wenzelm@10267: % wenzelm@10267: \begin{isabellebody}% wenzelm@10267: \def\isabellecontext{CTLind}% wenzelm@11866: \isamarkupfalse% wenzelm@10267: % paulson@10878: \isamarkupsubsection{CTL Revisited% wenzelm@10395: } wenzelm@11866: \isamarkuptrue% wenzelm@10267: % wenzelm@10267: \begin{isamarkuptext}% wenzelm@10267: \label{sec:CTL-revisited} paulson@11494: \index{CTL|(}% paulson@11494: The purpose of this section is twofold: to demonstrate paulson@11494: some of the induction principles and heuristics discussed above and to nipkow@10283: show how inductive definitions can simplify proofs. wenzelm@10267: In \S\ref{sec:CTL} we gave a fairly involved proof of the correctness of a paulson@10795: model checker for CTL\@. In particular the proof of the wenzelm@10267: \isa{infinity{\isacharunderscore}lemma} on the way to \isa{AF{\isacharunderscore}lemma{\isadigit{2}}} is not as paulson@11494: simple as one might expect, due to the \isa{SOME} operator nipkow@10283: involved. Below we give a simpler proof of \isa{AF{\isacharunderscore}lemma{\isadigit{2}}} nipkow@10283: based on an auxiliary inductive definition. wenzelm@10267: wenzelm@10267: Let us call a (finite or infinite) path \emph{\isa{A}-avoiding} if it does wenzelm@10267: not touch any node in the set \isa{A}. Then \isa{AF{\isacharunderscore}lemma{\isadigit{2}}} says wenzelm@10267: that if no infinite path from some state \isa{s} is \isa{A}-avoiding, wenzelm@10267: then \isa{s\ {\isasymin}\ lfp\ {\isacharparenleft}af\ A{\isacharparenright}}. We prove this by inductively defining the set wenzelm@10267: \isa{Avoid\ s\ A} of states reachable from \isa{s} by a finite \isa{A}-avoiding path: wenzelm@10267: % Second proof of opposite direction, directly by well-founded induction wenzelm@10267: % on the initial segment of M that avoids A.% wenzelm@10267: \end{isamarkuptext}% wenzelm@11866: \isamarkuptrue% wenzelm@10267: \isacommand{consts}\ Avoid\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}state\ {\isasymRightarrow}\ state\ set\ {\isasymRightarrow}\ state\ set{\isachardoublequote}\isanewline wenzelm@11866: \isamarkupfalse% wenzelm@10267: \isacommand{inductive}\ {\isachardoublequote}Avoid\ s\ A{\isachardoublequote}\isanewline wenzelm@10267: \isakeyword{intros}\ {\isachardoublequote}s\ {\isasymin}\ Avoid\ s\ A{\isachardoublequote}\isanewline wenzelm@11866: \ \ \ \ \ \ \ {\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}\isamarkupfalse% wenzelm@11866: % wenzelm@10267: \begin{isamarkuptext}% wenzelm@10267: It is easy to see that for any infinite \isa{A}-avoiding path \isa{f} nipkow@12492: with \isa{f\ {\isadigit{0}}\ {\isasymin}\ Avoid\ s\ A} there is an infinite \isa{A}-avoiding path wenzelm@10267: starting with \isa{s} because (by definition of \isa{Avoid}) there is a nipkow@12492: finite \isa{A}-avoiding path from \isa{s} to \isa{f\ {\isadigit{0}}}. nipkow@12492: The proof is by induction on \isa{f\ {\isadigit{0}}\ {\isasymin}\ Avoid\ s\ A}. However, wenzelm@10267: this requires the following wenzelm@10267: reformulation, as explained in \S\ref{sec:ind-var-in-prems} above; wenzelm@10267: the \isa{rule{\isacharunderscore}format} directive undoes the reformulation after the proof.% wenzelm@10267: \end{isamarkuptext}% wenzelm@11866: \isamarkuptrue% wenzelm@10267: \isacommand{lemma}\ ex{\isacharunderscore}infinite{\isacharunderscore}path{\isacharbrackleft}rule{\isacharunderscore}format{\isacharbrackright}{\isacharcolon}\isanewline wenzelm@10267: \ \ {\isachardoublequote}t\ {\isasymin}\ Avoid\ s\ A\ \ {\isasymLongrightarrow}\isanewline wenzelm@10267: \ \ \ {\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 wenzelm@11866: \isamarkupfalse% wenzelm@10267: \isacommand{apply}{\isacharparenleft}erule\ Avoid{\isachardot}induct{\isacharparenright}\isanewline wenzelm@11866: \ \isamarkupfalse% wenzelm@11866: \isacommand{apply}{\isacharparenleft}blast{\isacharparenright}\isanewline wenzelm@11866: \isamarkupfalse% wenzelm@10267: \isacommand{apply}{\isacharparenleft}clarify{\isacharparenright}\isanewline wenzelm@11866: \isamarkupfalse% wenzelm@10267: \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 wenzelm@11866: \isamarkupfalse% wenzelm@12815: \isacommand{apply}{\isacharparenleft}simp{\isacharunderscore}all\ add{\isacharcolon}\ Paths{\isacharunderscore}def\ split{\isacharcolon}\ nat{\isachardot}split{\isacharparenright}\isanewline wenzelm@11866: \isamarkupfalse% wenzelm@11866: \isacommand{done}\isamarkupfalse% wenzelm@11866: % wenzelm@10267: \begin{isamarkuptext}% wenzelm@10267: \noindent paulson@11494: The base case (\isa{t\ {\isacharequal}\ s}) is trivial and proved by \isa{blast}. wenzelm@10267: In the induction step, we have an infinite \isa{A}-avoiding path \isa{f} wenzelm@10267: starting from \isa{u}, a successor of \isa{t}. Now we simply instantiate wenzelm@10267: the \isa{{\isasymforall}f{\isasymin}Paths\ t} in the induction hypothesis by the path starting with wenzelm@10267: \isa{t} and continuing with \isa{f}. That is what the above $\lambda$-term paulson@10878: expresses. Simplification shows that this is a path starting with \isa{t} paulson@10878: and that the instantiated induction hypothesis implies the conclusion. wenzelm@10267: nipkow@11196: Now we come to the key lemma. Assuming that no infinite \isa{A}-avoiding nipkow@11277: path starts from \isa{s}, we want to show \isa{s\ {\isasymin}\ lfp\ {\isacharparenleft}af\ A{\isacharparenright}}. For the nipkow@11277: inductive proof this must be generalized to the statement that every point \isa{t} paulson@11494: ``between'' \isa{s} and \isa{A}, in other words all of \isa{Avoid\ s\ A}, nipkow@11196: is contained in \isa{lfp\ {\isacharparenleft}af\ A{\isacharparenright}}:% wenzelm@10267: \end{isamarkuptext}% wenzelm@11866: \isamarkuptrue% wenzelm@10267: \isacommand{lemma}\ Avoid{\isacharunderscore}in{\isacharunderscore}lfp{\isacharbrackleft}rule{\isacharunderscore}format{\isacharparenleft}no{\isacharunderscore}asm{\isacharparenright}{\isacharbrackright}{\isacharcolon}\isanewline wenzelm@11866: \ \ {\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}\isamarkupfalse% wenzelm@11866: % wenzelm@10267: \begin{isamarkuptxt}% wenzelm@10267: \noindent nipkow@11196: The proof is by induction on the ``distance'' between \isa{t} and \isa{A}. Remember that \isa{lfp\ {\isacharparenleft}af\ A{\isacharparenright}\ {\isacharequal}\ A\ {\isasymunion}\ M{\isasyminverse}\ {\isacharbackquote}{\isacharbackquote}\ lfp\ {\isacharparenleft}af\ A{\isacharparenright}}. nipkow@11196: If \isa{t} is already in \isa{A}, then \isa{t\ {\isasymin}\ lfp\ {\isacharparenleft}af\ A{\isacharparenright}} is nipkow@11196: trivial. If \isa{t} is not in \isa{A} but all successors are in nipkow@11196: \isa{lfp\ {\isacharparenleft}af\ A{\isacharparenright}} (induction hypothesis), then \isa{t\ {\isasymin}\ lfp\ {\isacharparenleft}af\ A{\isacharparenright}} is nipkow@11196: again trivial. nipkow@11196: nipkow@11196: The formal counterpart of this proof sketch is a well-founded induction paulson@11494: on~\isa{M} restricted to \isa{Avoid\ s\ A\ {\isacharminus}\ A}, roughly speaking: wenzelm@10267: \begin{isabelle}% nipkow@11196: \ \ \ \ \ {\isacharbraceleft}{\isacharparenleft}y{\isacharcomma}\ x{\isacharparenright}{\isachardot}\ {\isacharparenleft}x{\isacharcomma}\ y{\isacharparenright}\ {\isasymin}\ M\ {\isasymand}\ x\ {\isasymin}\ Avoid\ s\ A\ {\isasymand}\ x\ {\isasymnotin}\ A{\isacharbraceright}% wenzelm@10267: \end{isabelle} nipkow@11277: As we shall see presently, the absence of infinite \isa{A}-avoiding paths wenzelm@10267: starting from \isa{s} implies well-foundedness of this relation. For the wenzelm@10267: moment we assume this and proceed with the induction:% wenzelm@10267: \end{isamarkuptxt}% wenzelm@11866: \isamarkuptrue% nipkow@11196: \isacommand{apply}{\isacharparenleft}subgoal{\isacharunderscore}tac\ {\isachardoublequote}wf{\isacharbraceleft}{\isacharparenleft}y{\isacharcomma}x{\isacharparenright}{\isachardot}\ {\isacharparenleft}x{\isacharcomma}y{\isacharparenright}\ {\isasymin}\ M\ {\isasymand}\ x\ {\isasymin}\ Avoid\ s\ A\ {\isasymand}\ x\ {\isasymnotin}\ A{\isacharbraceright}{\isachardoublequote}{\isacharparenright}\isanewline wenzelm@11866: \ \isamarkupfalse% wenzelm@11866: \isacommand{apply}{\isacharparenleft}erule{\isacharunderscore}tac\ a\ {\isacharequal}\ t\ \isakeyword{in}\ wf{\isacharunderscore}induct{\isacharparenright}\isanewline wenzelm@11866: \ \isamarkupfalse% wenzelm@11866: \isacommand{apply}{\isacharparenleft}clarsimp{\isacharparenright}\isamarkupfalse% wenzelm@11866: \isamarkupfalse% wenzelm@11866: % wenzelm@10267: \begin{isamarkuptxt}% wenzelm@10267: \noindent paulson@10878: \begin{isabelle}% nipkow@13623: \ {\isadigit{1}}{\isachardot}\ {\isasymAnd}t{\isachardot}\ {\isasymlbrakk}{\isasymforall}p{\isasymin}Paths\ s{\isachardot}\ {\isasymexists}i{\isachardot}\ p\ i\ {\isasymin}\ A{\isacharsemicolon}\isanewline paulson@14379: \isaindent{\ {\isadigit{1}}{\isachardot}\ {\isasymAnd}t{\isachardot}\ \ }{\isasymforall}y{\isachardot}\ {\isacharparenleft}t{\isacharcomma}\ y{\isacharparenright}\ {\isasymin}\ M\ {\isasymand}\ t\ {\isasymnotin}\ A\ {\isasymlongrightarrow}\isanewline paulson@14379: \isaindent{\ {\isadigit{1}}{\isachardot}\ {\isasymAnd}t{\isachardot}\ \ {\isasymforall}y{\isachardot}\ }y\ {\isasymin}\ Avoid\ s\ A\ {\isasymlongrightarrow}\ y\ {\isasymin}\ lfp\ {\isacharparenleft}af\ A{\isacharparenright}{\isacharsemicolon}\isanewline paulson@14379: \isaindent{\ {\isadigit{1}}{\isachardot}\ {\isasymAnd}t{\isachardot}\ \ }t\ {\isasymin}\ Avoid\ s\ A{\isasymrbrakk}\isanewline nipkow@11196: \isaindent{\ {\isadigit{1}}{\isachardot}\ {\isasymAnd}t{\isachardot}\ }{\isasymLongrightarrow}\ t\ {\isasymin}\ lfp\ {\isacharparenleft}af\ A{\isacharparenright}\isanewline paulson@10878: \ {\isadigit{2}}{\isachardot}\ {\isasymforall}p{\isasymin}Paths\ s{\isachardot}\ {\isasymexists}i{\isachardot}\ p\ i\ {\isasymin}\ A\ {\isasymLongrightarrow}\isanewline nipkow@11196: \isaindent{\ {\isadigit{2}}{\isachardot}\ }wf\ {\isacharbraceleft}{\isacharparenleft}y{\isacharcomma}\ x{\isacharparenright}{\isachardot}\ {\isacharparenleft}x{\isacharcomma}\ y{\isacharparenright}\ {\isasymin}\ M\ {\isasymand}\ x\ {\isasymin}\ Avoid\ s\ A\ {\isasymand}\ x\ {\isasymnotin}\ A{\isacharbraceright}% paulson@10878: \end{isabelle} paulson@10878: Now the induction hypothesis states that if \isa{t\ {\isasymnotin}\ A} wenzelm@10267: then all successors of \isa{t} that are in \isa{Avoid\ s\ A} are in nipkow@11196: \isa{lfp\ {\isacharparenleft}af\ A{\isacharparenright}}. Unfolding \isa{lfp} in the conclusion of the first nipkow@11196: subgoal once, we have to prove that \isa{t} is in \isa{A} or all successors paulson@11494: of \isa{t} are in \isa{lfp\ {\isacharparenleft}af\ A{\isacharparenright}}. But if \isa{t} is not in \isa{A}, nipkow@11196: the second wenzelm@10267: \isa{Avoid}-rule implies that all successors of \isa{t} are in paulson@11494: \isa{Avoid\ s\ A}, because we also assume \isa{t\ {\isasymin}\ Avoid\ s\ A}. paulson@11494: Hence, by the induction hypothesis, all successors of \isa{t} are indeed in wenzelm@10267: \isa{lfp\ {\isacharparenleft}af\ A{\isacharparenright}}. Mechanically:% wenzelm@10267: \end{isamarkuptxt}% wenzelm@11866: \ \isamarkuptrue% wenzelm@11866: \isacommand{apply}{\isacharparenleft}subst\ lfp{\isacharunderscore}unfold{\isacharbrackleft}OF\ mono{\isacharunderscore}af{\isacharbrackright}{\isacharparenright}\isanewline wenzelm@11866: \ \isamarkupfalse% wenzelm@11866: \isacommand{apply}{\isacharparenleft}simp\ {\isacharparenleft}no{\isacharunderscore}asm{\isacharparenright}\ add{\isacharcolon}\ af{\isacharunderscore}def{\isacharparenright}\isanewline wenzelm@11866: \ \isamarkupfalse% wenzelm@12815: \isacommand{apply}{\isacharparenleft}blast\ intro{\isacharcolon}\ Avoid{\isachardot}intros{\isacharparenright}\isamarkupfalse% wenzelm@11866: % wenzelm@10267: \begin{isamarkuptxt}% paulson@11494: Having proved the main goal, we return to the proof obligation that the paulson@11494: relation used above is indeed well-founded. This is proved by contradiction: if paulson@10878: the relation is not well-founded then there exists an infinite \isa{A}-avoiding path all in \isa{Avoid\ s\ A}, by theorem wenzelm@10267: \isa{wf{\isacharunderscore}iff{\isacharunderscore}no{\isacharunderscore}infinite{\isacharunderscore}down{\isacharunderscore}chain}: wenzelm@10267: \begin{isabelle}% wenzelm@10267: \ \ \ \ \ 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}% wenzelm@10267: \end{isabelle} wenzelm@10267: From lemma \isa{ex{\isacharunderscore}infinite{\isacharunderscore}path} the existence of an infinite paulson@10878: \isa{A}-avoiding path starting in \isa{s} follows, contradiction.% wenzelm@10267: \end{isamarkuptxt}% wenzelm@11866: \isamarkuptrue% wenzelm@10267: \isacommand{apply}{\isacharparenleft}erule\ contrapos{\isacharunderscore}pp{\isacharparenright}\isanewline wenzelm@11866: \isamarkupfalse% wenzelm@12815: \isacommand{apply}{\isacharparenleft}simp\ add{\isacharcolon}\ wf{\isacharunderscore}iff{\isacharunderscore}no{\isacharunderscore}infinite{\isacharunderscore}down{\isacharunderscore}chain{\isacharparenright}\isanewline wenzelm@11866: \isamarkupfalse% wenzelm@10267: \isacommand{apply}{\isacharparenleft}erule\ exE{\isacharparenright}\isanewline wenzelm@11866: \isamarkupfalse% wenzelm@10267: \isacommand{apply}{\isacharparenleft}rule\ ex{\isacharunderscore}infinite{\isacharunderscore}path{\isacharparenright}\isanewline wenzelm@11866: \isamarkupfalse% wenzelm@12815: \isacommand{apply}{\isacharparenleft}auto\ simp\ add{\isacharcolon}\ Paths{\isacharunderscore}def{\isacharparenright}\isanewline wenzelm@11866: \isamarkupfalse% wenzelm@11866: \isacommand{done}\isamarkupfalse% wenzelm@11866: % wenzelm@10267: \begin{isamarkuptext}% nipkow@11196: The \isa{{\isacharparenleft}no{\isacharunderscore}asm{\isacharparenright}} modifier of the \isa{rule{\isacharunderscore}format} directive in the nipkow@11196: statement of the lemma means paulson@11494: that the assumption is left unchanged; otherwise the \isa{{\isasymforall}p} paulson@11494: would be turned wenzelm@10267: into a \isa{{\isasymAnd}p}, which would complicate matters below. As it is, wenzelm@10267: \isa{Avoid{\isacharunderscore}in{\isacharunderscore}lfp} is now wenzelm@10267: \begin{isabelle}% nipkow@10696: \ \ \ \ \ {\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}% wenzelm@10267: \end{isabelle} wenzelm@10267: The main theorem is simply the corollary where \isa{t\ {\isacharequal}\ s}, paulson@11494: when the assumption \isa{t\ {\isasymin}\ Avoid\ s\ A} is trivially true nipkow@10845: by the first \isa{Avoid}-rule. Isabelle confirms this:% paulson@11494: \index{CTL|)}% wenzelm@10267: \end{isamarkuptext}% wenzelm@11866: \isamarkuptrue% nipkow@10855: \isacommand{theorem}\ AF{\isacharunderscore}lemma{\isadigit{2}}{\isacharcolon}\ \ {\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 wenzelm@11866: \isamarkupfalse% wenzelm@12815: \isacommand{by}{\isacharparenleft}auto\ elim{\isacharcolon}\ Avoid{\isacharunderscore}in{\isacharunderscore}lfp\ intro{\isacharcolon}\ Avoid{\isachardot}intros{\isacharparenright}\isanewline wenzelm@10267: \isanewline wenzelm@11866: \isamarkupfalse% wenzelm@11866: \isamarkupfalse% wenzelm@10267: \end{isabellebody}% wenzelm@10267: %%% Local Variables: wenzelm@10267: %%% mode: latex wenzelm@10267: %%% TeX-master: "root" wenzelm@10267: %%% End: