32 (* identity refinement mapping for mm -- simply reused *) |
32 (* identity refinement mapping for mm -- simply reused *) |
33 rst :: "rpcStType" |
33 rst :: "rpcStType" |
34 cst :: "mClkStType" |
34 cst :: "mClkStType" |
35 ires :: "resType" |
35 ires :: "resType" |
36 |
36 |
37 constdefs |
37 definition |
38 (* auxiliary predicates *) |
38 (* auxiliary predicates *) |
39 MVOKBARF :: "Vals => bool" |
39 MVOKBARF :: "Vals => bool" |
40 "MVOKBARF v == (v : MemVal) | (v = OK) | (v = BadArg) | (v = RPCFailure)" |
40 where "MVOKBARF v <-> (v : MemVal) | (v = OK) | (v = BadArg) | (v = RPCFailure)" |
|
41 |
|
42 definition |
41 MVOKBA :: "Vals => bool" |
43 MVOKBA :: "Vals => bool" |
42 "MVOKBA v == (v : MemVal) | (v = OK) | (v = BadArg)" |
44 where "MVOKBA v <-> (v : MemVal) | (v = OK) | (v = BadArg)" |
|
45 |
|
46 definition |
43 MVNROKBA :: "Vals => bool" |
47 MVNROKBA :: "Vals => bool" |
44 "MVNROKBA v == (v : MemVal) | (v = NotAResult) | (v = OK) | (v = BadArg)" |
48 where "MVNROKBA v <-> (v : MemVal) | (v = NotAResult) | (v = OK) | (v = BadArg)" |
45 |
49 |
|
50 definition |
46 (* tuples of state functions changed by the various components *) |
51 (* tuples of state functions changed by the various components *) |
47 e :: "PrIds => (bit * memOp) stfun" |
52 e :: "PrIds => (bit * memOp) stfun" |
48 "e p == PRED (caller memCh!p)" |
53 where "e p = PRED (caller memCh!p)" |
|
54 |
|
55 definition |
49 c :: "PrIds => (mClkState * (bit * Vals) * (bit * rpcOp)) stfun" |
56 c :: "PrIds => (mClkState * (bit * Vals) * (bit * rpcOp)) stfun" |
50 "c p == PRED (cst!p, rtrner memCh!p, caller crCh!p)" |
57 where "c p = PRED (cst!p, rtrner memCh!p, caller crCh!p)" |
|
58 |
|
59 definition |
51 r :: "PrIds => (rpcState * (bit * Vals) * (bit * memOp)) stfun" |
60 r :: "PrIds => (rpcState * (bit * Vals) * (bit * memOp)) stfun" |
52 "r p == PRED (rst!p, rtrner crCh!p, caller rmCh!p)" |
61 where "r p = PRED (rst!p, rtrner crCh!p, caller rmCh!p)" |
|
62 |
|
63 definition |
53 m :: "PrIds => ((bit * Vals) * Vals) stfun" |
64 m :: "PrIds => ((bit * Vals) * Vals) stfun" |
54 "m p == PRED (rtrner rmCh!p, ires!p)" |
65 where "m p = PRED (rtrner rmCh!p, ires!p)" |
55 |
66 |
|
67 definition |
56 (* the environment action *) |
68 (* the environment action *) |
57 ENext :: "PrIds => action" |
69 ENext :: "PrIds => action" |
58 "ENext p == ACT (? l. #l : #MemLoc & Call memCh p #(read l))" |
70 where "ENext p = ACT (? l. #l : #MemLoc & Call memCh p #(read l))" |
59 |
71 |
60 |
72 |
|
73 definition |
61 (* specification of the history variable *) |
74 (* specification of the history variable *) |
62 HInit :: "histType => PrIds => stpred" |
75 HInit :: "histType => PrIds => stpred" |
63 "HInit rmhist p == PRED rmhist!p = #histA" |
76 where "HInit rmhist p = PRED rmhist!p = #histA" |
64 |
77 |
|
78 definition |
65 HNext :: "histType => PrIds => action" |
79 HNext :: "histType => PrIds => action" |
66 "HNext rmhist p == ACT (rmhist!p)$ = |
80 where "HNext rmhist p = ACT (rmhist!p)$ = |
67 (if (MemReturn rmCh ires p | RPCFail crCh rmCh rst p) |
81 (if (MemReturn rmCh ires p | RPCFail crCh rmCh rst p) |
68 then #histB |
82 then #histB |
69 else if (MClkReply memCh crCh cst p) |
83 else if (MClkReply memCh crCh cst p) |
70 then #histA |
84 then #histA |
71 else $(rmhist!p))" |
85 else $(rmhist!p))" |
72 |
86 |
|
87 definition |
73 HistP :: "histType => PrIds => temporal" |
88 HistP :: "histType => PrIds => temporal" |
74 "HistP rmhist p == TEMP Init HInit rmhist p |
89 where "HistP rmhist p = (TEMP Init HInit rmhist p |
75 & [][HNext rmhist p]_(c p,r p,m p, rmhist!p)" |
90 & [][HNext rmhist p]_(c p,r p,m p, rmhist!p))" |
76 |
91 |
|
92 definition |
77 Hist :: "histType => temporal" |
93 Hist :: "histType => temporal" |
78 "Hist rmhist == TEMP (ALL p. HistP rmhist p)" |
94 where "Hist rmhist = TEMP (ALL p. HistP rmhist p)" |
79 |
95 |
|
96 definition |
80 (* the implementation *) |
97 (* the implementation *) |
81 IPImp :: "PrIds => temporal" |
98 IPImp :: "PrIds => temporal" |
82 "IPImp p == TEMP ( Init ~Calling memCh p & [][ENext p]_(e p) |
99 where "IPImp p = (TEMP ( Init ~Calling memCh p & [][ENext p]_(e p) |
83 & MClkIPSpec memCh crCh cst p |
100 & MClkIPSpec memCh crCh cst p |
84 & RPCIPSpec crCh rmCh rst p |
101 & RPCIPSpec crCh rmCh rst p |
85 & RPSpec rmCh mm ires p |
102 & RPSpec rmCh mm ires p |
86 & (ALL l. #l : #MemLoc --> MSpec rmCh mm ires l))" |
103 & (ALL l. #l : #MemLoc --> MSpec rmCh mm ires l)))" |
87 |
104 |
|
105 definition |
88 ImpInit :: "PrIds => stpred" |
106 ImpInit :: "PrIds => stpred" |
89 "ImpInit p == PRED ( ~Calling memCh p |
107 where "ImpInit p = PRED ( ~Calling memCh p |
90 & MClkInit crCh cst p |
108 & MClkInit crCh cst p |
91 & RPCInit rmCh rst p |
109 & RPCInit rmCh rst p |
92 & PInit ires p)" |
110 & PInit ires p)" |
93 |
111 |
|
112 definition |
94 ImpNext :: "PrIds => action" |
113 ImpNext :: "PrIds => action" |
95 "ImpNext p == ACT [ENext p]_(e p) |
114 where "ImpNext p = (ACT [ENext p]_(e p) |
96 & [MClkNext memCh crCh cst p]_(c p) |
115 & [MClkNext memCh crCh cst p]_(c p) |
97 & [RPCNext crCh rmCh rst p]_(r p) |
116 & [RPCNext crCh rmCh rst p]_(r p) |
98 & [RNext rmCh mm ires p]_(m p)" |
117 & [RNext rmCh mm ires p]_(m p))" |
99 |
118 |
|
119 definition |
100 ImpLive :: "PrIds => temporal" |
120 ImpLive :: "PrIds => temporal" |
101 "ImpLive p == TEMP WF(MClkFwd memCh crCh cst p)_(c p) |
121 where "ImpLive p = (TEMP WF(MClkFwd memCh crCh cst p)_(c p) |
102 & SF(MClkReply memCh crCh cst p)_(c p) |
122 & SF(MClkReply memCh crCh cst p)_(c p) |
103 & WF(RPCNext crCh rmCh rst p)_(r p) |
123 & WF(RPCNext crCh rmCh rst p)_(r p) |
104 & WF(RNext rmCh mm ires p)_(m p) |
124 & WF(RNext rmCh mm ires p)_(m p) |
105 & WF(MemReturn rmCh ires p)_(m p)" |
125 & WF(MemReturn rmCh ires p)_(m p))" |
106 |
126 |
|
127 definition |
107 Implementation :: "temporal" |
128 Implementation :: "temporal" |
108 "Implementation == TEMP ( (ALL p. Init (~Calling memCh p) & [][ENext p]_(e p)) |
129 where "Implementation = (TEMP ( (ALL p. Init (~Calling memCh p) & [][ENext p]_(e p)) |
109 & MClkISpec memCh crCh cst |
130 & MClkISpec memCh crCh cst |
110 & RPCISpec crCh rmCh rst |
131 & RPCISpec crCh rmCh rst |
111 & IRSpec rmCh mm ires)" |
132 & IRSpec rmCh mm ires))" |
112 |
133 |
|
134 definition |
113 (* the predicate S describes the states of the implementation. |
135 (* the predicate S describes the states of the implementation. |
114 slight simplification: two "histState" parameters instead of a |
136 slight simplification: two "histState" parameters instead of a |
115 (one- or two-element) set. |
137 (one- or two-element) set. |
116 NB: The second conjunct of the definition in the paper is taken care of by |
138 NB: The second conjunct of the definition in the paper is taken care of by |
117 the type definitions. The last conjunct is asserted separately as the memory |
139 the type definitions. The last conjunct is asserted separately as the memory |
118 invariant MemInv, proved in Memory.thy. *) |
140 invariant MemInv, proved in Memory.thy. *) |
119 S :: "histType => bool => bool => bool => mClkState => rpcState => histState => histState => PrIds => stpred" |
141 S :: "histType => bool => bool => bool => mClkState => rpcState => histState => histState => PrIds => stpred" |
120 "S rmhist ecalling ccalling rcalling cs rs hs1 hs2 p == PRED |
142 where "S rmhist ecalling ccalling rcalling cs rs hs1 hs2 p = (PRED |
121 Calling memCh p = #ecalling |
143 Calling memCh p = #ecalling |
122 & Calling crCh p = #ccalling |
144 & Calling crCh p = #ccalling |
123 & (#ccalling --> arg<crCh!p> = MClkRelayArg<arg<memCh!p>>) |
145 & (#ccalling --> arg<crCh!p> = MClkRelayArg<arg<memCh!p>>) |
124 & (~ #ccalling & cst!p = #clkB --> MVOKBARF<res<crCh!p>>) |
146 & (~ #ccalling & cst!p = #clkB --> MVOKBARF<res<crCh!p>>) |
125 & Calling rmCh p = #rcalling |
147 & Calling rmCh p = #rcalling |
127 & (~ #rcalling --> ires!p = #NotAResult) |
149 & (~ #rcalling --> ires!p = #NotAResult) |
128 & (~ #rcalling & rst!p = #rpcB --> MVOKBA<res<rmCh!p>>) |
150 & (~ #rcalling & rst!p = #rpcB --> MVOKBA<res<rmCh!p>>) |
129 & cst!p = #cs |
151 & cst!p = #cs |
130 & rst!p = #rs |
152 & rst!p = #rs |
131 & (rmhist!p = #hs1 | rmhist!p = #hs2) |
153 & (rmhist!p = #hs1 | rmhist!p = #hs2) |
132 & MVNROKBA<ires!p>" |
154 & MVNROKBA<ires!p>)" |
133 |
155 |
|
156 definition |
134 (* predicates S1 -- S6 define special instances of S *) |
157 (* predicates S1 -- S6 define special instances of S *) |
135 S1 :: "histType => PrIds => stpred" |
158 S1 :: "histType => PrIds => stpred" |
136 "S1 rmhist p == S rmhist False False False clkA rpcA histA histA p" |
159 where "S1 rmhist p = S rmhist False False False clkA rpcA histA histA p" |
|
160 |
|
161 definition |
137 S2 :: "histType => PrIds => stpred" |
162 S2 :: "histType => PrIds => stpred" |
138 "S2 rmhist p == S rmhist True False False clkA rpcA histA histA p" |
163 where "S2 rmhist p = S rmhist True False False clkA rpcA histA histA p" |
|
164 |
|
165 definition |
139 S3 :: "histType => PrIds => stpred" |
166 S3 :: "histType => PrIds => stpred" |
140 "S3 rmhist p == S rmhist True True False clkB rpcA histA histB p" |
167 where "S3 rmhist p = S rmhist True True False clkB rpcA histA histB p" |
|
168 |
|
169 definition |
141 S4 :: "histType => PrIds => stpred" |
170 S4 :: "histType => PrIds => stpred" |
142 "S4 rmhist p == S rmhist True True True clkB rpcB histA histB p" |
171 where "S4 rmhist p = S rmhist True True True clkB rpcB histA histB p" |
|
172 |
|
173 definition |
143 S5 :: "histType => PrIds => stpred" |
174 S5 :: "histType => PrIds => stpred" |
144 "S5 rmhist p == S rmhist True True False clkB rpcB histB histB p" |
175 where "S5 rmhist p = S rmhist True True False clkB rpcB histB histB p" |
|
176 |
|
177 definition |
145 S6 :: "histType => PrIds => stpred" |
178 S6 :: "histType => PrIds => stpred" |
146 "S6 rmhist p == S rmhist True False False clkB rpcA histB histB p" |
179 where "S6 rmhist p = S rmhist True False False clkB rpcA histB histB p" |
147 |
180 |
|
181 definition |
148 (* The invariant asserts that the system is always in one of S1 - S6, for every p *) |
182 (* The invariant asserts that the system is always in one of S1 - S6, for every p *) |
149 ImpInv :: "histType => PrIds => stpred" |
183 ImpInv :: "histType => PrIds => stpred" |
150 "ImpInv rmhist p == PRED ( S1 rmhist p | S2 rmhist p | S3 rmhist p |
184 where "ImpInv rmhist p = (PRED (S1 rmhist p | S2 rmhist p | S3 rmhist p |
151 | S4 rmhist p | S5 rmhist p | S6 rmhist p)" |
185 | S4 rmhist p | S5 rmhist p | S6 rmhist p))" |
152 |
186 |
|
187 definition |
153 resbar :: "histType => resType" (* refinement mapping *) |
188 resbar :: "histType => resType" (* refinement mapping *) |
154 "resbar rmhist s p == |
189 where"resbar rmhist s p = |
155 (if (S1 rmhist p s | S2 rmhist p s) |
190 (if (S1 rmhist p s | S2 rmhist p s) |
156 then ires s p |
191 then ires s p |
157 else if S3 rmhist p s |
192 else if S3 rmhist p s |
158 then if rmhist s p = histA |
193 then if rmhist s p = histA |
159 then ires s p else MemFailure |
194 then ires s p else MemFailure |