author | clasohm |
Tue, 24 Oct 1995 14:59:17 +0100 | |
changeset 251 | f04b33ce250f |
parent 226 | da0e86b4b352 |
permissions | -rw-r--r-- |
168 | 1 |
(* Title: HOL/IOA/example/Lemmas.ML |
2 |
ID: $Id$ |
|
3 |
Author: Tobias Nipkow & Konrad Slind |
|
4 |
Copyright 1994 TU Muenchen |
|
5 |
||
6 |
(Mostly) Arithmetic lemmas |
|
7 |
Should realy go in Arith.ML. |
|
8 |
Also: Get rid of all the --> in favour of ==> !!! |
|
9 |
*) |
|
10 |
||
156 | 11 |
(* Logic *) |
12 |
val prems = goal HOL.thy "(P ==> Q-->R) ==> P&Q --> R"; |
|
13 |
by(fast_tac (HOL_cs addDs prems) 1); |
|
171 | 14 |
qed "imp_conj_lemma"; |
156 | 15 |
|
16 |
goal HOL.thy "(P --> (? x. Q(x))) = (? x. P --> Q(x))"; |
|
17 |
by(fast_tac HOL_cs 1); |
|
171 | 18 |
qed "imp_ex_equiv"; |
156 | 19 |
|
20 |
goal HOL.thy "(A --> B & C) = ((A --> B) & (A --> C))"; |
|
21 |
by (fast_tac HOL_cs 1); |
|
171 | 22 |
qed "fork_lemma"; |
156 | 23 |
|
24 |
goal HOL.thy "((A --> B) & (C --> B)) = ((A | C) --> B)"; |
|
25 |
by (fast_tac HOL_cs 1); |
|
171 | 26 |
qed "imp_or_lem"; |
156 | 27 |
|
28 |
goal HOL.thy "(X = (~ Y)) = ((~X) = Y)"; |
|
29 |
by (fast_tac HOL_cs 1); |
|
171 | 30 |
qed "neg_flip"; |
156 | 31 |
|
32 |
goal HOL.thy "P --> Q(M) --> Q(if(P,M,N))"; |
|
33 |
by (rtac impI 1); |
|
34 |
by (rtac impI 1); |
|
35 |
by (rtac (expand_if RS iffD2) 1); |
|
36 |
by (fast_tac HOL_cs 1); |
|
171 | 37 |
qed "imp_true_decompose"; |
156 | 38 |
|
39 |
goal HOL.thy "(~P) --> Q(N) --> Q(if(P,M,N))"; |
|
40 |
by (rtac impI 1); |
|
41 |
by (rtac impI 1); |
|
42 |
by (rtac (expand_if RS iffD2) 1); |
|
43 |
by (fast_tac HOL_cs 1); |
|
171 | 44 |
qed "imp_false_decompose"; |
156 | 45 |
|
46 |
||
47 |
(* Sets *) |
|
48 |
val set_lemmas = |
|
49 |
map (fn s => prove_goal Set.thy s (fn _ => [fast_tac set_cs 1])) |
|
50 |
["f(x) : (UN x. {f(x)})", |
|
51 |
"f(x,y) : (UN x y. {f(x,y)})", |
|
52 |
"!!a. (!x. a ~= f(x)) ==> a ~: (UN x. {f(x)})", |
|
53 |
"!!a. (!x y. a ~= f(x,y)) ==> a ~: (UN x y. {f(x,y)})"]; |
|
54 |
||
55 |
||
56 |
(* Arithmetic *) |
|
57 |
goal Arith.thy "n ~= 0 --> Suc(m+pred(n)) = m+n"; |
|
58 |
by (nat_ind_tac "n" 1); |
|
59 |
by (REPEAT(simp_tac arith_ss 1)); |
|
171 | 60 |
val Suc_pred_lemma = store_thm("Suc_pred_lemma", result() RS mp); |
156 | 61 |
|
62 |
goal Arith.thy "x <= y --> x <= Suc(y)"; |
|
63 |
by (rtac impI 1); |
|
64 |
by (rtac (le_eq_less_or_eq RS iffD2) 1); |
|
65 |
by (rtac disjI1 1); |
|
66 |
by (dtac (le_eq_less_or_eq RS iffD1) 1); |
|
67 |
by (etac disjE 1); |
|
68 |
by (etac less_SucI 1); |
|
69 |
by (asm_simp_tac nat_ss 1); |
|
171 | 70 |
val leq_imp_leq_suc = store_thm("leq_imp_leq_suc", result() RS mp); |
156 | 71 |
|
72 |
(* Same as previous! *) |
|
73 |
goal Arith.thy "(x::nat)<=y --> x<=Suc(y)"; |
|
74 |
by (simp_tac (arith_ss addsimps [le_eq_less_or_eq]) 1); |
|
171 | 75 |
qed "leq_suc"; |
156 | 76 |
|
77 |
goal Arith.thy "((m::nat) + n = m + p) = (n = p)"; |
|
78 |
by (nat_ind_tac "m" 1); |
|
79 |
by (simp_tac arith_ss 1); |
|
80 |
by (asm_simp_tac arith_ss 1); |
|
171 | 81 |
qed "left_plus_cancel"; |
156 | 82 |
|
83 |
goal Arith.thy "((x::nat) + y = Suc(x + z)) = (y = Suc(z))"; |
|
84 |
by (nat_ind_tac "x" 1); |
|
85 |
by (simp_tac arith_ss 1); |
|
86 |
by (asm_simp_tac arith_ss 1); |
|
171 | 87 |
qed "left_plus_cancel_inside_succ"; |
156 | 88 |
|
89 |
goal Arith.thy "(x ~= 0) = (? y. x = Suc(y))"; |
|
90 |
by (nat_ind_tac "x" 1); |
|
91 |
by (simp_tac arith_ss 1); |
|
92 |
by (asm_simp_tac arith_ss 1); |
|
93 |
by (fast_tac HOL_cs 1); |
|
171 | 94 |
qed "nonzero_is_succ"; |
156 | 95 |
|
96 |
goal Arith.thy "(m::nat) < n --> m + p < n + p"; |
|
97 |
by (nat_ind_tac "p" 1); |
|
98 |
by (simp_tac arith_ss 1); |
|
99 |
by (asm_simp_tac arith_ss 1); |
|
171 | 100 |
qed "less_add_same_less"; |
156 | 101 |
|
102 |
goal Arith.thy "(x::nat)<= y --> x<=y+k"; |
|
103 |
by (nat_ind_tac "k" 1); |
|
104 |
by (simp_tac arith_ss 1); |
|
105 |
by (asm_full_simp_tac (arith_ss addsimps [leq_suc]) 1); |
|
171 | 106 |
qed "leq_add_leq"; |
156 | 107 |
|
108 |
goal Arith.thy "(x::nat) + y <= z --> x <= z"; |
|
109 |
by (nat_ind_tac "y" 1); |
|
110 |
by (simp_tac arith_ss 1); |
|
111 |
by (asm_simp_tac arith_ss 1); |
|
112 |
by (rtac impI 1); |
|
113 |
by (dtac Suc_leD 1); |
|
114 |
by (fast_tac HOL_cs 1); |
|
171 | 115 |
qed "left_add_leq"; |
156 | 116 |
|
117 |
goal Arith.thy "(A::nat) < B --> C < D --> A + C < B + D"; |
|
118 |
by (rtac impI 1); |
|
119 |
by (rtac impI 1); |
|
120 |
by (rtac less_trans 1); |
|
121 |
by (rtac (less_add_same_less RS mp) 1); |
|
122 |
by (assume_tac 1); |
|
123 |
by (rtac (add_commute RS ssubst)1);; |
|
124 |
by (res_inst_tac [("m1","B")] (add_commute RS ssubst) 1); |
|
125 |
by (rtac (less_add_same_less RS mp) 1); |
|
126 |
by (assume_tac 1); |
|
171 | 127 |
qed "less_add_cong"; |
156 | 128 |
|
129 |
goal Arith.thy "(A::nat) <= B --> C <= D --> A + C <= B + D"; |
|
130 |
by (rtac impI 1); |
|
131 |
by (rtac impI 1); |
|
132 |
by (asm_full_simp_tac (arith_ss addsimps [le_eq_less_or_eq]) 1); |
|
133 |
by (safe_tac HOL_cs); |
|
134 |
by (rtac (less_add_cong RS mp RS mp) 1); |
|
135 |
by (assume_tac 1); |
|
136 |
by (assume_tac 1); |
|
137 |
by (rtac (less_add_same_less RS mp) 1); |
|
138 |
by (assume_tac 1); |
|
139 |
by (rtac (add_commute RS ssubst)1);; |
|
140 |
by (res_inst_tac [("m1","B")] (add_commute RS ssubst) 1); |
|
141 |
by (rtac (less_add_same_less RS mp) 1); |
|
142 |
by (assume_tac 1); |
|
171 | 143 |
qed "less_eq_add_cong"; |
156 | 144 |
|
145 |
goal Arith.thy "(w <= y) --> ((x::nat) + y <= z) --> (x + w <= z)"; |
|
146 |
by (rtac impI 1); |
|
147 |
by (dtac (less_eq_add_cong RS mp) 1); |
|
148 |
by (cut_facts_tac [le_refl] 1); |
|
149 |
by (dres_inst_tac [("P","x<=x")] mp 1);by (assume_tac 1); |
|
150 |
by (asm_full_simp_tac (HOL_ss addsimps [add_commute]) 1); |
|
151 |
by (rtac impI 1); |
|
152 |
by (etac le_trans 1); |
|
153 |
by (assume_tac 1); |
|
171 | 154 |
qed "leq_add_left_cong"; |
156 | 155 |
|
156 |
goal Arith.thy "(? x. y = Suc(x)) = (~(y = 0))"; |
|
157 |
by (nat_ind_tac "y" 1); |
|
158 |
by (simp_tac arith_ss 1); |
|
159 |
by (rtac iffI 1); |
|
160 |
by (asm_full_simp_tac arith_ss 1); |
|
161 |
by (fast_tac HOL_cs 1); |
|
171 | 162 |
qed "suc_not_zero"; |
156 | 163 |
|
164 |
goal Arith.thy "Suc(x) <= y --> (? z. y = Suc(z))"; |
|
165 |
by (rtac impI 1); |
|
166 |
by (asm_full_simp_tac (arith_ss addsimps [le_eq_less_or_eq]) 1); |
|
167 |
by (safe_tac HOL_cs); |
|
168 |
by (fast_tac HOL_cs 2); |
|
169 |
by (asm_simp_tac (arith_ss addsimps [suc_not_zero]) 1); |
|
170 |
by (rtac ccontr 1); |
|
171 |
by (asm_full_simp_tac (arith_ss addsimps [suc_not_zero]) 1); |
|
172 |
by (hyp_subst_tac 1); |
|
173 |
by (asm_full_simp_tac arith_ss 1); |
|
171 | 174 |
qed "suc_leq_suc"; |
156 | 175 |
|
176 |
goal Arith.thy "~0<n --> n = 0"; |
|
177 |
by (nat_ind_tac "n" 1); |
|
178 |
by (asm_simp_tac arith_ss 1); |
|
179 |
by (safe_tac HOL_cs); |
|
180 |
by (asm_full_simp_tac arith_ss 1); |
|
181 |
by (asm_full_simp_tac arith_ss 1); |
|
171 | 182 |
qed "zero_eq"; |
156 | 183 |
|
184 |
goal Arith.thy "x < Suc(y) --> x<=y"; |
|
185 |
by (nat_ind_tac "n" 1); |
|
186 |
by (asm_simp_tac arith_ss 1); |
|
187 |
by (safe_tac HOL_cs); |
|
188 |
by (etac less_imp_le 1); |
|
171 | 189 |
qed "less_suc_imp_leq"; |
156 | 190 |
|
191 |
goal Arith.thy "0<x --> Suc(pred(x)) = x"; |
|
192 |
by (nat_ind_tac "x" 1); |
|
193 |
by (simp_tac arith_ss 1); |
|
194 |
by (asm_simp_tac arith_ss 1); |
|
171 | 195 |
qed "suc_pred_id"; |
156 | 196 |
|
197 |
goal Arith.thy "0<x --> (pred(x) = y) = (x = Suc(y))"; |
|
198 |
by (nat_ind_tac "x" 1); |
|
199 |
by (simp_tac arith_ss 1); |
|
200 |
by (asm_simp_tac arith_ss 1); |
|
171 | 201 |
qed "pred_suc"; |
156 | 202 |
|
203 |
goal Arith.thy "(x ~= 0) = (0<x)"; |
|
204 |
by (nat_ind_tac "x" 1); |
|
205 |
by (simp_tac arith_ss 1); |
|
206 |
by (asm_simp_tac arith_ss 1); |
|
171 | 207 |
qed "unzero_less"; |
156 | 208 |
|
209 |
(* Odd proof. Why do induction? *) |
|
210 |
goal Arith.thy "((x::nat) = y + z) --> (y <= x)"; |
|
211 |
by (nat_ind_tac "y" 1); |
|
212 |
by (simp_tac arith_ss 1); |
|
213 |
by (simp_tac (arith_ss addsimps |
|
226
da0e86b4b352
Moved succ_leq_mono from IOA/example/Lemmas to Nat.ML as Suc_le_mono.
lcp
parents:
193
diff
changeset
|
214 |
[Suc_le_mono, le_refl RS (leq_add_leq RS mp)]) 1); |
171 | 215 |
qed "plus_leq_lem"; |
156 | 216 |
|
217 |
(* Lists *) |
|
218 |
||
193 | 219 |
goal List.thy "(xs @ (y#ys)) ~= []"; |
220 |
by (list.induct_tac "xs" 1); |
|
156 | 221 |
by (simp_tac list_ss 1); |
222 |
by (asm_simp_tac list_ss 1); |
|
171 | 223 |
qed "append_cons"; |
156 | 224 |
|
193 | 225 |
goal List.thy "(x ~= hd(xs@ys)) = (x ~= if(xs = [], hd(ys), hd(xs)))"; |
226 |
by (list.induct_tac "xs" 1); |
|
156 | 227 |
by (simp_tac list_ss 1); |
228 |
by (asm_full_simp_tac list_ss 1); |
|
171 | 229 |
qed "not_hd_append"; |
156 | 230 |
|
231 |
goal List.thy "(L = (x#rst)) --> (L = []) --> P"; |
|
232 |
by (simp_tac list_ss 1); |
|
171 | 233 |
qed "list_cases"; |
156 | 234 |
|
235 |
goal List.thy "(? L2. L1 = x#L2) --> (L1 ~= [])"; |
|
236 |
by (strip_tac 1); |
|
237 |
by (etac exE 1); |
|
238 |
by (asm_simp_tac list_ss 1); |
|
171 | 239 |
qed "cons_imp_not_null"; |