PrintDevGraph.hs revision c35969f341eb137848e9c0874503bed8c419cbd2
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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
c797f343be2f3619bb1f5569753166ec49d27bdbChristian MaederModule : $Header$
c797f343be2f3619bb1f5569753166ec49d27bdbChristian MaederDescription : pretty printing (parts of) a LibEnv
97018cf5fa25b494adffd7e9b4e87320dae6bf47Christian MaederCopyright : (c) C. Maeder, Uni Bremen 2002-2006
c797f343be2f3619bb1f5569753166ec49d27bdbChristian MaederLicense : similar to LGPL, see HetCATS/LICENSE.txt or LIZENZ.txt
c797f343be2f3619bb1f5569753166ec49d27bdbChristian MaederMaintainer : Christian.Maeder@dfki.de
c797f343be2f3619bb1f5569753166ec49d27bdbChristian MaederStability : provisional
f3a94a197960e548ecd6520bb768cb0d547457bbChristian MaederPortability : non-portable(DevGraph)
462ec4b2fa3e0e788eb60dcb4aebc518298f342cChristian Maederpretty printing (parts of) a LibEnv
462ec4b2fa3e0e788eb60dcb4aebc518298f342cChristian Maeder ( prettyLibEnv
4fb19f237193a3bd6778f8aee3b6dd8da5856665Christian Maeder , prettyHistElem
4fb19f237193a3bd6778f8aee3b6dd8da5856665Christian Maeder , prettyHistory
462ec4b2fa3e0e788eb60dcb4aebc518298f342cChristian Maeder , prettyLEdge
b645cf3dc1e449038ed291bbd11fcc6e02b2fc7fChristian Maeder , dgOriginHeader
04dada28736b4a237745e92063d8bdd49a362debChristian Maeder , dgOriginSpec
4fb19f237193a3bd6778f8aee3b6dd8da5856665Christian Maeder , dgLinkOriginHeader
462ec4b2fa3e0e788eb60dcb4aebc518298f342cChristian Maeder , dgLinkOriginSpec
4fb19f237193a3bd6778f8aee3b6dd8da5856665Christian Maeder , dgRuleHeader
89054b2b95a3f92e78324dc852f3d34704e2ca49Christian Maeder , dgRuleEdges
4fb19f237193a3bd6778f8aee3b6dd8da5856665Christian Maederimport qualified Common.Lib.SizedList as SizedList
6cca02cb6a5ae882d887a879f8b7a71941c3715cChristian Maederimport qualified Common.Lib.Rel as Rel
6cca02cb6a5ae882d887a879f8b7a71941c3715cChristian Maederimport qualified Common.Lib.Graph as Tree
6cca02cb6a5ae882d887a879f8b7a71941c3715cChristian Maederimport qualified Data.Map as Map
6cca02cb6a5ae882d887a879f8b7a71941c3715cChristian Maederimport qualified Data.Set as Set
462ec4b2fa3e0e788eb60dcb4aebc518298f342cChristian MaederprintTh :: GlobalAnnos -> SIMPLE_ID -> G_theory -> Doc
462ec4b2fa3e0e788eb60dcb4aebc518298f342cChristian MaederprintTh oga sn g =
462ec4b2fa3e0e788eb60dcb4aebc518298f342cChristian Maeder let ga = removeProblematicListAnnos oga in
6cca02cb6a5ae882d887a879f8b7a71941c3715cChristian Maeder useGlobalAnnos ga $ pretty ga $+$ prettyGTheorySL g $+$
6cca02cb6a5ae882d887a879f8b7a71941c3715cChristian Maeder sep [if null (tokStr sn) then Doc.empty else
6cca02cb6a5ae882d887a879f8b7a71941c3715cChristian Maeder keyword specS <+> sidDoc sn <+> equals, prettyGTheory g]
6cca02cb6a5ae882d887a879f8b7a71941c3715cChristian MaederremoveProblematicListAnnos :: GlobalAnnos -> GlobalAnnos
462ec4b2fa3e0e788eb60dcb4aebc518298f342cChristian MaederremoveProblematicListAnnos ga = let
462ec4b2fa3e0e788eb60dcb4aebc518298f342cChristian Maeder is = Map.keysSet $ Rel.toMap $ prec_annos ga
4fb19f237193a3bd6778f8aee3b6dd8da5856665Christian Maeder la = literal_annos ga
462ec4b2fa3e0e788eb60dcb4aebc518298f342cChristian Maeder nla = la { list_lit = Map.filterWithKey ( \ li _ ->
462ec4b2fa3e0e788eb60dcb4aebc518298f342cChristian Maeder let (op, cl, cs) = getListBrackets li in
462ec4b2fa3e0e788eb60dcb4aebc518298f342cChristian Maeder cs == ics && isPrefixOf op ts && isSuffixOf cl ts) is)
4fb19f237193a3bd6778f8aee3b6dd8da5856665Christian Maeder $ list_lit la }
4fb19f237193a3bd6778f8aee3b6dd8da5856665Christian Maeder Result _ (Just lm) = store_literal_map Map.empty $ convertLiteralAnnos nla
f4741f6b7da52b5417899c8fcbe4349b920b006eChristian Maeder in ga { literal_annos = nla
4fb19f237193a3bd6778f8aee3b6dd8da5856665Christian Maeder , literal_map = lm }
4fb19f237193a3bd6778f8aee3b6dd8da5856665Christian Maeder-- * pretty instances
462ec4b2fa3e0e788eb60dcb4aebc518298f342cChristian MaedershowXPathComp :: XPathPart -> String
4fb19f237193a3bd6778f8aee3b6dd8da5856665Christian MaedershowXPathComp c = case c of
4fb19f237193a3bd6778f8aee3b6dd8da5856665Christian Maeder ElemName s -> s
6cca02cb6a5ae882d887a879f8b7a71941c3715cChristian Maeder ChildIndex i -> "Spec[" ++ show i ++ "]"
6cca02cb6a5ae882d887a879f8b7a71941c3715cChristian MaedershowXPath :: [XPathPart] -> String
6cca02cb6a5ae882d887a879f8b7a71941c3715cChristian MaedershowXPath l = case l of
6cca02cb6a5ae882d887a879f8b7a71941c3715cChristian Maeder _ -> concatMap (('/' :) . showXPathComp) l
6cca02cb6a5ae882d887a879f8b7a71941c3715cChristian MaedershowNodeId :: Node -> String
6cca02cb6a5ae882d887a879f8b7a71941c3715cChristian MaedershowNodeId i = "node " ++ show i
6cca02cb6a5ae882d887a879f8b7a71941c3715cChristian Maederinstance Pretty NodeSig where
6cca02cb6a5ae882d887a879f8b7a71941c3715cChristian Maeder pretty (NodeSig n sig) = fsep [ text (showNodeId n) <> colon, pretty sig ]
6cca02cb6a5ae882d887a879f8b7a71941c3715cChristian MaederdgOriginSpec :: DGOrigin -> Maybe SIMPLE_ID
6cca02cb6a5ae882d887a879f8b7a71941c3715cChristian MaederdgOriginSpec o = case o of
6cca02cb6a5ae882d887a879f8b7a71941c3715cChristian Maeder DGInst n -> Just n
6cca02cb6a5ae882d887a879f8b7a71941c3715cChristian Maeder DGFitView n -> Just n
15bb922b665fcd44c6230a1202785d0c7890e90cChristian MaederdgOriginHeader :: DGOrigin -> String
6cca02cb6a5ae882d887a879f8b7a71941c3715cChristian MaederdgOriginHeader o = case o of
6cca02cb6a5ae882d887a879f8b7a71941c3715cChristian Maeder DGEmpty -> "empty-spec"
462ec4b2fa3e0e788eb60dcb4aebc518298f342cChristian Maeder DGBasic -> "foreign-basic-spec"
f4741f6b7da52b5417899c8fcbe4349b920b006eChristian Maeder DGBasicSpec _ _ -> "basic-spec"
4fb19f237193a3bd6778f8aee3b6dd8da5856665Christian Maeder DGExtension -> "extension"
4fb19f237193a3bd6778f8aee3b6dd8da5856665Christian Maeder DGLogicCoercion -> "logic-translation"
4fb19f237193a3bd6778f8aee3b6dd8da5856665Christian Maeder DGTranslation _ -> "translation"
4fb19f237193a3bd6778f8aee3b6dd8da5856665Christian Maeder DGUnion -> "union"
6cca02cb6a5ae882d887a879f8b7a71941c3715cChristian Maeder DGRestriction _ -> "restriction"
4fb19f237193a3bd6778f8aee3b6dd8da5856665Christian Maeder DGRevealTranslation -> "translation part of a revealing"
6cca02cb6a5ae882d887a879f8b7a71941c3715cChristian Maeder DGFreeOrCofree v -> map toLower (show v) ++ "-spec"
6cca02cb6a5ae882d887a879f8b7a71941c3715cChristian Maeder DGLocal -> "local-spec"
4fb19f237193a3bd6778f8aee3b6dd8da5856665Christian Maeder DGClosed -> "closed-spec"
4fb19f237193a3bd6778f8aee3b6dd8da5856665Christian Maeder DGLogicQual -> "spec with logic qualifier"
4fb19f237193a3bd6778f8aee3b6dd8da5856665Christian Maeder DGData -> "data-spec"
6cca02cb6a5ae882d887a879f8b7a71941c3715cChristian Maeder DGFormalParams -> "formal parameters"
4fb19f237193a3bd6778f8aee3b6dd8da5856665Christian Maeder DGImports -> "arch import"
6cca02cb6a5ae882d887a879f8b7a71941c3715cChristian Maeder DGInst _ -> "instantiation"
6cca02cb6a5ae882d887a879f8b7a71941c3715cChristian Maeder DGFitSpec -> "fitting-spec"
4fb19f237193a3bd6778f8aee3b6dd8da5856665Christian Maeder DGFitView _ -> "fitting-view"
4fb19f237193a3bd6778f8aee3b6dd8da5856665Christian Maeder DGProof -> "proof-construct"
04dada28736b4a237745e92063d8bdd49a362debChristian Maeder DGNormalForm n -> "normal-form(" ++ shows n ")"
04dada28736b4a237745e92063d8bdd49a362debChristian Maeder DGintegratedSCC -> "OWL spec with integrated strongly connected components"
15bb922b665fcd44c6230a1202785d0c7890e90cChristian Maeder DGFlattening -> "flattening"
4fb19f237193a3bd6778f8aee3b6dd8da5856665Christian Maederinstance Pretty DGOrigin where
04dada28736b4a237745e92063d8bdd49a362debChristian Maeder pretty o = text (dgOriginHeader o) <+> pretty (dgOriginSpec o)
76fa667489c5e0868ac68de9f0253ac10f73d0b5Christian Maeder $+$ case o of
76fa667489c5e0868ac68de9f0253ac10f73d0b5Christian Maeder DGBasicSpec gbs syms -> specBraces (pretty gbs) $+$
76fa667489c5e0868ac68de9f0253ac10f73d0b5Christian Maeder text "new symbols:" $+$ pretty syms
76fa667489c5e0868ac68de9f0253ac10f73d0b5Christian Maeder DGTranslation (Renamed r) -> pretty r
76fa667489c5e0868ac68de9f0253ac10f73d0b5Christian Maeder DGRestriction (Restricted r) -> pretty r
4fb19f237193a3bd6778f8aee3b6dd8da5856665Christian Maederinstance Pretty DGNodeInfo where
4fb19f237193a3bd6778f8aee3b6dd8da5856665Christian Maeder pretty c = case c of
4fb19f237193a3bd6778f8aee3b6dd8da5856665Christian Maeder DGNode {} -> pretty $ node_origin c
4fb19f237193a3bd6778f8aee3b6dd8da5856665Christian Maeder pretty (getLibId $ ref_libname c) <+> text (showNodeId $ ref_node c)
b984ff0ba75221f64451c1e69b3977967d4e99a1Christian MaederprettyDGNodeLab :: DGNodeLab -> Doc
6cca02cb6a5ae882d887a879f8b7a71941c3715cChristian MaederprettyDGNodeLab l = sep [ text $ getDGNodeName l, pretty $ nodeInfo l]
b984ff0ba75221f64451c1e69b3977967d4e99a1Christian Maederinstance Pretty DGNodeLab where
6cca02cb6a5ae882d887a879f8b7a71941c3715cChristian Maeder pretty l = vcat
6cca02cb6a5ae882d887a879f8b7a71941c3715cChristian Maeder [ text $ "xpath: " ++ showXPath (reverse $ xpath $ dgn_name l)
4fb19f237193a3bd6778f8aee3b6dd8da5856665Christian Maeder , pretty $ getNodeConsStatus l
15bb922b665fcd44c6230a1202785d0c7890e90cChristian Maeder , if hasOpenGoals l then text "has open goals" else
6cca02cb6a5ae882d887a879f8b7a71941c3715cChristian Maeder if hasSenKind (const True) l then Doc.empty else text "locally empty"
6cca02cb6a5ae882d887a879f8b7a71941c3715cChristian Maeder , if labelHasHiding l then text "has ingoing hiding link" else Doc.empty
4fb19f237193a3bd6778f8aee3b6dd8da5856665Christian Maeder , case dgn_nf l of
4fb19f237193a3bd6778f8aee3b6dd8da5856665Christian Maeder Just n -> text "normal form:" <+> text (showNodeId n)
4fb19f237193a3bd6778f8aee3b6dd8da5856665Christian Maeder , text "origin:" $+$ pretty (nodeInfo l)
4fb19f237193a3bd6778f8aee3b6dd8da5856665Christian Maeder , case dgn_sigma l of
4fb19f237193a3bd6778f8aee3b6dd8da5856665Christian Maeder Just gm -> text "normal form inclusion:" $+$ pretty gm
6cca02cb6a5ae882d887a879f8b7a71941c3715cChristian Maeder , text "local theory:"
4fb19f237193a3bd6778f8aee3b6dd8da5856665Christian Maeder , pretty $ dgn_theory l]
b984ff0ba75221f64451c1e69b3977967d4e99a1Christian Maederinstance Pretty EdgeId where
b984ff0ba75221f64451c1e69b3977967d4e99a1Christian Maeder pretty (EdgeId i) = text $ show i
ee9eddfa6953868fd6fbaff0d9ff68675a13675aChristian MaederdgLinkOriginSpec :: DGLinkOrigin -> Maybe SIMPLE_ID
b984ff0ba75221f64451c1e69b3977967d4e99a1Christian MaederdgLinkOriginSpec o = case o of
b984ff0ba75221f64451c1e69b3977967d4e99a1Christian Maeder DGLinkMorph n -> Just n
b984ff0ba75221f64451c1e69b3977967d4e99a1Christian Maeder DGLinkInst n _ -> Just n
b984ff0ba75221f64451c1e69b3977967d4e99a1Christian Maeder DGLinkInstArg n -> Just n
6cca02cb6a5ae882d887a879f8b7a71941c3715cChristian Maeder DGLinkView n _ -> Just n
b984ff0ba75221f64451c1e69b3977967d4e99a1Christian Maeder DGLinkFitView n -> Just n
b984ff0ba75221f64451c1e69b3977967d4e99a1Christian Maeder DGLinkFitViewImp n -> Just n
b984ff0ba75221f64451c1e69b3977967d4e99a1Christian MaederdgLinkMapping :: DGLinkOrigin -> [G_mapping]
962d5c684e2b86d1f9c556c096b426e10cc74026Christian MaederdgLinkMapping o = case o of
962d5c684e2b86d1f9c556c096b426e10cc74026Christian Maeder DGLinkInst _ (Fitted l) -> l
6cca02cb6a5ae882d887a879f8b7a71941c3715cChristian Maeder DGLinkView _ (Fitted l) -> l
962d5c684e2b86d1f9c556c096b426e10cc74026Christian MaederdgLinkOriginHeader :: DGLinkOrigin -> String
962d5c684e2b86d1f9c556c096b426e10cc74026Christian MaederdgLinkOriginHeader o = case o of
962d5c684e2b86d1f9c556c096b426e10cc74026Christian Maeder SeeTarget -> "see target"
6cca02cb6a5ae882d887a879f8b7a71941c3715cChristian Maeder TEST -> "test"
6cca02cb6a5ae882d887a879f8b7a71941c3715cChristian Maeder SeeSource -> "see source"
b984ff0ba75221f64451c1e69b3977967d4e99a1Christian Maeder DGImpliesLink -> "reversed implies link of extension"
ee9eddfa6953868fd6fbaff0d9ff68675a13675aChristian Maeder DGLinkExtension -> "extension"
ee9eddfa6953868fd6fbaff0d9ff68675a13675aChristian Maeder DGLinkTranslation -> "OMDoc translation"
6cca02cb6a5ae882d887a879f8b7a71941c3715cChristian Maeder DGLinkClosedLenv -> "closed spec and local environment"
6cca02cb6a5ae882d887a879f8b7a71941c3715cChristian Maeder DGLinkImports -> "OWL import"
6cca02cb6a5ae882d887a879f8b7a71941c3715cChristian Maeder DGLinkMorph _ -> "instantiation morphism of"
6cca02cb6a5ae882d887a879f8b7a71941c3715cChristian Maeder DGLinkInst _ _ -> "instantiation of"
6cca02cb6a5ae882d887a879f8b7a71941c3715cChristian Maeder DGLinkInstArg _ -> "actual parameter of"
6cca02cb6a5ae882d887a879f8b7a71941c3715cChristian Maeder DGLinkView _ _ -> "view"
6cca02cb6a5ae882d887a879f8b7a71941c3715cChristian Maeder DGLinkFitView _ -> "fit source of"
6cca02cb6a5ae882d887a879f8b7a71941c3715cChristian Maeder DGLinkFitViewImp _ -> "add import to source of"
6cca02cb6a5ae882d887a879f8b7a71941c3715cChristian Maeder DGLinkProof -> "proof-link"
6cca02cb6a5ae882d887a879f8b7a71941c3715cChristian Maeder DGLinkFlatteningUnion -> "flattening non-disjoint union"
ee9eddfa6953868fd6fbaff0d9ff68675a13675aChristian Maeder DGLinkFlatteningRename -> "flattening renaming"
4fb19f237193a3bd6778f8aee3b6dd8da5856665Christian Maederinstance Pretty DGLinkOrigin where
4fb19f237193a3bd6778f8aee3b6dd8da5856665Christian Maeder pretty o = text (dgLinkOriginHeader o) <+> pretty (dgLinkOriginSpec o)
c797f343be2f3619bb1f5569753166ec49d27bdbChristian Maeder $+$ ppWithCommas (dgLinkMapping o)
15bb922b665fcd44c6230a1202785d0c7890e90cChristian Maeder-- | only shows the edge and node ids
15bb922b665fcd44c6230a1202785d0c7890e90cChristian MaedershowLEdge :: LEdge DGLinkLab -> String
b645cf3dc1e449038ed291bbd11fcc6e02b2fc7fChristian MaedershowLEdge (s, t, l) = "edge " ++ showEdgeId (dgl_id l)
SeeTarget -> Doc.empty
[ text (dgRuleHeader r) <> if null es then Doc.empty else colon, case r of
[] -> Doc.empty
[(_, _, l)] -> prettyDGLinkLab (const Doc.empty) l
_ -> pretty $ Set.fromList $ map (\ (_, _, l) -> dgl_id l) es]
LeftOpen -> Doc.empty
prettyThmLinkStatus = maybe Doc.empty pretty . thmLinkStatus
None -> Doc.empty
_ -> Doc.empty)
, if dglPending l then text "proof chain incomplete" else Doc.empty
_ -> Doc.empty ]
prettyGr :: Tree.Gr DGNodeLab DGLinkLab -> Doc
EmptyNode _ -> Doc.empty
EmptyNode _ -> Doc.empty
(if null params then Doc.empty else pretty $ map getNode params)
, prettyHistory $ SizedList.reverse $ reverseHistory $ redoHistory dg
prettyHistory = vcat . map prettyHistElem . SizedList.toList