doc-src/TutorialI/CTL/document/CTL.tex
author paulson
Fri, 12 Jan 2001 16:07:20 +0100
changeset 10878 b254d5ad6dd4
parent 10867 bda1701848cd
child 10895 79194f07d356
permissions -rw-r--r--
auto update
nipkow@10123
     1
%
nipkow@10123
     2
\begin{isabellebody}%
nipkow@10123
     3
\def\isabellecontext{CTL}%
nipkow@10133
     4
%
paulson@10867
     5
\isamarkupsubsection{Computation Tree Logic---CTL%
wenzelm@10395
     6
}
nipkow@10149
     7
%
nipkow@10149
     8
\begin{isamarkuptext}%
nipkow@10217
     9
\label{sec:CTL}
paulson@10867
    10
The semantics of PDL only needs reflexive transitive closure.
paulson@10867
    11
Let us be adventurous and introduce a more expressive temporal operator.
paulson@10867
    12
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}:
paulson@10867
    27
\footnote{Do not be misled: 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
paulson@10867
    41
Now we define \isa{mc\ {\isacharparenleft}AF\ f{\isacharparenright}} as the least set \isa{T} that includes
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}%
paulson@10867
    55
All we need to prove now is  \isa{mc\ {\isacharparenleft}AF\ f{\isacharparenright}\ {\isacharequal}\ {\isacharbraceleft}s{\isachardot}\ s\ {\isasymTurnstile}\ AF\ f{\isacharbraceright}}, which states
paulson@10867
    56
that \isa{mc} and \isa{{\isasymTurnstile}} agree for \isa{AF}\@.
paulson@10867
    57
This time we prove the two inclusions separately, starting
nipkow@10159
    58
with the easy one:%
nipkow@10159
    59
\end{isamarkuptext}%
nipkow@10187
    60
\isacommand{theorem}\ AF{\isacharunderscore}lemma{\isadigit{1}}{\isacharcolon}\isanewline
nipkow@10159
    61
\ \ {\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
    62
\begin{isamarkuptxt}%
nipkow@10149
    63
\noindent
nipkow@10225
    64
In contrast to the analogous property for \isa{EF}, and just
nipkow@10242
    65
for a change, we do not use fixed point induction but a weaker theorem,
nipkow@10225
    66
\isa{lfp{\isacharunderscore}lowerbound}:
nipkow@10225
    67
\begin{isabelle}%
nipkow@10225
    68
\ \ \ \ \ f\ S\ {\isasymsubseteq}\ S\ {\isasymLongrightarrow}\ lfp\ f\ {\isasymsubseteq}\ S%
nipkow@10225
    69
\end{isabelle}
nipkow@10225
    70
The instance of the premise \isa{f\ S\ {\isasymsubseteq}\ S} is proved pointwise,
nipkow@10281
    71
a decision that clarification takes for us:%
nipkow@10159
    72
\end{isamarkuptxt}%
nipkow@10225
    73
\isacommand{apply}{\isacharparenleft}rule\ lfp{\isacharunderscore}lowerbound{\isacharparenright}\isanewline
nipkow@10159
    74
\isacommand{apply}{\isacharparenleft}clarsimp\ simp\ add{\isacharcolon}\ af{\isacharunderscore}def\ Paths{\isacharunderscore}def{\isacharparenright}%
nipkow@10159
    75
\begin{isamarkuptxt}%
nipkow@10363
    76
\begin{isabelle}%
nipkow@10696
    77
\ {\isadigit{1}}{\isachardot}\ {\isasymAnd}p{\isachardot}\ {\isasymlbrakk}p\ {\isadigit{0}}\ {\isasymin}\ A\ {\isasymor}\isanewline
nipkow@10696
    78
\ \ \ \ \ \ \ \ \ {\isacharparenleft}{\isasymforall}t{\isachardot}\ {\isacharparenleft}p\ {\isadigit{0}}{\isacharcomma}\ t{\isacharparenright}\ {\isasymin}\ M\ {\isasymlongrightarrow}\isanewline
nipkow@10696
    79
\ \ \ \ \ \ \ \ \ \ \ \ \ \ {\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
    80
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {\isacharparenleft}{\isasymexists}i{\isachardot}\ p\ i\ {\isasymin}\ A{\isacharparenright}{\isacharparenright}{\isacharparenright}{\isacharsemicolon}\isanewline
nipkow@10696
    81
\ \ \ \ \ \ \ \ \ \ \ {\isasymforall}i{\isachardot}\ {\isacharparenleft}p\ i{\isacharcomma}\ p\ {\isacharparenleft}Suc\ i{\isacharparenright}{\isacharparenright}\ {\isasymin}\ M{\isasymrbrakk}\isanewline
nipkow@10696
    82
\ \ \ \ \ \ \ \ {\isasymLongrightarrow}\ {\isasymexists}i{\isachardot}\ p\ i\ {\isasymin}\ A%
nipkow@10159
    83
\end{isabelle}
nipkow@10187
    84
Now we eliminate the disjunction. The case \isa{p\ {\isadigit{0}}\ {\isasymin}\ A} is trivial:%
nipkow@10159
    85
\end{isamarkuptxt}%
nipkow@10123
    86
\isacommand{apply}{\isacharparenleft}erule\ disjE{\isacharparenright}\isanewline
nipkow@10159
    87
\ \isacommand{apply}{\isacharparenleft}blast{\isacharparenright}%
nipkow@10159
    88
\begin{isamarkuptxt}%
nipkow@10159
    89
\noindent
nipkow@10187
    90
In the other case we set \isa{t} to \isa{p\ {\isadigit{1}}} and simplify matters:%
nipkow@10159
    91
\end{isamarkuptxt}%
nipkow@10187
    92
\isacommand{apply}{\isacharparenleft}erule{\isacharunderscore}tac\ x\ {\isacharequal}\ {\isachardoublequote}p\ {\isadigit{1}}{\isachardoublequote}\ \isakeyword{in}\ allE{\isacharparenright}\isanewline
nipkow@10159
    93
\isacommand{apply}{\isacharparenleft}clarsimp{\isacharparenright}%
nipkow@10159
    94
\begin{isamarkuptxt}%
nipkow@10363
    95
\begin{isabelle}%
nipkow@10696
    96
\ {\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
    97
\ \ \ \ \ \ \ \ \ \ \ {\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
    98
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {\isacharparenleft}{\isasymexists}i{\isachardot}\ pa\ i\ {\isasymin}\ A{\isacharparenright}{\isasymrbrakk}\isanewline
nipkow@10696
    99
\ \ \ \ \ \ \ \ {\isasymLongrightarrow}\ {\isasymexists}i{\isachardot}\ p\ i\ {\isasymin}\ A%
nipkow@10159
   100
\end{isabelle}
nipkow@10187
   101
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
   102
first element. The rest is practically automatic:%
nipkow@10159
   103
\end{isamarkuptxt}%
nipkow@10187
   104
\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
   105
\isacommand{apply}\ simp\isanewline
nipkow@10159
   106
\isacommand{apply}\ blast\isanewline
nipkow@10159
   107
\isacommand{done}%
nipkow@10123
   108
\begin{isamarkuptext}%
paulson@10867
   109
The opposite inclusion is proved by contradiction: if some state
nipkow@10159
   110
\isa{s} is not in \isa{lfp\ {\isacharparenleft}af\ A{\isacharparenright}}, then we can construct an
nipkow@10123
   111
infinite \isa{A}-avoiding path starting from \isa{s}. The reason is
nipkow@10123
   112
that by unfolding \isa{lfp} we find that if \isa{s} is not in
nipkow@10123
   113
\isa{lfp\ {\isacharparenleft}af\ A{\isacharparenright}}, then \isa{s} is not in \isa{A} and there is a
nipkow@10123
   114
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
   115
\isa{A}-avoiding path. Let us formalize this sketch.
nipkow@10123
   116
paulson@10867
   117
The one-step argument in the sketch above
paulson@10867
   118
is proved by a variant of contraposition:%
nipkow@10123
   119
\end{isamarkuptext}%
nipkow@10123
   120
\isacommand{lemma}\ not{\isacharunderscore}in{\isacharunderscore}lfp{\isacharunderscore}afD{\isacharcolon}\isanewline
nipkow@10123
   121
\ {\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
   122
\isacommand{apply}{\isacharparenleft}erule\ contrapos{\isacharunderscore}np{\isacharparenright}\isanewline
nipkow@10186
   123
\isacommand{apply}{\isacharparenleft}rule\ ssubst{\isacharbrackleft}OF\ lfp{\isacharunderscore}unfold{\isacharbrackleft}OF\ mono{\isacharunderscore}af{\isacharbrackright}{\isacharbrackright}{\isacharparenright}\isanewline
nipkow@10159
   124
\isacommand{apply}{\isacharparenleft}simp\ add{\isacharcolon}af{\isacharunderscore}def{\isacharparenright}\isanewline
nipkow@10159
   125
\isacommand{done}%
nipkow@10123
   126
\begin{isamarkuptext}%
nipkow@10123
   127
\noindent
paulson@10867
   128
We assume the negation of the conclusion and prove \isa{s\ {\isasymin}\ lfp\ {\isacharparenleft}af\ A{\isacharparenright}}.
nipkow@10237
   129
Unfolding \isa{lfp} once and
nipkow@10123
   130
simplifying with the definition of \isa{af} finishes the proof.
nipkow@10123
   131
nipkow@10123
   132
Now we iterate this process. The following construction of the desired
nipkow@10123
   133
path is parameterized by a predicate \isa{P} that should hold along the path:%
nipkow@10123
   134
\end{isamarkuptext}%
nipkow@10123
   135
\isacommand{consts}\ path\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}state\ {\isasymRightarrow}\ {\isacharparenleft}state\ {\isasymRightarrow}\ bool{\isacharparenright}\ {\isasymRightarrow}\ {\isacharparenleft}nat\ {\isasymRightarrow}\ state{\isacharparenright}{\isachardoublequote}\isanewline
nipkow@10123
   136
\isacommand{primrec}\isanewline
nipkow@10187
   137
{\isachardoublequote}path\ s\ P\ {\isadigit{0}}\ {\isacharequal}\ s{\isachardoublequote}\isanewline
nipkow@10123
   138
{\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
   139
\begin{isamarkuptext}%
nipkow@10123
   140
\noindent
nipkow@10187
   141
Element \isa{n\ {\isacharplus}\ {\isadigit{1}}} on this path is some arbitrary successor
nipkow@10159
   142
\isa{t} of element \isa{n} such that \isa{P\ t} holds.  Remember that \isa{SOME\ t{\isachardot}\ R\ t}
nipkow@10654
   143
is some arbitrary but fixed \isa{t} such that \isa{R\ t} holds (see \S\ref{sec:SOME}). Of
paulson@10867
   144
course, such a \isa{t} need not exist, but that is of no
paulson@10867
   145
concern to us since we will only use \isa{path} when a
nipkow@10123
   146
suitable \isa{t} does exist.
nipkow@10123
   147
nipkow@10159
   148
Let us show that if each state \isa{s} that satisfies \isa{P}
nipkow@10159
   149
has a successor that again satisfies \isa{P}, then there exists an infinite \isa{P}-path:%
nipkow@10123
   150
\end{isamarkuptext}%
nipkow@10159
   151
\isacommand{lemma}\ infinity{\isacharunderscore}lemma{\isacharcolon}\isanewline
nipkow@10159
   152
\ \ {\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
   153
\ \ \ {\isasymexists}p{\isasymin}Paths\ s{\isachardot}\ {\isasymforall}i{\isachardot}\ P{\isacharparenleft}p\ i{\isacharparenright}{\isachardoublequote}%
nipkow@10123
   154
\begin{isamarkuptxt}%
nipkow@10123
   155
\noindent
nipkow@10123
   156
First we rephrase the conclusion slightly because we need to prove both the path property
nipkow@10123
   157
and the fact that \isa{P} holds simultaneously:%
nipkow@10123
   158
\end{isamarkuptxt}%
nipkow@10187
   159
\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
   160
\begin{isamarkuptxt}%
nipkow@10123
   161
\noindent
nipkow@10159
   162
From this proposition the original goal follows easily:%
nipkow@10123
   163
\end{isamarkuptxt}%
nipkow@10159
   164
\ \isacommand{apply}{\isacharparenleft}simp\ add{\isacharcolon}Paths{\isacharunderscore}def{\isacharcomma}\ blast{\isacharparenright}%
nipkow@10159
   165
\begin{isamarkuptxt}%
nipkow@10159
   166
\noindent
nipkow@10159
   167
The new subgoal is proved by providing the witness \isa{path\ s\ P} for \isa{p}:%
nipkow@10159
   168
\end{isamarkuptxt}%
nipkow@10123
   169
\isacommand{apply}{\isacharparenleft}rule{\isacharunderscore}tac\ x\ {\isacharequal}\ {\isachardoublequote}path\ s\ P{\isachardoublequote}\ \isakeyword{in}\ exI{\isacharparenright}\isanewline
nipkow@10159
   170
\isacommand{apply}{\isacharparenleft}clarsimp{\isacharparenright}%
nipkow@10159
   171
\begin{isamarkuptxt}%
nipkow@10159
   172
\noindent
nipkow@10159
   173
After simplification and clarification the subgoal has the following compact form
nipkow@10363
   174
\begin{isabelle}%
nipkow@10696
   175
\ {\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
   176
\ \ \ \ \ \ \ \ {\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
   177
\ \ \ \ \ \ \ \ \ \ \ P\ {\isacharparenleft}path\ s\ P\ i{\isacharparenright}%
nipkow@10159
   178
\end{isabelle}
nipkow@10159
   179
and invites a proof by induction on \isa{i}:%
nipkow@10159
   180
\end{isamarkuptxt}%
nipkow@10123
   181
\isacommand{apply}{\isacharparenleft}induct{\isacharunderscore}tac\ i{\isacharparenright}\isanewline
nipkow@10159
   182
\ \isacommand{apply}{\isacharparenleft}simp{\isacharparenright}%
nipkow@10159
   183
\begin{isamarkuptxt}%
nipkow@10159
   184
\noindent
nipkow@10159
   185
After simplification the base case boils down to
nipkow@10363
   186
\begin{isabelle}%
nipkow@10696
   187
\ {\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
   188
\ \ \ \ {\isasymLongrightarrow}\ {\isacharparenleft}s{\isacharcomma}\ SOME\ t{\isachardot}\ {\isacharparenleft}s{\isacharcomma}\ t{\isacharparenright}\ {\isasymin}\ M\ {\isasymand}\ P\ t{\isacharparenright}\ {\isasymin}\ M%
nipkow@10159
   189
\end{isabelle}
nipkow@10159
   190
The conclusion looks exceedingly trivial: after all, \isa{t} is chosen such that \isa{{\isacharparenleft}s{\isacharcomma}\ t{\isacharparenright}\ {\isasymin}\ M}
nipkow@10159
   191
holds. However, we first have to show that such a \isa{t} actually exists! This reasoning
nipkow@10187
   192
is embodied in the theorem \isa{someI{\isadigit{2}}{\isacharunderscore}ex}:
nipkow@10159
   193
\begin{isabelle}%
nipkow@10696
   194
\ \ \ \ \ {\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
   195
\end{isabelle}
nipkow@10159
   196
When we apply this theorem as an introduction rule, \isa{{\isacharquery}P\ x} becomes
nipkow@10159
   197
\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
   198
two subgoals: \isa{{\isasymexists}a{\isachardot}\ {\isacharparenleft}s{\isacharcomma}\ a{\isacharparenright}\ {\isasymin}\ M\ {\isasymand}\ P\ a}, which follows from the assumptions, and
nipkow@10159
   199
\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
   200
\isa{fast} can prove the base case quickly:%
nipkow@10159
   201
\end{isamarkuptxt}%
nipkow@10187
   202
\ \isacommand{apply}{\isacharparenleft}fast\ intro{\isacharcolon}someI{\isadigit{2}}{\isacharunderscore}ex{\isacharparenright}%
nipkow@10159
   203
\begin{isamarkuptxt}%
nipkow@10159
   204
\noindent
nipkow@10212
   205
What is worth noting here is that we have used \isa{fast} rather than
nipkow@10212
   206
\isa{blast}.  The reason is that \isa{blast} would fail because it cannot
nipkow@10212
   207
cope with \isa{someI{\isadigit{2}}{\isacharunderscore}ex}: unifying its conclusion with the current
nipkow@10212
   208
subgoal is nontrivial because of the nested schematic variables. For
nipkow@10212
   209
efficiency reasons \isa{blast} does not even attempt such unifications.
nipkow@10212
   210
Although \isa{fast} can in principle cope with complicated unification
nipkow@10212
   211
problems, in practice the number of unifiers arising is often prohibitive and
nipkow@10212
   212
the offending rule may need to be applied explicitly rather than
nipkow@10212
   213
automatically. This is what happens in the step case.
nipkow@10159
   214
nipkow@10212
   215
The induction step is similar, but more involved, because now we face nested
nipkow@10212
   216
occurrences of \isa{SOME}. As a result, \isa{fast} is no longer able to
nipkow@10212
   217
solve the subgoal and we apply \isa{someI{\isadigit{2}}{\isacharunderscore}ex} by hand.  We merely
nipkow@10212
   218
show the proof commands but do not describe the details:%
nipkow@10159
   219
\end{isamarkuptxt}%
nipkow@10123
   220
\isacommand{apply}{\isacharparenleft}simp{\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@10187
   223
\isacommand{apply}{\isacharparenleft}rule\ someI{\isadigit{2}}{\isacharunderscore}ex{\isacharparenright}\isanewline
nipkow@10123
   224
\ \isacommand{apply}{\isacharparenleft}blast{\isacharparenright}\isanewline
nipkow@10159
   225
\isacommand{apply}{\isacharparenleft}blast{\isacharparenright}\isanewline
nipkow@10159
   226
\isacommand{done}%
nipkow@10159
   227
\begin{isamarkuptext}%
paulson@10867
   228
Function \isa{path} has fulfilled its purpose now and can be forgotten.
paulson@10867
   229
It was merely defined to provide the witness in the proof of the
nipkow@10171
   230
\isa{infinity{\isacharunderscore}lemma}. Aficionados of minimal proofs might like to know
nipkow@10159
   231
that we could have given the witness without having to define a new function:
nipkow@10159
   232
the term
nipkow@10159
   233
\begin{isabelle}%
nipkow@10159
   234
\ \ \ \ \ 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
   235
\end{isabelle}
nipkow@10171
   236
is extensionally equal to \isa{path\ s\ P},
paulson@10867
   237
where \isa{nat{\isacharunderscore}rec} is the predefined primitive recursor on \isa{nat}.%
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@10866
   243
\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}%
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}%
paulson@10867
   270
If you find these proofs too complicated, we recommend that you read
paulson@10867
   271
\S\ref{sec:CTL-revisited}, where we show 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}%
paulson@10867
   283
The language defined above is not quite CTL\@. The latter also includes an
paulson@10867
   284
until-operator \isa{EU\ f\ g} with semantics ``there exists 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@10839
   302
\ \ \ \ \ 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
   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}
paulson@10867
   315
For more CTL exercises see, for example, Huth and Ryan \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.
paulson@10878
   322
Fortunately, the HOL Library%
paulson@10878
   323
\footnote{See theory \isa{While_Combinator_Example}.}
paulson@10878
   324
provides a theorem stating that 
paulson@10878
   325
in the case of finite sets and a monotone function~\isa{F},
paulson@10867
   326
the value of \isa{lfp\ F} can be computed by iterated application of \isa{F} to~\isa{{\isacharbraceleft}{\isacharbraceright}} until
nipkow@10242
   327
a fixed point is reached. It is actually possible to generate executable functional programs
nipkow@10159
   328
from HOL definitions, but that is beyond the scope of the tutorial.%
nipkow@10159
   329
\end{isamarkuptext}%
nipkow@10123
   330
\end{isabellebody}%
nipkow@10123
   331
%%% Local Variables:
nipkow@10123
   332
%%% mode: latex
nipkow@10123
   333
%%% TeX-master: "root"
nipkow@10123
   334
%%% End: