Nominal/Ex/BetaCR.thy
author Cezary Kaliszyk <kaliszyk@in.tum.de>
Tue, 20 Dec 2011 11:40:04 +0900
changeset 3079 a303ef51cd97
parent 3078 abf147627b4b
child 3080 9253984db291
permissions -rw-r--r--
Tuned renaming
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3078
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     1
theory BetaCR
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     2
imports 
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     3
  "../Nominal2"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     4
begin
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     5
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     6
atom_decl name
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     7
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     8
nominal_datatype lam =
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
     9
  Var "name"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    10
| App "lam" "lam"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    11
| Lam x::"name" l::"lam"  binds x in l ("Lam [_]. _" [100, 100] 100)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    12
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    13
nominal_primrec
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    14
  subst :: "lam \<Rightarrow> name \<Rightarrow> lam \<Rightarrow> lam"  ("_ [_ ::= _]" [90, 90, 90] 90)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    15
where
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    16
  "(Var x)[y ::= s] = (if x = y then s else (Var x))"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    17
| "(App t1 t2)[y ::= s] = App (t1[y ::= s]) (t2[y ::= s])"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    18
| "atom x \<sharp> (y, s) \<Longrightarrow> (Lam [x]. t)[y ::= s] = Lam [x].(t[y ::= s])"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    19
  unfolding eqvt_def subst_graph_def
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    20
  apply (rule, perm_simp, rule)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    21
  apply(rule TrueI)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    22
  apply(auto simp add: lam.distinct lam.eq_iff)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    23
  apply(rule_tac y="a" and c="(aa, b)" in lam.strong_exhaust)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    24
  apply(blast)+
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    25
  apply(simp_all add: fresh_star_def fresh_Pair_elim)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    26
  apply (erule_tac c="(ya,sa)" in Abs_lst1_fcb2)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    27
  apply(simp_all add: Abs_fresh_iff)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    28
  apply(simp add: fresh_star_def fresh_Pair)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    29
  apply(simp add: eqvt_at_def atom_eqvt fresh_star_Pair perm_supp_eq)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    30
  apply(simp add: eqvt_at_def atom_eqvt fresh_star_Pair perm_supp_eq)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    31
done
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    32
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    33
termination (eqvt)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    34
  by lexicographic_order
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    35
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    36
lemma fresh_fact:
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    37
  fixes z::"name"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    38
  assumes a: "atom z \<sharp> s"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    39
      and b: "z = y \<or> atom z \<sharp> t"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    40
  shows "atom z \<sharp> t[y ::= s]"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    41
  using a b
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    42
  by (nominal_induct t avoiding: z y s rule: lam.strong_induct)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    43
      (auto simp add: lam.fresh fresh_at_base)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    44
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    45
inductive 
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    46
  beta :: "lam \<Rightarrow> lam \<Rightarrow> bool" (" _ \<longrightarrow>b _" [80,80] 80)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    47
where
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    48
  b1[intro]: "t1 \<longrightarrow>b t2 \<Longrightarrow> App t1 s \<longrightarrow>b App t2 s"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    49
| b2[intro]: "s1 \<longrightarrow>b s2 \<Longrightarrow> App t s1 \<longrightarrow>b App t s2"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    50
| b3[intro]: "t1 \<longrightarrow>b t2 \<Longrightarrow> Lam [x]. t1 \<longrightarrow>b Lam [x]. t2"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    51
| b4[intro]: "atom x \<sharp> s \<Longrightarrow> App (Lam [x]. t) s \<longrightarrow>b t[x ::= s]"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    52
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    53
equivariance beta
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    54
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    55
(* HERE 1 *)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    56
nominal_inductive beta
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    57
  avoids b3: x
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    58
  by (simp_all add: fresh_star_def fresh_Pair lam.fresh fresh_fact)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    59
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    60
(* This also works, but we cannot have them together: *)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    61
(*nominal_inductive beta
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    62
  avoids b4: x
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    63
  by (simp_all add: fresh_star_def fresh_Pair lam.fresh fresh_fact)*)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    64
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    65
(* But I need a combination, possibly with an 'and' syntax:
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    66
nominal_inductive beta
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    67
  avoids b3: x and b4: x
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    68
  by (simp_all add: fresh_star_def fresh_Pair lam.fresh fresh_fact)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    69
*)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    70
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    71
(* The combination should look like this: *)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    72
lemma beta_strong_induct:
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    73
  assumes "x1 \<longrightarrow>b x2"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    74
  and "\<And>t1 t2 s c. \<lbrakk> t1 \<longrightarrow>b t2; \<And>c. P c t1 t2\<rbrakk> \<Longrightarrow> P c (App t1 s) (App t2 s)"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    75
  and "\<And>s1 s2 t c. \<lbrakk> s1 \<longrightarrow>b s2; \<And>c. P c s1 s2\<rbrakk> \<Longrightarrow> P c (App t s1) (App t s2)"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    76
  and "\<And>t1 t2 x c. \<lbrakk>{atom x} \<sharp>* c;  t1 \<longrightarrow>b t2; \<And>c. P c t1 t2\<rbrakk> \<Longrightarrow> P c (Lam [x]. t1) (Lam [x]. t2)"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    77
  and "\<And>x s t c. \<lbrakk>{atom x} \<sharp>* c; atom x \<sharp> s\<rbrakk> \<Longrightarrow> P c (App (Lam [x]. t) s) (t [x ::= s])"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    78
  shows "P (c\<Colon>'a\<Colon>fs) x1 x2"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    79
  sorry
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    80
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    81
inductive
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    82
  beta_star :: "lam \<Rightarrow> lam \<Rightarrow> bool" (" _ \<longrightarrow>b* _" [80,80] 80)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    83
where
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    84
  bs1[intro, simp]: "M \<longrightarrow>b* M"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    85
| bs2[intro]: "\<lbrakk>M1\<longrightarrow>b* M2; M2 \<longrightarrow>b M3\<rbrakk> \<Longrightarrow> M1 \<longrightarrow>b* M3"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    86
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    87
lemma beta_star_trans:
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    88
  assumes "A \<longrightarrow>b* B"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    89
  and     "B \<longrightarrow>b* C"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    90
  shows   "A \<longrightarrow>b* C"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    91
  using assms(2) assms(1)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    92
  by induct auto
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    93
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    94
(* HERE 2: Does not work:*)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    95
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    96
(* equivariance beta_star *)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    97
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    98
(* proved manually below. *)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
    99
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   100
lemma eqvt_helper: "x1 \<longrightarrow>b* x2 \<Longrightarrow>  (p \<bullet> x1) \<longrightarrow>b* (p \<bullet> x2)"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   101
  apply (erule beta_star.induct)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   102
  apply auto
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   103
  using eqvt(1) bs2
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   104
  by blast
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   105
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   106
lemma [eqvt]: "p \<bullet> (x1 \<longrightarrow>b* x2) = ((p \<bullet> x1) \<longrightarrow>b* (p \<bullet> x2))"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   107
  apply rule
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   108
  apply (drule permute_boolE)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   109
  apply (erule eqvt_helper)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   110
  apply (intro permute_boolI)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   111
  apply (drule_tac p="-p" in eqvt_helper)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   112
  by simp
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   113
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   114
definition
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   115
  equ :: "lam \<Rightarrow> lam \<Rightarrow> bool" ("_ \<approx> _")
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   116
where
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   117
  "t \<approx> s \<longleftrightarrow> (\<exists>r. t \<longrightarrow>b* r \<and> s \<longrightarrow>b* r)"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   118
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   119
lemma equ_refl:
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   120
  shows "t \<approx> t"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   121
  unfolding equ_def by auto
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   122
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   123
lemma equ_sym:
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   124
  assumes "t \<approx> s"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   125
  shows "s \<approx> t"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   126
  using assms unfolding equ_def
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   127
  by auto
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   128
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   129
(* can be ported from nominal1 *)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   130
lemma cr:
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   131
  assumes "t \<longrightarrow>b* t1" and "t \<longrightarrow>b* t2" shows "\<exists>t3. t1 \<longrightarrow>b* t3 \<and> t2 \<longrightarrow>b* t3"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   132
  sorry
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   133
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   134
lemma equ_trans:
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   135
  assumes "A \<approx> B" "B \<approx> C"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   136
  shows "A \<approx> C"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   137
  using assms unfolding equ_def
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   138
proof (elim exE conjE)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   139
  fix D E
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   140
  assume a: "A \<longrightarrow>b* D" "B \<longrightarrow>b* D" "B \<longrightarrow>b* E" "C \<longrightarrow>b* E"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   141
  then obtain F where "D \<longrightarrow>b* F" "E \<longrightarrow>b* F" using cr by blast
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   142
  then have "A \<longrightarrow>b* F \<and> C \<longrightarrow>b* F" using a beta_star_trans by blast
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   143
  then show "\<exists>F. A \<longrightarrow>b* F \<and> C \<longrightarrow>b* F" by blast
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   144
qed
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   145
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   146
lemma App_beta: "A \<longrightarrow>b* B \<Longrightarrow> C \<longrightarrow>b* D \<Longrightarrow> App A C \<longrightarrow>b* App B D"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   147
  apply (erule beta_star.induct)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   148
  apply auto
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   149
  apply (erule beta_star.induct)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   150
  apply auto
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   151
  done
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   152
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   153
lemma Lam_beta: "A \<longrightarrow>b* B \<Longrightarrow> Lam [x]. A \<longrightarrow>b* Lam [x]. B"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   154
  by (erule beta_star.induct) auto
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   155
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   156
lemma [quot_respect]:
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   157
  shows "(op = ===> equ) Var Var"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   158
  and   "(equ ===> equ ===> equ) App App"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   159
  and   "(op = ===> equ ===> equ) BetaCR.Lam BetaCR.Lam"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   160
  unfolding fun_rel_def equ_def
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   161
  apply auto
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   162
  apply (rule_tac x="App r ra" in exI)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   163
  apply (auto simp add: App_beta)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   164
  apply (rule_tac x="Lam [x]. r" in exI)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   165
  apply (auto simp add: Lam_beta)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   166
  done
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   167
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   168
lemma beta_subst1_pre: "B \<longrightarrow>b C \<Longrightarrow> A [x ::= B] \<longrightarrow>b* A [x ::= C]"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   169
  by (nominal_induct A avoiding: x B C rule: lam.strong_induct)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   170
     (auto simp add: App_beta Lam_beta)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   171
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   172
lemma beta_subst1: "B \<longrightarrow>b* C \<Longrightarrow> A [x ::= B] \<longrightarrow>b* A [x ::= C]"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   173
  apply (erule beta_star.induct)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   174
  apply auto
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   175
  apply (subgoal_tac "A [x ::= M2] \<longrightarrow>b* A [x ::= M3]")
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   176
  apply (rotate_tac 1)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   177
  apply (erule beta_star_trans)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   178
  apply assumption
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   179
  apply (simp add: beta_subst1_pre)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   180
  done
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   181
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   182
lemma forget:
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   183
  shows "atom x \<sharp> t \<Longrightarrow> t[x ::= s] = t"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   184
  by (nominal_induct t avoiding: x s rule: lam.strong_induct)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   185
     (auto simp add: lam.fresh fresh_at_base)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   186
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   187
lemma substitution_lemma:
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   188
  assumes a: "x \<noteq> y" "atom x \<sharp> u"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   189
  shows "t[x ::= s][y ::= u] = t[y ::= u][x ::= s[y ::= u]]"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   190
  using a
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   191
  by (nominal_induct t avoiding: x y s u rule: lam.strong_induct)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   192
     (auto simp add: fresh_fact forget)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   193
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   194
lemma beta_subst2_pre:
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   195
  assumes "A \<longrightarrow>b B" shows "A [x ::= C] \<longrightarrow>b* B [x ::= C]"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   196
  using assms
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   197
(* HERE 3: nominal_induct doesn't work - leaves the assumption *)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   198
(*  apply (nominal_induct avoiding: x C rule: beta_strong_induct)*)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   199
  apply -
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   200
  apply (erule beta_strong_induct[of A B "\<lambda>c A B. A [(fst c) ::= (snd c)] \<longrightarrow>b* B [(fst c) ::= (snd c)]" "(x, C)", simplified])
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   201
  apply (auto simp add: App_beta fresh_star_def fresh_Pair Lam_beta)[3]
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   202
  apply (subst substitution_lemma)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   203
  apply (auto simp add: fresh_star_def fresh_Pair fresh_at_base)[2]
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   204
  apply (auto simp add: fresh_star_def fresh_Pair)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   205
  apply (rule beta_star.intros)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   206
  defer
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   207
  apply (subst beta.intros)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   208
  apply (auto simp add: fresh_fact)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   209
  done
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   210
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   211
lemma beta_subst2: "A \<longrightarrow>b* B \<Longrightarrow> A [x ::= C] \<longrightarrow>b* B [x ::= C]"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   212
  apply (erule beta_star.induct)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   213
  apply auto
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   214
  apply (subgoal_tac "M2[x ::= C] \<longrightarrow>b* M3[x ::= C]")
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   215
  apply (rotate_tac 1)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   216
  apply (erule beta_star_trans)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   217
  apply assumption
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   218
  apply (simp add: beta_subst2_pre)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   219
  done
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   220
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   221
lemma beta_subst: "A \<longrightarrow>b* B \<Longrightarrow> C \<longrightarrow>b* D \<Longrightarrow> A [x ::= C] \<longrightarrow>b* B [x ::= D]"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   222
  using beta_subst1 beta_subst2 beta_star_trans by metis
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   223
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   224
lemma [quot_respect]:
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   225
  shows "(equ ===> op = ===> equ ===> equ) subst subst"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   226
unfolding fun_rel_def equ_def
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   227
apply auto
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   228
apply (rule_tac x="r [xa ::= ra]" in exI)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   229
apply (simp add: beta_subst)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   230
done
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   231
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   232
lemma [quot_respect]:
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   233
  shows "(op = ===> equ ===> equ) permute permute"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   234
  unfolding fun_rel_def equ_def
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   235
  apply (auto intro: eqvts)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   236
  apply (rule_tac x="x \<bullet> r" in exI)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   237
  using eqvts(1) permute_boolI by metis
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   238
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   239
quotient_type qlam = lam / equ
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   240
  by (auto intro!: equivpI reflpI sympI transpI simp add: equ_refl equ_sym)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   241
     (erule equ_trans, assumption)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   242
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   243
quotient_definition "QVar::name \<Rightarrow> qlam" is Var
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   244
quotient_definition "QApp::qlam \<Rightarrow> qlam \<Rightarrow> qlam" is App
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   245
quotient_definition QLam ("QLam [_]._")
3079
a303ef51cd97 Tuned renaming
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents: 3078
diff changeset
   246
  where "QLam::name \<Rightarrow> qlam \<Rightarrow> qlam" is BetaCR.Lam
3078
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   247
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   248
lemmas qlam_strong_induct = lam.strong_induct[quot_lifted]
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   249
lemmas qlam_induct = lam.induct[quot_lifted]
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   250
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   251
instantiation qlam :: pt
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   252
begin
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   253
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   254
quotient_definition "permute_qlam::perm \<Rightarrow> qlam \<Rightarrow> qlam" 
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   255
  is "permute::perm \<Rightarrow> lam \<Rightarrow> lam"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   256
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   257
instance
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   258
apply default
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   259
apply(descending)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   260
apply(simp)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   261
apply(rule equ_refl)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   262
apply(descending)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   263
apply(simp)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   264
apply(rule equ_refl)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   265
done
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   266
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   267
end
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   268
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   269
lemma qlam_perm[simp, eqvt]:
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   270
  shows "p \<bullet> (QVar x) = QVar (p \<bullet> x)"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   271
  and "p \<bullet> (QApp t s) = QApp (p \<bullet> t) (p \<bullet> s)"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   272
  and "p \<bullet> (QLam [x].t) = QLam [p \<bullet> x].(p \<bullet> t)"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   273
  by(descending, simp add: equ_refl)+
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   274
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   275
lemma qlam_supports:
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   276
  shows "{atom x} supports (QVar x)"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   277
  and   "supp (t, s) supports (QApp t s)"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   278
  and   "supp (x, t) supports (QLam [x].t)"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   279
unfolding supports_def fresh_def[symmetric]
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   280
by (auto simp add: swap_fresh_fresh)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   281
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   282
lemma qlam_fs:
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   283
  fixes t::"qlam"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   284
  shows "finite (supp t)"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   285
apply(induct t rule: qlam_induct)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   286
apply(rule supports_finite)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   287
apply(rule qlam_supports)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   288
apply(simp)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   289
apply(rule supports_finite)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   290
apply(rule qlam_supports)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   291
apply(simp add: supp_Pair)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   292
apply(rule supports_finite)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   293
apply(rule qlam_supports)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   294
apply(simp add: supp_Pair finite_supp)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   295
done
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   296
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   297
instantiation qlam :: fs
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   298
begin
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   299
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   300
instance
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   301
apply(default)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   302
apply(rule qlam_fs)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   303
done
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   304
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   305
end
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   306
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   307
quotient_definition subst_qlam ("_[_ ::q= _]")
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   308
  where "subst_qlam::qlam \<Rightarrow> name \<Rightarrow> qlam \<Rightarrow> qlam" is subst  
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   309
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   310
lemmas qsubst = subst.simps(1-2)[quot_lifted]
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   311
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   312
definition
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   313
  "Supp t = \<Inter>{supp s | s. s \<approx> t}"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   314
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   315
lemma [quot_respect]:
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   316
  shows "(equ ===> op=) Supp Supp"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   317
  unfolding fun_rel_def Supp_def
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   318
  apply(intro allI impI)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   319
  apply(rule_tac f="Inter" in arg_cong)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   320
  apply(auto)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   321
  apply (metis equ_trans)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   322
  by (metis equivp_def qlam_equivp)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   323
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   324
quotient_definition "supp_qlam::qlam \<Rightarrow> atom set" 
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   325
  is "Supp::lam \<Rightarrow> atom set"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   326
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   327
lemma Supp_supp:
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   328
  "Supp t \<subseteq> supp t"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   329
unfolding Supp_def
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   330
apply(auto)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   331
apply(drule_tac x="supp t" in spec)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   332
apply(auto simp add: equ_refl)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   333
done
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   334
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   335
lemma Supp_Lam:
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   336
  "atom a \<notin> Supp (Lam [a].t)"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   337
proof -
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   338
  have "atom a \<notin> supp (Lam [a].t)" by (simp add: lam.supp)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   339
  then show ?thesis using Supp_supp
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   340
    by blast
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   341
qed
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   342
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   343
lemma [eqvt]: "(p \<bullet> (a \<approx> b)) = ((p \<bullet> a) \<approx> (p \<bullet> b))"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   344
  unfolding equ_def
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   345
  by perm_simp rule
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   346
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   347
lemma [eqvt]: "p \<bullet> (Supp x) = Supp (p \<bullet> x)"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   348
  unfolding Supp_def
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   349
  by perm_simp rule
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   350
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   351
lemmas s = Supp_Lam[quot_lifted]
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   352
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   353
lemma var_beta_pre: "s \<longrightarrow>b* r \<Longrightarrow> s = Var name \<Longrightarrow> r = Var name"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   354
  apply (induct rule: beta_star.induct)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   355
  apply simp
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   356
  apply (subgoal_tac "M2 = Var name")
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   357
  apply (thin_tac "M1 \<longrightarrow>b* M2")
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   358
  apply (thin_tac "M1 = Var name")
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   359
  apply (thin_tac "M1 = Var name \<Longrightarrow> M2 = Var name")
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   360
  defer
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   361
  apply simp
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   362
  apply (erule_tac beta.cases)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   363
  apply simp_all
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   364
  done
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   365
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   366
lemma var_beta: "Var name \<longrightarrow>b* r \<longleftrightarrow> r = Var name"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   367
  by (auto simp add: var_beta_pre)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   368
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   369
lemma qlam_eq_iff:
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   370
  "(QVar n = QVar m) = (n = m)"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   371
  apply descending unfolding equ_def var_beta by auto
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   372
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   373
lemma "supp (QVar n) = {atom n}"
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   374
  unfolding supp_def
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   375
  apply simp
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   376
  unfolding qlam_eq_iff
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   377
  apply (fold supp_def)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   378
  apply (simp add: supp_at_base)
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   379
  done
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   380
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   381
end
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   382
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   383
abf147627b4b Retry Beta using a reduction relation and its reflexive-symmetric-transitive closure.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff changeset
   384