Logic.hs revision f42a5ef19b4201900cbb62af61b3911bb07bc17d
c7e03d0708369f944b6f235057b39142a21599f2Mihai Codescu{-# OPTIONS -fallow-undecidable-instances #-}
c7e03d0708369f944b6f235057b39142a21599f2Mihai CodescuModule : $Header$
c7e03d0708369f944b6f235057b39142a21599f2Mihai CodescuDescription : central interface (type class) for logics in Hets
98890889ffb2e8f6f722b00e265a211f13b5a861Corneliu-Claudiu ProdescuCopyright : (c) Till Mossakowski, and Uni Bremen 2002-2006
c7e03d0708369f944b6f235057b39142a21599f2Mihai CodescuLicense : similar to LGPL, see HetCATS/LICENSE.txt or LIZENZ.txt
c7e03d0708369f944b6f235057b39142a21599f2Mihai CodescuMaintainer : till@tzi.de
402ffc909b645ddb2d5c76343bf74a6cb33c6205Christian MaederStability : provisional
c7e03d0708369f944b6f235057b39142a21599f2Mihai CodescuPortability : non-portable (various -fglasgow-exts extensions)
c7e03d0708369f944b6f235057b39142a21599f2Mihai CodescuCentral interface (type class) for logics in Hets
c7e03d0708369f944b6f235057b39142a21599f2Mihai CodescuProvides data structures for logics (with symbols). Logics are
c7e03d0708369f944b6f235057b39142a21599f2Mihai Codescu a type class with an /identity/ type (usually interpreted
142cf75c6377873ccc72450202fe7f0df94a6dffMihai Codescu by a singleton set) which serves to treat logics as
142cf75c6377873ccc72450202fe7f0df94a6dffMihai Codescu data. All the functions in the type class take the
c7e03d0708369f944b6f235057b39142a21599f2Mihai Codescu identity as first argument in order to determine the logic.
3d3889e0cefcdce9b3f43c53aaa201943ac2e895Jonathan von Schroeder For logic (co)morphisms see "Logic.Comorphism"
392634badbe11a21c7825ee0e1ee132220a2539eMihai Codescu This module uses multiparameter type classes
3d3889e0cefcdce9b3f43c53aaa201943ac2e895Jonathan von Schroeder (<http://haskell.org/ghc/docs/latest/html/users_guide/type-extensions.html#multi-param-type-classes>)
142cf75c6377873ccc72450202fe7f0df94a6dffMihai Codescu with functional dependencies (<http://haskell.org/hawiki/FunDeps>)
142cf75c6377873ccc72450202fe7f0df94a6dffMihai Codescu for defining an interface for the notion of logic. Multiparameter type
c7e03d0708369f944b6f235057b39142a21599f2Mihai Codescu classes are needed because a logic consists of a collection of types,
5418aa59492005c2ca40436ab84c4029cd2922a5Christian Maeder together with operations on these. Functional dependencies
80875f917d741946a39d0ec0b5721e46ba609823Till Mossakowski are needed because no operation will involve all types of
c7e03d0708369f944b6f235057b39142a21599f2Mihai Codescu the multiparameter type class; hence we need a method to derive
5418aa59492005c2ca40436ab84c4029cd2922a5Christian Maeder the missing types. We chose an easy way: for each logic, we
5418aa59492005c2ca40436ab84c4029cd2922a5Christian Maeder introduce a new singleton type that constitutes the identity
c7e03d0708369f944b6f235057b39142a21599f2Mihai Codescu of the logic. All other types of the multiparameter type class
c7e03d0708369f944b6f235057b39142a21599f2Mihai Codescu depend on this 'identy constituting' type, and all operations take
c7e03d0708369f944b6f235057b39142a21599f2Mihai Codescu the 'identity constituting' type as first arguments. The value
3bc502518f75cd5a21aa2f608a31f50c19134db0Christian Maeder of the argument of the 'identity constituting' type is irrelevant
142cf75c6377873ccc72450202fe7f0df94a6dffMihai Codescu (note that there is only one value of such a type anyway).
7b5ba6a2f3990cf508f90e55e1d59068e6aaa6a3Mihai Codescu J. A. Goguen and R. M. Burstall
7b5ba6a2f3990cf508f90e55e1d59068e6aaa6a3Mihai Codescu Institutions: Abstract Model Theory for Specification and
7b5ba6a2f3990cf508f90e55e1d59068e6aaa6a3Mihai Codescu JACM 39, p. 95--146, 1992
7b5ba6a2f3990cf508f90e55e1d59068e6aaa6a3Mihai Codescu (general notion of logic - model theory only)
142cf75c6377873ccc72450202fe7f0df94a6dffMihai Codescu General Logics
142cf75c6377873ccc72450202fe7f0df94a6dffMihai Codescu Logic Colloquium 87, p. 275--329, North Holland, 1989
142cf75c6377873ccc72450202fe7f0df94a6dffMihai Codescu (general notion of logic - also entailment\/proof theory;
3d3889e0cefcdce9b3f43c53aaa201943ac2e895Jonathan von Schroeder notion of logic representation, called map there)
142cf75c6377873ccc72450202fe7f0df94a6dffMihai Codescu T. Mossakowski:
142cf75c6377873ccc72450202fe7f0df94a6dffMihai Codescu Specification in an arbitrary institution with symbols
3d3889e0cefcdce9b3f43c53aaa201943ac2e895Jonathan von Schroeder 14th WADT 1999, LNCS 1827, p. 252--270
142cf75c6377873ccc72450202fe7f0df94a6dffMihai Codescu (treatment of symbols and raw symbols, see also CASL semantics
142cf75c6377873ccc72450202fe7f0df94a6dffMihai Codescu in the CASL reference manual)
142cf75c6377873ccc72450202fe7f0df94a6dffMihai Codescu T. Mossakowski, B. Klin:
142cf75c6377873ccc72450202fe7f0df94a6dffMihai Codescu Institution Independent Static Analysis for CASL
142cf75c6377873ccc72450202fe7f0df94a6dffMihai Codescu 15h WADT 2001, LNCS 2267, p. 221-237, 2002.
142cf75c6377873ccc72450202fe7f0df94a6dffMihai Codescu (what is needed for static anaylsis)
142cf75c6377873ccc72450202fe7f0df94a6dffMihai Codescu S. Autexier and T. Mossakowski
142cf75c6377873ccc72450202fe7f0df94a6dffMihai Codescu Integrating HOLCASL into the Development Graph Manager MAYA
142cf75c6377873ccc72450202fe7f0df94a6dffMihai Codescu FroCoS 2002, LNCS 2309, p. 2-17, 2002.
142cf75c6377873ccc72450202fe7f0df94a6dffMihai Codescu (interface to provers)
142cf75c6377873ccc72450202fe7f0df94a6dffMihai Codescu CoFI (ed.): CASL Reference Manual, LNCS 2960, Springer Verlag, 2004.
142cf75c6377873ccc72450202fe7f0df94a6dffMihai Codescu (static semantics of CASL structured and architectural specifications)
142cf75c6377873ccc72450202fe7f0df94a6dffMihai Codescu T. Mossakowski
142cf75c6377873ccc72450202fe7f0df94a6dffMihai Codescu Heterogeneous specification and the heterogeneous tool set
142cf75c6377873ccc72450202fe7f0df94a6dffMihai Codescu Habilitation thesis, University of Bremen, 2005
142cf75c6377873ccc72450202fe7f0df94a6dffMihai Codescu (the general picture of heterogeneous specification)
142cf75c6377873ccc72450202fe7f0df94a6dffMihai Codescuimport qualified Common.Lib.Set as Set
142cf75c6377873ccc72450202fe7f0df94a6dffMihai Codescuimport qualified Common.Lib.Map as Map
142cf75c6377873ccc72450202fe7f0df94a6dffMihai Codescuimport Logic.Prover -- for one half of class Sentences
142cf75c6377873ccc72450202fe7f0df94a6dffMihai Codescuimport Common.ATerm.Lib -- (ShATermConvertible)
142cf75c6377873ccc72450202fe7f0df94a6dffMihai Codescuimport Common.Amalgamate -- passed to ensures_amalgamability
3d3889e0cefcdce9b3f43c53aaa201943ac2e895Jonathan von Schroederimport Taxonomy.MMiSSOntology (MMiSSOntology)
3d3889e0cefcdce9b3f43c53aaa201943ac2e895Jonathan von Schroeder-- | Stability of logic implementations
142cf75c6377873ccc72450202fe7f0df94a6dffMihai Codescudata Stability = Stable | Testing | Unstable | Experimental
3d3889e0cefcdce9b3f43c53aaa201943ac2e895Jonathan von Schroeder deriving (Eq, Show)
142cf75c6377873ccc72450202fe7f0df94a6dffMihai Codescu-- | shortcut for class constraints
3d3889e0cefcdce9b3f43c53aaa201943ac2e895Jonathan von Schroederclass (Show a, Pretty a, Typeable a, ShATermConvertible a)
3d3889e0cefcdce9b3f43c53aaa201943ac2e895Jonathan von Schroeder => PrintTypeConv a
142cf75c6377873ccc72450202fe7f0df94a6dffMihai Codescu-- | shortcut for class constraints with equality
142cf75c6377873ccc72450202fe7f0df94a6dffMihai Codescuclass (Eq a, PrintTypeConv a) => EqPrintTypeConv a
96d8cf9817eeb0d26cba09ca192fc5a33e27bc09mcodescuinstance (Show a, Pretty a, Typeable a,
142cf75c6377873ccc72450202fe7f0df94a6dffMihai Codescu ShATermConvertible a) => PrintTypeConv a
803425dfe6a5da41b9cea480788980fa104545adMihai Codescuinstance (Eq a, PrintTypeConv a) => EqPrintTypeConv a
803425dfe6a5da41b9cea480788980fa104545adMihai Codescu-- | maps from a to a
80875f917d741946a39d0ec0b5721e46ba609823Till Mossakowskitype EndoMap a = Map.Map a a
80875f917d741946a39d0ec0b5721e46ba609823Till Mossakowski{- | the name of a logic.
803425dfe6a5da41b9cea480788980fa104545adMihai Codescu Define instances like "data CASL = CASL deriving Show"
803425dfe6a5da41b9cea480788980fa104545adMihai Codescuclass Show lid => Language lid where
803425dfe6a5da41b9cea480788980fa104545adMihai Codescu language_name :: lid -> String
3d3889e0cefcdce9b3f43c53aaa201943ac2e895Jonathan von Schroeder language_name i = show i
3d3889e0cefcdce9b3f43c53aaa201943ac2e895Jonathan von Schroeder description :: lid -> String
803425dfe6a5da41b9cea480788980fa104545adMihai Codescu -- default implementation
803425dfe6a5da41b9cea480788980fa104545adMihai Codescu description _ = "No description available"
803425dfe6a5da41b9cea480788980fa104545adMihai Codescu{- | Categories are given as usual: objects, morphisms, identities,
803425dfe6a5da41b9cea480788980fa104545adMihai Codescu domain, codomain and composition. The type id is the name, or
803425dfe6a5da41b9cea480788980fa104545adMihai Codescu the identity of the category. It is an argument to all functions
3d3889e0cefcdce9b3f43c53aaa201943ac2e895Jonathan von Schroeder of the type class, serving disambiguation among instances
3d3889e0cefcdce9b3f43c53aaa201943ac2e895Jonathan von Schroeder (via the functional dependency lid -> sign morphism).
b7f625188b6bf3d708b2a1b64a6cea7880708adbChristian Maeder The types for objects and morphisms may be restricted to
803425dfe6a5da41b9cea480788980fa104545adMihai Codescu subtypes, using legal_obj and legal_mor. For example, for the
803425dfe6a5da41b9cea480788980fa104545adMihai Codescu category of sets and injective maps, legal_mor would check
803425dfe6a5da41b9cea480788980fa104545adMihai Codescu injectivity. Since Eq is a subclass of Category, it is also
803425dfe6a5da41b9cea480788980fa104545adMihai Codescu possible to impose a quotient on the types for objects and morphisms.
803425dfe6a5da41b9cea480788980fa104545adMihai Codescuclass (Language lid, Eq sign, Eq morphism)
3d3889e0cefcdce9b3f43c53aaa201943ac2e895Jonathan von Schroeder => Category lid sign morphism | lid -> sign morphism where
96d8cf9817eeb0d26cba09ca192fc5a33e27bc09mcodescu -- | identity morphisms
96d8cf9817eeb0d26cba09ca192fc5a33e27bc09mcodescu ide :: lid -> sign -> morphism
803425dfe6a5da41b9cea480788980fa104545adMihai Codescu -- | composition, in diagrammatic order
803425dfe6a5da41b9cea480788980fa104545adMihai Codescu comp :: lid -> morphism -> morphism -> Result morphism
96d8cf9817eeb0d26cba09ca192fc5a33e27bc09mcodescu -- | domain and codomain of morphisms
b7f625188b6bf3d708b2a1b64a6cea7880708adbChristian Maeder dom, cod :: lid -> morphism -> sign
b7f625188b6bf3d708b2a1b64a6cea7880708adbChristian Maeder -- | is a value of type sign denoting a legal signature?
3d3889e0cefcdce9b3f43c53aaa201943ac2e895Jonathan von Schroeder legal_obj :: lid -> sign -> Bool
3d3889e0cefcdce9b3f43c53aaa201943ac2e895Jonathan von Schroeder -- | is a value of type morphism denoting a legal signature morphism?
803425dfe6a5da41b9cea480788980fa104545adMihai Codescu legal_mor :: lid -> morphism -> Bool
803425dfe6a5da41b9cea480788980fa104545adMihai Codescu{- | Abstract syntax, parsing and printing.
803425dfe6a5da41b9cea480788980fa104545adMihai Codescu There are three types for abstract syntax:
3d3889e0cefcdce9b3f43c53aaa201943ac2e895Jonathan von Schroeder basic_spec is for basic specifications (see CASL RefMan p. 5ff.),
803425dfe6a5da41b9cea480788980fa104545adMihai Codescu symb_items is for symbol lists (see CASL RefMan p. 35ff.),
sym_of :: lid -> sign -> Set.Set symbol
-- | several provers can be provided. See module "Logic.Prover"
-- | a dummy static analysis function to allow type checking *.inline.hs files
weaklyAmalgamableCocone :: lid -> Tree.Gr sign morphism
-> Result (sign, Map.Map Int morphism)
Tree.Gr sign morphism, -- the diagram to be analyzed
Tree.Gr String String) -- the descriptions of nodes and edges
lid -> Set.Set symbol -> sign -> Result morphism
empty_theory lid = Theory (empty_signature lid) Map.empty
tyconAnyLogic = mkTyCon "Logic.Logic.AnyLogic"