doc-src/TutorialI/CTL/document/CTL.tex
author nipkow
Wed, 10 Jan 2001 10:40:34 +0100
changeset 10839 1f93f5a27de6
parent 10801 c00ac928fc6f
child 10866 cf8956f49499
permissions -rw-r--r--
*** empty log message ***
nipkow@10123
     1
%
nipkow@10123
     2
\begin{isabellebody}%
nipkow@10123
     3
\def\isabellecontext{CTL}%
nipkow@10133
     4
%
wenzelm@10395
     5
\isamarkupsubsection{Computation tree logic---CTL%
wenzelm@10395
     6
}
nipkow@10149
     7
%
nipkow@10149
     8
\begin{isamarkuptext}%
nipkow@10217
     9
\label{sec:CTL}
nipkow@10149
    10
The semantics of PDL only needs transitive reflexive closure.
nipkow@10149
    11
Let us now be a bit more adventurous and introduce a new temporal operator
nipkow@10149
    12
that goes beyond transitive reflexive closure. We extend the datatype
nipkow@10149
    13
\isa{formula} by a new constructor%
nipkow@10149
    14
\end{isamarkuptext}%
nipkow@10149
    15
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {\isacharbar}\ AF\ formula%
nipkow@10149
    16
\begin{isamarkuptext}%
nipkow@10149
    17
\noindent
nipkow@10149
    18
which stands for "always in the future":
nipkow@10159
    19
on all paths, at some point the formula holds. Formalizing the notion of an infinite path is easy
nipkow@10159
    20
in HOL: it is simply a function from \isa{nat} to \isa{state}.%
nipkow@10149
    21
\end{isamarkuptext}%
nipkow@10123
    22
\isacommand{constdefs}\ Paths\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}state\ {\isasymRightarrow}\ {\isacharparenleft}nat\ {\isasymRightarrow}\ state{\isacharparenright}set{\isachardoublequote}\isanewline
nipkow@10187
    23
\ \ \ \ \ \ \ \ \ {\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}%
nipkow@10149
    24
\begin{isamarkuptext}%
nipkow@10149
    25
\noindent
nipkow@10159
    26
This definition allows a very succinct statement of the semantics of \isa{AF}:
nipkow@10149
    27
\footnote{Do not be mislead: neither datatypes nor recursive functions can be
nipkow@10149
    28
extended by new constructors or equations. This is just a trick of the
nipkow@10149
    29
presentation. In reality one has to define a new datatype and a new function.}%
nipkow@10149
    30
\end{isamarkuptext}%
nipkow@10149
    31
{\isachardoublequote}s\ {\isasymTurnstile}\ AF\ f\ \ \ \ {\isacharequal}\ {\isacharparenleft}{\isasymforall}p\ {\isasymin}\ Paths\ s{\isachardot}\ {\isasymexists}i{\isachardot}\ p\ i\ {\isasymTurnstile}\ f{\isacharparenright}{\isachardoublequote}%
nipkow@10149
    32
\begin{isamarkuptext}%
nipkow@10149
    33
\noindent
nipkow@10149
    34
Model checking \isa{AF} involves a function which
nipkow@10159
    35
is just complicated enough to warrant a separate definition:%
nipkow@10149
    36
\end{isamarkuptext}%
nipkow@10123
    37
\isacommand{constdefs}\ af\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}state\ set\ {\isasymRightarrow}\ state\ set\ {\isasymRightarrow}\ state\ set{\isachardoublequote}\isanewline
nipkow@10149
    38
\ \ \ \ \ \ \ \ \ {\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}%
nipkow@10149
    39
\begin{isamarkuptext}%
nipkow@10149
    40
\noindent
nipkow@10159
    41
Now we define \isa{mc\ {\isacharparenleft}AF\ f{\isacharparenright}} as the least set \isa{T} that contains
nipkow@10159
    42
\isa{mc\ f} and all states all of whose direct successors are in \isa{T}:%
nipkow@10159
    43
\end{isamarkuptext}%
nipkow@10159
    44
{\isachardoublequote}mc{\isacharparenleft}AF\ f{\isacharparenright}\ \ \ \ {\isacharequal}\ lfp{\isacharparenleft}af{\isacharparenleft}mc\ f{\isacharparenright}{\isacharparenright}{\isachardoublequote}%
nipkow@10159
    45
\begin{isamarkuptext}%
nipkow@10159
    46
\noindent
nipkow@10159
    47
Because \isa{af} is monotone in its second argument (and also its first, but
nipkow@10242
    48
that is irrelevant) \isa{af\ A} has a least fixed point:%
nipkow@10149
    49
\end{isamarkuptext}%
nipkow@10123
    50
\isacommand{lemma}\ mono{\isacharunderscore}af{\isacharcolon}\ {\isachardoublequote}mono{\isacharparenleft}af\ A{\isacharparenright}{\isachardoublequote}\isanewline
nipkow@10149
    51
\isacommand{apply}{\isacharparenleft}simp\ add{\isacharcolon}\ mono{\isacharunderscore}def\ af{\isacharunderscore}def{\isacharparenright}\isanewline
nipkow@10159
    52
\isacommand{apply}\ blast\isanewline
nipkow@10159
    53
\isacommand{done}%
nipkow@10149
    54
\begin{isamarkuptext}%
nipkow@10159
    55
All we need to prove now is that \isa{mc} and \isa{{\isasymTurnstile}}
nipkow@10159
    56
agree for \isa{AF}, i.e.\ that \isa{mc\ {\isacharparenleft}AF\ f{\isacharparenright}\ {\isacharequal}\ {\isacharbraceleft}s{\isachardot}\ s\ {\isasymTurnstile}\ AF\ f{\isacharbraceright}}. This time we prove the two containments separately, starting
nipkow@10159
    57
with the easy one:%
nipkow@10159
    58
\end{isamarkuptext}%
nipkow@10187
    59
\isacommand{theorem}\ AF{\isacharunderscore}lemma{\isadigit{1}}{\isacharcolon}\isanewline
nipkow@10159
    60
\ \ {\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}%
nipkow@10159
    61
\begin{isamarkuptxt}%
nipkow@10149
    62
\noindent
nipkow@10225
    63
In contrast to the analogous property for \isa{EF}, and just
nipkow@10242
    64
for a change, we do not use fixed point induction but a weaker theorem,
nipkow@10225
    65
\isa{lfp{\isacharunderscore}lowerbound}:
nipkow@10225
    66
\begin{isabelle}%
nipkow@10225
    67
\ \ \ \ \ f\ S\ {\isasymsubseteq}\ S\ {\isasymLongrightarrow}\ lfp\ f\ {\isasymsubseteq}\ S%
nipkow@10225
    68
\end{isabelle}
nipkow@10225
    69
The instance of the premise \isa{f\ S\ {\isasymsubseteq}\ S} is proved pointwise,
nipkow@10281
    70
a decision that clarification takes for us:%
nipkow@10159
    71
\end{isamarkuptxt}%
nipkow@10225
    72
\isacommand{apply}{\isacharparenleft}rule\ lfp{\isacharunderscore}lowerbound{\isacharparenright}\isanewline
nipkow@10159
    73
\isacommand{apply}{\isacharparenleft}clarsimp\ simp\ add{\isacharcolon}\ af{\isacharunderscore}def\ Paths{\isacharunderscore}def{\isacharparenright}%
nipkow@10159
    74
\begin{isamarkuptxt}%
nipkow@10363
    75
\begin{isabelle}%
nipkow@10696
    76
\ {\isadigit{1}}{\isachardot}\ {\isasymAnd}p{\isachardot}\ {\isasymlbrakk}p\ {\isadigit{0}}\ {\isasymin}\ A\ {\isasymor}\isanewline
nipkow@10696
    77
\ \ \ \ \ \ \ \ \ {\isacharparenleft}{\isasymforall}t{\isachardot}\ {\isacharparenleft}p\ {\isadigit{0}}{\isacharcomma}\ t{\isacharparenright}\ {\isasymin}\ M\ {\isasymlongrightarrow}\isanewline
nipkow@10696
    78
\ \ \ \ \ \ \ \ \ \ \ \ \ \ {\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
nipkow@10696
    79
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {\isacharparenleft}{\isasymexists}i{\isachardot}\ p\ i\ {\isasymin}\ A{\isacharparenright}{\isacharparenright}{\isacharparenright}{\isacharsemicolon}\isanewline
nipkow@10696
    80
\ \ \ \ \ \ \ \ \ \ \ {\isasymforall}i{\isachardot}\ {\isacharparenleft}p\ i{\isacharcomma}\ p\ {\isacharparenleft}Suc\ i{\isacharparenright}{\isacharparenright}\ {\isasymin}\ M{\isasymrbrakk}\isanewline
nipkow@10696
    81
\ \ \ \ \ \ \ \ {\isasymLongrightarrow}\ {\isasymexists}i{\isachardot}\ p\ i\ {\isasymin}\ A%
nipkow@10159
    82
\end{isabelle}
nipkow@10187
    83
Now we eliminate the disjunction. The case \isa{p\ {\isadigit{0}}\ {\isasymin}\ A} is trivial:%
nipkow@10159
    84
\end{isamarkuptxt}%
nipkow@10123
    85
\isacommand{apply}{\isacharparenleft}erule\ disjE{\isacharparenright}\isanewline
nipkow@10159
    86
\ \isacommand{apply}{\isacharparenleft}blast{\isacharparenright}%
nipkow@10159
    87
\begin{isamarkuptxt}%
nipkow@10159
    88
\noindent
nipkow@10187
    89
In the other case we set \isa{t} to \isa{p\ {\isadigit{1}}} and simplify matters:%
nipkow@10159
    90
\end{isamarkuptxt}%
nipkow@10187
    91
\isacommand{apply}{\isacharparenleft}erule{\isacharunderscore}tac\ x\ {\isacharequal}\ {\isachardoublequote}p\ {\isadigit{1}}{\isachardoublequote}\ \isakeyword{in}\ allE{\isacharparenright}\isanewline
nipkow@10159
    92
\isacommand{apply}{\isacharparenleft}clarsimp{\isacharparenright}%
nipkow@10159
    93
\begin{isamarkuptxt}%
nipkow@10363
    94
\begin{isabelle}%
nipkow@10696
    95
\ {\isadigit{1}}{\isachardot}\ {\isasymAnd}p{\isachardot}\ {\isasymlbrakk}{\isasymforall}i{\isachardot}\ {\isacharparenleft}p\ i{\isacharcomma}\ p\ {\isacharparenleft}Suc\ i{\isacharparenright}{\isacharparenright}\ {\isasymin}\ M{\isacharsemicolon}\isanewline
nipkow@10696
    96
\ \ \ \ \ \ \ \ \ \ \ {\isasymforall}pa{\isachardot}\ p\ {\isadigit{1}}\ {\isacharequal}\ pa\ {\isadigit{0}}\ {\isasymand}\ {\isacharparenleft}{\isasymforall}i{\isachardot}\ {\isacharparenleft}pa\ i{\isacharcomma}\ pa\ {\isacharparenleft}Suc\ i{\isacharparenright}{\isacharparenright}\ {\isasymin}\ M{\isacharparenright}\ {\isasymlongrightarrow}\isanewline
nipkow@10696
    97
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {\isacharparenleft}{\isasymexists}i{\isachardot}\ pa\ i\ {\isasymin}\ A{\isacharparenright}{\isasymrbrakk}\isanewline
nipkow@10696
    98
\ \ \ \ \ \ \ \ {\isasymLongrightarrow}\ {\isasymexists}i{\isachardot}\ p\ i\ {\isasymin}\ A%
nipkow@10159
    99
\end{isabelle}
nipkow@10187
   100
It merely remains to set \isa{pa} to \isa{{\isasymlambda}i{\isachardot}\ p\ {\isacharparenleft}i\ {\isacharplus}\ {\isadigit{1}}{\isacharparenright}}, i.e.\ \isa{p} without its
nipkow@10159
   101
first element. The rest is practically automatic:%
nipkow@10159
   102
\end{isamarkuptxt}%
nipkow@10187
   103
\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
nipkow@10159
   104
\isacommand{apply}\ simp\isanewline
nipkow@10159
   105
\isacommand{apply}\ blast\isanewline
nipkow@10159
   106
\isacommand{done}%
nipkow@10123
   107
\begin{isamarkuptext}%
nipkow@10159
   108
The opposite containment is proved by contradiction: if some state
nipkow@10159
   109
\isa{s} is not in \isa{lfp\ {\isacharparenleft}af\ A{\isacharparenright}}, then we can construct an
nipkow@10123
   110
infinite \isa{A}-avoiding path starting from \isa{s}. The reason is
nipkow@10123
   111
that by unfolding \isa{lfp} we find that if \isa{s} is not in
nipkow@10123
   112
\isa{lfp\ {\isacharparenleft}af\ A{\isacharparenright}}, then \isa{s} is not in \isa{A} and there is a
nipkow@10123
   113
direct successor of \isa{s} that is again not in \isa{lfp\ {\isacharparenleft}af\ A{\isacharparenright}}. Iterating this argument yields the promised infinite
nipkow@10123
   114
\isa{A}-avoiding path. Let us formalize this sketch.
nipkow@10123
   115
nipkow@10123
   116
The one-step argument in the above sketch%
nipkow@10123
   117
\end{isamarkuptext}%
nipkow@10123
   118
\isacommand{lemma}\ not{\isacharunderscore}in{\isacharunderscore}lfp{\isacharunderscore}afD{\isacharcolon}\isanewline
nipkow@10123
   119
\ {\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
nipkow@10237
   120
\isacommand{apply}{\isacharparenleft}erule\ contrapos{\isacharunderscore}np{\isacharparenright}\isanewline
nipkow@10186
   121
\isacommand{apply}{\isacharparenleft}rule\ ssubst{\isacharbrackleft}OF\ lfp{\isacharunderscore}unfold{\isacharbrackleft}OF\ mono{\isacharunderscore}af{\isacharbrackright}{\isacharbrackright}{\isacharparenright}\isanewline
nipkow@10159
   122
\isacommand{apply}{\isacharparenleft}simp\ add{\isacharcolon}af{\isacharunderscore}def{\isacharparenright}\isanewline
nipkow@10159
   123
\isacommand{done}%
nipkow@10123
   124
\begin{isamarkuptext}%
nipkow@10123
   125
\noindent
nipkow@10237
   126
is proved by a variant of contraposition:
nipkow@10237
   127
assume the negation of the conclusion and prove \isa{s\ {\isasymin}\ lfp\ {\isacharparenleft}af\ A{\isacharparenright}}.
nipkow@10237
   128
Unfolding \isa{lfp} once and
nipkow@10123
   129
simplifying with the definition of \isa{af} finishes the proof.
nipkow@10123
   130
nipkow@10123
   131
Now we iterate this process. The following construction of the desired
nipkow@10123
   132
path is parameterized by a predicate \isa{P} that should hold along the path:%
nipkow@10123
   133
\end{isamarkuptext}%
nipkow@10123
   134
\isacommand{consts}\ path\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}state\ {\isasymRightarrow}\ {\isacharparenleft}state\ {\isasymRightarrow}\ bool{\isacharparenright}\ {\isasymRightarrow}\ {\isacharparenleft}nat\ {\isasymRightarrow}\ state{\isacharparenright}{\isachardoublequote}\isanewline
nipkow@10123
   135
\isacommand{primrec}\isanewline
nipkow@10187
   136
{\isachardoublequote}path\ s\ P\ {\isadigit{0}}\ {\isacharequal}\ s{\isachardoublequote}\isanewline
nipkow@10123
   137
{\isachardoublequote}path\ s\ P\ {\isacharparenleft}Suc\ n{\isacharparenright}\ {\isacharequal}\ {\isacharparenleft}SOME\ t{\isachardot}\ {\isacharparenleft}path\ s\ P\ n{\isacharcomma}t{\isacharparenright}\ {\isasymin}\ M\ {\isasymand}\ P\ t{\isacharparenright}{\isachardoublequote}%
nipkow@10123
   138
\begin{isamarkuptext}%
nipkow@10123
   139
\noindent
nipkow@10187
   140
Element \isa{n\ {\isacharplus}\ {\isadigit{1}}} on this path is some arbitrary successor
nipkow@10159
   141
\isa{t} of element \isa{n} such that \isa{P\ t} holds.  Remember that \isa{SOME\ t{\isachardot}\ R\ t}
nipkow@10654
   142
is some arbitrary but fixed \isa{t} such that \isa{R\ t} holds (see \S\ref{sec:SOME}). Of
nipkow@10123
   143
course, such a \isa{t} may in general not exist, but that is of no
nipkow@10123
   144
concern to us since we will only use \isa{path} in such cases where a
nipkow@10123
   145
suitable \isa{t} does exist.
nipkow@10123
   146
nipkow@10159
   147
Let us show that if each state \isa{s} that satisfies \isa{P}
nipkow@10159
   148
has a successor that again satisfies \isa{P}, then there exists an infinite \isa{P}-path:%
nipkow@10123
   149
\end{isamarkuptext}%
nipkow@10159
   150
\isacommand{lemma}\ infinity{\isacharunderscore}lemma{\isacharcolon}\isanewline
nipkow@10159
   151
\ \ {\isachardoublequote}{\isasymlbrakk}\ P\ s{\isacharsemicolon}\ {\isasymforall}s{\isachardot}\ P\ s\ {\isasymlongrightarrow}\ {\isacharparenleft}{\isasymexists}\ t{\isachardot}\ {\isacharparenleft}s{\isacharcomma}t{\isacharparenright}\ {\isasymin}\ M\ {\isasymand}\ P\ t{\isacharparenright}\ {\isasymrbrakk}\ {\isasymLongrightarrow}\isanewline
nipkow@10159
   152
\ \ \ {\isasymexists}p{\isasymin}Paths\ s{\isachardot}\ {\isasymforall}i{\isachardot}\ P{\isacharparenleft}p\ i{\isacharparenright}{\isachardoublequote}%
nipkow@10123
   153
\begin{isamarkuptxt}%
nipkow@10123
   154
\noindent
nipkow@10123
   155
First we rephrase the conclusion slightly because we need to prove both the path property
nipkow@10123
   156
and the fact that \isa{P} holds simultaneously:%
nipkow@10123
   157
\end{isamarkuptxt}%
nipkow@10187
   158
\isacommand{apply}{\isacharparenleft}subgoal{\isacharunderscore}tac\ {\isachardoublequote}{\isasymexists}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\ {\isasymand}\ P{\isacharparenleft}p\ i{\isacharparenright}{\isacharparenright}{\isachardoublequote}{\isacharparenright}%
nipkow@10123
   159
\begin{isamarkuptxt}%
nipkow@10123
   160
\noindent
nipkow@10159
   161
From this proposition the original goal follows easily:%
nipkow@10123
   162
\end{isamarkuptxt}%
nipkow@10159
   163
\ \isacommand{apply}{\isacharparenleft}simp\ add{\isacharcolon}Paths{\isacharunderscore}def{\isacharcomma}\ blast{\isacharparenright}%
nipkow@10159
   164
\begin{isamarkuptxt}%
nipkow@10159
   165
\noindent
nipkow@10159
   166
The new subgoal is proved by providing the witness \isa{path\ s\ P} for \isa{p}:%
nipkow@10159
   167
\end{isamarkuptxt}%
nipkow@10123
   168
\isacommand{apply}{\isacharparenleft}rule{\isacharunderscore}tac\ x\ {\isacharequal}\ {\isachardoublequote}path\ s\ P{\isachardoublequote}\ \isakeyword{in}\ exI{\isacharparenright}\isanewline
nipkow@10159
   169
\isacommand{apply}{\isacharparenleft}clarsimp{\isacharparenright}%
nipkow@10159
   170
\begin{isamarkuptxt}%
nipkow@10159
   171
\noindent
nipkow@10159
   172
After simplification and clarification the subgoal has the following compact form
nipkow@10363
   173
\begin{isabelle}%
nipkow@10696
   174
\ {\isadigit{1}}{\isachardot}\ {\isasymAnd}i{\isachardot}\ {\isasymlbrakk}P\ s{\isacharsemicolon}\ {\isasymforall}s{\isachardot}\ P\ s\ {\isasymlongrightarrow}\ {\isacharparenleft}{\isasymexists}t{\isachardot}\ {\isacharparenleft}s{\isacharcomma}\ t{\isacharparenright}\ {\isasymin}\ M\ {\isasymand}\ P\ t{\isacharparenright}{\isasymrbrakk}\isanewline
nipkow@10696
   175
\ \ \ \ \ \ \ \ {\isasymLongrightarrow}\ {\isacharparenleft}path\ s\ P\ i{\isacharcomma}\ SOME\ t{\isachardot}\ {\isacharparenleft}path\ s\ P\ i{\isacharcomma}\ t{\isacharparenright}\ {\isasymin}\ M\ {\isasymand}\ P\ t{\isacharparenright}\ {\isasymin}\ M\ {\isasymand}\isanewline
wenzelm@10742
   176
\ \ \ \ \ \ \ \ \ \ \ P\ {\isacharparenleft}path\ s\ P\ i{\isacharparenright}%
nipkow@10159
   177
\end{isabelle}
nipkow@10159
   178
and invites a proof by induction on \isa{i}:%
nipkow@10159
   179
\end{isamarkuptxt}%
nipkow@10123
   180
\isacommand{apply}{\isacharparenleft}induct{\isacharunderscore}tac\ i{\isacharparenright}\isanewline
nipkow@10159
   181
\ \isacommand{apply}{\isacharparenleft}simp{\isacharparenright}%
nipkow@10159
   182
\begin{isamarkuptxt}%
nipkow@10159
   183
\noindent
nipkow@10159
   184
After simplification the base case boils down to
nipkow@10363
   185
\begin{isabelle}%
nipkow@10696
   186
\ {\isadigit{1}}{\isachardot}\ {\isasymlbrakk}P\ s{\isacharsemicolon}\ {\isasymforall}s{\isachardot}\ P\ s\ {\isasymlongrightarrow}\ {\isacharparenleft}{\isasymexists}t{\isachardot}\ {\isacharparenleft}s{\isacharcomma}\ t{\isacharparenright}\ {\isasymin}\ M\ {\isasymand}\ P\ t{\isacharparenright}{\isasymrbrakk}\isanewline
nipkow@10696
   187
\ \ \ \ {\isasymLongrightarrow}\ {\isacharparenleft}s{\isacharcomma}\ SOME\ t{\isachardot}\ {\isacharparenleft}s{\isacharcomma}\ t{\isacharparenright}\ {\isasymin}\ M\ {\isasymand}\ P\ t{\isacharparenright}\ {\isasymin}\ M%
nipkow@10159
   188
\end{isabelle}
nipkow@10159
   189
The conclusion looks exceedingly trivial: after all, \isa{t} is chosen such that \isa{{\isacharparenleft}s{\isacharcomma}\ t{\isacharparenright}\ {\isasymin}\ M}
nipkow@10159
   190
holds. However, we first have to show that such a \isa{t} actually exists! This reasoning
nipkow@10187
   191
is embodied in the theorem \isa{someI{\isadigit{2}}{\isacharunderscore}ex}:
nipkow@10159
   192
\begin{isabelle}%
nipkow@10696
   193
\ \ \ \ \ {\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}%
nipkow@10159
   194
\end{isabelle}
nipkow@10159
   195
When we apply this theorem as an introduction rule, \isa{{\isacharquery}P\ x} becomes
nipkow@10159
   196
\isa{{\isacharparenleft}s{\isacharcomma}\ x{\isacharparenright}\ {\isasymin}\ M\ {\isasymand}\ P\ x} and \isa{{\isacharquery}Q\ x} becomes \isa{{\isacharparenleft}s{\isacharcomma}\ x{\isacharparenright}\ {\isasymin}\ M} and we have to prove
nipkow@10159
   197
two subgoals: \isa{{\isasymexists}a{\isachardot}\ {\isacharparenleft}s{\isacharcomma}\ a{\isacharparenright}\ {\isasymin}\ M\ {\isasymand}\ P\ a}, which follows from the assumptions, and
nipkow@10159
   198
\isa{{\isacharparenleft}s{\isacharcomma}\ x{\isacharparenright}\ {\isasymin}\ M\ {\isasymand}\ P\ x\ {\isasymLongrightarrow}\ {\isacharparenleft}s{\isacharcomma}\ x{\isacharparenright}\ {\isasymin}\ M}, which is trivial. Thus it is not surprising that
nipkow@10159
   199
\isa{fast} can prove the base case quickly:%
nipkow@10159
   200
\end{isamarkuptxt}%
nipkow@10187
   201
\ \isacommand{apply}{\isacharparenleft}fast\ intro{\isacharcolon}someI{\isadigit{2}}{\isacharunderscore}ex{\isacharparenright}%
nipkow@10159
   202
\begin{isamarkuptxt}%
nipkow@10159
   203
\noindent
nipkow@10212
   204
What is worth noting here is that we have used \isa{fast} rather than
nipkow@10212
   205
\isa{blast}.  The reason is that \isa{blast} would fail because it cannot
nipkow@10212
   206
cope with \isa{someI{\isadigit{2}}{\isacharunderscore}ex}: unifying its conclusion with the current
nipkow@10212
   207
subgoal is nontrivial because of the nested schematic variables. For
nipkow@10212
   208
efficiency reasons \isa{blast} does not even attempt such unifications.
nipkow@10212
   209
Although \isa{fast} can in principle cope with complicated unification
nipkow@10212
   210
problems, in practice the number of unifiers arising is often prohibitive and
nipkow@10212
   211
the offending rule may need to be applied explicitly rather than
nipkow@10212
   212
automatically. This is what happens in the step case.
nipkow@10159
   213
nipkow@10212
   214
The induction step is similar, but more involved, because now we face nested
nipkow@10212
   215
occurrences of \isa{SOME}. As a result, \isa{fast} is no longer able to
nipkow@10212
   216
solve the subgoal and we apply \isa{someI{\isadigit{2}}{\isacharunderscore}ex} by hand.  We merely
nipkow@10212
   217
show the proof commands but do not describe the details:%
nipkow@10159
   218
\end{isamarkuptxt}%
nipkow@10123
   219
\isacommand{apply}{\isacharparenleft}simp{\isacharparenright}\isanewline
nipkow@10187
   220
\isacommand{apply}{\isacharparenleft}rule\ someI{\isadigit{2}}{\isacharunderscore}ex{\isacharparenright}\isanewline
nipkow@10123
   221
\ \isacommand{apply}{\isacharparenleft}blast{\isacharparenright}\isanewline
nipkow@10187
   222
\isacommand{apply}{\isacharparenleft}rule\ someI{\isadigit{2}}{\isacharunderscore}ex{\isacharparenright}\isanewline
nipkow@10123
   223
\ \isacommand{apply}{\isacharparenleft}blast{\isacharparenright}\isanewline
nipkow@10159
   224
\isacommand{apply}{\isacharparenleft}blast{\isacharparenright}\isanewline
nipkow@10159
   225
\isacommand{done}%
nipkow@10159
   226
\begin{isamarkuptext}%
nipkow@10159
   227
Function \isa{path} has fulfilled its purpose now and can be forgotten
nipkow@10159
   228
about. It was merely defined to provide the witness in the proof of the
nipkow@10171
   229
\isa{infinity{\isacharunderscore}lemma}. Aficionados of minimal proofs might like to know
nipkow@10159
   230
that we could have given the witness without having to define a new function:
nipkow@10159
   231
the term
nipkow@10159
   232
\begin{isabelle}%
nipkow@10159
   233
\ \ \ \ \ nat{\isacharunderscore}rec\ s\ {\isacharparenleft}{\isasymlambda}n\ t{\isachardot}\ SOME\ u{\isachardot}\ {\isacharparenleft}t{\isacharcomma}\ u{\isacharparenright}\ {\isasymin}\ M\ {\isasymand}\ P\ u{\isacharparenright}%
nipkow@10159
   234
\end{isabelle}
nipkow@10171
   235
is extensionally equal to \isa{path\ s\ P},
nipkow@10159
   236
where \isa{nat{\isacharunderscore}rec} is the predefined primitive recursor on \isa{nat}, whose defining
nipkow@10171
   237
equations we omit.%
nipkow@10159
   238
\end{isamarkuptext}%
nipkow@10159
   239
%
nipkow@10159
   240
\begin{isamarkuptext}%
nipkow@10187
   241
At last we can prove the opposite direction of \isa{AF{\isacharunderscore}lemma{\isadigit{1}}}:%
nipkow@10159
   242
\end{isamarkuptext}%
nipkow@10187
   243
\isacommand{theorem}\ AF{\isacharunderscore}lemma{\isadigit{2}}{\isacharcolon}\isanewline
nipkow@10159
   244
{\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}%
nipkow@10159
   245
\begin{isamarkuptxt}%
nipkow@10159
   246
\noindent
nipkow@10237
   247
The proof is again pointwise and then by contraposition:%
nipkow@10159
   248
\end{isamarkuptxt}%
nipkow@10123
   249
\isacommand{apply}{\isacharparenleft}rule\ subsetI{\isacharparenright}\isanewline
nipkow@10237
   250
\isacommand{apply}{\isacharparenleft}erule\ contrapos{\isacharunderscore}pp{\isacharparenright}\isanewline
nipkow@10159
   251
\isacommand{apply}\ simp%
nipkow@10159
   252
\begin{isamarkuptxt}%
nipkow@10363
   253
\begin{isabelle}%
nipkow@10363
   254
\ {\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%
nipkow@10159
   255
\end{isabelle}
nipkow@10159
   256
Applying the \isa{infinity{\isacharunderscore}lemma} as a destruction rule leaves two subgoals, the second
nipkow@10159
   257
premise of \isa{infinity{\isacharunderscore}lemma} and the original subgoal:%
nipkow@10159
   258
\end{isamarkuptxt}%
nipkow@10159
   259
\isacommand{apply}{\isacharparenleft}drule\ infinity{\isacharunderscore}lemma{\isacharparenright}%
nipkow@10159
   260
\begin{isamarkuptxt}%
nipkow@10363
   261
\begin{isabelle}%
nipkow@10363
   262
\ {\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
nipkow@10363
   263
\ {\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
nipkow@10363
   264
\ \ \ \ \ \ \ \ {\isasymexists}p{\isasymin}Paths\ x{\isachardot}\ {\isasymforall}i{\isachardot}\ p\ i\ {\isasymnotin}\ A%
nipkow@10159
   265
\end{isabelle}
nipkow@10159
   266
Both are solved automatically:%
nipkow@10159
   267
\end{isamarkuptxt}%
nipkow@10159
   268
\ \isacommand{apply}{\isacharparenleft}auto\ dest{\isacharcolon}not{\isacharunderscore}in{\isacharunderscore}lfp{\isacharunderscore}afD{\isacharparenright}\isanewline
nipkow@10159
   269
\isacommand{done}%
nipkow@10159
   270
\begin{isamarkuptext}%
nipkow@10217
   271
If you found the above proofs somewhat complicated we recommend you read
nipkow@10217
   272
\S\ref{sec:CTL-revisited} where we shown how inductive definitions lead to
nipkow@10217
   273
simpler arguments.
nipkow@10217
   274
nipkow@10217
   275
The main theorem is proved as for PDL, except that we also derive the
nipkow@10217
   276
necessary equality \isa{lfp{\isacharparenleft}af\ A{\isacharparenright}\ {\isacharequal}\ {\isachardot}{\isachardot}{\isachardot}} by combining
nipkow@10217
   277
\isa{AF{\isacharunderscore}lemma{\isadigit{1}}} and \isa{AF{\isacharunderscore}lemma{\isadigit{2}}} on the spot:%
nipkow@10159
   278
\end{isamarkuptext}%
nipkow@10123
   279
\isacommand{theorem}\ {\isachardoublequote}mc\ f\ {\isacharequal}\ {\isacharbraceleft}s{\isachardot}\ s\ {\isasymTurnstile}\ f{\isacharbraceright}{\isachardoublequote}\isanewline
nipkow@10123
   280
\isacommand{apply}{\isacharparenleft}induct{\isacharunderscore}tac\ f{\isacharparenright}\isanewline
nipkow@10187
   281
\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
nipkow@10159
   282
\isacommand{done}%
nipkow@10159
   283
\begin{isamarkuptext}%
paulson@10795
   284
The above language is not quite CTL\@. The latter also includes an
nipkow@10281
   285
until-operator \isa{EU\ f\ g} with semantics ``there exist a path
nipkow@10281
   286
where \isa{f} is true until \isa{g} becomes true''. With the help
nipkow@10281
   287
of an auxiliary function%
nipkow@10281
   288
\end{isamarkuptext}%
nipkow@10281
   289
\isacommand{consts}\ until{\isacharcolon}{\isacharcolon}\ {\isachardoublequote}state\ set\ {\isasymRightarrow}\ state\ set\ {\isasymRightarrow}\ state\ {\isasymRightarrow}\ state\ list\ {\isasymRightarrow}\ bool{\isachardoublequote}\isanewline
nipkow@10281
   290
\isacommand{primrec}\isanewline
nipkow@10281
   291
{\isachardoublequote}until\ A\ B\ s\ {\isacharbrackleft}{\isacharbrackright}\ \ \ \ {\isacharequal}\ {\isacharparenleft}s\ {\isasymin}\ B{\isacharparenright}{\isachardoublequote}\isanewline
nipkow@10281
   292
{\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}%
nipkow@10281
   293
\begin{isamarkuptext}%
nipkow@10281
   294
\noindent
nipkow@10281
   295
the semantics of \isa{EU} is straightforward:
nipkow@10171
   296
\begin{isabelle}%
nipkow@10281
   297
\ \ \ \ \ s\ {\isasymTurnstile}\ EU\ f\ g\ {\isacharequal}\ {\isacharparenleft}{\isasymexists}p{\isachardot}\ until\ A\ B\ s\ p{\isacharparenright}%
nipkow@10171
   298
\end{isabelle}
nipkow@10281
   299
Note that \isa{EU} is not definable in terms of the other operators!
nipkow@10281
   300
nipkow@10281
   301
Model checking \isa{EU} is again a least fixed point construction:
nipkow@10171
   302
\begin{isabelle}%
nipkow@10839
   303
\ \ \ \ \ 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}%
nipkow@10171
   304
\end{isabelle}
nipkow@10281
   305
nipkow@10281
   306
\begin{exercise}
nipkow@10281
   307
Extend the datatype of formulae by the above until operator
nipkow@10281
   308
and prove the equivalence between semantics and model checking, i.e.\ that
nipkow@10186
   309
\begin{isabelle}%
nipkow@10186
   310
\ \ \ \ \ mc\ {\isacharparenleft}EU\ f\ g{\isacharparenright}\ {\isacharequal}\ {\isacharbraceleft}s{\isachardot}\ s\ {\isasymTurnstile}\ EU\ f\ g{\isacharbraceright}%
nipkow@10186
   311
\end{isabelle}
nipkow@10186
   312
%For readability you may want to annotate {term EU} with its customary syntax
nipkow@10186
   313
%{text[display]"| EU formula formula    E[_ U _]"}
nipkow@10186
   314
%which enables you to read and write {text"E[f U g]"} instead of {term"EU f g"}.
nipkow@10186
   315
\end{exercise}
nipkow@10281
   316
For more CTL exercises see, for example, \cite{Huth-Ryan-book}.%
nipkow@10281
   317
\end{isamarkuptext}%
nipkow@10281
   318
%
nipkow@10281
   319
\begin{isamarkuptext}%
nipkow@10186
   320
Let us close this section with a few words about the executability of our model checkers.
nipkow@10159
   321
It is clear that if all sets are finite, they can be represented as lists and the usual
nipkow@10159
   322
set operations are easily implemented. Only \isa{lfp} requires a little thought.
nipkow@10159
   323
Fortunately the HOL library proves that in the case of finite sets and a monotone \isa{F},
nipkow@10159
   324
\isa{lfp\ F} can be computed by iterated application of \isa{F} to \isa{{\isacharbraceleft}{\isacharbraceright}} until
nipkow@10242
   325
a fixed point is reached. It is actually possible to generate executable functional programs
nipkow@10159
   326
from HOL definitions, but that is beyond the scope of the tutorial.%
nipkow@10159
   327
\end{isamarkuptext}%
nipkow@10123
   328
\end{isabellebody}%
nipkow@10123
   329
%%% Local Variables:
nipkow@10123
   330
%%% mode: latex
nipkow@10123
   331
%%% TeX-master: "root"
nipkow@10123
   332
%%% End: