src/HOL/Hyperreal/NSA.thy
author paulson
Tue, 10 Feb 2004 12:02:11 +0100
changeset 14378 69c4d5997669
parent 14371 c78c7da09519
child 14387 e96d5c42c4b0
permissions -rw-r--r--
generic of_nat and of_int functions, and generalization of iszero and neg
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10751
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
     1
(*  Title       : NSA.thy
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
     2
    Author      : Jacques D. Fleuriot
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
     3
    Copyright   : 1998  University of Cambridge
14370
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
     4
*)
10751
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
     5
14370
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
     6
header{*Infinite Numbers, Infinitesimals, Infinitely Close Relation*}
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
     7
14371
c78c7da09519 Conversion of HyperNat to Isar format and its declaration as a semiring
paulson
parents: 14370
diff changeset
     8
theory NSA = HyperArith + RComplete:
10751
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
     9
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
    10
constdefs
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
    11
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
    12
  Infinitesimal  :: "hypreal set"
14370
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    13
   "Infinitesimal == {x. \<forall>r \<in> Reals. 0 < r --> abs x < r}"
10751
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
    14
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
    15
  HFinite :: "hypreal set"
14370
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    16
   "HFinite == {x. \<exists>r \<in> Reals. abs x < r}"
10751
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
    17
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
    18
  HInfinite :: "hypreal set"
14370
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    19
   "HInfinite == {x. \<forall>r \<in> Reals. r < abs x}"
10751
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
    20
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
    21
  (* standard part map *)
14370
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    22
  st        :: "hypreal => hypreal"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    23
   "st           == (%x. @r. x \<in> HFinite & r \<in> Reals & r @= x)"
10751
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
    24
14370
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    25
  monad     :: "hypreal => hypreal set"
10751
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
    26
   "monad x      == {y. x @= y}"
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
    27
14370
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    28
  galaxy    :: "hypreal => hypreal set"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    29
   "galaxy x     == {y. (x + -y) \<in> HFinite}"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    30
10751
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
    31
  (* infinitely close *)
10919
144ede948e58 renamings: real_of_nat, real_of_int -> (overloaded) real
paulson
parents: 10751
diff changeset
    32
  approx :: "[hypreal, hypreal] => bool"    (infixl "@=" 50)
14370
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    33
   "x @= y       == (x + -y) \<in> Infinitesimal"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    34
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    35
14378
69c4d5997669 generic of_nat and of_int functions, and generalization of iszero
paulson
parents: 14371
diff changeset
    36
defs (overloaded)
14370
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    37
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    38
   (*standard real numbers as a subset of the hyperreals*)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    39
   SReal_def:      "Reals == {x. \<exists>r. x = hypreal_of_real r}"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    40
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    41
syntax (xsymbols)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    42
    approx :: "[hypreal, hypreal] => bool"    (infixl "\<approx>" 50)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    43
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    44
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    45
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    46
(*--------------------------------------------------------------------
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    47
     Closure laws for members of (embedded) set standard real Reals
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    48
 --------------------------------------------------------------------*)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    49
14378
69c4d5997669 generic of_nat and of_int functions, and generalization of iszero
paulson
parents: 14371
diff changeset
    50
lemma SReal_add [simp]:
69c4d5997669 generic of_nat and of_int functions, and generalization of iszero
paulson
parents: 14371
diff changeset
    51
     "[| (x::hypreal) \<in> Reals; y \<in> Reals |] ==> x + y \<in> Reals"
14370
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    52
apply (auto simp add: SReal_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    53
apply (rule_tac x = "r + ra" in exI, simp)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    54
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    55
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    56
lemma SReal_mult: "[| (x::hypreal) \<in> Reals; y \<in> Reals |] ==> x * y \<in> Reals"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    57
apply (simp add: SReal_def, safe)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    58
apply (rule_tac x = "r * ra" in exI)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    59
apply (simp (no_asm) add: hypreal_of_real_mult)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    60
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    61
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    62
lemma SReal_inverse: "(x::hypreal) \<in> Reals ==> inverse x \<in> Reals"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    63
apply (simp add: SReal_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    64
apply (blast intro: hypreal_of_real_inverse [symmetric])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    65
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    66
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    67
lemma SReal_divide: "[| (x::hypreal) \<in> Reals;  y \<in> Reals |] ==> x/y \<in> Reals"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    68
apply (simp (no_asm_simp) add: SReal_mult SReal_inverse hypreal_divide_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    69
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    70
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    71
lemma SReal_minus: "(x::hypreal) \<in> Reals ==> -x \<in> Reals"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    72
apply (simp add: SReal_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    73
apply (blast intro: hypreal_of_real_minus [symmetric])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    74
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    75
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    76
lemma SReal_minus_iff: "(-x \<in> Reals) = ((x::hypreal) \<in> Reals)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    77
apply auto
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    78
apply (erule_tac [2] SReal_minus)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    79
apply (drule SReal_minus, auto)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    80
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    81
declare SReal_minus_iff [simp]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    82
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    83
lemma SReal_add_cancel: "[| (x::hypreal) + y \<in> Reals; y \<in> Reals |] ==> x \<in> Reals"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    84
apply (drule_tac x = y in SReal_minus)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    85
apply (drule SReal_add, assumption, auto)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    86
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    87
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    88
lemma SReal_hrabs: "(x::hypreal) \<in> Reals ==> abs x \<in> Reals"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    89
apply (simp add: SReal_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    90
apply (auto simp add: hypreal_of_real_hrabs)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    91
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    92
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    93
lemma SReal_hypreal_of_real: "hypreal_of_real x \<in> Reals"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    94
by (simp add: SReal_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    95
declare SReal_hypreal_of_real [simp]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    96
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    97
lemma SReal_number_of: "(number_of w ::hypreal) \<in> Reals"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    98
apply (unfold hypreal_number_of_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
    99
apply (rule SReal_hypreal_of_real)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   100
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   101
declare SReal_number_of [simp]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   102
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   103
(** As always with numerals, 0 and 1 are special cases **)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   104
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   105
lemma Reals_0: "(0::hypreal) \<in> Reals"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   106
apply (subst hypreal_numeral_0_eq_0 [symmetric])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   107
apply (rule SReal_number_of)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   108
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   109
declare Reals_0 [simp]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   110
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   111
lemma Reals_1: "(1::hypreal) \<in> Reals"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   112
apply (subst hypreal_numeral_1_eq_1 [symmetric])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   113
apply (rule SReal_number_of)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   114
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   115
declare Reals_1 [simp]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   116
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   117
lemma SReal_divide_number_of: "r \<in> Reals ==> r/(number_of w::hypreal) \<in> Reals"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   118
apply (unfold hypreal_divide_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   119
apply (blast intro!: SReal_number_of SReal_mult SReal_inverse)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   120
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   121
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   122
(* Infinitesimal epsilon not in Reals *)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   123
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   124
lemma SReal_epsilon_not_mem: "epsilon \<notin> Reals"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   125
apply (simp add: SReal_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   126
apply (auto simp add: hypreal_of_real_not_eq_epsilon [THEN not_sym])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   127
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   128
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   129
lemma SReal_omega_not_mem: "omega \<notin> Reals"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   130
apply (simp add: SReal_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   131
apply (auto simp add: hypreal_of_real_not_eq_omega [THEN not_sym])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   132
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   133
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   134
lemma SReal_UNIV_real: "{x. hypreal_of_real x \<in> Reals} = (UNIV::real set)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   135
by (simp add: SReal_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   136
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   137
lemma SReal_iff: "(x \<in> Reals) = (\<exists>y. x = hypreal_of_real y)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   138
by (simp add: SReal_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   139
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   140
lemma hypreal_of_real_image: "hypreal_of_real `(UNIV::real set) = Reals"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   141
by (auto simp add: SReal_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   142
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   143
lemma inv_hypreal_of_real_image: "inv hypreal_of_real ` Reals = UNIV"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   144
apply (auto simp add: SReal_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   145
apply (rule inj_hypreal_of_real [THEN inv_f_f, THEN subst], blast)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   146
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   147
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   148
lemma SReal_hypreal_of_real_image:
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   149
      "[| \<exists>x. x: P; P <= Reals |] ==> \<exists>Q. P = hypreal_of_real ` Q"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   150
apply (simp add: SReal_def, blast)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   151
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   152
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   153
lemma SReal_dense: "[| (x::hypreal) \<in> Reals; y \<in> Reals;  x<y |] ==> \<exists>r \<in> Reals. x<r & r<y"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   154
apply (auto simp add: SReal_iff)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   155
apply (drule real_dense, safe)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   156
apply (rule_tac x = "hypreal_of_real r" in bexI, auto)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   157
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   158
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   159
(*------------------------------------------------------------------
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   160
                   Completeness of Reals
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   161
 ------------------------------------------------------------------*)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   162
lemma SReal_sup_lemma: "P <= Reals ==> ((\<exists>x \<in> P. y < x) =
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   163
      (\<exists>X. hypreal_of_real X \<in> P & y < hypreal_of_real X))"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   164
by (blast dest!: SReal_iff [THEN iffD1])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   165
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   166
lemma SReal_sup_lemma2:
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   167
     "[| P <= Reals; \<exists>x. x \<in> P; \<exists>y \<in> Reals. \<forall>x \<in> P. x < y |]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   168
      ==> (\<exists>X. X \<in> {w. hypreal_of_real w \<in> P}) &
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   169
          (\<exists>Y. \<forall>X \<in> {w. hypreal_of_real w \<in> P}. X < Y)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   170
apply (rule conjI)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   171
apply (fast dest!: SReal_iff [THEN iffD1])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   172
apply (auto, frule subsetD, assumption)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   173
apply (drule SReal_iff [THEN iffD1])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   174
apply (auto, rule_tac x = ya in exI, auto)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   175
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   176
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   177
(*------------------------------------------------------
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   178
    lifting of ub and property of lub
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   179
 -------------------------------------------------------*)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   180
lemma hypreal_of_real_isUb_iff:
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   181
      "(isUb (Reals) (hypreal_of_real ` Q) (hypreal_of_real Y)) =
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   182
       (isUb (UNIV :: real set) Q Y)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   183
apply (simp add: isUb_def setle_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   184
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   185
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   186
lemma hypreal_of_real_isLub1:
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   187
     "isLub Reals (hypreal_of_real ` Q) (hypreal_of_real Y)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   188
      ==> isLub (UNIV :: real set) Q Y"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   189
apply (simp add: isLub_def leastP_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   190
apply (auto intro: hypreal_of_real_isUb_iff [THEN iffD2]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   191
            simp add: hypreal_of_real_isUb_iff setge_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   192
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   193
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   194
lemma hypreal_of_real_isLub2:
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   195
      "isLub (UNIV :: real set) Q Y
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   196
       ==> isLub Reals (hypreal_of_real ` Q) (hypreal_of_real Y)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   197
apply (simp add: isLub_def leastP_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   198
apply (auto simp add: hypreal_of_real_isUb_iff setge_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   199
apply (frule_tac x2 = x in isUbD2a [THEN SReal_iff [THEN iffD1], THEN exE])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   200
 prefer 2 apply assumption
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   201
apply (drule_tac x = xa in spec)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   202
apply (auto simp add: hypreal_of_real_isUb_iff)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   203
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   204
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   205
lemma hypreal_of_real_isLub_iff: "(isLub Reals (hypreal_of_real ` Q) (hypreal_of_real Y)) =
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   206
      (isLub (UNIV :: real set) Q Y)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   207
apply (blast intro: hypreal_of_real_isLub1 hypreal_of_real_isLub2)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   208
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   209
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   210
(* lemmas *)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   211
lemma lemma_isUb_hypreal_of_real:
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   212
     "isUb Reals P Y ==> \<exists>Yo. isUb Reals P (hypreal_of_real Yo)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   213
by (auto simp add: SReal_iff isUb_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   214
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   215
lemma lemma_isLub_hypreal_of_real:
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   216
     "isLub Reals P Y ==> \<exists>Yo. isLub Reals P (hypreal_of_real Yo)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   217
by (auto simp add: isLub_def leastP_def isUb_def SReal_iff)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   218
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   219
lemma lemma_isLub_hypreal_of_real2:
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   220
     "\<exists>Yo. isLub Reals P (hypreal_of_real Yo) ==> \<exists>Y. isLub Reals P Y"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   221
by (auto simp add: isLub_def leastP_def isUb_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   222
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   223
lemma SReal_complete: "[| P <= Reals;  \<exists>x. x \<in> P;  \<exists>Y. isUb Reals P Y |]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   224
      ==> \<exists>t::hypreal. isLub Reals P t"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   225
apply (frule SReal_hypreal_of_real_image)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   226
apply (auto, drule lemma_isUb_hypreal_of_real)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   227
apply (auto intro!: reals_complete lemma_isLub_hypreal_of_real2 simp add: hypreal_of_real_isLub_iff hypreal_of_real_isUb_iff)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   228
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   229
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   230
(*--------------------------------------------------------------------
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   231
        Set of finite elements is a subring of the extended reals
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   232
 --------------------------------------------------------------------*)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   233
lemma HFinite_add: "[|x \<in> HFinite; y \<in> HFinite|] ==> (x+y) \<in> HFinite"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   234
apply (simp add: HFinite_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   235
apply (blast intro!: SReal_add hrabs_add_less)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   236
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   237
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   238
lemma HFinite_mult: "[|x \<in> HFinite; y \<in> HFinite|] ==> x*y \<in> HFinite"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   239
apply (simp add: HFinite_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   240
apply (blast intro!: SReal_mult abs_mult_less)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   241
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   242
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   243
lemma HFinite_minus_iff: "(-x \<in> HFinite) = (x \<in> HFinite)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   244
by (simp add: HFinite_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   245
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   246
lemma SReal_subset_HFinite: "Reals <= HFinite"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   247
apply (auto simp add: SReal_def HFinite_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   248
apply (rule_tac x = "1 + abs (hypreal_of_real r) " in exI)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   249
apply (auto simp add: hypreal_of_real_hrabs)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   250
apply (rule_tac x = "1 + abs r" in exI, simp)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   251
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   252
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   253
lemma HFinite_hypreal_of_real [simp]: "hypreal_of_real x \<in> HFinite"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   254
by (auto intro: SReal_subset_HFinite [THEN subsetD])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   255
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   256
lemma HFiniteD: "x \<in> HFinite ==> \<exists>t \<in> Reals. abs x < t"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   257
by (simp add: HFinite_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   258
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   259
lemma HFinite_hrabs_iff: "(abs x \<in> HFinite) = (x \<in> HFinite)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   260
by (simp add: HFinite_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   261
declare HFinite_hrabs_iff [iff]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   262
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   263
lemma HFinite_number_of: "number_of w \<in> HFinite"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   264
by (rule SReal_number_of [THEN SReal_subset_HFinite [THEN subsetD]])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   265
declare HFinite_number_of [simp]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   266
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   267
(** As always with numerals, 0 and 1 are special cases **)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   268
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   269
lemma HFinite_0: "0 \<in> HFinite"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   270
apply (subst hypreal_numeral_0_eq_0 [symmetric])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   271
apply (rule HFinite_number_of)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   272
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   273
declare HFinite_0 [simp]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   274
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   275
lemma HFinite_1: "1 \<in> HFinite"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   276
apply (subst hypreal_numeral_1_eq_1 [symmetric])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   277
apply (rule HFinite_number_of)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   278
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   279
declare HFinite_1 [simp]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   280
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   281
lemma HFinite_bounded: "[|x \<in> HFinite; y <= x; 0 <= y |] ==> y \<in> HFinite"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   282
apply (case_tac "x <= 0")
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   283
apply (drule_tac y = x in order_trans)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   284
apply (drule_tac [2] hypreal_le_anti_sym)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   285
apply (auto simp add: linorder_not_le)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   286
apply (auto intro: order_le_less_trans simp add: abs_if HFinite_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   287
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   288
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   289
(*------------------------------------------------------------------
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   290
       Set of infinitesimals is a subring of the hyperreals
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   291
 ------------------------------------------------------------------*)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   292
lemma InfinitesimalD:
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   293
      "x \<in> Infinitesimal ==> \<forall>r \<in> Reals. 0 < r --> abs x < r"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   294
apply (simp add: Infinitesimal_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   295
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   296
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   297
lemma Infinitesimal_zero: "0 \<in> Infinitesimal"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   298
by (simp add: Infinitesimal_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   299
declare Infinitesimal_zero [iff]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   300
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   301
lemma hypreal_sum_of_halves: "x/(2::hypreal) + x/(2::hypreal) = x"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   302
by auto
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   303
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   304
lemma hypreal_half_gt_zero: "0 < r ==> 0 < r/(2::hypreal)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   305
by auto
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   306
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   307
lemma Infinitesimal_add:
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   308
     "[| x \<in> Infinitesimal; y \<in> Infinitesimal |] ==> (x+y) \<in> Infinitesimal"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   309
apply (auto simp add: Infinitesimal_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   310
apply (rule hypreal_sum_of_halves [THEN subst])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   311
apply (drule hypreal_half_gt_zero)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   312
apply (blast intro: hrabs_add_less hrabs_add_less SReal_divide_number_of)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   313
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   314
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   315
lemma Infinitesimal_minus_iff: "(-x:Infinitesimal) = (x:Infinitesimal)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   316
by (simp add: Infinitesimal_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   317
declare Infinitesimal_minus_iff [simp]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   318
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   319
lemma Infinitesimal_diff: "[| x \<in> Infinitesimal;  y \<in> Infinitesimal |] ==> x-y \<in> Infinitesimal"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   320
by (simp add: hypreal_diff_def Infinitesimal_add)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   321
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   322
lemma Infinitesimal_mult:
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   323
     "[| x \<in> Infinitesimal; y \<in> Infinitesimal |] ==> (x * y) \<in> Infinitesimal"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   324
apply (auto simp add: Infinitesimal_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   325
apply (case_tac "y=0")
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   326
apply (cut_tac [2] a = "abs x" and b = 1 and c = "abs y" and d = r in mult_strict_mono, auto)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   327
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   328
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   329
lemma Infinitesimal_HFinite_mult: "[| x \<in> Infinitesimal; y \<in> HFinite |] ==> (x * y) \<in> Infinitesimal"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   330
apply (auto dest!: HFiniteD simp add: Infinitesimal_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   331
apply (frule hrabs_less_gt_zero)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   332
apply (drule_tac x = "r/t" in bspec)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   333
apply (blast intro: SReal_divide)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   334
apply (simp add: zero_less_divide_iff)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   335
apply (case_tac "x=0 | y=0")
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   336
apply (cut_tac [2] a = "abs x" and b = "r/t" and c = "abs y" in mult_strict_mono)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   337
apply (auto simp add: zero_less_divide_iff)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   338
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   339
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   340
lemma Infinitesimal_HFinite_mult2: "[| x \<in> Infinitesimal; y \<in> HFinite |] ==> (y * x) \<in> Infinitesimal"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   341
by (auto dest: Infinitesimal_HFinite_mult simp add: hypreal_mult_commute)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   342
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   343
(*** rather long proof ***)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   344
lemma HInfinite_inverse_Infinitesimal:
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   345
     "x \<in> HInfinite ==> inverse x: Infinitesimal"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   346
apply (auto simp add: HInfinite_def Infinitesimal_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   347
apply (erule_tac x = "inverse r" in ballE)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   348
apply (frule_tac a1 = r and z = "abs x" in positive_imp_inverse_positive [THEN order_less_trans], assumption)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   349
apply (drule inverse_inverse_eq [symmetric, THEN subst])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   350
apply (rule inverse_less_iff_less [THEN iffD1])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   351
apply (auto simp add: SReal_inverse)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   352
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   353
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   354
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   355
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   356
lemma HInfinite_mult: "[|x \<in> HInfinite;y \<in> HInfinite|] ==> (x*y) \<in> HInfinite"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   357
apply (simp add: HInfinite_def, auto)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   358
apply (erule_tac x = 1 in ballE)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   359
apply (erule_tac x = r in ballE)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   360
apply (case_tac "y=0")
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   361
apply (cut_tac [2] c = 1 and d = "abs x" and a = r and b = "abs y" in mult_strict_mono)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   362
apply (auto simp add: mult_ac)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   363
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   364
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   365
lemma HInfinite_add_ge_zero:
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   366
      "[|x \<in> HInfinite; 0 <= y; 0 <= x|] ==> (x + y): HInfinite"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   367
by (auto intro!: hypreal_add_zero_less_le_mono 
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   368
       simp add: abs_if hypreal_add_commute hypreal_le_add_order HInfinite_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   369
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   370
lemma HInfinite_add_ge_zero2: "[|x \<in> HInfinite; 0 <= y; 0 <= x|] ==> (y + x): HInfinite"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   371
by (auto intro!: HInfinite_add_ge_zero simp add: hypreal_add_commute)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   372
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   373
lemma HInfinite_add_gt_zero: "[|x \<in> HInfinite; 0 < y; 0 < x|] ==> (x + y): HInfinite"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   374
by (blast intro: HInfinite_add_ge_zero order_less_imp_le)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   375
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   376
lemma HInfinite_minus_iff: "(-x \<in> HInfinite) = (x \<in> HInfinite)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   377
by (simp add: HInfinite_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   378
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   379
lemma HInfinite_add_le_zero: "[|x \<in> HInfinite; y <= 0; x <= 0|] ==> (x + y): HInfinite"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   380
apply (drule HInfinite_minus_iff [THEN iffD2])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   381
apply (rule HInfinite_minus_iff [THEN iffD1])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   382
apply (auto intro: HInfinite_add_ge_zero)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   383
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   384
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   385
lemma HInfinite_add_lt_zero: "[|x \<in> HInfinite; y < 0; x < 0|] ==> (x + y): HInfinite"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   386
by (blast intro: HInfinite_add_le_zero order_less_imp_le)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   387
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   388
lemma HFinite_sum_squares: "[|a: HFinite; b: HFinite; c: HFinite|]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   389
      ==> a*a + b*b + c*c \<in> HFinite"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   390
apply (auto intro: HFinite_mult HFinite_add)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   391
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   392
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   393
lemma not_Infinitesimal_not_zero: "x \<notin> Infinitesimal ==> x \<noteq> 0"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   394
by auto
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   395
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   396
lemma not_Infinitesimal_not_zero2: "x \<in> HFinite - Infinitesimal ==> x \<noteq> 0"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   397
by auto
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   398
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   399
lemma Infinitesimal_hrabs_iff: "(abs x \<in> Infinitesimal) = (x \<in> Infinitesimal)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   400
by (auto simp add: hrabs_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   401
declare Infinitesimal_hrabs_iff [iff]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   402
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   403
lemma HFinite_diff_Infinitesimal_hrabs: "x \<in> HFinite - Infinitesimal ==> abs x \<in> HFinite - Infinitesimal"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   404
by blast
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   405
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   406
lemma hrabs_less_Infinitesimal:
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   407
      "[| e \<in> Infinitesimal; abs x < e |] ==> x \<in> Infinitesimal"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   408
apply (auto simp add: Infinitesimal_def abs_less_iff)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   409
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   410
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   411
lemma hrabs_le_Infinitesimal: "[| e \<in> Infinitesimal; abs x <= e |] ==> x \<in> Infinitesimal"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   412
by (blast dest: order_le_imp_less_or_eq intro: hrabs_less_Infinitesimal)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   413
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   414
lemma Infinitesimal_interval:
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   415
      "[| e \<in> Infinitesimal; e' \<in> Infinitesimal; e' < x ; x < e |] 
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   416
       ==> x \<in> Infinitesimal"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   417
apply (auto simp add: Infinitesimal_def abs_less_iff)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   418
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   419
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   420
lemma Infinitesimal_interval2: "[| e \<in> Infinitesimal; e' \<in> Infinitesimal;
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   421
         e' <= x ; x <= e |] ==> x \<in> Infinitesimal"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   422
apply (auto intro: Infinitesimal_interval simp add: order_le_less)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   423
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   424
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   425
lemma not_Infinitesimal_mult:
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   426
     "[| x \<notin> Infinitesimal;  y \<notin> Infinitesimal|] ==> (x*y) \<notin>Infinitesimal"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   427
apply (unfold Infinitesimal_def, clarify)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   428
apply (simp add: linorder_not_less)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   429
apply (erule_tac x = "r*ra" in ballE)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   430
prefer 2 apply (fast intro: SReal_mult)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   431
apply (auto simp add: zero_less_mult_iff)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   432
apply (cut_tac c = ra and d = "abs y" and a = r and b = "abs x" in mult_mono, auto)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   433
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   434
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   435
lemma Infinitesimal_mult_disj: "x*y \<in> Infinitesimal ==> x \<in> Infinitesimal | y \<in> Infinitesimal"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   436
apply (rule ccontr)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   437
apply (drule de_Morgan_disj [THEN iffD1])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   438
apply (fast dest: not_Infinitesimal_mult)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   439
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   440
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   441
lemma HFinite_Infinitesimal_not_zero: "x \<in> HFinite-Infinitesimal ==> x \<noteq> 0"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   442
by blast
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   443
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   444
lemma HFinite_Infinitesimal_diff_mult: "[| x \<in> HFinite - Infinitesimal;
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   445
                   y \<in> HFinite - Infinitesimal
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   446
                |] ==> (x*y) \<in> HFinite - Infinitesimal"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   447
apply clarify
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   448
apply (blast dest: HFinite_mult not_Infinitesimal_mult)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   449
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   450
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   451
lemma Infinitesimal_subset_HFinite:
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   452
      "Infinitesimal <= HFinite"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   453
apply (simp add: Infinitesimal_def HFinite_def, auto)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   454
apply (rule_tac x = 1 in bexI, auto)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   455
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   456
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   457
lemma Infinitesimal_hypreal_of_real_mult: "x \<in> Infinitesimal ==> x * hypreal_of_real r \<in> Infinitesimal"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   458
by (erule HFinite_hypreal_of_real [THEN [2] Infinitesimal_HFinite_mult])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   459
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   460
lemma Infinitesimal_hypreal_of_real_mult2: "x \<in> Infinitesimal ==> hypreal_of_real r * x \<in> Infinitesimal"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   461
by (erule HFinite_hypreal_of_real [THEN [2] Infinitesimal_HFinite_mult2])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   462
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   463
(*----------------------------------------------------------------------
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   464
                   Infinitely close relation @=
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   465
 ----------------------------------------------------------------------*)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   466
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   467
lemma mem_infmal_iff: "(x \<in> Infinitesimal) = (x @= 0)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   468
by (simp add: Infinitesimal_def approx_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   469
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   470
lemma approx_minus_iff: " (x @= y) = (x + -y @= 0)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   471
by (simp add: approx_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   472
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   473
lemma approx_minus_iff2: " (x @= y) = (-y + x @= 0)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   474
by (simp add: approx_def hypreal_add_commute)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   475
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   476
lemma approx_refl: "x @= x"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   477
by (simp add: approx_def Infinitesimal_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   478
declare approx_refl [iff]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   479
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   480
lemma approx_sym: "x @= y ==> y @= x"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   481
apply (simp add: approx_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   482
apply (rule hypreal_minus_distrib1 [THEN subst])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   483
apply (erule Infinitesimal_minus_iff [THEN iffD2])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   484
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   485
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   486
lemma approx_trans: "[| x @= y; y @= z |] ==> x @= z"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   487
apply (simp add: approx_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   488
apply (drule Infinitesimal_add, assumption, auto)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   489
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   490
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   491
lemma approx_trans2: "[| r @= x; s @= x |] ==> r @= s"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   492
by (blast intro: approx_sym approx_trans)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   493
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   494
lemma approx_trans3: "[| x @= r; x @= s|] ==> r @= s"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   495
by (blast intro: approx_sym approx_trans)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   496
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   497
lemma number_of_approx_reorient: "(number_of w @= x) = (x @= number_of w)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   498
by (blast intro: approx_sym)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   499
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   500
lemma zero_approx_reorient: "(0 @= x) = (x @= 0)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   501
by (blast intro: approx_sym)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   502
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   503
lemma one_approx_reorient: "(1 @= x) = (x @= 1)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   504
by (blast intro: approx_sym)
10751
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
   505
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
   506
14370
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   507
ML
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   508
{*
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   509
val SReal_add = thm "SReal_add";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   510
val SReal_mult = thm "SReal_mult";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   511
val SReal_inverse = thm "SReal_inverse";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   512
val SReal_divide = thm "SReal_divide";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   513
val SReal_minus = thm "SReal_minus";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   514
val SReal_minus_iff = thm "SReal_minus_iff";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   515
val SReal_add_cancel = thm "SReal_add_cancel";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   516
val SReal_hrabs = thm "SReal_hrabs";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   517
val SReal_hypreal_of_real = thm "SReal_hypreal_of_real";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   518
val SReal_number_of = thm "SReal_number_of";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   519
val Reals_0 = thm "Reals_0";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   520
val Reals_1 = thm "Reals_1";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   521
val SReal_divide_number_of = thm "SReal_divide_number_of";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   522
val SReal_epsilon_not_mem = thm "SReal_epsilon_not_mem";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   523
val SReal_omega_not_mem = thm "SReal_omega_not_mem";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   524
val SReal_UNIV_real = thm "SReal_UNIV_real";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   525
val SReal_iff = thm "SReal_iff";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   526
val hypreal_of_real_image = thm "hypreal_of_real_image";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   527
val inv_hypreal_of_real_image = thm "inv_hypreal_of_real_image";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   528
val SReal_hypreal_of_real_image = thm "SReal_hypreal_of_real_image";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   529
val SReal_dense = thm "SReal_dense";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   530
val SReal_sup_lemma = thm "SReal_sup_lemma";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   531
val SReal_sup_lemma2 = thm "SReal_sup_lemma2";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   532
val hypreal_of_real_isUb_iff = thm "hypreal_of_real_isUb_iff";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   533
val hypreal_of_real_isLub1 = thm "hypreal_of_real_isLub1";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   534
val hypreal_of_real_isLub2 = thm "hypreal_of_real_isLub2";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   535
val hypreal_of_real_isLub_iff = thm "hypreal_of_real_isLub_iff";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   536
val lemma_isUb_hypreal_of_real = thm "lemma_isUb_hypreal_of_real";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   537
val lemma_isLub_hypreal_of_real = thm "lemma_isLub_hypreal_of_real";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   538
val lemma_isLub_hypreal_of_real2 = thm "lemma_isLub_hypreal_of_real2";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   539
val SReal_complete = thm "SReal_complete";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   540
val HFinite_add = thm "HFinite_add";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   541
val HFinite_mult = thm "HFinite_mult";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   542
val HFinite_minus_iff = thm "HFinite_minus_iff";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   543
val SReal_subset_HFinite = thm "SReal_subset_HFinite";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   544
val HFinite_hypreal_of_real = thm "HFinite_hypreal_of_real";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   545
val HFiniteD = thm "HFiniteD";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   546
val HFinite_hrabs_iff = thm "HFinite_hrabs_iff";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   547
val HFinite_number_of = thm "HFinite_number_of";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   548
val HFinite_0 = thm "HFinite_0";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   549
val HFinite_1 = thm "HFinite_1";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   550
val HFinite_bounded = thm "HFinite_bounded";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   551
val InfinitesimalD = thm "InfinitesimalD";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   552
val Infinitesimal_zero = thm "Infinitesimal_zero";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   553
val hypreal_sum_of_halves = thm "hypreal_sum_of_halves";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   554
val hypreal_half_gt_zero = thm "hypreal_half_gt_zero";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   555
val Infinitesimal_add = thm "Infinitesimal_add";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   556
val Infinitesimal_minus_iff = thm "Infinitesimal_minus_iff";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   557
val Infinitesimal_diff = thm "Infinitesimal_diff";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   558
val Infinitesimal_mult = thm "Infinitesimal_mult";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   559
val Infinitesimal_HFinite_mult = thm "Infinitesimal_HFinite_mult";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   560
val Infinitesimal_HFinite_mult2 = thm "Infinitesimal_HFinite_mult2";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   561
val HInfinite_inverse_Infinitesimal = thm "HInfinite_inverse_Infinitesimal";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   562
val HInfinite_mult = thm "HInfinite_mult";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   563
val HInfinite_add_ge_zero = thm "HInfinite_add_ge_zero";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   564
val HInfinite_add_ge_zero2 = thm "HInfinite_add_ge_zero2";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   565
val HInfinite_add_gt_zero = thm "HInfinite_add_gt_zero";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   566
val HInfinite_minus_iff = thm "HInfinite_minus_iff";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   567
val HInfinite_add_le_zero = thm "HInfinite_add_le_zero";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   568
val HInfinite_add_lt_zero = thm "HInfinite_add_lt_zero";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   569
val HFinite_sum_squares = thm "HFinite_sum_squares";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   570
val not_Infinitesimal_not_zero = thm "not_Infinitesimal_not_zero";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   571
val not_Infinitesimal_not_zero2 = thm "not_Infinitesimal_not_zero2";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   572
val Infinitesimal_hrabs_iff = thm "Infinitesimal_hrabs_iff";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   573
val HFinite_diff_Infinitesimal_hrabs = thm "HFinite_diff_Infinitesimal_hrabs";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   574
val hrabs_less_Infinitesimal = thm "hrabs_less_Infinitesimal";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   575
val hrabs_le_Infinitesimal = thm "hrabs_le_Infinitesimal";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   576
val Infinitesimal_interval = thm "Infinitesimal_interval";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   577
val Infinitesimal_interval2 = thm "Infinitesimal_interval2";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   578
val not_Infinitesimal_mult = thm "not_Infinitesimal_mult";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   579
val Infinitesimal_mult_disj = thm "Infinitesimal_mult_disj";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   580
val HFinite_Infinitesimal_not_zero = thm "HFinite_Infinitesimal_not_zero";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   581
val HFinite_Infinitesimal_diff_mult = thm "HFinite_Infinitesimal_diff_mult";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   582
val Infinitesimal_subset_HFinite = thm "Infinitesimal_subset_HFinite";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   583
val Infinitesimal_hypreal_of_real_mult = thm "Infinitesimal_hypreal_of_real_mult";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   584
val Infinitesimal_hypreal_of_real_mult2 = thm "Infinitesimal_hypreal_of_real_mult2";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   585
val mem_infmal_iff = thm "mem_infmal_iff";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   586
val approx_minus_iff = thm "approx_minus_iff";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   587
val approx_minus_iff2 = thm "approx_minus_iff2";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   588
val approx_refl = thm "approx_refl";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   589
val approx_sym = thm "approx_sym";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   590
val approx_trans = thm "approx_trans";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   591
val approx_trans2 = thm "approx_trans2";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   592
val approx_trans3 = thm "approx_trans3";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   593
val number_of_approx_reorient = thm "number_of_approx_reorient";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   594
val zero_approx_reorient = thm "zero_approx_reorient";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   595
val one_approx_reorient = thm "one_approx_reorient";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   596
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   597
(*** re-orientation, following HOL/Integ/Bin.ML
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   598
     We re-orient x @=y where x is 0, 1 or a numeral, unless y is as well!
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   599
 ***)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   600
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   601
(*reorientation simprules using ==, for the following simproc*)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   602
val meta_zero_approx_reorient = zero_approx_reorient RS eq_reflection;
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   603
val meta_one_approx_reorient = one_approx_reorient RS eq_reflection;
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   604
val meta_number_of_approx_reorient = number_of_approx_reorient RS eq_reflection
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   605
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   606
(*reorientation simplification procedure: reorients (polymorphic)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   607
  0 = x, 1 = x, nnn = x provided x isn't 0, 1 or a numeral.*)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   608
fun reorient_proc sg _ (_ $ t $ u) =
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   609
  case u of
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   610
      Const("0", _) => None
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   611
    | Const("1", _) => None
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   612
    | Const("Numeral.number_of", _) $ _ => None
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   613
    | _ => Some (case t of
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   614
                Const("0", _) => meta_zero_approx_reorient
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   615
              | Const("1", _) => meta_one_approx_reorient
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   616
              | Const("Numeral.number_of", _) $ _ =>
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   617
                                 meta_number_of_approx_reorient);
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   618
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   619
val approx_reorient_simproc =
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   620
  Bin_Simprocs.prep_simproc
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   621
    ("reorient_simproc", ["0@=x", "1@=x", "number_of w @= x"], reorient_proc);
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   622
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   623
Addsimprocs [approx_reorient_simproc];
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   624
*}
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   625
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   626
lemma Infinitesimal_approx_minus: "(x-y \<in> Infinitesimal) = (x @= y)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   627
by (auto simp add: hypreal_diff_def approx_minus_iff [symmetric] mem_infmal_iff)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   628
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   629
lemma approx_monad_iff: "(x @= y) = (monad(x)=monad(y))"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   630
apply (simp add: monad_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   631
apply (auto dest: approx_sym elim!: approx_trans equalityCE)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   632
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   633
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   634
lemma Infinitesimal_approx: "[| x \<in> Infinitesimal; y \<in> Infinitesimal |] ==> x @= y"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   635
apply (simp add: mem_infmal_iff)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   636
apply (blast intro: approx_trans approx_sym)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   637
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   638
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   639
lemma approx_add: "[| a @= b; c @= d |] ==> a+c @= b+d"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   640
proof (unfold approx_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   641
  assume inf: "a + - b \<in> Infinitesimal" "c + - d \<in> Infinitesimal"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   642
  have "a + c + - (b + d) = (a + - b) + (c + - d)" by arith
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   643
  also have "... \<in> Infinitesimal" using inf by (rule Infinitesimal_add)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   644
  finally show "a + c + - (b + d) \<in> Infinitesimal" .
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   645
qed
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   646
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   647
lemma approx_minus: "a @= b ==> -a @= -b"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   648
apply (rule approx_minus_iff [THEN iffD2, THEN approx_sym])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   649
apply (drule approx_minus_iff [THEN iffD1])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   650
apply (simp (no_asm) add: hypreal_add_commute)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   651
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   652
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   653
lemma approx_minus2: "-a @= -b ==> a @= b"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   654
by (auto dest: approx_minus)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   655
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   656
lemma approx_minus_cancel: "(-a @= -b) = (a @= b)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   657
by (blast intro: approx_minus approx_minus2)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   658
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   659
declare approx_minus_cancel [simp]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   660
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   661
lemma approx_add_minus: "[| a @= b; c @= d |] ==> a + -c @= b + -d"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   662
by (blast intro!: approx_add approx_minus)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   663
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   664
lemma approx_mult1: "[| a @= b; c: HFinite|] ==> a*c @= b*c"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   665
by (simp add: approx_def Infinitesimal_HFinite_mult minus_mult_left 
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   666
              left_distrib [symmetric] 
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   667
         del: minus_mult_left [symmetric])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   668
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   669
lemma approx_mult2: "[|a @= b; c: HFinite|] ==> c*a @= c*b"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   670
apply (simp (no_asm_simp) add: approx_mult1 hypreal_mult_commute)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   671
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   672
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   673
lemma approx_mult_subst: "[|u @= v*x; x @= y; v \<in> HFinite|] ==> u @= v*y"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   674
by (blast intro: approx_mult2 approx_trans)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   675
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   676
lemma approx_mult_subst2: "[| u @= x*v; x @= y; v \<in> HFinite |] ==> u @= y*v"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   677
by (blast intro: approx_mult1 approx_trans)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   678
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   679
lemma approx_mult_subst_SReal: "[| u @= x*hypreal_of_real v; x @= y |] ==> u @= y*hypreal_of_real v"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   680
by (auto intro: approx_mult_subst2)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   681
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   682
lemma approx_eq_imp: "a = b ==> a @= b"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   683
by (simp add: approx_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   684
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   685
lemma Infinitesimal_minus_approx: "x \<in> Infinitesimal ==> -x @= x"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   686
by (blast intro: Infinitesimal_minus_iff [THEN iffD2] 
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   687
                    mem_infmal_iff [THEN iffD1] approx_trans2)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   688
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   689
lemma bex_Infinitesimal_iff: "(\<exists>y \<in> Infinitesimal. x + -z = y) = (x @= z)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   690
by (simp add: approx_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   691
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   692
lemma bex_Infinitesimal_iff2: "(\<exists>y \<in> Infinitesimal. x = z + y) = (x @= z)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   693
by (force simp add: bex_Infinitesimal_iff [symmetric])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   694
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   695
lemma Infinitesimal_add_approx: "[| y \<in> Infinitesimal; x + y = z |] ==> x @= z"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   696
apply (rule bex_Infinitesimal_iff [THEN iffD1])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   697
apply (drule Infinitesimal_minus_iff [THEN iffD2])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   698
apply (auto simp add: minus_add_distrib hypreal_add_assoc [symmetric])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   699
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   700
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   701
lemma Infinitesimal_add_approx_self: "y \<in> Infinitesimal ==> x @= x + y"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   702
apply (rule bex_Infinitesimal_iff [THEN iffD1])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   703
apply (drule Infinitesimal_minus_iff [THEN iffD2])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   704
apply (auto simp add: minus_add_distrib hypreal_add_assoc [symmetric])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   705
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   706
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   707
lemma Infinitesimal_add_approx_self2: "y \<in> Infinitesimal ==> x @= y + x"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   708
by (auto dest: Infinitesimal_add_approx_self simp add: hypreal_add_commute)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   709
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   710
lemma Infinitesimal_add_minus_approx_self: "y \<in> Infinitesimal ==> x @= x + -y"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   711
by (blast intro!: Infinitesimal_add_approx_self Infinitesimal_minus_iff [THEN iffD2])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   712
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   713
lemma Infinitesimal_add_cancel: "[| y \<in> Infinitesimal; x+y @= z|] ==> x @= z"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   714
apply (drule_tac x = x in Infinitesimal_add_approx_self [THEN approx_sym])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   715
apply (erule approx_trans3 [THEN approx_sym], assumption)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   716
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   717
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   718
lemma Infinitesimal_add_right_cancel: "[| y \<in> Infinitesimal; x @= z + y|] ==> x @= z"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   719
apply (drule_tac x = z in Infinitesimal_add_approx_self2 [THEN approx_sym])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   720
apply (erule approx_trans3 [THEN approx_sym])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   721
apply (simp add: hypreal_add_commute)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   722
apply (erule approx_sym)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   723
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   724
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   725
lemma approx_add_left_cancel: "d + b  @= d + c ==> b @= c"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   726
apply (drule approx_minus_iff [THEN iffD1])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   727
apply (simp add: minus_add_distrib approx_minus_iff [symmetric] add_ac)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   728
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   729
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   730
lemma approx_add_right_cancel: "b + d @= c + d ==> b @= c"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   731
apply (rule approx_add_left_cancel)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   732
apply (simp add: hypreal_add_commute)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   733
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   734
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   735
lemma approx_add_mono1: "b @= c ==> d + b @= d + c"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   736
apply (rule approx_minus_iff [THEN iffD2])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   737
apply (simp add: minus_add_distrib approx_minus_iff [symmetric] add_ac)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   738
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   739
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   740
lemma approx_add_mono2: "b @= c ==> b + a @= c + a"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   741
apply (simp (no_asm_simp) add: hypreal_add_commute approx_add_mono1)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   742
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   743
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   744
lemma approx_add_left_iff: "(a + b @= a + c) = (b @= c)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   745
by (fast elim: approx_add_left_cancel approx_add_mono1)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   746
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   747
declare approx_add_left_iff [simp]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   748
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   749
lemma approx_add_right_iff: "(b + a @= c + a) = (b @= c)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   750
apply (simp (no_asm) add: hypreal_add_commute)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   751
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   752
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   753
declare approx_add_right_iff [simp]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   754
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   755
lemma approx_HFinite: "[| x \<in> HFinite; x @= y |] ==> y \<in> HFinite"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   756
apply (drule bex_Infinitesimal_iff2 [THEN iffD2], safe)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   757
apply (drule Infinitesimal_subset_HFinite [THEN subsetD, THEN HFinite_minus_iff [THEN iffD2]])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   758
apply (drule HFinite_add)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   759
apply (auto simp add: hypreal_add_assoc)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   760
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   761
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   762
lemma approx_hypreal_of_real_HFinite: "x @= hypreal_of_real D ==> x \<in> HFinite"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   763
by (rule approx_sym [THEN [2] approx_HFinite], auto)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   764
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   765
lemma approx_mult_HFinite: "[|a @= b; c @= d; b: HFinite; d: HFinite|] ==> a*c @= b*d"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   766
apply (rule approx_trans)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   767
apply (rule_tac [2] approx_mult2)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   768
apply (rule approx_mult1)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   769
prefer 2 apply (blast intro: approx_HFinite approx_sym, auto)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   770
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   771
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   772
lemma approx_mult_hypreal_of_real: "[|a @= hypreal_of_real b; c @= hypreal_of_real d |]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   773
      ==> a*c @= hypreal_of_real b*hypreal_of_real d"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   774
apply (blast intro!: approx_mult_HFinite approx_hypreal_of_real_HFinite HFinite_hypreal_of_real)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   775
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   776
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   777
lemma approx_SReal_mult_cancel_zero: "[| a \<in> Reals; a \<noteq> 0; a*x @= 0 |] ==> x @= 0"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   778
apply (drule SReal_inverse [THEN SReal_subset_HFinite [THEN subsetD]])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   779
apply (auto dest: approx_mult2 simp add: hypreal_mult_assoc [symmetric])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   780
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   781
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   782
(* REM comments: newly added *)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   783
lemma approx_mult_SReal1: "[| a \<in> Reals; x @= 0 |] ==> x*a @= 0"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   784
by (auto dest: SReal_subset_HFinite [THEN subsetD] approx_mult1)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   785
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   786
lemma approx_mult_SReal2: "[| a \<in> Reals; x @= 0 |] ==> a*x @= 0"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   787
by (auto dest: SReal_subset_HFinite [THEN subsetD] approx_mult2)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   788
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   789
lemma approx_mult_SReal_zero_cancel_iff: "[|a \<in> Reals; a \<noteq> 0 |] ==> (a*x @= 0) = (x @= 0)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   790
by (blast intro: approx_SReal_mult_cancel_zero approx_mult_SReal2)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   791
declare approx_mult_SReal_zero_cancel_iff [simp]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   792
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   793
lemma approx_SReal_mult_cancel: "[| a \<in> Reals; a \<noteq> 0; a* w @= a*z |] ==> w @= z"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   794
apply (drule SReal_inverse [THEN SReal_subset_HFinite [THEN subsetD]])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   795
apply (auto dest: approx_mult2 simp add: hypreal_mult_assoc [symmetric])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   796
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   797
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   798
lemma approx_SReal_mult_cancel_iff1: "[| a \<in> Reals; a \<noteq> 0|] ==> (a* w @= a*z) = (w @= z)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   799
by (auto intro!: approx_mult2 SReal_subset_HFinite [THEN subsetD] intro: approx_SReal_mult_cancel)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   800
declare approx_SReal_mult_cancel_iff1 [simp]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   801
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   802
lemma approx_le_bound: "[| z <= f; f @= g; g <= z |] ==> f @= z"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   803
apply (simp add: bex_Infinitesimal_iff2 [symmetric], auto)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   804
apply (rule_tac x = "g+y-z" in bexI)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   805
apply (simp (no_asm))
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   806
apply (rule Infinitesimal_interval2)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   807
apply (rule_tac [2] Infinitesimal_zero, auto)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   808
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   809
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   810
(*-----------------------------------------------------------------
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   811
    Zero is the only infinitesimal that is also a real
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   812
 -----------------------------------------------------------------*)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   813
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   814
lemma Infinitesimal_less_SReal:
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   815
     "[| x \<in> Reals; y \<in> Infinitesimal; 0 < x |] ==> y < x"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   816
apply (simp add: Infinitesimal_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   817
apply (rule abs_ge_self [THEN order_le_less_trans], auto)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   818
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   819
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   820
lemma Infinitesimal_less_SReal2: "y \<in> Infinitesimal ==> \<forall>r \<in> Reals. 0 < r --> y < r"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   821
by (blast intro: Infinitesimal_less_SReal)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   822
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   823
lemma SReal_not_Infinitesimal:
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   824
     "[| 0 < y;  y \<in> Reals|] ==> y \<notin> Infinitesimal"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   825
apply (simp add: Infinitesimal_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   826
apply (auto simp add: hrabs_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   827
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   828
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   829
lemma SReal_minus_not_Infinitesimal: "[| y < 0;  y \<in> Reals |] ==> y \<notin> Infinitesimal"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   830
apply (subst Infinitesimal_minus_iff [symmetric])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   831
apply (rule SReal_not_Infinitesimal, auto)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   832
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   833
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   834
lemma SReal_Int_Infinitesimal_zero: "Reals Int Infinitesimal = {0}"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   835
apply auto
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   836
apply (cut_tac x = x and y = 0 in linorder_less_linear)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   837
apply (blast dest: SReal_not_Infinitesimal SReal_minus_not_Infinitesimal)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   838
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   839
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   840
lemma SReal_Infinitesimal_zero: "[| x \<in> Reals; x \<in> Infinitesimal|] ==> x = 0"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   841
by (cut_tac SReal_Int_Infinitesimal_zero, blast)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   842
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   843
lemma SReal_HFinite_diff_Infinitesimal: "[| x \<in> Reals; x \<noteq> 0 |] ==> x \<in> HFinite - Infinitesimal"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   844
by (auto dest: SReal_Infinitesimal_zero SReal_subset_HFinite [THEN subsetD])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   845
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   846
lemma hypreal_of_real_HFinite_diff_Infinitesimal: "hypreal_of_real x \<noteq> 0 ==> hypreal_of_real x \<in> HFinite - Infinitesimal"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   847
by (rule SReal_HFinite_diff_Infinitesimal, auto)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   848
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   849
lemma hypreal_of_real_Infinitesimal_iff_0: "(hypreal_of_real x \<in> Infinitesimal) = (x=0)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   850
apply auto
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   851
apply (rule ccontr)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   852
apply (rule hypreal_of_real_HFinite_diff_Infinitesimal [THEN DiffD2], auto)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   853
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   854
declare hypreal_of_real_Infinitesimal_iff_0 [iff]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   855
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   856
lemma number_of_not_Infinitesimal: "number_of w \<noteq> (0::hypreal) ==> number_of w \<notin> Infinitesimal"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   857
by (fast dest: SReal_number_of [THEN SReal_Infinitesimal_zero])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   858
declare number_of_not_Infinitesimal [simp]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   859
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   860
(*again: 1 is a special case, but not 0 this time*)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   861
lemma one_not_Infinitesimal: "1 \<notin> Infinitesimal"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   862
apply (subst hypreal_numeral_1_eq_1 [symmetric])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   863
apply (rule number_of_not_Infinitesimal)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   864
apply (simp (no_asm))
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   865
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   866
declare one_not_Infinitesimal [simp]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   867
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   868
lemma approx_SReal_not_zero: "[| y \<in> Reals; x @= y; y\<noteq> 0 |] ==> x \<noteq> 0"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   869
apply (cut_tac x = 0 and y = y in linorder_less_linear, simp)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   870
apply (blast dest: approx_sym [THEN mem_infmal_iff [THEN iffD2]] SReal_not_Infinitesimal SReal_minus_not_Infinitesimal)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   871
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   872
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   873
lemma HFinite_diff_Infinitesimal_approx: "[| x @= y; y \<in> HFinite - Infinitesimal |]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   874
      ==> x \<in> HFinite - Infinitesimal"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   875
apply (auto intro: approx_sym [THEN [2] approx_HFinite]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   876
            simp add: mem_infmal_iff)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   877
apply (drule approx_trans3, assumption)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   878
apply (blast dest: approx_sym)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   879
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   880
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   881
(*The premise y\<noteq>0 is essential; otherwise x/y =0 and we lose the
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   882
  HFinite premise.*)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   883
lemma Infinitesimal_ratio: "[| y \<noteq> 0;  y \<in> Infinitesimal;  x/y \<in> HFinite |] ==> x \<in> Infinitesimal"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   884
apply (drule Infinitesimal_HFinite_mult2, assumption)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   885
apply (simp add: hypreal_divide_def hypreal_mult_assoc)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   886
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   887
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   888
(*------------------------------------------------------------------
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   889
       Standard Part Theorem: Every finite x: R* is infinitely
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   890
       close to a unique real number (i.e a member of Reals)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   891
 ------------------------------------------------------------------*)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   892
(*------------------------------------------------------------------
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   893
         Uniqueness: Two infinitely close reals are equal
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   894
 ------------------------------------------------------------------*)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   895
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   896
lemma SReal_approx_iff: "[|x \<in> Reals; y \<in> Reals|] ==> (x @= y) = (x = y)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   897
apply auto
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   898
apply (simp add: approx_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   899
apply (drule_tac x = y in SReal_minus)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   900
apply (drule SReal_add, assumption)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   901
apply (drule SReal_Infinitesimal_zero, assumption)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   902
apply (drule sym)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   903
apply (simp add: hypreal_eq_minus_iff [symmetric])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   904
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   905
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   906
lemma number_of_approx_iff: "(number_of v @= number_of w) = (number_of v = (number_of w :: hypreal))"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   907
by (auto simp add: SReal_approx_iff)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   908
declare number_of_approx_iff [simp]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   909
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   910
(*And also for 0 @= #nn and 1 @= #nn, #nn @= 0 and #nn @= 1.*)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   911
lemma [simp]: "(0 @= number_of w) = ((number_of w :: hypreal) = 0)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   912
              "(number_of w @= 0) = ((number_of w :: hypreal) = 0)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   913
              "(1 @= number_of w) = ((number_of w :: hypreal) = 1)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   914
              "(number_of w @= 1) = ((number_of w :: hypreal) = 1)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   915
              "~ (0 @= 1)" "~ (1 @= 0)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   916
by (auto simp only: SReal_number_of SReal_approx_iff Reals_0 Reals_1)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   917
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   918
lemma hypreal_of_real_approx_iff: "(hypreal_of_real k @= hypreal_of_real m) = (k = m)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   919
apply auto
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   920
apply (rule inj_hypreal_of_real [THEN injD])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   921
apply (rule SReal_approx_iff [THEN iffD1], auto)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   922
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   923
declare hypreal_of_real_approx_iff [simp]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   924
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   925
lemma hypreal_of_real_approx_number_of_iff: "(hypreal_of_real k @= number_of w) = (k = number_of w)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   926
by (subst hypreal_of_real_approx_iff [symmetric], auto)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   927
declare hypreal_of_real_approx_number_of_iff [simp]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   928
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   929
(*And also for 0 and 1.*)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   930
(*And also for 0 @= #nn and 1 @= #nn, #nn @= 0 and #nn @= 1.*)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   931
lemma [simp]: "(hypreal_of_real k @= 0) = (k = 0)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   932
              "(hypreal_of_real k @= 1) = (k = 1)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   933
  by (simp_all add:  hypreal_of_real_approx_iff [symmetric])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   934
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   935
lemma approx_unique_real: "[| r \<in> Reals; s \<in> Reals; r @= x; s @= x|] ==> r = s"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   936
by (blast intro: SReal_approx_iff [THEN iffD1] approx_trans2)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   937
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   938
(*------------------------------------------------------------------
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   939
       Existence of unique real infinitely close
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   940
 ------------------------------------------------------------------*)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   941
(* lemma about lubs *)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   942
lemma hypreal_isLub_unique:
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   943
     "[| isLub R S x; isLub R S y |] ==> x = (y::hypreal)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   944
apply (frule isLub_isUb)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   945
apply (frule_tac x = y in isLub_isUb)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   946
apply (blast intro!: hypreal_le_anti_sym dest!: isLub_le_isUb)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   947
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   948
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   949
lemma lemma_st_part_ub: "x \<in> HFinite ==> \<exists>u. isUb Reals {s. s \<in> Reals & s < x} u"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   950
apply (drule HFiniteD, safe)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   951
apply (rule exI, rule isUbI)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   952
apply (auto intro: setleI isUbI simp add: abs_less_iff)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   953
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   954
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   955
lemma lemma_st_part_nonempty: "x \<in> HFinite ==> \<exists>y. y \<in> {s. s \<in> Reals & s < x}"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   956
apply (drule HFiniteD, safe)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   957
apply (drule SReal_minus)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   958
apply (rule_tac x = "-t" in exI)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   959
apply (auto simp add: abs_less_iff)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   960
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   961
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   962
lemma lemma_st_part_subset: "{s. s \<in> Reals & s < x} <= Reals"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   963
by auto
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   964
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   965
lemma lemma_st_part_lub: "x \<in> HFinite ==> \<exists>t. isLub Reals {s. s \<in> Reals & s < x} t"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   966
by (blast intro!: SReal_complete lemma_st_part_ub lemma_st_part_nonempty lemma_st_part_subset)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   967
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   968
lemma lemma_hypreal_le_left_cancel: "((t::hypreal) + r <= t) = (r <= 0)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   969
apply safe
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   970
apply (drule_tac c = "-t" in add_left_mono)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   971
apply (drule_tac [2] c = t in add_left_mono)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   972
apply (auto simp add: hypreal_add_assoc [symmetric])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   973
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   974
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   975
lemma lemma_st_part_le1: "[| x \<in> HFinite;  isLub Reals {s. s \<in> Reals & s < x} t;
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   976
         r \<in> Reals;  0 < r |] ==> x <= t + r"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   977
apply (frule isLubD1a)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   978
apply (rule ccontr, drule linorder_not_le [THEN iffD2])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   979
apply (drule_tac x = t in SReal_add, assumption)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   980
apply (drule_tac y = "t + r" in isLubD1 [THEN setleD], auto)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   981
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   982
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   983
lemma hypreal_setle_less_trans: "!!x::hypreal. [| S *<= x; x < y |] ==> S *<= y"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   984
apply (simp add: setle_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   985
apply (auto dest!: bspec order_le_less_trans intro: order_less_imp_le)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   986
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   987
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   988
lemma hypreal_gt_isUb:
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   989
     "!!x::hypreal. [| isUb R S x; x < y; y \<in> R |] ==> isUb R S y"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   990
apply (simp add: isUb_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   991
apply (blast intro: hypreal_setle_less_trans)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   992
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   993
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   994
lemma lemma_st_part_gt_ub: "[| x \<in> HFinite; x < y; y \<in> Reals |]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   995
               ==> isUb Reals {s. s \<in> Reals & s < x} y"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   996
apply (auto dest: order_less_trans intro: order_less_imp_le intro!: isUbI setleI)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   997
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   998
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
   999
lemma lemma_minus_le_zero: "t <= t + -r ==> r <= (0::hypreal)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1000
apply (drule_tac c = "-t" in add_left_mono)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1001
apply (auto simp add: hypreal_add_assoc [symmetric])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1002
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1003
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1004
lemma lemma_st_part_le2: "[| x \<in> HFinite;
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1005
         isLub Reals {s. s \<in> Reals & s < x} t;
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1006
         r \<in> Reals; 0 < r |]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1007
      ==> t + -r <= x"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1008
apply (frule isLubD1a)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1009
apply (rule ccontr, drule linorder_not_le [THEN iffD1])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1010
apply (drule SReal_minus, drule_tac x = t in SReal_add, assumption)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1011
apply (drule lemma_st_part_gt_ub, assumption+)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1012
apply (drule isLub_le_isUb, assumption)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1013
apply (drule lemma_minus_le_zero)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1014
apply (auto dest: order_less_le_trans)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1015
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1016
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1017
lemma lemma_hypreal_le_swap: "((x::hypreal) <= t + r) = (x + -t <= r)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1018
by auto
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1019
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1020
lemma lemma_st_part1a: "[| x \<in> HFinite;
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1021
         isLub Reals {s. s \<in> Reals & s < x} t;
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1022
         r \<in> Reals; 0 < r |]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1023
      ==> x + -t <= r"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1024
apply (blast intro!: lemma_hypreal_le_swap [THEN iffD1] lemma_st_part_le1)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1025
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1026
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1027
lemma lemma_hypreal_le_swap2: "(t + -r <= x) = (-(x + -t) <= (r::hypreal))"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1028
by auto
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1029
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1030
lemma lemma_st_part2a: "[| x \<in> HFinite;
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1031
         isLub Reals {s. s \<in> Reals & s < x} t;
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1032
         r \<in> Reals;  0 < r |]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1033
      ==> -(x + -t) <= r"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1034
apply (blast intro!: lemma_hypreal_le_swap2 [THEN iffD1] lemma_st_part_le2)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1035
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1036
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1037
lemma lemma_SReal_ub: "(x::hypreal) \<in> Reals ==> isUb Reals {s. s \<in> Reals & s < x} x"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1038
by (auto intro: isUbI setleI order_less_imp_le)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1039
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1040
lemma lemma_SReal_lub: "(x::hypreal) \<in> Reals ==> isLub Reals {s. s \<in> Reals & s < x} x"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1041
apply (auto intro!: isLubI2 lemma_SReal_ub setgeI)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1042
apply (frule isUbD2a)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1043
apply (rule_tac x = x and y = y in linorder_cases)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1044
apply (auto intro!: order_less_imp_le)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1045
apply (drule SReal_dense, assumption, assumption, safe)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1046
apply (drule_tac y = r in isUbD)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1047
apply (auto dest: order_less_le_trans)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1048
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1049
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1050
lemma lemma_st_part_not_eq1: "[| x \<in> HFinite;
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1051
         isLub Reals {s. s \<in> Reals & s < x} t;
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1052
         r \<in> Reals; 0 < r |]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1053
      ==> x + -t \<noteq> r"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1054
apply auto
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1055
apply (frule isLubD1a [THEN SReal_minus])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1056
apply (drule SReal_add_cancel, assumption)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1057
apply (drule_tac x = x in lemma_SReal_lub)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1058
apply (drule hypreal_isLub_unique, assumption, auto)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1059
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1060
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1061
lemma lemma_st_part_not_eq2: "[| x \<in> HFinite;
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1062
         isLub Reals {s. s \<in> Reals & s < x} t;
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1063
         r \<in> Reals; 0 < r |]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1064
      ==> -(x + -t) \<noteq> r"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1065
apply (auto simp add: minus_add_distrib)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1066
apply (frule isLubD1a)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1067
apply (drule SReal_add_cancel, assumption)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1068
apply (drule_tac x = "-x" in SReal_minus, simp)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1069
apply (drule_tac x = x in lemma_SReal_lub)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1070
apply (drule hypreal_isLub_unique, assumption, auto)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1071
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1072
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1073
lemma lemma_st_part_major: "[| x \<in> HFinite;
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1074
         isLub Reals {s. s \<in> Reals & s < x} t;
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1075
         r \<in> Reals; 0 < r |]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1076
      ==> abs (x + -t) < r"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1077
apply (frule lemma_st_part1a)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1078
apply (frule_tac [4] lemma_st_part2a, auto)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1079
apply (drule order_le_imp_less_or_eq)+
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1080
apply (auto dest: lemma_st_part_not_eq1 lemma_st_part_not_eq2 simp add: abs_less_iff)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1081
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1082
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1083
lemma lemma_st_part_major2: "[| x \<in> HFinite;
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1084
         isLub Reals {s. s \<in> Reals & s < x} t |]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1085
      ==> \<forall>r \<in> Reals. 0 < r --> abs (x + -t) < r"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1086
apply (blast dest!: lemma_st_part_major)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1087
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1088
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1089
(*----------------------------------------------
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1090
  Existence of real and Standard Part Theorem
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1091
 ----------------------------------------------*)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1092
lemma lemma_st_part_Ex: "x \<in> HFinite ==>
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1093
      \<exists>t \<in> Reals. \<forall>r \<in> Reals. 0 < r --> abs (x + -t) < r"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1094
apply (frule lemma_st_part_lub, safe)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1095
apply (frule isLubD1a)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1096
apply (blast dest: lemma_st_part_major2)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1097
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1098
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1099
lemma st_part_Ex:
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1100
     "x \<in> HFinite ==> \<exists>t \<in> Reals. x @= t"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1101
apply (simp add: approx_def Infinitesimal_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1102
apply (drule lemma_st_part_Ex, auto)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1103
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1104
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1105
(*--------------------------------
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1106
  Unique real infinitely close
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1107
 -------------------------------*)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1108
lemma st_part_Ex1: "x \<in> HFinite ==> EX! t. t \<in> Reals & x @= t"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1109
apply (drule st_part_Ex, safe)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1110
apply (drule_tac [2] approx_sym, drule_tac [2] approx_sym, drule_tac [2] approx_sym)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1111
apply (auto intro!: approx_unique_real)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1112
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1113
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1114
(*------------------------------------------------------------------
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1115
       Finite and Infinite --- more theorems
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1116
 ------------------------------------------------------------------*)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1117
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1118
lemma HFinite_Int_HInfinite_empty: "HFinite Int HInfinite = {}"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1119
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1120
apply (simp add: HFinite_def HInfinite_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1121
apply (auto dest: order_less_trans)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1122
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1123
declare HFinite_Int_HInfinite_empty [simp]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1124
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1125
lemma HFinite_not_HInfinite: 
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1126
  assumes x: "x \<in> HFinite" shows "x \<notin> HInfinite"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1127
proof
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1128
  assume x': "x \<in> HInfinite"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1129
  with x have "x \<in> HFinite \<inter> HInfinite" by blast
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1130
  thus False by auto
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1131
qed
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1132
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1133
lemma not_HFinite_HInfinite: "x\<notin> HFinite ==> x \<in> HInfinite"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1134
apply (simp add: HInfinite_def HFinite_def, auto)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1135
apply (drule_tac x = "r + 1" in bspec)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1136
apply (auto simp add: SReal_add)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1137
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1138
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1139
lemma HInfinite_HFinite_disj: "x \<in> HInfinite | x \<in> HFinite"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1140
by (blast intro: not_HFinite_HInfinite)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1141
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1142
lemma HInfinite_HFinite_iff: "(x \<in> HInfinite) = (x \<notin> HFinite)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1143
by (blast dest: HFinite_not_HInfinite not_HFinite_HInfinite)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1144
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1145
lemma HFinite_HInfinite_iff: "(x \<in> HFinite) = (x \<notin> HInfinite)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1146
apply (simp (no_asm) add: HInfinite_HFinite_iff)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1147
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1148
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1149
(*------------------------------------------------------------------
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1150
       Finite, Infinite and Infinitesimal --- more theorems
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1151
 ------------------------------------------------------------------*)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1152
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1153
lemma HInfinite_diff_HFinite_Infinitesimal_disj: "x \<notin> Infinitesimal ==> x \<in> HInfinite | x \<in> HFinite - Infinitesimal"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1154
by (fast intro: not_HFinite_HInfinite)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1155
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1156
lemma HFinite_inverse: "[| x \<in> HFinite; x \<notin> Infinitesimal |] ==> inverse x \<in> HFinite"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1157
apply (cut_tac x = "inverse x" in HInfinite_HFinite_disj)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1158
apply (auto dest!: HInfinite_inverse_Infinitesimal)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1159
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1160
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1161
lemma HFinite_inverse2: "x \<in> HFinite - Infinitesimal ==> inverse x \<in> HFinite"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1162
by (blast intro: HFinite_inverse)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1163
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1164
(* stronger statement possible in fact *)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1165
lemma Infinitesimal_inverse_HFinite: "x \<notin> Infinitesimal ==> inverse(x) \<in> HFinite"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1166
apply (drule HInfinite_diff_HFinite_Infinitesimal_disj)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1167
apply (blast intro: HFinite_inverse HInfinite_inverse_Infinitesimal Infinitesimal_subset_HFinite [THEN subsetD])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1168
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1169
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1170
lemma HFinite_not_Infinitesimal_inverse: "x \<in> HFinite - Infinitesimal ==> inverse x \<in> HFinite - Infinitesimal"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1171
apply (auto intro: Infinitesimal_inverse_HFinite)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1172
apply (drule Infinitesimal_HFinite_mult2, assumption)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1173
apply (simp add: not_Infinitesimal_not_zero hypreal_mult_inverse)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1174
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1175
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1176
lemma approx_inverse: "[| x @= y; y \<in>  HFinite - Infinitesimal |]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1177
      ==> inverse x @= inverse y"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1178
apply (frule HFinite_diff_Infinitesimal_approx, assumption)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1179
apply (frule not_Infinitesimal_not_zero2)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1180
apply (frule_tac x = x in not_Infinitesimal_not_zero2)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1181
apply (drule HFinite_inverse2)+
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1182
apply (drule approx_mult2, assumption, auto)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1183
apply (drule_tac c = "inverse x" in approx_mult1, assumption)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1184
apply (auto intro: approx_sym simp add: hypreal_mult_assoc)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1185
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1186
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1187
(*Used for NSLIM_inverse, NSLIMSEQ_inverse*)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1188
lemmas hypreal_of_real_approx_inverse =  hypreal_of_real_HFinite_diff_Infinitesimal [THEN [2] approx_inverse]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1189
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1190
lemma inverse_add_Infinitesimal_approx: "[| x \<in> HFinite - Infinitesimal;
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1191
         h \<in> Infinitesimal |] ==> inverse(x + h) @= inverse x"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1192
apply (auto intro: approx_inverse approx_sym Infinitesimal_add_approx_self)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1193
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1194
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1195
lemma inverse_add_Infinitesimal_approx2: "[| x \<in> HFinite - Infinitesimal;
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1196
         h \<in> Infinitesimal |] ==> inverse(h + x) @= inverse x"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1197
apply (rule hypreal_add_commute [THEN subst])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1198
apply (blast intro: inverse_add_Infinitesimal_approx)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1199
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1200
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1201
lemma inverse_add_Infinitesimal_approx_Infinitesimal: "[| x \<in> HFinite - Infinitesimal;
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1202
         h \<in> Infinitesimal |] ==> inverse(x + h) + -inverse x @= h"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1203
apply (rule approx_trans2)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1204
apply (auto intro: inverse_add_Infinitesimal_approx simp add: mem_infmal_iff approx_minus_iff [symmetric])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1205
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1206
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1207
lemma Infinitesimal_square_iff: "(x \<in> Infinitesimal) = (x*x \<in> Infinitesimal)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1208
apply (auto intro: Infinitesimal_mult)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1209
apply (rule ccontr, frule Infinitesimal_inverse_HFinite)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1210
apply (frule not_Infinitesimal_not_zero)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1211
apply (auto dest: Infinitesimal_HFinite_mult simp add: hypreal_mult_assoc)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1212
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1213
declare Infinitesimal_square_iff [symmetric, simp]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1214
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1215
lemma HFinite_square_iff: "(x*x \<in> HFinite) = (x \<in> HFinite)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1216
apply (auto intro: HFinite_mult)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1217
apply (auto dest: HInfinite_mult simp add: HFinite_HInfinite_iff)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1218
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1219
declare HFinite_square_iff [simp]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1220
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1221
lemma HInfinite_square_iff: "(x*x \<in> HInfinite) = (x \<in> HInfinite)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1222
by (auto simp add: HInfinite_HFinite_iff)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1223
declare HInfinite_square_iff [simp]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1224
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1225
lemma approx_HFinite_mult_cancel: "[| a: HFinite-Infinitesimal; a* w @= a*z |] ==> w @= z"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1226
apply safe
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1227
apply (frule HFinite_inverse, assumption)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1228
apply (drule not_Infinitesimal_not_zero)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1229
apply (auto dest: approx_mult2 simp add: hypreal_mult_assoc [symmetric])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1230
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1231
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1232
lemma approx_HFinite_mult_cancel_iff1: "a: HFinite-Infinitesimal ==> (a * w @= a * z) = (w @= z)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1233
by (auto intro: approx_mult2 approx_HFinite_mult_cancel)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1234
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1235
lemma HInfinite_HFinite_add_cancel: "[| x + y \<in> HInfinite; y \<in> HFinite |] ==> x \<in> HInfinite"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1236
apply (rule ccontr)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1237
apply (drule HFinite_HInfinite_iff [THEN iffD2])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1238
apply (auto dest: HFinite_add simp add: HInfinite_HFinite_iff)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1239
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1240
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1241
lemma HInfinite_HFinite_add: "[| x \<in> HInfinite; y \<in> HFinite |] ==> x + y \<in> HInfinite"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1242
apply (rule_tac y = "-y" in HInfinite_HFinite_add_cancel)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1243
apply (auto simp add: hypreal_add_assoc HFinite_minus_iff)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1244
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1245
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1246
lemma HInfinite_ge_HInfinite: "[| x \<in> HInfinite; x <= y; 0 <= x |] ==> y \<in> HInfinite"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1247
by (auto intro: HFinite_bounded simp add: HInfinite_HFinite_iff)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1248
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1249
lemma Infinitesimal_inverse_HInfinite: "[| x \<in> Infinitesimal; x \<noteq> 0 |] ==> inverse x \<in> HInfinite"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1250
apply (rule ccontr, drule HFinite_HInfinite_iff [THEN iffD2])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1251
apply (auto dest: Infinitesimal_HFinite_mult2)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1252
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1253
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1254
lemma HInfinite_HFinite_not_Infinitesimal_mult: "[| x \<in> HInfinite; y \<in> HFinite - Infinitesimal |]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1255
      ==> x * y \<in> HInfinite"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1256
apply (rule ccontr, drule HFinite_HInfinite_iff [THEN iffD2])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1257
apply (frule HFinite_Infinitesimal_not_zero)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1258
apply (drule HFinite_not_Infinitesimal_inverse)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1259
apply (safe, drule HFinite_mult)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1260
apply (auto simp add: hypreal_mult_assoc HFinite_HInfinite_iff)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1261
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1262
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1263
lemma HInfinite_HFinite_not_Infinitesimal_mult2: "[| x \<in> HInfinite; y \<in> HFinite - Infinitesimal |]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1264
      ==> y * x \<in> HInfinite"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1265
apply (auto simp add: hypreal_mult_commute HInfinite_HFinite_not_Infinitesimal_mult)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1266
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1267
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1268
lemma HInfinite_gt_SReal: "[| x \<in> HInfinite; 0 < x; y \<in> Reals |] ==> y < x"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1269
by (auto dest!: bspec simp add: HInfinite_def hrabs_def order_less_imp_le)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1270
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1271
lemma HInfinite_gt_zero_gt_one: "[| x \<in> HInfinite; 0 < x |] ==> 1 < x"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1272
by (auto intro: HInfinite_gt_SReal)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1273
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1274
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1275
lemma not_HInfinite_one: "1 \<notin> HInfinite"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1276
apply (simp (no_asm) add: HInfinite_HFinite_iff)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1277
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1278
declare not_HInfinite_one [simp]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1279
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1280
(*------------------------------------------------------------------
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1281
                  more about absolute value (hrabs)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1282
 ------------------------------------------------------------------*)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1283
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1284
lemma approx_hrabs_disj: "abs x @= x | abs x @= -x"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1285
by (cut_tac x = x in hrabs_disj, auto)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1286
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1287
(*------------------------------------------------------------------
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1288
                  Theorems about monads
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1289
 ------------------------------------------------------------------*)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1290
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1291
lemma monad_hrabs_Un_subset: "monad (abs x) <= monad(x) Un monad(-x)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1292
by (rule_tac x1 = x in hrabs_disj [THEN disjE], auto)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1293
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1294
lemma Infinitesimal_monad_eq: "e \<in> Infinitesimal ==> monad (x+e) = monad x"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1295
by (fast intro!: Infinitesimal_add_approx_self [THEN approx_sym] approx_monad_iff [THEN iffD1])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1296
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1297
lemma mem_monad_iff: "(u \<in> monad x) = (-u \<in> monad (-x))"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1298
by (simp add: monad_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1299
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1300
lemma Infinitesimal_monad_zero_iff: "(x \<in> Infinitesimal) = (x \<in> monad 0)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1301
by (auto intro: approx_sym simp add: monad_def mem_infmal_iff)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1302
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1303
lemma monad_zero_minus_iff: "(x \<in> monad 0) = (-x \<in> monad 0)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1304
apply (simp (no_asm) add: Infinitesimal_monad_zero_iff [symmetric])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1305
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1306
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1307
lemma monad_zero_hrabs_iff: "(x \<in> monad 0) = (abs x \<in> monad 0)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1308
apply (rule_tac x1 = x in hrabs_disj [THEN disjE])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1309
apply (auto simp add: monad_zero_minus_iff [symmetric])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1310
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1311
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1312
lemma mem_monad_self: "x \<in> monad x"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1313
by (simp add: monad_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1314
declare mem_monad_self [simp]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1315
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1316
(*------------------------------------------------------------------
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1317
         Proof that x @= y ==> abs x @= abs y
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1318
 ------------------------------------------------------------------*)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1319
lemma approx_subset_monad: "x @= y ==> {x,y}<=monad x"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1320
apply (simp (no_asm))
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1321
apply (simp add: approx_monad_iff)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1322
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1323
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1324
lemma approx_subset_monad2: "x @= y ==> {x,y}<=monad y"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1325
apply (drule approx_sym)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1326
apply (fast dest: approx_subset_monad)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1327
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1328
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1329
lemma mem_monad_approx: "u \<in> monad x ==> x @= u"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1330
by (simp add: monad_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1331
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1332
lemma approx_mem_monad: "x @= u ==> u \<in> monad x"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1333
by (simp add: monad_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1334
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1335
lemma approx_mem_monad2: "x @= u ==> x \<in> monad u"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1336
apply (simp add: monad_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1337
apply (blast intro!: approx_sym)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1338
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1339
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1340
lemma approx_mem_monad_zero: "[| x @= y;x \<in> monad 0 |] ==> y \<in> monad 0"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1341
apply (drule mem_monad_approx)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1342
apply (fast intro: approx_mem_monad approx_trans)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1343
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1344
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1345
lemma Infinitesimal_approx_hrabs: "[| x @= y; x \<in> Infinitesimal |] ==> abs x @= abs y"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1346
apply (drule Infinitesimal_monad_zero_iff [THEN iffD1])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1347
apply (blast intro: approx_mem_monad_zero monad_zero_hrabs_iff [THEN iffD1] mem_monad_approx approx_trans3)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1348
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1349
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1350
lemma less_Infinitesimal_less: "[| 0 < x;  x \<notin>Infinitesimal;  e :Infinitesimal |] ==> e < x"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1351
apply (rule ccontr)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1352
apply (auto intro: Infinitesimal_zero [THEN [2] Infinitesimal_interval] 
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1353
            dest!: order_le_imp_less_or_eq simp add: linorder_not_less)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1354
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1355
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1356
lemma Ball_mem_monad_gt_zero: "[| 0 < x;  x \<notin> Infinitesimal; u \<in> monad x |] ==> 0 < u"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1357
apply (drule mem_monad_approx [THEN approx_sym])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1358
apply (erule bex_Infinitesimal_iff2 [THEN iffD2, THEN bexE])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1359
apply (drule_tac e = "-xa" in less_Infinitesimal_less, auto)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1360
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1361
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1362
lemma Ball_mem_monad_less_zero: "[| x < 0; x \<notin> Infinitesimal; u \<in> monad x |] ==> u < 0"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1363
apply (drule mem_monad_approx [THEN approx_sym])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1364
apply (erule bex_Infinitesimal_iff [THEN iffD2, THEN bexE])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1365
apply (cut_tac x = "-x" and e = xa in less_Infinitesimal_less, auto)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1366
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1367
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1368
lemma lemma_approx_gt_zero: "[|0 < x; x \<notin> Infinitesimal; x @= y|] ==> 0 < y"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1369
by (blast dest: Ball_mem_monad_gt_zero approx_subset_monad)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1370
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1371
lemma lemma_approx_less_zero: "[|x < 0; x \<notin> Infinitesimal; x @= y|] ==> y < 0"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1372
by (blast dest: Ball_mem_monad_less_zero approx_subset_monad)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1373
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1374
lemma approx_hrabs1: "[| x @= y; x < 0; x \<notin> Infinitesimal |] ==> abs x @= abs y"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1375
apply (frule lemma_approx_less_zero)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1376
apply (assumption+)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1377
apply (simp add: abs_if) 
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1378
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1379
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1380
lemma approx_hrabs2: "[| x @= y; 0 < x; x \<notin> Infinitesimal |] ==> abs x @= abs y"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1381
apply (frule lemma_approx_gt_zero)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1382
apply (assumption+)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1383
apply (simp add: abs_if) 
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1384
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1385
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1386
lemma approx_hrabs: "x @= y ==> abs x @= abs y"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1387
apply (rule_tac Q = "x \<in> Infinitesimal" in excluded_middle [THEN disjE])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1388
apply (rule_tac x1 = x and y1 = 0 in linorder_less_linear [THEN disjE])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1389
apply (auto intro: approx_hrabs1 approx_hrabs2 Infinitesimal_approx_hrabs)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1390
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1391
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1392
lemma approx_hrabs_zero_cancel: "abs(x) @= 0 ==> x @= 0"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1393
apply (cut_tac x = x in hrabs_disj)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1394
apply (auto dest: approx_minus)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1395
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1396
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1397
lemma approx_hrabs_add_Infinitesimal: "e \<in> Infinitesimal ==> abs x @= abs(x+e)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1398
by (fast intro: approx_hrabs Infinitesimal_add_approx_self)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1399
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1400
lemma approx_hrabs_add_minus_Infinitesimal: "e \<in> Infinitesimal ==> abs x @= abs(x + -e)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1401
by (fast intro: approx_hrabs Infinitesimal_add_minus_approx_self)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1402
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1403
lemma hrabs_add_Infinitesimal_cancel: "[| e \<in> Infinitesimal; e' \<in> Infinitesimal;
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1404
         abs(x+e) = abs(y+e')|] ==> abs x @= abs y"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1405
apply (drule_tac x = x in approx_hrabs_add_Infinitesimal)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1406
apply (drule_tac x = y in approx_hrabs_add_Infinitesimal)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1407
apply (auto intro: approx_trans2)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1408
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1409
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1410
lemma hrabs_add_minus_Infinitesimal_cancel: "[| e \<in> Infinitesimal; e' \<in> Infinitesimal;
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1411
         abs(x + -e) = abs(y + -e')|] ==> abs x @= abs y"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1412
apply (drule_tac x = x in approx_hrabs_add_minus_Infinitesimal)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1413
apply (drule_tac x = y in approx_hrabs_add_minus_Infinitesimal)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1414
apply (auto intro: approx_trans2)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1415
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1416
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1417
lemma hypreal_less_minus_iff: "((x::hypreal) < y) = (0 < y + -x)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1418
by arith
10751
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
  1419
14370
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1420
(* interesting slightly counterintuitive theorem: necessary
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1421
   for proving that an open interval is an NS open set
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1422
*)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1423
lemma Infinitesimal_add_hypreal_of_real_less:
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1424
     "[| x < y;  u \<in> Infinitesimal |]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1425
      ==> hypreal_of_real x + u < hypreal_of_real y"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1426
apply (simp add: Infinitesimal_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1427
apply (drule hypreal_of_real_less_iff [THEN iffD2])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1428
apply (drule_tac x = "hypreal_of_real y + -hypreal_of_real x" in bspec)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1429
apply (auto simp add: hypreal_add_commute abs_less_iff SReal_add SReal_minus)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1430
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1431
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1432
lemma Infinitesimal_add_hrabs_hypreal_of_real_less: "[| x \<in> Infinitesimal; abs(hypreal_of_real r) < hypreal_of_real y |]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1433
      ==> abs (hypreal_of_real r + x) < hypreal_of_real y"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1434
apply (drule_tac x = "hypreal_of_real r" in approx_hrabs_add_Infinitesimal)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1435
apply (drule approx_sym [THEN bex_Infinitesimal_iff2 [THEN iffD2]])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1436
apply (auto intro!: Infinitesimal_add_hypreal_of_real_less simp add: hypreal_of_real_hrabs)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1437
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1438
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1439
lemma Infinitesimal_add_hrabs_hypreal_of_real_less2: "[| x \<in> Infinitesimal;  abs(hypreal_of_real r) < hypreal_of_real y |]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1440
      ==> abs (x + hypreal_of_real r) < hypreal_of_real y"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1441
apply (rule hypreal_add_commute [THEN subst])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1442
apply (erule Infinitesimal_add_hrabs_hypreal_of_real_less, assumption)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1443
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1444
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1445
lemma hypreal_of_real_le_add_Infininitesimal_cancel: "[| u \<in> Infinitesimal; v \<in> Infinitesimal;
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1446
         hypreal_of_real x + u <= hypreal_of_real y + v |]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1447
      ==> hypreal_of_real x <= hypreal_of_real y"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1448
apply (simp add: linorder_not_less [symmetric], auto)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1449
apply (drule_tac u = "v-u" in Infinitesimal_add_hypreal_of_real_less)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1450
apply (auto simp add: Infinitesimal_diff)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1451
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1452
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1453
lemma hypreal_of_real_le_add_Infininitesimal_cancel2: "[| u \<in> Infinitesimal; v \<in> Infinitesimal;
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1454
         hypreal_of_real x + u <= hypreal_of_real y + v |]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1455
      ==> x <= y"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1456
apply (blast intro!: hypreal_of_real_le_iff [THEN iffD1] hypreal_of_real_le_add_Infininitesimal_cancel)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1457
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1458
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1459
lemma hypreal_of_real_less_Infinitesimal_le_zero: "[| hypreal_of_real x < e; e \<in> Infinitesimal |] ==> hypreal_of_real x <= 0"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1460
apply (rule linorder_not_less [THEN iffD1], safe)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1461
apply (drule Infinitesimal_interval)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1462
apply (drule_tac [4] SReal_hypreal_of_real [THEN SReal_Infinitesimal_zero], auto)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1463
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1464
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1465
(*used once, in Lim/NSDERIV_inverse*)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1466
lemma Infinitesimal_add_not_zero: "[| h \<in> Infinitesimal; x \<noteq> 0 |] ==> hypreal_of_real x + h \<noteq> 0"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1467
apply auto
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1468
apply (subgoal_tac "h = - hypreal_of_real x", auto)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1469
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1470
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1471
lemma Infinitesimal_square_cancel: "x*x + y*y \<in> Infinitesimal ==> x*x \<in> Infinitesimal"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1472
apply (rule Infinitesimal_interval2)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1473
apply (rule_tac [3] zero_le_square, assumption)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1474
apply (auto simp add: zero_le_square)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1475
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1476
declare Infinitesimal_square_cancel [simp]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1477
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1478
lemma HFinite_square_cancel: "x*x + y*y \<in> HFinite ==> x*x \<in> HFinite"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1479
apply (rule HFinite_bounded, assumption)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1480
apply (auto simp add: zero_le_square)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1481
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1482
declare HFinite_square_cancel [simp]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1483
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1484
lemma Infinitesimal_square_cancel2: "x*x + y*y \<in> Infinitesimal ==> y*y \<in> Infinitesimal"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1485
apply (rule Infinitesimal_square_cancel)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1486
apply (rule hypreal_add_commute [THEN subst])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1487
apply (simp (no_asm))
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1488
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1489
declare Infinitesimal_square_cancel2 [simp]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1490
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1491
lemma HFinite_square_cancel2: "x*x + y*y \<in> HFinite ==> y*y \<in> HFinite"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1492
apply (rule HFinite_square_cancel)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1493
apply (rule hypreal_add_commute [THEN subst])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1494
apply (simp (no_asm))
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1495
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1496
declare HFinite_square_cancel2 [simp]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1497
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1498
lemma Infinitesimal_sum_square_cancel: "x*x + y*y + z*z \<in> Infinitesimal ==> x*x \<in> Infinitesimal"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1499
apply (rule Infinitesimal_interval2, assumption)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1500
apply (rule_tac [2] zero_le_square, simp)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1501
apply (insert zero_le_square [of y]) 
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1502
apply (insert zero_le_square [of z], simp)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1503
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1504
declare Infinitesimal_sum_square_cancel [simp]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1505
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1506
lemma HFinite_sum_square_cancel: "x*x + y*y + z*z \<in> HFinite ==> x*x \<in> HFinite"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1507
apply (rule HFinite_bounded, assumption)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1508
apply (rule_tac [2] zero_le_square)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1509
apply (insert zero_le_square [of y]) 
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1510
apply (insert zero_le_square [of z], simp)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1511
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1512
declare HFinite_sum_square_cancel [simp]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1513
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1514
lemma Infinitesimal_sum_square_cancel2: "y*y + x*x + z*z \<in> Infinitesimal ==> x*x \<in> Infinitesimal"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1515
apply (rule Infinitesimal_sum_square_cancel)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1516
apply (simp add: add_ac)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1517
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1518
declare Infinitesimal_sum_square_cancel2 [simp]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1519
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1520
lemma HFinite_sum_square_cancel2: "y*y + x*x + z*z \<in> HFinite ==> x*x \<in> HFinite"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1521
apply (rule HFinite_sum_square_cancel)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1522
apply (simp add: add_ac)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1523
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1524
declare HFinite_sum_square_cancel2 [simp]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1525
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1526
lemma Infinitesimal_sum_square_cancel3: "z*z + y*y + x*x \<in> Infinitesimal ==> x*x \<in> Infinitesimal"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1527
apply (rule Infinitesimal_sum_square_cancel)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1528
apply (simp add: add_ac)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1529
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1530
declare Infinitesimal_sum_square_cancel3 [simp]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1531
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1532
lemma HFinite_sum_square_cancel3: "z*z + y*y + x*x \<in> HFinite ==> x*x \<in> HFinite"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1533
apply (rule HFinite_sum_square_cancel)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1534
apply (simp add: add_ac)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1535
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1536
declare HFinite_sum_square_cancel3 [simp]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1537
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1538
lemma monad_hrabs_less: "[| y \<in> monad x; 0 < hypreal_of_real e |]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1539
      ==> abs (y + -x) < hypreal_of_real e"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1540
apply (drule mem_monad_approx [THEN approx_sym])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1541
apply (drule bex_Infinitesimal_iff [THEN iffD2])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1542
apply (auto dest!: InfinitesimalD)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1543
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1544
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1545
lemma mem_monad_SReal_HFinite: "x \<in> monad (hypreal_of_real  a) ==> x \<in> HFinite"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1546
apply (drule mem_monad_approx [THEN approx_sym])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1547
apply (drule bex_Infinitesimal_iff2 [THEN iffD2])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1548
apply (safe dest!: Infinitesimal_subset_HFinite [THEN subsetD])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1549
apply (erule SReal_hypreal_of_real [THEN SReal_subset_HFinite [THEN subsetD], THEN HFinite_add])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1550
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1551
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1552
(*------------------------------------------------------------------
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1553
              Theorems about standard part
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1554
 ------------------------------------------------------------------*)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1555
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1556
lemma st_approx_self: "x \<in> HFinite ==> st x @= x"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1557
apply (simp add: st_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1558
apply (frule st_part_Ex, safe)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1559
apply (rule someI2)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1560
apply (auto intro: approx_sym)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1561
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1562
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1563
lemma st_SReal: "x \<in> HFinite ==> st x \<in> Reals"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1564
apply (simp add: st_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1565
apply (frule st_part_Ex, safe)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1566
apply (rule someI2)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1567
apply (auto intro: approx_sym)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1568
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1569
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1570
lemma st_HFinite: "x \<in> HFinite ==> st x \<in> HFinite"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1571
by (erule st_SReal [THEN SReal_subset_HFinite [THEN subsetD]])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1572
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1573
lemma st_SReal_eq: "x \<in> Reals ==> st x = x"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1574
apply (simp add: st_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1575
apply (rule some_equality)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1576
apply (fast intro: SReal_subset_HFinite [THEN subsetD])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1577
apply (blast dest: SReal_approx_iff [THEN iffD1])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1578
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1579
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1580
(* ???should be added to simpset *)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1581
lemma st_hypreal_of_real: "st (hypreal_of_real x) = hypreal_of_real x"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1582
by (rule SReal_hypreal_of_real [THEN st_SReal_eq])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1583
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1584
lemma st_eq_approx: "[| x \<in> HFinite; y \<in> HFinite; st x = st y |] ==> x @= y"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1585
by (auto dest!: st_approx_self elim!: approx_trans3)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1586
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1587
lemma approx_st_eq: 
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1588
  assumes "x \<in> HFinite" and "y \<in> HFinite" and "x @= y" 
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1589
  shows "st x = st y"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1590
proof -
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1591
  have "st x @= x" "st y @= y" "st x \<in> Reals" "st y \<in> Reals"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1592
    by (simp_all add: st_approx_self st_SReal prems) 
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1593
  with prems show ?thesis 
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1594
    by (fast elim: approx_trans approx_trans2 SReal_approx_iff [THEN iffD1])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1595
qed
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1596
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1597
lemma st_eq_approx_iff: "[| x \<in> HFinite; y \<in> HFinite|]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1598
                   ==> (x @= y) = (st x = st y)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1599
by (blast intro: approx_st_eq st_eq_approx)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1600
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1601
lemma st_Infinitesimal_add_SReal: "[| x \<in> Reals; e \<in> Infinitesimal |] ==> st(x + e) = x"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1602
apply (frule st_SReal_eq [THEN subst])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1603
prefer 2 apply assumption
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1604
apply (frule SReal_subset_HFinite [THEN subsetD])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1605
apply (frule Infinitesimal_subset_HFinite [THEN subsetD])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1606
apply (drule st_SReal_eq)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1607
apply (rule approx_st_eq)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1608
apply (auto intro: HFinite_add simp add: Infinitesimal_add_approx_self [THEN approx_sym])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1609
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1610
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1611
lemma st_Infinitesimal_add_SReal2: "[| x \<in> Reals; e \<in> Infinitesimal |]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1612
      ==> st(e + x) = x"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1613
apply (rule hypreal_add_commute [THEN subst])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1614
apply (blast intro!: st_Infinitesimal_add_SReal)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1615
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1616
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1617
lemma HFinite_st_Infinitesimal_add: "x \<in> HFinite ==>
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1618
      \<exists>e \<in> Infinitesimal. x = st(x) + e"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1619
apply (blast dest!: st_approx_self [THEN approx_sym] bex_Infinitesimal_iff2 [THEN iffD2])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1620
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1621
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1622
lemma st_add: 
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1623
  assumes x: "x \<in> HFinite" and y: "y \<in> HFinite"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1624
  shows "st (x + y) = st(x) + st(y)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1625
proof -
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1626
  from HFinite_st_Infinitesimal_add [OF x]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1627
  obtain ex where ex: "ex \<in> Infinitesimal" "st x + ex = x" 
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1628
    by (blast intro: sym)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1629
  from HFinite_st_Infinitesimal_add [OF y]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1630
  obtain ey where ey: "ey \<in> Infinitesimal" "st y + ey = y" 
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1631
    by (blast intro: sym)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1632
  have "st (x + y) = st ((st x + ex) + (st y + ey))"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1633
    by (simp add: ex ey) 
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1634
  also have "... = st ((ex + ey) + (st x + st y))" by (simp add: add_ac)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1635
  also have "... = st x + st y" 
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1636
    by (simp add: prems st_SReal SReal_add Infinitesimal_add 
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1637
                  st_Infinitesimal_add_SReal2) 
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1638
  finally show ?thesis .
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1639
qed
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1640
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1641
lemma st_number_of: "st (number_of w) = number_of w"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1642
by (rule SReal_number_of [THEN st_SReal_eq])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1643
declare st_number_of [simp]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1644
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1645
(*the theorem above for the special cases of zero and one*)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1646
lemma [simp]: "st 0 = 0" "st 1 = 1"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1647
by (simp_all add: st_SReal_eq)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1648
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1649
lemma st_minus: assumes "y \<in> HFinite" shows "st(-y) = -st(y)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1650
proof -
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1651
  have "st (- y) + st y = 0"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1652
   by (simp add: prems st_add [symmetric] HFinite_minus_iff) 
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1653
  thus ?thesis by arith
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1654
qed
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1655
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1656
lemma st_diff:
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1657
     "[| x \<in> HFinite; y \<in> HFinite |] ==> st (x-y) = st(x) - st(y)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1658
apply (simp add: hypreal_diff_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1659
apply (frule_tac y1 = y in st_minus [symmetric])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1660
apply (drule_tac x1 = y in HFinite_minus_iff [THEN iffD2])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1661
apply (simp (no_asm_simp) add: st_add)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1662
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1663
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1664
(* lemma *)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1665
lemma lemma_st_mult: "[| x \<in> HFinite; y \<in> HFinite;
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1666
         e \<in> Infinitesimal;
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1667
         ea \<in> Infinitesimal |]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1668
       ==> e*y + x*ea + e*ea \<in> Infinitesimal"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1669
apply (frule_tac x = e and y = y in Infinitesimal_HFinite_mult)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1670
apply (frule_tac [2] x = ea and y = x in Infinitesimal_HFinite_mult)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1671
apply (drule_tac [3] Infinitesimal_mult)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1672
apply (auto intro: Infinitesimal_add simp add: add_ac mult_ac)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1673
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1674
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1675
lemma st_mult: "[| x \<in> HFinite; y \<in> HFinite |]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1676
               ==> st (x * y) = st(x) * st(y)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1677
apply (frule HFinite_st_Infinitesimal_add)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1678
apply (frule_tac x = y in HFinite_st_Infinitesimal_add, safe)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1679
apply (subgoal_tac "st (x * y) = st ((st x + e) * (st y + ea))")
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1680
apply (drule_tac [2] sym, drule_tac [2] sym)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1681
 prefer 2 apply simp 
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1682
apply (erule_tac V = "x = st x + e" in thin_rl)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1683
apply (erule_tac V = "y = st y + ea" in thin_rl)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1684
apply (simp add: left_distrib right_distrib)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1685
apply (drule st_SReal)+
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1686
apply (simp (no_asm_use) add: hypreal_add_assoc)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1687
apply (rule st_Infinitesimal_add_SReal)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1688
apply (blast intro!: SReal_mult)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1689
apply (drule SReal_subset_HFinite [THEN subsetD])+
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1690
apply (rule hypreal_add_assoc [THEN subst])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1691
apply (blast intro!: lemma_st_mult)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1692
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1693
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1694
lemma st_Infinitesimal: "x \<in> Infinitesimal ==> st x = 0"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1695
apply (subst hypreal_numeral_0_eq_0 [symmetric])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1696
apply (rule st_number_of [THEN subst])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1697
apply (rule approx_st_eq)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1698
apply (auto intro: Infinitesimal_subset_HFinite [THEN subsetD] simp add: mem_infmal_iff [symmetric])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1699
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1700
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1701
lemma st_not_Infinitesimal: "st(x) \<noteq> 0 ==> x \<notin> Infinitesimal"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1702
by (fast intro: st_Infinitesimal)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1703
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1704
lemma st_inverse: "[| x \<in> HFinite; st x \<noteq> 0 |]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1705
      ==> st(inverse x) = inverse (st x)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1706
apply (rule_tac c1 = "st x" in hypreal_mult_left_cancel [THEN iffD1])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1707
apply (auto simp add: st_mult [symmetric] st_not_Infinitesimal HFinite_inverse)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1708
apply (subst hypreal_mult_inverse, auto)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1709
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1710
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1711
lemma st_divide: "[| x \<in> HFinite; y \<in> HFinite; st y \<noteq> 0 |]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1712
      ==> st(x/y) = (st x) / (st y)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1713
apply (auto simp add: hypreal_divide_def st_mult st_not_Infinitesimal HFinite_inverse st_inverse)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1714
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1715
declare st_divide [simp]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1716
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1717
lemma st_idempotent: "x \<in> HFinite ==> st(st(x)) = st(x)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1718
by (blast intro: st_HFinite st_approx_self approx_st_eq)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1719
declare st_idempotent [simp]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1720
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1721
(*** lemmas ***)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1722
lemma Infinitesimal_add_st_less: "[| x \<in> HFinite; y \<in> HFinite;
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1723
         u \<in> Infinitesimal; st x < st y
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1724
      |] ==> st x + u < st y"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1725
apply (drule st_SReal)+
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1726
apply (auto intro!: Infinitesimal_add_hypreal_of_real_less simp add: SReal_iff)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1727
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1728
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1729
lemma Infinitesimal_add_st_le_cancel: "[| x \<in> HFinite; y \<in> HFinite;
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1730
         u \<in> Infinitesimal; st x <= st y + u
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1731
      |] ==> st x <= st y"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1732
apply (simp add: linorder_not_less [symmetric])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1733
apply (auto dest: Infinitesimal_add_st_less)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1734
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1735
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1736
lemma st_le: "[| x \<in> HFinite; y \<in> HFinite; x <= y |] ==> st(x) <= st(y)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1737
apply (frule HFinite_st_Infinitesimal_add)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1738
apply (rotate_tac 1)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1739
apply (frule HFinite_st_Infinitesimal_add, safe)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1740
apply (rule Infinitesimal_add_st_le_cancel)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1741
apply (rule_tac [3] x = ea and y = e in Infinitesimal_diff)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1742
apply (auto simp add: hypreal_add_assoc [symmetric])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1743
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1744
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1745
lemma st_zero_le: "[| 0 <= x;  x \<in> HFinite |] ==> 0 <= st x"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1746
apply (subst hypreal_numeral_0_eq_0 [symmetric])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1747
apply (rule st_number_of [THEN subst])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1748
apply (rule st_le, auto)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1749
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1750
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1751
lemma st_zero_ge: "[| x <= 0;  x \<in> HFinite |] ==> st x <= 0"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1752
apply (subst hypreal_numeral_0_eq_0 [symmetric])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1753
apply (rule st_number_of [THEN subst])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1754
apply (rule st_le, auto)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1755
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1756
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1757
lemma st_hrabs: "x \<in> HFinite ==> abs(st x) = st(abs x)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1758
apply (simp add: linorder_not_le st_zero_le abs_if st_minus
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1759
   linorder_not_less)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1760
apply (auto dest!: st_zero_ge [OF order_less_imp_le]) 
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1761
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1762
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1763
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1764
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1765
(*--------------------------------------------------------------------
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1766
   Alternative definitions for HFinite using Free ultrafilter
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1767
 --------------------------------------------------------------------*)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1768
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1769
lemma FreeUltrafilterNat_Rep_hypreal: "[| X \<in> Rep_hypreal x; Y \<in> Rep_hypreal x |]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1770
      ==> {n. X n = Y n} \<in> FreeUltrafilterNat"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1771
apply (rule_tac z = x in eq_Abs_hypreal, auto, ultra)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1772
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1773
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1774
lemma HFinite_FreeUltrafilterNat:
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1775
    "x \<in> HFinite 
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1776
     ==> \<exists>X \<in> Rep_hypreal x. \<exists>u. {n. abs (X n) < u} \<in> FreeUltrafilterNat"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1777
apply (rule eq_Abs_hypreal [of x])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1778
apply (auto simp add: HFinite_def abs_less_iff minus_less_iff [of x] 
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1779
              hypreal_less SReal_iff hypreal_minus hypreal_of_real_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1780
apply (rule_tac x=x in bexI) 
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1781
apply (rule_tac x=y in exI, auto, ultra)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1782
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1783
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1784
lemma FreeUltrafilterNat_HFinite:
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1785
     "\<exists>X \<in> Rep_hypreal x.
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1786
       \<exists>u. {n. abs (X n) < u} \<in> FreeUltrafilterNat
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1787
       ==>  x \<in> HFinite"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1788
apply (rule eq_Abs_hypreal [of x])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1789
apply (auto simp add: HFinite_def abs_less_iff minus_less_iff [of x])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1790
apply (rule_tac x = "hypreal_of_real u" in bexI)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1791
apply (auto simp add: hypreal_less SReal_iff hypreal_minus hypreal_of_real_def, ultra+)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1792
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1793
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1794
lemma HFinite_FreeUltrafilterNat_iff: "(x \<in> HFinite) = (\<exists>X \<in> Rep_hypreal x.
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1795
           \<exists>u. {n. abs (X n) < u} \<in> FreeUltrafilterNat)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1796
apply (blast intro!: HFinite_FreeUltrafilterNat FreeUltrafilterNat_HFinite)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1797
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1798
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1799
(*--------------------------------------------------------------------
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1800
   Alternative definitions for HInfinite using Free ultrafilter
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1801
 --------------------------------------------------------------------*)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1802
lemma lemma_Compl_eq: "- {n. (u::real) < abs (xa n)} = {n. abs (xa n) <= u}"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1803
by auto
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1804
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1805
lemma lemma_Compl_eq2: "- {n. abs (xa n) < (u::real)} = {n. u <= abs (xa n)}"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1806
by auto
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1807
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1808
lemma lemma_Int_eq1: "{n. abs (xa n) <= (u::real)} Int {n. u <= abs (xa n)}
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1809
          = {n. abs(xa n) = u}"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1810
apply auto
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1811
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1812
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1813
lemma lemma_FreeUltrafilterNat_one: "{n. abs (xa n) = u} <= {n. abs (xa n) < u + (1::real)}"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1814
by auto
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1815
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1816
(*-------------------------------------
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1817
  Exclude this type of sets from free
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1818
  ultrafilter for Infinite numbers!
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1819
 -------------------------------------*)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1820
lemma FreeUltrafilterNat_const_Finite: "[| xa: Rep_hypreal x;
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1821
                  {n. abs (xa n) = u} \<in> FreeUltrafilterNat
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1822
               |] ==> x \<in> HFinite"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1823
apply (rule FreeUltrafilterNat_HFinite)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1824
apply (rule_tac x = xa in bexI)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1825
apply (rule_tac x = "u + 1" in exI)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1826
apply (ultra, assumption)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1827
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1828
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1829
lemma HInfinite_FreeUltrafilterNat:
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1830
     "x \<in> HInfinite ==> \<exists>X \<in> Rep_hypreal x.
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1831
           \<forall>u. {n. u < abs (X n)} \<in> FreeUltrafilterNat"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1832
apply (frule HInfinite_HFinite_iff [THEN iffD1])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1833
apply (cut_tac x = x in Rep_hypreal_nonempty)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1834
apply (auto simp del: Rep_hypreal_nonempty simp add: HFinite_FreeUltrafilterNat_iff Bex_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1835
apply (drule spec)+
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1836
apply auto
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1837
apply (drule_tac x = u in spec)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1838
apply (drule FreeUltrafilterNat_Compl_mem)+
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1839
apply (drule FreeUltrafilterNat_Int, assumption)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1840
apply (simp add: lemma_Compl_eq lemma_Compl_eq2 lemma_Int_eq1)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1841
apply (auto dest: FreeUltrafilterNat_const_Finite simp
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1842
      add: HInfinite_HFinite_iff [THEN iffD1])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1843
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1844
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1845
(* yet more lemmas! *)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1846
lemma lemma_Int_HI: "{n. abs (Xa n) < u} Int {n. X n = Xa n}
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1847
          <= {n. abs (X n) < (u::real)}"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1848
apply auto
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1849
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1850
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1851
lemma lemma_Int_HIa: "{n. u < abs (X n)} Int {n. abs (X n) < (u::real)} = {}"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1852
by (auto intro: order_less_asym)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1853
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1854
lemma FreeUltrafilterNat_HInfinite: "\<exists>X \<in> Rep_hypreal x. \<forall>u.
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1855
               {n. u < abs (X n)} \<in> FreeUltrafilterNat
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1856
               ==>  x \<in> HInfinite"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1857
apply (rule HInfinite_HFinite_iff [THEN iffD2])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1858
apply (safe, drule HFinite_FreeUltrafilterNat, auto)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1859
apply (drule_tac x = u in spec)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1860
apply (drule FreeUltrafilterNat_Rep_hypreal, assumption)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1861
apply (drule_tac Y = "{n. X n = Xa n}" in FreeUltrafilterNat_Int, simp) 
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1862
apply (drule lemma_Int_HI [THEN [2] FreeUltrafilterNat_subset])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1863
apply (drule_tac Y = "{n. abs (X n) < u}" in FreeUltrafilterNat_Int)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1864
apply (auto simp add: lemma_Int_HIa FreeUltrafilterNat_empty)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1865
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1866
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1867
lemma HInfinite_FreeUltrafilterNat_iff: "(x \<in> HInfinite) = (\<exists>X \<in> Rep_hypreal x.
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1868
           \<forall>u. {n. u < abs (X n)} \<in> FreeUltrafilterNat)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1869
apply (blast intro!: HInfinite_FreeUltrafilterNat FreeUltrafilterNat_HInfinite)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1870
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1871
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1872
(*--------------------------------------------------------------------
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1873
   Alternative definitions for Infinitesimal using Free ultrafilter
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1874
 --------------------------------------------------------------------*)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1875
10751
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
  1876
14370
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1877
lemma Infinitesimal_FreeUltrafilterNat:
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1878
          "x \<in> Infinitesimal ==> \<exists>X \<in> Rep_hypreal x.
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1879
           \<forall>u. 0 < u --> {n. abs (X n) < u} \<in> FreeUltrafilterNat"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1880
apply (simp add: Infinitesimal_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1881
apply (auto simp add: abs_less_iff minus_less_iff [of x])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1882
apply (rule eq_Abs_hypreal [of x])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1883
apply (auto, rule bexI [OF _ lemma_hyprel_refl], safe)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1884
apply (drule hypreal_of_real_less_iff [THEN iffD2])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1885
apply (drule_tac x = "hypreal_of_real u" in bspec, auto)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1886
apply (auto simp add: hypreal_less hypreal_minus hypreal_of_real_def, ultra)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1887
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1888
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1889
lemma FreeUltrafilterNat_Infinitesimal:
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1890
     "\<exists>X \<in> Rep_hypreal x.
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1891
            \<forall>u. 0 < u --> {n. abs (X n) < u} \<in> FreeUltrafilterNat
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1892
      ==> x \<in> Infinitesimal"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1893
apply (simp add: Infinitesimal_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1894
apply (rule eq_Abs_hypreal [of x])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1895
apply (auto simp add: abs_less_iff abs_interval_iff minus_less_iff [of x])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1896
apply (auto simp add: SReal_iff)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1897
apply (drule_tac [!] x=y in spec) 
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1898
apply (auto simp add: hypreal_less hypreal_minus hypreal_of_real_def, ultra+)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1899
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1900
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1901
lemma Infinitesimal_FreeUltrafilterNat_iff: "(x \<in> Infinitesimal) = (\<exists>X \<in> Rep_hypreal x.
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1902
           \<forall>u. 0 < u --> {n. abs (X n) < u} \<in> FreeUltrafilterNat)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1903
apply (blast intro!: Infinitesimal_FreeUltrafilterNat FreeUltrafilterNat_Infinitesimal)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1904
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1905
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1906
(*------------------------------------------------------------------------
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1907
         Infinitesimals as smaller than 1/n for all n::nat (> 0)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1908
 ------------------------------------------------------------------------*)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1909
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1910
lemma lemma_Infinitesimal: "(\<forall>r. 0 < r --> x < r) = (\<forall>n. x < inverse(real (Suc n)))"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1911
apply (auto simp add: real_of_nat_Suc_gt_zero)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1912
apply (blast dest!: reals_Archimedean intro: order_less_trans)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1913
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1914
14378
69c4d5997669 generic of_nat and of_int functions, and generalization of iszero
paulson
parents: 14371
diff changeset
  1915
lemma of_nat_in_Reals [simp]: "(of_nat n::hypreal) \<in> \<real>"
69c4d5997669 generic of_nat and of_int functions, and generalization of iszero
paulson
parents: 14371
diff changeset
  1916
apply (induct n)
69c4d5997669 generic of_nat and of_int functions, and generalization of iszero
paulson
parents: 14371
diff changeset
  1917
apply (simp_all add: SReal_add);
69c4d5997669 generic of_nat and of_int functions, and generalization of iszero
paulson
parents: 14371
diff changeset
  1918
done 
69c4d5997669 generic of_nat and of_int functions, and generalization of iszero
paulson
parents: 14371
diff changeset
  1919
 
14370
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1920
lemma lemma_Infinitesimal2: "(\<forall>r \<in> Reals. 0 < r --> x < r) =
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1921
      (\<forall>n. x < inverse(hypreal_of_nat (Suc n)))"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1922
apply safe
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1923
apply (drule_tac x = "inverse (hypreal_of_real (real (Suc n))) " in bspec)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1924
apply (simp (no_asm_use) add: SReal_inverse)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1925
apply (rule real_of_nat_Suc_gt_zero [THEN positive_imp_inverse_positive, THEN hypreal_of_real_less_iff [THEN iffD2], THEN [2] impE])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1926
prefer 2 apply assumption
14378
69c4d5997669 generic of_nat and of_int functions, and generalization of iszero
paulson
parents: 14371
diff changeset
  1927
apply (simp add: real_of_nat_Suc_gt_zero hypreal_of_nat_eq)
14370
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1928
apply (auto dest!: reals_Archimedean simp add: SReal_iff)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1929
apply (drule hypreal_of_real_less_iff [THEN iffD2])
14378
69c4d5997669 generic of_nat and of_int functions, and generalization of iszero
paulson
parents: 14371
diff changeset
  1930
apply (simp add: real_of_nat_Suc_gt_zero hypreal_of_nat_eq)
14370
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1931
apply (blast intro: order_less_trans)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1932
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1933
14378
69c4d5997669 generic of_nat and of_int functions, and generalization of iszero
paulson
parents: 14371
diff changeset
  1934
14370
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1935
lemma Infinitesimal_hypreal_of_nat_iff:
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1936
     "Infinitesimal = {x. \<forall>n. abs x < inverse (hypreal_of_nat (Suc n))}"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1937
apply (simp add: Infinitesimal_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1938
apply (auto simp add: lemma_Infinitesimal2)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1939
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1940
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1941
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1942
(*-------------------------------------------------------------------------
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1943
       Proof that omega is an infinite number and
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1944
       hence that epsilon is an infinitesimal number.
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1945
 -------------------------------------------------------------------------*)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1946
lemma Suc_Un_eq: "{n. n < Suc m} = {n. n < m} Un {n. n = m}"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1947
by (auto simp add: less_Suc_eq)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1948
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1949
(*-------------------------------------------
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1950
  Prove that any segment is finite and
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1951
  hence cannot belong to FreeUltrafilterNat
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1952
 -------------------------------------------*)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1953
lemma finite_nat_segment: "finite {n::nat. n < m}"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1954
apply (induct_tac "m")
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1955
apply (auto simp add: Suc_Un_eq)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1956
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1957
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1958
lemma finite_real_of_nat_segment: "finite {n::nat. real n < real (m::nat)}"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1959
by (auto intro: finite_nat_segment)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1960
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1961
lemma finite_real_of_nat_less_real: "finite {n::nat. real n < u}"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1962
apply (cut_tac x = u in reals_Archimedean2, safe)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1963
apply (rule finite_real_of_nat_segment [THEN [2] finite_subset])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1964
apply (auto dest: order_less_trans)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1965
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1966
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1967
lemma lemma_real_le_Un_eq: "{n. f n <= u} = {n. f n < u} Un {n. u = (f n :: real)}"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1968
by (auto dest: order_le_imp_less_or_eq simp add: order_less_imp_le)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1969
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1970
lemma finite_real_of_nat_le_real: "finite {n::nat. real n <= u}"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1971
by (auto simp add: lemma_real_le_Un_eq lemma_finite_omega_set finite_real_of_nat_less_real)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1972
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1973
lemma finite_rabs_real_of_nat_le_real: "finite {n::nat. abs(real n) <= u}"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1974
apply (simp (no_asm) add: real_of_nat_Suc_gt_zero finite_real_of_nat_le_real)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1975
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1976
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1977
lemma rabs_real_of_nat_le_real_FreeUltrafilterNat: "{n. abs(real n) <= u} \<notin> FreeUltrafilterNat"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1978
by (blast intro!: FreeUltrafilterNat_finite finite_rabs_real_of_nat_le_real)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1979
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1980
lemma FreeUltrafilterNat_nat_gt_real: "{n. u < real n} \<in> FreeUltrafilterNat"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1981
apply (rule ccontr, drule FreeUltrafilterNat_Compl_mem)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1982
apply (subgoal_tac "- {n::nat. u < real n} = {n. real n <= u}")
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1983
prefer 2 apply force
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1984
apply (simp add: finite_real_of_nat_le_real [THEN FreeUltrafilterNat_finite])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1985
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1986
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1987
(*--------------------------------------------------------------
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1988
 The complement of {n. abs(real n) <= u} =
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1989
 {n. u < abs (real n)} is in FreeUltrafilterNat
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1990
 by property of (free) ultrafilters
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1991
 --------------------------------------------------------------*)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1992
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1993
lemma Compl_real_le_eq: "- {n::nat. real n <= u} = {n. u < real n}"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1994
by (auto dest!: order_le_less_trans simp add: linorder_not_le)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1995
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1996
(*-----------------------------------------------
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1997
       Omega is a member of HInfinite
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1998
 -----------------------------------------------*)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  1999
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2000
lemma hypreal_omega: "hyprel``{%n::nat. real (Suc n)} \<in> hypreal"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2001
by auto
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2002
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2003
lemma FreeUltrafilterNat_omega: "{n. u < real n} \<in> FreeUltrafilterNat"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2004
apply (cut_tac u = u in rabs_real_of_nat_le_real_FreeUltrafilterNat)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2005
apply (auto dest: FreeUltrafilterNat_Compl_mem simp add: Compl_real_le_eq)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2006
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2007
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2008
lemma HInfinite_omega: "omega: HInfinite"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2009
apply (simp add: omega_def)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2010
apply (auto intro!: FreeUltrafilterNat_HInfinite)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2011
apply (rule bexI)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2012
apply (rule_tac [2] lemma_hyprel_refl, auto)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2013
apply (simp (no_asm) add: real_of_nat_Suc diff_less_eq [symmetric] FreeUltrafilterNat_omega)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2014
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2015
declare HInfinite_omega [simp]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2016
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2017
(*-----------------------------------------------
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2018
       Epsilon is a member of Infinitesimal
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2019
 -----------------------------------------------*)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2020
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2021
lemma Infinitesimal_epsilon: "epsilon \<in> Infinitesimal"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2022
by (auto intro!: HInfinite_inverse_Infinitesimal HInfinite_omega simp add: hypreal_epsilon_inverse_omega)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2023
declare Infinitesimal_epsilon [simp]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2024
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2025
lemma HFinite_epsilon: "epsilon \<in> HFinite"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2026
by (auto intro: Infinitesimal_subset_HFinite [THEN subsetD])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2027
declare HFinite_epsilon [simp]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2028
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2029
lemma epsilon_approx_zero: "epsilon @= 0"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2030
apply (simp (no_asm) add: mem_infmal_iff [symmetric])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2031
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2032
declare epsilon_approx_zero [simp]
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2033
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2034
(*------------------------------------------------------------------------
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2035
  Needed for proof that we define a hyperreal [<X(n)] @= hypreal_of_real a given
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2036
  that \<forall>n. |X n - a| < 1/n. Used in proof of NSLIM => LIM.
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2037
 -----------------------------------------------------------------------*)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2038
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2039
lemma real_of_nat_less_inverse_iff: "0 < u  ==>
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2040
      (u < inverse (real(Suc n))) = (real(Suc n) < inverse u)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2041
apply (simp add: inverse_eq_divide)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2042
apply (subst pos_less_divide_eq, assumption)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2043
apply (subst pos_less_divide_eq)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2044
 apply (simp add: real_of_nat_Suc_gt_zero)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2045
apply (simp add: real_mult_commute)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2046
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2047
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2048
lemma finite_inverse_real_of_posnat_gt_real: "0 < u ==> finite {n. u < inverse(real(Suc n))}"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2049
apply (simp (no_asm_simp) add: real_of_nat_less_inverse_iff)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2050
apply (simp (no_asm_simp) add: real_of_nat_Suc less_diff_eq [symmetric])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2051
apply (rule finite_real_of_nat_less_real)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2052
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2053
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2054
lemma lemma_real_le_Un_eq2: "{n. u <= inverse(real(Suc n))} =
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2055
     {n. u < inverse(real(Suc n))} Un {n. u = inverse(real(Suc n))}"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2056
apply (auto dest: order_le_imp_less_or_eq simp add: order_less_imp_le)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2057
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2058
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2059
lemma real_of_nat_inverse_le_iff: "(inverse (real(Suc n)) <= r) = (1 <= r * real(Suc n))"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2060
apply (simp (no_asm) add: linorder_not_less [symmetric])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2061
apply (simp (no_asm) add: inverse_eq_divide)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2062
apply (subst pos_less_divide_eq)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2063
apply (simp (no_asm) add: real_of_nat_Suc_gt_zero)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2064
apply (simp (no_asm) add: real_mult_commute)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2065
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2066
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2067
lemma real_of_nat_inverse_eq_iff: "(u = inverse (real(Suc n))) = (real(Suc n) = inverse u)"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2068
by (auto simp add: inverse_inverse_eq real_of_nat_Suc_gt_zero real_not_refl2 [THEN not_sym])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2069
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2070
lemma lemma_finite_omega_set2: "finite {n::nat. u = inverse(real(Suc n))}"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2071
apply (simp (no_asm_simp) add: real_of_nat_inverse_eq_iff)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2072
apply (cut_tac x = "inverse u - 1" in lemma_finite_omega_set)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2073
apply (simp add: real_of_nat_Suc diff_eq_eq [symmetric] eq_commute)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2074
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2075
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2076
lemma finite_inverse_real_of_posnat_ge_real: "0 < u ==> finite {n. u <= inverse(real(Suc n))}"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2077
by (auto simp add: lemma_real_le_Un_eq2 lemma_finite_omega_set2 finite_inverse_real_of_posnat_gt_real)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2078
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2079
lemma inverse_real_of_posnat_ge_real_FreeUltrafilterNat: "0 < u ==>
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2080
       {n. u <= inverse(real(Suc n))} \<notin> FreeUltrafilterNat"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2081
apply (blast intro!: FreeUltrafilterNat_finite finite_inverse_real_of_posnat_ge_real)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2082
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2083
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2084
(*--------------------------------------------------------------
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2085
    The complement of  {n. u <= inverse(real(Suc n))} =
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2086
    {n. inverse(real(Suc n)) < u} is in FreeUltrafilterNat
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2087
    by property of (free) ultrafilters
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2088
 --------------------------------------------------------------*)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2089
lemma Compl_le_inverse_eq: "- {n. u <= inverse(real(Suc n))} =
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2090
      {n. inverse(real(Suc n)) < u}"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2091
apply (auto dest!: order_le_less_trans simp add: linorder_not_le)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2092
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2093
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2094
lemma FreeUltrafilterNat_inverse_real_of_posnat: "0 < u ==>
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2095
      {n. inverse(real(Suc n)) < u} \<in> FreeUltrafilterNat"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2096
apply (cut_tac u = u in inverse_real_of_posnat_ge_real_FreeUltrafilterNat)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2097
apply (auto dest: FreeUltrafilterNat_Compl_mem simp add: Compl_le_inverse_eq)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2098
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2099
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2100
(*--------------------------------------------------------------
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2101
      Example where we get a hyperreal from a real sequence
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2102
      for which a particular property holds. The theorem is
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2103
      used in proofs about equivalence of nonstandard and
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2104
      standard neighbourhoods. Also used for equivalence of
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2105
      nonstandard ans standard definitions of pointwise
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2106
      limit (the theorem was previously in REALTOPOS.thy).
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2107
 -------------------------------------------------------------*)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2108
(*-----------------------------------------------------
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2109
    |X(n) - x| < 1/n ==> [<X n>] - hypreal_of_real x| \<in> Infinitesimal
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2110
 -----------------------------------------------------*)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2111
lemma real_seq_to_hypreal_Infinitesimal: "\<forall>n. abs(X n + -x) < inverse(real(Suc n))
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2112
     ==> Abs_hypreal(hyprel``{X}) + -hypreal_of_real x \<in> Infinitesimal"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2113
apply (auto intro!: bexI dest: FreeUltrafilterNat_inverse_real_of_posnat FreeUltrafilterNat_all FreeUltrafilterNat_Int intro: order_less_trans FreeUltrafilterNat_subset simp add: hypreal_minus hypreal_of_real_def hypreal_add Infinitesimal_FreeUltrafilterNat_iff hypreal_inverse)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2114
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2115
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2116
lemma real_seq_to_hypreal_approx: "\<forall>n. abs(X n + -x) < inverse(real(Suc n))
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2117
      ==> Abs_hypreal(hyprel``{X}) @= hypreal_of_real x"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2118
apply (subst approx_minus_iff)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2119
apply (rule mem_infmal_iff [THEN subst])
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2120
apply (erule real_seq_to_hypreal_Infinitesimal)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2121
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2122
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2123
lemma real_seq_to_hypreal_approx2: "\<forall>n. abs(x + -X n) < inverse(real(Suc n))
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2124
               ==> Abs_hypreal(hyprel``{X}) @= hypreal_of_real x"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2125
apply (simp add: abs_minus_add_cancel real_seq_to_hypreal_approx)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2126
done
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2127
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2128
lemma real_seq_to_hypreal_Infinitesimal2: "\<forall>n. abs(X n + -Y n) < inverse(real(Suc n))
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2129
      ==> Abs_hypreal(hyprel``{X}) +
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2130
          -Abs_hypreal(hyprel``{Y}) \<in> Infinitesimal"
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2131
by (auto intro!: bexI
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2132
	 dest: FreeUltrafilterNat_inverse_real_of_posnat 
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2133
	       FreeUltrafilterNat_all FreeUltrafilterNat_Int
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2134
	 intro: order_less_trans FreeUltrafilterNat_subset 
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2135
	 simp add: Infinitesimal_FreeUltrafilterNat_iff hypreal_minus 
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2136
                   hypreal_add hypreal_inverse)
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2137
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2138
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2139
ML
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2140
{*
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2141
val Infinitesimal_def = thm"Infinitesimal_def";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2142
val HFinite_def = thm"HFinite_def";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2143
val HInfinite_def = thm"HInfinite_def";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2144
val st_def = thm"st_def";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2145
val monad_def = thm"monad_def";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2146
val galaxy_def = thm"galaxy_def";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2147
val approx_def = thm"approx_def";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2148
val SReal_def = thm"SReal_def";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2149
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2150
val Infinitesimal_approx_minus = thm "Infinitesimal_approx_minus";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2151
val approx_monad_iff = thm "approx_monad_iff";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2152
val Infinitesimal_approx = thm "Infinitesimal_approx";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2153
val approx_add = thm "approx_add";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2154
val approx_minus = thm "approx_minus";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2155
val approx_minus2 = thm "approx_minus2";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2156
val approx_minus_cancel = thm "approx_minus_cancel";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2157
val approx_add_minus = thm "approx_add_minus";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2158
val approx_mult1 = thm "approx_mult1";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2159
val approx_mult2 = thm "approx_mult2";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2160
val approx_mult_subst = thm "approx_mult_subst";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2161
val approx_mult_subst2 = thm "approx_mult_subst2";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2162
val approx_mult_subst_SReal = thm "approx_mult_subst_SReal";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2163
val approx_eq_imp = thm "approx_eq_imp";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2164
val Infinitesimal_minus_approx = thm "Infinitesimal_minus_approx";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2165
val bex_Infinitesimal_iff = thm "bex_Infinitesimal_iff";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2166
val bex_Infinitesimal_iff2 = thm "bex_Infinitesimal_iff2";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2167
val Infinitesimal_add_approx = thm "Infinitesimal_add_approx";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2168
val Infinitesimal_add_approx_self = thm "Infinitesimal_add_approx_self";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2169
val Infinitesimal_add_approx_self2 = thm "Infinitesimal_add_approx_self2";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2170
val Infinitesimal_add_minus_approx_self = thm "Infinitesimal_add_minus_approx_self";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2171
val Infinitesimal_add_cancel = thm "Infinitesimal_add_cancel";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2172
val Infinitesimal_add_right_cancel = thm "Infinitesimal_add_right_cancel";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2173
val approx_add_left_cancel = thm "approx_add_left_cancel";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2174
val approx_add_right_cancel = thm "approx_add_right_cancel";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2175
val approx_add_mono1 = thm "approx_add_mono1";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2176
val approx_add_mono2 = thm "approx_add_mono2";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2177
val approx_add_left_iff = thm "approx_add_left_iff";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2178
val approx_add_right_iff = thm "approx_add_right_iff";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2179
val approx_HFinite = thm "approx_HFinite";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2180
val approx_hypreal_of_real_HFinite = thm "approx_hypreal_of_real_HFinite";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2181
val approx_mult_HFinite = thm "approx_mult_HFinite";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2182
val approx_mult_hypreal_of_real = thm "approx_mult_hypreal_of_real";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2183
val approx_SReal_mult_cancel_zero = thm "approx_SReal_mult_cancel_zero";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2184
val approx_mult_SReal1 = thm "approx_mult_SReal1";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2185
val approx_mult_SReal2 = thm "approx_mult_SReal2";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2186
val approx_mult_SReal_zero_cancel_iff = thm "approx_mult_SReal_zero_cancel_iff";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2187
val approx_SReal_mult_cancel = thm "approx_SReal_mult_cancel";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2188
val approx_SReal_mult_cancel_iff1 = thm "approx_SReal_mult_cancel_iff1";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2189
val approx_le_bound = thm "approx_le_bound";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2190
val Infinitesimal_less_SReal = thm "Infinitesimal_less_SReal";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2191
val Infinitesimal_less_SReal2 = thm "Infinitesimal_less_SReal2";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2192
val SReal_not_Infinitesimal = thm "SReal_not_Infinitesimal";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2193
val SReal_minus_not_Infinitesimal = thm "SReal_minus_not_Infinitesimal";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2194
val SReal_Int_Infinitesimal_zero = thm "SReal_Int_Infinitesimal_zero";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2195
val SReal_Infinitesimal_zero = thm "SReal_Infinitesimal_zero";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2196
val SReal_HFinite_diff_Infinitesimal = thm "SReal_HFinite_diff_Infinitesimal";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2197
val hypreal_of_real_HFinite_diff_Infinitesimal = thm "hypreal_of_real_HFinite_diff_Infinitesimal";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2198
val hypreal_of_real_Infinitesimal_iff_0 = thm "hypreal_of_real_Infinitesimal_iff_0";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2199
val number_of_not_Infinitesimal = thm "number_of_not_Infinitesimal";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2200
val one_not_Infinitesimal = thm "one_not_Infinitesimal";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2201
val approx_SReal_not_zero = thm "approx_SReal_not_zero";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2202
val HFinite_diff_Infinitesimal_approx = thm "HFinite_diff_Infinitesimal_approx";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2203
val Infinitesimal_ratio = thm "Infinitesimal_ratio";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2204
val SReal_approx_iff = thm "SReal_approx_iff";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2205
val number_of_approx_iff = thm "number_of_approx_iff";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2206
val hypreal_of_real_approx_iff = thm "hypreal_of_real_approx_iff";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2207
val hypreal_of_real_approx_number_of_iff = thm "hypreal_of_real_approx_number_of_iff";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2208
val approx_unique_real = thm "approx_unique_real";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2209
val hypreal_isLub_unique = thm "hypreal_isLub_unique";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2210
val hypreal_setle_less_trans = thm "hypreal_setle_less_trans";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2211
val hypreal_gt_isUb = thm "hypreal_gt_isUb";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2212
val st_part_Ex = thm "st_part_Ex";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2213
val st_part_Ex1 = thm "st_part_Ex1";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2214
val HFinite_Int_HInfinite_empty = thm "HFinite_Int_HInfinite_empty";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2215
val HFinite_not_HInfinite = thm "HFinite_not_HInfinite";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2216
val not_HFinite_HInfinite = thm "not_HFinite_HInfinite";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2217
val HInfinite_HFinite_disj = thm "HInfinite_HFinite_disj";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2218
val HInfinite_HFinite_iff = thm "HInfinite_HFinite_iff";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2219
val HFinite_HInfinite_iff = thm "HFinite_HInfinite_iff";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2220
val HInfinite_diff_HFinite_Infinitesimal_disj = thm "HInfinite_diff_HFinite_Infinitesimal_disj";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2221
val HFinite_inverse = thm "HFinite_inverse";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2222
val HFinite_inverse2 = thm "HFinite_inverse2";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2223
val Infinitesimal_inverse_HFinite = thm "Infinitesimal_inverse_HFinite";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2224
val HFinite_not_Infinitesimal_inverse = thm "HFinite_not_Infinitesimal_inverse";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2225
val approx_inverse = thm "approx_inverse";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2226
val hypreal_of_real_approx_inverse = thm "hypreal_of_real_approx_inverse";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2227
val inverse_add_Infinitesimal_approx = thm "inverse_add_Infinitesimal_approx";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2228
val inverse_add_Infinitesimal_approx2 = thm "inverse_add_Infinitesimal_approx2";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2229
val inverse_add_Infinitesimal_approx_Infinitesimal = thm "inverse_add_Infinitesimal_approx_Infinitesimal";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2230
val Infinitesimal_square_iff = thm "Infinitesimal_square_iff";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2231
val HFinite_square_iff = thm "HFinite_square_iff";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2232
val HInfinite_square_iff = thm "HInfinite_square_iff";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2233
val approx_HFinite_mult_cancel = thm "approx_HFinite_mult_cancel";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2234
val approx_HFinite_mult_cancel_iff1 = thm "approx_HFinite_mult_cancel_iff1";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2235
val approx_hrabs_disj = thm "approx_hrabs_disj";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2236
val monad_hrabs_Un_subset = thm "monad_hrabs_Un_subset";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2237
val Infinitesimal_monad_eq = thm "Infinitesimal_monad_eq";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2238
val mem_monad_iff = thm "mem_monad_iff";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2239
val Infinitesimal_monad_zero_iff = thm "Infinitesimal_monad_zero_iff";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2240
val monad_zero_minus_iff = thm "monad_zero_minus_iff";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2241
val monad_zero_hrabs_iff = thm "monad_zero_hrabs_iff";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2242
val mem_monad_self = thm "mem_monad_self";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2243
val approx_subset_monad = thm "approx_subset_monad";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2244
val approx_subset_monad2 = thm "approx_subset_monad2";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2245
val mem_monad_approx = thm "mem_monad_approx";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2246
val approx_mem_monad = thm "approx_mem_monad";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2247
val approx_mem_monad2 = thm "approx_mem_monad2";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2248
val approx_mem_monad_zero = thm "approx_mem_monad_zero";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2249
val Infinitesimal_approx_hrabs = thm "Infinitesimal_approx_hrabs";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2250
val less_Infinitesimal_less = thm "less_Infinitesimal_less";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2251
val Ball_mem_monad_gt_zero = thm "Ball_mem_monad_gt_zero";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2252
val Ball_mem_monad_less_zero = thm "Ball_mem_monad_less_zero";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2253
val approx_hrabs1 = thm "approx_hrabs1";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2254
val approx_hrabs2 = thm "approx_hrabs2";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2255
val approx_hrabs = thm "approx_hrabs";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2256
val approx_hrabs_zero_cancel = thm "approx_hrabs_zero_cancel";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2257
val approx_hrabs_add_Infinitesimal = thm "approx_hrabs_add_Infinitesimal";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2258
val approx_hrabs_add_minus_Infinitesimal = thm "approx_hrabs_add_minus_Infinitesimal";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2259
val hrabs_add_Infinitesimal_cancel = thm "hrabs_add_Infinitesimal_cancel";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2260
val hrabs_add_minus_Infinitesimal_cancel = thm "hrabs_add_minus_Infinitesimal_cancel";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2261
val hypreal_less_minus_iff = thm "hypreal_less_minus_iff";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2262
val Infinitesimal_add_hypreal_of_real_less = thm "Infinitesimal_add_hypreal_of_real_less";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2263
val Infinitesimal_add_hrabs_hypreal_of_real_less = thm "Infinitesimal_add_hrabs_hypreal_of_real_less";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2264
val Infinitesimal_add_hrabs_hypreal_of_real_less2 = thm "Infinitesimal_add_hrabs_hypreal_of_real_less2";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2265
val hypreal_of_real_le_add_Infininitesimal_cancel2 = thm"hypreal_of_real_le_add_Infininitesimal_cancel2";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2266
val hypreal_of_real_less_Infinitesimal_le_zero = thm "hypreal_of_real_less_Infinitesimal_le_zero";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2267
val Infinitesimal_add_not_zero = thm "Infinitesimal_add_not_zero";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2268
val Infinitesimal_square_cancel = thm "Infinitesimal_square_cancel";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2269
val HFinite_square_cancel = thm "HFinite_square_cancel";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2270
val Infinitesimal_square_cancel2 = thm "Infinitesimal_square_cancel2";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2271
val HFinite_square_cancel2 = thm "HFinite_square_cancel2";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2272
val Infinitesimal_sum_square_cancel = thm "Infinitesimal_sum_square_cancel";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2273
val HFinite_sum_square_cancel = thm "HFinite_sum_square_cancel";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2274
val Infinitesimal_sum_square_cancel2 = thm "Infinitesimal_sum_square_cancel2";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2275
val HFinite_sum_square_cancel2 = thm "HFinite_sum_square_cancel2";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2276
val Infinitesimal_sum_square_cancel3 = thm "Infinitesimal_sum_square_cancel3";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2277
val HFinite_sum_square_cancel3 = thm "HFinite_sum_square_cancel3";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2278
val monad_hrabs_less = thm "monad_hrabs_less";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2279
val mem_monad_SReal_HFinite = thm "mem_monad_SReal_HFinite";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2280
val st_approx_self = thm "st_approx_self";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2281
val st_SReal = thm "st_SReal";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2282
val st_HFinite = thm "st_HFinite";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2283
val st_SReal_eq = thm "st_SReal_eq";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2284
val st_hypreal_of_real = thm "st_hypreal_of_real";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2285
val st_eq_approx = thm "st_eq_approx";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2286
val approx_st_eq = thm "approx_st_eq";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2287
val st_eq_approx_iff = thm "st_eq_approx_iff";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2288
val st_Infinitesimal_add_SReal = thm "st_Infinitesimal_add_SReal";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2289
val st_Infinitesimal_add_SReal2 = thm "st_Infinitesimal_add_SReal2";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2290
val HFinite_st_Infinitesimal_add = thm "HFinite_st_Infinitesimal_add";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2291
val st_add = thm "st_add";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2292
val st_number_of = thm "st_number_of";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2293
val st_minus = thm "st_minus";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2294
val st_diff = thm "st_diff";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2295
val st_mult = thm "st_mult";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2296
val st_Infinitesimal = thm "st_Infinitesimal";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2297
val st_not_Infinitesimal = thm "st_not_Infinitesimal";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2298
val st_inverse = thm "st_inverse";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2299
val st_divide = thm "st_divide";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2300
val st_idempotent = thm "st_idempotent";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2301
val Infinitesimal_add_st_less = thm "Infinitesimal_add_st_less";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2302
val Infinitesimal_add_st_le_cancel = thm "Infinitesimal_add_st_le_cancel";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2303
val st_le = thm "st_le";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2304
val st_zero_le = thm "st_zero_le";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2305
val st_zero_ge = thm "st_zero_ge";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2306
val st_hrabs = thm "st_hrabs";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2307
val FreeUltrafilterNat_HFinite = thm "FreeUltrafilterNat_HFinite";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2308
val HFinite_FreeUltrafilterNat_iff = thm "HFinite_FreeUltrafilterNat_iff";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2309
val FreeUltrafilterNat_const_Finite = thm "FreeUltrafilterNat_const_Finite";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2310
val FreeUltrafilterNat_HInfinite = thm "FreeUltrafilterNat_HInfinite";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2311
val HInfinite_FreeUltrafilterNat_iff = thm "HInfinite_FreeUltrafilterNat_iff";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2312
val Infinitesimal_FreeUltrafilterNat = thm "Infinitesimal_FreeUltrafilterNat";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2313
val FreeUltrafilterNat_Infinitesimal = thm "FreeUltrafilterNat_Infinitesimal";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2314
val Infinitesimal_FreeUltrafilterNat_iff = thm "Infinitesimal_FreeUltrafilterNat_iff";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2315
val Infinitesimal_hypreal_of_nat_iff = thm "Infinitesimal_hypreal_of_nat_iff";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2316
val Suc_Un_eq = thm "Suc_Un_eq";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2317
val finite_nat_segment = thm "finite_nat_segment";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2318
val finite_real_of_nat_segment = thm "finite_real_of_nat_segment";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2319
val finite_real_of_nat_less_real = thm "finite_real_of_nat_less_real";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2320
val finite_real_of_nat_le_real = thm "finite_real_of_nat_le_real";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2321
val finite_rabs_real_of_nat_le_real = thm "finite_rabs_real_of_nat_le_real";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2322
val rabs_real_of_nat_le_real_FreeUltrafilterNat = thm "rabs_real_of_nat_le_real_FreeUltrafilterNat";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2323
val FreeUltrafilterNat_nat_gt_real = thm "FreeUltrafilterNat_nat_gt_real";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2324
val hypreal_omega = thm "hypreal_omega";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2325
val FreeUltrafilterNat_omega = thm "FreeUltrafilterNat_omega";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2326
val HInfinite_omega = thm "HInfinite_omega";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2327
val Infinitesimal_epsilon = thm "Infinitesimal_epsilon";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2328
val HFinite_epsilon = thm "HFinite_epsilon";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2329
val epsilon_approx_zero = thm "epsilon_approx_zero";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2330
val real_of_nat_less_inverse_iff = thm "real_of_nat_less_inverse_iff";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2331
val finite_inverse_real_of_posnat_gt_real = thm "finite_inverse_real_of_posnat_gt_real";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2332
val real_of_nat_inverse_le_iff = thm "real_of_nat_inverse_le_iff";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2333
val real_of_nat_inverse_eq_iff = thm "real_of_nat_inverse_eq_iff";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2334
val finite_inverse_real_of_posnat_ge_real = thm "finite_inverse_real_of_posnat_ge_real";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2335
val inverse_real_of_posnat_ge_real_FreeUltrafilterNat = thm "inverse_real_of_posnat_ge_real_FreeUltrafilterNat";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2336
val FreeUltrafilterNat_inverse_real_of_posnat = thm "FreeUltrafilterNat_inverse_real_of_posnat";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2337
val real_seq_to_hypreal_Infinitesimal = thm "real_seq_to_hypreal_Infinitesimal";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2338
val real_seq_to_hypreal_approx = thm "real_seq_to_hypreal_approx";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2339
val real_seq_to_hypreal_approx2 = thm "real_seq_to_hypreal_approx2";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2340
val real_seq_to_hypreal_Infinitesimal2 = thm "real_seq_to_hypreal_Infinitesimal2";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2341
val HInfinite_HFinite_add = thm "HInfinite_HFinite_add";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2342
val HInfinite_ge_HInfinite = thm "HInfinite_ge_HInfinite";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2343
val Infinitesimal_inverse_HInfinite = thm "Infinitesimal_inverse_HInfinite";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2344
val HInfinite_HFinite_not_Infinitesimal_mult = thm "HInfinite_HFinite_not_Infinitesimal_mult";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2345
val HInfinite_HFinite_not_Infinitesimal_mult2 = thm "HInfinite_HFinite_not_Infinitesimal_mult2";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2346
val HInfinite_gt_SReal = thm "HInfinite_gt_SReal";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2347
val HInfinite_gt_zero_gt_one = thm "HInfinite_gt_zero_gt_one";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2348
val not_HInfinite_one = thm "not_HInfinite_one";
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2349
*}
b0064703967b simplifications in the hyperreals
paulson
parents: 12114
diff changeset
  2350
10751
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
  2351
end
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
  2352
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
  2353
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
  2354
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
  2355