src/HOL/Multivariate_Analysis/Derivative.thy
author wenzelm
Mon, 28 Dec 2015 01:28:28 +0100
changeset 61945 1135b8de26c3
parent 61915 e9812a95d108
child 61969 e01015e49041
permissions -rw-r--r--
more symbols;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
     1
(*  Title:      HOL/Multivariate_Analysis/Derivative.thy
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
     2
    Author:     John Harrison
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
     3
    Author:     Robert Himmelmann, TU Muenchen (translation from HOL Light)
36350
bc7982c54e37 dropped group_simps, ring_simps, field_eq_simps
haftmann
parents: 36334
diff changeset
     4
*)
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
     5
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
     6
section \<open>Multivariate calculus in Euclidean space\<close>
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
     7
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
     8
theory Derivative
61560
7c985fd653c5 tuned imports;
wenzelm
parents: 61531
diff changeset
     9
imports Brouwer_Fixpoint Operator_Norm Uniform_Limit
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
    10
begin
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
    11
61915
e9812a95d108 theory for type of bounded linear functions; differentiation under the integral sign
immler
parents: 61907
diff changeset
    12
lemma onorm_inner_left:
e9812a95d108 theory for type of bounded linear functions; differentiation under the integral sign
immler
parents: 61907
diff changeset
    13
  assumes "bounded_linear r"
e9812a95d108 theory for type of bounded linear functions; differentiation under the integral sign
immler
parents: 61907
diff changeset
    14
  shows "onorm (\<lambda>x. r x \<bullet> f) \<le> onorm r * norm f"
e9812a95d108 theory for type of bounded linear functions; differentiation under the integral sign
immler
parents: 61907
diff changeset
    15
proof (rule onorm_bound)
e9812a95d108 theory for type of bounded linear functions; differentiation under the integral sign
immler
parents: 61907
diff changeset
    16
  fix x
e9812a95d108 theory for type of bounded linear functions; differentiation under the integral sign
immler
parents: 61907
diff changeset
    17
  have "norm (r x \<bullet> f) \<le> norm (r x) * norm f"
e9812a95d108 theory for type of bounded linear functions; differentiation under the integral sign
immler
parents: 61907
diff changeset
    18
    by (simp add: Cauchy_Schwarz_ineq2)
e9812a95d108 theory for type of bounded linear functions; differentiation under the integral sign
immler
parents: 61907
diff changeset
    19
  also have "\<dots> \<le> onorm r * norm x * norm f"
e9812a95d108 theory for type of bounded linear functions; differentiation under the integral sign
immler
parents: 61907
diff changeset
    20
    by (intro mult_right_mono onorm assms norm_ge_zero)
e9812a95d108 theory for type of bounded linear functions; differentiation under the integral sign
immler
parents: 61907
diff changeset
    21
  finally show "norm (r x \<bullet> f) \<le> onorm r * norm f * norm x"
e9812a95d108 theory for type of bounded linear functions; differentiation under the integral sign
immler
parents: 61907
diff changeset
    22
    by (simp add: ac_simps)
e9812a95d108 theory for type of bounded linear functions; differentiation under the integral sign
immler
parents: 61907
diff changeset
    23
qed (intro mult_nonneg_nonneg norm_ge_zero onorm_pos_le assms)
e9812a95d108 theory for type of bounded linear functions; differentiation under the integral sign
immler
parents: 61907
diff changeset
    24
e9812a95d108 theory for type of bounded linear functions; differentiation under the integral sign
immler
parents: 61907
diff changeset
    25
lemma onorm_inner_right:
e9812a95d108 theory for type of bounded linear functions; differentiation under the integral sign
immler
parents: 61907
diff changeset
    26
  assumes "bounded_linear r"
e9812a95d108 theory for type of bounded linear functions; differentiation under the integral sign
immler
parents: 61907
diff changeset
    27
  shows "onorm (\<lambda>x. f \<bullet> r x) \<le> norm f * onorm r"
e9812a95d108 theory for type of bounded linear functions; differentiation under the integral sign
immler
parents: 61907
diff changeset
    28
  apply (subst inner_commute)
e9812a95d108 theory for type of bounded linear functions; differentiation under the integral sign
immler
parents: 61907
diff changeset
    29
  apply (rule onorm_inner_left[OF assms, THEN order_trans])
e9812a95d108 theory for type of bounded linear functions; differentiation under the integral sign
immler
parents: 61907
diff changeset
    30
  apply simp
e9812a95d108 theory for type of bounded linear functions; differentiation under the integral sign
immler
parents: 61907
diff changeset
    31
  done
e9812a95d108 theory for type of bounded linear functions; differentiation under the integral sign
immler
parents: 61907
diff changeset
    32
56369
2704ca85be98 moved generic theorems from Complex_Analysis_Basic; fixed some theorem names
hoelzl
parents: 56332
diff changeset
    33
declare has_derivative_bounded_linear[dest]
44137
ac5cb4c86448 simplify some proofs
huffman
parents: 44125
diff changeset
    34
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
    35
subsection \<open>Derivatives\<close>
51642
400ec5ae7f8f move FrechetDeriv from the Library to HOL/Deriv; base DERIV on FDERIV and both derivatives allow a restricted support set; FDERIV is now an abbreviation of has_derivative
hoelzl
parents: 51641
diff changeset
    36
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
    37
subsubsection \<open>Combining theorems.\<close>
51642
400ec5ae7f8f move FrechetDeriv from the Library to HOL/Deriv; base DERIV on FDERIV and both derivatives allow a restricted support set; FDERIV is now an abbreviation of has_derivative
hoelzl
parents: 51641
diff changeset
    38
56181
2aa0b19e74f3 unify syntax for has_derivative and differentiable
hoelzl
parents: 56151
diff changeset
    39
lemmas has_derivative_id = has_derivative_ident
2aa0b19e74f3 unify syntax for has_derivative and differentiable
hoelzl
parents: 56151
diff changeset
    40
lemmas has_derivative_neg = has_derivative_minus
2aa0b19e74f3 unify syntax for has_derivative and differentiable
hoelzl
parents: 56151
diff changeset
    41
lemmas has_derivative_sub = has_derivative_diff
2aa0b19e74f3 unify syntax for has_derivative and differentiable
hoelzl
parents: 56151
diff changeset
    42
lemmas scaleR_right_has_derivative = has_derivative_scaleR_right
2aa0b19e74f3 unify syntax for has_derivative and differentiable
hoelzl
parents: 56151
diff changeset
    43
lemmas scaleR_left_has_derivative = has_derivative_scaleR_left
2aa0b19e74f3 unify syntax for has_derivative and differentiable
hoelzl
parents: 56151
diff changeset
    44
lemmas inner_right_has_derivative = has_derivative_inner_right
2aa0b19e74f3 unify syntax for has_derivative and differentiable
hoelzl
parents: 56151
diff changeset
    45
lemmas inner_left_has_derivative = has_derivative_inner_left
2aa0b19e74f3 unify syntax for has_derivative and differentiable
hoelzl
parents: 56151
diff changeset
    46
lemmas mult_right_has_derivative = has_derivative_mult_right
2aa0b19e74f3 unify syntax for has_derivative and differentiable
hoelzl
parents: 56151
diff changeset
    47
lemmas mult_left_has_derivative = has_derivative_mult_left
51642
400ec5ae7f8f move FrechetDeriv from the Library to HOL/Deriv; base DERIV on FDERIV and both derivatives allow a restricted support set; FDERIV is now an abbreviation of has_derivative
hoelzl
parents: 51641
diff changeset
    48
400ec5ae7f8f move FrechetDeriv from the Library to HOL/Deriv; base DERIV on FDERIV and both derivatives allow a restricted support set; FDERIV is now an abbreviation of has_derivative
hoelzl
parents: 51641
diff changeset
    49
lemma has_derivative_add_const:
400ec5ae7f8f move FrechetDeriv from the Library to HOL/Deriv; base DERIV on FDERIV and both derivatives allow a restricted support set; FDERIV is now an abbreviation of has_derivative
hoelzl
parents: 51641
diff changeset
    50
  "(f has_derivative f') net \<Longrightarrow> ((\<lambda>x. f x + c) has_derivative f') net"
56381
0556204bc230 merged DERIV_intros, has_derivative_intros into derivative_intros
hoelzl
parents: 56371
diff changeset
    51
  by (intro derivative_eq_intros) auto
51642
400ec5ae7f8f move FrechetDeriv from the Library to HOL/Deriv; base DERIV on FDERIV and both derivatives allow a restricted support set; FDERIV is now an abbreviation of has_derivative
hoelzl
parents: 51641
diff changeset
    52
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
    53
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
    54
subsection \<open>Derivative with composed bilinear function.\<close>
51642
400ec5ae7f8f move FrechetDeriv from the Library to HOL/Deriv; base DERIV on FDERIV and both derivatives allow a restricted support set; FDERIV is now an abbreviation of has_derivative
hoelzl
parents: 51641
diff changeset
    55
400ec5ae7f8f move FrechetDeriv from the Library to HOL/Deriv; base DERIV on FDERIV and both derivatives allow a restricted support set; FDERIV is now an abbreviation of has_derivative
hoelzl
parents: 51641
diff changeset
    56
lemma has_derivative_bilinear_within:
400ec5ae7f8f move FrechetDeriv from the Library to HOL/Deriv; base DERIV on FDERIV and both derivatives allow a restricted support set; FDERIV is now an abbreviation of has_derivative
hoelzl
parents: 51641
diff changeset
    57
  assumes "(f has_derivative f') (at x within s)"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
    58
    and "(g has_derivative g') (at x within s)"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
    59
    and "bounded_bilinear h"
51642
400ec5ae7f8f move FrechetDeriv from the Library to HOL/Deriv; base DERIV on FDERIV and both derivatives allow a restricted support set; FDERIV is now an abbreviation of has_derivative
hoelzl
parents: 51641
diff changeset
    60
  shows "((\<lambda>x. h (f x) (g x)) has_derivative (\<lambda>d. h (f x) (g' d) + h (f' d) (g x))) (at x within s)"
400ec5ae7f8f move FrechetDeriv from the Library to HOL/Deriv; base DERIV on FDERIV and both derivatives allow a restricted support set; FDERIV is now an abbreviation of has_derivative
hoelzl
parents: 51641
diff changeset
    61
  using bounded_bilinear.FDERIV[OF assms(3,1,2)] .
400ec5ae7f8f move FrechetDeriv from the Library to HOL/Deriv; base DERIV on FDERIV and both derivatives allow a restricted support set; FDERIV is now an abbreviation of has_derivative
hoelzl
parents: 51641
diff changeset
    62
400ec5ae7f8f move FrechetDeriv from the Library to HOL/Deriv; base DERIV on FDERIV and both derivatives allow a restricted support set; FDERIV is now an abbreviation of has_derivative
hoelzl
parents: 51641
diff changeset
    63
lemma has_derivative_bilinear_at:
400ec5ae7f8f move FrechetDeriv from the Library to HOL/Deriv; base DERIV on FDERIV and both derivatives allow a restricted support set; FDERIV is now an abbreviation of has_derivative
hoelzl
parents: 51641
diff changeset
    64
  assumes "(f has_derivative f') (at x)"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
    65
    and "(g has_derivative g') (at x)"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
    66
    and "bounded_bilinear h"
51642
400ec5ae7f8f move FrechetDeriv from the Library to HOL/Deriv; base DERIV on FDERIV and both derivatives allow a restricted support set; FDERIV is now an abbreviation of has_derivative
hoelzl
parents: 51641
diff changeset
    67
  shows "((\<lambda>x. h (f x) (g x)) has_derivative (\<lambda>d. h (f x) (g' d) + h (f' d) (g x))) (at x)"
400ec5ae7f8f move FrechetDeriv from the Library to HOL/Deriv; base DERIV on FDERIV and both derivatives allow a restricted support set; FDERIV is now an abbreviation of has_derivative
hoelzl
parents: 51641
diff changeset
    68
  using has_derivative_bilinear_within[of f f' x UNIV g g' h] assms by simp
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
    69
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
    70
text \<open>These are the only cases we'll care about, probably.\<close>
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
    71
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
    72
lemma has_derivative_within: "(f has_derivative f') (at x within s) \<longleftrightarrow>
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
    73
    bounded_linear f' \<and> ((\<lambda>y. (1 / norm(y - x)) *\<^sub>R (f y - (f x + f' (y - x)))) ---> 0) (at x within s)"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
    74
  unfolding has_derivative_def Lim
57865
dcfb33c26f50 tuned proofs -- fewer warnings;
wenzelm
parents: 57512
diff changeset
    75
  by (auto simp add: netlimit_within field_simps)
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
    76
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
    77
lemma has_derivative_at: "(f has_derivative f') (at x) \<longleftrightarrow>
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
    78
    bounded_linear f' \<and> ((\<lambda>y. (1 / (norm(y - x))) *\<^sub>R (f y - (f x + f' (y - x)))) ---> 0) (at x)"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
    79
  using has_derivative_within [of f f' x UNIV]
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
    80
  by simp
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
    81
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
    82
text \<open>More explicit epsilon-delta forms.\<close>
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
    83
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
    84
lemma has_derivative_within':
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
    85
  "(f has_derivative f')(at x within s) \<longleftrightarrow>
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
    86
    bounded_linear f' \<and>
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
    87
    (\<forall>e>0. \<exists>d>0. \<forall>x'\<in>s. 0 < norm (x' - x) \<and> norm (x' - x) < d \<longrightarrow>
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
    88
      norm (f x' - f x - f'(x' - x)) / norm (x' - x) < e)"
36587
534418d8d494 remove redundant lemma vector_dist_norm
huffman
parents: 36581
diff changeset
    89
  unfolding has_derivative_within Lim_within dist_norm
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
    90
  unfolding diff_0_right
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
    91
  by (simp add: diff_diff_eq)
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
    92
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
    93
lemma has_derivative_at':
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
    94
  "(f has_derivative f') (at x) \<longleftrightarrow> bounded_linear f' \<and>
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
    95
    (\<forall>e>0. \<exists>d>0. \<forall>x'. 0 < norm (x' - x) \<and> norm (x' - x) < d \<longrightarrow>
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
    96
      norm (f x' - f x - f'(x' - x)) / norm (x' - x) < e)"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
    97
  using has_derivative_within' [of f f' x UNIV]
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
    98
  by simp
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
    99
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   100
lemma has_derivative_at_within:
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   101
  "(f has_derivative f') (at x) \<Longrightarrow> (f has_derivative f') (at x within s)"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   102
  unfolding has_derivative_within' has_derivative_at'
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   103
  by blast
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   104
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   105
lemma has_derivative_within_open:
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   106
  "a \<in> s \<Longrightarrow> open s \<Longrightarrow>
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   107
    (f has_derivative f') (at a within s) \<longleftrightarrow> (f has_derivative f') (at a)"
37730
1a24950dae33 generalize some lemmas about derivatives
huffman
parents: 37650
diff changeset
   108
  by (simp only: at_within_interior interior_open)
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   109
43338
a150d16bf77c lemmas about right derivative and limits
hoelzl
parents: 41970
diff changeset
   110
lemma has_derivative_right:
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   111
  fixes f :: "real \<Rightarrow> real"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   112
    and y :: "real"
43338
a150d16bf77c lemmas about right derivative and limits
hoelzl
parents: 41970
diff changeset
   113
  shows "(f has_derivative (op * y)) (at x within ({x <..} \<inter> I)) \<longleftrightarrow>
a150d16bf77c lemmas about right derivative and limits
hoelzl
parents: 41970
diff changeset
   114
    ((\<lambda>t. (f x - f t) / (x - t)) ---> y) (at x within ({x <..} \<inter> I))"
a150d16bf77c lemmas about right derivative and limits
hoelzl
parents: 41970
diff changeset
   115
proof -
a150d16bf77c lemmas about right derivative and limits
hoelzl
parents: 41970
diff changeset
   116
  have "((\<lambda>t. (f t - (f x + y * (t - x))) / \<bar>t - x\<bar>) ---> 0) (at x within ({x<..} \<inter> I)) \<longleftrightarrow>
a150d16bf77c lemmas about right derivative and limits
hoelzl
parents: 41970
diff changeset
   117
    ((\<lambda>t. (f t - f x) / (t - x) - y) ---> 0) (at x within ({x<..} \<inter> I))"
44282
f0de18b62d63 remove bounded_(bi)linear locale interpretations, to avoid duplicating so many lemmas
huffman
parents: 44140
diff changeset
   118
    by (intro Lim_cong_within) (auto simp add: diff_divide_distrib add_divide_distrib)
43338
a150d16bf77c lemmas about right derivative and limits
hoelzl
parents: 41970
diff changeset
   119
  also have "\<dots> \<longleftrightarrow> ((\<lambda>t. (f t - f x) / (t - x)) ---> y) (at x within ({x<..} \<inter> I))"
a150d16bf77c lemmas about right derivative and limits
hoelzl
parents: 41970
diff changeset
   120
    by (simp add: Lim_null[symmetric])
a150d16bf77c lemmas about right derivative and limits
hoelzl
parents: 41970
diff changeset
   121
  also have "\<dots> \<longleftrightarrow> ((\<lambda>t. (f x - f t) / (x - t)) ---> y) (at x within ({x<..} \<inter> I))"
44140
2c10c35dd4be remove several redundant and unused theorems about derivatives
huffman
parents: 44137
diff changeset
   122
    by (intro Lim_cong_within) (simp_all add: field_simps)
43338
a150d16bf77c lemmas about right derivative and limits
hoelzl
parents: 41970
diff changeset
   123
  finally show ?thesis
44282
f0de18b62d63 remove bounded_(bi)linear locale interpretations, to avoid duplicating so many lemmas
huffman
parents: 44140
diff changeset
   124
    by (simp add: bounded_linear_mult_right has_derivative_within)
43338
a150d16bf77c lemmas about right derivative and limits
hoelzl
parents: 41970
diff changeset
   125
qed
a150d16bf77c lemmas about right derivative and limits
hoelzl
parents: 41970
diff changeset
   126
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   127
subsubsection \<open>Caratheodory characterization\<close>
55970
6d123f0ae358 Some new proofs. Tidying up, esp to remove "apply rule".
paulson <lp15@cam.ac.uk>
parents: 55665
diff changeset
   128
6d123f0ae358 Some new proofs. Tidying up, esp to remove "apply rule".
paulson <lp15@cam.ac.uk>
parents: 55665
diff changeset
   129
lemma DERIV_within_iff:
56181
2aa0b19e74f3 unify syntax for has_derivative and differentiable
hoelzl
parents: 56151
diff changeset
   130
  "(f has_field_derivative D) (at a within s) \<longleftrightarrow> ((\<lambda>z. (f z - f a) / (z - a)) ---> D) (at a within s)"
55970
6d123f0ae358 Some new proofs. Tidying up, esp to remove "apply rule".
paulson <lp15@cam.ac.uk>
parents: 55665
diff changeset
   131
proof -
6d123f0ae358 Some new proofs. Tidying up, esp to remove "apply rule".
paulson <lp15@cam.ac.uk>
parents: 55665
diff changeset
   132
  have 1: "\<And>w y. ~(w = a) ==> y / (w - a) - D = (y - (w - a)*D)/(w - a)"
57512
cc97b347b301 reduced name variants for assoc and commute on plus and mult
haftmann
parents: 57447
diff changeset
   133
    by (metis divide_diff_eq_iff eq_iff_diff_eq_0 mult.commute)
55970
6d123f0ae358 Some new proofs. Tidying up, esp to remove "apply rule".
paulson <lp15@cam.ac.uk>
parents: 55665
diff changeset
   134
  show ?thesis
56181
2aa0b19e74f3 unify syntax for has_derivative and differentiable
hoelzl
parents: 56151
diff changeset
   135
    apply (simp add: has_field_derivative_def has_derivative_within bounded_linear_mult_right)
55970
6d123f0ae358 Some new proofs. Tidying up, esp to remove "apply rule".
paulson <lp15@cam.ac.uk>
parents: 55665
diff changeset
   136
    apply (simp add: LIM_zero_iff [where l = D, symmetric])
6d123f0ae358 Some new proofs. Tidying up, esp to remove "apply rule".
paulson <lp15@cam.ac.uk>
parents: 55665
diff changeset
   137
    apply (simp add: Lim_within dist_norm)
6d123f0ae358 Some new proofs. Tidying up, esp to remove "apply rule".
paulson <lp15@cam.ac.uk>
parents: 55665
diff changeset
   138
    apply (simp add: nonzero_norm_divide [symmetric])
59815
cce82e360c2f explicit commutative additive inverse operation;
haftmann
parents: 59558
diff changeset
   139
    apply (simp add: 1 diff_diff_eq ac_simps)
55970
6d123f0ae358 Some new proofs. Tidying up, esp to remove "apply rule".
paulson <lp15@cam.ac.uk>
parents: 55665
diff changeset
   140
    done
6d123f0ae358 Some new proofs. Tidying up, esp to remove "apply rule".
paulson <lp15@cam.ac.uk>
parents: 55665
diff changeset
   141
qed
6d123f0ae358 Some new proofs. Tidying up, esp to remove "apply rule".
paulson <lp15@cam.ac.uk>
parents: 55665
diff changeset
   142
6d123f0ae358 Some new proofs. Tidying up, esp to remove "apply rule".
paulson <lp15@cam.ac.uk>
parents: 55665
diff changeset
   143
lemma DERIV_caratheodory_within:
61104
3c2d4636cebc new lemmas about vector_derivative, complex numbers, paths, etc.
paulson
parents: 61076
diff changeset
   144
  "(f has_field_derivative l) (at x within s) \<longleftrightarrow>
55970
6d123f0ae358 Some new proofs. Tidying up, esp to remove "apply rule".
paulson <lp15@cam.ac.uk>
parents: 55665
diff changeset
   145
   (\<exists>g. (\<forall>z. f z - f x = g z * (z - x)) \<and> continuous (at x within s) g \<and> g x = l)"
6d123f0ae358 Some new proofs. Tidying up, esp to remove "apply rule".
paulson <lp15@cam.ac.uk>
parents: 55665
diff changeset
   146
      (is "?lhs = ?rhs")
6d123f0ae358 Some new proofs. Tidying up, esp to remove "apply rule".
paulson <lp15@cam.ac.uk>
parents: 55665
diff changeset
   147
proof
56181
2aa0b19e74f3 unify syntax for has_derivative and differentiable
hoelzl
parents: 56151
diff changeset
   148
  assume ?lhs
55970
6d123f0ae358 Some new proofs. Tidying up, esp to remove "apply rule".
paulson <lp15@cam.ac.uk>
parents: 55665
diff changeset
   149
  show ?rhs
6d123f0ae358 Some new proofs. Tidying up, esp to remove "apply rule".
paulson <lp15@cam.ac.uk>
parents: 55665
diff changeset
   150
  proof (intro exI conjI)
6d123f0ae358 Some new proofs. Tidying up, esp to remove "apply rule".
paulson <lp15@cam.ac.uk>
parents: 55665
diff changeset
   151
    let ?g = "(%z. if z = x then l else (f z - f x) / (z-x))"
6d123f0ae358 Some new proofs. Tidying up, esp to remove "apply rule".
paulson <lp15@cam.ac.uk>
parents: 55665
diff changeset
   152
    show "\<forall>z. f z - f x = ?g z * (z-x)" by simp
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   153
    show "continuous (at x within s) ?g" using \<open>?lhs\<close>
55970
6d123f0ae358 Some new proofs. Tidying up, esp to remove "apply rule".
paulson <lp15@cam.ac.uk>
parents: 55665
diff changeset
   154
      by (auto simp add: continuous_within DERIV_within_iff cong: Lim_cong_within)
6d123f0ae358 Some new proofs. Tidying up, esp to remove "apply rule".
paulson <lp15@cam.ac.uk>
parents: 55665
diff changeset
   155
    show "?g x = l" by simp
6d123f0ae358 Some new proofs. Tidying up, esp to remove "apply rule".
paulson <lp15@cam.ac.uk>
parents: 55665
diff changeset
   156
  qed
6d123f0ae358 Some new proofs. Tidying up, esp to remove "apply rule".
paulson <lp15@cam.ac.uk>
parents: 55665
diff changeset
   157
next
6d123f0ae358 Some new proofs. Tidying up, esp to remove "apply rule".
paulson <lp15@cam.ac.uk>
parents: 55665
diff changeset
   158
  assume ?rhs
6d123f0ae358 Some new proofs. Tidying up, esp to remove "apply rule".
paulson <lp15@cam.ac.uk>
parents: 55665
diff changeset
   159
  then obtain g where
6d123f0ae358 Some new proofs. Tidying up, esp to remove "apply rule".
paulson <lp15@cam.ac.uk>
parents: 55665
diff changeset
   160
    "(\<forall>z. f z - f x = g z * (z-x))" and "continuous (at x within s) g" and "g x = l" by blast
56181
2aa0b19e74f3 unify syntax for has_derivative and differentiable
hoelzl
parents: 56151
diff changeset
   161
  thus ?lhs
55970
6d123f0ae358 Some new proofs. Tidying up, esp to remove "apply rule".
paulson <lp15@cam.ac.uk>
parents: 55665
diff changeset
   162
    by (auto simp add: continuous_within DERIV_within_iff cong: Lim_cong_within)
6d123f0ae358 Some new proofs. Tidying up, esp to remove "apply rule".
paulson <lp15@cam.ac.uk>
parents: 55665
diff changeset
   163
qed
6d123f0ae358 Some new proofs. Tidying up, esp to remove "apply rule".
paulson <lp15@cam.ac.uk>
parents: 55665
diff changeset
   164
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   165
subsubsection \<open>Limit transformation for derivatives\<close>
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   166
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   167
lemma has_derivative_transform_within:
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   168
  assumes "0 < d"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   169
    and "x \<in> s"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   170
    and "\<forall>x'\<in>s. dist x' x < d \<longrightarrow> f x' = g x'"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   171
    and "(f has_derivative f') (at x within s)"
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   172
  shows "(g has_derivative f') (at x within s)"
55970
6d123f0ae358 Some new proofs. Tidying up, esp to remove "apply rule".
paulson <lp15@cam.ac.uk>
parents: 55665
diff changeset
   173
  using assms
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   174
  unfolding has_derivative_within
55970
6d123f0ae358 Some new proofs. Tidying up, esp to remove "apply rule".
paulson <lp15@cam.ac.uk>
parents: 55665
diff changeset
   175
  apply clarify
6d123f0ae358 Some new proofs. Tidying up, esp to remove "apply rule".
paulson <lp15@cam.ac.uk>
parents: 55665
diff changeset
   176
  apply (rule Lim_transform_within, auto)
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   177
  done
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   178
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   179
lemma has_derivative_transform_at:
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   180
  assumes "0 < d"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   181
    and "\<forall>x'. dist x' x < d \<longrightarrow> f x' = g x'"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   182
    and "(f has_derivative f') (at x)"
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   183
  shows "(g has_derivative f') (at x)"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   184
  using has_derivative_transform_within [of d x UNIV f g f'] assms
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   185
  by simp
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   186
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   187
lemma has_derivative_transform_within_open:
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   188
  assumes "open s"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   189
    and "x \<in> s"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   190
    and "\<forall>y\<in>s. f y = g y"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   191
    and "(f has_derivative f') (at x)"
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   192
  shows "(g has_derivative f') (at x)"
55970
6d123f0ae358 Some new proofs. Tidying up, esp to remove "apply rule".
paulson <lp15@cam.ac.uk>
parents: 55665
diff changeset
   193
  using assms
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   194
  unfolding has_derivative_at
55970
6d123f0ae358 Some new proofs. Tidying up, esp to remove "apply rule".
paulson <lp15@cam.ac.uk>
parents: 55665
diff changeset
   195
  apply clarify
6d123f0ae358 Some new proofs. Tidying up, esp to remove "apply rule".
paulson <lp15@cam.ac.uk>
parents: 55665
diff changeset
   196
  apply (rule Lim_transform_within_open[OF assms(1,2)], auto)
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   197
  done
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   198
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   199
subsection \<open>Differentiability\<close>
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   200
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   201
definition
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   202
  differentiable_on :: "('a::real_normed_vector \<Rightarrow> 'b::real_normed_vector) \<Rightarrow> 'a set \<Rightarrow> bool"
56182
528fae0816ea update syntax of has_*derivative to infix 50; fixed proofs
hoelzl
parents: 56181
diff changeset
   203
    (infix "differentiable'_on" 50)
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   204
  where "f differentiable_on s \<longleftrightarrow> (\<forall>x\<in>s. f differentiable (at x within s))"
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   205
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   206
lemma differentiableI: "(f has_derivative f') net \<Longrightarrow> f differentiable net"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   207
  unfolding differentiable_def
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   208
  by auto
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   209
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   210
lemma differentiable_at_withinI: "f differentiable (at x) \<Longrightarrow> f differentiable (at x within s)"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   211
  unfolding differentiable_def
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   212
  using has_derivative_at_within
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   213
  by blast
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   214
61104
3c2d4636cebc new lemmas about vector_derivative, complex numbers, paths, etc.
paulson
parents: 61076
diff changeset
   215
lemma differentiable_at_imp_differentiable_on:
3c2d4636cebc new lemmas about vector_derivative, complex numbers, paths, etc.
paulson
parents: 61076
diff changeset
   216
  "(\<And>x. x \<in> s \<Longrightarrow> f differentiable at x) \<Longrightarrow> f differentiable_on s"
3c2d4636cebc new lemmas about vector_derivative, complex numbers, paths, etc.
paulson
parents: 61076
diff changeset
   217
  by (metis differentiable_at_withinI differentiable_on_def)
3c2d4636cebc new lemmas about vector_derivative, complex numbers, paths, etc.
paulson
parents: 61076
diff changeset
   218
3c2d4636cebc new lemmas about vector_derivative, complex numbers, paths, etc.
paulson
parents: 61076
diff changeset
   219
corollary differentiable_iff_scaleR:
3c2d4636cebc new lemmas about vector_derivative, complex numbers, paths, etc.
paulson
parents: 61076
diff changeset
   220
  fixes f :: "real \<Rightarrow> 'a::real_normed_vector"
3c2d4636cebc new lemmas about vector_derivative, complex numbers, paths, etc.
paulson
parents: 61076
diff changeset
   221
  shows "f differentiable F \<longleftrightarrow> (\<exists>d. (f has_derivative (\<lambda>x. x *\<^sub>R d)) F)"
3c2d4636cebc new lemmas about vector_derivative, complex numbers, paths, etc.
paulson
parents: 61076
diff changeset
   222
  by (auto simp: differentiable_def dest: has_derivative_linear linear_imp_scaleR)
3c2d4636cebc new lemmas about vector_derivative, complex numbers, paths, etc.
paulson
parents: 61076
diff changeset
   223
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
   224
lemma differentiable_within_open: (* TODO: delete *)
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   225
  assumes "a \<in> s"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   226
    and "open s"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   227
  shows "f differentiable (at a within s) \<longleftrightarrow> f differentiable (at a)"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   228
  using assms
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   229
  by (simp only: at_within_interior interior_open)
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   230
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
   231
lemma differentiable_on_eq_differentiable_at:
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   232
  "open s \<Longrightarrow> f differentiable_on s \<longleftrightarrow> (\<forall>x\<in>s. f differentiable at x)"
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
   233
  unfolding differentiable_on_def
51641
cd05e9fcc63d remove the within-filter, replace "at" by "at _ within UNIV" (This allows to remove a couple of redundant lemmas)
hoelzl
parents: 51478
diff changeset
   234
  by (metis at_within_interior interior_open)
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   235
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   236
lemma differentiable_transform_within:
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   237
  assumes "0 < d"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   238
    and "x \<in> s"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   239
    and "\<forall>x'\<in>s. dist x' x < d \<longrightarrow> f x' = g x'"
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
   240
  assumes "f differentiable (at x within s)"
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   241
  shows "g differentiable (at x within s)"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   242
  using assms(4)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   243
  unfolding differentiable_def
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
   244
  by (auto intro!: has_derivative_transform_within[OF assms(1-3)])
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   245
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   246
lemma differentiable_transform_at:
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   247
  assumes "0 < d"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   248
    and "\<forall>x'. dist x' x < d \<longrightarrow> f x' = g x'"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   249
    and "f differentiable at x"
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   250
  shows "g differentiable at x"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   251
  using assms(3)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   252
  unfolding differentiable_def
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   253
  using has_derivative_transform_at[OF assms(1-2)]
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   254
  by auto
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   255
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   256
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   257
subsection \<open>Frechet derivative and Jacobian matrix\<close>
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   258
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   259
definition "frechet_derivative f net = (SOME f'. (f has_derivative f') net)"
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   260
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   261
lemma frechet_derivative_works:
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   262
  "f differentiable net \<longleftrightarrow> (f has_derivative (frechet_derivative f net)) net"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   263
  unfolding frechet_derivative_def differentiable_def
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   264
  unfolding some_eq_ex[of "\<lambda> f' . (f has_derivative f') net"] ..
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   265
56181
2aa0b19e74f3 unify syntax for has_derivative and differentiable
hoelzl
parents: 56151
diff changeset
   266
lemma linear_frechet_derivative: "f differentiable net \<Longrightarrow> linear (frechet_derivative f net)"
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
   267
  unfolding frechet_derivative_works has_derivative_def
56369
2704ca85be98 moved generic theorems from Complex_Analysis_Basic; fixed some theorem names
hoelzl
parents: 56332
diff changeset
   268
  by (auto intro: bounded_linear.linear)
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   269
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   270
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   271
subsection \<open>Differentiability implies continuity\<close>
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   272
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
   273
lemma differentiable_imp_continuous_within:
51642
400ec5ae7f8f move FrechetDeriv from the Library to HOL/Deriv; base DERIV on FDERIV and both derivatives allow a restricted support set; FDERIV is now an abbreviation of has_derivative
hoelzl
parents: 51641
diff changeset
   274
  "f differentiable (at x within s) \<Longrightarrow> continuous (at x within s) f"
56181
2aa0b19e74f3 unify syntax for has_derivative and differentiable
hoelzl
parents: 56151
diff changeset
   275
  by (auto simp: differentiable_def intro: has_derivative_continuous)
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   276
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
   277
lemma differentiable_imp_continuous_on:
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
   278
  "f differentiable_on s \<Longrightarrow> continuous_on s f"
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   279
  unfolding differentiable_on_def continuous_on_eq_continuous_within
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   280
  using differentiable_imp_continuous_within by blast
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   281
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
   282
lemma differentiable_on_subset:
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
   283
  "f differentiable_on t \<Longrightarrow> s \<subseteq> t \<Longrightarrow> f differentiable_on s"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   284
  unfolding differentiable_on_def
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   285
  using differentiable_within_subset
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   286
  by blast
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   287
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   288
lemma differentiable_on_empty: "f differentiable_on {}"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   289
  unfolding differentiable_on_def
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   290
  by auto
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   291
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   292
text \<open>Results about neighborhoods filter.\<close>
56151
41f9d22a9fa4 add lemmas about nhds filter; tuned proof
huffman
parents: 56150
diff changeset
   293
41f9d22a9fa4 add lemmas about nhds filter; tuned proof
huffman
parents: 56150
diff changeset
   294
lemma eventually_nhds_metric_le:
41f9d22a9fa4 add lemmas about nhds filter; tuned proof
huffman
parents: 56150
diff changeset
   295
  "eventually P (nhds a) = (\<exists>d>0. \<forall>x. dist x a \<le> d \<longrightarrow> P x)"
41f9d22a9fa4 add lemmas about nhds filter; tuned proof
huffman
parents: 56150
diff changeset
   296
  unfolding eventually_nhds_metric by (safe, rule_tac x="d / 2" in exI, auto)
41f9d22a9fa4 add lemmas about nhds filter; tuned proof
huffman
parents: 56150
diff changeset
   297
41f9d22a9fa4 add lemmas about nhds filter; tuned proof
huffman
parents: 56150
diff changeset
   298
lemma le_nhds: "F \<le> nhds a \<longleftrightarrow> (\<forall>S. open S \<and> a \<in> S \<longrightarrow> eventually (\<lambda>x. x \<in> S) F)"
61810
3c5040d5694a sorted out eventually_mono
paulson <lp15@cam.ac.uk>
parents: 61808
diff changeset
   299
  unfolding le_filter_def eventually_nhds by (fast elim: eventually_mono)
56151
41f9d22a9fa4 add lemmas about nhds filter; tuned proof
huffman
parents: 56150
diff changeset
   300
41f9d22a9fa4 add lemmas about nhds filter; tuned proof
huffman
parents: 56150
diff changeset
   301
lemma le_nhds_metric: "F \<le> nhds a \<longleftrightarrow> (\<forall>e>0. eventually (\<lambda>x. dist x a < e) F)"
61810
3c5040d5694a sorted out eventually_mono
paulson <lp15@cam.ac.uk>
parents: 61808
diff changeset
   302
  unfolding le_filter_def eventually_nhds_metric by (fast elim: eventually_mono)
56151
41f9d22a9fa4 add lemmas about nhds filter; tuned proof
huffman
parents: 56150
diff changeset
   303
41f9d22a9fa4 add lemmas about nhds filter; tuned proof
huffman
parents: 56150
diff changeset
   304
lemma le_nhds_metric_le: "F \<le> nhds a \<longleftrightarrow> (\<forall>e>0. eventually (\<lambda>x. dist x a \<le> e) F)"
61810
3c5040d5694a sorted out eventually_mono
paulson <lp15@cam.ac.uk>
parents: 61808
diff changeset
   305
  unfolding le_filter_def eventually_nhds_metric_le by (fast elim: eventually_mono)
56151
41f9d22a9fa4 add lemmas about nhds filter; tuned proof
huffman
parents: 56150
diff changeset
   306
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   307
text \<open>Several results are easier using a "multiplied-out" variant.
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   308
(I got this idea from Dieudonne's proof of the chain rule).\<close>
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   309
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   310
lemma has_derivative_within_alt:
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   311
  "(f has_derivative f') (at x within s) \<longleftrightarrow> bounded_linear f' \<and>
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   312
    (\<forall>e>0. \<exists>d>0. \<forall>y\<in>s. norm(y - x) < d \<longrightarrow> norm (f y - f x - f' (y - x)) \<le> e * norm (y - x))"
56151
41f9d22a9fa4 add lemmas about nhds filter; tuned proof
huffman
parents: 56150
diff changeset
   313
  unfolding has_derivative_within filterlim_def le_nhds_metric_le eventually_filtermap
59815
cce82e360c2f explicit commutative additive inverse operation;
haftmann
parents: 59558
diff changeset
   314
    eventually_at dist_norm diff_diff_eq
56369
2704ca85be98 moved generic theorems from Complex_Analysis_Basic; fixed some theorem names
hoelzl
parents: 56332
diff changeset
   315
  by (force simp add: linear_0 bounded_linear.linear pos_divide_le_eq)
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   316
56320
e84c12d4a886 tuned proofs
huffman
parents: 56271
diff changeset
   317
lemma has_derivative_within_alt2:
e84c12d4a886 tuned proofs
huffman
parents: 56271
diff changeset
   318
  "(f has_derivative f') (at x within s) \<longleftrightarrow> bounded_linear f' \<and>
e84c12d4a886 tuned proofs
huffman
parents: 56271
diff changeset
   319
    (\<forall>e>0. eventually (\<lambda>y. norm (f y - f x - f' (y - x)) \<le> e * norm (y - x)) (at x within s))"
e84c12d4a886 tuned proofs
huffman
parents: 56271
diff changeset
   320
  unfolding has_derivative_within filterlim_def le_nhds_metric_le eventually_filtermap
59815
cce82e360c2f explicit commutative additive inverse operation;
haftmann
parents: 59558
diff changeset
   321
    eventually_at dist_norm diff_diff_eq
56369
2704ca85be98 moved generic theorems from Complex_Analysis_Basic; fixed some theorem names
hoelzl
parents: 56332
diff changeset
   322
  by (force simp add: linear_0 bounded_linear.linear pos_divide_le_eq)
56320
e84c12d4a886 tuned proofs
huffman
parents: 56271
diff changeset
   323
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   324
lemma has_derivative_at_alt:
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   325
  "(f has_derivative f') (at x) \<longleftrightarrow>
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   326
    bounded_linear f' \<and>
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   327
    (\<forall>e>0. \<exists>d>0. \<forall>y. norm(y - x) < d \<longrightarrow> norm (f y - f x - f'(y - x)) \<le> e * norm (y - x))"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   328
  using has_derivative_within_alt[where s=UNIV]
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   329
  by simp
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   330
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   331
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   332
subsection \<open>The chain rule\<close>
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   333
56381
0556204bc230 merged DERIV_intros, has_derivative_intros into derivative_intros
hoelzl
parents: 56371
diff changeset
   334
lemma diff_chain_within[derivative_intros]:
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
   335
  assumes "(f has_derivative f') (at x within s)"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   336
    and "(g has_derivative g') (at (f x) within (f ` s))"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   337
  shows "((g \<circ> f) has_derivative (g' \<circ> f'))(at x within s)"
56181
2aa0b19e74f3 unify syntax for has_derivative and differentiable
hoelzl
parents: 56151
diff changeset
   338
  using has_derivative_in_compose[OF assms]
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   339
  by (simp add: comp_def)
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   340
56381
0556204bc230 merged DERIV_intros, has_derivative_intros into derivative_intros
hoelzl
parents: 56371
diff changeset
   341
lemma diff_chain_at[derivative_intros]:
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   342
  "(f has_derivative f') (at x) \<Longrightarrow>
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   343
    (g has_derivative g') (at (f x)) \<Longrightarrow> ((g \<circ> f) has_derivative (g' \<circ> f')) (at x)"
56181
2aa0b19e74f3 unify syntax for has_derivative and differentiable
hoelzl
parents: 56151
diff changeset
   344
  using has_derivative_compose[of f f' x UNIV g g']
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   345
  by (simp add: comp_def)
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   346
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   347
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   348
subsection \<open>Composition rules stated just for differentiability\<close>
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   349
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   350
lemma differentiable_chain_at:
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   351
  "f differentiable (at x) \<Longrightarrow>
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   352
    g differentiable (at (f x)) \<Longrightarrow> (g \<circ> f) differentiable (at x)"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   353
  unfolding differentiable_def
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   354
  by (meson diff_chain_at)
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   355
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   356
lemma differentiable_chain_within:
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   357
  "f differentiable (at x within s) \<Longrightarrow>
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   358
    g differentiable (at(f x) within (f ` s)) \<Longrightarrow> (g \<circ> f) differentiable (at x within s)"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   359
  unfolding differentiable_def
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   360
  by (meson diff_chain_within)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   361
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   362
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   363
subsection \<open>Uniqueness of derivative\<close>
37730
1a24950dae33 generalize some lemmas about derivatives
huffman
parents: 37650
diff changeset
   364
56369
2704ca85be98 moved generic theorems from Complex_Analysis_Basic; fixed some theorem names
hoelzl
parents: 56332
diff changeset
   365
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   366
text \<open>
37730
1a24950dae33 generalize some lemmas about derivatives
huffman
parents: 37650
diff changeset
   367
 The general result is a bit messy because we need approachability of the
1a24950dae33 generalize some lemmas about derivatives
huffman
parents: 37650
diff changeset
   368
 limit point from any direction. But OK for nontrivial intervals etc.
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   369
\<close>
51363
d4d00c804645 changed has_derivative_intros into a named theorems collection
hoelzl
parents: 50939
diff changeset
   370
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
   371
lemma frechet_derivative_unique_within:
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
   372
  fixes f :: "'a::euclidean_space \<Rightarrow> 'b::real_normed_vector"
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
   373
  assumes "(f has_derivative f') (at x within s)"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   374
    and "(f has_derivative f'') (at x within s)"
61945
1135b8de26c3 more symbols;
wenzelm
parents: 61915
diff changeset
   375
    and "\<forall>i\<in>Basis. \<forall>e>0. \<exists>d. 0 < \<bar>d\<bar> \<and> \<bar>d\<bar> < e \<and> (x + d *\<^sub>R i) \<in> s"
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
   376
  shows "f' = f''"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   377
proof -
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   378
  note as = assms(1,2)[unfolded has_derivative_def]
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
   379
  then interpret f': bounded_linear f' by auto
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
   380
  from as interpret f'': bounded_linear f'' by auto
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
   381
  have "x islimpt s" unfolding islimpt_approachable
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   382
  proof (rule, rule)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   383
    fix e :: real
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   384
    assume "e > 0"
55665
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
   385
    obtain d where "0 < \<bar>d\<bar>" and "\<bar>d\<bar> < e" and "x + d *\<^sub>R (SOME i. i \<in> Basis) \<in> s"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   386
      using assms(3) SOME_Basis \<open>e>0\<close> by blast
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   387
    then show "\<exists>x'\<in>s. x' \<noteq> x \<and> dist x' x < e"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   388
      apply (rule_tac x="x + d *\<^sub>R (SOME i. i \<in> Basis)" in bexI)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   389
      unfolding dist_norm
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   390
      apply (auto simp: SOME_Basis nonzero_Basis)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   391
      done
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
   392
  qed
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   393
  then have *: "netlimit (at x within s) = x"
55970
6d123f0ae358 Some new proofs. Tidying up, esp to remove "apply rule".
paulson <lp15@cam.ac.uk>
parents: 55665
diff changeset
   394
    apply (auto intro!: netlimit_within)
6d123f0ae358 Some new proofs. Tidying up, esp to remove "apply rule".
paulson <lp15@cam.ac.uk>
parents: 55665
diff changeset
   395
    by (metis trivial_limit_within)
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   396
  show ?thesis
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   397
    apply (rule linear_eq_stdbasis)
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
   398
    unfolding linear_conv_bounded_linear
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   399
    apply (rule as(1,2)[THEN conjunct1])+
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   400
  proof (rule, rule ccontr)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   401
    fix i :: 'a
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   402
    assume i: "i \<in> Basis"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   403
    def e \<equiv> "norm (f' i - f'' i)"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50418
diff changeset
   404
    assume "f' i \<noteq> f'' i"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   405
    then have "e > 0"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   406
      unfolding e_def by auto
55665
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
   407
    obtain d where d:
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
   408
      "0 < d"
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
   409
      "(\<And>xa. xa\<in>s \<longrightarrow> 0 < dist xa x \<and> dist xa x < d \<longrightarrow>
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
   410
          dist ((f xa - f x - f' (xa - x)) /\<^sub>R norm (xa - x) -
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
   411
              (f xa - f x - f'' (xa - x)) /\<^sub>R norm (xa - x)) (0 - 0) < e)"
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
   412
      using tendsto_diff [OF as(1,2)[THEN conjunct2]]
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
   413
      unfolding * Lim_within
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   414
      using \<open>e>0\<close> by blast
55665
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
   415
    obtain c where c: "0 < \<bar>c\<bar>" "\<bar>c\<bar> < d \<and> x + c *\<^sub>R i \<in> s"
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
   416
      using assms(3) i d(1) by blast
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   417
    have *: "norm (- ((1 / \<bar>c\<bar>) *\<^sub>R f' (c *\<^sub>R i)) + (1 / \<bar>c\<bar>) *\<^sub>R f'' (c *\<^sub>R i)) =
61945
1135b8de26c3 more symbols;
wenzelm
parents: 61915
diff changeset
   418
        norm ((1 / \<bar>c\<bar>) *\<^sub>R (- (f' (c *\<^sub>R i)) + f'' (c *\<^sub>R i)))"
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   419
      unfolding scaleR_right_distrib by auto
61945
1135b8de26c3 more symbols;
wenzelm
parents: 61915
diff changeset
   420
    also have "\<dots> = norm ((1 / \<bar>c\<bar>) *\<^sub>R (c *\<^sub>R (- (f' i) + f'' i)))"
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
   421
      unfolding f'.scaleR f''.scaleR
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   422
      unfolding scaleR_right_distrib scaleR_minus_right
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   423
      by auto
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   424
    also have "\<dots> = e"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   425
      unfolding e_def
55665
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
   426
      using c(1)
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50418
diff changeset
   427
      using norm_minus_cancel[of "f' i - f'' i"]
54230
b1d955791529 more simplification rules on unary and binary minus
haftmann
parents: 53799
diff changeset
   428
      by auto
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   429
    finally show False
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   430
      using c
55665
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
   431
      using d(2)[of "x + c *\<^sub>R i"]
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
   432
      unfolding dist_norm
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
   433
      unfolding f'.scaleR f''.scaleR f'.add f''.add f'.diff f''.diff
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
   434
        scaleR_scaleR scaleR_right_diff_distrib scaleR_right_distrib
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   435
      using i
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   436
      by (auto simp: inverse_eq_divide)
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
   437
  qed
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
   438
qed
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   439
37730
1a24950dae33 generalize some lemmas about derivatives
huffman
parents: 37650
diff changeset
   440
lemma frechet_derivative_unique_at:
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   441
  "(f has_derivative f') (at x) \<Longrightarrow> (f has_derivative f'') (at x) \<Longrightarrow> f' = f''"
56181
2aa0b19e74f3 unify syntax for has_derivative and differentiable
hoelzl
parents: 56151
diff changeset
   442
  by (rule has_derivative_unique)
41829
455cbcbba8c2 add name continuous_isCont to unnamed lemma
hoelzl
parents: 40702
diff changeset
   443
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
   444
lemma frechet_derivative_unique_within_closed_interval:
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56183
diff changeset
   445
  fixes f::"'a::euclidean_space \<Rightarrow> 'b::real_normed_vector"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   446
  assumes "\<forall>i\<in>Basis. a\<bullet>i < b\<bullet>i"
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56183
diff changeset
   447
    and "x \<in> cbox a b"
0268784f60da use cbox to relax class constraints
immler
parents: 56183
diff changeset
   448
    and "(f has_derivative f' ) (at x within cbox a b)"
0268784f60da use cbox to relax class constraints
immler
parents: 56183
diff changeset
   449
    and "(f has_derivative f'') (at x within cbox a b)"
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
   450
  shows "f' = f''"
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
   451
  apply(rule frechet_derivative_unique_within)
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
   452
  apply(rule assms(3,4))+
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   453
proof (rule, rule, rule)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   454
  fix e :: real
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   455
  fix i :: 'a
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   456
  assume "e > 0" and i: "i \<in> Basis"
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56183
diff changeset
   457
  then show "\<exists>d. 0 < \<bar>d\<bar> \<and> \<bar>d\<bar> < e \<and> x + d *\<^sub>R i \<in> cbox a b"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   458
  proof (cases "x\<bullet>i = a\<bullet>i")
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   459
    case True
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   460
    then show ?thesis
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   461
      apply (rule_tac x="(min (b\<bullet>i - a\<bullet>i)  e) / 2" in exI)
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   462
      using assms(1)[THEN bspec[where x=i]] and \<open>e>0\<close> and assms(2)
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56183
diff changeset
   463
      unfolding mem_box
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   464
      using i
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   465
      apply (auto simp add: field_simps inner_simps inner_Basis)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   466
      done
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   467
  next
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56183
diff changeset
   468
    note * = assms(2)[unfolded mem_box, THEN bspec, OF i]
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   469
    case False
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   470
    moreover have "a \<bullet> i < x \<bullet> i"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   471
      using False * by auto
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
   472
    moreover {
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50418
diff changeset
   473
      have "a \<bullet> i * 2 + min (x \<bullet> i - a \<bullet> i) e \<le> a\<bullet>i *2 + x\<bullet>i - a\<bullet>i"
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
   474
        by auto
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   475
      also have "\<dots> = a\<bullet>i + x\<bullet>i"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   476
        by auto
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   477
      also have "\<dots> \<le> 2 * (x\<bullet>i)"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   478
        using * by auto
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   479
      finally have "a \<bullet> i * 2 + min (x \<bullet> i - a \<bullet> i) e \<le> x \<bullet> i * 2"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   480
        by auto
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
   481
    }
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   482
    moreover have "min (x \<bullet> i - a \<bullet> i) e \<ge> 0"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   483
      using * and \<open>e>0\<close> by auto
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   484
    then have "x \<bullet> i * 2 \<le> b \<bullet> i * 2 + min (x \<bullet> i - a \<bullet> i) e"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   485
      using * by auto
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
   486
    ultimately show ?thesis
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   487
      apply (rule_tac x="- (min (x\<bullet>i - a\<bullet>i) e) / 2" in exI)
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   488
      using assms(1)[THEN bspec, OF i] and \<open>e>0\<close> and assms(2)
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56183
diff changeset
   489
      unfolding mem_box
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   490
      using i
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   491
      apply (auto simp add: field_simps inner_simps inner_Basis)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   492
      done
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
   493
  qed
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
   494
qed
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   495
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
   496
lemma frechet_derivative_unique_within_open_interval:
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56183
diff changeset
   497
  fixes f::"'a::euclidean_space \<Rightarrow> 'b::real_normed_vector"
54775
2d3df8633dad prefer box over greaterThanLessThan on euclidean_space
immler
parents: 54230
diff changeset
   498
  assumes "x \<in> box a b"
2d3df8633dad prefer box over greaterThanLessThan on euclidean_space
immler
parents: 54230
diff changeset
   499
    and "(f has_derivative f' ) (at x within box a b)"
2d3df8633dad prefer box over greaterThanLessThan on euclidean_space
immler
parents: 54230
diff changeset
   500
    and "(f has_derivative f'') (at x within box a b)"
37650
181a70d7b525 generalize some lemmas about derivatives
huffman
parents: 37648
diff changeset
   501
  shows "f' = f''"
181a70d7b525 generalize some lemmas about derivatives
huffman
parents: 37648
diff changeset
   502
proof -
54775
2d3df8633dad prefer box over greaterThanLessThan on euclidean_space
immler
parents: 54230
diff changeset
   503
  from assms(1) have *: "at x within box a b = at x"
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56183
diff changeset
   504
    by (metis at_within_interior interior_open open_box)
37650
181a70d7b525 generalize some lemmas about derivatives
huffman
parents: 37648
diff changeset
   505
  from assms(2,3) [unfolded *] show "f' = f''"
181a70d7b525 generalize some lemmas about derivatives
huffman
parents: 37648
diff changeset
   506
    by (rule frechet_derivative_unique_at)
181a70d7b525 generalize some lemmas about derivatives
huffman
parents: 37648
diff changeset
   507
qed
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   508
37730
1a24950dae33 generalize some lemmas about derivatives
huffman
parents: 37650
diff changeset
   509
lemma frechet_derivative_at:
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   510
  "(f has_derivative f') (at x) \<Longrightarrow> f' = frechet_derivative f (at x)"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   511
  apply (rule frechet_derivative_unique_at[of f])
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   512
  apply assumption
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   513
  unfolding frechet_derivative_works[symmetric]
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   514
  using differentiable_def
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   515
  apply auto
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   516
  done
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   517
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56183
diff changeset
   518
lemma frechet_derivative_within_cbox:
0268784f60da use cbox to relax class constraints
immler
parents: 56183
diff changeset
   519
  fixes f :: "'a::euclidean_space \<Rightarrow> 'b::real_normed_vector"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   520
  assumes "\<forall>i\<in>Basis. a\<bullet>i < b\<bullet>i"
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56183
diff changeset
   521
    and "x \<in> cbox a b"
0268784f60da use cbox to relax class constraints
immler
parents: 56183
diff changeset
   522
    and "(f has_derivative f') (at x within cbox a b)"
0268784f60da use cbox to relax class constraints
immler
parents: 56183
diff changeset
   523
  shows "frechet_derivative f (at x within cbox a b) = f'"
55970
6d123f0ae358 Some new proofs. Tidying up, esp to remove "apply rule".
paulson <lp15@cam.ac.uk>
parents: 55665
diff changeset
   524
  using assms
6d123f0ae358 Some new proofs. Tidying up, esp to remove "apply rule".
paulson <lp15@cam.ac.uk>
parents: 55665
diff changeset
   525
  by (metis Derivative.differentiableI frechet_derivative_unique_within_closed_interval frechet_derivative_works)
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   526
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   527
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   528
subsection \<open>The traditional Rolle theorem in one dimension\<close>
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36844
diff changeset
   529
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   530
text \<open>Derivatives of local minima and maxima are zero.\<close>
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   531
56133
304e37faf1ac generalization of differential_zero_maxmin to class real_normed_vector
huffman
parents: 56117
diff changeset
   532
lemma has_derivative_local_min:
304e37faf1ac generalization of differential_zero_maxmin to class real_normed_vector
huffman
parents: 56117
diff changeset
   533
  fixes f :: "'a::real_normed_vector \<Rightarrow> real"
304e37faf1ac generalization of differential_zero_maxmin to class real_normed_vector
huffman
parents: 56117
diff changeset
   534
  assumes deriv: "(f has_derivative f') (at x)"
304e37faf1ac generalization of differential_zero_maxmin to class real_normed_vector
huffman
parents: 56117
diff changeset
   535
  assumes min: "eventually (\<lambda>y. f x \<le> f y) (at x)"
304e37faf1ac generalization of differential_zero_maxmin to class real_normed_vector
huffman
parents: 56117
diff changeset
   536
  shows "f' = (\<lambda>h. 0)"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36844
diff changeset
   537
proof
56133
304e37faf1ac generalization of differential_zero_maxmin to class real_normed_vector
huffman
parents: 56117
diff changeset
   538
  fix h :: 'a
304e37faf1ac generalization of differential_zero_maxmin to class real_normed_vector
huffman
parents: 56117
diff changeset
   539
  interpret f': bounded_linear f'
56182
528fae0816ea update syntax of has_*derivative to infix 50; fixed proofs
hoelzl
parents: 56181
diff changeset
   540
    using deriv by (rule has_derivative_bounded_linear)
56133
304e37faf1ac generalization of differential_zero_maxmin to class real_normed_vector
huffman
parents: 56117
diff changeset
   541
  show "f' h = 0"
304e37faf1ac generalization of differential_zero_maxmin to class real_normed_vector
huffman
parents: 56117
diff changeset
   542
  proof (cases "h = 0")
304e37faf1ac generalization of differential_zero_maxmin to class real_normed_vector
huffman
parents: 56117
diff changeset
   543
    assume "h \<noteq> 0"
304e37faf1ac generalization of differential_zero_maxmin to class real_normed_vector
huffman
parents: 56117
diff changeset
   544
    from min obtain d where d1: "0 < d" and d2: "\<forall>y\<in>ball x d. f x \<le> f y"
304e37faf1ac generalization of differential_zero_maxmin to class real_normed_vector
huffman
parents: 56117
diff changeset
   545
      unfolding eventually_at by (force simp: dist_commute)
304e37faf1ac generalization of differential_zero_maxmin to class real_normed_vector
huffman
parents: 56117
diff changeset
   546
    have "FDERIV (\<lambda>r. x + r *\<^sub>R h) 0 :> (\<lambda>r. r *\<^sub>R h)"
56381
0556204bc230 merged DERIV_intros, has_derivative_intros into derivative_intros
hoelzl
parents: 56371
diff changeset
   547
      by (intro derivative_eq_intros) auto
56133
304e37faf1ac generalization of differential_zero_maxmin to class real_normed_vector
huffman
parents: 56117
diff changeset
   548
    then have "FDERIV (\<lambda>r. f (x + r *\<^sub>R h)) 0 :> (\<lambda>k. f' (k *\<^sub>R h))"
56182
528fae0816ea update syntax of has_*derivative to infix 50; fixed proofs
hoelzl
parents: 56181
diff changeset
   549
      by (rule has_derivative_compose, simp add: deriv)
56133
304e37faf1ac generalization of differential_zero_maxmin to class real_normed_vector
huffman
parents: 56117
diff changeset
   550
    then have "DERIV (\<lambda>r. f (x + r *\<^sub>R h)) 0 :> f' h"
56182
528fae0816ea update syntax of has_*derivative to infix 50; fixed proofs
hoelzl
parents: 56181
diff changeset
   551
      unfolding has_field_derivative_def by (simp add: f'.scaleR mult_commute_abs)
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   552
    moreover have "0 < d / norm h" using d1 and \<open>h \<noteq> 0\<close> by simp
56133
304e37faf1ac generalization of differential_zero_maxmin to class real_normed_vector
huffman
parents: 56117
diff changeset
   553
    moreover have "\<forall>y. \<bar>0 - y\<bar> < d / norm h \<longrightarrow> f (x + 0 *\<^sub>R h) \<le> f (x + y *\<^sub>R h)"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   554
      using \<open>h \<noteq> 0\<close> by (auto simp add: d2 dist_norm pos_less_divide_eq)
56133
304e37faf1ac generalization of differential_zero_maxmin to class real_normed_vector
huffman
parents: 56117
diff changeset
   555
    ultimately show "f' h = 0"
304e37faf1ac generalization of differential_zero_maxmin to class real_normed_vector
huffman
parents: 56117
diff changeset
   556
      by (rule DERIV_local_min)
304e37faf1ac generalization of differential_zero_maxmin to class real_normed_vector
huffman
parents: 56117
diff changeset
   557
  qed (simp add: f'.zero)
304e37faf1ac generalization of differential_zero_maxmin to class real_normed_vector
huffman
parents: 56117
diff changeset
   558
qed
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36844
diff changeset
   559
56133
304e37faf1ac generalization of differential_zero_maxmin to class real_normed_vector
huffman
parents: 56117
diff changeset
   560
lemma has_derivative_local_max:
304e37faf1ac generalization of differential_zero_maxmin to class real_normed_vector
huffman
parents: 56117
diff changeset
   561
  fixes f :: "'a::real_normed_vector \<Rightarrow> real"
304e37faf1ac generalization of differential_zero_maxmin to class real_normed_vector
huffman
parents: 56117
diff changeset
   562
  assumes "(f has_derivative f') (at x)"
304e37faf1ac generalization of differential_zero_maxmin to class real_normed_vector
huffman
parents: 56117
diff changeset
   563
  assumes "eventually (\<lambda>y. f y \<le> f x) (at x)"
304e37faf1ac generalization of differential_zero_maxmin to class real_normed_vector
huffman
parents: 56117
diff changeset
   564
  shows "f' = (\<lambda>h. 0)"
304e37faf1ac generalization of differential_zero_maxmin to class real_normed_vector
huffman
parents: 56117
diff changeset
   565
  using has_derivative_local_min [of "\<lambda>x. - f x" "\<lambda>h. - f' h" "x"]
304e37faf1ac generalization of differential_zero_maxmin to class real_normed_vector
huffman
parents: 56117
diff changeset
   566
  using assms unfolding fun_eq_iff by simp
304e37faf1ac generalization of differential_zero_maxmin to class real_normed_vector
huffman
parents: 56117
diff changeset
   567
304e37faf1ac generalization of differential_zero_maxmin to class real_normed_vector
huffman
parents: 56117
diff changeset
   568
lemma differential_zero_maxmin:
304e37faf1ac generalization of differential_zero_maxmin to class real_normed_vector
huffman
parents: 56117
diff changeset
   569
  fixes f::"'a::real_normed_vector \<Rightarrow> real"
304e37faf1ac generalization of differential_zero_maxmin to class real_normed_vector
huffman
parents: 56117
diff changeset
   570
  assumes "x \<in> s"
304e37faf1ac generalization of differential_zero_maxmin to class real_normed_vector
huffman
parents: 56117
diff changeset
   571
    and "open s"
304e37faf1ac generalization of differential_zero_maxmin to class real_normed_vector
huffman
parents: 56117
diff changeset
   572
    and deriv: "(f has_derivative f') (at x)"
304e37faf1ac generalization of differential_zero_maxmin to class real_normed_vector
huffman
parents: 56117
diff changeset
   573
    and mono: "(\<forall>y\<in>s. f y \<le> f x) \<or> (\<forall>y\<in>s. f x \<le> f y)"
304e37faf1ac generalization of differential_zero_maxmin to class real_normed_vector
huffman
parents: 56117
diff changeset
   574
  shows "f' = (\<lambda>v. 0)"
304e37faf1ac generalization of differential_zero_maxmin to class real_normed_vector
huffman
parents: 56117
diff changeset
   575
  using mono
304e37faf1ac generalization of differential_zero_maxmin to class real_normed_vector
huffman
parents: 56117
diff changeset
   576
proof
304e37faf1ac generalization of differential_zero_maxmin to class real_normed_vector
huffman
parents: 56117
diff changeset
   577
  assume "\<forall>y\<in>s. f y \<le> f x"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   578
  with \<open>x \<in> s\<close> and \<open>open s\<close> have "eventually (\<lambda>y. f y \<le> f x) (at x)"
56133
304e37faf1ac generalization of differential_zero_maxmin to class real_normed_vector
huffman
parents: 56117
diff changeset
   579
    unfolding eventually_at_topological by auto
304e37faf1ac generalization of differential_zero_maxmin to class real_normed_vector
huffman
parents: 56117
diff changeset
   580
  with deriv show ?thesis
304e37faf1ac generalization of differential_zero_maxmin to class real_normed_vector
huffman
parents: 56117
diff changeset
   581
    by (rule has_derivative_local_max)
304e37faf1ac generalization of differential_zero_maxmin to class real_normed_vector
huffman
parents: 56117
diff changeset
   582
next
304e37faf1ac generalization of differential_zero_maxmin to class real_normed_vector
huffman
parents: 56117
diff changeset
   583
  assume "\<forall>y\<in>s. f x \<le> f y"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   584
  with \<open>x \<in> s\<close> and \<open>open s\<close> have "eventually (\<lambda>y. f x \<le> f y) (at x)"
56133
304e37faf1ac generalization of differential_zero_maxmin to class real_normed_vector
huffman
parents: 56117
diff changeset
   585
    unfolding eventually_at_topological by auto
304e37faf1ac generalization of differential_zero_maxmin to class real_normed_vector
huffman
parents: 56117
diff changeset
   586
  with deriv show ?thesis
304e37faf1ac generalization of differential_zero_maxmin to class real_normed_vector
huffman
parents: 56117
diff changeset
   587
    by (rule has_derivative_local_min)
304e37faf1ac generalization of differential_zero_maxmin to class real_normed_vector
huffman
parents: 56117
diff changeset
   588
qed
304e37faf1ac generalization of differential_zero_maxmin to class real_normed_vector
huffman
parents: 56117
diff changeset
   589
304e37faf1ac generalization of differential_zero_maxmin to class real_normed_vector
huffman
parents: 56117
diff changeset
   590
lemma differential_zero_maxmin_component: (* TODO: delete? *)
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36844
diff changeset
   591
  fixes f :: "'a::euclidean_space \<Rightarrow> 'b::euclidean_space"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50418
diff changeset
   592
  assumes k: "k \<in> Basis"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   593
    and ball: "0 < e" "(\<forall>y \<in> ball x e. (f y)\<bullet>k \<le> (f x)\<bullet>k) \<or> (\<forall>y\<in>ball x e. (f x)\<bullet>k \<le> (f y)\<bullet>k)"
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36844
diff changeset
   594
    and diff: "f differentiable (at x)"
50526
899c9c4e4a4c Remove the indexed basis from the definition of euclidean spaces and only use the set of Basis vectors
hoelzl
parents: 50418
diff changeset
   595
  shows "(\<Sum>j\<in>Basis. (frechet_derivative f (at x) j \<bullet> k) *\<^sub>R j) = (0::'a)" (is "?D k = 0")
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36844
diff changeset
   596
proof -
56133
304e37faf1ac generalization of differential_zero_maxmin to class real_normed_vector
huffman
parents: 56117
diff changeset
   597
  let ?f' = "frechet_derivative f (at x)"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   598
  have "x \<in> ball x e" using \<open>0 < e\<close> by simp
56133
304e37faf1ac generalization of differential_zero_maxmin to class real_normed_vector
huffman
parents: 56117
diff changeset
   599
  moreover have "open (ball x e)" by simp
304e37faf1ac generalization of differential_zero_maxmin to class real_normed_vector
huffman
parents: 56117
diff changeset
   600
  moreover have "((\<lambda>x. f x \<bullet> k) has_derivative (\<lambda>h. ?f' h \<bullet> k)) (at x)"
304e37faf1ac generalization of differential_zero_maxmin to class real_normed_vector
huffman
parents: 56117
diff changeset
   601
    using bounded_linear_inner_left diff[unfolded frechet_derivative_works]
56182
528fae0816ea update syntax of has_*derivative to infix 50; fixed proofs
hoelzl
parents: 56181
diff changeset
   602
    by (rule bounded_linear.has_derivative)
56133
304e37faf1ac generalization of differential_zero_maxmin to class real_normed_vector
huffman
parents: 56117
diff changeset
   603
  ultimately have "(\<lambda>h. frechet_derivative f (at x) h \<bullet> k) = (\<lambda>v. 0)"
304e37faf1ac generalization of differential_zero_maxmin to class real_normed_vector
huffman
parents: 56117
diff changeset
   604
    using ball(2) by (rule differential_zero_maxmin)
304e37faf1ac generalization of differential_zero_maxmin to class real_normed_vector
huffman
parents: 56117
diff changeset
   605
  then show ?thesis
304e37faf1ac generalization of differential_zero_maxmin to class real_normed_vector
huffman
parents: 56117
diff changeset
   606
    unfolding fun_eq_iff by simp
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36844
diff changeset
   607
qed
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   608
51642
400ec5ae7f8f move FrechetDeriv from the Library to HOL/Deriv; base DERIV on FDERIV and both derivatives allow a restricted support set; FDERIV is now an abbreviation of has_derivative
hoelzl
parents: 51641
diff changeset
   609
lemma rolle:
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   610
  fixes f :: "real \<Rightarrow> real"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   611
  assumes "a < b"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   612
    and "f a = f b"
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56183
diff changeset
   613
    and "continuous_on {a .. b} f"
0268784f60da use cbox to relax class constraints
immler
parents: 56183
diff changeset
   614
    and "\<forall>x\<in>{a <..< b}. (f has_derivative f' x) (at x)"
0268784f60da use cbox to relax class constraints
immler
parents: 56183
diff changeset
   615
  shows "\<exists>x\<in>{a <..< b}. f' x = (\<lambda>v. 0)"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   616
proof -
54775
2d3df8633dad prefer box over greaterThanLessThan on euclidean_space
immler
parents: 54230
diff changeset
   617
  have "\<exists>x\<in>box a b. (\<forall>y\<in>box a b. f x \<le> f y) \<or> (\<forall>y\<in>box a b. f y \<le> f x)"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   618
  proof -
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   619
    have "(a + b) / 2 \<in> {a .. b}"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   620
      using assms(1) by auto
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56183
diff changeset
   621
    then have *: "{a .. b} \<noteq> {}"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   622
      by auto
55665
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
   623
    obtain d where d:
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56183
diff changeset
   624
        "d \<in>cbox a b"
0268784f60da use cbox to relax class constraints
immler
parents: 56183
diff changeset
   625
        "\<forall>y\<in>cbox a b. f y \<le> f d"
0268784f60da use cbox to relax class constraints
immler
parents: 56183
diff changeset
   626
      using continuous_attains_sup[OF compact_Icc * assms(3)] by auto
55665
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
   627
    obtain c where c:
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56183
diff changeset
   628
        "c \<in> cbox a b"
0268784f60da use cbox to relax class constraints
immler
parents: 56183
diff changeset
   629
        "\<forall>y\<in>cbox a b. f c \<le> f y"
0268784f60da use cbox to relax class constraints
immler
parents: 56183
diff changeset
   630
      using continuous_attains_inf[OF compact_Icc * assms(3)] by auto
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
   631
    show ?thesis
54775
2d3df8633dad prefer box over greaterThanLessThan on euclidean_space
immler
parents: 54230
diff changeset
   632
    proof (cases "d \<in> box a b \<or> c \<in> box a b")
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   633
      case True
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   634
      then show ?thesis
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56183
diff changeset
   635
        by (metis c(2) d(2) box_subset_cbox subset_iff)
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
   636
    next
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
   637
      def e \<equiv> "(a + b) /2"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   638
      case False
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   639
      then have "f d = f c"
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56183
diff changeset
   640
        using d c assms(2) by auto
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   641
      then have "\<And>x. x \<in> {a..b} \<Longrightarrow> f x = f d"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   642
        using c d
55970
6d123f0ae358 Some new proofs. Tidying up, esp to remove "apply rule".
paulson <lp15@cam.ac.uk>
parents: 55665
diff changeset
   643
        by force
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   644
      then show ?thesis
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   645
        apply (rule_tac x=e in bexI)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   646
        unfolding e_def
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   647
        using assms(1)
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56183
diff changeset
   648
        apply auto
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   649
        done
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
   650
    qed
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
   651
  qed
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56183
diff changeset
   652
  then obtain x where x: "x \<in> {a <..< b}" "(\<forall>y\<in>{a <..< b}. f x \<le> f y) \<or> (\<forall>y\<in>{a <..< b}. f y \<le> f x)"
0268784f60da use cbox to relax class constraints
immler
parents: 56183
diff changeset
   653
    by auto
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   654
  then have "f' x = (\<lambda>v. 0)"
54775
2d3df8633dad prefer box over greaterThanLessThan on euclidean_space
immler
parents: 54230
diff changeset
   655
    apply (rule_tac differential_zero_maxmin[of x "box a b" f "f' x"])
55970
6d123f0ae358 Some new proofs. Tidying up, esp to remove "apply rule".
paulson <lp15@cam.ac.uk>
parents: 55665
diff changeset
   656
    using assms
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   657
    apply auto
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   658
    done
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   659
  then show ?thesis
55970
6d123f0ae358 Some new proofs. Tidying up, esp to remove "apply rule".
paulson <lp15@cam.ac.uk>
parents: 55665
diff changeset
   660
    by (metis x(1))
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
   661
qed
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   662
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   663
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   664
subsection \<open>One-dimensional mean value theorem\<close>
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   665
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   666
lemma mvt:
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   667
  fixes f :: "real \<Rightarrow> real"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   668
  assumes "a < b"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   669
    and "continuous_on {a..b} f"
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
   670
  assumes "\<forall>x\<in>{a<..<b}. (f has_derivative (f' x)) (at x)"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   671
  shows "\<exists>x\<in>{a<..<b}. f b - f a = (f' x) (b - a)"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   672
proof -
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56183
diff changeset
   673
  have "\<exists>x\<in>{a <..< b}. (\<lambda>xa. f' x xa - (f b - f a) / (b - a) * xa) = (\<lambda>v. 0)"
51478
270b21f3ae0a move continuous and continuous_on to the HOL image; isCont is an abbreviation for continuous (at x) (isCont is now restricted to a T2 space)
hoelzl
parents: 51363
diff changeset
   674
  proof (intro rolle[OF assms(1), of "\<lambda>x. f x - (f b - f a) / (b - a) * x"] ballI)
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   675
    fix x
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56183
diff changeset
   676
    assume x: "x \<in> {a <..< b}"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   677
    show "((\<lambda>x. f x - (f b - f a) / (b - a) * x) has_derivative
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   678
        (\<lambda>xa. f' x xa - (f b - f a) / (b - a) * xa)) (at x)"
56381
0556204bc230 merged DERIV_intros, has_derivative_intros into derivative_intros
hoelzl
parents: 56371
diff changeset
   679
      by (intro derivative_intros assms(3)[rule_format,OF x])
56371
fb9ae0727548 extend continuous_intros; remove continuous_on_intros and isCont_intros
hoelzl
parents: 56370
diff changeset
   680
  qed (insert assms(1,2), auto intro!: continuous_intros simp: field_simps)
55665
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
   681
  then obtain x where
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56183
diff changeset
   682
    "x \<in> {a <..< b}"
55665
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
   683
    "(\<lambda>xa. f' x xa - (f b - f a) / (b - a) * xa) = (\<lambda>v. 0)" ..
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   684
  then show ?thesis
61762
d50b993b4fb9 Removal of redundant lemmas (diff_less_iff, diff_le_iff) and of the abbreviation Exp. Addition of some new material.
paulson <lp15@cam.ac.uk>
parents: 61649
diff changeset
   685
    by (metis (hide_lams) assms(1) diff_gt_0_iff_gt eq_iff_diff_eq_0
59558
5d9f0ace9af0 got rid of linordered_field_class.sign_simps(41) !
paulson <lp15@cam.ac.uk>
parents: 58877
diff changeset
   686
      zero_less_mult_iff nonzero_mult_divide_cancel_right not_real_square_gt_zero
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56183
diff changeset
   687
      times_divide_eq_left)
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
   688
qed
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   689
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
   690
lemma mvt_simple:
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   691
  fixes f :: "real \<Rightarrow> real"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   692
  assumes "a < b"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   693
    and "\<forall>x\<in>{a..b}. (f has_derivative f' x) (at x within {a..b})"
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   694
  shows "\<exists>x\<in>{a<..<b}. f b - f a = f' x (b - a)"
56264
2a091015a896 tuned proofs
huffman
parents: 56261
diff changeset
   695
proof (rule mvt)
2a091015a896 tuned proofs
huffman
parents: 56261
diff changeset
   696
  have "f differentiable_on {a..b}"
2a091015a896 tuned proofs
huffman
parents: 56261
diff changeset
   697
    using assms(2) unfolding differentiable_on_def differentiable_def by fast
2a091015a896 tuned proofs
huffman
parents: 56261
diff changeset
   698
  then show "continuous_on {a..b} f"
2a091015a896 tuned proofs
huffman
parents: 56261
diff changeset
   699
    by (rule differentiable_imp_continuous_on)
2a091015a896 tuned proofs
huffman
parents: 56261
diff changeset
   700
  show "\<forall>x\<in>{a<..<b}. (f has_derivative f' x) (at x)"
2a091015a896 tuned proofs
huffman
parents: 56261
diff changeset
   701
  proof
2a091015a896 tuned proofs
huffman
parents: 56261
diff changeset
   702
    fix x
2a091015a896 tuned proofs
huffman
parents: 56261
diff changeset
   703
    assume x: "x \<in> {a <..< b}"
2a091015a896 tuned proofs
huffman
parents: 56261
diff changeset
   704
    show "(f has_derivative f' x) (at x)"
2a091015a896 tuned proofs
huffman
parents: 56261
diff changeset
   705
      unfolding at_within_open[OF x open_greaterThanLessThan,symmetric]
2a091015a896 tuned proofs
huffman
parents: 56261
diff changeset
   706
      apply (rule has_derivative_within_subset)
2a091015a896 tuned proofs
huffman
parents: 56261
diff changeset
   707
      apply (rule assms(2)[rule_format])
2a091015a896 tuned proofs
huffman
parents: 56261
diff changeset
   708
      using x
2a091015a896 tuned proofs
huffman
parents: 56261
diff changeset
   709
      apply auto
2a091015a896 tuned proofs
huffman
parents: 56261
diff changeset
   710
      done
2a091015a896 tuned proofs
huffman
parents: 56261
diff changeset
   711
  qed
2a091015a896 tuned proofs
huffman
parents: 56261
diff changeset
   712
qed (rule assms(1))
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   713
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
   714
lemma mvt_very_simple:
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   715
  fixes f :: "real \<Rightarrow> real"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   716
  assumes "a \<le> b"
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56183
diff changeset
   717
    and "\<forall>x\<in>{a .. b}. (f has_derivative f' x) (at x within {a .. b})"
0268784f60da use cbox to relax class constraints
immler
parents: 56183
diff changeset
   718
  shows "\<exists>x\<in>{a .. b}. f b - f a = f' x (b - a)"
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
   719
proof (cases "a = b")
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   720
  interpret bounded_linear "f' b"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   721
    using assms(2) assms(1) by auto
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   722
  case True
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   723
  then show ?thesis
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   724
    apply (rule_tac x=a in bexI)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   725
    using assms(2)[THEN bspec[where x=a]]
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   726
    unfolding has_derivative_def
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   727
    unfolding True
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   728
    using zero
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   729
    apply auto
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   730
    done
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   731
next
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   732
  case False
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   733
  then show ?thesis
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   734
    using mvt_simple[OF _ assms(2)]
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   735
    using assms(1)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   736
    by auto
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
   737
qed
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   738
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   739
text \<open>A nice generalization (see Havin's proof of 5.19 from Rudin's book).\<close>
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   740
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
   741
lemma mvt_general:
56223
7696903b9e61 generalize theory of operator norms to work with class real_normed_vector
huffman
parents: 56217
diff changeset
   742
  fixes f :: "real \<Rightarrow> 'a::real_inner"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   743
  assumes "a < b"
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56183
diff changeset
   744
    and "continuous_on {a .. b} f"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   745
    and "\<forall>x\<in>{a<..<b}. (f has_derivative f'(x)) (at x)"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   746
  shows "\<exists>x\<in>{a<..<b}. norm (f b - f a) \<le> norm (f' x (b - a))"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   747
proof -
56264
2a091015a896 tuned proofs
huffman
parents: 56261
diff changeset
   748
  have "\<exists>x\<in>{a<..<b}. (f b - f a) \<bullet> f b - (f b - f a) \<bullet> f a = (f b - f a) \<bullet> f' x (b - a)"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   749
    apply (rule mvt)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   750
    apply (rule assms(1))
56371
fb9ae0727548 extend continuous_intros; remove continuous_on_intros and isCont_intros
hoelzl
parents: 56370
diff changeset
   751
    apply (intro continuous_intros assms(2))
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   752
    using assms(3)
56264
2a091015a896 tuned proofs
huffman
parents: 56261
diff changeset
   753
    apply (fast intro: has_derivative_inner_right)
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   754
    done
55665
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
   755
  then obtain x where x:
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
   756
    "x \<in> {a<..<b}"
56264
2a091015a896 tuned proofs
huffman
parents: 56261
diff changeset
   757
    "(f b - f a) \<bullet> f b - (f b - f a) \<bullet> f a = (f b - f a) \<bullet> f' x (b - a)" ..
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   758
  show ?thesis
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   759
  proof (cases "f a = f b")
36844
5f9385ecc1a7 Removed usage of normalizating locales.
hoelzl
parents: 36725
diff changeset
   760
    case False
53077
a1b3784f8129 more symbols;
wenzelm
parents: 51733
diff changeset
   761
    have "norm (f b - f a) * norm (f b - f a) = (norm (f b - f a))\<^sup>2"
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
   762
      by (simp add: power2_eq_square)
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   763
    also have "\<dots> = (f b - f a) \<bullet> (f b - f a)"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   764
      unfolding power2_norm_eq_inner ..
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
   765
    also have "\<dots> = (f b - f a) \<bullet> f' x (b - a)"
56264
2a091015a896 tuned proofs
huffman
parents: 56261
diff changeset
   766
      using x(2) by (simp only: inner_diff_right)
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
   767
    also have "\<dots> \<le> norm (f b - f a) * norm (f' x (b - a))"
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
   768
      by (rule norm_cauchy_schwarz)
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   769
    finally show ?thesis
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   770
      using False x(1)
56217
dc429a5b13c4 Some rationalisation of basic lemmas
paulson <lp15@cam.ac.uk>
parents: 56196
diff changeset
   771
      by (auto simp add: mult_left_cancel)
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
   772
  next
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   773
    case True
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   774
    then show ?thesis
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   775
      using assms(1)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   776
      apply (rule_tac x="(a + b) /2" in bexI)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   777
      apply auto
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
   778
      done
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
   779
  qed
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
   780
qed
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   781
60178
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   782
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   783
subsection \<open>More general bound theorems\<close>
60178
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   784
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   785
lemma differentiable_bound_general:
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   786
  fixes f :: "real \<Rightarrow> 'a::real_normed_vector"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   787
  assumes "a < b"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   788
    and f_cont: "continuous_on {a .. b} f"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   789
    and phi_cont: "continuous_on {a .. b} \<phi>"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   790
    and f': "\<And>x. a < x \<Longrightarrow> x < b \<Longrightarrow> (f has_vector_derivative f' x) (at x)"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   791
    and phi': "\<And>x. a < x \<Longrightarrow> x < b \<Longrightarrow> (\<phi> has_vector_derivative \<phi>' x) (at x)"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   792
    and bnd: "\<And>x. a < x \<Longrightarrow> x < b \<Longrightarrow> norm (f' x) \<le> \<phi>' x"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   793
  shows "norm (f b - f a) \<le> \<phi> b - \<phi> a"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   794
proof -
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   795
  {
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   796
    fix x assume x: "a < x" "x < b"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   797
    have "0 \<le> norm (f' x)" by simp
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   798
    also have "\<dots> \<le> \<phi>' x" using x by (auto intro!: bnd)
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   799
    finally have "0 \<le> \<phi>' x" .
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   800
  } note phi'_nonneg = this
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   801
  note f_tendsto = assms(2)[simplified continuous_on_def, rule_format]
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   802
  note phi_tendsto = assms(3)[simplified continuous_on_def, rule_format]
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   803
  {
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   804
    fix e::real assume "e > 0"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   805
    def e2 \<equiv> "e / 2" with \<open>e > 0\<close> have "e2 > 0" by simp
60178
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   806
    let ?le = "\<lambda>x1. norm (f x1 - f a) \<le> \<phi> x1 - \<phi> a + e * (x1 - a) + e"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   807
    def A \<equiv> "{x2. a \<le> x2 \<and> x2 \<le> b \<and> (\<forall>x1\<in>{a ..< x2}. ?le x1)}"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   808
    have A_subset: "A \<subseteq> {a .. b}" by (auto simp: A_def)
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   809
    {
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   810
      fix x2
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   811
      assume a: "a \<le> x2" "x2 \<le> b" and le: "\<forall>x1\<in>{a..<x2}. ?le x1"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   812
      have "?le x2" using \<open>e > 0\<close>
60178
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   813
      proof cases
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   814
        assume "x2 \<noteq> a" with a have "a < x2" by simp
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   815
        have "at x2 within {a <..<x2}\<noteq> bot"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   816
          using \<open>a < x2\<close>
60178
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   817
          by (auto simp: trivial_limit_within islimpt_in_closure)
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   818
        moreover
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   819
        have "((\<lambda>x1. (\<phi> x1 - \<phi> a) + e * (x1 - a) + e) ---> (\<phi> x2 - \<phi> a) + e * (x2 - a) + e) (at x2 within {a <..<x2})"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   820
          "((\<lambda>x1. norm (f x1 - f a)) ---> norm (f x2 - f a)) (at x2 within {a <..<x2})"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   821
          using a
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   822
          by (auto intro!: tendsto_eq_intros f_tendsto phi_tendsto
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   823
            intro: tendsto_within_subset[where S="{a .. b}"])
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   824
        moreover
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   825
        have "eventually (\<lambda>x. x > a) (at x2 within {a <..<x2})"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   826
          by (auto simp: eventually_at_filter)
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   827
        hence "eventually ?le (at x2 within {a <..<x2})"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   828
          unfolding eventually_at_filter
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   829
          by eventually_elim (insert le, auto)
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   830
        ultimately
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   831
        show ?thesis
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   832
          by (rule tendsto_le)
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   833
      qed simp
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   834
    } note le_cont = this
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   835
    have "a \<in> A"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   836
      using assms by (auto simp: A_def)
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   837
    hence [simp]: "A \<noteq> {}" by auto
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   838
    have A_ivl: "\<And>x1 x2. x2 \<in> A \<Longrightarrow> x1 \<in> {a ..x2} \<Longrightarrow> x1 \<in> A"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   839
      by (simp add: A_def)
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   840
    have [simp]: "bdd_above A" by (auto simp: A_def)
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   841
    def y \<equiv> "Sup A"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   842
    have "y \<le> b"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   843
      unfolding y_def
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   844
      by (simp add: cSup_le_iff) (simp add: A_def)
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   845
     have leI: "\<And>x x1. a \<le> x1 \<Longrightarrow> x \<in> A \<Longrightarrow> x1 < x \<Longrightarrow> ?le x1"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   846
       by (auto simp: A_def intro!: le_cont)
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   847
    have y_all_le: "\<forall>x1\<in>{a..<y}. ?le x1"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   848
      by (auto simp: y_def less_cSup_iff leI)
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   849
    have "a \<le> y"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   850
      by (metis \<open>a \<in> A\<close> \<open>bdd_above A\<close> cSup_upper y_def)
60178
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   851
    have "y \<in> A"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   852
      using y_all_le \<open>a \<le> y\<close> \<open>y \<le> b\<close>
60178
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   853
      by (auto simp: A_def)
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   854
    hence "A = {a .. y}"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   855
      using A_subset
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   856
      by (auto simp: subset_iff y_def cSup_upper intro: A_ivl)
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   857
    from le_cont[OF \<open>a \<le> y\<close> \<open>y \<le> b\<close> y_all_le] have le_y: "?le y" .
60178
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   858
    {
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   859
      assume "a \<noteq> y" with \<open>a \<le> y\<close> have "a < y" by simp
60178
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   860
      have "y = b"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   861
      proof (rule ccontr)
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   862
        assume "y \<noteq> b"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   863
        hence "y < b" using \<open>y \<le> b\<close> by simp
60178
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   864
        let ?F = "at y within {y..<b}"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   865
        from f' phi'
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   866
        have "(f has_vector_derivative f' y) ?F"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   867
          and "(\<phi> has_vector_derivative \<phi>' y) ?F"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   868
          using \<open>a < y\<close> \<open>y < b\<close>
60178
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   869
          by (auto simp add: at_within_open[of _ "{a<..<b}"] has_vector_derivative_def
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   870
            intro!: has_derivative_subset[where s="{a<..<b}" and t="{y..<b}"])
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   871
        hence "\<forall>\<^sub>F x1 in ?F. norm (f x1 - f y - (x1 - y) *\<^sub>R f' y) \<le> e2 * \<bar>x1 - y\<bar>"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   872
            "\<forall>\<^sub>F x1 in ?F. norm (\<phi> x1 - \<phi> y - (x1 - y) *\<^sub>R \<phi>' y) \<le> e2 * \<bar>x1 - y\<bar>"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   873
          using \<open>e2 > 0\<close>
60178
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   874
          by (auto simp: has_derivative_within_alt2 has_vector_derivative_def)
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   875
        moreover
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   876
        have "\<forall>\<^sub>F x1 in ?F. y \<le> x1" "\<forall>\<^sub>F x1 in ?F. x1 < b"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   877
          by (auto simp: eventually_at_filter)
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   878
        ultimately
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   879
        have "\<forall>\<^sub>F x1 in ?F. norm (f x1 - f y) \<le> (\<phi> x1 - \<phi> y) + e * \<bar>x1 - y\<bar>"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   880
          (is "\<forall>\<^sub>F x1 in ?F. ?le' x1")
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   881
        proof eventually_elim
60589
b5622eef7176 do not expose goal parameters;
wenzelm
parents: 60420
diff changeset
   882
          case (elim x1)
60178
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   883
          from norm_triangle_ineq2[THEN order_trans, OF elim(1)]
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   884
          have "norm (f x1 - f y) \<le> norm (f' y) * \<bar>x1 - y\<bar> + e2 * \<bar>x1 - y\<bar>"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   885
            by (simp add: ac_simps)
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   886
          also have "norm (f' y) \<le> \<phi>' y" using bnd \<open>a < y\<close> \<open>y < b\<close> by simp
60178
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   887
          also
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   888
          from elim have "\<phi>' y * \<bar>x1 - y\<bar> \<le> \<phi> x1 - \<phi> y + e2 * \<bar>x1 - y\<bar>"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   889
            by (simp add: ac_simps)
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   890
          finally
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   891
          have "norm (f x1 - f y) \<le> \<phi> x1 - \<phi> y + e2 * \<bar>x1 - y\<bar> + e2 * \<bar>x1 - y\<bar>"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   892
            by (auto simp: mult_right_mono)
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   893
          thus ?case by (simp add: e2_def)
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   894
        qed
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   895
        moreover have "?le' y" by simp
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   896
        ultimately obtain S
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   897
        where S: "open S" "y \<in> S" "\<And>x. x\<in>S \<Longrightarrow> x \<in> {y..<b} \<Longrightarrow> ?le' x"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   898
          unfolding eventually_at_topological
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   899
          by metis
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   900
        from \<open>open S\<close> obtain d where d: "\<And>x. dist x y < d \<Longrightarrow> x \<in> S" "d > 0"
60178
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   901
          by (force simp: dist_commute open_real_def ball_def
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   902
            dest!: bspec[OF _ \<open>y \<in> S\<close>])
60178
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   903
        def d' \<equiv> "min ((y + b)/2) (y + (d/2))"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   904
        have "d' \<in> A"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   905
          unfolding A_def
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   906
        proof safe
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   907
          show "a \<le> d'" using \<open>a < y\<close> \<open>0 < d\<close> \<open>y < b\<close> by (simp add: d'_def)
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   908
          show "d' \<le> b" using \<open>y < b\<close> by (simp add: d'_def min_def)
60178
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   909
          fix x1
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   910
          assume x1: "x1 \<in> {a..<d'}"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   911
          {
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   912
            assume "x1 < y"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   913
            hence "?le x1"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   914
              using \<open>x1 \<in> {a..<d'}\<close> y_all_le by auto
60178
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   915
          } moreover {
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   916
            assume "x1 \<ge> y"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   917
            hence x1': "x1 \<in> S" "x1 \<in> {y..<b}" using x1
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   918
              by (auto simp: d'_def dist_real_def intro!: d)
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   919
            have "norm (f x1 - f a) \<le> norm (f x1 - f y) + norm (f y - f a)"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   920
              by (rule order_trans[OF _ norm_triangle_ineq]) simp
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   921
            also note S(3)[OF x1']
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   922
            also note le_y
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   923
            finally have "?le x1"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   924
              using \<open>x1 \<ge> y\<close> by (auto simp: algebra_simps)
60178
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   925
          } ultimately show "?le x1" by arith
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   926
        qed
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   927
        hence "d' \<le> y"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   928
          unfolding y_def
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   929
          by (rule cSup_upper) simp
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   930
        thus False using \<open>d > 0\<close> \<open>y < b\<close>
60178
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   931
          by (simp add: d'_def min_def split: split_if_asm)
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   932
      qed
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   933
    } moreover {
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   934
      assume "a = y"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   935
      with \<open>a < b\<close> have "y < b" by simp
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   936
      with \<open>a = y\<close> f_cont phi_cont \<open>e2 > 0\<close>
60178
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   937
      have 1: "\<forall>\<^sub>F x in at y within {y..b}. dist (f x) (f y) < e2"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   938
       and 2: "\<forall>\<^sub>F x in at y within {y..b}. dist (\<phi> x) (\<phi> y) < e2"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   939
        by (auto simp: continuous_on_def tendsto_iff)
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   940
      have 3: "eventually (\<lambda>x. y < x) (at y within {y..b})"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   941
        by (auto simp: eventually_at_filter)
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   942
      have 4: "eventually (\<lambda>x::real. x < b) (at y within {y..b})"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   943
        using _ \<open>y < b\<close>
60178
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   944
        by (rule order_tendstoD) (auto intro!: tendsto_eq_intros)
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   945
      from 1 2 3 4
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   946
      have eventually_le: "eventually (\<lambda>x. ?le x) (at y within {y .. b})"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   947
      proof eventually_elim
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   948
        case (elim x1)
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   949
        have "norm (f x1 - f a) = norm (f x1 - f y)"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   950
          by (simp add: \<open>a = y\<close>)
60178
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   951
        also have "norm (f x1 - f y) \<le> e2"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   952
          using elim \<open>a = y\<close> by (auto simp : dist_norm intro!:  less_imp_le)
60178
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   953
        also have "\<dots> \<le> e2 + (\<phi> x1 - \<phi> a + e2 + e * (x1 - a))"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   954
          using \<open>0 < e\<close> elim
60178
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   955
          by (intro add_increasing2[OF add_nonneg_nonneg order.refl])
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   956
            (auto simp: \<open>a = y\<close> dist_norm intro!: mult_nonneg_nonneg)
60178
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   957
        also have "\<dots> = \<phi> x1 - \<phi> a + e * (x1 - a) + e"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   958
          by (simp add: e2_def)
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   959
        finally show "?le x1" .
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   960
      qed
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   961
      from this[unfolded eventually_at_topological] \<open>?le y\<close>
60178
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   962
      obtain S
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   963
      where S: "open S" "y \<in> S" "\<And>x. x\<in>S \<Longrightarrow> x \<in> {y..b} \<Longrightarrow> ?le x"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   964
        by metis
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   965
      from \<open>open S\<close> obtain d where d: "\<And>x. dist x y < d \<Longrightarrow> x \<in> S" "d > 0"
60178
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   966
        by (force simp: dist_commute open_real_def ball_def
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   967
          dest!: bspec[OF _ \<open>y \<in> S\<close>])
60178
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   968
      def d' \<equiv> "min b (y + (d/2))"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   969
      have "d' \<in> A"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   970
        unfolding A_def
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   971
      proof safe
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   972
        show "a \<le> d'" using \<open>a = y\<close> \<open>0 < d\<close> \<open>y < b\<close> by (simp add: d'_def)
60178
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   973
        show "d' \<le> b" by (simp add: d'_def)
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   974
        fix x1
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   975
        assume "x1 \<in> {a..<d'}"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   976
        hence "x1 \<in> S" "x1 \<in> {y..b}"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   977
          by (auto simp: \<open>a = y\<close> d'_def dist_real_def intro!: d )
60178
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   978
        thus "?le x1"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   979
          by (rule S)
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   980
      qed
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   981
      hence "d' \<le> y"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   982
        unfolding y_def
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   983
        by (rule cSup_upper) simp
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   984
      hence "y = b" using \<open>d > 0\<close> \<open>y < b\<close>
60178
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   985
        by (simp add: d'_def)
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   986
    } ultimately have "y = b"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   987
      by auto
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   988
    with le_y have "norm (f b - f a) \<le> \<phi> b - \<phi> a + e * (b - a + 1)"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   989
      by (simp add: algebra_simps)
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   990
  } note * = this
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   991
  {
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   992
    fix e::real assume "e > 0"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   993
    hence "norm (f b - f a) \<le> \<phi> b - \<phi> a + e"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
   994
      using *[of "e / (b - a + 1)"] \<open>a < b\<close> by simp
60178
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   995
  } thus ?thesis
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   996
    by (rule field_le_epsilon)
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
   997
qed
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
   998
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
   999
lemma differentiable_bound:
60178
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1000
  fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_vector"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1001
  assumes "convex s"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1002
    and "\<forall>x\<in>s. (f has_derivative f' x) (at x within s)"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1003
    and "\<forall>x\<in>s. onorm (f' x) \<le> B"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1004
    and x: "x \<in> s"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1005
    and y: "y \<in> s"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1006
  shows "norm (f x - f y) \<le> B * norm (x - y)"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1007
proof -
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  1008
  let ?p = "\<lambda>u. x + u *\<^sub>R (y - x)"
60178
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1009
  let ?\<phi> = "\<lambda>h. h * B * norm (x - y)"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1010
  have *: "\<And>u. u\<in>{0..1} \<Longrightarrow> x + u *\<^sub>R (y - x) \<in> s"
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1011
    using assms(1)[unfolded convex_alt,rule_format,OF x y]
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1012
    unfolding scaleR_left_diff_distrib scaleR_right_diff_distrib
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1013
    by (auto simp add: algebra_simps)
60178
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1014
  have 0: "continuous_on (?p ` {0..1}) f"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1015
    using *
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1016
    unfolding continuous_on_eq_continuous_within
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1017
    apply -
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1018
    apply rule
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1019
    apply (rule differentiable_imp_continuous_within)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1020
    unfolding differentiable_def
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1021
    apply (rule_tac x="f' xa" in exI)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1022
    apply (rule has_derivative_within_subset)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1023
    apply (rule assms(2)[rule_format])
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1024
    apply auto
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1025
    done
60178
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1026
  from * have 1: "continuous_on {0 .. 1} (f \<circ> ?p)"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1027
    by (intro continuous_intros 0)+
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1028
  {
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1029
    fix u::real assume u: "u \<in>{0 <..< 1}"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1030
    let ?u = "?p u"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1031
    interpret linear "(f' ?u)"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1032
      using u by (auto intro!: has_derivative_linear assms(2)[rule_format] *)
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56183
diff changeset
  1033
    have "(f \<circ> ?p has_derivative (f' ?u) \<circ> (\<lambda>u. 0 + u *\<^sub>R (y - x))) (at u within box 0 1)"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1034
      apply (rule diff_chain_within)
56381
0556204bc230 merged DERIV_intros, has_derivative_intros into derivative_intros
hoelzl
parents: 56371
diff changeset
  1035
      apply (rule derivative_intros)+
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1036
      apply (rule has_derivative_within_subset)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1037
      apply (rule assms(2)[rule_format])
60178
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1038
      using u *
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1039
      apply auto
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1040
      done
60178
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1041
    hence "((f \<circ> ?p) has_vector_derivative f' ?u (y - x)) (at u)"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1042
      by (simp add: has_derivative_within_open[OF u open_greaterThanLessThan]
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1043
        scaleR has_vector_derivative_def o_def)
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1044
  } note 2 = this
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1045
  {
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1046
    have "continuous_on {0..1} ?\<phi>"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1047
      by (rule continuous_intros)+
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1048
  } note 3 = this
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1049
  {
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1050
    fix u::real assume u: "u \<in>{0 <..< 1}"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1051
    have "(?\<phi> has_vector_derivative B * norm (x - y)) (at u)"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1052
      by (auto simp: has_vector_derivative_def intro!: derivative_eq_intros)
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1053
  } note 4 = this
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1054
  {
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1055
    fix u::real assume u: "u \<in>{0 <..< 1}"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1056
    let ?u = "?p u"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1057
    interpret bounded_linear "(f' ?u)"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1058
      using u by (auto intro!: has_derivative_bounded_linear assms(2)[rule_format] *)
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1059
    have "norm (f' ?u (y - x)) \<le> onorm (f' ?u) * norm (y - x)"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1060
      by (rule onorm) fact
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1061
    also have "onorm (f' ?u) \<le> B"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1062
      using u by (auto intro!: assms(3)[rule_format] *)
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1063
    finally have "norm ((f' ?u) (y - x)) \<le> B * norm (x - y)"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1064
      by (simp add: mult_right_mono norm_minus_commute)
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1065
  } note 5 = this
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  1066
  have "norm (f x - f y) = norm ((f \<circ> (\<lambda>u. x + u *\<^sub>R (y - x))) 1 - (f \<circ> (\<lambda>u. x + u *\<^sub>R (y - x))) 0)"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1067
    by (auto simp add: norm_minus_commute)
60178
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1068
  also
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1069
  from differentiable_bound_general[OF zero_less_one 1, OF 3 2 4 5]
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1070
  have "norm ((f \<circ> ?p) 1 - (f \<circ> ?p) 0) \<le> B * norm (x - y)"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1071
    by simp
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1072
  finally show ?thesis .
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1073
qed
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1074
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1075
lemma
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1076
  differentiable_bound_segment:
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1077
  fixes f::"'a::real_normed_vector \<Rightarrow> 'b::real_normed_vector"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1078
  assumes "\<And>t. t \<in> {0..1} \<Longrightarrow> x0 + t *\<^sub>R a \<in> G"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1079
  assumes f': "\<And>x. x \<in> G \<Longrightarrow> (f has_derivative f' x) (at x within G)"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1080
  assumes B: "\<forall>x\<in>{0..1}. onorm (f' (x0 + x *\<^sub>R a)) \<le> B"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1081
  shows "norm (f (x0 + a) - f x0) \<le> norm a * B"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1082
proof -
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1083
  let ?G = "(\<lambda>x. x0 + x *\<^sub>R a) ` {0..1}"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1084
  have "?G = op + x0 ` (\<lambda>x. x *\<^sub>R a) ` {0..1}" by auto
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1085
  also have "convex \<dots>"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1086
    by (intro convex_translation convex_scaled convex_real_interval)
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1087
  finally have "convex ?G" .
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1088
  moreover have "?G \<subseteq> G" "x0 \<in> ?G" "x0 + a \<in> ?G" using assms by (auto intro: image_eqI[where x=1])
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1089
  ultimately show ?thesis
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
  1090
    using has_derivative_subset[OF f' \<open>?G \<subseteq> G\<close>] B
60178
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1091
      differentiable_bound[of "(\<lambda>x. x0 + x *\<^sub>R a) ` {0..1}" f f' B "x0 + a" x0]
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1092
    by (auto simp: ac_simps)
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1093
qed
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1094
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1095
lemma differentiable_bound_linearization:
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1096
  fixes f::"'a::real_normed_vector \<Rightarrow> 'b::real_normed_vector"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1097
  assumes "\<And>t. t \<in> {0..1} \<Longrightarrow> a + t *\<^sub>R (b - a) \<in> S"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1098
  assumes f'[derivative_intros]: "\<And>x. x \<in> S \<Longrightarrow> (f has_derivative f' x) (at x within S)"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1099
  assumes B: "\<forall>x\<in>S. onorm (f' x - f' x0) \<le> B"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1100
  assumes "x0 \<in> S"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1101
  shows "norm (f b - f a - f' x0 (b - a)) \<le> norm (b - a) * B"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1102
proof -
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1103
  def g \<equiv> "\<lambda>x. f x - f' x0 x"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1104
  have g: "\<And>x. x \<in> S \<Longrightarrow> (g has_derivative (\<lambda>i. f' x i - f' x0 i)) (at x within S)"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1105
    unfolding g_def using assms
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1106
    by (auto intro!: derivative_eq_intros
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1107
      bounded_linear.has_derivative[OF has_derivative_bounded_linear, OF f'])
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1108
  from B have B: "\<forall>x\<in>{0..1}. onorm (\<lambda>i. f' (a + x *\<^sub>R (b - a)) i - f' x0 i) \<le> B"
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1109
     using assms by (auto simp: fun_diff_def)
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
  1110
  from differentiable_bound_segment[OF assms(1) g B] \<open>x0 \<in> S\<close>
60178
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1111
  show ?thesis
f620c70f9e9b generalized differentiable_bound; some further variations of differentiable_bound
immler
parents: 60177
diff changeset
  1112
    by (simp add: g_def field_simps linear_sub[OF has_derivative_linear[OF f']])
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1113
qed
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  1114
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
  1115
text \<open>In particular.\<close>
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  1116
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1117
lemma has_derivative_zero_constant:
60179
d87c8c2d4938 generalized class constraints
immler
parents: 60178
diff changeset
  1118
  fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_vector"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1119
  assumes "convex s"
56369
2704ca85be98 moved generic theorems from Complex_Analysis_Basic; fixed some theorem names
hoelzl
parents: 56332
diff changeset
  1120
    and "\<And>x. x \<in> s \<Longrightarrow> (f has_derivative (\<lambda>h. 0)) (at x within s)"
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1121
  shows "\<exists>c. \<forall>x\<in>s. f x = c"
56332
289dd9166d04 tuned proofs
hoelzl
parents: 56320
diff changeset
  1122
proof -
289dd9166d04 tuned proofs
hoelzl
parents: 56320
diff changeset
  1123
  { fix x y assume "x \<in> s" "y \<in> s"
289dd9166d04 tuned proofs
hoelzl
parents: 56320
diff changeset
  1124
    then have "norm (f x - f y) \<le> 0 * norm (x - y)"
289dd9166d04 tuned proofs
hoelzl
parents: 56320
diff changeset
  1125
      using assms by (intro differentiable_bound[of s]) (auto simp: onorm_zero)
289dd9166d04 tuned proofs
hoelzl
parents: 56320
diff changeset
  1126
    then have "f x = f y"
289dd9166d04 tuned proofs
hoelzl
parents: 56320
diff changeset
  1127
      by simp }
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1128
  then show ?thesis
56332
289dd9166d04 tuned proofs
hoelzl
parents: 56320
diff changeset
  1129
    by metis
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1130
qed
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  1131
61524
f2e51e704a96 added many small lemmas about setsum/setprod/powr/...
eberlm
parents: 61520
diff changeset
  1132
lemma has_field_derivative_zero_constant:
f2e51e704a96 added many small lemmas about setsum/setprod/powr/...
eberlm
parents: 61520
diff changeset
  1133
  assumes "convex s" "\<And>x. x \<in> s \<Longrightarrow> (f has_field_derivative 0) (at x within s)"
f2e51e704a96 added many small lemmas about setsum/setprod/powr/...
eberlm
parents: 61520
diff changeset
  1134
  shows   "\<exists>c. \<forall>x\<in>s. f (x) = (c :: 'a :: real_normed_field)"
f2e51e704a96 added many small lemmas about setsum/setprod/powr/...
eberlm
parents: 61520
diff changeset
  1135
proof (rule has_derivative_zero_constant)
f2e51e704a96 added many small lemmas about setsum/setprod/powr/...
eberlm
parents: 61520
diff changeset
  1136
  have A: "op * 0 = (\<lambda>_. 0 :: 'a)" by (intro ext) simp
f2e51e704a96 added many small lemmas about setsum/setprod/powr/...
eberlm
parents: 61520
diff changeset
  1137
  fix x assume "x \<in> s" thus "(f has_derivative (\<lambda>h. 0)) (at x within s)"
f2e51e704a96 added many small lemmas about setsum/setprod/powr/...
eberlm
parents: 61520
diff changeset
  1138
    using assms(2)[of x] by (simp add: has_field_derivative_def A)
f2e51e704a96 added many small lemmas about setsum/setprod/powr/...
eberlm
parents: 61520
diff changeset
  1139
qed fact
f2e51e704a96 added many small lemmas about setsum/setprod/powr/...
eberlm
parents: 61520
diff changeset
  1140
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1141
lemma has_derivative_zero_unique:
60179
d87c8c2d4938 generalized class constraints
immler
parents: 60178
diff changeset
  1142
  fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_vector"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1143
  assumes "convex s"
56369
2704ca85be98 moved generic theorems from Complex_Analysis_Basic; fixed some theorem names
hoelzl
parents: 56332
diff changeset
  1144
    and "\<And>x. x \<in> s \<Longrightarrow> (f has_derivative (\<lambda>h. 0)) (at x within s)"
2704ca85be98 moved generic theorems from Complex_Analysis_Basic; fixed some theorem names
hoelzl
parents: 56332
diff changeset
  1145
    and "x \<in> s" "y \<in> s"
2704ca85be98 moved generic theorems from Complex_Analysis_Basic; fixed some theorem names
hoelzl
parents: 56332
diff changeset
  1146
  shows "f x = f y"
2704ca85be98 moved generic theorems from Complex_Analysis_Basic; fixed some theorem names
hoelzl
parents: 56332
diff changeset
  1147
  using has_derivative_zero_constant[OF assms(1,2)] assms(3-) by force
2704ca85be98 moved generic theorems from Complex_Analysis_Basic; fixed some theorem names
hoelzl
parents: 56332
diff changeset
  1148
2704ca85be98 moved generic theorems from Complex_Analysis_Basic; fixed some theorem names
hoelzl
parents: 56332
diff changeset
  1149
lemma has_derivative_zero_unique_connected:
60179
d87c8c2d4938 generalized class constraints
immler
parents: 60178
diff changeset
  1150
  fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_vector"
56369
2704ca85be98 moved generic theorems from Complex_Analysis_Basic; fixed some theorem names
hoelzl
parents: 56332
diff changeset
  1151
  assumes "open s" "connected s"
2704ca85be98 moved generic theorems from Complex_Analysis_Basic; fixed some theorem names
hoelzl
parents: 56332
diff changeset
  1152
  assumes f: "\<And>x. x \<in> s \<Longrightarrow> (f has_derivative (\<lambda>x. 0)) (at x)"
2704ca85be98 moved generic theorems from Complex_Analysis_Basic; fixed some theorem names
hoelzl
parents: 56332
diff changeset
  1153
  assumes "x \<in> s" "y \<in> s"
2704ca85be98 moved generic theorems from Complex_Analysis_Basic; fixed some theorem names
hoelzl
parents: 56332
diff changeset
  1154
  shows "f x = f y"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
  1155
proof (rule connected_local_const[where f=f, OF \<open>connected s\<close> \<open>x\<in>s\<close> \<open>y\<in>s\<close>])
56369
2704ca85be98 moved generic theorems from Complex_Analysis_Basic; fixed some theorem names
hoelzl
parents: 56332
diff changeset
  1156
  show "\<forall>a\<in>s. eventually (\<lambda>b. f a = f b) (at a within s)"
2704ca85be98 moved generic theorems from Complex_Analysis_Basic; fixed some theorem names
hoelzl
parents: 56332
diff changeset
  1157
  proof
2704ca85be98 moved generic theorems from Complex_Analysis_Basic; fixed some theorem names
hoelzl
parents: 56332
diff changeset
  1158
    fix a assume "a \<in> s"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
  1159
    with \<open>open s\<close> obtain e where "0 < e" "ball a e \<subseteq> s"
56369
2704ca85be98 moved generic theorems from Complex_Analysis_Basic; fixed some theorem names
hoelzl
parents: 56332
diff changeset
  1160
      by (rule openE)
2704ca85be98 moved generic theorems from Complex_Analysis_Basic; fixed some theorem names
hoelzl
parents: 56332
diff changeset
  1161
    then have "\<exists>c. \<forall>x\<in>ball a e. f x = c"
2704ca85be98 moved generic theorems from Complex_Analysis_Basic; fixed some theorem names
hoelzl
parents: 56332
diff changeset
  1162
      by (intro has_derivative_zero_constant)
2704ca85be98 moved generic theorems from Complex_Analysis_Basic; fixed some theorem names
hoelzl
parents: 56332
diff changeset
  1163
         (auto simp: at_within_open[OF _ open_ball] f convex_ball)
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
  1164
    with \<open>0<e\<close> have "\<forall>x\<in>ball a e. f a = f x"
56369
2704ca85be98 moved generic theorems from Complex_Analysis_Basic; fixed some theorem names
hoelzl
parents: 56332
diff changeset
  1165
      by auto
2704ca85be98 moved generic theorems from Complex_Analysis_Basic; fixed some theorem names
hoelzl
parents: 56332
diff changeset
  1166
    then show "eventually (\<lambda>b. f a = f b) (at a within s)"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
  1167
      using \<open>0<e\<close> unfolding eventually_at_topological
56369
2704ca85be98 moved generic theorems from Complex_Analysis_Basic; fixed some theorem names
hoelzl
parents: 56332
diff changeset
  1168
      by (intro exI[of _ "ball a e"]) auto
2704ca85be98 moved generic theorems from Complex_Analysis_Basic; fixed some theorem names
hoelzl
parents: 56332
diff changeset
  1169
  qed
2704ca85be98 moved generic theorems from Complex_Analysis_Basic; fixed some theorem names
hoelzl
parents: 56332
diff changeset
  1170
qed
2704ca85be98 moved generic theorems from Complex_Analysis_Basic; fixed some theorem names
hoelzl
parents: 56332
diff changeset
  1171
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
  1172
subsection \<open>Differentiability of inverse function (most basic form)\<close>
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  1173
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1174
lemma has_derivative_inverse_basic:
56226
29fd6bd9228e generalize some theorems
huffman
parents: 56223
diff changeset
  1175
  fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_vector"
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1176
  assumes "(f has_derivative f') (at (g y))"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1177
    and "bounded_linear g'"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1178
    and "g' \<circ> f' = id"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1179
    and "continuous (at y) g"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1180
    and "open t"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1181
    and "y \<in> t"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1182
    and "\<forall>z\<in>t. f (g z) = z"
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1183
  shows "(g has_derivative g') (at y)"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1184
proof -
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1185
  interpret f': bounded_linear f'
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1186
    using assms unfolding has_derivative_def by auto
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1187
  interpret g': bounded_linear g'
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1188
    using assms by auto
55665
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1189
  obtain C where C: "0 < C" "\<And>x. norm (g' x) \<le> norm x * C"
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1190
    using bounded_linear.pos_bounded[OF assms(2)] by blast
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1191
  have lem1: "\<forall>e>0. \<exists>d>0. \<forall>z.
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1192
    norm (z - y) < d \<longrightarrow> norm (g z - g y - g'(z - y)) \<le> e * norm (g z - g y)"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1193
  proof (rule, rule)
61165
8020249565fb tuned proofs;
wenzelm
parents: 61104
diff changeset
  1194
    fix e :: real
8020249565fb tuned proofs;
wenzelm
parents: 61104
diff changeset
  1195
    assume "e > 0"
8020249565fb tuned proofs;
wenzelm
parents: 61104
diff changeset
  1196
    with C(1) have *: "e / C > 0" by auto
55665
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1197
    obtain d0 where d0:
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1198
        "0 < d0"
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1199
        "\<forall>ya. norm (ya - g y) < d0 \<longrightarrow> norm (f ya - f (g y) - f' (ya - g y)) \<le> e / C * norm (ya - g y)"
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1200
      using assms(1)
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1201
      unfolding has_derivative_at_alt
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1202
      using * by blast
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1203
    obtain d1 where d1:
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1204
        "0 < d1"
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1205
        "\<forall>x. 0 < dist x y \<and> dist x y < d1 \<longrightarrow> dist (g x) (g y) < d0"
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1206
      using assms(4)
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1207
      unfolding continuous_at Lim_at
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1208
      using d0(1) by blast
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1209
    obtain d2 where d2:
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1210
        "0 < d2"
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1211
        "\<forall>ya. dist ya y < d2 \<longrightarrow> ya \<in> t"
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1212
      using assms(5)
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1213
      unfolding open_dist
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1214
      using assms(6) by blast
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1215
    obtain d where d: "0 < d" "d < d1" "d < d2"
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1216
      using real_lbound_gt_zero[OF d1(1) d2(1)] by blast
61165
8020249565fb tuned proofs;
wenzelm
parents: 61104
diff changeset
  1217
    then show "\<exists>d>0. \<forall>z. norm (z - y) < d \<longrightarrow> norm (g z - g y - g' (z - y)) \<le> e * norm (g z - g y)"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1218
      apply (rule_tac x=d in exI)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1219
      apply rule
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1220
      defer
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1221
      apply rule
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1222
      apply rule
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1223
    proof -
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1224
      fix z
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1225
      assume as: "norm (z - y) < d"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1226
      then have "z \<in> t"
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1227
        using d2 d unfolding dist_norm by auto
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  1228
      have "norm (g z - g y - g' (z - y)) \<le> norm (g' (f (g z) - y - f' (g z - g y)))"
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1229
        unfolding g'.diff f'.diff
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1230
        unfolding assms(3)[unfolded o_def id_def, THEN fun_cong]
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
  1231
        unfolding assms(7)[rule_format,OF \<open>z\<in>t\<close>]
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1232
        apply (subst norm_minus_cancel[symmetric])
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1233
        apply auto
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1234
        done
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1235
      also have "\<dots> \<le> norm (f (g z) - y - f' (g z - g y)) * C"
55665
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1236
        by (rule C(2))
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1237
      also have "\<dots> \<le> (e / C) * norm (g z - g y) * C"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1238
        apply (rule mult_right_mono)
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
  1239
        apply (rule d0(2)[rule_format,unfolded assms(7)[rule_format,OF \<open>y\<in>t\<close>]])
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1240
        apply (cases "z = y")
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1241
        defer
55665
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1242
        apply (rule d1(2)[unfolded dist_norm,rule_format])
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1243
        using as d C d0
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1244
        apply auto
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1245
        done
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1246
      also have "\<dots> \<le> e * norm (g z - g y)"
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1247
        using C by (auto simp add: field_simps)
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1248
      finally show "norm (g z - g y - g' (z - y)) \<le> e * norm (g z - g y)"
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1249
        by simp
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1250
    qed auto
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1251
  qed
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1252
  have *: "(0::real) < 1 / 2"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1253
    by auto
55665
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1254
  obtain d where d:
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1255
      "0 < d"
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1256
      "\<forall>z. norm (z - y) < d \<longrightarrow> norm (g z - g y - g' (z - y)) \<le> 1 / 2 * norm (g z - g y)"
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1257
    using lem1 * by blast
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1258
  def B \<equiv> "C * 2"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1259
  have "B > 0"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1260
    unfolding B_def using C by auto
61165
8020249565fb tuned proofs;
wenzelm
parents: 61104
diff changeset
  1261
  have lem2: "norm (g z - g y) \<le> B * norm (z - y)" if z: "norm(z - y) < d" for z
8020249565fb tuned proofs;
wenzelm
parents: 61104
diff changeset
  1262
  proof -
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1263
    have "norm (g z - g y) \<le> norm(g' (z - y)) + norm ((g z - g y) - g'(z - y))"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1264
      by (rule norm_triangle_sub)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1265
    also have "\<dots> \<le> norm (g' (z - y)) + 1 / 2 * norm (g z - g y)"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1266
      apply (rule add_left_mono)
61165
8020249565fb tuned proofs;
wenzelm
parents: 61104
diff changeset
  1267
      using d and z
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1268
      apply auto
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1269
      done
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1270
    also have "\<dots> \<le> norm (z - y) * C + 1 / 2 * norm (g z - g y)"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1271
      apply (rule add_right_mono)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1272
      using C
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1273
      apply auto
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1274
      done
61165
8020249565fb tuned proofs;
wenzelm
parents: 61104
diff changeset
  1275
    finally show "norm (g z - g y) \<le> B * norm (z - y)"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1276
      unfolding B_def
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1277
      by (auto simp add: field_simps)
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1278
  qed
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1279
  show ?thesis
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1280
    unfolding has_derivative_at_alt
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1281
    apply rule
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1282
    apply (rule assms)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1283
    apply rule
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1284
    apply rule
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1285
  proof -
61165
8020249565fb tuned proofs;
wenzelm
parents: 61104
diff changeset
  1286
    fix e :: real
8020249565fb tuned proofs;
wenzelm
parents: 61104
diff changeset
  1287
    assume "e > 0"
8020249565fb tuned proofs;
wenzelm
parents: 61104
diff changeset
  1288
    then have *: "e / B > 0" by (metis \<open>B > 0\<close> divide_pos_pos)
55665
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1289
    obtain d' where d':
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1290
        "0 < d'"
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1291
        "\<forall>z. norm (z - y) < d' \<longrightarrow> norm (g z - g y - g' (z - y)) \<le> e / B * norm (g z - g y)"
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1292
      using lem1 * by blast
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1293
    obtain k where k: "0 < k" "k < d" "k < d'"
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1294
      using real_lbound_gt_zero[OF d(1) d'(1)] by blast
61165
8020249565fb tuned proofs;
wenzelm
parents: 61104
diff changeset
  1295
    show "\<exists>d>0. \<forall>ya. norm (ya - y) < d \<longrightarrow> norm (g ya - g y - g' (ya - y)) \<le> e * norm (ya - y)"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1296
      apply (rule_tac x=k in exI)
55970
6d123f0ae358 Some new proofs. Tidying up, esp to remove "apply rule".
paulson <lp15@cam.ac.uk>
parents: 55665
diff changeset
  1297
      apply auto
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1298
    proof -
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1299
      fix z
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1300
      assume as: "norm (z - y) < k"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1301
      then have "norm (g z - g y - g' (z - y)) \<le> e / B * norm(g z - g y)"
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1302
        using d' k by auto
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1303
      also have "\<dots> \<le> e * norm (z - y)"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
  1304
        unfolding times_divide_eq_left pos_divide_le_eq[OF \<open>B>0\<close>]
61165
8020249565fb tuned proofs;
wenzelm
parents: 61104
diff changeset
  1305
        using lem2[of z]
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
  1306
        using k as using \<open>e > 0\<close>
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1307
        by (auto simp add: field_simps)
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1308
      finally show "norm (g z - g y - g' (z - y)) \<le> e * norm (z - y)"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1309
        by simp
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1310
    qed(insert k, auto)
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1311
  qed
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1312
qed
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  1313
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
  1314
text \<open>Simply rewrite that based on the domain point x.\<close>
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  1315
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1316
lemma has_derivative_inverse_basic_x:
56226
29fd6bd9228e generalize some theorems
huffman
parents: 56223
diff changeset
  1317
  fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_vector"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1318
  assumes "(f has_derivative f') (at x)"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1319
    and "bounded_linear g'"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1320
    and "g' \<circ> f' = id"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1321
    and "continuous (at (f x)) g"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1322
    and "g (f x) = x"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1323
    and "open t"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1324
    and "f x \<in> t"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1325
    and "\<forall>y\<in>t. f (g y) = y"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1326
  shows "(g has_derivative g') (at (f x))"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1327
  apply (rule has_derivative_inverse_basic)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1328
  using assms
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1329
  apply auto
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1330
  done
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  1331
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
  1332
text \<open>This is the version in Dieudonne', assuming continuity of f and g.\<close>
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  1333
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1334
lemma has_derivative_inverse_dieudonne:
56226
29fd6bd9228e generalize some theorems
huffman
parents: 56223
diff changeset
  1335
  fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_vector"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1336
  assumes "open s"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1337
    and "open (f ` s)"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1338
    and "continuous_on s f"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1339
    and "continuous_on (f ` s) g"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1340
    and "\<forall>x\<in>s. g (f x) = x"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1341
    and "x \<in> s"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1342
    and "(f has_derivative f') (at x)"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1343
    and "bounded_linear g'"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1344
    and "g' \<circ> f' = id"
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  1345
  shows "(g has_derivative g') (at (f x))"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1346
  apply (rule has_derivative_inverse_basic_x[OF assms(7-9) _ _ assms(2)])
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1347
  using assms(3-6)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1348
  unfolding continuous_on_eq_continuous_at[OF assms(1)] continuous_on_eq_continuous_at[OF assms(2)]
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1349
  apply auto
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1350
  done
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  1351
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
  1352
text \<open>Here's the simplest way of not assuming much about g.\<close>
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  1353
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1354
lemma has_derivative_inverse:
56226
29fd6bd9228e generalize some theorems
huffman
parents: 56223
diff changeset
  1355
  fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_vector"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1356
  assumes "compact s"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1357
    and "x \<in> s"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1358
    and "f x \<in> interior (f ` s)"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1359
    and "continuous_on s f"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1360
    and "\<forall>y\<in>s. g (f y) = y"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1361
    and "(f has_derivative f') (at x)"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1362
    and "bounded_linear g'"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1363
    and "g' \<circ> f' = id"
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1364
  shows "(g has_derivative g') (at (f x))"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1365
proof -
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1366
  {
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1367
    fix y
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1368
    assume "y \<in> interior (f ` s)"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1369
    then obtain x where "x \<in> s" and *: "y = f x"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1370
      unfolding image_iff
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1371
      using interior_subset
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1372
      by auto
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1373
    have "f (g y) = y"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
  1374
      unfolding * and assms(5)[rule_format,OF \<open>x\<in>s\<close>] ..
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1375
  } note * = this
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1376
  show ?thesis
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1377
    apply (rule has_derivative_inverse_basic_x[OF assms(6-8)])
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1378
    apply (rule continuous_on_interior[OF _ assms(3)])
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1379
    apply (rule continuous_on_inv[OF assms(4,1)])
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1380
    apply (rule assms(2,5) assms(5)[rule_format] open_interior assms(3))+
55970
6d123f0ae358 Some new proofs. Tidying up, esp to remove "apply rule".
paulson <lp15@cam.ac.uk>
parents: 55665
diff changeset
  1381
    apply (metis *)
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1382
    done
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1383
qed
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  1384
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1385
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
  1386
subsection \<open>Proving surjectivity via Brouwer fixpoint theorem\<close>
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  1387
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1388
lemma brouwer_surjective:
56117
2dbf84ee3deb remove ordered_euclidean_space constraint from brouwer/derivative lemmas;
huffman
parents: 55970
diff changeset
  1389
  fixes f :: "'n::euclidean_space \<Rightarrow> 'n"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1390
  assumes "compact t"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1391
    and "convex t"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1392
    and "t \<noteq> {}"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1393
    and "continuous_on t f"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1394
    and "\<forall>x\<in>s. \<forall>y\<in>t. x + (y - f y) \<in> t"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1395
    and "x \<in> s"
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1396
  shows "\<exists>y\<in>t. f y = x"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1397
proof -
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1398
  have *: "\<And>x y. f y = x \<longleftrightarrow> x + (y - f y) = y"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1399
    by (auto simp add: algebra_simps)
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1400
  show ?thesis
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1401
    unfolding *
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1402
    apply (rule brouwer[OF assms(1-3), of "\<lambda>y. x + (y - f y)"])
56371
fb9ae0727548 extend continuous_intros; remove continuous_on_intros and isCont_intros
hoelzl
parents: 56370
diff changeset
  1403
    apply (rule continuous_intros assms)+
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1404
    using assms(4-6)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1405
    apply auto
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1406
    done
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1407
qed
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  1408
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1409
lemma brouwer_surjective_cball:
56117
2dbf84ee3deb remove ordered_euclidean_space constraint from brouwer/derivative lemmas;
huffman
parents: 55970
diff changeset
  1410
  fixes f :: "'n::euclidean_space \<Rightarrow> 'n"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1411
  assumes "e > 0"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1412
    and "continuous_on (cball a e) f"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1413
    and "\<forall>x\<in>s. \<forall>y\<in>cball a e. x + (y - f y) \<in> cball a e"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1414
    and "x \<in> s"
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1415
  shows "\<exists>y\<in>cball a e. f y = x"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1416
  apply (rule brouwer_surjective)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1417
  apply (rule compact_cball convex_cball)+
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1418
  unfolding cball_eq_empty
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1419
  using assms
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1420
  apply auto
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1421
  done
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  1422
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
  1423
text \<open>See Sussmann: "Multidifferential calculus", Theorem 2.1.1\<close>
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  1424
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1425
lemma sussmann_open_mapping:
56227
67a5f004583d generalize more theorems
huffman
parents: 56226
diff changeset
  1426
  fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::euclidean_space"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1427
  assumes "open s"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1428
    and "continuous_on s f"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1429
    and "x \<in> s"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1430
    and "(f has_derivative f') (at x)"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1431
    and "bounded_linear g'" "f' \<circ> g' = id"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1432
    and "t \<subseteq> s"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1433
    and "x \<in> interior t"
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1434
  shows "f x \<in> interior (f ` t)"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1435
proof -
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1436
  interpret f': bounded_linear f'
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1437
    using assms
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1438
    unfolding has_derivative_def
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1439
    by auto
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1440
  interpret g': bounded_linear g'
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1441
    using assms
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1442
    by auto
55665
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1443
  obtain B where B: "0 < B" "\<forall>x. norm (g' x) \<le> norm x * B"
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1444
    using bounded_linear.pos_bounded[OF assms(5)] by blast
56541
0e3abadbef39 made divide_pos_pos a simp rule
nipkow
parents: 56445
diff changeset
  1445
  hence *: "1 / (2 * B) > 0" by auto
55665
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1446
  obtain e0 where e0:
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1447
      "0 < e0"
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1448
      "\<forall>y. norm (y - x) < e0 \<longrightarrow> norm (f y - f x - f' (y - x)) \<le> 1 / (2 * B) * norm (y - x)"
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1449
    using assms(4)
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1450
    unfolding has_derivative_at_alt
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1451
    using * by blast
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1452
  obtain e1 where e1: "0 < e1" "cball x e1 \<subseteq> t"
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1453
    using assms(8)
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1454
    unfolding mem_interior_cball
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1455
    by blast
56541
0e3abadbef39 made divide_pos_pos a simp rule
nipkow
parents: 56445
diff changeset
  1456
  have *: "0 < e0 / B" "0 < e1 / B" using e0 e1 B by auto
55665
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1457
  obtain e where e: "0 < e" "e < e0 / B" "e < e1 / B"
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1458
    using real_lbound_gt_zero[OF *] by blast
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1459
  have "\<forall>z\<in>cball (f x) (e / 2). \<exists>y\<in>cball (f x) e. f (x + g' (y - f x)) = z"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1460
    apply rule
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1461
    apply (rule brouwer_surjective_cball[where s="cball (f x) (e/2)"])
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1462
    prefer 3
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1463
    apply rule
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1464
    apply rule
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1465
  proof-
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1466
    show "continuous_on (cball (f x) e) (\<lambda>y. f (x + g' (y - f x)))"
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1467
      unfolding g'.diff
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1468
      apply (rule continuous_on_compose[of _ _ f, unfolded o_def])
56371
fb9ae0727548 extend continuous_intros; remove continuous_on_intros and isCont_intros
hoelzl
parents: 56370
diff changeset
  1469
      apply (rule continuous_intros linear_continuous_on[OF assms(5)])+
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1470
      apply (rule continuous_on_subset[OF assms(2)])
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1471
      apply rule
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1472
      apply (unfold image_iff)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1473
      apply (erule bexE)
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1474
    proof-
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1475
      fix y z
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1476
      assume as: "y \<in>cball (f x) e" "z = x + (g' y - g' (f x))"
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1477
      have "dist x z = norm (g' (f x) - g' y)"
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1478
        unfolding as(2) and dist_norm by auto
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1479
      also have "\<dots> \<le> norm (f x - y) * B"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1480
        unfolding g'.diff[symmetric]
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1481
        using B
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1482
        by auto
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1483
      also have "\<dots> \<le> e * B"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1484
        using as(1)[unfolded mem_cball dist_norm]
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1485
        using B
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1486
        by auto
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1487
      also have "\<dots> \<le> e1"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1488
        using e
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1489
        unfolding less_divide_eq
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1490
        using B
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1491
        by auto
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1492
      finally have "z \<in> cball x e1"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1493
        unfolding mem_cball
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1494
        by force
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1495
      then show "z \<in> s"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1496
        using e1 assms(7) by auto
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1497
    qed
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1498
  next
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1499
    fix y z
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1500
    assume as: "y \<in> cball (f x) (e / 2)" "z \<in> cball (f x) e"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1501
    have "norm (g' (z - f x)) \<le> norm (z - f x) * B"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1502
      using B by auto
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1503
    also have "\<dots> \<le> e * B"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1504
      apply (rule mult_right_mono)
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1505
      using as(2)[unfolded mem_cball dist_norm] and B
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1506
      unfolding norm_minus_commute
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1507
      apply auto
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1508
      done
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1509
    also have "\<dots> < e0"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1510
      using e and B
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1511
      unfolding less_divide_eq
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1512
      by auto
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1513
    finally have *: "norm (x + g' (z - f x) - x) < e0"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1514
      by auto
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1515
    have **: "f x + f' (x + g' (z - f x) - x) = z"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1516
      using assms(6)[unfolded o_def id_def,THEN cong]
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1517
      by auto
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1518
    have "norm (f x - (y + (z - f (x + g' (z - f x))))) \<le>
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1519
        norm (f (x + g' (z - f x)) - z) + norm (f x - y)"
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1520
      using norm_triangle_ineq[of "f (x + g'(z - f x)) - z" "f x - y"]
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1521
      by (auto simp add: algebra_simps)
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1522
    also have "\<dots> \<le> 1 / (B * 2) * norm (g' (z - f x)) + norm (f x - y)"
55665
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1523
      using e0(2)[rule_format, OF *]
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1524
      unfolding algebra_simps **
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1525
      by auto
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1526
    also have "\<dots> \<le> 1 / (B * 2) * norm (g' (z - f x)) + e/2"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1527
      using as(1)[unfolded mem_cball dist_norm]
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1528
      by auto
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1529
    also have "\<dots> \<le> 1 / (B * 2) * B * norm (z - f x) + e/2"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1530
      using * and B
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1531
      by (auto simp add: field_simps)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1532
    also have "\<dots> \<le> 1 / 2 * norm (z - f x) + e/2"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1533
      by auto
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1534
    also have "\<dots> \<le> e/2 + e/2"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1535
      apply (rule add_right_mono)
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1536
      using as(2)[unfolded mem_cball dist_norm]
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1537
      unfolding norm_minus_commute
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1538
      apply auto
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1539
      done
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1540
    finally show "y + (z - f (x + g' (z - f x))) \<in> cball (f x) e"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1541
      unfolding mem_cball dist_norm
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1542
      by auto
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1543
  qed (insert e, auto) note lem = this
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1544
  show ?thesis
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1545
    unfolding mem_interior
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1546
    apply (rule_tac x="e/2" in exI)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1547
    apply rule
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1548
    apply (rule divide_pos_pos)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1549
    prefer 3
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1550
  proof
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1551
    fix y
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1552
    assume "y \<in> ball (f x) (e / 2)"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1553
    then have *: "y \<in> cball (f x) (e / 2)"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1554
      by auto
55665
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1555
    obtain z where z: "z \<in> cball (f x) e" "f (x + g' (z - f x)) = y"
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1556
      using lem * by blast
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1557
    then have "norm (g' (z - f x)) \<le> norm (z - f x) * B"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1558
      using B
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1559
      by (auto simp add: field_simps)
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1560
    also have "\<dots> \<le> e * B"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1561
      apply (rule mult_right_mono)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1562
      using z(1)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1563
      unfolding mem_cball dist_norm norm_minus_commute
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1564
      using B
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1565
      apply auto
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1566
      done
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1567
    also have "\<dots> \<le> e1"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1568
      using e B unfolding less_divide_eq by auto
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1569
    finally have "x + g'(z - f x) \<in> t"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1570
      apply -
55665
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1571
      apply (rule e1(2)[unfolded subset_eq,rule_format])
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1572
      unfolding mem_cball dist_norm
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1573
      apply auto
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1574
      done
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1575
    then show "y \<in> f ` t"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1576
      using z by auto
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1577
  qed (insert e, auto)
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1578
qed
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  1579
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
  1580
text \<open>Hence the following eccentric variant of the inverse function theorem.
53799
784223a8576e proper text for document preparation;
wenzelm
parents: 53781
diff changeset
  1581
  This has no continuity assumptions, but we do need the inverse function.
61808
fc1556774cfe isabelle update_cartouches -c -t;
wenzelm
parents: 61762
diff changeset
  1582
  We could put \<open>f' \<circ> g = I\<close> but this happens to fit with the minimal linear
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
  1583
  algebra theory I've set up so far.\<close>
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  1584
37489
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36844
diff changeset
  1585
(* move  before left_inverse_linear in Euclidean_Space*)
44e42d392c6e Introduce a type class for euclidean spaces, port most lemmas from real^'n to this type class.
hoelzl
parents: 36844
diff changeset
  1586
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1587
lemma right_inverse_linear:
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1588
  fixes f :: "'a::euclidean_space \<Rightarrow> 'a"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1589
  assumes lf: "linear f"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1590
    and gf: "f \<circ> g = id"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1591
  shows "linear g"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1592
proof -
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1593
  from gf have fi: "surj f"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1594
    by (auto simp add: surj_def o_def id_def) metis
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1595
  from linear_surjective_isomorphism[OF lf fi]
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1596
  obtain h:: "'a \<Rightarrow> 'a" where h: "linear h" "\<forall>x. h (f x) = x" "\<forall>x. f (h x) = x"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1597
    by blast
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1598
  have "h = g"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1599
    apply (rule ext)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1600
    using gf h(2,3)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1601
    apply (simp add: o_def id_def fun_eq_iff)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1602
    apply metis
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1603
    done
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1604
  with h(1) show ?thesis by blast
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1605
qed
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1606
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1607
lemma has_derivative_inverse_strong:
56117
2dbf84ee3deb remove ordered_euclidean_space constraint from brouwer/derivative lemmas;
huffman
parents: 55970
diff changeset
  1608
  fixes f :: "'n::euclidean_space \<Rightarrow> 'n"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1609
  assumes "open s"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1610
    and "x \<in> s"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1611
    and "continuous_on s f"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1612
    and "\<forall>x\<in>s. g (f x) = x"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1613
    and "(f has_derivative f') (at x)"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1614
    and "f' \<circ> g' = id"
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1615
  shows "(g has_derivative g') (at (f x))"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1616
proof -
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1617
  have linf: "bounded_linear f'"
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1618
    using assms(5) unfolding has_derivative_def by auto
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1619
  then have ling: "bounded_linear g'"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1620
    unfolding linear_conv_bounded_linear[symmetric]
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1621
    apply -
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1622
    apply (rule right_inverse_linear)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1623
    using assms(6)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1624
    apply auto
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1625
    done
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1626
  moreover have "g' \<circ> f' = id"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1627
    using assms(6) linf ling
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1628
    unfolding linear_conv_bounded_linear[symmetric]
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1629
    using linear_inverse_left
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1630
    by auto
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1631
  moreover have *:"\<forall>t\<subseteq>s. x \<in> interior t \<longrightarrow> f x \<in> interior (f ` t)"
55970
6d123f0ae358 Some new proofs. Tidying up, esp to remove "apply rule".
paulson <lp15@cam.ac.uk>
parents: 55665
diff changeset
  1632
    apply clarify
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1633
    apply (rule sussmann_open_mapping)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1634
    apply (rule assms ling)+
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1635
    apply auto
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1636
    done
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1637
  have "continuous (at (f x)) g"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1638
    unfolding continuous_at Lim_at
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1639
  proof (rule, rule)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1640
    fix e :: real
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1641
    assume "e > 0"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1642
    then have "f x \<in> interior (f ` (ball x e \<inter> s))"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
  1643
      using *[rule_format,of "ball x e \<inter> s"] \<open>x \<in> s\<close>
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1644
      by (auto simp add: interior_open[OF open_ball] interior_open[OF assms(1)])
55665
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1645
    then obtain d where d: "0 < d" "ball (f x) d \<subseteq> f ` (ball x e \<inter> s)"
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1646
      unfolding mem_interior by blast
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  1647
    show "\<exists>d>0. \<forall>y. 0 < dist y (f x) \<and> dist y (f x) < d \<longrightarrow> dist (g y) (g (f x)) < e"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1648
      apply (rule_tac x=d in exI)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1649
      apply rule
55665
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1650
      apply (rule d(1))
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1651
      apply rule
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1652
      apply rule
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1653
    proof -
61165
8020249565fb tuned proofs;
wenzelm
parents: 61104
diff changeset
  1654
      fix y
8020249565fb tuned proofs;
wenzelm
parents: 61104
diff changeset
  1655
      assume "0 < dist y (f x) \<and> dist y (f x) < d"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1656
      then have "g y \<in> g ` f ` (ball x e \<inter> s)"
55665
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1657
        using d(2)[unfolded subset_eq,THEN bspec[where x=y]]
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1658
        by (auto simp add: dist_commute)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1659
      then have "g y \<in> ball x e \<inter> s"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1660
        using assms(4) by auto
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1661
      then show "dist (g y) (g (f x)) < e"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
  1662
        using assms(4)[rule_format,OF \<open>x \<in> s\<close>]
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1663
        by (auto simp add: dist_commute)
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1664
    qed
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1665
  qed
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1666
  moreover have "f x \<in> interior (f ` s)"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1667
    apply (rule sussmann_open_mapping)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1668
    apply (rule assms ling)+
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
  1669
    using interior_open[OF assms(1)] and \<open>x \<in> s\<close>
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1670
    apply auto
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1671
    done
61165
8020249565fb tuned proofs;
wenzelm
parents: 61104
diff changeset
  1672
  moreover have "f (g y) = y" if "y \<in> interior (f ` s)" for y
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1673
  proof -
61165
8020249565fb tuned proofs;
wenzelm
parents: 61104
diff changeset
  1674
    from that have "y \<in> f ` s"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1675
      using interior_subset by auto
55665
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1676
    then obtain z where "z \<in> s" "y = f z" unfolding image_iff ..
61165
8020249565fb tuned proofs;
wenzelm
parents: 61104
diff changeset
  1677
    then show ?thesis
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1678
      using assms(4) by auto
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1679
  qed
55970
6d123f0ae358 Some new proofs. Tidying up, esp to remove "apply rule".
paulson <lp15@cam.ac.uk>
parents: 55665
diff changeset
  1680
  ultimately show ?thesis using assms
6d123f0ae358 Some new proofs. Tidying up, esp to remove "apply rule".
paulson <lp15@cam.ac.uk>
parents: 55665
diff changeset
  1681
    by (metis has_derivative_inverse_basic_x open_interior)
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1682
qed
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  1683
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
  1684
text \<open>A rewrite based on the other domain.\<close>
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  1685
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1686
lemma has_derivative_inverse_strong_x:
56117
2dbf84ee3deb remove ordered_euclidean_space constraint from brouwer/derivative lemmas;
huffman
parents: 55970
diff changeset
  1687
  fixes f :: "'a::euclidean_space \<Rightarrow> 'a"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1688
  assumes "open s"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1689
    and "g y \<in> s"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1690
    and "continuous_on s f"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1691
    and "\<forall>x\<in>s. g (f x) = x"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1692
    and "(f has_derivative f') (at (g y))"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1693
    and "f' \<circ> g' = id"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1694
    and "f (g y) = y"
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  1695
  shows "(g has_derivative g') (at y)"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1696
  using has_derivative_inverse_strong[OF assms(1-6)]
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1697
  unfolding assms(7)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1698
  by simp
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  1699
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
  1700
text \<open>On a region.\<close>
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  1701
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1702
lemma has_derivative_inverse_on:
56117
2dbf84ee3deb remove ordered_euclidean_space constraint from brouwer/derivative lemmas;
huffman
parents: 55970
diff changeset
  1703
  fixes f :: "'n::euclidean_space \<Rightarrow> 'n"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1704
  assumes "open s"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1705
    and "\<forall>x\<in>s. (f has_derivative f'(x)) (at x)"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1706
    and "\<forall>x\<in>s. g (f x) = x"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1707
    and "f' x \<circ> g' x = id"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1708
    and "x \<in> s"
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  1709
  shows "(g has_derivative g'(x)) (at (f x))"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1710
  apply (rule has_derivative_inverse_strong[where g'="g' x" and f=f])
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1711
  apply (rule assms)+
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  1712
  unfolding continuous_on_eq_continuous_at[OF assms(1)]
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1713
  apply rule
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1714
  apply (rule differentiable_imp_continuous_within)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1715
  unfolding differentiable_def
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1716
  using assms
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1717
  apply auto
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1718
  done
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  1719
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
  1720
text \<open>Invertible derivative continous at a point implies local
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1721
injectivity. It's only for this we need continuity of the derivative,
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1722
except of course if we want the fact that the inverse derivative is
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1723
also continuous. So if we know for some other reason that the inverse
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
  1724
function exists, it's OK.\<close>
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  1725
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1726
lemma has_derivative_locally_injective:
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1727
  fixes f :: "'n::euclidean_space \<Rightarrow> 'm::euclidean_space"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1728
  assumes "a \<in> s"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1729
    and "open s"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1730
    and "bounded_linear g'"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1731
    and "g' \<circ> f' a = id"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1732
    and "\<forall>x\<in>s. (f has_derivative f' x) (at x)"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1733
    and "\<forall>e>0. \<exists>d>0. \<forall>x. dist a x < d \<longrightarrow> onorm (\<lambda>v. f' x v - f' a v) < e"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1734
  obtains t where "a \<in> t" "open t" "\<forall>x\<in>t. \<forall>x'\<in>t. f x' = f x \<longrightarrow> x' = x"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1735
proof -
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1736
  interpret bounded_linear g'
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1737
    using assms by auto
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  1738
  note f'g' = assms(4)[unfolded id_def o_def,THEN cong]
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1739
  have "g' (f' a (\<Sum>Basis)) = (\<Sum>Basis)" "(\<Sum>Basis) \<noteq> (0::'n)"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1740
    defer
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1741
    apply (subst euclidean_eq_iff)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1742
    using f'g'
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1743
    apply auto
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1744
    done
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1745
  then have *: "0 < onorm g'"
56223
7696903b9e61 generalize theory of operator norms to work with class real_normed_vector
huffman
parents: 56217
diff changeset
  1746
    unfolding onorm_pos_lt[OF assms(3)]
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1747
    by fastforce
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1748
  def k \<equiv> "1 / onorm g' / 2"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1749
  have *: "k > 0"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1750
    unfolding k_def using * by auto
55665
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1751
  obtain d1 where d1:
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1752
      "0 < d1"
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1753
      "\<And>x. dist a x < d1 \<Longrightarrow> onorm (\<lambda>v. f' x v - f' a v) < k"
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1754
    using assms(6) * by blast
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
  1755
  from \<open>open s\<close> obtain d2 where "d2 > 0" "ball a d2 \<subseteq> s"
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
  1756
    using \<open>a\<in>s\<close> ..
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1757
  obtain d2 where "d2 > 0" "ball a d2 \<subseteq> s"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1758
    using assms(2,1) ..
55665
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1759
  obtain d2 where d2: "0 < d2" "ball a d2 \<subseteq> s"
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1760
    using assms(2)
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1761
    unfolding open_contains_ball
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
  1762
    using \<open>a\<in>s\<close> by blast
55665
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1763
  obtain d where d: "0 < d" "d < d1" "d < d2"
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1764
    using real_lbound_gt_zero[OF d1(1) d2(1)] by blast
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1765
  show ?thesis
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1766
  proof
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1767
    show "a \<in> ball a d"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1768
      using d by auto
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1769
    show "\<forall>x\<in>ball a d. \<forall>x'\<in>ball a d. f x' = f x \<longrightarrow> x' = x"
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1770
    proof (intro strip)
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1771
      fix x y
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1772
      assume as: "x \<in> ball a d" "y \<in> ball a d" "f x = f y"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1773
      def ph \<equiv> "\<lambda>w. w - g' (f w - f x)"
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1774
      have ph':"ph = g' \<circ> (\<lambda>w. f' a w - (f w - f x))"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1775
        unfolding ph_def o_def
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1776
        unfolding diff
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1777
        using f'g'
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1778
        by (auto simp add: algebra_simps)
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1779
      have "norm (ph x - ph y) \<le> (1 / 2) * norm (x - y)"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1780
        apply (rule differentiable_bound[OF convex_ball _ _ as(1-2), where f'="\<lambda>x v. v - g'(f' x v)"])
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1781
        apply (rule_tac[!] ballI)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1782
      proof -
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1783
        fix u
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1784
        assume u: "u \<in> ball a d"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1785
        then have "u \<in> s"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1786
          using d d2 by auto
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1787
        have *: "(\<lambda>v. v - g' (f' u v)) = g' \<circ> (\<lambda>w. f' a w - f' u w)"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1788
          unfolding o_def and diff
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1789
          using f'g' by auto
41958
5abc60a017e0 eliminated hard tabs;
wenzelm
parents: 41829
diff changeset
  1790
        show "(ph has_derivative (\<lambda>v. v - g' (f' u v))) (at u within ball a d)"
51642
400ec5ae7f8f move FrechetDeriv from the Library to HOL/Deriv; base DERIV on FDERIV and both derivatives allow a restricted support set; FDERIV is now an abbreviation of has_derivative
hoelzl
parents: 51641
diff changeset
  1791
          unfolding ph' *
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1792
          apply (simp add: comp_def)
56181
2aa0b19e74f3 unify syntax for has_derivative and differentiable
hoelzl
parents: 56151
diff changeset
  1793
          apply (rule bounded_linear.has_derivative[OF assms(3)])
56381
0556204bc230 merged DERIV_intros, has_derivative_intros into derivative_intros
hoelzl
parents: 56371
diff changeset
  1794
          apply (rule derivative_intros)
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1795
          defer
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1796
          apply (rule has_derivative_sub[where g'="\<lambda>x.0",unfolded diff_0_right])
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1797
          apply (rule has_derivative_at_within)
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
  1798
          using assms(5) and \<open>u \<in> s\<close> \<open>a \<in> s\<close>
56381
0556204bc230 merged DERIV_intros, has_derivative_intros into derivative_intros
hoelzl
parents: 56371
diff changeset
  1799
          apply (auto intro!: derivative_intros bounded_linear.has_derivative[of _ "\<lambda>x. x"] has_derivative_bounded_linear)
51642
400ec5ae7f8f move FrechetDeriv from the Library to HOL/Deriv; base DERIV on FDERIV and both derivatives allow a restricted support set; FDERIV is now an abbreviation of has_derivative
hoelzl
parents: 51641
diff changeset
  1800
          done
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1801
        have **: "bounded_linear (\<lambda>x. f' u x - f' a x)" "bounded_linear (\<lambda>x. f' a x - f' u x)"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1802
          apply (rule_tac[!] bounded_linear_sub)
56369
2704ca85be98 moved generic theorems from Complex_Analysis_Basic; fixed some theorem names
hoelzl
parents: 56332
diff changeset
  1803
          apply (rule_tac[!] has_derivative_bounded_linear)
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
  1804
          using assms(5) \<open>u \<in> s\<close> \<open>a \<in> s\<close>
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1805
          apply auto
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1806
          done
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1807
        have "onorm (\<lambda>v. v - g' (f' u v)) \<le> onorm g' * onorm (\<lambda>w. f' a w - f' u w)"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1808
          unfolding *
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1809
          apply (rule onorm_compose)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1810
          apply (rule assms(3) **)+
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1811
          done
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1812
        also have "\<dots> \<le> onorm g' * k"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1813
          apply (rule mult_left_mono)
55665
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1814
          using d1(2)[of u]
56223
7696903b9e61 generalize theory of operator norms to work with class real_normed_vector
huffman
parents: 56217
diff changeset
  1815
          using onorm_neg[where f="\<lambda>x. f' u x - f' a x"]
7696903b9e61 generalize theory of operator norms to work with class real_normed_vector
huffman
parents: 56217
diff changeset
  1816
          using d and u and onorm_pos_le[OF assms(3)]
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1817
          apply (auto simp add: algebra_simps)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1818
          done
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1819
        also have "\<dots> \<le> 1 / 2"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1820
          unfolding k_def by auto
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1821
        finally show "onorm (\<lambda>v. v - g' (f' u v)) \<le> 1 / 2" .
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1822
      qed
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1823
      moreover have "norm (ph y - ph x) = norm (y - x)"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1824
        apply (rule arg_cong[where f=norm])
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1825
        unfolding ph_def
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1826
        using diff
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1827
        unfolding as
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1828
        apply auto
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1829
        done
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1830
      ultimately show "x = y"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1831
        unfolding norm_minus_commute by auto
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1832
    qed
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1833
  qed auto
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1834
qed
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  1835
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1836
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
  1837
subsection \<open>Uniformly convergent sequence of derivatives\<close>
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  1838
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1839
lemma has_derivative_sequence_lipschitz_lemma:
60179
d87c8c2d4938 generalized class constraints
immler
parents: 60178
diff changeset
  1840
  fixes f :: "nat \<Rightarrow> 'a::real_normed_vector \<Rightarrow> 'b::real_normed_vector"
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1841
  assumes "convex s"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1842
    and "\<forall>n. \<forall>x\<in>s. ((f n) has_derivative (f' n x)) (at x within s)"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1843
    and "\<forall>n\<ge>N. \<forall>x\<in>s. \<forall>h. norm (f' n x h - g' x h) \<le> e * norm h"
56271
61b1e3d88e91 generalized theorems about derivatives of limits of sequences of funtions
huffman
parents: 56264
diff changeset
  1844
    and "0 \<le> e"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1845
  shows "\<forall>m\<ge>N. \<forall>n\<ge>N. \<forall>x\<in>s. \<forall>y\<in>s. norm ((f m x - f n x) - (f m y - f n y)) \<le> 2 * e * norm (x - y)"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1846
proof rule+
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1847
  fix m n x y
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1848
  assume as: "N \<le> m" "N \<le> n" "x \<in> s" "y \<in> s"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1849
  show "norm ((f m x - f n x) - (f m y - f n y)) \<le> 2 * e * norm (x - y)"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1850
    apply (rule differentiable_bound[where f'="\<lambda>x h. f' m x h - f' n x h", OF assms(1) _ _ as(3-4)])
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1851
    apply (rule_tac[!] ballI)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1852
  proof -
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1853
    fix x
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1854
    assume "x \<in> s"
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1855
    show "((\<lambda>a. f m a - f n a) has_derivative (\<lambda>h. f' m x h - f' n x h)) (at x within s)"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
  1856
      by (rule derivative_intros assms(2)[rule_format] \<open>x\<in>s\<close>)+
56271
61b1e3d88e91 generalized theorems about derivatives of limits of sequences of funtions
huffman
parents: 56264
diff changeset
  1857
    show "onorm (\<lambda>h. f' m x h - f' n x h) \<le> 2 * e"
61b1e3d88e91 generalized theorems about derivatives of limits of sequences of funtions
huffman
parents: 56264
diff changeset
  1858
    proof (rule onorm_bound)
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1859
      fix h
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1860
      have "norm (f' m x h - f' n x h) \<le> norm (f' m x h - g' x h) + norm (f' n x h - g' x h)"
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1861
        using norm_triangle_ineq[of "f' m x h - g' x h" "- f' n x h + g' x h"]
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1862
        unfolding norm_minus_commute
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1863
        by (auto simp add: algebra_simps)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1864
      also have "\<dots> \<le> e * norm h + e * norm h"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
  1865
        using assms(3)[rule_format,OF \<open>N \<le> m\<close> \<open>x \<in> s\<close>, of h]
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
  1866
        using assms(3)[rule_format,OF \<open>N \<le> n\<close> \<open>x \<in> s\<close>, of h]
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1867
        by (auto simp add: field_simps)
56271
61b1e3d88e91 generalized theorems about derivatives of limits of sequences of funtions
huffman
parents: 56264
diff changeset
  1868
      finally show "norm (f' m x h - f' n x h) \<le> 2 * e * norm h"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1869
        by auto
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
  1870
    qed (simp add: \<open>0 \<le> e\<close>)
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1871
  qed
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1872
qed
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  1873
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1874
lemma has_derivative_sequence_lipschitz:
60179
d87c8c2d4938 generalized class constraints
immler
parents: 60178
diff changeset
  1875
  fixes f :: "nat \<Rightarrow> 'a::real_normed_vector \<Rightarrow> 'b::real_normed_vector"
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1876
  assumes "convex s"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1877
    and "\<forall>n. \<forall>x\<in>s. ((f n) has_derivative (f' n x)) (at x within s)"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1878
    and "\<forall>e>0. \<exists>N. \<forall>n\<ge>N. \<forall>x\<in>s. \<forall>h. norm (f' n x h - g' x h) \<le> e * norm h"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1879
  shows "\<forall>e>0. \<exists>N. \<forall>m\<ge>N. \<forall>n\<ge>N. \<forall>x\<in>s. \<forall>y\<in>s.
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1880
    norm ((f m x - f n x) - (f m y - f n y)) \<le> e * norm (x - y)"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1881
proof (rule, rule)
61165
8020249565fb tuned proofs;
wenzelm
parents: 61104
diff changeset
  1882
  fix e :: real
8020249565fb tuned proofs;
wenzelm
parents: 61104
diff changeset
  1883
  assume "e > 0"
8020249565fb tuned proofs;
wenzelm
parents: 61104
diff changeset
  1884
  then have *: "2 * (1/2* e) = e" "1/2 * e >0"
8020249565fb tuned proofs;
wenzelm
parents: 61104
diff changeset
  1885
    by auto
55665
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1886
  obtain N where "\<forall>n\<ge>N. \<forall>x\<in>s. \<forall>h. norm (f' n x h - g' x h) \<le> 1 / 2 * e * norm h"
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1887
    using assms(3) *(2) by blast
61165
8020249565fb tuned proofs;
wenzelm
parents: 61104
diff changeset
  1888
  then show "\<exists>N. \<forall>m\<ge>N. \<forall>n\<ge>N. \<forall>x\<in>s. \<forall>y\<in>s. norm (f m x - f n x - (f m y - f n y)) \<le> e * norm (x - y)"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1889
    apply (rule_tac x=N in exI)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1890
    apply (rule has_derivative_sequence_lipschitz_lemma[where e="1/2 *e", unfolded *])
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
  1891
    using assms \<open>e > 0\<close>
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1892
    apply auto
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1893
    done
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1894
qed
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  1895
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1896
lemma has_derivative_sequence:
60179
d87c8c2d4938 generalized class constraints
immler
parents: 60178
diff changeset
  1897
  fixes f :: "nat \<Rightarrow> 'a::real_normed_vector \<Rightarrow> 'b::banach"
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1898
  assumes "convex s"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1899
    and "\<forall>n. \<forall>x\<in>s. ((f n) has_derivative (f' n x)) (at x within s)"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1900
    and "\<forall>e>0. \<exists>N. \<forall>n\<ge>N. \<forall>x\<in>s. \<forall>h. norm (f' n x h - g' x h) \<le> e * norm h"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1901
    and "x0 \<in> s"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1902
    and "((\<lambda>n. f n x0) ---> l) sequentially"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1903
  shows "\<exists>g. \<forall>x\<in>s. ((\<lambda>n. f n x) ---> g x) sequentially \<and> (g has_derivative g'(x)) (at x within s)"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1904
proof -
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1905
  have lem1: "\<forall>e>0. \<exists>N. \<forall>m\<ge>N. \<forall>n\<ge>N. \<forall>x\<in>s. \<forall>y\<in>s.
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1906
      norm ((f m x - f n x) - (f m y - f n y)) \<le> e * norm (x - y)"
56320
e84c12d4a886 tuned proofs
huffman
parents: 56271
diff changeset
  1907
    using assms(1,2,3) by (rule has_derivative_sequence_lipschitz)
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1908
  have "\<exists>g. \<forall>x\<in>s. ((\<lambda>n. f n x) ---> g x) sequentially"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1909
    apply (rule bchoice)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1910
    unfolding convergent_eq_cauchy
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1911
  proof
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1912
    fix x
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1913
    assume "x \<in> s"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1914
    show "Cauchy (\<lambda>n. f n x)"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1915
    proof (cases "x = x0")
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1916
      case True
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1917
      then show ?thesis
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1918
        using LIMSEQ_imp_Cauchy[OF assms(5)] by auto
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1919
    next
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1920
      case False
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1921
      show ?thesis
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1922
        unfolding Cauchy_def
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1923
      proof (rule, rule)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1924
        fix e :: real
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1925
        assume "e > 0"
56541
0e3abadbef39 made divide_pos_pos a simp rule
nipkow
parents: 56445
diff changeset
  1926
        hence *: "e / 2 > 0" "e / 2 / norm (x - x0) > 0" using False by auto
55665
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1927
        obtain M where M: "\<forall>m\<ge>M. \<forall>n\<ge>M. dist (f m x0) (f n x0) < e / 2"
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1928
          using LIMSEQ_imp_Cauchy[OF assms(5)]
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1929
          unfolding Cauchy_def
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1930
          using *(1) by blast
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1931
        obtain N where N:
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1932
          "\<forall>m\<ge>N. \<forall>n\<ge>N.
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1933
            \<forall>xa\<in>s. \<forall>y\<in>s. norm (f m xa - f n xa - (f m y - f n y)) \<le>
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1934
              e / 2 / norm (x - x0) * norm (xa - y)"
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1935
        using lem1 *(2) by blast
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1936
        show "\<exists>M. \<forall>m\<ge>M. \<forall>n\<ge>M. dist (f m x) (f n x) < e"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1937
          apply (rule_tac x="max M N" in exI)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1938
        proof rule+
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1939
          fix m n
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1940
          assume as: "max M N \<le>m" "max M N\<le>n"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1941
          have "dist (f m x) (f n x) \<le>
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1942
              norm (f m x0 - f n x0) + norm (f m x - f n x - (f m x0 - f n x0))"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1943
            unfolding dist_norm
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1944
            by (rule norm_triangle_sub)
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1945
          also have "\<dots> \<le> norm (f m x0 - f n x0) + e / 2"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
  1946
            using N[rule_format,OF _ _ \<open>x\<in>s\<close> \<open>x0\<in>s\<close>, of m n] and as and False
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1947
            by auto
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1948
          also have "\<dots> < e / 2 + e / 2"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1949
            apply (rule add_strict_right_mono)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1950
            using as and M[rule_format]
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1951
            unfolding dist_norm
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1952
            apply auto
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1953
            done
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1954
          finally show "dist (f m x) (f n x) < e"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1955
            by auto
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1956
        qed
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1957
      qed
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1958
    qed
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1959
  qed
55665
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1960
  then obtain g where g: "\<forall>x\<in>s. (\<lambda>n. f n x) ----> g x" ..
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1961
  have lem2: "\<forall>e>0. \<exists>N. \<forall>n\<ge>N. \<forall>x\<in>s. \<forall>y\<in>s. norm ((f n x - f n y) - (g x - g y)) \<le> e * norm (x - y)"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1962
  proof (rule, rule)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1963
    fix e :: real
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1964
    assume *: "e > 0"
55665
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1965
    obtain N where
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1966
      N: "\<forall>m\<ge>N. \<forall>n\<ge>N. \<forall>x\<in>s. \<forall>y\<in>s. norm (f m x - f n x - (f m y - f n y)) \<le> e * norm (x - y)"
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  1967
      using lem1 * by blast
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1968
    show "\<exists>N. \<forall>n\<ge>N. \<forall>x\<in>s. \<forall>y\<in>s. norm (f n x - f n y - (g x - g y)) \<le> e * norm (x - y)"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1969
      apply (rule_tac x=N in exI)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1970
    proof rule+
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1971
      fix n x y
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1972
      assume as: "N \<le> n" "x \<in> s" "y \<in> s"
56320
e84c12d4a886 tuned proofs
huffman
parents: 56271
diff changeset
  1973
      have "((\<lambda>m. norm (f n x - f n y - (f m x - f m y))) ---> norm (f n x - f n y - (g x - g y))) sequentially"
e84c12d4a886 tuned proofs
huffman
parents: 56271
diff changeset
  1974
        by (intro tendsto_intros g[rule_format] as)
e84c12d4a886 tuned proofs
huffman
parents: 56271
diff changeset
  1975
      moreover have "eventually (\<lambda>m. norm (f n x - f n y - (f m x - f m y)) \<le> e * norm (x - y)) sequentially"
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1976
        unfolding eventually_sequentially
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1977
        apply (rule_tac x=N in exI)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1978
        apply rule
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1979
        apply rule
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1980
      proof -
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1981
        fix m
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1982
        assume "N \<le> m"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1983
        then show "norm (f n x - f n y - (f m x - f m y)) \<le> e * norm (x - y)"
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1984
          using N[rule_format, of n m x y] and as
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1985
          by (auto simp add: algebra_simps)
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1986
      qed
56320
e84c12d4a886 tuned proofs
huffman
parents: 56271
diff changeset
  1987
      ultimately show "norm (f n x - f n y - (g x - g y)) \<le> e * norm (x - y)"
e84c12d4a886 tuned proofs
huffman
parents: 56271
diff changeset
  1988
        by (rule tendsto_ge_const[OF trivial_limit_sequentially])
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1989
    qed
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  1990
  qed
56320
e84c12d4a886 tuned proofs
huffman
parents: 56271
diff changeset
  1991
  have "\<forall>x\<in>s. ((\<lambda>n. f n x) ---> g x) sequentially \<and> (g has_derivative g' x) (at x within s)"
e84c12d4a886 tuned proofs
huffman
parents: 56271
diff changeset
  1992
    unfolding has_derivative_within_alt2
e84c12d4a886 tuned proofs
huffman
parents: 56271
diff changeset
  1993
  proof (intro ballI conjI)
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1994
    fix x
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1995
    assume "x \<in> s"
56320
e84c12d4a886 tuned proofs
huffman
parents: 56271
diff changeset
  1996
    then show "((\<lambda>n. f n x) ---> g x) sequentially"
e84c12d4a886 tuned proofs
huffman
parents: 56271
diff changeset
  1997
      by (simp add: g)
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  1998
    have lem3: "\<forall>u. ((\<lambda>n. f' n x u) ---> g' x u) sequentially"
56320
e84c12d4a886 tuned proofs
huffman
parents: 56271
diff changeset
  1999
      unfolding filterlim_def le_nhds_metric_le eventually_filtermap dist_norm
e84c12d4a886 tuned proofs
huffman
parents: 56271
diff changeset
  2000
    proof (intro allI impI)
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2001
      fix u
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2002
      fix e :: real
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2003
      assume "e > 0"
56320
e84c12d4a886 tuned proofs
huffman
parents: 56271
diff changeset
  2004
      show "eventually (\<lambda>n. norm (f' n x u - g' x u) \<le> e) sequentially"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2005
      proof (cases "u = 0")
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2006
        case True
56320
e84c12d4a886 tuned proofs
huffman
parents: 56271
diff changeset
  2007
        have "eventually (\<lambda>n. norm (f' n x u - g' x u) \<le> e * norm u) sequentially"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
  2008
          using assms(3)[folded eventually_sequentially] and \<open>0 < e\<close> and \<open>x \<in> s\<close>
61810
3c5040d5694a sorted out eventually_mono
paulson <lp15@cam.ac.uk>
parents: 61808
diff changeset
  2009
          by (fast elim: eventually_mono)
56320
e84c12d4a886 tuned proofs
huffman
parents: 56271
diff changeset
  2010
        then show ?thesis
61810
3c5040d5694a sorted out eventually_mono
paulson <lp15@cam.ac.uk>
parents: 61808
diff changeset
  2011
          using \<open>u = 0\<close> and \<open>0 < e\<close> by (auto elim: eventually_mono)
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  2012
      next
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2013
        case False
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
  2014
        with \<open>0 < e\<close> have "0 < e / norm u" by simp
56320
e84c12d4a886 tuned proofs
huffman
parents: 56271
diff changeset
  2015
        then have "eventually (\<lambda>n. norm (f' n x u - g' x u) \<le> e / norm u * norm u) sequentially"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
  2016
          using assms(3)[folded eventually_sequentially] and \<open>x \<in> s\<close>
61810
3c5040d5694a sorted out eventually_mono
paulson <lp15@cam.ac.uk>
parents: 61808
diff changeset
  2017
          by (fast elim: eventually_mono)
56320
e84c12d4a886 tuned proofs
huffman
parents: 56271
diff changeset
  2018
        then show ?thesis
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
  2019
          using \<open>u \<noteq> 0\<close> by simp
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  2020
      qed
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  2021
    qed
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  2022
    show "bounded_linear (g' x)"
56271
61b1e3d88e91 generalized theorems about derivatives of limits of sequences of funtions
huffman
parents: 56264
diff changeset
  2023
    proof
61b1e3d88e91 generalized theorems about derivatives of limits of sequences of funtions
huffman
parents: 56264
diff changeset
  2024
      fix x' y z :: 'a
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2025
      fix c :: real
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
  2026
      note lin = assms(2)[rule_format,OF \<open>x\<in>s\<close>,THEN has_derivative_bounded_linear]
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  2027
      show "g' x (c *\<^sub>R x') = c *\<^sub>R g' x x'"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2028
        apply (rule tendsto_unique[OF trivial_limit_sequentially])
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2029
        apply (rule lem3[rule_format])
56369
2704ca85be98 moved generic theorems from Complex_Analysis_Basic; fixed some theorem names
hoelzl
parents: 56332
diff changeset
  2030
        unfolding lin[THEN bounded_linear.linear, THEN linear_cmul]
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2031
        apply (intro tendsto_intros)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2032
        apply (rule lem3[rule_format])
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2033
        done
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  2034
      show "g' x (y + z) = g' x y + g' x z"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2035
        apply (rule tendsto_unique[OF trivial_limit_sequentially])
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2036
        apply (rule lem3[rule_format])
56369
2704ca85be98 moved generic theorems from Complex_Analysis_Basic; fixed some theorem names
hoelzl
parents: 56332
diff changeset
  2037
        unfolding lin[THEN bounded_linear.linear, THEN linear_add]
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2038
        apply (rule tendsto_add)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2039
        apply (rule lem3[rule_format])+
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2040
        done
56271
61b1e3d88e91 generalized theorems about derivatives of limits of sequences of funtions
huffman
parents: 56264
diff changeset
  2041
      obtain N where N: "\<forall>h. norm (f' N x h - g' x h) \<le> 1 * norm h"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
  2042
        using assms(3) \<open>x \<in> s\<close> by (fast intro: zero_less_one)
56271
61b1e3d88e91 generalized theorems about derivatives of limits of sequences of funtions
huffman
parents: 56264
diff changeset
  2043
      have "bounded_linear (f' N x)"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
  2044
        using assms(2) \<open>x \<in> s\<close> by fast
56271
61b1e3d88e91 generalized theorems about derivatives of limits of sequences of funtions
huffman
parents: 56264
diff changeset
  2045
      from bounded_linear.bounded [OF this]
61b1e3d88e91 generalized theorems about derivatives of limits of sequences of funtions
huffman
parents: 56264
diff changeset
  2046
      obtain K where K: "\<forall>h. norm (f' N x h) \<le> norm h * K" ..
61b1e3d88e91 generalized theorems about derivatives of limits of sequences of funtions
huffman
parents: 56264
diff changeset
  2047
      {
61b1e3d88e91 generalized theorems about derivatives of limits of sequences of funtions
huffman
parents: 56264
diff changeset
  2048
        fix h
61b1e3d88e91 generalized theorems about derivatives of limits of sequences of funtions
huffman
parents: 56264
diff changeset
  2049
        have "norm (g' x h) = norm (f' N x h - (f' N x h - g' x h))"
61b1e3d88e91 generalized theorems about derivatives of limits of sequences of funtions
huffman
parents: 56264
diff changeset
  2050
          by simp
61b1e3d88e91 generalized theorems about derivatives of limits of sequences of funtions
huffman
parents: 56264
diff changeset
  2051
        also have "\<dots> \<le> norm (f' N x h) + norm (f' N x h - g' x h)"
61b1e3d88e91 generalized theorems about derivatives of limits of sequences of funtions
huffman
parents: 56264
diff changeset
  2052
          by (rule norm_triangle_ineq4)
61b1e3d88e91 generalized theorems about derivatives of limits of sequences of funtions
huffman
parents: 56264
diff changeset
  2053
        also have "\<dots> \<le> norm h * K + 1 * norm h"
61b1e3d88e91 generalized theorems about derivatives of limits of sequences of funtions
huffman
parents: 56264
diff changeset
  2054
          using N K by (fast intro: add_mono)
61b1e3d88e91 generalized theorems about derivatives of limits of sequences of funtions
huffman
parents: 56264
diff changeset
  2055
        finally have "norm (g' x h) \<le> norm h * (K + 1)"
61b1e3d88e91 generalized theorems about derivatives of limits of sequences of funtions
huffman
parents: 56264
diff changeset
  2056
          by (simp add: ring_distribs)
61b1e3d88e91 generalized theorems about derivatives of limits of sequences of funtions
huffman
parents: 56264
diff changeset
  2057
      }
61b1e3d88e91 generalized theorems about derivatives of limits of sequences of funtions
huffman
parents: 56264
diff changeset
  2058
      then show "\<exists>K. \<forall>h. norm (g' x h) \<le> norm h * K" by fast
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  2059
    qed
56320
e84c12d4a886 tuned proofs
huffman
parents: 56271
diff changeset
  2060
    show "\<forall>e>0. eventually (\<lambda>y. norm (g y - g x - g' x (y - x)) \<le> e * norm (y - x)) (at x within s)"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2061
    proof (rule, rule)
61165
8020249565fb tuned proofs;
wenzelm
parents: 61104
diff changeset
  2062
      fix e :: real
8020249565fb tuned proofs;
wenzelm
parents: 61104
diff changeset
  2063
      assume "e > 0"
8020249565fb tuned proofs;
wenzelm
parents: 61104
diff changeset
  2064
      then have *: "e / 3 > 0"
8020249565fb tuned proofs;
wenzelm
parents: 61104
diff changeset
  2065
        by auto
55665
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  2066
      obtain N1 where N1: "\<forall>n\<ge>N1. \<forall>x\<in>s. \<forall>h. norm (f' n x h - g' x h) \<le> e / 3 * norm h"
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  2067
        using assms(3) * by blast
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  2068
      obtain N2 where
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  2069
          N2: "\<forall>n\<ge>N2. \<forall>x\<in>s. \<forall>y\<in>s. norm (f n x - f n y - (g x - g y)) \<le> e / 3 * norm (x - y)"
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  2070
        using lem2 * by blast
56320
e84c12d4a886 tuned proofs
huffman
parents: 56271
diff changeset
  2071
      let ?N = "max N1 N2"
e84c12d4a886 tuned proofs
huffman
parents: 56271
diff changeset
  2072
      have "eventually (\<lambda>y. norm (f ?N y - f ?N x - f' ?N x (y - x)) \<le> e / 3 * norm (y - x)) (at x within s)"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
  2073
        using assms(2)[unfolded has_derivative_within_alt2] and \<open>x \<in> s\<close> and * by fast
56320
e84c12d4a886 tuned proofs
huffman
parents: 56271
diff changeset
  2074
      moreover have "eventually (\<lambda>y. y \<in> s) (at x within s)"
e84c12d4a886 tuned proofs
huffman
parents: 56271
diff changeset
  2075
        unfolding eventually_at by (fast intro: zero_less_one)
61165
8020249565fb tuned proofs;
wenzelm
parents: 61104
diff changeset
  2076
      ultimately show "\<forall>\<^sub>F y in at x within s. norm (g y - g x - g' x (y - x)) \<le> e * norm (y - x)"
56320
e84c12d4a886 tuned proofs
huffman
parents: 56271
diff changeset
  2077
      proof (rule eventually_elim2)
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2078
        fix y
56320
e84c12d4a886 tuned proofs
huffman
parents: 56271
diff changeset
  2079
        assume "y \<in> s"
e84c12d4a886 tuned proofs
huffman
parents: 56271
diff changeset
  2080
        assume "norm (f ?N y - f ?N x - f' ?N x (y - x)) \<le> e / 3 * norm (y - x)"
e84c12d4a886 tuned proofs
huffman
parents: 56271
diff changeset
  2081
        moreover have "norm (g y - g x - (f ?N y - f ?N x)) \<le> e / 3 * norm (y - x)"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
  2082
          using N2[rule_format, OF _ \<open>y \<in> s\<close> \<open>x \<in> s\<close>]
56320
e84c12d4a886 tuned proofs
huffman
parents: 56271
diff changeset
  2083
          by (simp add: norm_minus_commute)
e84c12d4a886 tuned proofs
huffman
parents: 56271
diff changeset
  2084
        ultimately have "norm (g y - g x - f' ?N x (y - x)) \<le> 2 * e / 3 * norm (y - x)"
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  2085
          using norm_triangle_le[of "g y - g x - (f ?N y - f ?N x)" "f ?N y - f ?N x - f' ?N x (y - x)" "2 * e / 3 * norm (y - x)"]
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2086
          by (auto simp add: algebra_simps)
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  2087
        moreover
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  2088
        have " norm (f' ?N x (y - x) - g' x (y - x)) \<le> e / 3 * norm (y - x)"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
  2089
          using N1 \<open>x \<in> s\<close> by auto
41958
5abc60a017e0 eliminated hard tabs;
wenzelm
parents: 41829
diff changeset
  2090
        ultimately show "norm (g y - g x - g' x (y - x)) \<le> e * norm (y - x)"
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  2091
          using norm_triangle_le[of "g y - g x - f' (max N1 N2) x (y - x)" "f' (max N1 N2) x (y - x) - g' x (y - x)"]
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2092
          by (auto simp add: algebra_simps)
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  2093
      qed
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  2094
    qed
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  2095
  qed
56320
e84c12d4a886 tuned proofs
huffman
parents: 56271
diff changeset
  2096
  then show ?thesis by fast
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  2097
qed
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  2098
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
  2099
text \<open>Can choose to line up antiderivatives if we want.\<close>
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  2100
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  2101
lemma has_antiderivative_sequence:
60179
d87c8c2d4938 generalized class constraints
immler
parents: 60178
diff changeset
  2102
  fixes f :: "nat \<Rightarrow> 'a::real_normed_vector \<Rightarrow> 'b::banach"
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  2103
  assumes "convex s"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2104
    and "\<forall>n. \<forall>x\<in>s. ((f n) has_derivative (f' n x)) (at x within s)"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2105
    and "\<forall>e>0. \<exists>N. \<forall>n\<ge>N. \<forall>x\<in>s. \<forall>h. norm (f' n x h - g' x h) \<le> e * norm h"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2106
  shows "\<exists>g. \<forall>x\<in>s. (g has_derivative g' x) (at x within s)"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2107
proof (cases "s = {}")
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2108
  case False
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2109
  then obtain a where "a \<in> s"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2110
    by auto
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2111
  have *: "\<And>P Q. \<exists>g. \<forall>x\<in>s. P g x \<and> Q g x \<Longrightarrow> \<exists>g. \<forall>x\<in>s. Q g x"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2112
    by auto
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  2113
  show ?thesis
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2114
    apply (rule *)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2115
    apply (rule has_derivative_sequence[OF assms(1) _ assms(3), of "\<lambda>n x. f n x + (f 0 a - f n a)"])
55970
6d123f0ae358 Some new proofs. Tidying up, esp to remove "apply rule".
paulson <lp15@cam.ac.uk>
parents: 55665
diff changeset
  2116
    apply (metis assms(2) has_derivative_add_const)
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
  2117
    apply (rule \<open>a \<in> s\<close>)
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2118
    apply auto
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2119
    done
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  2120
qed auto
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  2121
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  2122
lemma has_antiderivative_limit:
60179
d87c8c2d4938 generalized class constraints
immler
parents: 60178
diff changeset
  2123
  fixes g' :: "'a::real_normed_vector \<Rightarrow> 'a \<Rightarrow> 'b::banach"
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  2124
  assumes "convex s"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2125
    and "\<forall>e>0. \<exists>f f'. \<forall>x\<in>s.
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2126
      (f has_derivative (f' x)) (at x within s) \<and> (\<forall>h. norm (f' x h - g' x h) \<le> e * norm h)"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2127
  shows "\<exists>g. \<forall>x\<in>s. (g has_derivative g' x) (at x within s)"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2128
proof -
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2129
  have *: "\<forall>n. \<exists>f f'. \<forall>x\<in>s.
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2130
    (f has_derivative (f' x)) (at x within s) \<and>
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2131
    (\<forall>h. norm(f' x h - g' x h) \<le> inverse (real (Suc n)) * norm h)"
61649
268d88ec9087 Tweaks for "real": Removal of [iff] status for some lemmas, adding [simp] for others. Plus fixes.
paulson <lp15@cam.ac.uk>
parents: 61560
diff changeset
  2132
    by (simp add: assms(2))
55665
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  2133
  obtain f where
56181
2aa0b19e74f3 unify syntax for has_derivative and differentiable
hoelzl
parents: 56151
diff changeset
  2134
    *: "\<forall>x. \<exists>f'. \<forall>xa\<in>s. (f x has_derivative f' xa) (at xa within s) \<and>
55665
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  2135
      (\<forall>h. norm (f' xa h - g' xa h) \<le> inverse (real (Suc x)) * norm h)"
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  2136
    using *[THEN choice] ..
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  2137
  obtain f' where
56181
2aa0b19e74f3 unify syntax for has_derivative and differentiable
hoelzl
parents: 56151
diff changeset
  2138
    f: "\<forall>x. \<forall>xa\<in>s. (f x has_derivative f' x xa) (at xa within s) \<and>
55665
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  2139
      (\<forall>h. norm (f' x xa h - g' xa h) \<le> inverse (real (Suc x)) * norm h)"
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  2140
    using *[THEN choice] ..
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2141
  show ?thesis
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2142
    apply (rule has_antiderivative_sequence[OF assms(1), of f f'])
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2143
    defer
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2144
    apply rule
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2145
    apply rule
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2146
  proof -
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2147
    fix e :: real
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2148
    assume "e > 0"
55665
4381a2b622ea tuned proofs;
wenzelm
parents: 54775
diff changeset
  2149
    obtain N where N: "inverse (real (Suc N)) < e"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
  2150
      using reals_Archimedean[OF \<open>e>0\<close>] ..
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  2151
    show "\<exists>N. \<forall>n\<ge>N. \<forall>x\<in>s. \<forall>h. norm (f' n x h - g' x h) \<le> e * norm h"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2152
      apply (rule_tac x=N in exI)
61165
8020249565fb tuned proofs;
wenzelm
parents: 61104
diff changeset
  2153
      apply rule
8020249565fb tuned proofs;
wenzelm
parents: 61104
diff changeset
  2154
      apply rule
8020249565fb tuned proofs;
wenzelm
parents: 61104
diff changeset
  2155
      apply rule
8020249565fb tuned proofs;
wenzelm
parents: 61104
diff changeset
  2156
      apply rule
8020249565fb tuned proofs;
wenzelm
parents: 61104
diff changeset
  2157
    proof -
8020249565fb tuned proofs;
wenzelm
parents: 61104
diff changeset
  2158
      fix n x h
8020249565fb tuned proofs;
wenzelm
parents: 61104
diff changeset
  2159
      assume n: "N \<le> n" and x: "x \<in> s"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2160
      have *: "inverse (real (Suc n)) \<le> e"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2161
        apply (rule order_trans[OF _ N[THEN less_imp_le]])
61165
8020249565fb tuned proofs;
wenzelm
parents: 61104
diff changeset
  2162
        using n
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2163
        apply (auto simp add: field_simps)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2164
        done
61165
8020249565fb tuned proofs;
wenzelm
parents: 61104
diff changeset
  2165
      show "norm (f' n x h - g' x h) \<le> e * norm h"
8020249565fb tuned proofs;
wenzelm
parents: 61104
diff changeset
  2166
        using f[rule_format,THEN conjunct2, OF x, of n, THEN spec[where x=h]]
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2167
        apply (rule order_trans)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2168
        using N *
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2169
        apply (cases "h = 0")
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2170
        apply auto
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2171
        done
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  2172
    qed
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2173
  qed (insert f, auto)
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  2174
qed
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  2175
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2176
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
  2177
subsection \<open>Differentiation of a series\<close>
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  2178
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  2179
lemma has_derivative_series:
60179
d87c8c2d4938 generalized class constraints
immler
parents: 60178
diff changeset
  2180
  fixes f :: "nat \<Rightarrow> 'a::real_normed_vector \<Rightarrow> 'b::banach"
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  2181
  assumes "convex s"
56183
f998bdd40763 remove sums_seq, it is not used
hoelzl
parents: 56182
diff changeset
  2182
    and "\<And>n x. x \<in> s \<Longrightarrow> ((f n) has_derivative (f' n x)) (at x within s)"
56193
c726ecfb22b6 cleanup Series: sorted according to typeclass hierarchy, use {..<_} instead of {0..<_}
hoelzl
parents: 56188
diff changeset
  2183
    and "\<forall>e>0. \<exists>N. \<forall>n\<ge>N. \<forall>x\<in>s. \<forall>h. norm (setsum (\<lambda>i. f' i x h) {..<n} - g' x h) \<le> e * norm h"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2184
    and "x \<in> s"
56183
f998bdd40763 remove sums_seq, it is not used
hoelzl
parents: 56182
diff changeset
  2185
    and "(\<lambda>n. f n x) sums l"
f998bdd40763 remove sums_seq, it is not used
hoelzl
parents: 56182
diff changeset
  2186
  shows "\<exists>g. \<forall>x\<in>s. (\<lambda>n. f n x) sums (g x) \<and> (g has_derivative g' x) (at x within s)"
f998bdd40763 remove sums_seq, it is not used
hoelzl
parents: 56182
diff changeset
  2187
  unfolding sums_def
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2188
  apply (rule has_derivative_sequence[OF assms(1) _ assms(3)])
55970
6d123f0ae358 Some new proofs. Tidying up, esp to remove "apply rule".
paulson <lp15@cam.ac.uk>
parents: 55665
diff changeset
  2189
  apply (metis assms(2) has_derivative_setsum)
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2190
  using assms(4-5)
56183
f998bdd40763 remove sums_seq, it is not used
hoelzl
parents: 56182
diff changeset
  2191
  unfolding sums_def
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2192
  apply auto
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2193
  done
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  2194
61531
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2195
lemma has_field_derivative_series:
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2196
  fixes f :: "nat \<Rightarrow> ('a :: {real_normed_field,banach}) \<Rightarrow> 'a"
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2197
  assumes "convex s"
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2198
  assumes "\<And>n x. x \<in> s \<Longrightarrow> (f n has_field_derivative f' n x) (at x within s)"
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2199
  assumes "uniform_limit s (\<lambda>n x. \<Sum>i<n. f' i x) g' sequentially"
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2200
  assumes "x0 \<in> s" "summable (\<lambda>n. f n x0)"
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2201
  shows   "\<exists>g. \<forall>x\<in>s. (\<lambda>n. f n x) sums g x \<and> (g has_field_derivative g' x) (at x within s)"
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2202
unfolding has_field_derivative_def
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2203
proof (rule has_derivative_series)
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2204
  show "\<forall>e>0. \<exists>N. \<forall>n\<ge>N. \<forall>x\<in>s. \<forall>h. norm ((\<Sum>i<n. f' i x * h) - g' x * h) \<le> e * norm h"
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2205
  proof (intro allI impI)
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2206
    fix e :: real assume "e > 0"
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2207
    with assms(3) obtain N where N: "\<And>n x. n \<ge> N \<Longrightarrow> x \<in> s \<Longrightarrow> norm ((\<Sum>i<n. f' i x) - g' x) < e"
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2208
      unfolding uniform_limit_iff eventually_at_top_linorder dist_norm by blast
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2209
    {
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2210
      fix n :: nat and x h :: 'a assume nx: "n \<ge> N" "x \<in> s"
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2211
      have "norm ((\<Sum>i<n. f' i x * h) - g' x * h) = norm ((\<Sum>i<n. f' i x) - g' x) * norm h"
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2212
        by (simp add: norm_mult [symmetric] ring_distribs setsum_left_distrib)
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2213
      also from N[OF nx] have "norm ((\<Sum>i<n. f' i x) - g' x) \<le> e" by simp
61649
268d88ec9087 Tweaks for "real": Removal of [iff] status for some lemmas, adding [simp] for others. Plus fixes.
paulson <lp15@cam.ac.uk>
parents: 61560
diff changeset
  2214
      hence "norm ((\<Sum>i<n. f' i x) - g' x) * norm h \<le> e * norm h"
61531
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2215
        by (intro mult_right_mono) simp_all
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2216
      finally have "norm ((\<Sum>i<n. f' i x * h) - g' x * h) \<le> e * norm h" .
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2217
    }
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2218
    thus "\<exists>N. \<forall>n\<ge>N. \<forall>x\<in>s. \<forall>h. norm ((\<Sum>i<n. f' i x * h) - g' x * h) \<le> e * norm h" by blast
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2219
  qed
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2220
qed (insert assms, auto simp: has_field_derivative_def)
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2221
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2222
lemma has_field_derivative_series':
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2223
  fixes f :: "nat \<Rightarrow> ('a :: {real_normed_field,banach}) \<Rightarrow> 'a"
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2224
  assumes "convex s"
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2225
  assumes "\<And>n x. x \<in> s \<Longrightarrow> (f n has_field_derivative f' n x) (at x within s)"
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2226
  assumes "uniformly_convergent_on s (\<lambda>n x. \<Sum>i<n. f' i x)"
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2227
  assumes "x0 \<in> s" "summable (\<lambda>n. f n x0)" "x \<in> interior s"
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2228
  shows   "summable (\<lambda>n. f n x)" "((\<lambda>x. \<Sum>n. f n x) has_field_derivative (\<Sum>n. f' n x)) (at x)"
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2229
proof -
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2230
  from \<open>x \<in> interior s\<close> have "x \<in> s" using interior_subset by blast
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2231
  def g' \<equiv> "\<lambda>x. \<Sum>i. f' i x"
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2232
  from assms(3) have "uniform_limit s (\<lambda>n x. \<Sum>i<n. f' i x) g' sequentially"
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2233
    by (simp add: uniformly_convergent_uniform_limit_iff suminf_eq_lim g'_def)
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2234
  from has_field_derivative_series[OF assms(1,2) this assms(4,5)] obtain g where g:
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2235
    "\<And>x. x \<in> s \<Longrightarrow> (\<lambda>n. f n x) sums g x"
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2236
    "\<And>x. x \<in> s \<Longrightarrow> (g has_field_derivative g' x) (at x within s)" by blast
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2237
  from g(1)[OF \<open>x \<in> s\<close>] show "summable (\<lambda>n. f n x)" by (simp add: sums_iff)
61649
268d88ec9087 Tweaks for "real": Removal of [iff] status for some lemmas, adding [simp] for others. Plus fixes.
paulson <lp15@cam.ac.uk>
parents: 61560
diff changeset
  2238
  from g(2)[OF \<open>x \<in> s\<close>] \<open>x \<in> interior s\<close> have "(g has_field_derivative g' x) (at x)"
61531
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2239
    by (simp add: at_within_interior[of x s])
61649
268d88ec9087 Tweaks for "real": Removal of [iff] status for some lemmas, adding [simp] for others. Plus fixes.
paulson <lp15@cam.ac.uk>
parents: 61560
diff changeset
  2240
  also have "(g has_field_derivative g' x) (at x) \<longleftrightarrow>
61531
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2241
                ((\<lambda>x. \<Sum>n. f n x) has_field_derivative g' x) (at x)"
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2242
    using eventually_nhds_in_nhd[OF \<open>x \<in> interior s\<close>] interior_subset[of s] g(1)
61810
3c5040d5694a sorted out eventually_mono
paulson <lp15@cam.ac.uk>
parents: 61808
diff changeset
  2243
    by (intro DERIV_cong_ev) (auto elim!: eventually_mono simp: sums_iff)
61531
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2244
  finally show "((\<lambda>x. \<Sum>n. f n x) has_field_derivative g' x) (at x)" .
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2245
qed
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2246
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2247
lemma differentiable_series:
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2248
  fixes f :: "nat \<Rightarrow> ('a :: {real_normed_field,banach}) \<Rightarrow> 'a"
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2249
  assumes "convex s" "open s"
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2250
  assumes "\<And>n x. x \<in> s \<Longrightarrow> (f n has_field_derivative f' n x) (at x)"
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2251
  assumes "uniformly_convergent_on s (\<lambda>n x. \<Sum>i<n. f' i x)"
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2252
  assumes "x0 \<in> s" "summable (\<lambda>n. f n x0)" and x: "x \<in> s"
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2253
  shows   "summable (\<lambda>n. f n x)" and "(\<lambda>x. \<Sum>n. f n x) differentiable (at x)"
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2254
proof -
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2255
  from assms(4) obtain g' where A: "uniform_limit s (\<lambda>n x. \<Sum>i<n. f' i x) g' sequentially"
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2256
    unfolding uniformly_convergent_on_def by blast
61808
fc1556774cfe isabelle update_cartouches -c -t;
wenzelm
parents: 61762
diff changeset
  2257
  from x and \<open>open s\<close> have s: "at x within s = at x" by (rule at_within_open)
61531
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2258
  have "\<exists>g. \<forall>x\<in>s. (\<lambda>n. f n x) sums g x \<and> (g has_field_derivative g' x) (at x within s)"
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2259
    by (intro has_field_derivative_series[of s f f' g' x0] assms A has_field_derivative_at_within)
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2260
  then obtain g where g: "\<And>x. x \<in> s \<Longrightarrow> (\<lambda>n. f n x) sums g x"
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2261
    "\<And>x. x \<in> s \<Longrightarrow> (g has_field_derivative g' x) (at x within s)" by blast
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2262
  from g[OF x] show "summable (\<lambda>n. f n x)" by (auto simp: summable_def)
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2263
  from g(2)[OF x] have g': "(g has_derivative op * (g' x)) (at x)"
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2264
    by (simp add: has_field_derivative_def s)
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2265
  have "((\<lambda>x. \<Sum>n. f n x) has_derivative op * (g' x)) (at x)"
61808
fc1556774cfe isabelle update_cartouches -c -t;
wenzelm
parents: 61762
diff changeset
  2266
    by (rule has_derivative_transform_within_open[OF \<open>open s\<close> x _ g'])
61531
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2267
       (insert g, auto simp: sums_iff)
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2268
  thus "(\<lambda>x. \<Sum>n. f n x) differentiable (at x)" unfolding differentiable_def
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2269
    by (auto simp: summable_def differentiable_def has_field_derivative_def)
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2270
qed
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2271
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2272
lemma differentiable_series':
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2273
  fixes f :: "nat \<Rightarrow> ('a :: {real_normed_field,banach}) \<Rightarrow> 'a"
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2274
  assumes "convex s" "open s"
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2275
  assumes "\<And>n x. x \<in> s \<Longrightarrow> (f n has_field_derivative f' n x) (at x)"
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2276
  assumes "uniformly_convergent_on s (\<lambda>n x. \<Sum>i<n. f' i x)"
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2277
  assumes "x0 \<in> s" "summable (\<lambda>n. f n x0)"
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2278
  shows   "(\<lambda>x. \<Sum>n. f n x) differentiable (at x0)"
61808
fc1556774cfe isabelle update_cartouches -c -t;
wenzelm
parents: 61762
diff changeset
  2279
  using differentiable_series[OF assms, of x0] \<open>x0 \<in> s\<close> by blast+
61531
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2280
61076
bdc1e2f0a86a eliminated \<Colon>;
wenzelm
parents: 60800
diff changeset
  2281
text \<open>Considering derivative @{typ "real \<Rightarrow> 'b::real_normed_vector"} as a vector.\<close>
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  2282
56381
0556204bc230 merged DERIV_intros, has_derivative_intros into derivative_intros
hoelzl
parents: 56371
diff changeset
  2283
definition "vector_derivative f net = (SOME f'. (f has_vector_derivative f') net)"
0556204bc230 merged DERIV_intros, has_derivative_intros into derivative_intros
hoelzl
parents: 56371
diff changeset
  2284
61245
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61204
diff changeset
  2285
lemma vector_derivative_unique_within:
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61204
diff changeset
  2286
  assumes not_bot: "at x within s \<noteq> bot"
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61204
diff changeset
  2287
    and f': "(f has_vector_derivative f') (at x within s)"
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61204
diff changeset
  2288
    and f'': "(f has_vector_derivative f'') (at x within s)"
37730
1a24950dae33 generalize some lemmas about derivatives
huffman
parents: 37650
diff changeset
  2289
  shows "f' = f''"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2290
proof -
37730
1a24950dae33 generalize some lemmas about derivatives
huffman
parents: 37650
diff changeset
  2291
  have "(\<lambda>x. x *\<^sub>R f') = (\<lambda>x. x *\<^sub>R f'')"
61245
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61204
diff changeset
  2292
  proof (rule frechet_derivative_unique_within)
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61204
diff changeset
  2293
    show "\<forall>i\<in>Basis. \<forall>e>0. \<exists>d. 0 < \<bar>d\<bar> \<and> \<bar>d\<bar> < e \<and> x + d *\<^sub>R i \<in> s"
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61204
diff changeset
  2294
    proof clarsimp
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61204
diff changeset
  2295
      fix e :: real assume "0 < e"
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61204
diff changeset
  2296
      with islimpt_approachable_real[of x s] not_bot
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61204
diff changeset
  2297
      obtain x' where "x' \<in> s" "x' \<noteq> x" "\<bar>x' - x\<bar> < e"
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61204
diff changeset
  2298
        by (auto simp add: trivial_limit_within)
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61204
diff changeset
  2299
      then show "\<exists>d. d \<noteq> 0 \<and> \<bar>d\<bar> < e \<and> x + d \<in> s"
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61204
diff changeset
  2300
        by (intro exI[of _ "x' - x"]) auto
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61204
diff changeset
  2301
    qed
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61204
diff changeset
  2302
  qed (insert f' f'', auto simp: has_vector_derivative_def)
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2303
  then show ?thesis
61649
268d88ec9087 Tweaks for "real": Removal of [iff] status for some lemmas, adding [simp] for others. Plus fixes.
paulson <lp15@cam.ac.uk>
parents: 61560
diff changeset
  2304
    unfolding fun_eq_iff by (metis scaleR_one)
37730
1a24950dae33 generalize some lemmas about derivatives
huffman
parents: 37650
diff changeset
  2305
qed
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  2306
61245
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61204
diff changeset
  2307
lemma vector_derivative_unique_at:
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61204
diff changeset
  2308
  "(f has_vector_derivative f') (at x) \<Longrightarrow> (f has_vector_derivative f'') (at x) \<Longrightarrow> f' = f''"
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61204
diff changeset
  2309
  by (rule vector_derivative_unique_within) auto
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61204
diff changeset
  2310
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61204
diff changeset
  2311
lemma differentiableI_vector: "(f has_vector_derivative y) F \<Longrightarrow> f differentiable F"
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61204
diff changeset
  2312
  by (auto simp: differentiable_def has_vector_derivative_def)
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61204
diff changeset
  2313
56381
0556204bc230 merged DERIV_intros, has_derivative_intros into derivative_intros
hoelzl
parents: 56371
diff changeset
  2314
lemma vector_derivative_works:
0556204bc230 merged DERIV_intros, has_derivative_intros into derivative_intros
hoelzl
parents: 56371
diff changeset
  2315
  "f differentiable net \<longleftrightarrow> (f has_vector_derivative (vector_derivative f net)) net"
0556204bc230 merged DERIV_intros, has_derivative_intros into derivative_intros
hoelzl
parents: 56371
diff changeset
  2316
    (is "?l = ?r")
0556204bc230 merged DERIV_intros, has_derivative_intros into derivative_intros
hoelzl
parents: 56371
diff changeset
  2317
proof
0556204bc230 merged DERIV_intros, has_derivative_intros into derivative_intros
hoelzl
parents: 56371
diff changeset
  2318
  assume ?l
0556204bc230 merged DERIV_intros, has_derivative_intros into derivative_intros
hoelzl
parents: 56371
diff changeset
  2319
  obtain f' where f': "(f has_derivative f') net"
60420
884f54e01427 isabelle update_cartouches;
wenzelm
parents: 60179
diff changeset
  2320
    using \<open>?l\<close> unfolding differentiable_def ..
56381
0556204bc230 merged DERIV_intros, has_derivative_intros into derivative_intros
hoelzl
parents: 56371
diff changeset
  2321
  then interpret bounded_linear f'
0556204bc230 merged DERIV_intros, has_derivative_intros into derivative_intros
hoelzl
parents: 56371
diff changeset
  2322
    by auto
0556204bc230 merged DERIV_intros, has_derivative_intros into derivative_intros
hoelzl
parents: 56371
diff changeset
  2323
  show ?r
0556204bc230 merged DERIV_intros, has_derivative_intros into derivative_intros
hoelzl
parents: 56371
diff changeset
  2324
    unfolding vector_derivative_def has_vector_derivative_def
0556204bc230 merged DERIV_intros, has_derivative_intros into derivative_intros
hoelzl
parents: 56371
diff changeset
  2325
    by (rule someI[of _ "f' 1"]) (simp add: scaleR[symmetric] f')
0556204bc230 merged DERIV_intros, has_derivative_intros into derivative_intros
hoelzl
parents: 56371
diff changeset
  2326
qed (auto simp: vector_derivative_def has_vector_derivative_def differentiable_def)
0556204bc230 merged DERIV_intros, has_derivative_intros into derivative_intros
hoelzl
parents: 56371
diff changeset
  2327
61245
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61204
diff changeset
  2328
lemma vector_derivative_within:
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61204
diff changeset
  2329
  assumes not_bot: "at x within s \<noteq> bot" and y: "(f has_vector_derivative y) (at x within s)"
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61204
diff changeset
  2330
  shows "vector_derivative f (at x within s) = y"
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61204
diff changeset
  2331
  using y
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61204
diff changeset
  2332
  by (intro vector_derivative_unique_within[OF not_bot vector_derivative_works[THEN iffD1] y])
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61204
diff changeset
  2333
     (auto simp: differentiable_def has_vector_derivative_def)
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61204
diff changeset
  2334
61520
8f85bb443d33 Cauchy's integral formula, required lemmas, and a bit of reorganisation
paulson <lp15@cam.ac.uk>
parents: 61518
diff changeset
  2335
lemma frechet_derivative_eq_vector_derivative:
8f85bb443d33 Cauchy's integral formula, required lemmas, and a bit of reorganisation
paulson <lp15@cam.ac.uk>
parents: 61518
diff changeset
  2336
  assumes "f differentiable (at x)"
8f85bb443d33 Cauchy's integral formula, required lemmas, and a bit of reorganisation
paulson <lp15@cam.ac.uk>
parents: 61518
diff changeset
  2337
    shows  "(frechet_derivative f (at x)) = (\<lambda>r. r *\<^sub>R vector_derivative f (at x))"
8f85bb443d33 Cauchy's integral formula, required lemmas, and a bit of reorganisation
paulson <lp15@cam.ac.uk>
parents: 61518
diff changeset
  2338
using assms
8f85bb443d33 Cauchy's integral formula, required lemmas, and a bit of reorganisation
paulson <lp15@cam.ac.uk>
parents: 61518
diff changeset
  2339
by (auto simp: differentiable_iff_scaleR vector_derivative_def has_vector_derivative_def
8f85bb443d33 Cauchy's integral formula, required lemmas, and a bit of reorganisation
paulson <lp15@cam.ac.uk>
parents: 61518
diff changeset
  2340
         intro: someI frechet_derivative_at [symmetric])
8f85bb443d33 Cauchy's integral formula, required lemmas, and a bit of reorganisation
paulson <lp15@cam.ac.uk>
parents: 61518
diff changeset
  2341
8f85bb443d33 Cauchy's integral formula, required lemmas, and a bit of reorganisation
paulson <lp15@cam.ac.uk>
parents: 61518
diff changeset
  2342
lemma has_real_derivative:
61649
268d88ec9087 Tweaks for "real": Removal of [iff] status for some lemmas, adding [simp] for others. Plus fixes.
paulson <lp15@cam.ac.uk>
parents: 61560
diff changeset
  2343
  fixes f :: "real \<Rightarrow> real"
61520
8f85bb443d33 Cauchy's integral formula, required lemmas, and a bit of reorganisation
paulson <lp15@cam.ac.uk>
parents: 61518
diff changeset
  2344
  assumes "(f has_derivative f') F"
8f85bb443d33 Cauchy's integral formula, required lemmas, and a bit of reorganisation
paulson <lp15@cam.ac.uk>
parents: 61518
diff changeset
  2345
  obtains c where "(f has_real_derivative c) F"
8f85bb443d33 Cauchy's integral formula, required lemmas, and a bit of reorganisation
paulson <lp15@cam.ac.uk>
parents: 61518
diff changeset
  2346
proof -
8f85bb443d33 Cauchy's integral formula, required lemmas, and a bit of reorganisation
paulson <lp15@cam.ac.uk>
parents: 61518
diff changeset
  2347
  obtain c where "f' = (\<lambda>x. x * c)"
8f85bb443d33 Cauchy's integral formula, required lemmas, and a bit of reorganisation
paulson <lp15@cam.ac.uk>
parents: 61518
diff changeset
  2348
    by (metis assms has_derivative_bounded_linear real_bounded_linear)
8f85bb443d33 Cauchy's integral formula, required lemmas, and a bit of reorganisation
paulson <lp15@cam.ac.uk>
parents: 61518
diff changeset
  2349
  then show ?thesis
8f85bb443d33 Cauchy's integral formula, required lemmas, and a bit of reorganisation
paulson <lp15@cam.ac.uk>
parents: 61518
diff changeset
  2350
    by (metis assms that has_field_derivative_def mult_commute_abs)
8f85bb443d33 Cauchy's integral formula, required lemmas, and a bit of reorganisation
paulson <lp15@cam.ac.uk>
parents: 61518
diff changeset
  2351
qed
8f85bb443d33 Cauchy's integral formula, required lemmas, and a bit of reorganisation
paulson <lp15@cam.ac.uk>
parents: 61518
diff changeset
  2352
8f85bb443d33 Cauchy's integral formula, required lemmas, and a bit of reorganisation
paulson <lp15@cam.ac.uk>
parents: 61518
diff changeset
  2353
lemma has_real_derivative_iff:
61649
268d88ec9087 Tweaks for "real": Removal of [iff] status for some lemmas, adding [simp] for others. Plus fixes.
paulson <lp15@cam.ac.uk>
parents: 61560
diff changeset
  2354
  fixes f :: "real \<Rightarrow> real"
61520
8f85bb443d33 Cauchy's integral formula, required lemmas, and a bit of reorganisation
paulson <lp15@cam.ac.uk>
parents: 61518
diff changeset
  2355
  shows "(\<exists>c. (f has_real_derivative c) F) = (\<exists>D. (f has_derivative D) F)"
8f85bb443d33 Cauchy's integral formula, required lemmas, and a bit of reorganisation
paulson <lp15@cam.ac.uk>
parents: 61518
diff changeset
  2356
  by (metis has_field_derivative_def has_real_derivative)
8f85bb443d33 Cauchy's integral formula, required lemmas, and a bit of reorganisation
paulson <lp15@cam.ac.uk>
parents: 61518
diff changeset
  2357
8f85bb443d33 Cauchy's integral formula, required lemmas, and a bit of reorganisation
paulson <lp15@cam.ac.uk>
parents: 61518
diff changeset
  2358
definition deriv :: "('a \<Rightarrow> 'a::real_normed_field) \<Rightarrow> 'a \<Rightarrow> 'a" where
8f85bb443d33 Cauchy's integral formula, required lemmas, and a bit of reorganisation
paulson <lp15@cam.ac.uk>
parents: 61518
diff changeset
  2359
  "deriv f x \<equiv> SOME D. DERIV f x :> D"
8f85bb443d33 Cauchy's integral formula, required lemmas, and a bit of reorganisation
paulson <lp15@cam.ac.uk>
parents: 61518
diff changeset
  2360
8f85bb443d33 Cauchy's integral formula, required lemmas, and a bit of reorganisation
paulson <lp15@cam.ac.uk>
parents: 61518
diff changeset
  2361
lemma DERIV_imp_deriv: "DERIV f x :> f' \<Longrightarrow> deriv f x = f'"
8f85bb443d33 Cauchy's integral formula, required lemmas, and a bit of reorganisation
paulson <lp15@cam.ac.uk>
parents: 61518
diff changeset
  2362
  unfolding deriv_def by (metis some_equality DERIV_unique)
8f85bb443d33 Cauchy's integral formula, required lemmas, and a bit of reorganisation
paulson <lp15@cam.ac.uk>
parents: 61518
diff changeset
  2363
61907
f0c894ab18c9 Liouville theorem, Fundamental Theorem of Algebra, etc.
paulson <lp15@cam.ac.uk>
parents: 61880
diff changeset
  2364
lemma DERIV_deriv_iff_has_field_derivative:
f0c894ab18c9 Liouville theorem, Fundamental Theorem of Algebra, etc.
paulson <lp15@cam.ac.uk>
parents: 61880
diff changeset
  2365
  "DERIV f x :> deriv f x \<longleftrightarrow> (\<exists>f'. (f has_field_derivative f') (at x))"
f0c894ab18c9 Liouville theorem, Fundamental Theorem of Algebra, etc.
paulson <lp15@cam.ac.uk>
parents: 61880
diff changeset
  2366
  by (auto simp: has_field_derivative_def DERIV_imp_deriv)
f0c894ab18c9 Liouville theorem, Fundamental Theorem of Algebra, etc.
paulson <lp15@cam.ac.uk>
parents: 61880
diff changeset
  2367
  
61520
8f85bb443d33 Cauchy's integral formula, required lemmas, and a bit of reorganisation
paulson <lp15@cam.ac.uk>
parents: 61518
diff changeset
  2368
lemma DERIV_deriv_iff_real_differentiable:
8f85bb443d33 Cauchy's integral formula, required lemmas, and a bit of reorganisation
paulson <lp15@cam.ac.uk>
parents: 61518
diff changeset
  2369
  fixes x :: real
8f85bb443d33 Cauchy's integral formula, required lemmas, and a bit of reorganisation
paulson <lp15@cam.ac.uk>
parents: 61518
diff changeset
  2370
  shows "DERIV f x :> deriv f x \<longleftrightarrow> f differentiable at x"
8f85bb443d33 Cauchy's integral formula, required lemmas, and a bit of reorganisation
paulson <lp15@cam.ac.uk>
parents: 61518
diff changeset
  2371
  unfolding differentiable_def by (metis DERIV_imp_deriv has_real_derivative_iff)
8f85bb443d33 Cauchy's integral formula, required lemmas, and a bit of reorganisation
paulson <lp15@cam.ac.uk>
parents: 61518
diff changeset
  2372
8f85bb443d33 Cauchy's integral formula, required lemmas, and a bit of reorganisation
paulson <lp15@cam.ac.uk>
parents: 61518
diff changeset
  2373
lemma real_derivative_chain:
8f85bb443d33 Cauchy's integral formula, required lemmas, and a bit of reorganisation
paulson <lp15@cam.ac.uk>
parents: 61518
diff changeset
  2374
  fixes x :: real
8f85bb443d33 Cauchy's integral formula, required lemmas, and a bit of reorganisation
paulson <lp15@cam.ac.uk>
parents: 61518
diff changeset
  2375
  shows "f differentiable at x \<Longrightarrow> g differentiable at (f x)
8f85bb443d33 Cauchy's integral formula, required lemmas, and a bit of reorganisation
paulson <lp15@cam.ac.uk>
parents: 61518
diff changeset
  2376
    \<Longrightarrow> deriv (g o f) x = deriv g (f x) * deriv f x"
8f85bb443d33 Cauchy's integral formula, required lemmas, and a bit of reorganisation
paulson <lp15@cam.ac.uk>
parents: 61518
diff changeset
  2377
  by (metis DERIV_deriv_iff_real_differentiable DERIV_chain DERIV_imp_deriv)
8f85bb443d33 Cauchy's integral formula, required lemmas, and a bit of reorganisation
paulson <lp15@cam.ac.uk>
parents: 61518
diff changeset
  2378
lemma field_derivative_eq_vector_derivative:
8f85bb443d33 Cauchy's integral formula, required lemmas, and a bit of reorganisation
paulson <lp15@cam.ac.uk>
parents: 61518
diff changeset
  2379
   "(deriv f x) = vector_derivative f (at x)"
8f85bb443d33 Cauchy's integral formula, required lemmas, and a bit of reorganisation
paulson <lp15@cam.ac.uk>
parents: 61518
diff changeset
  2380
by (simp add: mult.commute deriv_def vector_derivative_def has_vector_derivative_def has_field_derivative_def)
8f85bb443d33 Cauchy's integral formula, required lemmas, and a bit of reorganisation
paulson <lp15@cam.ac.uk>
parents: 61518
diff changeset
  2381
61245
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61204
diff changeset
  2382
lemma islimpt_closure_open:
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61204
diff changeset
  2383
  fixes s :: "'a::perfect_space set"
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61204
diff changeset
  2384
  assumes "open s" and t: "t = closure s" "x \<in> t"
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61204
diff changeset
  2385
  shows "x islimpt t"
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61204
diff changeset
  2386
proof cases
61649
268d88ec9087 Tweaks for "real": Removal of [iff] status for some lemmas, adding [simp] for others. Plus fixes.
paulson <lp15@cam.ac.uk>
parents: 61560
diff changeset
  2387
  assume "x \<in> s"
61245
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61204
diff changeset
  2388
  { fix T assume "x \<in> T" "open T"
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61204
diff changeset
  2389
    then have "open (s \<inter> T)"
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61204
diff changeset
  2390
      using \<open>open s\<close> by auto
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61204
diff changeset
  2391
    then have "s \<inter> T \<noteq> {x}"
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61204
diff changeset
  2392
      using not_open_singleton[of x] by auto
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61204
diff changeset
  2393
    with \<open>x \<in> T\<close> \<open>x \<in> s\<close> have "\<exists>y\<in>t. y \<in> T \<and> y \<noteq> x"
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61204
diff changeset
  2394
      using closure_subset[of s] by (auto simp: t) }
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61204
diff changeset
  2395
  then show ?thesis
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61204
diff changeset
  2396
    by (auto intro!: islimptI)
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61204
diff changeset
  2397
next
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61204
diff changeset
  2398
  assume "x \<notin> s" with t show ?thesis
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61204
diff changeset
  2399
    unfolding t closure_def by (auto intro: islimpt_subset)
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61204
diff changeset
  2400
qed
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61204
diff changeset
  2401
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  2402
lemma vector_derivative_unique_within_closed_interval:
61245
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61204
diff changeset
  2403
  assumes ab: "a < b" "x \<in> cbox a b"
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61204
diff changeset
  2404
  assumes D: "(f has_vector_derivative f') (at x within cbox a b)" "(f has_vector_derivative f'') (at x within cbox a b)"
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  2405
  shows "f' = f''"
61245
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61204
diff changeset
  2406
  using ab
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61204
diff changeset
  2407
  by (intro vector_derivative_unique_within[OF _ D])
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61204
diff changeset
  2408
     (auto simp: trivial_limit_within intro!: islimpt_closure_open[where s="{a <..< b}"])
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  2409
37730
1a24950dae33 generalize some lemmas about derivatives
huffman
parents: 37650
diff changeset
  2410
lemma vector_derivative_at:
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2411
  "(f has_vector_derivative f') (at x) \<Longrightarrow> vector_derivative f (at x) = f'"
61245
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61204
diff changeset
  2412
  by (intro vector_derivative_within at_neq_bot)
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  2413
61104
3c2d4636cebc new lemmas about vector_derivative, complex numbers, paths, etc.
paulson
parents: 61076
diff changeset
  2414
lemma has_vector_derivative_id_at [simp]: "vector_derivative (\<lambda>x. x) (at a) = 1"
3c2d4636cebc new lemmas about vector_derivative, complex numbers, paths, etc.
paulson
parents: 61076
diff changeset
  2415
  by (simp add: vector_derivative_at)
3c2d4636cebc new lemmas about vector_derivative, complex numbers, paths, etc.
paulson
parents: 61076
diff changeset
  2416
3c2d4636cebc new lemmas about vector_derivative, complex numbers, paths, etc.
paulson
parents: 61076
diff changeset
  2417
lemma vector_derivative_minus_at [simp]:
3c2d4636cebc new lemmas about vector_derivative, complex numbers, paths, etc.
paulson
parents: 61076
diff changeset
  2418
  "f differentiable at a
3c2d4636cebc new lemmas about vector_derivative, complex numbers, paths, etc.
paulson
parents: 61076
diff changeset
  2419
   \<Longrightarrow> vector_derivative (\<lambda>x. - f x) (at a) = - vector_derivative f (at a)"
3c2d4636cebc new lemmas about vector_derivative, complex numbers, paths, etc.
paulson
parents: 61076
diff changeset
  2420
  by (simp add: vector_derivative_at has_vector_derivative_minus vector_derivative_works [symmetric])
3c2d4636cebc new lemmas about vector_derivative, complex numbers, paths, etc.
paulson
parents: 61076
diff changeset
  2421
3c2d4636cebc new lemmas about vector_derivative, complex numbers, paths, etc.
paulson
parents: 61076
diff changeset
  2422
lemma vector_derivative_add_at [simp]:
3c2d4636cebc new lemmas about vector_derivative, complex numbers, paths, etc.
paulson
parents: 61076
diff changeset
  2423
  "\<lbrakk>f differentiable at a; g differentiable at a\<rbrakk>
3c2d4636cebc new lemmas about vector_derivative, complex numbers, paths, etc.
paulson
parents: 61076
diff changeset
  2424
   \<Longrightarrow> vector_derivative (\<lambda>x. f x + g x) (at a) = vector_derivative f (at a) + vector_derivative g (at a)"
3c2d4636cebc new lemmas about vector_derivative, complex numbers, paths, etc.
paulson
parents: 61076
diff changeset
  2425
  by (simp add: vector_derivative_at has_vector_derivative_add vector_derivative_works [symmetric])
3c2d4636cebc new lemmas about vector_derivative, complex numbers, paths, etc.
paulson
parents: 61076
diff changeset
  2426
3c2d4636cebc new lemmas about vector_derivative, complex numbers, paths, etc.
paulson
parents: 61076
diff changeset
  2427
lemma vector_derivative_diff_at [simp]:
3c2d4636cebc new lemmas about vector_derivative, complex numbers, paths, etc.
paulson
parents: 61076
diff changeset
  2428
  "\<lbrakk>f differentiable at a; g differentiable at a\<rbrakk>
3c2d4636cebc new lemmas about vector_derivative, complex numbers, paths, etc.
paulson
parents: 61076
diff changeset
  2429
   \<Longrightarrow> vector_derivative (\<lambda>x. f x - g x) (at a) = vector_derivative f (at a) - vector_derivative g (at a)"
3c2d4636cebc new lemmas about vector_derivative, complex numbers, paths, etc.
paulson
parents: 61076
diff changeset
  2430
  by (simp add: vector_derivative_at has_vector_derivative_diff vector_derivative_works [symmetric])
3c2d4636cebc new lemmas about vector_derivative, complex numbers, paths, etc.
paulson
parents: 61076
diff changeset
  2431
61204
3e491e34a62e new lemmas and movement of lemmas into place
paulson
parents: 61165
diff changeset
  2432
lemma vector_derivative_mult_at [simp]:
3e491e34a62e new lemmas and movement of lemmas into place
paulson
parents: 61165
diff changeset
  2433
  fixes f g :: "real \<Rightarrow> 'a :: real_normed_algebra"
3e491e34a62e new lemmas and movement of lemmas into place
paulson
parents: 61165
diff changeset
  2434
  shows  "\<lbrakk>f differentiable at a; g differentiable at a\<rbrakk>
3e491e34a62e new lemmas and movement of lemmas into place
paulson
parents: 61165
diff changeset
  2435
   \<Longrightarrow> vector_derivative (\<lambda>x. f x * g x) (at a) = f a * vector_derivative g (at a) + vector_derivative f (at a) * g a"
3e491e34a62e new lemmas and movement of lemmas into place
paulson
parents: 61165
diff changeset
  2436
  by (simp add: vector_derivative_at has_vector_derivative_mult vector_derivative_works [symmetric])
3e491e34a62e new lemmas and movement of lemmas into place
paulson
parents: 61165
diff changeset
  2437
3e491e34a62e new lemmas and movement of lemmas into place
paulson
parents: 61165
diff changeset
  2438
lemma vector_derivative_scaleR_at [simp]:
3e491e34a62e new lemmas and movement of lemmas into place
paulson
parents: 61165
diff changeset
  2439
    "\<lbrakk>f differentiable at a; g differentiable at a\<rbrakk>
3e491e34a62e new lemmas and movement of lemmas into place
paulson
parents: 61165
diff changeset
  2440
   \<Longrightarrow> vector_derivative (\<lambda>x. f x *\<^sub>R g x) (at a) = f a *\<^sub>R vector_derivative g (at a) + vector_derivative f (at a) *\<^sub>R g a"
3e491e34a62e new lemmas and movement of lemmas into place
paulson
parents: 61165
diff changeset
  2441
apply (rule vector_derivative_at)
3e491e34a62e new lemmas and movement of lemmas into place
paulson
parents: 61165
diff changeset
  2442
apply (rule has_vector_derivative_scaleR)
3e491e34a62e new lemmas and movement of lemmas into place
paulson
parents: 61165
diff changeset
  2443
apply (auto simp: vector_derivative_works has_vector_derivative_def has_field_derivative_def mult_commute_abs)
3e491e34a62e new lemmas and movement of lemmas into place
paulson
parents: 61165
diff changeset
  2444
done
3e491e34a62e new lemmas and movement of lemmas into place
paulson
parents: 61165
diff changeset
  2445
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  2446
lemma vector_derivative_within_closed_interval:
61245
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61204
diff changeset
  2447
  assumes ab: "a < b" "x \<in> cbox a b"
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61204
diff changeset
  2448
  assumes f: "(f has_vector_derivative f') (at x within cbox a b)"
56188
0268784f60da use cbox to relax class constraints
immler
parents: 56183
diff changeset
  2449
  shows "vector_derivative f (at x within cbox a b) = f'"
61245
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61204
diff changeset
  2450
  by (intro vector_derivative_unique_within_closed_interval[OF ab _ f]
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61204
diff changeset
  2451
            vector_derivative_works[THEN iffD1] differentiableI_vector)
b77bf45efe21 prove Liminf_inverse_ereal
hoelzl
parents: 61204
diff changeset
  2452
     fact
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  2453
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2454
lemma has_vector_derivative_within_subset:
56381
0556204bc230 merged DERIV_intros, has_derivative_intros into derivative_intros
hoelzl
parents: 56371
diff changeset
  2455
  "(f has_vector_derivative f') (at x within s) \<Longrightarrow> t \<subseteq> s \<Longrightarrow> (f has_vector_derivative f') (at x within t)"
0556204bc230 merged DERIV_intros, has_derivative_intros into derivative_intros
hoelzl
parents: 56371
diff changeset
  2456
  by (auto simp: has_vector_derivative_def intro: has_derivative_within_subset)
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  2457
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  2458
lemma has_vector_derivative_at_within:
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  2459
  "(f has_vector_derivative f') (at x) \<Longrightarrow> (f has_vector_derivative f') (at x within s)"
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  2460
  unfolding has_vector_derivative_def
45031
9583f2b56f85 add lemmas within_empty and tendsto_bot;
huffman
parents: 44907
diff changeset
  2461
  by (rule has_derivative_at_within)
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  2462
61880
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61824
diff changeset
  2463
lemma has_vector_derivative_weaken:
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61824
diff changeset
  2464
  fixes x D and f g s t
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61824
diff changeset
  2465
  assumes f: "(f has_vector_derivative D) (at x within t)"
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61824
diff changeset
  2466
    and "x \<in> s" "s \<subseteq> t" 
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61824
diff changeset
  2467
    and "\<And>x. x \<in> s \<Longrightarrow> f x = g x"
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61824
diff changeset
  2468
  shows "(g has_vector_derivative D) (at x within s)"
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61824
diff changeset
  2469
proof -
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61824
diff changeset
  2470
  have "(f has_vector_derivative D) (at x within s) \<longleftrightarrow> (g has_vector_derivative D) (at x within s)"
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61824
diff changeset
  2471
    unfolding has_vector_derivative_def has_derivative_iff_norm
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61824
diff changeset
  2472
    using assms by (intro conj_cong Lim_cong_within refl) auto
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61824
diff changeset
  2473
  then show ?thesis
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61824
diff changeset
  2474
    using has_vector_derivative_within_subset[OF f `s \<subseteq> t`] by simp
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61824
diff changeset
  2475
qed
ff4d33058566 moved some theorems from the CLT proof; reordered some theorems / notation
hoelzl
parents: 61824
diff changeset
  2476
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  2477
lemma has_vector_derivative_transform_within:
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2478
  assumes "0 < d"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2479
    and "x \<in> s"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2480
    and "\<forall>x'\<in>s. dist x' x < d \<longrightarrow> f x' = g x'"
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  2481
  assumes "(f has_vector_derivative f') (at x within s)"
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  2482
  shows "(g has_vector_derivative f') (at x within s)"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2483
  using assms
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2484
  unfolding has_vector_derivative_def
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  2485
  by (rule has_derivative_transform_within)
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  2486
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  2487
lemma has_vector_derivative_transform_at:
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2488
  assumes "0 < d"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2489
    and "\<forall>x'. dist x' x < d \<longrightarrow> f x' = g x'"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2490
    and "(f has_vector_derivative f') (at x)"
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  2491
  shows "(g has_vector_derivative f') (at x)"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2492
  using assms
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2493
  unfolding has_vector_derivative_def
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  2494
  by (rule has_derivative_transform_at)
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  2495
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  2496
lemma has_vector_derivative_transform_within_open:
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2497
  assumes "open s"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2498
    and "x \<in> s"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2499
    and "\<forall>y\<in>s. f y = g y"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2500
    and "(f has_vector_derivative f') (at x)"
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  2501
  shows "(g has_vector_derivative f') (at x)"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2502
  using assms
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2503
  unfolding has_vector_derivative_def
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  2504
  by (rule has_derivative_transform_within_open)
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  2505
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  2506
lemma vector_diff_chain_at:
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  2507
  assumes "(f has_vector_derivative f') (at x)"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2508
    and "(g has_vector_derivative g') (at (f x))"
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  2509
  shows "((g \<circ> f) has_vector_derivative (f' *\<^sub>R g')) (at x)"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2510
  using assms(2)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2511
  unfolding has_vector_derivative_def
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2512
  apply -
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2513
  apply (drule diff_chain_at[OF assms(1)[unfolded has_vector_derivative_def]])
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2514
  apply (simp only: o_def real_scaleR_def scaleR_scaleR)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2515
  done
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  2516
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  2517
lemma vector_diff_chain_within:
44123
2362a970e348 Derivative.thy: clean up formatting
huffman
parents: 44081
diff changeset
  2518
  assumes "(f has_vector_derivative f') (at x within s)"
53781
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2519
    and "(g has_vector_derivative g') (at (f x) within f ` s)"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2520
  shows "((g \<circ> f) has_vector_derivative (f' *\<^sub>R g')) (at x within s)"
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2521
  using assms(2)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2522
  unfolding has_vector_derivative_def
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2523
  apply -
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2524
  apply (drule diff_chain_within[OF assms(1)[unfolded has_vector_derivative_def]])
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2525
  apply (simp only: o_def real_scaleR_def scaleR_scaleR)
1e86d0b66866 tuned proofs;
wenzelm
parents: 53600
diff changeset
  2526
  done
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  2527
60762
bf0c76ccee8d new material for multivariate analysis, etc.
paulson
parents: 60589
diff changeset
  2528
lemma vector_derivative_const_at [simp]: "vector_derivative (\<lambda>x. c) (at a) = 0"
bf0c76ccee8d new material for multivariate analysis, etc.
paulson
parents: 60589
diff changeset
  2529
  by (simp add: vector_derivative_at)
bf0c76ccee8d new material for multivariate analysis, etc.
paulson
parents: 60589
diff changeset
  2530
60800
7d04351c795a New material for Cauchy's integral theorem
paulson <lp15@cam.ac.uk>
parents: 60762
diff changeset
  2531
lemma vector_derivative_at_within_ivl:
7d04351c795a New material for Cauchy's integral theorem
paulson <lp15@cam.ac.uk>
parents: 60762
diff changeset
  2532
  "(f has_vector_derivative f') (at x) \<Longrightarrow>
7d04351c795a New material for Cauchy's integral theorem
paulson <lp15@cam.ac.uk>
parents: 60762
diff changeset
  2533
    a \<le> x \<Longrightarrow> x \<le> b \<Longrightarrow> a<b \<Longrightarrow> vector_derivative f (at x within {a..b}) = f'"
7d04351c795a New material for Cauchy's integral theorem
paulson <lp15@cam.ac.uk>
parents: 60762
diff changeset
  2534
using has_vector_derivative_at_within vector_derivative_within_closed_interval by fastforce
7d04351c795a New material for Cauchy's integral theorem
paulson <lp15@cam.ac.uk>
parents: 60762
diff changeset
  2535
61204
3e491e34a62e new lemmas and movement of lemmas into place
paulson
parents: 61165
diff changeset
  2536
lemma vector_derivative_chain_at:
3e491e34a62e new lemmas and movement of lemmas into place
paulson
parents: 61165
diff changeset
  2537
  assumes "f differentiable at x" "(g differentiable at (f x))"
3e491e34a62e new lemmas and movement of lemmas into place
paulson
parents: 61165
diff changeset
  2538
  shows "vector_derivative (g \<circ> f) (at x) =
3e491e34a62e new lemmas and movement of lemmas into place
paulson
parents: 61165
diff changeset
  2539
         vector_derivative f (at x) *\<^sub>R vector_derivative g (at (f x))"
3e491e34a62e new lemmas and movement of lemmas into place
paulson
parents: 61165
diff changeset
  2540
by (metis vector_diff_chain_at vector_derivative_at vector_derivative_works assms)
3e491e34a62e new lemmas and movement of lemmas into place
paulson
parents: 61165
diff changeset
  2541
61531
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2542
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2543
subsection \<open>Relation between convexity and derivative\<close>
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2544
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2545
(* TODO: Generalise to real vector spaces? *)
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2546
lemma convex_on_imp_above_tangent:
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2547
  assumes convex: "convex_on A f" and connected: "connected A"
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2548
  assumes c: "c \<in> interior A" and x : "x \<in> A"
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2549
  assumes deriv: "(f has_field_derivative f') (at c within A)"
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2550
  shows   "f x - f c \<ge> f' * (x - c)"
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2551
proof (cases x c rule: linorder_cases)
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2552
  assume xc: "x > c"
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2553
  let ?A' = "interior A \<inter> {c<..}"
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2554
  from c have "c \<in> interior A \<inter> closure {c<..}" by auto
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2555
  also have "\<dots> \<subseteq> closure (interior A \<inter> {c<..})" by (intro open_inter_closure_subset) auto
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2556
  finally have "at c within ?A' \<noteq> bot" by (subst at_within_eq_bot_iff) auto
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2557
  moreover from deriv have "((\<lambda>y. (f y - f c) / (y - c)) ---> f') (at c within ?A')"
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2558
    unfolding DERIV_within_iff using interior_subset[of A] by (blast intro: tendsto_mono at_le)
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2559
  moreover from eventually_at_right_real[OF xc]
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2560
    have "eventually (\<lambda>y. (f y - f c) / (y - c) \<le> (f x - f c) / (x - c)) (at_right c)"
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2561
  proof eventually_elim
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2562
    fix y assume y: "y \<in> {c<..<x}"
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2563
    with convex connected x c have "f y \<le> (f x - f c) / (x - c) * (y - c) + f c"
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2564
      using interior_subset[of A]
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2565
      by (intro convex_onD_Icc' convex_on_subset[OF convex] connected_contains_Icc) auto
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2566
    hence "f y - f c \<le> (f x - f c) / (x - c) * (y - c)" by simp
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2567
    thus "(f y - f c) / (y - c) \<le> (f x - f c) / (x - c)" using y xc by (simp add: divide_simps)
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2568
  qed
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2569
  hence "eventually (\<lambda>y. (f y - f c) / (y - c) \<le> (f x - f c) / (x - c)) (at c within ?A')"
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2570
    by (blast intro: filter_leD at_le)
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2571
  ultimately have "f' \<le> (f x - f c) / (x - c)" by (rule tendsto_ge_const)
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2572
  thus ?thesis using xc by (simp add: field_simps)
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2573
next
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2574
  assume xc: "x < c"
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2575
  let ?A' = "interior A \<inter> {..<c}"
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2576
  from c have "c \<in> interior A \<inter> closure {..<c}" by auto
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2577
  also have "\<dots> \<subseteq> closure (interior A \<inter> {..<c})" by (intro open_inter_closure_subset) auto
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2578
  finally have "at c within ?A' \<noteq> bot" by (subst at_within_eq_bot_iff) auto
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2579
  moreover from deriv have "((\<lambda>y. (f y - f c) / (y - c)) ---> f') (at c within ?A')"
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2580
    unfolding DERIV_within_iff using interior_subset[of A] by (blast intro: tendsto_mono at_le)
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2581
  moreover from eventually_at_left_real[OF xc]
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2582
    have "eventually (\<lambda>y. (f y - f c) / (y - c) \<ge> (f x - f c) / (x - c)) (at_left c)"
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2583
  proof eventually_elim
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2584
    fix y assume y: "y \<in> {x<..<c}"
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2585
    with convex connected x c have "f y \<le> (f x - f c) / (c - x) * (c - y) + f c"
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2586
      using interior_subset[of A]
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2587
      by (intro convex_onD_Icc'' convex_on_subset[OF convex] connected_contains_Icc) auto
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2588
    hence "f y - f c \<le> (f x - f c) * ((c - y) / (c - x))" by simp
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2589
    also have "(c - y) / (c - x) = (y - c) / (x - c)" using y xc by (simp add: field_simps)
61649
268d88ec9087 Tweaks for "real": Removal of [iff] status for some lemmas, adding [simp] for others. Plus fixes.
paulson <lp15@cam.ac.uk>
parents: 61560
diff changeset
  2590
    finally show "(f y - f c) / (y - c) \<ge> (f x - f c) / (x - c)" using y xc
61531
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2591
      by (simp add: divide_simps)
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2592
  qed
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2593
  hence "eventually (\<lambda>y. (f y - f c) / (y - c) \<ge> (f x - f c) / (x - c)) (at c within ?A')"
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2594
    by (blast intro: filter_leD at_le)
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2595
  ultimately have "f' \<ge> (f x - f c) / (x - c)" by (rule tendsto_le_const)
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2596
  thus ?thesis using xc by (simp add: field_simps)
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2597
qed simp_all
ab2e862263e7 Rounding function, uniform limits, cotangent, binomial identities
eberlm
parents: 61524
diff changeset
  2598
33741
4c414d0835ab Added derivation and Brouwer's fixpoint theorem in Multivariate Analysis (translated by Robert Himmelmann from HOL-light)
hoelzl
parents:
diff changeset
  2599
end