Logic.hs revision 4b479bc5f0136c43d7d7da9502556cb940818efb
306763c67bb99228487345b32ab8c5c6cd41f23cChristian Maeder-- needs ghc -fglasgow-exts
306763c67bb99228487345b32ab8c5c6cd41f23cChristian Maeder Till Mossakowski
306763c67bb99228487345b32ab8c5c6cd41f23cChristian Maeder Provides data structures for logics (with symbols)
306763c67bb99228487345b32ab8c5c6cd41f23cChristian Maeder and logic representations. Logics are
306763c67bb99228487345b32ab8c5c6cd41f23cChristian Maeder a type class with an "identitiy" type (usually interpreted
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski by a singleton set) which serves to treat logics as
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski data. All the functions in the type class take the
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski identity as first argument in order to determine the logic.
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski Logic representations are just collections of
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski functions between (some of) the types of logics.
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski J. A. Goguen and R. M. Burstall
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski Institutions: Abstract Model Theory for Specification and
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski JACM 39, p. 95--146, 1992
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski (general notion of logic - model theory only)
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski General Logics
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski Logic Colloquium 87, p. 275--329, North Holland, 1989
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski (general notion of logic - also proof theory;
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski notion of logic representation, called map there)
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski T. Mossakowski:
38f350357e92da312d2c344352180b3dc5c1fc8aTill Mossakowski Specification in an arbitrary institution with symbols
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski 14th WADT 1999, LNCS 1827, p. 252--270
425b287f28abf82702d46c176a38b668fb017ce4Felix Reckers (treatment of symbols and raw symbols, see also CASL semantics)
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski T. Mossakowski, B. Klin:
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski Institution Independent Static Analysis for CASL
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski 15h WADT 2001, LNCS
59fa9b1349ae1e001d996da732c4ac805c2938e2Christian Maeder (what is needed for static anaylsis)
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski S. Autexier and T. Mossakowski
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski Integrating HOLCASL into the Development Graph Manager MAYA
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski FroCoS 2002, to appear
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski (interface to provers)
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski Should annotations be globally fixed?
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski Sublanguages more abstractly (lattice)
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski Weak amalgamability
d85e3f253f6af237c4b70bbfacb1bfecb5cfa678Christian Maedermodule Logic where
4184cb191a9081cb2a9cf3ef5f060f56f0ca5922Till Mossakowski-- maps and sets, just a quick thing
4184cb191a9081cb2a9cf3ef5f060f56f0ca5922Till Mossakowskitype Set a = [a]
8731f7b93b26083dc34a2c0937cd6493b42f2c2cTill Mossakowskitype Map a = [(a,a)]
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski-- diagrams, nodes are just integers
38f350357e92da312d2c344352180b3dc5c1fc8aTill Mossakowskitype Node = Int
5d6e7ea3bd14fc987436cff0f542393ea9ba34bbTill Mossakowskitype Edge morphism = (Node,morphism,Node)
5d6e7ea3bd14fc987436cff0f542393ea9ba34bbTill Mossakowskidata Diagram object morphism = Diagram [(Node,object)] [Edge morphism]
9a36df4f63e0214bc0b4aef9b388c8d4e48632bbTill Mossakowskiempty_diagram :: Diagram o m
9a36df4f63e0214bc0b4aef9b388c8d4e48632bbTill Mossakowskiempty_diagram = Diagram [] []
5d6e7ea3bd14fc987436cff0f542393ea9ba34bbTill Mossakowskiadd_node :: Diagram o m -> o -> (Node,Diagram o m)
5d6e7ea3bd14fc987436cff0f542393ea9ba34bbTill Mossakowskiadd_node (Diagram nodes edges) obj =
5d6e7ea3bd14fc987436cff0f542393ea9ba34bbTill Mossakowski (node,Diagram ((node,obj):nodes) edges) where
5d6e7ea3bd14fc987436cff0f542393ea9ba34bbTill Mossakowski node = maximum (map fst nodes)
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowskiadd_edge :: Diagram o m -> Edge m -> Diagram o m
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowskiadd_edge (Diagram nodes edges) edge =
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski Diagram nodes (edge:edges)
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowskiobject_at_node :: Node -> Diagram o m -> Maybe (Node,o)
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowskiobject_at_node node (Diagram nodes edges) =
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski case lookup node nodes of
425b287f28abf82702d46c176a38b668fb017ce4Felix Reckers Just obj -> Just (node,obj)
d85e3f253f6af237c4b70bbfacb1bfecb5cfa678Christian Maeder Nothing -> Nothing
425b287f28abf82702d46c176a38b668fb017ce4Felix Reckersdiagram_nodes :: Diagram o m -> [(Node,o)]
d85e3f253f6af237c4b70bbfacb1bfecb5cfa678Christian Maederdiagram_nodes (Diagram nodes edges) = nodes
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowskidiagram_edges :: Diagram o m -> [Edge m]
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowskidiagram_edges (Diagram nodes edges) = edges
8db2d2c5a8df6dd6d7302bc59577150b87237940Till Mossakowski-- identifiers, fixed for all logics
8db2d2c5a8df6dd6d7302bc59577150b87237940Till Mossakowskidata ID = Simple_Id String
59fa9b1349ae1e001d996da732c4ac805c2938e2Christian Maeder | Compound_Id (String,[ID])
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski-- Categories are given by a quotient,
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski-- i.e. we need equality
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski-- Should we allow arbitrary composition graphs and build paths?
230a51f3c282a3222d1cf40c2040fee19259964eTill Mossakowskiclass (Eq object, Eq morphism) =>
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski Category id object morphism | id ->, id -> morphism where
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski ide :: id -> object -> morphism
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski o :: id -> morphism -> morphism -> Maybe morphism
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski dom, cod :: id -> morphism -> object
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski legal_obj :: id -> object -> Bool
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski legal_mor :: id -> morphism -> Bool
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski-- abstract syntax, parsing and printing
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowskiclass (Read basic_spec, Read sentence, Read symb_items,
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski Read symb_map_items, Read anno,
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski Show basic_spec, Show sentence, Show symb_items,
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski Show symb_map_items, Show anno) =>
5e21bb46b24f477dafad6fdeff51aed7aaad0a47Till Mossakowski Syntax basic_spec sentence symb_items symb_map_items anno
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowskidata Sublogic basic_spec sentence symb_items symb_map_items anno
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski sign morphism symbol raw_symbol =
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski Sublogic {sublogic_name :: String,
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski is_in_basic_spec :: basic_spec -> Bool,
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski is_in_sentence :: sentence -> Bool,
d85e3f253f6af237c4b70bbfacb1bfecb5cfa678Christian Maeder is_in_symb_items :: symb_items -> Bool,
d85e3f253f6af237c4b70bbfacb1bfecb5cfa678Christian Maeder is_in_symb_map_items :: symb_map_items -> Bool,
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski is_in_anno :: anno -> Bool,
8db2d2c5a8df6dd6d7302bc59577150b87237940Till Mossakowski is_in_sign :: sign -> Bool,
d85e3f253f6af237c4b70bbfacb1bfecb5cfa678Christian Maeder is_in_morphism :: morphism -> Bool,
59fa9b1349ae1e001d996da732c4ac805c2938e2Christian Maeder is_in_symbol :: symbol -> Bool,
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski is_in_raw_symbol :: raw_symbol -> Bool
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski-- theories and theory morphisms
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowskidata Theory sign sen =
d85e3f253f6af237c4b70bbfacb1bfecb5cfa678Christian Maeder Theory {sign_of :: sign,
d85e3f253f6af237c4b70bbfacb1bfecb5cfa678Christian Maeder ax_of :: [(String,sen)]
d85e3f253f6af237c4b70bbfacb1bfecb5cfa678Christian Maederdata TheoryMorphism sign sen mor =
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski TheoryMorphism {t_source, t_target :: Theory sign sen,
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski t_morphism :: mor
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski-- proofs and provers
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowskitype Rule = String
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowskidata Proof_tree sen = Axiom sen
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski | Branch (sen,Rule,[Proof_tree sen]) -- add substitutions here?
d85e3f253f6af237c4b70bbfacb1bfecb5cfa678Christian Maedertype Tactic_script = String -- the file name
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowskidata Proof_status sen = Open sen
d85e3f253f6af237c4b70bbfacb1bfecb5cfa678Christian Maeder | Disproved sen
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski | Proved(sen,[sen],Proof_tree sen,Tactic_script)
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowskidata Prover sen symbol =
d85e3f253f6af237c4b70bbfacb1bfecb5cfa678Christian Maeder Prover { prover_name :: String,
f7819aa9d183836144a98c70d4fa7d65e31cb513Till Mossakowski prover_sublogic :: String,
f7819aa9d183836144a98c70d4fa7d65e31cb513Till Mossakowski add_sym :: symbol -> IO(Bool), -- returns True if succeeded
f7819aa9d183836144a98c70d4fa7d65e31cb513Till Mossakowski remove_sym :: symbol -> IO(Bool), -- returns True if succeeded
f7819aa9d183836144a98c70d4fa7d65e31cb513Till Mossakowski prove :: sen -> IO([Proof_status sen]) -- proof status for goal and lemmas
8731f7b93b26083dc34a2c0937cd6493b42f2c2cTill Mossakowskidata Cons_checker morphism =
8731f7b93b26083dc34a2c0937cd6493b42f2c2cTill Mossakowski Cons_checker {cons_checker_name :: String,
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski cons_checker_sublogic :: String,
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski cons_check :: morphism -> IO(Bool, Tactic_script)
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowskiclass (Syntax basic_spec sentence symb_items symb_map_items anno,
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski Show sign, Show morphism, Show symbol, Show raw_symbol,
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski Ord symbol, -- needed for efficient symbol tables
d85e3f253f6af237c4b70bbfacb1bfecb5cfa678Christian Maeder Category id sign morphism) =>
d85e3f253f6af237c4b70bbfacb1bfecb5cfa678Christian Maeder basic_spec sentence symb_items symb_map_items anno
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski sign morphism symbol raw_symbol
38f350357e92da312d2c344352180b3dc5c1fc8aTill Mossakowski | id -> basic_spec, id -> sentence, id -> symb_items,
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski id -> symb_map_items, id -> anno,
5bb3727ef464d9f08ab0decb2d4a59c1352a389eChristian Maeder id -> sign, id -> morphism, id ->symbol, id -> raw_symbol
5bb3727ef464d9f08ab0decb2d4a59c1352a389eChristian Maeder -- static analysis of basic specifications and symbol maps
5bb3727ef464d9f08ab0decb2d4a59c1352a389eChristian Maeder basic_analysis :: id ->
5bb3727ef464d9f08ab0decb2d4a59c1352a389eChristian Maeder (basic_spec,sign,[anno]) ->
d85e3f253f6af237c4b70bbfacb1bfecb5cfa678Christian Maeder (sign,[(String,sentence)])
d85e3f253f6af237c4b70bbfacb1bfecb5cfa678Christian Maeder stat_symb_map_items :: id -> [symb_map_items] -> Map raw_symbol
d85e3f253f6af237c4b70bbfacb1bfecb5cfa678Christian Maeder stat_symb_items :: id -> [symb_items] -> [raw_symbol]
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski -- architectural sharing analysis for one morphism
d85e3f253f6af237c4b70bbfacb1bfecb5cfa678Christian Maeder ensures_amalgamability :: id ->
d85e3f253f6af237c4b70bbfacb1bfecb5cfa678Christian Maeder (Diagram sign morphism, Node, sign, Edge morphism, morphism) ->
d85e3f253f6af237c4b70bbfacb1bfecb5cfa678Christian Maeder Diagram sign morphism
d85e3f253f6af237c4b70bbfacb1bfecb5cfa678Christian Maeder -- do we need it also for sinks consisting of two morphisms?