doc-src/TutorialI/CTL/document/PDL.tex
author nipkow
Wed, 04 Oct 2000 17:35:45 +0200
changeset 10149 7cfdf6a330a0
parent 10133 e187dacd248f
child 10159 a72ddfdbfca0
permissions -rw-r--r--
*** empty log message ***
nipkow@10123
     1
%
nipkow@10123
     2
\begin{isabellebody}%
nipkow@10123
     3
\def\isabellecontext{PDL}%
nipkow@10123
     4
%
nipkow@10123
     5
\isamarkupsubsection{Propositional dynmic logic---PDL}
nipkow@10133
     6
%
nipkow@10133
     7
\begin{isamarkuptext}%
nipkow@10133
     8
The formulae of PDL are built up from atomic propositions via the customary
nipkow@10133
     9
propositional connectives of negation and conjunction and the two temporal
nipkow@10133
    10
connectives \isa{AX} and \isa{EF}. Since formulae are essentially
nipkow@10133
    11
(syntax) trees, they are naturally modelled as a datatype:%
nipkow@10133
    12
\end{isamarkuptext}%
nipkow@10149
    13
\isacommand{datatype}\ formula\ {\isacharequal}\ Atom\ atom\isanewline
nipkow@10149
    14
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {\isacharbar}\ Neg\ formula\isanewline
nipkow@10149
    15
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {\isacharbar}\ And\ formula\ formula\isanewline
nipkow@10149
    16
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {\isacharbar}\ AX\ formula\isanewline
nipkow@10149
    17
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {\isacharbar}\ EF\ formula%
nipkow@10133
    18
\begin{isamarkuptext}%
nipkow@10133
    19
\noindent
nipkow@10149
    20
This is almost the same as in the boolean expression case study in
nipkow@10149
    21
\S\ref{sec:boolex}, except that what used to be called \isa{Var} is now
nipkow@10149
    22
called \isa{formula{\isachardot}Atom}.
nipkow@10149
    23
nipkow@10133
    24
The meaning of these formulae is given by saying which formula is true in
nipkow@10133
    25
which state:%
nipkow@10133
    26
\end{isamarkuptext}%
nipkow@10149
    27
\isacommand{consts}\ valid\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}state\ {\isasymRightarrow}\ formula\ {\isasymRightarrow}\ bool{\isachardoublequote}\ \ \ {\isacharparenleft}{\isachardoublequote}{\isacharparenleft}{\isacharunderscore}\ {\isasymTurnstile}\ {\isacharunderscore}{\isacharparenright}{\isachardoublequote}\ {\isacharbrackleft}\isadigit{8}\isadigit{0}{\isacharcomma}\isadigit{8}\isadigit{0}{\isacharbrackright}\ \isadigit{8}\isadigit{0}{\isacharparenright}%
nipkow@10149
    28
\begin{isamarkuptext}%
nipkow@10149
    29
\noindent
nipkow@10149
    30
The concrete syntax annotation allows us to write \isa{s\ {\isasymTurnstile}\ f} instead of
nipkow@10149
    31
\isa{valid\ s\ f}.
nipkow@10149
    32
nipkow@10149
    33
The definition of \isa{{\isasymTurnstile}} is by recursion over the syntax:%
nipkow@10149
    34
\end{isamarkuptext}%
nipkow@10123
    35
\isacommand{primrec}\isanewline
nipkow@10133
    36
{\isachardoublequote}s\ {\isasymTurnstile}\ Atom\ a\ \ {\isacharequal}\ {\isacharparenleft}a\ {\isasymin}\ L\ s{\isacharparenright}{\isachardoublequote}\isanewline
nipkow@10149
    37
{\isachardoublequote}s\ {\isasymTurnstile}\ Neg\ f\ \ \ {\isacharequal}\ {\isacharparenleft}{\isasymnot}{\isacharparenleft}s\ {\isasymTurnstile}\ f{\isacharparenright}{\isacharparenright}{\isachardoublequote}\isanewline
nipkow@10123
    38
{\isachardoublequote}s\ {\isasymTurnstile}\ And\ f\ g\ {\isacharequal}\ {\isacharparenleft}s\ {\isasymTurnstile}\ f\ {\isasymand}\ s\ {\isasymTurnstile}\ g{\isacharparenright}{\isachardoublequote}\isanewline
nipkow@10123
    39
{\isachardoublequote}s\ {\isasymTurnstile}\ AX\ f\ \ \ \ {\isacharequal}\ {\isacharparenleft}{\isasymforall}t{\isachardot}\ {\isacharparenleft}s{\isacharcomma}t{\isacharparenright}\ {\isasymin}\ M\ {\isasymlongrightarrow}\ t\ {\isasymTurnstile}\ f{\isacharparenright}{\isachardoublequote}\isanewline
nipkow@10133
    40
{\isachardoublequote}s\ {\isasymTurnstile}\ EF\ f\ \ \ \ {\isacharequal}\ {\isacharparenleft}{\isasymexists}t{\isachardot}\ {\isacharparenleft}s{\isacharcomma}t{\isacharparenright}\ {\isasymin}\ M{\isacharcircum}{\isacharasterisk}\ {\isasymand}\ t\ {\isasymTurnstile}\ f{\isacharparenright}{\isachardoublequote}%
nipkow@10133
    41
\begin{isamarkuptext}%
nipkow@10149
    42
\noindent
nipkow@10149
    43
The first three equations should be self-explanatory. The temporal formula
nipkow@10149
    44
\isa{AX\ f} means that \isa{f} is true in all next states whereas
nipkow@10149
    45
\isa{EF\ f} means that there exists some future state in which \isa{f} is
nipkow@10149
    46
true. The future is expressed via \isa{{\isacharcircum}{\isacharasterisk}}, the transitive reflexive
nipkow@10149
    47
closure. Because of reflexivity, the future includes the present.
nipkow@10149
    48
nipkow@10133
    49
Now we come to the model checker itself. It maps a formula into the set of
nipkow@10149
    50
states where the formula is true and is defined by recursion over the syntax,
nipkow@10149
    51
too:%
nipkow@10133
    52
\end{isamarkuptext}%
nipkow@10149
    53
\isacommand{consts}\ mc\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}formula\ {\isasymRightarrow}\ state\ set{\isachardoublequote}\isanewline
nipkow@10123
    54
\isacommand{primrec}\isanewline
nipkow@10133
    55
{\isachardoublequote}mc{\isacharparenleft}Atom\ a{\isacharparenright}\ \ {\isacharequal}\ {\isacharbraceleft}s{\isachardot}\ a\ {\isasymin}\ L\ s{\isacharbraceright}{\isachardoublequote}\isanewline
nipkow@10149
    56
{\isachardoublequote}mc{\isacharparenleft}Neg\ f{\isacharparenright}\ \ \ {\isacharequal}\ {\isacharminus}mc\ f{\isachardoublequote}\isanewline
nipkow@10133
    57
{\isachardoublequote}mc{\isacharparenleft}And\ f\ g{\isacharparenright}\ {\isacharequal}\ mc\ f\ {\isasyminter}\ mc\ g{\isachardoublequote}\isanewline
nipkow@10123
    58
{\isachardoublequote}mc{\isacharparenleft}AX\ f{\isacharparenright}\ \ \ \ {\isacharequal}\ {\isacharbraceleft}s{\isachardot}\ {\isasymforall}t{\isachardot}\ {\isacharparenleft}s{\isacharcomma}t{\isacharparenright}\ {\isasymin}\ M\ \ {\isasymlongrightarrow}\ t\ {\isasymin}\ mc\ f{\isacharbraceright}{\isachardoublequote}\isanewline
nipkow@10133
    59
{\isachardoublequote}mc{\isacharparenleft}EF\ f{\isacharparenright}\ \ \ \ {\isacharequal}\ lfp{\isacharparenleft}{\isasymlambda}T{\isachardot}\ mc\ f\ {\isasymunion}\ M{\isacharcircum}{\isacharminus}\isadigit{1}\ {\isacharcircum}{\isacharcircum}\ T{\isacharparenright}{\isachardoublequote}%
nipkow@10133
    60
\begin{isamarkuptext}%
nipkow@10149
    61
\noindent
nipkow@10149
    62
Only the equation for \isa{EF} deserves some comments. Remember that the
nipkow@10149
    63
postfix \isa{{\isacharcircum}{\isacharminus}\isadigit{1}} and the infix \isa{{\isacharcircum}{\isacharcircum}} are predefined and denote the
nipkow@10149
    64
converse of a relation and the application of a relation to a set. Thus
nipkow@10149
    65
\isa{M{\isacharcircum}{\isacharminus}\isadigit{1}\ {\isacharcircum}{\isacharcircum}\ T} is the set of all predecessors of \isa{T} and the least
nipkow@10149
    66
fixpoint (\isa{lfp}) of \isa{{\isasymlambda}T{\isachardot}\ mc\ f\ {\isasymunion}\ M{\isacharcircum}{\isacharminus}\isadigit{1}\ {\isacharcircum}{\isacharcircum}\ T} is the least set
nipkow@10149
    67
\isa{T} containing \isa{mc\ f} and all predecessors of \isa{T}. If you
nipkow@10149
    68
find it hard to see that \isa{mc\ {\isacharparenleft}EF\ f{\isacharparenright}} contains exactly those states from
nipkow@10149
    69
which there is a path to a state where \isa{f} is true, do not worry---that
nipkow@10149
    70
will be proved in a moment.
nipkow@10149
    71
nipkow@10149
    72
First we prove monotonicity of the function inside \isa{lfp}%
nipkow@10133
    73
\end{isamarkuptext}%
nipkow@10149
    74
\isacommand{lemma}\ mono{\isacharunderscore}ef{\isacharcolon}\ {\isachardoublequote}mono{\isacharparenleft}{\isasymlambda}T{\isachardot}\ A\ {\isasymunion}\ M{\isacharcircum}{\isacharminus}\isadigit{1}\ {\isacharcircum}{\isacharcircum}\ T{\isacharparenright}{\isachardoublequote}\isanewline
nipkow@10123
    75
\isacommand{apply}{\isacharparenleft}rule\ monoI{\isacharparenright}\isanewline
nipkow@10149
    76
\isacommand{by}{\isacharparenleft}blast{\isacharparenright}%
nipkow@10149
    77
\begin{isamarkuptext}%
nipkow@10149
    78
\noindent
nipkow@10149
    79
in order to make sure it really has a least fixpoint.
nipkow@10149
    80
nipkow@10149
    81
Now we can relate model checking and semantics. For the \isa{EF} case we need
nipkow@10149
    82
a separate lemma:%
nipkow@10149
    83
\end{isamarkuptext}%
nipkow@10149
    84
\isacommand{lemma}\ EF{\isacharunderscore}lemma{\isacharcolon}\isanewline
nipkow@10149
    85
\ \ {\isachardoublequote}lfp{\isacharparenleft}{\isasymlambda}T{\isachardot}\ A\ {\isasymunion}\ M{\isacharcircum}{\isacharminus}\isadigit{1}\ {\isacharcircum}{\isacharcircum}\ T{\isacharparenright}\ {\isacharequal}\ {\isacharbraceleft}s{\isachardot}\ {\isasymexists}t{\isachardot}\ {\isacharparenleft}s{\isacharcomma}t{\isacharparenright}\ {\isasymin}\ M{\isacharcircum}{\isacharasterisk}\ {\isasymand}\ t\ {\isasymin}\ A{\isacharbraceright}{\isachardoublequote}%
nipkow@10149
    86
\begin{isamarkuptxt}%
nipkow@10149
    87
\noindent
nipkow@10149
    88
The equality is proved in the canonical fashion by proving that each set
nipkow@10149
    89
contains the other; the containment is shown pointwise:%
nipkow@10149
    90
\end{isamarkuptxt}%
nipkow@10123
    91
\isacommand{apply}{\isacharparenleft}rule\ equalityI{\isacharparenright}\isanewline
nipkow@10123
    92
\ \isacommand{apply}{\isacharparenleft}rule\ subsetI{\isacharparenright}\isanewline
nipkow@10149
    93
\ \isacommand{apply}{\isacharparenleft}simp{\isacharparenright}%
nipkow@10149
    94
\begin{isamarkuptxt}%
nipkow@10149
    95
\noindent
nipkow@10149
    96
Simplification leaves us with the following first subgoal
nipkow@10149
    97
\begin{isabelle}
nipkow@10149
    98
\ \isadigit{1}{\isachardot}\ {\isasymAnd}s{\isachardot}\ s\ {\isasymin}\ lfp\ {\isacharparenleft}{\isasymlambda}T{\isachardot}\ A\ {\isasymunion}\ M{\isacharcircum}{\isacharminus}\isadigit{1}\ {\isacharcircum}{\isacharcircum}\ T{\isacharparenright}\ {\isasymLongrightarrow}\ {\isasymexists}t{\isachardot}\ {\isacharparenleft}s{\isacharcomma}\ t{\isacharparenright}\ {\isasymin}\ M{\isacharcircum}{\isacharasterisk}\ {\isasymand}\ t\ {\isasymin}\ A
nipkow@10149
    99
\end{isabelle}
nipkow@10149
   100
which is proved by \isa{lfp}-induction:%
nipkow@10149
   101
\end{isamarkuptxt}%
nipkow@10123
   102
\ \isacommand{apply}{\isacharparenleft}erule\ Lfp{\isachardot}induct{\isacharparenright}\isanewline
nipkow@10149
   103
\ \ \isacommand{apply}{\isacharparenleft}rule\ mono{\isacharunderscore}ef{\isacharparenright}\isanewline
nipkow@10149
   104
\ \isacommand{apply}{\isacharparenleft}simp{\isacharparenright}%
nipkow@10149
   105
\begin{isamarkuptxt}%
nipkow@10149
   106
\noindent
nipkow@10149
   107
Having disposed of the monotonicity subgoal,
nipkow@10149
   108
simplification leaves us with the following main goal
nipkow@10149
   109
\begin{isabelle}
nipkow@10149
   110
\ \isadigit{1}{\isachardot}\ {\isasymAnd}s{\isachardot}\ s\ {\isasymin}\ A\ {\isasymor}\isanewline
nipkow@10149
   111
\ \ \ \ \ \ \ \ \ s\ {\isasymin}\ M{\isacharcircum}{\isacharminus}\isadigit{1}\ {\isacharcircum}{\isacharcircum}\ {\isacharparenleft}lfp\ {\isacharparenleft}{\dots}{\isacharparenright}\ {\isasyminter}\ {\isacharbraceleft}x{\isachardot}\ {\isasymexists}t{\isachardot}\ {\isacharparenleft}x{\isacharcomma}\ t{\isacharparenright}\ {\isasymin}\ M{\isacharcircum}{\isacharasterisk}\ {\isasymand}\ t\ {\isasymin}\ A{\isacharbraceright}{\isacharparenright}\isanewline
nipkow@10149
   112
\ \ \ \ \ \ \ \ \ {\isasymLongrightarrow}\ {\isasymexists}t{\isachardot}\ {\isacharparenleft}s{\isacharcomma}\ t{\isacharparenright}\ {\isasymin}\ M{\isacharcircum}{\isacharasterisk}\ {\isasymand}\ t\ {\isasymin}\ A
nipkow@10149
   113
\end{isabelle}
nipkow@10149
   114
which is proved by \isa{blast} with the help of a few lemmas about
nipkow@10149
   115
\isa{{\isacharcircum}{\isacharasterisk}}:%
nipkow@10149
   116
\end{isamarkuptxt}%
nipkow@10149
   117
\ \isacommand{apply}{\isacharparenleft}blast\ intro{\isacharcolon}\ r{\isacharunderscore}into{\isacharunderscore}rtrancl\ rtrancl{\isacharunderscore}trans{\isacharparenright}%
nipkow@10149
   118
\begin{isamarkuptxt}%
nipkow@10149
   119
We now return to the second set containment subgoal, which is again proved
nipkow@10149
   120
pointwise:%
nipkow@10149
   121
\end{isamarkuptxt}%
nipkow@10123
   122
\isacommand{apply}{\isacharparenleft}rule\ subsetI{\isacharparenright}\isanewline
nipkow@10149
   123
\isacommand{apply}{\isacharparenleft}simp{\isacharcomma}\ clarify{\isacharparenright}%
nipkow@10149
   124
\begin{isamarkuptxt}%
nipkow@10149
   125
\noindent
nipkow@10149
   126
After simplification and clarification we are left with
nipkow@10149
   127
\begin{isabelle}
nipkow@10149
   128
\ \isadigit{1}{\isachardot}\ {\isasymAnd}s\ t{\isachardot}\ {\isasymlbrakk}{\isacharparenleft}s{\isacharcomma}\ t{\isacharparenright}\ {\isasymin}\ M{\isacharcircum}{\isacharasterisk}{\isacharsemicolon}\ t\ {\isasymin}\ A{\isasymrbrakk}\ {\isasymLongrightarrow}\ s\ {\isasymin}\ lfp\ {\isacharparenleft}{\isasymlambda}T{\isachardot}\ A\ {\isasymunion}\ M{\isacharcircum}{\isacharminus}\isadigit{1}\ {\isacharcircum}{\isacharcircum}\ T{\isacharparenright}
nipkow@10149
   129
\end{isabelle}
nipkow@10149
   130
This goal is proved by induction on \isa{{\isacharparenleft}s{\isacharcomma}\ t{\isacharparenright}\ {\isasymin}\ M{\isacharcircum}{\isacharasterisk}}. But since the model
nipkow@10149
   131
checker works backwards (from \isa{t} to \isa{s}), we cannot use the
nipkow@10149
   132
induction theorem \isa{rtrancl{\isacharunderscore}induct} because it works in the
nipkow@10149
   133
forward direction. Fortunately the converse induction theorem
nipkow@10149
   134
\isa{converse{\isacharunderscore}rtrancl{\isacharunderscore}induct} already exists:
nipkow@10149
   135
\begin{isabelle}%
nipkow@10149
   136
\ \ \ \ \ {\isasymlbrakk}{\isacharparenleft}a{\isacharcomma}\ b{\isacharparenright}\ {\isasymin}\ r{\isacharcircum}{\isacharasterisk}{\isacharsemicolon}\ P\ b{\isacharsemicolon}\isanewline
nipkow@10149
   137
\ \ \ \ \ \ \ \ {\isasymAnd}y\ z{\isachardot}\ {\isasymlbrakk}{\isacharparenleft}y{\isacharcomma}\ z{\isacharparenright}\ {\isasymin}\ r{\isacharsemicolon}\ {\isacharparenleft}z{\isacharcomma}\ b{\isacharparenright}\ {\isasymin}\ r{\isacharcircum}{\isacharasterisk}{\isacharsemicolon}\ P\ z{\isasymrbrakk}\ {\isasymLongrightarrow}\ P\ y{\isasymrbrakk}\isanewline
nipkow@10149
   138
\ \ \ \ \ {\isasymLongrightarrow}\ P\ a%
nipkow@10149
   139
\end{isabelle}
nipkow@10149
   140
It says that if \isa{{\isacharparenleft}a{\isacharcomma}\ b{\isacharparenright}\ {\isasymin}\ r{\isacharcircum}{\isacharasterisk}} and we know \isa{P\ b} then we can infer
nipkow@10149
   141
\isa{P\ a} provided each step backwards from a predecessor \isa{z} of
nipkow@10149
   142
\isa{b} preserves \isa{P}.%
nipkow@10149
   143
\end{isamarkuptxt}%
nipkow@10149
   144
\isacommand{apply}{\isacharparenleft}erule\ converse{\isacharunderscore}rtrancl{\isacharunderscore}induct{\isacharparenright}%
nipkow@10149
   145
\begin{isamarkuptxt}%
nipkow@10149
   146
\noindent
nipkow@10149
   147
The base case
nipkow@10149
   148
\begin{isabelle}
nipkow@10149
   149
\ \isadigit{1}{\isachardot}\ {\isasymAnd}t{\isachardot}\ t\ {\isasymin}\ A\ {\isasymLongrightarrow}\ t\ {\isasymin}\ lfp\ {\isacharparenleft}{\isasymlambda}T{\isachardot}\ A\ {\isasymunion}\ M{\isacharcircum}{\isacharminus}\isadigit{1}\ {\isacharcircum}{\isacharcircum}\ T{\isacharparenright}
nipkow@10149
   150
\end{isabelle}
nipkow@10149
   151
is solved by unrolling \isa{lfp} once%
nipkow@10149
   152
\end{isamarkuptxt}%
nipkow@10149
   153
\ \isacommand{apply}{\isacharparenleft}rule\ ssubst{\isacharbrackleft}OF\ lfp{\isacharunderscore}Tarski{\isacharbrackleft}OF\ mono{\isacharunderscore}ef{\isacharbrackright}{\isacharbrackright}{\isacharparenright}%
nipkow@10149
   154
\begin{isamarkuptxt}%
nipkow@10149
   155
\begin{isabelle}
nipkow@10149
   156
\ \isadigit{1}{\isachardot}\ {\isasymAnd}t{\isachardot}\ t\ {\isasymin}\ A\ {\isasymLongrightarrow}\ t\ {\isasymin}\ A\ {\isasymunion}\ M{\isacharcircum}{\isacharminus}\isadigit{1}\ {\isacharcircum}{\isacharcircum}\ lfp\ {\isacharparenleft}{\isasymlambda}T{\isachardot}\ A\ {\isasymunion}\ M{\isacharcircum}{\isacharminus}\isadigit{1}\ {\isacharcircum}{\isacharcircum}\ T{\isacharparenright}
nipkow@10149
   157
\end{isabelle}
nipkow@10149
   158
and disposing of the resulting trivial subgoal automatically:%
nipkow@10149
   159
\end{isamarkuptxt}%
nipkow@10149
   160
\ \isacommand{apply}{\isacharparenleft}blast{\isacharparenright}%
nipkow@10149
   161
\begin{isamarkuptxt}%
nipkow@10149
   162
\noindent
nipkow@10149
   163
The proof of the induction step is identical to the one for the base case:%
nipkow@10149
   164
\end{isamarkuptxt}%
nipkow@10149
   165
\isacommand{apply}{\isacharparenleft}rule\ ssubst{\isacharbrackleft}OF\ lfp{\isacharunderscore}Tarski{\isacharbrackleft}OF\ mono{\isacharunderscore}ef{\isacharbrackright}{\isacharbrackright}{\isacharparenright}\isanewline
nipkow@10149
   166
\isacommand{by}{\isacharparenleft}blast{\isacharparenright}%
nipkow@10149
   167
\begin{isamarkuptext}%
nipkow@10149
   168
The main theorem is proved in the familiar manner: induction followed by
nipkow@10149
   169
\isa{auto} augmented with the lemma as a simplification rule.%
nipkow@10149
   170
\end{isamarkuptext}%
nipkow@10123
   171
\isacommand{theorem}\ {\isachardoublequote}mc\ f\ {\isacharequal}\ {\isacharbraceleft}s{\isachardot}\ s\ {\isasymTurnstile}\ f{\isacharbraceright}{\isachardoublequote}\isanewline
nipkow@10123
   172
\isacommand{apply}{\isacharparenleft}induct{\isacharunderscore}tac\ f{\isacharparenright}\isanewline
nipkow@10149
   173
\isacommand{by}{\isacharparenleft}auto\ simp\ add{\isacharcolon}EF{\isacharunderscore}lemma{\isacharparenright}\end{isabellebody}%
nipkow@10123
   174
%%% Local Variables:
nipkow@10123
   175
%%% mode: latex
nipkow@10123
   176
%%% TeX-master: "root"
nipkow@10123
   177
%%% End: