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