| 10267 |      1 | %
 | 
|  |      2 | \begin{isabellebody}%
 | 
|  |      3 | \def\isabellecontext{CTLind}%
 | 
| 11866 |      4 | \isamarkupfalse%
 | 
| 10267 |      5 | %
 | 
| 10878 |      6 | \isamarkupsubsection{CTL Revisited%
 | 
| 10395 |      7 | }
 | 
| 11866 |      8 | \isamarkuptrue%
 | 
| 10267 |      9 | %
 | 
|  |     10 | \begin{isamarkuptext}%
 | 
|  |     11 | \label{sec:CTL-revisited}
 | 
| 11494 |     12 | \index{CTL|(}%
 | 
|  |     13 | The purpose of this section is twofold: to demonstrate
 | 
|  |     14 | some of the induction principles and heuristics discussed above and to
 | 
| 10283 |     15 | show how inductive definitions can simplify proofs.
 | 
| 10267 |     16 | In \S\ref{sec:CTL} we gave a fairly involved proof of the correctness of a
 | 
| 10795 |     17 | model checker for CTL\@. In particular the proof of the
 | 
| 10267 |     18 | \isa{infinity{\isacharunderscore}lemma} on the way to \isa{AF{\isacharunderscore}lemma{\isadigit{2}}} is not as
 | 
| 11494 |     19 | simple as one might expect, due to the \isa{SOME} operator
 | 
| 10283 |     20 | involved. Below we give a simpler proof of \isa{AF{\isacharunderscore}lemma{\isadigit{2}}}
 | 
|  |     21 | based on an auxiliary inductive definition.
 | 
| 10267 |     22 | 
 | 
|  |     23 | Let us call a (finite or infinite) path \emph{\isa{A}-avoiding} if it does
 | 
|  |     24 | not touch any node in the set \isa{A}. Then \isa{AF{\isacharunderscore}lemma{\isadigit{2}}} says
 | 
|  |     25 | that if no infinite path from some state \isa{s} is \isa{A}-avoiding,
 | 
|  |     26 | then \isa{s\ {\isasymin}\ lfp\ {\isacharparenleft}af\ A{\isacharparenright}}. We prove this by inductively defining the set
 | 
|  |     27 | \isa{Avoid\ s\ A} of states reachable from \isa{s} by a finite \isa{A}-avoiding path:
 | 
|  |     28 | % Second proof of opposite direction, directly by well-founded induction
 | 
|  |     29 | % on the initial segment of M that avoids A.%
 | 
|  |     30 | \end{isamarkuptext}%
 | 
| 11866 |     31 | \isamarkuptrue%
 | 
| 10267 |     32 | \isacommand{consts}\ Avoid\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}state\ {\isasymRightarrow}\ state\ set\ {\isasymRightarrow}\ state\ set{\isachardoublequote}\isanewline
 | 
| 11866 |     33 | \isamarkupfalse%
 | 
| 10267 |     34 | \isacommand{inductive}\ {\isachardoublequote}Avoid\ s\ A{\isachardoublequote}\isanewline
 | 
|  |     35 | \isakeyword{intros}\ {\isachardoublequote}s\ {\isasymin}\ Avoid\ s\ A{\isachardoublequote}\isanewline
 | 
| 11866 |     36 | \ \ \ \ \ \ \ {\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%
 | 
|  |     37 | %
 | 
| 10267 |     38 | \begin{isamarkuptext}%
 | 
|  |     39 | It is easy to see that for any infinite \isa{A}-avoiding path \isa{f}
 | 
| 12492 |     40 | with \isa{f\ {\isadigit{0}}\ {\isasymin}\ Avoid\ s\ A} there is an infinite \isa{A}-avoiding path
 | 
| 10267 |     41 | starting with \isa{s} because (by definition of \isa{Avoid}) there is a
 | 
| 12492 |     42 | finite \isa{A}-avoiding path from \isa{s} to \isa{f\ {\isadigit{0}}}.
 | 
|  |     43 | The proof is by induction on \isa{f\ {\isadigit{0}}\ {\isasymin}\ Avoid\ s\ A}. However,
 | 
| 10267 |     44 | this requires the following
 | 
|  |     45 | reformulation, as explained in \S\ref{sec:ind-var-in-prems} above;
 | 
|  |     46 | the \isa{rule{\isacharunderscore}format} directive undoes the reformulation after the proof.%
 | 
|  |     47 | \end{isamarkuptext}%
 | 
| 11866 |     48 | \isamarkuptrue%
 | 
| 10267 |     49 | \isacommand{lemma}\ ex{\isacharunderscore}infinite{\isacharunderscore}path{\isacharbrackleft}rule{\isacharunderscore}format{\isacharbrackright}{\isacharcolon}\isanewline
 | 
|  |     50 | \ \ {\isachardoublequote}t\ {\isasymin}\ Avoid\ s\ A\ \ {\isasymLongrightarrow}\isanewline
 | 
|  |     51 | \ \ \ {\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
 | 
| 11866 |     52 | \isamarkupfalse%
 | 
| 10267 |     53 | \isacommand{apply}{\isacharparenleft}erule\ Avoid{\isachardot}induct{\isacharparenright}\isanewline
 | 
| 11866 |     54 | \ \isamarkupfalse%
 | 
|  |     55 | \isacommand{apply}{\isacharparenleft}blast{\isacharparenright}\isanewline
 | 
|  |     56 | \isamarkupfalse%
 | 
| 10267 |     57 | \isacommand{apply}{\isacharparenleft}clarify{\isacharparenright}\isanewline
 | 
| 11866 |     58 | \isamarkupfalse%
 | 
| 10267 |     59 | \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
 | 
| 11866 |     60 | \isamarkupfalse%
 | 
| 12815 |     61 | \isacommand{apply}{\isacharparenleft}simp{\isacharunderscore}all\ add{\isacharcolon}\ Paths{\isacharunderscore}def\ split{\isacharcolon}\ nat{\isachardot}split{\isacharparenright}\isanewline
 | 
| 11866 |     62 | \isamarkupfalse%
 | 
|  |     63 | \isacommand{done}\isamarkupfalse%
 | 
|  |     64 | %
 | 
| 10267 |     65 | \begin{isamarkuptext}%
 | 
|  |     66 | \noindent
 | 
| 11494 |     67 | The base case (\isa{t\ {\isacharequal}\ s}) is trivial and proved by \isa{blast}.
 | 
| 10267 |     68 | In the induction step, we have an infinite \isa{A}-avoiding path \isa{f}
 | 
|  |     69 | starting from \isa{u}, a successor of \isa{t}. Now we simply instantiate
 | 
|  |     70 | the \isa{{\isasymforall}f{\isasymin}Paths\ t} in the induction hypothesis by the path starting with
 | 
|  |     71 | \isa{t} and continuing with \isa{f}. That is what the above $\lambda$-term
 | 
| 10878 |     72 | expresses.  Simplification shows that this is a path starting with \isa{t} 
 | 
|  |     73 | and that the instantiated induction hypothesis implies the conclusion.
 | 
| 10267 |     74 | 
 | 
| 11196 |     75 | Now we come to the key lemma. Assuming that no infinite \isa{A}-avoiding
 | 
| 11277 |     76 | path starts from \isa{s}, we want to show \isa{s\ {\isasymin}\ lfp\ {\isacharparenleft}af\ A{\isacharparenright}}. For the
 | 
|  |     77 | inductive proof this must be generalized to the statement that every point \isa{t}
 | 
| 11494 |     78 | ``between'' \isa{s} and \isa{A}, in other words all of \isa{Avoid\ s\ A},
 | 
| 11196 |     79 | is contained in \isa{lfp\ {\isacharparenleft}af\ A{\isacharparenright}}:%
 | 
| 10267 |     80 | \end{isamarkuptext}%
 | 
| 11866 |     81 | \isamarkuptrue%
 | 
| 10267 |     82 | \isacommand{lemma}\ Avoid{\isacharunderscore}in{\isacharunderscore}lfp{\isacharbrackleft}rule{\isacharunderscore}format{\isacharparenleft}no{\isacharunderscore}asm{\isacharparenright}{\isacharbrackright}{\isacharcolon}\isanewline
 | 
| 11866 |     83 | \ \ {\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%
 | 
|  |     84 | %
 | 
| 10267 |     85 | \begin{isamarkuptxt}%
 | 
|  |     86 | \noindent
 | 
| 11196 |     87 | 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}}.
 | 
|  |     88 | If \isa{t} is already in \isa{A}, then \isa{t\ {\isasymin}\ lfp\ {\isacharparenleft}af\ A{\isacharparenright}} is
 | 
|  |     89 | trivial. If \isa{t} is not in \isa{A} but all successors are in
 | 
|  |     90 | \isa{lfp\ {\isacharparenleft}af\ A{\isacharparenright}} (induction hypothesis), then \isa{t\ {\isasymin}\ lfp\ {\isacharparenleft}af\ A{\isacharparenright}} is
 | 
|  |     91 | again trivial.
 | 
|  |     92 | 
 | 
|  |     93 | The formal counterpart of this proof sketch is a well-founded induction
 | 
| 11494 |     94 | on~\isa{M} restricted to \isa{Avoid\ s\ A\ {\isacharminus}\ A}, roughly speaking:
 | 
| 10267 |     95 | \begin{isabelle}%
 | 
| 11196 |     96 | \ \ \ \ \ {\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}%
 | 
| 10267 |     97 | \end{isabelle}
 | 
| 11277 |     98 | As we shall see presently, the absence of infinite \isa{A}-avoiding paths
 | 
| 10267 |     99 | starting from \isa{s} implies well-foundedness of this relation. For the
 | 
|  |    100 | moment we assume this and proceed with the induction:%
 | 
|  |    101 | \end{isamarkuptxt}%
 | 
| 11866 |    102 | \isamarkuptrue%
 | 
| 11196 |    103 | \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
 | 
| 11866 |    104 | \ \isamarkupfalse%
 | 
|  |    105 | \isacommand{apply}{\isacharparenleft}erule{\isacharunderscore}tac\ a\ {\isacharequal}\ t\ \isakeyword{in}\ wf{\isacharunderscore}induct{\isacharparenright}\isanewline
 | 
|  |    106 | \ \isamarkupfalse%
 | 
|  |    107 | \isacommand{apply}{\isacharparenleft}clarsimp{\isacharparenright}\isamarkupfalse%
 | 
|  |    108 | \isamarkupfalse%
 | 
|  |    109 | %
 | 
| 10267 |    110 | \begin{isamarkuptxt}%
 | 
|  |    111 | \noindent
 | 
| 10878 |    112 | \begin{isabelle}%
 | 
| 13623 |    113 | \ {\isadigit{1}}{\isachardot}\ {\isasymAnd}t{\isachardot}\ {\isasymlbrakk}{\isasymforall}p{\isasymin}Paths\ s{\isachardot}\ {\isasymexists}i{\isachardot}\ p\ i\ {\isasymin}\ A{\isacharsemicolon}\isanewline
 | 
| 11196 |    114 | \isaindent{\ {\isadigit{1}}{\isachardot}\ {\isasymAnd}t{\isachardot}\ \ \ \ }{\isasymforall}y{\isachardot}\ {\isacharparenleft}t{\isacharcomma}\ y{\isacharparenright}\ {\isasymin}\ M\ {\isasymand}\ t\ {\isasymnotin}\ A\ {\isasymlongrightarrow}\isanewline
 | 
| 13623 |    115 | \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
 | 
|  |    116 | \isaindent{\ {\isadigit{1}}{\isachardot}\ {\isasymAnd}t{\isachardot}\ \ \ \ }t\ {\isasymin}\ Avoid\ s\ A{\isasymrbrakk}\isanewline
 | 
| 11196 |    117 | \isaindent{\ {\isadigit{1}}{\isachardot}\ {\isasymAnd}t{\isachardot}\ }{\isasymLongrightarrow}\ t\ {\isasymin}\ lfp\ {\isacharparenleft}af\ A{\isacharparenright}\isanewline
 | 
| 10878 |    118 | \ {\isadigit{2}}{\isachardot}\ {\isasymforall}p{\isasymin}Paths\ s{\isachardot}\ {\isasymexists}i{\isachardot}\ p\ i\ {\isasymin}\ A\ {\isasymLongrightarrow}\isanewline
 | 
| 11196 |    119 | \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}%
 | 
