src/HOL/Lambda/Lambda.thy
author haftmann
Tue, 20 Jul 2010 06:35:29 +0200
changeset 37891 c26f9d06e82c
parent 36862 952b2b102a0a
child 39126 ee117c5b3b75
permissions -rw-r--r--
robustified metis proof
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1269
ee011b365770 New version with eta reduction.
nipkow
parents: 1153
diff changeset
     1
(*  Title:      HOL/Lambda/Lambda.thy
1120
ff7dd80513e6 Lambda calculus in de Bruijn notation.
nipkow
parents:
diff changeset
     2
    Author:     Tobias Nipkow
ff7dd80513e6 Lambda calculus in de Bruijn notation.
nipkow
parents:
diff changeset
     3
    Copyright   1995 TU Muenchen
ff7dd80513e6 Lambda calculus in de Bruijn notation.
nipkow
parents:
diff changeset
     4
*)
ff7dd80513e6 Lambda calculus in de Bruijn notation.
nipkow
parents:
diff changeset
     5
9811
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
     6
header {* Basic definitions of Lambda-calculus *}
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
     7
16417
9bc16273c2d4 migrated theory headers to new format
haftmann
parents: 14065
diff changeset
     8
theory Lambda imports Main begin
9811
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
     9
1120
ff7dd80513e6 Lambda calculus in de Bruijn notation.
nipkow
parents:
diff changeset
    10
9811
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
    11
subsection {* Lambda-terms in de Bruijn notation and substitution *}
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
    12
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
    13
datatype dB =
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
    14
    Var nat
12011
1a3a7b3cd9bb tuned notation (degree instead of dollar);
wenzelm
parents: 11943
diff changeset
    15
  | App dB dB (infixl "\<degree>" 200)
9811
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
    16
  | Abs dB
1120
ff7dd80513e6 Lambda calculus in de Bruijn notation.
nipkow
parents:
diff changeset
    17
25974
0cb35fa9c6fa modernized primrec;
wenzelm
parents: 23750
diff changeset
    18
primrec
9811
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
    19
  lift :: "[dB, nat] => dB"
25974
0cb35fa9c6fa modernized primrec;
wenzelm
parents: 23750
diff changeset
    20
where
0cb35fa9c6fa modernized primrec;
wenzelm
parents: 23750
diff changeset
    21
    "lift (Var i) k = (if i < k then Var i else Var (i + 1))"
0cb35fa9c6fa modernized primrec;
wenzelm
parents: 23750
diff changeset
    22
  | "lift (s \<degree> t) k = lift s k \<degree> lift t k"
0cb35fa9c6fa modernized primrec;
wenzelm
parents: 23750
diff changeset
    23
  | "lift (Abs s) k = Abs (lift s (k + 1))"
1153
5c5daf97cf2d Simplified the confluence proofs.
nipkow
parents: 1124
diff changeset
    24
5184
9b8547a9496a Adapted to new datatype package.
berghofe
parents: 5146
diff changeset
    25
primrec
25974
0cb35fa9c6fa modernized primrec;
wenzelm
parents: 23750
diff changeset
    26
  subst :: "[dB, dB, nat] => dB"  ("_[_'/_]" [300, 0, 0] 300)
0cb35fa9c6fa modernized primrec;
wenzelm
parents: 23750
diff changeset
    27
where (* FIXME base names *)
0cb35fa9c6fa modernized primrec;
wenzelm
parents: 23750
diff changeset
    28
    subst_Var: "(Var i)[s/k] =
0cb35fa9c6fa modernized primrec;
wenzelm
parents: 23750
diff changeset
    29
      (if k < i then Var (i - 1) else if i = k then s else Var i)"
0cb35fa9c6fa modernized primrec;
wenzelm
parents: 23750
diff changeset
    30
  | subst_App: "(t \<degree> u)[s/k] = t[s/k] \<degree> u[s/k]"
0cb35fa9c6fa modernized primrec;
wenzelm
parents: 23750
diff changeset
    31
  | subst_Abs: "(Abs t)[s/k] = Abs (t[lift s 0 / k+1])"
9811
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
    32
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
    33
declare subst_Var [simp del]
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
    34
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
    35
text {* Optimized versions of @{term subst} and @{term lift}. *}
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
    36
25974
0cb35fa9c6fa modernized primrec;
wenzelm
parents: 23750
diff changeset
    37
primrec
9811
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
    38
  liftn :: "[nat, dB, nat] => dB"
25974
0cb35fa9c6fa modernized primrec;
wenzelm
parents: 23750
diff changeset
    39
where
0cb35fa9c6fa modernized primrec;
wenzelm
parents: 23750
diff changeset
    40
    "liftn n (Var i) k = (if i < k then Var i else Var (i + n))"
0cb35fa9c6fa modernized primrec;
wenzelm
parents: 23750
diff changeset
    41
  | "liftn n (s \<degree> t) k = liftn n s k \<degree> liftn n t k"
0cb35fa9c6fa modernized primrec;
wenzelm
parents: 23750
diff changeset
    42
  | "liftn n (Abs s) k = Abs (liftn n s (k + 1))"
9811
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
    43
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
    44
primrec
25974
0cb35fa9c6fa modernized primrec;
wenzelm
parents: 23750
diff changeset
    45
  substn :: "[dB, dB, nat] => dB"
0cb35fa9c6fa modernized primrec;
wenzelm
parents: 23750
diff changeset
    46
where
0cb35fa9c6fa modernized primrec;
wenzelm
parents: 23750
diff changeset
    47
    "substn (Var i) s k =
0cb35fa9c6fa modernized primrec;
wenzelm
parents: 23750
diff changeset
    48
      (if k < i then Var (i - 1) else if i = k then liftn k s 0 else Var i)"
0cb35fa9c6fa modernized primrec;
wenzelm
parents: 23750
diff changeset
    49
  | "substn (t \<degree> u) s k = substn t s k \<degree> substn u s k"
0cb35fa9c6fa modernized primrec;
wenzelm
parents: 23750
diff changeset
    50
  | "substn (Abs t) s k = Abs (substn t s (k + 1))"
1120
ff7dd80513e6 Lambda calculus in de Bruijn notation.
nipkow
parents:
diff changeset
    51
9811
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
    52
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
    53
subsection {* Beta-reduction *}
1153
5c5daf97cf2d Simplified the confluence proofs.
nipkow
parents: 1124
diff changeset
    54
23750
a1db5f819d00 - Renamed inductive2 to inductive
berghofe
parents: 22271
diff changeset
    55
inductive beta :: "[dB, dB] => bool"  (infixl "\<rightarrow>\<^sub>\<beta>" 50)
22271
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
    56
  where
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
    57
    beta [simp, intro!]: "Abs s \<degree> t \<rightarrow>\<^sub>\<beta> s[t/0]"
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
    58
  | appL [simp, intro!]: "s \<rightarrow>\<^sub>\<beta> t ==> s \<degree> u \<rightarrow>\<^sub>\<beta> t \<degree> u"
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
    59
  | appR [simp, intro!]: "s \<rightarrow>\<^sub>\<beta> t ==> u \<degree> s \<rightarrow>\<^sub>\<beta> u \<degree> t"
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
    60
  | abs [simp, intro!]: "s \<rightarrow>\<^sub>\<beta> t ==> Abs s \<rightarrow>\<^sub>\<beta> Abs t"
21404
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 21210
diff changeset
    61
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 21210
diff changeset
    62
abbreviation
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 21210
diff changeset
    63
  beta_reds :: "[dB, dB] => bool"  (infixl "->>" 50) where
22271
51a80e238b29 Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
    64
  "s ->> t == beta^** s t"
19086
1b3780be6cc2 new-style definitions/abbreviations;
wenzelm
parents: 18257
diff changeset
    65
21210
c17fd2df4e9e renamed 'const_syntax' to 'notation';
wenzelm
parents: 20503
diff changeset
    66
notation (latex)
19656
09be06943252 tuned concrete syntax -- abbreviation/const_syntax;
wenzelm
parents: 19380
diff changeset
    67
  beta_reds  (infixl "\<rightarrow>\<^sub>\<beta>\<^sup>*" 50)
1120
ff7dd80513e6 Lambda calculus in de Bruijn notation.
nipkow
parents:
diff changeset
    68
23750
a1db5f819d00 - Renamed inductive2 to inductive
berghofe
parents: 22271
diff changeset
    69
inductive_cases beta_cases [elim!]:
14065
8abaf978c9c2 Nicer syntax for beta reduction.
berghofe
parents: 13915
diff changeset
    70
  "Var i \<rightarrow>\<^sub>\<beta> t"
8abaf978c9c2 Nicer syntax for beta reduction.
berghofe
parents: 13915
diff changeset
    71
  "Abs r \<rightarrow>\<^sub>\<beta> s"
8abaf978c9c2 Nicer syntax for beta reduction.
berghofe
parents: 13915
diff changeset
    72
  "s \<degree> t \<rightarrow>\<^sub>\<beta> u"
9811
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
    73
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
    74
declare if_not_P [simp] not_less_eq [simp]
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
    75
  -- {* don't add @{text "r_into_rtrancl[intro!]"} *}
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
    76
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
    77
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
    78
subsection {* Congruence rules *}
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
    79
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
    80
lemma rtrancl_beta_Abs [intro!]:
14065
8abaf978c9c2 Nicer syntax for beta reduction.
berghofe
parents: 13915
diff changeset
    81
    "s \<rightarrow>\<^sub>\<beta>\<^sup>* s' ==> Abs s \<rightarrow>\<^sub>\<beta>\<^sup>* Abs s'"
23750
a1db5f819d00 - Renamed inductive2 to inductive
berghofe
parents: 22271
diff changeset
    82
  by (induct set: rtranclp) (blast intro: rtranclp.rtrancl_into_rtrancl)+
9811
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
    83
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
    84
lemma rtrancl_beta_AppL:
14065
8abaf978c9c2 Nicer syntax for beta reduction.
berghofe
parents: 13915
diff changeset
    85
    "s \<rightarrow>\<^sub>\<beta>\<^sup>* s' ==> s \<degree> t \<rightarrow>\<^sub>\<beta>\<^sup>* s' \<degree> t"
23750
a1db5f819d00 - Renamed inductive2 to inductive
berghofe
parents: 22271
diff changeset
    86
  by (induct set: rtranclp) (blast intro: rtranclp.rtrancl_into_rtrancl)+
9811
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
    87
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
    88
lemma rtrancl_beta_AppR:
14065
8abaf978c9c2 Nicer syntax for beta reduction.
berghofe
parents: 13915
diff changeset
    89
    "t \<rightarrow>\<^sub>\<beta>\<^sup>* t' ==> s \<degree> t \<rightarrow>\<^sub>\<beta>\<^sup>* s \<degree> t'"
23750
a1db5f819d00 - Renamed inductive2 to inductive
berghofe
parents: 22271
diff changeset
    90
  by (induct set: rtranclp) (blast intro: rtranclp.rtrancl_into_rtrancl)+
9811
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
    91
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
    92
lemma rtrancl_beta_App [intro]:
14065
8abaf978c9c2 Nicer syntax for beta reduction.
berghofe
parents: 13915
diff changeset
    93
    "[| s \<rightarrow>\<^sub>\<beta>\<^sup>* s'; t \<rightarrow>\<^sub>\<beta>\<^sup>* t' |] ==> s \<degree> t \<rightarrow>\<^sub>\<beta>\<^sup>* s' \<degree> t'"
23750
a1db5f819d00 - Renamed inductive2 to inductive
berghofe
parents: 22271
diff changeset
    94
  by (blast intro!: rtrancl_beta_AppL rtrancl_beta_AppR intro: rtranclp_trans)
9811
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
    95
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
    96
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
    97
subsection {* Substitution-lemmas *}
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
    98
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
    99
lemma subst_eq [simp]: "(Var k)[u/k] = u"
18241
afdba6b3e383 tuned induction proofs;
wenzelm
parents: 16417
diff changeset
   100
  by (simp add: subst_Var)
9811
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
   101
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
   102
lemma subst_gt [simp]: "i < j ==> (Var j)[u/i] = Var (j - 1)"
18241
afdba6b3e383 tuned induction proofs;
wenzelm
parents: 16417
diff changeset
   103
  by (simp add: subst_Var)
9811
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
   104
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
   105
lemma subst_lt [simp]: "j < i ==> (Var j)[u/i] = Var j"
18241
afdba6b3e383 tuned induction proofs;
wenzelm
parents: 16417
diff changeset
   106
  by (simp add: subst_Var)
9811
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
   107
18241
afdba6b3e383 tuned induction proofs;
wenzelm
parents: 16417
diff changeset
   108
lemma lift_lift:
afdba6b3e383 tuned induction proofs;
wenzelm
parents: 16417
diff changeset
   109
    "i < k + 1 \<Longrightarrow> lift (lift t i) (Suc k) = lift (lift t k) i"
20503
503ac4c5ef91 induct method: renamed 'fixing' to 'arbitrary';
wenzelm
parents: 19656
diff changeset
   110
  by (induct t arbitrary: i k) auto
9811
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
   111
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
   112
lemma lift_subst [simp]:
18241
afdba6b3e383 tuned induction proofs;
wenzelm
parents: 16417
diff changeset
   113
    "j < i + 1 \<Longrightarrow> lift (t[s/j]) i = (lift t (i + 1)) [lift s i / j]"
20503
503ac4c5ef91 induct method: renamed 'fixing' to 'arbitrary';
wenzelm
parents: 19656
diff changeset
   114
  by (induct t arbitrary: i j s)
18241
afdba6b3e383 tuned induction proofs;
wenzelm
parents: 16417
diff changeset
   115
    (simp_all add: diff_Suc subst_Var lift_lift split: nat.split)
9811
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
   116
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
   117
lemma lift_subst_lt:
18241
afdba6b3e383 tuned induction proofs;
wenzelm
parents: 16417
diff changeset
   118
    "i < j + 1 \<Longrightarrow> lift (t[s/j]) i = (lift t i) [lift s i / j + 1]"
20503
503ac4c5ef91 induct method: renamed 'fixing' to 'arbitrary';
wenzelm
parents: 19656
diff changeset
   119
  by (induct t arbitrary: i j s) (simp_all add: subst_Var lift_lift)
9811
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
   120
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
   121
lemma subst_lift [simp]:
18241
afdba6b3e383 tuned induction proofs;
wenzelm
parents: 16417
diff changeset
   122
    "(lift t k)[s/k] = t"
20503
503ac4c5ef91 induct method: renamed 'fixing' to 'arbitrary';
wenzelm
parents: 19656
diff changeset
   123
  by (induct t arbitrary: k s) simp_all
9811
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
   124
18241
afdba6b3e383 tuned induction proofs;
wenzelm
parents: 16417
diff changeset
   125
lemma subst_subst:
afdba6b3e383 tuned induction proofs;
wenzelm
parents: 16417
diff changeset
   126
    "i < j + 1 \<Longrightarrow> t[lift v i / Suc j][u[v/j]/i] = t[u/i][v/j]"
20503
503ac4c5ef91 induct method: renamed 'fixing' to 'arbitrary';
wenzelm
parents: 19656
diff changeset
   127
  by (induct t arbitrary: i j u v)
18241
afdba6b3e383 tuned induction proofs;
wenzelm
parents: 16417
diff changeset
   128
    (simp_all add: diff_Suc subst_Var lift_lift [symmetric] lift_subst_lt
9811
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
   129
      split: nat.split)
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
   130
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
   131
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
   132
subsection {* Equivalence proof for optimized substitution *}
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
   133
18241
afdba6b3e383 tuned induction proofs;
wenzelm
parents: 16417
diff changeset
   134
lemma liftn_0 [simp]: "liftn 0 t k = t"
20503
503ac4c5ef91 induct method: renamed 'fixing' to 'arbitrary';
wenzelm
parents: 19656
diff changeset
   135
  by (induct t arbitrary: k) (simp_all add: subst_Var)
9811
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
   136
18241
afdba6b3e383 tuned induction proofs;
wenzelm
parents: 16417
diff changeset
   137
lemma liftn_lift [simp]: "liftn (Suc n) t k = lift (liftn n t k) k"
20503
503ac4c5ef91 induct method: renamed 'fixing' to 'arbitrary';
wenzelm
parents: 19656
diff changeset
   138
  by (induct t arbitrary: k) (simp_all add: subst_Var)
9811
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
   139
18241
afdba6b3e383 tuned induction proofs;
wenzelm
parents: 16417
diff changeset
   140
lemma substn_subst_n [simp]: "substn t s n = t[liftn n s 0 / n]"
20503
503ac4c5ef91 induct method: renamed 'fixing' to 'arbitrary';
wenzelm
parents: 19656
diff changeset
   141
  by (induct t arbitrary: n) (simp_all add: subst_Var)
9811
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
   142
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
   143
theorem substn_subst_0: "substn t s 0 = t[s/0]"
18241
afdba6b3e383 tuned induction proofs;
wenzelm
parents: 16417
diff changeset
   144
  by simp
9811
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
   145
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
   146
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
   147
subsection {* Preservation theorems *}
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
   148
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
   149
text {* Not used in Church-Rosser proof, but in Strong
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
   150
  Normalization. \medskip *}
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
   151
13915
28ccb51bd2f3 Eliminated most occurrences of rule_format attribute.
berghofe
parents: 13187
diff changeset
   152
theorem subst_preserves_beta [simp]:
18257
2124b24454dd tuned induct proofs;
wenzelm
parents: 18241
diff changeset
   153
    "r \<rightarrow>\<^sub>\<beta> s ==> r[t/i] \<rightarrow>\<^sub>\<beta> s[t/i]"
20503
503ac4c5ef91 induct method: renamed 'fixing' to 'arbitrary';
wenzelm
parents: 19656
diff changeset
   154
  by (induct arbitrary: t i set: beta) (simp_all add: subst_subst [symmetric])
9811
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
   155
14065
8abaf978c9c2 Nicer syntax for beta reduction.
berghofe
parents: 13915
diff changeset
   156
theorem subst_preserves_beta': "r \<rightarrow>\<^sub>\<beta>\<^sup>* s ==> r[t/i] \<rightarrow>\<^sub>\<beta>\<^sup>* s[t/i]"
23750
a1db5f819d00 - Renamed inductive2 to inductive
berghofe
parents: 22271
diff changeset
   157
  apply (induct set: rtranclp)
a1db5f819d00 - Renamed inductive2 to inductive
berghofe
parents: 22271
diff changeset
   158
   apply (rule rtranclp.rtrancl_refl)
a1db5f819d00 - Renamed inductive2 to inductive
berghofe
parents: 22271
diff changeset
   159
  apply (erule rtranclp.rtrancl_into_rtrancl)
14065
8abaf978c9c2 Nicer syntax for beta reduction.
berghofe
parents: 13915
diff changeset
   160
  apply (erule subst_preserves_beta)
8abaf978c9c2 Nicer syntax for beta reduction.
berghofe
parents: 13915
diff changeset
   161
  done
8abaf978c9c2 Nicer syntax for beta reduction.
berghofe
parents: 13915
diff changeset
   162
13915
28ccb51bd2f3 Eliminated most occurrences of rule_format attribute.
berghofe
parents: 13187
diff changeset
   163
theorem lift_preserves_beta [simp]:
18257
2124b24454dd tuned induct proofs;
wenzelm
parents: 18241
diff changeset
   164
    "r \<rightarrow>\<^sub>\<beta> s ==> lift r i \<rightarrow>\<^sub>\<beta> lift s i"
20503
503ac4c5ef91 induct method: renamed 'fixing' to 'arbitrary';
wenzelm
parents: 19656
diff changeset
   165
  by (induct arbitrary: i set: beta) auto
9811
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
   166
14065
8abaf978c9c2 Nicer syntax for beta reduction.
berghofe
parents: 13915
diff changeset
   167
theorem lift_preserves_beta': "r \<rightarrow>\<^sub>\<beta>\<^sup>* s ==> lift r i \<rightarrow>\<^sub>\<beta>\<^sup>* lift s i"
23750
a1db5f819d00 - Renamed inductive2 to inductive
berghofe
parents: 22271
diff changeset
   168
  apply (induct set: rtranclp)
a1db5f819d00 - Renamed inductive2 to inductive
berghofe
parents: 22271
diff changeset
   169
   apply (rule rtranclp.rtrancl_refl)
a1db5f819d00 - Renamed inductive2 to inductive
berghofe
parents: 22271
diff changeset
   170
  apply (erule rtranclp.rtrancl_into_rtrancl)
14065
8abaf978c9c2 Nicer syntax for beta reduction.
berghofe
parents: 13915
diff changeset
   171
  apply (erule lift_preserves_beta)
8abaf978c9c2 Nicer syntax for beta reduction.
berghofe
parents: 13915
diff changeset
   172
  done
8abaf978c9c2 Nicer syntax for beta reduction.
berghofe
parents: 13915
diff changeset
   173
18241
afdba6b3e383 tuned induction proofs;
wenzelm
parents: 16417
diff changeset
   174
theorem subst_preserves_beta2 [simp]: "r \<rightarrow>\<^sub>\<beta> s ==> t[r/i] \<rightarrow>\<^sub>\<beta>\<^sup>* t[s/i]"
20503
503ac4c5ef91 induct method: renamed 'fixing' to 'arbitrary';
wenzelm
parents: 19656
diff changeset
   175
  apply (induct t arbitrary: r s i)
23750
a1db5f819d00 - Renamed inductive2 to inductive
berghofe
parents: 22271
diff changeset
   176
    apply (simp add: subst_Var r_into_rtranclp)
9811
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
   177
   apply (simp add: rtrancl_beta_App)
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
   178
  apply (simp add: rtrancl_beta_Abs)
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
   179
  done
39ffdb8cab03 HOL/Lambda: converted into new-style theory and document;
wenzelm
parents: 6453
diff changeset
   180
14065
8abaf978c9c2 Nicer syntax for beta reduction.
berghofe
parents: 13915
diff changeset
   181
theorem subst_preserves_beta2': "r \<rightarrow>\<^sub>\<beta>\<^sup>* s ==> t[r/i] \<rightarrow>\<^sub>\<beta>\<^sup>* t[s/i]"
23750
a1db5f819d00 - Renamed inductive2 to inductive
berghofe
parents: 22271
diff changeset
   182
  apply (induct set: rtranclp)
a1db5f819d00 - Renamed inductive2 to inductive
berghofe
parents: 22271
diff changeset
   183
   apply (rule rtranclp.rtrancl_refl)
a1db5f819d00 - Renamed inductive2 to inductive
berghofe
parents: 22271
diff changeset
   184
  apply (erule rtranclp_trans)
14065
8abaf978c9c2 Nicer syntax for beta reduction.
berghofe
parents: 13915
diff changeset
   185
  apply (erule subst_preserves_beta2)
8abaf978c9c2 Nicer syntax for beta reduction.
berghofe
parents: 13915
diff changeset
   186
  done
8abaf978c9c2 Nicer syntax for beta reduction.
berghofe
parents: 13915
diff changeset
   187
11638
2c3dee321b4b inductive: no collective atts;
wenzelm
parents: 10851
diff changeset
   188
end