src/HOL/NSA/NSA.thy
changeset 47108 2a1953f0d20d
parent 45541 934866fc776c
child 51521 36fa825e0ea7
equal deleted inserted replaced
47107:35807a5d8dc2 47108:2a1953f0d20d
   188 by (simp add: Reals_eq_Standard)
   188 by (simp add: Reals_eq_Standard)
   189 
   189 
   190 lemma SReal_hypreal_of_real [simp]: "hypreal_of_real x \<in> Reals"
   190 lemma SReal_hypreal_of_real [simp]: "hypreal_of_real x \<in> Reals"
   191 by (simp add: Reals_eq_Standard)
   191 by (simp add: Reals_eq_Standard)
   192 
   192 
   193 lemma SReal_divide_number_of: "r \<in> Reals ==> r/(number_of w::hypreal) \<in> Reals"
   193 lemma SReal_divide_numeral: "r \<in> Reals ==> r/(numeral w::hypreal) \<in> Reals"
   194 by simp
   194 by simp
   195 
   195 
   196 text{*epsilon is not in Reals because it is an infinitesimal*}
   196 text{*epsilon is not in Reals because it is an infinitesimal*}
   197 lemma SReal_epsilon_not_mem: "epsilon \<notin> Reals"
   197 lemma SReal_epsilon_not_mem: "epsilon \<notin> Reals"
   198 apply (simp add: SReal_def)
   198 apply (simp add: SReal_def)
   288 
   288 
   289 lemma HFinite_hnorm_iff [iff]:
   289 lemma HFinite_hnorm_iff [iff]:
   290   "(hnorm (x::hypreal) \<in> HFinite) = (x \<in> HFinite)"
   290   "(hnorm (x::hypreal) \<in> HFinite) = (x \<in> HFinite)"
   291 by (simp add: HFinite_def)
   291 by (simp add: HFinite_def)
   292 
   292 
   293 lemma HFinite_number_of [simp]: "number_of w \<in> HFinite"
   293 lemma HFinite_numeral [simp]: "numeral w \<in> HFinite"
   294 unfolding star_number_def by (rule HFinite_star_of)
   294 unfolding star_numeral_def by (rule HFinite_star_of)
   295 
   295 
   296 (** As always with numerals, 0 and 1 are special cases **)
   296 (** As always with numerals, 0 and 1 are special cases **)
   297 
   297 
   298 lemma HFinite_0 [simp]: "0 \<in> HFinite"
   298 lemma HFinite_0 [simp]: "0 \<in> HFinite"
   299 unfolding star_zero_def by (rule HFinite_star_of)
   299 unfolding star_zero_def by (rule HFinite_star_of)
   345 lemma Infinitesimal_add:
   345 lemma Infinitesimal_add:
   346      "[| x \<in> Infinitesimal; y \<in> Infinitesimal |] ==> (x+y) \<in> Infinitesimal"
   346      "[| x \<in> Infinitesimal; y \<in> Infinitesimal |] ==> (x+y) \<in> Infinitesimal"
   347 apply (rule InfinitesimalI)
   347 apply (rule InfinitesimalI)
   348 apply (rule hypreal_sum_of_halves [THEN subst])
   348 apply (rule hypreal_sum_of_halves [THEN subst])
   349 apply (drule half_gt_zero)
   349 apply (drule half_gt_zero)
   350 apply (blast intro: hnorm_add_less SReal_divide_number_of dest: InfinitesimalD)
   350 apply (blast intro: hnorm_add_less SReal_divide_numeral dest: InfinitesimalD)
   351 done
   351 done
   352 
   352 
   353 lemma Infinitesimal_minus_iff [simp]: "(-x:Infinitesimal) = (x:Infinitesimal)"
   353 lemma Infinitesimal_minus_iff [simp]: "(-x:Infinitesimal) = (x:Infinitesimal)"
   354 by (simp add: Infinitesimal_def)
   354 by (simp add: Infinitesimal_def)
   355 
   355 
   650 by (blast intro: approx_sym)
   650 by (blast intro: approx_sym)
   651 
   651 
   652 (*reorientation simplification procedure: reorients (polymorphic)
   652 (*reorientation simplification procedure: reorients (polymorphic)
   653   0 = x, 1 = x, nnn = x provided x isn't 0, 1 or a numeral.*)
   653   0 = x, 1 = x, nnn = x provided x isn't 0, 1 or a numeral.*)
   654 simproc_setup approx_reorient_simproc
   654 simproc_setup approx_reorient_simproc
   655   ("0 @= x" | "1 @= y" | "number_of w @= z") =
   655   ("0 @= x" | "1 @= y" | "numeral w @= z" | "neg_numeral w @= r") =
   656 {*
   656 {*
   657   let val rule = @{thm approx_reorient} RS eq_reflection
   657   let val rule = @{thm approx_reorient} RS eq_reflection
   658       fun proc phi ss ct = case term_of ct of
   658       fun proc phi ss ct = case term_of ct of
   659           _ $ t $ u => if can HOLogic.dest_number u then NONE
   659           _ $ t $ u => if can HOLogic.dest_number u then NONE
   660             else if can HOLogic.dest_number t then SOME rule else NONE
   660             else if can HOLogic.dest_number t then SOME rule else NONE
   955 
   955 
   956 lemma star_of_HFinite_diff_Infinitesimal:
   956 lemma star_of_HFinite_diff_Infinitesimal:
   957      "x \<noteq> 0 ==> star_of x \<in> HFinite - Infinitesimal"
   957      "x \<noteq> 0 ==> star_of x \<in> HFinite - Infinitesimal"
   958 by simp
   958 by simp
   959 
   959 
   960 lemma number_of_not_Infinitesimal [simp]:
   960 lemma numeral_not_Infinitesimal [simp]:
   961      "number_of w \<noteq> (0::hypreal) ==> (number_of w :: hypreal) \<notin> Infinitesimal"
   961      "numeral w \<noteq> (0::hypreal) ==> (numeral w :: hypreal) \<notin> Infinitesimal"
   962 by (fast dest: Reals_number_of [THEN SReal_Infinitesimal_zero])
   962 by (fast dest: Reals_numeral [THEN SReal_Infinitesimal_zero])
   963 
   963 
   964 (*again: 1 is a special case, but not 0 this time*)
   964 (*again: 1 is a special case, but not 0 this time*)
   965 lemma one_not_Infinitesimal [simp]:
   965 lemma one_not_Infinitesimal [simp]:
   966   "(1::'a::{real_normed_vector,zero_neq_one} star) \<notin> Infinitesimal"
   966   "(1::'a::{real_normed_vector,zero_neq_one} star) \<notin> Infinitesimal"
   967 apply (simp only: star_one_def star_of_Infinitesimal_iff_0)
   967 apply (simp only: star_one_def star_of_Infinitesimal_iff_0)
  1022 apply (drule (1) Reals_diff)
  1022 apply (drule (1) Reals_diff)
  1023 apply (drule (1) SReal_Infinitesimal_zero)
  1023 apply (drule (1) SReal_Infinitesimal_zero)
  1024 apply simp
  1024 apply simp
  1025 done
  1025 done
  1026 
  1026 
  1027 lemma number_of_approx_iff [simp]:
  1027 lemma numeral_approx_iff [simp]:
  1028      "(number_of v @= (number_of w :: 'a::{number,real_normed_vector} star)) =
  1028      "(numeral v @= (numeral w :: 'a::{numeral,real_normed_vector} star)) =
  1029       (number_of v = (number_of w :: 'a))"
  1029       (numeral v = (numeral w :: 'a))"
  1030 apply (unfold star_number_def)
  1030 apply (unfold star_numeral_def)
  1031 apply (rule star_of_approx_iff)
  1031 apply (rule star_of_approx_iff)
  1032 done
  1032 done
  1033 
  1033 
  1034 (*And also for 0 @= #nn and 1 @= #nn, #nn @= 0 and #nn @= 1.*)
  1034 (*And also for 0 @= #nn and 1 @= #nn, #nn @= 0 and #nn @= 1.*)
  1035 lemma [simp]:
  1035 lemma [simp]:
  1036   "(number_of w @= (0::'a::{number,real_normed_vector} star)) =
  1036   "(numeral w @= (0::'a::{numeral,real_normed_vector} star)) =
  1037    (number_of w = (0::'a))"
  1037    (numeral w = (0::'a))"
  1038   "((0::'a::{number,real_normed_vector} star) @= number_of w) =
  1038   "((0::'a::{numeral,real_normed_vector} star) @= numeral w) =
  1039    (number_of w = (0::'a))"
  1039    (numeral w = (0::'a))"
  1040   "(number_of w @= (1::'b::{number,one,real_normed_vector} star)) =
  1040   "(numeral w @= (1::'b::{numeral,one,real_normed_vector} star)) =
  1041    (number_of w = (1::'b))"
  1041    (numeral w = (1::'b))"
  1042   "((1::'b::{number,one,real_normed_vector} star) @= number_of w) =
  1042   "((1::'b::{numeral,one,real_normed_vector} star) @= numeral w) =
  1043    (number_of w = (1::'b))"
  1043    (numeral w = (1::'b))"
  1044   "~ (0 @= (1::'c::{zero_neq_one,real_normed_vector} star))"
  1044   "~ (0 @= (1::'c::{zero_neq_one,real_normed_vector} star))"
  1045   "~ (1 @= (0::'c::{zero_neq_one,real_normed_vector} star))"
  1045   "~ (1 @= (0::'c::{zero_neq_one,real_normed_vector} star))"
  1046 apply (unfold star_number_def star_zero_def star_one_def)
  1046 apply (unfold star_numeral_def star_zero_def star_one_def)
  1047 apply (unfold star_of_approx_iff)
  1047 apply (unfold star_of_approx_iff)
  1048 by (auto intro: sym)
  1048 by (auto intro: sym)
  1049 
  1049 
  1050 lemma star_of_approx_number_of_iff [simp]:
  1050 lemma star_of_approx_numeral_iff [simp]:
  1051      "(star_of k @= number_of w) = (k = number_of w)"
  1051      "(star_of k @= numeral w) = (k = numeral w)"
  1052 by (subst star_of_approx_iff [symmetric], auto)
  1052 by (subst star_of_approx_iff [symmetric], auto)
  1053 
  1053 
  1054 lemma star_of_approx_zero_iff [simp]: "(star_of k @= 0) = (k = 0)"
  1054 lemma star_of_approx_zero_iff [simp]: "(star_of k @= 0) = (k = 0)"
  1055 by (simp_all add: star_of_approx_iff [symmetric])
  1055 by (simp_all add: star_of_approx_iff [symmetric])
  1056 
  1056 
  1841 by (blast dest!: st_approx_self [THEN approx_sym] bex_Infinitesimal_iff2 [THEN iffD2])
  1841 by (blast dest!: st_approx_self [THEN approx_sym] bex_Infinitesimal_iff2 [THEN iffD2])
  1842 
  1842 
  1843 lemma st_add: "\<lbrakk>x \<in> HFinite; y \<in> HFinite\<rbrakk> \<Longrightarrow> st (x + y) = st x + st y"
  1843 lemma st_add: "\<lbrakk>x \<in> HFinite; y \<in> HFinite\<rbrakk> \<Longrightarrow> st (x + y) = st x + st y"
  1844 by (simp add: st_unique st_SReal st_approx_self approx_add)
  1844 by (simp add: st_unique st_SReal st_approx_self approx_add)
  1845 
  1845 
  1846 lemma st_number_of [simp]: "st (number_of w) = number_of w"
  1846 lemma st_numeral [simp]: "st (numeral w) = numeral w"
  1847 by (rule Reals_number_of [THEN st_SReal_eq])
  1847 by (rule Reals_numeral [THEN st_SReal_eq])
       
  1848 
       
  1849 lemma st_neg_numeral [simp]: "st (neg_numeral w) = neg_numeral w"
       
  1850 by (rule Reals_neg_numeral [THEN st_SReal_eq])
  1848 
  1851 
  1849 lemma st_0 [simp]: "st 0 = 0"
  1852 lemma st_0 [simp]: "st 0 = 0"
  1850 by (simp add: st_SReal_eq)
  1853 by (simp add: st_SReal_eq)
  1851 
  1854 
  1852 lemma st_1 [simp]: "st 1 = 1"
  1855 lemma st_1 [simp]: "st 1 = 1"