| 10878 |    120 | \end{isabelle}
 | 
|  |    121 | Now the induction hypothesis states that if \isa{t\ {\isasymnotin}\ A}
 | 
| 10267 |    122 | then all successors of \isa{t} that are in \isa{Avoid\ s\ A} are in
 | 
| 11196 |    123 | \isa{lfp\ {\isacharparenleft}af\ A{\isacharparenright}}. Unfolding \isa{lfp} in the conclusion of the first
 | 
|  |    124 | subgoal once, we have to prove that \isa{t} is in \isa{A} or all successors
 | 
| 11494 |    125 | of \isa{t} are in \isa{lfp\ {\isacharparenleft}af\ A{\isacharparenright}}.  But if \isa{t} is not in \isa{A},
 | 
| 11196 |    126 | the second 
 | 
| 10267 |    127 | \isa{Avoid}-rule implies that all successors of \isa{t} are in
 | 
| 11494 |    128 | \isa{Avoid\ s\ A}, because we also assume \isa{t\ {\isasymin}\ Avoid\ s\ A}.
 | 
|  |    129 | Hence, by the induction hypothesis, all successors of \isa{t} are indeed in
 | 
| 10267 |    130 | \isa{lfp\ {\isacharparenleft}af\ A{\isacharparenright}}. Mechanically:%
 | 
|  |    131 | \end{isamarkuptxt}%
 | 
| 11866 |    132 | \ \isamarkuptrue%
 | 
|  |    133 | \isacommand{apply}{\isacharparenleft}subst\ lfp{\isacharunderscore}unfold{\isacharbrackleft}OF\ mono{\isacharunderscore}af{\isacharbrackright}{\isacharparenright}\isanewline
 | 
|  |    134 | \ \isamarkupfalse%
 | 
|  |    135 | \isacommand{apply}{\isacharparenleft}simp\ {\isacharparenleft}no{\isacharunderscore}asm{\isacharparenright}\ add{\isacharcolon}\ af{\isacharunderscore}def{\isacharparenright}\isanewline
 | 
|  |    136 | \ \isamarkupfalse%
 | 
| 12815 |    137 | \isacommand{apply}{\isacharparenleft}blast\ intro{\isacharcolon}\ Avoid{\isachardot}intros{\isacharparenright}\isamarkupfalse%
 | 
| 11866 |    138 | %
 | 
| 10267 |    139 | \begin{isamarkuptxt}%
 | 
| 11494 |    140 | Having proved the main goal, we return to the proof obligation that the 
 | 
|  |    141 | relation used above is indeed well-founded. This is proved by contradiction: if
 | 
| 10878 |    142 | the relation is not well-founded then there exists an infinite \isa{A}-avoiding path all in \isa{Avoid\ s\ A}, by theorem
 | 
| 10267 |    143 | \isa{wf{\isacharunderscore}iff{\isacharunderscore}no{\isacharunderscore}infinite{\isacharunderscore}down{\isacharunderscore}chain}:
 | 
|  |    144 | \begin{isabelle}%
 | 
|  |    145 | \ \ \ \ \ 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}%
 | 
|  |    146 | \end{isabelle}
 | 
|  |    147 | From lemma \isa{ex{\isacharunderscore}infinite{\isacharunderscore}path} the existence of an infinite
 | 
| 10878 |    148 | \isa{A}-avoiding path starting in \isa{s} follows, contradiction.%
 | 
| 10267 |    149 | \end{isamarkuptxt}%
 | 
| 11866 |    150 | \isamarkuptrue%
 | 
| 10267 |    151 | \isacommand{apply}{\isacharparenleft}erule\ contrapos{\isacharunderscore}pp{\isacharparenright}\isanewline
 | 
| 11866 |    152 | \isamarkupfalse%
 | 
| 12815 |    153 | \isacommand{apply}{\isacharparenleft}simp\ add{\isacharcolon}\ wf{\isacharunderscore}iff{\isacharunderscore}no{\isacharunderscore}infinite{\isacharunderscore}down{\isacharunderscore}chain{\isacharparenright}\isanewline
 | 
| 11866 |    154 | \isamarkupfalse%
 | 
| 10267 |    155 | \isacommand{apply}{\isacharparenleft}erule\ exE{\isacharparenright}\isanewline
 | 
| 11866 |    156 | \isamarkupfalse%
 | 
| 10267 |    157 | \isacommand{apply}{\isacharparenleft}rule\ ex{\isacharunderscore}infinite{\isacharunderscore}path{\isacharparenright}\isanewline
 | 
| 11866 |    158 | \isamarkupfalse%
 | 
| 12815 |    159 | \isacommand{apply}{\isacharparenleft}auto\ simp\ add{\isacharcolon}\ Paths{\isacharunderscore}def{\isacharparenright}\isanewline
 | 
| 11866 |    160 | \isamarkupfalse%
 | 
|  |    161 | \isacommand{done}\isamarkupfalse%
 | 
|  |    162 | %
 | 
| 10267 |    163 | \begin{isamarkuptext}%
 | 
| 11196 |    164 | The \isa{{\isacharparenleft}no{\isacharunderscore}asm{\isacharparenright}} modifier of the \isa{rule{\isacharunderscore}format} directive in the
 | 
|  |    165 | statement of the lemma means
 | 
| 11494 |    166 | that the assumption is left unchanged; otherwise the \isa{{\isasymforall}p} 
 | 
|  |    167 | would be turned
 | 
| 10267 |    168 | into a \isa{{\isasymAnd}p}, which would complicate matters below. As it is,
 | 
|  |    169 | \isa{Avoid{\isacharunderscore}in{\isacharunderscore}lfp} is now
 | 
|  |    170 | \begin{isabelle}%
 | 
| 10696 |    171 | \ \ \ \ \ {\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}%
 | 
| 10267 |    172 | \end{isabelle}
 | 
|  |    173 | The main theorem is simply the corollary where \isa{t\ {\isacharequal}\ s},
 | 
| 11494 |    174 | when the assumption \isa{t\ {\isasymin}\ Avoid\ s\ A} is trivially true
 | 
| 10845 |    175 | by the first \isa{Avoid}-rule. Isabelle confirms this:%
 | 
| 11494 |    176 | \index{CTL|)}%
 | 
| 10267 |    177 | \end{isamarkuptext}%
 | 
| 11866 |    178 | \isamarkuptrue%
 | 
| 10855 |    179 | \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
 | 
| 11866 |    180 | \isamarkupfalse%
 | 
| 12815 |    181 | \isacommand{by}{\isacharparenleft}auto\ elim{\isacharcolon}\ Avoid{\isacharunderscore}in{\isacharunderscore}lfp\ intro{\isacharcolon}\ Avoid{\isachardot}intros{\isacharparenright}\isanewline
 | 
| 10267 |    182 | \isanewline
 | 
| 11866 |    183 | \isamarkupfalse%
 | 
|  |    184 | \isamarkupfalse%
 | 
| 10267 |    185 | \end{isabellebody}%
 | 
|  |    186 | %%% Local Variables:
 | 
|  |    187 | %%% mode: latex
 | 
|  |    188 | %%% TeX-master: "root"
 | 
|  |    189 | %%% End:
 |