Theory After_Operator_Non_Too_Destructive
section ‹Non too Destructiveness of After›
theory After_Operator_Non_Too_Destructive
imports Process_Restriction_Space
"HOL-CSP_OpSem.After_Trace_Operator"
begin
subsection ‹Equality›
lemma initials_restriction_process⇩p⇩t⇩i⇩c⇩k: ‹(P ↓ n)⇧0 = (if n = 0 then UNIV else P⇧0)›
by (cases n, solves simp)
(auto simp add: initials_def T_restriction_process⇩p⇩t⇩i⇩c⇩k,
metis append.right_neutral append_eq_conv_conj drop_Nil drop_Suc_Cons)
lemma (in After) restriction_process⇩p⇩t⇩i⇩c⇩k_After:
‹P after e ↓ n = (if ev e ∈ P⇧0 then (P ↓ Suc n) after e else Ψ P e ↓ n)›
proof (split if_split, intro conjI impI)
show ‹ev e ∉ P⇧0 ⟹ P after e ↓ n = Ψ P e ↓ n› by (simp add: not_initial_After)
next
assume ‹ev e ∈ P⇧0›
show ‹P after e ↓ n = (P ↓ Suc n) after e› (is ‹?lhs = ?rhs›)
proof (subst Process_eq_spec, safe)
show ‹t ∈ 𝒟 ?lhs ⟹ t ∈ 𝒟 ?rhs› for t
by (elim D_restriction_process⇩p⇩t⇩i⇩c⇩kE)
(simp_all add: ‹ev e ∈ P⇧0› After_projs
initials_restriction_process⇩p⇩t⇩i⇩c⇩k D_restriction_process⇩p⇩t⇩i⇩c⇩k,
meson Cons_eq_appendI event⇩p⇩t⇩i⇩c⇩k.disc(1) length_Cons tickFree_Cons_iff)
next
show ‹t ∈ 𝒟 ?rhs ⟹ t ∈ 𝒟 ?lhs› for t
by (auto simp add: D_After initials_restriction_process⇩p⇩t⇩i⇩c⇩k ‹ev e ∈ P⇧0›
D_restriction_process⇩p⇩t⇩i⇩c⇩k T_After Cons_eq_append_conv)
next
show ‹(t, X) ∈ ℱ ?lhs ⟹ (t, X) ∈ ℱ ?rhs› for t X
by (elim F_restriction_process⇩p⇩t⇩i⇩c⇩kE)
(simp_all add: ‹ev e ∈ P⇧0› After_projs
initials_restriction_process⇩p⇩t⇩i⇩c⇩k F_restriction_process⇩p⇩t⇩i⇩c⇩k,
meson Cons_eq_appendI event⇩p⇩t⇩i⇩c⇩k.disc(1) length_Cons tickFree_Cons_iff)
next
show ‹(t, X) ∈ ℱ ?rhs ⟹ (t, X) ∈ ℱ ?lhs› for t X
by (auto simp add: F_After initials_restriction_process⇩p⇩t⇩i⇩c⇩k ‹ev e ∈ P⇧0›
F_restriction_process⇩p⇩t⇩i⇩c⇩k T_After Cons_eq_append_conv)
qed
qed
lemma (in AfterExt) restriction_process⇩p⇩t⇩i⇩c⇩k_After⇩t⇩i⇩c⇩k:
‹P after⇩✓ e ↓ n =
(case e of ✓(r) ⇒ Ω P r ↓ n | ev x ⇒ if e ∈ P⇧0 then (P ↓ Suc n) after⇩✓ e else Ψ P x ↓ n)›
by (simp add: After⇩t⇩i⇩c⇩k_def restriction_process⇩p⇩t⇩i⇩c⇩k_After split: event⇩p⇩t⇩i⇩c⇩k.split )
lemma (in AfterExt) restriction_process⇩p⇩t⇩i⇩c⇩k_After⇩t⇩r⇩a⇩c⇩e:
‹t ∈ 𝒯 P ⟹ tF t ⟹ P after⇩𝒯 t ↓ n = (P ↓ (n + length t)) after⇩𝒯 t›
proof (induct t arbitrary: n rule: rev_induct)
show ‹P after⇩𝒯 [] ↓ n = (P ↓ (n + length [])) after⇩𝒯 []› for n by simp
next
fix e t n
assume hyp : ‹t ∈ 𝒯 P ⟹ tF t ⟹ P after⇩𝒯 t ↓ n = (P ↓ (n + length t)) after⇩𝒯 t› for n
assume prems : ‹t @ [e] ∈ 𝒯 P› ‹tickFree (t @ [e])›
from prems(2) obtain a where ‹e = ev a› by (cases e) simp_all
with initials_After⇩t⇩r⇩a⇩c⇩e[OF prems(1)] have ‹ev a ∈ (P after⇩𝒯 t)⇧0› by simp
from prems is_processT3_TR_append have ‹t ∈ 𝒯 P› ‹tF t› by auto
from hyp[OF this] have ‹P after⇩𝒯 t ↓ Suc n = (P ↓ (Suc n + length t)) after⇩𝒯 t› .
thus ‹P after⇩𝒯 (t @ [e]) ↓ n = (P ↓ (n + length (t @ [e]))) after⇩𝒯 (t @ [e])›
by (simp add: After⇩t⇩r⇩a⇩c⇩e_snoc restriction_process⇩p⇩t⇩i⇩c⇩k_After⇩t⇩i⇩c⇩k
‹e = ev a› ‹ev a ∈ (P after⇩𝒯 t)⇧0›)
qed
subsection ‹Non too Destructiveness›
lemma (in After) non_too_destructive_on_After :
‹non_too_destructive_on (λP. P after e) {P. ev e ∈ P⇧0}›
by (auto intro!: non_too_destructive_onI simp add: restriction_process⇩p⇩t⇩i⇩c⇩k_After)
lemma (in AfterExt) non_too_destructive_on_After⇩t⇩i⇩c⇩k :
‹non_too_destructive_on (λP. P after⇩✓ e) {P. e ∈ P⇧0}›
if ‹⋀r. e = ✓(r) ⟹ non_too_destructive_on Ω {P. ✓(r) ∈ P⇧0}›
proof (intro non_too_destructive_onI, clarify)
fix P Q n assume * : ‹P ↓ Suc n = Q ↓ Suc n› ‹e ∈ P⇧0› ‹e ∈ Q⇧0›
show ‹P after⇩✓ e ↓ n = Q after⇩✓ e ↓ n›
proof (cases e)
from "*" show ‹e = ev a ⟹ P after⇩✓ e ↓ n = Q after⇩✓ e ↓ n› for a
by (simp add: restriction_process⇩p⇩t⇩i⇩c⇩k_After⇩t⇩i⇩c⇩k)
next
fix r assume ‹e = ✓(r)›
with "*"(2, 3) have ‹P ∈ {P. ✓(r) ∈ P⇧0}› ‹Q ∈ {P. ✓(r) ∈ P⇧0}› by auto
from non_too_destructive_onD[OF that[simplified ‹e = ✓(r)›, OF refl] this "*"(1)]
have ‹Ω P ↓ n = Ω Q ↓ n› .
with ‹e = ✓(r)› show ‹P after⇩✓ e ↓ n = Q after⇩✓ e ↓ n›
by (simp add: restriction_process⇩p⇩t⇩i⇩c⇩k_After⇩t⇩i⇩c⇩k) (metis restriction_fun_def)
qed
qed
lemma (in After) non_too_destructive_After :
‹non_too_destructive (λP. P after e)› if * : ‹non_too_destructive_on Ψ {P. ev e ∉ P⇧0}›
proof (rule non_too_destructiveI)
fix P Q :: ‹('a, 'r) process⇩p⇩t⇩i⇩c⇩k› and n
assume ‹P ↓ Suc n = Q ↓ Suc n›
hence ‹ev e ∈ P⇧0 ∧ ev e ∈ Q⇧0 ∨ ev e ∉ P⇧0 ∧ ev e ∉ Q⇧0›
by (metis initials_restriction_process⇩p⇩t⇩i⇩c⇩k nat.distinct(1))
thus ‹P after e ↓ n = Q after e ↓ n›
proof (elim disjE conjE)
show ‹ev e ∈ P⇧0 ⟹ ev e ∈ Q⇧0 ⟹ P after e ↓ n = Q after e ↓ n›
by (simp add: restriction_process⇩p⇩t⇩i⇩c⇩k_After ‹P ↓ Suc n = Q ↓ Suc n›)
next
assume ‹ev e ∉ P⇧0› ‹ev e ∉ Q⇧0›
hence ‹P after e = Ψ P e› ‹Q after e = Ψ Q e›
by (simp_all add: not_initial_After)
from ‹P ↓ Suc n = Q ↓ Suc n› have ‹Ψ P ↓ n = Ψ Q ↓ n›
by (intro "*"[THEN non_too_destructive_onD, of P Q])
(simp_all add: ‹ev e ∉ P⇧0› ‹ev e ∉ Q⇧0›)
with ‹P after e = Ψ P e› ‹Q after e = Ψ Q e›
show ‹P after e ↓ n = Q after e ↓ n›
by (metis restriction_fun_def)
qed
qed
lemma (in AfterExt) non_too_destructive_After⇩t⇩i⇩c⇩k :
‹non_too_destructive (λP. P after⇩✓ e)›
if * : ‹⋀a. e = ev a ⟹ non_too_destructive_on Ψ {P. ev a ∉ P⇧0}›
‹⋀r. e = ✓(r) ⟹ non_too_destructive (λP. Ω P r)›
proof (rule non_too_destructiveI)
show ‹P after⇩✓ e ↓ n = Q after⇩✓ e ↓ n› if ‹P ↓ Suc n = Q ↓ Suc n› for P Q n
proof (cases e)
show ‹P after⇩✓ e ↓ n = Q after⇩✓ e ↓ n› if ‹e = ev a› for a
by (simp add: After⇩t⇩i⇩c⇩k_def ‹e = ev a›)
(fact non_too_destructive_After[OF "*"(1)[simplified ‹e = ev a›, OF refl],
THEN non_too_destructiveD, OF ‹P ↓ Suc n = Q ↓ Suc n›])
next
fix r assume ‹e = ✓(r)›
from "*"(2)[unfolded ‹e = ✓(r)›, OF refl,
THEN non_too_destructiveD, OF ‹P ↓ Suc n = Q ↓ Suc n›]
have ‹Ω P r ↓ n = Ω Q r ↓ n› .
thus ‹P after⇩✓ e ↓ n = Q after⇩✓ e ↓ n›
by (simp add: After⇩t⇩i⇩c⇩k_def ‹e = ✓(r)›)
qed
qed
lemma (in AfterExt) restriction_shift_After⇩t⇩r⇩a⇩c⇩e :
‹restriction_shift (λP. P after⇩𝒯 t) (- int (length t))›
if ‹non_too_destructive Ψ› ‹non_too_destructive Ω›
proof (induct t)
case Nil show ?case by (simp add: restriction_shiftI)
next
case (Cons e t)
have ‹non_too_destructive (λP. P after⇩✓ e)›
by (rule non_too_destructive_After⇩t⇩i⇩c⇩k)
(simp add: ‹non_too_destructive Ψ›,
metis non_too_destructive_fun_iff ‹non_too_destructive Ω›)
hence * : ‹restriction_shift (λP. P after⇩✓ e) (- 1)›
unfolding non_too_destructive_def
non_too_destructive_on_def restriction_shift_def .
from restriction_shift_comp_restriction_shift[OF Cons.hyps "*"]
show ?case by simp
qed
end