src/HOL/Hyperreal/Lim.thy
author huffman
Thu, 28 Sep 2006 02:50:07 +0200
changeset 20754 9c053a494dc6
parent 20752 09cf0e407a45
child 20755 956a0377a408
permissions -rw-r--r--
add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
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       : Lim.thy
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
     2
    ID          : $Id$
10751
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
     3
    Author      : Jacques D. Fleuriot
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
     4
    Copyright   : 1998  University of Cambridge
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
     5
    Conversion to Isar and new proofs by Lawrence C Paulson, 2004
19023
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
     6
    GMVT by Benjamin Porter, 2005
10751
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
     7
*)
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
     8
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
     9
header{*Limits, Continuity and Differentiation*}
10751
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
    10
15131
c69542757a4d New theory header syntax.
nipkow
parents: 15086
diff changeset
    11
theory Lim
15360
300e09825d8b Added "ALL x > y" and relatives.
nipkow
parents: 15251
diff changeset
    12
imports SEQ
15131
c69542757a4d New theory header syntax.
nipkow
parents: 15086
diff changeset
    13
begin
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
    14
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
    15
text{*Standard and Nonstandard Definitions*}
10751
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
    16
19765
dfe940911617 misc cleanup;
wenzelm
parents: 19023
diff changeset
    17
definition
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
    18
  LIM :: "['a::real_normed_vector => 'b::real_normed_vector, 'a, 'b] => bool"
19023
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
    19
        ("((_)/ -- (_)/ --> (_))" [60, 0, 60] 60)
19765
dfe940911617 misc cleanup;
wenzelm
parents: 19023
diff changeset
    20
  "f -- a --> L =
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
    21
     (\<forall>r > 0. \<exists>s > 0. \<forall>x. x \<noteq> a & norm (x - a) < s
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
    22
        --> norm (f x - L) < r)"
10751
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
    23
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
    24
  NSLIM :: "['a::real_normed_vector => 'b::real_normed_vector, 'a, 'b] => bool"
19023
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
    25
            ("((_)/ -- (_)/ --NS> (_))" [60, 0, 60] 60)
20552
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
    26
  "f -- a --NS> L =
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
    27
    (\<forall>x. (x \<noteq> star_of a & x @= star_of a --> ( *f* f) x @= star_of L))"
10751
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
    28
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
    29
  isCont :: "['a::real_normed_vector => 'b::real_normed_vector, 'a] => bool"
19765
dfe940911617 misc cleanup;
wenzelm
parents: 19023
diff changeset
    30
  "isCont f a = (f -- a --> (f a))"
10751
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
    31
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
    32
  isNSCont :: "['a::real_normed_vector => 'b::real_normed_vector, 'a] => bool"
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
    33
    --{*NS definition dispenses with limit notions*}
20552
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
    34
  "isNSCont f a = (\<forall>y. y @= star_of a -->
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
    35
         ( *f* f) y @= star_of (f a))"
10751
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
    36
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
    37
  deriv:: "[real=>real,real,real] => bool"
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
    38
    --{*Differentiation: D is derivative of function f at x*}
19023
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
    39
          ("(DERIV (_)/ (_)/ :> (_))" [1000, 1000, 60] 60)
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
    40
  "DERIV f x :> D = ((%h. (f(x + h) - f x)/h) -- 0 --> D)"
10751
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
    41
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
    42
  nsderiv :: "[real=>real,real,real] => bool"
19023
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
    43
          ("(NSDERIV (_)/ (_)/ :> (_))" [1000, 1000, 60] 60)
19765
dfe940911617 misc cleanup;
wenzelm
parents: 19023
diff changeset
    44
  "NSDERIV f x :> D = (\<forall>h \<in> Infinitesimal - {0}.
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
    45
      (( *f* f)(hypreal_of_real x + h)
19023
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
    46
       - hypreal_of_real (f x))/h @= hypreal_of_real D)"
10751
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
    47
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
    48
  differentiable :: "[real=>real,real] => bool"   (infixl "differentiable" 60)
19765
dfe940911617 misc cleanup;
wenzelm
parents: 19023
diff changeset
    49
  "f differentiable x = (\<exists>D. DERIV f x :> D)"
10751
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
    50
19023
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
    51
  NSdifferentiable :: "[real=>real,real] => bool"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
    52
                       (infixl "NSdifferentiable" 60)
19765
dfe940911617 misc cleanup;
wenzelm
parents: 19023
diff changeset
    53
  "f NSdifferentiable x = (\<exists>D. NSDERIV f x :> D)"
10751
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
    54
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
    55
  increment :: "[real=>real,real,hypreal] => hypreal"
19765
dfe940911617 misc cleanup;
wenzelm
parents: 19023
diff changeset
    56
  "increment f x h = (@inc. f NSdifferentiable x &
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
    57
           inc = ( *f* f)(hypreal_of_real x + h) - hypreal_of_real (f x))"
10751
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
    58
20752
09cf0e407a45 generalize type of is(NS)UCont
huffman
parents: 20693
diff changeset
    59
  isUCont :: "['a::real_normed_vector => 'b::real_normed_vector] => bool"
09cf0e407a45 generalize type of is(NS)UCont
huffman
parents: 20693
diff changeset
    60
  "isUCont f = (\<forall>r>0. \<exists>s>0. \<forall>x y. norm (x - y) < s \<longrightarrow> norm (f x - f y) < r)"
10751
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
    61
20752
09cf0e407a45 generalize type of is(NS)UCont
huffman
parents: 20693
diff changeset
    62
  isNSUCont :: "['a::real_normed_vector => 'b::real_normed_vector] => bool"
19765
dfe940911617 misc cleanup;
wenzelm
parents: 19023
diff changeset
    63
  "isNSUCont f = (\<forall>x y. x @= y --> ( *f* f) x @= ( *f* f) y)"
10751
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
    64
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
    65
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
    66
consts
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
    67
  Bolzano_bisect :: "[real*real=>bool, real, real, nat] => (real*real)"
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
    68
primrec
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
    69
  "Bolzano_bisect P a b 0 = (a,b)"
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
    70
  "Bolzano_bisect P a b (Suc n) =
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
    71
      (let (x,y) = Bolzano_bisect P a b n
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
    72
       in if P(x, (x+y)/2) then ((x+y)/2, y)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
    73
                            else (x, (x+y)/2))"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
    74
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
    75
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
    76
20635
e95db20977c5 change section to subsection
huffman
parents: 20563
diff changeset
    77
subsection{*Some Purely Standard Proofs*}
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
    78
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
    79
lemma LIM_eq:
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
    80
     "f -- a --> L =
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
    81
     (\<forall>r>0.\<exists>s>0.\<forall>x. x \<noteq> a & norm (x-a) < s --> norm (f x - L) < r)"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
    82
by (simp add: LIM_def diff_minus)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
    83
20552
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
    84
lemma LIM_I:
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
    85
     "(!!r. 0<r ==> \<exists>s>0.\<forall>x. x \<noteq> a & norm (x-a) < s --> norm (f x - L) < r)
20552
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
    86
      ==> f -- a --> L"
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
    87
by (simp add: LIM_eq)
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
    88
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
    89
lemma LIM_D:
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
    90
     "[| f -- a --> L; 0<r |]
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
    91
      ==> \<exists>s>0.\<forall>x. x \<noteq> a & norm (x-a) < s --> norm (f x - L) < r"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
    92
by (simp add: LIM_eq)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
    93
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
    94
lemma LIM_const [simp]: "(%x. k) -- x --> k"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
    95
