Logic.hs revision 42994fea8e167a6e58c189f3b6aa8a0d8034b4a9
a79fe3aad8743ea57e473ea5f66a723244cb9c0eMarkus Roggenbach{-# LANGUAGE UndecidableInstances #-}
e071fb22ea9923a2a4ff41184d80ca46b55ee932Till MossakowskiModule : $Header$
e85b224577b78d08ba5c39fe9dcc2e53995454a2Christian MaederDescription : central interface (type class) for logics in Hets
97018cf5fa25b494adffd7e9b4e87320dae6bf47Christian MaederCopyright : (c) Till Mossakowski, and Uni Bremen 2002-2006
a79fe3aad8743ea57e473ea5f66a723244cb9c0eMarkus RoggenbachLicense : similar to LGPL, see HetCATS/LICENSE.txt or LIZENZ.txt
b4fbc96e05117839ca409f5f20f97b3ac872d1edTill MossakowskiMaintainer : till@informatik.uni-bremen.de
a79fe3aad8743ea57e473ea5f66a723244cb9c0eMarkus RoggenbachStability : provisional
a79fe3aad8743ea57e473ea5f66a723244cb9c0eMarkus RoggenbachPortability : non-portable (various -fglasgow-exts extensions)
d326dac41dadbe2b84bb7021cbfd91f4dd4a19bcAndy GimblettCentral interface (type class) for logics in Hets
a79fe3aad8743ea57e473ea5f66a723244cb9c0eMarkus RoggenbachProvides data structures for logics (with symbols). Logics are
a79fe3aad8743ea57e473ea5f66a723244cb9c0eMarkus Roggenbach a type class with an /identity type/ (usually interpreted
d326dac41dadbe2b84bb7021cbfd91f4dd4a19bcAndy Gimblett by a singleton set) which serves to treat logics as
d326dac41dadbe2b84bb7021cbfd91f4dd4a19bcAndy Gimblett data. All the functions in the type class take the
d326dac41dadbe2b84bb7021cbfd91f4dd4a19bcAndy Gimblett identity as first argument in order to determine the logic.
a79fe3aad8743ea57e473ea5f66a723244cb9c0eMarkus Roggenbach For logic (co)morphisms see "Logic.Comorphism"
a79fe3aad8743ea57e473ea5f66a723244cb9c0eMarkus Roggenbach This module uses multiparameter type classes with functional dependencies
90047eafd2de482c67bcd13103c6064e9b0cb254Andy Gimblett (<http://www.haskell.org/haskellwiki/Functional_dependencies>)
eeaf0a8a1dc535d105904a2190f26c0835ecf429Andy Gimblett for defining an interface for the notion of logic. Multiparameter type
d326dac41dadbe2b84bb7021cbfd91f4dd4a19bcAndy Gimblett classes are needed because a logic consists of a collection of types,
d326dac41dadbe2b84bb7021cbfd91f4dd4a19bcAndy Gimblett together with operations on these. Functional dependencies
eeaf0a8a1dc535d105904a2190f26c0835ecf429Andy Gimblett are needed because no operation will involve all types of
e8c03c10d7987b223a9f6bfd5c0c54da21da5b86Andy Gimblett the multiparameter type class; hence we need a method to derive
a79fe3aad8743ea57e473ea5f66a723244cb9c0eMarkus Roggenbach the missing types. We chose an easy way: for each logic, we
1538a6e8d77301d6de757616ffc69ee61f1482e4Andy Gimblett introduce a new singleton type that is the name, or constitutes the identity
a79fe3aad8743ea57e473ea5f66a723244cb9c0eMarkus Roggenbach of the logic. All other types of the multiparameter type class
a79fe3aad8743ea57e473ea5f66a723244cb9c0eMarkus Roggenbach depend on this /identity constituting/ type, and all operations take
eeaf0a8a1dc535d105904a2190f26c0835ecf429Andy Gimblett the 'identity constituting' type as first arguments. The value
a79fe3aad8743ea57e473ea5f66a723244cb9c0eMarkus Roggenbach of the argument of the /identity constituting/ type is irrelevant
792df0347edab377785d98c63e2be8e2ce0a8bdeChristian Maeder (note that there is only one value of such a type anyway).
04ceed96d1528b939f2e592d0656290d81d1c045Andy Gimblett Note that we tend to use @lid@ both for the /identity type/
e8c03c10d7987b223a9f6bfd5c0c54da21da5b86Andy Gimblett of a logic, as well as for its unique inhabitant, i.e. @lid :: lid@.
1538a6e8d77301d6de757616ffc69ee61f1482e4Andy Gimblett The other types involved in the definition of logic are as follows:
41486a487c9b065d4d9d1a8adf63c00925cd455bAndy Gimblett * sign: signatures, that is, contexts, or non-logical vocabularies,
41486a487c9b065d4d9d1a8adf63c00925cd455bAndy Gimblett typically consisting of a set of declared sorts, predicates,
e771539425f4a0abef9f94cf4b63690f3603f682Andy Gimblett function symbols, propositional letters etc., together with their
e771539425f4a0abef9f94cf4b63690f3603f682Andy Gimblett * sentence: logical formulas.
e771539425f4a0abef9f94cf4b63690f3603f682Andy Gimblett * basic_spec: abstract syntax of basic specifications. The latter are
41486a487c9b065d4d9d1a8adf63c00925cd455bAndy Gimblett human-readable presentations of a signature together with some sentences.
e771539425f4a0abef9f94cf4b63690f3603f682Andy Gimblett * symbol: symbols that may occur in a signature, fully qualified
e8c03c10d7987b223a9f6bfd5c0c54da21da5b86Andy Gimblett with their types
90047eafd2de482c67bcd13103c6064e9b0cb254Andy Gimblett * raw_symbol: symbols that may occur in a signature, possibly not
e771539425f4a0abef9f94cf4b63690f3603f682Andy Gimblett or partially qualified
41486a487c9b065d4d9d1a8adf63c00925cd455bAndy Gimblett * morphism: maps between signatures (typically preserving the structure).
e771539425f4a0abef9f94cf4b63690f3603f682Andy Gimblett * symb_items: abstract syntax of symbol lists, used for declaring some
eeaf0a8a1dc535d105904a2190f26c0835ecf429Andy Gimblett symbols of a signature as hidden.
e771539425f4a0abef9f94cf4b63690f3603f682Andy Gimblett * symb_map_items: abstract syntax of symbol maps, i.e. human-readable
61051521e4d82769a47f23aecb5fb477de47d534Andy Gimblett presentations of signature morphisms.
eeaf0a8a1dc535d105904a2190f26c0835ecf429Andy Gimblett * sublogics: sublogics of the given logic. This type might be a
eeaf0a8a1dc535d105904a2190f26c0835ecf429Andy Gimblett record of Boolean flags, indicating whether some feature is
d326dac41dadbe2b84bb7021cbfd91f4dd4a19bcAndy Gimblett present in the sublogi of not.
eeaf0a8a1dc535d105904a2190f26c0835ecf429Andy Gimblett * proof_tree: proof trees.
61051521e4d82769a47f23aecb5fb477de47d534Andy Gimblett J. A. Goguen and R. M. Burstall
e8c03c10d7987b223a9f6bfd5c0c54da21da5b86Andy Gimblett Institutions: Abstract Model Theory for Specification and
d326dac41dadbe2b84bb7021cbfd91f4dd4a19bcAndy Gimblett JACM 39, p. 95-146, 1992
e771539425f4a0abef9f94cf4b63690f3603f682Andy Gimblett (general notion of logic - model theory only)
d326dac41dadbe2b84bb7021cbfd91f4dd4a19bcAndy Gimblett General Logics
d326dac41dadbe2b84bb7021cbfd91f4dd4a19bcAndy Gimblett Logic Colloquium 87, p. 275-329, North Holland, 1989
e8c03c10d7987b223a9f6bfd5c0c54da21da5b86Andy Gimblett (general notion of logic - also proof theory;
820947bd01ca952c3909eaa0366c6914c87cc1cbTill Mossakowski notion of logic representation, called map there)
d326dac41dadbe2b84bb7021cbfd91f4dd4a19bcAndy Gimblett T. Mossakowski:
d326dac41dadbe2b84bb7021cbfd91f4dd4a19bcAndy Gimblett Specification in an arbitrary institution with symbols
d326dac41dadbe2b84bb7021cbfd91f4dd4a19bcAndy Gimblett 14th WADT 1999, LNCS 1827, p. 252-270
90047eafd2de482c67bcd13103c6064e9b0cb254Andy Gimblett (treatment of symbols and raw symbols, see also CASL semantics
e8c03c10d7987b223a9f6bfd5c0c54da21da5b86Andy Gimblett in the CASL reference manual)
e8c03c10d7987b223a9f6bfd5c0c54da21da5b86Andy Gimblett T. Mossakowski, B. Klin:
90047eafd2de482c67bcd13103c6064e9b0cb254Andy Gimblett Institution Independent Static Analysis for CASL
d326dac41dadbe2b84bb7021cbfd91f4dd4a19bcAndy Gimblett 15h WADT 2001, LNCS 2267, p. 221-237, 2002.
90047eafd2de482c67bcd13103c6064e9b0cb254Andy Gimblett (what is needed for static anaylsis)
d326dac41dadbe2b84bb7021cbfd91f4dd4a19bcAndy Gimblett S. Autexier and T. Mossakowski
d326dac41dadbe2b84bb7021cbfd91f4dd4a19bcAndy Gimblett Integrating HOLCASL into the Development Graph Manager MAYA
90047eafd2de482c67bcd13103c6064e9b0cb254Andy Gimblett FroCoS 2002, LNCS 2309, p. 2-17, 2002.
a79fe3aad8743ea57e473ea5f66a723244cb9c0eMarkus Roggenbach (interface to provers)
e8c03c10d7987b223a9f6bfd5c0c54da21da5b86Andy Gimblett CoFI (ed.): CASL Reference Manual, LNCS 2960, Springer Verlag, 2004.
af745a4a6cb26002e55b69f90d837fe9c6176d4bAndy Gimblett (static semantics of CASL structured and architectural specifications)
e8c03c10d7987b223a9f6bfd5c0c54da21da5b86Andy Gimblett T. Mossakowski
d326dac41dadbe2b84bb7021cbfd91f4dd4a19bcAndy Gimblett Heterogeneous specification and the heterogeneous tool set
d326dac41dadbe2b84bb7021cbfd91f4dd4a19bcAndy Gimblett Habilitation thesis, University of Bremen, 2005
d326dac41dadbe2b84bb7021cbfd91f4dd4a19bcAndy Gimblett (the general picture of heterogeneous specification)
d326dac41dadbe2b84bb7021cbfd91f4dd4a19bcAndy Gimblettimport Logic.Prover (Prover, ConsChecker, Theory(..))
d326dac41dadbe2b84bb7021cbfd91f4dd4a19bcAndy Gimblettimport Taxonomy.MMiSSOntology (MMiSSOntology)
d326dac41dadbe2b84bb7021cbfd91f4dd4a19bcAndy Gimblettimport Common.ATerm.Lib (ShATermConvertible)
d326dac41dadbe2b84bb7021cbfd91f4dd4a19bcAndy Gimblettimport qualified Data.Set as Set
d326dac41dadbe2b84bb7021cbfd91f4dd4a19bcAndy Gimblettimport qualified Data.Map as Map
d326dac41dadbe2b84bb7021cbfd91f4dd4a19bcAndy Gimblettimport qualified OMDoc.DataTypes as OMDoc
d326dac41dadbe2b84bb7021cbfd91f4dd4a19bcAndy Gimblett-- | Stability of logic implementations
d326dac41dadbe2b84bb7021cbfd91f4dd4a19bcAndy Gimblettdata Stability = Stable | Testing | Unstable | Experimental
d326dac41dadbe2b84bb7021cbfd91f4dd4a19bcAndy Gimblett deriving (Eq, Show)
d326dac41dadbe2b84bb7021cbfd91f4dd4a19bcAndy Gimblett-- | shortcut for class constraints
e8c03c10d7987b223a9f6bfd5c0c54da21da5b86Andy Gimblettclass (Show a, Pretty a, Typeable a, ShATermConvertible a)
d326dac41dadbe2b84bb7021cbfd91f4dd4a19bcAndy Gimblett => PrintTypeConv a
d326dac41dadbe2b84bb7021cbfd91f4dd4a19bcAndy Gimblett-- | shortcut for class constraints with equality
d326dac41dadbe2b84bb7021cbfd91f4dd4a19bcAndy Gimblettclass (Eq a, PrintTypeConv a) => EqPrintTypeConv a
d326dac41dadbe2b84bb7021cbfd91f4dd4a19bcAndy Gimblettinstance (Show a, Pretty a, Typeable a,
d326dac41dadbe2b84bb7021cbfd91f4dd4a19bcAndy Gimblett ShATermConvertible a) => PrintTypeConv a
d326dac41dadbe2b84bb7021cbfd91f4dd4a19bcAndy Gimblettinstance (Eq a, PrintTypeConv a) => EqPrintTypeConv a
e8c03c10d7987b223a9f6bfd5c0c54da21da5b86Andy Gimblett-- | maps from a to a
d326dac41dadbe2b84bb7021cbfd91f4dd4a19bcAndy Gimbletttype EndoMap a = Map.Map a a
e8c03c10d7987b223a9f6bfd5c0c54da21da5b86Andy Gimblett{- | the name of a logic.
e8c03c10d7987b223a9f6bfd5c0c54da21da5b86Andy Gimblett Define instances like "data CASL = CASL deriving Show"
e95030058b77cb83593c85aa4c506caf154f63b7Andy Gimblettclass Show lid => Language lid where
e95030058b77cb83593c85aa4c506caf154f63b7Andy Gimblett language_name :: lid -> String
e95030058b77cb83593c85aa4c506caf154f63b7Andy Gimblett language_name i = show i
e95030058b77cb83593c85aa4c506caf154f63b7Andy Gimblett description :: lid -> String
e95030058b77cb83593c85aa4c506caf154f63b7Andy Gimblett -- default implementation
e95030058b77cb83593c85aa4c506caf154f63b7Andy Gimblett description _ = "No description available"
e95030058b77cb83593c85aa4c506caf154f63b7Andy Gimblett{- | Categories are given as usual: objects, morphisms, identities,
e95030058b77cb83593c85aa4c506caf154f63b7Andy Gimblett domain, codomain and composition. The type id is the name, or
e95030058b77cb83593c85aa4c506caf154f63b7Andy Gimblett the identity of the category. It is an argument to all functions
e95030058b77cb83593c85aa4c506caf154f63b7Andy Gimblett of the type class, serving disambiguation among instances
e95030058b77cb83593c85aa4c506caf154f63b7Andy Gimblett (via the functional dependency lid -> object morphism).
e95030058b77cb83593c85aa4c506caf154f63b7Andy Gimblett The types for objects and morphisms may be restricted to
e95030058b77cb83593c85aa4c506caf154f63b7Andy Gimblett subtypes, using legal_obj and legal_mor. For example, for the
e95030058b77cb83593c85aa4c506caf154f63b7Andy Gimblett category of sets and injective maps, legal_mor would check
e8c03c10d7987b223a9f6bfd5c0c54da21da5b86Andy Gimblett injectivity. Since Eq is a subclass of Category, it is also
e8c03c10d7987b223a9f6bfd5c0c54da21da5b86Andy Gimblett possible to impose a quotient on the types for objects and morphisms.
e8c03c10d7987b223a9f6bfd5c0c54da21da5b86Andy Gimblett Require Ord instances only for efficiency, i.e. in sets or maps.
inverse _ = fail "Logic.Logic.Category.inverse not implemented"
sym_of :: lid -> sign -> Set.Set symbol
-- | 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
++ showDoc (Set.difference (sym_of lid s1) $ sym_of lid s2) ""
-- | several provers can be provided. See module "Logic.Prover"
-> [OMDoc.TCElement]
export_morphismToOmdoc :: lid -> morphism -> OMDoc.TCElement
-> Named sentence -> OMDoc.TCElement
omdoc_metatheory :: lid -> Maybe OMDoc.OMCD
empty_theory lid = Theory (empty_signature lid) Map.empty