author | wenzelm |
Fri, 19 Jan 2007 22:08:04 +0100 | |
changeset 22097 | 7ee0529c5674 |
parent 16585 | 02cf78f0afce |
child 23498 | 4db8aa43076c |
permissions | -rw-r--r-- |
10603 | 1 |
(* ID: $Id$ *) |
16417 | 2 |
theory Numbers imports Real begin |
10603 | 3 |
|
4 |
ML "Pretty.setmargin 64" |
|
22097 | 5 |
ML "ThyOutput.indent := 0" (*we don't want 5 for listing theorems*) |
10603 | 6 |
|
7 |
text{* |
|
8 |
||
9 |
numeric literals; default simprules; can re-orient |
|
10 |
*} |
|
11 |
||
11711 | 12 |
lemma "2 * m = m + m" |
10880 | 13 |
txt{* |
14 |
@{subgoals[display,indent=0,margin=65]} |
|
15 |
*}; |
|
10603 | 16 |
oops |
17 |
||
10880 | 18 |
consts h :: "nat \<Rightarrow> nat" |
19 |
recdef h "{}" |
|
11711 | 20 |
"h i = (if i = 3 then 2 else i)" |
10880 | 21 |
|
10603 | 22 |
text{* |
11711 | 23 |
@{term"h 3 = 2"} |
10880 | 24 |
@{term"h i = i"} |
25 |
*} |
|
10603 | 26 |
|
10880 | 27 |
text{* |
10603 | 28 |
@{thm[display] numeral_0_eq_0[no_vars]} |
29 |
\rulename{numeral_0_eq_0} |
|
30 |
||
31 |
@{thm[display] numeral_1_eq_1[no_vars]} |
|
32 |
\rulename{numeral_1_eq_1} |
|
33 |
||
34 |
@{thm[display] add_2_eq_Suc[no_vars]} |
|
35 |
\rulename{add_2_eq_Suc} |
|
36 |
||
37 |
@{thm[display] add_2_eq_Suc'[no_vars]} |
|
38 |
\rulename{add_2_eq_Suc'} |
|
39 |
||
40 |
@{thm[display] add_assoc[no_vars]} |
|
41 |
\rulename{add_assoc} |
|
42 |
||
43 |
@{thm[display] add_commute[no_vars]} |
|
44 |
\rulename{add_commute} |
|
45 |
||
46 |
@{thm[display] add_left_commute[no_vars]} |
|
47 |
\rulename{add_left_commute} |
|
48 |
||
49 |
these form add_ac; similarly there is mult_ac |
|
50 |
*} |
|
51 |
||
52 |
lemma "Suc(i + j*l*k + m*n) = f (n*m + i + k*j*l)" |
|
10880 | 53 |
txt{* |
54 |
@{subgoals[display,indent=0,margin=65]} |
|
55 |
*}; |
|
10603 | 56 |
apply (simp add: add_ac mult_ac) |
10880 | 57 |
txt{* |
58 |
@{subgoals[display,indent=0,margin=65]} |
|
59 |
*}; |
|
10603 | 60 |
oops |
61 |
||
62 |
text{* |
|
63 |
||
64 |
@{thm[display] div_le_mono[no_vars]} |
|
65 |
\rulename{div_le_mono} |
|
66 |
||
67 |
@{thm[display] diff_mult_distrib[no_vars]} |
|
68 |
\rulename{diff_mult_distrib} |
|
69 |
||
70 |
@{thm[display] mod_mult_distrib[no_vars]} |
|
71 |
\rulename{mod_mult_distrib} |
|
72 |
||
73 |
@{thm[display] nat_diff_split[no_vars]} |
|
74 |
\rulename{nat_diff_split} |
|
75 |
*} |
|
76 |
||
77 |
||
12156
d2758965362e
new-style numerals without leading #, along with generic 0 and 1
paulson
parents:
11711
diff
changeset
|
78 |
lemma "(n - 1) * (n + 1) = n * n - (1::nat)" |
12843
50bd380e6675
iff del: less_Suc0 -- luckily this does NOT affect the printed text;
wenzelm
parents:
12156
diff
changeset
|
79 |
apply (clarsimp split: nat_diff_split iff del: less_Suc0) |
12156
d2758965362e
new-style numerals without leading #, along with generic 0 and 1
paulson
parents:
11711
diff
changeset
|
80 |
--{* @{subgoals[display,indent=0,margin=65]} *} |
d2758965362e
new-style numerals without leading #, along with generic 0 and 1
paulson
parents:
11711
diff
changeset
|
81 |
apply (subgoal_tac "n=0", force, arith) |
d2758965362e
new-style numerals without leading #, along with generic 0 and 1
paulson
parents:
11711
diff
changeset
|
82 |
done |
d2758965362e
new-style numerals without leading #, along with generic 0 and 1
paulson
parents:
11711
diff
changeset
|
83 |
|
d2758965362e
new-style numerals without leading #, along with generic 0 and 1
paulson
parents:
11711
diff
changeset
|
84 |
|
11711 | 85 |
lemma "(n - 2) * (n + 2) = n * n - (4::nat)" |
12156
d2758965362e
new-style numerals without leading #, along with generic 0 and 1
paulson
parents:
11711
diff
changeset
|
86 |
apply (simp split: nat_diff_split, clarify) |
11480 | 87 |
--{* @{subgoals[display,indent=0,margin=65]} *} |
88 |
apply (subgoal_tac "n=0 | n=1", force, arith) |
|
10603 | 89 |
done |
90 |
||
91 |
text{* |
|
92 |
@{thm[display] mod_if[no_vars]} |
|
93 |
\rulename{mod_if} |
|
94 |
||
95 |
@{thm[display] mod_div_equality[no_vars]} |
|
96 |
\rulename{mod_div_equality} |
|
97 |
||
98 |
||
99 |
@{thm[display] div_mult1_eq[no_vars]} |
|
100 |
\rulename{div_mult1_eq} |
|
101 |
||
102 |
@{thm[display] mod_mult1_eq[no_vars]} |
|
103 |
\rulename{mod_mult1_eq} |
|
104 |
||
105 |
@{thm[display] div_mult2_eq[no_vars]} |
|
106 |
\rulename{div_mult2_eq} |
|
107 |
||
108 |
@{thm[display] mod_mult2_eq[no_vars]} |
|
109 |
\rulename{mod_mult2_eq} |
|
110 |
||
111 |
@{thm[display] div_mult_mult1[no_vars]} |
|
112 |
\rulename{div_mult_mult1} |
|
113 |
||
114 |
@{thm[display] DIVISION_BY_ZERO_DIV[no_vars]} |
|
115 |
\rulename{DIVISION_BY_ZERO_DIV} |
|
116 |
||
117 |
@{thm[display] DIVISION_BY_ZERO_MOD[no_vars]} |
|
118 |
\rulename{DIVISION_BY_ZERO_MOD} |
|
119 |
||
120 |
@{thm[display] dvd_anti_sym[no_vars]} |
|
121 |
\rulename{dvd_anti_sym} |
|
122 |
||
123 |
@{thm[display] dvd_add[no_vars]} |
|
124 |
\rulename{dvd_add} |
|
125 |
||
126 |
For the integers, I'd list a few theorems that somehow involve negative |
|
13757 | 127 |
numbers.*} |
10603 | 128 |
|
13757 | 129 |
|
130 |
text{* |
|
10603 | 131 |
Division, remainder of negatives |
132 |
||
133 |
||
134 |
@{thm[display] pos_mod_sign[no_vars]} |
|
135 |
\rulename{pos_mod_sign} |
|
136 |
||
137 |
@{thm[display] pos_mod_bound[no_vars]} |
|
138 |
\rulename{pos_mod_bound} |
|
139 |
||
140 |
@{thm[display] neg_mod_sign[no_vars]} |
|
141 |
\rulename{neg_mod_sign} |
|
142 |
||
143 |
@{thm[display] neg_mod_bound[no_vars]} |
|
144 |
\rulename{neg_mod_bound} |
|
145 |
||
146 |
@{thm[display] zdiv_zadd1_eq[no_vars]} |
|
147 |
\rulename{zdiv_zadd1_eq} |
|
148 |
||
149 |
@{thm[display] zmod_zadd1_eq[no_vars]} |
|
150 |
\rulename{zmod_zadd1_eq} |
|
151 |
||
152 |
@{thm[display] zdiv_zmult1_eq[no_vars]} |
|
153 |
\rulename{zdiv_zmult1_eq} |
|
154 |
||
155 |
@{thm[display] zmod_zmult1_eq[no_vars]} |
|
156 |
\rulename{zmod_zmult1_eq} |
|
157 |
||
158 |
@{thm[display] zdiv_zmult2_eq[no_vars]} |
|
159 |
\rulename{zdiv_zmult2_eq} |
|
160 |
||
161 |
@{thm[display] zmod_zmult2_eq[no_vars]} |
|
162 |
\rulename{zmod_zmult2_eq} |
|
163 |
*} |
|
164 |
||
11174 | 165 |
lemma "abs (x+y) \<le> abs x + abs (y :: int)" |
10880 | 166 |
by arith |
167 |
||
11711 | 168 |
lemma "abs (2*x) = 2 * abs (x :: int)" |
16585 | 169 |
by (simp add: abs_if) |
11174 | 170 |
|
13757 | 171 |
|
172 |
text {*Induction rules for the Integers |
|
173 |
||
174 |
@{thm[display] int_ge_induct[no_vars]} |
|
175 |
\rulename{int_ge_induct} |
|
176 |
||
177 |
@{thm[display] int_gr_induct[no_vars]} |
|
178 |
\rulename{int_gr_induct} |
|
179 |
||
180 |
@{thm[display] int_le_induct[no_vars]} |
|
181 |
\rulename{int_le_induct} |
|
182 |
||
183 |
@{thm[display] int_less_induct[no_vars]} |
|
184 |
\rulename{int_less_induct} |
|
185 |
*} |
|
186 |
||
14400 | 187 |
text {*FIELDS |
10764 | 188 |
|
14295 | 189 |
@{thm[display] dense[no_vars]} |
190 |
\rulename{dense} |
|
10603 | 191 |
|
14288 | 192 |
@{thm[display] times_divide_eq_right[no_vars]} |
193 |
\rulename{times_divide_eq_right} |
|
10764 | 194 |
|
14288 | 195 |
@{thm[display] times_divide_eq_left[no_vars]} |
196 |
\rulename{times_divide_eq_left} |
|
10764 | 197 |
|
14288 | 198 |
@{thm[display] divide_divide_eq_right[no_vars]} |
199 |
\rulename{divide_divide_eq_right} |
|
10764 | 200 |
|
14288 | 201 |
@{thm[display] divide_divide_eq_left[no_vars]} |
202 |
\rulename{divide_divide_eq_left} |
|
10764 | 203 |
|
14295 | 204 |
@{thm[display] minus_divide_left[no_vars]} |
205 |
\rulename{minus_divide_left} |
|
10764 | 206 |
|
14295 | 207 |
@{thm[display] minus_divide_right[no_vars]} |
208 |
\rulename{minus_divide_right} |
|
10764 | 209 |
|
210 |
This last NOT a simprule |
|
211 |
||
14295 | 212 |
@{thm[display] add_divide_distrib[no_vars]} |
213 |
\rulename{add_divide_distrib} |
|
10764 | 214 |
*} |
10603 | 215 |
|
11711 | 216 |
lemma "3/4 < (7/8 :: real)" |
11174 | 217 |
by simp |
218 |
||
11711 | 219 |
lemma "P ((3/4) * (8/15 :: real))" |
11174 | 220 |
txt{* |
221 |
@{subgoals[display,indent=0,margin=65]} |
|
222 |
*}; |
|
223 |
apply simp |
|
224 |
txt{* |
|
225 |
@{subgoals[display,indent=0,margin=65]} |
|
226 |
*}; |
|
227 |
oops |
|
228 |
||
11711 | 229 |
lemma "(3/4) * (8/15) < (x :: real)" |
11174 | 230 |
txt{* |
231 |
@{subgoals[display,indent=0,margin=65]} |
|
232 |
*}; |
|
233 |
apply simp |
|
234 |
txt{* |
|
235 |
@{subgoals[display,indent=0,margin=65]} |
|
236 |
*}; |
|
237 |
oops |
|
238 |
||
14400 | 239 |
text{* |
240 |
Ring and Field |
|
241 |
||
242 |
Requires a field, or else an ordered ring |
|
243 |
||
244 |
@{thm[display] mult_eq_0_iff[no_vars]} |
|
245 |
\rulename{mult_eq_0_iff} |
|
246 |
||
247 |
@{thm[display] field_mult_eq_0_iff[no_vars]} |
|
248 |
\rulename{field_mult_eq_0_iff} |
|
249 |
||
250 |
@{thm[display] mult_cancel_right[no_vars]} |
|
251 |
\rulename{mult_cancel_right} |
|
252 |
||
253 |
@{thm[display] field_mult_cancel_right[no_vars]} |
|
254 |
\rulename{field_mult_cancel_right} |
|
255 |
*} |
|
256 |
||
257 |
ML{*set show_sorts*} |
|
258 |
||
259 |
text{* |
|
260 |
effect of show sorts on the above |
|
261 |
||
262 |
@{thm[display] field_mult_cancel_right[no_vars]} |
|
263 |
\rulename{field_mult_cancel_right} |
|
264 |
*} |
|
265 |
||
266 |
ML{*reset show_sorts*} |
|
267 |
||
268 |
||
269 |
text{* |
|
270 |
absolute value |
|
271 |
||
272 |
@{thm[display] abs_mult[no_vars]} |
|
273 |
\rulename{abs_mult} |
|
274 |
||
275 |
@{thm[display] abs_le_iff[no_vars]} |
|
276 |
\rulename{abs_le_iff} |
|
277 |
||
278 |
@{thm[display] abs_triangle_ineq[no_vars]} |
|
279 |
\rulename{abs_triangle_ineq} |
|
280 |
||
281 |
@{thm[display] power_add[no_vars]} |
|
282 |
\rulename{power_add} |
|
283 |
||
284 |
@{thm[display] power_mult[no_vars]} |
|
285 |
\rulename{power_mult} |
|
286 |
||
287 |
@{thm[display] power_abs[no_vars]} |
|
288 |
\rulename{power_abs} |
|
289 |
||
290 |
||
291 |
*} |
|
11174 | 292 |
|
293 |
||
10603 | 294 |
end |