Theory CRA
section ‹Concurrent Refinement Algebra \label{S:CRA}›
text ‹
This theory brings together the three main operators:
sequential composition,
parallel composition and
conjunction,
as well as the iteration operators.
›
theory CRA
imports
Sequential
Conjunction
Parallel
begin
text ‹
Locale sequential-parallel brings together the sequential and parallel
operators and relates their identities.
›
locale sequential_parallel = seq_distrib + par_distrib +
assumes nil_par_nil: "nil ∥ nil ⊑ nil"
and skip_nil: "skip ⊑ nil"
and skip_skip: "skip ⊑ skip;skip"
begin
lemma nil_absorb: "nil ∥ nil = nil" using nil_par_nil skip_nil par_skip
by (metis inf.absorb_iff2 inf.orderE inf_par_distrib2)
lemma skip_absorb [simp]: "skip;skip = skip"
by (metis antisym seq_mono_right seq_nil_right skip_skip skip_nil)
end
text ‹
Locale conjunction-parallel brings together the weak conjunction and
parallel operators and relates their identities.
It also introduces the interchange axiom for conjunction and parallel.
›
locale conjunction_parallel = conj_distrib + par_distrib +
assumes chaos_par_top: "⊤ ⊑ chaos ∥ ⊤"
assumes chaos_par_chaos: "chaos ⊑ chaos ∥ chaos"
assumes parallel_interchange: "(c⇩0 ∥ c⇩1) \<iinter> (d⇩0 ∥ d⇩1) ⊑ (c⇩0 \<iinter> d⇩0) ∥ (c⇩1 \<iinter> d⇩1)"
begin
lemma chaos_skip: "chaos ⊑ skip"
proof -
have "chaos = (chaos ∥ skip) \<iinter> (skip ∥ chaos)" by simp
then have "… ⊑ (chaos \<iinter> skip) ∥ (skip \<iinter> chaos)" using parallel_interchange by blast
thus ?thesis by auto
qed
lemma chaos_par_chaos_eq: "chaos = chaos ∥ chaos"
by (metis antisym chaos_par_chaos chaos_skip order_refl par_mono par_skip)
lemma nonabort_par_top: "chaos ⊑ c ⟹ c ∥ ⊤ = ⊤"
by (metis chaos_par_top par_mono top.extremum_uniqueI)
lemma skip_conj_top: "skip \<iinter> ⊤ = ⊤"
by (simp add: chaos_skip conjoin_top)
lemma conj_distrib2: "c ⊑ c ∥ c ⟹ c \<iinter> (d⇩0 ∥ d⇩1) ⊑ (c \<iinter> d⇩0) ∥ (c \<iinter> d⇩1)"
proof -
assume "c ⊑ c ∥ c"
then have "c \<iinter> (d⇩0 ∥ d⇩1) ⊑ (c ∥ c) \<iinter> (d⇩0 ∥ d⇩1)" by (metis conj_mono order.refl)
thus ?thesis by (metis parallel_interchange refine_trans)
qed
end
text ‹
Locale conjunction-sequential brings together the weak conjunction and
sequential operators.
It also introduces the interchange axiom for conjunction and sequential.
›
locale conjunction_sequential = conj_distrib + seq_distrib +
assumes chaos_seq_chaos: "chaos ⊑ chaos;chaos"
assumes sequential_interchange: "(c⇩0;c⇩1) \<iinter> (d⇩0;d⇩1) ⊑ (c⇩0 \<iinter> d⇩0);(c⇩1 \<iinter> d⇩1)"
begin
lemma chaos_nil: "chaos ⊑ nil"
by (metis conj_chaos local.conj_commute seq_nil_left seq_nil_right
sequential_interchange)
lemma chaos_seq_absorb: "chaos = chaos;chaos"
proof (rule antisym)
show "chaos ⊑ chaos;chaos" by (simp add: chaos_seq_chaos)
next
show "chaos;chaos ⊑ chaos" using chaos_nil
using seq_mono_left seq_nil_left by fastforce
qed
lemma seq_bot_conj: "c;⊥ \<iinter> d ⊑ (c \<iinter> d);⊥"
by (metis (no_types) conj_bot_left seq_nil_right sequential_interchange)
lemma conj_seq_bot_right [simp]: "c;⊥ \<iinter> c = c;⊥"
proof (rule antisym)
show lr: "c;⊥ \<iinter> c ⊑ c;⊥" by (metis seq_bot_conj conj_idem)
next
show rl: "c;⊥ ⊑ c;⊥ \<iinter> c"
by (metis conj_idem conj_mono_right seq_bot_right)
qed
lemma conj_distrib3: "c ⊑ c;c ⟹ c \<iinter> (d⇩0 ; d⇩1) ⊑ (c \<iinter> d⇩0);(c \<iinter> d⇩1)"
proof -
assume "c ⊑ c;c"
then have "c \<iinter> (d⇩0;d⇩1) ⊑ (c;c) \<iinter> (d⇩0;d⇩1)" by (metis conj_mono order.refl)
thus ?thesis by (metis sequential_interchange refine_trans)
qed
end
text ‹
Locale cra brings together sequential, parallel and weak conjunction.
›
locale cra = sequential_parallel + conjunction_parallel + conjunction_sequential
end