Comorphism.hs revision 1a38107941725211e7c3f051f7a8f5e12199f03a
076b559b2ea7b2f1d303df992ae71cd6c6fe563cChristian Maeder{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies, DeriveDataTypeable
076b559b2ea7b2f1d303df992ae71cd6c6fe563cChristian Maeder , FlexibleInstances, UndecidableInstances, ExistentialQuantification #-}
076b559b2ea7b2f1d303df992ae71cd6c6fe563cChristian MaederModule : $Header$
97018cf5fa25b494adffd7e9b4e87320dae6bf47Christian MaederDescription : interface and class for logic translations
076b559b2ea7b2f1d303df992ae71cd6c6fe563cChristian MaederCopyright : (c) Till Mossakowski, Uni Bremen 2002-2006
3f69b6948966979163bdfe8331c38833d5d90ecdChristian MaederLicense : GPLv2 or higher, see LICENSE.txt
076b559b2ea7b2f1d303df992ae71cd6c6fe563cChristian MaederMaintainer : till@informatik.uni-bremen.de
076b559b2ea7b2f1d303df992ae71cd6c6fe563cChristian MaederStability : provisional
f3a94a197960e548ecd6520bb768cb0d547457bbChristian MaederPortability : non-portable (via Logic)
568a1ce407fd05a2007c5db3c5c57098bf13997fChristian MaederCentral interface (type class) for logic translations (comorphisms) in Hets
568a1ce407fd05a2007c5db3c5c57098bf13997fChristian Maeder These are just collections of
e8ffec0fa3d3061061bdc16e44247b9cf96b050fChristian Maeder functions between (some of) the types of logics.
e8ffec0fa3d3061061bdc16e44247b9cf96b050fChristian Maeder References: see Logic.hs
35db0960aa2e2a13652381c756fae5fb2b27213bChristian Maeder ( CompComorphism (..)
568a1ce407fd05a2007c5db3c5c57098bf13997fChristian Maeder , InclComorphism
ac510075311023bf24175f7a76b89ec2bbda0626Christian Maeder , inclusion_logic
ac510075311023bf24175f7a76b89ec2bbda0626Christian Maeder , inclusion_source_sublogic
5b1f1d57c75562a7af79e8256f4afa07febe921bChristian Maeder , inclusion_target_sublogic
5b1f1d57c75562a7af79e8256f4afa07febe921bChristian Maeder , mkInclComorphism
5b1f1d57c75562a7af79e8256f4afa07febe921bChristian Maeder , mkIdComorphism
5b1f1d57c75562a7af79e8256f4afa07febe921bChristian Maeder , Comorphism (..)
568a1ce407fd05a2007c5db3c5c57098bf13997fChristian Maeder , targetSublogic
5b1f1d57c75562a7af79e8256f4afa07febe921bChristian Maeder , wrapMapTheory
99f16a0f9ca757410960ff51a79b034503384fe2Christian Maeder , mkTheoryMapping
6e5180855658f12f9059d9041f447bf0935de344Christian Maeder , AnyComorphism (..)
5b1f1d57c75562a7af79e8256f4afa07febe921bChristian Maeder , idComorphism
8a1f427564a5ae2db32332512237ef645289c34dChristian Maeder , isIdComorphism
76647324ed70f33b95a881b536d883daccf9568dChristian Maeder , isModelTransportable
76647324ed70f33b95a881b536d883daccf9568dChristian Maeder , hasModelExpansion
76647324ed70f33b95a881b536d883daccf9568dChristian Maeder , isWeaklyAmalgamable
1865083b72c1307e9040d78c2743abd5a54ee260Christian Maeder , compComorphism
ac510075311023bf24175f7a76b89ec2bbda0626Christian Maederimport qualified Data.Set as Set
fd5d3885a092ac0727fa2436cdfc3b248318ebd8Christian Maederclass (Language cid,
fd5d3885a092ac0727fa2436cdfc3b248318ebd8Christian Maeder Logic lid1 sublogics1
4be371b81d055e03a5946e4ec333613f313d689bChristian Maeder basic_spec1 sentence1 symb_items1 symb_map_items1
4be371b81d055e03a5946e4ec333613f313d689bChristian Maeder sign1 morphism1 symbol1 raw_symbol1 proof_tree1,
5b1f1d57c75562a7af79e8256f4afa07febe921bChristian Maeder Logic lid2 sublogics2
5b1f1d57c75562a7af79e8256f4afa07febe921bChristian Maeder basic_spec2 sentence2 symb_items2 symb_map_items2
5b1f1d57c75562a7af79e8256f4afa07febe921bChristian Maeder sign2 morphism2 symbol2 raw_symbol2 proof_tree2) =>
5b1f1d57c75562a7af79e8256f4afa07febe921bChristian Maeder Comorphism cid
5b1f1d57c75562a7af79e8256f4afa07febe921bChristian Maeder lid1 sublogics1 basic_spec1 sentence1 symb_items1 symb_map_items1
5b1f1d57c75562a7af79e8256f4afa07febe921bChristian Maeder sign1 morphism1 symbol1 raw_symbol1 proof_tree1
4be371b81d055e03a5946e4ec333613f313d689bChristian Maeder lid2 sublogics2 basic_spec2 sentence2 symb_items2 symb_map_items2
4be371b81d055e03a5946e4ec333613f313d689bChristian Maeder sign2 morphism2 symbol2 raw_symbol2 proof_tree2
4be371b81d055e03a5946e4ec333613f313d689bChristian Maeder | cid -> lid1 sublogics1 basic_spec1 sentence1 symb_items1 symb_map_items1
5b1f1d57c75562a7af79e8256f4afa07febe921bChristian Maeder sign1 morphism1 symbol1 raw_symbol1 proof_tree1
5b1f1d57c75562a7af79e8256f4afa07febe921bChristian Maeder lid2 sublogics2 basic_spec2 sentence2 symb_items2 symb_map_items2
5b1f1d57c75562a7af79e8256f4afa07febe921bChristian Maeder sign2 morphism2 symbol2 raw_symbol2 proof_tree2
5b1f1d57c75562a7af79e8256f4afa07febe921bChristian Maeder {- source and target logic and sublogic
5b1f1d57c75562a7af79e8256f4afa07febe921bChristian Maeder the source sublogic is the maximal one for which the comorphism works -}
4be371b81d055e03a5946e4ec333613f313d689bChristian Maeder sourceLogic :: cid -> lid1
ac510075311023bf24175f7a76b89ec2bbda0626Christian Maeder sourceSublogic :: cid -> sublogics1
7de39d39bc1700cc8a9bb9df90b920aad9e18d4aChristian Maeder sourceSublogic cid = top_sublogic $ sourceLogic cid
7de39d39bc1700cc8a9bb9df90b920aad9e18d4aChristian Maeder minSourceTheory :: cid -> Maybe (LibName, String)
ac510075311023bf24175f7a76b89ec2bbda0626Christian Maeder minSourceTheory _ = Nothing
ac510075311023bf24175f7a76b89ec2bbda0626Christian Maeder targetLogic :: cid -> lid2
ac510075311023bf24175f7a76b89ec2bbda0626Christian Maeder {- finer information of target sublogics corresponding to source sublogics
5b1f1d57c75562a7af79e8256f4afa07febe921bChristian Maeder this function must be partial because mapTheory is partial -}
568a1ce407fd05a2007c5db3c5c57098bf13997fChristian Maeder mapSublogic :: cid -> sublogics1 -> Maybe sublogics2
ac510075311023bf24175f7a76b89ec2bbda0626Christian Maeder mapSublogic cid _ = Just $ top_sublogic $ targetLogic cid
fd5d3885a092ac0727fa2436cdfc3b248318ebd8Christian Maeder {- the translation functions are partial
5b1f1d57c75562a7af79e8256f4afa07febe921bChristian Maeder because the target may be a sublanguage
76647324ed70f33b95a881b536d883daccf9568dChristian Maeder map_basic_spec :: cid -> basic_spec1 -> Result basic_spec2
ac510075311023bf24175f7a76b89ec2bbda0626Christian Maeder cover theoroidal comorphisms as well -}
7c57322afb6342e5cc8b1fdc96050b707407fc61Christian Maeder map_theory :: cid -> (sign1, [Named sentence1])
5b1f1d57c75562a7af79e8256f4afa07febe921bChristian Maeder -> Result (sign2, [Named sentence2])
5b1f1d57c75562a7af79e8256f4afa07febe921bChristian Maeder -- map_theory but also consider sentence marks
5b1f1d57c75562a7af79e8256f4afa07febe921bChristian Maeder mapMarkedTheory :: cid -> (sign1, [Named sentence1])
5b1f1d57c75562a7af79e8256f4afa07febe921bChristian Maeder -> Result (sign2, [Named sentence2])
map_symbol :: cid -> sign1 -> symbol1 -> Set.Set symbol2
=> cid -> sign1 -> symbol1 -> Set.Set symbol2
map_symbol _ _ = Set.singleton
_ -> error "CompComorphism.map_sentence"
in Set.unions
(Set.toList (map_symbol cid1 sig1 s1)))