src/HOL/Hyperreal/MacLaurin.thy
author obua
Tue, 11 May 2004 20:11:08 +0200
changeset 14738 83f1a514dcb4
parent 12224 02df7cbe7d25
child 15079 2ef899e4526d
permissions -rw-r--r--
changes made due to new Ring_and_Field theory
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12224
02df7cbe7d25 even more theories from Jacques
paulson
parents:
diff changeset
     1
(*  Title       : MacLaurin.thy
02df7cbe7d25 even more theories from Jacques
paulson
parents:
diff changeset
     2
    Author      : Jacques D. Fleuriot
02df7cbe7d25 even more theories from Jacques
paulson
parents:
diff changeset
     3
    Copyright   : 2001 University of Edinburgh
02df7cbe7d25 even more theories from Jacques
paulson
parents:
diff changeset
     4
    Description : MacLaurin series
02df7cbe7d25 even more theories from Jacques
paulson
parents:
diff changeset
     5
*)
02df7cbe7d25 even more theories from Jacques
paulson
parents:
diff changeset
     6
14738
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents: 12224
diff changeset
     7
theory MacLaurin = Log
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents: 12224
diff changeset
     8
files ("MacLaurin_lemmas.ML"):
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents: 12224
diff changeset
     9
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents: 12224
diff changeset
    10
use "MacLaurin_lemmas.ML"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents: 12224
diff changeset
    11
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents: 12224
diff changeset
    12
lemma Maclaurin_sin_bound: 
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents: 12224
diff changeset
    13
  "abs(sin x - sumr 0 n (%m. (if even m then 0 else ((- 1) ^ ((m - (Suc 0)) div 2)) / real (fact m)) * 
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents: 12224
diff changeset
    14
  x ^ m))  <= inverse(real (fact n)) * abs(x) ^ n"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents: 12224
diff changeset
    15
proof -
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents: 12224
diff changeset
    16
  have "!! x (y::real). x <= 1 \<Longrightarrow> 0 <= y \<Longrightarrow> x * y \<le> 1 * y" 
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents: 12224
diff changeset
    17
    by (rule_tac mult_right_mono,simp_all)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents: 12224
diff changeset
    18
  note est = this[simplified]
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents: 12224
diff changeset
    19
  show ?thesis
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents: 12224
diff changeset
    20
    apply (cut_tac f=sin and n=n and x=x and 
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents: 12224
diff changeset
    21
      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)"
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents: 12224
diff changeset
    22
      in Maclaurin_all_le_objl)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents: 12224
diff changeset
    23
    apply (tactic{* (Step_tac 1) *})
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents: 12224
diff changeset
    24
    apply (simp)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents: 12224
diff changeset
    25
    apply (subst mod_Suc_eq_Suc_mod)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents: 12224
diff changeset
    26
    apply (tactic{* cut_inst_tac [("m1","m")] (CLAIM "0 < (4::nat)" RS mod_less_divisor RS lemma_exhaust_less_4) 1*})
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents: 12224
diff changeset
    27
    apply (tactic{* Step_tac 1 *})
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents: 12224
diff changeset
    28
    apply (simp)+
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents: 12224
diff changeset
    29
    apply (rule DERIV_minus, simp+)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents: 12224
diff changeset
    30
    apply (rule lemma_DERIV_subst, rule DERIV_minus, rule DERIV_cos, simp)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents: 12224
diff changeset
    31
    apply (tactic{* dtac ssubst 1 THEN assume_tac 2 *})
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents: 12224
diff changeset
    32
    apply (tactic {* rtac (ARITH_PROVE "[|x = y; abs u <= (v::real) |] ==> abs ((x + u) - y) <= v") 1 *})
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents: 12224
diff changeset
    33
    apply (rule sumr_fun_eq)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents: 12224
diff changeset
    34
    apply (tactic{* Step_tac 1 *})
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents: 12224
diff changeset
    35
    apply (tactic{*rtac (CLAIM "x = y ==> x * z = y * (z::real)") 1*})
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents: 12224
diff changeset
    36
    apply (subst even_even_mod_4_iff)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents: 12224
diff changeset
    37
    apply (tactic{* cut_inst_tac [("m1","r")] (CLAIM "0 < (4::nat)" RS mod_less_divisor RS lemma_exhaust_less_4) 1 *})
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents: 12224
diff changeset
    38
    apply (tactic{* Step_tac 1 *})
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents: 12224
diff changeset
    39
    apply (simp)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents: 12224
diff changeset
    40
    apply (simp_all add:even_num_iff)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents: 12224
diff changeset
    41
    apply (drule lemma_even_mod_4_div_2[simplified])
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents: 12224
diff changeset
    42
    apply(simp add: numeral_2_eq_2 real_divide_def)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents: 12224
diff changeset
    43
    apply (drule lemma_odd_mod_4_div_2 );
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents: 12224
diff changeset
    44
    apply (simp add: numeral_2_eq_2 real_divide_def)
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents: 12224
diff changeset
    45
    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])
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents: 12224
diff changeset
    46
    done
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents: 12224
diff changeset
    47
qed
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents: 12224
diff changeset
    48
83f1a514dcb4 changes made due to new Ring_and_Field theory
obua
parents: 12224
diff changeset
    49
end