conversion of Hyperreal/MacLaurin_lemmas to Isar script
authorpaulson
Wed, 28 Jul 2004 10:49:29 +0200
changeset 15079 2ef899e4526d
parent 15078 8beb68a7afd9
child 15080 7912ace86f31
conversion of Hyperreal/MacLaurin_lemmas to Isar script
src/HOL/HOL.thy
src/HOL/Hyperreal/Integration.ML
src/HOL/Hyperreal/Lim.thy
src/HOL/Hyperreal/MacLaurin.thy
src/HOL/Hyperreal/MacLaurin_lemmas.ML
src/HOL/Hyperreal/Transcendental.thy
src/HOL/IsaMakefile
--- a/src/HOL/HOL.thy	Tue Jul 27 15:39:59 2004 +0200
+++ b/src/HOL/HOL.thy	Wed Jul 28 10:49:29 2004 +0200
@@ -818,6 +818,9 @@
   apply (insert linorder_linear, blast)
   done
 
+lemma linorder_le_less_linear: "!!x::'a::linorder. x\<le>y | y<x"
+  by (simp add: order_le_less linorder_less_linear)
+
 lemma linorder_le_cases [case_names le ge]:
     "((x::'a::linorder) \<le> y ==> P) ==> (y \<le> x ==> P) ==> P"
   by (insert linorder_linear, blast)
--- a/src/HOL/Hyperreal/Integration.ML	Tue Jul 27 15:39:59 2004 +0200
+++ b/src/HOL/Hyperreal/Integration.ML	Wed Jul 28 10:49:29 2004 +0200
@@ -7,6 +7,9 @@
 val mult_2 = thm"mult_2";
 val mult_2_right = thm"mult_2_right";
 
+fun ARITH_PROVE str = prove_goal thy str
+                      (fn prems => [cut_facts_tac prems 1,arith_tac 1]);
+
 Goalw [psize_def] "a = b ==> psize (%n. if n = 0 then a else b) = 0";
 by Auto_tac;
 qed "partition_zero";
--- a/src/HOL/Hyperreal/Lim.thy	Tue Jul 27 15:39:59 2004 +0200
+++ b/src/HOL/Hyperreal/Lim.thy	Wed Jul 28 10:49:29 2004 +0200
@@ -35,11 +35,11 @@
 
   (* differentiation: D is derivative of function f at x *)
   deriv:: "[real=>real,real,real] => bool"
-			    ("(DERIV (_)/ (_)/ :> (_))" [60, 60, 60] 60)
+			    ("(DERIV (_)/ (_)/ :> (_))" [0, 0, 60] 60)
   "DERIV f x :> D == ((%h. (f(x + h) + -f x)/h) -- 0 --> D)"
 
   nsderiv :: "[real=>real,real,real] => bool"
-			    ("(NSDERIV (_)/ (_)/ :> (_))" [60, 60, 60] 60)
+			    ("(NSDERIV (_)/ (_)/ :> (_))" [0, 0, 60] 60)
   "NSDERIV f x :> D == (\<forall>h \<in> Infinitesimal - {0}.
 			(( *f* f)(hypreal_of_real x + h) +
 			 - hypreal_of_real (f x))/h @= hypreal_of_real D)"
--- a/src/HOL/Hyperreal/MacLaurin.thy	Tue Jul 27 15:39:59 2004 +0200
+++ b/src/HOL/Hyperreal/MacLaurin.thy	Wed Jul 28 10:49:29 2004 +0200
@@ -2,48 +2,614 @@
     Author      : Jacques D. Fleuriot
     Copyright   : 2001 University of Edinburgh
     Description : MacLaurin series
+    Conversion to Isar and new proofs by Lawrence C Paulson, 2004
 *)
 
-theory MacLaurin = Log
-files ("MacLaurin_lemmas.ML"):
+theory MacLaurin = Log:
+
+lemma sumr_offset: "sumr 0 n (%m. f (m+k)) = sumr 0 (n+k) f - sumr 0 k f"
+by (induct_tac "n", auto)
+
+lemma sumr_offset2: "\<forall>f. sumr 0 n (%m. f (m+k)) = sumr 0 (n+k) f - sumr 0 k f"
+by (induct_tac "n", auto)
+
+lemma sumr_offset3: "sumr 0 (n+k) f = sumr 0 n (%m. f (m+k)) + sumr 0 k f"
+by (simp  add: sumr_offset)
+
+lemma sumr_offset4: "\<forall>n f. sumr 0 (n+k) f = sumr 0 n (%m. f (m+k)) + sumr 0 k f"
+by (simp add: sumr_offset)
+
+lemma sumr_from_1_from_0: "0 < n ==>
+      sumr (Suc 0) (Suc n) (%n. (if even(n) then 0 else
+             ((- 1) ^ ((n - (Suc 0)) div 2))/(real (fact n))) * a ^ n) =
+      sumr 0 (Suc n) (%n. (if even(n) then 0 else
+             ((- 1) ^ ((n - (Suc 0)) div 2))/(real (fact n))) * a ^ n)"
+by (rule_tac n1 = 1 in sumr_split_add [THEN subst], auto)
+
+
+subsection{*Maclaurin's Theorem with Lagrange Form of Remainder*}
+
+text{*This is a very long, messy proof even now that it's been broken down
+into lemmas.*}
+
+lemma Maclaurin_lemma:
+    "0 < h ==>
+     \<exists>B. f h = sumr 0 n (%m. (j m / real (fact m)) * (h^m)) +
+               (B * ((h^n) / real(fact n)))"
+by (rule_tac x = "(f h - sumr 0 n (%m. (j m / real (fact m)) * h^m)) *
+                 real(fact n) / (h^n)"
+       in exI, auto)
+
+
+lemma eq_diff_eq': "(x = y - z) = (y = x + (z::real))"
+by arith
+
+text{*A crude tactic to differentiate by proof.*}
+ML
+{*
+exception DERIV_name;
+fun get_fun_name (_ $ (Const ("Lim.deriv",_) $ Abs(_,_, Const (f,_) $ _) $ _ $ _)) = f
+|   get_fun_name (_ $ (_ $ (Const ("Lim.deriv",_) $ Abs(_,_, Const (f,_) $ _) $ _ $ _))) = f
+|   get_fun_name _ = raise DERIV_name;
+
+val deriv_rulesI = [DERIV_Id,DERIV_const,DERIV_cos,DERIV_cmult,
+                    DERIV_sin, DERIV_exp, DERIV_inverse,DERIV_pow,
+                    DERIV_add, DERIV_diff, DERIV_mult, DERIV_minus,
+                    DERIV_inverse_fun,DERIV_quotient,DERIV_fun_pow,
+                    DERIV_fun_exp,DERIV_fun_sin,DERIV_fun_cos,
+                    DERIV_Id,DERIV_const,DERIV_cos];
+
+val deriv_tac =
+  SUBGOAL (fn (prem,i) =>
+   (resolve_tac deriv_rulesI i) ORELSE
+    ((rtac (read_instantiate [("f",get_fun_name prem)]
+                     DERIV_chain2) i) handle DERIV_name => no_tac));;
+
+val DERIV_tac = ALLGOALS(fn i => REPEAT(deriv_tac i));
+*}
+
+lemma Maclaurin_lemma2:
+      "[| \<forall>m t. m < n \<and> 0\<le>t \<and> t\<le>h \<longrightarrow> DERIV (diff m) t :> diff (Suc m) t;
+          n = Suc k;
+        difg =
+        (\<lambda>m t. diff m t -
+               ((\<Sum>p = 0..<n - m. diff (m + p) 0 / real (fact p) * t ^ p) +
+                B * (t ^ (n - m) / real (fact (n - m)))))|] ==>
+        \<forall>m t. m < n & 0 \<le> t & t \<le> h -->
+                    DERIV (difg m) t :> difg (Suc m) t"
+apply clarify
+apply (rule DERIV_diff)
+apply (simp (no_asm_simp))
+apply (tactic DERIV_tac)
+apply (tactic DERIV_tac)
+apply (rule_tac [2] lemma_DERIV_subst)
+apply (rule_tac [2] DERIV_quotient)
+apply (rule_tac [3] DERIV_const)
+apply (rule_tac [2] DERIV_pow)
+  prefer 3 apply (simp add: fact_diff_Suc)
+ prefer 2 apply simp
+apply (frule_tac m = m in less_add_one, clarify)
+apply (simp del: sumr_Suc)
+apply (insert sumr_offset4 [of 1])
+apply (simp del: sumr_Suc fact_Suc realpow_Suc)
+apply (rule lemma_DERIV_subst)
+apply (rule DERIV_add)
+apply (rule_tac [2] DERIV_const)
+apply (rule DERIV_sumr, clarify)
+ prefer 2 apply simp
+apply (simp (no_asm) add: divide_inverse mult_assoc del: fact_Suc realpow_Suc)
+apply (rule DERIV_cmult)
+apply (rule lemma_DERIV_subst)
+apply (best intro: DERIV_chain2 intro!: DERIV_intros)
+apply (subst fact_Suc)
+apply (subst real_of_nat_mult)
+apply (simp add: inverse_mult_distrib mult_ac)
+done
+
+
+lemma Maclaurin_lemma3:
+     "[|\<forall>k t. k < Suc m \<and> 0\<le>t & t\<le>h \<longrightarrow> DERIV (difg k) t :> difg (Suc k) t;
+        \<forall>k<Suc m. difg k 0 = 0; DERIV (difg n) t :> 0;  n < m; 0 < t;
+        t < h|]
+     ==> \<exists>ta. 0 < ta & ta < t & DERIV (difg (Suc n)) ta :> 0"
+apply (rule Rolle, assumption, simp)
+apply (drule_tac x = n and P="%k. k<Suc m --> difg k 0 = 0" in spec)
+apply (rule DERIV_unique)
+prefer 2 apply assumption
+apply force
+apply (subgoal_tac "\<forall>ta. 0 \<le> ta & ta \<le> t --> (difg (Suc n)) differentiable ta")
+apply (simp add: differentiable_def)
+apply (blast dest!: DERIV_isCont)
+apply (simp add: differentiable_def, clarify)
+apply (rule_tac x = "difg (Suc (Suc n)) ta" in exI)
+apply force
+apply (simp add: differentiable_def, clarify)
+apply (rule_tac x = "difg (Suc (Suc n)) x" in exI)
+apply force
+done
 
