Theory Trace_hide

Up to index of Isabelle/HOL/HOL-Complex/CSP

theory Trace_hide
imports Prefix
begin

           (*-------------------------------------------*
            |        CSP-Prover on Isabelle2004         |
            |               November 2004               |
            |                   July 2005  (modified)   |
            |                                           |
            |        CSP-Prover on Isabelle2005         |
            |                October 2005  (modified)   |
            |                  April 2006  (modified)   |
            |                                           |
            |        Yoshinao Isobe (AIST JAPAN)        |
            *-------------------------------------------*)

theory Trace_hide
imports Prefix
begin

(*  The following simplification rules are deleted in this theory file *)
(*  because they unexpectly rewrite (notick | t = <>)                  *)
(*                                                                     *)
(*                  disj_not1: (~ P | Q) = (P --> Q)                   *)

declare disj_not1 [simp del]

(*****************************************************************

         1. 
         2. 
         3. 
         4. 

 *****************************************************************)

consts
  hidex :: "'a set => ('a trace * 'a trace) set"

inductive "hidex X"
intros
hidex_nil:
  "(<>, <>) : hidex X"

hidex_Tick:
  "(<Tick>, <Tick>) : hidex X"

hidex_in: 
  "[| (s, t) : hidex X ; a : X |]
   ==> (<Ev a> ^^ s, t) : hidex X"

hidex_notin: 
  "[| (s, t) : hidex X ; a ~: X |]
   ==> (<Ev a> ^^ s, <Ev a> ^^ t) : hidex X"

consts
  hide_tr :: "'a trace => 'a set => 'a trace"  ("_ --tr _" [84,85] 84)
  rest_tr :: "'a trace => 'a set => 'a trace"  ("_ rest-tr _" [84,85] 84)

defs
  hide_tr_def : 
    "s --tr X == THE t. (s, t) : hidex X"
  rest_tr_def : 
    "s rest-tr X == s --tr (- X)"

(*************************************************************
                       THE hidex 
 *************************************************************)

(*** exists ***)

lemma hidex_exists_lm: 
  "ALL X s. (EX t. (s, t) : hidex X)"
apply (rule allI)
apply (rule allI)
apply (induct_tac s rule: induct_trace)

apply (simp_all)
apply (rule_tac x="<>" in exI, simp add: hidex.intros)
apply (rule_tac x="<Tick>" in exI, simp add: hidex.intros)

apply (elim exE)
apply (case_tac "a : X")
apply (rule_tac x="t" in exI, simp add: hidex.intros)
apply (rule_tac x="<Ev a> ^^ t" in exI, simp add: hidex.intros)
done

(*** exists !! ***)

lemma hidex_exists: 
  "EX t. (s, t) : hidex X"
by (simp add: hidex_exists_lm)

(*** unique ***)

lemma hidex_unique_lm: 
  "ALL X s t u. ((s, t) : hidex X & (s, u) : hidex X)
    --> t = u"
apply (rule allI)
apply (rule allI)
apply (induct_tac s rule: induct_trace)

(* <> *)
apply (intro allI impI)
apply (erule conjE)
apply (erule hidex.elims, simp_all)
apply (erule hidex.elims, simp_all)

(* <Tick> *)
apply (intro allI impI)
apply (erule conjE)
apply (erule hidex.elims, simp_all)
apply (erule hidex.elims, simp_all)

(* step *)
apply (intro allI impI)
apply (erule conjE)
apply (case_tac "a : X")
 apply (erule hidex.elims, simp_all)
 apply (erule hidex.elims, simp_all)

 apply (erule hidex.elims, simp_all)
 apply (erule hidex.elims, simp_all)
done

lemma hidex_unique: 
  "[| (s, t) : hidex X ; (s, u) : hidex X |]
   ==> t = u"
apply (insert hidex_unique_lm)
apply (drule_tac x="X" in spec)
apply (drule_tac x="s" in spec)
apply (drule_tac x="t" in spec)
apply (drule_tac x="u" in spec)
apply (simp)
done

(*************************************************************
                       THE hidex 
 *************************************************************)

lemma hidex_to_hide_tr : 
    "(s, t) : hidex X = (t = s --tr X)"
apply (simp add: hide_tr_def)
apply (rule iffI)
apply (rule sym)
apply (rule the_equality)
apply (simp)
apply (simp add: hidex_unique)

apply (simp)
apply (insert hidex_exists[of s X])
apply (erule exE)
apply (rule theI[of "(%x. (s, x) : hidex X)"])
apply (simp)
apply (simp add: hidex_unique)
done

lemma hide_tr_to_hidex : 
    "(s --tr X = t) = ((s, t) : hidex X)"
