src/HOL/Nonstandard_Analysis/NatStar.thy
author immler
Sun, 03 Nov 2019 21:46:46 -0500
changeset 71034 e0755162093f
parent 70219 b21efbf64292
permissions -rw-r--r--
replace approximation oracle by less ad-hoc @{computation}s
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
62479
716336f19aa9 clarified session;
wenzelm
parents: 61975
diff changeset
     1
(*  Title:      HOL/Nonstandard_Analysis/NatStar.thy
716336f19aa9 clarified session;
wenzelm
parents: 61975
diff changeset
     2
    Author:     Jacques D. Fleuriot
716336f19aa9 clarified session;
wenzelm
parents: 61975
diff changeset
     3
    Copyright:  1998  University of Cambridge
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
     4
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
     5
Converted to Isar and polished by lcp
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
     6
*)
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
     7
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
     8
section \<open>Star-transforms for the Hypernaturals\<close>
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
     9
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    10
theory NatStar
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    11
  imports Star
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    12
begin
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    13
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    14
lemma star_n_eq_starfun_whn: "star_n X = ( *f* X) whn"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    15
  by (simp add: hypnat_omega_def starfun_def star_of_def Ifun_star_n)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    16
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    17
lemma starset_n_Un: "*sn* (\<lambda>n. (A n) \<union> (B n)) = *sn* A \<union> *sn* B"
70219
b21efbf64292 yet more de-applying
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
    18
proof -
b21efbf64292 yet more de-applying
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
    19
  have "\<And>N. Iset ((*f* (\<lambda>n. {x. x \<in> A n \<or> x \<in> B n})) N) =
b21efbf64292 yet more de-applying
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
    20
    {x. x \<in> Iset ((*f* A) N) \<or> x \<in> Iset ((*f* B) N)}"
b21efbf64292 yet more de-applying
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
    21
    by transfer simp
b21efbf64292 yet more de-applying
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
    22
  then show ?thesis
b21efbf64292 yet more de-applying
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
    23
    by (simp add: starset_n_def star_n_eq_starfun_whn Un_def)
b21efbf64292 yet more de-applying
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
    24
qed
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    25
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    26
lemma InternalSets_Un: "X \<in> InternalSets \<Longrightarrow> Y \<in> InternalSets \<Longrightarrow> X \<union> Y \<in> InternalSets"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    27
  by (auto simp add: InternalSets_def starset_n_Un [symmetric])
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    28
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    29
lemma starset_n_Int: "*sn* (\<lambda>n. A n \<inter> B n) = *sn* A \<inter> *sn* B"
70219
b21efbf64292 yet more de-applying
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
    30
proof -
b21efbf64292 yet more de-applying
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
    31
  have "\<And>N. Iset ((*f* (\<lambda>n. {x. x \<in> A n \<and> x \<in> B n})) N) =
b21efbf64292 yet more de-applying
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
    32
    {x. x \<in> Iset ((*f* A) N) \<and> x \<in> Iset ((*f* B) N)}"
b21efbf64292 yet more de-applying
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
    33
    by transfer simp
b21efbf64292 yet more de-applying
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
    34
  then show ?thesis
b21efbf64292 yet more de-applying
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
    35
    by (simp add: starset_n_def star_n_eq_starfun_whn Int_def)
b21efbf64292 yet more de-applying
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
    36
qed
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    37
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    38
lemma InternalSets_Int: "X \<in> InternalSets \<Longrightarrow> Y \<in> InternalSets \<Longrightarrow> X \<inter> Y \<in> InternalSets"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    39
  by (auto simp add: InternalSets_def starset_n_Int [symmetric])
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    40
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    41
lemma starset_n_Compl: "*sn* ((\<lambda>n. - A n)) = - ( *sn* A)"
70219
b21efbf64292 yet more de-applying
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
    42
proof -
b21efbf64292 yet more de-applying
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
    43
  have "\<And>N. Iset ((*f* (\<lambda>n. {x. x \<notin> A n})) N) =
b21efbf64292 yet more de-applying
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
    44
    {x. x \<notin> Iset ((*f* A) N)}"
b21efbf64292 yet more de-applying
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
    45
    by transfer simp
