src/HOL/Deriv.thy
changeset 69022 e2858770997a
parent 69020 4f94e262976d
child 69064 5840724b1d71
child 69109 c9ea9290880f
equal deleted inserted replaced
69021:4dee7d326703 69022:e2858770997a
   683 
   683 
   684 lemma real_differentiableE [elim?]:
   684 lemma real_differentiableE [elim?]:
   685   assumes f: "f differentiable (at x within s)"
   685   assumes f: "f differentiable (at x within s)"
   686   obtains df where "(f has_real_derivative df) (at x within s)"
   686   obtains df where "(f has_real_derivative df) (at x within s)"
   687   using assms by (auto simp: real_differentiable_def)
   687   using assms by (auto simp: real_differentiable_def)
   688 
       
   689 lemma differentiableD:
       
   690   "f differentiable (at x within s) \<Longrightarrow> \<exists>D. (f has_real_derivative D) (at x within s)"
       
   691   by (auto elim: real_differentiableE)
       
   692 
       
   693 lemma differentiableI:
       
   694   "(f has_real_derivative D) (at x within s) \<Longrightarrow> f differentiable (at x within s)"
       
   695   by (force simp add: real_differentiable_def)
       
   696 
   688 
   697 lemma has_field_derivative_iff:
   689 lemma has_field_derivative_iff:
   698   "(f has_field_derivative D) (at x within S) \<longleftrightarrow>
   690   "(f has_field_derivative D) (at x within S) \<longleftrightarrow>
   699     ((\<lambda>y. (f y - f x) / (y - x)) \<longlongrightarrow> D) (at x within S)"
   691     ((\<lambda>y. (f y - f x) / (y - x)) \<longlongrightarrow> D) (at x within S)"
   700 proof -
   692 proof -
  1372 qed
  1364 qed
  1373 
  1365 
  1374 corollary Rolle:
  1366 corollary Rolle:
  1375   fixes a b :: real
  1367   fixes a b :: real
  1376   assumes ab: "a < b" "f a = f b" "continuous_on {a..b} f"
  1368   assumes ab: "a < b" "f a = f b" "continuous_on {a..b} f"
  1377     and dif [rule_format]: "\<forall>x. a < x \<and> x < b \<longrightarrow> f differentiable (at x)"
  1369     and dif [rule_format]: "\<And>x. \<lbrakk>a < x; x < b\<rbrakk> \<Longrightarrow> f differentiable (at x)"
  1378   shows "\<exists>z. a < z \<and> z < b \<and> DERIV f z :> 0"
  1370   shows "\<exists>z. a < z \<and> z < b \<and> DERIV f z :> 0"
  1379 proof -
  1371 proof -
  1380   obtain f' where f': "\<And>x. \<lbrakk>a < x; x < b\<rbrakk> \<Longrightarrow> (f has_derivative f' x) (at x)"
  1372   obtain f' where f': "\<And>x. \<lbrakk>a < x; x < b\<rbrakk> \<Longrightarrow> (f has_derivative f' x) (at x)"
  1381     using dif unfolding differentiable_def by metis
  1373     using dif unfolding differentiable_def by metis
  1382   then have "\<exists>z. a < z \<and> z < b \<and> f' z = (\<lambda>v. 0)"
  1374   then have "\<exists>z. a < z \<and> z < b \<and> f' z = (\<lambda>v. 0)"
  1521   shows "f b - f a = (b - a) * k"
  1513   shows "f b - f a = (b - a) * k"
  1522 proof (cases a b rule: linorder_cases)
  1514 proof (cases a b rule: linorder_cases)
  1523   case less
  1515   case less
  1524   show ?thesis
  1516   show ?thesis
  1525     using MVT [OF less] df
  1517     using MVT [OF less] df
  1526     by (metis DERIV_continuous DERIV_unique continuous_at_imp_continuous_on differentiableI)
  1518     by (metis DERIV_continuous DERIV_unique continuous_at_imp_continuous_on real_differentiable_def)
  1527 next
  1519 next
  1528   case greater
  1520   case greater
  1529   have  "f a - f b = (a - b) * k"
  1521   have  "f a - f b = (a - b) * k"
  1530     using MVT [OF greater] df
  1522     using MVT [OF greater] df
  1531     by (metis DERIV_continuous DERIV_unique continuous_at_imp_continuous_on differentiableI)
  1523     by (metis DERIV_continuous DERIV_unique continuous_at_imp_continuous_on real_differentiable_def)
  1532   then show ?thesis
  1524   then show ?thesis
  1533     by (simp add: algebra_simps)
  1525     by (simp add: algebra_simps)
  1534 qed auto
  1526 qed auto
  1535 
  1527 
  1536 lemma DERIV_const_ratio_const2:
  1528 lemma DERIV_const_ratio_const2:
  1590     and con: "continuous_on {a..b} f"
  1582     and con: "continuous_on {a..b} f"
  1591   shows "f a < f b"
  1583   shows "f a < f b"
  1592 proof (rule ccontr)
  1584 proof (rule ccontr)
  1593   assume f: "\<not> ?thesis"
  1585   assume f: "\<not> ?thesis"
  1594   have "\<exists>l z. a < z \<and> z < b \<and> DERIV f z :> l \<and> f b - f a = (b - a) * l"
  1586   have "\<exists>l z. a < z \<and> z < b \<and> DERIV f z :> l \<and> f b - f a = (b - a) * l"
  1595     by (rule MVT) (use assms Deriv.differentiableI in \<open>force+\<close>)
  1587     by (rule MVT) (use assms real_differentiable_def in \<open>force+\<close>)
  1596   then obtain l z where z: "a < z" "z < b" "DERIV f z :> l" and "f b - f a = (b - a) * l"
  1588   then obtain l z where z: "a < z" "z < b" "DERIV f z :> l" and "f b - f a = (b - a) * l"
  1597     by auto
  1589     by auto
  1598   with assms f have "\<not> l > 0"
  1590   with assms f have "\<not> l > 0"
  1599     by (metis linorder_not_le mult_le_0_iff diff_le_0_iff_le)
  1591     by (metis linorder_not_le mult_le_0_iff diff_le_0_iff_le)
  1600   with assms z show False
  1592   with assms z show False
  1623   with \<open>a \<le> b\<close> have "a < b"
  1615   with \<open>a \<le> b\<close> have "a < b"
  1624     by linarith
  1616     by linarith
  1625   moreover have "continuous_on {a..b} f"
  1617   moreover have "continuous_on {a..b} f"
  1626     by (meson DERIV_isCont assms(2) atLeastAtMost_iff continuous_at_imp_continuous_on)
  1618     by (meson DERIV_isCont assms(2) atLeastAtMost_iff continuous_at_imp_continuous_on)
  1627   ultimately have "\<exists>l z. a < z \<and> z < b \<and> DERIV f z :> l \<and> f b - f a = (b - a) * l"
  1619   ultimately have "\<exists>l z. a < z \<and> z < b \<and> DERIV f z :> l \<and> f b - f a = (b - a) * l"
  1628     using assms MVT [OF \<open>a < b\<close>, of f] differentiableI less_eq_real_def by blast
  1620     using assms MVT [OF \<open>a < b\<close>, of f] real_differentiable_def less_eq_real_def by blast
  1629   then obtain l z where lz: "a < z" "z < b" "DERIV f z :> l" and **: "f b - f a = (b - a) * l"
  1621   then obtain l z where lz: "a < z" "z < b" "DERIV f z :> l" and **: "f b - f a = (b - a) * l"
  1630     by auto
  1622     by auto
  1631   with * have "a < b" "f b < f a" by auto
  1623   with * have "a < b" "f b < f a" by auto
  1632   with ** have "\<not> l \<ge> 0" by (auto simp add: not_le algebra_simps)
  1624   with ** have "\<not> l \<ge> 0" by (auto simp add: not_le algebra_simps)
  1633     (metis * add_le_cancel_right assms(1) less_eq_real_def mult_right_mono add_left_mono linear order_refl)
  1625     (metis * add_le_cancel_right assms(1) less_eq_real_def mult_right_mono add_left_mono linear order_refl)
  1770   qed
  1762   qed
  1771   then obtain l where l: "\<exists>z. a < z \<and> z < b \<and> DERIV ?h z :> l \<and> ?h b - ?h a = (b - a) * l" ..
  1763   then obtain l where l: "\<exists>z. a < z \<and> z < b \<and> DERIV ?h z :> l \<and> ?h b - ?h a = (b - a) * l" ..
  1772   then obtain c where c: "a < c \<and> c < b \<and> DERIV ?h c :> l \<and> ?h b - ?h a = (b - a) * l" ..
  1764   then obtain c where c: "a < c \<and> c < b \<and> DERIV ?h c :> l \<and> ?h b - ?h a = (b - a) * l" ..
  1773 
  1765 
  1774   from c have cint: "a < c \<and> c < b" by auto
  1766   from c have cint: "a < c \<and> c < b" by auto
  1775   with gd have "g differentiable (at c)" by simp
  1767   then obtain g'c where g'c: "DERIV g c :> g'c"
  1776   then have "\<exists>D. DERIV g c :> D" by (rule differentiableD)
  1768     using gd real_differentiable_def by blast 
  1777   then obtain g'c where g'c: "DERIV g c :> g'c" ..
       
  1778 
       
  1779   from c have "a < c \<and> c < b" by auto
  1769   from c have "a < c \<and> c < b" by auto
  1780   with fd have "f differentiable (at c)" by simp
  1770   then obtain f'c where f'c: "DERIV f c :> f'c"
  1781   then have "\<exists>D. DERIV f c :> D" by (rule differentiableD)
  1771     using fd real_differentiable_def by blast 
  1782   then obtain f'c where f'c: "DERIV f c :> f'c" ..
       
  1783 
  1772 
  1784   from c have "DERIV ?h c :> l" by auto
  1773   from c have "DERIV ?h c :> l" by auto
  1785   moreover have "DERIV ?h c :>  g'c * (f b - f a) - f'c * (g b - g a)"
  1774   moreover have "DERIV ?h c :>  g'c * (f b - f a) - f'c * (g b - g a)"
  1786     using g'c f'c by (auto intro!: derivative_eq_intros)
  1775     using g'c f'c by (auto intro!: derivative_eq_intros)
  1787   ultimately have leq: "l =  g'c * (f b - f a) - f'c * (g b - g a)" by (rule DERIV_unique)
  1776   ultimately have leq: "l =  g'c * (f b - f a) - f'c * (g b - g a)" by (rule DERIV_unique)