3 (* ------------------------------------------------------------------ *)
5 Topological Spaces, Metric Spaces,
6 Connectedness, Totally bounded spaces, compactness,
7 Hausdorff property, completeness, properties of Euclidean space,
9 Author: Thomas Hales 2004
13 (* ------------------------------------------------------------------ *)
16 (* prioritize_real (or num) *)
18 (* ------------------------------------------------------------------ *)
19 (* Logical Preliminaries *)
20 (* ------------------------------------------------------------------ *)
23 let Q_ELIM_THM = prove_by_refinement(
24 `!P Q R . (?(u:B). (?(x:A). (u = P x) /\ (Q x)) /\ (R u)) <=>
25 (?x. (Q x) /\ R( P x))`,
33 let Q_ELIM_THM' = prove_by_refinement(
34 `!P Q R. (!(t:B). (?(x:A). P x /\ (t = Q x)) ==> R t) <=>
35 (!x. P x ==> R (Q x))`,
43 let Q_ELIM_THM'' = prove_by_refinement(
44 `!P Q R. (!(t:B). (?(x:A). (t = Q x) /\ P x ) ==> R t) <=>
45 (!x. P x ==> R (Q x))`,
54 (* ------------------------------------------------------------------ *)
55 (* Set Preliminaries *)
56 (* ------------------------------------------------------------------ *)
58 let DIFF_SUBSET = prove_by_refinement(
59 `!X A (B:A->bool). A SUBSET (X DIFF B) <=>
60 (A SUBSET X) /\ (A INTER B = EMPTY)`,
64 REWRITE_TAC[SUBSET;DIFF;INTER;IN];
66 REWRITE_TAC[IN_ELIM_THM'];
72 REWRITE_TAC[IN_ELIM_THM';EMPTY];
77 REWRITE_TAC[IN_ELIM_THM'];
80 USE 1 (fun t-> AP_THM t `x:A`);
81 USE 1 (REWRITE_RULE[IN_ELIM_THM';EMPTY]);
86 let SUBSET_INTERS = prove_by_refinement(
87 `!X (A:A->bool). A SUBSET (INTERS X) <=> (!x. X x ==> (A SUBSET x))`,
91 REWRITE_TAC[SUBSET;INTERS];
92 REWRITE_TAC [IN_ELIM_THM'];
97 let EQ_EMPTY = prove_by_refinement(
98 `!P. ({(x:A) | P x} = {}) <=> (!x. ~P x)`,
104 (USE 0 (fun t-> AP_THM t `x:A`));
105 USE 0 (REWRITE_RULE[IN_ELIM_THM';EMPTY]);
111 REWRITE_TAC[IN_ELIM_THM';EMPTY];
116 let DIFF_INTER = prove_by_refinement(
117 `!A B (C:A->bool). ((A DIFF B) INTER C = EMPTY) <=>
118 ((A INTER C) SUBSET B)`,
121 REWRITE_TAC[DIFF;INTER;SUBSET;IN_ELIM_THM'];
122 REWRITE_TAC[IN;EQ_EMPTY];
127 let SUB_IMP_INTER = prove_by_refinement(
128 `!A B (C:A->bool). ((A SUBSET B) ==> (A INTER C) SUBSET B) /\
129 ((A SUBSET B) ==> (C INTER A) SUBSET B)`,
134 REWRITE_TAC[INTER;SUBSET;IN;IN_ELIM_THM'];
136 MESON_TAC[INTER_COMM];
140 let SUBSET_UNIONS_INSERT = prove_by_refinement(
141 `!(A:A->bool) B C. A SUBSET (UNIONS (B INSERT C)) <=>
142 (A DIFF B) SUBSET (UNIONS C)`,
146 SET_TAC[UNIONS;SUBSET;INSERT];
150 let UNIONS_DELETE2 = prove_by_refinement(
151 `!(A:A->bool) B C. (A SUBSET (UNIONS B)) /\ (A INTER C = EMPTY) ==>
152 (A SUBSET (UNIONS (B DELETE (C))))`,
156 ASM SET_TAC[SUBSET;UNIONS;INTER;EMPTY;DELETE];
161 (* this generalizes to arbitrary cardinalities *)
162 let finite_subset = prove_by_refinement(
163 `!A (f:A->B) B. (B SUBSET (IMAGE f A)) /\ (FINITE B) ==>
164 (?C. (C SUBSET A) /\ (FINITE C) /\ (B = IMAGE f C))`,
168 USE 0 (REWRITE_RULE[SUBSET;IN_IMAGE]);
169 USE 0 (CONV_RULE NAME_CONFLICT_CONV);
170 USE 0 (CONV_RULE (quant_left_CONV "x'"));
171 USE 0 (CONV_RULE (quant_left_CONV "x'"));
173 TYPE_THEN `IMAGE x' B` EXISTS_TAC ;
175 REWRITE_TAC[SUBSET;IN_IMAGE];
181 ASM_MESON_TAC[ FINITE_IMAGE];
182 MATCH_MP_TAC SUBSET_ANTISYM;
184 REWRITE_TAC[SUBSET;IN_IMAGE];
186 TYPE_THEN `x` (USE 0 o SPEC);
188 REWRITE_TAC[SUBSET;IN_IMAGE];
191 DISCH_THEN CHOOSE_TAC;
199 let inters_singleton = prove_by_refinement(
200 `!(A:A->bool). INTERS {A} = A`,
203 REWRITE_TAC[INSERT;INTERS];
204 REWRITE_TAC[IN_ELIM_THM';NOT_IN_EMPTY];
208 REWRITE_TAC[IN_ELIM_THM'];
213 let delete_empty = prove_by_refinement(
214 `!(A:A->bool) x. (A DELETE x = EMPTY) <=> (~(A = EMPTY) ==> (A = {x}))`,
222 USE 1 (fun t-> AP_THM t `u:A`);
223 USE 1 (REWRITE_RULE[IN_ELIM_THM';EMPTY]);
224 REWRITE_TAC[EMPTY;INSERT;IN];
225 USE 0 (REWRITE_RULE[EMPTY_EXISTS]);
229 REWRITE_TAC[IN_ELIM_THM'];
234 REWRITE_TAC[IN_ELIM_THM';EMPTY];
235 USE 0 (REWRITE_RULE[EMPTY_EXISTS]);
236 USE 0 (REWRITE_RULE[EMPTY;INSERT;IN]);
238 USE 0 (CONV_RULE (quant_left_CONV "u"));
240 MATCH_MP_TAC (TAUT `(a ==> b) ==> ~(a /\ ~b)`);
245 REWRITE_TAC[IN_ELIM_THM'];
250 let inters_subset = prove_by_refinement(
251 `!A (B:(A->bool)->bool). A SUBSET B ==> INTERS B SUBSET INTERS A`,
255 REWRITE_TAC[INTERS;SUBSET;IN_ELIM_THM'];
256 ASM_MESON_TAC[SUBSET;IN];
260 let delete_inters = prove_by_refinement(
261 `!V (u:A->bool). V u ==> (INTERS V = (INTERS (V DELETE u)) INTER u)`,
265 MATCH_MP_TAC SUBSET_ANTISYM;
267 REWRITE_TAC[SUBSET_INTER];
269 MATCH_MP_TAC inters_subset;
270 REWRITE_TAC [DELETE_SUBSET];
271 USE 0 (ONCE_REWRITE_RULE[GSYM IN]);
272 USE 0 (MATCH_MP INTERS_SUBSET);
274 TYPE_THEN `INTERS (V DELETE u) INTER u SUBSET u` SUBGOAL_TAC;
275 REWRITE_TAC[INTER_SUBSET];
276 REWRITE_TAC[SUBSET_INTERS];
279 TYPE_THEN `x = u` ASM_CASES_TAC;
281 TYPE_THEN `INTERS (V DELETE u) INTER u SUBSET INTERS (V DELETE u) ` SUBGOAL_TAC;
282 REWRITE_TAC[INTER_SUBSET];
283 TYPE_THEN `INTERS (V DELETE u) SUBSET x` SUBGOAL_TAC;
284 MATCH_MP_TAC INTERS_SUBSET;
285 ASM_REWRITE_TAC [IN;DELETE;IN_ELIM_THM'];
286 ASM_MESON_TAC[SUBSET_TRANS];
290 let EQ_EMPTY = prove_by_refinement(
291 `!(A:A->bool) . (A = EMPTY) <=> (!x. ~(A x))`,
294 ASM_MESON_TAC[EMPTY_EXISTS;IN];
298 let UNIONS_EQ_EMPTY = prove_by_refinement(
299 `!(U:(A->bool)->bool). (UNIONS U = {}) <=>
300 ((U = EMPTY) \/ (U = {EMPTY}))`,
304 REWRITE_TAC[EQ_EMPTY;UNIONS;IN_ELIM_THM';INSERT;EMPTY];
308 TYPE_THEN `!x. ~U x` ASM_CASES_TAC ;
313 REWRITE_TAC[IN_ELIM_THM'];
315 USE 1 (CONV_RULE (quant_left_CONV "x"));
317 USE 0 (CONV_RULE (quant_left_CONV "u"));
318 USE 0 (CONV_RULE (quant_left_CONV "u"));
321 TYPE_THEN `x` (USE 0 o SPEC);
325 TYPE_THEN `x` (USE 0 o SPEC);
326 TYPE_THEN `x'` (USE 3 o SPEC);
328 TYPE_THEN `x' = {}` SUBGOAL_TAC;
330 USE 5 (REWRITE_RULE[EMPTY_EXISTS]);
332 USE 5 (REWRITE_RULE[IN]);
334 USE 2 (CONV_RULE (quant_right_CONV "x'"));
335 ASM_MESON_TAC[IN;EMPTY_EXISTS];
336 DISCH_THEN DISJ_CASES_TAC;
338 ASM_REWRITE_TAC[IN_ELIM_THM'];
343 let INTERS_EQ_EMPTY = prove_by_refinement(
344 `!((A:(A->bool)->bool)). ((INTERS A) = EMPTY) <=>
345 (!x . ?a. (A a) /\ ~(a x))`,
348 REWRITE_TAC[INTERS;EQ_EMPTY;IN_ELIM_THM'];
354 let CARD_SING_CONV = prove_by_refinement(
355 `!X:A->bool. (X HAS_SIZE 1) ==> (SING X)`,
359 REWRITE_TAC[HAS_SIZE ;SING ];
361 TYPE_THEN `CHOICE X` EXISTS_TAC;
362 TYPE_THEN `~(X = {})` SUBGOAL_TAC;
363 ASM_MESON_TAC[CARD_CLAUSES;ARITH_RULE`~(0=1)`];
365 TYPE_THEN `SUC (CARD (X DELETE (CHOICE X)))=1` SUBGOAL_TAC ;
366 ASM_SIMP_TAC[CARD_DELETE_CHOICE];
367 REWRITE_TAC[ARITH_RULE`(SUC a = 1) <=> (a=0)`];
368 ASSUME_TAC HAS_SIZE_0;
369 USE 3 (REWRITE_RULE [HAS_SIZE ]);
370 ASSUME_TAC FINITE_DELETE_IMP;
371 ASM_MESON_TAC[delete_empty];
376 let countable_prod = prove_by_refinement(
377 `!(A:A->bool) (B:B->bool). (COUNTABLE A) /\ (COUNTABLE B) ==>
378 (COUNTABLE {(a,b) | (A a) /\ (B b) })`,
383 IMATCH_MP_TAC (INST_TYPE [`:num#num`,`:A`] COUNTABLE_IMAGE);
384 USE 0 (REWRITE_RULE [COUNTABLE;GE_C;IN_UNIV]);
385 USE 1 (REWRITE_RULE [COUNTABLE;GE_C;IN_UNIV]);
388 TYPE_THEN `{(m:num,n:num) | T}` EXISTS_TAC;
389 REWRITE_TAC[NUM2_COUNTABLE;SUBSET;IN_IMAGE];
390 REWRITE_TAC[IN_ELIM_THM];
391 TYPE_THEN `(\ (u,v) . (f u,f' v))` EXISTS_TAC;
396 TYPE_THEN `a` (USE 0 o SPEC);
397 TYPE_THEN `b` (USE 1 o SPEC);
403 TYPE_THEN `(x',x'')` EXISTS_TAC;
404 (CONV_TAC (TOP_DEPTH_CONV GEN_BETA_CONV));
410 let IMAGE_I = prove_by_refinement(
411 `!(A:A->bool). IMAGE I A = A`,
414 REWRITE_TAC[IMAGE;IN;I_DEF];
416 MATCH_MP_TAC EQ_EXT THEN GEN_TAC ;
417 REWRITE_TAC[IN_ELIM_THM'];
422 let EMPTY_NOT_EXISTS = prove_by_refinement(
423 `!X. (X = {}) <=> (~(?(u:A). X u))`,
426 MESON_TAC [IN;EMPTY_EXISTS];
430 let DIFF_SURJ = prove_by_refinement(
431 `!(f : A->B) X Y. (BIJ f X Y) ==>
432 (! t. (t SUBSET X) ==> ((IMAGE f (X DIFF t)) = (Y DIFF (IMAGE f t))))`,
436 REWRITE_TAC[BIJ;INJ;SURJ;IN ];
439 REWRITE_TAC[IMAGE;IN];
440 IMATCH_MP_TAC EQ_EXT ;
441 REWRITE_TAC[IN_ELIM_THM'];
444 REWRITE_TAC[REWRITE_RULE[IN] IN_DIFF];
445 REWRITE_TAC[IN_ELIM_THM'];
446 ASM_MESON_TAC[SUBSET;IN ];
451 let union_subset = prove_by_refinement(
452 `!Z1 Z2 A. ((Z1 UNION Z2) SUBSET (A:A->bool)) <=>
453 (Z1 SUBSET A) /\ (Z2 SUBSET A)`,
457 REWRITE_TAC[UNION;SUBSET;IN;IN_ELIM_THM'];
462 let preimage_disjoint = prove_by_refinement(
463 `!(f:A->B) A B X. (A INTER B = EMPTY) ==>
464 (preimage X f A INTER (preimage X f B) = EMPTY )`,
468 REWRITE_TAC[preimage];
469 REWRITE_TAC[EQ_EMPTY];
471 USE 1( REWRITE_RULE[INTER;IN;IN_ELIM_THM']);
472 USE 0 (REWRITE_RULE[EQ_EMPTY;INTER;IN;IN_ELIM_THM']);
477 let preimage_union = prove_by_refinement(
479 (Z SUBSET ((preimage X f A) UNION (preimage X f B))) <=>
480 (Z SUBSET X) /\ (IMAGE f Z SUBSET (A UNION B))`,
484 REWRITE_TAC[preimage;IMAGE;UNION;SUBSET;IN;IN_ELIM_THM' ];
489 let subset_preimage = prove_by_refinement(
490 `!(f:A->B) A X Z. (Z SUBSET (preimage X f A)) <=> (Z SUBSET X) /\
491 (IMAGE f Z SUBSET A)`,
494 REWRITE_TAC[SUBSET;preimage;IMAGE;IN;IN_ELIM_THM'];
499 let preimage_unions = prove_by_refinement(
500 `!dom (f:A->B) C. preimage dom f (UNIONS C) =
501 (UNIONS (IMAGE (preimage dom f) C))`,
504 REWRITE_TAC[preimage;IN_UNIONS ];
505 REWRITE_TAC[UNIONS;IN_IMAGE ];
506 REWRITE_TAC[preimage;IN];
508 IMATCH_MP_TAC EQ_EXT ;
510 REWRITE_TAC[IN_ELIM_THM'];
511 REWRITE_TAC[Q_ELIM_THM;IN_ELIM_THM' ];
516 let preimage_subset = prove_by_refinement(
517 `!(f:A->B) X A B. (A SUBSET B) ==>
518 (preimage X f A SUBSET (preimage X f B))`,
521 REWRITE_TAC[SUBSET;in_preimage];
527 (* to fix two varying descriptions of ((INTER) Y): *)
528 let INTER_THM = prove_by_refinement(
529 `!(X:A->bool). ((\B. B INTER X) = ((INTER) X)) /\
530 ((\B. X INTER B) = ((INTER) X))`,
533 REWRITE_TAC[INTER_COMM];
535 MATCH_MP_TAC EQ_EXT THEN BETA_TAC;
536 REWRITE_TAC[INTER_COMM];
541 (* ------------------------------------------------------------------ *)
542 (* Real Preliminaries *)
543 (* ------------------------------------------------------------------ *)
545 let REAL_SUM_SQUARE_POS = prove_by_refinement(
546 `!m n x . &.0 <=. sum(m,n) (\i. (x i)*.(x i))`,
550 MATCH_MP_TAC SUM_POS_GEN;
553 REWRITE_TAC[REAL_LE_SQUARE];
557 (* twopow , DUPLICATE OF TWOPOW_MK_POS *)
558 let twopow_pos = prove_by_refinement(
559 `!n. (&.0 <. twopow(n))`,
563 DISJ_CASES_TAC (SPEC `n:int` INT_IMAGE);
565 ASM_REWRITE_TAC[TWOPOW_POS];
569 ASM_REWRITE_TAC[TWOPOW_NEG];
575 let twopow_double = prove_by_refinement(
576 `!n. &.2 * (twopow (--: (&: (n+1)))) = twopow (--: (&:n))`,
580 REWRITE_TAC[TWOPOW_NEG;REAL_POW_ADD;POW_1;REAL_INV_MUL ];
581 REWRITE_TAC [REAL_ARITH `a*b*cc = (a*cc)*b`];
582 REWRITE_TAC [REAL_RINV_2 ];
588 let min_finite = prove_by_refinement(
589 `!X. (FINITE X) /\ (~(X = EMPTY )) ==>
590 (?delta. (X delta) /\ (!x. (X x) ==> (delta <=. x)))`,
594 TYPE_THEN `(!X k. FINITE X /\ (~(X = EMPTY )) /\ (X HAS_SIZE k) ==> (?delta. X delta /\ (!x. X x ==> delta <= x))) ==>(!X. FINITE X /\ (~(X = EMPTY )) ==> (?delta. X delta /\ (!x. X x ==> delta <= x)))` SUBGOAL_TAC ;
597 TYPE_THEN `X` (USE 0 o SPEC);
598 TYPE_THEN `CARD X` (USE 0 o SPEC);
600 DISCH_THEN IMATCH_MP_TAC ;
601 ASM_REWRITE_TAC[HAS_SIZE ];
602 DISCH_THEN IMATCH_MP_TAC ;
603 CONV_TAC (quant_left_CONV "k");
605 REWRITE_TAC[HAS_SIZE_0];
607 ASM_REWRITE_TAC[EMPTY];
610 USE 3(REWRITE_RULE[HAS_SIZE]);
611 TYPE_THEN `X DELETE (CHOICE X)` (USE 0 o SPEC);
614 USE 3 (REWRITE_RULE [ARITH_RULE `SUC 0=1`]);
615 TYPE_THEN `SING X` SUBGOAL_TAC ;
616 IMATCH_MP_TAC CARD_SING_CONV;
617 ASM_MESON_TAC [HAS_SIZE];
621 TYPE_THEN `x` EXISTS_TAC ;
622 ASM_REWRITE_TAC[REWRITE_RULE[IN] IN_SING ];
624 TYPE_THEN `FINITE (X DELETE CHOICE X) /\ ~(X DELETE CHOICE X = {}) /\ (X DELETE CHOICE X HAS_SIZE k ) ` SUBGOAL_TAC;
625 REWRITE_TAC[FINITE_DELETE;HAS_SIZE ];
628 IMATCH_MP_TAC (TAUT `(a /\ b) ==> (b /\ a)`);
630 IMATCH_MP_TAC (ARITH_RULE `(SUC x = SUC y) ==> (x = y)`);
633 DISCH_THEN (fun t-> REWRITE_TAC[GSYM t]);
634 IMATCH_MP_TAC CARD_DELETE_CHOICE;
636 IMATCH_MP_TAC (TAUT `(b ==> ~a ) ==> (a ==> ~b)`);
637 DISCH_THEN (fun t-> ASM_REWRITE_TAC[t;CARD_CLAUSES]);
642 TYPE_THEN `if (delta < (CHOICE X)) then delta else (CHOICE X)` EXISTS_TAC;
643 (* REWRITE_TAC[min_real]; *)
647 REWRITE_TAC[DELETE;IN ;IN_ELIM_THM' ];
651 REWRITE_TAC[DELETE;IN ;IN_ELIM_THM' ];
653 TYPE_THEN `x = CHOICE X` ASM_CASES_TAC ;
659 IMATCH_MP_TAC (REWRITE_RULE[IN ] CHOICE_DEF);
663 TYPE_THEN `x = CHOICE X` ASM_CASES_TAC ;
667 REWRITE_TAC[DELETE;IN ;IN_ELIM_THM' ];
669 TYPE_THEN `x` (USE 11 o SPEC);
678 let min_finite_delta = prove_by_refinement(
679 `!c X. (FINITE X) /\ ( !x. (X x) ==> (c <. x) ) ==>
680 (?delta. (c <. delta) /\ (!x. (X x) ==> (delta <=. x)))`,
684 TYPE_THEN `~(X = EMPTY)` ASM_CASES_TAC;
686 USE 0 (MATCH_MP min_finite);
688 TYPE_THEN `delta` EXISTS_TAC;
692 ASM_REWRITE_TAC[EMPTY];
693 TYPE_THEN `c +. (&.1)` EXISTS_TAC;
698 let union_closed_interval = prove_by_refinement(
699 `!a b c. (a <=. b) /\ (b <=. c) ==>
700 ({x | a <= x /\ x < b} UNION {x | b <= x /\ x <= c} =
701 { x | a <= x /\ x <= c})`,
705 REWRITE_TAC[UNION;IN;IN_ELIM_THM'];
706 IMATCH_MP_TAC EQ_EXT ;
707 REWRITE_TAC[IN_ELIM_THM'];
714 let real_half_LT = prove_by_refinement(
715 `!x y z. ((x < z/(&.2)) /\ (y < z/(&.2)) ==> (x + y < z))`,
719 (GEN_REWRITE_TAC RAND_CONV) [GSYM REAL_HALF_DOUBLE];
726 let real_half_LE = prove_by_refinement(
727 `!x y z. ((x < z/(&.2)) /\ (y <= z/(&.2)) ==> (x + y < z))`,
731 (GEN_REWRITE_TAC RAND_CONV) [GSYM REAL_HALF_DOUBLE];
738 let real_half_EL = prove_by_refinement(
739 `!x y z. ((x <= z/(&.2)) /\ (y < z/(&.2)) ==> (x + y < z))`,
743 (GEN_REWRITE_TAC RAND_CONV) [GSYM REAL_HALF_DOUBLE];
750 let real_half_LLE = prove_by_refinement(
751 `!x y z. ((x <= z/(&.2)) /\ (y <= z/(&.2)) ==> (x + y <= z))`,
755 (GEN_REWRITE_TAC RAND_CONV) [GSYM REAL_HALF_DOUBLE];
762 let interval_finite = prove_by_refinement(
763 `!N. FINITE {x | ?j. (abs x = &.j) /\ (j <=| N)}`,
767 ABBREV_TAC `inter = {n | n <=| N}`;
768 SUBGOAL_TAC `FINITE {y | ?x. (x IN inter /\ (y = (&. x)))}`;
769 MATCH_MP_TAC FINITE_IMAGE_EXPAND;
771 REWRITE_TAC[FINITE_NUMSEG_LE];
772 SUBGOAL_TAC `FINITE {y | ?x. (x IN inter /\ (y = --.(&. x)))}`;
773 MATCH_MP_TAC FINITE_IMAGE_EXPAND;
775 REWRITE_TAC[FINITE_NUMSEG_LE];
778 USE 1 (REWRITE_RULE[GSYM FINITE_UNION]);
780 SUBGOAL_TAC `!a b. ((a:real->bool) = b) ==> (FINITE a ==> FINITE b)`;
782 DISCH_THEN (fun t-> REWRITE_TAC[t]);
783 DISCH_THEN (fun t-> MATCH_MP_TAC t);
786 REWRITE_TAC[IN_ELIM_THM';UNION];
788 REWRITE_TAC[IN_ELIM_THM'];
789 REWRITE_TAC[real_abs];
791 MATCH_MP_TAC (TAUT `(a==>b) /\ (c==>b) ==> (a \/ c ==> b)`);
793 DISCH_THEN CHOOSE_TAC;
797 ASM_REWRITE_TAC [REAL_LE;LE_0];
798 DISCH_THEN CHOOSE_TAC;
801 ASM_REWRITE_TAC[REAL_NEG_NEG];
807 DISCH_THEN CHOOSE_TAC;
822 (* ------------------------------------------------------------------ *)
823 (* Euclidean Space *)
824 (* ------------------------------------------------------------------ *)
826 let euclid_add_closure = prove_by_refinement(
827 `!f g n. (euclid n f) /\ (euclid n g) ==> (euclid n (f + g))`,
830 REWRITE_TAC[euclid;euclid_plus];
831 ASM_MESON_TAC[REAL_ARITH `&0 +. (&.0) = (&.0)`];
835 let euclid_scale_closure = prove_by_refinement(
836 `!n t f. (euclid n f) ==> (euclid n ((t:real) *# f))`,
839 REWRITE_TAC[euclid;euclid_scale];
840 MESON_TAC[REAL_ARITH `t *.(&.0) = (&.0)`];
844 let euclid_neg_closure = prove_by_refinement(
845 `!f n. (euclid n f) ==> (euclid n (-- f))`,
849 REWRITE_TAC[euclid;euclid_neg];
851 ASM_REWRITE_TAC[REAL_ARITH `(--x = &.0) <=> (x = &.0)`];
856 let euclid_sub_closure = prove_by_refinement(
857 `!f g n. (euclid n f ) /\ (euclid n g) ==> (euclid n (f - g))`,
861 REWRITE_TAC[euclid;euclid_minus];
862 ASM_MESON_TAC[REAL_ARITH `&.0 -. (&.0) = (&.0)`];
867 let neg_dim = prove_by_refinement(
868 `!f n. (euclid n f) = (euclid n (--f))`,
874 REWRITE_TAC[euclid_neg_closure];
875 REWRITE_TAC[euclid;euclid_neg];
877 ONCE_REWRITE_TAC[REAL_ARITH `(x = &.0) <=> (--x = &.0)`];
883 let euclid_updim = prove_by_refinement (
884 `!f m n. (m <=| n) /\ (euclid m f) ==> (euclid n f)`,
892 let euclidean_add_closure = prove_by_refinement(
893 `!f g. (euclidean f) /\ (euclidean g) ==> (euclidean (f+g))`,
897 REWRITE_TAC[euclidean];
899 UNDISCH_FIND_THEN `euclid` CHOOSE_TAC;
900 UNDISCH_FIND_THEN `(?)` CHOOSE_TAC;
902 ASSUME_TAC (ARITH_RULE `n <=| n+n'`);
903 ASSUME_TAC (ARITH_RULE `n' <=| n+n'`);
904 ASM_MESON_TAC[euclid_add_closure;euclid_updim];
909 let euclidean_sub_closure = prove_by_refinement(
910 `!f g. (euclidean f) /\ (euclidean g) ==> (euclidean (f-g))`,
914 REWRITE_TAC[euclidean];
916 UNDISCH_FIND_THEN `euclid` CHOOSE_TAC;
917 UNDISCH_FIND_THEN `(?)` CHOOSE_TAC;
919 ASSUME_TAC (ARITH_RULE `n <=| n+n'`);
920 ASSUME_TAC (ARITH_RULE `n' <=| n+n'`);
921 ASM_MESON_TAC[euclid_sub_closure;euclid_updim];
926 let euclidean_scale_closure = prove_by_refinement(
927 `!s f. (euclidean f) ==> (euclidean (s *# f))`,
930 REWRITE_TAC[euclidean];
932 DISCH_THEN CHOOSE_TAC;
934 ASM_MESON_TAC[euclid_scale_closure];
938 let euclidean_neg_closure = prove_by_refinement(
939 `!f. (euclidean f) ==> (euclidean (-- f))`,
942 REWRITE_TAC[euclidean];
944 DISCH_THEN CHOOSE_TAC;
946 ASM_MESON_TAC[euclid_neg_closure];
950 let euclid_add_comm = prove_by_refinement(
951 `!(f:num->real) g. (f + g = g + f)`,
954 REWRITE_TAC[euclid_plus;REAL_ARITH `a+.b = b+.a`]
958 let euclid_add_assoc = prove_by_refinement(
959 `!(f:num->real) g h. (f + g)+h = f + g + h`,
962 REWRITE_TAC[euclid_plus;REAL_ARITH `(a+.b)+.c = a+b+c`];
966 let euclid_lzero = prove_by_refinement(
967 `!f. euclid0 + f = f`,
970 REWRITE_TAC[euclid_plus;euclid0;REAL_ARITH `&.0+a=a`];
971 ACCEPT_TAC (INST_TYPE [(`:num`,`:A`);(`:real`,`:B`)] ETA_AX);
975 let euclid_rzero = prove_by_refinement(
976 `!f. f + euclid0 = f`,
979 REWRITE_TAC[euclid_plus;euclid0;REAL_ARITH `a+(&.0)=a`];
980 ACCEPT_TAC (INST_TYPE [(`:num`,`:A`);(`:real`,`:B`)] ETA_AX);
984 let euclid_ldistrib = prove_by_refinement(
985 `!f g r. r *# (f + g) = (r *# f) + (r *# g)`,
988 REWRITE_TAC[euclid_plus;euclid_scale;REAL_ARITH `a*(b+.c)=a*b+a*c`];
992 let euclid_rdistrib = prove_by_refinement(
993 `!f r s. (r+s)*# f = (r *# f) + (s *# f)`,
996 REWRITE_TAC[euclid_plus;euclid_scale;REAL_ARITH `(a+b)*c= a*c+b*c`];
1000 let euclid_scale_act = prove_by_refinement(
1001 `!r s f. r *# (s *# f) = (r *s) *# f`,
1004 REWRITE_TAC[euclid_scale;REAL_ARITH `(a*b)*c = a*(b*c)`];
1008 let euclid_scale_one = prove_by_refinement(
1009 `!f. (&.1) *# f = f`,
1012 REWRITE_TAC[euclid_scale];
1018 let euclid_neg_sum = prove_by_refinement(
1019 `!x y . euclid_minus (--x) (--y) = -- (euclid_minus x y)`,
1022 REWRITE_TAC[euclid_neg;euclid_minus];
1024 IMATCH_MP_TAC EQ_EXT;
1030 let trivial_lin_combo = prove_by_refinement(
1031 `!x t. ((t *# x) + (&.1 - t) *# x = x)`,
1035 REWRITE_TAC[euclid_plus;euclid_scale;];
1036 IMATCH_MP_TAC EQ_EXT THEN BETA_TAC;
1044 let dot_euclid = prove_by_refinement(
1045 `!p f g. (euclid p f) /\ (euclid p g) ==>
1046 (dot f g = sum (0,p) (\i. (f i)* (g i)))`,
1053 ABBREV_TAC `(P:num->bool) = \m. (euclid m f) /\ (euclid m g)`;
1055 SUBGOAL_TAC `(P:num->bool) (p:num)`;
1059 SUBGOAL_TAC `min_num P <=| p`;
1060 ASM_MESON_TAC[min_least];
1063 `euclid (min_num (P:num->bool)) f /\ (euclid (min_num (P:num->bool)) g)`;
1064 ASM_MESON_TAC[min_least];
1066 ABBREV_TAC `q = min_num P`;
1067 MP_TAC (SPECL [`q:num`;`p:num`] LE_EXISTS);
1069 DISCH_THEN CHOOSE_TAC;
1070 ASM_REWRITE_TAC[GSYM SUM_TWO];
1071 MATCH_MP_TAC (REAL_ARITH `(u = (&.0)) ==> (x = x + u)`);
1072 SUBGOAL_THEN `!n. n>=| q ==> ((\i. f i *. g i) n = (&.0))` (fun th -> MATCH_MP_TAC (MATCH_MP SUM_ZERO th));
1073 GEN_TAC THEN BETA_TAC;
1075 SUBGOAL_THEN `(f:num->real) n = (&.0)` (fun th -> REWRITE_TAC[th;REAL_ARITH `(&.0)*.a =(&.0)`]);
1076 UNDISCH_TAC `euclid q f`;
1077 UNDISCH_TAC `n >=| q`;
1078 MESON_TAC[euclid;ARITH_RULE `(a<=|b) <=> (b >=| a)`];
1079 ACCEPT_TAC (ARITH_RULE `q >=| q`);
1084 let dot_updim = prove_by_refinement (
1085 `!f g m n. (m <=|n) /\ (euclid m f) /\ (euclid m g) ==>
1086 (dot f g = sum (0,n) (\i. (f i)* (g i)))`,
1091 SUBGOAL_TAC `(euclid n f) /\ (euclid n g)`;
1092 ASM_MESON_TAC[euclid_updim];
1093 MATCH_ACCEPT_TAC dot_euclid]
1097 let dot_nonneg = prove_by_refinement(
1098 `!f. (&.0 <= (dot f f))`,
1104 SUBGOAL_TAC `(!n. (&.0 <=. (\(i:num). f i *. f i) n))`;
1106 REWRITE_TAC[REAL_LE_SQUARE];
1107 ASSUME_TAC(SPEC `\i. (f:num->real) i *. f i` SUM_POS);
1111 let dot_comm = prove_by_refinement(
1112 `!f g. (dot f g = dot g f)`,
1116 REWRITE_TAC[REAL_ARITH `a*.b = b*.a`;TAUT `a/\b <=> b/\a`]
1120 let dot_neg = prove_by_refinement(
1121 `!f g. (dot (--f) g) = --. (dot f g)`,
1126 REWRITE_TAC [GSYM neg_dim];
1127 ONCE_REWRITE_TAC[GSYM SUM_NEG];
1128 REWRITE_TAC[euclid_neg];
1131 MATCH_MP_TAC EQ_EXT;
1134 REWRITE_TAC[REAL_ARITH `(--x) * y = --. (x *y)`];
1138 let dot_neg2 = prove_by_refinement(
1139 `!f g. (dot f (--g)) = --. (dot f g)`,
1142 ONCE_REWRITE_TAC[dot_comm];
1143 REWRITE_TAC[dot_neg];
1147 let dot_scale = prove_by_refinement(
1148 `!n f g s. (euclid n f) /\ (euclid n g) ==>
1149 (dot (s *# f) g = s *. (dot f g))`,
1152 REWRITE_TAC[euclid_scale];
1154 DISCH_THEN (fun th -> ASSUME_TAC th THEN ASSUME_TAC (MATCH_MP dot_euclid th));
1155 SUBGOAL_THEN (`euclid n (\ (i:num). (s *. f i) ) /\ (euclid n g)`) ASSUME_TAC;
1157 ASSUME_TAC(REWRITE_RULE[euclid_scale](SPECL [`n:num`;`s:real`;`f:num->real`] euclid_scale_closure));
1159 IMP_RES_THEN ASSUME_TAC dot_euclid;
1161 REWRITE_TAC[GSYM SUM_CMUL];
1163 MATCH_MP_TAC EQ_EXT;
1166 REWRITE_TAC[REAL_ARITH `a*.(b*.c) = (a*b)*c`];
1170 let dot_scale_euclidean = prove_by_refinement(
1171 `!f g s. (euclidean f) /\ (euclidean g) ==>
1172 (dot (s *# f) g = s *. (dot f g))`,
1176 REWRITE_TAC[euclidean];
1178 REPEAT (UNDISCH_FIND_THEN `euclid` (CHOOSE_THEN MP_TAC));
1180 ASSUME_TAC (ARITH_RULE `(n' <=| n+n')`);
1181 ASSUME_TAC (ARITH_RULE `(n <=| n+n')`);
1182 SUBGOAL_TAC `euclid (n+|n') f /\ euclid (n+n') g`;
1183 ASM_MESON_TAC[euclid_updim];
1184 MESON_TAC[dot_scale];
1189 let dot_scale2 = prove_by_refinement(
1190 `!n f g s. (euclid n f) /\ (euclid n g) ==>
1191 (dot f (s *# g) = s *. (dot f g))`,
1194 ONCE_REWRITE_TAC[dot_comm];
1195 MESON_TAC[dot_scale]
1199 let dot_scale2_euclidean = prove_by_refinement(
1200 `!f g s. (euclidean f) /\ (euclidean g) ==>
1201 (dot f (s *# g) = s *. (dot f g))`,
1204 ONCE_REWRITE_TAC[dot_comm];
1205 MESON_TAC[dot_scale_euclidean];
1209 let dot_linear = prove_by_refinement(
1210 `!n f g h. (euclid n f) /\ (euclid n g) /\ (euclid n h) ==>
1211 ((dot (f + g) h ) = (dot f h) +. (dot g h))`,
1215 SUBGOAL_TAC `euclid n (f+g)`;
1216 ASM_MESON_TAC[euclid_add_closure];
1218 MP_TAC (SPECL [`n:num`;`f:num->real`;`h:num->real`] dot_euclid);
1219 MP_TAC (SPECL [`n:num`;`g:num->real`;`h:num->real`] dot_euclid);
1220 MP_TAC (SPECL [`n:num`;`(f+g):num->real`;`h:num->real`] dot_euclid); ASM_REWRITE_TAC[];
1223 REWRITE_TAC[GSYM SUM_ADD];
1225 MATCH_MP_TAC EQ_EXT THEN GEN_TAC THEN BETA_TAC;
1226 REWRITE_TAC[euclid_plus];
1227 REWRITE_TAC[REAL_ARITH `(a+.b)*.c = a*c + b*c`];
1231 let dot_minus_linear = prove_by_refinement(
1232 `!n f g h. (euclid n f) /\ (euclid n g) /\ (euclid n h) ==>
1233 ((dot (f - g) h ) = (dot f h) -. (dot g h))`,
1238 SUBGOAL_TAC `euclid n (f-g)`;
1239 ASM_MESON_TAC[euclid_sub_closure];
1241 MP_TAC (SPECL [`n:num`;`f:num->real`;`h:num->real`] dot_euclid);
1242 MP_TAC (SPECL [`n:num`;`g:num->real`;`h:num->real`] dot_euclid);
1243 MP_TAC (SPECL [`n:num`;`(f-g):num->real`;`h:num->real`] dot_euclid);
1247 REWRITE_TAC[GSYM SUM_SUB];
1249 MATCH_MP_TAC EQ_EXT THEN GEN_TAC THEN BETA_TAC;
1250 REWRITE_TAC[euclid_minus];
1251 REWRITE_TAC[REAL_ARITH `(a-.b)*.c = a*c - b*c`];
1256 let dot_linear_euclidean = prove_by_refinement(
1257 `!f g h. (euclidean f) /\ (euclidean g) /\ (euclidean h) ==>
1258 ((dot (f + g) h ) = (dot f h) +. (dot g h))`,
1261 REWRITE_TAC[euclidean];
1263 REPEAT (UNDISCH_FIND_THEN `euclid` (CHOOSE_THEN MP_TAC));
1265 SUBGOAL_TAC `(euclid (n+n'+n'') f)`;
1266 ASM_MESON_TAC[ARITH_RULE `n <=| n+n'+n''`;euclid_updim];
1267 SUBGOAL_TAC `(euclid (n+n'+n'') g)`;
1268 ASM_MESON_TAC[ARITH_RULE `n' <=| n+n'+n''`;euclid_updim];
1269 SUBGOAL_TAC `(euclid (n+n'+n'') h)`;
1270 ASM_MESON_TAC[ARITH_RULE `n'' <=| n+n'+n''`;euclid_updim];
1271 MESON_TAC[dot_linear]]);;
1274 let dot_minus_linear_euclidean = prove_by_refinement(
1275 `!f g h. (euclidean f) /\ (euclidean g) /\ (euclidean h) ==>
1276 ((dot (f - g) h ) = (dot f h) -. (dot g h))`,
1280 REWRITE_TAC[euclidean];
1282 REPEAT (UNDISCH_FIND_THEN `euclid` (CHOOSE_THEN MP_TAC));
1284 SUBGOAL_TAC `(euclid (n+n'+n'') f)`;
1285 ASM_MESON_TAC[ARITH_RULE `n <=| n+n'+n''`;euclid_updim];
1286 SUBGOAL_TAC `(euclid (n+n'+n'') g)`;
1287 ASM_MESON_TAC[ARITH_RULE `n' <=| n+n'+n''`;euclid_updim];
1288 SUBGOAL_TAC `(euclid (n+n'+n'') h)`;
1289 ASM_MESON_TAC[ARITH_RULE `n'' <=| n+n'+n''`;euclid_updim];
1290 MESON_TAC[dot_minus_linear];
1295 let dot_linear2 = prove_by_refinement(
1296 `!n f g h. (euclid n f) /\ (euclid n g) /\ (euclid n h) ==>
1297 ((dot h (f + g)) = (dot h f) +. (dot h g))`,
1302 ONCE_REWRITE_TAC[dot_comm];
1303 MESON_TAC[dot_linear]
1308 let dot_linear2_euclidean = prove_by_refinement(
1309 `!f g h. (euclidean f) /\ (euclidean g) /\ (euclidean h) ==>
1310 ((dot h (f + g)) = (dot h f) +. (dot h g))`,
1314 ONCE_REWRITE_TAC[dot_comm];
1315 MESON_TAC[dot_linear_euclidean]
1319 let dot_minus_linear2 = prove_by_refinement(
1320 `!n f g h. (euclid n f) /\ (euclid n g) /\ (euclid n h) ==>
1321 ((dot h (f - g)) = (dot h f) -. (dot h g))`,
1326 ONCE_REWRITE_TAC[dot_comm];
1327 MESON_TAC[dot_minus_linear]
1332 let dot_minus_linear2_euclidean = prove_by_refinement(
1333 `!f g h. (euclidean f) /\ (euclidean g) /\ (euclidean h) ==>
1334 ((dot h (f - g)) = (dot h f) -. (dot h g))`,
1339 ONCE_REWRITE_TAC[dot_comm];
1340 MESON_TAC[dot_minus_linear_euclidean]
1345 let dot_rzero = prove_by_refinement(
1346 `!f. (dot f euclid0) = &.0`,
1349 REWRITE_TAC[dot;euclid0];
1352 SUBGOAL_THEN `(\ (i:num). (f i *. (&.0))) = (\ (r:num). (&.0))` (fun t -> REWRITE_TAC[t]);
1353 REWRITE_TAC[REAL_ARITH `a*.(&.0) = (&.0)`];
1358 let dot_lzero = prove_by_refinement(
1359 `!f. (dot euclid0 f ) = &.0`,
1362 ONCE_REWRITE_TAC[dot_comm];
1363 REWRITE_TAC[dot_rzero];
1367 let dot_zero = prove_by_refinement(
1368 `!f n. (euclid n f) /\ (dot f f = (&.0)) ==> (f = euclid0)`,
1372 UNDISCH_TAC `dot f f = (&.0)`;
1373 MP_TAC (SPECL [`n:num`;`f:num->real`;`f:num->real`] dot_euclid);
1375 DISCH_THEN (fun th -> REWRITE_TAC[th]);
1376 REWRITE_TAC[euclid0];
1378 MATCH_MP_TAC EQ_EXT;
1379 GEN_TAC THEN BETA_TAC;
1380 DISJ_CASES_TAC (ARITH_RULE `x <| n \/ (n <=| x)`);
1381 CLEAN_ASSUME_TAC (ARITH_RULE `(x <|n) ==> (SUC x <=| n)`);
1382 CLEAN_THEN (SPECL [`SUC x`;`n:num`] LE_EXISTS) CHOOSE_TAC;
1383 UNDISCH_TAC `sum(0,n) (\ (i:num). f i *. f i) = (&.0)`;
1385 REWRITE_TAC[GSYM SUM_TWO;sum;ARITH_RULE `0+| x = x`];
1386 SUBGOAL_TAC `!a b. (&.0 <=. sum(a,b) (\ (i:num). f i *. f i))`;
1388 MP_TAC (SPEC `\ (i:num). f i *. f i` SUM_POS);
1390 REWRITE_TAC[REAL_LE_SQUARE];
1393 IMP_RES_THEN MP_TAC (REAL_ARITH `(a+.b = &.0) ==> ((&.0 <=. b) ==> (a <=. (&.0)))`);
1396 IMP_RES_THEN MP_TAC (REAL_ARITH `(a+b <=. &.0) ==> ((&.0 <=. a) ==> (b <=. (&.0)))`);
1398 ABBREV_TAC `a = (f:num->real) x`;
1399 MESON_TAC[REAL_LE_SQUARE;REAL_ARITH `a <=. (&.0) /\ (&.0 <=. a) ==> (a = (&.0))`;REAL_ENTIRE];
1400 UNDISCH_TAC `euclid n f`;
1401 REWRITE_TAC[euclid];
1406 let dot_zero_euclidean = prove_by_refinement(
1407 `!f. (euclidean f) /\ (dot f f = (&.0)) ==> (f = euclid0)`,
1410 REWRITE_TAC[euclidean];
1412 UNDISCH_FIND_THEN `euclid` CHOOSE_TAC;
1413 ASM_MESON_TAC[dot_zero];
1419 let norm_nonneg = prove_by_refinement(
1420 `!f. (&.0 <=. norm f)`,
1424 ONCE_REWRITE_TAC[GSYM SQRT_0];
1426 MATCH_MP_TAC SQRT_MONO_LE;
1427 REWRITE_TAC[dot_nonneg];
1432 let norm_neg = prove_by_refinement(
1433 `!f. norm (--f) = norm f`,
1437 REWRITE_TAC[norm;dot_neg;dot_neg2];
1438 REWRITE_TAC[REAL_ARITH `--(--. x) = x`];
1443 let cauchy_schwartz = prove_by_refinement(
1444 `!f g. (euclidean f) /\ (euclidean g) ==>
1445 ((abs(dot f g)) <=. (norm f)*. (norm g))`,
1449 DISJ_CASES_TAC (TAUT `(f = euclid0 ) \/ ~(f = euclid0)`);
1450 ASM_REWRITE_TAC[dot_lzero;norm;SQRT_0;REAL_ARITH`&.0 *. x = (&.0)`];
1451 REWRITE_TAC[ABS_0;REAL_ARITH `x <=. x`];
1452 SUBGOAL_THEN `!a b. (dot (a *# f + b *# g) (a *# f + b *# g)) = a*a*(dot f f) + (&.2)*a*b*(dot f g) + b*b*(dot g g)` ASSUME_TAC;
1454 ASM_SIMP_TAC[euclidean_scale_closure;euclidean_add_closure;dot_linear_euclidean;dot_linear2_euclidean;dot_scale_euclidean;dot_scale2_euclidean];
1455 REWRITE_TAC[REAL_MUL_AC;REAL_ADD_AC;REAL_ADD_LDISTRIB];
1456 MATCH_MP_TAC (REAL_ARITH`(b+. c=e) ==> (a+b+c+d = a+ e+d)`);
1457 REWRITE_TAC[GSYM REAL_LDISTRIB];
1459 MATCH_MP_TAC (REAL_ARITH `(a=b)==> (a+.b = a*(&.2))`);
1460 REWRITE_TAC[dot_comm];
1461 FIRST_ASSUM (fun th -> ASSUME_TAC (SPECL[` --. (dot f g)`;`dot f f`] th));
1462 CLEAN_THEN (SPEC `(--.(dot f g)) *# f + (dot f f)*# g` dot_nonneg) ASSUME_TAC;
1464 ASSUME_TAC(SPEC `f:num->real` dot_nonneg);
1465 ASSUME_TAC(SPEC `g:num->real` dot_nonneg);
1466 ASM_SIMP_TAC[GSYM SQRT_MUL];
1467 REWRITE_TAC[GSYM POW_2_SQRT_ABS;POW_2];
1468 MATCH_MP_TAC SQRT_MONO_LE;
1469 REWRITE_TAC[REAL_LE_SQUARE];
1470 SUBGOAL_TAC `&.0 <. dot f f`;
1471 MATCH_MP_TAC (REAL_ARITH `~(x = &.0) /\ (&.0 <=. x) ==> (&.0 <. x)`);
1473 ASM_MESON_TAC[dot_zero_euclidean];
1474 REPEAT (UNDISCH_FIND_TAC `(<=.)` );
1475 ABBREV_TAC `a = dot f f`;
1476 ABBREV_TAC `b = dot f g`;
1477 ABBREV_TAC `c = dot g g`;
1478 POP_ASSUM_LIST (fun t -> ALL_TAC);
1479 REWRITE_TAC[REAL_ARITH `(&.2 *. x = x + x)`;REAL_ADD_AC];
1480 REWRITE_TAC[REAL_ARITH `(a *. ((--. b)*.c) = --. (a *. (b*.c)))/\ (--. ((--. a) *. b) = a *.b )`];
1481 REWRITE_TAC[REAL_ARITH `(--. b) *. a*. b + b*.b*.a = (&.0)`];
1482 REWRITE_TAC[REAL_ARITH `x +. (&.0) = x`];
1483 REWRITE_TAC[REAL_ARITH `(&.0 <=. (a*.a*.c +. (--.b)*.a*.b)) <=> (a*b*b <=. a*a*c)`];
1485 MATCH_MP_TAC (SPEC `a:real` REAL_LE_LCANCEL_IMP);
1490 let norm_dot = prove_by_refinement(
1491 `!h. norm(h) * norm(h) = (dot h h)`,
1495 ONCE_REWRITE_TAC[GSYM POW_2];
1496 REWRITE_TAC[SQRT_POW2;dot_nonneg];
1500 let norm_triangle = prove_by_refinement(
1501 `!f g. (euclidean f) /\ (euclidean g) ==>
1502 (norm (f+g) <=. norm(f) + norm(g))`,
1506 MATCH_MP_TAC square_le;
1507 REWRITE_TAC[norm_nonneg];
1509 MATCH_MP_TAC (REAL_ARITH `(&.0 <=. x) /\ (&.0 <=. y) ==> (&.0 <= x+y)`);
1510 REWRITE_TAC[norm_nonneg];
1511 REWRITE_TAC[REAL_ADD_LDISTRIB;REAL_ADD_RDISTRIB;REAL_ADD_AC];
1512 REWRITE_TAC[norm_dot];
1513 ASM_SIMP_TAC[euclidean_add_closure;dot_linear_euclidean;dot_linear2_euclidean];
1514 REWRITE_TAC[REAL_MUL_AC];
1515 REWRITE_TAC[REAL_ADD_AC];
1516 MATCH_MP_TAC (REAL_ARITH `(b<=.c)==>((a+.b) <=. (a+c))`);
1517 MATCH_MP_TAC (REAL_ARITH `(a=b)/\ (a<=. e) ==>((a+b+c) <= (c+e+e))`);
1519 REWRITE_TAC[dot_comm];
1520 ASM_MESON_TAC[cauchy_schwartz;REAL_LE_TRANS;REAL_ARITH `x <=. ||. x`];
1526 (* ------------------------------------------------------------------ *)
1528 (* ------------------------------------------------------------------ *)
1530 let metric_space_zero = prove_by_refinement(
1531 `!(X:A->bool) d a. (metric_space(X,d) /\ (X a) ==> (d a a = (&.0)))`,
1533 [MESON_TAC[metric_space]
1537 let metric_space_symm = prove_by_refinement(
1538 `!(X:A->bool) d a b. (metric_space(X,d) /\ (X a) /\ (X b) ==>
1542 MESON_TAC[metric_space];
1546 let metric_space_triangle = prove_by_refinement(
1547 `!(X:A->bool) d a b c. (metric_space(X,d) /\ (X a) /\ (X b) /\ (X c)
1548 ==> (d a c <=. d a b +. d b c))`,
1551 MESON_TAC[metric_space];
1555 let metric_subspace = prove_by_refinement(
1556 `!X Y d. (Y SUBSET (X:A->bool)) /\ (metric_space (X,d)) ==>
1557 (metric_space (Y,d))`,
1560 REWRITE_TAC[SUBSET;metric_space;IN];
1563 UNDISCH_FIND_THEN `( /\ )` (fun t -> MP_TAC (SPECL[`x:A`;`y:A`;`z:A`] t));
1568 let metric_euclidean = prove_by_refinement(
1569 `metric_space (euclidean,d_euclid)`,
1572 REWRITE_TAC[metric_space;d_euclid];
1575 REWRITE_TAC[norm_nonneg];
1579 ONCE_REWRITE_TAC[REAL_ARITH `(&.0 = x) <=> (x = (&.0))`];
1580 ASM_SIMP_TAC[dot_nonneg;SQRT_EQ_0];
1582 SUBGOAL_TAC `x - y = euclid0`;
1583 ASM_MESON_TAC[dot_zero_euclidean;euclidean_sub_closure];
1584 REWRITE_TAC[euclid_minus;euclid0];
1585 DISCH_TAC THEN (MATCH_MP_TAC EQ_EXT);
1587 FIRST_ASSUM (fun t -> ASSUME_TAC (BETA_RULE (AP_THM t `n:num`)));
1588 ASM_MESON_TAC [REAL_ARITH `(a = b) <=> (a-.b = (&.0))`];
1589 DISCH_THEN (fun t->REWRITE_TAC[t]);
1590 SUBGOAL_THEN `(y:num->real) - y = euclid0` (fun t-> REWRITE_TAC[t]);
1591 REWRITE_TAC[euclid0;euclid_minus];
1592 MATCH_MP_TAC EQ_EXT;
1593 GEN_TAC THEN BETA_TAC;
1595 REWRITE_TAC[norm;dot_lzero;SQRT_0];
1597 SUBGOAL_THEN `x - y = (euclid_neg (y-x))` ASSUME_TAC;
1598 REWRITE_TAC[euclid_neg;euclid_minus];
1599 MATCH_MP_TAC EQ_EXT THEN GEN_TAC THEN BETA_TAC;
1601 ASM_MESON_TAC[norm_neg];
1602 SUBGOAL_THEN `(x-z) = euclid_plus(x - y) (y-z)` (fun t -> REWRITE_TAC[t]);
1603 REWRITE_TAC[euclid_plus;euclid_minus];
1604 MATCH_MP_TAC EQ_EXT THEN GEN_TAC THEN BETA_TAC THEN REAL_ARITH_TAC;
1605 ASM_SIMP_TAC[norm_triangle;euclidean_sub_closure;euclidean_sub_closure];
1609 let metric_euclid = prove_by_refinement(
1610 `!n. metric_space (euclid n,d_euclid)`,
1614 MATCH_MP_TAC (ISPEC `euclidean` metric_subspace);
1615 REWRITE_TAC[metric_euclidean;SUBSET;IN];
1616 MESON_TAC[euclidean];
1620 let euclid1_abs = prove_by_refinement(
1621 `!x y. (euclid 1 x) /\ (euclid 1 y) ==>
1622 ((d_euclid x y) = (abs ((x 0) -. (y 0))))`,
1625 REWRITE_TAC[d_euclid;norm];
1627 SUBGOAL_TAC `euclid 1 (x - y)`;
1628 ASM_MESON_TAC[euclid_sub_closure];
1630 ASSUME_TAC (prove(`1 <= 1`,ARITH_TAC));
1631 MP_TAC (SPECL[`(x-y):num->real`;`(x-y):num->real`;`1`;`1`] dot_updim);
1633 DISCH_THEN (fun t-> REWRITE_TAC[t]);
1634 REWRITE_TAC[prove(`1 = SUC 0`,ARITH_TAC)];
1636 REWRITE_TAC[REAL_ARITH `&.0 + x = x`];
1637 REWRITE_TAC[ARITH_RULE `0 +| 0 = 0`];
1638 REWRITE_TAC[euclid_minus];
1639 ASM_MESON_TAC[REAL_POW_2;POW_2_SQRT_ABS];
1643 let coord_dirac = prove_by_refinement(
1644 `!i t. coord i (t *# dirac_delta i ) = t`,
1648 REWRITE_TAC[coord;dirac_delta;euclid_scale];
1654 let dirac_0 = prove_by_refinement(
1655 `!x. (x *# dirac_delta 0) 0 = x`,
1659 REWRITE_TAC[dirac_delta;euclid_scale;];
1664 let euclid1_dirac = prove_by_refinement(
1665 `!x. euclid 1 x <=> (x = (x 0) *# (dirac_delta 0))`,
1669 REWRITE_TAC[euclid; euclid_scale;dirac_delta ];
1672 IMATCH_MP_TAC EQ_EXT;
1679 ASM_SIMP_TAC[ARITH_RULE `(~(0=m))==>(1<=| m)`];
1682 USE 1 (MATCH_MP (ARITH_RULE `1<= m ==> (~(0=m))`));
1683 ASM ONCE_REWRITE_TAC[];
1689 (* projection onto the ith coordinate, as a euclidean vector *)
1690 let proj = euclid_def
1691 `proj i x = (\j. (if (j=0) then (x (i:num)) else (&.0)))`;;
1693 let proj_euclid1 = prove_by_refinement(
1694 `!i x. euclid 1 (proj i x)`,
1697 REWRITE_TAC[proj;euclid];
1706 let d_euclid_n = prove_by_refinement(
1707 `!n x y. ((euclid n x) /\ (euclid n y)) ==> ((d_euclid x y) =
1708 sqrt(sum (0,n) (\i. (x i - y i) * (x i - y i))))`,
1713 REWRITE_TAC[d_euclid;norm];
1715 ASSUME_TAC (ARITH_RULE `n <=| n`);
1716 SUBGOAL_TAC `euclid n (x - y)`;
1717 ASM_SIMP_TAC[euclid_sub_closure];
1719 CLEAN_ASSUME_TAC (SPECL[`(x-y):num->real`;`(x-y):num->real`;`n:num`;`n:num`]dot_updim);
1720 ASM_REWRITE_TAC[euclid_minus];
1725 let norm_n = prove_by_refinement(
1726 `!n x. ((euclid n x) ) ==> ((norm x) =
1727 sqrt(sum (0,n) (\i. (x i ) * (x i ))))`,
1731 TYPEL_THEN [`x`;`x`;`n`;`n`] (fun t-> SIMP_TAC [norm;ISPECL t dot_updim;ARITH_RULE `n <=| n`;]);
1735 let proj_d_euclid = prove_by_refinement(
1736 `!i x y. d_euclid (proj i x) (proj i y) = abs (x i -. y i)`,
1740 SIMP_TAC[SPEC `1` d_euclid_n;proj_euclid1];
1741 REWRITE_TAC[ARITH_RULE `1 = SUC 0`;sum];
1744 REWRITE_TAC[REAL_ARITH `&.0 + x = x`];
1745 MESON_TAC[POW_2_SQRT_ABS;REAL_POW_2];
1749 let d_euclid_pos = prove_by_refinement(
1750 `!x y n. (euclid n x) /\ (euclid n y) ==> (&.0 <=. d_euclid x y)`,
1754 MP_TAC metric_euclid;
1755 REWRITE_TAC[metric_space;euclidean];
1760 let proj_contraction = prove_by_refinement(
1761 `!n x y i. (euclid n x) /\ (euclid n y) ==>
1762 abs (x i - (y i)) <=. d_euclid x y`,
1766 MATCH_MP_TAC REAL_POW_2_LE;
1767 REWRITE_TAC[REAL_ABS_POS];
1769 ASM_MESON_TAC[d_euclid_pos];
1770 ASM_SIMP_TAC[SPEC `n:num` d_euclid_n];
1771 REWRITE_TAC[REAL_POW2_ABS];
1772 SUBGOAL_TAC `euclid n (x - y)`; (* why does MESON fail here??? *)
1773 MATCH_MP_TAC euclid_sub_closure;
1776 SUBGOAL_TAC `&.0 <=. sum (0,n) (\i. (x i - y i)*. (x i - y i))`;
1777 MATCH_MP_TAC SUM_POS_GEN;
1778 DISCH_ALL_TAC THEN BETA_TAC;
1779 REWRITE_TAC[REAL_LE_SQUARE];
1780 SIMP_TAC[SQRT_POW_2];
1782 ASM_CASES_TAC `n <=| i`;
1783 MATCH_MP_TAC (REAL_ARITH `(x = (&.0)) /\ (&.0 <=. y) ==> (x <=. y)`);
1785 REWRITE_TAC[REAL_PROP_ZERO_POW];
1787 ASM_MESON_TAC[euclid;euclid_minus];
1788 MP_TAC (ARITH_RULE `~(n <=| i) ==> (i < n) /\ (n = (SUC i) + (n-i-1))`);
1789 ASM_REWRITE_TAC[] THEN DISCH_ALL_TAC;
1790 ASM ONCE_REWRITE_TAC[];
1791 REWRITE_TAC[GSYM SUM_TWO];
1792 MATCH_MP_TAC (REAL_ARITH `(a <=. b) /\ (&.0 <=. c) ==> (a <=. (b +c))`);
1794 REWRITE_TAC[sum_DEF];
1795 REWRITE_TAC[ARITH_RULE `0 +| i = i`];
1796 MATCH_MP_TAC (REAL_ARITH `(a = c) /\ (&.0 <=. b) ==> (a <=. b+c)`);
1797 REWRITE_TAC[REAL_POW_2];
1798 MP_TAC (SPECL [`0:num`;`i:num`;`(x:num->real)- y`] REAL_SUM_SQUARE_POS);
1800 REWRITE_TAC[euclid_minus];
1801 MP_TAC (SPECL [`SUC i`;`(n:num)-i-1`;`(x:num->real)- y`] REAL_SUM_SQUARE_POS);
1803 REWRITE_TAC[euclid_minus];
1807 let euclid_dirac = prove_by_refinement(
1808 `!x. (euclid 1 (x *# (dirac_delta 0)))`,
1811 REWRITE_TAC[euclid;dirac_delta ;euclid_scale];
1813 USE 0 (MATCH_MP (ARITH_RULE `1 <=| m ==> (~(0=m))`));
1819 let d_euclid_pow2 = prove_by_refinement(
1820 `!n x y. (euclid n x) /\ (euclid n y) ==>
1821 ((d_euclid x y) pow 2 = sum (0,n) (\i. (x i - y i) * (x i - y i)))`,
1825 ASM_SIMP_TAC[d_euclid_n];
1826 REWRITE_TAC[SQRT_POW2];
1827 MATCH_MP_TAC SUM_POS_GEN;
1833 let D_EUCLID_BOUND = prove_by_refinement(
1834 `!n x y eps. ((euclid n x) /\ (euclid n y) /\
1835 (!i. (abs (x i -. y i) <=. eps))) ==>
1836 ( d_euclid x y <=. sqrt(&.n)*. eps )`,
1844 USE 0 (MATCH_MP d_euclid_pos);
1848 USE 4 (MATCH_MP (REAL_ARITH `abs (x) <=. eps ==> &.0 <=. eps`));
1851 REWRITE_TAC[REAL_MUL_NN];
1854 MATCH_MP_TAC SQRT_POS_LE ;
1858 ASM_SIMP_TAC[d_euclid_pow2];
1859 SUBGOAL_TAC `!i. ((x:num->real) i -. y i) *. (x i -. y i) <=. eps* eps`;
1862 USE 2 (SPEC `i:num`);
1863 ABBREV_TAC `t = x i - (y:num->real) i`;
1865 REWRITE_TAC[ABS_SQUARE_LE];
1866 REWRITE_TAC[REAL_POW_MUL];
1867 ASSUME_TAC (REWRITE_RULE[] ((REDUCE_CONV `&.0 <= &.n`)));
1868 USE 6 (REWRITE_RULE[GSYM SQRT_POW2]);
1872 MATCH_MP_TAC SUM_BOUND;
1882 let metric_translate = prove_by_refinement(
1883 `!n x y z . (euclid n x) /\ (euclid n y) /\ (euclid n z) ==>
1884 (d_euclid (x + z) (y + z) = d_euclid x y)`,
1888 REWRITE_TAC[d_euclid;norm];
1890 TYPE_THEN `euclid n (euclid_minus x y)` SUBGOAL_TAC;
1891 ASM_SIMP_TAC[euclid_sub_closure];
1893 TYPE_THEN `euclid n (euclid_minus (euclid_plus x z) (euclid_plus y z))` SUBGOAL_TAC;
1894 ASM_SIMP_TAC[euclid_sub_closure; euclid_add_closure];
1896 ASM_SIMP_TAC[SPEC `n:num` dot_euclid];
1897 TYPE_THEN `(x + z) - (y + z) = ((x:num->real) - y)` SUBGOAL_TAC;
1898 IMATCH_MP_TAC EQ_EXT;
1900 REWRITE_TAC[euclid_minus;euclid_plus];
1902 DISCH_THEN (fun t-> REWRITE_TAC[t]);
1907 let metric_translate_LEFT = prove_by_refinement(
1908 `!n x y z . (euclid n x) /\ (euclid n y) /\ (euclid n z) ==>
1909 (d_euclid (z + x ) (z + y) = d_euclid x y)`,
1913 REWRITE_TAC[d_euclid;norm];
1915 TYPE_THEN `euclid n (euclid_minus x y)` SUBGOAL_TAC;
1916 ASM_SIMP_TAC[euclid_sub_closure];
1918 TYPE_THEN `euclid n (euclid_minus (euclid_plus z x) (euclid_plus z y))` SUBGOAL_TAC;
1919 ASM_SIMP_TAC[euclid_sub_closure; euclid_add_closure];
1921 ASM_SIMP_TAC[SPEC `n:num` dot_euclid];
1922 TYPE_THEN `(z + x) - (z + y) = ((x:num->real) - y)` SUBGOAL_TAC;
1923 IMATCH_MP_TAC EQ_EXT;
1925 REWRITE_TAC[euclid_minus;euclid_plus];
1927 DISCH_THEN (fun t-> REWRITE_TAC[t]);
1932 let norm_scale = prove_by_refinement(
1933 `!t t' x . (euclidean x) ==>
1934 (d_euclid (t *# x) (t' *# x) =
1935 ||. (t - t') * norm(x))`,
1939 REWRITE_TAC[euclidean];
1942 ASM_SIMP_TAC[d_euclid_n;norm_n;euclid_scale_closure;euclid_scale;GSYM REAL_SUB_RDISTRIB;REAL_MUL_AC;];
1943 REWRITE_TAC[GSYM REAL_POW_2 ];
1944 REWRITE_TAC[REAL_ARITH `a * a * b = b * (a * a)`;SUM_CMUL;];
1945 ASM_SIMP_TAC[SQRT_MUL;REAL_SUM_SQUARE_POS;REAL_LE_SQUARE_POW;POW_2_SQRT_ABS ];
1946 REWRITE_TAC[REAL_POW_2];
1951 let norm_scale_vec = prove_by_refinement(
1952 `!n t x x' . (euclid n x) /\ (euclid n x') ==>
1953 (d_euclid (t *# x) (t *# x') = ||. t * d_euclid x x')`,
1958 ASM_SIMP_TAC[d_euclid_n;norm_n;euclid_scale_closure;euclid_scale;GSYM REAL_SUB_LDISTRIB;REAL_MUL_AC;];
1959 REWRITE_TAC[REAL_ARITH `t*t*b = (t*t)*b`];
1960 REWRITE_TAC[GSYM REAL_POW_2 ;SUM_CMUL ];
1961 GEN_REWRITE_TAC (LAND_CONV o RAND_CONV o RAND_CONV o ONCE_DEPTH_CONV) [REAL_POW_2];
1962 ASM_SIMP_TAC[SQRT_MUL;REAL_SUM_SQUARE_POS;REAL_LE_SQUARE_POW;POW_2_SQRT_ABS ];
1963 REWRITE_TAC[REAL_POW_2];
1969 (* ------------------------------------------------------------------ *)
1970 (* Topological Spaces *)
1971 (* ------------------------------------------------------------------ *)
1975 (* underscore is necessary to avoid Harrison's global "topology" *)
1976 (* carrier of topology is UNIONS U *)
1978 let topology = euclid_def `topology_ (U:(A->bool)->bool) <=>
1979 (!A B V. (U EMPTY) /\
1980 ((U A) /\ (U B) ==> (U (A INTER B))) /\
1981 ((V SUBSET U) ==> (U (UNIONS V))))`;;
1983 let open_DEF = euclid_def `open_ (U:(A->bool)->bool) A = (U A)`;;
1985 let closed = euclid_def `closed_ (U:(A->bool)->bool) B <=>
1986 (B SUBSET (UNIONS U)) /\
1987 (open_ U ((UNIONS U) DIFF B))`;;
1989 let closure = euclid_def `closure (U:(A->bool)->bool) A =
1990 INTERS { B | (closed_ U B) /\ (A SUBSET B) }`;;
1992 let induced_top = euclid_def `induced_top U (A:A->bool) =
1993 IMAGE ( \B. (B INTER A)) U`;;
1995 let open_ball = euclid_def
1996 `open_ball(X,d) (x:A) r = { y | (X x) /\ (X y) /\ (d x y <. r) }`;;
1998 let closed_ball =euclid_def
1999 `closed_ball (X,d) (x:A) r = { y | (X x) /\ (X y) /\ (d x y <=. r) }`;;
2001 let open_balls = euclid_def
2002 `open_balls (X,d) = { B | ?(x:A) r. B = open_ball (X,d) x r}`;;
2004 let top_of_metric = euclid_def
2005 `top_of_metric ((X:A->bool),d) =
2006 { A | ?F. (F SUBSET (open_balls (X,d)))/\
2009 (* basic properties *)
2011 let open_EMPTY = prove_by_refinement(
2012 `!(U:(A->bool)->bool). (topology_ U ==> open_ U EMPTY)`,
2015 REWRITE_TAC[topology;open_DEF];
2020 let open_closed = prove_by_refinement(
2021 `!U A. (topology_ (U:(A->bool)->bool)) /\ (open_ U A) ==>
2022 (closed_ U ((UNIONS U) DIFF A))`,
2025 REWRITE_TAC[closed;open_DEF];
2027 SUBGOAL_THEN `(A:A->bool) SUBSET (UNIONS U)` ASSUME_TAC;
2028 ASM_MESON_TAC[sub_union];
2029 ASM_SIMP_TAC[DIFF_DIFF2];
2030 REWRITE_TAC[SUBSET_DIFF];
2034 let closed_UNIV = prove_by_refinement(
2035 `!(U:(A->bool)->bool). (topology_ U ==> closed_ U (UNIONS U))`,
2040 ASM_SIMP_TAC[open_closed];
2041 REWRITE_TAC[closed;open_DEF];
2042 TYPE_THEN `a = UNIONS U` ABBREV_TAC;
2043 USE 0 (REWRITE_RULE[topology]);
2046 USE 0 (CONV_RULE (quant_right_CONV "V"));
2047 USE 0 (CONV_RULE (quant_right_CONV "B"));
2048 USE 0 (CONV_RULE (quant_right_CONV "A"));
2051 MESON_TAC[DIFF_EQ_EMPTY];
2056 let top_univ = prove_by_refinement(
2057 `!(U:(A->bool)->bool). (topology_ U) ==> (U (UNIONS U))`,
2060 REWRITE_TAC[topology];
2062 ASM_MESON_TAC[SUBSET_REFL];
2066 let empty_closed = prove_by_refinement(
2067 `!(U:(A->bool)->bool).
2068 (topology_ U) ==> closed_ U EMPTY`,
2072 REWRITE_TAC[closed;EMPTY_SUBSET;DIFF_EMPTY;open_DEF];
2073 ASM_MESON_TAC[top_univ];
2077 let closed_open = prove_by_refinement(
2078 `!(U:(A->bool)->bool) A. (closed_ U A) ==>
2079 (open_ U ((UNIONS U) DIFF A))`,
2086 let closed_inter = prove_by_refinement (
2087 `!U V. (topology_ (U:(A->bool)->bool)) /\ (!a. (V a) ==> (closed_ U a))
2089 ==> (closed_ U (INTERS V))`,
2092 REWRITE_TAC[closed];
2095 MATCH_MP_TAC INTERS_SUBSET2;
2096 USE 2 (REWRITE_RULE[ EMPTY_EXISTS]);
2097 USE 2 (REWRITE_RULE[IN]);
2099 EXISTS_TAC `u:A->bool`;
2101 ABBREV_TAC `VCOMP = IMAGE ((DIFF) (UNIONS (U:(A->bool)->bool))) V`;
2102 UNDISCH_FIND_THEN `VCOMP` (fun t -> ASSUME_TAC (GSYM t));
2103 SUBGOAL_THEN `(VCOMP:(A->bool)->bool) SUBSET U` ASSUME_TAC;
2104 ASM_REWRITE_TAC[SUBSET;IN_ELIM_THM;IMAGE];
2107 ASM_MESON_TAC[open_DEF];
2108 SUBGOAL_THEN `open_ U (UNIONS (VCOMP:(A->bool)->bool))` ASSUME_TAC;
2109 ASM_MESON_TAC[topology;open_DEF];
2110 SUBGOAL_THEN ` (UNIONS U DIFF INTERS V)= (UNIONS (VCOMP:(A->bool)->bool))` (fun t-> (REWRITE_TAC[t]));
2111 ASM_REWRITE_TAC[UNIONS_INTERS];
2112 UNDISCH_FIND_TAC `(open_)`;
2117 let open_nbd = prove_by_refinement(
2118 `!U (A:A->bool). (topology_ U) ==>
2119 ((U A) = (!x. ?B. (A x ) ==> ((B SUBSET A) /\ (B x) /\ (U B))))`,
2126 EXISTS_TAC `A:A->bool`;
2127 ASM_MESON_TAC[SUBSET];
2128 CONV_TAC (quant_left_CONV "B");
2129 DISCH_THEN CHOOSE_TAC;
2130 USE 1 (CONV_RULE NAME_CONFLICT_CONV);
2131 TYPE_THEN `UNIONS (IMAGE B A) = A` SUBGOAL_TAC;
2132 MATCH_MP_TAC SUBSET_ANTISYM;
2134 MATCH_MP_TAC UNIONS_SUBSET;
2135 REWRITE_TAC[IN_IMAGE];
2137 REWRITE_TAC[SUBSET;IN_UNIONS;IN_IMAGE];
2140 CONV_TAC (quant_left_CONV "x'");
2141 CONV_TAC (quant_left_CONV "x'");
2143 TYPE_THEN `B x` EXISTS_TAC ;
2147 TYPE_THEN `(IMAGE B A) SUBSET U` SUBGOAL_TAC;
2148 REWRITE_TAC[SUBSET;IN_IMAGE;];
2152 DISCH_THEN CHOOSE_TAC;
2155 TYPE_THEN `W = IMAGE B A` ABBREV_TAC;
2157 ASM_MESON_TAC[topology];
2161 let open_inters = prove_by_refinement(
2162 `!U (V:(A->bool)->bool). (topology_ U) /\ (V SUBSET U) /\
2163 (FINITE V) /\ ~(V = EMPTY) ==>
2169 TYPE_THEN `(?n. V HAS_SIZE n)` SUBGOAL_TAC;
2170 REWRITE_TAC[HAS_SIZE];
2178 CONV_TAC (quant_left_CONV "n");
2179 TYPE_THEN `V` SPEC2_TAC ;
2180 TYPE_THEN `U` SPEC2_TAC ;
2181 CONV_TAC (quant_left_CONV "n");
2182 CONV_TAC (quant_left_CONV "n");
2185 ASM_MESON_TAC[HAS_SIZE_0];
2187 TYPE_THEN `U` (USE 0 o SPEC);
2188 USE 5 (REWRITE_RULE[HAS_SIZE_SUC;EMPTY_EXISTS]);
2191 TYPE_THEN `u` (USE 5 o SPEC);
2193 TYPE_THEN `V DELETE u` (USE 0 o SPEC);
2195 TYPE_THEN `V={u}` ASM_CASES_TAC;
2196 ASM_REWRITE_TAC[inters_singleton];
2199 REWRITE_TAC [SUBSET;IN];
2202 USE 0 (REWRITE_RULE[delete_empty]);
2204 USE 0 (REWRITE_RULE[FINITE_DELETE]);
2206 TYPE_THEN `V DELETE u SUBSET U ` SUBGOAL_TAC;
2207 ASM_MESON_TAC[DELETE_SUBSET;SUBSET_TRANS];
2212 USE 9 (REWRITE_RULE[IN]);
2213 USE 9 (MATCH_MP delete_inters);
2215 USE 1 (REWRITE_RULE[topology]);
2216 TYPEL_THEN [`(INTERS (V DELETE u))`;`u`;`U`] (USE 1 o ISPECL);
2220 DISCH_THEN MATCH_MP_TAC ;
2224 REWRITE_TAC [SUBSET;IN];
2229 let top_unions = prove_by_refinement(
2230 `!(U:(A->bool)->bool) V. topology_ U /\ (V SUBSET U) ==> U (UNIONS V)`,
2233 MESON_TAC[topology];
2237 let top_inter = prove_by_refinement(
2238 `!(U:(A->bool)-> bool) A B. topology_ U /\ (U A) /\ (U B) ==> (U (A INTER B))`,
2241 MESON_TAC[topology];
2246 (* open and closed balls in metric spaces *)
2248 let open_ball_nonempty = prove_by_refinement(
2249 `!(X:A->bool) d a r. (metric_space (X,d)) /\ (&.0 <. r) /\ (X a) ==>
2250 (a IN (open_ball(X,d) a r))`,
2253 REWRITE_TAC[metric_space;IN_ELIM_THM;open_ball];
2255 UNDISCH_FIND_THEN `( /\ )` (ASSUME_TAC o (SPECL [`a:A`;`a:A`;`a:A`]));
2260 let open_ball_subset = prove_by_refinement(
2261 `!(X:A->bool) d a r. (open_ball (X,d) a r SUBSET X)`,
2264 REWRITE_TAC[SUBSET;open_ball;IN_ELIM_THM];
2269 let open_ball_subspace = prove_by_refinement(
2270 `!(X:A->bool) Y d a r. (Y SUBSET X) ==>
2271 (open_ball(Y,d) a r SUBSET open_ball(X,d) a r)`,
2274 REWRITE_TAC[SUBSET;open_ball;IN_ELIM_THM];
2279 let open_ball_empty = prove_by_refinement(
2280 `!(X:A->bool) d a r. ~(a IN X) ==> (EMPTY = open_ball (X,d) a r)`,
2284 REWRITE_TAC[open_ball];
2285 MATCH_MP_TAC EQ_EXT;
2286 REWRITE_TAC[IN_ELIM_THM;EMPTY];
2291 (*** Old proof modified by JRH to avoid GSPEC
2293 let open_ball_intersect = prove_by_refinement(
2294 `!(X:A->bool) Y d a r. (Y SUBSET X) /\ (a IN Y) ==>
2295 (open_ball(Y,d) a r = (open_ball(X,d) a r INTER Y))`,
2298 REWRITE_TAC[SUBSET;IN;INTER;open_ball];
2299 REWRITE_TAC[GSPEC_THM];
2300 REWRITE_TAC[IN_ELIM_THM];
2303 MATCH_MP_TAC EQ_EXT;
2312 let open_ball_intersect = prove_by_refinement(
2313 `!(X:A->bool) Y d a r. (Y SUBSET X) /\ (a IN Y) ==>
2314 (open_ball(Y,d) a r = (open_ball(X,d) a r INTER Y))`,
2317 REWRITE_TAC[SUBSET;IN;INTER;open_ball];
2318 REWRITE_TAC[EXTENSION; IN_ELIM_THM];
2323 let open_ball_center = prove_by_refinement(
2324 `!(X:A->bool) d a b r. (metric_space (X,d)) /\
2325 (a IN (open_ball (X,d) b r)) ==>
2326 (?r'. (&.0 <. r') /\
2327 ((open_ball(X,d) a r') SUBSET (open_ball(X,d) b r)))`,
2330 REWRITE_TAC[metric_space;open_ball];
2332 EXISTS_TAC `r -. (d (a:A) (b:A))`;
2333 REWRITE_TAC[SUBSET;IN_ELIM_THM];
2334 UNDISCH_FIND_TAC `(IN)`;
2335 REWRITE_TAC[IN_ELIM_THM];
2338 REWRITE_TAC[REAL_ARITH `(&.0 < r -. s)= (s <. r)`];
2342 REWRITE_TAC[REAL_ARITH `(u <. v-.w) <=> (w +. u <. v)`];
2345 UNDISCH_FIND_TAC `(!)`;
2346 DISCH_THEN (fun t-> (MP_TAC (SPECL [`b:A`;`a:A`;`x:A`] t)));
2348 ASM_MESON_TAC[REAL_LET_TRANS;REAL_LTE_TRANS];
2352 let open_ball_nonempty_center = prove_by_refinement(
2353 `!(X:A->bool) d a r. (metric_space(X,d)) ==>
2354 ((a IN (open_ball(X,d) a r)) =
2355 ~(open_ball(X,d) a r = EMPTY))`,
2358 REWRITE_TAC[metric_space];
2360 REWRITE_TAC[open_ball];
2361 REWRITE_TAC[REWRITE_CONV[IN_ELIM_THM] `(a:A) IN { y | X a /\ X y /\ (d a y <. r)}`];
2362 REWRITE_TAC[EXTENSION];
2363 REWRITE_TAC[IN_ELIM_THM;NOT_IN_EMPTY;NOT_FORALL_THM];
2366 DISCH_THEN CHOOSE_TAC;
2368 FIRST_ASSUM (fun t -> MP_TAC (SPECL [`a:A`;`x:A`;`a:A`] t));
2369 UNDISCH_FIND_THEN `(+.)` (fun t -> MP_TAC (SPECL [`a:A`;`a:A`;`a:A`] t));
2370 ASM_MESON_TAC[REAL_LET_TRANS;REAL_LTE_TRANS];
2374 (*** Old proof modified by JRH to remove apparent misnamed quantifier
2376 let open_ball_neg_radius = prove_by_refinement(
2377 `!(X:A->bool) d a r. metric_space(X,d) /\ (r <. (&.0)) ==>
2378 (EMPTY = open_ball(X,d) a r)`,
2381 REWRITE_TAC[open_ball;metric_space];
2383 MATCH_MP_TAC EQ_EXT;
2385 REWRITE_TAC[EMPTY;IN_ELIM_THM];
2386 FIRST_ASSUM (fun t -> MP_TAC (SPECL [`a:A`;`x:A`;`a:A`] t));
2387 ASSUME_TAC (REAL_ARITH `!u r. ~((dd <. r) /\ (r <. (&.0)) /\ (&.0 <=. dd))`);
2394 let open_ball_neg_radius = prove_by_refinement(
2395 `!(X:A->bool) d a r. metric_space(X,d) /\ (r <. (&.0)) ==>
2396 (EMPTY = open_ball(X,d) a r)`,
2399 REWRITE_TAC[open_ball;metric_space];
2401 MATCH_MP_TAC EQ_EXT;
2403 REWRITE_TAC[EMPTY;IN_ELIM_THM];
2404 FIRST_ASSUM (fun t -> MP_TAC (SPECL [`a:A`;`x:A`;`a:A`] t));
2405 ASSUME_TAC (REAL_ARITH `!d r. ~((d <. r) /\ (r <. (&.0)) /\ (&.0 <=. d))`);
2411 let open_ball_nest = prove_by_refinement(
2412 `!(X:A->bool) d a r r'. (r <. r') ==>
2413 ((open_ball (X,d) a r) SUBSET (open_ball(X,d) a r'))`,
2416 REWRITE_TAC[SUBSET;open_ball;IN_ELIM_THM];
2417 MESON_TAC[REAL_ARITH `(r<. r') /\ (a <. r) ==> (a <. r')`];
2421 (* intersection of open balls contains an open ball *)
2422 let open_ball_inter = prove_by_refinement(
2423 `!(X:A->bool) d a b c r r'. (metric_space (X,d)) /\ (X a) /\ (X b) /\
2424 (c IN (open_ball(X,d) a r INTER (open_ball(X,d) b r'))) ==>
2425 (?r''. (&.0 <. r'') /\ (open_ball(X,d) c r'') SUBSET
2426 (open_ball(X,d) a r INTER (open_ball(X,d) b r')))`,
2430 UNDISCH_FIND_THEN `(INTER)` (fun t-> MP_TAC (REWRITE_RULE[IN_INTER] t) THEN DISCH_ALL_TAC);
2431 SUBGOAL_TAC `(X:A->bool) (c:A)`;
2432 ASM_MESON_TAC[SUBSET;open_ball_subset;IN];
2434 MP_TAC (SPECL[`X:A->bool`;`d:A->A->real`;`c:A`;`b:A`;`r':real`] open_ball_center) THEN (ASM_REWRITE_TAC[]) THEN (DISCH_THEN CHOOSE_TAC);
2435 MP_TAC (SPECL[`X:A->bool`;`d:A->A->real`;`c:A`;`a:A`;`r:real`] open_ball_center) THEN (ASM_REWRITE_TAC[]) THEN (DISCH_THEN CHOOSE_TAC);
2436 REWRITE_TAC[SUBSET_INTER];
2437 EXISTS_TAC `(if (r'' <. r''') then (r'') else (r'''))`;
2439 ASM_MESON_TAC[open_ball_nest;SUBSET_TRANS];
2440 IMP_RES_THEN DISJ_CASES_TAC (REAL_ARITH `(~(r'' <. r''')) ==> ((r''' <. r'') \/ (r'''=r''))`);
2441 ASM_MESON_TAC[open_ball_nest;SUBSET_TRANS];
2446 let BALL_DIST = prove_by_refinement(
2447 `!X d x y (z:A) r. metric_space(X,d) /\ open_ball(X,d) z r x /\
2448 open_ball(X,d) z r y ==> d x y <. (&.2 * r)`,
2451 REWRITE_TAC[metric_space;open_ball;IN_ELIM_THM'];
2453 USE 0 (SPECL [`x:A`;`z:A`;`y:A`]);
2455 UND 0 THEN DISCH_ALL_TAC;
2464 let BALL_DIST_CLOSED = prove_by_refinement(
2465 `!X d x y (z:A) r. metric_space(X,d) /\ closed_ball(X,d) z r x /\
2466 closed_ball(X,d) z r y ==> d x y <=. (&.2 * r)`,
2470 REWRITE_TAC[metric_space;closed_ball;IN_ELIM_THM'];
2472 USE 0 (SPECL [`x:A`;`z:A`;`y:A`]);
2474 UND 0 THEN DISCH_ALL_TAC;
2485 let open_ball_sub_closed = prove_by_refinement(
2487 (open_ball(X,d) x r SUBSET (closed_ball(X,d) x r))`,
2492 REWRITE_TAC[SUBSET;IN;open_ball;closed_ball;IN_ELIM_THM'];
2501 let ball_symm = prove_by_refinement(
2502 `!X d (x:A) y r. metric_space(X,d) /\ (X x) /\ (X y) ==>
2503 (open_ball(X,d) x r y = open_ball(X,d) y r x)`,
2507 REWRITE_TAC [open_ball;IN_ELIM_THM'];
2509 ASM_MESON_TAC [metric_space_symm];
2513 let ball_subset_ball = prove_by_refinement(
2514 `!X d (x:A) z r. metric_space(X,d) /\
2515 (open_ball(X,d) x r z ) ==>
2516 (open_ball(X,d) z r SUBSET (open_ball(X,d) x (&.2 * r)))`,
2520 REWRITE_TAC[SUBSET;IN];
2522 REWRITE_TAC[open_ball;IN_ELIM_THM'];
2523 TYPE_THEN `X z /\ X x' /\ X x` SUBGOAL_TAC ;
2526 REWRITE_TAC[open_ball;IN_ELIM_THM'];
2529 TYPE_THEN `open_ball(X,d) z r x` SUBGOAL_TAC;
2530 ASM_MESON_TAC[ball_symm];
2531 ASM_MESON_TAC[BALL_DIST];
2538 let top_of_metric_unions = prove_by_refinement(
2539 `!(X:A->bool) d. (metric_space (X,d)) ==>
2540 (X = UNIONS (top_of_metric (X,d)))`,
2545 MATCH_MP_TAC SUBSET_ANTISYM THEN CONJ_TAC;
2546 REWRITE_TAC[SUBSET];
2547 REWRITE_TAC[IN_UNIONS;top_of_metric];
2549 EXISTS_TAC `open_ball(X,d) (x:A) (&.1)`;
2550 UNDISCH_TAC `(x:A) IN X` THEN (REWRITE_TAC[IN_ELIM_THM]);
2553 EXISTS_TAC `{(open_ball(X,d) (x:A) (&.1))}`;
2554 REWRITE_TAC[GSYM UNIONS_1;INSERT_SUBSET;EMPTY_SUBSET];
2555 REWRITE_TAC[open_balls;IN_ELIM_THM];
2557 REWRITE_TAC[IN_ELIM_THM;open_ball];
2558 UNDISCH_FIND_TAC `(IN)`;
2559 ASM_REWRITE_TAC[IN];
2562 UNDISCH_FIND_TAC `metric_space`;
2563 REWRITE_TAC[metric_space];
2564 DISCH_THEN (fun t -> MP_TAC (ISPECL [`x:A`;`x:A`;`x:A`] t));
2565 ASM_MESON_TAC[REAL_ARITH `(&.0) <. (&.1)`];
2566 MATCH_MP_TAC UNIONS_SUBSET;
2568 REWRITE_TAC[top_of_metric;IN_ELIM_THM];
2569 DISCH_THEN CHOOSE_TAC;
2571 MATCH_MP_TAC UNIONS_SUBSET;
2572 X_GEN_TAC `B:A->bool`;
2574 SUBGOAL_TAC `(B:A->bool) IN open_balls (X,d)`;
2576 REWRITE_TAC[open_balls;IN_ELIM_THM];
2577 DISCH_THEN (CHOOSE_THEN MP_TAC);
2578 DISCH_THEN (CHOOSE_THEN ASSUME_TAC);
2580 REWRITE_TAC[open_ball;SUBSET;IN_ELIM_THM];
2585 let top_of_metric_empty = prove_by_refinement(
2587 ( (top_of_metric (X,d)) EMPTY)`,
2590 REWRITE_TAC[top_of_metric];
2592 REWRITE_TAC[IN_ELIM_THM];
2593 EXISTS_TAC `EMPTY:(A->bool)->bool`;
2594 REWRITE_TAC[UNIONS_0;EMPTY_SUBSET];
2598 let top_of_metric_open = prove_by_refinement(
2600 (F SUBSET (open_balls (X,d))) ==>
2601 ((UNIONS F) IN (top_of_metric(X,d)))`,
2604 REWRITE_TAC[top_of_metric;IN_ELIM_THM];
2609 let top_of_metric_open_balls = prove_by_refinement(
2611 (open_balls (X,d)) SUBSET (top_of_metric(X,d))`,
2614 REWRITE_TAC[SUBSET];
2615 REWRITE_TAC[top_of_metric;IN_ELIM_THM];
2617 EXISTS_TAC `{(x:A->bool)}`;
2622 let open_ball_open = prove_by_refinement(
2623 `! (X:A->bool) d x r. (metric_space(X,d)) ==>
2624 (top_of_metric (X,d) (open_ball (X,d) x r)) `,
2628 TYPEL_THEN [`X`;`d`] (fun t-> ASSUME_TAC ( ISPECL t top_of_metric_open_balls));
2629 USE 1 (REWRITE_RULE[open_balls;SUBSET;IN_ELIM_THM']);
2634 (* a set is open then every point contains a ball *)
2635 let top_of_metric_nbd = prove_by_refinement(
2636 `!(X:A->bool) d A. (metric_space (X,d)) ==>
2637 ((top_of_metric (X,d) A) <=> ((A SUBSET X) /\
2639 (?r. (&.0 <. r) /\ (open_ball(X,d) a r SUBSET A)))))`,
2645 REWRITE_TAC[top_of_metric;IN_ELIM_THM];
2646 DISCH_THEN (CHOOSE_THEN MP_TAC);
2649 IMP_RES_THEN ASSUME_TAC top_of_metric_unions;
2651 IMP_RES_THEN ASSUME_TAC top_of_metric_open;
2652 ASM ONCE_REWRITE_TAC[];
2653 MATCH_MP_TAC UNIONS_UNIONS;
2654 ASM_MESON_TAC[SUBSET_TRANS;top_of_metric_open_balls];
2655 DISCH_ALL_TAC THEN (ASM_REWRITE_TAC[]);
2656 REWRITE_TAC[IN_UNIONS;UNIONS_SUBSET];
2657 UNDISCH_FIND_TAC `(IN)`;
2659 REWRITE_TAC[IN_UNIONS];
2660 DISCH_THEN (CHOOSE_THEN ASSUME_TAC);
2661 SUBGOAL_TAC `(t IN open_balls (X:A->bool,d))`;
2662 ASM_MESON_TAC[SUBSET];
2663 REWRITE_TAC[open_balls;IN_ELIM_THM];
2664 REPEAT (DISCH_THEN (CHOOSE_THEN MP_TAC));
2666 MP_TAC (SPECL[`(X:A->bool)`; `d:A->A->real`;`a:A`;`x:A`;`r:real`] open_ball_center);
2668 SUBGOAL_TAC `(a:A) IN open_ball(X,d) x r`;
2670 DISCH_TAC THEN (ASM_REWRITE_TAC[]);
2671 DISCH_THEN CHOOSE_TAC;
2672 EXISTS_TAC `r':real`;
2675 SUBGOAL_TAC `!s. ((s:A->bool) IN F') ==> (s SUBSET (UNIONS F'))`;
2677 ASM_MESON_TAC[SUBSET_TRANS] ; (*second direction: *)
2678 DISCH_THEN (fun t -> ASSUME_TAC (CONJUNCT1 t) THEN MP_TAC (CONJUNCT2 t));
2679 DISCH_THEN (fun t -> MP_TAC (REWRITE_RULE[RIGHT_IMP_EXISTS_THM] t));
2680 REWRITE_TAC[SKOLEM_THM];
2681 DISCH_THEN CHOOSE_TAC;
2682 REWRITE_TAC[top_of_metric;IN_ELIM_THM];
2683 EXISTS_TAC `IMAGE (\b. (open_ball(X,d) b (r b))) (A:A->bool)`;
2685 REWRITE_TAC[IMAGE;SUBSET];
2686 REWRITE_TAC[IN_ELIM_THM;open_balls];
2689 GEN_REWRITE_TAC I [EXTENSION];
2691 REWRITE_TAC[IN_UNIONS];
2692 REWRITE_TAC[IN_ELIM_THM];
2695 EXISTS_TAC `open_ball (X,d) (a:A) (r a)`;
2699 REWRITE_TAC[IN;open_ball];
2700 REWRITE_TAC[IN_ELIM_THM];
2701 ASM_MESON_TAC[metric_space_zero;IN;SUBSET]; (* last: *)
2702 DISCH_THEN (CHOOSE_THEN MP_TAC);
2704 UNDISCH_FIND_TAC `(?)` ;
2705 DISCH_THEN (CHOOSE_THEN MP_TAC);
2707 UNDISCH_FIND_TAC `(!)`;
2708 DISCH_THEN (fun t -> MP_TAC(SPEC `x:A` t));
2711 ASM_MESON_TAC[SUBSET;IN];
2716 let top_of_metric_inter = prove_by_refinement(
2717 `!(X:A->bool) d. (metric_space (X,d)) ==>
2718 (!A B. (top_of_metric (X,d) A) /\ (top_of_metric (X,d) B) ==>
2719 (top_of_metric (X,d) (A INTER B)))`,
2724 IMP_RES_THEN ASSUME_TAC (SPECL [`X:A->bool`;`d:A->A->real`] top_of_metric_nbd);
2725 UNDISCH_TAC `(top_of_metric (X,d) (B:A->bool))`;
2726 UNDISCH_TAC `(top_of_metric (X,d) (A:A->bool))`;
2733 UNDISCH_FIND_THEN `(INTER)` (fun t-> (MP_TAC (REWRITE_RULE[IN_INTER]t)) THEN DISCH_ALL_TAC );
2734 UNDISCH_FIND_THEN `(IN)` (fun t-> ANTE_RES_THEN MP_TAC t);
2735 UNDISCH_FIND_THEN `(IN)` (fun t-> ANTE_RES_THEN MP_TAC t);
2736 DISCH_THEN CHOOSE_TAC;
2737 DISCH_THEN CHOOSE_TAC;
2738 EXISTS_TAC `if (r<. r') then r else r'`;
2740 ASM_REWRITE_TAC[SUBSET_INTER];
2741 ASM_MESON_TAC[open_ball_nest;SUBSET_TRANS];
2742 MP_TAC (ARITH_RULE `~(r<.r') ==> ((r'<. r) \/ (r'=r))`) THEN (ASM_REWRITE_TAC[]);
2743 DISCH_THEN DISJ_CASES_TAC;
2744 ASM_REWRITE_TAC[SUBSET_INTER];
2745 ASM_MESON_TAC[open_ball_nest;SUBSET_TRANS];
2746 ASM_MESON_TAC[SUBSET_INTER];
2750 let top_of_metric_union = prove_by_refinement(
2751 `!(X:A->bool) d. (metric_space(X,d)) ==>
2752 (!V. (V SUBSET top_of_metric(X,d)) ==>
2753 (top_of_metric(X,d) (UNIONS V)))`,
2757 MP_TAC (SPECL[`X:A->bool`;`d:A->A->real`] top_of_metric_nbd);
2759 DISCH_THEN (fun t-> REWRITE_TAC[t]);
2762 ASM_MESON_TAC[UNIONS_UNIONS;top_of_metric_unions];
2764 REWRITE_TAC[IN_UNIONS];
2765 DISCH_THEN (CHOOSE_THEN MP_TAC);
2767 SUBGOAL_TAC `(top_of_metric (X,d)) (t:A->bool)`;
2768 ASM_MESON_TAC[IN;SUBSET];
2769 MP_TAC (SPECL[`X:A->bool`;`d:A->A->real`] top_of_metric_nbd);
2774 UNDISCH_FIND_THEN `(!)` (fun t -> MP_TAC (SPEC `a:A` t));
2776 DISCH_THEN CHOOSE_TAC;
2777 EXISTS_TAC `r:real`;
2779 ASM SET_TAC[UNIONS];
2783 let top_of_metric_top = prove_by_refinement(
2784 `!(X:A->bool) d. ( (metric_space (X,d))) ==>
2785 (topology_ (top_of_metric (X,d)))`,
2789 REWRITE_TAC[topology];
2791 ASM_SIMP_TAC[top_of_metric_empty;top_of_metric_inter;top_of_metric_union];
2795 let closed_ball_closed = prove_by_refinement(
2796 `!X d (x:A) r. (metric_space (X,d)) ==>
2797 (closed_ (top_of_metric(X,d)) (closed_ball(X,d) x r))`,
2801 TYPE_THEN `X x` ASM_CASES_TAC ;
2802 REWRITE_TAC[closed];
2803 ASM_SIMP_TAC [GSYM top_of_metric_unions];
2805 REWRITE_TAC[closed_ball;SUBSET;IN;IN_ELIM_THM'];
2808 REWRITE_TAC[open_DEF];
2810 USE 0 (MATCH_MP top_of_metric_top);
2811 ONCE_ASM_SIMP_TAC[open_nbd];
2813 TYPE_THEN `open_ball(X,d) x' (d x x' -. r)` EXISTS_TAC;
2814 TYPE_THEN `R = (d x x' -. r)` ABBREV_TAC;
2816 TYPE_THEN `X x'` SUBGOAL_TAC;
2817 USE 5 (REWRITE_RULE[INR IN_DIFF]);
2821 REWRITE_TAC[DIFF_SUBSET;open_ball_subset;INTER;EQ_EMPTY;IN_ELIM_THM'];
2824 ASM_REWRITE_TAC[open_ball;closed_ball];
2825 REWRITE_TAC[IN_ELIM_THM';GSYM CONJ_ASSOC];
2827 USE 7 (REWRITE_RULE[]);
2831 USE 3 (REWRITE_RULE[metric_space]);
2832 TYPEL_THEN [`x`;`y`;`x'`] (USE 3 o SPECL);
2834 ALL_TAC; (* "bb"; *)
2835 TYPE_THEN `d x' y = d y x'` SUBGOAL_TAC;
2836 TYPEL_THEN [`X`;`d`] (fun t-> MATCH_MP_TAC (SPECL t metric_space_symm));
2848 ALL_TAC; (* "cbc" *)
2850 ASM_SIMP_TAC [open_ball_open];
2851 MATCH_MP_TAC (INR open_ball_nonempty);
2855 USE 8 (MATCH_MP (REAL_ARITH `~(&.0 < d x x' - r) ==> (d x x' <=. r)`));
2856 USE 5 (REWRITE_RULE[INR IN_DIFF;closed_ball;IN_ELIM_THM']);
2858 TYPE_THEN `(closed_ball (X,d) x r) = EMPTY` SUBGOAL_TAC;
2859 (**** Old step changed by JRH for modified set comprehensions
2860 ASM_REWRITE_TAC[closed_ball;EMPTY;GSPEC];
2862 ASM_REWRITE_TAC[closed_ball;IN_ELIM_THM; EXTENSION; NOT_IN_EMPTY];
2863 DISCH_THEN (REWRT_TAC);
2864 ALL_TAC; (* "cbc1" *)
2865 ASM_MESON_TAC[empty_closed;top_of_metric_top];
2869 let open_ball_nbd = prove_by_refinement(
2870 `!X d C x. ?e. (metric_space((X:A->bool),d)) /\ (C x) /\
2871 (top_of_metric (X,d) C) ==>
2872 ((&.0 < e) /\ (open_ball (X,d) x e SUBSET C))`,
2879 USE 2 (REWRITE_RULE[top_of_metric;open_balls;IN_ELIM_THM';SUBSET;IN ]);
2884 USE 1 (REWRITE_RULE[UNIONS;IN;IN_ELIM_THM' ]);
2886 TYPE_THEN `u` (USE 3 o SPEC);
2891 TYPEL_THEN [`X`;`d`;`x`;`x'`;`r`] (fun t-> (ASSUME_TAC (ISPECL t open_ball_center)));
2892 USE 4 (REWRITE_RULE[IN ]);
2895 TYPE_THEN `r'` EXISTS_TAC;
2897 REWRITE_TAC[SUBSET;UNIONS;IN;IN_ELIM_THM'];
2900 USE 4 (REWRITE_RULE[SUBSET;IN;IN_ELIM_THM']);
2909 let closure_closed = prove_by_refinement(
2910 `!U (A:A->bool). (topology_ U) /\ (A SUBSET (UNIONS U)) ==>
2911 (closed_ U (closure U A))`,
2915 REWRITE_TAC[closure];
2916 MATCH_MP_TAC closed_inter;
2917 REWRITE_TAC[IN_ELIM_THM];
2921 REWRITE_TAC[EMPTY_EXISTS];
2922 TYPE_THEN `UNIONS U` EXISTS_TAC;
2923 ASM_REWRITE_TAC[IN_ELIM_THM'];
2924 ASM_SIMP_TAC[closed_UNIV];
2928 let subset_closure = prove_by_refinement(
2929 `!U (A:A->bool). (topology_ U) ==> (A SUBSET (closure U A))`,
2933 REWRITE_TAC[closure;SUBSET;IN_INTERS;IN_ELIM_THM];
2939 let closure_subset = prove_by_refinement(
2940 `!U (A:A->bool) B. (topology_ U) /\ (closed_ U B) /\ (A SUBSET B)
2941 ==> (closure U A SUBSET B)`,
2944 REWRITE_TAC[closure];
2946 MATCH_MP_TAC INTERS_SUBSET;
2947 ASM_REWRITE_TAC[IN_ELIM_THM];
2951 let closure_self = prove_by_refinement(
2952 `!U (A:A->bool). (topology_ U) /\ (closed_ U A) ==>
2957 MATCH_MP_TAC SUBSET_ANTISYM;
2958 ASM_SIMP_TAC[subset_closure];
2959 ASM_SIMP_TAC[closure_subset;SUBSET_REFL];
2963 let closure_close = prove_by_refinement(
2964 `!U Z (A:A->bool). (topology_ U) /\ (Z SUBSET (UNIONS U)) ==>
2965 ((A = closure U Z) = ((Z SUBSET A) /\ (closed_ U A) /\
2966 (!B. (closed_ U B) /\ ((Z SUBSET B)) ==>
2972 DISCH_THEN (REWRT_TAC);
2973 ASM_SIMP_TAC[subset_closure;closure_closed;closure_subset];
2975 REWRITE_TAC [closure];
2976 MATCH_MP_TAC (SUBSET_ANTISYM);
2978 REWRITE_TAC[SUBSET_INTERS];
2979 REWRITE_TAC[IN_ELIM_THM'];
2981 MATCH_MP_TAC INTERS_SUBSET;
2982 REWRITE_TAC[IN_ELIM_THM'];
2987 let closure_open = prove_by_refinement(
2988 `!U Z (A:A->bool). (topology_ U) /\ (Z SUBSET (UNIONS U)) ==>
2989 ((A = closure U Z) = ((Z SUBSET A) /\ (closed_ U A) /\
2990 (!B. (open_ U B) /\ ((B INTER Z) = EMPTY) ==>
2991 ((B INTER A) = EMPTY))))`,
2997 ASM_SIMP_TAC[closure_close];
2998 MATCH_MP_TAC (TAUT `( A ==> (B <=> C)) ==> (A /\ B <=> A /\ C)`);
3000 MATCH_MP_TAC (TAUT `( A ==> (B <=> C)) ==> (A /\ B <=> A /\ C)`);
3004 USE 2 (REWRITE_RULE[closed]);
3007 USE 3 (SPEC `(UNIONS U) DIFF (B:A->bool)`);
3010 ASM_SIMP_TAC[open_closed];
3011 ASM_REWRITE_TAC[DIFF_SUBSET];
3015 REWRITE_TAC[INTER_COMM];
3019 USE 3 (SPEC `(UNIONS U) DIFF (B:A->bool)`);
3021 ASM_SIMP_TAC[closed_open];
3022 REWRITE_TAC[DIFF_INTER];
3023 ASM_SIMP_TAC[SUB_IMP_INTER];
3024 TYPE_THEN `A SUBSET (UNIONS U INTER A)` SUBGOAL_TAC;
3025 USE 2 (REWRITE_RULE[closed]);
3029 SET_TAC[SUBSET;INTER];
3030 MESON_TAC [SUBSET_TRANS];
3036 (* induced topology *)
3038 let image_top = prove_by_refinement(
3039 `!(U:(A->bool)->bool) (f:(A->bool)->(B->bool)).
3040 ((topology_ U) /\ (EMPTY = f EMPTY) /\
3041 (!a b. (a IN U) /\ (b IN U) ==>
3042 (((f a) INTER (f b)) = f (a INTER b))) /\
3043 (!V. (V SUBSET U) ==> (UNIONS (IMAGE f V) =f (UNIONS V) )))
3044 ==> (topology_ (IMAGE f U))`,
3048 REWRITE_TAC[topology];
3052 REWRITE_TAC[IMAGE;IN];
3053 REWRITE_TAC[IN_ELIM_THM];
3056 REWRITE_TAC[IMAGE;IN];
3057 REWRITE_TAC[IN_ELIM_THM];
3059 REPEAT (UNDISCH_FIND_THEN `(?)` CHOOSE_TAC);
3061 EXISTS_TAC `(x:A->bool) INTER x'`;
3063 DISCH_THEN (fun t-> MP_TAC (MATCH_MP SUBSET_PREIMAGE t));
3064 DISCH_THEN CHOOSE_TAC;
3067 REWRITE_TAC[IMAGE;IN_ELIM_THM];
3068 EXISTS_TAC `UNIONS (Z:(A->bool)->bool)`;
3074 let induced_top_support = prove_by_refinement(
3075 `!U (C:A->bool). (UNIONS (induced_top U C) = ((UNIONS U) INTER C))`,
3078 REWRITE_TAC[UNIONS_INTER];
3081 REWRITE_TAC[induced_top];
3084 MATCH_MP_TAC EQ_EXT THEN BETA_TAC;
3089 let induced_top_top = prove_by_refinement(
3090 `!U (C:A->bool). (topology_ U) ==> (topology_ (induced_top U C))`,
3095 REWRITE_TAC[induced_top];
3096 MATCH_MP_TAC image_top;
3102 REWRITE_TAC[UNIONS_INTER];
3107 MATCH_MP_TAC EQ_EXT THEN BETA_TAC;
3112 let induced_top_open = prove_by_refinement(
3113 `!U (C:A->bool) A. (topology_ U) ==> (induced_top U C A =
3114 (?B. (U B) /\ ((B INTER C) = A)))`,
3118 REWRITE_TAC[induced_top;IMAGE];
3119 REWRITE_TAC[IN_ELIM_THM];
3124 let induced_trans = prove_by_refinement(
3125 `! U (A:A->bool) B. (topology_ U) /\ U A /\ (induced_top U A B) ==>
3129 REWRITE_TAC[induced_top;IMAGE;IN ;IN_ELIM_THM' ];
3132 ASM_MESON_TAC[top_inter];
3136 let induced_top_unions = prove_by_refinement(
3137 `!(U:(A->bool)->bool). (topology_ U) ==>
3138 ((induced_top U (UNIONS U)) = U)`,
3143 IMATCH_MP_TAC EQ_EXT;
3145 ASM_SIMP_TAC[induced_top_open];
3149 USE 0 (REWRITE_RULE[topology]);
3150 TYPE_THEN `B SUBSET (UNIONS U)` SUBGOAL_TAC;
3151 ASM_MESON_TAC[sub_union ];
3152 REWRITE_TAC[SUBSET_INTER_ABSORPTION];
3156 TYPE_THEN `x` EXISTS_TAC;
3158 TYPE_THEN `x SUBSET (UNIONS U)` SUBGOAL_TAC;
3159 ASM_MESON_TAC[sub_union ];
3160 REWRITE_TAC[SUBSET_INTER_ABSORPTION];
3165 (* induced metric *)
3167 let gen = euclid_def `gen (X:(A->bool)->bool)
3168 = {A | ?Y. (Y SUBSET X) /\ (A = UNIONS Y)}`;;
3170 let top_of_metric_gen = prove_by_refinement(
3171 `!(X:(A)->bool) d. gen (open_balls(X,d))= (top_of_metric(X,d))`,
3174 REWRITE_TAC[gen;top_of_metric];
3178 let gen_subset = prove_by_refinement(
3179 `!U (V:(A->bool)->bool). (U SUBSET V) /\
3180 (!A. (A IN V) ==> (?Y. (Y SUBSET U) /\ (A = UNIONS Y)))
3181 ==> (gen U = (gen V))`,
3185 REWRITE_TAC[EXTENSION];
3186 GEN_TAC THEN EQ_TAC;
3187 REWRITE_TAC[IN_ELIM_THM;gen];
3188 DISCH_THEN CHOOSE_TAC;
3189 ASM_MESON_TAC[SUBSET_TRANS];
3190 REWRITE_TAC[IN_ELIM_THM;gen];
3191 DISCH_THEN CHOOSE_TAC;
3192 UNDISCH_FIND_THEN `(?)` (fun t-> MP_TAC(REWRITE_RULE[RIGHT_IMP_EXISTS_THM;SKOLEM_THM]t));
3193 DISCH_THEN CHOOSE_TAC;
3194 EXISTS_TAC `UNIONS (IMAGE (Y':(A->bool)->((A->bool)->bool)) (Y:(A->bool)->bool))`;
3196 MATCH_MP_TAC UNIONS_SUBSET;
3197 REWRITE_TAC[IN_IMAGE];
3199 DISCH_THEN CHOOSE_TAC;
3200 ASM_MESON_TAC[IN;SUBSET];
3202 REWRITE_TAC[UNIONS_IMAGE_UNIONS];
3204 REWRITE_TAC[GSYM IMAGE_o];
3205 REWRITE_TAC[EXTENSION];
3206 X_GEN_TAC `A:(A->bool)`;
3207 REWRITE_TAC[IN_IMAGE;o_THM];
3208 ASM_MESON_TAC[SUBSET;IN];
3212 let gen_subspace = prove_by_refinement(
3213 `!(X:A->bool) Y d. (Y SUBSET X) /\ (metric_space(X,d)) ==>
3214 (induced_top (top_of_metric(X,d)) Y =
3215 gen (induced_top (open_balls(X,d)) Y))`,
3219 REWRITE_TAC[induced_top];
3220 REWRITE_TAC[EXTENSION];
3221 X_GEN_TAC `B:A->bool`;
3222 REWRITE_TAC[IN_IMAGE];
3224 DISCH_THEN (X_CHOOSE_TAC `C:A->bool`);
3226 REWRITE_TAC[top_of_metric];
3227 REWRITE_TAC[IN_ELIM_THM];
3229 UNDISCH_FIND_TAC `(?)`;
3230 DISCH_THEN (CHOOSE_TAC);
3231 UNDISCH_FIND_TAC `(INTER)`;
3232 ASM_REWRITE_TAC[UNIONS_INTER];
3233 REWRITE_TAC[gen;IN_ELIM_THM];
3234 EXISTS_TAC `IMAGE ((INTER) Y) (F':(A->bool)->bool)`;
3236 REWRITE_TAC[INTER_THM];
3237 MATCH_MP_TAC IMAGE_SUBSET;
3240 REWRITE_TAC[gen;IN_ELIM_THM];
3241 DISCH_THEN (CHOOSE_THEN MP_TAC);
3243 IMP_RES_THEN MP_TAC SUBSET_PREIMAGE;
3244 DISCH_THEN CHOOSE_TAC;
3245 EXISTS_TAC `UNIONS (Z:(A->bool)->bool)`;
3247 REWRITE_TAC[UNIONS_INTER];
3248 UNDISCH_FIND_THEN `(UNIONS)` (fun t -> REWRITE_TAC[t]);
3250 UNDISCH_FIND_TAC `(SUBSET)`;
3251 REWRITE_TAC[INTER_THM];
3253 REWRITE_TAC[top_of_metric;IN_ELIM_THM];
3258 let gen_induced = prove_by_refinement(
3259 `!(X:A->bool) Y d. (Y SUBSET X) /\ (metric_space (X,d)) ==>
3260 (gen (open_balls(Y,d)) = gen (induced_top (open_balls(X,d)) Y))`,
3264 MATCH_MP_TAC gen_subset;
3266 REWRITE_TAC[induced_top;SUBSET;open_balls];
3267 REWRITE_TAC [IN_IMAGE];
3268 X_GEN_TAC `A:(A->bool)`;
3269 REWRITE_TAC[IN_ELIM_THM];
3270 REPEAT (DISCH_THEN (CHOOSE_THEN MP_TAC));
3273 ASM_CASES_TAC `(Y:A->bool) (x:A)`;
3274 CONV_TAC (relabel_bound_conv);
3275 EXISTS_TAC `open_ball (X,d) (x:A) r`;
3277 MATCH_MP_TAC open_ball_intersect;
3280 EXISTS_TAC `open_ball (X,d) (x:A) (--. (&.1))`;
3282 ASM_MESON_TAC[IN;INTER_EMPTY;open_ball_empty;open_ball_neg_radius;REAL_ARITH `(--.(&.1) <. (&.0))`];
3283 MESON_TAC[]; (* end of first half *)
3284 REWRITE_TAC[induced_top;IN_IMAGE];
3286 DISCH_THEN (CHOOSE_THEN MP_TAC);
3288 REWRITE_TAC[IN;open_balls];
3289 REWRITE_TAC[IN_ELIM_THM'];
3293 FIRST_ASSUM (CHOOSE_THEN ASSUME_TAC);
3294 FIRST_ASSUM (CHOOSE_THEN ASSUME_TAC);
3295 SUBGOAL_TAC `!(a:A). (a IN x INTER Y) ==> (?r. ((&.0) <. r) /\ open_ball(Y,d) a r SUBSET (x INTER Y))`;
3297 TYPEL_THEN [`X`;`d`;`a`;`x'`;`r'`] (fun t -> (CLEAN_ASSUME_TAC (ISPECL t open_ball_center)));
3298 SUBGOAL_TAC `(a:A) IN open_ball(X,d) x' r'`;
3299 ASM_MESON_TAC[IN_INTER];
3300 DISCH_THEN (fun t -> ANTE_RES_THEN (MP_TAC) t);
3301 DISCH_THEN (CHOOSE_TAC);
3302 EXISTS_TAC `r'':real`;
3303 ASM_REWRITE_TAC[SUBSET_INTER;open_ball_subset];
3304 ASM_MESON_TAC[open_ball_subspace;SUBSET_TRANS];
3305 DISCH_THEN (fun t -> MP_TAC (REWRITE_RULE[RIGHT_IMP_EXISTS_THM;SKOLEM_THM] t));
3306 DISCH_THEN CHOOSE_TAC;
3307 EXISTS_TAC `IMAGE (\t. open_ball(Y,d) t (r t) ) ((x:A->bool) INTER Y)`;
3308 REWRITE_TAC[SUBSET_INTER];
3310 REWRITE_TAC[SUBSET;IN_ELIM_THM'];
3311 REWRITE_TAC[IN_IMAGE];
3314 MATCH_MP_TAC SUBSET_ANTISYM;
3316 REWRITE_TAC[SUBSET];
3318 REWRITE_TAC[IN_UNIONS];
3320 EXISTS_TAC `open_ball (Y,d) (x'':A) (r x'')`;
3321 REWRITE_TAC[IN_IMAGE];
3326 MATCH_MP_TAC open_ball_nonempty;
3327 ASM_SIMP_TAC[metric_subspace];
3328 ASM_MESON_TAC[IN_INTER;IN;metric_subspace];
3329 MATCH_MP_TAC UNIONS_SUBSET;
3331 REWRITE_TAC[IN_IMAGE];
3332 DISCH_THEN CHOOSE_TAC;
3337 let top_of_metric_induced = prove_by_refinement(
3338 `!(X:A->bool) Y d. (Y SUBSET X) /\ (metric_space(X,d)) ==>
3339 (induced_top (top_of_metric(X,d)) Y = (top_of_metric(Y,d)))`,
3342 SIMP_TAC[gen_subspace];
3344 REWRITE_TAC[GSYM top_of_metric_gen];
3345 MESON_TAC[gen_induced];
3349 (* ------------------------------------------------------------------ *)
3351 (* ------------------------------------------------------------------ *)
3354 let continuous = euclid_def `continuous (f:A->B) U V <=> !v.
3355 (v IN V) ==> (preimage (UNIONS U) f v) IN U`;;
3357 let metric_continuous_pt = euclid_def
3358 `metric_continuous_pt (f:A->B) (X,dX) ((Y:B->bool),dY) x =
3359 !epsilon. ?delta. (((&.0) < epsilon) ==> ((&.0) <. delta) /\
3360 (!y. ((x IN X) /\ (y IN X) /\ (dX x y) <. delta) ==>
3361 (dY (f x) (f y) <. epsilon)))`;;
3363 let metric_continuous = euclid_def
3364 `metric_continuous (f:A->B) (X,dX) (Y,dY) <=> !x.
3365 metric_continuous_pt f (X,dX) (Y,dY) x`;;
3367 let metric_continuous_pt_domain = prove_by_refinement(`!f X dX Y dY x .
3368 ~(x IN X) ==> (metric_continuous_pt (f:A->B) (X,dX) (Y,dY) x)`,
3372 REWRITE_TAC[metric_continuous_pt];
3378 let metric_continuous_continuous = prove_by_refinement(
3379 `!f X Y dX dY. (IMAGE f X SUBSET Y) /\ (metric_space(X,dX)) /\ (metric_space(Y,dY))
3381 (continuous (f:A->B) (top_of_metric(X,dX)) (top_of_metric(Y,dY))
3382 <=> (metric_continuous f (X,dX) (Y,dY)))`,
3387 REWRITE_TAC[continuous;metric_continuous];
3390 ASM_CASES_TAC `(x:A) IN X` THENL[ALL_TAC;ASM_SIMP_TAC[metric_continuous_pt_domain]];
3391 REWRITE_TAC[metric_continuous_pt];
3393 SUBGOAL_TAC `(open_ball (Y,dY) ((f:A->B) x) epsilon) IN (top_of_metric(Y,dY))`;
3394 MATCH_MP_TAC (prove_by_refinement(`!(x:A) B. (?A. (x IN A /\ A SUBSET B)) ==> (x IN B)`,[SET_TAC[]]));
3395 EXISTS_TAC `open_balls((Y:B->bool),dY)`;
3396 REWRITE_TAC[top_of_metric_open_balls];
3397 REWRITE_TAC[open_balls;IN_ELIM_THM'];
3399 DISCH_THEN (ANTE_RES_THEN ASSUME_TAC);
3400 REWRITE_TAC[GSYM RIGHT_IMP_EXISTS_THM];
3402 SUBGOAL_TAC `(x:A) IN preimage (UNIONS (top_of_metric (X,dX))) f (open_ball (Y,dY) ((f:A->B) x) epsilon)`;
3403 REWRITE_TAC[in_preimage];
3404 SUBGOAL_TAC `(Y:B->bool) ((f:A->B) x )`;
3405 UNDISCH_FIND_TAC `IMAGE`;
3406 UNDISCH_TAC `(x:A) IN X`;
3407 REWRITE_TAC[SUBSET;IMAGE];
3408 REWRITE_TAC[IN_ELIM_THM'];
3412 ASM_MESON_TAC[top_of_metric_unions;open_ball_nonempty];
3413 ABBREV_TAC `B = preimage (UNIONS (top_of_metric (X,dX))) (f:A->B) (open_ball (Y,dY) (f x) epsilon)`;
3415 SUBGOAL_TAC `?r. (&.0 <. r) /\ (open_ball(X,dX) (x:A) r SUBSET B)`;
3416 ASSUME_TAC top_of_metric_nbd;
3418 DISCH_THEN CHOOSE_TAC;
3419 EXISTS_TAC `r:real`;
3423 SUBGOAL_TAC `y:A IN B`;
3424 MATCH_MP_TAC (prove_by_refinement(`!(x:A) B. (?A. (x IN A /\ A SUBSET B)) ==> (x IN B)`,[SET_TAC[]]));
3425 EXISTS_TAC `open_ball(X,dX) (x:A) r`;
3427 REWRITE_TAC[open_ball;IN_ELIM_THM'];
3429 UNDISCH_FIND_TAC `preimage`;
3430 DISCH_THEN (fun t-> REWRITE_TAC[GSYM t]);
3431 REWRITE_TAC[in_preimage];
3432 REWRITE_TAC[open_ball;IN_ELIM_THM'];
3433 MESON_TAC[]; (* first half done *)
3434 REWRITE_TAC[metric_continuous];
3436 REWRITE_TAC[continuous];
3440 ASM_SIMP_TAC[top_of_metric_nbd];
3441 ASM_SIMP_TAC[GSYM top_of_metric_unions];
3443 REWRITE_TAC[SUBSET;in_preimage];
3446 DISCH_THEN (fun t -> ASSUME_TAC t THEN (MP_TAC (REWRITE_RULE[in_preimage] t)));
3448 SUBGOAL_TAC `?eps. (&.0 <. eps) /\ (open_ball(Y,dY) ((f:A->B) a) eps SUBSET v)`;
3449 UNDISCH_FIND_TAC `v IN top_of_metric (Y,dY)`;
3451 ASM_SIMP_TAC[top_of_metric_nbd];
3452 DISCH_THEN CHOOSE_TAC;
3453 FIRST_ASSUM (fun t -> MP_TAC (SPEC `a:A` t));
3454 REWRITE_TAC[metric_continuous_pt];
3455 DISCH_THEN (fun t-> MP_TAC (SPEC `eps:real` t));
3456 DISCH_THEN (CHOOSE_THEN MP_TAC);
3459 EXISTS_TAC `delta:real`;
3460 ASM_REWRITE_TAC[SUBSET];
3461 REWRITE_TAC[in_preimage;open_ball];
3462 REWRITE_TAC[IN_ELIM_THM'];
3465 CONJ_TAC THENL [(ASM_REWRITE_TAC[IN]);ALL_TAC];
3466 FIRST_ASSUM (fun t -> (MP_TAC (SPEC `y:A` t)));
3467 ASM_REWRITE_TAC[IN];
3468 UNDISCH_FIND_TAC `open_ball`;
3469 REWRITE_TAC[open_ball];
3470 DISCH_THEN (fun t -> (MP_TAC (CONJUNCT2 t)));
3471 REWRITE_TAC[SUBSET];
3472 DISCH_THEN (fun t-> (MP_TAC (SPEC `(f:A->B) y` t)));
3473 ASM_REWRITE_TAC[IN_ELIM_THM'];
3474 SUBGOAL_TAC `!x. (X x) ==> (Y ((f:A->B) x))`;
3475 UNDISCH_FIND_TAC `IMAGE`;
3476 REWRITE_TAC[SUBSET;IN_IMAGE];
3483 let continuous_induced = prove_by_refinement(
3484 `!(f:A->B) U V A. (topology_ V) /\ (continuous f U V) /\ (V A) ==>
3485 (continuous f U (induced_top V A)) `,
3488 REWRITE_TAC[continuous;induced_top;IN_IMAGE;Q_ELIM_THM'' ];
3489 ASM_MESON_TAC[top_inter;IN ];
3493 let metric_cont = prove_by_refinement(
3494 `!U X d f. (metric_space(X,d)) /\ (topology_ U) ==>
3495 ((continuous (f:A->B) U (top_of_metric(X,d))) =
3496 (!(x:B) r. U (preimage (UNIONS U) f (open_ball (X,d) x r))))`,
3503 USE 2 (REWRITE_RULE[continuous;IN]);
3504 UND 2 THEN (DISCH_THEN MATCH_MP_TAC );
3505 ASM_MESON_TAC [open_ball_open];
3506 REWRITE_TAC[continuous;IN];
3508 REWRITE_TAC[top_of_metric;IN_ELIM_THM' ];
3513 REWRITE_TAC[preimage_unions];
3514 IMATCH_MP_TAC top_unions ;
3515 ASM_REWRITE_TAC[IMAGE;SUBSET;IN;IN_ELIM_THM' ];
3517 REWRITE_TAC[Q_ELIM_THM'];
3518 USE 4 (REWRITE_RULE[SUBSET;IN]);
3520 TYPE_THEN `x'` (USE 4 o SPEC);
3522 USE 4 (REWRITE_RULE[open_balls;IN_ELIM_THM' ]);
3529 let continuous_sum = prove_by_refinement(
3530 `!U (f:A->(num->real)) g n. (topology_ U) /\
3531 (continuous f U (top_of_metric(euclid n,d_euclid))) /\
3532 (continuous g U (top_of_metric(euclid n,d_euclid))) /\
3533 (IMAGE f (UNIONS U) SUBSET (euclid n)) /\
3534 (IMAGE g (UNIONS U) SUBSET (euclid n)) ==>
3535 (continuous (\t. (f t + g t)) U (top_of_metric(euclid n,d_euclid)))`,
3538 ASSUME_TAC metric_euclid;
3540 ASM_SIMP_TAC[metric_cont];
3542 ONCE_ASM_SIMP_TAC[open_nbd];
3546 USE 6 (REWRITE_RULE[REWRITE_RULE[IN] in_preimage]);
3547 USE 2 (REWRITE_RULE[continuous]);
3548 USE 3 (REWRITE_RULE[continuous]);
3550 TYPE_THEN `n` (USE 0 o SPEC);
3553 USE 6 (MATCH_MP (REWRITE_RULE[IN] open_ball_center));
3556 TYPE_THEN `open_ball(euclid n,d_euclid) (f t) (r'/(&.2))` (USE 2 o SPEC);
3557 TYPE_THEN `open_ball(euclid n,d_euclid) (g t) (r'/(&.2))` (USE 3 o SPEC);
3561 ASM_SIMP_TAC[open_ball_open];
3563 TYPE_THEN `B = (preimage (UNIONS U) f (open_ball (euclid n,d_euclid) (f t) (r' / &2))) INTER (preimage (UNIONS U) g (open_ball (euclid n,d_euclid) (g t) (r' / &2)))` ABBREV_TAC ;
3564 TYPE_THEN `B` EXISTS_TAC;
3567 USE 6 (MATCH_MP preimage_subset );
3568 TYPEL_THEN [`(\t. euclid_plus (f t) (g t))`;`UNIONS U`] (USE 6 o ISPECL);
3570 IMATCH_MP_TAC (prove_by_refinement(`!D B C. ((B:A->bool) SUBSET D) ==> ((D SUBSET C) ==> (B SUBSET C))`,[MESON_TAC [SUBSET_TRANS]]));
3571 REWRITE_TAC[subset_preimage];
3573 REWRITE_TAC[SUBSET;IN;IN_ELIM_THM'];
3575 REWRITE_TAC[INTER;in_preimage;IN ;IN_ELIM_THM' ];
3577 REWRITE_TAC[IMAGE;SUBSET;IN;IN_ELIM_THM'];
3578 REWRITE_TAC[Q_ELIM_THM'];
3580 REWRITE_TAC[INTER;in_preimage;IN ;IN_ELIM_THM' ];
3581 REWRITE_TAC[open_ball;IN_ELIM_THM' ];
3583 ASM_SIMP_TAC[euclid_add_closure];
3584 TYPE_THEN `d_euclid (f t + (g t)) (f x' + g x') <=. (d_euclid (f t + (g t)) (f x' + g t)) + (d_euclid (f x' + g t) (f x' + g x'))` SUBGOAL_TAC;
3585 TYPEL_THEN [`euclid n`;`d_euclid`] (fun t-> ASSUME_TAC (ISPECL t metric_space_triangle));
3587 UND 17 THEN DISCH_THEN IMATCH_MP_TAC ;
3588 ASM_SIMP_TAC[euclid_add_closure];
3589 IMATCH_MP_TAC (REAL_ARITH `b + C < d ==> (a <= b + C ==> (a < d))`);
3591 IMATCH_MP_TAC real_half_LT;
3593 ASM_MESON_TAC [euclid_add_closure;SPEC `n:num` metric_translate];
3594 ASM_MESON_TAC[euclid_add_closure;metric_translate_LEFT];
3597 REWRITE_TAC[INTER;in_preimage ;IN_ELIM_THM];
3598 ASM_REWRITE_TAC[IN];
3601 REWRITE_TAC[SUBSET;IN;IN_IMAGE ;IN_ELIM_THM'];
3603 REWRITE_TAC[Q_ELIM_THM''];
3604 USE 8 (ONCE_REWRITE_RULE [GSYM REAL_LT_HALF1]);
3605 ASM_MESON_TAC[REWRITE_RULE[IN] open_ball_nonempty];
3607 IMATCH_MP_TAC top_inter;
3613 (* ------------------------------------------------------------------ *)
3614 (* Cauchy sequences and completeness *)
3615 (* ------------------------------------------------------------------ *)
3618 let sequence = euclid_def
3619 `sequence X (f:num->A) <=> (IMAGE f UNIV) SUBSET X`;;
3621 let converge = euclid_def
3622 `converge (X,d) (f:num -> A) <=> (?x. (x IN (X:A->bool)) /\
3623 (!eps. ?n. (&.0 <. eps) ==>
3624 (!i. (n <=| i) ==> (d x (f i) <. eps))))`;;
3626 let cauchy_seq = euclid_def
3627 `cauchy_seq (X,d) (f:num->A) <=> (sequence X f) /\
3628 (!eps. ?n. !i j. (&.0 <. eps) /\
3629 (n <= i) /\ (n <= j) ==> (d (f i) (f j) <. eps))`;;
3631 let complete = euclid_def
3632 `complete (X,d) <=> !(f:num->A). cauchy_seq (X,d) f ==>
3635 let converge_cauchy = prove_by_refinement(
3636 `!X d f. metric_space(X,d) /\ (sequence X f) /\ (converge((X:A->bool),d) f)
3637 ==> cauchy_seq(X,d) f`,
3641 REWRITE_TAC[converge;metric_space];
3643 REWRITE_TAC[cauchy_seq];
3645 FIRST_ASSUM CHOOSE_TAC;
3647 UNDISCH_FIND_TAC `(IN)`;
3649 FIRST_ASSUM (fun t-> MP_TAC (SPEC `eps/(&.2)` t));
3650 DISCH_THEN CHOOSE_TAC;
3654 SUBGOAL_TAC ` (&.0 <. (eps/(&.2)))`;
3655 MATCH_MP_TAC REAL_LT_DIV;
3658 DISCH_THEN (ANTE_RES_THEN ASSUME_TAC);
3659 UNDISCH_TAC `n <=| i`;
3660 DISCH_THEN (ANTE_RES_THEN ASSUME_TAC);
3661 UNDISCH_TAC `n <=| j`;
3662 DISCH_THEN (ANTE_RES_THEN ASSUME_TAC);
3663 FIRST_ASSUM (fun t-> MP_TAC (SPECL [`(f:num->A) i`;`x:A`;`(f:num->A) j`] t));
3664 UNDISCH_FIND_TAC `sequence`;
3665 REWRITE_TAC[sequence;SUBSET;IN_IMAGE;IN_UNIV];
3669 SUBGOAL_TAC `X ((f:num->A) i) /\ X x /\ X (f j)`;
3671 DISCH_THEN (fun t->REWRITE_TAC[t]);
3673 ASM_MESON_TAC[REAL_LET_TRANS;REAL_LT_ADD2;REAL_HALF_DOUBLE];
3679 (* relate the metric space version to the real numbers version *)
3680 let cauchy_seq_cauchy = prove_by_refinement(
3681 `!f. (cauchy_seq(euclid 1,d_euclid) f) ==> (cauchy (\x. (f x 0)))`,
3685 REWRITE_TAC[cauchy_seq;cauchy;sequence;SUBSET;IN_IMAGE;IN_UNIV];
3691 FIRST_ASSUM (fun t -> MP_TAC (SPEC `e':real` t));
3692 DISCH_THEN CHOOSE_TAC;
3693 EXISTS_TAC `n':num`;
3695 REWRITE_TAC[ARITH_RULE `a >=| b <=> b <=| a`];
3696 SUBGOAL_TAC `euclid 1 (f (m':num)) /\ euclid 1 (f (n'':num))`;
3698 ASM_MESON_TAC[euclid1_abs];
3702 (* a variant of SEQ_CAUCHY *)
3703 let complete_real = prove_by_refinement(
3704 `complete (euclid 1,d_euclid)`,
3708 REWRITE_TAC[complete;converge];
3710 DISCH_THEN (fun t-> ASSUME_TAC t THEN MP_TAC t);
3711 DISCH_THEN (fun t -> MP_TAC (MATCH_MP cauchy_seq_cauchy t));
3712 REWRITE_TAC[SEQ_CAUCHY;SEQ_LIM;tends_num_real;SEQ_TENDS];
3713 ABBREV_TAC `z = lim (\x. f x 0)`;
3714 REWRITE_TAC[MR1_DEF];
3716 ABBREV_TAC `c = \j. (if (j=0) then (z:real) else (&.0))`;
3717 EXISTS_TAC `(c:num->real)`;
3718 SUBGOAL_TAC `c IN (euclid 1)`;
3719 REWRITE_TAC[IN;euclid];
3729 REWRITE_TAC[GSYM RIGHT_IMP_EXISTS_THM];
3731 FIRST_ASSUM (fun t-> (MP_TAC (SPEC `eps:real` t)));
3732 FIRST_ASSUM (fun t-> REWRITE_TAC[t]);
3733 DISCH_THEN CHOOSE_TAC;
3736 SUBGOAL_TAC `euclid 1 (f (i:num))`;
3737 UNDISCH_FIND_TAC `cauchy_seq`;
3738 REWRITE_TAC[cauchy_seq;sequence;SUBSET;IN_IMAGE;IN_UNIV];
3739 DISCH_THEN (fun t-> MP_TAC (CONJUNCT1 t));
3742 UNDISCH_FIND_TAC `(IN)`;
3744 SIMP_TAC[euclid1_abs];
3748 ASM_MESON_TAC[ARITH_RULE `n >=| N <=> N <= n`];
3754 let sequence_in = prove_by_refinement(
3755 `!X (f:num->A) i. sequence X f ==> X (f i)`,
3760 REWRITE_TAC[sequence;SUBSET;IN_IMAGE;IN_UNIV];
3767 let proj_cauchy = prove_by_refinement(
3768 `!i f n. cauchy_seq (euclid n,d_euclid) f ==>
3769 (cauchy_seq (euclid 1,d_euclid) ((proj i) o f))`,
3773 REWRITE_TAC[cauchy_seq];
3775 SUBGOAL_TAC `sequence (euclid 1) (proj (i:num) o f)`;
3776 REWRITE_TAC[sequence;SUBSET;IN_IMAGE;o_DEF;IN_UNIV];
3778 MESON_TAC[IN;proj_euclid1];
3782 FIRST_ASSUM (fun t -> CHOOSE_TAC (SPEC `eps:real` t));
3783 EXISTS_TAC `n':num`;
3785 FIRST_ASSUM (fun t-> MP_TAC(SPECL [`i':num`;`j:num`] t));
3786 UNDISCH_FIND_THEN `d_euclid` (fun t-> ALL_TAC);
3788 MATCH_MP_TAC (REAL_ARITH `a <=. b ==> (b <. eps ==> a <. eps)`);
3789 REWRITE_TAC[o_DEF;proj_d_euclid];
3790 MATCH_MP_TAC proj_contraction;
3792 ASM_MESON_TAC[sequence_in];
3797 let complete_euclid = prove_by_refinement(
3798 `!n. complete (euclid n,d_euclid)`,
3801 REWRITE_TAC[complete;IN];
3804 IMP_RES_THEN MP_TAC proj_cauchy;
3806 SUBGOAL_TAC `!i. converge (euclid 1,d_euclid) (proj i o f)`;
3808 ASM_MESON_TAC[complete;complete_real];
3809 REWRITE_TAC[converge;IN];
3810 DISCH_THEN (fun t-> MP_TAC (ONCE_REWRITE_RULE[SKOLEM_THM] t));
3811 DISCH_THEN (X_CHOOSE_TAC `L:num->(num->real)`);
3812 EXISTS_TAC `(\j. ((L:num->num->real) j 0))`;
3814 REWRITE_TAC[euclid];
3816 FIRST_ASSUM (fun t->(MP_TAC (SPEC `m:num` t)));
3818 FIRST_ASSUM (fun t-> (MP_TAC (SPEC `abs((L:num->num->real) m 0)` t)));
3819 DISCH_THEN CHOOSE_TAC;
3821 ASSUME_TAC (REAL_ARITH `!x. ~(x=(&.0)) ==> (&.0 <. abs(x))`);
3822 UNDISCH_FIND_TAC `d_euclid`;
3824 REWRITE_TAC[GSYM EXISTS_NOT_THM];
3825 EXISTS_TAC `(n:num)+n'`;
3827 REWRITE_TAC[ARITH_RULE `n' <=| n+| n'`];
3828 MATCH_MP_TAC(REAL_ARITH `(x = y) ==> ~(x<y)`);
3829 ALL_TAC; (* #buffer "CE1"; *)
3830 SUBGOAL_TAC `euclid 1 (proj m (f (n +| n')))`;
3831 REWRITE_TAC[proj_euclid1];
3832 ASM_SIMP_TAC[euclid1_abs];
3834 MATCH_MP_TAC (REAL_ARITH `(&.0 = x) ==> (abs(u - x) = abs(u))`);
3836 SUBGOAL_TAC `euclid n (f (n+| n'))`;
3837 ASM_MESON_TAC[cauchy_seq;sequence_in];
3838 REWRITE_TAC[euclid];
3839 DISCH_THEN (fun t-> ASM_SIMP_TAC[t]);
3840 ALL_TAC; (* #buffer "CE2"; *)
3843 CONV_TAC (quant_right_CONV "n");
3845 USE 2 (CONV_RULE (quant_left_CONV "eps"));
3846 USE 2 (CONV_RULE (quant_left_CONV "eps"));
3847 USE 2 (SPEC `eps/(&.1 +. &. n)`);
3848 USE 2 (CONV_RULE (quant_left_CONV "n'"));
3849 USE 2 (CONV_RULE (quant_left_CONV "n'"));
3851 SUBGOAL_TAC `&.0 <. eps/ (&.1 +. &.n)`;
3852 MATCH_MP_TAC REAL_LT_DIV;
3853 ASM_REWRITE_TAC[REAL_OF_NUM_ADD;REAL_OF_NUM_LT];
3855 DISCH_THEN (fun t-> (USE 2 (REWRITE_RULE[t])));
3856 SUBGOAL_TAC `!i j. euclid 1 ((proj i o f) (j:num))`;
3857 ASM_MESON_TAC[cauchy_seq;sequence_in];
3859 SUBGOAL_TAC `!i. euclid n (f (i:num))`;
3861 ASM_MESON_TAC[cauchy_seq;sequence_in];
3863 ASM_SIMP_TAC[d_euclid_n];
3864 SUBGOAL_TAC `!(j:num). ?c. !i. (c <=| i) ==> ||. (L j 0 -. f i j) <. eps/(&.1 + &. n)`;
3865 CONV_TAC (quant_left_CONV "c");
3866 EXISTS_TAC `n':num->num`;
3868 USE 2 ((SPEC `j:num`));
3871 USE 8 (SPEC `i:num`);
3874 ASM_SIMP_TAC[euclid1_abs];
3875 REWRITE_TAC[proj;o_DEF];
3876 CONV_TAC (quant_left_CONV "c");
3877 DISCH_THEN CHOOSE_TAC;
3878 ABBREV_TAC `t = (\u. (if (u <| n) then (c u) else (0)))`;
3879 SUBGOAL_TAC `?M. (!j. (t:num->num) j <=| M)`;
3880 MATCH_MP_TAC max_num_sequence;
3885 ASM_MESON_TAC[ARITH_RULE `m <| n ==> ~(n <= m)`];
3887 DISCH_THEN CHOOSE_TAC;
3890 ALL_TAC; (* #set "CE3"; *)
3892 MATCH_MP_TAC REAL_POW_2_LT;
3894 MATCH_MP_TAC SQRT_POS_LE;
3895 REWRITE_TAC[REAL_SUM_SQUARE_POS];
3899 SIMP_TAC[REAL_SUM_SQUARE_POS;SQRT_POW_2];
3900 SUBGOAL_TAC `sum (0,n) (\i'. (L i' 0 - f (i:num) i') * (L i' 0 - f i i')) <=. sum (0,n) (\i'. (eps/(&.1 + &.n)) * (eps/(&.1 + &.n)))`;
3901 MATCH_MP_TAC SUM_LE;
3905 SUBGOAL_TAC `c (r:num) = (t:num->num) r`;
3909 ASM_MESON_TAC[ARITH_RULE `n +| 0 = n`];
3911 SUBGOAL_TAC `(abs (L r 0 - f (i:num) (r:num)) < eps/(&.1 + &.n))`;
3912 USE 7 (SPECL [`r:num`;`i:num`]);
3914 DISCH_THEN MATCH_MP_TAC;
3916 USE 9 (SPEC `r:num`);
3919 REWRITE_TAC[LE_TRANS];
3920 ALL_TAC; (* "CE4" *)
3921 ABBREV_TAC `b = eps/(&1 + &n)`;
3922 ABBREV_TAC `a = (L r 0 - (f:num->num->real) i r)`;
3923 REWRITE_TAC[GSYM REAL_POW_2];
3924 REWRITE_TAC[GSYM REAL_LE_SQUARE_ABS];
3926 MATCH_MP_TAC (REAL_ARITH `(b <. c) ==> ((a <=. b) ==> (a <. c))`);
3927 REWRITE_TAC[SUM_CONST];
3928 REWRITE_TAC[REAL_MUL_AC;real_div];
3929 SUBGOAL_TAC `eps pow 2 = eps*eps*(&. 1)`;
3930 REWRITE_TAC[REAL_POW_2];
3932 DISCH_THEN (fun t->REWRITE_TAC[t]);
3933 MATCH_MP_TAC REAL_PROP_LT_LMUL;
3935 MATCH_MP_TAC REAL_PROP_LT_LMUL;
3937 SUBGOAL_TAC `&.0 <. &.1 + &.n `;
3938 REWRITE_TAC[REAL_OF_NUM_ADD;REAL_OF_NUM_LT];
3940 ALL_TAC; (* "CE5" *)
3941 SIMP_TAC[REAL_INV_LT];
3943 REWRITE_TAC[REAL_OF_NUM_ADD;REAL_OF_NUM_LT;REAL_OF_NUM_MUL];
3944 REWRITE_TAC[ARITH_RULE `(1+n)*(1+n)*1 = 1+n+n+n*n`];
3945 MATCH_MP_TAC (ARITH_RULE `(0<=a)/\(0<=b) /\(0<1) ==> (a <| 1 + a + a + b)`);
3949 ONCE_REWRITE_TAC [ARITH_RULE `0 = n *| 0`];
3950 REWRITE_TAC[LE_MULT_LCANCEL];
3956 let subset_sequence = prove_by_refinement(
3957 `!(X:A->bool) S f. S SUBSET X /\ sequence S f ==>
3961 REWRITE_TAC[sequence];
3966 let subset_cauchy = prove_by_refinement(
3967 `!(X:A->bool) S d f. S SUBSET X /\ cauchy_seq(S,d) f ==>
3972 REWRITE_TAC[cauchy_seq];
3974 ASM_MESON_TAC[subset_sequence];
3978 let complete_closed = prove_by_refinement(
3979 `!n S. (closed_ (top_of_metric (euclid n,d_euclid)) S) /\
3980 (S SUBSET (euclid n)) ==>
3981 (complete (S,d_euclid))`,
3984 REWRITE_TAC[complete];
3989 USE 0 (MATCH_MP closed_open);
3991 SIMP_TAC[GSYM top_of_metric_unions;metric_euclid];
3993 SUBGOAL_TAC `cauchy_seq(euclid n,d_euclid) f`;
3994 ASM_MESON_TAC[subset_cauchy];
3996 SUBGOAL_TAC `converge(euclid n,d_euclid) f`;
3997 ASM_MESON_TAC[complete_euclid;complete];
3998 REWRITE_TAC[converge];
3999 DISCH_THEN CHOOSE_TAC;
4000 EXISTS_TAC `(x:num->real)`;
4003 SUBGOAL_TAC `~(x IN S) ==> (x IN (euclid n DIFF S))`;
4006 H_MATCH_MP (HYP "6") (HYP "5");
4007 USE 0 (REWRITE_RULE[open_DEF]);
4008 USE 0 (REWRITE_RULE[(MATCH_MP (CONV_RULE (quant_right_CONV "A") top_of_metric_nbd) (SPEC `n:num` metric_euclid))]);
4009 USE 0 (CONV_RULE (quant_left_CONV "a"));
4010 USE 0 (SPEC `x:num->real`);
4012 ASM_REWRITE_TAC[SUBSET_DIFF];
4013 ALL_TAC; (* #CC1; *)
4015 USE 0 (REWRITE_RULE[]);
4017 USE 0 (REWRITE_RULE[SUBSET;IN_ELIM_THM';open_ball]);
4020 USE 4 (SPEC `r:real`);
4022 H_MATCH_MP (HYP "4") (HYP "8");
4023 USE 10 (SPEC `n':num`);
4024 USE 10 (REWRITE_RULE[ARITH_RULE `n <=| n`]);
4025 USE 0 (SPEC `(f:num->num->real) n'`);
4027 USE 9 (REWRITE_RULE[IN]);
4029 SUBGOAL_TAC `(S:(num->real)->bool) ((f:num->num->real) n')`;
4030 ASM_MESON_TAC[cauchy_seq;sequence_in];
4032 ABBREV_TAC `X = euclid n`;
4033 ABBREV_TAC `a = (f:num->num->real) n'`;
4034 REWRITE_TAC[IN_DIFF];
4035 REWRITE_TAC[IN;SUBSET];
4041 (* ------------------------------------------------------------------ *)
4042 (* Totally bounded metric spaces *)
4043 (* ------------------------------------------------------------------ *)
4046 let totally_bounded = euclid_def `totally_bounded ((X:A->bool),d) =
4047 (!eps. ?B. (&.0 <. eps) ==>
4049 (!b. (B b) ==> ?x. b = open_ball(X,d) x eps) /\
4052 let totally_bounded_subset = prove_by_refinement(
4053 `!(X:A->bool) d S. (metric_space (X,d)) /\ (totally_bounded(X,d))
4055 (totally_bounded (S,d)) `,
4060 REWRITE_TAC[totally_bounded];
4063 USE 1 (SPEC `eps/(&.2)`);
4065 CONV_TAC (quant_right_CONV "B");
4067 SUBGOAL_TAC `&.0 <. eps ==> &.0 <. eps/(&.2)`;
4068 DISCH_THEN (fun t-> MP_TAC (ONCE_REWRITE_RULE[GSYM REAL_HALF_DOUBLE] t));
4069 REWRITE_TAC[REAL_DIV_LZERO];
4073 (UND 1) THEN (ASM_REWRITE_TAC[]) THEN DISCH_ALL_TAC;
4074 SUBGOAL_TAC `!b. ?s. (?t. (t IN (b:A->bool) INTER S)) ==> (s IN b INTER S)`;
4076 CONV_TAC (quant_left_CONV "t");
4078 CONV_TAC (quant_left_CONV "s");
4079 DISCH_THEN CHOOSE_TAC;
4080 ALL_TAC; (* #set "TB1"; *)
4081 EXISTS_TAC `IMAGE (\c. (open_ball ((S:A->bool),d) ((s) c) eps)) (B:(A->bool)->bool)`;
4083 MATCH_MP_TAC FINITE_IMAGE;
4087 REWRITE_TAC[IMAGE;IN_ELIM_THM'];
4089 DISCH_THEN (X_CHOOSE_TAC `c:A->bool`);
4091 MATCH_MP_TAC EQ_EXT;
4095 SUBGOAL_TAC `(X:A->bool) (u:A)`;
4096 ASM_MESON_TAC[SUBSET;IN];
4098 REWRITE_TAC[REWRITE_RULE[IN] IN_UNIONS];
4099 DISCH_THEN (X_CHOOSE_TAC `b':A->bool`);
4100 USE 7 (SPEC `b':A->bool`);
4102 REWRITE_TAC[IN_ELIM_THM'];
4103 CONV_TAC (quant_left_CONV "x");
4104 CONV_TAC (quant_left_CONV "x");
4105 EXISTS_TAC `b':A->bool`;
4106 EXISTS_TAC `open_ball((S:A->bool),d) (s (b':A->bool)) eps`;
4107 ASM_REWRITE_TAC[IN];
4108 REWRITE_TAC[open_ball];
4109 REWRITE_TAC[IN_ELIM_THM'];
4110 ALL_TAC; (* #set "TB2"; *)
4111 SUBGOAL_TAC `(u:A) IN (b' INTER S)`;
4112 REWRITE_TAC[IN_INTER];
4115 CONV_TAC (quant_left_CONV "t");
4116 CONV_TAC (quant_left_CONV "t");
4120 SUBGOAL_TAC `(S:A->bool) ((s:(A->bool)->A) b')`;
4123 REWRITE_TAC[IN_INTER];
4127 SUBGOAL_TAC `(b':A->bool) ((s:(A->bool)->A) b')`;
4130 REWRITE_TAC[IN_INTER];
4132 ALL_TAC; (* #set "TB3"; *)
4135 USE 5 (SPEC `b':A->bool`);
4136 H_MATCH_MP (HYP "5") (HYP "13");
4138 ABBREV_TAC `v = (s:(A->bool)->A) b'`;
4143 REWRITE_TAC[open_ball;IN_ELIM_THM'];
4145 SUBGOAL_TAC `(X x) /\ ((X:A->bool) u) /\ (X v)`;
4147 ASM_MESON_TAC[SUBSET;IN];
4149 USE 0 (REWRITE_RULE[metric_space]);
4157 DISCH_THEN (fun t-> ASSUME_TAC t THEN (REWRITE_TAC[t]));
4158 REWRITE_TAC[open_ball;IN_ELIM_THM'];
4160 USE 0 (SPECL [`v:A`;`x:A`;`u:A`]);
4164 USE 22 (MATCH_MP (REAL_ARITH `(a <=. b + c) ==> !e. (b + c <. e ==> (a <. e))`));
4165 USE 22 (SPEC `eps:real`);
4166 UND 22 THEN (DISCH_THEN (MATCH_MP_TAC));
4170 MP_TAC (SPEC `eps:real` REAL_HALF_DOUBLE);
4172 REWRITE_TAC[IMAGE;IN_ELIM_THM'];
4173 REWRITE_TAC[UNIONS;IN_ELIM_THM'];
4174 CONV_TAC (quant_left_CONV "x");
4175 CONV_TAC (quant_left_CONV "x");
4177 CONV_TAC (quant_left_CONV "x'");
4178 X_GEN_TAC `c:A->bool`;
4179 CONV_TAC (quant_left_CONV "u'");
4184 REWRITE_TAC[open_ball;IN_ELIM_THM'];
4190 let integer_cube_finite = prove_by_refinement(
4191 `!n N. FINITE { f | (euclid n f) /\
4192 (!i. (?j. (abs(f i) = &.j) /\ (j <=| N)))}`,
4197 ABBREV_TAC `fs = FUN {m | m <| n} {x | ?j. (abs x = &.j) /\ (j <=| N)}`;
4198 ABBREV_TAC `gs = { f | (euclid n f) /\ (!i. (?j. (abs(f i) = &.j) /\ (j <=| N)))}`;
4199 SUBGOAL_TAC `FINITE (fs:(num->real)->bool)`;
4201 MP_TAC(prove(`!(a:num->bool) (b:real->bool). FINITE a /\ FINITE b ==> (FINITE (FUN a b))`,MESON_TAC[HAS_SIZE;FUN_SIZE]));
4202 DISCH_THEN MATCH_MP_TAC;
4203 REWRITE_TAC[interval_finite;FINITE_NUMSEG_LT];
4205 ABBREV_TAC `G = (\ u. (\ j. if (n <=| j) then (&.0) else (u j)))`;
4206 SUBGOAL_TAC `FINITE { y | ?x. x IN fs /\ (y:(num->real) = G (x:num->real))}`;
4207 MATCH_MP_TAC FINITE_IMAGE_EXPAND;
4209 SUBGOAL_TAC `!a b. ((a:(num->real)->bool) = b) ==> (FINITE a ==> FINITE b)`;
4211 DISCH_THEN (fun t-> REWRITE_TAC[t]);
4212 DISCH_THEN (fun t-> MATCH_MP_TAC t);
4213 MATCH_MP_TAC EQ_EXT;
4216 REWRITE_TAC[IN_ELIM_THM'];
4218 REWRITE_TAC[FUN;IN_ELIM_THM'];
4221 DISCH_THEN (CHOOSE_TAC );
4222 SUBGOAL_TAC `euclid n x`;
4223 REWRITE_TAC[euclid];
4228 DISCH_THEN (fun t->REWRITE_TAC[t]);
4229 DISCH_THEN (fun t->REWRITE_TAC[t]);
4230 DISCH_TAC THEN (ASM_REWRITE_TAC[]);
4239 USE 8 (SPEC `i':num`);
4240 ASM_MESON_TAC[ARITH_RULE `~(n <=| i') ==> (i' <| n)`];
4242 EXISTS_TAC `\p. (if (p <| n) then ((x:num->real) p) else (CHOICE UNIV))`;
4244 REWRITE_TAC[SUPP;SUBSET;IN_ELIM_THM'];
4248 DISCH_THEN (fun t->REWRITE_TAC[t]);
4255 MATCH_MP_TAC EQ_EXT;
4259 ASM_MESON_TAC[euclid];
4260 USE 6 (MATCH_MP (ARITH_RULE `~(n <=| q) ==> (q <| n)`));
4266 let FINITE_scaled_lattice = prove_by_refinement(
4267 `!n N s. (&.0 <. s) ==> FINITE {x | euclid n x /\ (!i. (?j. abs(x i) = s*(&.j)) /\ (abs(x i) <=. (&.N) ) ) }`,
4272 ABBREV_TAC `map = ( *# ) s`;
4273 ASSUME_TAC REAL_ARCH_SIMPLE;
4274 USE 2 (SPEC `inv(s)*(&.N)`);
4275 UND 2 THEN (DISCH_THEN (X_CHOOSE_TAC `M:num`));
4276 ASSUME_TAC integer_cube_finite;
4277 USE 3 (SPECL [`n:num`;`M:num`]);
4278 USE 3 (MATCH_MP (ISPEC `map:(num->real)->(num->real)` FINITE_IMAGE_EXPAND));
4280 MATCH_MP_TAC (prove_by_refinement (`!a b. ((b:A->bool) SUBSET a) ==> (FINITE a ==> FINITE b)`,[MESON_TAC[FINITE_SUBSET]]));
4281 REWRITE_TAC[SUBSET];
4282 X_GEN_TAC `c:num->real`;
4283 REWRITE_TAC[IN_ELIM_THM'];
4286 EXISTS_TAC `inv(s) *# c`;
4287 REWRITE_TAC[euclid_scale_act];
4288 ASM_SIMP_TAC[euclid_scale_closure];
4289 WITH 0 (MATCH_MP (REAL_ARITH `&.0 < s ==> ~(s = &.0)`));
4290 ASM_SIMP_TAC[REAL_MUL_RINV];
4293 USE 4 (SPEC `i:num`);
4296 REWRITE_TAC[euclid_scale;REAL_ABS_MUL;REAL_ABS_INV];
4297 SUBGOAL_TAC `abs s = s`;
4300 DISCH_THEN (fun t-> REWRITE_TAC[t]);
4302 ALL_TAC; (* save_goal "C" *)
4306 REWRITE_TAC[GSYM (CONJUNCT1 (CONJUNCT2 (REAL_MUL_AC)))];
4307 SIMP_TAC[REAL_MUL_LINV];
4310 REWRITE_TAC[GSYM REAL_OF_NUM_LE];
4312 UND 7 THEN DISCH_THEN (fun t-> REWRITE_TAC[t]);
4313 USE 0 (MATCH_MP REAL_LT_INV);
4314 ABBREV_TAC `s' = inv(s)`;
4315 USE 0 (MATCH_MP (REAL_ARITH `&.0 < s' ==> &.0 <=. s'`));
4317 USE 0 (MATCH_MP REAL_LE_LMUL);
4321 REWRITE_TAC[euclid_scale_one];
4326 let totally_bounded_cube = prove_by_refinement(
4327 `!n N. totally_bounded
4328 ({x | euclid n x /\ (!i. abs(x i) <=. (&.N))},d_euclid)`,
4332 REWRITE_TAC[totally_bounded];
4334 CONV_TAC (quant_right_CONV "B");
4336 ABBREV_TAC `cent = {x | euclid n x /\ (!i. (?j. abs(x i) = (eps/(&.n+. &.1))*(&.j)) /\ (abs(x i) <=. (&.N) ) ) }`;
4337 SUBGOAL_TAC `&.0 <. (&.n +. &.1)`;
4341 ABBREV_TAC `s = eps/(&.n +. &.1)`;
4342 SUBGOAL_TAC `&.0 < s`;
4344 ASM_SIMP_TAC[REAL_LT_DIV];
4346 SUBGOAL_TAC `FINITE (cent:(num->real)->bool)`;
4348 ASM_SIMP_TAC[FINITE_scaled_lattice];
4350 ABBREV_TAC `cube = {x | euclid n x /\ (!i. abs(x i) <=. (&.N))}`;
4351 EXISTS_TAC `IMAGE (\c. open_ball(cube,d_euclid) c eps) cent`;
4353 ASM_MESON_TAC[FINITE_IMAGE];
4357 REWRITE_TAC[IMAGE;IN_ELIM_THM'];
4360 ALL_TAC; (* # TB1; *)
4361 SUBGOAL_TAC `cent SUBSET (cube:(num->real)->bool)`;
4362 REWRITE_TAC[SUBSET];
4365 REWRITE_TAC[IN_ELIM_THM'];
4368 MATCH_MP_TAC EQ_EXT;
4372 REWRITE_TAC[UNIONS;IN_IMAGE;IN_ELIM_THM'];
4373 ASSUME_TAC REAL_ARCH_LEAST;
4374 USE 11 (SPEC `s:real`);
4375 UND 11 THEN (ASM_REWRITE_TAC[]) THEN DISCH_TAC;
4376 USE 11 (CONV_RULE (quant_left_CONV "n"));
4377 USE 11 (CONV_RULE (quant_left_CONV "n"));
4378 UND 11 THEN (DISCH_THEN (X_CHOOSE_TAC `cs:real->num`));
4380 CONV_TAC (quant_left_CONV "x'");
4381 CONV_TAC (quant_left_CONV "x'");
4382 ABBREV_TAC `cx = \ (i:num) . if (&.0 <=. (x i)) then &(cs (x i))* s else --. (&.(cs (--. (x i))) * s )`;
4383 EXISTS_TAC `cx:num->real`;
4384 EXISTS_TAC `open_ball(cube,d_euclid) cx eps`;
4386 ALL_TAC; (* # TB2; *)
4387 SUBGOAL_TAC `euclid n x`;
4390 REWRITE_TAC[IN_ELIM_THM'];
4393 SUBGOAL_TAC `cx IN (euclid n)`;
4394 REWRITE_TAC[IN;euclid;];
4398 REWRITE_TAC[euclid];
4399 DISCH_THEN (fun t-> MP_TAC(SPEC `m:num` t));
4401 DISCH_THEN (fun t-> REWRITE_TAC[t]);
4403 USE 11 (SPEC `&.0`);
4406 ABBREV_TAC `(a:num) = (cs (&.0))`;
4407 SUBGOAL_TAC `&.0 <=. &.a *s`;
4408 REWRITE_TAC[REAL_MUL_NN];
4413 ABBREV_TAC `q = (&.a)*. s`;
4416 ALL_TAC; (* # TB3; *)
4419 REWRITE_TAC[IN_ELIM_THM'];
4420 USE 14 (REWRITE_RULE[IN]);
4427 EXISTS_TAC `((cs:real->num) (x (i:num)))`;
4428 REWRITE_TAC[REAL_ABS_MUL];
4430 REWRITE_TAC[REAL_MUL_AC];
4436 ALL_TAC; (* # TB4; *)
4437 SUBGOAL_TAC `(&.0 <=. &.(cs ((x:num->real) i)) * s)`;
4438 REWRITE_TAC[REAL_MUL_NN];
4441 UND 4 THEN REAL_ARITH_TAC;
4442 DISCH_THEN (fun t-> MP_TAC (REWRITE_RULE[GSYM REAL_ABS_REFL] t));
4443 DISCH_THEN (fun t-> REWRITE_TAC [t]);
4444 USE 11 (SPEC `(x:num->real) i`);
4449 REWRITE_TAC [IN_ELIM_THM'];
4450 DISCH_THEN (fun t -> ASSUME_TAC (CONJUNCT2 t));
4451 USE 10 (SPEC `i:num`);
4453 ASSUME_TAC(prove(`&.0 <= x ==> (abs x = x)`,MESON_TAC[REAL_ABS_REFL]));
4455 MESON_TAC[REAL_LE_TRANS];
4456 ALL_TAC ; (* #TB5; *)
4457 REWRITE_TAC[REAL_ABS_NEG];
4459 EXISTS_TAC `((cs:real->num) (--. (x (i:num))))`;
4460 REWRITE_TAC [REAL_ABS_MUL];
4462 ASSUME_TAC(prove(`&.0 <= x ==> (abs x = x)`,MESON_TAC[REAL_ABS_REFL]));
4463 ASSUME_TAC(REAL_ARITH `&.0 < x ==> &. 0 <=. x`);
4465 REWRITE_TAC [REAL_MUL_AC];
4467 USE 11 (SPEC `--. (x (i:num))`);
4469 ASSUME_TAC (REAL_ARITH `!x. ~(&.0 <= x) ==> (&.0 <= --. x)`);
4473 REWRITE_TAC[IN_ELIM_THM'];
4474 DISCH_THEN (fun t -> ASSUME_TAC (CONJUNCT2 t));
4475 USE 10 (SPEC `i:num`);
4477 MP_TAC(prove(`!v. (-- v <=. abs(v))`,REAL_ARITH_TAC));
4478 REWRITE_TAC [REAL_ABS_MUL];
4480 ASSUME_TAC(prove(`&.0 <= x ==> (abs x = x)`,MESON_TAC[REAL_ABS_REFL]));
4481 ASSUME_TAC(REAL_ARITH `&.0 < x ==> &. 0 <=. x`);
4483 MESON_TAC[REAL_LE_TRANS];
4484 ALL_TAC; (* #TB6; *)
4486 REWRITE_TAC[open_ball;IN_ELIM_THM'];
4491 REWRITE_TAC[SUBSET;IN];
4493 SUBGOAL_TAC `d_euclid cx x <= sqrt(&.n)*s`;
4494 MATCH_MP_TAC D_EUCLID_BOUND;
4495 USE 14 (REWRITE_RULE[IN]);
4500 ASSUME_TAC (REAL_ARITH `!x a b. a <=. x /\ x <. b ==> abs(a - x) <= b -a`);
4501 SUBGOAL_TAC `!x. &.0 <=. x ==> abs(&.(cs x)*.s -. x) <=. s`;
4503 USE 11 (SPEC `x':real`);
4504 H_MATCH_MP (HYP "11") (HYP "17");
4505 H_MATCH_MP (HYP "16") (HYP "18");
4506 USE 19 (REWRITE_RULE [GSYM REAL_SUB_RDISTRIB]);
4507 ALL_TAC; (* # TB7; *)
4508 USE 19 (CONV_RULE REDUCE_CONV);
4513 REWRITE_TAC[REAL_ARITH `--x - y = --(x+.y)`;REAL_ABS_NEG];
4514 REWRITE_TAC[REAL_ARITH `x+. y = (x -. (--. y))`];
4515 ASM_MESON_TAC[REAL_ARITH `!u. ~(&.0 <=. u) ==> (&.0 <=. (--. u))`];
4516 ALL_TAC; (* # TB8; *)
4517 MATCH_MP_TAC(REAL_ARITH `b < c ==> ((a<=b) ==> (a < c))`);
4519 REWRITE_TAC[real_div;REAL_MUL_AC];
4520 MATCH_MP_TAC(REAL_ARITH`(t < e *(&.1)) ==> (t <. e)`);
4521 MATCH_MP_TAC (REAL_LT_LMUL);
4523 ASSUME_TAC REAL_PROP_LT_LCANCEL ;
4524 USE 16 (SPEC `&.n +. &.1`);
4526 DISCH_THEN (MATCH_MP_TAC);
4528 SUBGOAL_TAC `~(&.(n+1) = &.0)`;
4531 REWRITE_TAC[REAL_ARITH`a*b*c = (a*b)*c`];
4532 ALL_TAC; (* # TB8; *)
4533 SIMP_TAC[REAL_MUL_RINV];
4540 MATCH_MP_TAC SQRT_POS_LE;
4546 SUBGOAL_TAC `&.0 <=. &.n`;
4548 SIMP_TAC[prove(`!x. (&.0 <=. x) ==> (sqrt(x) pow 2 = x)`,MESON_TAC[SQRT_POW2])];
4550 REWRITE_TAC[REAL_POW_2];
4552 REWRITE_TAC[LEFT_ADD_DISTRIB;RIGHT_ADD_DISTRIB];
4554 ABBREV_TAC `m = n*|n +| n`;
4556 ALL_TAC; (* # TB9; *)
4557 REWRITE_TAC[UNIONS;IN_IMAGE;IN_ELIM_THM'];
4558 DISCH_THEN CHOOSE_TAC;
4564 MP_TAC (ISPEC `cube:(num->real)->bool` open_ball_subset);
4565 REWRITE_TAC[SUBSET];
4571 let center_FINITE = prove_by_refinement(
4572 `!X d . metric_space ((X:A->bool),d) /\ (totally_bounded (X,d))
4573 ==> (!eps. (&.0 < eps) ==> (?C. (C SUBSET X) /\ (FINITE C) /\ (X = UNIONS (IMAGE (\x. open_ball(X,d) x eps) C))))`,
4576 REWRITE_TAC[totally_bounded];
4579 USE 1 (SPEC `eps:real`);
4584 USE 4 (CONV_RULE ((quant_left_CONV "x")));
4585 USE 4 (CONV_RULE ((quant_left_CONV "x")));
4587 ABBREV_TAC `C'={z | (X (z:A)) /\ (?b. (B (b:A->bool)) /\ (z = x b))}`;
4588 EXISTS_TAC `C':A->bool`;
4591 REWRITE_TAC[SUBSET;IN_ELIM_THM'];
4596 SUBGOAL_TAC `C' SUBSET (IMAGE (x:(A->bool)->A) B)`;
4598 REWRITE_TAC[SUBSET;IN_IMAGE;IN_ELIM_THM'];
4602 SUBGOAL_TAC `FINITE (IMAGE (x:(A->bool)->A) B)`;
4603 ASM_MESON_TAC[FINITE_IMAGE];
4604 ASM_MESON_TAC[FINITE_SUBSET];
4606 (ASM (GEN_REWRITE_TAC LAND_CONV)) [];
4607 ( (GEN_REWRITE_TAC LAND_CONV)) [UNIONS_DELETE];
4609 MATCH_MP_TAC EQ_EXT;
4611 REWRITE_TAC[DELETE;IN_ELIM_THM';IMAGE];
4613 REWRITE_TAC[IN_ELIM_THM'];
4617 USE 4 (SPEC `x':A->bool`);
4618 CONV_TAC (quant_left_CONV "b'");
4619 CONV_TAC (quant_left_CONV "b'");
4620 CONV_TAC (quant_left_CONV "b'");
4621 EXISTS_TAC `x':(A->bool)`;
4622 EXISTS_TAC `(x:(A->bool)->A) x'`;
4624 USE 7 (REWRITE_RULE[IN]);
4625 H_MATCH_MP (HYP "4") (HYP"7");
4627 ABBREV_TAC `a = (x:(A->bool)->A) x'`;
4632 MESON_TAC[open_ball_empty;IN];
4634 DISCH_THEN CHOOSE_TAC;
4643 USE 4 (SPEC `b':A->bool`);
4650 ABBREV_TAC `a = (x:(A->bool)->A) b'`;
4654 USE 0 (MATCH_MP open_ball_nonempty);
4656 ABBREV_TAC `E= open_ball(X,d) (a:A) eps `;
4657 MESON_TAC[IN;EMPTY];
4661 let open_ball_dist = prove_by_refinement(
4662 `!X d x y r. (open_ball(X,d) x r y) ==> (d (x:A) y <. r)`,
4665 REWRITE_TAC[open_ball;IN_ELIM_THM'];
4671 let totally_bounded_bounded = prove_by_refinement(
4672 `!(X:A->bool) d. metric_space(X,d) /\ totally_bounded (X,d) ==>
4673 (?a r. X SUBSET (open_ball(X,d) a r))`,
4679 USE 0 (MATCH_MP center_FINITE);
4681 USE 0 (CONV_RULE REDUCE_CONV);
4683 EXISTS_TAC `CHOICE (X:A->bool)`;
4684 ASM_CASES_TAC `(X:A->bool) = EMPTY`;
4685 ASM_REWRITE_TAC[EMPTY_SUBSET];
4686 USE 1 (MATCH_MP CHOICE_DEF);
4687 UND 0 THEN DISCH_ALL_TAC;
4688 ABBREV_TAC `(dset:real->bool) = IMAGE (\c. (d (CHOICE (X:A->bool)) (c:A))) C`;
4689 SUBGOAL_TAC `FINITE (dset:real->bool)`;
4691 MATCH_MP_TAC FINITE_IMAGE;
4694 USE 6 (MATCH_MP real_FINITE);
4696 EXISTS_TAC `a +. &.1`;
4697 REWRITE_TAC[SUBSET];
4699 REWRITE_TAC[open_ball;IN_ELIM_THM'];
4706 (* ASM (GEN_REWRITE_TAC LAND_CONV) []; *)
4707 USE 4(REWRITE_RULE[UNIONS;IN_IMAGE;IN_ELIM_THM']);
4708 USE 4(fun t -> AP_THM t `x:A`);
4710 DISCH_THEN (fun t-> ((MP_TAC t) THEN (ASM_REWRITE_TAC[])) THEN ASSUME_TAC t);
4712 USE 8 (REWRITE_RULE[IN_ELIM_THM']);
4715 USE 9 (CONV_RULE NAME_CONFLICT_CONV);
4717 ALL_TAC; (* # "tbb"; *)
4719 USE 8(REWRITE_RULE[IN]);
4720 USE 8 (MATCH_MP open_ball_dist);
4722 SUBGOAL_TAC `d (CHOICE (X:A->bool)) (x':A) IN (dset:real->bool)`;
4724 REWRITE_TAC[IN_IMAGE];
4727 H_MATCH_MP (HYP"6") (HYP"11");
4728 USE 2 (REWRITE_RULE[metric_space]);
4729 USE 2 (SPECL[`(CHOICE (X:A->bool))`;`(x':A)`;`x:A`]);
4732 SUBGOAL_TAC `(X:A->bool) x'`;
4738 UND 2 THEN DISCH_ALL_TAC;
4746 let subsequence_rec = prove_by_refinement(
4747 `!(X:A->bool) d f C s n r.
4748 metric_space(X,d) /\ (totally_bounded(X,d)) /\ (sequence X f) /\
4749 (C SUBSET X) /\ (&.0 < r) /\
4750 (~FINITE{j| C (f j)} /\ C(f s) /\ (!x y. (C x /\ C y) ==>
4751 d x y <. r*twopow(--: (&:n)))) ==>
4752 (? C' s'. ((C' SUBSET C) /\ (s < s') /\
4753 (~FINITE{j| C' (f j)} /\ C'(f s') /\ (!x y. (C' x /\ C' y) ==>
4754 d x y <. r*twopow(--: (&:(SUC n)))))))`,
4758 USE 1 (REWRITE_RULE[totally_bounded]);
4759 USE 1 (SPEC `r*twopow(--: (&:(n+| 2)))`);
4761 ASSUME_TAC twopow_pos;
4762 USE 8 (SPEC `--: (&: (n+| 2))`);
4763 ALL_TAC; (* ## need a few lines here to match Z8 with Z1. *)
4766 USE 8 (MATCH_MP REAL_LT_MUL);
4768 UND 1 THEN DISCH_ALL_TAC;
4769 ALL_TAC ; (* "sr1" OK TO HERE *)
4770 ASSUME_TAC (ISPECL [`UNIV:num->bool`;`f:num->A`;`B:(A->bool)->bool`;`C:A->bool`] INFINITE_PIGEONHOLE);
4773 H_REWRITE_RULE[HYP "10"] (HYP "3");
4775 DISCH_THEN CHOOSE_TAC;
4776 EXISTS_TAC `C INTER (b:A->bool)`;
4777 CONV_TAC (quant_right_CONV "s'");
4779 REWRITE_TAC[INTER_SUBSET];
4783 SUBGOAL_TAC `~(FINITE ({i | (C INTER b) ((f:num->A) i)} INTER {i | s <| i}))`;
4785 (USE 15) (REWRITE_RULE[]);
4786 USE 15 (MATCH_MP num_above_finite);
4790 ABBREV_TAC `J = ({i | (C INTER b) ((f:num->A) i)} INTER {i | s <| i})`;
4791 EXISTS_TAC `CHOICE (J:num->bool)`; (* ok to here *)
4792 SUBGOAL_TAC `J (CHOICE (J:num->bool))`;
4793 MATCH_MP_TAC (REWRITE_RULE [IN] CHOICE_DEF);
4795 USE 17 (REWRITE_RULE[]);
4796 H_REWRITE_RULE[(HYP "17")] (HYP "15");
4798 REWRITE_TAC[FINITE_RULES];
4799 ALL_TAC; (* "sr2" *)
4800 ABBREV_TAC `s' = (CHOICE (J:num->bool))`;
4802 REWRITE_TAC[INTER;IN_ELIM_THM'];
4806 KILL 5 THEN (KILL 2) THEN (KILL 1) THEN (KILL 13) THEN (KILL 12);
4807 SUBGOAL_TAC `(X x) /\ (X (y:A))`;
4808 UND 21 THEN UND 23 THEN UND 3;
4809 MESON_TAC[SUBSET;IN];
4810 USE 9 (SPEC `b:A->bool`);
4811 H_REWRITE_RULE[HYP "14"] (HYP "1");
4813 ALL_TAC; (* #"gg1" *)
4816 H_REWRITE_RULE[(HYP "2")] (HYP "0");
4817 USE 5 (REWRITE_RULE[IN]);
4818 USE 5 (MATCH_MP BALL_DIST);
4821 MATCH_MP_TAC (REAL_ARITH `(b = c) ==> ((a<. b) ==> (a<c))`);
4822 ALL_TAC; (* insert here *)
4823 REWRITE_TAC[REAL_MUL_ASSOC];
4824 REWRITE_TAC[REAL_ARITH `&.2 *.r = r*. (&.2)`];
4825 REWRITE_TAC[GSYM REAL_MUL_ASSOC];
4826 REWRITE_TAC[REAL_EQ_LMUL];
4827 USE 4 (MATCH_MP (REAL_ARITH `&.0 <. r ==> ~(r = &.0)`));
4829 REWRITE_TAC[TWOPOW_NEG];
4830 REWRITE_TAC[ARITH_RULE `(n+|2) = 1 + (SUC n)`];
4831 REWRITE_TAC[REAL_POW_ADD;REAL_INV_MUL];
4832 REWRITE_TAC [REAL_MUL_ASSOC];
4833 REWRITE_TAC[REAL_INV2;REAL_POW_1];
4838 let sequence_subseq = prove_by_refinement(
4839 `!(X:A->bool) f (ss:num->num). (sequence X f) ==>
4840 (sequence X (f o ss))`,
4843 REWRITE_TAC[sequence;IMAGE;IN_UNIV;SUBSET;IN_ELIM_THM';o_DEF];
4849 let cauchy_subseq = prove_by_refinement(
4850 `!(X:A->bool) d f. ((metric_space(X,d))/\(totally_bounded(X,d)) /\
4852 (?ss. (subseq ss) /\ (cauchy_seq(X,d) (f o ss)))`,
4859 USE 3 (MATCH_MP totally_bounded_bounded);
4862 ALL_TAC; (* {{{ xxx *)
4863 ALL_TAC; (* make r pos *)
4864 ASSUME_TAC (REAL_ARITH `r <. (&.1 + abs(r))`);
4865 ASSUME_TAC (REAL_ARITH `&.0 <. (&.1 + abs(r))`);
4866 ABBREV_TAC (`r' = &.1 +. abs(r)`);
4867 SUBGOAL_TAC `open_ball(X,d) a r SUBSET open_ball(X,d) (a:A) r'`;
4868 ASM_SIMP_TAC[open_ball_nest];
4871 USE 3 (MATCH_MP SUBSET_TRANS);
4874 ALL_TAC; (* "cs1" *)
4875 SUBGOAL_TAC `( !(x:A) y. (X x) /\ (X y) ==> (d x y <. &.2 *. r'))`;
4877 USE 3 (REWRITE_RULE[SUBSET;IN]);
4881 H_MATCH_MP (HYP "3") (HYP "6");
4882 H_MATCH_MP (HYP "7") (HYP "4");
4885 USE 0 (MATCH_MP BALL_DIST);
4888 ABBREV_TAC `cond = (\ ((C:A->bool),(s:num)) n. ~FINITE{j| C (f j)} /\ (C(f s)) /\ (!x y. (C x /\ C y) ==> d x y <. (&.2*.r')*. twopow(--: (&:n))))`;
4889 ABBREV_TAC `R = (&.2)*r'`;
4890 ALL_TAC ; (* 0 case of recursio *)
4892 SUBGOAL_TAC ` (X SUBSET X) /\ (cond ((X:A->bool),0) 0)`;
4893 REWRITE_TAC[SUBSET_REFL];
4895 CONV_TAC (TOP_DEPTH_CONV GEN_BETA_CONV);
4896 USE 2 (REWRITE_RULE[sequence;SUBSET;IN_IMAGE;IN_UNIV]);
4897 USE 2 (REWRITE_RULE[IN]);
4898 USE 2 (CONV_RULE (NAME_CONFLICT_CONV));
4899 SUBGOAL_TAC `!x. X((f:num->A) x)`;
4902 REWRITE_TAC[TWOPOW_0] THEN REDUCE_TAC;
4905 SUBGOAL_TAC `{ j | (X:A->bool) (f j) } = (UNIV:num->bool)`;
4906 MATCH_MP_TAC EQ_EXT;
4907 REWRITE_TAC[IN_ELIM_THM;UNIV];
4909 DISCH_THEN REWRT_TAC;
4911 REWRITE_TAC[num_infinite];
4912 ALL_TAC; (* #save_goal "cs3" *)
4913 SUBGOAL_TAC `&.0 <. R`;
4918 SUBGOAL_TAC `!cs n. ?cs' . (FST cs SUBSET X) /\ (cond cs n)==>( (FST cs' SUBSET (FST cs)) /\(SND cs <| ((SND:((A->bool)#num)->num) cs') /\ (cond cs' (SUC n))) )`;
4920 CONV_TAC (quant_right_CONV "cs'");
4923 H_REWRITE_RULE[GSYM o (HYP "6")] (HYP "11");
4924 USE 13 (CONV_RULE (SUBS_CONV[GSYM(ISPEC `cs:(A->bool)#num` PAIR)]));
4925 USE 13 (CONV_RULE (TOP_DEPTH_CONV GEN_BETA_CONV));
4931 USE 0 (MATCH_MP subsequence_rec);
4934 EXISTS_TAC `(C':A->bool,s':num)`;
4935 ASM_REWRITE_TAC[FST;SND];
4937 (CONV_TAC (TOP_DEPTH_CONV GEN_BETA_CONV));
4940 ALL_TAC; (* "cs4" *)
4941 USE 11 (REWRITE_RULE[SKOLEM_THM]);
4943 ASSUME_TAC (ISPECL[`((X:A->bool),0)`;`cs':(((A->bool)#num)->(num->(A->bool)#num))`] num_RECURSION);
4945 EXISTS_TAC `\i. (SND ((fn : num->(A->bool)#num) i))`;
4946 USE 11 (CONV_RULE (quant_left_CONV "n"));
4947 USE 11 (SPEC `n:num`);
4948 USE 11 (SPEC `(fn:num->(A->bool)#num) n`);
4950 H_REWRITE_RULE[GSYM o (HYP "12")] (HYP "11");
4952 ABBREV_TAC `sn = (\i. SND ((fn:num->(A->bool)#num) i))`;
4953 ABBREV_TAC `Cn = (\i. FST ((fn:num->(A->bool)#num) i))`;
4954 SUBGOAL_TAC `((sn:num->num) 0 = 0) /\ (Cn 0 = (X:A->bool))`;
4962 SUBGOAL_TAC `!(n:num). ((fn n):(A->bool)#num) = (Cn n,sn n)`;
4967 H_REWRITE_RULE[(HYP "11")] (HYP"14");
4974 ALL_TAC; (* KILL 10; cs4m *)
4980 TYPE_THEN `!n. (Cn n SUBSET X) /\ (cond (Cn n,sn n) n)` SUBGOAL_TAC;
4984 USE 13 (SPEC `n:num`);
4987 ASM_MESON_TAC[SUBSET_TRANS];
4991 ASM_REWRITE_TAC[SUBSEQ_SUC];
4993 ASM_REWRITE_TAC[cauchy_seq];
4994 ASM_SIMP_TAC[sequence_subseq];
4996 TYPE_THEN `!i j. (i <=| j) ==> (Cn j SUBSET (Cn i))` SUBGOAL_TAC;
4997 MATCH_MP_TAC SUBSET_SUC2;
5001 SUBGOAL_TAC `!R e. ?n. (&.0 <. R)/\ (&.0 <. e) ==> R*(twopow(--: (&:n))) <. e`;
5003 REWRITE_TAC[TWOPOW_NEG]; (* cs6b *)
5004 ASSUME_TAC (prove(`!n. &.0 < &.2 pow n`,REDUCE_TAC THEN ARITH_TAC));
5005 ONCE_REWRITE_TAC[REAL_MUL_AC];
5006 ASM_SIMP_TAC[REAL_INV_LT];
5007 ASM_SIMP_TAC[GSYM REAL_LT_LDIV_EQ];
5008 CONV_TAC (quant_right_CONV "n");
5010 ASSUME_TAC (SPEC `R'/e` REAL_ARCH_SIMPLE);
5014 MESON_TAC[POW_2_LT;REAL_LET_TRANS];
5016 USE 11 (SPECL [`R:real`;`eps:real`]);
5023 USE 3 (SPEC `n:num`);
5027 (CONV_TAC (TOP_DEPTH_CONV GEN_BETA_CONV));
5030 USE 15 (SPEC `i:num`);
5034 (CONV_TAC (TOP_DEPTH_CONV GEN_BETA_CONV));
5037 USE 20 (SPEC `j:num`);
5041 (CONV_TAC (TOP_DEPTH_CONV GEN_BETA_CONV));
5043 ABBREV_TAC `e2 = R * twopow (--: (&:n))`;
5045 TYPEL_THEN [`f (sn i)`;`f (sn j)`] (fun t-> (USE 19 (SPECL t)));
5055 USE 8 (SPECL [`n:num`;`i:num`]);
5056 USE 6 (SPECL [`n:num`;`j:num`]);
5058 MATCH_MP_TAC (REAL_ARITH `(c < a) ==> ((a < b) ==> (c < b))`);
5060 DISCH_THEN (MATCH_MP_TAC);
5066 MESON_TAC[IN;SUBSET];
5071 let convergent_subseq = prove_by_refinement(
5072 `!(X:A->bool) d f. metric_space(X,d) /\ (totally_bounded(X,d)) /\
5073 (complete (X,d)) /\ (sequence X f) ==>
5074 ((?(ss:num->num). (subseq ss) /\ (converge (X,d) (f o ss))))`,
5078 TYPE_THEN `?ss. (subseq ss) /\ (cauchy_seq(X,d) (f o ss))` SUBGOAL_TAC;
5079 ASM_MESON_TAC[cauchy_subseq];
5082 EXISTS_TAC `ss:num->num`;
5083 USE 2 (REWRITE_RULE[complete]);
5089 let dense = euclid_def `!U Z. dense U Z <=>
5090 (closure U (Z:A->bool) = UNIONS U)`;;
5092 let hausdorff = euclid_def `hausdorff U <=> (!x y.
5093 (UNIONS U (x:A) /\ UNIONS U y /\ ~(x = y)) ==>
5094 (?A B. (U A) /\ (U B) /\ (A x) /\ (B y) /\ (A INTER B = EMPTY)))`;;
5096 let dense_subset = prove_by_refinement(
5097 `!U Z. (topology_ U) /\ (dense U (Z:A->bool)) ==>
5098 (Z SUBSET (UNIONS U))`,
5102 MESON_TAC[subset_closure];
5106 let dense_open = prove_by_refinement(
5107 `!U Z. (topology_ U) /\ (Z SUBSET (UNIONS U)) ==>
5108 (dense U (Z:A->bool) <=>
5109 (!A. (open_ U A) /\ ( (A INTER Z) = EMPTY) ==> (A = EMPTY)))`,
5119 USE 0 (MATCH_MP (open_closed));
5120 TYPE_THEN `Z SUBSET (UNIONS U DIFF A)` SUBGOAL_TAC;
5122 REWRITE_TAC[DIFF_SUBSET];
5123 ONCE_REWRITE_TAC[INTER_COMM];
5128 USE 0 (MATCH_MP closure_subset);
5129 USE 0 (REWRITE_RULE[DIFF_SUBSET]);
5131 USE 2 (REWRITE_RULE[dense]);
5132 H_REWRITE_RULE [(HYP "2")] (HYP "0");
5133 (USE 5 (REWRITE_RULE[open_DEF]));
5134 USE 5 (MATCH_MP sub_union);
5135 USE 5 (REWRITE_RULE[ SUBSET_INTER_ABSORPTION]);
5136 USE 5 (ONCE_REWRITE_RULE[INTER_COMM]);
5140 MATCH_MP_TAC EQ_SYM;
5143 SIMP_TAC [closure_open];
5145 SIMP_TAC[closed_UNIV];
5149 USE 2 (SPEC `B:A->bool`);
5152 REWRITE_TAC[INTER_EMPTY];
5156 let countable_dense = prove_by_refinement(
5157 `!(X:A->bool) d. (metric_space(X,d)) /\ (totally_bounded(X,d)) ==>
5158 ?Z. (COUNTABLE Z) /\ (dense (top_of_metric(X,d)) Z)`,
5163 TYPE_THEN `!r. ?z. (COUNTABLE z) /\ (z SUBSET X) /\ (X = UNIONS (IMAGE (\x. open_ball(X,d) x (twopow(--: (&:r)))) z))` SUBGOAL_TAC;
5168 USE 2 (MATCH_MP center_FINITE);
5169 USE 2 (SPEC `twopow (--: (&:r))`);
5170 H_MATCH_MP (HYP "2") (THM (SPEC `(--: (&:r))` twopow_pos));
5171 X_CHO 3 `z:A->bool`;
5172 EXISTS_TAC `z:A->bool`;
5174 ASM_SIMP_TAC[FINITE_COUNTABLE];
5176 CONV_TAC (quant_left_CONV "z");
5177 DISCH_THEN CHOOSE_TAC;
5178 TYPE_THEN `UNIONS (IMAGE z (UNIV:num->bool))` EXISTS_TAC;
5180 MATCH_MP_TAC COUNTABLE_UNIONS;
5182 MATCH_MP_TAC (ISPEC `UNIV:num->bool` COUNTABLE_IMAGE);
5183 REWRITE_TAC[NUM_COUNTABLE];
5184 TYPE_THEN `z` EXISTS_TAC ;
5187 REWRITE_TAC[IN_IMAGE;IN_UNIV];
5189 TYPE_THEN `U = top_of_metric (X,d)` ABBREV_TAC;
5190 TYPE_THEN `Z = UNIONS (IMAGE z UNIV)` ABBREV_TAC;
5191 TYPE_THEN `topology_ U /\ (Z SUBSET (UNIONS U))` SUBGOAL_TAC;
5194 ASM_SIMP_TAC[top_of_metric_top;GSYM top_of_metric_unions];
5196 MATCH_MP_TAC UNIONS_SUBSET;
5197 REWRITE_TAC[IN_IMAGE;IN_UNIV];
5199 SIMP_TAC[dense_open];
5202 REWRITE_TAC[open_DEF];
5203 MATCH_MP_TAC (TAUT `( a /\ ~b ==> ~c) ==> (a /\ c ==> b)`);
5205 ASM_SIMP_TAC [top_of_metric_nbd];
5206 REWRITE_TAC[GSYM MEMBER_NOT_EMPTY];
5209 TYPE_THEN `x` (fun t-> (USE 8 (SPEC t)));
5213 SUBGOAL_TAC `?r. twopow(--: (&:r)) < eps`;
5214 ASSUME_TAC (SPECL [`&.1`;`eps:real`] twopow_eps);
5215 USE 10 (CONV_RULE REDUCE_CONV);
5217 DISCH_THEN CHOOSE_TAC;
5218 USE 2 (SPEC `r:num`);
5221 TYPE_THEN `x IN X` SUBGOAL_TAC;
5222 ASM SET_TAC[IN;SUBSET];
5223 ASM ONCE_REWRITE_TAC[];
5224 REWRITE_TAC[UNIONS;IN_ELIM_THM';IN_IMAGE];
5225 DISCH_THEN CHOOSE_TAC;
5231 REWRITE_TAC[IN_INTER];
5232 USE 13 (REWRITE_RULE[IN]);
5233 USE 13 (MATCH_MP open_ball_dist);
5235 USE 8 (REWRITE_RULE [open_ball;SUBSET]);
5237 USE 8 (SPEC `z0:A`);
5238 USE 8 (REWRITE_RULE [IN_ELIM_THM']);
5240 DISCH_THEN (MATCH_MP_TAC );
5241 ALL_TAC; (* "cd6" *)
5243 ASM SET_TAC[IN;SUBSET];
5246 ASM SET_TAC[IN;SUBSET];
5250 USE 0 (REWRITE_RULE[metric_space]);
5251 TYPEL_THEN [`z0`;`x`;`z0`] (fun t-> USE 0 (SPECL t));
5256 REWRITE_TAC[IN_UNIONS;IN_IMAGE;IN_UNIV];
5263 let metric_hausdorff = prove_by_refinement(
5264 `! (X:A->bool) d. (metric_space(X,d))==>
5265 (hausdorff (top_of_metric(X,d)))`,
5270 REWRITE_TAC[hausdorff;];
5271 ASM_SIMP_TAC [GSYM top_of_metric_unions];
5274 USE 4 (REWRITE_RULE[metric_space]);
5275 TYPEL_THEN [`x`;`y`;`x`] (USE 4 o SPECL);
5277 TYPE_THEN `r = d x y` ABBREV_TAC;
5278 SUBGOAL_TAC `&.0 <. r`;
5282 TYPE_THEN `open_ball(X,d) x (r/(&.2))` EXISTS_TAC;
5283 TYPE_THEN `open_ball(X,d) y (r/(&.2))` EXISTS_TAC;
5286 ASM_SIMP_TAC[open_ball_open];
5288 USE 4 (ONCE_REWRITE_RULE[GSYM REAL_LT_HALF1]);
5289 ASM_SIMP_TAC[REWRITE_RULE[IN] open_ball_nonempty];
5291 USE 7 (REWRITE_RULE[EMPTY_EXISTS]);
5293 USE 7 (REWRITE_RULE[IN_INTER]);
5294 USE 7 (REWRITE_RULE[IN]);
5299 USE 7 (MATCH_MP open_ball_dist);
5300 USE 8 (MATCH_MP open_ball_dist);
5301 USE 0 (REWRITE_RULE[metric_space]);
5303 TYPEL_THEN [`x`;`u`;`y`] (fun t-> (USE 0 (ISPECL t)));
5304 TYPEL_THEN [`y`;`u`;`y`] (fun t-> (USE 11 (ISPECL t)));
5308 TYPE_THEN `X u` SUBGOAL_TAC;
5309 ASM_MESON_TAC[ open_ball_subset;IN;SUBSET];
5310 DISCH_THEN (REWRT_TAC);
5314 DISCH_THEN (fun t-> REWRITE_TAC[GSYM t]);
5316 USE 0 (MATCH_MP (REAL_ARITH `(a <. c) /\ (b < c) ==> b+a < c + c`));
5317 USE 0 (CONV_RULE REDUCE_CONV);
5318 ASM_MESON_TAC[real_lt];
5325 let compact = euclid_def `compact U (K:A->bool) <=>
5326 (K SUBSET UNIONS U) /\ (!V. (K SUBSET UNIONS V ) /\ (V SUBSET U) ==>
5327 (?W. (W SUBSET V) /\ (FINITE W) /\ (K SUBSET UNIONS W )))`;;
5329 let closed_compact = prove_by_refinement(
5330 `!U K (S:A->bool). ((topology_ U) /\ (compact U K) /\
5331 (closed_ U S) /\ (S SUBSET K)) ==> (compact U S)`,
5334 REWRITE_TAC[compact];
5338 ASM_MESON_TAC[ SUBSET_TRANS];
5341 TYPE_THEN `A = UNIONS U DIFF S` ABBREV_TAC;
5342 TYPE_THEN `open_ U A` SUBGOAL_TAC ;
5343 ASM_MESON_TAC[ closed_open];
5344 TYPE_THEN `V' = (A INSERT V)` ABBREV_TAC;
5346 TYPE_THEN `V'` (USE 2 o SPEC);
5348 TYPE_THEN `K SUBSET UNIONS V'` SUBGOAL_TAC;
5354 TYPE_THEN `X = UNIONS U ` ABBREV_TAC;
5356 REWRITE_TAC[SUBSET_UNIONS_INSERT];
5357 SET_TAC[SUBSET;UNIONS;DIFF];
5359 TYPE_THEN `V' SUBSET U` SUBGOAL_TAC;
5362 REWRITE_TAC[INSERT_SUBSET];
5364 ASM_MESON_TAC[IN;open_DEF];
5368 TYPE_THEN `W DELETE A` EXISTS_TAC;
5373 SET_TAC[SUBSET;INSERT;DELETE];
5374 ASM_REWRITE_TAC[FINITE_DELETE];
5381 TYPE_THEN `X = UNIONS U ` ABBREV_TAC;
5384 MATCH_MP_TAC UNIONS_DELETE2;
5386 ASM_MESON_TAC[SUBSET_TRANS];
5387 SET_TAC[INTER;DIFF];
5392 let compact_closed = prove_by_refinement(
5393 `!U (K:A->bool). (topology_ U) /\ (hausdorff U) /\ (compact U K) ==>
5398 REWRITE_TAC[hausdorff;compact;closed];
5400 ASM_REWRITE_TAC[open_DEF];
5401 ONCE_ASM_SIMP_TAC[open_nbd];
5402 TYPE_THEN `C = UNIONS U DIFF K` ABBREV_TAC;
5404 CONV_TAC (quant_right_CONV "B");
5407 TYPE_THEN `!y. (K y) ==> (?A B. (U A /\ U B /\ A x /\ B y /\ (A INTER B = {})))` SUBGOAL_TAC;
5410 DISCH_THEN MATCH_MP_TAC;
5414 REWRITE_TAC[DIFF;IN_ELIM_THM'];
5420 REWRITE_TAC[SUBSET;IN];
5428 REWRITE_TAC[DIFF;IN_ELIM_THM'];
5432 USE 6 (CONV_RULE (quant_left_CONV "B"));
5433 USE 6 (CONV_RULE (quant_left_CONV "B"));
5434 USE 6 (CONV_RULE (quant_left_CONV "B"));
5436 TYPE_THEN `IMAGE B K` (USE 3 o SPEC);
5437 TYPE_THEN `K SUBSET UNIONS (IMAGE B K) /\ IMAGE B K SUBSET U` SUBGOAL_TAC;
5439 REWRITE_TAC[SUBSET;UNIONS;IN_IMAGE;IN_ELIM_THM'];
5443 REWRITE_TAC[SUBSET;IN_IMAGE];
5445 CONV_TAC (quant_left_CONV "x'");
5446 CONV_TAC (quant_left_CONV "x'");
5455 USE 8 (MATCH_MP finite_subset);
5456 X_CHO 8 `kc:A->bool`;
5457 USE 6 (CONV_RULE (quant_left_CONV "A"));
5458 USE 6 (CONV_RULE (quant_left_CONV "A"));
5461 TYPE_THEN `K = EMPTY` ASM_CASES_TAC;
5463 USE 4 (REWRITE_RULE[DIFF_EMPTY]);
5464 EXISTS_TAC `C:A->bool`;
5465 ASM_REWRITE_TAC[SUBSET_REFL];
5467 USE 0 (REWRITE_RULE[topology]);
5469 MESON_TAC[topology;IN;SUBSET_REFL];
5470 TYPE_THEN `~(kc = EMPTY)` SUBGOAL_TAC;
5472 USE 10 (REWRITE_RULE[]);
5474 USE 8 (REWRITE_RULE[IMAGE_CLAUSES]);
5476 USE 3 (REWRITE_RULE[UNIONS_0;SUBSET_EMPTY]);
5478 REWRITE_TAC[EMPTY_EXISTS];
5479 DISCH_THEN CHOOSE_TAC;
5481 TYPE_THEN `INTERS (IMAGE A kc)` EXISTS_TAC;
5482 TYPE_THEN `INTERS (IMAGE A kc) INTER (UNIONS (IMAGE B kc)) = EMPTY` SUBGOAL_TAC;
5483 REWRITE_TAC[INTER;UNIONS];
5484 MATCH_MP_TAC EQ_EXT;
5486 REWRITE_TAC[IN_ELIM_THM';EMPTY];
5487 MATCH_MP_TAC (TAUT `(a ==> ~b )==> ~(a /\ b)`);
5488 REWRITE_TAC[IN_INTERS;IN_IMAGE];
5495 USE 12 (CONV_RULE (quant_left_CONV "x"));
5496 USE 12 (CONV_RULE (quant_left_CONV "x"));
5497 TYPE_THEN `x''` (USE 12 o SPEC);
5498 TYPE_THEN `A x''` (USE 12 o SPEC);
5501 TYPE_THEN `x''` (USE 6 o SPEC);
5502 TYPE_THEN `K x''` SUBGOAL_TAC;
5506 MESON_TAC[SUBSET;IN];
5509 USE 6 (REWRITE_RULE [INTER]);
5514 USE 6 (fun t-> AP_THM t `x':A`);
5515 USE 6 (REWRITE_RULE[IN_ELIM_THM';EMPTY]);
5521 REWRITE_TAC[DIFF_SUBSET];
5523 MATCH_MP_TAC INTERS_SUBSET2;
5524 TYPE_THEN `A u` EXISTS_TAC ;
5525 REWRITE_TAC[IMAGE;IN_ELIM_THM'];
5527 TYPE_THEN `u` EXISTS_TAC;
5529 MATCH_MP_TAC sub_union;
5530 TYPE_THEN `u` (USE 6 o SPEC);
5532 USE 12 (REWRITE_RULE[SUBSET;IN]);
5537 TYPE_THEN `a' = INTERS (IMAGE A kc)` ABBREV_TAC;
5538 TYPE_THEN `b' = UNIONS (IMAGE B kc)` ABBREV_TAC;
5539 SET_TAC[INTER;SUBSET;EMPTY];
5543 REWRITE_TAC[INTERS;IN_IMAGE;IN_ELIM_THM'];
5545 DISCH_THEN CHOOSE_TAC;
5546 TYPE_THEN `x'` (USE 6 o SPEC);
5548 USE 8 (REWRITE_RULE[SUBSET;IN]);
5550 MATCH_MP_TAC open_inters;
5553 REWRITE_TAC[SUBSET;IN_IMAGE;];
5556 DISCH_THEN CHOOSE_TAC;
5557 USE 6 (SPEC `x':A`);
5558 USE 8 (REWRITE_RULE[SUBSET;IN]);
5561 ASM_MESON_TAC[FINITE_IMAGE];
5562 REWRITE_TAC[EMPTY_EXISTS];
5563 TYPE_THEN `A u` EXISTS_TAC;
5564 REWRITE_TAC[IN_IMAGE];
5570 let compact_totally_bounded = prove_by_refinement(
5571 `!(X:A->bool) d.( metric_space(X,d)) /\ (compact (top_of_metric(X,d)) X)
5572 ==> (totally_bounded (X,d))`,
5575 REWRITE_TAC[totally_bounded;compact];
5578 CONV_TAC (quant_right_CONV "B");
5580 TYPE_THEN `IMAGE (\x. open_ball(X,d) x eps) X` (USE 2 o SPEC);
5581 TYPE_THEN `X SUBSET UNIONS (IMAGE (\x. open_ball (X,d) x eps) X)` SUBGOAL_TAC;
5582 (REWRITE_TAC[SUBSET;IN_UNIONS;IN_IMAGE]);
5587 CONV_TAC (quant_left_CONV "x'");
5588 CONV_TAC (quant_left_CONV "x'");
5589 TYPE_THEN `x` EXISTS_TAC;
5590 TYPE_THEN `open_ball (X,d) x eps` EXISTS_TAC;
5592 ASM_MESON_TAC[open_ball_nonempty;IN];
5596 TYPE_THEN `IMAGE (\x. open_ball (X,d) x eps) X SUBSET top_of_metric (X,d)` SUBGOAL_TAC;
5597 TYPE_THEN `IMAGE (\x. open_ball (X,d) x eps) X SUBSET open_balls(X,d)` SUBGOAL_TAC;
5598 REWRITE_TAC[SUBSET;IN_IMAGE;open_balls;IN_ELIM_THM'];
5600 MESON_TAC[SUBSET_TRANS;top_of_metric_open_balls];
5604 TYPE_THEN `W` EXISTS_TAC;
5609 USE 7 (REWRITE_RULE [SUBSET;IN_IMAGE]);
5611 MATCH_MP_TAC SUBSET_ANTISYM;
5613 TYPE_THEN `W SUBSET top_of_metric (X,d)` SUBGOAL_TAC;
5614 ASM_MESON_TAC[SUBSET_TRANS];
5616 USE 6 (MATCH_MP UNIONS_UNIONS);
5617 ASM_MESON_TAC[top_of_metric_unions];
5622 If W is empty then INTERS W = UNIV, rather than EMPTY.
5623 Thus, extra arguments must be provided for this case. *)
5625 let finite_inters = prove_by_refinement(
5626 `!U V . (topology_ U) /\ (compact U (UNIONS U)) /\ (INTERS V = EMPTY) /\
5627 (!(u:A->bool). (V u) ==> (closed_ U u))
5628 ==> (?W. (W SUBSET V) /\ (FINITE W) /\ (INTERS W = EMPTY))`,
5632 REWRITE_TAC[compact;SUBSET_REFL];
5636 TYPE_THEN `IMAGE (\r. ((UNIONS U) DIFF r)) V` (USE 1 o SPEC);
5637 TYPE_THEN `IMAGE (\r. UNIONS U DIFF r) V SUBSET U` SUBGOAL_TAC;
5638 REWRITE_TAC[IMAGE;SUBSET;IN_ELIM_THM'];
5640 DISCH_THEN CHOOSE_TAC;
5642 ASM_SIMP_TAC[top_univ;IN;SUBSET_DIFF];
5644 TYPE_THEN `x'` (USE 3 o SPEC);
5646 USE 3 (REWRITE_RULE[closed;open_DEF]);
5651 TYPE_THEN `UNIONS U SUBSET UNIONS (IMAGE (\r. UNIONS U DIFF r) V)` SUBGOAL_TAC;
5652 REWRITE_TAC[SUBSET;IN_UNIONS;IN_IMAGE];
5654 DISCH_THEN CHOOSE_TAC;
5656 USE 2 (REWRITE_RULE[INTERS_EQ_EMPTY]);
5657 TYPE_THEN `x` (USE 2 o SPEC);
5659 CONV_TAC (quant_left_CONV "x'");
5660 CONV_TAC (quant_left_CONV "x'");
5661 TYPE_THEN `a` EXISTS_TAC;
5662 TYPE_THEN `UNIONS U DIFF a` EXISTS_TAC ;
5663 ASM_REWRITE_TAC[IN];
5664 REWRITE_TAC[DIFF;IN_ELIM_THM';IN_UNIONS];
5672 (*** Modified by JRH for changed theorem name
5673 USE 6 (MATCH_MP FINITE_SUBSET_IMAGE);
5675 USE 6 (MATCH_MP FINITE_SUBSET_IMAGE_IMP);
5678 TYPE_THEN `s'={}` ASM_CASES_TAC ;
5680 USE 6 (REWRITE_RULE[IMAGE_CLAUSES;SUBSET_EMPTY]);
5682 USE 1 (REWRITE_RULE[UNIONS_0;SUBSET_EMPTY]);
5683 USE 1 (REWRITE_RULE [UNIONS_EQ_EMPTY]);
5685 DISCH_THEN DISJ_CASES_TAC;
5687 USE 4 (REWRITE_RULE[SUBSET_EMPTY;IMAGE;EQ_EMPTY;IN_ELIM_THM']);
5688 TYPE_THEN `V = {}` SUBGOAL_TAC;
5690 USE 8 (REWRITE_RULE[EMPTY_EXISTS]);
5692 USE 4 (CONV_RULE (quant_left_CONV "x'"));
5693 USE 4 (CONV_RULE (quant_left_CONV "x'"));
5694 TYPE_THEN `u` (USE 4 o SPEC);
5695 TYPE_THEN `UNIONS {} DIFF u` (USE 4 o SPEC);
5697 USE 2 (REWRITE_RULE[INTERS_EQ_EMPTY]);
5698 REWRITE_TAC[EQ_EMPTY];
5701 TYPE_THEN `V` EXISTS_TAC;
5702 ASM_REWRITE_TAC[SUBSET_REFL];
5703 USE 3 (REWRITE_RULE[closed;open_DEF]);
5705 USE 3 (REWRITE_RULE[REWRITE_RULE[IN] IN_SING]);
5706 TYPE_THEN `!u. V u ==> (u = EMPTY)` SUBGOAL_TAC;
5708 TYPE_THEN `u` (USE 3 o SPEC);
5711 ASM_MESON_TAC[ SUBSET_EMPTY;UNIONS_EQ_EMPTY];
5713 TYPE_THEN `V SUBSET {EMPTY}` SUBGOAL_TAC;
5714 REWRITE_TAC[INSERT_DEF];
5715 REWRITE_TAC[IN_ELIM_THM'];
5716 REWRITE_TAC[IN;EMPTY;SUBSET];
5717 ASM_MESON_TAC[IN;EMPTY];
5720 MESON_TAC[FINITE_SING;FINITE_SUBSET];
5722 TYPE_THEN `s'` EXISTS_TAC;
5723 ASM_REWRITE_TAC[INTERS_EQ_EMPTY];
5725 USE 7 (REWRITE_RULE[EMPTY_EXISTS]);
5727 TYPE_THEN `UNIONS U x` ASM_CASES_TAC ;
5728 TYPE_THEN `UNIONS W x` SUBGOAL_TAC;
5729 USE 1 (REWRITE_RULE[SUBSET;IN]);
5734 TYPE_THEN `UNIONS (IMAGE (\r. UNIONS U DIFF r) s') x` SUBGOAL_TAC;
5737 USE 6 (MATCH_MP UNIONS_UNIONS);
5738 USE 6 (REWRITE_RULE[SUBSET;IN]);
5740 REWRITE_TAC[UNIONS;IN_IMAGE;IN_ELIM_THM'];
5745 TYPE_THEN `S:A->bool` (X_CHO 10) ;
5749 TYPE_THEN `S` EXISTS_TAC;
5751 USE 10(REWRITE_RULE[REWRITE_RULE[IN] IN_DIFF]);
5753 TYPE_THEN `u` EXISTS_TAC;
5757 USE 9 (REWRITE_RULE[]);
5758 TYPE_THEN `V u` SUBGOAL_TAC;
5761 USE 11 (REWRITE_RULE[SUBSET;IN]);
5764 H_MATCH_MP (HYP "3") (HYP "10");
5765 USE 11(REWRITE_RULE[closed;open_DEF]);
5766 USE 11 (REWRITE_RULE [SUBSET;IN]);
5773 (* first part of the proof of cauchy_subseq *)
5774 let cauchy_subseq_sublemma = prove_by_refinement(
5775 `!(X:A->bool) d f. ((metric_space(X,d))/\(totally_bounded(X,d)) /\
5779 (!x y. X x /\ X y ==> d x y < R) /\
5781 (sn 0 = 0) /\ (Cn 0 = X) /\
5782 (!n. Cn n SUBSET X /\ cond (Cn n,sn n) n) /\
5783 (!n. Cn (SUC n) SUBSET Cn n /\ sn n <| sn (SUC n)) /\
5785 (~FINITE {j | C (f j)}) /\
5787 (!x y. (C x /\ C y) ==> d x y < R * (twopow (--: (&:n))))) =
5795 USE 3 (MATCH_MP totally_bounded_bounded);
5798 ALL_TAC; (* {{{ xxx *)
5799 ALL_TAC; (* make r pos *)
5800 ASSUME_TAC (REAL_ARITH `r <. (&.1 + abs(r))`);
5801 ASSUME_TAC (REAL_ARITH `&.0 <. (&.1 + abs(r))`);
5802 ABBREV_TAC (`r' = &.1 +. abs(r)`);
5803 SUBGOAL_TAC `open_ball(X,d) a r SUBSET open_ball(X,d) (a:A) r'`;
5804 ASM_SIMP_TAC[open_ball_nest];
5807 USE 3 (MATCH_MP SUBSET_TRANS);
5810 ALL_TAC; (* "cs1" *)
5811 SUBGOAL_TAC `( !(x:A) y. (X x) /\ (X y) ==> (d x y <. &.2 *. r'))`;
5813 USE 3 (REWRITE_RULE[SUBSET;IN]);
5817 H_MATCH_MP (HYP "3") (HYP "6");
5818 H_MATCH_MP (HYP "7") (HYP "4");
5821 USE 0 (MATCH_MP BALL_DIST);
5824 ABBREV_TAC `cond = (\ ((C:A->bool),(s:num)) n. ~FINITE{j| C (f j)} /\ (C(f s)) /\ (!x y. (C x /\ C y) ==> d x y <. (&.2*.r')*. twopow(--: (&:n))))`;
5825 ABBREV_TAC `R = (&.2)*r'`;
5826 ALL_TAC ; (* 0 case of recursio *)
5828 SUBGOAL_TAC ` (X SUBSET X) /\ (cond ((X:A->bool),0) 0)`;
5829 REWRITE_TAC[SUBSET_REFL];
5831 CONV_TAC (TOP_DEPTH_CONV GEN_BETA_CONV);
5832 USE 2 (REWRITE_RULE[sequence;SUBSET;IN_IMAGE;IN_UNIV]);
5833 USE 2 (REWRITE_RULE[IN]);
5834 USE 2 (CONV_RULE (NAME_CONFLICT_CONV));
5835 SUBGOAL_TAC `!x. X((f:num->A) x)`;
5838 REWRITE_TAC[TWOPOW_0] THEN REDUCE_TAC;
5841 SUBGOAL_TAC `{ j | (X:A->bool) (f j) } = (UNIV:num->bool)`;
5842 MATCH_MP_TAC EQ_EXT;
5843 REWRITE_TAC[IN_ELIM_THM;UNIV];
5845 DISCH_THEN REWRT_TAC;
5847 REWRITE_TAC[num_infinite];
5848 ALL_TAC; (* #save_goal "cs3" *)
5849 SUBGOAL_TAC `&.0 <. R`;
5854 SUBGOAL_TAC `!cs n. ?cs' . (FST cs SUBSET X) /\ (cond cs n)==>( (FST cs' SUBSET (FST cs)) /\(SND cs <| ((SND:((A->bool)#num)->num) cs') /\ (cond cs' (SUC n))) )`;
5856 CONV_TAC (quant_right_CONV "cs'");
5859 H_REWRITE_RULE[GSYM o (HYP "6")] (HYP "11");
5860 USE 13 (CONV_RULE (SUBS_CONV[GSYM(ISPEC `cs:(A->bool)#num` PAIR)]));
5861 USE 13 (CONV_RULE (TOP_DEPTH_CONV GEN_BETA_CONV));
5867 USE 0 (MATCH_MP subsequence_rec);
5870 EXISTS_TAC `(C':A->bool,s':num)`;
5871 ASM_REWRITE_TAC[FST;SND];
5873 (CONV_TAC (TOP_DEPTH_CONV GEN_BETA_CONV));
5876 ALL_TAC; (* "cs4" *)
5877 USE 11 (REWRITE_RULE[SKOLEM_THM]);
5879 ASSUME_TAC (ISPECL[`((X:A->bool),0)`;`cs':(((A->bool)#num)->(num->(A->bool)#num))`] num_RECURSION);
5881 ALL_TAC;(* EXISTS_TAC `\i. (SND ((fn : num->(A->bool)#num) i))`; *)
5882 USE 11 (CONV_RULE (quant_left_CONV "n"));
5883 USE 11 (SPEC `n:num`);
5884 USE 11 (SPEC `(fn:num->(A->bool)#num) n`);
5886 H_REWRITE_RULE[GSYM o (HYP "12")] (HYP "11");
5888 ABBREV_TAC `sn = (\i. SND ((fn:num->(A->bool)#num) i))`;
5889 ABBREV_TAC `Cn = (\i. FST ((fn:num->(A->bool)#num) i))`;
5890 SUBGOAL_TAC `((sn:num->num) 0 = 0) /\ (Cn 0 = (X:A->bool))`;
5898 SUBGOAL_TAC `!(n:num). ((fn n):(A->bool)#num) = (Cn n,sn n)`;
5903 H_REWRITE_RULE[(HYP "11")] (HYP"14");
5910 ALL_TAC; (* KILL 10; cs4m *)
5916 TYPE_THEN `!n. (Cn n SUBSET X) /\ (cond (Cn n,sn n) n)` SUBGOAL_TAC;
5920 USE 13 (SPEC `n:num`);
5923 ASM_MESON_TAC[SUBSET_TRANS];
5926 ALL_TAC; (* TO HERE EVERYTHING WORKS GENERALLY *)
5927 TYPE_THEN `R` EXISTS_TAC;
5928 TYPE_THEN `Cn` EXISTS_TAC;
5929 TYPE_THEN `sn` EXISTS_TAC;
5930 TYPE_THEN `cond` EXISTS_TAC;
5935 (* more on metric spaces and topology *)
5937 let subseq_cauchy = prove_by_refinement(
5938 `!(X:A->bool) d f s. (metric_space(X,d)) /\
5939 (cauchy_seq (X,d) f) /\ (subseq s) /\
5940 (converge(X,d) (f o s)) ==> (converge(X,d) f)`,
5943 REWRITE_TAC[cauchy_seq;converge;sequence_in];
5946 TYPE_THEN `x` EXISTS_TAC ;
5950 TYPE_THEN `eps/(&.2)` (USE 2 o SPEC);
5951 TYPE_THEN `eps/(&.2)` (USE 4 o SPEC);
5954 CONV_TAC (quant_right_CONV "n");
5956 USE 2 (REWRITE_RULE[REAL_LT_HALF1]);
5957 USE 4 (REWRITE_RULE[REAL_LT_HALF1]);
5960 TYPE_THEN `n'` EXISTS_TAC ;
5962 TYPE_THEN `n +| n'` (USE 4 o SPEC);
5963 USE 4 (REWRITE_RULE[ARITH_RULE `n <=| n +| n'`]);
5964 TYPE_THEN `s(n +| n')` (USE 2 o SPEC);
5965 TYPE_THEN `i` (USE 2 o SPEC);
5966 TYPE_THEN `n' <=| s (n +| n')` SUBGOAL_TAC;
5967 USE 3 (MATCH_MP SEQ_SUBLE);
5968 TYPE_THEN `n +| n'` (USE 3 o SPEC);
5969 ASM_MESON_TAC[ LE_TRANS; ARITH_RULE `n' <=| n +| n'`];
5972 USE 4 (REWRITE_RULE[o_DEF]);
5973 (* save_goal"sc1"; *)
5974 TYPEL_THEN [`X`;`d`;`x`;`f (s(n +| n'))`;`f i`] (fun t-> ASSUME_TAC (ISPECL t metric_space_triangle));
5975 USE 5 (REWRITE_RULE[IN]);
5977 USE 1 (MATCH_MP sequence_in);
5982 MP_TAC (SPEC `eps:real` REAL_HALF_DOUBLE);
5983 TYPE_THEN `a = d (f (s (n +| n'))) (f i)` ABBREV_TAC ;
5984 TYPE_THEN `b = d x (f (s (n +| n')))` ABBREV_TAC ;
5985 TYPE_THEN `c = d x (f i)` ABBREV_TAC ;
5990 let compact_complete = prove_by_refinement(
5991 `!(X:A->bool) d. metric_space(X,d) /\
5992 (compact (top_of_metric(X,d)) X) ==>
5997 REWRITE_TAC [complete];
6003 USE 3 (MATCH_MP compact_totally_bounded);
6005 USE 4 (REWRITE_RULE[cauchy_seq]);
6012 USE 6 (MATCH_MP cauchy_subseq_sublemma);
6025 MATCH_MP_TAC subseq_cauchy;
6026 TYPE_THEN `sn` EXISTS_TAC;
6027 ASM_REWRITE_TAC [converge];
6029 REWRITE_TAC[SUBSEQ_SUC];
6032 TYPE_THEN `~(INTERS {z | ?n. z = closed_ball(X,d) (f (sn n)) (R* twopow(--: (&:n)))} =EMPTY)` SUBGOAL_TAC;
6033 PROOF_BY_CONTR_TAC ;
6035 TYPEL_THEN [`top_of_metric(X,d)`;`{z | ?n. z = closed_ball (X,d) (f(sn n)) (R * twopow (--: (&:n)))}`] (fun t-> ASSUME_TAC (ISPECL t finite_inters));
6037 TYPE_THEN `topology_ (top_of_metric (X,d)) /\ compact (top_of_metric (X,d)) (UNIONS (top_of_metric (X,d))) /\ (!u. {z | ?n. z = closed_ball (X,d) (f(sn n)) (R * twopow (--: (&:n)))} u ==> closed_ (top_of_metric (X,d)) u)` SUBGOAL_TAC ;
6038 ASM_SIMP_TAC[GSYM top_of_metric_unions;];
6039 ASM_SIMP_TAC[top_of_metric_top];
6040 REWRITE_TAC[IN_ELIM_THM'];
6041 ASM_MESON_TAC[closed_ball_closed];
6046 TYPE_THEN `{z | ?n. z = closed_ball (X,d) (f (sn n)) (R * twopow (--: (&:n)))} = IMAGE (\n. closed_ball (X,d) (f (sn n)) (R * twopow (--: (&:n)))) (UNIV)` SUBGOAL_TAC ;
6047 MATCH_MP_TAC EQ_EXT;
6049 REWRITE_TAC[IN_ELIM_THM';INR IN_IMAGE;UNIV];
6055 (*** Modified by JRH for new theorem name
6056 USE 19 (MATCH_MP FINITE_SUBSET_IMAGE);
6058 USE 19 (MATCH_MP FINITE_SUBSET_IMAGE_IMP);
6062 (*** JRH --- originally for implicational num_FINITE:
6063 USE 20 (MATCH_MP num_FINITE);
6065 USE 20 (CONV_RULE (REWR_CONV num_FINITE));
6067 TYPE_THEN `f (sn a) IN (INTERS W)` SUBGOAL_TAC ;
6068 REWRITE_TAC[IN_INTERS];
6071 USE 19 (REWRITE_RULE [SUBSET;IN_IMAGE]);
6072 TYPE_THEN `t` (USE 19 o SPEC);
6073 USE 19 (REWRITE_RULE [IN]);
6076 USE 20 (SPEC `m:num`);
6077 USE 20 (REWRITE_RULE[IN]);
6079 TYPE_THEN `Cn m SUBSET closed_ball (X,d) (f (sn m)) (R * twopow (--: (&:m)))` SUBGOAL_TAC ;
6080 REWRITE_TAC[SUBSET;closed_ball;IN_ELIM_THM'];
6081 USE 12 (SPEC `m:num`);
6084 (CONV_TAC (TOP_DEPTH_CONV GEN_BETA_CONV));
6085 REWRITE_TAC[SUBSET];
6086 MESON_TAC[IN;REAL_ARITH `x <. y ==> x <=. y`];
6087 REWRITE_TAC[SUBSET;IN];
6088 DISCH_THEN (MATCH_MP_TAC );
6090 TYPE_THEN `Cn a SUBSET Cn m` SUBGOAL_TAC ;
6093 MESON_TAC [SUBSET_SUC2];
6094 REWRITE_TAC[SUBSET;IN];
6095 DISCH_THEN (MATCH_MP_TAC );
6096 USE 12 (SPEC `a:num`);
6100 (CONV_TAC (TOP_DEPTH_CONV GEN_BETA_CONV));
6102 ASM_REWRITE_TAC [NOT_IN_EMPTY];
6105 USE 15 (REWRITE_RULE[EMPTY_EXISTS]);
6107 TYPE_THEN `u` EXISTS_TAC ;
6110 USE 15 (REWRITE_RULE [IN_INTERS]);
6111 TYPE_THEN `closed_ball (X,d) (f (sn 0)) (R * twopow (--: (&:0)))` (USE 15 o SPEC);
6112 USE 15 (REWRITE_RULE[IN_ELIM_THM']);
6114 TYPE_THEN `0` (USE 15 o SPEC);
6115 USE 15 (REWRITE_RULE[IN;closed_ball]);
6116 USE 15 (REWRITE_RULE [IN_ELIM_THM']);
6120 CONV_TAC (quant_right_CONV "n");
6122 TYPEL_THEN [`(&.2)*R`;`eps`] (fun t-> ASSUME_TAC (ISPECL t twopow_eps));
6125 TYPE_THEN `n` EXISTS_TAC;
6127 TYPE_THEN `&0 < &2 * R ` SUBGOAL_TAC;
6128 MATCH_MP_TAC REAL_PROP_POS_MUL2;
6135 MATCH_MP_TAC (REAL_ARITH `x <= a ==> ((a < b) ==> (x < b))`);
6136 USE 15 (REWRITE_RULE[IN_INTERS]);
6137 TYPE_THEN `closed_ball (X,d) (f (sn n)) (R * twopow (--: (&:n)))` (USE 15 o SPEC);
6138 USE 15 (REWRITE_RULE[IN_ELIM_THM']);
6140 USE 15 (SPEC `n:num`);
6142 TYPE_THEN `Cn n SUBSET closed_ball (X,d) (f (sn n)) (R * twopow (--: (&:n)))` SUBGOAL_TAC ;
6143 REWRITE_TAC[SUBSET;closed_ball;IN_ELIM_THM'];
6144 USE 12 (SPEC `n:num`);
6147 (CONV_TAC (TOP_DEPTH_CONV GEN_BETA_CONV));
6148 REWRITE_TAC[SUBSET];
6149 MESON_TAC[IN;REAL_ARITH `x <. y ==> x <=. y`];
6151 TYPE_THEN `Cn i SUBSET Cn n` SUBGOAL_TAC ;
6154 MESON_TAC [SUBSET_SUC2];
6155 ALL_TAC ; (* REWRITE_TAC[SUBSET;IN];*)
6157 USE 12 (SPEC `i:num`);
6161 (CONV_TAC (TOP_DEPTH_CONV GEN_BETA_CONV));
6163 TYPE_THEN `((f o sn) i) IN closed_ball (X,d) (f (sn n)) (R * twopow (--: (&:n)))` SUBGOAL_TAC;
6171 USE 0 (MATCH_MP SUBSET_TRANS);
6172 ALL_TAC; (* "CC5"; *)
6173 ASM_MESON_TAC[IN;o_DEF;SUBSET];
6174 REWRITE_TAC[GSYM REAL_MUL_ASSOC];
6176 TYPE_THEN `r = R * twopow (--: (&:n))` ABBREV_TAC;
6179 MESON_TAC[BALL_DIST_CLOSED];
6184 let countable_cover = prove_by_refinement(
6185 `!(X:A->bool) d U. (metric_space(X,d)) /\ (totally_bounded(X,d)) /\
6186 (X SUBSET (UNIONS U)) /\ (U SUBSET (top_of_metric(X,d))) ==>
6187 (?V. (V SUBSET U) /\ (X SUBSET (UNIONS V)) /\ (COUNTABLE V))`,
6192 TYPE_THEN `(?Z. COUNTABLE Z /\ dense (top_of_metric (X,d)) Z)` SUBGOAL_TAC;
6193 ASM_MESON_TAC[countable_dense];
6196 TYPE_THEN `S = {(z,n) | ?A. (Z z) /\ (open_ball(X,d) z (twopow(--: (&:n))) SUBSET A) /\ U A}` ABBREV_TAC ;
6197 TYPE_THEN `COUNTABLE S` SUBGOAL_TAC;
6198 IMATCH_MP_TAC (INST_TYPE [`:A#num`,`:A`] COUNTABLE_IMAGE);
6199 TYPE_THEN `{(z,(n:num)) | (Z z) /\ (UNIV n)}` EXISTS_TAC ;
6201 IMATCH_MP_TAC countable_prod;
6202 ASM_REWRITE_TAC [NUM_COUNTABLE];
6203 TYPE_THEN `I:(A#num) -> (A#num)` EXISTS_TAC;
6204 REWRITE_TAC[IMAGE_I;UNIV;SUBSET];
6208 REWRITE_TAC[IN_ELIM_THM'];
6209 ASM_MESON_TAC[GSPEC];
6211 TYPE_THEN `!z n. (S (z,n) ==> ?A. Z z /\ open_ball (X,d) z (twopow (--: (&:n))) SUBSET A /\ U A)` SUBGOAL_TAC;
6213 REWRITE_TAC[IN_ELIM_THM'];
6219 TYPE_THEN `A` EXISTS_TAC;
6220 ASM_MESON_TAC[PAIR_EQ];
6226 ALL_TAC ; (* "cc1"; *)
6227 TYPE_THEN `IMAGE (\ (z,n). A z n) S` EXISTS_TAC;
6229 REWRITE_TAC[SUBSET;IN_IMAGE];
6231 TYPE_THEN `Azn:A->bool` X_GEN_TAC;
6232 DISCH_THEN (X_CHOOSE_TAC `zn:A#num`);
6233 USE 8 (SUBS [(ISPEC `zn:A#num` (GSYM PAIR))]);
6235 TYPE_THEN `z = FST zn` ABBREV_TAC ;
6236 TYPE_THEN `n = SND zn` ABBREV_TAC ;
6241 REWRITE_TAC[SUBSET];
6242 USE 2 (REWRITE_RULE[SUBSET;IN_UNIONS]);
6245 TYPE_THEN `x` ( USE 6 o SPEC);
6248 TYPE_THEN `top_of_metric (X,d) t` SUBGOAL_TAC;
6252 REWRITE_TAC[SUBSET;IN];
6254 ASM_SIMP_TAC[top_of_metric_nbd];
6256 TYPE_THEN `x` (USE 11 o SPEC);
6261 ASSUME_TAC (SPECL[`&.1`;`r:real`] twopow_eps);
6263 USE 13 (CONV_RULE REDUCE_CONV);
6265 TYPEL_THEN [`X`;`d`;`x`] (fun t-> USE 13 (MATCH_MP (SPECL t open_ball_nest)));
6267 USE 0 (MATCH_MP SUBSET_TRANS);
6268 ASSUME_TAC (SPEC `(--: (&:n))` twopow_pos);
6269 WITH 3 (MATCH_MP top_of_metric_top);
6274 USE 7 (MATCH_MP dense_subset);
6276 ASM_SIMP_TAC [dense_open];
6278 TYPE_THEN `(open_ball(X,d) x (twopow (--: (&:(n+1)))))` (USE 14 o SPEC);
6279 ALL_TAC ; (* "cc2"; *)
6280 TYPE_THEN `open_ball (X,d) x (twopow (--: (&:(n +| 1)))) x` SUBGOAL_TAC;
6281 IMATCH_MP_TAC open_ball_nonempty;
6284 TYPE_THEN `?z. (Z z) /\ (open_ball(X,d) x (twopow (--: (&:(n+1)))) z)` SUBGOAL_TAC;
6286 REWRITE_TAC[open_DEF];
6287 ASM_SIMP_TAC[open_ball_open];
6289 TYPE_THEN `B = open_ball (X,d) x (twopow (--: (&:(n +| 1))))` ABBREV_TAC ;
6290 REWRITE_TAC[INTER;IN];
6291 POP_ASSUM_LIST (fun t->ALL_TAC);
6292 REWRITE_TAC[EMPTY_NOT_EXISTS];
6293 REWRITE_TAC[IN_ELIM_THM'];
6298 WITH 3 (MATCH_MP top_of_metric_unions);
6301 TYPE_THEN `X z` SUBGOAL_TAC;
6304 MESON_TAC[SUBSET;IN];
6306 TYPE_THEN `open_ball (X,d) z (twopow (--: (&:(n +| 1)))) x` SUBGOAL_TAC;
6307 ASM_MESON_TAC[ball_symm];
6309 ALL_TAC ; (* "cc3"; *)
6310 REWRITE_TAC[UNIONS;IN_IMAGE;IN_ELIM_THM'];
6314 TYPE_THEN `(z,n+1)` EXISTS_TAC;
6315 TYPE_THEN `A z (n+1)` EXISTS_TAC;
6318 REWRITE_TAC[IN_ELIM_THM'];
6320 TYPE_THEN `z` EXISTS_TAC;
6322 TYPE_THEN `n + 1` EXISTS_TAC;
6325 TYPE_THEN `t` EXISTS_TAC;
6327 ALL_TAC ; (* "cc4"; *)
6329 TYPE_THEN `open_ball (X,d) z (twopow (--: (&:(n +| 1)))) SUBSET (open_ball (X,d) x (twopow (--: (&:n))))` SUBGOAL_TAC ;
6330 CONV_TAC (RAND_CONV (ONCE_REWRITE_CONV [(GSYM twopow_double)]));
6331 IMATCH_MP_TAC ball_subset_ball;
6334 MESON_TAC[SUBSET_TRANS];
6336 TYPEL_THEN [`z`;`n+1`] (fun t -> USE 10 (SPECL t));
6337 USE 10 (REWRITE_RULE [SUBSET ]);
6339 ALL_TAC ; (* "cc5" *)
6340 TYPE_THEN `S (z,n +| 1)` SUBGOAL_TAC ;
6342 REWRITE_TAC[IN_ELIM_THM' ];
6343 TYPE_THEN `z` EXISTS_TAC ;
6344 TYPE_THEN `n + 1` EXISTS_TAC;
6346 TYPE_THEN `t` EXISTS_TAC;
6351 TYPE_THEN `x` (USE 25 o SPEC );
6354 TYPE_THEN `S` ( fun t-> IMATCH_MP_TAC ( ISPEC t COUNTABLE_IMAGE)) ;
6356 TYPE_THEN `\ (z,n). A z n` EXISTS_TAC;
6357 REWRITE_TAC[SUBSET_REFL ];
6362 let complete_compact = prove_by_refinement(
6363 `!(X:A->bool) d . (metric_space(X,d)) /\ (totally_bounded(X,d)) /\
6364 (complete (X,d)) ==> (compact (top_of_metric(X,d)) X)`,
6368 REWRITE_TAC[compact];
6371 SIMP_TAC[GSYM top_of_metric_unions ];
6372 REWRITE_TAC[SUBSET_REFL];
6375 TYPE_THEN `(?V'. (V' SUBSET V) /\ (X SUBSET (UNIONS V')) /\ (COUNTABLE V'))` SUBGOAL_TAC ;
6376 IMATCH_MP_TAC countable_cover;
6377 TYPE_THEN `d` EXISTS_TAC;
6379 DISCH_THEN (CHOOSE_THEN MP_TAC);
6381 ALL_TAC; (* ASM_MESON_TAC[]; *)
6382 ALL_TAC; (* DISCH_THEN (CHOOSE_THEN MP_TAC); *)
6383 ALL_TAC; (* DISCH_ALL_TAC; *)
6384 USE 7 (REWRITE_RULE[COUNTABLE;GE_C;UNIV]);
6387 TYPE_THEN `B = \i. (IMAGE f { u | (u <=| i ) /\ V' (f u)}) ` ABBREV_TAC ;
6388 TYPE_THEN `?i . UNIONS (B i ) = X ` ASM_CASES_TAC;
6390 TYPE_THEN `B i ` EXISTS_TAC;
6393 REWRITE_TAC[IMAGE;SUBSET ;IN ];
6395 REWRITE_TAC[IN_ELIM_THM'];
6398 REWRITE_TAC[SUBSET;IN ];
6401 IMATCH_MP_TAC FINITE_IMAGE;
6402 IMATCH_MP_TAC FINITE_SUBSET;
6403 TYPE_THEN `{u | u <=| i }` EXISTS_TAC;
6404 REWRITE_TAC[FINITE_NUMSEG_LE;SUBSET;IN ;IN_ELIM_THM' ];
6407 DISCH_THEN (fun t-> REWRITE_TAC[GSYM t]);
6409 REWRITE_TAC[SUBSET_REFL ];
6410 ALL_TAC ; (* "sv1" *)
6412 TYPE_THEN `UNIONS V' SUBSET X` SUBGOAL_TAC;
6414 USE 2 (MATCH_MP SUBSET_TRANS );
6415 USE 2 (MATCH_MP UNIONS_UNIONS );
6417 ASM_MESON_TAC[top_of_metric_unions ];
6419 TYPE_THEN `!i. UNIONS (B i) SUBSET X` SUBGOAL_TAC;
6423 REWRITE_TAC[SUBSET;IN_UNIONS;IN_IMAGE ];
6424 REWRITE_TAC[IN;IN_ELIM_THM' ];
6431 USE 12 (REWRITE_RULE [GSYM PSUBSET ;PSUBSET_MEMBER;IN ]);
6435 ALL_TAC ; (* "sv2" *)
6436 TYPE_THEN `(?ss. subseq ss /\ converge (X,d) (y o ss))` SUBGOAL_TAC;
6437 IMATCH_MP_TAC convergent_subseq ;
6438 ASM_REWRITE_TAC[sequence];
6439 REWRITE_TAC[SUBSET;UNIV;IN_IMAGE ];
6446 USE 13 (REWRITE_RULE[converge;IN ]);
6449 USE 1 (REWRITE_RULE[SUBSET;UNIONS;IN;IN_ELIM_THM' ]);
6450 TYPE_THEN `x` (USE 1 o SPEC);
6453 TYPE_THEN `u` (USE 0 o SPEC);
6456 TYPE_THEN `(UNIONS (B j)) x` SUBGOAL_TAC;
6458 REWRITE_TAC[UNIONS;IN_IMAGE ];
6459 REWRITE_TAC[IN;IN_ELIM_THM' ];
6460 TYPE_THEN `u` EXISTS_TAC;
6462 TYPE_THEN `j` EXISTS_TAC;
6463 ASM_MESON_TAC[ARITH_RULE `j <=| j`];
6465 TYPE_THEN `u SUBSET (UNIONS (B j))` SUBGOAL_TAC;
6466 IMATCH_MP_TAC sub_union;
6468 REWRITE_TAC[IMAGE;IN;IN_ELIM_THM' ];
6469 TYPE_THEN `j` EXISTS_TAC;
6470 ASM_MESON_TAC[ARITH_RULE `j <=| j`];
6473 USE 2 (MATCH_MP SUBSET_TRANS);
6474 ALL_TAC ; (* "sv3" *)
6475 TYPE_THEN `top_of_metric(X,d) u` SUBGOAL_TAC;
6476 USE 2 (REWRITE_RULE[SUBSET;IN ]);
6478 ASM_SIMP_TAC[top_of_metric_nbd];
6481 TYPE_THEN `x` (USE 19 o SPEC);
6485 TYPE_THEN `r` (USE 13 o SPEC);
6489 TYPE_THEN `n +| (j)` (USE 13 o SPEC);
6490 USE 13 (REWRITE_RULE[ARITH_RULE `n<=| (n+| a)`]);
6492 TYPE_THEN `u ((y o ss) (n +| j) )` SUBGOAL_TAC;
6493 USE 19 (REWRITE_RULE[SUBSET;open_ball;IN ;IN_ELIM_THM' ]);
6494 TYPE_THEN `((y o ss) (n +| j))` (USE 19 o SPEC);
6497 DISCH_THEN IMATCH_MP_TAC ;
6499 TYPE_THEN `(ss (n +| j))` (USE 12 o SPEC);
6500 ASM_REWRITE_TAC[o_DEF ];
6502 TYPE_THEN `z = ((y o ss) (n +| j))` ABBREV_TAC;
6503 TYPE_THEN `UNIONS (B (ss (n+| j))) ((y o ss) (n +| j))` SUBGOAL_TAC;
6506 REWRITE_TAC[UNIONS;IN_IMAGE];
6507 REWRITE_TAC[IN; IN_ELIM_THM'];
6508 TYPE_THEN `u` EXISTS_TAC;
6510 TYPE_THEN `j` EXISTS_TAC;
6512 IMATCH_MP_TAC (ARITH_RULE `j <= a /\ a <= ss(a) ==> (j <=| (ss (a)))`);
6513 ASM_SIMP_TAC[SEQ_SUBLE];
6516 TYPE_THEN `ss(n +| j)` (USE 12 o SPEC);
6522 let uniformly_continuous = euclid_def
6523 `uniformly_continuous (f:A->B) ((X:A->bool),dX) ((Y:B->bool),dY) <=>
6524 (!epsilon. ?delta. (&.0 < epsilon) ==> (&.0 <. delta) /\
6525 (!x y. (X x) /\ (X y) /\
6526 (dX x y < delta) ==> (dY (f x) (f y) < epsilon)))`;;
6528 (* NB. It is not part of the hypothesis on metric_continuous
6529 that the IMAGE of f on X is contained in Y. Hence the
6530 extra hypothesis. *)
6532 let compact_uniformly_continuous = prove_by_refinement(
6533 `!f X dX Y dY. metric_continuous f (X,dX) (Y,dY) /\ (metric_space(X,dX))
6534 /\ (metric_space(Y,dY)) /\ (compact(top_of_metric(X,dX)) X) /\
6535 (IMAGE f X SUBSET Y) ==>
6536 uniformly_continuous (f:A->B) ((X:A->bool),dX) ((Y:B->bool),dY)`,
6540 REWRITE_TAC[uniformly_continuous;metric_continuous;metric_continuous_pt];
6544 TYPE_THEN `epsilon/(&.2)` (USE 0 o SPEC);
6547 TYPE_THEN `cov = IMAGE (\x. open_ball (X,dX) x ((delta x)/(&.2))) X` ABBREV_TAC;
6548 USE 3 (REWRITE_RULE[compact]);
6550 ASM_SIMP_TAC[GSYM top_of_metric_unions;SUBSET_REFL ];
6552 TYPE_THEN `cov` (USE 3 o SPEC);
6553 CONV_TAC (quant_right_CONV "delta");
6555 WITH 6 (ONCE_REWRITE_RULE [GSYM REAL_LT_HALF1]);
6557 TYPE_THEN `!x. (&.0 < (delta x)/(&.2))` SUBGOAL_TAC;
6558 ASM_MESON_TAC[REAL_LT_HALF1];
6560 TYPE_THEN `X SUBSET UNIONS cov /\ cov SUBSET top_of_metric (X,dX)` SUBGOAL_TAC;
6562 REWRITE_TAC[SUBSET;UNIONS;IN;IN_ELIM_THM' ];
6564 TYPE_THEN `open_ball (X,dX) x ((delta x)/(&.2))` EXISTS_TAC;
6567 REWRITE_TAC[IMAGE;IN ;IN_ELIM_THM' ];
6569 IMATCH_MP_TAC (REWRITE_RULE[IN] open_ball_nonempty);
6572 REWRITE_TAC[SUBSET;IN ];
6574 REWRITE_TAC[IMAGE;IN;IN_ELIM_THM' ];
6580 ASM_MESON_TAC[open_ball_open];
6584 ALL_TAC; (* "cc1"; *)
6591 (*** Modified by JRH for changed theorem name
6592 USE 10 (MATCH_MP FINITE_SUBSET_IMAGE);
6594 USE 10 (MATCH_MP FINITE_SUBSET_IMAGE_IMP);
6595 X_CHO 10 `S:A->bool`;
6596 TYPE_THEN `ds = IMAGE delta S` ABBREV_TAC ;
6597 TYPE_THEN `(FINITE ds) /\ ( !x. (ds x) ==> (&.0 <. x) )` SUBGOAL_TAC;
6600 IMATCH_MP_TAC FINITE_IMAGE ;
6602 REWRITE_TAC[IMAGE;IN;IN_ELIM_THM' ];
6608 USE 12 (MATCH_MP min_finite_delta);
6610 TYPE_THEN `delta'/(&.2)` EXISTS_TAC;
6612 ALL_TAC ; (* "cc2" *)
6613 ASM_REWRITE_TAC[REAL_LT_HALF1];
6617 USE 10( MATCH_MP UNIONS_UNIONS );
6619 USE 3 (MATCH_MP SUBSET_TRANS);
6620 USE 3 (REWRITE_RULE [SUBSET;IN;UNIONS;IN_ELIM_THM' ]);
6621 USE 3 (REWRITE_RULE[IMAGE;IN ;IN_ELIM_THM' ]);
6622 TYPE_THEN `x` (WITH 3 o SPEC);
6623 TYPE_THEN `y` (WITH 3 o SPEC);
6624 KILL 3; (* start of yest *)
6625 H_MATCH_MP (HYP "18")(HYP "14");
6626 H_MATCH_MP (HYP "10") (HYP "13");
6632 USE 20 (REWRITE_RULE [open_ball]);
6634 USE 19 (REWRITE_RULE [IN_ELIM_THM']);
6637 TYPE_THEN `dX x' x < delta x'` SUBGOAL_TAC;
6639 IMATCH_MP_TAC (REAL_ARITH `((u <. v) ==> (a< u)==>(a <v))`);
6640 TYPE_THEN `x'` (USE 8 o SPEC);
6642 REWRITE_TAC[REAL_LT_HALF2;REAL_LT_HALF1 ];
6645 TYPE_THEN `dX x' y < delta x'` SUBGOAL_TAC;
6646 CONV_TAC (RAND_CONV (ONCE_REWRITE_CONV [GSYM REAL_HALF_DOUBLE]));
6647 IMATCH_MP_TAC (REAL_ARITH `(dX x' x <. u) /\ (dX x y <. u) /\ (dX x' y <= dX x' x +. dX x y) ==> (dX x' y <. u + u)`);
6651 IMATCH_MP_TAC (REAL_ARITH `((u <=. v) ==> (a< u)==>(a <v))`);
6652 IMATCH_MP_TAC (REAL_ARITH `(u + u) <= (v +. v) ==> (u <= v)`);
6653 REWRITE_TAC[REAL_HALF_DOUBLE];
6656 DISCH_THEN (MATCH_MP_TAC);
6658 REWRITE_TAC[IMAGE;IN; IN_ELIM_THM' ];
6661 IMATCH_MP_TAC metric_space_triangle;
6662 TYPE_THEN `X` EXISTS_TAC;
6665 CONV_TAC (RAND_CONV (ONCE_REWRITE_CONV [GSYM REAL_HALF_DOUBLE]));
6666 TYPE_THEN `(dY (f x) (f x') <. u0) /\ (dY (f x') (f y) <. u0) /\ (dY (f x) (f y) <= (dY (f x) (f x')) + (dY (f x') (f y))) ==> ((dY (f x) (f y)) < u0 + u0)` (fun t-> (IMATCH_MP_TAC (REAL_ARITH t)));
6667 TYPE_THEN `x'` (USE 0 o SPEC);
6669 USE 0 (REWRITE_RULE[IN ]);
6670 TYPE_THEN `y` (WITH 0 o SPEC);
6671 TYPE_THEN `x` (USE 0 o SPEC);
6673 TYPE_THEN `Y (f x) /\ Y (f y) /\ Y (f x')` SUBGOAL_TAC;
6675 REWRITE_TAC[SUBSET;IN_IMAGE; ];
6683 TYPE_THEN `dY (f x) (f x') = dY (f x') (f x)` SUBGOAL_TAC;
6687 TYPEL_THEN [`Y`;`dY`;`f x`;`f x'`] (fun t-> MP_TAC(ISPECL t metric_space_symm));
6689 DISCH_THEN (fun t-> REWRITE_TAC[t]);
6691 DISCH_THEN IMATCH_MP_TAC ;
6695 DISCH_THEN IMATCH_MP_TAC ;
6697 TYPEL_THEN [`Y`;`dY`;`f x`;`f x'`;`f y`] (fun t-> MP_TAC(ISPECL t metric_space_triangle));
6698 DISCH_THEN IMATCH_MP_TAC ;
6704 (* I'm rather surprised that this lemma did not need the
6705 hypothesis that U and- V are topologies. *)
6707 let image_compact = prove_by_refinement(
6708 `!U V (f:A->B) K. (continuous f U V ) /\
6709 (compact U K) /\ (IMAGE f K SUBSET (UNIONS V))
6710 ==> (compact V (IMAGE f K))`,
6714 REWRITE_TAC[compact];
6717 TYPE_THEN `cov = IMAGE (\v. preimage (UNIONS U) f v ) V'` ABBREV_TAC ;
6718 TYPE_THEN `cov SUBSET U` SUBGOAL_TAC ;
6720 REWRITE_TAC[SUBSET;IN_IMAGE ];
6727 USE 4 (REWRITE_RULE[SUBSET]);
6728 TYPE_THEN `x'` (USE 4 o SPEC);
6732 REWRITE_TAC[continuous];
6734 TYPE_THEN `K SUBSET UNIONS cov` SUBGOAL_TAC;
6737 REWRITE_TAC[SUBSET;IN_IMAGE ];
6744 TYPE_THEN `x'` (USE 3 o SPEC);
6745 TYPE_THEN `f x'` (USE 3 o SPEC);
6748 REWRITE_TAC[UNIONS;IN;IN_ELIM_THM' ];
6749 USE 5 (REWRITE_RULE[IMAGE]);
6751 REWRITE_TAC[IN_ELIM_THM';IN ];
6754 CONV_TAC (quant_left_CONV "x");
6755 CONV_TAC (quant_left_CONV "x");
6756 TYPE_THEN `u` EXISTS_TAC;
6758 TYPE_THEN `preimage (UNIONS U) f u` EXISTS_TAC;
6759 ASM_REWRITE_TAC[preimage;IN_ELIM_THM' ;IN ];
6760 USE 1 (REWRITE_RULE[compact;SUBSET;IN ]);
6766 USE 1 (REWRITE_RULE[compact]);
6768 TYPE_THEN `cov` (USE 1 o SPEC);
6772 TYPE_THEN `(?V''. V'' SUBSET V' /\ FINITE V'' /\ (W = IMAGE (\v. preimage (UNIONS U) f v) V''))` SUBGOAL_TAC;
6773 IMATCH_MP_TAC finite_subset ;
6777 TYPE_THEN `V''` EXISTS_TAC;
6779 REWRITE_TAC[SUBSET;IN_IMAGE];
6780 REWRITE_TAC[IN;UNIONS;IN_ELIM_THM' ];
6782 CONV_TAC (quant_left_CONV "x'");
6783 CONV_TAC (quant_left_CONV "x'");
6788 USE 1 (REWRITE_RULE[SUBSET;UNIONS;IN;IN_ELIM_THM' ]);
6789 TYPE_THEN `x'` (USE 1 o SPEC);
6793 USE 14 (REWRITE_RULE[IMAGE;IN ;IN_ELIM_THM' ]);
6794 TYPE_THEN `u':B->bool` (X_CHO 14);
6795 TYPE_THEN `u'` EXISTS_TAC;
6798 ASM_REWRITE_TAC[preimage;IN;IN_ELIM_THM' ];
6803 let metric_bounded = euclid_def
6804 `metric_bounded (X,d) <=>
6805 ?(x:A) r. X SUBSET (open_ball(X,d) x r)`;;
6807 let euclid_ball_cube = prove_by_refinement(
6808 `!n x r. ?N. (open_ball(euclid n,d_euclid) x r) SUBSET
6809 {x | euclid n x /\ (!i. abs (x i) <= &N)}`,
6813 REWRITE_TAC[SUBSET;IN;IN_ELIM_THM';open_ball; ];
6814 ASSUME_TAC REAL_ARCH_SIMPLE;
6815 TYPE_THEN ` (d_euclid x (\i. &.0) +. r)` (USE 0 o SPEC);
6817 TYPE_THEN `N` EXISTS_TAC;
6821 ASSUME_TAC proj_contraction;
6822 TYPEL_THEN [`n`;`x'`;`(\(i :num). &.0)`;`i`] (USE 4 o SPECL);
6824 USE 4 (CONV_RULE REDUCE_CONV );
6825 TYPE_THEN `euclid n (\i. &.0)` SUBGOAL_TAC ;
6826 REWRITE_TAC[euclid];
6829 ASSUME_TAC metric_euclid;
6830 TYPE_THEN `n` (USE 6 o SPEC);
6831 TYPE_THEN `d_euclid x' (\i. &.0) <=. d_euclid x' x + d_euclid x (\i. &0)` SUBGOAL_TAC;
6832 IMATCH_MP_TAC metric_space_triangle;
6833 TYPE_THEN `euclid n` EXISTS_TAC;
6835 TYPE_THEN `d_euclid x' x = d_euclid x x'` SUBGOAL_TAC;
6836 IMATCH_MP_TAC metric_space_symm;
6837 TYPE_THEN `euclid n` EXISTS_TAC;
6846 let totally_bounded_euclid = prove_by_refinement(
6847 `!X n. (metric_bounded (X,d_euclid) /\
6848 (X SUBSET (euclid n))) ==>
6849 (totally_bounded (X,d_euclid))`,
6852 REWRITE_TAC[metric_bounded];
6854 IMATCH_MP_TAC totally_bounded_subset;
6857 ASSUME_TAC euclid_ball_cube;
6858 TYPEL_THEN [`n`;`x`;`r`] (USE 2 o SPECL);
6860 ASSUME_TAC open_ball_subspace;
6861 TYPEL_THEN [`euclid n`;`X`;`d_euclid`;`x`;`r`] (USE 3 o ISPECL);
6864 USE 0 (MATCH_MP SUBSET_TRANS);
6866 USE 0 (MATCH_MP SUBSET_TRANS);
6867 TYPE_THEN `{x | euclid n x /\ (!i. abs (x i) <= &N)}` EXISTS_TAC;
6868 ASM_REWRITE_TAC[totally_bounded_cube ];
6869 IMATCH_MP_TAC metric_subspace;
6870 TYPE_THEN `euclid n` EXISTS_TAC;
6871 REWRITE_TAC[metric_euclid];
6872 REWRITE_TAC[SUBSET;IN;IN_ELIM_THM' ];
6877 (* topology is not needed as an assumption here! *)
6878 let induced_compact = prove_by_refinement(
6879 `!U (K:A->bool). (K SUBSET (UNIONS U)) ==>
6880 (compact U K <=> (compact (induced_top U K) K))`,
6885 ASM_REWRITE_TAC[compact];
6888 ASM_REWRITE_TAC[induced_top_support;SUBSET_INTER;SUBSET_REFL ];
6890 USE 3 (REWRITE_RULE[induced_top;SUBSET;IN_IMAGE ]);
6893 X_CHO 3 `u:(A->bool)->(A->bool)`;
6894 TYPE_THEN `IMAGE u V` (USE 1 o SPEC);
6895 TYPE_THEN `K SUBSET UNIONS (IMAGE u V) /\ IMAGE u V SUBSET U` SUBGOAL_TAC;
6896 REWRITE_TAC[IMAGE;SUBSET;IN_UNIONS;IN_ELIM_THM' ];
6900 USE 2 (REWRITE_RULE[SUBSET;IN_UNIONS ]);
6901 USE 2 (REWRITE_RULE[IN ]);
6902 TYPE_THEN `x` (USE 2 o SPEC);
6904 X_CHO 2 `v:A->bool`;
6906 CONV_TAC (quant_left_CONV "x'");
6907 CONV_TAC (quant_left_CONV "x'");
6908 TYPE_THEN `v` EXISTS_TAC;
6909 TYPE_THEN `u v` EXISTS_TAC;
6911 TYPE_THEN `v` (USE 3 o SPEC);
6912 USE 3 (REWRITE_RULE[IN]);
6914 ASSUME_TAC INTER_SUBSET;
6916 TYPEL_THEN [`u v`;`K`] (USE 5 o ISPECL);
6917 ASM_MESON_TAC[SUBSET;IN];
6927 (*** Modified by JRH for changed theorem name
6928 USE 5 (MATCH_MP FINITE_SUBSET_IMAGE);
6930 USE 5 (MATCH_MP FINITE_SUBSET_IMAGE_IMP);
6931 X_CHO 5 `W':(A->bool)->bool`;
6932 TYPE_THEN `W'` EXISTS_TAC;
6934 TYPE_THEN `K SUBSET UNIONS (IMAGE u W')` SUBGOAL_TAC;
6935 ASM_MESON_TAC[UNIONS_UNIONS ;SUBSET_TRANS];
6936 REWRITE_TAC[SUBSET;IN_UNIONS;IN_IMAGE; ];
6941 TYPE_THEN `x'` (USE 6 o SPEC);
6948 USE 10 (REWRITE_RULE[SUBSET;IN ]);
6949 TYPE_THEN `x''` (USE 10 o SPEC);
6951 USE 3 (REWRITE_RULE[IN]);
6952 TYPE_THEN `x''` (USE 3 o SPEC);
6954 TYPE_THEN `x''` EXISTS_TAC;
6956 ASM ONCE_REWRITE_TAC[];
6957 REWRITE_TAC[INTER;IN;IN_ELIM_THM' ];
6962 TYPE_THEN `VK = IMAGE (\b. (b INTER K)) V` ABBREV_TAC ;
6963 TYPE_THEN `VK` (USE 2 o SPEC);
6964 TYPE_THEN `K SUBSET UNIONS VK /\ VK SUBSET induced_top U K` SUBGOAL_TAC;
6967 REWRITE_TAC[INTER_THM;GSYM UNIONS_INTER ];
6968 ASM_REWRITE_TAC[SUBSET_INTER;SUBSET_REFL ]; (* end of branch *)
6969 REWRITE_TAC[induced_top];
6971 REWRITE_TAC[INTER_THM ];
6972 IMATCH_MP_TAC IMAGE_SUBSET;
6976 X_CHO 2 `WK:(A->bool)->bool`;
6977 TYPEL_THEN [`V`;`(INTER) K`;`WK`] (fun t-> MP_TAC (ISPECL t finite_subset ));
6982 REWRITE_TAC[INTER_THM];
6986 TYPE_THEN `C` EXISTS_TAC;
6990 USE 2 (REWRITE_RULE[GSYM UNIONS_INTER]);
6992 TYPE_THEN `R = UNIONS C` ABBREV_TAC;
6998 let compact_euclid = prove_by_refinement(
6999 `!X n. (X SUBSET euclid n) ==>
7000 (compact (top_of_metric(euclid n,d_euclid)) X <=>
7001 (closed_ (top_of_metric(euclid n,d_euclid)) X /\
7002 (metric_bounded(X,d_euclid))))`,
7006 TYPE_THEN `top_of_metric (X,d_euclid) = induced_top (top_of_metric(euclid n,d_euclid)) X` SUBGOAL_TAC;
7007 IMATCH_MP_TAC (GSYM top_of_metric_induced);
7008 ASM_REWRITE_TAC[metric_euclid];
7010 TYPE_THEN `metric_space (X,d_euclid)` SUBGOAL_TAC ;
7011 ASM_MESON_TAC [metric_euclid;metric_subspace];
7016 IMATCH_MP_TAC compact_closed;
7017 SIMP_TAC [metric_euclid;metric_hausdorff;top_of_metric_top ];
7019 REWRITE_TAC[metric_bounded];
7020 IMATCH_MP_TAC totally_bounded_bounded;
7022 IMATCH_MP_TAC compact_totally_bounded ;
7024 ASM_MESON_TAC[induced_compact;top_of_metric_unions;metric_euclid ];
7026 TYPE_THEN `X SUBSET (UNIONS (top_of_metric (euclid n,d_euclid)))` SUBGOAL_TAC;
7027 ASM_MESON_TAC[top_of_metric_unions ; metric_euclid];
7028 ASM_SIMP_TAC [induced_compact ];
7029 ASSUME_TAC metric_euclid;
7031 TYPE_THEN `induced_top (top_of_metric(euclid n,d_euclid)) X = top_of_metric(X,d_euclid)` SUBGOAL_TAC;
7032 IMATCH_MP_TAC top_of_metric_induced;
7034 DISCH_THEN REWRT_TAC;
7035 IMATCH_MP_TAC complete_compact;
7038 ASM_MESON_TAC[totally_bounded_euclid];
7039 IMATCH_MP_TAC complete_closed;
7040 TYPE_THEN `n` EXISTS_TAC;
7046 let neg_continuous = prove_by_refinement(
7047 `!n. metric_continuous (euclid_neg) (euclid n,d_euclid) (euclid n,d_euclid)`,
7051 REWRITE_TAC[metric_continuous;metric_continuous_pt];
7055 TYPE_THEN `epsilon` EXISTS_TAC;
7056 ASM_REWRITE_TAC[IN ];
7058 REWRITE_TAC[d_euclid];
7059 REWRITE_TAC[euclid_neg_sum];
7060 REWRITE_TAC[norm_neg];
7061 REWRITE_TAC[GSYM d_euclid];
7066 let continuous_comp = prove_by_refinement(
7067 `!(f:A->B) (g:B->C) U V W.
7068 continuous f U V /\ continuous g V W /\
7069 (IMAGE f (UNIONS U) SUBSET (UNIONS V)) ==>
7070 continuous (g o f) U W`,
7074 REWRITE_TAC[continuous;IN;preimage];
7076 X_GEN_TAC `w :C->bool`;
7078 TYPE_THEN `w ` (USE 1 o SPEC);
7080 TYPE_THEN `{x | UNIONS V x /\ w (g x)}` (USE 0 o SPEC);
7082 USE 0 (REWRITE_RULE[IN_ELIM_THM' ]);
7083 REWRITE_TAC[o_DEF ];
7084 TYPE_THEN `U {x | UNIONS U x /\ UNIONS V (f x) /\ w (g (f x))} = U {x | UNIONS U x /\ w (g (f x))}` SUBGOAL_TAC;
7086 IMATCH_MP_TAC EQ_EXT;
7088 REWRITE_TAC[IN_ELIM_THM'];
7089 IMATCH_MP_TAC (TAUT `(a ==> b) ==> ((a /\ b /\ c) <=> (a /\ c ))`);
7090 TYPE_THEN `UU = UNIONS U ` ABBREV_TAC;
7091 TYPE_THEN `VV = UNIONS V` ABBREV_TAC ;
7092 USE 2 (REWRITE_RULE[SUBSET;IN_IMAGE ]);
7094 DISCH_THEN (fun t-> (USE 0 ( REWRITE_RULE[t])));
7101 let compact_max = prove_by_refinement(
7102 `!(f:A->(num->real)) U K.
7103 (continuous f U (top_of_metric(euclid 1,d_euclid))) /\
7104 (IMAGE f K SUBSET (euclid 1)) /\
7105 (compact U K) /\ ~(K=EMPTY)==>
7106 (?x. K x /\ (!y. (K y) ==> (f y 0 <= f x 0)))`,
7113 TYPE_THEN `euclid 1 = UNIONS (top_of_metric (euclid 1,d_euclid))` SUBGOAL_TAC;
7114 MESON_TAC[top_of_metric_unions;metric_euclid];
7115 DISCH_THEN (fun t-> USE 5 (ONCE_REWRITE_RULE[t]));
7119 WITH 0 (MATCH_MP image_compact);
7121 ASM_SIMP_TAC[compact_euclid];
7123 TYPE_THEN `P = (IMAGE (coord 0) (IMAGE f K))` ABBREV_TAC ;
7124 TYPE_THEN `(?s. !y. (?x. P x /\ y <. x) <=> y <. s)` SUBGOAL_TAC;
7125 IMATCH_MP_TAC REAL_SUP_EXISTS;
7127 USE 3 (REWRITE_RULE[EMPTY_EXISTS;IN ]);
7129 TYPE_THEN `f u 0` EXISTS_TAC;
7131 REWRITE_TAC[IMAGE;IN;IN_ELIM_THM';coord ];
7135 TYPE_THEN `u` EXISTS_TAC;
7137 USE 6 (REWRITE_RULE[metric_bounded;open_ball;SUBSET;IN_IMAGE ]);
7138 X_CHO 6 `x0:num->real`;
7140 USE 6 (REWRITE_RULE[IN;IN_ELIM_THM' ]);
7142 REWRITE_TAC[IMAGE;IN;IN_ELIM_THM';coord];
7144 TYPE_THEN `x0 0 +. r` EXISTS_TAC;
7146 X_CHO 8 `fx:num->real`;
7153 TYPE_THEN `x` (USE 6 o SPEC);
7154 TYPE_THEN `fx` (USE 6 o SPEC);
7156 TYPE_THEN `(d_euclid x0 (f x) = abs (x0 0 - (f x 0)))` SUBGOAL_TAC;
7157 IMATCH_MP_TAC euclid1_abs;
7158 USE 1 (REWRITE_RULE[SUBSET;IN ]);
7168 TYPE_THEN `(!u. (P u) ==> (u <=. sup P)) /\ (P (sup P))` SUBGOAL_TAC;
7174 TYPE_THEN `s = t` SUBGOAL_TAC;
7176 USE 10 (MATCH_MP (REAL_ARITH `~(s=t) ==> (s<. t) \/ (t <. s)`));
7177 TYPE_THEN `s ` (WITH 9 o SPEC);
7178 TYPE_THEN `t` (WITH 9 o SPEC);
7179 ASM_MESON_TAC[REAL_ARITH `~(x <. x)`];
7184 TYPE_THEN `t` (USE 8 o SPEC);
7186 REWRITE_TAC[REAL_ARITH `~(x <. x)`];
7189 TYPE_THEN `u` EXISTS_TAC;
7194 TYPE_THEN `~ (IMAGE f K) (t *# (dirac_delta 0))` SUBGOAL_TAC;
7199 ONCE_REWRITE_TAC[IMAGE];
7200 ONCE_REWRITE_TAC[IMAGE];
7201 ONCE_REWRITE_TAC[IMAGE];
7202 REWRITE_TAC[IN_ELIM_THM';IN];
7203 TYPE_THEN `t *# (dirac_delta 0)` EXISTS_TAC;
7206 REWRITE_TAC[coord_dirac];
7208 USE 4 (MATCH_MP closed_open);
7209 ASSUME_TAC (SPEC `1` metric_euclid);
7210 WITH 14 (MATCH_MP top_of_metric_unions);
7213 TYPE_THEN `z = t *# dirac_delta 0` ABBREV_TAC ;
7214 TYPE_THEN `(euclid 1 DIFF (IMAGE f K)) z` SUBGOAL_TAC ;
7215 REWRITE_TAC[REWRITE_RULE[IN] IN_DIFF];
7218 REWRITE_TAC[euclid;euclid_scale;dirac_delta];
7220 ASSUME_TAC (ARITH_RULE `1 <=| m ==> (~(0=m))`);
7226 DISCH_THEN (fun t-> ONCE_REWRITE_TAC [GSYM t]);
7228 REWRITE_TAC[open_DEF];
7229 ASM_SIMP_TAC[top_of_metric_nbd];
7232 TYPE_THEN `z` (USE 0 o SPEC);
7239 DISCH_THEN (fun t-> ONCE_REWRITE_TAC[GSYM t]);
7244 USE 0 (REWRITE_RULE[SUBSET;IN; open_ball;IN_ELIM_THM' ]);
7246 TYPE_THEN `(t- (r/(&.2)))*# (dirac_delta 0)` (USE 0 o SPEC);
7247 TYPE_THEN `euclid 1 z /\ euclid 1 ((t - r / &2) *# dirac_delta 0) /\ d_euclid z ((t - r / &2) *# dirac_delta 0) < r` SUBGOAL_TAC;
7250 REWRITE_TAC[euclid;dirac_delta;euclid_scale];
7252 SIMP_TAC [ (ARITH_RULE `1 <=| m ==> (~(0=m))`)];
7253 REWRITE_TAC[REAL_ARITH `t*(&.0) = (&.0)`];
7256 REWRITE_TAC[euclid;dirac_delta;euclid_scale];
7258 SIMP_TAC [ (ARITH_RULE `1 <=| m ==> (~(0=m))`)];
7259 REWRITE_TAC[REAL_ARITH `t*(&.0) = (&.0)`];
7262 SIMP_TAC[euclid1_abs];
7264 REWRITE_TAC[euclid_minus ; euclid_scale;dirac_delta ];
7266 REWRITE_TAC[REAL_ARITH `t - (t - (r/(&.2))) = r/(&.2)`];
7267 WITH 9 (ONCE_REWRITE_RULE[GSYM REAL_LT_HALF1]);
7268 WITH 19 (MATCH_MP (REAL_ARITH `&.0 < x ==> (&.0 <= x)`));
7269 WITH 20 (REWRITE_RULE[GSYM REAL_ABS_REFL]);
7271 REWRITE_TAC[REAL_LT_HALF2];
7273 DISCH_THEN (fun t-> (USE 0 (REWRITE_RULE[t])));
7275 TYPE_THEN `t - (r/(&.2)) ` (USE 10 o SPEC);
7276 TYPE_THEN `t - r / &2 < t` SUBGOAL_TAC;
7277 IMATCH_MP_TAC (REAL_ARITH `&.0 < x ==> (t - x < t)`);
7278 WITH 9 (ONCE_REWRITE_RULE[GSYM REAL_LT_HALF1]);
7283 TYPE_THEN `u` (USE 7 o SPEC);
7285 TYPE_THEN `(euclid 1 DIFF IMAGE f K) (u *# (dirac_delta 0))` SUBGOAL_TAC ;
7287 DISCH_THEN (IMATCH_MP_TAC );
7290 REWRITE_TAC[euclid;euclid_scale;dirac_delta];
7291 REWRITE_TAC[ (ARITH_RULE `1 <=| m <=> (~(0=m))`)];
7297 REWRITE_TAC[euclid;euclid_scale;dirac_delta];
7298 REWRITE_TAC[ (ARITH_RULE `1 <=| m <=> (~(0=m))`)];
7303 ASM_SIMP_TAC[euclid1_abs];
7305 REWRITE_TAC[dirac_delta;euclid_scale;euclid_minus];
7308 REWRITE_TAC[GSYM ABS_BETWEEN];
7315 IMATCH_MP_TAC (REAL_ARITH `y <. x ==> ((t - y <. u) ==> (t <. u + x))`);
7316 REWRITE_TAC[REAL_LT_HALF2];
7318 REWRITE_TAC[REWRITE_RULE[IN] IN_DIFF];
7319 IMATCH_MP_TAC (TAUT `B ==> (~(A /\ ~B))`);
7323 TYPE_THEN `B = IMAGE f K` ABBREV_TAC ;
7325 REWRITE_TAC[IMAGE;coord;IN;IN_ELIM_THM' ];
7330 USE 17 (REWRITE_RULE[SUBSET;IN]);
7331 TYPE_THEN `x` (USE 17 o SPEC);
7333 USE 17 (REWRITE_RULE[euclid1_dirac]);
7336 TYPE_THEN `t = sup P` ABBREV_TAC;
7341 ONCE_REWRITE_TAC[IMAGE];
7342 REWRITE_TAC[IN_IMAGE;IN_ELIM_THM';IN ];
7349 TYPE_THEN `x'` EXISTS_TAC;
7355 ONCE_REWRITE_TAC[IMAGE];
7356 REWRITE_TAC[IN_IMAGE;IN_ELIM_THM' ];
7362 TYPE_THEN `f y' 0` (USE 10 o SPEC);
7364 DISCH_THEN IMATCH_MP_TAC ;
7373 (* ------------------------------------------------------------------ *)
7374 (* homeomorphisms *)
7375 (* ------------------------------------------------------------------ *)
7377 let homeomorphism = euclid_def `homeomorphism (f:A->B) U V <=>
7378 (BIJ f (UNIONS U) (UNIONS V) ) /\ (continuous f U V) /\
7379 (!A. (U A) ==> (V (IMAGE f A)))`;;
7381 let INV_homeomorphism = prove_by_refinement(
7382 `!f U V. homeomorphism (f:A-> B) U V ==>
7383 (continuous (INV f (UNIONS U) (UNIONS V)) V U)`,
7387 REWRITE_TAC[continuous;IN;preimage];
7388 REWRITE_TAC[homeomorphism];
7390 X_GEN_TAC `u:A->bool`;
7392 TYPE_THEN `{ x | UNIONS V x /\ u (INV f (UNIONS U) (UNIONS V) x)} = IMAGE f u` SUBGOAL_TAC;
7393 IMATCH_MP_TAC EQ_EXT ;
7395 REWRITE_TAC[IN_ELIM_THM';IMAGE ;IN ];
7398 TYPE_THEN `(INV f (UNIONS U) (UNIONS V) t)` EXISTS_TAC;
7400 ASM_MESON_TAC[INVERSE_DEF;IN;BIJ ];
7404 USE 0 (REWRITE_RULE[BIJ;INJ]);
7409 TYPE_THEN `x` (USE 6 o SPEC);
7411 DISCH_THEN (IMATCH_MP_TAC );
7412 REWRITE_TAC[UNIONS;IN;IN_ELIM_THM' ];
7415 TYPE_THEN `INV f (UNIONS U) (UNIONS V) t = x` SUBGOAL_TAC;
7416 (* stop here this is an example that ASM_MESON_TAC should catch *)
7417 (* ASM_MESON_TAC[INVERSE_XY;IN ;UNIONS ]; *)
7418 TYPE_THEN `(UNIONS U x)` SUBGOAL_TAC;
7419 REWRITE_TAC[UNIONS;IN_ELIM_THM';IN ];
7421 ASM_MESON_TAC[INVERSE_XY;IN ];
7422 DISCH_THEN (fun t-> REWRITE_TAC[t]);
7424 DISCH_THEN (fun t-> REWRITE_TAC[t]);
7426 DISCH_THEN IMATCH_MP_TAC ;
7432 let bicont_homeomorphism = prove_by_refinement(
7433 `!f U V. (BIJ (f:A->B) (UNIONS U) (UNIONS V)) /\ (continuous f U V) /\
7434 (continuous (INV f (UNIONS U) (UNIONS V)) V U) ==>
7435 (homeomorphism f U V)`,
7439 REWRITE_TAC[homeomorphism];
7444 REWRITE_TAC[continuous;IN;preimage ];
7446 TYPE_THEN `A` (USE 2 o SPEC);
7448 TYPE_THEN `{x | UNIONS V x /\ A (INV f (UNIONS U) (UNIONS V) x)}= (IMAGE f A) ` SUBGOAL_TAC;
7449 IMATCH_MP_TAC EQ_EXT ;
7451 REWRITE_TAC[IN_ELIM_THM';IMAGE ;IN ];
7454 TYPE_THEN `(INV f (UNIONS U) (UNIONS V) t)` EXISTS_TAC;
7456 ASM_MESON_TAC[INVERSE_DEF;IN;BIJ ];
7460 USE 0 (REWRITE_RULE[BIJ;INJ]);
7465 TYPE_THEN `x` (USE 6 o SPEC);
7467 DISCH_THEN (IMATCH_MP_TAC );
7468 REWRITE_TAC[UNIONS;IN;IN_ELIM_THM' ];
7471 TYPE_THEN `INV f (UNIONS U) (UNIONS V) t = x` SUBGOAL_TAC;
7472 TYPE_THEN `(UNIONS U x)` SUBGOAL_TAC;
7473 REWRITE_TAC[UNIONS;IN_ELIM_THM';IN ];
7475 ASM_MESON_TAC[INVERSE_XY;IN ];
7476 DISCH_THEN (fun t-> REWRITE_TAC[t]);
7478 DISCH_THEN (fun t-> REWRITE_TAC[GSYM t]);
7484 let open_and_closed = prove_by_refinement(
7485 `!(f:A->B) U V. (topology_ U) /\ (topology_ V) /\
7486 (BIJ f (UNIONS U) (UNIONS V)) ==>
7487 ((!A. (U A ==> V (IMAGE f A))) <=>
7488 (!B. (closed_ U B) ==> (closed_ V (IMAGE f B))))`,
7493 REWRITE_TAC[closed];
7500 (* should have worked:
7501 ASM_MESON_TAC[SUBSET;IN;BIJ;INJ;IMAGE;IN_ELIM_THM' ];
7503 REWRITE_TAC[BIJ;IN;INJ;SUBSET;IMAGE;IN_ELIM_THM' ];
7506 TYPE_THEN `y:B` X_GEN_TAC;
7509 REWRITE_TAC[open_DEF];
7510 USE 5 (REWRITE_RULE[open_DEF]);
7511 TYPE_THEN `UNIONS U DIFF B` (USE 3 o SPEC);
7513 TYPE_THEN `IMAGE f (UNIONS U DIFF B) = (UNIONS V DIFF IMAGE f B)` SUBGOAL_TAC;
7514 ASM_MESON_TAC[DIFF_SURJ];
7516 REWRITE_TAC[open_DEF];
7519 TYPE_THEN `UNIONS U DIFF A` (USE 3 o SPEC);
7520 TYPE_THEN `UNIONS U DIFF A SUBSET UNIONS U /\ U (UNIONS U DIFF (UNIONS U DIFF A))` SUBGOAL_TAC;
7521 ASM_SIMP_TAC[sub_union ; DIFF_DIFF2 ];
7522 ASM_REWRITE_TAC[SUBSET_DIFF];
7525 TYPE_THEN `UNIONS V DIFF IMAGE f (UNIONS U DIFF A) = IMAGE f A` SUBGOAL_TAC;
7526 ASM_MESON_TAC[DIFF_SURJ; sub_union; DIFF_DIFF2];
7532 let hausdorff_homeomorphsim = prove_by_refinement(
7533 `!f U V. (BIJ (f:A->B) (UNIONS U) (UNIONS V)) /\ (continuous f U V) /\
7534 (compact U (UNIONS U)) /\ (hausdorff V) /\ (topology_ U) /\
7535 (topology_ V) ==> (homeomorphism f U V)`,
7539 ASM_REWRITE_TAC[homeomorphism];
7540 ASM_SIMP_TAC[open_and_closed];
7542 TYPEL_THEN [`U`;`UNIONS U`;`B`] (fun t-> ASSUME_TAC (SPECL t closed_compact));
7544 WITH 6 (REWRITE_RULE[closed]);
7546 IMATCH_MP_TAC compact_closed ;
7548 IMATCH_MP_TAC image_compact;
7549 TYPE_THEN `U` EXISTS_TAC;
7552 USE 0 (REWRITE_RULE[BIJ;INJ;IN ]);
7555 REWRITE_TAC[SUBSET;IN_IMAGE];
7557 USE 9 (REWRITE_RULE[SUBSET;IN]);
7563 (* ------------------------------------------------------------------ *)
7564 (* the metric and topology on the real numbers *)
7565 (* ------------------------------------------------------------------ *)
7567 let d_real = euclid_def `d_real x y = ||. (x -. y)`;;
7570 let real_topology = euclid_def
7571 `real_topology = top_of_metric (UNIV,d_real)`;;
7574 let metric_real = prove_by_refinement(
7575 `metric_space (UNIV,d_real)`,
7578 REWRITE_TAC[metric_space;UNIV;d_real ];
7583 let continuous_euclid1 = prove_by_refinement(
7584 `!i n. continuous (coord i)
7585 (top_of_metric (euclid n,d_euclid))
7586 (top_of_metric (UNIV,d_real))`,
7590 TYPE_THEN `!i n . IMAGE (coord i) (euclid n) SUBSET (UNIV) /\ metric_space (euclid n,d_euclid) /\ metric_space (UNIV,d_real)` SUBGOAL_TAC;
7592 REWRITE_TAC[UNIV ;SUBSET;IN];
7593 REWRITE_TAC[metric_euclid;metric_real;GSYM UNIV];
7596 TYPEL_THEN [`i`;`n`] (USE 0 o SPECL);
7597 USE 0 (IMATCH_MP metric_continuous_continuous);
7599 REWRITE_TAC[metric_continuous;metric_continuous_pt];
7603 REWRITE_TAC[d_real;IN;coord];
7604 TYPE_THEN `epsilon` EXISTS_TAC;
7609 IMATCH_MP_TAC (REAL_ARITH `(a <=. b) ==> ((b <. e) ==> (a <. e))`);
7610 ASM_MESON_TAC[proj_contraction];
7616 let interval_closed_ball = prove_by_refinement(
7617 `!a b . ? x r. (a <=. b) ==>
7618 ({x | euclid 1 x /\ a <= x 0 /\ x 0 <= b} =
7619 (closed_ball(euclid 1,d_euclid)) x r)`,
7623 TYPE_THEN `((a +b)/(&.2)) *# (dirac_delta 0)` EXISTS_TAC;
7624 TYPE_THEN `((b -a)/(&.2))` EXISTS_TAC;
7626 IMATCH_MP_TAC EQ_EXT;
7627 REWRITE_TAC[closed_ball;IN_ELIM_THM'];
7629 IMATCH_MP_TAC (TAUT `(a ==> (b <=> d /\ c)) ==> (a /\ b <=> d /\ a /\ c)`);
7631 TYPE_THEN `z = ((a + b) / &2 *# dirac_delta 0)` ABBREV_TAC;
7632 TYPE_THEN `euclid 1 z` SUBGOAL_TAC;
7634 MESON_TAC[euclid_dirac];
7637 ASM_SIMP_TAC[euclid1_abs];
7639 TYPE_THEN `t = x 0` ABBREV_TAC ;
7640 REWRITE_TAC[dirac_delta;euclid_scale];
7642 REWRITE_TAC[GSYM INTERVAL_ABS ];
7643 IMATCH_MP_TAC (TAUT `((a = d) /\ (b = C)) ==> ((a /\ b) <=> (C /\ d))`);
7644 ONCE_REWRITE_TAC[REAL_ARITH `((x <=. u + v) <=> (x - v <=. u)) /\ ((x - u <= v) <=> (x <=. v + u))`];
7646 TYPE_THEN `(a + b) / &2 - (b - a) / &2 = a` SUBGOAL_TAC ;
7647 REWRITE_TAC[real_div];
7648 REWRITE_TAC[REAL_ARITH `(a+b)*C - (b-a)*C = a*(&.2*C) `];
7650 DISCH_THEN (fun t-> REWRITE_TAC[t]);
7651 TYPE_THEN `(a+ b) /(&.2) + (b - a)/(&.2) = b` SUBGOAL_TAC;
7652 REWRITE_TAC[real_div];
7653 REWRITE_TAC[REAL_ARITH `(a+b) * C + (b - a) * C = b *(&.2*C)`];
7655 DISCH_THEN (fun t-> REWRITE_TAC[t]);
7659 let interval_euclid1_closed = prove_by_refinement(
7660 `!a b. closed_ (top_of_metric (euclid 1,d_euclid))
7661 {x | euclid 1 x /\ a <= x 0 /\ x 0 <= b}`,
7665 ASM_CASES_TAC `a <=. b`;
7666 ASSUME_TAC interval_closed_ball;
7667 TYPEL_THEN [`a`;`b`] (USE 1 o SPECL);
7672 IMATCH_MP_TAC closed_ball_closed;
7673 REWRITE_TAC[metric_euclid];
7674 TYPE_THEN `{x | euclid 1 x /\ a <= x 0 /\ x 0 <= b}= EMPTY ` SUBGOAL_TAC ;
7675 REWRITE_TAC[EQ_EMPTY;IN_ELIM_THM' ];
7677 TYPE_THEN `t = x 0 ` ABBREV_TAC;
7679 IMATCH_MP_TAC (TAUT `~(b /\ C) ==> ~( a /\ b/\ C)`);
7682 DISCH_THEN (fun t-> REWRITE_TAC[t]);
7683 IMATCH_MP_TAC empty_closed;
7684 IMATCH_MP_TAC top_of_metric_top ;
7685 REWRITE_TAC[metric_euclid];
7689 let interval_euclid1_bounded = prove_by_refinement(
7690 `!a b. metric_bounded
7691 ({x | euclid 1 x /\ a <= x 0 /\ x 0 <= b},d_euclid)`,
7695 REWRITE_TAC[metric_bounded];
7696 ASSUME_TAC interval_closed_ball;
7697 TYPEL_THEN [`a`;`b`] (USE 0 o SPECL);
7700 ASM_CASES_TAC `a <=. b`;
7703 TYPE_THEN `x` EXISTS_TAC;
7704 TYPE_THEN `r + (&.1) ` EXISTS_TAC;
7705 REWRITE_TAC[open_ball;SUBSET;IN ;IN_ELIM_THM' ];
7709 REWRITE_TAC[closed_ball;IN_ELIM_THM' ];
7713 ASM_SIMP_TAC[euclid1_abs ];
7714 TYPE_THEN `t = x 0` ABBREV_TAC;
7715 TYPE_THEN `s = x' 0` ABBREV_TAC;
7717 TYPE_THEN `&.0 <=. r` SUBGOAL_TAC;
7726 TYPE_THEN `{x | euclid 1 x /\ a <= x 0 /\ x 0 <= b} = EMPTY` SUBGOAL_TAC;
7727 REWRITE_TAC[EQ_EMPTY;IN_ELIM_THM' ];
7729 TYPE_THEN `t = x 0 ` ABBREV_TAC;
7731 IMATCH_MP_TAC (TAUT `~(b /\ C) ==> ~( a /\ b/\ C)`);
7734 DISCH_THEN (fun t-> REWRITE_TAC[t]);
7735 REWRITE_TAC[EMPTY_SUBSET];
7739 let interval_euclid1_compact = prove_by_refinement(
7740 `!a b. compact (top_of_metric(euclid 1,d_euclid))
7741 {x | (euclid 1 x) /\ (a <=. (x 0)) /\ (x 0 <= b)}`,
7745 TYPE_THEN `{x | euclid 1 x /\ a <= x 0 /\ x 0 <= b} SUBSET (euclid 1)` SUBGOAL_TAC;
7746 REWRITE_TAC [SUBSET;IN;IN_ELIM_THM' ];
7749 ASM_SIMP_TAC[compact_euclid];
7751 MATCH_ACCEPT_TAC interval_euclid1_closed;
7752 MATCH_ACCEPT_TAC interval_euclid1_bounded;
7756 let interval_image = prove_by_refinement(
7757 `!a b. {x | a <=. x /\ (x <= b)} =
7758 IMAGE (coord 0) {x | euclid 1 x /\ a <= x 0 /\ x 0 <= b}`,
7763 IMATCH_MP_TAC EQ_EXT;
7764 REWRITE_TAC[IN_ELIM_THM';IMAGE];
7768 TYPE_THEN `x *# (dirac_delta 0)` EXISTS_TAC;
7769 REWRITE_TAC[coord_dirac;euclid_dirac;dirac_0];
7773 USE 0 (REWRITE_RULE[coord]);
7779 let interval_compact = prove_by_refinement(
7780 `!a b. compact (top_of_metric (UNIV,d_real))
7781 {x | a <=. x /\ (x <=. b)} `,
7785 REWRITE_TAC[interval_image];
7786 IMATCH_MP_TAC image_compact;
7787 TYPE_THEN `(top_of_metric (euclid 1,d_euclid))` EXISTS_TAC;
7788 REWRITE_TAC[continuous_euclid1;interval_euclid1_compact];
7789 SIMP_TAC[GSYM top_of_metric_unions;metric_real];
7790 REWRITE_TAC[UNIV;SUBSET;IN];
7794 let half_open = prove_by_refinement(
7795 `!a. top_of_metric(UNIV,d_real ) { x | x <. a}`,
7799 ASSUME_TAC open_nbd ;
7800 TYPEL_THEN [`top_of_metric (UNIV,d_real)`;` {x | x < a}`] (USE 0 o ISPECL);
7801 USE 0 (SIMP_RULE[top_of_metric_top;metric_real ]);
7804 TYPE_THEN `open_ball (UNIV,d_real) x (a - x)` EXISTS_TAC;
7805 REWRITE_TAC[IN_ELIM_THM'];
7808 REWRITE_TAC[open_ball;d_real ;IN;IN_ELIM_THM';UNIV ;SUBSET ];
7813 IMATCH_MP_TAC (REWRITE_RULE[IN] open_ball_nonempty);
7814 REWRITE_TAC[metric_real; UNIV ];
7817 IMATCH_MP_TAC open_ball_open;
7818 REWRITE_TAC[metric_real];
7822 let half_open_above = prove_by_refinement(
7823 `!a. top_of_metric(UNIV,d_real ) { x | a <. x}`,
7827 ASSUME_TAC open_nbd ;
7828 TYPEL_THEN [`top_of_metric (UNIV,d_real)`;` {x | a <. x}`] (USE 0 o ISPECL);
7829 USE 0 (SIMP_RULE[top_of_metric_top;metric_real ]);
7832 TYPE_THEN `open_ball (UNIV,d_real) x (x -. a)` EXISTS_TAC;
7833 REWRITE_TAC[IN_ELIM_THM'];
7836 REWRITE_TAC[open_ball;d_real ;IN;IN_ELIM_THM';UNIV ;SUBSET ];
7841 IMATCH_MP_TAC (REWRITE_RULE[IN] open_ball_nonempty);
7842 REWRITE_TAC[metric_real; UNIV ];
7845 IMATCH_MP_TAC open_ball_open;
7846 REWRITE_TAC[metric_real];
7850 let joinf = euclid_def `joinf (f:real -> A) g a =
7851 (\ x . (if (x <. a) then (f x) else (g x)))`;;
7853 let joinf_cont = prove_by_refinement(
7854 `!U a (f:real -> A) g.
7855 (continuous f (top_of_metric(UNIV,d_real)) U) /\
7856 (continuous g (top_of_metric(UNIV,d_real)) U) /\
7858 ( (continuous (joinf f g a) (top_of_metric(UNIV,d_real)) U))`,
7861 REWRITE_TAC[continuous];
7865 ASSUME_TAC open_nbd;
7866 TYPEL_THEN [`top_of_metric (UNIV,d_real)`;`(preimage (UNIONS (top_of_metric (UNIV,d_real))) (joinf f g a) v)`] (USE 4 o ISPECL);
7867 USE 4 (SIMP_RULE [top_of_metric_top;metric_real ]);
7870 REWRITE_TAC[subset_preimage];
7873 SIMP_TAC[GSYM top_of_metric_unions; metric_real];
7874 REWRITE_TAC[SUBSET_UNIV];
7875 MP_TAC (REAL_ARITH `(x = a) \/ (x <. a) \/ (a <. x)`);
7877 TYPE_THEN `B = (preimage (UNIONS (top_of_metric (UNIV,d_real))) f v) INTER (preimage (UNIONS (top_of_metric (UNIV,d_real))) g v)` ABBREV_TAC ;
7878 TYPE_THEN `B` EXISTS_TAC;
7880 REWRITE_TAC[SUBSET;IN_IMAGE;IN ];
7888 REWRITE_TAC[INTER;IN_ELIM_THM';IN ];
7889 REWRITE_TAC[REWRITE_RULE[IN] in_preimage;joinf ];
7897 REWRITE_TAC[INTER;IN;IN_ELIM_THM'];
7898 REWRITE_TAC[REWRITE_RULE[IN] in_preimage];
7901 REWRITE_TAC[REAL_ARITH `~(a<. a)`];
7902 ASSUME_TAC top_of_metric_top;
7903 TYPEL_THEN [`UNIV:real -> bool`;`d_real `] (USE 8 o ISPECL);
7904 USE 8 (REWRITE_RULE[metric_real ]);
7905 USE 8 (REWRITE_RULE[topology]);
7908 TYPE_THEN `v` (USE 0 o SPEC);
7909 TYPE_THEN `v` (USE 1 o SPEC);
7911 (* 2nd case x < a *)
7912 TYPE_THEN `B = { x | x <. a } INTER (preimage (UNIONS (top_of_metric (UNIV,d_real))) f v)` ABBREV_TAC ;
7913 TYPE_THEN `B` EXISTS_TAC;
7915 ASM_REWRITE_TAC[SUBSET;IN_IMAGE ; IN;joinf ];
7923 REWRITE_TAC[INTER ;IN ;IN_ELIM_THM'];
7926 USE 10 (REWRITE_RULE[REWRITE_RULE[IN] in_preimage]);
7931 REWRITE_TAC[INTER;IN;IN_ELIM_THM'];
7932 REWRITE_TAC[REWRITE_RULE[IN] in_preimage];
7939 ASSUME_TAC top_of_metric_top;
7940 TYPEL_THEN [`UNIV:real -> bool`;`d_real `] (USE 8 o ISPECL);
7941 USE 8 (REWRITE_RULE[metric_real ]);
7942 USE 8 (REWRITE_RULE[topology]);
7943 TYPE_THEN `v` (USE 0 o SPEC);
7944 TYPE_THEN `v` (USE 1 o SPEC);
7951 TYPEL_THEN [`{x | x < a}`;`preimage (UNIONS (top_of_metric (UNIV,d_real))) f v`] (USE 8 o ISPECL);
7957 USE 0 (REWRITE_RULE[IN]);
7959 USE 5 (REWRITE_RULE[half_open]);
7962 TYPE_THEN `B = { x | a <. x } INTER (preimage (UNIONS (top_of_metric (UNIV,d_real))) g v)` ABBREV_TAC ;
7963 TYPE_THEN `B` EXISTS_TAC;
7965 ASM_REWRITE_TAC[SUBSET;IN_IMAGE ; IN;joinf ];
7973 REWRITE_TAC[INTER ;IN ;IN_ELIM_THM'];
7976 USE 10 (REWRITE_RULE[REWRITE_RULE[IN] in_preimage]);
7978 USE 9 (MATCH_MP (REAL_ARITH `a < x'' ==> (~(x'' <. a))`));
7983 REWRITE_TAC[INTER;IN;IN_ELIM_THM'];
7984 REWRITE_TAC[REWRITE_RULE[IN] in_preimage];
7990 USE 6 (MATCH_MP (REAL_ARITH `a < x'' ==> (~(x'' <. a))`));
7992 ASSUME_TAC top_of_metric_top;
7993 TYPEL_THEN [`UNIV:real -> bool`;`d_real `] (USE 8 o ISPECL);
7994 USE 8 (REWRITE_RULE[metric_real ]);
7995 USE 8 (REWRITE_RULE[topology]);
7996 TYPE_THEN `v` (USE 0 o SPEC);
7997 TYPE_THEN `v` (USE 1 o SPEC);
8004 TYPEL_THEN [`{x | a < x}`;`preimage (UNIONS (top_of_metric (UNIV,d_real))) g v`] (USE 8 o ISPECL);
8010 USE 1 (REWRITE_RULE[IN]);
8012 USE 5 (REWRITE_RULE[half_open_above]);
8017 let neg_cont = prove_by_refinement(
8019 (top_of_metric(UNIV,d_real)) (top_of_metric(UNIV,d_real)) `,
8022 TYPE_THEN `IMAGE ( --. ) (UNIV) SUBSET (UNIV)` SUBGOAL_TAC;
8023 REWRITE_TAC[SUBSET;IN;UNION;UNIV ];
8025 ASM_SIMP_TAC[metric_continuous_continuous;metric_real ];
8026 REWRITE_TAC[metric_continuous;metric_continuous_pt];
8028 TYPE_THEN `epsilon` EXISTS_TAC;
8030 ASM_REWRITE_TAC[UNIV;IN;d_real ];
8035 let add_cont = prove_by_refinement(
8036 `!u. (continuous ( (+.) u))
8037 (top_of_metric(UNIV,d_real)) (top_of_metric(UNIV,d_real)) `,
8042 TYPE_THEN `IMAGE ( (+.) u ) (UNIV) SUBSET (UNIV)` SUBGOAL_TAC;
8043 REWRITE_TAC[SUBSET;IN;UNION;UNIV ];
8045 ASM_SIMP_TAC[metric_continuous_continuous;metric_real ];
8046 REWRITE_TAC[metric_continuous;metric_continuous_pt];
8048 TYPE_THEN `epsilon` EXISTS_TAC;
8050 ASM_REWRITE_TAC[UNIV;IN;d_real ];
8056 let continuous_scale = prove_by_refinement(
8057 `!x n. (euclid n x) ==>
8058 (continuous (\t. (t *# x)) (top_of_metric(UNIV,d_real))
8059 (top_of_metric(euclid n,d_euclid)))`,
8064 ASSUME_TAC metric_euclid;
8065 ASSUME_TAC metric_real ;
8066 TYPE_THEN `IMAGE (\t. (t *# x)) (UNIV) SUBSET (euclid n)` SUBGOAL_TAC;
8067 REWRITE_TAC[SUBSET;IN_IMAGE;IN_ELIM_THM'];
8068 REWRITE_TAC[Q_ELIM_THM'';IN ; UNIV ];
8069 ASM_MESON_TAC[euclid_scale_closure];
8070 ASM_SIMP_TAC[metric_continuous_continuous];
8072 REWRITE_TAC[metric_continuous;metric_continuous_pt];
8074 REWRITE_TAC[IN;UNIV];
8075 TYPE_THEN `euclidean x` SUBGOAL_TAC;
8076 ASM_MESON_TAC[euclidean];
8077 ASM_SIMP_TAC[norm_scale;d_real];
8079 TYPE_THEN `norm x <=. &.1` ASM_CASES_TAC ;
8080 TYPE_THEN `epsilon` EXISTS_TAC;
8084 MP_TAC (SPEC `x' -. y` REAL_ABS_POS);
8086 USE 5 (MATCH_MP (SPEC `x' -. y` REAL_PROP_LE_LABS));
8087 USE 5 (CONV_RULE REDUCE_CONV);
8091 TYPE_THEN `epsilon / norm x` EXISTS_TAC;
8094 IMATCH_MP_TAC REAL_LT_DIV;
8099 ASM_MESON_TAC[REAL_ARITH `~(x <= &.1) ==> (&.0 <. x)`;REAL_LT_RDIV_EQ];
8104 let continuous_lin_combo = prove_by_refinement(
8105 `! x y n. (euclid n x) /\ (euclid n y) ==>
8106 (continuous (\t. (t *# x + (&.1 - t) *# y))
8107 (top_of_metric(UNIV,d_real))
8108 (top_of_metric(euclid n,d_euclid)))`,
8111 let comp_elim_tac = ( IMATCH_MP_TAC continuous_comp THEN
8112 TYPE_THEN `(top_of_metric (UNIV,d_real))` EXISTS_TAC THEN
8113 ASM_SIMP_TAC[add_cont;neg_cont;continuous_scale] THEN
8114 REWRITE_TAC[SUBSET;IN_IMAGE;Q_ELIM_THM''] THEN
8115 SIMP_TAC[GSYM top_of_metric_unions ;metric_real;IN_UNIV ] ) in
8118 IMATCH_MP_TAC continuous_sum;
8119 ASM_SIMP_TAC[metric_real;metric_euclid;top_of_metric_top;continuous_scale;SUBSET ;IN_IMAGE;Q_ELIM_THM'' ];
8120 ASM_SIMP_TAC[IN;euclid_scale_closure;continuous_scale];
8121 TYPE_THEN `(\t . (&. 1 - t) *# y) = (\t. t *# y) o ((--.) o ((+.) (--. (&.1))))` SUBGOAL_TAC;
8122 IMATCH_MP_TAC EQ_EXT;
8123 REWRITE_TAC[o_DEF;REAL_ARITH `--.(--. u +. v) = (u -. v)`];
8124 DISCH_THEN (fun t-> REWRITE_TAC [t]);
8125 REPEAT comp_elim_tac;
8131 (* ------------------------------------------------------------------ *)
8132 (* Connected Sets *)
8133 (* ------------------------------------------------------------------ *)
8135 let connected = euclid_def `connected U (Z:A->bool) <=>
8136 (Z SUBSET (UNIONS U)) /\
8137 (!A B. (U A) /\ (U B) /\ (A INTER B = EMPTY ) /\
8138 (Z SUBSET (A UNION B)) ==> ((Z SUBSET A) \/ (Z SUBSET B)))`;;
8140 let connected_unions = prove_by_refinement(
8141 `!U (Z1:A->bool) Z2. (connected U Z1) /\ (connected U Z2) /\
8142 ~(Z1 INTER Z2 = EMPTY) ==> (connected U (Z1 UNION Z2))`,
8145 REWRITE_TAC[connected];
8149 REWRITE_TAC[UNION;SUBSET;IN;IN_ELIM_THM' ];
8150 ASM_MESON_TAC[SUBSET ;IN];
8153 TYPEL_THEN [`A`;`B`] (USE 1 o SPECL);
8155 TYPEL_THEN [`A`;`B`] (USE 3 o SPECL);
8157 WITH 9 (REWRITE_RULE[union_subset]);
8160 IMATCH_MP_TAC (TAUT `(~b ==> a) ==> (a \/ b)`);
8162 USE 11 (REWRITE_RULE[union_subset]);
8164 USE 4 (REWRITE_RULE[EMPTY_EXISTS]);
8166 USE 4 (REWRITE_RULE[IN;INTER;IN_ELIM_THM' ]);
8167 REWRITE_TAC[union_subset];
8168 TYPE_THEN `~((Z1 SUBSET A) /\ (Z2 SUBSET B))` SUBGOAL_TAC;
8170 USE 8 (REWRITE_RULE[EQ_EMPTY]);
8171 USE 8 (REWRITE_RULE[INTER;IN;IN_ELIM_THM' ]);
8172 ASM_MESON_TAC[SUBSET;IN];
8173 TYPE_THEN `~((Z2 SUBSET A) /\ (Z1 SUBSET B))` SUBGOAL_TAC;
8175 USE 8 (REWRITE_RULE[EQ_EMPTY]);
8176 USE 8 (REWRITE_RULE[INTER;IN;IN_ELIM_THM' ]);
8177 ASM_MESON_TAC[SUBSET;IN];
8182 let component_DEF = euclid_def `component U (x:A) y <=>
8183 (?Z. (connected U Z) /\ (Z x) /\ (Z y))`;;
8185 let connected_sing = prove_by_refinement(
8186 `!U (x:A). (UNIONS U x) ==> (connected U {x})`,
8189 REWRITE_TAC[connected];
8192 REWRITE_TAC[SUBSET;IN_SING ];
8200 let component_refl = prove_by_refinement(
8201 `!U x. (UNIONS U x) ==> (component U x (x:A))`,
8204 REWRITE_TAC[component_DEF];
8205 ASM_MESON_TAC[IN_SING;IN;connected_sing];
8209 let component_symm = prove_by_refinement(
8210 `!U x y. (component U x y) ==>
8211 (component U (y:A) x)`,
8214 MESON_TAC[component_DEF];
8218 let component_trans = prove_by_refinement(
8219 `!U (x:A) y z. (component U x y) /\ (component U y z) ==>
8223 REWRITE_TAC[component_DEF];
8227 TYPE_THEN `connected U (Z UNION Z')` SUBGOAL_TAC;
8228 IMATCH_MP_TAC connected_unions;
8230 REWRITE_TAC[EMPTY_EXISTS ];
8231 REWRITE_TAC[IN;INTER;IN_ELIM_THM' ];
8232 TYPE_THEN `y` EXISTS_TAC;
8235 TYPE_THEN `Z UNION Z'` EXISTS_TAC;
8237 REWRITE_TAC[UNION;IN;IN_ELIM_THM' ];
8242 (* based on the Bolzano lemma *)
8244 let connect_real = prove_by_refinement(
8245 `!a b. connected (top_of_metric (UNIV,d_real))
8246 {x | a <=. x /\ x <=. b }`,
8250 REWRITE_TAC[connected];
8251 ASSUME_TAC metric_real;
8252 ASM_SIMP_TAC[GSYM top_of_metric_unions];
8254 REWRITE_TAC[UNIV;SUBSET;IN ];
8257 TYPE_THEN `\ (u ,v ). ( u <. a) \/ (b <. v) \/ ({x | u <=. x /\ x <=. v } SUBSET A) \/ ({x | u <=. x /\ x <=. v } SUBSET B)` (fun t-> ASSUME_TAC (SPEC t BOLZANO_LEMMA ));
8260 IMATCH_MP_TAC (TAUT `((b ==> c ) /\ a ) ==> ((a ==> b) ==> c )`);
8263 TYPEL_THEN [`a`;`b`] ((USE 6 o SPECL));
8264 USE 6 (REWRITE_RULE[ARITH_RULE `~(a <. a)`]);
8265 ASM_CASES_TAC `a <=. b`;
8267 TYPE_THEN `{x | a <=. x /\ x <=. b} = EMPTY ` SUBGOAL_TAC;
8268 IMATCH_MP_TAC EQ_EXT;
8269 REWRITE_TAC[IN_ELIM_THM';EMPTY];
8273 DISCH_THEN (fun t-> REWRITE_TAC[t]);
8274 REWRITE_TAC[EMPTY_SUBSET];
8280 USE 4 (REWRITE_RULE[EQ_EMPTY;INTER;IN;IN_ELIM_THM' ]);
8281 TYPE_THEN `b'` (USE 4 o SPEC);
8282 TYPE_THEN `{x | a' <=. x /\ x <=. b' } b'` SUBGOAL_TAC;
8283 ASM_REWRITE_TAC[IN_ELIM_THM'];
8286 TYPE_THEN `{x | b' <=. x /\ x <=. c } b'` SUBGOAL_TAC;
8287 ASM_REWRITE_TAC[IN_ELIM_THM'];
8290 TYPE_THEN `{x | a' <=. x /\ x <=. b' } UNION {x | b' <=. x /\ x <= c } = { x | a' <=. x /\ x <=. c }` SUBGOAL_TAC;
8291 REWRITE_TAC[UNION;IN;IN_ELIM_THM'];
8292 IMATCH_MP_TAC EQ_EXT ;
8294 REWRITE_TAC[IN_ELIM_THM'];
8300 REPEAT (DISCH_THEN (REPEAT_TCL DISJ_CASES_THEN ASSUME_TAC)) THEN ASM_REWRITE_TAC[] THEN (TRY (GEN_MESON_TAC 0 7 1[REAL_ARITH `(b < b' /\ b' <=. c ==> b <. c ) /\ (a' <=. b' /\ b' <. a ==> a' <. a)`]));
8301 IMATCH_MP_TAC (TAUT `c ==> (a \/ b \/ c \/ d)`);
8303 DISCH_THEN (fun t-> REWRITE_TAC [GSYM t]);
8304 ASM_REWRITE_TAC[union_subset];
8305 (* ASM_MESON_TAC[SUBSET;IN]; should have worked *)
8312 REWRITE_TAC[SUBSET;IN];
8313 TYPE_THEN `R ={x | a' <=. x /\ x <=. b'}` ABBREV_TAC;
8314 TYPE_THEN `S = {x | b' <=. x /\ x <=. c}` ABBREV_TAC;
8315 MESON_TAC[]; (* ok now it works *)
8322 REWRITE_TAC[SUBSET;IN];
8323 TYPE_THEN `R ={x | a' <=. x /\ x <=. b'}` ABBREV_TAC;
8324 TYPE_THEN `S = {x | b' <=. x /\ x <=. c}` ABBREV_TAC;
8325 MESON_TAC[]; (* ok now it works *)
8326 IMATCH_MP_TAC (TAUT `d ==> (a \/ b \/ c \/ d)`);
8328 DISCH_THEN (fun t-> REWRITE_TAC [GSYM t]);
8329 ASM_REWRITE_TAC[union_subset];
8332 ASM_CASES_TAC `x <. a`;
8333 TYPE_THEN `&.1` EXISTS_TAC;
8340 ASM_CASES_TAC `b <. x`;
8341 TYPE_THEN `&.1` EXISTS_TAC;
8349 TYPE_THEN ` (A UNION B) x` SUBGOAL_TAC;
8350 USE 5 (REWRITE_RULE[SUBSET;IN]);
8352 DISCH_THEN (IMATCH_MP_TAC );
8353 REWRITE_TAC[IN_ELIM_THM'];
8359 TYPEL_THEN [`UNIV:real -> bool`;`d_real`] (fun t-> (ASSUME_TAC (ISPECL t open_ball_nbd))); (* --//-- *)
8360 USE 8 (REWRITE_RULE[REWRITE_RULE[IN] IN_UNION]);
8361 TYPE_THEN `A x` ASM_CASES_TAC; (* *)
8362 TYPE_THEN `A` (USE 9 o SPEC);
8363 TYPE_THEN `x` (USE 9 o SPEC); (* --//-- *)
8366 USE 9 (REWRITE_RULE[open_ball;d_real;UNIV ]);
8367 TYPE_THEN `e` EXISTS_TAC;
8370 IMATCH_MP_TAC (TAUT `C ==> (a \/ b \/ C\/ d)`);
8373 TYPE_THEN `{x | a' <=. x /\ x <=. b'} SUBSET {y | abs (x - y) <. e}` SUBGOAL_TAC;
8374 REWRITE_TAC[SUBSET;IN;IN_ELIM_THM'];
8380 REWRITE_TAC[SUBSET;IN;IN_ELIM_THM' ];
8383 TYPE_THEN `B` (USE 9 o SPEC);
8384 TYPE_THEN `x` (USE 9 o SPEC); (* --//-- *)
8387 USE 9 (REWRITE_RULE[open_ball;d_real;UNIV ]);
8388 TYPE_THEN `e` EXISTS_TAC;
8391 IMATCH_MP_TAC (TAUT `d ==> (a \/ b \/ C\/ d)`);
8394 TYPE_THEN `{x | a' <=. x /\ x <=. b'} SUBSET {y | abs (x - y) <. e}` SUBGOAL_TAC;
8395 REWRITE_TAC[SUBSET;IN;IN_ELIM_THM'];
8401 REWRITE_TAC[SUBSET;IN;IN_ELIM_THM' ];
8406 let connect_image = prove_by_refinement(
8407 `!f U V Z. (continuous (f:A->B) U V) /\
8408 (IMAGE f Z SUBSET (UNIONS V)) /\ (connected U Z) ==>
8409 (connected V (IMAGE f Z))`,
8413 REWRITE_TAC[connected];
8417 USE 0 (REWRITE_RULE[continuous;IN ]);
8418 TYPE_THEN `A` (WITH 0 o SPEC);
8419 TYPE_THEN `B` (USE 0 o SPEC);
8420 TYPE_THEN `(preimage (UNIONS U) f A)` (USE 3 o SPEC);
8421 TYPE_THEN `(preimage (UNIONS U) f B)` (USE 3 o SPEC);
8422 USE 6 (MATCH_MP preimage_disjoint );
8423 TYPE_THEN `Z SUBSET preimage (UNIONS U) f A UNION preimage (UNIONS U) f B` SUBGOAL_TAC;
8424 REWRITE_TAC[preimage_union];
8426 USE 3 (REWRITE_RULE[subset_preimage ]);
8432 let path = euclid_def `path U x y <=>
8433 (?f a b. (continuous f (top_of_metric(UNIV,d_real )) U ) /\
8434 (f a = (x:A)) /\ (f b = y))`;;
8436 (**** Old proof modified by JRH to avoid use of GSPEC
8438 let const_continuous = prove_by_refinement(
8439 `!U V y. (topology_ U) ==>
8440 (continuous (\ (x:A). (y:B)) U V)`,
8443 REWRITE_TAC[continuous];
8447 REWRITE_TAC[preimage;IN ];
8448 TYPE_THEN `v y` ASM_CASES_TAC ;
8449 ASM_REWRITE_TAC[IN_ELIM_THM;GSPEC ];
8450 USE 0 (MATCH_MP top_univ);
8451 TYPE_THEN`t = UNIONS U` ABBREV_TAC;
8453 REWRITE_TAC[ETA_AX];
8454 ASM_REWRITE_TAC[GSPEC ];
8455 USE 0 (MATCH_MP open_EMPTY);
8456 USE 0 (REWRITE_RULE[open_DEF ;EMPTY]);
8464 let const_continuous = prove_by_refinement(
8465 `!U V y. (topology_ U) ==>
8466 (continuous (\ (x:A). (y:B)) U V)`,
8469 REWRITE_TAC[continuous];
8473 REWRITE_TAC[preimage;IN ];
8474 TYPE_THEN `v y` ASM_CASES_TAC ;
8475 ASM_REWRITE_TAC[IN_ELIM_THM];
8476 USE 0 (MATCH_MP top_univ);
8477 TYPE_THEN`t = UNIONS U` ABBREV_TAC;
8479 MATCH_MP_TAC(TAUT `(a <=> b) ==> a ==> b`);
8481 REWRITE_TAC[EXTENSION; IN_ELIM_THM; IN];
8482 USE 0 (MATCH_MP open_EMPTY);
8483 USE 0 (REWRITE_RULE[open_DEF ;EMPTY]);
8485 SUBGOAL_THEN `{x:A | F} = \x. F` SUBST1_TAC;
8486 REWRITE_TAC[EXTENSION; IN; IN_ELIM_THM];
8491 let path_component = euclid_def `path_component U x y <=>
8492 (?f a b. (continuous f (top_of_metric(UNIV,d_real )) U ) /\ (a <. b) /\
8493 (f a = (x:A)) /\ (f b = y) /\
8494 (IMAGE f { t | a <=. t /\ t <=. b } SUBSET (UNIONS U)))`;;
8496 let path_refl = prove_by_refinement(
8497 `!U x. (UNIONS U x) ==> (path_component U x (x:A))`,
8501 ASSUME_TAC (top_of_metric_top );
8502 TYPEL_THEN [`UNIV:real ->bool`;`d_real`] (USE 1 o ISPECL);
8503 USE 1 (REWRITE_RULE[metric_real ]);
8504 USE 1 (MATCH_MP const_continuous);
8505 REWRITE_TAC[path_component];
8506 TYPE_THEN `(\ (t:real). x)` EXISTS_TAC;
8507 ASM_REWRITE_TAC[IMAGE;IN;];
8508 TYPE_THEN `&.0` EXISTS_TAC;
8509 TYPE_THEN `&.1` EXISTS_TAC;
8512 REWRITE_TAC[SUBSET;IN;IN_ELIM_THM'];
8518 let path_symm = prove_by_refinement(
8519 `!U x y . (path_component U x (y:A)) ==> (path_component U y (x:A))`,
8523 REWRITE_TAC[path_component];
8528 TYPE_THEN `f o (--.)` EXISTS_TAC;
8529 TYPE_THEN `--. b` EXISTS_TAC;
8530 TYPE_THEN `--. a` EXISTS_TAC;
8532 IMATCH_MP_TAC continuous_comp;
8533 TYPE_THEN `(top_of_metric (UNIV,d_real))` EXISTS_TAC;
8534 REWRITE_TAC[neg_cont];
8535 SIMP_TAC[top_of_metric_top; metric_real; metric_euclidean; metric_euclid; metric_hausdorff; GSYM top_of_metric_unions; open_ball_open;];
8537 REWRITE_TAC[UNIV;IN;SUBSET ];
8543 REWRITE_TAC[o_DEF ;];
8547 REWRITE_TAC[IMAGE;IN;SUBSET;IN_ELIM_THM'];
8551 USE 4 (CONV_RULE NAME_CONFLICT_CONV );
8552 TYPE_THEN `x'` (USE 4 o SPEC);
8554 DISCH_THEN IMATCH_MP_TAC ;
8556 TYPE_THEN `--. x''` EXISTS_TAC;
8564 let path_symm_eq = prove_by_refinement(
8565 `!U x y . (path_component U x (y:A)) <=> (path_component U y (x:A))`,
8568 MESON_TAC[path_symm];
8573 let path_trans = prove_by_refinement(
8574 `!U x y (z:A). (path_component U x y) /\ (path_component U y z) ==>
8575 (path_component U x z)`,
8579 REWRITE_TAC[path_component];
8587 TYPE_THEN `joinf f (f' o ((+.) (a' -. b))) b` EXISTS_TAC;
8588 TYPE_THEN `a` EXISTS_TAC;
8589 TYPE_THEN `b' +. (b - a')` EXISTS_TAC;
8590 CONJ_TAC; (* start of continuity *)
8591 IMATCH_MP_TAC joinf_cont;
8594 IMATCH_MP_TAC continuous_comp;
8595 TYPE_THEN `(top_of_metric (UNIV,d_real))` EXISTS_TAC;
8596 ASM_REWRITE_TAC [top_of_metric_top; metric_real; metric_euclidean; metric_euclid; metric_hausdorff; GSYM top_of_metric_unions; open_ball_open;];
8597 REWRITE_TAC[add_cont];
8598 ASM_SIMP_TAC [top_of_metric_top; metric_real; metric_euclidean; metric_euclid; metric_hausdorff; GSYM top_of_metric_unions; open_ball_open;];
8599 REWRITE_TAC[SUBSET;UNIV;IN;IN_ELIM_THM'];
8602 ASM_REWRITE_TAC[]; (* end of continuity *)
8603 CONJ_TAC; (* start real ineq *)
8610 REAL_ARITH_TAC; (* end of real ineq *)
8612 REWRITE_TAC[joinf;o_DEF];
8613 ASM_REWRITE_TAC[]; (* end of JOIN statement *)
8614 CONJ_TAC; (* next JOIN statement *)
8615 REWRITE_TAC[joinf;o_DEF];
8616 TYPE_THEN `~(b' +. b -. a' <. b)` SUBGOAL_TAC;
8617 TYPE_THEN `(a' <. b') /\ (a <. b)` SUBGOAL_TAC;
8620 DISCH_THEN (fun t-> REWRITE_TAC[t]);
8621 TYPE_THEN ` a' -. b +. b' +. b -. a' = b'` SUBGOAL_TAC;
8623 DISCH_THEN (fun t-> REWRITE_TAC[t]);
8624 ASM_REWRITE_TAC[]; (* end of next joinf *)
8625 TYPE_THEN `(a <=. b) /\ (b <=. (b' + b - a'))` SUBGOAL_TAC; (* subreal *)
8626 TYPE_THEN `(a' <. b') /\ (a <. b)` SUBGOAL_TAC;
8629 DISCH_TAC; (* end of subreal *)
8630 USE 2 (MATCH_MP union_closed_interval);
8632 DISCH_THEN (fun t-> REWRITE_TAC[GSYM t]);
8633 REWRITE_TAC[IMAGE_UNION;union_subset];
8634 CONJ_TAC; (* start of FIRST interval *)
8635 TYPE_THEN `IMAGE (joinf f (f' o (+.) (a' -. b)) b) {t | a <=. t /\ t <. b} = IMAGE f {t | a <=. t /\ t <. b}` SUBGOAL_TAC;
8636 REWRITE_TAC[joinf;IMAGE;IN_IMAGE ];
8637 IMATCH_MP_TAC EQ_EXT;
8639 REWRITE_TAC[IN_ELIM_THM'];
8651 TYPE_THEN `x'` EXISTS_TAC;
8653 DISCH_THEN (fun t-> REWRITE_TAC[t]); (* FIRST interval still *)
8654 TYPE_THEN `IMAGE f {t | a <=. t /\ t <. b} SUBSET IMAGE f {t | a <=. t /\ t <=. b} ` SUBGOAL_TAC;
8655 REWRITE_TAC[SUBSET;IN_IMAGE ;IN_ELIM_THM'];
8657 DISCH_THEN (CHOOSE_THEN MP_TAC);
8658 MESON_TAC[REAL_ARITH `a <. b ==> a<=. b`];
8663 USE 0 (MATCH_MP SUBSET_TRANS );
8664 ASM_REWRITE_TAC[]; (* end of FIRST interval *)
8666 TYPE_THEN `IMAGE (joinf f (f' o (+.) (a' -. b)) b) {t | b <=. t /\ t <=. b' + b -. a'} = IMAGE f' {t | a' <=. t /\ t <=. b'}` SUBGOAL_TAC;
8667 REWRITE_TAC[joinf;IMAGE;IN_IMAGE ];
8668 IMATCH_MP_TAC EQ_EXT;
8669 REWRITE_TAC[IN_ELIM_THM'];
8677 TYPE_THEN `~(x' <. b)` SUBGOAL_TAC;
8682 USE 4 (REWRITE_RULE[o_DEF]);
8683 TYPE_THEN `a' -. b +. x'` EXISTS_TAC; (* * *)
8685 TYPE_THEN `(a' <. b') /\ (a <. b) /\ (b <=. x') /\ (x' <=. b' +. b -. a')` SUBGOAL_TAC;
8692 TYPE_THEN `x' +. b -. a'` EXISTS_TAC;
8699 TYPE_THEN `~(x' +. b -. a' <. b)` SUBGOAL_TAC;
8702 DISCH_THEN (fun t-> REWRITE_TAC[t]);
8706 DISCH_THEN (fun t -> REWRITE_TAC [t]);
8712 let loc_path_conn = euclid_def `loc_path_conn U <=>
8713 !A x. (U A) /\ (A (x:A)) ==>
8714 (U (path_component (induced_top U A) x))`;;
8717 let path_eq_conn = prove_by_refinement(
8718 `!U (x:A). (loc_path_conn U) /\ (topology_ U) ==>
8719 (path_component U x = component U x)`,
8724 MATCH_MP_TAC EQ_EXT;
8727 REWRITE_TAC[path_component];
8732 UND 2 THEN DISCH_ALL_TAC;
8733 REWRITE_TAC[component_DEF];
8734 TYPE_THEN `IMAGE f {t | a <= t /\ t <= b}` EXISTS_TAC;
8736 IMATCH_MP_TAC connect_image ;
8738 TYPE_THEN `(top_of_metric (UNIV,d_real))` EXISTS_TAC ;
8739 ASM_REWRITE_TAC[connect_real ];
8740 REWRITE_TAC[IMAGE;IN;IN_ELIM_THM' ];
8742 TYPE_THEN `a` EXISTS_TAC;
8746 TYPE_THEN `b` EXISTS_TAC;
8750 REWRITE_TAC[component_DEF];
8753 UND 2 THEN DISCH_ALL_TAC;
8754 USE 2 (REWRITE_RULE[connected]);
8755 UND 2 THEN DISCH_ALL_TAC;
8756 TYPE_THEN `path_component U x` (USE 5 o SPEC);
8757 TYPE_THEN `A = path_component U x` ABBREV_TAC;
8758 TYPE_THEN `B = UNIONS (IMAGE (\z. (path_component U z)) (Z DIFF A))` ABBREV_TAC ;
8759 TYPE_THEN `B` (USE 5 o SPEC);
8760 TYPE_THEN `U A /\ U B /\ (A INTER B = {}) /\ Z SUBSET A UNION B` SUBGOAL_TAC;
8761 WITH 0 (REWRITE_RULE[loc_path_conn]);
8762 TYPE_THEN `(UNIONS U)` (USE 8 o SPEC);
8763 TYPE_THEN `x` (USE 8 o SPEC);
8765 ASM_SIMP_TAC[induced_top_unions];
8766 ASM_SIMP_TAC[top_univ];
8767 TYPE_THEN `UNIONS U x` SUBGOAL_TAC;
8768 USE 2 (REWRITE_RULE[SUBSET;IN;]);
8776 WITH 1 (REWRITE_RULE[topology]);
8777 TYPEL_THEN [`EMPTY:A->bool`;`EMPTY:A->bool`;`(IMAGE (\z. path_component U z) (Z DIFF A))`] (USE 10 o ISPECL);
8778 UND 10 THEN DISCH_ALL_TAC;
8779 UND 12 THEN (DISCH_THEN IMATCH_MP_TAC );
8780 REWRITE_TAC[SUBSET;IN_IMAGE];
8786 USE 0 (REWRITE_RULE[loc_path_conn]);
8787 TYPE_THEN `(UNIONS U)` (USE 0 o SPEC);
8788 USE 0 ( CONV_RULE NAME_CONFLICT_CONV);
8789 TYPE_THEN `x'` (USE 0 o SPEC);
8791 ASM_SIMP_TAC[induced_top_unions];
8792 DISCH_THEN MATCH_MP_TAC;
8793 ASM_SIMP_TAC[top_univ];
8795 USE 2 (REWRITE_RULE[SUBSET;IN]);
8796 USE 0 (REWRITE_RULE[DIFF;IN;IN_ELIM_THM' ]);
8799 REWRITE_TAC[EQ_EMPTY];
8801 USE 10 (REWRITE_RULE[INTER;IN;IN_ELIM_THM' ]);
8805 REWRITE_TAC[UNIONS;IN_IMAGE ;IN_ELIM_THM' ];
8815 USE 10 (ONCE_REWRITE_RULE [path_symm_eq]);
8818 USE 10 (MATCH_MP path_trans);
8822 REWRITE_TAC[DIFF;IN;IN_ELIM_THM'];
8824 REWRITE_TAC[SUBSET;IN;UNION;IN_ELIM_THM'];
8826 TYPE_THEN `A x'` ASM_CASES_TAC;
8830 REWRITE_TAC[UNIONS;IN_IMAGE;IN_ELIM_THM' ];
8834 TYPE_THEN `x'` EXISTS_TAC;
8835 TYPE_THEN `path_component U x'` EXISTS_TAC;
8836 ASM_REWRITE_TAC[DIFF;IN;IN_ELIM_THM' ];
8837 IMATCH_MP_TAC path_refl;
8838 USE 2 (REWRITE_RULE[SUBSET;IN]);
8843 DISCH_THEN DISJ_CASES_TAC ;
8844 USE 5 (REWRITE_RULE[SUBSET;IN ;]);
8846 UND 8 THEN DISCH_ALL_TAC;
8847 USE 10 (REWRITE_RULE[EQ_EMPTY]);
8848 TYPE_THEN `x` (USE 10 o SPEC);
8849 USE 10 (REWRITE_RULE[INTER;IN;IN_ELIM_THM']);
8850 USE 5 (REWRITE_RULE[SUBSET;IN;IN_ELIM_THM']);
8851 TYPE_THEN `A x` SUBGOAL_TAC;
8853 IMATCH_MP_TAC path_refl ;
8854 USE 2 (REWRITE_RULE[SUBSET;IN;IN_ELIM_THM']);
8862 let open_ball_star = prove_by_refinement(
8863 `!x r y t n. (open_ball(euclid n,d_euclid) x r y) /\
8864 (&.0 <=. t) /\ (t <=. &.1) ==>
8865 (open_ball(euclid n,d_euclid) x r ((t *# x + (&.1-t)*#y)))`,
8869 REWRITE_TAC[open_ball;IN_ELIM_THM' ];
8871 ASM_SIMP_TAC[euclid_scale_closure;euclid_add_closure];
8872 GEN_REWRITE_TAC (LAND_CONV o LAND_CONV) [GSYM trivial_lin_combo];
8873 ASSUME_TAC (SPEC `n:num` metric_translate_LEFT);
8874 TYPEL_THEN [`(&.1 - t) *# x`;`(&.1 - t)*# y`;`t *# x`] (USE 5 o ISPECL);
8876 ASM_SIMP_TAC [euclid_scale_closure];
8877 ASM_MESON_TAC[norm_scale_vec;REAL_ARITH `(&.0 <=. t) /\ (t <=. (&.1)) ==> (||. (&.1 - t) <=. &.1)`;REAL_ARITH `(b <= a) ==> ((a < C) ==> (b < C))`;GSYM REAL_MUL_LID;REAL_LE_RMUL;d_euclid_pos];
8882 let open_ball_path = prove_by_refinement(
8883 `!x r y n. (open_ball(euclid n,d_euclid) x r y) ==>
8885 (top_of_metric(open_ball(euclid n,d_euclid) x r,d_euclid)) y x)`,
8889 REWRITE_TAC[path_component ;];
8891 TYPE_THEN `(\t. (t *# x + (&.1 - t) *# y))` EXISTS_TAC;
8895 TYPE_THEN `top_of_metric (open_ball (euclid n,d_euclid) x r,d_euclid) = (induced_top(top_of_metric(euclid n,d_euclid)) (open_ball (euclid n,d_euclid) x r))` SUBGOAL_TAC;
8896 ASM_MESON_TAC[open_ball_subset;metric_euclid;top_of_metric_induced ];
8898 TYPE_THEN `euclid n x /\ euclid n y` SUBGOAL_TAC;
8899 USE 0 (REWRITE_RULE[open_ball;IN_ELIM_THM' ]);
8904 IMATCH_MP_TAC continuous_induced;
8905 ASM_SIMP_TAC [top_of_metric_top;metric_euclid;open_ball_open];
8906 IMATCH_MP_TAC continuous_lin_combo ;
8909 REWRITE_TAC[euclid_plus;euclid_scale];
8910 IMATCH_MP_TAC EQ_EXT THEN BETA_TAC ;
8913 REWRITE_TAC[euclid_plus;euclid_scale];
8914 IMATCH_MP_TAC EQ_EXT THEN BETA_TAC ;
8916 REWRITE_TAC[SUBSET;IN_IMAGE;Q_ELIM_THM'' ];
8917 REWRITE_TAC[IN;IN_ELIM_THM'];
8918 TYPE_THEN `(UNIONS (top_of_metric (open_ball (euclid n,d_euclid) x r,d_euclid))) = (open_ball(euclid n,d_euclid) x r)` SUBGOAL_TAC;
8919 IMATCH_MP_TAC (GSYM top_of_metric_unions);
8920 IMATCH_MP_TAC metric_subspace;
8921 ASM_MESON_TAC[metric_euclid;open_ball_subset];
8922 DISCH_THEN (fun t->REWRITE_TAC[t]);
8923 ASM_MESON_TAC [open_ball_star];
8928 let path_domain = prove_by_refinement(
8929 `!U x (y:A). path_component U x y <=>
8930 (?f a b. (continuous f (top_of_metric(UNIV,d_real )) U ) /\ (a <. b) /\
8931 (f a = (x:A)) /\ (f b = y) /\
8932 (IMAGE f UNIV SUBSET (UNIONS U)))`,
8936 REWRITE_TAC[path_component];
8943 TYPE_THEN `joinf (\t. (f a)) (joinf f (\t. (f b)) b) a` EXISTS_TAC;
8944 TYPE_THEN `a` EXISTS_TAC;
8945 TYPE_THEN `b` EXISTS_TAC;
8948 IMATCH_MP_TAC joinf_cont;
8949 ASM_SIMP_TAC[const_continuous;top_of_metric_top;metric_real];
8951 IMATCH_MP_TAC joinf_cont;
8953 ASM_SIMP_TAC[const_continuous;top_of_metric_top;metric_real];
8957 ASM_REWRITE_TAC[joinf;REAL_ARITH `~(a<a)`];
8961 USE 1 (MATCH_MP (REAL_ARITH `(a < b) ==> (~(b < a))`));
8962 ASM_REWRITE_TAC [joinf;REAL_ARITH `~(b < b)`];
8963 REWRITE_TAC[SUBSET;IN_IMAGE;Q_ELIM_THM'';joinf ];
8964 REWRITE_TAC[IN_UNIV];
8968 USE 4 (REWRITE_RULE[SUBSET;IN_IMAGE;Q_ELIM_THM'';]);
8969 USE 4 (REWRITE_RULE[IN;IN_ELIM_THM' ]);
8971 TYPE_THEN `a` (WITH 4 o SPEC);
8972 TYPE_THEN `b` (WITH 4 o SPEC);
8973 TYPE_THEN `x'` (USE 4 o SPEC);
8974 DISJ_CASES_TAC (REAL_ARITH `x' < a \/ (a <= x')`);
8975 ASM_REWRITE_TAC[IN];
8976 ASM_MESON_TAC[REAL_ARITH `(a <=a) /\ ((a < b) ==> (a <= b))`];
8977 DISJ_CASES_TAC (REAL_ARITH `x' < b \/ (b <= x')`);
8979 USE 7 (MATCH_MP (REAL_ARITH `a <= x' ==> (~(x' < a))`));
8980 ASM_REWRITE_TAC[IN ];
8981 ASM_MESON_TAC[REAL_ARITH `x' < b ==> x' <= b`];
8982 USE 7 (MATCH_MP (REAL_ARITH `a <= x' ==> (~(x' < a))`));
8984 USE 8 (MATCH_MP (REAL_ARITH `b <= x' ==> ~(x' < b)`));
8985 ASM_REWRITE_TAC[IN];
8986 ASM_MESON_TAC[REAL_ARITH `b <=b /\ ((a < b) ==> (a <= b))`];
8991 TYPE_THEN `f` EXISTS_TAC;
8992 TYPE_THEN `a ` EXISTS_TAC;
8993 TYPE_THEN `b` EXISTS_TAC;
8996 REWRITE_TAC[SUBSET;IN_IMAGE ;Q_ELIM_THM''];
8997 REWRITE_TAC[IN_UNIV];
8998 REWRITE_TAC[IN;IN_ELIM_THM'];
9004 let path_component_subspace = prove_by_refinement(
9005 `!X Y d (y:A). ((Y SUBSET X) /\ (metric_space(X,d) /\ (Y y))) ==>
9006 ((path_component(top_of_metric(Y,d)) y) SUBSET
9007 (path_component(top_of_metric(X,d)) y))`,
9011 REWRITE_TAC[SUBSET;IN;path_domain];
9016 TYPE_THEN `f` EXISTS_TAC;
9017 TYPE_THEN `a` EXISTS_TAC;
9018 TYPE_THEN `b` EXISTS_TAC;
9020 TYPE_THEN `metric_space(Y,d)` SUBGOAL_TAC;
9021 ASM_MESON_TAC[metric_subspace];
9024 ASM_SIMP_TAC[GSYM top_of_metric_unions];
9028 TYPE_THEN `IMAGE f UNIV SUBSET X /\ IMAGE f UNIV SUBSET Y` SUBGOAL_TAC;
9029 ASM_MESON_TAC[SUBSET;IN];
9031 ASM_SIMP_TAC[metric_continuous_continuous;metric_real];
9032 REWRITE_TAC[metric_continuous;metric_continuous_pt];
9033 ASM_MESON_TAC[SUBSET;IN];
9037 let path_component_in = prove_by_refinement(
9038 `!x (y:A) U. (path_component U x y) ==> (UNIONS U y)`,
9041 REWRITE_TAC[path_component];
9048 USE 4 (REWRITE_RULE[SUBSET;IN_IMAGE;Q_ELIM_THM'']);
9049 USE 4 (REWRITE_RULE[IN_ELIM_THM';IN]);
9050 TYPE_THEN `b` (USE 4 o SPEC);
9051 ASM_MESON_TAC[REAL_ARITH `(a < b) ==> ((a<=. b) /\ (b <= b))`];
9055 let loc_path_conn_euclid = prove_by_refinement(
9056 `!n A. (top_of_metric(euclid n,d_euclid)) A ==>
9057 (loc_path_conn (top_of_metric(A,d_euclid)))`,
9061 REWRITE_TAC[loc_path_conn];
9063 TYPE_THEN `metric_space (A,d_euclid)` SUBGOAL_TAC;
9064 IMATCH_MP_TAC metric_subspace;
9065 TYPE_THEN `euclid n` EXISTS_TAC;
9066 REWRITE_TAC[metric_euclid];
9067 USE 0 (MATCH_MP sub_union);
9068 ASM_MESON_TAC[top_of_metric_unions;metric_euclid];
9070 WITH 3 (MATCH_MP top_of_metric_nbd);
9072 DISCH_THEN (fun t-> REWRITE_TAC[t]);
9073 TYPE_THEN `A' SUBSET A` SUBGOAL_TAC;
9074 USE 1 (MATCH_MP sub_union);
9075 ASM_MESON_TAC[top_of_metric_unions];
9077 ASM_SIMP_TAC[top_of_metric_induced];
9078 TYPE_THEN `metric_space(A',d_euclid)` SUBGOAL_TAC;
9079 ASM_MESON_TAC[metric_subspace];
9082 REWRITE_TAC[SUBSET;IN];
9083 REWRITE_TAC[path_component];
9088 USE 6 (REWRITE_RULE[SUBSET;IN_IMAGE ;IN_ELIM_THM';Q_ELIM_THM'']);
9091 TYPE_THEN `b` (USE 10 o SPEC);
9092 USE 4 (REWRITE_RULE[SUBSET;IN]);
9094 DISCH_THEN IMATCH_MP_TAC ;
9095 USE 5 (MATCH_MP top_of_metric_unions);
9098 DISCH_THEN (fun t -> ONCE_REWRITE_TAC[GSYM t]);
9099 ASM_REWRITE_TAC[IN];
9100 ASM_MESON_TAC[REAL_ARITH `b <=. b /\ ((a < b)==> (a <=. b))`];
9105 WITH 7 (MATCH_MP path_component_in);
9106 TYPE_THEN `A' a` SUBGOAL_TAC;
9108 ASM_SIMP_TAC[GSYM top_of_metric_unions;];
9110 TYPE_THEN `A SUBSET (euclid n)` SUBGOAL_TAC;
9111 USE 0 (MATCH_MP sub_union);
9113 ASM_SIMP_TAC[GSYM top_of_metric_unions;metric_euclid];
9115 TYPE_THEN `top_of_metric(euclid n,d_euclid) A'` SUBGOAL_TAC;
9116 IMATCH_MP_TAC induced_trans;
9117 TYPE_THEN `A` EXISTS_TAC;
9119 ASM_SIMP_TAC[top_of_metric_top;metric_euclid;top_of_metric_induced ];
9123 SIMP_TAC[top_of_metric_nbd;metric_euclid];
9125 TYPE_THEN `a` (USE 13 o SPEC);
9126 USE 13 (REWRITE_RULE[IN]);
9129 TYPE_THEN `r` EXISTS_TAC;
9131 TYPE_THEN `open_ball (A,d_euclid) a r SUBSET path_component (top_of_metric (A',d_euclid)) a` SUBGOAL_TAC ;
9132 TYPE_THEN `open_ball (euclid n,d_euclid) a r SUBSET path_component (top_of_metric (A',d_euclid)) a` SUBGOAL_TAC ;
9133 TYPE_THEN `open_ball (euclid n,d_euclid) a r SUBSET path_component (top_of_metric ((open_ball(euclid n,d_euclid) a r),d_euclid)) a` SUBGOAL_TAC;
9134 REWRITE_TAC[SUBSET;IN];
9135 MESON_TAC[open_ball_path;SUBSET;IN;path_symm];
9136 IMATCH_MP_TAC (prove_by_refinement(`!A B C. (B:A->bool) SUBSET C ==> (A SUBSET B ==> A SUBSET C)`,[MESON_TAC[SUBSET_TRANS]]));
9137 IMATCH_MP_TAC path_component_subspace;
9139 IMATCH_MP_TAC (REWRITE_RULE[IN] open_ball_nonempty);
9140 ASM_SIMP_TAC[metric_euclid];
9141 ASM_MESON_TAC[SUBSET;IN];
9142 IMATCH_MP_TAC (prove_by_refinement (`!A B C. (A:A->bool) SUBSET B ==> (B SUBSET C ==> A SUBSET C)`,[MESON_TAC[SUBSET_TRANS]]));
9143 ASM_SIMP_TAC[open_ball_subspace];
9144 IMATCH_MP_TAC (prove_by_refinement(`!A B C. (B:A->bool) SUBSET C ==> (A SUBSET B ==> A SUBSET C)`,[MESON_TAC[SUBSET_TRANS]]));
9145 REWRITE_TAC[SUBSET;IN];
9148 MESON_TAC[path_trans];
9152 let loc_path_euclid_cor = prove_by_refinement(
9153 `!n A . (top_of_metric(euclid n,d_euclid)) A ==>
9154 (path_component (top_of_metric(A,d_euclid)) =
9155 component (top_of_metric(A,d_euclid)))`,
9159 WITH 0 (MATCH_MP loc_path_conn_euclid);
9160 IMATCH_MP_TAC EQ_EXT;
9162 IMATCH_MP_TAC path_eq_conn;
9164 IMATCH_MP_TAC top_of_metric_top;
9165 USE 0 (MATCH_MP sub_union);
9167 ASM_SIMP_TAC[GSYM top_of_metric_unions ;metric_euclid];
9168 ASM_MESON_TAC[metric_subspace;metric_euclid];