3807
|
1 |
(*
|
|
2 |
File: TLA/ex/inc/Inc.thy
|
|
3 |
Author: Stephan Merz
|
|
4 |
Copyright: 1997 University of Munich
|
|
5 |
|
|
6 |
Theory Name: Inc
|
|
7 |
Logic Image: TLA
|
|
8 |
|
|
9 |
Lamport's "increment" example.
|
|
10 |
*)
|
|
11 |
|
6255
|
12 |
Inc = TLA + Nat +
|
|
13 |
|
|
14 |
(* program counter as an enumeration type *)
|
|
15 |
datatype pcount = a | b | g
|
3807
|
16 |
|
|
17 |
consts
|
|
18 |
(* program variables *)
|
6255
|
19 |
x,y,sem :: nat stfun
|
|
20 |
pc1,pc2 :: pcount stfun
|
3807
|
21 |
|
|
22 |
(* names of actions and predicates *)
|
6255
|
23 |
M1,M2,N1,N2 :: action
|
|
24 |
alpha1,alpha2,beta1,beta2,gamma1,gamma2 :: action
|
|
25 |
InitPhi, InitPsi :: stpred
|
|
26 |
PsiInv,PsiInv1,PsiInv2,PsiInv3 :: stpred
|
3807
|
27 |
|
|
28 |
(* temporal formulas *)
|
6255
|
29 |
Phi, Psi :: temporal
|
3807
|
30 |
|
|
31 |
rules
|
|
32 |
(* the "base" variables, required to compute enabledness predicates *)
|
6255
|
33 |
Inc_base "basevars (x, y, sem, pc1, pc2)"
|
3807
|
34 |
|
|
35 |
(* definitions for high-level program *)
|
6255
|
36 |
InitPhi_def "InitPhi == PRED x = # 0 & y = # 0"
|
|
37 |
M1_def "M1 == ACT x` = Suc<$x> & y` = $y"
|
|
38 |
M2_def "M2 == ACT y` = Suc<$y> & x` = $x"
|
|
39 |
Phi_def "Phi == TEMP Init InitPhi & [][M1 | M2]_(x,y)
|
|
40 |
& WF(M1)_(x,y) & WF(M2)_(x,y)"
|
3807
|
41 |
|
|
42 |
(* definitions for low-level program *)
|
6255
|
43 |
InitPsi_def "InitPsi == PRED pc1 = #a & pc2 = #a
|
|
44 |
& x = # 0 & y = # 0 & sem = # 1"
|
|
45 |
alpha1_def "alpha1 == ACT $pc1 = #a & pc1$ = #b & $sem = Suc<sem`>
|
|
46 |
& unchanged(x,y,pc2)"
|
|
47 |
alpha2_def "alpha2 == ACT $pc2 = #a & pc2$ = #b & $sem = Suc<sem`>
|
|
48 |
& unchanged(x,y,pc1)"
|
|
49 |
beta1_def "beta1 == ACT $pc1 = #b & pc1$ = #g & x$ = Suc<$x>
|
|
50 |
& unchanged(y,sem,pc2)"
|
|
51 |
beta2_def "beta2 == ACT $pc2 = #b & pc2$ = #g & y$ = Suc<$y>
|
|
52 |
& unchanged(x,sem,pc1)"
|
|
53 |
gamma1_def "gamma1 == ACT $pc1 = #g & pc1$ = #a & sem$ = Suc<$sem>
|
|
54 |
& unchanged(x,y,pc2)"
|
|
55 |
gamma2_def "gamma2 == ACT $pc2 = #g & pc2$ = #a & sem$ = Suc<$sem>
|
|
56 |
& unchanged(x,y,pc1)"
|
|
57 |
N1_def "N1 == ACT (alpha1 | beta1 | gamma1)"
|
|
58 |
N2_def "N2 == ACT (alpha2 | beta2 | gamma2)"
|
|
59 |
Psi_def "Psi == TEMP Init InitPsi
|
|
60 |
& [][N1 | N2]_(x,y,sem,pc1,pc2)
|
|
61 |
& SF(N1)_(x,y,sem,pc1,pc2)
|
|
62 |
& SF(N2)_(x,y,sem,pc1,pc2)"
|
3807
|
63 |
|
6255
|
64 |
PsiInv1_def "PsiInv1 == PRED sem = # 1 & pc1 = #a & pc2 = #a"
|
|
65 |
PsiInv2_def "PsiInv2 == PRED sem = # 0 & pc1 = #a & (pc2 = #b | pc2 = #g)"
|
|
66 |
PsiInv3_def "PsiInv3 == PRED sem = # 0 & pc2 = #a & (pc1 = #b | pc1 = #g)"
|
|
67 |
PsiInv_def "PsiInv == PRED (PsiInv1 | PsiInv2 | PsiInv3)"
|
3807
|
68 |
|
|
69 |
end
|
|
70 |
|
|
71 |
ML
|