Comorphism.hs revision 44fb55f639914f4f531641f32dd4904f15c510a4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
306763c67bb99228487345b32ab8c5c6cd41f23cChristian MaederModule : $Header$
306763c67bb99228487345b32ab8c5c6cd41f23cChristian MaederCopyright : (c) Till Mossakowski, Uni Bremen 2002-2004
97018cf5fa25b494adffd7e9b4e87320dae6bf47Christian MaederLicence : similar to LGPL, see HetCATS/LICENCE.txt or LIZENZ.txt
b4fbc96e05117839ca409f5f20f97b3ac872d1edTill MossakowskiMaintainer : hets@tzi.de
306763c67bb99228487345b32ab8c5c6cd41f23cChristian MaederStability : provisional
306763c67bb99228487345b32ab8c5c6cd41f23cChristian MaederPortability : non-portable (via Logic)
53310804002cd9e3c9c5844db3b984abcf001788Christian Maeder Provides data structures for institution comorphisms.
44fb55f639914f4f531641f32dd4904f15c510a4Till Mossakowski These are just collections of
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski functions between (some of) the types of logics.
306763c67bb99228487345b32ab8c5c6cd41f23cChristian Maeder{- References: see Logic.hs
5c602504f85bbac7ddf0226064452bdc7d4a8cd8Till Mossakowski Weak amalgamability, also for comorphisms
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski comorphism modifications
2ecf6cfb90e84d40f224cda5d92c191182c976d2Till Mossakowski comorphisms out of sublogic relationships
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski restrictions of comorphisms to sublogics
2ecf6cfb90e84d40f224cda5d92c191182c976d2Till Mossakowski morphisms and other translations via spans
53310804002cd9e3c9c5844db3b984abcf001788Christian Maederimport Common.AS_Annotation (Named, mapNamedM)
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowskiclass (Language cid,
59fa9b1349ae1e001d996da732c4ac805c2938e2Christian Maeder Logic lid1 sublogics1
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski basic_spec1 sentence1 symb_items1 symb_map_items1
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski sign1 morphism1 symbol1 raw_symbol1 proof_tree1,
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski Logic lid2 sublogics2
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski basic_spec2 sentence2 symb_items2 symb_map_items2
53310804002cd9e3c9c5844db3b984abcf001788Christian Maeder sign2 morphism2 symbol2 raw_symbol2 proof_tree2) =>
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski Comorphism cid
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski lid1 sublogics1 basic_spec1 sentence1 symb_items1 symb_map_items1
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski sign1 morphism1 symbol1 raw_symbol1 proof_tree1
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski lid2 sublogics2 basic_spec2 sentence2 symb_items2 symb_map_items2
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski sign2 morphism2 symbol2 raw_symbol2 proof_tree2
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski | cid -> lid1, cid -> lid2
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski -- source and target logic and sublogic
2ecf6cfb90e84d40f224cda5d92c191182c976d2Till Mossakowski -- the source sublogic is the maximal one for which the comorphism works
2ecf6cfb90e84d40f224cda5d92c191182c976d2Till Mossakowski -- the target sublogic is the resulting one
2ecf6cfb90e84d40f224cda5d92c191182c976d2Till Mossakowski sourceLogic :: cid -> lid1
4184cb191a9081cb2a9cf3ef5f060f56f0ca5922Till Mossakowski sourceSublogic :: cid -> sublogics1
8731f7b93b26083dc34a2c0937cd6493b42f2c2cTill Mossakowski targetLogic :: cid -> lid2
4184cb191a9081cb2a9cf3ef5f060f56f0ca5922Till Mossakowski targetSublogic :: cid -> sublogics2
8731f7b93b26083dc34a2c0937cd6493b42f2c2cTill Mossakowski -- finer information of target sublogics corresponding to source sublogics
2ecf6cfb90e84d40f224cda5d92c191182c976d2Till Mossakowski mapSublogic :: cid -> sublogics1 -> sublogics2
2ecf6cfb90e84d40f224cda5d92c191182c976d2Till Mossakowski -- default implementation
2ecf6cfb90e84d40f224cda5d92c191182c976d2Till Mossakowski mapSublogic cid _ = targetSublogic cid
2ecf6cfb90e84d40f224cda5d92c191182c976d2Till Mossakowski -- the translation functions are partial
53310804002cd9e3c9c5844db3b984abcf001788Christian Maeder -- because the target may be a sublanguage
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski -- map_basic_spec :: cid -> basic_spec1 -> Maybe basic_spec2
a89e661aad28f1b39f4fc9f9f9a4d46074234123Christian Maeder -- cover theoroidal comorphisms as well
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski map_sign :: cid -> sign1 -> Maybe (sign2,[Named sentence2])
5d6e7ea3bd14fc987436cff0f542393ea9ba34bbTill Mossakowski map_theory :: cid -> (sign1,[Named sentence1])
a89e661aad28f1b39f4fc9f9f9a4d46074234123Christian Maeder -> Maybe (sign2,[Named sentence2])
a89e661aad28f1b39f4fc9f9f9a4d46074234123Christian Maeder --default implementations
a89e661aad28f1b39f4fc9f9f9a4d46074234123Christian Maeder map_sign cid sign = map_theory cid (sign,[])
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski map_theory cid (sign,sens) = do
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski (sign',sens') <- map_sign cid sign
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski let sens'' = mapMaybe (mapNamedM (map_sentence cid sign)) sens
0647a6c86b231e391826c7715338ba29cb4934c0Christian Maeder return (sign',sens'++sens'')
0e51a998b1b213654c7a9eca451562041971f100Till Mossakowski map_morphism :: cid -> morphism1 -> Maybe morphism2
0e51a998b1b213654c7a9eca451562041971f100Till Mossakowski map_sentence :: cid -> sign1 -> sentence1 -> Maybe sentence2
0e51a998b1b213654c7a9eca451562041971f100Till Mossakowski -- also covers semi-comorphisms
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski -- with no sentence translation
19298cbfd6ee2abd904f3181af7760b965b822c3Christian Maeder -- - but these are spans!
19298cbfd6ee2abd904f3181af7760b965b822c3Christian Maeder map_symbol :: cid -> symbol1 -> Set symbol2
19298cbfd6ee2abd904f3181af7760b965b822c3Christian Maeder constituents :: cid -> [String]
19298cbfd6ee2abd904f3181af7760b965b822c3Christian Maeder -- default implementation
19298cbfd6ee2abd904f3181af7760b965b822c3Christian Maeder constituents cid = [language_name cid]
19298cbfd6ee2abd904f3181af7760b965b822c3Christian Maederdata IdComorphism lid sublogics =
19298cbfd6ee2abd904f3181af7760b965b822c3Christian Maeder IdComorphism lid sublogics deriving Show
53310804002cd9e3c9c5844db3b984abcf001788Christian MaederidComorphismTc :: TyCon
19298cbfd6ee2abd904f3181af7760b965b822c3Christian MaederidComorphismTc = mkTyCon "Logic.Comorphism.IdComorphism"
19298cbfd6ee2abd904f3181af7760b965b822c3Christian Maederinstance Typeable (IdComorphism lid sub) where
19298cbfd6ee2abd904f3181af7760b965b822c3Christian Maeder typeOf _ = mkTyConApp idComorphismTc []
53310804002cd9e3c9c5844db3b984abcf001788Christian Maederinstance Logic lid sublogics
53310804002cd9e3c9c5844db3b984abcf001788Christian Maeder basic_spec sentence symb_items symb_map_items
19298cbfd6ee2abd904f3181af7760b965b822c3Christian Maeder sign morphism symbol raw_symbol proof_tree =>
19298cbfd6ee2abd904f3181af7760b965b822c3Christian Maeder Language (IdComorphism lid sublogics) where
19298cbfd6ee2abd904f3181af7760b965b822c3Christian Maeder language_name (IdComorphism lid sub) =
19298cbfd6ee2abd904f3181af7760b965b822c3Christian Maeder case sublogic_names lid sub of
53310804002cd9e3c9c5844db3b984abcf001788Christian Maeder [] -> error "language_name IdComorphism"
19298cbfd6ee2abd904f3181af7760b965b822c3Christian Maeder h : _ -> "id_" ++ language_name lid ++ "." ++ h
53310804002cd9e3c9c5844db3b984abcf001788Christian Maederinstance Logic lid sublogics
797595aad6dfd626bc1c9df52616f1ac4235c669Till Mossakowski basic_spec sentence symb_items symb_map_items
797595aad6dfd626bc1c9df52616f1ac4235c669Till Mossakowski sign morphism symbol raw_symbol proof_tree =>
797595aad6dfd626bc1c9df52616f1ac4235c669Till Mossakowski Comorphism (IdComorphism lid sublogics)
797595aad6dfd626bc1c9df52616f1ac4235c669Till Mossakowski lid sublogics
797595aad6dfd626bc1c9df52616f1ac4235c669Till Mossakowski basic_spec sentence symb_items symb_map_items
53310804002cd9e3c9c5844db3b984abcf001788Christian Maeder sign morphism symbol raw_symbol proof_tree
797595aad6dfd626bc1c9df52616f1ac4235c669Till Mossakowski lid sublogics
933baca0720dae81434de384b32a93b47e754d09Christian Maeder basic_spec sentence symb_items symb_map_items
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski sign morphism symbol raw_symbol proof_tree
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski sourceLogic (IdComorphism lid _sub) = lid
586af0e9490a14dd3075095692b584c652584875Till Mossakowski targetLogic (IdComorphism lid _sub) = lid
53310804002cd9e3c9c5844db3b984abcf001788Christian Maeder sourceSublogic (IdComorphism _lid sub) = sub
53310804002cd9e3c9c5844db3b984abcf001788Christian Maeder targetSublogic (IdComorphism _lid sub) = sub
933baca0720dae81434de384b32a93b47e754d09Christian Maeder map_sign _ = \sigma -> Just(sigma,[])
933baca0720dae81434de384b32a93b47e754d09Christian Maeder map_morphism _ = Just
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski map_sentence _ = \_ -> Just
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski map_symbol _ = single
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski constituents _ = []
586af0e9490a14dd3075095692b584c652584875Till Mossakowskidata CompComorphism cid1 cid2 = CompComorphism cid1 cid2 deriving Show
e9249d3ecd51a2b6a966a58669953e58d703adc6Till MossakowskityconCompComorphism :: TyCon
e9249d3ecd51a2b6a966a58669953e58d703adc6Till MossakowskityconCompComorphism = mkTyCon "Logic.Comorphism.CompComorphism"
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowskiinstance Typeable (CompComorphism cid1 cid2) where
53310804002cd9e3c9c5844db3b984abcf001788Christian Maeder typeOf _ = mkTyConApp tyconCompComorphism []
933baca0720dae81434de384b32a93b47e754d09Christian Maederinstance (Comorphism cid1
933baca0720dae81434de384b32a93b47e754d09Christian Maeder lid1 sublogics1 basic_spec1 sentence1 symb_items1 symb_map_items1
933baca0720dae81434de384b32a93b47e754d09Christian Maeder sign1 morphism1 symbol1 raw_symbol1 proof_tree1
933baca0720dae81434de384b32a93b47e754d09Christian Maeder lid2 sublogics2 basic_spec2 sentence2 symb_items2 symb_map_items2
f2a87c712ea3cd13f86a95cae738f861f6c4a908Till Mossakowski sign2 morphism2 symbol2 raw_symbol2 proof_tree2,
19298cbfd6ee2abd904f3181af7760b965b822c3Christian Maeder Comorphism cid2
a89e661aad28f1b39f4fc9f9f9a4d46074234123Christian Maeder lid4 sublogics4 basic_spec4 sentence4 symb_items4 symb_map_items4
a89e661aad28f1b39f4fc9f9f9a4d46074234123Christian Maeder sign4 morphism4 symbol4 raw_symbol4 proof_tree4
88ece6e49930670e8fd3ee79c89a2e918d2fbd0cChristian Maeder lid3 sublogics3 basic_spec3 sentence3 symb_items3 symb_map_items3
0e51a998b1b213654c7a9eca451562041971f100Till Mossakowski sign3 morphism3 symbol3 raw_symbol3 proof_tree3)
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski => Language (CompComorphism cid1 cid2) where
d85e3f253f6af237c4b70bbfacb1bfecb5cfa678Christian Maeder language_name (CompComorphism cid1 cid2) =
d85e3f253f6af237c4b70bbfacb1bfecb5cfa678Christian Maeder language_name cid1++";"
ca8550c6d47234042130bdc10a152806ecbc9832Christian Maeder ++language_name cid2
ca8550c6d47234042130bdc10a152806ecbc9832Christian Maederinstance (Comorphism cid1
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski lid1 sublogics1 basic_spec1 sentence1 symb_items1 symb_map_items1
d85e3f253f6af237c4b70bbfacb1bfecb5cfa678Christian Maeder sign1 morphism1 symbol1 raw_symbol1 proof_tree1
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski lid2 sublogics2 basic_spec2 sentence2 symb_items2 symb_map_items2
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski sign2 morphism2 symbol2 raw_symbol2 proof_tree2,
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski Comorphism cid2
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski lid4 sublogics4 basic_spec4 sentence4 symb_items4 symb_map_items4
53310804002cd9e3c9c5844db3b984abcf001788Christian Maeder sign4 morphism4 symbol4 raw_symbol4 proof_tree4
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski lid3 sublogics3 basic_spec3 sentence3 symb_items3 symb_map_items3
d85e3f253f6af237c4b70bbfacb1bfecb5cfa678Christian Maeder sign3 morphism3 symbol3 raw_symbol3 proof_tree3)
d85e3f253f6af237c4b70bbfacb1bfecb5cfa678Christian Maeder => Comorphism (CompComorphism cid1 cid2)
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski lid1 sublogics1 basic_spec1 sentence1 symb_items1 symb_map_items1
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski sign1 morphism1 symbol1 raw_symbol1 proof_tree1
d85e3f253f6af237c4b70bbfacb1bfecb5cfa678Christian Maeder lid3 sublogics3 basic_spec3 sentence3 symb_items3 symb_map_items3
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski sign3 morphism3 symbol3 raw_symbol3 proof_tree3 where
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski sourceLogic (CompComorphism cid1 _) =
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski sourceLogic cid1
d85e3f253f6af237c4b70bbfacb1bfecb5cfa678Christian Maeder targetLogic (CompComorphism _ cid2) =
53310804002cd9e3c9c5844db3b984abcf001788Christian Maeder targetLogic cid2
f7819aa9d183836144a98c70d4fa7d65e31cb513Till Mossakowski sourceSublogic (CompComorphism cid1 _) =
53310804002cd9e3c9c5844db3b984abcf001788Christian Maeder sourceSublogic cid1
f7819aa9d183836144a98c70d4fa7d65e31cb513Till Mossakowski targetSublogic (CompComorphism _ cid2) =
53310804002cd9e3c9c5844db3b984abcf001788Christian Maeder targetSublogic cid2
8731f7b93b26083dc34a2c0937cd6493b42f2c2cTill Mossakowski map_sentence (CompComorphism cid1 cid2) =
53310804002cd9e3c9c5844db3b984abcf001788Christian Maeder do (si2,_) <- map_sign cid1 si1
53310804002cd9e3c9c5844db3b984abcf001788Christian Maeder se2 <- map_sentence cid1 si1 se1
f2a87c712ea3cd13f86a95cae738f861f6c4a908Till Mossakowski (si2', se2') <- mcoerce (targetLogic cid1) (sourceLogic cid2)
53310804002cd9e3c9c5844db3b984abcf001788Christian Maeder "Mapping sentence along comorphism" (si2, se2)
53310804002cd9e3c9c5844db3b984abcf001788Christian Maeder map_sentence cid2 si2' se2'
53310804002cd9e3c9c5844db3b984abcf001788Christian Maeder map_sign (CompComorphism cid1 cid2) =
53310804002cd9e3c9c5844db3b984abcf001788Christian Maeder do (si2, se2s) <- map_sign cid1 si1
53310804002cd9e3c9c5844db3b984abcf001788Christian Maeder (si2', se2s') <- mcoerce (targetLogic cid1) (sourceLogic cid2)
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski "Mapping signature along comorphism"(si2, se2s)
53310804002cd9e3c9c5844db3b984abcf001788Christian Maeder (si3, se3s) <- map_sign cid2 si2'
53310804002cd9e3c9c5844db3b984abcf001788Christian Maeder return (si3, se3s ++ catMaybes
53310804002cd9e3c9c5844db3b984abcf001788Christian Maeder (map (mapNamedM (map_sentence cid2 si2')) se2s'))
53310804002cd9e3c9c5844db3b984abcf001788Christian Maeder map_theory (CompComorphism cid1 cid2) =
922819b1c2d383a0fa5d70e1c4aa76667e2f1ca3Christian Maeder do ti2 <- map_theory cid1 ti1
e9249d3ecd51a2b6a966a58669953e58d703adc6Till Mossakowski ti2' <- mcoerce (targetLogic cid1) (sourceLogic cid2)
53310804002cd9e3c9c5844db3b984abcf001788Christian Maeder "Mapping theory along comorphism" ti2
53310804002cd9e3c9c5844db3b984abcf001788Christian Maeder map_theory cid2 ti2'
53310804002cd9e3c9c5844db3b984abcf001788Christian Maeder map_morphism (CompComorphism cid1 cid2) = \ m1 ->
53310804002cd9e3c9c5844db3b984abcf001788Christian Maeder do m2 <- map_morphism cid1 m1
5bb3727ef464d9f08ab0decb2d4a59c1352a389eChristian Maeder m3 <- mcoerce (targetLogic cid1) (sourceLogic cid2)
5bb3727ef464d9f08ab0decb2d4a59c1352a389eChristian Maeder "Mapping signature morphism along comorphism"m2
53310804002cd9e3c9c5844db3b984abcf001788Christian Maeder map_morphism cid2 m3
922819b1c2d383a0fa5d70e1c4aa76667e2f1ca3Christian Maeder map_symbol (CompComorphism cid1 cid2) = \ s1 ->
9d34a8049237647d0188ee2ec88db2dc45f1f848Till Mossakowski let mycast = fromJust . mcoerce (targetLogic cid1) (sourceLogic cid2)
d85e3f253f6af237c4b70bbfacb1bfecb5cfa678Christian Maeder "Mapping symbol along comorphism"
53310804002cd9e3c9c5844db3b984abcf001788Christian Maeder (map (map_symbol cid2 . mycast)
922819b1c2d383a0fa5d70e1c4aa76667e2f1ca3Christian Maeder (toList (map_symbol cid1 s1)))
0647a6c86b231e391826c7715338ba29cb4934c0Christian Maeder constituents (CompComorphism cid1 cid2) =
53310804002cd9e3c9c5844db3b984abcf001788Christian Maeder constituents cid1 ++ constituents cid2