apply (simp add: hidex_to_hide_tr)
by (fast)

lemma hide_tr_to_hidex_sym : 
    "(t = s --tr X) = ((s, t) : hidex X)"
by (simp add: hidex_to_hide_tr)

lemmas hide_tr_iff = hide_tr_to_hidex hide_tr_to_hidex_sym

(*************************************************************
                         hide_tr
 *************************************************************)

(*------------------*
 |      intros      |
 *------------------*)

lemma hide_tr_nil[simp] : "<> --tr X = <>"
apply (simp add: hide_tr_to_hidex)
by (simp add: hidex.intros)

lemma hide_tr_Tick[simp] : "<Tick> --tr X = <Tick>"
apply (simp add: hide_tr_to_hidex)
by (simp add: hidex.intros)

lemma hide_tr_in_lm : 
  "[| a : X ;  t = s --tr X |]
   ==> (<Ev a> ^^ s) --tr X = t"
apply (simp add: hide_tr_to_hidex_sym)
apply (simp add: hide_tr_to_hidex)
apply (simp add: hidex.intros)
done

lemma hide_tr_in[simp] : 
  "a : X ==> (<Ev a> ^^ s) --tr X = s --tr X"
by (simp add: hide_tr_in_lm)

lemma hide_tr_in_one[simp] : 
  "a : X ==> <Ev a> --tr X = <>"
apply (insert hide_tr_in[of a X "<>"])
by (simp)

lemma hide_tr_notin_lm : 
  "[| a ~: X ;  t = s --tr X |]
   ==> (<Ev a> ^^ s) --tr X = <Ev a> ^^ t"
apply (simp add: hide_tr_to_hidex_sym)
apply (simp add: hide_tr_to_hidex)
apply (simp add: hidex.intros)
done

lemma hide_tr_notin_appt[simp] : 
  "a ~: X ==> (<Ev a> ^^ s) --tr X = <Ev a> ^^ (s --tr X)"
by (simp add: hide_tr_notin_lm)

lemma hide_tr_notin[simp] : 
  "a ~: X ==> <Ev a> --tr X = <Ev a>"
apply (insert hide_tr_notin_appt[of a X "<>"])
by (simp)

(*------------------*
 |      elims       |
 *------------------*)

lemma hide_tr_elims_lm:
  "[| s --tr X = t ;
      (( s = <> & t = <> ) --> P) ;
      (( s = <Tick> & t = <Tick> ) --> P) ;
      ( ALL a s'.
        ((s = <Ev a> ^^ s' & s' --tr X = t & a : X )
         --> P)) ;
      ( ALL a s' t'.
        ((s = <Ev a> ^^ s' & t = <Ev a> ^^ t' & s' --tr X = t' & a ~: X )
         --> P)) |]
   ==> P"
apply (simp add: hide_tr_iff)
apply (erule hidex.elims)
by (auto)

lemma hide_tr_elims:
  "[| s --tr X = t; 
      [| s = <> ; t = <> |] ==> P; 
      [| s = <Tick> ; t = <Tick> |] ==> P; 
   !!a s'.
      [| s = <Ev a> ^^ s' ; s' --tr X = t; a : X |]
      ==> P;
   !!a s' t'.
      [| s = <Ev a> ^^ s' ; t = <Ev a> ^^ t' ; s' --tr X = t' ; a ~: X |]
      ==> P |]
   ==> P"
apply (rule hide_tr_elims_lm[of s X t])
apply (simp_all)
by (force)+

(*************************************************************
        a new event is not introduced by HIDE (trace)
 *************************************************************)

lemma hide_tr_in_event[simp]:
  "e : sett (s --tr X) = (e ~: Ev ` X & e : sett s)"
apply (induct_tac s rule: induct_trace)
apply (simp)
apply (simp)
apply (force)

apply (simp)
apply (case_tac "a : X")
apply (simp)
apply (rule iffI, simp, force)
apply (rule iffI, force, force)
done

(*** notick ***)

lemma hide_tr_noTick[simp]: "noTick (s --tr X) = noTick s"
apply (simp add: noTick_def)
by (auto)

(*************************************************************
                  appended traces in hide
 *************************************************************)

lemma hide_tr_appt_noTick_lm:
  "ALL X s e t. noTick s --> ((s ^^ t) --tr X = (s --tr X) ^^ (t --tr X))"
apply (rule allI)
apply (rule allI)
apply (induct_tac s rule: induct_trace)
apply (simp_all)

apply (intro allI impI, simp)
apply (case_tac "a : X")
by (simp_all add: appt_assoc)

(*** simp ***)

lemma hide_tr_appt[simp]:
  "noTick s | t = <> ==> (s ^^ t) --tr X = (s --tr X) ^^ (t --tr X)"
apply (erule disjE)
apply (simp add: hide_tr_appt_noTick_lm)
by (simp)

(*************************************************************
                 decompose traces in hide
 *************************************************************)

lemma hide_tr_decompo_only_if_lm:
  "ALL X u s t.
      ((noTick s | t = <>) & u --tr X = s ^^ t)
      --> (EX s' t'. (noTick s' | t' = <>) &
                     u = s' ^^ t' &
                     s = s' --tr X & t = t' --tr X) "
apply (rule allI)
apply (rule allI)
apply (induct_tac u rule: induct_trace)
apply (intro allI impI)
apply (rule_tac x="<>" in exI)
apply (rule_tac x="<>" in exI)
apply (force)

apply (intro allI impI)
apply (elim conjE disjE)
apply (simp)
apply (elim conjE disjE)
apply (rule_tac x="<Tick>" in exI)
apply (rule_tac x="<>" in exI)
apply (simp)
apply (rule_tac x="<>" in exI)
apply (rule_tac x="<Tick>" in exI)
apply (simp)
apply (rule_tac x="<Tick>" in exI)
apply (rule_tac x="<>" in exI)
apply (drule sym)
apply (simp)

apply (intro allI impI)
apply (erule conjE)
apply (erule hide_tr_elims)
apply (simp_all)

 (* a : X *)
 apply (drule_tac x="sa" in spec)
 apply (drule_tac x="t" in spec)
 apply (simp)
 apply (elim conjE exE)
 apply (simp)

 apply (rule_tac x="<Ev aa> ^^ s'a" in exI)
 apply (rule_tac x="t'" in exI)
 apply (erule disjE)
 apply (simp add: appt_assoc)
 apply (erule disjE)
 apply (simp add: appt_assoc)
 apply (simp)

 (* a ~: X *)
 apply (insert trace_nil_or_Tick_or_Ev)
 apply (rotate_tac -1)
 apply (drule_tac x="sa" in spec)
 apply (rotate_tac -1)

  (* <> *)
  apply (erule disjE)
  apply (rule_tac x="<>" in exI, simp)

  (* <Tick> *)
  apply (rotate_tac -1)
  apply (erule disjE)
  apply (simp)

  (* <Ev a> ^^ ... *)
  apply (elim exE)
  apply (simp add: appt_assoc)

  apply (drule_tac x="sb" in spec)
  apply (drule_tac x="t" in spec)
  apply (simp)
  apply (elim conjE exE)

  apply (rule_tac x="<Ev aa> ^^ s'a" in exI)
  apply (rule_tac x="t'a" in exI)
  apply (simp add: appt_assoc)
done

lemma hide_tr_decompo_only_if:
  "[| noTick s | t = <> ; u --tr X = s ^^ t |]
   ==> (EX s' t'. (noTick s' | t' = <>) &
                  u = s' ^^ t' &
                  s = s' --tr X & t = t' --tr X)"
by (simp add: hide_tr_decompo_only_if_lm)

(* if *)

lemma hide_tr_decompo_if:
  "[| noTick s | t = <> ; 
      (EX s' t'. (noTick s' | t' = <>) &
                  u = s' ^^ t' &
                  s = s' --tr X & t = t' --tr X) |]
   ==> u --tr X = s ^^ t"
apply (elim conjE exE)
by (simp)

(*** iff ***)

lemma hide_tr_decompo:
  "noTick s | t = <>
   ==> u --tr X = s ^^ t
    = (EX s' t'. (noTick s' | t' = <>) &
                  u = s' ^^ t' &
                  s = s' --tr X & t = t' --tr X)"
apply (rule iffI)
apply (simp add: hide_tr_decompo_only_if)
apply (rule hide_tr_decompo_if)
by (simp_all)

(*************************************************************
                  hide trace prefix_closed
 *************************************************************)

lemma hide_tr_prefix_only_if_lm:
 "ALL X s u. (prefix u (s --tr X)) 
    --> (EX t. u = t --tr X & prefix t s)"
apply (rule allI)
apply (rule allI)
apply (induct_tac s rule: induct_trace)
apply (simp_all)

(* Tick *)
apply (force)

(* <Ev a> ^^ ... *)
apply (intro allI impI)

 apply (case_tac "a : X")
 apply (drule_tac x="u" in spec, simp)
 apply (elim conjE exE)
 apply (rule_tac x="<Ev a> ^^ t" in exI, simp)

 (* a ~: X *)
 apply (simp)

  (* u = <> *)
  apply (erule disjE)
  apply (drule_tac x="<>" in spec)
  apply (simp)
  apply (elim conjE exE)
  apply (rule_tac x="<>" in exI)
  apply (simp)

  (* u = <Ev a> ^^ ... *)
  apply (elim conjE exE)
  apply (drule_tac x="v'" in spec, simp)
  apply (elim conjE exE)
  apply (rule_tac x="<Ev a> ^^ t" in exI, simp)
done

lemma hide_tr_prefix_only_if:
 "prefix u (s --tr X) ==> (EX t. u = t --tr X & prefix t s)"
by (simp add: hide_tr_prefix_only_if_lm)

(*** if ***)

lemma hide_tr_prefix_if:
 "prefix t s ==> prefix (t --tr X) (s --tr X)"
apply (simp add: prefix_def)
apply (erule exE)
apply (simp)
apply (rule_tac x="u --tr X" in exI)
by (auto)

lemma hide_tr_prefix:
 "prefix u (s --tr X) = (EX t. u = t --tr X & prefix t s)"
apply (rule iffI)
apply (simp add: hide_tr_prefix_only_if)
apply (erule exE)
by (simp add: hide_tr_prefix_if)

(*************************************************************
                  hide + alpha lemma
 *************************************************************)

(* rev <> *)

(* only if *)

lemma hide_tr_nilt_sett_only_if_lm:
  "ALL s. s --tr X = <> --> (sett s <= Ev ` X)"
apply (rule allI)
apply (induct_tac s rule: induct_trace)
apply (simp_all)
apply (intro allI impI)
apply (elim conjE exE)
apply (case_tac "a : X")
by (simp_all)

lemma hide_tr_nilt_sett_only_if:
  "s --tr X = <> ==> (sett s <= Ev ` X)"
by (simp add: hide_tr_nilt_sett_only_if_lm)

(* if *)

lemma hide_tr_nilt_sett_if_lm:
  "ALL s. sett s <= Ev ` X --> s --tr X = <>"
apply (rule allI)
apply (induct_tac s rule: induct_trace)
apply (simp_all)
apply (force)
apply (intro allI impI)
apply (elim conjE)
apply (simp)
apply (case_tac "a : X")
by (auto)

lemma hide_tr_nilt_sett_if:
  "sett s <= Ev ` X ==> s --tr X = <>"
by (simp add: hide_tr_nilt_sett_if_lm)

(* iff *)

lemma hide_tr_nilt_sett:
  "(s --tr X = <>) = (sett s <= Ev ` X)"
apply (rule iffI)
apply (simp add: hide_tr_nilt_sett_only_if)
apply (simp add: hide_tr_nilt_sett_if)
done

(*** sett <= sett ***)

lemma hide_tr_sett_subseteq_sett:
  "X <= Y ==> sett (u --tr Y) <= sett (u --tr X)"
apply (induct_tac u rule: induct_trace)
apply (simp_all)
apply (case_tac "a : X")
apply (simp_all)
apply (case_tac "a ~: Y", fast)
apply (simp)

apply (case_tac "a : Y")
apply (auto)
done

(* rev <Tick> *)

(* only if *)

lemma hide_tr_Tick_sett_only_if_lm:
  "ALL s. s --tr X = <Tick>
    --> (EX s'. s = s' ^^ <Tick> & sett s' <= Ev ` X & noTick s')"
apply (rule allI)
apply (induct_tac s rule: rev_induct_trace)
apply (simp_all)
apply (rule conjI)

 apply (force)

 apply (intro allI impI)
 apply (elim conjE exE)
 apply (rule_tac x="sa" in exI)
 apply (simp)
 apply (insert event_Tick_or_Ev)
 apply (drule_tac x="e" in spec)
 apply (erule disjE)
 apply (simp add: hide_tr_nilt_sett)

 apply (erule exE)
 apply (case_tac "a : X")
 apply (simp_all)
done

lemma hide_tr_Tick_sett_only_if:
  "s --tr X = <Tick>
    ==> (EX s'. s = s' ^^ <Tick> & sett s' <= Ev ` X & noTick s')"
by (simp add: hide_tr_Tick_sett_only_if_lm)

(* if *)

lemma hide_tr_Tick_sett_if:
  "sett s <= Ev ` X ==> s --tr X = <>"
by (simp add: hide_tr_nilt_sett)

(* iff *)

lemma hide_tr_Tick_sett:
  "(s --tr X = <Tick>)
   = (EX s'. s = s' ^^ <Tick> & sett s' <= Ev ` X & noTick s')"
apply (rule iffI)
apply (simp add: hide_tr_Tick_sett_only_if)
apply (elim conjE exE)
apply (simp add: hide_tr_Tick_sett_if)
done

(*--------------------------*
 |       commutativity      |
 *--------------------------*)

lemma hide_tr_commute:
  "(u --tr X) --tr Y = (u --tr Y) --tr X"
apply (induct_tac u rule: induct_trace)
apply (simp_all)
apply (case_tac "a:X")
 apply (case_tac "a:Y")
  apply (simp)
  apply (simp)
 apply (case_tac "a:Y")
  apply (simp)
  apply (simp)
done

(*--------------------------------*
 |   used in Inductive_parallel   |
 *--------------------------------*)

lemma hide_tr_of_hide_tr_subset1:
  "X <= Y ==> (u --tr X) --tr Y = u --tr Y"
apply (induct_tac u rule: induct_trace)
apply (simp_all)
apply (case_tac "a:X")
by (auto)

lemma hide_tr_of_hide_tr_subset2:
  "X <= Y ==> (u --tr Y) --tr X = u --tr Y"
apply (simp add: hide_tr_commute)
apply (simp add: hide_tr_of_hide_tr_subset1)
done

lemmas hide_tr_of_hide_tr_subset = hide_tr_of_hide_tr_subset1
                                   hide_tr_of_hide_tr_subset2

lemma hide_tr_UNIV_lm:
  "((u --tr UNIV = <>) | (u --tr UNIV = <Tick>))"
apply (induct_tac u rule: induct_trace)
by (simp_all)

lemma hide_tr_UNIV:
  "((u --tr UNIV = <>) | (u --tr UNIV = <Tick>))"
by (simp add: hide_tr_UNIV_lm)

(*======================================================*
 |                                                      |
 |                        rest-tr                       |
 |                                                      |
 *======================================================*)

(*------------------*
 |      intros      |
 *------------------*)

lemma rest_tr_nil[simp] : "<> rest-tr X = <>"
by (simp add: rest_tr_def)

lemma rest_tr_Tick[simp] : "<Tick> rest-tr X = <Tick>"
by (simp add: rest_tr_def)

lemma rest_tr_notin[simp] : 
  "a ~: X ==> (<Ev a> ^^ s) rest-tr X = s rest-tr X"
by (simp add: rest_tr_def)

lemma rest_tr_notin_one[simp] : 
  "a ~: X ==> <Ev a> rest-tr X = <>"
by (simp add: rest_tr_def)

lemma rest_tr_in_appt[simp] : 
  "a : X ==> (<Ev a> ^^ s) rest-tr X = <Ev a> ^^ (s rest-tr X)"
by (simp add: rest_tr_def)

lemma rest_tr_in[simp] : 
  "a : X ==> <Ev a> rest-tr X = <Ev a>"
by (simp add: rest_tr_def)

(*------------------*
 |      elims       |
 *------------------*)

lemma rest_tr_elims:
  "[| s rest-tr X = t; 
      [| s = <> ; t = <> |] ==> P; 
      [| s = <Tick> ; t = <Tick> |] ==> P; 
   !!a s'.
      [| s = <Ev a> ^^ s' ; s' rest-tr X = t; a ~: X |]
      ==> P;
   !!a s' t'.
      [| s = <Ev a> ^^ s' ; t = <Ev a> ^^ t' ; s' rest-tr X = t' ; a : X |]
      ==> P |]
   ==> P"
apply (simp add: rest_tr_def)
apply (erule hide_tr_elims)
apply (simp)
apply (simp)
apply (blast)
apply (blast)
done

(*************************************************************
        a new event is not introduced by rest (trace)
 *************************************************************)

lemma rest_tr_in_event[simp]:
  "e : sett (s rest-tr X) = ((e : Ev ` X | e = Tick) & e : sett s)"
apply (simp add: rest_tr_def)
apply (insert event_Tick_or_Ev)
apply (drule_tac x="e" in spec)
apply (auto)
done

lemma rest_tr_subset_event[simp]:
  "sett (s rest-tr X) <= insert Tick (Ev ` X)"
apply (auto)
done
(*** notick ***)

lemma rest_tr_noTick[simp]: "noTick (s rest-tr X) = noTick s"
by (simp add: noTick_def)

(*************************************************************
                  appended traces in rest
 *************************************************************)

lemma rest_tr_appt[simp]:
  "noTick s | t = <> ==> (s ^^ t) rest-tr X = (s rest-tr X) ^^ (t rest-tr X)"
apply (simp add: rest_tr_def)
done

(*************************************************************
                 decompose traces in rest
 *************************************************************)

lemma rest_tr_decompo:
  "noTick s | t = <>
   ==> u rest-tr X = s ^^ t
    = (EX s' t'. (noTick s' | t' = <>) &
                  u = s' ^^ t' &
                  s = s' rest-tr X & t = t' rest-tr X)"
apply (simp add: rest_tr_def)
apply (simp add: hide_tr_decompo)
done

(*************************************************************
                  rest trace prefix_closed
 *************************************************************)

lemma rest_tr_prefix:
 "prefix u (s rest-tr X) = (EX t. u = t rest-tr X & prefix t s)"
apply (simp add: rest_tr_def)
apply (simp add: hide_tr_prefix)
done

(*************************************************************
                  rest + alpha lemma
 *************************************************************)

(* rev <> *)

lemma rest_tr_nilt_sett:
  "(s rest-tr X = <>) = (sett s Int (insert Tick (Ev ` X)) = {})"
apply (simp add: rest_tr_def)
apply (simp add: hide_tr_nilt_sett)
apply (auto)
apply (insert event_Tick_or_Ev)
apply (drule_tac x="x" in spec)
apply (auto)
done

(*** sett <= sett ***)

lemma rest_tr_sett_subseteq_sett:
  "X <= Y ==> sett (u rest-tr X) <= sett (u rest-tr Y)"
apply (simp add: rest_tr_def)
by (simp add: hide_tr_sett_subseteq_sett)

(* rev <Tick> *)