-use "MacLaurin_lemmas.ML"
+lemma Maclaurin:
+   "[| 0 < h; 0 < n; diff 0 = f;
+       \<forall>m t. m < n & 0 \<le> t & t \<le> h --> DERIV (diff m) t :> diff (Suc m) t |]
+    ==> \<exists>t. 0 < t &
+              t < h &
+              f h =
+              sumr 0 n (%m. (diff m 0 / real (fact m)) * h ^ m) +
+              (diff n t / real (fact n)) * h ^ n"
+apply (case_tac "n = 0", force)
+apply (drule not0_implies_Suc)
+apply (erule exE)
+apply (frule_tac f=f and n=n and j="%m. diff m 0" in Maclaurin_lemma)
+apply (erule exE)
+apply (subgoal_tac "\<exists>g.
+     g = (%t. f t - (sumr 0 n (%m. (diff m 0 / real(fact m)) * t^m) + (B * (t^n / real(fact n)))))")
+ prefer 2 apply blast
+apply (erule exE)
+apply (subgoal_tac "g 0 = 0 & g h =0")
+ prefer 2
+ apply (simp del: sumr_Suc)
+ apply (cut_tac n = m and k = 1 in sumr_offset2)
+ apply (simp add: eq_diff_eq' del: sumr_Suc)
+apply (subgoal_tac "\<exists>difg. difg = (%m t. diff m t - (sumr 0 (n - m) (%p. (diff (m + p) 0 / real (fact p)) * (t ^ p)) + (B * ((t ^ (n - m)) / real (fact (n - m))))))")
+ prefer 2 apply blast
+apply (erule exE)
+apply (subgoal_tac "difg 0 = g")
+ prefer 2 apply simp
+apply (frule Maclaurin_lemma2, assumption+)
+apply (subgoal_tac "\<forall>ma. ma < n --> (\<exists>t. 0 < t & t < h & difg (Suc ma) t = 0) ")
+apply (drule_tac x = m and P="%m. m<n --> (\<exists>t. ?QQ m t)" in spec)
+apply (erule impE)
+apply (simp (no_asm_simp))
+apply (erule exE)
+apply (rule_tac x = t in exI)
+apply (simp del: realpow_Suc fact_Suc)
+apply (subgoal_tac "\<forall>m. m < n --> difg m 0 = 0")
+ prefer 2
+ apply clarify
+ apply simp
+ apply (frule_tac m = ma in less_add_one, clarify)
+ apply (simp del: sumr_Suc)
+apply (insert sumr_offset4 [of 1])
+apply (simp del: sumr_Suc fact_Suc realpow_Suc)
+apply (subgoal_tac "\<forall>m. m < n --> (\<exists>t. 0 < t & t < h & DERIV (difg m) t :> 0) ")
+apply (rule allI, rule impI)
+apply (drule_tac x = ma and P="%m. m<n --> (\<exists>t. ?QQ m t)" in spec)
+apply (erule impE, assumption)
+apply (erule exE)
+apply (rule_tac x = t in exI)
+(* do some tidying up *)
+apply (erule_tac [!] V= "difg = (%m t. diff m t - (sumr 0 (n - m) (%p. diff (m + p) 0 / real (fact p) * t ^ p) + B * (t ^ (n - m) / real (fact (n - m)))))"
+       in thin_rl)
+apply (erule_tac [!] V="g = (%t. f t - (sumr 0 n (%m. diff m 0 / real (fact m) * t ^ m) + B * (t ^ n / real (fact n))))"
+       in thin_rl)
+apply (erule_tac [!] V="f h = sumr 0 n (%m. diff m 0 / real (fact m) * h ^ m) + B * (h ^ n / real (fact n))"
+       in thin_rl)
+(* back to business *)
+apply (simp (no_asm_simp))
+apply (rule DERIV_unique)
+prefer 2 apply blast
+apply force
+apply (rule allI, induct_tac "ma")
+apply (rule impI, rule Rolle, assumption, simp, simp)
+apply (subgoal_tac "\<forall>t. 0 \<le> t & t \<le> h --> g differentiable t")
+apply (simp add: differentiable_def)
+apply (blast dest: DERIV_isCont)
+apply (simp add: differentiable_def, clarify)
+apply (rule_tac x = "difg (Suc 0) t" in exI)
+apply force
+apply (simp add: differentiable_def, clarify)
+apply (rule_tac x = "difg (Suc 0) x" in exI)
+apply force
+apply safe
+apply force
+apply (frule Maclaurin_lemma3, assumption+, safe)
+apply (rule_tac x = ta in exI, force)
+done
+
+lemma Maclaurin_objl:
+     "0 < h & 0 < n & diff 0 = f &
+       (\<forall>m t. m < n & 0 \<le> t & t \<le> h --> DERIV (diff m) t :> diff (Suc m) t)
+    --> (\<exists>t. 0 < t &
+              t < h &
+              f h =
+              sumr 0 n (%m. diff m 0 / real (fact m) * h ^ m) +
+              diff n t / real (fact n) * h ^ n)"
+by (blast intro: Maclaurin)
+
+
+lemma Maclaurin2:
+   "[| 0 < h; diff 0 = f;
+       \<forall>m t.
+          m < n & 0 \<le> t & t \<le> h --> DERIV (diff m) t :> diff (Suc m) t |]
+    ==> \<exists>t. 0 < t &
+              t \<le> h &
+              f h =
+              sumr 0 n (%m. diff m 0 / real (fact m) * h ^ m) +
+              diff n t / real (fact n) * h ^ n"
+apply (case_tac "n", auto)
+apply (drule Maclaurin, auto)
+done
+
+lemma Maclaurin2_objl:
+     "0 < h & diff 0 = f &
+       (\<forall>m t.
+          m < n & 0 \<le> t & t \<le> h --> DERIV (diff m) t :> diff (Suc m) t)
+    --> (\<exists>t. 0 < t &
+              t \<le> h &
+              f h =
+              sumr 0 n (%m. diff m 0 / real (fact m) * h ^ m) +
+              diff n t / real (fact n) * h ^ n)"
+by (blast intro: Maclaurin2)
+
+lemma Maclaurin_minus:
+   "[| h < 0; 0 < n; diff 0 = f;
+       \<forall>m t. m < n & h \<le> t & t \<le> 0 --> DERIV (diff m) t :> diff (Suc m) t |]
+    ==> \<exists>t. h < t &
+              t < 0 &
+              f h =
+              sumr 0 n (%m. diff m 0 / real (fact m) * h ^ m) +
+              diff n t / real (fact n) * h ^ n"
+apply (cut_tac f = "%x. f (-x)"
+        and diff = "%n x. ((- 1) ^ n) * diff n (-x)"
+        and h = "-h" and n = n in Maclaurin_objl)
+apply simp
+apply safe
+apply (subst minus_mult_right)
+apply (rule DERIV_cmult)
+apply (rule lemma_DERIV_subst)
+apply (rule DERIV_chain2 [where g=uminus])
+apply (rule_tac [2] DERIV_minus, rule_tac [2] DERIV_Id)
+prefer 2 apply force
+apply force
+apply (rule_tac x = "-t" in exI, auto)
+apply (subgoal_tac "(\<Sum>m = 0..<n. -1 ^ m * diff m 0 * (-h)^m / real(fact m)) =
+                    (\<Sum>m = 0..<n. diff m 0 * h ^ m / real(fact m))")
+apply (rule_tac [2] sumr_fun_eq)
+apply (auto simp add: divide_inverse power_mult_distrib [symmetric])
+done
+
+lemma Maclaurin_minus_objl:
+     "(h < 0 & 0 < n & diff 0 = f &
+       (\<forall>m t.
+          m < n & h \<le> t & t \<le> 0 --> DERIV (diff m) t :> diff (Suc m) t))
+    --> (\<exists>t. h < t &
+              t < 0 &
+              f h =
+              sumr 0 n (%m. diff m 0 / real (fact m) * h ^ m) +
+              diff n t / real (fact n) * h ^ n)"
+by (blast intro: Maclaurin_minus)
+
+
+subsection{*More Convenient "Bidirectional" Version.*}
+
+(* not good for PVS sin_approx, cos_approx *)
+
+lemma Maclaurin_bi_le_lemma [rule_format]:
+     "0 < n \<longrightarrow>
+       diff 0 0 =
+       (\<Sum>m = 0..<n. diff m 0 * 0 ^ m / real (fact m)) +
+       diff n 0 * 0 ^ n / real (fact n)"
+by (induct_tac "n", auto)
 
-lemma Maclaurin_sin_bound: 
-  "abs(sin x - sumr 0 n (%m. (if even m then 0 else ((- 1) ^ ((m - (Suc 0)) div 2)) / real (fact m)) * 
-  x ^ m))  <= inverse(real (fact n)) * abs(x) ^ n"
+lemma Maclaurin_bi_le:
+   "[| diff 0 = f;
+       \<forall>m t. m < n & abs t \<le> abs x --> DERIV (diff m) t :> diff (Suc m) t |]
+    ==> \<exists>t. abs t \<le> abs x &
+              f x =
+              sumr 0 n (%m. diff m 0 / real (fact m) * x ^ m) +
+              diff n t / real (fact n) * x ^ n"
+apply (case_tac "n = 0", force)
+apply (case_tac "x = 0")
+apply (rule_tac x = 0 in exI)
+apply (force simp add: Maclaurin_bi_le_lemma)
+apply (cut_tac x = x and y = 0 in linorder_less_linear, auto)
+txt{*Case 1, where @{term "x < 0"}*}
+apply (cut_tac f = "diff 0" and diff = diff and h = x and n = n in Maclaurin_minus_objl, safe)
+apply (simp add: abs_if)
+apply (rule_tac x = t in exI)
+apply (simp add: abs_if)
+txt{*Case 2, where @{term "0 < x"}*}
+apply (cut_tac f = "diff 0" and diff = diff and h = x and n = n in Maclaurin_objl, safe)
+apply (simp add: abs_if)
+apply (rule_tac x = t in exI)
+apply (simp add: abs_if)
+done
+
+lemma Maclaurin_all_lt:
+     "[| diff 0 = f;
+         \<forall>m x. DERIV (diff m) x :> diff(Suc m) x;
+        x ~= 0; 0 < n
+      |] ==> \<exists>t. 0 < abs t & abs t < abs x &
+               f x = sumr 0 n (%m. (diff m 0 / real (fact m)) * x ^ m) +
+                     (diff n t / real (fact n)) * x ^ n"
+apply (rule_tac x = x and y = 0 in linorder_cases)
+prefer 2 apply blast
+apply (drule_tac [2] diff=diff in Maclaurin)
+apply (drule_tac diff=diff in Maclaurin_minus, simp_all, safe)
+apply (rule_tac [!] x = t in exI, auto, arith+)
+done
+
+lemma Maclaurin_all_lt_objl:
+     "diff 0 = f &
+      (\<forall>m x. DERIV (diff m) x :> diff(Suc m) x) &
+      x ~= 0 & 0 < n
+      --> (\<exists>t. 0 < abs t & abs t < abs x &
+               f x = sumr 0 n (%m. (diff m 0 / real (fact m)) * x ^ m) +
+                     (diff n t / real (fact n)) * x ^ n)"
+by (blast intro: Maclaurin_all_lt)
+
+lemma Maclaurin_zero [rule_format]:
+     "x = (0::real)
+      ==> 0 < n -->
+          sumr 0 n (%m. (diff m (0::real) / real (fact m)) * x ^ m) =
+          diff 0 0"
+by (induct n, auto)
+
+lemma Maclaurin_all_le: "[| diff 0 = f;
+        \<forall>m x. DERIV (diff m) x :> diff (Suc m) x
+      |] ==> \<exists>t. abs t \<le> abs x &
+              f x = sumr 0 n (%m. (diff m 0 / real (fact m)) * x ^ m) +
+                    (diff n t / real (fact n)) * x ^ n"
+apply (insert linorder_le_less_linear [of n 0])
+apply (erule disjE, force)
+apply (case_tac "x = 0")
+apply (frule_tac diff = diff and n = n in Maclaurin_zero, assumption)
+apply (drule gr_implies_not0 [THEN not0_implies_Suc])
+apply (rule_tac x = 0 in exI, force)
+apply (frule_tac diff = diff and n = n in Maclaurin_all_lt, auto)
+apply (rule_tac x = t in exI, auto)
+done
+
+lemma Maclaurin_all_le_objl: "diff 0 = f &
+      (\<forall>m x. DERIV (diff m) x :> diff (Suc m) x)
+      --> (\<exists>t. abs t \<le> abs x &
+              f x = sumr 0 n (%m. (diff m 0 / real (fact m)) * x ^ m) +
+                    (diff n t / real (fact n)) * x ^ n)"
+by (blast intro: Maclaurin_all_le)
+
+
+subsection{*Version for Exponential Function*}
+
+lemma Maclaurin_exp_lt: "[| x ~= 0; 0 < n |]
+      ==> (\<exists>t. 0 < abs t &
+                abs t < abs x &
+                exp x = sumr 0 n (%m. (x ^ m) / real (fact m)) +
+                        (exp t / real (fact n)) * x ^ n)"
+by (cut_tac diff = "%n. exp" and f = exp and x = x and n = n in Maclaurin_all_lt_objl, auto)
+
+
+lemma Maclaurin_exp_le:
+     "\<exists>t. abs t \<le> abs x &
+            exp x = sumr 0 n (%m. (x ^ m) / real (fact m)) +
+                       (exp t / real (fact n)) * x ^ n"
+by (cut_tac diff = "%n. exp" and f = exp and x = x and n = n in Maclaurin_all_le_objl, auto)
+
+
+subsection{*Version for Sine Function*}
+
+lemma MVT2:
+     "[| a < b; \<forall>x. a \<le> x & x \<le> b --> DERIV f x :> f'(x) |]
+      ==> \<exists>z. a < z & z < b & (f b - f a = (b - a) * f'(z))"
+apply (drule MVT)
+apply (blast intro: DERIV_isCont)
+apply (force dest: order_less_imp_le simp add: differentiable_def)
+apply (blast dest: DERIV_unique order_less_imp_le)
+done
+
+lemma mod_exhaust_less_4:
+     "m mod 4 = 0 | m mod 4 = 1 | m mod 4 = 2 | m mod 4 = (3::nat)"
+by (case_tac "m mod 4", auto, arith)
+
+lemma Suc_Suc_mult_two_diff_two [rule_format, simp]:
+     "0 < n --> Suc (Suc (2 * n - 2)) = 2*n"
+by (induct_tac "n", auto)
+
+lemma lemma_Suc_Suc_4n_diff_2 [rule_format, simp]:
+     "0 < n --> Suc (Suc (4*n - 2)) = 4*n"
+by (induct_tac "n", auto)
+
+lemma Suc_mult_two_diff_one [rule_format, simp]:
+      "0 < n --> Suc (2 * n - 1) = 2*n"
+by (induct_tac "n", auto)
+
+lemma Maclaurin_sin_expansion:
+     "\<exists>t. sin x =
+       (sumr 0 n (%m. (if even m then 0
+                       else ((- 1) ^ ((m - (Suc 0)) div 2)) / real (fact m)) *
+                       x ^ m))
+      + ((sin(t + 1/2 * real (n) *pi) / real (fact n)) * x ^ n)"
+apply (cut_tac f = sin and n = n and x = x and diff = "%n x. sin (x + 1/2*real (n) *pi)" in Maclaurin_all_lt_objl)
+apply safe
+apply (simp (no_asm))
+apply (simp (no_asm))
+apply (case_tac "n", clarify, simp)
+apply (drule_tac x = 0 in spec, simp, simp)
+apply (rule ccontr, simp)
+apply (drule_tac x = x in spec, simp)
+apply (erule ssubst)
+apply (rule_tac x = t in exI, simp)
+apply (rule sumr_fun_eq)
+apply (auto simp add: odd_Suc_mult_two_ex)
+apply (auto simp add: even_mult_two_ex simp del: fact_Suc realpow_Suc)
+(*Could sin_zero_iff help?*)
+done
+
+lemma Maclaurin_sin_expansion2:
+     "\<exists>t. abs t \<le> abs x &
+       sin x =
+       (sumr 0 n (%m. (if even m then 0
+                       else ((- 1) ^ ((m - (Suc 0)) div 2)) / real (fact m)) *
+                       x ^ m))
+      + ((sin(t + 1/2 * real (n) *pi) / real (fact n)) * x ^ n)"
+apply (cut_tac f = sin and n = n and x = x
+        and diff = "%n x. sin (x + 1/2*real n * pi)" in Maclaurin_all_lt_objl)
+apply safe
+apply (simp (no_asm))
+apply (simp (no_asm))
+apply (case_tac "n", clarify, simp, simp)
+apply (rule ccontr, simp)
+apply (drule_tac x = x in spec, simp)
+apply (erule ssubst)
+apply (rule_tac x = t in exI, simp)
+apply (rule sumr_fun_eq)
+apply (auto simp add: odd_Suc_mult_two_ex)
+apply (auto simp add: even_mult_two_ex simp del: fact_Suc realpow_Suc)
+done
+
+lemma Maclaurin_sin_expansion3:
+     "[| 0 < n; 0 < x |] ==>
+       \<exists>t. 0 < t & t < x &
+       sin x =
+       (sumr 0 n (%m. (if even m then 0
+                       else ((- 1) ^ ((m - (Suc 0)) div 2)) / real (fact m)) *
+                       x ^ m))
+      + ((sin(t + 1/2 * real(n) *pi) / real (fact n)) * x ^ n)"
+apply (cut_tac f = sin and n = n and h = x and diff = "%n x. sin (x + 1/2*real (n) *pi)" in Maclaurin_objl)
+apply safe
+apply simp
+apply (simp (no_asm))
+apply (erule ssubst)
+apply (rule_tac x = t in exI, simp)
+apply (rule sumr_fun_eq)
+apply (auto simp add: odd_Suc_mult_two_ex)
+apply (auto simp add: even_mult_two_ex simp del: fact_Suc realpow_Suc)
+done
+
+lemma Maclaurin_sin_expansion4:
+     "0 < x ==>
+       \<exists>t. 0 < t & t \<le> x &
+       sin x =
+       (sumr 0 n (%m. (if even m then 0
+                       else ((- 1) ^ ((m - (Suc 0)) div 2)) / real (fact m)) *
+                       x ^ m))
+      + ((sin(t + 1/2 * real (n) *pi) / real (fact n)) * x ^ n)"
+apply (cut_tac f = sin and n = n and h = x and diff = "%n x. sin (x + 1/2*real (n) *pi)" in Maclaurin2_objl)
+apply safe
+apply simp
+apply (simp (no_asm))
+apply (erule ssubst)
+apply (rule_tac x = t in exI, simp)
+apply (rule sumr_fun_eq)
+apply (auto simp add: odd_Suc_mult_two_ex)
+apply (auto simp add: even_mult_two_ex simp del: fact_Suc realpow_Suc)
+done
+
+
+subsection{*Maclaurin Expansion for Cosine Function*}
+
+lemma sumr_cos_zero_one [simp]:
+     "sumr 0 (Suc n)
+         (%m. (if even m
+               then (- 1) ^ (m div 2)/(real  (fact m))
+               else 0) *
+              0 ^ m) = 1"
+by (induct_tac "n", auto)
+
+lemma Maclaurin_cos_expansion:
+     "\<exists>t. abs t \<le> abs x &
+       cos x =
+       (sumr 0 n (%m. (if even m
+                       then (- 1) ^ (m div 2)/(real (fact m))
+                       else 0) *
+                       x ^ m))
+      + ((cos(t + 1/2 * real (n) *pi) / real (fact n)) * x ^ n)"
+apply (cut_tac f = cos and n = n and x = x and diff = "%n x. cos (x + 1/2*real (n) *pi)" in Maclaurin_all_lt_objl)
+apply safe
+apply (simp (no_asm))
+apply (simp (no_asm))
+apply (case_tac "n", simp)
+apply (simp del: sumr_Suc)
+apply (rule ccontr, simp)
+apply (drule_tac x = x in spec, simp)
+apply (erule ssubst)
+apply (rule_tac x = t in exI, simp)
+apply (rule sumr_fun_eq)
+apply (auto simp add: odd_Suc_mult_two_ex)
+apply (auto simp add: even_mult_two_ex left_distrib cos_add simp del: fact_Suc realpow_Suc)
+apply (simp add: mult_commute [of _ pi])
+done
+
+lemma Maclaurin_cos_expansion2:
+     "[| 0 < x; 0 < n |] ==>
+       \<exists>t. 0 < t & t < x &
+       cos x =
+       (sumr 0 n (%m. (if even m
+                       then (- 1) ^ (m div 2)/(real (fact m))
+                       else 0) *
+                       x ^ m))
+      + ((cos(t + 1/2 * real (n) *pi) / real (fact n)) * x ^ n)"
+apply (cut_tac f = cos and n = n and h = x and diff = "%n x. cos (x + 1/2*real (n) *pi)" in Maclaurin_objl)
+apply safe
+apply simp
+apply (simp (no_asm))
+apply (erule ssubst)
+apply (rule_tac x = t in exI, simp)
+apply (rule sumr_fun_eq)
+apply (auto simp add: odd_Suc_mult_two_ex)
+apply (auto simp add: even_mult_two_ex left_distrib cos_add simp del: fact_Suc realpow_Suc)
+apply (simp add: mult_commute [of _ pi])
+done
+
+lemma Maclaurin_minus_cos_expansion: "[| x < 0; 0 < n |] ==>
+       \<exists>t. x < t & t < 0 &
+       cos x =
+       (sumr 0 n (%m. (if even m
+                       then (- 1) ^ (m div 2)/(real (fact m))
+                       else 0) *
+                       x ^ m))
+      + ((cos(t + 1/2 * real (n) *pi) / real (fact n)) * x ^ n)"
+apply (cut_tac f = cos and n = n and h = x and diff = "%n x. cos (x + 1/2*real (n) *pi)" in Maclaurin_minus_objl)
+apply safe
+apply simp
+apply (simp (no_asm))
+apply (erule ssubst)
+apply (rule_tac x = t in exI, simp)
+apply (rule sumr_fun_eq)
+apply (auto simp add: odd_Suc_mult_two_ex)
+apply (auto simp add: even_mult_two_ex left_distrib cos_add simp del: fact_Suc realpow_Suc)
+apply (simp add: mult_commute [of _ pi])
+done
+
+(* ------------------------------------------------------------------------- *)
+(* Version for ln(1 +/- x). Where is it??                                    *)
+(* ------------------------------------------------------------------------- *)
+
+lemma sin_bound_lemma:
+    "[|x = y; abs u \<le> (v::real) |] ==> abs ((x + u) - y) \<le> v"
+by auto
+
+lemma Maclaurin_sin_bound:
+  "abs(sin x - sumr 0 n (%m. (if even m then 0 else ((- 1) ^ ((m - (Suc 0)) div 2)) / real (fact m)) *
+  x ^ m))  \<le> inverse(real (fact n)) * abs(x) ^ n"
 proof -
-  have "!! x (y::real). x <= 1 \<Longrightarrow> 0 <= y \<Longrightarrow> x * y \<le> 1 * y" 
+  have "!! x (y::real). x \<le> 1 \<Longrightarrow> 0 \<le> y \<Longrightarrow> x * y \<le> 1 * y"
     by (rule_tac mult_right_mono,simp_all)
   note est = this[simplified]
   show ?thesis
-    apply (cut_tac f=sin and n=n and x=x and 
+    apply (cut_tac f=sin and n=n and x=x and
       diff = "%n x. if n mod 4 = 0 then sin(x) else if n mod 4 = 1 then cos(x) else if n mod 4 = 2 then -sin(x) else -cos(x)"
       in Maclaurin_all_le_objl)
-    apply (tactic{* (Step_tac 1) *})
-    apply (simp)
+    apply safe
+    apply simp
     apply (subst mod_Suc_eq_Suc_mod)
-    apply (tactic{* cut_inst_tac [("m1","m")] (CLAIM "0 < (4::nat)" RS mod_less_divisor RS lemma_exhaust_less_4) 1*})
-    apply (tactic{* Step_tac 1 *})
-    apply (simp)+
+    apply (cut_tac m=m in mod_exhaust_less_4, safe, simp+)
     apply (rule DERIV_minus, simp+)
     apply (rule lemma_DERIV_subst, rule DERIV_minus, rule DERIV_cos, simp)
-    apply (tactic{* dtac ssubst 1 THEN assume_tac 2 *})
-    apply (tactic {* rtac (ARITH_PROVE "[|x = y; abs u <= (v::real) |] ==> abs ((x + u) - y) <= v") 1 *})
-    apply (rule sumr_fun_eq)
-    apply (tactic{* Step_tac 1 *})
-    apply (tactic{*rtac (CLAIM "x = y ==> x * z = y * (z::real)") 1*})
+    apply (erule ssubst)
+    apply (rule sin_bound_lemma)
+    apply (rule sumr_fun_eq, safe)
+    apply (rule_tac f = "%u. u * (x^r)" in arg_cong)
     apply (subst even_even_mod_4_iff)
-    apply (tactic{* cut_inst_tac [("m1","r")] (CLAIM "0 < (4::nat)" RS mod_less_divisor RS lemma_exhaust_less_4) 1 *})
-    apply (tactic{* Step_tac 1 *})
-    apply (simp)
+    apply (cut_tac m=r in mod_exhaust_less_4, simp, safe)
     apply (simp_all add:even_num_iff)
     apply (drule lemma_even_mod_4_div_2[simplified])
-    apply(simp add: numeral_2_eq_2 real_divide_def)
-    apply (drule lemma_odd_mod_4_div_2 );
-    apply (simp add: numeral_2_eq_2 real_divide_def)
-    apply (auto intro: real_mult_le_lemma mult_right_mono simp add: est mult_pos_le mult_ac real_divide_def abs_mult abs_inverse power_abs[symmetric])
+    apply(simp add: numeral_2_eq_2 divide_inverse)
+    apply (drule lemma_odd_mod_4_div_2)
+    apply (simp add: numeral_2_eq_2 divide_inverse)
+    apply (auto intro: mult_right_mono [where b=1, simplified] mult_right_mono
+                   simp add: est mult_pos_le mult_ac divide_inverse
+                          power_abs [symmetric])
     done
 qed
 
-end
\ No newline at end of file
+end
--- a/src/HOL/Hyperreal/MacLaurin_lemmas.ML	Tue Jul 27 15:39:59 2004 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,724 +0,0 @@
-(*  Title       : MacLaurin.thy
-    Author      : Jacques D. Fleuriot
-    Copyright   : 2001 University of Edinburgh
-    Description : MacLaurin series
-*)
-
-val DERIV_intros = thms"DERIV_intros";
-
-val lemma_DERIV_subst = thm"lemma_DERIV_subst";
-
-fun ARITH_PROVE str = prove_goal thy str
-                      (fn prems => [cut_facts_tac prems 1,arith_tac 1]);
-
-
-(* FIXME: remove this quick, crude tactic *)
-exception DERIV_name;
-fun get_fun_name (_ $ (Const ("Lim.deriv",_) $ Abs(_,_, Const (f,_) $ _) $ _ $ _)) = f
-|   get_fun_name (_ $ (_ $ (Const ("Lim.deriv",_) $ Abs(_,_, Const (f,_) $ _) $ _ $ _))) = f
-|   get_fun_name _ = raise DERIV_name;
-
-val deriv_rulesI = [DERIV_Id,DERIV_const,DERIV_cos,DERIV_cmult,
-                    DERIV_sin, DERIV_exp, DERIV_inverse,DERIV_pow,
-                    DERIV_add, DERIV_diff, DERIV_mult, DERIV_minus,
-                    DERIV_inverse_fun,DERIV_quotient,DERIV_fun_pow,
-                    DERIV_fun_exp,DERIV_fun_sin,DERIV_fun_cos,
-                    DERIV_Id,DERIV_const,DERIV_cos];
-
-
-fun deriv_tac i = (resolve_tac deriv_rulesI i) ORELSE 
-                   ((rtac (read_instantiate [("f",get_fun_name (getgoal i))] 
-                     DERIV_chain2) i) handle DERIV_name => no_tac);
-
-val DERIV_tac = ALLGOALS(fn i => REPEAT(deriv_tac i));
-
-
-Goal "sumr 0 n (%m. f (m + k)) = sumr 0 (n + k) f - sumr 0 k f";
-by (induct_tac "n" 1);
-by Auto_tac;
-qed "sumr_offset";
-
-Goal "ALL f. sumr 0 n (%m. f (m + k)) = sumr 0 (n + k) f - sumr 0 k f";
-by (induct_tac "n" 1);
-by Auto_tac;
-qed "sumr_offset2";
-
-Goal "sumr 0 (n + k) f = sumr 0 n (%m. f (m + k)) + sumr 0 k f";
-by (simp_tac (simpset() addsimps [sumr_offset]) 1);
-qed "sumr_offset3";
-
-Goal "ALL n f. sumr 0 (n + k) f = sumr 0 n (%m. f (m + k)) + sumr 0 k f";
-by (simp_tac (simpset() addsimps [sumr_offset]) 1);
-qed "sumr_offset4";
-
-Goal "0 < n ==> \
-\     sumr (Suc 0) (Suc n) (%n. (if even(n) then 0 else \
-\            ((- 1) ^ ((n - (Suc 0)) div 2))/(real (fact n))) * a ^ n) = \
-\     sumr 0 (Suc n) (%n. (if even(n) then 0 else \
-\            ((- 1) ^ ((n - (Suc 0)) div 2))/(real (fact n))) * a ^ n)";
-by (res_inst_tac [("n1","1")] (sumr_split_add RS subst) 1);
-by Auto_tac;
-qed "sumr_from_1_from_0";
-
-(*---------------------------------------------------------------------------*)
-(* Maclaurin's theorem with Lagrange form of remainder                       *)
-(*---------------------------------------------------------------------------*)
-
-
-
-(* FIXME: remove this quick, crude tactic *)
-exception DERIV_name;
-fun get_fun_name (_ $ (Const ("Lim.deriv",_) $ Abs(_,_, Const (f,_) $ _) $ _ $ _)) = f
-|   get_fun_name (_ $ (_ $ (Const ("Lim.deriv",_) $ Abs(_,_, Const (f,_) $ _) $ _ $ _))) = f
-|   get_fun_name _ = raise DERIV_name;
-
-val deriv_rulesI = [DERIV_Id,DERIV_const,DERIV_cos,DERIV_cmult,
-                    DERIV_sin, DERIV_exp, DERIV_inverse,DERIV_pow,
-                    DERIV_add, DERIV_diff, DERIV_mult, DERIV_minus,
-                    DERIV_inverse_fun,DERIV_quotient,DERIV_fun_pow,
-                    DERIV_fun_exp,DERIV_fun_sin,DERIV_fun_cos,
-                    DERIV_Id,DERIV_const,DERIV_cos];
-
-
-fun deriv_tac i = (resolve_tac deriv_rulesI i) ORELSE 
-                   ((rtac (read_instantiate [("f",get_fun_name (getgoal i))] 
-                     DERIV_chain2) i) handle DERIV_name => no_tac);
-
-val DERIV_tac = ALLGOALS(fn i => REPEAT(deriv_tac i));
-
-
-(* Annoying: Proof is now even longer due mostly to 
-   change in behaviour of simplifier  since Isabelle99 *)
-Goal " [| 0 < h; 0 < n; diff 0 = f; \
-\      ALL m t. \
-\         m < n & 0 <= t & t <= h --> DERIV (diff m) t :> diff (Suc m) t |] \
-\   ==> EX t. 0 < t & \
-\             t < h & \
-\             f h = \
-\             sumr 0 n (%m. (diff m 0 / real (fact m)) * h ^ m) + \
-\             (diff n t / real (fact n)) * h ^ n";
-by (case_tac "n = 0" 1);
-by (Force_tac 1);
-by (dtac not0_implies_Suc 1);
-by (etac exE 1);
-by (subgoal_tac 
-     "EX B. f h = sumr 0 n (%m. (diff m 0 / real (fact m)) * (h ^ m)) \
-\                  + (B * ((h ^ n) / real (fact n)))" 1);
-
-by (simp_tac (HOL_ss addsimps [real_add_commute, real_divide_def,
-    ARITH_PROVE "(x = z + (y::real)) = (x - y = z)"]) 2);
-by (res_inst_tac 
-  [("x","(f(h) - sumr 0 n (%m. (diff(m)(0) / real (fact m)) * (h ^ m))) \
-\        * real (fact n) / (h ^ n)")] exI 2);
-by (simp_tac (HOL_ss addsimps [real_mult_assoc,real_divide_def]) 2);
- by (rtac (CLAIM "x = (1::real) ==>  a = a * (x::real)") 2);
-by (asm_simp_tac (HOL_ss addsimps 
-    [CLAIM "(a::real) * (b * (c * d)) = (d * a) * (b * c)"]
-     delsimps [realpow_Suc]) 2);
-by (stac left_inverse 2);
-by (stac left_inverse 3);
-by (rtac (real_not_refl2 RS not_sym) 2);
-by (etac zero_less_power 2);
-by (rtac real_of_nat_fact_not_zero 2);
-by (Simp_tac 2);
-by (etac exE 1);
-by (cut_inst_tac [("b","%t. f t - \
-\      (sumr 0 n (%m. (diff m 0 / real (fact m)) * (t ^ m)) + \
-\                       (B * ((t ^ n) / real (fact n))))")] 
-    (CLAIM "EX g. g = b") 1);
-by (etac exE 1);
-by (subgoal_tac "g 0 = 0 & g h =0" 1);
-by (asm_simp_tac (simpset() addsimps 
-    [ARITH_PROVE "(x - y = z) = (x = z + (y::real))"]
-    delsimps [sumr_Suc]) 2);
-by (cut_inst_tac [("n","m"),("k","1")] sumr_offset2 2);
-by (asm_full_simp_tac (simpset() addsimps 
-    [ARITH_PROVE "(x = y - z) = (y = x + (z::real))"]
-    delsimps [sumr_Suc]) 2);
-by (cut_inst_tac [("b","%m t. diff m t - \
-\      (sumr 0 (n - m) (%p. (diff (m + p) 0 / real (fact p)) * (t ^ p)) \
-\       + (B * ((t ^ (n - m)) / real (fact(n - m)))))")] 
-    (CLAIM "EX difg. difg = b") 1);
-by (etac exE 1);
-by (subgoal_tac "difg 0 = g" 1);
-by (asm_simp_tac (simpset() delsimps [realpow_Suc,fact_Suc]) 2);
-by (subgoal_tac "ALL m t. m < n & 0 <= t & t <= h --> \
-\                   DERIV (difg m) t :> difg (Suc m) t" 1);
-by (Clarify_tac 2);
-by (rtac DERIV_diff 2);
-by (Asm_simp_tac 2);
-by DERIV_tac;
-by DERIV_tac;
-by (rtac lemma_DERIV_subst 3);
-by (rtac DERIV_quotient 3);
-by (rtac DERIV_const 4);
-by (rtac DERIV_pow 3);
-by (asm_simp_tac (simpset() addsimps [inverse_mult_distrib,
-    CLAIM_SIMP "(a::real) * b * c * (d * e) = a * b * (c * d) * e" 
-    mult_ac,fact_diff_Suc]) 4);
-by (Asm_simp_tac 3);
-by (forw_inst_tac [("m","ma")] less_add_one 2);
-by (Clarify_tac 2);
-by (asm_simp_tac (simpset() addsimps 
-    [CLAIM "Suc m = ma + d + 1 ==> m - ma = d"]
-    delsimps [sumr_Suc]) 2);
-by (asm_simp_tac (simpset() addsimps [(simplify (simpset() delsimps [sumr_Suc])
-          (read_instantiate [("k","1")] sumr_offset4))] 
-    delsimps [sumr_Suc,fact_Suc,realpow_Suc]) 2);
-by (rtac lemma_DERIV_subst 2);
-by (rtac DERIV_add 2);
-by (rtac DERIV_const 3);
-by (rtac DERIV_sumr 2);
-by (Clarify_tac 2);
-by (Simp_tac 3);
-by (simp_tac (simpset() addsimps [real_divide_def,real_mult_assoc] 
-    delsimps [fact_Suc,realpow_Suc]) 2);
-by (rtac DERIV_cmult 2);
-by (rtac lemma_DERIV_subst 2);
-by (best_tac (claset() addIs [DERIV_chain2] addSIs DERIV_intros) 2);
-by (stac fact_Suc 2);
-by (stac real_of_nat_mult 2);
-by (simp_tac (simpset() addsimps [inverse_mult_distrib] @
-    mult_ac) 2);
-by (subgoal_tac "ALL ma. ma < n --> \
-\        (EX t. 0 < t & t < h & difg (Suc ma) t = 0)" 1);
-by (rotate_tac 11 1);
-by (dres_inst_tac [("x","m")] spec 1);
-by (etac impE 1);
-by (Asm_simp_tac 1);
-by (etac exE 1);
-by (res_inst_tac [("x","t")] exI 1);
-by (asm_full_simp_tac (simpset() addsimps 
-     [ARITH_PROVE "(x - y = 0) = (y = (x::real))"] 
-      delsimps [realpow_Suc,fact_Suc]) 1);
-by (subgoal_tac "ALL m. m < n --> difg m 0 = 0" 1);
-by (Clarify_tac 2);
-by (Asm_simp_tac 2);
-by (forw_inst_tac [("m","ma")] less_add_one 2);
-by (Clarify_tac 2);
-by (asm_simp_tac (simpset() delsimps [sumr_Suc]) 2);
-by (asm_simp_tac (simpset() addsimps [(simplify (simpset() delsimps [sumr_Suc]) 
-          (read_instantiate [("k","1")] sumr_offset4))] 
-    delsimps [sumr_Suc,fact_Suc,realpow_Suc]) 2);
-by (subgoal_tac "ALL m. m < n --> (EX t. 0 < t & t < h & \
-\                DERIV (difg m) t :> 0)" 1);
-by (rtac allI 1 THEN rtac impI 1);
-by (rotate_tac 12 1);
-by (dres_inst_tac [("x","ma")] spec 1);
-by (etac impE 1 THEN assume_tac 1);
-by (etac exE 1);
-by (res_inst_tac [("x","t")] exI 1);
-(* do some tidying up *)
-by (ALLGOALS(thin_tac "difg = \
-\          (%m t. diff m t - \
-\                 (sumr 0 (n - m) \
-\                   (%p. diff (m + p) 0 / real (fact p) * t ^ p) + \
-\                  B * (t ^ (n - m) / real (fact (n - m)))))"));
-by (ALLGOALS(thin_tac "g = \
-\          (%t. f t - \
-\               (sumr 0 n (%m. diff m 0 / real  (fact m) * t ^ m) + \
-\                B * (t ^ n / real (fact n))))"));
-by (ALLGOALS(thin_tac "f h = \
-\          sumr 0 n (%m. diff m 0 / real (fact m) * h ^ m) + \
-\          B * (h ^ n / real (fact n))"));
-(* back to business *)
-by (Asm_simp_tac 1);
-by (rtac DERIV_unique 1);
-by (Blast_tac 2);
-by (Force_tac 1);
-by (rtac allI 1 THEN induct_tac "ma" 1);
-by (rtac impI 1 THEN rtac Rolle 1);
-by (assume_tac 1);
-by (Asm_full_simp_tac 1);
-by (Asm_full_simp_tac 1);
-by (subgoal_tac "ALL t. 0 <= t & t <= h --> g differentiable t" 1);
-by (asm_full_simp_tac (simpset() addsimps [differentiable_def]) 1);
-by (blast_tac (claset() addDs [DERIV_isCont]) 1);
-by (asm_full_simp_tac (simpset() addsimps [differentiable_def]) 1);
-by (Clarify_tac 1);
-by (res_inst_tac [("x","difg (Suc 0) t")] exI 1);
-by (Force_tac 1);
-by (asm_full_simp_tac (simpset() addsimps [differentiable_def]) 1);
-by (Clarify_tac 1);
-by (res_inst_tac [("x","difg (Suc 0) x")] exI 1);
-by (Force_tac 1);
-by (Step_tac 1);
-by (Force_tac 1);
-by (subgoal_tac "EX ta. 0 < ta & ta < t & \
-\                DERIV difg (Suc n) ta :> 0" 1);
-by (rtac Rolle 2 THEN assume_tac 2);
-by (Asm_full_simp_tac 2);
-by (rotate_tac 2 2);
-by (dres_inst_tac [("x","n")] spec 2);
-by (ftac (ARITH_PROVE "n < m  ==> n < Suc m") 2);
-by (rtac DERIV_unique 2);
-by (assume_tac 3);
-by (Force_tac 2);
-by (subgoal_tac 
-    "ALL ta. 0 <= ta & ta <= t --> (difg (Suc n)) differentiable ta" 2);
-by (asm_full_simp_tac (simpset() addsimps [differentiable_def]) 2);
-by (blast_tac (claset() addSDs [DERIV_isCont]) 2);
-by (asm_full_simp_tac (simpset() addsimps [differentiable_def]) 2);
-by (Clarify_tac 2);
-by (res_inst_tac [("x","difg (Suc (Suc n)) ta")] exI 2);
-by (Force_tac 2);
-by (asm_full_simp_tac (simpset() addsimps [differentiable_def]) 2);
-by (Clarify_tac 2);
-by (res_inst_tac [("x","difg (Suc (Suc n)) x")] exI 2);
-by (Force_tac 2);
-by (Step_tac 1);
-by (res_inst_tac [("x","ta")] exI 1);
-by (Force_tac 1);
-qed "Maclaurin";
-
-Goal "0 < h & 0 < n & diff 0 = f & \
-\      (ALL m t. \
-\         m < n & 0 <= t & t <= h --> DERIV (diff m) t :> diff (Suc m) t) \
-\   --> (EX t. 0 < t & \
-\             t < h & \
-\             f h = \
-\             sumr 0 n (%m. diff m 0 / real (fact m) * h ^ m) + \
-\             diff n t / real (fact n) * h ^ n)";
-by (blast_tac (claset() addIs [Maclaurin]) 1);
-qed "Maclaurin_objl";
-
-Goal " [| 0 < h; diff 0 = f; \
-\      ALL m t. \
-\         m < n & 0 <= t & t <= h --> DERIV (diff m) t :> diff (Suc m) t |] \
-\   ==> EX t. 0 < t & \
-\             t <= h & \
-\             f h = \
-\             sumr 0 n (%m. diff m 0 / real (fact m) * h ^ m) + \
-\             diff n t / real (fact n) * h ^ n";
-by (case_tac "n" 1);
-by Auto_tac;
-by (dtac Maclaurin 1 THEN Auto_tac);
-qed "Maclaurin2";
-
-Goal "0 < h & diff 0 = f & \
-\      (ALL m t. \
-\         m < n & 0 <= t & t <= h --> DERIV (diff m) t :> diff (Suc m) t) \
-\   --> (EX t. 0 < t & \
-\             t <= h & \
-\             f h = \
-\             sumr 0 n (%m. diff m 0 / real (fact m) * h ^ m) + \
-\             diff n t / real (fact n) * h ^ n)";
-by (blast_tac (claset() addIs [Maclaurin2]) 1);
-qed "Maclaurin2_objl";
-
-Goal " [| h < 0; 0 < n; diff 0 = f; \
-\      ALL m t. \
-\         m < n & h <= t & t <= 0 --> DERIV (diff m) t :> diff (Suc m) t |] \
-\   ==> EX t. h < t & \
-\             t < 0 & \
-\             f h = \
-\             sumr 0 n (%m. diff m 0 / real (fact m) * h ^ m) + \
-\             diff n t / real (fact n) * h ^ n";
-by (cut_inst_tac [("f","%x. f (-x)"),
-                 ("diff","%n x. ((- 1) ^ n) * diff n (-x)"),
-                 ("h","-h"),("n","n")] Maclaurin_objl 1);
-by (Asm_full_simp_tac 1);
-by (etac impE 1 THEN Step_tac 1);
-by (stac minus_mult_right 1);
-by (rtac DERIV_cmult 1);
-by (rtac lemma_DERIV_subst 1);
-by (rtac (read_instantiate [("g","uminus")] DERIV_chain2) 1);
-by (rtac DERIV_minus 2 THEN rtac DERIV_Id 2);
-by (Force_tac 2);
-by (Force_tac 1);
-by (res_inst_tac [("x","-t")] exI 1);
-by Auto_tac;
-by (rtac (CLAIM "[| x = x'; y = y' |] ==> x + y = x' + (y'::real)") 1);
-by (rtac sumr_fun_eq 1);
-by (Asm_full_simp_tac 1);
-by (auto_tac (claset(),simpset() addsimps [real_divide_def,
-    CLAIM "((a * b) * c) * d = (b * c) * (a * (d::real))",
-    power_mult_distrib RS sym]));
-qed "Maclaurin_minus";
-
-Goal "(h < 0 & 0 < n & diff 0 = f & \
-\      (ALL m t. \
-\         m < n & h <= t & t <= 0 --> DERIV (diff m) t :> diff (Suc m) t))\
-\   --> (EX t. h < t & \
-\             t < 0 & \
-\             f h = \
-\             sumr 0 n (%m. diff m 0 / real (fact m) * h ^ m) + \
-\             diff n t / real (fact n) * h ^ n)";
-by (blast_tac (claset() addIs [Maclaurin_minus]) 1);
-qed "Maclaurin_minus_objl";
-
-(* ------------------------------------------------------------------------- *)
-(* More convenient "bidirectional" version.                                  *)
-(* ------------------------------------------------------------------------- *)
-
-(* not good for PVS sin_approx, cos_approx *)
-Goal " [| diff 0 = f; \
-\      ALL m t. \
-\         m < n & abs t <= abs x --> DERIV (diff m) t :> diff (Suc m) t |] \
-\   ==> EX t. abs t <= abs x & \
-\             f x = \
-\             sumr 0 n (%m. diff m 0 / real (fact m) * x ^ m) + \
-\             diff n t / real (fact n) * x ^ n";
-by (case_tac "n = 0" 1);
-by (Force_tac 1);
-by (case_tac "x = 0" 1);
-by (res_inst_tac [("x","0")] exI 1);
-by (Asm_full_simp_tac 1);
-by (res_inst_tac [("P","0 < n")] impE 1);
-by (assume_tac 2 THEN assume_tac 2);
-by (induct_tac "n" 1);
-by (Simp_tac 1);
-by Auto_tac;
-by (cut_inst_tac [("x","x"),("y","0")] linorder_less_linear 1);
-by Auto_tac;
-by (cut_inst_tac [("f","diff 0"),
-                 ("diff","diff"),
-                 ("h","x"),("n","n")] Maclaurin_objl 2);
-by (Step_tac 2);
-by (blast_tac (claset() addDs 
-    [ARITH_PROVE "[|(0::real) <= t;t <= x |] ==> abs t <= abs x"]) 2);
-by (res_inst_tac [("x","t")] exI 2);
-by (force_tac (claset() addIs 
-    [ARITH_PROVE "[| 0 < t; (t::real) < x|] ==> abs t <= abs x"],simpset()) 2);
-by (cut_inst_tac [("f","diff 0"),
-                 ("diff","diff"),
-                 ("h","x"),("n","n")] Maclaurin_minus_objl 1);
-by (Step_tac 1);
-by (blast_tac (claset() addDs 
-    [ARITH_PROVE "[|x <= t;t <= (0::real) |] ==> abs t <= abs x"]) 1);
-by (res_inst_tac [("x","t")] exI 1);
-by (force_tac (claset() addIs 
-    [ARITH_PROVE "[| x < t; (t::real) < 0|] ==> abs t <= abs x"],simpset()) 1);
-qed "Maclaurin_bi_le";
-
-Goal "[| diff 0 = f; \
-\        ALL m x. DERIV (diff m) x :> diff(Suc m) x; \ 
-\       x ~= 0; 0 < n \
-\     |] ==> EX t. 0 < abs t & abs t < abs x & \
-\              f x = sumr 0 n (%m. (diff m 0 / real (fact m)) * x ^ m) + \
-\                    (diff n t / real (fact n)) * x ^ n";
-by (res_inst_tac [("x","x"),("y","0")] linorder_cases 1);
-by (Blast_tac 2);
-by (dtac Maclaurin_minus 1);
-by (dtac Maclaurin 5);
-by (TRYALL(assume_tac));
-by (Blast_tac 1);
-by (Blast_tac 2);
-by (Step_tac 1);
-by (ALLGOALS(res_inst_tac [("x","t")] exI));
-by (Step_tac 1);
-by (ALLGOALS(arith_tac));
-qed "Maclaurin_all_lt";
-
-Goal "diff 0 = f & \
-\     (ALL m x. DERIV (diff m) x :> diff(Suc m) x) & \
-\     x ~= 0 & 0 < n \
-\     --> (EX t. 0 < abs t & abs t < abs x & \
-\              f x = sumr 0 n (%m. (diff m 0 / real (fact m)) * x ^ m) + \
-\                    (diff n t / real (fact n)) * x ^ n)";
-by (blast_tac (claset() addIs [Maclaurin_all_lt]) 1);
-qed "Maclaurin_all_lt_objl";
-
-Goal "x = (0::real)  \
-\     ==> 0 < n --> \
-\         sumr 0 n (%m. (diff m (0::real) / real (fact m)) * x ^ m) = \
-\         diff 0 0";
-by (Asm_simp_tac 1);
-by (induct_tac "n" 1);
-by Auto_tac; 
-qed_spec_mp "Maclaurin_zero";
-
-Goal "[| diff 0 = f; \
-\       ALL m x. DERIV (diff m) x :> diff (Suc m) x \
-\     |] ==> EX t. abs t <= abs x & \
-\             f x = sumr 0 n (%m. (diff m 0 / real (fact m)) * x ^ m) + \
-\                   (diff n t / real (fact n)) * x ^ n";
-by (cut_inst_tac [("n","n"),("m","0")] 
-       (ARITH_PROVE "n <= m | m < (n::nat)") 1);
-by (etac disjE 1);
-by (Force_tac 1);
-by (case_tac "x = 0" 1);
-by (forw_inst_tac [("diff","diff"),("n","n")] Maclaurin_zero 1);
-by (assume_tac 1);
-by (dtac (gr_implies_not0 RS  not0_implies_Suc) 1);
-by (res_inst_tac [("x","0")] exI 1);
-by (Force_tac 1);
-by (forw_inst_tac [("diff","diff"),("n","n")] Maclaurin_all_lt 1);
-by (TRYALL(assume_tac));
-by (Step_tac 1);
-by (res_inst_tac [("x","t")] exI 1);
-by Auto_tac;
-qed "Maclaurin_all_le";
-
-Goal "diff 0 = f & \
-\     (ALL m x. DERIV (diff m) x :> diff (Suc m) x)  \
-\     --> (EX t. abs t <= abs x & \
-\             f x = sumr 0 n (%m. (diff m 0 / real (fact m)) * x ^ m) + \
-\                   (diff n t / real (fact n)) * x ^ n)";
-by (blast_tac (claset() addIs [Maclaurin_all_le]) 1);
-qed "Maclaurin_all_le_objl";
-
-(* ------------------------------------------------------------------------- *)
-(* Version for exp.                                                          *)
-(* ------------------------------------------------------------------------- *)
-
-Goal "[| x ~= 0; 0 < n |] \
-\     ==> (EX t. 0 < abs t & \
-\               abs t < abs x & \
-\               exp x = sumr 0 n (%m. (x ^ m) / real (fact m)) + \
-\                       (exp t / real (fact n)) * x ^ n)";
-by (cut_inst_tac [("diff","%n. exp"),("f","exp"),("x","x"),("n","n")] 
-    Maclaurin_all_lt_objl 1);
-by Auto_tac;
-qed "Maclaurin_exp_lt";
-
-Goal "EX t. abs t <= abs x & \
-\           exp x = sumr 0 n (%m. (x ^ m) / real (fact m)) + \
-\                      (exp t / real (fact n)) * x ^ n";
-by (cut_inst_tac [("diff","%n. exp"),("f","exp"),("x","x"),("n","n")] 
-    Maclaurin_all_le_objl 1);
-by Auto_tac;
-qed "Maclaurin_exp_le";
-
-(* ------------------------------------------------------------------------- *)
-(* Version for sin function                                                  *)
-(* ------------------------------------------------------------------------- *)
-
-Goal "[| a < b; ALL x. a <= x & x <= b --> DERIV f x :> f'(x) |] \
-\     ==> EX z. a < z & z < b & (f b - f a = (b - a) * f'(z))";
-by (dtac MVT 1);
-by (blast_tac (claset() addIs [DERIV_isCont]) 1);
-by (force_tac (claset() addDs [order_less_imp_le],
-    simpset() addsimps [differentiable_def]) 1);
-by (blast_tac (claset() addDs [DERIV_unique,order_less_imp_le]) 1);
-qed "MVT2";
-
-Goal "d < (4::nat) ==> d = 0 | d = 1 | d = 2 | d = 3";
-by (case_tac "d" 1 THEN Auto_tac);
-qed "lemma_exhaust_less_4";
-
-bind_thm ("real_mult_le_lemma",
-          simplify (simpset()) (inst "b" "1" mult_right_mono));
-
-
-Goal "0 < n --> Suc (Suc (2 * n - 2)) = 2*n";
-by (induct_tac "n" 1);
-by Auto_tac;
-qed_spec_mp "Suc_Suc_mult_two_diff_two";
-Addsimps [Suc_Suc_mult_two_diff_two];
-
-Goal "0 < n --> Suc (Suc (4*n - 2)) = 4*n";
-by (induct_tac "n" 1);
-by Auto_tac;
-qed_spec_mp "lemma_Suc_Suc_4n_diff_2";
-Addsimps [lemma_Suc_Suc_4n_diff_2];
-
-Goal "0 < n --> Suc (2 * n - 1) = 2*n";
-by (induct_tac "n" 1);
-by Auto_tac;
-qed_spec_mp "Suc_mult_two_diff_one";
-Addsimps [Suc_mult_two_diff_one];
-
-Goal "EX t. sin x = \
-\      (sumr 0 n (%m. (if even m then 0 \
-\                      else ((- 1) ^ ((m - (Suc 0)) div 2)) / real (fact m)) * \
-\                      x ^ m)) \
-\     + ((sin(t + 1/2 * real (n) *pi) / real (fact n)) * x ^ n)";
-by (cut_inst_tac [("f","sin"),("n","n"),("x","x"),
-       ("diff","%n x. sin(x + 1/2*real (n)*pi)")] 
-       Maclaurin_all_lt_objl 1);
-by (Safe_tac);
-by (Simp_tac 1);
-by (Simp_tac 1);
-by (case_tac "n" 1);
-by (Clarify_tac 1); 
-by (Asm_full_simp_tac 1);
-by (dres_inst_tac [("x","0")] spec 1 THEN Asm_full_simp_tac 1);
-by (Asm_full_simp_tac 1);
-by (rtac ccontr 1);
-by (Asm_full_simp_tac 1);
-by (dres_inst_tac [("x","x")] spec 1 THEN Asm_full_simp_tac 1);
-by (dtac ssubst 1 THEN assume_tac 2);
-by (res_inst_tac [("x","t")] exI 1);
-by (rtac (CLAIM "[|x = y; x' = y'|] ==> x + x' = y + (y'::real)") 1);
-by (rtac sumr_fun_eq 1);
-by (auto_tac (claset(),simpset() addsimps [odd_Suc_mult_two_ex]));
-by (auto_tac (claset(),simpset() addsimps [even_mult_two_ex] delsimps [fact_Suc,realpow_Suc]));
-(*Could sin_zero_iff help?*)
-qed "Maclaurin_sin_expansion";
-
-Goal "EX t. abs t <= abs x &  \
-\      sin x = \
-\      (sumr 0 n (%m. (if even m then 0 \
-\                      else ((- 1) ^ ((m - (Suc 0)) div 2)) / real (fact m)) * \
-\                      x ^ m)) \
-\     + ((sin(t + 1/2 * real (n) *pi) / real (fact n)) * x ^ n)";
-
-by (cut_inst_tac [("f","sin"),("n","n"),("x","x"),
-       ("diff","%n x. sin(x + 1/2*real (n)*pi)")] 
-       Maclaurin_all_lt_objl 1);
-by (Step_tac 1);
-by (Simp_tac 1);
-by (Simp_tac 1);
-by (case_tac "n" 1);
-by (Clarify_tac 1); 
-by (Asm_full_simp_tac 1);
-by (Asm_full_simp_tac 1);
-by (rtac ccontr 1);
-by (Asm_full_simp_tac 1);
-by (dres_inst_tac [("x","x")] spec 1 THEN Asm_full_simp_tac 1);
-by (dtac ssubst 1 THEN assume_tac 2);
-by (res_inst_tac [("x","t")] exI 1);
-by (rtac conjI 1);
-by (arith_tac 1);
-by (rtac (CLAIM "[|x = y; x' = y'|] ==> x + x' = y + (y'::real)") 1);
-by (rtac sumr_fun_eq 1);
-by (auto_tac (claset(),simpset() addsimps [odd_Suc_mult_two_ex]));
-by (auto_tac (claset(),simpset() addsimps [even_mult_two_ex] delsimps [fact_Suc,realpow_Suc]));
-qed "Maclaurin_sin_expansion2";
-
-Goal "[| 0 < n; 0 < x |] ==> \
-\      EX t. 0 < t & t < x & \
-\      sin x = \
-\      (sumr 0 n (%m. (if even m then 0 \
-\                      else ((- 1) ^ ((m - (Suc 0)) div 2)) / real (fact m)) * \
-\                      x ^ m)) \
-\     + ((sin(t + 1/2 * real(n) *pi) / real (fact n)) * x ^ n)";
-by (cut_inst_tac [("f","sin"),("n","n"),("h","x"),
-       ("diff","%n x. sin(x + 1/2*real (n)*pi)")] 
-       Maclaurin_objl 1);
-by (Step_tac 1);
-by (Asm_full_simp_tac 1);
-by (Simp_tac 1);
-by (dtac ssubst 1 THEN assume_tac 2);
-by (res_inst_tac [("x","t")] exI 1);
-by (rtac conjI 1 THEN rtac conjI 2);
-by (assume_tac 1 THEN assume_tac 1);
-by (rtac (CLAIM "[|x = y; x' = y'|] ==> x + x' = y + (y'::real)") 1);
-by (rtac sumr_fun_eq 1);
-by (auto_tac (claset(),simpset() addsimps [odd_Suc_mult_two_ex]));
-by (auto_tac (claset(),simpset() addsimps [even_mult_two_ex] delsimps [fact_Suc,realpow_Suc]));
-qed "Maclaurin_sin_expansion3";
-
-Goal "0 < x ==> \
-\      EX t. 0 < t & t <= x & \
-\      sin x = \
-\      (sumr 0 n (%m. (if even m then 0 \
-\                      else ((- 1) ^ ((m - (Suc 0)) div 2)) / real (fact m)) * \
-\                      x ^ m)) \
-\     + ((sin(t + 1/2 * real (n) *pi) / real (fact n)) * x ^ n)";
-by (cut_inst_tac [("f","sin"),("n","n"),("h","x"),
-       ("diff","%n x. sin(x + 1/2*real (n)*pi)")] 
-       Maclaurin2_objl 1);
-by (Step_tac 1);
-by (Asm_full_simp_tac 1);
-by (Simp_tac 1);
-by (dtac ssubst 1 THEN assume_tac 2);
-by (res_inst_tac [("x","t")] exI 1);
-by (rtac conjI 1 THEN rtac conjI 2);
-by (assume_tac 1 THEN assume_tac 1);
-by (rtac (CLAIM "[|x = y; x' = y'|] ==> x + x' = y + (y'::real)") 1);
-by (rtac sumr_fun_eq 1);
-by (auto_tac (claset(),simpset() addsimps [odd_Suc_mult_two_ex]));
-by (auto_tac (claset(),simpset() addsimps [even_mult_two_ex] delsimps [fact_Suc,realpow_Suc]));
-qed "Maclaurin_sin_expansion4";
-
-(*-----------------------------------------------------------------------------*)
-(* Maclaurin expansion for cos                                                 *)
-(*-----------------------------------------------------------------------------*)
-
-Goal "sumr 0 (Suc n) \
-\        (%m. (if even m \
-\              then (- 1) ^ (m div 2)/(real  (fact m)) \
-\              else 0) * \
-\             0 ^ m) = 1";
-by (induct_tac "n" 1);
-by Auto_tac;
-qed "sumr_cos_zero_one";
-Addsimps [sumr_cos_zero_one];
-
-Goal "EX t. abs t <= abs x & \
-\      cos x = \
-\      (sumr 0 n (%m. (if even m \
-\                      then (- 1) ^ (m div 2)/(real (fact m)) \
-\                      else 0) * \
-\                      x ^ m)) \
-\     + ((cos(t + 1/2 * real (n) *pi) / real (fact n)) * x ^ n)";
-by (cut_inst_tac [("f","cos"),("n","n"),("x","x"),
-       ("diff","%n x. cos(x + 1/2*real (n)*pi)")] 
-       Maclaurin_all_lt_objl 1);
-by (Step_tac 1);
-by (Simp_tac 1);
-by (Simp_tac 1);
-by (case_tac "n" 1);
-by (Asm_full_simp_tac 1);
-by (asm_full_simp_tac (simpset() delsimps [sumr_Suc]) 1);
-by (rtac ccontr 1);
-by (Asm_full_simp_tac 1);
-by (dres_inst_tac [("x","x")] spec 1 THEN Asm_full_simp_tac 1);
-by (dtac ssubst 1 THEN assume_tac 2);
-by (res_inst_tac [("x","t")] exI 1);
-by (rtac conjI 1);
-by (arith_tac 1);
-by (rtac (CLAIM "[|x = y; x' = y'|] ==> x + x' = y + (y'::real)") 1);
-by (rtac sumr_fun_eq 1);
-by (auto_tac (claset(),simpset() addsimps [odd_Suc_mult_two_ex]));
-by (auto_tac (claset(),simpset() addsimps [even_mult_two_ex,left_distrib,cos_add]  delsimps 
-    [fact_Suc,realpow_Suc]));
-by (auto_tac (claset(),simpset() addsimps [real_mult_commute]));
-qed "Maclaurin_cos_expansion";
-
-Goal "[| 0 < x; 0 < n |] ==> \
-\      EX t. 0 < t & t < x & \
-\      cos x = \
-\      (sumr 0 n (%m. (if even m \
-\                      then (- 1) ^ (m div 2)/(real (fact m)) \
-\                      else 0) * \
-\                      x ^ m)) \
-\     + ((cos(t + 1/2 * real (n) *pi) / real (fact n)) * x ^ n)";
-by (cut_inst_tac [("f","cos"),("n","n"),("h","x"),
-       ("diff","%n x. cos(x + 1/2*real (n)*pi)")] 
-       Maclaurin_objl 1);
-by (Step_tac 1);
-by (Asm_full_simp_tac 1);
-by (Simp_tac 1);
-by (dtac ssubst 1 THEN assume_tac 2);
-by (res_inst_tac [("x","t")] exI 1);
-by (rtac conjI 1 THEN rtac conjI 2);
-by (assume_tac 1 THEN assume_tac 1);
-by (rtac (CLAIM "[|x = y; x' = y'|] ==> x + x' = y + (y'::real)") 1);
-by (rtac sumr_fun_eq 1);
-by (auto_tac (claset(),simpset() addsimps [odd_Suc_mult_two_ex]));
-by (auto_tac (claset(),simpset() addsimps [even_mult_two_ex,left_distrib,cos_add]  delsimps [fact_Suc,realpow_Suc]));
-by (auto_tac (claset(),simpset() addsimps [real_mult_commute]));
-qed "Maclaurin_cos_expansion2";
-
-Goal "[| x < 0; 0 < n |] ==> \
-\      EX t. x < t & t < 0 & \
-\      cos x = \
-\      (sumr 0 n (%m. (if even m \
-\                      then (- 1) ^ (m div 2)/(real (fact m)) \
-\                      else 0) * \
-\                      x ^ m)) \
-\     + ((cos(t + 1/2 * real (n) *pi) / real (fact n)) * x ^ n)";
-by (cut_inst_tac [("f","cos"),("n","n"),("h","x"),
-       ("diff","%n x. cos(x + 1/2*real (n)*pi)")] 
-       Maclaurin_minus_objl 1);
-by (Step_tac 1);
-by (Asm_full_simp_tac 1);
-by (Simp_tac 1);
-by (dtac ssubst 1 THEN assume_tac 2);
-by (res_inst_tac [("x","t")] exI 1);
-by (rtac conjI 1 THEN rtac conjI 2);
-by (assume_tac 1 THEN assume_tac 1);
-by (rtac (CLAIM "[|x = y; x' = y'|] ==> x + x' = y + (y'::real)") 1);
-by (rtac sumr_fun_eq 1);
-by (auto_tac (claset(),simpset() addsimps [odd_Suc_mult_two_ex]));
-by (auto_tac (claset(),simpset() addsimps [even_mult_two_ex,left_distrib,cos_add]  delsimps [fact_Suc,realpow_Suc]));
-by (auto_tac (claset(),simpset() addsimps [real_mult_commute]));
-qed "Maclaurin_minus_cos_expansion";
-
-(* ------------------------------------------------------------------------- *)
-(* Version for ln(1 +/- x). Where is it??                                    *)
-(* ------------------------------------------------------------------------- *)
-
--- a/src/HOL/Hyperreal/Transcendental.thy	Tue Jul 27 15:39:59 2004 +0200
+++ b/src/HOL/Hyperreal/Transcendental.thy	Wed Jul 28 10:49:29 2004 +0200
@@ -665,7 +665,7 @@
 apply (drule_tac x="(\<lambda>n. c n * (xa + x) ^ n)" in sums_diff, assumption) 
 apply (drule_tac x = " (%n. c n * (xa + x) ^ n - c n * x ^ n) " and c = "inverse xa" in sums_mult)
 apply (rule sums_unique [symmetric])
-apply (simp add: diff_def real_divide_def add_ac mult_ac)
+apply (simp add: diff_def divide_inverse add_ac mult_ac)
 apply (rule LIM_zero_cancel)
 apply (rule_tac g = "%h. suminf (%n. c (n) * ((( ((x + h) ^ n) - (x ^ n)) * inverse h) - (real n * (x ^ (n - Suc 0))))) " in LIM_trans)
  prefer 2 apply (blast intro: termdiffs_aux) 
@@ -1377,7 +1377,7 @@
 apply (subst real_of_nat_mult)
 apply (subst real_of_nat_mult)
 apply (subst real_of_nat_mult)
-apply (simp (no_asm) add: real_divide_def inverse_mult_distrib del: fact_Suc)
+apply (simp (no_asm) add: divide_inverse inverse_mult_distrib del: fact_Suc)
 apply (auto simp add: mult_assoc [symmetric] simp del: fact_Suc)
 apply (rule_tac c="real (Suc (Suc (4*m)))" in mult_less_imp_less_right) 
 apply (auto simp add: mult_assoc simp del: fact_Suc)
@@ -1430,7 +1430,7 @@
 apply (simp (no_asm) add: mult_assoc del: sumr_Suc)
 apply (rule sumr_pos_lt_pair)
 apply (erule sums_summable, safe)
-apply (simp (no_asm) add: real_divide_def mult_assoc [symmetric] del: fact_Suc)
+apply (simp (no_asm) add: divide_inverse mult_assoc [symmetric] del: fact_Suc)
 apply (rule real_mult_inverse_cancel2)
 apply (rule real_of_nat_fact_gt_zero)+
 apply (simp (no_asm) add: mult_assoc [symmetric] del: fact_Suc)
@@ -1788,7 +1788,7 @@
      "cos x \<noteq> 0 ==> DERIV (%x. sin(x)/cos(x)) x :> inverse((cos x)\<twosuperior>)"
 apply (rule lemma_DERIV_subst)
 apply (best intro!: DERIV_intros intro: DERIV_chain2) 
-apply (auto simp add: real_divide_def numeral_2_eq_2)
+apply (auto simp add: divide_inverse numeral_2_eq_2)
 done
 
 lemma DERIV_tan [simp]: "cos x \<noteq> 0 ==> DERIV tan x :> inverse((cos x)\<twosuperior>)"
@@ -1816,7 +1816,7 @@
 apply (drule_tac x = " (pi/2) - e" in spec)
 apply (auto simp add: abs_eqI2 tan_def)
 apply (rule inverse_less_iff_less [THEN iffD1])
-apply (auto simp add: real_divide_def)
+apply (auto simp add: divide_inverse)
 apply (rule real_mult_order)
 apply (subgoal_tac [3] "0 < sin e")
 apply (subgoal_tac [3] "0 < cos e")
@@ -1999,7 +1999,7 @@
 
 lemma lemma_sin_cos_eq2 [simp]: "sin (xa + real (Suc m) * pi / 2) =  
       cos (xa + real (m) * pi / 2)"
-apply (simp only: cos_add sin_add real_divide_def real_of_nat_Suc left_distrib right_distrib, auto)
+apply (simp only: cos_add sin_add divide_inverse real_of_nat_Suc left_distrib right_distrib, auto)
 done
 
 lemma DERIV_sin_add [simp]: "DERIV (%x. sin (x + k)) xa :> cos (xa + k)"
@@ -2015,7 +2015,7 @@
 
 lemma sin_cos_npi2 [simp]: "sin (real (Suc (2 * n)) * pi / 2) = (-1) ^ n"
 apply (cut_tac m = n in sin_cos_npi)
-apply (simp only: real_of_nat_Suc left_distrib real_divide_def, auto)
+apply (simp only: real_of_nat_Suc left_distrib divide_inverse, auto)
 done
 
 lemma cos_2npi [simp]: "cos (2 * real (n::nat) * pi) = 1"
@@ -2043,11 +2043,11 @@
 
 (*NEEDED??*)
 lemma [simp]: "cos (x + real(Suc m) * pi / 2) = -sin (x + real m * pi / 2)"
-apply (simp only: cos_add sin_add real_divide_def real_of_nat_Suc left_distrib right_distrib, auto)
+apply (simp only: cos_add sin_add divide_inverse real_of_nat_Suc left_distrib right_distrib, auto)
 done
 
 lemma cos_pi_eq_zero [simp]: "cos (pi * real (Suc (2 * m)) / 2) = 0"
-by (simp only: cos_add sin_add real_divide_def real_of_nat_Suc left_distrib right_distrib, auto)
+by (simp only: cos_add sin_add divide_inverse real_of_nat_Suc left_distrib right_distrib, auto)
 
 lemma DERIV_cos_add [simp]: "DERIV (%x. cos (x + k)) xa :> - sin (xa + k)"
 apply (rule lemma_DERIV_subst)
@@ -2373,7 +2373,7 @@
 apply (case_tac "x = 0")
 apply (auto simp add: abs_eqI2)
 apply (drule_tac y = y in real_sqrt_sum_squares_gt_zero3)
-apply (auto simp add: zero_less_mult_iff real_divide_def power2_eq_square)
+apply (auto simp add: zero_less_mult_iff divide_inverse power2_eq_square)
 done
 
 lemma polar_ex1: "[| x \<noteq> 0; 0 < y |] ==> \<exists>r a. x = r * cos a & y = r * sin a"
--- a/src/HOL/IsaMakefile	Tue Jul 27 15:39:59 2004 +0200
+++ b/src/HOL/IsaMakefile	Wed Jul 28 10:49:29 2004 +0200
@@ -152,7 +152,7 @@
   Hyperreal/HyperDef.thy Hyperreal/HyperNat.thy\
   Hyperreal/HyperPow.thy Hyperreal/Hyperreal.thy\
   Hyperreal/Lim.thy Hyperreal/Log.thy\
-  Hyperreal/MacLaurin_lemmas.ML Hyperreal/MacLaurin.thy Hyperreal/NatStar.thy\
+  Hyperreal/MacLaurin.thy Hyperreal/NatStar.thy\
   Hyperreal/NSA.thy Hyperreal/NthRoot.thy Hyperreal/Poly.thy\
   Hyperreal/SEQ.ML Hyperreal/SEQ.thy Hyperreal/Series.thy Hyperreal/Star.thy \
   Hyperreal/Transcendental.thy Hyperreal/fuf.ML Hyperreal/hypreal_arith.ML \