Theory CompoTraces

Up to index of Isabelle/HOLCF/IOA

theory CompoTraces
imports CompoScheds ShortExecutions
uses [CompoTraces.ML]
begin

(*  Title:      HOLCF/IOA/meta_theory/CompoTraces.thy
    ID:         $Id: CompoTraces.thy,v 1.9 2005/09/02 15:24:00 wenzelm Exp $
    Author:     Olaf Müller
*) 

header {* Compositionality on Trace level *}

theory CompoTraces
imports CompoScheds ShortExecutions
begin
 

consts  

 mksch      ::"('a,'s)ioa => ('a,'t)ioa => 'a Seq -> 'a Seq -> 'a Seq -> 'a Seq" 
 par_traces ::"['a trace_module,'a trace_module] => 'a trace_module"

defs

mksch_def:
  "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
             )
         )
       )))"


par_traces_def:
  "par_traces TracesA TracesB == 
       let trA = fst TracesA; sigA = snd TracesA; 
           trB = fst TracesB; sigB = snd TracesB       
       in
       (    {tr. Filter (%a. a:actions sigA)$tr : trA}
        Int {tr. Filter (%a. a:actions sigB)$tr : trB}
        Int {tr. Forall (%x. x:(externals sigA Un externals sigB)) tr},
        asig_comp sigA sigB)"

axioms

finiteR_mksch:
  "Finite (mksch A B$tr$x$y) --> Finite tr"

ML {* use_legacy_bindings (the_context ()) *}


end

mksch rewrite rules

theorem 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 AschA @@
                        Takewhile (%a. a ∈ int BschB @@
                        y>>mksch A
                            B·xs·(TL·(Dropwhile
                                       (%a.
   a ∈ int AschA))·(TL·(Dropwhile (%a. a ∈ int BschB))
                   else Takewhile (%a. a ∈ int AschA @@
                        y>>mksch A B·xs·(TL·(Dropwhile (%a. a ∈ int AschA))·schB
              else if y ∈ act B
                   then Takewhile (%a. a ∈ int BschB @@
                        y>>mksch A B·xs·schA·(TL·(Dropwhile (%a. a ∈ int BschB))
                   else UU)

theorem mksch_UU:

  mksch A B·UU·schA·schB = UU

theorem mksch_nil:

  mksch A B·nil·schA·schB = nil

theorem mksch_cons1:

  [| x ∈ act A; x ∉ act B |]
  ==> mksch A B·(x>>trschA·schB =
      Takewhile (%a. a ∈ int AschA @@
      x>>mksch A B·tr·(TL·(Dropwhile (%a. a ∈ int AschA))·schB

theorem mksch_cons2:

  [| x ∉ act A; x ∈ act B |]
  ==> mksch A B·(x>>trschA·schB =
      Takewhile (%a. a ∈ int BschB @@
      x>>mksch A B·tr·schA·(TL·(Dropwhile (%a. a ∈ int BschB))

theorem mksch_cons3:

  [| x ∈ act A; x ∈ act B |]
  ==> mksch A B·(x>>trschA·schB =
      Takewhile (%a. a ∈ int AschA @@
      Takewhile (%a. a ∈ int BschB @@
      x>>mksch A
          B·tr·(TL·(Dropwhile
                     (%a. a ∈ int AschA))·(TL·(Dropwhile (%a. a ∈ int BschB))

Lemmata for ==>

theorem compatibility_consequence1:

  (eB ∧ ¬ eA --> ¬ A) --> (A ∧ (eAeB)) = (eAA)

theorem compatibility_consequence2:

  (eB ∧ ¬ eA --> ¬ A) --> (A ∧ (eBeA)) = (eAA)

Lemmata for <==

theorem subst_lemma1:

  [| f << g x; x = h x |] ==> f << g (h x)

theorem subst_lemma2:

  [| f x = y>>g; x = h x |] ==> f (h x) = y>>g

theorem ForallAorB_mksch:

  [| compatible A B; Forall (%x. x ∈ act (A || B)) tr |]
  ==> Forall (%x. x ∈ act (A || B)) (mksch A B·tr·schA·schB)

theorem ForallBnAmksch:

  [| compatible B A; Forall (%x. x ∈ act Bx ∉ act A) tr |]
  ==> Forall (%x. x ∈ act Bx ∉ act A) (mksch A B·tr·schA·schB)

theorem ForallAnBmksch:

  [| compatible A B; Forall (%x. x ∈ act Ax ∉ act B) tr |]
  ==> Forall (%x. x ∈ act Ax ∉ act B) (mksch A B·tr·schA·schB)

theorem FiniteL_mksch:

  [| Finite tr; is_asig (asig_of A); is_asig (asig_of B);
     Forall (%x. x ∈ act A) x ∧
     Forall (%x. x ∈ act B) y ∧
     Filter (%a. a ∈ ext Ax = Filter (%a. a ∈ act Atr ∧
     Filter (%a. a ∈ ext By = Filter (%a. a ∈ act Btr ∧
     Forall (%x. x ∈ ext (A || B)) tr |]
  ==> Finite (mksch A B·tr·x·y)

theorem reduceA_mksch1:

  [| Finite bs; is_asig (asig_of A); is_asig (asig_of B); compatible A B;
     Forall (%x. x ∈ act B) y ∧
     Forall (%x. x ∈ act Bx ∉ act A) bs ∧
     Filter (%a. a ∈ ext By = Filter (%a. a ∈ act B)·(bs @@ z) |]
  ==> ∃y1 y2.
         mksch A B·(bs @@ zx·y = y1 @@ mksch A B·z·x·y2 ∧
         Forall (%x. x ∈ act Bx ∉ act A) y1 ∧
         Finite y1y = y1 @@ y2 ∧ Filter (%a. a ∈ ext By1 = bs

theorem reduceA_mksch:

  [| Finite bs; is_asig (asig_of A); is_asig (asig_of B); compatible A B;
     Forall (%x. x ∈ act B) y; Forall (%x. x ∈ act Bx ∉ act A) bs;
     Filter (%a. a ∈ ext By = Filter (%a. a ∈ act B)·(bs @@ z) |]
  ==> ∃y1 y2.
         mksch A B·(bs @@ zx·y = y1 @@ mksch A B·z·x·y2 ∧
         Forall (%x. x ∈ act Bx ∉ act A) y1 ∧
         Finite y1y = y1 @@ y2 ∧ Filter (%a. a ∈ ext By1 = bs

theorem reduceB_mksch1:

  [| Finite as; is_asig (asig_of A); is_asig (asig_of B); compatible A B;
     Forall (%x. x ∈ act A) x ∧
     Forall (%x. x ∈ act Ax ∉ act B) as ∧
     Filter (%a. a ∈ ext Ax = Filter (%a. a ∈ act A)·(as @@ z) |]
  ==> ∃x1 x2.
         mksch A B·(as @@ zx·y = x1 @@ mksch A B·z·x2·y ∧
         Forall (%x. x ∈ act Ax ∉ act B) x1 ∧
         Finite x1x = x1 @@ x2 ∧ Filter (%a. a ∈ ext Ax1 = as

theorem reduceB_mksch:

  [| Finite as; is_asig (asig_of A); is_asig (asig_of B); compatible A B;
     Forall (%x. x ∈ act A) x; Forall (%x. x ∈ act Ax ∉ act B) as;
     Filter (%a. a ∈ ext Ax = Filter (%a. a ∈ act A)·(as @@ z) |]
  ==> ∃x1 x2.
         mksch A B·(as @@ zx·y = x1 @@ mksch A B·z·x2·y ∧
         Forall (%x. x ∈ act Ax ∉ act B) x1 ∧
         Finite x1x = x1 @@ x2 ∧ Filter (%a. a ∈ ext Ax1 = as

Filtering external actions out of mksch(tr,schA,schB) yields the oracle tr

theorem 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 Atr << Filter (%a. a ∈ ext AschA ∧
         Filter (%a. a ∈ act Btr << Filter (%a. a ∈ ext BschB -->
         Filter (%a. a ∈ ext (A || B))·(mksch A B·tr·schA·schB) = tr

Filter of mksch(tr,schA,schB) to A is schA -- take lemma proof

theorem FilterAmksch_is_schA:

  [| 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 AschA = Filter (%a. a ∈ act Atr ∧
      Filter (%a. a ∈ ext BschB = Filter (%a. a ∈ act Btr ∧
      LastActExtsch A schA ∧ LastActExtsch B schB -->
      Filter (%a. a ∈ act A)·(mksch A B·tr·schA·schB) = schA

Filter of mksch(tr,schA,schB) to B is schB -- take lemma proof

theorem 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 AschA = Filter (%a. a ∈ act Atr ∧
      Filter (%a. a ∈ ext BschB = Filter (%a. a ∈ act Btr ∧
      LastActExtsch A schA ∧ LastActExtsch B schB -->
      Filter (%a. a ∈ act B)·(mksch A B·tr·schA·schB) = schB

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 Atr ∈ traces A ∧
       Filter (%a. a ∈ act Btr ∈ traces B ∧ Forall (%x. x ∈ ext (A || B)) tr)

theorem 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)