needs "lib/ssrbool-compiled.hl";;
needs "lib/ssrnat-compiled.hl";;
needs "taylor/theory/taylor_interval-compiled.hl";;
prioritize_overload `:real^N`;;
prioritize_real();;
let partial = new_definition `partial i f x = derivative (f o (\t. (x:real^N) + t % basis i)) (&0)`;;
let all_n = define `(all_n n [] s <=> T) /\ (all_n n (CONS h t) s <=> s n h /\ all_n (SUC n) t s)`;;
let m_lin_approx = new_definition `m_lin_approx (f:real^N->real) x f_bounds df_bounds_list <=> 
	(lift o f) differentiable at x /\
	interval_arith (f x) f_bounds /\
	all_n 1 df_bounds_list (\i int. interval_arith (partial i f x) int)`;;
(* Section Misc *) begin_section "Misc";; (* Lemma f_lift_neg *) let f_lift_neg = section_proof ["f"] `lift o (\x. --f x) = (\x. --(lift o f) x)` [ (((((use_arg_then "eq_ext")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "o_THM")(thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (((use_arg_then "LIFT_NEG")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma f_lift_scale *) let f_lift_scale = section_proof ["f";"c"] `lift o (\x. c * f x) = (\x. c % (lift o f) x)` [ (((((use_arg_then "eq_ext")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "o_THM")(thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (((use_arg_then "LIFT_CMUL")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma f_lift_add *) let f_lift_add = section_proof ["f";"g"] `lift o (\x. f x + g x) = (\x. (lift o f) x + (lift o g) x)` [ (((((use_arg_then "eq_ext")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "o_THM")(thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (((use_arg_then "LIFT_ADD")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma f_lift_sub *) let f_lift_sub = section_proof ["f";"g"] `lift o (\x. f x - g x) = (\x. (lift o f) x - (lift o g) x)` [ (((((use_arg_then "eq_ext")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "o_THM")(thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (((use_arg_then "LIFT_SUB")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma f_binary_drop *) let f_binary_drop = section_proof ["op";"f";"g"] `(\t. op (f t) (g t)) o drop = (\x. op (f (drop x)) (g (drop x)))` [ (((((use_arg_then "eq_ext")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "o_THM")(thm_tac (new_rewrite [] [])))))) THEN (done_tac)); ];; (* Lemma f_unary_drop *) let f_unary_drop = section_proof ["op";"f"] `(\t. op (f t)) o drop = (\x. op (f (drop x)))` [ (((((use_arg_then "eq_ext")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "o_THM")(thm_tac (new_rewrite [] [])))))) THEN (done_tac)); ];; (* Section MoreFrechet *) begin_section "MoreFrechet";; (add_section_var (mk_var ("f", (`:real^N -> real^M`))); add_section_var (mk_var ("g", (`:real^N -> real^M`))));; (add_section_var (mk_var ("x", (`:real^N`))); add_section_var (mk_var ("y", (`:real^N`))));; (* Lemma frechet_compose *) let frechet_compose = section_proof ["f";"g";"x"] `f differentiable at (g x) ==> g differentiable at x ==> frechet_derivative (f o g) (at x) = frechet_derivative f (at (g x)) o frechet_derivative g (at x)` [ ((BETA_TAC THEN (move ["df"]) THEN (move ["dg"])) THEN (((use_arg_then "EQ_SYM_EQ")(thm_tac (new_rewrite [] [])))) THEN ((use_arg_then "FRECHET_DERIVATIVE_AT") (thm_tac apply_tac))); (((use_arg_then "DIFF_CHAIN_AT") (thm_tac apply_tac)) THEN (repeat_tactic 1 9 (((use_arg_then "FRECHET_DERIVATIVE_WORKS")(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (done_tac)); ];; (* Lemma frechet_const *) let frechet_const = section_proof ["z"] `frechet_derivative (\x. y) (at z) = (\x. vec 0)` [ ((((use_arg_then "EQ_SYM_EQ")(thm_tac (new_rewrite [] [])))) THEN ((use_arg_then "FRECHET_DERIVATIVE_AT") (thm_tac apply_tac)) THEN (((use_arg_then "HAS_DERIVATIVE_CONST")(thm_tac (new_rewrite [] [])))) THEN (done_tac)); ];; (* Lemma frechet_id *) let frechet_id = section_proof [] `frechet_derivative (\x. x) (at y) = (\x. x)` [ ((((use_arg_then "EQ_SYM_EQ")(thm_tac (new_rewrite [] [])))) THEN ((use_arg_then "FRECHET_DERIVATIVE_AT") (thm_tac apply_tac)) THEN (((use_arg_then "HAS_DERIVATIVE_ID")(thm_tac (new_rewrite [] [])))) THEN (done_tac)); ];; (* Lemma frechet_vmul *) let frechet_vmul = section_proof ["z"] `frechet_derivative (\x. drop x % y) (at z) = (\x. drop x % y)` [ ((((use_arg_then "EQ_SYM_EQ")(thm_tac (new_rewrite [] [])))) THEN ((use_arg_then "FRECHET_DERIVATIVE_AT") (thm_tac apply_tac)) THEN ((use_arg_then "HAS_DERIVATIVE_VMUL_DROP") (thm_tac apply_tac))); (((use_arg_then "HAS_DERIVATIVE_ID")(thm_tac (new_rewrite [] [])))); ];; (add_section_hyp "df" (`f differentiable at x`));; (* Lemma frechet_neg *) let frechet_neg = section_proof [] `frechet_derivative (\x. --f x) (at x) = (\y. --frechet_derivative f (at x) y)` [ ((((use_arg_then "EQ_SYM_EQ")(thm_tac (new_rewrite [] [])))) THEN ((use_arg_then "FRECHET_DERIVATIVE_AT") (thm_tac apply_tac)) THEN ((use_arg_then "HAS_DERIVATIVE_NEG") (thm_tac apply_tac))); ((((use_arg_then "ETA_AX")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN (((use_arg_then "FRECHET_DERIVATIVE_WORKS")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma frechet_scale *) let frechet_scale = section_proof ["c"] `frechet_derivative (\x. c % f x) (at x) = (\y. c % frechet_derivative f (at x) y)` [ ((((use_arg_then "EQ_SYM_EQ")(thm_tac (new_rewrite [] [])))) THEN ((use_arg_then "FRECHET_DERIVATIVE_AT") (thm_tac apply_tac)) THEN ((use_arg_then "HAS_DERIVATIVE_CMUL") (thm_tac apply_tac))); ((((use_arg_then "ETA_AX")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN (((use_arg_then "FRECHET_DERIVATIVE_WORKS")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (add_section_hyp "dg" (`g differentiable at x`));; (* Lemma frechet_add *) let frechet_add = section_proof [] `frechet_derivative (\x. f x + g x) (at x) = (\y. frechet_derivative f (at x) y + frechet_derivative g (at x) y)` [ ((((use_arg_then "EQ_SYM_EQ")(thm_tac (new_rewrite [] [])))) THEN ((use_arg_then "FRECHET_DERIVATIVE_AT") (thm_tac apply_tac)) THEN ((use_arg_then "HAS_DERIVATIVE_ADD") (thm_tac apply_tac))); ((((use_arg_then "ETA_AX")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN (repeat_tactic 1 9 (((use_arg_then "FRECHET_DERIVATIVE_WORKS")(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (done_tac)); ];; (* Lemma frechet_sub *) let frechet_sub = section_proof [] `frechet_derivative (\x. f x - g x) (at x) = (\y. frechet_derivative f (at x) y - frechet_derivative g (at x) y)` [ ((((use_arg_then "EQ_SYM_EQ")(thm_tac (new_rewrite [] [])))) THEN ((use_arg_then "FRECHET_DERIVATIVE_AT") (thm_tac apply_tac)) THEN ((use_arg_then "HAS_DERIVATIVE_SUB") (thm_tac apply_tac))); ((((use_arg_then "ETA_AX")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN (repeat_tactic 1 9 (((use_arg_then "FRECHET_DERIVATIVE_WORKS")(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (done_tac)); ];; (* Finalization of the section MoreFrechet *) let frechet_compose = finalize_theorem frechet_compose;; let frechet_const = finalize_theorem frechet_const;; let frechet_id = finalize_theorem frechet_id;; let frechet_vmul = finalize_theorem frechet_vmul;; let frechet_neg = finalize_theorem frechet_neg;; let frechet_scale = finalize_theorem frechet_scale;; let frechet_add = finalize_theorem frechet_add;; let frechet_sub = finalize_theorem frechet_sub;; end_section "MoreFrechet";; (* Lemma differentiable_compose_at *) let differentiable_compose_at = section_proof ["f";"g";"x"] `f differentiable at (g x) ==> g differentiable at x ==> (f o g) differentiable at x` [ ((BETA_TAC THEN (move ["df"]) THEN (move ["dg"])) THEN (((use_arg_then "FRECHET_DERIVATIVE_WORKS")(thm_tac (new_rewrite [] []))))); (((((use_arg_then "frechet_compose")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac))) THEN ((use_arg_then "DIFF_CHAIN_AT") (thm_tac apply_tac)) THEN (repeat_tactic 1 9 (((use_arg_then "FRECHET_DERIVATIVE_WORKS")(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (done_tac)); ];; (* Lemma jacobian_compose *) let jacobian_compose = section_proof ["f";"g";"x"] `f differentiable at (g x) ==> g differentiable at x ==> jacobian (f o g) (at x) = jacobian f (at (g x)) ** jacobian g (at x)` [ (BETA_TAC THEN (move ["df"]) THEN (move ["dg"])); (((repeat_tactic 1 9 (((use_arg_then "jacobian")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "frechet_compose")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "MATRIX_COMPOSE")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (repeat_tactic 1 9 (((use_arg_then "LINEAR_FRECHET_DERIVATIVE")(thm_tac (new_rewrite [] [])))))) THEN (done_tac)); ];; (* Lemma frechet_eq_jacobian *) let frechet_eq_jacobian = section_proof ["f";"x"] `f differentiable at x ==> frechet_derivative f (at x) = (\h. jacobian f (at x) ** h)` [ (BETA_TAC THEN (move ["df"])); (((((use_arg_then "EQ_SYM_EQ")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "FRECHET_DERIVATIVE_AT")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "JACOBIAN_WORKS")(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (done_tac)); ];; (* Section Product *) begin_section "Product";; (* Lemma REAL_LET_MUL2 *) let REAL_LET_MUL2 = section_proof ["w";"x";"y";"z"] `&0 < w /\ w <= x /\ &0 <= y /\ y < z ==> w * y < x * z` [ (BETA_TAC THEN (move ["ineq"])); ((THENL) (((fun arg_tac -> (use_arg_then "EXCLUDED_MIDDLE") (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`w = x`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN case) [(move ["w_eq_x"]); (move ["wnx"])]); (((((use_arg_then "w_eq_x")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "REAL_LT_LMUL")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ((((use_arg_then "REAL_LT_MUL2")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "wnx") (disch_tac [])) THEN (clear_assumption "wnx") THEN ((use_arg_then "ineq") (disch_tac [])) THEN (clear_assumption "ineq") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac)); ];; (* Lemma has_derivative_x12 *) let has_derivative_x12 = section_proof ["y"] `(lift o (\x:real^2. x$1 * x$2) has_derivative lift o (\x. y$2 * x$1 + y$1 * x$2)) (at y)` [ ((((use_arg_then "has_derivative_at")(thm_tac (new_rewrite [] [])))) THEN (split_tac)); ((((use_arg_then "linear")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "o_THM")(thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (repeat_tactic 1 9 (((use_arg_then "VECTOR_ADD_COMPONENT")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "VECTOR_MUL_COMPONENT")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "LIFT_ADD")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "LIFT_CMUL")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "LIFT_ADD")(thm_tac (new_rewrite [] [])))))); ((VECTOR_ARITH_TAC) THEN (done_tac)); ((repeat_tactic 1 9 (((use_arg_then "o_THM")(thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (((use_arg_then "LIFT_ADD")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "LIFT_SUB")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "LIFT_CMUL")(gsym_then (thm_tac (new_rewrite [] [])))))); (((((use_arg_then "LIM_AT")(thm_tac (new_rewrite [] [])))) THEN (simp_tac) THEN (repeat_tactic 1 9 (((use_arg_then "dist")(thm_tac (new_rewrite [] []))))) THEN (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL VECTOR_SUB_RZERO)))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "NORM_LIFT")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "VECTOR_SUB_COMPONENT")(thm_tac (new_rewrite [] [])))))) THEN (move ["e"]) THEN (move ["e0"])); (((fun arg_tac -> arg_tac (Arg_theorem (REAL_ARITH `(x:real^2)$1 * x$2 - ((y:real^2)$1 * y$2 + y$2 * (x$1 - y$1) + y$1 * (x$2 - y$2)) = (x$2 - y$2) * (x$1 - y$1)`)))(thm_tac (new_rewrite [] [])))); (((use_arg_then "e") (term_tac exists_tac)) THEN (((((use_arg_then "e0")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))) THEN (move ["x"]) THEN (case THEN ((move ["norm0"]) THEN (move ["norm_e"]))))); ((repeat_tactic 1 9 (((use_arg_then "REAL_ABS_MUL")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "REAL_ABS_INV")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_ABS_NORM")(thm_tac (new_rewrite [] []))))); ((repeat_tactic 1 9 (((use_arg_then "VECTOR_SUB_COMPONENT")(gsym_then (thm_tac (new_rewrite [] [])))))) THEN ((fun arg_tac -> arg_tac (Arg_term (`x - y:real^2`))) (term_tac (set_tac "p")))); ((fun arg_tac -> (use_arg_then "NORM_BOUND_COMPONENT_LT") (fun fst_arg -> (use_arg_then "norm_e") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun arg -> thm_tac MP_TAC arg THEN (move ["ineq"]))); ((((use_arg_then "REAL_LTE_TRANS") (disch_tac [])) THEN (clear_assumption "REAL_LTE_TRANS") THEN (DISCH_THEN apply_tac)) THEN ((fun arg_tac -> arg_tac (Arg_term (`inv (infnorm p) * infnorm p * e`))) (term_tac exists_tac))); ((THENL_FIRST) ((fun arg_tac -> arg_tac (Arg_term (`&0 < infnorm p`))) (term_tac (have_gen_tac [](move ["infnorm_0"])))) (((((use_arg_then "INFNORM_POS_LT")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "NORM_POS_LT")(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (done_tac))); ((THENL_ROT (-1)) (split_tac)); (((((use_arg_then "REAL_MUL_ASSOC")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_MUL_LINV")(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_LE_REFL")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((use_arg_then "INFNORM_EQ_0")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "NORM_POS_LT")(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (done_tac)); ((((use_arg_then "REAL_LET_MUL2")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_LT_INV")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "REAL_LE_INV2")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "INFNORM_LE_NORM")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (repeat_tactic 1 9 (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))))); ((((use_arg_then "REAL_LE_MUL")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "REAL_ABS_POS")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))); ((fun arg_tac -> arg_tac (Arg_term (`infnorm p = abs (p$1) \/ infnorm p = abs (p$2)`))) (term_tac (have_gen_tac []ALL_TAC))); ((((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL INFNORM_2)))(thm_tac (new_rewrite [] [])))) THEN (arith_tac) THEN (done_tac)); (((THENL_FIRST) (case THEN (((conv_thm_tac DISCH_THEN)(gsym_then (thm_tac (new_rewrite [] [])))))) (((use_arg_then "REAL_MUL_SYM")(thm_tac (new_rewrite [] []))))) THEN ((((use_arg_then "REAL_LT_LMUL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "ineq")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "DIMINDEX_2")(thm_tac (new_rewrite [] []))))) THEN (arith_tac) THEN (done_tac)); ];; (* Lemma lambda_eq_vsum *) let lambda_eq_vsum = section_proof ["f"] `(\x:A. lambda i. f i x) = (\x. vsum (1..dimindex (:N)) (\i. f i x % (basis i:real^N)))` [ (((((use_arg_then "eq_ext")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (simp_tac)) THEN (move ["x"])); (((((use_arg_then "CART_EQ")(thm_tac (new_rewrite [] [])))) THEN (move ["i"]) THEN (move ["ineq"])) THEN ((((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL LAMBDA_BETA)))(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "VSUM_COMPONENT")(thm_tac (new_rewrite [] [])))) THEN ((simp_tac THEN TRY done_tac)))); (((fun arg_tac -> arg_tac (Arg_term (`1.. _`))) (term_tac (set_tac "A"))) THEN ((fun arg_tac -> arg_tac (Arg_term (`A DIFF {i}`))) (term_tac (set_tac "B")))); ((fun arg_tac -> arg_tac (Arg_term (`DISJOINT B {i} /\ A = B UNION {i}`))) (term_tac (have_gen_tac [](move ["cond"])))); ((((use_arg_then "DISJOINT")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "EXTENSION")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "B_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "A_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "IN_INTER")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "IN_DIFF")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "IN_SING")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "NOT_IN_EMPTY")(thm_tac (new_rewrite [] [])))) THEN (simp_tac)); ((THENL_FIRST) ((split_tac) THEN (move ["x"])) (((repeat_tactic 1 9 (((use_arg_then "negb_and")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "negbK")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "orbA")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "EXCLUDED_MIDDLE")(thm_tac (new_rewrite [] []))))) THEN (done_tac))); ((((use_arg_then "IN_UNION")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "IN_DIFF")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "IN_SING")(thm_tac (new_rewrite [] []))))); ((((fun arg_tac -> (use_arg_then "EXCLUDED_MIDDLE") (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`x = i`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN case THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac))) THEN ((simp_tac) THEN (((use_arg_then "IN_NUMSEG")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ((((use_arg_then "cond")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "SUM_UNION")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "cond")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "B_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "FINITE_DIFF")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "A_def")(gsym_then (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 "FINITE_SING")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac))); ((((use_arg_then "SUM_SING")(thm_tac (new_rewrite [] [])))) THEN (simp_tac) THEN (repeat_tactic 1 9 (((use_arg_then "VECTOR_MUL_COMPONENT")(thm_tac (new_rewrite [] []))))) THEN (((fun arg_tac -> (fun arg_tac -> (use_arg_then "BASIS_COMPONENT") (fun fst_arg -> (use_arg_then "i") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "i") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [])))) THEN ((simp_tac THEN TRY done_tac))); (((((fun arg_tac -> arg_tac (Arg_theorem (REAL_ARITH `!a b. a = b + a * &1 <=> b = &0`)))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "SUM_EQ_0")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac))) THEN (move ["j"])); ((((((use_arg_then "IN_DIFF")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "IN_SING")(thm_tac (new_rewrite [] []))))) THEN (move ["ineq_j"]) THEN (simp_tac)) THEN ((((use_arg_then "BASIS_COMPONENT")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((fun arg_tac -> (use_arg_then "EQ_SYM_EQ") (fun fst_arg -> (use_arg_then "i") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [])))))); (((((use_arg_then "ineq_j")(thm_tac (new_rewrite [] [])))) THEN (simp_tac) THEN (((use_arg_then "REAL_MUL_RZERO")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma has_derivative_lambda *) let has_derivative_lambda = section_proof ["f";"f'";"y"] `(!i. i IN 1..dimindex (:M) ==> (lift o (f i) has_derivative lift o (f' i)) (at (y:real^N))) ==> (((\x. lambda i. f i x):real^N->real^M) has_derivative (\x. lambda i. f' i x) ) (at y)` [ ((BETA_TAC THEN (move ["df"])) THEN (repeat_tactic 1 9 (((use_arg_then "lambda_eq_vsum")(thm_tac (new_rewrite [] []))))) THEN ((use_arg_then "HAS_DERIVATIVE_VSUM") (thm_tac apply_tac))); (((((use_arg_then "FINITE_NUMSEG")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))) THEN (move ["i"]) THEN (move ["ineq"]) THEN (simp_tac)); ((fun arg_tac -> arg_tac (Arg_term (`!f. (\x:real^N. f i x % (basis i:real^M)) = (\x. drop ((lift o f i) x) % basis i)`))) (term_tac (have_gen_tac [](move ["eq"])))); ((BETA_TAC THEN (move ["g"])) THEN ((((use_arg_then "eq_ext")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (((use_arg_then "o_THM")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "LIFT_DROP")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); (((((fun arg_tac -> (use_arg_then "eq") (fun fst_arg -> (use_arg_then "f") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> (use_arg_then "eq") (fun fst_arg -> (use_arg_then "f'") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL HAS_DERIVATIVE_VMUL_DROP)))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "ETA_AX")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN (((use_arg_then "df")(thm_tac (new_rewrite [] [])))) THEN (done_tac)); ];; (* Lemma vector2_eq_lambda *) let vector2_eq_lambda = section_proof ["x";"y"] `(vector [x; y]:real^2) = (lambda i. if i = 1 then x else y)` [ ((((((use_arg_then "CART_EQ")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "DIMINDEX_2")(thm_tac (new_rewrite [] []))))) THEN (move ["i"])) THEN (((fun arg_tac -> arg_tac (Arg_theorem (ARITH_RULE `1 <= i /\ i <= 2 <=> i = 1 \/ i = 2`)))(thm_tac (new_rewrite [] []))))); ((case THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [1; 3] []))))) THEN ((((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL VECTOR_2)))(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL LAMBDA_BETA)))(thm_tac (new_rewrite [] [])))) THEN (simp_tac) THEN (repeat_tactic 0 10 (((use_arg_then "DIMINDEX_2")(thm_tac (new_rewrite [] [])))))) THEN (arith_tac) THEN (done_tac)); ];; (* Lemma has_derivative_vector2 *) let has_derivative_vector2 = section_proof ["f";"g";"f'";"g'";"y"] `(lift o f has_derivative lift o f') (at y) ==> (lift o g has_derivative lift o g') (at y) ==> ((\x. vector [f x; g x]:real^2) has_derivative (\x. vector [f' x; g' x]:real^2)) (at y)` [ ((BETA_TAC THEN (move ["df"]) THEN (move ["dg"])) THEN (repeat_tactic 1 9 (((use_arg_then "vector2_eq_lambda")(thm_tac (new_rewrite [] [])))))); (((use_arg_then "has_derivative_lambda") (thm_tac apply_tac)) THEN (((((use_arg_then "DIMINDEX_2")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "IN_NUMSEG")(thm_tac (new_rewrite [] []))))) THEN (move ["i"]))); ((((fun arg_tac -> arg_tac (Arg_theorem (ARITH_RULE `1 <= i /\ i <= 2 <=> i = 1 \/ i = 2`)))(thm_tac (new_rewrite [] [])))) THEN (case THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [2; 4] [])))) THEN (simp_tac)) THEN ((((use_arg_then "ETA_AX")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN ((TRY done_tac)))); (((((fun arg_tac -> arg_tac (Arg_theorem (ARITH_RULE `~(2 = 1)`)))(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)); ];; (* Lemma has_derivative_mul *) let has_derivative_mul = section_proof ["f";"g";"f'";"g'";"y"] `(lift o f has_derivative lift o f') (at y) ==> (lift o g has_derivative lift o g') (at y) ==> (lift o (\x. f x * g x) has_derivative lift o (\x. f' x * g y + f y * g' x)) (at y)` [ (BETA_TAC THEN (move ["df"]) THEN (move ["dg"])); ((fun arg_tac -> arg_tac (Arg_term (`lift o (\x. f x * g x) = (lift o (\p. p$1 * p$2)) o (\x. vector [f x; g x]:real^2)`))) (term_tac (have_gen_tac [](((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))))); ((((((use_arg_then "eq_ext")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "o_THM")(thm_tac (new_rewrite [] []))))) THEN (simp_tac)) THEN (move ["x"])) THEN (repeat_tactic 1 9 (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL VECTOR_2)))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ((fun arg_tac -> arg_tac (Arg_term (`vector [f y; g y]:real^2`))) (term_tac (set_tac "q"))); ((fun arg_tac -> arg_tac (Arg_term (`lift o (\x. f' x * g y + f y * g' x) = (lift o (\x:real^2. q$2 * x$1 + q$1 * x$2)) o (\x. vector [f' x; g' x])`))) (term_tac (have_gen_tac [](((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))))); (((((use_arg_then "eq_ext")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "o_THM")(thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (((use_arg_then "q_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL VECTOR_2)))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "REAL_MUL_SYM")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ((((use_arg_then "DIFF_CHAIN_AT") (thm_tac apply_tac)) THEN (simp_tac)) THEN ((((use_arg_then "q_def")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "has_derivative_x12")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "has_derivative_vector2")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma f_eq_lift_drop *) let f_eq_lift_drop = section_proof ["f"] `f = lift o (drop o f)` [ (((((use_arg_then "eq_ext")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "o_THM")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "LIFT_DROP")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma differentiable_mul *) let differentiable_mul = section_proof ["f";"g";"y"] `lift o f differentiable (at y) ==> lift o g differentiable (at y) ==> lift o (\x. f x * g x) differentiable (at y)` [ ((repeat_tactic 2 0 (((use_arg_then "differentiable")(thm_tac (new_rewrite [] []))))) THEN ALL_TAC THEN (case THEN (move ["f'"])) THEN (move ["df"]) THEN (case THEN (move ["g'"])) THEN (move ["dg"])); ((((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 (((((fun arg_tac -> (use_arg_then "f_eq_lift_drop") (fun fst_arg -> (use_arg_then "f'") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> (use_arg_then "f_eq_lift_drop") (fun fst_arg -> (use_arg_then "g'") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] []))))) THEN (move ["df"]) THEN (move ["dg"]))); ((fun arg_tac -> (fun arg_tac -> (use_arg_then "has_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 arg -> thm_tac MP_TAC arg THEN ALL_TAC)); (((use_arg_then "HAS_DERIVATIVE_IMP_DIFFERENTIABLE") (thm_tac apply_tac)) THEN (done_tac)); ];; (* Lemma frechet_mul *) let frechet_mul = section_proof ["f";"g";"y"] `lift o f differentiable at y ==> lift o g differentiable at y ==> frechet_derivative (lift o (\x. f x * g x)) (at y) = (\x. g y % frechet_derivative (lift o f) (at y) x + f y % frechet_derivative (lift o g) (at y) x)` [ (((repeat_tactic 1 9 (((use_arg_then "FRECHET_DERIVATIVE_WORKS")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "f_eq_lift_drop")(thm_tac (new_rewrite [] [(`frechet_derivative _1 _2`)]))))) THEN (move ["df"])); ((((use_arg_then "f_eq_lift_drop")(thm_tac (new_rewrite [] [(`frechet_derivative _1 _2`)])))) THEN (move ["dg"])); (((fun arg_tac -> (fun arg_tac -> (use_arg_then "has_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 arg -> thm_tac MP_TAC arg THEN ALL_TAC)) THEN ((DISCH_THEN (fun snd_th -> (use_arg_then "FRECHET_DERIVATIVE_AT") (thm_tac (match_mp_then snd_th MP_TAC)))) THEN BETA_TAC THEN (((conv_thm_tac DISCH_THEN)(gsym_then (thm_tac (new_rewrite [] []))))))); (((((use_arg_then "eq_ext")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "o_THM")(thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (repeat_tactic 1 9 (((use_arg_then "LIFT_DROP")(thm_tac (new_rewrite [] [])))))) THEN (move ["x"])); (((((use_arg_then "LIFT_ADD")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_MUL_SYM")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "LIFT_CMUL")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "LIFT_DROP")(thm_tac (new_rewrite [] [])))))) THEN (done_tac)); ];; (* Finalization of the section Product *) let REAL_LET_MUL2 = finalize_theorem REAL_LET_MUL2;; let has_derivative_x12 = finalize_theorem has_derivative_x12;; let lambda_eq_vsum = finalize_theorem lambda_eq_vsum;; let has_derivative_lambda = finalize_theorem has_derivative_lambda;; let vector2_eq_lambda = finalize_theorem vector2_eq_lambda;; let has_derivative_vector2 = finalize_theorem has_derivative_vector2;; let has_derivative_mul = finalize_theorem has_derivative_mul;; let f_eq_lift_drop = finalize_theorem f_eq_lift_drop;; let differentiable_mul = finalize_theorem differentiable_mul;; let frechet_mul = finalize_theorem frechet_mul;; end_section "Product";; (* Finalization of the section Misc *) let f_lift_neg = finalize_theorem f_lift_neg;; let f_lift_scale = finalize_theorem f_lift_scale;; let f_lift_add = finalize_theorem f_lift_add;; let f_lift_sub = finalize_theorem f_lift_sub;; let f_binary_drop = finalize_theorem f_binary_drop;; let f_unary_drop = finalize_theorem f_unary_drop;; let frechet_compose = finalize_theorem frechet_compose;; let frechet_const = finalize_theorem frechet_const;; let frechet_id = finalize_theorem frechet_id;; let frechet_vmul = finalize_theorem frechet_vmul;; let frechet_neg = finalize_theorem frechet_neg;; let frechet_scale = finalize_theorem frechet_scale;; let frechet_add = finalize_theorem frechet_add;; let frechet_sub = finalize_theorem frechet_sub;; let differentiable_compose_at = finalize_theorem differentiable_compose_at;; let jacobian_compose = finalize_theorem jacobian_compose;; let frechet_eq_jacobian = finalize_theorem frechet_eq_jacobian;; let REAL_LET_MUL2 = finalize_theorem REAL_LET_MUL2;; let has_derivative_x12 = finalize_theorem has_derivative_x12;; let lambda_eq_vsum = finalize_theorem lambda_eq_vsum;; let has_derivative_lambda = finalize_theorem has_derivative_lambda;; let vector2_eq_lambda = finalize_theorem vector2_eq_lambda;; let has_derivative_vector2 = finalize_theorem has_derivative_vector2;; let has_derivative_mul = finalize_theorem has_derivative_mul;; let f_eq_lift_drop = finalize_theorem f_eq_lift_drop;; let differentiable_mul = finalize_theorem differentiable_mul;; let frechet_mul = finalize_theorem frechet_mul;; end_section "Misc";; (* Section Partial *) begin_section "Partial";; (* Lemma real_derivative_compose_frechet *) let real_derivative_compose_frechet = section_proof ["f";"h";"t"] `(lift o f) differentiable at (h t) ==> (h o drop) differentiable at (lift t) ==> ((f o h) has_real_derivative (drop o (frechet_derivative (lift o f) (at (h t)) o frechet_derivative (h o drop) (at (lift t))) o lift) (&1)) (atreal t)` [ (BETA_TAC THEN (move ["diff_f"]) THEN (move ["diff_h"])); ((((use_arg_then "diff_h") (disch_tac [])) THEN ((use_arg_then "diff_f") (disch_tac [])) THEN BETA_TAC) THEN (repeat_tactic 1 9 (((use_arg_then "FRECHET_DERIVATIVE_WORKS")(thm_tac (new_rewrite [] [])))))); ((fun arg_tac -> arg_tac (Arg_term (`frechet_derivative _1 _2`))) (term_tac (set_tac "f'"))); ((fun arg_tac -> arg_tac (Arg_term (`frechet_derivative _1 _2`))) (term_tac (set_tac "h'"))); (BETA_TAC THEN (move ["df"]) THEN (move ["dh"])); (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL HAS_REAL_FRECHET_DERIVATIVE_AT)))(thm_tac (new_rewrite [] [])))); ((THENL_FIRST) ((fun arg_tac -> arg_tac (Arg_term (`lift o (f o h) o drop = (lift o f) o (h o drop)`))) (term_tac (have_gen_tac [](((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))))) ((repeat_tactic 1 9 (((use_arg_then "o_ASSOC")(thm_tac (new_rewrite [] []))))) THEN (done_tac))); (((THENL_ROT 1)) ((fun arg_tac -> arg_tac (Arg_term (`(\x. (drop o (f' o h') o lift) (&1) % x) = f' o h'`))) (term_tac (have_gen_tac [](((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] [])))))))); (((((use_arg_then "DIFF_CHAIN_AT")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "dh")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "o_THM")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "LIFT_DROP")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "df")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); (((((use_arg_then "eq_ext")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "o_THM")(thm_tac (new_rewrite [] [])))))) THEN (move ["x"]) THEN (simp_tac)); ((fun arg_tac -> arg_tac (Arg_term (`linear f' /\ linear h'`))) (term_tac (have_gen_tac [](move ["lin"])))); (((((use_arg_then "h'_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "f'_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "LINEAR_FRECHET_DERIVATIVE")(thm_tac (new_rewrite [] [])))))) THEN (done_tac)); ((fun arg_tac -> arg_tac (Arg_term (`x = drop x % lift (&1)`))) (term_tac (have_gen_tac [](((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [2] []))))))); (((((use_arg_then "DROP_EQ")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "DROP_CMUL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "LIFT_DROP")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_MUL_RID")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); (((repeat_tactic 1 9 (((use_arg_then "LINEAR_CMUL")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((use_arg_then "DROP_EQ")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "DROP_CMUL")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "REAL_MUL_SYM")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma real_derivative_compose_jacobian *) let real_derivative_compose_jacobian = section_proof ["f";"h";"t"] `(lift o f) differentiable at (h t) ==> (h o drop) differentiable at (lift t) ==> ((f o h) has_real_derivative (jacobian (lift o f) (at (h t)) ** jacobian (h o drop) (at (lift t)))$1$1) (atreal t)` [ (BETA_TAC THEN (move ["df"]) THEN (move ["dh"])); (((fun arg_tac -> (fun arg_tac -> (use_arg_then "real_derivative_compose_frechet") (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 "dh") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC); ((repeat_tactic 1 9 (((use_arg_then "frechet_eq_jacobian")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (repeat_tactic 1 9 (((use_arg_then "o_THM")(thm_tac (new_rewrite [] []))))) THEN (simp_tac)); ((((use_arg_then "MATRIX_VECTOR_MUL_ASSOC")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "matrix_vector_mul")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "DROP_LAMBDA")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "DIMINDEX_1")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "SUM_SING_NUMSEG")(thm_tac (new_rewrite [] [])))) THEN (simp_tac)); (((((use_arg_then "LIFT_COMPONENT")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_MUL_RID")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma diff_imp_real_diff *) let diff_imp_real_diff = section_proof ["f";"h";"t"] `(lift o f) differentiable at (h t) ==> (h o drop) differentiable at (lift t) ==> (f o h) real_differentiable atreal t` [ (BETA_TAC THEN (move ["diff_f"]) THEN (move ["diff_h"])); (((fun arg_tac -> (fun arg_tac -> (use_arg_then "real_derivative_compose_frechet") (fun fst_arg -> (use_arg_then "diff_f") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "diff_h") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC); ((fun arg_tac -> arg_tac (Arg_term (`(drop o _ o lift) (&1)`))) (term_tac (set_tac "fh'"))); (((((use_arg_then "real_differentiable")(thm_tac (new_rewrite [] [])))) THEN (move ["dfh"])) THEN ((use_arg_then "fh'") (term_tac exists_tac)) THEN (done_tac)); ];; (* Lemma diff_direction *) let diff_direction = section_proof ["y";"e";"net"] `((\t. y + t % e) o drop) differentiable net` [ ((THENL_FIRST) ((fun arg_tac -> arg_tac (Arg_term (`(\t. y + t % e) o drop = (\x. y + drop x % e)`))) (term_tac (have_gen_tac [](((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))))) (((((use_arg_then "eq_ext")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "o_THM")(thm_tac (new_rewrite [] []))))) THEN (done_tac))); ((((use_arg_then "DIFFERENTIABLE_ADD")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "DIFFERENTIABLE_CONST")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))); ((use_arg_then "HAS_DERIVATIVE_IMP_DIFFERENTIABLE") (thm_tac apply_tac)); (((fun arg_tac -> arg_tac (Arg_term (`\x. drop x % e`))) (term_tac exists_tac)) THEN ((use_arg_then "HAS_DERIVATIVE_VMUL_DROP") (thm_tac apply_tac)) THEN (((use_arg_then "HAS_DERIVATIVE_ID")(thm_tac (new_rewrite [] [])))) THEN (done_tac)); ];; (* Lemma frechet_direction *) let frechet_direction = section_proof ["y";"e";"t"] `frechet_derivative ((\t. y + t % e) o drop) (at (lift t)) = (\x. drop x % e)` [ ((((use_arg_then "f_unary_drop")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "frechet_add")(thm_tac (new_rewrite [] []))))); (((((use_arg_then "DIFFERENTIABLE_CONST")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))) THEN ((use_arg_then "HAS_DERIVATIVE_IMP_DIFFERENTIABLE") (thm_tac apply_tac))); (((fun arg_tac -> arg_tac (Arg_term (`\x. drop x % e`))) (term_tac exists_tac)) THEN ((use_arg_then "HAS_DERIVATIVE_VMUL_DROP") (thm_tac apply_tac)) THEN (((use_arg_then "HAS_DERIVATIVE_ID")(thm_tac (new_rewrite [] []))))); (((((use_arg_then "frechet_vmul")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "frechet_const")(thm_tac (new_rewrite [] [])))) THEN (simp_tac) THEN (((use_arg_then "VECTOR_ADD_LID")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma real_dir_derivative_frechet *) let real_dir_derivative_frechet = section_proof ["f";"y";"e";"t"] `(lift o f) differentiable at (y + t % e) ==> ((f o (\t. y + t % e)) has_real_derivative (drop (frechet_derivative (lift o f) (at (y + t % e)) e))) (atreal t)` [ (BETA_TAC THEN (move ["df"])); (((fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (use_arg_then "real_derivative_compose_frechet") (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 (`\t. y + t % e`))) (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))) (disch_tac [])) THEN BETA_TAC); (((((use_arg_then "df")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "diff_direction")(thm_tac (new_rewrite [] [])))) THEN (simp_tac) THEN (((use_arg_then "frechet_direction")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "o_THM")(thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (((use_arg_then "LIFT_DROP")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "VECTOR_MUL_LID")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma real_dir_derivative_jacobian *) let real_dir_derivative_jacobian = section_proof ["f";"y";"e";"t"] `(lift o f) differentiable at (y + t % e) ==> ((f o (\t. y + t % e)) has_real_derivative drop (jacobian (lift o f) (at (y + t % e)) ** e)) (atreal t)` [ (BETA_TAC THEN (move ["df"])); (((fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (use_arg_then "real_dir_derivative_frechet") (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 "e") (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))) (disch_tac [])) THEN BETA_TAC); ((((use_arg_then "frechet_eq_jacobian")(thm_tac (new_rewrite [] [])))) THEN (done_tac)); ];; (* Lemma partial_eq_frechet *) let partial_eq_frechet = section_proof ["f";"y";"i"] `(lift o f) differentiable at (y:real^N) ==> partial i f y = drop (frechet_derivative (lift o f) (at y) (basis i))` [ ((BETA_TAC THEN (move ["df"])) THEN (((use_arg_then "partial")(thm_tac (new_rewrite [] []))))); ((((fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (use_arg_then "real_dir_derivative_frechet") (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))) (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`basis i:real^N`))) (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))) (disch_tac [])) THEN BETA_TAC) THEN ((((use_arg_then "VECTOR_MUL_LZERO")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "VECTOR_ADD_RID")(thm_tac (new_rewrite [] [])))))); ((BETA_TAC THEN ((fun arg_tac -> (conv_thm_tac DISCH_THEN) (fun fst_arg -> (use_arg_then "df") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (thm_tac MP_TAC)) THEN (DISCH_THEN (fun snd_th -> (use_arg_then "derivative_unique") (thm_tac (match_mp_then snd_th MP_TAC))))) THEN (done_tac)); ];; (* Lemma partial_eq_jacobian *) let partial_eq_jacobian = section_proof ["f";"y";"i"] `(lift o f) differentiable at y ==> partial i f y = drop (jacobian (lift o f) (at y) ** basis i)` [ (BETA_TAC THEN (move ["df"])); ((((use_arg_then "df") (disch_tac [])) THEN BETA_TAC) THEN (((((use_arg_then "partial_eq_frechet")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "JACOBIAN_WORKS")(thm_tac (new_rewrite [] []))))) THEN (DISCH_THEN (fun snd_th -> (use_arg_then "FRECHET_DERIVATIVE_AT") (thm_tac (match_mp_then snd_th MP_TAC)))) THEN (((conv_thm_tac DISCH_THEN)(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (done_tac)); ];; (* Lemma partial_eq_jacobian_column *) let partial_eq_jacobian_column = section_proof ["f";"y";"i"] `(lift o (f:real^N->real)) differentiable at y ==> i IN 1..dimindex (:N) ==> partial i f y = drop (column i (jacobian (lift o f) (at y)))` [ ((((use_arg_then "IN_NUMSEG")(thm_tac (new_rewrite [] [])))) THEN (move ["df"]) THEN (move ["ineq"])); (((((use_arg_then "partial_eq_jacobian")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "MATRIX_VECTOR_MUL_BASIS")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma partial_eq_jacobian_entry *) let partial_eq_jacobian_entry = section_proof ["f";"y";"i"] `(lift o (f:real^N->real)) differentiable at y ==> i IN 1..dimindex (:N) ==> partial i f y = (jacobian (lift o f) (at y))$1$i` [ ((BETA_TAC THEN (move ["df"]) THEN (move ["ineq"])) THEN ((((use_arg_then "partial_eq_jacobian_column")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "column")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "DROP_LAMBDA")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (add_section_var (mk_var ("y", (`:real^N`))));; (add_section_var (mk_var ("i", (`:num`))));; (* Lemma partial_eq0 *) let partial_eq0 = section_proof ["f"] `~(i IN 1..dimindex (:N)) ==> partial i f y = &0` [ ((BETA_TAC THEN (move ["ineq"])) THEN (((use_arg_then "partial")(thm_tac (new_rewrite [] []))))); ((THENL_FIRST) ((fun arg_tac -> arg_tac (Arg_term (`basis i = (vec 0):real^N`))) (term_tac (have_gen_tac [](((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))))) ((((use_arg_then "BASIS_EQ_0")(thm_tac (new_rewrite [] [])))) THEN (done_tac))); ((((use_arg_then "VECTOR_MUL_RZERO")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN (((use_arg_then "VECTOR_ADD_RID")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg])))); ((fun arg_tac -> arg_tac (Arg_term (`derivative (f o (\t. y)) = derivative (\t. f y)`))) (term_tac (have_gen_tac [](((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))))); ((AP_TERM_TAC) THEN ((((use_arg_then "eq_ext")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "o_THM")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ((((use_arg_then "derivative_const")(thm_tac (new_rewrite [] [])))) THEN (done_tac)); ];; (* Lemma derivative_compose *) let derivative_compose = section_proof ["f";"g";"x"] `f real_differentiable atreal (g x) ==> g real_differentiable atreal x ==> derivative (f o g) x = derivative f (g x) * derivative g x` [ (BETA_TAC THEN (move ["df"]) THEN (move ["dg"])); ((THENL_FIRST) ((fun arg_tac -> arg_tac (Arg_term (`f o g = \x. f (g x)`))) (term_tac (have_gen_tac [](((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))))) (((((use_arg_then "eq_ext")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "o_THM")(thm_tac (new_rewrite [] []))))) THEN (done_tac))); (((((use_arg_then "derivative_composition")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "REAL_MUL_SYM")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma projection_has_derivative *) let projection_has_derivative = section_proof ["i";"net"] `i IN 1..dimindex (:N) ==> (lift o (\x:real^N. x$i) has_derivative lift o (\x. x$i)) net` [ ((((use_arg_then "IN_NUMSEG")(thm_tac (new_rewrite [] [])))) THEN (move ["ineq"])); ((fun arg_tac -> arg_tac (Arg_term (`lift o (\x:real^N. x$i) = (\x. x$i % vec 1)`))) (term_tac (have_gen_tac [](((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))))); ((((((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 (move ["x"])) THEN ((((use_arg_then "DROP_EQ")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "LIFT_DROP")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "DROP_CMUL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "DROP_VEC")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_MUL_RID")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); (((((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL HAS_DERIVATIVE_VMUL_COMPONENT)))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "HAS_DERIVATIVE_ID")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma projection_diff *) let projection_diff = section_proof ["i";"net"] `i IN 1..dimindex (:N) ==> (lift o (\x:real^N. x$i)) differentiable net` [ ((((use_arg_then "differentiable")(thm_tac (new_rewrite [] [])))) THEN (DISCH_THEN (fun snd_th -> (fun arg_tac -> (fun arg_tac -> (use_arg_then "projection_has_derivative") (fun fst_arg -> (use_arg_then "i") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "net") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (thm_tac (match_mp_then snd_th MP_TAC)))) THEN (move ["h"])); (((fun arg_tac -> arg_tac (Arg_term (`lift o \x:real^N. x$i`))) (term_tac exists_tac)) THEN (done_tac)); ];; (* Lemma frechet_projection *) let frechet_projection = section_proof ["i";"x"] `i IN 1..dimindex (:N) ==> frechet_derivative (lift o (\x:real^N. x$i)) (at x) = lift o (\x:real^N. x$i)` [ ((BETA_TAC THEN (move ["ineq"])) THEN (((use_arg_then "EQ_SYM_EQ")(thm_tac (new_rewrite [] [])))) THEN ((use_arg_then "FRECHET_DERIVATIVE_AT") (thm_tac apply_tac))); ((((use_arg_then "projection_has_derivative")(thm_tac (new_rewrite [] [])))) THEN (done_tac)); ];; (* Lemma has_derivative_vector_frechet *) let has_derivative_vector_frechet = section_proof ["h";"t";"i"] `i IN 1..dimindex (:N) ==> (h o drop) differentiable at (lift t) ==> ((\s. (h:real->real^N) s$i) has_real_derivative (frechet_derivative (h o drop) (at (lift t)) (lift (&1)))$i) (atreal t)` [ (BETA_TAC THEN (move ["ineq"]) THEN (move ["dh"])); ((THENL_FIRST) ((fun arg_tac -> arg_tac (Arg_term (`(\s. h s$i) = (\x. x$i) o h`))) (term_tac (have_gen_tac [](((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))))) (((((use_arg_then "eq_ext")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "o_THM")(thm_tac (new_rewrite [] []))))) THEN (done_tac))); (((fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (use_arg_then "real_derivative_compose_frechet") (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`\x:real^N. x$i`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "h") (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))) (disch_tac [])) THEN BETA_TAC); ((((use_arg_then "dh")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "projection_diff")(thm_tac (new_rewrite [] [])))) THEN ((simp_tac THEN TRY done_tac))); ((fun arg_tac -> arg_tac (Arg_term (`(drop o _ o lift) (&1)`))) (term_tac (set_tac "lhs"))); ((fun arg_tac -> arg_tac (Arg_term (`(frechet_derivative _1 _2 _3)$i`))) (term_tac (set_tac "rhs"))); ((THENL_FIRST) (((THENL_ROT 1)) ((fun arg_tac -> arg_tac (Arg_term (`lhs = rhs`))) (term_tac (have_gen_tac [](((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] [])))))))) ((done_tac) THEN (done_tac))); (((((use_arg_then "lhs_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "o_THM")(thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (((use_arg_then "frechet_projection")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "o_THM")(thm_tac (new_rewrite [] [])))) THEN (simp_tac) THEN (((use_arg_then "rhs_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "LIFT_DROP")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma has_derivative_vector_jacobian *) let has_derivative_vector_jacobian = section_proof ["h";"t";"i"] `i IN 1..dimindex (:N) ==> (h o drop) differentiable at (lift t) ==> ((\s. (h:real->real^N) s$i) has_real_derivative (jacobian (h o drop) (at (lift t)))$i$1) (atreal t)` [ (BETA_TAC THEN (move ["ineq"]) THEN (move ["dh"])); (((fun arg_tac -> (fun arg_tac -> (use_arg_then "has_derivative_vector_frechet") (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 "dh") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC); ((fun arg_tac -> arg_tac (Arg_term (`(frechet_derivative _1 _2 _3)$i`))) (term_tac (set_tac "lhs"))); ((fun arg_tac -> arg_tac (Arg_term (`jacobian _1 _2$i$1`))) (term_tac (set_tac "rhs"))); ((THENL_FIRST) (((THENL_ROT 1)) ((fun arg_tac -> arg_tac (Arg_term (`lhs = rhs`))) (term_tac (have_gen_tac [](((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] [])))))))) ((done_tac) THEN (done_tac))); ((((use_arg_then "lhs_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "frechet_eq_jacobian")(thm_tac (new_rewrite [] [])))) THEN ((simp_tac THEN TRY done_tac))); ((fun arg_tac -> arg_tac (Arg_term (`lift (&1) = basis 1`))) (term_tac (have_gen_tac [](((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))))); (((((use_arg_then "DROP_EQ")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "LIFT_DROP")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "basis")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "DROP_LAMBDA")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); (((((use_arg_then "MATRIX_VECTOR_MUL_BASIS")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "DIMINDEX_GE_1")(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 "column")(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL LAMBDA_BETA)))(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "IN_NUMSEG")(gsym_then (thm_tac (new_rewrite [] []))))))) THEN (done_tac)); ];; (* Lemma derivative_vector_jacobian *) let derivative_vector_jacobian = section_proof ["h";"t";"i"] `i IN 1..dimindex (:N) ==> ((h:real->real^N) o drop) differentiable at (lift t) ==> derivative (\s. h s$i) t = jacobian (h o drop) (at (lift t))$i$1` [ ((BETA_TAC THEN (move ["ineq"]) THEN (move ["dh"])) THEN ((use_arg_then "derivative_unique") (thm_tac apply_tac)) THEN (((use_arg_then "has_derivative_vector_jacobian")(thm_tac (new_rewrite [] [])))) THEN (done_tac)); ];; (* Lemma real_derivative_compose_partial *) let real_derivative_compose_partial = section_proof ["f";"h";"t"] `(lift o (f:real^N -> real)) differentiable at (h t) ==> (h o drop) differentiable at (lift t) ==> ((f o h) has_real_derivative sum (1..dimindex (:N)) (\i. partial i f (h t) * derivative (\s. h s$i) t)) (atreal t)` [ (BETA_TAC THEN (move ["df"]) THEN (move ["dh"])); (((fun arg_tac -> (fun arg_tac -> (use_arg_then "real_derivative_compose_jacobian") (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 "dh") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC); (((fun arg_tac -> arg_tac (Arg_term (`_$1$1`))) (term_tac (set_tac "lhs"))) THEN ((fun arg_tac -> arg_tac (Arg_term (`sum _ _2`))) (term_tac (set_tac "rhs")))); ((THENL_FIRST) (((THENL_ROT 1)) ((fun arg_tac -> arg_tac (Arg_term (`lhs = rhs`))) (term_tac (have_gen_tac [](((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] [])))))))) ((done_tac) THEN (done_tac))); (((use_arg_then "lhs_def")(gsym_then (thm_tac (new_rewrite [] []))))); ((((use_arg_then "matrix_mul")(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL LAMBDA_BETA)))(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "DIMINDEX_GE_1")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "leqnn")(thm_tac (new_rewrite [] []))))) THEN ((simp_tac THEN TRY done_tac))); ((((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL LAMBDA_BETA)))(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "DIMINDEX_GE_1")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "leqnn")(thm_tac (new_rewrite [] []))))) THEN ((simp_tac THEN TRY done_tac)) THEN (((use_arg_then "rhs_def")(gsym_then (thm_tac (new_rewrite [] [])))))); (((use_arg_then "SUM_EQ") (thm_tac apply_tac)) THEN (move ["i"]) THEN (move ["ineq"]) THEN (simp_tac)); (((((use_arg_then "partial_eq_jacobian_entry")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "REAL_EQ_MUL_LCANCEL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "derivative_vector_jacobian")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma real_dir_derivative_partial *) let real_dir_derivative_partial = section_proof ["f";"e";"t"] `(lift o f) differentiable at (y + t % e) ==> ((f o (\t. y + t % e)) has_real_derivative sum (1..dimindex (:N)) (\i. e$i * (partial i f o (\t. y + t % e)) t)) (atreal t)` [ (BETA_TAC THEN (move ["df"])); (((fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (use_arg_then "real_dir_derivative_jacobian") (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))) (fun fst_arg -> (use_arg_then "e") (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))) (disch_tac [])) THEN BETA_TAC); ((((use_arg_then "matrix_vector_mul")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "DROP_LAMBDA")(thm_tac (new_rewrite [] []))))); (((fun arg_tac -> arg_tac (Arg_term (`sum _1 _2`))) (term_tac (set_tac "lhs"))) THEN ((fun arg_tac -> arg_tac (Arg_term (`sum _1 _2`))) (term_tac (set_tac "rhs")))); ((THENL_FIRST) (((THENL_ROT 1)) ((fun arg_tac -> arg_tac (Arg_term (`lhs = rhs`))) (term_tac (have_gen_tac [](((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] [])))))))) ((done_tac) THEN (done_tac))); (((((use_arg_then "lhs_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "rhs_def")(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (((use_arg_then "SUM_EQ") (thm_tac apply_tac)) THEN (move ["i"]) THEN (move ["ineq"]) THEN (simp_tac))); (((((use_arg_then "o_THM")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "partial_eq_jacobian_entry")(thm_tac (new_rewrite [] [])))) THEN ((simp_tac THEN TRY done_tac)) THEN (((use_arg_then "REAL_MUL_SYM")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (add_section_var (mk_var ("f", (`:real^N -> real`))); add_section_var (mk_var ("g", (`:real^N -> real`))));; (add_section_hyp "df" (`(lift o f) differentiable at y`));; (* Lemma partial_uni_compose *) let partial_uni_compose = section_proof ["u"] `u real_differentiable atreal (f y) ==> partial i (u o f) y = derivative u (f y) * partial i f y` [ ((BETA_TAC THEN (move ["du"])) THEN ((repeat_tactic 1 9 (((use_arg_then "partial")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "o_ASSOC")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "derivative_compose")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "o_THM")(thm_tac (new_rewrite [] []))))) THEN (simp_tac))); (((((use_arg_then "diff_imp_real_diff")(thm_tac (new_rewrite [] [])))) THEN (simp_tac) THEN (((use_arg_then "VECTOR_MUL_LZERO")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "VECTOR_ADD_RID")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "df")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "diff_direction")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); (((((use_arg_then "VECTOR_MUL_LZERO")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "VECTOR_ADD_RID")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma partial_neg *) let partial_neg = section_proof [] `partial i (\x. --f x) y = --partial i f y` [ (((repeat_tactic 1 9 (((use_arg_then "partial_eq_frechet")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "f_lift_neg")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "DIFFERENTIABLE_NEG")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (repeat_tactic 0 10 (((use_arg_then "frechet_neg")(thm_tac (new_rewrite [] [])))))) THEN ((repeat_tactic 1 9 (((use_arg_then "ETA_AX")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg])))) THEN ((TRY done_tac)) THEN (((use_arg_then "DROP_NEG")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg])))) THEN (done_tac)); ];; (* Lemma partial_scale *) let partial_scale = section_proof ["c"] `partial i (\x. c * f x) y = c * partial i f y` [ (((repeat_tactic 1 9 (((use_arg_then "partial_eq_frechet")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "f_lift_scale")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "DIFFERENTIABLE_CMUL")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (repeat_tactic 0 10 (((use_arg_then "frechet_scale")(thm_tac (new_rewrite [] [])))))) THEN ((repeat_tactic 1 9 (((use_arg_then "ETA_AX")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg])))) THEN ((TRY done_tac)))); ((((use_arg_then "DROP_CMUL")(thm_tac (new_rewrite [] [])))) THEN (done_tac)); ];; (add_section_hyp "dg" (`(lift o g) differentiable at y`));; (* Lemma partial_add *) let partial_add = section_proof [] `partial i (\x. f x + g x) y = partial i f y + partial i g y` [ (((repeat_tactic 1 9 (((use_arg_then "partial_eq_frechet")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "f_lift_add")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "DIFFERENTIABLE_ADD")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (repeat_tactic 0 10 (((use_arg_then "frechet_add")(thm_tac (new_rewrite [] [])))))) THEN ((repeat_tactic 1 9 (((use_arg_then "ETA_AX")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg])))) THEN ((TRY done_tac)))); ((((use_arg_then "DROP_ADD")(thm_tac (new_rewrite [] [])))) THEN (done_tac)); ];; (* Lemma partial_sub *) let partial_sub = section_proof [] `partial i (\x. f x - g x) y = partial i f y - partial i g y` [ (((repeat_tactic 1 9 (((use_arg_then "partial_eq_frechet")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "f_lift_sub")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "DIFFERENTIABLE_SUB")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (repeat_tactic 0 10 (((use_arg_then "frechet_sub")(thm_tac (new_rewrite [] [])))))) THEN ((repeat_tactic 1 9 (((use_arg_then "ETA_AX")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg])))) THEN ((TRY done_tac)))); ((((use_arg_then "DROP_SUB")(thm_tac (new_rewrite [] [])))) THEN (done_tac)); ];; (* Lemma partial_mul *) let partial_mul = section_proof [] `partial i (\x. f x * g x) y = partial i f y * g y + f y * partial i g y` [ ((repeat_tactic 1 9 (((use_arg_then "partial")(thm_tac (new_rewrite [] []))))) THEN ((fun arg_tac -> arg_tac (Arg_term (`\t. y + t % basis i`))) (term_tac (set_tac "h")))); ((fun arg_tac -> arg_tac (Arg_term (`(\x. f x * g x) o h = (\t. (f o h) t * (g o h) t)`))) (term_tac (have_gen_tac [](((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))))); (((((use_arg_then "eq_ext")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "o_THM")(thm_tac (new_rewrite [] [])))))) THEN (done_tac)); ((THENL_ROT (-1)) (((use_arg_then "derivative_mul")(thm_tac (new_rewrite [] []))))); ((((use_arg_then "h_def")(gsym_then (thm_tac (new_rewrite [1; 4] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "o_THM")(thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (((use_arg_then "VECTOR_MUL_LZERO")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "VECTOR_ADD_RID")(thm_tac (new_rewrite [] [])))) THEN (((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 (((fun arg_tac -> (use_arg_then "o_THM") (fun fst_arg -> (use_arg_then "g") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(gsym_then (thm_tac (new_rewrite [] [])))))); ((((use_arg_then "REAL_ADD_SYM")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "ETA_AX")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN (done_tac)); ((THENL_FIRST) ((fun arg_tac -> arg_tac (Arg_term (`h (&0) = y`))) (term_tac (have_gen_tac [](move ["h0"])))) (((((use_arg_then "h_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (((use_arg_then "VECTOR_MUL_LZERO")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "VECTOR_ADD_RID")(thm_tac (new_rewrite [] []))))) THEN (done_tac))); ((THENL_FIRST) ((fun arg_tac -> arg_tac (Arg_term (`(h o drop) differentiable at (lift (&0))`))) (term_tac (have_gen_tac [](move ["dh"])))) (((((use_arg_then "h_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "diff_direction")(thm_tac (new_rewrite [] []))))) THEN (done_tac))); ((((use_arg_then "ETA_AX")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN ((repeat_tactic 1 9 (((use_arg_then "diff_imp_real_diff")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "h0")(thm_tac (new_rewrite [] [])))))) THEN (done_tac)); ];; (* Finalization of the section Partial *) let real_derivative_compose_frechet = finalize_theorem real_derivative_compose_frechet;; let real_derivative_compose_jacobian = finalize_theorem real_derivative_compose_jacobian;; let diff_imp_real_diff = finalize_theorem diff_imp_real_diff;; let diff_direction = finalize_theorem diff_direction;; let frechet_direction = finalize_theorem frechet_direction;; let real_dir_derivative_frechet = finalize_theorem real_dir_derivative_frechet;; let real_dir_derivative_jacobian = finalize_theorem real_dir_derivative_jacobian;; let partial_eq_frechet = finalize_theorem partial_eq_frechet;; let partial_eq_jacobian = finalize_theorem partial_eq_jacobian;; let partial_eq_jacobian_column = finalize_theorem partial_eq_jacobian_column;; let partial_eq_jacobian_entry = finalize_theorem partial_eq_jacobian_entry;; let partial_eq0 = finalize_theorem partial_eq0;; let derivative_compose = finalize_theorem derivative_compose;; let projection_has_derivative = finalize_theorem projection_has_derivative;; let projection_diff = finalize_theorem projection_diff;; let frechet_projection = finalize_theorem frechet_projection;; let has_derivative_vector_frechet = finalize_theorem has_derivative_vector_frechet;; let has_derivative_vector_jacobian = finalize_theorem has_derivative_vector_jacobian;; let derivative_vector_jacobian = finalize_theorem derivative_vector_jacobian;; let real_derivative_compose_partial = finalize_theorem real_derivative_compose_partial;; let real_dir_derivative_partial = finalize_theorem real_dir_derivative_partial;; let partial_uni_compose = finalize_theorem partial_uni_compose;; let partial_neg = finalize_theorem partial_neg;; let partial_scale = finalize_theorem partial_scale;; let partial_add = finalize_theorem partial_add;; let partial_sub = finalize_theorem partial_sub;; let partial_mul = finalize_theorem partial_mul;; end_section "Partial";; (* Section PartialMonotone *) begin_section "PartialMonotone";; (* Lemma derivative_translation *) let derivative_translation = section_proof ["f";"x"] `f real_differentiable atreal x ==> derivative f x = derivative (f o (\t. x + t)) (&0)` [ (BETA_TAC THEN (move ["diff_f"])); ((((use_arg_then "derivative_compose")(thm_tac (new_rewrite [] [])))) THEN (simp_tac) THEN (repeat_tactic 0 10 (((use_arg_then "REAL_ADD_RID")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "diff_f")(thm_tac (new_rewrite [] [])))))); (((((use_arg_then "REAL_DIFFERENTIABLE_ADD")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "REAL_DIFFERENTIABLE_CONST")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "REAL_DIFFERENTIABLE_ID")(thm_tac (new_rewrite [] [])))))) THEN (done_tac)); ((((use_arg_then "derivative_add")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "REAL_DIFFERENTIABLE_CONST")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "REAL_DIFFERENTIABLE_ID")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac))); (((((use_arg_then "derivative_const")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "derivative_x")(thm_tac (new_rewrite [] [])))) THEN (simp_tac)) THEN (arith_tac) THEN (done_tac)); ];; (add_section_type (mk_var ("f", (`:real^N->real`))));; (* Lemma partial_increasing_left *) let partial_increasing_left = section_proof ["f";"j";"u";"x";"z";"lo"] `(!i. i IN 1..dimindex (:N) ==> ~(i = j) ==> u$i = z$i) ==> u$j = x$j ==> (!y. y IN interval [x,z] ==> (lift o f) differentiable at y) ==> (!y. y IN interval [x,z] ==> &0 <= partial j f y) ==> (!y. y IN interval [x,u] ==> lo <= f y) ==> (!y. y IN interval [x,z] ==> lo <= f y)` [ (((((use_arg_then "IN_NUMSEG")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL IN_INTERVAL)))(thm_tac (new_rewrite [] [])))))) THEN (move ["uz_eq"]) THEN (move ["ux_eq"]) THEN (move ["diff_f"]) THEN (move ["partial_pos"]) THEN (move ["f_bound"]) THEN (move ["y"]) THEN (move ["y_in"])); ((((use_arg_then "partial_pos") (disch_tac [])) THEN (clear_assumption "partial_pos") THEN ((use_arg_then "diff_f") (disch_tac [])) THEN (clear_assumption "diff_f") THEN BETA_TAC) THEN ((repeat_tactic 1 9 (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL IN_INTERVAL)))(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (move ["diff_f"]) THEN (move ["partial_pos"]))); ((fun arg_tac -> arg_tac (Arg_term (`(lambda i. if i = j then x$j else y$i):real^N`))) (term_tac (set_tac "y'"))); (((THENL_ROT 1)) ((fun arg_tac -> arg_tac (Arg_term (`f y' <= f y`))) (term_tac (have_gen_tac []ALL_TAC)))); ((((fun arg_tac -> arg_tac (Arg_theorem (REWRITE_RULE[GSYM IMP_IMP] REAL_LE_TRANS))) (disch_tac [])) THEN (DISCH_THEN apply_tac)) THEN (((use_arg_then "f_bound") (disch_tac [])) THEN (clear_assumption "f_bound") THEN (DISCH_THEN apply_tac) THEN (move ["i"]) THEN (move ["i_in"]))); ((((use_arg_then "y'_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL LAMBDA_BETA)))(thm_tac (new_rewrite [] [])))) THEN ((simp_tac THEN TRY done_tac))); ((THENL_FIRST) (((fun arg_tac -> (use_arg_then "EXCLUDED_MIDDLE") (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`i = j`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN case THEN (simp_tac) THEN (move ["ij"])) (((((use_arg_then "ux_eq")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_LE_REFL")(thm_tac (new_rewrite [] []))))) THEN (done_tac))); (((((use_arg_then "uz_eq")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (repeat_tactic 1 9 (((use_arg_then "y_in")(thm_tac (new_rewrite [] [])))))) THEN (done_tac)); (((THENL_ROT (-1)) (((fun arg_tac -> (use_arg_then "EXCLUDED_MIDDLE") (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`j IN 1..dimindex (:N)`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN case)) THEN ((((use_arg_then "IN_NUMSEG")(thm_tac (new_rewrite [] [])))) THEN (move ["j_in"]))); ((THENL_FIRST) (((THENL_ROT 1)) ((fun arg_tac -> arg_tac (Arg_term (`y' = y`))) (term_tac (have_gen_tac []ALL_TAC)))) ((BETA_TAC THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "REAL_LE_REFL")(thm_tac (new_rewrite [] [])))) THEN (done_tac))); ((((use_arg_then "CART_EQ")(thm_tac (new_rewrite [] [])))) THEN (move ["i"]) THEN (move ["i_in"])); ((THENL_FIRST) ((fun arg_tac -> arg_tac (Arg_term (`~(i = j)`))) (term_tac (have_gen_tac [](move ["inj"])))) ((((use_arg_then "i_in") (disch_tac [])) THEN (clear_assumption "i_in") THEN ((use_arg_then "j_in") (disch_tac [])) THEN (clear_assumption "j_in") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac))); (((((use_arg_then "y'_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL LAMBDA_BETA)))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ((fun arg_tac -> arg_tac (Arg_term (`f o (\t. y' + t % basis j)`))) (term_tac (set_tac "g"))); ((fun arg_tac -> arg_tac (Arg_term (`f y' = g (&0)`))) (term_tac (have_gen_tac [](((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))))); (((((use_arg_then "g_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "o_THM")(thm_tac (new_rewrite [] [])))) THEN (simp_tac) THEN (((use_arg_then "VECTOR_MUL_LZERO")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "VECTOR_ADD_RID")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ((fun arg_tac -> arg_tac (Arg_term (`f y = g (y$j - x$j)`))) (term_tac (have_gen_tac [](((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))))); (((((use_arg_then "g_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "o_THM")(thm_tac (new_rewrite [] [])))) THEN (simp_tac)) THEN (AP_TERM_TAC)); ((((use_arg_then "CART_EQ")(thm_tac (new_rewrite [] [])))) THEN (move ["i"]) THEN (move ["i_in"])); ((((use_arg_then "VECTOR_ADD_COMPONENT")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "VECTOR_MUL_COMPONENT")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "BASIS_COMPONENT")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac))); ((((fun arg_tac -> (use_arg_then "EXCLUDED_MIDDLE") (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`i = j`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN case THEN (simp_tac) THEN (move ["ij"])) THEN ((((use_arg_then "y'_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL LAMBDA_BETA)))(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)))); ((arith_tac) THEN (done_tac)); (((simp_tac) THEN (((use_arg_then "ij")(thm_tac (new_rewrite [] [])))) THEN (simp_tac)) THEN (arith_tac) THEN (done_tac)); ((fun arg_tac -> arg_tac (Arg_term (`real_interval [&0, y$j - x$j]`))) (term_tac (set_tac "s"))); ((fun arg_tac -> arg_tac (Arg_term (`!t. t IN s ==> y' + t % basis j IN interval [x,z]`))) (term_tac (have_gen_tac [](move ["in_s"])))); (((((use_arg_then "s_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "IN_REAL_INTERVAL")(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL IN_INTERVAL)))(thm_tac (new_rewrite [] []))))) THEN (move ["t"]) THEN (move ["t_ineq"]) THEN (move ["i"]) THEN (move ["i_ineq"])); ((repeat_tactic 1 9 (((use_arg_then "VECTOR_ADD_COMPONENT")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "VECTOR_MUL_COMPONENT")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "BASIS_COMPONENT")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac))); ((((use_arg_then "y'_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL LAMBDA_BETA)))(thm_tac (new_rewrite [] [])))) THEN ((simp_tac THEN TRY done_tac))); ((THENL_ROT (-1)) (((fun arg_tac -> (use_arg_then "EXCLUDED_MIDDLE") (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`i = j`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN case THEN (simp_tac) THEN (move ["ij"]))); (((((use_arg_then "REAL_MUL_RZERO")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_ADD_RID")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "y_in")(thm_tac (new_rewrite [] [])))))) THEN (done_tac)); ((((use_arg_then "t_ineq") (disch_tac [])) THEN (clear_assumption "t_ineq") THEN ((fun arg_tac -> (use_arg_then "y_in") (fun fst_arg -> (use_arg_then "i_ineq") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC) THEN (((use_arg_then "ij")(thm_tac (new_rewrite [] [])))) THEN (arith_tac) THEN (done_tac)); ((fun arg_tac -> arg_tac (Arg_term (`!t. t IN s ==> (g has_real_derivative (partial j f (y' + t % basis j))) (atreal t within s)`))) (term_tac (have_gen_tac [](move ["ds"])))); ((BETA_TAC THEN (move ["t"]) THEN (DISCH_THEN (fun snd_th -> (use_arg_then "in_s") (thm_tac (match_mp_then snd_th MP_TAC)))) THEN (move ["p_in"])) THEN (((use_arg_then "HAS_REAL_DERIVATIVE_ATREAL_WITHIN") (disch_tac [])) THEN (clear_assumption "HAS_REAL_DERIVATIVE_ATREAL_WITHIN") THEN (DISCH_THEN apply_tac)) THEN (((use_arg_then "partial")(thm_tac (new_rewrite [] []))))); ((fun arg_tac -> arg_tac (Arg_term (`f o _`))) (term_tac (set_tac "h"))); ((fun arg_tac -> arg_tac (Arg_term (`h = g o (\t'. t + t')`))) (term_tac (have_gen_tac [](((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))))); ((((((use_arg_then "eq_ext")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "h_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "g_def")(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (move ["r"])) THEN ((repeat_tactic 1 9 (((use_arg_then "o_THM")(thm_tac (new_rewrite [] []))))) THEN (simp_tac))); (((((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL VECTOR_ADD_RDISTRIB)))(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL VECTOR_ADD_ASSOC)))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); (((((use_arg_then "derivative_translation")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "has_derivative_alt")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "g_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "diff_imp_real_diff")(thm_tac (new_rewrite [] []))))) THEN ((((use_arg_then "diff_f")(thm_tac (new_rewrite [] [])))) THEN ((simp_tac THEN TRY done_tac)) THEN (((use_arg_then "diff_direction")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ((THENL_FIRST) ((fun arg_tac -> arg_tac (Arg_term (`&0 <= y$j - x$j`))) (term_tac (have_gen_tac [](move ["pos"])))) ((((fun arg_tac -> (use_arg_then "y_in") (fun fst_arg -> (use_arg_then "j_in") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC) THEN (arith_tac) THEN (done_tac))); ((fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (use_arg_then "HAS_REAL_DERIVATIVE_INCREASING_IMP") (fun fst_arg -> (use_arg_then "g") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`\t. partial j f (y' + t % basis j)`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "s") (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 (`y$j - x$j`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun arg -> thm_tac MP_TAC arg THEN ALL_TAC)); (((((use_arg_then "s_def")(gsym_then (thm_tac (new_rewrite [1] []))))) THEN (((use_arg_then "IS_REALINTERVAL_INTERVAL")(thm_tac (new_rewrite [] [])))) THEN (simp_tac)) THEN ((((use_arg_then "ds")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN (simp_tac)) THEN (DISCH_THEN apply_tac)); ((((use_arg_then "s_def")(gsym_then (thm_tac (new_rewrite [2; 3] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "IN_REAL_INTERVAL")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "pos")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "REAL_LE_REFL")(thm_tac (new_rewrite [] []))))) THEN (simp_tac)); ((BETA_TAC THEN (move ["t"]) THEN (DISCH_THEN (fun snd_th -> (use_arg_then "in_s") (thm_tac (match_mp_then snd_th MP_TAC)))) THEN (DISCH_THEN (fun snd_th -> (use_arg_then "partial_pos") (thm_tac (match_mp_then snd_th MP_TAC))))) THEN (done_tac)); ];; (* Lemma partial_decreasing_left *) let partial_decreasing_left = section_proof ["f";"j";"u";"x";"z";"hi"] `(!i. i IN 1..dimindex (:N) ==> ~(i = j) ==> u$i = z$i) ==> u$j = x$j ==> (!y. y IN interval [x,z] ==> (lift o f) differentiable at y) ==> (!y. y IN interval [x,z] ==> partial j f y <= &0) ==> (!y. y IN interval [x,u] ==> f y <= hi) ==> (!y. y IN interval [x,z] ==> f y <= hi)` [ (BETA_TAC THEN (move ["u_eq_i"]) THEN (move ["u_eq_j"]) THEN (move ["diff_f"]) THEN (move ["partial_f"]) THEN (move ["f_bound"]) THEN (move ["y"]) THEN (move ["y_in"])); ((fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (use_arg_then "partial_increasing_left") (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`(\p. -- f p)`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "j") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "u") (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 fst_arg -> (use_arg_then "z") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`--hi`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "u_eq_i") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "u_eq_j") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun arg -> thm_tac MP_TAC arg THEN ALL_TAC)); ((THENL_FIRST) (ANTS_TAC) ((BETA_TAC THEN (move ["p"]) THEN (DISCH_THEN (fun snd_th -> (use_arg_then "diff_f") (thm_tac (match_mp_then snd_th MP_TAC)))) THEN (DISCH_THEN (fun snd_th -> (use_arg_then "DIFFERENTIABLE_NEG") (thm_tac (match_mp_then snd_th MP_TAC))))) THEN (((use_arg_then "f_lift_neg")(thm_tac (new_rewrite [] [])))) THEN (done_tac))); (ANTS_TAC); ((BETA_TAC THEN (move ["p"]) THEN (move ["p_in"])) THEN ((((use_arg_then "partial_neg")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "diff_f")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((use_arg_then "REAL_NEG_GE0")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "partial_f")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ((THENL_FIRST) (ANTS_TAC) ((BETA_TAC THEN (move ["p"]) THEN (DISCH_THEN (fun snd_th -> (use_arg_then "f_bound") (thm_tac (match_mp_then snd_th MP_TAC))))) THEN (arith_tac) THEN (done_tac))); ((((fun arg_tac -> (conv_thm_tac DISCH_THEN) (fun fst_arg -> (use_arg_then "y_in") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (thm_tac MP_TAC)) THEN BETA_TAC) THEN (arith_tac) THEN (done_tac)); ];; (* Lemma partial_translation *) let partial_translation = section_proof ["f";"i";"p";"y"] `lift o f differentiable at (p + y) ==> partial i (f o (\x. p + x)) y = partial i f (p + y)` [ (BETA_TAC THEN (move ["diff"])); ((fun arg_tac -> arg_tac (Arg_term (`!net. (\x. p + x) differentiable net`))) (term_tac (have_gen_tac [](move ["diff_p"])))); ((BETA_TAC THEN (move ["net"])) THEN ((((use_arg_then "DIFFERENTIABLE_ADD")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "DIFFERENTIABLE_CONST")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "DIFFERENTIABLE_ID")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ((((use_arg_then "partial_eq_frechet")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 1 (((use_arg_then "o_ASSOC")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "DIFFERENTIABLE_CHAIN_AT")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac))); ((((use_arg_then "frechet_compose")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "frechet_add")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "DIFFERENTIABLE_ID")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "DIFFERENTIABLE_CONST")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac))); ((((use_arg_then "frechet_const")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "frechet_id")(thm_tac (new_rewrite [] [])))) THEN (simp_tac) THEN (((use_arg_then "VECTOR_ADD_LID")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "I_DEF")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "I_O_ID")(thm_tac (new_rewrite [] []))))); ((((use_arg_then "partial_eq_frechet")(thm_tac (new_rewrite [] [])))) THEN (done_tac)); ];; (* Lemma partial_rev_translation *) let partial_rev_translation = section_proof ["f";"i";"p";"y"] `lift o f differentiable at (p - y) ==> partial i (f o (\x. p - x)) y = --partial i f (p - y)` [ (BETA_TAC THEN (move ["diff"])); ((fun arg_tac -> arg_tac (Arg_term (`!net. (\x. p - x) differentiable net`))) (term_tac (have_gen_tac [](move ["diff_p"])))); ((BETA_TAC THEN (move ["net"])) THEN ((((use_arg_then "DIFFERENTIABLE_SUB")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "DIFFERENTIABLE_CONST")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "DIFFERENTIABLE_ID")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ((((use_arg_then "partial_eq_frechet")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 1 (((use_arg_then "o_ASSOC")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "DIFFERENTIABLE_CHAIN_AT")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac))); ((((use_arg_then "frechet_compose")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "frechet_sub")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "DIFFERENTIABLE_ID")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "DIFFERENTIABLE_CONST")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac))); ((((use_arg_then "frechet_const")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "frechet_id")(thm_tac (new_rewrite [] [])))) THEN (simp_tac) THEN (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL VECTOR_SUB_LZERO)))(thm_tac (new_rewrite [] []))))); ((((use_arg_then "partial_eq_frechet")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (repeat_tactic 1 9 (((use_arg_then "o_THM")(thm_tac (new_rewrite [] []))))) THEN (simp_tac)); (((((use_arg_then "LINEAR_NEG")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "LINEAR_FRECHET_DERIVATIVE")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((use_arg_then "DROP_NEG")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma partial_increasing_right *) let partial_increasing_right = section_proof ["f";"j";"u";"x";"z";"hi"] `(!i. i IN 1..dimindex (:N) ==> ~(i = j) ==> u$i = x$i) ==> u$j = z$j ==> (!y. y IN interval [x,z] ==> (lift o f) differentiable at y) ==> (!y. y IN interval [x,z] ==> &0 <= partial j f y) ==> (!y. y IN interval [u,z] ==> f y <= hi) ==> (!y. y IN interval [x,z] ==> f y <= hi)` [ (BETA_TAC THEN (move ["u_eq_i"]) THEN (move ["u_eq_j"]) THEN (move ["diff_f"]) THEN (move ["partial_f"]) THEN (move ["f_bound"]) THEN (move ["y"]) THEN (move ["y_in"])); (((THENL_ROT (-1)) (((fun arg_tac -> (use_arg_then "EXCLUDED_MIDDLE") (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`j IN 1..dimindex (:N)`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN case)) THEN ((((use_arg_then "IN_NUMSEG")(thm_tac (new_rewrite [] [])))) THEN (move ["j_in"]))); ((((use_arg_then "f_bound") (disch_tac [])) THEN (clear_assumption "f_bound") THEN (DISCH_THEN apply_tac)) THEN (((use_arg_then "y_in") (disch_tac [])) THEN (clear_assumption "y_in") THEN BETA_TAC) THEN ((repeat_tactic 1 9 (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL IN_INTERVAL)))(thm_tac (new_rewrite [] []))))) THEN (move ["y_ineq"]) THEN (move ["i"]) THEN (move ["i_in"]))); ((THENL_FIRST) ((fun arg_tac -> arg_tac (Arg_term (`~(i = j)`))) (term_tac (have_gen_tac [](move ["inj"])))) ((((use_arg_then "i_in") (disch_tac [])) THEN (clear_assumption "i_in") THEN ((use_arg_then "j_in") (disch_tac [])) THEN (clear_assumption "j_in") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac))); (((((use_arg_then "u_eq_i")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "IN_NUMSEG")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (repeat_tactic 1 9 (((use_arg_then "y_ineq")(thm_tac (new_rewrite [] [])))))) THEN (done_tac)); ((fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (use_arg_then "partial_decreasing_left") (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`f o (\p:real^N. x + (z - p))`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "j") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`x + (z - u):real^N`))) (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 fst_arg -> (use_arg_then "z") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "hi") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun arg -> thm_tac MP_TAC arg THEN ALL_TAC)); (ANTS_TAC); ((BETA_TAC THEN (move ["i"]) THEN (DISCH_THEN (fun snd_th -> (use_arg_then "u_eq_i") (thm_tac (match_mp_then snd_th MP_TAC)))) THEN (move ["eq1"]) THEN (move ["inj"])) THEN ((((use_arg_then "VECTOR_ADD_COMPONENT")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "VECTOR_SUB_COMPONENT")(thm_tac (new_rewrite [] [])))))); (((((use_arg_then "eq1")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac))) THEN (arith_tac) THEN (done_tac)); ((THENL_FIRST) (ANTS_TAC) (((((use_arg_then "VECTOR_ADD_COMPONENT")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "VECTOR_SUB_COMPONENT")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "u_eq_j")(thm_tac (new_rewrite [] []))))) THEN (arith_tac) THEN (done_tac))); ((fun arg_tac -> arg_tac (Arg_term (`!p. p IN interval [x,z] ==> x + (z - p) IN interval [x,z]`))) (term_tac (have_gen_tac [](move ["Hp"])))); ((BETA_TAC THEN (move ["p"])) THEN ((repeat_tactic 1 9 (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL IN_INTERVAL)))(thm_tac (new_rewrite [] []))))) THEN (move ["p_in"]) THEN (move ["i"]) THEN (move ["ineq"]))); ((((fun arg_tac -> (use_arg_then "p_in") (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 ((((use_arg_then "VECTOR_ADD_COMPONENT")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "VECTOR_SUB_COMPONENT")(thm_tac (new_rewrite [] []))))) THEN (arith_tac) THEN (done_tac)); ((fun arg_tac -> arg_tac (Arg_term (`!y. _ y`))) (term_tac (set_tac "dP"))); ((fun arg_tac -> arg_tac (Arg_term (`dP`))) (term_tac (have_gen_tac [](move ["P"])))); ((((use_arg_then "dP_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (BETA_TAC THEN (move ["p"]) THEN (move ["p_in"]))); (((((use_arg_then "o_ASSOC")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "DIFFERENTIABLE_CHAIN_AT")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "DIFFERENTIABLE_ADD")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "DIFFERENTIABLE_SUB")(thm_tac (new_rewrite [] [])))))) THEN ((repeat_tactic 0 10 (((use_arg_then "DIFFERENTIABLE_ID")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "DIFFERENTIABLE_CONST")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((use_arg_then "diff_f")(thm_tac (new_rewrite [] [])))) THEN ((simp_tac THEN TRY done_tac)) THEN (((use_arg_then "Hp")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ((((use_arg_then "P") (disch_tac [])) THEN (clear_assumption "P") THEN BETA_TAC THEN (simp_tac)) THEN ((((use_arg_then "dP_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (move ["diff"]))); (ANTS_TAC); (BETA_TAC THEN (move ["p"]) THEN (move ["p_in"])); ((fun arg_tac -> arg_tac (Arg_theorem (VECTOR_ARITH `!x z p. x + z - p = (x + z) - p:real^N`))) (fun arg -> thm_tac MP_TAC arg THEN (move ["assoc"]))); ((((use_arg_then "assoc")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "partial_rev_translation")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "assoc")(gsym_then (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 "Hp")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac))); (((((use_arg_then "REAL_NEG_LE0")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "partial_f")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "Hp")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); (ANTS_TAC); ((BETA_TAC THEN (move ["p"]) THEN (move ["p_in"])) THEN ((((use_arg_then "o_THM")(thm_tac (new_rewrite [] [])))) THEN (simp_tac) THEN (((use_arg_then "f_bound")(thm_tac (new_rewrite [] [])))))); ((((use_arg_then "p_in") (disch_tac [])) THEN (clear_assumption "p_in") THEN BETA_TAC) THEN ((repeat_tactic 1 9 (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL IN_INTERVAL)))(thm_tac (new_rewrite [] []))))) THEN (move ["ineq"]) THEN (move ["i"]) THEN (move ["i_ineq"]))); ((((fun arg_tac -> (use_arg_then "ineq") (fun fst_arg -> (use_arg_then "i_ineq") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC) THEN ((repeat_tactic 1 9 (((use_arg_then "VECTOR_ADD_COMPONENT")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "VECTOR_SUB_COMPONENT")(thm_tac (new_rewrite [] [])))))) THEN (arith_tac) THEN (done_tac)); ((((fun arg_tac -> (conv_thm_tac DISCH_THEN) (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`x + z - y:real^N`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (thm_tac MP_TAC)) THEN BETA_TAC) THEN ((((use_arg_then "o_THM")(thm_tac (new_rewrite [] [])))) THEN (simp_tac))); ((((fun arg_tac -> arg_tac (Arg_theorem (VECTOR_ARITH `!x z y:real^N. x + z - (x + z - y) = y`)))(thm_tac (new_rewrite [] [])))) THEN (DISCH_THEN apply_tac)); ((((use_arg_then "Hp")(thm_tac (new_rewrite [] [])))) THEN (done_tac)); ];; (* Finalization of the section PartialMonotone *) let derivative_translation = finalize_theorem derivative_translation;; let partial_increasing_left = finalize_theorem partial_increasing_left;; let partial_decreasing_left = finalize_theorem partial_decreasing_left;; let partial_translation = finalize_theorem partial_translation;; let partial_rev_translation = finalize_theorem partial_rev_translation;; let partial_increasing_right = finalize_theorem partial_increasing_right;; end_section "PartialMonotone";; (* Section Taylor *) begin_section "Taylor";; (* Lemma real_taylor2_bound *) let real_taylor2_bound = section_proof ["f";"dd_bound"] `nth_diff_strong_int 2 (&0, &1) f ==> (!t. interval_arith t (&0, &1) ==> abs (nth_derivative 2 f t) <= dd_bound) ==> abs (f (&1) - (f (&0) + derivative f (&0))) <= dd_bound / &2` [ (((((use_arg_then "nth_diff_strong_int")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "nth_diff_strong2_eq_alt")(thm_tac (new_rewrite [] []))))) THEN (move ["df"]) THEN (move ["dd"])); ((fun arg_tac -> arg_tac (Arg_term (`\i. if i = 0 then f else if i = 1 then derivative f else nth_derivative 2 f`))) (term_tac (set_tac "R"))); ((fun arg_tac -> arg_tac (Arg_theorem (ARITH_RULE `0 + 1 = 1 /\ ~(1 = 0) /\ 1 + 1 = 2 /\ ~(2 = 1) /\ ~(2 = 0)`))) (fun arg -> thm_tac MP_TAC arg THEN (move ["arithH"]))); ((((fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (use_arg_then "REAL_TAYLOR") (fun fst_arg -> (use_arg_then "R") (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 [&0, &1]`))) (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))) (disch_tac [])) THEN BETA_TAC) THEN (ANTS_TAC)); (((((use_arg_then "IS_REALINTERVAL_INTERVAL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))) THEN (split_tac)); ((BETA_TAC THEN (move ["i"]) THEN (move ["x"])) THEN ((((use_arg_then "IN_REAL_INTERVAL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "interval_arith")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((fun arg_tac -> arg_tac (Arg_theorem (ARITH_RULE `i <= 1 <=> i = 0 \/ i = 1`)))(thm_tac (new_rewrite [] [])))))); (BETA_TAC THEN (case THEN ALL_TAC) THEN (DISCH_THEN (fun snd_th -> (use_arg_then "df") (thm_tac (match_mp_then snd_th MP_TAC)))) THEN (case THEN (move ["s"])) THEN (move ["d_f"])); ((case THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))) THEN ((((use_arg_then "R_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (repeat_tactic 1 9 (((use_arg_then "arithH")(thm_tac (new_rewrite [] []))))) THEN (simp_tac)) THEN ((use_arg_then "HAS_REAL_DERIVATIVE_ATREAL_WITHIN") (thm_tac apply_tac)) THEN (((use_arg_then "d_f")(thm_tac (new_rewrite [] [])))) THEN (done_tac)); ((BETA_TAC THEN (move ["x"])) THEN (((((use_arg_then "IN_REAL_INTERVAL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "interval_arith")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "arithH")(thm_tac (new_rewrite [] []))))) THEN (move ["ineq"]))); ((((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 ["s"])) THEN (move ["d_f"])) THEN ((((use_arg_then "R_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (repeat_tactic 1 9 (((use_arg_then "arithH")(thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (((use_arg_then "dd")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ((((fun arg_tac -> (fun arg_tac -> (conv_thm_tac DISCH_THEN) (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 (`&1`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (thm_tac MP_TAC)) THEN BETA_TAC) THEN ((repeat_tactic 1 9 (((use_arg_then "IN_REAL_INTERVAL")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "REAL_LE_REFL")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "REAL_LE_01")(thm_tac (new_rewrite [] [])))) THEN (simp_tac))); ((((use_arg_then "REAL_SUB_RZERO")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_ABS_1")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "REAL_POW_ONE")(thm_tac (new_rewrite [] []))))) THEN (((fun arg_tac -> arg_tac (Arg_theorem (ARITH_RULE `FACT (1 + 1) = 2`)))(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_LID")(thm_tac (new_rewrite [] [])))))); ((((use_arg_then "ONE")(thm_tac (new_rewrite [2] [])))) 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 (((use_arg_then "ONE")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((fun arg_tac -> arg_tac (Arg_theorem (ARITH_RULE `0 <= 1`)))(thm_tac (new_rewrite [] [])))) THEN (simp_tac)); ((repeat_tactic 1 9 (((fun arg_tac -> arg_tac (Arg_theorem (ARITH_RULE `FACT 0 = 1 /\ FACT 1 = 1`)))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "REAL_INV_1")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "REAL_MUL_RID")(thm_tac (new_rewrite [] [])))))); (((((use_arg_then "R_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (repeat_tactic 1 9 (((use_arg_then "arithH")(thm_tac (new_rewrite [] [])))))) THEN (done_tac)); ];; (* Lemma real_taylor1_bound *) let real_taylor1_bound = section_proof ["f";"d_bound"] `(!t. interval_arith t (&0, &1) ==> f real_differentiable atreal t /\ abs (derivative f t) <= d_bound) ==> abs (f (&1) - f (&0)) <= d_bound` [ (BETA_TAC THEN (move ["df"])); ((fun arg_tac -> arg_tac (Arg_term (`\i. if i = 0 then f else derivative f`))) (term_tac (set_tac "R"))); ((fun arg_tac -> arg_tac (Arg_theorem (ARITH_RULE `0 + 1 = 1 /\ ~(1 = 0)`))) (fun arg -> thm_tac MP_TAC arg THEN (move ["arithH"]))); ((((fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (use_arg_then "REAL_TAYLOR") (fun fst_arg -> (use_arg_then "R") (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 [&0, &1]`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "d_bound") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC) THEN (ANTS_TAC)); (((((use_arg_then "IS_REALINTERVAL_INTERVAL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))) THEN (split_tac)); ((BETA_TAC THEN (move ["i"]) THEN (move ["x"])) THEN ((((use_arg_then "IN_REAL_INTERVAL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "interval_arith")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "leqn0")(thm_tac (new_rewrite [] [])))))); (BETA_TAC THEN (case THEN ALL_TAC) THEN (DISCH_THEN (fun snd_th -> (use_arg_then "df") (thm_tac (match_mp_then snd_th MP_TAC)))) THEN (case THEN ((move ["diff_f"]) THEN (move ["df_bound"]))) THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))); (((((use_arg_then "R_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (repeat_tactic 1 9 (((use_arg_then "arithH")(thm_tac (new_rewrite [] []))))) THEN (simp_tac)) THEN ((use_arg_then "HAS_REAL_DERIVATIVE_ATREAL_WITHIN") (thm_tac apply_tac)) THEN (((use_arg_then "has_derivative_alt")(thm_tac (new_rewrite [] [])))) THEN (done_tac)); ((BETA_TAC THEN (move ["x"])) THEN (((((use_arg_then "IN_REAL_INTERVAL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "interval_arith")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "arithH")(thm_tac (new_rewrite [] []))))) THEN (move ["ineq"]))); ((((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 ["s"])) THEN (move ["d_f"])) THEN ((((use_arg_then "R_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (repeat_tactic 1 9 (((use_arg_then "arithH")(thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (((use_arg_then "df")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ((((fun arg_tac -> (fun arg_tac -> (conv_thm_tac DISCH_THEN) (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 (`&1`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (thm_tac MP_TAC)) THEN BETA_TAC) THEN ((repeat_tactic 1 9 (((use_arg_then "IN_REAL_INTERVAL")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "REAL_LE_REFL")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "REAL_LE_01")(thm_tac (new_rewrite [] [])))) THEN (simp_tac))); ((((use_arg_then "SUM_SING_NUMSEG")(thm_tac (new_rewrite [] [])))) THEN (simp_tac) THEN (((use_arg_then "REAL_SUB_RZERO")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "arithH")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_ABS_1")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "REAL_POW_ONE")(thm_tac (new_rewrite [] [])))))); ((repeat_tactic 1 9 (((fun arg_tac -> arg_tac (Arg_theorem (ARITH_RULE `FACT 1 = 1 /\ FACT 0 = 1`)))(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "REAL_DIV_1")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "REAL_MUL_RID")(thm_tac (new_rewrite [] [])))))); (((((use_arg_then "R_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (repeat_tactic 1 9 (((use_arg_then "arithH")(thm_tac (new_rewrite [] [])))))) THEN (done_tac)); ];;
let m_taylor_error = new_definition `m_taylor_error f domain (w:real^N) error <=>
	!x:real^N. x IN interval [domain] ==> sum (1..dimindex (:N)) (\i. w$i * sum (1..dimindex (:N))
		(\j. w$j * abs (partial j (partial i f) x))) <= error`;;
let m_taylor_partial_error = new_definition `m_taylor_partial_error f i domain (w:real^N) error <=>
	(!x:real^N. x IN interval[domain] ==>
		sum (1..dimindex (:N)) (\j. w$j * abs (partial j (partial i f) x)) <= error)`;;
(* Lemma taylor_error_eq_sum_partial_errors *) let taylor_error_eq_sum_partial_errors = section_proof ["f";"domain";"w";"p_error";"error"] `(!i. i IN 1..dimindex (:N) ==> m_taylor_partial_error f i domain w (p_error i) /\ &0 <= w$i) ==> sum (1..dimindex (:N)) (\i. w$i * p_error i) <= error ==> m_taylor_error f domain (w:real^N) error` [ (((((use_arg_then "m_taylor_partial_error")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "m_taylor_error")(thm_tac (new_rewrite [] []))))) THEN (move ["partialH"]) THEN (move ["ineq"]) THEN (move ["p"]) THEN (move ["p_in"])); (((use_arg_then "ineq") (disch_tac [])) THEN (clear_assumption "ineq") THEN ((fun arg_tac -> arg_tac (Arg_theorem (REWRITE_RULE[GSYM IMP_IMP] REAL_LE_TRANS))) (disch_tac [])) THEN (DISCH_THEN apply_tac)); (((use_arg_then "SUM_LE") (thm_tac apply_tac)) THEN (((((use_arg_then "FINITE_NUMSEG")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))) THEN (move ["i"]) THEN (move ["i_ineq"]) THEN (simp_tac))); (((((use_arg_then "REAL_LE_LMUL")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((fun arg_tac -> (use_arg_then "partialH") (fun fst_arg -> (use_arg_then "i_ineq") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [])))))) THEN (done_tac)); ];;
let partial2 = new_definition `partial2 j i f = partial j (partial i f)`;;
let diff2 = new_definition `diff2 f x <=>
	?s. open s /\ x IN s /\ (!y. y IN s ==> (lift o f) differentiable at y /\
		(!i. (lift o partial i f) differentiable at y))`;;
let diff2c = new_definition `diff2c f x <=> diff2 f x /\
	(!i j. (lift o partial2 j i f) continuous at x)`;;
(* Lemma diff2c_imp_diff2 *) let diff2c_imp_diff2 = section_proof ["f";"x"] `diff2c f x ==> diff2 f x` [ (((((use_arg_then "diff2c")(thm_tac (new_rewrite [] [])))) THEN (simp_tac)) THEN (done_tac)); ];; (* Lemma diff2_eq_diff2_on_open *) let diff2_eq_diff2_on_open = section_proof ["f";"x"] `diff2 f x <=> ?s. open s /\ x IN s /\ (!y. y IN s ==> diff2 f y)` [ ((repeat_tactic 1 9 (((use_arg_then "diff2")(thm_tac (new_rewrite [] []))))) THEN ((split_tac) THEN ALL_TAC THEN (case THEN (move ["s"])) THEN (case THEN (move ["open_s"])) THEN (case THEN (move ["xs"])) THEN (move ["df"]))); (((use_arg_then "s") (term_tac exists_tac)) THEN (((((use_arg_then "open_s")(thm_tac (new_rewrite [1] [])))) 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 (move ["ys"])) THEN ((use_arg_then "s") (term_tac exists_tac)) THEN (done_tac)); ((((fun arg_tac -> (use_arg_then "df") (fun fst_arg -> (use_arg_then "xs") (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 ["df2"])) THEN (((use_arg_then "df") (disch_tac [])) THEN (clear_assumption "df") THEN BETA_TAC THEN (move ["_"]))); (((use_arg_then "t") (term_tac exists_tac)) THEN (done_tac)); ];; (* Lemma diff2_imp_real_diff *) let diff2_imp_real_diff = section_proof ["f";"x";"e";"t"] `diff2 f (x + t % e) ==> f o (\t. x + t % e) real_differentiable atreal t` [ ((((use_arg_then "diff2")(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 ["df"])); (((use_arg_then "diff_imp_real_diff") (thm_tac apply_tac)) THEN ((simp_tac) THEN (((use_arg_then "df")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "diff_direction")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma diff2_dir_derivative *) let diff2_dir_derivative = section_proof ["f";"x";"e";"t"] `diff2 f (x + t % e:real^N) ==> derivative (f o (\t. x + t % e)) t = sum (1..dimindex (:N)) (\i. e$i * (partial i f o (\t. x + t % e)) t)` [ ((((use_arg_then "diff2")(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 ["df"])); ((((use_arg_then "derivative_unique") (disch_tac [])) THEN (clear_assumption "derivative_unique") THEN (DISCH_THEN apply_tac)) THEN ((((use_arg_then "real_dir_derivative_partial")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "df")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma diff2_partial_real_diff *) let diff2_partial_real_diff = section_proof ["f";"i";"x";"e";"t"] `diff2 f (x + t % e:real^N) ==> partial i f o (\t. x + t % e) real_differentiable atreal t` [ ((((use_arg_then "diff2")(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 ["df"])); (((((use_arg_then "diff_imp_real_diff")(thm_tac (new_rewrite [] [])))) THEN (simp_tac) THEN (((use_arg_then "df")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "diff_direction")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma in_trans *) let in_trans = section_proof ["x";"s";"t"] `t SUBSET s ==> x IN t ==> x IN s` [ ((((use_arg_then "SUBSET")(thm_tac (new_rewrite [] [])))) THEN (move ["sub"]) THEN (move ["xt"])); (((use_arg_then "sub") (disch_tac [])) THEN (clear_assumption "sub") THEN (exact_tac)); ];; (* Lemma open_contains_open_interval *) let open_contains_open_interval = section_proof ["e";"s";"x"] `open s ==> x IN s ==> ?a b. &0 IN real_interval (a, b) /\ IMAGE (\t. x + t % e) (real_interval (a, b)) SUBSET s` [ ((((use_arg_then "OPEN_CONTAINS_BALL")(thm_tac (new_rewrite [] [])))) THEN (move ["open_s"])); (((DISCH_THEN (fun snd_th -> (use_arg_then "open_s") (thm_tac (match_mp_then snd_th MP_TAC)))) THEN BETA_TAC THEN (case THEN (move ["d"])) THEN (case THEN (move ["d0"])) THEN (move ["ball_s"])) THEN (((use_arg_then "open_s") (disch_tac [])) THEN (clear_assumption "open_s") THEN BETA_TAC THEN (move ["_"]))); ((THENL) (((fun arg_tac -> (use_arg_then "EXCLUDED_MIDDLE") (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`norm e = &0`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN case) [ALL_TAC; (move ["n0"])]); (((((use_arg_then "NORM_EQ_0")(thm_tac (new_rewrite [] [])))) THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))) THEN (((fun arg_tac -> arg_tac (Arg_term (`--d`))) (term_tac exists_tac)) THEN ((use_arg_then "d") (term_tac exists_tac)))); ((THENL_FIRST) (split_tac) ((((use_arg_then "IN_REAL_INTERVAL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "d0") (disch_tac [])) THEN (clear_assumption "d0") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac))); ((((((use_arg_then "SUBSET")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "IN_IMAGE")(thm_tac (new_rewrite [] []))))) THEN (move ["y"]) THEN (case THEN (move ["t"])) THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] [])))) THEN (simp_tac)) THEN ((((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL VECTOR_MUL_RZERO)))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "VECTOR_ADD_RID")(thm_tac (new_rewrite [] [])))))); (((((fun arg_tac -> (use_arg_then "in_trans") (fun fst_arg -> (use_arg_then "ball_s") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "CENTRE_IN_BALL")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ((fun arg_tac -> arg_tac (Arg_term (`((d / &2) * inv(norm e)) % e`))) (term_tac (set_tac "y"))); ((fun arg_tac -> arg_tac (Arg_term (`norm y = d / &2`))) (term_tac (have_gen_tac [](move ["norm_y"])))); ((((use_arg_then "y_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "VECTOR_MUL_ASSOC")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "NORM_MUL")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "REAL_ABS_INV")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_ABS_NORM")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_MUL_LINV")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac))); ((((use_arg_then "d0") (disch_tac [])) THEN (clear_assumption "d0") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac)); ((((fun arg_tac -> arg_tac (Arg_term (`-- (d / &2 * inv (norm e))`))) (term_tac exists_tac)) THEN ((fun arg_tac -> arg_tac (Arg_term (`d / &2 * inv (norm e)`))) (term_tac exists_tac))) THEN (split_tac)); ((((use_arg_then "IN_REAL_INTERVAL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_NEG_LT0")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andbb")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_LT_MUL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_LT_INV")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "NORM_POS_LT")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "NORM_EQ_0")(gsym_then (thm_tac (new_rewrite [] [])))))) THEN ((TRY done_tac))); ((((use_arg_then "d0") (disch_tac [])) THEN (clear_assumption "d0") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac)); (((use_arg_then "SUBSET_TRANS") (thm_tac apply_tac)) THEN ((fun arg_tac -> arg_tac (Arg_term (`ball (x, d)`))) (term_tac exists_tac)) THEN (((((use_arg_then "ball_s")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andbT")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "SUBSET")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "IN_IMAGE")(thm_tac (new_rewrite [] []))))) THEN (move ["p"]) THEN (case THEN (move ["t"])) THEN (case THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))) THEN (move ["t_in"]) THEN (simp_tac))); ((((use_arg_then "IN_BALL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "dist")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "VECTOR_SUB_RADD")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "NORM_NEG")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "NORM_MUL")(thm_tac (new_rewrite [] []))))); ((THENL_LAST) ((((use_arg_then "REAL_LET_TRANS") (disch_tac [])) THEN (clear_assumption "REAL_LET_TRANS") THEN (DISCH_THEN apply_tac)) THEN ((fun arg_tac -> arg_tac (Arg_term (`d / &2`))) (term_tac exists_tac)) THEN (split_tac)) ((((use_arg_then "d0") (disch_tac [])) THEN (clear_assumption "d0") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac))); ((((fun arg_tac -> (use_arg_then "REAL_MUL_RID") (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`d / &2`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((fun arg_tac -> (use_arg_then "REAL_MUL_LINV") (fun fst_arg -> (use_arg_then "n0") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "REAL_MUL_ASSOC")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_LE_RMUL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "NORM_POS_LE")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andbT")(thm_tac (new_rewrite [] []))))); ((((use_arg_then "t_in") (disch_tac [])) THEN (clear_assumption "t_in") THEN BETA_TAC) THEN (((use_arg_then "IN_REAL_INTERVAL")(thm_tac (new_rewrite [] [])))) THEN (arith_tac) THEN (done_tac)); ];; (* Lemma diff2_dir *) let diff2_dir = section_proof ["f";"x";"e";"t"] `diff2 f (x + t % e:real^N) ==> nth_diff_strong 2 (f o (\t. x + t % e)) t` [ (((((use_arg_then "diff2_eq_diff2_on_open")(thm_tac (new_rewrite [] [])))) 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 (move ["df"])); (((fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (use_arg_then "open_contains_open_interval") (fun fst_arg -> (use_arg_then "e") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "open_s") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "xs") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC THEN (case THEN (move ["a"])) THEN (case THEN (move ["b"])) THEN (case THEN (move ["in0"])) THEN (move ["sub"])); (((fun arg_tac -> arg_tac (Arg_term (`real_interval (a + t, b + t)`))) (term_tac exists_tac)) THEN ((((use_arg_then "REAL_OPEN_REAL_INTERVAL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))) THEN (split_tac)); ((((use_arg_then "in0") (disch_tac [])) THEN (clear_assumption "in0") THEN BETA_TAC) THEN (repeat_tactic 1 9 (((use_arg_then "IN_REAL_INTERVAL")(thm_tac (new_rewrite [] []))))) THEN (arith_tac) THEN (done_tac)); (BETA_TAC THEN (move ["p"]) THEN (move ["p_int"])); ((fun arg_tac -> arg_tac (Arg_term (`x + p % e IN s`))) (term_tac (have_gen_tac [](move ["xp_in"])))); ((((use_arg_then "sub") (disch_tac [])) THEN (clear_assumption "sub") THEN BETA_TAC) THEN (((use_arg_then "SUBSET")(thm_tac (new_rewrite [] [])))) THEN (DISCH_THEN apply_tac) THEN ((((use_arg_then "IN_IMAGE")(thm_tac (new_rewrite [] [])))) THEN (simp_tac)) THEN ((fun arg_tac -> arg_tac (Arg_term (`p - t`))) (term_tac exists_tac))); (((THENL) (split_tac) [(VECTOR_ARITH_TAC); ((((use_arg_then "p_int") (disch_tac [])) THEN (clear_assumption "p_int") THEN BETA_TAC) THEN (repeat_tactic 1 9 (((use_arg_then "IN_REAL_INTERVAL")(thm_tac (new_rewrite [] []))))) THEN (arith_tac))]) THEN (done_tac)); ((((use_arg_then "diff2_imp_real_diff")(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 "andTb")(thm_tac (new_rewrite [] []))))); ((use_arg_then "differentiable_local") (thm_tac apply_tac)); ((fun arg_tac -> arg_tac (Arg_term (`\t. sum (1..dimindex(:N)) (\i. e$i * (partial i f o (\t. x + t % e)) t)`))) (term_tac exists_tac)); ((fun arg_tac -> arg_tac (Arg_term (`min (p - (a + t)) (b + t - p)`))) (term_tac (set_tac "d"))); ((THENL_FIRST) ((fun arg_tac -> arg_tac (Arg_term (`&0 < d`))) (term_tac (have_gen_tac [](move ["d0"])))) ((((use_arg_then "p_int") (disch_tac [])) THEN (clear_assumption "p_int") THEN BETA_TAC) THEN ((((use_arg_then "d_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "IN_REAL_INTERVAL")(thm_tac (new_rewrite [] []))))) THEN (arith_tac) THEN (done_tac))); (((fun arg_tac -> arg_tac (Arg_term (`real_interval (p - d, p + d)`))) (term_tac exists_tac)) THEN (split_tac)); ((((use_arg_then "differentiable_sum_numseg")(thm_tac (new_rewrite [] [])))) THEN (move ["i"]) THEN (move ["ineq"]) THEN (simp_tac)); (((((use_arg_then "REAL_DIFFERENTIABLE_MUL_ATREAL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_DIFFERENTIABLE_CONST")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "ETA_AX")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg])))); (((((use_arg_then "diff2_partial_real_diff")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "df")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); (((((use_arg_then "REAL_OPEN_REAL_INTERVAL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))) THEN (split_tac)); ((((use_arg_then "IN_REAL_INTERVAL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "d0") (disch_tac [])) THEN (clear_assumption "d0") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac)); ((BETA_TAC THEN (move ["y"]) THEN (move ["y_in"])) THEN ((((use_arg_then "diff2_dir_derivative")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "df")(thm_tac (new_rewrite [] [])))))); ((((use_arg_then "sub") (disch_tac [])) THEN (clear_assumption "sub") THEN BETA_TAC) THEN (((use_arg_then "SUBSET")(thm_tac (new_rewrite [] [])))) THEN (DISCH_THEN apply_tac) THEN ((((use_arg_then "IN_IMAGE")(thm_tac (new_rewrite [] [])))) THEN (simp_tac)) THEN ((fun arg_tac -> arg_tac (Arg_term (`y - t`))) (term_tac exists_tac))); ((THENL_FIRST) (split_tac) ((VECTOR_ARITH_TAC) THEN (done_tac))); ((((use_arg_then "p_int") (disch_tac [])) THEN (clear_assumption "p_int") THEN ((use_arg_then "d_def") (disch_tac [])) THEN (clear_assumption "d_def") THEN ((use_arg_then "y_in") (disch_tac [])) THEN (clear_assumption "y_in") THEN BETA_TAC) THEN (repeat_tactic 1 9 (((use_arg_then "IN_REAL_INTERVAL")(thm_tac (new_rewrite [] []))))) THEN (arith_tac) THEN (done_tac)); ];; (* Lemma diff2_dir_derivative2 *) let diff2_dir_derivative2 = section_proof ["f";"x";"e";"t"] `diff2 f (x + t % e:real^N) ==> nth_derivative 2 (f o (\t. x + t % e)) t = sum (1..dimindex (:N)) (\i. sum (1..dimindex (:N)) (\j. e$i * e$j * (partial j (partial i f) o (\t. x + t % e)) t))` [ ((((use_arg_then "diff2_eq_diff2_on_open")(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 ["df"])); ((((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))); (((use_arg_then "HAS_REAL_DERIVATIVE_LOCAL") (disch_tac [])) THEN (clear_assumption "HAS_REAL_DERIVATIVE_LOCAL") THEN (DISCH_THEN apply_tac)); (((fun arg_tac -> arg_tac (Arg_term (`\t. sum (1..dimindex(:N)) (\i. e$i * (partial i f o (\t. x + t % e)) t)`))) (term_tac exists_tac)) THEN (split_tac)); (((use_arg_then "HAS_REAL_DERIVATIVE_SUM") (thm_tac apply_tac)) THEN (((((use_arg_then "FINITE_NUMSEG")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))) THEN (move ["i"]) THEN (move ["ineq"]) THEN (simp_tac))); (((((use_arg_then "SUM_LMUL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "HAS_REAL_DERIVATIVE_LMUL_ATREAL")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "ETA_AX")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg])))); (((use_arg_then "real_dir_derivative_partial")(thm_tac (new_rewrite [] [])))); ((((fun arg_tac -> (use_arg_then "df") (fun fst_arg -> (use_arg_then "xs") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC) THEN ((((use_arg_then "diff2")(thm_tac (new_rewrite [] [])))) THEN ALL_TAC THEN (case THEN (move ["r"])) THEN (case THEN (move ["_"])) THEN (case THEN (move ["xr"])) THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))) THEN (done_tac)); (((fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (use_arg_then "open_contains_open_interval") (fun fst_arg -> (use_arg_then "e") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "open_s") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "xs") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC THEN (case THEN (move ["a"])) THEN (case THEN (move ["b"])) THEN (case THEN (move ["in0"])) THEN (move ["sub"])); (((fun arg_tac -> arg_tac (Arg_term (`real_interval (a + t, b + t)`))) (term_tac exists_tac)) THEN ((((use_arg_then "REAL_OPEN_REAL_INTERVAL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))) THEN (split_tac)); ((((use_arg_then "in0") (disch_tac [])) THEN (clear_assumption "in0") THEN BETA_TAC) THEN (repeat_tactic 1 9 (((use_arg_then "IN_REAL_INTERVAL")(thm_tac (new_rewrite [] []))))) THEN (arith_tac) THEN (done_tac)); ((BETA_TAC THEN (move ["p"]) THEN (move ["p_in"])) THEN ((((use_arg_then "diff2_dir_derivative")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "df")(thm_tac (new_rewrite [] [])))))); ((((use_arg_then "sub") (disch_tac [])) THEN (clear_assumption "sub") THEN BETA_TAC) THEN (((use_arg_then "SUBSET")(thm_tac (new_rewrite [] [])))) THEN (DISCH_THEN apply_tac) THEN ((((use_arg_then "IN_IMAGE")(thm_tac (new_rewrite [] [])))) THEN (simp_tac)) THEN ((fun arg_tac -> arg_tac (Arg_term (`p - t`))) (term_tac exists_tac))); ((THENL_FIRST) (split_tac) ((VECTOR_ARITH_TAC) THEN (done_tac))); ((((use_arg_then "p_in") (disch_tac [])) THEN (clear_assumption "p_in") THEN BETA_TAC) THEN (repeat_tactic 1 9 (((use_arg_then "IN_REAL_INTERVAL")(thm_tac (new_rewrite [] []))))) THEN (arith_tac) THEN (done_tac)); ];; (* Lemma diff2_has_derivative_partial *) let diff2_has_derivative_partial = section_proof ["f";"i";"x";"e";"t"] `diff2 f (x + t % e:real^N) ==> (partial i f o (\t. x + t % e) has_real_derivative sum (1..dimindex (:N)) (\j. e$j * (partial j (partial i f) o (\t. x + t % e)) t)) (atreal t)` [ ((((use_arg_then "diff2")(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 ["df"])); (((((use_arg_then "real_dir_derivative_partial")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "df")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma diff2_derivative_partial *) let diff2_derivative_partial = section_proof ["f";"i";"x";"e";"t"] `diff2 f (x + t % e:real^N) ==> derivative (partial i f o (\t. x + t % e)) t = sum (1..dimindex (:N)) (\j. e$j * (partial j (partial i f) o (\t. x + t % e)) t)` [ ((BETA_TAC THEN (move ["df"])) THEN (((use_arg_then "derivative_unique") (disch_tac [])) THEN (clear_assumption "derivative_unique") THEN (DISCH_THEN apply_tac)) THEN (((use_arg_then "diff2_has_derivative_partial") (disch_tac [])) THEN (clear_assumption "diff2_has_derivative_partial") THEN (exact_tac)) THEN (done_tac)); ];; (* Lemma diff2_real_diff_partial *) let diff2_real_diff_partial = section_proof ["f";"i";"x";"e";"t"] `diff2 f (x + t % e:real^N) ==> partial i f o (\t. x + t % e) real_differentiable atreal t` [ (BETA_TAC THEN (move ["df2"])); ((((fun arg_tac -> (fun arg_tac -> (use_arg_then "diff2_has_derivative_partial") (fun fst_arg -> (use_arg_then "df2") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "i") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC) THEN ((fun arg_tac -> arg_tac (Arg_term (`sum _1 _2`))) (term_tac (set_tac "s")))); (((((use_arg_then "real_differentiable")(thm_tac (new_rewrite [] [])))) THEN (move ["df"])) THEN ((use_arg_then "s") (term_tac exists_tac)) THEN (done_tac)); ];; (* Lemma partial_const *) let partial_const = section_proof ["i";"c"] `partial i (\x:real^N. c) = (\x. &0)` [ (((((use_arg_then "eq_ext")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "partial")(thm_tac (new_rewrite [] []))))) THEN (move ["x"]) THEN (simp_tac)); (((THENL_ROT 1)) ((fun arg_tac -> arg_tac (Arg_term (`(\x. c) o (\t. x + t % basis i) = (\x. c)`))) (term_tac (have_gen_tac [](((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] [])))))))); ((((use_arg_then "derivative_const")(thm_tac (new_rewrite [] [])))) THEN (done_tac)); (((((use_arg_then "eq_ext")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "o_THM")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma partial_eq0_alt *) let partial_eq0_alt = section_proof ["i";"f"] `~(i IN 1..dimindex (:N)) ==> partial i f = (\x:real^N. &0)` [ ((BETA_TAC THEN (move ["ih"])) THEN ((((use_arg_then "FUN_EQ_THM")(thm_tac (new_rewrite [] [])))) THEN (move ["x"])) THEN (((use_arg_then "partial_eq0")(thm_tac (new_rewrite [] [])))) THEN (done_tac)); ];; (* Lemma real_mvt0 *) let real_mvt0 = section_proof [] `!f f' a. (!x. abs x <= abs a ==> (f has_real_derivative f' x) (atreal x)) ==> (?t. abs t <= abs a /\ f a - f (&0) = f' t * a)` [ (BETA_TAC THEN (move ["f"]) THEN (move ["f'"]) THEN (move ["a"]) THEN (move ["h"])); (((fun arg_tac -> (use_arg_then "EXCLUDED_MIDDLE") (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`&0 <= a`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN case THEN (move ["a_ineq"])); ((fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (use_arg_then "REAL_MVT_VERY_SIMPLE") (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 -> (fun arg_tac -> arg_tac (Arg_term (`&0`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "a") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun arg -> thm_tac MP_TAC arg THEN ALL_TAC)); (((((use_arg_then "a_ineq")(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 (ANTS_TAC)); (BETA_TAC THEN (move ["x"]) THEN (move ["x_ineq"])); (((((use_arg_then "HAS_REAL_DERIVATIVE_ATREAL_WITHIN")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "h")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "x_ineq") (disch_tac [])) THEN (clear_assumption "x_ineq") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac)); (BETA_TAC THEN (case THEN (move ["t"])) THEN (case THEN (move ["t_ineq"])) THEN (move ["eq"])); (((use_arg_then "t") (term_tac exists_tac)) THEN (((use_arg_then "eq")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "t_ineq") (disch_tac [])) THEN (clear_assumption "t_ineq") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac)); ((fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (use_arg_then "REAL_MVT_VERY_SIMPLE") (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 "a") (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 arg -> thm_tac MP_TAC arg THEN ALL_TAC)); ((repeat_tactic 1 9 (((use_arg_then "IN_REAL_INTERVAL")(thm_tac (new_rewrite [] []))))) THEN (ANTS_TAC)); ((THENL_FIRST) (split_tac) ((((use_arg_then "a_ineq") (disch_tac [])) THEN (clear_assumption "a_ineq") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac))); ((BETA_TAC THEN (move ["x"]) THEN (move ["x_ineq"])) THEN ((((use_arg_then "HAS_REAL_DERIVATIVE_ATREAL_WITHIN")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "h")(thm_tac (new_rewrite [] [])))))); ((((use_arg_then "x_ineq") (disch_tac [])) THEN (clear_assumption "x_ineq") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac)); (BETA_TAC THEN (case THEN (move ["t"])) THEN (case THEN (move ["t_ineq"])) THEN (move ["eq"])); (((use_arg_then "t") (term_tac exists_tac)) THEN ((((use_arg_then "REAL_NEG_SUB")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "eq")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_NEG_RMUL")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "t_ineq") (disch_tac [])) THEN (clear_assumption "t_ineq") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac)); ];; (* Lemma mixed_second_partials *) let mixed_second_partials = section_proof ["f";"x";"i";"j"] `diff2c f x ==> partial2 i j f x = partial2 j i f (x:real^N)` [ (((((use_arg_then "diff2c")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "partial2")(thm_tac (new_rewrite [] [])))))) THEN ALL_TAC THEN (case THEN ((move ["d2f"]) THEN (move ["pc"])))); ((THENL_ROT (-1)) (((fun arg_tac -> (use_arg_then "EXCLUDED_MIDDLE") (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`i IN 1..dimindex (:N)`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN case THEN (move ["ih"]))); (((repeat_tactic 1 9 (((fun arg_tac -> (use_arg_then "partial_eq0_alt") (fun fst_arg -> (use_arg_then "i") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((use_arg_then "partial_const")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ((THENL_ROT (-1)) (((fun arg_tac -> (use_arg_then "EXCLUDED_MIDDLE") (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`j IN 1..dimindex (:N)`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN case THEN (move ["jh"]))); (((repeat_tactic 1 9 (((fun arg_tac -> (use_arg_then "partial_eq0_alt") (fun fst_arg -> (use_arg_then "j") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((use_arg_then "partial_const")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ((((use_arg_then "jh") (disch_tac [])) THEN (clear_assumption "jh") THEN ((use_arg_then "ih") (disch_tac [])) THEN (clear_assumption "ih") THEN BETA_TAC) THEN ((repeat_tactic 1 9 (((use_arg_then "IN_NUMSEG")(thm_tac (new_rewrite [] []))))) THEN (move ["ih"]) THEN (move ["jh"]))); ((((use_arg_then "d2f") (disch_tac [])) THEN (clear_assumption "d2f") THEN BETA_TAC) THEN ((((use_arg_then "diff2_eq_diff2_on_open")(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 ["d2f"]))); ((fun arg_tac -> arg_tac (Arg_term (`\h k. f ((x + k % basis j) + h % basis i) - f (x + k % basis j)`))) (term_tac (set_tac "F1"))); ((fun arg_tac -> arg_tac (Arg_term (`\k h. f ((x + h % basis i) + k % basis j) - f (x + h % basis i)`))) (term_tac (set_tac "F2"))); ((fun arg_tac -> arg_tac (Arg_term (`\h k. F1 h k - F1 h (&0)`))) (term_tac (set_tac "G"))); ((THENL_FIRST) ((fun arg_tac -> arg_tac (Arg_term (`!h k. (x + k % basis j) + h % basis i = (x + h % basis i) + k % basis j`))) (term_tac (have_gen_tac [](move ["v_eq"])))) ((VECTOR_ARITH_TAC) THEN (done_tac))); ((fun arg_tac -> arg_tac (Arg_term (`G = \h k. F2 k h - F2 k (&0)`))) (term_tac (have_gen_tac [](move ["G_eq"])))); ((repeat_tactic 2 0 (((use_arg_then "eq_ext")(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (move ["h"]) THEN (move ["k"])); (((((use_arg_then "G_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "F2_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "F1_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (repeat_tactic 1 9 (((use_arg_then "VECTOR_MUL_LZERO")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "VECTOR_ADD_RID")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "v_eq")(thm_tac (new_rewrite [] []))))) THEN (arith_tac) THEN (done_tac)); ((fun arg_tac -> arg_tac (Arg_term (`?r. &0 < r /\ (!h k. abs h <= r /\ abs k <= r ==> (x + h % basis i) + k % basis j IN s)`))) (term_tac (have_gen_tac [](case THEN ((move ["r"]) THEN (case THEN ((move ["r0"]) THEN (move ["rs"])))))))); ((((use_arg_then "open_s") (disch_tac [])) THEN (clear_assumption "open_s") THEN BETA_TAC) THEN (((((use_arg_then "OPEN_CONTAINS_BALL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "SUBSET")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "IN_BALL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "dist")(thm_tac (new_rewrite [] []))))) THEN ((fun arg_tac -> (conv_thm_tac DISCH_THEN) (fun fst_arg -> (use_arg_then "xs") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (thm_tac MP_TAC)) THEN (case THEN (move ["e"])) THEN (case THEN ((move ["e0"]) THEN (move ["de"]))))); ((THENL_FIRST) (((fun arg_tac -> arg_tac (Arg_term (`e / &3`))) (term_tac exists_tac)) THEN (split_tac)) ((((use_arg_then "e0") (disch_tac [])) THEN (clear_assumption "e0") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac))); (BETA_TAC THEN (move ["h"]) THEN (move ["k"]) THEN (move ["ineq"])); ((((use_arg_then "de")(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL VECTOR_ADD_ASSOC)))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "VECTOR_SUB_RADD")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "NORM_NEG")(thm_tac (new_rewrite [] []))))); ((THENL_LAST) ((((use_arg_then "REAL_LET_TRANS") (disch_tac [])) THEN (clear_assumption "REAL_LET_TRANS") THEN (DISCH_THEN apply_tac)) THEN ((fun arg_tac -> arg_tac (Arg_term (`e / &3 + e / &3`))) (term_tac exists_tac)) THEN (split_tac)) ((((use_arg_then "e0") (disch_tac [])) THEN (clear_assumption "e0") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac))); ((THENL_LAST) ((((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 h + abs k`))) (term_tac exists_tac)) THEN (split_tac)) ((((use_arg_then "ineq") (disch_tac [])) THEN (clear_assumption "ineq") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac))); ((fun arg_tac -> (fun arg_tac -> (use_arg_then "NORM_TRIANGLE") (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`h % basis i:real^N`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`k % basis j:real^N`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun arg -> thm_tac MP_TAC arg THEN ALL_TAC)); (((repeat_tactic 1 9 (((use_arg_then "NORM_MUL")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "NORM_BASIS")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (repeat_tactic 1 9 (((use_arg_then "REAL_MUL_RID")(thm_tac (new_rewrite [] [])))))) THEN (done_tac)); ((fun arg_tac -> arg_tac (Arg_term (`(!h. abs h <= r ==> x + h % basis i IN s) /\ (!k. abs k <= r ==> x + k % basis j IN s)`))) (term_tac (have_gen_tac [](move ["in_s"])))); ((THENL) (split_tac) [((move ["h"]) THEN (move ["h_ineq"])); ((move ["k"]) THEN (move ["k_ineq"]))]); ((((fun arg_tac -> (fun arg_tac -> (use_arg_then "rs") (fun fst_arg -> (use_arg_then "h") (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))) (disch_tac [])) THEN BETA_TAC) THEN (((((use_arg_then "VECTOR_MUL_LZERO")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "VECTOR_ADD_RID")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "h_ineq")(thm_tac (new_rewrite [] []))))) THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "r0") (disch_tac [])) THEN (clear_assumption "r0") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac)); ((((fun arg_tac -> (fun arg_tac -> (use_arg_then "rs") (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 -> (use_arg_then "k") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC) THEN (((((use_arg_then "VECTOR_MUL_LZERO")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "VECTOR_ADD_RID")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "k_ineq")(thm_tac (new_rewrite [] []))))) THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "r0") (disch_tac [])) THEN (clear_assumption "r0") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac)); ((fun arg_tac -> arg_tac (Arg_term (`!h. F1 h = (\k. (f o (\k. (x + h % basis i) + k % basis j)) k - (f o (\k. x + k % basis j)) k)`))) (term_tac (have_gen_tac [](move ["F1h"])))); (((((use_arg_then "F1_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "o_THM")(thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (((use_arg_then "v_eq")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ((fun arg_tac -> arg_tac (Arg_term (`!h. abs h <= r ==> !k. abs k <= r ==> (F1 h) real_differentiable atreal k`))) (term_tac (have_gen_tac [](move ["dF1"])))); (BETA_TAC THEN (move ["h"]) THEN (move ["h_ineq"]) THEN (move ["k"]) THEN (move ["k_ineq"])); (((((use_arg_then "F1h")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_DIFFERENTIABLE_SUB")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "ETA_AX")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg])))); (((repeat_tactic 1 9 (((use_arg_then "diff2_imp_real_diff")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "d2f")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "rs")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "in_s")(thm_tac (new_rewrite [] [])))))) THEN (done_tac)); ((fun arg_tac -> arg_tac (Arg_term (`!h k. abs h <= r /\ abs k <= r ==> derivative (F1 h) k = partial j f ((x + h % basis i) + k % basis j) - partial j f (x + k % basis j)`))) (term_tac (have_gen_tac [](move ["F1_der"])))); ((BETA_TAC THEN (move ["h"]) THEN (move ["k"]) THEN (move ["ineq"])) THEN ((((use_arg_then "F1h")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "derivative_sub")(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 "diff2_imp_real_diff")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "d2f")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "rs")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "in_s")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)))); (((((use_arg_then "derivative_translation")(thm_tac (new_rewrite [] [(`derivative (f o (\k. x + k % basis j)) k`)])))) THEN (repeat_tactic 0 1 (((use_arg_then "derivative_translation")(thm_tac (new_rewrite [] [])))))) THEN ((repeat_tactic 0 10 (((use_arg_then "diff2_imp_real_diff")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "d2f")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "rs")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "in_s")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)))); ((fun arg_tac -> arg_tac (Arg_term (`!y e. (f o (\k. y + k % e)) o (\t. k + t) = f o (\t. (y + k % e) + t % e)`))) (term_tac (have_gen_tac [](move ["eq"])))); (((((use_arg_then "eq_ext")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "o_THM")(thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL VECTOR_ADD_RDISTRIB)))(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL VECTOR_ADD_ASSOC)))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); (((repeat_tactic 1 9 (((use_arg_then "eq")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "partial")(gsym_then (thm_tac (new_rewrite [] []))))))) THEN (done_tac)); ((fun arg_tac -> arg_tac (Arg_term (`!h k. abs h <= r /\ abs k <= r ==> (?t1. G h k = k * derivative (F1 h) t1 /\ abs t1 <= abs k)`))) (term_tac (have_gen_tac [](move ["Gh"])))); ((BETA_TAC THEN (move ["h"]) THEN (move ["k"]) THEN (move ["ineq"])) THEN ((((use_arg_then "G_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (simp_tac))); ((fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (use_arg_then "real_mvt0") (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`F1 h`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`derivative (F1 h)`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "k") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun arg -> thm_tac MP_TAC arg THEN ALL_TAC)); (ANTS_TAC); ((BETA_TAC THEN (move ["t"]) THEN (move ["t_ineq"])) THEN ((((use_arg_then "has_derivative_alt")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "dF1")(thm_tac (new_rewrite [] [])))))); ((((use_arg_then "t_ineq") (disch_tac [])) THEN (clear_assumption "t_ineq") THEN ((use_arg_then "ineq") (disch_tac [])) THEN (clear_assumption "ineq") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac)); (BETA_TAC THEN (case THEN (move ["t1"])) THEN (case THEN (move ["t1_ineq"])) THEN (move ["eq"])); (((use_arg_then "t1") (term_tac exists_tac)) THEN (((use_arg_then "eq")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "ineq") (disch_tac [])) THEN (clear_assumption "ineq") THEN ((use_arg_then "t1_ineq") (disch_tac [])) THEN (clear_assumption "t1_ineq") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac)); ((fun arg_tac -> arg_tac (Arg_term (`!h k. abs h <= r /\ abs k <= r ==> (?t1 t2. G h k = h * k * partial i (partial j f) (x + t1 % basis j + t2 % basis i) /\ abs t1 <= abs k /\ abs t2 <= abs h)`))) (term_tac (have_gen_tac [](move ["Ghk"])))); (BETA_TAC THEN (move ["h"]) THEN (move ["k"]) THEN (move ["ineq"])); ((((fun arg_tac -> (fun arg_tac -> (use_arg_then "Gh") (fun fst_arg -> (use_arg_then "h") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "k") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC) THEN (((repeat_tactic 1 9 (((use_arg_then "ineq")(thm_tac (new_rewrite [] []))))) THEN (simp_tac)) THEN ALL_TAC THEN (case THEN (move ["t1"])) THEN (case THEN ((move ["eq"]) THEN (move ["t1k"]))))); ((THENL) ((((use_arg_then "eq") (disch_tac [])) THEN (clear_assumption "eq") THEN BETA_TAC) THEN (((use_arg_then "F1_der")(thm_tac (new_rewrite [] []))))) [((((use_arg_then "ineq") (disch_tac [])) THEN (clear_assumption "ineq") THEN ((use_arg_then "t1k") (disch_tac [])) THEN (clear_assumption "t1k") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac)); (BETA_TAC THEN (move ["eq"]))]); ((fun arg_tac -> arg_tac (Arg_term (`partial j f o (\h. (x + t1 % basis j) + h % basis i)`))) (term_tac (set_tac "g"))); ((fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (use_arg_then "real_mvt0") (fun fst_arg -> (use_arg_then "g") (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 -> (use_arg_then "h") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun arg -> thm_tac MP_TAC arg THEN ALL_TAC)); (ANTS_TAC); ((BETA_TAC THEN (move ["t"]) THEN (move ["t_ineq"])) THEN (((use_arg_then "has_derivative_alt")(thm_tac (new_rewrite [] []))))); ((((use_arg_then "g_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "diff2_partial_real_diff")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "d2f")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "v_eq")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "rs")(thm_tac (new_rewrite [] []))))); ((((use_arg_then "ineq") (disch_tac [])) THEN (clear_assumption "ineq") THEN ((use_arg_then "t_ineq") (disch_tac [])) THEN (clear_assumption "t_ineq") THEN ((use_arg_then "t1k") (disch_tac [])) THEN (clear_assumption "t1k") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac)); (BETA_TAC THEN (case THEN (move ["t2"])) THEN (case THEN (move ["t2_ineq"])) THEN (move ["g_eq"])); ((THENL_LAST) ((((use_arg_then "t1") (term_tac exists_tac)) THEN ((use_arg_then "t2") (term_tac exists_tac))) THEN (((use_arg_then "eq")(thm_tac (new_rewrite [] [])))) THEN (split_tac)) ((((use_arg_then "ineq") (disch_tac [])) THEN (clear_assumption "ineq") THEN ((use_arg_then "t2_ineq") (disch_tac [])) THEN (clear_assumption "t2_ineq") THEN ((use_arg_then "t1k") (disch_tac [])) THEN (clear_assumption "t1k") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac))); ((fun arg_tac -> arg_tac (Arg_term (`_1 - _2`))) (term_tac (set_tac "p"))); ((fun arg_tac -> arg_tac (Arg_term (`p = g h - g (&0)`))) (term_tac (have_gen_tac [](((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))))); (((((use_arg_then "p_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "g_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "o_THM")(thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (((use_arg_then "VECTOR_MUL_LZERO")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "VECTOR_ADD_RID")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "v_eq")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ((((use_arg_then "g_eq")(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> arg_tac (Arg_theorem (REAL_ARITH `!a. k * a * h = h * k * a`)))(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "REAL_MUL_ASSOC")(thm_tac (new_rewrite [] [])))))); (((((use_arg_then "REAL_EQ_MUL_LCANCEL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "g_def")(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (DISJ2_TAC)); (((use_arg_then "derivative_translation")(thm_tac (new_rewrite [] [])))); (((((use_arg_then "diff2_partial_real_diff")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "d2f")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "v_eq")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "rs")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "ineq") (disch_tac [])) THEN (clear_assumption "ineq") THEN ((use_arg_then "t2_ineq") (disch_tac [])) THEN (clear_assumption "t2_ineq") THEN ((use_arg_then "t1k") (disch_tac [])) THEN (clear_assumption "t1k") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac)); ((((use_arg_then "partial")(thm_tac (new_rewrite [] [])))) THEN (AP_THM_TAC) THEN (AP_TERM_TAC)); (((((use_arg_then "eq_ext")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "o_THM")(thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL VECTOR_ADD_RDISTRIB)))(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL VECTOR_ADD_ASSOC)))(gsym_then (thm_tac (new_rewrite [] []))))))) THEN (done_tac)); (((use_arg_then "F1_def") (disch_tac [])) THEN (clear_assumption "F1_def") THEN ((use_arg_then "G_def") (disch_tac [])) THEN (clear_assumption "G_def") THEN ((use_arg_then "F1h") (disch_tac [])) THEN (clear_assumption "F1h") THEN ((use_arg_then "dF1") (disch_tac [])) THEN (clear_assumption "dF1") THEN ((use_arg_then "F1_der") (disch_tac [])) THEN (clear_assumption "F1_der") THEN ((use_arg_then "Gh") (disch_tac [])) THEN (clear_assumption "Gh") THEN BETA_TAC THEN (move ["_"]) THEN (move ["_"]) THEN (move ["_"]) THEN (move ["_"]) THEN (move ["_"]) THEN (move ["_"])); ((fun arg_tac -> arg_tac (Arg_term (`!k. F2 k = (\h. (f o (\h. (x + k % basis j) + h % basis i)) h - (f o (\h. x + h % basis i)) h)`))) (term_tac (have_gen_tac [](move ["F2h"])))); (((((use_arg_then "F2_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "o_THM")(thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (((use_arg_then "v_eq")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ((fun arg_tac -> arg_tac (Arg_term (`!k. abs k <= r ==> !h. abs h <= r ==> (F2 k) real_differentiable atreal h`))) (term_tac (have_gen_tac [](move ["dF2"])))); (BETA_TAC THEN (move ["k"]) THEN (move ["k_ineq"]) THEN (move ["h"]) THEN (move ["h_ineq"])); (((((use_arg_then "F2h")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_DIFFERENTIABLE_SUB")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "ETA_AX")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg])))); (((repeat_tactic 1 9 (((use_arg_then "diff2_imp_real_diff")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "d2f")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "v_eq")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "rs")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "in_s")(thm_tac (new_rewrite [] [])))))) THEN (done_tac)); ((fun arg_tac -> arg_tac (Arg_term (`!h k. abs h <= r /\ abs k <= r ==> derivative (F2 k) h = partial i f ((x + k % basis j) + h % basis i) - partial i f (x + h % basis i)`))) (term_tac (have_gen_tac [](move ["F2_der"])))); ((BETA_TAC THEN (move ["h"]) THEN (move ["k"]) THEN (move ["ineq"])) THEN ((((use_arg_then "F2h")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "derivative_sub")(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 "diff2_imp_real_diff")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "d2f")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "v_eq")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "rs")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "in_s")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)))); (((((use_arg_then "v_eq")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "derivative_translation")(thm_tac (new_rewrite [] [(`derivative (f o (\h. x + h % basis i)) h`)])))) THEN (repeat_tactic 0 1 (((use_arg_then "derivative_translation")(thm_tac (new_rewrite [] [])))))) THEN ((repeat_tactic 0 10 (((use_arg_then "diff2_imp_real_diff")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "d2f")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "v_eq")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "rs")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "in_s")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((use_arg_then "v_eq")(gsym_then (thm_tac (new_rewrite [] []))))))); ((fun arg_tac -> arg_tac (Arg_term (`!y e. (f o (\h. y + h % e)) o (\t. h + t) = f o (\t. (y + h % e) + t % e)`))) (term_tac (have_gen_tac [](move ["eq"])))); (((((use_arg_then "eq_ext")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "o_THM")(thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL VECTOR_ADD_RDISTRIB)))(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL VECTOR_ADD_ASSOC)))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); (((repeat_tactic 1 9 (((use_arg_then "eq")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "partial")(gsym_then (thm_tac (new_rewrite [] []))))))) THEN (done_tac)); ((fun arg_tac -> arg_tac (Arg_term (`!h k. abs h <= r /\ abs k <= r ==> (?t3. G h k = h * derivative (F2 k) t3 /\ abs t3 <= abs h)`))) (term_tac (have_gen_tac [](move ["Gk"])))); ((BETA_TAC THEN (move ["h"]) THEN (move ["k"]) THEN (move ["ineq"])) THEN ((((use_arg_then "G_eq")(thm_tac (new_rewrite [] [])))) THEN (simp_tac))); ((fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (use_arg_then "real_mvt0") (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`F2 k`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`derivative (F2 k)`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "h") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun arg -> thm_tac MP_TAC arg THEN ALL_TAC)); (ANTS_TAC); ((BETA_TAC THEN (move ["t"]) THEN (move ["t_ineq"])) THEN ((((use_arg_then "has_derivative_alt")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "dF2")(thm_tac (new_rewrite [] [])))))); ((((use_arg_then "t_ineq") (disch_tac [])) THEN (clear_assumption "t_ineq") THEN ((use_arg_then "ineq") (disch_tac [])) THEN (clear_assumption "ineq") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac)); (BETA_TAC THEN (case THEN (move ["t3"])) THEN (case THEN (move ["t3_ineq"])) THEN (move ["eq"])); (((use_arg_then "t3") (term_tac exists_tac)) THEN (((use_arg_then "eq")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "ineq") (disch_tac [])) THEN (clear_assumption "ineq") THEN ((use_arg_then "t3_ineq") (disch_tac [])) THEN (clear_assumption "t3_ineq") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac)); ((fun arg_tac -> arg_tac (Arg_term (`!h k. abs h <= r /\ abs k <= r ==> (?t3 t4. G h k = h * k * partial j (partial i f) (x + t4 % basis j + t3 % basis i) /\ abs t3 <= abs h /\ abs t4 <= abs k)`))) (term_tac (have_gen_tac [](move ["Gkh"])))); (BETA_TAC THEN (move ["h"]) THEN (move ["k"]) THEN (move ["ineq"])); ((((fun arg_tac -> (fun arg_tac -> (use_arg_then "Gk") (fun fst_arg -> (use_arg_then "h") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "k") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC) THEN (((repeat_tactic 1 9 (((use_arg_then "ineq")(thm_tac (new_rewrite [] []))))) THEN (simp_tac)) THEN ALL_TAC THEN (case THEN (move ["t3"])) THEN (case THEN ((move ["eq"]) THEN (move ["t3h"]))))); ((THENL) ((((use_arg_then "eq") (disch_tac [])) THEN (clear_assumption "eq") THEN BETA_TAC) THEN (((use_arg_then "F2_der")(thm_tac (new_rewrite [] []))))) [((((use_arg_then "ineq") (disch_tac [])) THEN (clear_assumption "ineq") THEN ((use_arg_then "t3h") (disch_tac [])) THEN (clear_assumption "t3h") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac)); (BETA_TAC THEN (move ["eq"]))]); ((fun arg_tac -> arg_tac (Arg_term (`partial i f o (\k. (x + t3 % basis i) + k % basis j)`))) (term_tac (set_tac "g"))); ((fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (use_arg_then "real_mvt0") (fun fst_arg -> (use_arg_then "g") (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 -> (use_arg_then "k") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun arg -> thm_tac MP_TAC arg THEN ALL_TAC)); (ANTS_TAC); ((BETA_TAC THEN (move ["t"]) THEN (move ["t_ineq"])) THEN (((use_arg_then "has_derivative_alt")(thm_tac (new_rewrite [] []))))); ((((use_arg_then "g_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "diff2_partial_real_diff")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "d2f")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "rs")(thm_tac (new_rewrite [] []))))); ((((use_arg_then "ineq") (disch_tac [])) THEN (clear_assumption "ineq") THEN ((use_arg_then "t_ineq") (disch_tac [])) THEN (clear_assumption "t_ineq") THEN ((use_arg_then "t3h") (disch_tac [])) THEN (clear_assumption "t3h") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac)); (BETA_TAC THEN (case THEN (move ["t4"])) THEN (case THEN (move ["t4_ineq"])) THEN (move ["g_eq"])); ((THENL_LAST) ((((use_arg_then "t3") (term_tac exists_tac)) THEN ((use_arg_then "t4") (term_tac exists_tac))) THEN (((use_arg_then "eq")(thm_tac (new_rewrite [] [])))) THEN (split_tac)) ((((use_arg_then "ineq") (disch_tac [])) THEN (clear_assumption "ineq") THEN ((use_arg_then "t4_ineq") (disch_tac [])) THEN (clear_assumption "t4_ineq") THEN ((use_arg_then "t3h") (disch_tac [])) THEN (clear_assumption "t3h") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac))); ((fun arg_tac -> arg_tac (Arg_term (`_1 - _2`))) (term_tac (set_tac "p"))); ((fun arg_tac -> arg_tac (Arg_term (`p = g k - g (&0)`))) (term_tac (have_gen_tac [](((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))))); (((((use_arg_then "p_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "g_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "o_THM")(thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (((use_arg_then "VECTOR_MUL_LZERO")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "VECTOR_ADD_RID")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "v_eq")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ((((use_arg_then "g_eq")(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> arg_tac (Arg_theorem (REAL_ARITH `!a. h * a * k = h * k * a`)))(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "REAL_MUL_ASSOC")(thm_tac (new_rewrite [] [])))))); (((((use_arg_then "REAL_EQ_MUL_LCANCEL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "g_def")(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (DISJ2_TAC)); (((use_arg_then "derivative_translation")(thm_tac (new_rewrite [] [])))); (((((use_arg_then "diff2_partial_real_diff")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "d2f")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "rs")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "ineq") (disch_tac [])) THEN (clear_assumption "ineq") THEN ((use_arg_then "t4_ineq") (disch_tac [])) THEN (clear_assumption "t4_ineq") THEN ((use_arg_then "t3h") (disch_tac [])) THEN (clear_assumption "t3h") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac)); ((((use_arg_then "partial")(thm_tac (new_rewrite [] [])))) THEN (AP_THM_TAC) THEN (AP_TERM_TAC)); (((((use_arg_then "eq_ext")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "o_THM")(thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL VECTOR_ADD_RDISTRIB)))(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL VECTOR_ADD_ASSOC)))(gsym_then (thm_tac (new_rewrite [] []))))))) THEN (move ["y"])); ((AP_TERM_TAC) THEN (VECTOR_ARITH_TAC) THEN (done_tac)); (((use_arg_then "F2_def") (disch_tac [])) THEN (clear_assumption "F2_def") THEN ((use_arg_then "G_eq") (disch_tac [])) THEN (clear_assumption "G_eq") THEN ((use_arg_then "F2h") (disch_tac [])) THEN (clear_assumption "F2h") THEN ((use_arg_then "dF2") (disch_tac [])) THEN (clear_assumption "dF2") THEN ((use_arg_then "F2_der") (disch_tac [])) THEN (clear_assumption "F2_der") THEN ((use_arg_then "Gk") (disch_tac [])) THEN (clear_assumption "Gk") THEN BETA_TAC THEN (move ["_"]) THEN (move ["_"]) THEN (move ["_"]) THEN (move ["_"]) THEN (move ["_"]) THEN (move ["_"])); ((fun arg_tac -> arg_tac (Arg_term (`(vec 0:real^2) limit_point_of {y | &0 < y$1 /\ &0 < y$2}`))) (term_tac (have_gen_tac [](move ["lim0"])))); (((((use_arg_then "limit_point_of")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "OPEN_CONTAINS_BALL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "SUBSET")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "IN_BALL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "dist")(thm_tac (new_rewrite [] []))))) THEN (move ["t"]) THEN (case THEN (move ["v0t"]))); (((fun arg_tac -> (conv_thm_tac DISCH_THEN) (fun fst_arg -> (use_arg_then "v0t") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (thm_tac MP_TAC)) THEN BETA_TAC THEN (case THEN (move ["e"])) THEN (case THEN (move ["e0"])) THEN (move ["in_t"])); ((fun arg_tac -> arg_tac (Arg_term (`e / &2 % (vec 1:real^2)`))) (term_tac (set_tac "y"))); ((THENL_FIRST) ((fun arg_tac -> arg_tac (Arg_term (`!i. y$i = e / (&2)`))) (term_tac (have_gen_tac [](move ["yc"])))) (((((use_arg_then "y_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "VECTOR_MUL_COMPONENT")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "VEC_COMPONENT")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_MUL_RID")(thm_tac (new_rewrite [] []))))) THEN (done_tac))); ((THENL_FIRST) ((fun arg_tac -> arg_tac (Arg_term (`&0 < e / (&2)`))) (term_tac (have_gen_tac [](move ["ineq"])))) (((((use_arg_then "REAL_LT_DIV")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "e0")(thm_tac (new_rewrite [] []))))) THEN (arith_tac) THEN (done_tac))); ((fun arg_tac -> arg_tac (Arg_term (`infnorm y = e / &2`))) (term_tac (have_gen_tac [](move ["inf_y"])))); (((((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL INFNORM_2)))(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "yc")(thm_tac (new_rewrite [] []))))) THEN (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL (CONJUNCT2 REAL_MAX_ACI))))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_ABS_REFL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_LE_LT")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "ineq")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ((THENL_FIRST) (((use_arg_then "y") (term_tac exists_tac)) THEN (split_tac)) (((((use_arg_then "INFNORM_EQ_0")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "inf_y")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "ineq") (disch_tac [])) THEN (clear_assumption "ineq") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac))); ((THENL_FIRST) (split_tac) (((((use_arg_then "IN_ELIM_THM")(thm_tac (new_rewrite [] [])))) THEN (simp_tac)) THEN ((use_arg_then "y") (term_tac exists_tac)) THEN ((repeat_tactic 1 9 (((use_arg_then "yc")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "ineq")(thm_tac (new_rewrite [] []))))) THEN (done_tac))); ((((use_arg_then "in_t")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_LET_TRANS") (disch_tac [])) THEN (clear_assumption "REAL_LET_TRANS") THEN (DISCH_THEN apply_tac)) THEN ((fun arg_tac -> arg_tac (Arg_term (`e * inv(&2) * sqrt(&2)`))) (term_tac exists_tac)) THEN (split_tac)); ((((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 (`infnorm y * sqrt (&2)`))) (term_tac exists_tac)) THEN (split_tac)); (((((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL REAL_MUL_AC)))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "NORM_SUB")(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL VECTOR_SUB_RZERO)))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "DIMINDEX_2")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "NORM_LE_INFNORM")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); (((((use_arg_then "inf_y")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "real_div")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_MUL_ASSOC")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "REAL_LE_REFL")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ((((fun arg_tac -> (use_arg_then "REAL_MUL_RID") (fun fst_arg -> (use_arg_then "e") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(gsym_then (thm_tac (new_rewrite [2] []))))) THEN (((use_arg_then "REAL_LT_LMUL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "e0")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))); (((((fun arg_tac -> (use_arg_then "REAL_MUL_LINV") (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`&2`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "REAL_LT_LMUL")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "REAL_LT_INV")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))))) THEN (TRY ((arith_tac)))); ((THENL_FIRST) ((fun arg_tac -> arg_tac (Arg_term (`&2 = sqrt (&2 * &2)`))) (term_tac (have_gen_tac [](((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [2] []))))))) (((((use_arg_then "REAL_POW_2")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "POW_2_SQRT_ABS")(thm_tac (new_rewrite [] []))))) THEN (arith_tac) THEN (done_tac))); ((((use_arg_then "SQRT_MONO_LT")(thm_tac (new_rewrite [] [])))) THEN (arith_tac) THEN (done_tac)); ((fun arg_tac -> arg_tac (Arg_term (`((\y:real^2. lift (G (y$1) (y$2) / (y$1 * y$2))) --> lift (partial j (partial i f) x)) (at (vec 0) within {y | &0 < y$1 /\ &0 < y$2})`))) (term_tac (have_gen_tac [](move ["lim_ji"])))); ((((use_arg_then "LIM_WITHIN")(thm_tac (new_rewrite [] [])))) THEN (move ["e"]) THEN (move ["e_gt0"])); ((((fun arg_tac -> (fun arg_tac -> (use_arg_then "pc") (fun fst_arg -> (use_arg_then "i") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "j") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC) THEN (((((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL continuous_at)))(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "dist")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "o_THM")(thm_tac (new_rewrite [] [])))))) THEN ((fun arg_tac -> (conv_thm_tac DISCH_THEN) (fun fst_arg -> (use_arg_then "e_gt0") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (thm_tac MP_TAC)) THEN (case THEN (move ["d"])) THEN (case THEN (move ["d0"])) THEN (move ["e_ineq"]))); ((THENL_FIRST) (((fun arg_tac -> arg_tac (Arg_term (`min r (d / &2)`))) (term_tac exists_tac)) THEN (((use_arg_then "REAL_LT_MIN")(thm_tac (new_rewrite [] [])))) THEN (split_tac)) ((((use_arg_then "d0") (disch_tac [])) THEN (clear_assumption "d0") THEN ((use_arg_then "r0") (disch_tac [])) THEN (clear_assumption "r0") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac))); (((simp_tac) THEN (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL VECTOR_SUB_RZERO)))(thm_tac (new_rewrite [] []))))) THEN (move ["y"]) THEN (move ["ineq"])); ((fun arg_tac -> arg_tac (Arg_term (`&0 < abs (y$1) /\ &0 < abs (y$2)`))) (term_tac (have_gen_tac [](move ["y0"])))); ((((use_arg_then "ineq") (disch_tac [])) THEN (clear_assumption "ineq") THEN BETA_TAC) THEN (((((use_arg_then "IN_ELIM_THM")(thm_tac (new_rewrite [] [])))) THEN (simp_tac)) THEN ALL_TAC THEN (case THEN ALL_TAC) THEN (case THEN (move ["z"])) THEN (case THEN (move ["z_ineq"])) THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] [])))) THEN (move ["_"]))); ((((use_arg_then "z_ineq") (disch_tac [])) THEN (clear_assumption "z_ineq") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac)); ((fun arg_tac -> arg_tac (Arg_term (`abs (y$1) <= r /\ abs (y$2) <= r /\ abs (y$1) < d / &2 /\ abs (y$2) < d / &2`))) (term_tac (have_gen_tac [](move ["yr"])))); ((THENL_FIRST) (((THENL_ROT 1)) ((fun arg_tac -> arg_tac (Arg_term (`infnorm y < min r (d / &2)`))) (term_tac (have_gen_tac []ALL_TAC)))) ((((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL INFNORM_2)))(thm_tac (new_rewrite [] [])))) THEN (arith_tac) THEN (done_tac))); ((((use_arg_then "REAL_LET_TRANS") (disch_tac [])) THEN (clear_assumption "REAL_LET_TRANS") THEN (DISCH_THEN apply_tac)) THEN ((fun arg_tac -> arg_tac (Arg_term (`norm y`))) (term_tac exists_tac)) THEN (((use_arg_then "INFNORM_LE_NORM")(thm_tac (new_rewrite [] [])))) THEN (done_tac)); ((fun arg_tac -> (fun arg_tac -> (use_arg_then "Gkh") (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`y$1`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`y$2`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun arg -> thm_tac MP_TAC arg THEN ALL_TAC)); (((repeat_tactic 1 9 (((use_arg_then "yr")(thm_tac (new_rewrite [] []))))) THEN (simp_tac)) THEN ALL_TAC THEN (case THEN (move ["t1"])) THEN (case THEN (move ["t2"])) THEN (case THEN (move ["G_eq"])) THEN (move ["t_ineq"])); ((((use_arg_then "G_eq")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_MUL_ASSOC")(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL REAL_MUL_AC)))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "real_div")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_MUL_ASSOC")(gsym_then (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_RID")(thm_tac (new_rewrite [] [])))))); ((((use_arg_then "REAL_ENTIRE")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "y0") (disch_tac [])) THEN (clear_assumption "y0") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac)); ((((use_arg_then "e_ineq") (disch_tac [])) THEN (clear_assumption "e_ineq") THEN (DISCH_THEN apply_tac)) THEN (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL VECTOR_ADD_SUB)))(thm_tac (new_rewrite [] []))))); ((((use_arg_then "REAL_LET_TRANS") (disch_tac [])) THEN (clear_assumption "REAL_LET_TRANS") THEN (DISCH_THEN apply_tac)) THEN ((fun arg_tac -> arg_tac (Arg_term (`norm (t2 % basis j:real^N) + norm (t1 % basis i:real^N)`))) (term_tac exists_tac))); ((((use_arg_then "NORM_TRIANGLE")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "NORM_MUL")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "NORM_BASIS")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (repeat_tactic 1 9 (((use_arg_then "REAL_MUL_RID")(thm_tac (new_rewrite [] [])))))); ((((use_arg_then "yr") (disch_tac [])) THEN (clear_assumption "yr") THEN ((use_arg_then "t_ineq") (disch_tac [])) THEN (clear_assumption "t_ineq") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac)); ((fun arg_tac -> arg_tac (Arg_term (`((\y:real^2. lift (G (y$1) (y$2) / (y$1 * y$2))) --> lift (partial i (partial j f) x)) (at (vec 0) within {y | &0 < y$1 /\ &0 < y$2})`))) (term_tac (have_gen_tac [](move ["lim_ij"])))); ((((use_arg_then "LIM_WITHIN")(thm_tac (new_rewrite [] [])))) THEN (move ["e"]) THEN (move ["e_gt0"])); ((((fun arg_tac -> (fun arg_tac -> (use_arg_then "pc") (fun fst_arg -> (use_arg_then "j") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "i") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC) THEN (((((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL continuous_at)))(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "dist")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "o_THM")(thm_tac (new_rewrite [] [])))))) THEN ((fun arg_tac -> (conv_thm_tac DISCH_THEN) (fun fst_arg -> (use_arg_then "e_gt0") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (thm_tac MP_TAC)) THEN (case THEN (move ["d"])) THEN (case THEN (move ["d0"])) THEN (move ["e_ineq"]))); ((THENL_FIRST) (((fun arg_tac -> arg_tac (Arg_term (`min r (d / &2)`))) (term_tac exists_tac)) THEN (((use_arg_then "REAL_LT_MIN")(thm_tac (new_rewrite [] [])))) THEN (split_tac)) ((((use_arg_then "d0") (disch_tac [])) THEN (clear_assumption "d0") THEN ((use_arg_then "r0") (disch_tac [])) THEN (clear_assumption "r0") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac))); (((simp_tac) THEN (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL VECTOR_SUB_RZERO)))(thm_tac (new_rewrite [] []))))) THEN (move ["y"]) THEN (move ["ineq"])); ((fun arg_tac -> arg_tac (Arg_term (`&0 < abs (y$1) /\ &0 < abs (y$2)`))) (term_tac (have_gen_tac [](move ["y0"])))); ((((use_arg_then "ineq") (disch_tac [])) THEN (clear_assumption "ineq") THEN BETA_TAC) THEN (((((use_arg_then "IN_ELIM_THM")(thm_tac (new_rewrite [] [])))) THEN (simp_tac)) THEN ALL_TAC THEN (case THEN ALL_TAC) THEN (case THEN (move ["z"])) THEN (case THEN (move ["z_ineq"])) THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] [])))) THEN (move ["_"]))); ((((use_arg_then "z_ineq") (disch_tac [])) THEN (clear_assumption "z_ineq") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac)); ((fun arg_tac -> arg_tac (Arg_term (`abs (y$1) <= r /\ abs (y$2) <= r /\ abs (y$1) < d / &2 /\ abs (y$2) < d / &2`))) (term_tac (have_gen_tac [](move ["yr"])))); ((THENL_FIRST) (((THENL_ROT 1)) ((fun arg_tac -> arg_tac (Arg_term (`infnorm y < min r (d / &2)`))) (term_tac (have_gen_tac []ALL_TAC)))) ((((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL INFNORM_2)))(thm_tac (new_rewrite [] [])))) THEN (arith_tac) THEN (done_tac))); ((((use_arg_then "REAL_LET_TRANS") (disch_tac [])) THEN (clear_assumption "REAL_LET_TRANS") THEN (DISCH_THEN apply_tac)) THEN ((fun arg_tac -> arg_tac (Arg_term (`norm y`))) (term_tac exists_tac)) THEN (((use_arg_then "INFNORM_LE_NORM")(thm_tac (new_rewrite [] [])))) THEN (done_tac)); ((fun arg_tac -> (fun arg_tac -> (use_arg_then "Ghk") (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`y$1`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`y$2`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun arg -> thm_tac MP_TAC arg THEN ALL_TAC)); (((repeat_tactic 1 9 (((use_arg_then "yr")(thm_tac (new_rewrite [] []))))) THEN (simp_tac)) THEN ALL_TAC THEN (case THEN (move ["t1"])) THEN (case THEN (move ["t2"])) THEN (case THEN (move ["G_eq"])) THEN (move ["t_ineq"])); ((((use_arg_then "G_eq")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_MUL_ASSOC")(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL REAL_MUL_AC)))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "real_div")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_MUL_ASSOC")(gsym_then (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_RID")(thm_tac (new_rewrite [] [])))))); ((((use_arg_then "REAL_ENTIRE")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "y0") (disch_tac [])) THEN (clear_assumption "y0") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac)); ((((use_arg_then "e_ineq") (disch_tac [])) THEN (clear_assumption "e_ineq") THEN (DISCH_THEN apply_tac)) THEN (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL VECTOR_ADD_SUB)))(thm_tac (new_rewrite [] []))))); ((((use_arg_then "REAL_LET_TRANS") (disch_tac [])) THEN (clear_assumption "REAL_LET_TRANS") THEN (DISCH_THEN apply_tac)) THEN ((fun arg_tac -> arg_tac (Arg_term (`norm (t1 % basis j:real^N) + norm (t2 % basis i:real^N)`))) (term_tac exists_tac))); ((((use_arg_then "NORM_TRIANGLE")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "NORM_MUL")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "NORM_BASIS")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (repeat_tactic 1 9 (((use_arg_then "REAL_MUL_RID")(thm_tac (new_rewrite [] [])))))); ((((use_arg_then "yr") (disch_tac [])) THEN (clear_assumption "yr") THEN ((use_arg_then "t_ineq") (disch_tac [])) THEN (clear_assumption "t_ineq") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac)); ((((use_arg_then "LIFT_EQ")(gsym_then (thm_tac (new_rewrite [] []))))) THEN ((fun arg_tac -> (use_arg_then "LIM_UNIQUE") (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`at (vec 0:real^2) within {y:real^2 | &0 < y$1 /\ &0 < y$2}`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (thm_tac apply_tac))); ((fun arg_tac -> arg_tac (Arg_term (`\y:real^2. lift (G (y$1) (y$2) / (y$1 * y$2))`))) (term_tac exists_tac)); (((((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL TRIVIAL_LIMIT_WITHIN)))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "negbK")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "lim0")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];;
let m_cell_domain = new_definition `m_cell_domain (x:real^N, z:real^N) (y:real^N) (w:real^N) <=>
	!i. i IN 1..dimindex (:N) ==> x$i <= y$i /\ y$i <= z$i /\ max (y$i - x$i) (z$i - y$i) <= w$i`;;
let m_bounded_on_int = new_definition `m_bounded_on_int (f:real^N->real) domain f_bounds <=>
	!x. x IN interval [domain] ==> interval_arith (f x) f_bounds`;;
let diff2_domain = new_definition `diff2_domain domain f <=>
	!x. x IN interval [domain] ==> diff2 f x`;;
let diff2c_domain = new_definition `diff2c_domain domain f <=>
	!x. x IN interval [domain] ==> diff2c f x`;;
(* Lemma diff2c_domain_alt *) let diff2c_domain_alt = section_proof ["f";"domain"] `diff2c_domain domain f <=> diff2_domain domain f /\ (!x. x IN interval [domain] ==> !i j. (lift o partial2 j i f) continuous at x)` [ (((((use_arg_then "diff2c_domain")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "diff2c")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "diff2_domain")(thm_tac (new_rewrite [] []))))) THEN ((THENL) (split_tac) [(move ["h1"]); ((case THEN ((move ["h1"]) THEN (move ["h2"]))) THEN (move ["x"]) THEN (move ["h3"]))])); (((split_tac) THEN (move ["x"]) THEN (DISCH_THEN (fun snd_th -> (use_arg_then "h1") (thm_tac (match_mp_then snd_th MP_TAC)))) THEN (simp_tac)) THEN (done_tac)); ((((fun arg_tac -> (use_arg_then "h1") (fun fst_arg -> (use_arg_then "h3") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN ((fun arg_tac -> (use_arg_then "h2") (fun fst_arg -> (use_arg_then "h3") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC THEN (simp_tac)) THEN (done_tac)); ];; (* Lemma y_in_domain *) let y_in_domain = section_proof ["domain";"y";"w"] `m_cell_domain domain y w ==> y IN interval [domain]` [ ((((use_arg_then "domain") (disch_tac [])) THEN (clear_assumption "domain") THEN case THEN (move ["x"]) THEN (move ["z"])) THEN (((((use_arg_then "m_cell_domain")(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL IN_INTERVAL)))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "IN_NUMSEG")(thm_tac (new_rewrite [] []))))) THEN (move ["ineqs"]) THEN (move ["i"]))); (((DISCH_THEN (fun snd_th -> (use_arg_then "ineqs") (thm_tac (match_mp_then snd_th MP_TAC)))) THEN BETA_TAC THEN (simp_tac)) THEN (done_tac)); ];; (* Lemma domain_width *) let domain_width = section_proof ["p";"domain";"y";"w"] `m_cell_domain domain y (w:real^N) ==> p IN interval [domain] ==> !i. i IN 1..dimindex (:N) ==> abs (p$i - y$i) <= w$i` [ ((((use_arg_then "domain") (disch_tac [])) THEN (clear_assumption "domain") THEN case THEN (move ["x"]) THEN (move ["z"])) THEN ((((use_arg_then "m_cell_domain")(thm_tac (new_rewrite [] [])))) THEN (move ["ineqs"]) THEN (move ["p_in"]) THEN (move ["i"]) THEN (move ["i_in"]))); ((((fun arg_tac -> (use_arg_then "ineqs") (fun fst_arg -> (use_arg_then "i_in") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN ((use_arg_then "p_in") (disch_tac [])) THEN (clear_assumption "p_in") THEN BETA_TAC) THEN (((((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL IN_INTERVAL)))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "IN_NUMSEG")(gsym_then (thm_tac (new_rewrite [] [])))))) THEN ((fun arg_tac -> (conv_thm_tac DISCH_THEN) (fun fst_arg -> (use_arg_then "i_in") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (thm_tac MP_TAC))) THEN (arith_tac) THEN (done_tac)); ];; (* Lemma sum_swap1 *) let sum_swap1 = section_proof ["g";"n"] `sum (1..n) (\i. sum (i + 1..n) (\j. g i j)) = sum (1..n) (\i. sum (1..i - 1) (\j. g j i))` [ ((repeat_tactic 1 9 (((use_arg_then "SUM_SUM_PRODUCT")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "FINITE_NUMSEG")(thm_tac (new_rewrite [] []))))) THEN ((simp_tac THEN TRY done_tac)) THEN (repeat_tactic 1 9 (((use_arg_then "IN_NUMSEG")(thm_tac (new_rewrite [] [])))))); ((fun arg_tac -> arg_tac (Arg_term (`{i, j | (1 <= i /\ i <= n) /\ i + 1 <= j /\ j <= n}`))) (term_tac (set_tac "s1"))); ((fun arg_tac -> arg_tac (Arg_term (`{i, j | (1 <= i /\ i <= n) /\ 1 <= j /\ j <= i - 1}`))) (term_tac (set_tac "s2"))); ((fun arg_tac -> arg_tac (Arg_term (`\(i,j):num#num. j, i`))) (term_tac (set_tac "f"))); ((fun arg_tac -> arg_tac (Arg_term (`s1 = IMAGE f s2`))) (term_tac (have_gen_tac [](((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))))); ((((((use_arg_then "s1_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "s2_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "f_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "EXTENSION")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "IN_IMAGE")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "IN_ELIM_THM")(thm_tac (new_rewrite [] []))))) THEN (simp_tac)) THEN (move ["p"])) THEN (split_tac)); (BETA_TAC THEN (case THEN (move ["i"])) THEN (case THEN (move ["j"])) THEN (case THEN (move ["ineq"])) THEN (move ["p_eq"])); (((fun arg_tac -> arg_tac (Arg_term (`j, i`))) (term_tac exists_tac)) THEN ((((use_arg_then "p_eq")(thm_tac (new_rewrite [] [])))) THEN (simp_tac)) THEN (((use_arg_then "j") (term_tac exists_tac)) THEN ((use_arg_then "i") (term_tac exists_tac))) THEN (((use_arg_then "ineq") (disch_tac [])) THEN (clear_assumption "ineq") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac)); (BETA_TAC THEN (case THEN (move ["p1"])) THEN (case THEN (move ["p_eq"])) THEN (case THEN (move ["i"])) THEN (case THEN (move ["j"])) THEN (case THEN (move ["ineq"])) THEN (move ["p1_eq"])); ((((use_arg_then "j") (term_tac exists_tac)) THEN ((use_arg_then "i") (term_tac exists_tac))) THEN ((((use_arg_then "p_eq")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "p1_eq")(thm_tac (new_rewrite [] [])))) THEN (simp_tac)) THEN (((use_arg_then "ineq") (disch_tac [])) THEN (clear_assumption "ineq") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac)); ((fun arg_tac -> arg_tac (Arg_term (`(\(i,j). g j i) = (\(i,j). g i j) o f`))) (term_tac (have_gen_tac [](((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))))); (((((use_arg_then "eq_ext")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "o_THM")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "f_def")(gsym_then (thm_tac (new_rewrite [] [])))))) THEN case THEN (done_tac)); (((use_arg_then "SUM_IMAGE") (thm_tac apply_tac)) THEN (case THEN (move ["i1"]) THEN (move ["j1"])) THEN (case THEN (move ["i2"]) THEN (move ["j2"]))); ((((((use_arg_then "f_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (repeat_tactic 1 9 (((use_arg_then "PAIR_EQ")(thm_tac (new_rewrite [] [])))))) THEN ALL_TAC THEN (case THEN (move ["_"])) THEN (case THEN (move ["_"])) THEN (case THEN ((((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] [])))) THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))))) THEN (done_tac)); ];; (* Lemma m_taylor_error_eq *) let m_taylor_error_eq = section_proof ["f";"domain";"w";"error"] `diff2c_domain domain f ==> (m_taylor_error f domain (w:real^N) error <=> (!x. x IN interval [domain] ==> sum (1..dimindex (:N)) (\i. w$i * (w$i * abs (partial2 i i f x) + &2 * sum (1..i - 1) (\j. w$j * abs (partial2 j i f x)))) <= error))` [ (((((use_arg_then "diff2c_domain")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "m_taylor_error")(thm_tac (new_rewrite [] []))))) THEN (move ["d2f"])); ((fun arg_tac -> arg_tac (Arg_term (`!g1 g2. (!x. x IN interval [domain] ==> g1 x = g2 x) ==> ((!x. x IN interval [domain] ==> g1 x <= error) <=> (!x. x IN interval [domain] ==> g2 x <= error))`))) (term_tac (have_gen_tac [](move ["eq"])))); ((BETA_TAC THEN (move ["g1"]) THEN (move ["g2"]) THEN (move ["eq"])) THEN ((split_tac) THEN (move ["cond"]) THEN (move ["x"]) THEN (move ["Px"]))); (((((use_arg_then "eq")(gsym_then (thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((use_arg_then "cond")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); (((((use_arg_then "eq")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "cond")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); (((use_arg_then "eq") (disch_tac [])) THEN (clear_assumption "eq") THEN (DISCH_THEN apply_tac) THEN (move ["x"]) THEN (DISCH_THEN (fun snd_th -> (use_arg_then "d2f") (thm_tac (match_mp_then snd_th MP_TAC)))) THEN (move ["d2fx"])); ((fun arg_tac -> arg_tac (Arg_term (`\i j. w$i * w$j * abs (partial2 j i f x)`))) (term_tac (set_tac "g"))); ((fun arg_tac -> arg_tac (Arg_term (`dimindex (:N)`))) (term_tac (set_tac "n"))); ((fun arg_tac -> arg_tac (Arg_term (`sum _1 _2`))) (term_tac (set_tac "s1"))); ((fun arg_tac -> arg_tac (Arg_term (`s1 = sum (1..n) (\i. sum (1..n) (\j. g i j))`))) (term_tac (have_gen_tac [](move ["s1_eq"])))); ((((use_arg_then "s1_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "SUM_EQ") (thm_tac apply_tac)) THEN (move ["i"]) THEN (simp_tac) THEN (move ["i_in"]))); (((((use_arg_then "SUM_LMUL")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (((use_arg_then "g_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "partial2")(thm_tac (new_rewrite [] []))))) THEN ((use_arg_then "SUM_EQ") (thm_tac apply_tac)) THEN (done_tac)); ((((use_arg_then "REAL_MUL_2")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "REAL_ADD_LDISTRIB")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "SUM_LMUL")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "REAL_ADD_ASSOC")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "SUM_ADD_NUMSEG")(thm_tac (new_rewrite [] [])))) THEN (simp_tac)); ((fun arg_tac -> arg_tac (Arg_term (`sum _1 _2`))) (term_tac (set_tac "s2"))); ((THENL_FIRST) ((fun arg_tac -> arg_tac (Arg_term (`s2 = sum (1..n) (\i. g i i + sum (1..i - 1) (\j. g i j))`))) (term_tac (have_gen_tac [](move ["s2_eq"])))) (((((use_arg_then "s2_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "g_def")(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (done_tac))); ((fun arg_tac -> arg_tac (Arg_term (`sum _1 _2`))) (term_tac (set_tac "s3"))); ((THENL_FIRST) ((fun arg_tac -> arg_tac (Arg_term (`s3 = sum (1..n) (\i. sum (1..i - 1) (\j. g i j))`))) (term_tac (have_gen_tac [](move ["s3_eq"])))) (((((use_arg_then "s3_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "g_def")(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (done_tac))); (((use_arg_then "s3_def") (disch_tac [])) THEN (clear_assumption "s3_def") THEN ((use_arg_then "s2_def") (disch_tac [])) THEN (clear_assumption "s2_def") THEN ((use_arg_then "s1_def") (disch_tac [])) THEN (clear_assumption "s1_def") THEN BETA_TAC THEN (move ["_"]) THEN (move ["_"]) THEN (move ["_"])); (((THENL_ROT 1)) ((fun arg_tac -> arg_tac (Arg_term (`s3 = sum (1..n) (\i. sum (i + 1..n) (\j. g i j))`))) (term_tac (have_gen_tac [](((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] [])))))))); (((((use_arg_then "s2_eq")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "SUM_ADD_NUMSEG")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (((use_arg_then "s1_eq")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "SUM_EQ") (thm_tac apply_tac)) THEN (move ["i"]) THEN (simp_tac)) THEN ((((use_arg_then "IN_NUMSEG")(thm_tac (new_rewrite [] [])))) THEN (move ["i_ineq"]))); (((((fun arg_tac -> arg_tac (Arg_theorem (REAL_ARITH `!a b c. (a + b) + c = (a + c) + b`)))(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> (fun arg_tac -> (use_arg_then "SUM_SING_NUMSEG") (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`g i`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "i") (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])))); ((THENL_FIRST) ((((use_arg_then "SUM_COMBINE_R")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "i_ineq")(thm_tac (new_rewrite [] [])))))) ((arith_tac) THEN (done_tac))); (((((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL REAL_ADD_AC)))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "SUM_COMBINE_L")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac))) THEN (((use_arg_then "i_ineq") (disch_tac [])) THEN (clear_assumption "i_ineq") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac)); (((((use_arg_then "s3_eq")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "sum_swap1")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "SUM_EQ") (thm_tac apply_tac)) THEN (move ["i"]) THEN (move ["_"]) THEN (simp_tac)) THEN (((use_arg_then "SUM_EQ") (thm_tac apply_tac)) THEN (move ["j"]) THEN (move ["_"]) THEN (simp_tac))); (((((use_arg_then "g_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (((fun arg_tac -> arg_tac (Arg_theorem (REAL_ARITH `!a b c. a * b * c = b * a * c`)))(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "REAL_EQ_MUL_LCANCEL")(thm_tac (new_rewrite [] [])))))) THEN (DISJ2_TAC) THEN (DISJ2_TAC)); ((((use_arg_then "mixed_second_partials")(thm_tac (new_rewrite [] [])))) THEN (done_tac)); ];; (* Lemma diff2_derivative2_bound *) let diff2_derivative2_bound = section_proof ["domain";"y";"w";"p";"f";"dd_bound"] `m_cell_domain domain y (w:real^N) ==> p IN interval [domain] ==> diff2_domain domain f ==> m_taylor_error f domain w dd_bound ==> (!t. interval_arith t (&0, &1) ==> abs (nth_derivative 2 (f o (\t. y + t % (p - y))) t) <= dd_bound)` [ (((((use_arg_then "diff2_domain")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "m_taylor_error")(thm_tac (new_rewrite [] []))))) THEN (move ["domainH"]) THEN (move ["p_in"]) THEN (move ["df"]) THEN (move ["boundedH"]) THEN (move ["t"]) THEN (move ["t_in"])); ((fun arg_tac -> arg_tac (Arg_term (`y + t % (p - y) IN interval [domain]`))) (term_tac (have_gen_tac [](move ["pt_in"])))); ((((fun arg_tac -> arg_tac (Arg_theorem (VECTOR_ARITH `y + t % (p - y) = (&1 - t) % y + t % p:real^N`)))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "IN_CONVEX_SET")(thm_tac (new_rewrite [] []))))); (((((fun arg_tac -> (use_arg_then "y_in_domain") (fun fst_arg -> (use_arg_then "domainH") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "p_in")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "interval_arith")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "t_in")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "pair_eq")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "CONVEX_INTERVAL")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ((((use_arg_then "diff2_dir_derivative2")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "df")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac))); (((((use_arg_then "o_THM")(thm_tac (new_rewrite [] [])))) THEN (simp_tac)) THEN (((fun arg_tac -> (use_arg_then "boundedH") (fun fst_arg -> (use_arg_then "pt_in") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC)); (((fun arg_tac -> arg_tac (Arg_term (`sum _1 _2`))) (term_tac (set_tac "s1"))) THEN (((fun arg_tac -> arg_tac (Arg_term (`sum _1 _2`))) (term_tac (set_tac "s2"))) THEN (move ["i1"]))); ((((use_arg_then "REAL_LE_TRANS") (disch_tac [])) THEN (clear_assumption "REAL_LE_TRANS") THEN (DISCH_THEN apply_tac)) THEN ((use_arg_then "s1") (term_tac exists_tac)) THEN ((((use_arg_then "i1")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andbT")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "s1_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "s2_def")(gsym_then (thm_tac (new_rewrite [] []))))))); (((((use_arg_then "SUM_ABS_LE")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "FINITE_NUMSEG")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))) THEN (move ["i"]) THEN (move ["i_ineq"]) THEN (simp_tac)); (((((use_arg_then "SUM_LMUL")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "SUM_ABS_LE")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "FINITE_NUMSEG")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))) THEN (move ["j"]) THEN (move ["j_ineq"]) THEN (simp_tac)); (((repeat_tactic 1 9 (((use_arg_then "REAL_ABS_MUL")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "REAL_LE_MUL2")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "REAL_LE_MUL")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "REAL_ABS_POS")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((use_arg_then "VECTOR_SUB_COMPONENT")(thm_tac (new_rewrite [] []))))) THEN ((((fun arg_tac -> (fun arg_tac -> (use_arg_then "domain_width") (fun fst_arg -> (use_arg_then "domainH") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "p_in") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "REAL_LE_REFL")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma m_taylor_error_lemma *) let m_taylor_error_lemma = section_proof ["domain";"y";"w";"p";"f";"dd_bound"] `m_cell_domain domain y (w:real^N) ==> p IN interval [domain] ==> diff2_domain domain f ==> m_taylor_error f domain w dd_bound ==> abs (f p - (f y + sum (1..dimindex (:N)) (\i. (p - y)$i * partial i f y))) <= dd_bound / &2` [ ((((use_arg_then "diff2_domain")(thm_tac (new_rewrite [] [])))) THEN (BETA_TAC THEN (move ["domainH"]) THEN (move ["p_in"]) THEN (move ["df"]) THEN (move ["taylor_error"]))); ((fun arg_tac -> arg_tac (Arg_term (`!t. interval_arith t (&0, &1) ==> y + t % (p - y) IN interval [domain]`))) (term_tac (have_gen_tac [](move ["pt_in"])))); ((BETA_TAC THEN (move ["t"]) THEN (move ["t_in"])) THEN ((((fun arg_tac -> arg_tac (Arg_theorem (VECTOR_ARITH `y + t % (p - y) = (&1 - t) % y + t % p:real^N`)))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "IN_CONVEX_SET")(thm_tac (new_rewrite [] [])))))); (((((fun arg_tac -> (use_arg_then "y_in_domain") (fun fst_arg -> (use_arg_then "domainH") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "p_in")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "interval_arith")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "t_in")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "pair_eq")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "CONVEX_INTERVAL")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); (((fun arg_tac -> (fun arg_tac -> (use_arg_then "real_taylor2_bound") (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`f o (\t. y + t % (p - y))`))) (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))) (disch_tac [])) THEN BETA_TAC); ((THENL_FIRST) (ANTS_TAC) (((((use_arg_then "nth_diff_strong_int")(thm_tac (new_rewrite [] [])))) THEN (move ["t"]) THEN (move ["t_in"])) THEN ((((use_arg_then "diff2_dir")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "df")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "pt_in")(thm_tac (new_rewrite [] []))))) THEN (done_tac))); ((THENL_FIRST) (ANTS_TAC) ((((fun arg_tac -> (use_arg_then "diff2_derivative2_bound") (fun fst_arg -> (use_arg_then "domainH") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN (DISCH_THEN apply_tac)) THEN (((use_arg_then "diff2_domain")(thm_tac (new_rewrite [] [])))) THEN (done_tac))); ((repeat_tactic 1 9 (((use_arg_then "o_THM")(thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (((use_arg_then "VECTOR_MUL_LID")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "VECTOR_MUL_LZERO")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "VECTOR_ADD_RID")(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL VECTOR_SUB_ADD2)))(thm_tac (new_rewrite [] []))))); ((THENL_FIRST) ((((use_arg_then "diff2_dir_derivative")(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 "pt_in")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "interval_arith")(thm_tac (new_rewrite [] [])))))) ((arith_tac) THEN (done_tac))); (((((use_arg_then "o_THM")(thm_tac (new_rewrite [] [])))) THEN (simp_tac) THEN (((use_arg_then "VECTOR_MUL_LZERO")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "VECTOR_ADD_RID")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma m_taylor_upper_bound *) let m_taylor_upper_bound = section_proof ["domain";"y";"w";"f";"dd_bound";"hi";"hi_bound"] `m_cell_domain domain y (w:real^N) ==> diff2_domain domain f ==> m_taylor_error f domain w dd_bound ==> f y <= hi ==> hi + sum(1..dimindex (:N)) (\i. w$i * abs (partial i f y)) + dd_bound / &2 <= hi_bound ==> !p. p IN interval [domain] ==> f p <= hi_bound` [ (BETA_TAC THEN (move ["domainH"]) THEN (move ["df"]) THEN (move ["errorH"]) THEN (move ["f_bound"]) THEN (move ["total_bound"]) THEN (move ["p"]) THEN (move ["p_in"])); (((fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (use_arg_then "m_taylor_error_lemma") (fun fst_arg -> (use_arg_then "domainH") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "p_in") (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 fst_arg -> (use_arg_then "errorH") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC); ((DISCH_THEN (fun snd_th -> (fun arg_tac -> arg_tac (Arg_theorem (REAL_ARITH `!x y e. abs (x - y) <= e ==> x <= y + e`))) (thm_tac (match_mp_then snd_th MP_TAC)))) THEN BETA_TAC); (((fun arg_tac -> arg_tac (Arg_term (`sum _1 _2`))) (term_tac (set_tac "s"))) THEN (move ["ineq"])); ((((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 (`(f y + s) + dd_bound / &2`))) (term_tac exists_tac)) THEN ((((use_arg_then "ineq")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))))); (((use_arg_then "total_bound") (disch_tac [])) THEN (clear_assumption "total_bound") THEN ((fun arg_tac -> arg_tac (Arg_theorem (REWRITE_RULE[GSYM IMP_IMP] REAL_LE_TRANS))) (disch_tac [])) THEN (DISCH_THEN apply_tac)); ((((use_arg_then "REAL_ADD_ASSOC")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_LE_RADD")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_LE_ADD2")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "f_bound")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))); ((((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 s`))) (term_tac exists_tac)) THEN ((((use_arg_then "REAL_ABS_LE")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))))); (((((use_arg_then "s_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "SUM_ABS_LE")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "FINITE_NUMSEG")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))) THEN (move ["i"]) THEN (move ["i_ineq"]) THEN (simp_tac)); (((((use_arg_then "REAL_ABS_MUL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_LE_MUL2")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "REAL_ABS_POS")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "REAL_LE_REFL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "VECTOR_SUB_COMPONENT")(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> (use_arg_then "domain_width") (fun fst_arg -> (use_arg_then "domainH") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma m_taylor_lower_bound *) let m_taylor_lower_bound = section_proof ["domain";"y";"w";"f";"dd_bound";"lo";"lo_bound"] `m_cell_domain domain y (w:real^N) ==> diff2_domain domain f ==> m_taylor_error f domain w dd_bound ==> lo <= f y ==> lo_bound <= lo - (sum(1..dimindex (:N)) (\i. w$i * abs (partial i f y)) + dd_bound / &2) ==> !p. p IN interval [domain] ==> lo_bound <= f p` [ (BETA_TAC THEN (move ["domainH"]) THEN (move ["df"]) THEN (move ["errorH"]) THEN (move ["f_bound"]) THEN (move ["total_bound"]) THEN (move ["p"]) THEN (move ["p_in"])); (((fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (use_arg_then "m_taylor_error_lemma") (fun fst_arg -> (use_arg_then "domainH") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "p_in") (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 fst_arg -> (use_arg_then "errorH") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC); ((DISCH_THEN (fun snd_th -> (fun arg_tac -> arg_tac (Arg_theorem (REAL_ARITH `!x y e. abs (x - y) <= e ==> y - e <= x`))) (thm_tac (match_mp_then snd_th MP_TAC)))) THEN BETA_TAC); (((fun arg_tac -> arg_tac (Arg_term (`sum _1 _2`))) (term_tac (set_tac "s"))) THEN (move ["ineq"])); ((((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 (`(f y + s) - dd_bound / &2`))) (term_tac exists_tac)) THEN ((((use_arg_then "ineq")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andbT")(thm_tac (new_rewrite [] [])))))); (((fun arg_tac -> (fun arg_tac -> arg_tac (Arg_theorem (REWRITE_RULE[GSYM IMP_IMP] REAL_LE_TRANS))) (fun fst_arg -> (use_arg_then "total_bound") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN (DISCH_THEN apply_tac)); ((repeat_tactic 1 9 (((use_arg_then "real_sub")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "REAL_NEG_ADD")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_ADD_ASSOC")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_LE_RADD")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_LE_ADD2")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "f_bound")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))); ((THENL_LAST) ((((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 s`))) (term_tac exists_tac)) THEN (((use_arg_then "REAL_LE_NEG")(thm_tac (new_rewrite [] [])))) THEN (split_tac)) ((arith_tac) THEN (done_tac))); (((((use_arg_then "s_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "SUM_ABS_LE")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "FINITE_NUMSEG")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))) THEN (move ["i"]) THEN (move ["i_ineq"]) THEN (simp_tac)); (((((use_arg_then "REAL_ABS_MUL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_LE_MUL2")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "REAL_ABS_POS")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "REAL_LE_REFL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "VECTOR_SUB_COMPONENT")(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> (use_arg_then "domain_width") (fun fst_arg -> (use_arg_then "domainH") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma m_taylor_bounds *) let m_taylor_bounds = section_proof ["domain";"y";"w";"f";"dd_bound";"lo";"hi";"err_bound";"lo_bound";"hi_bound"] `m_cell_domain domain y (w:real^N) ==> diff2_domain domain f ==> m_taylor_error f domain w dd_bound ==> interval_arith (f y) (lo, hi) ==> sum(1..dimindex (:N)) (\i. w$i * abs(partial i f y)) + dd_bound / &2 <= err_bound ==> lo_bound <= lo - err_bound ==> hi + err_bound <= hi_bound ==> m_bounded_on_int f domain (lo_bound, hi_bound)` [ (((((use_arg_then "m_bounded_on_int")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "interval_arith")(thm_tac (new_rewrite [] [])))))) THEN (move ["domainH"]) THEN (move ["df"]) THEN (move ["errorH"]) THEN (case THEN ((move ["f_lo"]) THEN (move ["f_hi"]))) THEN (move ["err"]) THEN (move ["lo_ineq"]) THEN (move ["hi_ineq"]) THEN (move ["p"]) THEN (move ["p_in"])); (((fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (use_arg_then "m_taylor_lower_bound") (fun fst_arg -> (use_arg_then "domainH") (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 fst_arg -> (use_arg_then "errorH") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "f_lo") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "lo_bound") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))); (((((use_arg_then "p_in")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andbT")(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 ((fun arg_tac -> arg_tac (Arg_term (`lo - err_bound`))) (term_tac exists_tac))); (((((use_arg_then "lo_ineq")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "real_sub")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "REAL_LE_ADD2")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_LE_REFL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_LE_NEG")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); (((fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (use_arg_then "m_taylor_upper_bound") (fun fst_arg -> (use_arg_then "domainH") (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 fst_arg -> (use_arg_then "errorH") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "f_hi") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "hi_bound") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac))); (((((use_arg_then "p_in")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andbT")(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 ((fun arg_tac -> arg_tac (Arg_term (`hi + err_bound`))) (term_tac exists_tac))); (((((use_arg_then "hi_ineq")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andbT")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_LE_LADD")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma diff2_derivative_partial_bound *) let diff2_derivative_partial_bound = section_proof ["domain";"y";"w";"p";"f";"i";"d_bound"] `m_cell_domain domain y (w:real^N) ==> p IN interval [domain] ==> diff2_domain domain f ==> m_taylor_partial_error f i domain w d_bound ==> (!t. interval_arith t (&0, &1) ==> abs (derivative (partial i f o (\t. y + t % (p - y))) t) <= d_bound)` [ (((((use_arg_then "diff2_domain")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "m_taylor_partial_error")(thm_tac (new_rewrite [] []))))) THEN (move ["domainH"]) THEN (move ["p_in"]) THEN (move ["df"]) THEN (move ["boundedH"]) THEN (move ["t"]) THEN (move ["t_in"])); ((fun arg_tac -> arg_tac (Arg_term (`y + t % (p - y) IN interval [domain]`))) (term_tac (have_gen_tac [](move ["pt_in"])))); ((((fun arg_tac -> arg_tac (Arg_theorem (VECTOR_ARITH `y + t % (p - y) = (&1 - t) % y + t % p:real^N`)))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "IN_CONVEX_SET")(thm_tac (new_rewrite [] []))))); (((((fun arg_tac -> (use_arg_then "y_in_domain") (fun fst_arg -> (use_arg_then "domainH") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "p_in")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "interval_arith")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "t_in")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "pair_eq")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "CONVEX_INTERVAL")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ((((use_arg_then "diff2_derivative_partial")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "df")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac))); (((fun arg_tac -> (use_arg_then "boundedH") (fun fst_arg -> (use_arg_then "pt_in") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN ((fun arg_tac -> arg_tac (Arg_theorem (REWRITE_RULE[GSYM IMP_IMP] REAL_LE_TRANS))) (disch_tac [])) THEN (DISCH_THEN apply_tac)); (((((use_arg_then "SUM_ABS_LE")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "FINITE_NUMSEG")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))) THEN (move ["j"]) THEN (move ["j_ineq"]) THEN (simp_tac)); ((((use_arg_then "REAL_ABS_MUL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "o_THM")(thm_tac (new_rewrite [] [])))) THEN (simp_tac) THEN (((use_arg_then "REAL_LE_MUL2")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "REAL_ABS_POS")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "REAL_LE_REFL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "VECTOR_SUB_COMPONENT")(thm_tac (new_rewrite [] []))))); ((((fun arg_tac -> (use_arg_then "domain_width") (fun fst_arg -> (use_arg_then "domainH") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [])))) THEN (done_tac)); ];; (* Lemma m_taylor_partial_error_lemma *) let m_taylor_partial_error_lemma = section_proof ["domain";"y";"w";"p";"f";"i";"dd_bound"] `m_cell_domain domain y (w:real^N) ==> p IN interval [domain] ==> diff2_domain domain f ==> m_taylor_partial_error f i domain w dd_bound ==> abs (partial i f p - partial i f y) <= dd_bound` [ ((((use_arg_then "diff2_domain")(thm_tac (new_rewrite [] [])))) THEN (BETA_TAC THEN (move ["domainH"]) THEN (move ["p_in"]) THEN (move ["df"]) THEN (move ["partial_error"]))); ((fun arg_tac -> arg_tac (Arg_term (`!t. interval_arith t (&0, &1) ==> y + t % (p - y) IN interval [domain]`))) (term_tac (have_gen_tac [](move ["pt_in"])))); ((BETA_TAC THEN (move ["t"]) THEN (move ["t_in"])) THEN ((((fun arg_tac -> arg_tac (Arg_theorem (VECTOR_ARITH `y + t % (p - y) = (&1 - t) % y + t % p:real^N`)))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "IN_CONVEX_SET")(thm_tac (new_rewrite [] [])))))); (((((fun arg_tac -> (use_arg_then "y_in_domain") (fun fst_arg -> (use_arg_then "domainH") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "p_in")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "interval_arith")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "t_in")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "pair_eq")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "CONVEX_INTERVAL")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); (((fun arg_tac -> (fun arg_tac -> (use_arg_then "real_taylor1_bound") (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`partial i f o (\t. y + t % (p - y))`))) (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))) (disch_tac [])) THEN BETA_TAC); (ANTS_TAC); ((BETA_TAC THEN (move ["t"]) THEN (move ["t_in"])) THEN ((((use_arg_then "diff2_real_diff_partial")(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 "pt_in")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((fun arg_tac -> (use_arg_then "diff2_derivative_partial_bound") (fun fst_arg -> (use_arg_then "domainH") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)))); ((((use_arg_then "diff2_domain")(thm_tac (new_rewrite [] [])))) THEN (done_tac)); (((repeat_tactic 1 9 (((use_arg_then "o_THM")(thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (((use_arg_then "VECTOR_MUL_LID")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "VECTOR_MUL_LZERO")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "VECTOR_ADD_RID")(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL VECTOR_SUB_ADD2)))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma m_taylor_upper_partial_bound *) let m_taylor_upper_partial_bound = section_proof ["domain";"y";"w";"f";"i";"dd_bound";"hi";"hi_bound"] `m_cell_domain domain y (w:real^N) ==> diff2_domain domain f ==> m_taylor_partial_error f i domain w dd_bound ==> partial i f y <= hi ==> hi + dd_bound <= hi_bound ==> !p. p IN interval [domain] ==> partial i f p <= hi_bound` [ (BETA_TAC THEN (move ["domainH"]) THEN (move ["df"]) THEN (move ["errorH"]) THEN (move ["df_bound"]) THEN (move ["total_bound"]) THEN (move ["p"]) THEN (move ["p_in"])); (((fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (use_arg_then "m_taylor_partial_error_lemma") (fun fst_arg -> (use_arg_then "domainH") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "p_in") (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 fst_arg -> (use_arg_then "errorH") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC); ((DISCH_THEN (fun snd_th -> (fun arg_tac -> arg_tac (Arg_theorem (REAL_ARITH `!x y e. abs (x - y) <= e ==> x <= y + e`))) (thm_tac (match_mp_then snd_th MP_TAC)))) THEN BETA_TAC THEN (move ["ineq"])); (((fun arg_tac -> (fun arg_tac -> arg_tac (Arg_theorem (REWRITE_RULE[GSYM IMP_IMP] REAL_LE_TRANS))) (fun fst_arg -> (use_arg_then "ineq") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN (DISCH_THEN apply_tac)); (((use_arg_then "total_bound") (disch_tac [])) THEN (clear_assumption "total_bound") THEN ((fun arg_tac -> arg_tac (Arg_theorem (REWRITE_RULE[GSYM IMP_IMP] REAL_LE_TRANS))) (disch_tac [])) THEN (DISCH_THEN apply_tac)); (((((use_arg_then "REAL_LE_ADD2")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_LE_REFL")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma m_taylor_lower_partial_bound *) let m_taylor_lower_partial_bound = section_proof ["domain";"y";"w";"f";"i";"dd_bound";"lo";"lo_bound"] `m_cell_domain domain y (w:real^N) ==> diff2_domain domain f ==> m_taylor_partial_error f i domain w dd_bound ==> lo <= partial i f y ==> lo_bound <= lo - dd_bound ==> !p. p IN interval [domain] ==> lo_bound <= partial i f p` [ (BETA_TAC THEN (move ["domainH"]) THEN (move ["df"]) THEN (move ["errorH"]) THEN (move ["df_bound"]) THEN (move ["total_bound"]) THEN (move ["p"]) THEN (move ["p_in"])); (((fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (use_arg_then "m_taylor_partial_error_lemma") (fun fst_arg -> (use_arg_then "domainH") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "p_in") (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 fst_arg -> (use_arg_then "errorH") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC); ((DISCH_THEN (fun snd_th -> (fun arg_tac -> arg_tac (Arg_theorem (REAL_ARITH `!x y e. abs (x - y) <= e ==> y - e <= x`))) (thm_tac (match_mp_then snd_th MP_TAC)))) THEN BETA_TAC THEN (move ["ineq"])); (((use_arg_then "ineq") (disch_tac [])) THEN (clear_assumption "ineq") THEN ((fun arg_tac -> arg_tac (Arg_theorem (REWRITE_RULE[GSYM IMP_IMP] REAL_LE_TRANS))) (disch_tac [])) THEN (DISCH_THEN apply_tac)); (((fun arg_tac -> (fun arg_tac -> arg_tac (Arg_theorem (REWRITE_RULE[GSYM IMP_IMP] REAL_LE_TRANS))) (fun fst_arg -> (use_arg_then "total_bound") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN (DISCH_THEN apply_tac)); (((repeat_tactic 1 9 (((use_arg_then "real_sub")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "REAL_LE_ADD2")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_LE_REFL")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma m_taylor_partial_bounds *) let m_taylor_partial_bounds = section_proof ["domain";"y";"w";"f";"i";"dd_bound";"lo";"hi";"lo_bound";"hi_bound"] `m_cell_domain domain y (w:real^N) ==> diff2_domain domain f ==> m_taylor_partial_error f i domain w dd_bound ==> interval_arith (partial i f y) (lo, hi) ==> lo_bound <= lo - dd_bound ==> hi + dd_bound <= hi_bound ==> m_bounded_on_int (partial i f) domain (lo_bound, hi_bound)` [ (((((use_arg_then "m_bounded_on_int")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "interval_arith")(thm_tac (new_rewrite [] [])))))) THEN (move ["domainH"]) THEN (move ["df"]) THEN (move ["errorH"]) THEN (case THEN ((move ["df_lo"]) THEN (move ["df_hi"]))) THEN (move ["lo_ineq"]) THEN (move ["hi_ineq"]) THEN (move ["p"]) THEN (move ["p_in"])); (((fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (use_arg_then "m_taylor_lower_partial_bound") (fun fst_arg -> (use_arg_then "domainH") (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 fst_arg -> (use_arg_then "errorH") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "df_lo") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "lo_bound") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac))); ((((fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (use_arg_then "m_taylor_upper_partial_bound") (fun fst_arg -> (use_arg_then "domainH") (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 fst_arg -> (use_arg_then "errorH") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "df_hi") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "hi_bound") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Finalization of the section Taylor *) let real_taylor2_bound = finalize_theorem real_taylor2_bound;; let real_taylor1_bound = finalize_theorem real_taylor1_bound;; let taylor_error_eq_sum_partial_errors = finalize_theorem taylor_error_eq_sum_partial_errors;; let diff2c_imp_diff2 = finalize_theorem diff2c_imp_diff2;; let diff2_eq_diff2_on_open = finalize_theorem diff2_eq_diff2_on_open;; let diff2_imp_real_diff = finalize_theorem diff2_imp_real_diff;; let diff2_dir_derivative = finalize_theorem diff2_dir_derivative;; let diff2_partial_real_diff = finalize_theorem diff2_partial_real_diff;; let in_trans = finalize_theorem in_trans;; let open_contains_open_interval = finalize_theorem open_contains_open_interval;; let diff2_dir = finalize_theorem diff2_dir;; let diff2_dir_derivative2 = finalize_theorem diff2_dir_derivative2;; let diff2_has_derivative_partial = finalize_theorem diff2_has_derivative_partial;; let diff2_derivative_partial = finalize_theorem diff2_derivative_partial;; let diff2_real_diff_partial = finalize_theorem diff2_real_diff_partial;; let partial_const = finalize_theorem partial_const;; let partial_eq0_alt = finalize_theorem partial_eq0_alt;; let real_mvt0 = finalize_theorem real_mvt0;; let mixed_second_partials = finalize_theorem mixed_second_partials;; let diff2c_domain_alt = finalize_theorem diff2c_domain_alt;; let y_in_domain = finalize_theorem y_in_domain;; let domain_width = finalize_theorem domain_width;; let sum_swap1 = finalize_theorem sum_swap1;; let m_taylor_error_eq = finalize_theorem m_taylor_error_eq;; let diff2_derivative2_bound = finalize_theorem diff2_derivative2_bound;; let m_taylor_error_lemma = finalize_theorem m_taylor_error_lemma;; let m_taylor_upper_bound = finalize_theorem m_taylor_upper_bound;; let m_taylor_lower_bound = finalize_theorem m_taylor_lower_bound;; let m_taylor_bounds = finalize_theorem m_taylor_bounds;; let diff2_derivative_partial_bound = finalize_theorem diff2_derivative_partial_bound;; let m_taylor_partial_error_lemma = finalize_theorem m_taylor_partial_error_lemma;; let m_taylor_upper_partial_bound = finalize_theorem m_taylor_upper_partial_bound;; let m_taylor_lower_partial_bound = finalize_theorem m_taylor_lower_partial_bound;; let m_taylor_partial_bounds = finalize_theorem m_taylor_partial_bounds;; end_section "Taylor";; (* Section Diff2Arith *) begin_section "Diff2Arith";; (add_section_var (mk_var ("f", (`:real^N -> real`))); add_section_var (mk_var ("g", (`:real^N -> real`))));; (add_section_var (mk_var ("x", (`:real^N`))));; (add_section_var (mk_var ("domain", (`:real^N#real^N`))));; (* Lemma differentiable_local_at *) let differentiable_local_at = section_proof ["s";"f";"g";"x"] `f differentiable at x ==> open s ==> x IN s ==> (!y. y IN s ==> g y = f y) ==> g differentiable at x` [ ((((use_arg_then "OPEN_CONTAINS_BALL")(thm_tac (new_rewrite [] [])))) THEN (move ["df"]) THEN (move ["open_s"]) THEN (move ["xs"]) THEN (move ["eq"])); ((((fun arg_tac -> (use_arg_then "open_s") (fun fst_arg -> (use_arg_then "xs") (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 (((((use_arg_then "SUBSET")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "IN_BALL")(thm_tac (new_rewrite [] []))))) THEN (move ["in_ball"]))); ((((fun arg_tac -> (use_arg_then "DIFFERENTIABLE_TRANSFORM_AT") (fun fst_arg -> (use_arg_then "f") (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 "andbT")(thm_tac (new_rewrite [] [])))))); (((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 ["z"]) THEN (move ["dzx"])) THEN ((((use_arg_then "eq")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "in_ball")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "DIST_SYM")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Section Point *) begin_section "Point";; (* Lemma diff2_scale *) let diff2_scale = section_proof ["f";"c"] `diff2 f x ==> diff2 (\x. c * f x) x` [ ((repeat_tactic 1 9 (((use_arg_then "diff2")(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 ["df"])); (((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 ["z"]) THEN (move ["zs"]))); ((THENL_FIRST) ((((use_arg_then "f_lift_scale")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "DIFFERENTIABLE_CMUL")(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 (((use_arg_then "df")(thm_tac (new_rewrite [] [])))) THEN (done_tac))); ((BETA_TAC THEN (move ["i"])) THEN (((fun arg_tac -> (fun arg_tac -> (use_arg_then "differentiable_local_at") (fun fst_arg -> (use_arg_then "s") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`lift o (\x. c * partial i f x)`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN (DISCH_THEN apply_tac))); ((THENL_FIRST) ((((use_arg_then "open_s")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "zs")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "f_lift_scale")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "DIFFERENTIABLE_CMUL")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))))) ((repeat_tactic 1 9 (((use_arg_then "ETA_AX")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg])))) THEN (((use_arg_then "df")(thm_tac (new_rewrite [] [])))) THEN (done_tac))); ((BETA_TAC THEN (move ["y"]) THEN (move ["ys"])) THEN ((repeat_tactic 1 9 (((use_arg_then "o_THM")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "partial_scale")(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 "LIFT_CMUL")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma diff2_neg *) let diff2_neg = section_proof ["f"] `diff2 f x ==> diff2 (\x. --f x) x` [ (((DISCH_THEN (fun snd_th -> (fun arg_tac -> (fun arg_tac -> (use_arg_then "diff2_scale") (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 (`--(&1)`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (thm_tac (match_mp_then snd_th MP_TAC)))) THEN BETA_TAC) THEN (((use_arg_then "REAL_NEG_MINUS1")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Section Composite *) begin_section "Composite";; (* Lemma has_derivative_uni_compose *) let has_derivative_uni_compose = section_proof ["u";"f";"u'";"f'";"x"] `(lift o f has_derivative f') (at x) ==> (u has_real_derivative u') (atreal (f x)) ==> (lift o u o f has_derivative (\x. u' % f' x)) (at x)` [ (BETA_TAC THEN (move ["df"]) THEN (move ["du"])); ((fun arg_tac -> arg_tac (Arg_term (`lift o u o f = (lift o u o drop) o (lift o f)`))) (term_tac (have_gen_tac [](((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))))); (((((use_arg_then "eq_ext")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "o_THM")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "LIFT_DROP")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ((THENL_FIRST) ((fun arg_tac -> arg_tac (Arg_term (`(\x. u' % f' x) = (\x. u' % x) o f'`))) (term_tac (have_gen_tac [](((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))))) (((((use_arg_then "eq_ext")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "o_THM")(thm_tac (new_rewrite [] []))))) THEN (simp_tac)) THEN (done_tac))); (((((use_arg_then "DIFF_CHAIN_AT")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "o_THM")(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL HAS_REAL_FRECHET_DERIVATIVE_AT)))(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (done_tac)); ];; (* Lemma diff_uni_compose *) let diff_uni_compose = section_proof ["u";"f";"x"] `lift o f differentiable at x ==> u real_differentiable atreal (f x) ==> lift o u o f differentiable at x` [ (((repeat_tactic 1 9 (((use_arg_then "differentiable")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "real_differentiable")(thm_tac (new_rewrite [] []))))) THEN ALL_TAC THEN (case THEN (move ["f'"])) THEN (move ["df"]) THEN (case THEN (move ["u'"])) THEN (move ["du"])); (((fun arg_tac -> arg_tac (Arg_term (`\x. u' % f' x`))) (term_tac exists_tac)) THEN ((use_arg_then "has_derivative_uni_compose") (thm_tac apply_tac)) THEN (done_tac)); ];; (* Lemma diff2_uni_compose *) let diff2_uni_compose = section_proof ["u";"f"] `diff2 f x ==> nth_diff_strong 2 u (f x) ==> diff2 (u o f) x` [ (((repeat_tactic 1 9 (((use_arg_then "diff2")(thm_tac (new_rewrite [] []))))) 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 (move ["df"]) THEN (case THEN (move ["t"])) THEN (case THEN (move ["open_t"])) THEN (case THEN (move ["fxt"])) THEN (move ["du"])); ((fun arg_tac -> arg_tac (Arg_term (`{z | z IN s /\ (lift o f) z IN (IMAGE lift t)}`))) (term_tac (set_tac "r"))); ((fun arg_tac -> arg_tac (Arg_term (`open r`))) (term_tac (have_gen_tac [](move ["open_r"])))); ((((use_arg_then "r_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "CONTINUOUS_OPEN_PREIMAGE")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_OPEN")(gsym_then (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 [] [])))))); (((use_arg_then "DIFFERENTIABLE_IMP_CONTINUOUS_ON") (thm_tac apply_tac)) THEN ((((use_arg_then "differentiable_on")(thm_tac (new_rewrite [] [])))) THEN (move ["y"]) THEN (move ["ys"])) THEN (((use_arg_then "ETA_AX")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg])))); (((((use_arg_then "DIFFERENTIABLE_AT_WITHIN")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "df")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ((THENL_FIRST) (((use_arg_then "r") (term_tac exists_tac)) THEN ((((use_arg_then "open_r")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "r_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "IN_ELIM_THM")(thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (((use_arg_then "o_THM")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "LIFT_IN_IMAGE_LIFT")(thm_tac (new_rewrite [] []))))) THEN (split_tac)) (((use_arg_then "x") (term_tac exists_tac)) THEN (done_tac))); (BETA_TAC THEN (move ["y"]) THEN (case THEN (move ["z"])) THEN (case THEN ((case THEN (move ["zs"])) THEN (move ["fzt"]))) THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))); (((((use_arg_then "diff_uni_compose")(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 "du")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))) THEN (move ["i"])); (((use_arg_then "differentiable_local_at") (thm_tac apply_tac)) THEN (((use_arg_then "r") (term_tac exists_tac)) THEN ((fun arg_tac -> arg_tac (Arg_term (`lift o (\y. derivative u (f y) * partial i f y)`))) (term_tac exists_tac)))); ((((use_arg_then "open_r")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "differentiable_mul")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))))); ((((fun arg_tac -> (use_arg_then "o_THM") (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`derivative u`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "ETA_AX")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg])))) THEN ((((use_arg_then "diff_uni_compose")(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 "du")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ((THENL_FIRST) (((((use_arg_then "r_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "IN_ELIM_THM")(thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (repeat_tactic 1 9 (((use_arg_then "o_THM")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "LIFT_IN_IMAGE_LIFT")(thm_tac (new_rewrite [] [])))))) THEN (split_tac)) (((use_arg_then "z") (term_tac exists_tac)) THEN (done_tac))); (BETA_TAC THEN (move ["y"]) THEN (case THEN (move ["p"])) THEN (case THEN ((case THEN (move ["ps"])) THEN (move ["fpt"]))) THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))); (((((use_arg_then "partial_uni_compose")(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 "du")(thm_tac (new_rewrite [] [])))))) THEN (done_tac)); ];; (* Lemma diff2_inv_compose *) let diff2_inv_compose = section_proof [] `~(f x = &0) ==> diff2 f x ==> diff2 (inv o f) x` [ ((BETA_TAC THEN (DISCH_THEN (fun snd_th -> (use_arg_then "diff2_inv") (thm_tac (match_mp_then snd_th MP_TAC)))) THEN (move ["du"]) THEN (move ["df"])) THEN (((use_arg_then "diff2_uni_compose")(thm_tac (new_rewrite [] [])))) THEN (done_tac)); ];; (* Lemma diff2_sqrt_compose *) let diff2_sqrt_compose = section_proof [] `&0 < f x ==> diff2 f x ==> diff2 (sqrt o f) x` [ ((BETA_TAC THEN (DISCH_THEN (fun snd_th -> (use_arg_then "diff2_sqrt") (thm_tac (match_mp_then snd_th MP_TAC)))) THEN (move ["du"]) THEN (move ["df"])) THEN (((use_arg_then "diff2_uni_compose")(thm_tac (new_rewrite [] [])))) THEN (done_tac)); ];; (* Lemma diff2_atn_compose *) let diff2_atn_compose = section_proof [] `diff2 f x ==> diff2 (atn o f) x` [ ((BETA_TAC THEN (move ["df"])) THEN ((((use_arg_then "diff2_uni_compose")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "diff2_atn")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma diff2_acs_compose *) let diff2_acs_compose = section_proof [] `abs (f x) < &1 ==> diff2 f x ==> diff2 (acs o f) x` [ ((BETA_TAC THEN (DISCH_THEN (fun snd_th -> (use_arg_then "diff2_acs") (thm_tac (match_mp_then snd_th MP_TAC)))) THEN (move ["du"]) THEN (move ["df"])) THEN (((use_arg_then "diff2_uni_compose")(thm_tac (new_rewrite [] [])))) THEN (done_tac)); ];; (* Finalization of the section Composite *) let has_derivative_uni_compose = finalize_theorem has_derivative_uni_compose;; let diff_uni_compose = finalize_theorem diff_uni_compose;; let diff2_uni_compose = finalize_theorem diff2_uni_compose;; let diff2_inv_compose = finalize_theorem diff2_inv_compose;; let diff2_sqrt_compose = finalize_theorem diff2_sqrt_compose;; let diff2_atn_compose = finalize_theorem diff2_atn_compose;; let diff2_acs_compose = finalize_theorem diff2_acs_compose;; end_section "Composite";; (* Lemma diff2_add *) let diff2_add = section_proof ["f";"g"] `diff2 f x ==> diff2 g x ==> diff2 (\x. f x + g x) x` [ ((repeat_tactic 1 9 (((use_arg_then "diff2")(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 ["df"]) THEN (case THEN (move ["t"])) THEN (case THEN (move ["open_t"])) THEN (case THEN (move ["ys"])) THEN (move ["dg"])); (((fun arg_tac -> arg_tac (Arg_term (`s INTER t`))) (term_tac exists_tac)) THEN (((((use_arg_then "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 [] [])))) THEN (((use_arg_then "ys")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))))) THEN (move ["z"]) THEN (case THEN ((move ["zs"]) THEN (move ["zt"]))))); ((((use_arg_then "f_lift_add")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "DIFFERENTIABLE_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 ((((use_arg_then "df")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "dg")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ((BETA_TAC THEN (move ["i"])) THEN (((fun arg_tac -> (fun arg_tac -> (use_arg_then "differentiable_local_at") (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`s INTER t`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`lift o (\x. partial i f x + partial i g x)`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN (DISCH_THEN apply_tac))); ((((use_arg_then "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 "zt")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "zs")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "f_lift_add")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "DIFFERENTIABLE_ADD")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))))); ((repeat_tactic 1 9 (((use_arg_then "ETA_AX")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg])))) THEN ((((use_arg_then "df")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "dg")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ((BETA_TAC THEN (move ["y"]) THEN (case THEN ((move ["ys"]) THEN (move ["yt"])))) THEN ((repeat_tactic 1 9 (((use_arg_then "o_THM")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "partial_add")(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 "LIFT_ADD")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma diff2_sub *) let diff2_sub = section_proof ["f";"g"] `diff2 f x ==> diff2 g x ==> diff2 (\x. f x - g x) x` [ ((BETA_TAC THEN (move ["d2f"]) THEN (move ["d2g"])) THEN ((((use_arg_then "real_sub")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "diff2_add")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "diff2_neg")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma diff2_mul *) let diff2_mul = section_proof ["f";"g"] `diff2 f x ==> diff2 g x ==> diff2 (\x. f x * g x) x` [ ((repeat_tactic 1 9 (((use_arg_then "diff2")(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 ["df"]) THEN (case THEN (move ["t"])) THEN (case THEN (move ["open_t"])) THEN (case THEN (move ["ys"])) THEN (move ["dg"])); (((fun arg_tac -> arg_tac (Arg_term (`s INTER t`))) (term_tac exists_tac)) THEN (((((use_arg_then "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 [] [])))) THEN (((use_arg_then "ys")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))))) THEN (move ["z"]) THEN (case THEN ((move ["zs"]) THEN (move ["zt"]))))); (((((use_arg_then "differentiable_mul")(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 "andTb")(thm_tac (new_rewrite [] []))))) THEN (move ["i"])); (((fun arg_tac -> (fun arg_tac -> (use_arg_then "differentiable_local_at") (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`s INTER t`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`lift o (\x. partial i f x * g x + f x * partial i g x)`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN (DISCH_THEN apply_tac)); ((((use_arg_then "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 "zt")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "zs")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "f_lift_add")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "DIFFERENTIABLE_ADD")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))))); ((repeat_tactic 1 9 (((use_arg_then "ETA_AX")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg])))) THEN (repeat_tactic 1 9 (((use_arg_then "differentiable_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 "df")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "dg")(thm_tac (new_rewrite [] [])))))) THEN (done_tac)); ((BETA_TAC THEN (move ["y"]) THEN (case THEN ((move ["ys"]) THEN (move ["yt"])))) THEN ((repeat_tactic 1 9 (((use_arg_then "o_THM")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "partial_mul")(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 "LIFT_ADD")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Finalization of the section Point *) let diff2_scale = finalize_theorem diff2_scale;; let diff2_neg = finalize_theorem diff2_neg;; let has_derivative_uni_compose = finalize_theorem has_derivative_uni_compose;; let diff_uni_compose = finalize_theorem diff_uni_compose;; let diff2_uni_compose = finalize_theorem diff2_uni_compose;; let diff2_inv_compose = finalize_theorem diff2_inv_compose;; let diff2_sqrt_compose = finalize_theorem diff2_sqrt_compose;; let diff2_atn_compose = finalize_theorem diff2_atn_compose;; let diff2_acs_compose = finalize_theorem diff2_acs_compose;; let diff2_add = finalize_theorem diff2_add;; let diff2_sub = finalize_theorem diff2_sub;; let diff2_mul = finalize_theorem diff2_mul;; end_section "Point";; (* Section Domain *) begin_section "Domain";; (add_section_hyp "d2f" (`diff2_domain domain f`));; (* Lemma diff2_domain_scale *) let diff2_domain_scale = section_proof ["c"] `diff2_domain domain (\x. c * f x)` [ ((((use_arg_then "d2f") (disch_tac [])) THEN (clear_assumption "d2f") THEN BETA_TAC) THEN ((repeat_tactic 1 9 (((use_arg_then "diff2_domain")(thm_tac (new_rewrite [] []))))) THEN (move ["d2f"]) THEN (move ["x"]) THEN (move ["x_in"])) THEN ((((use_arg_then "diff2_scale")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "d2f")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma diff2_domain_neg *) let diff2_domain_neg = section_proof [] `diff2_domain domain (\x. --f x)` [ ((((use_arg_then "d2f") (disch_tac [])) THEN (clear_assumption "d2f") THEN BETA_TAC) THEN ((repeat_tactic 1 9 (((use_arg_then "diff2_domain")(thm_tac (new_rewrite [] []))))) THEN (move ["d2f"]) THEN (move ["x"]) THEN (move ["x_in"])) THEN ((((use_arg_then "diff2_neg")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "d2f")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (add_section_var (mk_var ("bounds", (`:real#real`))));; (* Lemma diff2_domain_inv_compose *) let diff2_domain_inv_compose = section_proof [] `m_bounded_on_int f domain bounds ==> interval_not_zero bounds ==> diff2_domain domain (inv o f)` [ ((((use_arg_then "d2f") (disch_tac [])) THEN (clear_assumption "d2f") THEN BETA_TAC) THEN (((((use_arg_then "m_bounded_on_int")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "diff2_domain")(thm_tac (new_rewrite [] [])))))) THEN (move ["d2f"]) THEN (move ["ineq"]) THEN (move ["n0"]) THEN (move ["x"]) THEN (move ["x_in"]))); (((((use_arg_then "diff2_inv_compose")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "d2f")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "andbT")(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> (use_arg_then "interval_arith_not_zero") (fun fst_arg -> (fun arg_tac -> (use_arg_then "ineq") (fun fst_arg -> (use_arg_then "x_in") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma diff2_domain_sqrt_compose *) let diff2_domain_sqrt_compose = section_proof [] `m_bounded_on_int f domain bounds ==> interval_pos bounds ==> diff2_domain domain (sqrt o f)` [ ((((use_arg_then "d2f") (disch_tac [])) THEN (clear_assumption "d2f") THEN BETA_TAC) THEN (((((use_arg_then "m_bounded_on_int")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "diff2_domain")(thm_tac (new_rewrite [] [])))))) THEN (move ["d2f"]) THEN (move ["ineq"]) THEN (move ["n0"]) THEN (move ["x"]) THEN (move ["x_in"]))); (((((use_arg_then "diff2_sqrt_compose")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "d2f")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "andbT")(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> (use_arg_then "interval_arith_pos") (fun fst_arg -> (fun arg_tac -> (use_arg_then "ineq") (fun fst_arg -> (use_arg_then "x_in") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma diff2_domain_atn_compose *) let diff2_domain_atn_compose = section_proof [] `diff2_domain domain (atn o f)` [ ((((use_arg_then "d2f") (disch_tac [])) THEN (clear_assumption "d2f") THEN BETA_TAC) THEN ((repeat_tactic 1 9 (((use_arg_then "diff2_domain")(thm_tac (new_rewrite [] []))))) THEN (move ["d2f"]) THEN (move ["x"]) THEN (move ["x_in"])) THEN ((((use_arg_then "diff2_atn_compose")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "d2f")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma diff2_domain_acs_compose *) let diff2_domain_acs_compose = section_proof [] `m_bounded_on_int f domain bounds ==> iabs bounds < &1 ==> diff2_domain domain (acs o f)` [ ((((use_arg_then "d2f") (disch_tac [])) THEN (clear_assumption "d2f") THEN BETA_TAC) THEN (((((use_arg_then "m_bounded_on_int")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "diff2_domain")(thm_tac (new_rewrite [] [])))))) THEN (move ["d2f"]) THEN (move ["ineq"]) THEN (move ["n0"]) THEN (move ["x"]) THEN (move ["x_in"]))); (((((use_arg_then "diff2_acs_compose")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "d2f")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "andbT")(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> (use_arg_then "interval_arith_abs") (fun fst_arg -> (fun arg_tac -> (use_arg_then "ineq") (fun fst_arg -> (use_arg_then "x_in") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (add_section_hyp "d2g" (`diff2_domain domain g`));; (* Lemma diff2_domain_add *) let diff2_domain_add = section_proof [] `diff2_domain domain (\x. f x + g x)` [ ((((use_arg_then "d2g") (disch_tac [])) THEN (clear_assumption "d2g") THEN ((use_arg_then "d2f") (disch_tac [])) THEN (clear_assumption "d2f") THEN BETA_TAC) THEN ((repeat_tactic 1 9 (((use_arg_then "diff2_domain")(thm_tac (new_rewrite [] []))))) THEN (move ["d2f"]) THEN (move ["d2g"]) THEN (move ["x"]) THEN (move ["x_in"])) THEN ((((use_arg_then "diff2_add")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "d2f")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "d2g")(thm_tac (new_rewrite [] [])))))) THEN (done_tac)); ];; (* Lemma diff2_domain_sub *) let diff2_domain_sub = section_proof [] `diff2_domain domain (\x. f x - g x)` [ ((((use_arg_then "d2g") (disch_tac [])) THEN (clear_assumption "d2g") THEN ((use_arg_then "d2f") (disch_tac [])) THEN (clear_assumption "d2f") THEN BETA_TAC) THEN ((repeat_tactic 1 9 (((use_arg_then "diff2_domain")(thm_tac (new_rewrite [] []))))) THEN (move ["d2f"]) THEN (move ["d2g"]) THEN (move ["x"]) THEN (move ["x_in"])) THEN ((((use_arg_then "diff2_sub")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "d2f")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "d2g")(thm_tac (new_rewrite [] [])))))) THEN (done_tac)); ];; (* Lemma diff2_domain_mul *) let diff2_domain_mul = section_proof [] `diff2_domain domain (\x. f x * g x)` [ ((((use_arg_then "d2g") (disch_tac [])) THEN (clear_assumption "d2g") THEN ((use_arg_then "d2f") (disch_tac [])) THEN (clear_assumption "d2f") THEN BETA_TAC) THEN ((repeat_tactic 1 9 (((use_arg_then "diff2_domain")(thm_tac (new_rewrite [] []))))) THEN (move ["d2f"]) THEN (move ["d2g"]) THEN (move ["x"]) THEN (move ["x_in"])) THEN ((((use_arg_then "diff2_mul")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "d2f")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "d2g")(thm_tac (new_rewrite [] [])))))) THEN (done_tac)); ];; (* Finalization of the section Domain *) let diff2_domain_scale = finalize_theorem diff2_domain_scale;; let diff2_domain_neg = finalize_theorem diff2_domain_neg;; let diff2_domain_inv_compose = finalize_theorem diff2_domain_inv_compose;; let diff2_domain_sqrt_compose = finalize_theorem diff2_domain_sqrt_compose;; let diff2_domain_atn_compose = finalize_theorem diff2_domain_atn_compose;; let diff2_domain_acs_compose = finalize_theorem diff2_domain_acs_compose;; let diff2_domain_add = finalize_theorem diff2_domain_add;; let diff2_domain_sub = finalize_theorem diff2_domain_sub;; let diff2_domain_mul = finalize_theorem diff2_domain_mul;; end_section "Domain";; (* Section SecondPartial *) begin_section "SecondPartial";; (* Lemma diff2_imp_diff *) let diff2_imp_diff = section_proof ["f";"x"] `diff2 f x ==> (lift o f) differentiable at x` [ (((((use_arg_then "diff2")(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 (done_tac)); ];; (* Lemma diff2_imp_partial_diff *) let diff2_imp_partial_diff = section_proof ["f";"i";"x"] `diff2 f x ==> (lift o partial i f) differentiable at x` [ (((((use_arg_then "diff2")(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 (done_tac)); ];; (* Lemma partial_local *) let partial_local = section_proof ["s";"f";"g";"i";"x"] `(lift o f) differentiable at x ==> open s ==> x IN s ==> (!y:real^N. y IN s ==> f y = g y) ==> partial i f x = partial i g x` [ ((BETA_TAC THEN (move ["df"]) THEN (move ["open_s"]) THEN (move ["xs"]) THEN (move ["eq"])) THEN (repeat_tactic 1 9 (((use_arg_then "partial")(thm_tac (new_rewrite [] [])))))); ((((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))); (((fun arg_tac -> arg_tac (Arg_term (`g o (\t. x + t % basis i)`))) (term_tac exists_tac)) THEN (split_tac)); ((((use_arg_then "has_derivative_alt") (disch_tac [])) THEN (clear_assumption "has_derivative_alt") THEN (DISCH_THEN apply_tac)) THEN ((use_arg_then "diff_imp_real_diff") (thm_tac apply_tac)) THEN ((((use_arg_then "diff_direction")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andbT")(thm_tac (new_rewrite [] [])))))); ((fun arg_tac -> (fun arg_tac -> (use_arg_then "differentiable_local_at") (fun fst_arg -> (use_arg_then "s") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`lift o f`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (thm_tac apply_tac)); (((simp_tac) THEN (((use_arg_then "VECTOR_MUL_LZERO")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "VECTOR_ADD_RID")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "df")(thm_tac (new_rewrite [] [])))) 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 (move ["ys"])); (((repeat_tactic 1 9 (((use_arg_then "o_THM")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "eq")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ((((fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (use_arg_then "open_contains_open_interval") (fun fst_arg -> (use_arg_then "open_s") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "xs") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`basis i:real^N`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC THEN (case THEN (move ["a"])) THEN (case THEN (move ["b"])) THEN (case THEN (move ["ab0"]))) THEN ((((use_arg_then "SUBSET")(thm_tac (new_rewrite [] [])))) THEN (move ["sub"]))); (((fun arg_tac -> arg_tac (Arg_term (`real_interval (a, b)`))) (term_tac exists_tac)) THEN (((((use_arg_then "ab0")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_OPEN_REAL_INTERVAL")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))))) THEN (move ["y"]) THEN (move ["y_in"]))); (((repeat_tactic 1 9 (((use_arg_then "o_THM")(thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (((use_arg_then "eq")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "sub")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "IN_IMAGE")(thm_tac (new_rewrite [] [])))) THEN (simp_tac)) THEN ((use_arg_then "y") (term_tac exists_tac)) THEN (done_tac)); ];; (add_section_var (mk_var ("i", (`:num`))); add_section_var (mk_var ("j", (`:num`))));; (* Lemma second_partial_scale *) let second_partial_scale = section_proof ["f";"c"] `diff2 f x ==> partial2 i j (\x. c * f x) x = c * partial2 i j f x` [ ((BETA_TAC THEN (move ["d2f"])) THEN ((repeat_tactic 1 9 (((use_arg_then "partial2")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "partial_scale")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "diff2_imp_partial_diff")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((use_arg_then "EQ_SYM_EQ")(thm_tac (new_rewrite [] [])))))); ((((use_arg_then "d2f") (disch_tac [])) THEN (clear_assumption "d2f") THEN BETA_TAC) THEN ((((use_arg_then "diff2")(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 ["df"]))); (((use_arg_then "partial_local") (thm_tac apply_tac)) THEN ((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 (((use_arg_then "f_lift_scale")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "DIFFERENTIABLE_CMUL")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))))); ((repeat_tactic 1 9 (((use_arg_then "ETA_AX")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg])))) THEN (((use_arg_then "df")(thm_tac (new_rewrite [] [])))) THEN (done_tac)); ((BETA_TAC THEN (move ["y"]) THEN (move ["ys"])) THEN ((((use_arg_then "partial_scale")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "df")(thm_tac (new_rewrite [] [])))))) THEN (done_tac)); ];; (* Lemma second_partial_neg *) let second_partial_neg = section_proof ["f"] `diff2 f x ==> partial2 i j (\x. --f x) x = --partial2 i j f x` [ (((DISCH_THEN (fun snd_th -> (fun arg_tac -> (fun arg_tac -> (use_arg_then "second_partial_scale") (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 (`--(&1)`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (thm_tac (match_mp_then snd_th MP_TAC)))) THEN BETA_TAC) THEN (repeat_tactic 1 9 (((use_arg_then "REAL_NEG_MINUS1")(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (done_tac)); ];; (* Lemma second_partial_add *) let second_partial_add = section_proof ["f";"g"] `diff2 f x ==> diff2 g x ==> partial2 i j (\x. f x + g x) x = partial2 i j f x + partial2 i j g x` [ ((repeat_tactic 1 9 (((use_arg_then "diff2")(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 ["df"]) THEN (case THEN (move ["t"])) THEN (case THEN (move ["open_t"])) THEN (case THEN (move ["ys"])) THEN (move ["dg"])); (((repeat_tactic 1 9 (((use_arg_then "partial2")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "partial_add")(gsym_then (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 "EQ_SYM_EQ")(thm_tac (new_rewrite [] []))))) THEN ((use_arg_then "partial_local") (thm_tac apply_tac))); (((fun arg_tac -> arg_tac (Arg_term (`s INTER t`))) (term_tac exists_tac)) THEN ((((use_arg_then "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 [] [])))) THEN (((use_arg_then "ys")(thm_tac (new_rewrite [] [])))))); ((((use_arg_then "f_lift_add")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "DIFFERENTIABLE_ADD")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))))); ((repeat_tactic 1 9 (((use_arg_then "ETA_AX")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg])))) 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)); ((BETA_TAC THEN (move ["z"]) THEN (case THEN ((move ["zs"]) THEN (move ["zt"])))) THEN ((((use_arg_then "partial_add")(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 (done_tac)); ];; (* Lemma second_partial_sub *) let second_partial_sub = section_proof ["f";"g"] `diff2 f x ==> diff2 g x ==> partial2 i j (\x. f x - g x) x = partial2 i j f x - partial2 i j g x` [ ((BETA_TAC THEN (move ["d2f"]) THEN (move ["d2g"])) THEN ((((use_arg_then "real_sub")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "second_partial_add")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "diff2_neg")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((use_arg_then "second_partial_neg")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "real_sub")(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (done_tac)); ];; (* Lemma second_partial_mul *) let second_partial_mul = section_proof ["f";"g"] `diff2 f x ==> diff2 g x ==> partial2 i j (\x. f x * g x) x = (partial2 i j f x * g x + partial j f x * partial i g x) + (partial i f x * partial j g x + f x * partial2 i j g x)` [ ((repeat_tactic 1 9 (((use_arg_then "diff2")(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 ["df"]) THEN (case THEN (move ["t"])) THEN (case THEN (move ["open_t"])) THEN (case THEN (move ["ys"])) THEN (move ["dg"])); ((repeat_tactic 1 9 (((use_arg_then "partial2")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "partial_mul")(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (repeat_tactic 0 10 (((use_arg_then "partial_add")(gsym_then (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 (repeat_tactic 0 1 (((use_arg_then "EQ_SYM_EQ")(thm_tac (new_rewrite [] [])))))); ((repeat_tactic 1 9 (((use_arg_then "differentiable_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 "df")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "dg")(thm_tac (new_rewrite [] [])))))) THEN (done_tac)); ((use_arg_then "partial_local") (thm_tac apply_tac)); (((fun arg_tac -> arg_tac (Arg_term (`s INTER t`))) (term_tac exists_tac)) THEN ((((use_arg_then "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 [] [])))) THEN (((use_arg_then "ys")(thm_tac (new_rewrite [] [])))))); ((((use_arg_then "f_lift_add")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "DIFFERENTIABLE_ADD")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))))); ((repeat_tactic 1 9 (((use_arg_then "ETA_AX")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg])))) THEN (repeat_tactic 1 9 (((use_arg_then "differentiable_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 "df")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "dg")(thm_tac (new_rewrite [] [])))))) THEN (done_tac)); ((BETA_TAC THEN (move ["z"]) THEN (case THEN ((move ["zs"]) THEN (move ["zt"])))) THEN ((((use_arg_then "partial_mul")(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 (done_tac)); ];; (* Lemma second_partial_uni_compose *) let second_partial_uni_compose = section_proof ["f";"u"] `diff2 f x ==> nth_diff_strong 2 u (f x) ==> partial2 i j (u o f) x = (nth_derivative 2 u (f x) * partial i f x) * partial j f x + derivative u (f x) * partial2 i j f x` [ (((repeat_tactic 1 9 (((use_arg_then "diff2")(thm_tac (new_rewrite [] []))))) 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 (move ["df"]) THEN (case THEN (move ["t"])) THEN (case THEN (move ["open_t"])) THEN (case THEN (move ["fxt"])) THEN (move ["du"])); ((fun arg_tac -> arg_tac (Arg_term (`{z | z IN s /\ (lift o f) z IN (IMAGE lift t)}`))) (term_tac (set_tac "r"))); ((fun arg_tac -> arg_tac (Arg_term (`open r`))) (term_tac (have_gen_tac [](move ["open_r"])))); ((((use_arg_then "r_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "CONTINUOUS_OPEN_PREIMAGE")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_OPEN")(gsym_then (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 [] [])))))); (((use_arg_then "DIFFERENTIABLE_IMP_CONTINUOUS_ON") (thm_tac apply_tac)) THEN ((((use_arg_then "differentiable_on")(thm_tac (new_rewrite [] [])))) THEN (move ["y"]) THEN (move ["ys"])) THEN (((use_arg_then "ETA_AX")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg])))); (((((use_arg_then "DIFFERENTIABLE_AT_WITHIN")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "df")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ((repeat_tactic 1 9 (((use_arg_then "partial2")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "nth_derivative2")(thm_tac (new_rewrite [] []))))); ((((use_arg_then "partial_uni_compose")(gsym_then (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 "du")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((fun arg_tac -> (use_arg_then "o_THM") (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`derivative u`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "partial_mul")(gsym_then (thm_tac (new_rewrite [] [])))))); (((((use_arg_then "diff_uni_compose")(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 "du")(thm_tac (new_rewrite [] [])))))) THEN (done_tac)); (((use_arg_then "partial_local") (thm_tac apply_tac)) THEN ((use_arg_then "r") (term_tac exists_tac)) THEN ((((use_arg_then "open_r")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andbT")(thm_tac (new_rewrite [] [])))))); ((THENL_ROT (-1)) (((((use_arg_then "r_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "IN_ELIM_THM")(thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (((use_arg_then "o_THM")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "LIFT_IN_IMAGE_LIFT")(thm_tac (new_rewrite [] []))))) THEN (split_tac))); ((BETA_TAC THEN (move ["y"]) THEN (case THEN (move ["z"])) THEN (case THEN ((case THEN (move ["zs"])) THEN (move ["fpz"]))) THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))) THEN ((((use_arg_then "partial_uni_compose")(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 "du")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((use_arg_then "o_THM")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ((THENL_LAST) (split_tac) (((use_arg_then "x") (term_tac exists_tac)) THEN (done_tac))); (((use_arg_then "differentiable_local_at") (thm_tac apply_tac)) THEN (((use_arg_then "r") (term_tac exists_tac)) THEN ((fun arg_tac -> arg_tac (Arg_term (`lift o (\y. derivative u (f y) * partial j f y)`))) (term_tac exists_tac)))); ((((use_arg_then "open_r")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "differentiable_mul")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))))); ((((fun arg_tac -> (use_arg_then "o_THM") (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`derivative u`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "ETA_AX")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg])))) THEN ((((use_arg_then "diff_uni_compose")(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 "du")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ((THENL_FIRST) (((((use_arg_then "r_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "IN_ELIM_THM")(thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (repeat_tactic 1 9 (((use_arg_then "o_THM")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "LIFT_IN_IMAGE_LIFT")(thm_tac (new_rewrite [] [])))))) THEN (split_tac)) (((use_arg_then "x") (term_tac exists_tac)) THEN (done_tac))); ((BETA_TAC THEN (move ["y"]) THEN (case THEN (move ["p"])) THEN (case THEN ((case THEN (move ["ps"])) THEN (move ["fpt"]))) THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))) THEN ((((use_arg_then "partial_uni_compose")(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 "du")(thm_tac (new_rewrite [] [])))))) THEN (done_tac)); ];; (* Finalization of the section SecondPartial *) let diff2_imp_diff = finalize_theorem diff2_imp_diff;; let diff2_imp_partial_diff = finalize_theorem diff2_imp_partial_diff;; let partial_local = finalize_theorem partial_local;; let second_partial_scale = finalize_theorem second_partial_scale;; let second_partial_neg = finalize_theorem second_partial_neg;; let second_partial_add = finalize_theorem second_partial_add;; let second_partial_sub = finalize_theorem second_partial_sub;; let second_partial_mul = finalize_theorem second_partial_mul;; let second_partial_uni_compose = finalize_theorem second_partial_uni_compose;; end_section "SecondPartial";; (* Finalization of the section Diff2Arith *) let differentiable_local_at = finalize_theorem differentiable_local_at;; let diff2_scale = finalize_theorem diff2_scale;; let diff2_neg = finalize_theorem diff2_neg;; let has_derivative_uni_compose = finalize_theorem has_derivative_uni_compose;; let diff_uni_compose = finalize_theorem diff_uni_compose;; let diff2_uni_compose = finalize_theorem diff2_uni_compose;; let diff2_inv_compose = finalize_theorem diff2_inv_compose;; let diff2_sqrt_compose = finalize_theorem diff2_sqrt_compose;; let diff2_atn_compose = finalize_theorem diff2_atn_compose;; let diff2_acs_compose = finalize_theorem diff2_acs_compose;; let diff2_add = finalize_theorem diff2_add;; let diff2_sub = finalize_theorem diff2_sub;; let diff2_mul = finalize_theorem diff2_mul;; let diff2_domain_scale = finalize_theorem diff2_domain_scale;; let diff2_domain_neg = finalize_theorem diff2_domain_neg;; let diff2_domain_inv_compose = finalize_theorem diff2_domain_inv_compose;; let diff2_domain_sqrt_compose = finalize_theorem diff2_domain_sqrt_compose;; let diff2_domain_atn_compose = finalize_theorem diff2_domain_atn_compose;; let diff2_domain_acs_compose = finalize_theorem diff2_domain_acs_compose;; let diff2_domain_add = finalize_theorem diff2_domain_add;; let diff2_domain_sub = finalize_theorem diff2_domain_sub;; let diff2_domain_mul = finalize_theorem diff2_domain_mul;; let diff2_imp_diff = finalize_theorem diff2_imp_diff;; let diff2_imp_partial_diff = finalize_theorem diff2_imp_partial_diff;; let partial_local = finalize_theorem partial_local;; let second_partial_scale = finalize_theorem second_partial_scale;; let second_partial_neg = finalize_theorem second_partial_neg;; let second_partial_add = finalize_theorem second_partial_add;; let second_partial_sub = finalize_theorem second_partial_sub;; let second_partial_mul = finalize_theorem second_partial_mul;; let second_partial_uni_compose = finalize_theorem second_partial_uni_compose;; end_section "Diff2Arith";; (* Section Diff2c *) begin_section "Diff2c";; (* Lemma real_cont_at_local *) let real_cont_at_local = section_proof ["f";"g";"x";"s"] `g real_continuous at x ==> open s ==> x IN s ==> (!y. y IN s ==> f y = g y) ==> f real_continuous at x` [ ((repeat_tactic 1 9 (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL real_continuous_at)))(thm_tac (new_rewrite [] []))))) THEN (move ["g_cont"]) THEN (move ["open_s"]) THEN (move ["xs"]) THEN (move ["f_eq_g"]) THEN (move ["e"]) THEN (move ["e_gt0"])); (((fun arg_tac -> (use_arg_then "OPEN_CONTAINS_BALL") (fun fst_arg -> (use_arg_then "s") (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 "open_s")(thm_tac (new_rewrite [] [])))) THEN (simp_tac) THEN (((use_arg_then "ball")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "SUBSET")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "IN_ELIM_THM")(thm_tac (new_rewrite [] [])))) THEN (simp_tac))); (((fun arg_tac -> (conv_thm_tac DISCH_THEN) (fun fst_arg -> (use_arg_then "xs") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (thm_tac MP_TAC)) THEN BETA_TAC THEN (case THEN (move ["d0"])) THEN (case THEN (move ["d0_gt0"])) THEN (move ["sub_s"])); (((fun arg_tac -> (use_arg_then "g_cont") (fun fst_arg -> (use_arg_then "e_gt0") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC THEN (case THEN (move ["d1"])) THEN (case THEN (move ["d1_gt0"])) THEN (move ["dist_cond"])); ((fun arg_tac -> arg_tac (Arg_term (`min d0 d1`))) (term_tac exists_tac)); (((repeat_tactic 1 9 (((use_arg_then "REAL_LT_MIN")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "d1_gt0")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "d0_gt0")(thm_tac (new_rewrite [] [])))) THEN (simp_tac)) THEN (move ["y"]) THEN (case THEN ((move ["yd0"]) THEN (move ["yd1"])))); ((repeat_tactic 1 9 (((use_arg_then "f_eq_g")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac))); (((((use_arg_then "sub_s")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "DIST_SYM")(thm_tac (new_rewrite [] []))))) THEN ((use_arg_then "y") (term_tac exists_tac)) THEN (done_tac)); (((use_arg_then "dist_cond") (disch_tac [])) THEN (clear_assumption "dist_cond") THEN (exact_tac)); ];; (* Lemma real_cont_atreal_local *) let real_cont_atreal_local = section_proof ["v";"u";"t";"x"] `v real_continuous atreal x ==> real_open t ==> x IN t ==> (!y. y IN t ==> u y = v y) ==> u real_continuous atreal x` [ (repeat_tactic 1 9 (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL REAL_CONTINUOUS_CONTINUOUS_ATREAL)))(thm_tac (new_rewrite [] []))))); (((repeat_tactic 1 9 (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL REAL_CONTINUOUS_CONTINUOUS1)))(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (((use_arg_then "REAL_OPEN")(thm_tac (new_rewrite [] []))))) THEN (move ["vc"]) THEN (move ["open_t"]) THEN (move ["xt"]) THEN (move ["v_eq_u"])); ((use_arg_then "real_cont_at_local") (thm_tac apply_tac)); (((fun arg_tac -> arg_tac (Arg_term (`v o drop`))) (term_tac exists_tac)) THEN ((fun arg_tac -> arg_tac (Arg_term (`IMAGE lift t`))) (term_tac exists_tac))); ((((((use_arg_then "open_t")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "vc")(thm_tac (new_rewrite [] [])))) THEN (simp_tac) THEN (((use_arg_then "LIFT_IN_IMAGE_LIFT")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "xt")(thm_tac (new_rewrite [] [])))) THEN (simp_tac) THEN (((use_arg_then "IN_IMAGE_LIFT_DROP")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "o_THM")(thm_tac (new_rewrite [] [])))))) THEN (move ["y"]) THEN (DISCH_THEN (fun snd_th -> (use_arg_then "v_eq_u") (thm_tac (match_mp_then snd_th MP_TAC))))) THEN (done_tac)); ];; (add_section_type (mk_var ("f", (`:real^N -> real`))); add_section_type (mk_var ("g", (`:real^N -> real`))));; (add_section_var (mk_var ("x", (`:real^N`))));; (add_section_var (mk_var ("domain", (`:real^N#real^N`))));; (* Section Point *) begin_section "Point";; (* Lemma diff2c_scale *) let diff2c_scale = section_proof ["f";"c"] `diff2c f x ==> diff2c (\x. c * f x) x` [ (((repeat_tactic 1 9 (((use_arg_then "diff2c")(thm_tac (new_rewrite [] []))))) THEN ALL_TAC THEN (case THEN ((move ["d2f"]) THEN (move ["p2c"])))) THEN (((((use_arg_then "diff2_scale")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))) THEN (move ["i"]) THEN (move ["j"]))); ((((fun arg_tac -> (fun arg_tac -> (use_arg_then "p2c") (fun fst_arg -> (use_arg_then "i") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "j") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC) THEN ((repeat_tactic 1 9 (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL REAL_CONTINUOUS_CONTINUOUS1)))(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (move ["p2ij"]))); ((use_arg_then "real_cont_at_local") (thm_tac apply_tac)); ((((use_arg_then "d2f") (disch_tac [])) THEN (clear_assumption "d2f") THEN BETA_TAC) THEN ((((use_arg_then "diff2_eq_diff2_on_open")(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 ["d2s"]))); (((fun arg_tac -> arg_tac (Arg_term (`(\x. c * partial2 j i f x)`))) (term_tac exists_tac)) THEN ((use_arg_then "s") (term_tac exists_tac))); ((THENL_FIRST) (((use_arg_then "REAL_CONTINUOUS_LMUL")(thm_tac (new_rewrite [] [])))) ((((use_arg_then "ETA_AX")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN (done_tac))); (((((use_arg_then "open_s")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "xs")(thm_tac (new_rewrite [] [])))) THEN (simp_tac)) THEN (move ["y"]) THEN (DISCH_THEN (fun snd_th -> (use_arg_then "d2s") (thm_tac (match_mp_then snd_th MP_TAC)))) THEN (move ["d2y"])); ((((use_arg_then "second_partial_scale")(thm_tac (new_rewrite [] [])))) THEN (done_tac)); ];; (* Lemma diff2c_neg *) let diff2c_neg = section_proof ["f"] `diff2c f x ==> diff2c (\x. --f x) x` [ (((DISCH_THEN (fun snd_th -> (fun arg_tac -> (fun arg_tac -> (use_arg_then "diff2c_scale") (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 (`--(&1)`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (thm_tac (match_mp_then snd_th MP_TAC)))) THEN BETA_TAC) THEN (((use_arg_then "REAL_NEG_MINUS1")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Section Composite *) begin_section "Composite";; (* Lemma nth_diff_strong_eq_on_open *) let nth_diff_strong_eq_on_open = section_proof ["n";"u";"x"] `nth_diff_strong n u x ==> ?s. real_open s /\ x IN s /\ (!y. y IN s ==> nth_diff_strong n u y)` [ ((repeat_tactic 1 9 (((use_arg_then "nth_diff_strong")(thm_tac (new_rewrite [] []))))) THEN ALL_TAC THEN (case THEN (move ["t"])) THEN (case THEN (move ["open_t"])) THEN (case THEN (move ["xt"])) THEN (move ["dt"])); (((use_arg_then "t") (term_tac exists_tac)) THEN (((((use_arg_then "xt")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "open_t")(thm_tac (new_rewrite [] [])))) THEN (simp_tac)) THEN (move ["y"]) THEN (move ["yt"]))); (((use_arg_then "t") (term_tac exists_tac)) THEN (done_tac)); ];; (* Lemma diff2_imp_cont *) let diff2_imp_cont = section_proof ["f";"x"] `diff2 f x ==> f real_continuous at x` [ ((((use_arg_then "diff2")(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 ["df"])); (((((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL REAL_CONTINUOUS_CONTINUOUS1)))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "DIFFERENTIABLE_IMP_CONTINUOUS_AT")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "df")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma diff2_imp_partial_cont *) let diff2_imp_partial_cont = section_proof ["f";"i";"x"] `diff2 f x ==> (partial i f) real_continuous at x` [ ((((use_arg_then "diff2")(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 ["df"])); (((((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL REAL_CONTINUOUS_CONTINUOUS1)))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "DIFFERENTIABLE_IMP_CONTINUOUS_AT")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "df")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma diff2c_uni_compose *) let diff2c_uni_compose = section_proof ["u";"f";"x"] `diff2c f x ==> nth_diff_strong 2 u (f x) ==> (nth_derivative 2 u) real_continuous atreal (f x) ==> diff2c (u o f) x` [ ((repeat_tactic 1 9 (((use_arg_then "diff2c")(thm_tac (new_rewrite [] []))))) THEN ALL_TAC THEN (case THEN (move ["d2f"])) THEN (move ["p2c"]) THEN (move ["d2u"]) THEN (move ["u2c"])); (((((use_arg_then "diff2_uni_compose")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "d2f")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "d2u")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))) THEN (move ["i"]) THEN (move ["j"])); ((((fun arg_tac -> (fun arg_tac -> (use_arg_then "p2c") (fun fst_arg -> (use_arg_then "i") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "j") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC) THEN ((repeat_tactic 1 9 (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL REAL_CONTINUOUS_CONTINUOUS1)))(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (move ["p2ij"]))); ((use_arg_then "real_cont_at_local") (thm_tac apply_tac)); ((((use_arg_then "d2f") (disch_tac [])) THEN (clear_assumption "d2f") THEN BETA_TAC) THEN ((((use_arg_then "diff2_eq_diff2_on_open")(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 ["d2s"]))); (((fun arg_tac -> (use_arg_then "nth_diff_strong_eq_on_open") (fun fst_arg -> (use_arg_then "d2u") (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 ["fxt"])) THEN (move ["d2t"])); ((fun arg_tac -> arg_tac (Arg_term (`{z | z IN s /\ (lift o f) z IN (IMAGE lift t)}`))) (term_tac (set_tac "r"))); ((fun arg_tac -> arg_tac (Arg_term (`open r`))) (term_tac (have_gen_tac [](move ["open_r"])))); ((((use_arg_then "r_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "CONTINUOUS_OPEN_PREIMAGE")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_OPEN")(gsym_then (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 [] [])))))); (((use_arg_then "DIFFERENTIABLE_IMP_CONTINUOUS_ON") (thm_tac apply_tac)) THEN ((((use_arg_then "differentiable_on")(thm_tac (new_rewrite [] [])))) THEN (move ["y"]) THEN (move ["ys"])) THEN (((use_arg_then "ETA_AX")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg])))); (((use_arg_then "DIFFERENTIABLE_AT_WITHIN")(thm_tac (new_rewrite [] [])))); ((((fun arg_tac -> (use_arg_then "d2s") (fun fst_arg -> (use_arg_then "ys") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC) THEN ((((use_arg_then "diff2")(thm_tac (new_rewrite [] [])))) THEN ALL_TAC THEN (case THEN (move ["s'"])) THEN (case THEN (move ["_"])) THEN (case THEN (move ["ys'"])))); ((((fun arg_tac -> (conv_thm_tac DISCH_THEN) (fun fst_arg -> (use_arg_then "ys'") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (thm_tac MP_TAC)) THEN BETA_TAC THEN (simp_tac)) THEN (done_tac)); (((fun arg_tac -> arg_tac (Arg_term (`(\x. (nth_derivative 2 u (f x) * partial j f x) * partial i f x + derivative u (f x) * partial2 j i f x)`))) (term_tac exists_tac)) THEN ((use_arg_then "r") (term_tac exists_tac))); ((THENL_ROT (-1)) (((((use_arg_then "open_r")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "r_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "IN_ELIM_THM")(thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (((use_arg_then "o_THM")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "LIFT_IN_IMAGE_LIFT")(thm_tac (new_rewrite [] []))))) THEN (split_tac))); (BETA_TAC THEN (move ["y"]) THEN (case THEN (move ["z"])) THEN (case THEN ALL_TAC) THEN (case THEN (move ["zs"])) THEN (move ["fzt"]) THEN (move ["yz"])); (((((use_arg_then "second_partial_uni_compose")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "yz")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "d2s")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "d2t")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ((THENL_LAST) (split_tac) (((use_arg_then "x") (term_tac exists_tac)) THEN (done_tac))); (((((use_arg_then "REAL_CONTINUOUS_ADD")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "REAL_CONTINUOUS_MUL")(thm_tac (new_rewrite [] []))))) THEN ((simp_tac THEN TRY done_tac))) THEN (((use_arg_then "ETA_AX")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN ((repeat_tactic 0 10 (((fun arg_tac ->(use_arg_then "diff2_imp_partial_cont")(fun tmp_arg1 -> (use_arg_then "d2s")(fun tmp_arg2 -> arg_tac (Arg_theorem (CONJ (get_arg_thm tmp_arg1) (get_arg_thm tmp_arg2))))))(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)))); (((((use_arg_then "andbT")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "o_THM")(gsym_then (thm_tac (new_rewrite [] [(`nth_derivative 2 u _1`)])))))) THEN (((use_arg_then "ETA_AX")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg])))); (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL REAL_CONTINUOUS_CONTINUOUS1)))(thm_tac (new_rewrite [] [])))); ((((use_arg_then "o_ASSOC")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "CONTINUOUS_REAL_CONTINUOUS_AT_COMPOSE")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "diff2_imp_cont")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "d2s")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))); (((((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL REAL_CONTINUOUS_CONTINUOUS1)))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "REAL_CONTINUOUS_ATREAL_WITHINREAL")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); (((((use_arg_then "p2ij")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andbT")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "o_THM")(gsym_then (thm_tac (new_rewrite [] [(`derivative u _`)])))))) THEN (((use_arg_then "ETA_AX")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg])))); (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL REAL_CONTINUOUS_CONTINUOUS1)))(thm_tac (new_rewrite [] [])))); ((((use_arg_then "o_ASSOC")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "CONTINUOUS_REAL_CONTINUOUS_AT_COMPOSE")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "diff2_imp_cont")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "d2s")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))); ((((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL REAL_CONTINUOUS_CONTINUOUS1)))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "REAL_CONTINUOUS_ATREAL_WITHINREAL")(thm_tac (new_rewrite [] []))))); ((((use_arg_then "nth_derivative1")(gsym_then (thm_tac (new_rewrite [] []))))) THEN ((use_arg_then "nth_derivative_continuous") (thm_tac apply_tac))); ((THENL_LAST) (((fun arg_tac -> arg_tac (Arg_term (`2`))) (term_tac exists_tac)) THEN (split_tac)) ((arith_tac) THEN (done_tac))); ((((fun arg_tac -> (use_arg_then "d2t") (fun fst_arg -> (use_arg_then "fxt") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC) THEN (((((use_arg_then "nth_diff_strong")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "nth_differentiable_on")(thm_tac (new_rewrite [] []))))) THEN ALL_TAC THEN (case THEN (move ["t'"])) THEN (case THEN (move ["_"])) THEN (case THEN (move ["fxt'"])) THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma real_open_delete *) let real_open_delete = section_proof ["s";"x"] `real_open s ==> real_open (s DELETE x)` [ ((repeat_tactic 1 9 (((use_arg_then "REAL_OPEN")(thm_tac (new_rewrite [] []))))) THEN (DISCH_THEN (fun snd_th -> (use_arg_then "OPEN_DELETE") (thm_tac (match_mp_then snd_th MP_TAC)))) THEN ((fun arg_tac -> (conv_thm_tac DISCH_THEN) (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`lift x`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (thm_tac MP_TAC))); (((((use_arg_then "IMAGE_DELETE_INJ")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "LIFT_EQ")(thm_tac (new_rewrite [] [])))))) THEN (done_tac)); ];; (* Lemma diff2c_inv_compose *) let diff2c_inv_compose = section_proof ["f"] `~(f x = &0) ==> diff2c f x ==> diff2c (inv o f) x` [ ((BETA_TAC THEN (move ["fn0"]) THEN (move ["d2f"])) THEN (((use_arg_then "diff2c_uni_compose")(thm_tac (new_rewrite [] []))))); ((((fun arg_tac -> (use_arg_then "diff2_inv") (fun fst_arg -> (use_arg_then "fn0") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "d2f")(thm_tac (new_rewrite [] [])))) THEN (simp_tac)); (((use_arg_then "real_cont_atreal_local") (disch_tac [])) THEN (clear_assumption "real_cont_atreal_local") THEN (DISCH_THEN apply_tac)); (((fun arg_tac -> arg_tac (Arg_term (`\x. &2 * inv (x pow 3)`))) (term_tac exists_tac)) THEN ((fun arg_tac -> arg_tac (Arg_term (`UNIV DELETE (&0)`))) (term_tac exists_tac))); ((THENL_ROT (-1)) (((((use_arg_then "real_open_delete")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "REAL_OPEN_UNIV")(thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (repeat_tactic 1 9 (((use_arg_then "IN_DELETE")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "IN_UNIV")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "fn0")(thm_tac (new_rewrite [] [])))) THEN (simp_tac)) THEN (split_tac))); ((BETA_TAC THEN (move ["y"]) THEN (move ["yn0"])) THEN (((use_arg_then "second_derivative_inv")(thm_tac (new_rewrite [] [])))) THEN (done_tac)); ((((use_arg_then "REAL_CONTINUOUS_LMUL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_CONTINUOUS_INV_ATREAL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_CONTINUOUS_POW")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "REAL_CONTINUOUS_AT_ID")(thm_tac (new_rewrite [] [])))))); ((((use_arg_then "REAL_POW_NZ")(thm_tac (new_rewrite [] [])))) THEN (done_tac)); ];; (* Lemma diff2c_sqrt_compose *) let diff2c_sqrt_compose = section_proof ["f"] `&0 < f x ==> diff2c f x ==> diff2c (sqrt o f) x` [ ((BETA_TAC THEN (move ["fn0"]) THEN (move ["d2f"])) THEN (((use_arg_then "diff2c_uni_compose")(thm_tac (new_rewrite [] []))))); ((((fun arg_tac -> (use_arg_then "diff2_sqrt") (fun fst_arg -> (use_arg_then "fn0") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "d2f")(thm_tac (new_rewrite [] [])))) THEN (simp_tac)); (((use_arg_then "real_cont_atreal_local") (disch_tac [])) THEN (clear_assumption "real_cont_atreal_local") THEN (DISCH_THEN apply_tac)); (((fun arg_tac -> arg_tac (Arg_term (`\x. -- inv (&4 * sqrt (x pow 3))`))) (term_tac exists_tac)) THEN ((fun arg_tac -> arg_tac (Arg_term (`{x | x > &0}`))) (term_tac exists_tac))); ((THENL_ROT (-1)) (((((use_arg_then "REAL_OPEN_HALFSPACE_GT")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "IN_ELIM_THM")(thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (repeat_tactic 1 9 (((use_arg_then "real_gt")(thm_tac (new_rewrite [] [])))))) THEN (split_tac))); ((BETA_TAC THEN (move ["y"]) THEN (case THEN (move ["z"])) THEN (case THEN (move ["z0"])) THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "second_derivative_sqrt")(thm_tac (new_rewrite [] [])))) THEN (done_tac)); ((THENL_LAST) (split_tac) (((fun arg_tac -> arg_tac (Arg_term (`f x`))) (term_tac exists_tac)) THEN (done_tac))); ((THENL_ROT (-1)) ((((use_arg_then "REAL_CONTINUOUS_NEG")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_CONTINUOUS_INV_ATREAL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_CONTINUOUS_LMUL")(thm_tac (new_rewrite [] [])))))); ((THENL_FIRST) (((((use_arg_then "REAL_ENTIRE")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "negb_or")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))) THEN (split_tac)) ((arith_tac) THEN (done_tac))); ((((use_arg_then "SQRT_EQ_0")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "REAL_POW_NZ")(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_POW_LE")(thm_tac (new_rewrite [] []))))); ((((use_arg_then "fn0") (disch_tac [])) THEN (clear_assumption "fn0") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac)); ((fun arg_tac -> arg_tac (Arg_term (`(\x. sqrt (x pow 3)) = (sqrt o (\x. x pow 3))`))) (term_tac (have_gen_tac [](((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))))); (((((use_arg_then "FUN_EQ_THM")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "o_THM")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ((((use_arg_then "REAL_CONTINUOUS_ATREAL_COMPOSE")(thm_tac (new_rewrite [] [])))) THEN (simp_tac) THEN (((use_arg_then "REAL_CONTINUOUS_POW")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "REAL_CONTINUOUS_AT_ID")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))); (((((use_arg_then "REAL_CONTINUOUS_AT_SQRT")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_POW_LT")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma diff2c_atn_compose *) let diff2c_atn_compose = section_proof ["f"] `diff2c f x ==> diff2c (atn o f) x` [ ((BETA_TAC THEN (move ["d2f"])) THEN (((use_arg_then "diff2c_uni_compose")(thm_tac (new_rewrite [] []))))); ((((use_arg_then "diff2_atn")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "d2f")(thm_tac (new_rewrite [] [])))) THEN (simp_tac) THEN (((use_arg_then "nth_derivative2")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "second_derivative_atn")(thm_tac (new_rewrite [] []))))); ((repeat_tactic 1 9 (((use_arg_then "REAL_CONTINUOUS_MUL")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "REAL_CONTINUOUS_CONST")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "REAL_CONTINUOUS_AT_ID")(thm_tac (new_rewrite [] []))))) THEN ((simp_tac THEN TRY done_tac))); ((((use_arg_then "REAL_CONTINUOUS_POW")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_CONTINUOUS_INV_ATREAL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_CONTINUOUS_ADD")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))))); (((((use_arg_then "REAL_CONTINUOUS_CONST")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_CONTINUOUS_POW")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "REAL_CONTINUOUS_AT_ID")(thm_tac (new_rewrite [] [])))))) THEN (done_tac)); (((use_arg_then "REAL_RNEG_UNIQ")(thm_tac (new_rewrite [] [])))); ((fun arg_tac -> (use_arg_then "REAL_LE_POW_2") (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 arg -> thm_tac MP_TAC arg THEN ALL_TAC)); ((arith_tac) THEN (done_tac)); ];; (* Lemma diff2c_acs_compose *) let diff2c_acs_compose = section_proof ["f"] `abs (f x) < &1 ==> diff2c f x ==> diff2c (acs o f) x` [ ((BETA_TAC THEN (move ["fn1"]) THEN (move ["d2f"])) THEN (((use_arg_then "diff2c_uni_compose")(thm_tac (new_rewrite [] []))))); ((((fun arg_tac -> (use_arg_then "diff2_acs") (fun fst_arg -> (use_arg_then "fn1") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "d2f")(thm_tac (new_rewrite [] [])))) THEN (simp_tac)); (((use_arg_then "real_cont_atreal_local") (disch_tac [])) THEN (clear_assumption "real_cont_atreal_local") THEN (DISCH_THEN apply_tac)); (((fun arg_tac -> arg_tac (Arg_term (`\x. --(x / sqrt ((&1 - x * x) pow 3))`))) (term_tac exists_tac)) THEN ((fun arg_tac -> arg_tac (Arg_term (`{x | x < &1} INTER {x | x > -- &1}`))) (term_tac exists_tac))); ((((use_arg_then "REAL_OPEN_INTER")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "REAL_OPEN_HALFSPACE_GT")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "REAL_OPEN_HALFSPACE_LT")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac))); ((THENL_ROT (-1)) (((repeat_tactic 1 9 (((use_arg_then "IN_INTER")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "IN_ELIM_THM")(thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (repeat_tactic 1 9 (((use_arg_then "real_gt")(thm_tac (new_rewrite [] [])))))) THEN (split_tac))); ((BETA_TAC THEN (move ["y"]) THEN (case THEN ALL_TAC) THEN (case THEN (move ["a"])) THEN (case THEN (move ["a1"])) THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] [])))) THEN (case THEN (move ["b"])) THEN (case THEN (move ["b1"])) THEN (move ["ab"])) THEN ((((use_arg_then "second_derivative_acs")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)))); ((((use_arg_then "a1") (disch_tac [])) THEN (clear_assumption "a1") THEN ((use_arg_then "b1") (disch_tac [])) THEN (clear_assumption "b1") THEN ((use_arg_then "ab") (disch_tac [])) THEN (clear_assumption "ab") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac)); ((THENL_LAST) (split_tac) ((split_tac) THEN ((fun arg_tac -> arg_tac (Arg_term (`f x`))) (term_tac exists_tac)) THEN (((use_arg_then "fn1") (disch_tac [])) THEN (clear_assumption "fn1") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac))); (((use_arg_then "REAL_CONTINUOUS_NEG")(thm_tac (new_rewrite [] [])))); ((use_arg_then "REAL_CONTINUOUS_DIV_ATREAL") (thm_tac apply_tac)); ((fun arg_tac -> arg_tac (Arg_term (`&0 < (&1 - f x * f x) pow 3`))) (term_tac (have_gen_tac [](move ["h"])))); (((use_arg_then "REAL_POW_LT")(thm_tac (new_rewrite [] [])))); ((((fun arg_tac -> arg_tac (Arg_theorem (REAL_ARITH `!a. &1 - a * a = (&1 - a) * (&1 + a)`)))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_LT_MUL")(thm_tac (new_rewrite [] []))))); ((((use_arg_then "fn1") (disch_tac [])) THEN (clear_assumption "fn1") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac)); ((THENL_ROT (-1)) (((((use_arg_then "REAL_CONTINUOUS_AT_ID")(thm_tac (new_rewrite [] [])))) THEN (simp_tac)) THEN (split_tac))); (((((use_arg_then "SQRT_EQ_0")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "REAL_LE_LT")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((use_arg_then "REAL_LT_IMP_NZ")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ((fun arg_tac -> arg_tac (Arg_term (`(\x. sqrt ((&1 - x * x) pow 3)) = sqrt o (\x. (&1 - x * x) pow 3)`))) (term_tac (have_gen_tac [](((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))))); (((((use_arg_then "FUN_EQ_THM")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "o_THM")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ((((use_arg_then "REAL_CONTINUOUS_ATREAL_COMPOSE")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_CONTINUOUS_AT_SQRT")(thm_tac (new_rewrite [] [])))) THEN ((simp_tac THEN TRY done_tac))); ((((use_arg_then "REAL_CONTINUOUS_POW")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_CONTINUOUS_SUB")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_CONTINUOUS_CONST")(thm_tac (new_rewrite [] []))))); (((((use_arg_then "REAL_CONTINUOUS_MUL")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "REAL_CONTINUOUS_AT_ID")(thm_tac (new_rewrite [] [])))))) THEN (done_tac)); ];; (* Finalization of the section Composite *) let nth_diff_strong_eq_on_open = finalize_theorem nth_diff_strong_eq_on_open;; let diff2_imp_cont = finalize_theorem diff2_imp_cont;; let diff2_imp_partial_cont = finalize_theorem diff2_imp_partial_cont;; let diff2c_uni_compose = finalize_theorem diff2c_uni_compose;; let real_open_delete = finalize_theorem real_open_delete;; let diff2c_inv_compose = finalize_theorem diff2c_inv_compose;; let diff2c_sqrt_compose = finalize_theorem diff2c_sqrt_compose;; let diff2c_atn_compose = finalize_theorem diff2c_atn_compose;; let diff2c_acs_compose = finalize_theorem diff2c_acs_compose;; end_section "Composite";; (* Lemma diff2c_add *) let diff2c_add = section_proof ["f";"g"] `diff2c f x ==> diff2c g x ==> diff2c (\x. f x + g x) x` [ (((repeat_tactic 1 9 (((use_arg_then "diff2c")(thm_tac (new_rewrite [] []))))) THEN ALL_TAC THEN (case THEN ((move ["d2f"]) THEN (move ["p2f"]))) THEN (case THEN ((move ["d2g"]) THEN (move ["p2g"])))) THEN (((((use_arg_then "diff2_add")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))) THEN (move ["i"]) THEN (move ["j"]))); ((((fun arg_tac -> (fun arg_tac -> (use_arg_then "p2g") (fun fst_arg -> (use_arg_then "i") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "j") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN ((fun arg_tac -> (fun arg_tac -> (use_arg_then "p2f") (fun fst_arg -> (use_arg_then "i") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "j") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC) THEN ((repeat_tactic 1 9 (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL REAL_CONTINUOUS_CONTINUOUS1)))(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (move ["p2fij"]) THEN (move ["p2gij"]))); ((use_arg_then "real_cont_at_local") (thm_tac apply_tac)); ((((use_arg_then "d2g") (disch_tac [])) THEN (clear_assumption "d2g") THEN ((use_arg_then "d2f") (disch_tac [])) THEN (clear_assumption "d2f") THEN BETA_TAC) THEN ((((use_arg_then "diff2_eq_diff2_on_open")(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 ["d2f"]))); ((((use_arg_then "diff2_eq_diff2_on_open")(thm_tac (new_rewrite [] [])))) THEN ALL_TAC THEN (case THEN (move ["t"])) THEN (case THEN (move ["open_t"])) THEN (case THEN (move ["xt"])) THEN (move ["d2g"])); (((fun arg_tac -> arg_tac (Arg_term (`(\x. partial2 j i f x + partial2 j i g x)`))) (term_tac exists_tac)) THEN ((fun arg_tac -> arg_tac (Arg_term (`s INTER t`))) (term_tac exists_tac))); ((THENL_FIRST) ((repeat_tactic 1 9 (((use_arg_then "IN_INTER")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "xs")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "xt")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "OPEN_INTER")(thm_tac (new_rewrite [] [])))) THEN ((simp_tac THEN TRY done_tac)) THEN (((use_arg_then "REAL_CONTINUOUS_ADD")(thm_tac (new_rewrite [] [])))) THEN (simp_tac)) ((((use_arg_then "ETA_AX")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN (done_tac))); ((BETA_TAC THEN (move ["y"]) THEN (case THEN ((move ["ys"]) THEN (move ["yt"])))) THEN ((((use_arg_then "second_partial_add")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "d2f")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "d2g")(thm_tac (new_rewrite [] [])))))) THEN (done_tac)); ];; (* Lemma diff2c_sub *) let diff2c_sub = section_proof ["f";"g"] `diff2c f x ==> diff2c g x ==> diff2c (\x. f x - g x) x` [ ((BETA_TAC THEN (move ["d2f"]) THEN (move ["d2g"])) THEN ((((use_arg_then "real_sub")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "diff2c_add")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "diff2c_neg")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma diff2c_mul *) let diff2c_mul = section_proof ["f";"g"] `diff2c f x ==> diff2c g x ==> diff2c (\x. f x * g x) x` [ (((repeat_tactic 1 9 (((use_arg_then "diff2c")(thm_tac (new_rewrite [] []))))) THEN ALL_TAC THEN (case THEN ((move ["d2f"]) THEN (move ["p2f"]))) THEN (case THEN ((move ["d2g"]) THEN (move ["p2g"])))) THEN (((((use_arg_then "diff2_mul")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] []))))) THEN (move ["i"]) THEN (move ["j"]))); ((((fun arg_tac -> (fun arg_tac -> (use_arg_then "p2g") (fun fst_arg -> (use_arg_then "i") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "j") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN ((fun arg_tac -> (fun arg_tac -> (use_arg_then "p2f") (fun fst_arg -> (use_arg_then "i") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "j") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC) THEN ((repeat_tactic 1 9 (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL REAL_CONTINUOUS_CONTINUOUS1)))(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (move ["p2fij"]) THEN (move ["p2gij"]))); ((use_arg_then "real_cont_at_local") (thm_tac apply_tac)); ((((use_arg_then "d2g") (disch_tac [])) THEN (clear_assumption "d2g") THEN ((use_arg_then "d2f") (disch_tac [])) THEN (clear_assumption "d2f") THEN BETA_TAC) THEN ((((use_arg_then "diff2_eq_diff2_on_open")(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 ["d2f"]))); ((((use_arg_then "diff2_eq_diff2_on_open")(thm_tac (new_rewrite [] [])))) THEN ALL_TAC THEN (case THEN (move ["t"])) THEN (case THEN (move ["open_t"])) THEN (case THEN (move ["xt"])) THEN (move ["d2g"])); (((fun arg_tac -> arg_tac (Arg_term (`(\x. (partial2 j i f x * g x + partial i f x * partial j g x) + partial j f x * partial i g x + f x * partial2 j i g x)`))) (term_tac exists_tac)) THEN ((fun arg_tac -> arg_tac (Arg_term (`s INTER t`))) (term_tac exists_tac))); ((THENL_ROT (-1)) (((repeat_tactic 1 9 (((use_arg_then "IN_INTER")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "xs")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "xt")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "OPEN_INTER")(thm_tac (new_rewrite [] [])))) THEN ((simp_tac THEN TRY done_tac))) THEN (split_tac))); ((BETA_TAC THEN (move ["y"]) THEN (case THEN ((move ["ys"]) THEN (move ["yt"])))) THEN ((((use_arg_then "second_partial_mul")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "d2f")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "d2g")(thm_tac (new_rewrite [] [])))))) THEN (done_tac)); (((repeat_tactic 1 9 (((use_arg_then "REAL_CONTINUOUS_ADD")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (repeat_tactic 1 9 (((use_arg_then "REAL_CONTINUOUS_MUL")(thm_tac (new_rewrite [] [])))))) THEN ((((use_arg_then "ETA_AX")(fun arg -> ONCE_REWRITE_TAC[get_arg_thm arg]))) THEN ((TRY done_tac))) THEN ((repeat_tactic 0 10 (((use_arg_then "p2gij")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "p2fij")(thm_tac (new_rewrite [] []))))) THEN (simp_tac) THEN (repeat_tactic 0 10 (((use_arg_then "diff2_imp_partial_cont")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "diff2_imp_cont")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "d2f")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "d2g")(thm_tac (new_rewrite [] [])))))) THEN (done_tac)); ];; (* Finalization of the section Point *) let diff2c_scale = finalize_theorem diff2c_scale;; let diff2c_neg = finalize_theorem diff2c_neg;; let nth_diff_strong_eq_on_open = finalize_theorem nth_diff_strong_eq_on_open;; let diff2_imp_cont = finalize_theorem diff2_imp_cont;; let diff2_imp_partial_cont = finalize_theorem diff2_imp_partial_cont;; let diff2c_uni_compose = finalize_theorem diff2c_uni_compose;; let real_open_delete = finalize_theorem real_open_delete;; let diff2c_inv_compose = finalize_theorem diff2c_inv_compose;; let diff2c_sqrt_compose = finalize_theorem diff2c_sqrt_compose;; let diff2c_atn_compose = finalize_theorem diff2c_atn_compose;; let diff2c_acs_compose = finalize_theorem diff2c_acs_compose;; let diff2c_add = finalize_theorem diff2c_add;; let diff2c_sub = finalize_theorem diff2c_sub;; let diff2c_mul = finalize_theorem diff2c_mul;; end_section "Point";; (* Section Domain *) begin_section "Domain";; (add_section_var (mk_var ("f", (`:real^N -> real`))); add_section_var (mk_var ("g", (`:real^N -> real`))));; (add_section_hyp "d2f" (`diff2c_domain domain f`));; (* Lemma diff2c_domain_scale *) let diff2c_domain_scale = section_proof ["c"] `diff2c_domain domain (\x. c * f x)` [ ((((use_arg_then "d2f") (disch_tac [])) THEN (clear_assumption "d2f") THEN BETA_TAC) THEN ((repeat_tactic 1 9 (((use_arg_then "diff2c_domain")(thm_tac (new_rewrite [] []))))) THEN (move ["d2f"]) THEN (move ["x"]) THEN (move ["x_in"])) THEN ((((use_arg_then "diff2c_scale")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "d2f")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma diff2c_domain_neg *) let diff2c_domain_neg = section_proof [] `diff2c_domain domain (\x. --f x)` [ ((((use_arg_then "d2f") (disch_tac [])) THEN (clear_assumption "d2f") THEN BETA_TAC) THEN ((repeat_tactic 1 9 (((use_arg_then "diff2c_domain")(thm_tac (new_rewrite [] []))))) THEN (move ["d2f"]) THEN (move ["x"]) THEN (move ["x_in"])) THEN ((((use_arg_then "diff2c_neg")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "d2f")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (add_section_var (mk_var ("bounds", (`:real#real`))));; (* Lemma diff2c_domain_inv_compose *) let diff2c_domain_inv_compose = section_proof [] `m_bounded_on_int f domain bounds ==> interval_not_zero bounds ==> diff2c_domain domain (inv o f)` [ ((((use_arg_then "d2f") (disch_tac [])) THEN (clear_assumption "d2f") THEN BETA_TAC) THEN (((((use_arg_then "m_bounded_on_int")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "diff2c_domain")(thm_tac (new_rewrite [] [])))))) THEN (move ["d2f"]) THEN (move ["ineq"]) THEN (move ["n0"]) THEN (move ["x"]) THEN (move ["x_in"]))); (((((use_arg_then "diff2c_inv_compose")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "d2f")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "andbT")(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> (use_arg_then "interval_arith_not_zero") (fun fst_arg -> (fun arg_tac -> (use_arg_then "ineq") (fun fst_arg -> (use_arg_then "x_in") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma diff2c_domain_sqrt_compose *) let diff2c_domain_sqrt_compose = section_proof [] `m_bounded_on_int f domain bounds ==> interval_pos bounds ==> diff2c_domain domain (sqrt o f)` [ ((((use_arg_then "d2f") (disch_tac [])) THEN (clear_assumption "d2f") THEN BETA_TAC) THEN (((((use_arg_then "m_bounded_on_int")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "diff2c_domain")(thm_tac (new_rewrite [] [])))))) THEN (move ["d2f"]) THEN (move ["ineq"]) THEN (move ["n0"]) THEN (move ["x"]) THEN (move ["x_in"]))); (((((use_arg_then "diff2c_sqrt_compose")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "d2f")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "andbT")(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> (use_arg_then "interval_arith_pos") (fun fst_arg -> (fun arg_tac -> (use_arg_then "ineq") (fun fst_arg -> (use_arg_then "x_in") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma diff2c_domain_atn_compose *) let diff2c_domain_atn_compose = section_proof [] `diff2c_domain domain (atn o f)` [ ((((use_arg_then "d2f") (disch_tac [])) THEN (clear_assumption "d2f") THEN BETA_TAC) THEN ((repeat_tactic 1 9 (((use_arg_then "diff2c_domain")(thm_tac (new_rewrite [] []))))) THEN (move ["d2f"]) THEN (move ["x"]) THEN (move ["x_in"])) THEN ((((use_arg_then "diff2c_atn_compose")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "d2f")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma diff2c_domain_acs_compose *) let diff2c_domain_acs_compose = section_proof [] `m_bounded_on_int f domain bounds ==> iabs bounds < &1 ==> diff2c_domain domain (acs o f)` [ ((((use_arg_then "d2f") (disch_tac [])) THEN (clear_assumption "d2f") THEN BETA_TAC) THEN (((((use_arg_then "m_bounded_on_int")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "diff2c_domain")(thm_tac (new_rewrite [] [])))))) THEN (move ["d2f"]) THEN (move ["ineq"]) THEN (move ["n0"]) THEN (move ["x"]) THEN (move ["x_in"]))); (((((use_arg_then "diff2c_acs_compose")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "d2f")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "andbT")(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> (use_arg_then "interval_arith_abs") (fun fst_arg -> (fun arg_tac -> (use_arg_then "ineq") (fun fst_arg -> (use_arg_then "x_in") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (add_section_hyp "d2g" (`diff2c_domain domain g`));; (* Lemma diff2c_domain_add *) let diff2c_domain_add = section_proof [] `diff2c_domain domain (\x. f x + g x)` [ ((((use_arg_then "d2g") (disch_tac [])) THEN (clear_assumption "d2g") THEN ((use_arg_then "d2f") (disch_tac [])) THEN (clear_assumption "d2f") THEN BETA_TAC) THEN ((repeat_tactic 1 9 (((use_arg_then "diff2c_domain")(thm_tac (new_rewrite [] []))))) THEN (move ["d2f"]) THEN (move ["d2g"]) THEN (move ["x"]) THEN (move ["x_in"])) THEN ((((use_arg_then "diff2c_add")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "d2f")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "d2g")(thm_tac (new_rewrite [] [])))))) THEN (done_tac)); ];; (* Lemma diff2c_domain_sub *) let diff2c_domain_sub = section_proof [] `diff2c_domain domain (\x. f x - g x)` [ ((((use_arg_then "d2g") (disch_tac [])) THEN (clear_assumption "d2g") THEN ((use_arg_then "d2f") (disch_tac [])) THEN (clear_assumption "d2f") THEN BETA_TAC) THEN ((repeat_tactic 1 9 (((use_arg_then "diff2c_domain")(thm_tac (new_rewrite [] []))))) THEN (move ["d2f"]) THEN (move ["d2g"]) THEN (move ["x"]) THEN (move ["x_in"])) THEN ((((use_arg_then "diff2c_sub")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "d2f")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "d2g")(thm_tac (new_rewrite [] [])))))) THEN (done_tac)); ];; (* Lemma diff2c_domain_mul *) let diff2c_domain_mul = section_proof [] `diff2c_domain domain (\x. f x * g x)` [ ((((use_arg_then "d2g") (disch_tac [])) THEN (clear_assumption "d2g") THEN ((use_arg_then "d2f") (disch_tac [])) THEN (clear_assumption "d2f") THEN BETA_TAC) THEN ((repeat_tactic 1 9 (((use_arg_then "diff2c_domain")(thm_tac (new_rewrite [] []))))) THEN (move ["d2f"]) THEN (move ["d2g"]) THEN (move ["x"]) THEN (move ["x_in"])) THEN ((((use_arg_then "diff2c_mul")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "d2f")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "d2g")(thm_tac (new_rewrite [] [])))))) THEN (done_tac)); ];; (* Finalization of the section Domain *) let diff2c_domain_scale = finalize_theorem diff2c_domain_scale;; let diff2c_domain_neg = finalize_theorem diff2c_domain_neg;; let diff2c_domain_inv_compose = finalize_theorem diff2c_domain_inv_compose;; let diff2c_domain_sqrt_compose = finalize_theorem diff2c_domain_sqrt_compose;; let diff2c_domain_atn_compose = finalize_theorem diff2c_domain_atn_compose;; let diff2c_domain_acs_compose = finalize_theorem diff2c_domain_acs_compose;; let diff2c_domain_add = finalize_theorem diff2c_domain_add;; let diff2c_domain_sub = finalize_theorem diff2c_domain_sub;; let diff2c_domain_mul = finalize_theorem diff2c_domain_mul;; end_section "Domain";; (* Finalization of the section Diff2c *) let real_cont_at_local = finalize_theorem real_cont_at_local;; let real_cont_atreal_local = finalize_theorem real_cont_atreal_local;; let diff2c_scale = finalize_theorem diff2c_scale;; let diff2c_neg = finalize_theorem diff2c_neg;; let nth_diff_strong_eq_on_open = finalize_theorem nth_diff_strong_eq_on_open;; let diff2_imp_cont = finalize_theorem diff2_imp_cont;; let diff2_imp_partial_cont = finalize_theorem diff2_imp_partial_cont;; let diff2c_uni_compose = finalize_theorem diff2c_uni_compose;; let real_open_delete = finalize_theorem real_open_delete;; let diff2c_inv_compose = finalize_theorem diff2c_inv_compose;; let diff2c_sqrt_compose = finalize_theorem diff2c_sqrt_compose;; let diff2c_atn_compose = finalize_theorem diff2c_atn_compose;; let diff2c_acs_compose = finalize_theorem diff2c_acs_compose;; let diff2c_add = finalize_theorem diff2c_add;; let diff2c_sub = finalize_theorem diff2c_sub;; let diff2c_mul = finalize_theorem diff2c_mul;; let diff2c_domain_scale = finalize_theorem diff2c_domain_scale;; let diff2c_domain_neg = finalize_theorem diff2c_domain_neg;; let diff2c_domain_inv_compose = finalize_theorem diff2c_domain_inv_compose;; let diff2c_domain_sqrt_compose = finalize_theorem diff2c_domain_sqrt_compose;; let diff2c_domain_atn_compose = finalize_theorem diff2c_domain_atn_compose;; let diff2c_domain_acs_compose = finalize_theorem diff2c_domain_acs_compose;; let diff2c_domain_add = finalize_theorem diff2c_domain_add;; let diff2c_domain_sub = finalize_theorem diff2c_domain_sub;; let diff2c_domain_mul = finalize_theorem diff2c_domain_mul;; end_section "Diff2c";; (* Section M_LinApprox *) begin_section "M_LinApprox";; (add_section_var (mk_var ("f", (`:real^N -> real`))); add_section_var (mk_var ("g", (`:real^N -> real`))));; (add_section_var (mk_var ("bounds", (`:real#real`))));; (add_section_var (mk_var ("d_bounds_list", (`:(real#real)list`))));; (add_section_var (mk_var ("x", (`:real^N`))));; (* Lemma m_lin_approx_neg *) let m_lin_approx_neg = section_proof [] `(lift o f) differentiable at x ==> interval_arith (--f x) bounds ==> all_n 1 d_bounds_list (\i int. interval_arith (--partial i f x) int) ==> m_lin_approx (\x. --f x) x bounds d_bounds_list` [ (BETA_TAC THEN (move ["df"]) THEN (move ["b"]) THEN (move ["db"])); ((THENL_FIRST) ((((use_arg_then "m_lin_approx")(thm_tac (new_rewrite [] [])))) THEN (simp_tac) THEN (((use_arg_then "b")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "f_lift_neg")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "DIFFERENTIABLE_NEG")(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 (done_tac))); ((ASM_SIMP_TAC[partial_neg]) THEN (done_tac)); ];; (* Lemma m_lin_approx_scale *) let m_lin_approx_scale = section_proof ["c"] `(lift o f) differentiable at x ==> interval_arith (c * f x) bounds ==> all_n 1 d_bounds_list (\i int. interval_arith (c * partial i f x) int) ==> m_lin_approx (\x. c * f x) x bounds d_bounds_list` [ (BETA_TAC THEN (move ["df"]) THEN (move ["bH"]) THEN (move ["dbH"])); ((THENL_FIRST) ((((use_arg_then "m_lin_approx")(thm_tac (new_rewrite [] [])))) THEN (simp_tac) THEN (((use_arg_then "bH")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "f_lift_scale")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "DIFFERENTIABLE_CMUL")(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 (done_tac))); ((ASM_SIMP_TAC[partial_scale]) THEN (done_tac)); ];; (* Lemma m_lin_approx_add *) let m_lin_approx_add = section_proof [] `(lift o f) differentiable at x ==> (lift o g) differentiable at x ==> interval_arith (f x + g x) bounds ==> all_n 1 d_bounds_list (\i int. interval_arith (partial i f x + partial i g x) int) ==> m_lin_approx (\x. f x + g x) x bounds d_bounds_list` [ (BETA_TAC THEN (move ["df"]) THEN (move ["dg"]) THEN (move ["bH"]) THEN (move ["dbH"])); ((THENL_FIRST) ((((use_arg_then "m_lin_approx")(thm_tac (new_rewrite [] [])))) THEN (simp_tac) THEN (((use_arg_then "bH")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "f_lift_add")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "DIFFERENTIABLE_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 (done_tac))); ((ASM_SIMP_TAC[partial_add]) THEN (done_tac)); ];; (* Lemma m_lin_approx_sub *) let m_lin_approx_sub = section_proof [] `(lift o f) differentiable at x ==> (lift o g) differentiable at x ==> interval_arith (f x - g x) bounds ==> all_n 1 d_bounds_list (\i int. interval_arith (partial i f x - partial i g x) int) ==> m_lin_approx (\x. f x - g x) x bounds d_bounds_list` [ (BETA_TAC THEN (move ["df"]) THEN (move ["dg"]) THEN (move ["bH"]) THEN (move ["dbH"])); ((THENL_FIRST) ((((use_arg_then "m_lin_approx")(thm_tac (new_rewrite [] [])))) THEN (simp_tac) THEN (((use_arg_then "bH")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "f_lift_sub")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "DIFFERENTIABLE_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 (done_tac))); ((ASM_SIMP_TAC[partial_sub]) THEN (done_tac)); ];; (* Lemma m_lin_approx_mul *) let m_lin_approx_mul = section_proof [] `(lift o f) differentiable at x ==> (lift o g) differentiable at x ==> interval_arith (f x * g x) bounds ==> all_n 1 d_bounds_list (\i int. interval_arith (partial i f x * g x + f x * partial i g x) int) ==> m_lin_approx (\x. f x * g x) x bounds d_bounds_list` [ (BETA_TAC THEN (move ["df"]) THEN (move ["dg"]) THEN (move ["bH"]) THEN (move ["dbH"])); ((((use_arg_then "m_lin_approx")(thm_tac (new_rewrite [] [])))) THEN (simp_tac) THEN (((use_arg_then "bH")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "differentiable_mul")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (repeat_tactic 1 9 (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))))); ((ASM_SIMP_TAC[partial_mul]) THEN (done_tac)); ];; (* Finalization of the section M_LinApprox *) let m_lin_approx_neg = finalize_theorem m_lin_approx_neg;; let m_lin_approx_scale = finalize_theorem m_lin_approx_scale;; let m_lin_approx_add = finalize_theorem m_lin_approx_add;; let m_lin_approx_sub = finalize_theorem m_lin_approx_sub;; let m_lin_approx_mul = finalize_theorem m_lin_approx_mul;; end_section "M_LinApprox";;
let second_bounded = new_definition `second_bounded f domain dd_bounds_list <=>
	!x. x IN interval [domain] ==> all_n 1 dd_bounds_list
		(\i list_i. all_n 1 list_i (\j int. interval_arith (partial2 j i f x) int))`;;
let m_taylor_interval = 
	new_definition `m_taylor_interval f domain y w f_bounds d_bounds_list dd_bounds_list <=>
		m_cell_domain domain y w /\
		diff2c_domain domain f /\
		m_lin_approx f y f_bounds d_bounds_list /\
		second_bounded f domain dd_bounds_list`;;
(* Section M_TaylorIntervalArith *) begin_section "M_TaylorIntervalArith";; (add_section_var (mk_var ("f", (`:real^N -> real`))); add_section_var (mk_var ("g", (`:real^N -> real`))));; (add_section_var (mk_var ("x", (`:real^N`))); add_section_var (mk_var ("z", (`:real^N`))); add_section_var (mk_var ("y", (`:real^N`))); add_section_var (mk_var ("w", (`:real^N`))));; (add_section_var (mk_var ("domain", (`:real^N#real^N`))));; (add_section_var (mk_var ("f_bounds", (`:real#real`))); add_section_var (mk_var ("g_bounds", (`:real#real`))); add_section_var (mk_var ("bounds", (`:real#real`))));; (add_section_var (mk_var ("df_bounds_list", (`:(real#real)list`))); add_section_var (mk_var ("dg_bounds_list", (`:(real#real)list`))); add_section_var (mk_var ("d_bounds_list", (`:(real#real)list`))));; (add_section_var (mk_var ("ddf_bounds_list", (`:((real#real)list)list`))); add_section_var (mk_var ("ddg_bounds_list", (`:((real#real)list)list`))); add_section_var (mk_var ("dd_bounds_list", (`:((real#real)list)list`))));; (add_section_hyp "domainH" (`m_cell_domain domain y w`));; (add_section_hyp "d2f" (`diff2c_domain domain f`));; (* Lemma m_taylor_inv_compose *) let m_taylor_inv_compose = section_proof [] `m_bounded_on_int f domain f_bounds ==> interval_not_zero f_bounds ==> m_lin_approx (inv o f) y bounds d_bounds_list ==> second_bounded (inv o f) domain dd_bounds_list ==> m_taylor_interval (inv o f) domain y w bounds d_bounds_list dd_bounds_list` [ ((BETA_TAC THEN (move ["bf"]) THEN (move ["fn0"]) THEN (move ["lin"]) THEN (move ["second"])) THEN (((use_arg_then "m_taylor_interval")(thm_tac (new_rewrite [] []))))); ((((fun arg_tac -> (fun arg_tac -> (use_arg_then "diff2c_domain_inv_compose") (fun fst_arg -> (use_arg_then "d2f") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "bf") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [])))) THEN (done_tac)); ];; (* Lemma m_taylor_sqrt_compose *) let m_taylor_sqrt_compose = section_proof [] `m_bounded_on_int f domain f_bounds ==> interval_pos f_bounds ==> m_lin_approx (sqrt o f) y bounds d_bounds_list ==> second_bounded (sqrt o f) domain dd_bounds_list ==> m_taylor_interval (sqrt o f) domain y w bounds d_bounds_list dd_bounds_list` [ ((BETA_TAC THEN (move ["bf"]) THEN (move ["fn0"]) THEN (move ["lin"]) THEN (move ["second"])) THEN (((use_arg_then "m_taylor_interval")(thm_tac (new_rewrite [] []))))); ((((fun arg_tac -> (fun arg_tac -> (use_arg_then "diff2c_domain_sqrt_compose") (fun fst_arg -> (use_arg_then "d2f") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "bf") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [])))) THEN (done_tac)); ];; (* Lemma m_taylor_atn_compose *) let m_taylor_atn_compose = section_proof [] `m_lin_approx (atn o f) y bounds d_bounds_list ==> second_bounded (atn o f) domain dd_bounds_list ==> m_taylor_interval (atn o f) domain y w bounds d_bounds_list dd_bounds_list` [ ((BETA_TAC THEN (move ["lin"]) THEN (move ["second"])) THEN ((((use_arg_then "m_taylor_interval")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "diff2c_domain_atn_compose")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma m_taylor_acs_compose *) let m_taylor_acs_compose = section_proof [] `m_bounded_on_int f domain f_bounds ==> iabs f_bounds < &1 ==> m_lin_approx (acs o f) y bounds d_bounds_list ==> second_bounded (acs o f) domain dd_bounds_list ==> m_taylor_interval (acs o f) domain y w bounds d_bounds_list dd_bounds_list` [ ((BETA_TAC THEN (move ["bf"]) THEN (move ["fn0"]) THEN (move ["lin"]) THEN (move ["second"])) THEN (((use_arg_then "m_taylor_interval")(thm_tac (new_rewrite [] []))))); ((((fun arg_tac -> (fun arg_tac -> (use_arg_then "diff2c_domain_acs_compose") (fun fst_arg -> (use_arg_then "d2f") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "bf") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg)))(thm_tac (new_rewrite [] [])))) THEN (done_tac)); ];; (* Lemma m_taylor_neg *) let m_taylor_neg = section_proof [] `m_lin_approx (\x. --f x) y bounds d_bounds_list ==> second_bounded (\x. --f x) domain dd_bounds_list ==> m_taylor_interval (\x. --f x) domain y w bounds d_bounds_list dd_bounds_list` [ ((BETA_TAC THEN (move ["lin"]) THEN (move ["second"])) THEN ((((use_arg_then "m_taylor_interval")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "diff2c_domain_neg")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma m_taylor_scale *) let m_taylor_scale = section_proof ["c"] `m_lin_approx (\x. c * f x) y bounds d_bounds_list ==> second_bounded (\x. c * f x) domain dd_bounds_list ==> m_taylor_interval (\x. c * f x) domain y w bounds d_bounds_list dd_bounds_list` [ ((BETA_TAC THEN (move ["lin"]) THEN (move ["second"])) THEN ((((use_arg_then "m_taylor_interval")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "diff2c_domain_scale")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (add_section_hyp "d2g" (`diff2c_domain domain g`));; (* Lemma m_taylor_add *) let m_taylor_add = section_proof [] `m_lin_approx (\x. f x + g x) y bounds d_bounds_list ==> second_bounded (\x. f x + g x) domain dd_bounds_list ==> m_taylor_interval (\x. f x + g x) domain y w bounds d_bounds_list dd_bounds_list` [ ((BETA_TAC THEN (move ["lin"]) THEN (move ["second"])) THEN ((((use_arg_then "m_taylor_interval")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "diff2c_domain_add")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma m_taylor_sub *) let m_taylor_sub = section_proof [] `m_lin_approx (\x. f x - g x) y bounds d_bounds_list ==> second_bounded (\x. f x - g x) domain dd_bounds_list ==> m_taylor_interval (\x. f x - g x) domain y w bounds d_bounds_list dd_bounds_list` [ ((BETA_TAC THEN (move ["lin"]) THEN (move ["second"])) THEN ((((use_arg_then "m_taylor_interval")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "diff2c_domain_sub")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma m_taylor_mul *) let m_taylor_mul = section_proof [] `m_lin_approx (\x. f x * g x) y bounds d_bounds_list ==> second_bounded (\x. f x * g x) domain dd_bounds_list ==> m_taylor_interval (\x. f x * g x) domain y w bounds d_bounds_list dd_bounds_list` [ ((BETA_TAC THEN (move ["lin"]) THEN (move ["second"])) THEN ((((use_arg_then "m_taylor_interval")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "diff2c_domain_mul")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Finalization of the section M_TaylorIntervalArith *) let m_taylor_inv_compose = finalize_theorem m_taylor_inv_compose;; let m_taylor_sqrt_compose = finalize_theorem m_taylor_sqrt_compose;; let m_taylor_atn_compose = finalize_theorem m_taylor_atn_compose;; let m_taylor_acs_compose = finalize_theorem m_taylor_acs_compose;; let m_taylor_neg = finalize_theorem m_taylor_neg;; let m_taylor_scale = finalize_theorem m_taylor_scale;; let m_taylor_add = finalize_theorem m_taylor_add;; let m_taylor_sub = finalize_theorem m_taylor_sub;; let m_taylor_mul = finalize_theorem m_taylor_mul;; end_section "M_TaylorIntervalArith";; (* Section PartialConvex *) begin_section "PartialConvex";; (add_section_type (mk_var ("f", (`:real^N->real`))));; (* Lemma REAL_LE_DIV_1 *) let REAL_LE_DIV_1 = section_proof ["a";"b"] `&0 < b ==> (a / b <= &1 <=> a <= b)` [ ((BETA_TAC THEN (move ["b_gt"])) THEN ((((use_arg_then "REAL_LE_LDIV_EQ")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "REAL_MUL_LID")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma partial_convex_max *) let partial_convex_max = section_proof ["f";"j";"x";"z";"u";"v";"hi"] `(!i. i IN 1..dimindex (:N) ==> ~(i = j) ==> u$i = z$i /\ v$i = x$i) ==> u$j = x$j ==> v$j = z$j ==> diff2_domain (x,z) f ==> (!y. y IN interval [x,z] ==> &0 <= partial2 j j f y) ==> (!y. y IN interval [x,u] ==> f y <= hi) ==> (!y. y IN interval [v,z] ==> f y <= hi) ==> (!y. y IN interval [x,z] ==> f y <= hi)` [ ((((use_arg_then "IN_NUMSEG")(thm_tac (new_rewrite [] [])))) THEN (move ["uv_eq"]) THEN (move ["ux_eq"]) THEN (move ["vz_eq"])); ((((use_arg_then "diff2_domain")(thm_tac (new_rewrite [] [])))) THEN (move ["diff2_f"]) THEN (move ["partial2_pos"]) THEN (move ["bound1"]) THEN (move ["bound2"]) THEN (move ["y"]) THEN (move ["y_in"])); ((fun arg_tac -> arg_tac (Arg_term (`(lambda i. if i = j then x$j else y$i):real^N`))) (term_tac (set_tac "y1"))); ((fun arg_tac -> arg_tac (Arg_term (`(lambda i. if i = j then z$j else y$i):real^N`))) (term_tac (set_tac "y2"))); ((((use_arg_then "y_in") (disch_tac [])) THEN (clear_assumption "y_in") THEN BETA_TAC) THEN ((((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL IN_INTERVAL)))(thm_tac (new_rewrite [] [])))) THEN (move ["y_in"]))); ((fun arg_tac -> arg_tac (Arg_term (`y1 IN interval [x,u] /\ y2 IN interval [v,z]`))) (term_tac (have_gen_tac [](case THEN ((move ["y1_in"]) THEN (move ["y2_in"])))))); ((((use_arg_then "y1_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "y2_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL IN_INTERVAL)))(thm_tac (new_rewrite [] [])))))); (((split_tac) THEN (move ["i"]) THEN (move ["i_ineq"])) THEN ((((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL LAMBDA_BETA)))(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac))) THEN (((fun arg_tac -> (use_arg_then "EXCLUDED_MIDDLE") (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`i = j`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN case THEN (simp_tac) THEN (move ["ij"])) THEN ((repeat_tactic 0 10 (((fun arg_tac ->(use_arg_then "ux_eq")(fun tmp_arg1 -> (use_arg_then "vz_eq")(fun tmp_arg2 -> arg_tac (Arg_theorem (CONJ (get_arg_thm tmp_arg1) (get_arg_thm tmp_arg2))))))(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "REAL_LE_REFL")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac))) THEN ((((use_arg_then "uv_eq")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (repeat_tactic 1 9 (((use_arg_then "y_in")(thm_tac (new_rewrite [] [])))))) THEN (done_tac)); (((THENL_ROT (-1)) (((fun arg_tac -> (use_arg_then "EXCLUDED_MIDDLE") (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`j IN 1..dimindex (:N)`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN case)) THEN ((((use_arg_then "IN_NUMSEG")(thm_tac (new_rewrite [] [])))) THEN (move ["j_in"]))); ((THENL_FIRST) (((THENL_ROT 1)) ((fun arg_tac -> arg_tac (Arg_term (`y1 = y`))) (term_tac (have_gen_tac []ALL_TAC)))) ((BETA_TAC THEN (((conv_thm_tac DISCH_THEN)(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (((use_arg_then "bound1") (disch_tac [])) THEN (clear_assumption "bound1") THEN (DISCH_THEN apply_tac)) THEN (done_tac))); ((((use_arg_then "CART_EQ")(thm_tac (new_rewrite [] [])))) THEN (move ["i"]) THEN (move ["i_in"])); ((THENL_FIRST) ((fun arg_tac -> arg_tac (Arg_term (`~(i = j)`))) (term_tac (have_gen_tac [](move ["inj"])))) ((((use_arg_then "i_in") (disch_tac [])) THEN (clear_assumption "i_in") THEN ((use_arg_then "j_in") (disch_tac [])) THEN (clear_assumption "j_in") THEN BETA_TAC) THEN (arith_tac) THEN (done_tac))); (((((use_arg_then "y1_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL LAMBDA_BETA)))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); (((THENL_ROT 1)) ((fun arg_tac -> arg_tac (Arg_term (`f y <= max (f y1) (f y2)`))) (term_tac (have_gen_tac []ALL_TAC)))); (BETA_TAC THEN (move ["cond"])); (((fun arg_tac -> (fun arg_tac -> arg_tac (Arg_theorem (REWRITE_RULE[GSYM IMP_IMP] REAL_LE_TRANS))) (fun fst_arg -> (use_arg_then "cond") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN (DISCH_THEN apply_tac)); ((((fun arg_tac -> (use_arg_then "bound2") (fun fst_arg -> (use_arg_then "y2_in") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN ((fun arg_tac -> (use_arg_then "bound1") (fun fst_arg -> (use_arg_then "y1_in") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC) THEN (arith_tac) THEN (done_tac)); ((fun arg_tac -> arg_tac (Arg_term (`f o (\t. y1 + t % basis j)`))) (term_tac (set_tac "g"))); ((fun arg_tac -> arg_tac (Arg_term (`f y1 = g (&0)`))) (term_tac (have_gen_tac [](((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))))); (((((use_arg_then "g_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "o_THM")(thm_tac (new_rewrite [] [])))) THEN (simp_tac) THEN (((use_arg_then "VECTOR_MUL_LZERO")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "VECTOR_ADD_RID")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ((fun arg_tac -> arg_tac (Arg_term (`y = y1 + (y$j - x$j) % basis j /\ y2 = y1 + (z$j - x$j) % basis j`))) (term_tac (have_gen_tac [](move ["y_eq"])))); ((repeat_tactic 1 9 (((use_arg_then "CART_EQ")(thm_tac (new_rewrite [] []))))) THEN ((split_tac) THEN (move ["i"]) THEN (move ["i_in"])) THEN ((((use_arg_then "VECTOR_ADD_COMPONENT")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "VECTOR_MUL_COMPONENT")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "BASIS_COMPONENT")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac))) THEN (((fun arg_tac -> (use_arg_then "EXCLUDED_MIDDLE") (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`i = j`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN case THEN (simp_tac) THEN (move ["ij"])) THEN ((repeat_tactic 0 10 (((fun arg_tac ->(use_arg_then "y1_def")(fun tmp_arg1 -> (use_arg_then "y2_def")(fun tmp_arg2 -> arg_tac (Arg_theorem (CONJ (get_arg_thm tmp_arg1) (get_arg_thm tmp_arg2))))))(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (repeat_tactic 1 9 (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL LAMBDA_BETA)))(thm_tac (new_rewrite [] []))))) THEN ((simp_tac THEN TRY done_tac)) THEN (repeat_tactic 0 10 (((use_arg_then "REAL_MUL_RID")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "REAL_SUB_ADD2")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)))); (((((use_arg_then "ij")(thm_tac (new_rewrite [] [])))) THEN (simp_tac)) THEN (arith_tac) THEN (done_tac)); (((((use_arg_then "ij")(thm_tac (new_rewrite [] [])))) THEN (simp_tac)) THEN (arith_tac) THEN (done_tac)); ((THENL_FIRST) ((fun arg_tac -> arg_tac (Arg_term (`f y = g (y$j - x$j)`))) (term_tac (have_gen_tac [](((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))))) (((((use_arg_then "g_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "o_THM")(thm_tac (new_rewrite [] [])))) THEN (simp_tac) THEN (((use_arg_then "y_eq")(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (done_tac))); ((THENL_FIRST) ((fun arg_tac -> arg_tac (Arg_term (`f y2 = g (z$j - x$j)`))) (term_tac (have_gen_tac [](((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))))) (((((use_arg_then "g_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "o_THM")(thm_tac (new_rewrite [] [])))) THEN (simp_tac) THEN (((use_arg_then "y_eq")(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (done_tac))); (((fun arg_tac -> (use_arg_then "EXCLUDED_MIDDLE") (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`z$j = x$j`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN case THEN (move ["zx_j"])); ((THENL_FIRST) (((THENL_ROT 1)) ((fun arg_tac -> arg_tac (Arg_term (`y$j = x$j`))) (term_tac (have_gen_tac []ALL_TAC)))) ((BETA_TAC THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))) THEN ((((use_arg_then "zx_j")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_SUB_REFL")(thm_tac (new_rewrite [] []))))) THEN (arith_tac) THEN (done_tac))); ((((fun arg_tac -> (use_arg_then "y_in") (fun fst_arg -> (use_arg_then "j_in") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC) THEN (((use_arg_then "zx_j")(thm_tac (new_rewrite [] [])))) THEN (arith_tac) THEN (done_tac)); ((fun arg_tac -> arg_tac (Arg_term (`(y$j - x$j) / (z$j - x$j)`))) (term_tac (set_tac "t"))); ((fun arg_tac -> arg_tac (Arg_term (`&0 < z$j - x$j`))) (term_tac (have_gen_tac [](move ["zx_pos"])))); ((((fun arg_tac -> arg_tac (Arg_theorem (REAL_ARITH `!a b. &0 < a - b <=> ~(a = b) /\ b <= a`)))(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "zx_j")(thm_tac (new_rewrite [] [])))) THEN (simp_tac)); ((((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 (`y$j`))) (term_tac exists_tac)) THEN (repeat_tactic 1 9 (((use_arg_then "y_in")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ((fun arg_tac -> arg_tac (Arg_term (`&0 <= t /\ t <= &1 /\ y$j - x$j = (&1 - t) * &0 + t * (z$j - x$j)`))) (term_tac (have_gen_tac [](move ["t_props"])))); ((((use_arg_then "t_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "REAL_LE_DIV_1")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "REAL_MUL_RZERO")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_ADD_LID")(thm_tac (new_rewrite [] []))))); ((((use_arg_then "real_div")(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL REAL_MUL_ASSOC)))(gsym_then (thm_tac (new_rewrite [] [])))))); ((((use_arg_then "REAL_MUL_LINV")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "REAL_SUB_0")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((use_arg_then "REAL_MUL_RID")(thm_tac (new_rewrite [] [])))) THEN (simp_tac)); ((repeat_tactic 1 9 (((use_arg_then "real_sub")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "REAL_LE_RADD")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "y_in")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "andbT")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "real_sub")(gsym_then (thm_tac (new_rewrite [] []))))))); ((THENL_FIRST) ((((use_arg_then "REAL_LE_MUL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_LE_INV")(thm_tac (new_rewrite [] []))))) ((((fun arg_tac -> arg_tac (Arg_theorem (REAL_ARITH `!a. &0 < a ==> &0 <= a`)))(thm_tac (new_rewrite [] [])))) THEN (done_tac))); (((((use_arg_then "REAL_SUB_LE")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "y_in")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ((((use_arg_then "t_props")(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL REAL_CONVEX_LOWER))) (disch_tac [])) THEN (DISCH_THEN apply_tac))); ((fun arg_tac -> arg_tac (Arg_term (`real_interval [&0, z$j - x$j]`))) (term_tac exists_tac)); ((((use_arg_then "REAL_SUB_ADD")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_SUB_LE")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "t_props")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "IN_REAL_INTERVAL")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "REAL_LE_REFL")(thm_tac (new_rewrite [] []))))) THEN (simp_tac)); ((((fun arg_tac -> arg_tac (Arg_theorem (REAL_ARITH `!a. &0 < a ==> &0 <= a`)))(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "andbT")(thm_tac (new_rewrite [] []))))); (((fun arg_tac -> arg_tac (Arg_term (`real_interval _`))) (term_tac (set_tac "s"))) THEN (((use_arg_then "t_props") (disch_tac [])) THEN (clear_assumption "t_props") THEN ((use_arg_then "t_def") (disch_tac [])) THEN (clear_assumption "t_def") THEN BETA_TAC THEN (move ["_"]) THEN (move ["_"]))); ((fun arg_tac -> arg_tac (Arg_term (`!t. t IN s ==> y1 + t % basis j IN interval [x,z]`))) (term_tac (have_gen_tac [](move ["in_s"])))); (((((use_arg_then "s_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "IN_REAL_INTERVAL")(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL IN_INTERVAL)))(thm_tac (new_rewrite [] []))))) THEN (move ["t"]) THEN (move ["t_ineq"]) THEN (move ["i"]) THEN (move ["i_ineq"])); ((repeat_tactic 1 9 (((use_arg_then "VECTOR_ADD_COMPONENT")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "VECTOR_MUL_COMPONENT")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "BASIS_COMPONENT")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac))); ((((use_arg_then "y1_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL LAMBDA_BETA)))(thm_tac (new_rewrite [] [])))) THEN ((simp_tac THEN TRY done_tac))); ((THENL_ROT (-1)) (((fun arg_tac -> (use_arg_then "EXCLUDED_MIDDLE") (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`i = j`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN case THEN (simp_tac) THEN (move ["ij"]))); (((((use_arg_then "REAL_MUL_RZERO")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_ADD_RID")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "y_in")(thm_tac (new_rewrite [] [])))))) THEN (done_tac)); ((((use_arg_then "t_ineq") (disch_tac [])) THEN (clear_assumption "t_ineq") THEN ((fun arg_tac -> (use_arg_then "y_in") (fun fst_arg -> (use_arg_then "i_ineq") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC) THEN (((use_arg_then "ij")(thm_tac (new_rewrite [] [])))) THEN (arith_tac) THEN (done_tac)); ((fun arg_tac -> arg_tac (Arg_term (`!t. t IN s ==> nth_diff_strong 2 g t`))) (term_tac (have_gen_tac [](move ["diff2_g"])))); ((BETA_TAC THEN (move ["t"]) THEN (move ["ts"])) THEN (((use_arg_then "g_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN ((((use_arg_then "diff2_dir")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "diff2_f")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "in_s")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ((fun arg_tac -> arg_tac (Arg_term (`!t. t IN s ==> derivative g t = partial j f (y1 + t % basis j)`))) (term_tac (have_gen_tac [](move ["dg"])))); ((BETA_TAC THEN (move ["t"]) THEN (move ["ts"])) THEN (((use_arg_then "partial")(thm_tac (new_rewrite [] []))))); ((((fun arg_tac -> (use_arg_then "in_s") (fun fst_arg -> (use_arg_then "ts") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC THEN (move ["p_in"])) THEN ((fun arg_tac -> arg_tac (Arg_term (`f o _`))) (term_tac (set_tac "h")))); ((fun arg_tac -> arg_tac (Arg_term (`h = g o (\t'. t + t')`))) (term_tac (have_gen_tac [](((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))))); ((((((use_arg_then "eq_ext")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "h_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "g_def")(gsym_then (thm_tac (new_rewrite [] [])))))) THEN (move ["r"])) THEN ((repeat_tactic 1 9 (((use_arg_then "o_THM")(thm_tac (new_rewrite [] []))))) THEN (simp_tac))); (((((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL VECTOR_ADD_RDISTRIB)))(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL VECTOR_ADD_ASSOC)))(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ((((use_arg_then "derivative_translation")(gsym_then (thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac))); ((((fun arg_tac -> (use_arg_then "diff2_g") (fun fst_arg -> (use_arg_then "ts") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC) THEN ((((use_arg_then "nth_diff_strong2_eq")(thm_tac (new_rewrite [] [])))) THEN ALL_TAC THEN (case THEN (move ["e"])) THEN (case THEN (move ["_"])) THEN (case THEN (move ["te"])) THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ((fun arg_tac -> arg_tac (Arg_term (`!t. t IN s ==> nth_derivative 2 g t = partial2 j j f (y1 + t % basis j)`))) (term_tac (have_gen_tac [](move ["d2g"])))); ((BETA_TAC THEN (move ["t"]) THEN (move ["ts"])) THEN ((((use_arg_then "g_def")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "diff2_dir_derivative2")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "diff2_f")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "in_s")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)))); ((fun arg_tac -> arg_tac (Arg_term (`1..dimindex (:N) = ((1..dimindex (:N)) DELETE j) UNION {j}`))) (term_tac (have_gen_tac [](move ["s_eq"])))); ((((((use_arg_then "EXTENSION")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "IN_UNION")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "IN_SING")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "IN_DELETE")(thm_tac (new_rewrite [] []))))) THEN (move ["i"])) THEN (split_tac)); ((BETA_TAC THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))) THEN ((((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "orNb")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ((case THEN (simp_tac)) THEN (((use_arg_then "IN_NUMSEG")(thm_tac (new_rewrite [] [])))) THEN (done_tac)); ((fun arg_tac -> arg_tac (Arg_term (`DISJOINT ((1..dimindex (:N)) DELETE j) {j}`))) (term_tac (have_gen_tac [](move ["disj"])))); (((((use_arg_then "DISJOINT")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "EXTENSION")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "IN_INTER")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "IN_SING")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "NOT_IN_EMPTY")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "IN_DELETE")(thm_tac (new_rewrite [] []))))) THEN (move ["i"])); (((((use_arg_then "andbA")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "andNb")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andbF")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ((((use_arg_then "s_eq")(thm_tac (new_rewrite [1] [])))) THEN (((use_arg_then "SUM_UNION")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "FINITE_DELETE")(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 "FINITE_SING")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((use_arg_then "SUM_SING")(thm_tac (new_rewrite [] [])))) THEN (simp_tac)); ((((use_arg_then "SUM_EQ_0")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "IN_DELETE")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "REAL_ADD_LID")(thm_tac (new_rewrite [] [])))))); ((BETA_TAC THEN (move ["i"]) THEN (move ["i_in"])) THEN (((use_arg_then "SUM_EQ_0") (thm_tac apply_tac)) THEN (move ["k"]) THEN (move ["k_in"]) THEN (simp_tac))); (((((use_arg_then "BASIS_COMPONENT")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "IN_NUMSEG")(gsym_then (thm_tac (new_rewrite [] [])))))) THEN ((TRY done_tac)) THEN (((use_arg_then "i_in")(thm_tac (new_rewrite [] [])))) THEN (simp_tac) THEN (((use_arg_then "REAL_MUL_LZERO")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ((((use_arg_then "s_eq")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "SUM_UNION")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "FINITE_DELETE")(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 "FINITE_SING")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac)) THEN (((use_arg_then "SUM_SING")(thm_tac (new_rewrite [] [])))) THEN (simp_tac)); ((((use_arg_then "SUM_EQ_0")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "IN_DELETE")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "REAL_ADD_LID")(thm_tac (new_rewrite [] [])))))); ((BETA_TAC THEN (move ["i"]) THEN (move ["i_in"]) THEN (simp_tac)) THEN (((use_arg_then "REAL_ENTIRE")(thm_tac (new_rewrite [] [])))) THEN (DISJ2_TAC)); (((((use_arg_then "BASIS_COMPONENT")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "IN_NUMSEG")(gsym_then (thm_tac (new_rewrite [] [])))))) THEN ((TRY done_tac)) THEN (((use_arg_then "i_in")(thm_tac (new_rewrite [] [])))) THEN (simp_tac) THEN (((use_arg_then "REAL_MUL_LZERO")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); (((((use_arg_then "BASIS_COMPONENT")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "j_in")(thm_tac (new_rewrite [] []))))) THEN ((simp_tac THEN TRY done_tac)) THEN (repeat_tactic 1 9 (((use_arg_then "REAL_MUL_LID")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "partial2")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "o_THM")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ((fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (fun arg_tac -> (use_arg_then "REAL_CONVEX_ON_SECOND_DERIVATIVE") (fun fst_arg -> (use_arg_then "g") (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 (`nth_derivative 2 g`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun fst_arg -> (use_arg_then "s") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (fun arg -> thm_tac MP_TAC arg THEN ALL_TAC)); ((THENL_ROT (-1)) (((((use_arg_then "s_def")(gsym_then (thm_tac (new_rewrite [1; 2] []))))) THEN (((use_arg_then "IS_REALINTERVAL_INTERVAL")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "NOT_EXISTS_THM")(thm_tac (new_rewrite [] []))))) THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] [])))))); ((BETA_TAC THEN (move ["t"]) THEN (move ["ts"])) THEN ((((use_arg_then "d2g")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "partial2_pos")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "in_s")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); (split_tac); ((BETA_TAC THEN (move ["t"])) THEN (((use_arg_then "contraT") (disch_tac [])) THEN (clear_assumption "contraT") THEN (DISCH_THEN apply_tac)) THEN (((((use_arg_then "negbK")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "EXTENSION")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "IN_SING")(thm_tac (new_rewrite [] []))))) THEN (move ["eq"]))); ((((use_arg_then "zx_pos") (disch_tac [])) THEN (clear_assumption "zx_pos") THEN ((fun arg_tac -> (use_arg_then "eq") (fun fst_arg -> (fun arg_tac -> arg_tac (Arg_term (`z$j - x$j`))) (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN ((fun arg_tac -> (use_arg_then "eq") (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 ((repeat_tactic 1 9 (((use_arg_then "IN_REAL_INTERVAL")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "REAL_LE_REFL")(thm_tac (new_rewrite [] []))))))); ((arith_tac) THEN (done_tac)); ((split_tac) THEN (move ["t"]) THEN (move ["ts"])); ((((fun arg_tac -> (use_arg_then "diff2_g") (fun fst_arg -> (use_arg_then "ts") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC) THEN ((((use_arg_then "nth_diff_strong2_eq_alt")(thm_tac (new_rewrite [] [])))) THEN ALL_TAC THEN (case THEN (move ["e"])) THEN (case THEN (move ["_"])) THEN (case THEN (move ["te"])) THEN (move ["H"]))); (((((use_arg_then "HAS_REAL_DERIVATIVE_ATREAL_WITHIN")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "H")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ((((fun arg_tac -> (use_arg_then "diff2_g") (fun fst_arg -> (use_arg_then "ts") (fun snd_arg -> combine_args_then arg_tac fst_arg snd_arg))) (disch_tac [])) THEN BETA_TAC) THEN ((((use_arg_then "nth_diff_strong2_eq_alt")(thm_tac (new_rewrite [] [])))) THEN ALL_TAC THEN (case THEN (move ["e"])) THEN (case THEN (move ["_"])) THEN (case THEN (move ["te"])) THEN (move ["H"]))); (((((use_arg_then "HAS_REAL_DERIVATIVE_ATREAL_WITHIN")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "H")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Finalization of the section PartialConvex *) let REAL_LE_DIV_1 = finalize_theorem REAL_LE_DIV_1;; let partial_convex_max = finalize_theorem partial_convex_max;; end_section "PartialConvex";; (* Section ElementaryFunctions *) begin_section "ElementaryFunctions";; (* Lemma f_lift_const *) let f_lift_const = section_proof ["c"] `lift o (\x. c) = (\x. lift c)` [ (((((use_arg_then "eq_ext")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "o_THM")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma f_lift_unary *) let f_lift_unary = section_proof ["f"] `lift o (\x. f x) = (\x. lift (f x))` [ (((((use_arg_then "eq_ext")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "o_THM")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma diff2_const *) let diff2_const = section_proof ["c";"x"] `diff2 (\x:real^N. c) x` [ ((((use_arg_then "diff2")(thm_tac (new_rewrite [] [])))) THEN ((fun arg_tac -> arg_tac (Arg_term (`(:real^N)`))) (term_tac exists_tac)) THEN (((((use_arg_then "OPEN_UNIV")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "IN_UNIV")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))))) THEN (move ["y"]) THEN (move ["_"]))); (((((use_arg_then "partial_const")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "f_lift_const")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 1 9 (((use_arg_then "DIFFERENTIABLE_CONST")(thm_tac (new_rewrite [] [])))))) THEN (done_tac)); ];; (* Lemma diff2_domain_const *) let diff2_domain_const = section_proof ["c";"domain"] `diff2_domain domain (\x:real^N. c)` [ (((((use_arg_then "diff2_domain")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "diff2_const")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma partial2_const *) let partial2_const = section_proof ["i";"j";"c"] `partial2 i j (\x:real^N. c) = (\x. &0)` [ (((((use_arg_then "partial2")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "partial_const")(thm_tac (new_rewrite [] [])))))) THEN (done_tac)); ];; (* Lemma diff2c_const *) let diff2c_const = section_proof ["c";"x"] `diff2c (\x:real^N. c) x` [ (((((use_arg_then "diff2c")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "diff2_const")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "partial2_const")(thm_tac (new_rewrite [] [])))) THEN (((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL REAL_CONTINUOUS_CONTINUOUS1)))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "REAL_CONTINUOUS_CONST")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma diff2c_domain_const *) let diff2c_domain_const = section_proof ["c";"domain"] `diff2c_domain domain (\x:real^N. c)` [ (((((use_arg_then "diff2c_domain")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "diff2c_const")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma partial_x_lemma *) let partial_x_lemma = section_proof ["k";"i"] `partial i (\x:real^N. x$k) = (\x. (basis i:real^N)$k)` [ (((((use_arg_then "eq_ext")(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "partial")(thm_tac (new_rewrite [] []))))) THEN (move ["x"]) THEN (simp_tac)); ((fun arg_tac -> arg_tac (Arg_term (`(\x. x$k) o (\t. x + t % basis i) = (\t. x$k + t * (basis i:real^N)$k)`))) (term_tac (have_gen_tac [](((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))))); (((((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 (((use_arg_then "VECTOR_ADD_COMPONENT")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "VECTOR_MUL_COMPONENT")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ((((use_arg_then "derivative_add")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((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))); (((((use_arg_then "REAL_DIFFERENTIABLE_ID")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_DIFFERENTIABLE_CONST")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ((((use_arg_then "derivative_const")(thm_tac (new_rewrite [] [])))) THEN (simp_tac) THEN (((use_arg_then "derivative_mul")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "REAL_DIFFERENTIABLE_ID")(thm_tac (new_rewrite [] []))))) THEN (repeat_tactic 0 10 (((use_arg_then "REAL_DIFFERENTIABLE_CONST")(thm_tac (new_rewrite [] []))))) THEN ((TRY done_tac))); (((((use_arg_then "derivative_x")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "derivative_const")(thm_tac (new_rewrite [] []))))) THEN (arith_tac) THEN (done_tac)); ];; (* Lemma partial_x *) let partial_x = section_proof ["k";"i"] `k IN 1..dimindex (:N) ==> partial i (\x:real^N. x$k) = (\x. if i = k then &1 else &0)` [ ((BETA_TAC THEN (move ["k_ineq"])) THEN ((((use_arg_then "partial_x_lemma")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "BASIS_COMPONENT")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 0 10 (((use_arg_then "IN_NUMSEG")(gsym_then (thm_tac (new_rewrite [] [])))))) THEN ((TRY done_tac))) THEN (arith_tac) THEN (done_tac)); ];; (* Lemma partial2_x *) let partial2_x = section_proof ["k";"i";"j"] `partial2 i j (\x:real^N. x$k) = (\x. &0)` [ (((((use_arg_then "partial2")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "partial_x_lemma")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "partial_const")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma diff2_x *) let diff2_x = section_proof ["k";"x"] `k IN 1..dimindex (:N) ==> diff2 (\x:real^N. x$k) x` [ ((BETA_TAC THEN (move ["k_ineq"])) THEN (((use_arg_then "diff2")(thm_tac (new_rewrite [] [])))) THEN ((fun arg_tac -> arg_tac (Arg_term (`(:real^N)`))) (term_tac exists_tac)) THEN (((((use_arg_then "OPEN_UNIV")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "IN_UNIV")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "andTb")(thm_tac (new_rewrite [] [])))))) THEN (move ["y"]) THEN (move ["_"]))); (((((use_arg_then "projection_diff")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)) THEN (((use_arg_then "partial_x_lemma")(thm_tac (new_rewrite [] [])))) THEN (repeat_tactic 1 9 (((use_arg_then "f_lift_unary")(thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "DIFFERENTIABLE_CONST")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma diff2_domain_x *) let diff2_domain_x = section_proof ["k";"domain"] `k IN 1..dimindex (:N) ==> diff2_domain domain (\x:real^N. x$k)` [ (((DISCH_THEN (fun snd_th -> (use_arg_then "diff2_x") (thm_tac (match_mp_then snd_th MP_TAC)))) THEN BETA_TAC) THEN ((((use_arg_then "diff2_domain")(thm_tac (new_rewrite [] [])))) THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma diff2c_x *) let diff2c_x = section_proof ["k";"x"] `k IN 1..dimindex (:N) ==> diff2c (\x:real^N. x$k) x` [ ((BETA_TAC THEN (move ["k_ineq"])) THEN ((((use_arg_then "diff2c")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "diff2_x")(thm_tac (new_rewrite [] [])))) THEN ((TRY done_tac)))); (((((fun arg_tac -> arg_tac (Arg_theorem (GEN_ALL REAL_CONTINUOUS_CONTINUOUS1)))(gsym_then (thm_tac (new_rewrite [] []))))) THEN (((use_arg_then "partial2_x")(thm_tac (new_rewrite [] [])))) THEN (((use_arg_then "REAL_CONTINUOUS_CONST")(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Lemma diff2c_domain_x *) let diff2c_domain_x = section_proof ["k";"domain"] `k IN 1..dimindex (:N) ==> diff2c_domain domain (\x:real^N. x$k)` [ (((DISCH_THEN (fun snd_th -> (use_arg_then "diff2c_x") (thm_tac (match_mp_then snd_th MP_TAC)))) THEN BETA_TAC) THEN ((((use_arg_then "diff2c_domain")(thm_tac (new_rewrite [] [])))) THEN (((conv_thm_tac DISCH_THEN)(thm_tac (new_rewrite [] []))))) THEN (done_tac)); ];; (* Finalization of the section ElementaryFunctions *) let f_lift_const = finalize_theorem f_lift_const;; let f_lift_unary = finalize_theorem f_lift_unary;; let diff2_const = finalize_theorem diff2_const;; let diff2_domain_const = finalize_theorem diff2_domain_const;; let partial2_const = finalize_theorem partial2_const;; let diff2c_const = finalize_theorem diff2c_const;; let diff2c_domain_const = finalize_theorem diff2c_domain_const;; let partial_x_lemma = finalize_theorem partial_x_lemma;; let partial_x = finalize_theorem partial_x;; let partial2_x = finalize_theorem partial2_x;; let diff2_x = finalize_theorem diff2_x;; let diff2_domain_x = finalize_theorem diff2_domain_x;; let diff2c_x = finalize_theorem diff2c_x;; let diff2c_domain_x = finalize_theorem diff2c_domain_x;; end_section "ElementaryFunctions";;