-
Notifications
You must be signed in to change notification settings - Fork 0
/
maude-strat.maude
14985 lines (13115 loc) · 618 KB
/
maude-strat.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
---- Full Maude specification version 2.3
---- To be run on Maude 2.3
---- author: Francisco Duran
fmod BANNER is
pr STRING .
op banner : -> String .
eq banner = "Full Maude 2.3 (February 12th, 2007)" .
endfm
***(
This file is part of the Maude 2 interpreter.
Copyright 1997-2003 SRI International, Menlo Park, CA 94025, USA.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 inclof the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNSS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public Leicense
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
)
---- to do:
---- - continue .
---- - show search path .
---- - show path labels <number> .
---- - show components .
---- Main bugs fixed since last release:
----
---- - (october 17th, 2006)
---- Changes in Alpha88a's prelude are now correctly handled
---- - (july 22nd, 2006)
---- Bug in the meta-pretty-print of types.
---- - (july 21st, 2006)
---- Object-oriented messages where not given the attribute msg
---- (from a comment by Peter).
---- - (reported by Radestock)
---- getSort was not handling parameterized sorts appropriately.
---- - the set protect/extend/include off commands didn't work if the
---- module not importing was not among the imported ones
----
---- Last changes:
----
---- - BOOL is included, instead of protected, into any entered module.
---- - A new module expression POWER[n] is now available. A module expression
---- POWER[n]{Nat} produces a module
----
---- fmod POWER[n]{X :: TRIV} is
---- inc TUPLE[n]{X, X, ..., X} .
---- endfm
----
---- which is then instantiated by the Nat view.
---- - (July 18th, 2006)
---- The summation module expression now generates a module
---- that includes (instead of protect) its summands.
----
---- - All sorts declared in modules used for parsing have been renamed.
---- Any sort S in one of these modules is nos called @S@.
---- Since some of these modules where added to the user defined modules
---- for dealing with ups, conditions, etc., he was getting error when
---- using sorts like Token or OpDecl in his specs.
----
---- - Syntax for parameterization has been changed (again) !!! :
---- - module definition: FOO{X :: TRIV, Y :: TRIV}
---- - module instantiation: FOO{Bar,Baz}
---- - parameterized sorts: Foo{Bar,Baz}
----
---- - Any module loaded in Core Maude can be used in Full Maude.
---- This may be particularly useful in the case of using the model checker.
----
---- (mod CHECK-RESP is
---- protecting MODEL-CHECKER .
---- ...
---- endm)
----
---- (red p(0) |= (<> Qstate) .)
----
---- - Module renaming and summation consistent with Core Maude's. Built-ins
---- are now handled at the metalevel, instead of leaving the inclusions to
---- Core Maude. In this way, they can be renamed and redefined, as in
---- Core Maude. This makes Full Maude slower.
----
---- - The lazy evaluation of modules is working. When a module is redefined
---- its dependent modules are removed only if generated internally. Those
---- introduced by the user save their term representation, from which the
---- whole processing can take place. They will be recompiled by need.
----
---- - The form of qualifying sorts coming from the parameters in
---- parameterized modules has changed AGAIN: The sort Elt coming from
---- X :: TRIV is now written as X$Elt (Note that sort names cannot contain
---- dots anymore).
----
---- - Tuples are built with the syntax
---- TUPLE[size]{comma_separated_list_of_views}
---- For example, given a view Nat from TRIV to NAT we can define pairs of
---- nats with TUPLE[2]{Nat, Nat}.
----
---- - The model-checker is loaded before the full maude modules, so that
---- it can be used.
----
---- - Object-oriented modules include a module CONFIGURATION+, which
---- imports CONFIGURATION, defines a function
---- op class : Object -> Cid .
---- returning the actual class of the given object, and add syntax
---- for objects with no attributes <_:_| >. Classes without attributes
---- are defined with syntax class CLASS-NAME .
----
---- Things to come:
----
---- - Commands missing: continue ...
----
---- - On parameterized theories and views: linked parameters, composed and
---- lifted views, and default views.
----
---- - ops names in op declarations
----
---- known bugs:
----
---- - error messages could be given in down commands
----
---- - Check: perhaps we need to convert constants back into vbles in
---- procViewAux
----
---- - Parameterized sorts don't work in sort constraints (nor by themselves,
---- nor in the conditions of axioms. They are accepted in their equivalent
---- single token form but do not get instantiated
---- cmb (A, B) S : PFun(X, Y) if not(A in dom(S)) /\ S : PFun`(X`,Y`) .
----
----load model-checker.maude
-------------------------------------------------------------------------------
*******************************************************************************
***
*** 2 The Signature of Full Maude
***
*******************************************************************************
-------------------------------------------------------------------------------
fmod EXTENDED-SORTS is
---- Any modification in this module must be reflected in the metamodule
---- used in eq addInfoConds in module UNIT-BUBBLE-PARSING
sorts @SortToken@ @ViewToken@ @Sort@ @Kind@ @Type@ @SortList@
@TypeList@ @ViewExp@ @ModExp@ .
subsorts @SortToken@ < @Sort@ < @SortList@ < @TypeList@ .
subsorts @Sort@ @Kind@ < @Type@ < @TypeList@ .
subsort @ViewToken@ < @ViewExp@ .
op _`{_`} : @Sort@ @ViewExp@ -> @Sort@ [prec 40] .
op __ : @SortList@ @SortList@ -> @SortList@ [assoc] .
op __ : @TypeList@ @TypeList@ -> @TypeList@ [assoc] .
op `[_`] : @Sort@ -> @Kind@ .
op _`,_ : @ViewExp@ @ViewExp@ -> @ViewExp@ [assoc] .
op _`{_`} : @ViewExp@ @ViewExp@ -> @ViewExp@ [prec 40] .
endfm
-------------------------------------------------------------------------------
******************************************************************************
-------------------------------------------------------------------------------
fmod OPERATOR-ATTRIBUTES is
sorts @Attr@ @AttrList@ @Hook@ @HookList@ @Bubble@ @Token@ @NeTokenList@ .
subsort @Attr@ < @AttrList@ .
subsort @Hook@ < @HookList@ .
op __ : @AttrList@ @AttrList@ -> @AttrList@ [assoc] .
ops assoc associative : -> @Attr@ .
ops comm commutative : -> @Attr@ .
ops idem idempotent : -> @Attr@ .
ops id:_ identity:_ : @Bubble@ -> @Attr@ .
ops left`id:_ left`identity:_ : @Bubble@ -> @Attr@ .
ops right`id:_ right`identity:_ : @Bubble@ -> @Attr@ .
ops frozen`(_`) poly`(_`) strat`(_`) strategy`(_`) :
@NeTokenList@ -> @AttrList@ .
ops memo memoization : -> @Attr@ .
ops prec_ precedence_ : @Token@ -> @Attr@ .
ops gather`(_`) gathering`(_`) : @NeTokenList@ -> @Attr@ .
ops format`(_`) : @NeTokenList@ -> @Attr@ .
ops ctor constructor : -> @Attr@ .
ops frozen ditto iter : -> @Attr@ .
ops object msg message config : -> @Attr@ .
op special`(_`) : @HookList@ -> @Attr@ .
op __ : @HookList@ @HookList@ -> @HookList@ [assoc] .
op id-hook_ : @Token@ -> @Hook@ .
op id-hook_`(_`) : @Token@ @NeTokenList@ -> @Hook@ .
op op-hook_`(_:_->_`) : @Token@ @Token@ @NeTokenList@ @Token@ -> @Hook@ .
op op-hook_`(_:`->_`) : @Token@ @Token@ @Token@ -> @Hook@ .
op op-hook_`(_:_~>_`) : @Token@ @Token@ @NeTokenList@ @Token@ -> @Hook@ .
op op-hook_`(_:`~>_`) : @Token@ @Token@ @Token@ -> @Hook@ .
op term-hook_`(_`) : @Token@ @Bubble@ -> @Hook@ .
endfm
-------------------------------------------------------------------------------
*******************************************************************************
-------------------------------------------------------------------------------
fmod MOD-EXPRS is
including OPERATOR-ATTRIBUTES .
including EXTENDED-SORTS .
sorts @Map@ @MapList@ .
subsort @Map@ < @MapList@ .
subsorts @Token@ < @ModExp@ .
*** module expression
op _*`(_`) : @ModExp@ @MapList@ -> @ModExp@ .
op _`{_`} : @ModExp@ @ViewExp@ -> @ModExp@ .
op TUPLE`[_`] : @Token@ -> @ModExp@ .
op POWER`[_`] : @Token@ -> @ModExp@ .
op _+_ : @ModExp@ @ModExp@ -> @ModExp@ [assoc prec 42] .
*** renaming maps
op op_to_ : @Token@ @Token@ -> @Map@ .
op op_:_->_to_ : @Token@ @TypeList@ @Type@ @Token@ -> @Map@ .
op op_: ->_to_ : @Token@ @Type@ @Token@ -> @Map@ .
op op_:_~>_to_ : @Token@ @TypeList@ @Type@ @Token@ -> @Map@ .
op op_: ~>_to_ : @Token@ @Type@ @Token@ -> @Map@ .
op op_to_`[_`] : @Token@ @Token@ @AttrList@ -> @Map@ .
op op_:_->_to_`[_`] : @Token@ @TypeList@ @Type@ @Token@ @AttrList@ -> @Map@ .
op op_:`->_to_`[_`] : @Token@ @Type@ @Token@ @AttrList@ -> @Map@ .
op op_:_~>_to_`[_`] : @Token@ @TypeList@ @Type@ @Token@ @AttrList@ -> @Map@ .
op op_:`~>_to_`[_`] : @Token@ @Type@ @Token@ @AttrList@ -> @Map@ .
op sort_to_ : @Sort@ @Sort@ -> @Map@ .
op label_to_ : @Token@ @Token@ -> @Map@ .
op class_to_ : @Sort@ @Sort@ -> @Map@ .
op attr_._to_ : @Sort@ @Token@ @Token@ -> @Map@ .
op msg_to_ : @Token@ @Token@ -> @Map@ .
op msg_:_->_to_ : @Token@ @TypeList@ @Type@ @Token@ -> @Map@ .
op msg_:`->_to_ : @Token@ @Type@ @Token@ -> @Map@ .
op _`,_ : @MapList@ @MapList@ -> @MapList@ [assoc prec 42] .
endfm
-------------------------------------------------------------------------------
*******************************************************************************
-------------------------------------------------------------------------------
fmod SIGNATURES is
inc MOD-EXPRS .
sorts @SortDecl@ @SubsortRel@ @SubsortDecl@ @OpDecl@ .
op `(_`) : @Token@ -> @Token@ .
*** sort declaration
op sorts_. : @SortList@ -> @SortDecl@ .
op sort_. : @SortList@ -> @SortDecl@ .
*** subsort declaration
op subsort_. : @SubsortRel@ -> @SubsortDecl@ .
op subsorts_. : @SubsortRel@ -> @SubsortDecl@ .
op _<_ : @SortList@ @SortList@ -> @SubsortRel@ .
op _<_ : @SortList@ @SubsortRel@ -> @SubsortRel@ .
*** operator declaration
op op_:`->_. : @Token@ @Type@ -> @OpDecl@ .
op op_:`->_`[_`]. : @Token@ @Type@ @AttrList@ -> @OpDecl@ .
op op_:_->_. : @Token@ @TypeList@ @Type@ -> @OpDecl@ .
op op_:_->_`[_`]. : @Token@ @TypeList@ @Type@ @AttrList@ -> @OpDecl@ .
op ops_:`->_. : @NeTokenList@ @Type@ -> @OpDecl@ .
op ops_:`->_`[_`]. : @NeTokenList@ @Type@ @AttrList@ -> @OpDecl@ .
op ops_:_->_. : @NeTokenList@ @TypeList@ @Type@ -> @OpDecl@ .
op ops_:_->_`[_`]. : @NeTokenList@ @TypeList@ @Type@ @AttrList@ -> @OpDecl@ .
op op_:`~>_. : @Token@ @Sort@ -> @OpDecl@ .
op op_:`~>_`[_`]. : @Token@ @Sort@ @AttrList@ -> @OpDecl@ .
op op_:_~>_. : @Token@ @TypeList@ @Sort@ -> @OpDecl@ .
op op_:_~>_`[_`]. : @Token@ @TypeList@ @Sort@ @AttrList@ -> @OpDecl@ .
op ops_:`~>_. : @NeTokenList@ @Sort@ -> @OpDecl@ .
op ops_:`~>_`[_`]. : @NeTokenList@ @Sort@ @AttrList@ -> @OpDecl@ .
op ops_:_~>_. : @NeTokenList@ @TypeList@ @Sort@ -> @OpDecl@ .
op ops_:_~>_`[_`]. : @NeTokenList@ @TypeList@ @Sort@ @AttrList@ -> @OpDecl@ .
endfm
-------------------------------------------------------------------------------
*******************************************************************************
-------------------------------------------------------------------------------
fmod F&S-MODS&THS is
including SIGNATURES .
including QID-LIST .
sorts @FDeclList@ @SDeclList@ @Module@ @ImportDecl@ @Parameter@
@List<Parameter>@ @EqDecl@ @RlDecl@ @MbDecl@ @VarDecl@ @VarDeclList@ .
subsort @VarDecl@ < @VarDeclList@ .
subsorts @VarDecl@ @ImportDecl@ @SortDecl@ @SubsortDecl@ @OpDecl@ @MbDecl@
@EqDecl@ @VarDeclList@ < @FDeclList@ .
subsorts @RlDecl@ @FDeclList@ < @SDeclList@ .
*** variable declaration
op vars_:_. : @NeTokenList@ @Type@ -> @VarDecl@ .
op var_:_. : @NeTokenList@ @Type@ -> @VarDecl@ .
*** membership axiom declaration
op mb_:_. : @Bubble@ @Sort@ -> @MbDecl@ .
op cmb_:_if_. : @Bubble@ @Sort@ @Bubble@ -> @MbDecl@ .
*** equation declaration
op eq_=_. : @Bubble@ @Bubble@ -> @EqDecl@ .
op ceq_=_if_. : @Bubble@ @Bubble@ @Bubble@ -> @EqDecl@ .
op cq_=_if_. : @Bubble@ @Bubble@ @Bubble@ -> @EqDecl@ .
*** rule declaration
*** op rl`[_`]:_=>_. : @Token@ @Bubble@ @Bubble@ -> @RlDecl@ .
op rl_=>_. : @Bubble@ @Bubble@ -> @RlDecl@ .
*** op crl`[_`]:_=>_if_. : @Token@ @Bubble@ @Bubble@ @Bubble@ -> @RlDecl@ .
op crl_=>_if_. : @Bubble@ @Bubble@ @Bubble@ -> @RlDecl@ .
*** importation declaration
ops including_. inc_. : @ModExp@ -> @ImportDecl@ .
ops extending_. ex_. : @ModExp@ -> @ImportDecl@ .
ops protecting_. pr_. : @ModExp@ -> @ImportDecl@ .
sorts @Interface@ .
subsort @Parameter@ < @List<Parameter>@ .
subsorts @Token@ < @Interface@ .
*** parameterized module interface
op _::_ : @Token@ @ModExp@ -> @Parameter@ [prec 40 gather (e &)] .
op _::_ : @Token@ @Interface@ -> @Parameter@ [prec 40 gather (e &)] .
op _`,_ : @List<Parameter>@ @List<Parameter>@ -> @List<Parameter>@ [assoc] .
op _`{_`} : @ModExp@ @List<Parameter>@ -> @Interface@ .
*** declaration list
op __ : @VarDeclList@ @VarDeclList@ -> @VarDeclList@ [assoc] .
op __ : @SDeclList@ @SDeclList@ -> @SDeclList@ [assoc] .
op __ : @FDeclList@ @FDeclList@ -> @FDeclList@ [assoc] .
*** functional and system module and theory
op fmod_is_endfm : @Interface@ @FDeclList@ -> @Module@ .
op obj_is_jbo : @Interface@ @FDeclList@ -> @Module@ .
op obj_is_endo : @Interface@ @FDeclList@ -> @Module@ .
op mod_is_endm : @Interface@ @SDeclList@ -> @Module@ .
op fth_is_endfth : @Interface@ @FDeclList@ -> @Module@ .
op th_is_endth : @Interface@ @SDeclList@ -> @Module@ .
endfm
-------------------------------------------------------------------------------
*******************************************************************************
-------------------------------------------------------------------------------
fmod O-MODS&THS is
including F&S-MODS&THS .
sorts @ClassDecl@ @AttrDecl@ @AttrDeclList@ @SubclassDecl@ @MsgDecl@
@ODeclList@ .
subsorts @SDeclList@ @MsgDecl@ @SubclassDecl@ @ClassDecl@ < @ODeclList@ .
subsort @AttrDecl@ < @AttrDeclList@ .
op __ : @ODeclList@ @ODeclList@ -> @ODeclList@ [assoc] .
*** object-oriented module and theory
op omod_is_endom : @Interface@ @ODeclList@ -> @Module@ .
op oth_is_endoth : @Interface@ @ODeclList@ -> @Module@ .
*** class declaration
op class_|_. : @Sort@ @AttrDeclList@ -> @ClassDecl@ .
op class_. : @Sort@ -> @ClassDecl@ .
op _`,_ : @AttrDeclList@ @AttrDeclList@ -> @AttrDeclList@ [assoc] .
op _:_ : @Token@ @Sort@ -> @AttrDecl@ [prec 40] .
*** subclass declaration
op subclass_. : @SubsortRel@ -> @SubclassDecl@ .
op subclasses_. : @SubsortRel@ -> @SubclassDecl@ .
*** message declaration
op msg_:_->_. : @Token@ @SortList@ @Sort@ -> @MsgDecl@ .
op msgs_:_->_. : @NeTokenList@ @SortList@ @Sort@ -> @MsgDecl@ .
op msg_:`->_. : @Token@ @Sort@ -> @MsgDecl@ .
op msgs_:`->_. : @NeTokenList@ @Sort@ -> @MsgDecl@ .
endfm
-------------------------------------------------------------------------------
*******************************************************************************
-------------------------------------------------------------------------------
fmod VIEWS is
including O-MODS&THS .
sorts @ViewDecl@ @ViewDeclList@ @View@ .
subsorts @VarDecl@ < @ViewDecl@ < @ViewDeclList@ .
subsort @VarDeclList@ < @ViewDeclList@ .
*** view maps
op op_to`term_. : @Bubble@ @Bubble@ -> @ViewDecl@ .
op op_to_. : @Token@ @Token@ -> @ViewDecl@ .
op op_:_->_to_. : @Token@ @TypeList@ @Type@ @Token@ -> @ViewDecl@ .
op op_:`->_to_. : @Token@ @Type@ @Token@ -> @ViewDecl@ .
op op_:_~>_to_. : @Token@ @TypeList@ @Type@ @Token@ -> @ViewDecl@ .
op op_:`~>_to_. : @Token@ @Type@ @Token@ -> @ViewDecl@ .
op sort_to_. : @Sort@ @Sort@ -> @ViewDecl@ .
op class_to_. : @Sort@ @Sort@ -> @ViewDecl@ .
op attr_._to_. : @Sort@ @Token@ @Token@ -> @ViewDecl@ .
op msg_to_. : @Token@ @Token@ -> @ViewDecl@ .
op msg_:_->_to_. : @Token@ @TypeList@ @Type@ @Token@ -> @ViewDecl@ .
op msg_:`->_to_. : @Token@ @Type@ @Token@ -> @ViewDecl@ .
*** view
op view_from_to_is_endv : @Interface@ @ModExp@ @ModExp@ @ViewDeclList@
-> @View@ .
op __ : @ViewDeclList@ @ViewDeclList@ -> @ViewDeclList@ [assoc] .
endfm
-------------------------------------------------------------------------------
*******************************************************************************
-------------------------------------------------------------------------------
fmod COMMANDS is
including MOD-EXPRS .
sorts @Command@ .
*** down function
op down_:_ : @ModExp@ @Command@ -> @Command@ .
*** parse commands
op parse_. : @Bubble@ -> @Command@ .
*** reduce commands
op red_. : @Bubble@ -> @Command@ .
op reduce_. : @Bubble@ -> @Command@ .
*** rewrite commands
op rew_. : @Bubble@ -> @Command@ .
op rewrite_. : @Bubble@ -> @Command@ .
*** frewrite commands
op frew_. : @Bubble@ -> @Command@ .
op frewrite_. : @Bubble@ -> @Command@ .
*** search commands
op search_=>1_. : @Bubble@ @Bubble@ -> @Command@ .
op search_=>*_. : @Bubble@ @Bubble@ -> @Command@ .
op search_=>+_. : @Bubble@ @Bubble@ -> @Command@ .
op search_=>!_. : @Bubble@ @Bubble@ -> @Command@ .
*** matching commands
op match_<=?_. : @Bubble@ @Bubble@ -> @Command@ .
op xmatch_<=?_. : @Bubble@ @Bubble@ -> @Command@ .
*** select command
op select_. : @ModExp@ -> @Command@ .
*** show commands
op show`module`. : -> @Command@ .
op show`module_. : @ModExp@ -> @Command@ .
op show`all`. : -> @Command@ .
op show`all_. : @ModExp@ -> @Command@ .
op show`vars`. : -> @Command@ .
op show`vars_. : @ModExp@ -> @Command@ .
op show`sorts`. : -> @Command@ .
op show`sorts_. : @ModExp@ -> @Command@ .
op show`ops`. : -> @Command@ .
op show`ops_. : @ModExp@ -> @Command@ .
op show`mbs`. : -> @Command@ .
op show`mbs_. : @ModExp@ -> @Command@ .
op show`eqs`. : -> @Command@ .
op show`eqs_. : @ModExp@ -> @Command@ .
op show`rls`. : -> @Command@ .
op show`rls_. : @ModExp@ -> @Command@ .
op show`view_. : @ViewExp@ -> @Command@ .
op show`modules`. : -> @Command@ .
op show`views`. : -> @Command@ .
*** set commands
op set`protect_on`. : @ModExp@ -> @Command@ .
op set`protect_off`. : @ModExp@ -> @Command@ .
op set`include_on`. : @ModExp@ -> @Command@ .
op set`include_off`. : @ModExp@ -> @Command@ .
op set`extend_on`. : @ModExp@ -> @Command@ .
op set`extend_off`. : @ModExp@ -> @Command@ .
*** miscellaneous
op load_. : @ModExp@ -> @Command@ .
endfm
-------------------------------------------------------------------------------
*******************************************************************************
-------------------------------------------------------------------------------
fmod FULL-MAUDE-SIGN is
including VIEWS .
including COMMANDS .
sort @Input@ .
subsorts @Command@ @Module@ @View@ < @Input@ .
endfm
-------------------------------------------------------------------------------
*******************************************************************************
-------------------------------------------------------------------------------
*** To parse some input using the built-in function \texttt{metaParse}, we
*** need to give the metarepresentation of the signature in which the input is
*** going to be parsed.
*** But we do not need to give the complete metarepresentation of such a
*** module. In modules including \texttt{META-LEVEL} it is possible to define
*** terms of sort \texttt{Module} that import built-in modules or any module
*** introduced at the ``object level'' of Core Maude. In this way, it is
*** possible to get the equivalent effect of having the explicit
*** metarepresentation of a module by declaring a constant and adding an
*** equation identifying such a constant with the metarepresentation of an
*** extended module that imports the original module at the object level.
*** The declaration of constructors for bubble sorts at the object level is
*** not supported in the current version of Core Maude. The \texttt{special}
*** attributes linking the constructors for the bubble sorts to the built-in
*** ones are only supported at the metalevel, that is, the declarations of the
*** constructor operators for bubble sorts have to be given in the
*** metarepresentation of a module.
*** To allow the greatest generality and flexibility in future extensions of
*** Full Maude, we have declared its signature as a module
*** \texttt{FULL-MAUDE-SIGN}. Then, in the following module
*** \texttt{META-FULL-MAUDE-SIGN} we declare a constant \texttt{GRAMMAR} of
*** sort \texttt{FModule}, and we give an equation identifying such constant
*** with the metarepresentation of a module \texttt{GRAMMAR} in which there is
*** a declaration importing \texttt{FULL-MAUDE-SIGN}. Declarations for the
*** constructors of the bubble sorts are also included in this module. Note
*** that the bubble sorts \texttt{@Token@}, \texttt{@Bubble@},
*** \texttt{@SortToken@}, and \texttt{@NeTokenList@} are declared in the
*** module \texttt{SIGN\&VIEW-EXPR}, which is imported by
*** \texttt{FULL-MAUDE-SIGN}. These sorts are used in the declarations
*** describing the syntax of the system.
-------------------------------------------------------------------------------
*******************************************************************************
-------------------------------------------------------------------------------
fmod META-FULL-MAUDE-SIGN is
including META-LEVEL .
op GRAMMAR : -> FModule [memo] .
eq GRAMMAR
= (fmod 'GRAMMAR is
including 'QID-LIST .
including 'FULL-MAUDE-SIGN .
sorts none .
none
op 'token : 'Qid -> '@Token@
[special(
(id-hook('Bubble, '1 '1)
op-hook('qidSymbol, '<Qids>, nil, 'Qid)))] .
op 'viewToken : 'Qid -> '@ViewToken@
[special(
(id-hook('Bubble, '1 '1)
op-hook('qidSymbol, '<Qids>, nil, 'Qid)))] .
op 'sortToken : 'Qid -> '@SortToken@
[special(
(id-hook('Bubble, '1 '1)
op-hook('qidSymbol, '<Qids>, nil, '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)))] .
op 'neTokenList : 'QidList -> '@NeTokenList@
[special(
(id-hook('Bubble, '1 '-1 '`( '`))
op-hook('qidListSymbol, '__, 'QidList 'QidList, 'QidList)
op-hook('qidSymbol, '<Qids>, nil, 'Qid)
id-hook('Exclude, '.)))] .
op 'bubble : 'QidList -> '@Bubble@
[special(
(id-hook('Bubble, '1 '-1 '`( '`))
op-hook('qidListSymbol, '__, 'QidList 'QidList, 'QidList)
op-hook('qidSymbol, '<Qids>, nil, 'Qid)))] .
none
none
endfm) .
endfm
-------------------------------------------------------------------------------
*******************************************************************************
-------------------------------------------------------------------------------
*** The \texttt{GRAMMAR} module will be used in calls to the \texttt{metaParse}
*** function in order to get the input parsed in this signature. Note that
*** this module is not the data type in which we shall represent the inputs.
*** From the call to \texttt{metaParse} we shall get a term representing the
*** parse tree of the input. This term will then be transformed into terms of
*** other appropriate data types if necessary.
*** Future extensions to Full Maude will require extending the signature as
*** well. The addition of new commands, new module expressions, or additions
*** of any other kind will require adding new declarations to the present Full
*** Maude signature and defining the corresponding extensions to the data
*** types and functions to deal with the new cases introduced by the
*** extensions.
*******
******* ERROR HANDLING, by Peter Olveczky
*******
*** The following module defines a function which prints up to n characters
*** of a bubble, followed by the usual arrow <---*HERE* which points to the
*** erroneous token:
-------------------------------------------------------------------------------
*******************************************************************************
-------------------------------------------------------------------------------
fmod PRINT-SYNTAX-ERROR is
protecting META-LEVEL .
protecting INT .
var QIL : QidList .
var Q : Qid .
var N : Nat .
vars RP RP' : ResultPair .
var RP? : [ResultPair?] .
op printN : Nat QidList -> QidList . *** first N qid's in a qidList
eq printN(N, nil) = nil .
eq printN(0, QIL) = nil .
eq printN(s N, Q QIL) = Q printN(N, QIL) .
op removeFront : Nat QidList -> QidList . *** removes first N qid's
eq removeFront(N, nil) = nil .
eq removeFront(0, QIL) = QIL .
eq removeFront(s N, Q QIL) = removeFront(N, QIL) .
op printSyntaxError : [ResultPair?] QidList -> QidList .
eq printSyntaxError(noParse(N), QIL)
= '\r 'Parse 'error 'in '\o '\s printN(N + 1, QIL) '\r '<---*HERE* '\o .
eq printSyntaxError(ambiguity(RP, RP'), QIL)
= '\r 'Ambiguous 'parsing 'for '\o '\s QIL '\o .
eq printSyntaxError(RP?, QIL) = QIL [owise] .
endfm
-------------------------------------------------------------------------------
*******************************************************************************
-------------------------------------------------------------------------------
***
*** The Abstract Data Type \texttt{Module}
***
-------------------------------------------------------------------------------
*******************************************************************************
-------------------------------------------------------------------------------
*** In this section we present the abstract data type \texttt{Module}, which
*** can be seen as an extension of the predefined sort \texttt{Module} in
*** several ways. There are constructors for functional, system, and object-
*** oriented modules and theories, which can be parameterized and can import
*** module expressions. There can also be parameterized sorts in Full Maude
*** modules, and therefore, the constructors for the different declarations
*** that can appear in a module have to be appropriately extended.
*** The section is structured as follows. After introducing some modules
*** defining some functions on the predefined sorts \texttt{Bool} and
*** \texttt{QidList} in Section~\ref{BOOL-QID-LIST}, we present in
*** Sections~\ref{EXT-SORT} and~\ref{EXT-DECL} the data types for extended
*** sorts and extended declarations. In Section~\ref{mod-exp-mod-id} we
*** introduce module expressions and module names, and in
*** Section~\ref{unitADT} the abstract data type \texttt{Module} itself.
***
*** Extension \texttt{QID-LIST}
***
*** The conversion of lists of quoted identifiers into single quoted
*** identifiers by concatenating them is heavily used in the coming modules.
*** This is the task of the \texttt{} function, which is
*** introduced in the following module \texttt{EXT-QID-LIST} extending the
*** predefined module \texttt{QID-LIST}.
-------------------------------------------------------------------------------
*******************************************************************************
-------------------------------------------------------------------------------
fmod EXT-QID-LIST is
pr QID-LIST .
op qidList2Qid : QidList -> Qid .
var QI : Qid .
var QIL : QidList .
var St : String .
var N : Nat .
var F : FindResult .
eq qidList2Qid(('\s QIL)) = qid(" " + string(qidList2Qid(QIL))) .
eq qidList2Qid((QI QIL))
= qid(string(QI) + " " + string(qidList2Qid(QIL)))
[owise] .
eq qidList2Qid(nil) = qid("") .
op string2qidList : String -> QidList .
eq string2qidList("") = nil .
ceq string2qidList(St)
= if F == notFound
then qid(substr(St, findNonSpace(St), length(St)))
else qid(substr(St, findNonSpace(St), F + 1))
string2qidList(substr(St, F + 1, length(St)))
fi
if F := find(substr(St, findNonSpace(St), length(St)), " ", 0)
[owise] .
op findNonSpace : String -> Nat .
op findNonSpace : String Nat -> Nat .
---- returns the length of the string if not found
eq findNonSpace(St) = findNonSpace(St, 0) .
eq findNonSpace(St, N)
= if substr(St, N, 1) =/= "" and substr(St, N, 1) == " "
then findNonSpace(St, N + 1)
else N
fi .
endfm
-------------------------------------------------------------------------------
*******************************************************************************
-------------------------------------------------------------------------------
*** 3.2 View Expressions and Extended Sorts
*** To allow the use of parameterized sorts, or sorts qualified by the view
*** expression with which the parameterized module in which the given sorts
*** appear is instantiated, we add the sort Sort of ``extended sorts'' as a
*** supersort of the predefined sort Sort. View expressions and extended
*** sorts are introduced in the following modules.
*** 3.2.1 View Expressions
*** A view expression is given by a single quoted identifier, by a sequence of
*** view expressions (at the user level, separated by commas), or by the
*** composition of view expressions. In the current version, the composition
*** of view expressions is only used internally; we plan to make it available
*** to the user with syntax \verb~_;_~ in the future. View expressions are
*** used in the instantiation of parameterized modules and in parameterized
*** sorts. We plan to support parameterized views in the future as well. We
*** use operators \verb~_|_~ and \verb~_;;_~ to represent, respectively,
*** sequences and composition of view expressions.
-------------------------------------------------------------------------------
*******************************************************************************
-------------------------------------------------------------------------------
fmod VIEW-EXPR is
pr META-MODULE .
sort ViewExp .
subsorts Sort < ViewExp < ModuleExpression NeParameterList .
op mtViewExp : -> ViewExp .
op _{_} : Sort ParameterList -> ViewExp [ctor prec 37].
op _;;_ : ViewExp ViewExp -> ViewExp
[assoc id: mtViewExp] . *** view composition _;_
endfm
-------------------------------------------------------------------------------
*******************************************************************************
-------------------------------------------------------------------------------
*** Since the Core Maude engine does not know about view expressions, or, as
*** we shall see, about extended sorts, extended module expressions, extended
*** modules, and other declarations that we introduce, to be able to use them
*** with built-in functions such as \texttt{sameComponent},
*** \texttt{leastSort}, \texttt{metaReduce}, etc., we shall have to convert
*** them into terms which only use the built-in constructors. Thus, for
*** example, view expressions in sort \texttt{ViewExp} will be converted
*** into quoted identifiers of sort \texttt{Qid} by means of function
*** \texttt{parameter2Qid}, or, similarly, elements of sorts \texttt{Sort},
*** \texttt{SortList}, and \texttt{SortSet} are transformed into elements
*** of sorts \texttt{Qid}, \texttt{QidList}, and \texttt{QidSet},
*** respectively, with functions \texttt{eSortToQid} defined on the
*** appropriate sorts.
-------------------------------------------------------------------------------
*******************************************************************************
-------------------------------------------------------------------------------
fmod VIEW-EXPR-TO-QID is
pr VIEW-EXPR .
pr EXT-QID-LIST .
op viewExp2Qid : ViewExp -> Qid .
op parameterList2Qid : ParameterList -> Qid .
op viewExp2QidList : ViewExp -> QidList .
op parameterList2QidList : ParameterList -> QidList .
var V : Sort .
var QI : Qid .
var QIL : QidList .
var P : ViewExp .
var PL : NeParameterList .
vars VE VE' : ViewExp .
eq parameterList2QidList(P) = viewExp2QidList(P) .
ceq parameterList2QidList((P, PL))
= (if QI == '`) then QIL QI '\s else QIL QI fi)
'`, parameterList2QidList(PL)
if QIL QI := viewExp2QidList(P).
eq viewExp2QidList(V{PL})
= (viewExp2QidList(V) '`{ parameterList2QidList(PL) '`}) .
ceq viewExp2QidList(VE ;; VE')
= (viewExp2QidList(VE) '; viewExp2QidList(VE'))
if VE =/= mtViewExp /\ VE' =/= mtViewExp .
eq viewExp2QidList(V) = V .
eq parameterList2Qid(P) = viewExp2Qid(P) .
eq parameterList2Qid((P, PL))
= qid(string(viewExp2Qid(P)) + ", " + string(parameterList2Qid(PL))) .
eq viewExp2Qid(VE) = qidList2Qid(viewExp2QidList(VE)) .
endfm
-------------------------------------------------------------------------------
*******************************************************************************
-------------------------------------------------------------------------------
***
*** Parameterized Sorts
***
*** In addition to the \texttt{Sort} sort, in the following module
*** \texttt{EXT-SORT} we also define sorts \texttt{SortList} and
*** \texttt{SortSet}.
*** The operator \texttt{eSort} is declared to be a constructor for extended
*** sorts.
*** As for lists and sTS of quoted identifiers, we declare \verb~__~ and
*** \verb~_;_~ as constructors for sorts \texttt{SortList} and
*** \texttt{SortList}, and \texttt{SortSet}, respectively.
-------------------------------------------------------------------------------
*******************************************************************************
-------------------------------------------------------------------------------
fmod EXT-SORT is
pr META-LEVEL .
pr EXT-BOOL .
pr VIEW-EXPR .
*** We define operations extending the built-in functions \texttt{sameKind}
*** and \texttt{leastSort}, respectively, to lists of sorts and
*** to lists of extended terms. The function \texttt{sameKind} takes
*** a module and two lists of extended sorts as arguments, and returns
*** \texttt{true} if the $i$-th elements of both lists are in the same
*** connected component of sorts. This function will be used, for example, to
*** check whether two operators are in the same family of subsort overloaded
*** operators. \texttt{leastSort} returns a list of sorts where the $i$-th
*** element of the list is the least sort, computed by the homonymous built-in
*** function, of the $i$-th term in the list of terms given as argument.
*** Moreover, we define a function \verb~_in_~ to check whether an
*** extended sort is in a given set of extended sorts. Note that before
*** calling the built-in function \texttt{sameComponent}, extended sorts of
*** sort \texttt{Sort} have to be `desugared' into sorts of sort
*** \texttt{Sort} as defined in the predefined \texttt{META-LEVEL} module.
*** This conversion is done by the \texttt{eTypeToType} function. Basically,
*** user-defined sorts are converted into quoted identifiers by concatenating
*** the list of identifiers composing the name of the sort. For example, sorts
*** \texttt{'Nat} and \texttt{'List['Nat]} are converted, respectively, into
*** \texttt{'Nat} and \texttt{'List`[Nat`]}. Error
*** sorts~\cite{ClavelDuranEkerLincolnMarti-OlietMeseguerQuesada99} are left
*** as such.
vars Tp Tp' Tp'' Tp''' : Type .
vars TpL TpL' : TypeList .
op sameKind : Module TypeList TypeList -> Bool [ditto] .
eq sameKind(M:Module, (Tp Tp' TpL), (Tp'' Tp''' TpL'))
= sameKind(M:Module, Tp, Tp'')
and-then sameKind(M:Module, Tp' TpL, Tp''' TpL') .
eq sameKind(M:Module, nil, nil) = true .
eq sameKind(M:Module, TpL, TpL) = false [owise] .
eq sameKind(M:Module, cc(S:Sort ; SS:SortSet), S':Sort)
= sameKind(M:Module, S:Sort, S':Sort) .
eq sameKind(M:Module, S:Sort, cc(S':Sort ; SS:SortSet))
= sameKind(M:Module, S:Sort, S':Sort) .
eq sameKind(M:Module, cc(S:Sort ; SS:SortSet), cc(S':Sort ; SS':SortSet))
= sameKind(M:Module, S:Sort, S':Sort) .
op leastSort : Module TermList ~> TypeList [ditto] .
eq leastSort(M:Module, (T:Term, TL:TermList))
= (leastSort(M:Module, T:Term) leastSort(M:Module, TL:TermList)) .
eq leastSort(M:Module, T:Term) = qidError('Error: 'non-valid 'module) .
op qidError : QidList -> [Sort] .
op stringError : QidList -> [String] .
eq string(qidError(QIL)) = stringError(QIL) .
eq qid(stringError(QIL)) = qidError(QIL) .
eq stringError(QIL) + St:String = stringError(QIL) .
op getMsg : [Sort] -> QidList .
eq getMsg(qidError(QIL:QidList)) = QIL:QidList .
op kind : TypeList -> Type .
eq kind(S:Sort TL:TypeList)
= qid("[" + string(S:Sort) + "]") kind(TL:TypeList) .
eq kind(K:Kind TL:TypeList) = K:Kind kind(TL:TypeList) .
eq kind(nil) = nil .
op kind : SortSet -> Type .
eq kind(S:Sort ; SS:SortSet) = qid("[" + string(S:Sort) + "]") .
op cc : SortSet -> Type .
op getSort : Kind -> Sort .
eq getSort(K:Kind)
= if findOut(string(K:Kind), "`,", "{", "}", 0) == notFound
then qid(substr(string(K:Kind),
2,
sd(length(string(K:Kind)), 4)))
else qid(substr(string(K:Kind),
2,
sd(findOut(string(K:Kind), "`,", "{", "}", 0), 2)))
fi .
op getSorts : Kind -> SortSet .
eq getSorts(K:Kind)
= if findOut(string(K:Kind), "`,", "{", "}", 0) == notFound
then qid(substr(string(K:Kind),
2,
sd(length(string(K:Kind)), 4)))
else qid(substr(string(K:Kind),
2,
sd(findOut(string(K:Kind), "`,", "{", "}", 0), 2)))
;
getSorts(qid("[" + substr(string(K:Kind),
sd(findOut(string(K:Kind), "`,", "{", "}", 0), 1),
length(string(K:Kind)))))
fi .
---- name of a sort (the name of S{P1, ..., Pn} is S)
op getName : Sort -> Qid .
eq getName(S:Sort)
= if findOpening(string(S:Sort), "{", "}", sd(length(string(S:Sort)), 2))
== notFound
then S:Sort
else qid(substr(string(S:Sort),
0,
findOpening(string(S:Sort),
"{", "}",
sd(length(string(S:Sort)), 2))))
fi .
---- parameters of a sort (the parameters of S{P1, ..., Pn} are P1 ... Pn)
op getPars : Sort -> ParameterList .
op getParsAux : String Nat Nat -> ParameterList .
eq getPars(S:Sort)
= if findOpening(string(S:Sort), "{", "}", sd(length(string(S:Sort)), 2))
== notFound
then empty
else getParsAux(string(S:Sort),
findOpening(string(S:Sort),
"{", "}", sd(length(string(S:Sort)), 2)) + 1,
length(string(S:Sort)))
fi .
var St Pattern OpenPar ClosingPar : String .
vars L R N OpenPars ClosingPars : Nat .
eq getParsAux(St, L, R)
= if findOut(St, ",", "{", "}", L) == notFound
then qid(substr(St, L, sd(findClosing(St, "{", "}", L), L)))
else (qid(substr(St, L, sd(findOut(St, ",", "{", "}", L), L))),
getParsAux(St, findOut(St, ",", "{", "}", L) + 1, R))
fi .
---- finds a pattern out of balanced parentheses
---- findOut("S{P1, P2{P21, P22}, P3}", ",", "{", "}", 6) returns 18, not 12
op findOut : String String String String Nat -> FindResult .
op findOut : String String String String Nat Nat -> FindResult .
eq findOut(St, Pattern, OpenPar, ClosingPar, N)