-
Notifications
You must be signed in to change notification settings - Fork 0
/
DeltaCCS.maude
977 lines (773 loc) · 33.8 KB
/
DeltaCCS.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
***(
This file is part of the Maude 2 interpreter.
Copyright 1997-2006 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 of 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 FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
)
***
*** Maude LTL satisfiability solver and model checker.
*** Version 2.3.
***
fmod LTL is
protecting BOOL .
sort Formula .
*** primitive LTL operators
ops True False : -> Formula [ctor format (g o)] .
op ~_ : Formula -> Formula [ctor prec 53 format (r o d)] .
op _/\_ : Formula Formula -> Formula [comm ctor gather (E e) prec 55 format (d r o d)] .
op _\/_ : Formula Formula -> Formula [comm ctor gather (E e) prec 59 format (d r o d)] .
op O_ : Formula -> Formula [ctor prec 53 format (r o d)] .
op _U_ : Formula Formula -> Formula [ctor prec 63 format (d r o d)] .
op _R_ : Formula Formula -> Formula [ctor prec 63 format (d r o d)] .
*** defined LTL operators
op _->_ : Formula Formula -> Formula [gather (e E) prec 65 format (d r o d)] .
op _<->_ : Formula Formula -> Formula [prec 65 format (d r o d)] .
op <>_ : Formula -> Formula [prec 53 format (r o d)] .
op []_ : Formula -> Formula [prec 53 format (r d o d)] .
op _W_ : Formula Formula -> Formula [prec 63 format (d r o d)] .
op _|->_ : Formula Formula -> Formula [prec 63 format (d r o d)] . *** leads-to
op _=>_ : Formula Formula -> Formula [gather (e E) prec 65 format (d r o d)] .
op _<=>_ : Formula Formula -> Formula [prec 65 format (d r o d)] .
vars f g : Formula .
eq f -> g = ~ f \/ g .
eq f <-> g = (f -> g) /\ (g -> f) .
eq <> f = True U f .
eq [] f = False R f .
eq f W g = (f U g) \/ [] f .
eq f |-> g = [](f -> (<> g)) .
eq f => g = [] (f -> g) .
eq f <=> g = [] (f <-> g) .
*** negative normal form
eq ~ True = False .
eq ~ False = True .
eq ~ ~ f = f .
eq ~ (f \/ g) = ~ f /\ ~ g .
eq ~ (f /\ g) = ~ f \/ ~ g .
eq ~ O f = O ~ f .
eq ~(f U g) = (~ f) R (~ g) .
eq ~(f R g) = (~ f) U (~ g) .
endfm
fmod LTL-SIMPLIFIER is
including LTL .
*** The simplifier is based on:
*** Kousha Etessami and Gerard J. Holzman,
*** "Optimizing Buchi Automata", p153-167, CONCUR 2000, LNCS 1877.
*** We use the Maude sort system to do much of the work.
sorts TrueFormula FalseFormula PureFormula PE-Formula PU-Formula .
subsort TrueFormula FalseFormula < PureFormula <
PE-Formula PU-Formula < Formula .
op True : -> TrueFormula [ctor ditto] .
op False : -> FalseFormula [ctor ditto] .
op _/\_ : PE-Formula PE-Formula -> PE-Formula [ctor ditto] .
op _/\_ : PU-Formula PU-Formula -> PU-Formula [ctor ditto] .
op _/\_ : PureFormula PureFormula -> PureFormula [ctor ditto] .
op _\/_ : PE-Formula PE-Formula -> PE-Formula [ctor ditto] .
op _\/_ : PU-Formula PU-Formula -> PU-Formula [ctor ditto] .
op _\/_ : PureFormula PureFormula -> PureFormula [ctor ditto] .
op O_ : PE-Formula -> PE-Formula [ctor ditto] .
op O_ : PU-Formula -> PU-Formula [ctor ditto] .
op O_ : PureFormula -> PureFormula [ctor ditto] .
op _U_ : PE-Formula PE-Formula -> PE-Formula [ctor ditto] .
op _U_ : PU-Formula PU-Formula -> PU-Formula [ctor ditto] .
op _U_ : PureFormula PureFormula -> PureFormula [ctor ditto] .
op _U_ : TrueFormula Formula -> PE-Formula [ctor ditto] .
op _U_ : TrueFormula PU-Formula -> PureFormula [ctor ditto] .
op _R_ : PE-Formula PE-Formula -> PE-Formula [ctor ditto] .
op _R_ : PU-Formula PU-Formula -> PU-Formula [ctor ditto] .
op _R_ : PureFormula PureFormula -> PureFormula [ctor ditto] .
op _R_ : FalseFormula Formula -> PU-Formula [ctor ditto] .
op _R_ : FalseFormula PE-Formula -> PureFormula [ctor ditto] .
vars p q r s : Formula .
var pe : PE-Formula .
var pu : PU-Formula .
var pr : PureFormula .
*** Rules 1, 2 and 3; each with its dual.
eq (p U r) /\ (q U r) = (p /\ q) U r .
eq (p R r) \/ (q R r) = (p \/ q) R r .
eq (p U q) \/ (p U r) = p U (q \/ r) .
eq (p R q) /\ (p R r) = p R (q /\ r) .
eq True U (p U q) = True U q .
eq False R (p R q) = False R q .
*** Rules 4 and 5 do most of the work.
eq p U pe = pe .
eq p R pu = pu .
*** An extra rule in the same style.
eq O pr = pr .
*** We also use the rules from:
*** Fabio Somenzi and Roderick Bloem,
*** "Efficient Buchi Automata from LTL Formulae",
*** p247-263, CAV 2000, LNCS 1633.
*** that are not subsumed by the previous system.
*** Four pairs of duals.
eq O p /\ O q = O (p /\ q) .
eq O p \/ O q = O (p \/ q) .
eq O p U O q = O (p U q) .
eq O p R O q = O (p R q) .
eq True U O p = O (True U p) .
eq False R O p = O (False R p) .
eq (False R (True U p)) \/ (False R (True U q)) = False R (True U (p \/ q)) .
eq (True U (False R p)) /\ (True U (False R q)) = True U (False R (p /\ q)) .
*** <= relation on formula
op _<=_ : Formula Formula -> Bool [prec 75] .
eq p <= p = true .
eq False <= p = true .
eq p <= True = true .
ceq p <= (q /\ r) = true if (p <= q) /\ (p <= r) .
ceq p <= (q \/ r) = true if p <= q .
ceq (p /\ q) <= r = true if p <= r .
ceq (p \/ q) <= r = true if (p <= r) /\ (q <= r) .
ceq p <= (q U r) = true if p <= r .
ceq (p R q) <= r = true if q <= r .
ceq (p U q) <= r = true if (p <= r) /\ (q <= r) .
ceq p <= (q R r) = true if (p <= q) /\ (p <= r) .
ceq (p U q) <= (r U s) = true if (p <= r) /\ (q <= s) .
ceq (p R q) <= (r R s) = true if (p <= r) /\ (q <= s) .
*** condition rules depending on <= relation
ceq p /\ q = p if p <= q .
ceq p \/ q = q if p <= q .
ceq p /\ q = False if p <= ~ q .
ceq p \/ q = True if ~ p <= q .
ceq p U q = q if p <= q .
ceq p R q = q if q <= p .
ceq p U q = True U q if p =/= True /\ ~ q <= p .
ceq p R q = False R q if p =/= False /\ q <= ~ p .
ceq p U (q U r) = q U r if p <= q .
ceq p R (q R r) = q R r if q <= p .
endfm
fmod SAT-SOLVER is
protecting LTL .
*** formula lists and results
sorts FormulaList SatSolveResult TautCheckResult .
subsort Formula < FormulaList .
subsort Bool < SatSolveResult TautCheckResult .
op nil : -> FormulaList [ctor] .
op _;_ : FormulaList FormulaList -> FormulaList [ctor assoc id: nil] .
op model : FormulaList FormulaList -> SatSolveResult [ctor] .
op satSolve : Formula ~> SatSolveResult
[special (
id-hook SatSolverSymbol
op-hook trueSymbol (True : ~> Formula)
op-hook falseSymbol (False : ~> Formula)
op-hook notSymbol (~_ : Formula ~> Formula)
op-hook nextSymbol (O_ : Formula ~> Formula)
op-hook andSymbol (_/\_ : Formula Formula ~> Formula)
op-hook orSymbol (_\/_ : Formula Formula ~> Formula)
op-hook untilSymbol (_U_ : Formula Formula ~> Formula)
op-hook releaseSymbol (_R_ : Formula Formula ~> Formula)
op-hook formulaListSymbol
(_;_ : FormulaList FormulaList ~> FormulaList)
op-hook nilFormulaListSymbol (nil : ~> FormulaList)
op-hook modelSymbol
(model : FormulaList FormulaList ~> SatSolveResult)
term-hook falseTerm (false)
)] .
op counterexample : FormulaList FormulaList -> TautCheckResult [ctor] .
op tautCheck : Formula ~> TautCheckResult .
op $invert : SatSolveResult -> TautCheckResult .
var F : Formula .
vars L C : FormulaList .
eq tautCheck(F) = $invert(satSolve(~ F)) .
eq $invert(false) = true .
eq $invert(model(L, C)) = counterexample(L, C) .
endfm
fmod SATISFACTION is
protecting BOOL .
sorts State Prop .
op _|=_ : State Prop -> Bool [frozen] .
endfm
fmod MODEL-CHECKER is
protecting QID .
including SATISFACTION .
including LTL .
subsort Prop < Formula .
*** transitions and results
sorts RuleName Transition TransitionList ModelCheckResult .
subsort Qid < RuleName .
subsort Transition < TransitionList .
subsort Bool < ModelCheckResult .
ops unlabeled deadlock : -> RuleName .
op {_,_} : State RuleName -> Transition [ctor] .
op nil : -> TransitionList [ctor] .
op __ : TransitionList TransitionList -> TransitionList [ctor assoc id: nil] .
op counterexample : TransitionList TransitionList -> ModelCheckResult [ctor] .
op modelCheck : State Formula ~> ModelCheckResult
[special (
id-hook ModelCheckerSymbol
op-hook trueSymbol (True : ~> Formula)
op-hook falseSymbol (False : ~> Formula)
op-hook notSymbol (~_ : Formula ~> Formula)
op-hook nextSymbol (O_ : Formula ~> Formula)
op-hook andSymbol (_/\_ : Formula Formula ~> Formula)
op-hook orSymbol (_\/_ : Formula Formula ~> Formula)
op-hook untilSymbol (_U_ : Formula Formula ~> Formula)
op-hook releaseSymbol (_R_ : Formula Formula ~> Formula)
op-hook satisfiesSymbol (_|=_ : State Formula ~> Bool)
op-hook qidSymbol (<Qids> : ~> Qid)
op-hook unlabeledSymbol (unlabeled : ~> RuleName)
op-hook deadlockSymbol (deadlock : ~> RuleName)
op-hook transitionSymbol ({_,_} : State RuleName ~> Transition)
op-hook transitionListSymbol
(__ : TransitionList TransitionList ~> TransitionList)
op-hook nilTransitionListSymbol (nil : ~> TransitionList)
op-hook counterexampleSymbol
(counterexample : TransitionList TransitionList ~> ModelCheckResult)
term-hook trueTerm (true)
)] .
endfm
fmod SAT-SOLVER-TEST is
extending SAT-SOLVER .
extending LTL .
var F : Formula .
vars L C : FormulaList .
ops AutomaticPowerWindow CentralLockingSystem RemoteControlKey AutomaticLocking SafetyFunction ControlAutomaticPowerWindow a b c d p q r : -> Formula .
---eq model(L True) = true .
op $sat : SatSolveResult -> Bool .
eq $sat(model(L , True)) = true .
op sat : Formula -> Bool .
eq sat(F) = $sat(satSolve(F)) .
endfm
*** Implementation based on the CCS Implementation from Verdejo and Marti-Oliet
fmod CCS-SYNTAX is inc QID .
sorts Label Act ProcessId Process .
subsorts Qid < Label < Act .
subsorts Qid < ProcessId < Process .
---subsorts Qid < DeltaId < Delta .
---subsorts Qid < DeltaId .
op ~_ : Label -> Label .
eq ~ ~ L:Label = L:Label .
op tau : -> Act .
op 0 : -> Process .
op _._ : Act Process -> Process [frozen prec 25] .
op _+_ : Process Process -> Process [frozen assoc comm prec 35] .
op _|_ : Process Process -> Process [frozen assoc comm prec 30] .
op _[_/_] : Process Label Label -> Process [frozen prec 20] .
op _\_ : Process Label -> Process [frozen prec 20] .
endfm
fmod CCS-CONTEXT is
inc CCS-SYNTAX .
sorts Process? Context .
subsort Process < Process? .
op _=def_ : ProcessId Process -> Context [prec 40] .
op cnil : -> Context .
op _&_ : Context Context -> Context
[assoc comm id: cnil prec 42] .
op _definedIn_ : ProcessId Context -> Bool .
op def : ProcessId Context -> Process? .
op not-defined : -> Process? .
op _isUniqueIn_ : ProcessId Context -> Bool .
op context : -> Context .
vars X X' : ProcessId .
var P : Process .
vars C C' : Context .
eq X definedIn cnil = false .
eq X definedIn (X' =def P & C') = (X == X') or (X definedIn C') .
eq def(X, cnil) = not-defined .
eq def(X, (X' =def P) & C') = if X == X' then P
else def(X, C') fi .
eq X isUniqueIn cnil = true .
eq X isUniqueIn (X' =def P & C') = if X == X' then not (X definedIn C')
else (X isUniqueIn C') fi .
endfm
fmod DeltaCCS-Set is
pr CCS-CONTEXT .
pr LTL .
pr SAT-SOLVER .
sorts NeDeltaSet DeltaSet DeltaId Delta Product .
subsort Delta < NeDeltaSet < DeltaSet .
subsort Qid < DeltaId .
subsort Product < Formula .
var D : Delta .
var N : NeDeltaSet .
vars A S S’ : DeltaSet .
vars B B' F F' : Formula .
var FL : FormulaList .
vars I I' : DeltaId .
vars X X' Y Y' : ProcessId .
vars P Q : Process .
var a : Act .
var L : Label .
var C : Nat .
var p : Product .
--- delta operators
op _=ddef(_,_,_) : DeltaId ProcessId Formula ProcessId -> Delta .
op getSourceId : Delta -> ProcessId .
eq getSourceId( I =ddef( X , B , Y ) ) = X .
op getCondition : Delta -> Formula .
eq getCondition( I =ddef( X , B , Y ) ) = B .
op getTargetId : Delta -> ProcessId .
eq getTargetId( I =ddef( X , B , Y ) ) = Y .
op getDeltaId : Delta -> DeltaId .
eq getDeltaId( I =ddef( X , B , Y ) ) = I .
--- product configuration
op prod : -> Product .
eq prod = True .
--- delta application
op $apply : Delta Process -> Process .
eq $apply (D , 0) = 0 .
eq $apply (D , X) = if ( getSourceId(D) == X )
then getTargetId(D)
else X
fi .
eq $apply (D , a . P) = a . ($apply (D , P)) .
eq $apply (D , P + Q) = ($apply (D , P)) + ( $apply (D , Q) ) .
eq $apply (D , P | Q) = ($apply (D , P)) | ($apply (D , Q)) .
eq $apply (D , P \ L) = ( $apply (D , P) ) \ L .
op apply_to_ : Delta Process -> Process .
ceq apply D to P = $apply(D, P)
if not(sat(prod /\ ~(getCondition(D)))) .
eq apply D to P = P [owise] .
op applySet_to_ : DeltaSet Process -> Process .
eq applySet empty to P = P .
eq applySet ( D & S ) to P = applySet S to (apply D to P) .
--- applicable deltas
---op _isApplicableIn_ : Delta Product -> Bool .
---eq D isApplicableIn p = not(sat(p /\ ~(getCondition(D)))) .
--- standard operators for sets
op empty : -> DeltaSet [ctor] .
op _&_ : DeltaSet DeltaSet -> DeltaSet [ctor assoc comm id: empty prec 121 format (d r os d)] .
op _&_ : NeDeltaSet DeltaSet -> NeDeltaSet [ctor ditto] .
eq N & N = N .
op union : DeltaSet DeltaSet -> DeltaSet .
op union : NeDeltaSet DeltaSet -> NeDeltaSet .
op union : DeltaSet NeDeltaSet -> NeDeltaSet .
eq union(S, S’) = S & S’ .
op insert : Delta DeltaSet -> DeltaSet .
eq insert(D, S) = D & S .
op _in_ : Delta DeltaSet -> Bool .
eq D in (D & S) = true .
eq D in S = false [owise] .
op cardinality : DeltaSet -> Nat .
op cardinality : NeDeltaSet -> NzNat .
eq cardinality(S) = $card(S, 0) .
op $card : DeltaSet Nat -> Nat .
eq $card(empty, C) = C .
eq $card((N & N & S), C) = $card((N & S), C) .
eq $card((D & S), C) = $card(S, C + 1) [owise] .
op _difference_ : DeltaSet DeltaSet -> DeltaSet [gather (E e)].
eq S difference empty = S .
eq S difference N = $diff(S, N, empty) .
op $diff : DeltaSet DeltaSet DeltaSet -> DeltaSet .
eq $diff(empty, S’, A) = A .
eq $diff((D & S), S’, A) = $diff(S, S’, if D in S’ then A else D & A fi) .
--- special operators for delta sets
op getDeltasFor : ProcessId DeltaSet -> DeltaSet .
eq getDeltasFor(X, empty) = empty .
eq getDeltasFor(X, (D & S)) = if (getSourceId(D) == X) and (sat(fm /\ S /\ D)) then $getDeltasFor(X, S, D) else getDeltasFor(X, S) fi .
op $getDeltasFor : ProcessId DeltaSet DeltaSet -> DeltaSet .
eq $getDeltasFor(X, empty , A) = A .
eq $getDeltasFor(X, (D & S) , A) = if (getSourceId(D) == X) and (sat(fm /\ S /\ D)) then $getDeltasFor(X, S , (A & D)) else $getDeltasFor(X, S, A) fi .
op deltaSet : -> DeltaSet .
--- feature model operator
op fm : -> Formula .
--- operators for application condition
op $sat : SatSolveResult -> Bool .
eq $sat(model(FL , True)) = true .
eq $sat(false) = false .
op sat : Formula -> Bool .
eq sat(F) = $sat(satSolve(F)) .
op _/\_ : Formula DeltaSet -> Formula .
eq F /\ empty = F .
eq F /\ (D & S) = F /\ getCondition(D) /\ S .
op ~_ : DeltaSet -> Formula .
eq ~ (empty) = True .
eq ~ (D & S) = ~ getCondition(D) /\ ~ (S) .
endfm
fmod DeltaCCS-Syntax is
pr DeltaCCS-Set .
sorts DeltaCCSProcess .
var D : Delta .
var N : NeDeltaSet .
vars A S S’ : DeltaSet .
var P : Process .
var Z : DeltaCCSProcess .
op (_,_) : Process DeltaSet -> DeltaCCSProcess .
op _+_ : DeltaCCSProcess DeltaCCSProcess -> DeltaCCSProcess [frozen assoc comm prec 35] .
op getChoiceProcessForDeltas : DeltaSet DeltaSet -> DeltaCCSProcess .
eq getChoiceProcessForDeltas(empty , A) = ( 0 , A ) .
eq getChoiceProcessForDeltas( (D & S) , A) = if (getDeltasFor(getSourceId(D) , (A difference D)) == empty)
then $getChoiceProcessForDeltas( S , A , ( getTargetId(D) , (A & D) ) )
else getChoiceProcessForDeltas(S , A) fi .
op $getChoiceProcessForDeltas : DeltaSet DeltaSet DeltaCCSProcess -> DeltaCCSProcess .
eq $getChoiceProcessForDeltas(empty , A , Z) = Z .
eq $getChoiceProcessForDeltas( (D & S) , A , Z ) = if (getDeltasFor(getSourceId(D) , (A difference D)) == empty)
then $getChoiceProcessForDeltas( S , A , ( Z + ( getTargetId(D) , (A & D) ) ) )
else $getChoiceProcessForDeltas( S , A , Z ) fi .
op dProcess : -> DeltaCCSProcess .
endfm
--- DeltaCCS transitions
mod DeltaCCS is
pr DeltaCCS-Syntax .
sorts ActDProcess . ---MachineInt .
subsort DeltaCCSProcess < ActDProcess .
op {_}_ : Act ActDProcess -> ActDProcess [frozen] .
*** {A}P means that the process P has performed the action A
var D : Delta .
vars S S' S'' : DeltaSet .
vars L M : Label .
var A : Act .
***var B : Bool .
vars P P' Q Q' R : Process .
vars K K' X X' : ProcessId .
vars I I' : DeltaId .
var ADP : ActDProcess .
---var N : MachineInt .
vars U U' V V' : DeltaCCSProcess .
var FL : FormulaList .
op getDeltaSet : ActDProcess -> DeltaSet .
eq getDeltaSet ( {A}(P , S) ) = S .
op getDeltaSet : DeltaCCSProcess -> DeltaSet .
eq getDeltaSet ( (P , S) ) = S .
op checkVariant : ActDProcess -> Bool .
eq checkVariant ( {A}(P , S) ) = checkVariant( (P , S) ) .
op checkVariant : DeltaCCSProcess -> Bool .
eq checkVariant( (P , S) ) = sat( fm /\ S /\ ~ (deltaSet difference S) ) .
*** Prefix
rl [pref] : (A . P , S) => {A}(P , S) .
*** Summation
crl [sum] : (P + Q , S) => {A}(P' , S') if (P , S) => {A}(P' , S' ) .
*** Composition
crl [par] : (P | Q , S) => {A}((P' | Q) , S' ) if (P , S) => {A}(P' , S' ) .
crl [par] : (P | Q , S) => {tau}((P' | Q') , (S & S' & S'' ) ) if (P , S) => {A}(P' , (S & S' )) /\ (Q , S) => {~ A}(Q' , (S & S'' )) .
*** Restriction
crl [res] : (P \ L , S) => {A}((P' \ L) , S') if (P , S) => {A}(P' , S') /\ A =/= L /\ A =/= ~ L .
*** Relabelling
crl [rel] : (P[M / L] , S) => {M}((P' [M / L]) , S' ) if (P , S) => {L}(P' , S' ) .
crl [rel] : (P[M / L] , S) => {~ M}((P' [M / L]) , S' ) if (P , S) => {~ L}(P' , S' ) .
crl [rel] : (P[M / L] , S) => {A}((P' [M / L]) , S' ) if (P , S) =>{A}(P' , S' ) /\ A =/= L /\ A =/= ~ L .
*** Definition
crl [def] : (K , S) => {A}(P' , S') if (K definedIn context)
/\ (def(K , context) , S) => {A}(P' , S')
/\ getDeltasFor( K , S ) == empty .
*** Pseudo DeltaCCSProcess Summation
crl [pseudo] : U + V => U' if U => U' .
*** Delta
crl [delta] : (K , S) => {A}(P , S') if ---getDeltasFor( K , deltaSet ) =/= empty
(K definedIn context)
/\ getChoiceProcessForDeltas( getDeltasFor(K , deltaSet) , S) => {A}(P , S') .
---/\ satSolve( fm ) == model(FL , True) .
--- Check for other Deltas on K in S integrated in getChoiceProcessForDeltas
*** reflexive, transitive closure
sort TDProcess .
subsort TDProcess < ActDProcess .
op [_] : DeltaCCSProcess -> TDProcess [frozen] .
crl [ U ] => {A}U' if U => {A}U' .
crl [ U ] => {A}ADP if U => {A}U' /\ [ U' ] => ADP .
*** weak semantics
sorts Act*DProcess OActDProcess .
op {_}*_ : Act DeltaCCSProcess -> Act*DProcess [frozen] .
op {{_}}_ : Act DeltaCCSProcess -> OActDProcess [frozen] .
sort WDProcess .
subsorts WDProcess < Act*DProcess OActDProcess .
op |_| : DeltaCCSProcess -> WDProcess [frozen] .
op <_> : DeltaCCSProcess -> WDProcess [frozen] .
rl | U | => {tau}* U .
crl | U | => {tau}* V if U => {tau}U' /\ | U' | => {tau}* V .
crl < U > => {{A}}U' if | U | => {tau}* V /\
V => {A}V' /\
| V' | => {tau}* U' .
endm
fmod SUCC is
inc META-LEVEL .
op MOD : -> Module .
---eq MOD = ['Wiper-Variante1] .
---eq MOD = ['Wiper-EXAMPLE] .
eq MOD = ['EXAMPLE] .
sort TermSet .
subsort Term < TermSet .
op mt : -> TermSet .
op _++_ : TermSet TermSet -> TermSet [assoc comm id: mt] .
op _isIn_ : Term TermSet -> Bool .
op allOneStep : Term Nat Term -> TermSet .
op filter : Qid TermSet TermSet -> TermSet .
op filter : Qid TermSet -> TermSet .
op succ : Term -> TermSet .
op succ : Term TermSet -> TermSet .
op wsucc : Term -> TermSet .
op wsucc : Term TermSet -> TermSet .
var M : Module .
var F : Qid .
vars T T' X : Term .
var N : Nat .
vars TS TS' : TermSet .
eq T isIn mt = false .
eq T isIn (T' ++ TS) =
(getTerm(metaReduce(MOD, '_==_[T,T'])) == 'true.Bool)
or (T isIn TS) .
eq filter(F,mt, TS') = mt .
ceq filter(F, X ++ TS, TS') =
(if T isIn TS' then T' else mt fi) ++ filter(F,TS,TS')
if F[T,T'] := X .
eq filter(F,mt) = mt .
ceq filter(F, X ++ TS) =
T' ++ filter(F,TS)
if F[T,T'] := X .
eq allOneStep(T,N,X) =
if metaSearch(MOD,T, X, nil, '+,1,N) == failure then mt
else getTerm(metaSearch(MOD,T, X, nil, '+,1,N)) ++
allOneStep(T,N + 1,X) fi .
eq succ(T) = filter(('`{_`}_),
allOneStep(T, 0, 'ADP:ActDProcess)) .
eq succ(T,TS) = filter(('`{_`}_),
allOneStep(T,0,'ADP:ActDProcess),TS) .
eq wsucc(T) = filter(('`{`{_`}`}_),
allOneStep('<_>[T], 0, 'OADP:OActDProcess)) .
eq wsucc(T,TS) = filter(('`{`{_`}`}_),
allOneStep('<_>[T],0,'OADP:OActDProcess),TS) .
endfm
*** Modul wie bei Wang Implementierung
fmod mu-calculus is
protecting SUCC .
sorts SEnvironment SDefinition SVariable Environment Definition MuVariable MuFormula .
subsort MuVariable SVariable < MuFormula .
subsort Definition < Environment .
subsort SDefinition < SEnvironment .
*** primitive operators ***
ops tt ff : -> MuFormula .
op ~_ : MuFormula -> MuFormula [ prec 52 ] .
op _/\_ : MuFormula MuFormula -> MuFormula [ comm prec 55 ] .
op _\/_ : MuFormula MuFormula -> MuFormula [ comm prec 59 ] .
*** modal operators
op <_>_ : TermSet MuFormula -> MuFormula [ prec 53 ] .
op <<_>>_ : TermSet MuFormula -> MuFormula [ prec 53 ] .
op `[_`]_ : TermSet MuFormula -> MuFormula [ prec 53 ] .
op `[`[_`]`]_ : TermSet MuFormula -> MuFormula [ prec 53 ] .
op <->_ : MuFormula -> MuFormula [ prec 53 ] .
op <<->>_ : MuFormula -> MuFormula [ prec 53 ] .
op `[-`]_ : MuFormula -> MuFormula [ prec 53 ] .
op `[`[-`]`]_ : MuFormula -> MuFormula [ prec 53 ] .
*** new modal operators
op <_>#_#_ : TermSet SVariable MuFormula -> MuFormula [ prec 53 ] .
op <<_>>#_#_ : TermSet SVariable MuFormula -> MuFormula [ prec 53 ] .
op `[_`]#_#_ : TermSet SVariable MuFormula -> MuFormula [ prec 53 ] .
op `[`[_`]`]#_#_ : TermSet SVariable MuFormula -> MuFormula [ prec 53 ] .
op <->#_#_ : SVariable MuFormula -> MuFormula [ prec 53 ] .
op <<->>#_#_ : SVariable MuFormula -> MuFormula [ prec 53 ] .
op `[-`]#_#_ : SVariable MuFormula -> MuFormula [ prec 53 ] .
op `[`[-`]`]#_#_ : SVariable MuFormula -> MuFormula [ prec 53 ] .
*** mu-operators
op Mu__ : MuVariable MuFormula -> MuFormula [ prec 61 ] .
op Nu__ : MuVariable MuFormula -> MuFormula [ prec 61 ] .
ops forall exists : SEnvironment Environment TermSet MuFormula -> Bool .
op setSVar : SVariable Term SEnvironment -> SEnvironment .
op getSigma : Term -> Term .
op checkFalse : Term -> Bool .
---op _|=_ : Term MuFormula -> Bool [ prec 85 ].
op _ _ _|=_ : SEnvironment Environment Term MuFormula -> Bool [ prec 85 ] .
---sorts Recquirements Declarations .
---op "_,_" : Recquirements Declarations -> Environment .
---var Recs : Recquirements .
---var Decl : Declarations .
vars P Q T T' U U' : Term .
var K S PS : TermSet .
vars Phi Psi : MuFormula .
vars X Y : MuVariable .
var E : Environment .
var SE : SEnvironment .
vars SVA SVB : SVariable .
var b : Bool .
*** Die beiden folgenden Abschnitt sind aus der Implementierung von Wang, Modul ENVIRONMENT
*** Definition
op _:=___ : MuVariable Bool TermSet MuFormula -> Definition [ prec 81 ] .
*** Environment
op `{`} : -> Environment .
op _&_ : Environment Environment -> Environment [ ctor assoc comm id: {} prec 83 ] .
*** Definition SEnvironment
op _=def_ : SVariable Term -> SEnvironment .
*** SEnvironment
op `{`} : -> SEnvironment .
op _&_ : SEnvironment SEnvironment -> SEnvironment [ ctor assoc comm id: {} prec 83 ] .
*** Tableau Rules from Stirling - Modal and Temporal Logics for CCS*
*** Constants
eq SE E P |= tt = true .
eq SE E P |= ff = checkFalse(P) .
*** Double Negation
eq SE E P |= ~(~ Psi) = SE E P |= Psi .
*** Konjunktion
eq SE E P |= Phi /\ Psi = if SE E P |= Phi then SE E P |= Psi else checkFalse(P) fi .
ceq SE E P |= ~(Psi /\ Phi) = true if SE E P |= ~ Psi .
ceq SE E P |= ~(Psi /\ Phi) = true if SE E P |= ~ Phi .
*** Disjunction
ceq SE E P |= Psi \/ Phi = true if SE E P |= Psi .
ceq SE E P |= Psi \/ Phi = true if SE E P |= Phi .
*** Box-Operator
eq SE E P |= [ K ] Phi = forall(SE, E, succ(P, K), Phi) .
eq SE E P |= [[ K ]] Phi = forall(SE, E, wsucc(P, K), Phi) .
eq SE E P |= [-] Phi = forall(SE, E, succ(P), Phi) .
eq SE E P |= [[-]] Phi = forall(SE, E, wsucc(P), Phi) .
*** new Box-Operators
eq SE E P |= [ K ]# SVA # Phi = forall(setSVar(SVA, P, SE), E, succ(P, K), Phi) .
eq SE E P |= [[ K ]]# SVA # Phi = forall(setSVar(SVA, P, SE), E, wsucc(P, K), Phi) .
eq SE E P |= [-]# SVA # Phi = forall(setSVar(SVA, P, SE), E, succ(P), Phi) .
eq SE E P |= [[-]]# SVA # Phi = forall(setSVar(SVA, P, SE), E, wsucc(P), Phi) .
*** Diamond-Operator
eq SE E P |= < K > Phi = exists(SE, E, succ(P, K), Phi) .
eq SE E P |= << K >> Phi = exists(SE, E, wsucc(P, K), Phi) .
eq SE E P |= <-> Phi = exists(SE, E, succ(P), Phi) .
eq SE E P |= <<->> Phi = exists(SE, E, wsucc(P), Phi) .
*** new Diamond-Operators
eq SE E P |= < K ># SVA # Phi = exists(setSVar(SVA, P, SE), E, succ(P, K), Phi) .
eq SE E P |= << K >># SVA # Phi = exists(setSVar(SVA, P, SE), E, wsucc(P, K), Phi) .
eq SE E P |= <-># SVA # Phi = exists(setSVar(SVA, P, SE), E, succ(P), Phi) .
eq SE E P |= <<->># SVA # Phi = exists(setSVar(SVA, P, SE), E, wsucc(P), Phi) .
*** Auxiliary-Methods
eq forall(SE, E, mt, Phi) = true .
eq forall(SE, E, P ++ PS, Phi) = (SE E P |= Phi) and (forall(SE, E, PS, Phi)) .
eq exists(SE, E, mt, Phi) = false .
eq exists(SE, E, P ++ PS, Phi) = (SE E P |= Phi) or (exists(SE, E, PS, Phi)) .
eq setSVar(SVA, P, {}) = SVA =def getSigma(P) .
eq setSVar(SVA, P, (SVB =def Q) & SE) = if ( SVA == SVB ) then ( SVA =def getSigma(P) & SE ) else ( (SVB =def Q) & setSVar(SVA, P, SE) ) fi .
eq getSigma(P) = getTerm( metaReduce(MOD, 'getDeltaSet [ P ] ) ) .
eq checkFalse(P) = if getTerm( metaReduce(MOD, 'checkVariant [ 'Proc.DeltaCCSProcess ] ) ) == ( 'true.Bool) then false else true fi .
*** check SVar
eq {} E P |= SVB = false .
eq (SVA =def Q) & SE E P |= SVB = ( ( SVA == SVB ) and ( Q == getSigma(P) ) ) or ( SE E P |= SVB ) .
*** Mu-Operator
eq SE {} K |= Mu X Phi = SE (X := false K Phi) K |= Phi .
ceq SE (E & (Y := b S Psi)) K |= Mu X Phi = SE E & (Y := b S Psi) & (X := false K Phi) K |= Phi if X =/= Y .
*** Nu-Operator
eq SE {} K |= Nu X Phi = SE (X := true K Phi) K |= Phi .
ceq SE E & (Y := b S Psi) K |= Nu X Phi = SE E & (Y := b S Psi) & (X := true K Phi) K |= Phi if X =/= Y .
***
ceq SE E & (X := b S Phi) K |= X = b if K isIn S .
ceq SE E & (X := b S Phi) K |= X = SE E & (X := b (K ++ S) Phi) K |= Phi if not (K isIn S) .
endfm
mod EXAMPLE is
inc DeltaCCS .
var ADP : ActDProcess .
op Proc : -> DeltaCCSProcess .
eq fm = True .
eq context = ( 'PC =def 'a . 'K ) &
( 'K =def 'b . 'K ) &
( 'KK =def 'c . 'KK ) &
( 'KKK =def 'd . 'KK ) .
eq deltaSet = ( 'd2 =ddef ( 'KK, True, 'KKK ) & 'd1 =ddef ( 'K, True, 'KK ) ) .
eq Proc = ( 'PC, deltaSet ) .
op ds : -> DeltaSet .
eq ds = ( 'd1 =ddef ( 'K, True, 'KK ) & 'd2 =ddef ( 'KK, True, 'KKK ) ) .
endm
---red in mu-calculus : upModule( 'SUCC , false) .
---red in mu-calculus : getTerm( metaReduce(MOD, 'getDeltaSet [ 'Proc.DeltaCCSProcess ] ) ) .
---red in mu-calculus : {} 'Proc.DeltaCCSProcess |= Nu X ( < ''a.Act ++ ''b.Act ++ ''c.Act ++ ''d.Act > tt ) /\ ( [ ''a.Act ++ ''b.Act ++ ''c.Act ++ ''d.Act ] X ) .
---red in mu-calculus : {} 'Proc.DeltaCCSProcess |= Nu X ( <-> tt ) /\ ( [-] X ) .
---reduce in Experiments : applySet deltaSet to 'K .
---search in Experiments : ['PC] =>+ AP .
mod Experiments is
inc DeltaCCS .
--- Example 1: Crossing
vars S S' S'' : DeltaSet .
vars P Q : Process .
var ADP : ActDProcess .
ops Ven PC Crossing : -> DeltaCCSProcess .
eq fm = True .
---eq context = ('PC =def 'a . 'b . 'K0) & ('K0 =def 'b . 0) .
eq context = ('PC2 =def 'K0) &
('PC1 =def 'a . 'b . 'c . 0 | ~ 'a . 0) &
('PC =def 'a . 'b . 'K0) &
('Test =def 'x . 'AB) &
('AB =def 'a . 'b . 'AB) &
('AB1 =def 'c . 'd . 0) &
('K0 =def 'd . 'b . 0) &
('K1 =def 'd . 'd . 0) &
('K2 =def 'd . 'e . 0) &
('K3 =def 'd . 'K4) &
('K4 =def 'g . 0) &
('K5 =def 'goal . 0) &
('Proc =def 'a . 'b . 'Proc) &
('Proc2 =def 'a . tau . 'Proc2 + tau . 'b . 'Proc2) &
('Ven =def '2p . 'VenB + '1p . 'VenL) &
('VenB =def 'big . 'collectB . 'Ven) &
('VenL =def 'little . 'collectL . 'Ven) &
('Road =def 'car . 'up . ~ 'ccross . ~ 'down . 'Road) &
('Rail =def 'train . 'green . ~ 'tcross . ~ 'red . 'Rail) &
('Signal =def ~ 'green . 'red . 'Signal
+ ~ 'up . 'down . 'Signal) &
('Crossing =def (('Road | ('Rail | 'Signal))
\ 'green \ 'red \ 'up \ 'down )) .
eq deltaSet = 'd1 =ddef ('K0 , True , 'K1) &
'd2 =ddef ('K0 , True , 'K2) &
'd3 =ddef ('K0 , True , 'K3) &
'd4 =ddef ('K4 , True , 'K5) &
'd6 =ddef ('AB , True , 'AB1) .
eq dProcess = ( 'Test , empty) .
eq Ven = ( 'Ven , empty) .
eq Crossing = ( 'Signal , empty) .
endm
---search in Experiments : ('PC, empty) =>+ ADP .
mod EXAMPLE is
inc DeltaCCS .
--- Example 2: Wiper SPL
var ADP : ActDProcess .
ops Simple Good Low High : -> Formula .
op Proc : -> DeltaCCSProcess .
eq fm = ( Simple \/ Good )
/\ ~ ( Simple /\ Good )
/\ ( Low \/ High )
/\ ~ ( Low /\ High ) .
eq context = ('PC =def ('default . ('Dry | 'Off)) \ 'noRain \ 'rain \ 'heavyRain ) &
('Dry =def ~ 'noRain . 'Dry + 'little . 'Damp + 'heavy . 'Wet) &
('Damp =def ~ 'rain . 'Damp + 'heavy . 'Wet + 'non . 'Dry) &
('Wet =def ~ 'heavyRain . 'Wet + 'little . 'Damp + 'non . 'Dry) &
('Off =def 'mOn . 'Man + 'iOn . 'Auto) &
('Man =def ~ 'perm . 'Man + 'off . 'Off + 'iOn . 'Auto) &
('Auto =def 'noRain . 'Auto + 'rain . 'Slow + 'heavyRain . 'Fast) &
('Slow =def ~ 'slowWipe . 'Auto) &
('Fast =def ~ 'fastWipe . 'Auto) &
('Damp1 =def ~ 'rain . 'Damp1 + 'non . 'Dry) &
('Wet1 =def ( ~ 'nil | 'nil ) \ 'nil ) &
('Dry1 =def ~ 'noRain . 'Dry1 + 'little . 'Damp) &
('Dry2 =def ~ 'noRain . 'Dry2 + 'little . 'Damp + 'heavy . 'Damp) &
('Auto1 =def 'noRain . 'Auto + 'rain . 'Slow + 'heavyRain . 'Slow) &
('Fast1 =def ( ~ 'nil | 'nil ) \ 'nil ) .
eq deltaSet = 'd1 =ddef ('Damp, Simple , 'Damp1) &
'd2 =ddef ('Wet, Simple , 'Wet1) &
'd3 =ddef ('Dry, Simple , 'Dry1) &
'd4 =ddef ('Dry1, Simple , 'Dry2) &
'd5 =ddef ('Auto, Low , 'Auto1) &
'd6 =ddef ('Fast, High , 'Fast1) .
eq Proc = ( 'PC , ( 'd1 =ddef ('Damp, Simple , 'Damp1) &
'd2 =ddef ('Wet, Simple , 'Wet1) &
'd3 =ddef ('Dry, Simple , 'Dry1) &
'd4 =ddef ('Dry1, Simple , 'Dry2) ) ) .
endm
--- delta2 5-6
mod Wiper-EXAMPLE is
inc DeltaCCS .
var ADP : ActDProcess .
op Proc : -> DeltaCCSProcess .
op a : -> Act .
ops Simple Good Low High : -> Formula .
eq fm = ( Simple \/ Good )
/\ ~ ( Simple /\ Good )
/\ ( Low \/ High )
/\ ~ ( Low /\ High ) .
eq context = ('PC =def ('Dry | 'Off) \ 'noRain \ 'rain \ 'heavyRain ) &
('Dry =def ~ 'noRain . 'Dry + 'little . 'Damp + 'heavy . 'Wet) &
('Damp =def ~ 'rain . 'Damp + 'heavy . 'Wet + 'non . 'Dry) &
('Wet =def ~ 'heavyRain . 'Wet + 'little . 'Damp + 'non . 'Dry) &
('Off =def 'mOn . 'Man + 'iOn . 'Auto) &
('Man =def ~ 'perm . 'Man + 'off . 'Off + 'iOn . 'Auto) &
('Auto =def 'noRain . 'Auto + 'rain . 'Slow + 'heavyRain . 'Fast) &
('Slow =def ~ 'slowWipe . 'Auto) &
('Fast =def 'fastWipe . 'Auto) &
('Auto1 =def 'noRain . 'Auto + 'rain . 'Slow + 'heavyRain . 'Slow) &
('Fast1 =def ( ~ 'nil . 0 | 'nil . 0 ) \ 'nil ) .
eq deltaSet = 'd5 =ddef ('Auto, Low , 'Auto1) &
'd6 =ddef ('Fast, Low , 'Fast1) .
eq Proc = ( 'PC , deltaSet) .
eq a = 'fastWipe .
endm
---red in Wiper : deltaSet difference getDeltaSet(Proc) .
---red in Wiper : sat( fm /\ getDeltaSet(Proc) /\ ~ (deltaSet difference getDeltaSet(Proc)) ) .
---red in mu-calculus : getTerm( metaReduce(MOD, 'getDeltaSet [ 'Proc.DeltaCCSProcess ] ) ) .
---red in mu-calculus : getTerm( metaReduce(MOD, 'checkVariant [ 'Proc.DeltaCCSProcess ] ) ) == ( 'true.Bool) .
---red in mu-calculus : {} {} 'Proc.DeltaCCSProcess |= Nu X ( <-> tt ) /\ ( [-] X ) .
---red in mu-calculus : {} {} 'Proc.DeltaCCSProcess |= Mu X ( < ''heavy.Act > < 'a.Act > tt ) \/ ( <-> X ) .