-
Notifications
You must be signed in to change notification settings - Fork 0
/
attGr.hs
2678 lines (2580 loc) · 102 KB
/
attGr.hs
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
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
-- UUAGC 0.9.42.3 (attGr.ag)
{-# LINE 4 "./attGr.ag" #-}
import Data.List
import Text.Parsec.Prim
import N3grammar
import System.Directory
import Data.Text (pack, count)
{-# LINE 17 "attGr.hs" #-}
{-# LINE 434 "./attGr.ag" #-}
parseToCoreTree :: String -> IO ()
parseToCoreTree filename = do {
input <- readFile filename
; case runParser mainparser 0 filename input of
{
Left err -> print err
; Right ans -> putStrLn $ show ( transformed_Syn_S ( wrap_S (sem_S (read (show ans))) Inh_S ) )
}
}
eyeToCore :: String -> IO ()
eyeToCore fname = do {
input <- readFile fname
; case runParser mainparser 0 fname input of
{ Left err -> print err
; Right ans -> putStrLn $ show ( eye_Syn_S ( wrap_S (sem_S (read (show ans))) Inh_S ) )
}}
parseToCoreFormula :: String -> IO ()
parseToCoreFormula fname = do {
input <- readFile fname
; case runParser mainparser 0 fname input of
{ Left err -> print err
; Right ans -> print ( formula_Syn_S ( wrap_S (sem_S (read (show ans))) Inh_S ) )
}
}
testp :: String -> IO ()
testp fname = do {
input <- readFile fname
; case runParser mainparser 0 fname input of
{ Left err -> print err
; Right ans -> putStrLn $ show ( eyeVar_Syn_S ( wrap_S (sem_S (read (show ans))) Inh_S ) )
}
}
-- function for quantifiers: takes Universals and existentials as lists and the formula without quantifier and produces a quantified formula
qua :: [String] -> [String] -> CFormula -> CFormula
--qua u e f = foldr fa f u
--fa :: String -> CFormula
--fa u f = Quant (Forall (Var u)) f
qua [] [] f = f
qua [] (a:as) f = Quant (Forsome (Var a)) (qua [] as f)
qua (a:as) g f = Quant (Forall (Var a)) (qua as g f)
--the qua function to generate a formula (just to see the translation as text)
quaf :: [String] -> [String] -> String -> String
quaf [] [] s = s
quaf [] (a:as) s = "ForSome " ++ a ++ ". " ++ (quaf [] as s)
quaf (a:as) g s = "ForAll " ++ a ++ ". " ++ (quaf as g s)
findDepth :: [String] -> Int -> Int -> Int
findDepth [] n m = m
findDepth set n m = max n m
deepest :: [String] -> [String] ->[String]
deepest new [] = new
deepest new old = old
choose :: [String] -> [String] -> Int -> Int ->[String]
choose first second n m = if (n>m) then first
else second
imp :: Bool -> [String] -> [String]
imp False l = l
imp f l = []
--not really pretty, but at least easy
printTree :: String -> Int -> String
printTree ('(':b) n = "\n"++ ( concat (replicate (n+1) "| ") ) ++ ( printTree b (n+1) )
printTree (')':b) n = ( printTree b (n-1) )
printTree (s:b) n = (s : ( printTree b n))
printTree s n = s
makeTree :: String -> String -> IO()
makeTree fname "uni" = do {
input <- readFile fname
; case runParser mainparser 0 fname input of
{ Left err -> print err
; Right ans -> putStrLn $ printTree (show ( eye_Syn_S ( wrap_S (sem_S (read (show ans))) Inh_S ) )) 0
}}
makeTree fname "cwm" = do {
input <- readFile fname
; case runParser mainparser 0 fname input of
{ Left err -> print err
; Right ans -> putStrLn $ printTree (show ( transformed_Syn_S ( wrap_S (sem_S (read (show ans))) Inh_S ) )) 0
}
}
makeTree fname "eye" = do {
input <- readFile fname
; case runParser mainparser 0 fname input of
{ Left err -> print err
; Right ans -> putStrLn $ printTree (show ( diff_Syn_S ( wrap_S (sem_S (read (show ans))) Inh_S ) )) 0
}
}
--simple function to compare tree strings, later that comparison should be on tree level
compareTree :: String -> String -> String -> Int -> String
compareTree (x:b) (y:c) s n
| (x==y) = compareTree b c (s++[x]) (n+1)
| otherwise = "Difference at pos. "++ show(n) ++ "\n" ++ s ++
"\n CWM: " ++ (take 100 (x:b)) ++ "... \n and \n Other: " ++ (take 100 (y:c))++ "..."
compareTree [][] s n = "no differences found"
compareB :: String -> IO()
compareB fname = do {
input <- readFile fname
; case runParser mainparser 0 fname input of
{
Left err -> print err
; Right ans -> putStrLn $ compareTree (show ( transformed_Syn_S ( wrap_S (sem_S (read (show ans))) Inh_S ) ))
(show ( eye_Syn_S ( wrap_S (sem_S (read (show ans))) Inh_S ) ))
[]
0
}
}
topUni :: String -> IO()
topUni fname = do {
input <- readFile fname
; case runParser mainparser 0 fname input of
{
Left err -> print err
; Right ans -> putStrLn $ show ( n1_Syn_S ( wrap_S (sem_S (read (show ans))) Inh_S ) )
}
}
compareU :: String -> IO()
compareU fname = do {
input <- readFile fname
; case runParser mainparser 0 fname input of
{
Left err -> print err
; Right ans -> putStrLn $ compareTree (show ( transformed_Syn_S ( wrap_S (sem_S (read (show ans))) Inh_S ) ))
(show ( diff_Syn_S ( wrap_S (sem_S (read (show ans))) Inh_S ) ))
[]
0
}
}
depth :: String -> IO()
depth fname = do {
input <- readFile fname
; case runParser mainparser 0 fname input of
{
Left err -> print err
; Right ans -> putStrLn $ show ( count_Syn_S ( wrap_S (sem_S (read (show ans))) Inh_S ) )
}
}
deepvars :: String -> IO()
deepvars fname = do {
input <- readFile fname
; case runParser mainparser 0 fname input of
{
Left err -> print err
; Right ans -> putStrLn $ show ( deep_Syn_S ( wrap_S (sem_S (read (show ans))) Inh_S ) )
}
}
--not used any more
--hasBuiltins :: String -> Int
hasBuiltins foname [] result = do { return (reverse result) }
hasBuiltins foname fs result =
do {
let fname = (head fs)
; input <- readFile $ foname ++ "/"++ fname
; case ( (count (pack ("e:")) (pack input) ) > 1)
|| ( (count (pack ("prolog:")) (pack input) ) > 1)
|| ( (count (pack ("fn:")) (pack input) ) > 1)
|| ( (count (pack ("crypto:")) (pack input) ) > 1)
|| ( (count (pack ("list:")) (pack input) ) > 1)
|| ( (count (pack ("log:")) (pack input) ) > 1)
|| ( (count (pack ("math:")) (pack input) ) > 1)
|| (isInfixOf " rdf:first" input)
|| (isInfixOf " rdf:rest" input)
|| ( (count (pack ("string:")) (pack input) ) > 1)
|| ( (count (pack ("time:")) (pack input) ) > 1)
|| ( (count (pack ("func:")) (pack input) ) > 1)
|| ( (count (pack ("pred:")) (pack input) ) > 1)
of
{
True -> (hasBuiltins foname (tail fs) (1:result))
; False -> (hasBuiltins foname (tail fs) (0:result))
}
}
compareAll :: String -> String -> IO ()
compareAll foname target = do {
files <- getDirectoryContents foname
; let fs = (filter (isSuffixOf ".n3") files)
-- ; let fname = head fs
-- ; input <- readFile (foname ++"/"++fname)
-- ; case runParser mainparser 0 fname input of
-- { Left err -> writeFile "err.txt" (show err)
-- ; Right ans -> writeFile "out.txt" $ niceTable (read (show ans)) fname
-- }
--this here is to only consider the files containing the symbol ?, only those can contain universals
; newfs <- findFilesWithUniversals foname fs []
--; builtins <- hasBuiltins foname newfs []
; (values, count) <- (readAll foname newfs [] [0, 0, 0, 0, 0,0,0,0, 0, 0])
; let table = makeTable newfs values count
; writeFile target $ ((replicate 40 ' ') ++ "cwm/es2 " ++ "cwm/eye " ++ "eye/es2 " ++ "builtin " ++ "proof "++ "nested "++ "depth " ++ "reason \n" )++ table
}
--readAll :: String -> [String] -> -> IO()
readAll foname [] list [a, b, c, d, e, r1, r2, r3, ne, pc ] = do {
return $ ((reverse list), [a,b,c,d, e, r1 , r2, r3, ne, pc])
}
readAll foname fs list [a, b, c, d, e, r1, r2, r3, ne, pc] = do {
let fname = (head fs)
; input <- readFile $ foname ++ "/"++ fname
; print (foname ++ "/"++ fname ++ " parsed \n" )
;case runParser mainparser 0 fname input of
{
Left err -> (readAll foname (tail fs) ( [9,9,9,9,9,9,9,9, 9 ]:list ) [a, b, c, d, e, r1, r2, r3, ne, pc] )
;Right ans -> case (( eyeVar_Syn_S ( wrap_S (sem_S (read (show ans))) Inh_S ) )== []) of
{
True -> (readAll foname (tail fs) ( [9,9,9,9,9,9,9,9, 9]:list ) [a, b, c, d, e, r1, r2, r3, ne, pc] )
; False ->
(\res -> ((\x y z zz zzzz proof zzz ff r -> (readAll foname (tail fs) (
[x,
y,
z,
zz,
zzzz,
proof,
ff,
zzz ,
r
]:list )
[(a+x), (b+y), (c+z), (d+1), (e+zzzz), (countR1 r1 r), (countR2 r2 r), ( countR3 r3 r), (countBI ne ff), pc + proof ]
) )
(cwm_and_eye res )
(cwm_and_diff res)
(eye_and_diff res)
(boolToInt ( (eyeVar_Syn_S ( wrap_S (sem_S res) Inh_S ))==[]))
(be_Syn_S ( wrap_S (sem_S (read (show ans))) Inh_S ))
(proof_Syn_S ( wrap_S (sem_S (read (show ans))) Inh_S ))
( count_Syn_S ( wrap_S (sem_S (read (show ans))) Inh_S ) )
( cb_Syn_S ( wrap_S (sem_S (read (show ans))) Inh_S ) )
)
--r
(reason (cwm_and_diff res) ( proof_Syn_S ( wrap_S (sem_S (read (show ans))) Inh_S ) ) ( count_Syn_S ( wrap_S (sem_S (read (show ans))) Inh_S ) ) ( bwfe_Syn_S ( wrap_S (sem_S (read (show ans))) Inh_S ) ) )
)
(read (show ans))
}
}
}
findFilesWithUniversals foname [] newfs = do { return (reverse newfs) }
findFilesWithUniversals foname fs newfs = do {
let fname = (head fs)
; input <- readFile $ foname ++ "/"++ fname
; case (isInfixOf "?" input) of
{
True -> ( findFilesWithUniversals foname (tail fs) (fname:newfs))
;False -> ( findFilesWithUniversals foname (tail fs) newfs)
}
}
--todo: every parsing only once
cwm_and_eye :: S -> Int
cwm_and_eye f = boolToInt ( ( eye_Syn_S x ) == ( transformed_Syn_S x ) )
where x = ( wrap_S (sem_S f) Inh_S )
cwm_and_diff :: S -> Int
cwm_and_diff f = boolToInt (( diff_Syn_S x ) == ( transformed_Syn_S x ) )
where x = ( wrap_S (sem_S f) Inh_S )
eye_and_diff :: S -> Int
eye_and_diff f = boolToInt (( diff_Syn_S x ) == ( eye_Syn_S x ) )
where x = ( wrap_S (sem_S f) Inh_S )
niceTable :: S -> String -> String
niceTable f fname = (replicate 30 ' ') ++ "cwm/eye " ++ "cwm/uni " ++ "uni/eye \n"
++ fname ++ (replicate (30 - length(fname)) ' ') ++ (show ( cwm_and_eye f ))++ (replicate 8 ' ') ++ (show ( cwm_and_diff f )) ++ (replicate 8 ' ') ++ (show ( eye_and_diff f ))
makeTable :: [String] -> [[Int]] -> [Int] -> String
makeTable [] values stat = lastLine stat
makeTable names ([a , b, c , 1, e1, e, f, r, p]:v) [s1, s2, s3, s4, s5, s6 , s7] = (makeTable (tail names) v [(s1-a), (s2-b), (s3-c), (s4-1),(s5-e1)])
makeTable names ([a , b, c , d, e1, e, f, r, p]:v) stat = (head names) ++ (replicate (40 - length(head names)) ' ') ++ (concat $ fmap makeEntry [a, b, c, e1, e, f , r, p]) ++ "\n"
++ (makeTable (tail names) v stat)
lastLine :: [Int]-> String
lastLine [a,b,c, d, e, r1, r2, r3, bi, pc] = "--------------------------------------------------------------------------------------------------------------" ++ "\n"
++ "Absolute Number (from "
++ (show d) ++ "): "
++ (replicate(15 - (length(show d))) ' ')
++ (show a) ++ (replicate (9 - (length(show a))) ' ')
++ (show b) ++ (replicate (9 - (length(show b))) ' ')
++ (show c) ++ (replicate (9 - (length(show c))) ' ')
++ (show e) ++ (replicate (9 - (length(show e))) ' ')
++ (show pc) ++ (replicate (9 - (length(show pc))) ' ')
++ (show bi) ++ (replicate (9 - (length(show bi))) ' ')
++ "\n"
++ "Percentage: "
++ (show ((fromIntegral a)/(fromIntegral d)))
++" "
++ (show $ (fromIntegral b)/(fromIntegral d))
++ " "
++ (show $ (fromIntegral c)/(fromIntegral d))
++ " "
++ (show $ (fromIntegral e)/(fromIntegral d))
++ " "
++ (show $ (fromIntegral pc)/(fromIntegral d))
++ " "
++ (show $ (fromIntegral bi)/(fromIntegral d))
++ "\n" ++ "\n"
++ "Distribution of Errors in EYE vs. CWM" ++ "\n"
++ "Nesting: " ++ (show r1) ++ " (absolut) "
++ (show $ (fromIntegral r1)/(fromIntegral d)) ++ " (from all files) " ++ (show $ (fromIntegral r1)/(fromIntegral (d - b) )) ++ " (from differences) " ++ "\n"
++ "Proof: " ++ (show r2) ++ " (absolut) "
++ (show $ (fromIntegral r2)/(fromIntegral d)) ++ " (from all files) " ++ (show $ (fromIntegral r2)/(fromIntegral (d - b) )) ++ " (from differences) " ++ "\n"
++ "Builtins: " ++ (show r3) ++ " (absolut) "
++ (show $ (fromIntegral r3)/(fromIntegral d)) ++ " (from all files) " ++ (show $ (fromIntegral r3)/(fromIntegral (d - b) )) ++ " (from differences) " ++ "\n"
makeEntry :: Int -> String
makeEntry n = (show n) ++ (replicate 8 ' ')
--data TreeElem = CFormula | CTerm
-- function to compare trees
--compareTrees :: TreeElem -> TreeElem -> [(TreeElem, TreeElem)]
--compareTrees (CFormula rest)(CFormula rest2) = compareTrees rest rest2
--compareTrees (CTriple t1 t2 t3)(CTriple t11 t22 t33) = (compareTrees t1 t11)++(compareTrees t2 t22)++(compareTrees t3 t33)
--compareTrees a b = [(a,b)]
--compareTrees (Var x) (Var y)
-- | (x == y) = []
-- | otherwise = [(x,y)]
boolToInt :: Bool -> Int
boolToInt False = 0
boolToInt True = 1
keepEx :: Bool -> [String] -> [String]
keepEx True l = l
keepEx False l = []
impExc :: CTerm -> Bool -> Bool
impExc (Con "uri_http://www.w3.org/2000/10/swap/log#implies") b = True
impExc t b = b
exception :: Bool -> Bool -> [String] -> [String]
exception True False s = []
exception t f s = s
boolToString :: Bool -> String
boolToString True = "TRUE"
boolToString False = "FALSE"
isProof :: String -> Int
isProof string
|string == "r:Proof" = 1
| otherwise = 0
isBuiltIn :: String -> Int
isBuiltIn string
| elem string builtinlist = 1
| isPrefixOf "prolog:" string = 1
| otherwise = 0
builtinlist = [ "e:avg",
"e:becomes",
"e:biconditional",
"e:binaryEntropy",
"e:calculate",
"e:call",
"e:cartesianProduct",
"e:compoundTerm",
"e:cov",
"e:csvTuple",
"e:derive",
"e:fail",
"e:finalize",
"e:findall",
"e:firstRest",
"e:format",
"e:graphCopy",
"e:graphDifference",
"e:graphIntersection",
"e:graphList",
"e:graphMember",
"e:graphPair",
"e:hmac-sha",
"e:ignore",
"e:label",
"e:labelvars",
"e:length",
"e:match",
"e:max",
"e:min",
"e:multisetEqualTo",
"e:multisetNotEqualTo",
"e:notLabel",
"e:numeral",
"e:optional",
"e:pcc",
"e:prefix",
"e:propertyChainExtension",
"e:random",
"e:relabel",
"e:rms",
"e:roc",
"e:roots",
"e:sha",
"e:sigmoid",
"e:skolem",
"e:sort",
"e:std",
"e:stringEscape",
"e:stringReverse",
"e:stringSplit",
"e:subsequence",
"e:trace",
"e:transaction",
"e:transpose",
"e:tripleList",
"e:tuple",
"e:unique",
"e:whenGround",
"e:wwwFormEncode",
"crypto:sha",
"list:append",
"list:first",
"list:in",
"list:last",
"list:member",
"list:rest",
"log:conclusion",
"log:conjunction",
"log:dtlit",
"log:equalTo",
"log:implies",
"log:includes",
"log:notEqualTo",
"log:notIncludes",
"log:outputString",
"log:rawType",
"log:semantics",
"log:uri",
"math:absoluteValue",
"math:atan2",
"math:cos",
"math:cosh",
"math:degrees",
"math:difference",
"math:equalTo",
"math:exponentiation",
"math:greaterThan",
"math:integerQuotient",
"math:lessThan",
"math:memberCount",
"math:negation",
"math:notEqualTo",
"math:notGreaterThan",
"math:notLessThan",
"math:product",
"math:quotient",
"math:remainder",
"math:rounded",
"math:sin",
"math:sinh",
"math:sum",
"math:tan",
"math:tanh",
"rdf:first",
"rdf:rest",
"string:concatenation",
"string:contains",
"string:containsIgnoringCase",
"string:endsWith",
"string:equalIgnoringCase",
"string:greaterThan",
"string:lessThan",
"string:matches",
"string:notEqualIgnoringCase",
"string:notGreaterThan",
"string:notLessThan",
"string:notMatches",
"string:replace",
"string:scrape",
"string:search",
"string:startsWith",
"time:day",
"time:month",
"time:year",
"pred:literal-not-identical",
"pred:iri-string",
"pred:numeric-equal",
"pred:numeric-less-than",
"pred:numeric-greater-than",
"pred:numeric-not-equal",
"pred:numeric-less-than-or-equal",
"pred:numeric-greater-than-or-equal",
"func:not",
"pred:boolean-equal",
"pred:boolean-less-than",
"pred:boolean-greater-than",
"func:compare",
"func:concat",
"func:string-join",
"func:substring",
"func:string-length",
"func:upper-case",
"func:lower-case",
"func:encode-for-uri",
"func:substring-before",
"func:substring-after",
"pred:contains",
"pred:starts-with",
"pred:ends-with",
"pred:matches",
"func:year-from-dateTime",
"func:month-from-dateTime",
"func:day-from-dateTime",
"func:hours-from-dateTime",
"func:minutes-from-dateTime",
"func:seconds-from-dateTime",
"func:year-from-date",
"func:month-from-date",
"func:day-from-date",
"func:hours-from-time",
"func:minutes-from-time",
"func:seconds-from-time",
"func:years-from-duration",
"func:months-from-duration",
"func:days-from-duration",
"func:hours-from-duration",
"func:minutes-from-duration",
"func:seconds-from-duration",
"func:timezone-from-dateTime",
"func:timezone-from-date",
"func:timezone-from-time",
"func:subtract-dateTimes",
"func:subtract-dates",
"func:subtract-times",
"func:add-yearMonthDurations",
"func:subtract-yearMonthDurations",
"func:multiply-yearMonthDuration",
"func:divide-yearMonthDuration",
"func:divide-yearMonthDuration-by-yearMonthDuration",
"func:add-dayTimeDurations",
"func:subtract-dayTimeDurations",
"func:multiply-dayTimeDuration",
"func:divide-dayTimeDuration",
"func:divide-dayTimeDuration-by-dayTimeDuration",
"func:add-yearMonthDuration-to-dateTime",
"func:add-yearMonthDuration-to-date",
"func:add-dayTimeDuration-to-dateTime",
"func:add-dayTimeDuration-to-date",
"func:add-dayTimeDuration-to-time",
"func:subtract-yearMonthDuration-from-dateTime",
"func:subtract-yearMonthDuration-from-date",
"func:subtract-dayTimeDuration-from-dateTime",
"func:subtract-dayTimeDuration-from-date",
"func:subtract-dayTimeDuration-from-time",
"pred:dateTime-equal",
"pred:dateTime-less-than",
"pred:dateTime-greater-than",
"pred:date-equal",
"pred:date-less-than",
"pred:date-greater-than",
"pred:time-equal",
"pred:time-less-than",
"pred:time-greater-than",
"pred:duration-equal",
"pred:dayTimeDuration-less-than",
"pred:dayTimeDuration-greater-than",
"pred:yearMonthDuration-less-than",
"pred:yearMonthDuration-greater-than",
"pred:dateTime-not-equal",
"pred:dateTime-less-than-or-equal",
"pred:dateTime-greater-than-or-equal",
"pred:date-not-equal",
"pred:date-less-than-or-equal",
"pred:date-greater-than-or-equal",
"pred:time-not-equal",
"pred:time-less-than-or-equal",
"pred:time-greater-than-or-equal",
"pred:duration-not-equal",
"pred:dayTimeDuration-less-than-or-equal",
"pred:dayTimeDuration-greater-than-or-equal",
"pred:yearMonthDuration-less-than-or-equal",
"pred:yearMonthDuration-greater-than-or-equal",
"func:PlainLiteral-from-string-lang",
"func:string-from-PlainLiteral",
"func:lang-from-PlainLiteral",
"func:PlainLiteral-compare",
"func:PlainLiteral-length",
"pred:matches-language-range",
"pred:is-list",
"pred:list-contains",
"func:make-list",
"func:count",
"func:get",
"func:sublist",
"func:append",
"func:concatenate",
"func:insert-before",
"func:remove",
"func:reverse",
"func:index-of",
"func:union",
"func:distinct-values",
"func:intersect",
"func:except"
]
reason :: Int -> Int -> Int -> Int -> Int
-- "no problem" = 0, "nesting" = 1, "proof" = 2, "builtin" = 3
reason 1 n1 n2 n3 = 0
reason 0 n1 n2 n3
| (n3 > 0) = 3
| (n1 == 1) && (n2 > 2) = 1
| (n1 == 1) = 2
| otherwise = 1
b :: Int -> [String] -> Int
b 0 [] = 0
b n set = 1
-- universalsInBuiltins @p.be @lhs.n2 ((@s.biscope `union` @p.biscope) `union` @o.biscope)
universalsInBuiltins :: Int -> [String] -> [String] -> [String]
universalsInBuiltins 0 s1 s2 = s2
universalsInBuiltins 1 s1 s2 = (s1 `union` s2)
countR1 :: Int -> Int -> Int
countR1 r1 1 = r1 + 1
countR1 r1 r = r1
countR2 :: Int -> Int -> Int
countR2 r2 2 = r2 + 1
countR2 r2 r = r2
countR3 :: Int -> Int -> Int
countR3 r3 3 = r3 + 1
countR3 r3 r = r3
--this is to count nesting
countBI :: Int -> Int -> Int
countBI ne 1 = ne
countBI ne ff = ne +1
{-# LINE 707 "attGr.hs" #-}
-- CExpression -------------------------------------------------
data CExpression = CBE (Bool)
| CFE (CFormula)
deriving ( Eq,Show)
-- cata
sem_CExpression :: CExpression ->
T_CExpression
sem_CExpression (CBE _b) =
(sem_CExpression_CBE _b)
sem_CExpression (CFE _f) =
(sem_CExpression_CFE (sem_CFormula _f))
-- semantic domain
type T_CExpression = ( )
data Inh_CExpression = Inh_CExpression {}
data Syn_CExpression = Syn_CExpression {}
wrap_CExpression :: T_CExpression ->
Inh_CExpression ->
Syn_CExpression
wrap_CExpression sem (Inh_CExpression) =
(let ( ) = sem
in (Syn_CExpression))
sem_CExpression_CBE :: Bool ->
T_CExpression
sem_CExpression_CBE b_ =
(let
in ( ))
sem_CExpression_CFE :: T_CFormula ->
T_CExpression
sem_CExpression_CFE f_ =
(let
in ( ))
-- CFormula ----------------------------------------------------
data CFormula = CTriple (CTerm) (CTerm) (CTerm)
| CImplication (CExpression) (CExpression)
| CConjunction (CFormula) (CFormula)
| Quant (Quant) (CFormula)
deriving ( Eq,Show)
-- cata
sem_CFormula :: CFormula ->
T_CFormula
sem_CFormula (CTriple _t1 _t2 _t3) =
(sem_CFormula_CTriple (sem_CTerm _t1) (sem_CTerm _t2) (sem_CTerm _t3))
sem_CFormula (CImplication _e1 _e2) =
(sem_CFormula_CImplication (sem_CExpression _e1) (sem_CExpression _e2))
sem_CFormula (CConjunction _f1 _f2) =
(sem_CFormula_CConjunction (sem_CFormula _f1) (sem_CFormula _f2))
sem_CFormula (Quant _a _f) =
(sem_CFormula_Quant (sem_Quant _a) (sem_CFormula _f))
-- semantic domain
type T_CFormula = ( )
data Inh_CFormula = Inh_CFormula {}
data Syn_CFormula = Syn_CFormula {}
wrap_CFormula :: T_CFormula ->
Inh_CFormula ->
Syn_CFormula
wrap_CFormula sem (Inh_CFormula) =
(let ( ) = sem
in (Syn_CFormula))
sem_CFormula_CTriple :: T_CTerm ->
T_CTerm ->
T_CTerm ->
T_CFormula
sem_CFormula_CTriple t1_ t2_ t3_ =
(let
in ( ))
sem_CFormula_CImplication :: T_CExpression ->
T_CExpression ->
T_CFormula
sem_CFormula_CImplication e1_ e2_ =
(let
in ( ))
sem_CFormula_CConjunction :: T_CFormula ->
T_CFormula ->
T_CFormula
sem_CFormula_CConjunction f1_ f2_ =
(let
in ( ))
sem_CFormula_Quant :: T_Quant ->
T_CFormula ->
T_CFormula
sem_CFormula_Quant a_ f_ =
(let
in ( ))
-- CTerm -------------------------------------------------------
data CTerm = Var (String)
| Con (String)
| CExp (CExpression)
| CList (CTerm) (CTerm)
deriving ( Eq,Show)
-- cata
sem_CTerm :: CTerm ->
T_CTerm
sem_CTerm (Var _t) =
(sem_CTerm_Var _t)
sem_CTerm (Con _c) =
(sem_CTerm_Con _c)
sem_CTerm (CExp _e) =
(sem_CTerm_CExp (sem_CExpression _e))
sem_CTerm (CList _t _list) =
(sem_CTerm_CList (sem_CTerm _t) (sem_CTerm _list))
-- semantic domain
type T_CTerm = ( )
data Inh_CTerm = Inh_CTerm {}
data Syn_CTerm = Syn_CTerm {}
wrap_CTerm :: T_CTerm ->
Inh_CTerm ->
Syn_CTerm
wrap_CTerm sem (Inh_CTerm) =
(let ( ) = sem
in (Syn_CTerm))
sem_CTerm_Var :: String ->
T_CTerm
sem_CTerm_Var t_ =
(let
in ( ))
sem_CTerm_Con :: String ->
T_CTerm
sem_CTerm_Con c_ =
(let
in ( ))
sem_CTerm_CExp :: T_CExpression ->
T_CTerm
sem_CTerm_CExp e_ =
(let
in ( ))
sem_CTerm_CList :: T_CTerm ->
T_CTerm ->
T_CTerm
sem_CTerm_CList t_ list_ =
(let
in ( ))
-- Expression --------------------------------------------------
data Expression = BE (Bool)
| FE (Formula)
deriving ( Eq,Read,Show)
-- cata
sem_Expression :: Expression ->
T_Expression
sem_Expression (BE _b) =
(sem_Expression_BE _b)
sem_Expression (FE _f) =
(sem_Expression_FE (sem_Formula _f))
-- semantic domain
type T_Expression = Int ->
Bool ->
([String]) ->
( Int,([String]),Int,Int,Int,([String]),CExpression,CExpression,([String]),([String]),String,([String]),Int,CExpression)
data Inh_Expression = Inh_Expression {c_Inh_Expression :: Int,insideQuotation_Inh_Expression :: Bool,scope_Inh_Expression :: ([String])}
data Syn_Expression = Syn_Expression {be_Syn_Expression :: Int,biscope_Syn_Expression :: ([String]),bwfe_Syn_Expression :: Int,cb_Syn_Expression :: Int,count_Syn_Expression :: Int,deep_Syn_Expression :: ([String]),diff_Syn_Expression :: CExpression,eye_Syn_Expression :: CExpression,eyeEx_Syn_Expression :: ([String]),eyeVar_Syn_Expression :: ([String]),formula_Syn_Expression :: String,n1_Syn_Expression :: ([String]),proof_Syn_Expression :: Int,transformed_Syn_Expression :: CExpression}
wrap_Expression :: T_Expression ->
Inh_Expression ->
Syn_Expression
wrap_Expression sem (Inh_Expression _lhsIc _lhsIinsideQuotation _lhsIscope) =
(let ( _lhsObe,_lhsObiscope,_lhsObwfe,_lhsOcb,_lhsOcount,_lhsOdeep,_lhsOdiff,_lhsOeye,_lhsOeyeEx,_lhsOeyeVar,_lhsOformula,_lhsOn1,_lhsOproof,_lhsOtransformed) = sem _lhsIc _lhsIinsideQuotation _lhsIscope
in (Syn_Expression _lhsObe _lhsObiscope _lhsObwfe _lhsOcb _lhsOcount _lhsOdeep _lhsOdiff _lhsOeye _lhsOeyeEx _lhsOeyeVar _lhsOformula _lhsOn1 _lhsOproof _lhsOtransformed))
sem_Expression_BE :: Bool ->
T_Expression
sem_Expression_BE b_ =
(\ _lhsIc
_lhsIinsideQuotation
_lhsIscope ->
(let _lhsOn1 :: ([String])
_lhsOtransformed :: CExpression
_lhsOformula :: String
_lhsOeyeVar :: ([String])
_lhsOeye :: CExpression
_lhsOeyeEx :: ([String])
_lhsOdiff :: CExpression
_lhsOcount :: Int
_lhsOdeep :: ([String])
_lhsObe :: Int
_lhsOcb :: Int
_lhsOproof :: Int
_lhsObwfe :: Int
_lhsObiscope :: ([String])
_lhsOn1 =
({-# LINE 399 "./attGr.ag" #-}
[]
{-# LINE 886 "attGr.hs" #-}
)
_lhsOtransformed =
({-# LINE 400 "./attGr.ag" #-}
CBE b_
{-# LINE 891 "attGr.hs" #-}
)
_lhsOformula =
({-# LINE 401 "./attGr.ag" #-}
if b_ == True then "<>" else "false"
{-# LINE 896 "attGr.hs" #-}
)
_lhsOeyeVar =
({-# LINE 402 "./attGr.ag" #-}
[]
{-# LINE 901 "attGr.hs" #-}
)
_lhsOeye =
({-# LINE 403 "./attGr.ag" #-}
CBE b_
{-# LINE 906 "attGr.hs" #-}
)
_lhsOeyeEx =
({-# LINE 404 "./attGr.ag" #-}
[]
{-# LINE 911 "attGr.hs" #-}
)
_lhsOdiff =
({-# LINE 405 "./attGr.ag" #-}
CBE b_
{-# LINE 916 "attGr.hs" #-}
)
_lhsOcount =
({-# LINE 406 "./attGr.ag" #-}
0
{-# LINE 921 "attGr.hs" #-}
)
_lhsOdeep =
({-# LINE 407 "./attGr.ag" #-}
[]
{-# LINE 926 "attGr.hs" #-}
)
_lhsObe =
({-# LINE 408 "./attGr.ag" #-}
0
{-# LINE 931 "attGr.hs" #-}
)
_lhsOcb =
({-# LINE 409 "./attGr.ag" #-}
0
{-# LINE 936 "attGr.hs" #-}
)
_lhsOproof =
({-# LINE 410 "./attGr.ag" #-}
0
{-# LINE 941 "attGr.hs" #-}
)
_lhsObwfe =
({-# LINE 411 "./attGr.ag" #-}
0
{-# LINE 946 "attGr.hs" #-}
)
_lhsObiscope =
({-# LINE 412 "./attGr.ag" #-}
[]
{-# LINE 951 "attGr.hs" #-}
)
in ( _lhsObe,_lhsObiscope,_lhsObwfe,_lhsOcb,_lhsOcount,_lhsOdeep,_lhsOdiff,_lhsOeye,_lhsOeyeEx,_lhsOeyeVar,_lhsOformula,_lhsOn1,_lhsOproof,_lhsOtransformed)))
sem_Expression_FE :: T_Formula ->
T_Expression
sem_Expression_FE f_ =
(\ _lhsIc
_lhsIinsideQuotation
_lhsIscope ->
(let _lhsOn1 :: ([String])
_fOscope :: ([String])
_lhsOtransformed :: CExpression
_lhsOformula :: String
_fOuni :: ([String])
_lhsOeye :: CExpression
_lhsOeyeEx :: ([String])
_lhsOdiff :: CExpression
_fOinsideQuotation :: Bool
_fOc :: Int
_lhsOcount :: Int
_lhsOdeep :: ([String])
_lhsObe :: Int
_lhsOcb :: Int
_lhsOproof :: Int
_lhsObwfe :: Int
_lhsObiscope :: ([String])
_lhsOeyeVar :: ([String])
_fIbe :: Int
_fIbiscope :: ([String])
_fIbwfe :: Int
_fIcb :: Int
_fIcount :: Int
_fIdeep :: ([String])
_fIdiff :: CFormula
_fIex :: ([String])
_fIeye :: CFormula
_fIeyeEx :: ([String])
_fIeyeVar :: ([String])
_fIformula :: String
_fIn1 :: ([String])
_fIn2 :: ([String])
_fIproof :: Int
_fItransformed :: CFormula
_lhsOn1 =
({-# LINE 414 "./attGr.ag" #-}
_fIn2
{-# LINE 997 "attGr.hs" #-}
)
_fOscope =
({-# LINE 415 "./attGr.ag" #-}
_lhsIscope `union` _fIn1