Grothendieck.hs revision 9e2e744c6b967c3f5f581acf01c13769b6769285
8b054cade993ef373d564b2d74c9c5a2da48f8b7Kristina SojakovaModule : $Header$
cb5d588c4c3b286cc1e7210335d6ef7f584d79bcKristina SojakovaCopyright : (c) Till Mossakowski, and Uni Bremen 2002-2004
097b7fb3f8f90e87120d30bf37a1d89fe0ddfaf0Kristina SojakovaLicence : similar to LGPL, see HetCATS/LICENCE.txt or LIZENZ.txt
211c5fb252e0a776baad9a4857ab198659289a4aKristina SojakovaMaintainer : till@tzi.de
211c5fb252e0a776baad9a4857ab198659289a4aKristina SojakovaStability : provisional
94e2e03f6efde106de095ef4ea0ec87f74955a31Kristina SojakovaPortability : non-portable (overlapping instances, dynamics, existentials)
8b054cade993ef373d564b2d74c9c5a2da48f8b7Kristina Sojakova The Grothendieck logic is defined to be the
8b054cade993ef373d564b2d74c9c5a2da48f8b7Kristina Sojakova heterogeneous logic over the logic graph.
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova This will be the logic over which the data
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova structures and algorithms for specification in-the-large
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova R. Diaconescu:
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova Grothendieck institutions
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova J. applied categorical structures 10, 2002, p. 383-402.
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova T. Mossakowski:
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova Heterogeneous development graphs and heterogeneous borrowing
45caf47cd6ed07be0637f6c51e4735512ce9d83aKristina Sojakova Fossacs 2002, LNCS 2303, p. 326-341
8b054cade993ef373d564b2d74c9c5a2da48f8b7Kristina Sojakova T. Mossakowski: Foundations of heterogeneous specification
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova T. Mossakowski:
8b054cade993ef373d564b2d74c9c5a2da48f8b7Kristina Sojakova Relating CASL with Other Specification Languages:
8b054cade993ef373d564b2d74c9c5a2da48f8b7Kristina Sojakova the Institution Level
8b054cade993ef373d564b2d74c9c5a2da48f8b7Kristina Sojakova Theoretical Computer Science 286, 2002, p. 367-475
8b054cade993ef373d564b2d74c9c5a2da48f8b7Kristina Sojakovaimport qualified Common.Lib.Map as Map
51bbd37b3957f301b2628422e161aac2cbd46f1cKristina Sojakovaimport qualified Common.Lib.Set as Set
51bbd37b3957f301b2628422e161aac2cbd46f1cKristina Sojakovaimport qualified Data.List as List
cb5d588c4c3b286cc1e7210335d6ef7f584d79bcKristina Sojakovaimport Common.Lib.Parsec.Pos -- for testing purposes
51bbd37b3957f301b2628422e161aac2cbd46f1cKristina Sojakova------------------------------------------------------------------
51bbd37b3957f301b2628422e161aac2cbd46f1cKristina Sojakova--"Grothendieck" versions of the various parts of type class Logic
51bbd37b3957f301b2628422e161aac2cbd46f1cKristina Sojakova------------------------------------------------------------------
cb5d588c4c3b286cc1e7210335d6ef7f584d79bcKristina Sojakova-- | Grothendieck basic specifications
8b054cade993ef373d564b2d74c9c5a2da48f8b7Kristina Sojakovadata G_basic_spec = forall lid sublogics
cb5d588c4c3b286cc1e7210335d6ef7f584d79bcKristina Sojakova basic_spec sentence symb_items symb_map_items
8b054cade993ef373d564b2d74c9c5a2da48f8b7Kristina Sojakova sign morphism symbol raw_symbol proof_tree .
cb5d588c4c3b286cc1e7210335d6ef7f584d79bcKristina Sojakova Logic lid sublogics
81d28e8372831ae5e6054d8d2212f0114b09b79aKristina Sojakova basic_spec sentence symb_items symb_map_items
81d28e8372831ae5e6054d8d2212f0114b09b79aKristina Sojakova sign morphism symbol raw_symbol proof_tree =>
cb5d588c4c3b286cc1e7210335d6ef7f584d79bcKristina Sojakova G_basic_spec lid basic_spec
81d28e8372831ae5e6054d8d2212f0114b09b79aKristina Sojakovainstance Show G_basic_spec where
81d28e8372831ae5e6054d8d2212f0114b09b79aKristina Sojakova show (G_basic_spec _ s) = show s
81d28e8372831ae5e6054d8d2212f0114b09b79aKristina Sojakovainstance PrettyPrint G_basic_spec where
cb5d588c4c3b286cc1e7210335d6ef7f584d79bcKristina Sojakova printText0 ga (G_basic_spec _ s) = printText0 ga s
81d28e8372831ae5e6054d8d2212f0114b09b79aKristina Sojakova-- | Grothendieck sentences
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakovadata G_sentence = forall lid sublogics
51bbd37b3957f301b2628422e161aac2cbd46f1cKristina Sojakova basic_spec sentence symb_items symb_map_items
f2f62e61c66f678b0042d1a772ff89849d8b2113Kristina Sojakova sign morphism symbol raw_symbol proof_tree .
f2f62e61c66f678b0042d1a772ff89849d8b2113Kristina Sojakova Logic lid sublogics
f2f62e61c66f678b0042d1a772ff89849d8b2113Kristina Sojakova basic_spec sentence symb_items symb_map_items
f2f62e61c66f678b0042d1a772ff89849d8b2113Kristina Sojakova sign morphism symbol raw_symbol proof_tree =>
f2f62e61c66f678b0042d1a772ff89849d8b2113Kristina Sojakova G_sentence lid sentence
f2f62e61c66f678b0042d1a772ff89849d8b2113Kristina Sojakovainstance Show G_sentence where
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova show (G_sentence _ s) = show s
887a1999374d1fb3a534e602a8d322de6ef4c8e8Kristina Sojakova-- | Grothendieck sentence lists
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakovadata G_l_sentence_list = forall lid sublogics
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova basic_spec sentence symb_items symb_map_items
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova sign morphism symbol raw_symbol proof_tree .
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova Logic lid sublogics
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova basic_spec sentence symb_items symb_map_items
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova sign morphism symbol raw_symbol proof_tree =>
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova G_l_sentence_list lid [Named sentence]
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakovainstance Show G_l_sentence_list where
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova show (G_l_sentence_list _ s) = show s
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakovainstance Eq G_l_sentence_list where
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova (G_l_sentence_list i1 nl1) == (G_l_sentence_list i2 nl2) =
887a1999374d1fb3a534e602a8d322de6ef4c8e8Kristina Sojakova coerce i1 i2 nl1 == Just nl2
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakovaeq_G_l_sentence_set :: G_l_sentence_list -> G_l_sentence_list -> Bool
887a1999374d1fb3a534e602a8d322de6ef4c8e8Kristina Sojakovaeq_G_l_sentence_set (G_l_sentence_list i1 nl1) (G_l_sentence_list i2 nl2) =
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova case coerce i1 i2 nl1 of
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova Just nl1' -> Set.fromList nl1' == Set.fromList nl2
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova Nothing -> False
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova-- | Grothendieck signatures
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakovadata G_sign = forall lid sublogics
887a1999374d1fb3a534e602a8d322de6ef4c8e8Kristina Sojakova basic_spec sentence symb_items symb_map_items
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova sign morphism symbol raw_symbol proof_tree .
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova Logic lid sublogics
887a1999374d1fb3a534e602a8d322de6ef4c8e8Kristina Sojakova basic_spec sentence symb_items symb_map_items
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova sign morphism symbol raw_symbol proof_tree =>
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova G_sign lid sign
887a1999374d1fb3a534e602a8d322de6ef4c8e8Kristina SojakovatyconG_sign :: TyCon
887a1999374d1fb3a534e602a8d322de6ef4c8e8Kristina SojakovatyconG_sign = mkTyCon "Logic.Grothendieck.G_sign"
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakovainstance Typeable G_sign where
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova typeOf _ = mkTyConApp tyconG_sign []
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakovainstance Eq G_sign where
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova (G_sign i1 sigma1) == (G_sign i2 sigma2) =
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova coerce i1 i2 sigma1 == Just sigma2
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova-- | prefer a faster subsignature test if possible
887a1999374d1fb3a534e602a8d322de6ef4c8e8Kristina Sojakovais_subgsign :: G_sign -> G_sign -> Bool
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakovais_subgsign (G_sign i1 sigma1) (G_sign i2 sigma2) =
345d3dcc9f809776009851c446916fc770aa428dKristina Sojakova maybe False (is_subsig i1 sigma1) $ coerce i2 i1 sigma2
cb5d588c4c3b286cc1e7210335d6ef7f584d79bcKristina Sojakovainstance Show G_sign where
345d3dcc9f809776009851c446916fc770aa428dKristina Sojakova show (G_sign _ s) = show s
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakovainstance PrettyPrint G_sign where
a3a6b6ebe9c2d1dc3554e44779dc7361a90e7617Kristina Sojakova printText0 ga (G_sign _ s) = printText0 ga s
45caf47cd6ed07be0637f6c51e4735512ce9d83aKristina SojakovalangNameSig :: G_sign -> String
cb5d588c4c3b286cc1e7210335d6ef7f584d79bcKristina SojakovalangNameSig (G_sign lid _) = language_name lid
45caf47cd6ed07be0637f6c51e4735512ce9d83aKristina Sojakova-- | Grothendieck signature lists
45caf47cd6ed07be0637f6c51e4735512ce9d83aKristina Sojakovadata G_sign_list = forall lid sublogics
45caf47cd6ed07be0637f6c51e4735512ce9d83aKristina Sojakova basic_spec sentence symb_items symb_map_items
45caf47cd6ed07be0637f6c51e4735512ce9d83aKristina Sojakova sign morphism symbol raw_symbol proof_tree .
8b054cade993ef373d564b2d74c9c5a2da48f8b7Kristina Sojakova Logic lid sublogics
8b054cade993ef373d564b2d74c9c5a2da48f8b7Kristina Sojakova basic_spec sentence symb_items symb_map_items
51bbd37b3957f301b2628422e161aac2cbd46f1cKristina Sojakova sign morphism symbol raw_symbol proof_tree =>
8b054cade993ef373d564b2d74c9c5a2da48f8b7Kristina Sojakova G_sign_list lid [sign]
cb5d588c4c3b286cc1e7210335d6ef7f584d79bcKristina Sojakova-- | Grothendieck extended signatures
51bbd37b3957f301b2628422e161aac2cbd46f1cKristina Sojakovadata G_ext_sign = forall lid sublogics
51bbd37b3957f301b2628422e161aac2cbd46f1cKristina Sojakova basic_spec sentence symb_items symb_map_items
f2f62e61c66f678b0042d1a772ff89849d8b2113Kristina Sojakova sign morphism symbol raw_symbol proof_tree .
f2f62e61c66f678b0042d1a772ff89849d8b2113Kristina Sojakova Logic lid sublogics
f2f62e61c66f678b0042d1a772ff89849d8b2113Kristina Sojakova basic_spec sentence symb_items symb_map_items
8b054cade993ef373d564b2d74c9c5a2da48f8b7Kristina Sojakova sign morphism symbol raw_symbol proof_tree =>
51bbd37b3957f301b2628422e161aac2cbd46f1cKristina Sojakova G_ext_sign lid sign (Set.Set symbol)
51bbd37b3957f301b2628422e161aac2cbd46f1cKristina SojakovatyconG_ext_sign :: TyCon
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina SojakovatyconG_ext_sign = mkTyCon "Logic.Grothendieck.G_ext_sign"
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakovainstance Typeable G_ext_sign where
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova typeOf _ = mkTyConApp tyconG_ext_sign []
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakovainstance Eq G_ext_sign where
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova (G_ext_sign i1 sigma1 sys1) == (G_ext_sign i2 sigma2 sys2) =
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova coerce i1 i2 sigma1 == Just sigma2
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova && coerce i1 i2 sys1 == Just sys2
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakovainstance Show G_ext_sign where
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova show (G_ext_sign _ s _) = show s
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakovainstance PrettyPrint G_ext_sign where
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova printText0 ga (G_ext_sign _ s _) = printText0 ga s
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina SojakovalangNameExtSig :: G_ext_sign -> String
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina SojakovalangNameExtSig (G_ext_sign lid _ _) = language_name lid
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova-- | Grothendieck theories
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakovadata G_theory = forall lid sublogics
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova basic_spec sentence symb_items symb_map_items
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova sign morphism symbol raw_symbol proof_tree .
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova Logic lid sublogics
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova basic_spec sentence symb_items symb_map_items
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova sign morphism symbol raw_symbol proof_tree =>
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova G_theory lid sign [Named sentence]
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova-- | compute sublogic of a theory
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina SojakovasublogicOfTh :: G_theory -> G_sublogics
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina SojakovasublogicOfTh (G_theory lid sigma sens) =
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova (min_sublogic_sign lid sigma)
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova (map (min_sublogic_sentence lid . sentence) sens)
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova in G_sublogics lid sub
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova-- | simplify a theory (throw away qualifications)
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina SojakovasimplifyTh :: G_theory -> G_theory
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina SojakovasimplifyTh (G_theory lid sigma sens) =
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova G_theory lid sigma (map (mapNamed (simplify_sen lid sigma)) sens)
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova-- | Grothendieck symbols
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakovadata G_symbol = forall lid sublogics
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova basic_spec sentence symb_items symb_map_items
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova sign morphism symbol raw_symbol proof_tree .
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova Logic lid sublogics
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova basic_spec sentence symb_items symb_map_items
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova sign morphism symbol raw_symbol proof_tree =>
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova G_symbol lid symbol
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakovainstance Show G_symbol where
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova show (G_symbol _ s) = show s
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakovainstance Eq G_symbol where
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova (G_symbol i1 s1) == (G_symbol i2 s2) =
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova coerce i1 i2 s1 == Just s2
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova-- | Grothendieck symbol lists
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakovadata G_symb_items_list = forall lid sublogics
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova basic_spec sentence symb_items symb_map_items
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova sign morphism symbol raw_symbol proof_tree .
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova Logic lid sublogics
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova basic_spec sentence symb_items symb_map_items
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova sign morphism symbol raw_symbol proof_tree =>
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova G_symb_items_list lid [symb_items]
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakovainstance Show G_symb_items_list where
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova show (G_symb_items_list _ l) = show l
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakovainstance PrettyPrint G_symb_items_list where
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova printText0 ga (G_symb_items_list _ l) =
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova fsep $ punctuate comma $ map (printText0 ga) l
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakovainstance Eq G_symb_items_list where
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova (G_symb_items_list i1 s1) == (G_symb_items_list i2 s2) =
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova coerce i1 i2 s1 == Just s2
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova-- | Grothendieck symbol maps
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakovadata G_symb_map_items_list = forall lid sublogics
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova basic_spec sentence symb_items symb_map_items
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova sign morphism symbol raw_symbol proof_tree .
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova Logic lid sublogics
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova basic_spec sentence symb_items symb_map_items
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova sign morphism symbol raw_symbol proof_tree =>
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova G_symb_map_items_list lid [symb_map_items]
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakovainstance Show G_symb_map_items_list where
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova show (G_symb_map_items_list _ l) = show l
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakovainstance PrettyPrint G_symb_map_items_list where
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova printText0 ga (G_symb_map_items_list _ l) =
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova fsep $ punctuate comma $ map (printText0 ga) l
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakovainstance Eq G_symb_map_items_list where
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova (G_symb_map_items_list i1 s1) == (G_symb_map_items_list i2 s2) =
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova coerce i1 i2 s1 == Just s2
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova-- | Grothendieck diagrams
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakovadata G_diagram = forall lid sublogics
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova basic_spec sentence symb_items symb_map_items
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova sign morphism symbol raw_symbol proof_tree .
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova Logic lid sublogics
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova basic_spec sentence symb_items symb_map_items
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova sign morphism symbol raw_symbol proof_tree =>
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova G_diagram lid (Diagram sign morphism)
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova-- | Grothendieck sublogics
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakovadata G_sublogics = forall lid sublogics
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova basic_spec sentence symb_items symb_map_items
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova sign morphism symbol raw_symbol proof_tree .
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova Logic lid sublogics
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova basic_spec sentence symb_items symb_map_items
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova sign morphism symbol raw_symbol proof_tree =>
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova G_sublogics lid sublogics
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina SojakovatyconG_sublogics :: TyCon
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina SojakovatyconG_sublogics = mkTyCon "Logic.Grothendieck.G_sublogics"
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakovainstance Typeable G_sublogics where
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova typeOf _ = mkTyConApp tyconG_sublogics []
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakovainstance Show G_sublogics where
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova show (G_sublogics lid sub) =
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova show lid++"."++head (sublogic_names lid sub)
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakovainstance Eq G_sublogics where
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova (G_sublogics lid1 l1) == (G_sublogics lid2 l2) =
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova coerce lid1 lid2 l1 == Just l2
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakovainstance Ord G_sublogics where
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova compare (G_sublogics lid1 l1) (G_sublogics lid2 l2) =
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova case coerce lid1 lid2 l2 of
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova Just l2' -> compare l1 l2' {-if l1==l2' then EQ
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova else if l1 <<= l2' then LT
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova Nothing -> error "Attempt to compare sublogics of different logics"
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova-- | Homogeneous Grothendieck signature morphisms
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakovadata G_morphism = forall lid sublogics
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova basic_spec sentence symb_items symb_map_items
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova sign morphism symbol raw_symbol proof_tree .
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova Logic lid sublogics
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova basic_spec sentence symb_items symb_map_items
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova sign morphism symbol raw_symbol proof_tree =>
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova G_morphism lid morphism
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakovainstance Show G_morphism where
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova show (G_morphism _ l) = show l
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova----------------------------------------------------------------
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova-- Existential types for the logic graph
9d770d1ea15092156d65e2a89b081eeeb8c6b153Kristina Sojakova----------------------------------------------------------------
tyconAnyComorphism = mkTyCon "Logic.Grothendieck.AnyComorphism"
logics :: Map.Map String AnyLogic,
comorphisms :: Map.Map String AnyComorphism,
inclusions :: Map.Map (String,String) AnyComorphism
case Map.lookup logname (logics logicGraph) of
$ Map.lookup mainLogic (logics logicGraph)
$ Map.lookup name (comorphisms logicGraph)
tyconAnyComorphismAux = mkTyCon "Logic.Grothendieck.AnyComorphismAux"
else case Map.lookup (ln1,ln2) (inclusions logicGraph) of
List.nub $ map fst $ iterateComp (0::Int) [(idc,[idc])]
coMors = Map.elems $ comorphisms lg
newL = List.nub (l ++ (concat (map extend l)))