Theory CTL
section ‹CTL formulae›
theory CTL
imports Main
begin
text ‹
We formalize basic concepts of Computational Tree Logic (CTL) \<^cite>‹"McMillan-PhDThesis"› within the simply-typed
set theory of HOL.
By using the common technique of ``shallow embedding'', a CTL formula is
identified with the corresponding set of states where it holds.
Consequently, CTL operations such as negation, conjunction, disjunction
simply become complement, intersection, union of sets. We only require a
separate operation for implication, as point-wise inclusion is usually not
encountered in plain set-theory.
›
lemmas [intro!] = Int_greatest Un_upper2 Un_upper1 Int_lower1 Int_lower2
type_synonym 'a ctl = "'a set"
definition imp :: "'a ctl ⇒ 'a ctl ⇒ 'a ctl" (infixr "→" 75)
where "p → q = - p ∪ q"
lemma [intro!]: "p ∩ p → q ⊆ q" unfolding imp_def by auto
lemma [intro!]: "p ⊆ (q → p)" unfolding imp_def by rule
text ‹
┈
The CTL path operators are more interesting; they are based on an arbitrary,
but fixed model ‹ℳ›, which is simply a transition relation over states
\<^typ>‹'a›.
›
axiomatization ℳ :: "('a × 'a) set"
text ‹
The operators ‹❙E❙X›, ‹❙E❙F›, ‹❙E❙G› are taken as primitives, while ‹❙A❙X›,
‹❙A❙F›, ‹❙A❙G› are defined as derived ones. The formula ‹❙E❙X p› holds in a
state ‹s›, iff there is a successor state ‹s'› (with respect to the model
‹ℳ›), such that ‹p› holds in ‹s'›. The formula ‹❙E❙F p› holds in a state
‹s›, iff there is a path in ‹ℳ›, starting from ‹s›, such that there exists a
state ‹s'› on the path, such that ‹p› holds in ‹s'›. The formula ‹❙E❙G p›
holds in a state ‹s›, iff there is a path, starting from ‹s›, such that for
all states ‹s'› on the path, ‹p› holds in ‹s'›. It is easy to see that ‹❙E❙F
p› and ‹❙E❙G p› may be expressed using least and greatest fixed points
\<^cite>‹"McMillan-PhDThesis"›.
›
definition EX ("❙E❙X _" [80] 90)
where [simp]: "❙E❙X p = {s. ∃s'. (s, s') ∈ ℳ ∧ s' ∈ p}"
definition EF ("❙E❙F _" [80] 90)
where [simp]: "❙E❙F p = lfp (λs. p ∪ ❙E❙X s)"
definition EG ("❙E❙G _" [80] 90)
where [simp]: "❙E❙G p = gfp (λs. p ∩ ❙E❙X s)"
text ‹
‹❙A❙X›, ‹❙A❙F› and ‹❙A❙G› are now defined dually in terms of ‹❙E❙X›,
‹❙E❙F› and ‹❙E❙G›.
›
definition AX ("❙A❙X _" [80] 90)
where [simp]: "❙A❙X p = - ❙E❙X - p"
definition AF ("❙A❙F _" [80] 90)
where [simp]: "❙A❙F p = - ❙E❙G - p"
definition AG ("❙A❙G _" [80] 90)
where [simp]: "❙A❙G p = - ❙E❙F - p"
subsection ‹Basic fixed point properties›
text ‹
First of all, we use the de-Morgan property of fixed points.
›
lemma lfp_gfp: "lfp f = - gfp (λs::'a set. - (f (- s)))"
proof
show "lfp f ⊆ - gfp (λs. - f (- s))"
proof
show "x ∈ - gfp (λs. - f (- s))" if l: "x ∈ lfp f" for x
proof
assume "x ∈ gfp (λs. - f (- s))"
then obtain u where "x ∈ u" and "u ⊆ - f (- u)"
by (auto simp add: gfp_def)
then have "f (- u) ⊆ - u" by auto
then have "lfp f ⊆ - u" by (rule lfp_lowerbound)
from l and this have "x ∉ u" by auto
with ‹x ∈ u› show False by contradiction
qed
qed
show "- gfp (λs. - f (- s)) ⊆ lfp f"
proof (rule lfp_greatest)
fix u
assume "f u ⊆ u"
then have "- u ⊆ - f u" by auto
then have "- u ⊆ - f (- (- u))" by simp
then have "- u ⊆ gfp (λs. - f (- s))" by (rule gfp_upperbound)
then show "- gfp (λs. - f (- s)) ⊆ u" by auto
qed
qed
lemma lfp_gfp': "- lfp f = gfp (λs::'a set. - (f (- s)))"
by (simp add: lfp_gfp)
lemma gfp_lfp': "- gfp f = lfp (λs::'a set. - (f (- s)))"
by (simp add: lfp_gfp)
text ‹
In order to give dual fixed point representations of \<^term>‹❙A❙F p› and
\<^term>‹❙A❙G p›:
›
lemma AF_lfp: "❙A❙F p = lfp (λs. p ∪ ❙A❙X s)"
by (simp add: lfp_gfp)
lemma AG_gfp: "❙A❙G p = gfp (λs. p ∩ ❙A❙X s)"
by (simp add: lfp_gfp)
lemma EF_fp: "❙E❙F p = p ∪ ❙E❙X ❙E❙F p"
proof -
have "mono (λs. p ∪ ❙E❙X s)" by rule auto
then show ?thesis by (simp only: EF_def) (rule lfp_unfold)
qed
lemma AF_fp: "❙A❙F p = p ∪ ❙A❙X ❙A❙F p"
proof -
have "mono (λs. p ∪ ❙A❙X s)" by rule auto
then show ?thesis by (simp only: AF_lfp) (rule lfp_unfold)
qed
lemma EG_fp: "❙E❙G p = p ∩ ❙E❙X ❙E❙G p"
proof -
have "mono (λs. p ∩ ❙E❙X s)" by rule auto
then show ?thesis by (simp only: EG_def) (rule gfp_unfold)
qed
text ‹
From the greatest fixed point definition of \<^term>‹❙A❙G p›, we derive as
a consequence of the Knaster-Tarski theorem on the one hand that \<^term>‹❙A❙G p› is a fixed point of the monotonic function
\<^term>‹λs. p ∩ ❙A❙X s›.
›
lemma AG_fp: "❙A❙G p = p ∩ ❙A❙X ❙A❙G p"
proof -
have "mono (λs. p ∩ ❙A❙X s)" by rule auto
then show ?thesis by (simp only: AG_gfp) (rule gfp_unfold)
qed
text ‹
This fact may be split up into two inequalities (merely using transitivity
of ‹⊆›, which is an instance of the overloaded ‹≤› in Isabelle/HOL).
›
lemma AG_fp_1: "❙A❙G p ⊆ p"
proof -
note AG_fp also have "p ∩ ❙A❙X ❙A❙G p ⊆ p" by auto
finally show ?thesis .
qed
lemma AG_fp_2: "❙A❙G p ⊆ ❙A❙X ❙A❙G p"
proof -
note AG_fp also have "p ∩ ❙A❙X ❙A❙G p ⊆ ❙A❙X ❙A❙G p" by auto
finally show ?thesis .
qed
text ‹
On the other hand, we have from the Knaster-Tarski fixed point theorem that
any other post-fixed point of \<^term>‹λs. p ∩ ❙A❙X s› is smaller than
\<^term>‹❙A❙G p›. A post-fixed point is a set of states ‹q› such that \<^term>‹q ⊆ p ∩ ❙A❙X q›. This leads to the following co-induction principle for
\<^term>‹❙A❙G p›.
›
lemma AG_I: "q ⊆ p ∩ ❙A❙X q ⟹ q ⊆ ❙A❙G p"
by (simp only: AG_gfp) (rule gfp_upperbound)
subsection ‹The tree induction principle \label{sec:calc-ctl-tree-induct}›
text ‹
With the most basic facts available, we are now able to establish a few more
interesting results, leading to the ∗‹tree induction› principle for ‹❙A❙G›
(see below). We will use some elementary monotonicity and distributivity
rules.
›
lemma AX_int: "❙A❙X (p ∩ q) = ❙A❙X p ∩ ❙A❙X q" by auto
lemma AX_mono: "p ⊆ q ⟹ ❙A❙X p ⊆ ❙A❙X q" by auto
lemma AG_mono: "p ⊆ q ⟹ ❙A❙G p ⊆ ❙A❙G q"
by (simp only: AG_gfp, rule gfp_mono) auto
text ‹
The formula \<^term>‹AG p› implies \<^term>‹AX p› (we use substitution of
‹⊆› with monotonicity).
›
lemma AG_AX: "❙A❙G p ⊆ ❙A❙X p"
proof -
have "❙A❙G p ⊆ ❙A❙X ❙A❙G p" by (rule AG_fp_2)
also have "❙A❙G p ⊆ p" by (rule AG_fp_1)
moreover note AX_mono
finally show ?thesis .
qed
text ‹
Furthermore we show idempotency of the ‹❙A❙G› operator. The proof is a good
example of how accumulated facts may get used to feed a single rule step.
›
lemma AG_AG: "❙A❙G ❙A❙G p = ❙A❙G p"
proof
show "❙A❙G ❙A❙G p ⊆ ❙A❙G p" by (rule AG_fp_1)
next
show "❙A❙G p ⊆ ❙A❙G ❙A❙G p"
proof (rule AG_I)
have "❙A❙G p ⊆ ❙A❙G p" ..
moreover have "❙A❙G p ⊆ ❙A❙X ❙A❙G p" by (rule AG_fp_2)
ultimately show "❙A❙G p ⊆ ❙A❙G p ∩ ❙A❙X ❙A❙G p" ..
qed
qed
text ‹
┈
We now give an alternative characterization of the ‹❙A❙G› operator, which
describes the ‹❙A❙G› operator in an ``operational'' way by tree induction:
In a state holds \<^term>‹AG p› iff in that state holds ‹p›, and in all
reachable states ‹s› follows from the fact that ‹p› holds in ‹s›, that ‹p›
also holds in all successor states of ‹s›. We use the co-induction principle
@{thm [source] AG_I} to establish this in a purely algebraic manner.
›
theorem AG_induct: "p ∩ ❙A❙G (p → ❙A❙X p) = ❙A❙G p"
proof
show "p ∩ ❙A❙G (p → ❙A❙X p) ⊆ ❙A❙G p" (is "?lhs ⊆ _")
proof (rule AG_I)
show "?lhs ⊆ p ∩ ❙A❙X ?lhs"
proof
show "?lhs ⊆ p" ..
show "?lhs ⊆ ❙A❙X ?lhs"
proof -
{
have "❙A❙G (p → ❙A❙X p) ⊆ p → ❙A❙X p" by (rule AG_fp_1)
also have "p ∩ p → ❙A❙X p ⊆ ❙A❙X p" ..
finally have "?lhs ⊆ ❙A❙X p" by auto
}
moreover
{
have "p ∩ ❙A❙G (p → ❙A❙X p) ⊆ ❙A❙G (p → ❙A❙X p)" ..
also have "… ⊆ ❙A❙X …" by (rule AG_fp_2)
finally have "?lhs ⊆ ❙A❙X ❙A❙G (p → ❙A❙X p)" .
}
ultimately have "?lhs ⊆ ❙A❙X p ∩ ❙A❙X ❙A❙G (p → ❙A❙X p)" ..
also have "… = ❙A❙X ?lhs" by (simp only: AX_int)
finally show ?thesis .
qed
qed
qed
next
show "❙A❙G p ⊆ p ∩ ❙A❙G (p → ❙A❙X p)"
proof
show "❙A❙G p ⊆ p" by (rule AG_fp_1)
show "❙A❙G p ⊆ ❙A❙G (p → ❙A❙X p)"
proof -
have "❙A❙G p = ❙A❙G ❙A❙G p" by (simp only: AG_AG)
also have "❙A❙G p ⊆ ❙A❙X p" by (rule AG_AX) moreover note AG_mono
also have "❙A❙X p ⊆ (p → ❙A❙X p)" .. moreover note AG_mono
finally show ?thesis .
qed
qed
qed
subsection ‹An application of tree induction \label{sec:calc-ctl-commute}›
text ‹
Further interesting properties of CTL expressions may be demonstrated with
the help of tree induction; here we show that ‹❙A❙X› and ‹❙A❙G› commute.
›
theorem AG_AX_commute: "❙A❙G ❙A❙X p = ❙A❙X ❙A❙G p"
proof -
have "❙A❙G ❙A❙X p = ❙A❙X p ∩ ❙A❙X ❙A❙G ❙A❙X p" by (rule AG_fp)
also have "… = ❙A❙X (p ∩ ❙A❙G ❙A❙X p)" by (simp only: AX_int)
also have "p ∩ ❙A❙G ❙A❙X p = ❙A❙G p" (is "?lhs = _")
proof
have "❙A❙X p ⊆ p → ❙A❙X p" ..
also have "p ∩ ❙A❙G (p → ❙A❙X p) = ❙A❙G p" by (rule AG_induct)
also note Int_mono AG_mono
ultimately show "?lhs ⊆ ❙A❙G p" by fast
next
have "❙A❙G p ⊆ p" by (rule AG_fp_1)
moreover
{
have "❙A❙G p = ❙A❙G ❙A❙G p" by (simp only: AG_AG)
also have "❙A❙G p ⊆ ❙A❙X p" by (rule AG_AX)
also note AG_mono
ultimately have "❙A❙G p ⊆ ❙A❙G ❙A❙X p" .
}
ultimately show "❙A❙G p ⊆ ?lhs" ..
qed
finally show ?thesis .
qed
end