src/HOL/HOLCF/IOA/CompoTraces.thy
changeset 62156 7355fd313cf8
parent 62008 cbedaddc9351
child 62195 799a5306e2ed
equal deleted inserted replaced
62155:ec2f0dad8b98 62156:7355fd313cf8
     6 
     6 
     7 theory CompoTraces
     7 theory CompoTraces
     8 imports CompoScheds ShortExecutions
     8 imports CompoScheds ShortExecutions
     9 begin
     9 begin
    10 
    10 
    11 definition mksch :: "('a,'s)ioa => ('a,'t)ioa => 'a Seq -> 'a Seq -> 'a Seq -> 'a Seq"
    11 definition mksch ::
    12 where
    12     "('a, 's) ioa \<Rightarrow> ('a, 't) ioa \<Rightarrow> 'a Seq \<rightarrow> 'a Seq \<rightarrow> 'a Seq \<rightarrow> 'a Seq"
    13   "mksch A B = (fix$(LAM h tr schA schB. case tr of
    13   where "mksch A B =
    14        nil => nil
    14     (fix $
    15     | x##xs =>
    15       (LAM h tr schA schB.
    16       (case x of
    16         case tr of
    17         UU => UU
    17           nil \<Rightarrow> nil
    18       | Def y =>
    18         | x ## xs \<Rightarrow>
    19          (if y:act A then
    19             (case x of
    20              (if y:act B then
    20               UU \<Rightarrow> UU
    21                    ((Takewhile (%a. a:int A)$schA)
    21             | Def y \<Rightarrow>
    22                       @@ (Takewhile (%a. a:int B)$schB)
    22                 (if y \<in> act A then
    23                            @@ (y\<leadsto>(h$xs
    23                   (if y \<in> act B then
    24                                     $(TL$(Dropwhile (%a. a:int A)$schA))
    24                     ((Takewhile (\<lambda>a. a \<in> int A) $ schA) @@
    25                                     $(TL$(Dropwhile (%a. a:int B)$schB))
    25                      (Takewhile (\<lambda>a. a \<in> int B) $ schB) @@
    26                     )))
    26                      (y \<leadsto> (h $ xs $ (TL $ (Dropwhile (\<lambda>a. a \<in> int A) $ schA))
    27               else
    27                                    $ (TL $ (Dropwhile (\<lambda>a. a \<in> int B) $ schB)))))
    28                  ((Takewhile (%a. a:int A)$schA)
    28                    else
    29                   @@ (y\<leadsto>(h$xs
    29                     ((Takewhile (\<lambda>a. a \<in> int A) $ schA) @@
    30                            $(TL$(Dropwhile (%a. a:int A)$schA))
    30                      (y \<leadsto> (h $ xs $ (TL $ (Dropwhile (\<lambda>a. a \<in> int A) $ schA)) $ schB))))
    31                            $schB)))
    31                  else
    32               )
    32                   (if y \<in> act B then
    33           else
    33                     ((Takewhile (\<lambda>a. a \<in> int B) $ schB) @@
    34              (if y:act B then
    34                      (y \<leadsto> (h $ xs $ schA $ (TL $ (Dropwhile (\<lambda>a. a \<in> int B) $ schB)))))
    35                  ((Takewhile (%a. a:int B)$schB)
    35                    else UU)))))"
    36                      @@ (y\<leadsto>(h$xs
    36 
    37                               $schA
    37 definition par_traces :: "'a trace_module \<Rightarrow> 'a trace_module \<Rightarrow> 'a trace_module"
    38                               $(TL$(Dropwhile (%a. a:int B)$schB))
    38   where "par_traces TracesA TracesB =
    39                               )))
    39     (let
    40              else
    40       trA = fst TracesA; sigA = snd TracesA;
    41                UU
    41       trB = fst TracesB; sigB = snd TracesB
    42              )
    42      in
    43          )
    43        ({tr. Filter (\<lambda>a. a \<in> actions sigA) $ tr \<in> trA} \<inter>
    44        )))"
    44         {tr. Filter (\<lambda>a. a \<in> actions sigB) $ tr \<in> trB} \<inter>
    45 
    45         {tr. Forall (\<lambda>x. x \<in> externals sigA \<union> externals sigB) tr},
    46 definition par_traces ::"['a trace_module,'a trace_module] => 'a trace_module"
       
    47 where
       
    48   "par_traces TracesA TracesB =
       
    49       (let trA = fst TracesA; sigA = snd TracesA;
       
    50            trB = fst TracesB; sigB = snd TracesB
       
    51        in
       
    52        (    {tr. Filter (%a. a:actions sigA)$tr : trA}
       
    53         Int {tr. Filter (%a. a:actions sigB)$tr : trB}
       
    54         Int {tr. Forall (%x. x:(externals sigA Un externals sigB)) tr},
       
    55         asig_comp sigA sigB))"
    46         asig_comp sigA sigB))"
    56 
    47 
    57 axiomatization
    48 axiomatization where
    58 where
    49   finiteR_mksch: "Finite (mksch A B $ tr $ x $ y) \<Longrightarrow> Finite tr"
    59   finiteR_mksch:
    50 
    60     "Finite (mksch A B$tr$x$y) \<Longrightarrow> Finite tr"
    51 lemma finiteR_mksch': "\<not> Finite tr \<Longrightarrow> \<not> Finite (mksch A B $ tr $ x $ y)"
    61 
       
    62 lemma finiteR_mksch': "\<not> Finite tr \<Longrightarrow> \<not> Finite (mksch A B$tr$x$y)"
       
    63   by (blast intro: finiteR_mksch)
    52   by (blast intro: finiteR_mksch)
    64 
    53 
    65 
    54 
    66 declaration \<open>fn _ => Simplifier.map_ss (Simplifier.set_mksym (K (K NONE)))\<close>
    55 declaration \<open>fn _ => Simplifier.map_ss (Simplifier.set_mksym (K (K NONE)))\<close>
    67 
    56 
    68 
    57 
    69 subsection "mksch rewrite rules"
    58 subsection "mksch rewrite rules"
    70 
    59 
    71 lemma mksch_unfold:
    60 lemma mksch_unfold:
    72 "mksch A B = (LAM tr schA schB. case tr of
    61   "mksch A B =
    73        nil => nil
    62     (LAM tr schA schB.
    74     | x##xs =>
    63       case tr of
    75       (case x of
    64         nil \<Rightarrow> nil
    76         UU => UU
    65       | x ## xs \<Rightarrow>
    77       | Def y =>
    66           (case x of
    78          (if y:act A then
    67             UU \<Rightarrow> UU
    79              (if y:act B then
    68           | Def y \<Rightarrow>
    80                    ((Takewhile (%a. a:int A)$schA)
    69               (if y \<in> act A then
    81                          @@(Takewhile (%a. a:int B)$schB)
    70                 (if y \<in> act B then
    82                               @@(y\<leadsto>(mksch A B$xs
    71                   ((Takewhile (\<lambda>a. a \<in> int A) $ schA) @@
    83                                        $(TL$(Dropwhile (%a. a:int A)$schA))
    72                    (Takewhile (\<lambda>a. a \<in> int B) $ schB) @@
    84                                        $(TL$(Dropwhile (%a. a:int B)$schB))
    73                    (y \<leadsto> (mksch A B $ xs $(TL $ (Dropwhile (\<lambda>a. a \<in> int A) $ schA))
    85                     )))
    74                                          $(TL $ (Dropwhile (\<lambda>a. a \<in> int B) $ schB)))))
    86               else
    75                  else
    87                  ((Takewhile (%a. a:int A)$schA)
    76                   ((Takewhile (\<lambda>a. a \<in> int A) $ schA) @@
    88                       @@ (y\<leadsto>(mksch A B$xs
    77                    (y \<leadsto> (mksch A B $ xs $ (TL $ (Dropwhile (\<lambda>a. a \<in> int A) $ schA)) $ schB))))
    89                               $(TL$(Dropwhile (%a. a:int A)$schA))
    78                else
    90                               $schB)))
    79                 (if y \<in> act B then
    91               )
    80                   ((Takewhile (\<lambda>a. a \<in> int B) $ schB) @@
    92           else
    81                    (y \<leadsto> (mksch A B $ xs $ schA $ (TL $ (Dropwhile (\<lambda>a. a \<in> int B) $ schB)))))
    93              (if y:act B then
    82                  else UU))))"
    94                  ((Takewhile (%a. a:int B)$schB)
    83   apply (rule trans)
    95                        @@ (y\<leadsto>(mksch A B$xs
    84   apply (rule fix_eq4)
    96                               $schA
    85   apply (rule mksch_def)
    97                               $(TL$(Dropwhile (%a. a:int B)$schB))
    86   apply (rule beta_cfun)
    98                               )))
    87   apply simp
    99              else
    88   done
   100                UU
    89 
   101              )
    90 lemma mksch_UU: "mksch A B $ UU $ schA $ schB = UU"
   102          )
    91   apply (subst mksch_unfold)
   103        ))"
    92   apply simp
   104 apply (rule trans)
    93   done
   105 apply (rule fix_eq4)
    94 
   106 apply (rule mksch_def)
    95 lemma mksch_nil: "mksch A B $ nil $ schA $ schB = nil"
   107 apply (rule beta_cfun)
    96   apply (subst mksch_unfold)
   108 apply simp
    97   apply simp
   109 done
    98   done
   110 
    99 
   111 lemma mksch_UU: "mksch A B$UU$schA$schB = UU"
   100 lemma mksch_cons1:
   112 apply (subst mksch_unfold)
   101   "x \<in> act A \<Longrightarrow> x \<notin> act B \<Longrightarrow>
   113 apply simp
   102     mksch A B $ (x \<leadsto> tr) $ schA $ schB =
   114 done
   103       (Takewhile (\<lambda>a. a \<in> int A) $ schA) @@
   115 
   104       (x \<leadsto> (mksch A B $ tr $ (TL $ (Dropwhile (\<lambda>a. a \<in> int A) $ schA)) $ schB))"
   116 lemma mksch_nil: "mksch A B$nil$schA$schB = nil"
   105   apply (rule trans)
   117 apply (subst mksch_unfold)
   106   apply (subst mksch_unfold)
   118 apply simp
   107   apply (simp add: Consq_def If_and_if)
   119 done
   108   apply (simp add: Consq_def)
   120 
   109   done
   121 lemma mksch_cons1: "[|x:act A;x~:act B|]
   110 
   122     ==> mksch A B$(x\<leadsto>tr)$schA$schB =
   111 lemma mksch_cons2:
   123           (Takewhile (%a. a:int A)$schA)
   112   "x \<notin> act A \<Longrightarrow> x \<in> act B \<Longrightarrow>
   124           @@ (x\<leadsto>(mksch A B$tr$(TL$(Dropwhile (%a. a:int A)$schA))
   113     mksch A B $ (x \<leadsto> tr) $ schA $ schB =
   125                               $schB))"
   114       (Takewhile (\<lambda>a. a \<in> int B) $ schB) @@
   126 apply (rule trans)
   115       (x \<leadsto> (mksch A B $ tr $ schA $ (TL $ (Dropwhile (\<lambda>a. a \<in> int B) $ schB))))"
   127 apply (subst mksch_unfold)
   116   apply (rule trans)
   128 apply (simp add: Consq_def If_and_if)
   117   apply (subst mksch_unfold)
   129 apply (simp add: Consq_def)
   118   apply (simp add: Consq_def If_and_if)
   130 done
   119   apply (simp add: Consq_def)
   131 
   120   done
   132 lemma mksch_cons2: "[|x~:act A;x:act B|]
   121 
   133     ==> mksch A B$(x\<leadsto>tr)$schA$schB =
   122 lemma mksch_cons3:
   134          (Takewhile (%a. a:int B)$schB)
   123   "x \<in> act A \<Longrightarrow> x \<in> act B \<Longrightarrow>
   135           @@ (x\<leadsto>(mksch A B$tr$schA$(TL$(Dropwhile (%a. a:int B)$schB))
   124     mksch A B $ (x \<leadsto> tr) $ schA $ schB =
   136                              ))"
   125       (Takewhile (\<lambda>a. a \<in> int A) $ schA) @@
   137 apply (rule trans)
   126       ((Takewhile (\<lambda>a. a \<in> int B) $ schB) @@
   138 apply (subst mksch_unfold)
   127       (x \<leadsto> (mksch A B $ tr $ (TL $ (Dropwhile (\<lambda>a. a \<in> int A) $ schA))
   139 apply (simp add: Consq_def If_and_if)
   128                             $ (TL $ (Dropwhile (\<lambda>a. a \<in> int B) $ schB)))))"
   140 apply (simp add: Consq_def)
   129   apply (rule trans)
   141 done
   130   apply (subst mksch_unfold)
   142 
   131   apply (simp add: Consq_def If_and_if)
   143 lemma mksch_cons3: "[|x:act A;x:act B|]
   132   apply (simp add: Consq_def)
   144     ==> mksch A B$(x\<leadsto>tr)$schA$schB =
   133   done
   145              (Takewhile (%a. a:int A)$schA)
       
   146           @@ ((Takewhile (%a. a:int B)$schB)
       
   147           @@ (x\<leadsto>(mksch A B$tr$(TL$(Dropwhile (%a. a:int A)$schA))
       
   148                              $(TL$(Dropwhile (%a. a:int B)$schB))))
       
   149               )"
       
   150 apply (rule trans)
       
   151 apply (subst mksch_unfold)
       
   152 apply (simp add: Consq_def If_and_if)
       
   153 apply (simp add: Consq_def)
       
   154 done
       
   155 
   134 
   156 lemmas compotr_simps = mksch_UU mksch_nil mksch_cons1 mksch_cons2 mksch_cons3
   135 lemmas compotr_simps = mksch_UU mksch_nil mksch_cons1 mksch_cons2 mksch_cons3
   157 
   136 
   158 declare compotr_simps [simp]
   137 declare compotr_simps [simp]
   159 
   138 
   160 
   139 
   161 subsection \<open>COMPOSITIONALITY on TRACE Level\<close>
   140 subsection \<open>COMPOSITIONALITY on TRACE Level\<close>
   162 
   141 
   163 subsubsection "Lemmata for ==>"
   142 subsubsection "Lemmata for \<open>\<Longrightarrow>\<close>"
   164 
   143 
   165 (* Consequence out of ext1_ext2_is_not_act1(2), which in turn are consequences out of
   144 text \<open>
   166    the compatibility of IOA, in particular out of the condition that internals are
   145   Consequence out of \<open>ext1_ext2_is_not_act1(2)\<close>, which in turn are
   167    really hidden. *)
   146   consequences out of the compatibility of IOA, in particular out of the
   168 
   147   condition that internals are really hidden.
   169 lemma compatibility_consequence1: "(eB & ~eA --> ~A) -->
   148 \<close>
   170           (A & (eA | eB)) = (eA & A)"
   149 
   171 apply fast
   150 lemma compatibility_consequence1: "(eB \<and> \<not> eA \<longrightarrow> \<not> A) \<longrightarrow> A \<and> (eA \<or> eB) \<longleftrightarrow> eA \<and> A"
   172 done
   151   by fast
   173 
   152 
   174 
   153 
   175 (* very similar to above, only the commutativity of | is used to make a slight change *)
   154 (* very similar to above, only the commutativity of | is used to make a slight change *)
   176 
   155 lemma compatibility_consequence2: "(eB \<and> \<not> eA \<longrightarrow> \<not> A) \<longrightarrow> A \<and> (eB \<or> eA) \<longleftrightarrow> eA \<and> A"
   177 lemma compatibility_consequence2: "(eB & ~eA --> ~A) -->
   156   by fast
   178           (A & (eB | eA)) = (eA & A)"
   157 
   179 apply fast
   158 
   180 done
   159 subsubsection \<open>Lemmata for \<open>\<Longleftarrow>\<close>\<close>
   181 
       
   182 
       
   183 subsubsection "Lemmata for <=="
       
   184 
   160 
   185 (* Lemma for substitution of looping assumption in another specific assumption *)
   161 (* Lemma for substitution of looping assumption in another specific assumption *)
   186 lemma subst_lemma1: "[| f << (g x) ; x=(h x) |] ==> f << g (h x)"
   162 lemma subst_lemma1: "f \<sqsubseteq> g x \<Longrightarrow> x = h x \<Longrightarrow> f \<sqsubseteq> g (h x)"
   187 by (erule subst)
   163   by (erule subst)
   188 
   164 
   189 (* Lemma for substitution of looping assumption in another specific assumption *)
   165 (* Lemma for substitution of looping assumption in another specific assumption *)
   190 lemma subst_lemma2: "[| (f x) = y \<leadsto> g; x=(h x) |] ==> (f (h x)) = y \<leadsto> g"
   166 lemma subst_lemma2: "(f x) = y \<leadsto> g \<Longrightarrow> x = h x \<Longrightarrow> f (h x) = y \<leadsto> g"
   191 by (erule subst)
   167   by (erule subst)
   192 
   168 
   193 lemma ForallAorB_mksch [rule_format]:
   169 lemma ForallAorB_mksch [rule_format]:
   194   "!!A B. compatible A B ==>
   170   "compatible A B \<Longrightarrow>
   195     ! schA schB. Forall (%x. x:act (A\<parallel>B)) tr
   171     \<forall>schA schB. Forall (\<lambda>x. x \<in> act (A \<parallel> B)) tr \<longrightarrow>
   196     --> Forall (%x. x:act (A\<parallel>B)) (mksch A B$tr$schA$schB)"
   172       Forall (\<lambda>x. x \<in> act (A \<parallel> B)) (mksch A B $ tr $ schA $ schB)"
   197 apply (tactic \<open>Seq_induct_tac @{context} "tr"
   173   apply (tactic \<open>Seq_induct_tac @{context} "tr" @{thms Forall_def sforall_def mksch_def} 1\<close>)
   198   [@{thm Forall_def}, @{thm sforall_def}, @{thm mksch_def}] 1\<close>)
   174   apply auto
   199 apply auto
   175   apply (simp add: actions_of_par)
   200 apply (simp add: actions_of_par)
   176   apply (case_tac "a \<in> act A")
   201 apply (case_tac "a:act A")
   177   apply (case_tac "a \<in> act B")
   202 apply (case_tac "a:act B")
   178   text \<open>\<open>a \<in> A\<close>, \<open>a \<in> B\<close>\<close>
   203 (* a:A, a:B *)
   179   apply simp
   204 apply simp
   180   apply (rule Forall_Conc_impl [THEN mp])
   205 apply (rule Forall_Conc_impl [THEN mp])
   181   apply (simp add: intA_is_not_actB int_is_act)
   206 apply (simp add: intA_is_not_actB int_is_act)
   182   apply (rule Forall_Conc_impl [THEN mp])
   207 apply (rule Forall_Conc_impl [THEN mp])
   183   apply (simp add: intA_is_not_actB int_is_act)
   208 apply (simp add: intA_is_not_actB int_is_act)
   184   text \<open>\<open>a \<in> A\<close>, \<open>a \<notin> B\<close>\<close>
   209 (* a:A,a~:B *)
   185   apply simp
   210 apply simp
   186   apply (rule Forall_Conc_impl [THEN mp])
   211 apply (rule Forall_Conc_impl [THEN mp])
   187   apply (simp add: intA_is_not_actB int_is_act)
   212 apply (simp add: intA_is_not_actB int_is_act)
   188   apply (case_tac "a:act B")
   213 apply (case_tac "a:act B")
   189   text \<open>\<open>a \<notin> A\<close>, \<open>a \<in> B\<close>\<close>
   214 (* a~:A, a:B *)
   190   apply simp
   215 apply simp
   191   apply (rule Forall_Conc_impl [THEN mp])
   216 apply (rule Forall_Conc_impl [THEN mp])
   192   apply (simp add: intA_is_not_actB int_is_act)
   217 apply (simp add: intA_is_not_actB int_is_act)
   193   text \<open>\<open>a \<notin> A\<close>, \<open>a \<notin> B\<close>\<close>
   218 (* a~:A,a~:B *)
   194   apply auto
   219 apply auto
   195   done
   220 done
   196 
   221 
   197 lemma ForallBnAmksch [rule_format]:
   222 lemma ForallBnAmksch [rule_format (no_asm)]: "!!A B. compatible B A  ==>
   198   "compatible B A \<Longrightarrow>
   223     ! schA schB.  (Forall (%x. x:act B & x~:act A) tr
   199     \<forall>schA schB. Forall (\<lambda>x. x \<in> act B \<and> x \<notin> act A) tr \<longrightarrow>
   224     --> Forall (%x. x:act B & x~:act A) (mksch A B$tr$schA$schB))"
   200       Forall (\<lambda>x. x \<in> act B \<and> x \<notin> act A) (mksch A B $ tr $ schA $ schB)"
   225 apply (tactic \<open>Seq_induct_tac @{context} "tr"
   201   apply (tactic \<open>Seq_induct_tac @{context} "tr" @{thms Forall_def sforall_def mksch_def} 1\<close>)
   226   [@{thm Forall_def}, @{thm sforall_def}, @{thm mksch_def}] 1\<close>)
   202   apply auto
   227 apply auto
   203   apply (rule Forall_Conc_impl [THEN mp])
   228 apply (rule Forall_Conc_impl [THEN mp])
   204   apply (simp add: intA_is_not_actB int_is_act)
   229 apply (simp add: intA_is_not_actB int_is_act)
   205   done
   230 done
   206 
   231 
   207 lemma ForallAnBmksch [rule_format]:
   232 lemma ForallAnBmksch [rule_format (no_asm)]: "!!A B. compatible A B ==>
   208   "compatible A B \<Longrightarrow>
   233     ! schA schB.  (Forall (%x. x:act A & x~:act B) tr
   209     \<forall>schA schB. Forall (\<lambda>x. x \<in> act A \<and> x \<notin> act B) tr \<longrightarrow>
   234     --> Forall (%x. x:act A & x~:act B) (mksch A B$tr$schA$schB))"
   210       Forall (\<lambda>x. x \<in> act A \<and> x \<notin> act B) (mksch A B $ tr $ schA $ schB)"
   235 apply (tactic \<open>Seq_induct_tac @{context} "tr"
   211   apply (tactic \<open>Seq_induct_tac @{context} "tr" @{thms Forall_def sforall_def mksch_def} 1\<close>)
   236   [@{thm Forall_def}, @{thm sforall_def}, @{thm mksch_def}] 1\<close>)
   212   apply auto
   237 apply auto
   213   apply (rule Forall_Conc_impl [THEN mp])
   238 apply (rule Forall_Conc_impl [THEN mp])
   214   apply (simp add: intA_is_not_actB int_is_act)
   239 apply (simp add: intA_is_not_actB int_is_act)
   215   done
   240 done
   216 
   241 
   217 (* safe_tac makes too many case distinctions with this lemma in the next proof *)
   242 (* safe-tac makes too many case distinctions with this lemma in the next proof *)
       
   243 declare FiniteConc [simp del]
   218 declare FiniteConc [simp del]
   244 
   219 
   245 lemma FiniteL_mksch [rule_format (no_asm)]: "[| Finite tr; is_asig(asig_of A); is_asig(asig_of B) |] ==>
   220 lemma FiniteL_mksch [rule_format]:
   246     ! x y. Forall (%x. x:act A) x & Forall (%x. x:act B) y &
   221   "Finite tr \<Longrightarrow> is_asig (asig_of A) \<Longrightarrow> is_asig (asig_of B) \<Longrightarrow>
   247            Filter (%a. a:ext A)$x = Filter (%a. a:act A)$tr &
   222     \<forall>x y.
   248            Filter (%a. a:ext B)$y = Filter (%a. a:act B)$tr &
   223       Forall (\<lambda>x. x \<in> act A) x \<and> Forall (\<lambda>x. x \<in> act B) y \<and>
   249            Forall (%x. x:ext (A\<parallel>B)) tr
   224       Filter (\<lambda>a. a \<in> ext A) $ x = Filter (\<lambda>a. a \<in> act A) $ tr \<and>
   250            --> Finite (mksch A B$tr$x$y)"
   225       Filter (\<lambda>a. a \<in> ext B) $ y = Filter (\<lambda>a. a \<in> act B) $ tr \<and>
   251 
   226       Forall (\<lambda>x. x \<in> ext (A \<parallel> B)) tr \<longrightarrow> Finite (mksch A B $ tr $ x $ y)"
   252 apply (erule Seq_Finite_ind)
   227   apply (erule Seq_Finite_ind)
   253 apply simp
   228   apply simp
   254 (* main case *)
   229   text \<open>main case\<close>
   255 apply simp
   230   apply simp
   256 apply auto
   231   apply auto
   257 
   232 
   258 (* a: act A; a: act B *)
   233   text \<open>\<open>a \<in> act A\<close>; \<open>a \<in> act B\<close>\<close>
   259 apply (frule sym [THEN eq_imp_below, THEN divide_Seq])
   234   apply (frule sym [THEN eq_imp_below, THEN divide_Seq])
   260 apply (frule sym [THEN eq_imp_below, THEN divide_Seq])
   235   apply (frule sym [THEN eq_imp_below, THEN divide_Seq])
   261 back
   236   back
   262 apply (erule conjE)+
   237   apply (erule conjE)+
   263 (* Finite (tw iA x) and Finite (tw iB y) *)
   238   text \<open>\<open>Finite (tw iA x)\<close> and \<open>Finite (tw iB y)\<close>\<close>
   264 apply (simp add: not_ext_is_int_or_not_act FiniteConc)
   239   apply (simp add: not_ext_is_int_or_not_act FiniteConc)
   265 (* now for conclusion IH applicable, but assumptions have to be transformed *)
   240   text \<open>now for conclusion IH applicable, but assumptions have to be transformed\<close>
   266 apply (drule_tac x = "x" and g = "Filter (%a. a:act A) $s" in subst_lemma2)
   241   apply (drule_tac x = "x" and g = "Filter (\<lambda>a. a \<in> act A) $ s" in subst_lemma2)
   267 apply assumption
   242   apply assumption
   268 apply (drule_tac x = "y" and g = "Filter (%a. a:act B) $s" in subst_lemma2)
   243   apply (drule_tac x = "y" and g = "Filter (\<lambda>a. a \<in> act B) $ s" in subst_lemma2)
   269 apply assumption
   244   apply assumption
   270 (* IH *)
   245   text \<open>IH\<close>
   271 apply (simp add: not_ext_is_int_or_not_act ForallTL ForallDropwhile)
   246   apply (simp add: not_ext_is_int_or_not_act ForallTL ForallDropwhile)
   272 
   247 
   273 (* a: act B; a~: act A *)
   248   text \<open>\<open>a \<in> act B\<close>; \<open>a \<notin> act A\<close>\<close>
   274 apply (frule sym [THEN eq_imp_below, THEN divide_Seq])
   249   apply (frule sym [THEN eq_imp_below, THEN divide_Seq])
   275 
   250 
   276 apply (erule conjE)+
   251   apply (erule conjE)+
   277 (* Finite (tw iB y) *)
   252   text \<open>\<open>Finite (tw iB y)\<close>\<close>
   278 apply (simp add: not_ext_is_int_or_not_act FiniteConc)
   253   apply (simp add: not_ext_is_int_or_not_act FiniteConc)
   279 (* now for conclusion IH applicable, but assumptions have to be transformed *)
   254   text \<open>now for conclusion IH applicable, but assumptions have to be transformed\<close>
   280 apply (drule_tac x = "y" and g = "Filter (%a. a:act B) $s" in subst_lemma2)
   255   apply (drule_tac x = "y" and g = "Filter (\<lambda>a. a \<in> act B) $ s" in subst_lemma2)
   281 apply assumption
   256   apply assumption
   282 (* IH *)
   257   text \<open>IH\<close>
   283 apply (simp add: not_ext_is_int_or_not_act ForallTL ForallDropwhile)
   258   apply (simp add: not_ext_is_int_or_not_act ForallTL ForallDropwhile)
   284 
   259 
   285 (* a~: act B; a: act A *)
   260   text \<open>\<open>a \<notin> act B\<close>; \<open>a \<in> act A\<close>\<close>
   286 apply (frule sym [THEN eq_imp_below, THEN divide_Seq])
   261   apply (frule sym [THEN eq_imp_below, THEN divide_Seq])
   287 
   262 
   288 apply (erule conjE)+
   263   apply (erule conjE)+
   289 (* Finite (tw iA x) *)
   264   text \<open>\<open>Finite (tw iA x)\<close>\<close>
   290 apply (simp add: not_ext_is_int_or_not_act FiniteConc)
   265   apply (simp add: not_ext_is_int_or_not_act FiniteConc)
   291 (* now for conclusion IH applicable, but assumptions have to be transformed *)
   266   text \<open>now for conclusion IH applicable, but assumptions have to be transformed\<close>
   292 apply (drule_tac x = "x" and g = "Filter (%a. a:act A) $s" in subst_lemma2)
   267   apply (drule_tac x = "x" and g = "Filter (\<lambda>a. a \<in> act A) $ s" in subst_lemma2)
   293 apply assumption
   268   apply assumption
   294 (* IH *)
   269   text \<open>IH\<close>
   295 apply (simp add: not_ext_is_int_or_not_act ForallTL ForallDropwhile)
   270   apply (simp add: not_ext_is_int_or_not_act ForallTL ForallDropwhile)
   296 
   271 
   297 (* a~: act B; a~: act A *)
   272   text \<open>\<open>a \<notin> act B\<close>; \<open>a \<notin> act A\<close>\<close>
   298 apply (fastforce intro!: ext_is_act simp: externals_of_par)
   273   apply (fastforce intro!: ext_is_act simp: externals_of_par)
   299 done
   274   done
   300 
   275 
   301 declare FiniteConc [simp]
   276 declare FiniteConc [simp]
   302 
   277 
   303 declare FilterConc [simp del]
   278 declare FilterConc [simp del]
   304 
   279 
   305 lemma reduceA_mksch1 [rule_format (no_asm)]: " [| Finite bs; is_asig(asig_of A); is_asig(asig_of B);compatible A B|] ==>
   280 lemma reduceA_mksch1 [rule_format]:
   306  ! y. Forall (%x. x:act B) y & Forall (%x. x:act B & x~:act A) bs &
   281   "Finite bs \<Longrightarrow> is_asig (asig_of A) \<Longrightarrow> is_asig (asig_of B) \<Longrightarrow> compatible A B \<Longrightarrow>
   307      Filter (%a. a:ext B)$y = Filter (%a. a:act B)$(bs @@ z)
   282     \<forall>y. Forall (\<lambda>x. x \<in> act B) y \<and> Forall (\<lambda>x. x \<in> act B \<and> x \<notin> act A) bs \<and>
   308      --> (? y1 y2.  (mksch A B$(bs @@ z)$x$y) = (y1 @@ (mksch A B$z$x$y2)) &
   283       Filter (\<lambda>a. a \<in> ext B) $ y = Filter (\<lambda>a. a \<in> act B) $ (bs @@ z) \<longrightarrow>
   309                     Forall (%x. x:act B & x~:act A) y1 &
   284       (\<exists>y1 y2.
   310                     Finite y1 & y = (y1 @@ y2) &
   285         (mksch A B $ (bs @@ z) $ x $ y) = (y1 @@ (mksch A B $ z $ x $ y2)) \<and>
   311                     Filter (%a. a:ext B)$y1 = bs)"
   286         Forall (\<lambda>x. x \<in> act B \<and> x \<notin> act A) y1 \<and>
   312 apply (frule_tac A1 = "A" in compat_commute [THEN iffD1])
   287         Finite y1 \<and> y = (y1 @@ y2) \<and>
   313 apply (erule Seq_Finite_ind)
   288         Filter (\<lambda>a. a \<in> ext B) $ y1 = bs)"
   314 apply (rule allI)+
   289   apply (frule_tac A1 = "A" in compat_commute [THEN iffD1])
   315 apply (rule impI)
   290   apply (erule Seq_Finite_ind)
   316 apply (rule_tac x = "nil" in exI)
   291   apply (rule allI)+
   317 apply (rule_tac x = "y" in exI)
   292   apply (rule impI)
   318 apply simp
   293   apply (rule_tac x = "nil" in exI)
   319 (* main case *)
   294   apply (rule_tac x = "y" in exI)
   320 apply (rule allI)+
   295   apply simp
   321 apply (rule impI)
   296   text \<open>main case\<close>
   322 apply simp
   297   apply (rule allI)+
   323 apply (erule conjE)+
   298   apply (rule impI)
   324 apply simp
   299   apply simp
   325 (* divide_Seq on s *)
   300   apply (erule conjE)+
   326 apply (frule sym [THEN eq_imp_below, THEN divide_Seq])
   301   apply simp
   327 apply (erule conjE)+
   302   text \<open>\<open>divide_Seq\<close> on \<open>s\<close>\<close>
   328 (* transform assumption f eB y = f B (s@z) *)
   303   apply (frule sym [THEN eq_imp_below, THEN divide_Seq])
   329 apply (drule_tac x = "y" and g = "Filter (%a. a:act B) $ (s@@z) " in subst_lemma2)
   304   apply (erule conjE)+
   330 apply assumption
   305   text \<open>transform assumption \<open>f eB y = f B (s @ z)\<close>\<close>
   331 apply (simp add: not_ext_is_int_or_not_act FilterConc)
   306   apply (drule_tac x = "y" and g = "Filter (\<lambda>a. a \<in> act B) $ (s @@ z) " in subst_lemma2)
   332 (* apply IH *)
   307   apply assumption
   333 apply (erule_tac x = "TL$ (Dropwhile (%a. a:int B) $y) " in allE)
   308   apply (simp add: not_ext_is_int_or_not_act FilterConc)
   334 apply (simp add: ForallTL ForallDropwhile FilterConc)
   309   text \<open>apply IH\<close>
   335 apply (erule exE)+
   310   apply (erule_tac x = "TL $ (Dropwhile (\<lambda>a. a \<in> int B) $ y)" in allE)
   336 apply (erule conjE)+
   311   apply (simp add: ForallTL ForallDropwhile FilterConc)
   337 apply (simp add: FilterConc)
   312   apply (erule exE)+
   338 (* for replacing IH in conclusion *)
   313   apply (erule conjE)+
   339 apply (rotate_tac -2)
   314   apply (simp add: FilterConc)
   340 (* instantiate y1a and y2a *)
   315   text \<open>for replacing IH in conclusion\<close>
   341 apply (rule_tac x = "Takewhile (%a. a:int B) $y @@ a\<leadsto>y1" in exI)
   316   apply (rotate_tac -2)
   342 apply (rule_tac x = "y2" in exI)
   317   text \<open>instantiate \<open>y1a\<close> and \<open>y2a\<close>\<close>
   343 (* elminate all obligations up to two depending on Conc_assoc *)
   318   apply (rule_tac x = "Takewhile (\<lambda>a. a \<in> int B) $ y @@ a \<leadsto> y1" in exI)
   344 apply (simp add: intA_is_not_actB int_is_act int_is_not_ext FilterConc)
   319   apply (rule_tac x = "y2" in exI)
   345 apply (simp (no_asm) add: Conc_assoc FilterConc)
   320   text \<open>elminate all obligations up to two depending on \<open>Conc_assoc\<close>\<close>
   346 done
   321   apply (simp add: intA_is_not_actB int_is_act int_is_not_ext FilterConc)
       
   322   apply (simp add: Conc_assoc FilterConc)
       
   323   done
   347 
   324 
   348 lemmas reduceA_mksch = conjI [THEN [6] conjI [THEN [5] reduceA_mksch1]]
   325 lemmas reduceA_mksch = conjI [THEN [6] conjI [THEN [5] reduceA_mksch1]]
   349 
   326 
   350 lemma reduceB_mksch1 [rule_format]:
   327 lemma reduceB_mksch1 [rule_format]:
   351 " [| Finite a_s; is_asig(asig_of A); is_asig(asig_of B);compatible A B|] ==>
   328   "Finite a_s \<Longrightarrow> is_asig (asig_of A) \<Longrightarrow> is_asig (asig_of B) \<Longrightarrow> compatible A B \<Longrightarrow>
   352  ! x. Forall (%x. x:act A) x & Forall (%x. x:act A & x~:act B) a_s &
   329     \<forall>x. Forall (\<lambda>x. x \<in> act A) x \<and> Forall (\<lambda>x. x \<in> act A \<and> x \<notin> act B) a_s \<and>
   353      Filter (%a. a:ext A)$x = Filter (%a. a:act A)$(a_s @@ z)
   330       Filter (\<lambda>a. a \<in> ext A) $ x = Filter (\<lambda>a. a \<in> act A) $ (a_s @@ z) \<longrightarrow>
   354      --> (? x1 x2.  (mksch A B$(a_s @@ z)$x$y) = (x1 @@ (mksch A B$z$x2$y)) &
   331       (\<exists>x1 x2.
   355                     Forall (%x. x:act A & x~:act B) x1 &
   332         (mksch A B $ (a_s @@ z) $ x $ y) = (x1 @@ (mksch A B $ z $ x2 $ y)) \<and>
   356                     Finite x1 & x = (x1 @@ x2) &
   333         Forall (\<lambda>x. x \<in> act A \<and> x \<notin> act B) x1 \<and>
   357                     Filter (%a. a:ext A)$x1 = a_s)"
   334         Finite x1 \<and> x = (x1 @@ x2) \<and>
   358 apply (frule_tac A1 = "A" in compat_commute [THEN iffD1])
   335         Filter (\<lambda>a. a \<in> ext A) $ x1 = a_s)"
   359 apply (erule Seq_Finite_ind)
   336   apply (frule_tac A1 = "A" in compat_commute [THEN iffD1])
   360 apply (rule allI)+
   337   apply (erule Seq_Finite_ind)
   361 apply (rule impI)
   338   apply (rule allI)+
   362 apply (rule_tac x = "nil" in exI)
   339   apply (rule impI)
   363 apply (rule_tac x = "x" in exI)
   340   apply (rule_tac x = "nil" in exI)
   364 apply simp
   341   apply (rule_tac x = "x" in exI)
   365 (* main case *)
   342   apply simp
   366 apply (rule allI)+
   343   text \<open>main case\<close>
   367 apply (rule impI)
   344   apply (rule allI)+
   368 apply simp
   345   apply (rule impI)
   369 apply (erule conjE)+
   346   apply simp
   370 apply simp
   347   apply (erule conjE)+
   371 (* divide_Seq on s *)
   348   apply simp
   372 apply (frule sym [THEN eq_imp_below, THEN divide_Seq])
   349   text \<open>\<open>divide_Seq\<close> on \<open>s\<close>\<close>
   373 apply (erule conjE)+
   350   apply (frule sym [THEN eq_imp_below, THEN divide_Seq])
   374 (* transform assumption f eA x = f A (s@z) *)
   351   apply (erule conjE)+
   375 apply (drule_tac x = "x" and g = "Filter (%a. a:act A) $ (s@@z) " in subst_lemma2)
   352   text \<open>transform assumption \<open>f eA x = f A (s @ z)\<close>\<close>
   376 apply assumption
   353   apply (drule_tac x = "x" and g = "Filter (\<lambda>a. a \<in> act A) $ (s @@ z)" in subst_lemma2)
   377 apply (simp add: not_ext_is_int_or_not_act FilterConc)
   354   apply assumption
   378 (* apply IH *)
   355   apply (simp add: not_ext_is_int_or_not_act FilterConc)
   379 apply (erule_tac x = "TL$ (Dropwhile (%a. a:int A) $x) " in allE)
   356   text \<open>apply IH\<close>
   380 apply (simp add: ForallTL ForallDropwhile FilterConc)
   357   apply (erule_tac x = "TL $ (Dropwhile (\<lambda>a. a \<in> int A) $ x)" in allE)
   381 apply (erule exE)+
   358   apply (simp add: ForallTL ForallDropwhile FilterConc)
   382 apply (erule conjE)+
   359   apply (erule exE)+
   383 apply (simp add: FilterConc)
   360   apply (erule conjE)+
   384 (* for replacing IH in conclusion *)
   361   apply (simp add: FilterConc)
   385 apply (rotate_tac -2)
   362   text \<open>for replacing IH in conclusion\<close>
   386 (* instantiate y1a and y2a *)
   363   apply (rotate_tac -2)
   387 apply (rule_tac x = "Takewhile (%a. a:int A) $x @@ a\<leadsto>x1" in exI)
   364   text \<open>instantiate \<open>y1a\<close> and \<open>y2a\<close>\<close>
   388 apply (rule_tac x = "x2" in exI)
   365   apply (rule_tac x = "Takewhile (\<lambda>a. a \<in> int A) $ x @@ a \<leadsto> x1" in exI)
   389 (* elminate all obligations up to two depending on Conc_assoc *)
   366   apply (rule_tac x = "x2" in exI)
   390 apply (simp add: intA_is_not_actB int_is_act int_is_not_ext FilterConc)
   367   text \<open>eliminate all obligations up to two depending on \<open>Conc_assoc\<close>\<close>
   391 apply (simp (no_asm) add: Conc_assoc FilterConc)
   368   apply (simp add: intA_is_not_actB int_is_act int_is_not_ext FilterConc)
   392 done
   369   apply (simp add: Conc_assoc FilterConc)
       
   370   done
   393 
   371 
   394 lemmas reduceB_mksch = conjI [THEN [6] conjI [THEN [5] reduceB_mksch1]]
   372 lemmas reduceB_mksch = conjI [THEN [6] conjI [THEN [5] reduceB_mksch1]]
   395 
   373 
   396 declare FilterConc [simp]
   374 declare FilterConc [simp]
   397 
   375 
   398 
   376 
   399 subsection "Filtering external actions out of mksch(tr,schA,schB) yields the oracle tr"
   377 subsection \<open>Filtering external actions out of \<open>mksch (tr, schA, schB)\<close> yields the oracle \<open>tr\<close>\<close>
   400 
   378 
   401 lemma FilterA_mksch_is_tr:
   379 lemma FilterA_mksch_is_tr:
   402 "!! A B. [| compatible A B; compatible B A;
   380   "compatible A B \<Longrightarrow> compatible B A \<Longrightarrow> is_asig (asig_of A) \<Longrightarrow> is_asig (asig_of B) \<Longrightarrow>
   403             is_asig(asig_of A); is_asig(asig_of B) |] ==>
   381     \<forall>schA schB.
   404   ! schA schB. Forall (%x. x:act A) schA & Forall (%x. x:act B) schB &
   382       Forall (\<lambda>x. x \<in> act A) schA \<and>
   405   Forall (%x. x:ext (A\<parallel>B)) tr &
   383       Forall (\<lambda>x. x \<in> act B) schB \<and>
   406   Filter (%a. a:act A)$tr << Filter (%a. a:ext A)$schA &
   384       Forall (\<lambda>x. x \<in> ext (A \<parallel> B)) tr \<and>
   407   Filter (%a. a:act B)$tr << Filter (%a. a:ext B)$schB
   385       Filter (\<lambda>a. a \<in> act A) $ tr \<sqsubseteq> Filter (\<lambda>a. a \<in> ext A) $ schA \<and>
   408   --> Filter (%a. a:ext (A\<parallel>B))$(mksch A B$tr$schA$schB) = tr"
   386       Filter (\<lambda>a. a \<in> act B) $ tr \<sqsubseteq> Filter (\<lambda>a. a \<in> ext B) $ schB
   409 
   387       \<longrightarrow> Filter (\<lambda>a. a \<in> ext (A \<parallel> B)) $ (mksch A B $ tr $ schA $ schB) = tr"
   410 apply (tactic \<open>Seq_induct_tac @{context} "tr"
   388   apply (tactic \<open>Seq_induct_tac @{context} "tr" @{thms Forall_def sforall_def mksch_def} 1\<close>)
   411   [@{thm Forall_def}, @{thm sforall_def}, @{thm mksch_def}] 1\<close>)
   389   text \<open>main case\<close>
   412 (* main case *)
   390   text \<open>splitting into 4 cases according to \<open>a \<in> A\<close>, \<open>a \<in> B\<close>\<close>
   413 (* splitting into 4 cases according to a:A, a:B *)
   391   apply auto
   414 apply auto
   392 
   415 
   393   text \<open>Case \<open>a \<in> A\<close>, \<open>a \<in> B\<close>\<close>
   416 (* Case a:A, a:B *)
   394   apply (frule divide_Seq)
   417 apply (frule divide_Seq)
   395   apply (frule divide_Seq)
   418 apply (frule divide_Seq)
   396   back
   419 back
   397   apply (erule conjE)+
   420 apply (erule conjE)+
   398   text \<open>filtering internals of \<open>A\<close> in \<open>schA\<close> and of \<open>B\<close> in \<open>schB\<close> is \<open>nil\<close>\<close>
   421 (* filtering internals of A in schA and of B in schB is nil *)
   399   apply (simp add: not_ext_is_int_or_not_act externals_of_par intA_is_not_extB int_is_not_ext)
   422 apply (simp add: not_ext_is_int_or_not_act externals_of_par intA_is_not_extB int_is_not_ext)
   400   text \<open>conclusion of IH ok, but assumptions of IH have to be transformed\<close>
   423 (* conclusion of IH ok, but assumptions of IH have to be transformed *)
   401   apply (drule_tac x = "schA" in subst_lemma1)
   424 apply (drule_tac x = "schA" in subst_lemma1)
   402   apply assumption
   425 apply assumption
   403   apply (drule_tac x = "schB" in subst_lemma1)
   426 apply (drule_tac x = "schB" in subst_lemma1)
   404   apply assumption
   427 apply assumption
   405   text \<open>IH\<close>
   428 (* IH *)
   406   apply (simp add: not_ext_is_int_or_not_act ForallTL ForallDropwhile)
   429 apply (simp add: not_ext_is_int_or_not_act ForallTL ForallDropwhile)
   407 
   430 
   408   text \<open>Case \<open>a \<in> A\<close>, \<open>a \<notin> B\<close>\<close>
   431 (* Case a:A, a~:B *)
   409   apply (frule divide_Seq)
   432 apply (frule divide_Seq)
   410   apply (erule conjE)+
   433 apply (erule conjE)+
   411   text \<open>filtering internals of \<open>A\<close> is \<open>nil\<close>\<close>
   434 (* filtering internals of A is nil *)
   412   apply (simp add: not_ext_is_int_or_not_act externals_of_par intA_is_not_extB int_is_not_ext)
   435 apply (simp add: not_ext_is_int_or_not_act externals_of_par intA_is_not_extB int_is_not_ext)
   413   apply (drule_tac x = "schA" in subst_lemma1)
   436 apply (drule_tac x = "schA" in subst_lemma1)
   414   apply assumption
   437 apply assumption
   415   apply (simp add: not_ext_is_int_or_not_act ForallTL ForallDropwhile)
   438 apply (simp add: not_ext_is_int_or_not_act ForallTL ForallDropwhile)
   416 
   439 
   417   text \<open>Case \<open>a \<in> B\<close>, \<open>a \<notin> A\<close>\<close>
   440 (* Case a:B, a~:A *)
   418   apply (frule divide_Seq)
   441 apply (frule divide_Seq)
   419   apply (erule conjE)+
   442 apply (erule conjE)+
   420   text \<open>filtering internals of \<open>A\<close> is \<open>nil\<close>\<close>
   443 (* filtering internals of A is nil *)
   421   apply (simp add: not_ext_is_int_or_not_act externals_of_par intA_is_not_extB int_is_not_ext)
   444 apply (simp add: not_ext_is_int_or_not_act externals_of_par intA_is_not_extB int_is_not_ext)
   422   apply (drule_tac x = "schB" in subst_lemma1)
   445 apply (drule_tac x = "schB" in subst_lemma1)
   423   back
   446 back
   424   apply assumption
   447 apply assumption
   425   apply (simp add: not_ext_is_int_or_not_act ForallTL ForallDropwhile)
   448 apply (simp add: not_ext_is_int_or_not_act ForallTL ForallDropwhile)
   426 
   449 
   427   text \<open>Case \<open>a \<notin> A\<close>, \<open>a \<notin> B\<close>\<close>
   450 (* Case a~:A, a~:B *)
   428   apply (fastforce intro!: ext_is_act simp: externals_of_par)
   451 apply (fastforce intro!: ext_is_act simp: externals_of_par)
   429   done
   452 done
       
   453 
   430 
   454 
   431 
   455 subsection" Filter of mksch(tr,schA,schB) to A is schA -- take lemma proof"
   432 subsection" Filter of mksch(tr,schA,schB) to A is schA -- take lemma proof"
   456 
   433 
   457 lemma FilterAmksch_is_schA: "!! A B. [| compatible A B; compatible B A;
   434 lemma FilterAmksch_is_schA:
   458   is_asig(asig_of A); is_asig(asig_of B) |] ==>
   435   "compatible A B \<Longrightarrow> compatible B A \<Longrightarrow> is_asig (asig_of A) \<Longrightarrow> is_asig (asig_of B) \<Longrightarrow>
   459   Forall (%x. x:ext (A\<parallel>B)) tr &
   436     Forall (\<lambda>x. x \<in> ext (A \<parallel> B)) tr \<and>
   460   Forall (%x. x:act A) schA & Forall (%x. x:act B) schB &
   437     Forall (\<lambda>x. x \<in> act A) schA \<and>
   461   Filter (%a. a:ext A)$schA = Filter (%a. a:act A)$tr &
   438     Forall (\<lambda>x. x \<in> act B) schB \<and>
   462   Filter (%a. a:ext B)$schB = Filter (%a. a:act B)$tr &
   439     Filter (\<lambda>a. a \<in> ext A) $ schA = Filter (\<lambda>a. a \<in> act A) $ tr \<and>
   463   LastActExtsch A schA & LastActExtsch B schB
   440     Filter (\<lambda>a. a \<in> ext B) $ schB = Filter (\<lambda>a. a \<in> act B) $ tr \<and>
   464   --> Filter (%a. a:act A)$(mksch A B$tr$schA$schB) = schA"
   441     LastActExtsch A schA \<and> LastActExtsch B schB
   465 apply (intro strip)
   442     \<longrightarrow> Filter (\<lambda>a. a \<in> act A) $ (mksch A B $ tr $ schA $ schB) = schA"
   466 apply (rule seq.take_lemma)
   443   apply (intro strip)
   467 apply (rule mp)
   444   apply (rule seq.take_lemma)
   468 prefer 2 apply assumption
   445   apply (rule mp)
   469 back back back back
   446   prefer 2 apply assumption
   470 apply (rule_tac x = "schA" in spec)
   447   back back back back
   471 apply (rule_tac x = "schB" in spec)
   448   apply (rule_tac x = "schA" in spec)
   472 apply (rule_tac x = "tr" in spec)
   449   apply (rule_tac x = "schB" in spec)
   473 apply (tactic "thin_tac' @{context} 5 1")
   450   apply (rule_tac x = "tr" in spec)
   474 apply (rule nat_less_induct)
   451   apply (tactic "thin_tac' @{context} 5 1")
   475 apply (rule allI)+
   452   apply (rule nat_less_induct)
   476 apply (rename_tac tr schB schA)
   453   apply (rule allI)+
   477 apply (intro strip)
   454   apply (rename_tac tr schB schA)
   478 apply (erule conjE)+
   455   apply (intro strip)
   479 
   456   apply (erule conjE)+
   480 apply (case_tac "Forall (%x. x:act B & x~:act A) tr")
   457 
   481 
   458   apply (case_tac "Forall (\<lambda>x. x \<in> act B \<and> x \<notin> act A) tr")
   482 apply (rule seq_take_lemma [THEN iffD2, THEN spec])
   459 
   483 apply (tactic "thin_tac' @{context} 5 1")
   460   apply (rule seq_take_lemma [THEN iffD2, THEN spec])
   484 
   461   apply (tactic "thin_tac' @{context} 5 1")
   485 
   462 
   486 apply (case_tac "Finite tr")
   463 
   487 
   464   apply (case_tac "Finite tr")
   488 (* both sides of this equation are nil *)
   465 
   489 apply (subgoal_tac "schA=nil")
   466   text \<open>both sides of this equation are \<open>nil\<close>\<close>
   490 apply (simp (no_asm_simp))
   467   apply (subgoal_tac "schA = nil")
   491 (* first side: mksch = nil *)
   468   apply simp
   492 apply (auto intro!: ForallQFilterPnil ForallBnAmksch FiniteL_mksch)[1]
   469   text \<open>first side: \<open>mksch = nil\<close>\<close>
   493 (* second side: schA = nil *)
   470   apply (auto intro!: ForallQFilterPnil ForallBnAmksch FiniteL_mksch)[1]
   494 apply (erule_tac A = "A" in LastActExtimplnil)
   471   text \<open>second side: \<open>schA = nil\<close>\<close>
   495 apply (simp (no_asm_simp))
   472   apply (erule_tac A = "A" in LastActExtimplnil)
   496 apply (erule_tac Q = "%x. x:act B & x~:act A" in ForallQFilterPnil)
   473   apply simp
   497 apply assumption
   474   apply (erule_tac Q = "\<lambda>x. x \<in> act B \<and> x \<notin> act A" in ForallQFilterPnil)
   498 apply fast
   475   apply assumption
   499 
   476   apply fast
   500 (* case ~ Finite s *)
   477 
   501 
   478   text \<open>case \<open>\<not> Finite s\<close>\<close>
   502 (* both sides of this equation are UU *)
   479 
   503 apply (subgoal_tac "schA=UU")
   480   text \<open>both sides of this equation are \<open>UU\<close>\<close>
   504 apply (simp (no_asm_simp))
   481   apply (subgoal_tac "schA = UU")
   505 (* first side: mksch = UU *)
   482   apply simp
   506 apply (auto intro!: ForallQFilterPUU finiteR_mksch' ForallBnAmksch)[1]
   483   text \<open>first side: \<open>mksch = UU\<close>\<close>
   507 (* schA = UU *)
   484   apply (auto intro!: ForallQFilterPUU finiteR_mksch' ForallBnAmksch)[1]
   508 apply (erule_tac A = "A" in LastActExtimplUU)
   485   text \<open>\<open>schA = UU\<close>\<close>
   509 apply (simp (no_asm_simp))
   486   apply (erule_tac A = "A" in LastActExtimplUU)
   510 apply (erule_tac Q = "%x. x:act B & x~:act A" in ForallQFilterPUU)
   487   apply simp
   511 apply assumption
   488   apply (erule_tac Q = "\<lambda>x. x \<in> act B \<and> x \<notin> act A" in ForallQFilterPUU)
   512 apply fast
   489   apply assumption
   513 
   490   apply fast
   514 (* case" ~ Forall (%x.x:act B & x~:act A) s" *)
   491 
   515 
   492   text \<open>case \<open>\<not> Forall (\<lambda>x. x \<in> act B \<and> x \<notin> act A) s\<close>\<close>
   516 apply (drule divide_Seq3)
   493 
   517 
   494   apply (drule divide_Seq3)
   518 apply (erule exE)+
   495 
   519 apply (erule conjE)+
   496   apply (erule exE)+
   520 apply hypsubst
   497   apply (erule conjE)+
   521 
   498   apply hypsubst
   522 (* bring in lemma reduceA_mksch *)
   499 
   523 apply (frule_tac x = "schA" and y = "schB" and A = "A" and B = "B" in reduceA_mksch)
   500   text \<open>bring in lemma \<open>reduceA_mksch\<close>\<close>
   524 apply assumption+
   501   apply (frule_tac x = "schA" and y = "schB" and A = "A" and B = "B" in reduceA_mksch)
   525 apply (erule exE)+
   502   apply assumption+
   526 apply (erule conjE)+
   503   apply (erule exE)+
   527 
   504   apply (erule conjE)+
   528 (* use reduceA_mksch to rewrite conclusion *)
   505 
   529 apply hypsubst
   506   text \<open>use \<open>reduceA_mksch\<close> to rewrite conclusion\<close>
   530 apply simp
   507   apply hypsubst
   531 
   508   apply simp
   532 (* eliminate the B-only prefix *)
   509 
   533 
   510   text \<open>eliminate the \<open>B\<close>-only prefix\<close>
   534 apply (subgoal_tac " (Filter (%a. a :act A) $y1) = nil")
   511 
   535 apply (erule_tac [2] ForallQFilterPnil)
   512   apply (subgoal_tac "(Filter (\<lambda>a. a \<in> act A) $ y1) = nil")
   536 prefer 2 apply assumption
   513   apply (erule_tac [2] ForallQFilterPnil)
   537 prefer 2 apply fast
   514   prefer 2 apply assumption
   538 
   515   prefer 2 apply fast
   539 (* Now real recursive step follows (in y) *)
   516 
   540 
   517   text \<open>Now real recursive step follows (in \<open>y\<close>)\<close>
   541 apply simp
   518 
   542 apply (case_tac "x:act A")
   519   apply simp
   543 apply (case_tac "x~:act B")
   520   apply (case_tac "x \<in> act A")
   544 apply (rotate_tac -2)
   521   apply (case_tac "x \<notin> act B")
   545 apply simp
   522   apply (rotate_tac -2)
   546 
   523   apply simp
   547 apply (subgoal_tac "Filter (%a. a:act A & a:ext B) $y1=nil")
   524 
   548 apply (rotate_tac -1)
   525   apply (subgoal_tac "Filter (\<lambda>a. a \<in> act A \<and> a \<in> ext B) $ y1 = nil")
   549 apply simp
   526   apply (rotate_tac -1)
   550 (* eliminate introduced subgoal 2 *)
   527   apply simp
   551 apply (erule_tac [2] ForallQFilterPnil)
   528   text \<open>eliminate introduced subgoal 2\<close>
   552 prefer 2 apply assumption
   529   apply (erule_tac [2] ForallQFilterPnil)
   553 prefer 2 apply fast
   530   prefer 2 apply assumption
   554 
   531   prefer 2 apply fast
   555 (* bring in divide Seq for s *)
   532 
   556 apply (frule sym [THEN eq_imp_below, THEN divide_Seq])
   533   text \<open>bring in \<open>divide_Seq\<close> for \<open>s\<close>\<close>
   557 apply (erule conjE)+
   534   apply (frule sym [THEN eq_imp_below, THEN divide_Seq])
   558 
   535   apply (erule conjE)+
   559 (* subst divide_Seq in conclusion, but only at the righest occurrence *)
   536 
   560 apply (rule_tac t = "schA" in ssubst)
   537   text \<open>subst \<open>divide_Seq\<close> in conclusion, but only at the rightest occurrence\<close>
   561 back
   538   apply (rule_tac t = "schA" in ssubst)
   562 back
   539   back
   563 back
   540   back
   564 apply assumption
   541   back
   565 
   542   apply assumption
   566 (* reduce trace_takes from n to strictly smaller k *)
   543 
   567 apply (rule take_reduction)
   544   text \<open>reduce trace_takes from \<open>n\<close> to strictly smaller \<open>k\<close>\<close>
   568 
   545   apply (rule take_reduction)
   569 (* f A (tw iA) = tw ~eA *)
   546 
   570 apply (simp add: int_is_act not_ext_is_int_or_not_act)
   547   text \<open>\<open>f A (tw iA) = tw \<not> eA\<close>\<close>
   571 apply (rule refl)
   548   apply (simp add: int_is_act not_ext_is_int_or_not_act)
   572 apply (simp add: int_is_act not_ext_is_int_or_not_act)
   549   apply (rule refl)
   573 apply (rotate_tac -11)
   550   apply (simp add: int_is_act not_ext_is_int_or_not_act)
   574 
   551   apply (rotate_tac -11)
   575 (* now conclusion fulfills induction hypothesis, but assumptions are not ready *)
   552 
   576 
   553   text \<open>now conclusion fulfills induction hypothesis, but assumptions are not ready\<close>
   577 (* assumption Forall tr *)
   554 
   578 (* assumption schB *)
   555   text \<open>assumption \<open>Forall tr\<close>\<close>
   579 apply (simp add: ext_and_act)
   556   text \<open>assumption \<open>schB\<close>\<close>
   580 (* assumption schA *)
   557   apply (simp add: ext_and_act)
   581 apply (drule_tac x = "schA" and g = "Filter (%a. a:act A) $rs" in subst_lemma2)
   558   text \<open>assumption \<open>schA\<close>\<close>
   582 apply assumption
   559   apply (drule_tac x = "schA" and g = "Filter (\<lambda>a. a \<in> act A) $ rs" in subst_lemma2)
   583 apply (simp add: int_is_not_ext)
   560   apply assumption
   584 (* assumptions concerning LastActExtsch, cannot be rewritten, as LastActExtsmalli are looping  *)
   561   apply (simp add: int_is_not_ext)
   585 apply (drule_tac sch = "schA" and P = "%a. a:int A" in LastActExtsmall1)
   562   text \<open>assumptions concerning \<open>LastActExtsch\<close>, cannot be rewritten, as \<open>LastActExtsmalli\<close> are looping\<close>
   586 apply (frule_tac ?sch1.0 = "y1" in LastActExtsmall2)
   563   apply (drule_tac sch = "schA" and P = "\<lambda>a. a \<in> int A" in LastActExtsmall1)
   587 apply assumption
   564   apply (frule_tac ?sch1.0 = "y1" in LastActExtsmall2)
   588 
   565   apply assumption
   589 (* assumption Forall schA *)
   566 
   590 apply (drule_tac s = "schA" and P = "Forall (%x. x:act A) " in subst)
   567   text \<open>assumption \<open>Forall schA\<close>\<close>
   591 apply assumption
   568   apply (drule_tac s = "schA" and P = "Forall (\<lambda>x. x \<in> act A) " in subst)
   592 apply (simp add: int_is_act)
   569   apply assumption
   593 
   570   apply (simp add: int_is_act)
   594 (* case x:actions(asig_of A) & x: actions(asig_of B) *)
   571 
   595 
   572   text \<open>case \<open>x \<in> actions (asig_of A) \<and> x \<in> actions (asig_of B)\<close>\<close>
   596 
   573 
   597 apply (rotate_tac -2)
   574   apply (rotate_tac -2)
   598 apply simp
   575   apply simp
   599 
   576 
   600 apply (subgoal_tac "Filter (%a. a:act A & a:ext B) $y1=nil")
   577   apply (subgoal_tac "Filter (\<lambda>a. a \<in> act A \<and> a \<in> ext B) $ y1 = nil")
   601 apply (rotate_tac -1)
   578   apply (rotate_tac -1)
   602 apply simp
   579   apply simp
   603 (* eliminate introduced subgoal 2 *)
   580   text \<open>eliminate introduced subgoal 2\<close>
   604 apply (erule_tac [2] ForallQFilterPnil)
   581   apply (erule_tac [2] ForallQFilterPnil)
   605 prefer 2 apply (assumption)
   582   prefer 2 apply assumption
   606 prefer 2 apply (fast)
   583   prefer 2 apply fast
   607 
   584 
   608 (* bring in divide Seq for s *)
   585   text \<open>bring in \<open>divide_Seq\<close> for \<open>s\<close>\<close>
   609 apply (frule sym [THEN eq_imp_below, THEN divide_Seq])
   586   apply (frule sym [THEN eq_imp_below, THEN divide_Seq])
   610 apply (erule conjE)+
   587   apply (erule conjE)+
   611 
   588 
   612 (* subst divide_Seq in conclusion, but only at the rightmost occurrence *)
   589   text \<open>subst \<open>divide_Seq\<close> in conclusion, but only at the rightmost occurrence\<close>
   613 apply (rule_tac t = "schA" in ssubst)
   590   apply (rule_tac t = "schA" in ssubst)
   614 back
   591   back
   615 back
   592   back
   616 back
   593   back
   617 apply assumption
   594   apply assumption
   618 
   595 
   619 (* f A (tw iA) = tw ~eA *)
   596   text \<open>\<open>f A (tw iA) = tw \<not> eA\<close>\<close>
   620 apply (simp add: int_is_act not_ext_is_int_or_not_act)
   597   apply (simp add: int_is_act not_ext_is_int_or_not_act)
   621 
   598 
   622 (* rewrite assumption forall and schB *)
   599   text \<open>rewrite assumption forall and \<open>schB\<close>\<close>
   623 apply (rotate_tac 13)
   600   apply (rotate_tac 13)
   624 apply (simp add: ext_and_act)
   601   apply (simp add: ext_and_act)
   625 
   602 
   626 (* divide_Seq for schB2 *)
   603   text \<open>\<open>divide_Seq\<close> for \<open>schB2\<close>\<close>
   627 apply (frule_tac y = "y2" in sym [THEN eq_imp_below, THEN divide_Seq])
   604   apply (frule_tac y = "y2" in sym [THEN eq_imp_below, THEN divide_Seq])
   628 apply (erule conjE)+
   605   apply (erule conjE)+
   629 (* assumption schA *)
   606   text \<open>assumption \<open>schA\<close>\<close>
   630 apply (drule_tac x = "schA" and g = "Filter (%a. a:act A) $rs" in subst_lemma2)
   607   apply (drule_tac x = "schA" and g = "Filter (%a. a:act A) $rs" in subst_lemma2)
   631 apply assumption
   608   apply assumption
   632 apply (simp add: int_is_not_ext)
   609   apply (simp add: int_is_not_ext)
   633 
   610 
   634 (* f A (tw iB schB2) = nil *)
   611   text \<open>\<open>f A (tw iB schB2) = nil\<close>\<close>
   635 apply (simp add: int_is_not_ext not_ext_is_int_or_not_act intA_is_not_actB)
   612   apply (simp add: int_is_not_ext not_ext_is_int_or_not_act intA_is_not_actB)
   636 
   613 
   637 
   614 
   638 (* reduce trace_takes from n to strictly smaller k *)
   615   text \<open>reduce trace_takes from \<open>n\<close> to strictly smaller \<open>k\<close>\<close>
   639 apply (rule take_reduction)
   616   apply (rule take_reduction)
   640 apply (rule refl)
   617   apply (rule refl)
   641 apply (rule refl)
   618   apply (rule refl)
   642 
   619 
   643 (* now conclusion fulfills induction hypothesis, but assumptions are not all ready *)
   620   text \<open>now conclusion fulfills induction hypothesis, but assumptions are not all ready\<close>
   644 
   621 
   645 (* assumption schB *)
   622   text \<open>assumption \<open>schB\<close>\<close>
   646 apply (drule_tac x = "y2" and g = "Filter (%a. a:act B) $rs" in subst_lemma2)
   623   apply (drule_tac x = "y2" and g = "Filter (\<lambda>a. a \<in> act B) $ rs" in subst_lemma2)
   647 apply assumption
   624   apply assumption
   648 apply (simp add: intA_is_not_actB int_is_not_ext)
   625   apply (simp add: intA_is_not_actB int_is_not_ext)
   649 
   626 
   650 (* conclusions concerning LastActExtsch, cannot be rewritten, as LastActExtsmalli are looping  *)
   627   text \<open>conclusions concerning \<open>LastActExtsch\<close>, cannot be rewritten, as \<open>LastActExtsmalli\<close> are looping\<close>
   651 apply (drule_tac sch = "schA" and P = "%a. a:int A" in LastActExtsmall1)
   628   apply (drule_tac sch = "schA" and P = "\<lambda>a. a \<in> int A" in LastActExtsmall1)
   652 apply (frule_tac ?sch1.0 = "y1" in LastActExtsmall2)
   629   apply (frule_tac ?sch1.0 = "y1" in LastActExtsmall2)
   653 apply assumption
   630   apply assumption
   654 apply (drule_tac sch = "y2" and P = "%a. a:int B" in LastActExtsmall1)
   631   apply (drule_tac sch = "y2" and P = "\<lambda>a. a \<in> int B" in LastActExtsmall1)
   655 
   632 
   656 (* assumption Forall schA, and Forall schA are performed by ForallTL,ForallDropwhile *)
   633   text \<open>assumption \<open>Forall schA\<close>, and \<open>Forall schA\<close> are performed by \<open>ForallTL\<close>, \<open>ForallDropwhile\<close>\<close>
   657 apply (simp add: ForallTL ForallDropwhile)
   634   apply (simp add: ForallTL ForallDropwhile)
   658 
   635 
   659 (* case x~:A & x:B  *)
   636   text \<open>case \<open>x \<notin> A \<and> x \<in> B\<close>\<close>
   660 (* cannot occur, as just this case has been scheduled out before as the B-only prefix *)
   637   text \<open>cannot occur, as just this case has been scheduled out before as the \<open>B\<close>-only prefix\<close>
   661 apply (case_tac "x:act B")
   638   apply (case_tac "x \<in> act B")
   662 apply fast
   639   apply fast
   663 
   640 
   664 (* case x~:A & x~:B  *)
   641   text \<open>case \<open>x \<notin> A \<and> x \<notin> B\<close>\<close>
   665 (* cannot occur because of assumption: Forall (a:ext A | a:ext B) *)
   642   text \<open>cannot occur because of assumption: \<open>Forall (a \<in> ext A \<or> a \<in> ext B)\<close>\<close>
   666 apply (rotate_tac -9)
   643   apply (rotate_tac -9)
   667 (* reduce forall assumption from tr to (x\<leadsto>rs) *)
   644   text \<open>reduce forall assumption from \<open>tr\<close> to \<open>x \<leadsto> rs\<close>\<close>
   668 apply (simp add: externals_of_par)
   645   apply (simp add: externals_of_par)
   669 apply (fast intro!: ext_is_act)
   646   apply (fast intro!: ext_is_act)
   670 
   647   done
   671 done
   648 
   672 
   649 
   673 
   650 subsection \<open>Filter of \<open>mksch (tr, schA, schB)\<close> to \<open>B\<close> is \<open>schB\<close> -- take lemma proof\<close>
   674 
   651 
   675 subsection" Filter of mksch(tr,schA,schB) to B is schB -- take lemma proof"
   652 lemma FilterBmksch_is_schB:
   676 
   653   "compatible A B \<Longrightarrow> compatible B A \<Longrightarrow> is_asig (asig_of A) \<Longrightarrow> is_asig (asig_of B) \<Longrightarrow>
   677 lemma FilterBmksch_is_schB: "!! A B. [| compatible A B; compatible B A;
   654     Forall (\<lambda>x. x \<in> ext (A \<parallel> B)) tr \<and>
   678   is_asig(asig_of A); is_asig(asig_of B) |] ==>
   655     Forall (\<lambda>x. x \<in> act A) schA \<and>
   679   Forall (%x. x:ext (A\<parallel>B)) tr &
   656     Forall (\<lambda>x. x \<in> act B) schB \<and>
   680   Forall (%x. x:act A) schA & Forall (%x. x:act B) schB &
   657     Filter (\<lambda>a. a \<in> ext A) $ schA = Filter (\<lambda>a. a \<in> act A) $ tr \<and>
   681   Filter (%a. a:ext A)$schA = Filter (%a. a:act A)$tr &
   658     Filter (\<lambda>a. a \<in> ext B) $ schB = Filter (\<lambda>a. a \<in> act B) $ tr \<and>
   682   Filter (%a. a:ext B)$schB = Filter (%a. a:act B)$tr &
   659     LastActExtsch A schA \<and> LastActExtsch B schB
   683   LastActExtsch A schA & LastActExtsch B schB
   660     \<longrightarrow> Filter (\<lambda>a. a \<in> act B) $ (mksch A B $ tr $ schA $ schB) = schB"
   684   --> Filter (%a. a:act B)$(mksch A B$tr$schA$schB) = schB"
   661   apply (intro strip)
   685 apply (intro strip)
   662   apply (rule seq.take_lemma)
   686 apply (rule seq.take_lemma)
   663   apply (rule mp)
   687 apply (rule mp)
   664   prefer 2 apply assumption
   688 prefer 2 apply assumption
   665   back back back back
   689 back back back back
   666   apply (rule_tac x = "schA" in spec)
   690 apply (rule_tac x = "schA" in spec)
   667   apply (rule_tac x = "schB" in spec)
   691 apply (rule_tac x = "schB" in spec)
   668   apply (rule_tac x = "tr" in spec)
   692 apply (rule_tac x = "tr" in spec)
   669   apply (tactic "thin_tac' @{context} 5 1")
   693 apply (tactic "thin_tac' @{context} 5 1")
   670   apply (rule nat_less_induct)
   694 apply (rule nat_less_induct)
   671   apply (rule allI)+
   695 apply (rule allI)+
   672   apply (rename_tac tr schB schA)
   696 apply (rename_tac tr schB schA)
   673   apply (intro strip)
   697 apply (intro strip)
   674   apply (erule conjE)+
   698 apply (erule conjE)+
   675 
   699 
   676   apply (case_tac "Forall (\<lambda>x. x \<in> act A \<and> x \<notin> act B) tr")
   700 apply (case_tac "Forall (%x. x:act A & x~:act B) tr")
   677 
   701 
   678   apply (rule seq_take_lemma [THEN iffD2, THEN spec])
   702 apply (rule seq_take_lemma [THEN iffD2, THEN spec])
   679   apply (tactic "thin_tac' @{context} 5 1")
   703 apply (tactic "thin_tac' @{context} 5 1")
   680 
   704 
   681   apply (case_tac "Finite tr")
   705 apply (case_tac "Finite tr")
   682 
   706 
   683   text \<open>both sides of this equation are \<open>nil\<close>\<close>
   707 (* both sides of this equation are nil *)
   684   apply (subgoal_tac "schB = nil")
   708 apply (subgoal_tac "schB=nil")
   685   apply simp
   709 apply (simp (no_asm_simp))
   686   text \<open>first side: \<open>mksch = nil\<close>\<close>
   710 (* first side: mksch = nil *)
   687   apply (auto intro!: ForallQFilterPnil ForallAnBmksch FiniteL_mksch)[1]
   711 apply (auto intro!: ForallQFilterPnil ForallAnBmksch FiniteL_mksch)[1]
   688   text \<open>second side: \<open>schA = nil\<close>\<close>
   712 (* second side: schA = nil *)
   689   apply (erule_tac A = "B" in LastActExtimplnil)
   713 apply (erule_tac A = "B" in LastActExtimplnil)
   690   apply (simp (no_asm_simp))
   714 apply (simp (no_asm_simp))
   691   apply (erule_tac Q = "\<lambda>x. x \<in> act A \<and> x \<notin> act B" in ForallQFilterPnil)
   715 apply (erule_tac Q = "%x. x:act A & x~:act B" in ForallQFilterPnil)
   692   apply assumption
   716 apply assumption
   693   apply fast
   717 apply fast
   694 
   718 
   695   text \<open>case \<open>\<not> Finite tr\<close>\<close>
   719 (* case ~ Finite tr *)
   696 
   720 
   697   text \<open>both sides of this equation are \<open>UU\<close>\<close>
   721 (* both sides of this equation are UU *)
   698   apply (subgoal_tac "schB = UU")
   722 apply (subgoal_tac "schB=UU")
   699   apply simp
   723 apply (simp (no_asm_simp))
   700   text \<open>first side: \<open>mksch = UU\<close>\<close>
   724 (* first side: mksch = UU *)
   701   apply (force intro!: ForallQFilterPUU finiteR_mksch' ForallAnBmksch)
   725 apply (force intro!: ForallQFilterPUU finiteR_mksch' ForallAnBmksch)
   702   text \<open>\<open>schA = UU\<close>\<close>
   726 (* schA = UU *)
   703   apply (erule_tac A = "B" in LastActExtimplUU)
   727 apply (erule_tac A = "B" in LastActExtimplUU)
   704   apply simp
   728 apply (simp (no_asm_simp))
   705   apply (erule_tac Q = "\<lambda>x. x \<in> act A \<and> x \<notin> act B" in ForallQFilterPUU)
   729 apply (erule_tac Q = "%x. x:act A & x~:act B" in ForallQFilterPUU)
   706   apply assumption
   730 apply assumption
   707   apply fast
   731 apply fast
   708 
   732 
   709   text \<open>case \<open>\<not> Forall (\<lambda>x. x \<in> act B \<and> x \<notin> act A) s\<close>\<close>
   733 (* case" ~ Forall (%x.x:act B & x~:act A) s" *)
   710 
   734 
   711   apply (drule divide_Seq3)
   735 apply (drule divide_Seq3)
   712 
   736 
   713   apply (erule exE)+
   737 apply (erule exE)+
   714   apply (erule conjE)+
   738 apply (erule conjE)+
   715   apply hypsubst
   739 apply hypsubst
   716 
   740 
   717   text \<open>bring in lemma \<open>reduceB_mksch\<close>\<close>
   741 (* bring in lemma reduceB_mksch *)
   718   apply (frule_tac y = "schB" and x = "schA" and A = "A" and B = "B" in reduceB_mksch)
   742 apply (frule_tac y = "schB" and x = "schA" and A = "A" and B = "B" in reduceB_mksch)
   719   apply assumption+
   743 apply assumption+
   720   apply (erule exE)+
   744 apply (erule exE)+
   721   apply (erule conjE)+
   745 apply (erule conjE)+
   722 
   746 
   723   text \<open>use \<open>reduceB_mksch\<close> to rewrite conclusion\<close>
   747 (* use reduceB_mksch to rewrite conclusion *)
   724   apply hypsubst
   748 apply hypsubst
   725   apply simp
   749 apply simp
   726 
   750 
   727   text \<open>eliminate the \<open>A\<close>-only prefix\<close>
   751 (* eliminate the A-only prefix *)
   728 
   752 
   729   apply (subgoal_tac "(Filter (\<lambda>a. a \<in> act B) $ x1) = nil")
   753 apply (subgoal_tac "(Filter (%a. a :act B) $x1) = nil")
   730   apply (erule_tac [2] ForallQFilterPnil)
   754 apply (erule_tac [2] ForallQFilterPnil)
   731   prefer 2 apply (assumption)
   755 prefer 2 apply (assumption)
   732   prefer 2 apply (fast)
   756 prefer 2 apply (fast)
   733 
   757 
   734   text \<open>Now real recursive step follows (in \<open>x\<close>)\<close>
   758 (* Now real recursive step follows (in x) *)
   735 
   759 
   736   apply simp
   760 apply simp
   737   apply (case_tac "x \<in> act B")
   761 apply (case_tac "x:act B")
   738   apply (case_tac "x \<notin> act A")
   762 apply (case_tac "x~:act A")
   739   apply (rotate_tac -2)
   763 apply (rotate_tac -2)
   740   apply simp
   764 apply simp
   741 
   765 
   742   apply (subgoal_tac "Filter (\<lambda>a. a \<in> act B \<and> a \<in> ext A) $ x1 = nil")
   766 apply (subgoal_tac "Filter (%a. a:act B & a:ext A) $x1=nil")
   743   apply (rotate_tac -1)
   767 apply (rotate_tac -1)
   744   apply simp
   768 apply simp
   745   text \<open>eliminate introduced subgoal 2\<close>
   769 (* eliminate introduced subgoal 2 *)
   746   apply (erule_tac [2] ForallQFilterPnil)
   770 apply (erule_tac [2] ForallQFilterPnil)
   747   prefer 2 apply assumption
   771 prefer 2 apply (assumption)
   748   prefer 2 apply fast
   772 prefer 2 apply (fast)
   749 
   773 
   750   text \<open>bring in \<open>divide_Seq\<close> for \<open>s\<close>\<close>
   774 (* bring in divide Seq for s *)
   751   apply (frule sym [THEN eq_imp_below, THEN divide_Seq])
   775 apply (frule sym [THEN eq_imp_below, THEN divide_Seq])
   752   apply (erule conjE)+
   776 apply (erule conjE)+
   753 
   777 
   754   text \<open>subst \<open>divide_Seq\<close> in conclusion, but only at the rightmost occurrence\<close>
   778 (* subst divide_Seq in conclusion, but only at the rightmost occurrence *)
   755   apply (rule_tac t = "schB" in ssubst)
   779 apply (rule_tac t = "schB" in ssubst)
   756   back
   780 back
   757   back
   781 back
   758   back
   782 back
   759   apply assumption
   783 apply assumption
   760 
   784 
   761   text \<open>reduce \<open>trace_takes\<close> from \<open>n\<close> to strictly smaller \<open>k\<close>\<close>
   785 (* reduce trace_takes from n to strictly smaller k *)
   762   apply (rule take_reduction)
   786 apply (rule take_reduction)
   763 
   787 
   764   text \<open>\<open>f B (tw iB) = tw \<not> eB\<close>\<close>
   788 (* f B (tw iB) = tw ~eB *)
   765   apply (simp add: int_is_act not_ext_is_int_or_not_act)
   789 apply (simp add: int_is_act not_ext_is_int_or_not_act)
   766   apply (rule refl)
   790 apply (rule refl)
   767   apply (simp add: int_is_act not_ext_is_int_or_not_act)
   791 apply (simp add: int_is_act not_ext_is_int_or_not_act)
   768   apply (rotate_tac -11)
   792 apply (rotate_tac -11)
   769 
   793 
   770   text \<open>now conclusion fulfills induction hypothesis, but assumptions are not ready\<close>
   794 (* now conclusion fulfills induction hypothesis, but assumptions are not ready *)
   771 
   795 
   772   text \<open>assumption \<open>schA\<close>\<close>
   796 (* assumption schA *)
   773   apply (simp add: ext_and_act)
   797 apply (simp add: ext_and_act)
   774   text \<open>assumption \<open>schB\<close>\<close>
   798 (* assumption schB *)
   775   apply (drule_tac x = "schB" and g = "Filter (\<lambda>a. a \<in> act B) $ rs" in subst_lemma2)
   799 apply (drule_tac x = "schB" and g = "Filter (%a. a:act B) $rs" in subst_lemma2)
   776   apply assumption
   800 apply assumption
   777   apply (simp add: int_is_not_ext)
   801 apply (simp add: int_is_not_ext)
   778   text \<open>assumptions concerning \<open>LastActExtsch\<close>, cannot be rewritten, as \<open>LastActExtsmalli\<close> are looping\<close>
   802 (* assumptions concerning LastActExtsch, cannot be rewritten, as LastActExtsmalli are looping  *)
   779   apply (drule_tac sch = "schB" and P = "\<lambda>a. a \<in> int B" in LastActExtsmall1)
   803 apply (drule_tac sch = "schB" and P = "%a. a:int B" in LastActExtsmall1)
   780   apply (frule_tac ?sch1.0 = "x1" in LastActExtsmall2)
   804 apply (frule_tac ?sch1.0 = "x1" in LastActExtsmall2)
   781   apply assumption
   805 apply assumption
   782 
   806 
   783   text \<open>assumption \<open>Forall schB\<close>\<close>
   807 (* assumption Forall schB *)
   784   apply (drule_tac s = "schB" and P = "Forall (\<lambda>x. x \<in> act B)" in subst)
   808 apply (drule_tac s = "schB" and P = "Forall (%x. x:act B) " in subst)
   785   apply assumption
   809 apply assumption
   786   apply (simp add: int_is_act)
   810 apply (simp add: int_is_act)
   787 
   811 
   788   text \<open>case \<open>x \<in> actions (asig_of A) \<and> x \<in> actions (asig_of B)\<close>\<close>
   812 (* case x:actions(asig_of A) & x: actions(asig_of B) *)
   789 
   813 
   790   apply (rotate_tac -2)
   814 apply (rotate_tac -2)
   791   apply simp
   815 apply simp
   792 
   816 
   793   apply (subgoal_tac "Filter (\<lambda>a. a \<in> act B \<and> a \<in> ext A) $ x1 = nil")
   817 apply (subgoal_tac "Filter (%a. a:act B & a:ext A) $x1=nil")
   794   apply (rotate_tac -1)
   818 apply (rotate_tac -1)
   795   apply simp
   819 apply simp
   796   text \<open>eliminate introduced subgoal 2\<close>
   820 (* eliminate introduced subgoal 2 *)
   797   apply (erule_tac [2] ForallQFilterPnil)
   821 apply (erule_tac [2] ForallQFilterPnil)
   798   prefer 2 apply assumption
   822 prefer 2 apply (assumption)
   799   prefer 2 apply fast
   823 prefer 2 apply (fast)
   800 
   824 
   801   text \<open>bring in \<open>divide_Seq\<close> for \<open>s\<close>\<close>
   825 (* bring in divide Seq for s *)
   802   apply (frule sym [THEN eq_imp_below, THEN divide_Seq])
   826 apply (frule sym [THEN eq_imp_below, THEN divide_Seq])
   803   apply (erule conjE)+
   827 apply (erule conjE)+
   804 
   828 
   805   text \<open>subst \<open>divide_Seq\<close> in conclusion, but only at the rightmost occurrence\<close>
   829 (* subst divide_Seq in conclusion, but only at the rightmost occurrence *)
   806   apply (rule_tac t = "schB" in ssubst)
   830 apply (rule_tac t = "schB" in ssubst)
   807   back
   831 back
   808   back
   832 back
   809   back
   833 back
   810   apply assumption
   834 apply assumption
   811 
   835 
   812   text \<open>\<open>f B (tw iB) = tw \<not> eB\<close>\<close>
   836 (* f B (tw iB) = tw ~eB *)
   813   apply (simp add: int_is_act not_ext_is_int_or_not_act)
   837 apply (simp add: int_is_act not_ext_is_int_or_not_act)
   814 
   838 
   815   text \<open>rewrite assumption forall and \<open>schB\<close>\<close>
   839 (* rewrite assumption forall and schB *)
   816   apply (rotate_tac 13)
   840 apply (rotate_tac 13)
   817   apply (simp add: ext_and_act)
   841 apply (simp add: ext_and_act)
   818 
   842 
   819   text \<open>\<open>divide_Seq\<close> for \<open>schB2\<close>\<close>
   843 (* divide_Seq for schB2 *)
   820   apply (frule_tac y = "x2" in sym [THEN eq_imp_below, THEN divide_Seq])
   844 apply (frule_tac y = "x2" in sym [THEN eq_imp_below, THEN divide_Seq])
   821   apply (erule conjE)+
   845 apply (erule conjE)+
   822   text \<open>assumption \<open>schA\<close>\<close>
   846 (* assumption schA *)
   823   apply (drule_tac x = "schB" and g = "Filter (\<lambda>a. a \<in> act B) $ rs" in subst_lemma2)
   847 apply (drule_tac x = "schB" and g = "Filter (%a. a:act B) $rs" in subst_lemma2)
   824   apply assumption
   848 apply assumption
   825   apply (simp add: int_is_not_ext)
   849 apply (simp add: int_is_not_ext)
   826 
   850 
   827   text \<open>\<open>f B (tw iA schA2) = nil\<close>\<close>
   851 (* f B (tw iA schA2) = nil *)
   828   apply (simp add: int_is_not_ext not_ext_is_int_or_not_act intA_is_not_actB)
   852 apply (simp add: int_is_not_ext not_ext_is_int_or_not_act intA_is_not_actB)
   829 
   853 
   830 
   854 
   831   text \<open>reduce \<open>trace_takes from \<open>n\<close> to strictly smaller \<open>k\<close>\<close>\<close>
   855 (* reduce trace_takes from n to strictly smaller k *)
   832   apply (rule take_reduction)
   856 apply (rule take_reduction)
   833   apply (rule refl)
   857 apply (rule refl)
   834   apply (rule refl)
   858 apply (rule refl)
   835 
   859 
   836   text \<open>now conclusion fulfills induction hypothesis, but assumptions are not all ready\<close>
   860 (* now conclusion fulfills induction hypothesis, but assumptions are not all ready *)
   837 
   861 
   838   text \<open>assumption \<open>schA\<close>\<close>
   862 (* assumption schA *)
   839   apply (drule_tac x = "x2" and g = "Filter (\<lambda>a. a \<in> act A) $ rs" in subst_lemma2)
   863 apply (drule_tac x = "x2" and g = "Filter (%a. a:act A) $rs" in subst_lemma2)
   840   apply assumption
   864 apply assumption
   841   apply (simp add: intA_is_not_actB int_is_not_ext)
   865 apply (simp add: intA_is_not_actB int_is_not_ext)
   842 
   866 
   843   text \<open>conclusions concerning \<open>LastActExtsch\<close>, cannot be rewritten, as \<open>LastActExtsmalli\<close> are looping\<close>
   867 (* conclusions concerning LastActExtsch, cannot be rewritten, as LastActExtsmalli are looping  *)
   844   apply (drule_tac sch = "schB" and P = "%a. a:int B" in LastActExtsmall1)
   868 apply (drule_tac sch = "schB" and P = "%a. a:int B" in LastActExtsmall1)
   845   apply (frule_tac ?sch1.0 = "x1" in LastActExtsmall2)
   869 apply (frule_tac ?sch1.0 = "x1" in LastActExtsmall2)
   846   apply assumption
   870 apply assumption
   847   apply (drule_tac sch = "x2" and P = "%a. a:int A" in LastActExtsmall1)
   871 apply (drule_tac sch = "x2" and P = "%a. a:int A" in LastActExtsmall1)
   848 
   872 
   849   text \<open>assumption \<open>Forall schA\<close>, and \<open>Forall schA\<close> are performed by \<open>ForallTL\<close>, \<open>ForallDropwhile\<close>\<close>
   873 (* assumption Forall schA, and Forall schA are performed by ForallTL,ForallDropwhile *)
   850   apply (simp add: ForallTL ForallDropwhile)
   874 apply (simp add: ForallTL ForallDropwhile)
   851 
   875 
   852   text \<open>case \<open>x \<notin> B \<and> x \<in> A\<close>\<close>
   876 (* case x~:B & x:A  *)
   853   text \<open>cannot occur, as just this case has been scheduled out before as the \<open>B\<close>-only prefix\<close>
   877 (* cannot occur, as just this case has been scheduled out before as the B-only prefix *)
   854   apply (case_tac "x \<in> act A")
   878 apply (case_tac "x:act A")
   855   apply fast
   879 apply fast
   856 
   880 
   857   text \<open>case \<open>x \<notin> B \<and> x \<notin> A\<close>\<close>
   881 (* case x~:B & x~:A  *)
   858   text \<open>cannot occur because of assumption: \<open>Forall (a \<in> ext A \<or> a \<in> ext B)\<close>\<close>
   882 (* cannot occur because of assumption: Forall (a:ext A | a:ext B) *)
   859   apply (rotate_tac -9)
   883 apply (rotate_tac -9)
   860   text \<open>reduce forall assumption from \<open>tr\<close> to \<open>x \<leadsto> rs\<close>\<close>
   884 (* reduce forall assumption from tr to (x\<leadsto>rs) *)
   861   apply (simp add: externals_of_par)
   885 apply (simp add: externals_of_par)
   862   apply (fast intro!: ext_is_act)
   886 apply (fast intro!: ext_is_act)
   863   done
   887 
       
   888 done
       
   889 
   864 
   890 
   865 
   891 subsection "COMPOSITIONALITY on TRACE Level -- Main Theorem"
   866 subsection "COMPOSITIONALITY on TRACE Level -- Main Theorem"
   892 
   867 
   893 lemma compositionality_tr:
   868 theorem compositionality_tr:
   894 "!! A B. [| is_trans_of A; is_trans_of B; compatible A B; compatible B A;
   869   "is_trans_of A \<Longrightarrow> is_trans_of B \<Longrightarrow> compatible A B \<Longrightarrow> compatible B A \<Longrightarrow>
   895             is_asig(asig_of A); is_asig(asig_of B)|]
   870     is_asig (asig_of A) \<Longrightarrow> is_asig (asig_of B) \<Longrightarrow>
   896         ==>  (tr: traces(A\<parallel>B)) =
   871     tr \<in> traces (A \<parallel> B) \<longleftrightarrow>
   897              (Filter (%a. a:act A)$tr : traces A &
   872       Filter (\<lambda>a. a \<in> act A) $ tr \<in> traces A \<and>
   898               Filter (%a. a:act B)$tr : traces B &
   873       Filter (\<lambda>a. a \<in> act B) $ tr \<in> traces B \<and>
   899               Forall (%x. x:ext(A\<parallel>B)) tr)"
   874       Forall (\<lambda>x. x \<in> ext(A \<parallel> B)) tr"
   900 
   875   apply (simp add: traces_def has_trace_def)
   901 apply (simp (no_asm) add: traces_def has_trace_def)
   876   apply auto
   902 apply auto
   877 
   903 
   878   text \<open>\<open>\<Longrightarrow>\<close>\<close>
   904 (* ==> *)
   879   text \<open>There is a schedule of \<open>A\<close>\<close>
   905 (* There is a schedule of A *)
   880   apply (rule_tac x = "Filter (\<lambda>a. a \<in> act A) $ sch" in bexI)
   906 apply (rule_tac x = "Filter (%a. a:act A) $sch" in bexI)
   881   prefer 2
   907 prefer 2
   882   apply (simp add: compositionality_sch)
   908 apply (simp add: compositionality_sch)
   883   apply (simp add: compatibility_consequence1 externals_of_par ext1_ext2_is_not_act1)
   909 apply (simp add: compatibility_consequence1 externals_of_par ext1_ext2_is_not_act1)
   884   text \<open>There is a schedule of \<open>B\<close>\<close>
   910 (* There is a schedule of B *)
   885   apply (rule_tac x = "Filter (\<lambda>a. a \<in> act B) $ sch" in bexI)
   911 apply (rule_tac x = "Filter (%a. a:act B) $sch" in bexI)
   886   prefer 2
   912 prefer 2
   887   apply (simp add: compositionality_sch)
   913 apply (simp add: compositionality_sch)
   888   apply (simp add: compatibility_consequence2 externals_of_par ext1_ext2_is_not_act2)
   914 apply (simp add: compatibility_consequence2 externals_of_par ext1_ext2_is_not_act2)
   889   text \<open>Traces of \<open>A \<parallel> B\<close> have only external actions from \<open>A\<close> or \<open>B\<close>\<close>
   915 (* Traces of A\<parallel>B have only external actions from A or B *)
   890   apply (rule ForallPFilterP)
   916 apply (rule ForallPFilterP)
   891 
   917 
   892   text \<open>\<open>\<Longleftarrow>\<close>\<close>
   918 (* <== *)
   893 
   919 
   894   text \<open>replace \<open>schA\<close> and \<open>schB\<close> by \<open>Cut schA\<close> and \<open>Cut schB\<close>\<close>
   920 (* replace schA and schB by Cut(schA) and Cut(schB) *)
   895   apply (drule exists_LastActExtsch)
   921 apply (drule exists_LastActExtsch)
   896   apply assumption
   922 apply assumption
   897   apply (drule exists_LastActExtsch)
   923 apply (drule exists_LastActExtsch)
   898   apply assumption
   924 apply assumption
   899   apply (erule exE)+
   925 apply (erule exE)+
   900   apply (erule conjE)+
   926 apply (erule conjE)+
   901   text \<open>Schedules of A(B) have only actions of A(B)\<close>
   927 (* Schedules of A(B) have only actions of A(B) *)
   902   apply (drule scheds_in_sig)
   928 apply (drule scheds_in_sig)
   903   apply assumption
   929 apply assumption
   904   apply (drule scheds_in_sig)
   930 apply (drule scheds_in_sig)
   905   apply assumption
   931 apply assumption
   906 
   932 
   907   apply (rename_tac h1 h2 schA schB)
   933 apply (rename_tac h1 h2 schA schB)
   908   text \<open>\<open>mksch\<close> is exactly the construction of \<open>trA\<parallel>B\<close> out of \<open>schA\<close>, \<open>schB\<close>, and the oracle \<open>tr\<close>,
   934 (* mksch is exactly the construction of trA\<parallel>B out of schA, schB, and the oracle tr,
   909      we need here\<close>
   935    we need here *)
   910   apply (rule_tac x = "mksch A B $ tr $ schA $ schB" in bexI)
   936 apply (rule_tac x = "mksch A B$tr$schA$schB" in bexI)
   911 
   937 
   912   text \<open>External actions of mksch are just the oracle\<close>
   938 (* External actions of mksch are just the oracle *)
   913   apply (simp add: FilterA_mksch_is_tr)
   939 apply (simp add: FilterA_mksch_is_tr)
   914 
   940 
   915   text \<open>\<open>mksch\<close> is a schedule -- use compositionality on sch-level\<close>
   941 (* mksch is a schedule -- use compositionality on sch-level *)
   916   apply (simp add: compositionality_sch)
   942 apply (simp add: compositionality_sch)
   917   apply (simp add: FilterAmksch_is_schA FilterBmksch_is_schB)
   943 apply (simp add: FilterAmksch_is_schA FilterBmksch_is_schB)
   918   apply (erule ForallAorB_mksch)
   944 apply (erule ForallAorB_mksch)
   919   apply (erule ForallPForallQ)
   945 apply (erule ForallPForallQ)
   920   apply (erule ext_is_act)
   946 apply (erule ext_is_act)
   921   done
   947 done
       
   948 
   922 
   949 
   923 
   950 
   924 
   951 subsection \<open>COMPOSITIONALITY on TRACE Level -- for Modules\<close>
   925 subsection \<open>COMPOSITIONALITY on TRACE Level -- for Modules\<close>
   952 
   926 
   953 lemma compositionality_tr_modules:
   927 lemma compositionality_tr_modules:
   954 
   928   "is_trans_of A \<Longrightarrow> is_trans_of B \<Longrightarrow> compatible A B \<Longrightarrow> compatible B A \<Longrightarrow>
   955 "!! A B. [| is_trans_of A; is_trans_of B; compatible A B; compatible B A;
   929     is_asig(asig_of A) \<Longrightarrow> is_asig(asig_of B) \<Longrightarrow>
   956             is_asig(asig_of A); is_asig(asig_of B)|]
   930     Traces (A\<parallel>B) = par_traces (Traces A) (Traces B)"
   957  ==> Traces (A\<parallel>B) = par_traces (Traces A) (Traces B)"
   931   apply (unfold Traces_def par_traces_def)
   958 
   932   apply (simp add: asig_of_par)
   959 apply (unfold Traces_def par_traces_def)
   933   apply (rule set_eqI)
   960 apply (simp add: asig_of_par)
   934   apply (simp add: compositionality_tr externals_of_par)
   961 apply (rule set_eqI)
   935   done
   962 apply (simp add: compositionality_tr externals_of_par)
       
   963 done
       
   964 
   936 
   965 
   937 
   966 declaration \<open>fn _ => Simplifier.map_ss (Simplifier.set_mksym Simplifier.default_mk_sym)\<close>
   938 declaration \<open>fn _ => Simplifier.map_ss (Simplifier.set_mksym Simplifier.default_mk_sym)\<close>
   967 
   939 
   968 
       
   969 end
   940 end