src/HOL/Nominal/Examples/Standardization.thy
author huffman
Mon, 23 Jan 2012 17:29:19 +0100
changeset 46317 80dccedd6c14
parent 46129 229fcbebf732
child 47397 d654c73e4b12
permissions -rw-r--r--
generalize type of List.listrel
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
27623
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
     1
(*  Title:      HOL/Nominal/Examples/Standardization.thy
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
     2
    Author:     Stefan Berghofer and Tobias Nipkow
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
     3
    Copyright   2005, 2008 TU Muenchen
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
     4
*)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
     5
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
     6
header {* Standardization *}
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
     7
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
     8
theory Standardization
45966
03ce2b2a29a2 tuned proofs
haftmann
parents: 44890
diff changeset
     9
imports "../Nominal"
27623
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    10
begin
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    11
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    12
text {*
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    13
The proof of the standardization theorem, as well as most of the theorems about
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    14
lambda calculus in the following sections, are taken from @{text "HOL/Lambda"}.
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    15
*}
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    16
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    17
subsection {* Lambda terms *}
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    18
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    19
atom_decl name
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    20
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    21
nominal_datatype lam =
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    22
  Var "name"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    23
| App "lam" "lam" (infixl "\<degree>" 200)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    24
| Lam "\<guillemotleft>name\<guillemotright>lam" ("Lam [_]._" [0, 10] 10)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    25
29097
68245155eb58 Modified nominal_primrec to make it work with local theories, unified syntax
berghofe
parents: 27623
diff changeset
    26
instantiation lam :: size
68245155eb58 Modified nominal_primrec to make it work with local theories, unified syntax
berghofe
parents: 27623
diff changeset
    27
begin
27623
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    28
29097
68245155eb58 Modified nominal_primrec to make it work with local theories, unified syntax
berghofe
parents: 27623
diff changeset
    29
nominal_primrec size_lam
68245155eb58 Modified nominal_primrec to make it work with local theories, unified syntax
berghofe
parents: 27623
diff changeset
    30
where
27623
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    31
  "size (Var n) = 0"
29097
68245155eb58 Modified nominal_primrec to make it work with local theories, unified syntax
berghofe
parents: 27623
diff changeset
    32
| "size (t \<degree> u) = size t + size u + 1"
68245155eb58 Modified nominal_primrec to make it work with local theories, unified syntax
berghofe
parents: 27623
diff changeset
    33
| "size (Lam [x].t) = size t + 1"
27623
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    34
  apply finite_guess+
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    35
  apply (rule TrueI)+
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    36
  apply (simp add: fresh_nat)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    37
  apply fresh_guess+
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    38
  done
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    39
29097
68245155eb58 Modified nominal_primrec to make it work with local theories, unified syntax
berghofe
parents: 27623
diff changeset
    40
instance ..
68245155eb58 Modified nominal_primrec to make it work with local theories, unified syntax
berghofe
parents: 27623
diff changeset
    41
68245155eb58 Modified nominal_primrec to make it work with local theories, unified syntax
berghofe
parents: 27623
diff changeset
    42
end
27623
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    43
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    44
nominal_primrec
29097
68245155eb58 Modified nominal_primrec to make it work with local theories, unified syntax
berghofe
parents: 27623
diff changeset
    45
  subst :: "lam \<Rightarrow> name \<Rightarrow> lam \<Rightarrow> lam"  ("_[_::=_]" [300, 0, 0] 300)
68245155eb58 Modified nominal_primrec to make it work with local theories, unified syntax
berghofe
parents: 27623
diff changeset
    46
where
27623
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    47
  subst_Var: "(Var x)[y::=s] = (if x=y then s else (Var x))"
29097
68245155eb58 Modified nominal_primrec to make it work with local theories, unified syntax
berghofe
parents: 27623
diff changeset
    48
| subst_App: "(t\<^isub>1 \<degree> t\<^isub>2)[y::=s] = t\<^isub>1[y::=s] \<degree> t\<^isub>2[y::=s]"
68245155eb58 Modified nominal_primrec to make it work with local theories, unified syntax
berghofe
parents: 27623
diff changeset
    49
| subst_Lam: "x \<sharp> (y, s) \<Longrightarrow> (Lam [x].t)[y::=s] = (Lam [x].(t[y::=s]))"
27623
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    50
  apply(finite_guess)+
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    51
  apply(rule TrueI)+
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    52
  apply(simp add: abs_fresh)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    53
  apply(fresh_guess)+
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    54
  done
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    55
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    56
lemma subst_eqvt [eqvt]:
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    57
  "(pi::name prm) \<bullet> (t[x::=u]) = (pi \<bullet> t)[(pi \<bullet> x)::=(pi \<bullet> u)]"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    58
  by (nominal_induct t avoiding: x u rule: lam.strong_induct)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    59
    (perm_simp add: fresh_bij)+
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    60
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    61
lemma subst_rename:
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    62
  "y \<sharp> t \<Longrightarrow> ([(y, x)] \<bullet> t)[y::=u] = t[x::=u]"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    63
  by (nominal_induct t avoiding: x y u rule: lam.strong_induct)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    64
    (simp_all add: fresh_atm calc_atm abs_fresh)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    65
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    66
lemma fresh_subst: 
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    67
  "(x::name) \<sharp> t \<Longrightarrow> x \<sharp> u \<Longrightarrow> x \<sharp> t[y::=u]"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    68
  by (nominal_induct t avoiding: x y u rule: lam.strong_induct)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    69
    (auto simp add: abs_fresh fresh_atm)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    70
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    71
lemma fresh_subst': 
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    72
  "(x::name) \<sharp> u \<Longrightarrow> x \<sharp> t[x::=u]"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    73
  by (nominal_induct t avoiding: x u rule: lam.strong_induct)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    74
    (auto simp add: abs_fresh fresh_atm)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    75
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    76
lemma subst_forget: "(x::name) \<sharp> t \<Longrightarrow> t[x::=u] = t"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    77
  by (nominal_induct t avoiding: x u rule: lam.strong_induct)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    78
    (auto simp add: abs_fresh fresh_atm)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    79
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    80
lemma subst_subst:
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    81
  "x \<noteq> y \<Longrightarrow> x \<sharp> v \<Longrightarrow> t[y::=v][x::=u[y::=v]] = t[x::=u][y::=v]"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    82
  by (nominal_induct t avoiding: x y u v rule: lam.strong_induct)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    83
    (auto simp add: fresh_subst subst_forget)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    84
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    85
declare subst_Var [simp del]
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    86
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    87
lemma subst_eq [simp]: "(Var x)[x::=u] = u"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    88
  by (simp add: subst_Var)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    89
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    90
lemma subst_neq [simp]: "x \<noteq> y \<Longrightarrow> (Var x)[y::=u] = Var x"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    91
  by (simp add: subst_Var)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    92
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    93
inductive beta :: "lam \<Rightarrow> lam \<Rightarrow> bool"  (infixl "\<rightarrow>\<^sub>\<beta>" 50)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    94
  where
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    95
    beta: "x \<sharp> t \<Longrightarrow> (Lam [x].s) \<degree> t \<rightarrow>\<^sub>\<beta> s[x::=t]"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    96
  | appL [simp, intro!]: "s \<rightarrow>\<^sub>\<beta> t \<Longrightarrow> s \<degree> u \<rightarrow>\<^sub>\<beta> t \<degree> u"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    97
  | appR [simp, intro!]: "s \<rightarrow>\<^sub>\<beta> t \<Longrightarrow> u \<degree> s \<rightarrow>\<^sub>\<beta> u \<degree> t"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    98
  | abs [simp, intro!]: "s \<rightarrow>\<^sub>\<beta> t \<Longrightarrow> (Lam [x].s) \<rightarrow>\<^sub>\<beta> (Lam [x].t)"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
    99
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   100
equivariance beta
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   101
nominal_inductive beta
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   102
  by (simp_all add: abs_fresh fresh_subst')
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   103
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   104
lemma better_beta [simp, intro!]: "(Lam [x].s) \<degree> t \<rightarrow>\<^sub>\<beta> s[x::=t]"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   105
proof -
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   106
  obtain y::name where y: "y \<sharp> (x, s, t)"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   107
    by (rule exists_fresh) (rule fin_supp)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   108
  then have "y \<sharp> t" by simp
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   109
  then have "(Lam [y]. [(y, x)] \<bullet> s) \<degree> t \<rightarrow>\<^sub>\<beta> ([(y, x)] \<bullet> s)[y::=t]"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   110
    by (rule beta)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   111
  moreover from y have "(Lam [x].s) = (Lam [y]. [(y, x)] \<bullet> s)"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   112
    by (auto simp add: lam.inject alpha' fresh_prod fresh_atm)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   113
  ultimately show ?thesis using y by (simp add: subst_rename)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   114
qed
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   115
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   116
abbreviation
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   117
  beta_reds :: "lam \<Rightarrow> lam \<Rightarrow> bool"  (infixl "\<rightarrow>\<^sub>\<beta>\<^sup>*" 50) where
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   118
  "s \<rightarrow>\<^sub>\<beta>\<^sup>* t \<equiv> beta\<^sup>*\<^sup>* s t"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   119
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   120
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   121
subsection {* Application of a term to a list of terms *}
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   122
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   123
abbreviation
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   124
  list_application :: "lam \<Rightarrow> lam list \<Rightarrow> lam"  (infixl "\<degree>\<degree>" 150) where
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   125
  "t \<degree>\<degree> ts \<equiv> foldl (op \<degree>) t ts"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   126
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   127
lemma apps_eq_tail_conv [iff]: "(r \<degree>\<degree> ts = s \<degree>\<degree> ts) = (r = s)"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   128
  by (induct ts rule: rev_induct) (auto simp add: lam.inject)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   129
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   130
lemma Var_eq_apps_conv [iff]: "(Var m = s \<degree>\<degree> ss) = (Var m = s \<and> ss = [])"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   131
  by (induct ss arbitrary: s) auto
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   132
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   133
lemma Var_apps_eq_Var_apps_conv [iff]:
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   134
    "(Var m \<degree>\<degree> rs = Var n \<degree>\<degree> ss) = (m = n \<and> rs = ss)"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   135
  apply (induct rs arbitrary: ss rule: rev_induct)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   136
   apply (simp add: lam.inject)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   137
   apply blast
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   138
  apply (induct_tac ss rule: rev_induct)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   139
   apply (auto simp add: lam.inject)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   140
  done
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   141
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   142
lemma App_eq_foldl_conv:
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   143
  "(r \<degree> s = t \<degree>\<degree> ts) =
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   144
    (if ts = [] then r \<degree> s = t
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   145
    else (\<exists>ss. ts = ss @ [s] \<and> r = t \<degree>\<degree> ss))"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   146
  apply (rule_tac xs = ts in rev_exhaust)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   147
   apply (auto simp add: lam.inject)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   148
  done
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   149
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   150
lemma Abs_eq_apps_conv [iff]:
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   151
    "((Lam [x].r) = s \<degree>\<degree> ss) = ((Lam [x].r) = s \<and> ss = [])"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   152
  by (induct ss rule: rev_induct) auto
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   153
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   154
lemma apps_eq_Abs_conv [iff]: "(s \<degree>\<degree> ss = (Lam [x].r)) = (s = (Lam [x].r) \<and> ss = [])"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   155
  by (induct ss rule: rev_induct) auto
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   156
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   157
lemma Abs_App_neq_Var_apps [iff]:
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   158
    "(Lam [x].s) \<degree> t \<noteq> Var n \<degree>\<degree> ss"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   159
  by (induct ss arbitrary: s t rule: rev_induct) (auto simp add: lam.inject)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   160
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   161
lemma Var_apps_neq_Abs_apps [iff]:
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   162
    "Var n \<degree>\<degree> ts \<noteq> (Lam [x].r) \<degree>\<degree> ss"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   163
  apply (induct ss arbitrary: ts rule: rev_induct)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   164
   apply simp
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   165
  apply (induct_tac ts rule: rev_induct)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   166
   apply (auto simp add: lam.inject)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   167
  done
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   168
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   169
lemma ex_head_tail:
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   170
  "\<exists>ts h. t = h \<degree>\<degree> ts \<and> ((\<exists>n. h = Var n) \<or> (\<exists>x u. h = (Lam [x].u)))"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   171
  apply (induct t rule: lam.induct)
39459
7753083c00e6 tidied a few proofs
paulson
parents: 32960
diff changeset
   172
    apply (metis foldl_Nil)
7753083c00e6 tidied a few proofs
paulson
parents: 32960
diff changeset
   173
   apply (metis foldl_Cons foldl_Nil foldl_append)
7753083c00e6 tidied a few proofs
paulson
parents: 32960
diff changeset
   174
  apply (metis foldl_Nil)
27623
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   175
  done
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   176
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   177
lemma size_apps [simp]:
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   178
  "size (r \<degree>\<degree> rs) = size r + foldl (op +) 0 (map size rs) + length rs"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   179
  by (induct rs rule: rev_induct) auto
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   180
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   181
lemma lem0: "(0::nat) < k \<Longrightarrow> m \<le> n \<Longrightarrow> m < n + k"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   182
  by simp
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   183
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   184
lemma subst_map [simp]:
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   185
    "(t \<degree>\<degree> ts)[x::=u] = t[x::=u] \<degree>\<degree> map (\<lambda>t. t[x::=u]) ts"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   186
  by (induct ts arbitrary: t) simp_all
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   187
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   188
lemma app_last: "(t \<degree>\<degree> ts) \<degree> u = t \<degree>\<degree> (ts @ [u])"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   189
  by simp
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   190
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   191
lemma perm_apps [eqvt]:
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   192
  "(pi::name prm) \<bullet> (t \<degree>\<degree> ts) = ((pi \<bullet> t) \<degree>\<degree> (pi \<bullet> ts))"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   193
  by (induct ts rule: rev_induct) (auto simp add: append_eqvt)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   194
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   195
lemma fresh_apps [simp]: "(x::name) \<sharp> (t \<degree>\<degree> ts) = (x \<sharp> t \<and> x \<sharp> ts)"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   196
  by (induct ts rule: rev_induct)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   197
    (auto simp add: fresh_list_append fresh_list_nil fresh_list_cons)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   198
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   199
text {* A customized induction schema for @{text "\<degree>\<degree>"}. *}
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   200
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   201
lemma lem:
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   202
  assumes "\<And>n ts (z::'a::fs_name). (\<And>z. \<forall>t \<in> set ts. P z t) \<Longrightarrow> P z (Var n \<degree>\<degree> ts)"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   203
    and "\<And>x u ts z. x \<sharp> z \<Longrightarrow> (\<And>z. P z u) \<Longrightarrow> (\<And>z. \<forall>t \<in> set ts. P z t) \<Longrightarrow> P z ((Lam [x].u) \<degree>\<degree> ts)"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   204
  shows "size t = n \<Longrightarrow> P z t"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   205
  apply (induct n arbitrary: t z rule: nat_less_induct)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   206
  apply (cut_tac t = t in ex_head_tail)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   207
  apply clarify
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   208
  apply (erule disjE)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   209
   apply clarify
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   210
   apply (rule assms)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   211
   apply clarify
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   212
   apply (erule allE, erule impE)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   213
    prefer 2
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   214
    apply (erule allE, erule impE, rule refl, erule spec)
46129
229fcbebf732 tuned proofs
haftmann
parents: 45966
diff changeset
   215
    apply simp
229fcbebf732 tuned proofs
haftmann
parents: 45966
diff changeset
   216
   apply (clarsimp simp add: foldr_conv_foldl [symmetric] foldr_def fold_plus_listsum_rev listsum_map_remove1)
27623
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   217
  apply clarify
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   218
  apply (subgoal_tac "\<exists>y::name. y \<sharp> (x, u, z)")
39459
7753083c00e6 tidied a few proofs
paulson
parents: 32960
diff changeset
   219
   prefer 2
7753083c00e6 tidied a few proofs
paulson
parents: 32960
diff changeset
   220
   apply (blast intro: exists_fresh' fin_supp) 
27623
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   221
  apply (erule exE)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   222
  apply (subgoal_tac "(Lam [x].u) = (Lam [y].([(y, x)] \<bullet> u))")
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   223
  prefer 2
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   224
  apply (auto simp add: lam.inject alpha' fresh_prod fresh_atm)[]
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   225
  apply (simp (no_asm_simp))
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   226
  apply (rule assms)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   227
  apply (simp add: fresh_prod)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   228
   apply (erule allE, erule impE)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   229
    prefer 2
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   230
    apply (erule allE, erule impE, rule refl, erule spec)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   231
   apply simp
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   232
  apply clarify
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   233
  apply (erule allE, erule impE)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   234
   prefer 2
39459
7753083c00e6 tidied a few proofs
paulson
parents: 32960
diff changeset
   235
   apply blast   
7753083c00e6 tidied a few proofs
paulson
parents: 32960
diff changeset
   236
  apply (force intro: le_imp_less_Suc trans_le_add1 trans_le_add2 elem_le_sum) 
27623
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   237
  done
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   238
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   239
theorem Apps_lam_induct:
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   240
  assumes "\<And>n ts (z::'a::fs_name). (\<And>z. \<forall>t \<in> set ts. P z t) \<Longrightarrow> P z (Var n \<degree>\<degree> ts)"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   241
    and "\<And>x u ts z. x \<sharp> z \<Longrightarrow> (\<And>z. P z u) \<Longrightarrow> (\<And>z. \<forall>t \<in> set ts. P z t) \<Longrightarrow> P z ((Lam [x].u) \<degree>\<degree> ts)"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   242
  shows "P z t"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   243
  apply (rule_tac t = t and z = z in lem)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   244
    prefer 3
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   245
    apply (rule refl)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   246
    using assms apply blast+
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   247
  done
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   248
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   249
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   250
subsection {* Congruence rules *}
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   251
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   252
lemma apps_preserves_beta [simp]:
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   253
    "r \<rightarrow>\<^sub>\<beta> s \<Longrightarrow> r \<degree>\<degree> ss \<rightarrow>\<^sub>\<beta> s \<degree>\<degree> ss"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   254
  by (induct ss rule: rev_induct) auto
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   255
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   256
lemma rtrancl_beta_Abs [intro!]:
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   257
    "s \<rightarrow>\<^sub>\<beta>\<^sup>* s' \<Longrightarrow> (Lam [x].s) \<rightarrow>\<^sub>\<beta>\<^sup>* (Lam [x].s')"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   258
  by (induct set: rtranclp) (blast intro: rtranclp.rtrancl_into_rtrancl)+
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   259
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   260
lemma rtrancl_beta_AppL:
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   261
    "s \<rightarrow>\<^sub>\<beta>\<^sup>* s' \<Longrightarrow> s \<degree> t \<rightarrow>\<^sub>\<beta>\<^sup>* s' \<degree> t"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   262
  by (induct set: rtranclp) (blast intro: rtranclp.rtrancl_into_rtrancl)+
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   263
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   264
lemma rtrancl_beta_AppR:
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   265
    "t \<rightarrow>\<^sub>\<beta>\<^sup>* t' \<Longrightarrow> s \<degree> t \<rightarrow>\<^sub>\<beta>\<^sup>* s \<degree> t'"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   266
  by (induct set: rtranclp) (blast intro: rtranclp.rtrancl_into_rtrancl)+
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   267
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   268
lemma rtrancl_beta_App [intro]:
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   269
    "s \<rightarrow>\<^sub>\<beta>\<^sup>* s' \<Longrightarrow> t \<rightarrow>\<^sub>\<beta>\<^sup>* t' \<Longrightarrow> s \<degree> t \<rightarrow>\<^sub>\<beta>\<^sup>* s' \<degree> t'"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   270
  by (blast intro!: rtrancl_beta_AppL rtrancl_beta_AppR intro: rtranclp_trans)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   271
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   272
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   273
subsection {* Lifting an order to lists of elements *}
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   274
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   275
definition
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   276
  step1 :: "('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> 'a list \<Rightarrow> 'a list \<Rightarrow> bool" where
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   277
  "step1 r =
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   278
    (\<lambda>ys xs. \<exists>us z z' vs. xs = us @ z # vs \<and> r z' z \<and> ys =
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   279
      us @ z' # vs)"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   280
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   281
lemma not_Nil_step1 [iff]: "\<not> step1 r [] xs"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   282
  apply (unfold step1_def)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   283
  apply blast
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   284
  done
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   285
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   286
lemma not_step1_Nil [iff]: "\<not> step1 r xs []"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   287
  apply (unfold step1_def)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   288
  apply blast
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   289
  done
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   290
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   291
lemma Cons_step1_Cons [iff]:
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   292
    "(step1 r (y # ys) (x # xs)) =
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   293
      (r y x \<and> xs = ys \<or> x = y \<and> step1 r ys xs)"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   294
  apply (unfold step1_def)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   295
  apply (rule iffI)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   296
   apply (erule exE)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   297
   apply (rename_tac ts)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   298
   apply (case_tac ts)
44890
22f665a2e91c new fastforce replacing fastsimp - less confusing name
nipkow
parents: 39779
diff changeset
   299
    apply fastforce
27623
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   300
   apply force
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   301
  apply (erule disjE)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   302
   apply blast
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   303
  apply (blast intro: Cons_eq_appendI)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   304
  done
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   305
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   306
lemma append_step1I:
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   307
  "step1 r ys xs \<and> vs = us \<or> ys = xs \<and> step1 r vs us
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   308
    \<Longrightarrow> step1 r (ys @ vs) (xs @ us)"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   309
  apply (unfold step1_def)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   310
  apply auto
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   311
   apply blast
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   312
  apply (blast intro: append_eq_appendI)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   313
  done
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   314
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   315
lemma Cons_step1E [elim!]:
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   316
  assumes "step1 r ys (x # xs)"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   317
    and "\<And>y. ys = y # xs \<Longrightarrow> r y x \<Longrightarrow> R"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   318
    and "\<And>zs. ys = x # zs \<Longrightarrow> step1 r zs xs \<Longrightarrow> R"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   319
  shows R
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   320
  using assms
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   321
  apply (cases ys)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   322
   apply (simp add: step1_def)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   323
  apply blast
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   324
  done
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   325
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   326
lemma Snoc_step1_SnocD:
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   327
  "step1 r (ys @ [y]) (xs @ [x])
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   328
    \<Longrightarrow> (step1 r ys xs \<and> y = x \<or> ys = xs \<and> r y x)"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   329
  apply (unfold step1_def)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   330
  apply (clarify del: disjCI)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   331
  apply (rename_tac vs)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   332
  apply (rule_tac xs = vs in rev_exhaust)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   333
   apply force
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   334
  apply simp
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   335
  apply blast
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   336
  done
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   337
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   338
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   339
subsection {* Lifting beta-reduction to lists *}
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   340
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   341
abbreviation
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   342
  list_beta :: "lam list \<Rightarrow> lam list \<Rightarrow> bool"  (infixl "[\<rightarrow>\<^sub>\<beta>]\<^sub>1" 50) where
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   343
  "rs [\<rightarrow>\<^sub>\<beta>]\<^sub>1 ss \<equiv> step1 beta rs ss"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   344
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   345
lemma head_Var_reduction:
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   346
  "Var n \<degree>\<degree> rs \<rightarrow>\<^sub>\<beta> v \<Longrightarrow> \<exists>ss. rs [\<rightarrow>\<^sub>\<beta>]\<^sub>1 ss \<and> v = Var n \<degree>\<degree> ss"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   347
  apply (induct u \<equiv> "Var n \<degree>\<degree> rs" v arbitrary: rs set: beta)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   348
     apply simp
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   349
    apply (rule_tac xs = rs in rev_exhaust)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   350
     apply simp
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   351
    apply (atomize, force intro: append_step1I iff: lam.inject)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   352
   apply (rule_tac xs = rs in rev_exhaust)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   353
    apply simp
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   354
    apply (auto 0 3 intro: disjI2 [THEN append_step1I] simp add: lam.inject)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   355
  done
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   356
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   357
lemma apps_betasE [case_names appL appR beta, consumes 1]:
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   358
  assumes major: "r \<degree>\<degree> rs \<rightarrow>\<^sub>\<beta> s"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   359
    and cases: "\<And>r'. r \<rightarrow>\<^sub>\<beta> r' \<Longrightarrow> s = r' \<degree>\<degree> rs \<Longrightarrow> R"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   360
      "\<And>rs'. rs [\<rightarrow>\<^sub>\<beta>]\<^sub>1 rs' \<Longrightarrow> s = r \<degree>\<degree> rs' \<Longrightarrow> R"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   361
      "\<And>t u us. (x \<sharp> r \<Longrightarrow> r = (Lam [x].t) \<and> rs = u # us \<and> s = t[x::=u] \<degree>\<degree> us) \<Longrightarrow> R"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   362
  shows R
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   363
proof -
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   364
  from major have
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   365
   "(\<exists>r'. r \<rightarrow>\<^sub>\<beta> r' \<and> s = r' \<degree>\<degree> rs) \<or>
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   366
    (\<exists>rs'. rs [\<rightarrow>\<^sub>\<beta>]\<^sub>1 rs' \<and> s = r \<degree>\<degree> rs') \<or>
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   367
    (\<exists>t u us. x \<sharp> r \<longrightarrow> r = (Lam [x].t) \<and> rs = u # us \<and> s = t[x::=u] \<degree>\<degree> us)"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   368
    apply (nominal_induct u \<equiv> "r \<degree>\<degree> rs" s avoiding: x r rs rule: beta.strong_induct)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   369
    apply (simp add: App_eq_foldl_conv)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   370
    apply (split split_if_asm)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   371
    apply simp
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   372
    apply blast
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   373
    apply simp
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   374
    apply (rule impI)+
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   375
    apply (rule disjI2)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   376
    apply (rule disjI2)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   377
    apply (subgoal_tac "r = [(xa, x)] \<bullet> (Lam [x].s)")
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   378
    prefer 2
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   379
    apply (simp add: perm_fresh_fresh)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   380
    apply (drule conjunct1)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   381
    apply (subgoal_tac "r = (Lam [xa]. [(xa, x)] \<bullet> s)")
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   382
    prefer 2
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   383
    apply (simp add: calc_atm)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   384
    apply (thin_tac "r = ?t")
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   385
    apply simp
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   386
    apply (rule exI)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   387
    apply (rule conjI)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   388
    apply (rule refl)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   389
    apply (simp add: abs_fresh fresh_atm fresh_left calc_atm subst_rename)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   390
      apply (drule App_eq_foldl_conv [THEN iffD1])
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   391
      apply (split split_if_asm)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   392
       apply simp
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   393
       apply blast
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   394
      apply (force intro!: disjI1 [THEN append_step1I] simp add: fresh_list_append)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   395
     apply (drule App_eq_foldl_conv [THEN iffD1])
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   396
     apply (split split_if_asm)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   397
      apply simp
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   398
      apply blast
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   399
     apply (clarify, auto 0 3 intro!: exI intro: append_step1I)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   400
    done
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   401
  with cases show ?thesis by blast
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   402
qed
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   403
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   404
lemma apps_preserves_betas [simp]:
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   405
    "rs [\<rightarrow>\<^sub>\<beta>]\<^sub>1 ss \<Longrightarrow> r \<degree>\<degree> rs \<rightarrow>\<^sub>\<beta> r \<degree>\<degree> ss"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   406
  apply (induct rs arbitrary: ss rule: rev_induct)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   407
   apply simp
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   408
  apply simp
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   409
  apply (rule_tac xs = ss in rev_exhaust)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   410
   apply simp
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   411
  apply simp
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   412
  apply (drule Snoc_step1_SnocD)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   413
  apply blast
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   414
  done
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   415
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   416
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   417
subsection {* Standard reduction relation *}
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   418
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   419
text {*
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   420
Based on lecture notes by Ralph Matthes,
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   421
original proof idea due to Ralph Loader.
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   422
*}
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   423
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   424
declare listrel_mono [mono_set]
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   425
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   426
lemma listrelp_eqvt [eqvt]:
46317
80dccedd6c14 generalize type of List.listrel
huffman
parents: 46129
diff changeset
   427
  fixes f :: "'a::pt_name \<Rightarrow> 'b::pt_name \<Rightarrow> bool"
27623
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   428
  assumes xy: "listrelp f (x::'a::pt_name list) y"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   429
  shows "listrelp ((pi::name prm) \<bullet> f) (pi \<bullet> x) (pi \<bullet> y)" using xy
45966
03ce2b2a29a2 tuned proofs
haftmann
parents: 44890
diff changeset
   430
  by induct (simp_all add: listrelp.intros perm_app [symmetric])
27623
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   431
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   432
inductive
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   433
  sred :: "lam \<Rightarrow> lam \<Rightarrow> bool"  (infixl "\<rightarrow>\<^sub>s" 50)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   434
  and sredlist :: "lam list \<Rightarrow> lam list \<Rightarrow> bool"  (infixl "[\<rightarrow>\<^sub>s]" 50)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   435
where
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   436
  "s [\<rightarrow>\<^sub>s] t \<equiv> listrelp op \<rightarrow>\<^sub>s s t"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   437
| Var: "rs [\<rightarrow>\<^sub>s] rs' \<Longrightarrow> Var x \<degree>\<degree> rs \<rightarrow>\<^sub>s Var x \<degree>\<degree> rs'"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   438
| Abs: "x \<sharp> (ss, ss') \<Longrightarrow> r \<rightarrow>\<^sub>s r' \<Longrightarrow> ss [\<rightarrow>\<^sub>s] ss' \<Longrightarrow> (Lam [x].r) \<degree>\<degree> ss \<rightarrow>\<^sub>s (Lam [x].r') \<degree>\<degree> ss'"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   439
| Beta: "x \<sharp> (s, ss, t) \<Longrightarrow> r[x::=s] \<degree>\<degree> ss \<rightarrow>\<^sub>s t \<Longrightarrow> (Lam [x].r) \<degree> s \<degree>\<degree> ss \<rightarrow>\<^sub>s t"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   440
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   441
equivariance sred
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   442
nominal_inductive sred
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   443
  by (simp add: abs_fresh)+
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   444
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   445
lemma better_sred_Abs:
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   446
  assumes H1: "r \<rightarrow>\<^sub>s r'"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   447
  and H2: "ss [\<rightarrow>\<^sub>s] ss'"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   448
  shows "(Lam [x].r) \<degree>\<degree> ss \<rightarrow>\<^sub>s (Lam [x].r') \<degree>\<degree> ss'"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   449
proof -
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   450
  obtain y::name where y: "y \<sharp> (x, r, r', ss, ss')"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   451
    by (rule exists_fresh) (rule fin_supp)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   452
  then have "y \<sharp> (ss, ss')" by simp
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   453
  moreover from H1 have "[(y, x)] \<bullet> (r \<rightarrow>\<^sub>s r')" by (rule perm_boolI)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   454
  then have "([(y, x)] \<bullet> r) \<rightarrow>\<^sub>s ([(y, x)] \<bullet> r')" by (simp add: eqvts)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   455
  ultimately have "(Lam [y]. [(y, x)] \<bullet> r) \<degree>\<degree> ss \<rightarrow>\<^sub>s (Lam [y]. [(y, x)] \<bullet> r') \<degree>\<degree> ss'" using H2
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   456
    by (rule sred.Abs)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   457
  moreover from y have "(Lam [x].r) = (Lam [y]. [(y, x)] \<bullet> r)"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   458
    by (auto simp add: lam.inject alpha' fresh_prod fresh_atm)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   459
  moreover from y have "(Lam [x].r') = (Lam [y]. [(y, x)] \<bullet> r')"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   460
    by (auto simp add: lam.inject alpha' fresh_prod fresh_atm)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   461
  ultimately show ?thesis by simp
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   462
qed
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   463
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   464
lemma better_sred_Beta:
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   465
  assumes H: "r[x::=s] \<degree>\<degree> ss \<rightarrow>\<^sub>s t"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   466
  shows "(Lam [x].r) \<degree> s \<degree>\<degree> ss \<rightarrow>\<^sub>s t"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   467
proof -
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   468
  obtain y::name where y: "y \<sharp> (x, r, s, ss, t)"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   469
    by (rule exists_fresh) (rule fin_supp)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   470
  then have "y \<sharp> (s, ss, t)" by simp
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   471
  moreover from y H have "([(y, x)] \<bullet> r)[y::=s] \<degree>\<degree> ss \<rightarrow>\<^sub>s t"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   472
    by (simp add: subst_rename)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   473
  ultimately have "(Lam [y].[(y, x)] \<bullet> r) \<degree> s \<degree>\<degree> ss \<rightarrow>\<^sub>s t"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   474
    by (rule sred.Beta)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   475
  moreover from y have "(Lam [x].r) = (Lam [y]. [(y, x)] \<bullet> r)"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   476
    by (auto simp add: lam.inject alpha' fresh_prod fresh_atm)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   477
  ultimately show ?thesis by simp
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   478
qed
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   479
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   480
lemmas better_sred_intros = sred.Var better_sred_Abs better_sred_Beta
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   481
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   482
lemma refl_listrelp: "\<forall>x\<in>set xs. R x x \<Longrightarrow> listrelp R xs xs"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   483
  by (induct xs) (auto intro: listrelp.intros)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   484
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   485
lemma refl_sred: "t \<rightarrow>\<^sub>s t"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   486
  by (nominal_induct t rule: Apps_lam_induct) (auto intro: refl_listrelp better_sred_intros)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   487
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   488
lemma listrelp_conj1: "listrelp (\<lambda>x y. R x y \<and> S x y) x y \<Longrightarrow> listrelp R x y"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   489
  by (erule listrelp.induct) (auto intro: listrelp.intros)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   490
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   491
lemma listrelp_conj2: "listrelp (\<lambda>x y. R x y \<and> S x y) x y \<Longrightarrow> listrelp S x y"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   492
  by (erule listrelp.induct) (auto intro: listrelp.intros)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   493
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   494
lemma listrelp_app:
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   495
  assumes xsys: "listrelp R xs ys"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   496
  shows "listrelp R xs' ys' \<Longrightarrow> listrelp R (xs @ xs') (ys @ ys')" using xsys
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   497
  by (induct arbitrary: xs' ys') (auto intro: listrelp.intros)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   498
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   499
lemma lemma1:
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   500
  assumes r: "r \<rightarrow>\<^sub>s r'" and s: "s \<rightarrow>\<^sub>s s'"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   501
  shows "r \<degree> s \<rightarrow>\<^sub>s r' \<degree> s'" using r
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   502
proof induct
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   503
  case (Var rs rs' x)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   504
  then have "rs [\<rightarrow>\<^sub>s] rs'" by (rule listrelp_conj1)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   505
  moreover have "[s] [\<rightarrow>\<^sub>s] [s']" by (iprover intro: s listrelp.intros)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   506
  ultimately have "rs @ [s] [\<rightarrow>\<^sub>s] rs' @ [s']" by (rule listrelp_app)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   507
  hence "Var x \<degree>\<degree> (rs @ [s]) \<rightarrow>\<^sub>s Var x \<degree>\<degree> (rs' @ [s'])" by (rule sred.Var)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   508
  thus ?case by (simp only: app_last)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   509
next
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   510
  case (Abs x ss ss' r r')
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   511
  from Abs(4) have "ss [\<rightarrow>\<^sub>s] ss'" by (rule listrelp_conj1)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   512
  moreover have "[s] [\<rightarrow>\<^sub>s] [s']" by (iprover intro: s listrelp.intros)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   513
  ultimately have "ss @ [s] [\<rightarrow>\<^sub>s] ss' @ [s']" by (rule listrelp_app)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   514
  with `r \<rightarrow>\<^sub>s r'` have "(Lam [x].r) \<degree>\<degree> (ss @ [s]) \<rightarrow>\<^sub>s (Lam [x].r') \<degree>\<degree> (ss' @ [s'])"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   515
    by (rule better_sred_Abs)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   516
  thus ?case by (simp only: app_last)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   517
next
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   518
  case (Beta x u ss t r)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   519
  hence "r[x::=u] \<degree>\<degree> (ss @ [s]) \<rightarrow>\<^sub>s t \<degree> s'" by (simp only: app_last)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   520
  hence "(Lam [x].r) \<degree> u \<degree>\<degree> (ss @ [s]) \<rightarrow>\<^sub>s t \<degree> s'" by (rule better_sred_Beta)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   521
  thus ?case by (simp only: app_last)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   522
qed
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   523
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   524
lemma lemma1':
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   525
  assumes ts: "ts [\<rightarrow>\<^sub>s] ts'"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   526
  shows "r \<rightarrow>\<^sub>s r' \<Longrightarrow> r \<degree>\<degree> ts \<rightarrow>\<^sub>s r' \<degree>\<degree> ts'" using ts
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   527
  by (induct arbitrary: r r') (auto intro: lemma1)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   528
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   529
lemma listrelp_betas:
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   530
  assumes ts: "listrelp op \<rightarrow>\<^sub>\<beta>\<^sup>* ts ts'"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   531
  shows "\<And>t t'. t \<rightarrow>\<^sub>\<beta>\<^sup>* t' \<Longrightarrow> t \<degree>\<degree> ts \<rightarrow>\<^sub>\<beta>\<^sup>* t' \<degree>\<degree> ts'" using ts
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   532
  by induct auto
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   533
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   534
lemma lemma2:
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   535
  assumes t: "t \<rightarrow>\<^sub>s u"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   536
  shows "t \<rightarrow>\<^sub>\<beta>\<^sup>* u" using t
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   537
  by induct (auto dest: listrelp_conj2
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   538
    intro: listrelp_betas apps_preserves_beta converse_rtranclp_into_rtranclp)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   539
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   540
lemma lemma3:
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   541
  assumes r: "r \<rightarrow>\<^sub>s r'"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   542
  shows "s \<rightarrow>\<^sub>s s' \<Longrightarrow> r[x::=s] \<rightarrow>\<^sub>s r'[x::=s']" using r
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   543
proof (nominal_induct avoiding: x s s' rule: sred.strong_induct)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   544
  case (Var rs rs' y)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   545
  hence "map (\<lambda>t. t[x::=s]) rs [\<rightarrow>\<^sub>s] map (\<lambda>t. t[x::=s']) rs'"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   546
    by induct (auto intro: listrelp.intros Var)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   547
  moreover have "Var y[x::=s] \<rightarrow>\<^sub>s Var y[x::=s']"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   548
    by (cases "y = x") (auto simp add: Var intro: refl_sred)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   549
  ultimately show ?case by simp (rule lemma1')
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   550
next
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   551
  case (Abs y ss ss' r r')
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   552
  then have "r[x::=s] \<rightarrow>\<^sub>s r'[x::=s']" by fast
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   553
  moreover from Abs(8) `s \<rightarrow>\<^sub>s s'` have "map (\<lambda>t. t[x::=s]) ss [\<rightarrow>\<^sub>s] map (\<lambda>t. t[x::=s']) ss'"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   554
    by induct (auto intro: listrelp.intros Abs)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   555
  ultimately show ?case using Abs(6) `y \<sharp> x` `y \<sharp> s` `y \<sharp> s'`
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   556
    by simp (rule better_sred_Abs)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   557
next
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   558
  case (Beta y u ss t r)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   559
  thus ?case by (auto simp add: subst_subst fresh_atm intro: better_sred_Beta)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   560
qed
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   561
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   562
lemma lemma4_aux:
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   563
  assumes rs: "listrelp (\<lambda>t u. t \<rightarrow>\<^sub>s u \<and> (\<forall>r. u \<rightarrow>\<^sub>\<beta> r \<longrightarrow> t \<rightarrow>\<^sub>s r)) rs rs'"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   564
  shows "rs' [\<rightarrow>\<^sub>\<beta>]\<^sub>1 ss \<Longrightarrow> rs [\<rightarrow>\<^sub>s] ss" using rs
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   565
proof (induct arbitrary: ss)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   566
  case Nil
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   567
  thus ?case by cases (auto intro: listrelp.Nil)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   568
next
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   569
  case (Cons x y xs ys)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   570
  note Cons' = Cons
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   571
  show ?case
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   572
  proof (cases ss)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   573
    case Nil with Cons show ?thesis by simp
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   574
  next
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   575
    case (Cons y' ys')
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   576
    hence ss: "ss = y' # ys'" by simp
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   577
    from Cons Cons' have "y \<rightarrow>\<^sub>\<beta> y' \<and> ys' = ys \<or> y' = y \<and> ys [\<rightarrow>\<^sub>\<beta>]\<^sub>1 ys'" by simp
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   578
    hence "x # xs [\<rightarrow>\<^sub>s] y' # ys'"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   579
    proof
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   580
      assume H: "y \<rightarrow>\<^sub>\<beta> y' \<and> ys' = ys"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   581
      with Cons' have "x \<rightarrow>\<^sub>s y'" by blast
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   582
      moreover from Cons' have "xs [\<rightarrow>\<^sub>s] ys" by (iprover dest: listrelp_conj1)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   583
      ultimately have "x # xs [\<rightarrow>\<^sub>s] y' # ys" by (rule listrelp.Cons)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   584
      with H show ?thesis by simp
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   585
    next
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   586
      assume H: "y' = y \<and> ys [\<rightarrow>\<^sub>\<beta>]\<^sub>1 ys'"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   587
      with Cons' have "x \<rightarrow>\<^sub>s y'" by blast
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   588
      moreover from H have "xs [\<rightarrow>\<^sub>s] ys'" by (blast intro: Cons')
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   589
      ultimately show ?thesis by (rule listrelp.Cons)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   590
    qed
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   591
    with ss show ?thesis by simp
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   592
  qed
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   593
qed
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   594
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   595
lemma lemma4:
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   596
  assumes r: "r \<rightarrow>\<^sub>s r'"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   597
  shows "r' \<rightarrow>\<^sub>\<beta> r'' \<Longrightarrow> r \<rightarrow>\<^sub>s r''" using r
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   598
proof (nominal_induct avoiding: r'' rule: sred.strong_induct)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   599
  case (Var rs rs' x)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   600
  then obtain ss where rs: "rs' [\<rightarrow>\<^sub>\<beta>]\<^sub>1 ss" and r'': "r'' = Var x \<degree>\<degree> ss"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   601
    by (blast dest: head_Var_reduction)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   602
  from Var(1) [simplified] rs have "rs [\<rightarrow>\<^sub>s] ss" by (rule lemma4_aux)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   603
  hence "Var x \<degree>\<degree> rs \<rightarrow>\<^sub>s Var x \<degree>\<degree> ss" by (rule sred.Var)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   604
  with r'' show ?case by simp
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   605
next
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   606
  case (Abs x ss ss' r r')
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   607
  from `(Lam [x].r') \<degree>\<degree> ss' \<rightarrow>\<^sub>\<beta> r''` show ?case
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   608
  proof (cases rule: apps_betasE [where x=x])
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   609
    case (appL s)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   610
    then obtain r''' where s: "s = (Lam [x].r''')" and r''': "r' \<rightarrow>\<^sub>\<beta> r'''" using `x \<sharp> r''`
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   611
      by (cases rule: beta.strong_cases) (auto simp add: abs_fresh lam.inject alpha)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   612
    from r''' have "r \<rightarrow>\<^sub>s r'''" by (blast intro: Abs)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   613
    moreover from Abs have "ss [\<rightarrow>\<^sub>s] ss'" by (iprover dest: listrelp_conj1)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   614
    ultimately have "(Lam [x].r) \<degree>\<degree> ss \<rightarrow>\<^sub>s (Lam [x].r''') \<degree>\<degree> ss'" by (rule better_sred_Abs)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   615
    with appL s show "(Lam [x].r) \<degree>\<degree> ss \<rightarrow>\<^sub>s r''" by simp
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   616
  next
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   617
    case (appR rs')
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   618
    from Abs(6) [simplified] `ss' [\<rightarrow>\<^sub>\<beta>]\<^sub>1 rs'`
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   619
    have "ss [\<rightarrow>\<^sub>s] rs'" by (rule lemma4_aux)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   620
    with `r \<rightarrow>\<^sub>s r'` have "(Lam [x].r) \<degree>\<degree> ss \<rightarrow>\<^sub>s (Lam [x].r') \<degree>\<degree> rs'" by (rule better_sred_Abs)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   621
    with appR show "(Lam [x].r) \<degree>\<degree> ss \<rightarrow>\<^sub>s r''" by simp
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   622
  next
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   623
    case (beta t u' us')
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   624
    then have Lam_eq: "(Lam [x].r') = (Lam [x].t)" and ss': "ss' = u' # us'"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   625
      and r'': "r'' = t[x::=u'] \<degree>\<degree> us'"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   626
      by (simp_all add: abs_fresh)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   627
    from Abs(6) ss' obtain u us where
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   628
      ss: "ss = u # us" and u: "u \<rightarrow>\<^sub>s u'" and us: "us [\<rightarrow>\<^sub>s] us'"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   629
      by cases (auto dest!: listrelp_conj1)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   630
    have "r[x::=u] \<rightarrow>\<^sub>s r'[x::=u']" using `r \<rightarrow>\<^sub>s r'` and u by (rule lemma3)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   631
    with us have "r[x::=u] \<degree>\<degree> us \<rightarrow>\<^sub>s r'[x::=u'] \<degree>\<degree> us'" by (rule lemma1')
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   632
    hence "(Lam [x].r) \<degree> u \<degree>\<degree> us \<rightarrow>\<^sub>s r'[x::=u'] \<degree>\<degree> us'" by (rule better_sred_Beta)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   633
    with ss r'' Lam_eq show "(Lam [x].r) \<degree>\<degree> ss \<rightarrow>\<^sub>s r''" by (simp add: lam.inject alpha)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   634
  qed
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   635
next
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   636
  case (Beta x s ss t r)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   637
  show ?case
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   638
    by (rule better_sred_Beta) (rule Beta)+
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   639
qed
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   640
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   641
lemma rtrancl_beta_sred:
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   642
  assumes r: "r \<rightarrow>\<^sub>\<beta>\<^sup>* r'"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   643
  shows "r \<rightarrow>\<^sub>s r'" using r
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   644
  by induct (iprover intro: refl_sred lemma4)+
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   645
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   646
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   647
subsection {* Terms in normal form *}
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   648
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   649
lemma listsp_eqvt [eqvt]:
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   650
  assumes xs: "listsp p (xs::'a::pt_name list)"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   651
  shows "listsp ((pi::name prm) \<bullet> p) (pi \<bullet> xs)" using xs
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   652
  apply induct
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   653
  apply simp
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   654
  apply simp
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   655
  apply (rule listsp.intros)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   656
  apply (drule_tac pi=pi in perm_boolI)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   657
  apply perm_simp
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   658
  apply assumption
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   659
  done
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   660
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   661
inductive NF :: "lam \<Rightarrow> bool"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   662
where
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   663
  App: "listsp NF ts \<Longrightarrow> NF (Var x \<degree>\<degree> ts)"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   664
| Abs: "NF t \<Longrightarrow> NF (Lam [x].t)"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   665
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   666
equivariance NF
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   667
nominal_inductive NF
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   668
  by (simp add: abs_fresh)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   669
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   670
lemma Abs_NF:
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   671
  assumes NF: "NF ((Lam [x].t) \<degree>\<degree> ts)"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   672
  shows "ts = []" using NF
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   673
proof cases
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   674
  case (App us i)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   675
  thus ?thesis by (simp add: Var_apps_neq_Abs_apps [THEN not_sym])
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   676
next
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   677
  case (Abs u)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   678
  thus ?thesis by simp
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   679
qed
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   680
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   681
text {*
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   682
@{term NF} characterizes exactly the terms that are in normal form.
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   683
*}
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   684
  
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   685
lemma NF_eq: "NF t = (\<forall>t'. \<not> t \<rightarrow>\<^sub>\<beta> t')"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   686
proof
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   687
  assume H: "NF t"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   688
  show "\<forall>t'. \<not> t \<rightarrow>\<^sub>\<beta> t'"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   689
  proof
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   690
    fix t'
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   691
    from H show "\<not> t \<rightarrow>\<^sub>\<beta> t'"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   692
    proof (nominal_induct avoiding: t' rule: NF.strong_induct)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   693
      case (App ts t)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   694
      show ?case
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   695
      proof
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 29097
diff changeset
   696
        assume "Var t \<degree>\<degree> ts \<rightarrow>\<^sub>\<beta> t'"
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 29097
diff changeset
   697
        then obtain rs where "ts [\<rightarrow>\<^sub>\<beta>]\<^sub>1 rs"
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 29097
diff changeset
   698
          by (iprover dest: head_Var_reduction)
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 29097
diff changeset
   699
        with App show False
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 29097
diff changeset
   700
          by (induct rs arbitrary: ts) (auto del: in_listspD)
27623
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   701
      qed
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   702
    next
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   703
      case (Abs t x)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   704
      show ?case
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   705
      proof
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 29097
diff changeset
   706
        assume "(Lam [x].t) \<rightarrow>\<^sub>\<beta> t'"
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 29097
diff changeset
   707
        then show False using Abs
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 29097
diff changeset
   708
          by (cases rule: beta.strong_cases) (auto simp add: abs_fresh lam.inject alpha)
27623
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   709
      qed
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   710
    qed
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   711
  qed
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   712
next
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   713
  assume H: "\<forall>t'. \<not> t \<rightarrow>\<^sub>\<beta> t'"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   714
  then show "NF t"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   715
  proof (nominal_induct t rule: Apps_lam_induct)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   716
    case (1 n ts)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   717
    then have "\<forall>ts'. \<not> ts [\<rightarrow>\<^sub>\<beta>]\<^sub>1 ts'"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   718
      by (iprover intro: apps_preserves_betas)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   719
    with 1(1) have "listsp NF ts"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   720
      by (induct ts) (auto simp add: in_listsp_conv_set)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   721
    then show ?case by (rule NF.App)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   722
  next
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   723
    case (2 x u ts)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   724
    show ?case
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   725
    proof (cases ts)
39459
7753083c00e6 tidied a few proofs
paulson
parents: 32960
diff changeset
   726
      case Nil thus ?thesis by (metis 2 NF.Abs abs foldl_Nil)
27623
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   727
    next
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   728
      case (Cons r rs)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   729
      have "(Lam [x].u) \<degree> r \<rightarrow>\<^sub>\<beta> u[x::=r]" ..
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   730
      then have "(Lam [x].u) \<degree> r \<degree>\<degree> rs \<rightarrow>\<^sub>\<beta> u[x::=r] \<degree>\<degree> rs"
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 29097
diff changeset
   731
        by (rule apps_preserves_beta)
27623
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   732
      with Cons have "(Lam [x].u) \<degree>\<degree> ts \<rightarrow>\<^sub>\<beta> u[x::=r] \<degree>\<degree> rs"
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 29097
diff changeset
   733
        by simp
27623
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   734
      with 2 show ?thesis by iprover
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   735
    qed
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   736
  qed
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   737
qed
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   738
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   739
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   740
subsection {* Leftmost reduction and weakly normalizing terms *}
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   741
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   742
inductive
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   743
  lred :: "lam \<Rightarrow> lam \<Rightarrow> bool"  (infixl "\<rightarrow>\<^sub>l" 50)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   744
  and lredlist :: "lam list \<Rightarrow> lam list \<Rightarrow> bool"  (infixl "[\<rightarrow>\<^sub>l]" 50)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   745
where
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   746
  "s [\<rightarrow>\<^sub>l] t \<equiv> listrelp op \<rightarrow>\<^sub>l s t"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   747
| Var: "rs [\<rightarrow>\<^sub>l] rs' \<Longrightarrow> Var x \<degree>\<degree> rs \<rightarrow>\<^sub>l Var x \<degree>\<degree> rs'"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   748
| Abs: "r \<rightarrow>\<^sub>l r' \<Longrightarrow> (Lam [x].r) \<rightarrow>\<^sub>l (Lam [x].r')"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   749
| Beta: "r[x::=s] \<degree>\<degree> ss \<rightarrow>\<^sub>l t \<Longrightarrow> (Lam [x].r) \<degree> s \<degree>\<degree> ss \<rightarrow>\<^sub>l t"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   750
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   751
lemma lred_imp_sred:
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   752
  assumes lred: "s \<rightarrow>\<^sub>l t"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   753
  shows "s \<rightarrow>\<^sub>s t" using lred
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   754
proof induct
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   755
  case (Var rs rs' x)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   756
  then have "rs [\<rightarrow>\<^sub>s] rs'"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   757
    by induct (iprover intro: listrelp.intros)+
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   758
  then show ?case by (rule sred.Var)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   759
next
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   760
  case (Abs r r' x)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   761
  from `r \<rightarrow>\<^sub>s r'`
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   762
  have "(Lam [x].r) \<degree>\<degree> [] \<rightarrow>\<^sub>s (Lam [x].r') \<degree>\<degree> []" using listrelp.Nil
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   763
    by (rule better_sred_Abs)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   764
  then show ?case by simp
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   765
next
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   766
  case (Beta r x s ss t)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   767
  from `r[x::=s] \<degree>\<degree> ss \<rightarrow>\<^sub>s t`
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   768
  show ?case by (rule better_sred_Beta)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   769
qed
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   770
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   771
inductive WN :: "lam \<Rightarrow> bool"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   772
  where
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   773
    Var: "listsp WN rs \<Longrightarrow> WN (Var n \<degree>\<degree> rs)"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   774
  | Lambda: "WN r \<Longrightarrow> WN (Lam [x].r)"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   775
  | Beta: "WN ((r[x::=s]) \<degree>\<degree> ss) \<Longrightarrow> WN (((Lam [x].r) \<degree> s) \<degree>\<degree> ss)"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   776
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   777
lemma listrelp_imp_listsp1:
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   778
  assumes H: "listrelp (\<lambda>x y. P x) xs ys"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   779
  shows "listsp P xs" using H
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   780
  by induct auto
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   781
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   782
lemma listrelp_imp_listsp2:
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   783
  assumes H: "listrelp (\<lambda>x y. P y) xs ys"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   784
  shows "listsp P ys" using H
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   785
  by induct auto
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   786
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   787
lemma lemma5:
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   788
  assumes lred: "r \<rightarrow>\<^sub>l r'"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   789
  shows "WN r" and "NF r'" using lred
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   790
  by induct
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   791
    (iprover dest: listrelp_conj1 listrelp_conj2
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   792
     listrelp_imp_listsp1 listrelp_imp_listsp2 intro: WN.intros
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   793
     NF.intros)+
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   794
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   795
lemma lemma6:
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   796
  assumes wn: "WN r"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   797
  shows "\<exists>r'. r \<rightarrow>\<^sub>l r'" using wn
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   798
proof induct
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   799
  case (Var rs n)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   800
  then have "\<exists>rs'. rs [\<rightarrow>\<^sub>l] rs'"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   801
    by induct (iprover intro: listrelp.intros)+
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   802
  then show ?case by (iprover intro: lred.Var)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   803
qed (iprover intro: lred.intros)+
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   804
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   805
lemma lemma7:
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   806
  assumes r: "r \<rightarrow>\<^sub>s r'"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   807
  shows "NF r' \<Longrightarrow> r \<rightarrow>\<^sub>l r'" using r
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   808
proof induct
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   809
  case (Var rs rs' x)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   810
  from `NF (Var x \<degree>\<degree> rs')` have "listsp NF rs'"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   811
    by cases simp_all
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   812
  with Var(1) have "rs [\<rightarrow>\<^sub>l] rs'"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   813
  proof induct
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   814
    case Nil
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   815
    show ?case by (rule listrelp.Nil)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   816
  next
39459
7753083c00e6 tidied a few proofs
paulson
parents: 32960
diff changeset
   817
    case (Cons x y xs ys) 
27623
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   818
    hence "x \<rightarrow>\<^sub>l y" and "xs [\<rightarrow>\<^sub>l] ys" by (auto del: in_listspD)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   819
    thus ?case by (rule listrelp.Cons)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   820
  qed
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   821
  thus ?case by (rule lred.Var)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   822
next
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   823
  case (Abs x ss ss' r r')
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   824
  from `NF ((Lam [x].r') \<degree>\<degree> ss')`
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   825
  have ss': "ss' = []" by (rule Abs_NF)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   826
  from Abs(4) have ss: "ss = []" using ss'
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   827
    by cases simp_all
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   828
  from ss' Abs have "NF (Lam [x].r')" by simp
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   829
  hence "NF r'" by (cases rule: NF.strong_cases) (auto simp add: abs_fresh lam.inject alpha)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   830
  with Abs have "r \<rightarrow>\<^sub>l r'" by simp
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   831
  hence "(Lam [x].r) \<rightarrow>\<^sub>l (Lam [x].r')" by (rule lred.Abs)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   832
  with ss ss' show ?case by simp
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   833
next
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   834
  case (Beta x s ss t r)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   835
  hence "r[x::=s] \<degree>\<degree> ss \<rightarrow>\<^sub>l t" by simp
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   836
  thus ?case by (rule lred.Beta)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   837
qed
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   838
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   839
lemma WN_eq: "WN t = (\<exists>t'. t \<rightarrow>\<^sub>\<beta>\<^sup>* t' \<and> NF t')"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   840
proof
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   841
  assume "WN t"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   842
  then have "\<exists>t'. t \<rightarrow>\<^sub>l t'" by (rule lemma6)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   843
  then obtain t' where t': "t \<rightarrow>\<^sub>l t'" ..
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   844
  then have NF: "NF t'" by (rule lemma5)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   845
  from t' have "t \<rightarrow>\<^sub>s t'" by (rule lred_imp_sred)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   846
  then have "t \<rightarrow>\<^sub>\<beta>\<^sup>* t'" by (rule lemma2)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   847
  with NF show "\<exists>t'. t \<rightarrow>\<^sub>\<beta>\<^sup>* t' \<and> NF t'" by iprover
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   848
next
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   849
  assume "\<exists>t'. t \<rightarrow>\<^sub>\<beta>\<^sup>* t' \<and> NF t'"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   850
  then obtain t' where t': "t \<rightarrow>\<^sub>\<beta>\<^sup>* t'" and NF: "NF t'"
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   851
    by iprover
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   852
  from t' have "t \<rightarrow>\<^sub>s t'" by (rule rtrancl_beta_sred)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   853
  then have "t \<rightarrow>\<^sub>l t'" using NF by (rule lemma7)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   854
  then show "WN t" by (rule lemma5)
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   855
qed
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   856
8e9c19529a4e Added Standardization theory.
berghofe
parents:
diff changeset
   857
end