src/HOL/Proofs/Lambda/Eta.thy
author wenzelm
Thu May 24 17:25:53 2012 +0200 (2012-05-24)
changeset 47988 e4b69e10b990
parent 47124 960f0a4404c7
child 58273 9f0bfcd15097
permissions -rw-r--r--
tuned proofs;
wenzelm@39157
     1
(*  Title:      HOL/Proofs/Lambda/Eta.thy
berghofe@15522
     2
    Author:     Tobias Nipkow and Stefan Berghofer
berghofe@15522
     3
    Copyright   1995, 2005 TU Muenchen
nipkow@1269
     4
*)
nipkow@1269
     5
wenzelm@9811
     6
header {* Eta-reduction *}
wenzelm@9811
     7
haftmann@16417
     8
theory Eta imports ParRed begin
wenzelm@9811
     9
wenzelm@9811
    10
wenzelm@9811
    11
subsection {* Definition of eta-reduction and relatives *}
nipkow@1269
    12
wenzelm@25973
    13
primrec
wenzelm@9811
    14
  free :: "dB => nat => bool"
wenzelm@25973
    15
where
wenzelm@25973
    16
    "free (Var j) i = (j = i)"
wenzelm@25973
    17
  | "free (s \<degree> t) i = (free s i \<or> free t i)"
wenzelm@25973
    18
  | "free (Abs s) i = free s (i + 1)"
nipkow@1269
    19
wenzelm@25973
    20
inductive
wenzelm@25973
    21
  eta :: "[dB, dB] => bool"  (infixl "\<rightarrow>\<^sub>\<eta>" 50)
wenzelm@25973
    22
where
berghofe@22272
    23
    eta [simp, intro]: "\<not> free s 0 ==> Abs (s \<degree> Var 0) \<rightarrow>\<^sub>\<eta> s[dummy/0]"
berghofe@22272
    24
  | appL [simp, intro]: "s \<rightarrow>\<^sub>\<eta> t ==> s \<degree> u \<rightarrow>\<^sub>\<eta> t \<degree> u"
berghofe@22272
    25
  | appR [simp, intro]: "s \<rightarrow>\<^sub>\<eta> t ==> u \<degree> s \<rightarrow>\<^sub>\<eta> u \<degree> t"
berghofe@22272
    26
  | abs [simp, intro]: "s \<rightarrow>\<^sub>\<eta> t ==> Abs s \<rightarrow>\<^sub>\<eta> Abs t"
wenzelm@21404
    27
wenzelm@21404
    28
abbreviation
wenzelm@21404
    29
  eta_reds :: "[dB, dB] => bool"   (infixl "-e>>" 50) where
berghofe@22272
    30
  "s -e>> t == eta^** s t"
wenzelm@21404
    31
wenzelm@21404
    32
abbreviation
wenzelm@21404
    33
  eta_red0 :: "[dB, dB] => bool"   (infixl "-e>=" 50) where
berghofe@22272
    34
  "s -e>= t == eta^== s t"
nipkow@1269
    35
berghofe@22272
    36
notation (xsymbols)
berghofe@22272
    37
  eta_reds  (infixl "\<rightarrow>\<^sub>\<eta>\<^sup>*" 50) and
berghofe@22272
    38
  eta_red0  (infixl "\<rightarrow>\<^sub>\<eta>\<^sup>=" 50)
wenzelm@9811
    39
berghofe@23750
    40
inductive_cases eta_cases [elim!]:
berghofe@22272
    41
  "Abs s \<rightarrow>\<^sub>\<eta> z"
berghofe@22272
    42
  "s \<degree> t \<rightarrow>\<^sub>\<eta> u"
berghofe@22272
    43
  "Var i \<rightarrow>\<^sub>\<eta> t"
wenzelm@9811
    44
wenzelm@9811
    45
wenzelm@25973
    46
subsection {* Properties of @{text "eta"}, @{text "subst"} and @{text "free"} *}
wenzelm@9811
    47
wenzelm@18241
    48
lemma subst_not_free [simp]: "\<not> free s i \<Longrightarrow> s[t/i] = s[u/i]"
wenzelm@20503
    49
  by (induct s arbitrary: i t u) (simp_all add: subst_Var)
wenzelm@9811
    50
wenzelm@9811
    51
lemma free_lift [simp]:
wenzelm@18241
    52
    "free (lift t k) i = (i < k \<and> free t i \<or> k < i \<and> free t (i - 1))"
wenzelm@20503
    53
  apply (induct t arbitrary: i k)
webertj@20217
    54
  apply (auto cong: conj_cong)
wenzelm@9811
    55
  done
wenzelm@9811
    56
wenzelm@9811
    57
lemma free_subst [simp]:
wenzelm@18241
    58
    "free (s[t/k]) i =
wenzelm@9811
    59
      (free s k \<and> free t i \<or> free s (if i < k then i else i + 1))"
wenzelm@20503
    60
  apply (induct s arbitrary: i k t)
wenzelm@9811
    61
    prefer 2
wenzelm@9811
    62
    apply simp
wenzelm@9811
    63
    apply blast
wenzelm@9811
    64
   prefer 2
wenzelm@9811
    65
   apply simp
wenzelm@9811
    66
  apply (simp add: diff_Suc subst_Var split: nat.split)
wenzelm@9811
    67
  done
wenzelm@9811
    68
berghofe@22272
    69
lemma free_eta: "s \<rightarrow>\<^sub>\<eta> t ==> free t i = free s i"
wenzelm@20503
    70
  by (induct arbitrary: i set: eta) (simp_all cong: conj_cong)
wenzelm@9811
    71
wenzelm@9811
    72
lemma not_free_eta:
berghofe@22272
    73
    "[| s \<rightarrow>\<^sub>\<eta> t; \<not> free s i |] ==> \<not> free t i"
wenzelm@18241
    74
  by (simp add: free_eta)
wenzelm@9811
    75
wenzelm@18241
    76
lemma eta_subst [simp]:
berghofe@22272
    77
    "s \<rightarrow>\<^sub>\<eta> t ==> s[u/i] \<rightarrow>\<^sub>\<eta> t[u/i]"
wenzelm@20503
    78
  by (induct arbitrary: u i set: eta) (simp_all add: subst_subst [symmetric])
wenzelm@9811
    79
wenzelm@18241
    80
theorem lift_subst_dummy: "\<not> free s i \<Longrightarrow> lift (s[dummy/i]) i = s"
wenzelm@20503
    81
  by (induct s arbitrary: i dummy) simp_all
berghofe@15522
    82
wenzelm@9811
    83
wenzelm@25973
    84
subsection {* Confluence of @{text "eta"} *}
wenzelm@9811
    85
berghofe@22272
    86
lemma square_eta: "square eta eta (eta^==) (eta^==)"
wenzelm@9811
    87
  apply (unfold square_def id_def)
wenzelm@9811
    88
  apply (rule impI [THEN allI [THEN allI]])
wenzelm@9811
    89
  apply (erule eta.induct)
wenzelm@9811
    90
     apply (slowsimp intro: subst_not_free eta_subst free_eta [THEN iffD1])
wenzelm@9811
    91
    apply safe
wenzelm@9811
    92
       prefer 5
wenzelm@9811
    93
       apply (blast intro!: eta_subst intro: free_eta [THEN iffD1])
wenzelm@9811
    94
      apply blast+
wenzelm@9811
    95
  done
wenzelm@9811
    96
wenzelm@9811
    97
theorem eta_confluent: "confluent eta"
wenzelm@9811
    98
  apply (rule square_eta [THEN square_reflcl_confluent])
wenzelm@9811
    99
  done
wenzelm@9811
   100
wenzelm@9811
   101
wenzelm@25973
   102
subsection {* Congruence rules for @{text "eta\<^sup>*"} *}
wenzelm@9811
   103
berghofe@22272
   104
lemma rtrancl_eta_Abs: "s \<rightarrow>\<^sub>\<eta>\<^sup>* s' ==> Abs s \<rightarrow>\<^sub>\<eta>\<^sup>* Abs s'"
berghofe@23750
   105
  by (induct set: rtranclp)
berghofe@23750
   106
    (blast intro: rtranclp.rtrancl_into_rtrancl)+
wenzelm@9811
   107
berghofe@22272
   108
lemma rtrancl_eta_AppL: "s \<rightarrow>\<^sub>\<eta>\<^sup>* s' ==> s \<degree> t \<rightarrow>\<^sub>\<eta>\<^sup>* s' \<degree> t"
berghofe@23750
   109
  by (induct set: rtranclp)
berghofe@23750
   110
    (blast intro: rtranclp.rtrancl_into_rtrancl)+
wenzelm@9811
   111
berghofe@22272
   112
lemma rtrancl_eta_AppR: "t \<rightarrow>\<^sub>\<eta>\<^sup>* t' ==> s \<degree> t \<rightarrow>\<^sub>\<eta>\<^sup>* s \<degree> t'"
berghofe@23750
   113
  by (induct set: rtranclp) (blast intro: rtranclp.rtrancl_into_rtrancl)+
wenzelm@9811
   114
wenzelm@9811
   115
lemma rtrancl_eta_App:
berghofe@22272
   116
    "[| s \<rightarrow>\<^sub>\<eta>\<^sup>* s'; t \<rightarrow>\<^sub>\<eta>\<^sup>* t' |] ==> s \<degree> t \<rightarrow>\<^sub>\<eta>\<^sup>* s' \<degree> t'"
berghofe@23750
   117
  by (blast intro!: rtrancl_eta_AppL rtrancl_eta_AppR intro: rtranclp_trans)
wenzelm@9811
   118
wenzelm@9811
   119
wenzelm@25973
   120
subsection {* Commutation of @{text "beta"} and @{text "eta"} *}
berghofe@1900
   121
wenzelm@18241
   122
lemma free_beta:
berghofe@22272
   123
    "s \<rightarrow>\<^sub>\<beta> t ==> free t i \<Longrightarrow> free s i"
wenzelm@20503
   124
  by (induct arbitrary: i set: beta) auto
wenzelm@9811
   125
berghofe@22272
   126
lemma beta_subst [intro]: "s \<rightarrow>\<^sub>\<beta> t ==> s[u/i] \<rightarrow>\<^sub>\<beta> t[u/i]"
wenzelm@20503
   127
  by (induct arbitrary: u i set: beta) (simp_all add: subst_subst [symmetric])
wenzelm@9811
   128
wenzelm@18241
   129
lemma subst_Var_Suc [simp]: "t[Var i/i] = t[Var(i)/i + 1]"
wenzelm@20503
   130
  by (induct t arbitrary: i) (auto elim!: linorder_neqE simp: subst_Var)
wenzelm@9811
   131
berghofe@22272
   132
lemma eta_lift [simp]: "s \<rightarrow>\<^sub>\<eta> t ==> lift s i \<rightarrow>\<^sub>\<eta> lift t i"
wenzelm@20503
   133
  by (induct arbitrary: i set: eta) simp_all
wenzelm@9811
   134
berghofe@22272
   135
lemma rtrancl_eta_subst: "s \<rightarrow>\<^sub>\<eta> t \<Longrightarrow> u[s/i] \<rightarrow>\<^sub>\<eta>\<^sup>* u[t/i]"
wenzelm@20503
   136
  apply (induct u arbitrary: s t i)
wenzelm@9811
   137
    apply (simp_all add: subst_Var)
wenzelm@18241
   138
    apply blast
wenzelm@9811
   139
   apply (blast intro: rtrancl_eta_App)
wenzelm@9811
   140
  apply (blast intro!: rtrancl_eta_Abs eta_lift)
wenzelm@9811
   141
  done
wenzelm@9811
   142
berghofe@22272
   143
lemma rtrancl_eta_subst':
wenzelm@24231
   144
  fixes s t :: dB
berghofe@22272
   145
  assumes eta: "s \<rightarrow>\<^sub>\<eta>\<^sup>* t"
berghofe@22272
   146
  shows "s[u/i] \<rightarrow>\<^sub>\<eta>\<^sup>* t[u/i]" using eta
berghofe@22272
   147
  by induct (iprover intro: eta_subst)+
berghofe@22272
   148
berghofe@22272
   149
lemma rtrancl_eta_subst'':
wenzelm@24231
   150
  fixes s t :: dB
berghofe@22272
   151
  assumes eta: "s \<rightarrow>\<^sub>\<eta>\<^sup>* t"
berghofe@22272
   152
  shows "u[s/i] \<rightarrow>\<^sub>\<eta>\<^sup>* u[t/i]" using eta
berghofe@23750
   153
  by induct (iprover intro: rtrancl_eta_subst rtranclp_trans)+
berghofe@22272
   154
berghofe@22272
   155
lemma square_beta_eta: "square beta eta (eta^**) (beta^==)"
wenzelm@9811
   156
  apply (unfold square_def)
wenzelm@9811
   157
  apply (rule impI [THEN allI [THEN allI]])
wenzelm@9811
   158
  apply (erule beta.induct)
paulson@11183
   159
     apply (slowsimp intro: rtrancl_eta_subst eta_subst)
paulson@11183
   160
    apply (blast intro: rtrancl_eta_AppL)
paulson@11183
   161
   apply (blast intro: rtrancl_eta_AppR)
huffman@47124
   162
  apply simp
paulson@11183
   163
  apply (slowsimp intro: rtrancl_eta_Abs free_beta
wenzelm@9858
   164
    iff del: dB.distinct simp: dB.distinct)    (*23 seconds?*)
wenzelm@9811
   165
  done
wenzelm@9811
   166
haftmann@22422
   167
lemma confluent_beta_eta: "confluent (sup beta eta)"
wenzelm@9811
   168
  apply (assumption |
wenzelm@9811
   169
    rule square_rtrancl_reflcl_commute confluent_Un
wenzelm@9811
   170
      beta_confluent eta_confluent square_beta_eta)+
wenzelm@9811
   171
  done
wenzelm@9811
   172
wenzelm@9811
   173
wenzelm@25973
   174
subsection {* Implicit definition of @{text "eta"} *}
wenzelm@9811
   175
berghofe@22272
   176
text {* @{term "Abs (lift s 0 \<degree> Var 0) \<rightarrow>\<^sub>\<eta> s"} *}
wenzelm@9811
   177
wenzelm@18241
   178
lemma not_free_iff_lifted:
wenzelm@18241
   179
    "(\<not> free s i) = (\<exists>t. s = lift t i)"
wenzelm@20503
   180
  apply (induct s arbitrary: i)
wenzelm@9811
   181
    apply simp
wenzelm@9811
   182
    apply (rule iffI)
wenzelm@9811
   183
     apply (erule linorder_neqE)
wenzelm@9811
   184
      apply (rule_tac x = "Var nat" in exI)
wenzelm@9811
   185
      apply simp
wenzelm@9811
   186
     apply (rule_tac x = "Var (nat - 1)" in exI)
wenzelm@9811
   187
     apply simp
wenzelm@9811
   188
    apply clarify
wenzelm@9811
   189
    apply (rule notE)
wenzelm@9811
   190
     prefer 2
wenzelm@9811
   191
     apply assumption
wenzelm@9811
   192
    apply (erule thin_rl)
wenzelm@9811
   193
    apply (case_tac t)
wenzelm@9811
   194
      apply simp
wenzelm@9811
   195
     apply simp
wenzelm@9811
   196
    apply simp
wenzelm@9811
   197
   apply simp
wenzelm@9811
   198
   apply (erule thin_rl)
wenzelm@9811
   199
   apply (erule thin_rl)
wenzelm@9811
   200
   apply (rule iffI)
wenzelm@9811
   201
    apply (elim conjE exE)
wenzelm@9811
   202
    apply (rename_tac u1 u2)
wenzelm@12011
   203
    apply (rule_tac x = "u1 \<degree> u2" in exI)
wenzelm@9811
   204
    apply simp
wenzelm@9811
   205
   apply (erule exE)
wenzelm@9811
   206
   apply (erule rev_mp)
wenzelm@9811
   207
   apply (case_tac t)
wenzelm@9811
   208
     apply simp
wenzelm@9811
   209
    apply simp
wenzelm@9811
   210
    apply blast
wenzelm@9811
   211
   apply simp
wenzelm@9811
   212
  apply simp
wenzelm@9811
   213
  apply (erule thin_rl)
wenzelm@9811
   214
  apply (rule iffI)
wenzelm@9811
   215
   apply (erule exE)
wenzelm@9811
   216
   apply (rule_tac x = "Abs t" in exI)
wenzelm@9811
   217
   apply simp
wenzelm@9811
   218
  apply (erule exE)
wenzelm@9811
   219
  apply (erule rev_mp)
wenzelm@9811
   220
  apply (case_tac t)
wenzelm@9811
   221
    apply simp
wenzelm@9811
   222
   apply simp
wenzelm@9811
   223
  apply simp
wenzelm@9811
   224
  apply blast
wenzelm@9811
   225
  done
wenzelm@9811
   226
wenzelm@9811
   227
theorem explicit_is_implicit:
wenzelm@12011
   228
  "(\<forall>s u. (\<not> free s 0) --> R (Abs (s \<degree> Var 0)) (s[u/0])) =
wenzelm@12011
   229
    (\<forall>s. R (Abs (lift s 0 \<degree> Var 0)) s)"
wenzelm@18241
   230
  by (auto simp add: not_free_iff_lifted)
wenzelm@9811
   231
berghofe@15522
   232
berghofe@15522
   233
subsection {* Eta-postponement theorem *}
berghofe@15522
   234
berghofe@15522
   235
text {*
berghofe@22272
   236
  Based on a paper proof due to Andreas Abel.
berghofe@22272
   237
  Unlike the proof by Masako Takahashi \cite{Takahashi-IandC}, it does not
berghofe@22272
   238
  use parallel eta reduction, which only seems to complicate matters unnecessarily.
berghofe@15522
   239
*}
berghofe@15522
   240
berghofe@22272
   241
theorem eta_case:
wenzelm@24231
   242
  fixes s :: dB
berghofe@22272
   243
  assumes free: "\<not> free s 0"
berghofe@22272
   244
  and s: "s[dummy/0] => u"
berghofe@22272
   245
  shows "\<exists>t'. Abs (s \<degree> Var 0) => t' \<and> t' \<rightarrow>\<^sub>\<eta>\<^sup>* u"
berghofe@22272
   246
proof -
berghofe@22272
   247
  from s have "lift (s[dummy/0]) 0 => lift u 0" by (simp del: lift_subst)
berghofe@22272
   248
  with free have "s => lift u 0" by (simp add: lift_subst_dummy del: lift_subst)
berghofe@22272
   249
  hence "Abs (s \<degree> Var 0) => Abs (lift u 0 \<degree> Var 0)" by simp
berghofe@22272
   250
  moreover have "\<not> free (lift u 0) 0" by simp
berghofe@22272
   251
  hence "Abs (lift u 0 \<degree> Var 0) \<rightarrow>\<^sub>\<eta> lift u 0[dummy/0]"
berghofe@22272
   252
    by (rule eta.eta)
berghofe@22272
   253
  hence "Abs (lift u 0 \<degree> Var 0) \<rightarrow>\<^sub>\<eta>\<^sup>* u" by simp
berghofe@22272
   254
  ultimately show ?thesis by iprover
berghofe@15522
   255
qed
berghofe@15522
   256
berghofe@22272
   257
theorem eta_par_beta:
berghofe@22272
   258
  assumes st: "s \<rightarrow>\<^sub>\<eta> t"
berghofe@22272
   259
  and tu: "t => u"
berghofe@22272
   260
  shows "\<exists>t'. s => t' \<and> t' \<rightarrow>\<^sub>\<eta>\<^sup>* u" using tu st
berghofe@22272
   261
proof (induct arbitrary: s)
berghofe@22272
   262
  case (var n)
berghofe@22272
   263
  thus ?case by (iprover intro: par_beta_refl)
berghofe@22272
   264
next
berghofe@22272
   265
  case (abs s' t)
berghofe@22272
   266
  note abs' = this
berghofe@22272
   267
  from `s \<rightarrow>\<^sub>\<eta> Abs s'` show ?case
berghofe@22272
   268
  proof cases
berghofe@22272
   269
    case (eta s'' dummy)
berghofe@22272
   270
    from abs have "Abs s' => Abs t" by simp
berghofe@22272
   271
    with eta have "s''[dummy/0] => Abs t" by simp
berghofe@22272
   272
    with `\<not> free s'' 0` have "\<exists>t'. Abs (s'' \<degree> Var 0) => t' \<and> t' \<rightarrow>\<^sub>\<eta>\<^sup>* Abs t"
berghofe@22272
   273
      by (rule eta_case)
berghofe@22272
   274
    with eta show ?thesis by simp
berghofe@22272
   275
  next
berghofe@34990
   276
    case (abs r)
berghofe@34990
   277
    from `r \<rightarrow>\<^sub>\<eta> s'`
berghofe@34990
   278
    obtain t' where r: "r => t'" and t': "t' \<rightarrow>\<^sub>\<eta>\<^sup>* t" by (iprover dest: abs')
berghofe@22272
   279
    from r have "Abs r => Abs t'" ..
berghofe@22272
   280
    moreover from t' have "Abs t' \<rightarrow>\<^sub>\<eta>\<^sup>* Abs t" by (rule rtrancl_eta_Abs)
berghofe@22272
   281
    ultimately show ?thesis using abs by simp iprover
berghofe@34990
   282
  qed
berghofe@22272
   283
next
berghofe@22272
   284
  case (app u u' t t')
berghofe@22272
   285
  from `s \<rightarrow>\<^sub>\<eta> u \<degree> t` show ?case
berghofe@22272
   286
  proof cases
berghofe@22272
   287
    case (eta s' dummy)
berghofe@22272
   288
    from app have "u \<degree> t => u' \<degree> t'" by simp
berghofe@22272
   289
    with eta have "s'[dummy/0] => u' \<degree> t'" by simp
berghofe@22272
   290
    with `\<not> free s' 0` have "\<exists>r. Abs (s' \<degree> Var 0) => r \<and> r \<rightarrow>\<^sub>\<eta>\<^sup>* u' \<degree> t'"
berghofe@22272
   291
      by (rule eta_case)
berghofe@22272
   292
    with eta show ?thesis by simp
berghofe@22272
   293
  next
berghofe@34990
   294
    case (appL s')
berghofe@34990
   295
    from `s' \<rightarrow>\<^sub>\<eta> u`
berghofe@34990
   296
    obtain r where s': "s' => r" and r: "r \<rightarrow>\<^sub>\<eta>\<^sup>* u'" by (iprover dest: app)
berghofe@22272
   297
    from s' and app have "s' \<degree> t => r \<degree> t'" by simp
berghofe@22272
   298
    moreover from r have "r \<degree> t' \<rightarrow>\<^sub>\<eta>\<^sup>* u' \<degree> t'" by (simp add: rtrancl_eta_AppL)
berghofe@22272
   299
    ultimately show ?thesis using appL by simp iprover
berghofe@22272
   300
  next
berghofe@34990
   301
    case (appR s')
berghofe@34990
   302
    from `s' \<rightarrow>\<^sub>\<eta> t`
berghofe@34990
   303
    obtain r where s': "s' => r" and r: "r \<rightarrow>\<^sub>\<eta>\<^sup>* t'" by (iprover dest: app)
berghofe@22272
   304
    from s' and app have "u \<degree> s' => u' \<degree> r" by simp
berghofe@22272
   305
    moreover from r have "u' \<degree> r \<rightarrow>\<^sub>\<eta>\<^sup>* u' \<degree> t'" by (simp add: rtrancl_eta_AppR)
berghofe@22272
   306
    ultimately show ?thesis using appR by simp iprover
berghofe@34990
   307
  qed
berghofe@22272
   308
next
berghofe@22272
   309
  case (beta u u' t t')
berghofe@22272
   310
  from `s \<rightarrow>\<^sub>\<eta> Abs u \<degree> t` show ?case
berghofe@22272
   311
  proof cases
berghofe@22272
   312
    case (eta s' dummy)
berghofe@22272
   313
    from beta have "Abs u \<degree> t => u'[t'/0]" by simp
berghofe@22272
   314
    with eta have "s'[dummy/0] => u'[t'/0]" by simp
berghofe@22272
   315
    with `\<not> free s' 0` have "\<exists>r. Abs (s' \<degree> Var 0) => r \<and> r \<rightarrow>\<^sub>\<eta>\<^sup>* u'[t'/0]"
berghofe@22272
   316
      by (rule eta_case)
berghofe@22272
   317
    with eta show ?thesis by simp
berghofe@22272
   318
  next
berghofe@34990
   319
    case (appL s')
berghofe@34990
   320
    from `s' \<rightarrow>\<^sub>\<eta> Abs u` show ?thesis
berghofe@22272
   321
    proof cases
berghofe@22272
   322
      case (eta s'' dummy)
berghofe@22272
   323
      have "Abs (lift u 1) = lift (Abs u) 0" by simp
berghofe@22272
   324
      also from eta have "\<dots> = s''" by (simp add: lift_subst_dummy del: lift_subst)
berghofe@22272
   325
      finally have s: "s = Abs (Abs (lift u 1) \<degree> Var 0) \<degree> t" using appL and eta by simp
berghofe@22272
   326
      from beta have "lift u 1 => lift u' 1" by simp
berghofe@22272
   327
      hence "Abs (lift u 1) \<degree> Var 0 => lift u' 1[Var 0/0]"
wenzelm@25973
   328
        using par_beta.var ..
berghofe@22272
   329
      hence "Abs (Abs (lift u 1) \<degree> Var 0) \<degree> t => lift u' 1[Var 0/0][t'/0]"
wenzelm@25973
   330
        using `t => t'` ..
berghofe@22272
   331
      with s have "s => u'[t'/0]" by simp
berghofe@22272
   332
      thus ?thesis by iprover
berghofe@22272
   333
    next
berghofe@34990
   334
      case (abs r)
berghofe@34990
   335
      from `r \<rightarrow>\<^sub>\<eta> u`
berghofe@34990
   336
      obtain r'' where r: "r => r''" and r'': "r'' \<rightarrow>\<^sub>\<eta>\<^sup>* u'" by (iprover dest: beta)
berghofe@22272
   337
      from r and beta have "Abs r \<degree> t => r''[t'/0]" by simp
berghofe@22272
   338
      moreover from r'' have "r''[t'/0] \<rightarrow>\<^sub>\<eta>\<^sup>* u'[t'/0]"
wenzelm@25973
   339
        by (rule rtrancl_eta_subst')
berghofe@22272
   340
      ultimately show ?thesis using abs and appL by simp iprover
berghofe@34990
   341
    qed
berghofe@22272
   342
  next
berghofe@34990
   343
    case (appR s')
berghofe@34990
   344
    from `s' \<rightarrow>\<^sub>\<eta> t`
berghofe@34990
   345
    obtain r where s': "s' => r" and r: "r \<rightarrow>\<^sub>\<eta>\<^sup>* t'" by (iprover dest: beta)
berghofe@22272
   346
    from s' and beta have "Abs u \<degree> s' => u'[r/0]" by simp
berghofe@22272
   347
    moreover from r have "u'[r/0] \<rightarrow>\<^sub>\<eta>\<^sup>* u'[t'/0]"
berghofe@22272
   348
      by (rule rtrancl_eta_subst'')
berghofe@22272
   349
    ultimately show ?thesis using appR by simp iprover
berghofe@34990
   350
  qed
berghofe@22272
   351
qed
berghofe@22272
   352
berghofe@22272
   353
theorem eta_postponement':
berghofe@22272
   354
  assumes eta: "s \<rightarrow>\<^sub>\<eta>\<^sup>* t" and beta: "t => u"
berghofe@22272
   355
  shows "\<exists>t'. s => t' \<and> t' \<rightarrow>\<^sub>\<eta>\<^sup>* u" using eta beta
wenzelm@20503
   356
proof (induct arbitrary: u)
wenzelm@26181
   357
  case base
berghofe@15522
   358
  thus ?case by blast
berghofe@15522
   359
next
wenzelm@26181
   360
  case (step s' s'' s''')
wenzelm@26181
   361
  then obtain t' where s': "s' => t'" and t': "t' \<rightarrow>\<^sub>\<eta>\<^sup>* s'''"
berghofe@22272
   362
    by (auto dest: eta_par_beta)
wenzelm@26181
   363
  from s' obtain t'' where s: "s => t''" and t'': "t'' \<rightarrow>\<^sub>\<eta>\<^sup>* t'" using step
paulson@18557
   364
    by blast
berghofe@23750
   365
  from t'' and t' have "t'' \<rightarrow>\<^sub>\<eta>\<^sup>* s'''" by (rule rtranclp_trans)
nipkow@17589
   366
  with s show ?case by iprover
berghofe@15522
   367
qed
berghofe@15522
   368
berghofe@15522
   369
theorem eta_postponement:
wenzelm@26181
   370
  assumes "(sup beta eta)\<^sup>*\<^sup>* s t"
krauss@32235
   371
  shows "(beta\<^sup>*\<^sup>* OO eta\<^sup>*\<^sup>*) s t" using assms
berghofe@15522
   372
proof induct
wenzelm@26181
   373
  case base
berghofe@15522
   374
  show ?case by blast
berghofe@15522
   375
next
wenzelm@26181
   376
  case (step s' s'')
wenzelm@26181
   377
  from step(3) obtain t' where s: "s \<rightarrow>\<^sub>\<beta>\<^sup>* t'" and t': "t' \<rightarrow>\<^sub>\<eta>\<^sup>* s'" by blast
wenzelm@26181
   378
  from step(2) show ?case
berghofe@15522
   379
  proof
berghofe@22272
   380
    assume "s' \<rightarrow>\<^sub>\<beta> s''"
berghofe@15522
   381
    with beta_subset_par_beta have "s' => s''" ..
berghofe@22272
   382
    with t' obtain t'' where st: "t' => t''" and tu: "t'' \<rightarrow>\<^sub>\<eta>\<^sup>* s''"
berghofe@15522
   383
      by (auto dest: eta_postponement')
berghofe@15522
   384
    from par_beta_subset_beta st have "t' \<rightarrow>\<^sub>\<beta>\<^sup>* t''" ..
berghofe@23750
   385
    with s have "s \<rightarrow>\<^sub>\<beta>\<^sup>* t''" by (rule rtranclp_trans)
berghofe@15522
   386
    thus ?thesis using tu ..
berghofe@15522
   387
  next
berghofe@22272
   388
    assume "s' \<rightarrow>\<^sub>\<eta> s''"
berghofe@22272
   389
    with t' have "t' \<rightarrow>\<^sub>\<eta>\<^sup>* s''" ..
berghofe@15522
   390
    with s show ?thesis ..
berghofe@15522
   391
  qed
berghofe@15522
   392
qed
berghofe@15522
   393
wenzelm@11638
   394
end