doc-src/TutorialI/CTL/document/CTL.tex
author paulson
Tue, 10 Feb 2004 12:17:04 +0100
changeset 14379 ea10a8c3e9cf
parent 13791 3b6ff7ceaf27
child 15102 04b0e943fcc9
permissions -rw-r--r--
updated links to the old ftp site
     1 %
     2 \begin{isabellebody}%
     3 \def\isabellecontext{CTL}%
     4 \isamarkupfalse%
     5 %
     6 \isamarkupsubsection{Computation Tree Logic --- CTL%
     7 }
     8 \isamarkuptrue%
     9 %
    10 \begin{isamarkuptext}%
    11 \label{sec:CTL}
    12 \index{CTL|(}%
    13 The semantics of PDL only needs reflexive transitive closure.
    14 Let us be adventurous and introduce a more expressive temporal operator.
    15 We extend the datatype
    16 \isa{formula} by a new constructor%
    17 \end{isamarkuptext}%
    18 \isamarkuptrue%
    19 \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {\isacharbar}\ AF\ formula\isamarkupfalse%
    20 %
    21 \begin{isamarkuptext}%
    22 \noindent
    23 which stands for ``\emph{A}lways in the \emph{F}uture'':
    24 on all infinite paths, at some point the formula holds.
    25 Formalizing the notion of an infinite path is easy
    26 in HOL: it is simply a function from \isa{nat} to \isa{state}.%
    27 \end{isamarkuptext}%
    28 \isamarkuptrue%
    29 \isacommand{constdefs}\ Paths\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}state\ {\isasymRightarrow}\ {\isacharparenleft}nat\ {\isasymRightarrow}\ state{\isacharparenright}set{\isachardoublequote}\isanewline
    30 \ \ \ \ \ \ \ \ \ {\isachardoublequote}Paths\ s\ {\isasymequiv}\ {\isacharbraceleft}p{\isachardot}\ s\ {\isacharequal}\ p\ {\isadigit{0}}\ {\isasymand}\ {\isacharparenleft}{\isasymforall}i{\isachardot}\ {\isacharparenleft}p\ i{\isacharcomma}\ p{\isacharparenleft}i{\isacharplus}{\isadigit{1}}{\isacharparenright}{\isacharparenright}\ {\isasymin}\ M{\isacharparenright}{\isacharbraceright}{\isachardoublequote}\isamarkupfalse%
    31 %
    32 \begin{isamarkuptext}%
    33 \noindent
    34 This definition allows a succinct statement of the semantics of \isa{AF}:
    35 \footnote{Do not be misled: neither datatypes nor recursive functions can be
    36 extended by new constructors or equations. This is just a trick of the
    37 presentation (see \S\ref{sec:doc-prep-suppress}). In reality one has to define
    38 a new datatype and a new function.}%
    39 \end{isamarkuptext}%
    40 \isamarkuptrue%
    41 \isamarkupfalse%
    42 {\isachardoublequote}s\ {\isasymTurnstile}\ AF\ f\ \ \ \ {\isacharequal}\ {\isacharparenleft}{\isasymforall}p\ {\isasymin}\ Paths\ s{\isachardot}\ {\isasymexists}i{\isachardot}\ p\ i\ {\isasymTurnstile}\ f{\isacharparenright}{\isachardoublequote}\isamarkupfalse%
    43 %
    44 \begin{isamarkuptext}%
    45 \noindent
    46 Model checking \isa{AF} involves a function which
    47 is just complicated enough to warrant a separate definition:%
    48 \end{isamarkuptext}%
    49 \isamarkuptrue%
    50 \isacommand{constdefs}\ af\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}state\ set\ {\isasymRightarrow}\ state\ set\ {\isasymRightarrow}\ state\ set{\isachardoublequote}\isanewline
    51 \ \ \ \ \ \ \ \ \ {\isachardoublequote}af\ A\ T\ {\isasymequiv}\ A\ {\isasymunion}\ {\isacharbraceleft}s{\isachardot}\ {\isasymforall}t{\isachardot}\ {\isacharparenleft}s{\isacharcomma}\ t{\isacharparenright}\ {\isasymin}\ M\ {\isasymlongrightarrow}\ t\ {\isasymin}\ T{\isacharbraceright}{\isachardoublequote}\isamarkupfalse%
    52 %
    53 \begin{isamarkuptext}%
    54 \noindent
    55 Now we define \isa{mc\ {\isacharparenleft}AF\ f{\isacharparenright}} as the least set \isa{T} that includes
    56 \isa{mc\ f} and all states all of whose direct successors are in \isa{T}:%
    57 \end{isamarkuptext}%
    58 \isamarkuptrue%
    59 \isamarkupfalse%
    60 {\isachardoublequote}mc{\isacharparenleft}AF\ f{\isacharparenright}\ \ \ \ {\isacharequal}\ lfp{\isacharparenleft}af{\isacharparenleft}mc\ f{\isacharparenright}{\isacharparenright}{\isachardoublequote}\isamarkupfalse%
    61 %
    62 \begin{isamarkuptext}%
    63 \noindent
    64 Because \isa{af} is monotone in its second argument (and also its first, but
    65 that is irrelevant), \isa{af\ A} has a least fixed point:%
    66 \end{isamarkuptext}%
    67 \isamarkuptrue%
    68 \isacommand{lemma}\ mono{\isacharunderscore}af{\isacharcolon}\ {\isachardoublequote}mono{\isacharparenleft}af\ A{\isacharparenright}{\isachardoublequote}\isanewline
    69 \isamarkupfalse%
    70 \isacommand{apply}{\isacharparenleft}simp\ add{\isacharcolon}\ mono{\isacharunderscore}def\ af{\isacharunderscore}def{\isacharparenright}\isanewline
    71 \isamarkupfalse%
    72 \isacommand{apply}\ blast\isanewline
    73 \isamarkupfalse%
    74 \isacommand{done}\isamarkupfalse%
    75 \isamarkupfalse%
    76 \isamarkupfalse%
    77 \isamarkupfalse%
    78 \isamarkupfalse%
    79 \isamarkupfalse%
    80 \isamarkupfalse%
    81 \isamarkupfalse%
    82 \isamarkupfalse%
    83 \isamarkupfalse%
    84 \isamarkupfalse%
    85 \isamarkupfalse%
    86 \isamarkupfalse%
    87 \isamarkupfalse%
    88 \isamarkupfalse%
    89 \isamarkupfalse%
    90 \isamarkupfalse%
    91 \isamarkupfalse%
    92 \isamarkupfalse%
    93 %
    94 \begin{isamarkuptext}%
    95 All we need to prove now is  \isa{mc\ {\isacharparenleft}AF\ f{\isacharparenright}\ {\isacharequal}\ {\isacharbraceleft}s{\isachardot}\ s\ {\isasymTurnstile}\ AF\ f{\isacharbraceright}}, which states
    96 that \isa{mc} and \isa{{\isasymTurnstile}} agree for \isa{AF}\@.
    97 This time we prove the two inclusions separately, starting
    98 with the easy one:%
    99 \end{isamarkuptext}%
   100 \isamarkuptrue%
   101 \isacommand{theorem}\ AF{\isacharunderscore}lemma{\isadigit{1}}{\isacharcolon}\isanewline
   102 \ \ {\isachardoublequote}lfp{\isacharparenleft}af\ A{\isacharparenright}\ {\isasymsubseteq}\ {\isacharbraceleft}s{\isachardot}\ {\isasymforall}p\ {\isasymin}\ Paths\ s{\isachardot}\ {\isasymexists}i{\isachardot}\ p\ i\ {\isasymin}\ A{\isacharbraceright}{\isachardoublequote}\isamarkupfalse%
   103 %
   104 \begin{isamarkuptxt}%
   105 \noindent
   106 In contrast to the analogous proof for \isa{EF}, and just
   107 for a change, we do not use fixed point induction.  Park-induction,
   108 named after David Park, is weaker but sufficient for this proof:
   109 \begin{center}
   110 \isa{f\ S\ {\isasymsubseteq}\ S\ {\isasymLongrightarrow}\ lfp\ f\ {\isasymsubseteq}\ S} \hfill (\isa{lfp{\isacharunderscore}lowerbound})
   111 \end{center}
   112 The instance of the premise \isa{f\ S\ {\isasymsubseteq}\ S} is proved pointwise,
   113 a decision that clarification takes for us:%
   114 \end{isamarkuptxt}%
   115 \isamarkuptrue%
   116 \isacommand{apply}{\isacharparenleft}rule\ lfp{\isacharunderscore}lowerbound{\isacharparenright}\isanewline
   117 \isamarkupfalse%
   118 \isacommand{apply}{\isacharparenleft}clarsimp\ simp\ add{\isacharcolon}\ af{\isacharunderscore}def\ Paths{\isacharunderscore}def{\isacharparenright}\isamarkupfalse%
   119 %
   120 \begin{isamarkuptxt}%
   121 \begin{isabelle}%
   122 \ {\isadigit{1}}{\isachardot}\ {\isasymAnd}p{\isachardot}\ {\isasymlbrakk}p\ {\isadigit{0}}\ {\isasymin}\ A\ {\isasymor}\isanewline
   123 \isaindent{\ {\isadigit{1}}{\isachardot}\ {\isasymAnd}p{\isachardot}\ {\isasymlbrakk}}{\isacharparenleft}{\isasymforall}t{\isachardot}\ {\isacharparenleft}p\ {\isadigit{0}}{\isacharcomma}\ t{\isacharparenright}\ {\isasymin}\ M\ {\isasymlongrightarrow}\isanewline
   124 \isaindent{\ {\isadigit{1}}{\isachardot}\ {\isasymAnd}p{\isachardot}\ {\isasymlbrakk}{\isacharparenleft}{\isasymforall}t{\isachardot}\ }{\isacharparenleft}{\isasymforall}p{\isachardot}\ t\ {\isacharequal}\ p\ {\isadigit{0}}\ {\isasymand}\ {\isacharparenleft}{\isasymforall}i{\isachardot}\ {\isacharparenleft}p\ i{\isacharcomma}\ p\ {\isacharparenleft}Suc\ i{\isacharparenright}{\isacharparenright}\ {\isasymin}\ M{\isacharparenright}\ {\isasymlongrightarrow}\isanewline
   125 \isaindent{\ {\isadigit{1}}{\isachardot}\ {\isasymAnd}p{\isachardot}\ {\isasymlbrakk}{\isacharparenleft}{\isasymforall}t{\isachardot}\ {\isacharparenleft}{\isasymforall}p{\isachardot}\ }{\isacharparenleft}{\isasymexists}i{\isachardot}\ p\ i\ {\isasymin}\ A{\isacharparenright}{\isacharparenright}{\isacharparenright}{\isacharsemicolon}\isanewline
   126 \isaindent{\ {\isadigit{1}}{\isachardot}\ {\isasymAnd}p{\isachardot}\ \ }{\isasymforall}i{\isachardot}\ {\isacharparenleft}p\ i{\isacharcomma}\ p\ {\isacharparenleft}Suc\ i{\isacharparenright}{\isacharparenright}\ {\isasymin}\ M{\isasymrbrakk}\isanewline
   127 \isaindent{\ {\isadigit{1}}{\isachardot}\ {\isasymAnd}p{\isachardot}\ }{\isasymLongrightarrow}\ {\isasymexists}i{\isachardot}\ p\ i\ {\isasymin}\ A%
   128 \end{isabelle}
   129 Now we eliminate the disjunction. The case \isa{p\ {\isadigit{0}}\ {\isasymin}\ A} is trivial:%
   130 \end{isamarkuptxt}%
   131 \isamarkuptrue%
   132 \isacommand{apply}{\isacharparenleft}erule\ disjE{\isacharparenright}\isanewline
   133 \ \isamarkupfalse%
   134 \isacommand{apply}{\isacharparenleft}blast{\isacharparenright}\isamarkupfalse%
   135 %
   136 \begin{isamarkuptxt}%
   137 \noindent
   138 In the other case we set \isa{t} to \isa{p\ {\isadigit{1}}} and simplify matters:%
   139 \end{isamarkuptxt}%
   140 \isamarkuptrue%
   141 \isacommand{apply}{\isacharparenleft}erule{\isacharunderscore}tac\ x\ {\isacharequal}\ {\isachardoublequote}p\ {\isadigit{1}}{\isachardoublequote}\ \isakeyword{in}\ allE{\isacharparenright}\isanewline
   142 \isamarkupfalse%
   143 \isacommand{apply}{\isacharparenleft}clarsimp{\isacharparenright}\isamarkupfalse%
   144 %
   145 \begin{isamarkuptxt}%
   146 \begin{isabelle}%
   147 \ {\isadigit{1}}{\isachardot}\ {\isasymAnd}p{\isachardot}\ {\isasymlbrakk}{\isasymforall}i{\isachardot}\ {\isacharparenleft}p\ i{\isacharcomma}\ p\ {\isacharparenleft}Suc\ i{\isacharparenright}{\isacharparenright}\ {\isasymin}\ M{\isacharsemicolon}\isanewline
   148 \isaindent{\ {\isadigit{1}}{\isachardot}\ {\isasymAnd}p{\isachardot}\ \ }{\isasymforall}pa{\isachardot}\ p\ {\isacharparenleft}Suc\ {\isadigit{0}}{\isacharparenright}\ {\isacharequal}\ pa\ {\isadigit{0}}\ {\isasymand}\ {\isacharparenleft}{\isasymforall}i{\isachardot}\ {\isacharparenleft}pa\ i{\isacharcomma}\ pa\ {\isacharparenleft}Suc\ i{\isacharparenright}{\isacharparenright}\ {\isasymin}\ M{\isacharparenright}\ {\isasymlongrightarrow}\isanewline
   149 \isaindent{\ {\isadigit{1}}{\isachardot}\ {\isasymAnd}p{\isachardot}\ \ {\isasymforall}pa{\isachardot}\ }{\isacharparenleft}{\isasymexists}i{\isachardot}\ pa\ i\ {\isasymin}\ A{\isacharparenright}{\isasymrbrakk}\isanewline
   150 \isaindent{\ {\isadigit{1}}{\isachardot}\ {\isasymAnd}p{\isachardot}\ }{\isasymLongrightarrow}\ {\isasymexists}i{\isachardot}\ p\ i\ {\isasymin}\ A%
   151 \end{isabelle}
   152 It merely remains to set \isa{pa} to \isa{{\isasymlambda}i{\isachardot}\ p\ {\isacharparenleft}i\ {\isacharplus}\ {\isadigit{1}}{\isacharparenright}}, that is, 
   153 \isa{p} without its first element.  The rest is automatic:%
   154 \end{isamarkuptxt}%
   155 \isamarkuptrue%
   156 \isacommand{apply}{\isacharparenleft}erule{\isacharunderscore}tac\ x\ {\isacharequal}\ {\isachardoublequote}{\isasymlambda}i{\isachardot}\ p{\isacharparenleft}i{\isacharplus}{\isadigit{1}}{\isacharparenright}{\isachardoublequote}\ \isakeyword{in}\ allE{\isacharparenright}\isanewline
   157 \isamarkupfalse%
   158 \isacommand{apply}\ force\isanewline
   159 \isamarkupfalse%
   160 \isacommand{done}\isamarkupfalse%
   161 %
   162 \begin{isamarkuptext}%
   163 The opposite inclusion is proved by contradiction: if some state
   164 \isa{s} is not in \isa{lfp\ {\isacharparenleft}af\ A{\isacharparenright}}, then we can construct an
   165 infinite \isa{A}-avoiding path starting from~\isa{s}. The reason is
   166 that by unfolding \isa{lfp} we find that if \isa{s} is not in
   167 \isa{lfp\ {\isacharparenleft}af\ A{\isacharparenright}}, then \isa{s} is not in \isa{A} and there is a
   168 direct successor of \isa{s} that is again not in \mbox{\isa{lfp\ {\isacharparenleft}af\ A{\isacharparenright}}}. Iterating this argument yields the promised infinite
   169 \isa{A}-avoiding path. Let us formalize this sketch.
   170 
   171 The one-step argument in the sketch above
   172 is proved by a variant of contraposition:%
   173 \end{isamarkuptext}%
   174 \isamarkuptrue%
   175 \isacommand{lemma}\ not{\isacharunderscore}in{\isacharunderscore}lfp{\isacharunderscore}afD{\isacharcolon}\isanewline
   176 \ {\isachardoublequote}s\ {\isasymnotin}\ lfp{\isacharparenleft}af\ A{\isacharparenright}\ {\isasymLongrightarrow}\ s\ {\isasymnotin}\ A\ {\isasymand}\ {\isacharparenleft}{\isasymexists}\ t{\isachardot}\ {\isacharparenleft}s{\isacharcomma}t{\isacharparenright}\ {\isasymin}\ M\ {\isasymand}\ t\ {\isasymnotin}\ lfp{\isacharparenleft}af\ A{\isacharparenright}{\isacharparenright}{\isachardoublequote}\isanewline
   177 \isamarkupfalse%
   178 \isacommand{apply}{\isacharparenleft}erule\ contrapos{\isacharunderscore}np{\isacharparenright}\isanewline
   179 \isamarkupfalse%
   180 \isacommand{apply}{\isacharparenleft}subst\ lfp{\isacharunderscore}unfold{\isacharbrackleft}OF\ mono{\isacharunderscore}af{\isacharbrackright}{\isacharparenright}\isanewline
   181 \isamarkupfalse%
   182 \isacommand{apply}{\isacharparenleft}simp\ add{\isacharcolon}\ af{\isacharunderscore}def{\isacharparenright}\isanewline
   183 \isamarkupfalse%
   184 \isacommand{done}\isamarkupfalse%
   185 %
   186 \begin{isamarkuptext}%
   187 \noindent
   188 We assume the negation of the conclusion and prove \isa{s\ {\isasymin}\ lfp\ {\isacharparenleft}af\ A{\isacharparenright}}.
   189 Unfolding \isa{lfp} once and
   190 simplifying with the definition of \isa{af} finishes the proof.
   191 
   192 Now we iterate this process. The following construction of the desired
   193 path is parameterized by a predicate \isa{Q} that should hold along the path:%
   194 \end{isamarkuptext}%
   195 \isamarkuptrue%
   196 \isacommand{consts}\ path\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}state\ {\isasymRightarrow}\ {\isacharparenleft}state\ {\isasymRightarrow}\ bool{\isacharparenright}\ {\isasymRightarrow}\ {\isacharparenleft}nat\ {\isasymRightarrow}\ state{\isacharparenright}{\isachardoublequote}\isanewline
   197 \isamarkupfalse%
   198 \isacommand{primrec}\isanewline
   199 {\isachardoublequote}path\ s\ Q\ {\isadigit{0}}\ {\isacharequal}\ s{\isachardoublequote}\isanewline
   200 {\isachardoublequote}path\ s\ Q\ {\isacharparenleft}Suc\ n{\isacharparenright}\ {\isacharequal}\ {\isacharparenleft}SOME\ t{\isachardot}\ {\isacharparenleft}path\ s\ Q\ n{\isacharcomma}t{\isacharparenright}\ {\isasymin}\ M\ {\isasymand}\ Q\ t{\isacharparenright}{\isachardoublequote}\isamarkupfalse%
   201 %
   202 \begin{isamarkuptext}%
   203 \noindent
   204 Element \isa{n\ {\isacharplus}\ {\isadigit{1}}} on this path is some arbitrary successor
   205 \isa{t} of element \isa{n} such that \isa{Q\ t} holds.  Remember that \isa{SOME\ t{\isachardot}\ R\ t}
   206 is some arbitrary but fixed \isa{t} such that \isa{R\ t} holds (see \S\ref{sec:SOME}). Of
   207 course, such a \isa{t} need not exist, but that is of no
   208 concern to us since we will only use \isa{path} when a
   209 suitable \isa{t} does exist.
   210 
   211 Let us show that if each state \isa{s} that satisfies \isa{Q}
   212 has a successor that again satisfies \isa{Q}, then there exists an infinite \isa{Q}-path:%
   213 \end{isamarkuptext}%
   214 \isamarkuptrue%
   215 \isacommand{lemma}\ infinity{\isacharunderscore}lemma{\isacharcolon}\isanewline
   216 \ \ {\isachardoublequote}{\isasymlbrakk}\ Q\ s{\isacharsemicolon}\ {\isasymforall}s{\isachardot}\ Q\ s\ {\isasymlongrightarrow}\ {\isacharparenleft}{\isasymexists}\ t{\isachardot}\ {\isacharparenleft}s{\isacharcomma}t{\isacharparenright}\ {\isasymin}\ M\ {\isasymand}\ Q\ t{\isacharparenright}\ {\isasymrbrakk}\ {\isasymLongrightarrow}\isanewline
   217 \ \ \ {\isasymexists}p{\isasymin}Paths\ s{\isachardot}\ {\isasymforall}i{\isachardot}\ Q{\isacharparenleft}p\ i{\isacharparenright}{\isachardoublequote}\isamarkupfalse%
   218 %
   219 \begin{isamarkuptxt}%
   220 \noindent
   221 First we rephrase the conclusion slightly because we need to prove simultaneously
   222 both the path property and the fact that \isa{Q} holds:%
   223 \end{isamarkuptxt}%
   224 \isamarkuptrue%
   225 \isacommand{apply}{\isacharparenleft}subgoal{\isacharunderscore}tac\isanewline
   226 \ \ {\isachardoublequote}{\isasymexists}p{\isachardot}\ s\ {\isacharequal}\ p\ {\isadigit{0}}\ {\isasymand}\ {\isacharparenleft}{\isasymforall}i{\isacharcolon}{\isacharcolon}nat{\isachardot}\ {\isacharparenleft}p\ i{\isacharcomma}\ p{\isacharparenleft}i{\isacharplus}{\isadigit{1}}{\isacharparenright}{\isacharparenright}\ {\isasymin}\ M\ {\isasymand}\ Q{\isacharparenleft}p\ i{\isacharparenright}{\isacharparenright}{\isachardoublequote}{\isacharparenright}\isamarkupfalse%
   227 %
   228 \begin{isamarkuptxt}%
   229 \noindent
   230 From this proposition the original goal follows easily:%
   231 \end{isamarkuptxt}%
   232 \ \isamarkuptrue%
   233 \isacommand{apply}{\isacharparenleft}simp\ add{\isacharcolon}\ Paths{\isacharunderscore}def{\isacharcomma}\ blast{\isacharparenright}\isamarkupfalse%
   234 %
   235 \begin{isamarkuptxt}%
   236 \noindent
   237 The new subgoal is proved by providing the witness \isa{path\ s\ Q} for \isa{p}:%
   238 \end{isamarkuptxt}%
   239 \isamarkuptrue%
   240 \isacommand{apply}{\isacharparenleft}rule{\isacharunderscore}tac\ x\ {\isacharequal}\ {\isachardoublequote}path\ s\ Q{\isachardoublequote}\ \isakeyword{in}\ exI{\isacharparenright}\isanewline
   241 \isamarkupfalse%
   242 \isacommand{apply}{\isacharparenleft}clarsimp{\isacharparenright}\isamarkupfalse%
   243 %
   244 \begin{isamarkuptxt}%
   245 \noindent
   246 After simplification and clarification, the subgoal has the following form:
   247 \begin{isabelle}%
   248 \ {\isadigit{1}}{\isachardot}\ {\isasymAnd}i{\isachardot}\ {\isasymlbrakk}Q\ s{\isacharsemicolon}\ {\isasymforall}s{\isachardot}\ Q\ s\ {\isasymlongrightarrow}\ {\isacharparenleft}{\isasymexists}t{\isachardot}\ {\isacharparenleft}s{\isacharcomma}\ t{\isacharparenright}\ {\isasymin}\ M\ {\isasymand}\ Q\ t{\isacharparenright}{\isasymrbrakk}\isanewline
   249 \isaindent{\ {\isadigit{1}}{\isachardot}\ {\isasymAnd}i{\isachardot}\ }{\isasymLongrightarrow}\ {\isacharparenleft}path\ s\ Q\ i{\isacharcomma}\ SOME\ t{\isachardot}\ {\isacharparenleft}path\ s\ Q\ i{\isacharcomma}\ t{\isacharparenright}\ {\isasymin}\ M\ {\isasymand}\ Q\ t{\isacharparenright}\ {\isasymin}\ M\ {\isasymand}\isanewline
   250 \isaindent{\ {\isadigit{1}}{\isachardot}\ {\isasymAnd}i{\isachardot}\ {\isasymLongrightarrow}\ }Q\ {\isacharparenleft}path\ s\ Q\ i{\isacharparenright}%
   251 \end{isabelle}
   252 It invites a proof by induction on \isa{i}:%
   253 \end{isamarkuptxt}%
   254 \isamarkuptrue%
   255 \isacommand{apply}{\isacharparenleft}induct{\isacharunderscore}tac\ i{\isacharparenright}\isanewline
   256 \ \isamarkupfalse%
   257 \isacommand{apply}{\isacharparenleft}simp{\isacharparenright}\isamarkupfalse%
   258 %
   259 \begin{isamarkuptxt}%
   260 \noindent
   261 After simplification, the base case boils down to
   262 \begin{isabelle}%
   263 \ {\isadigit{1}}{\isachardot}\ {\isasymlbrakk}Q\ s{\isacharsemicolon}\ {\isasymforall}s{\isachardot}\ Q\ s\ {\isasymlongrightarrow}\ {\isacharparenleft}{\isasymexists}t{\isachardot}\ {\isacharparenleft}s{\isacharcomma}\ t{\isacharparenright}\ {\isasymin}\ M\ {\isasymand}\ Q\ t{\isacharparenright}{\isasymrbrakk}\isanewline
   264 \isaindent{\ {\isadigit{1}}{\isachardot}\ }{\isasymLongrightarrow}\ {\isacharparenleft}s{\isacharcomma}\ SOME\ t{\isachardot}\ {\isacharparenleft}s{\isacharcomma}\ t{\isacharparenright}\ {\isasymin}\ M\ {\isasymand}\ Q\ t{\isacharparenright}\ {\isasymin}\ M%
   265 \end{isabelle}
   266 The conclusion looks exceedingly trivial: after all, \isa{t} is chosen such that \isa{{\isacharparenleft}s{\isacharcomma}\ t{\isacharparenright}\ {\isasymin}\ M}
   267 holds. However, we first have to show that such a \isa{t} actually exists! This reasoning
   268 is embodied in the theorem \isa{someI{\isadigit{2}}{\isacharunderscore}ex}:
   269 \begin{isabelle}%
   270 \ \ \ \ \ {\isasymlbrakk}{\isasymexists}a{\isachardot}\ {\isacharquery}P\ a{\isacharsemicolon}\ {\isasymAnd}x{\isachardot}\ {\isacharquery}P\ x\ {\isasymLongrightarrow}\ {\isacharquery}Q\ x{\isasymrbrakk}\ {\isasymLongrightarrow}\ {\isacharquery}Q\ {\isacharparenleft}SOME\ x{\isachardot}\ {\isacharquery}P\ x{\isacharparenright}%
   271 \end{isabelle}
   272 When we apply this theorem as an introduction rule, \isa{{\isacharquery}P\ x} becomes
   273 \isa{{\isacharparenleft}s{\isacharcomma}\ x{\isacharparenright}\ {\isasymin}\ M\ {\isasymand}\ Q\ x} and \isa{{\isacharquery}Q\ x} becomes \isa{{\isacharparenleft}s{\isacharcomma}\ x{\isacharparenright}\ {\isasymin}\ M} and we have to prove
   274 two subgoals: \isa{{\isasymexists}a{\isachardot}\ {\isacharparenleft}s{\isacharcomma}\ a{\isacharparenright}\ {\isasymin}\ M\ {\isasymand}\ Q\ a}, which follows from the assumptions, and
   275 \isa{{\isacharparenleft}s{\isacharcomma}\ x{\isacharparenright}\ {\isasymin}\ M\ {\isasymand}\ Q\ x\ {\isasymLongrightarrow}\ {\isacharparenleft}s{\isacharcomma}\ x{\isacharparenright}\ {\isasymin}\ M}, which is trivial. Thus it is not surprising that
   276 \isa{fast} can prove the base case quickly:%
   277 \end{isamarkuptxt}%
   278 \ \isamarkuptrue%
   279 \isacommand{apply}{\isacharparenleft}fast\ intro{\isacharcolon}\ someI{\isadigit{2}}{\isacharunderscore}ex{\isacharparenright}\isamarkupfalse%
   280 %
   281 \begin{isamarkuptxt}%
   282 \noindent
   283 What is worth noting here is that we have used \methdx{fast} rather than
   284 \isa{blast}.  The reason is that \isa{blast} would fail because it cannot
   285 cope with \isa{someI{\isadigit{2}}{\isacharunderscore}ex}: unifying its conclusion with the current
   286 subgoal is non-trivial because of the nested schematic variables. For
   287 efficiency reasons \isa{blast} does not even attempt such unifications.
   288 Although \isa{fast} can in principle cope with complicated unification
   289 problems, in practice the number of unifiers arising is often prohibitive and
   290 the offending rule may need to be applied explicitly rather than
   291 automatically. This is what happens in the step case.
   292 
   293 The induction step is similar, but more involved, because now we face nested
   294 occurrences of \isa{SOME}. As a result, \isa{fast} is no longer able to
   295 solve the subgoal and we apply \isa{someI{\isadigit{2}}{\isacharunderscore}ex} by hand.  We merely
   296 show the proof commands but do not describe the details:%
   297 \end{isamarkuptxt}%
   298 \isamarkuptrue%
   299 \isacommand{apply}{\isacharparenleft}simp{\isacharparenright}\isanewline
   300 \isamarkupfalse%
   301 \isacommand{apply}{\isacharparenleft}rule\ someI{\isadigit{2}}{\isacharunderscore}ex{\isacharparenright}\isanewline
   302 \ \isamarkupfalse%
   303 \isacommand{apply}{\isacharparenleft}blast{\isacharparenright}\isanewline
   304 \isamarkupfalse%
   305 \isacommand{apply}{\isacharparenleft}rule\ someI{\isadigit{2}}{\isacharunderscore}ex{\isacharparenright}\isanewline
   306 \ \isamarkupfalse%
   307 \isacommand{apply}{\isacharparenleft}blast{\isacharparenright}\isanewline
   308 \isamarkupfalse%
   309 \isacommand{apply}{\isacharparenleft}blast{\isacharparenright}\isanewline
   310 \isamarkupfalse%
   311 \isacommand{done}\isamarkupfalse%
   312 %
   313 \begin{isamarkuptext}%
   314 Function \isa{path} has fulfilled its purpose now and can be forgotten.
   315 It was merely defined to provide the witness in the proof of the
   316 \isa{infinity{\isacharunderscore}lemma}. Aficionados of minimal proofs might like to know
   317 that we could have given the witness without having to define a new function:
   318 the term
   319 \begin{isabelle}%
   320 \ \ \ \ \ nat{\isacharunderscore}rec\ s\ {\isacharparenleft}{\isasymlambda}n\ t{\isachardot}\ SOME\ u{\isachardot}\ {\isacharparenleft}t{\isacharcomma}\ u{\isacharparenright}\ {\isasymin}\ M\ {\isasymand}\ Q\ u{\isacharparenright}%
   321 \end{isabelle}
   322 is extensionally equal to \isa{path\ s\ Q},
   323 where \isa{nat{\isacharunderscore}rec} is the predefined primitive recursor on \isa{nat}.%
   324 \end{isamarkuptext}%
   325 \isamarkuptrue%
   326 \isamarkupfalse%
   327 \isamarkupfalse%
   328 \isamarkupfalse%
   329 \isamarkupfalse%
   330 \isamarkupfalse%
   331 \isamarkupfalse%
   332 \isamarkupfalse%
   333 \isamarkupfalse%
   334 \isamarkupfalse%
   335 \isamarkupfalse%
   336 \isamarkupfalse%
   337 \isamarkupfalse%
   338 \isamarkupfalse%
   339 \isamarkupfalse%
   340 \isamarkupfalse%
   341 \isamarkupfalse%
   342 %
   343 \begin{isamarkuptext}%
   344 At last we can prove the opposite direction of \isa{AF{\isacharunderscore}lemma{\isadigit{1}}}:%
   345 \end{isamarkuptext}%
   346 \isamarkuptrue%
   347 \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}\isamarkupfalse%
   348 %
   349 \begin{isamarkuptxt}%
   350 \noindent
   351 The proof is again pointwise and then by contraposition:%
   352 \end{isamarkuptxt}%
   353 \isamarkuptrue%
   354 \isacommand{apply}{\isacharparenleft}rule\ subsetI{\isacharparenright}\isanewline
   355 \isamarkupfalse%
   356 \isacommand{apply}{\isacharparenleft}erule\ contrapos{\isacharunderscore}pp{\isacharparenright}\isanewline
   357 \isamarkupfalse%
   358 \isacommand{apply}\ simp\isamarkupfalse%
   359 %
   360 \begin{isamarkuptxt}%
   361 \begin{isabelle}%
   362 \ {\isadigit{1}}{\isachardot}\ {\isasymAnd}x{\isachardot}\ x\ {\isasymnotin}\ lfp\ {\isacharparenleft}af\ A{\isacharparenright}\ {\isasymLongrightarrow}\ {\isasymexists}p{\isasymin}Paths\ x{\isachardot}\ {\isasymforall}i{\isachardot}\ p\ i\ {\isasymnotin}\ A%
   363 \end{isabelle}
   364 Applying the \isa{infinity{\isacharunderscore}lemma} as a destruction rule leaves two subgoals, the second
   365 premise of \isa{infinity{\isacharunderscore}lemma} and the original subgoal:%
   366 \end{isamarkuptxt}%
   367 \isamarkuptrue%
   368 \isacommand{apply}{\isacharparenleft}drule\ infinity{\isacharunderscore}lemma{\isacharparenright}\isamarkupfalse%
   369 %
   370 \begin{isamarkuptxt}%
   371 \begin{isabelle}%
   372 \ {\isadigit{1}}{\isachardot}\ {\isasymAnd}x{\isachardot}\ {\isasymforall}s{\isachardot}\ s\ {\isasymnotin}\ lfp\ {\isacharparenleft}af\ A{\isacharparenright}\ {\isasymlongrightarrow}\ {\isacharparenleft}{\isasymexists}t{\isachardot}\ {\isacharparenleft}s{\isacharcomma}\ t{\isacharparenright}\ {\isasymin}\ M\ {\isasymand}\ t\ {\isasymnotin}\ lfp\ {\isacharparenleft}af\ A{\isacharparenright}{\isacharparenright}\isanewline
   373 \ {\isadigit{2}}{\isachardot}\ {\isasymAnd}x{\isachardot}\ {\isasymexists}p{\isasymin}Paths\ x{\isachardot}\ {\isasymforall}i{\isachardot}\ p\ i\ {\isasymnotin}\ lfp\ {\isacharparenleft}af\ A{\isacharparenright}\ {\isasymLongrightarrow}\isanewline
   374 \isaindent{\ {\isadigit{2}}{\isachardot}\ {\isasymAnd}x{\isachardot}\ }{\isasymexists}p{\isasymin}Paths\ x{\isachardot}\ {\isasymforall}i{\isachardot}\ p\ i\ {\isasymnotin}\ A%
   375 \end{isabelle}
   376 Both are solved automatically:%
   377 \end{isamarkuptxt}%
   378 \ \isamarkuptrue%
   379 \isacommand{apply}{\isacharparenleft}auto\ dest{\isacharcolon}\ not{\isacharunderscore}in{\isacharunderscore}lfp{\isacharunderscore}afD{\isacharparenright}\isanewline
   380 \isamarkupfalse%
   381 \isacommand{done}\isamarkupfalse%
   382 %
   383 \begin{isamarkuptext}%
   384 If you find these proofs too complicated, we recommend that you read
   385 \S\ref{sec:CTL-revisited}, where we show how inductive definitions lead to
   386 simpler arguments.
   387 
   388 The main theorem is proved as for PDL, except that we also derive the
   389 necessary equality \isa{lfp{\isacharparenleft}af\ A{\isacharparenright}\ {\isacharequal}\ {\isachardot}{\isachardot}{\isachardot}} by combining
   390 \isa{AF{\isacharunderscore}lemma{\isadigit{1}}} and \isa{AF{\isacharunderscore}lemma{\isadigit{2}}} on the spot:%
   391 \end{isamarkuptext}%
   392 \isamarkuptrue%
   393 \isacommand{theorem}\ {\isachardoublequote}mc\ f\ {\isacharequal}\ {\isacharbraceleft}s{\isachardot}\ s\ {\isasymTurnstile}\ f{\isacharbraceright}{\isachardoublequote}\isanewline
   394 \isamarkupfalse%
   395 \isacommand{apply}{\isacharparenleft}induct{\isacharunderscore}tac\ f{\isacharparenright}\isanewline
   396 \isamarkupfalse%
   397 \isacommand{apply}{\isacharparenleft}auto\ simp\ add{\isacharcolon}\ EF{\isacharunderscore}lemma\ equalityI{\isacharbrackleft}OF\ AF{\isacharunderscore}lemma{\isadigit{1}}\ AF{\isacharunderscore}lemma{\isadigit{2}}{\isacharbrackright}{\isacharparenright}\isanewline
   398 \isamarkupfalse%
   399 \isacommand{done}\isamarkupfalse%
   400 %
   401 \begin{isamarkuptext}%
   402 The language defined above is not quite CTL\@. The latter also includes an
   403 until-operator \isa{EU\ f\ g} with semantics ``there \emph{E}xists a path
   404 where \isa{f} is true \emph{U}ntil \isa{g} becomes true''.  We need
   405 an auxiliary function:%
   406 \end{isamarkuptext}%
   407 \isamarkuptrue%
   408 \isacommand{consts}\ until{\isacharcolon}{\isacharcolon}\ {\isachardoublequote}state\ set\ {\isasymRightarrow}\ state\ set\ {\isasymRightarrow}\ state\ {\isasymRightarrow}\ state\ list\ {\isasymRightarrow}\ bool{\isachardoublequote}\isanewline
   409 \isamarkupfalse%
   410 \isacommand{primrec}\isanewline
   411 {\isachardoublequote}until\ A\ B\ s\ {\isacharbrackleft}{\isacharbrackright}\ \ \ \ {\isacharequal}\ {\isacharparenleft}s\ {\isasymin}\ B{\isacharparenright}{\isachardoublequote}\isanewline
   412 {\isachardoublequote}until\ A\ B\ s\ {\isacharparenleft}t{\isacharhash}p{\isacharparenright}\ {\isacharequal}\ {\isacharparenleft}s\ {\isasymin}\ A\ {\isasymand}\ {\isacharparenleft}s{\isacharcomma}t{\isacharparenright}\ {\isasymin}\ M\ {\isasymand}\ until\ A\ B\ t\ p{\isacharparenright}{\isachardoublequote}\isamarkupfalse%
   413 \isamarkupfalse%
   414 %
   415 \begin{isamarkuptext}%
   416 \noindent
   417 Expressing the semantics of \isa{EU} is now straightforward:
   418 \begin{isabelle}%
   419 \ \ \ \ \ s\ {\isasymTurnstile}\ EU\ f\ g\ {\isacharequal}\ {\isacharparenleft}{\isasymexists}p{\isachardot}\ until\ {\isacharbraceleft}t{\isachardot}\ t\ {\isasymTurnstile}\ f{\isacharbraceright}\ {\isacharbraceleft}t{\isachardot}\ t\ {\isasymTurnstile}\ g{\isacharbraceright}\ s\ p{\isacharparenright}%
   420 \end{isabelle}
   421 Note that \isa{EU} is not definable in terms of the other operators!
   422 
   423 Model checking \isa{EU} is again a least fixed point construction:
   424 \begin{isabelle}%
   425 \ \ \ \ \ mc{\isacharparenleft}EU\ f\ g{\isacharparenright}\ {\isacharequal}\ lfp{\isacharparenleft}{\isasymlambda}T{\isachardot}\ mc\ g\ {\isasymunion}\ mc\ f\ {\isasyminter}\ {\isacharparenleft}M{\isasyminverse}\ {\isacharbackquote}{\isacharbackquote}\ T{\isacharparenright}{\isacharparenright}%
   426 \end{isabelle}
   427 
   428 \begin{exercise}
   429 Extend the datatype of formulae by the above until operator
   430 and prove the equivalence between semantics and model checking, i.e.\ that
   431 \begin{isabelle}%
   432 \ \ \ \ \ mc\ {\isacharparenleft}EU\ f\ g{\isacharparenright}\ {\isacharequal}\ {\isacharbraceleft}s{\isachardot}\ s\ {\isasymTurnstile}\ EU\ f\ g{\isacharbraceright}%
   433 \end{isabelle}
   434 %For readability you may want to annotate {term EU} with its customary syntax
   435 %{text[display]"| EU formula formula    E[_ U _]"}
   436 %which enables you to read and write {text"E[f U g]"} instead of {term"EU f g"}.
   437 \end{exercise}
   438 For more CTL exercises see, for example, Huth and Ryan \cite{Huth-Ryan-book}.%
   439 \end{isamarkuptext}%
   440 \isamarkuptrue%
   441 \isamarkupfalse%
   442 \isamarkupfalse%
   443 \isamarkupfalse%
   444 \isamarkupfalse%
   445 \isamarkupfalse%
   446 \isamarkupfalse%
   447 \isamarkupfalse%
   448 \isamarkupfalse%
   449 \isamarkupfalse%
   450 \isamarkupfalse%
   451 \isamarkupfalse%
   452 \isamarkupfalse%
   453 \isamarkupfalse%
   454 \isamarkupfalse%
   455 \isamarkupfalse%
   456 \isamarkupfalse%
   457 \isamarkupfalse%
   458 \isamarkupfalse%
   459 \isamarkupfalse%
   460 \isamarkupfalse%
   461 \isamarkupfalse%
   462 \isamarkupfalse%
   463 \isamarkupfalse%
   464 \isamarkupfalse%
   465 \isamarkupfalse%
   466 \isamarkupfalse%
   467 \isamarkupfalse%
   468 %
   469 \begin{isamarkuptext}%
   470 Let us close this section with a few words about the executability of
   471 our model checkers.  It is clear that if all sets are finite, they can be
   472 represented as lists and the usual set operations are easily
   473 implemented. Only \isa{lfp} requires a little thought.  Fortunately, theory
   474 \isa{While{\isacharunderscore}Combinator} in the Library~\cite{HOL-Library} provides a
   475 theorem stating that in the case of finite sets and a monotone
   476 function~\isa{F}, the value of \mbox{\isa{lfp\ F}} can be computed by
   477 iterated application of \isa{F} to~\isa{{\isacharbraceleft}{\isacharbraceright}} until a fixed point is
   478 reached. It is actually possible to generate executable functional programs
   479 from HOL definitions, but that is beyond the scope of the tutorial.%
   480 \index{CTL|)}%
   481 \end{isamarkuptext}%
   482 \isamarkuptrue%
   483 \isamarkupfalse%
   484 \end{isabellebody}%
   485 %%% Local Variables:
   486 %%% mode: latex
   487 %%% TeX-master: "root"
   488 %%% End: