src/HOL/Deriv.thy
changeset 44568 e6f291cb5810
parent 44317 b7e9fa025f15
child 44890 22f665a2e91c
equal deleted inserted replaced
44549:5e5e6ad3922c 44568:e6f291cb5810
    35 
    35 
    36 lemma DERIV_D: "DERIV f x :> D ==> (%h. (f(x + h) - f(x))/h) -- 0 --> D"
    36 lemma DERIV_D: "DERIV f x :> D ==> (%h. (f(x + h) - f(x))/h) -- 0 --> D"
    37 by (simp add: deriv_def)
    37 by (simp add: deriv_def)
    38 
    38 
    39 lemma DERIV_const [simp]: "DERIV (\<lambda>x. k) x :> 0"
    39 lemma DERIV_const [simp]: "DERIV (\<lambda>x. k) x :> 0"
    40 by (simp add: deriv_def)
    40   by (simp add: deriv_def tendsto_const)
    41 
    41 
    42 lemma DERIV_ident [simp]: "DERIV (\<lambda>x. x) x :> 1"
    42 lemma DERIV_ident [simp]: "DERIV (\<lambda>x. x) x :> 1"
    43 by (simp add: deriv_def cong: LIM_cong)
    43   by (simp add: deriv_def tendsto_const cong: LIM_cong)
    44 
    44 
    45 lemma DERIV_add:
    45 lemma DERIV_add:
    46   "\<lbrakk>DERIV f x :> D; DERIV g x :> E\<rbrakk> \<Longrightarrow> DERIV (\<lambda>x. f x + g x) x :> D + E"
    46   "\<lbrakk>DERIV f x :> D; DERIV g x :> E\<rbrakk> \<Longrightarrow> DERIV (\<lambda>x. f x + g x) x :> D + E"
    47 by (simp only: deriv_def add_diff_add add_divide_distrib LIM_add)
    47   by (simp only: deriv_def add_diff_add add_divide_distrib tendsto_add)
    48 
    48 
    49 lemma DERIV_minus:
    49 lemma DERIV_minus:
    50   "DERIV f x :> D \<Longrightarrow> DERIV (\<lambda>x. - f x) x :> - D"
    50   "DERIV f x :> D \<Longrightarrow> DERIV (\<lambda>x. - f x) x :> - D"
    51 by (simp only: deriv_def minus_diff_minus divide_minus_left LIM_minus)
    51   by (simp only: deriv_def minus_diff_minus divide_minus_left tendsto_minus)
    52 
    52 
    53 lemma DERIV_diff:
    53 lemma DERIV_diff:
    54   "\<lbrakk>DERIV f x :> D; DERIV g x :> E\<rbrakk> \<Longrightarrow> DERIV (\<lambda>x. f x - g x) x :> D - E"
    54   "\<lbrakk>DERIV f x :> D; DERIV g x :> E\<rbrakk> \<Longrightarrow> DERIV (\<lambda>x. f x - g x) x :> D - E"
    55 by (simp only: diff_minus DERIV_add DERIV_minus)
    55 by (simp only: diff_minus DERIV_add DERIV_minus)
    56 
    56 
    62 proof (unfold isCont_iff)
    62 proof (unfold isCont_iff)
    63   assume "DERIV f x :> D"
    63   assume "DERIV f x :> D"
    64   hence "(\<lambda>h. (f(x+h) - f(x)) / h) -- 0 --> D"
    64   hence "(\<lambda>h. (f(x+h) - f(x)) / h) -- 0 --> D"
    65     by (rule DERIV_D)
    65     by (rule DERIV_D)
    66   hence "(\<lambda>h. (f(x+h) - f(x)) / h * h) -- 0 --> D * 0"
    66   hence "(\<lambda>h. (f(x+h) - f(x)) / h * h) -- 0 --> D * 0"
    67     by (intro LIM_mult LIM_ident)
    67     by (intro tendsto_mult tendsto_ident_at)
    68   hence "(\<lambda>h. (f(x+h) - f(x)) * (h / h)) -- 0 --> 0"
    68   hence "(\<lambda>h. (f(x+h) - f(x)) * (h / h)) -- 0 --> 0"
    69     by simp
    69     by simp
    70   hence "(\<lambda>h. f(x+h) - f(x)) -- 0 --> 0"
    70   hence "(\<lambda>h. f(x+h) - f(x)) -- 0 --> 0"
    71     by (simp cong: LIM_cong)
    71     by (simp cong: LIM_cong)
    72   thus "(\<lambda>h. f(x+h)) -- 0 --> f(x)"
    72   thus "(\<lambda>h. f(x+h)) -- 0 --> f(x)"
    88   hence "(\<lambda>h. f(x+h)) -- 0 --> f x"
    88   hence "(\<lambda>h. f(x+h)) -- 0 --> f x"
    89     by (simp only: isCont_iff)
    89     by (simp only: isCont_iff)
    90   hence "(\<lambda>h. f(x+h) * ((g(x+h) - g x) / h) +
    90   hence "(\<lambda>h. f(x+h) * ((g(x+h) - g x) / h) +
    91               ((f(x+h) - f x) / h) * g x)
    91               ((f(x+h) - f x) / h) * g x)
    92           -- 0 --> f x * E + D * g x"
    92           -- 0 --> f x * E + D * g x"
    93     by (intro LIM_add LIM_mult LIM_const DERIV_D f g)
    93     by (intro tendsto_intros DERIV_D f g)
    94   thus "(\<lambda>h. (f(x+h) * g(x+h) - f x * g x) / h)
    94   thus "(\<lambda>h. (f(x+h) * g(x+h) - f x * g x) / h)
    95          -- 0 --> f x * E + D * g x"
    95          -- 0 --> f x * E + D * g x"
    96     by (simp only: DERIV_mult_lemma)
    96     by (simp only: DERIV_mult_lemma)
    97 qed
    97 qed
    98 
    98 
   170   next
   170   next
   171     from der have "(\<lambda>z. (f z - f x) / (z - x)) -- x --> D"
   171     from der have "(\<lambda>z. (f z - f x) / (z - x)) -- x --> D"
   172       by (unfold DERIV_iff2)
   172       by (unfold DERIV_iff2)
   173     thus "(\<lambda>z. - (inverse (f z) * ((f z - f x) / (z - x)) * inverse (f x)))
   173     thus "(\<lambda>z. - (inverse (f z) * ((f z - f x) / (z - x)) * inverse (f x)))
   174           -- x --> ?E"
   174           -- x --> ?E"
   175       by (intro LIM_mult LIM_inverse LIM_minus LIM_const lim_f neq)
   175       by (intro tendsto_intros lim_f neq)
   176   qed
   176   qed
   177 qed
   177 qed
   178 
   178 
   179 lemma DERIV_divide:
   179 lemma DERIV_divide:
   180   "\<lbrakk>DERIV f x :> D; DERIV g x :> E; g x \<noteq> 0\<rbrakk>
   180   "\<lbrakk>DERIV f x :> D; DERIV g x :> E; g x \<noteq> 0\<rbrakk>
   243     and cont_d: "isCont d (f x)" and dfx: "d (f x) = E"
   243     and cont_d: "isCont d (f x)" and dfx: "d (f x) = E"
   244     using CARAT_DERIV [THEN iffD1, OF g] by fast
   244     using CARAT_DERIV [THEN iffD1, OF g] by fast
   245   from f have "f -- x --> f x"
   245   from f have "f -- x --> f x"
   246     by (rule DERIV_isCont [unfolded isCont_def])
   246     by (rule DERIV_isCont [unfolded isCont_def])
   247   with cont_d have "(\<lambda>z. d (f z)) -- x --> d (f x)"
   247   with cont_d have "(\<lambda>z. d (f z)) -- x --> d (f x)"
   248     by (rule isCont_LIM_compose)
   248     by (rule isCont_tendsto_compose)
   249   hence "(\<lambda>z. d (f z) * ((f z - f x) / (z - x)))
   249   hence "(\<lambda>z. d (f z) * ((f z - f x) / (z - x)))
   250           -- x --> d (f x) * D"
   250           -- x --> d (f x) * D"
   251     by (rule LIM_mult [OF _ f [unfolded DERIV_iff2]])
   251     by (rule tendsto_mult [OF _ f [unfolded DERIV_iff2]])
   252   thus "(\<lambda>z. (g (f z) - g (f x)) / (z - x)) -- x --> E * D"
   252   thus "(\<lambda>z. (g (f z) - g (f x)) / (z - x)) -- x --> E * D"
   253     by (simp add: d dfx)
   253     by (simp add: d dfx)
   254 qed
   254 qed
   255 
   255 
   256 text {*
   256 text {*
   483 done
   483 done
   484 
   484 
   485 lemma lim_uminus:
   485 lemma lim_uminus:
   486   fixes g :: "nat \<Rightarrow> 'a::real_normed_vector"
   486   fixes g :: "nat \<Rightarrow> 'a::real_normed_vector"
   487   shows "convergent g ==> lim (%x. - g x) = - (lim g)"
   487   shows "convergent g ==> lim (%x. - g x) = - (lim g)"
   488 apply (rule LIMSEQ_minus [THEN limI])
   488 apply (rule tendsto_minus [THEN limI])
   489 apply (simp add: convergent_LIMSEQ_iff)
   489 apply (simp add: convergent_LIMSEQ_iff)
   490 done
   490 done
   491 
   491 
   492 lemma g_dec_imp_lim_le:
   492 lemma g_dec_imp_lim_le:
   493   fixes g :: "nat \<Rightarrow> real"
   493   fixes g :: "nat \<Rightarrow> real"
   519          (%n. f(n) - g(n)) ----> 0 |]
   519          (%n. f(n) - g(n)) ----> 0 |]
   520       ==> \<exists>l::real. ((\<forall>n. f(n) \<le> l) & f ----> l) &
   520       ==> \<exists>l::real. ((\<forall>n. f(n) \<le> l) & f ----> l) &
   521                 ((\<forall>n. l \<le> g(n)) & g ----> l)"
   521                 ((\<forall>n. l \<le> g(n)) & g ----> l)"
   522 apply (drule lemma_nest, auto)
   522 apply (drule lemma_nest, auto)
   523 apply (subgoal_tac "l = m")
   523 apply (subgoal_tac "l = m")
   524 apply (drule_tac [2] f = f in LIMSEQ_diff)
   524 apply (drule_tac [2] f = f in tendsto_diff)
   525 apply (auto intro: LIMSEQ_unique)
   525 apply (auto intro: LIMSEQ_unique)
   526 done
   526 done
   527 
   527 
   528 text{*The universal quantifiers below are required for the declaration
   528 text{*The universal quantifiers below are required for the declaration
   529   of @{text Bolzano_nest_unique} below.*}
   529   of @{text Bolzano_nest_unique} below.*}
   597          \<forall>x. \<exists>d::real. 0 < d &
   597          \<forall>x. \<exists>d::real. 0 < d &
   598                 (\<forall>a b. a \<le> x & x \<le> b & (b-a) < d --> P(a,b));
   598                 (\<forall>a b. a \<le> x & x \<le> b & (b-a) < d --> P(a,b));
   599          a \<le> b |]
   599          a \<le> b |]
   600       ==> P(a,b)"
   600       ==> P(a,b)"
   601 apply (rule Bolzano_nest_unique [where P1=P, THEN exE], assumption+)
   601 apply (rule Bolzano_nest_unique [where P1=P, THEN exE], assumption+)
   602 apply (rule LIMSEQ_minus_cancel)
   602 apply (rule tendsto_minus_cancel)
   603 apply (simp (no_asm_simp) add: Bolzano_bisect_diff LIMSEQ_divide_realpow_zero)
   603 apply (simp (no_asm_simp) add: Bolzano_bisect_diff LIMSEQ_divide_realpow_zero)
   604 apply (rule ccontr)
   604 apply (rule ccontr)
   605 apply (drule not_P_Bolzano_bisect', assumption+)
   605 apply (drule not_P_Bolzano_bisect', assumption+)
   606 apply (rename_tac "l")
   606 apply (rename_tac "l")
   607 apply (drule_tac x = l in spec, clarify)
   607 apply (drule_tac x = l in spec, clarify)
  1486   qed
  1486   qed
  1487   have "(\<lambda>y. (f (g y) - x) / (g y - g x)) -- x --> D"
  1487   have "(\<lambda>y. (f (g y) - x) / (g y - g x)) -- x --> D"
  1488     using cont 1 2 by (rule isCont_LIM_compose2)
  1488     using cont 1 2 by (rule isCont_LIM_compose2)
  1489   thus "(\<lambda>y. inverse ((f (g y) - x) / (g y - g x)))
  1489   thus "(\<lambda>y. inverse ((f (g y) - x) / (g y - g x)))
  1490         -- x --> inverse D"
  1490         -- x --> inverse D"
  1491     using neq by (rule LIM_inverse)
  1491     using neq by (rule tendsto_inverse)
  1492 qed
  1492 qed
  1493 
  1493 
  1494 
  1494 
  1495 subsection {* Generalized Mean Value Theorem *}
  1495 subsection {* Generalized Mean Value Theorem *}
  1496 
  1496