section"Control terms and well-definedness of sequential processes"
theory AWN_Cterms imports AWN begin
subsection"Microsteps "
text‹
We distinguish microsteps from `external' transitions (observable or not). Here, they are
a kind of `hypothetical computation', since, unlike ‹τ›-transitions, they do not make
choices but rather `compute' which choices are possible. ›
definition
wellformed :: "('s, 'm, 'p, 'l) seqp_env ==> bool" where "wellformed Γ = wf {(q, p). p ↝<Gamma> q}"
lemma wellformed_defP: "wellformed Γ = wfP (λq p. p ↝<Gamma> q)" unfolding wellformed_def wfp_def by simp
text‹
The induction rule for @{term "wellformed Γ"} is stronger than @{thm seqp.induct} because
the case for @{term "call(pn)"} can be shown with the assumption on @{term "Γ pn"}. ›
lemma wellformed_induct
[consumes 1, case_names ASSIGN CHOICE CALL GUARD UCAST BCAST GCAST SEND DELIVER RECEIVE,
induct set: wellformed]: assumes"wellformed Γ" and ASSIGN: "∧l f p. wellformed Γ ==> P ({l}[f] p)" and GUARD: "∧l f p. wellformed Γ ==> P ({l}⟨f⟩ p)" and UCAST: "∧l fip fmsg p q. wellformed Γ ==> P ({l}unicast(fip, fmsg). p ▹ q)" and BCAST: "∧l fmsg p. wellformed Γ ==> P ({l}broadcast(fmsg). p)" and GCAST: "∧l fips fmsg p. wellformed Γ ==> P ({l}groupcast(fips, fmsg). p)" and SEND: "∧l fmsg p. wellformed Γ ==> P ({l}send(fmsg). p)" and DELIVER: "∧l fdata p. wellformed Γ ==> P ({l}deliver(fdata). p)" and RECEIVE: "∧l fmsg p. wellformed Γ ==> P ({l}receive(fmsg). p)" and CHOICE: "∧p1 p2. [ wellformed Γ; P p1; P p2 ]==> P (p1 ⊕ p2)" and CALL: "∧pn. [ wellformed Γ; P (Γ pn) ]==> P (call(pn))" shows"P a" using assms(1) unfolding wellformed_defP proof (rule wfp_induct_rule, case_tac x, simp_all) fix p1 p2 assume"∧q. (p1 ⊕ p2) ↝<Gamma> q ==> P q" thenobtain"P p1"and"P p2"by (auto intro!: microstep.intros) thus"P (p1 ⊕ p2)"by (rule CHOICE [OF ‹wellformed Γ›]) next fix pn assume"∧q. (call(pn)) ↝<Gamma> q ==> P q" hence"P (Γ pn)"by (auto intro!: microstep.intros) thus"P (call(pn))"by (rule CALL [OF ‹wellformed Γ›]) qed (auto intro: assms)
subsection"Start terms (sterms) "
text‹
Formulate sets of local subterms from which an action is directly possible. Since the
process specification @{term "Γ"} is not considered, only choice terms @{term "p1⊕ p2"}
are traversed, and not @{term "call(p)"} terms. ›
lemma stermsl_not_empty: "stermsl p ≠ {}" by (induct p) auto
lemma stermsl_idem [simp]: "(∪q∈stermsl p. stermsl q) = stermsl p" by (induct p) simp_all
lemma stermsl_in_wfpf: assumes AA: "A ⊆ {(q, p). p ↝<Gamma> q} `` A" and *: "p ∈ A" shows"∃r∈stermsl p. r ∈ A" using * proof (induction p) fix p1 p2 assume IH1: "p1 ∈ A ==>∃r∈stermsl p1. r ∈ A" and IH2: "p2 ∈ A ==>∃r∈stermsl p2. r ∈ A" and *: "p1 ⊕ p2 ∈ A" from * and AA have"p1 ⊕ p2 ∈ {(q, p). p ↝<Gamma> q} `` A"by auto hence"p1 ∈ A ∨ p2 ∈ A"by auto hence"(∃r∈stermsl p1. r ∈ A) ∨ (∃r∈stermsl p2. r ∈ A)" proof assume"p1 ∈ A"hence"∃r∈stermsl p1. r ∈ A"by (rule IH1) thus ?thesis .. next assume"p2 ∈ A"hence"∃r∈stermsl p2. r ∈ A"by (rule IH2) thus ?thesis .. qed hence"∃r∈stermsl p1 ∪ stermsl p2. r ∈ A"by blast thus"∃r∈stermsl (p1 ⊕ p2). r ∈ A"by simp nextcase UCAST from UCAST.prems show ?caseby auto qed auto
lemma nocall_stermsl_max: assumes"r ∈ stermsl p" and"not_call r" shows"¬ (r ↝<Gamma> q)" using assms by (induction p) auto
theorem wf_no_direct_calls[intro]: fixes Γ :: "('s, 'm, 'p, 'l) seqp_env" assumes no_calls: "∧pn. ∀pn'. call(pn') ∉ stermsl(Γ(pn))" shows"wellformed Γ" unfolding wellformed_def wfp_def proof (rule wfI_pf) fix A assume ARA: "A ⊆ {(q, p). p ↝<Gamma> q} `` A" hence hasnext: "∧p. p ∈ A ==>∃q. p ↝<Gamma> q ∧ q ∈ A"by auto show"A = {}" proof (rule Set.equals0I) fix p assume"p ∈ A"thus"False" proof (induction p) fix l f p' assume *: "{l}⟨f⟩ p' ∈ A" from hasnext [OF *] have"∃q. ({l}⟨f⟩ p') ↝<Gamma> q"by simp thus"False"by simp next fix p1 p2 assume *: "p1 ⊕ p2 ∈ A" and IH1: "p1 ∈ A ==> False" and IH2: "p2 ∈ A ==> False" have"∃q. (p1 ⊕ p2) ↝<Gamma> q ∧ q ∈ A"by (rule hasnext [OF *]) hence"p1 ∈ A ∨ p2 ∈ A"by auto thus"False"by (auto dest: IH1 IH2) next fix pn assume"call(pn) ∈ A" hence"∃q. (call(pn)) ↝<Gamma> q ∧ q ∈ A"by (rule hasnext) hence"Γ(pn) ∈ A"by auto
with ARA [THEN stermsl_in_wfpf] obtain q where"q∈stermsl (Γ pn)"and"q ∈ A"by metis hence"not_call q"using no_calls [of pn] unfolding not_call_def by auto
from hasnext [OF ‹q ∈ A›] obtain q' where"q ↝<Gamma> q'"by auto moreoverfrom‹q ∈ stermsl (Γ pn)›‹not_call q›have"¬ (q ↝<Gamma> q')" by (rule nocall_stermsl_max) ultimatelyshow"False"by simp qed (auto dest: hasnext) qed qed
subsection"Start terms"
text‹
The start terms are those terms, relative to a wellformed process specification ‹Γ›,
from which transitions can occur directly. ›
text‹
The derivatives of a term are those @{term sterm}s potentially reachable by taking a
transition, relative to a wellformed process specification ‹Γ›. These terms
overapproximate the reachable sterms, since the truth of guards is not considered. ›
text‹
Note that the converse of @{thm dterms_subterms} is not true because @{term dterm}s are an
over-approximation; i.e., we cannot show, in general, that guards return a non-empty set
of post-states. ›
subsection"Control terms "
text‹
The control terms of a process specification @{term Γ} are those subterms from which
transitions are directly possible. We can omit @{term "call(pn)"} terms, since
the root terms of all processes are considered, and also @{term "p1 ⊕ p2"} terms
since they effectively combine the transitions of the subterms @{term p1} and
@{term p2}.
It will be shown that only the control terms, rather than all subterms, need be
considered in invariant proofs. ›
lemma dterms_cterms [elim]: assumes"p ∈ cterms Γ" and"q ∈ dterms Γ p" and"wellformed Γ" shows"q ∈ cterms Γ" using assms by (cases p) auto
lemma derivs_in_cterms [simp]: "∧l f p. {l}⟨f⟩ p ∈ cterms Γ ==> sterms Γ p ⊆ cterms Γ" "∧l f p. {l}[f] p ∈ cterms Γ ==> sterms Γ p ⊆ cterms Γ" "∧l fip fmsg q p. {l}unicast(fip, fmsg). p ▹ q ∈ cterms Γ ==> sterms Γ p ⊆ cterms Γ ∧ sterms Γ q ⊆ cterms Γ" "∧l fmsg p. {l}broadcast(fmsg).p ∈ cterms Γ ==> sterms Γ p ⊆ cterms Γ" "∧l fips fmsg p. {l}groupcast(fips, fmsg).p ∈ cterms Γ ==> sterms Γ p ⊆ cterms Γ" "∧l fmsg p. {l}send(fmsg).p ∈ cterms Γ ==> sterms Γ p ⊆ cterms Γ" "∧l fdata p. {l}deliver(fdata).p ∈ cterms Γ ==> sterms Γ p ⊆ cterms Γ" "∧l fmsg p. {l}receive(fmsg).p ∈ cterms Γ ==> sterms Γ p ⊆ cterms Γ" by (auto simp: dterms.psimps)
subsection"Local control terms"
text‹
We introduce a `local' version of @{term cterms} that does not step through calls and,
thus, that is defined independently of a process specification @{term Γ}.
This allows an alternative, terminating characterisation of cterms as a set of
subterms. Including @{term "call(pn)"}s in the set makes for a simpler relation with
@{term "stermsl"}, even if they must be filtered out for the desired characterisation. ›
lemma dtermsl_in_branch [elim]: "[p ∈ dtermsl (p1 ⊕ p2); p ∈ dtermsl p1 ==> P; p ∈ dtermsl p2 ==> P]==> P" by auto
lemma ctermsl_dtermsl [elim]: assumes"q ∈ dtermsl p" shows"q ∈ ctermsl p" using assms by (induct p) (simp_all, (metis stermsl_ctermsl)+)
lemma dtermsl_dterms [elim]: assumes"q ∈ dtermsl p" and"not_call q" and"wellformed Γ" shows"q ∈ dterms Γ p" using assms using assms by (induct p) (simp_all, (metis stermsl_sterms)+)
lemma ctermsl_stermsl_or_dtermsl: assumes"q ∈ ctermsl p" shows"q ∈ stermsl p ∨ (∃p'∈dtermsl p. q ∈ ctermsl p')" using assms by (induct p) (auto dest: ctermsl_ex_stermsl)
lemma dtermsl_add_stermsl_beforeD: assumes"q ∈ dtermsl p" shows"∃ps∈stermsl p. q ∈ dtermsl ps" proof - from assms have"q ∈ (∪x∈stermsl p. dtermsl x)"by auto thus ?thesis by (rule UN_E) auto qed
lemma call_dtermsl_empty [elim]: "q ∈ dtermsl p ==> not_call p" by (cases p) simp_all
subsection"More properties of control terms"
text‹
We now show an alternative definition of @{term "cterms"} based on sets of local control
terms. While the original definition has convenient induction and simplification rules,
useful for proving properties like cterms\_includes\_sterms\_of\_seq\_reachable, this
definition makes it easier to systematically generate the set of control terms of a
process specification. ›
theorem cterms_def': assumes wfg: "wellformed Γ" shows"cterms Γ = { p |p pn. p ∈ ctermsl (Γ pn) ∧ not_call p }"
(is"_ = ?ctermsl_set") proof (rule iffI [THEN set_eqI]) fix p assume"p ∈ cterms Γ" thus"p ∈ ?ctermsl_set" proof (induction p) fix p pn assume"p ∈ sterms Γ (Γ pn)" thenobtain pn' where"p ∈ stermsl (Γ pn')"using wfg by (blast dest: sterms_stermsl_heads) hence"p ∈ ctermsl (Γ pn')" .. moreoverfrom‹p ∈ sterms Γ (Γ pn)› wfg have"not_call p"by simp ultimatelyshow"p ∈ ?ctermsl_set"by auto next fix pp p assume"pp ∈ cterms Γ" and IH: "pp ∈ ?ctermsl_set" and *: "p ∈ dterms Γ pp" from * have"p ∈ ctermsl pp ∨ (∃pn. p ∈ ctermsl (Γ pn))" using wfg by (rule dterms_ctermsl) hence"∃pn. p ∈ ctermsl (Γ pn)" proof assume"p ∈ ctermsl pp" from‹pp ∈ cterms Γ›and IH obtain pn' where"pp ∈ ctermsl (Γ pn')" by auto with‹p ∈ ctermsl pp›have"p ∈ ctermsl (Γ pn')"by auto thus"∃pn. p ∈ ctermsl (Γ pn)" .. qed - moreoverfrom‹p ∈ dterms Γ pp› wfg have"not_call p"by simp ultimatelyshow"p ∈ ?ctermsl_set"by auto qed next fix p assume"p ∈ ?ctermsl_set" thenobtain pn where *: "p ∈ ctermsl (Γ pn)"and"not_call p"by auto from * have"p ∈ stermsl (Γ pn) ∨ (∃p'∈dtermsl (Γ pn). p ∈ ctermsl p')" by (rule ctermsl_stermsl_or_dtermsl) thus"p ∈ cterms Γ" proof assume"p ∈ stermsl (Γ pn)" hence"p ∈ sterms Γ (Γ pn)"using‹not_call p› wfg .. thus"p ∈ cterms Γ" .. next assume"∃p'∈dtermsl (Γ pn). p ∈ ctermsl p'" thenobtain p' where p'1: "p' ∈ dtermsl (Γ pn)" and p'2: "p ∈ ctermsl p'" .. from p'2and‹not_call p›have"not_call p'" .. from p'1obtain ps where ps1: "ps ∈ stermsl (Γ pn)" and ps2: "p' ∈ dtermsl ps" by (blast dest: dtermsl_add_stermsl_beforeD) from ps2 have"not_call ps" .. with ps1 have"ps ∈ cterms Γ"using wfg by auto with‹p' ∈ dtermsl ps›and‹not_call p'›have"p' ∈ cterms Γ"using wfg by auto hence"sterms Γ p' ⊆ cterms Γ"using wfg by auto with‹p ∈ ctermsl p'›‹not_call p›show"p ∈ cterms Γ"using wfg .. qed qed
lemma ctermsE [elim]: assumes"wellformed Γ" and"p ∈ cterms Γ" obtains pn where"p ∈ ctermsl (Γ pn)" and"not_call p" using assms(2) unfolding cterms_def' [OF assms(1)] by auto
corollary cterms_subterms: assumes"wellformed Γ" shows"cterms Γ = {p|p pn. p∈subterms (Γ pn) ∧ not_call p ∧ not_choice p}" by (subst cterms_def' [OF assms(1)], subst ctermsl_subterms) auto
lemma subterms_in_cterms [elim]: assumes"wellformed Γ" and"p∈subterms (Γ pn)" and"not_call p" and"not_choice p" shows"p ∈ cterms Γ" using assms unfolding cterms_subterms [OF ‹wellformed Γ›] by auto
lemma subterms_stermsl_ctermsl: assumes"q ∈ subterms p" and"r ∈ stermsl q" shows"r ∈ ctermsl p" using assms proof (induct p) fix p1 p2 assume IH1: "q ∈ subterms p1 ==> r ∈ stermsl q ==> r ∈ ctermsl p1" and IH2: "q ∈ subterms p2 ==> r ∈ stermsl q ==> r ∈ ctermsl p2" and *: "q ∈ subterms (p1 ⊕ p2)" and"r ∈ stermsl q" from * have"q ∈ {p1 ⊕ p2} ∪ subterms p1 ∪ subterms p2"by simp thus"r ∈ ctermsl (p1 ⊕ p2)" proof (elim UnE) assume"q ∈ {p1 ⊕ p2}"with‹r ∈ stermsl q›show ?thesis by simp (metis stermsl_ctermsl) next assume"q ∈ subterms p1"hence"r ∈ ctermsl p1"using‹r ∈ stermsl q›by (rule IH1) thus ?thesis by simp next assume"q ∈ subterms p2"hence"r ∈ ctermsl p2"using‹r ∈ stermsl q›by (rule IH2) thus ?thesis by simp qed qed auto
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.