Theory Eg1RefinementTrivial
theory Eg1RefinementTrivial
imports Eg1
"../CompositionalRefinement"
Dependent_SIFUM_Type_Systems.TypeSystem
begin
sublocale sifum_example ⊆
sifum_refinement_same_mem dma 𝒞_vars 𝒞 eval⇩w eval⇩w
by(unfold_locales)
context sifum_example begin
text ‹This predicate can be used to express arbitrary relational invariants for
compiler-specific features, but for this trivial case the vacuous one is fine.
›
definition P_true :: "('a × 'a) set"
where
"P_true ≡ UNIV"
lemma Id_secure_refinement:
"secure_refinement R Id P_true"
unfolding secure_refinement_def
proof(safe)
show "closed_others Id"
unfolding closed_others_def Id_def by blast
next
show "preserves_modes_mem Id"
unfolding preserves_modes_mem_def Id_def by blast
next
fix c⇩1⇩A mds mem⇩1 c⇩1⇩C c⇩1⇩C' mds' mem⇩1'
assume step: "(⟨c⇩1⇩C, mds, mem⇩1⟩⇩C, ⟨c⇩1⇩C', mds', mem⇩1'⟩⇩C) ∈ eval⇩w"
show
"∃n c⇩1⇩A'.
neval ⟨c⇩1⇩C, mds, mem⇩1⟩⇩C n ⟨c⇩1⇩A', mds', mem⇩1'⟩⇩C ∧
(⟨c⇩1⇩A', mds', mem⇩1'⟩⇩C, ⟨c⇩1⇩C', mds', mem⇩1'⟩⇩C) ∈ Id ∧
(∀c⇩2⇩A mem⇩2 c⇩2⇩C c⇩2⇩A' mem⇩2'.
(⟨c⇩1⇩C, mds, mem⇩1⟩⇩C, ⟨c⇩2⇩A, mds, mem⇩2⟩⇩C) ∈ R ∧
(⟨c⇩2⇩A, mds, mem⇩2⟩⇩C, ⟨c⇩2⇩C, mds, mem⇩2⟩⇩C) ∈ Id ∧
(⟨c⇩1⇩C, mds, mem⇩1⟩⇩C, ⟨c⇩2⇩C, mds, mem⇩2⟩⇩C) ∈ P_true ∧
neval ⟨c⇩2⇩A, mds, mem⇩2⟩⇩C n ⟨c⇩2⇩A', mds', mem⇩2'⟩⇩C ⟶
(∃c⇩2⇩C'.
(⟨c⇩2⇩C, mds, mem⇩2⟩⇩C, ⟨c⇩2⇩C', mds', mem⇩2'⟩⇩C)
∈ eval⇩w ∧
(⟨c⇩2⇩A', mds', mem⇩2'⟩⇩C, ⟨c⇩2⇩C', mds', mem⇩2'⟩⇩C) ∈ Id ∧
(⟨c⇩1⇩C', mds', mem⇩1'⟩⇩C, ⟨c⇩2⇩C', mds', mem⇩2'⟩⇩C) ∈ P_true))"
proof -
let ?n = "Suc 0"
let ?c⇩1⇩A' = c⇩1⇩C'
from step have "neval ⟨c⇩1⇩C, mds, mem⇩1⟩⇩C ?n ⟨?c⇩1⇩A', mds', mem⇩1'⟩⇩C"
by simp
moreover have "(⟨?c⇩1⇩A', mds', mem⇩1'⟩⇩C, ⟨c⇩1⇩C', mds', mem⇩1'⟩⇩C) ∈ Id"
by simp
moreover have "(∀c⇩2⇩A mem⇩2 c⇩2⇩C c⇩2⇩A' mem⇩2'.
(⟨c⇩1⇩C, mds, mem⇩1⟩⇩C, ⟨c⇩2⇩A, mds, mem⇩2⟩⇩C) ∈ R ∧
(⟨c⇩2⇩A, mds, mem⇩2⟩⇩C, ⟨c⇩2⇩C, mds, mem⇩2⟩⇩C) ∈ Id ∧
(⟨c⇩1⇩C, mds, mem⇩1⟩⇩C, ⟨c⇩2⇩C, mds, mem⇩2⟩⇩C) ∈ P_true ∧
neval ⟨c⇩2⇩A, mds, mem⇩2⟩⇩C ?n ⟨c⇩2⇩A', mds', mem⇩2'⟩⇩C ⟶
(∃c⇩2⇩C'.
(⟨c⇩2⇩C, mds, mem⇩2⟩⇩C, ⟨c⇩2⇩C', mds', mem⇩2'⟩⇩C)
∈ eval⇩w ∧
(⟨c⇩2⇩A', mds', mem⇩2'⟩⇩C, ⟨c⇩2⇩C', mds', mem⇩2'⟩⇩C) ∈ Id ∧
(⟨c⇩1⇩C', mds', mem⇩1'⟩⇩C, ⟨c⇩2⇩C', mds', mem⇩2'⟩⇩C) ∈ P_true))"
using step
unfolding P_true_def
by clarsimp
ultimately show ?thesis by blast
qed
next
show "closed_glob_consistent P_true"
by(auto simp: closed_glob_consistent_def P_true_def)
qed
text ‹
This doesn't really mean much, but shows the lemmas in action.
(I suspect that @{term "R⇩C_of R Id"} is equivalent to @{term R}. But who cares?)
›
lemma "strong_low_bisim_mm (gen_refine.R⇩C_of (ℛ Γ 𝒮 P) Id P_true)"
apply(rule R⇩C_of_strong_low_bisim_mm)
apply(rule ℛ_bisim)
apply(rule Id_secure_refinement)
unfolding P_true_def sym_def apply blast
done
end
end