src/HOL/Hyperreal/Lim.thy
author huffman
Sat, 30 Sep 2006 19:41:06 +0200
changeset 20795 4e3adc66231a
parent 20794 02482f9501ac
child 20796 257e01fab4b7
permissions -rw-r--r--
generalized some DERIV proofs
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
20793
3b0489715b0e generalize type of DERIV
huffman
parents: 20756
diff changeset
    37
  deriv :: "[real \<Rightarrow> 'a::real_normed_vector, real, 'a] \<Rightarrow> 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)
20793
3b0489715b0e generalize type of DERIV
huffman
parents: 20756
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
20755
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
    76
subsection {* Limits of Functions *}
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
    77
20755
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
    78
subsubsection {* Purely standard proofs *}
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
    79
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
    80
lemma LIM_eq:
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
    81
     "f -- a --> L =
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
    82
     (\<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
    83
by (simp add: LIM_def diff_minus)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
    84
20552
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
    85
lemma LIM_I:
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
    86
     "(!!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
    87
      ==> f -- a --> L"
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
    88
by (simp add: LIM_eq)
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
    89
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
    90
lemma LIM_D:
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
    91
     "[| 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
    92
      ==> \<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
    93
by (simp add: LIM_eq)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
    94
20756
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
    95
lemma LIM_shift: "f -- a --> L \<Longrightarrow> (\<lambda>x. f (x + k)) -- a - k --> L"
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
    96
apply (rule LIM_I)
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
    97
apply (drule_tac r="r" in LIM_D, safe)
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
    98
apply (rule_tac x="s" in exI, safe)
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
    99
apply (drule_tac x="x + k" in spec)
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
   100
apply (simp add: compare_rls)
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
   101
done
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
   102
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   103
lemma LIM_const [simp]: "(%x. k) -- x --> k"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   104
by (simp add: LIM_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   105
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   106
lemma LIM_add:
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   107
  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
   108
  assumes f: "f -- a --> L" and g: "g -- a --> M"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   109
  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
   110
proof (rule LIM_I)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   111
  fix r :: real
20409
eba80f91e3fc speed up some proofs
huffman
parents: 20254
diff changeset
   112
  assume r: "0 < r"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   113
  from LIM_D [OF f half_gt_zero [OF r]]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   114
  obtain fs
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   115
    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
   116
      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
   117
  by blast
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   118
  from LIM_D [OF g half_gt_zero [OF r]]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   119
  obtain gs
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   120
    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
   121
      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
   122
  by blast
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   123
  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
   124
  proof (intro exI conjI strip)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   125
    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
   126
    fix x :: 'a
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   127
    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
   128
    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
   129
    with fs_lt gs_lt
20552
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   130
    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
   131
    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
   132
    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
   133
      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
   134
  qed
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   135
qed
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   136
20552
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   137
lemma minus_diff_minus:
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   138
  fixes a b :: "'a::ab_group_add"
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   139
  shows "(- a) - (- b) = - (a - b)"
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   140
by simp
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   141
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   142
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
   143
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
   144
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   145
lemma LIM_add_minus:
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   146
    "[| 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
   147
by (intro LIM_add LIM_minus)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   148
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   149
lemma LIM_diff:
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   150
    "[| 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
   151
by (simp only: diff_minus LIM_add LIM_minus)
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_not_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 "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
   156
apply (simp add: LIM_eq)
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   157
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
   158
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
   159
done
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   160
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   161
lemma LIM_const_eq:
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   162
  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
   163
  shows "(%x. k) -- a --> L ==> k = L"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   164
apply (rule ccontr)
19023
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
   165
apply (blast dest: LIM_const_not_eq)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   166
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   167
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   168
lemma LIM_unique:
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   169
  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
   170
  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
   171
apply (drule LIM_diff, assumption)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   172
apply (auto dest!: LIM_const_eq)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   173
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   174
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   175
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
   176
  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
   177
  assumes f: "f -- a --> 0" and g: "g -- a --> 0"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   178
  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
   179
proof (rule LIM_I, simp)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   180
  fix r :: real
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   181
  assume r: "0<r"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   182
  from LIM_D [OF f zero_less_one]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   183
  obtain fs
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   184
    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
   185
      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
   186
  by auto
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   187
  from LIM_D [OF g r]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   188
  obtain gs
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   189
    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
   190
      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
   191
  by auto
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   192
  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
   193
  proof (intro exI conjI strip)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   194
    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
   195
    fix x :: 'a
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   196
    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
   197
    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
   198
    with fs_lt gs_lt
20552
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   199
    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
   200
    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
   201
      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
   202
    thus "norm (f x * g x) < r"
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   203
      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
   204
  qed
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   205
qed
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
lemma LIM_self: "(%x. x) -- a --> a"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   208
by (auto simp add: LIM_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   209
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   210
text{*Limits are equal for functions equal except at limit point*}
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   211
lemma LIM_equal:
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   212
     "[| \<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
   213
by (simp add: LIM_def)
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
text{*Two uses in Hyperreal/Transcendental.ML*}
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   216
lemma LIM_trans:
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   217
     "[| (%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
   218
apply (drule LIM_add, assumption)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   219
apply (auto simp add: add_assoc)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   220
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   221
20755
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   222
subsubsection {* Purely nonstandard proofs *}
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   223
20754
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   224
lemma NSLIM_I:
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   225
  "(\<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
   226
   \<Longrightarrow> f -- a --NS> L"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   227
by (simp add: NSLIM_def)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   228
20754
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   229
lemma NSLIM_D:
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   230
  "\<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
   231
   \<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
   232
by (simp add: NSLIM_def)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   233
20755
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   234
text{*Proving properties of limits using nonstandard definition.
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   235
      The properties hold for standard limits as well!*}
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   236
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   237
lemma NSLIM_mult:
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   238
  fixes l m :: "'a::real_normed_algebra"
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   239
  shows "[| f -- x --NS> l; g -- x --NS> m |]
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   240
      ==> (%x. f(x) * g(x)) -- x --NS> (l * m)"
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   241
by (auto simp add: NSLIM_def intro!: approx_mult_HFinite)
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   242
20794
02482f9501ac add scaleR lemmas
huffman
parents: 20793
diff changeset
   243
lemma starfun_scaleR [simp]:
02482f9501ac add scaleR lemmas
huffman
parents: 20793
diff changeset
   244
  "starfun (\<lambda>x. f x *# g x) = (\<lambda>x. scaleHR (starfun f x) (starfun g x))"
02482f9501ac add scaleR lemmas
huffman
parents: 20793
diff changeset
   245
by transfer (rule refl)
02482f9501ac add scaleR lemmas
huffman
parents: 20793
diff changeset
   246
02482f9501ac add scaleR lemmas
huffman
parents: 20793
diff changeset
   247
lemma NSLIM_scaleR:
02482f9501ac add scaleR lemmas
huffman
parents: 20793
diff changeset
   248
  "[| f -- x --NS> l; g -- x --NS> m |]
02482f9501ac add scaleR lemmas
huffman
parents: 20793
diff changeset
   249
      ==> (%x. f(x) *# g(x)) -- x --NS> (l *# m)"
02482f9501ac add scaleR lemmas
huffman
parents: 20793
diff changeset
   250
by (auto simp add: NSLIM_def intro!: approx_scaleR_HFinite)
02482f9501ac add scaleR lemmas
huffman
parents: 20793
diff changeset
   251
20755
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   252
lemma NSLIM_add:
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   253
     "[| f -- x --NS> l; g -- x --NS> m |]
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   254
      ==> (%x. f(x) + g(x)) -- x --NS> (l + m)"
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   255
by (auto simp add: NSLIM_def intro!: approx_add)
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   256
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   257
lemma NSLIM_const [simp]: "(%x. k) -- x --NS> k"
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   258
by (simp add: NSLIM_def)
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   259
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   260
lemma NSLIM_minus: "f -- a --NS> L ==> (%x. -f(x)) -- a --NS> -L"
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   261
by (simp add: NSLIM_def)
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   262
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   263
lemma NSLIM_add_minus: "[| f -- x --NS> l; g -- x --NS> m |] ==> (%x. f(x) + -g(x)) -- x --NS> (l + -m)"
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   264
by (simp only: NSLIM_add NSLIM_minus)
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   265
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   266
lemma NSLIM_inverse:
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   267
  fixes L :: "'a::real_normed_div_algebra"
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   268
  shows "[| f -- a --NS> L;  L \<noteq> 0 |]
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   269
      ==> (%x. inverse(f(x))) -- a --NS> (inverse L)"
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   270
apply (simp add: NSLIM_def, clarify)
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   271
apply (drule spec)
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   272
apply (auto simp add: star_of_approx_inverse)
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   273
done
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   274
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   275
lemma NSLIM_zero:
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   276
  assumes f: "f -- a --NS> l" shows "(%x. f(x) + -l) -- a --NS> 0"
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   277
proof -
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   278
  have "(\<lambda>x. f x + - l) -- a --NS> l + -l"
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   279
    by (rule NSLIM_add_minus [OF f NSLIM_const])
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   280
  thus ?thesis by simp
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   281
qed
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   282
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   283
lemma NSLIM_zero_cancel: "(%x. f(x) - l) -- x --NS> 0 ==> f -- x --NS> l"
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   284
apply (drule_tac g = "%x. l" and m = l in NSLIM_add)
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   285
apply (auto simp add: diff_minus add_assoc)
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   286
done
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   287
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   288
lemma NSLIM_const_not_eq:
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   289
  fixes a :: real (* TODO: generalize to real_normed_div_algebra *)
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   290
  shows "k \<noteq> L ==> ~ ((%x. k) -- a --NS> L)"
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   291
apply (simp add: NSLIM_def)
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   292
apply (rule_tac x="star_of a + epsilon" in exI)
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   293
apply (auto intro: Infinitesimal_add_approx_self [THEN approx_sym]
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   294
            simp add: hypreal_epsilon_not_zero)
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   295
done
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   296
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   297
lemma NSLIM_not_zero:
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   298
  fixes a :: real
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   299
  shows "k \<noteq> 0 ==> ~ ((%x. k) -- a --NS> 0)"
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   300
by (rule NSLIM_const_not_eq)
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   301
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   302
lemma NSLIM_const_eq:
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   303
  fixes a :: real
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   304
  shows "(%x. k) -- a --NS> L ==> k = L"
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   305
apply (rule ccontr)
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   306
apply (blast dest: NSLIM_const_not_eq)
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   307
done
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   308
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   309
text{* can actually be proved more easily by unfolding the definition!*}
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   310
lemma NSLIM_unique:
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   311
  fixes a :: real
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   312
  shows "[| f -- a --NS> L; f -- a --NS> M |] ==> L = M"
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   313
apply (drule NSLIM_minus)
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   314
apply (drule NSLIM_add, assumption)
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   315
apply (auto dest!: NSLIM_const_eq [symmetric])
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   316
apply (simp add: diff_def [symmetric])
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   317
done
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   318
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   319
lemma NSLIM_mult_zero:
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   320
  fixes f g :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_algebra"
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   321
  shows "[| f -- x --NS> 0; g -- x --NS> 0 |] ==> (%x. f(x)*g(x)) -- x --NS> 0"
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   322
by (drule NSLIM_mult, auto)
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   323
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   324
lemma NSLIM_self: "(%x. x) -- a --NS> a"
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   325
by (simp add: NSLIM_def)
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   326
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   327
subsubsection {* Equivalence of @{term LIM} and @{term NSLIM} *}
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   328
20754
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   329
lemma LIM_NSLIM:
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   330
  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
   331
proof (rule NSLIM_I)
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   332
  fix x
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   333
  assume neq: "x \<noteq> star_of a"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   334
  assume approx: "x \<approx> star_of a"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   335
  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
   336
  proof (rule InfinitesimalI2)
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   337
    fix r::real assume r: "0 < r"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   338
    from LIM_D [OF f r]
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   339
    obtain s where s: "0 < s" and
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   340
      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
   341
      by fast
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   342
    from less_r have less_r':
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   343
       "\<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
   344
        \<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
   345
      by transfer
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   346
    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
   347
      by (unfold approx_def)
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   348
    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
   349
      using s by (rule InfinitesimalD2)
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   350
    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
   351
      by (rule less_r')
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   352
  qed
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   353
  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
   354
    by (unfold approx_def)
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   355
qed
20552
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   356
20754
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   357
lemma NSLIM_LIM:
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   358
  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
   359
proof (rule LIM_I)
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   360
  fix r::real assume r: "0 < r"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   361
  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
   362
        \<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
   363
  proof (rule exI, safe)
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   364
    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
   365
  next
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   366
    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
   367
    assume "hnorm (x - star_of a) < epsilon"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   368
    with Infinitesimal_epsilon
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   369
    have "x - star_of a \<in> Infinitesimal"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   370
      by (rule hnorm_less_Infinitesimal)
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   371
    hence "x \<approx> star_of a"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   372
      by (unfold approx_def)
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   373
    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
   374
      by (rule NSLIM_D)
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   375
    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
   376
      by (unfold approx_def)
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   377
    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
   378
      using r by (rule InfinitesimalD2)
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   379
  qed
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   380
  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
   381
    by transfer
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   382
qed
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   383
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   384
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
   385
by (blast intro: LIM_NSLIM NSLIM_LIM)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   386
20755
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   387
subsubsection {* Derived theorems about @{term LIM} *}
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   388
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   389
lemma LIM_mult2:
20552
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   390
  fixes l m :: "'a::real_normed_algebra"
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   391
  shows "[| f -- x --> l; g -- x --> m |]
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   392
      ==> (%x. f(x) * g(x)) -- x --> (l * m)"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   393
by (simp add: LIM_NSLIM_iff NSLIM_mult)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   394
20794
02482f9501ac add scaleR lemmas
huffman
parents: 20793
diff changeset
   395
lemma LIM_scaleR:
02482f9501ac add scaleR lemmas
huffman
parents: 20793
diff changeset
   396
  "[| f -- x --> l; g -- x --> m |]
02482f9501ac add scaleR lemmas
huffman
parents: 20793
diff changeset
   397
      ==> (%x. f(x) *# g(x)) -- x --> (l *# m)"
02482f9501ac add scaleR lemmas
huffman
parents: 20793
diff changeset
   398
by (simp add: LIM_NSLIM_iff NSLIM_scaleR)
02482f9501ac add scaleR lemmas
huffman
parents: 20793
diff changeset
   399
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   400
lemma LIM_add2:
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   401
     "[| 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
   402
by (simp add: LIM_NSLIM_iff NSLIM_add)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   403
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   404
lemma LIM_const2: "(%x. k) -- x --> k"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   405
by (simp add: LIM_NSLIM_iff)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   406
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   407
lemma LIM_minus2: "f -- a --> L ==> (%x. -f(x)) -- a --> -L"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   408
by (simp add: LIM_NSLIM_iff NSLIM_minus)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   409
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   410
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
   411
by (simp add: LIM_NSLIM_iff NSLIM_add_minus)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   412
20552
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   413
lemma LIM_inverse:
20653
24cda2c5fd40 removed division_by_zero class requirements from several lemmas
huffman
parents: 20635
diff changeset
   414
  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
   415
  shows "[| f -- a --> L; L \<noteq> 0 |]
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   416
      ==> (%x. inverse(f(x))) -- a --> (inverse L)"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   417
by (simp add: LIM_NSLIM_iff NSLIM_inverse)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   418
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   419
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
   420
by (simp add: LIM_NSLIM_iff NSLIM_zero)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   421
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   422
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
   423
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
   424
apply (auto simp add: diff_minus add_assoc)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   425
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   426
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   427
lemma LIM_unique2:
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   428
  fixes a :: real
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   429
  shows "[| f -- a --> L; f -- a --> M |] ==> L = M"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   430
by (simp add: LIM_NSLIM_iff NSLIM_unique)
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
(* we can use the corresponding thm LIM_mult2 *)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   433
(* for standard definition of limit           *)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   434
20552
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   435
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
   436
  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
   437
  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
   438
by (drule LIM_mult2, auto)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   439
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   440
20755
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   441
subsection {* Continuity *}
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   442
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   443
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
   444
by (simp add: isNSCont_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   445
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   446
lemma isNSCont_NSLIM: "isNSCont f a ==> f -- a --NS> (f a) "
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   447
by (simp add: isNSCont_def NSLIM_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   448
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   449
lemma NSLIM_isNSCont: "f -- a --NS> (f a) ==> isNSCont f a"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   450
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
   451
apply (case_tac "y = star_of a", auto)
14477
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{*NS continuity can be defined using NS Limit in
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   455
    similar fashion to standard def of continuity*}
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   456
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
   457
by (blast intro: isNSCont_NSLIM NSLIM_isNSCont)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   458
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   459
text{*Hence, NS continuity can be given
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   460
  in terms of standard limit*}
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   461
lemma isNSCont_LIM_iff: "(isNSCont f a) = (f -- a --> (f a))"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   462
by (simp add: LIM_NSLIM_iff isNSCont_NSLIM_iff)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   463
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   464
text{*Moreover, it's trivial now that NS continuity
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   465
  is equivalent to standard continuity*}
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   466
lemma isNSCont_isCont_iff: "(isNSCont f a) = (isCont f a)"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   467
apply (simp add: isCont_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   468
apply (rule isNSCont_LIM_iff)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   469
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   470
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   471
text{*Standard continuity ==> NS continuity*}
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   472
lemma isCont_isNSCont: "isCont f a ==> isNSCont f a"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   473
by (erule isNSCont_isCont_iff [THEN iffD2])
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   474
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   475
text{*NS continuity ==> Standard continuity*}
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   476
lemma isNSCont_isCont: "isNSCont f a ==> isCont f a"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   477
by (erule isNSCont_isCont_iff [THEN iffD1])
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   478
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   479
text{*Alternative definition of continuity*}
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   480
(* Prove equivalence between NS limits - *)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   481
(* seems easier than using standard def  *)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   482
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
   483
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
   484
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
   485
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
   486
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
   487
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
   488
 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
   489
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
   490
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
   491
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
   492
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   493
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   494
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
   495
by (rule NSLIM_h_iff)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   496
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   497
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
   498
by (simp add: LIM_NSLIM_iff NSLIM_isCont_iff)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   499
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   500
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
   501
by (simp add: isCont_def LIM_isCont_iff)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   502
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   503
text{*Immediate application of nonstandard criterion for continuity can offer
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   504
   very simple proofs of some standard property of continuous functions*}
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   505
text{*sum continuous*}
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   506
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
   507
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
   508
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   509
text{*mult continuous*}
20552
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   510
lemma isCont_mult:
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   511
  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
   512
  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
   513
by (auto intro!: starfun_mult_HFinite_approx
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   514
            simp del: starfun_mult [symmetric]
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   515
            simp add: isNSCont_isCont_iff [symmetric] isNSCont_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   516
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   517
text{*composition of continuous functions
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   518
     Note very short straightforard proof!*}
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   519
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
   520
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
   521
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   522
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
   523
by (auto dest: isCont_o simp add: o_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   524
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   525
lemma isNSCont_minus: "isNSCont f a ==> isNSCont (%x. - f x) a"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   526
by (simp add: isNSCont_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   527
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   528
lemma isCont_minus: "isCont f a ==> isCont (%x. - f x) a"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   529
by (auto simp add: isNSCont_isCont_iff [symmetric] isNSCont_minus)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   530
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   531
lemma isCont_inverse:
20653
24cda2c5fd40 removed division_by_zero class requirements from several lemmas
huffman
parents: 20635
diff changeset
   532
  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
   533
  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
   534
apply (simp add: isCont_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   535
apply (blast intro: LIM_inverse)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   536
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   537
20552
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
   538
lemma isNSCont_inverse:
20653
24cda2c5fd40 removed division_by_zero class requirements from several lemmas
huffman
parents: 20635
diff changeset
   539
  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
   540
  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
   541
by (auto intro: isCont_inverse simp add: isNSCont_isCont_iff)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   542
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   543
lemma isCont_diff:
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   544
      "[| 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
   545
apply (simp add: diff_minus)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   546
apply (auto intro: isCont_add isCont_minus)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   547
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   548
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   549
lemma isCont_const [simp]: "isCont (%x. k) a"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   550
by (simp add: isCont_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   551
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   552
lemma isNSCont_const [simp]: "isNSCont (%x. k) a"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   553
by (simp add: isNSCont_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   554
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   555
lemma isNSCont_abs [simp]: "isNSCont abs (a::real)"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   556
apply (simp add: isNSCont_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   557
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
   558
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   559
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
   560
lemma isCont_abs [simp]: "isCont abs (a::real)"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   561
by (auto simp add: isNSCont_isCont_iff [symmetric])
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   562
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   563
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   564
(****************************************************************
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   565
(%* Leave as commented until I add topology theory or remove? *%)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   566
(%*------------------------------------------------------------
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   567
  Elementary topology proof for a characterisation of
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   568
  continuity now: a function f is continuous if and only
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   569
  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
   570
  is always an open set
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   571
 ------------------------------------------------------------*%)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   572
Goal "[| isNSopen A; \<forall>x. isNSCont f x |]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   573
               ==> isNSopen {x. f x \<in> A}"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   574
by (auto_tac (claset(),simpset() addsimps [isNSopen_iff1]));
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   575
by (dtac (mem_monad_approx RS approx_sym);
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   576
by (dres_inst_tac [("x","a")] spec 1);
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   577
by (dtac isNSContD 1 THEN assume_tac 1)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   578
by (dtac bspec 1 THEN assume_tac 1)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   579
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
   580
by (blast_tac (claset() addIs [starfun_mem_starset]);
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   581
qed "isNSCont_isNSopen";
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   582
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   583
Goalw [isNSCont_def]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   584
          "\<forall>A. isNSopen A --> isNSopen {x. f x \<in> A} \
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   585
\              ==> isNSCont f x";
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   586
by (auto_tac (claset() addSIs [(mem_infmal_iff RS iffD1) RS
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   587
     (approx_minus_iff RS iffD2)],simpset() addsimps
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   588
      [Infinitesimal_def,SReal_iff]));
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   589
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
   590
by (etac (isNSopen_open_interval RSN (2,impE));
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   591
by (auto_tac (claset(),simpset() addsimps [isNSopen_def,isNSnbhd_def]));
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   592
by (dres_inst_tac [("x","x")] spec 1);
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   593
by (auto_tac (claset() addDs [approx_sym RS approx_mem_monad],
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   594
    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
   595
qed "isNSopen_isNSCont";
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   596
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   597
Goal "(\<forall>x. isNSCont f x) = \
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   598
\     (\<forall>A. isNSopen A --> isNSopen {x. f(x) \<in> A})";
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   599
by (blast_tac (claset() addIs [isNSCont_isNSopen,
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   600
    isNSopen_isNSCont]);
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   601
qed "isNSCont_isNSopen_iff";
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   602
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   603
(%*------- Standard version of same theorem --------*%)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   604
Goal "(\<forall>x. isCont f x) = \
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   605
\         (\<forall>A. isopen A --> isopen {x. f(x) \<in> A})";
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   606
by (auto_tac (claset() addSIs [isNSCont_isNSopen_iff],
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   607
              simpset() addsimps [isNSopen_isopen_iff RS sym,
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   608
              isNSCont_isCont_iff RS sym]));
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   609
qed "isCont_isopen_iff";
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   610
*******************************************************************)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   611
20755
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   612
subsection {* Uniform Continuity *}
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   613
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   614
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
   615
by (simp add: isNSUCont_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   616
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   617
lemma isUCont_isCont: "isUCont f ==> isCont f x"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   618
by (simp add: isUCont_def isCont_def LIM_def, meson)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   619
20754
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   620
lemma isUCont_isNSUCont:
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   621
  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
   622
  assumes f: "isUCont f" shows "isNSUCont f"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   623
proof (unfold isNSUCont_def, safe)
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   624
  fix x y :: "'a star"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   625
  assume approx: "x \<approx> y"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   626
  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
   627
  proof (rule InfinitesimalI2)
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   628
    fix r::real assume r: "0 < r"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   629
    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
   630
      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
   631
      by (auto simp add: isUCont_def)
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   632
    from less_r have less_r':
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   633
       "\<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
   634
        \<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
   635
      by transfer
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   636
    from approx have "x - y \<in> Infinitesimal"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   637
      by (unfold approx_def)
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   638
    hence "hnorm (x - y) < star_of s"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   639
      using s by (rule InfinitesimalD2)
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   640
    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
   641
      by (rule less_r')
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   642
  qed
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   643
  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
   644
    by (unfold approx_def)
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   645
qed
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   646
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   647
lemma isNSUCont_isUCont:
20754
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   648
  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
   649
  assumes f: "isNSUCont f" shows "isUCont f"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   650
proof (unfold isUCont_def, safe)
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   651
  fix r::real assume r: "0 < r"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   652
  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
   653
        \<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
   654
  proof (rule exI, safe)
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   655
    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
   656
  next
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   657
    fix x y :: "'a star"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   658
    assume "hnorm (x - y) < epsilon"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   659
    with Infinitesimal_epsilon
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   660
    have "x - y \<in> Infinitesimal"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   661
      by (rule hnorm_less_Infinitesimal)
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   662
    hence "x \<approx> y"
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   663
      by (unfold approx_def)
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   664
    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
   665
      by (simp add: isNSUCont_def)
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   666
    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
   667
      by (unfold approx_def)
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   668
    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
   669
      using r by (rule InfinitesimalD2)
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   670
  qed
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   671
  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
   672
    by transfer
9c053a494dc6 add intro/dest rules for NSLIM; rewrite equivalence proofs using transfer
huffman
parents: 20752
diff changeset
   673
qed
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   674
20755
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   675
subsection {* Derivatives *}
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   676
20756
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
   677
subsubsection {* Purely standard proofs *}
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
   678
20793
3b0489715b0e generalize type of DERIV
huffman
parents: 20756
diff changeset
   679
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
   680
by (simp add: deriv_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   681
20793
3b0489715b0e generalize type of DERIV
huffman
parents: 20756
diff changeset
   682
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
   683
by (simp add: deriv_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   684
20795
4e3adc66231a generalized some DERIV proofs
huffman
parents: 20794
diff changeset
   685
lemma DERIV_const [simp]: "DERIV (\<lambda>x. k) x :> 0"
4e3adc66231a generalized some DERIV proofs
huffman
parents: 20794
diff changeset
   686
by (simp add: deriv_def)
4e3adc66231a generalized some DERIV proofs
huffman
parents: 20794
diff changeset
   687
4e3adc66231a generalized some DERIV proofs
huffman
parents: 20794
diff changeset
   688
lemma DERIV_Id [simp]: "DERIV (\<lambda>x. x) x :> 1"
4e3adc66231a generalized some DERIV proofs
huffman
parents: 20794
diff changeset
   689
by (simp add: deriv_def real_scaleR_def cong: LIM_equal [rule_format])
4e3adc66231a generalized some DERIV proofs
huffman
parents: 20794
diff changeset
   690
4e3adc66231a generalized some DERIV proofs
huffman
parents: 20794
diff changeset
   691
lemma add_diff_add:
4e3adc66231a generalized some DERIV proofs
huffman
parents: 20794
diff changeset
   692
  fixes a b c d :: "'a::ab_group_add"
4e3adc66231a generalized some DERIV proofs
huffman
parents: 20794
diff changeset
   693
  shows "(a + c) - (b + d) = (a - b) + (c - d)"
4e3adc66231a generalized some DERIV proofs
huffman
parents: 20794
diff changeset
   694
by simp
4e3adc66231a generalized some DERIV proofs
huffman
parents: 20794
diff changeset
   695
4e3adc66231a generalized some DERIV proofs
huffman
parents: 20794
diff changeset
   696
lemma DERIV_add:
4e3adc66231a generalized some DERIV proofs
huffman
parents: 20794
diff changeset
   697
  "\<lbrakk>DERIV f x :> D; DERIV g x :> E\<rbrakk> \<Longrightarrow> DERIV (\<lambda>x. f x + g x) x :> D + E"
4e3adc66231a generalized some DERIV proofs
huffman
parents: 20794
diff changeset
   698
by (simp only: deriv_def add_diff_add scaleR_right_distrib LIM_add)
4e3adc66231a generalized some DERIV proofs
huffman
parents: 20794
diff changeset
   699
4e3adc66231a generalized some DERIV proofs
huffman
parents: 20794
diff changeset
   700
lemma DERIV_minus:
4e3adc66231a generalized some DERIV proofs
huffman
parents: 20794
diff changeset
   701
  "DERIV f x :> D \<Longrightarrow> DERIV (\<lambda>x. - f x) x :> - D"
4e3adc66231a generalized some DERIV proofs
huffman
parents: 20794
diff changeset
   702
by (simp only: deriv_def minus_diff_minus scaleR_minus_right LIM_minus)
4e3adc66231a generalized some DERIV proofs
huffman
parents: 20794
diff changeset
   703
4e3adc66231a generalized some DERIV proofs
huffman
parents: 20794
diff changeset
   704
lemma DERIV_diff:
4e3adc66231a generalized some DERIV proofs
huffman
parents: 20794
diff changeset
   705
  "\<lbrakk>DERIV f x :> D; DERIV g x :> E\<rbrakk> \<Longrightarrow> DERIV (\<lambda>x. f x - g x) x :> D - E"
4e3adc66231a generalized some DERIV proofs
huffman
parents: 20794
diff changeset
   706
by (simp only: diff_def DERIV_add DERIV_minus)
4e3adc66231a generalized some DERIV proofs
huffman
parents: 20794
diff changeset
   707
4e3adc66231a generalized some DERIV proofs
huffman
parents: 20794
diff changeset
   708
lemma DERIV_add_minus:
4e3adc66231a generalized some DERIV proofs
huffman
parents: 20794
diff changeset
   709
  "\<lbrakk>DERIV f x :> D; DERIV g x :> E\<rbrakk> \<Longrightarrow> DERIV (\<lambda>x. f x + - g x) x :> D + - E"
4e3adc66231a generalized some DERIV proofs
huffman
parents: 20794
diff changeset
   710
by (simp only: DERIV_add DERIV_minus)
4e3adc66231a generalized some DERIV proofs
huffman
parents: 20794
diff changeset
   711
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   712
lemma DERIV_unique:
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   713
      "[| DERIV f x :> D; DERIV f x :> E |] ==> D = E"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   714
apply (simp add: deriv_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   715
apply (blast intro: LIM_unique)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   716
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   717
20756
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
   718
text{*Alternative definition for differentiability*}
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
   719
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
   720
lemma DERIV_LIM_iff:
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
   721
     "((%h::real. (f(a + h) - f(a)) / h) -- 0 --> D) =
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
   722
      ((%x. (f(x)-f(a)) / (x-a)) -- a --> D)"
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
   723
apply (rule iffI)
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
   724
apply (drule_tac k="- a" in LIM_shift)
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
   725
apply (simp add: diff_minus)
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
   726
apply (drule_tac k="a" in LIM_shift)
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
   727
apply (simp add: add_commute)
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
   728
done
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
   729
20793
3b0489715b0e generalize type of DERIV
huffman
parents: 20756
diff changeset
   730
lemma DERIV_LIM_iff':
3b0489715b0e generalize type of DERIV
huffman
parents: 20756
diff changeset
   731
     "((%h::real. (f(a + h) - f(a)) /# h) -- 0 --> D) =
3b0489715b0e generalize type of DERIV
huffman
parents: 20756
diff changeset
   732
      ((%x. (f(x)-f(a)) /# (x-a)) -- a --> D)"
3b0489715b0e generalize type of DERIV
huffman
parents: 20756
diff changeset
   733
apply (rule iffI)
3b0489715b0e generalize type of DERIV
huffman
parents: 20756
diff changeset
   734
apply (drule_tac k="- a" in LIM_shift)
3b0489715b0e generalize type of DERIV
huffman
parents: 20756
diff changeset
   735
apply (simp add: diff_minus)
3b0489715b0e generalize type of DERIV
huffman
parents: 20756
diff changeset
   736
apply (drule_tac k="a" in LIM_shift)
3b0489715b0e generalize type of DERIV
huffman
parents: 20756
diff changeset
   737
apply (simp add: add_commute)
3b0489715b0e generalize type of DERIV
huffman
parents: 20756
diff changeset
   738
done
3b0489715b0e generalize type of DERIV
huffman
parents: 20756
diff changeset
   739
3b0489715b0e generalize type of DERIV
huffman
parents: 20756
diff changeset
   740
lemma DERIV_iff2: "(DERIV f x :> D) = ((%z. (f(z) - f(x)) /# (z-x)) -- x --> D)"
3b0489715b0e generalize type of DERIV
huffman
parents: 20756
diff changeset
   741
by (simp add: deriv_def diff_minus [symmetric] DERIV_LIM_iff')
20756
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
   742
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
   743
(* ------------------------------------------------------------------------ *)
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
   744
(* Caratheodory formulation of derivative at a point: standard proof        *)
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
   745
(* ------------------------------------------------------------------------ *)
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
   746
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
   747
lemma CARAT_DERIV:
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
   748
     "(DERIV f x :> l) =
20793
3b0489715b0e generalize type of DERIV
huffman
parents: 20756
diff changeset
   749
      (\<exists>g. (\<forall>z. f z - f x = (z-x) *# g z) & isCont g x & g x = l)"
20756
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
   750
      (is "?lhs = ?rhs")
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
   751
proof
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
   752
  assume der: "DERIV f x :> l"
20793
3b0489715b0e generalize type of DERIV
huffman
parents: 20756
diff changeset
   753
  show "\<exists>g. (\<forall>z. f z - f x = (z-x) *# g z) \<and> isCont g x \<and> g x = l"
20756
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
   754
  proof (intro exI conjI)
20793
3b0489715b0e generalize type of DERIV
huffman
parents: 20756
diff changeset
   755
    let ?g = "(%z. if z = x then l else (f z - f x) /# (z-x))"
3b0489715b0e generalize type of DERIV
huffman
parents: 20756
diff changeset
   756
    show "\<forall>z. f z - f x = (z-x) *# ?g z" by (simp)
20756
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
   757
    show "isCont ?g x" using der
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
   758
      by (simp add: isCont_iff DERIV_iff diff_minus
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
   759
               cong: LIM_equal [rule_format])
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
   760
    show "?g x = l" by simp
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
   761
  qed
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
   762
next
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
   763
  assume "?rhs"
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
   764
  then obtain g where
20793
3b0489715b0e generalize type of DERIV
huffman
parents: 20756
diff changeset
   765
    "(\<forall>z. f z - f x = (z-x) *# g z)" and "isCont g x" and "g x = l" by blast
20756
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
   766
  thus "(DERIV f x :> l)"
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
   767
     by (auto simp add: isCont_iff DERIV_iff diff_minus
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
   768
               cong: LIM_equal [rule_format])
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
   769
qed
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
   770
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
   771
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
   772
20793
3b0489715b0e generalize type of DERIV
huffman
parents: 20756
diff changeset
   773
subsubsection {* Nonstandard proofs *}
20756
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
   774
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
   775
lemma DERIV_NS_iff:
20793
3b0489715b0e generalize type of DERIV
huffman
parents: 20756
diff changeset
   776
      "(DERIV f x :> D) = ((%h. (f(x + h) - f(x))/#h) -- 0 --NS> D)"
20756
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
   777
by (simp add: deriv_def LIM_NSLIM_iff)
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
   778
20793
3b0489715b0e generalize type of DERIV
huffman
parents: 20756
diff changeset
   779
lemma NS_DERIV_D: "DERIV f x :> D ==> (%h. (f(x + h) - f(x))/#h) -- 0 --NS> D"
20756
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
   780
by (simp add: deriv_def LIM_NSLIM_iff)
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
   781
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   782
lemma NSDeriv_unique:
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   783
     "[| NSDERIV f x :> D; NSDERIV f x :> E |] ==> D = E"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   784
apply (simp add: nsderiv_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   785
apply (cut_tac Infinitesimal_epsilon hypreal_epsilon_not_zero)
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   786
apply (auto dest!: bspec [where x=epsilon]
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   787
            intro!: inj_hypreal_of_real [THEN injD]
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   788
            dest: approx_trans3)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   789
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   790
20755
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
   791
text {*First NSDERIV in terms of NSLIM*}
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   792
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   793
text{*first equivalence *}
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   794
lemma NSDERIV_NSLIM_iff:
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
   795
      "(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
   796
apply (simp add: nsderiv_def NSLIM_def, auto)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   797
apply (drule_tac x = xa in bspec)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   798
apply (rule_tac [3] ccontr)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   799
apply (drule_tac [3] x = h in spec)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   800
apply (auto simp add: mem_infmal_iff starfun_lambda_cancel)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   801
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   802
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   803
text{*second equivalence *}
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   804
lemma NSDERIV_NSLIM_iff2:
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   805
     "(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
   806
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
   807
              LIM_NSLIM_iff [symmetric])
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   808
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   809
(* while we're at it! *)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   810
lemma NSDERIV_iff2:
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   811
     "(NSDERIV f x :> D) =
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   812
      (\<forall>w.
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   813
        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
   814
        ( *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
   815
by (simp add: NSDERIV_NSLIM_iff2 NSLIM_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   816
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   817
(*FIXME DELETE*)
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
   818
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
   819
by (auto dest: hypreal_eq_minus_iff [THEN iffD2])
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   820
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   821
lemma NSDERIVD5:
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   822
  "(NSDERIV f x :> D) ==>
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   823
   (\<forall>u. u \<approx> hypreal_of_real x -->
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   824
     ( *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
   825
apply (auto simp add: NSDERIV_iff2)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   826
apply (case_tac "u = hypreal_of_real x", auto)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   827
apply (drule_tac x = u in spec, auto)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   828
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
   829
apply (drule_tac [!] hypreal_not_eq_minus_iff [THEN iffD1])
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   830
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
   831
apply (auto simp add:
19023
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
   832
         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
   833
         Infinitesimal_subset_HFinite [THEN subsetD])
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   834
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   835
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   836
lemma NSDERIVD4:
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   837
     "(NSDERIV f x :> D) ==>
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   838
      (\<forall>h \<in> Infinitesimal.
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   839
               (( *f* f)(hypreal_of_real x + h) -
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   840
                 hypreal_of_real (f x))\<approx> (hypreal_of_real D) * h)"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   841
apply (auto simp add: nsderiv_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   842
apply (case_tac "h = (0::hypreal) ")
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   843
apply (auto simp add: diff_minus)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   844
apply (drule_tac x = h in bspec)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   845
apply (drule_tac [2] c = h in approx_mult1)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   846
apply (auto intro: Infinitesimal_subset_HFinite [THEN subsetD]
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15360
diff changeset
   847
            simp add: diff_minus)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   848
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   849
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   850
lemma NSDERIVD3:
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   851
     "(NSDERIV f x :> D) ==>
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   852
      (\<forall>h \<in> Infinitesimal - {0}.
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   853
               (( *f* f)(hypreal_of_real x + h) -
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   854
                 hypreal_of_real (f x))\<approx> (hypreal_of_real D) * h)"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   855
apply (auto simp add: nsderiv_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   856
apply (rule ccontr, drule_tac x = h in bspec)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   857
apply (drule_tac [2] c = h in approx_mult1)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   858
apply (auto intro: Infinitesimal_subset_HFinite [THEN subsetD]
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15360
diff changeset
   859
            simp add: mult_assoc diff_minus)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   860
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   861
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   862
text{*Differentiability implies continuity
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   863
         nice and simple "algebraic" proof*}
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   864
lemma NSDERIV_isNSCont: "NSDERIV f x :> D ==> isNSCont f x"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   865
apply (auto simp add: nsderiv_def isNSCont_NSLIM_iff NSLIM_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   866
apply (drule approx_minus_iff [THEN iffD1])
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   867
apply (drule hypreal_not_eq_minus_iff [THEN iffD1])
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
   868
apply (drule_tac x = "xa - hypreal_of_real x" in bspec)
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   869
 prefer 2 apply (simp add: add_assoc [symmetric])
15234
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15228
diff changeset
   870
apply (auto simp add: mem_infmal_iff [symmetric] add_commute)
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
   871
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
   872
apply (auto intro: Infinitesimal_subset_HFinite [THEN subsetD]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   873
            simp add: mult_assoc)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   874
apply (drule_tac x3=D in
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   875
           HFinite_hypreal_of_real [THEN [2] Infinitesimal_HFinite_mult,
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   876
             THEN mem_infmal_iff [THEN iffD1]])
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15360
diff changeset
   877
apply (auto simp add: mult_commute
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   878
            intro: approx_trans approx_minus_iff [THEN iffD2])
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   879
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   880
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   881
text{*Differentiation rules for combinations of functions
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   882
      follow from clear, straightforard, algebraic
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   883
      manipulations*}
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   884
text{*Constant function*}
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   885
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   886
(* use simple constant nslimit theorem *)
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   887
lemma NSDERIV_const [simp]: "(NSDERIV (%x. k) x :> 0)"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   888
by (simp add: NSDERIV_NSLIM_iff)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   889
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   890
text{*Sum of functions- proved easily*}
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   891
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   892
lemma NSDERIV_add: "[| NSDERIV f x :> Da;  NSDERIV g x :> Db |]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   893
      ==> NSDERIV (%x. f x + g x) x :> Da + Db"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   894
apply (auto simp add: NSDERIV_NSLIM_iff NSLIM_def)
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
   895
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
   896
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
   897
apply (auto simp add: diff_def add_ac)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   898
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   899
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   900
text{*Product of functions - Proof is trivial but tedious
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   901
  and long due to rearrangement of terms*}
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   902
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
   903
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
   904
by (simp add: right_diff_distrib)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   905
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
   906
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
   907
         z \<in> Infinitesimal; yb \<in> Infinitesimal |]
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
   908
      ==> x - y \<approx> 0"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   909
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
   910
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
   911
apply (auto intro!: Infinitesimal_HFinite_mult2 HFinite_add
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15360
diff changeset
   912
            simp add: mult_assoc mem_infmal_iff [symmetric])
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   913
apply (erule Infinitesimal_subset_HFinite [THEN subsetD])
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   914
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   915
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   916
lemma NSDERIV_mult: "[| NSDERIV f x :> Da; NSDERIV g x :> Db |]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   917
      ==> 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
   918
apply (auto simp add: NSDERIV_NSLIM_iff NSLIM_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   919
apply (auto dest!: spec
19023
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
   920
      simp add: starfun_lambda_cancel lemma_nsderiv1)
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
   921
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
   922
apply (drule bex_Infinitesimal_iff2 [THEN iffD2])+
15234
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15228
diff changeset
   923
apply (auto simp add: times_divide_eq_right [symmetric]
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15228
diff changeset
   924
            simp del: times_divide_eq)
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
   925
apply (drule_tac D = Db in lemma_nsderiv2, assumption+)
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
   926
apply (drule_tac
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   927
     approx_minus_iff [THEN iffD2, THEN bex_Infinitesimal_iff2 [THEN iffD2]])
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   928
apply (auto intro!: approx_add_mono1
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   929
            simp add: left_distrib right_distrib mult_commute add_assoc)
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   930
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
   931
         in add_commute [THEN subst])
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   932
apply (auto intro!: Infinitesimal_add_approx_self2 [THEN approx_sym]
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   933
                    Infinitesimal_add Infinitesimal_mult
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   934
                    Infinitesimal_hypreal_of_real_mult
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   935
                    Infinitesimal_hypreal_of_real_mult2
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   936
          simp add: add_assoc [symmetric])
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   937
done
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
text{*Multiplying by a constant*}
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   940
lemma NSDERIV_cmult: "NSDERIV f x :> D
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   941
      ==> NSDERIV (%x. c * f x) x :> c*D"
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
   942
apply (simp only: times_divide_eq_right [symmetric] NSDERIV_NSLIM_iff
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
   943
                  minus_mult_right right_diff_distrib [symmetric])
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   944
apply (erule NSLIM_const [THEN NSLIM_mult])
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   945
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   946
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   947
text{*Negation of function*}
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   948
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
   949
proof (simp add: NSDERIV_NSLIM_iff)
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
   950
  assume "(\<lambda>h. (f (x + h) - f x) / h) -- 0 --NS> D"
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
   951
  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
   952
    by (rule NSLIM_minus)
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
   953
  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
   954
    by (simp add: minus_divide_left)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   955
  with deriv
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   956
  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
   957
qed
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
text{*Subtraction*}
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   960
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
   961
by (blast dest: NSDERIV_add NSDERIV_minus)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   962
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   963
lemma NSDERIV_diff:
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   964
     "[| NSDERIV f x :> Da; NSDERIV g x :> Db |]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   965
      ==> NSDERIV (%x. f x - g x) x :> Da-Db"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   966
apply (simp add: diff_minus)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   967
apply (blast intro: NSDERIV_add_minus)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   968
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   969
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   970
text{*  Similarly to the above, the chain rule admits an entirely
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   971
   straightforward derivation. Compare this with Harrison's
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   972
   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
   973
   required an alternative characterisation of differentiability-
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   974
   the so-called Carathedory derivative. Our main problem is
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   975
   manipulation of terms.*}
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   976
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   977
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   978
(* lemmas *)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   979
lemma NSDERIV_zero:
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   980
      "[| NSDERIV g x :> D;
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   981
               ( *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
   982
               xa \<in> Infinitesimal;
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   983
               xa \<noteq> 0
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   984
            |] ==> D = 0"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   985
apply (simp add: nsderiv_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   986
apply (drule bspec, auto)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   987
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   988
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   989
(* can be proved differently using NSLIM_isCont_iff *)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   990
lemma NSDERIV_approx:
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   991
     "[| NSDERIV f x :> D;  h \<in> Infinitesimal;  h \<noteq> 0 |]
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
   992
      ==> ( *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
   993
apply (simp add: nsderiv_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   994
apply (simp add: mem_infmal_iff [symmetric])
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   995
apply (rule Infinitesimal_ratio)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   996
apply (rule_tac [3] approx_hypreal_of_real_HFinite, auto)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   997
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   998
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
   999
(*---------------------------------------------------------------
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1000
   from one version of differentiability
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1001
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1002
                f(x) - f(a)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1003
              --------------- \<approx> Db
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1004
                  x - a
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1005
 ---------------------------------------------------------------*)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1006
lemma NSDERIVD1: "[| NSDERIV f (g x) :> Da;
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1007
         ( *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
  1008
         ( *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
  1009
      |] ==> (( *f* f) (( *f* g) (hypreal_of_real(x) + xa))
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  1010
                   - hypreal_of_real (f (g x)))
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  1011
              / (( *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
  1012
             \<approx> hypreal_of_real(Da)"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1013
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
  1014
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
   from other version of differentiability
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1017
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1018
                f(x + h) - f(x)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1019
               ----------------- \<approx> Db
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1020
                       h
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1021
 --------------------------------------------------------------*)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1022
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
  1023
      ==> (( *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
  1024
          \<approx> hypreal_of_real(Db)"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1025
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
  1026
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1027
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
  1028
by auto
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1029
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1030
text{*This proof uses both definitions of differentiability.*}
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1031
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
  1032
      ==> NSDERIV (f o g) x :> Da * Db"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1033
apply (simp (no_asm_simp) add: NSDERIV_NSLIM_iff NSLIM_def
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1034
                mem_infmal_iff [symmetric])
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1035
apply clarify
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1036
apply (frule_tac f = g in NSDERIV_approx)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1037
apply (auto simp add: starfun_lambda_cancel2 starfun_o [symmetric])
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1038
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
  1039
apply (drule_tac g = g in NSDERIV_zero)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1040
apply (auto simp add: divide_inverse)
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  1041
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
  1042
apply (erule hypreal_not_eq_minus_iff [THEN iffD1])
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1043
apply (rule approx_mult_hypreal_of_real)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1044
apply (simp_all add: divide_inverse [symmetric])
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1045
apply (blast intro: NSDERIVD1 approx_minus_iff [THEN iffD2])
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1046
apply (blast intro: NSDERIVD2)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1047
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1048
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1049
text{*Differentiation of natural number powers*}
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1050
lemma NSDERIV_Id [simp]: "NSDERIV (%x. x) x :> 1"
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1051
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
  1052
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1053
lemma NSDERIV_cmult_Id [simp]: "NSDERIV (op * c) x :> c"
20756
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
  1054
by (cut_tac c = c and x = x in NSDERIV_Id [THEN NSDERIV_cmult], simp)
14477
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
(*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
  1057
lemma NSDERIV_inverse:
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1058
     "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
  1059
apply (simp add: nsderiv_def)
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1060
apply (rule ballI, simp, clarify)
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  1061
apply (frule (1) Infinitesimal_add_not_zero)
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  1062
apply (simp add: add_commute)
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  1063
(*apply (auto simp add: starfun_inverse_inverse realpow_two
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  1064
        simp del: minus_mult_left [symmetric] minus_mult_right [symmetric])*)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1065
apply (simp add: inverse_add inverse_mult_distrib [symmetric]
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  1066
              inverse_minus_eq [symmetric] add_ac mult_ac diff_def
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1067
            del: inverse_mult_distrib inverse_minus_eq
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1068
                 minus_mult_left [symmetric] minus_mult_right [symmetric])
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1069
apply (simp (no_asm_simp) add: mult_assoc [symmetric] right_distrib
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1070
            del: minus_mult_left [symmetric] minus_mult_right [symmetric])
15234
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15228
diff changeset
  1071
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
  1072
apply (rule inverse_add_Infinitesimal_approx2)
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1073
apply (auto dest!: hypreal_of_real_HFinite_diff_Infinitesimal
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1074
            simp add: inverse_minus_eq [symmetric] HFinite_minus_iff)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1075
apply (rule Infinitesimal_HFinite_mult2, auto)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1076
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1077
20756
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
  1078
subsubsection {* Equivalence of NS and Standard definitions *}
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1079
20793
3b0489715b0e generalize type of DERIV
huffman
parents: 20756
diff changeset
  1080
lemma divideR_eq_divide [simp]: "x /# y = x / y"
3b0489715b0e generalize type of DERIV
huffman
parents: 20756
diff changeset
  1081
by (simp add: real_scaleR_def divide_inverse mult_commute)
3b0489715b0e generalize type of DERIV
huffman
parents: 20756
diff changeset
  1082
20756
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
  1083
text{*Now equivalence between NSDERIV and DERIV*}
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
  1084
lemma NSDERIV_DERIV_iff: "(NSDERIV f x :> D) = (DERIV f x :> D)"
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
  1085
by (simp add: deriv_def NSDERIV_NSLIM_iff LIM_NSLIM_iff)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1086
20756
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
  1087
text{*Now Standard proof*}
20793
3b0489715b0e generalize type of DERIV
huffman
parents: 20756
diff changeset
  1088
lemma DERIV_isCont: "DERIV (f::real=>real) x :> D ==> isCont f x"
20756
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
  1089
by (simp add: NSDERIV_DERIV_iff [symmetric] isNSCont_isCont_iff [symmetric]
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
  1090
              NSDERIV_isNSCont)
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
  1091
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
  1092
lemma DERIV_mult:
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
  1093
     "[| DERIV f x :> Da; DERIV g x :> Db |]
20793
3b0489715b0e generalize type of DERIV
huffman
parents: 20756
diff changeset
  1094
      ==> DERIV (%x. f x * g x :: real) x :> (Da * g(x)) + (Db * f(x))"
20756
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
  1095
by (simp add: NSDERIV_mult NSDERIV_DERIV_iff [symmetric])
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
  1096
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
  1097
(* let's do the standard proof though theorem *)
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
  1098
(* LIM_mult2 follows from a NS proof          *)
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
  1099
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
  1100
lemma DERIV_cmult:
20793
3b0489715b0e generalize type of DERIV
huffman
parents: 20756
diff changeset
  1101
      "DERIV f x :> D ==> DERIV (%x. c * f x :: real) x :> c*D"
20756
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
  1102
apply (simp only: deriv_def times_divide_eq_right [symmetric]
20793
3b0489715b0e generalize type of DERIV
huffman
parents: 20756
diff changeset
  1103
                  divideR_eq_divide
20756
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
  1104
                  NSDERIV_NSLIM_iff minus_mult_right right_diff_distrib [symmetric])
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
  1105
apply (erule LIM_const [THEN LIM_mult2])
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
  1106
done
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
  1107
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
  1108
(* standard version *)
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
  1109
lemma DERIV_chain: "[| DERIV f (g x) :> Da; DERIV g x :> Db |] ==> DERIV (f o g) x :> Da * Db"
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
  1110
by (simp add: NSDERIV_DERIV_iff [symmetric] NSDERIV_chain)
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
  1111
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
  1112
lemma DERIV_chain2: "[| DERIV f (g x) :> Da; DERIV g x :> Db |] ==> DERIV (%x. f (g x)) x :> Da * Db"
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
  1113
by (auto dest: DERIV_chain simp add: o_def)
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
  1114
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
  1115
lemmas isCont_Id = DERIV_Id [THEN DERIV_isCont, standard]
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
  1116
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
  1117
(*derivative of linear multiplication*)
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
  1118
lemma DERIV_cmult_Id [simp]: "DERIV (op * c) x :> c"
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
  1119
by (cut_tac c = c and x = x in DERIV_Id [THEN DERIV_cmult], simp)
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
  1120
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
  1121
lemma DERIV_pow: "DERIV (%x. x ^ n) x :> real n * (x ^ (n - Suc 0))"
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
  1122
apply (induct "n")
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
  1123
apply (drule_tac [2] DERIV_Id [THEN DERIV_mult])
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
  1124
apply (auto simp add: real_of_nat_Suc left_distrib)
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
  1125
apply (case_tac "0 < n")
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
  1126
apply (drule_tac x = x in realpow_minus_mult)
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
  1127
apply (auto simp add: mult_assoc add_commute)
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
  1128
done
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
  1129
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
  1130
(* NS version *)
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
  1131
lemma NSDERIV_pow: "NSDERIV (%x. x ^ n) x :> real n * (x ^ (n - Suc 0))"
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
  1132
by (simp add: NSDERIV_DERIV_iff DERIV_pow)
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
  1133
fec7f5834ffe more reorganizing sections
huffman
parents: 20755
diff changeset
  1134
text{*Power of -1*}
14477
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
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
  1137
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
  1138
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1139
text{*Derivative of inverse*}
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1140
lemma DERIV_inverse_fun: "[| DERIV f x :> d; f(x) \<noteq> 0 |]
20793
3b0489715b0e generalize type of DERIV
huffman
parents: 20756
diff changeset
  1141
      ==> DERIV (%x. inverse(f x)::real) x :> (- (d * inverse(f(x) ^ Suc (Suc 0))))"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1142
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
  1143
apply (fold o_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1144
apply (blast intro!: DERIV_chain DERIV_inverse)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1145
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1146
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1147
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
  1148
      ==> 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
  1149
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
  1150
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1151
text{*Derivative of quotient*}
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1152
lemma DERIV_quotient: "[| DERIV f x :> d; DERIV g x :> e; g(x) \<noteq> 0 |]
20793
3b0489715b0e generalize type of DERIV
huffman
parents: 20756
diff changeset
  1153
       ==> DERIV (%y. f(y) / (g y) :: real) 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
  1154
apply (drule_tac f = g in DERIV_inverse_fun)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1155
apply (drule_tac [2] DERIV_mult)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1156
apply (assumption+)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1157
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
  1158
                 mult_ac diff_def
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1159
     del: realpow_Suc minus_mult_right [symmetric] minus_mult_left [symmetric])
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1160
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1161
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1162
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
  1163
       ==> NSDERIV (%y. f(y) / (g y)) x :> (d*g(x)
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  1164
                            - (e*f(x))) / (g(x) ^ Suc (Suc 0))"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1165
by (simp add: NSDERIV_DERIV_iff DERIV_quotient del: realpow_Suc)
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 CARAT_NSDERIV: "NSDERIV f x :> l ==>
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1168
      \<exists>g. (\<forall>z. f z - f x = g z * (z-x)) & isNSCont g x & g x = l"
20793
3b0489715b0e generalize type of DERIV
huffman
parents: 20756
diff changeset
  1169
by (auto simp add: NSDERIV_DERIV_iff isNSCont_isCont_iff CARAT_DERIV
3b0489715b0e generalize type of DERIV
huffman
parents: 20756
diff changeset
  1170
                   real_scaleR_def mult_commute)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1171
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1172
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
  1173
by auto
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1174
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1175
lemma CARAT_DERIVD:
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1176
  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
  1177
      and nsc: "isNSCont g x"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1178
  shows "NSDERIV f x :> g x"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1179
proof -
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1180
  from nsc
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1181
  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
  1182
         ( *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
  1183
         hypreal_of_real (g x)"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1184
    by (simp add: diff_minus isNSCont_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1185
  thus ?thesis using all
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1186
    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
  1187
qed
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1188
20755
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1189
subsubsection {* Differentiability predicate *}
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1190
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1191
lemma differentiableD: "f differentiable x ==> \<exists>D. DERIV f x :> D"
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1192
by (simp add: differentiable_def)
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1193
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1194
lemma differentiableI: "DERIV f x :> D ==> f differentiable x"
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1195
by (force simp add: differentiable_def)
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1196
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1197
lemma NSdifferentiableD: "f NSdifferentiable x ==> \<exists>D. NSDERIV f x :> D"
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1198
by (simp add: NSdifferentiable_def)
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1199
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1200
lemma NSdifferentiableI: "NSDERIV f x :> D ==> f NSdifferentiable x"
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1201
by (force simp add: NSdifferentiable_def)
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1202
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1203
lemma differentiable_const: "(\<lambda>z. a) differentiable x"
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1204
  apply (unfold differentiable_def)
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1205
  apply (rule_tac x=0 in exI)
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1206
  apply simp
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1207
  done
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1208
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1209
lemma differentiable_sum:
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1210
  assumes "f differentiable x"
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1211
  and "g differentiable x"
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1212
  shows "(\<lambda>x. f x + g x) differentiable x"
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1213
proof -
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1214
  from prems have "\<exists>D. DERIV f x :> D" by (unfold differentiable_def)
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1215
  then obtain df where "DERIV f x :> df" ..
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1216
  moreover from prems have "\<exists>D. DERIV g x :> D" by (unfold differentiable_def)
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1217
  then obtain dg where "DERIV g x :> dg" ..
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1218
  ultimately have "DERIV (\<lambda>x. f x + g x) x :> df + dg" by (rule DERIV_add)
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1219
  hence "\<exists>D. DERIV (\<lambda>x. f x + g x) x :> D" by auto
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1220
  thus ?thesis by (fold differentiable_def)
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1221
qed
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1222
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1223
lemma differentiable_diff:
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1224
  assumes "f differentiable x"
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1225
  and "g differentiable x"
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1226
  shows "(\<lambda>x. f x - g x) differentiable x"
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1227
proof -
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1228
  from prems have "f differentiable x" by simp
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1229
  moreover
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1230
  from prems have "\<exists>D. DERIV g x :> D" by (unfold differentiable_def)
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1231
  then obtain dg where "DERIV g x :> dg" ..
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1232
  then have "DERIV (\<lambda>x. - g x) x :> -dg" by (rule DERIV_minus)
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1233
  hence "\<exists>D. DERIV (\<lambda>x. - g x) x :> D" by auto
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1234
  hence "(\<lambda>x. - g x) differentiable x" by (fold differentiable_def)
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1235
  ultimately 
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1236
  show ?thesis
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1237
    by (auto simp: real_diff_def dest: differentiable_sum)
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1238
qed
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1239
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1240
lemma differentiable_mult:
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1241
  assumes "f differentiable x"
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1242
  and "g differentiable x"
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1243
  shows "(\<lambda>x. f x * g x) differentiable x"
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1244
proof -
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1245
  from prems have "\<exists>D. DERIV f x :> D" by (unfold differentiable_def)
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1246
  then obtain df where "DERIV f x :> df" ..
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1247
  moreover from prems have "\<exists>D. DERIV g x :> D" by (unfold differentiable_def)
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1248
  then obtain dg where "DERIV g x :> dg" ..
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1249
  ultimately have "DERIV (\<lambda>x. f x * g x) x :> df * g x + dg * f x" by (simp add: DERIV_mult)
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1250
  hence "\<exists>D. DERIV (\<lambda>x. f x * g x) x :> D" by auto
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1251
  thus ?thesis by (fold differentiable_def)
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1252
qed
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1253
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1254
subsection {*(NS) Increment*}
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1255
lemma incrementI:
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1256
      "f NSdifferentiable x ==>
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1257
      increment f x h = ( *f* f) (hypreal_of_real(x) + h) -
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1258
      hypreal_of_real (f x)"
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1259
by (simp add: increment_def)
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1260
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1261
lemma incrementI2: "NSDERIV f x :> D ==>
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1262
     increment f x h = ( *f* f) (hypreal_of_real(x) + h) -
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1263
     hypreal_of_real (f x)"
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1264
apply (erule NSdifferentiableI [THEN incrementI])
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1265
done
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1266
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1267
(* The Increment theorem -- Keisler p. 65 *)
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1268
lemma increment_thm: "[| NSDERIV f x :> D; h \<in> Infinitesimal; h \<noteq> 0 |]
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1269
      ==> \<exists>e \<in> Infinitesimal. increment f x h = hypreal_of_real(D)*h + e*h"
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1270
apply (frule_tac h = h in incrementI2, simp add: nsderiv_def)
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1271
apply (drule bspec, auto)
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1272
apply (drule bex_Infinitesimal_iff2 [THEN iffD2], clarify)
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1273
apply (frule_tac b1 = "hypreal_of_real (D) + y"
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1274
        in hypreal_mult_right_cancel [THEN iffD2])
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1275
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)
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1276
apply assumption
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1277
apply (simp add: times_divide_eq_right [symmetric])
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1278
apply (auto simp add: left_distrib)
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1279
done
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1280
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1281
lemma increment_thm2:
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1282
     "[| NSDERIV f x :> D; h \<approx> 0; h \<noteq> 0 |]
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1283
      ==> \<exists>e \<in> Infinitesimal. increment f x h =
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1284
              hypreal_of_real(D)*h + e*h"
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1285
by (blast dest!: mem_infmal_iff [THEN iffD2] intro!: increment_thm)
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1286
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1287
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1288
lemma increment_approx_zero: "[| NSDERIV f x :> D; h \<approx> 0; h \<noteq> 0 |]
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1289
      ==> increment f x h \<approx> 0"
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1290
apply (drule increment_thm2,
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1291
       auto intro!: Infinitesimal_HFinite_mult2 HFinite_add simp add: left_distrib [symmetric] mem_infmal_iff [symmetric])
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1292
apply (erule Infinitesimal_subset_HFinite [THEN subsetD])
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1293
done
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1294
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1295
subsection {* Nested Intervals and Bisection *}
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1296
15234
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15228
diff changeset
  1297
text{*Lemmas about nested intervals and proof by bisection (cf.Harrison).
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15228
diff changeset
  1298
     All considerably tidied by lcp.*}
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1299
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1300
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
  1301
apply (induct "no")
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1302
apply (auto intro: order_trans)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1303
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1304
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1305
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
  1306
         \<forall>n. g(Suc n) \<le> g(n);
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1307
         \<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
  1308
      ==> Bseq (f :: nat \<Rightarrow> real)"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1309
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
  1310
apply (induct_tac "n")
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1311
apply (auto intro: order_trans)
15234
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15228
diff changeset
  1312
apply (rule_tac y = "g (Suc na)" in order_trans)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1313
apply (induct_tac [2] "na")
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1314
apply (auto intro: order_trans)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1315
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1316
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1317
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
  1318
         \<forall>n. g(Suc n) \<le> g(n);
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1319
         \<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
  1320
      ==> Bseq (g :: nat \<Rightarrow> real)"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1321
apply (subst Bseq_minus_iff [symmetric])
15234
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15228
diff changeset
  1322
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
  1323
apply auto
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1324
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1325
20693
f763367e332f generalize types of lim and nslim
huffman
parents: 20653
diff changeset
  1326
lemma f_inc_imp_le_lim:
f763367e332f generalize types of lim and nslim
huffman
parents: 20653
diff changeset
  1327
  fixes f :: "nat \<Rightarrow> real"
f763367e332f generalize types of lim and nslim
huffman
parents: 20653
diff changeset
  1328
  shows "\<lbrakk>\<forall>n. f n \<le> f (Suc n); convergent f\<rbrakk> \<Longrightarrow> f n \<le> lim f"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1329
apply (rule linorder_not_less [THEN iffD1])
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1330
apply (auto simp add: convergent_LIMSEQ_iff LIMSEQ_iff monoseq_Suc)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1331
apply (drule real_less_sum_gt_zero)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1332
apply (drule_tac x = "f n + - lim f" in spec, safe)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1333
apply (drule_tac P = "%na. no\<le>na --> ?Q na" and x = "no + n" in spec, auto)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1334
apply (subgoal_tac "lim f \<le> f (no + n) ")
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1335
apply (drule_tac no=no and m=n in lemma_f_mono_add)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1336
apply (auto simp add: add_commute)
20254
58b71535ed00 lin_arith_prover splits certain operators (e.g. min, max, abs)
webertj
parents: 20217
diff changeset
  1337
apply (induct_tac "no")
58b71535ed00 lin_arith_prover splits certain operators (e.g. min, max, abs)
webertj
parents: 20217
diff changeset
  1338
apply simp
58b71535ed00 lin_arith_prover splits certain operators (e.g. min, max, abs)
webertj
parents: 20217
diff changeset
  1339
apply (auto intro: order_trans simp add: diff_minus abs_if)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1340
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1341
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1342
lemma lim_uminus: "convergent g ==> lim (%x. - g x) = - (lim g)"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1343
apply (rule LIMSEQ_minus [THEN limI])
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1344
apply (simp add: convergent_LIMSEQ_iff)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1345
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1346
20693
f763367e332f generalize types of lim and nslim
huffman
parents: 20653
diff changeset
  1347
lemma g_dec_imp_lim_le:
f763367e332f generalize types of lim and nslim
huffman
parents: 20653
diff changeset
  1348
  fixes g :: "nat \<Rightarrow> real"
f763367e332f generalize types of lim and nslim
huffman
parents: 20653
diff changeset
  1349
  shows "\<lbrakk>\<forall>n. g (Suc n) \<le> g(n); convergent g\<rbrakk> \<Longrightarrow> lim g \<le> g n"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1350
apply (subgoal_tac "- (g n) \<le> - (lim g) ")
15234
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15228
diff changeset
  1351
apply (cut_tac [2] f = "%x. - (g x)" in f_inc_imp_le_lim)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1352
apply (auto simp add: lim_uminus convergent_minus_iff [symmetric])
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1353
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1354
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1355
lemma lemma_nest: "[| \<forall>n. f(n) \<le> f(Suc n);
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1356
         \<forall>n. g(Suc n) \<le> g(n);
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1357
         \<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
  1358
      ==> \<exists>l m :: real. l \<le> m &  ((\<forall>n. f(n) \<le> l) & f ----> l) &
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1359
                            ((\<forall>n. m \<le> g(n)) & g ----> m)"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1360
apply (subgoal_tac "monoseq f & monoseq g")
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1361
prefer 2 apply (force simp add: LIMSEQ_iff monoseq_Suc)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1362
apply (subgoal_tac "Bseq f & Bseq g")
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1363
prefer 2 apply (blast intro: f_inc_g_dec_Beq_f f_inc_g_dec_Beq_g)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1364
apply (auto dest!: Bseq_monoseq_convergent simp add: convergent_LIMSEQ_iff)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1365
apply (rule_tac x = "lim f" in exI)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1366
apply (rule_tac x = "lim g" in exI)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1367
apply (auto intro: LIMSEQ_le)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1368
apply (auto simp add: f_inc_imp_le_lim g_dec_imp_lim_le convergent_LIMSEQ_iff)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1369
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1370
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1371
lemma lemma_nest_unique: "[| \<forall>n. f(n) \<le> f(Suc n);
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1372
         \<forall>n. g(Suc n) \<le> g(n);
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1373
         \<forall>n. f(n) \<le> g(n);
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1374
         (%n. f(n) - g(n)) ----> 0 |]
20552
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
  1375
      ==> \<exists>l::real. ((\<forall>n. f(n) \<le> l) & f ----> l) &
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1376
                ((\<forall>n. l \<le> g(n)) & g ----> l)"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1377
apply (drule lemma_nest, auto)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1378
apply (subgoal_tac "l = m")
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1379
apply (drule_tac [2] X = f in LIMSEQ_diff)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1380
apply (auto intro: LIMSEQ_unique)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1381
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1382
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1383
text{*The universal quantifiers below are required for the declaration
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1384
  of @{text Bolzano_nest_unique} below.*}
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1385
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1386
lemma Bolzano_bisect_le:
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1387
 "a \<le> b ==> \<forall>n. fst (Bolzano_bisect P a b n) \<le> snd (Bolzano_bisect P a b n)"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1388
apply (rule allI)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1389
apply (induct_tac "n")
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1390
apply (auto simp add: Let_def split_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1391
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1392
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1393
lemma Bolzano_bisect_fst_le_Suc: "a \<le> b ==>
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1394
   \<forall>n. fst(Bolzano_bisect P a b n) \<le> fst (Bolzano_bisect P a b (Suc n))"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1395
apply (rule allI)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1396
apply (induct_tac "n")
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1397
apply (auto simp add: Bolzano_bisect_le Let_def split_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1398
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1399
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1400
lemma Bolzano_bisect_Suc_le_snd: "a \<le> b ==>
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1401
   \<forall>n. snd(Bolzano_bisect P a b (Suc n)) \<le> snd (Bolzano_bisect P a b n)"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1402
apply (rule allI)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1403
apply (induct_tac "n")
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15360
diff changeset
  1404
apply (auto simp add: Bolzano_bisect_le Let_def split_def)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1405
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1406
19023
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  1407
lemma eq_divide_2_times_iff: "((x::real) = y / (2 * z)) = (2 * x = y/z)"
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15360
diff changeset
  1408
apply (auto)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1409
apply (drule_tac f = "%u. (1/2) *u" in arg_cong)
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15360
diff changeset
  1410
apply (simp)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1411
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1412
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1413
lemma Bolzano_bisect_diff:
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1414
     "a \<le> b ==>
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1415
      snd(Bolzano_bisect P a b n) - fst(Bolzano_bisect P a b n) =
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1416
      (b-a) / (2 ^ n)"
15251
bb6f072c8d10 converted some induct_tac to induct
paulson
parents: 15234
diff changeset
  1417
apply (induct "n")
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1418
apply (auto simp add: eq_divide_2_times_iff add_divide_distrib Let_def split_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1419
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1420
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1421
lemmas Bolzano_nest_unique =
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1422
    lemma_nest_unique
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1423
    [OF Bolzano_bisect_fst_le_Suc Bolzano_bisect_Suc_le_snd Bolzano_bisect_le]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1424
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1425
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1426
lemma not_P_Bolzano_bisect:
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1427
  assumes P:    "!!a b c. [| P(a,b); P(b,c); a \<le> b; b \<le> c|] ==> P(a,c)"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1428
      and notP: "~ P(a,b)"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1429
      and le:   "a \<le> b"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1430
  shows "~ P(fst(Bolzano_bisect P a b n), snd(Bolzano_bisect P a b n))"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1431
proof (induct n)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1432
  case 0 thus ?case by simp
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1433
 next
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1434
  case (Suc n)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1435
  thus ?case
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1436
 by (auto simp del: surjective_pairing [symmetric]
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1437
             simp add: Let_def split_def Bolzano_bisect_le [OF le]
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1438
     P [of "fst (Bolzano_bisect P a b n)" _ "snd (Bolzano_bisect P a b n)"])
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1439
qed
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1440
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1441
(*Now we re-package P_prem as a formula*)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1442
lemma not_P_Bolzano_bisect':
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1443
     "[| \<forall>a b c. P(a,b) & P(b,c) & a \<le> b & b \<le> c --> P(a,c);
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1444
         ~ P(a,b);  a \<le> b |] ==>
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1445
      \<forall>n. ~ P(fst(Bolzano_bisect P a b n), snd(Bolzano_bisect P a b n))"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1446
by (blast elim!: not_P_Bolzano_bisect [THEN [2] rev_notE])
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1447
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1448
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1449
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1450
lemma lemma_BOLZANO:
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1451
     "[| \<forall>a b c. P(a,b) & P(b,c) & a \<le> b & b \<le> c --> P(a,c);
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1452
         \<forall>x. \<exists>d::real. 0 < d &
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1453
                (\<forall>a b. a \<le> x & x \<le> b & (b-a) < d --> P(a,b));
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1454
         a \<le> b |]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1455
      ==> P(a,b)"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1456
apply (rule Bolzano_nest_unique [where P1=P, THEN exE], assumption+)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1457
apply (rule LIMSEQ_minus_cancel)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1458
apply (simp (no_asm_simp) add: Bolzano_bisect_diff LIMSEQ_divide_realpow_zero)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1459
apply (rule ccontr)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1460
apply (drule not_P_Bolzano_bisect', assumption+)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1461
apply (rename_tac "l")
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1462
apply (drule_tac x = l in spec, clarify)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1463
apply (simp add: LIMSEQ_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1464
apply (drule_tac P = "%r. 0<r --> ?Q r" and x = "d/2" in spec)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1465
apply (drule_tac P = "%r. 0<r --> ?Q r" and x = "d/2" in spec)
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1466
apply (drule real_less_half_sum, auto)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1467
apply (drule_tac x = "fst (Bolzano_bisect P a b (no + noa))" in spec)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1468
apply (drule_tac x = "snd (Bolzano_bisect P a b (no + noa))" in spec)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1469
apply safe
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1470
apply (simp_all (no_asm_simp))
15234
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15228
diff changeset
  1471
apply (rule_tac y = "abs (fst (Bolzano_bisect P a b (no + noa)) - l) + abs (snd (Bolzano_bisect P a b (no + noa)) - l)" in order_le_less_trans)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1472
apply (simp (no_asm_simp) add: abs_if)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1473
apply (rule real_sum_of_halves [THEN subst])
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1474
apply (rule add_strict_mono)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1475
apply (simp_all add: diff_minus [symmetric])
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1476
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1478
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1479
lemma lemma_BOLZANO2: "((\<forall>a b c. (a \<le> b & b \<le> c & P(a,b) & P(b,c)) --> P(a,c)) &
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1480
       (\<forall>x. \<exists>d::real. 0 < d &
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1481
                (\<forall>a b. a \<le> x & x \<le> b & (b-a) < d --> P(a,b))))
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1482
      --> (\<forall>a b. a \<le> b --> P(a,b))"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1483
apply clarify
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1484
apply (blast intro: lemma_BOLZANO)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1485
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1486
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1487
20755
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1488
subsection {* Intermediate Value Theorem *}
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1489
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1490
text {*Prove Contrapositive by Bisection*}
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1491
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
  1492
lemma IVT: "[| f(a::real) \<le> (y::real); y \<le> f(b);
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1493
         a \<le> b;
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1494
         (\<forall>x. a \<le> x & x \<le> b --> isCont f x) |]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1495
      ==> \<exists>x. a \<le> x & x \<le> b & f(x) = y"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1496
apply (rule contrapos_pp, assumption)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1497
apply (cut_tac P = "% (u,v) . a \<le> u & u \<le> v & v \<le> b --> ~ (f (u) \<le> y & y \<le> f (v))" in lemma_BOLZANO2)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1498
apply safe
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1499
apply simp_all
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1500
apply (simp add: isCont_iff LIM_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1501
apply (rule ccontr)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1502
apply (subgoal_tac "a \<le> x & x \<le> b")
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1503
 prefer 2
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1504
 apply simp
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1505
 apply (drule_tac P = "%d. 0<d --> ?P d" and x = 1 in spec, arith)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1506
apply (drule_tac x = x in spec)+
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1507
apply simp
15360
300e09825d8b Added "ALL x > y" and relatives.
nipkow
parents: 15251
diff changeset
  1508
apply (drule_tac P = "%r. ?P r --> (\<exists>s>0. ?Q r s) " and x = "\<bar>y - f x\<bar>" in spec)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1509
apply safe
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1510
apply simp
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1511
apply (drule_tac x = s in spec, clarify)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1512
apply (cut_tac x = "f x" and y = y in linorder_less_linear, safe)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1513
apply (drule_tac x = "ba-x" in spec)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1514
apply (simp_all add: abs_if)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1515
apply (drule_tac x = "aa-x" in spec)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1516
apply (case_tac "x \<le> aa", simp_all)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1517
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1518
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
  1519
lemma IVT2: "[| f(b::real) \<le> (y::real); y \<le> f(a);
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1520
         a \<le> b;
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1521
         (\<forall>x. a \<le> x & x \<le> b --> isCont f x)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1522
      |] ==> \<exists>x. a \<le> x & x \<le> b & f(x) = y"
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1523
apply (subgoal_tac "- f a \<le> -y & -y \<le> - f b", clarify)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1524
apply (drule IVT [where f = "%x. - f x"], assumption)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1525
apply (auto intro: isCont_minus)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1526
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1527
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1528
(*HOL style here: object-level formulations*)
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
  1529
lemma IVT_objl: "(f(a::real) \<le> (y::real) & y \<le> f(b) & a \<le> b &
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1530
      (\<forall>x. a \<le> x & x \<le> b --> isCont f x))
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1531
      --> (\<exists>x. a \<le> x & x \<le> b & f(x) = y)"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1532
apply (blast intro: IVT)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1533
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1534
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
  1535
lemma IVT2_objl: "(f(b::real) \<le> (y::real) & y \<le> f(a) & a \<le> b &
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1536
      (\<forall>x. a \<le> x & x \<le> b --> isCont f x))
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1537
      --> (\<exists>x. a \<le> x & x \<le> b & f(x) = y)"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1538
apply (blast intro: IVT2)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1539
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1540
20755
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1541
text{*By bisection, function continuous on closed interval is bounded above*}
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1542
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1543
lemma isCont_bounded:
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1544
     "[| a \<le> b; \<forall>x. a \<le> x & x \<le> b --> isCont f x |]
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
  1545
      ==> \<exists>M::real. \<forall>x::real. a \<le> x & x \<le> b --> f(x) \<le> M"
15234
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15228
diff changeset
  1546
apply (cut_tac P = "% (u,v) . a \<le> u & u \<le> v & v \<le> b --> (\<exists>M. \<forall>x. u \<le> x & x \<le> v --> f x \<le> M)" in lemma_BOLZANO2)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1547
apply safe
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1548
apply simp_all
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1549
apply (rename_tac x xa ya M Ma)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1550
apply (cut_tac x = M and y = Ma in linorder_linear, safe)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1551
apply (rule_tac x = Ma in exI, clarify)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1552
apply (cut_tac x = xb and y = xa in linorder_linear, force)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1553
apply (rule_tac x = M in exI, clarify)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1554
apply (cut_tac x = xb and y = xa in linorder_linear, force)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1555
apply (case_tac "a \<le> x & x \<le> b")
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1556
apply (rule_tac [2] x = 1 in exI)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1557
prefer 2 apply force
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1558
apply (simp add: LIM_def isCont_iff)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1559
apply (drule_tac x = x in spec, auto)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1560
apply (erule_tac V = "\<forall>M. \<exists>x. a \<le> x & x \<le> b & ~ f x \<le> M" in thin_rl)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1561
apply (drule_tac x = 1 in spec, auto)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1562
apply (rule_tac x = s in exI, clarify)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1563
apply (rule_tac x = "\<bar>f x\<bar> + 1" in exI, clarify)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1564
apply (drule_tac x = "xa-x" in spec)
20217
25b068a99d2b linear arithmetic splits certain operators (e.g. min, max, abs)
webertj
parents: 19765
diff changeset
  1565
apply (auto simp add: abs_ge_self)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1566
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1567
15234
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15228
diff changeset
  1568
text{*Refine the above to existence of least upper bound*}
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1569
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1570
lemma lemma_reals_complete: "((\<exists>x. x \<in> S) & (\<exists>y. isUb UNIV S (y::real))) -->
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1571
      (\<exists>t. isLub UNIV S t)"
15234
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15228
diff changeset
  1572
by (blast intro: reals_complete)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1573
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1574
lemma isCont_has_Ub: "[| a \<le> b; \<forall>x. a \<le> x & x \<le> b --> isCont f x |]
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
  1575
         ==> \<exists>M::real. (\<forall>x::real. a \<le> x & x \<le> b --> f(x) \<le> M) &
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1576
                   (\<forall>N. N < M --> (\<exists>x. a \<le> x & x \<le> b & N < f(x)))"
19023
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  1577
apply (cut_tac S = "Collect (%y. \<exists>x. a \<le> x & x \<le> b & y = f x)"
15234
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15228
diff changeset
  1578
        in lemma_reals_complete)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1579
apply auto
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1580
apply (drule isCont_bounded, assumption)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1581
apply (auto simp add: isUb_def leastP_def isLub_def setge_def setle_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1582
apply (rule exI, auto)
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1583
apply (auto dest!: spec simp add: linorder_not_less)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1584
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1585
15234
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15228
diff changeset
  1586
text{*Now show that it attains its upper bound*}
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1587
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1588
lemma isCont_eq_Ub:
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1589
  assumes le: "a \<le> b"
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
  1590
      and con: "\<forall>x::real. a \<le> x & x \<le> b --> isCont f x"
20552
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
  1591
  shows "\<exists>M::real. (\<forall>x. a \<le> x & x \<le> b --> f(x) \<le> M) &
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1592
             (\<exists>x. a \<le> x & x \<le> b & f(x) = M)"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1593
proof -
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1594
  from isCont_has_Ub [OF le con]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1595
  obtain M where M1: "\<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> f x \<le> M"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1596
             and M2: "!!N. N<M ==> \<exists>x. a \<le> x \<and> x \<le> b \<and> N < f x"  by blast
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1597
  show ?thesis
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1598
  proof (intro exI, intro conjI)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1599
    show " \<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> f x \<le> M" by (rule M1)
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1600
    show "\<exists>x. a \<le> x \<and> x \<le> b \<and> f x = M"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1601
    proof (rule ccontr)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1602
      assume "\<not> (\<exists>x. a \<le> x \<and> x \<le> b \<and> f x = M)"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1603
      with M1 have M3: "\<forall>x. a \<le> x & x \<le> b --> f x < M"
15195
197e00ce3f20 new forward deduction capability for simplifier
nipkow
parents: 15140
diff changeset
  1604
        by (fastsimp simp add: linorder_not_le [symmetric])
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1605
      hence "\<forall>x. a \<le> x & x \<le> b --> isCont (%x. inverse (M - f x)) x"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1606
        by (auto simp add: isCont_inverse isCont_diff con)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1607
      from isCont_bounded [OF le this]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1608
      obtain k where k: "!!x. a \<le> x & x \<le> b --> inverse (M - f x) \<le> k" by auto
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1609
      have Minv: "!!x. a \<le> x & x \<le> b --> 0 < inverse (M - f (x))"
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1610
        by (simp add: M3 compare_rls)
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1611
      have "!!x. a \<le> x & x \<le> b --> inverse (M - f x) < k+1" using k
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1612
        by (auto intro: order_le_less_trans [of _ k])
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1613
      with Minv
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1614
      have "!!x. a \<le> x & x \<le> b --> inverse(k+1) < inverse(inverse(M - f x))"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1615
        by (intro strip less_imp_inverse_less, simp_all)
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1616
      hence invlt: "!!x. a \<le> x & x \<le> b --> inverse(k+1) < M - f x"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1617
        by simp
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1618
      have "M - inverse (k+1) < M" using k [of a] Minv [of a] le
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1619
        by (simp, arith)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1620
      from M2 [OF this]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1621
      obtain x where ax: "a \<le> x & x \<le> b & M - inverse(k+1) < f x" ..
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1622
      thus False using invlt [of x] by force
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1623
    qed
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1624
  qed
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1625
qed
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1626
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1627
15234
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15228
diff changeset
  1628
text{*Same theorem for lower bound*}
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1629
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1630
lemma isCont_eq_Lb: "[| a \<le> b; \<forall>x. a \<le> x & x \<le> b --> isCont f x |]
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
  1631
         ==> \<exists>M::real. (\<forall>x::real. a \<le> x & x \<le> b --> M \<le> f(x)) &
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1632
                   (\<exists>x. a \<le> x & x \<le> b & f(x) = M)"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1633
apply (subgoal_tac "\<forall>x. a \<le> x & x \<le> b --> isCont (%x. - (f x)) x")
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1634
prefer 2 apply (blast intro: isCont_minus)
15234
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15228
diff changeset
  1635
apply (drule_tac f = "(%x. - (f x))" in isCont_eq_Ub)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1636
apply safe
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1637
apply auto
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1638
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1639
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1640
15234
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15228
diff changeset
  1641
text{*Another version.*}
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1642
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1643
lemma isCont_Lb_Ub: "[|a \<le> b; \<forall>x. a \<le> x & x \<le> b --> isCont f x |]
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
  1644
      ==> \<exists>L M::real. (\<forall>x::real. a \<le> x & x \<le> b --> L \<le> f(x) & f(x) \<le> M) &
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1645
          (\<forall>y. L \<le> y & y \<le> M --> (\<exists>x. a \<le> x & x \<le> b & (f(x) = y)))"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1646
apply (frule isCont_eq_Lb)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1647
apply (frule_tac [2] isCont_eq_Ub)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1648
apply (assumption+, safe)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1649
apply (rule_tac x = "f x" in exI)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1650
apply (rule_tac x = "f xa" in exI, simp, safe)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1651
apply (cut_tac x = x and y = xa in linorder_linear, safe)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1652
apply (cut_tac f = f and a = x and b = xa and y = y in IVT_objl)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1653
apply (cut_tac [2] f = f and a = xa and b = x and y = y in IVT2_objl, safe)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1654
apply (rule_tac [2] x = xb in exI)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1655
apply (rule_tac [4] x = xb in exI, simp_all)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1656
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1657
15003
6145dd7538d7 replaced monomorphic abs definitions by abs_if
paulson
parents: 14477
diff changeset
  1658
20755
956a0377a408 reorganize sections
huffman
parents: 20754
diff changeset
  1659
text{*If @{term "0 < f'(x)"} then @{term x} is Locally Strictly Increasing At The Right*}
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1660
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1661
lemma DERIV_left_inc:
20793
3b0489715b0e generalize type of DERIV
huffman
parents: 20756
diff changeset
  1662
  fixes f :: "real => real"
15003
6145dd7538d7 replaced monomorphic abs definitions by abs_if
paulson
parents: 14477
diff changeset
  1663
  assumes der: "DERIV f x :> l"
6145dd7538d7 replaced monomorphic abs definitions by abs_if
paulson
parents: 14477
diff changeset
  1664
      and l:   "0 < l"
15360
300e09825d8b Added "ALL x > y" and relatives.
nipkow
parents: 15251
diff changeset
  1665
  shows "\<exists>d > 0. \<forall>h > 0. h < d --> f(x) < f(x + h)"
15003
6145dd7538d7 replaced monomorphic abs definitions by abs_if
paulson
parents: 14477
diff changeset
  1666
proof -
6145dd7538d7 replaced monomorphic abs definitions by abs_if
paulson
parents: 14477
diff changeset
  1667
  from l der [THEN DERIV_D, THEN LIM_D [where r = "l"]]
15360
300e09825d8b Added "ALL x > y" and relatives.
nipkow
parents: 15251
diff changeset
  1668
  have "\<exists>s > 0. (\<forall>z. z \<noteq> 0 \<and> \<bar>z\<bar> < s \<longrightarrow> \<bar>(f(x+z) - f x) / z - l\<bar> < l)"
15003
6145dd7538d7 replaced monomorphic abs definitions by abs_if
paulson
parents: 14477
diff changeset
  1669
    by (simp add: diff_minus)
6145dd7538d7 replaced monomorphic abs definitions by abs_if
paulson
parents: 14477
diff changeset
  1670
  then obtain s
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1671
        where s:   "0 < s"
15003
6145dd7538d7 replaced monomorphic abs definitions by abs_if
paulson
parents: 14477
diff changeset
  1672
          and all: "!!z. z \<noteq> 0 \<and> \<bar>z\<bar> < s \<longrightarrow> \<bar>(f(x+z) - f x) / z - l\<bar> < l"
6145dd7538d7 replaced monomorphic abs definitions by abs_if
paulson
parents: 14477
diff changeset
  1673
    by auto
6145dd7538d7 replaced monomorphic abs definitions by abs_if
paulson
parents: 14477
diff changeset
  1674
  thus ?thesis
6145dd7538d7 replaced monomorphic abs definitions by abs_if
paulson
parents: 14477
diff changeset
  1675
  proof (intro exI conjI strip)
6145dd7538d7 replaced monomorphic abs definitions by abs_if
paulson
parents: 14477
diff changeset
  1676
    show "0<s" .
6145dd7538d7 replaced monomorphic abs definitions by abs_if
paulson
parents: 14477
diff changeset
  1677
    fix h::real
15360
300e09825d8b Added "ALL x > y" and relatives.
nipkow
parents: 15251
diff changeset
  1678
    assume "0 < h" "h < s"
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1679
    with all [of h] show "f x < f (x+h)"
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1680
    proof (simp add: abs_if pos_less_divide_eq diff_minus [symmetric]
19023
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  1681
    split add: split_if_asm)
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1682
      assume "~ (f (x+h) - f x) / h < l" and h: "0 < h"
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1683
      with l
15003
6145dd7538d7 replaced monomorphic abs definitions by abs_if
paulson
parents: 14477
diff changeset
  1684
      have "0 < (f (x+h) - f x) / h" by arith
6145dd7538d7 replaced monomorphic abs definitions by abs_if
paulson
parents: 14477
diff changeset
  1685
      thus "f x < f (x+h)"
19023
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  1686
  by (simp add: pos_less_divide_eq h)
15003
6145dd7538d7 replaced monomorphic abs definitions by abs_if
paulson
parents: 14477
diff changeset
  1687
    qed
6145dd7538d7 replaced monomorphic abs definitions by abs_if
paulson
parents: 14477
diff changeset
  1688
  qed
6145dd7538d7 replaced monomorphic abs definitions by abs_if
paulson
parents: 14477
diff changeset
  1689
qed
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1690
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1691
lemma DERIV_left_dec:
20793
3b0489715b0e generalize type of DERIV
huffman
parents: 20756
diff changeset
  1692
  fixes f :: "real => real"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1693
  assumes der: "DERIV f x :> l"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1694
      and l:   "l < 0"
15360
300e09825d8b Added "ALL x > y" and relatives.
nipkow
parents: 15251
diff changeset
  1695
  shows "\<exists>d > 0. \<forall>h > 0. h < d --> f(x) < f(x-h)"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1696
proof -
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1697
  from l der [THEN DERIV_D, THEN LIM_D [where r = "-l"]]
15360
300e09825d8b Added "ALL x > y" and relatives.
nipkow
parents: 15251
diff changeset
  1698
  have "\<exists>s > 0. (\<forall>z. z \<noteq> 0 \<and> \<bar>z\<bar> < s \<longrightarrow> \<bar>(f(x+z) - f x) / z - l\<bar> < -l)"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1699
    by (simp add: diff_minus)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1700
  then obtain s
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1701
        where s:   "0 < s"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1702
          and all: "!!z. z \<noteq> 0 \<and> \<bar>z\<bar> < s \<longrightarrow> \<bar>(f(x+z) - f x) / z - l\<bar> < -l"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1703
    by auto
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1704
  thus ?thesis
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1705
  proof (intro exI conjI strip)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1706
    show "0<s" .
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1707
    fix h::real
15360
300e09825d8b Added "ALL x > y" and relatives.
nipkow
parents: 15251
diff changeset
  1708
    assume "0 < h" "h < s"
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1709
    with all [of "-h"] show "f x < f (x-h)"
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1710
    proof (simp add: abs_if pos_less_divide_eq diff_minus [symmetric]
19023
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  1711
    split add: split_if_asm)
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1712
      assume " - ((f (x-h) - f x) / h) < l" and h: "0 < h"
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1713
      with l
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1714
      have "0 < (f (x-h) - f x) / h" by arith
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1715
      thus "f x < f (x-h)"
19023
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  1716
  by (simp add: pos_less_divide_eq h)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1717
    qed
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1718
  qed
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1719
qed
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1720
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1721
lemma DERIV_local_max:
20793
3b0489715b0e generalize type of DERIV
huffman
parents: 20756
diff changeset
  1722
  fixes f :: "real => real"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1723
  assumes der: "DERIV f x :> l"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1724
      and d:   "0 < d"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1725
      and le:  "\<forall>y. \<bar>x-y\<bar> < d --> f(y) \<le> f(x)"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1726
  shows "l = 0"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1727
proof (cases rule: linorder_cases [of l 0])
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1728
  case equal show ?thesis .
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1729
next
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1730
  case less
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1731
  from DERIV_left_dec [OF der less]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1732
  obtain d' where d': "0 < d'"
15360
300e09825d8b Added "ALL x > y" and relatives.
nipkow
parents: 15251
diff changeset
  1733
             and lt: "\<forall>h > 0. h < d' \<longrightarrow> f x < f (x-h)" by blast
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1734
  from real_lbound_gt_zero [OF d d']
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1735
  obtain e where "0 < e \<and> e < d \<and> e < d'" ..
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1736
  with lt le [THEN spec [where x="x-e"]]
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1737
  show ?thesis by (auto simp add: abs_if)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1738
next
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1739
  case greater
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1740
  from DERIV_left_inc [OF der greater]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1741
  obtain d' where d': "0 < d'"
15360
300e09825d8b Added "ALL x > y" and relatives.
nipkow
parents: 15251
diff changeset
  1742
             and lt: "\<forall>h > 0. h < d' \<longrightarrow> f x < f (x + h)" by blast
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1743
  from real_lbound_gt_zero [OF d d']
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1744
  obtain e where "0 < e \<and> e < d \<and> e < d'" ..
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1745
  with lt le [THEN spec [where x="x+e"]]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1746
  show ?thesis by (auto simp add: abs_if)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1747
qed
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1748
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1749
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1750
text{*Similar theorem for a local minimum*}
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1751
lemma DERIV_local_min:
20793
3b0489715b0e generalize type of DERIV
huffman
parents: 20756
diff changeset
  1752
  fixes f :: "real => real"
3b0489715b0e generalize type of DERIV
huffman
parents: 20756
diff changeset
  1753
  shows "[| DERIV f x :> l; 0 < d; \<forall>y. \<bar>x-y\<bar> < d --> f(x) \<le> f(y) |] ==> l = 0"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1754
by (drule DERIV_minus [THEN DERIV_local_max], auto)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1755
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1756
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1757
text{*In particular, if a function is locally flat*}
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1758
lemma DERIV_local_const:
20793
3b0489715b0e generalize type of DERIV
huffman
parents: 20756
diff changeset
  1759
  fixes f :: "real => real"
3b0489715b0e generalize type of DERIV
huffman
parents: 20756
diff changeset
  1760
  shows "[| DERIV f x :> l; 0 < d; \<forall>y. \<bar>x-y\<bar> < d --> f(x) = f(y) |] ==> l = 0"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1761
by (auto dest!: DERIV_local_max)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1762
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1763
text{*Lemma about introducing open ball in open interval*}
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1764
lemma lemma_interval_lt:
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1765
     "[| a < x;  x < b |]
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1766
      ==> \<exists>d::real. 0 < d & (\<forall>y. \<bar>x-y\<bar> < d --> a < y & y < b)"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1767
apply (simp add: abs_interval_iff)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1768
apply (insert linorder_linear [of "x-a" "b-x"], safe)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1769
apply (rule_tac x = "x-a" in exI)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1770
apply (rule_tac [2] x = "b-x" in exI, auto)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1771
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1772
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1773
lemma lemma_interval: "[| a < x;  x < b |] ==>
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1774
        \<exists>d::real. 0 < d &  (\<forall>y. \<bar>x-y\<bar> < d --> a \<le> y & y \<le> b)"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1775
apply (drule lemma_interval_lt, auto)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1776
apply (auto intro!: exI)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1777
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1778
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1779
text{*Rolle's Theorem.
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1780
   If @{term f} is defined and continuous on the closed interval
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1781
   @{text "[a,b]"} and differentiable on the open interval @{text "(a,b)"},
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1782
   and @{term "f(a) = f(b)"},
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1783
   then there exists @{text "x0 \<in> (a,b)"} such that @{term "f'(x0) = 0"}*}
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1784
theorem Rolle:
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1785
  assumes lt: "a < b"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1786
      and eq: "f(a) = f(b)"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1787
      and con: "\<forall>x. a \<le> x & x \<le> b --> isCont f x"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1788
      and dif [rule_format]: "\<forall>x. a < x & x < b --> f differentiable x"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1789
  shows "\<exists>z. a < z & z < b & DERIV f z :> 0"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1790
proof -
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1791
  have le: "a \<le> b" using lt by simp
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1792
  from isCont_eq_Ub [OF le con]
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1793
  obtain x where x_max: "\<forall>z. a \<le> z \<and> z \<le> b \<longrightarrow> f z \<le> f x"
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1794
             and alex: "a \<le> x" and xleb: "x \<le> b"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1795
    by blast
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1796
  from isCont_eq_Lb [OF le con]
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1797
  obtain x' where x'_min: "\<forall>z. a \<le> z \<and> z \<le> b \<longrightarrow> f x' \<le> f z"
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1798
              and alex': "a \<le> x'" and x'leb: "x' \<le> b"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1799
    by blast
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1800
  show ?thesis
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1801
  proof cases
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1802
    assume axb: "a < x & x < b"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1803
        --{*@{term f} attains its maximum within the interval*}
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1804
    hence ax: "a<x" and xb: "x<b" by auto
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1805
    from lemma_interval [OF ax xb]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1806
    obtain d where d: "0<d" and bound: "\<forall>y. \<bar>x-y\<bar> < d \<longrightarrow> a \<le> y \<and> y \<le> b"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1807
      by blast
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1808
    hence bound': "\<forall>y. \<bar>x-y\<bar> < d \<longrightarrow> f y \<le> f x" using x_max
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1809
      by blast
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1810
    from differentiableD [OF dif [OF axb]]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1811
    obtain l where der: "DERIV f x :> l" ..
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1812
    have "l=0" by (rule DERIV_local_max [OF der d bound'])
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1813
        --{*the derivative at a local maximum is zero*}
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1814
    thus ?thesis using ax xb der by auto
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1815
  next
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1816
    assume notaxb: "~ (a < x & x < b)"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1817
    hence xeqab: "x=a | x=b" using alex xleb by arith
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1818
    hence fb_eq_fx: "f b = f x" by (auto simp add: eq)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1819
    show ?thesis
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1820
    proof cases
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1821
      assume ax'b: "a < x' & x' < b"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1822
        --{*@{term f} attains its minimum within the interval*}
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1823
      hence ax': "a<x'" and x'b: "x'<b" by auto
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1824
      from lemma_interval [OF ax' x'b]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1825
      obtain d where d: "0<d" and bound: "\<forall>y. \<bar>x'-y\<bar> < d \<longrightarrow> a \<le> y \<and> y \<le> b"
19023
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  1826
  by blast
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1827
      hence bound': "\<forall>y. \<bar>x'-y\<bar> < d \<longrightarrow> f x' \<le> f y" using x'_min
19023
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  1828
  by blast
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1829
      from differentiableD [OF dif [OF ax'b]]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1830
      obtain l where der: "DERIV f x' :> l" ..
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1831
      have "l=0" by (rule DERIV_local_min [OF der d bound'])
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1832
        --{*the derivative at a local minimum is zero*}
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1833
      thus ?thesis using ax' x'b der by auto
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1834
    next
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1835
      assume notax'b: "~ (a < x' & x' < b)"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1836
        --{*@{term f} is constant througout the interval*}
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1837
      hence x'eqab: "x'=a | x'=b" using alex' x'leb by arith
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1838
      hence fb_eq_fx': "f b = f x'" by (auto simp add: eq)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1839
      from dense [OF lt]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1840
      obtain r where ar: "a < r" and rb: "r < b" by blast
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1841
      from lemma_interval [OF ar rb]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1842
      obtain d where d: "0<d" and bound: "\<forall>y. \<bar>r-y\<bar> < d \<longrightarrow> a \<le> y \<and> y \<le> b"
19023
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  1843
  by blast
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1844
      have eq_fb: "\<forall>z. a \<le> z --> z \<le> b --> f z = f b"
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1845
      proof (clarify)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1846
        fix z::real
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1847
        assume az: "a \<le> z" and zb: "z \<le> b"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1848
        show "f z = f b"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1849
        proof (rule order_antisym)
15195
197e00ce3f20 new forward deduction capability for simplifier
nipkow
parents: 15140
diff changeset
  1850
          show "f z \<le> f b" by (simp add: fb_eq_fx x_max az zb)
197e00ce3f20 new forward deduction capability for simplifier
nipkow
parents: 15140
diff changeset
  1851
          show "f b \<le> f z" by (simp add: fb_eq_fx' x'_min az zb)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1852
        qed
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1853
      qed
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1854
      have bound': "\<forall>y. \<bar>r-y\<bar> < d \<longrightarrow> f r = f y"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1855
      proof (intro strip)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1856
        fix y::real
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1857
        assume lt: "\<bar>r-y\<bar> < d"
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1858
        hence "f y = f b" by (simp add: eq_fb bound)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1859
        thus "f r = f y" by (simp add: eq_fb ar rb order_less_imp_le)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1860
      qed
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1861
      from differentiableD [OF dif [OF conjI [OF ar rb]]]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1862
      obtain l where der: "DERIV f r :> l" ..
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1863
      have "l=0" by (rule DERIV_local_const [OF der d bound'])
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1864
        --{*the derivative of a constant function is zero*}
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1865
      thus ?thesis using ar rb der by auto
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1866
    qed
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1867
  qed
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1868
qed
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1869
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1870
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1871
subsection{*Mean Value Theorem*}
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1872
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1873
lemma lemma_MVT:
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1874
     "f a - (f b - f a)/(b-a) * a = f b - (f b - f a)/(b-a) * (b::real)"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1875
proof cases
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1876
  assume "a=b" thus ?thesis by simp
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1877
next
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1878
  assume "a\<noteq>b"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1879
  hence ba: "b-a \<noteq> 0" by arith
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1880
  show ?thesis
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1881
    by (rule real_mult_left_cancel [OF ba, THEN iffD1],
19023
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  1882
        simp add: right_diff_distrib,
15234
ec91a90c604e simplification tweaks for better arithmetic reasoning
paulson
parents: 15228
diff changeset
  1883
        simp add: left_diff_distrib)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1884
qed
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1885
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1886
theorem MVT:
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1887
  assumes lt:  "a < b"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1888
      and con: "\<forall>x. a \<le> x & x \<le> b --> isCont f x"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1889
      and dif [rule_format]: "\<forall>x. a < x & x < b --> f differentiable x"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1890
  shows "\<exists>l z. a < z & z < b & DERIV f z :> l &
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1891
                   (f(b) - f(a) = (b-a) * l)"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1892
proof -
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1893
  let ?F = "%x. f x - ((f b - f a) / (b-a)) * x"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1894
  have contF: "\<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> isCont ?F x" using con
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1895
    by (fast intro: isCont_diff isCont_const isCont_mult isCont_Id)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1896
  have difF: "\<forall>x. a < x \<and> x < b \<longrightarrow> ?F differentiable x"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1897
  proof (clarify)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1898
    fix x::real
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1899
    assume ax: "a < x" and xb: "x < b"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1900
    from differentiableD [OF dif [OF conjI [OF ax xb]]]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1901
    obtain l where der: "DERIV f x :> l" ..
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1902
    show "?F differentiable x"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1903
      by (rule differentiableI [where D = "l - (f b - f a)/(b-a)"],
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1904
          blast intro: DERIV_diff DERIV_cmult_Id der)
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1905
  qed
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1906
  from Rolle [where f = ?F, OF lt lemma_MVT contF difF]
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1907
  obtain z where az: "a < z" and zb: "z < b" and der: "DERIV ?F z :> 0"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1908
    by blast
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1909
  have "DERIV (%x. ((f b - f a)/(b-a)) * x) z :> (f b - f a)/(b-a)"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1910
    by (rule DERIV_cmult_Id)
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1911
  hence derF: "DERIV (\<lambda>x. ?F x + (f b - f a) / (b - a) * x) z
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1912
                   :> 0 + (f b - f a) / (b - a)"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1913
    by (rule DERIV_add [OF der])
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1914
  show ?thesis
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1915
  proof (intro exI conjI)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1916
    show "a < z" .
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1917
    show "z < b" .
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15360
diff changeset
  1918
    show "f b - f a = (b - a) * ((f b - f a)/(b-a))" by (simp)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1919
    show "DERIV f z :> ((f b - f a)/(b-a))"  using derF by simp
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1920
  qed
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1921
qed
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1922
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1923
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1924
text{*A function is constant if its derivative is 0 over an interval.*}
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1925
20793
3b0489715b0e generalize type of DERIV
huffman
parents: 20756
diff changeset
  1926
lemma DERIV_isconst_end:
3b0489715b0e generalize type of DERIV
huffman
parents: 20756
diff changeset
  1927
  fixes f :: "real => real"
3b0489715b0e generalize type of DERIV
huffman
parents: 20756
diff changeset
  1928
  shows "[| a < b;
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1929
         \<forall>x. a \<le> x & x \<le> b --> isCont f x;
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1930
         \<forall>x. a < x & x < b --> DERIV f x :> 0 |]
15360
300e09825d8b Added "ALL x > y" and relatives.
nipkow
parents: 15251
diff changeset
  1931
        ==> f b = f a"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1932
apply (drule MVT, assumption)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1933
apply (blast intro: differentiableI)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1934
apply (auto dest!: DERIV_unique simp add: diff_eq_eq)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1935
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1936
20793
3b0489715b0e generalize type of DERIV
huffman
parents: 20756
diff changeset
  1937
lemma DERIV_isconst1:
3b0489715b0e generalize type of DERIV
huffman
parents: 20756
diff changeset
  1938
  fixes f :: "real => real"
3b0489715b0e generalize type of DERIV
huffman
parents: 20756
diff changeset
  1939
  shows "[| a < b;
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1940
         \<forall>x. a \<le> x & x \<le> b --> isCont f x;
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1941
         \<forall>x. a < x & x < b --> DERIV f x :> 0 |]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1942
        ==> \<forall>x. a \<le> x & x \<le> b --> f x = f a"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1943
apply safe
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1944
apply (drule_tac x = a in order_le_imp_less_or_eq, safe)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1945
apply (drule_tac b = x in DERIV_isconst_end, auto)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1946
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1947
20793
3b0489715b0e generalize type of DERIV
huffman
parents: 20756
diff changeset
  1948
lemma DERIV_isconst2:
3b0489715b0e generalize type of DERIV
huffman
parents: 20756
diff changeset
  1949
  fixes f :: "real => real"
3b0489715b0e generalize type of DERIV
huffman
parents: 20756
diff changeset
  1950
  shows "[| a < b;
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1951
         \<forall>x. a \<le> x & x \<le> b --> isCont f x;
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1952
         \<forall>x. a < x & x < b --> DERIV f x :> 0;
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1953
         a \<le> x; x \<le> b |]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1954
        ==> f x = f a"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1955
apply (blast dest: DERIV_isconst1)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1956
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1957
20793
3b0489715b0e generalize type of DERIV
huffman
parents: 20756
diff changeset
  1958
lemma DERIV_isconst_all:
3b0489715b0e generalize type of DERIV
huffman
parents: 20756
diff changeset
  1959
  fixes f :: "real => real"
3b0489715b0e generalize type of DERIV
huffman
parents: 20756
diff changeset
  1960
  shows "\<forall>x. DERIV f x :> 0 ==> f(x) = f(y)"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1961
apply (rule linorder_cases [of x y])
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1962
apply (blast intro: sym DERIV_isCont DERIV_isconst_end)+
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1963
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1964
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1965
lemma DERIV_const_ratio_const:
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1966
     "[|a \<noteq> b; \<forall>x. DERIV f x :> k |] ==> (f(b) - f(a)) = (b-a) * k"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1967
apply (rule linorder_cases [of a b], auto)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1968
apply (drule_tac [!] f = f in MVT)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1969
apply (auto dest: DERIV_isCont DERIV_unique simp add: differentiable_def)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1970
apply (auto dest: DERIV_unique simp add: left_distrib diff_minus)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1971
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1972
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1973
lemma DERIV_const_ratio_const2:
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1974
     "[|a \<noteq> b; \<forall>x. DERIV f x :> k |] ==> (f(b) - f(a))/(b-a) = k"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1975
apply (rule_tac c1 = "b-a" in real_mult_right_cancel [THEN iffD1])
15539
333a88244569 comprehensive cleanup, replacing sumr by setsum
nipkow
parents: 15360
diff changeset
  1976
apply (auto dest!: DERIV_const_ratio_const simp add: mult_assoc)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1977
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1978
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1979
lemma real_average_minus_first [simp]: "((a + b) /2 - a) = (b-a)/(2::real)"
19023
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  1980
by (simp)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1981
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1982
lemma real_average_minus_second [simp]: "((b + a)/2 - a) = (b-a)/(2::real)"
19023
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  1983
by (simp)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1984
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1985
text{*Gallileo's "trick": average velocity = av. of end velocities*}
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1986
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1987
lemma DERIV_const_average:
20793
3b0489715b0e generalize type of DERIV
huffman
parents: 20756
diff changeset
  1988
  fixes v :: "real => real"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1989
  assumes neq: "a \<noteq> (b::real)"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1990
      and der: "\<forall>x. DERIV v x :> k"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1991
  shows "v ((a + b)/2) = (v a + v b)/2"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1992
proof (cases rule: linorder_cases [of a b])
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1993
  case equal with neq show ?thesis by simp
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1994
next
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1995
  case less
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1996
  have "(v b - v a) / (b - a) = k"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1997
    by (rule DERIV_const_ratio_const2 [OF neq der])
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  1998
  hence "(b-a) * ((v b - v a) / (b-a)) = (b-a) * k" by simp
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  1999
  moreover have "(v ((a + b) / 2) - v a) / ((a + b) / 2 - a) = k"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2000
    by (rule DERIV_const_ratio_const2 [OF _ der], simp add: neq)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2001
  ultimately show ?thesis using neq by force
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2002
next
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2003
  case greater
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2004
  have "(v b - v a) / (b - a) = k"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2005
    by (rule DERIV_const_ratio_const2 [OF neq der])
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  2006
  hence "(b-a) * ((v b - v a) / (b-a)) = (b-a) * k" by simp
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2007
  moreover have " (v ((b + a) / 2) - v a) / ((b + a) / 2 - a) = k"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2008
    by (rule DERIV_const_ratio_const2 [OF _ der], simp add: neq)
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  2009
  ultimately show ?thesis using neq by (force simp add: add_commute)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2010
qed
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2011
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2012
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2013
text{*Dull lemma: an continuous injection on an interval must have a
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2014
strict maximum at an end point, not in the middle.*}
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2015
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2016
lemma lemma_isCont_inj:
20552
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
  2017
  fixes f :: "real \<Rightarrow> real"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2018
  assumes d: "0 < d"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2019
      and inj [rule_format]: "\<forall>z. \<bar>z-x\<bar> \<le> d --> g(f z) = z"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2020
      and cont: "\<forall>z. \<bar>z-x\<bar> \<le> d --> isCont f z"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2021
  shows "\<exists>z. \<bar>z-x\<bar> \<le> d & f x < f z"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2022
proof (rule ccontr)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2023
  assume  "~ (\<exists>z. \<bar>z-x\<bar> \<le> d & f x < f z)"
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  2024
  hence all [rule_format]: "\<forall>z. \<bar>z - x\<bar> \<le> d --> f z \<le> f x" by auto
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2025
  show False
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2026
  proof (cases rule: linorder_le_cases [of "f(x-d)" "f(x+d)"])
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2027
    case le
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2028
    from d cont all [of "x+d"]
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  2029
    have flef: "f(x+d) \<le> f x"
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  2030
     and xlex: "x - d \<le> x"
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  2031
     and cont': "\<forall>z. x - d \<le> z \<and> z \<le> x \<longrightarrow> isCont f z"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2032
       by (auto simp add: abs_if)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2033
    from IVT [OF le flef xlex cont']
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2034
    obtain x' where "x-d \<le> x'" "x' \<le> x" "f x' = f(x+d)" by blast
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2035
    moreover
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2036
    hence "g(f x') = g (f(x+d))" by simp
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2037
    ultimately show False using d inj [of x'] inj [of "x+d"]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2038
      by (simp add: abs_le_interval_iff)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2039
  next
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2040
    case ge
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2041
    from d cont all [of "x-d"]
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  2042
    have flef: "f(x-d) \<le> f x"
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  2043
     and xlex: "x \<le> x+d"
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  2044
     and cont': "\<forall>z. x \<le> z \<and> z \<le> x+d \<longrightarrow> isCont f z"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2045
       by (auto simp add: abs_if)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2046
    from IVT2 [OF ge flef xlex cont']
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2047
    obtain x' where "x \<le> x'" "x' \<le> x+d" "f x' = f(x-d)" by blast
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2048
    moreover
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2049
    hence "g(f x') = g (f(x-d))" by simp
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2050
    ultimately show False using d inj [of x'] inj [of "x-d"]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2051
      by (simp add: abs_le_interval_iff)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2052
  qed
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2053
qed
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2054
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2055
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2056
text{*Similar version for lower bound.*}
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2057
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2058
lemma lemma_isCont_inj2:
20552
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
  2059
  fixes f g :: "real \<Rightarrow> real"
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
  2060
  shows "[|0 < d; \<forall>z. \<bar>z-x\<bar> \<le> d --> g(f z) = z;
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2061
        \<forall>z. \<bar>z-x\<bar> \<le> d --> isCont f z |]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2062
      ==> \<exists>z. \<bar>z-x\<bar> \<le> d & f z < f x"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2063
apply (insert lemma_isCont_inj
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2064
          [where f = "%x. - f x" and g = "%y. g(-y)" and x = x and d = d])
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  2065
apply (simp add: isCont_minus linorder_not_le)
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2066
done
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2067
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  2068
text{*Show there's an interval surrounding @{term "f(x)"} in
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2069
@{text "f[[x - d, x + d]]"} .*}
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2070
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  2071
lemma isCont_inj_range:
20552
2c31dd358c21 generalized types of many constants to work over arbitrary vector spaces;
huffman
parents: 20432
diff changeset
  2072
  fixes f :: "real \<Rightarrow> real"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2073
  assumes d: "0 < d"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2074
      and inj: "\<forall>z. \<bar>z-x\<bar> \<le> d --> g(f z) = z"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2075
      and cont: "\<forall>z. \<bar>z-x\<bar> \<le> d --> isCont f z"
15360
300e09825d8b Added "ALL x > y" and relatives.
nipkow
parents: 15251
diff changeset
  2076
  shows "\<exists>e>0. \<forall>y. \<bar>y - f x\<bar> \<le> e --> (\<exists>z. \<bar>z-x\<bar> \<le> d & f z = y)"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2077
proof -
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2078
  have "x-d \<le> x+d" "\<forall>z. x-d \<le> z \<and> z \<le> x+d \<longrightarrow> isCont f z" using cont d
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2079
    by (auto simp add: abs_le_interval_iff)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2080
  from isCont_Lb_Ub [OF this]
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  2081
  obtain L M
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2082
  where all1 [rule_format]: "\<forall>z. x-d \<le> z \<and> z \<le> x+d \<longrightarrow> L \<le> f z \<and> f z \<le> M"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2083
    and all2 [rule_format]:
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2084
           "\<forall>y. L \<le> y \<and> y \<le> M \<longrightarrow> (\<exists>z. x-d \<le> z \<and> z \<le> x+d \<and> f z = y)"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2085
    by auto
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2086
  with d have "L \<le> f x & f x \<le> M" by simp
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2087
  moreover have "L \<noteq> f x"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2088
  proof -
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2089
    from lemma_isCont_inj2 [OF d inj cont]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2090
    obtain u where "\<bar>u - x\<bar> \<le> d" "f u < f x"  by auto
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2091
    thus ?thesis using all1 [of u] by arith
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2092
  qed
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2093
  moreover have "f x \<noteq> M"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2094
  proof -
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2095
    from lemma_isCont_inj [OF d inj cont]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2096
    obtain u where "\<bar>u - x\<bar> \<le> d" "f x < f u"  by auto
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2097
    thus ?thesis using all1 [of u] by arith
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2098
  qed
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2099
  ultimately have "L < f x & f x < M" by arith
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2100
  hence "0 < f x - L" "0 < M - f x" by arith+
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2101
  from real_lbound_gt_zero [OF this]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2102
  obtain e where e: "0 < e" "e < f x - L" "e < M - f x" by auto
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2103
  thus ?thesis
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2104
  proof (intro exI conjI)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2105
    show "0<e" .
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2106
    show "\<forall>y. \<bar>y - f x\<bar> \<le> e \<longrightarrow> (\<exists>z. \<bar>z - x\<bar> \<le> d \<and> f z = y)"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2107
    proof (intro strip)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2108
      fix y::real
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2109
      assume "\<bar>y - f x\<bar> \<le> e"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2110
      with e have "L \<le> y \<and> y \<le> M" by arith
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2111
      from all2 [OF this]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2112
      obtain z where "x - d \<le> z" "z \<le> x + d" "f z = y" by blast
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  2113
      thus "\<exists>z. \<bar>z - x\<bar> \<le> d \<and> f z = y"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2114
        by (force simp add: abs_le_interval_iff)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2115
    qed
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2116
  qed
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2117
qed
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2118
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2119
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2120
text{*Continuity of inverse function*}
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2121
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2122
lemma isCont_inverse_function:
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
  2123
  fixes f g :: "real \<Rightarrow> real"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2124
  assumes d: "0 < d"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2125
      and inj: "\<forall>z. \<bar>z-x\<bar> \<le> d --> g(f z) = z"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2126
      and cont: "\<forall>z. \<bar>z-x\<bar> \<le> d --> isCont f z"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2127
  shows "isCont g (f x)"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2128
proof (simp add: isCont_iff LIM_eq)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2129
  show "\<forall>r. 0 < r \<longrightarrow>
15360
300e09825d8b Added "ALL x > y" and relatives.
nipkow
parents: 15251
diff changeset
  2130
         (\<exists>s>0. \<forall>z. z\<noteq>0 \<and> \<bar>z\<bar> < s \<longrightarrow> \<bar>g(f x + z) - g(f x)\<bar> < r)"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2131
  proof (intro strip)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2132
    fix r::real
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2133
    assume r: "0<r"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2134
    from real_lbound_gt_zero [OF r d]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2135
    obtain e where e: "0 < e" and e_lt: "e < r \<and> e < d" by blast
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2136
    with inj cont
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  2137
    have e_simps: "\<forall>z. \<bar>z-x\<bar> \<le> e --> g (f z) = z"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2138
                  "\<forall>z. \<bar>z-x\<bar> \<le> e --> isCont f z"   by auto
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2139
    from isCont_inj_range [OF e this]
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  2140
    obtain e' where e': "0 < e'"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2141
        and all: "\<forall>y. \<bar>y - f x\<bar> \<le> e' \<longrightarrow> (\<exists>z. \<bar>z - x\<bar> \<le> e \<and> f z = y)"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2142
          by blast
15360
300e09825d8b Added "ALL x > y" and relatives.
nipkow
parents: 15251
diff changeset
  2143
    show "\<exists>s>0. \<forall>z. z\<noteq>0 \<and> \<bar>z\<bar> < s \<longrightarrow> \<bar>g(f x + z) - g(f x)\<bar> < r"
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2144
    proof (intro exI conjI)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2145
      show "0<e'" .
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2146
      show "\<forall>z. z \<noteq> 0 \<and> \<bar>z\<bar> < e' \<longrightarrow> \<bar>g (f x + z) - g (f x)\<bar> < r"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2147
      proof (intro strip)
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2148
        fix z::real
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2149
        assume z: "z \<noteq> 0 \<and> \<bar>z\<bar> < e'"
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2150
        with e e_lt e_simps all [rule_format, of "f x + z"]
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2151
        show "\<bar>g (f x + z) - g (f x)\<bar> < r" by force
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2152
      qed
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2153
    qed
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2154
  qed
15228
4d332d10fa3d revised simprules for division
paulson
parents: 15195
diff changeset
  2155
qed
14477
cc61fd03e589 conversion of Hyperreal/Lim to new-style
paulson
parents: 14387
diff changeset
  2156
19023
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2157
theorem GMVT:
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2158
  assumes alb: "a < b"
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2159
  and fc: "\<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> isCont f x"
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2160
  and fd: "\<forall>x. a < x \<and> x < b \<longrightarrow> f differentiable x"
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2161
  and gc: "\<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> isCont g x"
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2162
  and gd: "\<forall>x. a < x \<and> x < b \<longrightarrow> g differentiable x"
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2163
  shows "\<exists>g'c f'c c. DERIV g c :> g'c \<and> DERIV f c :> f'c \<and> a < c \<and> c < b \<and> ((f b - f a) * g'c) = ((g b - g a) * f'c)"
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2164
proof -
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2165
  let ?h = "\<lambda>x. (f b - f a)*(g x) - (g b - g a)*(f x)"
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2166
  from prems have "a < b" by simp
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2167
  moreover have "\<forall>x. a \<le> x \<and> x \<le> b \<longrightarrow> isCont ?h x"
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2168
  proof -
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2169
    have "\<forall>x. a <= x \<and> x <= b \<longrightarrow> isCont (\<lambda>x. f b - f a) x" by simp
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2170
    with gc have "\<forall>x. a <= x \<and> x <= b \<longrightarrow> isCont (\<lambda>x. (f b - f a) * g x) x"
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2171
      by (auto intro: isCont_mult)
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2172
    moreover
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2173
    have "\<forall>x. a <= x \<and> x <= b \<longrightarrow> isCont (\<lambda>x. g b - g a) x" by simp
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2174
    with fc have "\<forall>x. a <= x \<and> x <= b \<longrightarrow> isCont (\<lambda>x. (g b - g a) * f x) x"
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2175
      by (auto intro: isCont_mult)
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2176
    ultimately show ?thesis
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2177
      by (fastsimp intro: isCont_diff)
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2178
  qed
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2179
  moreover
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2180
  have "\<forall>x. a < x \<and> x < b \<longrightarrow> ?h differentiable x"
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2181
  proof -
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2182
    have "\<forall>x. a < x \<and> x < b \<longrightarrow> (\<lambda>x. f b - f a) differentiable x" by (simp add: differentiable_const)
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2183
    with gd have "\<forall>x. a < x \<and> x < b \<longrightarrow> (\<lambda>x. (f b - f a) * g x) differentiable x" by (simp add: differentiable_mult)
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2184
    moreover
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2185
    have "\<forall>x. a < x \<and> x < b \<longrightarrow> (\<lambda>x. g b - g a) differentiable x" by (simp add: differentiable_const)
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2186
    with fd have "\<forall>x. a < x \<and> x < b \<longrightarrow> (\<lambda>x. (g b - g a) * f x) differentiable x" by (simp add: differentiable_mult)
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2187
    ultimately show ?thesis by (simp add: differentiable_diff)
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2188
  qed
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2189
  ultimately have "\<exists>l z. a < z \<and> z < b \<and> DERIV ?h z :> l \<and> ?h b - ?h a = (b - a) * l" by (rule MVT)
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2190
  then obtain l where ldef: "\<exists>z. a < z \<and> z < b \<and> DERIV ?h z :> l \<and> ?h b - ?h a = (b - a) * l" ..
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2191
  then obtain c where cdef: "a < c \<and> c < b \<and> DERIV ?h c :> l \<and> ?h b - ?h a = (b - a) * l" ..
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2192
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2193
  from cdef have cint: "a < c \<and> c < b" by auto
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2194
  with gd have "g differentiable c" by simp
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2195
  hence "\<exists>D. DERIV g c :> D" by (rule differentiableD)
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2196
  then obtain g'c where g'cdef: "DERIV g c :> g'c" ..
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2197
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2198
  from cdef have "a < c \<and> c < b" by auto
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2199
  with fd have "f differentiable c" by simp
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2200
  hence "\<exists>D. DERIV f c :> D" by (rule differentiableD)
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2201
  then obtain f'c where f'cdef: "DERIV f c :> f'c" ..
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2202
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2203
  from cdef have "DERIV ?h c :> l" by auto
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2204
  moreover
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2205
  {
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2206
    from g'cdef have "DERIV (\<lambda>x. (f b - f a) * g x) c :> g'c * (f b - f a)"
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2207
      apply (insert DERIV_const [where k="f b - f a"])
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2208
      apply (drule meta_spec [of _ c])
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2209
      apply (drule DERIV_mult [where f="(\<lambda>x. f b - f a)" and g=g])
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2210
      by simp_all
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2211
    moreover from f'cdef have "DERIV (\<lambda>x. (g b - g a) * f x) c :> f'c * (g b - g a)"
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2212
      apply (insert DERIV_const [where k="g b - g a"])
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2213
      apply (drule meta_spec [of _ c])
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2214
      apply (drule DERIV_mult [where f="(\<lambda>x. g b - g a)" and g=f])
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2215
      by simp_all
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2216
    ultimately have "DERIV ?h c :>  g'c * (f b - f a) - f'c * (g b - g a)"
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2217
      by (simp add: DERIV_diff)
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2218
  }
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2219
  ultimately have leq: "l =  g'c * (f b - f a) - f'c * (g b - g a)" by (rule DERIV_unique)
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2220
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2221
  {
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2222
    from cdef have "?h b - ?h a = (b - a) * l" by auto
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2223
    also with leq have "\<dots> = (b - a) * (g'c * (f b - f a) - f'c * (g b - g a))" by simp
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2224
    finally have "?h b - ?h a = (b - a) * (g'c * (f b - f a) - f'c * (g b - g a))" by simp
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2225
  }
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2226
  moreover
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2227
  {
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2228
    have "?h b - ?h a =
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2229
         ((f b)*(g b) - (f a)*(g b) - (g b)*(f b) + (g a)*(f b)) -
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2230
          ((f b)*(g a) - (f a)*(g a) - (g b)*(f a) + (g a)*(f a))"
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2231
      by (simp add: mult_ac add_ac real_diff_mult_distrib)
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2232
    hence "?h b - ?h a = 0" by auto
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2233
  }
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2234
  ultimately have "(b - a) * (g'c * (f b - f a) - f'c * (g b - g a)) = 0" by auto
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2235
  with alb have "g'c * (f b - f a) - f'c * (g b - g a) = 0" by simp
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2236
  hence "g'c * (f b - f a) = f'c * (g b - g a)" by simp
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2237
  hence "(f b - f a) * g'c = (g b - g a) * f'c" by (simp add: mult_ac)
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2238
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2239
  with g'cdef f'cdef cint show ?thesis by auto
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2240
qed
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2241
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2242
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2243
lemma LIMSEQ_SEQ_conv1:
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
  2244
  fixes a :: real
19023
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2245
  assumes "X -- a --> L"
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2246
  shows "\<forall>S. (\<forall>n. S n \<noteq> a) \<and> S ----> a \<longrightarrow> (\<lambda>n. X (S n)) ----> L"
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2247
proof -
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2248
  {
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  2249
    from prems have Xdef: "\<forall>r > 0. \<exists>s > 0. \<forall>x. x \<noteq> a & norm (x - a) < s --> norm (X x - L) < r" by (unfold LIM_def)
19023
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2250
    
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2251
    fix S
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2252
    assume as: "(\<forall>n. S n \<noteq> a) \<and> S ----> a"
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2253
    then have "S ----> a" by auto
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  2254
    then have Sdef: "(\<forall>r. 0 < r --> (\<exists>no. \<forall>n. no \<le> n --> norm (S n - a) < r))" by (unfold LIMSEQ_def)
19023
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2255
    {
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2256
      fix r
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  2257
      from Xdef have Xdef2: "0 < r --> (\<exists>s > 0. \<forall>x. x \<noteq> a \<and> \<bar>x - a\<bar> < s --> norm (X x - L) < r)" by simp
19023
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2258
      {
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2259
        assume rgz: "0 < r"
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2260
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  2261
        from Xdef2 rgz have "\<exists>s > 0. \<forall>x. x \<noteq> a \<and> \<bar>x - a\<bar> < s --> norm (X x - L) < r" by simp 
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  2262
        then obtain s where sdef: "s > 0 \<and> (\<forall>x. x\<noteq>a \<and> \<bar>x - a\<bar> < s \<longrightarrow> norm (X x - L) < r)" by auto
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  2263
        then have aux: "\<forall>x. x\<noteq>a \<and> \<bar>x - a\<bar> < s \<longrightarrow> norm (X x - L) < r" by auto
19023
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2264
        {
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2265
          fix n
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  2266
          from aux have "S n \<noteq> a \<and> \<bar>S n - a\<bar> < s \<longrightarrow> norm (X (S n) - L) < r" by simp
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  2267
          with as have imp2: "\<bar>S n - a\<bar> < s --> norm (X (S n) - L) < r" by auto
19023
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2268
        }
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  2269
        hence "\<forall>n. \<bar>S n - a\<bar> < s --> norm (X (S n) - L) < r" ..
19023
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2270
        moreover
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  2271
        from Sdef sdef have imp1: "\<exists>no. \<forall>n. no \<le> n --> \<bar>S n - a\<bar> < s" by auto  
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  2272
        then obtain no where "\<forall>n. no \<le> n --> \<bar>S n - a\<bar> < s" by auto
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  2273
        ultimately have "\<forall>n. no \<le> n \<longrightarrow> norm (X (S n) - L) < r" by simp
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  2274
        hence "\<exists>no. \<forall>n. no \<le> n \<longrightarrow> norm (X (S n) - L) < r" by auto
19023
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2275
      }
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2276
    }
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  2277
    hence "(\<forall>r. 0 < r --> (\<exists>no. \<forall>n. no \<le> n --> norm (X (S n) - L) < r))" by simp
19023
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2278
    hence "(\<lambda>n. X (S n)) ----> L" by (fold LIMSEQ_def)
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2279
  }
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2280
  thus ?thesis by simp
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2281
qed
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2282
20432
07ec57376051 lin_arith_prover: splitting reverted because of performance loss
webertj
parents: 20409
diff changeset
  2283
ML {* fast_arith_split_limit := 0; *}  (* FIXME *)
20217
25b068a99d2b linear arithmetic splits certain operators (e.g. min, max, abs)
webertj
parents: 19765
diff changeset
  2284
19023
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2285
lemma LIMSEQ_SEQ_conv2:
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
  2286
  fixes a :: real
19023
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2287
  assumes "\<forall>S. (\<forall>n. S n \<noteq> a) \<and> S ----> a \<longrightarrow> (\<lambda>n. X (S n)) ----> L"
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2288
  shows "X -- a --> L"
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2289
proof (rule ccontr)
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2290
  assume "\<not> (X -- a --> L)"
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  2291
  hence "\<not> (\<forall>r > 0. \<exists>s > 0. \<forall>x. x \<noteq> a & norm (x - a) < s --> norm (X x - L) < r)" by (unfold LIM_def)
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  2292
  hence "\<exists>r > 0. \<forall>s > 0. \<exists>x. \<not>(x \<noteq> a \<and> \<bar>x - a\<bar> < s --> norm (X x - L) < r)" by simp
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  2293
  hence "\<exists>r > 0. \<forall>s > 0. \<exists>x. (x \<noteq> a \<and> \<bar>x - a\<bar> < s \<and> norm (X x - L) \<ge> r)" by (simp add: linorder_not_less)
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  2294
  then obtain r where rdef: "r > 0 \<and> (\<forall>s > 0. \<exists>x. (x \<noteq> a \<and> \<bar>x - a\<bar> < s \<and> norm (X x - L) \<ge> r))" by auto
19023
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2295
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  2296
  let ?F = "\<lambda>n::nat. SOME x. x\<noteq>a \<and> \<bar>x - a\<bar> < inverse (real (Suc n)) \<and> norm (X x - L) \<ge> r"
19023
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2297
  have "?F ----> a"
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2298
  proof -
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2299
    {
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2300
      fix e::real
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2301
      assume "0 < e"
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2302
        (* choose no such that inverse (real (Suc n)) < e *)
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2303
      have "\<exists>no. inverse (real (Suc no)) < e" by (rule reals_Archimedean)
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2304
      then obtain m where nodef: "inverse (real (Suc m)) < e" by auto
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2305
      {
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2306
        fix n
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2307
        assume mlen: "m \<le> n"
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2308
        then have
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2309
          "inverse (real (Suc n)) \<le> inverse (real (Suc m))"
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2310
          by auto
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2311
        moreover have
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  2312
          "\<bar>?F n - a\<bar> < inverse (real (Suc n))"
19023
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2313
        proof -
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2314
          from rdef have
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  2315
            "\<exists>x. x\<noteq>a \<and> \<bar>x - a\<bar> < inverse (real (Suc n)) \<and> norm (X x - L) \<ge> r"
19023
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2316
            by simp
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2317
          hence
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  2318
            "(?F n)\<noteq>a \<and> \<bar>(?F n) - a\<bar> < inverse (real (Suc n)) \<and> norm (X (?F n) - L) \<ge> r"
19023
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2319
            by (simp add: some_eq_ex [symmetric])
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2320
          thus ?thesis by simp
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2321
        qed
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2322
        moreover from nodef have
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2323
          "inverse (real (Suc m)) < e" .
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  2324
        ultimately have "\<bar>?F n - a\<bar> < e" by arith
19023
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2325
      }
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  2326
      then have "\<exists>no. \<forall>n. no \<le> n --> \<bar>?F n - a\<bar> < e" by auto
19023
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2327
    }
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2328
    thus ?thesis by (unfold LIMSEQ_def, simp)
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2329
  qed
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2330
  
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2331
  moreover have "\<forall>n. ?F n \<noteq> a"
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2332
  proof -
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2333
    {
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2334
      fix n
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2335
      from rdef have
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  2336
        "\<exists>x. x\<noteq>a \<and> \<bar>x - a\<bar> < inverse (real (Suc n)) \<and> norm (X x - L) \<ge> r"
19023
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2337
        by simp
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2338
      hence "?F n \<noteq> a" by (simp add: some_eq_ex [symmetric])
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2339
    }
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2340
    thus ?thesis ..
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2341
  qed
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2342
  moreover from prems have "\<forall>S. (\<forall>n. S n \<noteq> a) \<and> S ----> a \<longrightarrow> (\<lambda>n. X (S n)) ----> L" by simp
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2343
  ultimately have "(\<lambda>n. X (?F n)) ----> L" by simp
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2344
  
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2345
  moreover have "\<not> ((\<lambda>n. X (?F n)) ----> L)"
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2346
  proof -
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2347
    {
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2348
      fix no::nat
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2349
      obtain n where "n = no + 1" by simp
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2350
      then have nolen: "no \<le> n" by simp
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2351
        (* We prove this by showing that for any m there is an n\<ge>m such that |X (?F n) - L| \<ge> r *)
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  2352
      from rdef have "\<forall>s > 0. \<exists>x. (x \<noteq> a \<and> \<bar>x - a\<bar> < s \<and> norm (X x - L) \<ge> r)" ..
19023
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2353
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  2354
      then have "\<exists>x. x\<noteq>a \<and> \<bar>x - a\<bar> < inverse (real (Suc n)) \<and> norm (X x - L) \<ge> r" by simp
19023
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2355
      
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  2356
      hence "norm (X (?F n) - L) \<ge> r" by (simp add: some_eq_ex [symmetric])
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  2357
      with nolen have "\<exists>n. no \<le> n \<and> norm (X (?F n) - L) \<ge> r" by auto
19023
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2358
    }
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  2359
    then have "(\<forall>no. \<exists>n. no \<le> n \<and> norm (X (?F n) - L) \<ge> r)" by simp
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  2360
    with rdef have "\<exists>e>0. (\<forall>no. \<exists>n. no \<le> n \<and> norm (X (?F n) - L) \<ge> e)" by auto
19023
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2361
    thus ?thesis by (unfold LIMSEQ_def, auto simp add: linorder_not_less)
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2362
  qed
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2363
  ultimately show False by simp
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2364
qed
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2365
20432
07ec57376051 lin_arith_prover: splitting reverted because of performance loss
webertj
parents: 20409
diff changeset
  2366
ML {* fast_arith_split_limit := 9; *}  (* FIXME *)
19023
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2367
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2368
lemma LIMSEQ_SEQ_conv:
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
  2369
  "(\<forall>S. (\<forall>n. S n \<noteq> a) \<and> S ----> (a::real) \<longrightarrow> (\<lambda>n. X (S n)) ----> L) =
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
  2370
   (X -- a --> L)"
19023
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2371
proof
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2372
  assume "\<forall>S. (\<forall>n. S n \<noteq> a) \<and> S ----> a \<longrightarrow> (\<lambda>n. X (S n)) ----> L"
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2373
  show "X -- a --> L" by (rule LIMSEQ_SEQ_conv2)
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2374
next
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2375
  assume "(X -- a --> L)"
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2376
  show "\<forall>S. (\<forall>n. S n \<noteq> a) \<and> S ----> a \<longrightarrow> (\<lambda>n. X (S n)) ----> L" by (rule LIMSEQ_SEQ_conv1)
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2377
qed
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2378
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2379
lemma real_sqz:
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2380
  fixes a::real
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2381
  assumes "a < c"
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2382
  shows "\<exists>b. a < b \<and> b < c"
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  2383
by (rule dense)
19023
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2384
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2385
lemma LIM_offset:
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2386
  assumes "(\<lambda>x. f x) -- a --> L"
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2387
  shows "(\<lambda>x. f (x+c)) -- (a-c) --> L"
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2388
proof -
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2389
  have "f -- a --> L" .
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2390
  hence
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  2391
    fd: "\<forall>r > 0. \<exists>s > 0. \<forall>x. x \<noteq> a & norm (x - a) < s --> norm (f x - L) < r"
19023
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2392
    by (unfold LIM_def)
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2393
  {
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2394
    fix r::real
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2395
    assume rgz: "0 < r"
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  2396
    with fd have "\<exists>s > 0. \<forall>x. x\<noteq>a \<and> norm (x - a) < s --> norm (f x - L) < r" by simp
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  2397
    then obtain s where sgz: "s > 0" and ax: "\<forall>x. x\<noteq>a \<and> norm (x - a) < s \<longrightarrow> norm (f x - L) < r" by auto
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  2398
    from ax have ax2: "\<forall>x. (x+c)\<noteq>a \<and> norm ((x+c) - a) < s \<longrightarrow> norm (f (x+c) - L) < r" by auto
19023
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2399
    {
20561
6a6d8004322f generalize type of (NS)LIM to work on functions with vector space domain types
huffman
parents: 20552
diff changeset
  2400
      fix x
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  2401
      from ax2 have nt: "(x+c)\<noteq>a \<and> norm ((x+c) - a) < s \<longrightarrow> norm (f (x+c) - L) < r" ..
19023
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2402
      moreover have "((x+c)\<noteq>a) = (x\<noteq>(a-c))" by auto
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  2403
      moreover have "((x+c) - a) = (x - (a-c))" by simp
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  2404
      ultimately have "x\<noteq>(a-c) \<and> norm (x - (a-c)) < s \<longrightarrow> norm (f (x+c) - L) < r" by simp
19023
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2405
    }
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  2406
    then have "\<forall>x. x\<noteq>(a-c) \<and> norm (x - (a-c)) < s \<longrightarrow> norm (f (x+c) - L) < r" ..
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  2407
    with sgz have "\<exists>s > 0. \<forall>x. x\<noteq>(a-c) \<and> norm (x - (a-c)) < s \<longrightarrow> norm (f (x+c) - L) < r" by auto
19023
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2408
  }
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2409
  then have
20563
44eda2314aab replace (x + - y) with (x - y)
huffman
parents: 20561
diff changeset
  2410
    "\<forall>r > 0. \<exists>s > 0. \<forall>x. x \<noteq> (a-c) & norm (x - (a-c)) < s --> norm (f (x+c) - L) < r" by simp
19023
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2411
  thus ?thesis by (fold LIM_def)
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2412
qed
5652a536b7e8 * include generalised MVT in HyperReal (contributed by Benjamin Porter)
kleing
parents: 17318
diff changeset
  2413
10751
a81ea5d3dd41 separation of HOL-Hyperreal from HOL-Real
paulson
parents:
diff changeset
  2414
end