Logic.hs revision 92dc581bf568c9e225aa9d0570ab0a4b6ebdab69
4b0a4c7dea0f67a233dcc42ce9bb18d36de109aeChristian Maeder{-# OPTIONS -fallow-undecidable-instances #-}
e47d29b522739fbf08aac80c6faa447dde113fbcChristian MaederModule : $Header$
11d6ec73ee5550e00cb56b221bdbeb709142e779Christian MaederDescription : central interface (type class) for logics in Hets
97018cf5fa25b494adffd7e9b4e87320dae6bf47Christian MaederCopyright : (c) Till Mossakowski, and Uni Bremen 2002-2006
f3cd81f98592d1dbf301f48af31677a6a0cc666aChristian MaederLicense : similar to LGPL, see HetCATS/LICENSE.txt or LIZENZ.txt
3f69b6948966979163bdfe8331c38833d5d90ecdChristian MaederMaintainer : till@informatik.uni-bremen.de
4b0a4c7dea0f67a233dcc42ce9bb18d36de109aeChristian MaederStability : provisional
b603f34b79bc0992e5d74f484e5bdc9f9c2346c6Christian MaederPortability : non-portable (various -fglasgow-exts extensions)
f3a94a197960e548ecd6520bb768cb0d547457bbChristian MaederCentral interface (type class) for logics in Hets
f3cd81f98592d1dbf301f48af31677a6a0cc666aChristian MaederProvides data structures for logics (with symbols). Logics are
ac142c1b088711f911018d8108a64be80b2f2a58Christian Maeder a type class with an /identity type/ (usually interpreted
ac142c1b088711f911018d8108a64be80b2f2a58Christian Maeder by a singleton set) which serves to treat logics as
ac142c1b088711f911018d8108a64be80b2f2a58Christian Maeder data. All the functions in the type class take the
ac142c1b088711f911018d8108a64be80b2f2a58Christian Maeder identity as first argument in order to determine the logic.
0216a1580abf46ed8981f25e89d6fd99b2944ac2Christian Maeder For logic (co)morphisms see "Logic.Comorphism"
0216a1580abf46ed8981f25e89d6fd99b2944ac2Christian Maeder This module uses multiparameter type classes with functional dependencies
1c67beb3720d0b84d8d71ee2012166a09be81fbdChristian Maeder (<http://www.haskell.org/haskellwiki/Functional_dependencies>)
1c67beb3720d0b84d8d71ee2012166a09be81fbdChristian Maeder for defining an interface for the notion of logic. Multiparameter type
1c67beb3720d0b84d8d71ee2012166a09be81fbdChristian Maeder classes are needed because a logic consists of a collection of types,
23f8d286586ff38a9e73052b2c7c04c62c5c638fChristian Maeder together with operations on these. Functional dependencies
e8ffec0fa3d3061061bdc16e44247b9cf96b050fChristian Maeder are needed because no operation will involve all types of
4b0a4c7dea0f67a233dcc42ce9bb18d36de109aeChristian Maeder the multiparameter type class; hence we need a method to derive
1c67beb3720d0b84d8d71ee2012166a09be81fbdChristian Maeder the missing types. We chose an easy way: for each logic, we
1c67beb3720d0b84d8d71ee2012166a09be81fbdChristian Maeder introduce a new singleton type that is the name, or constitutes the identity
975642b989852fc24119c59cf40bc1af653608ffChristian Maeder of the logic. All other types of the multiparameter type class
1c67beb3720d0b84d8d71ee2012166a09be81fbdChristian Maeder depend on this /identity constituting/ type, and all operations take
1c67beb3720d0b84d8d71ee2012166a09be81fbdChristian Maeder the 'identity constituting' type as first arguments. The value
62925f4a144f45b5ed1e7c841f891d13f51e553dChristian Maeder of the argument of the /identity constituting/ type is irrelevant
715ffaf874309df081d1e1cd8e05073fc1227729Christian Maeder (note that there is only one value of such a type anyway).
53301de22afd7190981b363b57c48df86fcb50f7Christian Maeder Note that we tend to use @lid@ both for the /identity type/
cdaff0507c1b7240e2660dbb311f9c4646a6d14aChristian Maeder of a logic, as well as for its unique inhabitant, i.e. @lid :: lid@.
ff9a53595208f532c25ac5168f772f48fd80fdb5Christian Maeder The other types involved in the definition of logic are as follows:
975642b989852fc24119c59cf40bc1af653608ffChristian Maeder * sign: signatures, that is, contexts, or non-logical vocabularies,
975642b989852fc24119c59cf40bc1af653608ffChristian Maeder typically consisting of a set of declared sorts, predicates,
e47d29b522739fbf08aac80c6faa447dde113fbcChristian Maeder function symbols, propositional letters etc., together with their
975642b989852fc24119c59cf40bc1af653608ffChristian Maeder * sentence: logical formulas.
975642b989852fc24119c59cf40bc1af653608ffChristian Maeder * basic_spec: abstract syntax of basic specifications. The latter are
975642b989852fc24119c59cf40bc1af653608ffChristian Maeder human-readable presentations of a signature together with some sentences.
b603f34b79bc0992e5d74f484e5bdc9f9c2346c6Christian Maeder * symbol: symbols that may occur in a signature, fully qualified
b603f34b79bc0992e5d74f484e5bdc9f9c2346c6Christian Maeder with their types
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder * raw_symbol: symbols that may occur in a signature, possibly not
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder or partially qualified
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder * morphism: maps between signatures (typically preserving the structure).
b603f34b79bc0992e5d74f484e5bdc9f9c2346c6Christian Maeder * symb_items: abstract syntax of symbol lists, used for declaring some
0216a1580abf46ed8981f25e89d6fd99b2944ac2Christian Maeder symbols of a signature as hidden.
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder * symb_map_items: abstract syntax of symbol maps, i.e. human-readable
53301de22afd7190981b363b57c48df86fcb50f7Christian Maeder presentations of signature morphisms.
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder * sublogics: sublogics of the given logic. This type might be a
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder record of Boolean flags, indicating whether some feature is
ff9a53595208f532c25ac5168f772f48fd80fdb5Christian Maeder present in the sublogi of not.
25612a7b3ce708909298d5426406592473880a20Christian Maeder * proof_tree: proof trees.
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maeder J. A. Goguen and R. M. Burstall
0216a1580abf46ed8981f25e89d6fd99b2944ac2Christian Maeder Institutions: Abstract Model Theory for Specification and
b603f34b79bc0992e5d74f484e5bdc9f9c2346c6Christian Maeder JACM 39, p. 95-146, 1992
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maeder (general notion of logic - model theory only)
ac142c1b088711f911018d8108a64be80b2f2a58Christian Maeder General Logics
ac142c1b088711f911018d8108a64be80b2f2a58Christian Maeder Logic Colloquium 87, p. 275-329, North Holland, 1989
ac142c1b088711f911018d8108a64be80b2f2a58Christian Maeder (general notion of logic - also proof theory;
0216a1580abf46ed8981f25e89d6fd99b2944ac2Christian Maeder notion of logic representation, called map there)
0216a1580abf46ed8981f25e89d6fd99b2944ac2Christian Maeder T. Mossakowski:
ac142c1b088711f911018d8108a64be80b2f2a58Christian Maeder Specification in an arbitrary institution with symbols
ac142c1b088711f911018d8108a64be80b2f2a58Christian Maeder 14th WADT 1999, LNCS 1827, p. 252-270
ac142c1b088711f911018d8108a64be80b2f2a58Christian Maeder (treatment of symbols and raw symbols, see also CASL semantics
0216a1580abf46ed8981f25e89d6fd99b2944ac2Christian Maeder in the CASL reference manual)
ac142c1b088711f911018d8108a64be80b2f2a58Christian Maeder T. Mossakowski, B. Klin:
ac142c1b088711f911018d8108a64be80b2f2a58Christian Maeder Institution Independent Static Analysis for CASL
ac142c1b088711f911018d8108a64be80b2f2a58Christian Maeder 15h WADT 2001, LNCS 2267, p. 221-237, 2002.
ac142c1b088711f911018d8108a64be80b2f2a58Christian Maeder (what is needed for static anaylsis)
0216a1580abf46ed8981f25e89d6fd99b2944ac2Christian Maeder S. Autexier and T. Mossakowski
ac142c1b088711f911018d8108a64be80b2f2a58Christian Maeder Integrating HOLCASL into the Development Graph Manager MAYA
0216a1580abf46ed8981f25e89d6fd99b2944ac2Christian Maeder FroCoS 2002, LNCS 2309, p. 2-17, 2002.
18b709ce961d68328da768318dcc70067f066d86Christian Maeder (interface to provers)
9c5b1136299d9052e4e995614a3a36a051a2682fChristian Maeder CoFI (ed.): CASL Reference Manual, LNCS 2960, Springer Verlag, 2004.
0216a1580abf46ed8981f25e89d6fd99b2944ac2Christian Maeder (static semantics of CASL structured and architectural specifications)
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maeder T. Mossakowski
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maeder Heterogeneous specification and the heterogeneous tool set
9c5b1136299d9052e4e995614a3a36a051a2682fChristian Maeder Habilitation thesis, University of Bremen, 2005
9c5b1136299d9052e4e995614a3a36a051a2682fChristian Maeder (the general picture of heterogeneous specification)
fe5dbb45b6a8abf34375b4bc5f2a81cda664c0e4Christian Maederimport Logic.Prover (Prover, ConsChecker, Theory(..))
797f811e57952d59e73b8cd03b667eef276db972Christian Maederimport Taxonomy.MMiSSOntology (MMiSSOntology)
369454f9b2dbea113cbb40544a9b0f31425b2c69Christian Maederimport Common.ATerm.Lib (ShATermConvertible)
b603f34b79bc0992e5d74f484e5bdc9f9c2346c6Christian Maederimport qualified Data.Set as Set
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maederimport qualified Data.Map as Map
5581c4644d91dcb9b7e2e7f6052f7cbf5f97b6deChristian Maeder-- | Stability of logic implementations
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maederdata Stability = Stable | Testing | Unstable | Experimental
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder deriving (Eq, Show)
b603f34b79bc0992e5d74f484e5bdc9f9c2346c6Christian Maeder-- | shortcut for class constraints
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maederclass (Show a, Pretty a, Typeable a, ShATermConvertible a)
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder => PrintTypeConv a
65835942d66905c377fa503e0d577df5aade58feChristian Maeder-- | shortcut for class constraints with equality
5581c4644d91dcb9b7e2e7f6052f7cbf5f97b6deChristian Maederclass (Eq a, PrintTypeConv a) => EqPrintTypeConv a
9c5b1136299d9052e4e995614a3a36a051a2682fChristian Maederinstance (Show a, Pretty a, Typeable a,
9c5b1136299d9052e4e995614a3a36a051a2682fChristian Maeder ShATermConvertible a) => PrintTypeConv a
5581c4644d91dcb9b7e2e7f6052f7cbf5f97b6deChristian Maederinstance (Eq a, PrintTypeConv a) => EqPrintTypeConv a
11d6ec73ee5550e00cb56b221bdbeb709142e779Christian Maeder-- | maps from a to a
9c5b1136299d9052e4e995614a3a36a051a2682fChristian Maedertype EndoMap a = Map.Map a a
ac142c1b088711f911018d8108a64be80b2f2a58Christian Maeder{- | the name of a logic.
fcec1ffa4a95dbc47cf23f75e6843ceff93a925eChristian Maeder Define instances like "data CASL = CASL deriving Show"
5581c4644d91dcb9b7e2e7f6052f7cbf5f97b6deChristian Maederclass Show lid => Language lid where
b52ad1aed6b1eb8b8416aaf100695f54ea59aea0Christian Maeder language_name :: lid -> String
5581c4644d91dcb9b7e2e7f6052f7cbf5f97b6deChristian Maeder language_name i = show i
5581c4644d91dcb9b7e2e7f6052f7cbf5f97b6deChristian Maeder description :: lid -> String
5581c4644d91dcb9b7e2e7f6052f7cbf5f97b6deChristian Maeder -- default implementation
5581c4644d91dcb9b7e2e7f6052f7cbf5f97b6deChristian Maeder description _ = "No description available"
b603f34b79bc0992e5d74f484e5bdc9f9c2346c6Christian Maeder{- | Categories are given as usual: objects, morphisms, identities,
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder domain, codomain and composition. The type id is the name, or
b52ad1aed6b1eb8b8416aaf100695f54ea59aea0Christian Maeder the identity of the category. It is an argument to all functions
65835942d66905c377fa503e0d577df5aade58feChristian Maeder of the type class, serving disambiguation among instances
65835942d66905c377fa503e0d577df5aade58feChristian Maeder (via the functional dependency lid -> object morphism).
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder The types for objects and morphisms may be restricted to
b603f34b79bc0992e5d74f484e5bdc9f9c2346c6Christian Maeder subtypes, using legal_obj and legal_mor. For example, for the
b603f34b79bc0992e5d74f484e5bdc9f9c2346c6Christian Maeder category of sets and injective maps, legal_mor would check
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder injectivity. Since Eq is a subclass of Category, it is also
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder possible to impose a quotient on the types for objects and morphisms.
b603f34b79bc0992e5d74f484e5bdc9f9c2346c6Christian Maederclass (Eq object, Eq morphism)
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder => Category object morphism | morphism -> object where
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder -- | identity morphisms
fcec1ffa4a95dbc47cf23f75e6843ceff93a925eChristian Maeder ide :: object -> morphism
5581c4644d91dcb9b7e2e7f6052f7cbf5f97b6deChristian Maeder -- | composition, in diagrammatic order
5581c4644d91dcb9b7e2e7f6052f7cbf5f97b6deChristian Maeder comp :: morphism -> morphism -> Result morphism
sym_of :: lid -> sign -> Set.Set symbol
sym_of _ _ = Set.empty
symmap_of _ _ = Map.empty
-- | a dummy static analysis function to allow type checking *.inline.hs files
-> Result (sign, Map.Map Int morphism)
lid -> Set.Set symbol -> sign -> Result morphism
-- | several provers can be provided. See module "Logic.Prover"
empty_theory lid = Theory (empty_signature lid) Map.empty