src/HOL/Deriv.thy
 changeset 30240 5b25fee0362c parent 29803 c56a5571f60a child 30242 aea5d7fa7ef5
```     1.1 --- a/src/HOL/Deriv.thy	Wed Mar 04 10:43:39 2009 +0100
1.2 +++ b/src/HOL/Deriv.thy	Wed Mar 04 10:45:52 2009 +0100
1.3 @@ -9,7 +9,7 @@
1.5
1.6  theory Deriv
1.7 -imports Lim Polynomial
1.8 +imports Lim
1.9  begin
1.10
1.11  text{*Standard Definitions*}
1.12 @@ -217,9 +217,7 @@
1.13  by (cases "n", simp, simp add: DERIV_power_Suc f)
1.14
1.15
1.16 -(* ------------------------------------------------------------------------ *)
1.17 -(* Caratheodory formulation of derivative at a point: standard proof        *)
1.18 -(* ------------------------------------------------------------------------ *)
1.19 +text {* Caratheodory formulation of derivative at a point *}
1.20
1.21  lemma CARAT_DERIV:
1.22       "(DERIV f x :> l) =
1.23 @@ -307,6 +305,9 @@
1.24         ==> DERIV (%y. f(y) / (g y)) x :> (d*g(x) - (e*f(x))) / (g(x) ^ Suc (Suc 0))"
1.25  by (drule (2) DERIV_divide) (simp add: mult_commute power_Suc)
1.26
1.27 +lemma lemma_DERIV_subst: "[| DERIV f x :> D; D = E |] ==> DERIV f x :> E"
1.28 +by auto
1.29 +
1.30
1.31  subsection {* Differentiability predicate *}
1.32
1.33 @@ -655,6 +656,9 @@
1.34  apply (blast intro: IVT2)
1.35  done
1.36
1.37 +
1.38 +subsection {* Boundedness of continuous functions *}
1.39 +
1.40  text{*By bisection, function continuous on closed interval is bounded above*}
1.41
1.42  lemma isCont_bounded:
1.43 @@ -773,6 +777,8 @@
1.44  done
1.45
1.46
1.47 +subsection {* Local extrema *}
1.48 +
1.49  text{*If @{term "0 < f'(x)"} then @{term x} is Locally Strictly Increasing At The Right*}
1.50
1.51  lemma DERIV_left_inc:
1.52 @@ -877,6 +883,9 @@
1.53    shows "[| DERIV f x :> l; 0 < d; \<forall>y. \<bar>x-y\<bar> < d --> f(x) = f(y) |] ==> l = 0"
1.54  by (auto dest!: DERIV_local_max)
1.55
1.56 +
1.57 +subsection {* Rolle's Theorem *}
1.58 +
1.59  text{*Lemma about introducing open ball in open interval*}
1.60  lemma lemma_interval_lt:
1.61       "[| a < x;  x < b |]
1.62 @@ -1163,6 +1172,8 @@
1.63  qed
1.64
1.65
1.66 +subsection {* Continuous injective functions *}
1.67 +
1.68  text{*Dull lemma: an continuous injection on an interval must have a
1.69  strict maximum at an end point, not in the middle.*}
1.70
1.71 @@ -1356,6 +1367,9 @@
1.72      using neq by (rule LIM_inverse)
1.73  qed
1.74
1.75 +
1.76 +subsection {* Generalized Mean Value Theorem *}
1.77 +
1.78  theorem GMVT:
1.79    fixes a b :: real
1.80    assumes alb: "a < b"
1.81 @@ -1442,245 +1456,6 @@
1.82    with g'cdef f'cdef cint show ?thesis by auto
1.83  qed
1.84
1.85 -lemma lemma_DERIV_subst: "[| DERIV f x :> D; D = E |] ==> DERIV f x :> E"
1.86 -by auto
1.87 -
1.88 -
1.89 -subsection {* Derivatives of univariate polynomials *}
1.90 -
1.91 -definition
1.92 -  pderiv :: "'a::real_normed_field poly \<Rightarrow> 'a poly" where
1.93 -  "pderiv = poly_rec 0 (\<lambda>a p p'. p + pCons 0 p')"
1.94 -
1.95 -lemma pderiv_0 [simp]: "pderiv 0 = 0"
1.96 -  unfolding pderiv_def by (simp add: poly_rec_0)
1.97 -
1.98 -lemma pderiv_pCons: "pderiv (pCons a p) = p + pCons 0 (pderiv p)"
1.99 -  unfolding pderiv_def by (simp add: poly_rec_pCons)
1.100 -
1.101 -lemma coeff_pderiv: "coeff (pderiv p) n = of_nat (Suc n) * coeff p (Suc n)"
1.102 -  apply (induct p arbitrary: n, simp)
1.103 -  apply (simp add: pderiv_pCons coeff_pCons algebra_simps split: nat.split)
1.104 -  done
1.105 -
1.106 -lemma pderiv_eq_0_iff: "pderiv p = 0 \<longleftrightarrow> degree p = 0"
1.107 -  apply (rule iffI)
1.108 -  apply (cases p, simp)
1.109 -  apply (simp add: expand_poly_eq coeff_pderiv del: of_nat_Suc)
1.110 -  apply (simp add: expand_poly_eq coeff_pderiv coeff_eq_0)
1.111 -  done
1.112 -
1.113 -lemma degree_pderiv: "degree (pderiv p) = degree p - 1"
1.114 -  apply (rule order_antisym [OF degree_le])
1.115 -  apply (simp add: coeff_pderiv coeff_eq_0)
1.116 -  apply (cases "degree p", simp)
1.117 -  apply (rule le_degree)
1.118 -  apply (simp add: coeff_pderiv del: of_nat_Suc)
1.119 -  apply (rule subst, assumption)
1.120 -  apply (rule leading_coeff_neq_0, clarsimp)
1.121 -  done
1.122 -
1.123 -lemma pderiv_singleton [simp]: "pderiv [:a:] = 0"
1.125 -
1.126 -lemma pderiv_add: "pderiv (p + q) = pderiv p + pderiv q"
1.127 -by (rule poly_ext, simp add: coeff_pderiv algebra_simps)
1.128 -
1.129 -lemma pderiv_minus: "pderiv (- p) = - pderiv p"
1.130 -by (rule poly_ext, simp add: coeff_pderiv)
1.131 -
1.132 -lemma pderiv_diff: "pderiv (p - q) = pderiv p - pderiv q"
1.133 -by (rule poly_ext, simp add: coeff_pderiv algebra_simps)
1.134 -
1.135 -lemma pderiv_smult: "pderiv (smult a p) = smult a (pderiv p)"
1.136 -by (rule poly_ext, simp add: coeff_pderiv algebra_simps)
1.137 -
1.138 -lemma pderiv_mult: "pderiv (p * q) = p * pderiv q + q * pderiv p"
1.139 -apply (induct p)
1.140 -apply simp
1.142 -done
1.143 -
1.144 -lemma pderiv_power_Suc:
1.145 -  "pderiv (p ^ Suc n) = smult (of_nat (Suc n)) (p ^ n) * pderiv p"
1.146 -apply (induct n)
1.147 -apply simp
1.148 -apply (subst power_Suc)
1.149 -apply (subst pderiv_mult)
1.150 -apply (erule ssubst)
1.152 -done
1.153 -
1.154 -lemma DERIV_cmult2: "DERIV f x :> D ==> DERIV (%x. (f x) * c :: real) x :> D * c"
1.155 -by (simp add: DERIV_cmult mult_commute [of _ c])
1.156 -
1.157 -lemma DERIV_pow2: "DERIV (%x. x ^ Suc n) x :> real (Suc n) * (x ^ n)"
1.158 -by (rule lemma_DERIV_subst, rule DERIV_pow, simp)
1.159 -declare DERIV_pow2 [simp] DERIV_pow [simp]
1.160 -
1.161 -lemma DERIV_add_const: "DERIV f x :> D ==>  DERIV (%x. a + f x :: 'a::real_normed_field) x :> D"
1.162 -by (rule lemma_DERIV_subst, rule DERIV_add, auto)
1.163 -
1.164 -lemma poly_DERIV[simp]: "DERIV (%x. poly p x) x :> poly (pderiv p) x"
1.165 -apply (induct p)
1.166 -apply simp
1.168 -apply (rule lemma_DERIV_subst)
1.169 -apply (rule DERIV_add DERIV_mult DERIV_const DERIV_ident | assumption)+
1.170 -apply simp
1.171 -done
1.172 -
1.173 -text{* Consequences of the derivative theorem above*}
1.174 -
1.175 -lemma poly_differentiable[simp]: "(%x. poly p x) differentiable (x::real)"
1.177 -apply (blast intro: poly_DERIV)
1.178 -done
1.179 -
1.180 -lemma poly_isCont[simp]: "isCont (%x. poly p x) (x::real)"
1.181 -by (rule poly_DERIV [THEN DERIV_isCont])
1.182 -
1.183 -lemma poly_IVT_pos: "[| a < b; poly p (a::real) < 0; 0 < poly p b |]
1.184 -      ==> \<exists>x. a < x & x < b & (poly p x = 0)"
1.185 -apply (cut_tac f = "%x. poly p x" and a = a and b = b and y = 0 in IVT_objl)
1.186 -apply (auto simp add: order_le_less)
1.187 -done
1.188 -
1.189 -lemma poly_IVT_neg: "[| (a::real) < b; 0 < poly p a; poly p b < 0 |]
1.190 -      ==> \<exists>x. a < x & x < b & (poly p x = 0)"
1.191 -by (insert poly_IVT_pos [where p = "- p" ]) simp
1.192 -
1.193 -lemma poly_MVT: "(a::real) < b ==>
1.194 -     \<exists>x. a < x & x < b & (poly p b - poly p a = (b - a) * poly (pderiv p) x)"
1.195 -apply (drule_tac f = "poly p" in MVT, auto)
1.196 -apply (rule_tac x = z in exI)
1.197 -apply (auto simp add: real_mult_left_cancel poly_DERIV [THEN DERIV_unique])
1.198 -done
1.199 -
1.200 -text{*Lemmas for Derivatives*}
1.201 -
1.202 -(* FIXME
1.203 -lemma lemma_order_pderiv [rule_format]:
1.204 -     "\<forall>p q a. 0 < n &
1.205 -       poly (pderiv p) \<noteq> poly [] &
1.206 -       poly p = poly ([- a, 1] %^ n *** q) & ~ [- a, 1] divides q
1.207 -       --> n = Suc (order a (pderiv p))"
1.208 -apply (induct "n", safe)
1.209 -apply (rule order_unique_lemma, rule conjI, assumption)
1.210 -apply (subgoal_tac "\<forall>r. r divides (pderiv p) = r divides (pderiv ([-a, 1] %^ Suc n *** q))")
1.211 -apply (drule_tac [2] poly_pderiv_welldef)
1.212 - prefer 2 apply (simp add: divides_def del: pmult_Cons pexp_Suc)
1.213 -apply (simp del: pmult_Cons pexp_Suc)
1.214 -apply (rule conjI)
1.215 -apply (simp add: divides_def fun_eq del: pmult_Cons pexp_Suc)
1.216 -apply (rule_tac x = "[-a, 1] *** (pderiv q) +++ real (Suc n) %* q" in exI)
1.217 -apply (simp add: poly_pderiv_mult poly_pderiv_exp_prime poly_add poly_mult poly_cmult right_distrib mult_ac del: pmult_Cons pexp_Suc)
1.218 -apply (simp add: poly_mult right_distrib left_distrib mult_ac del: pmult_Cons)
1.219 -apply (erule_tac V = "\<forall>r. r divides pderiv p = r divides pderiv ([- a, 1] %^ Suc n *** q)" in thin_rl)
1.220 -apply (unfold divides_def)
1.221 -apply (simp (no_asm) add: poly_pderiv_mult poly_pderiv_exp_prime fun_eq poly_add poly_mult del: pmult_Cons pexp_Suc)
1.222 -apply (rule contrapos_np, assumption)
1.223 -apply (rotate_tac 3, erule contrapos_np)
1.224 -apply (simp del: pmult_Cons pexp_Suc, safe)
1.225 -apply (rule_tac x = "inverse (real (Suc n)) %* (qa +++ -- (pderiv q))" in exI)
1.226 -apply (subgoal_tac "poly ([-a, 1] %^ n *** q) = poly ([-a, 1] %^ n *** ([-a, 1] *** (inverse (real (Suc n)) %* (qa +++ -- (pderiv q))))) ")
1.227 -apply (drule poly_mult_left_cancel [THEN iffD1], simp)
1.228 -apply (simp add: fun_eq poly_mult poly_add poly_cmult poly_minus del: pmult_Cons mult_cancel_left, safe)
1.229 -apply (rule_tac c1 = "real (Suc n)" in real_mult_left_cancel [THEN iffD1])
1.230 -apply (simp (no_asm))
1.231 -apply (subgoal_tac "real (Suc n) * (poly ([- a, 1] %^ n) xa * poly q xa) =
1.232 -          (poly qa xa + - poly (pderiv q) xa) *
1.233 -          (poly ([- a, 1] %^ n) xa *
1.234 -           ((- a + xa) * (inverse (real (Suc n)) * real (Suc n))))")
1.235 -apply (simp only: mult_ac)
1.236 -apply (rotate_tac 2)
1.237 -apply (drule_tac x = xa in spec)
1.238 -apply (simp add: left_distrib mult_ac del: pmult_Cons)
1.239 -done
1.240 -
1.241 -lemma order_pderiv: "[| poly (pderiv p) \<noteq> poly []; order a p \<noteq> 0 |]
1.242 -      ==> (order a p = Suc (order a (pderiv p)))"
1.243 -apply (case_tac "poly p = poly []")
1.244 -apply (auto dest: pderiv_zero)
1.245 -apply (drule_tac a = a and p = p in order_decomp)
1.246 -using neq0_conv
1.247 -apply (blast intro: lemma_order_pderiv)
1.248 -done
1.249 -
1.250 -text{*Now justify the standard squarefree decomposition, i.e. f / gcd(f,f'). *}
1.251 -
1.252 -lemma poly_squarefree_decomp_order: "[| poly (pderiv p) \<noteq> poly [];
1.253 -         poly p = poly (q *** d);
1.254 -         poly (pderiv p) = poly (e *** d);
1.255 -         poly d = poly (r *** p +++ s *** pderiv p)
1.256 -      |] ==> order a q = (if order a p = 0 then 0 else 1)"
1.257 -apply (subgoal_tac "order a p = order a q + order a d")
1.258 -apply (rule_tac [2] s = "order a (q *** d)" in trans)
1.259 -prefer 2 apply (blast intro: order_poly)
1.260 -apply (rule_tac [2] order_mult)
1.261 - prefer 2 apply force
1.262 -apply (case_tac "order a p = 0", simp)
1.263 -apply (subgoal_tac "order a (pderiv p) = order a e + order a d")
1.264 -apply (rule_tac [2] s = "order a (e *** d)" in trans)
1.265 -prefer 2 apply (blast intro: order_poly)
1.266 -apply (rule_tac [2] order_mult)
1.267 - prefer 2 apply force
1.268 -apply (case_tac "poly p = poly []")
1.269 -apply (drule_tac p = p in pderiv_zero, simp)
1.270 -apply (drule order_pderiv, assumption)
1.271 -apply (subgoal_tac "order a (pderiv p) \<le> order a d")
1.272 -apply (subgoal_tac [2] " ([-a, 1] %^ (order a (pderiv p))) divides d")
1.273 - prefer 2 apply (simp add: poly_entire order_divides)
1.274 -apply (subgoal_tac [2] " ([-a, 1] %^ (order a (pderiv p))) divides p & ([-a, 1] %^ (order a (pderiv p))) divides (pderiv p) ")
1.275 - prefer 3 apply (simp add: order_divides)
1.276 - prefer 2 apply (simp add: divides_def del: pexp_Suc pmult_Cons, safe)
1.277 -apply (rule_tac x = "r *** qa +++ s *** qaa" in exI)
1.278 -apply (simp add: fun_eq poly_add poly_mult left_distrib right_distrib mult_ac del: pexp_Suc pmult_Cons, auto)
1.279 -done
1.280 -
1.281 -
1.282 -lemma poly_squarefree_decomp_order2: "[| poly (pderiv p) \<noteq> poly [];
1.283 -         poly p = poly (q *** d);
1.284 -         poly (pderiv p) = poly (e *** d);
1.285 -         poly d = poly (r *** p +++ s *** pderiv p)
1.286 -      |] ==> \<forall>a. order a q = (if order a p = 0 then 0 else 1)"
1.287 -apply (blast intro: poly_squarefree_decomp_order)
1.288 -done
1.289 -
1.290 -lemma order_pderiv2: "[| poly (pderiv p) \<noteq> poly []; order a p \<noteq> 0 |]
1.291 -      ==> (order a (pderiv p) = n) = (order a p = Suc n)"
1.292 -apply (auto dest: order_pderiv)
1.293 -done
1.294 -
1.295 -lemma rsquarefree_roots:
1.296 -  "rsquarefree p = (\<forall>a. ~(poly p a = 0 & poly (pderiv p) a = 0))"
1.298 -apply (case_tac "poly p = poly []", simp, simp)
1.299 -apply (case_tac "poly (pderiv p) = poly []")
1.300 -apply simp
1.301 -apply (drule pderiv_iszero, clarify)
1.302 -apply (subgoal_tac "\<forall>a. order a p = order a [h]")
1.304 -apply (rule allI)
1.305 -apply (cut_tac p = "[h]" and a = a in order_root)
1.307 -apply (blast intro: order_poly)
1.308 -apply (auto simp add: order_root order_pderiv2)
1.309 -apply (erule_tac x="a" in allE, simp)
1.310 -done
1.311 -
1.312 -lemma poly_squarefree_decomp: "[| poly (pderiv p) \<noteq> poly [];
1.313 -         poly p = poly (q *** d);
1.314 -         poly (pderiv p) = poly (e *** d);
1.315 -         poly d = poly (r *** p +++ s *** pderiv p)
1.316 -      |] ==> rsquarefree q & (\<forall>a. (poly q a = 0) = (poly p a = 0))"
1.317 -apply (frule poly_squarefree_decomp_order2, assumption+)
1.318 -apply (case_tac "poly p = poly []")
1.319 -apply (blast dest: pderiv_zero)
1.320 -apply (simp (no_asm) add: rsquarefree_def order_root del: pmult_Cons)
1.321 -apply (simp add: poly_entire del: pmult_Cons)
1.322 -done
1.323 -*)
1.324
1.325  subsection {* Theorems about Limits *}
1.326
```