Sublogic.hs revision 0f67ca7b0c738a28f6688ba6e96d44d7c14af611
62ecb1e7f8fd9573eea8369657de12c7bf9f4f25Christian MaederModule : $Header$
97018cf5fa25b494adffd7e9b4e87320dae6bf47Christian MaederCopyright : (c) Pascal Schmidt, Christiantian Maeder, and Uni Bremen 2002-2003
bbae6e6ca0de7f2ffbb44d2c8da179f2b717237fChristian MaederLicence : similar to LGPL, see HetCATS/LICENCE.txt or LIZENZ.txt
bbae6e6ca0de7f2ffbb44d2c8da179f2b717237fChristian MaederMaintainer : hets@tzi.de
bbae6e6ca0de7f2ffbb44d2c8da179f2b717237fChristian MaederStability : experimental
f3a94a197960e548ecd6520bb768cb0d547457bbChristian MaederPortability : portable
bbae6e6ca0de7f2ffbb44d2c8da179f2b717237fChristian Maeder This module provides the sublogic functions (as required by Logic.hs) for
bbae6e6ca0de7f2ffbb44d2c8da179f2b717237fChristian Maeder HasCASL. The functions allow to compute the minimal sublogics needed by a
bbae6e6ca0de7f2ffbb44d2c8da179f2b717237fChristian Maeder given element, to check whether an item is part of a given sublogic, and --
bbae6e6ca0de7f2ffbb44d2c8da179f2b717237fChristian Maeder not yet -- to project an element into a given sublogic.
1d589334ba6b4a4cbfb35307a7a732261e77b0cdChristian Maedermodule HasCASL.Sublogic ( -- * datatypes
bbae6e6ca0de7f2ffbb44d2c8da179f2b717237fChristian Maeder HasCASL_Sublogics(..),
bbae6e6ca0de7f2ffbb44d2c8da179f2b717237fChristian Maeder HasCASL_Formulas(..),
5e26bfc8d7b18cf3a3fa7b919b4450fb669f37a5Christian Maeder -- * functions for LatticeWithTop instance
bbae6e6ca0de7f2ffbb44d2c8da179f2b717237fChristian Maeder sublogics_max,
5e26bfc8d7b18cf3a3fa7b919b4450fb669f37a5Christian Maeder sublogics_min,
715ffaf874309df081d1e1cd8e05073fc1227729Christian Maeder -- * functions for Logic instance
bbae6e6ca0de7f2ffbb44d2c8da179f2b717237fChristian Maeder -- * sublogic to string converstion
6e39bfd041946fce4982ac89834be73fd1bfb39aChristian Maeder sublogics_name,
62ecb1e7f8fd9573eea8369657de12c7bf9f4f25Christian Maeder -- * list of all sublogics
62ecb1e7f8fd9573eea8369657de12c7bf9f4f25Christian Maeder sublogics_all,
62ecb1e7f8fd9573eea8369657de12c7bf9f4f25Christian Maeder -- * checks if element is in given sublogic
6e39bfd041946fce4982ac89834be73fd1bfb39aChristian Maeder in_basicSpec,
6e39bfd041946fce4982ac89834be73fd1bfb39aChristian Maeder in_symbItems,
6e39bfd041946fce4982ac89834be73fd1bfb39aChristian Maeder in_symbMapItems,
62ecb1e7f8fd9573eea8369657de12c7bf9f4f25Christian Maeder -- * computes the sublogic of a given element
717686b54b9650402e2ebfbaadf433eab8ba5171Christian Maeder sl_basicSpec,
62ecb1e7f8fd9573eea8369657de12c7bf9f4f25Christian Maeder sl_symbItems,
62ecb1e7f8fd9573eea8369657de12c7bf9f4f25Christian Maeder sl_symbMapItems,
62ecb1e7f8fd9573eea8369657de12c7bf9f4f25Christian Maederimport qualified Common.Lib.Map as Map
b645cf3dc1e449038ed291bbd11fcc6e02b2fc7fChristian Maeder------------------------------------------------------------------------------
715ffaf874309df081d1e1cd8e05073fc1227729Christian Maeder-- | Datatypes for HasCASL sublogics
715ffaf874309df081d1e1cd8e05073fc1227729Christian Maeder------------------------------------------------------------------------------
715ffaf874309df081d1e1cd8e05073fc1227729Christian Maederdata HasCASL_Formulas = Atomic -- atomic logic
715ffaf874309df081d1e1cd8e05073fc1227729Christian Maeder | Horn -- positive conditional logic
715ffaf874309df081d1e1cd8e05073fc1227729Christian Maeder | GHorn -- generalized positive conditional logic
715ffaf874309df081d1e1cd8e05073fc1227729Christian Maeder | FOL -- first-order logic
715ffaf874309df081d1e1cd8e05073fc1227729Christian Maeder | HOL -- higher-order logic
715ffaf874309df081d1e1cd8e05073fc1227729Christian Maeder deriving (Show,Ord,Eq)
715ffaf874309df081d1e1cd8e05073fc1227729Christian Maederdata HasCASL_Sublogics = HasCASL_SL
2a598ff0c1b7b51c33aee7029b43bc5cfcbea6b8Christian Maeder { has_sub :: Bool, -- subsorting
6e39bfd041946fce4982ac89834be73fd1bfb39aChristian Maeder has_part :: Bool, -- partiality
62ecb1e7f8fd9573eea8369657de12c7bf9f4f25Christian Maeder has_eq :: Bool, -- equality
ccf3de3d66b521a260e5c22d335c64a48e3f0195Christian Maeder has_pred :: Bool, -- predicates
ccf3de3d66b521a260e5c22d335c64a48e3f0195Christian Maeder has_ho :: Bool, -- higher order
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder has_type_classes :: Bool,
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder has_polymorphism :: Bool,
dfa74d066ea0f00a70276aedecc624c6b3c86deaChristian Maeder has_type_constructors :: Bool,
ccf3de3d66b521a260e5c22d335c64a48e3f0195Christian Maeder which_logic::HasCASL_Formulas
2a598ff0c1b7b51c33aee7029b43bc5cfcbea6b8Christian Maeder } deriving (Show,Ord,Eq)
2a598ff0c1b7b51c33aee7029b43bc5cfcbea6b8Christian Maeder-----------------------------------------------------------------------------
2a598ff0c1b7b51c33aee7029b43bc5cfcbea6b8Christian Maeder-- Special sublogics elements
2a598ff0c1b7b51c33aee7029b43bc5cfcbea6b8Christian Maeder-----------------------------------------------------------------------------
2a598ff0c1b7b51c33aee7029b43bc5cfcbea6b8Christian Maeder-- top element
2a598ff0c1b7b51c33aee7029b43bc5cfcbea6b8Christian Maedertop :: HasCASL_Sublogics
6e39bfd041946fce4982ac89834be73fd1bfb39aChristian Maedertop = (HasCASL_SL True True True True True True True True HOL)
715ffaf874309df081d1e1cd8e05073fc1227729Christian Maeder-- bottom element
3c62e6ef442caf092adcbecf6fccd957dcd72689Christian Maederbottom :: HasCASL_Sublogics
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maederbottom = (HasCASL_SL False False False False False False False False Atomic)
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder-- the following are used to add a needed feature to a given
715ffaf874309df081d1e1cd8e05073fc1227729Christian Maeder-- sublogic via sublogics_max, i.e. (sublogics_max given needs_part)
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder-- will force partiality in addition to what features given already
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder-- has included
62ecb1e7f8fd9573eea8369657de12c7bf9f4f25Christian Maeder-- minimal sublogic with subsorting
715ffaf874309df081d1e1cd8e05073fc1227729Christian Maederneed_sub :: HasCASL_Sublogics
6e39bfd041946fce4982ac89834be73fd1bfb39aChristian Maederneed_sub = bottom { has_sub = True }
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maeder-- minimal sublogic with partiality
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maederneed_part :: HasCASL_Sublogics
5e26bfc8d7b18cf3a3fa7b919b4450fb669f37a5Christian Maederneed_part = bottom { has_part = True }
836e72a3c413366ba9801726f3b249c7791cb9caChristian Maeder-- minimal sublogic with equality
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maederneed_eq :: HasCASL_Sublogics
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maederneed_eq = bottom { has_eq = True }
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maeder-- minimal sublogic with predicates
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maederneed_pred :: HasCASL_Sublogics
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maederneed_pred = bottom { has_pred = True }
5e26bfc8d7b18cf3a3fa7b919b4450fb669f37a5Christian Maeder-- minimal sublogic with higher order
5e26bfc8d7b18cf3a3fa7b919b4450fb669f37a5Christian Maederneed_ho :: HasCASL_Sublogics
bbae6e6ca0de7f2ffbb44d2c8da179f2b717237fChristian Maederneed_ho = bottom { has_ho = True }
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder-- minimal sublogic with type classes
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maederneed_type_classes :: HasCASL_Sublogics
5e26bfc8d7b18cf3a3fa7b919b4450fb669f37a5Christian Maederneed_type_classes = bottom { has_type_classes = True }
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maeder-- minimal sublogic with polymorhism
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maederneed_polymorphism :: HasCASL_Sublogics
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maederneed_polymorphism = bottom { has_polymorphism = True }
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maeder-- minimal sublogic with type constructors
5e26bfc8d7b18cf3a3fa7b919b4450fb669f37a5Christian Maederneed_type_constructors :: HasCASL_Sublogics
bbae6e6ca0de7f2ffbb44d2c8da179f2b717237fChristian Maederneed_type_constructors = bottom { has_type_constructors = True }
6e39bfd041946fce4982ac89834be73fd1bfb39aChristian Maederneed_horn :: HasCASL_Sublogics
149e43c4a2705a86a0e5fa301ba849fdf19db32eChristian Maederneed_horn = bottom { which_logic = Horn }
1738d16957389457347bee85075d3d33d002158fChristian Maederneed_ghorn :: HasCASL_Sublogics
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maederneed_ghorn = bottom { which_logic = GHorn }
33a5d53a412ba0a4e5847f7538d6da2e22bd116cChristian Maederneed_fol :: HasCASL_Sublogics
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maederneed_fol = bottom { which_logic = FOL }
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maederneed_hol :: HasCASL_Sublogics
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maederneed_hol = bottom { which_logic = HOL }
b645cf3dc1e449038ed291bbd11fcc6e02b2fc7fChristian Maeder-----------------------------------------------------------------------------
5e26bfc8d7b18cf3a3fa7b919b4450fb669f37a5Christian Maeder-- Functions to generate a list of all sublogics for HasCASL
1d589334ba6b4a4cbfb35307a7a732261e77b0cdChristian Maeder-----------------------------------------------------------------------------
88ece6e49930670e8fd3ee79c89a2e918d2fbd0cChristian Maedersublogics_all :: [HasCASL_Sublogics]
1d589334ba6b4a4cbfb35307a7a732261e77b0cdChristian Maedersublogics_all = [HasCASL_SL {has_sub = sub,
1d589334ba6b4a4cbfb35307a7a732261e77b0cdChristian Maeder has_part = part,
88ece6e49930670e8fd3ee79c89a2e918d2fbd0cChristian Maeder has_pred = pre,
1d589334ba6b4a4cbfb35307a7a732261e77b0cdChristian Maeder has_type_classes = tyCl,
1d589334ba6b4a4cbfb35307a7a732261e77b0cdChristian Maeder has_polymorphism = poly,
1d589334ba6b4a4cbfb35307a7a732261e77b0cdChristian Maeder has_type_constructors = tyCon,
1d589334ba6b4a4cbfb35307a7a732261e77b0cdChristian Maeder which_logic = logic}
1d589334ba6b4a4cbfb35307a7a732261e77b0cdChristian Maeder | sub <- [False,True],
88ece6e49930670e8fd3ee79c89a2e918d2fbd0cChristian Maeder part <- [False,True],
1d589334ba6b4a4cbfb35307a7a732261e77b0cdChristian Maeder eq <- [False,True],
1d589334ba6b4a4cbfb35307a7a732261e77b0cdChristian Maeder pre <- [False,True],
1d589334ba6b4a4cbfb35307a7a732261e77b0cdChristian Maeder ho <- [False,True],
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder tyCl <- [False,True],
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder poly <- [False,True],
1d589334ba6b4a4cbfb35307a7a732261e77b0cdChristian Maeder tyCon <- [False,True],
1d589334ba6b4a4cbfb35307a7a732261e77b0cdChristian Maeder logic <- [Atomic, Horn, GHorn, FOL, HOL] ]
88ece6e49930670e8fd3ee79c89a2e918d2fbd0cChristian Maeder------------------------------------------------------------------------------
1d589334ba6b4a4cbfb35307a7a732261e77b0cdChristian Maeder-- Conversion functions (to String)
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder------------------------------------------------------------------------------
1d589334ba6b4a4cbfb35307a7a732261e77b0cdChristian Maeder-- "formulas_name :: has_pred -> has_ho -> which_logic -> String"
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maederformulas_name :: Bool -> Bool -> HasCASL_Formulas -> String
1d589334ba6b4a4cbfb35307a7a732261e77b0cdChristian Maederformulas_name True True HOL = "HOL"
1d589334ba6b4a4cbfb35307a7a732261e77b0cdChristian Maederformulas_name True False HOL = "HOL" -- ?!
1d589334ba6b4a4cbfb35307a7a732261e77b0cdChristian Maederformulas_name False True HOL = "HOL"
1d589334ba6b4a4cbfb35307a7a732261e77b0cdChristian Maederformulas_name False False HOL = "HOL" -- ?!
1d589334ba6b4a4cbfb35307a7a732261e77b0cdChristian Maederformulas_name True True FOL = "HOL" -- ?!
88ece6e49930670e8fd3ee79c89a2e918d2fbd0cChristian Maederformulas_name True False FOL = "FOL"
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maederformulas_name False True FOL = "HO-FOAlg" -- ?!
They are adapted for HasCASL, especially HasCASLs abstract syntax (As.hs)
no lambda/let/case,
no higher types (i.e. all types are basic, tuples, or tuple -> basic)
no higher types (i.e. all types are basic, tuples, or tuple -> basic)
let classes = if Map.isEmpty $ classMap e
types = comp_list $ map sl_typeInfo (Map.elems (typeMap e))
ops = comp_list $ map sl_opInfos (Map.elems (assumps e))
-- check if a "new" sublogic is contained in/equal to a given