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