Grothendieck.hs revision 8ddc7a5666b6887cf3a2c7c29e4691e04373545f
ce5ff829db5f0bb4f16ad4de150eed4401d6acd5Christian MaederModule : $Header$
10397bcc134edbcfbe3ae2c7ea4c6080036aae22Christian MaederCopyright : (c) Till Mossakowski, and Uni Bremen 2002-2004
97018cf5fa25b494adffd7e9b4e87320dae6bf47Christian MaederLicence : similar to LGPL, see HetCATS/LICENCE.txt or LIZENZ.txt
eca29a7be76eb73944ec19b06eda3d6a9e6e543dChristian MaederMaintainer : till@tzi.de
ce5ff829db5f0bb4f16ad4de150eed4401d6acd5Christian MaederStability : provisional
ce5ff829db5f0bb4f16ad4de150eed4401d6acd5Christian MaederPortability : non-portable (overlapping instances, dynamics, existentials)
717686b54b9650402e2ebfbaadf433eab8ba5171Christian Maeder The Grothendieck logic is defined to be the
3f63b98c111e5e2bb2cf13795cf6e084a78b0a8dChristian Maeder heterogeneous logic over the logic graph.
3f63b98c111e5e2bb2cf13795cf6e084a78b0a8dChristian Maeder This will be the logic over which the data
3f63b98c111e5e2bb2cf13795cf6e084a78b0a8dChristian Maeder structures and algorithms for specification in-the-large
15c12a3ac049a4528da05b1017b78145f308aeb0Christian Maeder R. Diaconescu:
3f63b98c111e5e2bb2cf13795cf6e084a78b0a8dChristian Maeder Grothendieck institutions
f353be6210f67ffd4a46967bba749afc968cee52Christian Maeder J. applied categorical structures 10, 2002, p. 383-402.
15c12a3ac049a4528da05b1017b78145f308aeb0Christian Maeder T. Mossakowski:
15c12a3ac049a4528da05b1017b78145f308aeb0Christian Maeder Heterogeneous development graphs and heterogeneous borrowing
3f63b98c111e5e2bb2cf13795cf6e084a78b0a8dChristian Maeder Fossacs 2002, LNCS 2303, p. 326-341
fc7df539e6d41b050161ed8f9ae6e444b1b5ab14Christian Maeder T. Mossakowski: Foundations of heterogeneous specification
2b9022bd5dfb351d1d80f61680336effeccfa23eChristian Maeder T. Mossakowski:
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maeder Relating CASL with Other Specification Languages:
d3bca27d616c5741d0b18776c8a0848ec31c87f4Christian Maeder the Institution Level
2b9022bd5dfb351d1d80f61680336effeccfa23eChristian Maeder Theoretical Computer Science 286, 2002, p. 367-475
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maederimport qualified Common.Lib.Map as Map
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maederimport qualified Common.Lib.Set as Set
f4741f6b7da52b5417899c8fcbe4349b920b006eChristian Maederimport qualified Data.List as List
f4741f6b7da52b5417899c8fcbe4349b920b006eChristian Maeder------------------------------------------------------------------
f4741f6b7da52b5417899c8fcbe4349b920b006eChristian Maeder--"Grothendieck" versions of the various parts of type class Logic
f4741f6b7da52b5417899c8fcbe4349b920b006eChristian Maeder------------------------------------------------------------------
ce5ff829db5f0bb4f16ad4de150eed4401d6acd5Christian Maeder-- | Grothendieck basic specifications
cf5149eb4d0faef6272231879c04aa740f5abc2bChristian Maederdata G_basic_spec = forall lid sublogics
cf5149eb4d0faef6272231879c04aa740f5abc2bChristian Maeder basic_spec sentence symb_items symb_map_items
cf5149eb4d0faef6272231879c04aa740f5abc2bChristian Maeder sign morphism symbol raw_symbol proof_tree .
cf5149eb4d0faef6272231879c04aa740f5abc2bChristian Maeder Logic lid sublogics
cf5149eb4d0faef6272231879c04aa740f5abc2bChristian Maeder basic_spec sentence symb_items symb_map_items
cf5149eb4d0faef6272231879c04aa740f5abc2bChristian Maeder sign morphism symbol raw_symbol proof_tree =>
cf5149eb4d0faef6272231879c04aa740f5abc2bChristian Maeder G_basic_spec lid basic_spec
f4741f6b7da52b5417899c8fcbe4349b920b006eChristian Maederinstance Show G_basic_spec where
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maeder show (G_basic_spec _ s) = show s
f4741f6b7da52b5417899c8fcbe4349b920b006eChristian Maederinstance PrettyPrint G_basic_spec where
f4741f6b7da52b5417899c8fcbe4349b920b006eChristian Maeder printText0 ga (G_basic_spec _ s) = printText0 ga s
f4741f6b7da52b5417899c8fcbe4349b920b006eChristian Maeder-- | Grothendieck sentences
04dada28736b4a237745e92063d8bdd49a362debChristian Maederdata G_sentence = forall lid sublogics
ce5ff829db5f0bb4f16ad4de150eed4401d6acd5Christian Maeder basic_spec sentence symb_items symb_map_items
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maeder sign morphism symbol raw_symbol proof_tree .
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maeder Logic lid sublogics
ccf3de3d66b521a260e5c22d335c64a48e3f0195Christian Maeder basic_spec sentence symb_items symb_map_items
ccf3de3d66b521a260e5c22d335c64a48e3f0195Christian Maeder sign morphism symbol raw_symbol proof_tree =>
8338fbf3cfb9cf981261d893286f070bd9fa17efChristian Maeder G_sentence lid sentence
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maederinstance Show G_sentence where
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maeder show (G_sentence _ s) = show s
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maeder-- | Grothendieck sentence lists
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maederdata G_l_sentence_list = forall lid sublogics
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maeder basic_spec sentence symb_items symb_map_items
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maeder sign morphism symbol raw_symbol proof_tree .
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maeder Logic lid sublogics
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maeder basic_spec sentence symb_items symb_map_items
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maeder sign morphism symbol raw_symbol proof_tree =>
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maeder G_l_sentence_list lid [Named sentence]
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maederinstance Show G_l_sentence_list where
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maeder show (G_l_sentence_list _ s) = show s
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maederinstance Eq G_l_sentence_list where
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maeder (G_l_sentence_list i1 nl1) == (G_l_sentence_list i2 nl2) =
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maeder coerce i1 i2 nl1 == Just nl2
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maedereq_G_l_sentence_set :: G_l_sentence_list -> G_l_sentence_list -> Bool
e76e6a43f51438215737d6fc176c89da05bb86daChristian Maedereq_G_l_sentence_set (G_l_sentence_list i1 nl1) (G_l_sentence_list i2 nl2) =
3f63b98c111e5e2bb2cf13795cf6e084a78b0a8dChristian Maeder case coerce i1 i2 nl1 of
0df692ce8b9293499b2e1768458613a63e7b5cd0Christian Maeder Just nl1' -> Set.fromList nl1' == Set.fromList nl2
0df692ce8b9293499b2e1768458613a63e7b5cd0Christian Maeder Nothing -> False
f626b1acbe874a48143a6f8d6246bf9d7a055ffbChristian Maeder-- | Grothendieck signatures
f626b1acbe874a48143a6f8d6246bf9d7a055ffbChristian Maederdata G_sign = forall lid sublogics
15c12a3ac049a4528da05b1017b78145f308aeb0Christian Maeder basic_spec sentence symb_items symb_map_items
15c12a3ac049a4528da05b1017b78145f308aeb0Christian Maeder sign morphism symbol raw_symbol proof_tree .
cc8b603388a7deb7fb8045db0341f550f8be5844Christian Maeder Logic lid sublogics
f4741f6b7da52b5417899c8fcbe4349b920b006eChristian Maeder basic_spec sentence symb_items symb_map_items
f4741f6b7da52b5417899c8fcbe4349b920b006eChristian Maeder sign morphism symbol raw_symbol proof_tree =>
f4741f6b7da52b5417899c8fcbe4349b920b006eChristian Maeder G_sign lid sign
15c12a3ac049a4528da05b1017b78145f308aeb0Christian MaedertyconG_sign :: TyCon
15c12a3ac049a4528da05b1017b78145f308aeb0Christian MaedertyconG_sign = mkTyCon "Logic.Grothendieck.G_sign"
15c12a3ac049a4528da05b1017b78145f308aeb0Christian Maederinstance Typeable G_sign where
f4741f6b7da52b5417899c8fcbe4349b920b006eChristian Maeder typeOf _ = mkTyConApp tyconG_sign []
f4741f6b7da52b5417899c8fcbe4349b920b006eChristian Maederinstance Eq G_sign where
cc8b603388a7deb7fb8045db0341f550f8be5844Christian Maeder (G_sign i1 sigma1) == (G_sign i2 sigma2) =
cc8b603388a7deb7fb8045db0341f550f8be5844Christian Maeder coerce i1 i2 sigma1 == Just sigma2
1d589334ba6b4a4cbfb35307a7a732261e77b0cdChristian Maeder-- | prefer a faster subsignature test if possible
cc8b603388a7deb7fb8045db0341f550f8be5844Christian Maederis_subgsign :: G_sign -> G_sign -> Bool
cc8b603388a7deb7fb8045db0341f550f8be5844Christian Maederis_subgsign (G_sign i1 sigma1) (G_sign i2 sigma2) =
cc8b603388a7deb7fb8045db0341f550f8be5844Christian Maeder maybe False (is_subsig i1 sigma1) $ coerce i2 i1 sigma2
e92ae8b45c138b6cf7db8b69e2d099d7f62f24f0Christian Maederinstance Show G_sign where
36c6cc568751e4235502cfee00ba7b597dae78dcChristian Maeder show (G_sign _ s) = show s
ac19f8695aa1b2d2d1cd1319da2530edd8f46a96Christian Maederinstance PrettyPrint G_sign where
ac19f8695aa1b2d2d1cd1319da2530edd8f46a96Christian Maeder printText0 ga (G_sign _ s) = printText0 ga s
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian MaederlangNameSig :: G_sign -> String
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian MaederlangNameSig (G_sign lid _) = language_name lid
15c12a3ac049a4528da05b1017b78145f308aeb0Christian Maeder-- | Grothendieck signature lists
15c12a3ac049a4528da05b1017b78145f308aeb0Christian Maederdata G_sign_list = forall lid sublogics
15c12a3ac049a4528da05b1017b78145f308aeb0Christian Maeder basic_spec sentence symb_items symb_map_items
15c12a3ac049a4528da05b1017b78145f308aeb0Christian Maeder sign morphism symbol raw_symbol proof_tree .
15c12a3ac049a4528da05b1017b78145f308aeb0Christian Maeder Logic lid sublogics
8338fbf3cfb9cf981261d893286f070bd9fa17efChristian Maeder basic_spec sentence symb_items symb_map_items
355a453397fa18360bbaeb0f1068ad6a299a1dffChristian Maeder sign morphism symbol raw_symbol proof_tree =>
0f67ca7b0c738a28f6688ba6e96d44d7c14af611Christian Maeder G_sign_list lid [sign]
88ece6e49930670e8fd3ee79c89a2e918d2fbd0cChristian Maeder-- | Grothendieck extended signatures
0f67ca7b0c738a28f6688ba6e96d44d7c14af611Christian Maederdata G_ext_sign = forall lid sublogics
88ece6e49930670e8fd3ee79c89a2e918d2fbd0cChristian Maeder basic_spec sentence symb_items symb_map_items
8338fbf3cfb9cf981261d893286f070bd9fa17efChristian Maeder sign morphism symbol raw_symbol proof_tree .
8338fbf3cfb9cf981261d893286f070bd9fa17efChristian Maeder Logic lid sublogics
355a453397fa18360bbaeb0f1068ad6a299a1dffChristian Maeder basic_spec sentence symb_items symb_map_items
0f67ca7b0c738a28f6688ba6e96d44d7c14af611Christian Maeder sign morphism symbol raw_symbol proof_tree =>
355a453397fa18360bbaeb0f1068ad6a299a1dffChristian Maeder G_ext_sign lid sign (Set.Set symbol)
355a453397fa18360bbaeb0f1068ad6a299a1dffChristian MaedertyconG_ext_sign :: TyCon
0f67ca7b0c738a28f6688ba6e96d44d7c14af611Christian MaedertyconG_ext_sign = mkTyCon "Logic.Grothendieck.G_ext_sign"
0f67ca7b0c738a28f6688ba6e96d44d7c14af611Christian Maederinstance Typeable G_ext_sign where
15c12a3ac049a4528da05b1017b78145f308aeb0Christian Maeder typeOf _ = mkTyConApp tyconG_ext_sign []
15c12a3ac049a4528da05b1017b78145f308aeb0Christian Maederinstance Eq G_ext_sign where
15c12a3ac049a4528da05b1017b78145f308aeb0Christian Maeder (G_ext_sign i1 sigma1 sys1) == (G_ext_sign i2 sigma2 sys2) =
15c12a3ac049a4528da05b1017b78145f308aeb0Christian Maeder coerce i1 i2 sigma1 == Just sigma2
15c12a3ac049a4528da05b1017b78145f308aeb0Christian Maeder && coerce i1 i2 sys1 == Just sys2
15c12a3ac049a4528da05b1017b78145f308aeb0Christian Maederinstance Show G_ext_sign where
0f67ca7b0c738a28f6688ba6e96d44d7c14af611Christian Maeder show (G_ext_sign _ s _) = show s
20fe556546c9277cf017931a07d90add61f199d9Christian Maederinstance PrettyPrint G_ext_sign where
b645cf3dc1e449038ed291bbd11fcc6e02b2fc7fChristian Maeder printText0 ga (G_ext_sign _ s _) = printText0 ga s
b645cf3dc1e449038ed291bbd11fcc6e02b2fc7fChristian MaederlangNameExtSig :: G_ext_sign -> String
b645cf3dc1e449038ed291bbd11fcc6e02b2fc7fChristian MaederlangNameExtSig (G_ext_sign lid _ _) = language_name lid
20fe556546c9277cf017931a07d90add61f199d9Christian Maeder-- | Grothendieck theories
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maederdata G_theory = forall lid sublogics
20fe556546c9277cf017931a07d90add61f199d9Christian Maeder basic_spec sentence symb_items symb_map_items
20fe556546c9277cf017931a07d90add61f199d9Christian Maeder sign morphism symbol raw_symbol proof_tree .
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder Logic lid sublogics
b645cf3dc1e449038ed291bbd11fcc6e02b2fc7fChristian Maeder basic_spec sentence symb_items symb_map_items
3f63b98c111e5e2bb2cf13795cf6e084a78b0a8dChristian Maeder sign morphism symbol raw_symbol proof_tree =>
f626b1acbe874a48143a6f8d6246bf9d7a055ffbChristian Maeder G_theory lid sign [Named sentence]
15c12a3ac049a4528da05b1017b78145f308aeb0Christian Maeder-- | compute sublogic of a theory
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian MaedersublogicOfTh :: G_theory -> G_sublogics
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian MaedersublogicOfTh (G_theory lid sigma sens) =
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder (min_sublogic_sign lid sigma)
15c12a3ac049a4528da05b1017b78145f308aeb0Christian Maeder (map (min_sublogic_sentence lid . sentence) sens)
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder in G_sublogics lid sub
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder-- | simplify a theory (throw away qualifications)
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian MaedersimplifyTh :: G_theory -> G_theory
3f63b98c111e5e2bb2cf13795cf6e084a78b0a8dChristian MaedersimplifyTh (G_theory lid sigma sens) =
f626b1acbe874a48143a6f8d6246bf9d7a055ffbChristian Maeder G_theory lid sigma (map (mapNamed (simplify_sen lid sigma)) sens)
15c12a3ac049a4528da05b1017b78145f308aeb0Christian Maeder-- | Grothendieck symbols
15c12a3ac049a4528da05b1017b78145f308aeb0Christian Maederdata G_symbol = forall lid sublogics
15c12a3ac049a4528da05b1017b78145f308aeb0Christian Maeder basic_spec sentence symb_items symb_map_items
15c12a3ac049a4528da05b1017b78145f308aeb0Christian Maeder sign morphism symbol raw_symbol proof_tree .
15c12a3ac049a4528da05b1017b78145f308aeb0Christian Maeder Logic lid sublogics
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder basic_spec sentence symb_items symb_map_items
aff01ee50b66032469c232e00c945d1fd4f57d1bChristian Maeder sign morphism symbol raw_symbol proof_tree =>
20fe556546c9277cf017931a07d90add61f199d9Christian Maeder G_symbol lid symbol
278de8173a1b7b7f6299f7c804135d14560176daChristian Maederinstance Show G_symbol where
15c12a3ac049a4528da05b1017b78145f308aeb0Christian Maeder show (G_symbol _ s) = show s
15c12a3ac049a4528da05b1017b78145f308aeb0Christian Maederinstance Eq G_symbol where
278de8173a1b7b7f6299f7c804135d14560176daChristian Maeder (G_symbol i1 s1) == (G_symbol i2 s2) =
c9b711a46e5138b2742727817c8071960e673073Christian Maeder coerce i1 i2 s1 == Just s2
c9b711a46e5138b2742727817c8071960e673073Christian Maeder-- | Grothendieck symbol lists
c9b711a46e5138b2742727817c8071960e673073Christian Maederdata G_symb_items_list = forall lid sublogics
c9b711a46e5138b2742727817c8071960e673073Christian Maeder basic_spec sentence symb_items symb_map_items
c9b711a46e5138b2742727817c8071960e673073Christian Maeder sign morphism symbol raw_symbol proof_tree .
10397bcc134edbcfbe3ae2c7ea4c6080036aae22Christian Maeder Logic lid sublogics
tyconG_sublogics = mkTyCon "Logic.Grothendieck.G_sublogics"
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)))