src/HOL/Complex/ex/NSPrimes.ML
author paulson
Tue, 10 Feb 2004 12:02:11 +0100
changeset 14378 69c4d5997669
parent 14371 c78c7da09519
permissions -rw-r--r--
generic of_nat and of_int functions, and generalization of iszero and neg
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13957
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
     1
(*  Title       : NSPrimes.ML
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
     2
    Author      : Jacques D. Fleuriot
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
     3
    Copyright   : 2002 University of Edinburgh
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
     4
    Description : The nonstandard primes as an extension of 
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
     5
                  the prime numbers
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
     6
*)
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
     7
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
     8
(*--------------------------------------------------------------*) 
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
     9
(* A "choice" theorem for ultrafilters cf. almost everywhere    *)
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    10
(* quantification                                               *)
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    11
(*--------------------------------------------------------------*) 
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    12
    
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    13
Goal "{n. EX m. Q n m} : FreeUltrafilterNat \
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    14
\     ==> EX f. {n. Q n (f n)} : FreeUltrafilterNat";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    15
by (res_inst_tac [("x","%n. (@x. Q n x)")] exI 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    16
by (Ultra_tac 1 THEN rtac someI 1 THEN Auto_tac);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    17
qed "UF_choice";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    18
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    19
Goal "({n. P n} : FreeUltrafilterNat --> {n. Q n} : FreeUltrafilterNat) = \
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    20
\     ({n. P n --> Q n} : FreeUltrafilterNat)";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    21
by Auto_tac;
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    22
by (ALLGOALS(Ultra_tac));
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    23
qed "UF_if";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    24
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    25
Goal "({n. P n} : FreeUltrafilterNat & {n. Q n} : FreeUltrafilterNat) = \
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    26
\     ({n. P n & Q n} : FreeUltrafilterNat)";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    27
by Auto_tac;
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    28
by (ALLGOALS(Ultra_tac));
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    29
qed "UF_conj";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    30
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    31
Goal "(ALL f. {n. Q n (f n)} : FreeUltrafilterNat) = \
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    32
\     ({n. ALL m. Q n m} : FreeUltrafilterNat)";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    33
by Auto_tac;
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    34
by (Ultra_tac 2);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    35
by (rtac ccontr 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    36
by (rtac swap 1 THEN assume_tac 2);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    37
by (simp_tac (simpset() addsimps [FreeUltrafilterNat_Compl_iff1,
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    38
    CLAIM "-{n. Q n} = {n. ~ Q n}"]) 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    39
by (rtac UF_choice 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    40
by (Ultra_tac 1 THEN Auto_tac);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    41
qed "UF_choice_ccontr";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    42
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    43
Goal "ALL M. EX N. 0 < N & (ALL m. 0 < m & (m::nat) <= M --> m dvd N)";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    44
by (rtac allI 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    45
by (induct_tac "M" 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    46
by Auto_tac;
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    47
by (res_inst_tac [("x","N * (Suc n)")] exI 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    48
by (Step_tac 1 THEN Force_tac 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    49
by (dtac le_imp_less_or_eq 1 THEN etac disjE 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    50
by (force_tac (claset() addSIs [dvd_mult2],simpset()) 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    51
by (force_tac (claset() addSIs [dvd_mult],simpset()) 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    52
qed "dvd_by_all";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    53
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    54
bind_thm ("dvd_by_all2",dvd_by_all RS spec);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    55
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    56
Goal "(EX (x::hypnat). P x) = (EX f. P (Abs_hypnat(hypnatrel `` {f})))";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    57
by Auto_tac;
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    58
by (res_inst_tac [("z","x")] eq_Abs_hypnat 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    59
by Auto_tac;
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    60
qed "lemma_hypnat_P_EX";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    61
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    62
Goal "(ALL (x::hypnat). P x) = (ALL f. P (Abs_hypnat(hypnatrel `` {f})))";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    63
by Auto_tac;
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    64
by (res_inst_tac [("z","x")] eq_Abs_hypnat 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    65
by Auto_tac;
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    66
qed "lemma_hypnat_P_ALL";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    67
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    68
Goalw [hdvd_def]
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    69
      "(Abs_hypnat(hypnatrel``{%n. X n}) hdvd \
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    70
\           Abs_hypnat(hypnatrel``{%n. Y n})) = \
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    71
\      ({n. X n dvd Y n} : FreeUltrafilterNat)";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    72
by (Auto_tac THEN Ultra_tac 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    73
qed "hdvd";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    74
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    75
Goal "(hypnat_of_nat n <= 0) = (n = 0)";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    76
by (stac (hypnat_of_nat_zero RS sym) 1);
14371
c78c7da09519 Conversion of HyperNat to Isar format and its declaration as a semiring
paulson
parents: 13957
diff changeset
    77
by Auto_tac;
13957
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    78
qed "hypnat_of_nat_le_zero_iff";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    79
Addsimps [hypnat_of_nat_le_zero_iff];
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    80
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    81
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    82
(* Goldblatt: Exercise 5.11(2) - p. 57 *)
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    83
Goal "ALL M. EX N. 0 < N & (ALL m. 0 < m & (m::hypnat) <= M --> m hdvd N)";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    84
by (Step_tac 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    85
by (res_inst_tac [("z","M")] eq_Abs_hypnat 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    86
by (auto_tac (claset(),simpset() addsimps [lemma_hypnat_P_EX,
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    87
    lemma_hypnat_P_ALL,hypnat_zero_def,hypnat_le,hypnat_less,hdvd]));
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    88
by (cut_facts_tac [dvd_by_all] 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    89
by (dtac (CLAIM "(ALL (M::nat). EX N. 0 < N & (ALL m. 0 < m & m <= M \
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    90
\                               --> m dvd N)) \
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    91
\                ==> ALL (n::nat). EX N. 0 < N & (ALL m. 0 < (m::nat) & m <= (x n) \
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    92
\                                  --> m dvd N)") 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    93
by (dtac choice 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    94
by (Step_tac 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    95
by (res_inst_tac [("x","f")] exI 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    96
by Auto_tac;
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    97
by (ALLGOALS(Ultra_tac));
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    98
by Auto_tac;
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
    99
qed "hdvd_by_all";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   100
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   101
bind_thm ("hdvd_by_all2",hdvd_by_all RS spec);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   102
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   103
(* Goldblatt: Exercise 5.11(2) - p. 57 *)
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   104
Goal "EX (N::hypnat). 0 < N & (ALL n : - {0::nat}. hypnat_of_nat(n) hdvd N)"; 
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   105
by (cut_facts_tac [hdvd_by_all] 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   106
by (dres_inst_tac [("x","whn")] spec 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   107
by Auto_tac;
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   108
by (rtac exI 1 THEN Auto_tac);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   109
by (dres_inst_tac [("x","hypnat_of_nat n")] spec 1);
14371
c78c7da09519 Conversion of HyperNat to Isar format and its declaration as a semiring
paulson
parents: 13957
diff changeset
   110
by (auto_tac (claset(),
c78c7da09519 Conversion of HyperNat to Isar format and its declaration as a semiring
paulson
parents: 13957
diff changeset
   111
     simpset() addsimps [linorder_not_less, hypnat_of_nat_zero_iff]));
13957
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   112
qed "hypnat_dvd_all_hypnat_of_nat";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   113
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   114
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   115
(*--------------------------------------------------------------*)
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   116
(* the nonstandard extension of the set prime numbers consists  *)
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   117
(* of precisely those hypernaturals > 1 that have no nontrivial *)
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   118
(* factors                                                      *)
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   119
(*--------------------------------------------------------------*) 
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   120
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   121
(* Goldblatt: Exercise 5.11(3a) - p 57  *)
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   122
Goalw [starprime_def,thm "prime_def"]
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   123
  "starprime = {p. 1 < p & (ALL m. m hdvd p --> m = 1 | m = p)}";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   124
by (auto_tac (claset(),simpset() addsimps 
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   125
    [CLAIM "{p. Q(p) & R(p)} = {p. Q(p)} Int {p. R(p)}",NatStar_Int]));
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   126
by (ALLGOALS(res_inst_tac [("z","x")] eq_Abs_hypnat));
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   127
by (res_inst_tac [("z","m")] eq_Abs_hypnat 2);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   128
by (auto_tac (claset(),simpset() addsimps [hdvd,hypnat_one_def,hypnat_less,
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   129
    lemma_hypnat_P_ALL,starsetNat_def]));
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   130
by (dtac bspec 1 THEN dtac bspec 2 THEN Auto_tac);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   131
by (Ultra_tac 1 THEN Ultra_tac 1); 
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   132
by (rtac ccontr 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   133
by (dtac FreeUltrafilterNat_Compl_mem 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   134
by (auto_tac (claset(),simpset() addsimps [CLAIM "- {p. Q p} = {p. ~ Q p}"]));
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   135
by (dtac UF_choice 1 THEN Auto_tac);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   136
by (dres_inst_tac [("x","f")] spec 1 THEN Auto_tac);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   137
by (ALLGOALS(Ultra_tac));
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   138
qed "starprime";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   139
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   140
Goalw [thm "prime_def"] "2 : prime";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   141
by Auto_tac;
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   142
by (ftac dvd_imp_le 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   143
by (auto_tac (claset() addDs [dvd_0_left],simpset() addsimps 
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   144
    [ARITH_PROVE "(m <= (2::nat)) = (m = 0 | m = 1 | m = 2)"]));
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   145
qed "prime_two";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   146
Addsimps [prime_two];
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   147
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   148
(* proof uses course-of-value induction *)
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   149
Goal "Suc 0 < n --> (EX k : prime. k dvd n)";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   150
by (res_inst_tac [("n","n")] nat_less_induct 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   151
by Auto_tac;
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   152
by (case_tac "n : prime" 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   153
by (res_inst_tac [("x","n")] bexI 1 THEN Auto_tac);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   154
by (dtac (conjI RS (thm "not_prime_ex_mk")) 1 THEN Auto_tac);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   155
by (dres_inst_tac [("x","m")] spec 1 THEN Auto_tac);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   156
by (res_inst_tac [("x","ka")] bexI 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   157
by (auto_tac (claset() addIs [dvd_mult2],simpset()));
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   158
qed_spec_mp "prime_factor_exists";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   159
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   160
(* Goldblatt Exercise 5.11(3b) - p 57  *)
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   161
Goal "1 < n ==> (EX k : starprime. k hdvd n)";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   162
by (res_inst_tac [("z","n")] eq_Abs_hypnat 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   163
by (auto_tac (claset(),simpset() addsimps [hypnat_one_def,
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   164
    hypnat_less,starprime_def,lemma_hypnat_P_EX,lemma_hypnat_P_ALL,
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   165
    hdvd,starsetNat_def,CLAIM "(ALL X: S. P X) = (ALL X. X : S --> P X)",
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   166
    UF_if]));
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   167
by (res_inst_tac [("x","%n. @y. y : prime & y dvd x n")] exI 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   168
by Auto_tac;
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   169
by (ALLGOALS (Ultra_tac));
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   170
by (dtac sym 1 THEN Asm_simp_tac 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   171
by (ALLGOALS(rtac someI2_ex));
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   172
by (auto_tac (claset() addSDs [prime_factor_exists],simpset()));
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   173
qed_spec_mp "hyperprime_factor_exists";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   174
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   175
(* behaves as expected! *)
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   176
Goal "( *sNat* insert x A) = insert (hypnat_of_nat x) ( *sNat* A)";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   177
by (auto_tac (claset(),simpset() addsimps [starsetNat_def,
14378
69c4d5997669 generic of_nat and of_int functions, and generalization of iszero
paulson
parents: 14371
diff changeset
   178
    hypnat_of_nat_eq]));
13957
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   179
by (ALLGOALS(res_inst_tac [("z","xa")] eq_Abs_hypnat));
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   180
by Auto_tac;
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   181
by (TRYALL(dtac bspec));
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   182
by Auto_tac;
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   183
by (ALLGOALS(Ultra_tac));
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   184
qed "NatStar_insert";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   185
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   186
(* Goldblatt Exercise 3.10(1) - p. 29 *)
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   187
Goal "finite A ==> *sNat* A = hypnat_of_nat ` A";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   188
by (res_inst_tac [("P","%x. *sNat* x = hypnat_of_nat ` x")] finite_induct 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   189
by (auto_tac (claset(),simpset() addsimps [NatStar_insert]));
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   190
qed "NatStar_hypnat_of_nat";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   191
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   192
(* proved elsewhere? *)
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   193
Goal "{x} ~: FreeUltrafilterNat";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   194
by (auto_tac (claset() addSIs [FreeUltrafilterNat_finite],simpset()));
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   195
qed "FreeUltrafilterNat_singleton_not_mem";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   196
Addsimps [FreeUltrafilterNat_singleton_not_mem];
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   197
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   198
(*-------------------------------------------------------------------------------*)
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   199
(* Another characterization of infinite set of natural numbers                   *)
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   200
(*-------------------------------------------------------------------------------*)
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   201
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   202
Goal "finite N ==> EX n. (ALL i:N. i<(n::nat))";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   203
by (eres_inst_tac [("F","N")] finite_induct 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   204
by Auto_tac;
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   205
by (res_inst_tac [("x","Suc n + x")] exI 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   206
by Auto_tac;
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   207
qed "finite_nat_set_bounded";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   208
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   209
Goal "finite N = (EX n. (ALL i:N. i<(n::nat)))";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   210
by (blast_tac (claset() addIs [finite_nat_set_bounded,
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   211
    bounded_nat_set_is_finite]) 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   212
qed "finite_nat_set_bounded_iff";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   213
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   214
Goal "(~ finite N) = (ALL n. EX i:N. n <= (i::nat))";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   215
by (auto_tac (claset(),simpset() addsimps [finite_nat_set_bounded_iff,
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   216
    le_def]));
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   217
qed "not_finite_nat_set_iff";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   218
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   219
Goal "(ALL i:N. i<=(n::nat)) ==> finite N";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   220
by (rtac finite_subset 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   221
 by (rtac finite_atMost 2);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   222
by Auto_tac;
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   223
qed "bounded_nat_set_is_finite2";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   224
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   225
Goal "finite N ==> EX n. (ALL i:N. i<=(n::nat))";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   226
by (eres_inst_tac [("F","N")] finite_induct 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   227
by Auto_tac;
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   228
by (res_inst_tac [("x","n + x")] exI 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   229
by Auto_tac;
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   230
qed "finite_nat_set_bounded2";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   231
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   232
Goal "finite N = (EX n. (ALL i:N. i<=(n::nat)))";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   233
by (blast_tac (claset() addIs [finite_nat_set_bounded2,
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   234
    bounded_nat_set_is_finite2]) 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   235
qed "finite_nat_set_bounded_iff2";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   236
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   237
Goal "(~ finite N) = (ALL n. EX i:N. n < (i::nat))";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   238
by (auto_tac (claset(),simpset() addsimps [finite_nat_set_bounded_iff2,
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   239
    le_def]));
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   240
qed "not_finite_nat_set_iff2";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   241
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   242
(*-------------------------------------------------------------------------------*)
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   243
(* An injective function cannot define an embedded natural number                *)
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   244
(*-------------------------------------------------------------------------------*)
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   245
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   246
Goal "ALL m n. m ~= n --> f n ~= f m \
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   247
\     ==>  {n. f n = N} = {} |  (EX m. {n. f n = N} = {m})";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   248
by Auto_tac;
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   249
by (dres_inst_tac [("x","x")] spec 1 THEN Auto_tac); 
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   250
by (subgoal_tac "ALL n. (f n = f x) = (x = n)" 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   251
by Auto_tac;
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   252
qed "lemma_infinite_set_singleton";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   253
14378
69c4d5997669 generic of_nat and of_int functions, and generalization of iszero
paulson
parents: 14371
diff changeset
   254
Goal "inj f ==> Abs_hypnat(hypnatrel `` {f}) ~: Nats";
69c4d5997669 generic of_nat and of_int functions, and generalization of iszero
paulson
parents: 14371
diff changeset
   255
by (auto_tac (claset(), simpset() addsimps [SHNat_eq,hypnat_of_nat_eq])); 
13957
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   256
by (subgoal_tac "ALL m n. m ~= n --> f n ~= f m" 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   257
by Auto_tac;
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   258
by (dtac injD 2);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   259
by (assume_tac 2 THEN Force_tac 2);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   260
by (dres_inst_tac[("N","N")] lemma_infinite_set_singleton 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   261
by Auto_tac;
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   262
qed "inj_fun_not_hypnat_in_SHNat";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   263
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   264
Goalw [starsetNat_def] 
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   265
   "range f <= A ==> Abs_hypnat(hypnatrel `` {f}) : *sNat* A";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   266
by Auto_tac;
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   267
by (Ultra_tac 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   268
by (dres_inst_tac [("c","f x")] subsetD 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   269
by (rtac rangeI 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   270
by Auto_tac;
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   271
qed "range_subset_mem_starsetNat";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   272
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   273
(*--------------------------------------------------------------------------------*)
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   274
(* Gleason Proposition 11-5.5. pg 149, pg 155 (ex. 3) and pg. 360                 *)
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   275
(* Let E be a nonvoid ordered set with no maximal elements (note: effectively an  *) 
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   276
(* infinite set if we take E = N (Nats)). Then there exists an order-preserving   *) 
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   277
(* injection from N to E. Of course, (as some doofus will undoubtedly point out!  *)
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   278
(* :-)) can use notion of least element in proof (i.e. no need for choice) if     *)
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   279
(* dealing with nats as we have well-ordering property                            *) 
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   280
(*--------------------------------------------------------------------------------*)
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   281
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   282
Goal "E ~= {} ==> EX x. EX X : (Pow E - {{}}). x: X";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   283
by Auto_tac;
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   284
val lemmaPow3 = result();
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   285
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   286
Goalw [choicefun_def] "E ~= {} ==> choicefun E : E";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   287
by (rtac (lemmaPow3 RS someI2_ex) 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   288
by Auto_tac;
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   289
qed "choicefun_mem_set";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   290
Addsimps [choicefun_mem_set];
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   291
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   292
Goal "[| E ~={}; ALL x. EX y: E. x < y |] ==> injf_max n E : E";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   293
by (induct_tac "n" 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   294
by (Force_tac 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   295
by (simp_tac (simpset() addsimps [choicefun_def]) 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   296
by (rtac (lemmaPow3 RS someI2_ex) 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   297
by Auto_tac;
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   298
qed "injf_max_mem_set";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   299
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   300
Goal "ALL x. EX y: E. x < y ==> injf_max n E < injf_max (Suc n) E";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   301
by (simp_tac (simpset() addsimps [choicefun_def]) 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   302
by (rtac (lemmaPow3 RS someI2_ex) 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   303
by Auto_tac;
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   304
qed "injf_max_order_preserving";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   305
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   306
Goal "ALL x. EX y: E. x < y \
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   307
\     ==> ALL n m. m < n --> injf_max m E < injf_max n E";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   308
by (rtac allI 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   309
by (induct_tac "n" 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   310
by Auto_tac;
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   311
by (simp_tac (simpset() addsimps [choicefun_def]) 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   312
by (rtac (lemmaPow3 RS someI2_ex) 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   313
by Auto_tac;
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   314
by (dtac (CLAIM "m < Suc n ==> m = n | m < n") 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   315
by Auto_tac;
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   316
by (dres_inst_tac [("x","m")] spec 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   317
by Auto_tac;
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   318
by (dtac subsetD 1 THEN Auto_tac);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   319
by (dres_inst_tac [("x","injf_max m E")] order_less_trans 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   320
by Auto_tac;
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   321
qed "injf_max_order_preserving2";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   322
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   323
Goal "ALL x. EX y: E. x < y ==> inj (%n. injf_max n E)";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   324
by (rtac injI 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   325
by (rtac ccontr 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   326
by Auto_tac;
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   327
by (dtac injf_max_order_preserving2 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   328
by (cut_inst_tac [("m","x"),("n","y")] less_linear 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   329
by Auto_tac;
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   330
by (auto_tac (claset() addSDs [spec],simpset()));
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   331
qed "inj_injf_max";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   332
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   333
Goal "[| (E::('a::{order} set)) ~= {}; ALL x. EX y: E. x < y |] \
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   334
\     ==> EX f. range f <= E & inj (f::nat => 'a) & (ALL m. f m < f(Suc m))";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   335
by (res_inst_tac [("x","%n. injf_max n E")] exI 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   336
by (Step_tac 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   337
by (rtac injf_max_mem_set 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   338
by (rtac inj_injf_max 3);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   339
by (rtac injf_max_order_preserving 4);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   340
by Auto_tac;
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   341
qed "infinite_set_has_order_preserving_inj";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   342
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   343
(*-------------------------------------------------------------------------------*)
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   344
(* Only need fact that we can have an injective function from N to A for proof   *)
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   345
(*-------------------------------------------------------------------------------*)
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   346
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   347
Goal "~ finite A ==> hypnat_of_nat ` A < ( *sNat* A)";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   348
by Auto_tac;
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   349
by (rtac subsetD 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   350
by (rtac NatStar_hypreal_of_real_image_subset 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   351
by Auto_tac;
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   352
by (subgoal_tac "A ~= {}" 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   353
by (Force_tac 2);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   354
by (dtac infinite_set_has_order_preserving_inj 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   355
by (etac (not_finite_nat_set_iff2 RS iffD1) 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   356
by Auto_tac;
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   357
by (dtac inj_fun_not_hypnat_in_SHNat 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   358
by (dtac range_subset_mem_starsetNat 1);
14378
69c4d5997669 generic of_nat and of_int functions, and generalization of iszero
paulson
parents: 14371
diff changeset
   359
by (auto_tac (claset(),simpset() addsimps [SHNat_eq]));
13957
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   360
qed "hypnat_infinite_has_nonstandard";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   361
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   362
Goal "*sNat* A =  hypnat_of_nat ` A ==> finite A";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   363
by (rtac ccontr 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   364
by (auto_tac (claset() addDs [hypnat_infinite_has_nonstandard],
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   365
    simpset()));
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   366
qed "starsetNat_eq_hypnat_of_nat_image_finite";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   367
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   368
Goal "( *sNat* A = hypnat_of_nat ` A) = (finite A)";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   369
by (blast_tac (claset() addSIs [starsetNat_eq_hypnat_of_nat_image_finite,
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   370
    NatStar_hypnat_of_nat]) 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   371
qed "finite_starsetNat_iff";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   372
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   373
Goal "(~ finite A) = (hypnat_of_nat ` A < *sNat* A)";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   374
by (rtac iffI 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   375
by (blast_tac (claset() addSIs [hypnat_infinite_has_nonstandard]) 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   376
by (auto_tac (claset(),simpset() addsimps [finite_starsetNat_iff RS sym]));
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   377
qed "hypnat_infinite_has_nonstandard_iff";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   378
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   379
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   380
(*-------------------------------------------------------------------------------*)
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   381
(* Existence of infinitely many primes: a nonstandard proof                      *)
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   382
(*-------------------------------------------------------------------------------*)
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   383
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   384
Goal "~ (ALL n:- {0}. hypnat_of_nat n hdvd 1)";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   385
by Auto_tac;
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   386
by (res_inst_tac [("x","2")] bexI 1);
14378
69c4d5997669 generic of_nat and of_int functions, and generalization of iszero
paulson
parents: 14371
diff changeset
   387
by (auto_tac (claset(),simpset() addsimps [hypnat_of_nat_eq,
13957
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   388
    hypnat_one_def,hdvd,dvd_def]));
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   389
val lemma_not_dvd_hypnat_one = result();
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   390
Addsimps [lemma_not_dvd_hypnat_one];
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   391
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   392
Goal "EX n:- {0}. ~ hypnat_of_nat n hdvd 1";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   393
by (cut_facts_tac [lemma_not_dvd_hypnat_one] 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   394
by (auto_tac (claset(),simpset() delsimps [lemma_not_dvd_hypnat_one]));
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   395
val lemma_not_dvd_hypnat_one2 = result();
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   396
Addsimps [lemma_not_dvd_hypnat_one2];
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   397
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   398
(* not needed here *)
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   399
Goalw [hypnat_zero_def,hypnat_one_def] 
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   400
  "[| 0 < (N::hypnat); N ~= 1 |] ==> 1 < N";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   401
by (res_inst_tac [("z","N")] eq_Abs_hypnat 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   402
by (auto_tac (claset(),simpset() addsimps [hypnat_less]));
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   403
by (Ultra_tac 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   404
qed "hypnat_gt_zero_gt_one";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   405
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   406
Goalw [hypnat_zero_def,hypnat_one_def]
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   407
    "0 < N ==> 1 < (N::hypnat) + 1";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   408
by (res_inst_tac [("z","N")] eq_Abs_hypnat 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   409
by (auto_tac (claset(),simpset() addsimps [hypnat_less,hypnat_add]));
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   410
qed "hypnat_add_one_gt_one";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   411
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   412
Goal "0 ~: prime";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   413
by (Step_tac 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   414
by (dtac (thm "prime_g_zero") 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   415
by Auto_tac;
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   416
qed "zero_not_prime";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   417
Addsimps [zero_not_prime];
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   418
14378
69c4d5997669 generic of_nat and of_int functions, and generalization of iszero
paulson
parents: 14371
diff changeset
   419
Goal "hypnat_of_nat 0 ~: starprime";
69c4d5997669 generic of_nat and of_int functions, and generalization of iszero
paulson
parents: 14371
diff changeset
   420
by (auto_tac (claset() addSIs [bexI],
69c4d5997669 generic of_nat and of_int functions, and generalization of iszero
paulson
parents: 14371
diff changeset
   421
      simpset() addsimps [starprime_def,starsetNat_def,hypnat_of_nat_eq]));
13957
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   422
qed "hypnat_of_nat_zero_not_prime";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   423
Addsimps [hypnat_of_nat_zero_not_prime];
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   424
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   425
Goalw [starprime_def,starsetNat_def,hypnat_zero_def]
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   426
   "0 ~: starprime";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   427
by (auto_tac (claset() addSIs [bexI],simpset()));
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   428
qed "hypnat_zero_not_prime";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   429
Addsimps [hypnat_zero_not_prime];
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   430
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   431
Goal "1 ~: prime";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   432
by (Step_tac 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   433
by (dtac (thm "prime_g_one") 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   434
by Auto_tac;
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   435
qed "one_not_prime";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   436
Addsimps [one_not_prime];
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   437
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   438
Goal "Suc 0 ~: prime";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   439
by (Step_tac 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   440
by (dtac (thm "prime_g_one") 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   441
by Auto_tac;
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   442
qed "one_not_prime2";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   443
Addsimps [one_not_prime2];
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   444
14378
69c4d5997669 generic of_nat and of_int functions, and generalization of iszero
paulson
parents: 14371
diff changeset
   445
Goal "hypnat_of_nat 1 ~: starprime";
69c4d5997669 generic of_nat and of_int functions, and generalization of iszero
paulson
parents: 14371
diff changeset
   446
by (auto_tac (claset() addSIs [bexI],
69c4d5997669 generic of_nat and of_int functions, and generalization of iszero
paulson
parents: 14371
diff changeset
   447
     simpset() addsimps [starprime_def,starsetNat_def,hypnat_of_nat_eq]));
13957
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   448
qed "hypnat_of_nat_one_not_prime";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   449
Addsimps [hypnat_of_nat_one_not_prime];
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   450
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   451
Goalw [starprime_def,starsetNat_def,hypnat_one_def]
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   452
   "1 ~: starprime";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   453
by (auto_tac (claset() addSIs [bexI],simpset()));
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   454
qed "hypnat_one_not_prime";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   455
Addsimps [hypnat_one_not_prime];
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   456
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   457
Goal "[| k hdvd m; k hdvd n |] ==> k hdvd (m - n)";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   458
by (res_inst_tac [("z","k")] eq_Abs_hypnat 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   459
by (res_inst_tac [("z","m")] eq_Abs_hypnat 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   460
by (res_inst_tac [("z","n")] eq_Abs_hypnat 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   461
by (auto_tac (claset(),simpset() addsimps [hdvd,hypnat_minus]));
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   462
by (Ultra_tac 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   463
by (blast_tac (claset() addIs [dvd_diff]) 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   464
qed "hdvd_diff";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   465
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   466
Goalw [dvd_def] "x dvd (1::nat) ==> x = 1";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   467
by Auto_tac;
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   468
qed "dvd_one_eq_one";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   469
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   470
Goalw [hypnat_one_def] "x hdvd 1 ==> x = 1";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   471
by (res_inst_tac [("z","x")] eq_Abs_hypnat 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   472
by (auto_tac (claset(),simpset() addsimps [hdvd]));
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   473
qed "hdvd_one_eq_one";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   474
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   475
Goal "~ finite prime";
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   476
by (rtac (hypnat_infinite_has_nonstandard_iff RS iffD2) 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   477
by (cut_facts_tac [hypnat_dvd_all_hypnat_of_nat] 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   478
by (etac exE 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   479
by (etac conjE 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   480
by (subgoal_tac "1 < N + 1" 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   481
by (blast_tac (claset() addIs [hypnat_add_one_gt_one]) 2);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   482
by (dtac hyperprime_factor_exists 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   483
by (auto_tac (claset() addIs [NatStar_mem],simpset()));
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   484
by (subgoal_tac "k ~: hypnat_of_nat ` prime" 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   485
by (force_tac (claset(),simpset() addsimps [starprime_def]) 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   486
by (Step_tac 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   487
by (dres_inst_tac [("x","x")] bspec 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   488
by (rtac ccontr 1 THEN Asm_full_simp_tac 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   489
by (dtac hdvd_diff 1 THEN assume_tac 1);
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   490
by (auto_tac (claset() addDs [hdvd_one_eq_one],simpset()));
10dbf16be15f new session Complex for the complex numbers
paulson
parents:
diff changeset
   491
qed "not_finite_prime";