Update from HH
[Flyspeck/.git] / formal_ineqs / taylor / theory / taylor_interval-compiled.hl
1 needs "lib/ssrbool-compiled.hl";;
2 needs "lib/ssrnat-compiled.hl";;
3 needs "arith/interval_arith.hl";;
4 needs "Multivariate/realanalysis.ml";;
5 open Interval_arith;;
6 prioritize_real();;
7 let derivative = new_definition `derivative f = \y. @d. (f has_real_derivative d) (atreal y)`;;
8 let nth_derivative = new_definition `nth_derivative n f = iter n derivative f`;;
9 let nth_differentiable = define `(nth_differentiable 0 f x <=> f real_continuous atreal x) /\
10         (nth_differentiable (SUC n) f x <=> nth_differentiable n f x /\ 
11                         nth_derivative n f real_differentiable atreal x)`;;
12 let nth_differentiable_on = new_definition `nth_differentiable_on n s f <=>
13         !x. x IN s ==> nth_differentiable n f x`;;
14 let nth_differentiable_on_int = new_definition `nth_differentiable_on_int n int f <=>
15         !x. interval_arith x int ==> nth_differentiable n f x`;;
16 let nth_diff_weak = new_definition `nth_diff_weak n f x <=> f real_continuous atreal x /\ 
17         ?F. F 0 = f /\ !i. i < n ==> (F i has_real_derivative F (SUC i) x) (atreal x)`;;
18 let nth_diff_strong = new_definition `nth_diff_strong n f x <=> 
19         ?s. real_open s /\ x IN s /\ nth_differentiable_on n s f`;;
20 let nth_diff_strong_int = new_definition `nth_diff_strong_int n int f <=>
21         !x. interval_arith x int ==> nth_diff_strong n f x`;;
22
23 (* Section NthDerivatives *)
24 begin_section "NthDerivatives";;
25
26 (* Lemma has_derivative_cond *)
27 let has_derivative_cond = section_proof ["f";"x"]
28 `(?d. (f has_real_derivative d) (atreal x)) ==>
29         (f has_real_derivative (derivative f x)) (atreal x)`
30 [
31    (BETA_TAC THEN (case THEN (move ["d"])) THEN (move ["df"]));
32    ((THENL_FIRST) (((THENL_ROT 1)) ((fun arg_tac -> arg_tac (Arg_term (`derivative f x = d`))) (term_tac (have_gen_tac [](((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] [])))))))) (exact_tac));
33    (((((use_arg_then "derivative")(thm_tac (new_rewrite [] [])))) THEN (simp_tac)) THEN (((use_arg_then "SELECT_UNIQUE") (thm_tac apply_tac)) THEN (simp_tac) THEN (move ["y"])) THEN ((THENL) (split_tac) [(move ["df2"]); ((((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)))]));
34    ((((fun arg_tac -> (fun arg_tac -> (use_arg_then "REAL_DERIVATIVE_UNIQUE_ATREAL") (fun fst_arg -> (use_arg_then "f") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "x") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN (DISCH_THEN apply_tac)) THEN (done_tac));
35 ];;
36
37 (* Lemma has_derivative_alt *)
38 let has_derivative_alt = section_proof ["f";"x"]
39 `f real_differentiable atreal x ==>
40         (f has_real_derivative (derivative f x)) (atreal x)`
41 [
42    (((((use_arg_then "real_differentiable")(thm_tac (new_rewrite [] [])))) THEN (DISCH_THEN (fun snd_th -> (use_arg_then "has_derivative_cond") (thm_tac (match_mp_then snd_th MP_TAC))))) THEN (done_tac));
43 ];;
44
45 (* Lemma derivative_unique *)
46 let derivative_unique = section_proof ["f";"f'";"x"]
47 `(f has_real_derivative f') (atreal x) ==> derivative f x = f'`
48 [
49    ((BETA_TAC THEN (move ["df"])) THEN (((fun arg_tac -> (fun arg_tac -> (use_arg_then "REAL_DERIVATIVE_UNIQUE_ATREAL") (fun fst_arg -> (use_arg_then "f") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "x") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN (DISCH_THEN apply_tac)));
50    (((((use_arg_then "df")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "has_derivative_cond")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac))) THEN ((use_arg_then "f'") (term_tac exists_tac)) THEN (done_tac));
51 ];;
52
53 (* Lemma derivative_unique_on *)
54 let derivative_unique_on = section_proof ["s";"f";"f'"]
55 `(!x. x IN s ==> (f has_real_derivative f' x) (atreal x)) ==>
56         (!x. x IN s ==> f' x = derivative f x)`
57 [
58    (BETA_TAC THEN (move ["df"]) THEN (move ["x"]) THEN (move ["xs"]));
59    (((((fun arg_tac -> (fun arg_tac -> (use_arg_then "derivative_unique") (fun fst_arg -> (use_arg_then "f") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`f' x`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "df")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
60 ];;
61
62 (* Lemma has_derivative_lemma *)
63 let has_derivative_lemma = section_proof ["f";"f'";"x"]
64 `f real_differentiable atreal x /\
65         derivative f x = f' ==>
66         (f has_real_derivative f') (atreal x)`
67 [
68    ((BETA_TAC THEN (case THEN ((move ["diff"]) THEN (((conv_thm_tac DISCH_THEN)(gsym_then (thm_tac (new_rewrite [] [])))))))) THEN (((use_arg_then "has_derivative_alt")(thm_tac (new_rewrite [] [])))) THEN (done_tac));
69 ];;
70
71 (* Lemma nth_derivative0 *)
72 let nth_derivative0 = section_proof ["f"]
73 `nth_derivative 0 f = f`
74 [
75    (((((use_arg_then "nth_derivative")(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL iter)))(thm_tac (new_rewrite [] []))))) THEN (done_tac));
76 ];;
77
78 (* Lemma nth_derivativeS *)
79 let nth_derivativeS = section_proof ["n";"f"]
80 `nth_derivative (SUC n) f = derivative (nth_derivative n f)`
81 [
82    (((repeat_tactic 1 9 (((use_arg_then "nth_derivative")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "iterS")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
83 ];;
84
85 (* Lemma nth_Sderivative *)
86 let nth_Sderivative = section_proof ["n";"f"]
87 `nth_derivative (SUC n) f = nth_derivative n (derivative f)`
88 [
89    (((((use_arg_then "nth_derivative")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "iterSr")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "nth_derivative")(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (done_tac));
90 ];;
91
92 (* Lemma nth_derivative1 *)
93 let nth_derivative1 = section_proof ["f"]
94 `nth_derivative 1 f = derivative f`
95 [
96    (((((use_arg_then "ONE")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "nth_derivativeS")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "nth_derivative0")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
97 ];;
98
99 (* Lemma nth_derivative2 *)
100 let nth_derivative2 = section_proof ["f"]
101 `nth_derivative 2 f = derivative (derivative f)`
102 [
103    (((((fun arg_tac -> arg_tac (Arg_theorem (ARITH_RULE `2 = SUC(SUC 0)`)))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "nth_derivative")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "iterS")(thm_tac (new_rewrite [] []))))) THEN (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL iter)))(thm_tac (new_rewrite [] []))))) THEN (done_tac));
104 ];;
105
106 (* Lemma nth_derivative_add *)
107 let nth_derivative_add = section_proof ["n";"m";"f"]
108 `nth_derivative n (nth_derivative m f) = nth_derivative (n + m) f`
109 [
110    (((repeat_tactic 1 9 (((use_arg_then "nth_derivative")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "iter_add")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
111 ];;
112
113 (* Lemma nth_diff_continuous *)
114 let nth_diff_continuous = section_proof ["n";"f";"x"]
115 `nth_differentiable n f x ==>
116         f real_continuous atreal x`
117 [
118    (((THENL) (((use_arg_then "n") (disch_tac [])) THEN (clear_assumption "n") THEN elim) [ALL_TAC; ((move ["n"]) THEN (move ["IHn"]))]) THEN ((((use_arg_then "nth_differentiable")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac))));
119    ((BETA_TAC THEN (case THEN (DISCH_THEN (fun snd_th -> (use_arg_then "IHn") (thm_tac (match_mp_then snd_th MP_TAC))))) THEN (simp_tac)) THEN (done_tac));
120 ];;
121
122 (* Lemma nth_differentiable_cond *)
123 let nth_differentiable_cond = section_proof ["n";"f";"x"]
124 `nth_differentiable n f x ==>
125    !i. i < n ==> (nth_derivative i f has_real_derivative (nth_derivative (SUC i) f x)) (atreal x)`
126 [
127    ((THENL_FIRST) ((THENL) (((use_arg_then "n") (disch_tac [])) THEN (clear_assumption "n") THEN elim) [ALL_TAC; ((move ["n"]) THEN (move ["IHn"]))]) ((((use_arg_then "ltn0")(thm_tac (new_rewrite [] [])))) THEN (done_tac)));
128    ((((use_arg_then "nth_differentiable")(thm_tac (new_rewrite [] [])))) THEN ALL_TAC THEN (case THEN ((DISCH_THEN (fun snd_th -> (use_arg_then "IHn") (thm_tac (match_mp_then snd_th MP_TAC)))) THEN (move ["df_n"]) THEN (move ["dfn"]))) THEN (move ["i"]));
129    (((((use_arg_then "ltE")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "leqSS")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "leq_eqVlt")(thm_tac (new_rewrite [] []))))) THEN ((THENL) case [(((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] [])))); ((DISCH_THEN (fun snd_th -> (use_arg_then "df_n") (thm_tac (match_mp_then snd_th MP_TAC)))) THEN ((TRY done_tac)))]));
130    (((((use_arg_then "nth_derivativeS")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "has_derivative_alt")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
131 ];;
132
133 (* Lemma nth_differentiable_on_cond *)
134 let nth_differentiable_on_cond = section_proof ["n";"s";"f"]
135 `nth_differentiable_on n s f ==>
136  !x. x IN s ==> 
137   !i. i < n ==> (nth_derivative i f has_real_derivative (nth_derivative (SUC i) f x)) (atreal x)`
138 [
139    ((((use_arg_then "nth_differentiable_on")(thm_tac (new_rewrite [] [])))) THEN (move ["cond"]) THEN (move ["x"]));
140    (((DISCH_THEN (fun snd_th -> (use_arg_then "cond") (thm_tac (match_mp_then snd_th MP_TAC)))) THEN BETA_TAC THEN (DISCH_THEN (fun snd_th -> (use_arg_then "nth_differentiable_cond") (thm_tac (match_mp_then snd_th MP_TAC))))) THEN (done_tac));
141 ];;
142
143 (* Lemma nth_differentiable_eq *)
144 let nth_differentiable_eq = section_proof ["n";"f";"x"]
145 `nth_differentiable n f x <=>
146   f real_continuous atreal x /\
147   !i. i < n ==> (nth_derivative i f has_real_derivative (nth_derivative (SUC i) f x)) (atreal x)`
148 [
149    ((THENL) (split_tac) [(move ["dn_f"]); (case THEN (move ["f_cont"]))]);
150    (((((fun arg_tac -> (use_arg_then "nth_diff_continuous") (fun fst_arg -> (use_arg_then "dn_f") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "nth_differentiable_cond") (disch_tac [])) THEN (clear_assumption "nth_differentiable_cond") THEN (exact_tac)) THEN (done_tac));
151    (((THENL) (((use_arg_then "n") (disch_tac [])) THEN (clear_assumption "n") THEN elim) [ALL_TAC; ((move ["n"]) THEN (move ["IHn"]))]) THEN (((((use_arg_then "nth_differentiable")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "ltE")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "leqSS")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "leq_eqVlt")(thm_tac (new_rewrite [] []))))) THEN (move ["cond"])));
152    ((THENL_FIRST) ((((use_arg_then "IHn")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))))) ((BETA_TAC THEN (move ["i"]) THEN (move ["i_lt_n"])) THEN (((use_arg_then "cond") (disch_tac [])) THEN (clear_assumption "cond") THEN (DISCH_THEN apply_tac)) THEN (done_tac)));
153    ((((use_arg_then "real_differentiable")(thm_tac (new_rewrite [] [])))) THEN ((fun arg_tac -> arg_tac (Arg_term (`nth_derivative (SUC n) f x`))) (term_tac exists_tac)));
154    (((use_arg_then "cond") (disch_tac [])) THEN (clear_assumption "cond") THEN (exact_tac));
155 ];;
156
157 (* Lemma nth_differentiable_on_int2 *)
158 let nth_differentiable_on_int2 = section_proof ["f";"int"]
159 `nth_differentiable_on_int 2 int f ==>
160         ?f' f''. f' = derivative f /\ f'' = nth_derivative 2 f /\
161                 !x. interval_arith x int ==> (f has_real_derivative f' x) (atreal x) /\
162                                         (f' has_real_derivative f'' x) (atreal x)`
163 [
164    ((((use_arg_then "nth_differentiable_on_int")(thm_tac (new_rewrite [] [])))) THEN (move ["h"]));
165    ((((fun arg_tac -> arg_tac (Arg_term (`derivative f`))) (term_tac exists_tac)) THEN ((fun arg_tac -> arg_tac (Arg_term (`nth_derivative 2 f`))) (term_tac exists_tac))) THEN (simp_tac) THEN (move ["x"]) THEN (move ["ineq"]));
166    ((((use_arg_then "nth_derivative1")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((fun arg_tac -> (use_arg_then "nth_derivative0") (fun fst_arg -> (use_arg_then "f") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(gsym_then (thm_tac (new_rewrite [1] []))))) THEN (((use_arg_then "ONE")(thm_tac (new_rewrite [1] [])))) THEN (((fun arg_tac -> arg_tac (Arg_theorem (ARITH_RULE `2 = SUC 1`)))(thm_tac (new_rewrite [] [])))));
167    (((repeat_tactic 1 9 (((fun arg_tac -> (use_arg_then "nth_differentiable_cond") (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`2`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((use_arg_then "h")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac))) THEN (arith_tac) THEN (done_tac));
168 ];;
169
170 (* Lemma nth_mth_diff *)
171 let nth_mth_diff = section_proof ["n";"m";"f";"x"]
172 `n <= m ==> nth_differentiable m f x ==> nth_differentiable n f x`
173 [
174    ((BETA_TAC THEN (move ["n_le_m"])) THEN ((repeat_tactic 1 9 (((use_arg_then "nth_differentiable_eq")(thm_tac (new_rewrite [] []))))) THEN ALL_TAC THEN (case THEN ((((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] [])))) THEN (move ["cond"])))) THEN ((((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))) THEN (move ["i"]) THEN (move ["i_lt"])));
175    ((((use_arg_then "cond") (disch_tac [])) THEN (clear_assumption "cond") THEN (DISCH_THEN apply_tac)) THEN (((use_arg_then "n_le_m") (disch_tac [])) THEN (clear_assumption "n_le_m") THEN ((use_arg_then "ltn_leq_trans") (disch_tac [])) THEN (clear_assumption "ltn_leq_trans") THEN (DISCH_THEN apply_tac)) THEN (done_tac));
176 ];;
177
178 (* Lemma nth_differentiable1 *)
179 let nth_differentiable1 = section_proof ["f";"x"]
180 `nth_differentiable 1 f x <=> f real_differentiable atreal x`
181 [
182    (((((use_arg_then "ONE")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL nth_differentiable)))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "nth_derivative0")(thm_tac (new_rewrite [] []))))) THEN ((THENL) (split_tac) [(((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] [])))); (move ["df"])]));
183    ((((use_arg_then "REAL_DIFFERENTIABLE_IMP_CONTINUOUS_ATREAL")(thm_tac (new_rewrite [] [])))) THEN (done_tac));
184 ];;
185
186 (* Lemma nth_diff_imp_diff *)
187 let nth_diff_imp_diff = section_proof ["n";"f";"x"]
188 `0 < n ==> nth_differentiable n f x ==>
189         f real_differentiable atreal x`
190 [
191    ((((((use_arg_then "ltE")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "ONE")(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (move ["ineq"]) THEN (move ["df"])) THEN (((use_arg_then "nth_differentiable1")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "nth_mth_diff") (disch_tac [])) THEN (clear_assumption "nth_mth_diff") THEN (DISCH_THEN apply_tac)) THEN ((use_arg_then "n") (term_tac exists_tac)) THEN (done_tac));
192 ];;
193
194 (* Lemma nth_derivative_continuous *)
195 let nth_derivative_continuous = section_proof ["n";"f";"x";"i"]
196 `nth_differentiable n f x ==> i < n ==>
197         nth_derivative i f real_continuous atreal x`
198 [
199    ((((use_arg_then "nth_differentiable_eq")(thm_tac (new_rewrite [] [])))) THEN ALL_TAC THEN (case THEN (move ["_"])) THEN (move ["df"]));
200    (((DISCH_THEN (fun snd_th -> (use_arg_then "df") (thm_tac (match_mp_then snd_th MP_TAC)))) THEN BETA_TAC THEN (move ["cond"])) THEN (((use_arg_then "REAL_DIFFERENTIABLE_IMP_CONTINUOUS_ATREAL") (disch_tac [])) THEN (clear_assumption "REAL_DIFFERENTIABLE_IMP_CONTINUOUS_ATREAL") THEN (DISCH_THEN apply_tac)));
201    ((((use_arg_then "real_differentiable")(thm_tac (new_rewrite [] [])))) THEN ((fun arg_tac -> arg_tac (Arg_term (`nth_derivative (SUC i) f x`))) (term_tac exists_tac)) THEN (done_tac));
202 ];;
203
204 (* Lemma ith_derivative_differentiable *)
205 let ith_derivative_differentiable = section_proof ["i";"n";"f";"x"]
206 `nth_differentiable n f x ==> i < n ==>
207         nth_differentiable (n - i) (nth_derivative i f) x`
208 [
209    (BETA_TAC THEN (move ["dnf"]));
210    ((((use_arg_then "dnf") (disch_tac [])) THEN BETA_TAC) THEN ((repeat_tactic 1 9 (((use_arg_then "nth_differentiable_eq")(thm_tac (new_rewrite [] []))))) THEN ALL_TAC THEN (case THEN (move ["_"])) THEN (move ["cond"]) THEN (move ["i_lt_n"])));
211    (((((fun arg_tac -> (use_arg_then "nth_derivative_continuous") (fun fst_arg -> (use_arg_then "dnf") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))) THEN (move ["j"]) THEN (move ["j_lt_ni"]));
212    (((repeat_tactic 1 9 (((use_arg_then "nth_derivative_add")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "addSn")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "cond")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "j_lt_ni") (disch_tac [])) THEN (clear_assumption "j_lt_ni") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac));
213 ];;
214
215 (* Lemma nth_diff_strong_imp_diff *)
216 let nth_diff_strong_imp_diff = section_proof ["n";"f";"x"]
217 `nth_diff_strong n f x ==>      nth_differentiable n f x`
218 [
219    (((((use_arg_then "nth_diff_strong")(thm_tac (new_rewrite [] [])))) THEN ALL_TAC THEN (case THEN (move ["s"])) THEN (case THEN (move ["_"])) THEN (case THEN (move ["xs"]))) THEN ((((use_arg_then "nth_differentiable_on")(thm_tac (new_rewrite [] [])))) THEN (move ["h"])));
220    (((use_arg_then "h") (disch_tac [])) THEN (clear_assumption "h") THEN (exact_tac));
221 ];;
222
223 (* Section DerivativeArith *)
224 begin_section "DerivativeArith";;
225
226 (* Section ElementaryDerivatives *)
227 begin_section "ElementaryDerivatives";;
228
229 (* Lemma derivative_x *)
230 let derivative_x = section_proof []
231 `derivative (\x. x) = (\x. &1)`
232 [
233    ((((use_arg_then "eq_ext")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (move ["x"]) THEN (simp_tac));
234    ((((use_arg_then "derivative_unique") (disch_tac [])) THEN (clear_assumption "derivative_unique") THEN (DISCH_THEN apply_tac)) THEN (((use_arg_then "HAS_REAL_DERIVATIVE_ID")(thm_tac (new_rewrite [] [])))) THEN (done_tac));
235 ];;
236
237 (* Lemma derivative_const *)
238 let derivative_const = section_proof ["c"]
239 `derivative (\x. c) = (\x. &0)`
240 [
241    ((((use_arg_then "eq_ext")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (move ["x"]) THEN (simp_tac));
242    ((((use_arg_then "derivative_unique") (disch_tac [])) THEN (clear_assumption "derivative_unique") THEN (DISCH_THEN apply_tac)) THEN (((use_arg_then "HAS_REAL_DERIVATIVE_CONST")(thm_tac (new_rewrite [] [])))) THEN (done_tac));
243 ];;
244
245 (* Lemma derivative_inv *)
246 let derivative_inv = section_proof ["x"]
247 `~(x = &0) ==> derivative inv x = -- inv (x * x)`
248 [
249    (BETA_TAC THEN (move ["xn0"]));
250    ((((use_arg_then "derivative_unique") (disch_tac [])) THEN (clear_assumption "derivative_unique") THEN (DISCH_THEN apply_tac)) THEN ((((use_arg_then "REAL_POW_2")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "HAS_REAL_DERIVATIVE_INV_BASIC")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
251 ];;
252
253 (* Lemma derivative_atn *)
254 let derivative_atn = section_proof []
255 `derivative atn = (\x. inv (&1 + x * x))`
256 [
257    (((((use_arg_then "eq_ext")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "REAL_POW_2")(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (move ["x"]) THEN (simp_tac));
258    ((((use_arg_then "derivative_unique") (disch_tac [])) THEN (clear_assumption "derivative_unique") THEN (DISCH_THEN apply_tac)) THEN (((use_arg_then "HAS_REAL_DERIVATIVE_ATN")(thm_tac (new_rewrite [] [])))) THEN (done_tac));
259 ];;
260
261 (* Lemma derivative_exp *)
262 let derivative_exp = section_proof []
263 `derivative exp = exp`
264 [
265    ((((use_arg_then "eq_ext")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (move ["x"]) THEN (simp_tac));
266    ((((use_arg_then "derivative_unique") (disch_tac [])) THEN (clear_assumption "derivative_unique") THEN (DISCH_THEN apply_tac)) THEN (((use_arg_then "HAS_REAL_DERIVATIVE_EXP")(thm_tac (new_rewrite [] [])))) THEN (done_tac));
267 ];;
268
269 (* Lemma derivative_acs *)
270 let derivative_acs = section_proof ["x"]
271 `abs x < &1 ==> derivative acs x = --inv(sqrt(&1 - x * x))`
272 [
273    (BETA_TAC THEN (move ["x_ineq"]));
274    ((((use_arg_then "derivative_unique") (disch_tac [])) THEN (clear_assumption "derivative_unique") THEN (DISCH_THEN apply_tac)) THEN ((((use_arg_then "REAL_POW_2")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "HAS_REAL_DERIVATIVE_ACS")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
275 ];;
276
277 (* Lemma derivative_sqrt *)
278 let derivative_sqrt = section_proof ["x"]
279 `&0 < x ==> derivative sqrt x = inv (&2 * sqrt x)`
280 [
281    (BETA_TAC THEN (move ["xg0"]));
282    ((((use_arg_then "derivative_unique") (disch_tac [])) THEN (clear_assumption "derivative_unique") THEN (DISCH_THEN apply_tac)) THEN (((use_arg_then "HAS_REAL_DERIVATIVE_SQRT")(thm_tac (new_rewrite [] [])))) THEN (done_tac));
283 ];;
284
285 (* Lemma derivative_composition *)
286 let derivative_composition = section_proof ["f";"g";"x"]
287 `f real_differentiable atreal x ==>
288         g real_differentiable atreal (f x) ==>
289         derivative (\x. g (f x)) x = derivative f x * derivative g (f x)`
290 [
291    ((BETA_TAC THEN (DISCH_THEN (fun snd_th -> (use_arg_then "has_derivative_alt") (thm_tac (match_mp_then snd_th MP_TAC)))) THEN (move ["df"]) THEN (DISCH_THEN (fun snd_th -> (use_arg_then "has_derivative_alt") (thm_tac (match_mp_then snd_th MP_TAC)))) THEN (move ["dg"])) THEN (((use_arg_then "derivative_unique") (disch_tac [])) THEN (clear_assumption "derivative_unique") THEN (DISCH_THEN apply_tac)));
292    ((THENL_FIRST) (((fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL HAS_REAL_DERIVATIVE_CHAIN))) (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`derivative f x`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`derivative g`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`\y. y = f x`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "f") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "g") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun arg -> thm_tac MP_TAC arg THEN ALL_TAC)) THEN (ANTS_TAC)) ((BETA_TAC THEN (move ["y"]) THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))) THEN (done_tac)));
293    ((BETA_TAC THEN (case THEN (move ["_"]))) THEN (DISCH_THEN apply_tac) THEN (done_tac));
294 ];;
295
296 (* Section ElementaryCompose *)
297 begin_section "ElementaryCompose";;
298
299 (* Lemma REAL_DIFFERENTIABLE_AT_INV *)
300 let REAL_DIFFERENTIABLE_AT_INV = section_proof ["x"]
301 `~(x = &0) ==> inv real_differentiable atreal x`
302 [
303    (BETA_TAC THEN (move ["xn0"]));
304    ((fun arg_tac -> (fun arg_tac -> (use_arg_then "REAL_DIFFERENTIABLE_INV_ATREAL") (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`(\x. x:real)`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "x") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun arg -> thm_tac MP_TAC arg THEN ALL_TAC));
305    (((simp_tac) THEN (((use_arg_then "REAL_DIFFERENTIABLE_ID")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "xn0")(thm_tac (new_rewrite [] [])))) THEN (simp_tac)) THEN (((use_arg_then "ETA_AX")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN (done_tac));
306 ];;
307 (add_section_var (mk_var ("f", (`:real->real`))));;
308 (add_section_var (mk_var ("x", (`:real`))));;
309 (add_section_hyp "df" (`f real_differentiable atreal x`));;
310
311 (* Lemma derivative_compose_atn *)
312 let derivative_compose_atn = section_proof []
313 `(\x. atn (f x)) real_differentiable atreal x /\
314         derivative (\x. atn (f x)) x = derivative f x / (&1 + f x * f x)`
315 [
316    (split_tac);
317    ((((fun arg_tac -> (use_arg_then "o_THM") (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`atn`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "ETA_AX")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN (((use_arg_then "REAL_DIFFERENTIABLE_COMPOSE_ATREAL") (disch_tac [])) THEN (clear_assumption "REAL_DIFFERENTIABLE_COMPOSE_ATREAL") THEN (DISCH_THEN apply_tac)));
318    (((((use_arg_then "REAL_DIFFERENTIABLE_AT_ATN")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "df")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
319    ((((use_arg_then "derivative_composition")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "df")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "REAL_DIFFERENTIABLE_AT_ATN")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)));
320    (((((use_arg_then "derivative_atn")(thm_tac (new_rewrite [] [])))) THEN (simp_tac) THEN (((use_arg_then "real_div")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
321 ];;
322
323 (* Lemma derivative_compose_exp *)
324 let derivative_compose_exp = section_proof []
325 `(\x. exp (f x)) real_differentiable atreal x /\
326         derivative (\x. exp (f x)) x = exp (f x) * derivative f x`
327 [
328    (split_tac);
329    ((((fun arg_tac -> (use_arg_then "o_THM") (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`exp`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "ETA_AX")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN (((use_arg_then "REAL_DIFFERENTIABLE_COMPOSE_ATREAL") (disch_tac [])) THEN (clear_assumption "REAL_DIFFERENTIABLE_COMPOSE_ATREAL") THEN (DISCH_THEN apply_tac)));
330    (((((use_arg_then "REAL_DIFFERENTIABLE_AT_EXP")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "df")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
331    ((((use_arg_then "derivative_composition")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "df")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "REAL_DIFFERENTIABLE_AT_EXP")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)));
332    (((((use_arg_then "derivative_exp")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_MUL_SYM")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
333 ];;
334
335 (* Lemma derivative_compose_inv *)
336 let derivative_compose_inv = section_proof []
337 `~(f x = &0) ==>
338         (\x. inv (f x)) real_differentiable atreal x /\
339         derivative (\x. inv (f x)) x = -- inv (f x * f x) * derivative f x`
340 [
341    ((THENL_FIRST) ((BETA_TAC THEN (move ["fn0"])) THEN (split_tac)) ((((use_arg_then "REAL_DIFFERENTIABLE_INV_ATREAL") (disch_tac [])) THEN (clear_assumption "REAL_DIFFERENTIABLE_INV_ATREAL") THEN (DISCH_THEN apply_tac)) THEN (done_tac)));
342    (((((use_arg_then "derivative_composition")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "derivative_inv")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "REAL_MUL_SYM")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((use_arg_then "df")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_DIFFERENTIABLE_AT_INV")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
343 ];;
344
345 (* Lemma derivative_compose_sqrt *)
346 let derivative_compose_sqrt = section_proof []
347 `&0 < f x ==>
348         (\x. sqrt (f x)) real_differentiable atreal x /\
349         derivative (\x. sqrt (f x)) x = derivative f x / (&2 * sqrt (f x))`
350 [
351    ((BETA_TAC THEN (move ["f_pos"])) THEN (split_tac));
352    ((((fun arg_tac -> (use_arg_then "o_THM") (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`sqrt`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "ETA_AX")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN (((use_arg_then "REAL_DIFFERENTIABLE_COMPOSE_ATREAL") (disch_tac [])) THEN (clear_assumption "REAL_DIFFERENTIABLE_COMPOSE_ATREAL") THEN (DISCH_THEN apply_tac)));
353    (((((use_arg_then "df")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "REAL_DIFFERENTIABLE_AT_SQRT") (disch_tac [])) THEN (clear_assumption "REAL_DIFFERENTIABLE_AT_SQRT") THEN (DISCH_THEN apply_tac)) THEN (done_tac));
354    ((((use_arg_then "derivative_composition")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "df")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "REAL_DIFFERENTIABLE_AT_SQRT")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)));
355    (((((use_arg_then "derivative_sqrt")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "real_div")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
356 ];;
357
358 (* Lemma derivative_compose_acs *)
359 let derivative_compose_acs = section_proof []
360 `abs (f x) < &1 ==>
361         (\x. acs (f x)) real_differentiable atreal x /\
362         derivative (\x. acs (f x)) x = -- (derivative f x / sqrt (&1 - f x * f x))`
363 [
364    ((BETA_TAC THEN (move ["f_abs"])) THEN (split_tac));
365    ((((fun arg_tac -> (use_arg_then "o_THM") (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`acs`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "ETA_AX")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN (((use_arg_then "REAL_DIFFERENTIABLE_COMPOSE_ATREAL") (disch_tac [])) THEN (clear_assumption "REAL_DIFFERENTIABLE_COMPOSE_ATREAL") THEN (DISCH_THEN apply_tac)));
366    (((((use_arg_then "df")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_DIFFERENTIABLE_AT_ACS")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
367    ((((use_arg_then "derivative_composition")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "df")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "REAL_DIFFERENTIABLE_AT_ACS")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)));
368    (((((use_arg_then "derivative_acs")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "REAL_MUL_RNEG")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "real_div")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
369 ];;
370
371 (* Finalization of the section ElementaryCompose *)
372 let REAL_DIFFERENTIABLE_AT_INV = finalize_theorem REAL_DIFFERENTIABLE_AT_INV;;
373 let derivative_compose_atn = finalize_theorem derivative_compose_atn;;
374 let derivative_compose_exp = finalize_theorem derivative_compose_exp;;
375 let derivative_compose_inv = finalize_theorem derivative_compose_inv;;
376 let derivative_compose_sqrt = finalize_theorem derivative_compose_sqrt;;
377 let derivative_compose_acs = finalize_theorem derivative_compose_acs;;
378 end_section "ElementaryCompose";;
379
380 (* Finalization of the section ElementaryDerivatives *)
381 let derivative_x = finalize_theorem derivative_x;;
382 let derivative_const = finalize_theorem derivative_const;;
383 let derivative_inv = finalize_theorem derivative_inv;;
384 let derivative_atn = finalize_theorem derivative_atn;;
385 let derivative_exp = finalize_theorem derivative_exp;;
386 let derivative_acs = finalize_theorem derivative_acs;;
387 let derivative_sqrt = finalize_theorem derivative_sqrt;;
388 let derivative_composition = finalize_theorem derivative_composition;;
389 let REAL_DIFFERENTIABLE_AT_INV = finalize_theorem REAL_DIFFERENTIABLE_AT_INV;;
390 let derivative_compose_atn = finalize_theorem derivative_compose_atn;;
391 let derivative_compose_exp = finalize_theorem derivative_compose_exp;;
392 let derivative_compose_inv = finalize_theorem derivative_compose_inv;;
393 let derivative_compose_sqrt = finalize_theorem derivative_compose_sqrt;;
394 let derivative_compose_acs = finalize_theorem derivative_compose_acs;;
395 end_section "ElementaryDerivatives";;
396 (add_section_var (mk_var ("f", (`:real -> real`))); add_section_var (mk_var ("g", (`:real -> real`))));;
397 (add_section_var (mk_var ("x", (`:real`))); add_section_var (mk_var ("c", (`:real`))));;
398 (add_section_hyp "df" (`f real_differentiable atreal x`));;
399
400 (* Lemma derivative_scale *)
401 let derivative_scale = section_proof []
402 `derivative (\x. c * f x) x = c * derivative f x`
403 [
404    ((((use_arg_then "derivative_unique") (disch_tac [])) THEN (clear_assumption "derivative_unique") THEN (DISCH_THEN apply_tac)) THEN ((((use_arg_then "HAS_REAL_DERIVATIVE_LMUL_ATREAL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "has_derivative_alt")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
405 ];;
406
407 (* Lemma derivative_neg *)
408 let derivative_neg = section_proof []
409 `derivative (\x. -- f x) x = -- derivative f x`
410 [
411    ((((use_arg_then "derivative_unique") (disch_tac [])) THEN (clear_assumption "derivative_unique") THEN (DISCH_THEN apply_tac)) THEN ((((use_arg_then "HAS_REAL_DERIVATIVE_NEG")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "has_derivative_alt")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
412 ];;
413
414 (* Lemma derivative_pow *)
415 let derivative_pow = section_proof ["n"]
416 `derivative (\x. f x pow n) x = &n * f x pow (n - 1) * derivative f x`
417 [
418    ((((use_arg_then "derivative_unique") (disch_tac [])) THEN (clear_assumption "derivative_unique") THEN (DISCH_THEN apply_tac)) THEN ((((use_arg_then "HAS_REAL_DERIVATIVE_POW_ATREAL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "has_derivative_alt")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
419 ];;
420 (add_section_hyp "dg" (`g real_differentiable atreal x`));;
421
422 (* Lemma derivative_add *)
423 let derivative_add = section_proof []
424 `derivative (\x. f x + g x) x = derivative f x + derivative g x`
425 [
426    ((((use_arg_then "derivative_unique") (disch_tac [])) THEN (clear_assumption "derivative_unique") THEN (DISCH_THEN apply_tac)) THEN ((((use_arg_then "HAS_REAL_DERIVATIVE_ADD")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "has_derivative_alt")(thm_tac (new_rewrite [] [])))))) THEN (done_tac));
427 ];;
428
429 (* Lemma derivative_mul *)
430 let derivative_mul = section_proof []
431 `derivative (\x. f x * g x) x = f x * derivative g x + derivative f x * g x`
432 [
433    ((((use_arg_then "derivative_unique") (disch_tac [])) THEN (clear_assumption "derivative_unique") THEN (DISCH_THEN apply_tac)) THEN ((((use_arg_then "HAS_REAL_DERIVATIVE_MUL_ATREAL")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "has_derivative_alt")(thm_tac (new_rewrite [] [])))))) THEN (done_tac));
434 ];;
435
436 (* Lemma derivative_sub *)
437 let derivative_sub = section_proof []
438 `derivative (\x. f x - g x) x = derivative f x - derivative g x`
439 [
440    ((((use_arg_then "derivative_unique") (disch_tac [])) THEN (clear_assumption "derivative_unique") THEN (DISCH_THEN apply_tac)) THEN ((((use_arg_then "HAS_REAL_DERIVATIVE_SUB")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "has_derivative_alt")(thm_tac (new_rewrite [] [])))))) THEN (done_tac));
441 ];;
442
443 (* Lemma derivative_div *)
444 let derivative_div = section_proof []
445 `~(g x = &0) ==> 
446   derivative (\x. f x / g x) x = (derivative f x * g x - f x * derivative g x) / (g x * g x)`
447 [
448    ((BETA_TAC THEN (move ["gn0"])) THEN (((use_arg_then "derivative_unique") (disch_tac [])) THEN (clear_assumption "derivative_unique") THEN (DISCH_THEN apply_tac)) THEN ((((use_arg_then "REAL_POW_2")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "HAS_REAL_DERIVATIVE_DIV_ATREAL")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac))));
449    ((repeat_tactic 1 9 (((use_arg_then "has_derivative_alt")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
450 ];;
451
452 (* Finalization of the section DerivativeArith *)
453 let derivative_x = finalize_theorem derivative_x;;
454 let derivative_const = finalize_theorem derivative_const;;
455 let derivative_inv = finalize_theorem derivative_inv;;
456 let derivative_atn = finalize_theorem derivative_atn;;
457 let derivative_exp = finalize_theorem derivative_exp;;
458 let derivative_acs = finalize_theorem derivative_acs;;
459 let derivative_sqrt = finalize_theorem derivative_sqrt;;
460 let derivative_composition = finalize_theorem derivative_composition;;
461 let REAL_DIFFERENTIABLE_AT_INV = finalize_theorem REAL_DIFFERENTIABLE_AT_INV;;
462 let derivative_compose_atn = finalize_theorem derivative_compose_atn;;
463 let derivative_compose_exp = finalize_theorem derivative_compose_exp;;
464 let derivative_compose_inv = finalize_theorem derivative_compose_inv;;
465 let derivative_compose_sqrt = finalize_theorem derivative_compose_sqrt;;
466 let derivative_compose_acs = finalize_theorem derivative_compose_acs;;
467 let derivative_scale = finalize_theorem derivative_scale;;
468 let derivative_neg = finalize_theorem derivative_neg;;
469 let derivative_pow = finalize_theorem derivative_pow;;
470 let derivative_add = finalize_theorem derivative_add;;
471 let derivative_mul = finalize_theorem derivative_mul;;
472 let derivative_sub = finalize_theorem derivative_sub;;
473 let derivative_div = finalize_theorem derivative_div;;
474 end_section "DerivativeArith";;
475
476 (* Section MoreDerivativeArith *)
477 begin_section "MoreDerivativeArith";;
478
479 (* Lemma differentiable_sum_numseg *)
480 let differentiable_sum_numseg = section_proof ["G";"n";"m";"x"]
481 `(!i. i IN n..m ==> G i real_differentiable atreal x) ==>
482         (\x. sum (n..m) (\i. G i x)) real_differentiable atreal x`
483 [
484    ((((THENL) (((use_arg_then "m") (disch_tac [])) THEN (clear_assumption "m") THEN elim) [ALL_TAC; ((move ["m"]) THEN (move ["IHm"]))]) THEN (move ["dG"])) THEN (repeat_tactic 1 9 (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL SUM_CLAUSES_NUMSEG)))(thm_tac (new_rewrite [] []))))));
485    ((((fun arg_tac -> (use_arg_then "EXCLUDED_MIDDLE") (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`n = 0`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN case THEN (simp_tac) THEN (move ["n_eq_0"])) THEN ((((use_arg_then "ETA_AX")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN (((use_arg_then "REAL_DIFFERENTIABLE_CONST")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN ((TRY done_tac))));
486    (((((use_arg_then "dG")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "IN_NUMSEG")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "n_eq_0")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "leqnn")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
487    ((THENL_ROT (-1)) (((fun arg_tac -> (use_arg_then "EXCLUDED_MIDDLE") (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`n <= SUC m`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN case THEN (simp_tac) THEN (move ["n_le_Sm"])));
488    ((((use_arg_then "IHm") (disch_tac [])) THEN (clear_assumption "IHm") THEN (DISCH_THEN apply_tac) THEN (move ["i"]) THEN (move ["i_in"])) THEN (((use_arg_then "dG") (disch_tac [])) THEN (clear_assumption "dG") THEN (DISCH_THEN apply_tac)));
489    ((((use_arg_then "i_in") (disch_tac [])) THEN (clear_assumption "i_in") THEN BETA_TAC) THEN (repeat_tactic 1 9 (((use_arg_then "IN_NUMSEG")(thm_tac (new_rewrite [] []))))) THEN (arith_tac) THEN (done_tac));
490    ((((use_arg_then "REAL_DIFFERENTIABLE_ADD")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "ETA_AX")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN ((((use_arg_then "dG")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "IHm")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((use_arg_then "IN_NUMSEG")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "n_le_Sm")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "leqnn")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac))));
491    ((BETA_TAC THEN (move ["i"]) THEN (move ["ineq"])) THEN (((use_arg_then "dG") (disch_tac [])) THEN (clear_assumption "dG") THEN (DISCH_THEN apply_tac)) THEN (((use_arg_then "IN_NUMSEG")(thm_tac (new_rewrite [] [])))));
492    ((((use_arg_then "ineq") (disch_tac [])) THEN (clear_assumption "ineq") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac));
493 ];;
494
495 (* Lemma derivative_sum_numseg *)
496 let derivative_sum_numseg = section_proof ["G";"n";"m";"x"]
497 `(!i. i IN n..m ==> G i real_differentiable atreal x) ==>
498         derivative (\x. sum (n..m) (\i. G i x)) x = sum (n..m) (\i. derivative (G i) x)`
499 [
500    ((((THENL) (((use_arg_then "m") (disch_tac [])) THEN (clear_assumption "m") THEN elim) [ALL_TAC; ((move ["m"]) THEN (move ["IHm"]))]) THEN (move ["dG"])) THEN (repeat_tactic 1 9 (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL SUM_CLAUSES_NUMSEG)))(thm_tac (new_rewrite [] []))))));
501    ((((fun arg_tac -> arg_tac (Arg_term (`n = 0`))) (disch_tac [])) THEN case THEN (simp_tac)) THEN ((((use_arg_then "ETA_AX")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN ((TRY done_tac)) THEN (((use_arg_then "derivative_const")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg])))) THEN (done_tac));
502    ((THENL_ROT (-1)) (((fun arg_tac -> (use_arg_then "EXCLUDED_MIDDLE") (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`n <= SUC m`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN case THEN (simp_tac) THEN (move ["n_le_Sm"])));
503    ((((use_arg_then "IHm") (disch_tac [])) THEN (clear_assumption "IHm") THEN (DISCH_THEN apply_tac) THEN (move ["i"]) THEN (move ["i_in"])) THEN (((use_arg_then "dG") (disch_tac [])) THEN (clear_assumption "dG") THEN (DISCH_THEN apply_tac)));
504    ((((use_arg_then "i_in") (disch_tac [])) THEN (clear_assumption "i_in") THEN BETA_TAC) THEN (repeat_tactic 1 9 (((use_arg_then "IN_NUMSEG")(thm_tac (new_rewrite [] []))))) THEN (arith_tac) THEN (done_tac));
505    (((use_arg_then "IHm")(gsym_then (thm_tac (new_rewrite [] [])))));
506    ((BETA_TAC THEN (move ["i"]) THEN (move ["i_in"])) THEN (((use_arg_then "dG") (disch_tac [])) THEN (clear_assumption "dG") THEN (DISCH_THEN apply_tac)));
507    ((((use_arg_then "i_in") (disch_tac [])) THEN (clear_assumption "i_in") THEN BETA_TAC) THEN (repeat_tactic 1 9 (((use_arg_then "IN_NUMSEG")(thm_tac (new_rewrite [] []))))) THEN (arith_tac));
508    ((((use_arg_then "derivative_add")(thm_tac (new_rewrite [] [])))) THEN ((((use_arg_then "ETA_AX")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN ((TRY done_tac))));
509    (((((use_arg_then "dG")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "IN_NUMSEG")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "leqnn")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((use_arg_then "andbT")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "differentiable_sum_numseg")(thm_tac (new_rewrite [] []))))) THEN (move ["i"]) THEN (move ["i_in"]));
510    ((((use_arg_then "dG") (disch_tac [])) THEN (clear_assumption "dG") THEN (DISCH_THEN apply_tac)) THEN (((use_arg_then "i_in") (disch_tac [])) THEN (clear_assumption "i_in") THEN BETA_TAC) THEN (repeat_tactic 1 9 (((use_arg_then "IN_NUMSEG")(thm_tac (new_rewrite [] []))))) THEN (arith_tac) THEN (done_tac));
511 ];;
512
513 (* Finalization of the section MoreDerivativeArith *)
514 let differentiable_sum_numseg = finalize_theorem differentiable_sum_numseg;;
515 let derivative_sum_numseg = finalize_theorem derivative_sum_numseg;;
516 end_section "MoreDerivativeArith";;
517
518 (* Lemma HAS_REAL_DERIVATIVE_LOCAL *)
519 let HAS_REAL_DERIVATIVE_LOCAL = section_proof ["f";"g";"x";"g'"]
520 `(g has_real_derivative g') (atreal x) /\
521         (?s. real_open s /\ x IN s /\ (!y. y IN s ==> f y = g y))
522         ==> (f has_real_derivative g') (atreal x)`
523 [
524    (BETA_TAC THEN (case THEN (move ["dg"])) THEN (case THEN (move ["s"])) THEN (case THEN (move ["open_s"])) THEN (case THEN (move ["xs"])) THEN (move ["f_eq_g"]));
525    ((((use_arg_then "dg") (disch_tac [])) THEN (clear_assumption "dg") THEN BETA_TAC) THEN (((repeat_tactic 1 9 (((fun arg_tac -> (use_arg_then "HAS_REAL_DERIVATIVE_WITHIN_REAL_OPEN") (fun fst_arg -> (use_arg_then "open_s") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(gsym_then (thm_tac (new_rewrite [] [])))))) THEN ((TRY done_tac))) THEN (move ["dg"])));
526    (((fun arg_tac -> (use_arg_then "HAS_REAL_DERIVATIVE_TRANSFORM_WITHIN") (fun fst_arg -> (use_arg_then "dg") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN (DISCH_THEN apply_tac));
527    (((fun arg_tac -> arg_tac (Arg_term (`&1`))) (term_tac exists_tac)) THEN (((((use_arg_then "REAL_LT_01")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "xs")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))))) THEN (move ["y"]) THEN (case THEN ALL_TAC) THEN (DISCH_THEN (fun snd_th -> (use_arg_then "f_eq_g") (thm_tac (match_mp_then snd_th MP_TAC)))) THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))) THEN (done_tac));
528 ];;
529
530 (* Lemma differentiable_local *)
531 let differentiable_local = section_proof ["f";"g";"x";"s"]
532 `g real_differentiable atreal x /\ real_open s /\ x IN s /\
533         (!y. y IN s ==> f y = g y) ==> f real_differentiable atreal x`
534 [
535    ((repeat_tactic 1 9 (((use_arg_then "real_differentiable")(thm_tac (new_rewrite [] []))))) THEN ALL_TAC THEN (case THEN ALL_TAC) THEN (case THEN (move ["f'"])) THEN (move ["dg"]) THEN (case THEN (move ["open_s"])) THEN (case THEN (move ["xs"])) THEN (move ["eq"]));
536    (((use_arg_then "f'") (term_tac exists_tac)) THEN (((use_arg_then "HAS_REAL_DERIVATIVE_LOCAL") (disch_tac [])) THEN (clear_assumption "HAS_REAL_DERIVATIVE_LOCAL") THEN (DISCH_THEN apply_tac)));
537    (((use_arg_then "g") (term_tac exists_tac)) THEN ((((use_arg_then "dg")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))) THEN ((use_arg_then "s") (term_tac exists_tac)) THEN (done_tac));
538 ];;
539
540 (* Section NthDerivativeArith *)
541 begin_section "NthDerivativeArith";;
542 (add_section_var (mk_var ("f", (`:real->real`))); add_section_var (mk_var ("g", (`:real->real`))));;
543 (add_section_var (mk_var ("int", (`:real#real`))));;
544 (add_section_var (mk_var ("n", (`:num`))));;
545 (add_section_hyp "df" (`nth_diff_strong_int n int f`));;
546
547 (* Lemma nth_derivative_scale_strong *)
548 let nth_derivative_scale_strong = section_proof ["c";"i";"x"]
549 `interval_arith x int ==> i <= n ==>
550         ?s. real_open s /\ x IN s /\ 
551         !y. y IN s ==> nth_derivative i (\y. c * f y) y = c * nth_derivative i f y`
552 [
553    ((((use_arg_then "df") (disch_tac [])) THEN (clear_assumption "df") THEN BETA_TAC) THEN (((((use_arg_then "nth_diff_strong_int")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "nth_diff_strong")(thm_tac (new_rewrite [] []))))) THEN (move ["df"])));
554    (((DISCH_THEN (fun snd_th -> (use_arg_then "df") (thm_tac (match_mp_then snd_th MP_TAC)))) THEN BETA_TAC THEN (case THEN (move ["s"])) THEN (case THEN (move ["open_s"])) THEN (case THEN (move ["xs"]))) THEN (((((use_arg_then "nth_differentiable_on")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "nth_differentiable_eq")(thm_tac (new_rewrite [] []))))) THEN (move ["diff"])));
555    ((THENL_FIRST) ((THENL) (((use_arg_then "i") (disch_tac [])) THEN (clear_assumption "i") THEN elim) [(move ["_"]); ((move ["i"]) THEN (move ["IHi"]))]) ((repeat_tactic 1 9 (((use_arg_then "nth_derivative0")(thm_tac (new_rewrite [] []))))) THEN ((use_arg_then "s") (term_tac exists_tac)) THEN (done_tac)));
556    (((((use_arg_then "nth_derivativeS")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "ltE")(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (move ["i_lt_n"]));
557    ((((fun arg_tac -> (use_arg_then "IHi") (fun fst_arg -> (fun arg_tac -> (use_arg_then "ltnW") (fun fst_arg -> (use_arg_then "i_lt_n") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC THEN (case THEN (move ["t"])) THEN (case THEN (move ["open_t"])) THEN (case THEN (move ["xt"])) THEN (move ["eq"])) THEN (((use_arg_then "IHi") (disch_tac [])) THEN (clear_assumption "IHi") THEN BETA_TAC THEN (move ["_"])));
558    (((fun arg_tac -> arg_tac (Arg_term (`s INTER t`))) (term_tac exists_tac)) THEN (((((use_arg_then "REAL_OPEN_INTER")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (repeat_tactic 1 9 (((use_arg_then "IN_INTER")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "xt")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "xs")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))))) THEN (move ["y"]) THEN (case THEN ((move ["ys"]) THEN (move ["yt"])))));
559    (((use_arg_then "derivative_unique") (disch_tac [])) THEN (clear_assumption "derivative_unique") THEN (DISCH_THEN apply_tac));
560    (((use_arg_then "HAS_REAL_DERIVATIVE_LOCAL") (disch_tac [])) THEN (clear_assumption "HAS_REAL_DERIVATIVE_LOCAL") THEN (DISCH_THEN apply_tac));
561    ((fun arg_tac -> arg_tac (Arg_term (`\y. c * nth_derivative i f y`))) (term_tac exists_tac));
562    ((((use_arg_then "HAS_REAL_DERIVATIVE_LMUL_ATREAL")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))));
563    ((((use_arg_then "ETA_AX")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN (((fun arg_tac -> (use_arg_then "diff") (fun fst_arg -> (use_arg_then "ys") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [])))) THEN (done_tac));
564    (((fun arg_tac -> arg_tac (Arg_term (`s INTER t`))) (term_tac exists_tac)) THEN (((((use_arg_then "REAL_OPEN_INTER")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (repeat_tactic 1 9 (((use_arg_then "IN_INTER")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "yt")(thm_tac (new_rewrite [1] [])))) THEN (((use_arg_then "ys")(thm_tac (new_rewrite [1] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))))) THEN (move ["z"]) THEN (move ["z_in"]) THEN (simp_tac)));
565    ((((use_arg_then "eq")(thm_tac (new_rewrite [] [])))) THEN (done_tac));
566 ];;
567
568 (* Lemma nth_derivative_scale_strong_all *)
569 let nth_derivative_scale_strong_all = section_proof ["c";"x"]
570 `interval_arith x int ==>
571         ?s. real_open s /\ x IN s /\ 
572         !i y. i <= n /\ y IN s ==> nth_derivative i (\y. c * f y) y = c * nth_derivative i f y`
573 [
574    (BETA_TAC THEN (DISCH_THEN (fun snd_th -> (fun arg_tac -> (use_arg_then "nth_derivative_scale_strong") (fun fst_arg -> (use_arg_then "c") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (thm_tac (match_mp_then snd_th MP_TAC)))) THEN (move ["h"]));
575    ((fun arg_tac -> arg_tac (Arg_term (`\i s. real_open s /\ x IN s /\ 
576         (!y. y IN s ==> nth_derivative i (\y. c * f y) y = c * nth_derivative i f y)`))) (term_tac (set_tac "P")));
577    ((fun arg_tac -> arg_tac (Arg_term (`!i. i <= n:num ==> P i ((@) (P i))`))) (term_tac (have_gen_tac [](move ["sel_P"]))));
578    ((BETA_TAC THEN (move ["i"]) THEN (move ["i_le_n"])) THEN ((use_arg_then "SELECT_AX") (thm_tac apply_tac)));
579    (((fun arg_tac -> (use_arg_then "h") (fun fst_arg -> (use_arg_then "i_le_n") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC THEN (case THEN (move ["s"])) THEN (move ["cond"]));
580    (((use_arg_then "s") (term_tac exists_tac)) THEN ((((use_arg_then "P_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (simp_tac)) THEN (done_tac));
581    ((fun arg_tac -> arg_tac (Arg_term (`INTERS (IMAGE (\i. (@) (P i)) (0..n))`))) (term_tac (set_tac "S")));
582    ((use_arg_then "S") (term_tac exists_tac));
583    ((((use_arg_then "S_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "REAL_OPEN_INTERS")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "FINITE_IMAGE")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "FINITE_NUMSEG")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "IN_IMAGE")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))));
584    ((BETA_TAC THEN (move ["t"]) THEN (case THEN (move ["i"])) THEN (case THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] [])))))) THEN ((((use_arg_then "IN_NUMSEG_0")(thm_tac (new_rewrite [] [])))) THEN (DISCH_THEN (fun snd_th -> (use_arg_then "sel_P") (thm_tac (match_mp_then snd_th MP_TAC))))));
585    (((((use_arg_then "P_def")(gsym_then (thm_tac (new_rewrite [1] []))))) THEN (simp_tac)) THEN (done_tac));
586    (((repeat_tactic 1 9 (((use_arg_then "IN_INTERS")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "IN_IMAGE")(thm_tac (new_rewrite [] [])))))) THEN (split_tac));
587    ((BETA_TAC THEN (move ["t"]) THEN (case THEN (move ["i"])) THEN (case THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] [])))))) THEN ((((use_arg_then "IN_NUMSEG_0")(thm_tac (new_rewrite [] [])))) THEN (DISCH_THEN (fun snd_th -> (use_arg_then "sel_P") (thm_tac (match_mp_then snd_th MP_TAC))))));
588    (((((use_arg_then "P_def")(gsym_then (thm_tac (new_rewrite [1] []))))) THEN (simp_tac)) THEN (done_tac));
589    (BETA_TAC THEN (move ["i"]) THEN (move ["y"]) THEN (case THEN (move ["i_le_n"])));
590    ((((fun arg_tac -> (use_arg_then "sel_P") (fun fst_arg -> (use_arg_then "i_le_n") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC) THEN (((((use_arg_then "P_def")(gsym_then (thm_tac (new_rewrite [1] []))))) THEN (simp_tac)) THEN ALL_TAC THEN (case THEN (move ["_"])) THEN (case THEN (move ["_"])) THEN (move ["y_in"]) THEN ((fun arg_tac ->  (conv_thm_tac DISCH_THEN)  (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`(@) (P i)`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (thm_tac MP_TAC))));
591    ((THENL_FIRST) (ANTS_TAC) (((use_arg_then "i") (term_tac exists_tac)) THEN (((use_arg_then "IN_NUMSEG_0")(thm_tac (new_rewrite [] [])))) THEN (done_tac)));
592    (((use_arg_then "y_in") (disch_tac [])) THEN (clear_assumption "y_in") THEN (exact_tac));
593 ];;
594
595 (* Lemma nth_derivative_scale *)
596 let nth_derivative_scale = section_proof ["c";"i";"x"]
597 `interval_arith x int ==> i <= n ==>
598         nth_derivative i (\x. c * f x) x = c * nth_derivative i f x`
599 [
600    (BETA_TAC THEN (move ["ineq"]) THEN (move ["i_le_n"]));
601    ((fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (use_arg_then "nth_derivative_scale_strong") (fun fst_arg -> (use_arg_then "c") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "ineq") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "i_le_n") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun arg -> thm_tac MP_TAC arg THEN ALL_TAC));
602    (BETA_TAC THEN (case THEN (move ["s"])) THEN (case THEN (move ["_"])) THEN (case THEN (move ["xs"])) THEN (move ["h"]));
603    (((use_arg_then "h") (disch_tac [])) THEN (clear_assumption "h") THEN (exact_tac));
604 ];;
605
606 (* Lemma nth_diff_scale *)
607 let nth_diff_scale = section_proof ["c"]
608 `nth_diff_strong_int n int (\x. c * f x)`
609 [
610    ((((use_arg_then "df") (disch_tac [])) THEN BETA_TAC) THEN ((repeat_tactic 1 9 (((use_arg_then "nth_diff_strong_int")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "nth_diff_strong")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "nth_differentiable_on")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "nth_differentiable_eq")(thm_tac (new_rewrite [] [])))))));
611    (BETA_TAC THEN (move ["df"]) THEN (move ["x"]) THEN (move ["ineq"]));
612    ((fun arg_tac -> (fun arg_tac -> (use_arg_then "nth_derivative_scale_strong_all") (fun fst_arg -> (use_arg_then "c") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "ineq") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun arg -> thm_tac MP_TAC arg THEN ALL_TAC));
613    (BETA_TAC THEN (case THEN (move ["s"])) THEN (case THEN (move ["open_s"])) THEN (case THEN (move ["xs"])) THEN (move ["diff"]));
614    (((fun arg_tac -> (use_arg_then "df") (fun fst_arg -> (use_arg_then "ineq") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC THEN (case THEN (move ["t"])) THEN (case THEN (move ["open_t"])) THEN (case THEN (move ["xt"])) THEN (move ["diff2"]));
615    (((fun arg_tac -> arg_tac (Arg_term (`s INTER t`))) (term_tac exists_tac)) THEN (((((use_arg_then "REAL_OPEN_INTER")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "IN_INTER")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "xs")(thm_tac (new_rewrite [1] [])))) THEN (((use_arg_then "xt")(thm_tac (new_rewrite [1] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))))) THEN (move ["y"]) THEN (case THEN ((move ["ys"]) THEN (move ["yt"])))));
616    (((((use_arg_then "REAL_CONTINUOUS_LMUL")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "diff2")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))) THEN (move ["i"]) THEN (move ["i_lt_n"]));
617    ((((use_arg_then "diff")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "ys")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "ltE")(gsym_then (thm_tac (new_rewrite [] [])))))) THEN ((TRY done_tac)));
618    (((use_arg_then "HAS_REAL_DERIVATIVE_LOCAL") (disch_tac [])) THEN (clear_assumption "HAS_REAL_DERIVATIVE_LOCAL") THEN (DISCH_THEN apply_tac));
619    ((fun arg_tac -> arg_tac (Arg_term (`(\y. c * nth_derivative i f y)`))) (term_tac exists_tac));
620    ((THENL_FIRST) ((((use_arg_then "HAS_REAL_DERIVATIVE_LMUL_ATREAL")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))))) ((((use_arg_then "ETA_AX")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN (((fun arg_tac -> (use_arg_then "diff2") (fun fst_arg -> (use_arg_then "yt") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [])))) THEN (done_tac)));
621    (((use_arg_then "s") (term_tac exists_tac)) THEN (((((use_arg_then "open_s")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "ys")(thm_tac (new_rewrite [1] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))))) THEN (move ["z"]) THEN (move ["zs"]) THEN (simp_tac)));
622    ((((use_arg_then "diff") (disch_tac [])) THEN (clear_assumption "diff") THEN (DISCH_THEN apply_tac)) THEN (((use_arg_then "ltnW")(thm_tac (new_rewrite [] [])))) THEN (done_tac));
623 ];;
624 (add_section_hyp "dg" (`nth_diff_strong_int n int g`));;
625
626 (* Lemma nth_derivative_add_strong *)
627 let nth_derivative_add_strong = section_proof ["i";"x"]
628 `interval_arith x int ==> i <= n ==>
629    ?s. real_open s /\ x IN s /\ 
630       !y. y IN s ==> nth_derivative i (\y. f y + g y) y = nth_derivative i f y + nth_derivative i g y`
631 [
632    ((((use_arg_then "dg") (disch_tac [])) THEN (clear_assumption "dg") THEN ((use_arg_then "df") (disch_tac [])) THEN (clear_assumption "df") THEN BETA_TAC) THEN (((repeat_tactic 1 9 (((use_arg_then "nth_diff_strong_int")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "nth_diff_strong")(thm_tac (new_rewrite [] [])))))) THEN (move ["df"]) THEN (move ["dg"]) THEN (move ["ineq"])));
633    ((((fun arg_tac -> (use_arg_then "df") (fun fst_arg -> (use_arg_then "ineq") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC THEN (case THEN (move ["sf"])) THEN (case THEN (move ["open_sf"])) THEN (case THEN (move ["xsf"]))) THEN (((use_arg_then "df") (disch_tac [])) THEN (clear_assumption "df") THEN BETA_TAC THEN (move ["_"])));
634    ((((fun arg_tac -> (use_arg_then "dg") (fun fst_arg -> (use_arg_then "ineq") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC THEN (case THEN (move ["sg"])) THEN (case THEN (move ["open_sg"])) THEN (case THEN (move ["xsg"]))) THEN (((use_arg_then "dg") (disch_tac [])) THEN (clear_assumption "dg") THEN BETA_TAC THEN (move ["_"])));
635    (((repeat_tactic 1 9 (((use_arg_then "nth_differentiable_on")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "nth_differentiable_eq")(thm_tac (new_rewrite [] [])))))) THEN (move ["diff_g"]) THEN (move ["diff_f"]));
636    ((THENL_FIRST) ((THENL) (((use_arg_then "i") (disch_tac [])) THEN (clear_assumption "i") THEN elim) [(move ["_"]); ((move ["i"]) THEN (move ["IHi"]))]) ((repeat_tactic 1 9 (((use_arg_then "nth_derivative0")(thm_tac (new_rewrite [] []))))) THEN ((use_arg_then "sf") (term_tac exists_tac)) THEN (done_tac)));
637    (((((use_arg_then "nth_derivativeS")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "ltE")(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (move ["i_lt_n"]));
638    ((((fun arg_tac -> (use_arg_then "IHi") (fun fst_arg -> (fun arg_tac -> (use_arg_then "ltnW") (fun fst_arg -> (use_arg_then "i_lt_n") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC THEN (case THEN (move ["t"])) THEN (case THEN (move ["open_t"])) THEN (case THEN (move ["xt"])) THEN (move ["eq"])) THEN (((use_arg_then "IHi") (disch_tac [])) THEN (clear_assumption "IHi") THEN BETA_TAC THEN (move ["_"])));
639    ((fun arg_tac -> arg_tac (Arg_term (`sf INTER sg INTER t`))) (term_tac exists_tac));
640    (((repeat_tactic 1 9 (((use_arg_then "REAL_OPEN_INTER")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (repeat_tactic 1 9 (((use_arg_then "IN_INTER")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "xt")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "xsf")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "xsg")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))))) THEN (move ["y"]) THEN (case THEN (move ["ysf"])) THEN (case THEN ((move ["ysg"]) THEN (move ["yt"]))));
641    (((use_arg_then "derivative_unique") (disch_tac [])) THEN (clear_assumption "derivative_unique") THEN (DISCH_THEN apply_tac));
642    (((use_arg_then "HAS_REAL_DERIVATIVE_LOCAL") (disch_tac [])) THEN (clear_assumption "HAS_REAL_DERIVATIVE_LOCAL") THEN (DISCH_THEN apply_tac));
643    ((fun arg_tac -> arg_tac (Arg_term (`(\y. nth_derivative i f y + nth_derivative i g y)`))) (term_tac exists_tac));
644    ((((use_arg_then "HAS_REAL_DERIVATIVE_ADD")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))));
645    ((((use_arg_then "ETA_AX")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN ((((fun arg_tac -> (use_arg_then "diff_f") (fun fst_arg -> (use_arg_then "ysf") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((fun arg_tac -> (use_arg_then "diff_g") (fun fst_arg -> (use_arg_then "ysg") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] []))))) THEN (done_tac));
646    (((fun arg_tac -> arg_tac (Arg_term (`sf INTER sg INTER t`))) (term_tac exists_tac)) THEN ((repeat_tactic 1 9 (((use_arg_then "REAL_OPEN_INTER")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (repeat_tactic 1 9 (((use_arg_then "IN_INTER")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "yt")(thm_tac (new_rewrite [1] [])))) THEN (((use_arg_then "ysf")(thm_tac (new_rewrite [1] [])))) THEN (((use_arg_then "ysg")(thm_tac (new_rewrite [1] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))))));
647    ((BETA_TAC THEN (move ["z"]) THEN (move ["z_in"]) THEN (simp_tac)) THEN (((use_arg_then "eq")(thm_tac (new_rewrite [] [])))) THEN (done_tac));
648 ];;
649
650 (* Lemma nth_derivative_add_strong_all *)
651 let nth_derivative_add_strong_all = section_proof ["x"]
652 `interval_arith x int ==>
653         ?s. real_open s /\ x IN s /\ 
654         !i y. i <= n /\ y IN s ==> 
655                 nth_derivative i (\y. f y + g y) y = nth_derivative i f y + nth_derivative i g y`
656 [
657    (BETA_TAC THEN (DISCH_THEN (fun snd_th -> (use_arg_then "nth_derivative_add_strong") (thm_tac (match_mp_then snd_th MP_TAC)))) THEN (move ["h"]));
658    ((fun arg_tac -> arg_tac (Arg_term (`\i s. real_open s /\ x IN s /\ 
659    (!y. y IN s ==> nth_derivative i (\y. f y + g y) y = nth_derivative i f y + nth_derivative i g y)`))) (term_tac (set_tac "P")));
660    ((fun arg_tac -> arg_tac (Arg_term (`!i. i <= n:num ==> P i ((@) (P i))`))) (term_tac (have_gen_tac [](move ["sel_P"]))));
661    ((BETA_TAC THEN (move ["i"]) THEN (move ["i_le_n"])) THEN ((use_arg_then "SELECT_AX") (thm_tac apply_tac)));
662    (((fun arg_tac -> (use_arg_then "h") (fun fst_arg -> (use_arg_then "i_le_n") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC THEN (case THEN (move ["s"])) THEN (move ["cond"]));
663    (((use_arg_then "s") (term_tac exists_tac)) THEN ((((use_arg_then "P_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (simp_tac)) THEN (done_tac));
664    ((fun arg_tac -> arg_tac (Arg_term (`INTERS (IMAGE (\i. (@) (P i)) (0..n))`))) (term_tac (set_tac "S")));
665    ((use_arg_then "S") (term_tac exists_tac));
666    ((((use_arg_then "S_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "REAL_OPEN_INTERS")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "FINITE_IMAGE")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "FINITE_NUMSEG")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "IN_IMAGE")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))));
667    ((BETA_TAC THEN (move ["t"]) THEN (case THEN (move ["i"])) THEN (case THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] [])))))) THEN ((((use_arg_then "IN_NUMSEG_0")(thm_tac (new_rewrite [] [])))) THEN (DISCH_THEN (fun snd_th -> (use_arg_then "sel_P") (thm_tac (match_mp_then snd_th MP_TAC))))));
668    (((((use_arg_then "P_def")(gsym_then (thm_tac (new_rewrite [1] []))))) THEN (simp_tac)) THEN (done_tac));
669    (((repeat_tactic 1 9 (((use_arg_then "IN_INTERS")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "IN_IMAGE")(thm_tac (new_rewrite [] [])))))) THEN (split_tac));
670    ((BETA_TAC THEN (move ["t"]) THEN (case THEN (move ["i"])) THEN (case THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] [])))))) THEN ((((use_arg_then "IN_NUMSEG_0")(thm_tac (new_rewrite [] [])))) THEN (DISCH_THEN (fun snd_th -> (use_arg_then "sel_P") (thm_tac (match_mp_then snd_th MP_TAC))))));
671    (((((use_arg_then "P_def")(gsym_then (thm_tac (new_rewrite [1] []))))) THEN (simp_tac)) THEN (done_tac));
672    (BETA_TAC THEN (move ["i"]) THEN (move ["y"]) THEN (case THEN (move ["i_le_n"])));
673    ((((fun arg_tac -> (use_arg_then "sel_P") (fun fst_arg -> (use_arg_then "i_le_n") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC) THEN (((((use_arg_then "P_def")(gsym_then (thm_tac (new_rewrite [1] []))))) THEN (simp_tac)) THEN ALL_TAC THEN (case THEN (move ["_"])) THEN (case THEN (move ["_"])) THEN (move ["y_in"]) THEN ((fun arg_tac ->  (conv_thm_tac DISCH_THEN)  (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`(@) (P i)`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (thm_tac MP_TAC))));
674    ((THENL_FIRST) (ANTS_TAC) (((use_arg_then "i") (term_tac exists_tac)) THEN (((use_arg_then "IN_NUMSEG_0")(thm_tac (new_rewrite [] [])))) THEN (done_tac)));
675    (((use_arg_then "y_in") (disch_tac [])) THEN (clear_assumption "y_in") THEN (exact_tac));
676 ];;
677
678 (* Lemma nth_derivative_add *)
679 let nth_derivative_add = section_proof ["i";"x"]
680 `interval_arith x int ==> i <= n ==>
681         nth_derivative i (\x. f x + g x) x = nth_derivative i f x + nth_derivative i g x`
682 [
683    (BETA_TAC THEN (move ["ineq"]) THEN (move ["i_le_n"]));
684    ((fun arg_tac -> (fun arg_tac -> (use_arg_then "nth_derivative_add_strong") (fun fst_arg -> (use_arg_then "ineq") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "i_le_n") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun arg -> thm_tac MP_TAC arg THEN ALL_TAC));
685    (BETA_TAC THEN (case THEN (move ["s"])) THEN (case THEN (move ["_"])) THEN (case THEN (move ["xs"])) THEN (move ["h"]));
686    (((use_arg_then "h") (disch_tac [])) THEN (clear_assumption "h") THEN (exact_tac));
687 ];;
688
689 (* Lemma nth_diff_add *)
690 let nth_diff_add = section_proof []
691 `nth_diff_strong_int n int (\x. f x + g x)`
692 [
693    (((use_arg_then "dg") (disch_tac [])) THEN ((use_arg_then "df") (disch_tac [])) THEN BETA_TAC);
694    ((repeat_tactic 1 9 (((use_arg_then "nth_diff_strong_int")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "nth_diff_strong")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "nth_differentiable_on")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "nth_differentiable_eq")(thm_tac (new_rewrite [] []))))));
695    (BETA_TAC THEN (move ["df"]) THEN (move ["dg"]) THEN (move ["x"]) THEN (move ["ineq"]));
696    ((fun arg_tac -> (use_arg_then "nth_derivative_add_strong_all") (fun fst_arg -> (use_arg_then "ineq") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun arg -> thm_tac MP_TAC arg THEN ALL_TAC));
697    (BETA_TAC THEN (case THEN (move ["s"])) THEN (case THEN (move ["open_s"])) THEN (case THEN (move ["xs"])) THEN (move ["diff"]));
698    (((fun arg_tac -> (use_arg_then "df") (fun fst_arg -> (use_arg_then "ineq") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC THEN (case THEN (move ["tf"])) THEN (case THEN (move ["open_tf"])) THEN (case THEN (move ["xtf"])) THEN (move ["diff_f"]));
699    (((fun arg_tac -> (use_arg_then "dg") (fun fst_arg -> (use_arg_then "ineq") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC THEN (case THEN (move ["tg"])) THEN (case THEN (move ["open_tg"])) THEN (case THEN (move ["xtg"])) THEN (move ["diff_g"]));
700    (((fun arg_tac -> arg_tac (Arg_term (`s INTER tf INTER tg`))) (term_tac exists_tac)) THEN ((repeat_tactic 1 9 (((use_arg_then "REAL_OPEN_INTER")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (repeat_tactic 1 9 (((use_arg_then "IN_INTER")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "xs")(thm_tac (new_rewrite [1] [])))) THEN (((use_arg_then "xtf")(thm_tac (new_rewrite [1] [])))) THEN (((use_arg_then "xtg")(thm_tac (new_rewrite [1] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))))));
701    (BETA_TAC THEN (move ["y"]) THEN (case THEN ((move ["ys"]) THEN (case THEN ((move ["ytf"]) THEN (move ["ytg"]))))));
702    (((((use_arg_then "REAL_CONTINUOUS_ADD")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "diff_f")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "diff_g")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))) THEN (move ["i"]) THEN (move ["i_lt_n"]));
703    ((((use_arg_then "diff")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "ys")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "ltE")(gsym_then (thm_tac (new_rewrite [] [])))))) THEN ((TRY done_tac)));
704    (((use_arg_then "HAS_REAL_DERIVATIVE_LOCAL") (disch_tac [])) THEN (clear_assumption "HAS_REAL_DERIVATIVE_LOCAL") THEN (DISCH_THEN apply_tac));
705    ((fun arg_tac -> arg_tac (Arg_term (`(\y. nth_derivative i f y + nth_derivative i g y)`))) (term_tac exists_tac));
706    ((THENL_FIRST) ((((use_arg_then "HAS_REAL_DERIVATIVE_ADD")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))))) ((((use_arg_then "ETA_AX")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN ((((fun arg_tac -> (use_arg_then "diff_f") (fun fst_arg -> (use_arg_then "ytf") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((fun arg_tac -> (use_arg_then "diff_g") (fun fst_arg -> (use_arg_then "ytg") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] []))))) THEN (done_tac)));
707    (((use_arg_then "s") (term_tac exists_tac)) THEN (((((use_arg_then "open_s")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "ys")(thm_tac (new_rewrite [1] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))))) THEN (move ["z"]) THEN (move ["zs"]) THEN (simp_tac)));
708    ((((use_arg_then "diff") (disch_tac [])) THEN (clear_assumption "diff") THEN (DISCH_THEN apply_tac)) THEN (((use_arg_then "ltnW")(thm_tac (new_rewrite [] [])))) THEN (done_tac));
709 ];;
710
711 (* Lemma nth_derivative_sub_strong *)
712 let nth_derivative_sub_strong = section_proof ["i";"x"]
713 `interval_arith x int ==> i <= n ==>
714    ?s. real_open s /\ x IN s /\ 
715       !y. y IN s ==> nth_derivative i (\y. f y - g y) y = nth_derivative i f y - nth_derivative i g y`
716 [
717    ((((use_arg_then "dg") (disch_tac [])) THEN (clear_assumption "dg") THEN ((use_arg_then "df") (disch_tac [])) THEN (clear_assumption "df") THEN BETA_TAC) THEN (((repeat_tactic 1 9 (((use_arg_then "nth_diff_strong_int")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "nth_diff_strong")(thm_tac (new_rewrite [] [])))))) THEN (move ["df"]) THEN (move ["dg"]) THEN (move ["ineq"])));
718    ((((fun arg_tac -> (use_arg_then "df") (fun fst_arg -> (use_arg_then "ineq") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC THEN (case THEN (move ["sf"])) THEN (case THEN (move ["open_sf"])) THEN (case THEN (move ["xsf"]))) THEN (((use_arg_then "df") (disch_tac [])) THEN (clear_assumption "df") THEN BETA_TAC THEN (move ["_"])));
719    ((((fun arg_tac -> (use_arg_then "dg") (fun fst_arg -> (use_arg_then "ineq") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC THEN (case THEN (move ["sg"])) THEN (case THEN (move ["open_sg"])) THEN (case THEN (move ["xsg"]))) THEN (((use_arg_then "dg") (disch_tac [])) THEN (clear_assumption "dg") THEN BETA_TAC THEN (move ["_"])));
720    (((repeat_tactic 1 9 (((use_arg_then "nth_differentiable_on")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "nth_differentiable_eq")(thm_tac (new_rewrite [] [])))))) THEN (move ["diff_g"]) THEN (move ["diff_f"]));
721    ((THENL_FIRST) ((THENL) (((use_arg_then "i") (disch_tac [])) THEN (clear_assumption "i") THEN elim) [(move ["_"]); ((move ["i"]) THEN (move ["IHi"]))]) ((repeat_tactic 1 9 (((use_arg_then "nth_derivative0")(thm_tac (new_rewrite [] []))))) THEN ((use_arg_then "sf") (term_tac exists_tac)) THEN (done_tac)));
722    (((((use_arg_then "nth_derivativeS")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "ltE")(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (move ["i_lt_n"]));
723    ((((fun arg_tac -> (use_arg_then "IHi") (fun fst_arg -> (fun arg_tac -> (use_arg_then "ltnW") (fun fst_arg -> (use_arg_then "i_lt_n") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC THEN (case THEN (move ["t"])) THEN (case THEN (move ["open_t"])) THEN (case THEN (move ["xt"])) THEN (move ["eq"])) THEN (((use_arg_then "IHi") (disch_tac [])) THEN (clear_assumption "IHi") THEN BETA_TAC THEN (move ["_"])));
724    ((fun arg_tac -> arg_tac (Arg_term (`sf INTER sg INTER t`))) (term_tac exists_tac));
725    (((repeat_tactic 1 9 (((use_arg_then "REAL_OPEN_INTER")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (repeat_tactic 1 9 (((use_arg_then "IN_INTER")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "xt")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "xsf")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "xsg")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))))) THEN (move ["y"]) THEN (case THEN (move ["ysf"])) THEN (case THEN ((move ["ysg"]) THEN (move ["yt"]))));
726    (((use_arg_then "derivative_unique") (disch_tac [])) THEN (clear_assumption "derivative_unique") THEN (DISCH_THEN apply_tac));
727    (((use_arg_then "HAS_REAL_DERIVATIVE_LOCAL") (disch_tac [])) THEN (clear_assumption "HAS_REAL_DERIVATIVE_LOCAL") THEN (DISCH_THEN apply_tac));
728    ((fun arg_tac -> arg_tac (Arg_term (`(\y. nth_derivative i f y - nth_derivative i g y)`))) (term_tac exists_tac));
729    ((((use_arg_then "HAS_REAL_DERIVATIVE_SUB")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))));
730    ((((use_arg_then "ETA_AX")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN ((((fun arg_tac -> (use_arg_then "diff_f") (fun fst_arg -> (use_arg_then "ysf") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((fun arg_tac -> (use_arg_then "diff_g") (fun fst_arg -> (use_arg_then "ysg") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] []))))) THEN (done_tac));
731    (((fun arg_tac -> arg_tac (Arg_term (`sf INTER sg INTER t`))) (term_tac exists_tac)) THEN ((repeat_tactic 1 9 (((use_arg_then "REAL_OPEN_INTER")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (repeat_tactic 1 9 (((use_arg_then "IN_INTER")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "yt")(thm_tac (new_rewrite [1] [])))) THEN (((use_arg_then "ysf")(thm_tac (new_rewrite [1] [])))) THEN (((use_arg_then "ysg")(thm_tac (new_rewrite [1] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))))));
732    ((BETA_TAC THEN (move ["z"]) THEN (move ["z_in"]) THEN (simp_tac)) THEN (((use_arg_then "eq")(thm_tac (new_rewrite [] [])))) THEN (done_tac));
733 ];;
734
735 (* Lemma nth_derivative_sub_strong_all *)
736 let nth_derivative_sub_strong_all = section_proof ["x"]
737 `interval_arith x int ==>
738         ?s. real_open s /\ x IN s /\ 
739         !i y. i <= n /\ y IN s ==> 
740                 nth_derivative i (\y. f y - g y) y = nth_derivative i f y - nth_derivative i g y`
741 [
742    (BETA_TAC THEN (DISCH_THEN (fun snd_th -> (use_arg_then "nth_derivative_sub_strong") (thm_tac (match_mp_then snd_th MP_TAC)))) THEN (move ["h"]));
743    ((fun arg_tac -> arg_tac (Arg_term (`\i s. real_open s /\ x IN s /\ 
744    (!y. y IN s ==> nth_derivative i (\y. f y - g y) y = nth_derivative i f y - nth_derivative i g y)`))) (term_tac (set_tac "P")));
745    ((fun arg_tac -> arg_tac (Arg_term (`!i. i <= n:num ==> P i ((@) (P i))`))) (term_tac (have_gen_tac [](move ["sel_P"]))));
746    ((BETA_TAC THEN (move ["i"]) THEN (move ["i_le_n"])) THEN ((use_arg_then "SELECT_AX") (thm_tac apply_tac)));
747    (((fun arg_tac -> (use_arg_then "h") (fun fst_arg -> (use_arg_then "i_le_n") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC THEN (case THEN (move ["s"])) THEN (move ["cond"]));
748    (((use_arg_then "s") (term_tac exists_tac)) THEN ((((use_arg_then "P_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (simp_tac)) THEN (done_tac));
749    ((fun arg_tac -> arg_tac (Arg_term (`INTERS (IMAGE (\i. (@) (P i)) (0..n))`))) (term_tac (set_tac "S")));
750    ((use_arg_then "S") (term_tac exists_tac));
751    ((((use_arg_then "S_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "REAL_OPEN_INTERS")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "FINITE_IMAGE")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "FINITE_NUMSEG")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "IN_IMAGE")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))));
752    ((BETA_TAC THEN (move ["t"]) THEN (case THEN (move ["i"])) THEN (case THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] [])))))) THEN ((((use_arg_then "IN_NUMSEG_0")(thm_tac (new_rewrite [] [])))) THEN (DISCH_THEN (fun snd_th -> (use_arg_then "sel_P") (thm_tac (match_mp_then snd_th MP_TAC))))));
753    (((((use_arg_then "P_def")(gsym_then (thm_tac (new_rewrite [1] []))))) THEN (simp_tac)) THEN (done_tac));
754    (((repeat_tactic 1 9 (((use_arg_then "IN_INTERS")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "IN_IMAGE")(thm_tac (new_rewrite [] [])))))) THEN (split_tac));
755    ((BETA_TAC THEN (move ["t"]) THEN (case THEN (move ["i"])) THEN (case THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] [])))))) THEN ((((use_arg_then "IN_NUMSEG_0")(thm_tac (new_rewrite [] [])))) THEN (DISCH_THEN (fun snd_th -> (use_arg_then "sel_P") (thm_tac (match_mp_then snd_th MP_TAC))))));
756    (((((use_arg_then "P_def")(gsym_then (thm_tac (new_rewrite [1] []))))) THEN (simp_tac)) THEN (done_tac));
757    (BETA_TAC THEN (move ["i"]) THEN (move ["y"]) THEN (case THEN (move ["i_le_n"])));
758    ((((fun arg_tac -> (use_arg_then "sel_P") (fun fst_arg -> (use_arg_then "i_le_n") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC) THEN (((((use_arg_then "P_def")(gsym_then (thm_tac (new_rewrite [1] []))))) THEN (simp_tac)) THEN ALL_TAC THEN (case THEN (move ["_"])) THEN (case THEN (move ["_"])) THEN (move ["y_in"]) THEN ((fun arg_tac ->  (conv_thm_tac DISCH_THEN)  (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`(@) (P i)`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (thm_tac MP_TAC))));
759    ((THENL_FIRST) (ANTS_TAC) (((use_arg_then "i") (term_tac exists_tac)) THEN (((use_arg_then "IN_NUMSEG_0")(thm_tac (new_rewrite [] [])))) THEN (done_tac)));
760    (((use_arg_then "y_in") (disch_tac [])) THEN (clear_assumption "y_in") THEN (exact_tac));
761 ];;
762
763 (* Lemma nth_derivative_sub *)
764 let nth_derivative_sub = section_proof ["i";"x"]
765 `interval_arith x int ==> i <= n ==>
766         nth_derivative i (\x. f x - g x) x = nth_derivative i f x - nth_derivative i g x`
767 [
768    (BETA_TAC THEN (move ["ineq"]) THEN (move ["i_le_n"]));
769    ((fun arg_tac -> (fun arg_tac -> (use_arg_then "nth_derivative_sub_strong") (fun fst_arg -> (use_arg_then "ineq") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "i_le_n") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun arg -> thm_tac MP_TAC arg THEN ALL_TAC));
770    (BETA_TAC THEN (case THEN (move ["s"])) THEN (case THEN (move ["_"])) THEN (case THEN (move ["xs"])) THEN (move ["h"]));
771    (((use_arg_then "h") (disch_tac [])) THEN (clear_assumption "h") THEN (exact_tac));
772 ];;
773
774 (* Lemma nth_diff_sub *)
775 let nth_diff_sub = section_proof []
776 `nth_diff_strong_int n int (\x. f x - g x)`
777 [
778    (((use_arg_then "dg") (disch_tac [])) THEN ((use_arg_then "df") (disch_tac [])) THEN BETA_TAC);
779    ((repeat_tactic 1 9 (((use_arg_then "nth_diff_strong_int")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "nth_diff_strong")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "nth_differentiable_on")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "nth_differentiable_eq")(thm_tac (new_rewrite [] []))))));
780    (BETA_TAC THEN (move ["df"]) THEN (move ["dg"]) THEN (move ["x"]) THEN (move ["ineq"]));
781    ((fun arg_tac -> (use_arg_then "nth_derivative_sub_strong_all") (fun fst_arg -> (use_arg_then "ineq") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun arg -> thm_tac MP_TAC arg THEN ALL_TAC));
782    (BETA_TAC THEN (case THEN (move ["s"])) THEN (case THEN (move ["open_s"])) THEN (case THEN (move ["xs"])) THEN (move ["diff"]));
783    (((fun arg_tac -> (use_arg_then "df") (fun fst_arg -> (use_arg_then "ineq") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC THEN (case THEN (move ["tf"])) THEN (case THEN (move ["open_tf"])) THEN (case THEN (move ["xtf"])) THEN (move ["diff_f"]));
784    (((fun arg_tac -> (use_arg_then "dg") (fun fst_arg -> (use_arg_then "ineq") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC THEN (case THEN (move ["tg"])) THEN (case THEN (move ["open_tg"])) THEN (case THEN (move ["xtg"])) THEN (move ["diff_g"]));
785    (((fun arg_tac -> arg_tac (Arg_term (`s INTER tf INTER tg`))) (term_tac exists_tac)) THEN ((repeat_tactic 1 9 (((use_arg_then "REAL_OPEN_INTER")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (repeat_tactic 1 9 (((use_arg_then "IN_INTER")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "xs")(thm_tac (new_rewrite [1] [])))) THEN (((use_arg_then "xtf")(thm_tac (new_rewrite [1] [])))) THEN (((use_arg_then "xtg")(thm_tac (new_rewrite [1] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))))));
786    (BETA_TAC THEN (move ["y"]) THEN (case THEN ((move ["ys"]) THEN (case THEN ((move ["ytf"]) THEN (move ["ytg"]))))));
787    (((((use_arg_then "REAL_CONTINUOUS_SUB")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "diff_f")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "diff_g")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))) THEN (move ["i"]) THEN (move ["i_lt_n"]));
788    ((((use_arg_then "diff")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "ys")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "ltE")(gsym_then (thm_tac (new_rewrite [] [])))))) THEN ((TRY done_tac)));
789    (((use_arg_then "HAS_REAL_DERIVATIVE_LOCAL") (disch_tac [])) THEN (clear_assumption "HAS_REAL_DERIVATIVE_LOCAL") THEN (DISCH_THEN apply_tac));
790    ((fun arg_tac -> arg_tac (Arg_term (`(\y. nth_derivative i f y - nth_derivative i g y)`))) (term_tac exists_tac));
791    ((THENL_FIRST) ((((use_arg_then "HAS_REAL_DERIVATIVE_SUB")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))))) ((((use_arg_then "ETA_AX")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN ((((fun arg_tac -> (use_arg_then "diff_f") (fun fst_arg -> (use_arg_then "ytf") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((fun arg_tac -> (use_arg_then "diff_g") (fun fst_arg -> (use_arg_then "ytg") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] []))))) THEN (done_tac)));
792    (((use_arg_then "s") (term_tac exists_tac)) THEN (((((use_arg_then "open_s")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "ys")(thm_tac (new_rewrite [1] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))))) THEN (move ["z"]) THEN (move ["zs"]) THEN (simp_tac)));
793    ((((use_arg_then "diff") (disch_tac [])) THEN (clear_assumption "diff") THEN (DISCH_THEN apply_tac)) THEN (((use_arg_then "ltnW")(thm_tac (new_rewrite [] [])))) THEN (done_tac));
794 ];;
795
796 (* Lemma nth_derivative_mul_strong *)
797 let nth_derivative_mul_strong = section_proof ["i";"x"]
798 `interval_arith x int ==> i <= n ==>
799    ?s. real_open s /\ x IN s /\ 
800       !y. y IN s ==> nth_derivative i (\y. f y * g y) y = 
801         sum (0..i) (\k. &(binom (i, k)) * nth_derivative k f y * nth_derivative (i - k) g y)`
802 [
803    ((((use_arg_then "dg") (disch_tac [])) THEN (clear_assumption "dg") THEN ((use_arg_then "df") (disch_tac [])) THEN (clear_assumption "df") THEN BETA_TAC) THEN (((repeat_tactic 1 9 (((use_arg_then "nth_diff_strong_int")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "nth_diff_strong")(thm_tac (new_rewrite [] [])))))) THEN (move ["df"]) THEN (move ["dg"]) THEN (move ["ineq"])));
804    ((((fun arg_tac -> (use_arg_then "df") (fun fst_arg -> (use_arg_then "ineq") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC THEN (case THEN (move ["sf"])) THEN (case THEN (move ["open_sf"])) THEN (case THEN (move ["xsf"]))) THEN (((use_arg_then "df") (disch_tac [])) THEN (clear_assumption "df") THEN BETA_TAC THEN (move ["_"])));
805    ((((fun arg_tac -> (use_arg_then "dg") (fun fst_arg -> (use_arg_then "ineq") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC THEN (case THEN (move ["sg"])) THEN (case THEN (move ["open_sg"])) THEN (case THEN (move ["xsg"]))) THEN (((use_arg_then "dg") (disch_tac [])) THEN (clear_assumption "dg") THEN BETA_TAC THEN (move ["_"])));
806    (((repeat_tactic 1 9 (((use_arg_then "nth_differentiable_on")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "nth_differentiable_eq")(thm_tac (new_rewrite [] [])))))) THEN (move ["diff_g"]) THEN (move ["diff_f"]));
807    ((THENL) (((use_arg_then "i") (disch_tac [])) THEN (clear_assumption "i") THEN elim) [(move ["_"]); ((move ["i"]) THEN (move ["IHi"]))]);
808    (((use_arg_then "sf") (term_tac exists_tac)) THEN (((((use_arg_then "open_sf")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "xsf")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "nth_derivative0")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "SUM_SING_NUMSEG")(thm_tac (new_rewrite [] []))))) THEN (move ["y"]) THEN (move ["_"]) THEN (simp_tac)));
809    (((((use_arg_then "subn0")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "nth_derivative0")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "binom")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_MUL_LID")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
810    (((((use_arg_then "nth_derivativeS")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "ltE")(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (move ["i_lt_n"]));
811    ((((fun arg_tac -> (use_arg_then "IHi") (fun fst_arg -> (fun arg_tac -> (use_arg_then "ltnW") (fun fst_arg -> (use_arg_then "i_lt_n") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC THEN (case THEN (move ["t"])) THEN (case THEN (move ["open_t"])) THEN (case THEN (move ["xt"])) THEN (move ["eq"])) THEN (((use_arg_then "IHi") (disch_tac [])) THEN (clear_assumption "IHi") THEN BETA_TAC THEN (move ["_"])));
812    ((fun arg_tac -> arg_tac (Arg_term (`sf INTER sg INTER t`))) (term_tac exists_tac));
813    (((repeat_tactic 1 9 (((use_arg_then "REAL_OPEN_INTER")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (repeat_tactic 1 9 (((use_arg_then "IN_INTER")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "xt")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "xsf")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "xsg")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))))) THEN (move ["y"]) THEN (case THEN (move ["ysf"])) THEN (case THEN ((move ["ysg"]) THEN (move ["yt"]))));
814    (((use_arg_then "derivative_unique") (disch_tac [])) THEN (clear_assumption "derivative_unique") THEN (DISCH_THEN apply_tac));
815    (((use_arg_then "HAS_REAL_DERIVATIVE_LOCAL") (disch_tac [])) THEN (clear_assumption "HAS_REAL_DERIVATIVE_LOCAL") THEN (DISCH_THEN apply_tac));
816    ((fun arg_tac -> arg_tac (Arg_term (`\y. sum (0..i) (\k. &(binom (i, k)) * nth_derivative k f y * nth_derivative (i - k) g y)`))) (term_tac exists_tac));
817    ((THENL_ROT (-1)) (split_tac));
818    (((fun arg_tac -> arg_tac (Arg_term (`sf INTER sg INTER t`))) (term_tac exists_tac)) THEN ((repeat_tactic 1 9 (((use_arg_then "REAL_OPEN_INTER")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (repeat_tactic 1 9 (((use_arg_then "IN_INTER")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "yt")(thm_tac (new_rewrite [1] [])))) THEN (((use_arg_then "ysf")(thm_tac (new_rewrite [1] [])))) THEN (((use_arg_then "ysg")(thm_tac (new_rewrite [1] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))))));
819    ((BETA_TAC THEN (move ["z"]) THEN (move ["z_in"]) THEN (simp_tac)) THEN (((use_arg_then "eq")(thm_tac (new_rewrite [] [])))) THEN (done_tac));
820    (((use_arg_then "has_derivative_lemma") (disch_tac [])) THEN (clear_assumption "has_derivative_lemma") THEN (DISCH_THEN apply_tac));
821    ((fun arg_tac -> arg_tac (Arg_term (`!k. k IN 0..i ==>
822         nth_derivative k f real_differentiable atreal y /\
823         nth_derivative (i - k) g real_differentiable atreal y`))) (term_tac (have_gen_tac [](move ["diff_cond"]))));
824    (((((use_arg_then "IN_NUMSEG")(thm_tac (new_rewrite [] [])))) THEN (move ["k"]) THEN (move ["ineq"]) THEN (simp_tac)) THEN (repeat_tactic 1 9 (((use_arg_then "real_differentiable")(thm_tac (new_rewrite [] []))))) THEN (split_tac));
825    (((fun arg_tac -> arg_tac (Arg_term (`nth_derivative (SUC k) f y`))) (term_tac exists_tac)) THEN (((fun arg_tac -> (use_arg_then "diff_f") (fun fst_arg -> (use_arg_then "ysf") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [])))));
826    ((((use_arg_then "i_lt_n") (disch_tac [])) THEN (clear_assumption "i_lt_n") THEN ((use_arg_then "ineq") (disch_tac [])) THEN (clear_assumption "ineq") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac));
827    (((fun arg_tac -> arg_tac (Arg_term (`nth_derivative (SUC (i - k)) g y`))) (term_tac exists_tac)) THEN (((fun arg_tac -> (use_arg_then "diff_g") (fun fst_arg -> (use_arg_then "ysg") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [])))));
828    ((((use_arg_then "i_lt_n") (disch_tac [])) THEN (clear_assumption "i_lt_n") THEN ((use_arg_then "ineq") (disch_tac [])) THEN (clear_assumption "ineq") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac));
829    ((fun arg_tac -> arg_tac (Arg_term (`!k. k IN 0..i ==> 
830         (\y. &(binom (i, k)) * nth_derivative k f y * nth_derivative (i - k) g y)
831                 real_differentiable atreal y`))) (term_tac (have_gen_tac [](move ["diff_cond2"]))));
832    (BETA_TAC THEN (move ["k"]) THEN (move ["k_in"]) THEN (simp_tac));
833    (((repeat_tactic 1 9 (((use_arg_then "REAL_DIFFERENTIABLE_MUL_ATREAL")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "REAL_DIFFERENTIABLE_CONST")(thm_tac (new_rewrite [] [])))))) THEN (((use_arg_then "ETA_AX")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN ((repeat_tactic 1 9 (((use_arg_then "diff_cond")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac))) THEN (done_tac));
834    (((((use_arg_then "differentiable_sum_numseg")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "derivative_sum_numseg")(thm_tac (new_rewrite [] [])))))) THEN ((simp_tac) THEN (((use_arg_then "diff_cond2")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN ((TRY done_tac))));
835    ((fun arg_tac -> arg_tac (Arg_term (`sum (0..i) _`))) (term_tac (set_tac "lhs")));
836    ((fun arg_tac -> arg_tac (Arg_term (`sum (0 + 1..i + 1) (\k. &(binom (i, k - 1)) * nth_derivative k f y * nth_derivative (SUC i - k) g y)`))) (term_tac (set_tac "sum1")));
837    ((fun arg_tac -> arg_tac (Arg_term (`sum (0..i + 1) (\k. &(binom (i, k)) * nth_derivative k f y * nth_derivative (SUC i - k) g y)`))) (term_tac (set_tac "sum2")));
838    ((fun arg_tac -> arg_tac (Arg_term (`lhs = sum1 + sum2`))) (term_tac (have_gen_tac [](((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] [])))))));
839    ((((use_arg_then "sum1_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "SUM_OFFSET")(thm_tac (new_rewrite [] [])))) THEN (simp_tac) THEN (((use_arg_then "addn1")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "succnK")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "subSS")(thm_tac (new_rewrite [] [])))));
840    ((((use_arg_then "sum2_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "addn1")(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL SUM_CLAUSES_NUMSEG)))(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> arg_tac (Arg_theorem (ARITH_RULE `0 <= SUC i`)))(thm_tac (new_rewrite [] [])))) THEN (simp_tac));
841    ((THENL_FIRST) ((fun arg_tac -> arg_tac (Arg_term (`binom(i, SUC i) = 0`))) (term_tac (have_gen_tac [](((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))))) ((((use_arg_then "BINOM_EQ_0")(thm_tac (new_rewrite [] [])))) THEN (arith_tac) THEN (done_tac)));
842    ((((use_arg_then "REAL_MUL_LZERO")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_ADD_RID")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "SUM_ADD_NUMSEG")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (((use_arg_then "lhs_def")(gsym_then (thm_tac (new_rewrite [] []))))));
843    (((use_arg_then "SUM_EQ") (thm_tac apply_tac)) THEN (move ["k"]) THEN (move ["k_in"]) THEN (simp_tac));
844    (((((use_arg_then "derivative_scale")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "REAL_DIFFERENTIABLE_MUL_ATREAL")(thm_tac (new_rewrite [] [])))))) THEN (((use_arg_then "ETA_AX")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN ((repeat_tactic 0 10 (((use_arg_then "diff_cond")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac))));
845    (((((use_arg_then "REAL_ADD_LDISTRIB")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "REAL_EQ_MUL_LCANCEL")(thm_tac (new_rewrite [] []))))) THEN (DISJ2_TAC));
846    ((((use_arg_then "derivative_mul")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "ETA_AX")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN ((repeat_tactic 0 10 (((use_arg_then "diff_cond")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac))));
847    ((((use_arg_then "REAL_ADD_SYM")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "nth_derivativeS")(gsym_then (thm_tac (new_rewrite [] [])))))));
848    ((THENL_FIRST) (((THENL_ROT 1)) ((fun arg_tac -> arg_tac (Arg_term (`SUC (i - k) = SUC i - k`))) (term_tac (have_gen_tac [](((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] [])))))))) ((done_tac) THEN (done_tac)));
849    ((((use_arg_then "k_in") (disch_tac [])) THEN (clear_assumption "k_in") THEN BETA_TAC) THEN (((use_arg_then "IN_NUMSEG")(thm_tac (new_rewrite [] [])))) THEN (arith_tac) THEN (done_tac));
850    (((((use_arg_then "REAL_ADD_SYM")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "SUM_CLAUSES_LEFT")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "sum2_def")(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (repeat_tactic 0 1 (((use_arg_then "SUM_CLAUSES_LEFT")(thm_tac (new_rewrite [] []))))) THEN (simp_tac)) THEN (TRY ((arith_tac))));
851    ((repeat_tactic 1 9 (((use_arg_then "binom")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "REAL_MUL_LID")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "REAL_ADD_ASSOC")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "REAL_EQ_ADD_LCANCEL")(thm_tac (new_rewrite [] [])))));
852    ((((use_arg_then "sum1_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "SUM_ADD_NUMSEG")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((fun arg_tac -> (use_arg_then "addn1") (fun fst_arg -> (use_arg_then "i") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [])))));
853    (((use_arg_then "SUM_EQ") (thm_tac apply_tac)) THEN (move ["k"]) THEN (move ["k_in"]) THEN (simp_tac));
854    (((((use_arg_then "REAL_ADD_RDISTRIB")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "REAL_EQ_MUL_RCANCEL")(thm_tac (new_rewrite [] []))))) THEN (DISJ1_TAC));
855    ((THENL_FIRST) (((THENL) (((use_arg_then "k_in") (disch_tac [])) THEN (clear_assumption "k_in") THEN ((use_arg_then "k") (disch_tac [])) THEN (clear_assumption "k") THEN case) [ALL_TAC; (move ["k"])]) THEN (((use_arg_then "IN_NUMSEG")(thm_tac (new_rewrite [] []))))) ((arith_tac) THEN (done_tac)));
856    (((((use_arg_then "binom")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "ONE")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "subSS")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "subn0")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_OF_NUM_ADD")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
857 ];;
858
859 (* Lemma nth_derivative_mul_strong_all *)
860 let nth_derivative_mul_strong_all = section_proof ["x"]
861 `interval_arith x int ==>
862         ?s. real_open s /\ x IN s /\ 
863         !i y. i <= n /\ y IN s ==> 
864           nth_derivative i (\y. f y * g y) y = 
865                 sum (0..i) (\k. &(binom (i, k)) * nth_derivative k f y * nth_derivative (i - k) g y)`
866 [
867    (BETA_TAC THEN (DISCH_THEN (fun snd_th -> (use_arg_then "nth_derivative_mul_strong") (thm_tac (match_mp_then snd_th MP_TAC)))) THEN (move ["h"]));
868    ((fun arg_tac -> arg_tac (Arg_term (`\i s. real_open s /\ x IN s /\ 
869    (!y. y IN s ==> nth_derivative i (\y. f y * g y) y = 
870         sum (0..i) (\k. &(binom (i, k)) * nth_derivative k f y * nth_derivative (i - k) g y))`))) (term_tac (set_tac "P")));
871    ((fun arg_tac -> arg_tac (Arg_term (`!i. i <= n:num ==> P i ((@) (P i))`))) (term_tac (have_gen_tac [](move ["sel_P"]))));
872    ((BETA_TAC THEN (move ["i"]) THEN (move ["i_le_n"])) THEN ((use_arg_then "SELECT_AX") (thm_tac apply_tac)));
873    (((fun arg_tac -> (use_arg_then "h") (fun fst_arg -> (use_arg_then "i_le_n") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC THEN (case THEN (move ["s"])) THEN (move ["cond"]));
874    (((use_arg_then "s") (term_tac exists_tac)) THEN ((((use_arg_then "P_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (simp_tac)) THEN (done_tac));
875    ((fun arg_tac -> arg_tac (Arg_term (`INTERS (IMAGE (\i. (@) (P i)) (0..n))`))) (term_tac (set_tac "S")));
876    ((use_arg_then "S") (term_tac exists_tac));
877    ((((use_arg_then "S_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "REAL_OPEN_INTERS")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "FINITE_IMAGE")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "FINITE_NUMSEG")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "IN_IMAGE")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))));
878    ((BETA_TAC THEN (move ["t"]) THEN (case THEN (move ["i"])) THEN (case THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] [])))))) THEN ((((use_arg_then "IN_NUMSEG_0")(thm_tac (new_rewrite [] [])))) THEN (DISCH_THEN (fun snd_th -> (use_arg_then "sel_P") (thm_tac (match_mp_then snd_th MP_TAC))))));
879    (((((use_arg_then "P_def")(gsym_then (thm_tac (new_rewrite [1] []))))) THEN (simp_tac)) THEN (done_tac));
880    (((repeat_tactic 1 9 (((use_arg_then "IN_INTERS")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "IN_IMAGE")(thm_tac (new_rewrite [] [])))))) THEN (split_tac));
881    ((BETA_TAC THEN (move ["t"]) THEN (case THEN (move ["i"])) THEN (case THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] [])))))) THEN ((((use_arg_then "IN_NUMSEG_0")(thm_tac (new_rewrite [] [])))) THEN (DISCH_THEN (fun snd_th -> (use_arg_then "sel_P") (thm_tac (match_mp_then snd_th MP_TAC))))));
882    (((((use_arg_then "P_def")(gsym_then (thm_tac (new_rewrite [1] []))))) THEN (simp_tac)) THEN (done_tac));
883    (BETA_TAC THEN (move ["i"]) THEN (move ["y"]) THEN (case THEN (move ["i_le_n"])));
884    ((((fun arg_tac -> (use_arg_then "sel_P") (fun fst_arg -> (use_arg_then "i_le_n") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC) THEN (((((use_arg_then "P_def")(gsym_then (thm_tac (new_rewrite [1] []))))) THEN (simp_tac)) THEN ALL_TAC THEN (case THEN (move ["_"])) THEN (case THEN (move ["_"])) THEN (move ["y_in"]) THEN ((fun arg_tac ->  (conv_thm_tac DISCH_THEN)  (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`(@) (P i)`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (thm_tac MP_TAC))));
885    ((THENL_FIRST) (ANTS_TAC) (((use_arg_then "i") (term_tac exists_tac)) THEN (((use_arg_then "IN_NUMSEG_0")(thm_tac (new_rewrite [] [])))) THEN (done_tac)));
886    (((use_arg_then "y_in") (disch_tac [])) THEN (clear_assumption "y_in") THEN (exact_tac));
887 ];;
888
889 (* Lemma nth_derivative_mul *)
890 let nth_derivative_mul = section_proof ["i";"x"]
891 `interval_arith x int ==> i <= n ==>
892         nth_derivative i (\x. f x * g x) x = 
893           sum (0..i) (\k. &(binom (i, k)) * nth_derivative k f x * nth_derivative (i - k) g x)`
894 [
895    (BETA_TAC THEN (move ["ineq"]) THEN (move ["i_le_n"]));
896    ((fun arg_tac -> (fun arg_tac -> (use_arg_then "nth_derivative_mul_strong") (fun fst_arg -> (use_arg_then "ineq") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "i_le_n") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun arg -> thm_tac MP_TAC arg THEN ALL_TAC));
897    (BETA_TAC THEN (case THEN (move ["s"])) THEN (case THEN (move ["_"])) THEN (case THEN (move ["xs"])) THEN (move ["h"]));
898    (((use_arg_then "h") (disch_tac [])) THEN (clear_assumption "h") THEN (exact_tac));
899 ];;
900
901 (* Lemma nth_diff_mul *)
902 let nth_diff_mul = section_proof []
903 `nth_diff_strong_int n int (\x. f x * g x)`
904 [
905    (((use_arg_then "dg") (disch_tac [])) THEN ((use_arg_then "df") (disch_tac [])) THEN BETA_TAC);
906    ((repeat_tactic 1 9 (((use_arg_then "nth_diff_strong_int")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "nth_diff_strong")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "nth_differentiable_on")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "nth_differentiable_eq")(thm_tac (new_rewrite [] []))))));
907    (BETA_TAC THEN (move ["df"]) THEN (move ["dg"]) THEN (move ["x"]) THEN (move ["ineq"]));
908    ((fun arg_tac -> (use_arg_then "nth_derivative_mul_strong_all") (fun fst_arg -> (use_arg_then "ineq") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun arg -> thm_tac MP_TAC arg THEN ALL_TAC));
909    (BETA_TAC THEN (case THEN (move ["s"])) THEN (case THEN (move ["open_s"])) THEN (case THEN (move ["xs"])) THEN (move ["diff"]));
910    (((fun arg_tac -> (use_arg_then "df") (fun fst_arg -> (use_arg_then "ineq") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC THEN (case THEN (move ["tf"])) THEN (case THEN (move ["open_tf"])) THEN (case THEN (move ["xtf"])) THEN (move ["diff_f"]));
911    (((fun arg_tac -> (use_arg_then "dg") (fun fst_arg -> (use_arg_then "ineq") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC THEN (case THEN (move ["tg"])) THEN (case THEN (move ["open_tg"])) THEN (case THEN (move ["xtg"])) THEN (move ["diff_g"]));
912    (((fun arg_tac -> arg_tac (Arg_term (`s INTER tf INTER tg`))) (term_tac exists_tac)) THEN ((repeat_tactic 1 9 (((use_arg_then "REAL_OPEN_INTER")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (repeat_tactic 1 9 (((use_arg_then "IN_INTER")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "xs")(thm_tac (new_rewrite [1] [])))) THEN (((use_arg_then "xtf")(thm_tac (new_rewrite [1] [])))) THEN (((use_arg_then "xtg")(thm_tac (new_rewrite [1] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))))));
913    (BETA_TAC THEN (move ["y"]) THEN (case THEN ((move ["ys"]) THEN (case THEN ((move ["ytf"]) THEN (move ["ytg"]))))));
914    (((((use_arg_then "REAL_CONTINUOUS_MUL")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "diff_f")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "diff_g")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))) THEN (move ["i"]) THEN (move ["i_lt_n"]));
915    ((((use_arg_then "nth_derivativeS")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "has_derivative_alt")(thm_tac (new_rewrite [] [])))));
916    (((use_arg_then "differentiable_local") (disch_tac [])) THEN (clear_assumption "differentiable_local") THEN (DISCH_THEN apply_tac));
917    (((fun arg_tac -> arg_tac (Arg_term (`\y. sum (0..i) (\k. &(binom(i, k)) * nth_derivative k f y * nth_derivative (i - k) g y)`))) (term_tac exists_tac)) THEN ((use_arg_then "s") (term_tac exists_tac)));
918    ((THENL_LAST) (((((use_arg_then "open_s")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "ys")(thm_tac (new_rewrite [1] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))))) THEN (split_tac)) ((BETA_TAC THEN (move ["z"]) THEN (move ["zs"])) THEN ((((use_arg_then "diff")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "ltnW")(thm_tac (new_rewrite [] []))))) THEN (done_tac)));
919    (((((use_arg_then "differentiable_sum_numseg")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "IN_NUMSEG")(thm_tac (new_rewrite [] []))))) THEN (move ["k"]) THEN (move ["k_in"]) THEN (simp_tac));
920    (((repeat_tactic 1 9 (((use_arg_then "REAL_DIFFERENTIABLE_MUL_ATREAL")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "REAL_DIFFERENTIABLE_CONST")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac))) THEN (((use_arg_then "ETA_AX")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))));
921    ((repeat_tactic 1 9 (((use_arg_then "real_differentiable")(thm_tac (new_rewrite [] []))))) THEN (split_tac));
922    (((fun arg_tac -> arg_tac (Arg_term (`nth_derivative (SUC k) f y`))) (term_tac exists_tac)) THEN (((fun arg_tac -> (use_arg_then "diff_f") (fun fst_arg -> (use_arg_then "ytf") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [])))));
923    ((((use_arg_then "i_lt_n") (disch_tac [])) THEN (clear_assumption "i_lt_n") THEN ((use_arg_then "k_in") (disch_tac [])) THEN (clear_assumption "k_in") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac));
924    (((fun arg_tac -> arg_tac (Arg_term (`nth_derivative (SUC (i - k)) g y`))) (term_tac exists_tac)) THEN (((fun arg_tac -> (use_arg_then "diff_g") (fun fst_arg -> (use_arg_then "ytg") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [])))));
925    ((((use_arg_then "i_lt_n") (disch_tac [])) THEN (clear_assumption "i_lt_n") THEN ((use_arg_then "k_in") (disch_tac [])) THEN (clear_assumption "k_in") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac));
926 ];;
927
928 (* Finalization of the section NthDerivativeArith *)
929 let nth_derivative_scale_strong = finalize_theorem nth_derivative_scale_strong;;
930 let nth_derivative_scale_strong_all = finalize_theorem nth_derivative_scale_strong_all;;
931 let nth_derivative_scale = finalize_theorem nth_derivative_scale;;
932 let nth_diff_scale = finalize_theorem nth_diff_scale;;
933 let nth_derivative_add_strong = finalize_theorem nth_derivative_add_strong;;
934 let nth_derivative_add_strong_all = finalize_theorem nth_derivative_add_strong_all;;
935 let nth_derivative_add = finalize_theorem nth_derivative_add;;
936 let nth_diff_add = finalize_theorem nth_diff_add;;
937 let nth_derivative_sub_strong = finalize_theorem nth_derivative_sub_strong;;
938 let nth_derivative_sub_strong_all = finalize_theorem nth_derivative_sub_strong_all;;
939 let nth_derivative_sub = finalize_theorem nth_derivative_sub;;
940 let nth_diff_sub = finalize_theorem nth_diff_sub;;
941 let nth_derivative_mul_strong = finalize_theorem nth_derivative_mul_strong;;
942 let nth_derivative_mul_strong_all = finalize_theorem nth_derivative_mul_strong_all;;
943 let nth_derivative_mul = finalize_theorem nth_derivative_mul;;
944 let nth_diff_mul = finalize_theorem nth_diff_mul;;
945 end_section "NthDerivativeArith";;
946
947 (* Finalization of the section NthDerivatives *)
948 let has_derivative_cond = finalize_theorem has_derivative_cond;;
949 let has_derivative_alt = finalize_theorem has_derivative_alt;;
950 let derivative_unique = finalize_theorem derivative_unique;;
951 let derivative_unique_on = finalize_theorem derivative_unique_on;;
952 let has_derivative_lemma = finalize_theorem has_derivative_lemma;;
953 let nth_derivative0 = finalize_theorem nth_derivative0;;
954 let nth_derivativeS = finalize_theorem nth_derivativeS;;
955 let nth_Sderivative = finalize_theorem nth_Sderivative;;
956 let nth_derivative1 = finalize_theorem nth_derivative1;;
957 let nth_derivative2 = finalize_theorem nth_derivative2;;
958 let nth_derivative_add = finalize_theorem nth_derivative_add;;
959 let nth_diff_continuous = finalize_theorem nth_diff_continuous;;
960 let nth_differentiable_cond = finalize_theorem nth_differentiable_cond;;
961 let nth_differentiable_on_cond = finalize_theorem nth_differentiable_on_cond;;
962 let nth_differentiable_eq = finalize_theorem nth_differentiable_eq;;
963 let nth_differentiable_on_int2 = finalize_theorem nth_differentiable_on_int2;;
964 let nth_mth_diff = finalize_theorem nth_mth_diff;;
965 let nth_differentiable1 = finalize_theorem nth_differentiable1;;
966 let nth_diff_imp_diff = finalize_theorem nth_diff_imp_diff;;
967 let nth_derivative_continuous = finalize_theorem nth_derivative_continuous;;
968 let ith_derivative_differentiable = finalize_theorem ith_derivative_differentiable;;
969 let nth_diff_strong_imp_diff = finalize_theorem nth_diff_strong_imp_diff;;
970 let derivative_x = finalize_theorem derivative_x;;
971 let derivative_const = finalize_theorem derivative_const;;
972 let derivative_inv = finalize_theorem derivative_inv;;
973 let derivative_atn = finalize_theorem derivative_atn;;
974 let derivative_exp = finalize_theorem derivative_exp;;
975 let derivative_acs = finalize_theorem derivative_acs;;
976 let derivative_sqrt = finalize_theorem derivative_sqrt;;
977 let derivative_composition = finalize_theorem derivative_composition;;
978 let REAL_DIFFERENTIABLE_AT_INV = finalize_theorem REAL_DIFFERENTIABLE_AT_INV;;
979 let derivative_compose_atn = finalize_theorem derivative_compose_atn;;
980 let derivative_compose_exp = finalize_theorem derivative_compose_exp;;
981 let derivative_compose_inv = finalize_theorem derivative_compose_inv;;
982 let derivative_compose_sqrt = finalize_theorem derivative_compose_sqrt;;
983 let derivative_compose_acs = finalize_theorem derivative_compose_acs;;
984 let derivative_scale = finalize_theorem derivative_scale;;
985 let derivative_neg = finalize_theorem derivative_neg;;
986 let derivative_pow = finalize_theorem derivative_pow;;
987 let derivative_add = finalize_theorem derivative_add;;
988 let derivative_mul = finalize_theorem derivative_mul;;
989 let derivative_sub = finalize_theorem derivative_sub;;
990 let derivative_div = finalize_theorem derivative_div;;
991 let differentiable_sum_numseg = finalize_theorem differentiable_sum_numseg;;
992 let derivative_sum_numseg = finalize_theorem derivative_sum_numseg;;
993 let HAS_REAL_DERIVATIVE_LOCAL = finalize_theorem HAS_REAL_DERIVATIVE_LOCAL;;
994 let differentiable_local = finalize_theorem differentiable_local;;
995 let nth_derivative_scale_strong = finalize_theorem nth_derivative_scale_strong;;
996 let nth_derivative_scale_strong_all = finalize_theorem nth_derivative_scale_strong_all;;
997 let nth_derivative_scale = finalize_theorem nth_derivative_scale;;
998 let nth_diff_scale = finalize_theorem nth_diff_scale;;
999 let nth_derivative_add_strong = finalize_theorem nth_derivative_add_strong;;
1000 let nth_derivative_add_strong_all = finalize_theorem nth_derivative_add_strong_all;;
1001 let nth_derivative_add = finalize_theorem nth_derivative_add;;
1002 let nth_diff_add = finalize_theorem nth_diff_add;;
1003 let nth_derivative_sub_strong = finalize_theorem nth_derivative_sub_strong;;
1004 let nth_derivative_sub_strong_all = finalize_theorem nth_derivative_sub_strong_all;;
1005 let nth_derivative_sub = finalize_theorem nth_derivative_sub;;
1006 let nth_diff_sub = finalize_theorem nth_diff_sub;;
1007 let nth_derivative_mul_strong = finalize_theorem nth_derivative_mul_strong;;
1008 let nth_derivative_mul_strong_all = finalize_theorem nth_derivative_mul_strong_all;;
1009 let nth_derivative_mul = finalize_theorem nth_derivative_mul;;
1010 let nth_diff_mul = finalize_theorem nth_diff_mul;;
1011 end_section "NthDerivatives";;
1012 let lin_approx = new_definition `lin_approx f x f_bounds df_bounds <=> 
1013         interval_arith (f x) f_bounds /\
1014         (?f'. (f has_real_derivative f') (atreal x) /\ interval_arith f' df_bounds)`;;
1015 let has_bounded_second_derivative = new_definition `has_bounded_second_derivative f int dd_bounds <=>
1016         nth_diff_strong_int 2 int f /\ 
1017         bounded_on_int (nth_derivative 2 f) int dd_bounds`;;
1018 let taylor_interval = new_definition 
1019   `taylor_interval f x y z w f_bounds df_bounds ddf_bounds <=>
1020         x <= y /\ y <= z /\ y - x <= w /\ z - y <= w /\
1021         lin_approx f y f_bounds df_bounds /\
1022         has_bounded_second_derivative f (x, z) ddf_bounds`;;
1023
1024 (* Lemma nth_diff_strong_imp_diff_int *)
1025 let nth_diff_strong_imp_diff_int = section_proof ["n";"int";"f"]
1026 `nth_diff_strong_int n int f ==>
1027         nth_differentiable_on_int n int f`
1028 [
1029    ((((use_arg_then "nth_diff_strong_int")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "nth_differentiable_on_int")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "nth_diff_strong")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "nth_differentiable_on")(thm_tac (new_rewrite [] [])))));
1030    (BETA_TAC THEN (move ["h"]) THEN (move ["x"]) THEN (move ["ineq"]));
1031    ((((fun arg_tac -> (use_arg_then "h") (fun fst_arg -> (use_arg_then "ineq") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC THEN (case THEN (move ["s"])) THEN (case THEN (move ["_"])) THEN (case THEN (move ["xs"]))) THEN (exact_tac) THEN (done_tac));
1032 ];;
1033
1034 (* Lemma has_bounded_second_derivative_old *)
1035 let has_bounded_second_derivative_old = section_proof ["f";"int";"dd_bounds"]
1036 `has_bounded_second_derivative f int dd_bounds ==>
1037         ?f' f''. (!x. interval_arith x int ==> (f has_real_derivative f' x) (atreal x) /\
1038                 (f' has_real_derivative f'' x) (atreal x) /\    interval_arith (f'' x) dd_bounds)`
1039 [
1040    ((((use_arg_then "has_bounded_second_derivative")(thm_tac (new_rewrite [] [])))) THEN ALL_TAC THEN (case THEN (DISCH_THEN (fun snd_th -> (use_arg_then "nth_diff_strong_imp_diff_int") (thm_tac (match_mp_then snd_th MP_TAC))))));
1041    ((DISCH_THEN (fun snd_th -> (use_arg_then "nth_differentiable_on_int2") (thm_tac (match_mp_then snd_th MP_TAC)))) THEN BETA_TAC THEN (case THEN (move ["f'"])) THEN (case THEN (move ["f''"])));
1042    ((BETA_TAC THEN (case THEN (move ["eq1"])) THEN (case THEN (move ["eq2"])) THEN (move ["h"]) THEN (move ["b"])) THEN ((((use_arg_then "f'") (term_tac exists_tac)) THEN ((use_arg_then "f''") (term_tac exists_tac))) THEN (move ["x"]) THEN (move ["ineq"])));
1043    ((((use_arg_then "b") (disch_tac [])) THEN (clear_assumption "b") THEN BETA_TAC) THEN (((((use_arg_then "bounded_on_int")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "eq2")(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (move ["b"])));
1044    (((repeat_tactic 1 9 (((use_arg_then "h")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((use_arg_then "b")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
1045 ];;
1046
1047 (* Lemma exists_and_left *)
1048 let exists_and_left = section_proof ["P";"Q"]
1049 `(?x. P x /\ Q x) ==> (?x. P x)`
1050 [
1051    (BETA_TAC THEN (case THEN (move ["x"])) THEN (case THEN ((move ["Px"]) THEN (move ["_"]))));
1052    (((use_arg_then "x") (term_tac exists_tac)) THEN (done_tac));
1053 ];;
1054
1055 (* Lemma lim_ineq *)
1056 let lim_ineq = section_proof ["a";"b"]
1057 `(!e. &0 < e ==> a <= b + e) <=> (a <= b)`
1058 [
1059    ((THENL_ROT (-1)) ((THENL) (split_tac) [ALL_TAC; ((move ["ineq"]) THEN (move ["e"]) THEN (move ["e0"]))]));
1060    (((((fun arg_tac -> (use_arg_then "REAL_ADD_RID") (fun fst_arg -> (use_arg_then "a") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "REAL_LE_ADD2")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "ineq")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_LT_IMP_LE")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
1061    ((((use_arg_then "contraLR") (disch_tac [])) THEN (clear_assumption "contraLR") THEN (DISCH_THEN apply_tac)) THEN (((((use_arg_then "NOT_FORALL_THM")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "NOT_IMP")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "REAL_NOT_LE")(thm_tac (new_rewrite [] [])))))) THEN (move ["ba"])));
1062    (((fun arg_tac -> arg_tac (Arg_term (`(a - b) / &2`))) (term_tac exists_tac)) THEN (((use_arg_then "ba") (disch_tac [])) THEN (clear_assumption "ba") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac));
1063 ];;
1064
1065 (* Lemma continuous_leq *)
1066 let continuous_leq = section_proof ["f";"c";"a"]
1067 `(?b. a < b /\ !x. x IN real_interval (a, b) ==> f x <= c) /\
1068         f real_continuous atreal a ==> f a <= c`
1069 [
1070    (BETA_TAC THEN (case THEN ((case THEN (move ["b"])) THEN (case THEN (move ["ab"])) THEN (move ["ineq"]))));
1071    (((((use_arg_then "REAL_CONTINUOUS_ATREAL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REALLIM_ATREAL")(thm_tac (new_rewrite [] []))))) THEN (move ["f_cont"]));
1072    ((((use_arg_then "lim_ineq")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (move ["e"]) THEN (DISCH_THEN (fun snd_th -> (use_arg_then "f_cont") (thm_tac (match_mp_then snd_th MP_TAC)))) THEN (case THEN (move ["d"])) THEN (case THEN (move ["d0"])) THEN (move ["cond"]));
1073    ((fun arg_tac -> arg_tac (Arg_term (`a + min (b - a) d / &2`))) (term_tac (set_tac "r")));
1074    ((THENL_FIRST) ((((fun arg_tac -> (use_arg_then "cond") (fun fst_arg -> (use_arg_then "r") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC) THEN (ANTS_TAC)) ((((use_arg_then "ab") (disch_tac [])) THEN (clear_assumption "ab") THEN ((use_arg_then "d0") (disch_tac [])) THEN (clear_assumption "d0") THEN ((use_arg_then "r_def") (disch_tac [])) THEN (clear_assumption "r_def") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac)));
1075    ((THENL_LAST) ((((fun arg_tac -> (use_arg_then "ineq") (fun fst_arg -> (use_arg_then "r") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC) THEN (ANTS_TAC)) ((arith_tac) THEN (done_tac)));
1076    ((((use_arg_then "IN_REAL_INTERVAL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "ab") (disch_tac [])) THEN (clear_assumption "ab") THEN ((use_arg_then "d0") (disch_tac [])) THEN (clear_assumption "d0") THEN ((use_arg_then "r_def") (disch_tac [])) THEN (clear_assumption "r_def") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac));
1077 ];;
1078
1079 (* Lemma continuous_reflection *)
1080 let continuous_reflection = section_proof ["f";"x"]
1081 `f real_continuous atreal x <=>
1082         (\x. f (--x)) real_continuous atreal (--x)`
1083 [
1084    (((repeat_tactic 1 9 (((use_arg_then "REAL_CONTINUOUS_ATREAL")(thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (repeat_tactic 1 9 (((use_arg_then "REALLIM_ATREAL")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "REAL_NEG_NEG")(thm_tac (new_rewrite [] [])))) THEN (simp_tac)) THEN ((split_tac) THEN (move ["h"]) THEN (move ["e"]) THEN (move ["e0"])));
1085    (((fun arg_tac -> (use_arg_then "h") (fun fst_arg -> (use_arg_then "e0") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC THEN (case THEN (move ["d"])) THEN (case THEN (move ["d0"])) THEN (move ["cond"]));
1086    (((use_arg_then "d") (term_tac exists_tac)) THEN (((((use_arg_then "d0")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))) THEN (move ["y"]) THEN (move ["ineqs"])) THEN (((use_arg_then "cond") (disch_tac [])) THEN (clear_assumption "cond") THEN (DISCH_THEN apply_tac)));
1087    ((((use_arg_then "ineqs") (disch_tac [])) THEN (clear_assumption "ineqs") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac));
1088    (((fun arg_tac -> (use_arg_then "h") (fun fst_arg -> (use_arg_then "e0") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC THEN (case THEN (move ["d"])) THEN (case THEN (move ["d0"])) THEN (move ["cond"]));
1089    (((use_arg_then "d") (term_tac exists_tac)) THEN (((((use_arg_then "d0")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))) THEN (move ["y"]) THEN (move ["ineqs"])));
1090    ((((fun arg_tac -> (use_arg_then "cond") (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`--y`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC) THEN (((use_arg_then "REAL_NEG_NEG")(thm_tac (new_rewrite [] [])))) THEN (DISCH_THEN apply_tac) THEN (((use_arg_then "ineqs") (disch_tac [])) THEN (clear_assumption "ineqs") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac));
1091 ];;
1092
1093 (* Lemma continuous_leq_segment *)
1094 let continuous_leq_segment = section_proof ["f";"c";"a";"b"]
1095 `a < b ==> f real_continuous atreal a ==> f real_continuous atreal b ==>
1096         (!x. x IN real_interval (a, b) ==> f x <= c) ==>
1097         (!x. x IN real_interval [a, b] ==> f x <= c)`
1098 [
1099    (BETA_TAC THEN (move ["ab"]) THEN (move ["f_cont_a"]) THEN (move ["f_cont_b"]) THEN (move ["ineq"]) THEN (move ["x"]));
1100    ((((use_arg_then "IN_REAL_INTERVAL")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 2 0 (((fun arg_tac -> arg_tac (Arg_theorem (REAL_ARITH `!a b. a <= b <=> (a = b \/ a < b)`)))(thm_tac (new_rewrite [] []))))));
1101    (case THEN ((THENL) case [((((conv_thm_tac DISCH_THEN)(gsym_then (thm_tac (new_rewrite [] []))))) THEN (move ["_"])); (move ["ax"])]));
1102    ((((use_arg_then "continuous_leq") (disch_tac [])) THEN (clear_assumption "continuous_leq") THEN (DISCH_THEN apply_tac)) THEN ((((use_arg_then "f_cont_a")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andbT")(thm_tac (new_rewrite [] []))))) THEN ((use_arg_then "b") (term_tac exists_tac)) THEN (done_tac));
1103    ((THENL_LAST) ((THENL) case [(((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] [])))); (move ["xb"])]) ((((use_arg_then "ineq") (disch_tac [])) THEN (clear_assumption "ineq") THEN (DISCH_THEN apply_tac)) THEN (((use_arg_then "IN_REAL_INTERVAL")(thm_tac (new_rewrite [] [])))) THEN (done_tac)));
1104    ((fun arg_tac -> arg_tac (Arg_term (`\x. f (--x)`))) (term_tac (set_tac "g")));
1105    ((THENL_FIRST) ((fun arg_tac -> arg_tac (Arg_term (`!x. f x = g (--x)`))) (term_tac (have_gen_tac [](move ["fg"])))) (((((use_arg_then "g_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (((use_arg_then "REAL_NEG_NEG")(thm_tac (new_rewrite [] []))))) THEN (done_tac)));
1106    ((((use_arg_then "fg")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "continuous_leq") (disch_tac [])) THEN (clear_assumption "continuous_leq") THEN (DISCH_THEN apply_tac)) THEN (split_tac));
1107    (((fun arg_tac -> arg_tac (Arg_term (`--a`))) (term_tac exists_tac)) THEN (((((use_arg_then "REAL_LT_NEG")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "ab")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "IN_REAL_INTERVAL")(thm_tac (new_rewrite [] []))))) THEN (move ["y"])));
1108    ((((fun arg_tac -> (use_arg_then "ineq") (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`--y`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC) THEN ((((use_arg_then "IN_REAL_INTERVAL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "fg")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_NEG_NEG")(thm_tac (new_rewrite [] []))))) THEN (arith_tac) THEN (done_tac));
1109    (((((use_arg_then "g_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "continuous_reflection")(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (done_tac));
1110 ];;
1111
1112 (* Lemma pair_eq *)
1113 let pair_eq = section_proof ["p"]
1114 `p = (FST p, SND p)`
1115 [
1116    (done_tac);
1117 ];;
1118
1119 (* Section Taylor *)
1120 begin_section "Taylor";;
1121
1122 (* Lemma iabs_alt *)
1123 let iabs_alt = section_proof ["lo";"hi";"a"]
1124 `interval_arith a (lo, hi) ==> iabs (lo, hi) = max (abs lo) (abs hi)`
1125 [
1126    (((((use_arg_then "interval_arith")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "iabs")(thm_tac (new_rewrite [] []))))) THEN (arith_tac) THEN (done_tac));
1127 ];;
1128
1129 (* Lemma iabs_pos *)
1130 let iabs_pos = section_proof ["lo";"hi";"a"]
1131 `interval_arith a (lo, hi) ==> &0 <= iabs (lo, hi)`
1132 [
1133    (((((use_arg_then "interval_arith")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "iabs")(thm_tac (new_rewrite [] []))))) THEN (arith_tac) THEN (done_tac));
1134 ];;
1135 (add_section_var (mk_var ("f", (`:real -> real`))));;
1136 (add_section_var (mk_var ("x", (`:real`))); add_section_var (mk_var ("y", (`:real`))); add_section_var (mk_var ("z", (`:real`))); add_section_var (mk_var ("w", (`:real`))));;
1137 (add_section_var (mk_var ("f_bounds", (`:real#real`))); add_section_var (mk_var ("df_bounds", (`:real#real`))); add_section_var (mk_var ("ddf_bounds", (`:real#real`))));;
1138 (add_section_var (mk_var ("dd_bound", (`:real`))));;
1139 (add_section_hyp "dd_bound_eq" (`dd_bound = iabs ddf_bounds`));;
1140 (add_section_hyp "tif" (`taylor_interval f x y z w f_bounds df_bounds ddf_bounds`));;
1141
1142 (* Lemma f_continuous *)
1143 let f_continuous = section_proof []
1144 `!t. t IN real_interval [x, z] ==> f real_continuous atreal t`
1145 [
1146    (((((use_arg_then "IN_REAL_INTERVAL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "interval_arith")(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (move ["t"]) THEN (move ["t_in"]));
1147    (((use_arg_then "HAS_REAL_DERIVATIVE_IMP_CONTINUOUS_ATREAL") (disch_tac [])) THEN (clear_assumption "HAS_REAL_DERIVATIVE_IMP_CONTINUOUS_ATREAL") THEN (DISCH_THEN apply_tac));
1148    ((((use_arg_then "tif") (disch_tac [])) THEN (clear_assumption "tif") THEN BETA_TAC) THEN (((((use_arg_then "taylor_interval")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "andbA")(thm_tac (new_rewrite [] [])))))) THEN ALL_TAC THEN (case THEN (move ["_"])) THEN (DISCH_THEN (fun snd_th -> (use_arg_then "has_bounded_second_derivative_old") (thm_tac (match_mp_then snd_th MP_TAC))))));
1149    (BETA_TAC THEN (case THEN (move ["f'"])) THEN (case THEN (move ["f''"])) THEN (move ["df"]));
1150    (((fun arg_tac -> arg_tac (Arg_term (`f' t`))) (term_tac exists_tac)) THEN (((use_arg_then "df")(thm_tac (new_rewrite [] [])))) THEN (done_tac));
1151 ];;
1152
1153 (* Lemma taylor_error *)
1154 let taylor_error = section_proof ["t"]
1155 `x <= t /\ t <= z ==> 
1156         abs (f t - f y) <= w * iabs df_bounds + w * w * dd_bound / &2`
1157 [
1158    (BETA_TAC THEN (move ["t_ineqs"]));
1159    (((use_arg_then "tif") (fun arg -> thm_tac MP_TAC arg THEN ALL_TAC)) THEN (((((use_arg_then "taylor_interval")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "andbA")(thm_tac (new_rewrite [] [])))))) THEN ALL_TAC THEN (case THEN ALL_TAC) THEN (case THEN (move ["domain_ineqs"])) THEN (move ["lin_app"])));
1160    ((DISCH_THEN (fun snd_th -> (use_arg_then "has_bounded_second_derivative_old") (thm_tac (match_mp_then snd_th MP_TAC)))) THEN BETA_TAC THEN (case THEN (move ["f'"])) THEN (case THEN (move ["f''"])) THEN (move ["df"]));
1161    ((fun arg_tac -> arg_tac (Arg_term (`abs (t - y) <= w`))) (term_tac (have_gen_tac [](move ["abs_ty"]))));
1162    ((((use_arg_then "t_ineqs") (disch_tac [])) THEN (clear_assumption "t_ineqs") THEN ((use_arg_then "domain_ineqs") (disch_tac [])) THEN (clear_assumption "domain_ineqs") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac));
1163    ((THENL_FIRST) ((fun arg_tac -> arg_tac (Arg_term (`interval_arith y (x, z)`))) (term_tac (have_gen_tac [](move ["y_in"])))) ((((use_arg_then "interval_arith")(thm_tac (new_rewrite [] [])))) THEN (done_tac)));
1164    ((fun arg_tac -> arg_tac (Arg_term (`&0 <= dd_bound /\ !p. p IN real_interval [x, z] ==> abs (f'' p) <= dd_bound`))) (term_tac (have_gen_tac [](move ["dd_prop"]))));
1165    ((((use_arg_then "dd_bound_eq")(thm_tac (new_rewrite [] [])))) THEN (split_tac));
1166    ((((fun arg_tac -> (use_arg_then "df") (fun fst_arg -> (use_arg_then "y_in") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC) THEN ((((use_arg_then "pair_eq")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "interval_arith")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "iabs")(thm_tac (new_rewrite [] []))))) THEN (arith_tac) THEN (done_tac));
1167    (((((use_arg_then "IN_REAL_INTERVAL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "interval_arith")(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (BETA_TAC THEN (move ["p"]) THEN (DISCH_THEN (fun snd_th -> (use_arg_then "df") (thm_tac (match_mp_then snd_th MP_TAC))))) THEN ((((use_arg_then "pair_eq")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "interval_arith")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "iabs")(thm_tac (new_rewrite [] []))))) THEN (arith_tac) THEN (done_tac));
1168    (((THENL_ROT 1)) ((fun arg_tac -> arg_tac (Arg_term (`abs (f t - (f y + f' y * (t - y) pow 1)) <= dd_bound * abs (t - y) pow (1 + 1) / &2`))) (term_tac (have_gen_tac []ALL_TAC))));
1169    (((fun arg_tac -> arg_tac (Arg_term (`f' y * _`))) (term_tac (set_tac "b1"))) THEN (((fun arg_tac -> arg_tac (Arg_term (`dd_bound * _`))) (term_tac (set_tac "b2"))) THEN (move ["ineq1"])));
1170    ((((use_arg_then "REAL_LE_TRANS") (disch_tac [])) THEN (clear_assumption "REAL_LE_TRANS") THEN (DISCH_THEN apply_tac)) THEN ((fun arg_tac -> arg_tac (Arg_term (`abs (f t - (f y + b1)) + abs b1`))) (term_tac exists_tac)) THEN (split_tac));
1171    (((((fun arg_tac -> arg_tac (Arg_theorem (REAL_ARITH `!a b. a - b = (a - (b + b1)) + b1`)))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_ABS_TRIANGLE")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
1172    ((((use_arg_then "REAL_ADD_SYM")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_LE_ADD2")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "b1_def")(gsym_then (thm_tac (new_rewrite [1] []))))) THEN (((use_arg_then "REAL_POW_1")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_ABS_MUL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_MUL_SYM")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_LE_MUL2")(thm_tac (new_rewrite [] [])))));
1173    ((repeat_tactic 1 9 (((use_arg_then "REAL_ABS_POS")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "abs_ty")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "pair_eq")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "iabs")(thm_tac (new_rewrite [] [])))));
1174    ((((use_arg_then "lin_app") (disch_tac [])) THEN (clear_assumption "lin_app") THEN BETA_TAC) THEN ((((use_arg_then "lin_approx")(thm_tac (new_rewrite [] [])))) THEN ALL_TAC THEN (case THEN (move ["_"])) THEN (case THEN (move ["ff"])) THEN (case THEN (move ["df'"]))));
1175    ((THENL_FIRST) (((THENL_ROT 1)) ((fun arg_tac -> arg_tac (Arg_term (`ff = f' y`))) (term_tac (have_gen_tac [](((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] [])))))))) (((((use_arg_then "pair_eq")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "interval_arith")(thm_tac (new_rewrite [] []))))) THEN (arith_tac) THEN (done_tac)));
1176    ((((fun arg_tac -> (fun arg_tac -> (use_arg_then "REAL_DERIVATIVE_UNIQUE_ATREAL") (fun fst_arg -> (use_arg_then "f") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "y") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN (DISCH_THEN apply_tac)) THEN ((((use_arg_then "df'")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "df")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "IN_REAL_INTERVAL")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
1177    ((((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_LE_TRANS") (disch_tac [])) THEN (clear_assumption "REAL_LE_TRANS") THEN (DISCH_THEN apply_tac)) THEN ((use_arg_then "b2") (term_tac exists_tac)));
1178    ((((use_arg_then "ineq1")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "b2_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "real_div")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "REAL_MUL_ASSOC")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "REAL_LE_MUL2")(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> arg_tac (Arg_theorem (ARITH_RULE `1 + 1 = 2`)))(thm_tac (new_rewrite [] [])))));
1179    (((((use_arg_then "REAL_LE_REFL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_LE_INV")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "REAL_LE_MUL")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "dd_prop")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "REAL_LE_POW_2")(thm_tac (new_rewrite [] [])))))) THEN (TRY ((arith_tac))));
1180    ((((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "andbT")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "REAL_MUL_SYM")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_POW_2")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "REAL_LE_MUL2")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_LE_REFL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "dd_prop")(thm_tac (new_rewrite [] [])))));
1181    (((((use_arg_then "REAL_LE_POW_2")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "andbT")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "REAL_LE_SQUARE_ABS")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "REAL_ABS_ABS")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "abs_ty") (disch_tac [])) THEN (clear_assumption "abs_ty") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac));
1182    ((fun arg_tac -> arg_tac (Arg_term (`\i. if i = 0 then f else if i = 1 then f' else if i = 2 then f'' else I`))) (term_tac (set_tac "Df")));
1183    ((fun arg_tac -> arg_tac (Arg_theorem (ARITH_RULE `0 + 1 = 1 /\ ~(1 = 0) /\ 1 + 1 = 2 /\ 
1184         ~(2 = 1) /\ ~(2 = 1) /\ ~(2 = 0)`))) (fun arg -> thm_tac MP_TAC arg THEN (move ["arith"])));
1185    ((fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (use_arg_then "REAL_TAYLOR") (fun fst_arg -> (use_arg_then "Df") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`1`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`real_interval [x, z]`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "dd_bound") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun arg -> thm_tac MP_TAC arg THEN ALL_TAC));
1186    (ANTS_TAC);
1187    (((((use_arg_then "IS_REALINTERVAL_INTERVAL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))) THEN (split_tac));
1188    ((((use_arg_then "IN_REAL_INTERVAL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "interval_arith")(gsym_then (thm_tac (new_rewrite [] []))))));
1189    ((BETA_TAC THEN (move ["i"]) THEN (move ["p"]) THEN (case THEN (move ["p_in"]))) THEN (((fun arg_tac -> arg_tac (Arg_theorem (ARITH_RULE `i <= 1 <=> i = 0 \/ i = 1`)))(thm_tac (new_rewrite [] [])))));
1190    ((case THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))) THEN ((((use_arg_then "Df_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (simp_tac)) THEN ((use_arg_then "HAS_REAL_DERIVATIVE_ATREAL_WITHIN") (thm_tac apply_tac)) THEN ((repeat_tactic 1 9 (((use_arg_then "arith")(thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (((use_arg_then "df")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
1191    ((BETA_TAC THEN (move ["p"]) THEN (move ["p_in"])) THEN ((((use_arg_then "Df_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (simp_tac)));
1192    (((repeat_tactic 1 9 (((use_arg_then "arith")(thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (((use_arg_then "dd_prop")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
1193    ((BETA_TAC THEN ((fun arg_tac -> (fun arg_tac ->  (conv_thm_tac DISCH_THEN)  (fun fst_arg -> (use_arg_then "y") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "t") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (thm_tac MP_TAC))) THEN ((repeat_tactic 1 9 (((use_arg_then "IN_REAL_INTERVAL")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "domain_ineqs")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "t_ineqs")(thm_tac (new_rewrite [] []))))) THEN (simp_tac)));
1194    ((((use_arg_then "ONE")(thm_tac (new_rewrite [1] [])))) THEN (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL SUM_CLAUSES_NUMSEG)))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "SUM_SING_NUMSEG")(thm_tac (new_rewrite [] [])))) THEN (simp_tac) THEN (((use_arg_then "Df_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (((use_arg_then "ONE")(gsym_then (thm_tac (new_rewrite [] []))))));
1195    ((repeat_tactic 1 9 (((fun arg_tac -> arg_tac (Arg_theorem (ARITH_RULE `0 <= 1 /\ ~(1 = 0)`)))(thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL real_pow)))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "FACT")(thm_tac (new_rewrite [] [])))));
1196    (((repeat_tactic 1 9 (((fun arg_tac -> arg_tac (Arg_theorem (ARITH_RULE `FACT 1 = 1 /\ FACT (1 + 1) = 2`)))(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "REAL_DIV_1")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "REAL_MUL_RID")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
1197 ];;
1198
1199 (* Lemma taylor_upper_bound *)
1200 let taylor_upper_bound = section_proof []
1201 `!t. x <= t /\ t <= z ==>
1202         f t <= SND f_bounds + (w * iabs df_bounds + w * w * dd_bound / &2)`
1203 [
1204    (((fun arg_tac -> (use_arg_then "pair_eq") (fun fst_arg -> (use_arg_then "f_bounds") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC THEN (move ["eq"]));
1205    (BETA_TAC THEN (move ["t"]) THEN (DISCH_THEN (fun snd_th -> (use_arg_then "taylor_error") (thm_tac (match_mp_then snd_th MP_TAC)))));
1206    ((((use_arg_then "tif") (disch_tac [])) THEN (clear_assumption "tif") THEN BETA_TAC) THEN (((((use_arg_then "taylor_interval")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "andbA")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "lin_approx")(thm_tac (new_rewrite [] []))))) THEN ALL_TAC THEN (case THEN ALL_TAC) THEN (case THEN (move ["_"])) THEN (case THEN (move ["f_int"])) THEN (move ["_"]) THEN (move ["_"])));
1207    ((((use_arg_then "f_int") (disch_tac [])) THEN (clear_assumption "f_int") THEN BETA_TAC) THEN ((((use_arg_then "eq")(thm_tac (new_rewrite [1] [])))) THEN (((use_arg_then "interval_arith")(thm_tac (new_rewrite [] []))))) THEN (arith_tac) THEN (done_tac));
1208 ];;
1209
1210 (* Lemma taylor_lower_bound *)
1211 let taylor_lower_bound = section_proof []
1212 `!t. x <= t /\ t <= z ==>
1213         FST f_bounds - (w * iabs df_bounds + w * w * dd_bound / &2) <= f t`
1214 [
1215    ((fun arg_tac -> (use_arg_then "pair_eq") (fun fst_arg -> (use_arg_then "f_bounds") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun arg -> thm_tac MP_TAC arg THEN (move ["eq"])));
1216    (BETA_TAC THEN (move ["t"]) THEN (DISCH_THEN (fun snd_th -> (use_arg_then "taylor_error") (thm_tac (match_mp_then snd_th MP_TAC)))));
1217    ((((use_arg_then "tif") (disch_tac [])) THEN (clear_assumption "tif") THEN BETA_TAC) THEN (((((use_arg_then "eq")(thm_tac (new_rewrite [1] [])))) THEN (((use_arg_then "taylor_interval")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "andbA")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "lin_approx")(thm_tac (new_rewrite [] []))))) THEN ALL_TAC THEN (case THEN ALL_TAC) THEN (case THEN (move ["_"])) THEN (case THEN (move ["f_int"])) THEN (move ["_"]) THEN (move ["_"])));
1218    ((((use_arg_then "f_int") (disch_tac [])) THEN (clear_assumption "f_int") THEN BETA_TAC) THEN (((use_arg_then "interval_arith")(thm_tac (new_rewrite [] [])))) THEN (arith_tac));
1219 ];;
1220
1221 (* Lemma taylor_derivative_error *)
1222 let taylor_derivative_error = section_proof []
1223 `!t. x <= t /\ t <= z ==> 
1224         abs (derivative f t - derivative f y) <= w * dd_bound`
1225 [
1226    (BETA_TAC THEN (move ["t"]) THEN (move ["t_ineqs"]));
1227    (((use_arg_then "tif") (fun arg -> thm_tac MP_TAC arg THEN ALL_TAC)) THEN (((((use_arg_then "taylor_interval")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "andbA")(thm_tac (new_rewrite [] [])))))) THEN ALL_TAC THEN (case THEN ALL_TAC) THEN (case THEN (move ["domain_ineqs"])) THEN (move ["_"])));
1228    ((DISCH_THEN (fun snd_th -> (use_arg_then "has_bounded_second_derivative_old") (thm_tac (match_mp_then snd_th MP_TAC)))) THEN BETA_TAC THEN (case THEN (move ["f'"])) THEN (case THEN (move ["f''"])) THEN (move ["df"]));
1229    ((fun arg_tac -> arg_tac (Arg_term (`abs (t - y) <= w`))) (term_tac (have_gen_tac [](move ["abs_ty"]))));
1230    ((((use_arg_then "t_ineqs") (disch_tac [])) THEN (clear_assumption "t_ineqs") THEN ((use_arg_then "domain_ineqs") (disch_tac [])) THEN (clear_assumption "domain_ineqs") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac));
1231    ((fun arg_tac -> arg_tac (Arg_term (`!p. x <= p /\ p <= z ==> derivative f p = f' p`))) (term_tac (have_gen_tac [](move ["der_eq"]))));
1232    (((((use_arg_then "IN_REAL_INTERVAL")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "EQ_SYM_EQ")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "derivative_unique_on") (disch_tac [])) THEN (clear_assumption "derivative_unique_on") THEN (DISCH_THEN apply_tac)));
1233    ((((((use_arg_then "IN_REAL_INTERVAL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "interval_arith")(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (move ["p"]) THEN (DISCH_THEN (fun snd_th -> (use_arg_then "df") (thm_tac (match_mp_then snd_th MP_TAC)))) THEN (simp_tac)) THEN (done_tac));
1234    ((repeat_tactic 1 9 (((use_arg_then "der_eq")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)));
1235    ((fun arg_tac -> arg_tac (Arg_term (`&0 <= dd_bound /\ !p. p IN real_interval [x, z] ==> abs (f'' p) <= dd_bound`))) (term_tac (have_gen_tac [](move ["dd_prop"]))));
1236    (((((use_arg_then "dd_bound_eq")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "IN_REAL_INTERVAL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "interval_arith")(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (split_tac));
1237    ((((fun arg_tac -> (use_arg_then "df") (fun fst_arg -> (use_arg_then "y") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC) THEN ((((fun arg_tac -> (use_arg_then "pair_eq") (fun fst_arg -> (use_arg_then "ddf_bounds") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "interval_arith")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "iabs")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "domain_ineqs")(thm_tac (new_rewrite [] [])))))) THEN (arith_tac) THEN (done_tac));
1238    ((BETA_TAC THEN (move ["p"]) THEN (DISCH_THEN (fun snd_th -> (use_arg_then "df") (thm_tac (match_mp_then snd_th MP_TAC))))) THEN ((((use_arg_then "pair_eq")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "interval_arith")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "iabs")(thm_tac (new_rewrite [] []))))) THEN (arith_tac) THEN (done_tac));
1239    ((fun arg_tac -> arg_tac (Arg_term (`\i. if i = 0 then f' else if i = 1 then f'' else I`))) (term_tac (set_tac "Df")));
1240    ((fun arg_tac -> arg_tac (Arg_theorem (ARITH_RULE `0 + 1 = 1 /\ ~(1 = 0) /\ 1 + 1 = 2 /\ 
1241         ~(2 = 1) /\ ~(2 = 1) /\ ~(2 = 0)`))) (fun arg -> thm_tac MP_TAC arg THEN (move ["arith"])));
1242    ((fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (use_arg_then "REAL_TAYLOR") (fun fst_arg -> (use_arg_then "Df") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`0`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`real_interval [x, z]`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "dd_bound") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun arg -> thm_tac MP_TAC arg THEN ALL_TAC));
1243    (ANTS_TAC);
1244    (((((use_arg_then "IS_REALINTERVAL_INTERVAL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))) THEN (split_tac));
1245    ((BETA_TAC THEN (move ["i"]) THEN (move ["p"]) THEN (case THEN (move ["p_in"]))) THEN ((((fun arg_tac -> arg_tac (Arg_theorem (ARITH_RULE `i <= 0 <=> i = 0`)))(thm_tac (new_rewrite [] [])))) THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))));
1246    (((((use_arg_then "Df_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (repeat_tactic 1 9 (((use_arg_then "arith")(thm_tac (new_rewrite [] []))))) THEN (simp_tac)) THEN (((use_arg_then "HAS_REAL_DERIVATIVE_ATREAL_WITHIN") (disch_tac [])) THEN (clear_assumption "HAS_REAL_DERIVATIVE_ATREAL_WITHIN") THEN (DISCH_THEN apply_tac)));
1247    (((((use_arg_then "df")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "interval_arith")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "IN_REAL_INTERVAL")(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (done_tac));
1248    ((BETA_TAC THEN (move ["p"]) THEN (move ["p_in"])) THEN ((((use_arg_then "Df_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (simp_tac)));
1249    (((repeat_tactic 1 9 (((use_arg_then "arith")(thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (((use_arg_then "dd_prop")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
1250    ((BETA_TAC THEN ((fun arg_tac -> (fun arg_tac ->  (conv_thm_tac DISCH_THEN)  (fun fst_arg -> (use_arg_then "y") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "t") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (thm_tac MP_TAC))) THEN ((repeat_tactic 1 9 (((use_arg_then "IN_REAL_INTERVAL")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "domain_ineqs")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "t_ineqs")(thm_tac (new_rewrite [] []))))) THEN (simp_tac)));
1251    ((((use_arg_then "ONE")(thm_tac (new_rewrite [1] [])))) THEN (((use_arg_then "SUM_SING_NUMSEG")(thm_tac (new_rewrite [] [])))) THEN (simp_tac) THEN (((use_arg_then "Df_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (((use_arg_then "ONE")(gsym_then (thm_tac (new_rewrite [] []))))));
1252    ((((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL real_pow)))(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "arith")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "FACT")(thm_tac (new_rewrite [] []))))) THEN (((fun arg_tac -> arg_tac (Arg_theorem (ARITH_RULE `FACT 1 = 1`)))(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "REAL_DIV_1")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "REAL_MUL_RID")(thm_tac (new_rewrite [] [])))));
1253    ((((use_arg_then "REAL_POW_1")(thm_tac (new_rewrite [] [])))) THEN (move ["ineq"]));
1254    ((((use_arg_then "REAL_LE_TRANS") (disch_tac [])) THEN (clear_assumption "REAL_LE_TRANS") THEN (DISCH_THEN apply_tac)) THEN ((fun arg_tac -> arg_tac (Arg_term (`dd_bound * abs (t - y)`))) (term_tac exists_tac)));
1255    (((((use_arg_then "ineq")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_MUL_SYM")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_LE_RMUL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "dd_prop")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "abs_ty")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
1256 ];;
1257
1258 (* Lemma derivative_interval *)
1259 let derivative_interval = section_proof []
1260 `FST df_bounds <= derivative f y /\ derivative f y <= SND df_bounds`
1261 [
1262    ((fun arg_tac -> (use_arg_then "pair_eq") (fun fst_arg -> (use_arg_then "df_bounds") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun arg -> thm_tac MP_TAC arg THEN (move ["eq"])));
1263    ((((use_arg_then "tif") (disch_tac [])) THEN (clear_assumption "tif") THEN BETA_TAC) THEN (((((use_arg_then "taylor_interval")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "lin_approx")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "andbA")(thm_tac (new_rewrite [] [])))))) THEN ALL_TAC THEN (case THEN ALL_TAC) THEN (case THEN (move ["ineqs"])) THEN (case THEN (move ["g"])) THEN (case THEN ((move ["fg"]) THEN (move ["g_int"]))) THEN (move ["_"])));
1264    ((THENL_FIRST) (((THENL_ROT 1)) ((fun arg_tac -> arg_tac (Arg_term (`derivative f y = g`))) (term_tac (have_gen_tac [](((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] [])))))))) ((((use_arg_then "g_int") (disch_tac [])) THEN (clear_assumption "g_int") THEN BETA_TAC) THEN ((((use_arg_then "eq")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "interval_arith")(thm_tac (new_rewrite [] []))))) THEN (done_tac)));
1265    (((fun arg_tac -> (fun arg_tac -> (use_arg_then "REAL_DERIVATIVE_UNIQUE_ATREAL") (fun fst_arg -> (use_arg_then "f") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "y") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN (DISCH_THEN apply_tac));
1266    (((((use_arg_then "fg")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "has_derivative_cond")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac))) THEN ((use_arg_then "g") (term_tac exists_tac)) THEN (done_tac));
1267 ];;
1268
1269 (* Lemma taylor_derivative_upper_bound *)
1270 let taylor_derivative_upper_bound = section_proof []
1271 `!t. x <= t /\ t <= z ==>
1272         derivative f t <= SND df_bounds + w * dd_bound`
1273 [
1274    ((BETA_TAC THEN (move ["t"]) THEN (DISCH_THEN (fun snd_th -> (use_arg_then "taylor_derivative_error") (thm_tac (match_mp_then snd_th MP_TAC))))) THEN (((use_arg_then "derivative_interval") (disch_tac [])) THEN (clear_assumption "derivative_interval") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac));
1275 ];;
1276
1277 (* Lemma taylor_derivative_lower_bound *)
1278 let taylor_derivative_lower_bound = section_proof []
1279 `!t. x <= t /\ t <= z ==>
1280         FST df_bounds - w * dd_bound <= derivative f t`
1281 [
1282    ((BETA_TAC THEN (move ["t"]) THEN (DISCH_THEN (fun snd_th -> (use_arg_then "taylor_derivative_error") (thm_tac (match_mp_then snd_th MP_TAC))))) THEN (((use_arg_then "derivative_interval") (disch_tac [])) THEN (clear_assumption "derivative_interval") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac));
1283 ];;
1284
1285 (* Finalization of the section Taylor *)
1286 let iabs_alt = finalize_theorem iabs_alt;;
1287 let iabs_pos = finalize_theorem iabs_pos;;
1288 let f_continuous = finalize_theorem f_continuous;;
1289 let taylor_error = finalize_theorem taylor_error;;
1290 let taylor_upper_bound = finalize_theorem taylor_upper_bound;;
1291 let taylor_lower_bound = finalize_theorem taylor_lower_bound;;
1292 let taylor_derivative_error = finalize_theorem taylor_derivative_error;;
1293 let derivative_interval = finalize_theorem derivative_interval;;
1294 let taylor_derivative_upper_bound = finalize_theorem taylor_derivative_upper_bound;;
1295 let taylor_derivative_lower_bound = finalize_theorem taylor_derivative_lower_bound;;
1296 end_section "Taylor";;
1297
1298 (* Section LinearApproximation *)
1299 begin_section "LinearApproximation";;
1300 (add_section_var (mk_var ("f", (`:real->real`))));;
1301 (add_section_var (mk_var ("f_bounds", (`:real#real`))); add_section_var (mk_var ("df_bounds", (`:real#real`))));;
1302 (add_section_var (mk_var ("x", (`:real`))));;
1303
1304 (* Lemma lin_approx_eq *)
1305 let lin_approx_eq = section_proof []
1306 `lin_approx f x f_bounds df_bounds <=>
1307         (f real_differentiable atreal x /\ interval_arith (f x) f_bounds /\
1308         interval_arith (derivative f x) df_bounds)`
1309 [
1310    (((((use_arg_then "lin_approx")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "real_differentiable")(thm_tac (new_rewrite [] []))))) THEN ((THENL) (split_tac) [(case THEN ((((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] [])))) THEN (case THEN (move ["f'"])) THEN (case THEN ((move ["df'"]) THEN (move ["int_f'"]))))); ((case THEN ((case THEN (move ["f'"])) THEN (move ["df"]))) THEN (case THEN ((((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] [])))) THEN (move ["df_int"]))))]));
1311    ((THENL_FIRST) (split_tac) (((use_arg_then "f'") (term_tac exists_tac)) THEN (done_tac)));
1312    ((((fun arg_tac -> (fun arg_tac -> (use_arg_then "derivative_unique") (fun fst_arg -> (use_arg_then "f") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "f'") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [])))) THEN (done_tac));
1313    ((((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))) THEN ((use_arg_then "f'") (term_tac exists_tac)) THEN ((((use_arg_then "df")(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (use_arg_then "derivative_unique") (fun fst_arg -> (use_arg_then "f") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "f'") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "x") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (done_tac));
1314 ];;
1315 (add_section_hyp "approx_f" (`lin_approx f x f_bounds df_bounds`));;
1316
1317 (* Lemma lin_approx_imp_f_interval *)
1318 let lin_approx_imp_f_interval = section_proof []
1319 `interval_arith (f x) f_bounds`
1320 [
1321    ((((use_arg_then "approx_f") (disch_tac [])) THEN (clear_assumption "approx_f") THEN BETA_TAC) THEN ((((use_arg_then "lin_approx_eq")(thm_tac (new_rewrite [] [])))) THEN (simp_tac)) THEN (done_tac));
1322 ];;
1323
1324 (* Lemma lin_approx_imp_df_interval *)
1325 let lin_approx_imp_df_interval = section_proof []
1326 `interval_arith (derivative f x) df_bounds`
1327 [
1328    ((((use_arg_then "approx_f") (disch_tac [])) THEN (clear_assumption "approx_f") THEN BETA_TAC) THEN ((((use_arg_then "lin_approx_eq")(thm_tac (new_rewrite [] [])))) THEN (simp_tac)) THEN (done_tac));
1329 ];;
1330
1331 (* Lemma lin_approx_imp_f_diff *)
1332 let lin_approx_imp_f_diff = section_proof []
1333 `f real_differentiable atreal x`
1334 [
1335    ((((use_arg_then "approx_f") (disch_tac [])) THEN (clear_assumption "approx_f") THEN BETA_TAC) THEN ((((use_arg_then "lin_approx_eq")(thm_tac (new_rewrite [] [])))) THEN (simp_tac)) THEN (done_tac));
1336 ];;
1337
1338 (* Finalization of the section LinearApproximation *)
1339 let lin_approx_eq = finalize_theorem lin_approx_eq;;
1340 let lin_approx_imp_f_interval = finalize_theorem lin_approx_imp_f_interval;;
1341 let lin_approx_imp_df_interval = finalize_theorem lin_approx_imp_df_interval;;
1342 let lin_approx_imp_f_diff = finalize_theorem lin_approx_imp_f_diff;;
1343 end_section "LinearApproximation";;
1344
1345 (* Section MoreLinearApproximation *)
1346 begin_section "MoreLinearApproximation";;
1347 (add_section_var (mk_var ("f", (`:real->real`))); add_section_var (mk_var ("g", (`:real->real`))));;
1348 (add_section_var (mk_var ("x", (`:real`))));;
1349 (add_section_var (mk_var ("f_bounds", (`:real#real`))); add_section_var (mk_var ("df_bounds", (`:real#real`))));;
1350 (add_section_var (mk_var ("g_bounds", (`:real#real`))); add_section_var (mk_var ("dg_bounds", (`:real#real`))));;
1351
1352 (* Lemma interval_arith_not_zero *)
1353 let interval_arith_not_zero = section_proof ["x";"int"]
1354 `interval_arith x int ==> interval_not_zero int ==>
1355         ~(x = &0)`
1356 [
1357    (((((fun arg_tac -> (use_arg_then "PAIR") (fun fst_arg -> (use_arg_then "int") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "interval_arith")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "interval_not_zero")(thm_tac (new_rewrite [] []))))) THEN (arith_tac) THEN (done_tac));
1358 ];;
1359
1360 (* Lemma interval_arith_pos *)
1361 let interval_arith_pos = section_proof ["x";"int"]
1362 `interval_arith x int ==> interval_pos int ==> &0 < x`
1363 [
1364    ((((use_arg_then "int") (disch_tac [])) THEN (clear_assumption "int") THEN case) THEN ((((use_arg_then "interval_arith")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "interval_pos")(thm_tac (new_rewrite [] []))))) THEN (arith_tac) THEN (done_tac));
1365 ];;
1366
1367 (* Lemma interval_arith_abs *)
1368 let interval_arith_abs = section_proof ["x";"int";"y"]
1369 `interval_arith x int ==> iabs int < y ==> abs x < y`
1370 [
1371    (((((fun arg_tac -> (use_arg_then "PAIR") (fun fst_arg -> (use_arg_then "int") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "interval_arith")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "iabs")(thm_tac (new_rewrite [] []))))) THEN (arith_tac) THEN (done_tac));
1372 ];;
1373
1374 (* Lemma lin_approx_x *)
1375 let lin_approx_x = section_proof []
1376 `lin_approx (\x. x) x (x, x) (&1, &1)`
1377 [
1378    (((((use_arg_then "lin_approx_eq")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "derivative_x")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "interval_arith")(thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (((use_arg_then "REAL_DIFFERENTIABLE_ID")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "REAL_LE_REFL")(thm_tac (new_rewrite [] [])))))) THEN (done_tac));
1379 ];;
1380
1381 (* Lemma lin_approx_const *)
1382 let lin_approx_const = section_proof ["c"]
1383 `lin_approx (\x. c) x (c, c) (&0, &0)`
1384 [
1385    ((((use_arg_then "lin_approx_eq")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "derivative_const")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "interval_arith")(thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (((use_arg_then "REAL_DIFFERENTIABLE_CONST")(thm_tac (new_rewrite [] [])))));
1386    ((repeat_tactic 1 9 (((use_arg_then "REAL_LE_REFL")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
1387 ];;
1388
1389 (* Section LinearApproxUnivariateComposition *)
1390 begin_section "LinearApproxUnivariateComposition";;
1391 (add_section_hyp "approx_f" (`lin_approx f x f_bounds df_bounds`));;
1392
1393 (* Lemma lin_approx_compose_atn *)
1394 let lin_approx_compose_atn = section_proof []
1395 `(\x. atn (f x)) real_differentiable atreal x /\
1396         derivative (\x. atn (f x)) x = derivative f x / (&1 + f x * f x)`
1397 [
1398    ((((use_arg_then "derivative_compose_atn") (disch_tac [])) THEN (clear_assumption "derivative_compose_atn") THEN (DISCH_THEN apply_tac)) THEN (((use_arg_then "approx_f") (disch_tac [])) THEN (clear_assumption "approx_f") THEN BETA_TAC) THEN ((((use_arg_then "lin_approx_eq")(thm_tac (new_rewrite [] [])))) THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))) THEN (done_tac));
1399 ];;
1400
1401 (* Lemma lin_approx_compose_exp *)
1402 let lin_approx_compose_exp = section_proof []
1403 `(\x. exp (f x)) real_differentiable atreal x /\
1404         derivative (\x. exp (f x)) x = exp (f x) * derivative f x`
1405 [
1406    ((((use_arg_then "derivative_compose_exp") (disch_tac [])) THEN (clear_assumption "derivative_compose_exp") THEN (DISCH_THEN apply_tac)) THEN (((use_arg_then "approx_f") (disch_tac [])) THEN (clear_assumption "approx_f") THEN BETA_TAC) THEN ((((use_arg_then "lin_approx_eq")(thm_tac (new_rewrite [] [])))) THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))) THEN (done_tac));
1407 ];;
1408
1409 (* Lemma lin_approx_compose_inv *)
1410 let lin_approx_compose_inv = section_proof []
1411 `interval_not_zero f_bounds ==>
1412         (\x. inv (f x)) real_differentiable atreal x /\
1413         derivative (\x. inv (f x)) x = -- inv (f x * f x) * derivative f x`
1414 [
1415    ((((use_arg_then "approx_f") (disch_tac [])) THEN (clear_assumption "approx_f") THEN BETA_TAC) THEN ((((use_arg_then "lin_approx_eq")(thm_tac (new_rewrite [] [])))) THEN ALL_TAC THEN (case THEN ((move ["df"]) THEN (move ["h"]))) THEN (move ["f0"])));
1416    ((THENL_FIRST) ((fun arg_tac -> arg_tac (Arg_term (`~(f x = &0)`))) (term_tac (have_gen_tac [](move ["fn0"])))) ((((use_arg_then "interval_arith_not_zero") (disch_tac [])) THEN (clear_assumption "interval_arith_not_zero") THEN (DISCH_THEN apply_tac)) THEN ((use_arg_then "f_bounds") (term_tac exists_tac)) THEN (done_tac)));
1417    (((fun arg_tac -> (fun arg_tac -> (use_arg_then "derivative_compose_inv") (fun fst_arg -> (use_arg_then "df") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "fn0") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN (exact_tac));
1418 ];;
1419
1420 (* Lemma lin_approx_compose_sqrt *)
1421 let lin_approx_compose_sqrt = section_proof []
1422 `interval_pos f_bounds ==>
1423         (\x. sqrt (f x)) real_differentiable atreal x /\
1424         derivative (\x. sqrt (f x)) x = derivative f x / (&2 * sqrt (f x))`
1425 [
1426    ((((use_arg_then "approx_f") (disch_tac [])) THEN (clear_assumption "approx_f") THEN BETA_TAC) THEN ((((use_arg_then "lin_approx_eq")(thm_tac (new_rewrite [] [])))) THEN ALL_TAC THEN (case THEN ((move ["df"]) THEN (move ["h"]))) THEN (move ["f_ineq"])));
1427    ((THENL_FIRST) ((fun arg_tac -> arg_tac (Arg_term (`&0 < f x`))) (term_tac (have_gen_tac [](move ["f_pos"])))) ((((use_arg_then "interval_arith_pos") (disch_tac [])) THEN (clear_assumption "interval_arith_pos") THEN (DISCH_THEN apply_tac)) THEN ((use_arg_then "f_bounds") (term_tac exists_tac)) THEN (done_tac)));
1428    (((fun arg_tac -> (fun arg_tac -> (use_arg_then "derivative_compose_sqrt") (fun fst_arg -> (use_arg_then "df") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "f_pos") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN (exact_tac));
1429 ];;
1430
1431 (* Lemma lin_approx_compose_acs *)
1432 let lin_approx_compose_acs = section_proof []
1433 `iabs f_bounds < &1 ==>
1434         (\x. acs (f x)) real_differentiable atreal x /\
1435         derivative (\x. acs (f x)) x = -- (derivative f x / sqrt (&1 - f x * f x))`
1436 [
1437    ((((use_arg_then "approx_f") (disch_tac [])) THEN (clear_assumption "approx_f") THEN BETA_TAC) THEN ((((use_arg_then "lin_approx_eq")(thm_tac (new_rewrite [] [])))) THEN ALL_TAC THEN (case THEN ((move ["df"]) THEN (move ["h"]))) THEN (move ["f_ineq"])));
1438    ((THENL_FIRST) ((fun arg_tac -> arg_tac (Arg_term (`abs (f x) < &1`))) (term_tac (have_gen_tac [](move ["f_abs"])))) ((((use_arg_then "interval_arith_abs") (disch_tac [])) THEN (clear_assumption "interval_arith_abs") THEN (DISCH_THEN apply_tac)) THEN ((use_arg_then "f_bounds") (term_tac exists_tac)) THEN (done_tac)));
1439    (((fun arg_tac -> (fun arg_tac -> (use_arg_then "derivative_compose_acs") (fun fst_arg -> (use_arg_then "df") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "f_abs") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN (exact_tac));
1440 ];;
1441
1442 (* Finalization of the section LinearApproxUnivariateComposition *)
1443 let lin_approx_compose_atn = finalize_theorem lin_approx_compose_atn;;
1444 let lin_approx_compose_exp = finalize_theorem lin_approx_compose_exp;;
1445 let lin_approx_compose_inv = finalize_theorem lin_approx_compose_inv;;
1446 let lin_approx_compose_sqrt = finalize_theorem lin_approx_compose_sqrt;;
1447 let lin_approx_compose_acs = finalize_theorem lin_approx_compose_acs;;
1448 end_section "LinearApproxUnivariateComposition";;
1449 (add_section_hyp "approx_f" (`lin_approx f x f_bounds df_bounds`));;
1450 (add_section_hyp "approx_g" (`lin_approx g x g_bounds dg_bounds`));;
1451
1452 (* Lemma lin_approx_imp_add_diff *)
1453 let lin_approx_imp_add_diff = section_proof []
1454 `(\x. f x + g x) real_differentiable atreal x`
1455 [
1456    (((use_arg_then "REAL_DIFFERENTIABLE_ADD") (disch_tac [])) THEN (clear_assumption "REAL_DIFFERENTIABLE_ADD") THEN (DISCH_THEN apply_tac));
1457    (((((fun arg_tac -> (use_arg_then "lin_approx_imp_f_diff") (fun fst_arg -> (use_arg_then "approx_f") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> (use_arg_then "lin_approx_imp_f_diff") (fun fst_arg -> (use_arg_then "approx_g") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] []))))) THEN (done_tac));
1458 ];;
1459
1460 (* Lemma lin_approx_imp_sub_diff *)
1461 let lin_approx_imp_sub_diff = section_proof []
1462 `(\x. f x - g x) real_differentiable atreal x`
1463 [
1464    (((use_arg_then "REAL_DIFFERENTIABLE_SUB") (disch_tac [])) THEN (clear_assumption "REAL_DIFFERENTIABLE_SUB") THEN (DISCH_THEN apply_tac));
1465    (((((fun arg_tac -> (use_arg_then "lin_approx_imp_f_diff") (fun fst_arg -> (use_arg_then "approx_f") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> (use_arg_then "lin_approx_imp_f_diff") (fun fst_arg -> (use_arg_then "approx_g") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] []))))) THEN (done_tac));
1466 ];;
1467
1468 (* Lemma lin_approx_imp_mul_diff *)
1469 let lin_approx_imp_mul_diff = section_proof []
1470 `(\x. f x * g x) real_differentiable atreal x`
1471 [
1472    (((use_arg_then "REAL_DIFFERENTIABLE_MUL_ATREAL") (disch_tac [])) THEN (clear_assumption "REAL_DIFFERENTIABLE_MUL_ATREAL") THEN (DISCH_THEN apply_tac));
1473    (((((fun arg_tac -> (use_arg_then "lin_approx_imp_f_diff") (fun fst_arg -> (use_arg_then "approx_f") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> (use_arg_then "lin_approx_imp_f_diff") (fun fst_arg -> (use_arg_then "approx_g") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] []))))) THEN (done_tac));
1474 ];;
1475
1476 (* Lemma lin_approx_imp_div_diff *)
1477 let lin_approx_imp_div_diff = section_proof []
1478 `interval_not_zero g_bounds ==> (\x. f x / g x) real_differentiable atreal x`
1479 [
1480    ((BETA_TAC THEN (move ["gn0"])) THEN (((use_arg_then "REAL_DIFFERENTIABLE_DIV_ATREAL") (disch_tac [])) THEN (clear_assumption "REAL_DIFFERENTIABLE_DIV_ATREAL") THEN (DISCH_THEN apply_tac)));
1481    ((((fun arg_tac -> (use_arg_then "lin_approx_imp_f_diff") (fun fst_arg -> (use_arg_then "approx_f") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> (use_arg_then "lin_approx_imp_f_diff") (fun fst_arg -> (use_arg_then "approx_g") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))));
1482    ((((use_arg_then "interval_arith_not_zero") (disch_tac [])) THEN (clear_assumption "interval_arith_not_zero") THEN (DISCH_THEN apply_tac)) THEN ((use_arg_then "g_bounds") (term_tac exists_tac)));
1483    ((((use_arg_then "approx_g") (disch_tac [])) THEN (clear_assumption "approx_g") THEN BETA_TAC) THEN ((((use_arg_then "lin_approx_eq")(thm_tac (new_rewrite [] [])))) THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))) THEN (done_tac));
1484 ];;
1485
1486 (* Finalization of the section MoreLinearApproximation *)
1487 let interval_arith_not_zero = finalize_theorem interval_arith_not_zero;;
1488 let interval_arith_pos = finalize_theorem interval_arith_pos;;
1489 let interval_arith_abs = finalize_theorem interval_arith_abs;;
1490 let lin_approx_x = finalize_theorem lin_approx_x;;
1491 let lin_approx_const = finalize_theorem lin_approx_const;;
1492 let lin_approx_compose_atn = finalize_theorem lin_approx_compose_atn;;
1493 let lin_approx_compose_exp = finalize_theorem lin_approx_compose_exp;;
1494 let lin_approx_compose_inv = finalize_theorem lin_approx_compose_inv;;
1495 let lin_approx_compose_sqrt = finalize_theorem lin_approx_compose_sqrt;;
1496 let lin_approx_compose_acs = finalize_theorem lin_approx_compose_acs;;
1497 let lin_approx_imp_add_diff = finalize_theorem lin_approx_imp_add_diff;;
1498 let lin_approx_imp_sub_diff = finalize_theorem lin_approx_imp_sub_diff;;
1499 let lin_approx_imp_mul_diff = finalize_theorem lin_approx_imp_mul_diff;;
1500 let lin_approx_imp_div_diff = finalize_theorem lin_approx_imp_div_diff;;
1501 end_section "MoreLinearApproximation";;
1502
1503 (* Section LinearApproxArith *)
1504 begin_section "LinearApproxArith";;
1505 (add_section_var (mk_var ("f1", (`:real->real`))); add_section_var (mk_var ("f2", (`:real->real`))));;
1506 (add_section_var (mk_var ("f1_bounds", (`:real#real`))); add_section_var (mk_var ("f2_bounds", (`:real#real`))));;
1507 (add_section_var (mk_var ("df1_lo", (`:real`))); add_section_var (mk_var ("df1_hi", (`:real`))); add_section_var (mk_var ("df2_lo", (`:real`))); add_section_var (mk_var ("df2_hi", (`:real`))));;
1508 (add_section_var (mk_var ("f_bounds", (`:real#real`))));;
1509 (add_section_var (mk_var ("df_lo", (`:real`))); add_section_var (mk_var ("df_hi", (`:real`))));;
1510 (add_section_var (mk_var ("x", (`:real`))));;
1511 (add_section_hyp "approx1" (`lin_approx f1 x f1_bounds (df1_lo, df1_hi)`));;
1512
1513 (* Lemma lin_approx_scale *)
1514 let lin_approx_scale = section_proof ["c"]
1515 `&0 <= c ==> interval_arith (c * f1 x) f_bounds /\
1516         df_lo <= c * df1_lo /\ c * df1_hi <= df_hi ==>
1517         lin_approx (\x. c * f1 x) x f_bounds (df_lo, df_hi)`
1518 [
1519    (((((use_arg_then "pair_eq")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "interval_arith")(thm_tac (new_rewrite [] []))))) THEN (move ["c0"]) THEN (move ["ineqs"]));
1520    (((((use_arg_then "lin_approx")(thm_tac (new_rewrite [] [])))) THEN (simp_tac)) THEN (split_tac));
1521    ((((use_arg_then "pair_eq")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "ineqs") (disch_tac [])) THEN (clear_assumption "ineqs") THEN ((use_arg_then "approx1") (disch_tac [])) THEN (clear_assumption "approx1") THEN BETA_TAC) THEN ((repeat_tactic 1 9 (((use_arg_then "lin_approx")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "interval_arith")(thm_tac (new_rewrite [] [])))))) THEN (arith_tac) THEN (done_tac));
1522    ((((use_arg_then "approx1") (disch_tac [])) THEN (clear_assumption "approx1") THEN BETA_TAC) THEN ((repeat_tactic 1 9 (((use_arg_then "lin_approx")(thm_tac (new_rewrite [] []))))) THEN ALL_TAC THEN (case THEN (move ["int_f1"])) THEN (case THEN (move ["f1'"])) THEN (case THEN ((move ["df1"]) THEN (move ["int_f1'"])))));
1523    (((fun arg_tac -> arg_tac (Arg_term (`c * f1'`))) (term_tac exists_tac)) THEN ((((use_arg_then "HAS_REAL_DERIVATIVE_LMUL_ATREAL")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))));
1524    ((((use_arg_then "int_f1'") (disch_tac [])) THEN (clear_assumption "int_f1'") THEN BETA_TAC) THEN ((repeat_tactic 1 9 (((use_arg_then "interval_arith")(thm_tac (new_rewrite [] []))))) THEN (move ["ineqs2"])) THEN (split_tac) THEN (((use_arg_then "REAL_LE_TRANS") (disch_tac [])) THEN (clear_assumption "REAL_LE_TRANS") THEN (DISCH_THEN apply_tac)));
1525    (((fun arg_tac -> arg_tac (Arg_term (`c * df1_lo`))) (term_tac exists_tac)) THEN ((((use_arg_then "ineqs")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_LE_LMUL")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
1526    (((fun arg_tac -> arg_tac (Arg_term (`c * df1_hi`))) (term_tac exists_tac)) THEN ((((use_arg_then "ineqs")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_LE_LMUL")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
1527 ];;
1528 (add_section_hyp "approx2" (`lin_approx f2 x f2_bounds (df2_lo, df2_hi)`));;
1529
1530 (* Lemma lin_approx_add *)
1531 let lin_approx_add = section_proof []
1532 `interval_arith (f1 x + f2 x) f_bounds /\
1533         df_lo <= df1_lo + df2_lo /\ df1_hi + df2_hi <= df_hi ==>
1534         lin_approx (\x. f1 x + f2 x) x f_bounds (df_lo, df_hi)`
1535 [
1536    (((((use_arg_then "pair_eq")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "interval_arith")(thm_tac (new_rewrite [] []))))) THEN (move ["ineqs"]));
1537    (((((use_arg_then "lin_approx")(thm_tac (new_rewrite [] [])))) THEN (simp_tac)) THEN (split_tac));
1538    ((((use_arg_then "pair_eq")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "ineqs") (disch_tac [])) THEN (clear_assumption "ineqs") THEN ((use_arg_then "approx2") (disch_tac [])) THEN (clear_assumption "approx2") THEN ((use_arg_then "approx1") (disch_tac [])) THEN (clear_assumption "approx1") THEN BETA_TAC) THEN ((repeat_tactic 1 9 (((use_arg_then "lin_approx")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "interval_arith")(thm_tac (new_rewrite [] [])))))) THEN (arith_tac) THEN (done_tac));
1539    ((((use_arg_then "approx2") (disch_tac [])) THEN (clear_assumption "approx2") THEN ((use_arg_then "approx1") (disch_tac [])) THEN (clear_assumption "approx1") THEN BETA_TAC) THEN ((repeat_tactic 1 9 (((use_arg_then "lin_approx")(thm_tac (new_rewrite [] []))))) THEN ALL_TAC THEN (case THEN (move ["int_f1"])) THEN (case THEN (move ["f1'"])) THEN (case THEN ((move ["df1"]) THEN (move ["int_f1'"])))));
1540    (BETA_TAC THEN (case THEN (move ["int_f2"])) THEN (case THEN (move ["f2'"])) THEN (case THEN ((move ["df2"]) THEN (move ["int_f2'"]))));
1541    (((fun arg_tac -> arg_tac (Arg_term (`f1' + f2':real`))) (term_tac exists_tac)) THEN ((((use_arg_then "HAS_REAL_DERIVATIVE_ADD")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))));
1542    ((((use_arg_then "int_f2'") (disch_tac [])) THEN (clear_assumption "int_f2'") THEN ((use_arg_then "int_f1'") (disch_tac [])) THEN (clear_assumption "int_f1'") THEN ((use_arg_then "ineqs") (disch_tac [])) THEN (clear_assumption "ineqs") THEN BETA_TAC) THEN (repeat_tactic 1 9 (((use_arg_then "interval_arith")(thm_tac (new_rewrite [] []))))) THEN (arith_tac) THEN (done_tac));
1543 ];;
1544
1545 (* Finalization of the section LinearApproxArith *)
1546 let lin_approx_scale = finalize_theorem lin_approx_scale;;
1547 let lin_approx_add = finalize_theorem lin_approx_add;;
1548 end_section "LinearApproxArith";;
1549
1550 (* Section SecondDerivativeBound *)
1551 begin_section "SecondDerivativeBound";;
1552 (add_section_var (mk_var ("f1", (`:real->real`))); add_section_var (mk_var ("f2", (`:real->real`))));;
1553 (add_section_var (mk_var ("int", (`:real#real`))));;
1554 (add_section_var (mk_var ("dd1", (`:real#real`))); add_section_var (mk_var ("dd2", (`:real#real`))));;
1555
1556 (* Lemma nth_diff_strong2_eq_alt *)
1557 let nth_diff_strong2_eq_alt = section_proof ["f";"x"]
1558 `nth_diff_strong 2 f x <=> ?s. real_open s /\ x IN s /\
1559         !y. y IN s ==> (f has_real_derivative derivative f y) (atreal y) /\
1560         (derivative f has_real_derivative nth_derivative 2 f y) (atreal y)`
1561 [
1562    ((((use_arg_then "nth_diff_strong")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "nth_differentiable_on")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "nth_differentiable_eq")(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> arg_tac (Arg_theorem (ARITH_RULE `i < 2 <=> i = 0 \/ i = 1`)))(thm_tac (new_rewrite [] [])))));
1563    ((split_tac) THEN ALL_TAC THEN (case THEN (move ["s"])) THEN (case THEN (move ["open_s"])) THEN (case THEN (move ["xs"])) THEN (move ["df"]));
1564    (((use_arg_then "s") (term_tac exists_tac)) THEN (((((use_arg_then "open_s")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "xs")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))))) THEN (move ["y"]) THEN (DISCH_THEN (fun snd_th -> (use_arg_then "df") (thm_tac (match_mp_then snd_th MP_TAC)))) THEN (case THEN (move ["_"])) THEN (move ["h"])));
1565    ((((fun arg_tac -> (use_arg_then "h") (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`1`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN ((fun arg_tac -> (use_arg_then "h") (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`0`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC THEN (simp_tac)) THEN (((((use_arg_then "ONE")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "nth_derivative1")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "nth_derivative0")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "TWO")(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] [])))) THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))) THEN (done_tac));
1566    (((use_arg_then "s") (term_tac exists_tac)) THEN (((((use_arg_then "open_s")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "xs")(thm_tac (new_rewrite [1] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))))) THEN (move ["y"]) THEN (DISCH_THEN (fun snd_th -> (use_arg_then "df") (thm_tac (match_mp_then snd_th MP_TAC)))) THEN (move ["h"])));
1567    ((((use_arg_then "REAL_DIFFERENTIABLE_IMP_CONTINUOUS_ATREAL")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))));
1568    ((((use_arg_then "real_differentiable")(thm_tac (new_rewrite [] [])))) THEN ((fun arg_tac -> arg_tac (Arg_term (`derivative f y`))) (term_tac exists_tac)) THEN (done_tac));
1569    ((BETA_TAC THEN (move ["i"])) THEN (case THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))) THEN ((repeat_tactic 0 10 (((use_arg_then "ONE")(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (repeat_tactic 0 10 (((use_arg_then "TWO")(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (repeat_tactic 1 9 (((fun arg_tac ->(use_arg_then "nth_derivative0")(fun tmp_arg1 -> (use_arg_then "nth_derivative1")(fun tmp_arg2 -> arg_tac (Arg_theorem (CONJ (get_arg_thm tmp_arg1) (get_arg_thm tmp_arg2))))))(thm_tac (new_rewrite [] [])))))) THEN (done_tac));
1570 ];;
1571
1572 (* Lemma nth_diff_strong2_eq *)
1573 let nth_diff_strong2_eq = section_proof ["f";"x"]
1574 `nth_diff_strong 2 f x <=> ?s. real_open s /\ x IN s /\
1575         !y. y IN s ==> f real_differentiable atreal y /\ derivative f real_differentiable atreal y`
1576 [
1577    ((((use_arg_then "nth_diff_strong")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "nth_differentiable_on")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "TWO")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "ONE")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL nth_differentiable)))(thm_tac (new_rewrite [] []))))));
1578    ((((use_arg_then "ONE")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "nth_derivative0")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "nth_derivative1")(thm_tac (new_rewrite [] [])))));
1579    ((split_tac) THEN ALL_TAC THEN (case THEN (move ["s"])) THEN (case THEN (move ["open_s"])) THEN (case THEN (move ["xs"])) THEN (move ["df"]));
1580    (((use_arg_then "s") (term_tac exists_tac)) THEN (((((use_arg_then "open_s")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "xs")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))))) THEN (move ["y"]) THEN (DISCH_THEN (fun snd_th -> (use_arg_then "df") (thm_tac (match_mp_then snd_th MP_TAC)))) THEN (move ["h"])) THEN (done_tac));
1581    (((use_arg_then "s") (term_tac exists_tac)) THEN (((((use_arg_then "open_s")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "xs")(thm_tac (new_rewrite [1] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))))) THEN (move ["y"]) THEN (DISCH_THEN (fun snd_th -> (use_arg_then "df") (thm_tac (match_mp_then snd_th MP_TAC)))) THEN (move ["h"])));
1582    (((repeat_tactic 1 9 (((use_arg_then "h")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "REAL_DIFFERENTIABLE_IMP_CONTINUOUS_ATREAL")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
1583 ];;
1584
1585 (* Lemma lin_approx_compose *)
1586 let lin_approx_compose = section_proof ["f";"g";"y";"g_bounds";"f_bounds";"d_bounds"]
1587 `nth_diff_strong_int 2 g_bounds f ==>
1588           g real_differentiable atreal y ==>
1589           interval_arith (g y) g_bounds ==>
1590           bounded_on_int f g_bounds f_bounds ==>
1591           interval_arith (derivative g y * derivative f (g y)) d_bounds ==>
1592           lin_approx (\x. f (g x)) y f_bounds d_bounds`
1593 [
1594    (((((use_arg_then "nth_diff_strong_int")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "nth_diff_strong2_eq")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "bounded_on_int")(thm_tac (new_rewrite [] []))))) THEN (move ["df"]) THEN (move ["dg"]) THEN (move ["g_int"]) THEN (move ["f_int"]) THEN (move ["dfg_int"]));
1595    ((fun arg_tac -> arg_tac (Arg_term (`f real_differentiable atreal (g y)`))) (term_tac (have_gen_tac [](move ["dfgy"]))));
1596    ((((fun arg_tac -> (use_arg_then "df") (fun fst_arg -> (use_arg_then "g_int") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC THEN (case THEN (move ["s"])) THEN (case THEN (move ["open_s"])) THEN (case THEN (move ["ys"])) THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))) THEN (done_tac));
1597    ((((use_arg_then "lin_approx_eq")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "derivative_composition")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "dfg_int")(thm_tac (new_rewrite [] [])))) THEN (simp_tac) THEN (((use_arg_then "f_int")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "andbT")(thm_tac (new_rewrite [] [])))));
1598    ((((fun arg_tac -> (use_arg_then "o_THM") (fun fst_arg -> (use_arg_then "f") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "ETA_AX")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN (((use_arg_then "REAL_DIFFERENTIABLE_COMPOSE_ATREAL") (disch_tac [])) THEN (clear_assumption "REAL_DIFFERENTIABLE_COMPOSE_ATREAL") THEN (exact_tac)) THEN (done_tac));
1599 ];;
1600
1601 (* Lemma second_derivative_atn_eq *)
1602 let second_derivative_atn_eq = section_proof ["x"]
1603 `((\x. inv (&1 + x pow 2)) has_real_derivative 
1604         (-- &2 * x) * inv (&1 + x pow 2) pow 2) (atreal x)`
1605 [
1606    (((((use_arg_then "REAL_POW_INV")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "real_div")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "REAL_NEG_LMUL")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "HAS_REAL_DERIVATIVE_INV_ATREAL")(thm_tac (new_rewrite [] []))))) THEN (split_tac));
1607    ((((fun arg_tac -> (use_arg_then "REAL_ADD_LID") (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`&2 * x`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "HAS_REAL_DERIVATIVE_ADD")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "HAS_REAL_DERIVATIVE_CONST")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))));
1608    ((((use_arg_then "REAL_POW_2")(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> arg_tac (Arg_theorem (REAL_ARITH `&2 * x = x * &1 + &1 * x`)))(thm_tac (new_rewrite [] [])))));
1609    (((((use_arg_then "HAS_REAL_DERIVATIVE_MUL_ATREAL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "HAS_REAL_DERIVATIVE_ID")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
1610    (((((use_arg_then "REAL_POS_NZ")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "REAL_ADD_SYM")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_LT_ADD1")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_LE_POW_2")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
1611 ];;
1612
1613 (* Lemma second_derivative_atn *)
1614 let second_derivative_atn = section_proof []
1615 `derivative (derivative atn) = (\x. (-- &2 * x) * inv (&1 + x pow 2) pow 2)`
1616 [
1617    ((((((use_arg_then "derivative_atn")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "eq_ext")(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (move ["x"]) THEN (simp_tac)) THEN (((use_arg_then "derivative_unique") (disch_tac [])) THEN (clear_assumption "derivative_unique") THEN (DISCH_THEN apply_tac)));
1618    (((((use_arg_then "REAL_POW_2")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "second_derivative_atn_eq")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
1619 ];;
1620
1621 (* Lemma diff2_atn *)
1622 let diff2_atn = section_proof ["x"]
1623 `nth_diff_strong 2 atn x`
1624 [
1625    ((((use_arg_then "nth_diff_strong2_eq_alt")(thm_tac (new_rewrite [] [])))) THEN ((fun arg_tac -> arg_tac (Arg_term (`(:real)`))) (term_tac exists_tac)));
1626    (((((use_arg_then "IN_UNIV")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_OPEN_UNIV")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "IN_UNIV")(thm_tac (new_rewrite [] []))))) THEN (move ["y"]) THEN (simp_tac));
1627    ((((use_arg_then "derivative_atn")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_POW_2")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (((use_arg_then "HAS_REAL_DERIVATIVE_ATN")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))));
1628    (((((use_arg_then "nth_derivative2")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "second_derivative_atn")(thm_tac (new_rewrite [] [])))) THEN (simp_tac) THEN (((use_arg_then "second_derivative_atn_eq")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
1629 ];;
1630
1631 (* Lemma second_derivative_inv *)
1632 let second_derivative_inv = section_proof ["x"]
1633 `~(x = &0) ==> nth_derivative 2 inv x = &2 * inv (x pow 3)`
1634 [
1635    ((((use_arg_then "nth_derivative2")(thm_tac (new_rewrite [] [])))) THEN (move ["xn0"]));
1636    ((((use_arg_then "derivative_unique") (disch_tac [])) THEN (clear_assumption "derivative_unique") THEN (DISCH_THEN apply_tac)) THEN (((use_arg_then "HAS_REAL_DERIVATIVE_LOCAL") (disch_tac [])) THEN (clear_assumption "HAS_REAL_DERIVATIVE_LOCAL") THEN (DISCH_THEN apply_tac)));
1637    (((fun arg_tac -> arg_tac (Arg_term (`(\x. -- inv (x * x))`))) (term_tac exists_tac)) THEN (split_tac));
1638    (((fun arg_tac -> arg_tac (Arg_theorem ((DISCH_ALL o REAL_DIFF_CONV) `((\x. -- inv(x * x)) has_real_derivative f) (atreal x)`))) (disch_tac [])) THEN BETA_TAC);
1639    ((((use_arg_then "REAL_ENTIRE")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "xn0")(thm_tac (new_rewrite [] [])))) THEN (simp_tac) THEN (((use_arg_then "real_div")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_MUL_LNEG")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_NEG_NEG")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_MUL_LID")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_MUL_RID")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_MUL_2")(gsym_then (thm_tac (new_rewrite [] []))))));
1640    ((((fun arg_tac -> arg_tac (Arg_theorem (REAL_ARITH `(x * x) pow 2 = x * x pow 3`)))(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "REAL_INV_MUL")(thm_tac (new_rewrite [] []))))));
1641    (((((fun arg_tac -> arg_tac (Arg_theorem (REAL_ARITH `!a. (&2 * x) * inv x * a = &2 * (x * inv x) * a`)))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_MUL_RINV")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "REAL_MUL_LID")(thm_tac (new_rewrite [] [])))))) THEN (done_tac));
1642    ((fun arg_tac -> arg_tac (Arg_term (`real_interval (x - abs x, x + abs x)`))) (term_tac exists_tac));
1643    (((((use_arg_then "REAL_OPEN_REAL_INTERVAL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "IN_REAL_INTERVAL")(thm_tac (new_rewrite [] [])))))) THEN ((THENL) (split_tac) [ALL_TAC; ((move ["y"]) THEN (move ["ineq"]))]));
1644    ((((use_arg_then "xn0") (disch_tac [])) THEN (clear_assumption "xn0") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac));
1645    ((((use_arg_then "derivative_inv")(thm_tac (new_rewrite [] [])))) THEN ((simp_tac THEN TRY done_tac)));
1646    ((((use_arg_then "xn0") (disch_tac [])) THEN (clear_assumption "xn0") THEN ((use_arg_then "ineq") (disch_tac [])) THEN (clear_assumption "ineq") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac));
1647 ];;
1648
1649 (* Lemma diff2_inv *)
1650 let diff2_inv = section_proof ["x"]
1651 `~(x = &0) ==> nth_diff_strong 2 inv x`
1652 [
1653    ((((use_arg_then "nth_diff_strong2_eq")(thm_tac (new_rewrite [] [])))) THEN (move ["xn0"]));
1654    ((fun arg_tac -> arg_tac (Arg_term (`real_interval (x - abs x, x + abs x)`))) (term_tac exists_tac));
1655    (((((use_arg_then "REAL_OPEN_REAL_INTERVAL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "IN_REAL_INTERVAL")(thm_tac (new_rewrite [] [])))))) THEN ((THENL) (split_tac) [ALL_TAC; ((move ["y"]) THEN (move ["ineq"]))]));
1656    ((((use_arg_then "xn0") (disch_tac [])) THEN (clear_assumption "xn0") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac));
1657    ((THENL_FIRST) ((((use_arg_then "REAL_DIFFERENTIABLE_AT_INV")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))))) ((((use_arg_then "xn0") (disch_tac [])) THEN (clear_assumption "xn0") THEN ((use_arg_then "ineq") (disch_tac [])) THEN (clear_assumption "ineq") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac)));
1658    ((((use_arg_then "differentiable_local") (disch_tac [])) THEN (clear_assumption "differentiable_local") THEN (DISCH_THEN apply_tac)) THEN (((fun arg_tac -> arg_tac (Arg_term (`\x. --inv (x * x)`))) (term_tac exists_tac)) THEN ((fun arg_tac -> arg_tac (Arg_term (`real_interval (y - abs y, y + abs y)`))) (term_tac exists_tac))));
1659    (((((use_arg_then "REAL_OPEN_REAL_INTERVAL")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "IN_REAL_INTERVAL")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))) THEN (split_tac));
1660    ((((use_arg_then "REAL_DIFFERENTIABLE_NEG")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_DIFFERENTIABLE_INV_ATREAL")(thm_tac (new_rewrite [] [])))));
1661    ((((use_arg_then "REAL_DIFFERENTIABLE_MUL_ATREAL")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "REAL_DIFFERENTIABLE_ID")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((use_arg_then "REAL_ENTIRE")(thm_tac (new_rewrite [] [])))));
1662    ((((use_arg_then "xn0") (disch_tac [])) THEN (clear_assumption "xn0") THEN ((use_arg_then "ineq") (disch_tac [])) THEN (clear_assumption "ineq") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac));
1663    ((THENL) (split_tac) [ALL_TAC; ((move ["z"]) THEN (move ["ineq2"]))]);
1664    ((((use_arg_then "xn0") (disch_tac [])) THEN (clear_assumption "xn0") THEN ((use_arg_then "ineq") (disch_tac [])) THEN (clear_assumption "ineq") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac));
1665    (((((use_arg_then "derivative_inv")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac))) THEN (((use_arg_then "xn0") (disch_tac [])) THEN (clear_assumption "xn0") THEN ((use_arg_then "ineq2") (disch_tac [])) THEN (clear_assumption "ineq2") THEN ((use_arg_then "ineq") (disch_tac [])) THEN (clear_assumption "ineq") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac));
1666 ];;
1667
1668 (* Lemma SQRT_POW *)
1669 let SQRT_POW = section_proof ["x";"n"]
1670 `&0 <= x ==> sqrt x pow n = sqrt (x pow n)`
1671 [
1672    ((BETA_TAC THEN (move ["ineq"])) THEN ((THENL) (((use_arg_then "n") (disch_tac [])) THEN (clear_assumption "n") THEN elim) [ALL_TAC; ((move ["n"]) THEN (move ["IHn"]))]) THEN ((repeat_tactic 1 9 (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL real_pow)))(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "SQRT_1")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac))));
1673    (((((use_arg_then "IHn")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "SQRT_MUL")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "REAL_POW_LE")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
1674 ];;
1675
1676 (* Lemma second_derivative_sqrt *)
1677 let second_derivative_sqrt = section_proof ["x"]
1678 `&0 < x ==> nth_derivative 2 sqrt x = -- inv(&4 * sqrt (x pow 3))`
1679 [
1680    ((((use_arg_then "nth_derivative2")(thm_tac (new_rewrite [] [])))) THEN (move ["x_pos"]));
1681    ((((use_arg_then "derivative_unique") (disch_tac [])) THEN (clear_assumption "derivative_unique") THEN (DISCH_THEN apply_tac)) THEN (((use_arg_then "HAS_REAL_DERIVATIVE_LOCAL") (disch_tac [])) THEN (clear_assumption "HAS_REAL_DERIVATIVE_LOCAL") THEN (DISCH_THEN apply_tac)));
1682    (((fun arg_tac -> arg_tac (Arg_term (`(\x. inv (&2 * sqrt x))`))) (term_tac exists_tac)) THEN (split_tac));
1683    (((fun arg_tac -> arg_tac (Arg_theorem ((DISCH_ALL o REAL_DIFF_CONV) `((\x. inv(&2 * sqrt x)) has_real_derivative f) (atreal x)`))) (disch_tac [])) THEN BETA_TAC);
1684    ((fun arg_tac -> arg_tac (Arg_term (`~(&2 * sqrt x = &0)`))) (term_tac (have_gen_tac [](move ["ineq"]))));
1685    (((((use_arg_then "REAL_ENTIRE")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "negb_or")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "SQRT_EQ_0")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "REAL_LT_IMP_LE")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac))) THEN (((use_arg_then "x_pos") (disch_tac [])) THEN (clear_assumption "x_pos") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac));
1686    ((((use_arg_then "x_pos")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "ineq")(thm_tac (new_rewrite [] [])))) THEN (simp_tac) THEN (((use_arg_then "real_div")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_INV_POW")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_MUL_LID")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_MUL_LNEG")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "REAL_MUL_ASSOC")(gsym_then (thm_tac (new_rewrite [] []))))));
1687    ((((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL real_pow)))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "REAL_INV_POW")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "REAL_POW_MUL")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "REAL_INV_MUL")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "SQRT_POW")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "REAL_LT_IMP_LE")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)));
1688    ((((use_arg_then "REAL_MUL_ASSOC")(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL real_pow)))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_MUL_LNEG")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_INV_MUL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_MUL_ASSOC")(thm_tac (new_rewrite [] [])))));
1689    ((THENL_FIRST) ((((use_arg_then "REAL_MUL_RINV")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "REAL_MUL_LID")(thm_tac (new_rewrite [] [])))))) ((arith_tac) THEN (done_tac)));
1690    (((((use_arg_then "REAL_MUL_LNEG")(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> arg_tac (Arg_theorem (REAL_ARITH `&2 pow 2 = &4`)))(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> arg_tac (Arg_theorem (ARITH_RULE `SUC 2 = 3`)))(thm_tac (new_rewrite [] []))))) THEN (done_tac));
1691    ((fun arg_tac -> arg_tac (Arg_term (`real_interval (&0, x + &1)`))) (term_tac exists_tac));
1692    (((((use_arg_then "REAL_OPEN_REAL_INTERVAL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "IN_REAL_INTERVAL")(thm_tac (new_rewrite [] [])))))) THEN ((THENL) (split_tac) [ALL_TAC; ((move ["y"]) THEN (move ["ineq"]))]));
1693    ((((use_arg_then "x_pos") (disch_tac [])) THEN (clear_assumption "x_pos") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac));
1694    ((((use_arg_then "derivative_sqrt")(thm_tac (new_rewrite [] [])))) THEN (done_tac));
1695 ];;
1696
1697 (* Lemma diff2_sqrt *)
1698 let diff2_sqrt = section_proof ["x"]
1699 `&0 < x ==> nth_diff_strong 2 sqrt x`
1700 [
1701    ((((use_arg_then "nth_diff_strong2_eq")(thm_tac (new_rewrite [] [])))) THEN (move ["x_pos"]));
1702    ((fun arg_tac -> arg_tac (Arg_term (`real_interval (&0, x + &1)`))) (term_tac exists_tac));
1703    (((((use_arg_then "REAL_OPEN_REAL_INTERVAL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "IN_REAL_INTERVAL")(thm_tac (new_rewrite [] [])))))) THEN ((THENL) (split_tac) [ALL_TAC; ((move ["y"]) THEN (move ["ineq"]))]));
1704    ((((use_arg_then "x_pos") (disch_tac [])) THEN (clear_assumption "x_pos") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac));
1705    ((THENL_FIRST) ((((use_arg_then "REAL_DIFFERENTIABLE_AT_SQRT")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))))) ((((use_arg_then "x_pos") (disch_tac [])) THEN (clear_assumption "x_pos") THEN ((use_arg_then "ineq") (disch_tac [])) THEN (clear_assumption "ineq") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac)));
1706    ((((use_arg_then "differentiable_local") (disch_tac [])) THEN (clear_assumption "differentiable_local") THEN (DISCH_THEN apply_tac)) THEN (((fun arg_tac -> arg_tac (Arg_term (`\x. inv (&2 * sqrt x)`))) (term_tac exists_tac)) THEN ((fun arg_tac -> arg_tac (Arg_term (`real_interval (&0, y + &1)`))) (term_tac exists_tac))));
1707    (((((use_arg_then "REAL_OPEN_REAL_INTERVAL")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "IN_REAL_INTERVAL")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))) THEN (split_tac));
1708    ((((use_arg_then "REAL_DIFFERENTIABLE_INV_ATREAL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_DIFFERENTIABLE_MUL_ATREAL")(thm_tac (new_rewrite [] [])))));
1709    (((((use_arg_then "REAL_DIFFERENTIABLE_CONST")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_DIFFERENTIABLE_AT_SQRT")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
1710    (((((use_arg_then "REAL_ENTIRE")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "SQRT_EQ_0")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "REAL_LT_IMP_LE")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac))) THEN (((use_arg_then "ineq") (disch_tac [])) THEN (clear_assumption "ineq") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac));
1711    ((THENL_FIRST) ((THENL) (split_tac) [ALL_TAC; ((move ["z"]) THEN (move ["ineq2"]))]) ((((use_arg_then "x_pos") (disch_tac [])) THEN (clear_assumption "x_pos") THEN ((use_arg_then "ineq") (disch_tac [])) THEN (clear_assumption "ineq") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac)));
1712    ((((use_arg_then "derivative_sqrt")(thm_tac (new_rewrite [] [])))) THEN (done_tac));
1713 ];;
1714
1715 (* Lemma real_powS *)
1716 let real_powS = section_proof ["x";"n"]
1717 `x pow (SUC n) = x * x pow n`
1718 [
1719    ((((use_arg_then "real_pow")(thm_tac (new_rewrite [] [])))) THEN (done_tac));
1720 ];;
1721
1722 (* Lemma second_derivative_acs *)
1723 let second_derivative_acs = section_proof ["x"]
1724 `abs x < &1 ==> 
1725         nth_derivative 2 acs x = --(x / sqrt ((&1 - x * x) pow 3))`
1726 [
1727    ((((use_arg_then "nth_derivative2")(thm_tac (new_rewrite [] [])))) THEN (move ["x_ineq"]));
1728    ((((use_arg_then "derivative_unique") (disch_tac [])) THEN (clear_assumption "derivative_unique") THEN (DISCH_THEN apply_tac)) THEN (((use_arg_then "HAS_REAL_DERIVATIVE_LOCAL") (disch_tac [])) THEN (clear_assumption "HAS_REAL_DERIVATIVE_LOCAL") THEN (DISCH_THEN apply_tac)));
1729    (((fun arg_tac -> arg_tac (Arg_term (`\x. --inv (sqrt (&1 - x * x))`))) (term_tac exists_tac)) THEN (split_tac));
1730    (((fun arg_tac -> arg_tac (Arg_theorem ((DISCH_ALL o REAL_DIFF_CONV) `((\x. --inv (sqrt (&1 - x * x))) has_real_derivative f) (atreal x)`))) (disch_tac [])) THEN BETA_TAC);
1731    ((fun arg_tac -> arg_tac (Arg_term (`&0 < &1 - x * x /\ ~(sqrt(&1 - x * x) = &0)`))) (term_tac (have_gen_tac [](move ["ineqs"]))));
1732    (((THENL_ROT 1)) ((fun arg_tac -> arg_tac (Arg_term (`&0 < &1 - x * x`))) (term_tac (have_gen_tac [](move ["h"])))));
1733    (((((use_arg_then "SQRT_EQ_0")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "REAL_LT_IMP_LE")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac))) THEN (((use_arg_then "h") (disch_tac [])) THEN (clear_assumption "h") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac));
1734    ((((fun arg_tac -> arg_tac (Arg_theorem (REAL_ARITH `&1 - x * x = (&1 - x) * (&1 + x)`)))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_LT_MUL")(thm_tac (new_rewrite [] [])))));
1735    ((((use_arg_then "x_ineq") (disch_tac [])) THEN (clear_assumption "x_ineq") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac));
1736    ((repeat_tactic 1 9 (((use_arg_then "ineqs")(thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (repeat_tactic 1 9 (((use_arg_then "real_div")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "REAL_INV_MUL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_SUB_LZERO")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "REAL_MUL_LNEG")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "REAL_NEG_NEG")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "REAL_MUL_ASSOC")(gsym_then (thm_tac (new_rewrite [] [])))))));
1737    ((((use_arg_then "REAL_INV_MUL")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "real_powS")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "SQRT_POW")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "REAL_LT_IMP_LE")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)));
1738    ((((use_arg_then "REAL_MUL_LID")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_MUL_RID")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_MUL_2")(gsym_then (thm_tac (new_rewrite [] []))))));
1739    ((((fun arg_tac -> arg_tac (Arg_theorem (REAL_ARITH `!a. (&2 * x) * inv (&2) * a = (&2 * inv (&2)) * x * a`)))(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> arg_tac (Arg_theorem (ARITH_RULE `SUC 2 = 3`)))(thm_tac (new_rewrite [] [])))));
1740    (((((use_arg_then "REAL_MUL_RINV")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "REAL_MUL_LID")(thm_tac (new_rewrite [] [])))))) THEN (arith_tac) THEN (done_tac));
1741    ((fun arg_tac -> arg_tac (Arg_term (`&1 - abs x`))) (term_tac (set_tac "e")));
1742    ((fun arg_tac -> arg_tac (Arg_term (`real_interval (x - e, x + e)`))) (term_tac exists_tac));
1743    (((((use_arg_then "REAL_OPEN_REAL_INTERVAL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "IN_REAL_INTERVAL")(thm_tac (new_rewrite [] [])))))) THEN ((THENL) (split_tac) [ALL_TAC; ((move ["y"]) THEN (move ["ineq"]))]));
1744    ((((use_arg_then "e_def") (disch_tac [])) THEN (clear_assumption "e_def") THEN ((use_arg_then "x_ineq") (disch_tac [])) THEN (clear_assumption "x_ineq") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac));
1745    ((((use_arg_then "derivative_acs")(thm_tac (new_rewrite [] [])))) THEN ((simp_tac THEN TRY done_tac)));
1746    ((((use_arg_then "e_def") (disch_tac [])) THEN (clear_assumption "e_def") THEN ((use_arg_then "x_ineq") (disch_tac [])) THEN (clear_assumption "x_ineq") THEN ((use_arg_then "ineq") (disch_tac [])) THEN (clear_assumption "ineq") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac));
1747 ];;
1748
1749 (* Lemma diff2_acs *)
1750 let diff2_acs = section_proof ["x"]
1751 `abs x < &1 ==> nth_diff_strong 2 acs x`
1752 [
1753    ((((use_arg_then "nth_diff_strong2_eq")(thm_tac (new_rewrite [] [])))) THEN (move ["x_ineq"]));
1754    ((fun arg_tac -> arg_tac (Arg_term (`&1 - abs x`))) (term_tac (set_tac "e")));
1755    ((fun arg_tac -> arg_tac (Arg_term (`real_interval (x - e, x + e)`))) (term_tac exists_tac));
1756    (((((use_arg_then "REAL_OPEN_REAL_INTERVAL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "IN_REAL_INTERVAL")(thm_tac (new_rewrite [] [])))))) THEN ((THENL) (split_tac) [ALL_TAC; ((move ["y"]) THEN (move ["ineq"]))]));
1757    ((((use_arg_then "e_def") (disch_tac [])) THEN (clear_assumption "e_def") THEN ((use_arg_then "x_ineq") (disch_tac [])) THEN (clear_assumption "x_ineq") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac));
1758    ((THENL_FIRST) ((((use_arg_then "REAL_DIFFERENTIABLE_AT_ACS")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))))) ((((use_arg_then "e_def") (disch_tac [])) THEN (clear_assumption "e_def") THEN ((use_arg_then "x_ineq") (disch_tac [])) THEN (clear_assumption "x_ineq") THEN ((use_arg_then "ineq") (disch_tac [])) THEN (clear_assumption "ineq") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac)));
1759    ((fun arg_tac -> arg_tac (Arg_term (`&1 - abs y`))) (term_tac (set_tac "e2")));
1760    ((((use_arg_then "differentiable_local") (disch_tac [])) THEN (clear_assumption "differentiable_local") THEN (DISCH_THEN apply_tac)) THEN (((fun arg_tac -> arg_tac (Arg_term (`\x. --inv (sqrt (&1 - x * x))`))) (term_tac exists_tac)) THEN ((fun arg_tac -> arg_tac (Arg_term (`real_interval (y - e2, y + e2)`))) (term_tac exists_tac))));
1761    (((((use_arg_then "REAL_OPEN_REAL_INTERVAL")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "IN_REAL_INTERVAL")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))) THEN (split_tac));
1762    ((((use_arg_then "REAL_DIFFERENTIABLE_NEG")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_DIFFERENTIABLE_INV_ATREAL")(thm_tac (new_rewrite [] [])))));
1763    ((fun arg_tac -> arg_tac (Arg_term (`&0 < &1 - y * y`))) (term_tac (have_gen_tac [](move ["gt0"]))));
1764    (((((fun arg_tac -> arg_tac (Arg_theorem (REAL_ARITH `&1 - y * y = (&1 - y) * (&1 + y)`)))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_LT_MUL")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "e_def") (disch_tac [])) THEN (clear_assumption "e_def") THEN ((use_arg_then "ineq") (disch_tac [])) THEN (clear_assumption "ineq") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac));
1765    ((((use_arg_then "SQRT_EQ_0")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "REAL_LT_IMP_LE")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((use_arg_then "REAL_LT_IMP_NZ")(thm_tac (new_rewrite [] [])))) THEN ((simp_tac THEN TRY done_tac)));
1766    ((fun arg_tac -> arg_tac (Arg_term (`(\x. sqrt (&1 - x * x)) = sqrt o (\x. &1 - x * x)`))) (term_tac (have_gen_tac [](((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] [])))))));
1767    (((((use_arg_then "eq_ext")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "o_THM")(thm_tac (new_rewrite [] [])))) THEN (simp_tac)) THEN (done_tac));
1768    ((((use_arg_then "REAL_DIFFERENTIABLE_COMPOSE_ATREAL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_DIFFERENTIABLE_AT_SQRT")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)));
1769    ((((use_arg_then "REAL_DIFFERENTIABLE_SUB")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "REAL_DIFFERENTIABLE_CONST")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_DIFFERENTIABLE_MUL_ATREAL")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)));
1770    ((((use_arg_then "REAL_DIFFERENTIABLE_ID")(thm_tac (new_rewrite [] [])))) THEN (done_tac));
1771    ((THENL) (split_tac) [ALL_TAC; ((move ["z"]) THEN (move ["ineq2"]))]);
1772    ((((use_arg_then "e2_def") (disch_tac [])) THEN (clear_assumption "e2_def") THEN ((use_arg_then "e_def") (disch_tac [])) THEN (clear_assumption "e_def") THEN ((use_arg_then "x_ineq") (disch_tac [])) THEN (clear_assumption "x_ineq") THEN ((use_arg_then "ineq") (disch_tac [])) THEN (clear_assumption "ineq") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac));
1773    ((((use_arg_then "derivative_acs")(thm_tac (new_rewrite [] [])))) THEN ((simp_tac THEN TRY done_tac)));
1774    ((((use_arg_then "ineq2") (disch_tac [])) THEN (clear_assumption "ineq2") THEN ((use_arg_then "e2_def") (disch_tac [])) THEN (clear_assumption "e2_def") THEN ((use_arg_then "e_def") (disch_tac [])) THEN (clear_assumption "e_def") THEN ((use_arg_then "ineq") (disch_tac [])) THEN (clear_assumption "ineq") THEN ((use_arg_then "x_ineq") (disch_tac [])) THEN (clear_assumption "x_ineq") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac));
1775 ];;
1776
1777 (* Section SecondDerivativeCompose *)
1778 begin_section "SecondDerivativeCompose";;
1779
1780 (* Lemma REAL_CONTINUOUS_OPEN_PREIMAGE *)
1781 let REAL_CONTINUOUS_OPEN_PREIMAGE = section_proof ["f";"s";"t"]
1782 `f real_continuous_on s ==> real_open s ==> real_open t ==>
1783         real_open {x | x IN s /\ f x IN t}`
1784 [
1785    (BETA_TAC THEN (move ["f_cont"]) THEN (move ["open_s"]) THEN (move ["open_t"]));
1786    (((use_arg_then "REAL_OPEN")(thm_tac (new_rewrite [] []))));
1787    (((THENL_ROT 1)) ((fun arg_tac -> arg_tac (Arg_term (`IMAGE lift {x | x IN s /\ f x IN t} = 
1788         {x | x IN (IMAGE lift s) /\ (lift o f o drop) x IN (IMAGE lift t)}`))) (term_tac (have_gen_tac [](((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))))));
1789    (((((use_arg_then "CONTINUOUS_OPEN_PREIMAGE")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "REAL_OPEN")(gsym_then (thm_tac (new_rewrite [] []))))))) THEN (((use_arg_then "ETA_AX")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN (((use_arg_then "REAL_CONTINUOUS_ON")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (done_tac));
1790    ((((((use_arg_then "EXTENSION")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "IN_IMAGE_LIFT_DROP")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "IN_ELIM_THM")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "IN_IMAGE_LIFT_DROP")(thm_tac (new_rewrite [] [])))))) THEN (move ["z"]) THEN (simp_tac)) THEN (split_tac));
1791    ((BETA_TAC THEN (case THEN (move ["x"])) THEN (case THEN (move ["x_in"])) THEN (move ["x_eq"])) THEN ((fun arg_tac -> arg_tac (Arg_term (`lift x`))) (term_tac exists_tac)));
1792    (((repeat_tactic 1 9 (((use_arg_then "o_THM")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "LIFT_DROP")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "x_in")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "x_eq")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "LIFT_DROP")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
1793    (((repeat_tactic 1 9 (((use_arg_then "o_THM")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "LIFT_DROP")(thm_tac (new_rewrite [] []))))) THEN ALL_TAC THEN (case THEN (move ["x"])) THEN (case THEN (move ["x_in"])) THEN (move ["x_eq"]));
1794    (((fun arg_tac -> arg_tac (Arg_term (`drop x`))) (term_tac exists_tac)) THEN (done_tac));
1795 ];;
1796
1797 (* Lemma second_derivative_compose *)
1798 let second_derivative_compose = section_proof ["f";"g";"x"]
1799 `nth_diff_strong 2 g x ==> nth_diff_strong 2 f (g x) ==>
1800         nth_derivative 2 (\x. f (g x)) x = 
1801         nth_derivative 2 f (g x) * (derivative g x) pow 2 + derivative f (g x) * nth_derivative 2 g x`
1802 [
1803    (BETA_TAC THEN (move ["dg"]) THEN (move ["df"]));
1804    ((((use_arg_then "nth_derivative2")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "derivative_unique") (disch_tac [])) THEN (clear_assumption "derivative_unique") THEN (DISCH_THEN apply_tac)) THEN (((use_arg_then "HAS_REAL_DERIVATIVE_LOCAL") (disch_tac [])) THEN (clear_assumption "HAS_REAL_DERIVATIVE_LOCAL") THEN (DISCH_THEN apply_tac)));
1805    ((THENL_ROT (-1)) (((fun arg_tac -> arg_tac (Arg_term (`\x. derivative f (g x) * derivative g x`))) (term_tac exists_tac)) THEN (split_tac)));
1806    ((((use_arg_then "dg") (disch_tac [])) THEN ((use_arg_then "df") (disch_tac [])) THEN BETA_TAC) THEN ((repeat_tactic 1 9 (((use_arg_then "nth_diff_strong2_eq")(thm_tac (new_rewrite [] []))))) THEN ALL_TAC THEN (case THEN (move ["s"])) THEN (case THEN (move ["open_s"])) THEN (case THEN (move ["gxs"])) THEN (move ["d_f"]) THEN (case THEN (move ["t"])) THEN (case THEN (move ["open_t"])) THEN (case THEN (move ["xt"])) THEN (move ["d_g"])));
1807    ((fun arg_tac -> arg_tac (Arg_term (`{z | z IN t /\ g z IN s}`))) (term_tac (set_tac "s'")));
1808    ((fun arg_tac -> arg_tac (Arg_term (`real_open s'`))) (term_tac (have_gen_tac [](move ["open_s'"]))));
1809    ((((use_arg_then "s'_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "REAL_CONTINUOUS_OPEN_PREIMAGE")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "open_t")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "open_s")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "andbT")(thm_tac (new_rewrite [] []))))));
1810    (((((use_arg_then "REAL_CONTINUOUS_ON_EQ_REAL_CONTINUOUS_AT")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac))) THEN (move ["y"]) THEN (move ["yt"]));
1811    (((((use_arg_then "REAL_DIFFERENTIABLE_IMP_CONTINUOUS_ATREAL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "d_g")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
1812    (((fun arg_tac -> arg_tac (Arg_term (`t INTER s'`))) (term_tac exists_tac)) THEN ((((use_arg_then "REAL_OPEN_INTER")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (repeat_tactic 1 9 (((use_arg_then "IN_INTER")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))) THEN (split_tac));
1813    (((((use_arg_then "s'_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "IN_ELIM_THM")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "xt")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))) THEN (simp_tac)) THEN ((use_arg_then "x") (term_tac exists_tac)) THEN (done_tac));
1814    ((BETA_TAC THEN (move ["y"]) THEN (case THEN ((move ["yt"]) THEN (move ["ys'"])))) THEN ((((use_arg_then "derivative_composition")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "REAL_MUL_SYM")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac))));
1815    (((((use_arg_then "d_g")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "d_f")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac))) THEN (((use_arg_then "ys'") (disch_tac [])) THEN (clear_assumption "ys'") THEN BETA_TAC) THEN (((((use_arg_then "s'_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "IN_ELIM_THM")(thm_tac (new_rewrite [] []))))) THEN ALL_TAC THEN (case THEN (move ["z"])) THEN (simp_tac)) THEN (done_tac));
1816    ((((use_arg_then "dg") (disch_tac [])) THEN (clear_assumption "dg") THEN ((use_arg_then "df") (disch_tac [])) THEN (clear_assumption "df") THEN BETA_TAC) THEN ((repeat_tactic 1 9 (((use_arg_then "nth_diff_strong2_eq_alt")(thm_tac (new_rewrite [] []))))) THEN ALL_TAC THEN (case THEN (move ["_"])) THEN (move ["d_f"]) THEN (case THEN (move ["_"])) THEN (move ["d_g"])));
1817    ((THENL_ROT (-1)) (((((use_arg_then "REAL_ADD_SYM")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_POW_2")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_MUL_ASSOC")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "HAS_REAL_DERIVATIVE_MUL_ATREAL")(thm_tac (new_rewrite [] []))))) THEN (split_tac)));
1818    ((((use_arg_then "ETA_AX")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN (((use_arg_then "d_g")(thm_tac (new_rewrite [] [])))) THEN (done_tac));
1819    ((((fun arg_tac -> (use_arg_then "o_THM") (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`derivative f`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "ETA_AX")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN (((use_arg_then "REAL_DIFF_CHAIN_ATREAL")(thm_tac (new_rewrite [] [])))));
1820    (((((use_arg_then "d_g")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "d_f")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
1821 ];;
1822
1823 (* Lemma diff2_compose *)
1824 let diff2_compose = section_proof ["f";"g";"x"]
1825 `nth_diff_strong 2 g x ==> nth_diff_strong 2 f (g x) ==>
1826         nth_diff_strong 2 (\x. f (g x)) x`
1827 [
1828    ((repeat_tactic 1 9 (((use_arg_then "nth_diff_strong2_eq")(thm_tac (new_rewrite [] []))))) THEN ALL_TAC THEN (case THEN (move ["s"])) THEN (case THEN (move ["open_s"])) THEN (case THEN (move ["xs"])) THEN (move ["dg"]) THEN (case THEN (move ["t"])) THEN (case THEN (move ["open_t"])) THEN (case THEN (move ["gxt"])) THEN (move ["df"]));
1829    ((fun arg_tac -> arg_tac (Arg_term (`{z | z IN s /\ g z IN t}`))) (term_tac (set_tac "s'")));
1830    ((fun arg_tac -> arg_tac (Arg_term (`real_open s'`))) (term_tac (have_gen_tac [](move ["open_s'"]))));
1831    ((((use_arg_then "s'_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "REAL_CONTINUOUS_OPEN_PREIMAGE")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "open_t")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "open_s")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "andbT")(thm_tac (new_rewrite [] []))))));
1832    (((((use_arg_then "REAL_CONTINUOUS_ON_EQ_REAL_CONTINUOUS_AT")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac))) THEN (move ["y"]) THEN (move ["yt"]));
1833    (((((use_arg_then "REAL_DIFFERENTIABLE_IMP_CONTINUOUS_ATREAL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "dg")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
1834    (((fun arg_tac -> arg_tac (Arg_term (`s INTER s'`))) (term_tac exists_tac)) THEN ((((use_arg_then "REAL_OPEN_INTER")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (repeat_tactic 1 9 (((use_arg_then "IN_INTER")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))) THEN (split_tac));
1835    (((((use_arg_then "s'_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "IN_ELIM_THM")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "xs")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "x") (term_tac exists_tac)) THEN (simp_tac)) THEN (done_tac));
1836    (BETA_TAC THEN (move ["y"]) THEN (case THEN ((move ["ys"]) THEN (move ["ys'"]))));
1837    ((((fun arg_tac -> (use_arg_then "o_THM") (fun fst_arg -> (use_arg_then "f") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(gsym_then (thm_tac (new_rewrite [1] []))))) THEN (((use_arg_then "ETA_AX")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN ((((use_arg_then "REAL_DIFFERENTIABLE_COMPOSE_ATREAL")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "dg")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "df")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac))));
1838    ((((use_arg_then "ys'") (disch_tac [])) THEN (clear_assumption "ys'") THEN BETA_TAC) THEN (((use_arg_then "s'_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN ((((use_arg_then "IN_ELIM_THM")(thm_tac (new_rewrite [] [])))) THEN ALL_TAC THEN (case THEN (move ["z"])) THEN (simp_tac)) THEN (done_tac));
1839    (((use_arg_then "differentiable_local") (disch_tac [])) THEN (clear_assumption "differentiable_local") THEN (DISCH_THEN apply_tac));
1840    ((THENL_ROT (-1)) ((((fun arg_tac -> arg_tac (Arg_term (`\x. derivative g x * derivative f (g x)`))) (term_tac exists_tac)) THEN ((fun arg_tac -> arg_tac (Arg_term (`s INTER s'`))) (term_tac exists_tac))) THEN (split_tac)));
1841    (((((use_arg_then "REAL_OPEN_INTER")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (repeat_tactic 1 9 (((use_arg_then "IN_INTER")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "ys")(thm_tac (new_rewrite [1] [])))) THEN (((use_arg_then "ys'")(thm_tac (new_rewrite [1] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))))) THEN (move ["z"]) THEN (move ["z_in"]));
1842    ((((use_arg_then "derivative_composition")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "dg")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "df")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)));
1843    ((((use_arg_then "z_in") (disch_tac [])) THEN (clear_assumption "z_in") THEN BETA_TAC) THEN (((use_arg_then "s'_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN ((((use_arg_then "IN_ELIM_THM")(thm_tac (new_rewrite [] [])))) THEN ALL_TAC THEN (case THEN (move ["_"])) THEN (case THEN (move ["_"])) THEN (simp_tac)) THEN (done_tac));
1844    ((((use_arg_then "REAL_DIFFERENTIABLE_MUL_ATREAL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "ETA_AX")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN ((((use_arg_then "dg")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))));
1845    ((((fun arg_tac -> (use_arg_then "o_THM") (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`derivative f`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "ETA_AX")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN ((((use_arg_then "REAL_DIFFERENTIABLE_COMPOSE_ATREAL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "dg")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "df")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac))));
1846    ((((use_arg_then "ys'") (disch_tac [])) THEN (clear_assumption "ys'") THEN BETA_TAC) THEN (((use_arg_then "s'_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN ((((use_arg_then "IN_ELIM_THM")(thm_tac (new_rewrite [] [])))) THEN ALL_TAC THEN (case THEN (move ["z"])) THEN (simp_tac)) THEN (done_tac));
1847 ];;
1848
1849 (* Lemma continuous_not0_exists_open *)
1850 let continuous_not0_exists_open = section_proof ["f";"x"]
1851 `~(f x = &0) ==> f real_continuous atreal x ==>
1852         ?s. real_open s /\ x IN s /\ !y. y IN s ==> ~(f y = &0)`
1853 [
1854    ((((use_arg_then "real_continuous_atreal")(thm_tac (new_rewrite [] [])))) THEN (move ["fn0"]) THEN ((fun arg_tac ->  (conv_thm_tac DISCH_THEN)  (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`abs (f x)`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (thm_tac MP_TAC)));
1855    ((THENL_FIRST) (ANTS_TAC) ((((use_arg_then "fn0") (disch_tac [])) THEN (clear_assumption "fn0") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac)));
1856    (BETA_TAC THEN (case THEN (move ["d"])) THEN (case THEN (move ["d0"])) THEN (move ["ineq"]));
1857    ((fun arg_tac -> arg_tac (Arg_term (`real_interval (x - d, x + d)`))) (term_tac exists_tac));
1858    ((THENL_FIRST) (((((use_arg_then "REAL_OPEN_REAL_INTERVAL")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "IN_REAL_INTERVAL")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))) THEN ((THENL) (split_tac) [ALL_TAC; (move ["y"])])) ((((use_arg_then "d0") (disch_tac [])) THEN (clear_assumption "d0") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac)));
1859    ((((use_arg_then "fn0") (disch_tac [])) THEN (clear_assumption "fn0") THEN ((use_arg_then "d0") (disch_tac [])) THEN (clear_assumption "d0") THEN ((fun arg_tac -> (use_arg_then "ineq") (fun fst_arg -> (use_arg_then "y") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC) THEN (arith_tac) THEN (done_tac));
1860 ];;
1861
1862 (* Lemma continuous_gt_exists_open *)
1863 let continuous_gt_exists_open = section_proof ["a";"f";"x"]
1864 `a < f x ==> f real_continuous atreal x ==>
1865         ?s. real_open s /\ x IN s /\ !y. y IN s ==> a < f y`
1866 [
1867    ((BETA_TAC THEN (move ["f_ineq"])) THEN ((((use_arg_then "real_continuous_atreal")(thm_tac (new_rewrite [] [])))) THEN ((fun arg_tac ->  (conv_thm_tac DISCH_THEN)  (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`f x - a`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (thm_tac MP_TAC))));
1868    ((THENL_FIRST) (ANTS_TAC) ((((use_arg_then "f_ineq") (disch_tac [])) THEN (clear_assumption "f_ineq") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac)));
1869    (BETA_TAC THEN (case THEN (move ["d"])) THEN (case THEN (move ["d0"])) THEN (move ["ineq"]));
1870    ((fun arg_tac -> arg_tac (Arg_term (`real_interval (x - d, x + d)`))) (term_tac exists_tac));
1871    ((THENL_FIRST) (((((use_arg_then "REAL_OPEN_REAL_INTERVAL")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "IN_REAL_INTERVAL")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))) THEN ((THENL) (split_tac) [ALL_TAC; (move ["y"])])) ((((use_arg_then "d0") (disch_tac [])) THEN (clear_assumption "d0") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac)));
1872    ((((use_arg_then "f_ineq") (disch_tac [])) THEN (clear_assumption "f_ineq") THEN ((use_arg_then "d0") (disch_tac [])) THEN (clear_assumption "d0") THEN ((fun arg_tac -> (use_arg_then "ineq") (fun fst_arg -> (use_arg_then "y") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC) THEN (arith_tac) THEN (done_tac));
1873 ];;
1874
1875 (* Lemma continuous_lt_exists_open *)
1876 let continuous_lt_exists_open = section_proof ["a";"f";"x"]
1877 `f x < a ==> f real_continuous atreal x ==>
1878         ?s. real_open s /\ x IN s /\ !y. y IN s ==> f y < a`
1879 [
1880    ((BETA_TAC THEN (move ["f_ineq"])) THEN ((((use_arg_then "real_continuous_atreal")(thm_tac (new_rewrite [] [])))) THEN ((fun arg_tac ->  (conv_thm_tac DISCH_THEN)  (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`a - f x`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (thm_tac MP_TAC))));
1881    ((THENL_FIRST) (ANTS_TAC) ((((use_arg_then "f_ineq") (disch_tac [])) THEN (clear_assumption "f_ineq") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac)));
1882    (BETA_TAC THEN (case THEN (move ["d"])) THEN (case THEN (move ["d0"])) THEN (move ["ineq"]));
1883    ((fun arg_tac -> arg_tac (Arg_term (`real_interval (x - d, x + d)`))) (term_tac exists_tac));
1884    ((THENL_FIRST) (((((use_arg_then "REAL_OPEN_REAL_INTERVAL")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "IN_REAL_INTERVAL")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))) THEN ((THENL) (split_tac) [ALL_TAC; (move ["y"])])) ((((use_arg_then "d0") (disch_tac [])) THEN (clear_assumption "d0") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac)));
1885    ((((use_arg_then "f_ineq") (disch_tac [])) THEN (clear_assumption "f_ineq") THEN ((use_arg_then "d0") (disch_tac [])) THEN (clear_assumption "d0") THEN ((fun arg_tac -> (use_arg_then "ineq") (fun fst_arg -> (use_arg_then "y") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC) THEN (arith_tac) THEN (done_tac));
1886 ];;
1887 (add_section_var (mk_var ("f", (`:real->real`))));;
1888 (add_section_var (mk_var ("x", (`:real`))));;
1889 (add_section_hyp "df" (`nth_diff_strong 2 f x`));;
1890
1891 (* Lemma second_derivative_compose_atn *)
1892 let second_derivative_compose_atn = section_proof []
1893 `nth_derivative 2 (\x. atn (f x)) x = 
1894         (nth_derivative 2 f x * (&1 + f x * f x) - &2 * f x * derivative f x pow 2) / (&1 + f x * f x) pow 2`
1895 [
1896    ((((use_arg_then "second_derivative_compose")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "diff2_atn")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((use_arg_then "nth_derivative2")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "second_derivative_atn")(thm_tac (new_rewrite [] [])))) THEN (simp_tac) THEN (((use_arg_then "derivative_atn")(thm_tac (new_rewrite [] [])))) THEN (simp_tac));
1897    ((((use_arg_then "REAL_ADD_SYM")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "REAL_MUL_LNEG")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "real_sub")(gsym_then (thm_tac (new_rewrite [] []))))));
1898    (((fun arg_tac -> arg_tac (Arg_term (`_1 * _2`))) (term_tac (set_tac "lhs1"))) THEN ((fun arg_tac -> arg_tac (Arg_term (`_1 * _2`))) (term_tac (set_tac "lhs2"))));
1899    ((((use_arg_then "real_div")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_INV_POW")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_SUB_RDISTRIB")(thm_tac (new_rewrite [] [])))));
1900    (((fun arg_tac -> arg_tac (Arg_term (`_1 * _2`))) (term_tac (set_tac "rhs1"))) THEN ((fun arg_tac -> arg_tac (Arg_term (`_1 * _2`))) (term_tac (set_tac "rhs2"))));
1901    (((fun arg_tac -> arg_tac (Arg_theorem (REAL_ARITH `lhs1 = rhs1 /\ lhs2 = rhs2 ==> lhs1 - lhs2 = rhs1 - rhs2`))) (disch_tac [])) THEN (DISCH_THEN apply_tac));
1902    (((((use_arg_then "lhs2_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "rhs2_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "REAL_MUL_ASSOC")(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (((use_arg_then "REAL_MUL_SYM")(thm_tac (new_rewrite [] [(`_1 * _2 pow 2`)])))) THEN (((use_arg_then "REAL_POW_2")(gsym_then (thm_tac (new_rewrite [] [])))))) THEN ((split_tac) THEN ((TRY done_tac))));
1903    ((((use_arg_then "rhs1_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "REAL_POW_2")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "REAL_MUL_ASSOC")(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (((fun arg_tac -> arg_tac (Arg_theorem (REAL_ARITH `!a b c d. a * b * c * d = a * (b * c) * d`)))(thm_tac (new_rewrite [] [])))));
1904    ((((use_arg_then "REAL_MUL_RINV")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "lhs1_def")(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (repeat_tactic 0 10 (((use_arg_then "REAL_MUL_LID")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "REAL_MUL_SYM")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)));
1905    ((((fun arg_tac -> (use_arg_then "REAL_LE_SQUARE") (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`f x`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC) THEN (arith_tac) THEN (done_tac));
1906 ];;
1907
1908 (* Lemma second_derivative_compose_inv *)
1909 let second_derivative_compose_inv = section_proof []
1910 `~(f x = &0) ==>
1911         nth_derivative 2 (\x. inv (f x)) x =
1912         (&2 * derivative f x pow 2 - nth_derivative 2 f x * f x) / (f x pow 3)`
1913 [
1914    (BETA_TAC THEN (move ["fn0"]));
1915    ((((use_arg_then "second_derivative_compose")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "diff2_inv")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((use_arg_then "second_derivative_inv")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "derivative_inv")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)));
1916    ((((use_arg_then "REAL_MUL_LNEG")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "real_sub")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "real_div")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_SUB_RDISTRIB")(thm_tac (new_rewrite [] [])))));
1917    ((THENL_FIRST) ((((fun arg_tac -> arg_tac (Arg_theorem (REAL_ARITH `!a b c d. a = c /\ b = d ==> a - b = c - d`))) (disch_tac [])) THEN (DISCH_THEN apply_tac)) THEN (split_tac)) ((arith_tac) THEN (done_tac)));
1918    ((((use_arg_then "REAL_INV_POW")(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> arg_tac (Arg_theorem (ARITH_RULE `3 = SUC 2`)))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "real_powS")(thm_tac (new_rewrite [] [])))));
1919    ((((fun arg_tac -> arg_tac (Arg_theorem (REAL_ARITH `!a b c d. (a * b) * c * d = a * (b * c) * d`)))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_MUL_RINV")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "REAL_MUL_LID")(thm_tac (new_rewrite [] [])))));
1920    (((((use_arg_then "REAL_INV_MUL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_POW_2")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "REAL_MUL_SYM")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
1921 ];;
1922
1923 (* Lemma second_derivative_compose_sqrt *)
1924 let second_derivative_compose_sqrt = section_proof []
1925 `&0 < f x ==>
1926         nth_derivative 2 (\x. sqrt (f x)) x =
1927         (&2 * nth_derivative 2 f x * f x - derivative f x pow 2) / (&4 * sqrt (f x pow 3))`
1928 [
1929    (BETA_TAC THEN (move ["f_pos"]));
1930    ((((use_arg_then "second_derivative_compose")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "diff2_sqrt")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((use_arg_then "second_derivative_sqrt")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "derivative_sqrt")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)));
1931    ((((use_arg_then "REAL_MUL_LNEG")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_ADD_SYM")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "real_sub")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "real_div")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_SUB_RDISTRIB")(thm_tac (new_rewrite [] [])))));
1932    ((THENL_LAST) ((((fun arg_tac -> arg_tac (Arg_theorem (REAL_ARITH `!a b c d. a = c /\ b = d ==> a - b = c - d`))) (disch_tac [])) THEN (DISCH_THEN apply_tac)) THEN (split_tac)) ((arith_tac) THEN (done_tac)));
1933    ((fun arg_tac -> arg_tac (Arg_term (`sqrt (f x pow 3) = sqrt (f x) * f x`))) (term_tac (have_gen_tac [](((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] [])))))));
1934    (((((use_arg_then "SQRT_POW")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "REAL_LT_IMP_LE")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((fun arg_tac -> arg_tac (Arg_theorem (ARITH_RULE `3 = SUC 2`)))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "real_powS")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "SQRT_POW_2")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "REAL_LT_IMP_LE")(thm_tac (new_rewrite [] [])))))) THEN (done_tac));
1935    (repeat_tactic 1 9 (((use_arg_then "REAL_INV_MUL")(thm_tac (new_rewrite [] [])))));
1936    (((fun arg_tac -> arg_tac (Arg_theorem (REAL_ARITH `!a b c d. (&2 * a * b) * inv (&4) * c * d = (inv (&2) * c) * a * (b * d)`)))(thm_tac (new_rewrite [] []))));
1937    (((((use_arg_then "REAL_MUL_RINV")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "REAL_POS_NZ")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((use_arg_then "REAL_MUL_RID")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
1938 ];;
1939
1940 (* Lemma second_derivative_compose_acs *)
1941 let second_derivative_compose_acs = section_proof []
1942 `abs (f x) < &1 ==>
1943         nth_derivative 2 (\x. acs (f x)) x =
1944         -- ((nth_derivative 2 f x * (&1 - f x * f x) + f x * derivative f x pow 2) / 
1945         sqrt ((&1 - f x * f x) pow 3))`
1946 [
1947    (BETA_TAC THEN (move ["f_ineq"]));
1948    ((((use_arg_then "second_derivative_compose")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "diff2_acs")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((use_arg_then "second_derivative_acs")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "derivative_acs")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)));
1949    ((repeat_tactic 1 9 (((use_arg_then "REAL_MUL_LNEG")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "REAL_NEG_ADD")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "REAL_EQ_NEG2")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "real_div")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "REAL_ADD_RDISTRIB")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_ADD_SYM")(thm_tac (new_rewrite [] [])))));
1950    ((THENL_LAST) ((((fun arg_tac -> arg_tac (Arg_theorem (REAL_ARITH `!a b c d. a = c /\ b = d ==> a + b = c + d`))) (disch_tac [])) THEN (DISCH_THEN apply_tac)) THEN (split_tac)) ((arith_tac) THEN (done_tac)));
1951    ((fun arg_tac -> arg_tac (Arg_term (`&1 - f x * f x`))) (term_tac (set_tac "y")));
1952    ((fun arg_tac -> arg_tac (Arg_term (`&0 <= y /\ &0 < y /\ ~(y = &0)`))) (term_tac (have_gen_tac [](move ["y_ineq"]))));
1953    ((((use_arg_then "y_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((fun arg_tac -> arg_tac (Arg_theorem (REAL_ARITH `!a. &1 - a * a = (&1 - a) * (&1 + a)`)))(thm_tac (new_rewrite [] [])))));
1954    (((((use_arg_then "REAL_ENTIRE")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_LE_MUL")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "REAL_LT_MUL")(thm_tac (new_rewrite [] [])))))) THEN (((use_arg_then "f_ineq") (disch_tac [])) THEN (clear_assumption "f_ineq") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac));
1955    ((fun arg_tac -> arg_tac (Arg_term (`sqrt (y pow 3) = sqrt y * y`))) (term_tac (have_gen_tac [](((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] [])))))));
1956    (((((use_arg_then "SQRT_POW")(gsym_then (thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((fun arg_tac -> arg_tac (Arg_theorem (ARITH_RULE `3 = SUC 2`)))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "real_powS")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "SQRT_POW_2")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
1957    ((((use_arg_then "REAL_INV_MUL")(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> arg_tac (Arg_theorem (REAL_ARITH `!a b c d. (a * b) * c * d = c * a * (b * d)`)))(thm_tac (new_rewrite [] [])))));
1958    (((((use_arg_then "REAL_MUL_RINV")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "REAL_MUL_RID")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
1959 ];;
1960
1961 (* Lemma diff2_compose_atn *)
1962 let diff2_compose_atn = section_proof []
1963 `nth_diff_strong 2 (\x. atn (f x)) x`
1964 [
1965    (((((use_arg_then "diff2_compose")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "diff2_atn")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
1966 ];;
1967
1968 (* Lemma diff2_compose_inv *)
1969 let diff2_compose_inv = section_proof []
1970 `~(f x = &0) ==> nth_diff_strong 2 (\x. inv (f x)) x`
1971 [
1972    ((BETA_TAC THEN (move ["fn0"])) THEN ((((use_arg_then "diff2_compose")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "diff2_inv")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
1973 ];;
1974
1975 (* Lemma diff2_compose_sqrt *)
1976 let diff2_compose_sqrt = section_proof []
1977 `&0 < f x ==> nth_diff_strong 2 (\x. sqrt (f x)) x`
1978 [
1979    ((BETA_TAC THEN (move ["f_pos"])) THEN ((((use_arg_then "diff2_compose")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "diff2_sqrt")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
1980 ];;
1981
1982 (* Lemma diff2_compose_acs *)
1983 let diff2_compose_acs = section_proof []
1984 `abs (f x) < &1 ==> nth_diff_strong 2 (\x. acs (f x)) x`
1985 [
1986    ((BETA_TAC THEN (move ["f_abs"])) THEN ((((use_arg_then "diff2_compose")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "diff2_acs")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
1987 ];;
1988
1989 (* Finalization of the section SecondDerivativeCompose *)
1990 let REAL_CONTINUOUS_OPEN_PREIMAGE = finalize_theorem REAL_CONTINUOUS_OPEN_PREIMAGE;;
1991 let second_derivative_compose = finalize_theorem second_derivative_compose;;
1992 let diff2_compose = finalize_theorem diff2_compose;;
1993 let continuous_not0_exists_open = finalize_theorem continuous_not0_exists_open;;
1994 let continuous_gt_exists_open = finalize_theorem continuous_gt_exists_open;;
1995 let continuous_lt_exists_open = finalize_theorem continuous_lt_exists_open;;
1996 let second_derivative_compose_atn = finalize_theorem second_derivative_compose_atn;;
1997 let second_derivative_compose_inv = finalize_theorem second_derivative_compose_inv;;
1998 let second_derivative_compose_sqrt = finalize_theorem second_derivative_compose_sqrt;;
1999 let second_derivative_compose_acs = finalize_theorem second_derivative_compose_acs;;
2000 let diff2_compose_atn = finalize_theorem diff2_compose_atn;;
2001 let diff2_compose_inv = finalize_theorem diff2_compose_inv;;
2002 let diff2_compose_sqrt = finalize_theorem diff2_compose_sqrt;;
2003 let diff2_compose_acs = finalize_theorem diff2_compose_acs;;
2004 end_section "SecondDerivativeCompose";;
2005
2006 (* Lemma second_derivative_mul *)
2007 let second_derivative_mul = section_proof ["f";"g";"x"]
2008 `nth_diff_strong 2 f x ==>
2009   nth_diff_strong 2 g x ==>
2010   nth_derivative 2 (\x. f x * g x) x =
2011   f x * nth_derivative 2 g x + &2 * derivative f x * derivative g x + nth_derivative 2 f x * g x`
2012 [
2013    ((BETA_TAC THEN (move ["df0"]) THEN (move ["dg0"])) THEN ((fun arg_tac -> arg_tac (Arg_term (`(x,x)`))) (term_tac (set_tac "int"))));
2014    ((fun arg_tac -> arg_tac (Arg_term (`interval_arith x int /\ nth_diff_strong_int 2 int f /\ nth_diff_strong_int 2 int g`))) (term_tac (have_gen_tac [](case THEN ((move ["ineq"]) THEN (case THEN ((move ["df"]) THEN (move ["dg"]))))))));
2015    ((repeat_tactic 1 9 (((use_arg_then "int_def")(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (repeat_tactic 1 9 (((use_arg_then "nth_diff_strong_int")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "CONST_INTERVAL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))));
2016    (((split_tac) THEN (move ["y"])) THEN (((((use_arg_then "interval_arith")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_LE_ANTISYM")(thm_tac (new_rewrite [] []))))) THEN (((conv_thm_tac DISCH_THEN)(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (done_tac));
2017    (((fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (use_arg_then "nth_derivative_mul") (fun fst_arg -> (use_arg_then "df") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "dg") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`2`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "ineq") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun arg -> thm_tac MP_TAC arg THEN ALL_TAC)) THEN ((((use_arg_then "leqnn")(thm_tac (new_rewrite [] [])))) THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac))));
2018    ((((use_arg_then "TWO")(thm_tac (new_rewrite [1] [])))) THEN (((use_arg_then "ONE")(thm_tac (new_rewrite [1] [])))) THEN (repeat_tactic 1 9 (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL SUM_CLAUSES_NUMSEG)))(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((fun arg_tac -> arg_tac (Arg_theorem (ARITH_RULE `!n. 0 <= SUC n`)))(thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (((use_arg_then "ONE")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "TWO")(gsym_then (thm_tac (new_rewrite [] []))))));
2019    ((((use_arg_then "subnn")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "subn0")(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> arg_tac (Arg_theorem (ARITH_RULE `2 - 1 = 1`)))(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "nth_derivative0")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "nth_derivative1")(thm_tac (new_rewrite [] []))))));
2020    (((((use_arg_then "binom")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "BINOM_1")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "BINOM_REFL")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "REAL_MUL_LID")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "REAL_ADD_ASSOC")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
2021 ];;
2022
2023 (* Lemma second_derivative_div *)
2024 let second_derivative_div = section_proof ["f";"g";"x"]
2025 `~(g x = &0) ==>
2026         nth_diff_strong 2 f x ==>
2027         nth_diff_strong 2 g x ==>
2028         nth_derivative 2 (\x. f x / g x) x = 
2029         ((nth_derivative 2 f x * g x - f x * nth_derivative 2 g x) * g x -
2030         &2 * derivative g x * (derivative f x * g x - f x * derivative g x)) / (g x pow 3)`
2031 [
2032    (BETA_TAC THEN (move ["gn0"]) THEN (move ["diff_f"]) THEN (move ["diff_g"]));
2033    (((fun arg_tac -> arg_tac (Arg_term (`derivative g x`))) (term_tac (set_tac "dg"))) THEN ((fun arg_tac -> arg_tac (Arg_term (`derivative f x`))) (term_tac (set_tac "df"))));
2034    (((fun arg_tac -> arg_tac (Arg_term (`nth_derivative 2 g x`))) (term_tac (set_tac "ddg"))) THEN ((fun arg_tac -> arg_tac (Arg_term (`nth_derivative 2 f x`))) (term_tac (set_tac "ddf"))));
2035    ((repeat_tactic 1 9 (((use_arg_then "real_div")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "second_derivative_mul")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "second_derivative_compose_inv")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "diff2_compose_inv")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)));
2036    (((use_arg_then "derivative_compose_inv")(thm_tac (new_rewrite [] []))));
2037    ((((use_arg_then "diff_g") (disch_tac [])) THEN (clear_assumption "diff_g") THEN BETA_TAC) THEN ((((use_arg_then "nth_diff_strong2_eq")(thm_tac (new_rewrite [] [])))) THEN ALL_TAC THEN (case THEN (move ["s"])) THEN (case THEN (move ["open_s"])) THEN (case THEN (move ["xs"])) THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac))) THEN (done_tac));
2038    ((((use_arg_then "ddf_def")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "ddg_def")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "df_def")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "dg_def")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "real_div")(thm_tac (new_rewrite [] []))))));
2039    ((fun arg_tac -> arg_tac (Arg_term (`_1 + _2`))) (term_tac (set_tac "lhs")));
2040    (((fun arg_tac -> arg_tac (Arg_theorem (REAL_RING `!f g x. ((ddf * g x - f x * ddg) * g x - &2 * dg * (df * g x - f x * dg)) * 
2041                                                 inv (g x pow 3) =
2042                         f x * (&2 * dg pow 2 - ddg * g x) * inv (g x pow 3) +
2043                         &2 * df * --(g x * inv (g x pow 3)) * dg +
2044                         ddf * (g x * g x * inv (g x pow 3))`)))(thm_tac (new_rewrite [] []))));
2045    ((fun arg_tac -> arg_tac (Arg_term (`g x * inv (g x pow 3) = inv (g x pow 2)`))) (term_tac (have_gen_tac [](((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] [])))))));
2046    (((((fun arg_tac -> arg_tac (Arg_theorem (ARITH_RULE `3 = SUC 2`)))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "real_powS")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_INV_MUL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_MUL_ASSOC")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_MUL_RINV")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "REAL_MUL_LID")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
2047    ((fun arg_tac -> arg_tac (Arg_term (`g x * inv (g x pow 2) = inv (g x)`))) (term_tac (have_gen_tac [](((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] [])))))));
2048    (((((use_arg_then "TWO")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "real_powS")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_INV_MUL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_MUL_ASSOC")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_MUL_RINV")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "REAL_MUL_LID")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_POW_1")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
2049    (((((fun arg_tac -> (use_arg_then "REAL_POW_2") (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`g x`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "lhs_def")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
2050 ];;
2051
2052 (* Lemma diff2_div *)
2053 let diff2_div = section_proof ["f";"g";"x"]
2054 `~(g x = &0) ==> nth_diff_strong 2 f x ==> nth_diff_strong 2 g x ==>
2055         nth_diff_strong 2 (\x. f x / g x) x`
2056 [
2057    ((BETA_TAC THEN (move ["gn0"]) THEN (move ["df0"]) THEN (move ["dg0"])) THEN ((fun arg_tac -> arg_tac (Arg_term (`(x,x)`))) (term_tac (set_tac "int"))));
2058    ((fun arg_tac -> arg_tac (Arg_term (`interval_arith x int /\ nth_diff_strong_int 2 int f /\ nth_diff_strong_int 2 int g`))) (term_tac (have_gen_tac [](case THEN ((move ["ineq"]) THEN (case THEN ((move ["df"]) THEN (move ["dg"]))))))));
2059    ((repeat_tactic 1 9 (((use_arg_then "int_def")(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (repeat_tactic 1 9 (((use_arg_then "nth_diff_strong_int")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "CONST_INTERVAL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))));
2060    (((split_tac) THEN (move ["y"])) THEN (((((use_arg_then "interval_arith")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_LE_ANTISYM")(thm_tac (new_rewrite [] []))))) THEN (((conv_thm_tac DISCH_THEN)(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (done_tac));
2061    ((fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (use_arg_then "nth_diff_mul") (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`2`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "int") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "f") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`\x. inv (g x)`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "df") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun arg -> thm_tac MP_TAC arg THEN ALL_TAC));
2062    ((((repeat_tactic 1 9 (((use_arg_then "nth_diff_strong_int")(thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (((use_arg_then "real_div")(thm_tac (new_rewrite [] []))))) THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))) THEN ((split_tac) THEN ((TRY done_tac)) THEN (move ["y"])));
2063    (((((use_arg_then "int_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "interval_arith")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_LE_ANTISYM")(thm_tac (new_rewrite [] []))))) THEN (((conv_thm_tac DISCH_THEN)(gsym_then (thm_tac (new_rewrite [] []))))));
2064    ((((use_arg_then "diff2_compose_inv")(thm_tac (new_rewrite [] [])))) THEN (done_tac));
2065 ];;
2066
2067 (* Lemma second_derivative_scale *)
2068 let second_derivative_scale = section_proof ["f";"c";"x"]
2069 `nth_diff_strong 2 f x ==>
2070         nth_derivative 2 (\x. c * f x) x = c * nth_derivative 2 f x`
2071 [
2072    ((BETA_TAC THEN (move ["df0"])) THEN ((fun arg_tac -> arg_tac (Arg_term (`(x,x)`))) (term_tac (set_tac "int"))));
2073    ((fun arg_tac -> arg_tac (Arg_term (`interval_arith x int /\ nth_diff_strong_int 2 int f`))) (term_tac (have_gen_tac [](case THEN ((move ["ineq"]) THEN (move ["df"]))))));
2074    ((repeat_tactic 1 9 (((use_arg_then "int_def")(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (repeat_tactic 1 9 (((use_arg_then "nth_diff_strong_int")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "CONST_INTERVAL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))));
2075    ((BETA_TAC THEN (move ["y"])) THEN (((((use_arg_then "interval_arith")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_LE_ANTISYM")(thm_tac (new_rewrite [] []))))) THEN (((conv_thm_tac DISCH_THEN)(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (done_tac));
2076    (((fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (use_arg_then "nth_derivative_scale") (fun fst_arg -> (use_arg_then "df") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "c") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`2`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "ineq") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun arg -> thm_tac MP_TAC arg THEN ALL_TAC)) THEN ((((use_arg_then "leqnn")(thm_tac (new_rewrite [] [])))) THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))) THEN (done_tac));
2077 ];;
2078
2079 (* Lemma second_derivative_add *)
2080 let second_derivative_add = section_proof ["f";"g";"x"]
2081 `nth_diff_strong 2 f x ==>
2082         nth_diff_strong 2 g x ==>
2083         nth_derivative 2 (\x. f x + g x) x = nth_derivative 2 f x + nth_derivative 2 g x`
2084 [
2085    ((BETA_TAC THEN (move ["df0"]) THEN (move ["dg0"])) THEN ((fun arg_tac -> arg_tac (Arg_term (`(x,x)`))) (term_tac (set_tac "int"))));
2086    ((fun arg_tac -> arg_tac (Arg_term (`interval_arith x int /\ nth_diff_strong_int 2 int f /\ nth_diff_strong_int 2 int g`))) (term_tac (have_gen_tac [](case THEN ((move ["ineq"]) THEN (case THEN ((move ["df"]) THEN (move ["dg"]))))))));
2087    ((repeat_tactic 1 9 (((use_arg_then "int_def")(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (repeat_tactic 1 9 (((use_arg_then "nth_diff_strong_int")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "CONST_INTERVAL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))));
2088    (((split_tac) THEN (move ["y"])) THEN (((((use_arg_then "interval_arith")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_LE_ANTISYM")(thm_tac (new_rewrite [] []))))) THEN (((conv_thm_tac DISCH_THEN)(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (done_tac));
2089    (((fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (use_arg_then "nth_derivative_add") (fun fst_arg -> (use_arg_then "df") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "dg") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`2`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "ineq") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun arg -> thm_tac MP_TAC arg THEN ALL_TAC)) THEN ((((use_arg_then "leqnn")(thm_tac (new_rewrite [] [])))) THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))) THEN (done_tac));
2090 ];;
2091
2092 (* Lemma second_derivative_sub *)
2093 let second_derivative_sub = section_proof ["f";"g";"x"]
2094 `nth_diff_strong 2 f x ==>
2095         nth_diff_strong 2 g x ==>
2096         nth_derivative 2 (\x. f x - g x) x = nth_derivative 2 f x - nth_derivative 2 g x`
2097 [
2098    ((BETA_TAC THEN (move ["df0"]) THEN (move ["dg0"])) THEN ((fun arg_tac -> arg_tac (Arg_term (`(x,x)`))) (term_tac (set_tac "int"))));
2099    ((fun arg_tac -> arg_tac (Arg_term (`interval_arith x int /\ nth_diff_strong_int 2 int f /\ nth_diff_strong_int 2 int g`))) (term_tac (have_gen_tac [](case THEN ((move ["ineq"]) THEN (case THEN ((move ["df"]) THEN (move ["dg"]))))))));
2100    ((repeat_tactic 1 9 (((use_arg_then "int_def")(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (repeat_tactic 1 9 (((use_arg_then "nth_diff_strong_int")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "CONST_INTERVAL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))));
2101    (((split_tac) THEN (move ["y"])) THEN (((((use_arg_then "interval_arith")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_LE_ANTISYM")(thm_tac (new_rewrite [] []))))) THEN (((conv_thm_tac DISCH_THEN)(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (done_tac));
2102    (((fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (use_arg_then "nth_derivative_sub") (fun fst_arg -> (use_arg_then "df") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "dg") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`2`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "ineq") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun arg -> thm_tac MP_TAC arg THEN ALL_TAC)) THEN ((((use_arg_then "leqnn")(thm_tac (new_rewrite [] [])))) THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))) THEN (done_tac));
2103 ];;
2104
2105 (* Lemma second_derivative_compose_bounds *)
2106 let second_derivative_compose_bounds = section_proof ["f";"g";"int";"g_bounds";"dd_bounds"]
2107 `nth_diff_strong_int 2 int g ==>
2108         bounded_on_int g int g_bounds ==>
2109         nth_diff_strong_int 2 g_bounds f ==>
2110         bounded_on_int (\x. nth_derivative 2 f (g x) * derivative g x pow 2 + 
2111                         derivative f (g x) * nth_derivative 2 g x) int dd_bounds ==>
2112         has_bounded_second_derivative (\x. f (g x)) int dd_bounds`
2113 [
2114    ((((use_arg_then "has_bounded_second_derivative")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "bounded_on_int")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "nth_diff_strong_int")(thm_tac (new_rewrite [] []))))) THEN (simp_tac));
2115    ((BETA_TAC THEN (move ["dg"]) THEN (move ["g_bounded"]) THEN (move ["df"]) THEN (move ["bounded"])) THEN ((split_tac) THEN (move ["x"]) THEN (move ["ineq"])));
2116    (((((use_arg_then "diff2_compose")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "dg")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "df")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "g_bounded")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
2117    (((((use_arg_then "second_derivative_compose")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "dg")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "df")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "g_bounded")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((use_arg_then "bounded")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
2118 ];;
2119
2120 (* Lemma second_derivative_atn_bounds *)
2121 let second_derivative_atn_bounds = section_proof ["dd_bounds"]
2122 `bounded_on_int (\x. (-- &2 * x) * inv(&1 + x pow 2) pow 2) int dd_bounds ==>
2123         has_bounded_second_derivative atn int dd_bounds`
2124 [
2125    (((((use_arg_then "bounded_on_int")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "has_bounded_second_derivative")(thm_tac (new_rewrite [] []))))) THEN (move ["ineq"]));
2126    ((THENL_LAST) (split_tac) (((((use_arg_then "nth_derivative2")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "second_derivative_atn")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "bounded_on_int")(thm_tac (new_rewrite [] []))))) THEN (done_tac)));
2127    (((((use_arg_then "nth_diff_strong_int")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "diff2_atn")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
2128 ];;
2129
2130 (* Lemma second_derivative_compose_atn_bounds *)
2131 let second_derivative_compose_atn_bounds = section_proof ["f";"dd_bounds"]
2132 `nth_diff_strong_int 2 int f ==>
2133         bounded_on_int (\x. (nth_derivative 2 f x * (&1 + f x * f x) - &2 * f x * derivative f x pow 2) /
2134                         (&1 + f x * f x) pow 2) int dd_bounds ==>
2135         has_bounded_second_derivative (\x. atn (f x)) int dd_bounds`
2136 [
2137    ((((((use_arg_then "has_bounded_second_derivative")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "bounded_on_int")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "nth_diff_strong_int")(thm_tac (new_rewrite [] []))))) THEN (simp_tac)) THEN (move ["df"]) THEN (move ["bounded"])) THEN ((split_tac) THEN (move ["x"]) THEN (move ["ineq"])));
2138    (((((use_arg_then "diff2_compose_atn")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "df")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
2139    (((((use_arg_then "second_derivative_compose_atn")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "df")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((use_arg_then "bounded")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
2140 ];;
2141
2142 (* Lemma second_derivative_inv_bounds *)
2143 let second_derivative_inv_bounds = section_proof ["dd_bounds"]
2144 `interval_not_zero int ==>
2145         bounded_on_int (\x. &2 * inv (x pow 3)) int dd_bounds ==>
2146         has_bounded_second_derivative inv int dd_bounds`
2147 [
2148    ((((((use_arg_then "has_bounded_second_derivative")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "bounded_on_int")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "nth_diff_strong_int")(thm_tac (new_rewrite [] []))))) THEN (simp_tac)) THEN (move ["int0"]) THEN (move ["bounded"])) THEN ((split_tac) THEN (move ["x"]) THEN (move ["ineq"])));
2149    (((((use_arg_then "diff2_inv")(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> (fun arg_tac -> (use_arg_then "interval_arith_not_zero") (fun fst_arg -> (use_arg_then "x") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "int") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] []))))) THEN (done_tac));
2150    (((((use_arg_then "second_derivative_inv")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((fun arg_tac -> (fun arg_tac -> (use_arg_then "interval_arith_not_zero") (fun fst_arg -> (use_arg_then "x") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "int") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((use_arg_then "bounded")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
2151 ];;
2152
2153 (* Lemma second_derivative_compose_inv_bounds *)
2154 let second_derivative_compose_inv_bounds = section_proof ["f";"f_bounds";"dd_bounds"]
2155 `bounded_on_int f int f_bounds ==> interval_not_zero f_bounds ==>
2156         nth_diff_strong_int 2 int f ==>
2157         bounded_on_int (\x. (&2 * derivative f x pow 2 - nth_derivative 2 f x * f x) / f x pow 3) 
2158                         int dd_bounds ==>
2159         has_bounded_second_derivative (\x. inv (f x)) int dd_bounds`
2160 [
2161    (((((use_arg_then "has_bounded_second_derivative")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "bounded_on_int")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "nth_diff_strong_int")(thm_tac (new_rewrite [] []))))) THEN (simp_tac)) THEN (move ["f_bounded"]) THEN (move ["f0"]) THEN (move ["df"]) THEN (move ["bounded"]));
2162    ((fun arg_tac -> arg_tac (Arg_term (`!x. interval_arith x int ==> ~(f x = &0)`))) (term_tac (have_gen_tac [](move ["fn0"]))));
2163    ((BETA_TAC THEN (move ["x"]) THEN (move ["ineq"])) THEN ((((fun arg_tac -> (fun arg_tac -> (use_arg_then "interval_arith_not_zero") (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`f x`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "f_bounds") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "f_bounded")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
2164    ((split_tac) THEN (move ["x"]) THEN (move ["ineq"]));
2165    (((((use_arg_then "diff2_compose_inv")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "df")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "fn0")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
2166    (((((use_arg_then "second_derivative_compose_inv")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "df")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "fn0")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((use_arg_then "bounded")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
2167 ];;
2168
2169 (* Lemma second_derivative_sqrt_bounds *)
2170 let second_derivative_sqrt_bounds = section_proof ["dd_bounds"]
2171 `interval_pos int ==>
2172         bounded_on_int (\x. --inv (&4 * sqrt (x pow 3))) int dd_bounds ==>
2173         has_bounded_second_derivative sqrt int dd_bounds`
2174 [
2175    (((((use_arg_then "has_bounded_second_derivative")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "bounded_on_int")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "nth_diff_strong_int")(thm_tac (new_rewrite [] []))))) THEN (simp_tac)) THEN (move ["int_pos"]) THEN (move ["bounded"]));
2176    ((split_tac) THEN (move ["x"]) THEN (move ["ineq"]));
2177    (((((use_arg_then "diff2_sqrt")(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> (fun arg_tac -> (use_arg_then "interval_arith_pos") (fun fst_arg -> (use_arg_then "x") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "int") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] []))))) THEN (done_tac));
2178    (((((use_arg_then "second_derivative_sqrt")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((fun arg_tac -> (fun arg_tac -> (use_arg_then "interval_arith_pos") (fun fst_arg -> (use_arg_then "x") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "int") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((use_arg_then "bounded")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
2179 ];;
2180
2181 (* Lemma second_derivative_compose_sqrt_bounds *)
2182 let second_derivative_compose_sqrt_bounds = section_proof ["f";"f_bounds";"dd_bounds"]
2183 `bounded_on_int f int f_bounds ==> interval_pos f_bounds ==>
2184         nth_diff_strong_int 2 int f ==>
2185         bounded_on_int (\x. (&2 * nth_derivative 2 f x * f x - derivative f x pow 2) /
2186                         (&4 * sqrt (f x pow 3))) 
2187                         int dd_bounds ==>
2188         has_bounded_second_derivative (\x. sqrt (f x)) int dd_bounds`
2189 [
2190    (((((use_arg_then "has_bounded_second_derivative")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "bounded_on_int")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "nth_diff_strong_int")(thm_tac (new_rewrite [] []))))) THEN (simp_tac)) THEN (move ["f_bounded"]) THEN (move ["f_int"]) THEN (move ["df"]) THEN (move ["bounded"]));
2191    ((fun arg_tac -> arg_tac (Arg_term (`!x. interval_arith x int ==> &0 < f x`))) (term_tac (have_gen_tac [](move ["f_pos"]))));
2192    ((BETA_TAC THEN (move ["x"]) THEN (move ["ineq"])) THEN ((((fun arg_tac -> (fun arg_tac -> (use_arg_then "interval_arith_pos") (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`f x`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "f_bounds") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "f_bounded")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
2193    ((split_tac) THEN (move ["x"]) THEN (move ["ineq"]));
2194    (((((use_arg_then "diff2_compose_sqrt")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "df")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "f_pos")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
2195    (((((use_arg_then "second_derivative_compose_sqrt")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "df")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "f_pos")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((use_arg_then "bounded")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
2196 ];;
2197
2198 (* Lemma second_derivative_acs_bounds *)
2199 let second_derivative_acs_bounds = section_proof ["dd_bounds"]
2200 `iabs int < &1 ==>
2201         bounded_on_int (\x. --(x / sqrt ((&1 - x * x) pow 3))) int dd_bounds ==>
2202         has_bounded_second_derivative acs int dd_bounds`
2203 [
2204    (((((use_arg_then "has_bounded_second_derivative")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "bounded_on_int")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "nth_diff_strong_int")(thm_tac (new_rewrite [] []))))) THEN (simp_tac)) THEN (move ["int_abs"]) THEN (move ["bounded"]));
2205    ((split_tac) THEN (move ["x"]) THEN (move ["ineq"]));
2206    (((((use_arg_then "diff2_acs")(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> (fun arg_tac -> (use_arg_then "interval_arith_abs") (fun fst_arg -> (use_arg_then "x") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "int") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] []))))) THEN (done_tac));
2207    (((((use_arg_then "second_derivative_acs")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((fun arg_tac -> (fun arg_tac -> (use_arg_then "interval_arith_abs") (fun fst_arg -> (use_arg_then "x") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "int") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((use_arg_then "bounded")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
2208 ];;
2209
2210 (* Lemma second_derivative_compose_acs_bounds *)
2211 let second_derivative_compose_acs_bounds = section_proof ["f";"f_bounds";"dd_bounds"]
2212 `bounded_on_int f int f_bounds ==> iabs f_bounds < &1 ==>
2213         nth_diff_strong_int 2 int f ==>
2214         bounded_on_int (\x. --((nth_derivative 2 f x * (&1 - f x * f x) + f x * derivative f x pow 2) /
2215                                 sqrt ((&1 - f x * f x) pow 3))) int dd_bounds ==>
2216         has_bounded_second_derivative (\x. acs (f x)) int dd_bounds`
2217 [
2218    (((((use_arg_then "has_bounded_second_derivative")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "bounded_on_int")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "nth_diff_strong_int")(thm_tac (new_rewrite [] []))))) THEN (simp_tac)) THEN (move ["f_bounded"]) THEN (move ["f_abs"]) THEN (move ["df"]) THEN (move ["bounded"]));
2219    ((fun arg_tac -> arg_tac (Arg_term (`!x. interval_arith x int ==> abs (f x) < &1`))) (term_tac (have_gen_tac [](move ["fabs"]))));
2220    ((BETA_TAC THEN (move ["x"]) THEN (move ["ineq"])) THEN ((((fun arg_tac -> (fun arg_tac -> (use_arg_then "interval_arith_abs") (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`f x`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "f_bounds") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "f_bounded")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
2221    ((split_tac) THEN (move ["x"]) THEN (move ["ineq"]));
2222    (((((use_arg_then "diff2_compose_acs")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "df")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "fabs")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
2223    (((((use_arg_then "second_derivative_compose_acs")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "df")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "fabs")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((use_arg_then "bounded")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
2224 ];;
2225
2226 (* Lemma second_derivative_scale_bounds *)
2227 let second_derivative_scale_bounds = section_proof ["c";"f";"dd_bounds"]
2228 `nth_diff_strong_int 2 int f ==>
2229         bounded_on_int (\x. c * nth_derivative 2 f x) int dd_bounds ==>
2230         has_bounded_second_derivative (\x. c * f x) int dd_bounds`
2231 [
2232    (((((use_arg_then "has_bounded_second_derivative")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "bounded_on_int")(thm_tac (new_rewrite [] [])))))) THEN (simp_tac) THEN (move ["df"]) THEN (move ["b"]));
2233    (((((use_arg_then "nth_diff_scale")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))) THEN (move ["x"]) THEN (move ["ineq"]));
2234    ((((use_arg_then "second_derivative_scale")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "b")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)));
2235    ((((use_arg_then "df") (disch_tac [])) THEN (clear_assumption "df") THEN BETA_TAC) THEN (((use_arg_then "nth_diff_strong_int")(thm_tac (new_rewrite [] [])))) THEN (exact_tac) THEN (done_tac));
2236 ];;
2237
2238 (* Lemma second_derivative_add_bounds *)
2239 let second_derivative_add_bounds = section_proof ["f";"g";"dd_bounds"]
2240 `nth_diff_strong_int 2 int f ==>
2241         nth_diff_strong_int 2 int g ==>
2242         bounded_on_int (\x. nth_derivative 2 f x + nth_derivative 2 g x) int dd_bounds ==>
2243         has_bounded_second_derivative (\x. f x + g x) int dd_bounds`
2244 [
2245    (((((use_arg_then "has_bounded_second_derivative")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "bounded_on_int")(thm_tac (new_rewrite [] [])))))) THEN (simp_tac) THEN (move ["df"]) THEN (move ["dg"]) THEN (move ["b"]));
2246    (((((use_arg_then "nth_diff_add")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))) THEN (move ["x"]) THEN (move ["ineq"]));
2247    ((((use_arg_then "second_derivative_add")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "b")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)));
2248    ((((use_arg_then "dg") (disch_tac [])) THEN (clear_assumption "dg") THEN ((use_arg_then "df") (disch_tac [])) THEN (clear_assumption "df") THEN BETA_TAC) THEN ((repeat_tactic 1 9 (((use_arg_then "nth_diff_strong_int")(thm_tac (new_rewrite [] []))))) THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))) THEN (done_tac));
2249 ];;
2250
2251 (* Lemma second_derivative_sub_bounds *)
2252 let second_derivative_sub_bounds = section_proof ["f";"g";"dd_bounds"]
2253 `nth_diff_strong_int 2 int f ==>
2254         nth_diff_strong_int 2 int g ==>
2255         bounded_on_int (\x. nth_derivative 2 f x - nth_derivative 2 g x) int dd_bounds ==>
2256         has_bounded_second_derivative (\x. f x - g x) int dd_bounds`
2257 [
2258    (((((use_arg_then "has_bounded_second_derivative")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "bounded_on_int")(thm_tac (new_rewrite [] [])))))) THEN (simp_tac) THEN (move ["df"]) THEN (move ["dg"]) THEN (move ["b"]));
2259    (((((use_arg_then "nth_diff_sub")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))) THEN (move ["x"]) THEN (move ["ineq"]));
2260    ((((use_arg_then "second_derivative_sub")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "b")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)));
2261    ((((use_arg_then "dg") (disch_tac [])) THEN (clear_assumption "dg") THEN ((use_arg_then "df") (disch_tac [])) THEN (clear_assumption "df") THEN BETA_TAC) THEN ((repeat_tactic 1 9 (((use_arg_then "nth_diff_strong_int")(thm_tac (new_rewrite [] []))))) THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))) THEN (done_tac));
2262 ];;
2263
2264 (* Lemma second_derivative_mul_bounds *)
2265 let second_derivative_mul_bounds = section_proof ["f";"g";"dd_bounds"]
2266 `nth_diff_strong_int 2 int f ==>
2267         nth_diff_strong_int 2 int g ==>
2268         bounded_on_int (\x. f x * nth_derivative 2 g x + &2 * derivative f x * derivative g x +
2269                         nth_derivative 2 f x * g x) int dd_bounds ==>
2270         has_bounded_second_derivative (\x. f x * g x) int dd_bounds`
2271 [
2272    (((((use_arg_then "has_bounded_second_derivative")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "bounded_on_int")(thm_tac (new_rewrite [] [])))))) THEN (simp_tac) THEN (move ["df"]) THEN (move ["dg"]) THEN (move ["b"]));
2273    (((((use_arg_then "nth_diff_mul")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))) THEN (move ["x"]) THEN (move ["ineq"]));
2274    ((((use_arg_then "second_derivative_mul")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "b")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)));
2275    ((((use_arg_then "dg") (disch_tac [])) THEN (clear_assumption "dg") THEN ((use_arg_then "df") (disch_tac [])) THEN (clear_assumption "df") THEN BETA_TAC) THEN ((repeat_tactic 1 9 (((use_arg_then "nth_diff_strong_int")(thm_tac (new_rewrite [] []))))) THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))) THEN (done_tac));
2276 ];;
2277
2278 (* Lemma second_derivative_div_bounds *)
2279 let second_derivative_div_bounds = section_proof ["f";"g";"g_bounds";"dd_bounds"]
2280 `bounded_on_int g int g_bounds ==> interval_not_zero g_bounds ==>
2281         nth_diff_strong_int 2 int f ==>
2282         nth_diff_strong_int 2 int g ==>
2283         bounded_on_int (\x. ((nth_derivative 2 f x * g x - f x * nth_derivative 2 g x) * g x -
2284           &2 * derivative g x * (derivative f x * g x - f x * derivative g x)) / g x pow 3) int dd_bounds ==>
2285         has_bounded_second_derivative (\x. f x / g x) int dd_bounds`
2286 [
2287    (((((use_arg_then "has_bounded_second_derivative")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "bounded_on_int")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "nth_diff_strong_int")(thm_tac (new_rewrite [] [])))))) THEN (move ["bg"]) THEN (move ["gn0"]) THEN (simp_tac) THEN (move ["df"]) THEN (move ["dg"]) THEN (move ["b"]));
2288    ((fun arg_tac -> arg_tac (Arg_term (`!x. interval_arith x int ==> ~(g x = &0)`))) (term_tac (have_gen_tac [](move ["g0"]))));
2289    ((BETA_TAC THEN (move ["x"]) THEN (move ["ineq"])) THEN (((use_arg_then "interval_arith_not_zero") (disch_tac [])) THEN (clear_assumption "interval_arith_not_zero") THEN (DISCH_THEN apply_tac)) THEN ((fun arg_tac -> arg_tac (Arg_term (`g_bounds`))) (term_tac exists_tac)) THEN (((use_arg_then "bg")(thm_tac (new_rewrite [] [])))) THEN (done_tac));
2290    ((THENL_FIRST) ((split_tac) THEN (move ["x"]) THEN (move ["ineq"])) (((((use_arg_then "diff2_div")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "g0")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "df")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "dg")(thm_tac (new_rewrite [] [])))))) THEN (done_tac)));
2291    (((((use_arg_then "second_derivative_div")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "g0")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "df")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "dg")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((use_arg_then "b")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
2292 ];;
2293
2294 (* Finalization of the section SecondDerivativeBound *)
2295 let nth_diff_strong2_eq_alt = finalize_theorem nth_diff_strong2_eq_alt;;
2296 let nth_diff_strong2_eq = finalize_theorem nth_diff_strong2_eq;;
2297 let lin_approx_compose = finalize_theorem lin_approx_compose;;
2298 let second_derivative_atn_eq = finalize_theorem second_derivative_atn_eq;;
2299 let second_derivative_atn = finalize_theorem second_derivative_atn;;
2300 let diff2_atn = finalize_theorem diff2_atn;;
2301 let second_derivative_inv = finalize_theorem second_derivative_inv;;
2302 let diff2_inv = finalize_theorem diff2_inv;;
2303 let SQRT_POW = finalize_theorem SQRT_POW;;
2304 let second_derivative_sqrt = finalize_theorem second_derivative_sqrt;;
2305 let diff2_sqrt = finalize_theorem diff2_sqrt;;
2306 let real_powS = finalize_theorem real_powS;;
2307 let second_derivative_acs = finalize_theorem second_derivative_acs;;
2308 let diff2_acs = finalize_theorem diff2_acs;;
2309 let REAL_CONTINUOUS_OPEN_PREIMAGE = finalize_theorem REAL_CONTINUOUS_OPEN_PREIMAGE;;
2310 let second_derivative_compose = finalize_theorem second_derivative_compose;;
2311 let diff2_compose = finalize_theorem diff2_compose;;
2312 let continuous_not0_exists_open = finalize_theorem continuous_not0_exists_open;;
2313 let continuous_gt_exists_open = finalize_theorem continuous_gt_exists_open;;
2314 let continuous_lt_exists_open = finalize_theorem continuous_lt_exists_open;;
2315 let second_derivative_compose_atn = finalize_theorem second_derivative_compose_atn;;
2316 let second_derivative_compose_inv = finalize_theorem second_derivative_compose_inv;;
2317 let second_derivative_compose_sqrt = finalize_theorem second_derivative_compose_sqrt;;
2318 let second_derivative_compose_acs = finalize_theorem second_derivative_compose_acs;;
2319 let diff2_compose_atn = finalize_theorem diff2_compose_atn;;
2320 let diff2_compose_inv = finalize_theorem diff2_compose_inv;;
2321 let diff2_compose_sqrt = finalize_theorem diff2_compose_sqrt;;
2322 let diff2_compose_acs = finalize_theorem diff2_compose_acs;;
2323 let second_derivative_mul = finalize_theorem second_derivative_mul;;
2324 let second_derivative_div = finalize_theorem second_derivative_div;;
2325 let diff2_div = finalize_theorem diff2_div;;
2326 let second_derivative_scale = finalize_theorem second_derivative_scale;;
2327 let second_derivative_add = finalize_theorem second_derivative_add;;
2328 let second_derivative_sub = finalize_theorem second_derivative_sub;;
2329 let second_derivative_compose_bounds = finalize_theorem second_derivative_compose_bounds;;
2330 let second_derivative_atn_bounds = finalize_theorem second_derivative_atn_bounds;;
2331 let second_derivative_compose_atn_bounds = finalize_theorem second_derivative_compose_atn_bounds;;
2332 let second_derivative_inv_bounds = finalize_theorem second_derivative_inv_bounds;;
2333 let second_derivative_compose_inv_bounds = finalize_theorem second_derivative_compose_inv_bounds;;
2334 let second_derivative_sqrt_bounds = finalize_theorem second_derivative_sqrt_bounds;;
2335 let second_derivative_compose_sqrt_bounds = finalize_theorem second_derivative_compose_sqrt_bounds;;
2336 let second_derivative_acs_bounds = finalize_theorem second_derivative_acs_bounds;;
2337 let second_derivative_compose_acs_bounds = finalize_theorem second_derivative_compose_acs_bounds;;
2338 let second_derivative_scale_bounds = finalize_theorem second_derivative_scale_bounds;;
2339 let second_derivative_add_bounds = finalize_theorem second_derivative_add_bounds;;
2340 let second_derivative_sub_bounds = finalize_theorem second_derivative_sub_bounds;;
2341 let second_derivative_mul_bounds = finalize_theorem second_derivative_mul_bounds;;
2342 let second_derivative_div_bounds = finalize_theorem second_derivative_div_bounds;;
2343 end_section "SecondDerivativeBound";;
2344
2345 (* Section TaylorArith *)
2346 begin_section "TaylorArith";;
2347 let cell_domain = new_definition `cell_domain x y z w <=> 
2348         x <= y /\ y <= z /\ y - x <= w /\ z - y <= w`;;
2349
2350 (* Lemma taylor_x *)
2351 let taylor_x = section_proof ["x";"y";"z";"w"]
2352 `cell_domain x y z w ==>
2353         taylor_interval (\x. x) x y z w (y, y) (&1, &1) (&0, &0)`
2354 [
2355    ((((use_arg_then "cell_domain")(thm_tac (new_rewrite [] [])))) THEN (move ["ineqs"]));
2356    ((((use_arg_then "taylor_interval")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "ineqs")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "lin_approx_x")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))));
2357    (((use_arg_then "has_bounded_second_derivative")(thm_tac (new_rewrite [] []))));
2358    (((((use_arg_then "nth_diff_strong_int")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "nth_diff_strong")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "nth_differentiable_on")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "nth_differentiable_eq")(thm_tac (new_rewrite [] []))))) THEN (split_tac));
2359    ((BETA_TAC THEN (move ["p"]) THEN (move ["_"])) THEN ((fun arg_tac -> arg_tac (Arg_term (`(:real)`))) (term_tac exists_tac)) THEN (((((use_arg_then "REAL_OPEN_UNIV")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "IN_UNIV")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))))) THEN (move ["q"]) THEN (simp_tac)));
2360    (((((use_arg_then "REAL_CONTINUOUS_AT_ID")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))) THEN (move ["i"]));
2361    ((((fun arg_tac -> arg_tac (Arg_theorem (ARITH_RULE `i < 2 <=> i = 0 \/ i = 1`)))(thm_tac (new_rewrite [] [])))) THEN (case THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))));
2362    (((((use_arg_then "nth_derivative0")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "ONE")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "nth_derivative1")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "derivative_x")(thm_tac (new_rewrite [] [])))) THEN (simp_tac) THEN (((use_arg_then "HAS_REAL_DERIVATIVE_ID")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
2363    ((((use_arg_then "nth_derivative1")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "TWO")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "nth_derivative2")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "derivative_x")(thm_tac (new_rewrite [] [])))) THEN (simp_tac) THEN (((use_arg_then "derivative_const")(thm_tac (new_rewrite [] [])))) THEN (simp_tac));
2364    ((((use_arg_then "HAS_REAL_DERIVATIVE_CONST")(thm_tac (new_rewrite [] [])))) THEN (done_tac));
2365    ((((use_arg_then "nth_derivative2")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "derivative_x")(thm_tac (new_rewrite [] [])))) THEN (simp_tac) THEN (((use_arg_then "derivative_const")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "bounded_on_int")(thm_tac (new_rewrite [] [])))) THEN (simp_tac));
2366    (((repeat_tactic 1 9 (((use_arg_then "interval_arith")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "REAL_LE_REFL")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
2367 ];;
2368
2369 (* Lemma taylor_const *)
2370 let taylor_const = section_proof ["c";"x";"y";"z";"w"]
2371 `cell_domain x y z w ==>
2372         taylor_interval (\x. c) x y z w (c, c) (&0, &0) (&0, &0)`
2373 [
2374    ((((use_arg_then "cell_domain")(thm_tac (new_rewrite [] [])))) THEN (move ["ineqs"]));
2375    ((((use_arg_then "taylor_interval")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "ineqs")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "lin_approx_const")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))));
2376    (((use_arg_then "has_bounded_second_derivative")(thm_tac (new_rewrite [] []))));
2377    (((((use_arg_then "nth_diff_strong_int")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "nth_diff_strong")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "nth_differentiable_on")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "nth_differentiable_eq")(thm_tac (new_rewrite [] []))))) THEN (split_tac));
2378    ((BETA_TAC THEN (move ["p"]) THEN (move ["_"])) THEN ((fun arg_tac -> arg_tac (Arg_term (`(:real)`))) (term_tac exists_tac)) THEN (((((use_arg_then "REAL_OPEN_UNIV")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "IN_UNIV")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))))) THEN (move ["q"]) THEN (simp_tac)));
2379    (((((use_arg_then "REAL_CONTINUOUS_CONST")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))) THEN (move ["i"]));
2380    ((((fun arg_tac -> arg_tac (Arg_theorem (ARITH_RULE `i < 2 <=> i = 0 \/ i = 1`)))(thm_tac (new_rewrite [] [])))) THEN (case THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))));
2381    (((((use_arg_then "nth_derivative0")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "ONE")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "nth_derivative1")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "derivative_const")(thm_tac (new_rewrite [] [])))) THEN (simp_tac) THEN (((use_arg_then "HAS_REAL_DERIVATIVE_CONST")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
2382    (((((use_arg_then "nth_derivative1")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "TWO")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "nth_derivative2")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "derivative_const")(thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (((use_arg_then "HAS_REAL_DERIVATIVE_CONST")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
2383    ((((use_arg_then "nth_derivative2")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "derivative_const")(thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (((use_arg_then "bounded_on_int")(thm_tac (new_rewrite [] [])))) THEN (simp_tac));
2384    (((repeat_tactic 1 9 (((use_arg_then "interval_arith")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "REAL_LE_REFL")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
2385 ];;
2386 (add_section_var (mk_var ("f", (`:real->real`))));;
2387 (add_section_var (mk_var ("x", (`:real`))); add_section_var (mk_var ("y", (`:real`))); add_section_var (mk_var ("z", (`:real`))); add_section_var (mk_var ("w", (`:real`))));;
2388 (add_section_var (mk_var ("f_bounds", (`:real#real`))); add_section_var (mk_var ("df_bounds", (`:real#real`))); add_section_var (mk_var ("dd_bounds", (`:real#real`))));;
2389 (add_section_var (mk_var ("f_lo", (`:real`))); add_section_var (mk_var ("f_hi", (`:real`))); add_section_var (mk_var ("df_lo", (`:real`))); add_section_var (mk_var ("df_hi", (`:real`))));;
2390
2391 (* Lemma taylor_f_bounds *)
2392 let taylor_f_bounds = section_proof ["df";"dd";"lo";"hi";"t"]
2393 `taylor_interval f x y z w (f_lo, f_hi) df_bounds dd_bounds ==>
2394         iabs df_bounds = df ==>
2395         iabs dd_bounds = dd ==>
2396         w * (df + w * dd * inv(&2)) <= t ==>
2397         f_hi + t <= hi ==> lo <= f_lo - t ==>
2398         bounded_on_int f (x, z) (lo, hi)`
2399 [
2400    (BETA_TAC THEN (move ["taylor_f"]) THEN (move ["iabs_df"]) THEN (move ["iabs_dd"]) THEN (move ["t_ineq"]) THEN (move ["hi_ineq"]) THEN (move ["lo_ineq"]));
2401    (((((use_arg_then "bounded_on_int")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "interval_arith")(thm_tac (new_rewrite [] [])))))) THEN (move ["p"]) THEN (move ["ineq"]));
2402    (((fun arg_tac -> (fun arg_tac -> (use_arg_then "taylor_upper_bound") (fun fst_arg -> (fun arg_tac -> (use_arg_then "EQ_SYM") (fun fst_arg -> (use_arg_then "iabs_dd") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "taylor_f") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN ((fun arg_tac -> (fun arg_tac -> (use_arg_then "taylor_lower_bound") (fun fst_arg -> (fun arg_tac -> (use_arg_then "EQ_SYM") (fun fst_arg -> (use_arg_then "iabs_dd") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "taylor_f") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC);
2403    (((simp_tac) THEN (repeat_tactic 1 9 (((use_arg_then "real_div")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "iabs_df")(thm_tac (new_rewrite [] []))))) THEN ((fun arg_tac ->  (conv_thm_tac DISCH_THEN)  (fun fst_arg -> (use_arg_then "ineq") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (thm_tac MP_TAC)) THEN (move ["ineq1"]) THEN ((fun arg_tac ->  (conv_thm_tac DISCH_THEN)  (fun fst_arg -> (use_arg_then "ineq") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (thm_tac MP_TAC)) THEN (move ["ineq2"]));
2404    ((((use_arg_then "t_ineq") (disch_tac [])) THEN (clear_assumption "t_ineq") THEN ((use_arg_then "hi_ineq") (disch_tac [])) THEN (clear_assumption "hi_ineq") THEN ((use_arg_then "lo_ineq") (disch_tac [])) THEN (clear_assumption "lo_ineq") THEN ((use_arg_then "ineq2") (disch_tac [])) THEN (clear_assumption "ineq2") THEN ((use_arg_then "ineq1") (disch_tac [])) THEN (clear_assumption "ineq1") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac));
2405 ];;
2406
2407 (* Lemma taylor_df_bounds *)
2408 let taylor_df_bounds = section_proof ["dd";"lo";"hi"]
2409 `taylor_interval f x y z w f_bounds (df_lo, df_hi) dd_bounds ==>
2410         iabs dd_bounds = dd ==>
2411         df_hi + w * dd <= hi ==>
2412         lo <= df_lo - w * dd ==>
2413         bounded_on_int (derivative f) (x, z) (lo, hi)`
2414 [
2415    (BETA_TAC THEN (move ["taylor_f"]) THEN (move ["iabs_dd"]) THEN (move ["hi_ineq"]) THEN (move ["lo_ineq"]));
2416    (((((use_arg_then "bounded_on_int")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "interval_arith")(thm_tac (new_rewrite [] [])))))) THEN (move ["p"]) THEN (move ["ineq"]));
2417    (((fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (use_arg_then "taylor_derivative_lower_bound") (fun fst_arg -> (fun arg_tac -> (use_arg_then "EQ_SYM") (fun fst_arg -> (use_arg_then "iabs_dd") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "taylor_f") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "ineq") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC);
2418    (((fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (use_arg_then "taylor_derivative_upper_bound") (fun fst_arg -> (fun arg_tac -> (use_arg_then "EQ_SYM") (fun fst_arg -> (use_arg_then "iabs_dd") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "taylor_f") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "ineq") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC);
2419    ((((use_arg_then "hi_ineq") (disch_tac [])) THEN (clear_assumption "hi_ineq") THEN ((use_arg_then "lo_ineq") (disch_tac [])) THEN (clear_assumption "lo_ineq") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac));
2420 ];;
2421
2422 (* Lemma bounded_on_int_compose *)
2423 let bounded_on_int_compose = section_proof ["g";"int";"g_bounds"]
2424 `bounded_on_int g int g_bounds ==>
2425         bounded_on_int f g_bounds f_bounds ==>
2426         bounded_on_int (\x. f (g x)) int f_bounds`
2427 [
2428    ((repeat_tactic 1 9 (((use_arg_then "bounded_on_int")(thm_tac (new_rewrite [] []))))) THEN (move ["g_bounded"]) THEN (move ["f_bounded"]) THEN (move ["x"]) THEN (move ["ineq"]) THEN (simp_tac));
2429    (((((use_arg_then "f_bounded")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "g_bounded")(thm_tac (new_rewrite [] []))))) THEN (done_tac));
2430 ];;
2431
2432 (* Lemma bounded_on_int_imp_interval_arith *)
2433 let bounded_on_int_imp_interval_arith = section_proof ["int"]
2434 `bounded_on_int f int f_bounds ==>
2435         interval_arith y int ==> interval_arith (f y) f_bounds`
2436 [
2437    ((((use_arg_then "bounded_on_int")(thm_tac (new_rewrite [] [])))) THEN (move ["bounded_f"]) THEN (move ["int_y"]));
2438    ((((use_arg_then "bounded_f")(thm_tac (new_rewrite [] [])))) THEN (done_tac));
2439 ];;
2440
2441 (* Lemma taylor_interval_narrow *)
2442 let taylor_interval_narrow = section_proof ["x0";"z0";"w0"]
2443 `taylor_interval f x y z w f_bounds df_bounds dd_bounds ==>
2444         cell_domain x0 y z0 w0 ==>
2445         x <= x0 ==> z0 <= z ==>
2446         taylor_interval f x0 y z0 w0 f_bounds df_bounds dd_bounds`
2447 [
2448    (((repeat_tactic 1 9 (((use_arg_then "taylor_interval")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "cell_domain")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "andbA")(thm_tac (new_rewrite [] [])))))) THEN ALL_TAC THEN (case THEN ((case THEN ((move ["ineq"]) THEN (move ["lin"]))) THEN (move ["dd"]))) THEN (move ["c"]) THEN (move ["i1"]) THEN (move ["i2"]));
2449    ((THENL_FIRST) (((((use_arg_then "lin")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andbT")(thm_tac (new_rewrite [] []))))) THEN (split_tac)) ((((use_arg_then "i2") (disch_tac [])) THEN (clear_assumption "i2") THEN ((use_arg_then "i1") (disch_tac [])) THEN (clear_assumption "i1") THEN ((use_arg_then "c") (disch_tac [])) THEN (clear_assumption "c") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac)));
2450    ((((use_arg_then "dd") (disch_tac [])) THEN (clear_assumption "dd") THEN BETA_TAC) THEN (((repeat_tactic 1 9 (((use_arg_then "has_bounded_second_derivative")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "nth_diff_strong_int")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "bounded_on_int")(thm_tac (new_rewrite [] [])))))) THEN (move ["df"])));
2451    ((split_tac) THEN (move ["p"]) THEN (move ["int_p"]));
2452    ((((use_arg_then "df")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "i2") (disch_tac [])) THEN (clear_assumption "i2") THEN ((use_arg_then "i1") (disch_tac [])) THEN (clear_assumption "i1") THEN ((use_arg_then "int_p") (disch_tac [])) THEN (clear_assumption "int_p") THEN BETA_TAC) THEN (repeat_tactic 1 9 (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL interval_arith)))(thm_tac (new_rewrite [] []))))) THEN (arith_tac) THEN (done_tac));
2453    ((((use_arg_then "df")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "i2") (disch_tac [])) THEN (clear_assumption "i2") THEN ((use_arg_then "i1") (disch_tac [])) THEN (clear_assumption "i1") THEN ((use_arg_then "int_p") (disch_tac [])) THEN (clear_assumption "int_p") THEN BETA_TAC) THEN (repeat_tactic 1 9 (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL interval_arith)))(thm_tac (new_rewrite [] []))))) THEN (arith_tac) THEN (done_tac));
2454 ];;
2455
2456 (* Finalization of the section TaylorArith *)
2457 let taylor_x = finalize_theorem taylor_x;;
2458 let taylor_const = finalize_theorem taylor_const;;
2459 let taylor_f_bounds = finalize_theorem taylor_f_bounds;;
2460 let taylor_df_bounds = finalize_theorem taylor_df_bounds;;
2461 let bounded_on_int_compose = finalize_theorem bounded_on_int_compose;;
2462 let bounded_on_int_imp_interval_arith = finalize_theorem bounded_on_int_imp_interval_arith;;
2463 let taylor_interval_narrow = finalize_theorem taylor_interval_narrow;;
2464 end_section "TaylorArith";;