-
Notifications
You must be signed in to change notification settings - Fork 2
/
meta-aux.maude
4382 lines (3730 loc) · 175 KB
/
meta-aux.maude
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
--- file: meta-aux.maude
--- reqs: prelude, prelude-aux
--- desc: This file extends the meta-level
--- with many additional operations
view Term from TRIV to META-MODULE is sort Elt to Term . endv
view TermList from TRIV to META-MODULE is sort Elt to TermList . endv
fmod QIDSET-REFINEMENT is
pr META-MODULE .
---
var V : Variable .
var VS : VariableSet .
var QS1 QS2 : QidSet .
---
sort VariableSet ConstantSet TermQidSet .
sort NeVariableSet NeConstantSet NeTermQidSet .
---
subsort Variable < NeVariableSet < VariableSet .
subsort Constant < NeConstantSet < ConstantSet .
subsort TermQid < NeTermQidSet < TermQidSet .
---
subsort EmptyTypeSet < ConstantSet VariableSet .
subsort VariableSet ConstantSet < TermQidSet .
subsort NeVariableSet NeConstantSet < NeTermQidSet .
---
subsort TermQidSet < QidSet .
subsort NeTermQidSet < NeQidSet .
---
op _;_ : TermQidSet TermQidSet -> TermQidSet [ctor ditto] .
op _;_ : NeTermQidSet TermQidSet -> NeTermQidSet [ctor ditto] .
op _;_ : ConstantSet ConstantSet -> ConstantSet [ctor ditto] .
op _;_ : NeConstantSet ConstantSet -> NeConstantSet [ctor ditto] .
op _;_ : VariableSet VariableSet -> VariableSet [ctor ditto] .
op _;_ : NeVariableSet VariableSet -> NeVariableSet [ctor ditto] .
op pickAny : QidSet -> [Qid] .
op pickAny : NeQidSet -> Qid .
eq pickAny(Q:Qid ; QS:QidSet) = Q:Qid .
op TermList : TermQid -> TermQid .
op TermList : TermQidSet -> TermList .
eq TermList(TQ:TermQid ; TQS:TermQidSet) = TQ:TermQid,TermList(TQS:TermQidSet) .
eq TermList(none) = empty .
--- FIXME: Input VariableSet must be a proper set (no redundancies)
---- for this to work correctly --- ideally should be checked
op overlappingVarNames : VariableSet -> QidSet .
op overlappingVarNames : VariableSet QidSet QidSet -> QidSet .
-------------------------------------------------------------
eq overlappingVarNames(VS) = overlappingVarNames(VS,none,none) .
eq overlappingVarNames(V ; VS,QS1,QS2) =
if getName(V) in QS2
then overlappingVarNames(VS,QS1 ; getName(V),QS2 )
else overlappingVarNames(VS,QS1, QS2 ; getName(V))
fi .
eq overlappingVarNames(none, QS1,QS2) = QS1 .
endfm
--- ### New
fmod TERM-EXTRA is
pr META-LEVEL .
pr CONVERSION .
pr QIDSET-REFINEMENT .
var TQ : TermQid . var Q : Qid . var QS QS' QS'' : QidSet . var V : Variable .
var T T' : Term . var NTL : NeTermList . var C : Constant . var TS : TypeSet .
var M : Module . var TL : TermList . var X Y : Type . var YL : TypeList .
var N : Nat . var VS : VariableSet . var Str : String .
--- OUT: The set of variables in a term
op vars : TermList -> VariableSet .
eq vars(V) = V .
eq vars(C) = none .
eq vars(Q[NTL]) = vars(NTL) .
eq vars(empty) = none .
eq vars((T, TL)) = vars(T) ; vars(TL) .
--- OUT: true iff the QidSet is a TermQid set and all names are unique
op uniqueNames : QidSet ~> Bool .
op uniqueNames : QidSet QidSet ~> Bool .
eq uniqueNames(QS') = uniqueNames(none,QS') .
eq uniqueNames(QS,Q ; QS') = (not getName(Q) in QS) and-then uniqueNames(QS ; getName(Q),QS') .
eq uniqueNames(QS,none) = true .
--- PRE: Each Qid in QidSet is a TermQid
--- OUT: QidSet composed of the name/sort of each TermQid
op getName : QidSet -> [QidSet] .
eq getName(TQ ; Q ; QS) = getName(TQ) ; getName(Q ; QS) .
eq getName(none) = none .
op getType : QidSet -> [QidSet] .
eq getType(TQ ; Q ; QS) = getType(TQ) ; getType(Q ; QS) .
eq getType(none) = none .
--- PRE: Each Qid in QidSet is a TermQid
--- OUT: Set of names (obtained by getName) which are not unique
op repeatedNames : QidSet -> QidSet .
eq repeatedNames(QS) = $repeatedNames(QS,none,none) .
op $repeatedNames : QidSet QidSet QidSet -> QidSet .
eq $repeatedNames(TQ ; QS,QS',QS'') =
if getName(TQ) in QS'
then $repeatedNames(QS,QS',QS'' ; getName(TQ))
else $repeatedNames(QS,QS' ; getName(TQ),QS'')
fi .
eq $repeatedNames(none,QS',QS'') = QS'' .
--- PRE: Each Qid in QidSet is a TermQid
--- OUT: QidSet composed of only those TermQids who Type is in TypeSet
op filterByType : QidSet TypeSet -> [QidSet] .
eq filterByType(TQ ; QS,TS) =
if getType(TQ) in TS then TQ else none fi ; filterByType(QS,TS) .
eq filterByType(none,TS) = none .
--- PRE: Each Qid in QidSet is a Variable
--- OUT: A TermList where each Variable occurs in an undefined order
op varsToTermList : VariableSet -> [TermList] .
eq varsToTermList(V ; VS) = V,varsToTermList(VS) .
eq varsToTermList(none) = empty .
--- PRE: None
--- OUT: The list of subterms from this term
op subterms : Term -> TermList .
eq subterms(Q[NTL]) = NTL .
eq subterms(C) = empty .
eq subterms(V) = empty .
--- OUT: the head Qid of the term
op head : Term -> Qid .
eq head(Q[NTL]) = Q .
eq head(TQ) = TQ .
--- OUT: self-explanatory
op termSize : TermList -> Nat .
eq termSize(TQ) = 1 .
eq termSize(Q[NTL]) = 1 + termSize(NTL) .
eq termSize((T,TL)) = termSize(T) + termSize(TL) .
eq termSize(empty) = 0 .
--- OUT: true iff TermList has no repeated variables
op linear : TermList -> Bool .
op linear : TermList VariableSet -> Bool .
eq linear(TL) = linear(TL,none) .
eq linear((Q[NTL],TL),VS) = linear((NTL,TL),VS) .
eq linear((C,TL), VS) = linear(TL, VS) .
eq linear((V,TL), VS) = (not V in VS) and-then linear(TL,V ; VS) .
eq linear(empty, VS) = true .
--- PRE: the module is sort-decreasing
--- OUT: true iff one of the terms is provably not equal to other
--- to the other because either: one is a ground constructor
--- and its least sort is greater than the least sort of the
--- other term; guaranteeing the two terms are not equal
--- NB: The two terms MUST have distinct sorts to infer that are
--- not equal; we need sort-decreasingness to tell us that
--- one term is in normal form and the other can only decrease
--- so that it must be different
op groundLeastSortGreater : Module Term Term ~> Bool .
eq groundLeastSortGreater(M,T,T') =
groundLeastSortGreater(M,
T, completeName(M,leastSort(M,T )),
T',completeName(M,leastSort(M,T'))) .
op groundLeastSortGreater : Module Term Type Term Type ~> Bool .
eq groundLeastSortGreater(M,T,X,T',Y) =
X =/= Y and-then
(vars(T) == none and-then sortLeq(M,Y,X) or-else
vars(T') == none and-then sortLeq(M,X,Y)) .
eq groundLeastSortGreater(M,T,X:[Type],T',Y:[Type]) = false [owise] .
--- PRE: Term is well-formed in Module
--- OUT: The reduced term in the module
op metaReduce2 : Module Term ~> Term .
eq metaReduce2(M,T) = getTerm(metaReduce(M,T)) .
--- OUT: Generate term from:
--- [1] OpDecl
--- [2] Fresh Variable Postfix
--- PRE: OpDecl should not be poly
op buildTerm : OpDecl Nat -> Term .
eq buildTerm(op Q : YL -> Y [A:AttrSet].,N) = buildTerm(Q,N,YL,Y) .
--- OUT: Generate term from:
--- [1] Operator Name
--- [2] Fresh Variable Postfix
--- [3] List of Types
op buildTerm : Qid Nat TypeList Type -> Term .
eq buildTerm(Q,N,Y YL,X) = Q[buildTerm'(N,Y YL)] .
eq buildTerm(Q,N,nil ,X) = qid(string(Q) + "." + string(X)) .
op buildTerm' : Nat TypeList -> TermList .
eq buildTerm'(N,Y YL) = qid("@" + string(N,10) + ":" + string(Y)), buildTerm'(s(N),YL) .
eq buildTerm'(N,nil ) = empty .
op buildVar : Qid Type -> Variable .
eq buildVar(Q,X) = qid(string(Q) + ":" + string(X)) .
endfm
fmod TERMLISTPAIR is
pr META-LEVEL .
sort TermListPair .
op ((_,_)) : TermList TermList -> TermListPair [ctor] .
endfm
view TermListPair from TRIV to TERMLISTPAIR is sort Elt to TermListPair . endv
--- copy of code in FULL-MAUDE (fortunately, interpreter does not complain)
fmod TERMSET-FM is
pr META-LEVEL .
pr TERM-EXTRA .
sort TermSet NeTermSet .
subsort Term < NeTermSet < TermSet .
op emptyTermSet : -> TermSet [ctor] .
op _|_ : TermSet TermSet -> TermSet [ctor assoc comm id: emptyTermSet format (d n d d)] .
op _|_ : TermSet NeTermSet -> NeTermSet [ctor ditto] .
var U : Module .
var T : Term . var TS : TermSet . var NTS : NeTermSet . var TL : TermList .
var Y : Type .
var V : Variable .
var TQ : TermQid .
var QS : QidSet .
var O O' : OpDecl .
var OS : OpDeclSet .
var N : Nat .
eq T | T = T .
op |_| : TermSet -> Nat .
op $card : TermSet Nat -> Nat .
-------------------------------
eq | TS | = $card(TS,0) .
eq $card(T | TS, N) = $card(TS,s(N)) .
eq $card(emptyTermSet,N) = N .
op _in_ : Term TermSet -> Bool .
eq T in (T | TS) = true .
eq T in TS = false [owise] .
op TermSet : TermList -> TermSet .
eq TermSet(empty) = emptyTermSet .
eq TermSet((T,TL)) = T | TermSet(TL) .
op setsize : TermSet -> Nat .
eq setsize(T | TS) = s(size(TS)) .
eq setsize(emptyTermSet) = 0 .
--- OUT: return all terms in the termset that are less than
--- the given type
op allInSort : Module TermSet Type -> TermSet .
eq allInSort(U,T | TS,Y) =
if sortLeq(U,leastSort(U,T),Y) then T else emptyTermSet fi |
allInSort(U,TS,Y) .
eq allInSort(U,emptyTermSet,Y) = emptyTermSet .
--- OUT: return the set of TypeSet containing all the types
--- of the terms in this TermSet
op tsleastSort : Module TermSet -> [TypeSet] .
eq tsleastSort(U,emptyTermSet) = none .
eq tsleastSort(U,T | NTS) = leastSort(U,T) ; tsleastSort(U,NTS) .
--- OUT: a substitution built from mapping the variable to each term
op tsBuildSub : Variable TermSet -> Substitution .
eq tsBuildSub(V,T | TS) = V <- T ; tsBuildSub(V,TS) .
eq tsBuildSub(V,emptyTermSet) = none .
--- ### New
op vars : TermSet -> QidSet .
eq vars(T | NTS) = vars(T) ; vars(NTS) .
eq vars(emptyTermSet) = none .
--- ### New
op termQidsToSet : QidSet -> TermSet .
eq termQidsToSet(TQ ; QS) = TQ | termQidsToSet(QS) .
eq termQidsToSet(none) = emptyTermSet .
--- ### New
--- OUT: true if each term in the set is well-formed
op wellFormedSet : Module TermSet ~> Bool .
eq wellFormedSet(U,T | TS) = wellFormed(U,T) and-then wellFormedSet(U,TS) .
eq wellFormedSet(U,emptyTermSet) = true .
op TermList : TermSet -> TermList .
eq TermList(T | TS) = T,TermList(TS) .
eq TermList(emptyTermSet) = empty .
op buildTerm : OpDeclSet Nat -> TermSet .
eq buildTerm(O O' OS,N) = buildTerm(O,N) buildTerm(O' OS,N) .
eq buildTerm(none,N) = emptyTermSet .
endfm
fmod TERMPAIRSET is
pr META-LEVEL .
sort TermPair TermPairSet .
subsort TermPair < TermPairSet .
op ((_:_)) : Term Term -> TermPair [ctor] .
op _|_ : TermPairSet TermPairSet -> TermPairSet [ctor assoc comm id: .TermPairSet] .
op .TermPairSet : -> TermPairSet [ctor] .
endfm
--- copy of code in FULL-MAUDE (fortunately, interpreter does not complain)
fmod UNIT-FM is
inc META-LEVEL .
op noModule : -> Module [ctor] .
op emptyFModule : -> FModule .
eq emptyFModule = fmod 'fmod is nil sorts none . none none none none endfm .
op emptyFTheory : -> FModule .
eq emptyFTheory = fth 'fth is nil sorts none . none none none none endfth .
op emptySModule : -> SModule .
eq emptySModule = mod 'mod is nil sorts none . none none none none none endm .
op emptySTheory : -> SModule .
eq emptySTheory = th 'th is nil sorts none . none none none none none endth .
op getName : Module -> Header .
op getPars : Module -> ParameterDeclList .
op setName : Module ModuleExpression -> Module .
op setName : Module ParameterDecl -> Module .
op setPars : Module ParameterDeclList -> Module .
op setImports : Module ImportList -> Module .
op setSorts : Module SortSet -> Module .
op setSubsorts : Module SubsortDeclSet -> Module .
op setOps : Module OpDeclSet -> Module .
op setMbs : Module MembAxSet -> Module .
op setEqs : Module EquationSet -> Module .
op setRls : Module RuleSet ~> Module .
op addImports : ImportList Module -> Module .
op addSorts : SortSet Module -> Module .
op addSubsorts : [SubsortDeclSet] Module -> Module .
op addOps : [OpDeclSet] Module -> Module .
op addMbs : MembAxSet Module -> Module .
op addEqs : EquationSet Module -> Module .
op addRls : RuleSet Module -> Module .
op addDecls : Module Module -> Module .
vars M M' M'' : Module .
vars SSDS SSDS' SSDS'' : SubsortDeclSet .
vars OPD OPD' : OpDecl .
vars OPDS OPDS' : OpDeclSet .
vars MAS MAS' : MembAxSet .
vars Eq Eq' : Equation .
vars EqS EqS' : EquationSet .
vars Rl Rl' : Rule .
vars RlS RlS' : RuleSet .
vars SS SS' : SortSet .
vars IL IL' : ImportList .
vars PL PL' : ParameterList .
vars U U' : Module .
vars I I' : Import .
vars ME ME' : ModuleExpression .
vars PD PD' : ParameterDecl .
vars PDL PDL' : ParameterDeclList .
var H H' : Header .
eq getName(noModule) = ' .
eq getName(mod ME is IL sorts SS . SSDS OPDS MAS EqS RlS endm) = ME .
eq getName(mod ME{PDL} is IL sorts SS . SSDS OPDS MAS EqS RlS endm) = ME .
eq getName(th H is IL sorts SS . SSDS OPDS MAS EqS RlS endth) = H .
eq getName(fmod ME is IL sorts SS . SSDS OPDS MAS EqS endfm) = ME .
eq getName(fmod ME{PDL} is IL sorts SS . SSDS OPDS MAS EqS endfm) = ME .
eq getName(fth H is IL sorts SS . SSDS OPDS MAS EqS endfth) = H .
eq getImports(noModule) = nil .
eq getImports(mod H is IL sorts SS . SSDS OPDS MAS EqS RlS endm) = IL .
eq getImports(th H is IL sorts SS . SSDS OPDS MAS EqS RlS endth) = IL .
eq getImports(fmod H is IL sorts SS . SSDS OPDS MAS EqS endfm) = IL .
eq getImports(fth H is IL sorts SS . SSDS OPDS MAS EqS endfth) = IL .
eq getPars(noModule) = nil .
eq getPars(mod ME is IL sorts SS . SSDS OPDS MAS EqS RlS endm) = nil .
eq getPars(mod ME{PDL} is IL sorts SS . SSDS OPDS MAS EqS RlS endm) = PDL .
eq getPars(th H is IL sorts SS . SSDS OPDS MAS EqS RlS endth) = nil .
eq getPars(th H is IL sorts SS . SSDS OPDS MAS EqS RlS endth) = nil .
eq getPars(fmod ME is IL sorts SS . SSDS OPDS MAS EqS endfm) = nil .
eq getPars(fmod ME{PDL} is IL sorts SS . SSDS OPDS MAS EqS endfm) = PDL .
eq getPars(fth H is IL sorts SS . SSDS OPDS MAS EqS endfth) = nil .
eq getSorts(noModule) = none .
eq getSorts(mod H is IL sorts SS . SSDS OPDS MAS EqS RlS endm) = SS .
eq getSorts(th H is IL sorts SS . SSDS OPDS MAS EqS RlS endth) = SS .
eq getSorts(fmod H is IL sorts SS . SSDS OPDS MAS EqS endfm) = SS .
eq getSorts(fth H is IL sorts SS . SSDS OPDS MAS EqS endfth) = SS .
eq getSubsorts(noModule) = none .
eq getSubsorts(mod H is IL sorts SS . SSDS OPDS MAS EqS RlS endm) = SSDS .
eq getSubsorts(th H is IL sorts SS . SSDS OPDS MAS EqS RlS endth) = SSDS .
eq getSubsorts(fmod H is IL sorts SS . SSDS OPDS MAS EqS endfm) = SSDS .
eq getSubsorts(fth H is IL sorts SS . SSDS OPDS MAS EqS endfth) = SSDS .
eq getOps(noModule) = none .
eq getOps(mod H is IL sorts SS . SSDS OPDS MAS EqS RlS endm) = OPDS .
eq getOps(th H is IL sorts SS . SSDS OPDS MAS EqS RlS endth) = OPDS .
eq getOps(fmod H is IL sorts SS . SSDS OPDS MAS EqS endfm) = OPDS .
eq getOps(fth H is IL sorts SS . SSDS OPDS MAS EqS endfth) = OPDS .
eq getMbs(noModule) = none .
eq getMbs(mod H is IL sorts SS . SSDS OPDS MAS EqS RlS endm) = MAS .
eq getMbs(th H is IL sorts SS . SSDS OPDS MAS EqS RlS endth) = MAS .
eq getMbs(fmod H is IL sorts SS . SSDS OPDS MAS EqS endfm) = MAS .
eq getMbs(fth H is IL sorts SS . SSDS OPDS MAS EqS endfth) = MAS .
eq getEqs(noModule) = none .
eq getEqs(mod H is IL sorts SS . SSDS OPDS MAS EqS RlS endm) = EqS .
eq getEqs(th H is IL sorts SS . SSDS OPDS MAS EqS RlS endth) = EqS .
eq getEqs(fmod H is IL sorts SS . SSDS OPDS MAS EqS endfm) = EqS .
eq getEqs(fth H is IL sorts SS . SSDS OPDS MAS EqS endfth) = EqS .
eq getRls(noModule) = none .
eq getRls(mod H is IL sorts SS . SSDS OPDS MAS EqS RlS endm) = RlS .
eq getRls(th H is IL sorts SS . SSDS OPDS MAS EqS RlS endth) = RlS .
eq getRls(fmod H is IL sorts SS . SSDS OPDS MAS EqS endfm) = none .
eq getRls(fth H is IL sorts SS . SSDS OPDS MAS EqS endfth) = none .
eq setImports(noModule, IL) = noModule .
eq setImports(mod H is IL sorts SS . SSDS OPDS MAS EqS RlS endm, IL')
= mod H is IL' sorts SS . SSDS OPDS MAS EqS RlS endm .
eq setImports(th H is IL sorts SS . SSDS OPDS MAS EqS RlS endth, IL')
= th H is IL' sorts SS . SSDS OPDS MAS EqS RlS endth .
eq setImports(fmod H is IL sorts SS . SSDS OPDS MAS EqS endfm, IL')
= fmod H is IL' sorts SS . SSDS OPDS MAS EqS endfm .
eq setImports(fth H is IL sorts SS . SSDS OPDS MAS EqS endfth, IL')
= fth H is IL' sorts SS . SSDS OPDS MAS EqS endfth .
eq setOps(noModule, OPDS) = noModule .
eq setOps(mod H is IL sorts SS . SSDS OPDS MAS EqS RlS endm, OPDS')
= mod H is IL sorts SS . SSDS OPDS' MAS EqS RlS endm .
eq setOps(th H is IL sorts SS . SSDS OPDS MAS EqS RlS endth, OPDS')
= th H is IL sorts SS . SSDS OPDS' MAS EqS RlS endth .
eq setOps(fmod H is IL sorts SS . SSDS OPDS MAS EqS endfm, OPDS')
= fmod H is IL sorts SS . SSDS OPDS' MAS EqS endfm .
eq setOps(fth H is IL sorts SS . SSDS OPDS MAS EqS endfth, OPDS')
= fth H is IL sorts SS . SSDS OPDS' MAS EqS endfth .
eq setSubsorts(noModule, SSDS) = noModule .
eq setSubsorts(mod H is IL sorts SS . SSDS OPDS MAS EqS RlS endm, SSDS')
= mod H is IL sorts SS . SSDS' OPDS MAS EqS RlS endm .
eq setSubsorts(th H is IL sorts SS . SSDS OPDS MAS EqS RlS endth, SSDS')
= th H is IL sorts SS . SSDS' OPDS MAS EqS RlS endth .
eq setSubsorts(fmod H is IL sorts SS . SSDS OPDS MAS EqS endfm, SSDS')
= fmod H is IL sorts SS . SSDS' OPDS MAS EqS endfm .
eq setSubsorts(fth H is IL sorts SS . SSDS OPDS MAS EqS endfth, SSDS')
= fth H is IL sorts SS . SSDS' OPDS MAS EqS endfth .
eq setMbs(noModule, MAS) = noModule .
eq setMbs(mod H is IL sorts SS . SSDS OPDS MAS EqS RlS endm, MAS')
= mod H is IL sorts SS . SSDS OPDS MAS' EqS RlS endm .
eq setMbs(th H is IL sorts SS . SSDS OPDS MAS EqS RlS endth, MAS')
= th H is IL sorts SS . SSDS OPDS MAS' EqS RlS endth .
eq setMbs(fmod H is IL sorts SS . SSDS OPDS MAS EqS endfm, MAS')
= fmod H is IL sorts SS . SSDS OPDS MAS' EqS endfm .
eq setMbs(fth H is IL sorts SS . SSDS OPDS MAS EqS endfth, MAS')
= fth H is IL sorts SS . SSDS OPDS MAS' EqS endfth .
eq setEqs(noModule, EqS) = noModule .
eq setEqs(mod H is IL sorts SS . SSDS OPDS MAS EqS RlS endm, EqS')
= mod H is IL sorts SS . SSDS OPDS MAS EqS' RlS endm .
eq setEqs(th H is IL sorts SS . SSDS OPDS MAS EqS RlS endth, EqS')
= th H is IL sorts SS . SSDS OPDS MAS EqS' RlS endth .
eq setEqs(fmod H is IL sorts SS . SSDS OPDS MAS EqS endfm, EqS')
= fmod H is IL sorts SS . SSDS OPDS MAS EqS' endfm .
eq setEqs(fth H is IL sorts SS . SSDS OPDS MAS EqS endfth, EqS')
= fth H is IL sorts SS . SSDS OPDS MAS EqS' endfth .
eq setRls(mod H is IL sorts SS . SSDS OPDS MAS EqS RlS endm, RlS')
= mod H is IL sorts SS . SSDS OPDS MAS EqS RlS' endm .
eq setRls(th H is IL sorts SS . SSDS OPDS MAS EqS RlS endth, RlS')
= th H is IL sorts SS . SSDS OPDS MAS EqS RlS' endth .
eq setRls(fmod H is IL sorts SS . SSDS OPDS MAS EqS endfm, RlS)
= if RlS == none
then fmod H is IL sorts SS . SSDS OPDS MAS EqS endfm
else mod H is IL sorts SS . SSDS OPDS MAS EqS RlS endm
fi .
eq setRls(fth H is IL sorts SS . SSDS OPDS MAS EqS endfth, RlS)
= if RlS == none
then fth H is IL sorts SS . SSDS OPDS MAS EqS endfth
else th H is IL sorts SS . SSDS OPDS MAS EqS RlS endth
fi .
eq setSorts(noModule, SS) = noModule .
eq setSorts(mod H is IL sorts SS . SSDS OPDS MAS EqS RlS endm, SS')
= mod H is IL sorts SS' . SSDS OPDS MAS EqS RlS endm .
eq setSorts(th H is IL sorts SS . SSDS OPDS MAS EqS RlS endth, SS')
= th H is IL sorts SS' . SSDS OPDS MAS EqS RlS endth .
eq setSorts(fmod H is IL sorts SS . SSDS OPDS MAS EqS endfm, SS')
= fmod H is IL sorts SS' . SSDS OPDS MAS EqS endfm .
eq setSorts(fth H is IL sorts SS . SSDS OPDS MAS EqS endfth, SS')
= fth H is IL sorts SS' . SSDS OPDS MAS EqS endfth .
eq setPars(mod ME is IL sorts SS . SSDS OPDS MAS EqS RlS endm, PDL)
= if PDL == nil
then mod ME is IL sorts SS . SSDS OPDS MAS EqS RlS endm
else mod ME{PDL} is IL sorts SS . SSDS OPDS MAS EqS RlS endm
fi .
eq setPars(mod ME{PDL} is IL sorts SS . SSDS OPDS MAS EqS RlS endm, PDL')
= if PDL' == nil
then mod ME is IL sorts SS . SSDS OPDS MAS EqS RlS endm
else mod ME{PDL'} is IL sorts SS . SSDS OPDS MAS EqS RlS endm
fi .
eq setPars(th H is IL sorts SS . SSDS OPDS MAS EqS RlS endth, PDL)
= th H is IL sorts SS . SSDS OPDS MAS EqS RlS endth .
eq setPars(fmod ME is IL sorts SS . SSDS OPDS MAS EqS endfm, PDL)
= if PDL == nil
then fmod ME is IL sorts SS . SSDS OPDS MAS EqS endfm
else fmod ME{PDL} is IL sorts SS . SSDS OPDS MAS EqS endfm
fi .
eq setPars(fmod ME{PDL} is IL sorts SS . SSDS OPDS MAS EqS endfm, PDL')
= if PDL' == nil
then fmod ME is IL sorts SS . SSDS OPDS MAS EqS endfm
else fmod ME{PDL'} is IL sorts SS . SSDS OPDS MAS EqS endfm
fi .
eq setPars(fth H is IL sorts SS . SSDS OPDS MAS EqS endfth, PDL)
= fth H is IL sorts SS . SSDS OPDS MAS EqS endfth .
eq setName(mod ME is IL sorts SS . SSDS OPDS MAS EqS RlS endm, ME')
= mod ME' is IL sorts SS . SSDS OPDS MAS EqS RlS endm .
eq setName(mod ME{PDL} is IL sorts SS . SSDS OPDS MAS EqS RlS endm, ME')
= mod ME'{PDL} is IL sorts SS . SSDS OPDS MAS EqS RlS endm .
eq setName(fmod ME is IL sorts SS . SSDS OPDS MAS EqS endfm, ME')
= fmod ME' is IL sorts SS . SSDS OPDS MAS EqS endfm .
eq setName(fmod ME{PDL} is IL sorts SS . SSDS OPDS MAS EqS endfm, ME')
= fmod ME'{PDL} is IL sorts SS . SSDS OPDS MAS EqS endfm .
eq setName(fth H is IL sorts SS . SSDS OPDS MAS EqS endfth, H')
= fth H' is IL sorts SS . SSDS OPDS MAS EqS endfth .
eq setName(th H is IL sorts SS . SSDS OPDS MAS EqS RlS endth, H')
= th H' is IL sorts SS . SSDS OPDS MAS EqS RlS endth .
eq setName(noModule, ME) = noModule .
eq addSorts(SS, U) = setSorts(U, (SS ; getSorts(U))) .
eq addSorts(SS, noModule) = noModule .
eq addSubsorts(SSDS, U) = setSubsorts(U, (SSDS getSubsorts(U))) .
eq addSubsorts(SSDS, noModule) = noModule .
eq addOps(OPDS, U) = setOps(U, (OPDS getOps(U))) .
eq addMbs(MAS, U) = setMbs(U, (MAS getMbs(U))) .
eq addMbs(MAS, noModule) = noModule .
eq addEqs(EqS, U) = setEqs(U, (EqS getEqs(U))) .
eq addEqs(EqS, noModule) = noModule .
eq addRls(RlS, U) = setRls(U, (RlS getRls(U))) .
eq addRls(RlS, noModule) = noModule .
eq addImports(IL, U) = setImports(U, (getImports(U) IL)) .
eq addImports(IL, noModule) = noModule .
eq addDecls(noModule, U) = U .
eq addDecls(U, noModule) = U .
eq addDecls(U, U')
= addImports(getImports(U'),
addSorts(getSorts(U'),
addSubsorts(getSubsorts(U'),
addOps(getOps(U'),
addMbs(getMbs(U'),
addEqs(getEqs(U'),
if U' :: FModule or U' :: FTheory
then U
else addRls(getRls(U'),U)
fi))))))
[owise] .
op toFModule : Module -> FModule .
eq toFModule(U) = addDecls(setName(emptyFModule,getName(U)),setRls(U,none)) .
op getSig : Module -> Module .
eq getSig(U) = setRls(setEqs(U,none),none) .
endfm
fmod BUBBLES is
including QID-LIST .
sorts @Token@ @SortToken@ @NeTokenList@ @Bubble@ .
op token : Qid -> @Token@
[special(
id-hook Bubble (1 1)
op-hook qidSymbol (<Qids> : ~> Qid))] .
op sortToken : Qid -> @SortToken@
[special(
id-hook Bubble (1 1)
op-hook qidSymbol (<Qids> : ~> Qid)
id-hook Exclude ([ ] < to , . ( ) { } : |
ditto precedence prec gather
assoc associative comm commutative
ctor constructor id: strat strategy
poly memo memoization iter frozen
config object msg metadata nonexec variant))] .
op neTokenList : QidList -> @NeTokenList@
[special(
id-hook Bubble (1 -1 ( ))
op-hook qidListSymbol (__ : QidList QidList ~> QidList)
op-hook qidSymbol (<Qids> : ~> Qid)
id-hook Exclude (.))] .
op bubble : QidList -> @Bubble@
[special(
id-hook Bubble (1 -1 ( ))
op-hook qidListSymbol (__ : QidList QidList ~> QidList)
op-hook qidSymbol (<Qids> : ~> Qid))] .
endfm
fmod SUBSTITUTION-HANDLING is
protecting META-MODULE .
var S S' Subst Subst' : Substitution .
var V V' : Variable .
var C C' : Constant .
var Ct : Context .
var T T' T1 T2 T1' T2' T1'' T2'' : Term .
var F F' : Qid .
var TL TL' TL1 TL2 TL1' TL2' : TermList .
var Att : AttrSet .
var RLS : RuleSet .
var Rl : Rule .
var TP : Type .
var N : Nat .
var NeTL : NeTermList .
var CtL : NeCTermList .
var ST : Sort .
var Cnd : Condition .
--- Apply Substitution to Term --------------------------------------------
op _<<_ : Term Substitution -> Term .
eq TL << none = TL .
eq C << Subst = C .
eq V << ((V' <- T) ; Subst) = if V == V' then T else V << Subst fi .
eq F[TL] << Subst = F[TL << Subst] .
op _<<_ : TermList Substitution -> TermList .
eq (T, NeTL) << Subst = (T << Subst, NeTL << Subst) .
eq empty << Subst = empty .
op _<<_ : Context Substitution -> Context .
eq Ct << none = Ct .
eq [] << Subst = [] .
eq F[CtL,NeTL] << Subst = F[CtL << Subst,NeTL << Subst] .
eq F[NeTL,CtL] << Subst = F[NeTL << Subst, CtL << Subst] .
eq F[Ct] << Subst = F[Ct << Subst] .
op _<<_ : Condition Substitution -> Condition .
eq (T1 = T2 /\ Cnd) << S = (T1 << S) = (T2 << S) /\ (Cnd << S) .
eq (T1 := T2 /\ Cnd) << S = (T1 << S) := (T2 << S) /\ (Cnd << S) .
eq (T1 : ST /\ Cnd) << S = (T1 << S) : ST /\ (Cnd << S) .
eq (T1 => T2 /\ Cnd) << S = (T1 << S) => (T2 << S) /\ (Cnd << S) .
eq (nil).EqCondition << S = nil .
op _<<_ : Substitution Substitution -> Substitution .
eq S << (none).Substitution = S .
eq (none).Substitution << S = (none).Substitution .
eq ((V' <- T) ; S') << S
= (V' <- (T << S))
;
(S' << S) .
--- Combine Substitutions -------------------------------------------------
op _.._ : Substitution Substitution -> Substitution .
eq S .. S' = (S << S') ; S' .
--- Restrict Assignments to Variables in a Term ----------------------
op _|>_ : Substitution TermList -> Substitution .
eq Subst |> TL = Subst |>* Vars(TL) .
op _|>*_ : Substitution TermList -> Substitution .
--- eq noMatch |>* TL = noMatch .
eq Subst |>* TL = Subst |>** TL [none] .
op _|>**_[_] : Substitution TermList
Substitution -> Substitution .
eq none |>** TL [Subst']
= Subst' .
eq ((V <- V) ; Subst) |>** TL [Subst']
= Subst |>** TL [Subst'] .
eq ((V <- T') ; Subst) |>** TL [Subst']
= Subst |>** TL
[Subst' ; if any V in TL then (V <- T') else none fi] .
--- Remove Variables from list ----------------------
op _intersect_ : TermList TermList -> TermList .
eq (TL1,T,TL2) intersect (TL1',T,TL2')
= (T,((TL1,TL2) intersect (TL1',TL2'))) .
eq TL intersect TL' = empty [owise] .
op _intersectVar_ : TermList TermList -> TermList .
eq TL1 intersectVar TL2
= TL1 intersectVar* Vars(TL2) .
op _intersectVar*_ : TermList TermList -> TermList .
eq (T,TL1) intersectVar* TL2
= (if any Vars(T) in TL2 then T else empty fi,TL1 intersectVar* TL2) .
eq empty intersectVar* TL2
= empty .
--- Remove Variables from list ----------------------
op _setMinus_ : TermList TermList -> TermList .
eq (TL1,T,TL2) setMinus (TL1',T,TL2')
= (TL1,TL2) setMinus (TL1',T,TL2') .
eq TL setMinus TL' = TL [owise] .
--- Variables ---
op Vars : GTermList -> TermList .
eq Vars((T,TL:GTermList)) = VarsTerm(T),Vars(TL:GTermList) .
eq Vars((Ct,TL:GTermList)) = VarsTerm(Ct),Vars(TL:GTermList) .
eq Vars(empty) = empty .
op VarsTerm : Term -> TermList . ---warning memo
eq VarsTerm(V) = V .
eq VarsTerm(F[TL:TermList]) = Vars(TL:TermList) .
eq VarsTerm(C) = empty .
op VarsTerm : Context -> TermList . ---warning memo
eq VarsTerm(F[TL:GTermList]) = Vars(TL:GTermList) .
--- membership ---
op _in_ : Term TermList -> Bool .
eq T in (TL,T,TL') = true .
eq T in TL = false [owise] .
--- membership ---
op any_in_ : TermList TermList -> Bool . --- [memo] .
eq any empty in TL = false .
eq any (TL1,T,TL2) in (TL1',T,TL2') = true .
eq any TL in TL' = false [owise] .
--- membership ---
op all_in_ : TermList TermList -> Bool . --- [memo] .
eq all empty in TL = true .
eq all (TL1,T,TL2) in (TL1',T,TL2') = all (TL1,TL2) in (TL1',T,TL2') .
eq all TL in TL' = false [owise] .
--- Occur check ---
op allVars_inVars_ : GTermList GTermList -> Bool .
eq allVars TL:GTermList inVars TL':GTermList
= all Vars(TL:GTermList) in Vars(TL':GTermList) .
op anyVars_inVars_ : GTermList GTermList -> Bool .
eq anyVars TL:GTermList inVars TL':GTermList
= any Vars(TL:GTermList) in Vars(TL':GTermList) .
op rangeVars : Substitution -> TermList .
eq rangeVars(V <- T ; Subst) = (Vars(T),rangeVars(Subst)) .
eq rangeVars(none) = empty .
op dom_inVars_ : Substitution TermList -> Bool .
eq dom Subst inVars TL = dom Subst in Vars(TL) .
op dom_in_ : Substitution TermList -> Bool .
eq dom (V <- T ; Subst) in (TL1,V,TL2) = true .
eq dom Subst in TL = false [owise] .
op dom_notInVars_ : Substitution TermList -> Bool .
eq dom Subst notInVars TL = dom Subst notIn Vars(TL) .
op dom_notIn_ : Substitution TermList -> Bool .
eq dom none notIn TL = true .
ceq dom (V <- T ; Subst) notIn TL = true if not (V in TL) .
eq dom Subst notIn TL = false [owise] .
op range_inVars_ : Substitution TermList -> Bool .
eq range Subst inVars TL = range Subst in Vars(TL) .
op range_in_ : Substitution TermList -> Bool .
eq range (V <- T ; Subst) in TL
= any Vars(T) in TL or-else range Subst in TL .
eq range none in TL
= false .
op valid-occur-check? : Substitution -> Bool .
eq valid-occur-check?(Subst)
= not (dom Subst inVars (rangeVars(Subst))) .
op extract-bindings : Substitution -> TermList .
eq extract-bindings(none) = empty .
eq extract-bindings(V <- T ; Subst) = (T,extract-bindings(Subst)) .
endfm
fmod SUBSTITUTIONSET is
protecting SUBSTITUTION-HANDLING .
protecting TERMSET-FM .
sort SubstitutionSet NeSubstitutionSet .
subsort Substitution < NeSubstitutionSet < SubstitutionSet .
op empty : -> SubstitutionSet [ctor] .
op _|_ : SubstitutionSet SubstitutionSet -> SubstitutionSet
[ctor assoc comm id: empty format (d n d d)] .
op _|_ : NeSubstitutionSet SubstitutionSet -> NeSubstitutionSet
[ctor ditto] .
eq X:Substitution | X:Substitution = X:Substitution .
vars SS SS' : SubstitutionSet .
vars S S' Subst : Substitution .
vars T T' : Term .
vars TL TL' : TermList .
vars N N' : Nat .
var V : Variable .
op _<<_ : Substitution SubstitutionSet -> SubstitutionSet .
eq S << empty = empty .
ceq S << (S' | SS') = (S << S') | (S << SS') if SS' =/= empty .
op _..._ : SubstitutionSet [SubstitutionSet]
-> SubstitutionSet [strat (1) gather (e E)] .
eq empty ... SS':[SubstitutionSet] = empty .
eq (S | SS) ... SS':[SubstitutionSet]
= (S ...' SS':[SubstitutionSet])
|
(SS ... SS':[SubstitutionSet]) .
op _...'_ : Substitution SubstitutionSet -> SubstitutionSet .
eq S ...' empty
= empty .
eq S ...' (S' | SS')
= (S .. S')
|
(S ...' SS') .
op anySub : NeSubstitutionSet -> Substitution .
eq anySub(S | SS) = S .
endfm
fmod VARIANT is
pr SUBSTITUTIONSET .
pr META-LEVEL .
var M : Module .
vars T T' TS TS' CtTS CtTS' Lhs Rhs : Term .
vars N N' NextVar NextVar' NextVar'' : Nat .
var B : Bound .
var TL TL' : TermList .
var NeTL : NeTermList .
var EqS : EquationSet .
var AtS : AttrSet .
var Q : Qid .
vars S S' : Substitution .
var V : Variable .
vars TP TP' : Type .
var C : Constant .
vars F F' : Qid .
sort VariantTripleSet .
subsort Variant < VariantTripleSet .
op empty : -> VariantTripleSet [ctor] .
op _|_ : VariantTripleSet VariantTripleSet -> VariantTripleSet
[ctor assoc comm id: empty prec 65 format (d d n d)] .
eq X:Variant | X:Variant = X:Variant .
op getTerms : VariantTripleSet -> TermSet .
eq getTerms({T:Term,S:Substitution,NextVar:Nat,P:Parent,B:Bool}
| R:VariantTripleSet)
= T:Term | getTerms(R:VariantTripleSet) .
eq getTerms((empty).VariantTripleSet)
= emptyTermSet .
op getSubstitutions : VariantTripleSet -> SubstitutionSet .
eq getSubstitutions({T:Term,S:Substitution,NextVar:Nat,P:Parent,B:Bool}
| R:VariantTripleSet) = S:Substitution | getSubstitutions(R:VariantTripleSet) .
eq getSubstitutions((empty).VariantTripleSet)
= empty .
endfm
fmod KIND-CHECK is
pr META-LEVEL .
--- copy of or-else to make eqs more readable
op _orL_ : Bool Bool -> Bool [strat (1 0) gather (e E) prec 59] .
op kinds? : TypeListSet -> Bool .
op kinds? : Module Bool TermList -> Bool .
op kinds? : Module Bool AttrSet -> Bool .
op kinds? : Module Bool Condition -> Bool .
op kinds? : Module Bool OpDeclSet -> Bool .
op kinds? : Module Bool MembAxSet -> Bool .
op kinds? : Module Bool EquationSet -> Bool .
op kinds? : Module Bool RuleSet -> Bool .
op kinds? : Bool Module -> Bool .
var FM : FModule .
var FT : FTheory .
var SM : SModule .
var ST : STheory .
var M : Module .
var K : Kind .
var S : Sort .
var SS : SortSet .
var T : Type .
var TL TL' : TypeList .
var NTL : NeTypeList .
var TS : TypeListSet .
var C : Constant .
var V : Variable .
var TML : TermList .
var NTML : NeTermList .
var Q : Qid .
var AS : AttrSet .
var CN : Condition .
var TM TM' : Term .
var O O' : OpDecl .
var OS : OpDeclSet .
var E E' : Equation .
var ES : EquationSet .
var MB MB' : MembAx .
var MBS : MembAxSet .
var R R' : Rule .
var RS : RuleSet .
var B : Bool .
eq true orL B = true .
eq false orL B = B .
eq kinds?(K) = true .
eq kinds?(S) = false .
eq kinds?(T NTL) = kinds?(T) orL kinds?(NTL) .
eq kinds?(nil) = false .
eq kinds?(TL ; TL' ; TS) = kinds?(TL) orL kinds?(TL' ; TS) .
eq kinds?((none).TypeListSet) = false .
eq kinds?(M,B,C) = getType(C) :: Kind .
eq kinds?(M,B,V) = getType(V) :: Kind .
eq kinds?(M,B,Q[NTML]) = (B and-then (leastSort(M,Q[NTML]) :: Kind)) orL kinds?(M,B,NTML) .
eq kinds?(M,B,(TM,NTML)) = kinds?(M,B,TM) orL kinds?(M,B,NTML) .
eq kinds?(M,B,empty) = false .
eq kinds?(M,B,id(T) AS) = kinds?(M,B,T) orL kinds?(M,B,AS) .
eq kinds?(M,B,left-id(T) AS) = kinds?(M,B,T) orL kinds?(M,B,AS) .
eq kinds?(M,B,right-id(T) AS) = kinds?(M,B,T) orL kinds?(M,B,AS) .
eq kinds?(M,B,AS) = false [owise] .
eq kinds?(M,B,TM = TM' /\ CN) = kinds?(M,B,(TM,TM')) orL kinds?(M,B,CN) .
eq kinds?(M,B,TM : S /\ CN) = kinds?(M,B,TM) orL kinds?(M,B,CN) .
eq kinds?(M,B,TM := TM' /\ CN) = kinds?(M,B,(TM,TM')) orL kinds?(M,B,CN) .
eq kinds?(M,B,TM => TM' /\ CN) = kinds?(M,B,(TM,TM')) orL kinds?(M,B,CN) .
eq kinds?(M,B,(nil).Condition) = false .
eq kinds?(M,B,op Q : TL -> T [AS].) = kinds?(TL T) orL kinds?(M,B,AS) .
eq kinds?(M,B,O O' OS) = kinds?(M,B,O) orL kinds?(M,B,O' OS) .
eq kinds?(M,B,(none).OpDeclSet) = false .
eq kinds?(M,B,mb TM : S [AS].) = kinds?(M,B,TM) orL kinds?(M,B,AS) .
eq kinds?(M,B,cmb TM : S if CN [AS].) = kinds?(M,B,TM) orL kinds?(M,B,CN) orL kinds?(M,B,AS) .
eq kinds?(M,B,MB MB' MBS) = kinds?(M,B,MB) orL kinds?(M,B,MB' MBS) .
eq kinds?(M,B,(none).MembAxSet) = false .
eq kinds?(M,B,eq TM = TM' [AS].) = kinds?(M,B,(TM,TM')) orL kinds?(M,B,AS) .
eq kinds?(M,B,ceq TM = TM' if CN [AS].) = kinds?(M,B,(TM,TM')) orL kinds?(M,B,CN) orL kinds?(M,B,AS) .
eq kinds?(M,B,E E' ES) = kinds?(M,B,E) orL kinds?(M,B,E' ES) .
eq kinds?(M,B,(none).EquationSet) = false .
eq kinds?(M,B,rl TM => TM' [AS].) = kinds?(M,B,(TM,TM')) orL kinds?(M,B,AS) .
eq kinds?(M,B,crl TM => TM' if CN [AS].) = kinds?(M,B,(TM,TM')) orL kinds?(M,B,CN) orL kinds?(M,B,AS) .
eq kinds?(M,B,R R' RS) = kinds?(M,B,R) orL kinds?(M,B,R' RS) .
eq kinds?(M,B,(none).RuleSet) = false .
eq kinds?(B,FM) =
kinds?(FM,B,getOps(FM)) orL
kinds?(FM,B,getMbs(FM)) orL
kinds?(FM,B,getEqs(FM)) .
eq kinds?(B,FT) =
kinds?(FT,B,getOps(FT)) orL
kinds?(FT,B,getMbs(FT)) orL
kinds?(FT,B,getEqs(FT)) .
eq kinds?(B,SM) =
kinds?(SM,B,getOps(SM)) orL
kinds?(SM,B,getMbs(SM)) orL
kinds?(SM,B,getEqs(SM)) orL
kinds?(SM,B,getRls(SM)) .
eq kinds?(B,ST) =
kinds?(ST,B,getOps(ST)) orL
kinds?(ST,B,getMbs(ST)) orL
kinds?(ST,B,getEqs(ST)) orL
kinds?(ST,B,getRls(ST)) .
endfm
fmod GTERMLIST-REFINEMENT is
pr META-TERM .
sort GTerm NeGTermList .
subsort Term Context < GTerm < NeGTermList < GTermList .
subsort NeTermList NeCTermList < NeGTermList .
op _,_ : NeGTermList GTermList -> NeGTermList [ctor ditto] .
op _,_ : GTermList NeGTermList -> NeGTermList [ctor ditto] .
endfm
fmod SUBSTITUTION-REFINEMENT is
pr QIDSET-REFINEMENT .
pr GTERMLIST-REFINEMENT .
sort VarAssignment ConstAssignment GroundAssignment .
sort EmptySubstitution VarSubstitution ConstSubstitution GroundSubstitution .
subsort ConstAssignment < GroundAssignment .
subsort VarAssignment ConstAssignment GroundAssignment < Assignment .
subsort EmptySubstitution < VarSubstitution ConstSubstitution GroundSubstitution < Substitution .
subsort ConstSubstitution < GroundSubstitution .
subsort VarAssignment < VarSubstitution .
subsort ConstAssignment < ConstSubstitution .
subsort GroundAssignment < GroundSubstitution .