b21efbf64292 yet more de-applying
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
    46
  then show ?thesis
b21efbf64292 yet more de-applying
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
    47
    by (simp add: starset_n_def star_n_eq_starfun_whn Compl_eq)
b21efbf64292 yet more de-applying
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
    48
qed
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    49
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    50
lemma InternalSets_Compl: "X \<in> InternalSets \<Longrightarrow> - X \<in> InternalSets"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    51
  by (auto simp add: InternalSets_def starset_n_Compl [symmetric])
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    52
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    53
lemma starset_n_diff: "*sn* (\<lambda>n. (A n) - (B n)) = *sn* A - *sn* B"
70219
b21efbf64292 yet more de-applying
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
    54
proof -
b21efbf64292 yet more de-applying
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
    55
  have "\<And>N. Iset ((*f* (\<lambda>n. {x. x \<in> A n \<and> x \<notin> B n})) N) =
b21efbf64292 yet more de-applying
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
    56
    {x. x \<in> Iset ((*f* A) N) \<and> x \<notin> Iset ((*f* B) N)}"
b21efbf64292 yet more de-applying
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
    57
    by transfer simp
b21efbf64292 yet more de-applying
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
    58
  then show ?thesis
b21efbf64292 yet more de-applying
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
    59
    by (simp add: starset_n_def star_n_eq_starfun_whn set_diff_eq)
b21efbf64292 yet more de-applying
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
    60
qed
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    61
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    62
lemma InternalSets_diff: "X \<in> InternalSets \<Longrightarrow> Y \<in> InternalSets \<Longrightarrow> X - Y \<in> InternalSets"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    63
  by (auto simp add: InternalSets_def starset_n_diff [symmetric])
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    64
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    65
lemma NatStar_SHNat_subset: "Nats \<le> *s* (UNIV:: nat set)"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    66
  by simp
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    67
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    68
lemma NatStar_hypreal_of_real_Int: "*s* X Int Nats = hypnat_of_nat ` X"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    69
  by (auto simp add: SHNat_eq)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    70
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    71
lemma starset_starset_n_eq: "*s* X = *sn* (\<lambda>n. X)"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    72
  by (simp add: starset_n_starset)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    73
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    74
lemma InternalSets_starset_n [simp]: "( *s* X) \<in> InternalSets"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    75
  by (auto simp add: InternalSets_def starset_starset_n_eq)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    76
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    77
lemma InternalSets_UNIV_diff: "X \<in> InternalSets \<Longrightarrow> UNIV - X \<in> InternalSets"
70219
b21efbf64292 yet more de-applying
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
    78
  by (simp add: InternalSets_Compl diff_eq)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    79
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    80
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    81
subsection \<open>Nonstandard Extensions of Functions\<close>
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    82
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    83
text \<open>Example of transfer of a property from reals to hyperreals
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    84
  --- used for limit comparison of sequences.\<close>
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    85
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    86
lemma starfun_le_mono: "\<forall>n. N \<le> n \<longrightarrow> f n \<le> g n \<Longrightarrow>
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    87
  \<forall>n. hypnat_of_nat N \<le> n \<longrightarrow> ( *f* f) n \<le> ( *f* g) n"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    88
  by transfer
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    89
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    90
text \<open>And another:\<close>
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    91
lemma starfun_less_mono:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    92
  "\<forall>n. N \<le> n \<longrightarrow> f n < g n \<Longrightarrow> \<forall>n. hypnat_of_nat N \<le> n \<longrightarrow> ( *f* f) n < ( *f* g) n"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    93
  by transfer
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    94
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    95
text \<open>Nonstandard extension when we increment the argument by one.\<close>
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    96
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    97
lemma starfun_shift_one: "\<And>N. ( *f* (\<lambda>n. f (Suc n))) N = ( *f* f) (N + (1::hypnat))"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
    98
  by transfer simp
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    99
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   100
text \<open>Nonstandard extension with absolute value.\<close>
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   101
lemma starfun_abs: "\<And>N. ( *f* (\<lambda>n. \<bar>f n\<bar>)) N = \<bar>( *f* f) N\<bar>"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   102
  by transfer (rule refl)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   103
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   104
text \<open>The \<open>hyperpow\<close> function as a nonstandard extension of \<open>realpow\<close>.\<close>
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   105
lemma starfun_pow: "\<And>N. ( *f* (\<lambda>n. r ^ n)) N = hypreal_of_real r pow N"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   106
  by transfer (rule refl)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   107
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   108
lemma starfun_pow2: "\<And>N. ( *f* (\<lambda>n. X n ^ m)) N = ( *f* X) N pow hypnat_of_nat m"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   109
  by transfer (rule refl)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   110
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   111
lemma starfun_pow3: "\<And>R. ( *f* (\<lambda>r. r ^ n)) R = R pow hypnat_of_nat n"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   112
  by transfer (rule refl)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   113
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 67399
diff changeset
   114
text \<open>The \<^term>\<open>hypreal_of_hypnat\<close> function as a nonstandard extension of
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 67399
diff changeset
   115
  \<^term>\<open>real_of_nat\<close>.\<close>
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   116
lemma starfunNat_real_of_nat: "( *f* real) = hypreal_of_hypnat"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   117
  by transfer (simp add: fun_eq_iff)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   118
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   119
lemma starfun_inverse_real_of_nat_eq:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   120
  "N \<in> HNatInfinite \<Longrightarrow> ( *f* (\<lambda>x::nat. inverse (real x))) N = inverse (hypreal_of_hypnat N)"
70219
b21efbf64292 yet more de-applying
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   121
  by (metis of_hypnat_def starfun_inverse2)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   122
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   123
text \<open>Internal functions -- some redundancy with \<open>*f*\<close> now.\<close>
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   124
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   125
lemma starfun_n: "( *fn* f) (star_n X) = star_n (\<lambda>n. f n (X n))"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   126
  by (simp add: starfun_n_def Ifun_star_n)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   127
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   128
text \<open>Multiplication: \<open>( *fn) x ( *gn) = *(fn x gn)\<close>\<close>
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   129
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   130
lemma starfun_n_mult: "( *fn* f) z * ( *fn* g) z = ( *fn* (\<lambda>i x. f i x * g i x)) z"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   131
  by (cases z) (simp add: starfun_n star_n_mult)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   132
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   133
text \<open>Addition: \<open>( *fn) + ( *gn) = *(fn + gn)\<close>\<close>
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   134
lemma starfun_n_add: "( *fn* f) z + ( *fn* g) z = ( *fn* (\<lambda>i x. f i x + g i x)) z"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   135
  by (cases z) (simp add: starfun_n star_n_add)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   136
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   137
text \<open>Subtraction: \<open>( *fn) - ( *gn) = *(fn + - gn)\<close>\<close>
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   138
lemma starfun_n_add_minus: "( *fn* f) z + -( *fn* g) z = ( *fn* (\<lambda>i x. f i x + -g i x)) z"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   139
  by (cases z) (simp add: starfun_n star_n_minus star_n_add)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   140
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   141
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   142
text \<open>Composition: \<open>( *fn) \<circ> ( *gn) = *(fn \<circ> gn)\<close>\<close>
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   143
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   144
lemma starfun_n_const_fun [simp]: "( *fn* (\<lambda>i x. k)) z = star_of k"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   145
  by (cases z) (simp add: starfun_n star_of_def)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   146
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   147
lemma starfun_n_minus: "- ( *fn* f) x = ( *fn* (\<lambda>i x. - (f i) x)) x"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   148
  by (cases x) (simp add: starfun_n star_n_minus)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   149
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   150
lemma starfun_n_eq [simp]: "( *fn* f) (star_of n) = star_n (\<lambda>i. f i n)"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   151
  by (simp add: starfun_n star_of_def)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   152
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   153
lemma starfun_eq_iff: "(( *f* f) = ( *f* g)) \<longleftrightarrow> f = g"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   154
  by transfer (rule refl)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   155
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   156
lemma starfunNat_inverse_real_of_nat_Infinitesimal [simp]:
67091
1393c2340eec more symbols;
wenzelm
parents: 64435
diff changeset
   157
  "N \<in> HNatInfinite \<Longrightarrow> ( *f* (\<lambda>x. inverse (real x))) N \<in> Infinitesimal"
70219
b21efbf64292 yet more de-applying
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   158
  using starfun_inverse_real_of_nat_eq by auto
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   159
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   160
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   161
subsection \<open>Nonstandard Characterization of Induction\<close>
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   162
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   163
lemma hypnat_induct_obj:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   164
  "\<And>n. (( *p* P) (0::hypnat) \<and> (\<forall>n. ( *p* P) n \<longrightarrow> ( *p* P) (n + 1))) \<longrightarrow> ( *p* P) n"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   165
  by transfer (induct_tac n, auto)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   166
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   167
lemma hypnat_induct:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   168
  "\<And>n. ( *p* P) (0::hypnat) \<Longrightarrow> (\<And>n. ( *p* P) n \<Longrightarrow> ( *p* P) (n + 1)) \<Longrightarrow> ( *p* P) n"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   169
  by transfer (induct_tac n, auto)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   170
67399
eab6ce8368fa ran isabelle update_op on all sources
nipkow
parents: 67091
diff changeset
   171
lemma starP2_eq_iff: "( *p2* (=)) = (=)"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   172
  by transfer (rule refl)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   173
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   174
lemma starP2_eq_iff2: "( *p2* (\<lambda>x y. x = y)) X Y \<longleftrightarrow> X = Y"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   175
  by (simp add: starP2_eq_iff)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   176
70219
b21efbf64292 yet more de-applying
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   177
lemma nonempty_set_star_has_least_lemma:
b21efbf64292 yet more de-applying
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   178
  "\<exists>n\<in>S. \<forall>m\<in>S. n \<le> m" if "S \<noteq> {}" for S :: "nat set"
b21efbf64292 yet more de-applying
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   179
proof
b21efbf64292 yet more de-applying
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   180
  show "\<forall>m\<in>S. (LEAST n. n \<in> S) \<le> m"
b21efbf64292 yet more de-applying
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   181
    by (simp add: Least_le)
b21efbf64292 yet more de-applying
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   182
  show "(LEAST n. n \<in> S) \<in> S"
b21efbf64292 yet more de-applying
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   183
    by (meson that LeastI_ex equals0I)
b21efbf64292 yet more de-applying
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   184
qed
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   185
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   186
lemma nonempty_set_star_has_least:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   187
  "\<And>S::nat set star. Iset S \<noteq> {} \<Longrightarrow> \<exists>n \<in> Iset S. \<forall>m \<in> Iset S. n \<le> m"
70219
b21efbf64292 yet more de-applying
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   188
  using nonempty_set_star_has_least_lemma by (transfer empty_def)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   189
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   190
lemma nonempty_InternalNatSet_has_least: "S \<in> InternalSets \<Longrightarrow> S \<noteq> {} \<Longrightarrow> \<exists>n \<in> S. \<forall>m \<in> S. n \<le> m"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   191
  for S :: "hypnat set"
70219
b21efbf64292 yet more de-applying
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   192
  by (force simp add: InternalSets_def starset_n_def dest!: nonempty_set_star_has_least)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   193
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   194
text \<open>Goldblatt, page 129 Thm 11.3.2.\<close>
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   195
lemma internal_induct_lemma:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   196
  "\<And>X::nat set star.
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   197
    (0::hypnat) \<in> Iset X \<Longrightarrow> \<forall>n. n \<in> Iset X \<longrightarrow> n + 1 \<in> Iset X \<Longrightarrow> Iset X = (UNIV:: hypnat set)"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   198
  apply (transfer UNIV_def)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   199
  apply (rule equalityI [OF subset_UNIV subsetI])
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   200
  apply (induct_tac x, auto)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   201
  done
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   202
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   203
lemma internal_induct:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   204
  "X \<in> InternalSets \<Longrightarrow> (0::hypnat) \<in> X \<Longrightarrow> \<forall>n. n \<in> X \<longrightarrow> n + 1 \<in> X \<Longrightarrow> X = (UNIV:: hypnat set)"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   205
  apply (clarsimp simp add: InternalSets_def starset_n_def)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   206
  apply (erule (1) internal_induct_lemma)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 62479
diff changeset
   207
  done
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   208
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   209
end