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