lemma rest_tr_Tick_sett:
  "(s rest-tr X = <Tick>)
   = (EX s'. s = s' ^^ <Tick> & (sett s' Int (Ev ` X) = {})
      & noTick s')"
apply (simp add: rest_tr_def)
apply (simp add: hide_tr_Tick_sett)
apply (auto)
apply (rule_tac x="s'" in exI)
apply (auto)
apply (insert event_Tick_or_Ev)
apply (drule_tac x="x" in spec)
apply (auto simp add: noTick_def)
done

(*--------------------------*
 |       commutativity      |
 *--------------------------*)

lemma rest_tr_commute:
  "(u rest-tr X) rest-tr Y = (u rest-tr Y) rest-tr X"
apply (simp add: rest_tr_def)
apply (simp add: hide_tr_commute)
done

(*--------------------------------*
 |   used in Inductive_parallel   |
 *--------------------------------*)

lemma rest_tr_of_rest_tr_subset1:
  "X <= Y ==> (u rest-tr X) rest-tr Y = u rest-tr X"
apply (simp add: rest_tr_def)
apply (rule hide_tr_of_hide_tr_subset)
by (auto)

lemma rest_tr_of_rest_tr_subset2:
  "X <= Y ==> (u rest-tr Y) rest-tr X = u rest-tr X"
apply (simp add: rest_tr_commute)
apply (simp add: rest_tr_of_rest_tr_subset1)
done

lemmas rest_tr_of_rest_tr_subset = rest_tr_of_rest_tr_subset1
                                   rest_tr_of_rest_tr_subset2

lemma rest_tr_empty:
  "((u rest-tr {} = <>) | (u rest-tr {} = <Tick>))"
apply (simp add: rest_tr_def)
apply (simp add: hide_tr_UNIV)
done

(****************** to add it again ******************)

declare disj_not1 [simp] 

end

lemma hidex_exists_lm:

X s. ∃t. (s, t) ∈ hidex X

lemma hidex_exists:

t. (s, t) ∈ hidex X

lemma hidex_unique_lm:

X s t u. (s, t) ∈ hidex X ∧ (s, u) ∈ hidex X --> t = u

lemma hidex_unique:

  [| (s, t) ∈ hidex X; (s, u) ∈ hidex X |] ==> t = u

lemma hidex_to_hide_tr:

  ((s, t) ∈ hidex X) = (t = s --tr X)

lemma hide_tr_to_hidex:

  (s --tr X = t) = ((s, t) ∈ hidex X)

lemma hide_tr_to_hidex_sym:

  (t = s --tr X) = ((s, t) ∈ hidex X)

lemmas hide_tr_iff:

  (s --tr X = t) = ((s, t) ∈ hidex X)
  (t = s --tr X) = ((s, t) ∈ hidex X)

lemmas hide_tr_iff:

  (s --tr X = t) = ((s, t) ∈ hidex X)
  (t = s --tr X) = ((s, t) ∈ hidex X)

lemma hide_tr_nil:

  <> --tr X = <>

lemma hide_tr_Tick:

  <Tick> --tr X = <Tick>

lemma hide_tr_in_lm:

  [| aX; t = s --tr X |] ==> (<Ev a> ^^ s) --tr X = t

lemma hide_tr_in:

  aX ==> (<Ev a> ^^ s) --tr X = s --tr X

lemma hide_tr_in_one:

  aX ==> <Ev a> --tr X = <>

lemma hide_tr_notin_lm:

  [| aX; t = s --tr X |] ==> (<Ev a> ^^ s) --tr X = <Ev a> ^^ t

lemma hide_tr_notin_appt:

  aX ==> (<Ev a> ^^ s) --tr X = <Ev a> ^^ s --tr X

lemma hide_tr_notin:

  aX ==> <Ev a> --tr X = <Ev a>

lemma hide_tr_elims_lm:

  [| s --tr X = t; s = <> ∧ t = <> --> P; s = <Tick> ∧ t = <Tick> --> P;
     ∀a s'. s = <Ev a> ^^ s's' --tr X = taX --> P;
     ∀a s' t'.
        s = <Ev a> ^^ s't = <Ev a> ^^ t's' --tr X = t'aX --> P |]
  ==> P

lemma hide_tr_elims:

  [| s --tr X = t; [| s = <>; t = <> |] ==> P; [| s = <Tick>; t = <Tick> |] ==> P;
     !!a s'. [| s = <Ev a> ^^ s'; s' --tr X = t; aX |] ==> P;
     !!a s' t'.
        [| s = <Ev a> ^^ s'; t = <Ev a> ^^ t'; s' --tr X = t'; aX |] ==> P |]
  ==> P

lemma hide_tr_in_event:

  (e ∈ sett (s --tr X)) = (e ∉ Ev ` Xe ∈ sett s)

lemma hide_tr_noTick:

  noTick (s --tr X) = noTick s

lemma hide_tr_appt_noTick_lm:

X s e t. noTick s --> (s ^^ t) --tr X = s --tr X ^^ t --tr X

lemma hide_tr_appt:

  noTick st = <> ==> (s ^^ t) --tr X = s --tr X ^^ t --tr X

lemma hide_tr_decompo_only_if_lm:

X u s t.
     (noTick st = <>) ∧ u --tr X = s ^^ t -->
     (∃s' t'.
         (noTick s't' = <>) ∧ u = s' ^^ t's = s' --tr Xt = t' --tr X)

lemma hide_tr_decompo_only_if:

  [| noTick st = <>; u --tr X = s ^^ t |]
  ==> ∃s' t'. (noTick s't' = <>) ∧ u = s' ^^ t's = s' --tr Xt = t' --tr X

lemma hide_tr_decompo_if:

  [| noTick st = <>;
     ∃s' t'.
        (noTick s't' = <>) ∧ u = s' ^^ t's = s' --tr Xt = t' --tr X |]
  ==> u --tr X = s ^^ t

lemma hide_tr_decompo:

  noTick st = <>
  ==> (u --tr X = s ^^ t) =
      (∃s' t'.
          (noTick s't' = <>) ∧ u = s' ^^ t's = s' --tr Xt = t' --tr X)

lemma hide_tr_prefix_only_if_lm:

X s u. prefix u (s --tr X) --> (∃t. u = t --tr X ∧ prefix t s)

lemma hide_tr_prefix_only_if:

  prefix u (s --tr X) ==> ∃t. u = t --tr X ∧ prefix t s

lemma hide_tr_prefix_if:

  prefix t s ==> prefix (t --tr X) (s --tr X)

lemma hide_tr_prefix:

  prefix u (s --tr X) = (∃t. u = t --tr X ∧ prefix t s)

lemma hide_tr_nilt_sett_only_if_lm:

s. s --tr X = <> --> sett s ⊆ Ev ` X

lemma hide_tr_nilt_sett_only_if:

  s --tr X = <> ==> sett s ⊆ Ev ` X

lemma hide_tr_nilt_sett_if_lm:

s. sett s ⊆ Ev ` X --> s --tr X = <>

lemma hide_tr_nilt_sett_if:

  sett s ⊆ Ev ` X ==> s --tr X = <>

lemma hide_tr_nilt_sett:

  (s --tr X = <>) = (sett s ⊆ Ev ` X)

lemma hide_tr_sett_subseteq_sett:

  XY ==> sett (u --tr Y) ⊆ sett (u --tr X)

lemma hide_tr_Tick_sett_only_if_lm:

s. s --tr X = <Tick> --> (∃s'. s = s' ^^ <Tick> ∧ sett s' ⊆ Ev ` X ∧ noTick s')

lemma hide_tr_Tick_sett_only_if:

  s --tr X = <Tick> ==> ∃s'. s = s' ^^ <Tick> ∧ sett s' ⊆ Ev ` X ∧ noTick s'

lemma hide_tr_Tick_sett_if:

  sett s ⊆ Ev ` X ==> s --tr X = <>

lemma hide_tr_Tick_sett:

  (s --tr X = <Tick>) = (∃s'. s = s' ^^ <Tick> ∧ sett s' ⊆ Ev ` X ∧ noTick s')

lemma hide_tr_commute:

  u --tr X --tr Y = u --tr Y --tr X

lemma hide_tr_of_hide_tr_subset1:

  XY ==> u --tr X --tr Y = u --tr Y

lemma hide_tr_of_hide_tr_subset2:

  XY ==> u --tr Y --tr X = u --tr Y

lemmas hide_tr_of_hide_tr_subset:

  XY ==> u --tr X --tr Y = u --tr Y
  XY ==> u --tr Y --tr X = u --tr Y

lemmas hide_tr_of_hide_tr_subset:

  XY ==> u --tr X --tr Y = u --tr Y
  XY ==> u --tr Y --tr X = u --tr Y

lemma hide_tr_UNIV_lm:

  u --tr UNIV = <> ∨ u --tr UNIV = <Tick>

lemma hide_tr_UNIV:

  u --tr UNIV = <> ∨ u --tr UNIV = <Tick>

lemma rest_tr_nil:

  <> rest-tr X = <>

lemma rest_tr_Tick:

  <Tick> rest-tr X = <Tick>

lemma rest_tr_notin:

  aX ==> (<Ev a> ^^ s) rest-tr X = s rest-tr X

lemma rest_tr_notin_one:

  aX ==> <Ev a> rest-tr X = <>

lemma rest_tr_in_appt:

  aX ==> (<Ev a> ^^ s) rest-tr X = <Ev a> ^^ s rest-tr X

lemma rest_tr_in:

  aX ==> <Ev a> rest-tr X = <Ev a>

lemma rest_tr_elims:

  [| s rest-tr X = t; [| s = <>; t = <> |] ==> P;
     [| s = <Tick>; t = <Tick> |] ==> P;
     !!a s'. [| s = <Ev a> ^^ s'; s' rest-tr X = t; aX |] ==> P;
     !!a s' t'.
        [| s = <Ev a> ^^ s'; t = <Ev a> ^^ t'; s' rest-tr X = t'; aX |]
        ==> P |]
  ==> P

lemma rest_tr_in_event:

  (e ∈ sett (s rest-tr X)) = ((e ∈ Ev ` Xe = Tick) ∧ e ∈ sett s)

lemma rest_tr_subset_event:

  sett (s rest-tr X) ⊆ insert Tick (Ev ` X)

lemma rest_tr_noTick:

  noTick (s rest-tr X) = noTick s

lemma rest_tr_appt:

  noTick st = <> ==> (s ^^ t) rest-tr X = s rest-tr X ^^ t rest-tr X

lemma rest_tr_decompo:

  noTick st = <>
  ==> (u rest-tr X = s ^^ t) =
      (∃s' t'.
          (noTick s't' = <>) ∧
          u = s' ^^ t's = s' rest-tr Xt = t' rest-tr X)

lemma rest_tr_prefix:

  prefix u (s rest-tr X) = (∃t. u = t rest-tr X ∧ prefix t s)

lemma rest_tr_nilt_sett:

  (s rest-tr X = <>) = (sett s ∩ insert Tick (Ev ` X) = {})

lemma rest_tr_sett_subseteq_sett:

  XY ==> sett (u rest-tr X) ⊆ sett (u rest-tr Y)

lemma rest_tr_Tick_sett:

  (s rest-tr X = <Tick>) =
  (∃s'. s = s' ^^ <Tick> ∧ sett s' ∩ Ev ` X = {} ∧ noTick s')

lemma rest_tr_commute:

  u rest-tr X rest-tr Y = u rest-tr Y rest-tr X

lemma rest_tr_of_rest_tr_subset1:

  XY ==> u rest-tr X rest-tr Y = u rest-tr X

lemma rest_tr_of_rest_tr_subset2:

  XY ==> u rest-tr Y rest-tr X = u rest-tr X

lemmas rest_tr_of_rest_tr_subset:

  XY ==> u rest-tr X rest-tr Y = u rest-tr X
  XY ==> u rest-tr Y rest-tr X = u rest-tr X

lemmas rest_tr_of_rest_tr_subset:

  XY ==> u rest-tr X rest-tr Y = u rest-tr X
  XY ==> u rest-tr Y rest-tr X = u rest-tr X

lemma rest_tr_empty:

  u rest-tr {} = <> ∨ u rest-tr {} = <Tick>