theory CompoTraces imports CompoScheds ShortExecutions begin
definition mksch :: "('a, 's) ioa → ('a, 't) ioa → 'a Seq → 'a Seq → 'a Seq → 'a Seq" where"mksch A B = (fix ⋅ (LAM h tr schA schB. case tr of nil → nil | x ## xs → (case x of UU → UU | Def y → (if y ∈ act A then (if y ∈ act B then ((Takewhile (λa. a ∈ int A) ⋅ schA) @@ (Takewhile (λa. a ∈ int B) ⋅ schB) @@ (y ↝ (h ⋅ xs ⋅ (TL ⋅ (Dropwhile (λa. a ∈ int A) ⋅ schA)) ⋅ (TL ⋅ (Dropwhile (λa. a ∈ int B) ⋅ schB))))) else ((Takewhile (λa. a ∈ int A) ⋅ schA) @@ (y ↝ (h ⋅ xs ⋅ (TL ⋅ (Dropwhile (λa. a ∈ int A) ⋅ schA)) ⋅ schB)))) else (if y ∈ act B then ((Takewhile (λa. a ∈ int B) ⋅ schB) @@ (y ↝ (h ⋅ xs ⋅ schA ⋅ (TL ⋅ (Dropwhile (λa. a ∈ int B) ⋅ schB))))) else UU)))))"
lemma mksch_unfold: "mksch A B = (LAM tr schA schB. case tr of nil → nil | x ## xs → (case x of UU → UU | Def y → (if y ∈ act A then (if y ∈ act B then ((Takewhile (λa. a ∈ int A) ⋅ schA) @@ (Takewhile (λa. a ∈ int B) ⋅ schB) @@ (y ↝ (mksch A B ⋅ xs ⋅(TL ⋅ (Dropwhile (λa. a ∈ int A) ⋅ schA)) ⋅(TL ⋅ (Dropwhile (λa. a ∈ int B) ⋅ schB))))) else ((Takewhile (λa. a ∈ int A) ⋅ schA) @@ (y ↝ (mksch A B ⋅ xs ⋅ (TL ⋅ (Dropwhile (λa. a ∈ int A) ⋅ schA)) ⋅ schB)))) else (if y ∈ act B then ((Takewhile (λa. a ∈ int B) ⋅ schB) @@ (y ↝ (mksch A B ⋅ xs ⋅ schA ⋅ (TL ⋅ (Dropwhile (λa. a ∈ int B) ⋅ schB))))) else UU))))" apply (rule trans) apply (rule fix_eq4) apply (rule mksch_def) apply (rule beta_cfun) apply simp done
lemma mksch_UU: "mksch A B ⋅ UU ⋅ schA ⋅ schB = UU" apply (subst mksch_unfold) apply simp done
lemma mksch_nil: "mksch A B ⋅ nil ⋅ schA ⋅ schB = nil" apply (subst mksch_unfold) apply simp done
lemma mksch_cons1: "x ∈ act A ==> x ∉ act B ==> mksch A B ⋅ (x ↝ tr) ⋅ schA ⋅ schB = (Takewhile (λa. a ∈ int A) ⋅ schA) @@ (x ↝ (mksch A B ⋅ tr ⋅ (TL ⋅ (Dropwhile (λa. a ∈ int A) ⋅ schA)) ⋅ schB))" apply (rule trans) apply (subst mksch_unfold) apply (simp add: Consq_def If_and_if) apply (simp add: Consq_def) done
lemma mksch_cons2: "x ∉ act A ==> x ∈ act B ==> mksch A B ⋅ (x ↝ tr) ⋅ schA ⋅ schB = (Takewhile (λa. a ∈ int B) ⋅ schB) @@ (x ↝ (mksch A B ⋅ tr ⋅ schA ⋅ (TL ⋅ (Dropwhile (λa. a ∈ int B) ⋅ schB))))" apply (rule trans) apply (subst mksch_unfold) apply (simp add: Consq_def If_and_if) apply (simp add: Consq_def) done
lemma mksch_cons3: "x ∈ act A ==> x ∈ act B ==> mksch A B ⋅ (x ↝ tr) ⋅ schA ⋅ schB = (Takewhile (λa. a ∈ int A) ⋅ schA) @@ ((Takewhile (λa. a ∈ int B) ⋅ schB) @@ (x ↝ (mksch A B ⋅ tr ⋅ (TL ⋅ (Dropwhile (λa. a ∈ int A) ⋅ schA)) ⋅ (TL ⋅ (Dropwhile (λa. a ∈ int B) ⋅ schB)))))" apply (rule trans) apply (subst mksch_unfold) apply (simp add: Consq_def If_and_if) apply (simp add: Consq_def) done
text ‹ Consequence out of ‹ext1_ext2_is_not_act1(2)›, which in turn are consequences out of the compatibility of IOA, in particular out of the condition that internals are really hidden. \<close>
lemma compatibility_consequence1: " eB ∧¬ eA ⟶¬ A) ⟶ A ∧ (eA ∨ eB) ⟷ eA ∧ A"
by fast
(* very similar to above, only the commutativity of | is used to make a slight change *) lemma compatibility_consequence2: "(eB ∧¬ eA ⟶¬ A) ⟶ A ∧ (eB ∨ eA) ⟷ eA ∧ A" by fast
subsubsection‹Lemmata for ‹<==››
(* Lemma for substitution of looping assumption in another specific assumption *) lemma subst_lemma1: "f ⊑ g x ==> x = h x ==> f ⊑ g (h x)" by (erule subst)
(* Lemma for substitution of looping assumption in another specific assumption *) lemma subst_lemma2: "(f x) = y ↝ g ==> x = h x ==> f (h x) = y ↝ g" by (erule subst)
lemma ForallBnAmksch [rule_format]: "compatible B A ==> ∀schA schB. Forall (λx. x ∈ act B ∧ x ∉ act A) tr ⟶ Forall (λx. x ∈ act B ∧ x ∉ act A) (mksch A B ⋅ tr ⋅ schA ⋅ schB)" apply (Seq_induct tr simp: Forall_def sforall_def mksch_def) apply auto apply (rule Forall_Conc_impl [THEN mp]) apply (simp add: intA_is_not_actB int_is_act) done
lemma ForallAnBmksch [rule_format]: "compatible A B ==> ∀schA schB. Forall (λx. x ∈ act A ∧ x ∉ act B) tr ⟶ Forall (λx. x ∈ act A ∧ x ∉ act B) (mksch A B ⋅ tr ⋅ schA ⋅ schB)" apply (Seq_induct tr simp: Forall_def sforall_def mksch_def) apply auto apply (rule Forall_Conc_impl [THEN mp]) apply (simp add: intA_is_not_actB int_is_act) done
(* safe_tac makes too many case distinctions with this lemma in the next proof *) declare FiniteConc [simp del]
lemma FiniteL_mksch [rule_format]: "Finite tr ==> is_asig (asig_of A) ==> is_asig (asig_of B) ==> ∀x y. Forall (λx. x ∈ act A) x ∧ Forall (λx. x ∈ act B) y ∧ Filter (λa. a ∈ ext A) ⋅ x = Filter (λa. a ∈ act A) ⋅ tr ∧ Filter (λa. a ∈ ext B) ⋅ y = Filter (λa. a ∈ act B) ⋅ tr ∧ Forall (λx. x ∈ ext (A ∥ B)) tr ⟶ Finite (mksch A B ⋅ tr ⋅ x ⋅ y)" apply (erule Seq_Finite_ind) apply simp text‹main case› apply simp apply auto
text‹‹a ∈ act A›; ‹a ∈ act B›› apply (frule sym [THEN eq_imp_below, THEN divide_Seq]) apply (frule sym [THEN eq_imp_below, THEN divide_Seq]) back apply (erule conjE)+ text‹‹Finite (tw iA x)› and ‹Finite (tw iB y)›› apply (simp add: not_ext_is_int_or_not_act FiniteConc) text‹now for conclusion IH applicable, but assumptions have to be transformed› apply (drule_tac x = "x"and g = "Filter (λa. a ∈ act A) ⋅ s"in subst_lemma2) apply assumption apply (drule_tac x = "y"and g = "Filter (λa. a ∈ act B) ⋅ s"in subst_lemma2) apply assumption text‹IH› apply (simp add: not_ext_is_int_or_not_act ForallTL ForallDropwhile)
apply (erule conjE)+ text‹‹Finite (tw iB y)›› apply (simp add: not_ext_is_int_or_not_act FiniteConc) text‹now for conclusion IH applicable, but assumptions have to be transformed› apply (drule_tac x = "y"and g = "Filter (λa. a ∈ act B) ⋅ s"in subst_lemma2) apply assumption text‹IH› apply (simp add: not_ext_is_int_or_not_act ForallTL ForallDropwhile)
apply (erule conjE)+ text‹‹Finite (tw iA x)›› apply (simp add: not_ext_is_int_or_not_act FiniteConc) text‹now for conclusion IH applicable, but assumptions have to be transformed› apply (drule_tac x = "x"and g = "Filter (λa. a ∈ act A) ⋅ s"in subst_lemma2) apply assumption text‹IH› apply (simp add: not_ext_is_int_or_not_act ForallTL ForallDropwhile)
lemma reduceA_mksch1 [rule_format]: "Finite bs ==> is_asig (asig_of A) ==> is_asig (asig_of B) ==> compatible A B ==> ∀y. Forall (λx. x ∈ act B) y ∧ Forall (λx. x ∈ act B ∧ x ∉ act A) bs ∧ Filter (λa. a ∈ ext B) ⋅ y = Filter (λa. a ∈ act B) ⋅ (bs @@ z) ⟶ (∃y1 y2. (mksch A B ⋅ (bs @@ z) ⋅ x ⋅ y) = (y1 @@ (mksch A B ⋅ z ⋅ x ⋅ y2)) ∧ Forall (λx. x ∈ act B ∧ x ∉ act A) y1 ∧ Finite y1 ∧ y = (y1 @@ y2) ∧ Filter (λa. a ∈ ext B) ⋅ y1 = bs)" apply (frule_tac A1 = "A"in compat_commute [THEN iffD1]) apply (erule Seq_Finite_ind) apply (rule allI)+ apply (rule impI) apply (rule_tac x = "nil"in exI) apply (rule_tac x = "y"in exI) apply simp text‹main case› apply (rule allI)+ apply (rule impI) apply simp apply (erule conjE)+ apply simp text‹‹divide_Seq› on ‹s›› apply (frule sym [THEN eq_imp_below, THEN divide_Seq]) apply (erule conjE)+ text‹transform assumption ‹f eB y = f B (s @ z)›› apply (drule_tac x = "y"and g = "Filter (λa. a ∈ act B) ⋅ (s @@ z) "in subst_lemma2) apply assumption apply (simp add: not_ext_is_int_or_not_act FilterConc) text‹apply IH› apply (erule_tac x = "TL ⋅ (Dropwhile (λa. a ∈ int B) ⋅ y)"in allE) apply (simp add: ForallTL ForallDropwhile FilterConc) apply (erule exE)+ apply (erule conjE)+ apply (simp add: FilterConc) text‹for replacing IH in conclusion› apply (rotate_tac -2) text‹instantiate ‹y1a› and ‹y2a›› apply (rule_tac x = "Takewhile (λa. a ∈ int B) ⋅ y @@ a ↝ y1"in exI) apply (rule_tac x = "y2"in exI) text‹elminate all obligations up to two depending on ‹Conc_assoc›› apply (simp add: intA_is_not_actB int_is_act int_is_not_ext FilterConc) apply (simp add: Conc_assoc FilterConc) done
lemma reduceB_mksch1 [rule_format]: "Finite a_s ==> is_asig (asig_of A) ==> is_asig (asig_of B) ==> compatible A B ==> ∀x. Forall (λx. x ∈ act A) x ∧ Forall (λx. x ∈ act A ∧ x ∉ act B) a_s ∧ Filter (λa. a ∈ ext A) ⋅ x = Filter (λa. a ∈ act A) ⋅ (a_s @@ z) ⟶ (∃x1 x2. (mksch A B ⋅ (a_s @@ z) ⋅ x ⋅ y) = (x1 @@ (mksch A B ⋅ z ⋅ x2 ⋅ y)) ∧ Forall (λx. x ∈ act A ∧ x ∉ act B) x1 ∧ Finite x1 ∧ x = (x1 @@ x2) ∧ Filter (λa. a ∈ ext A) ⋅ x1 = a_s)" apply (frule_tac A1 = "A"in compat_commute [THEN iffD1]) apply (erule Seq_Finite_ind) apply (rule allI)+ apply (rule impI) apply (rule_tac x = "nil"in exI) apply (rule_tac x = "x"in exI) apply simp text‹main case› apply (rule allI)+ apply (rule impI) apply simp apply (erule conjE)+ apply simp text‹‹divide_Seq› on ‹s›› apply (frule sym [THEN eq_imp_below, THEN divide_Seq]) apply (erule conjE)+ text‹transform assumption ‹f eA x = f A (s @ z)›› apply (drule_tac x = "x"and g = "Filter (λa. a ∈ act A) ⋅ (s @@ z)"in subst_lemma2) apply assumption apply (simp add: not_ext_is_int_or_not_act FilterConc) text‹apply IH› apply (erule_tac x = "TL ⋅ (Dropwhile (λa. a ∈ int A) ⋅ x)"in allE) apply (simp add: ForallTL ForallDropwhile FilterConc) apply (erule exE)+ apply (erule conjE)+ apply (simp add: FilterConc) text‹for replacing IH in conclusion› apply (rotate_tac -2) text‹instantiate ‹y1a› and ‹y2a›› apply (rule_tac x = "Takewhile (λa. a ∈ int A) ⋅ x @@ a ↝ x1"in exI) apply (rule_tac x = "x2"in exI) text‹eliminate all obligations up to two depending on ‹Conc_assoc›› apply (simp add: intA_is_not_actB int_is_act int_is_not_ext FilterConc) apply (simp add: Conc_assoc FilterConc) done
subsection‹Filtering external actions out of ‹mksch (tr, schA, schB)› yields the oracle ‹tr››
lemma FilterA_mksch_is_tr: "compatible A B ==> compatible B A ==> is_asig (asig_of A) ==> is_asig (asig_of B) ==> ∀schA schB. Forall (λx. x ∈ act A) schA ∧ Forall (λx. x ∈ act B) schB ∧ Forall (λx. x ∈ ext (A ∥ B)) tr ∧ Filter (λa. a ∈ act A) ⋅ tr ⊑ Filter (λa. a ∈ ext A) ⋅ schA ∧ Filter (λa. a ∈ act B) ⋅ tr ⊑ Filter (λa. a ∈ ext B) ⋅ schB ⟶ Filter (λa. a ∈ ext (A ∥ B)) ⋅ (mksch A B ⋅ tr ⋅ schA ⋅ schB) = tr" apply (Seq_induct tr simp: Forall_def sforall_def mksch_def) text‹main case› text‹splitting into 4 cases according to ‹a ∈ A›, ‹a ∈ B›› apply auto
text‹Case ‹a ∈ A›, ‹a ∈ B›› apply (frule divide_Seq) apply (frule divide_Seq) back apply (erule conjE)+ text‹filtering internals of ‹A› in ‹schA› and of ‹B› in ‹schB› is ‹nil›› apply (simp add: not_ext_is_int_or_not_act externals_of_par intA_is_not_extB int_is_not_ext) text‹conclusion of IH ok, but assumptions of IH have to be transformed› apply (drule_tac x = "schA"in subst_lemma1) apply assumption apply (drule_tac x = "schB"in subst_lemma1) apply assumption text‹IH› apply (simp add: not_ext_is_int_or_not_act ForallTL ForallDropwhile)
text‹reduce trace_takes from ‹n› to strictly smaller ‹k›› apply (rule take_reduction) apply (rule refl) apply (rule refl)
text‹now conclusion fulfills induction hypothesis, but assumptions are not all ready›
text‹assumption ‹schB›› apply (drule_tac x = "y2"and g = "Filter (λa. a ∈ act B) ⋅ rs"in subst_lemma2) apply assumption apply (simp add: intA_is_not_actB int_is_not_ext)
text‹conclusions concerning ‹LastActExtsch›, cannot be rewritten, as ‹LastActExtsmalli› are looping› apply (drule_tac sch = "schA"and P = "λa. a ∈ int A"in LastActExtsmall1) apply (frule_tac ?sch1.0 = "y1"in LastActExtsmall2) apply assumption apply (drule_tac sch = "y2"and P = "λa. a ∈ int B"in LastActExtsmall1)
text‹assumption ‹Forall schA›, and ‹Forall schA› are performed by ‹ForallTL›, ‹ForallDropwhile›› apply (simp add: ForallTL ForallDropwhile)
text‹case ‹x ∉ A ∧ x ∈ B›› text‹cannot occur, as just this case has been scheduled out before as the ‹B›-only prefix› apply (case_tac "x ∈ act B") apply fast
text‹case ‹x ∉ A ∧ x ∉ B›› text‹cannot occur because of assumption: ‹Forall (a ∈ ext A ∨ a ∈ ext B)›› apply (rotate_tac -9) text‹reduce forall assumption from ‹tr› to ‹x ↝ rs›› apply (simp add: externals_of_par) apply (fast intro!: ext_is_act) done
subsection‹Filter of ‹mksch (tr, schA, schB)› to ‹B› is ‹schB› -- take lemma proof›
lemma FilterBmksch_is_schB: "compatible A B ==> compatible B A ==> is_asig (asig_of A) ==> is_asig (asig_of B) ==> Forall (λx. x ∈ ext (A ∥ B)) tr ∧ Forall (λx. x ∈ act A) schA ∧ Forall (λx. x ∈ act B) schB ∧ Filter (λa. a ∈ ext A) ⋅ schA = Filter (λa. a ∈ act A) ⋅ tr ∧ Filter (λa. a ∈ ext B) ⋅ schB = Filter (λa. a ∈ act B) ⋅ tr ∧ LastActExtsch A schA ∧ LastActExtsch B schB ⟶ Filter (λa. a ∈ act B) ⋅ (mksch A B ⋅ tr ⋅ schA ⋅ schB) = schB" apply (intro strip) apply (rule seq.take_lemma) apply (rule mp) prefer2apply assumption backbackbackback apply (rule_tac x = "schA"in spec) apply (rule_tac x = "schB"in spec) apply (rule_tac x = "tr"in spec) apply (tactic "thin_tac' context 5 1") apply (rule nat_less_induct) apply (rule allI)+ apply (rename_tac tr schB schA) apply (intro strip) apply (erule conjE)+
apply (case_tac "Forall (λx. x ∈ act A ∧ x ∉ act B) tr")
text‹‹divide_Seq› for ‹schB2›› apply (frule_tac y = "x2"in sym [THEN eq_imp_below, THEN divide_Seq]) apply (erule conjE)+ text‹assumption ‹schA›› apply (drule_tac x = "schB"and g = "Filter (λa. a ∈ act B) ⋅ rs"in subst_lemma2) apply assumption apply (simp add: int_is_not_ext)
text‹‹f B (tw iA schA2) = nil›› apply (simp add: int_is_not_ext not_ext_is_int_or_not_act intA_is_not_actB)
text‹reduce ‹trace_takes from ‹n› to strictly smaller ‹k››› apply (rule take_reduction) apply (rule refl) apply (rule refl)
text‹now conclusion fulfills induction hypothesis, but assumptions are not all ready›
text‹assumption ‹schA›› apply (drule_tac x = "x2"and g = "Filter (λa. a ∈ act A) ⋅ rs"in subst_lemma2) apply assumption apply (simp add: intA_is_not_actB int_is_not_ext)
text‹conclusions concerning ‹LastActExtsch›, cannot be rewritten, as ‹LastActExtsmalli› are looping› apply (drule_tac sch = "schB"and P = "λa. a∈int B"in LastActExtsmall1) apply (frule_tac ?sch1.0 = "x1"in LastActExtsmall2) apply assumption apply (drule_tac sch = "x2"and P = "λa. a∈int A"in LastActExtsmall1)
text‹assumption ‹Forall schA›, and ‹Forall schA› are performed by ‹ForallTL›, ‹ForallDropwhile›› apply (simp add: ForallTL ForallDropwhile)
text‹case ‹x ∉ B ∧ x ∈ A›› text‹cannot occur, as just this case has been scheduled out before as the ‹B›-only prefix› apply (case_tac "x ∈ act A") apply fast
text‹case ‹x ∉ B ∧ x ∉ A›› text‹cannot occur because of assumption: ‹Forall (a ∈ ext A ∨ a ∈ ext B)›› apply (rotate_tac -9) text‹reduce forall assumption from ‹tr› to ‹x ↝ rs›› apply (simp add: externals_of_par) apply (fast intro!: ext_is_act) done
subsection"COMPOSITIONALITY on TRACE Level -- Main Theorem"
theorem compositionality_tr: "is_trans_of A ==> is_trans_of B ==> compatible A B ==> compatible B A ==> is_asig (asig_of A) ==> is_asig (asig_of B) ==> tr ∈ traces (A ∥ B) ⟷ Filter (λa. a ∈ act A) ⋅ tr ∈ traces A ∧ Filter (λa. a ∈ act B) ⋅ tr ∈ traces B ∧ Forall (λx. x ∈ ext(A ∥ B)) tr" apply (simp add: traces_def has_trace_def) apply auto
text‹‹==>›› text‹There is a schedule of ‹A›› apply (rule_tac x = "Filter (λa. a ∈ act A) ⋅ sch"in bexI) prefer2 apply (simp add: compositionality_sch) apply (simp add: compatibility_consequence1 externals_of_par ext1_ext2_is_not_act1) text‹There is a schedule of ‹B›› apply (rule_tac x = "Filter (λa. a ∈ act B) ⋅ sch"in bexI) prefer2 apply (simp add: compositionality_sch) apply (simp add: compatibility_consequence2 externals_of_par ext1_ext2_is_not_act2) text‹Traces of ‹A ∥ B› have only external actions from ‹A› or ‹B›› apply (rule ForallPFilterP)
text‹‹<==››
text‹replace ‹schA› and ‹schB› by ‹Cut schA› and ‹Cut schB›› apply (drule exists_LastActExtsch) apply assumption apply (drule exists_LastActExtsch) apply assumption apply (erule exE)+ apply (erule conjE)+ text‹Schedules of A(B) have only actions of A(B)› apply (drule scheds_in_sig) apply assumption apply (drule scheds_in_sig) apply assumption
apply (rename_tac h1 h2 schA schB) text‹‹mksch› is exactly the construction of ‹trA∥B› out of ‹schA›, ‹schB›, and the oracle ‹tr›,
we need here› apply (rule_tac x = "mksch A B ⋅ tr ⋅ schA ⋅ schB"in bexI)
text‹External actions of mksch are just the oracle› apply (simp add: FilterA_mksch_is_tr)
text‹‹mksch› is a schedule -- use compositionality on sch-level› apply (simp add: compositionality_sch) apply (simp add: FilterAmksch_is_schA FilterBmksch_is_schB) apply (erule ForallAorB_mksch) apply (erule ForallPForallQ) apply (erule ext_is_act) done
subsection‹COMPOSITIONALITY on TRACE Level -- for Modules›
lemma compositionality_tr_modules: "is_trans_of A ==> is_trans_of B ==> compatible A B ==> compatible B A ==> is_asig(asig_of A) ==> is_asig(asig_of B) ==> Traces (A∥B) = par_traces (Traces A) (Traces B)" apply (unfold Traces_def par_traces_def) apply (simp add: asig_of_par) apply (rule set_eqI) apply (simp add: compositionality_tr externals_of_par) done
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.