doc-src/TutorialI/CTL/document/PDL.tex
author paulson
Tue, 10 Feb 2004 12:17:04 +0100
changeset 14379 ea10a8c3e9cf
parent 13791 3b6ff7ceaf27
child 15488 7c638a46dcbb
permissions -rw-r--r--
updated links to the old ftp site
     1 %
     2 \begin{isabellebody}%
     3 \def\isabellecontext{PDL}%
     4 \isamarkupfalse%
     5 %
     6 \isamarkupsubsection{Propositional Dynamic Logic --- PDL%
     7 }
     8 \isamarkuptrue%
     9 %
    10 \begin{isamarkuptext}%
    11 \index{PDL|(}
    12 The formulae of PDL are built up from atomic propositions via
    13 negation and conjunction and the two temporal
    14 connectives \isa{AX} and \isa{EF}\@. Since formulae are essentially
    15 syntax trees, they are naturally modelled as a datatype:%
    16 \footnote{The customary definition of PDL
    17 \cite{HarelKT-DL} looks quite different from ours, but the two are easily
    18 shown to be equivalent.}%
    19 \end{isamarkuptext}%
    20 \isamarkuptrue%
    21 \isacommand{datatype}\ formula\ {\isacharequal}\ Atom\ atom\isanewline
    22 \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {\isacharbar}\ Neg\ formula\isanewline
    23 \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {\isacharbar}\ And\ formula\ formula\isanewline
    24 \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {\isacharbar}\ AX\ formula\isanewline
    25 \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ {\isacharbar}\ EF\ formula\isamarkupfalse%
    26 %
    27 \begin{isamarkuptext}%
    28 \noindent
    29 This resembles the boolean expression case study in
    30 \S\ref{sec:boolex}.
    31 A validity relation between
    32 states and formulae specifies the semantics:%
    33 \end{isamarkuptext}%
    34 \isamarkuptrue%
    35 \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}\isamarkupfalse%
    36 %
    37 \begin{isamarkuptext}%
    38 \noindent
    39 The syntax annotation allows us to write \isa{s\ {\isasymTurnstile}\ f} instead of
    40 \hbox{\isa{valid\ s\ f}}.
    41 The definition of \isa{{\isasymTurnstile}} is by recursion over the syntax:%
    42 \end{isamarkuptext}%
    43 \isamarkuptrue%
    44 \isacommand{primrec}\isanewline
    45 {\isachardoublequote}s\ {\isasymTurnstile}\ Atom\ a\ \ {\isacharequal}\ {\isacharparenleft}a\ {\isasymin}\ L\ s{\isacharparenright}{\isachardoublequote}\isanewline
    46 {\isachardoublequote}s\ {\isasymTurnstile}\ Neg\ f\ \ \ {\isacharequal}\ {\isacharparenleft}{\isasymnot}{\isacharparenleft}s\ {\isasymTurnstile}\ f{\isacharparenright}{\isacharparenright}{\isachardoublequote}\isanewline
    47 {\isachardoublequote}s\ {\isasymTurnstile}\ And\ f\ g\ {\isacharequal}\ {\isacharparenleft}s\ {\isasymTurnstile}\ f\ {\isasymand}\ s\ {\isasymTurnstile}\ g{\isacharparenright}{\isachardoublequote}\isanewline
    48 {\isachardoublequote}s\ {\isasymTurnstile}\ AX\ f\ \ \ \ {\isacharequal}\ {\isacharparenleft}{\isasymforall}t{\isachardot}\ {\isacharparenleft}s{\isacharcomma}t{\isacharparenright}\ {\isasymin}\ M\ {\isasymlongrightarrow}\ t\ {\isasymTurnstile}\ f{\isacharparenright}{\isachardoublequote}\isanewline
    49 {\isachardoublequote}s\ {\isasymTurnstile}\ EF\ f\ \ \ \ {\isacharequal}\ {\isacharparenleft}{\isasymexists}t{\isachardot}\ {\isacharparenleft}s{\isacharcomma}t{\isacharparenright}\ {\isasymin}\ M\isactrlsup {\isacharasterisk}\ {\isasymand}\ t\ {\isasymTurnstile}\ f{\isacharparenright}{\isachardoublequote}\isamarkupfalse%
    50 %
    51 \begin{isamarkuptext}%
    52 \noindent
    53 The first three equations should be self-explanatory. The temporal formula
    54 \isa{AX\ f} means that \isa{f} is true in \emph{A}ll ne\emph{X}t states whereas
    55 \isa{EF\ f} means that there \emph{E}xists some \emph{F}uture state in which \isa{f} is
    56 true. The future is expressed via \isa{\isactrlsup {\isacharasterisk}}, the reflexive transitive
    57 closure. Because of reflexivity, the future includes the present.
    58 
    59 Now we come to the model checker itself. It maps a formula into the set of
    60 states where the formula is true.  It too is defined by recursion over the syntax:%
    61 \end{isamarkuptext}%
    62 \isamarkuptrue%
    63 \isacommand{consts}\ mc\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequote}formula\ {\isasymRightarrow}\ state\ set{\isachardoublequote}\isanewline
    64 \isamarkupfalse%
    65 \isacommand{primrec}\isanewline
    66 {\isachardoublequote}mc{\isacharparenleft}Atom\ a{\isacharparenright}\ \ {\isacharequal}\ {\isacharbraceleft}s{\isachardot}\ a\ {\isasymin}\ L\ s{\isacharbraceright}{\isachardoublequote}\isanewline
    67 {\isachardoublequote}mc{\isacharparenleft}Neg\ f{\isacharparenright}\ \ \ {\isacharequal}\ {\isacharminus}mc\ f{\isachardoublequote}\isanewline
    68 {\isachardoublequote}mc{\isacharparenleft}And\ f\ g{\isacharparenright}\ {\isacharequal}\ mc\ f\ {\isasyminter}\ mc\ g{\isachardoublequote}\isanewline
    69 {\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
    70 {\isachardoublequote}mc{\isacharparenleft}EF\ f{\isacharparenright}\ \ \ \ {\isacharequal}\ lfp{\isacharparenleft}{\isasymlambda}T{\isachardot}\ mc\ f\ {\isasymunion}\ {\isacharparenleft}M{\isasyminverse}\ {\isacharbackquote}{\isacharbackquote}\ T{\isacharparenright}{\isacharparenright}{\isachardoublequote}\isamarkupfalse%
    71 %
    72 \begin{isamarkuptext}%
    73 \noindent
    74 Only the equation for \isa{EF} deserves some comments. Remember that the
    75 postfix \isa{{\isasyminverse}} and the infix \isa{{\isacharbackquote}{\isacharbackquote}} are predefined and denote the
    76 converse of a relation and the image of a set under a relation.  Thus
    77 \isa{M{\isasyminverse}\ {\isacharbackquote}{\isacharbackquote}\ T} is the set of all predecessors of \isa{T} and the least
    78 fixed point (\isa{lfp}) of \isa{{\isasymlambda}T{\isachardot}\ mc\ f\ {\isasymunion}\ M{\isasyminverse}\ {\isacharbackquote}{\isacharbackquote}\ T} is the least set
    79 \isa{T} containing \isa{mc\ f} and all predecessors of \isa{T}. If you
    80 find it hard to see that \isa{mc\ {\isacharparenleft}EF\ f{\isacharparenright}} contains exactly those states from
    81 which there is a path to a state where \isa{f} is true, do not worry --- this
    82 will be proved in a moment.
    83 
    84 First we prove monotonicity of the function inside \isa{lfp}
    85 in order to make sure it really has a least fixed point.%
    86 \end{isamarkuptext}%
    87 \isamarkuptrue%
    88 \isacommand{lemma}\ mono{\isacharunderscore}ef{\isacharcolon}\ {\isachardoublequote}mono{\isacharparenleft}{\isasymlambda}T{\isachardot}\ A\ {\isasymunion}\ {\isacharparenleft}M{\isasyminverse}\ {\isacharbackquote}{\isacharbackquote}\ T{\isacharparenright}{\isacharparenright}{\isachardoublequote}\isanewline
    89 \isamarkupfalse%
    90 \isacommand{apply}{\isacharparenleft}rule\ monoI{\isacharparenright}\isanewline
    91 \isamarkupfalse%
    92 \isacommand{apply}\ blast\isanewline
    93 \isamarkupfalse%
    94 \isacommand{done}\isamarkupfalse%
    95 %
    96 \begin{isamarkuptext}%
    97 \noindent
    98 Now we can relate model checking and semantics. For the \isa{EF} case we need
    99 a separate lemma:%
   100 \end{isamarkuptext}%
   101 \isamarkuptrue%
   102 \isacommand{lemma}\ EF{\isacharunderscore}lemma{\isacharcolon}\isanewline
   103 \ \ {\isachardoublequote}lfp{\isacharparenleft}{\isasymlambda}T{\isachardot}\ A\ {\isasymunion}\ {\isacharparenleft}M{\isasyminverse}\ {\isacharbackquote}{\isacharbackquote}\ T{\isacharparenright}{\isacharparenright}\ {\isacharequal}\ {\isacharbraceleft}s{\isachardot}\ {\isasymexists}t{\isachardot}\ {\isacharparenleft}s{\isacharcomma}t{\isacharparenright}\ {\isasymin}\ M\isactrlsup {\isacharasterisk}\ {\isasymand}\ t\ {\isasymin}\ A{\isacharbraceright}{\isachardoublequote}\isamarkupfalse%
   104 %
   105 \begin{isamarkuptxt}%
   106 \noindent
   107 The equality is proved in the canonical fashion by proving that each set
   108 includes the other; the inclusion is shown pointwise:%
   109 \end{isamarkuptxt}%
   110 \isamarkuptrue%
   111 \isacommand{apply}{\isacharparenleft}rule\ equalityI{\isacharparenright}\isanewline
   112 \ \isamarkupfalse%
   113 \isacommand{apply}{\isacharparenleft}rule\ subsetI{\isacharparenright}\isanewline
   114 \ \isamarkupfalse%
   115 \isacommand{apply}{\isacharparenleft}simp{\isacharparenright}\isamarkupfalse%
   116 \isamarkupfalse%
   117 %
   118 \begin{isamarkuptxt}%
   119 \noindent
   120 Simplification leaves us with the following first subgoal
   121 \begin{isabelle}%
   122 \ {\isadigit{1}}{\isachardot}\ {\isasymAnd}s{\isachardot}\ s\ {\isasymin}\ lfp\ {\isacharparenleft}{\isasymlambda}T{\isachardot}\ A\ {\isasymunion}\ M{\isasyminverse}\ {\isacharbackquote}{\isacharbackquote}\ T{\isacharparenright}\ {\isasymLongrightarrow}\ {\isasymexists}t{\isachardot}\ {\isacharparenleft}s{\isacharcomma}\ t{\isacharparenright}\ {\isasymin}\ M\isactrlsup {\isacharasterisk}\ {\isasymand}\ t\ {\isasymin}\ A%
   123 \end{isabelle}
   124 which is proved by \isa{lfp}-induction:%
   125 \end{isamarkuptxt}%
   126 \ \isamarkuptrue%
   127 \isacommand{apply}{\isacharparenleft}erule\ lfp{\isacharunderscore}induct{\isacharparenright}\isanewline
   128 \ \ \isamarkupfalse%
   129 \isacommand{apply}{\isacharparenleft}rule\ mono{\isacharunderscore}ef{\isacharparenright}\isanewline
   130 \ \isamarkupfalse%
   131 \isacommand{apply}{\isacharparenleft}simp{\isacharparenright}\isamarkupfalse%
   132 %
   133 \begin{isamarkuptxt}%
   134 \noindent
   135 Having disposed of the monotonicity subgoal,
   136 simplification leaves us with the following goal:
   137 \begin{isabelle}
   138 \ {\isadigit{1}}{\isachardot}\ {\isasymAnd}x{\isachardot}\ x\ {\isasymin}\ A\ {\isasymor}\isanewline
   139 \ \ \ \ \ \ \ \ \ x\ {\isasymin}\ M{\isasyminverse}\ {\isacharbackquote}{\isacharbackquote}\ {\isacharparenleft}lfp\ {\isacharparenleft}\dots{\isacharparenright}\ {\isasyminter}\ {\isacharbraceleft}x{\isachardot}\ {\isasymexists}t{\isachardot}\ {\isacharparenleft}x{\isacharcomma}\ t{\isacharparenright}\ {\isasymin}\ M\isactrlsup {\isacharasterisk}\ {\isasymand}\ t\ {\isasymin}\ A{\isacharbraceright}{\isacharparenright}\isanewline
   140 \ \ \ \ \ \ \ \ {\isasymLongrightarrow}\ {\isasymexists}t{\isachardot}\ {\isacharparenleft}x{\isacharcomma}\ t{\isacharparenright}\ {\isasymin}\ M\isactrlsup {\isacharasterisk}\ {\isasymand}\ t\ {\isasymin}\ A
   141 \end{isabelle}
   142 It is proved by \isa{blast}, using the transitivity of 
   143 \isa{M\isactrlsup {\isacharasterisk}}.%
   144 \end{isamarkuptxt}%
   145 \ \isamarkuptrue%
   146 \isacommand{apply}{\isacharparenleft}blast\ intro{\isacharcolon}\ rtrancl{\isacharunderscore}trans{\isacharparenright}\isamarkupfalse%
   147 %
   148 \begin{isamarkuptxt}%
   149 We now return to the second set inclusion subgoal, which is again proved
   150 pointwise:%
   151 \end{isamarkuptxt}%
   152 \isamarkuptrue%
   153 \isacommand{apply}{\isacharparenleft}rule\ subsetI{\isacharparenright}\isanewline
   154 \isamarkupfalse%
   155 \isacommand{apply}{\isacharparenleft}simp{\isacharcomma}\ clarify{\isacharparenright}\isamarkupfalse%
   156 %
   157 \begin{isamarkuptxt}%
   158 \noindent
   159 After simplification and clarification we are left with
   160 \begin{isabelle}%
   161 \ {\isadigit{1}}{\isachardot}\ {\isasymAnd}x\ t{\isachardot}\ {\isasymlbrakk}{\isacharparenleft}x{\isacharcomma}\ t{\isacharparenright}\ {\isasymin}\ M\isactrlsup {\isacharasterisk}{\isacharsemicolon}\ t\ {\isasymin}\ A{\isasymrbrakk}\ {\isasymLongrightarrow}\ x\ {\isasymin}\ lfp\ {\isacharparenleft}{\isasymlambda}T{\isachardot}\ A\ {\isasymunion}\ M{\isasyminverse}\ {\isacharbackquote}{\isacharbackquote}\ T{\isacharparenright}%
   162 \end{isabelle}
   163 This goal is proved by induction on \isa{{\isacharparenleft}s{\isacharcomma}\ t{\isacharparenright}\ {\isasymin}\ M\isactrlsup {\isacharasterisk}}. But since the model
   164 checker works backwards (from \isa{t} to \isa{s}), we cannot use the
   165 induction theorem \isa{rtrancl{\isacharunderscore}induct}: it works in the
   166 forward direction. Fortunately the converse induction theorem
   167 \isa{converse{\isacharunderscore}rtrancl{\isacharunderscore}induct} already exists:
   168 \begin{isabelle}%
   169 \ \ \ \ \ {\isasymlbrakk}{\isacharparenleft}a{\isacharcomma}\ b{\isacharparenright}\ {\isasymin}\ r\isactrlsup {\isacharasterisk}{\isacharsemicolon}\ P\ b{\isacharsemicolon}\isanewline
   170 \isaindent{\ \ \ \ \ \ }{\isasymAnd}y\ z{\isachardot}\ {\isasymlbrakk}{\isacharparenleft}y{\isacharcomma}\ z{\isacharparenright}\ {\isasymin}\ r{\isacharsemicolon}\ {\isacharparenleft}z{\isacharcomma}\ b{\isacharparenright}\ {\isasymin}\ r\isactrlsup {\isacharasterisk}{\isacharsemicolon}\ P\ z{\isasymrbrakk}\ {\isasymLongrightarrow}\ P\ y{\isasymrbrakk}\isanewline
   171 \isaindent{\ \ \ \ \ }{\isasymLongrightarrow}\ P\ a%
   172 \end{isabelle}
   173 It says that if \isa{{\isacharparenleft}a{\isacharcomma}\ b{\isacharparenright}\ {\isasymin}\ r\isactrlsup {\isacharasterisk}} and we know \isa{P\ b} then we can infer
   174 \isa{P\ a} provided each step backwards from a predecessor \isa{z} of
   175 \isa{b} preserves \isa{P}.%
   176 \end{isamarkuptxt}%
   177 \isamarkuptrue%
   178 \isacommand{apply}{\isacharparenleft}erule\ converse{\isacharunderscore}rtrancl{\isacharunderscore}induct{\isacharparenright}\isamarkupfalse%
   179 %
   180 \begin{isamarkuptxt}%
   181 \noindent
   182 The base case
   183 \begin{isabelle}%
   184 \ {\isadigit{1}}{\isachardot}\ {\isasymAnd}x\ t{\isachardot}\ t\ {\isasymin}\ A\ {\isasymLongrightarrow}\ t\ {\isasymin}\ lfp\ {\isacharparenleft}{\isasymlambda}T{\isachardot}\ A\ {\isasymunion}\ M{\isasyminverse}\ {\isacharbackquote}{\isacharbackquote}\ T{\isacharparenright}%
   185 \end{isabelle}
   186 is solved by unrolling \isa{lfp} once%
   187 \end{isamarkuptxt}%
   188 \ \isamarkuptrue%
   189 \isacommand{apply}{\isacharparenleft}subst\ lfp{\isacharunderscore}unfold{\isacharbrackleft}OF\ mono{\isacharunderscore}ef{\isacharbrackright}{\isacharparenright}\isamarkupfalse%
   190 %
   191 \begin{isamarkuptxt}%
   192 \begin{isabelle}%
   193 \ {\isadigit{1}}{\isachardot}\ {\isasymAnd}x\ t{\isachardot}\ t\ {\isasymin}\ A\ {\isasymLongrightarrow}\ t\ {\isasymin}\ A\ {\isasymunion}\ M{\isasyminverse}\ {\isacharbackquote}{\isacharbackquote}\ lfp\ {\isacharparenleft}{\isasymlambda}T{\isachardot}\ A\ {\isasymunion}\ M{\isasyminverse}\ {\isacharbackquote}{\isacharbackquote}\ T{\isacharparenright}%
   194 \end{isabelle}
   195 and disposing of the resulting trivial subgoal automatically:%
   196 \end{isamarkuptxt}%
   197 \ \isamarkuptrue%
   198 \isacommand{apply}{\isacharparenleft}blast{\isacharparenright}\isamarkupfalse%
   199 %
   200 \begin{isamarkuptxt}%
   201 \noindent
   202 The proof of the induction step is identical to the one for the base case:%
   203 \end{isamarkuptxt}%
   204 \isamarkuptrue%
   205 \isacommand{apply}{\isacharparenleft}subst\ lfp{\isacharunderscore}unfold{\isacharbrackleft}OF\ mono{\isacharunderscore}ef{\isacharbrackright}{\isacharparenright}\isanewline
   206 \isamarkupfalse%
   207 \isacommand{apply}{\isacharparenleft}blast{\isacharparenright}\isanewline
   208 \isamarkupfalse%
   209 \isacommand{done}\isamarkupfalse%
   210 %
   211 \begin{isamarkuptext}%
   212 The main theorem is proved in the familiar manner: induction followed by
   213 \isa{auto} augmented with the lemma as a simplification rule.%
   214 \end{isamarkuptext}%
   215 \isamarkuptrue%
   216 \isacommand{theorem}\ {\isachardoublequote}mc\ f\ {\isacharequal}\ {\isacharbraceleft}s{\isachardot}\ s\ {\isasymTurnstile}\ f{\isacharbraceright}{\isachardoublequote}\isanewline
   217 \isamarkupfalse%
   218 \isacommand{apply}{\isacharparenleft}induct{\isacharunderscore}tac\ f{\isacharparenright}\isanewline
   219 \isamarkupfalse%
   220 \isacommand{apply}{\isacharparenleft}auto\ simp\ add{\isacharcolon}\ EF{\isacharunderscore}lemma{\isacharparenright}\isanewline
   221 \isamarkupfalse%
   222 \isacommand{done}\isamarkupfalse%
   223 %
   224 \begin{isamarkuptext}%
   225 \begin{exercise}
   226 \isa{AX} has a dual operator \isa{EN} 
   227 (``there exists a next state such that'')%
   228 \footnote{We cannot use the customary \isa{EX}: it is reserved
   229 as the \textsc{ascii}-equivalent of \isa{{\isasymexists}}.}
   230 with the intended semantics
   231 \begin{isabelle}%
   232 \ \ \ \ \ s\ {\isasymTurnstile}\ EN\ f\ {\isacharequal}\ {\isacharparenleft}{\isasymexists}t{\isachardot}\ {\isacharparenleft}s{\isacharcomma}\ t{\isacharparenright}\ {\isasymin}\ M\ {\isasymand}\ t\ {\isasymTurnstile}\ f{\isacharparenright}%
   233 \end{isabelle}
   234 Fortunately, \isa{EN\ f} can already be expressed as a PDL formula. How?
   235 
   236 Show that the semantics for \isa{EF} satisfies the following recursion equation:
   237 \begin{isabelle}%
   238 \ \ \ \ \ s\ {\isasymTurnstile}\ EF\ f\ {\isacharequal}\ {\isacharparenleft}s\ {\isasymTurnstile}\ f\ {\isasymor}\ s\ {\isasymTurnstile}\ EN\ {\isacharparenleft}EF\ f{\isacharparenright}{\isacharparenright}%
   239 \end{isabelle}
   240 \end{exercise}
   241 \index{PDL|)}%
   242 \end{isamarkuptext}%
   243 \isamarkuptrue%
   244 \isamarkupfalse%
   245 \isamarkupfalse%
   246 \isamarkupfalse%
   247 \isamarkupfalse%
   248 \isamarkupfalse%
   249 \isamarkupfalse%
   250 \isamarkupfalse%
   251 \isamarkupfalse%
   252 \isamarkupfalse%
   253 \isamarkupfalse%
   254 \isamarkupfalse%
   255 \isamarkupfalse%
   256 \isamarkupfalse%
   257 \end{isabellebody}%
   258 %%% Local Variables:
   259 %%% mode: latex
   260 %%% TeX-master: "root"
   261 %%% End: