121 txt\<open> |
121 txt\<open> |
122 @{subgoals[display,indent=0,margin=70,goals_limit=1]} |
122 @{subgoals[display,indent=0,margin=70,goals_limit=1]} |
123 In this remaining case, we set @{term t} to @{term"p(1::nat)"}. |
123 In this remaining case, we set @{term t} to @{term"p(1::nat)"}. |
124 The rest is automatic, which is surprising because it involves |
124 The rest is automatic, which is surprising because it involves |
125 finding the instantiation @{term"\<lambda>i::nat. p(i+1)"} |
125 finding the instantiation @{term"\<lambda>i::nat. p(i+1)"} |
126 for @{text"\<forall>p"}. |
126 for \<open>\<forall>p\<close>. |
127 \<close> |
127 \<close> |
128 |
128 |
129 apply(erule_tac x = "p 1" in allE) |
129 apply(erule_tac x = "p 1" in allE) |
130 apply(auto) |
130 apply(auto) |
131 done |
131 done |
165 "path s Q 0 = s" | |
165 "path s Q 0 = s" | |
166 "path s Q (Suc n) = (SOME t. (path s Q n,t) \<in> M \<and> Q t)" |
166 "path s Q (Suc n) = (SOME t. (path s Q n,t) \<in> M \<and> Q t)" |
167 |
167 |
168 text\<open>\noindent |
168 text\<open>\noindent |
169 Element @{term"n+1::nat"} on this path is some arbitrary successor |
169 Element @{term"n+1::nat"} on this path is some arbitrary successor |
170 @{term t} of element @{term n} such that @{term"Q t"} holds. Remember that @{text"SOME t. R t"} |
170 @{term t} of element @{term n} such that @{term"Q t"} holds. Remember that \<open>SOME t. R t\<close> |
171 is some arbitrary but fixed @{term t} such that @{prop"R t"} holds (see \S\ref{sec:SOME}). Of |
171 is some arbitrary but fixed @{term t} such that @{prop"R t"} holds (see \S\ref{sec:SOME}). Of |
172 course, such a @{term t} need not exist, but that is of no |
172 course, such a @{term t} need not exist, but that is of no |
173 concern to us since we will only use @{const path} when a |
173 concern to us since we will only use @{const path} when a |
174 suitable @{term t} does exist. |
174 suitable @{term t} does exist. |
175 |
175 |
216 @{subgoals[display,indent=0,margin=70,goals_limit=1]} |
216 @{subgoals[display,indent=0,margin=70,goals_limit=1]} |
217 The conclusion looks exceedingly trivial: after all, @{term t} is chosen such that @{prop"(s,t)\<in>M"} |
217 The conclusion looks exceedingly trivial: after all, @{term t} is chosen such that @{prop"(s,t)\<in>M"} |
218 holds. However, we first have to show that such a @{term t} actually exists! This reasoning |
218 holds. However, we first have to show that such a @{term t} actually exists! This reasoning |
219 is embodied in the theorem @{thm[source]someI2_ex}: |
219 is embodied in the theorem @{thm[source]someI2_ex}: |
220 @{thm[display,eta_contract=false]someI2_ex} |
220 @{thm[display,eta_contract=false]someI2_ex} |
221 When we apply this theorem as an introduction rule, @{text"?P x"} becomes |
221 When we apply this theorem as an introduction rule, \<open>?P x\<close> becomes |
222 @{prop"(s, x) \<in> M \<and> Q x"} and @{text"?Q x"} becomes @{prop"(s,x) \<in> M"} and we have to prove |
222 @{prop"(s, x) \<in> M \<and> Q x"} and \<open>?Q x\<close> becomes @{prop"(s,x) \<in> M"} and we have to prove |
223 two subgoals: @{prop"\<exists>a. (s, a) \<in> M \<and> Q a"}, which follows from the assumptions, and |
223 two subgoals: @{prop"\<exists>a. (s, a) \<in> M \<and> Q a"}, which follows from the assumptions, and |
224 @{prop"(s, x) \<in> M \<and> Q x \<Longrightarrow> (s,x) \<in> M"}, which is trivial. Thus it is not surprising that |
224 @{prop"(s, x) \<in> M \<and> Q x \<Longrightarrow> (s,x) \<in> M"}, which is trivial. Thus it is not surprising that |
225 @{text fast} can prove the base case quickly: |
225 \<open>fast\<close> can prove the base case quickly: |
226 \<close> |
226 \<close> |
227 |
227 |
228 apply(fast intro: someI2_ex) |
228 apply(fast intro: someI2_ex) |
229 |
229 |
230 txt\<open>\noindent |
230 txt\<open>\noindent |
231 What is worth noting here is that we have used \methdx{fast} rather than |
231 What is worth noting here is that we have used \methdx{fast} rather than |
232 @{text blast}. The reason is that @{text blast} would fail because it cannot |
232 \<open>blast\<close>. The reason is that \<open>blast\<close> would fail because it cannot |
233 cope with @{thm[source]someI2_ex}: unifying its conclusion with the current |
233 cope with @{thm[source]someI2_ex}: unifying its conclusion with the current |
234 subgoal is non-trivial because of the nested schematic variables. For |
234 subgoal is non-trivial because of the nested schematic variables. For |
235 efficiency reasons @{text blast} does not even attempt such unifications. |
235 efficiency reasons \<open>blast\<close> does not even attempt such unifications. |
236 Although @{text fast} can in principle cope with complicated unification |
236 Although \<open>fast\<close> can in principle cope with complicated unification |
237 problems, in practice the number of unifiers arising is often prohibitive and |
237 problems, in practice the number of unifiers arising is often prohibitive and |
238 the offending rule may need to be applied explicitly rather than |
238 the offending rule may need to be applied explicitly rather than |
239 automatically. This is what happens in the step case. |
239 automatically. This is what happens in the step case. |
240 |
240 |
241 The induction step is similar, but more involved, because now we face nested |
241 The induction step is similar, but more involved, because now we face nested |
242 occurrences of @{text SOME}. As a result, @{text fast} is no longer able to |
242 occurrences of \<open>SOME\<close>. As a result, \<open>fast\<close> is no longer able to |
243 solve the subgoal and we apply @{thm[source]someI2_ex} by hand. We merely |
243 solve the subgoal and we apply @{thm[source]someI2_ex} by hand. We merely |
244 show the proof commands but do not describe the details: |
244 show the proof commands but do not describe the details: |
245 \<close> |
245 \<close> |
246 |
246 |
247 apply(simp) |
247 apply(simp) |
318 If you find these proofs too complicated, we recommend that you read |
318 If you find these proofs too complicated, we recommend that you read |
319 \S\ref{sec:CTL-revisited}, where we show how inductive definitions lead to |
319 \S\ref{sec:CTL-revisited}, where we show how inductive definitions lead to |
320 simpler arguments. |
320 simpler arguments. |
321 |
321 |
322 The main theorem is proved as for PDL, except that we also derive the |
322 The main theorem is proved as for PDL, except that we also derive the |
323 necessary equality @{text"lfp(af A) = ..."} by combining |
323 necessary equality \<open>lfp(af A) = ...\<close> by combining |
324 @{thm[source]AF_lemma1} and @{thm[source]AF_lemma2} on the spot: |
324 @{thm[source]AF_lemma1} and @{thm[source]AF_lemma2} on the spot: |
325 \<close> |
325 \<close> |
326 |
326 |
327 theorem "mc f = {s. s \<Turnstile> f}" |
327 theorem "mc f = {s. s \<Turnstile> f}" |
328 apply(induct_tac f) |
328 apply(induct_tac f) |
437 |
437 |
438 text\<open>Let us close this section with a few words about the executability of |
438 text\<open>Let us close this section with a few words about the executability of |
439 our model checkers. It is clear that if all sets are finite, they can be |
439 our model checkers. It is clear that if all sets are finite, they can be |
440 represented as lists and the usual set operations are easily |
440 represented as lists and the usual set operations are easily |
441 implemented. Only @{const lfp} requires a little thought. Fortunately, theory |
441 implemented. Only @{const lfp} requires a little thought. Fortunately, theory |
442 @{text While_Combinator} in the Library~@{cite "HOL-Library"} provides a |
442 \<open>While_Combinator\<close> in the Library~@{cite "HOL-Library"} provides a |
443 theorem stating that in the case of finite sets and a monotone |
443 theorem stating that in the case of finite sets and a monotone |
444 function~@{term F}, the value of \mbox{@{term"lfp F"}} can be computed by |
444 function~@{term F}, the value of \mbox{@{term"lfp F"}} can be computed by |
445 iterated application of @{term F} to~@{term"{}"} until a fixed point is |
445 iterated application of @{term F} to~@{term"{}"} until a fixed point is |
446 reached. It is actually possible to generate executable functional programs |
446 reached. It is actually possible to generate executable functional programs |
447 from HOL definitions, but that is beyond the scope of the tutorial.% |
447 from HOL definitions, but that is beyond the scope of the tutorial.% |