by (simp add: LIM_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
    96
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
    97
lemma LIM_add:
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
    98
  fixes f g :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_vector"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
    99
  assumes f: "f -- a --> L" and g: "g -- a --> M"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   100
  shows "(%x. f x + g(x)) -- a --> (L + M)"
20552
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   101
proof (rule LIM_I)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   102
  fix r :: real
20409
eba80f91e3fc speed up some proofs
huffman
parents: 20254
diff changeset
   103
  assume r: "0 < r"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   104
  from LIM_D [OF f half_gt_zero [OF r]]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   105
  obtain fs
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   106
    where fs:    "0 < fs"
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   107
      and fs_lt: "\<forall>x. x \<noteq> a & norm (x-a) < fs --> norm (f x - L) < r/2"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   108
  by blast
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   109
  from LIM_D [OF g half_gt_zero [OF r]]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   110
  obtain gs
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   111
    where gs:    "0 < gs"
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   112
      and gs_lt: "\<forall>x. x \<noteq> a & norm (x-a) < gs --> norm (g x - M) < r/2"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   113
  by blast
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   114
  show "\<exists>s>0.\<forall>x. x \<noteq> a \<and> norm (x-a) < s \<longrightarrow> norm (f x + g x - (L + M)) < r"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   115
  proof (intro exI conjI strip)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   116
    show "0 < min fs gs"  by (simp add: fs gs)
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   117
    fix x :: 'a
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   118
    assume "x \<noteq> a \<and> norm (x-a) < min fs gs"
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   119
    hence "x \<noteq> a \<and> norm (x-a) < fs \<and> norm (x-a) < gs" by simp
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   120
    with fs_lt gs_lt
20552
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   121
    have "norm (f x - L) < r/2" and "norm (g x - M) < r/2" by blast+
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   122
    hence "norm (f x - L) + norm (g x - M) < r" by arith
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   123
    thus "norm (f x + g x - (L + M)) < r"
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   124
      by (blast intro: norm_diff_triangle_ineq order_le_less_trans)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   125
  qed
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   126
qed
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   127
20552
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   128
lemma minus_diff_minus:
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   129
  fixes a b :: "'a::ab_group_add"
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   130
  shows "(- a) - (- b) = - (a - b)"
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   131
by simp
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   132
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   133
lemma LIM_minus: "f -- a --> L ==> (%x. -f(x)) -- a --> -L"
20552
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   134
by (simp only: LIM_eq minus_diff_minus norm_minus_cancel)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   135
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   136
lemma LIM_add_minus:
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   137
    "[| f -- x --> l; g -- x --> m |] ==> (%x. f(x) + -g(x)) -- x --> (l + -m)"
20552
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   138
by (intro LIM_add LIM_minus)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   139
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   140
lemma LIM_diff:
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   141
    "[| f -- x --> l; g -- x --> m |] ==> (%x. f(x) - g(x)) -- x --> l-m"
20552
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   142
by (simp only: diff_minus LIM_add LIM_minus)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   143
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   144
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   145
lemma LIM_const_not_eq:
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   146
  fixes a :: "'a::real_normed_div_algebra"
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   147
  shows "k \<noteq> L ==> ~ ((%x. k) -- a --> L)"
20552
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   148
apply (simp add: LIM_eq)
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   149
apply (rule_tac x="norm (k - L)" in exI, simp, safe)
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   150
apply (rule_tac x="a + of_real (s/2)" in exI, simp add: norm_of_real)
20552
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   151
done
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   152
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   153
lemma LIM_const_eq:
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   154
  fixes a :: "'a::real_normed_div_algebra"
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   155
  shows "(%x. k) -- a --> L ==> k = L"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   156
apply (rule ccontr)
19023
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
   157
apply (blast dest: LIM_const_not_eq)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   158
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   159
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   160
lemma LIM_unique:
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   161
  fixes a :: "'a::real_normed_div_algebra"
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   162
  shows "[| f -- a --> L; f -- a --> M |] ==> L = M"
19023
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
   163
apply (drule LIM_diff, assumption)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   164
apply (auto dest!: LIM_const_eq)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   165
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   166
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   167
lemma LIM_mult_zero:
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   168
  fixes f g :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_algebra"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   169
  assumes f: "f -- a --> 0" and g: "g -- a --> 0"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   170
  shows "(%x. f(x) * g(x)) -- a --> 0"
20552
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   171
proof (rule LIM_I, simp)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   172
  fix r :: real
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   173
  assume r: "0<r"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   174
  from LIM_D [OF f zero_less_one]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   175
  obtain fs
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   176
    where fs:    "0 < fs"
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   177
      and fs_lt: "\<forall>x. x \<noteq> a & norm (x-a) < fs --> norm (f x) < 1"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   178
  by auto
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   179
  from LIM_D [OF g r]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   180
  obtain gs
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   181
    where gs:    "0 < gs"
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   182
      and gs_lt: "\<forall>x. x \<noteq> a & norm (x-a) < gs --> norm (g x) < r"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   183
  by auto
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   184
  show "\<exists>s. 0 < s \<and> (\<forall>x. x \<noteq> a \<and> norm (x-a) < s \<longrightarrow> norm (f x * g x) < r)"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   185
  proof (intro exI conjI strip)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   186
    show "0 < min fs gs"  by (simp add: fs gs)
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   187
    fix x :: 'a
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   188
    assume "x \<noteq> a \<and> norm (x-a) < min fs gs"
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   189
    hence  "x \<noteq> a \<and> norm (x-a) < fs \<and> norm (x-a) < gs" by simp
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   190
    with fs_lt gs_lt
20552
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   191
    have "norm (f x) < 1" and "norm (g x) < r" by blast+
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   192
    hence "norm (f x) * norm (g x) < 1*r"
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   193
      by (rule mult_strict_mono' [OF _ _ norm_ge_zero norm_ge_zero])
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   194
    thus "norm (f x * g x) < r"
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   195
      by (simp add: order_le_less_trans [OF norm_mult_ineq])
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   196
  qed
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   197
qed
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   198
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   199
lemma LIM_self: "(%x. x) -- a --> a"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   200
by (auto simp add: LIM_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   201
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   202
text{*Limits are equal for functions equal except at limit point*}
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   203
lemma LIM_equal:
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   204
     "[| \<forall>x. x \<noteq> a --> (f x = g x) |] ==> (f -- a --> l) = (g -- a --> l)"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   205
by (simp add: LIM_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   206
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   207
text{*Two uses in Hyperreal/Transcendental.ML*}
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   208
lemma LIM_trans:
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   209
     "[| (%x. f(x) + -g(x)) -- a --> 0;  g -- a --> l |] ==> f -- a --> l"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   210
apply (drule LIM_add, assumption)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   211
apply (auto simp add: add_assoc)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   212
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   213
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   214
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   215
subsection{*Relationships Between Standard and Nonstandard Concepts*}
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   216
20754
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   217
lemma NSLIM_I:
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   218
  "(\<And>x. \<lbrakk>x \<noteq> star_of a; x \<approx> star_of a\<rbrakk> \<Longrightarrow> starfun f x \<approx> star_of L)
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   219
   \<Longrightarrow> f -- a --NS> L"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   220
by (simp add: NSLIM_def)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   221
20754
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   222
lemma NSLIM_D:
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   223
  "\<lbrakk>f -- a --NS> L; x \<noteq> star_of a; x \<approx> star_of a\<rbrakk>
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   224
   \<Longrightarrow> starfun f x \<approx> star_of L"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   225
by (simp add: NSLIM_def)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   226
20754
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   227
lemma LIM_NSLIM:
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   228
  assumes f: "f -- a --> L" shows "f -- a --NS> L"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   229
proof (rule NSLIM_I)
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   230
  fix x
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   231
  assume neq: "x \<noteq> star_of a"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   232
  assume approx: "x \<approx> star_of a"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   233
  have "starfun f x - star_of L \<in> Infinitesimal"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   234
  proof (rule InfinitesimalI2)
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   235
    fix r::real assume r: "0 < r"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   236
    from LIM_D [OF f r]
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   237
    obtain s where s: "0 < s" and
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   238
      less_r: "\<And>x. \<lbrakk>x \<noteq> a; norm (x - a) < s\<rbrakk> \<Longrightarrow> norm (f x - L) < r"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   239
      by fast
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   240
    from less_r have less_r':
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   241
       "\<And>x. \<lbrakk>x \<noteq> star_of a; hnorm (x - star_of a) < star_of s\<rbrakk>
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   242
        \<Longrightarrow> hnorm (starfun f x - star_of L) < star_of r"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   243
      by transfer
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   244
    from approx have "x - star_of a \<in> Infinitesimal"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   245
      by (unfold approx_def)
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   246
    hence "hnorm (x - star_of a) < star_of s"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   247
      using s by (rule InfinitesimalD2)
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   248
    with neq show "hnorm (starfun f x - star_of L) < star_of r"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   249
      by (rule less_r')
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   250
  qed
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   251
  thus "starfun f x \<approx> star_of L"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   252
    by (unfold approx_def)
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   253
qed
20552
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   254
20754
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   255
lemma NSLIM_LIM:
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   256
  assumes f: "f -- a --NS> L" shows "f -- a --> L"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   257
proof (rule LIM_I)
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   258
  fix r::real assume r: "0 < r"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   259
  have "\<exists>s>0. \<forall>x. x \<noteq> star_of a \<and> hnorm (x - star_of a) < s
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   260
        \<longrightarrow> hnorm (starfun f x - star_of L) < star_of r"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   261
  proof (rule exI, safe)
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   262
    show "0 < epsilon" by (rule hypreal_epsilon_gt_zero)
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   263
  next
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   264
    fix x assume neq: "x \<noteq> star_of a"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   265
    assume "hnorm (x - star_of a) < epsilon"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   266
    with Infinitesimal_epsilon
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   267
    have "x - star_of a \<in> Infinitesimal"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   268
      by (rule hnorm_less_Infinitesimal)
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   269
    hence "x \<approx> star_of a"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   270
      by (unfold approx_def)
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   271
    with f neq have "starfun f x \<approx> star_of L"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   272
      by (rule NSLIM_D)
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   273
    hence "starfun f x - star_of L \<in> Infinitesimal"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   274
      by (unfold approx_def)
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   275
    thus "hnorm (starfun f x - star_of L) < star_of r"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   276
      using r by (rule InfinitesimalD2)
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   277
  qed
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   278
  thus "\<exists>s>0. \<forall>x. x \<noteq> a \<and> norm (x - a) < s \<longrightarrow> norm (f x - L) < r"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   279
    by transfer
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   280
qed
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   281
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   282
theorem LIM_NSLIM_iff: "(f -- x --> L) = (f -- x --NS> L)"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   283
by (blast intro: LIM_NSLIM NSLIM_LIM)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   284
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   285
text{*Proving properties of limits using nonstandard definition.
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   286
      The properties hold for standard limits as well!*}
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   287
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   288
lemma NSLIM_mult:
20552
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   289
  fixes l m :: "'a::real_normed_algebra"
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   290
  shows "[| f -- x --NS> l; g -- x --NS> m |]
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   291
      ==> (%x. f(x) * g(x)) -- x --NS> (l * m)"
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   292
by (auto simp add: NSLIM_def intro!: approx_mult_HFinite)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   293
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   294
lemma LIM_mult2:
20552
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   295
  fixes l m :: "'a::real_normed_algebra"
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   296
  shows "[| f -- x --> l; g -- x --> m |]
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   297
      ==> (%x. f(x) * g(x)) -- x --> (l * m)"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   298
by (simp add: LIM_NSLIM_iff NSLIM_mult)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   299
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   300
lemma NSLIM_add:
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   301
     "[| f -- x --NS> l; g -- x --NS> m |]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   302
      ==> (%x. f(x) + g(x)) -- x --NS> (l + m)"
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   303
by (auto simp add: NSLIM_def intro!: approx_add)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   304
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   305
lemma LIM_add2:
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   306
     "[| f -- x --> l; g -- x --> m |] ==> (%x. f(x) + g(x)) -- x --> (l + m)"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   307
by (simp add: LIM_NSLIM_iff NSLIM_add)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   308
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   309
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   310
lemma NSLIM_const [simp]: "(%x. k) -- x --NS> k"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   311
by (simp add: NSLIM_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   312
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   313
lemma LIM_const2: "(%x. k) -- x --> k"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   314
by (simp add: LIM_NSLIM_iff)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   315
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   316
lemma NSLIM_minus: "f -- a --NS> L ==> (%x. -f(x)) -- a --NS> -L"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   317
by (simp add: NSLIM_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   318
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   319
lemma LIM_minus2: "f -- a --> L ==> (%x. -f(x)) -- a --> -L"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   320
by (simp add: LIM_NSLIM_iff NSLIM_minus)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   321
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   322
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   323
lemma NSLIM_add_minus: "[| f -- x --NS> l; g -- x --NS> m |] ==> (%x. f(x) + -g(x)) -- x --NS> (l + -m)"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   324
by (blast dest: NSLIM_add NSLIM_minus)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   325
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   326
lemma LIM_add_minus2: "[| f -- x --> l; g -- x --> m |] ==> (%x. f(x) + -g(x)) -- x --> (l + -m)"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   327
by (simp add: LIM_NSLIM_iff NSLIM_add_minus)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   328
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   329
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   330
lemma NSLIM_inverse:
20653
24cda2c5fd40 removed division_by_zero class requirements from several lemmas
huffman
parents: 20635
diff changeset
   331
  fixes L :: "'a::real_normed_div_algebra"
20552
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   332
  shows "[| f -- a --NS> L;  L \<noteq> 0 |]
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   333
      ==> (%x. inverse(f(x))) -- a --NS> (inverse L)"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   334
apply (simp add: NSLIM_def, clarify)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   335
apply (drule spec)
20552
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   336
apply (auto simp add: star_of_approx_inverse)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   337
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   338
20552
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   339
lemma LIM_inverse:
20653
24cda2c5fd40 removed division_by_zero class requirements from several lemmas
huffman
parents: 20635
diff changeset
   340
  fixes L :: "'a::real_normed_div_algebra"
20552
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   341
  shows "[| f -- a --> L; L \<noteq> 0 |]
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   342
      ==> (%x. inverse(f(x))) -- a --> (inverse L)"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   343
by (simp add: LIM_NSLIM_iff NSLIM_inverse)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   344
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   345
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   346
lemma NSLIM_zero:
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   347
  assumes f: "f -- a --NS> l" shows "(%x. f(x) + -l) -- a --NS> 0"
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   348
proof -
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   349
  have "(\<lambda>x. f x + - l) -- a --NS> l + -l"
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   350
    by (rule NSLIM_add_minus [OF f NSLIM_const])
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   351
  thus ?thesis by simp
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   352
qed
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   353
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   354
lemma LIM_zero2: "f -- a --> l ==> (%x. f(x) + -l) -- a --> 0"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   355
by (simp add: LIM_NSLIM_iff NSLIM_zero)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   356
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   357
lemma NSLIM_zero_cancel: "(%x. f(x) - l) -- x --NS> 0 ==> f -- x --NS> l"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   358
apply (drule_tac g = "%x. l" and m = l in NSLIM_add)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   359
apply (auto simp add: diff_minus add_assoc)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   360
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   361
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   362
lemma LIM_zero_cancel: "(%x. f(x) - l) -- x --> 0 ==> f -- x --> l"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   363
apply (drule_tac g = "%x. l" and M = l in LIM_add)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   364
apply (auto simp add: diff_minus add_assoc)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   365
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   366
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   367
lemma NSLIM_const_not_eq:
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   368
  fixes a :: real (* TODO: generalize to real_normed_div_algebra *)
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   369
  shows "k \<noteq> L ==> ~ ((%x. k) -- a --NS> L)"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   370
apply (simp add: NSLIM_def)
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   371
apply (rule_tac x="star_of a + epsilon" in exI)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   372
apply (auto intro: Infinitesimal_add_approx_self [THEN approx_sym]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   373
            simp add: hypreal_epsilon_not_zero)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   374
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   375
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   376
lemma NSLIM_not_zero:
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   377
  fixes a :: real
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   378
  shows "k \<noteq> 0 ==> ~ ((%x. k) -- a --NS> 0)"
20552
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   379
by (rule NSLIM_const_not_eq)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   380
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   381
lemma NSLIM_const_eq:
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   382
  fixes a :: real
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   383
  shows "(%x. k) -- a --NS> L ==> k = L"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   384
apply (rule ccontr)
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   385
apply (blast dest: NSLIM_const_not_eq)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   386
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   387
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   388
text{* can actually be proved more easily by unfolding the definition!*}
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   389
lemma NSLIM_unique:
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   390
  fixes a :: real
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   391
  shows "[| f -- a --NS> L; f -- a --NS> M |] ==> L = M"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   392
apply (drule NSLIM_minus)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   393
apply (drule NSLIM_add, assumption)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   394
apply (auto dest!: NSLIM_const_eq [symmetric])
20552
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   395
apply (simp add: diff_def [symmetric])
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   396
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   397
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   398
lemma LIM_unique2:
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   399
  fixes a :: real
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   400
  shows "[| f -- a --> L; f -- a --> M |] ==> L = M"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   401
by (simp add: LIM_NSLIM_iff NSLIM_unique)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   402
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   403
20552
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   404
lemma NSLIM_mult_zero:
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   405
  fixes f g :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_algebra"
20552
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   406
  shows "[| f -- x --NS> 0; g -- x --NS> 0 |] ==> (%x. f(x)*g(x)) -- x --NS> 0"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   407
by (drule NSLIM_mult, auto)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   408
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   409
(* we can use the corresponding thm LIM_mult2 *)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   410
(* for standard definition of limit           *)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   411
20552
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   412
lemma LIM_mult_zero2:
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   413
  fixes f g :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_algebra"
20552
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   414
  shows "[| f -- x --> 0; g -- x --> 0 |] ==> (%x. f(x)*g(x)) -- x --> 0"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   415
by (drule LIM_mult2, auto)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   416
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   417
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   418
lemma NSLIM_self: "(%x. x) -- a --NS> a"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   419
by (simp add: NSLIM_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   420
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   421
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   422
subsection{* Derivatives and Continuity: NS and Standard properties*}
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   423
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   424
subsubsection{*Continuity*}
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   425
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   426
lemma isNSContD: "[| isNSCont f a; y \<approx> hypreal_of_real a |] ==> ( *f* f) y \<approx> hypreal_of_real (f a)"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   427
by (simp add: isNSCont_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   428
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   429
lemma isNSCont_NSLIM: "isNSCont f a ==> f -- a --NS> (f a) "
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   430
by (simp add: isNSCont_def NSLIM_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   431
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   432
lemma NSLIM_isNSCont: "f -- a --NS> (f a) ==> isNSCont f a"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   433
apply (simp add: isNSCont_def NSLIM_def, auto)
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   434
apply (case_tac "y = star_of a", auto)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   435
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   436
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   437
text{*NS continuity can be defined using NS Limit in
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   438
    similar fashion to standard def of continuity*}
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   439
lemma isNSCont_NSLIM_iff: "(isNSCont f a) = (f -- a --NS> (f a))"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   440
by (blast intro: isNSCont_NSLIM NSLIM_isNSCont)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   441
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   442
text{*Hence, NS continuity can be given
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   443
  in terms of standard limit*}
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   444
lemma isNSCont_LIM_iff: "(isNSCont f a) = (f -- a --> (f a))"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   445
by (simp add: LIM_NSLIM_iff isNSCont_NSLIM_iff)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   446
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   447
text{*Moreover, it's trivial now that NS continuity
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   448
  is equivalent to standard continuity*}
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   449
lemma isNSCont_isCont_iff: "(isNSCont f a) = (isCont f a)"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   450
apply (simp add: isCont_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   451
apply (rule isNSCont_LIM_iff)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   452
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   453
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   454
text{*Standard continuity ==> NS continuity*}
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   455
lemma isCont_isNSCont: "isCont f a ==> isNSCont f a"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   456
by (erule isNSCont_isCont_iff [THEN iffD2])
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   457
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   458
text{*NS continuity ==> Standard continuity*}
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   459
lemma isNSCont_isCont: "isNSCont f a ==> isCont f a"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   460
by (erule isNSCont_isCont_iff [THEN iffD1])
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   461
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   462
text{*Alternative definition of continuity*}
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   463
(* Prove equivalence between NS limits - *)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   464
(* seems easier than using standard def  *)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   465
lemma NSLIM_h_iff: "(f -- a --NS> L) = ((%h. f(a + h)) -- 0 --NS> L)"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   466
apply (simp add: NSLIM_def, auto)
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   467
apply (drule_tac x = "star_of a + x" in spec)
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   468
apply (drule_tac [2] x = "- star_of a + x" in spec, safe, simp)
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   469
apply (erule mem_infmal_iff [THEN iffD2, THEN Infinitesimal_add_approx_self [THEN approx_sym]])
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   470
apply (erule_tac [3] approx_minus_iff2 [THEN iffD1])
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   471
 prefer 2 apply (simp add: add_commute diff_def [symmetric])
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   472
apply (rule_tac x = x in star_cases)
17318
bc1c75855f3d starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents: 17298
diff changeset
   473
apply (rule_tac [2] x = x in star_cases)
bc1c75855f3d starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents: 17298
diff changeset
   474
apply (auto simp add: starfun star_of_def star_n_minus star_n_add add_assoc approx_refl star_n_zero_num)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   475
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   476
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   477
lemma NSLIM_isCont_iff: "(f -- a --NS> f a) = ((%h. f(a + h)) -- 0 --NS> f a)"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   478
by (rule NSLIM_h_iff)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   479
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   480
lemma LIM_isCont_iff: "(f -- a --> f a) = ((%h. f(a + h)) -- 0 --> f(a))"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   481
by (simp add: LIM_NSLIM_iff NSLIM_isCont_iff)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   482
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   483
lemma isCont_iff: "(isCont f x) = ((%h. f(x + h)) -- 0 --> f(x))"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   484
by (simp add: isCont_def LIM_isCont_iff)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   485
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   486
text{*Immediate application of nonstandard criterion for continuity can offer
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   487
   very simple proofs of some standard property of continuous functions*}
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   488
text{*sum continuous*}
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   489
lemma isCont_add: "[| isCont f a; isCont g a |] ==> isCont (%x. f(x) + g(x)) a"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   490
by (auto intro: approx_add simp add: isNSCont_isCont_iff [symmetric] isNSCont_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   491
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   492
text{*mult continuous*}
20552
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   493
lemma isCont_mult:
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   494
  fixes f g :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_algebra"
20552
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   495
  shows "[| isCont f a; isCont g a |] ==> isCont (%x. f(x) * g(x)) a"
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   496
by (auto intro!: starfun_mult_HFinite_approx
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   497
            simp del: starfun_mult [symmetric]
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   498
            simp add: isNSCont_isCont_iff [symmetric] isNSCont_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   499
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   500
text{*composition of continuous functions
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   501
     Note very short straightforard proof!*}
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   502
lemma isCont_o: "[| isCont f a; isCont g (f a) |] ==> isCont (g o f) a"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   503
by (auto simp add: isNSCont_isCont_iff [symmetric] isNSCont_def starfun_o [symmetric])
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   504
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   505
lemma isCont_o2: "[| isCont f a; isCont g (f a) |] ==> isCont (%x. g (f x)) a"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   506
by (auto dest: isCont_o simp add: o_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   507
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   508
lemma isNSCont_minus: "isNSCont f a ==> isNSCont (%x. - f x) a"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   509
by (simp add: isNSCont_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   510
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   511
lemma isCont_minus: "isCont f a ==> isCont (%x. - f x) a"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   512
by (auto simp add: isNSCont_isCont_iff [symmetric] isNSCont_minus)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   513
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   514
lemma isCont_inverse:
20653
24cda2c5fd40 removed division_by_zero class requirements from several lemmas
huffman
parents: 20635
diff changeset
   515
  fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_div_algebra"
20552
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   516
  shows "[| isCont f x; f x \<noteq> 0 |] ==> isCont (%x. inverse (f x)) x"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   517
apply (simp add: isCont_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   518
apply (blast intro: LIM_inverse)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   519
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   520
20552
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   521
lemma isNSCont_inverse:
20653
24cda2c5fd40 removed division_by_zero class requirements from several lemmas
huffman
parents: 20635
diff changeset
   522
  fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_div_algebra"
20552
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   523
  shows "[| isNSCont f x; f x \<noteq> 0 |] ==> isNSCont (%x. inverse (f x)) x"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   524
by (auto intro: isCont_inverse simp add: isNSCont_isCont_iff)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   525
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   526
lemma isCont_diff:
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   527
      "[| isCont f a; isCont g a |] ==> isCont (%x. f(x) - g(x)) a"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   528
apply (simp add: diff_minus)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   529
apply (auto intro: isCont_add isCont_minus)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   530
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   531
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   532
lemma isCont_const [simp]: "isCont (%x. k) a"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   533
by (simp add: isCont_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   534
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   535
lemma isNSCont_const [simp]: "isNSCont (%x. k) a"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   536
by (simp add: isNSCont_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   537
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   538
lemma isNSCont_abs [simp]: "isNSCont abs (a::real)"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   539
apply (simp add: isNSCont_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   540
apply (auto intro: approx_hrabs simp add: hypreal_of_real_hrabs [symmetric] starfun_rabs_hrabs)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   541
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   542
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   543
lemma isCont_abs [simp]: "isCont abs (a::real)"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   544
by (auto simp add: isNSCont_isCont_iff [symmetric])
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   545
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   546
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   547
(****************************************************************
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   548
(%* Leave as commented until I add topology theory or remove? *%)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   549
(%*------------------------------------------------------------
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   550
  Elementary topology proof for a characterisation of
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   551
  continuity now: a function f is continuous if and only
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   552
  if the inverse image, {x. f(x) \<in> A}, of any open set A
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   553
  is always an open set
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   554
 ------------------------------------------------------------*%)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   555
Goal "[| isNSopen A; \<forall>x. isNSCont f x |]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   556
               ==> isNSopen {x. f x \<in> A}"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   557
by (auto_tac (claset(),simpset() addsimps [isNSopen_iff1]));
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   558
by (dtac (mem_monad_approx RS approx_sym);
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   559
by (dres_inst_tac [("x","a")] spec 1);
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   560
by (dtac isNSContD 1 THEN assume_tac 1)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   561
by (dtac bspec 1 THEN assume_tac 1)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   562
by (dres_inst_tac [("x","( *f* f) x")] approx_mem_monad2 1);
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   563
by (blast_tac (claset() addIs [starfun_mem_starset]);
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   564
qed "isNSCont_isNSopen";
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   565
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   566
Goalw [isNSCont_def]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   567
          "\<forall>A. isNSopen A --> isNSopen {x. f x \<in> A} \
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   568
\              ==> isNSCont f x";
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   569
by (auto_tac (claset() addSIs [(mem_infmal_iff RS iffD1) RS
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   570
     (approx_minus_iff RS iffD2)],simpset() addsimps
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   571
      [Infinitesimal_def,SReal_iff]));
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   572
by (dres_inst_tac [("x","{z. abs(z + -f(x)) < ya}")] spec 1);
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   573
by (etac (isNSopen_open_interval RSN (2,impE));
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   574
by (auto_tac (claset(),simpset() addsimps [isNSopen_def,isNSnbhd_def]));
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   575
by (dres_inst_tac [("x","x")] spec 1);
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   576
by (auto_tac (claset() addDs [approx_sym RS approx_mem_monad],
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   577
    simpset() addsimps [hypreal_of_real_zero RS sym,STAR_starfun_rabs_add_minus]));
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   578
qed "isNSopen_isNSCont";
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   579
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   580
Goal "(\<forall>x. isNSCont f x) = \
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   581
\     (\<forall>A. isNSopen A --> isNSopen {x. f(x) \<in> A})";
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   582
by (blast_tac (claset() addIs [isNSCont_isNSopen,
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   583
    isNSopen_isNSCont]);
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   584
qed "isNSCont_isNSopen_iff";
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   585
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   586
(%*------- Standard version of same theorem --------*%)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   587
Goal "(\<forall>x. isCont f x) = \
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   588
\         (\<forall>A. isopen A --> isopen {x. f(x) \<in> A})";
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   589
by (auto_tac (claset() addSIs [isNSCont_isNSopen_iff],
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   590
              simpset() addsimps [isNSopen_isopen_iff RS sym,
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   591
              isNSCont_isCont_iff RS sym]));
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   592
qed "isCont_isopen_iff";
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   593
*******************************************************************)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   594
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   595
text{*Uniform continuity*}
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   596
lemma isNSUContD: "[| isNSUCont f; x \<approx> y|] ==> ( *f* f) x \<approx> ( *f* f) y"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   597
by (simp add: isNSUCont_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   598
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   599
lemma isUCont_isCont: "isUCont f ==> isCont f x"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   600
by (simp add: isUCont_def isCont_def LIM_def, meson)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   601
20754
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   602
lemma isUCont_isNSUCont:
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   603
  fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_vector"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   604
  assumes f: "isUCont f" shows "isNSUCont f"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   605
proof (unfold isNSUCont_def, safe)
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   606
  fix x y :: "'a star"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   607
  assume approx: "x \<approx> y"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   608
  have "starfun f x - starfun f y \<in> Infinitesimal"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   609
  proof (rule InfinitesimalI2)
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   610
    fix r::real assume r: "0 < r"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   611
    with f obtain s where s: "0 < s" and
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   612
      less_r: "\<And>x y. norm (x - y) < s \<Longrightarrow> norm (f x - f y) < r"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   613
      by (auto simp add: isUCont_def)
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   614
    from less_r have less_r':
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   615
       "\<And>x y. hnorm (x - y) < star_of s
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   616
        \<Longrightarrow> hnorm (starfun f x - starfun f y) < star_of r"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   617
      by transfer
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   618
    from approx have "x - y \<in> Infinitesimal"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   619
      by (unfold approx_def)
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   620
    hence "hnorm (x - y) < star_of s"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   621
      using s by (rule InfinitesimalD2)
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   622
    thus "hnorm (starfun f x - starfun f y) < star_of r"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   623
      by (rule less_r')
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   624
  qed
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   625
  thus "starfun f x \<approx> starfun f y"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   626
    by (unfold approx_def)
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   627
qed
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   628
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   629
lemma isNSUCont_isUCont:
20754
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   630
  fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_vector"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   631
  assumes f: "isNSUCont f" shows "isUCont f"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   632
proof (unfold isUCont_def, safe)
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   633
  fix r::real assume r: "0 < r"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   634
  have "\<exists>s>0. \<forall>x y. hnorm (x - y) < s
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   635
        \<longrightarrow> hnorm (starfun f x - starfun f y) < star_of r"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   636
  proof (rule exI, safe)
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   637
    show "0 < epsilon" by (rule hypreal_epsilon_gt_zero)
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   638
  next
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   639
    fix x y :: "'a star"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   640
    assume "hnorm (x - y) < epsilon"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   641
    with Infinitesimal_epsilon
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   642
    have "x - y \<in> Infinitesimal"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   643
      by (rule hnorm_less_Infinitesimal)
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   644
    hence "x \<approx> y"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   645
      by (unfold approx_def)
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   646
    with f have "starfun f x \<approx> starfun f y"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   647
      by (simp add: isNSUCont_def)
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   648
    hence "starfun f x - starfun f y \<in> Infinitesimal"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   649
      by (unfold approx_def)
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   650
    thus "hnorm (starfun f x - starfun f y) < star_of r"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   651
      using r by (rule InfinitesimalD2)
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   652
  qed
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   653
  thus "\<exists>s>0. \<forall>x y. norm (x - y) < s \<longrightarrow> norm (f x - f y) < r"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   654
    by transfer
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   655
qed
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   656
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   657
text{*Derivatives*}
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
   658
lemma DERIV_iff: "(DERIV f x :> D) = ((%h. (f(x + h) - f(x))/h) -- 0 --> D)"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   659
by (simp add: deriv_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   660
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   661
lemma DERIV_NS_iff:
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
   662
      "(DERIV f x :> D) = ((%h. (f(x + h) - f(x))/h) -- 0 --NS> D)"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   663
by (simp add: deriv_def LIM_NSLIM_iff)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   664
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
   665
lemma DERIV_D: "DERIV f x :> D ==> (%h. (f(x + h) - f(x))/h) -- 0 --> D"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   666
by (simp add: deriv_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   667
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
   668
lemma NS_DERIV_D: "DERIV f x :> D ==> (%h. (f(x + h) - f(x))/h) -- 0 --NS> D"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   669
by (simp add: deriv_def LIM_NSLIM_iff)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   670
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   671
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   672
subsubsection{*Uniqueness*}
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   673
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   674
lemma DERIV_unique:
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   675
      "[| DERIV f x :> D; DERIV f x :> E |] ==> D = E"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   676
apply (simp add: deriv_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   677
apply (blast intro: LIM_unique)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   678
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   679
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   680
lemma NSDeriv_unique:
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   681
     "[| NSDERIV f x :> D; NSDERIV f x :> E |] ==> D = E"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   682
apply (simp add: nsderiv_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   683
apply (cut_tac Infinitesimal_epsilon hypreal_epsilon_not_zero)
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   684
apply (auto dest!: bspec [where x=epsilon]
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   685
            intro!: inj_hypreal_of_real [THEN injD]
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   686
            dest: approx_trans3)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   687
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   688
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   689
subsubsection{*Differentiable*}
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   690
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   691
lemma differentiableD: "f differentiable x ==> \<exists>D. DERIV f x :> D"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   692
by (simp add: differentiable_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   693
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   694
lemma differentiableI: "DERIV f x :> D ==> f differentiable x"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   695
by (force simp add: differentiable_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   696
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   697
lemma NSdifferentiableD: "f NSdifferentiable x ==> \<exists>D. NSDERIV f x :> D"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   698
by (simp add: NSdifferentiable_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   699
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   700
lemma NSdifferentiableI: "NSDERIV f x :> D ==> f NSdifferentiable x"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   701
by (force simp add: NSdifferentiable_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   702
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   703
subsubsection{*Alternative definition for differentiability*}
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   704
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   705
lemma DERIV_LIM_iff:
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   706
     "((%h::real. (f(a + h) - f(a)) / h) -- 0 --> D) =
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   707
      ((%x. (f(x)-f(a)) / (x-a)) -- a --> D)"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   708
proof (intro iffI LIM_I)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   709
  fix r::real
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   710
  assume r: "0<r"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   711
  assume "(\<lambda>h. (f (a + h) - f a) / h) -- 0 --> D"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   712
  from LIM_D [OF this r]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   713
  obtain s
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   714
    where s:    "0 < s"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   715
      and s_lt: "\<forall>x. x \<noteq> 0 & \<bar>x\<bar> < s --> \<bar>(f (a + x) - f a) / x - D\<bar> < r"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   716
  by auto
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   717
  show "\<exists>s. 0 < s \<and>
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   718
        (\<forall>x. x \<noteq> a \<and> norm (x-a) < s \<longrightarrow> norm ((f x - f a) / (x-a) - D) < r)"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   719
  proof (intro exI conjI strip)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   720
    show "0 < s"  by (rule s)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   721
  next
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   722
    fix x::real
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   723
    assume "x \<noteq> a \<and> norm (x-a) < s"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   724
    with s_lt [THEN spec [where x="x-a"]]
20552
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   725
    show "norm ((f x - f a) / (x-a) - D) < r" by auto
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   726
  qed
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   727
next
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   728
  fix r::real
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   729
  assume r: "0<r"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   730
  assume "(\<lambda>x. (f x - f a) / (x-a)) -- a --> D"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   731
  from LIM_D [OF this r]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   732
  obtain s
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   733
    where s:    "0 < s"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   734
      and s_lt: "\<forall>x. x \<noteq> a & \<bar>x-a\<bar> < s --> \<bar>(f x - f a)/(x-a) - D\<bar> < r"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   735
  by auto
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   736
  show "\<exists>s. 0 < s \<and>
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   737
        (\<forall>x. x \<noteq> 0 & norm (x - 0) < s --> norm ((f (a + x) - f a) / x - D) < r)"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   738
  proof (intro exI conjI strip)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   739
    show "0 < s"  by (rule s)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   740
  next
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   741
    fix x::real
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   742
    assume "x \<noteq> 0 \<and> norm (x - 0) < s"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   743
    with s_lt [THEN spec [where x="x+a"]]
20552
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   744
    show "norm ((f (a + x) - f a) / x - D) < r" by (auto simp add: add_ac)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   745
  qed
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   746
qed
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   747
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   748
lemma DERIV_iff2: "(DERIV f x :> D) = ((%z. (f(z) - f(x)) / (z-x)) -- x --> D)"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   749
by (simp add: deriv_def diff_minus [symmetric] DERIV_LIM_iff)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   750
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   751
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   752
subsection{*Equivalence of NS and standard definitions of differentiation*}
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   753
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   754
subsubsection{*First NSDERIV in terms of NSLIM*}
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   755
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   756
text{*first equivalence *}
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   757
lemma NSDERIV_NSLIM_iff:
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
   758
      "(NSDERIV f x :> D) = ((%h. (f(x + h) - f(x))/h) -- 0 --NS> D)"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   759
apply (simp add: nsderiv_def NSLIM_def, auto)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   760
apply (drule_tac x = xa in bspec)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   761
apply (rule_tac [3] ccontr)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   762
apply (drule_tac [3] x = h in spec)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   763
apply (auto simp add: mem_infmal_iff starfun_lambda_cancel)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   764
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   765
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   766
text{*second equivalence *}
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   767
lemma NSDERIV_NSLIM_iff2:
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   768
     "(NSDERIV f x :> D) = ((%z. (f(z) - f(x)) / (z-x)) -- x --NS> D)"
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   769
by (simp add: NSDERIV_NSLIM_iff DERIV_LIM_iff  diff_minus [symmetric]
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   770
              LIM_NSLIM_iff [symmetric])
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   771
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   772
(* while we're at it! *)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   773
lemma NSDERIV_iff2:
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   774
     "(NSDERIV f x :> D) =
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   775
      (\<forall>w.
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   776
        w \<noteq> hypreal_of_real x & w \<approx> hypreal_of_real x -->
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   777
        ( *f* (%z. (f z - f x) / (z-x))) w \<approx> hypreal_of_real D)"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   778
by (simp add: NSDERIV_NSLIM_iff2 NSLIM_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   779
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   780
(*FIXME DELETE*)
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
   781
lemma hypreal_not_eq_minus_iff: "(x \<noteq> a) = (x - a \<noteq> (0::hypreal))"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   782
by (auto dest: hypreal_eq_minus_iff [THEN iffD2])
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   783
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   784
lemma NSDERIVD5:
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   785
  "(NSDERIV f x :> D) ==>
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   786
   (\<forall>u. u \<approx> hypreal_of_real x -->
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   787
     ( *f* (%z. f z - f x)) u \<approx> hypreal_of_real D * (u - hypreal_of_real x))"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   788
apply (auto simp add: NSDERIV_iff2)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   789
apply (case_tac "u = hypreal_of_real x", auto)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   790
apply (drule_tac x = u in spec, auto)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   791
apply (drule_tac c = "u - hypreal_of_real x" and b = "hypreal_of_real D" in approx_mult1)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   792
apply (drule_tac [!] hypreal_not_eq_minus_iff [THEN iffD1])
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   793
apply (subgoal_tac [2] "( *f* (%z. z-x)) u \<noteq> (0::hypreal) ")
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
   794
apply (auto simp add:
19023
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
   795
         approx_minus_iff [THEN iffD1, THEN mem_infmal_iff [THEN iffD2]]
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
   796
         Infinitesimal_subset_HFinite [THEN subsetD])
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   797
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   798
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   799
lemma NSDERIVD4:
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   800
     "(NSDERIV f x :> D) ==>
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   801
      (\<forall>h \<in> Infinitesimal.
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   802
               (( *f* f)(hypreal_of_real x + h) -
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   803
                 hypreal_of_real (f x))\<approx> (hypreal_of_real D) * h)"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   804
apply (auto simp add: nsderiv_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   805
apply (case_tac "h = (0::hypreal) ")
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   806
apply (auto simp add: diff_minus)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   807
apply (drule_tac x = h in bspec)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   808
apply (drule_tac [2] c = h in approx_mult1)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   809
apply (auto intro: Infinitesimal_subset_HFinite [THEN subsetD]
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15360
diff changeset
   810
            simp add: diff_minus)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   811
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   812
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   813
lemma NSDERIVD3:
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   814
     "(NSDERIV f x :> D) ==>
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   815
      (\<forall>h \<in> Infinitesimal - {0}.
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   816
               (( *f* f)(hypreal_of_real x + h) -
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   817
                 hypreal_of_real (f x))\<approx> (hypreal_of_real D) * h)"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   818
apply (auto simp add: nsderiv_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   819
apply (rule ccontr, drule_tac x = h in bspec)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   820
apply (drule_tac [2] c = h in approx_mult1)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   821
apply (auto intro: Infinitesimal_subset_HFinite [THEN subsetD]
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15360
diff changeset
   822
            simp add: mult_assoc diff_minus)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   823
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   824
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   825
text{*Now equivalence between NSDERIV and DERIV*}
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   826
lemma NSDERIV_DERIV_iff: "(NSDERIV f x :> D) = (DERIV f x :> D)"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   827
by (simp add: deriv_def NSDERIV_NSLIM_iff LIM_NSLIM_iff)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   828
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   829
text{*Differentiability implies continuity
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   830
         nice and simple "algebraic" proof*}
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   831
lemma NSDERIV_isNSCont: "NSDERIV f x :> D ==> isNSCont f x"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   832
apply (auto simp add: nsderiv_def isNSCont_NSLIM_iff NSLIM_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   833
apply (drule approx_minus_iff [THEN iffD1])
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   834
apply (drule hypreal_not_eq_minus_iff [THEN iffD1])
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
   835
apply (drule_tac x = "xa - hypreal_of_real x" in bspec)
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   836
 prefer 2 apply (simp add: add_assoc [symmetric])
15234
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15228
diff changeset
   837
apply (auto simp add: mem_infmal_iff [symmetric] add_commute)
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
   838
apply (drule_tac c = "xa - hypreal_of_real x" in approx_mult1)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   839
apply (auto intro: Infinitesimal_subset_HFinite [THEN subsetD]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   840
            simp add: mult_assoc)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   841
apply (drule_tac x3=D in
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   842
           HFinite_hypreal_of_real [THEN [2] Infinitesimal_HFinite_mult,
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   843
             THEN mem_infmal_iff [THEN iffD1]])
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15360
diff changeset
   844
apply (auto simp add: mult_commute
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   845
            intro: approx_trans approx_minus_iff [THEN iffD2])
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   846
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   847
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   848
text{*Now Sandard proof*}
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   849
lemma DERIV_isCont: "DERIV f x :> D ==> isCont f x"
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   850
by (simp add: NSDERIV_DERIV_iff [symmetric] isNSCont_isCont_iff [symmetric]
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   851
              NSDERIV_isNSCont)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   852
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   853
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   854
text{*Differentiation rules for combinations of functions
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   855
      follow from clear, straightforard, algebraic
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   856
      manipulations*}
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   857
text{*Constant function*}
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   858
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   859
(* use simple constant nslimit theorem *)
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   860
lemma NSDERIV_const [simp]: "(NSDERIV (%x. k) x :> 0)"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   861
by (simp add: NSDERIV_NSLIM_iff)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   862
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   863
lemma DERIV_const [simp]: "(DERIV (%x. k) x :> 0)"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   864
by (simp add: NSDERIV_DERIV_iff [symmetric])
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   865
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   866
text{*Sum of functions- proved easily*}
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   867
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   868
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   869
lemma NSDERIV_add: "[| NSDERIV f x :> Da;  NSDERIV g x :> Db |]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   870
      ==> NSDERIV (%x. f x + g x) x :> Da + Db"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   871
apply (auto simp add: NSDERIV_NSLIM_iff NSLIM_def)
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
   872
apply (auto simp add: add_divide_distrib diff_divide_distrib dest!: spec)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   873
apply (drule_tac b = "hypreal_of_real Da" and d = "hypreal_of_real Db" in approx_add)
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
   874
apply (auto simp add: diff_def add_ac)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   875
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   876
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   877
(* Standard theorem *)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   878
lemma DERIV_add: "[| DERIV f x :> Da; DERIV g x :> Db |]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   879
      ==> DERIV (%x. f x + g x) x :> Da + Db"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   880
apply (simp add: NSDERIV_add NSDERIV_DERIV_iff [symmetric])
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   881
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   882
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   883
text{*Product of functions - Proof is trivial but tedious
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   884
  and long due to rearrangement of terms*}
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   885
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
   886
lemma lemma_nsderiv1: "((a::hypreal)*b) - (c*d) = (b*(a - c)) + (c*(b - d))"
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
   887
by (simp add: right_diff_distrib)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   888
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
   889
lemma lemma_nsderiv2: "[| (x - y) / z = hypreal_of_real D + yb; z \<noteq> 0;
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   890
         z \<in> Infinitesimal; yb \<in> Infinitesimal |]
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
   891
      ==> x - y \<approx> 0"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   892
apply (frule_tac c1 = z in hypreal_mult_right_cancel [THEN iffD2], assumption)
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
   893
apply (erule_tac V = "(x - y) / z = hypreal_of_real D + yb" in thin_rl)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   894
apply (auto intro!: Infinitesimal_HFinite_mult2 HFinite_add
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15360
diff changeset
   895
            simp add: mult_assoc mem_infmal_iff [symmetric])
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   896
apply (erule Infinitesimal_subset_HFinite [THEN subsetD])
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   897
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   898
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   899
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   900
lemma NSDERIV_mult: "[| NSDERIV f x :> Da; NSDERIV g x :> Db |]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   901
      ==> NSDERIV (%x. f x * g x) x :> (Da * g(x)) + (Db * f(x))"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   902
apply (auto simp add: NSDERIV_NSLIM_iff NSLIM_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   903
apply (auto dest!: spec
19023
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
   904
      simp add: starfun_lambda_cancel lemma_nsderiv1)
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
   905
apply (simp (no_asm) add: add_divide_distrib diff_divide_distrib)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   906
apply (drule bex_Infinitesimal_iff2 [THEN iffD2])+
15234
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15228
diff changeset
   907
apply (auto simp add: times_divide_eq_right [symmetric]
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15228
diff changeset
   908
            simp del: times_divide_eq)
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
   909
apply (drule_tac D = Db in lemma_nsderiv2, assumption+)
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
   910
apply (drule_tac
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   911
     approx_minus_iff [THEN iffD2, THEN bex_Infinitesimal_iff2 [THEN iffD2]])
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   912
apply (auto intro!: approx_add_mono1
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   913
            simp add: left_distrib right_distrib mult_commute add_assoc)
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   914
apply (rule_tac b1 = "hypreal_of_real Db * hypreal_of_real (f x)"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   915
         in add_commute [THEN subst])
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   916
apply (auto intro!: Infinitesimal_add_approx_self2 [THEN approx_sym]
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   917
                    Infinitesimal_add Infinitesimal_mult
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   918
                    Infinitesimal_hypreal_of_real_mult
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   919
                    Infinitesimal_hypreal_of_real_mult2
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   920
          simp add: add_assoc [symmetric])
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   921
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   922
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   923
lemma DERIV_mult:
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   924
     "[| DERIV f x :> Da; DERIV g x :> Db |]
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   925
      ==> DERIV (%x. f x * g x) x :> (Da * g(x)) + (Db * f(x))"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   926
by (simp add: NSDERIV_mult NSDERIV_DERIV_iff [symmetric])
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   927
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   928
text{*Multiplying by a constant*}
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   929
lemma NSDERIV_cmult: "NSDERIV f x :> D
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   930
      ==> NSDERIV (%x. c * f x) x :> c*D"
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   931
apply (simp only: times_divide_eq_right [symmetric] NSDERIV_NSLIM_iff
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
   932
                  minus_mult_right right_diff_distrib [symmetric])
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   933
apply (erule NSLIM_const [THEN NSLIM_mult])
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   934
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   935
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   936
(* let's do the standard proof though theorem *)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   937
(* LIM_mult2 follows from a NS proof          *)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   938
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   939
lemma DERIV_cmult:
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   940
      "DERIV f x :> D ==> DERIV (%x. c * f x) x :> c*D"
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   941
apply (simp only: deriv_def times_divide_eq_right [symmetric]
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
   942
                  NSDERIV_NSLIM_iff minus_mult_right right_diff_distrib [symmetric])
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   943
apply (erule LIM_const [THEN LIM_mult2])
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   944
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   945
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   946
text{*Negation of function*}
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   947
lemma NSDERIV_minus: "NSDERIV f x :> D ==> NSDERIV (%x. -(f x)) x :> -D"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   948
proof (simp add: NSDERIV_NSLIM_iff)
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
   949
  assume "(\<lambda>h. (f (x + h) - f x) / h) -- 0 --NS> D"
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
   950
  hence deriv: "(\<lambda>h. - ((f(x+h) - f x) / h)) -- 0 --NS> - D"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   951
    by (rule NSLIM_minus)
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
   952
  have "\<forall>h. - ((f (x + h) - f x) / h) = (- f (x + h) + f x) / h"
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   953
    by (simp add: minus_divide_left)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   954
  with deriv
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   955
  show "(\<lambda>h. (- f (x + h) + f x) / h) -- 0 --NS> - D" by simp
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   956
qed
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   957
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   958
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   959
lemma DERIV_minus: "DERIV f x :> D ==> DERIV (%x. -(f x)) x :> -D"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   960
by (simp add: NSDERIV_minus NSDERIV_DERIV_iff [symmetric])
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   961
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   962
text{*Subtraction*}
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   963
lemma NSDERIV_add_minus: "[| NSDERIV f x :> Da; NSDERIV g x :> Db |] ==> NSDERIV (%x. f x + -g x) x :> Da + -Db"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   964
by (blast dest: NSDERIV_add NSDERIV_minus)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   965
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   966
lemma DERIV_add_minus: "[| DERIV f x :> Da; DERIV g x :> Db |] ==> DERIV (%x. f x + -g x) x :> Da + -Db"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   967
by (blast dest: DERIV_add DERIV_minus)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   968
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   969
lemma NSDERIV_diff:
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   970
     "[| NSDERIV f x :> Da; NSDERIV g x :> Db |]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   971
      ==> NSDERIV (%x. f x - g x) x :> Da-Db"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   972
apply (simp add: diff_minus)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   973
apply (blast intro: NSDERIV_add_minus)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   974
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   975
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   976
lemma DERIV_diff:
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   977
     "[| DERIV f x :> Da; DERIV g x :> Db |]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   978
       ==> DERIV (%x. f x - g x) x :> Da-Db"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   979
apply (simp add: diff_minus)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   980
apply (blast intro: DERIV_add_minus)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   981
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   982
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   983
text{*(NS) Increment*}
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   984
lemma incrementI:
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   985
      "f NSdifferentiable x ==>
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
   986
      increment f x h = ( *f* f) (hypreal_of_real(x) + h) -
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
   987
      hypreal_of_real (f x)"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   988
by (simp add: increment_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   989
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   990
lemma incrementI2: "NSDERIV f x :> D ==>
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
   991
     increment f x h = ( *f* f) (hypreal_of_real(x) + h) -
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
   992
     hypreal_of_real (f x)"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   993
apply (erule NSdifferentiableI [THEN incrementI])
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   994
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   995
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   996
(* The Increment theorem -- Keisler p. 65 *)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   997
lemma increment_thm: "[| NSDERIV f x :> D; h \<in> Infinitesimal; h \<noteq> 0 |]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   998
      ==> \<exists>e \<in> Infinitesimal. increment f x h = hypreal_of_real(D)*h + e*h"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   999
apply (frule_tac h = h in incrementI2, simp add: nsderiv_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1000
apply (drule bspec, auto)
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1001
apply (drule bex_Infinitesimal_iff2 [THEN iffD2], clarify)
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1002
apply (frule_tac b1 = "hypreal_of_real (D) + y"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1003
        in hypreal_mult_right_cancel [THEN iffD2])
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  1004
apply (erule_tac [2] V = "(( *f* f) (hypreal_of_real (x) + h) - hypreal_of_real (f x)) / h = hypreal_of_real (D) + y" in thin_rl)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1005
apply assumption
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15360
diff changeset
  1006
apply (simp add: times_divide_eq_right [symmetric])
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1007
apply (auto simp add: left_distrib)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1008
done
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1009
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1010
lemma increment_thm2:
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1011
     "[| NSDERIV f x :> D; h \<approx> 0; h \<noteq> 0 |]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1012
      ==> \<exists>e \<in> Infinitesimal. increment f x h =
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1013
              hypreal_of_real(D)*h + e*h"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1014
by (blast dest!: mem_infmal_iff [THEN iffD2] intro!: increment_thm)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1015
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1016
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1017
lemma increment_approx_zero: "[| NSDERIV f x :> D; h \<approx> 0; h \<noteq> 0 |]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1018
      ==> increment f x h \<approx> 0"
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1019
apply (drule increment_thm2,
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1020
       auto intro!: Infinitesimal_HFinite_mult2 HFinite_add simp add: left_distrib [symmetric] mem_infmal_iff [symmetric])
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1021
apply (erule Infinitesimal_subset_HFinite [THEN subsetD])
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1022
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1023
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1024
text{*  Similarly to the above, the chain rule admits an entirely
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1025
   straightforward derivation. Compare this with Harrison's
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1026
   HOL proof of the chain rule, which proved to be trickier and
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1027
   required an alternative characterisation of differentiability-
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1028
   the so-called Carathedory derivative. Our main problem is
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1029
   manipulation of terms.*}
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1030
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1031
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1032
(* lemmas *)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1033
lemma NSDERIV_zero:
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1034
      "[| NSDERIV g x :> D;
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1035
               ( *f* g) (hypreal_of_real(x) + xa) = hypreal_of_real(g x);
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1036
               xa \<in> Infinitesimal;
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1037
               xa \<noteq> 0
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1038
            |] ==> D = 0"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1039
apply (simp add: nsderiv_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1040
apply (drule bspec, auto)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1041
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1042
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1043
(* can be proved differently using NSLIM_isCont_iff *)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1044
lemma NSDERIV_approx:
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1045
     "[| NSDERIV f x :> D;  h \<in> Infinitesimal;  h \<noteq> 0 |]
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  1046
      ==> ( *f* f) (hypreal_of_real(x) + h) - hypreal_of_real(f x) \<approx> 0"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1047
apply (simp add: nsderiv_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1048
apply (simp add: mem_infmal_iff [symmetric])
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1049
apply (rule Infinitesimal_ratio)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1050
apply (rule_tac [3] approx_hypreal_of_real_HFinite, auto)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1051
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1052
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1053
(*---------------------------------------------------------------
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1054
   from one version of differentiability
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1055
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1056
                f(x) - f(a)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1057
              --------------- \<approx> Db
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1058
                  x - a
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1059
 ---------------------------------------------------------------*)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1060
lemma NSDERIVD1: "[| NSDERIV f (g x) :> Da;
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1061
         ( *f* g) (hypreal_of_real(x) + xa) \<noteq> hypreal_of_real (g x);
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1062
         ( *f* g) (hypreal_of_real(x) + xa) \<approx> hypreal_of_real (g x)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1063
      |] ==> (( *f* f) (( *f* g) (hypreal_of_real(x) + xa))
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  1064
                   - hypreal_of_real (f (g x)))
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  1065
              / (( *f* g) (hypreal_of_real(x) + xa) - hypreal_of_real (g x))
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1066
             \<approx> hypreal_of_real(Da)"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1067
by (auto simp add: NSDERIV_NSLIM_iff2 NSLIM_def diff_minus [symmetric])
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1068
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1069
(*--------------------------------------------------------------
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1070
   from other version of differentiability
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1071
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1072
                f(x + h) - f(x)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1073
               ----------------- \<approx> Db
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1074
                       h
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1075
 --------------------------------------------------------------*)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1076
lemma NSDERIVD2: "[| NSDERIV g x :> Db; xa \<in> Infinitesimal; xa \<noteq> 0 |]
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  1077
      ==> (( *f* g) (hypreal_of_real(x) + xa) - hypreal_of_real(g x)) / xa
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1078
          \<approx> hypreal_of_real(Db)"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1079
by (auto simp add: NSDERIV_NSLIM_iff NSLIM_def mem_infmal_iff starfun_lambda_cancel)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1080
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1081
lemma lemma_chain: "(z::hypreal) \<noteq> 0 ==> x*y = (x*inverse(z))*(z*y)"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1082
by auto
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1083
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1084
text{*This proof uses both definitions of differentiability.*}
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1085
lemma NSDERIV_chain: "[| NSDERIV f (g x) :> Da; NSDERIV g x :> Db |]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1086
      ==> NSDERIV (f o g) x :> Da * Db"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1087
apply (simp (no_asm_simp) add: NSDERIV_NSLIM_iff NSLIM_def
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1088
                mem_infmal_iff [symmetric])
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1089
apply clarify
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1090
apply (frule_tac f = g in NSDERIV_approx)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1091
apply (auto simp add: starfun_lambda_cancel2 starfun_o [symmetric])
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1092
apply (case_tac "( *f* g) (hypreal_of_real (x) + xa) = hypreal_of_real (g x) ")
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1093
apply (drule_tac g = g in NSDERIV_zero)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1094
apply (auto simp add: divide_inverse)
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  1095
apply (rule_tac z1 = "( *f* g) (hypreal_of_real (x) + xa) - hypreal_of_real (g x) " and y1 = "inverse xa" in lemma_chain [THEN ssubst])
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1096
apply (erule hypreal_not_eq_minus_iff [THEN iffD1])
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1097
apply (rule approx_mult_hypreal_of_real)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1098
apply (simp_all add: divide_inverse [symmetric])
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1099
apply (blast intro: NSDERIVD1 approx_minus_iff [THEN iffD2])
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1100
apply (blast intro: NSDERIVD2)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1101
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1102
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1103
(* standard version *)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1104
lemma DERIV_chain: "[| DERIV f (g x) :> Da; DERIV g x :> Db |] ==> DERIV (f o g) x :> Da * Db"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1105
by (simp add: NSDERIV_DERIV_iff [symmetric] NSDERIV_chain)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1106
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1107
lemma DERIV_chain2: "[| DERIV f (g x) :> Da; DERIV g x :> Db |] ==> DERIV (%x. f (g x)) x :> Da * Db"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1108
by (auto dest: DERIV_chain simp add: o_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1109
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1110
text{*Differentiation of natural number powers*}
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1111
lemma NSDERIV_Id [simp]: "NSDERIV (%x. x) x :> 1"
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1112
by (simp add: NSDERIV_NSLIM_iff NSLIM_def divide_self del: divide_self_if)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1113
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1114
(*derivative of the identity function*)
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1115
lemma DERIV_Id [simp]: "DERIV (%x. x) x :> 1"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1116
by (simp add: NSDERIV_DERIV_iff [symmetric])
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1117
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1118
lemmas isCont_Id = DERIV_Id [THEN DERIV_isCont, standard]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1119
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1120
(*derivative of linear multiplication*)
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1121
lemma DERIV_cmult_Id [simp]: "DERIV (op * c) x :> c"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1122
by (cut_tac c = c and x = x in DERIV_Id [THEN DERIV_cmult], simp)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1123
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1124
lemma NSDERIV_cmult_Id [simp]: "NSDERIV (op * c) x :> c"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1125
by (simp add: NSDERIV_DERIV_iff)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1126
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1127
lemma DERIV_pow: "DERIV (%x. x ^ n) x :> real n * (x ^ (n - Suc 0))"
15251
bb6f072c8d10 converted some induct_tac to induct
paulson
parents: 15234
diff changeset
  1128
apply (induct "n")
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1129
apply (drule_tac [2] DERIV_Id [THEN DERIV_mult])
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1130
apply (auto simp add: real_of_nat_Suc left_distrib)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1131
apply (case_tac "0 < n")
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1132
apply (drule_tac x = x in realpow_minus_mult)
15234
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15228
diff changeset
  1133
apply (auto simp add: mult_assoc add_commute)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1134
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1135
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1136
(* NS version *)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1137
lemma NSDERIV_pow: "NSDERIV (%x. x ^ n) x :> real n * (x ^ (n - Suc 0))"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1138
by (simp add: NSDERIV_DERIV_iff DERIV_pow)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1139
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1140
text{*Power of -1*}
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1141
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1142
(*Can't get rid of x \<noteq> 0 because it isn't continuous at zero*)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1143
lemma NSDERIV_inverse:
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1144
     "x \<noteq> 0 ==> NSDERIV (%x. inverse(x)) x :> (- (inverse x ^ Suc (Suc 0)))"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1145
apply (simp add: nsderiv_def)
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1146
apply (rule ballI, simp, clarify)
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  1147
apply (frule (1) Infinitesimal_add_not_zero)
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  1148
apply (simp add: add_commute)
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  1149
(*apply (auto simp add: starfun_inverse_inverse realpow_two
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  1150
        simp del: minus_mult_left [symmetric] minus_mult_right [symmetric])*)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1151
apply (simp add: inverse_add inverse_mult_distrib [symmetric]
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  1152
              inverse_minus_eq [symmetric] add_ac mult_ac diff_def
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1153
            del: inverse_mult_distrib inverse_minus_eq
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1154
                 minus_mult_left [symmetric] minus_mult_right [symmetric])
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1155
apply (simp (no_asm_simp) add: mult_assoc [symmetric] right_distrib
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1156
            del: minus_mult_left [symmetric] minus_mult_right [symmetric])
15234
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15228
diff changeset
  1157
apply (rule_tac y = "inverse (- hypreal_of_real x * hypreal_of_real x)" in approx_trans)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1158
apply (rule inverse_add_Infinitesimal_approx2)
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1159
apply (auto dest!: hypreal_of_real_HFinite_diff_Infinitesimal
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1160
            simp add: inverse_minus_eq [symmetric] HFinite_minus_iff)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1161
apply (rule Infinitesimal_HFinite_mult2, auto)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1162
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1163
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1164
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1165
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1166
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1167
lemma DERIV_inverse: "x \<noteq> 0 ==> DERIV (%x. inverse(x)) x :> (-(inverse x ^ Suc (Suc 0)))"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1168
by (simp add: NSDERIV_inverse NSDERIV_DERIV_iff [symmetric] del: realpow_Suc)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1169
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1170
text{*Derivative of inverse*}
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1171
lemma DERIV_inverse_fun: "[| DERIV f x :> d; f(x) \<noteq> 0 |]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1172
      ==> DERIV (%x. inverse(f x)) x :> (- (d * inverse(f(x) ^ Suc (Suc 0))))"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1173
apply (simp only: mult_commute [of d] minus_mult_left power_inverse)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1174
apply (fold o_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1175
apply (blast intro!: DERIV_chain DERIV_inverse)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1176
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1177
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1178
lemma NSDERIV_inverse_fun: "[| NSDERIV f x :> d; f(x) \<noteq> 0 |]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1179
      ==> NSDERIV (%x. inverse(f x)) x :> (- (d * inverse(f(x) ^ Suc (Suc 0))))"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1180
by (simp add: NSDERIV_DERIV_iff DERIV_inverse_fun del: realpow_Suc)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1181
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1182
text{*Derivative of quotient*}
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1183
lemma DERIV_quotient: "[| DERIV f x :> d; DERIV g x :> e; g(x) \<noteq> 0 |]
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  1184
       ==> DERIV (%y. f(y) / (g y)) x :> (d*g(x) - (e*f(x))) / (g(x) ^ Suc (Suc 0))"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1185
apply (drule_tac f = g in DERIV_inverse_fun)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1186
apply (drule_tac [2] DERIV_mult)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1187
apply (assumption+)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1188
apply (simp add: divide_inverse right_distrib power_inverse minus_mult_left
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  1189
                 mult_ac diff_def
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1190
     del: realpow_Suc minus_mult_right [symmetric] minus_mult_left [symmetric])
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1191
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1192
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1193
lemma NSDERIV_quotient: "[| NSDERIV f x :> d; DERIV g x :> e; g(x) \<noteq> 0 |]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1194
       ==> NSDERIV (%y. f(y) / (g y)) x :> (d*g(x)
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  1195
                            - (e*f(x))) / (g(x) ^ Suc (Suc 0))"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1196
by (simp add: NSDERIV_DERIV_iff DERIV_quotient del: realpow_Suc)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1197
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1198
(* ------------------------------------------------------------------------ *)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1199
(* Caratheodory formulation of derivative at a point: standard proof        *)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1200
(* ------------------------------------------------------------------------ *)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1201
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1202
lemma CARAT_DERIV:
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1203
     "(DERIV f x :> l) =
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1204
      (\<exists>g. (\<forall>z. f z - f x = g z * (z-x)) & isCont g x & g x = l)"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1205
      (is "?lhs = ?rhs")
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1206
proof
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1207
  assume der: "DERIV f x :> l"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1208
  show "\<exists>g. (\<forall>z. f z - f x = g z * (z-x)) \<and> isCont g x \<and> g x = l"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1209
  proof (intro exI conjI)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1210
    let ?g = "(%z. if z = x then l else (f z - f x) / (z-x))"
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15360
diff changeset
  1211
    show "\<forall>z. f z - f x = ?g z * (z-x)" by (simp)
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1212
    show "isCont ?g x" using der
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1213
      by (simp add: isCont_iff DERIV_iff diff_minus
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1214
               cong: LIM_equal [rule_format])
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1215
    show "?g x = l" by simp
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1216
  qed
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1217
next
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1218
  assume "?rhs"
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1219
  then obtain g where
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1220
    "(\<forall>z. f z - f x = g z * (z-x))" and "isCont g x" and "g x = l" by blast
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1221
  thus "(DERIV f x :> l)"
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1222
     by (auto simp add: isCont_iff DERIV_iff diff_minus
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1223
               cong: LIM_equal [rule_format])
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1224
qed
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1225
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1226
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1227
lemma CARAT_NSDERIV: "NSDERIV f x :> l ==>
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1228
      \<exists>g. (\<forall>z. f z - f x = g z * (z-x)) & isNSCont g x & g x = l"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1229
by (auto simp add: NSDERIV_DERIV_iff isNSCont_isCont_iff CARAT_DERIV)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1230
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1231
lemma hypreal_eq_minus_iff3: "(x = y + z) = (x + -z = (y::hypreal))"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1232
by auto
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1233
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1234
lemma CARAT_DERIVD:
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1235
  assumes all: "\<forall>z. f z - f x = g z * (z-x)"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1236
      and nsc: "isNSCont g x"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1237
  shows "NSDERIV f x :> g x"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1238
proof -
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1239
  from nsc
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1240
  have "\<forall>w. w \<noteq> hypreal_of_real x \<and> w \<approx> hypreal_of_real x \<longrightarrow>
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1241
         ( *f* g) w * (w - hypreal_of_real x) / (w - hypreal_of_real x) \<approx>
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1242
         hypreal_of_real (g x)"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1243
    by (simp add: diff_minus isNSCont_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1244
  thus ?thesis using all
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1245
    by (simp add: NSDERIV_iff2 starfun_if_eq cong: if_cong)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1246
qed
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1247
15234
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15228
diff changeset
  1248
text{*Lemmas about nested intervals and proof by bisection (cf.Harrison).
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15228
diff changeset
  1249
     All considerably tidied by lcp.*}
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1250
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1251
lemma lemma_f_mono_add [rule_format (no_asm)]: "(\<forall>n. (f::nat=>real) n \<le> f (Suc n)) --> f m \<le> f(m + no)"
15251
bb6f072c8d10 converted some induct_tac to induct
paulson
parents: 15234
diff changeset
  1252
apply (induct "no")
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1253
apply (auto intro: order_trans)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1254
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1255
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1256
lemma f_inc_g_dec_Beq_f: "[| \<forall>n. f(n) \<le> f(Suc n);
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1257
         \<forall>n. g(Suc n) \<le> g(n);
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1258
         \<forall>n. f(n) \<le> g(n) |]
20552
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
  1259
      ==> Bseq (f :: nat \<Rightarrow> real)"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1260
apply (rule_tac k = "f 0" and K = "g 0" in BseqI2, rule allI)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1261
apply (induct_tac "n")
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1262
apply (auto intro: order_trans)
15234
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15228
diff changeset
  1263
apply (rule_tac y = "g (Suc na)" in order_trans)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1264
apply (induct_tac [2] "na")
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1265
apply (auto intro: order_trans)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1266
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1267
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1268
lemma f_inc_g_dec_Beq_g: "[| \<forall>n. f(n) \<le> f(Suc n);
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1269
         \<forall>n. g(Suc n) \<le> g(n);
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1270
         \<forall>n. f(n) \<le> g(n) |]
20552
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
  1271
      ==> Bseq (g :: nat \<Rightarrow> real)"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1272
apply (subst Bseq_minus_iff [symmetric])
15234
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15228
diff changeset
  1273
apply (rule_tac g = "%x. - (f x)" in f_inc_g_dec_Beq_f)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1274
apply auto
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1275
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1276
20693
f763367e332f generalize types of lim and nslim
huffman
parents: 20653
diff