doc-src/TutorialI/CTL/document/CTLind.tex
 author nipkow Wed Dec 06 13:22:58 2000 +0100 (2000-12-06) changeset 10608 620647438780 parent 10601 894f845c3dbf child 10617 adc0ed64a120 permissions -rw-r--r--
*** empty log message ***
1 %
2 \begin{isabellebody}%
3 \def\isabellecontext{CTLind}%
4 %
5 \isamarkupsubsection{CTL revisited%
6 }
7 %
8 \begin{isamarkuptext}%
9 \label{sec:CTL-revisited}
10 The purpose of this section is twofold: we want to demonstrate
11 some of the induction principles and heuristics discussed above and we want to
12 show how inductive definitions can simplify proofs.
13 In \S\ref{sec:CTL} we gave a fairly involved proof of the correctness of a
14 model checker for CTL. In particular the proof of the
15 \isa{infinity{\isacharunderscore}lemma} on the way to \isa{AF{\isacharunderscore}lemma{\isadigit{2}}} is not as
16 simple as one might intuitively expect, due to the \isa{SOME} operator
17 involved. Below we give a simpler proof of \isa{AF{\isacharunderscore}lemma{\isadigit{2}}}
18 based on an auxiliary inductive definition.
20 Let us call a (finite or infinite) path \emph{\isa{A}-avoiding} if it does
21 not touch any node in the set \isa{A}. Then \isa{AF{\isacharunderscore}lemma{\isadigit{2}}} says
22 that if no infinite path from some state \isa{s} is \isa{A}-avoiding,
23 then \isa{s\ {\isasymin}\ lfp\ {\isacharparenleft}af\ A{\isacharparenright}}. We prove this by inductively defining the set
24 \isa{Avoid\ s\ A} of states reachable from \isa{s} by a finite \isa{A}-avoiding path:
25 % Second proof of opposite direction, directly by well-founded induction
26 % on the initial segment of M that avoids A.%
27 \end{isamarkuptext}%
28 \isacommand{consts}\ Avoid\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}state\ {\isasymRightarrow}\ state\ set\ {\isasymRightarrow}\ state\ set{\isachardoublequote}\isanewline
29 \isacommand{inductive}\ {\isachardoublequote}Avoid\ s\ A{\isachardoublequote}\isanewline
30 \isakeyword{intros}\ {\isachardoublequote}s\ {\isasymin}\ Avoid\ s\ A{\isachardoublequote}\isanewline
31 \ \ \ \ \ \ \ {\isachardoublequote}{\isasymlbrakk}\ t\ {\isasymin}\ Avoid\ s\ A{\isacharsemicolon}\ t\ {\isasymnotin}\ A{\isacharsemicolon}\ {\isacharparenleft}t{\isacharcomma}u{\isacharparenright}\ {\isasymin}\ M\ {\isasymrbrakk}\ {\isasymLongrightarrow}\ u\ {\isasymin}\ Avoid\ s\ A{\isachardoublequote}%
32 \begin{isamarkuptext}%
33 It is easy to see that for any infinite \isa{A}-avoiding path \isa{f}
34 with \isa{f\ {\isadigit{0}}\ {\isasymin}\ Avoid\ s\ A} there is an infinite \isa{A}-avoiding path
35 starting with \isa{s} because (by definition of \isa{Avoid}) there is a
36 finite \isa{A}-avoiding path from \isa{s} to \isa{f\ {\isadigit{0}}}.
37 The proof is by induction on \isa{f\ {\isadigit{0}}\ {\isasymin}\ Avoid\ s\ A}. However,
38 this requires the following
39 reformulation, as explained in \S\ref{sec:ind-var-in-prems} above;
40 the \isa{rule{\isacharunderscore}format} directive undoes the reformulation after the proof.%
41 \end{isamarkuptext}%
42 \isacommand{lemma}\ ex{\isacharunderscore}infinite{\isacharunderscore}path{\isacharbrackleft}rule{\isacharunderscore}format{\isacharbrackright}{\isacharcolon}\isanewline
43 \ \ {\isachardoublequote}t\ {\isasymin}\ Avoid\ s\ A\ \ {\isasymLongrightarrow}\isanewline
44 \ \ \ {\isasymforall}f{\isasymin}Paths\ t{\isachardot}\ {\isacharparenleft}{\isasymforall}i{\isachardot}\ f\ i\ {\isasymnotin}\ A{\isacharparenright}\ {\isasymlongrightarrow}\ {\isacharparenleft}{\isasymexists}p{\isasymin}Paths\ s{\isachardot}\ {\isasymforall}i{\isachardot}\ p\ i\ {\isasymnotin}\ A{\isacharparenright}{\isachardoublequote}\isanewline
45 \isacommand{apply}{\isacharparenleft}erule\ Avoid{\isachardot}induct{\isacharparenright}\isanewline
46 \ \isacommand{apply}{\isacharparenleft}blast{\isacharparenright}\isanewline
47 \isacommand{apply}{\isacharparenleft}clarify{\isacharparenright}\isanewline
48 \isacommand{apply}{\isacharparenleft}drule{\isacharunderscore}tac\ x\ {\isacharequal}\ {\isachardoublequote}{\isasymlambda}i{\isachardot}\ case\ i\ of\ {\isadigit{0}}\ {\isasymRightarrow}\ t\ {\isacharbar}\ Suc\ i\ {\isasymRightarrow}\ f\ i{\isachardoublequote}\ \isakeyword{in}\ bspec{\isacharparenright}\isanewline
49 \isacommand{apply}{\isacharparenleft}simp{\isacharunderscore}all\ add{\isacharcolon}Paths{\isacharunderscore}def\ split{\isacharcolon}nat{\isachardot}split{\isacharparenright}\isanewline
50 \isacommand{done}%
51 \begin{isamarkuptext}%
52 \noindent
53 The base case (\isa{t\ {\isacharequal}\ s}) is trivial (\isa{blast}).
54 In the induction step, we have an infinite \isa{A}-avoiding path \isa{f}
55 starting from \isa{u}, a successor of \isa{t}. Now we simply instantiate
56 the \isa{{\isasymforall}f{\isasymin}Paths\ t} in the induction hypothesis by the path starting with
57 \isa{t} and continuing with \isa{f}. That is what the above $\lambda$-term
58 expresses. That fact that this is a path starting with \isa{t} and that
59 the instantiated induction hypothesis implies the conclusion is shown by
60 simplification.
62 Now we come to the key lemma. It says that if \isa{t} can be reached by a
63 finite \isa{A}-avoiding path from \isa{s}, then \isa{t\ {\isasymin}\ lfp\ {\isacharparenleft}af\ A{\isacharparenright}},
64 provided there is no infinite \isa{A}-avoiding path starting from \isa{s}.%
65 \end{isamarkuptext}%
66 \isacommand{lemma}\ Avoid{\isacharunderscore}in{\isacharunderscore}lfp{\isacharbrackleft}rule{\isacharunderscore}format{\isacharparenleft}no{\isacharunderscore}asm{\isacharparenright}{\isacharbrackright}{\isacharcolon}\isanewline
67 \ \ {\isachardoublequote}{\isasymforall}p{\isasymin}Paths\ s{\isachardot}\ {\isasymexists}i{\isachardot}\ p\ i\ {\isasymin}\ A\ {\isasymLongrightarrow}\ t\ {\isasymin}\ Avoid\ s\ A\ {\isasymlongrightarrow}\ t\ {\isasymin}\ lfp{\isacharparenleft}af\ A{\isacharparenright}{\isachardoublequote}%
68 \begin{isamarkuptxt}%
69 \noindent
70 The trick is not to induct on \isa{t\ {\isasymin}\ Avoid\ s\ A}, as already the base
71 case would be a problem, but to proceed by well-founded induction \isa{t}. Hence \isa{t\ {\isasymin}\ Avoid\ s\ A} needs to be brought into the conclusion as
72 well, which the directive \isa{rule{\isacharunderscore}format} undoes at the end (see below).
73 But induction with respect to which well-founded relation? The restriction
74 of \isa{M} to \isa{Avoid\ s\ A}:
75 \begin{isabelle}%
76 \ \ \ \ \ {\isacharbraceleft}{\isacharparenleft}y{\isacharcomma}\ x{\isacharparenright}{\isachardot}\ {\isacharparenleft}x{\isacharcomma}\ y{\isacharparenright}\ {\isasymin}\ M\ {\isasymand}\ x\ {\isasymin}\ Avoid\ s\ A\ {\isasymand}\ y\ {\isasymin}\ Avoid\ s\ A\ {\isasymand}\ x\ {\isasymnotin}\ A{\isacharbraceright}%
77 \end{isabelle}
78 As we shall see in a moment, the absence of infinite \isa{A}-avoiding paths
79 starting from \isa{s} implies well-foundedness of this relation. For the
80 moment we assume this and proceed with the induction:%
81 \end{isamarkuptxt}%
82 \isacommand{apply}{\isacharparenleft}subgoal{\isacharunderscore}tac\isanewline
83 \ \ {\isachardoublequote}wf{\isacharbraceleft}{\isacharparenleft}y{\isacharcomma}x{\isacharparenright}{\isachardot}\ {\isacharparenleft}x{\isacharcomma}y{\isacharparenright}{\isasymin}M\ {\isasymand}\ x\ {\isasymin}\ Avoid\ s\ A\ {\isasymand}\ y\ {\isasymin}\ Avoid\ s\ A\ {\isasymand}\ x\ {\isasymnotin}\ A{\isacharbraceright}{\isachardoublequote}{\isacharparenright}\isanewline
84 \ \isacommand{apply}{\isacharparenleft}erule{\isacharunderscore}tac\ a\ {\isacharequal}\ t\ \isakeyword{in}\ wf{\isacharunderscore}induct{\isacharparenright}\isanewline
85 \ \isacommand{apply}{\isacharparenleft}clarsimp{\isacharparenright}%
86 \begin{isamarkuptxt}%
87 \noindent
88 Now can assume additionally (induction hypothesis) that if \isa{t\ {\isasymnotin}\ A}
89 then all successors of \isa{t} that are in \isa{Avoid\ s\ A} are in
90 \isa{lfp\ {\isacharparenleft}af\ A{\isacharparenright}}. To prove the actual goal we unfold \isa{lfp} once. Now
91 we have to prove that \isa{t} is in \isa{A} or all successors of \isa{t} are in \isa{lfp\ {\isacharparenleft}af\ A{\isacharparenright}}. If \isa{t} is not in \isa{A}, the second
92 \isa{Avoid}-rule implies that all successors of \isa{t} are in
93 \isa{Avoid\ s\ A} (because we also assume \isa{t\ {\isasymin}\ Avoid\ s\ A}), and
94 hence, by the induction hypothesis, all successors of \isa{t} are indeed in
95 \isa{lfp\ {\isacharparenleft}af\ A{\isacharparenright}}. Mechanically:%
96 \end{isamarkuptxt}%
97 \ \isacommand{apply}{\isacharparenleft}rule\ ssubst\ {\isacharbrackleft}OF\ lfp{\isacharunderscore}unfold{\isacharbrackleft}OF\ mono{\isacharunderscore}af{\isacharbrackright}{\isacharbrackright}{\isacharparenright}\isanewline
98 \ \isacommand{apply}{\isacharparenleft}simp\ only{\isacharcolon}\ af{\isacharunderscore}def{\isacharparenright}\isanewline
99 \ \isacommand{apply}{\isacharparenleft}blast\ intro{\isacharcolon}Avoid{\isachardot}intros{\isacharparenright}%
100 \begin{isamarkuptxt}%
101 Having proved the main goal we return to the proof obligation that the above
102 relation is indeed well-founded. This is proved by contraposition: we assume
103 the relation is not well-founded. Thus there exists an infinite \isa{A}-avoiding path all in \isa{Avoid\ s\ A}, by theorem
104 \isa{wf{\isacharunderscore}iff{\isacharunderscore}no{\isacharunderscore}infinite{\isacharunderscore}down{\isacharunderscore}chain}:
105 \begin{isabelle}%
106 \ \ \ \ \ wf\ r\ {\isacharequal}\ {\isacharparenleft}{\isasymnot}\ {\isacharparenleft}{\isasymexists}f{\isachardot}\ {\isasymforall}i{\isachardot}\ {\isacharparenleft}f\ {\isacharparenleft}Suc\ i{\isacharparenright}{\isacharcomma}\ f\ i{\isacharparenright}\ {\isasymin}\ r{\isacharparenright}{\isacharparenright}%
107 \end{isabelle}
108 From lemma \isa{ex{\isacharunderscore}infinite{\isacharunderscore}path} the existence of an infinite
109 \isa{A}-avoiding path starting in \isa{s} follows, just as required for
110 the contraposition.%
111 \end{isamarkuptxt}%
112 \isacommand{apply}{\isacharparenleft}erule\ contrapos{\isacharunderscore}pp{\isacharparenright}\isanewline
113 \isacommand{apply}{\isacharparenleft}simp\ add{\isacharcolon}wf{\isacharunderscore}iff{\isacharunderscore}no{\isacharunderscore}infinite{\isacharunderscore}down{\isacharunderscore}chain{\isacharparenright}\isanewline
114 \isacommand{apply}{\isacharparenleft}erule\ exE{\isacharparenright}\isanewline
115 \isacommand{apply}{\isacharparenleft}rule\ ex{\isacharunderscore}infinite{\isacharunderscore}path{\isacharparenright}\isanewline
116 \isacommand{apply}{\isacharparenleft}auto\ simp\ add{\isacharcolon}Paths{\isacharunderscore}def{\isacharparenright}\isanewline
117 \isacommand{done}%
118 \begin{isamarkuptext}%
119 The \isa{{\isacharparenleft}no{\isacharunderscore}asm{\isacharparenright}} modifier of the \isa{rule{\isacharunderscore}format} directive means
120 that the assumption is left unchanged---otherwise the \isa{{\isasymforall}p} is turned
121 into a \isa{{\isasymAnd}p}, which would complicate matters below. As it is,
122 \isa{Avoid{\isacharunderscore}in{\isacharunderscore}lfp} is now
123 \begin{isabelle}%
124 \ \ \ \ \ {\isasymlbrakk}{\isasymforall}p{\isasymin}Paths\ s{\isachardot}\ {\isasymexists}i{\isachardot}\ p\ i\ {\isasymin}\ A{\isacharsemicolon}\ t\ {\isasymin}\ Avoid\ s\ A{\isasymrbrakk}\ {\isasymLongrightarrow}\ t\ {\isasymin}\ lfp\ {\isacharparenleft}af\ A{\isacharparenright}%
125 \end{isabelle}
126 The main theorem is simply the corollary where \isa{t\ {\isacharequal}\ s},
127 in which case the assumption \isa{t\ {\isasymin}\ Avoid\ s\ A} is trivially true
128 by the first \isa{Avoid}-rule). Isabelle confirms this:%
129 \end{isamarkuptext}%
130 \isacommand{theorem}\ AF{\isacharunderscore}lemma{\isadigit{2}}{\isacharcolon}\isanewline
131 \ \ {\isachardoublequote}{\isacharbraceleft}s{\isachardot}\ {\isasymforall}p\ {\isasymin}\ Paths\ s{\isachardot}\ {\isasymexists}\ i{\isachardot}\ p\ i\ {\isasymin}\ A{\isacharbraceright}\ {\isasymsubseteq}\ lfp{\isacharparenleft}af\ A{\isacharparenright}{\isachardoublequote}\isanewline
132 \isacommand{by}{\isacharparenleft}auto\ elim{\isacharcolon}Avoid{\isacharunderscore}in{\isacharunderscore}lfp\ intro{\isacharcolon}Avoid{\isachardot}intros{\isacharparenright}\isanewline
133 \isanewline
134 \end{isabellebody}%
135 %%% Local Variables:
136 %%% mode: latex
137 %%% TeX-master: "root"
138 %%% End: