author | wenzelm |
Mon, 29 Nov 1999 15:52:49 +0100 | |
changeset 8039 | a901bafe4578 |
parent 6307 | fdf236c98914 |
permissions | -rw-r--r-- |
1269 | 1 |
(* Title: HOL/Lambda/Lambda.ML |
1120 | 2 |
ID: $Id$ |
3 |
Author: Tobias Nipkow |
|
4 |
Copyright 1995 TU Muenchen |
|
5 |
||
2116
73bbf2cc7651
Used trans_tac (see Provers/nat_transitive.ML) to automate arithmetic.
nipkow
parents:
2031
diff
changeset
|
6 |
Substitution-lemmas. |
1120 | 7 |
*) |
8 |
||
9 |
(*** Lambda ***) |
|
10 |
||
6141 | 11 |
val beta_cases = map beta.mk_cases ["Var i -> t", "Abs r -> s", "s $ t -> u"]; |
5261
ce3c25c8a694
First steps towards termination of simply typed terms.
nipkow
parents:
5184
diff
changeset
|
12 |
AddSEs beta_cases; |
1120 | 13 |
|
1974
b50f96543dec
Removed refs to clasets like rel_cs etc. Used implicit claset.
nipkow
parents:
1759
diff
changeset
|
14 |
Delsimps [subst_Var]; |
1269 | 15 |
Addsimps ([if_not_P, not_less_eq] @ beta.intrs); |
1120 | 16 |
|
1302 | 17 |
(* don't add r_into_rtrancl! *) |
1974
b50f96543dec
Removed refs to clasets like rel_cs etc. Used implicit claset.
nipkow
parents:
1759
diff
changeset
|
18 |
AddSIs beta.intrs; |
1120 | 19 |
|
20 |
(*** Congruence rules for ->> ***) |
|
21 |
||
5117 | 22 |
Goal "s ->> s' ==> Abs s ->> Abs s'"; |
1465 | 23 |
by (etac rtrancl_induct 1); |
4089 | 24 |
by (ALLGOALS (blast_tac (claset() addIs [rtrancl_into_rtrancl]))); |
2159
e650a3f6f600
Used nat_trans_tac. New Eta. various smaller changes.
nipkow
parents:
2116
diff
changeset
|
25 |
qed "rtrancl_beta_Abs"; |
e650a3f6f600
Used nat_trans_tac. New Eta. various smaller changes.
nipkow
parents:
2116
diff
changeset
|
26 |
AddSIs [rtrancl_beta_Abs]; |
1120 | 27 |
|
5146 | 28 |
Goal "s ->> s' ==> s $ t ->> s' $ t"; |
1465 | 29 |
by (etac rtrancl_induct 1); |
4089 | 30 |
by (ALLGOALS (blast_tac (claset() addIs [rtrancl_into_rtrancl]))); |
1120 | 31 |
qed "rtrancl_beta_AppL"; |
32 |
||
5146 | 33 |
Goal "t ->> t' ==> s $ t ->> s $ t'"; |
1465 | 34 |
by (etac rtrancl_induct 1); |
4089 | 35 |
by (ALLGOALS (blast_tac (claset() addIs [rtrancl_into_rtrancl]))); |
1120 | 36 |
qed "rtrancl_beta_AppR"; |
37 |
||
5146 | 38 |
Goal "[| s ->> s'; t ->> t' |] ==> s $ t ->> s' $ t'"; |
4089 | 39 |
by (blast_tac (claset() addSIs [rtrancl_beta_AppL, rtrancl_beta_AppR] |
2922 | 40 |
addIs [rtrancl_trans]) 1); |
1120 | 41 |
qed "rtrancl_beta_App"; |
1974
b50f96543dec
Removed refs to clasets like rel_cs etc. Used implicit claset.
nipkow
parents:
1759
diff
changeset
|
42 |
AddIs [rtrancl_beta_App]; |
1120 | 43 |
|
44 |
(*** subst and lift ***) |
|
45 |
||
3919 | 46 |
fun addsplit ss = ss addsimps [subst_Var] |
4831 | 47 |
delsplits [split_if] |
48 |
setloop (split_inside_tac [split_if]); |
|
1120 | 49 |
|
5069 | 50 |
Goal "(Var k)[u/k] = u"; |
4089 | 51 |
by (asm_full_simp_tac(addsplit(simpset())) 1); |
1120 | 52 |
qed "subst_eq"; |
53 |
||
5117 | 54 |
Goal "i<j ==> (Var j)[u/i] = Var(j-1)"; |
4089 | 55 |
by (asm_full_simp_tac(addsplit(simpset())) 1); |
1120 | 56 |
qed "subst_gt"; |
57 |
||
5117 | 58 |
Goal "j<i ==> (Var j)[u/i] = Var(j)"; |
5351 | 59 |
by (asm_full_simp_tac (addsplit(simpset()) addsimps [less_not_refl3]) 1); |
1120 | 60 |
qed "subst_lt"; |
61 |
||
1266 | 62 |
Addsimps [subst_eq,subst_gt,subst_lt]; |
1120 | 63 |
|
5069 | 64 |
Goal |
6307 | 65 |
"!i k. i < k+1 --> lift (lift t i) (Suc k) = lift (lift t k) i"; |
5184 | 66 |
by (induct_tac "t" 1); |
5983 | 67 |
by (Auto_tac); |
1486 | 68 |
qed_spec_mp "lift_lift"; |
1120 | 69 |
|
6307 | 70 |
Goal "!i j s. j < i+1 --> lift (t[s/j]) i = (lift t (i+1)) [lift s i / j]"; |
5184 | 71 |
by (induct_tac "t" 1); |
4360 | 72 |
by (ALLGOALS(asm_simp_tac (simpset() addsimps [diff_Suc,subst_Var,lift_lift] |
5983 | 73 |
addsplits [nat.split]))); |
74 |
by (Auto_tac); |
|
1120 | 75 |
qed "lift_subst"; |
1266 | 76 |
Addsimps [lift_subst]; |
1120 | 77 |
|
5069 | 78 |
Goal |
6307 | 79 |
"!i j s. i < j+1 --> lift (t[s/j]) i = (lift t i) [lift s i / j+1]"; |
5184 | 80 |
by (induct_tac "t" 1); |
5983 | 81 |
by (ALLGOALS(asm_simp_tac (simpset() addsimps [subst_Var,lift_lift]))); |
1120 | 82 |
qed "lift_subst_lt"; |
83 |
||
5069 | 84 |
Goal "!k s. (lift t k)[s/k] = t"; |
5184 | 85 |
by (induct_tac "t" 1); |
4686 | 86 |
by (ALLGOALS Asm_full_simp_tac); |
1120 | 87 |
qed "subst_lift"; |
1266 | 88 |
Addsimps [subst_lift]; |
1120 | 89 |
|
90 |
||
6307 | 91 |
Goal "!i j u v. i < j+1 --> t[lift v i / Suc j][u[v/j]/i] = t[u/i][v/j]"; |
5184 | 92 |
by (induct_tac "t" 1); |
2116
73bbf2cc7651
Used trans_tac (see Provers/nat_transitive.ML) to automate arithmetic.
nipkow
parents:
2031
diff
changeset
|
93 |
by (ALLGOALS(asm_simp_tac |
4360 | 94 |
(simpset() addsimps [diff_Suc,subst_Var,lift_lift RS sym,lift_subst_lt] |
5983 | 95 |
addsplits [nat.split]))); |
2922 | 96 |
by (safe_tac (HOL_cs addSEs [nat_neqE])); |
5983 | 97 |
by (ALLGOALS Simp_tac); |
1486 | 98 |
qed_spec_mp "subst_subst"; |
1153 | 99 |
|
100 |
||
101 |
(*** Equivalence proof for optimized substitution ***) |
|
102 |
||
5069 | 103 |
Goal "!k. liftn 0 t k = t"; |
5184 | 104 |
by (induct_tac "t" 1); |
4089 | 105 |
by (ALLGOALS(asm_simp_tac(addsplit(simpset())))); |
1153 | 106 |
qed "liftn_0"; |
1266 | 107 |
Addsimps [liftn_0]; |
1153 | 108 |
|
5069 | 109 |
Goal "!k. liftn (Suc n) t k = lift (liftn n t k) k"; |
5184 | 110 |
by (induct_tac "t" 1); |
4089 | 111 |
by (ALLGOALS(asm_simp_tac(addsplit(simpset())))); |
1153 | 112 |
qed "liftn_lift"; |
1266 | 113 |
Addsimps [liftn_lift]; |
1153 | 114 |
|
5069 | 115 |
Goal "!n. substn t s n = t[liftn n s 0 / n]"; |
5184 | 116 |
by (induct_tac "t" 1); |
4089 | 117 |
by (ALLGOALS(asm_simp_tac(addsplit(simpset())))); |
1153 | 118 |
qed "substn_subst_n"; |
1266 | 119 |
Addsimps [substn_subst_n]; |
1153 | 120 |
|
5069 | 121 |
Goal "substn t s 0 = t[s/0]"; |
2031 | 122 |
by (Simp_tac 1); |
1153 | 123 |
qed "substn_subst_0"; |
5261
ce3c25c8a694
First steps towards termination of simply typed terms.
nipkow
parents:
5184
diff
changeset
|
124 |
|
ce3c25c8a694
First steps towards termination of simply typed terms.
nipkow
parents:
5184
diff
changeset
|
125 |
(*** Preservation thms ***) |
ce3c25c8a694
First steps towards termination of simply typed terms.
nipkow
parents:
5184
diff
changeset
|
126 |
(* Not used in CR-proof but in SN-proof *) |
ce3c25c8a694
First steps towards termination of simply typed terms.
nipkow
parents:
5184
diff
changeset
|
127 |
|
ce3c25c8a694
First steps towards termination of simply typed terms.
nipkow
parents:
5184
diff
changeset
|
128 |
Goal "r -> s ==> !t i. r[t/i] -> s[t/i]"; |
5326 | 129 |
by (etac beta.induct 1); |
5318 | 130 |
by (ALLGOALS (asm_simp_tac (simpset() addsimps [subst_subst RS sym]))); |
5261
ce3c25c8a694
First steps towards termination of simply typed terms.
nipkow
parents:
5184
diff
changeset
|
131 |
qed_spec_mp "subst_preserves_beta"; |
ce3c25c8a694
First steps towards termination of simply typed terms.
nipkow
parents:
5184
diff
changeset
|
132 |
Addsimps [subst_preserves_beta]; |
ce3c25c8a694
First steps towards termination of simply typed terms.
nipkow
parents:
5184
diff
changeset
|
133 |
|
ce3c25c8a694
First steps towards termination of simply typed terms.
nipkow
parents:
5184
diff
changeset
|
134 |
Goal "r -> s ==> !i. lift r i -> lift s i"; |
5326 | 135 |
by (etac beta.induct 1); |
5318 | 136 |
by (Auto_tac); |
5261
ce3c25c8a694
First steps towards termination of simply typed terms.
nipkow
parents:
5184
diff
changeset
|
137 |
qed_spec_mp "lift_preserves_beta"; |
ce3c25c8a694
First steps towards termination of simply typed terms.
nipkow
parents:
5184
diff
changeset
|
138 |
Addsimps [lift_preserves_beta]; |
ce3c25c8a694
First steps towards termination of simply typed terms.
nipkow
parents:
5184
diff
changeset
|
139 |
|
ce3c25c8a694
First steps towards termination of simply typed terms.
nipkow
parents:
5184
diff
changeset
|
140 |
Goal "!r s i. r -> s --> t[r/i] ->> t[s/i]"; |
5318 | 141 |
by (induct_tac "t" 1); |
142 |
by (asm_simp_tac (addsplit(simpset() addsimps [r_into_rtrancl])) 1); |
|
143 |
by (asm_simp_tac (simpset() addsimps [rtrancl_beta_App]) 1); |
|
144 |
by (asm_simp_tac (simpset() addsimps [rtrancl_beta_Abs]) 1); |
|
5261
ce3c25c8a694
First steps towards termination of simply typed terms.
nipkow
parents:
5184
diff
changeset
|
145 |
qed_spec_mp "subst_preserves_beta2"; |
ce3c25c8a694
First steps towards termination of simply typed terms.
nipkow
parents:
5184
diff
changeset
|
146 |
Addsimps [subst_preserves_beta2]; |