14516
|
1 |
theory HOL4Compat = HOL4Setup + Divides + Primes + Real:
|
|
2 |
|
|
3 |
lemma EXISTS_UNIQUE_DEF: "(Ex1 P) = (Ex P & (ALL x y. P x & P y --> (x = y)))"
|
|
4 |
by auto
|
|
5 |
|
|
6 |
lemma COND_DEF:"(If b t f) = (@x. ((b = True) --> (x = t)) & ((b = False) --> (x = f)))"
|
|
7 |
by auto
|
|
8 |
|
|
9 |
constdefs
|
|
10 |
LET :: "['a \<Rightarrow> 'b,'a] \<Rightarrow> 'b"
|
|
11 |
"LET f s == f s"
|
|
12 |
|
|
13 |
lemma [hol4rew]: "LET f s = Let s f"
|
|
14 |
by (simp add: LET_def Let_def)
|
|
15 |
|
|
16 |
lemmas [hol4rew] = ONE_ONE_rew
|
|
17 |
|
|
18 |
lemma bool_case_DEF: "(bool_case x y b) = (if b then x else y)"
|
|
19 |
by simp;
|
|
20 |
|
|
21 |
lemma INR_INL_11: "(ALL y x. (Inl x = Inl y) = (x = y)) & (ALL y x. (Inr x = Inr y) = (x = y))"
|
|
22 |
by safe
|
|
23 |
|
|
24 |
consts
|
|
25 |
ISL :: "'a + 'b => bool"
|
|
26 |
ISR :: "'a + 'b => bool"
|
|
27 |
|
|
28 |
primrec ISL_def:
|
|
29 |
"ISL (Inl x) = True"
|
|
30 |
"ISL (Inr x) = False"
|
|
31 |
|
|
32 |
primrec ISR_def:
|
|
33 |
"ISR (Inl x) = False"
|
|
34 |
"ISR (Inr x) = True"
|
|
35 |
|
|
36 |
lemma ISL: "(ALL x. ISL (Inl x)) & (ALL y. ~ISL (Inr y))"
|
|
37 |
by simp
|
|
38 |
|
|
39 |
lemma ISR: "(ALL x. ISR (Inr x)) & (ALL y. ~ISR (Inl y))"
|
|
40 |
by simp
|
|
41 |
|
|
42 |
consts
|
|
43 |
OUTL :: "'a + 'b => 'a"
|
|
44 |
OUTR :: "'a + 'b => 'b"
|
|
45 |
|
|
46 |
primrec OUTL_def:
|
|
47 |
"OUTL (Inl x) = x"
|
|
48 |
|
|
49 |
primrec OUTR_def:
|
|
50 |
"OUTR (Inr x) = x"
|
|
51 |
|
|
52 |
lemma OUTL: "OUTL (Inl x) = x"
|
|
53 |
by simp
|
|
54 |
|
|
55 |
lemma OUTR: "OUTR (Inr x) = x"
|
|
56 |
by simp
|
|
57 |
|
|
58 |
lemma sum_case_def: "(ALL f g x. sum_case f g (Inl x) = f x) & (ALL f g y. sum_case f g (Inr y) = g y)"
|
|
59 |
by simp;
|
|
60 |
|
|
61 |
lemma one: "ALL v. v = ()"
|
|
62 |
by simp;
|
|
63 |
|
|
64 |
lemma option_case_def: "(!u f. option_case u f None = u) & (!u f x. option_case u f (Some x) = f x)"
|
|
65 |
by simp
|
|
66 |
|
|
67 |
lemma OPTION_MAP_DEF: "(!f x. option_map f (Some x) = Some (f x)) & (!f. option_map f None = None)"
|
|
68 |
by simp
|
|
69 |
|
|
70 |
consts
|
|
71 |
IS_SOME :: "'a option => bool"
|
|
72 |
IS_NONE :: "'a option => bool"
|
|
73 |
|
|
74 |
primrec IS_SOME_def:
|
|
75 |
"IS_SOME (Some x) = True"
|
|
76 |
"IS_SOME None = False"
|
|
77 |
|
|
78 |
primrec IS_NONE_def:
|
|
79 |
"IS_NONE (Some x) = False"
|
|
80 |
"IS_NONE None = True"
|
|
81 |
|
|
82 |
lemma IS_NONE_DEF: "(!x. IS_NONE (Some x) = False) & (IS_NONE None = True)"
|
|
83 |
by simp
|
|
84 |
|
|
85 |
lemma IS_SOME_DEF: "(!x. IS_SOME (Some x) = True) & (IS_SOME None = False)"
|
|
86 |
by simp
|
|
87 |
|
|
88 |
consts
|
|
89 |
OPTION_JOIN :: "'a option option => 'a option"
|
|
90 |
|
|
91 |
primrec OPTION_JOIN_def:
|
|
92 |
"OPTION_JOIN None = None"
|
|
93 |
"OPTION_JOIN (Some x) = x"
|
|
94 |
|
|
95 |
lemma OPTION_JOIN_DEF: "(OPTION_JOIN None = None) & (ALL x. OPTION_JOIN (Some x) = x)"
|
|
96 |
by simp;
|
|
97 |
|
|
98 |
lemma PAIR: "(fst x,snd x) = x"
|
|
99 |
by simp
|
|
100 |
|
|
101 |
lemma PAIR_MAP: "prod_fun f g p = (f (fst p),g (snd p))"
|
|
102 |
by (simp add: prod_fun_def split_def)
|
|
103 |
|
|
104 |
lemma pair_case_def: "split = split"
|
|
105 |
..;
|
|
106 |
|
|
107 |
lemma LESS_OR_EQ: "m <= (n::nat) = (m < n | m = n)"
|
|
108 |
by auto
|
|
109 |
|
|
110 |
constdefs
|
|
111 |
nat_gt :: "nat => nat => bool"
|
|
112 |
"nat_gt == %m n. n < m"
|
|
113 |
nat_ge :: "nat => nat => bool"
|
|
114 |
"nat_ge == %m n. nat_gt m n | m = n"
|
|
115 |
|
|
116 |
lemma [hol4rew]: "nat_gt m n = (n < m)"
|
|
117 |
by (simp add: nat_gt_def)
|
|
118 |
|
|
119 |
lemma [hol4rew]: "nat_ge m n = (n <= m)"
|
|
120 |
by (auto simp add: nat_ge_def nat_gt_def)
|
|
121 |
|
|
122 |
lemma GREATER_DEF: "ALL m n. (n < m) = (n < m)"
|
|
123 |
by simp
|
|
124 |
|
|
125 |
lemma GREATER_OR_EQ: "ALL m n. n <= (m::nat) = (n < m | m = n)"
|
|
126 |
by auto
|
|
127 |
|
|
128 |
lemma LESS_DEF: "m < n = (? P. (!n. P (Suc n) --> P n) & P m & ~P n)"
|
|
129 |
proof safe
|
|
130 |
assume "m < n"
|
|
131 |
def P == "%n. n <= m"
|
|
132 |
have "(!n. P (Suc n) \<longrightarrow> P n) & P m & ~P n"
|
|
133 |
proof (auto simp add: P_def)
|
|
134 |
assume "n <= m"
|
|
135 |
from prems
|
|
136 |
show False
|
|
137 |
by auto
|
|
138 |
qed
|
|
139 |
thus "? P. (!n. P (Suc n) \<longrightarrow> P n) & P m & ~P n"
|
|
140 |
by auto
|
|
141 |
next
|
|
142 |
fix P
|
|
143 |
assume alln: "!n. P (Suc n) \<longrightarrow> P n"
|
|
144 |
assume pm: "P m"
|
|
145 |
assume npn: "~P n"
|
|
146 |
have "!k q. q + k = m \<longrightarrow> P q"
|
|
147 |
proof
|
|
148 |
fix k
|
|
149 |
show "!q. q + k = m \<longrightarrow> P q"
|
|
150 |
proof (induct k,simp_all)
|
|
151 |
show "P m" .
|
|
152 |
next
|
|
153 |
fix k
|
|
154 |
assume ind: "!q. q + k = m \<longrightarrow> P q"
|
|
155 |
show "!q. Suc (q + k) = m \<longrightarrow> P q"
|
|
156 |
proof (rule+)
|
|
157 |
fix q
|
|
158 |
assume "Suc (q + k) = m"
|
|
159 |
hence "(Suc q) + k = m"
|
|
160 |
by simp
|
|
161 |
with ind
|
|
162 |
have psq: "P (Suc q)"
|
|
163 |
by simp
|
|
164 |
from alln
|
|
165 |
have "P (Suc q) --> P q"
|
|
166 |
..
|
|
167 |
with psq
|
|
168 |
show "P q"
|
|
169 |
by simp
|
|
170 |
qed
|
|
171 |
qed
|
|
172 |
qed
|
|
173 |
hence "!q. q + (m - n) = m \<longrightarrow> P q"
|
|
174 |
..
|
|
175 |
hence hehe: "n + (m - n) = m \<longrightarrow> P n"
|
|
176 |
..
|
|
177 |
show "m < n"
|
|
178 |
proof (rule classical)
|
|
179 |
assume "~(m<n)"
|
|
180 |
hence "n <= m"
|
|
181 |
by simp
|
|
182 |
with hehe
|
|
183 |
have "P n"
|
|
184 |
by simp
|
|
185 |
with npn
|
|
186 |
show "m < n"
|
|
187 |
..
|
|
188 |
qed
|
|
189 |
qed;
|
|
190 |
|
|
191 |
constdefs
|
|
192 |
FUNPOW :: "('a => 'a) => nat => 'a => 'a"
|
|
193 |
"FUNPOW f n == f ^ n"
|
|
194 |
|
|
195 |
lemma FUNPOW: "(ALL f x. (f ^ 0) x = x) &
|
|
196 |
(ALL f n x. (f ^ Suc n) x = (f ^ n) (f x))"
|
|
197 |
proof auto
|
|
198 |
fix f n x
|
|
199 |
have "ALL x. f ((f ^ n) x) = (f ^ n) (f x)"
|
|
200 |
by (induct n,auto)
|
|
201 |
thus "f ((f ^ n) x) = (f ^ n) (f x)"
|
|
202 |
..
|
|
203 |
qed
|
|
204 |
|
|
205 |
lemma [hol4rew]: "FUNPOW f n = f ^ n"
|
|
206 |
by (simp add: FUNPOW_def)
|
|
207 |
|
|
208 |
lemma ADD: "(!n. (0::nat) + n = n) & (!m n. Suc m + n = Suc (m + n))"
|
|
209 |
by simp
|
|
210 |
|
|
211 |
lemma MULT: "(!n. (0::nat) * n = 0) & (!m n. Suc m * n = m * n + n)"
|
|
212 |
by simp
|
|
213 |
|
|
214 |
lemma SUB: "(!m. (0::nat) - m = 0) & (!m n. (Suc m) - n = (if m < n then 0 else Suc (m - n)))"
|
|
215 |
apply simp
|
|
216 |
apply arith
|
|
217 |
done
|
|
218 |
|
|
219 |
lemma MAX_DEF: "max (m::nat) n = (if m < n then n else m)"
|
|
220 |
by (simp add: max_def)
|
|
221 |
|
|
222 |
lemma MIN_DEF: "min (m::nat) n = (if m < n then m else n)"
|
|
223 |
by (simp add: min_def)
|
|
224 |
|
|
225 |
lemma DIVISION: "(0::nat) < n --> (!k. (k = k div n * n + k mod n) & k mod n < n)"
|
|
226 |
by simp
|
|
227 |
|
|
228 |
constdefs
|
|
229 |
ALT_ZERO :: nat
|
|
230 |
"ALT_ZERO == 0"
|
|
231 |
NUMERAL_BIT1 :: "nat \<Rightarrow> nat"
|
|
232 |
"NUMERAL_BIT1 n == n + (n + Suc 0)"
|
|
233 |
NUMERAL_BIT2 :: "nat \<Rightarrow> nat"
|
|
234 |
"NUMERAL_BIT2 n == n + (n + Suc (Suc 0))"
|
|
235 |
NUMERAL :: "nat \<Rightarrow> nat"
|
|
236 |
"NUMERAL x == x"
|
|
237 |
|
|
238 |
lemma [hol4rew]: "NUMERAL ALT_ZERO = 0"
|
|
239 |
by (simp add: ALT_ZERO_def NUMERAL_def)
|
|
240 |
|
|
241 |
lemma [hol4rew]: "NUMERAL (NUMERAL_BIT1 ALT_ZERO) = 1"
|
|
242 |
by (simp add: ALT_ZERO_def NUMERAL_BIT1_def NUMERAL_def)
|
|
243 |
|
|
244 |
lemma [hol4rew]: "NUMERAL (NUMERAL_BIT2 ALT_ZERO) = 2"
|
|
245 |
by (simp add: ALT_ZERO_def NUMERAL_BIT2_def NUMERAL_def)
|
|
246 |
|
|
247 |
lemma EXP: "(!m. m ^ 0 = (1::nat)) & (!m n. m ^ Suc n = m * (m::nat) ^ n)"
|
|
248 |
by auto
|
|
249 |
|
|
250 |
lemma num_case_def: "(!b f. nat_case b f 0 = b) & (!b f n. nat_case b f (Suc n) = f n)"
|
|
251 |
by simp;
|
|
252 |
|
|
253 |
lemma divides_def: "(a::nat) dvd b = (? q. b = q * a)"
|
|
254 |
by (auto simp add: dvd_def);
|
|
255 |
|
|
256 |
lemma list_case_def: "(!v f. list_case v f [] = v) & (!v f a0 a1. list_case v f (a0#a1) = f a0 a1)"
|
|
257 |
by simp
|
|
258 |
|
|
259 |
consts
|
|
260 |
list_size :: "('a \<Rightarrow> nat) \<Rightarrow> 'a list \<Rightarrow> nat"
|
|
261 |
|
|
262 |
primrec
|
|
263 |
"list_size f [] = 0"
|
|
264 |
"list_size f (a0#a1) = 1 + (f a0 + list_size f a1)"
|
|
265 |
|
|
266 |
lemma list_size_def: "(!f. list_size f [] = 0) &
|
|
267 |
(!f a0 a1. list_size f (a0#a1) = 1 + (f a0 + list_size f a1))"
|
|
268 |
by simp
|
|
269 |
|
|
270 |
lemma list_case_cong: "! M M' v f. M = M' & (M' = [] \<longrightarrow> v = v') &
|
|
271 |
(!a0 a1. (M' = a0#a1) \<longrightarrow> (f a0 a1 = f' a0 a1)) -->
|
|
272 |
(list_case v f M = list_case v' f' M')"
|
|
273 |
proof clarify
|
|
274 |
fix M M' v f
|
|
275 |
assume "M' = [] \<longrightarrow> v = v'"
|
|
276 |
and "!a0 a1. M' = a0 # a1 \<longrightarrow> f a0 a1 = f' a0 a1"
|
|
277 |
show "list_case v f M' = list_case v' f' M'"
|
|
278 |
proof (rule List.list.case_cong)
|
|
279 |
show "M' = M'"
|
|
280 |
..
|
|
281 |
next
|
|
282 |
assume "M' = []"
|
|
283 |
with prems
|
|
284 |
show "v = v'"
|
|
285 |
by auto
|
|
286 |
next
|
|
287 |
fix a0 a1
|
|
288 |
assume "M' = a0 # a1"
|
|
289 |
with prems
|
|
290 |
show "f a0 a1 = f' a0 a1"
|
|
291 |
by auto
|
|
292 |
qed
|
|
293 |
qed
|
|
294 |
|
|
295 |
lemma list_Axiom: "ALL f0 f1. EX fn. (fn [] = f0) & (ALL a0 a1. fn (a0#a1) = f1 a0 a1 (fn a1))"
|
|
296 |
proof safe
|
|
297 |
fix f0 f1
|
|
298 |
def fn == "list_rec f0 f1"
|
|
299 |
have "fn [] = f0 & (ALL a0 a1. fn (a0 # a1) = f1 a0 a1 (fn a1))"
|
|
300 |
by (simp add: fn_def)
|
|
301 |
thus "EX fn. fn [] = f0 & (ALL a0 a1. fn (a0 # a1) = f1 a0 a1 (fn a1))"
|
|
302 |
by auto
|
|
303 |
qed
|
|
304 |
|
|
305 |
lemma list_Axiom_old: "EX! fn. (fn [] = x) & (ALL h t. fn (h#t) = f (fn t) h t)"
|
|
306 |
proof safe
|
|
307 |
def fn == "list_rec x (%h t r. f r h t)"
|
|
308 |
have "fn [] = x & (ALL h t. fn (h # t) = f (fn t) h t)"
|
|
309 |
by (simp add: fn_def)
|
|
310 |
thus "EX fn. fn [] = x & (ALL h t. fn (h # t) = f (fn t) h t)"
|
|
311 |
by auto
|
|
312 |
next
|
|
313 |
fix fn1 fn2
|
|
314 |
assume "ALL h t. fn1 (h # t) = f (fn1 t) h t"
|
|
315 |
assume "ALL h t. fn2 (h # t) = f (fn2 t) h t"
|
|
316 |
assume "fn2 [] = fn1 []"
|
|
317 |
show "fn1 = fn2"
|
|
318 |
proof
|
|
319 |
fix xs
|
|
320 |
show "fn1 xs = fn2 xs"
|
|
321 |
by (induct xs,simp_all add: prems)
|
|
322 |
qed
|
|
323 |
qed
|
|
324 |
|
|
325 |
lemma NULL_DEF: "(null [] = True) & (!h t. null (h # t) = False)"
|
|
326 |
by simp
|
|
327 |
|
|
328 |
constdefs
|
|
329 |
sum :: "nat list \<Rightarrow> nat"
|
|
330 |
"sum l == foldr (op +) l 0"
|
|
331 |
|
|
332 |
lemma SUM: "(sum [] = 0) & (!h t. sum (h#t) = h + sum t)"
|
|
333 |
by (simp add: sum_def)
|
|
334 |
|
|
335 |
lemma APPEND: "(!l. [] @ l = l) & (!l1 l2 h. (h#l1) @ l2 = h# l1 @ l2)"
|
|
336 |
by simp
|
|
337 |
|
|
338 |
lemma FLAT: "(concat [] = []) & (!h t. concat (h#t) = h @ (concat t))"
|
|
339 |
by simp
|
|
340 |
|
|
341 |
lemma LENGTH: "(length [] = 0) & (!h t. length (h#t) = Suc (length t))"
|
|
342 |
by simp
|
|
343 |
|
|
344 |
lemma MAP: "(!f. map f [] = []) & (!f h t. map f (h#t) = f h#map f t)"
|
|
345 |
by simp
|
|
346 |
|
|
347 |
lemma MEM: "(!x. x mem [] = False) & (!x h t. x mem (h#t) = ((x = h) | x mem t))"
|
|
348 |
by auto
|
|
349 |
|
|
350 |
lemma FILTER: "(!P. filter P [] = []) & (!P h t.
|
|
351 |
filter P (h#t) = (if P h then h#filter P t else filter P t))"
|
|
352 |
by simp
|
|
353 |
|
|
354 |
lemma REPLICATE: "(ALL x. replicate 0 x = []) &
|
|
355 |
(ALL n x. replicate (Suc n) x = x # replicate n x)"
|
|
356 |
by simp
|
|
357 |
|
|
358 |
constdefs
|
|
359 |
FOLDR :: "[['a,'b]\<Rightarrow>'b,'b,'a list] \<Rightarrow> 'b"
|
|
360 |
"FOLDR f e l == foldr f l e"
|
|
361 |
|
|
362 |
lemma [hol4rew]: "FOLDR f e l = foldr f l e"
|
|
363 |
by (simp add: FOLDR_def)
|
|
364 |
|
|
365 |
lemma FOLDR: "(!f e. foldr f [] e = e) & (!f e x l. foldr f (x#l) e = f x (foldr f l e))"
|
|
366 |
by simp
|
|
367 |
|
|
368 |
lemma FOLDL: "(!f e. foldl f e [] = e) & (!f e x l. foldl f e (x#l) = foldl f (f e x) l)"
|
|
369 |
by simp
|
|
370 |
|
|
371 |
lemma EVERY_DEF: "(!P. list_all P [] = True) & (!P h t. list_all P (h#t) = (P h & list_all P t))"
|
|
372 |
by simp
|
|
373 |
|
|
374 |
consts
|
|
375 |
list_exists :: "['a \<Rightarrow> bool,'a list] \<Rightarrow> bool"
|
|
376 |
|
|
377 |
primrec
|
|
378 |
list_exists_Nil: "list_exists P Nil = False"
|
|
379 |
list_exists_Cons: "list_exists P (x#xs) = (if P x then True else list_exists P xs)"
|
|
380 |
|
|
381 |
lemma list_exists_DEF: "(!P. list_exists P [] = False) &
|
|
382 |
(!P h t. list_exists P (h#t) = (P h | list_exists P t))"
|
|
383 |
by simp
|
|
384 |
|
|
385 |
consts
|
|
386 |
map2 :: "[['a,'b]\<Rightarrow>'c,'a list,'b list] \<Rightarrow> 'c list"
|
|
387 |
|
|
388 |
primrec
|
|
389 |
map2_Nil: "map2 f [] l2 = []"
|
|
390 |
map2_Cons: "map2 f (x#xs) l2 = f x (hd l2) # map2 f xs (tl l2)"
|
|
391 |
|
|
392 |
lemma MAP2: "(!f. map2 f [] [] = []) & (!f h1 t1 h2 t2. map2 f (h1#t1) (h2#t2) = f h1 h2#map2 f t1 t2)"
|
|
393 |
by simp
|
|
394 |
|
|
395 |
lemma list_INDUCT: "\<lbrakk> P [] ; !t. P t \<longrightarrow> (!h. P (h#t)) \<rbrakk> \<Longrightarrow> !l. P l"
|
|
396 |
proof
|
|
397 |
fix l
|
|
398 |
assume "P []"
|
|
399 |
assume allt: "!t. P t \<longrightarrow> (!h. P (h # t))"
|
|
400 |
show "P l"
|
|
401 |
proof (induct l)
|
|
402 |
show "P []" .
|
|
403 |
next
|
|
404 |
fix h t
|
|
405 |
assume "P t"
|
|
406 |
with allt
|
|
407 |
have "!h. P (h # t)"
|
|
408 |
by auto
|
|
409 |
thus "P (h # t)"
|
|
410 |
..
|
|
411 |
qed
|
|
412 |
qed
|
|
413 |
|
|
414 |
lemma list_CASES: "(l = []) | (? t h. l = h#t)"
|
|
415 |
by (induct l,auto)
|
|
416 |
|
|
417 |
constdefs
|
|
418 |
ZIP :: "'a list * 'b list \<Rightarrow> ('a * 'b) list"
|
|
419 |
"ZIP == %(a,b). zip a b"
|
|
420 |
|
|
421 |
lemma ZIP: "(zip [] [] = []) &
|
|
422 |
(!x1 l1 x2 l2. zip (x1#l1) (x2#l2) = (x1,x2)#zip l1 l2)"
|
|
423 |
by simp
|
|
424 |
|
|
425 |
lemma [hol4rew]: "ZIP (a,b) = zip a b"
|
|
426 |
by (simp add: ZIP_def)
|
|
427 |
|
|
428 |
consts
|
|
429 |
unzip :: "('a * 'b) list \<Rightarrow> 'a list * 'b list"
|
|
430 |
|
|
431 |
primrec
|
|
432 |
unzip_Nil: "unzip [] = ([],[])"
|
|
433 |
unzip_Cons: "unzip (xy#xys) = (let zs = unzip xys in (fst xy # fst zs,snd xy # snd zs))"
|
|
434 |
|
|
435 |
lemma UNZIP: "(unzip [] = ([],[])) &
|
|
436 |
(!x l. unzip (x#l) = (fst x#fst (unzip l),snd x#snd (unzip l)))"
|
|
437 |
by (simp add: Let_def)
|
|
438 |
|
|
439 |
lemma REVERSE: "(rev [] = []) & (!h t. rev (h#t) = (rev t) @ [h])"
|
|
440 |
by simp;
|
|
441 |
|
|
442 |
lemma REAL_SUP_ALLPOS: "\<lbrakk> ALL x. P (x::real) \<longrightarrow> 0 < x ; EX x. P x; EX z. ALL x. P x \<longrightarrow> x < z \<rbrakk> \<Longrightarrow> EX s. ALL y. (EX x. P x & y < x) = (y < s)"
|
|
443 |
proof safe
|
|
444 |
fix x z
|
|
445 |
assume allx: "ALL x. P x \<longrightarrow> 0 < x"
|
|
446 |
assume px: "P x"
|
|
447 |
assume allx': "ALL x. P x \<longrightarrow> x < z"
|
|
448 |
have "EX s. ALL y. (EX x : Collect P. y < x) = (y < s)"
|
|
449 |
proof (rule posreal_complete)
|
|
450 |
show "ALL x : Collect P. 0 < x"
|
|
451 |
proof safe
|
|
452 |
fix x
|
|
453 |
assume "P x"
|
|
454 |
from allx
|
|
455 |
have "P x \<longrightarrow> 0 < x"
|
|
456 |
..
|
|
457 |
thus "0 < x"
|
|
458 |
by (simp add: prems)
|
|
459 |
qed
|
|
460 |
next
|
|
461 |
from px
|
|
462 |
show "EX x. x : Collect P"
|
|
463 |
by auto
|
|
464 |
next
|
|
465 |
from allx'
|
|
466 |
show "EX y. ALL x : Collect P. x < y"
|
|
467 |
apply simp
|
|
468 |
..
|
|
469 |
qed
|
|
470 |
thus "EX s. ALL y. (EX x. P x & y < x) = (y < s)"
|
|
471 |
by simp
|
|
472 |
qed
|
|
473 |
|
|
474 |
lemma REAL_10: "~((1::real) = 0)"
|
|
475 |
by simp
|
|
476 |
|
|
477 |
lemma REAL_ADD_ASSOC: "(x::real) + (y + z) = x + y + z"
|
|
478 |
by simp
|
|
479 |
|
|
480 |
lemma REAL_MUL_ASSOC: "(x::real) * (y * z) = x * y * z"
|
|
481 |
by simp
|
|
482 |
|
|
483 |
lemma REAL_ADD_LINV: "-x + x = (0::real)"
|
|
484 |
by simp
|
|
485 |
|
|
486 |
lemma REAL_MUL_LINV: "x ~= (0::real) ==> inverse x * x = 1"
|
|
487 |
by simp
|
|
488 |
|
|
489 |
lemma REAL_LT_TOTAL: "((x::real) = y) | x < y | y < x"
|
|
490 |
by auto;
|
|
491 |
|
|
492 |
lemma [hol4rew]: "real (0::nat) = 0"
|
|
493 |
by simp
|
|
494 |
|
|
495 |
lemma [hol4rew]: "real (1::nat) = 1"
|
|
496 |
by simp
|
|
497 |
|
|
498 |
lemma [hol4rew]: "real (2::nat) = 2"
|
|
499 |
by simp
|
|
500 |
|
|
501 |
lemma real_lte: "((x::real) <= y) = (~(y < x))"
|
|
502 |
by auto
|
|
503 |
|
|
504 |
lemma real_of_num: "((0::real) = 0) & (!n. real (Suc n) = real n + 1)"
|
|
505 |
by (simp add: real_of_nat_Suc)
|
|
506 |
|
|
507 |
lemma abs: "abs (x::real) = (if 0 <= x then x else -x)"
|
|
508 |
by (simp add: real_abs_def)
|
|
509 |
|
|
510 |
lemma pow: "(!x::real. x ^ 0 = 1) & (!x::real. ALL n. x ^ (Suc n) = x * x ^ n)"
|
|
511 |
by simp;
|
|
512 |
|
|
513 |
constdefs
|
|
514 |
real_gt :: "real => real => bool"
|
|
515 |
"real_gt == %x y. y < x"
|
|
516 |
|
|
517 |
lemma [hol4rew]: "real_gt x y = (y < x)"
|
|
518 |
by (simp add: real_gt_def)
|
|
519 |
|
|
520 |
lemma real_gt: "ALL x (y::real). (y < x) = (y < x)"
|
|
521 |
by simp
|
|
522 |
|
|
523 |
constdefs
|
|
524 |
real_ge :: "real => real => bool"
|
|
525 |
"real_ge x y == y <= x"
|
|
526 |
|
|
527 |
lemma [hol4rew]: "real_ge x y = (y <= x)"
|
|
528 |
by (simp add: real_ge_def)
|
|
529 |
|
|
530 |
lemma real_ge: "ALL x y. (y <= x) = (y <= x)"
|
|
531 |
by simp
|
|
532 |
|
|
533 |
end
|