10159
|
1 |
(*<*)theory CTL = Base:;(*>*)
|
9958
|
2 |
|
10867
|
3 |
subsection{*Computation Tree Logic---CTL*};
|
9958
|
4 |
|
10212
|
5 |
text{*\label{sec:CTL}
|
10867
|
6 |
The semantics of PDL only needs reflexive transitive closure.
|
|
7 |
Let us be adventurous and introduce a more expressive temporal operator.
|
|
8 |
We extend the datatype
|
10149
|
9 |
@{text formula} by a new constructor
|
10159
|
10 |
*};
|
10149
|
11 |
(*<*)
|
|
12 |
datatype formula = Atom atom
|
|
13 |
| Neg formula
|
|
14 |
| And formula formula
|
|
15 |
| AX formula
|
|
16 |
| EF formula(*>*)
|
10159
|
17 |
| AF formula;
|
9958
|
18 |
|
10149
|
19 |
text{*\noindent
|
|
20 |
which stands for "always in the future":
|
10159
|
21 |
on all paths, at some point the formula holds. Formalizing the notion of an infinite path is easy
|
|
22 |
in HOL: it is simply a function from @{typ nat} to @{typ state}.
|
|
23 |
*};
|
9958
|
24 |
|
|
25 |
constdefs Paths :: "state \<Rightarrow> (nat \<Rightarrow> state)set"
|
10149
|
26 |
"Paths s \<equiv> {p. s = p 0 \<and> (\<forall>i. (p i, p(i+1)) \<in> M)}";
|
|
27 |
|
|
28 |
text{*\noindent
|
10159
|
29 |
This definition allows a very succinct statement of the semantics of @{term AF}:
|
10867
|
30 |
\footnote{Do not be misled: neither datatypes nor recursive functions can be
|
10149
|
31 |
extended by new constructors or equations. This is just a trick of the
|
|
32 |
presentation. In reality one has to define a new datatype and a new function.}
|
10159
|
33 |
*};
|
10149
|
34 |
(*<*)
|
10159
|
35 |
consts valid :: "state \<Rightarrow> formula \<Rightarrow> bool" ("(_ \<Turnstile> _)" [80,80] 80);
|
9958
|
36 |
|
|
37 |
primrec
|
10133
|
38 |
"s \<Turnstile> Atom a = (a \<in> L s)"
|
10149
|
39 |
"s \<Turnstile> Neg f = (~(s \<Turnstile> f))"
|
9958
|
40 |
"s \<Turnstile> And f g = (s \<Turnstile> f \<and> s \<Turnstile> g)"
|
|
41 |
"s \<Turnstile> AX f = (\<forall>t. (s,t) \<in> M \<longrightarrow> t \<Turnstile> f)"
|
10801
|
42 |
"s \<Turnstile> EF f = (\<exists>t. (s,t) \<in> M\<^sup>* \<and> t \<Turnstile> f)"
|
10149
|
43 |
(*>*)
|
9958
|
44 |
"s \<Turnstile> AF f = (\<forall>p \<in> Paths s. \<exists>i. p i \<Turnstile> f)";
|
|
45 |
|
10149
|
46 |
text{*\noindent
|
|
47 |
Model checking @{term AF} involves a function which
|
10159
|
48 |
is just complicated enough to warrant a separate definition:
|
|
49 |
*};
|
10149
|
50 |
|
9958
|
51 |
constdefs af :: "state set \<Rightarrow> state set \<Rightarrow> state set"
|
10149
|
52 |
"af A T \<equiv> A \<union> {s. \<forall>t. (s, t) \<in> M \<longrightarrow> t \<in> T}";
|
|
53 |
|
|
54 |
text{*\noindent
|
10867
|
55 |
Now we define @{term "mc(AF f)"} as the least set @{term T} that includes
|
10149
|
56 |
@{term"mc f"} and all states all of whose direct successors are in @{term T}:
|
10159
|
57 |
*};
|
10149
|
58 |
(*<*)
|
|
59 |
consts mc :: "formula \<Rightarrow> state set";
|
9958
|
60 |
primrec
|
10133
|
61 |
"mc(Atom a) = {s. a \<in> L s}"
|
10149
|
62 |
"mc(Neg f) = -mc f"
|
9958
|
63 |
"mc(And f g) = mc f \<inter> mc g"
|
|
64 |
"mc(AX f) = {s. \<forall>t. (s,t) \<in> M \<longrightarrow> t \<in> mc f}"
|
10839
|
65 |
"mc(EF f) = lfp(\<lambda>T. mc f \<union> M\<inverse> `` T)"(*>*)
|
9958
|
66 |
"mc(AF f) = lfp(af(mc f))";
|
10159
|
67 |
|
|
68 |
text{*\noindent
|
|
69 |
Because @{term af} is monotone in its second argument (and also its first, but
|
10242
|
70 |
that is irrelevant) @{term"af A"} has a least fixed point:
|
10159
|
71 |
*};
|
|
72 |
|
|
73 |
lemma mono_af: "mono(af A)";
|
|
74 |
apply(simp add: mono_def af_def);
|
|
75 |
apply blast;
|
|
76 |
done
|
10149
|
77 |
(*<*)
|
10839
|
78 |
lemma mono_ef: "mono(\<lambda>T. A \<union> M\<inverse> `` T)";
|
10159
|
79 |
apply(rule monoI);
|
|
80 |
by(blast);
|
9958
|
81 |
|
10149
|
82 |
lemma EF_lemma:
|
10839
|
83 |
"lfp(\<lambda>T. A \<union> M\<inverse> `` T) = {s. \<exists>t. (s,t) \<in> M\<^sup>* \<and> t \<in> A}";
|
9958
|
84 |
apply(rule equalityI);
|
|
85 |
apply(rule subsetI);
|
10159
|
86 |
apply(simp);
|
10210
|
87 |
apply(erule lfp_induct);
|
10159
|
88 |
apply(rule mono_ef);
|
|
89 |
apply(simp);
|
10281
|
90 |
apply(blast intro: rtrancl_trans);
|
10159
|
91 |
apply(rule subsetI);
|
|
92 |
apply(simp, clarify);
|
|
93 |
apply(erule converse_rtrancl_induct);
|
10186
|
94 |
apply(rule ssubst[OF lfp_unfold[OF mono_ef]]);
|
10159
|
95 |
apply(blast);
|
10186
|
96 |
apply(rule ssubst[OF lfp_unfold[OF mono_ef]]);
|
10159
|
97 |
by(blast);
|
10149
|
98 |
(*>*)
|
10159
|
99 |
text{*
|
10867
|
100 |
All we need to prove now is @{prop"mc(AF f) = {s. s \<Turnstile> AF f}"}, which states
|
|
101 |
that @{term mc} and @{text"\<Turnstile>"} agree for @{term AF}\@.
|
|
102 |
This time we prove the two inclusions separately, starting
|
10159
|
103 |
with the easy one:
|
|
104 |
*};
|
9958
|
105 |
|
10159
|
106 |
theorem AF_lemma1:
|
|
107 |
"lfp(af A) \<subseteq> {s. \<forall> p \<in> Paths s. \<exists> i. p i \<in> A}";
|
|
108 |
|
|
109 |
txt{*\noindent
|
10225
|
110 |
In contrast to the analogous property for @{term EF}, and just
|
10242
|
111 |
for a change, we do not use fixed point induction but a weaker theorem,
|
10225
|
112 |
@{thm[source]lfp_lowerbound}:
|
|
113 |
@{thm[display]lfp_lowerbound[of _ "S",no_vars]}
|
|
114 |
The instance of the premise @{prop"f S \<subseteq> S"} is proved pointwise,
|
10281
|
115 |
a decision that clarification takes for us:
|
10159
|
116 |
*};
|
10225
|
117 |
apply(rule lfp_lowerbound);
|
10159
|
118 |
apply(clarsimp simp add: af_def Paths_def);
|
10363
|
119 |
|
10225
|
120 |
txt{*
|
10363
|
121 |
@{subgoals[display,indent=0,margin=70,goals_limit=1]}
|
10159
|
122 |
Now we eliminate the disjunction. The case @{prop"p 0 \<in> A"} is trivial:
|
|
123 |
*};
|
|
124 |
|
9958
|
125 |
apply(erule disjE);
|
|
126 |
apply(blast);
|
10159
|
127 |
|
|
128 |
txt{*\noindent
|
|
129 |
In the other case we set @{term t} to @{term"p 1"} and simplify matters:
|
|
130 |
*};
|
|
131 |
|
9958
|
132 |
apply(erule_tac x = "p 1" in allE);
|
|
133 |
apply(clarsimp);
|
10159
|
134 |
|
|
135 |
txt{*
|
10363
|
136 |
@{subgoals[display,indent=0,margin=70,goals_limit=1]}
|
10159
|
137 |
It merely remains to set @{term pa} to @{term"\<lambda>i. p(i+1)"}, i.e.\ @{term p} without its
|
|
138 |
first element. The rest is practically automatic:
|
|
139 |
*};
|
|
140 |
|
9958
|
141 |
apply(erule_tac x = "\<lambda>i. p(i+1)" in allE);
|
10159
|
142 |
apply simp;
|
|
143 |
apply blast;
|
|
144 |
done;
|
9958
|
145 |
|
10225
|
146 |
|
9958
|
147 |
text{*
|
10867
|
148 |
The opposite inclusion is proved by contradiction: if some state
|
10159
|
149 |
@{term s} is not in @{term"lfp(af A)"}, then we can construct an
|
9958
|
150 |
infinite @{term A}-avoiding path starting from @{term s}. The reason is
|
10159
|
151 |
that by unfolding @{term lfp} we find that if @{term s} is not in
|
9958
|
152 |
@{term"lfp(af A)"}, then @{term s} is not in @{term A} and there is a
|
|
153 |
direct successor of @{term s} that is again not in @{term"lfp(af
|
|
154 |
A)"}. Iterating this argument yields the promised infinite
|
|
155 |
@{term A}-avoiding path. Let us formalize this sketch.
|
|
156 |
|
10867
|
157 |
The one-step argument in the sketch above
|
|
158 |
is proved by a variant of contraposition:
|
9958
|
159 |
*};
|
|
160 |
|
|
161 |
lemma not_in_lfp_afD:
|
|
162 |
"s \<notin> lfp(af A) \<Longrightarrow> s \<notin> A \<and> (\<exists> t. (s,t)\<in>M \<and> t \<notin> lfp(af A))";
|
10235
|
163 |
apply(erule contrapos_np);
|
10186
|
164 |
apply(rule ssubst[OF lfp_unfold[OF mono_af]]);
|
10159
|
165 |
apply(simp add:af_def);
|
|
166 |
done;
|
9958
|
167 |
|
|
168 |
text{*\noindent
|
10867
|
169 |
We assume the negation of the conclusion and prove @{term"s : lfp(af A)"}.
|
10237
|
170 |
Unfolding @{term lfp} once and
|
9958
|
171 |
simplifying with the definition of @{term af} finishes the proof.
|
|
172 |
|
|
173 |
Now we iterate this process. The following construction of the desired
|
|
174 |
path is parameterized by a predicate @{term P} that should hold along the path:
|
|
175 |
*};
|
|
176 |
|
|
177 |
consts path :: "state \<Rightarrow> (state \<Rightarrow> bool) \<Rightarrow> (nat \<Rightarrow> state)";
|
|
178 |
primrec
|
|
179 |
"path s P 0 = s"
|
|
180 |
"path s P (Suc n) = (SOME t. (path s P n,t) \<in> M \<and> P t)";
|
|
181 |
|
|
182 |
text{*\noindent
|
|
183 |
Element @{term"n+1"} on this path is some arbitrary successor
|
10159
|
184 |
@{term t} of element @{term n} such that @{term"P t"} holds. Remember that @{text"SOME t. R t"}
|
10654
|
185 |
is some arbitrary but fixed @{term t} such that @{prop"R t"} holds (see \S\ref{sec:SOME}). Of
|
10867
|
186 |
course, such a @{term t} need not exist, but that is of no
|
|
187 |
concern to us since we will only use @{term path} when a
|
10159
|
188 |
suitable @{term t} does exist.
|
9958
|
189 |
|
10159
|
190 |
Let us show that if each state @{term s} that satisfies @{term P}
|
|
191 |
has a successor that again satisfies @{term P}, then there exists an infinite @{term P}-path:
|
9958
|
192 |
*};
|
|
193 |
|
10159
|
194 |
lemma infinity_lemma:
|
|
195 |
"\<lbrakk> P s; \<forall>s. P s \<longrightarrow> (\<exists> t. (s,t) \<in> M \<and> P t) \<rbrakk> \<Longrightarrow>
|
|
196 |
\<exists>p\<in>Paths s. \<forall>i. P(p i)";
|
9958
|
197 |
|
|
198 |
txt{*\noindent
|
|
199 |
First we rephrase the conclusion slightly because we need to prove both the path property
|
10159
|
200 |
and the fact that @{term P} holds simultaneously:
|
9958
|
201 |
*};
|
|
202 |
|
10159
|
203 |
apply(subgoal_tac "\<exists>p. s = p 0 \<and> (\<forall>i. (p i,p(i+1)) \<in> M \<and> P(p i))");
|
9958
|
204 |
|
|
205 |
txt{*\noindent
|
10159
|
206 |
From this proposition the original goal follows easily:
|
9958
|
207 |
*};
|
|
208 |
|
|
209 |
apply(simp add:Paths_def, blast);
|
10159
|
210 |
|
|
211 |
txt{*\noindent
|
|
212 |
The new subgoal is proved by providing the witness @{term "path s P"} for @{term p}:
|
|
213 |
*};
|
|
214 |
|
9958
|
215 |
apply(rule_tac x = "path s P" in exI);
|
10159
|
216 |
apply(clarsimp);
|
|
217 |
|
|
218 |
txt{*\noindent
|
|
219 |
After simplification and clarification the subgoal has the following compact form
|
10363
|
220 |
@{subgoals[display,indent=0,margin=70,goals_limit=1]}
|
10159
|
221 |
and invites a proof by induction on @{term i}:
|
|
222 |
*};
|
|
223 |
|
9958
|
224 |
apply(induct_tac i);
|
|
225 |
apply(simp);
|
10159
|
226 |
|
|
227 |
txt{*\noindent
|
|
228 |
After simplification the base case boils down to
|
10363
|
229 |
@{subgoals[display,indent=0,margin=70,goals_limit=1]}
|
10159
|
230 |
The conclusion looks exceedingly trivial: after all, @{term t} is chosen such that @{prop"(s,t):M"}
|
|
231 |
holds. However, we first have to show that such a @{term t} actually exists! This reasoning
|
|
232 |
is embodied in the theorem @{thm[source]someI2_ex}:
|
|
233 |
@{thm[display,eta_contract=false]someI2_ex}
|
|
234 |
When we apply this theorem as an introduction rule, @{text"?P x"} becomes
|
|
235 |
@{prop"(s, x) : M & P x"} and @{text"?Q x"} becomes @{prop"(s,x) : M"} and we have to prove
|
|
236 |
two subgoals: @{prop"EX a. (s, a) : M & P a"}, which follows from the assumptions, and
|
|
237 |
@{prop"(s, x) : M & P x ==> (s,x) : M"}, which is trivial. Thus it is not surprising that
|
|
238 |
@{text fast} can prove the base case quickly:
|
|
239 |
*};
|
|
240 |
|
10000
|
241 |
apply(fast intro:someI2_ex);
|
10159
|
242 |
|
|
243 |
txt{*\noindent
|
10212
|
244 |
What is worth noting here is that we have used @{text fast} rather than
|
|
245 |
@{text blast}. The reason is that @{text blast} would fail because it cannot
|
|
246 |
cope with @{thm[source]someI2_ex}: unifying its conclusion with the current
|
|
247 |
subgoal is nontrivial because of the nested schematic variables. For
|
|
248 |
efficiency reasons @{text blast} does not even attempt such unifications.
|
|
249 |
Although @{text fast} can in principle cope with complicated unification
|
|
250 |
problems, in practice the number of unifiers arising is often prohibitive and
|
|
251 |
the offending rule may need to be applied explicitly rather than
|
|
252 |
automatically. This is what happens in the step case.
|
10159
|
253 |
|
10212
|
254 |
The induction step is similar, but more involved, because now we face nested
|
|
255 |
occurrences of @{text SOME}. As a result, @{text fast} is no longer able to
|
|
256 |
solve the subgoal and we apply @{thm[source]someI2_ex} by hand. We merely
|
|
257 |
show the proof commands but do not describe the details:
|
10159
|
258 |
*};
|
|
259 |
|
9958
|
260 |
apply(simp);
|
10000
|
261 |
apply(rule someI2_ex);
|
9958
|
262 |
apply(blast);
|
10000
|
263 |
apply(rule someI2_ex);
|
9958
|
264 |
apply(blast);
|
10159
|
265 |
apply(blast);
|
|
266 |
done;
|
9958
|
267 |
|
10159
|
268 |
text{*
|
10867
|
269 |
Function @{term path} has fulfilled its purpose now and can be forgotten.
|
|
270 |
It was merely defined to provide the witness in the proof of the
|
10171
|
271 |
@{thm[source]infinity_lemma}. Aficionados of minimal proofs might like to know
|
10159
|
272 |
that we could have given the witness without having to define a new function:
|
|
273 |
the term
|
|
274 |
@{term[display]"nat_rec s (\<lambda>n t. SOME u. (t,u)\<in>M \<and> P u)"}
|
10171
|
275 |
is extensionally equal to @{term"path s P"},
|
10867
|
276 |
where @{term nat_rec} is the predefined primitive recursor on @{typ nat}.
|
10159
|
277 |
*};
|
|
278 |
(*<*)
|
|
279 |
lemma infinity_lemma:
|
9958
|
280 |
"\<lbrakk> P s; \<forall> s. P s \<longrightarrow> (\<exists> t. (s,t)\<in>M \<and> P t) \<rbrakk> \<Longrightarrow>
|
|
281 |
\<exists> p\<in>Paths s. \<forall> i. P(p i)";
|
|
282 |
apply(subgoal_tac
|
|
283 |
"\<exists> p. s = p 0 \<and> (\<forall> i. (p i,p(Suc i))\<in>M \<and> P(p i))");
|
|
284 |
apply(simp add:Paths_def);
|
|
285 |
apply(blast);
|
|
286 |
apply(rule_tac x = "nat_rec s (\<lambda>n t. SOME u. (t,u)\<in>M \<and> P u)" in exI);
|
|
287 |
apply(simp);
|
|
288 |
apply(intro strip);
|
|
289 |
apply(induct_tac i);
|
|
290 |
apply(simp);
|
10000
|
291 |
apply(fast intro:someI2_ex);
|
9958
|
292 |
apply(simp);
|
10000
|
293 |
apply(rule someI2_ex);
|
9958
|
294 |
apply(blast);
|
10000
|
295 |
apply(rule someI2_ex);
|
9958
|
296 |
apply(blast);
|
|
297 |
by(blast);
|
10159
|
298 |
(*>*)
|
9958
|
299 |
|
10159
|
300 |
text{*
|
|
301 |
At last we can prove the opposite direction of @{thm[source]AF_lemma1}:
|
|
302 |
*};
|
|
303 |
|
10866
|
304 |
theorem AF_lemma2: "{s. \<forall> p \<in> Paths s. \<exists> i. p i \<in> A} \<subseteq> lfp(af A)";
|
10159
|
305 |
|
|
306 |
txt{*\noindent
|
10237
|
307 |
The proof is again pointwise and then by contraposition:
|
10159
|
308 |
*};
|
|
309 |
|
9958
|
310 |
apply(rule subsetI);
|
10235
|
311 |
apply(erule contrapos_pp);
|
9958
|
312 |
apply simp;
|
10159
|
313 |
|
|
314 |
txt{*
|
10363
|
315 |
@{subgoals[display,indent=0,goals_limit=1]}
|
10159
|
316 |
Applying the @{thm[source]infinity_lemma} as a destruction rule leaves two subgoals, the second
|
|
317 |
premise of @{thm[source]infinity_lemma} and the original subgoal:
|
|
318 |
*};
|
|
319 |
|
|
320 |
apply(drule infinity_lemma);
|
|
321 |
|
|
322 |
txt{*
|
10363
|
323 |
@{subgoals[display,indent=0,margin=65]}
|
10159
|
324 |
Both are solved automatically:
|
|
325 |
*};
|
9958
|
326 |
|
10159
|
327 |
apply(auto dest:not_in_lfp_afD);
|
|
328 |
done;
|
9958
|
329 |
|
10159
|
330 |
text{*
|
10867
|
331 |
If you find these proofs too complicated, we recommend that you read
|
|
332 |
\S\ref{sec:CTL-revisited}, where we show how inductive definitions lead to
|
10217
|
333 |
simpler arguments.
|
|
334 |
|
|
335 |
The main theorem is proved as for PDL, except that we also derive the
|
|
336 |
necessary equality @{text"lfp(af A) = ..."} by combining
|
|
337 |
@{thm[source]AF_lemma1} and @{thm[source]AF_lemma2} on the spot:
|
10159
|
338 |
*}
|
|
339 |
|
|
340 |
theorem "mc f = {s. s \<Turnstile> f}";
|
|
341 |
apply(induct_tac f);
|
|
342 |
apply(auto simp add: EF_lemma equalityI[OF AF_lemma1 AF_lemma2]);
|
|
343 |
done
|
|
344 |
|
|
345 |
text{*
|
10281
|
346 |
|
10867
|
347 |
The language defined above is not quite CTL\@. The latter also includes an
|
|
348 |
until-operator @{term"EU f g"} with semantics ``there exists a path
|
10281
|
349 |
where @{term f} is true until @{term g} becomes true''. With the help
|
|
350 |
of an auxiliary function
|
|
351 |
*}
|
|
352 |
|
|
353 |
consts until:: "state set \<Rightarrow> state set \<Rightarrow> state \<Rightarrow> state list \<Rightarrow> bool"
|
|
354 |
primrec
|
|
355 |
"until A B s [] = (s \<in> B)"
|
|
356 |
"until A B s (t#p) = (s \<in> A \<and> (s,t) \<in> M \<and> until A B t p)"
|
|
357 |
(*<*)constdefs
|
|
358 |
eusem :: "state set \<Rightarrow> state set \<Rightarrow> state set"
|
|
359 |
"eusem A B \<equiv> {s. \<exists>p. until A B s p}"(*>*)
|
|
360 |
|
|
361 |
text{*\noindent
|
|
362 |
the semantics of @{term EU} is straightforward:
|
|
363 |
@{text[display]"s \<Turnstile> EU f g = (\<exists>p. until A B s p)"}
|
|
364 |
Note that @{term EU} is not definable in terms of the other operators!
|
|
365 |
|
|
366 |
Model checking @{term EU} is again a least fixed point construction:
|
10839
|
367 |
@{text[display]"mc(EU f g) = lfp(\<lambda>T. mc g \<union> mc f \<inter> (M\<inverse> `` T))"}
|
10281
|
368 |
|
10171
|
369 |
\begin{exercise}
|
10281
|
370 |
Extend the datatype of formulae by the above until operator
|
|
371 |
and prove the equivalence between semantics and model checking, i.e.\ that
|
10186
|
372 |
@{prop[display]"mc(EU f g) = {s. s \<Turnstile> EU f g}"}
|
|
373 |
%For readability you may want to annotate {term EU} with its customary syntax
|
|
374 |
%{text[display]"| EU formula formula E[_ U _]"}
|
|
375 |
%which enables you to read and write {text"E[f U g]"} instead of {term"EU f g"}.
|
|
376 |
\end{exercise}
|
10867
|
377 |
For more CTL exercises see, for example, Huth and Ryan \cite{Huth-Ryan-book}.
|
10281
|
378 |
*}
|
|
379 |
|
|
380 |
(*<*)
|
|
381 |
constdefs
|
|
382 |
eufix :: "state set \<Rightarrow> state set \<Rightarrow> state set \<Rightarrow> state set"
|
10839
|
383 |
"eufix A B T \<equiv> B \<union> A \<inter> (M\<inverse> `` T)"
|
10281
|
384 |
|
|
385 |
lemma "lfp(eufix A B) \<subseteq> eusem A B"
|
|
386 |
apply(rule lfp_lowerbound)
|
|
387 |
apply(clarsimp simp add:eusem_def eufix_def);
|
|
388 |
apply(erule disjE);
|
|
389 |
apply(rule_tac x = "[]" in exI);
|
|
390 |
apply simp
|
|
391 |
apply(clarsimp);
|
|
392 |
apply(rule_tac x = "y#xc" in exI);
|
|
393 |
apply simp;
|
|
394 |
done
|
|
395 |
|
|
396 |
lemma mono_eufix: "mono(eufix A B)";
|
|
397 |
apply(simp add: mono_def eufix_def);
|
|
398 |
apply blast;
|
|
399 |
done
|
|
400 |
|
|
401 |
lemma "eusem A B \<subseteq> lfp(eufix A B)";
|
|
402 |
apply(clarsimp simp add:eusem_def);
|
|
403 |
apply(erule rev_mp);
|
|
404 |
apply(rule_tac x = x in spec);
|
|
405 |
apply(induct_tac p);
|
|
406 |
apply(rule ssubst[OF lfp_unfold[OF mono_eufix]]);
|
|
407 |
apply(simp add:eufix_def);
|
|
408 |
apply(clarsimp);
|
|
409 |
apply(rule ssubst[OF lfp_unfold[OF mono_eufix]]);
|
|
410 |
apply(simp add:eufix_def);
|
|
411 |
apply blast;
|
|
412 |
done
|
10178
|
413 |
|
10281
|
414 |
(*
|
|
415 |
constdefs
|
|
416 |
eusem :: "state set \<Rightarrow> state set \<Rightarrow> state set"
|
|
417 |
"eusem A B \<equiv> {s. \<exists>p\<in>Paths s. \<exists>j. p j \<in> B \<and> (\<forall>i < j. p i \<in> A)}"
|
|
418 |
|
|
419 |
axioms
|
|
420 |
M_total: "\<exists>t. (s,t) \<in> M"
|
|
421 |
|
|
422 |
consts apath :: "state \<Rightarrow> (nat \<Rightarrow> state)"
|
|
423 |
primrec
|
|
424 |
"apath s 0 = s"
|
|
425 |
"apath s (Suc i) = (SOME t. (apath s i,t) \<in> M)"
|
|
426 |
|
|
427 |
lemma [iff]: "apath s \<in> Paths s";
|
|
428 |
apply(simp add:Paths_def);
|
|
429 |
apply(blast intro: M_total[THEN someI_ex])
|
|
430 |
done
|
|
431 |
|
|
432 |
constdefs
|
|
433 |
pcons :: "state \<Rightarrow> (nat \<Rightarrow> state) \<Rightarrow> (nat \<Rightarrow> state)"
|
|
434 |
"pcons s p == \<lambda>i. case i of 0 \<Rightarrow> s | Suc j \<Rightarrow> p j"
|
|
435 |
|
|
436 |
lemma pcons_PathI: "[| (s,t) : M; p \<in> Paths t |] ==> pcons s p \<in> Paths s";
|
|
437 |
by(simp add:Paths_def pcons_def split:nat.split);
|
|
438 |
|
|
439 |
lemma "lfp(eufix A B) \<subseteq> eusem A B"
|
|
440 |
apply(rule lfp_lowerbound)
|
|
441 |
apply(clarsimp simp add:eusem_def eufix_def);
|
|
442 |
apply(erule disjE);
|
|
443 |
apply(rule_tac x = "apath x" in bexI);
|
|
444 |
apply(rule_tac x = 0 in exI);
|
|
445 |
apply simp;
|
|
446 |
apply simp;
|
|
447 |
apply(clarify);
|
|
448 |
apply(rule_tac x = "pcons xb p" in bexI);
|
|
449 |
apply(rule_tac x = "j+1" in exI);
|
|
450 |
apply (simp add:pcons_def split:nat.split);
|
|
451 |
apply (simp add:pcons_PathI)
|
|
452 |
done
|
|
453 |
*)
|
|
454 |
(*>*)
|
|
455 |
text{*
|
10186
|
456 |
Let us close this section with a few words about the executability of our model checkers.
|
10159
|
457 |
It is clear that if all sets are finite, they can be represented as lists and the usual
|
|
458 |
set operations are easily implemented. Only @{term lfp} requires a little thought.
|
10885
|
459 |
Fortunately, the HOL Library%
|
|
460 |
\footnote{See theory \isa{While_Combinator_Example}.}
|
|
461 |
provides a theorem stating that
|
|
462 |
in the case of finite sets and a monotone function~@{term F},
|
10867
|
463 |
the value of @{term"lfp F"} can be computed by iterated application of @{term F} to~@{term"{}"} until
|
10242
|
464 |
a fixed point is reached. It is actually possible to generate executable functional programs
|
10159
|
465 |
from HOL definitions, but that is beyond the scope of the tutorial.
|
|
466 |
*}
|
10212
|
467 |
(*<*)end(*>*)
|