src/HOL/Nonstandard_Analysis/NSA.thy
author paulson <lp15@cam.ac.uk>
Tue, 30 Apr 2019 21:04:08 +0100
changeset 70221 bca14283e1a8
parent 69597 ff784d5a5bfb
child 70224 3706106c2e0f
permissions -rw-r--r--
huge de-apply effort
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
62479
716336f19aa9 clarified session;
wenzelm
parents: 61982
diff changeset
     1
(*  Title:      HOL/Nonstandard_Analysis/NSA.thy
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32155
diff changeset
     2
    Author:     Jacques D. Fleuriot, University of Cambridge
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32155
diff changeset
     3
    Author:     Lawrence C Paulson, 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
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
     6
section \<open>Infinite Numbers, Infinitesimals, Infinitely Close Relation\<close>
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
     7
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
     8
theory NSA
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
     9
  imports HyperDef "HOL-Library.Lub_Glb" 
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    10
begin
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    11
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
    12
definition hnorm :: "'a::real_normed_vector star \<Rightarrow> real star"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
    13
  where [transfer_unfold]: "hnorm = *f* norm"
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    14
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
    15
definition Infinitesimal  :: "('a::real_normed_vector) star set"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
    16
  where "Infinitesimal = {x. \<forall>r \<in> Reals. 0 < r \<longrightarrow> hnorm x < r}"
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    17
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
    18
definition HFinite :: "('a::real_normed_vector) star set"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
    19
  where "HFinite = {x. \<exists>r \<in> Reals. hnorm x < r}"
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    20
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
    21
definition HInfinite :: "('a::real_normed_vector) star set"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
    22
  where "HInfinite = {x. \<forall>r \<in> Reals. r < hnorm x}"
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    23
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
    24
definition approx :: "'a::real_normed_vector star \<Rightarrow> 'a star \<Rightarrow> bool"  (infixl "\<approx>" 50)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
    25
  where "x \<approx> y \<longleftrightarrow> x - y \<in> Infinitesimal"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
    26
    \<comment> \<open>the ``infinitely close'' relation\<close>
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    27
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
    28
definition st :: "hypreal \<Rightarrow> hypreal"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
    29
  where "st = (\<lambda>x. SOME r. x \<in> HFinite \<and> r \<in> \<real> \<and> r \<approx> x)"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
    30
    \<comment> \<open>the standard part of a hyperreal\<close>
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    31
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
    32
definition monad :: "'a::real_normed_vector star \<Rightarrow> 'a star set"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
    33
  where "monad x = {y. x \<approx> y}"
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    34
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
    35
definition galaxy :: "'a::real_normed_vector star \<Rightarrow> 'a star set"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
    36
  where "galaxy x = {y. (x + -y) \<in> HFinite}"
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    37
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
    38
lemma SReal_def: "\<real> \<equiv> {x. \<exists>r. x = hypreal_of_real r}"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
    39
  by (simp add: Reals_def image_def)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
    40
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    41
61975
b4b11391c676 isabelle update_cartouches -c -t;
wenzelm
parents: 61945
diff changeset
    42
subsection \<open>Nonstandard Extension of the Norm Function\<close>
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    43
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
    44
definition scaleHR :: "real star \<Rightarrow> 'a star \<Rightarrow> 'a::real_normed_vector star"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
    45
  where [transfer_unfold]: "scaleHR = starfun2 scaleR"
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    46
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    47
lemma Standard_hnorm [simp]: "x \<in> Standard \<Longrightarrow> hnorm x \<in> Standard"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
    48
  by (simp add: hnorm_def)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    49
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    50
lemma star_of_norm [simp]: "star_of (norm x) = hnorm (star_of x)"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
    51
  by transfer (rule refl)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    52
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
    53
lemma hnorm_ge_zero [simp]: "\<And>x::'a::real_normed_vector star. 0 \<le> hnorm x"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
    54
  by transfer (rule norm_ge_zero)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    55
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
    56
lemma hnorm_eq_zero [simp]: "\<And>x::'a::real_normed_vector star. hnorm x = 0 \<longleftrightarrow> x = 0"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
    57
  by transfer (rule norm_eq_zero)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    58
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
    59
lemma hnorm_triangle_ineq: "\<And>x y::'a::real_normed_vector star. hnorm (x + y) \<le> hnorm x + hnorm y"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
    60
  by transfer (rule norm_triangle_ineq)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    61
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
    62
lemma hnorm_triangle_ineq3: "\<And>x y::'a::real_normed_vector star. \<bar>hnorm x - hnorm y\<bar> \<le> hnorm (x - y)"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
    63
  by transfer (rule norm_triangle_ineq3)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
    64
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
    65
lemma hnorm_scaleR: "\<And>x::'a::real_normed_vector star. hnorm (a *\<^sub>R x) = \<bar>star_of a\<bar> * hnorm x"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
    66
  by transfer (rule norm_scaleR)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    67
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
    68
lemma hnorm_scaleHR: "\<And>a (x::'a::real_normed_vector star). hnorm (scaleHR a x) = \<bar>a\<bar> * hnorm x"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
    69
  by transfer (rule norm_scaleR)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    70
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
    71
lemma hnorm_mult_ineq: "\<And>x y::'a::real_normed_algebra star. hnorm (x * y) \<le> hnorm x * hnorm y"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
    72
  by transfer (rule norm_mult_ineq)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    73
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
    74
lemma hnorm_mult: "\<And>x y::'a::real_normed_div_algebra star. hnorm (x * y) = hnorm x * hnorm y"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
    75
  by transfer (rule norm_mult)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    76
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
    77
lemma hnorm_hyperpow: "\<And>(x::'a::{real_normed_div_algebra} star) n. hnorm (x pow n) = hnorm x pow n"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
    78
  by transfer (rule norm_power)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
    79
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
    80
lemma hnorm_one [simp]: "hnorm (1::'a::real_normed_div_algebra star) = 1"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
    81
  by transfer (rule norm_one)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    82
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
    83
lemma hnorm_zero [simp]: "hnorm (0::'a::real_normed_vector star) = 0"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
    84
  by transfer (rule norm_zero)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    85
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
    86
lemma zero_less_hnorm_iff [simp]: "\<And>x::'a::real_normed_vector star. 0 < hnorm x \<longleftrightarrow> x \<noteq> 0"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
    87
  by transfer (rule zero_less_norm_iff)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    88
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
    89
lemma hnorm_minus_cancel [simp]: "\<And>x::'a::real_normed_vector star. hnorm (- x) = hnorm x"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
    90
  by transfer (rule norm_minus_cancel)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    91
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
    92
lemma hnorm_minus_commute: "\<And>a b::'a::real_normed_vector star. hnorm (a - b) = hnorm (b - a)"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
    93
  by transfer (rule norm_minus_commute)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    94
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
    95
lemma hnorm_triangle_ineq2: "\<And>a b::'a::real_normed_vector star. hnorm a - hnorm b \<le> hnorm (a - b)"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
    96
  by transfer (rule norm_triangle_ineq2)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
    97
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
    98
lemma hnorm_triangle_ineq4: "\<And>a b::'a::real_normed_vector star. hnorm (a - b) \<le> hnorm a + hnorm b"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
    99
  by transfer (rule norm_triangle_ineq4)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   100
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   101
lemma abs_hnorm_cancel [simp]: "\<And>a::'a::real_normed_vector star. \<bar>hnorm a\<bar> = hnorm a"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   102
  by transfer (rule abs_norm_cancel)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   103
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   104
lemma hnorm_of_hypreal [simp]: "\<And>r. hnorm (of_hypreal r::'a::real_normed_algebra_1 star) = \<bar>r\<bar>"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   105
  by transfer (rule norm_of_real)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   106
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   107
lemma nonzero_hnorm_inverse:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   108
  "\<And>a::'a::real_normed_div_algebra star. a \<noteq> 0 \<Longrightarrow> hnorm (inverse a) = inverse (hnorm a)"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   109
  by transfer (rule nonzero_norm_inverse)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   110
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   111
lemma hnorm_inverse:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   112
  "\<And>a::'a::{real_normed_div_algebra, division_ring} star. hnorm (inverse a) = inverse (hnorm a)"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   113
  by transfer (rule norm_inverse)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   114
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   115
lemma hnorm_divide: "\<And>a b::'a::{real_normed_field, field} star. hnorm (a / b) = hnorm a / hnorm b"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   116
  by transfer (rule norm_divide)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   117
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   118
lemma hypreal_hnorm_def [simp]: "\<And>r::hypreal. hnorm r = \<bar>r\<bar>"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   119
  by transfer (rule real_norm_def)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   120
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   121
lemma hnorm_add_less:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   122
  "\<And>(x::'a::real_normed_vector star) y r s. hnorm x < r \<Longrightarrow> hnorm y < s \<Longrightarrow> hnorm (x + y) < r + s"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   123
  by transfer (rule norm_add_less)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   124
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   125
lemma hnorm_mult_less:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   126
  "\<And>(x::'a::real_normed_algebra star) y r s. hnorm x < r \<Longrightarrow> hnorm y < s \<Longrightarrow> hnorm (x * y) < r * s"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   127
  by transfer (rule norm_mult_less)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   128
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   129
lemma hnorm_scaleHR_less: "\<bar>x\<bar> < r \<Longrightarrow> hnorm y < s \<Longrightarrow> hnorm (scaleHR x y) < r * s"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   130
 by (simp only: hnorm_scaleHR) (simp add: mult_strict_mono')
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   131
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   132
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   133
subsection \<open>Closure Laws for the Standard Reals\<close>
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   134
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   135
lemma Reals_add_cancel: "x + y \<in> \<real> \<Longrightarrow> y \<in> \<real> \<Longrightarrow> x \<in> \<real>"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   136
  by (drule (1) Reals_diff) simp
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   137
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   138
lemma SReal_hrabs: "x \<in> \<real> \<Longrightarrow> \<bar>x\<bar> \<in> \<real>"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   139
  for x :: hypreal
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   140
  by (simp add: Reals_eq_Standard)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   141
61070
b72a990adfe2 prefer symbols;
wenzelm
parents: 60041
diff changeset
   142
lemma SReal_hypreal_of_real [simp]: "hypreal_of_real x \<in> \<real>"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   143
  by (simp add: Reals_eq_Standard)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   144
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   145
lemma SReal_divide_numeral: "r \<in> \<real> \<Longrightarrow> r / (numeral w::hypreal) \<in> \<real>"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   146
  by simp
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   147
61981
1b5845c62fa0 more symbols;
wenzelm
parents: 61975
diff changeset
   148
text \<open>\<open>\<epsilon>\<close> is not in Reals because it is an infinitesimal\<close>
1b5845c62fa0 more symbols;
wenzelm
parents: 61975
diff changeset
   149
lemma SReal_epsilon_not_mem: "\<epsilon> \<notin> \<real>"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   150
  by (auto simp: SReal_def hypreal_of_real_not_eq_epsilon [symmetric])
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   151
61981
1b5845c62fa0 more symbols;
wenzelm
parents: 61975
diff changeset
   152
lemma SReal_omega_not_mem: "\<omega> \<notin> \<real>"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   153
  by (auto simp: SReal_def hypreal_of_real_not_eq_omega [symmetric])
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   154
61070
b72a990adfe2 prefer symbols;
wenzelm
parents: 60041
diff changeset
   155
lemma SReal_UNIV_real: "{x. hypreal_of_real x \<in> \<real>} = (UNIV::real set)"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   156
  by simp
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   157
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   158
lemma SReal_iff: "x \<in> \<real> \<longleftrightarrow> (\<exists>y. x = hypreal_of_real y)"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   159
  by (simp add: SReal_def)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   160
61070
b72a990adfe2 prefer symbols;
wenzelm
parents: 60041
diff changeset
   161
lemma hypreal_of_real_image: "hypreal_of_real `(UNIV::real set) = \<real>"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   162
  by (simp add: Reals_eq_Standard Standard_def)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   163
61070
b72a990adfe2 prefer symbols;
wenzelm
parents: 60041
diff changeset
   164
lemma inv_hypreal_of_real_image: "inv hypreal_of_real ` \<real> = UNIV"
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   165
  by (simp add: Reals_eq_Standard Standard_def inj_star_of)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   166
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   167
lemma SReal_dense: "x \<in> \<real> \<Longrightarrow> y \<in> \<real> \<Longrightarrow> x < y \<Longrightarrow> \<exists>r \<in> Reals. x < r \<and> r < y"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   168
  for x y :: hypreal
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   169
  using dense by (fastforce simp add: SReal_def)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   170
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   171
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   172
subsection \<open>Set of Finite Elements is a Subring of the Extended Reals\<close>
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   173
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   174
lemma HFinite_add: "x \<in> HFinite \<Longrightarrow> y \<in> HFinite \<Longrightarrow> x + y \<in> HFinite"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   175
  unfolding HFinite_def by (blast intro!: Reals_add hnorm_add_less)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   176
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   177
lemma HFinite_mult: "x \<in> HFinite \<Longrightarrow> y \<in> HFinite \<Longrightarrow> x * y \<in> HFinite"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   178
  for x y :: "'a::real_normed_algebra star"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   179
  unfolding HFinite_def by (blast intro!: Reals_mult hnorm_mult_less)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   180
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   181
lemma HFinite_scaleHR: "x \<in> HFinite \<Longrightarrow> y \<in> HFinite \<Longrightarrow> scaleHR x y \<in> HFinite"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   182
  by (auto simp: HFinite_def intro!: Reals_mult hnorm_scaleHR_less)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   183
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   184
lemma HFinite_minus_iff: "- x \<in> HFinite \<longleftrightarrow> x \<in> HFinite"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   185
  by (simp add: HFinite_def)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   186
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   187
lemma HFinite_star_of [simp]: "star_of x \<in> HFinite"
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   188
  by (simp add: HFinite_def) (metis SReal_hypreal_of_real gt_ex star_of_less star_of_norm)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   189
61070
b72a990adfe2 prefer symbols;
wenzelm
parents: 60041
diff changeset
   190
lemma SReal_subset_HFinite: "(\<real>::hypreal set) \<subseteq> HFinite"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   191
  by (auto simp add: SReal_def)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   192
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   193
lemma HFiniteD: "x \<in> HFinite \<Longrightarrow> \<exists>t \<in> Reals. hnorm x < t"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   194
  by (simp add: HFinite_def)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   195
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   196
lemma HFinite_hrabs_iff [iff]: "\<bar>x\<bar> \<in> HFinite \<longleftrightarrow> x \<in> HFinite"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   197
  for x :: hypreal
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   198
  by (simp add: HFinite_def)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   199
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   200
lemma HFinite_hnorm_iff [iff]: "hnorm x \<in> HFinite \<longleftrightarrow> x \<in> HFinite"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   201
  for x :: hypreal
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   202
  by (simp add: HFinite_def)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   203
47108
2a1953f0d20d merged fork with new numeral representation (see NEWS)
huffman
parents: 45541
diff changeset
   204
lemma HFinite_numeral [simp]: "numeral w \<in> HFinite"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   205
  unfolding star_numeral_def by (rule HFinite_star_of)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   206
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   207
text \<open>As always with numerals, \<open>0\<close> and \<open>1\<close> are special cases.\<close>
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
lemma HFinite_0 [simp]: "0 \<in> HFinite"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   210
  unfolding star_zero_def by (rule HFinite_star_of)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   211
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   212
lemma HFinite_1 [simp]: "1 \<in> HFinite"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   213
  unfolding star_one_def by (rule HFinite_star_of)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   214
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   215
lemma hrealpow_HFinite: "x \<in> HFinite \<Longrightarrow> x ^ n \<in> HFinite"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   216
  for x :: "'a::{real_normed_algebra,monoid_mult} star"
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   217
  by (induct n) (auto intro: HFinite_mult)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   218
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   219
lemma HFinite_bounded: 
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   220
  fixes x y :: hypreal
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   221
  assumes "x \<in> HFinite" and y: "y \<le> x" "0 \<le> y" shows "y \<in> HFinite"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   222
proof (cases "x \<le> 0")
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   223
  case True
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   224
  then have "y = 0"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   225
    using y by auto
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   226
  then show ?thesis
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   227
    by simp
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   228
next
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   229
  case False
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   230
  then show ?thesis
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   231
    using assms le_less_trans by (auto simp: HFinite_def)
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   232
qed
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   233
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   234
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   235
subsection \<open>Set of Infinitesimals is a Subring of the Hyperreals\<close>
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   236
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   237
lemma InfinitesimalI: "(\<And>r. r \<in> \<real> \<Longrightarrow> 0 < r \<Longrightarrow> hnorm x < r) \<Longrightarrow> x \<in> Infinitesimal"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   238
  by (simp add: Infinitesimal_def)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   239
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   240
lemma InfinitesimalD: "x \<in> Infinitesimal \<Longrightarrow> \<forall>r \<in> Reals. 0 < r \<longrightarrow> hnorm x < r"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   241
  by (simp add: Infinitesimal_def)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   242
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   243
lemma InfinitesimalI2: "(\<And>r. 0 < r \<Longrightarrow> hnorm x < star_of r) \<Longrightarrow> x \<in> Infinitesimal"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   244
  by (auto simp add: Infinitesimal_def SReal_def)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   245
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   246
lemma InfinitesimalD2: "x \<in> Infinitesimal \<Longrightarrow> 0 < r \<Longrightarrow> hnorm x < star_of r"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   247
  by (auto simp add: Infinitesimal_def SReal_def)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   248
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   249
lemma Infinitesimal_zero [iff]: "0 \<in> Infinitesimal"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   250
  by (simp add: Infinitesimal_def)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   251
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   252
lemma Infinitesimal_add:
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   253
  assumes "x \<in> Infinitesimal" "y \<in> Infinitesimal"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   254
  shows "x + y \<in> Infinitesimal"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   255
proof (rule InfinitesimalI)
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   256
  show "hnorm (x + y) < r"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   257
    if "r \<in> \<real>" and "0 < r" for r :: "real star"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   258
  proof -
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   259
    have "hnorm x < r/2" "hnorm y < r/2"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   260
      using InfinitesimalD SReal_divide_numeral assms half_gt_zero that by blast+
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   261
    then show ?thesis
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   262
      using hnorm_add_less by fastforce
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   263
  qed
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   264
qed
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   265
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   266
lemma Infinitesimal_minus_iff [simp]: "- x \<in> Infinitesimal \<longleftrightarrow> x \<in> Infinitesimal"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   267
  by (simp add: Infinitesimal_def)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   268
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   269
lemma Infinitesimal_hnorm_iff: "hnorm x \<in> Infinitesimal \<longleftrightarrow> x \<in> Infinitesimal"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   270
  by (simp add: Infinitesimal_def)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   271
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   272
lemma Infinitesimal_hrabs_iff [iff]: "\<bar>x\<bar> \<in> Infinitesimal \<longleftrightarrow> x \<in> Infinitesimal"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   273
  for x :: hypreal
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   274
  by (simp add: abs_if)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   275
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   276
lemma Infinitesimal_of_hypreal_iff [simp]:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   277
  "(of_hypreal x::'a::real_normed_algebra_1 star) \<in> Infinitesimal \<longleftrightarrow> x \<in> Infinitesimal"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   278
  by (subst Infinitesimal_hnorm_iff [symmetric]) simp
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   279
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   280
lemma Infinitesimal_diff: "x \<in> Infinitesimal \<Longrightarrow> y \<in> Infinitesimal \<Longrightarrow> x - y \<in> Infinitesimal"
54230
b1d955791529 more simplification rules on unary and binary minus
haftmann
parents: 51521
diff changeset
   281
  using Infinitesimal_add [of x "- y"] by simp
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   282
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   283
lemma Infinitesimal_mult: 
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   284
  fixes x y :: "'a::real_normed_algebra star"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   285
  assumes "x \<in> Infinitesimal" "y \<in> Infinitesimal"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   286
  shows "x * y \<in> Infinitesimal"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   287
  proof (rule InfinitesimalI)
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   288
  show "hnorm (x * y) < r"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   289
    if "r \<in> \<real>" and "0 < r" for r :: "real star"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   290
  proof -
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   291
    have "hnorm x < 1" "hnorm y < r"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   292
      using assms that  by (auto simp add: InfinitesimalD)
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   293
    then show ?thesis
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   294
      using hnorm_mult_less by fastforce
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   295
  qed
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   296
qed
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   297
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   298
lemma Infinitesimal_HFinite_mult:
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   299
  fixes x y :: "'a::real_normed_algebra star"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   300
  assumes "x \<in> Infinitesimal" "y \<in> HFinite"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   301
  shows "x * y \<in> Infinitesimal"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   302
proof (rule InfinitesimalI)
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   303
  obtain t where "hnorm y < t" "t \<in> Reals"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   304
    using HFiniteD \<open>y \<in> HFinite\<close> by blast
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   305
  then have "t > 0"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   306
    using hnorm_ge_zero le_less_trans by blast
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   307
  show "hnorm (x * y) < r"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   308
    if "r \<in> \<real>" and "0 < r" for r :: "real star"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   309
  proof -
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   310
    have "hnorm x < r/t"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   311
      by (meson InfinitesimalD Reals_divide \<open>hnorm y < t\<close> \<open>t \<in> \<real>\<close> assms(1) divide_pos_pos hnorm_ge_zero le_less_trans that) 
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   312
    then have "hnorm (x * y) < (r / t) * t"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   313
      using \<open>hnorm y < t\<close> hnorm_mult_less by blast
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   314
    then show ?thesis
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   315
      using \<open>0 < t\<close> by auto
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   316
  qed
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   317
qed
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   318
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   319
lemma Infinitesimal_HFinite_scaleHR:
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   320
  assumes "x \<in> Infinitesimal" "y \<in> HFinite"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   321
  shows "scaleHR x y \<in> Infinitesimal"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   322
proof (rule InfinitesimalI)
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   323
  obtain t where "hnorm y < t" "t \<in> Reals"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   324
    using HFiniteD \<open>y \<in> HFinite\<close> by blast
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   325
  then have "t > 0"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   326
    using hnorm_ge_zero le_less_trans by blast
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   327
  show "hnorm (scaleHR x y) < r"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   328
    if "r \<in> \<real>" and "0 < r" for r :: "real star"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   329
  proof -
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   330
    have "\<bar>x\<bar> * hnorm y < (r / t) * t"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   331
      by (metis InfinitesimalD Reals_divide \<open>0 < t\<close> \<open>hnorm y < t\<close> \<open>t \<in> \<real>\<close> assms(1) divide_pos_pos hnorm_ge_zero hypreal_hnorm_def mult_strict_mono' that)
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   332
    then show ?thesis
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   333
      by (simp add: \<open>0 < t\<close> hnorm_scaleHR less_imp_not_eq2)
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   334
  qed
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   335
qed
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   336
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   337
lemma Infinitesimal_HFinite_mult2:
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   338
  fixes x y :: "'a::real_normed_algebra star"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   339
  assumes "x \<in> Infinitesimal" "y \<in> HFinite"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   340
  shows  "y * x \<in> Infinitesimal"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   341
proof (rule InfinitesimalI)
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   342
  obtain t where "hnorm y < t" "t \<in> Reals"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   343
    using HFiniteD \<open>y \<in> HFinite\<close> by blast
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   344
  then have "t > 0"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   345
    using hnorm_ge_zero le_less_trans by blast
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   346
  show "hnorm (y * x) < r"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   347
    if "r \<in> \<real>" and "0 < r" for r :: "real star"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   348
  proof -
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   349
    have "hnorm x < r/t"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   350
      by (meson InfinitesimalD Reals_divide \<open>hnorm y < t\<close> \<open>t \<in> \<real>\<close> assms(1) divide_pos_pos hnorm_ge_zero le_less_trans that) 
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   351
    then have "hnorm (y * x) < t * (r / t)"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   352
      using \<open>hnorm y < t\<close> hnorm_mult_less by blast
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   353
    then show ?thesis
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   354
      using \<open>0 < t\<close> by auto
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   355
  qed
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   356
qed
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   357
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   358
lemma Infinitesimal_scaleR2: 
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   359
  assumes "x \<in> Infinitesimal" shows "a *\<^sub>R x \<in> Infinitesimal"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   360
    by (metis HFinite_star_of Infinitesimal_HFinite_mult2 Infinitesimal_hnorm_iff assms hnorm_scaleR hypreal_hnorm_def star_of_norm)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   361
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   362
lemma Compl_HFinite: "- HFinite = HInfinite"
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   363
  proof -
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   364
  have "r < hnorm x" if *: "\<And>s. s \<in> \<real> \<Longrightarrow> s \<le> hnorm x" and "r \<in> \<real>"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   365
    for x :: "'a star" and r :: hypreal
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   366
    using * [of "r+1"] \<open>r \<in> \<real>\<close> by auto
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   367
  then show ?thesis
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   368
    by (auto simp add: HInfinite_def HFinite_def linorder_not_less)
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   369
qed
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   370
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   371
lemma HInfinite_inverse_Infinitesimal:
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   372
  "x \<in> HInfinite \<Longrightarrow> inverse x \<in> Infinitesimal"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   373
  for x :: "'a::real_normed_div_algebra star"
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   374
  by (simp add: HInfinite_def InfinitesimalI hnorm_inverse inverse_less_imp_less)
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   375
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   376
lemma inverse_Infinitesimal_iff_HInfinite:
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   377
  "x \<noteq> 0 \<Longrightarrow> inverse x \<in> Infinitesimal \<longleftrightarrow> x \<in> HInfinite"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   378
  for x :: "'a::real_normed_div_algebra star"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   379
  by (metis Compl_HFinite Compl_iff HInfinite_inverse_Infinitesimal InfinitesimalD Infinitesimal_HFinite_mult Reals_1 hnorm_one left_inverse less_irrefl zero_less_one)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   380
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   381
lemma HInfiniteI: "(\<And>r. r \<in> \<real> \<Longrightarrow> r < hnorm x) \<Longrightarrow> x \<in> HInfinite"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   382
  by (simp add: HInfinite_def)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   383
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   384
lemma HInfiniteD: "x \<in> HInfinite \<Longrightarrow> r \<in> \<real> \<Longrightarrow> r < hnorm x"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   385
  by (simp add: HInfinite_def)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   386
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   387
lemma HInfinite_mult: 
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   388
  fixes x y :: "'a::real_normed_div_algebra star"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   389
  assumes "x \<in> HInfinite" "y \<in> HInfinite" shows "x * y \<in> HInfinite"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   390
proof (rule HInfiniteI, simp only: hnorm_mult)
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   391
  have "x \<noteq> 0"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   392
    using Compl_HFinite HFinite_0 assms by blast
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   393
  show "r < hnorm x * hnorm y"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   394
    if "r \<in> \<real>" for r :: "real star"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   395
  proof -
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   396
    have "r = r * 1"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   397
      by simp
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   398
    also have "\<dots> < hnorm x * hnorm y"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   399
      by (meson HInfiniteD Reals_1 \<open>x \<noteq> 0\<close> assms le_numeral_extra(1) mult_strict_mono that zero_less_hnorm_iff)
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   400
    finally show ?thesis .
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   401
  qed
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   402
qed
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   403
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   404
lemma hypreal_add_zero_less_le_mono: "r < x \<Longrightarrow> 0 \<le> y \<Longrightarrow> r < x + y"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   405
  for r x y :: hypreal
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   406
  by simp
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   407
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   408
lemma HInfinite_add_ge_zero: "x \<in> HInfinite \<Longrightarrow> 0 \<le> y \<Longrightarrow> 0 \<le> x \<Longrightarrow> x + y \<in> HInfinite"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   409
  for x y :: hypreal
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   410
  by (auto simp: abs_if add.commute HInfinite_def)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   411
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   412
lemma HInfinite_add_ge_zero2: "x \<in> HInfinite \<Longrightarrow> 0 \<le> y \<Longrightarrow> 0 \<le> x \<Longrightarrow> y + x \<in> HInfinite"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   413
  for x y :: hypreal
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   414
  by (auto intro!: HInfinite_add_ge_zero simp add: add.commute)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   415
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   416
lemma HInfinite_add_gt_zero: "x \<in> HInfinite \<Longrightarrow> 0 < y \<Longrightarrow> 0 < x \<Longrightarrow> x + y \<in> HInfinite"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   417
  for x y :: hypreal
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   418
  by (blast intro: HInfinite_add_ge_zero order_less_imp_le)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   419
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   420
lemma HInfinite_minus_iff: "- x \<in> HInfinite \<longleftrightarrow> x \<in> HInfinite"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   421
  by (simp add: HInfinite_def)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   422
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   423
lemma HInfinite_add_le_zero: "x \<in> HInfinite \<Longrightarrow> y \<le> 0 \<Longrightarrow> x \<le> 0 \<Longrightarrow> x + y \<in> HInfinite"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   424
  for x y :: hypreal
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   425
  by (metis (no_types, lifting) HInfinite_add_ge_zero2 HInfinite_minus_iff add.inverse_distrib_swap neg_0_le_iff_le)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   426
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   427
lemma HInfinite_add_lt_zero: "x \<in> HInfinite \<Longrightarrow> y < 0 \<Longrightarrow> x < 0 \<Longrightarrow> x + y \<in> HInfinite"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   428
  for x y :: hypreal
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   429
  by (blast intro: HInfinite_add_le_zero order_less_imp_le)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   430
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   431
lemma HFinite_sum_squares:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   432
  "a \<in> HFinite \<Longrightarrow> b \<in> HFinite \<Longrightarrow> c \<in> HFinite \<Longrightarrow> a * a + b * b + c * c \<in> HFinite"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   433
  for a b c :: "'a::real_normed_algebra star"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   434
  by (auto intro: HFinite_mult HFinite_add)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   435
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   436
lemma not_Infinitesimal_not_zero: "x \<notin> Infinitesimal \<Longrightarrow> x \<noteq> 0"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   437
  by auto
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   438
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   439
lemma not_Infinitesimal_not_zero2: "x \<in> HFinite - Infinitesimal \<Longrightarrow> x \<noteq> 0"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   440
  by auto
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   441
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   442
lemma HFinite_diff_Infinitesimal_hrabs:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   443
  "x \<in> HFinite - Infinitesimal \<Longrightarrow> \<bar>x\<bar> \<in> HFinite - Infinitesimal"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   444
  for x :: hypreal
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   445
  by blast
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   446
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   447
lemma hnorm_le_Infinitesimal: "e \<in> Infinitesimal \<Longrightarrow> hnorm x \<le> e \<Longrightarrow> x \<in> Infinitesimal"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   448
  by (auto simp: Infinitesimal_def abs_less_iff)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   449
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   450
lemma hnorm_less_Infinitesimal: "e \<in> Infinitesimal \<Longrightarrow> hnorm x < e \<Longrightarrow> x \<in> Infinitesimal"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   451
  by (erule hnorm_le_Infinitesimal, erule order_less_imp_le)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   452
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   453
lemma hrabs_le_Infinitesimal: "e \<in> Infinitesimal \<Longrightarrow> \<bar>x\<bar> \<le> e \<Longrightarrow> x \<in> Infinitesimal"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   454
  for x :: hypreal
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   455
  by (erule hnorm_le_Infinitesimal) simp
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   456
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   457
lemma hrabs_less_Infinitesimal: "e \<in> Infinitesimal \<Longrightarrow> \<bar>x\<bar> < e \<Longrightarrow> x \<in> Infinitesimal"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   458
  for x :: hypreal
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   459
  by (erule hnorm_less_Infinitesimal) simp
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   460
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   461
lemma Infinitesimal_interval:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   462
  "e \<in> Infinitesimal \<Longrightarrow> e' \<in> Infinitesimal \<Longrightarrow> e' < x \<Longrightarrow> x < e \<Longrightarrow> x \<in> Infinitesimal"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   463
  for x :: hypreal
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   464
  by (auto simp add: Infinitesimal_def abs_less_iff)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   465
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   466
lemma Infinitesimal_interval2:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   467
  "e \<in> Infinitesimal \<Longrightarrow> e' \<in> Infinitesimal \<Longrightarrow> e' \<le> x \<Longrightarrow> x \<le> e \<Longrightarrow> x \<in> Infinitesimal"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   468
  for x :: hypreal
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   469
  by (auto intro: Infinitesimal_interval simp add: order_le_less)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   470
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   471
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   472
lemma lemma_Infinitesimal_hyperpow: "x \<in> Infinitesimal \<Longrightarrow> 0 < N \<Longrightarrow> \<bar>x pow N\<bar> \<le> \<bar>x\<bar>"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   473
  for x :: hypreal
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   474
  apply (clarsimp simp: Infinitesimal_def)
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   475
  by (metis Reals_1 abs_ge_zero hyperpow_Suc_le_self2 hyperpow_hrabs hypnat_gt_zero_iff2 zero_less_one)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   476
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   477
lemma Infinitesimal_hyperpow: "x \<in> Infinitesimal \<Longrightarrow> 0 < N \<Longrightarrow> x pow N \<in> Infinitesimal"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   478
  for x :: hypreal
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   479
  using hrabs_le_Infinitesimal lemma_Infinitesimal_hyperpow by blast
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   480
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   481
lemma hrealpow_hyperpow_Infinitesimal_iff:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   482
  "(x ^ n \<in> Infinitesimal) \<longleftrightarrow> x pow (hypnat_of_nat n) \<in> Infinitesimal"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   483
  by (simp only: hyperpow_hypnat_of_nat)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   484
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   485
lemma Infinitesimal_hrealpow: "x \<in> Infinitesimal \<Longrightarrow> 0 < n \<Longrightarrow> x ^ n \<in> Infinitesimal"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   486
  for x :: hypreal
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   487
  by (simp add: hrealpow_hyperpow_Infinitesimal_iff Infinitesimal_hyperpow)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   488
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   489
lemma not_Infinitesimal_mult:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   490
  "x \<notin> Infinitesimal \<Longrightarrow> y \<notin> Infinitesimal \<Longrightarrow> x * y \<notin> Infinitesimal"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   491
  for x y :: "'a::real_normed_div_algebra star"
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   492
  by (metis (no_types, lifting) inverse_Infinitesimal_iff_HInfinite ComplI Compl_HFinite Infinitesimal_HFinite_mult divide_inverse eq_divide_imp inverse_inverse_eq mult_zero_right)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   493
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   494
lemma Infinitesimal_mult_disj: "x * y \<in> Infinitesimal \<Longrightarrow> x \<in> Infinitesimal \<or> y \<in> Infinitesimal"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   495
  for x y :: "'a::real_normed_div_algebra star"
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   496
  using not_Infinitesimal_mult by blast
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   497
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   498
lemma HFinite_Infinitesimal_not_zero: "x \<in> HFinite-Infinitesimal \<Longrightarrow> x \<noteq> 0"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   499
  by blast
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   500
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   501
lemma HFinite_Infinitesimal_diff_mult:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   502
  "x \<in> HFinite - Infinitesimal \<Longrightarrow> y \<in> HFinite - Infinitesimal \<Longrightarrow> x * y \<in> HFinite - Infinitesimal"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   503
  for x y :: "'a::real_normed_div_algebra star"
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   504
  by (simp add: HFinite_mult not_Infinitesimal_mult)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   505
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   506
lemma Infinitesimal_subset_HFinite: "Infinitesimal \<subseteq> HFinite"
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   507
  using HFinite_def InfinitesimalD Reals_1 zero_less_one by blast
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   508
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   509
lemma Infinitesimal_star_of_mult: "x \<in> Infinitesimal \<Longrightarrow> x * star_of r \<in> Infinitesimal"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   510
  for x :: "'a::real_normed_algebra star"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   511
  by (erule HFinite_star_of [THEN [2] Infinitesimal_HFinite_mult])
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   512
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   513
lemma Infinitesimal_star_of_mult2: "x \<in> Infinitesimal \<Longrightarrow> star_of r * x \<in> Infinitesimal"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   514
  for x :: "'a::real_normed_algebra star"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   515
  by (erule HFinite_star_of [THEN [2] Infinitesimal_HFinite_mult2])
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   516
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   517
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   518
subsection \<open>The Infinitely Close Relation\<close>
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   519
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   520
lemma mem_infmal_iff: "x \<in> Infinitesimal \<longleftrightarrow> x \<approx> 0"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   521
  by (simp add: Infinitesimal_def approx_def)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   522
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   523
lemma approx_minus_iff: "x \<approx> y \<longleftrightarrow> x - y \<approx> 0"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   524
  by (simp add: approx_def)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   525
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   526
lemma approx_minus_iff2: "x \<approx> y \<longleftrightarrow> - y + x \<approx> 0"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   527
  by (simp add: approx_def add.commute)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   528
61982
3af5a06577c7 more symbols;
wenzelm
parents: 61981
diff changeset
   529
lemma approx_refl [iff]: "x \<approx> x"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   530
  by (simp add: approx_def Infinitesimal_def)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   531
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   532
lemma approx_sym: "x \<approx> y \<Longrightarrow> y \<approx> x"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   533
  by (metis Infinitesimal_minus_iff approx_def minus_diff_eq)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   534
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   535
lemma approx_trans:
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   536
  assumes "x \<approx> y" "y \<approx> z" shows "x \<approx> z"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   537
proof -
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   538
  have "x - y \<in> Infinitesimal" "z - y \<in> Infinitesimal"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   539
    using assms approx_def approx_sym by auto
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   540
  then have "x - z \<in> Infinitesimal"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   541
    using Infinitesimal_diff by force
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   542
  then show ?thesis
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   543
    by (simp add: approx_def)
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   544
qed
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   545
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   546
lemma approx_trans2: "r \<approx> x \<Longrightarrow> s \<approx> x \<Longrightarrow> r \<approx> s"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   547
  by (blast intro: approx_sym approx_trans)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   548
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   549
lemma approx_trans3: "x \<approx> r \<Longrightarrow> x \<approx> s \<Longrightarrow> r \<approx> s"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   550
  by (blast intro: approx_sym approx_trans)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   551
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   552
lemma approx_reorient: "x \<approx> y \<longleftrightarrow> y \<approx> x"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   553
  by (blast intro: approx_sym)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   554
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   555
text \<open>Reorientation simplification procedure: reorients (polymorphic)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   556
  \<open>0 = x\<close>, \<open>1 = x\<close>, \<open>nnn = x\<close> provided \<open>x\<close> isn't \<open>0\<close>, \<open>1\<close> or a numeral.\<close>
45541
934866fc776c simplify implementation of approx_reorient_simproc
huffman
parents: 45540
diff changeset
   557
simproc_setup approx_reorient_simproc
61982
3af5a06577c7 more symbols;
wenzelm
parents: 61981
diff changeset
   558
  ("0 \<approx> x" | "1 \<approx> y" | "numeral w \<approx> z" | "- 1 \<approx> y" | "- numeral w \<approx> r") =
61975
b4b11391c676 isabelle update_cartouches -c -t;
wenzelm
parents: 61945
diff changeset
   559
\<open>
45541
934866fc776c simplify implementation of approx_reorient_simproc
huffman
parents: 45540
diff changeset
   560
  let val rule = @{thm approx_reorient} RS eq_reflection
59582
0fbed69ff081 tuned signature -- prefer qualified names;
wenzelm
parents: 58878
diff changeset
   561
      fun proc phi ss ct =
0fbed69ff081 tuned signature -- prefer qualified names;
wenzelm
parents: 58878
diff changeset
   562
        case Thm.term_of ct of
45541
934866fc776c simplify implementation of approx_reorient_simproc
huffman
parents: 45540
diff changeset
   563
          _ $ t $ u => if can HOLogic.dest_number u then NONE
934866fc776c simplify implementation of approx_reorient_simproc
huffman
parents: 45540
diff changeset
   564
            else if can HOLogic.dest_number t then SOME rule else NONE
934866fc776c simplify implementation of approx_reorient_simproc
huffman
parents: 45540
diff changeset
   565
        | _ => NONE
934866fc776c simplify implementation of approx_reorient_simproc
huffman
parents: 45540
diff changeset
   566
  in proc end
61975
b4b11391c676 isabelle update_cartouches -c -t;
wenzelm
parents: 61945
diff changeset
   567
\<close>
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   568
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   569
lemma Infinitesimal_approx_minus: "x - y \<in> Infinitesimal \<longleftrightarrow> x \<approx> y"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   570
  by (simp add: approx_minus_iff [symmetric] mem_infmal_iff)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   571
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   572
lemma approx_monad_iff: "x \<approx> y \<longleftrightarrow> monad x = monad y"
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   573
  apply (simp add: monad_def set_eq_iff)
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   574
  using approx_reorient approx_trans by blast
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   575
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   576
lemma Infinitesimal_approx: "x \<in> Infinitesimal \<Longrightarrow> y \<in> Infinitesimal \<Longrightarrow> x \<approx> y"
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   577
  by (simp add: Infinitesimal_diff approx_def)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   578
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   579
lemma approx_add: "a \<approx> b \<Longrightarrow> c \<approx> d \<Longrightarrow> a + c \<approx> b + d"
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   580
proof (unfold approx_def)
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   581
  assume inf: "a - b \<in> Infinitesimal" "c - d \<in> Infinitesimal"
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   582
  have "a + c - (b + d) = (a - b) + (c - d)" by simp
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   583
  also have "... \<in> Infinitesimal"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   584
    using inf by (rule Infinitesimal_add)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   585
  finally show "a + c - (b + d) \<in> Infinitesimal" .
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   586
qed
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   587
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   588
lemma approx_minus: "a \<approx> b \<Longrightarrow> - a \<approx> - b"
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   589
  by (metis approx_def approx_sym minus_diff_eq minus_diff_minus)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   590
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   591
lemma approx_minus2: "- a \<approx> - b \<Longrightarrow> a \<approx> b"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   592
  by (auto dest: approx_minus)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   593
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   594
lemma approx_minus_cancel [simp]: "- a \<approx> - b \<longleftrightarrow> a \<approx> b"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   595
  by (blast intro: approx_minus approx_minus2)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   596
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   597
lemma approx_add_minus: "a \<approx> b \<Longrightarrow> c \<approx> d \<Longrightarrow> a + - c \<approx> b + - d"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   598
  by (blast intro!: approx_add approx_minus)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   599
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   600
lemma approx_diff: "a \<approx> b \<Longrightarrow> c \<approx> d \<Longrightarrow> a - c \<approx> b - d"
54230
b1d955791529 more simplification rules on unary and binary minus
haftmann
parents: 51521
diff changeset
   601
  using approx_add [of a b "- c" "- d"] by simp
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   602
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   603
lemma approx_mult1: "a \<approx> b \<Longrightarrow> c \<in> HFinite \<Longrightarrow> a * c \<approx> b * c"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   604
  for a b c :: "'a::real_normed_algebra star"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   605
  by (simp add: approx_def Infinitesimal_HFinite_mult left_diff_distrib [symmetric])
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   606
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   607
lemma approx_mult2: "a \<approx> b \<Longrightarrow> c \<in> HFinite \<Longrightarrow> c * a \<approx> c * b"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   608
  for a b c :: "'a::real_normed_algebra star"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   609
  by (simp add: approx_def Infinitesimal_HFinite_mult2 right_diff_distrib [symmetric])
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   610
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   611
lemma approx_mult_subst: "u \<approx> v * x \<Longrightarrow> x \<approx> y \<Longrightarrow> v \<in> HFinite \<Longrightarrow> u \<approx> v * y"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   612
  for u v x y :: "'a::real_normed_algebra star"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   613
  by (blast intro: approx_mult2 approx_trans)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   614
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   615
lemma approx_mult_subst2: "u \<approx> x * v \<Longrightarrow> x \<approx> y \<Longrightarrow> v \<in> HFinite \<Longrightarrow> u \<approx> y * v"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   616
  for u v x y :: "'a::real_normed_algebra star"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   617
  by (blast intro: approx_mult1 approx_trans)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   618
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   619
lemma approx_mult_subst_star_of: "u \<approx> x * star_of v \<Longrightarrow> x \<approx> y \<Longrightarrow> u \<approx> y * star_of v"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   620
  for u x y :: "'a::real_normed_algebra star"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   621
  by (auto intro: approx_mult_subst2)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   622
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   623
lemma approx_eq_imp: "a = b \<Longrightarrow> a \<approx> b"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   624
  by (simp add: approx_def)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   625
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   626
lemma Infinitesimal_minus_approx: "x \<in> Infinitesimal \<Longrightarrow> - x \<approx> x"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   627
  by (blast intro: Infinitesimal_minus_iff [THEN iffD2] mem_infmal_iff [THEN iffD1] approx_trans2)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   628
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   629
lemma bex_Infinitesimal_iff: "(\<exists>y \<in> Infinitesimal. x - z = y) \<longleftrightarrow> x \<approx> z"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   630
  by (simp add: approx_def)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   631
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   632
lemma bex_Infinitesimal_iff2: "(\<exists>y \<in> Infinitesimal. x = z + y) \<longleftrightarrow> x \<approx> z"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   633
  by (force simp add: bex_Infinitesimal_iff [symmetric])
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   634
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   635
lemma Infinitesimal_add_approx: "y \<in> Infinitesimal \<Longrightarrow> x + y = z \<Longrightarrow> x \<approx> z"
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   636
  using approx_sym bex_Infinitesimal_iff2 by blast
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   637
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   638
lemma Infinitesimal_add_approx_self: "y \<in> Infinitesimal \<Longrightarrow> x \<approx> x + y"
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   639
  by (simp add: Infinitesimal_add_approx)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   640
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   641
lemma Infinitesimal_add_approx_self2: "y \<in> Infinitesimal \<Longrightarrow> x \<approx> y + x"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   642
  by (auto dest: Infinitesimal_add_approx_self simp add: add.commute)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   643
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   644
lemma Infinitesimal_add_minus_approx_self: "y \<in> Infinitesimal \<Longrightarrow> x \<approx> x + - y"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   645
  by (blast intro!: Infinitesimal_add_approx_self Infinitesimal_minus_iff [THEN iffD2])
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   646
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   647
lemma Infinitesimal_add_cancel: "y \<in> Infinitesimal \<Longrightarrow> x + y \<approx> z \<Longrightarrow> x \<approx> z"
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   648
  using Infinitesimal_add_approx approx_trans by blast
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   649
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   650
lemma Infinitesimal_add_right_cancel: "y \<in> Infinitesimal \<Longrightarrow> x \<approx> z + y \<Longrightarrow> x \<approx> z"
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   651
  by (metis Infinitesimal_add_approx_self approx_monad_iff)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   652
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   653
lemma approx_add_left_cancel: "d + b \<approx> d + c \<Longrightarrow> b \<approx> c"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   654
  by (metis add_diff_cancel_left bex_Infinitesimal_iff)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   655
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   656
lemma approx_add_right_cancel: "b + d \<approx> c + d \<Longrightarrow> b \<approx> c"
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   657
  by (simp add: approx_def)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   658
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   659
lemma approx_add_mono1: "b \<approx> c \<Longrightarrow> d + b \<approx> d + c"
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   660
  by (simp add: approx_add)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   661
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   662
lemma approx_add_mono2: "b \<approx> c \<Longrightarrow> b + a \<approx> c + a"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   663
  by (simp add: add.commute approx_add_mono1)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   664
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   665
lemma approx_add_left_iff [simp]: "a + b \<approx> a + c \<longleftrightarrow> b \<approx> c"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   666
  by (fast elim: approx_add_left_cancel approx_add_mono1)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   667
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   668
lemma approx_add_right_iff [simp]: "b + a \<approx> c + a \<longleftrightarrow> b \<approx> c"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   669
  by (simp add: add.commute)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   670
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   671
lemma approx_HFinite: "x \<in> HFinite \<Longrightarrow> x \<approx> y \<Longrightarrow> y \<in> HFinite"
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   672
  by (metis HFinite_add Infinitesimal_subset_HFinite approx_sym subsetD bex_Infinitesimal_iff2)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   673
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   674
lemma approx_star_of_HFinite: "x \<approx> star_of D \<Longrightarrow> x \<in> HFinite"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   675
  by (rule approx_sym [THEN [2] approx_HFinite], auto)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   676
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   677
lemma approx_mult_HFinite: "a \<approx> b \<Longrightarrow> c \<approx> d \<Longrightarrow> b \<in> HFinite \<Longrightarrow> d \<in> HFinite \<Longrightarrow> a * c \<approx> b * d"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   678
  for a b c d :: "'a::real_normed_algebra star"
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   679
  by (meson approx_HFinite approx_mult2 approx_mult_subst2 approx_sym)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   680
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   681
lemma scaleHR_left_diff_distrib: "\<And>a b x. scaleHR (a - b) x = scaleHR a x - scaleHR b x"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   682
  by transfer (rule scaleR_left_diff_distrib)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   683
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   684
lemma approx_scaleR1: "a \<approx> star_of b \<Longrightarrow> c \<in> HFinite \<Longrightarrow> scaleHR a c \<approx> b *\<^sub>R c"
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   685
  unfolding approx_def
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   686
  by (metis Infinitesimal_HFinite_scaleHR scaleHR_def scaleHR_left_diff_distrib star_scaleR_def starfun2_star_of)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   687
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   688
lemma approx_scaleR2: "a \<approx> b \<Longrightarrow> c *\<^sub>R a \<approx> c *\<^sub>R b"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   689
  by (simp add: approx_def Infinitesimal_scaleR2 scaleR_right_diff_distrib [symmetric])
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   690
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   691
lemma approx_scaleR_HFinite: "a \<approx> star_of b \<Longrightarrow> c \<approx> d \<Longrightarrow> d \<in> HFinite \<Longrightarrow> scaleHR a c \<approx> b *\<^sub>R d"
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   692
  by (meson approx_HFinite approx_scaleR1 approx_scaleR2 approx_sym approx_trans)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   693
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   694
lemma approx_mult_star_of: "a \<approx> star_of b \<Longrightarrow> c \<approx> star_of d \<Longrightarrow> a * c \<approx> star_of b * star_of d"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   695
  for a c :: "'a::real_normed_algebra star"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   696
  by (blast intro!: approx_mult_HFinite approx_star_of_HFinite HFinite_star_of)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   697
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   698
lemma approx_SReal_mult_cancel_zero:
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   699
  fixes a x :: hypreal
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   700
  assumes "a \<in> \<real>" "a \<noteq> 0" "a * x \<approx> 0" shows "x \<approx> 0"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   701
proof -
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   702
  have "inverse a \<in> HFinite"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   703
    using Reals_inverse SReal_subset_HFinite assms(1) by blast
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   704
  then show ?thesis
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   705
    using assms by (auto dest: approx_mult2 simp add: mult.assoc [symmetric])
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   706
qed
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   707
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   708
lemma approx_mult_SReal1: "a \<in> \<real> \<Longrightarrow> x \<approx> 0 \<Longrightarrow> x * a \<approx> 0"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   709
  for a x :: hypreal
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   710
  by (auto dest: SReal_subset_HFinite [THEN subsetD] approx_mult1)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   711
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   712
lemma approx_mult_SReal2: "a \<in> \<real> \<Longrightarrow> x \<approx> 0 \<Longrightarrow> a * x \<approx> 0"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   713
  for a x :: hypreal
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   714
  by (auto dest: SReal_subset_HFinite [THEN subsetD] approx_mult2)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   715
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   716
lemma approx_mult_SReal_zero_cancel_iff [simp]: "a \<in> \<real> \<Longrightarrow> a \<noteq> 0 \<Longrightarrow> a * x \<approx> 0 \<longleftrightarrow> x \<approx> 0"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   717
  for a x :: hypreal
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   718
  by (blast intro: approx_SReal_mult_cancel_zero approx_mult_SReal2)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   719
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   720
lemma approx_SReal_mult_cancel:
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   721
  fixes a w z :: hypreal
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   722
  assumes "a \<in> \<real>" "a \<noteq> 0" "a * w \<approx> a * z" shows "w \<approx> z"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   723
proof -
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   724
  have "inverse a \<in> HFinite"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   725
    using Reals_inverse SReal_subset_HFinite assms(1) by blast
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   726
  then show ?thesis
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   727
    using assms by (auto dest: approx_mult2 simp add: mult.assoc [symmetric])
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   728
qed
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   729
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   730
lemma approx_SReal_mult_cancel_iff1 [simp]: "a \<in> \<real> \<Longrightarrow> a \<noteq> 0 \<Longrightarrow> a * w \<approx> a * z \<longleftrightarrow> w \<approx> z"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   731
  for a w z :: hypreal
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   732
  by (meson SReal_subset_HFinite approx_SReal_mult_cancel approx_mult2 subsetD)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   733
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   734
lemma approx_le_bound:
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   735
  fixes z :: hypreal
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   736
  assumes "z \<le> f" " f \<approx> g" "g \<le> z" shows "f \<approx> z"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   737
proof -
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   738
  obtain y where "z \<le> g + y" and "y \<in> Infinitesimal" "f = g + y"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   739
    using assms bex_Infinitesimal_iff2 by auto
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   740
  then have "z - g \<in> Infinitesimal"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   741
    using assms(3) hrabs_le_Infinitesimal by auto 
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   742
  then show ?thesis
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   743
    by (metis approx_def approx_trans2 assms(2))
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   744
qed
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   745
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   746
lemma approx_hnorm: "x \<approx> y \<Longrightarrow> hnorm x \<approx> hnorm y"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   747
  for x y :: "'a::real_normed_vector star"
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   748
proof (unfold approx_def)
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   749
  assume "x - y \<in> Infinitesimal"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   750
  then have "hnorm (x - y) \<in> Infinitesimal"
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   751
    by (simp only: Infinitesimal_hnorm_iff)
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   752
  moreover have "(0::real star) \<in> Infinitesimal"
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   753
    by (rule Infinitesimal_zero)
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   754
  moreover have "0 \<le> \<bar>hnorm x - hnorm y\<bar>"
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   755
    by (rule abs_ge_zero)
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   756
  moreover have "\<bar>hnorm x - hnorm y\<bar> \<le> hnorm (x - y)"
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   757
    by (rule hnorm_triangle_ineq3)
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   758
  ultimately have "\<bar>hnorm x - hnorm y\<bar> \<in> Infinitesimal"
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   759
    by (rule Infinitesimal_interval2)
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   760
  then show "hnorm x - hnorm y \<in> Infinitesimal"
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   761
    by (simp only: Infinitesimal_hrabs_iff)
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   762
qed
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   763
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   764
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   765
subsection \<open>Zero is the Only Infinitesimal that is also a Real\<close>
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   766
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   767
lemma Infinitesimal_less_SReal: "x \<in> \<real> \<Longrightarrow> y \<in> Infinitesimal \<Longrightarrow> 0 < x \<Longrightarrow> y < x"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   768
  for x y :: hypreal
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   769
  using InfinitesimalD by fastforce
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   770
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   771
lemma Infinitesimal_less_SReal2: "y \<in> Infinitesimal \<Longrightarrow> \<forall>r \<in> Reals. 0 < r \<longrightarrow> y < r"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   772
  for y :: hypreal
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   773
  by (blast intro: Infinitesimal_less_SReal)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   774
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   775
lemma SReal_not_Infinitesimal: "0 < y \<Longrightarrow> y \<in> \<real> ==> y \<notin> Infinitesimal"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   776
  for y :: hypreal
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   777
  by (auto simp add: Infinitesimal_def abs_if)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   778
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   779
lemma SReal_minus_not_Infinitesimal: "y < 0 \<Longrightarrow> y \<in> \<real> \<Longrightarrow> y \<notin> Infinitesimal"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   780
  for y :: hypreal
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   781
  using Infinitesimal_minus_iff Reals_minus SReal_not_Infinitesimal neg_0_less_iff_less by blast
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   782
61070
b72a990adfe2 prefer symbols;
wenzelm
parents: 60041
diff changeset
   783
lemma SReal_Int_Infinitesimal_zero: "\<real> Int Infinitesimal = {0::hypreal}"
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   784
  proof -
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   785
  have "x = 0" if "x \<in> \<real>" "x \<in> Infinitesimal" for x :: "real star"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   786
    using that SReal_minus_not_Infinitesimal SReal_not_Infinitesimal not_less_iff_gr_or_eq by blast
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   787
  then show ?thesis
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   788
    by auto
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   789
qed
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   790
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   791
lemma SReal_Infinitesimal_zero: "x \<in> \<real> \<Longrightarrow> x \<in> Infinitesimal \<Longrightarrow> x = 0"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   792
  for x :: hypreal
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   793
  using SReal_Int_Infinitesimal_zero by blast
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   794
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   795
lemma SReal_HFinite_diff_Infinitesimal: "x \<in> \<real> \<Longrightarrow> x \<noteq> 0 \<Longrightarrow> x \<in> HFinite - Infinitesimal"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   796
  for x :: hypreal
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   797
  by (auto dest: SReal_Infinitesimal_zero SReal_subset_HFinite [THEN subsetD])
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   798
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   799
lemma hypreal_of_real_HFinite_diff_Infinitesimal:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   800
  "hypreal_of_real x \<noteq> 0 \<Longrightarrow> hypreal_of_real x \<in> HFinite - Infinitesimal"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   801
  by (rule SReal_HFinite_diff_Infinitesimal) auto
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   802
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   803
lemma star_of_Infinitesimal_iff_0 [iff]: "star_of x \<in> Infinitesimal \<longleftrightarrow> x = 0"
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   804
proof
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   805
  show "x = 0" if "star_of x \<in> Infinitesimal"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   806
  proof -
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   807
    have "hnorm (star_n (\<lambda>n. x)) \<in> Standard"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   808
      by (metis Reals_eq_Standard SReal_iff star_of_def star_of_norm)
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   809
    then show ?thesis
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   810
      by (metis InfinitesimalD2 less_irrefl star_of_norm that zero_less_norm_iff)
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   811
  qed
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   812
qed auto
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   813
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   814
lemma star_of_HFinite_diff_Infinitesimal: "x \<noteq> 0 \<Longrightarrow> star_of x \<in> HFinite - Infinitesimal"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   815
  by simp
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   816
47108
2a1953f0d20d merged fork with new numeral representation (see NEWS)
huffman
parents: 45541
diff changeset
   817
lemma numeral_not_Infinitesimal [simp]:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   818
  "numeral w \<noteq> (0::hypreal) \<Longrightarrow> (numeral w :: hypreal) \<notin> Infinitesimal"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   819
  by (fast dest: Reals_numeral [THEN SReal_Infinitesimal_zero])
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   820
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   821
text \<open>Again: \<open>1\<close> is a special case, but not \<open>0\<close> this time.\<close>
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   822
lemma one_not_Infinitesimal [simp]:
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   823
  "(1::'a::{real_normed_vector,zero_neq_one} star) \<notin> Infinitesimal"
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   824
  by (metis star_of_Infinitesimal_iff_0 star_one_def zero_neq_one)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   825
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   826
lemma approx_SReal_not_zero: "y \<in> \<real> \<Longrightarrow> x \<approx> y \<Longrightarrow> y \<noteq> 0 \<Longrightarrow> x \<noteq> 0"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   827
  for x y :: hypreal
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   828
  using SReal_Infinitesimal_zero approx_sym mem_infmal_iff by auto
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   829
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   830
lemma HFinite_diff_Infinitesimal_approx:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   831
  "x \<approx> y \<Longrightarrow> y \<in> HFinite - Infinitesimal \<Longrightarrow> x \<in> HFinite - Infinitesimal"
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   832
  by (meson Diff_iff approx_HFinite approx_sym approx_trans3 mem_infmal_iff)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   833
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   834
text \<open>The premise \<open>y \<noteq> 0\<close> is essential; otherwise \<open>x / y = 0\<close> and we lose the
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   835
  \<open>HFinite\<close> premise.\<close>
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   836
lemma Infinitesimal_ratio:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   837
  "y \<noteq> 0 \<Longrightarrow> y \<in> Infinitesimal \<Longrightarrow> x / y \<in> HFinite \<Longrightarrow> x \<in> Infinitesimal"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   838
  for x y :: "'a::{real_normed_div_algebra,field} star"
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   839
  using Infinitesimal_HFinite_mult by fastforce
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   840
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   841
lemma Infinitesimal_SReal_divide: "x \<in> Infinitesimal \<Longrightarrow> y \<in> \<real> \<Longrightarrow> x / y \<in> Infinitesimal"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   842
  for x y :: hypreal
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   843
  by (metis HFinite_star_of Infinitesimal_HFinite_mult Reals_inverse SReal_iff divide_inverse)
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   844
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   845
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   846
section \<open>Standard Part Theorem\<close>
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   847
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   848
text \<open>
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   849
  Every finite \<open>x \<in> R*\<close> is infinitely close to a unique real number
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   850
  (i.e. a member of \<open>Reals\<close>).
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   851
\<close>
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   852
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   853
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   854
subsection \<open>Uniqueness: Two Infinitely Close Reals are Equal\<close>
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   855
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   856
lemma star_of_approx_iff [simp]: "star_of x \<approx> star_of y \<longleftrightarrow> x = y"
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   857
  by (metis approx_def right_minus_eq star_of_Infinitesimal_iff_0 star_of_simps(2))
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   858
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   859
lemma SReal_approx_iff: "x \<in> \<real> \<Longrightarrow> y \<in> \<real> \<Longrightarrow> x \<approx> y \<longleftrightarrow> x = y"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   860
  for x y :: hypreal
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   861
  by (meson Reals_diff SReal_Infinitesimal_zero approx_def approx_refl right_minus_eq)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   862
47108
2a1953f0d20d merged fork with new numeral representation (see NEWS)
huffman
parents: 45541
diff changeset
   863
lemma numeral_approx_iff [simp]:
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   864
  "(numeral v \<approx> (numeral w :: 'a::{numeral,real_normed_vector} star)) = (numeral v = (numeral w :: 'a))"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   865
  by (metis star_of_approx_iff star_of_numeral)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   866
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   867
text \<open>And also for \<open>0 \<approx> #nn\<close> and \<open>1 \<approx> #nn\<close>, \<open>#nn \<approx> 0\<close> and \<open>#nn \<approx> 1\<close>.\<close>
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   868
lemma [simp]:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   869
  "(numeral w \<approx> (0::'a::{numeral,real_normed_vector} star)) = (numeral w = (0::'a))"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   870
  "((0::'a::{numeral,real_normed_vector} star) \<approx> numeral w) = (numeral w = (0::'a))"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   871
  "(numeral w \<approx> (1::'b::{numeral,one,real_normed_vector} star)) = (numeral w = (1::'b))"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   872
  "((1::'b::{numeral,one,real_normed_vector} star) \<approx> numeral w) = (numeral w = (1::'b))"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   873
  "\<not> (0 \<approx> (1::'c::{zero_neq_one,real_normed_vector} star))"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   874
  "\<not> (1 \<approx> (0::'c::{zero_neq_one,real_normed_vector} star))"
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   875
  unfolding star_numeral_def star_zero_def star_one_def star_of_approx_iff
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   876
  by (auto intro: sym)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   877
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   878
lemma star_of_approx_numeral_iff [simp]: "star_of k \<approx> numeral w \<longleftrightarrow> k = numeral w"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   879
  by (subst star_of_approx_iff [symmetric]) auto
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   880
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   881
lemma star_of_approx_zero_iff [simp]: "star_of k \<approx> 0 \<longleftrightarrow> k = 0"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   882
  by (simp_all add: star_of_approx_iff [symmetric])
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   883
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   884
lemma star_of_approx_one_iff [simp]: "star_of k \<approx> 1 \<longleftrightarrow> k = 1"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   885
  by (simp_all add: star_of_approx_iff [symmetric])
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   886
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   887
lemma approx_unique_real: "r \<in> \<real> \<Longrightarrow> s \<in> \<real> \<Longrightarrow> r \<approx> x \<Longrightarrow> s \<approx> x \<Longrightarrow> r = s"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   888
  for r s :: hypreal
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   889
  by (blast intro: SReal_approx_iff [THEN iffD1] approx_trans2)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   890
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   891
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   892
subsection \<open>Existence of Unique Real Infinitely Close\<close>
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   893
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   894
subsubsection \<open>Lifting of the Ub and Lub Properties\<close>
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   895
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   896
lemma hypreal_of_real_isUb_iff: "isUb \<real> (hypreal_of_real ` Q) (hypreal_of_real Y) = isUb UNIV Q Y"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   897
  for Q :: "real set" and Y :: real
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   898
  by (simp add: isUb_def setle_def)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   899
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   900
lemma hypreal_of_real_isLub_iff:
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   901
  "isLub \<real> (hypreal_of_real ` Q) (hypreal_of_real Y) = isLub (UNIV :: real set) Q Y" (is "?lhs = ?rhs")
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   902
  for Q :: "real set" and Y :: real
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   903
proof 
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   904
  assume ?lhs
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   905
  then show ?rhs
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   906
    by (simp add: isLub_def leastP_def) (metis hypreal_of_real_isUb_iff mem_Collect_eq setge_def star_of_le)
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   907
next
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   908
  assume ?rhs
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   909
  then show ?lhs
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   910
  apply (simp add: isLub_def leastP_def hypreal_of_real_isUb_iff setge_def)
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   911
    by (metis SReal_iff hypreal_of_real_isUb_iff isUb_def star_of_le)
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   912
qed
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   913
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   914
lemma lemma_isUb_hypreal_of_real: "isUb \<real> P Y \<Longrightarrow> \<exists>Yo. isUb \<real> P (hypreal_of_real Yo)"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   915
  by (auto simp add: SReal_iff isUb_def)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   916
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   917
lemma lemma_isLub_hypreal_of_real: "isLub \<real> P Y \<Longrightarrow> \<exists>Yo. isLub \<real> P (hypreal_of_real Yo)"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   918
  by (auto simp add: isLub_def leastP_def isUb_def SReal_iff)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   919
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   920
lemma SReal_complete:
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   921
  fixes P :: "hypreal set"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   922
  assumes "isUb \<real> P Y" "P \<subseteq> \<real>" "P \<noteq> {}"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   923
    shows "\<exists>t. isLub \<real> P t"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   924
proof -
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   925
  obtain Q where "P = hypreal_of_real ` Q"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   926
    by (metis \<open>P \<subseteq> \<real>\<close> hypreal_of_real_image subset_imageE)
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   927
  then show ?thesis
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   928
    by (metis assms(1) \<open>P \<noteq> {}\<close> equals0I hypreal_of_real_isLub_iff hypreal_of_real_isUb_iff image_empty lemma_isUb_hypreal_of_real reals_complete)
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   929
qed
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   930
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   931
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   932
text \<open>Lemmas about lubs.\<close>
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   933
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   934
lemma lemma_st_part_lub:
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   935
  fixes x :: hypreal
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   936
  assumes "x \<in> HFinite"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   937
  shows "\<exists>t. isLub \<real> {s. s \<in> \<real> \<and> s < x} t"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   938
proof -
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   939
  obtain t where t: "t \<in> \<real>" "hnorm x < t"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   940
    using HFiniteD assms by blast
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   941
  then have "isUb \<real> {s. s \<in> \<real> \<and> s < x} t"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   942
    by (simp add: abs_less_iff isUbI le_less_linear less_imp_not_less setleI)
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   943
  moreover have "\<exists>y. y \<in> \<real> \<and> y < x"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   944
    using t by (rule_tac x = "-t" in exI) (auto simp add: abs_less_iff)
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   945
  ultimately show ?thesis
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   946
    using SReal_complete by fastforce
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   947
qed
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   948
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   949
lemma lemma_st_part_le1:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   950
  "x \<in> HFinite \<Longrightarrow> isLub \<real> {s. s \<in> \<real> \<and> s < x} t \<Longrightarrow> r \<in> \<real> \<Longrightarrow> 0 < r \<Longrightarrow> x \<le> t + r"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   951
  for x r t :: hypreal
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   952
  by (metis (no_types, lifting) Reals_add add.commute isLubD1a isLubD2 less_add_same_cancel2 mem_Collect_eq not_le)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   953
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   954
lemma hypreal_setle_less_trans: "S *<= x \<Longrightarrow> x < y \<Longrightarrow> S *<= y"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   955
  for x y :: hypreal
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   956
  by (meson le_less_trans less_imp_le setle_def)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   957
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   958
lemma hypreal_gt_isUb: "isUb R S x \<Longrightarrow> x < y \<Longrightarrow> y \<in> R \<Longrightarrow> isUb R S y"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   959
  for x y :: hypreal
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   960
  using hypreal_setle_less_trans isUb_def by blast
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   961
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   962
lemma lemma_st_part_gt_ub: "x \<in> HFinite \<Longrightarrow> x < y \<Longrightarrow> y \<in> \<real> \<Longrightarrow> isUb \<real> {s. s \<in> \<real> \<and> s < x} y"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   963
  for x y :: hypreal
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   964
  by (auto dest: order_less_trans intro: order_less_imp_le intro!: isUbI setleI)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   965
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   966
lemma lemma_minus_le_zero: "t \<le> t + -r \<Longrightarrow> r \<le> 0"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   967
  for r t :: hypreal
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   968
  by simp
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   969
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   970
lemma lemma_st_part_le2:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   971
  "x \<in> HFinite \<Longrightarrow> isLub \<real> {s. s \<in> \<real> \<and> s < x} t \<Longrightarrow> r \<in> \<real> \<Longrightarrow> 0 < r \<Longrightarrow> t + -r \<le> x"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   972
  for x r t :: hypreal
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   973
  apply (frule isLubD1a)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   974
  apply (rule ccontr, drule linorder_not_le [THEN iffD1])
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   975
  apply (drule Reals_minus, drule_tac a = t in Reals_add, assumption)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   976
  apply (drule lemma_st_part_gt_ub, assumption+)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   977
  apply (drule isLub_le_isUb, assumption)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   978
  apply (drule lemma_minus_le_zero)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   979
  apply (auto dest: order_less_le_trans)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   980
  done
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   981
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   982
lemma lemma_st_part1a:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   983
  "x \<in> HFinite \<Longrightarrow> isLub \<real> {s. s \<in> \<real> \<and> s < x} t \<Longrightarrow> r \<in> \<real> \<Longrightarrow> 0 < r \<Longrightarrow> x + -t \<le> r"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   984
  for x r t :: hypreal
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
   985
  using lemma_st_part_le1 by fastforce
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   986
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   987
lemma lemma_st_part2a:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   988
  "x \<in> HFinite \<Longrightarrow> isLub \<real> {s. s \<in> \<real> \<and> s < x} t \<Longrightarrow> r \<in> \<real> \<Longrightarrow> 0 < r \<Longrightarrow> - (x + -t) \<le> r"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   989
  for x r t :: hypreal
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   990
  apply (subgoal_tac "(t + -r \<le> x)")
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   991
   apply simp
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   992
  apply (rule lemma_st_part_le2)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   993
     apply auto
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   994
  done
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   995
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   996
lemma lemma_SReal_ub: "x \<in> \<real> \<Longrightarrow> isUb \<real> {s. s \<in> \<real> \<and> s < x} x"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   997
  for x :: hypreal
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
   998
  by (auto intro: isUbI setleI order_less_imp_le)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
   999
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1000
lemma lemma_SReal_lub: "x \<in> \<real> \<Longrightarrow> isLub \<real> {s. s \<in> \<real> \<and> s < x} x"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1001
  for x :: hypreal
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1002
  apply (auto intro!: isLubI2 lemma_SReal_ub setgeI)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1003
  apply (frule isUbD2a)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1004
  apply (rule_tac x = x and y = y in linorder_cases)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1005
    apply (auto intro!: order_less_imp_le)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1006
  apply (drule SReal_dense, assumption, assumption, safe)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1007
  apply (drule_tac y = r in isUbD)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1008
   apply (auto dest: order_less_le_trans)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1009
  done
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1010
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1011
lemma lemma_st_part_not_eq1:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1012
  "x \<in> HFinite \<Longrightarrow> isLub \<real> {s. s \<in> \<real> \<and> s < x} t \<Longrightarrow> r \<in> \<real> \<Longrightarrow> 0 < r \<Longrightarrow> x + - t \<noteq> r"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1013
  for x r t :: hypreal
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1014
  apply auto
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1015
  apply (frule isLubD1a [THEN Reals_minus])
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1016
  using Reals_add_cancel [of x "- t"] apply simp
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1017
  apply (drule_tac x = x in lemma_SReal_lub)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1018
  apply (drule isLub_unique, assumption, auto)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1019
  done
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1020
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1021
lemma lemma_st_part_not_eq2:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1022
  "x \<in> HFinite \<Longrightarrow> isLub \<real> {s. s \<in> \<real> \<and> s < x} t \<Longrightarrow> r \<in> \<real> \<Longrightarrow> 0 < r \<Longrightarrow> - (x + -t) \<noteq> r"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1023
  for x r t :: hypreal
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1024
  apply (auto)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1025
  apply (frule isLubD1a)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1026
  using Reals_add_cancel [of "- x" t] apply simp
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1027
  apply (drule_tac x = x in lemma_SReal_lub)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1028
  apply (drule isLub_unique, assumption, auto)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1029
  done
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1030
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1031
lemma lemma_st_part_major:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1032
  "x \<in> HFinite \<Longrightarrow> isLub \<real> {s. s \<in> \<real> \<and> s < x} t \<Longrightarrow> r \<in> \<real> \<Longrightarrow> 0 < r \<Longrightarrow> \<bar>x - t\<bar> < r"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1033
  for x r t :: hypreal
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1034
  apply (frule lemma_st_part1a)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1035
     apply (frule_tac [4] lemma_st_part2a, auto)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1036
  apply (drule order_le_imp_less_or_eq)+
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1037
  apply auto
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1038
  using lemma_st_part_not_eq2 apply fastforce
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1039
  using lemma_st_part_not_eq1 apply fastforce
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1040
  done
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1041
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1042
lemma lemma_st_part_major2:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1043
  "x \<in> HFinite \<Longrightarrow> isLub \<real> {s. s \<in> \<real> \<and> s < x} t \<Longrightarrow> \<forall>r \<in> Reals. 0 < r \<longrightarrow> \<bar>x - t\<bar> < r"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1044
  for x t :: hypreal
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1045
  by (blast dest!: lemma_st_part_major)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1046
61649
268d88ec9087 Tweaks for "real": Removal of [iff] status for some lemmas, adding [simp] for others. Plus fixes.
paulson <lp15@cam.ac.uk>
parents: 61609
diff changeset
  1047
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1048
text\<open>Existence of real and Standard Part Theorem.\<close>
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1049
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1050
lemma lemma_st_part_Ex: "x \<in> HFinite \<Longrightarrow> \<exists>t\<in>Reals. \<forall>r \<in> Reals. 0 < r \<longrightarrow> \<bar>x - t\<bar> < r"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1051
  for x :: hypreal
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
  1052
  by (meson isLubD1a lemma_st_part_lub lemma_st_part_major2)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1053
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1054
lemma st_part_Ex: "x \<in> HFinite \<Longrightarrow> \<exists>t\<in>Reals. x \<approx> t"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1055
  for x :: hypreal
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
  1056
  by (metis InfinitesimalI approx_def hypreal_hnorm_def lemma_st_part_Ex)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1057
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1058
text \<open>There is a unique real infinitely close.\<close>
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1059
lemma st_part_Ex1: "x \<in> HFinite \<Longrightarrow> \<exists>!t::hypreal. t \<in> \<real> \<and> x \<approx> t"
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
  1060
  by (meson SReal_approx_iff approx_trans2 st_part_Ex)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1061
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1062
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1063
subsection \<open>Finite, Infinite and Infinitesimal\<close>
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1064
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1065
lemma HFinite_Int_HInfinite_empty [simp]: "HFinite Int HInfinite = {}"
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
  1066
  using Compl_HFinite by blast
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1067
56217
dc429a5b13c4 Some rationalisation of basic lemmas
paulson <lp15@cam.ac.uk>
parents: 54489
diff changeset
  1068
lemma HFinite_not_HInfinite:
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
  1069
  assumes x: "x \<in> HFinite" shows "x \<notin> HInfinite"
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
  1070
  using Compl_HFinite x by blast
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1071
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1072
lemma not_HFinite_HInfinite: "x \<notin> HFinite \<Longrightarrow> x \<in> HInfinite"
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
  1073
  using Compl_HFinite by blast
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1074
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1075
lemma HInfinite_HFinite_disj: "x \<in> HInfinite \<or> x \<in> HFinite"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1076
  by (blast intro: not_HFinite_HInfinite)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1077
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1078
lemma HInfinite_HFinite_iff: "x \<in> HInfinite \<longleftrightarrow> x \<notin> HFinite"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1079
  by (blast dest: HFinite_not_HInfinite not_HFinite_HInfinite)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1080
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1081
lemma HFinite_HInfinite_iff: "x \<in> HFinite \<longleftrightarrow> x \<notin> HInfinite"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1082
  by (simp add: HInfinite_HFinite_iff)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1083
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1084
lemma HInfinite_diff_HFinite_Infinitesimal_disj:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1085
  "x \<notin> Infinitesimal \<Longrightarrow> x \<in> HInfinite \<or> x \<in> HFinite - Infinitesimal"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1086
  by (fast intro: not_HFinite_HInfinite)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1087
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1088
lemma HFinite_inverse: "x \<in> HFinite \<Longrightarrow> x \<notin> Infinitesimal \<Longrightarrow> inverse x \<in> HFinite"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1089
  for x :: "'a::real_normed_div_algebra star"
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
  1090
  using HInfinite_inverse_Infinitesimal not_HFinite_HInfinite by force
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1091
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1092
lemma HFinite_inverse2: "x \<in> HFinite - Infinitesimal \<Longrightarrow> inverse x \<in> HFinite"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1093
  for x :: "'a::real_normed_div_algebra star"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1094
  by (blast intro: HFinite_inverse)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1095
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1096
text \<open>Stronger statement possible in fact.\<close>
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1097
lemma Infinitesimal_inverse_HFinite: "x \<notin> Infinitesimal \<Longrightarrow> inverse x \<in> HFinite"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1098
  for x :: "'a::real_normed_div_algebra star"
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
  1099
  using HFinite_HInfinite_iff HInfinite_inverse_Infinitesimal by fastforce
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1100
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1101
lemma HFinite_not_Infinitesimal_inverse:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1102
  "x \<in> HFinite - Infinitesimal \<Longrightarrow> inverse x \<in> HFinite - Infinitesimal"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1103
  for x :: "'a::real_normed_div_algebra star"
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
  1104
  using HFinite_Infinitesimal_not_zero HFinite_inverse2 Infinitesimal_HFinite_mult2 by fastforce
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1105
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1106
lemma approx_inverse: "x \<approx> y \<Longrightarrow> y \<in> HFinite - Infinitesimal \<Longrightarrow> inverse x \<approx> inverse y"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1107
  for x y :: "'a::real_normed_div_algebra star"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1108
  apply (frule HFinite_diff_Infinitesimal_approx, assumption)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1109
  apply (frule not_Infinitesimal_not_zero2)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1110
  apply (frule_tac x = x in not_Infinitesimal_not_zero2)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1111
  apply (drule HFinite_inverse2)+
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1112
  apply (drule approx_mult2, assumption, auto)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1113
  apply (drule_tac c = "inverse x" in approx_mult1, assumption)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1114
  apply (auto intro: approx_sym simp add: mult.assoc)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1115
  done
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1116
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1117
(*Used for NSLIM_inverse, NSLIMSEQ_inverse*)
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1118
lemmas star_of_approx_inverse = star_of_HFinite_diff_Infinitesimal [THEN [2] approx_inverse]
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1119
lemmas hypreal_of_real_approx_inverse =  hypreal_of_real_HFinite_diff_Infinitesimal [THEN [2] approx_inverse]
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1120
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1121
lemma inverse_add_Infinitesimal_approx:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1122
  "x \<in> HFinite - Infinitesimal \<Longrightarrow> h \<in> Infinitesimal \<Longrightarrow> inverse (x + h) \<approx> inverse x"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1123
  for x h :: "'a::real_normed_div_algebra star"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1124
  by (auto intro: approx_inverse approx_sym Infinitesimal_add_approx_self)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1125
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1126
lemma inverse_add_Infinitesimal_approx2:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1127
  "x \<in> HFinite - Infinitesimal \<Longrightarrow> h \<in> Infinitesimal \<Longrightarrow> inverse (h + x) \<approx> inverse x"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1128
  for x h :: "'a::real_normed_div_algebra star"
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
  1129
  by (metis add.commute inverse_add_Infinitesimal_approx)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1130
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1131
lemma inverse_add_Infinitesimal_approx_Infinitesimal:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1132
  "x \<in> HFinite - Infinitesimal \<Longrightarrow> h \<in> Infinitesimal \<Longrightarrow> inverse (x + h) - inverse x \<approx> h"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1133
  for x h :: "'a::real_normed_div_algebra star"
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
  1134
  by (meson Infinitesimal_approx bex_Infinitesimal_iff inverse_add_Infinitesimal_approx)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1135
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1136
lemma Infinitesimal_square_iff: "x \<in> Infinitesimal \<longleftrightarrow> x * x \<in> Infinitesimal"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1137
  for x :: "'a::real_normed_div_algebra star"
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
  1138
  using Infinitesimal_mult Infinitesimal_mult_disj by auto
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1139
declare Infinitesimal_square_iff [symmetric, simp]
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1140
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1141
lemma HFinite_square_iff [simp]: "x * x \<in> HFinite \<longleftrightarrow> x \<in> HFinite"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1142
  for x :: "'a::real_normed_div_algebra star"
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
  1143
  using HFinite_HInfinite_iff HFinite_mult HInfinite_mult by blast
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1144
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1145
lemma HInfinite_square_iff [simp]: "x * x \<in> HInfinite \<longleftrightarrow> x \<in> HInfinite"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1146
  for x :: "'a::real_normed_div_algebra star"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1147
  by (auto simp add: HInfinite_HFinite_iff)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1148
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1149
lemma approx_HFinite_mult_cancel: "a \<in> HFinite - Infinitesimal \<Longrightarrow> a * w \<approx> a * z \<Longrightarrow> w \<approx> z"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1150
  for a w z :: "'a::real_normed_div_algebra star"
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
  1151
  by (metis DiffD2 Infinitesimal_mult_disj bex_Infinitesimal_iff right_diff_distrib)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1152
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1153
lemma approx_HFinite_mult_cancel_iff1: "a \<in> HFinite - Infinitesimal \<Longrightarrow> a * w \<approx> a * z \<longleftrightarrow> w \<approx> z"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1154
  for a w z :: "'a::real_normed_div_algebra star"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1155
  by (auto intro: approx_mult2 approx_HFinite_mult_cancel)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1156
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1157
lemma HInfinite_HFinite_add_cancel: "x + y \<in> HInfinite \<Longrightarrow> y \<in> HFinite \<Longrightarrow> x \<in> HInfinite"
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
  1158
  using HFinite_add HInfinite_HFinite_iff by blast
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1159
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1160
lemma HInfinite_HFinite_add: "x \<in> HInfinite \<Longrightarrow> y \<in> HFinite \<Longrightarrow> x + y \<in> HInfinite"
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
  1161
  by (metis (no_types, hide_lams) HFinite_HInfinite_iff HFinite_add HFinite_minus_iff add.commute add_minus_cancel)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1162
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1163
lemma HInfinite_ge_HInfinite: "x \<in> HInfinite \<Longrightarrow> x \<le> y \<Longrightarrow> 0 \<le> x \<Longrightarrow> y \<in> HInfinite"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1164
  for x y :: hypreal
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1165
  by (auto intro: HFinite_bounded simp add: HInfinite_HFinite_iff)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1166
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1167
lemma Infinitesimal_inverse_HInfinite: "x \<in> Infinitesimal \<Longrightarrow> x \<noteq> 0 \<Longrightarrow> inverse x \<in> HInfinite"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1168
  for x :: "'a::real_normed_div_algebra star"
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
  1169
  by (metis Infinitesimal_HFinite_mult not_HFinite_HInfinite one_not_Infinitesimal right_inverse)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1170
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1171
lemma HInfinite_HFinite_not_Infinitesimal_mult:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1172
  "x \<in> HInfinite \<Longrightarrow> y \<in> HFinite - Infinitesimal \<Longrightarrow> x * y \<in> HInfinite"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1173
  for x y :: "'a::real_normed_div_algebra star"
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
  1174
  by (metis (no_types, hide_lams) HFinite_HInfinite_iff HFinite_Infinitesimal_not_zero HFinite_inverse2 HFinite_mult mult.assoc mult.right_neutral right_inverse)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1175
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1176
lemma HInfinite_HFinite_not_Infinitesimal_mult2:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1177
  "x \<in> HInfinite \<Longrightarrow> y \<in> HFinite - Infinitesimal \<Longrightarrow> y * x \<in> HInfinite"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1178
  for x y :: "'a::real_normed_div_algebra star"
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
  1179
  by (metis Diff_iff HInfinite_HFinite_iff HInfinite_inverse_Infinitesimal Infinitesimal_HFinite_mult2 divide_inverse mult_zero_right nonzero_eq_divide_eq)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1180
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1181
lemma HInfinite_gt_SReal: "x \<in> HInfinite \<Longrightarrow> 0 < x \<Longrightarrow> y \<in> \<real> \<Longrightarrow> y < x"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1182
  for x y :: hypreal
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1183
  by (auto dest!: bspec simp add: HInfinite_def abs_if order_less_imp_le)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1184
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1185
lemma HInfinite_gt_zero_gt_one: "x \<in> HInfinite \<Longrightarrow> 0 < x \<Longrightarrow> 1 < x"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1186
  for x :: hypreal
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1187
  by (auto intro: HInfinite_gt_SReal)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1188
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1189
lemma not_HInfinite_one [simp]: "1 \<notin> HInfinite"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1190
  by (simp add: HInfinite_HFinite_iff)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1191
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1192
lemma approx_hrabs_disj: "\<bar>x\<bar> \<approx> x \<or> \<bar>x\<bar> \<approx> -x"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1193
  for x :: hypreal
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1194
  using hrabs_disj [of x] by auto
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1195
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1196
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1197
subsection \<open>Theorems about Monads\<close>
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1198
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1199
lemma monad_hrabs_Un_subset: "monad \<bar>x\<bar> \<le> monad x \<union> monad (- x)"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1200
  for x :: hypreal
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1201
  by (rule hrabs_disj [of x, THEN disjE]) auto
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1202
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1203
lemma Infinitesimal_monad_eq: "e \<in> Infinitesimal \<Longrightarrow> monad (x + e) = monad x"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1204
  by (fast intro!: Infinitesimal_add_approx_self [THEN approx_sym] approx_monad_iff [THEN iffD1])
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1205
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1206
lemma mem_monad_iff: "u \<in> monad x \<longleftrightarrow> - u \<in> monad (- x)"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1207
  by (simp add: monad_def)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1208
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1209
lemma Infinitesimal_monad_zero_iff: "x \<in> Infinitesimal \<longleftrightarrow> x \<in> monad 0"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1210
  by (auto intro: approx_sym simp add: monad_def mem_infmal_iff)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1211
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1212
lemma monad_zero_minus_iff: "x \<in> monad 0 \<longleftrightarrow> - x \<in> monad 0"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1213
  by (simp add: Infinitesimal_monad_zero_iff [symmetric])
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1214
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1215
lemma monad_zero_hrabs_iff: "x \<in> monad 0 \<longleftrightarrow> \<bar>x\<bar> \<in> monad 0"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1216
  for x :: hypreal
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1217
  by (rule hrabs_disj [of x, THEN disjE]) (auto simp: monad_zero_minus_iff [symmetric])
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1218
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1219
lemma mem_monad_self [simp]: "x \<in> monad x"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1220
  by (simp add: monad_def)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1221
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1222
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 68527
diff changeset
  1223
subsection \<open>Proof that \<^term>\<open>x \<approx> y\<close> implies \<^term>\<open>\<bar>x\<bar> \<approx> \<bar>y\<bar>\<close>\<close>
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1224
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1225
lemma approx_subset_monad: "x \<approx> y \<Longrightarrow> {x, y} \<le> monad x"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1226
  by (simp (no_asm)) (simp add: approx_monad_iff)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1227
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1228
lemma approx_subset_monad2: "x \<approx> y \<Longrightarrow> {x, y} \<le> monad y"
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
  1229
  using approx_subset_monad approx_sym by auto
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1230
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1231
lemma mem_monad_approx: "u \<in> monad x \<Longrightarrow> x \<approx> u"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1232
  by (simp add: monad_def)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1233
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1234
lemma approx_mem_monad: "x \<approx> u \<Longrightarrow> u \<in> monad x"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1235
  by (simp add: monad_def)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1236
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1237
lemma approx_mem_monad2: "x \<approx> u \<Longrightarrow> x \<in> monad u"
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
  1238
  using approx_mem_monad approx_sym by blast
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1239
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1240
lemma approx_mem_monad_zero: "x \<approx> y \<Longrightarrow> x \<in> monad 0 \<Longrightarrow> y \<in> monad 0"
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
  1241
  using approx_trans monad_def by blast
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1242
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1243
lemma Infinitesimal_approx_hrabs: "x \<approx> y \<Longrightarrow> x \<in> Infinitesimal \<Longrightarrow> \<bar>x\<bar> \<approx> \<bar>y\<bar>"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1244
  for x y :: hypreal
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
  1245
  using approx_hnorm by fastforce
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1246
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1247
lemma less_Infinitesimal_less: "0 < x \<Longrightarrow> x \<notin> Infinitesimal \<Longrightarrow> e \<in> Infinitesimal \<Longrightarrow> e < x"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1248
  for x :: hypreal
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
  1249
  using Infinitesimal_interval less_linear by blast
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1250
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1251
lemma Ball_mem_monad_gt_zero: "0 < x \<Longrightarrow> x \<notin> Infinitesimal \<Longrightarrow> u \<in> monad x \<Longrightarrow> 0 < u"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1252
  for u x :: hypreal
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1253
  apply (drule mem_monad_approx [THEN approx_sym])
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1254
  apply (erule bex_Infinitesimal_iff2 [THEN iffD2, THEN bexE])
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1255
  apply (drule_tac e = "-xa" in less_Infinitesimal_less, auto)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1256
  done
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1257
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1258
lemma Ball_mem_monad_less_zero: "x < 0 \<Longrightarrow> x \<notin> Infinitesimal \<Longrightarrow> u \<in> monad x \<Longrightarrow> u < 0"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1259
  for u x :: hypreal
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1260
  apply (drule mem_monad_approx [THEN approx_sym])
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1261
  apply (erule bex_Infinitesimal_iff [THEN iffD2, THEN bexE])
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1262
  apply (cut_tac x = "-x" and e = xa in less_Infinitesimal_less, auto)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1263
  done
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1264
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1265
lemma lemma_approx_gt_zero: "0 < x \<Longrightarrow> x \<notin> Infinitesimal \<Longrightarrow> x \<approx> y \<Longrightarrow> 0 < y"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1266
  for x y :: hypreal
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1267
  by (blast dest: Ball_mem_monad_gt_zero approx_subset_monad)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1268
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1269
lemma lemma_approx_less_zero: "x < 0 \<Longrightarrow> x \<notin> Infinitesimal \<Longrightarrow> x \<approx> y \<Longrightarrow> y < 0"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1270
  for x y :: hypreal
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1271
  by (blast dest: Ball_mem_monad_less_zero approx_subset_monad)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1272
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1273
lemma approx_hrabs: "x \<approx> y \<Longrightarrow> \<bar>x\<bar> \<approx> \<bar>y\<bar>"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1274
  for x y :: hypreal
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1275
  by (drule approx_hnorm) simp
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1276
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1277
lemma approx_hrabs_zero_cancel: "\<bar>x\<bar> \<approx> 0 \<Longrightarrow> x \<approx> 0"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1278
  for x :: hypreal
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1279
  using hrabs_disj [of x] by (auto dest: approx_minus)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1280
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1281
lemma approx_hrabs_add_Infinitesimal: "e \<in> Infinitesimal \<Longrightarrow> \<bar>x\<bar> \<approx> \<bar>x + e\<bar>"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1282
  for e x :: hypreal
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1283
  by (fast intro: approx_hrabs Infinitesimal_add_approx_self)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1284
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1285
lemma approx_hrabs_add_minus_Infinitesimal: "e \<in> Infinitesimal ==> \<bar>x\<bar> \<approx> \<bar>x + -e\<bar>"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1286
  for e x :: hypreal
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1287
  by (fast intro: approx_hrabs Infinitesimal_add_minus_approx_self)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1288
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1289
lemma hrabs_add_Infinitesimal_cancel:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1290
  "e \<in> Infinitesimal \<Longrightarrow> e' \<in> Infinitesimal \<Longrightarrow> \<bar>x + e\<bar> = \<bar>y + e'\<bar> \<Longrightarrow> \<bar>x\<bar> \<approx> \<bar>y\<bar>"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1291
  for e e' x y :: hypreal
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
  1292
  by (metis approx_hrabs_add_Infinitesimal approx_trans2)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1293
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1294
lemma hrabs_add_minus_Infinitesimal_cancel:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1295
  "e \<in> Infinitesimal \<Longrightarrow> e' \<in> Infinitesimal \<Longrightarrow> \<bar>x + -e\<bar> = \<bar>y + -e'\<bar> \<Longrightarrow> \<bar>x\<bar> \<approx> \<bar>y\<bar>"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1296
  for e e' x y :: hypreal
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
  1297
  by (meson Infinitesimal_minus_iff hrabs_add_Infinitesimal_cancel)
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1298
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1299
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 68527
diff changeset
  1300
subsection \<open>More \<^term>\<open>HFinite\<close> and \<^term>\<open>Infinitesimal\<close> Theorems\<close>
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1301
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1302
text \<open>
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1303
  Interesting slightly counterintuitive theorem: necessary
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1304
  for proving that an open interval is an NS open set.
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1305
\<close>
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1306
lemma Infinitesimal_add_hypreal_of_real_less:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1307
  "x < y \<Longrightarrow> u \<in> Infinitesimal \<Longrightarrow> hypreal_of_real x + u < hypreal_of_real y"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1308
  apply (simp add: Infinitesimal_def)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1309
  apply (drule_tac x = "hypreal_of_real y + -hypreal_of_real x" in bspec, simp)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1310
  apply (simp add: abs_less_iff)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1311
  done
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1312
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1313
lemma Infinitesimal_add_hrabs_hypreal_of_real_less:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1314
  "x \<in> Infinitesimal \<Longrightarrow> \<bar>hypreal_of_real r\<bar> < hypreal_of_real y \<Longrightarrow>
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1315
    \<bar>hypreal_of_real r + x\<bar> < hypreal_of_real y"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1316
  apply (drule_tac x = "hypreal_of_real r" in approx_hrabs_add_Infinitesimal)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1317
  apply (drule approx_sym [THEN bex_Infinitesimal_iff2 [THEN iffD2]])
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1318
  apply (auto intro!: Infinitesimal_add_hypreal_of_real_less
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1319
      simp del: star_of_abs simp add: star_of_abs [symmetric])
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1320
  done
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1321
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1322
lemma Infinitesimal_add_hrabs_hypreal_of_real_less2:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1323
  "x \<in> Infinitesimal \<Longrightarrow> \<bar>hypreal_of_real r\<bar> < hypreal_of_real y \<Longrightarrow>
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1324
    \<bar>x + hypreal_of_real r\<bar> < hypreal_of_real y"
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
  1325
  using Infinitesimal_add_hrabs_hypreal_of_real_less by fastforce
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1326
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1327
lemma hypreal_of_real_le_add_Infininitesimal_cancel:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1328
  "u \<in> Infinitesimal \<Longrightarrow> v \<in> Infinitesimal \<Longrightarrow>
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1329
    hypreal_of_real x + u \<le> hypreal_of_real y + v \<Longrightarrow>
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1330
    hypreal_of_real x \<le> hypreal_of_real y"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1331
  apply (simp add: linorder_not_less [symmetric], auto)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1332
  apply (drule_tac u = "v-u" in Infinitesimal_add_hypreal_of_real_less)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1333
   apply (auto simp add: Infinitesimal_diff)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1334
  done
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1335
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1336
lemma hypreal_of_real_le_add_Infininitesimal_cancel2:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1337
  "u \<in> Infinitesimal \<Longrightarrow> v \<in> Infinitesimal \<Longrightarrow>
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1338
    hypreal_of_real x + u \<le> hypreal_of_real y + v \<Longrightarrow> x \<le> y"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1339
  by (blast intro: star_of_le [THEN iffD1] intro!: hypreal_of_real_le_add_Infininitesimal_cancel)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1340
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1341
lemma hypreal_of_real_less_Infinitesimal_le_zero:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1342
  "hypreal_of_real x < e \<Longrightarrow> e \<in> Infinitesimal \<Longrightarrow> hypreal_of_real x \<le> 0"
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
  1343
  by (metis Infinitesimal_interval eq_iff le_less_linear star_of_Infinitesimal_iff_0 star_of_eq_0)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1344
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1345
(*used once, in Lim/NSDERIV_inverse*)
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1346
lemma Infinitesimal_add_not_zero: "h \<in> Infinitesimal \<Longrightarrow> x \<noteq> 0 \<Longrightarrow> star_of x + h \<noteq> 0"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1347
  apply auto
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1348
  apply (subgoal_tac "h = - star_of x")
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1349
   apply (auto intro: minus_unique [symmetric])
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1350
  done
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1351
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1352
lemma Infinitesimal_square_cancel [simp]: "x * x + y * y \<in> Infinitesimal \<Longrightarrow> x * x \<in> Infinitesimal"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1353
  for x y :: hypreal
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
  1354
  by (meson Infinitesimal_interval2 le_add_same_cancel1 not_Infinitesimal_not_zero zero_le_square)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1355
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1356
lemma HFinite_square_cancel [simp]: "x * x + y * y \<in> HFinite \<Longrightarrow> x * x \<in> HFinite"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1357
  for x y :: hypreal
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
  1358
  using HFinite_bounded le_add_same_cancel1 zero_le_square by blast
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1359
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1360
lemma Infinitesimal_square_cancel2 [simp]: "x * x + y * y \<in> Infinitesimal \<Longrightarrow> y * y \<in> Infinitesimal"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1361
  for x y :: hypreal
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1362
  apply (rule Infinitesimal_square_cancel)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1363
  apply (rule add.commute [THEN subst])
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1364
  apply simp
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1365
  done
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1366
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1367
lemma HFinite_square_cancel2 [simp]: "x * x + y * y \<in> HFinite \<Longrightarrow> y * y \<in> HFinite"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1368
  for x y :: hypreal
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1369
  apply (rule HFinite_square_cancel)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1370
  apply (rule add.commute [THEN subst])
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1371
  apply simp
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1372
  done
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1373
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1374
lemma Infinitesimal_sum_square_cancel [simp]:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1375
  "x * x + y * y + z * z \<in> Infinitesimal \<Longrightarrow> x * x \<in> Infinitesimal"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1376
  for x y z :: hypreal
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1377
  apply (rule Infinitesimal_interval2, assumption)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1378
    apply (rule_tac [2] zero_le_square, simp)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1379
  apply (insert zero_le_square [of y])
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1380
  apply (insert zero_le_square [of z], simp del:zero_le_square)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1381
  done
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1382
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1383
lemma HFinite_sum_square_cancel [simp]: "x * x + y * y + z * z \<in> HFinite \<Longrightarrow> x * x \<in> HFinite"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1384
  for x y z :: hypreal
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1385
  apply (rule HFinite_bounded, assumption)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1386
   apply (rule_tac [2] zero_le_square)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1387
  apply (insert zero_le_square [of y])
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1388
  apply (insert zero_le_square [of z], simp del:zero_le_square)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1389
  done
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1390
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1391
lemma Infinitesimal_sum_square_cancel2 [simp]:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1392
  "y * y + x * x + z * z \<in> Infinitesimal \<Longrightarrow> x * x \<in> Infinitesimal"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1393
  for x y z :: hypreal
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1394
  apply (rule Infinitesimal_sum_square_cancel)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1395
  apply (simp add: ac_simps)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1396
  done
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1397
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1398
lemma HFinite_sum_square_cancel2 [simp]: "y * y + x * x + z * z \<in> HFinite \<Longrightarrow> x * x \<in> HFinite"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1399
  for x y z :: hypreal
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1400
  apply (rule HFinite_sum_square_cancel)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1401
  apply (simp add: ac_simps)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1402
  done
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1403
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1404
lemma Infinitesimal_sum_square_cancel3 [simp]:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1405
  "z * z + y * y + x * x \<in> Infinitesimal \<Longrightarrow> x * x \<in> Infinitesimal"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1406
  for x y z :: hypreal
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1407
  apply (rule Infinitesimal_sum_square_cancel)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1408
  apply (simp add: ac_simps)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1409
  done
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1410
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1411
lemma HFinite_sum_square_cancel3 [simp]: "z * z + y * y + x * x \<in> HFinite \<Longrightarrow> x * x \<in> HFinite"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1412
  for x y z :: hypreal
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1413
  apply (rule HFinite_sum_square_cancel)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1414
  apply (simp add: ac_simps)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1415
  done
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1416
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1417
lemma monad_hrabs_less: "y \<in> monad x \<Longrightarrow> 0 < hypreal_of_real e \<Longrightarrow> \<bar>y - x\<bar> < hypreal_of_real e"
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
  1418
  by (simp add: Infinitesimal_approx_minus approx_sym less_Infinitesimal_less mem_monad_approx)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1419
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1420
lemma mem_monad_SReal_HFinite: "x \<in> monad (hypreal_of_real  a) \<Longrightarrow> x \<in> HFinite"
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
  1421
  using HFinite_star_of approx_HFinite mem_monad_approx by blast
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1422
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1423
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1424
subsection \<open>Theorems about Standard Part\<close>
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1425
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1426
lemma st_approx_self: "x \<in> HFinite \<Longrightarrow> st x \<approx> x"
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
  1427
  by (metis (no_types, lifting) approx_refl approx_trans3 someI_ex st_def st_part_Ex st_part_Ex1)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1428
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1429
lemma st_SReal: "x \<in> HFinite \<Longrightarrow> st x \<in> \<real>"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1430
  apply (simp add: st_def)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1431
  apply (frule st_part_Ex, safe)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1432
  apply (rule someI2)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1433
   apply (auto intro: approx_sym)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1434
  done
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1435
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1436
lemma st_HFinite: "x \<in> HFinite \<Longrightarrow> st x \<in> HFinite"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1437
  by (erule st_SReal [THEN SReal_subset_HFinite [THEN subsetD]])
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1438
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1439
lemma st_unique: "r \<in> \<real> \<Longrightarrow> r \<approx> x \<Longrightarrow> st x = r"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1440
  apply (frule SReal_subset_HFinite [THEN subsetD])
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1441
  apply (drule (1) approx_HFinite)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1442
  apply (unfold st_def)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1443
  apply (rule some_equality)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1444
   apply (auto intro: approx_unique_real)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1445
  done
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1446
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1447
lemma st_SReal_eq: "x \<in> \<real> \<Longrightarrow> st x = x"
61649
268d88ec9087 Tweaks for "real": Removal of [iff] status for some lemmas, adding [simp] for others. Plus fixes.
paulson <lp15@cam.ac.uk>
parents: 61609
diff changeset
  1448
  by (metis approx_refl st_unique)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1449
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1450
lemma st_hypreal_of_real [simp]: "st (hypreal_of_real x) = hypreal_of_real x"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1451
  by (rule SReal_hypreal_of_real [THEN st_SReal_eq])
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1452
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1453
lemma st_eq_approx: "x \<in> HFinite \<Longrightarrow> y \<in> HFinite \<Longrightarrow> st x = st y \<Longrightarrow> x \<approx> y"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1454
  by (auto dest!: st_approx_self elim!: approx_trans3)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1455
56217
dc429a5b13c4 Some rationalisation of basic lemmas
paulson <lp15@cam.ac.uk>
parents: 54489
diff changeset
  1456
lemma approx_st_eq:
61982
3af5a06577c7 more symbols;
wenzelm
parents: 61981
diff changeset
  1457
  assumes x: "x \<in> HFinite" and y: "y \<in> HFinite" and xy: "x \<approx> y"
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1458
  shows "st x = st y"
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1459
proof -
61982
3af5a06577c7 more symbols;
wenzelm
parents: 61981
diff changeset
  1460
  have "st x \<approx> x" "st y \<approx> y" "st x \<in> \<real>" "st y \<in> \<real>"
41541
1fa4725c4656 eliminated global prems;
wenzelm
parents: 39159
diff changeset
  1461
    by (simp_all add: st_approx_self st_SReal x y)
1fa4725c4656 eliminated global prems;
wenzelm
parents: 39159
diff changeset
  1462
  with xy show ?thesis
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1463
    by (fast elim: approx_trans approx_trans2 SReal_approx_iff [THEN iffD1])
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1464
qed
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1465
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1466
lemma st_eq_approx_iff: "x \<in> HFinite \<Longrightarrow> y \<in> HFinite \<Longrightarrow> x \<approx> y \<longleftrightarrow> st x = st y"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1467
  by (blast intro: approx_st_eq st_eq_approx)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1468
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1469
lemma st_Infinitesimal_add_SReal: "x \<in> \<real> \<Longrightarrow> e \<in> Infinitesimal \<Longrightarrow> st (x + e) = x"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1470
  apply (erule st_unique)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1471
  apply (erule Infinitesimal_add_approx_self)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1472
  done
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1473
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1474
lemma st_Infinitesimal_add_SReal2: "x \<in> \<real> \<Longrightarrow> e \<in> Infinitesimal \<Longrightarrow> st (e + x) = x"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1475
  apply (erule st_unique)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1476
  apply (erule Infinitesimal_add_approx_self2)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1477
  done
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1478
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1479
lemma HFinite_st_Infinitesimal_add: "x \<in> HFinite \<Longrightarrow> \<exists>e \<in> Infinitesimal. x = st(x) + e"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1480
  by (blast dest!: st_approx_self [THEN approx_sym] bex_Infinitesimal_iff2 [THEN iffD2])
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1481
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1482
lemma st_add: "x \<in> HFinite \<Longrightarrow> y \<in> HFinite \<Longrightarrow> st (x + y) = st x + st y"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1483
  by (simp add: st_unique st_SReal st_approx_self approx_add)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1484
47108
2a1953f0d20d merged fork with new numeral representation (see NEWS)
huffman
parents: 45541
diff changeset
  1485
lemma st_numeral [simp]: "st (numeral w) = numeral w"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1486
  by (rule Reals_numeral [THEN st_SReal_eq])
47108
2a1953f0d20d merged fork with new numeral representation (see NEWS)
huffman
parents: 45541
diff changeset
  1487
54489
03ff4d1e6784 eliminiated neg_numeral in favour of - (numeral _)
haftmann
parents: 54263
diff changeset
  1488
lemma st_neg_numeral [simp]: "st (- numeral w) = - numeral w"
03ff4d1e6784 eliminiated neg_numeral in favour of - (numeral _)
haftmann
parents: 54263
diff changeset
  1489
proof -
03ff4d1e6784 eliminiated neg_numeral in favour of - (numeral _)
haftmann
parents: 54263
diff changeset
  1490
  from Reals_numeral have "numeral w \<in> \<real>" .
03ff4d1e6784 eliminiated neg_numeral in favour of - (numeral _)
haftmann
parents: 54263
diff changeset
  1491
  then have "- numeral w \<in> \<real>" by simp
03ff4d1e6784 eliminiated neg_numeral in favour of - (numeral _)
haftmann
parents: 54263
diff changeset
  1492
  with st_SReal_eq show ?thesis .
03ff4d1e6784 eliminiated neg_numeral in favour of - (numeral _)
haftmann
parents: 54263
diff changeset
  1493
qed
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1494
45540
7f5050fb8821 name simp theorems st_0 and st_1
huffman
parents: 44945
diff changeset
  1495
lemma st_0 [simp]: "st 0 = 0"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1496
  by (simp add: st_SReal_eq)
45540
7f5050fb8821 name simp theorems st_0 and st_1
huffman
parents: 44945
diff changeset
  1497
7f5050fb8821 name simp theorems st_0 and st_1
huffman
parents: 44945
diff changeset
  1498
lemma st_1 [simp]: "st 1 = 1"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1499
  by (simp add: st_SReal_eq)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1500
54489
03ff4d1e6784 eliminiated neg_numeral in favour of - (numeral _)
haftmann
parents: 54263
diff changeset
  1501
lemma st_neg_1 [simp]: "st (- 1) = - 1"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1502
  by (simp add: st_SReal_eq)
54489
03ff4d1e6784 eliminiated neg_numeral in favour of - (numeral _)
haftmann
parents: 54263
diff changeset
  1503
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1504
lemma st_minus: "x \<in> HFinite \<Longrightarrow> st (- x) = - st x"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1505
  by (simp add: st_unique st_SReal st_approx_self approx_minus)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1506
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1507
lemma st_diff: "\<lbrakk>x \<in> HFinite; y \<in> HFinite\<rbrakk> \<Longrightarrow> st (x - y) = st x - st y"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1508
  by (simp add: st_unique st_SReal st_approx_self approx_diff)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1509
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1510
lemma st_mult: "\<lbrakk>x \<in> HFinite; y \<in> HFinite\<rbrakk> \<Longrightarrow> st (x * y) = st x * st y"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1511
  by (simp add: st_unique st_SReal st_approx_self approx_mult_HFinite)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1512
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1513
lemma st_Infinitesimal: "x \<in> Infinitesimal \<Longrightarrow> st x = 0"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1514
  by (simp add: st_unique mem_infmal_iff)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1515
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1516
lemma st_not_Infinitesimal: "st(x) \<noteq> 0 \<Longrightarrow> x \<notin> Infinitesimal"
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1517
by (fast intro: st_Infinitesimal)
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1518
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1519
lemma st_inverse: "x \<in> HFinite \<Longrightarrow> st x \<noteq> 0 \<Longrightarrow> st (inverse x) = inverse (st x)"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1520
  apply (rule_tac c1 = "st x" in mult_left_cancel [THEN iffD1])
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1521
   apply (auto simp add: st_mult [symmetric] st_not_Infinitesimal HFinite_inverse)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1522
  apply (subst right_inverse, auto)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1523
  done
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1524
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1525
lemma st_divide [simp]: "x \<in> HFinite \<Longrightarrow> y \<in> HFinite \<Longrightarrow> st y \<noteq> 0 \<Longrightarrow> st (x / y) = st x / st y"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1526
  by (simp add: divide_inverse st_mult st_not_Infinitesimal HFinite_inverse st_inverse)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1527
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1528
lemma st_idempotent [simp]: "x \<in> HFinite \<Longrightarrow> st (st x) = st x"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1529
  by (blast intro: st_HFinite st_approx_self approx_st_eq)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1530
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1531
lemma Infinitesimal_add_st_less:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1532
  "x \<in> HFinite \<Longrightarrow> y \<in> HFinite \<Longrightarrow> u \<in> Infinitesimal \<Longrightarrow> st x < st y \<Longrightarrow> st x + u < st y"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1533
  apply (drule st_SReal)+
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1534
  apply (auto intro!: Infinitesimal_add_hypreal_of_real_less simp add: SReal_iff)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1535
  done
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1536
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1537
lemma Infinitesimal_add_st_le_cancel:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1538
  "x \<in> HFinite \<Longrightarrow> y \<in> HFinite \<Longrightarrow> u \<in> Infinitesimal \<Longrightarrow>
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1539
    st x \<le> st y + u \<Longrightarrow> st x \<le> st y"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1540
  apply (simp add: linorder_not_less [symmetric])
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1541
  apply (auto dest: Infinitesimal_add_st_less)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1542
  done
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1543
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1544
lemma st_le: "x \<in> HFinite \<Longrightarrow> y \<in> HFinite \<Longrightarrow> x \<le> y \<Longrightarrow> st x \<le> st y"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1545
  by (metis approx_le_bound approx_sym linear st_SReal st_approx_self st_part_Ex1)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1546
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1547
lemma st_zero_le: "0 \<le> x \<Longrightarrow> x \<in> HFinite \<Longrightarrow> 0 \<le> st x"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1548
  apply (subst st_0 [symmetric])
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1549
  apply (rule st_le, auto)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1550
  done
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1551
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1552
lemma st_zero_ge: "x \<le> 0 \<Longrightarrow> x \<in> HFinite \<Longrightarrow> st x \<le> 0"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1553
  apply (subst st_0 [symmetric])
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1554
  apply (rule st_le, auto)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1555
  done
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1556
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1557
lemma st_hrabs: "x \<in> HFinite \<Longrightarrow> \<bar>st x\<bar> = st \<bar>x\<bar>"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1558
  apply (simp add: linorder_not_le st_zero_le abs_if st_minus linorder_not_less)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1559
  apply (auto dest!: st_zero_ge [OF order_less_imp_le])
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1560
  done
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1561
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1562
61975
b4b11391c676 isabelle update_cartouches -c -t;
wenzelm
parents: 61945
diff changeset
  1563
subsection \<open>Alternative Definitions using Free Ultrafilter\<close>
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1564
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 68527
diff changeset
  1565
subsubsection \<open>\<^term>\<open>HFinite\<close>\<close>
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1566
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1567
lemma HFinite_FreeUltrafilterNat:
64438
wenzelm
parents: 64435
diff changeset
  1568
  "star_n X \<in> HFinite \<Longrightarrow> \<exists>u. eventually (\<lambda>n. norm (X n) < u) \<U>"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1569
  apply (auto simp add: HFinite_def SReal_def)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1570
  apply (rule_tac x=r in exI)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1571
  apply (simp add: hnorm_def star_of_def starfun_star_n)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1572
  apply (simp add: star_less_def starP2_star_n)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1573
  done
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1574
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1575
lemma FreeUltrafilterNat_HFinite:
64438
wenzelm
parents: 64435
diff changeset
  1576
  "\<exists>u. eventually (\<lambda>n. norm (X n) < u) \<U> \<Longrightarrow> star_n X \<in> HFinite"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1577
  apply (auto simp add: HFinite_def mem_Rep_star_iff)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1578
  apply (rule_tac x="star_of u" in bexI)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1579
   apply (simp add: hnorm_def starfun_star_n star_of_def)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1580
   apply (simp add: star_less_def starP2_star_n)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1581
  apply (simp add: SReal_def)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1582
  done
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1583
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1584
lemma HFinite_FreeUltrafilterNat_iff:
64438
wenzelm
parents: 64435
diff changeset
  1585
  "star_n X \<in> HFinite \<longleftrightarrow> (\<exists>u. eventually (\<lambda>n. norm (X n) < u) \<U>)"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1586
  by (blast intro!: HFinite_FreeUltrafilterNat FreeUltrafilterNat_HFinite)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1587
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1588
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 68527
diff changeset
  1589
subsubsection \<open>\<^term>\<open>HInfinite\<close>\<close>
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1590
56225
00112abe9b25 fixing messy proofs
paulson <lp15@cam.ac.uk>
parents: 56217
diff changeset
  1591
lemma lemma_Compl_eq: "- {n. u < norm (f n)} = {n. norm (f n) \<le> u}"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1592
  by auto
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1593
56225
00112abe9b25 fixing messy proofs
paulson <lp15@cam.ac.uk>
parents: 56217
diff changeset
  1594
lemma lemma_Compl_eq2: "- {n. norm (f n) < u} = {n. u \<le> norm (f n)}"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1595
  by auto
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1596
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1597
lemma lemma_Int_eq1: "{n. norm (f n) \<le> u} Int {n. u \<le> norm (f n)} = {n. norm(f n) = u}"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1598
  by auto
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1599
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1600
lemma lemma_FreeUltrafilterNat_one: "{n. norm (f n) = u} \<le> {n. norm (f n) < u + (1::real)}"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1601
  by auto
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1602
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1603
text \<open>Exclude this type of sets from free ultrafilter for Infinite numbers!\<close>
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1604
lemma FreeUltrafilterNat_const_Finite:
64438
wenzelm
parents: 64435
diff changeset
  1605
  "eventually (\<lambda>n. norm (X n) = u) \<U> \<Longrightarrow> star_n X \<in> HFinite"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1606
  apply (rule FreeUltrafilterNat_HFinite)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1607
  apply (rule_tac x = "u + 1" in exI)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1608
  apply (auto elim: eventually_mono)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1609
  done
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1610
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1611
lemma HInfinite_FreeUltrafilterNat:
64438
wenzelm
parents: 64435
diff changeset
  1612
  "star_n X \<in> HInfinite \<Longrightarrow> \<forall>u. eventually (\<lambda>n. u < norm (X n)) \<U>"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1613
  apply (drule HInfinite_HFinite_iff [THEN iffD1])
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1614
  apply (simp add: HFinite_FreeUltrafilterNat_iff)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1615
  apply (rule allI, drule_tac x="u + 1" in spec)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1616
  apply (simp add: FreeUltrafilterNat.eventually_not_iff[symmetric])
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1617
  apply (auto elim: eventually_mono)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1618
  done
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1619
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1620
lemma lemma_Int_HI: "{n. norm (Xa n) < u} \<inter> {n. X n = Xa n} \<subseteq> {n. norm (X n) < u}"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1621
  for u :: real
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1622
  by auto
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1623
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1624
lemma FreeUltrafilterNat_HInfinite:
64438
wenzelm
parents: 64435
diff changeset
  1625
  "\<forall>u. eventually (\<lambda>n. u < norm (X n)) \<U> \<Longrightarrow> star_n X \<in> HInfinite"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1626
  apply (rule HInfinite_HFinite_iff [THEN iffD2])
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1627
  apply (safe, drule HFinite_FreeUltrafilterNat, safe)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1628
  apply (drule_tac x = u in spec)
60041
6c86d58ab0ca replace Filters in NSA by HOL-Filters
hoelzl
parents: 59867
diff changeset
  1629
proof -
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1630
  fix u
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1631
  assume "\<forall>\<^sub>Fn in \<U>. norm (X n) < u" "\<forall>\<^sub>Fn in \<U>. u < norm (X n)"
60041
6c86d58ab0ca replace Filters in NSA by HOL-Filters
hoelzl
parents: 59867
diff changeset
  1632
  then have "\<forall>\<^sub>F x in \<U>. False"
6c86d58ab0ca replace Filters in NSA by HOL-Filters
hoelzl
parents: 59867
diff changeset
  1633
    by eventually_elim auto
6c86d58ab0ca replace Filters in NSA by HOL-Filters
hoelzl
parents: 59867
diff changeset
  1634
  then show False
6c86d58ab0ca replace Filters in NSA by HOL-Filters
hoelzl
parents: 59867
diff changeset
  1635
    by (simp add: eventually_False FreeUltrafilterNat.proper)
6c86d58ab0ca replace Filters in NSA by HOL-Filters
hoelzl
parents: 59867
diff changeset
  1636
qed
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1637
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1638
lemma HInfinite_FreeUltrafilterNat_iff:
64438
wenzelm
parents: 64435
diff changeset
  1639
  "star_n X \<in> HInfinite \<longleftrightarrow> (\<forall>u. eventually (\<lambda>n. u < norm (X n)) \<U>)"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1640
  by (blast intro!: HInfinite_FreeUltrafilterNat FreeUltrafilterNat_HInfinite)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1641
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1642
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 68527
diff changeset
  1643
subsubsection \<open>\<^term>\<open>Infinitesimal\<close>\<close>
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1644
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1645
lemma ball_SReal_eq: "(\<forall>x::hypreal \<in> Reals. P x) \<longleftrightarrow> (\<forall>x::real. P (star_of x))"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1646
  by (auto simp: SReal_def)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1647
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1648
lemma Infinitesimal_FreeUltrafilterNat:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1649
  "star_n X \<in> Infinitesimal \<Longrightarrow> \<forall>u>0. eventually (\<lambda>n. norm (X n) < u) \<U>"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1650
  apply (simp add: Infinitesimal_def ball_SReal_eq)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1651
  apply (simp add: hnorm_def starfun_star_n star_of_def)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1652
  apply (simp add: star_less_def starP2_star_n)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1653
  done
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1654
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1655
lemma FreeUltrafilterNat_Infinitesimal:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1656
  "\<forall>u>0. eventually (\<lambda>n. norm (X n) < u) \<U> \<Longrightarrow> star_n X \<in> Infinitesimal"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1657
  apply (simp add: Infinitesimal_def ball_SReal_eq)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1658
  apply (simp add: hnorm_def starfun_star_n star_of_def)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1659
  apply (simp add: star_less_def starP2_star_n)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1660
  done
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1661
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1662
lemma Infinitesimal_FreeUltrafilterNat_iff:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1663
  "(star_n X \<in> Infinitesimal) = (\<forall>u>0. eventually (\<lambda>n. norm (X n) < u) \<U>)"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1664
  by (blast intro!: Infinitesimal_FreeUltrafilterNat FreeUltrafilterNat_Infinitesimal)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1665
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1666
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1667
text \<open>Infinitesimals as smaller than \<open>1/n\<close> for all \<open>n::nat (> 0)\<close>.\<close>
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1668
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1669
lemma lemma_Infinitesimal: "(\<forall>r. 0 < r \<longrightarrow> x < r) \<longleftrightarrow> (\<forall>n. x < inverse (real (Suc n)))"
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
  1670
  by (meson inverse_positive_iff_positive less_trans of_nat_0_less_iff reals_Archimedean zero_less_Suc)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1671
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1672
lemma lemma_Infinitesimal2:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1673
  "(\<forall>r \<in> Reals. 0 < r \<longrightarrow> x < r) \<longleftrightarrow> (\<forall>n. x < inverse(hypreal_of_nat (Suc n)))"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1674
  apply safe
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1675
   apply (drule_tac x = "inverse (hypreal_of_real (real (Suc n))) " in bspec)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1676
    apply simp_all
61649
268d88ec9087 Tweaks for "real": Removal of [iff] status for some lemmas, adding [simp] for others. Plus fixes.
paulson <lp15@cam.ac.uk>
parents: 61609
diff changeset
  1677
  using less_imp_of_nat_less apply fastforce
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1678
  apply (auto dest!: reals_Archimedean simp add: SReal_iff simp del: of_nat_Suc)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1679
  apply (drule star_of_less [THEN iffD2])
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1680
  apply simp
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1681
  apply (blast intro: order_less_trans)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1682
  done
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1683
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1684
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1685
lemma Infinitesimal_hypreal_of_nat_iff:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1686
  "Infinitesimal = {x. \<forall>n. hnorm x < inverse (hypreal_of_nat (Suc n))}"
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
  1687
  using Infinitesimal_def lemma_Infinitesimal2 by auto
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1688
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1689
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1690
subsection \<open>Proof that \<open>\<omega>\<close> is an infinite number\<close>
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1691
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1692
text \<open>It will follow that \<open>\<epsilon>\<close> is an infinitesimal number.\<close>
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1693
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1694
lemma Suc_Un_eq: "{n. n < Suc m} = {n. n < m} Un {n. n = m}"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1695
  by (auto simp add: less_Suc_eq)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1696
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1697
64438
wenzelm
parents: 64435
diff changeset
  1698
text \<open>Prove that any segment is finite and hence cannot belong to \<open>\<U>\<close>.\<close>
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1699
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1700
lemma finite_real_of_nat_segment: "finite {n::nat. real n < real (m::nat)}"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1701
  by auto
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1702
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1703
lemma finite_real_of_nat_less_real: "finite {n::nat. real n < u}"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1704
  apply (cut_tac x = u in reals_Archimedean2, safe)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1705
  apply (rule finite_real_of_nat_segment [THEN [2] finite_subset])
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1706
  apply (auto dest: order_less_trans)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1707
  done
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1708
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1709
lemma finite_real_of_nat_le_real: "finite {n::nat. real n \<le> u}"
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
  1710
  by (metis infinite_nat_iff_unbounded leD le_nat_floor mem_Collect_eq)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1711
61945
1135b8de26c3 more symbols;
wenzelm
parents: 61810
diff changeset
  1712
lemma finite_rabs_real_of_nat_le_real: "finite {n::nat. \<bar>real n\<bar> \<le> u}"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1713
  by (simp add: finite_real_of_nat_le_real)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1714
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1715
lemma rabs_real_of_nat_le_real_FreeUltrafilterNat:
64438
wenzelm
parents: 64435
diff changeset
  1716
  "\<not> eventually (\<lambda>n. \<bar>real n\<bar> \<le> u) \<U>"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1717
  by (blast intro!: FreeUltrafilterNat.finite finite_rabs_real_of_nat_le_real)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1718
64438
wenzelm
parents: 64435
diff changeset
  1719
lemma FreeUltrafilterNat_nat_gt_real: "eventually (\<lambda>n. u < real n) \<U>"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1720
  apply (rule FreeUltrafilterNat.finite')
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1721
  apply (subgoal_tac "{n::nat. \<not> u < real n} = {n. real n \<le> u}")
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1722
   apply (auto simp add: finite_real_of_nat_le_real)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1723
  done
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1724
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1725
text \<open>The complement of \<open>{n. \<bar>real n\<bar> \<le> u} = {n. u < \<bar>real n\<bar>}\<close> is in
64438
wenzelm
parents: 64435
diff changeset
  1726
  \<open>\<U>\<close> by property of (free) ultrafilters.\<close>
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1727
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 68527
diff changeset
  1728
text \<open>\<^term>\<open>\<omega>\<close> is a member of \<^term>\<open>HInfinite\<close>.\<close>
61981
1b5845c62fa0 more symbols;
wenzelm
parents: 61975
diff changeset
  1729
theorem HInfinite_omega [simp]: "\<omega> \<in> HInfinite"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1730
  apply (simp add: omega_def)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1731
  apply (rule FreeUltrafilterNat_HInfinite)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1732
  apply clarify
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1733
  apply (rule_tac u1 = "u-1" in eventually_mono [OF FreeUltrafilterNat_nat_gt_real])
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1734
  apply auto
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1735
  done
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1736
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1737
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1738
text \<open>Epsilon is a member of Infinitesimal.\<close>
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1739
61981
1b5845c62fa0 more symbols;
wenzelm
parents: 61975
diff changeset
  1740
lemma Infinitesimal_epsilon [simp]: "\<epsilon> \<in> Infinitesimal"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1741
  by (auto intro!: HInfinite_inverse_Infinitesimal HInfinite_omega
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1742
      simp add: hypreal_epsilon_inverse_omega)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1743
61981
1b5845c62fa0 more symbols;
wenzelm
parents: 61975
diff changeset
  1744
lemma HFinite_epsilon [simp]: "\<epsilon> \<in> HFinite"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1745
  by (auto intro: Infinitesimal_subset_HFinite [THEN subsetD])
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1746
61982
3af5a06577c7 more symbols;
wenzelm
parents: 61981
diff changeset
  1747
lemma epsilon_approx_zero [simp]: "\<epsilon> \<approx> 0"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1748
  by (simp add: mem_infmal_iff [symmetric])
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1749
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1750
text \<open>Needed for proof that we define a hyperreal \<open>[<X(n)] \<approx> hypreal_of_real a\<close> given
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1751
  that \<open>\<forall>n. |X n - a| < 1/n\<close>. Used in proof of \<open>NSLIM \<Rightarrow> LIM\<close>.\<close>
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1752
lemma real_of_nat_less_inverse_iff: "0 < u \<Longrightarrow> u < inverse (real(Suc n)) \<longleftrightarrow> real(Suc n) < inverse u"
70221
bca14283e1a8 huge de-apply effort
paulson <lp15@cam.ac.uk>
parents: 69597
diff changeset
  1753
  using less_imp_inverse_less by force
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1754
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1755
lemma finite_inverse_real_of_posnat_gt_real: "0 < u \<Longrightarrow> finite {n. u < inverse (real (Suc n))}"
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61378
diff changeset
  1756
proof (simp only: real_of_nat_less_inverse_iff)
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61378
diff changeset
  1757
  have "{n. 1 + real n < inverse u} = {n. real n < inverse u - 1}"
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61378
diff changeset
  1758
    by fastforce
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1759
  then show "finite {n. real (Suc n) < inverse u}"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1760
    using finite_real_of_nat_less_real [of "inverse u - 1"]
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1761
    by auto
61609
77b453bd616f Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
paulson <lp15@cam.ac.uk>
parents: 61378
diff changeset
  1762
qed
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1763
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1764
lemma lemma_real_le_Un_eq2:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1765
  "{n. u \<le> inverse(real(Suc n))} =
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1766
    {n. u < inverse(real(Suc n))} \<union> {n. u = inverse(real(Suc n))}"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1767
  by (auto dest: order_le_imp_less_or_eq simp add: order_less_imp_le)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1768
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1769
lemma finite_inverse_real_of_posnat_ge_real: "0 < u \<Longrightarrow> finite {n. u \<le> inverse (real (Suc n))}"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1770
  by (auto simp add: lemma_real_le_Un_eq2 lemma_finite_epsilon_set finite_inverse_real_of_posnat_gt_real
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1771
      simp del: of_nat_Suc)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1772
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1773
lemma inverse_real_of_posnat_ge_real_FreeUltrafilterNat:
64438
wenzelm
parents: 64435
diff changeset
  1774
  "0 < u \<Longrightarrow> \<not> eventually (\<lambda>n. u \<le> inverse(real(Suc n))) \<U>"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1775
  by (blast intro!: FreeUltrafilterNat.finite finite_inverse_real_of_posnat_ge_real)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1776
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1777
text \<open>The complement of \<open>{n. u \<le> inverse(real(Suc n))} = {n. inverse (real (Suc n)) < u}\<close>
64438
wenzelm
parents: 64435
diff changeset
  1778
  is in \<open>\<U>\<close> by property of (free) ultrafilters.\<close>
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1779
lemma Compl_le_inverse_eq: "- {n. u \<le> inverse(real(Suc n))} = {n. inverse(real(Suc n)) < u}"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1780
  by (auto dest!: order_le_less_trans simp add: linorder_not_le)
56225
00112abe9b25 fixing messy proofs
paulson <lp15@cam.ac.uk>
parents: 56217
diff changeset
  1781
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1782
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1783
lemma FreeUltrafilterNat_inverse_real_of_posnat:
64438
wenzelm
parents: 64435
diff changeset
  1784
  "0 < u \<Longrightarrow> eventually (\<lambda>n. inverse(real(Suc n)) < u) \<U>"
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1785
  by (drule inverse_real_of_posnat_ge_real_FreeUltrafilterNat)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1786
    (simp add: FreeUltrafilterNat.eventually_not_iff not_le[symmetric])
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1787
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1788
text \<open>Example of an hypersequence (i.e. an extended standard sequence)
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1789
  whose term with an hypernatural suffix is an infinitesimal i.e.
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1790
  the whn'nth term of the hypersequence is a member of Infinitesimal\<close>
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1791
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1792
lemma SEQ_Infinitesimal: "( *f* (\<lambda>n::nat. inverse(real(Suc n)))) whn \<in> Infinitesimal"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1793
  by (simp add: hypnat_omega_def starfun_star_n star_n_inverse Infinitesimal_FreeUltrafilterNat_iff
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1794
      FreeUltrafilterNat_inverse_real_of_posnat del: of_nat_Suc)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1795
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1796
text \<open>Example where we get a hyperreal from a real sequence
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1797
  for which a particular property holds. The theorem is
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1798
  used in proofs about equivalence of nonstandard and
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1799
  standard neighbourhoods. Also used for equivalence of
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1800
  nonstandard ans standard definitions of pointwise
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1801
  limit.\<close>
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1802
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1803
text \<open>\<open>|X(n) - x| < 1/n \<Longrightarrow> [<X n>] - hypreal_of_real x| \<in> Infinitesimal\<close>\<close>
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1804
lemma real_seq_to_hypreal_Infinitesimal:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1805
  "\<forall>n. norm (X n - x) < inverse (real (Suc n)) \<Longrightarrow> star_n X - star_of x \<in> Infinitesimal"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1806
  unfolding star_n_diff star_of_def Infinitesimal_FreeUltrafilterNat_iff star_n_inverse
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1807
  by (auto dest!: FreeUltrafilterNat_inverse_real_of_posnat
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1808
      intro: order_less_trans elim!: eventually_mono)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1809
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1810
lemma real_seq_to_hypreal_approx:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1811
  "\<forall>n. norm (X n - x) < inverse (real (Suc n)) \<Longrightarrow> star_n X \<approx> star_of x"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1812
  by (metis bex_Infinitesimal_iff real_seq_to_hypreal_Infinitesimal)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1813
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1814
lemma real_seq_to_hypreal_approx2:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1815
  "\<forall>n. norm (x - X n) < inverse(real(Suc n)) \<Longrightarrow> star_n X \<approx> star_of x"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1816
  by (metis norm_minus_commute real_seq_to_hypreal_approx)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1817
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1818
lemma real_seq_to_hypreal_Infinitesimal2:
64435
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1819
  "\<forall>n. norm(X n - Y n) < inverse(real(Suc n)) \<Longrightarrow> star_n X - star_n Y \<in> Infinitesimal"
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1820
  unfolding Infinitesimal_FreeUltrafilterNat_iff star_n_diff
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1821
  by (auto dest!: FreeUltrafilterNat_inverse_real_of_posnat
c93b0e6131c3 misc tuning and modernization;
wenzelm
parents: 63901
diff changeset
  1822
      intro: order_less_trans elim!: eventually_mono)
27468
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1823
0783dd1dc13d move nonstandard analysis theories to NSA directory
huffman
parents:
diff changeset
  1824
end