(* ========================================================================== *)
(* FLYSPECK - BOOK FORMALIZATION                                              *)
(* Section: Conclusions                                                       *)
(* Chapter: Local Fan                                                         *)
(* Lemma: OCBICBY                                                             *)
(* Author: Thomas C. Hales                                                    *)
(* Date: 2013-06-27                                                           *)
(* ========================================================================== *)



module Ocbicby = struct

  open Hales_tactic;;

let LET_THM = CONJ LET_DEF LET_END_DEF;;

let diff = Pent_hex.diff;;
let DERIVED_TAC = Pent_hex.DERIVED_TAC;;
(*
Functional_equation.functional_overload();;
*)

let sqrt8_flyspeck = 
prove_by_refinement( `#2.828427 < sqrt8 /\ sqrt8 < #2.828428`,
(* {{{ proof *) [ BY(REWRITE_TAC[Flyspeck_constants.bounds]) ]);;
(* }}} *)
let DOT_LSUB  = 
prove_by_refinement( `!x y (z:real^A). (x - y) dot z = x dot z - y dot z`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; BY(VECTOR_ARITH_TAC) ]);;
(* }}} *)
let DOT_RSUB  = 
prove_by_refinement( `!x y (z:real^A). x dot (y - z) = x dot y - x dot z `,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; BY(VECTOR_ARITH_TAC) ]);;
(* }}} *)
let euler_p_eulerA_x = 
prove_by_refinement( `!(v0:real^A) v1 v2 v3. (let x1 = dist(v0,v1) pow 2 in let x2 = dist(v0,v2) pow 2 in let x3 = dist(v0,v3) pow 2 in let x4 = dist(v2,v3) pow 2 in let x5 = dist(v1,v3) pow 2 in let x6 = dist(v1,v2) pow 2 in (euler_p v0 v1 v2 v3 = eulerA_x x1 x2 x3 x4 x5 x6))`,
(* {{{ proof *) [ REWRITE_TAC[LET_DEF;LET_END_DEF;Sphere.euler_p;Sphere.eulerA_x;Sphere.ylist]; REPEAT WEAKER_STRIP_TAC; REPEAT (GMATCH_SIMP_TAC POW_2_SQRT); REWRITE_TAC[DIST_POS_LE]; MATCH_MP_TAC (arith `b = b' ==> a + b = a + b'`); MATCH_MP_TAC (arith `a = a' /\ b = b' /\ c = c' ==> ra * a + rb * b + rc * c = ra * a' + rb * b' + rc * c'`); REWRITE_TAC[Collect_geom2.DIST_POW2_DOT]; REWRITE_TAC[DOT_LSUB;DOT_RSUB]; REWRITE_TAC[DOT_SYM]; BY(REAL_ARITH_TAC) ]);;
(* }}} *) (* was DELTA_IMP_DIH_PI *)
let COPLANAR_IMP_DIH_PI = 
prove_by_refinement( `!(v0:real^3) v1 v2 v3. (let y1 = dist(v0,v1) in let y2 = dist(v0,v2) in let y3 = dist(v0,v3) in let y4 = dist(v2,v3) in let y5 = dist(v1,v3) in let y6 = dist(v1,v2) in (~collinear {v0, v1, v2} /\ ~collinear {v0, v1, v3} /\ coplanar {v0,v1,v2,v3} /\ y_of_x delta_x4 y1 y2 y3 y4 y5 y6 < &0 ==> dihV v0 v1 v2 v3 = pi))`,
(* {{{ proof *) [ REWRITE_TAC[LET_DEF;LET_END_DEF]; REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM_ST `coplanar` MP_TAC; GMATCH_SIMP_TAC (GSYM DIHV_EQ_0_PI_EQ_COPLANAR); ASM_REWRITE_TAC[]; TYPIFY `(&0 < dihV v0 v1 v2 v3 )` ENOUGH_TO_SHOW_TAC; BY(REAL_ARITH_TAC); INTRO_TAC Euler_complement.OJEKOJF2 [`v0`;`v1`;`v2`;`v3`]; REWRITE_TAC[LET_DEF;LET_END_DEF]; ASM_REWRITE_TAC[]; DISCH_THEN SUBST1_TAC; FIRST_X_ASSUM MP_TAC; REWRITE_TAC[Sphere.y_of_x;arith `x*x = x pow 2`]; TYPED_ABBREV_TAC `d4 = delta_x4 (dist (v0,v1) pow 2) (dist (v0,v2) pow 2) (dist (v0,v3) pow 2) (dist (v2,v3) pow 2) (dist (v1,v3) pow 2) (dist (v1,v2) pow 2)` ; DISCH_TAC; TYPIFY `!x y. (y < &0 ==> atn2 (x,y) = --(pi / &2) - atn (x / y))` (C SUBGOAL_THEN ASSUME_TAC); BY(MESON_TAC[Trigonometry1.ATN2_BREAKDOWN]); FIRST_X_ASSUM (unlist ASM_SIMP_TAC); MATCH_MP_TAC (arith `&0 < pi /\ -- (pi / &2) < a ==> &0 < pi/ &2 - ( -- (pi/ &2) - a)`); REWRITE_TAC[PI_POS]; BY(REWRITE_TAC[ATN_BOUNDS]) ]);;
(* }}} *)
let DIH_IMP_EULER_A_POS = 
prove_by_refinement( `main_nonlinear_terminal_v11 ==> (!(v0:real^3) v1 v2 v3. (let y1 = dist(v0,v1) in let y2 = dist(v0,v2) in let y3 = dist(v0,v3) in let y4 = dist(v2,v3) in let y5 = dist(v1,v3) in let y6 = dist(v1,v2) in (~collinear {v0,v1,v2} /\ ~collinear {v0,v2,v3} /\ ~collinear{v0,v1,v3} /\ dihV v0 v1 v2 v3 + dihV v0 v2 v3 v1 + dihV v0 v3 v1 v2 < &2 * pi /\ &2 <= y1 /\ y1 <= &2 * h0 /\ &2 <= y2 /\ y2 <= &2 * h0 /\ &2 <= y3 /\ y3 <= &2 * h0 /\ #3.01 <= y4 /\ y4 <= #3.915 /\ #3.01 <= y5 /\ y5 <= #3.915 /\ #3.01 <= y6 /\ y6 <= #3.915 ==> y_of_x eulerA_x y1 y2 y3 y4 y5 y6 > &0)))`,
(* {{{ proof *) [ REWRITE_TAC[LET_DEF;LET_END_DEF]; REPEAT WEAKER_STRIP_TAC; TYPIFY `&0 < delta_y (dist(v0,v1)) (dist(v0,v2)) (dist(v0,v3)) (dist(v2,v3)) (dist(v1,v3)) (dist(v1,v2))` ASM_CASES_TAC; INTRO_TAC Euler_main_theorem.EULER_TRIANGLE [`v0`;`v1`;`v2`;`v3`]; REWRITE_TAC[LET_DEF;LET_END_DEF;Sphere.xlist;Sphere.ylist]; ANTS_TAC; BY(ASM_REWRITE_TAC[arith `x pow 2 = x * x`;GSYM Sphere.delta_y]); DISCH_TAC; FIRST_X_ASSUM_ST `&2 * pi` MP_TAC; REWRITE_TAC[arith `dd < &2 * pi <=> dd - pi < pi`]; ASM_REWRITE_TAC[arith `(a + b+c) -pi = a + b + c - pi`]; ASM_REWRITE_TAC[arith `x pow 2 = x * x`;GSYM Sphere.delta_y;arith `pi - u < pi <=> &0 < u`]; REWRITE_TAC[ (REWRITE_RULE[LET_DEF;LET_END_DEF] euler_p_eulerA_x)]; REWRITE_TAC[arith `x pow 2 = x * x`;GSYM Sphere.y_of_x]; TYPED_ABBREV_TAC `p = y_of_x eulerA_x (dist (v0,v1)) (dist (v0,v2)) (dist (v0,v3)) (dist (v2,v3)) (dist (v1,v3)) (dist (v1,v2))` ; REWRITE_TAC[arith `&0 < &2 * x <=> &0 < x`]; GMATCH_SIMP_TAC Merge_ineq.ATN2_POS; CONJ_TAC; GMATCH_SIMP_TAC REAL_LT_RSQRT; BY(ASM_TAC THEN REAL_ARITH_TAC); BY(REAL_ARITH_TAC); COMMENT "case delta=0";
TYPIFY `delta_y (dist (v0,v1)) (dist (v0,v2)) (dist (v0,v3)) (dist (v2,v3)) (dist (v1,v3)) (dist (v1,v2)) = &0` (C SUBGOAL_THEN ASSUME_TAC); INTRO_TAC Terminal.DELTA_Y_POS_4POINTS [`v0`;`v1`;`v2`;`v3`]; BY(ASM_TAC THEN REAL_ARITH_TAC); PROOF_BY_CONTR_TAC; TYPIFY `coplanar {v0,v1,v2,v3}` (C SUBGOAL_THEN ASSUME_TAC); REWRITE_TAC[ONCE_REWRITE_RULE[TAUT `(~a <=> b) <=> (a <=> ~b)`] Oxlzlez.coplanar_delta_y]; BY(ASM_TAC THEN REAL_ARITH_TAC); TYPIFY `{v0,v2,v3,v1} = {v0,v1,v2,v3} /\ {v0,v3,v1,v2} = {v0,v1,v2,v3}` (C SUBGOAL_THEN ASSUME_TAC); BY(SET_TAC[]); TYPIFY `{v0,v2,v1} = {v0,v1,v2} /\ {v0,v3,v2} = {v0,v2,v3} /\ {v0,v3,v1} = {v0,v1,v3}` (C SUBGOAL_THEN ASSUME_TAC); BY(SET_TAC[]); INTRO_TAC (Terminal.get_main_nonlinear "7439076204") [`dist(v0,v1)`;`dist(v0,v2)`;`dist(v0,v3)`;`dist(v2,v3)`;`dist(v1,v3)`;`dist(v1,v2)`]; ASM_REWRITE_TAC[Sphere.ineq;TAUT `a ==> b ==> c <=> a /\ b ==> c`]; DISCH_THEN MP_TAC THEN ANTS_TAC; BY(ASM_TAC THEN REWRITE_TAC[Sphere.h0] THEN REAL_ARITH_TAC); DISCH_TAC; TYPIFY `dihV v0 v1 v2 v3 = pi` (C SUBGOAL_THEN ASSUME_TAC); MATCH_MP_TAC (REWRITE_RULE[LET_THM] COPLANAR_IMP_DIH_PI); BY(ASM_REWRITE_TAC[]); INTRO_TAC (Terminal.get_main_nonlinear "7439076204") [`dist(v0,v2)`;`dist(v0,v3)`;`dist(v0,v1)`;`dist(v3,v1)`;`dist(v2,v1)`;`dist(v2,v3)`]; ASM_REWRITE_TAC[Sphere.ineq;TAUT `a ==> b ==> c <=> a /\ b ==> c`]; DISCH_THEN MP_TAC THEN ANTS_TAC; BY(ASM_TAC THEN REWRITE_TAC[Sphere.h0;DIST_SYM] THEN REAL_ARITH_TAC); TYPIFY_GOAL_THEN `y_of_x eulerA_x (dist (v0,v2)) (dist (v0,v3)) (dist (v0,v1)) (dist (v3,v1)) (dist (v2,v1)) (dist (v2,v3)) = y_of_x eulerA_x (dist (v0,v1)) (dist (v0,v2)) (dist (v0,v3)) (dist (v2,v3)) (dist (v1,v3)) (dist (v1,v2))` (unlist ASM_REWRITE_TAC); REWRITE_TAC[DIST_SYM;Sphere.y_of_x]; BY(MESON_TAC[Merge_ineq.eulerA_x_sym]); DISCH_TAC; TYPIFY `dihV v0 v2 v3 v1 = pi` (C SUBGOAL_THEN ASSUME_TAC); MATCH_MP_TAC (REWRITE_RULE[LET_THM] COPLANAR_IMP_DIH_PI); BY(ASM_REWRITE_TAC[]); INTRO_TAC (Terminal.get_main_nonlinear "7439076204") [`dist(v0,v3)`;`dist(v0,v1)`;`dist(v0,v2)`;`dist(v1,v2)`;`dist(v3,v2)`;`dist(v3,v1)`]; ASM_REWRITE_TAC[Sphere.ineq;TAUT `a ==> b ==> c <=> a /\ b ==> c`]; DISCH_THEN MP_TAC THEN ANTS_TAC; BY(ASM_TAC THEN REWRITE_TAC[Sphere.h0;DIST_SYM] THEN REAL_ARITH_TAC); TYPIFY_GOAL_THEN `y_of_x eulerA_x (dist (v0,v3)) (dist (v0,v1)) (dist (v0,v2)) (dist (v1,v2)) (dist (v3,v2)) (dist (v3,v1)) = y_of_x eulerA_x (dist (v0,v1)) (dist (v0,v2)) (dist (v0,v3)) (dist (v2,v3)) (dist (v1,v3)) (dist (v1,v2))` (unlist ASM_REWRITE_TAC); REWRITE_TAC[DIST_SYM;Sphere.y_of_x]; BY(MESON_TAC[Merge_ineq.eulerA_x_sym]); DISCH_TAC; TYPIFY `dihV v0 v3 v1 v2 = pi` (C SUBGOAL_THEN ASSUME_TAC); MATCH_MP_TAC (REWRITE_RULE[LET_THM] COPLANAR_IMP_DIH_PI); BY(ASM_REWRITE_TAC[]); REPEAT (FIRST_X_ASSUM_ST `dihV` MP_TAC); MP_TAC PI_POS; BY(REAL_ARITH_TAC) ]);; (* }}} *)
let ups_x_delta_x = 
prove_by_refinement( `!x1 x2 x3 x4 x5 x6. delta_x4 x1 x2 x3 x4 x5 x6 pow 2 + &4 * x1 * delta_x x1 x2 x3 x4 x5 x6 = ups_x x1 x3 x5 * ups_x x1 x2 x6`,
(* {{{ proof *) [ REWRITE_TAC[Sphere.delta_x4;Sphere.delta_x;Sphere.ups_x]; BY(REAL_ARITH_TAC) ]);;
(* }}} *) (* DERIVATIVES *)
let derived_form_b = 
prove_by_refinement( `!b f f' x s. derived_form b f f' x s <=> (b ==> derived_form T f f' x s)`,
(* {{{ proof *) [ BY(REWRITE_TAC[Calc_derivative.derived_form]) ]);;
(* }}} *)
let derived_form_delta_x_wrt_x4 = 
prove_by_refinement( `!x1 x2 x3 x4 x5 x6. derived_form T (\q. delta_x x1 x2 x3 q x5 x6) (delta_x4 x1 x2 x3 x4 x5 x6) (x4) (:real)`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; REWRITE_TAC[Sphere.delta_x4;Sphere.delta_x]; DERIVED_TAC (MP_TAC); MATCH_MP_TAC (TAUT `(x <=> y) ==> (x ==> y)`); REPEAT (AP_THM_TAC ORELSE AP_TERM_TAC); BY(REAL_ARITH_TAC) ]);;
(* }}} *)
let derived_form_delta_x_wrt_x5 = 
prove_by_refinement( `!x1 x2 x3 x4 x5 x6. derived_form T (\q. delta_x x1 x2 x3 x4 q x6) (delta_x5 x1 x2 x3 x4 x5 x6) (x5) (:real)`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; REWRITE_TAC[Nonlin_def.delta_x5;Sphere.delta_x]; DERIVED_TAC (MP_TAC); MATCH_MP_TAC (TAUT `(x <=> y) ==> (x ==> y)`); REPEAT (AP_THM_TAC ORELSE AP_TERM_TAC); BY(REAL_ARITH_TAC) ]);;
(* }}} *)
let derived_form_delta_x_wrt_x6 = 
prove_by_refinement( `!x1 x2 x3 x4 x5 x6. derived_form T (\q. delta_x x1 x2 x3 x4 x5 q) (delta_x6 x1 x2 x3 x4 x5 x6) (x6) (:real)`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; REWRITE_TAC[Nonlin_def.delta_x6;Sphere.delta_x]; DERIVED_TAC (MP_TAC); MATCH_MP_TAC (TAUT `(x <=> y) ==> (x ==> y)`); REPEAT (AP_THM_TAC ORELSE AP_TERM_TAC); BY(REAL_ARITH_TAC) ]);;
(* }}} *)
let derived_form_delta_x4_wrt_x4 = 
prove_by_refinement( `!x1 x2 x3 x4 x5 x6. derived_form T (\q. delta_x4 x1 x2 x3 q x5 x6) (-- &2 * x1) (x4) (:real)`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; REWRITE_TAC[Sphere.delta_x4]; DERIVED_TAC (MP_TAC); MATCH_MP_TAC (TAUT `(x <=> y) ==> (x ==> y)`); REPEAT (AP_THM_TAC ORELSE AP_TERM_TAC); BY(REAL_ARITH_TAC) ]);;
(* }}} *)
let derived_form_delta_x4_wrt_x5 = 
prove_by_refinement( `!x1 x2 x3 x4 x5 x6. derived_form T (\q. delta_x4 x1 x2 x3 x4 q x6) (x1 + x2 - x6) (x5) (:real)`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; REWRITE_TAC[Sphere.delta_x4]; DERIVED_TAC (MP_TAC); MATCH_MP_TAC (TAUT `(x <=> y) ==> (x ==> y)`); REPEAT (AP_THM_TAC ORELSE AP_TERM_TAC); BY(REAL_ARITH_TAC) ]);;
(* }}} *)
let derived_form_delta_x4_wrt_x6 = 
prove_by_refinement( `!x1 x2 x3 x4 x5 x6. derived_form T (\q. delta_x4 x1 x2 x3 x4 x5 q) (x1 + x3 - x5) (x6) (:real)`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; REWRITE_TAC[Sphere.delta_x4]; DERIVED_TAC (MP_TAC); MATCH_MP_TAC (TAUT `(x <=> y) ==> (x ==> y)`); REPEAT (AP_THM_TAC ORELSE AP_TERM_TAC); BY(REAL_ARITH_TAC) ]);;
(* }}} *)
let derived_form_dih_x_wrt_x4 = 
prove_by_refinement( `!x1 x2 x3 x4 x5 x6. &0 < x1 /\ &0 < delta_x x1 x2 x3 x4 x5 x6 /\ &0 < ups_x x1 x2 x6 /\ &0 < ups_x x1 x3 x5 ==> derived_form T (\q. dih_x x1 x2 x3 q x5 x6) (sqrt x1 / sqrt (delta_x x1 x2 x3 x4 x5 x6)) (x4) (:real)`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; TYPED_ABBREV_TAC `w = (sqrt x1 / sqrt (delta_x x1 x2 x3 x4 x5 x6))`; REWRITE_TAC[Sphere.dih_x;LET_THM]; DERIVED_TAC (MP_TAC o GEN_ALL o (GENL [`x1:real`;`x2:real`;`x3:real`;`x4:real`;`x5:real`;`x6:real`])); DISCH_THEN (C INTRO_TAC [`(-- &2 * x1)`;`(delta_x4 x1 x2 x3 x4 x5 x6)`;`x1`;`x2`;`x3`;`x4`;`x5`;`x6`]); TYPIFY `&0 < &4 * x1 * delta_x x1 x2 x3 x4 x5 x6` (C SUBGOAL_THEN ASSUME_TAC); GMATCH_SIMP_TAC REAL_LT_MUL_EQ; REWRITE_TAC[arith `&0 < &4`]; GMATCH_SIMP_TAC REAL_LT_MUL_EQ; BY(ASM_REWRITE_TAC[]); TYPIFY `&0 < sqrt(&4 * x1 * delta_x x1 x2 x3 x4 x5 x6)` (C SUBGOAL_THEN ASSUME_TAC); GMATCH_SIMP_TAC REAL_LT_RSQRT; BY(ASM_TAC THEN REAL_ARITH_TAC); ONCE_REWRITE_TAC[derived_form_b]; ANTS_TAC; ASM_REWRITE_TAC[derived_form_delta_x4_wrt_x4;derived_form_delta_x_wrt_x4;IN_UNIV;DE_MORGAN_THM]; BY(ASM_TAC THEN REAL_ARITH_TAC); REWRITE_TAC[]; MATCH_MP_TAC (TAUT `(x <=> y) ==> (x ==> y)`); REPEAT (AP_THM_TAC ORELSE AP_TERM_TAC); TYPIFY `(sqrt (&4 * x1 * delta_x x1 x2 x3 x4 x5 x6) pow 2 + --delta_x4 x1 x2 x3 x4 x5 x6 pow 2) = ups_x x1 x3 x5 * ups_x x1 x2 x6 ` (C SUBGOAL_THEN ASSUME_TAC); GMATCH_SIMP_TAC SQRT_POW_2; ASM_SIMP_TAC[arith `&0 < x ==> &0 <= x`]; REWRITE_TAC[arith `(-- x) pow 2 = x pow 2`;GSYM ups_x_delta_x]; BY(REAL_ARITH_TAC); ASM_REWRITE_TAC[]; TYPIFY `(((-- &2 * x1) * -- &1) * sqrt (&4 * x1 * delta_x x1 x2 x3 x4 x5 x6) - --delta_x4 x1 x2 x3 x4 x5 x6 * (&4 * x1 * delta_x4 x1 x2 x3 x4 x5 x6) * inv (&2 * sqrt (&4 * x1 * delta_x x1 x2 x3 x4 x5 x6))) = (&2 * x1) * (ups_x x1 x3 x5 * ups_x x1 x2 x6) / sqrt(&4 * x1 * delta_x x1 x2 x3 x4 x5 x6)` (C SUBGOAL_THEN SUBST1_TAC); FIRST_ASSUM ( SUBST1_TAC o GSYM); Calc_derivative.CALC_ID_TAC; BY(ASM_TAC THEN REAL_ARITH_TAC); TYPIFY `((&2 * x1) * (ups_x x1 x3 x5 * ups_x x1 x2 x6) / sqrt (&4 * x1 * delta_x x1 x2 x3 x4 x5 x6)) / (ups_x x1 x3 x5 * ups_x x1 x2 x6) = sqrt(x1) / sqrt(delta_x x1 x2 x3 x4 x5 x6)` (C SUBGOAL_THEN SUBST1_TAC); Calc_derivative.CALC_ID_TAC; TYPIFY `&0 < sqrt(delta_x x1 x2 x3 x4 x5 x6)` (C SUBGOAL_THEN ASSUME_TAC); GMATCH_SIMP_TAC REAL_LT_RSQRT; BY(ASM_TAC THEN REAL_ARITH_TAC); CONJ_TAC; BY(ASM_TAC THEN REAL_ARITH_TAC); TYPIFY `sqrt(&4 * x1 * delta_x x1 x2 x3 x4 x5 x6) = &2 * sqrt(x1) * sqrt(delta_x x1 x2 x3 x4 x5 x6)` (C SUBGOAL_THEN SUBST1_TAC); GMATCH_SIMP_TAC (GSYM SQRT_MUL); TYPIFY `&2 = sqrt(&4)` (C SUBGOAL_THEN SUBST1_TAC); MATCH_MP_TAC Upfzbzm_support_lemmas.SQRT_RULE_Euler_lemma; BY(REAL_ARITH_TAC); CONJ_TAC; BY(ASM_TAC THEN REAL_ARITH_TAC); GMATCH_SIMP_TAC (GSYM SQRT_MUL); REWRITE_TAC[arith `&0 <= &4`]; GMATCH_SIMP_TAC REAL_LE_MUL; BY(ASM_TAC THEN REAL_ARITH_TAC); TYPIFY `sqrt x1 * sqrt x1 = x1` (C SUBGOAL_THEN MP_TAC); GMATCH_SIMP_TAC (GSYM SQRT_MUL); GMATCH_SIMP_TAC Nonlinear_lemma.sqrtxx; BY(ASM_TAC THEN REAL_ARITH_TAC); TYPED_ABBREV_TAC `s = sqrt(delta_x x1 x2 x3 x4 x5 x6)` ; REWRITE_TAC[arith `((&2 * sx * s) * u) * sx = &2 * (sx * sx) * s * u`]; DISCH_THEN SUBST1_TAC; BY(REAL_ARITH_TAC); EXPAND_TAC "w";
BY(REWRITE_TAC[]) ]);; (* }}} *)
let derived_form_dih_x_wrt_x5 = 
prove_by_refinement( `!x1 x2 x3 x4 x5 x6. &0 < x1 /\ &0 < delta_x x1 x2 x3 x4 x5 x6 /\ &0 < ups_x x1 x2 x6 /\ &0 < ups_x x1 x3 x5 ==> derived_form T (\q. dih_x x1 x2 x3 x4 q x6) (--sqrt x1 * delta_x6 x1 x2 x3 x4 x5 x6 / (ups_x x1 x3 x5 * sqrt (delta_x x1 x2 x3 x4 x5 x6))) (x5) (:real)`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; TYPED_ABBREV_TAC `w = (--sqrt x1 * delta_x6 x1 x2 x3 x4 x5 x6 / (ups_x x1 x3 x5 * sqrt (delta_x x1 x2 x3 x4 x5 x6)))`; REWRITE_TAC[Sphere.dih_x;LET_THM]; DERIVED_TAC (MP_TAC o GEN_ALL o (GENL [`x1:real`;`x2:real`;`x3:real`;`x4:real`;`x5:real`;`x6:real`])); DISCH_THEN (C INTRO_TAC [`x1 + x2 - x6`;`(delta_x5 x1 x2 x3 x4 x5 x6)`;`x1`;`x2`;`x3`;`x4`;`x5`;`x6`]); TYPIFY `&0 < &4 * x1 * delta_x x1 x2 x3 x4 x5 x6` (C SUBGOAL_THEN ASSUME_TAC); GMATCH_SIMP_TAC REAL_LT_MUL_EQ; REWRITE_TAC[arith `&0 < &4`]; GMATCH_SIMP_TAC REAL_LT_MUL_EQ; BY(ASM_REWRITE_TAC[]); TYPIFY `&0 < sqrt(&4 * x1 * delta_x x1 x2 x3 x4 x5 x6)` (C SUBGOAL_THEN ASSUME_TAC); GMATCH_SIMP_TAC REAL_LT_RSQRT; BY(ASM_TAC THEN REAL_ARITH_TAC); ONCE_REWRITE_TAC[derived_form_b]; ANTS_TAC; ASM_REWRITE_TAC[derived_form_delta_x4_wrt_x5;derived_form_delta_x_wrt_x5;IN_UNIV;DE_MORGAN_THM]; BY(ASM_TAC THEN REAL_ARITH_TAC); REWRITE_TAC[]; MATCH_MP_TAC (TAUT `(x <=> y) ==> (x ==> y)`); REPEAT (AP_THM_TAC ORELSE AP_TERM_TAC); TYPIFY `(sqrt (&4 * x1 * delta_x x1 x2 x3 x4 x5 x6) pow 2 + --delta_x4 x1 x2 x3 x4 x5 x6 pow 2) = ups_x x1 x3 x5 * ups_x x1 x2 x6 ` (C SUBGOAL_THEN ASSUME_TAC); GMATCH_SIMP_TAC SQRT_POW_2; ASM_SIMP_TAC[arith `&0 < x ==> &0 <= x`]; REWRITE_TAC[arith `(-- x) pow 2 = x pow 2`;GSYM ups_x_delta_x]; BY(REAL_ARITH_TAC); ASM_REWRITE_TAC[]; TYPIFY `(((x1 + x2 - x6) * -- &1) * sqrt (&4 * x1 * delta_x x1 x2 x3 x4 x5 x6) - --delta_x4 x1 x2 x3 x4 x5 x6 * (&4 * x1 * delta_x5 x1 x2 x3 x4 x5 x6) * inv (&2 * sqrt (&4 * x1 * delta_x x1 x2 x3 x4 x5 x6))) = (-- &4 * x1 * ups_x x1 x2 x6 * delta_x6 x1 x2 x3 x4 x5 x6) / (&2 * sqrt(&4 * x1 * delta_x x1 x2 x3 x4 x5 x6))` (C SUBGOAL_THEN SUBST1_TAC); Calc_derivative.CALC_ID_TAC; CONJ_TAC; BY(ASM_TAC THEN REAL_ARITH_TAC); REWRITE_TAC[arith `(xx * s) * &2 * s = (s * s) * xx * &2`]; GMATCH_SIMP_TAC (GSYM SQRT_MUL); ASM_SIMP_TAC[arith `&0 <x ==> &0 <= x`]; GMATCH_SIMP_TAC Nonlinear_lemma.sqrtxx; ASM_SIMP_TAC[arith `&0 <x ==> &0 <= x`]; TYPED_ABBREV_TAC `sq = sqrt (&4 * x1 * delta_x x1 x2 x3 x4 x5 x6)`; REWRITE_TAC[Sphere.delta_x;Nonlin_def.delta_x4;Nonlin_def.delta_x5;Nonlin_def.delta_x6;Sphere.ups_x]; BY(REAL_ARITH_TAC); TYPIFY `(-- &4 * x1 * ups_x x1 x2 x6 * delta_x6 x1 x2 x3 x4 x5 x6) / (&2 * sqrt (&4 * x1 * delta_x x1 x2 x3 x4 x5 x6)) / (ups_x x1 x3 x5 * ups_x x1 x2 x6) = -- sqrt x1 * delta_x6 x1 x2 x3 x4 x5 x6 / (ups_x x1 x3 x5 * sqrt(delta_x x1 x2 x3 x4 x5 x6))` (C SUBGOAL_THEN SUBST1_TAC); Calc_derivative.CALC_ID_TAC; TYPIFY `&0 < sqrt(delta_x x1 x2 x3 x4 x5 x6)` (C SUBGOAL_THEN ASSUME_TAC); GMATCH_SIMP_TAC REAL_LT_RSQRT; BY(ASM_TAC THEN REAL_ARITH_TAC); CONJ_TAC; BY(ASM_TAC THEN REAL_ARITH_TAC); TYPIFY `sqrt(&4 * x1 * delta_x x1 x2 x3 x4 x5 x6) = &2 * sqrt(x1) * sqrt(delta_x x1 x2 x3 x4 x5 x6)` (C SUBGOAL_THEN SUBST1_TAC); GMATCH_SIMP_TAC (GSYM SQRT_MUL); TYPIFY `&2 = sqrt(&4)` (C SUBGOAL_THEN SUBST1_TAC); MATCH_MP_TAC Upfzbzm_support_lemmas.SQRT_RULE_Euler_lemma; BY(REAL_ARITH_TAC); CONJ_TAC; BY(ASM_TAC THEN REAL_ARITH_TAC); GMATCH_SIMP_TAC (GSYM SQRT_MUL); REWRITE_TAC[arith `&0 <= &4`]; GMATCH_SIMP_TAC REAL_LE_MUL; BY(ASM_TAC THEN REAL_ARITH_TAC); TYPIFY `sqrt x1 * sqrt x1 = x1` (C SUBGOAL_THEN MP_TAC); GMATCH_SIMP_TAC (GSYM SQRT_MUL); GMATCH_SIMP_TAC Nonlinear_lemma.sqrtxx; BY(ASM_TAC THEN REAL_ARITH_TAC); TYPED_ABBREV_TAC `s = sqrt(delta_x x1 x2 x3 x4 x5 x6)` ; REWRITE_TAC[arith `((&2 * sx * s) * u) * sx = &2 * (sx * sx) * s * u`]; BY(CONV_TAC REAL_RING); EXPAND_TAC "w";
BY(REWRITE_TAC[]) ]);; (* }}} *)
let derived_form_dih_x_wrt_x6 = 
prove_by_refinement( `!x1 x2 x3 x4 x5 x6. &0 < x1 /\ &0 < delta_x x1 x2 x3 x4 x5 x6 /\ &0 < ups_x x1 x2 x6 /\ &0 < ups_x x1 x3 x5 ==> derived_form T (\q. dih_x x1 x2 x3 x4 x5 q) (--sqrt x1 * delta_x5 x1 x2 x3 x4 x5 x6 / (ups_x x1 x2 x6 * sqrt (delta_x x1 x2 x3 x4 x5 x6))) (x6) (:real)`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; TYPIFY_GOAL_THEN `!q. dih_x x1 x2 x3 x4 x5 q = dih_x x1 x3 x2 x4 q x5` (unlist REWRITE_TAC); BY(REWRITE_TAC[Nonlinear_lemma.dih_x_sym]); INTRO_TAC derived_form_dih_x_wrt_x5 [`x1`;`x3`;`x2`;`x4`;`x6`;`x5`]; TYPIFY `delta_x x1 x3 x2 x4 x6 x5 = delta_x x1 x2 x3 x4 x5 x6` (C SUBGOAL_THEN SUBST1_TAC); BY(ASM_TAC THEN MESON_TAC[Merge_ineq.delta_x_sym]); ASM_REWRITE_TAC[]; MATCH_MP_TAC (TAUT `(x <=> y) ==> (x ==> y)`); REPEAT (AP_THM_TAC ORELSE AP_TERM_TAC); REWRITE_TAC[Nonlin_def.delta_x6;Nonlin_def.delta_x5]; BY(REAL_ARITH_TAC) ]);;
(* }}} *)
let derived_form_num1 = 
prove_by_refinement( `!x4 x5 x6 e1 e2 e3. derived_form T (\q. num1 e1 e2 e3 q x5 x6) (&4 * ((&16 - &2 * x4) * e1 + (x5 - &8) * e2 + (x6 - &8) * e3)) (x4) (:real)`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; REWRITE_TAC[Sphere.num1]; DERIVED_TAC MP_TAC; MATCH_MP_TAC (TAUT `(x <=> y) ==> (x ==> y)`); REPEAT (AP_THM_TAC ORELSE AP_TERM_TAC); BY(REAL_ARITH_TAC) ]);;
(* }}} *)
let derived_form_dnum1 = 
prove_by_refinement( `!x4 x5 x6 e1 e2 e3. derived_form T (\q. num1 e1 e2 e3 q x5 x6) (&4 * dnum1 e1 e2 e3 x4 x5 x6) (x4) (:real)`,
(* {{{ proof *) [ BY(REWRITE_TAC[Nonlin_def.dnum1;derived_form_num1]) ]);;
(* }}} *)
let derived_form_sum_dih = 
prove_by_refinement( `!x1 x2 x3 x4 x5 x6 e1 e2 e3. &0 < x1 /\ &0 < x2 /\ &0 < x3 /\ &0 < delta_x x1 x2 x3 x4 x5 x6 /\ &0 < ups_x x1 x2 x6 /\ &0 < ups_x x1 x3 x5 /\ &0 < ups_x x2 x3 x4 ==> derived_form T (\q. e1 * dih_x x1 x2 x3 q x5 x6 + e2 * dih_x x2 x3 x1 x5 x6 q + e3 * dih_x x3 x1 x2 x6 q x5) ((e1 * sqrt x1 * ups_x x2 x3 x4 - e2 * sqrt x2 * delta_x6 x1 x2 x3 x4 x5 x6 - e3 * sqrt x3 * delta_x5 x1 x2 x3 x4 x5 x6) / (ups_x x2 x3 x4 * sqrt (delta_x x1 x2 x3 x4 x5 x6))) (x4) (:real)`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; TYPED_ABBREV_TAC `w = (e1 * sqrt x1 * ups_x x2 x3 x4 - e2 * sqrt x2 * delta_x6 x1 x2 x3 x4 x5 x6 - e3 * sqrt x3 * delta_x5 x1 x2 x3 x4 x5 x6) / (ups_x x2 x3 x4 * sqrt (delta_x x1 x2 x3 x4 x5 x6))`; TYPIFY_GOAL_THEN `!q. e1 * dih_x x1 x2 x3 q x5 x6 + e2 * dih_x x2 x3 x1 x5 x6 q + e3 * dih_x x3 x1 x2 x6 q x5 = e1 * (\q. dih_x x1 x2 x3 q x5 x6) q + e2 * (\q. dih_x x2 x3 x1 x5 x6 q) q + e3 * (\q. dih_x x3 x1 x2 x6 q x5) q` (unlist PURE_REWRITE_TAC); BY(REWRITE_TAC[]); TYPED_ABBREV_TAC `f1 = (\q. dih_x x1 x2 x3 q x5 x6)` ; TYPED_ABBREV_TAC `f2 = (\q. dih_x x2 x3 x1 x5 x6 q)` ; TYPED_ABBREV_TAC `f3 = (\q. dih_x x3 x1 x2 x6 q x5)` ; DERIVED_TAC (MP_TAC o GEN_ALL o (GENL [`x1:real`;`x2:real`;`x3:real`;`x4:real`;`x5:real`;`x6:real`;`e1:real`;`e2:real`;`e3:real`])); DISCH_THEN (C INTRO_TAC [`f1`;`f2`;`f3`]); EXPAND_TAC "f1";
DISCH_THEN (C INTRO_TAC [`(sqrt x1 / sqrt (delta_x x1 x2 x3 x4 x5 x6))`;`(--sqrt x2 * delta_x5 x2 x3 x1 x5 x6 x4 / (ups_x x2 x3 x4 * sqrt (delta_x x2 x3 x1 x5 x6 x4)))`;` (--sqrt x3 * delta_x6 x3 x1 x2 x6 x4 x5 / (ups_x x3 x2 x4 * sqrt (delta_x x3 x1 x2 x6 x4 x5)))`;`x1`;`x2`;`x3`;`x4`;`x5`;`x6`;`e1`;`e2`;`e3`]); ASM_SIMP_TAC[derived_form_dih_x_wrt_x4]; TYPIFY `delta_x x2 x3 x1 x5 x6 x4 = delta_x x1 x2 x3 x4 x5 x6 /\ delta_x x3 x1 x2 x6 x4 x5 = delta_x x1 x2 x3 x4 x5 x6` (C SUBGOAL_THEN ASSUME_TAC); BY(REWRITE_TAC[Merge_ineq.delta_x_sym]); TYPIFY `ups_x x2 x1 x6 = ups_x x1 x2 x6 /\ ups_x x3 x1 x5 = ups_x x1 x3 x5 /\ ups_x x3 x2 x4 = ups_x x2 x3 x4` (C SUBGOAL_THEN ASSUME_TAC); BY(REWRITE_TAC[Merge_ineq.ups_x_sym]); ONCE_REWRITE_TAC[derived_form_b]; ANTS_TAC; EXPAND_TAC "f2"; EXPAND_TAC "f3"; CONJ_TAC; MATCH_MP_TAC derived_form_dih_x_wrt_x6; BY(ASM_REWRITE_TAC[]); MATCH_MP_TAC derived_form_dih_x_wrt_x5; BY(ASM_REWRITE_TAC[]); REWRITE_TAC[]; MATCH_MP_TAC (TAUT `(x <=> y) ==> (x ==> y)`); REPEAT (AP_THM_TAC ORELSE AP_TERM_TAC); ASM_REWRITE_TAC[]; TYPIFY `delta_x5 x2 x3 x1 x5 x6 x4 = delta_x6 x1 x2 x3 x4 x5 x6` (C SUBGOAL_THEN SUBST1_TAC); REWRITE_TAC[Nonlin_def.delta_x5;Nonlin_def.delta_x6]; BY(REAL_ARITH_TAC); TYPIFY `delta_x6 x3 x1 x2 x6 x4 x5 = delta_x5 x1 x2 x3 x4 x5 x6` (C SUBGOAL_THEN SUBST1_TAC); REWRITE_TAC[Nonlin_def.delta_x5;Nonlin_def.delta_x6]; BY(REAL_ARITH_TAC); TYPIFY `&0 < sqrt(delta_x x1 x2 x3 x4 x5 x6)` (C SUBGOAL_THEN ASSUME_TAC); GMATCH_SIMP_TAC REAL_LT_RSQRT; BY(ASM_TAC THEN REAL_ARITH_TAC); TYPIFY `e1 * sqrt x1 / sqrt (delta_x x1 x2 x3 x4 x5 x6) + e2 * --sqrt x2 * delta_x6 x1 x2 x3 x4 x5 x6 / (ups_x x2 x3 x4 * sqrt (delta_x x1 x2 x3 x4 x5 x6)) + e3 * --sqrt x3 * delta_x5 x1 x2 x3 x4 x5 x6 / (ups_x x2 x3 x4 * sqrt (delta_x x1 x2 x3 x4 x5 x6)) = (e1 * sqrt x1 * ups_x x2 x3 x4 - e2 * sqrt x2 * delta_x6 x1 x2 x3 x4 x5 x6 - e3 * sqrt x3 * delta_x5 x1 x2 x3 x4 x5 x6) / (ups_x x2 x3 x4 * sqrt(delta_x x1 x2 x3 x4 x5 x6))` (C SUBGOAL_THEN SUBST1_TAC); Calc_derivative.CALC_ID_TAC; BY(ASM_TAC THEN REAL_ARITH_TAC); EXPAND_TAC "w"; BY(REWRITE_TAC[]) ]);; (* }}} *)
let derived_form_sum_dih444 = 
prove_by_refinement( `!x4 x5 x6 e1 e2 e3. &0 < x4 /\ x4 < &16 /\ &0 < x5 /\ x5 < &16 /\ &0 < x6 /\ x6 < &16 /\ &0 < delta_x (&4) (&4) (&4) x4 x5 x6 ==> derived_form T (\q. e1 * dih_x (&4) (&4) (&4) q x5 x6 + e2 * dih_x (&4) (&4) (&4) x5 x6 q + e3 * dih_x (&4) (&4) (&4) x6 q x5) (( num1 e1 e2 e3 x4 x5 x6 ) / (&2 * x4 * (&16 - x4) * sqrt(delta_x (&4) (&4) (&4) x4 x5 x6))) (x4) (:real)`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; ONCE_REWRITE_TAC[arith `a / (&2 * b) = (a/ &2) / b`]; INTRO_TAC derived_form_sum_dih [`&4`;`&4`;`&4`;`x4`;`x5`;`x6`;`e1`;`e2`;`e3`]; TYPIFY_GOAL_THEN `!x. ups_x (&4) (&4) (x) = x * (&16 - x)` (unlist REWRITE_TAC); ASM_REWRITE_TAC[Sphere.ups_x;arith `&0 < &4`]; TYPIFY_GOAL_THEN `!x6. -- &4 * &4 - &4 * &4 - x6 * x6 + &2 * &4 * x6 + &2 * &4 * &4 + &2 * &4 * x6 = x6 * (&16- x6)` (unlist REWRITE_TAC); BY(REAL_ARITH_TAC); ANTS_TAC; REPEAT (GMATCH_SIMP_TAC REAL_LT_MUL_EQ); BY(ASM_TAC THEN REAL_ARITH_TAC); MATCH_MP_TAC (TAUT `(x <=> y) ==> (x ==> y)`); REWRITE_TAC[REAL_MUL_AC;Collect_geom2.SQRT4_EQ2]; REPEAT (AP_THM_TAC ORELSE AP_TERM_TAC); REWRITE_TAC[Sphere.num1;Nonlin_def.delta_x6;Nonlin_def.delta_x5]; BY(REAL_ARITH_TAC) ]);;
(* }}} *)
let derived_form_sum_dih444sub = 
prove_by_refinement( `!x4 x5 x6 e1 e2 e3. &0 < x4 /\ x4 < &16 /\ &0 < x5 /\ x5 < &16 /\ &0 < x6 /\ x6 < &16 /\ &0 < delta_x (&4) (&4) (&4) x4 x5 x6 ==> derived_form T (\q. e1 * dih_x (&4) (&4) (&4) q x5 x6 + e2 * dih_x (&4) (&4) (&4) x5 x6 q + e3 * dih_x (&4) (&4) (&4) x6 q x5 - (&1 + const1) * pi) (( num1 e1 e2 e3 x4 x5 x6 ) / (&2 * x4 * (&16 - x4) * sqrt(delta_x (&4) (&4) (&4) x4 x5 x6))) (x4) (:real)`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; TYPED_ABBREV_TAC `f' = (num1 e1 e2 e3 x4 x5 x6 / (&2 * x4 * (&16 - x4) * sqrt (delta_x (&4) (&4) (&4) x4 x5 x6)))`; INTRO_TAC (GEN_ALL Calc_derivative.derived_form_sub) [`T`;`T`;`(\q. e1 * dih_x (&4) (&4) (&4) q x5 x6 + e2 * dih_x (&4) (&4) (&4) x5 x6 q + e3 * dih_x (&4) (&4) (&4) x6 q x5)`;`\ (q:real). (&1 + const1)*pi`;`f'`;`&0`;`x4`;`(:real)`]; ASM_REWRITE_TAC[arith `f' - &0 = f'`;arith `(a + b) - c = a + b - c`]; DISCH_THEN MATCH_MP_TAC; EXPAND_TAC "f'";
ASM_SIMP_TAC[derived_form_sum_dih444]; DERIVED_TAC MP_TAC; BY(REWRITE_TAC[]) ]);; (* }}} *)
let derived_form_tau2D = 
prove_by_refinement( `!x4 x5 x6 e1 e2 e3. &0 < x4 /\ x4 < &16 /\ &0 < x5 /\ x5 < &16 /\ &0 < x6 /\ x6 < &16 /\ &0 < delta_x (&4) (&4) (&4) x4 x5 x6 /\ num1 e1 e2 e3 x4 x5 x6 = &0 ==> derived_form T (\q. ( num1 e1 e2 e3 q x5 x6) / (&2 * q * (&16 - q) * sqrt(delta_x (&4) (&4) (&4) q x5 x6))) ((&4 * dnum1 e1 e2 e3 x4 x5 x6) / (&2 * x4 * (&16 - x4) * sqrt(delta_x (&4) (&4) (&4) x4 x5 x6))) (x4) (:real)`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; TYPIFY ` (\q. ( num1 e1 e2 e3 q x5 x6) / (&2 * q * (&16 - q) * sqrt(delta_x (&4) (&4) (&4) q x5 x6))) = (\q. (\q. num1 e1 e2 e3 q x5 x6) q / (\q. &2 * q * (&16 - q) * sqrt(delta_x (&4) (&4) (&4) q x5 x6)) q) ` (C SUBGOAL_THEN SUBST1_TAC); BY(REWRITE_TAC[FUN_EQ_THM]); TYPED_ABBREV_TAC `(f:real->real) = (\q. num1 e1 e2 e3 q x5 x6 )` ; TYPED_ABBREV_TAC `(g:real->real) = (\q. &2 * q * (&16 - q) * sqrt (delta_x (&4) (&4) (&4) q x5 x6))` ; DERIVED_TAC (MP_TAC o GEN_ALL); MP_TAC (diff `(\q. &2 * q * (&16 - q) * sqrt (delta_x (&4) (&4) (&4) q x5 x6))` [Sphere.delta_x] `x4:real` `(:real)`); ASM_REWRITE_TAC[]; DISCH_TAC; TYPED_ABBREV_TAC `(g':real) = (&2 * (x4 * ((&16 - x4) * (&4 * (x4 * -- &1 + -- &4 + &4 + &4 - x4 + x5 + x6) + &4 * x5 + &4 * x6 - &4 * &4 - x5 * x6) * inv (&2 * sqrt (delta_x (&4) (&4) (&4) x4 x5 x6)) + -- &1 * sqrt (delta_x (&4) (&4) (&4) x4 x5 x6)) + (&16 - x4) * sqrt (delta_x (&4) (&4) (&4) x4 x5 x6)))` ; DISCH_THEN (C INTRO_TAC [`&4 * dnum1 e1 e2 e3 x4 x5 x6`;`f`;`g'`;`g`;`x4`]); ASM_REWRITE_TAC[]; EXPAND_TAC "f";
REWRITE_TAC[derived_form_dnum1]; EXPAND_TAC "g"; ASM_REWRITE_TAC[arith `&0 * x = &0 /\ &0 / x = &0 /\ x - &0 = x`]; ONCE_REWRITE_TAC[derived_form_b]; TYPIFY `~(&2 * x4 * (&16 - x4) * sqrt (delta_x (&4) (&4) (&4) x4 x5 x6) = &0)` (C SUBGOAL_THEN ASSUME_TAC); REWRITE_TAC[REAL_ENTIRE;DE_MORGAN_THM]; TYPIFY_GOAL_THEN `~(sqrt(delta_x (&4) (&4) (&4) x4 x5 x6) = &0)` (unlist REWRITE_TAC); GMATCH_SIMP_TAC SQRT_EQ_0; BY(ASM_TAC THEN REAL_ARITH_TAC); BY(ASM_TAC THEN REAL_ARITH_TAC); ASM_REWRITE_TAC[]; TYPED_ABBREV_TAC `d = (&2 * x4 * (&16 - x4) * sqrt (delta_x (&4) (&4) (&4) x4 x5 x6))` ; MATCH_MP_TAC (TAUT `(x <=> y) ==> (x ==> y)`); REPEAT (AP_THM_TAC ORELSE AP_TERM_TAC); Calc_derivative.CALC_ID_TAC; BY(ASM_REWRITE_TAC[]) ]);; (* }}} *)
let derived_form_taum_d3_exists = 
prove_by_refinement( `!x4 x5 x6 e1 e2 e3. ?f'' f'''. &0 < x4 /\ x4 < &16 /\ &0 < x5 /\ x5 < &16 /\ &0 < x6 /\ x6 < &16 /\ &0 < delta_x (&4) (&4) (&4) x4 x5 x6 ==> (!x4. &0 < x4 /\ x4 < &16 /\ &0 < delta_x (&4) (&4) (&4) x4 x5 x6 ==> derived_form T (\q. ( num1 e1 e2 e3 q x5 x6 ) / (&2 * q * (&16 - q) * sqrt(delta_x (&4) (&4) (&4) q x5 x6))) (f'' x4) (x4) (:real)) /\ (derived_form T f'' f''' x4 (:real))`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; TYPIFY `\q. (((&4 * dnum1 e1 e2 e3 q x5 x6) * &2 * q * (&16 - q) * sqrt (delta_x (&4) (&4) (&4) q x5 x6) - num1 e1 e2 e3 q x5 x6 * &2 * (q * ((&16 - q) * delta_x4 (&4) (&4) (&4) q x5 x6 * inv (&2 * sqrt (delta_x (&4) (&4) (&4) q x5 x6)) + -- &1 * sqrt (delta_x (&4) (&4) (&4) q x5 x6)) + (&16 - q) * sqrt (delta_x (&4) (&4) (&4) q x5 x6))) / (&2 * q * (&16 - q) * sqrt (delta_x (&4) (&4) (&4) q x5 x6)) pow 2)` EXISTS_TAC; TYPIFY `(((((&4 * ((&16 - &2 * x4) * e1 + (x5 - &8) * e2 + (x6 - &8) * e3)) * &2 * (x4 * ((&16 - x4) * delta_x4 (&4) (&4) (&4) x4 x5 x6 * inv (&2 * sqrt (delta_x (&4) (&4) (&4) x4 x5 x6)) + -- &1 * sqrt (delta_x (&4) (&4) (&4) x4 x5 x6)) + (&16 - x4) * sqrt (delta_x (&4) (&4) (&4) x4 x5 x6)) + (&4 * -- &2 * e1) * &2 * x4 * (&16 - x4) * sqrt (delta_x (&4) (&4) (&4) x4 x5 x6)) - (num1 e1 e2 e3 x4 x5 x6 * &2 * ((x4 * (((&16 - x4) * (delta_x4 (&4) (&4) (&4) x4 x5 x6 * (&2 * delta_x4 (&4) (&4) (&4) x4 x5 x6 * inv (&2 * sqrt (delta_x (&4) (&4) (&4) x4 x5 x6))) * --inv ((&2 * sqrt (delta_x (&4) (&4) (&4) x4 x5 x6)) pow 2) + (-- &2 * &4) * inv (&2 * sqrt (delta_x (&4) (&4) (&4) x4 x5 x6))) + -- &1 * delta_x4 (&4) (&4) (&4) x4 x5 x6 * inv (&2 * sqrt (delta_x (&4) (&4) (&4) x4 x5 x6))) + -- &1 * delta_x4 (&4) (&4) (&4) x4 x5 x6 * inv (&2 * sqrt (delta_x (&4) (&4) (&4) x4 x5 x6))) + (&16 - x4) * delta_x4 (&4) (&4) (&4) x4 x5 x6 * inv (&2 * sqrt (delta_x (&4) (&4) (&4) x4 x5 x6)) + -- &1 * sqrt (delta_x (&4) (&4) (&4) x4 x5 x6)) + (&16 - x4) * delta_x4 (&4) (&4) (&4) x4 x5 x6 * inv (&2 * sqrt (delta_x (&4) (&4) (&4) x4 x5 x6)) + -- &1 * sqrt (delta_x (&4) (&4) (&4) x4 x5 x6)) + (&4 * dnum1 e1 e2 e3 x4 x5 x6) * &2 * (x4 * ((&16 - x4) * delta_x4 (&4) (&4) (&4) x4 x5 x6 * inv (&2 * sqrt (delta_x (&4) (&4) (&4) x4 x5 x6)) + -- &1 * sqrt (delta_x (&4) (&4) (&4) x4 x5 x6)) + (&16 - x4) * sqrt (delta_x (&4) (&4) (&4) x4 x5 x6)))) * (&2 * x4 * (&16 - x4) * sqrt (delta_x (&4) (&4) (&4) x4 x5 x6)) pow 2 - ((&4 * ((&16 - &2 * x4) * e1 + (x5 - &8) * e2 + (x6 - &8) * e3)) * &2 * x4 * (&16 - x4) * sqrt (delta_x (&4) (&4) (&4) x4 x5 x6) - num1 e1 e2 e3 x4 x5 x6 * &2 * (x4 * ((&16 - x4) * delta_x4 (&4) (&4) (&4) x4 x5 x6 * inv (&2 * sqrt (delta_x (&4) (&4) (&4) x4 x5 x6)) + -- &1 * sqrt (delta_x (&4) (&4) (&4) x4 x5 x6)) + (&16 - x4) * sqrt (delta_x (&4) (&4) (&4) x4 x5 x6))) * &2 * (&2 * x4 * (&16 - x4) * sqrt (delta_x (&4) (&4) (&4) x4 x5 x6)) pow 1 * &2 * (x4 * ((&16 - x4) * delta_x4 (&4) (&4) (&4) x4 x5 x6 * inv (&2 * sqrt (delta_x (&4) (&4) (&4) x4 x5 x6)) + -- &1 * sqrt (delta_x (&4) (&4) (&4) x4 x5 x6)) + (&16 - x4) * sqrt (delta_x (&4) (&4) (&4) x4 x5 x6))) / (&2 * x4 * (&16 - x4) * sqrt (delta_x (&4) (&4) (&4) x4 x5 x6)) pow 4)` EXISTS_TAC; REPEAT WEAKER_STRIP_TAC; CONJ_TAC; REPEAT WEAKER_STRIP_TAC; REWRITE_TAC[]; DERIVED_TAC (MP_TAC o GEN_ALL); DISCH_THEN (C INTRO_TAC [`(&4 * dnum1 e1 e2 e3 x4' x5 x6)`;`e1`;`e2`;`e3`;`delta_x4 (&4) (&4) (&4) x4' x5 x6`;`x5`;`x6`;`x4'`]); REWRITE_TAC[derived_form_dnum1;derived_form_delta_x_wrt_x4]; ONCE_REWRITE_TAC[derived_form_b]; ANTS_TAC; GMATCH_SIMP_TAC SQRT_EQ_0; BY(ASM_TAC THEN REAL_ARITH_TAC); BY(REWRITE_TAC[]); REWRITE_TAC[Nonlin_def.dnum1]; DERIVED_TAC (MP_TAC o GEN_ALL); DISCH_THEN (C INTRO_TAC [`delta_x4 (&4) (&4) (&4) x4 x5 x6`;`delta_x4 (&4) (&4) (&4) x4 x5 x6`;`-- &2 * &4`;`delta_x4 (&4) (&4) (&4) x4 x5 x6`;`delta_x4 (&4) (&4) (&4) x4 x5 x6`;`(&4 * dnum1 e1 e2 e3 x4 x5 x6)`;`e1`;`e2`;`e3`;`delta_x4 (&4) (&4) (&4) x4 x5 x6`;`x5`;`x6`;`x4`]); REWRITE_TAC[derived_form_dnum1;derived_form_delta_x_wrt_x4;derived_form_delta_x4_wrt_x4]; ONCE_REWRITE_TAC[derived_form_b]; ANTS_TAC; GMATCH_SIMP_TAC SQRT_EQ_0; BY(ASM_TAC THEN REAL_ARITH_TAC); REWRITE_TAC[]; MATCH_MP_TAC (TAUT `(x <=> y) ==> (x ==> y)`); REPEAT (AP_THM_TAC ORELSE AP_TERM_TAC); BY(REWRITE_TAC[Nonlin_def.dnum1]) ]);;
(* }}} *)
let delta_y_dim_reduction = 
prove_by_refinement( `!y1 y2 y3 y4 y5 y6. (let x6' = &8 * (&1 - (y1 * y1 + y2*y2 - y6*y6)/(&2* y1 * y2)) in let x5' = &8 * (&1 - (y1*y1 + y3*y3 - y5*y5)/(&2 * y1 * y3)) in let x4' = &8 * (&1 - (y2*y2 + y3*y3 - y4*y4)/(&2*y2*y3)) in (~(y1 = &0) /\ ~(y2 = &0) /\ ~(y3 = &0) ==> delta_x (&4) (&4) (&4) x4' x5' x6' = &64 * delta_y y1 y2 y3 y4 y5 y6 / ((y1 * y2 * y3) pow 2))) `,
(* {{{ proof *) [ REWRITE_TAC[LET_THM]; REWRITE_TAC[Sphere.delta_x;Sphere.delta_y]; BY(CONV_TAC REAL_FIELD) ]);;
(* }}} *)
let delta_x_xrr = 
prove_by_refinement( `!y1 y2 y3 y4 y5 y6. (~(y1 = &0) /\ ~(y2 = &0) /\ ~(y3 = &0) ==> delta_x (&4) (&4) (&4) (xrr y2 y3 y4) (xrr y1 y3 y5) (xrr y1 y2 y6) = &64 * delta_y y1 y2 y3 y4 y5 y6 / ((y1 *y2 * y3) pow 2))`,
(* {{{ proof *) [ REWRITE_TAC[Appendix.xrr]; REPEAT WEAKER_STRIP_TAC; BY(ASM_SIMP_TAC[GSYM (REWRITE_RULE[LET_THM] delta_y_dim_reduction)]) ]);;
(* }}} *)
let delta_x4_dim_reduction = 
prove_by_refinement( `!y1 y2 y3 y4 y5 y6. (let x6' = &8 * (&1 - (y1 * y1 + y2*y2 - y6*y6)/(&2* y1 * y2)) in let x5' = &8 * (&1 - (y1*y1 + y3*y3 - y5*y5)/(&2 * y1 * y3)) in let x4' = &8 * (&1 - (y2*y2 + y3*y3 - y4*y4)/(&2*y2*y3)) in (~(y1 = &0) /\ ~(y2 = &0) /\ ~(y3 = &0) ==> delta_x4 (&4) (&4) (&4) x4' x5' x6' = &16 * y_of_x delta_x4 y1 y2 y3 y4 y5 y6 / (y1 * y1 * y2 * y3))) `,
(* {{{ proof *) [ REWRITE_TAC[LET_THM]; REWRITE_TAC[Sphere.delta_x4;Sphere.y_of_x]; BY(CONV_TAC REAL_FIELD) ]);;
(* }}} *)
let dih_x_dim_reduction = 
prove_by_refinement( `!y1 y2 y3 y4 y5 y6. (let x6' = &8 * (&1 - (y1 * y1 + y2*y2 - y6*y6)/(&2* y1 * y2)) in let x5' = &8 * (&1 - (y1*y1 + y3*y3 - y5*y5)/(&2 * y1 * y3)) in let x4' = &8 * (&1 - (y2*y2 + y3*y3 - y4*y4)/(&2*y2*y3)) in ((&0 < y1) /\ (&0 < y2) /\ (&0 < y3) /\ &0 < delta_y y1 y2 y3 y4 y5 y6 ==> dih_x (&4) (&4) (&4) x4' x5' x6' = dih_y y1 y2 y3 y4 y5 y6)) `,
(* {{{ proof *) [ REWRITE_TAC[Sphere.dih_x;Sphere.dih_y;LET_THM]; REPEAT WEAKER_STRIP_TAC; TYPIFY `~(y1 = &0) /\ ~(y2 = &0) /\ ~(y3 = &0)` (C SUBGOAL_THEN ASSUME_TAC); BY(ASM_TAC THEN REAL_ARITH_TAC); ASM_SIMP_TAC[REWRITE_RULE[LET_THM] delta_x4_dim_reduction;REWRITE_RULE[LET_THM] delta_y_dim_reduction]; REWRITE_TAC[GSYM Sphere.y_of_x]; TYPIFY `sqrt (&4 * &4 * &64 * delta_y y1 y2 y3 y4 y5 y6 / (y1 * y2 * y3) pow 2) = &16 * sqrt (&4 * (y1 * y1) * y_of_x delta_x y1 y2 y3 y4 y5 y6) / (y1 * y1 * y2 * y3)` (C SUBGOAL_THEN SUBST1_TAC); Calc_derivative.CALC_ID_TAC; ASM_REWRITE_TAC[]; TYPIFY `&0 < y1 * y1 * y2 * y3` (C SUBGOAL_THEN ASSUME_TAC); REPEAT (GMATCH_SIMP_TAC REAL_LT_MUL); BY(ASM_TAC THEN REAL_ARITH_TAC); TYPIFY `y1 * y1 * y2 * y3 = sqrt((y1 * y1 * y2 * y3) pow 2)` (C SUBGOAL_THEN SUBST1_TAC); GMATCH_SIMP_TAC POW_2_SQRT; BY(ASM_SIMP_TAC[arith `&0 < x ==> &0 <= x`]); GMATCH_SIMP_TAC (GSYM SQRT_MUL); REWRITE_TAC[ REAL_LE_POW_2]; GMATCH_SIMP_TAC (arith `&0 <= d/ y ==> &0 <= &4 * &4 * &64 * d / y`); GMATCH_SIMP_TAC REAL_LE_RDIV_EQ; CONJ_TAC; REPEAT (GMATCH_SIMP_TAC REAL_LT_MUL); REWRITE_TAC[GSYM Trigonometry2.NOT_ZERO_EQ_POW2_LT]; REWRITE_TAC[REAL_ENTIRE]; BY(ASM_TAC THEN REAL_ARITH_TAC); CONJ_TAC; BY(ASM_TAC THEN REAL_ARITH_TAC); TYPIFY `&16 * sqrt (&4 * (y1 * y1) * y_of_x delta_x y1 y2 y3 y4 y5 y6) = sqrt (&16 pow 2 * &4 * (y1 * y1) * y_of_x delta_x y1 y2 y3 y4 y5 y6)` (C SUBGOAL_THEN SUBST1_TAC); TYPIFY `&16 = sqrt(&16 pow 2)` (C SUBGOAL_THEN SUBST1_TAC); REWRITE_TAC[POW_2_SQRT_ABS]; BY(REAL_ARITH_TAC); GMATCH_SIMP_TAC (GSYM SQRT_MUL); CONJ_TAC; CONJ_TAC; BY(REAL_ARITH_TAC); GMATCH_SIMP_TAC (arith `&0 <= x ==> &0 <= &4 * x`); GMATCH_SIMP_TAC REAL_LE_MUL; REWRITE_TAC[ REAL_LE_SQUARE]; REWRITE_TAC[Sphere.y_of_x;Sphere.delta_x;GSYM Sphere.delta_y]; BY(ASM_TAC THEN REAL_ARITH_TAC); AP_TERM_TAC; REWRITE_TAC[POW_2_SQRT_ABS]; BY(REAL_ARITH_TAC); REWRITE_TAC[arith `s - s' = &0 <=> s = s'`]; AP_TERM_TAC; REWRITE_TAC[Sphere.y_of_x;Sphere.delta_x;GSYM Sphere.delta_y]; Calc_derivative.CALC_ID_TAC; BY(ASM_REWRITE_TAC[]); TYPED_ABBREV_TAC `dx = y_of_x delta_x y1 y2 y3 y4 y5 y6` ; TYPED_ABBREV_TAC `d4 = y_of_x delta_x4 y1 y2 y3 y4 y5 y6 ` ; TYPED_ABBREV_TAC `s = sqrt(&4 * (y1 * y1) * dx)` ; REWRITE_TAC[arith `&16 * s / y = (&16 / y) * s`]; REWRITE_TAC[arith `-- (a * d4) = a * -- d4`]; GMATCH_SIMP_TAC Trigonometry1.ATN2_LMUL_EQ; GMATCH_SIMP_TAC REAL_LT_DIV; REPEAT (GMATCH_SIMP_TAC REAL_LT_MUL); BY(ASM_TAC THEN REAL_ARITH_TAC) ]);;
(* }}} *) let KPIDBQH = dih_x_dim_reduction;;
let derived_form_xrr = 
prove_by_refinement( `!y1 y2 y6. derived_form (&0 < y1 /\ &0 < y2) (\q. xrr y1 y2 q) ((&8 * y6) / (y1 * y2)) y6 (:real)`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; ASM_CASES_TAC `~(&0 < y1 /\ &0 < y2)`; BY(ASM_REWRITE_TAC[Pent_hex.derived_form_F]); RULE_ASSUM_TAC (REWRITE_RULE[]); ASM_REWRITE_TAC[Appendix.xrr]; DERIVED_TAC MP_TAC; TYPIFY `~(y1 = &0) /\ ~(y2 = &0) /\ ~(&2 = &0)` (C SUBGOAL_THEN ASSUME_TAC); BY(ASM_TAC THEN REAL_ARITH_TAC); ASM_REWRITE_TAC[]; MATCH_MP_TAC (TAUT `(x <=> y) ==> (x ==> y)`); REPEAT (AP_THM_TAC ORELSE AP_TERM_TAC); Calc_derivative.CALC_ID_TAC; BY(ASM_REWRITE_TAC[]) ]);;
(* }}} *)
let derived_form_xrr_wrt_y1 = 
prove_by_refinement( `!y1 y2 y6. derived_form (&0 < y1 /\ &0 < y2) (\q. xrr q y2 y6) ( -- &4 * ((y1*y1 + y6*y6 - y2*y2)/ (y1 pow 2 * y2))) y1 (:real)`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; ASM_CASES_TAC `~(&0 < y1 /\ &0 < y2)`; BY(ASM_REWRITE_TAC[Pent_hex.derived_form_F]); RULE_ASSUM_TAC (REWRITE_RULE[]); ASM_REWRITE_TAC[Appendix.xrr]; DERIVED_TAC MP_TAC; TYPIFY `~(y1 = &0) /\ ~(y2 = &0) /\ ~(&2 = &0)` (C SUBGOAL_THEN ASSUME_TAC); BY(ASM_TAC THEN REAL_ARITH_TAC); ASM_REWRITE_TAC[]; MATCH_MP_TAC (TAUT `(x <=> y) ==> (x ==> y)`); REPEAT (AP_THM_TAC ORELSE AP_TERM_TAC); Calc_derivative.CALC_ID_TAC; (ASM_REWRITE_TAC[]) ]);;
(* }}} *)
let derived_form_xrr_D2 = 
prove_by_refinement( `!y1 y2 y6. derived_form (&0 < y1 /\ &0 < y2) (\q. (&8* q) / (y1 *y2)) (&8 / (y1 * y2)) y6 (:real)`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; ASM_CASES_TAC `~(&0 < y1 /\ &0 < y2)`; BY(ASM_REWRITE_TAC[Pent_hex.derived_form_F]); RULE_ASSUM_TAC (REWRITE_RULE[]); ASM_REWRITE_TAC[]; DERIVED_TAC MP_TAC; ONCE_REWRITE_TAC[derived_form_b]; ANTS_TAC; BY(ASM_TAC THEN REAL_ARITH_TAC); ASM_REWRITE_TAC[]; MATCH_MP_TAC (TAUT `(x <=> y) ==> (x ==> y)`); REPEAT (AP_THM_TAC ORELSE AP_TERM_TAC); Calc_derivative.CALC_ID_TAC; BY(ASM_TAC THEN REAL_ARITH_TAC) ]);;
(* }}} *)
let derived_form_xrr_D3 = 
prove_by_refinement( `!y1 y2 y6. derived_form (&0 < y1 /\ &0 < y2) (\q. (&8) / (y1 *y2)) (&0) y6 (:real)`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; ASM_CASES_TAC `~(&0 < y1 /\ &0 < y2)`; BY(ASM_REWRITE_TAC[Pent_hex.derived_form_F]); RULE_ASSUM_TAC (REWRITE_RULE[]); ASM_REWRITE_TAC[]; DERIVED_TAC MP_TAC; BY(REWRITE_TAC[]) ]);;
(* }}} *) let DRNDRDV = derived_form_xrr;;
let derived_form_unique = 
prove_by_refinement( `!f f' f'' x. derived_form T f f' x (:real) /\ derived_form T f f'' x (:real) ==> (f' = f'')`,
(* {{{ proof *) [ REWRITE_TAC[Calc_derivative.derived_form;WITHINREAL_UNIV]; BY(MESON_TAC[REAL_DERIVATIVE_UNIQUE_ATREAL]) ]);;
(* }}} *)
let derived_form_chain = 
prove_by_refinement( `!f f' g g' x y. f x = y /\ derived_form T f f' x (:real) /\ derived_form T g g' y (:real) ==> derived_form T (g o f) (g' * f') x (:real) `,
(* {{{ proof *) [ REPEAT GEN_TAC; TYPIFY `g o f = \q. g(f(q))` (C SUBGOAL_THEN SUBST1_TAC); BY(REWRITE_TAC[FUN_EQ_THM;o_THM]); REPEAT WEAKER_STRIP_TAC; MP_TAC (GEN_ALL (Calc_derivative.differentiate `(\(q:real). (g:real->real) (f q))` `x:real` `(:real)`)); DISCH_THEN (C INTRO_TAC [`g`;`f`;`f'`;`g'`;`x`]); ASM_REWRITE_TAC[]; BY(REWRITE_TAC[REAL_MUL_AC]) ]);;
(* }}} *)
let derived_form_chain_old = 
prove_by_refinement( `!f f' g g' h' x y. f x = y /\ derived_form T f f' x (:real) /\ derived_form T g g' y (:real) /\ derived_form T (g o f) h' x (:real) ==> h' = g' * f' `,
(* {{{ proof *) [ REPEAT GEN_TAC; TYPIFY `g o f = \q. g(f(q))` (C SUBGOAL_THEN SUBST1_TAC); BY(REWRITE_TAC[FUN_EQ_THM;o_THM]); REPEAT WEAKER_STRIP_TAC; MP_TAC (GEN_ALL (Calc_derivative.differentiate `(\(q:real). (g:real->real) (f q))` `x:real` `(:real)`)); DISCH_THEN (C INTRO_TAC [`g`;`f`;`f'`;`g'`;`x`]); ASM_REWRITE_TAC[]; DISCH_TAC; TYPIFY `h' = f' * g'` (C SUBGOAL_THEN SUBST1_TAC); INTRO_TAC derived_form_unique [`(\q. g (f q))`;`h'`;`f'*g'`;`x`]; DISCH_THEN MATCH_MP_TAC; BY(ASM_REWRITE_TAC[]); BY(REAL_ARITH_TAC) ]);;
(* }}} *)
let xrr_sym = 
prove_by_refinement( `!y1 y2 y6. xrr y1 y2 y6 = xrr y2 y1 y6`,
(* {{{ proof *) [ REWRITE_TAC[Appendix.xrr]; REPEAT WEAKER_STRIP_TAC; REWRITE_TAC[REAL_MUL_AC]; BY(REWRITE_TAC[arith `x + y -z = (x + y) -z`;REAL_ADD_AC]) ]);;
(* }}} *)
let taum_compose_xrr = 
prove_by_refinement( `!y1 y2 y3 y4 y5 y6. (let e1 = rho y1 in let e2 = rho y2 in let e3 = rho y3 in let x5 = xrr y1 y3 y5 in let x6 = xrr y1 y2 y6 in ( &0 < y1 /\ &0 < y2 /\ &0 < y3 /\ &0 < delta_y y1 y2 y3 y4 y5 y6 ==> (\q. taum y1 y2 y3 q y5 y6) y4 = ((\q. e1 * dih_x (&4) (&4) (&4) q x5 x6 + e2 * dih_x (&4) (&4) (&4) x5 x6 q + e3 * dih_x (&4) (&4) (&4) x6 q x5 - (&1 + const1) * pi) o (\q. xrr y2 y3 q)) y4))`,
(* {{{ proof *) [ REWRITE_TAC[LET_DEF;LET_END_DEF]; REWRITE_TAC[o_THM;Nonlinear_lemma.taum_123]; REWRITE_TAC[Sphere.rhazim;Sphere.rhazim2;Sphere.rhazim3;Sphere.node2_y;Sphere.node3_y]; REPEAT WEAKER_STRIP_TAC; TYPIFY `dih_x (&4) (&4) (&4) (xrr y1 y3 y5) (xrr y1 y2 y6) (xrr y2 y3 y4) = dih_x (&4) (&4) (&4) (xrr y1 y3 y5) (xrr y2 y3 y4) (xrr y2 y1 y6)` (C SUBGOAL_THEN SUBST1_TAC); BY(MESON_TAC[xrr_sym;Nonlinear_lemma.dih_x_sym]); TYPIFY `dih_x (&4) (&4) (&4) (xrr y1 y2 y6) (xrr y2 y3 y4) (xrr y1 y3 y5) = dih_x (&4) (&4) (&4) (xrr y1 y2 y6) (xrr y3 y2 y4) (xrr y3 y1 y5)` (C SUBGOAL_THEN SUBST1_TAC); BY(MESON_TAC[xrr_sym]); REWRITE_TAC[Appendix.xrr]; REPEAT (GMATCH_SIMP_TAC (REWRITE_RULE[LET_THM] dih_x_dim_reduction)); ASM_REWRITE_TAC[]; REWRITE_TAC[Nonlinear_lemma.dih_y_sym]; FIRST_X_ASSUM MP_TAC; BY(REWRITE_TAC[Merge_ineq.delta_y_sym;]) ]);;
(* }}} *)
let real_open_univ = 
prove_by_refinement( `real_open (:real)`,
(* {{{ proof *) [ REWRITE_TAC[real_open;IN_UNIV]; TYPIFY `&1` EXISTS_TAC; BY(REAL_ARITH_TAC) ]);;
(* }}} *)
let real_open_empty = 
prove_by_refinement( `real_open ({})`,
(* {{{ proof *) [ BY(REWRITE_TAC[real_open;NOT_IN_EMPTY]) ]);;
(* }}} *)
let real_open_delta_y = 
prove_by_refinement( `!y1 y2 y3 y5 y6. real_open {y4 | &0 < y4 /\ &0 < delta_y y1 y2 y3 y4 y5 y6}`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; INTRO_TAC Pent_hex.continuous_preimage_open [`(\q. delta_y y1 y2 y3 q y5 y6)`; `{y4 | &0 < y4}`;`{y | &0 < y}`]; REWRITE_TAC[IN_ELIM_THM;]; DISCH_THEN MATCH_MP_TAC; TYPIFY_GOAL_THEN `real_open {u | &0 < u}` (unlist REWRITE_TAC); BY(REWRITE_TAC[arith `a < b <=> b > a`;REAL_OPEN_HALFSPACE_GT]); REWRITE_TAC[REAL_CONTINUOUS_ON_EQ_CONTINUOUS_WITHIN;IN_ELIM_THM]; REPEAT WEAKER_STRIP_TAC; MATCH_MP_TAC REAL_CONTINUOUS_ATREAL_WITHINREAL; MATCH_MP_TAC HAS_REAL_DERIVATIVE_IMP_CONTINUOUS_ATREAL; TYPIFY `?f. derived_form T (\q. delta_y y1 y2 y3 q y5 y6) f x (:real)` (C SUBGOAL_THEN MP_TAC); REWRITE_TAC[Sphere.delta_y;Sphere.delta_x]; TYPIFY `((y1 * y1) * ((x * x) * --(x + x) + (x + x) * (--(y1 * y1) + y2 * y2 + y3 * y3 - x * x + y5 * y5 + y6 * y6)) + (y2 * y2) * (y5 * y5) * (x + x) + (y3 * y3) * (y6 * y6) * (x + x) - (y2 * y2) * (y3 * y3) * (x + x) - (x + x) * (y5 * y5) * y6 * y6)` EXISTS_TAC; DERIVED_TAC MP_TAC; BY(REWRITE_TAC[]); BY(REWRITE_TAC[Calc_derivative.derived_form;WITHINREAL_UNIV]) ]);;
(* }}} *)
let real_open_ups_y = 
prove_by_refinement( `!y1 y2. real_open {y6 | &0 < ups_x (y1*y1) (y2*y2) (y6*y6) }`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; INTRO_TAC Pent_hex.continuous_preimage_open [`(\q. ups_x (y1*y1) (y2*y2) (q*q))`; `(:real)`;`{y | &0 < y}`]; REWRITE_TAC[IN_ELIM_THM;IN_UNIV]; DISCH_THEN MATCH_MP_TAC; TYPIFY_GOAL_THEN `real_open {u | &0 < u}` (unlist REWRITE_TAC); BY(REWRITE_TAC[arith `a < b <=> b > a`;REAL_OPEN_HALFSPACE_GT]); REWRITE_TAC[real_open_univ]; REWRITE_TAC[REAL_CONTINUOUS_ON_EQ_CONTINUOUS_WITHIN;IN_ELIM_THM]; REPEAT WEAKER_STRIP_TAC; MATCH_MP_TAC REAL_CONTINUOUS_ATREAL_WITHINREAL; MATCH_MP_TAC HAS_REAL_DERIVATIVE_IMP_CONTINUOUS_ATREAL; TYPIFY `derived_form T ((\q. ups_x (y1 * y1) (y2 * y2) (q * q))) ((--((x * x) * (x + x) + (x + x) * x * x) + &2 * (y1 * y1) * (x + x) + &2 * (y2 * y2) * (x + x))) x (:real)` (C SUBGOAL_THEN MP_TAC); REWRITE_TAC[Sphere.ups_x]; DERIVED_TAC (MP_TAC); BY(REWRITE_TAC[]); (REWRITE_TAC[Calc_derivative.derived_form;WITHINREAL_UNIV]); BY(MESON_TAC[]) ]);;
(* }}} *)
let derived_form_local = 
prove_by_refinement( `!f g g' s x b. derived_form b g g' x (:real) /\ real_open s /\ x IN s /\ (!y. y IN s ==> f y = g y) ==> derived_form b f g' x (:real) `,
(* {{{ proof *) [ REWRITE_TAC[Calc_derivative.derived_form;WITHINREAL_UNIV]; REPEAT WEAKER_STRIP_TAC; MATCH_MP_TAC Arc_properties.HAS_REAL_DERIVATIVE_LOCAL; BY(ASM_MESON_TAC[]) ]);;
(* }}} *)
let xrr_factor = 
prove_by_refinement( `!y1 y2 y6. &0 < y1 /\ &0 < y2 ==> (xrr y1 y2 y6 = &4 * ((y6 + y2 - y1) * (y6 - y2 + y1))/(y1 * y2))`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; REWRITE_TAC[Appendix.xrr]; Calc_derivative.CALC_ID_TAC; BY(ASM_TAC THEN REAL_ARITH_TAC) ]);;
(* }}} *)
let xrr_factor_8 = 
prove_by_refinement( `!y1 y2 y6. &0 < y1 /\ &0 < y2 ==> (&16 - xrr y1 y2 y6 = &4* ((y6 + y2 + y1) * ( y2 + y1- y6))/(y1 * y2))`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; REWRITE_TAC[Appendix.xrr]; Calc_derivative.CALC_ID_TAC; BY(ASM_TAC THEN REAL_ARITH_TAC) ]);;
(* }}} *)
let xrr_pos = 
prove_by_refinement( `!y1 y2 y6. &0 < y1 /\ &0 < y2 /\ y1 < y2 + y6 /\ y2 < y1 + y6 ==> &0 < xrr y1 y2 y6`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; REWRITE_TAC[Appendix.xrr]; MATCH_MP_TAC (arith `&0 < x ==> &0 < &8 * x`); TYPIFY `&1 - (y1 * y1 + y2 * y2 - y6 * y6) / (&2 * y1 * y2) = ((y6 + y2 - y1) * (y6 - y2 + y1))/(&2 * y1 * y2)` (C SUBGOAL_THEN SUBST1_TAC); Calc_derivative.CALC_ID_TAC; BY(ASM_TAC THEN REAL_ARITH_TAC); GMATCH_SIMP_TAC REAL_LT_RDIV_EQ; REWRITE_TAC[arith `&0 * x = &0`]; GMATCH_SIMP_TAC REAL_LT_MUL_EQ; REPEAT (GMATCH_SIMP_TAC REAL_LT_MUL_EQ); BY(ASM_TAC THEN REAL_ARITH_TAC) ]);;
(* }}} *)
let xrr_lt_16 = 
prove_by_refinement( `!y1 y2 y6. &0 < y1 /\ &0 < y2 /\ y6 < y1 + y2 /\ &0 < y6 ==> xrr y1 y2 y6 < &16`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; REWRITE_TAC[Appendix.xrr]; MATCH_MP_TAC (arith `&0 < &1 + u ==> &8 * (&1 - u) < &16`); TYPIFY `&1 + (y1 * y1 + y2 * y2 - y6 * y6) / (&2 * y1 * y2) = ((y6 + y2 + y1) * ( y2 + y1- y6))/(&2 * y1 * y2)` (C SUBGOAL_THEN SUBST1_TAC); Calc_derivative.CALC_ID_TAC; BY(ASM_TAC THEN REAL_ARITH_TAC); GMATCH_SIMP_TAC REAL_LT_RDIV_EQ; REWRITE_TAC[arith `&0 * x = &0`]; REPEAT (GMATCH_SIMP_TAC REAL_LT_MUL_EQ); BY(ASM_TAC THEN REAL_ARITH_TAC) ]);;
(* }}} *)
let ups_x_triangle_ineq = 
prove_by_refinement( `!y1 y2 y6. &0 < y1 /\ &0 < y2 /\ &0 < y6 ==> (&0 < ups_x (y1*y1) (y2*y2) (y6*y6) <=> (y1 < y2 + y6 /\ y2 < y1 + y6 /\ y6 < y1 + y2))`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; TYPIFY `ups_x (y1*y1) (y2*y2) (y6*y6) = (y1 - y2 + y6) * (y1 + y2 - y6) * (-- y1 + y2 + y6) * (y1 + y2 + y6) ` (C SUBGOAL_THEN SUBST1_TAC); REWRITE_TAC[Sphere.ups_x]; BY(REAL_ARITH_TAC); REPEAT WEAKER_STRIP_TAC; REWRITE_TAC[REAL_MUL_POS_LT;arith `x * y < &0 <=> &0 < (--x ) * y`]; ASM_CASES_TAC `y2 < y1 + y6`; BY(ASM_TAC THEN REAL_ARITH_TAC); BY(ASM_TAC THEN REAL_ARITH_TAC) ]);;
(* }}} *)
let xrr_bounds = 
prove_by_refinement( `!y1 y2 y6. &0 < y1 /\ &0 < y2 /\ &0 < y6 /\ &0 < ups_x (y1*y1) (y2*y2) (y6*y6) ==> (&0 < xrr y1 y2 y6 /\ xrr y1 y2 y6 < &16)`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; INTRO_TAC ups_x_triangle_ineq [`y1`;`y2`;`y6`]; ANTS_TAC; BY(ASM_REWRITE_TAC[]); DISCH_THEN (RULE_ASSUM_TAC o (unlist REWRITE_RULE)); CONJ_TAC; MATCH_MP_TAC xrr_pos; BY(ASM_REWRITE_TAC[]); MATCH_MP_TAC xrr_lt_16; BY(ASM_REWRITE_TAC[]) ]);;
(* }}} *)
let xrr_bounds_2 = 
prove_by_refinement( `!y1 y2 y6. &0 < y1 /\ &0 < y2 /\ &0 < y6 ==> (&0 < ups_x (y1*y1) (y2*y2) (y6*y6) <=> &0 < xrr y1 y2 y6 /\ xrr y1 y2 y6 < &16)`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; REWRITE_TAC[ (TAUT `(a <=>b) <=> ((a ==> b) /\ (b ==> a) )`)]; CONJ_TAC; BY(ASM_MESON_TAC[xrr_bounds]); ASM_SIMP_TAC[ups_x_triangle_ineq]; ONCE_REWRITE_TAC[arith `x < &16 <=> &0 < &16- x`]; ASM_SIMP_TAC[xrr_factor_8]; ASM_SIMP_TAC[xrr_factor]; ONCE_REWRITE_TAC[arith `&0 < &4 * x <=> &0 < x`]; REPEAT (GMATCH_SIMP_TAC Trigonometry2.REAL_LT_DIV_0); TYPIFY_GOAL_THEN `&0 < y1 * y2` (unlist REWRITE_TAC); GMATCH_SIMP_TAC REAL_LT_MUL_EQ; BY(ASM_REWRITE_TAC[]); REWRITE_TAC[REAL_MUL_POS_LT]; BY(ASM_TAC THEN REAL_ARITH_TAC) ]);;
(* }}} *)
let xrr_le_16 = 
prove_by_refinement( `!y1 y2 y6. &0 < y1 /\ &0 < y2 /\ &0 < y6 /\ &0 < ups_x (y1*y1) (y2*y2) (y6*y6) ==> xrr y1 y2 y6 <= &16`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; MATCH_MP_TAC (arith `x < y ==> x <= y`); BY(ASM_MESON_TAC[xrr_bounds_2]) ]);;
(* }}} *)
let arclength_xrr = 
prove_by_refinement( `!y1 y2 y6. &0 < y1 /\ &0 < y2 /\ &0 < y6 /\ &0 < ups_x (y1*y1) (y2*y2) (y6*y6) ==> arclength y1 y2 y6 = acs(&1 - xrr y1 y2 y6 / &8)`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; INTRO_TAC ups_x_triangle_ineq [`y1`;`y2`;`y6`]; ANTS_TAC; BY(ASM_REWRITE_TAC[]); DISCH_THEN (RULE_ASSUM_TAC o (unlist REWRITE_RULE)); REWRITE_TAC[Appendix.xrr]; GMATCH_SIMP_TAC Trigonometry.PQQDENV; ASM_SIMP_TAC[arith `a < b ==> a <= b`]; CONJ_TAC; BY(ASM_TAC THEN REAL_ARITH_TAC); AP_TERM_TAC; Calc_derivative.CALC_ID_TAC; BY(ASM_TAC THEN REAL_ARITH_TAC) ]);;
(* }}} *)
let TBRMXRZ1 = 
prove_by_refinement( `!f f' g g' h' x y. derived_form T f f' x (:real) /\ derived_form T g g' y (:real) /\ derived_form T (g o f) h' x (:real) /\ &0 < f' /\ f x = y ==> re_eqvl h' g'`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; INTRO_TAC derived_form_chain_old [`f`;`f'`;`g`;`g'`;`h'`;`x`;`y`]; ASM_REWRITE_TAC[]; DISCH_THEN SUBST1_TAC; REWRITE_TAC[Trigonometry2.re_eqvl]; EXISTS_TAC `f':real`; ASM_REWRITE_TAC[]; BY(REAL_ARITH_TAC) ]);;
(* }}} *)
let TBRMXRZ2 = 
prove_by_refinement( `!P Q f f' f'' g g' g'' h' h'' x y. (P x) /\ (Q (f x)) /\ (y = f x) /\ &0 < f' x /\ h' x = &0 /\ real_open {x | P x /\ Q (f x) } /\ (!x. derived_form (P x) f (f' x) x (:real)) /\ (!y. derived_form (Q( y)) g (g' y) y (:real)) /\ (!x. derived_form (P x /\ Q (f x)) (g o f) (h' x) x (:real)) /\ derived_form T f' f'' x (:real) /\ derived_form T g' g'' y (:real) /\ derived_form T h' h'' x (:real) ==> re_eqvl h'' g''`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; TYPIFY `!x. P x /\ Q (f x) ==> h' x = g' (f x) * f' x` (C SUBGOAL_THEN ASSUME_TAC); REPEAT WEAKER_STRIP_TAC; INTRO_TAC derived_form_chain_old [`f`;`f' x'`;`g`;`g' (f x')`;`h' x'`;`x'`;`f x'`]; DISCH_THEN MATCH_MP_TAC; ASM_REWRITE_TAC[]; RULE_ASSUM_TAC(ONCE_REWRITE_RULE[derived_form_b]); BY(ASM_SIMP_TAC[]); TYPIFY `derived_form T (\q. g' (f q) * f' q) h'' x (:real)` (C SUBGOAL_THEN ASSUME_TAC); REWRITE_TAC[Calc_derivative.derived_form;WITHINREAL_UNIV]; MATCH_MP_TAC Arc_properties.HAS_REAL_DERIVATIVE_LOCAL; TYPIFY `h'` EXISTS_TAC; CONJ_TAC; FIRST_X_ASSUM_ST `derived_form` MP_TAC; BY(REWRITE_TAC[Calc_derivative.derived_form;WITHINREAL_UNIV]); TYPIFY `{ x | P x /\ Q (f x)}` EXISTS_TAC; ASM_REWRITE_TAC[IN_ELIM_THM]; BY(FIRST_X_ASSUM MP_TAC THEN MESON_TAC[]); MP_TAC (GEN_ALL (Calc_derivative.differentiate `(\(q:real). (g':real->real) (f q) * f' q)` `x:real` `(:real)`)); DISCH_THEN (C INTRO_TAC [`g'`;`f`;`f''`;`f' x`;`g''`;`f'`;`x`]); ASM_REWRITE_TAC[]; TYPIFY_GOAL_THEN `(derived_form T g' g'' (f x) (:real) /\ derived_form T f (f' x) x (:real))` (unlist REWRITE_TAC); CONJ_TAC; BY(ASM_MESON_TAC[]); RULE_ASSUM_TAC (ONCE_REWRITE_RULE[derived_form_b]); FIRST_X_ASSUM MATCH_MP_TAC; BY(ASM_REWRITE_TAC[]); DISCH_TAC; INTRO_TAC derived_form_unique [`(\q. g' (f q) * f' q)`;`h''`;`(g' (f x) * f'' + (f' x * g'') * f' x)`;`x`]; ASM_REWRITE_TAC[]; DISCH_THEN SUBST1_TAC; INTRO_TAC TBRMXRZ1 [`f`;`f' x`;`g`;`g' y`;`h' x`;`x`;`y`]; ANTS_TAC; RULE_ASSUM_TAC (ONCE_REWRITE_RULE[derived_form_b]); BY(ASM_MESON_TAC[]); DISCH_TAC; RULE_ASSUM_TAC(ONCE_REWRITE_RULE[Leaf_cell.RE_EQVL_SYM]); FIRST_X_ASSUM MP_TAC; ASM_REWRITE_TAC[Trigonometry2.re_eqvl]; REPEAT WEAKER_STRIP_TAC; ASM_REWRITE_TAC[]; TYPIFY `f' x * f' x` EXISTS_TAC; GMATCH_SIMP_TAC REAL_LT_MUL_EQ; ASM_REWRITE_TAC[]; BY(REAL_ARITH_TAC) ]);;
(* }}} *)
let SECOND_CHAIN_GENERAL = 
prove_by_refinement( `!P Q f f' f'' g g' g'' x y. (P x) /\ (Q (f x)) /\ (f x = y) /\ real_open {x | P x /\ Q (f x) } /\ (!x. derived_form (P x) f (f' x) x (:real)) /\ (!y. derived_form (Q( y)) g (g' y) y (:real)) /\ derived_form T f' f'' x (:real) /\ derived_form T g' g'' y (:real) ==> derived_form T (\q. g' (f q) * f' q) (g' y * f'' + g'' * f' x pow 2 ) x (:real)`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; MP_TAC (GEN_ALL (Calc_derivative.differentiate `(\(q:real). (g':real->real) (f q) * f' q)` `x:real` `(:real)`)); DISCH_THEN (C INTRO_TAC [`g'`;`f`;`f''`;`f' x`;`g''`;`f'`;`x`]); ASM_REWRITE_TAC[]; ONCE_REWRITE_TAC[derived_form_b]; ANTS_TAC; RULE_ASSUM_TAC (ONCE_REWRITE_RULE[derived_form_b]); BY(ASM_MESON_TAC[]); ASM_REWRITE_TAC[]; MATCH_MP_TAC (TAUT `(x <=> y) ==> (x ==> y)`); REPEAT (AP_THM_TAC ORELSE AP_TERM_TAC); BY(REAL_ARITH_TAC) ]);;
(* }}} *)
let SECOND_CHAIN_CRITICAL = 
prove_by_refinement( `!P Q f f' f'' g g' g'' x y. (P x) /\ (Q (f x)) /\ (f x = y) /\ g' y = &0 /\ real_open {x | P x /\ Q (f x) } /\ (!x. derived_form (P x) f (f' x) x (:real)) /\ (!y. derived_form (Q( y)) g (g' y) y (:real)) /\ derived_form T f' f'' x (:real) /\ derived_form T g' g'' y (:real) ==> derived_form T (\q. g' (f q) * f' q) (g'' * (f' x) pow 2) x (:real)`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; MP_TAC (GEN_ALL (Calc_derivative.differentiate `(\(q:real). (g':real->real) (f q) * f' q)` `x:real` `(:real)`)); DISCH_THEN (C INTRO_TAC [`g'`;`f`;`f''`;`f' x`;`g''`;`f'`;`x`]); ASM_REWRITE_TAC[]; ONCE_REWRITE_TAC[derived_form_b]; ANTS_TAC; RULE_ASSUM_TAC (ONCE_REWRITE_RULE[derived_form_b]); BY(ASM_MESON_TAC[]); ASM_REWRITE_TAC[]; MATCH_MP_TAC (TAUT `(x <=> y) ==> (x ==> y)`); REPEAT (AP_THM_TAC ORELSE AP_TERM_TAC); BY(REAL_ARITH_TAC) ]);;
(* }}} *)
let THIRD_CHAIN_GENERAL = 
prove_by_refinement( `!P Q f f' f'' f''' g g' g'' g''' x y. (P x) /\ (Q (f x)) /\ (f x = y) /\ real_open {x | P x /\ Q (f x) } /\ (!x. derived_form (P x) f (f' x) x (:real)) /\ (!y. derived_form (Q( y)) g (g' y) y (:real)) /\ (!x. derived_form (P x) f' (f'' x) x (:real)) /\ (!y. derived_form (Q y) g' (g'' y) y (:real)) /\ derived_form (P x) f'' f''' x (:real) /\ derived_form (Q y) g'' g''' y (:real) ==> (?h'''. derived_form T (\ (q:real). (g' (f q) * f'' q + g'' (f q) * f' q pow 2 )) h''' x (:real))`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; TYPIFY `(g' y * f''' + (f' x * g'' y) * f'' x) + g'' y * &2 * f' x pow 1 * f'' x + (f' x * g''') * f' x pow 2` EXISTS_TAC; MP_TAC (GEN_ALL (Calc_derivative.differentiate `(\ (q:real). (g' ((f:real->real) q) * f'' q + g'' (f q) * f' q pow 2 ))` `x:real` `(:real)`)); DISCH_THEN (C INTRO_TAC [`g'`; `f'''`;`f' x`;`g'' y`; `f''`;`g''`;`f`; `f'' x`;`f' x`;`g'''`;`f'`;`x`]); ASM_REWRITE_TAC[]; ONCE_REWRITE_TAC[derived_form_b]; ANTS_TAC; RULE_ASSUM_TAC (ONCE_REWRITE_RULE[derived_form_b]); BY(ASM_MESON_TAC[]); BY(ASM_REWRITE_TAC[]) ]);;
(* }}} *)
let SECOND_CHAIN_CONTINUOUS = 
prove_by_refinement( `!P Q f f' f'' f''' g g' g'' g''' x y. (P x) /\ (Q (f x)) /\ (f x = y) /\ real_open {x | P x /\ Q (f x) } /\ (!x. derived_form (P x) f (f' x) x (:real)) /\ (!y. derived_form (Q( y)) g (g' y) y (:real)) /\ (!x. derived_form (P x) f' (f'' x) x (:real)) /\ (!y. derived_form (Q y) g' (g'' y) y (:real)) /\ derived_form (P x) f'' f''' x (:real) /\ derived_form (Q y) g'' g''' y (:real) ==> (\ (q:real). (g' (f q) * f'' q + g'' (f q) * f' q pow 2 )) real_continuous atreal x`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; MATCH_MP_TAC HAS_REAL_DERIVATIVE_IMP_CONTINUOUS_ATREAL; INTRO_TAC THIRD_CHAIN_GENERAL [`P`;`Q`;`f`;`f'`;`f''`;`f'''`;`g`;`g'`;`g''`;`g'''`;`x`;`y`]; ASM_REWRITE_TAC[]; BY(REWRITE_TAC[Calc_derivative.derived_form;WITHINREAL_UNIV]) ]);;
(* }}} *)
let SECOND_DERIVATIVE_TEST_COMPOSE = 
prove_by_refinement( `!P Q x y s f f' f'' f''' g g' g'' g'''. P x /\ Q (f x) /\ (f x = y) /\ &0 < f' x /\ s SUBSET {x | P x /\ Q (f x)} /\ real_open {x | P x /\ Q (f x) } /\ real_open s /\ x IN s /\ (!x'. x' IN s ==> g(f x) <= g(f x') ) /\ (!x. derived_form (P x) f (f' x) x (:real)) /\ (!x. derived_form (P x) f' (f'' x) x (:real)) /\ derived_form (P x) f'' f''' x (:real) /\ (!y. derived_form (Q( y)) g (g' y) y (:real)) /\ (!y. derived_form (Q y) g' (g'' y) y (:real)) /\ derived_form (Q y) g'' g''' y (:real) ==> (g' y = &0 /\ &0 <= g'' y) `,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; INTRO_TAC Pent_hex.SECOND_DERIVATIVE_TEST [`g o f`;`(\q. g' (f q) * f' q)`;`(\ (q:real). (g' (f q) * f'' q + g'' (f q) * f' q pow 2 ))`;`x`;`s`]; ANTS_TAC; ASM_REWRITE_TAC[]; TYPIFY_GOAL_THEN `(\q. g' (f q) * f'' q + g'' (f q) * f' q pow 2) real_continuous atreal x` (unlist REWRITE_TAC); MATCH_MP_TAC SECOND_CHAIN_CONTINUOUS; BY(ASM_MESON_TAC[]); TYPIFY_GOAL_THEN `(!x'. x' IN s ==> (g o f) x <= (g o f) x')` (unlist REWRITE_TAC); BY(ASM_MESON_TAC[o_THM]); CONJ_TAC; REPEAT WEAKER_STRIP_TAC; INTRO_TAC derived_form_chain [`f`;`f' x'`;`g`;`g' (f x')`;`x'`;`f x'`]; RULE_ASSUM_TAC (ONCE_REWRITE_RULE[derived_form_b]); ANTS_TAC; TYPIFY `P x' /\ Q(f x')` (C SUBGOAL_THEN ASSUME_TAC); BY(ASM_TAC THEN SET_TAC[]); BY(ASM_MESON_TAC[]); BY(REWRITE_TAC[Calc_derivative.derived_form;WITHINREAL_UNIV]); REPEAT WEAKER_STRIP_TAC; TYPIFY `P x' /\ Q(f x')` (C SUBGOAL_THEN ASSUME_TAC); BY(ASM_TAC THEN SET_TAC[]); INTRO_TAC SECOND_CHAIN_GENERAL [`P`;`Q`;`f`;`f'`;`f'' x'`;`g`;`g'`;`g'' (f x')`;`x'`;`f x'`]; ANTS_TAC; ASM_REWRITE_TAC[]; RULE_ASSUM_TAC(ONCE_REWRITE_RULE[derived_form_b]); BY(ASM_MESON_TAC[]); BY(ASM_REWRITE_TAC[Calc_derivative.derived_form;WITHINREAL_UNIV]); ASM_REWRITE_TAC[]; REPEAT WEAKER_STRIP_TAC; SUBCONJ_TAC; FIRST_X_ASSUM_ST `gf = &0` MP_TAC; REWRITE_TAC[REAL_ENTIRE]; BY(ASM_SIMP_TAC[arith `&0 < f' ==> ~(f' = &0)`]); DISCH_TAC; FIRST_X_ASSUM_ST `&0 <= stuff` MP_TAC; ASM_REWRITE_TAC[]; ASM_REWRITE_TAC[arith `&0 * x + u = u`]; REPEAT WEAKER_STRIP_TAC; MATCH_MP_TAC Real_ext.REAL_PROP_NN_RCANCEL; TYPIFY `f' x pow 2` EXISTS_TAC; ASM_REWRITE_TAC[]; REWRITE_TAC[arith `x pow 2 = x * x`]; GMATCH_SIMP_TAC REAL_LT_MUL_EQ; BY(ASM_REWRITE_TAC[]) ]);;
(* }}} *)
let REAL_OPEN_REAL_INTERVAL = 
prove_by_refinement( `!a b. real_open(real_interval(a,b))`,
(* {{{ proof *) [ REWRITE_TAC[real_open;IN_REAL_INTERVAL]; REPEAT WEAKER_STRIP_TAC; TYPIFY `real_min (x - a) (b - x)` EXISTS_TAC; REWRITE_TAC[real_min]; COND_CASES_TAC; BY(ASM_TAC THEN REAL_ARITH_TAC); BY(ASM_TAC THEN REAL_ARITH_TAC) ]);;
(* }}} *)
let delta_y_pos_xrr = 
prove_by_refinement( `!y1 y2 y3 y4 y5 y6. &0 < y1 /\ &0 < y2 /\ &0 < y3 ==> (&0 < delta_y y1 y2 y3 y4 y5 y6 <=> &0 < delta_x (&4) (&4) (&4) (xrr y2 y3 y4) (xrr y1 y3 y5) (xrr y1 y2 y6)) `,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; GMATCH_SIMP_TAC delta_x_xrr; ASM_SIMP_TAC[arith `&0 < y ==> ~(y= &0)`]; REWRITE_TAC[arith `&0 < &64 * x <=> &0 < x`]; GMATCH_SIMP_TAC Trigonometry2.REAL_LT_DIV_0; REWRITE_TAC[GSYM Trigonometry2.NOT_ZERO_EQ_POW2_LT]; REWRITE_TAC[REAL_ENTIRE]; BY(ASM_TAC THEN REAL_ARITH_TAC) ]);;
(* }}} *)
let xrr_convert = 
prove_by_refinement( `!y1 y2 y3 y5 y6. &0 < y1 /\ &0 < y2 /\ &0 < y3 /\ &0 < y5 /\ &0 < y6 /\ &0 < ups_x (y1*y1) (y3*y3) (y5*y5) /\ &0 < ups_x (y1*y1) (y2*y2) (y6*y6) ==> { y | &0 < y /\ &0 < xrr y2 y3 y /\ xrr y2 y3 y < &16 /\ &0 < delta_x (&4) (&4) (&4) (xrr y2 y3 y) (xrr y1 y3 y5) (xrr y1 y2 y6)} = { y | &0 < y /\ &0 < ups_x (y2*y2) (y3*y3) (y*y) /\ &0 < delta_y y1 y2 y3 y y5 y6 }`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; REWRITE_TAC[FUN_EQ_THM;IN_ELIM_THM]; GEN_TAC; ASM_CASES_TAC `~(&0<x)`; BY(ASM_REWRITE_TAC[]); RULE_ASSUM_TAC (REWRITE_RULE[]); ASM_REWRITE_TAC[]; GMATCH_SIMP_TAC (GSYM delta_y_pos_xrr); ASM_REWRITE_TAC[]; ASM_SIMP_TAC[xrr_bounds_2]; BY(MESON_TAC[]) ]);;
(* }}} *)
let SECOND_DERIVATIVE_TEST_TAUM = 
prove_by_refinement( `!a b y1 y2 y3 y4 y5 y6. y4 IN real_interval (a,b) /\ real_interval (a,b) SUBSET {y4 | &0 < delta_y y1 y2 y3 y4 y5 y6 /\ &0 < y4 /\ &0 < ups_x (y2*y2) (y3*y3) (y4*y4)} /\ &0 < y1 /\ &0 < y2 /\ &0 < y3 /\ &0 < y5 /\ &0 < y6 /\ &0 < ups_x (y1*y1) (y2*y2) (y6*y6) /\ &0 < ups_x (y1*y1) (y3*y3) (y5*y5) /\ (num1 (rho y1) (rho y2) (rho y3) (xrr y2 y3 y4) (xrr y1 y3 y5) (xrr y1 y2 y6) = &0 ==> dnum1 (rho y1) (rho y2) (rho y3) (xrr y2 y3 y4) (xrr y1 y3 y5) (xrr y1 y2 y6) < &0) ==> (?y4'. y4' IN real_interval(a,b) /\ taum y1 y2 y3 y4' y5 y6 < taum y1 y2 y3 y4 y5 y6)`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; PROOF_BY_CONTR_TAC; RULE_ASSUM_TAC (REWRITE_RULE[NOT_EXISTS_THM;TAUT `~(a /\ b) <=> (a ==> ~b)`]); RULE_ASSUM_TAC (REWRITE_RULE[arith `~(x < y) <=> y <= x`]); COMMENT "set up second derivative";
TYPED_ABBREV_TAC `x4 = xrr y2 y3 y4` ; TYPED_ABBREV_TAC `x5 = xrr y1 y3 y5` ; TYPED_ABBREV_TAC `x6 = xrr y1 y2 y6` ; TYPED_ABBREV_TAC `e1 = rho y1` ; TYPED_ABBREV_TAC `e2 = rho y2` ; TYPED_ABBREV_TAC `e3 = rho y3` ; TYPIFY `&0 < y4 /\ &0 < ups_x (y2 * y2) (y3*y3) (y4*y4) /\ &0 < delta_y y1 y2 y3 y4 y5 y6` (C SUBGOAL_THEN ASSUME_TAC); RULE_ASSUM_TAC(REWRITE_RULE[SUBSET;IN_ELIM_THM]); BY(ASM_MESON_TAC[]); TYPIFY `&0 < x5 /\ x5 < &16 /\ &0 < x4 /\ x4 < &16 /\ &0 < x6 /\ x6 < &16` (C SUBGOAL_THEN ASSUME_TAC); BY(ASM_MESON_TAC[xrr_bounds]); TYPIFY `&0 < delta_x (&4) (&4) (&4) x4 x5 x6` (C SUBGOAL_THEN ASSUME_TAC); EXPAND_TAC "x4"; EXPAND_TAC "x5"; EXPAND_TAC "x6"; GMATCH_SIMP_TAC delta_x_xrr; ASM_SIMP_TAC[arith `&0 < y ==> ~(y = &0)`]; GMATCH_SIMP_TAC REAL_LT_MUL_EQ; GMATCH_SIMP_TAC REAL_LT_DIV; ASM_REWRITE_TAC[arith `&0 < &64`]; REWRITE_TAC[GSYM Trigonometry2.NOT_ZERO_EQ_POW2_LT]; REWRITE_TAC[REAL_ENTIRE]; BY(ASM_TAC THEN REAL_ARITH_TAC); INTRO_TAC derived_form_taum_d3_exists [`x4`;`x5`;`x6`;`e1`;`e2`;`e3`]; DISCH_THEN (X_CHOOSE_TAC `g'':real->real`); FIRST_X_ASSUM (X_CHOOSE_TAC `g''':real`); FIRST_X_ASSUM MP_TAC THEN ANTS_TAC; BY(ASM_REWRITE_TAC[]); REPEAT WEAKER_STRIP_TAC; COMMENT "introduce second derivative test"; INTRO_TAC SECOND_DERIVATIVE_TEST_COMPOSE [`\ (y4:real). &0 < y4` ;`\ (x:real). &0 < x /\ x < &16 /\ &0 < delta_x (&4) (&4) (&4) x x5 x6` ;`y4`;`xrr y2 y3 y4`;`real_interval(a,b)`;`(\q. xrr y2 y3 q)`;`\q. (&8 * q) / (y2*y3)`;`\ (q:real). (&8) / (y2 * y3)`;`&0`;`(\q. e1 * dih_x (&4) (&4) (&4) q x5 x6 + e2 * dih_x (&4) (&4) (&4) x5 x6 q + e3 * dih_x (&4) (&4) (&4) x6 q x5 - (&1 + const1) * pi) `;`(\q. ( num1 e1 e2 e3 q x5 x6) / (&2 * q * (&16 - q) * sqrt(delta_x (&4) (&4) (&4) q x5 x6))) `;`g''`;`g'''`]; ANTS_TAC; ASM_REWRITE_TAC[]; ASM_SIMP_TAC[ONCE_REWRITE_RULE[derived_form_b] derived_form_xrr_D3]; ASM_SIMP_TAC[ONCE_REWRITE_RULE[derived_form_b] derived_form_xrr_D2]; ASM_SIMP_TAC[ONCE_REWRITE_RULE[derived_form_b] derived_form_xrr]; CONJ_TAC; GMATCH_SIMP_TAC REAL_LT_DIV; GMATCH_SIMP_TAC REAL_LT_MUL_EQ; GMATCH_SIMP_TAC REAL_LT_MUL_EQ; ASM_REWRITE_TAC[]; BY(REAL_ARITH_TAC); REWRITE_TAC[REAL_OPEN_REAL_INTERVAL]; SUBCONJ_TAC; EXPAND_TAC "x5"; EXPAND_TAC "x6"; ASM_SIMP_TAC[xrr_convert]; FIRST_X_ASSUM_ST `SUBSET` MP_TAC; BY(SET_TAC[]); DISCH_TAC; CONJ_TAC; EXPAND_TAC "x5"; EXPAND_TAC "x6"; ASM_SIMP_TAC[xrr_convert]; TYPIFY `{x | &0 < x /\ &0 < ups_x (y2 * y2) (y3 * y3) (x * x) /\ &0 < delta_y y1 y2 y3 x y5 y6} = {x | &0 < x /\ &0 < delta_y y1 y2 y3 x y5 y6} INTER {x | &0 < ups_x (y2 * y2) (y3 * y3) (x * x) }` (C SUBGOAL_THEN SUBST1_TAC); BY(SET_TAC[]); MATCH_MP_TAC REAL_OPEN_INTER; REWRITE_TAC[real_open_ups_y]; BY(REWRITE_TAC[real_open_delta_y]); COMMENT "continue working on ants"; CONJ_TAC; REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM_ST `taum` (C INTRO_TAC [`x'`]); ASM_REWRITE_TAC[]; REPEAT (GMATCH_SIMP_TAC (REWRITE_RULE[LET_THM] taum_compose_xrr)); ASM_REWRITE_TAC[o_THM]; BY(ASM_TAC THEN SET_TAC[]); COMMENT "next ants"; CONJ_TAC; ONCE_REWRITE_TAC[derived_form_b]; REPEAT WEAKER_STRIP_TAC; INTRO_TAC derived_form_xrr [`y2`;`y3`;`x`]; BY(ASM_REWRITE_TAC[]); CONJ_TAC; ONCE_REWRITE_TAC[derived_form_b]; REPEAT WEAKER_STRIP_TAC; INTRO_TAC derived_form_xrr_D2 [`y2`;`y3`;`x`]; BY(ASM_REWRITE_TAC[]); CONJ_TAC; ONCE_REWRITE_TAC[derived_form_b]; REPEAT WEAKER_STRIP_TAC; BY(ASM_SIMP_TAC[derived_form_sum_dih444sub]); COMMENT "last conj of ants"; ONCE_REWRITE_TAC[derived_form_b]; REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM MATCH_MP_TAC; BY(ASM_REWRITE_TAC[]); COMMENT "clear denominators"; ASM_REWRITE_TAC[]; REWRITE_TAC[REAL_DIV_EQ_0]; TYPIFY_GOAL_THEN `~(&2 * x4 * (&16 - x4) * sqrt (delta_x (&4) (&4) (&4) x4 x5 x6) = &0)` (unlist REWRITE_TAC); REWRITE_TAC[REAL_ENTIRE]; GMATCH_SIMP_TAC SQRT_EQ_0; BY(ASM_TAC THEN REAL_ARITH_TAC); REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM_ST `dnum1` MP_TAC; ASM_REWRITE_TAC[]; REWRITE_TAC[arith `~(x < &0) <=> &0 <= x`]; INTRO_TAC derived_form_tau2D [`x4`;`x5`;`x6`;`e1`;`e2`;`e3`]; ASM_REWRITE_TAC[]; DISCH_TAC; FIRST_X_ASSUM (C INTRO_TAC [`x4`]); ASM_REWRITE_TAC[]; DISCH_TAC; INTRO_TAC derived_form_unique [`(\q. num1 e1 e2 e3 q x5 x6 / (&2 * q * (&16 - q) * sqrt (delta_x (&4) (&4) (&4) q x5 x6)))`;`g'' x4`;`((&4 * dnum1 e1 e2 e3 x4 x5 x6) / (&2 * x4 * (&16 - x4) * sqrt (delta_x (&4) (&4) (&4) x4 x5 x6)))`;`x4`]; ASM_REWRITE_TAC[]; DISCH_TAC; FIRST_X_ASSUM_ST `&0 <= g'' x4` MP_TAC; ASM_REWRITE_TAC[]; GMATCH_SIMP_TAC Trigonometry2.REAL_LE_RDIV_0; REWRITE_TAC[arith `&0 <= &4 * x <=> &0 <= x`]; GMATCH_SIMP_TAC REAL_LT_MUL_EQ; GMATCH_SIMP_TAC REAL_LT_MUL_EQ; GMATCH_SIMP_TAC REAL_LT_MUL_EQ; GMATCH_SIMP_TAC SQRT_POS_LT; BY(ASM_TAC THEN REAL_ARITH_TAC) ]);; (* }}} *)
let FIRST_DERIV_POS_OPEN_COMPOSE = 
prove_by_refinement( `!P Q x y f f' f'' g g' g''. P x /\ Q (f x) /\ (f x = y) /\ real_open {x | P x /\ Q (f x)} /\ (!x. derived_form (P x) f (f' x) x (:real)) /\ (!x. derived_form (P x) f' (f'' x) x (:real)) /\ (!y. derived_form (Q( y)) g (g' y) y (:real)) /\ (!y. derived_form (Q y) g' (g'' y) y (:real)) ==> real_open { x | (P x /\ Q (f x)) /\ &0 < g' (f x) * f' x } `,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; INTRO_TAC Pent_hex.continuous_preimage_open [`(\q. g' (f q) * f' q)`; `{x | P x /\ Q(f x)}`;`{y | &0 < y}`]; ASM_REWRITE_TAC[IN_ELIM_THM]; DISCH_THEN MATCH_MP_TAC; TYPIFY_GOAL_THEN `real_open {u | &0 < u}` (unlist REWRITE_TAC); BY(REWRITE_TAC[arith `a < b <=> b > a`;REAL_OPEN_HALFSPACE_GT]); GMATCH_SIMP_TAC REAL_CONTINUOUS_ON_EQ_REAL_CONTINUOUS_AT; ASM_REWRITE_TAC[IN_ELIM_THM]; REPEAT WEAKER_STRIP_TAC; MATCH_MP_TAC HAS_REAL_DERIVATIVE_IMP_CONTINUOUS_ATREAL; INTRO_TAC SECOND_CHAIN_GENERAL [`P`;`Q`;`f`;`f'`;`f'' x'`;`g`;`g'`;`g'' (f x')`;`x'`;`f x'`]; ASM_REWRITE_TAC[]; ANTS_TAC; RULE_ASSUM_TAC (ONCE_REWRITE_RULE[derived_form_b]); BY(ASM_MESON_TAC[]); REWRITE_TAC[Calc_derivative.derived_form;WITHINREAL_UNIV]; BY(MESON_TAC[]) ]);;
(* }}} *)
let real_open_contains_real_interval = 
prove_by_refinement( `!x s. x IN s /\ real_open s ==> ?a b. x IN real_interval (a,b) /\ real_interval(a,b) SUBSET s`,
(* {{{ proof *) [ REWRITE_TAC[real_open]; REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM (C INTRO_TAC [`x`]); ASM_REWRITE_TAC[]; REPEAT WEAKER_STRIP_TAC; GEXISTL_TAC [`x - e`;`x + e`]; REWRITE_TAC[IN_REAL_INTERVAL;SUBSET]; CONJ_TAC; BY(ASM_TAC THEN REAL_ARITH_TAC); REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM MATCH_MP_TAC; BY(ASM_TAC THEN REAL_ARITH_TAC) ]);;
(* }}} *)
let FIRST_DERIVATIVE_TEST_TAUM = 
prove_by_refinement( `!y1 y2 y3 y4 y5 y6. &0 < delta_y y1 y2 y3 y4 y5 y6 /\ &0 < y1 /\ &0 < y2 /\ &0 < y3 /\ &0 < y5 /\ &0 < y6 /\ &0 < y4 /\ &0 < ups_x (y1 * y1) (y2 * y2) (y6 * y6) /\ &0 < ups_x (y1 * y1) (y3 * y3) (y5 * y5) /\ &0 < ups_x (y2 * y2) (y3 * y3) (y4* y4) /\ &0 < num1 (rho y1) (rho y2) (rho y3) (xrr y2 y3 y4) (xrr y1 y3 y5) (xrr y1 y2 y6) ==> (?a b. y4 IN real_interval (a,b) /\ (!y4' y4''. (y4' IN real_interval(a,b) /\ y4'' IN real_interval(a,b) /\ y4' < y4'' ==> taum y1 y2 y3 y4' y5 y6 < taum y1 y2 y3 y4'' y5 y6))) `,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; REPEAT WEAKER_STRIP_TAC; PROOF_BY_CONTR_TAC; RULE_ASSUM_TAC (REWRITE_RULE[NOT_EXISTS_THM;TAUT `!a b. ~(a ==> b) <=> (a /\ ~b)`]); COMMENT "set up first derivative";
TYPED_ABBREV_TAC `x4 = xrr y2 y3 y4` ; TYPED_ABBREV_TAC `x5 = xrr y1 y3 y5` ; TYPED_ABBREV_TAC `x6 = xrr y1 y2 y6` ; TYPED_ABBREV_TAC `e1 = rho y1` ; TYPED_ABBREV_TAC `e2 = rho y2` ; TYPED_ABBREV_TAC `e3 = rho y3` ; TYPIFY `&0 < x5 /\ x5 < &16 /\ &0 < x4 /\ x4 < &16 /\ &0 < x6 /\ x6 < &16` (C SUBGOAL_THEN ASSUME_TAC); BY(ASM_MESON_TAC[xrr_bounds]); TYPIFY `&0 < delta_x (&4) (&4) (&4) x4 x5 x6` (C SUBGOAL_THEN ASSUME_TAC); EXPAND_TAC "x4"; EXPAND_TAC "x5"; EXPAND_TAC "x6"; GMATCH_SIMP_TAC (GSYM delta_y_pos_xrr); BY(ASM_REWRITE_TAC[]); COMMENT "introduce positivity"; INTRO_TAC derived_form_taum_d3_exists [`x4`;`x5`;`x6`;`e1`;`e2`;`e3`]; DISCH_THEN (X_CHOOSE_TAC `g'':real->real`); FIRST_X_ASSUM (X_CHOOSE_TAC `g''':real`); FIRST_X_ASSUM MP_TAC THEN ANTS_TAC; BY(ASM_REWRITE_TAC[]); REPEAT WEAKER_STRIP_TAC; INTRO_TAC FIRST_DERIV_POS_OPEN_COMPOSE [`\ (y4:real). &0 < y4` ;`\ (x:real). &0 < x /\ x < &16 /\ &0 < delta_x (&4) (&4) (&4) x x5 x6` ;`y4`;`xrr y2 y3 y4`;`(\q. xrr y2 y3 q)`;`\q. (&8 * q) / (y2*y3)`;`\ (q:real). (&8) / (y2 * y3)`;`(\q. e1 * dih_x (&4) (&4) (&4) q x5 x6 + e2 * dih_x (&4) (&4) (&4) x5 x6 q + e3 * dih_x (&4) (&4) (&4) x6 q x5 - (&1 + const1) * pi) `;`(\q. ( num1 e1 e2 e3 q x5 x6) / (&2 * q * (&16 - q) * sqrt(delta_x (&4) (&4) (&4) q x5 x6))) `;`g''`]; REWRITE_TAC[]; DISCH_THEN MP_TAC THEN ANTS_TAC; ASM_REWRITE_TAC[]; SUBCONJ_TAC; EXPAND_TAC "x5"; EXPAND_TAC "x6"; ASM_SIMP_TAC[xrr_convert]; TYPIFY `{x | &0 < x /\ &0 < ups_x (y2 * y2) (y3 * y3) (x * x) /\ &0 < delta_y y1 y2 y3 x y5 y6} = {x | &0 < x /\ &0 < delta_y y1 y2 y3 x y5 y6} INTER {x | &0 < ups_x (y2 * y2) (y3 * y3) (x * x) }` (C SUBGOAL_THEN SUBST1_TAC); BY(SET_TAC[]); MATCH_MP_TAC REAL_OPEN_INTER; REWRITE_TAC[real_open_ups_y]; BY(REWRITE_TAC[real_open_delta_y]); DISCH_TAC; ONCE_REWRITE_TAC[derived_form_b]; CONJ_TAC; REPEAT WEAKER_STRIP_TAC; BY(ASM_SIMP_TAC[ONCE_REWRITE_RULE[derived_form_b] derived_form_xrr]); CONJ_TAC; REPEAT WEAKER_STRIP_TAC; BY(ASM_SIMP_TAC[ONCE_REWRITE_RULE[derived_form_b] derived_form_xrr_D2]); CONJ2_TAC; BY(ASM_REWRITE_TAC[]); BY(ASM_SIMP_TAC[derived_form_sum_dih444sub]); DISCH_TAC; TYPED_ABBREV_TAC `s = {x | (&0 < x /\ &0 < xrr y2 y3 x /\ xrr y2 y3 x < &16 /\ &0 < delta_x (&4) (&4) (&4) (xrr y2 y3 x) x5 x6) /\ &0 < num1 e1 e2 e3 (xrr y2 y3 x) x5 x6 / (&2 * xrr y2 y3 x * (&16 - xrr y2 y3 x) * sqrt (delta_x (&4) (&4) (&4) (xrr y2 y3 x) x5 x6)) * (&8 * x) / (y2 * y3)}` ; TYPIFY `y4 IN s` (C SUBGOAL_THEN ASSUME_TAC); EXPAND_TAC "s"; ASM_REWRITE_TAC[IN_ELIM_THM]; GMATCH_SIMP_TAC REAL_LT_MUL_EQ; GMATCH_SIMP_TAC REAL_LT_DIV; ASM_REWRITE_TAC[]; GMATCH_SIMP_TAC REAL_LT_DIV; GMATCH_SIMP_TAC REAL_LT_MUL_EQ; REPEAT (GMATCH_SIMP_TAC REAL_LT_MUL_EQ); GMATCH_SIMP_TAC SQRT_POS_LT; ASM_REWRITE_TAC[]; BY(REPLICATE_TAC 3 (FIRST_X_ASSUM_ST `x < &16` MP_TAC) THEN REAL_ARITH_TAC); INTRO_TAC real_open_contains_real_interval [`y4`;`s`]; ASM_REWRITE_TAC[]; REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM (C INTRO_TAC [`a`;`b`]); ASM_REWRITE_TAC[]; REPEAT WEAKER_STRIP_TAC; TYPIFY `y4' IN s /\ y4'' IN s` (C SUBGOAL_THEN ASSUME_TAC); BY(REPLICATE_TAC 10 (FIRST_X_ASSUM MP_TAC) THEN SET_TAC[]); TYPIFY `real_interval[y4',y4''] SUBSET s` (C SUBGOAL_THEN ASSUME_TAC); REPEAT (FIRST_X_ASSUM_ST `real_interval:(real#real)->(real->bool)` MP_TAC); REWRITE_TAC[real_interval;IN_ELIM_THM;SUBSET]; REPLICATE_TAC 2 (FIRST_X_ASSUM MP_TAC); REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM MATCH_MP_TAC; BY(REPLICATE_TAC 10 (FIRST_X_ASSUM MP_TAC) THEN REAL_ARITH_TAC); COMMENT "introduce MVT"; TYPED_ABBREV_TAC `f = (\q. xrr y2 y3 q)`; TYPED_ABBREV_TAC `g = (\q. e1 * dih_x (&4) (&4) (&4) q x5 x6 + e2 * dih_x (&4) (&4) (&4) x5 x6 q + e3 * dih_x (&4) (&4) (&4) x6 q x5 - (&1 + const1) * pi) `; INTRO_TAC REAL_MVT_SIMPLE [`g o f`;`(\x. num1 e1 e2 e3 (xrr y2 y3 x) x5 x6 / (&2 * xrr y2 y3 x * (&16 - xrr y2 y3 x) * sqrt (delta_x (&4) (&4) (&4) (xrr y2 y3 x) x5 x6)) * (&8 * x) / (y2 * y3))`;`y4'`;`y4''`]; ANTS_TAC; ASM_REWRITE_TAC[]; REPEAT WEAKER_STRIP_TAC; MATCH_MP_TAC HAS_REAL_DERIVATIVE_ATREAL_WITHIN; ONCE_REWRITE_TAC[GSYM WITHINREAL_UNIV]; MP_TAC TRUTH; PURE_ONCE_REWRITE_TAC[GSYM Calc_derivative.derived_form]; MATCH_MP_TAC derived_form_chain; TYPIFY `f x` EXISTS_TAC; REWRITE_TAC[]; CONJ_TAC; EXPAND_TAC "f"; BY(ASM_SIMP_TAC[ONCE_REWRITE_RULE[derived_form_b] derived_form_xrr]); EXPAND_TAC "g"; EXPAND_TAC "f"; MATCH_MP_TAC derived_form_sum_dih444sub; ASM_REWRITE_TAC[]; TYPIFY `x IN s` (C SUBGOAL_THEN MP_TAC); BY(REPLICATE_TAC 5 (FIRST_X_ASSUM MP_TAC) THEN SET_TAC[]); EXPAND_TAC "s"; REWRITE_TAC[IN_ELIM_THM]; BY(DISCH_THEN (unlist REWRITE_TAC)); REWRITE_TAC[]; REPEAT WEAKER_STRIP_TAC; COMMENT "u positive"; TYPED_ABBREV_TAC `u = (num1 e1 e2 e3 (xrr y2 y3 x) x5 x6 / (&2 * xrr y2 y3 x * (&16 - xrr y2 y3 x) * sqrt (delta_x (&4) (&4) (&4) (xrr y2 y3 x) x5 x6)) * (&8 * x) / (y2 * y3))`; TYPIFY `x IN s` (C SUBGOAL_THEN MP_TAC); (FIRST_X_ASSUM_ST `real_interval:(real#real)->(real->bool)` MP_TAC); FIRST_X_ASSUM_ST `SUBSET` MP_TAC; BY(SET_TAC[REAL_INTERVAL_OPEN_SUBSET_CLOSED]); EXPAND_TAC "s"; REWRITE_TAC[IN_ELIM_THM]; DISCH_TAC; TYPIFY `&0 < u` (C SUBGOAL_THEN ASSUME_TAC); EXPAND_TAC "u"; BY(ASM_REWRITE_TAC[]); REPEAT (GMATCH_SIMP_TAC (REWRITE_RULE[LET_THM] taum_compose_xrr)); ASM_REWRITE_TAC[]; COMMENT "final kill"; TYPIFY_GOAL_THEN ` (g o f) y4' < (g o f) y4''` (unlist REWRITE_TAC); ONCE_REWRITE_TAC[arith `g' < g'' <=> &0 < g'' - g'`]; ASM_REWRITE_TAC[]; GMATCH_SIMP_TAC REAL_LT_MUL_EQ; ASM_REWRITE_TAC[]; BY(REPLICATE_TAC 15 (FIRST_X_ASSUM MP_TAC) THEN REAL_ARITH_TAC); TYPIFY `!y. y IN s ==> &0 < delta_y y1 y2 y3 y y5 y6` ENOUGH_TO_SHOW_TAC; DISCH_THEN (REPEAT o GMATCH_SIMP_TAC); BY(ASM_REWRITE_TAC[]); EXPAND_TAC "s"; REWRITE_TAC[IN_ELIM_THM]; REPEAT WEAKER_STRIP_TAC; GMATCH_SIMP_TAC delta_y_pos_xrr; BY(ASM_REWRITE_TAC[]) ]);; (* }}} *)
let const1_pos = 
prove_by_refinement( `&0 < const1`,
(* {{{ proof *) [ REWRITE_TAC[GSYM Nonlinear_lemma.sol0_over_pi_EQ_const1]; GMATCH_SIMP_TAC REAL_LT_DIV; REWRITE_TAC[PI_POS]; MP_TAC Flyspeck_constants.bounds; BY(REAL_ARITH_TAC) ]);;
(* }}} *)
let rho_bounds = 
prove_by_refinement( `!y. &2 <= y /\ y <= &2 * h0 ==> &1 <= rho y /\ rho y <= &1 + sol0 / pi`,
(* {{{ proof *) [ REWRITE_TAC[Nonlinear_lemma.rho_alt;Nonlinear_lemma.sol0_over_pi_EQ_const1]; REPEAT WEAKER_STRIP_TAC; ASSUME_TAC const1_pos; REWRITE_TAC[arith `&1 <= &1 + x <=> &0 <= x`;arith `&1 + c* x <= &1 + c <=> &0 <= c *(&1 - x)`]; GMATCH_SIMP_TAC REAL_LE_MUL; GMATCH_SIMP_TAC REAL_LE_MUL; BY(ASM_TAC THEN REWRITE_TAC[Sphere.h0] THEN REAL_ARITH_TAC) ]);;
(* }}} *)
let LEMMA_1834976363 = 
prove_by_refinement( `main_nonlinear_terminal_v11 ==> (!y1 y2 y3 y4 y5 y6 a b. &2 <= y1 /\ y1 <= &2 * h0 /\ &2 <= y2 /\ y2 <= &2 * h0 /\ &2 <= y3 /\ y3 <= &2 * h0 /\ (&2 / h0) pow 2 <= xrr y2 y3 y4 /\ xrr y2 y3 y4 <= #15.53 /\ (&2 / h0) pow 2 <= xrr y1 y3 y5 /\ (&2 / h0) pow 2 <= xrr y1 y2 y6 /\ y4 IN real_interval (a,b) /\ real_interval (a,b) SUBSET {y4 | &0 < delta_y y1 y2 y3 y4 y5 y6 /\ &0 < y4 /\ &0 < ups_x (y2*y2) (y3*y3) (y4*y4)} /\ &0 < y5 /\ &0 < y6 /\ &0 < ups_x (y1*y1) (y2*y2) (y6*y6) /\ &0 < ups_x (y1*y1) (y3*y3) (y5*y5) ==> (?y4'. y4' IN real_interval(a,b) /\ taum y1 y2 y3 y4' y5 y6 < taum y1 y2 y3 y4 y5 y6))`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; MATCH_MP_TAC SECOND_DERIVATIVE_TEST_TAUM; ASM_REWRITE_TAC[]; ASM_SIMP_TAC[arith `&2 <= y ==> &0 < y`]; DISCH_TAC; PROOF_BY_CONTR_TAC; INTRO_TAC (Terminal.get_main_nonlinear "1834976363") [`rho y1`;`rho y2`;`rho y3`;`xrr y2 y3 y4`;`xrr y1 y3 y5`;`xrr y1 y2 y6`]; ASM_REWRITE_TAC[Sphere.ineq;TAUT `a ==> b ==> c <=> a /\ b ==> c`]; REWRITE_TAC[arith `~(&0 > &0) /\ ~(&0 < &0)`;arith `&4 pow 2 = &16`;rho_bounds]; ASM_SIMP_TAC[rho_bounds]; REPEAT (GMATCH_SIMP_TAC (arith `x < y ==> x <= y`)); BY(ASM_MESON_TAC[arith `&2 <= y ==> &0 < y`;xrr_bounds]) ]);;
(* }}} *)
let xrr_increasing = 
prove_by_refinement( `!y1 y2 y6 y6'. &0 < y1 /\ &0 < y2 /\ &0 <= y6 /\ y6 < y6' ==> xrr y1 y2 y6 < xrr y1 y2 y6'`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; ONCE_REWRITE_TAC[arith `x < y <=> &0 < y - x`]; TYPIFY `xrr y1 y2 y6' - xrr y1 y2 y6 = (&4 / (y1 * y2)) * (y6' * y6' - y6 * y6)` (C SUBGOAL_THEN SUBST1_TAC); REWRITE_TAC[Appendix.xrr]; Calc_derivative.CALC_ID_TAC; BY(ASM_TAC THEN REAL_ARITH_TAC); GMATCH_SIMP_TAC REAL_LT_MUL_EQ; GMATCH_SIMP_TAC REAL_LT_DIV; GMATCH_SIMP_TAC REAL_LT_MUL_EQ; ONCE_REWRITE_TAC[arith `&0 < y - x <=> x < y`]; GMATCH_SIMP_TAC Misc_defs_and_lemmas.ABS_SQUARE; BY(ASM_TAC THEN REAL_ARITH_TAC) ]);;
(* }}} *)
let xrr_decreasing = 
prove_by_refinement( `!y1 y1' y2 y6. &2 <= y1 /\ &2 <= y1' /\ &2 <= y2 /\ &2 <= y6 /\ y2 <= &2 * h0 /\ y1 <= y1' ==> xrr y1' y2 y6 <= xrr y1 y2 y6`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; TYPIFY `y1 = y1'` ASM_CASES_TAC; BY(ASM_REWRITE_TAC[arith `x <= x`]); INTRO_TAC REAL_MVT_SIMPLE [`(\q. xrr q y2 y6)`;`\q. ( -- &4 * ((q*q + y6*y6 - y2*y2)/ (q pow 2 * y2)))`;`y1`;`y1'`]; REWRITE_TAC[IN_REAL_INTERVAL]; ANTS_TAC; CONJ_TAC; BY(ASM_TAC THEN REAL_ARITH_TAC); REPEAT WEAKER_STRIP_TAC; MATCH_MP_TAC HAS_REAL_DERIVATIVE_ATREAL_WITHIN; INTRO_TAC derived_form_xrr_wrt_y1 [`x`;`y2`;`y6`]; REWRITE_TAC[Calc_derivative.derived_form;WITHINREAL_UNIV]; DISCH_THEN MATCH_MP_TAC; BY(ASM_TAC THEN REAL_ARITH_TAC); REPEAT WEAKER_STRIP_TAC; ONCE_REWRITE_TAC [arith `x <= y <=> &0 <= y - x`]; RULE_ASSUM_TAC(ONCE_REWRITE_RULE[arith `x' - x = (-- &4 * u/v) * z <=> x - x' = &4 * u/ v * z`]); ASM_REWRITE_TAC[]; GMATCH_SIMP_TAC REAL_LE_MUL; GMATCH_SIMP_TAC REAL_LE_MUL; GMATCH_SIMP_TAC REAL_LE_DIV; GMATCH_SIMP_TAC REAL_LE_MUL; REWRITE_TAC[ REAL_LE_POW_2]; ENOUGH_TO_SHOW_TAC ` &0 <= x * x + y6 * y6 - y2 * y2`; BY(ASM_TAC THEN REAL_ARITH_TAC); MATCH_MP_TAC REAL_LE_TRANS; TYPIFY `&2 * &2 + &2 * &2 - (&2 * h0) * (&2 * h0)` EXISTS_TAC; CONJ_TAC; BY(REWRITE_TAC[Sphere.h0] THEN REAL_ARITH_TAC); MATCH_MP_TAC (arith `x <= x' /\ y <= y' /\ z' <= z ==> x + y - z <= x' + y' - z'`); GMATCH_SIMP_TAC Misc_defs_and_lemmas.ABS_SQUARE_LE; GMATCH_SIMP_TAC Misc_defs_and_lemmas.ABS_SQUARE_LE; GMATCH_SIMP_TAC Misc_defs_and_lemmas.ABS_SQUARE_LE; BY(ASM_TAC THEN REAL_ARITH_TAC) ]);;
(* }}} *)
let xrr_simple_lower_bound = 
prove_by_refinement( `!y1 y2 y6 y6inf. &2 <= y1 /\ y1 <= &2 * h0 /\ &2 <= y2 /\ y2 <= &2 * h0 /\ &2 <= y6inf /\ y6inf <= y6 ==> (y6inf/ h0) pow 2 <= xrr y1 y2 y6`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; MATCH_MP_TAC REAL_LE_TRANS; TYPIFY `xrr (&2 * h0) y2 y6` EXISTS_TAC; CONJ2_TAC; MATCH_MP_TAC xrr_decreasing; BY(ASM_TAC THEN REWRITE_TAC[Sphere.h0] THEN REAL_ARITH_TAC); MATCH_MP_TAC REAL_LE_TRANS; TYPIFY `xrr (&2 * h0) (&2 * h0) y6` EXISTS_TAC; CONJ2_TAC; ONCE_REWRITE_TAC[xrr_sym]; MATCH_MP_TAC xrr_decreasing; BY(ASM_TAC THEN REWRITE_TAC[Sphere.h0] THEN REAL_ARITH_TAC); MATCH_MP_TAC REAL_LE_TRANS; TYPIFY `xrr (&2 * h0) (&2 * h0) y6inf` EXISTS_TAC; CONJ2_TAC; TYPIFY `y6inf = y6` ASM_CASES_TAC; BY(ASM_REWRITE_TAC[arith `x <= x`]); MATCH_MP_TAC (arith (`x < y ==> x <= y`)); MATCH_MP_TAC xrr_increasing; BY(ASM_TAC THEN REWRITE_TAC[Sphere.h0] THEN REAL_ARITH_TAC); REWRITE_TAC[Appendix.xrr]; MATCH_MP_TAC (arith `x = y ==> x <= y`); Calc_derivative.CALC_ID_TAC; BY(REWRITE_TAC[Sphere.h0] THEN REAL_ARITH_TAC) ]);;
(* }}} *)
let xrr_simple_upper_bound = 
prove_by_refinement( `!y1 y2 y6 y6sup. &2 <= y1 /\ y1 <= &2 * h0 /\ &2 <= y2 /\ y2 <= &2 * h0 /\ &2 <= y6 /\ y6 <= y6sup /\ y6sup < &4 ==> xrr y1 y2 y6 <= y6sup pow 2`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; MATCH_MP_TAC REAL_LE_TRANS; TYPIFY `xrr (&2) y2 y6` EXISTS_TAC; CONJ_TAC; MATCH_MP_TAC xrr_decreasing; BY(ASM_TAC THEN REWRITE_TAC[Sphere.h0] THEN REAL_ARITH_TAC); MATCH_MP_TAC REAL_LE_TRANS; TYPIFY `xrr (&2) (&2) y6` EXISTS_TAC; CONJ_TAC; ONCE_REWRITE_TAC[xrr_sym]; MATCH_MP_TAC xrr_decreasing; BY(ASM_TAC THEN REWRITE_TAC[Sphere.h0] THEN REAL_ARITH_TAC); MATCH_MP_TAC REAL_LE_TRANS; TYPIFY `xrr (&2) (&2) y6sup` EXISTS_TAC; CONJ_TAC; TYPIFY `y6sup = y6` ASM_CASES_TAC; BY(ASM_REWRITE_TAC[arith `x <= x`]); MATCH_MP_TAC (arith (`x < y ==> x <= y`)); MATCH_MP_TAC xrr_increasing; BY(ASM_TAC THEN REWRITE_TAC[Sphere.h0] THEN REAL_ARITH_TAC); REWRITE_TAC[Appendix.xrr]; MATCH_MP_TAC (arith `x = y ==> x <= y`); Calc_derivative.CALC_ID_TAC; BY(REAL_ARITH_TAC) ]);;
(* }}} *)
let NUM1_GENERIC = 
prove_by_refinement( ` (!x4inf x4sup x5inf x5sup x6inf x6sup y1 y2 y3 y4 y5 y6. ineq [ (&1 , rho y1, &1 + sol0/ pi); (&1 , rho y2, &1 + sol0/ pi); (&1 , rho y3, &1 + sol0/ pi); (x4inf, xrr y2 y3 y4, x4sup); (x5inf, xrr y1 y3 y5, x5sup); (x6inf, xrr y1 y2 y6, x6sup) ] ((num1 (rho y1) (rho y2) (rho y3) (xrr y2 y3 y4) (xrr y1 y3 y5) (xrr y1 y2 y6) ) > &0) /\ &2 <= y1 /\ y1 <= &2 * h0 /\ &2 <= y2 /\ y2 <= &2 * h0 /\ &2 <= y3 /\ y3 <= &2 * h0 /\ x4inf <= xrr y2 y3 y4 /\ xrr y2 y3 y4 <= x4sup /\ x5inf <= xrr y1 y3 y5 /\ xrr y1 y3 y5 <= x5sup /\ x6inf <= xrr y1 y2 y6 /\ xrr y1 y2 y6 <= x6sup /\ &0 < y4 /\ &0 < y5 /\ &0 < y6 /\ &0 < delta_y y1 y2 y3 y4 y5 y6 /\ &0 < ups_x (y2 * y2) (y3 * y3) (y4* y4) /\ &0 < ups_x (y1*y1) (y2*y2) (y6*y6) /\ &0 < ups_x (y1*y1) (y3*y3) (y5*y5) ==> (?a b. y4 IN real_interval (a,b) /\ (!y4' y4''. (y4' IN real_interval(a,b) /\ y4'' IN real_interval(a,b) /\ y4' < y4'' ==> taum y1 y2 y3 y4' y5 y6 < taum y1 y2 y3 y4'' y5 y6))))`,
(* {{{ proof *) [ ASM_REWRITE_TAC[Sphere.ineq;TAUT `a ==> b ==> c <=> a /\ b ==> c`]; REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM_ST `num1` MP_TAC; ANTS_TAC; ASM_REWRITE_TAC[]; BY(ASM_MESON_TAC[rho_bounds]); DISCH_TAC; MATCH_MP_TAC FIRST_DERIVATIVE_TEST_TAUM; ASM_REWRITE_TAC[]; BY(ASM_SIMP_TAC[arith `n > &0 ==> &0 < n`;arith `&2 <= y ==> &0 < y`]) ]);;
(* }}} *)
let LEMMA_4828966562 = 
prove_by_refinement( `main_nonlinear_terminal_v11 ==> (!y1 y2 y3 y4 y5 y6. &2 <= y1 /\ y1 <= &2 * h0 /\ &2 <= y2 /\ y2 <= &2 * h0 /\ &2 <= y3 /\ y3 <= &2 * h0 /\ &2 <= y4 /\ y4 <= &2 * h0 /\ &2 <= y5 /\ y5 <= #3.01 /\ (&3 <= y6) /\ &0 < delta_y y1 y2 y3 y4 y5 y6 /\ // &0 < ups_x (y2 * y2) (y3 * y3) (y4* y4) /\ // &0 < ups_x (y1*y1) (y3*y3) (y5*y5) /\ &0 < ups_x (y1*y1) (y2*y2) (y6*y6) ==> (?a b. y4 IN real_interval (a,b) /\ (!y4' y4''. (y4' IN real_interval(a,b) /\ y4'' IN real_interval(a,b) /\ y4' < y4'' ==> taum y1 y2 y3 y4' y5 y6 < taum y1 y2 y3 y4'' y5 y6))))`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; MATCH_MP_TAC NUM1_GENERIC; GEXISTL_TAC [ `(&2/h0) pow 2`;`(&2 * h0) pow 2`;`(&2/h0) pow 2 `;`#3.01 pow 2`;`#2.38 pow 2`;`#16.0`]; INTRO_TAC (Terminal.get_main_nonlinear "4828966562") [`xrr y2 y3 y4`;`xrr y1 y3 y5`;`xrr y1 y2 y6`;`rho y1`;`rho y2`;`rho y3`]; DISCH_THEN (unlist REWRITE_TAC); ASM_REWRITE_TAC[]; TYPIFY `&0 < ups_x (y2 * y2) (y3 * y3) (y4 * y4) /\ &0 < ups_x (y1 * y1) (y3 * y3) (y5 * y5)` (C SUBGOAL_THEN ASSUME_TAC); REPEAT (GMATCH_SIMP_TAC Ysskqoy.TRI_UPS_X_STRICT_POS); BY(ASM_TAC THEN REWRITE_TAC[Sphere.h0] THEN REAL_ARITH_TAC); ASM_REWRITE_TAC[]; REPEAT (GMATCH_SIMP_TAC xrr_simple_lower_bound); ASM_REWRITE_TAC[]; REPEAT (GMATCH_SIMP_TAC xrr_simple_upper_bound); ASM_REWRITE_TAC[arith `#16.0 = &16`]; GMATCH_SIMP_TAC xrr_le_16; TYPIFY_GOAL_THEN `#2.38 pow 2 <= xrr y1 y2 y6` (unlist REWRITE_TAC); MATCH_MP_TAC REAL_LE_TRANS; TYPIFY `(&3 / h0) pow 2` EXISTS_TAC; CONJ_TAC; BY(REWRITE_TAC[Sphere.h0] THEN REAL_ARITH_TAC); GMATCH_SIMP_TAC xrr_simple_lower_bound; BY(ASM_TAC THEN REAL_ARITH_TAC); ASM_REWRITE_TAC[]; BY(ASM_TAC THEN REWRITE_TAC[Sphere.h0] THEN REAL_ARITH_TAC) ]);;
(* }}} *)
let LEMMA_6843920790 = 
prove_by_refinement( `main_nonlinear_terminal_v11 ==> (!y1 y2 y3 y4 y5 y6. &2 <= y1 /\ y1 <= &2 * h0 /\ &2 <= y2 /\ y2 <= &2 * h0 /\ &2 <= y3 /\ y3 <= &2 * h0 /\ &2 <= y4 /\ y4 <= #3.01 /\ &3 <= y5 /\ xrr y1 y3 y5 <= #15.53 /\ &3 <= y6 /\ xrr y1 y2 y6 <= #15.53 /\ &0 < delta_y y1 y2 y3 y4 y5 y6 ==> (?a b. y4 IN real_interval (a,b) /\ (!y4' y4''. (y4' IN real_interval(a,b) /\ y4'' IN real_interval(a,b) /\ y4' < y4'' ==> taum y1 y2 y3 y4' y5 y6 < taum y1 y2 y3 y4'' y5 y6))))`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; MATCH_MP_TAC NUM1_GENERIC; GEXISTL_TAC [ `(&2/h0) pow 2`;`#3.01 pow 2`;`(#2.38) pow 2 `;`#15.53`;`#2.38 pow 2`;`#15.53`]; INTRO_TAC (Terminal.get_main_nonlinear "6843920790") [`xrr y2 y3 y4`;`xrr y1 y3 y5`;`xrr y1 y2 y6`;`rho y1`;`rho y2`;`rho y3`]; DISCH_THEN (unlist REWRITE_TAC); ASM_REWRITE_TAC[]; REPEAT (GMATCH_SIMP_TAC xrr_simple_lower_bound); ASM_REWRITE_TAC[]; REPEAT (GMATCH_SIMP_TAC xrr_simple_upper_bound); ASM_REWRITE_TAC[]; TYPIFY_GOAL_THEN `#2.38 pow 2 <= xrr y1 y2 y6` (ASSUME_TAC); MATCH_MP_TAC REAL_LE_TRANS; TYPIFY `(&3 / h0) pow 2` EXISTS_TAC; CONJ_TAC; BY(REWRITE_TAC[Sphere.h0] THEN REAL_ARITH_TAC); GMATCH_SIMP_TAC xrr_simple_lower_bound; BY(ASM_TAC THEN REAL_ARITH_TAC); TYPIFY_GOAL_THEN `#2.38 pow 2 <= xrr y1 y3 y5` (ASSUME_TAC); MATCH_MP_TAC REAL_LE_TRANS; TYPIFY `(&3 / h0) pow 2` EXISTS_TAC; CONJ_TAC; BY(REWRITE_TAC[Sphere.h0] THEN REAL_ARITH_TAC); GMATCH_SIMP_TAC xrr_simple_lower_bound; BY(ASM_TAC THEN REAL_ARITH_TAC); TYPIFY `&0 < ups_x (y2 * y2) (y3 * y3) (y4 * y4) ` (C SUBGOAL_THEN ASSUME_TAC); REPEAT (GMATCH_SIMP_TAC Ysskqoy.TRI_UPS_X_STRICT_POS); BY(ASM_TAC THEN REWRITE_TAC[Sphere.h0] THEN REAL_ARITH_TAC); ASM_REWRITE_TAC[]; REPEAT (GMATCH_SIMP_TAC xrr_bounds_2); BY(ASM_TAC THEN REWRITE_TAC[Sphere.h0] THEN REAL_ARITH_TAC) ]);;
(* }}} *) (* RETURN TO PENT HEX CASES *) (* IS_SCS LEMMAS *)
let is_scs_funlist_basic = 
prove_by_refinement( `!k d a0 b0 a b . d < #0.9 /\ 3 <= k /\ k <= 6 /\ (!i j. i < j /\ j < k ==> funlist_v39 a a0 k i j <= funlist_v39 b b0 k i j) /\ (!i j. i < j /\ j < k ==> &2 <= funlist_v39 a a0 k i j) /\ (!i. i < 3 /\ k = 3 ==> funlist_v39 b b0 k i (SUC i) < &4) /\ (!i. i < k /\ 3 < k ==> funlist_v39 b b0 k i (SUC i) <= cstab) /\ CARD {i | i < k /\ (&2 * h0 < funlist_v39 b b0 k i (SUC i) \/ &2 < funlist_v39 a a0 k i (SUC i))} + k <= 6 ==> is_scs_v39 (scs_v39 (k,d, funlist_v39 a a0 k,funlist_v39 a a0 k, funlist_v39 b b0 k,funlist_v39 b b0 k, (\i j. F),{},{},{}))`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; ONCE_REWRITE_TAC[GSYM Terminal.funlistA_empty]; MATCH_MP_TAC Terminal.is_scs_funlist; ASM_REWRITE_TAC[Appendix.periodic_empty]; BY(REWRITE_TAC[Terminal.funlistA_empty]) ]);;
(* }}} *)
let periodic2_cs_adj = 
prove_by_refinement( `!k r r'. periodic2(cs_adj k r r') k`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; REWRITE_TAC[LET_DEF;LET_END_DEF;Appendix.periodic2;Appendix.cs_adj]; TYPIFY `!i. (i + k) MOD k = i MOD k` (C SUBGOAL_THEN ASSUME_TAC); GEN_TAC; ONCE_REWRITE_TAC[arith `i + (k:num) = 1 * k + i`]; BY(REWRITE_TAC[MOD_MULT_ADD]); REPEAT WEAKER_STRIP_TAC; BY(ASM_REWRITE_TAC[arith `SUC (i + k) = (SUC i + k)`]) ]);;
(* }}} *)
let is_scs_adj = 
prove_by_refinement( `!k d r r' s s'. d < #0.9 /\ 3 <= k /\ k <= 6 /\ (k = 3 ==> s < &4) /\ (3 < k ==> s <= cstab) /\ (&2 <= r ) /\ (&2 <= r') /\ (r <= s) /\ (r' <= s') /\ (3 < k ==> s <= &2 * h0 /\ r = &2) ==> is_scs_v39 (mk_unadorned_v39 k d (cs_adj k r r') (cs_adj k s s'))`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; ASM_REWRITE_TAC[Appendix.is_scs_v39;Terminal.scs_unadorned_explicit;Appendix.scs_v39_explicit;arith `x <= x`;Appendix.periodic_empty;periodic2_cs_adj]; CONJ_TAC; BY(REWRITE_TAC[Appendix.periodic2]); CONJ_TAC; REPEAT WEAKER_STRIP_TAC; REWRITE_TAC[Appendix.cs_adj]; CONJ_TAC; BY(MESON_TAC[]); CONJ_TAC; BY(MESON_TAC[]); BY(MESON_TAC[]); CONJ_TAC; REPEAT WEAKER_STRIP_TAC; REWRITE_TAC[Appendix.cs_adj]; COND_CASES_TAC THEN ASM_REWRITE_TAC[]; BY(REAL_ARITH_TAC); COND_CASES_TAC; BY(ASM_TAC THEN REAL_ARITH_TAC); BY(ASM_TAC THEN REAL_ARITH_TAC); CONJ_TAC; REPEAT WEAKER_STRIP_TAC; BY(REWRITE_TAC[Appendix.cs_adj]); CONJ_TAC; REPEAT WEAKER_STRIP_TAC; REWRITE_TAC[Appendix.cs_adj]; COND_CASES_TAC; BY(ASM_MESON_TAC[MOD_LT;arith `3 <= k ==> 0 < k`]); BY(ASM_TAC THEN REAL_ARITH_TAC); CONJ_TAC; REPEAT WEAKER_STRIP_TAC; REWRITE_TAC[Appendix.cs_adj]; ASM_REWRITE_TAC[]; FIRST_X_ASSUM (RULE_ASSUM_TAC o (unlist REWRITE_RULE)); BY(ASM_TAC THEN REAL_ARITH_TAC); CONJ_TAC; REPEAT WEAKER_STRIP_TAC; REWRITE_TAC[Appendix.cs_adj]; FIRST_X_ASSUM (RULE_ASSUM_TAC o (unlist REWRITE_RULE)); BY(ASM_TAC THEN REAL_ARITH_TAC); ASM_CASES_TAC `k=3`; ASM_REWRITE_TAC[arith `x + 3 <= 6 <=> x <= 3`]; INTRO_TAC HAS_SIZE_NUMSEG_LT [`3`]; REWRITE_TAC[HAS_SIZE]; TYPIFY `{i | i < 3 /\ (&2 * h0 < cs_adj 3 s s' i (SUC i) \/ &2 < cs_adj 3 r r' i (SUC i))} SUBSET {i | i < 3}` (C SUBGOAL_THEN MP_TAC); BY(SET_TAC[]); BY(MESON_TAC[CARD_SUBSET]); TYPIFY `{i | i < k /\ (&2 * h0 < cs_adj k s s' i (SUC i) \/ &2 < cs_adj k r r' i (SUC i))} = {}` ENOUGH_TO_SHOW_TAC; DISCH_THEN SUBST1_TAC; REWRITE_TAC[CARD_CLAUSES]; BY(ASM_TAC THEN ARITH_TAC); REWRITE_TAC[EXTENSION;IN_ELIM_THM;NOT_IN_EMPTY]; REWRITE_TAC[Appendix.cs_adj]; GEN_TAC; REWRITE_TAC[DE_MORGAN_THM]; REWRITE_TAC[TAUT `~a \/ b <=> a ==> b`]; DISCH_TAC; ASM_SIMP_TAC[Qknvmlb.SUC_MOD_NOT_EQ;arith `3 <= k==> 1 < k`]; TYPIFY `3 < k` (C SUBGOAL_THEN ASSUME_TAC); BY(ASM_TAC THEN ARITH_TAC); FIRST_X_ASSUM_ST `h0` MP_TAC; ASM_REWRITE_TAC[]; BY(REAL_ARITH_TAC) ]);;
(* }}} *)
let is_scs_6T1 = 
prove_by_refinement( `is_scs_v39 scs_6T1`,
(* {{{ proof *) [ REWRITE_TAC[Appendix.scs_6T1]; MATCH_MP_TAC is_scs_adj; REWRITE_TAC[Appendix.d_tame;Sphere.cstab]; NUM_REDUCE_TAC; BY(REWRITE_TAC[Sphere.h0] THEN REAL_ARITH_TAC) ]);;
(* }}} *)
let azim_in_fan_azim = 
prove_by_refinement( `!vv E k i. periodic vv k /\ 3 <= k /\ (!i j. i < k /\ j < k /\ vv i = vv j ==> i =j ) /\ E = IMAGE (\i. {vv i, vv (SUC i)}) (:num) ==> azim_in_fan (vv i,vv (SUC i)) E = azim (vec 0) (vv i) (vv (SUC i)) (vv (i + k -1))`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; ASM_REWRITE_TAC[Localization.azim_in_fan;LET_DEF;LET_END_DEF]; GMATCH_SIMP_TAC Terminal.EE_vv; TYPIFY `k` EXISTS_TAC; ASM_REWRITE_TAC[]; COND_CASES_TAC; BY(REWRITE_TAC[GEN_ALL Local_lemmas.AZIM_CYCLE_TWO_POINT_SET]); PROOF_BY_CONTR_TAC; FIRST_X_ASSUM_ST `CARD` MP_TAC; TYPIFY `~(k = 0)` (C SUBGOAL_THEN ASSUME_TAC); BY(REPEAT (FIRST_X_ASSUM MP_TAC) THEN ARITH_TAC); REWRITE_TAC[]; MATCH_MP_TAC (arith `c = 2 ==> c > 1`); MATCH_MP_TAC Hypermap.CARD_TWO_ELEMENTS; INTRO_TAC Oxl_def.periodic_mod [`vv`;`k`]; ASM_REWRITE_TAC[]; DISCH_THEN (unlist ONCE_REWRITE_TAC); DISCH_TAC; TYPIFY `SUC i MOD k = (i + k - 1) MOD k` (C SUBGOAL_THEN ASSUME_TAC); BY(ASM_MESON_TAC[DIVISION]); INTRO_TAC Oxlzlez.MOD_INJ1_ALT [`k-2`;`k`]; ANTS_TAC; BY(REPEAT (FIRST_X_ASSUM_ST `3 <= k` MP_TAC) THEN ARITH_TAC); DISCH_TAC; FIRST_X_ASSUM (C INTRO_TAC [`SUC i`]); ASM_REWRITE_TAC[]; BY(ASM_SIMP_TAC[arith `3 <= k ==> SUC x + k - 2 = x + k - 1`]) ]);;
(* }}} *)
let sol_local_azim = 
prove_by_refinement( `!vv k . ( let E = IMAGE (\i. {vv i, vv (SUC i)}) (:num) in let f = IMAGE (\i. vv i,vv (SUC i)) (:num) in (periodic vv k /\ 3 <= k /\ (!i j. i < k /\ j < k /\ vv i = vv j ==> (i = j)) ==> sol_local E f = sum {i | i < k} (\i. azim (vec 0) (vv i) (vv (i+1)) (vv (i + (k-1)))) - pi * (&k - &2)))`,
(* {{{ proof *) [ REWRITE_TAC[LET_DEF;LET_END_DEF;Localization.sol_local]; REPEAT WEAKER_STRIP_TAC; GMATCH_SIMP_TAC (GSYM Oxlzlez.PERIODIC_IMAGE); TYPIFY `k` EXISTS_TAC; CONJ_TAC; ASM_SIMP_TAC[arith `3 <= k ==> ~(0 = k)`]; FIRST_X_ASSUM_ST `periodic` MP_TAC; REWRITE_TAC[Oxl_def.periodic;PAIR_EQ]; BY(MESON_TAC[arith `SUC (i + k) = SUC i + k`]); TYPIFY `FINITE (IMAGE (\i. vv i,vv (SUC i)) {i | i < k})` (C SUBGOAL_THEN ASSUME_TAC); MATCH_MP_TAC FINITE_IMAGE; BY(REWRITE_TAC[FINITE_NUMSEG_LT]); ASM_SIMP_TAC[ SUM_SUB]; ASM_SIMP_TAC[ SUM_CONST]; MATCH_MP_TAC (arith `b = b' /\ s = s' ==> &2 * pi + s - b*pi = s' - (pi) * (b'- &2)`); GMATCH_SIMP_TAC CARD_IMAGE_INJ; ASM_REWRITE_TAC[IN_ELIM_THM;PAIR_EQ;FINITE_NUMSEG_LT;CARD_NUMSEG_LT]; CONJ_TAC; BY(ASM_MESON_TAC[]); GMATCH_SIMP_TAC SUM_IMAGE; ASM_REWRITE_TAC[IN_ELIM_THM;PAIR_EQ;FINITE_NUMSEG_LT;CARD_NUMSEG_LT]; CONJ_TAC; BY(ASM_MESON_TAC[]); MATCH_MP_TAC SUM_EQ; REWRITE_TAC[IN_ELIM_THM;o_THM]; REPEAT WEAKER_STRIP_TAC; REWRITE_TAC[arith `x + 1 = SUC x`]; MATCH_MP_TAC azim_in_fan_azim; BY(ASM_MESON_TAC[]) ]);;
(* }}} *)
let vv_inj_lemma = 
prove_by_refinement( `!s v k. is_scs_v39 s /\ v IN BBs_v39 s /\ scs_k_v39 s = k ==> (!i j. i < k /\ j < k /\ v i = v j ==> i = j)`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; RULE_ASSUM_TAC(REWRITE_RULE[Appendix.is_scs_v39;IN;Appendix.BBs_v39;LET_THM]); ASM_TAC THEN REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM (C INTRO_TAC [`i`;`j`]); REPEAT WEAKER_STRIP_TAC; PROOF_BY_CONTR_TAC; FIRST_X_ASSUM_ST `&2 <= x` (C INTRO_TAC [`i`;`j`]); ASM_REWRITE_TAC[arith `~(x <= y) <=> y < x`]; FIRST_X_ASSUM_ST `a <= dist(u,v)` MP_TAC; ASM_REWRITE_TAC[DIST_REFL]; BY(REAL_ARITH_TAC) ]);;
(* }}} *)
let LOCAL_FAN_AZIM_POS = 
prove_by_refinement( `!s vv i. (let V = IMAGE vv (:num) in let E = IMAGE (\i. {vv i, vv (SUC i)}) (:num) in let f = IMAGE (\i. (vv i,vv (SUC i))) (:num) in let k = scs_k_v39 s in (convex_local_fan (V,E,f) /\ is_scs_v39 s /\ vv IN BBs_v39 s ==> &0 < azim (vec 0) (vv i ) (vv (SUC i)) (vv (i + (k-1)))))`,
(* {{{ proof *) [ REWRITE_TAC[LET_THM]; REPEAT WEAKER_STRIP_TAC; GMATCH_SIMP_TAC (GSYM azim_in_fan_azim); TYPED_ABBREV_TAC `V = IMAGE vv (:num)`; TYPED_ABBREV_TAC `E = IMAGE (\i. {vv i, vv (SUC i)}) (:num)`; TYPED_ABBREV_TAC `f = IMAGE (\i. (vv i,vv (SUC i))) (:num)`; TYPIFY `vv i IN V` (C SUBGOAL_THEN ASSUME_TAC); EXPAND_TAC "V";
REWRITE_TAC[IN_IMAGE;IN_UNIV]; BY(MESON_TAC[]); TYPIFY ` E` EXISTS_TAC; INTRO_TAC (GEN_ALL Nkezbfc_local.CONVEX_LOFA_IMP_INANGLE_EQ_AZIM) [`V`;`f`;`E`]; ASM_REWRITE_TAC[]; DISCH_THEN (C INTRO_TAC [`vv i`]); ASM_REWRITE_TAC[]; INTRO_TAC Terminal.vv_rho_node1 [`vv`;`scs_k_v39 s`]; ASM_REWRITE_TAC[LET_THM]; INTRO_TAC vv_inj_lemma [`s`;`vv`;`scs_k_v39 s`]; ASM_REWRITE_TAC[]; DISCH_TAC; ASM_REWRITE_TAC[]; INTRO_TAC (GEN_ALL Local_lemmas.INTERIOR_ANGLE1_POS) [`E`;`V`;`f`;`vv i`]; ASM_REWRITE_TAC[]; ANTS_TAC; BY(ASM_SIMP_TAC[Local_lemmas.CVX_LO_IMP_LO]); TYPIFY `periodic vv (scs_k_v39 s) /\ 3 <= scs_k_v39 s` ENOUGH_TO_SHOW_TAC; BY(ASM_MESON_TAC[]); RULE_ASSUM_TAC(REWRITE_RULE[Appendix.is_scs_v39]); ASM_REWRITE_TAC[]; RULE_ASSUM_TAC(REWRITE_RULE[IN;Appendix.BBs_v39;LET_THM]); BY(ASM_REWRITE_TAC[]) ]);; (* }}} *)
let INTERIOR_ANGLE1_AZIM = 
prove_by_refinement( `!s vv i. (let V = IMAGE vv (:num) in let E = IMAGE (\i. {vv i, vv (SUC i)}) (:num) in let f = IMAGE (\i. (vv i,vv (SUC i))) (:num) in let k = scs_k_v39 s in (is_scs_v39 s /\ vv IN BBs_v39 s /\ 3 < k ==> azim (vec 0) (vv i ) (vv (SUC i)) (vv (i + (k-1))) = interior_angle1 (vec 0) f (vv(i) )))`,
(* {{{ proof *) [ REWRITE_TAC[LET_THM]; REPEAT WEAKER_STRIP_TAC; GMATCH_SIMP_TAC (GSYM azim_in_fan_azim); TYPED_ABBREV_TAC `V = IMAGE vv (:num)`; TYPED_ABBREV_TAC `E = IMAGE (\i. {vv i, vv (SUC i)}) (:num)`; TYPED_ABBREV_TAC `f = IMAGE (\i. (vv i,vv (SUC i))) (:num)`; TYPIFY `vv i IN V` (C SUBGOAL_THEN ASSUME_TAC); EXPAND_TAC "V";
REWRITE_TAC[IN_IMAGE;IN_UNIV]; BY(MESON_TAC[]); TYPIFY ` E` EXISTS_TAC; INTRO_TAC (GEN_ALL Nkezbfc_local.CONVEX_LOFA_IMP_INANGLE_EQ_AZIM) [`V`;`f`;`E`]; TYPIFY `convex_local_fan(V,E,f)` (C SUBGOAL_THEN ASSUME_TAC); RULE_ASSUM_TAC(REWRITE_RULE[Appendix.BBs_v39;IN;LET_THM]); FIRST_X_ASSUM_ST `convex_local_fan` MP_TAC THEN ASM_REWRITE_TAC[]; BY(ASM_SIMP_TAC[arith `3 < k ==> ~( k <= 3)`]); ASM_REWRITE_TAC[]; DISCH_THEN (C INTRO_TAC [`vv i`]); ASM_REWRITE_TAC[]; DISCH_THEN SUBST1_TAC; INTRO_TAC Terminal.vv_rho_node1 [`vv`;`scs_k_v39 s`]; ASM_REWRITE_TAC[LET_THM]; INTRO_TAC vv_inj_lemma [`s`;`vv`;`scs_k_v39 s`]; ASM_REWRITE_TAC[]; DISCH_TAC; ASM_REWRITE_TAC[]; TYPIFY `periodic vv (scs_k_v39 s) /\ 3 <= scs_k_v39 s` ENOUGH_TO_SHOW_TAC; BY(ASM_MESON_TAC[]); RULE_ASSUM_TAC(REWRITE_RULE[Appendix.is_scs_v39]); ASM_REWRITE_TAC[]; RULE_ASSUM_TAC(REWRITE_RULE[IN;Appendix.BBs_v39;LET_THM]); BY(ASM_REWRITE_TAC[]) ]);; (* }}} *)
let delta_x4_imp_obtuse = 
prove_by_refinement( `!x1 x2 x3 x4 x5 x6. &0 < x1 /\ &0 <= delta_x x1 x2 x3 x4 x5 x6 /\ delta_x4 x1 x2 x3 x4 x5 x6 < &0 ==> pi/ &2 < dih_x x1 x2 x3 x4 x5 x6`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; REWRITE_TAC[Sphere.dih_x;LET_THM]; REWRITE_TAC[arith `x < x + y <=> &0 < y`]; TYPED_ABBREV_TAC `s = sqrt(&4 * x1 * delta_x x1 x2 x3 x4 x5 x6)`; TYPIFY `&0 <= s` (C SUBGOAL_THEN ASSUME_TAC); EXPAND_TAC "s";
GMATCH_SIMP_TAC SQRT_POS_LE; GMATCH_SIMP_TAC REAL_LE_MUL; GMATCH_SIMP_TAC REAL_LE_MUL; BY(ASM_TAC THEN REAL_ARITH_TAC); ASM_CASES_TAC `&0 < s`; ASM_SIMP_TAC[Merge_ineq.ATN2_POS]; BY(ASM_TAC THEN REAL_ARITH_TAC); TYPIFY `s = &0` (C SUBGOAL_THEN SUBST1_TAC); BY(ASM_TAC THEN REAL_ARITH_TAC); GMATCH_SIMP_TAC Merge_ineq.atn2_0; MP_TAC PI_POS; BY(ASM_TAC THEN REAL_ARITH_TAC) ]);; (* }}} *)
let delta4_y_imp_obtuse = 
prove_by_refinement( `!y1 y2 y3 y4 y5 y6. &0 < y1 /\ &0 <= delta_y y1 y2 y3 y4 y5 y6 /\ delta4_y y1 y2 y3 y4 y5 y6 < &0 ==> pi/ &2 < dih_y y1 y2 y3 y4 y5 y6`,
(* {{{ proof *) [ REWRITE_TAC[Sphere.dih_y;LET_THM;Sphere.delta_y;Sphere.delta4_y;Sphere.y_of_x]; REPEAT WEAKER_STRIP_TAC; MATCH_MP_TAC delta_x4_imp_obtuse; ASM_REWRITE_TAC[]; GMATCH_SIMP_TAC REAL_LT_MUL_EQ; BY(ASM_REWRITE_TAC[]) ]);;
(* }}} *)
let scs_vv_MOD = 
prove_by_refinement( `!s vv i. is_scs_v39 s /\ BBs_v39 s vv ==> vv(i MOD scs_k_v39 s) = vv i`,
(* {{{ proof *) [ REWRITE_TAC[Appendix.is_scs_v39;Appendix.BBs_v39;LET_THM]; REPEAT WEAKER_STRIP_TAC; SPEC_TAC (`i:num`,`i:num`); MATCH_MP_TAC Xwitccn.PERIODIC_PROPERTY; ASM_REWRITE_TAC[]; BY(FIRST_X_ASSUM_ST `3 <= k` MP_TAC THEN ARITH_TAC) ]);;
(* }}} *)
let scs_lb_2 = 
prove_by_refinement( `!s vv i j. is_scs_v39 s /\ BBs_v39 s vv /\ ~(i MOD scs_k_v39 s = j MOD scs_k_v39 s) ==> &2 <= dist(vv i,vv j)`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; TYPIFY_GOAL_THEN `!i. vv(i MOD scs_k_v39 s) = vv (i)` (unlist ONCE_REWRITE_TAC o GSYM); BY(ASM_MESON_TAC[scs_vv_MOD]); RULE_ASSUM_TAC(REWRITE_RULE[Appendix.is_scs_v39;Appendix.BBs_v39;LET_THM]); TYPED_ABBREV_TAC `k = scs_k_v39 s`; ASM_TAC THEN REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM_ST `&2 <= x` (C INTRO_TAC [`i MOD k`;`j MOD k`]); FIRST_X_ASSUM_ST `scs_a_v39` (C INTRO_TAC [`i MOD k`;`j MOD k`]); ASM_SIMP_TAC[arith `3 <= k ==> ~(k = 0)`;DIVISION]; BY(REAL_ARITH_TAC) ]);;
(* }}} *)
let delta_x4_decreasing = 
prove_by_refinement( `!x1 x2 x3 x4 x5 x6 x4'. x4 <= x4' /\ &0 <= x1 ==> delta_x4 x1 x2 x3 x4' x5 x6 <= delta_x4 x1 x2 x3 x4 x5 x6`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; ENOUGH_TO_SHOW_TAC `delta_x4 x1 x2 x3 x4 x5 x6 - delta_x4 x1 x2 x3 x4' x5 x6 = &2 * x1 * (x4' - x4)`; ONCE_REWRITE_TAC[arith `d' <= d <=> &0 <= d - d'`]; DISCH_THEN SUBST1_TAC; GMATCH_SIMP_TAC REAL_LE_MUL; CONJ_TAC; BY(REAL_ARITH_TAC); GMATCH_SIMP_TAC REAL_LE_MUL; BY(ASM_TAC THEN REAL_ARITH_TAC); REWRITE_TAC[Nonlin_def.delta_x4]; BY(REAL_ARITH_TAC) ]);;
(* }}} *)
let SYNQIWN = 
prove_by_refinement( `main_nonlinear_terminal_v11 ==> (!s v i k. is_scs_v39 s /\ BBs_v39 s v /\ scs_k_v39 s =k /\ 3 < k /\ ((norm (v (SUC i)) = &2 /\ dist(v i,v (i+k-1)) = &2) \/ (norm (v (i+k-1)) = &2 /\ dist(v i,v (SUC i)) = &2) \/ (norm (v (SUC i)) = &2 /\ norm (v(i+k-1)) = &2) \/ (dist(v i,v(SUC i)) = &2 /\ dist(v i,v(i + k - 1)) = &2) \/ (norm (v (SUC i)) = &2 /\ dist(v i,v (SUC i)) = &2) \/ (norm (v (i+k-1)) = &2 /\ dist(v i,v (i+k-1)) = &2)) /\ (dist(v i,v (SUC i)) <= &2 * h0) /\ (dist(v (i),v(i+k-1)) <= &2 * h0) /\ cstab <= dist(v (SUC i),v(i+k - 1)) ==> pi/ &2 < azim (vec 0) (v (i)) (v (SUC i)) (v (i + k - 1))) `,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; REWRITE_TAC[arith `x < y <=> ~(y <= x)`]; DISCH_TAC; TYPED_ABBREV_TAC `E = IMAGE (\i. {v i, v (SUC i)}) (:num) `; INTRO_TAC vv_inj_lemma [`s`;`v`;`k`]; ASM_REWRITE_TAC[IN]; COMMENT "noncollinearity";
DISCH_TAC; INTRO_TAC (GEN_ALL Qknvmlb.IS_SCS_NOT_COLLINEAR_BBs_CASE_LE_PRIME_3) [`v`;`i`;`s`]; ASM_REWRITE_TAC[IN]; INTRO_TAC (GEN_ALL Qknvmlb.IS_SCS_NOT_COLLINEAR_BBs_CASE_LE_PRIME_3) [`v`;`i + k - 1`;`s`]; ASM_REWRITE_TAC[IN]; TYPIFY `SUC (i + k -1) MOD k = i MOD k` (C SUBGOAL_THEN SUBST1_TAC); TYPIFY `SUC (i + k - 1) = 1*k + i` (C SUBGOAL_THEN SUBST1_TAC); BY(FIRST_X_ASSUM_ST `3 < k` MP_TAC THEN ARITH_TAC); BY(REWRITE_TAC[MOD_MULT_ADD]); TYPIFY_GOAL_THEN `!i. v (i MOD k) = v i` (unlist REWRITE_TAC); RULE_ASSUM_TAC(REWRITE_RULE[Appendix.BBs_v39;LET_THM]); MATCH_MP_TAC Xwitccn.PERIODIC_PROPERTY; BY(ASM_MESON_TAC[arith `3 < k ==> ~(k=0)`]); TYPIFY `{vec 0, v (i + k - 1),v ( i)} = {vec 0,v (i),v (i + k - 1)}` (C SUBGOAL_THEN SUBST1_TAC); BY(SET_TAC[]); REPEAT WEAKER_STRIP_TAC; PROOF_BY_CONTR_TAC; TYPIFY `azim (vec 0) (v i) (v (SUC i)) (v (i + k - 1)) = dihV (vec 0) (v i) (v (SUC i)) (v (i + k - 1))` (C SUBGOAL_THEN ASSUME_TAC); GMATCH_SIMP_TAC (GSYM Polar_fan.AZIM_DIHV_SAME_STRONG); ASM_REWRITE_TAC[]; FIRST_X_ASSUM_ST `pi` MP_TAC; MP_TAC PI_POS; BY(REAL_ARITH_TAC); TYPIFY `pi / &2 < dihV (vec 0) (v (i)) (v (SUC i)) (v (i + k - 1))` ENOUGH_TO_SHOW_TAC; BY(ASM_TAC THEN REAL_ARITH_TAC); GMATCH_SIMP_TAC (REWRITE_RULE[LET_THM] Merge_ineq.DIHV_EQ_DIH_Y); ASM_REWRITE_TAC[]; MATCH_MP_TAC delta4_y_imp_obtuse; COMMENT "three final steps"; TYPIFY `!i. &2 <= norm(v i) /\ norm(v i) <= &2 * h0` (C SUBGOAL_THEN ASSUME_TAC); RULE_ASSUM_TAC(REWRITE_RULE[Appendix.BBs_v39;LET_THM;Terminal.IMAGE_SUBSET_IN;IN_UNIV]); BY(ASM_MESON_TAC[Fnjlbxs.in_ball_annulus]); REWRITE_TAC[Trigonometry1.DIST_L_ZERO]; SUBCONJ_TAC; FIRST_X_ASSUM (C INTRO_TAC [`i`]); BY(REAL_ARITH_TAC); DISCH_TAC; REWRITE_TAC[REWRITE_RULE[LET_THM] Tame_lemmas.delta_y_pos]; INTRO_TAC scs_lb_2 [`s`;`v`]; ASM_REWRITE_TAC[]; DISCH_TAC; TYPIFY `&2 <= dist (v i, v (SUC i))` (C SUBGOAL_THEN ASSUME_TAC); FIRST_X_ASSUM MATCH_MP_TAC; BY(ASM_MESON_TAC[ Qknvmlb.SUC_MOD_NOT_EQ;arith `3 < k ==> 1 < k`]); TYPIFY `&2 <= dist(v i,v (i + k - 1))` (C SUBGOAL_THEN ASSUME_TAC); FIRST_X_ASSUM MATCH_MP_TAC; INTRO_TAC (GEN_ALL Oxl_2012.MOD_INJ1) [`k - 1`;`k`]; ANTS_TAC; BY(FIRST_X_ASSUM_ST `3 < k` MP_TAC THEN ARITH_TAC); BY(DISCH_THEN (unlist REWRITE_TAC)); TYPIFY `delta4_y (norm (v i)) (norm (v (SUC i))) (norm (v (i + k - 1))) cstab (dist (v i,v (i + k - 1))) (dist (v i,v (SUC i))) < &0` ENOUGH_TO_SHOW_TAC; MATCH_MP_TAC (arith `y<= x ==> (x < &0 ==> y < &0)`); REWRITE_TAC[Sphere.delta4_y;Sphere.y_of_x]; MATCH_MP_TAC delta_x4_decreasing; GMATCH_SIMP_TAC Misc_defs_and_lemmas.ABS_SQUARE_LE; REWRITE_TAC[ REAL_LE_SQUARE]; BY(FIRST_X_ASSUM_ST `cstab` MP_TAC THEN REWRITE_TAC[Sphere.cstab] THEN REAL_ARITH_TAC); REWRITE_TAC[Sphere.cstab]; COMMENT "ineq cases"; REPEAT (FIRST_X_ASSUM_ST `collinear` kill); REPEAT (FIRST_X_ASSUM_ST `azim` kill); FIRST_ASSUM_ST `h0` (C INTRO_TAC [`i`]); FIRST_ASSUM_ST `h0` (C INTRO_TAC [`SUC i`]); FIRST_X_ASSUM_ST `h0` (C INTRO_TAC [`i + k - 1`]); TYPED_ABBREV_TAC `y1 = norm (v i)`; TYPED_ABBREV_TAC `y2 = norm (v (SUC i))`; TYPED_ABBREV_TAC `y3 = norm (v (i + k - 1))`; TYPED_ABBREV_TAC `y5 = dist(v i ,v(i + k - 1))`; TYPED_ABBREV_TAC `y6 = dist(v i, v(SUC i))`; REPLICATE_TAC 5 (FIRST_X_ASSUM kill); REPEAT WEAKER_STRIP_TAC; TYPIFY `delta4_y y1 y3 y2 #3.01 y6 y5 = delta4_y y1 y2 y3 #3.01 y5 y6 /\ delta4_y y1 y5 y6 #3.01 y2 y3 = delta4_y y1 y2 y3 #3.01 y5 y6 /\ delta4_y y1 y6 y5 #3.01 y3 y2 = delta4_y y1 y2 y3 #3.01 y5 y6` (C SUBGOAL_THEN ASSUME_TAC); BY(REWRITE_TAC[Sphere.delta4_y;Sphere.delta_x4;Sphere.y_of_x] THEN REAL_ARITH_TAC); (FIRST_X_ASSUM_ST `\/` MP_TAC) THEN REPEAT STRIP_TAC; INTRO_TAC (Terminal.get_main_nonlinear "1117202051") [`y1`;`y3`;`y2`;`#3.01`;`y6`;`y5`]; ASM_REWRITE_TAC[Sphere.ineq;TAUT `a ==> b ==> c <=> a /\ b ==> c`]; DISCH_THEN MATCH_MP_TAC; BY(ASM_TAC THEN REWRITE_TAC[Sphere.h0] THEN REAL_ARITH_TAC); INTRO_TAC (Terminal.get_main_nonlinear "1117202051") [`y1`;`y2`;`y3`;`#3.01`;`y5`;`y6`]; ASM_REWRITE_TAC[Sphere.ineq;TAUT `a ==> b ==> c <=> a /\ b ==> c`]; DISCH_THEN MATCH_MP_TAC; BY(ASM_TAC THEN REWRITE_TAC[Sphere.h0] THEN REAL_ARITH_TAC); INTRO_TAC (Terminal.get_main_nonlinear "4559601669") [`y1`;`y2`;`y3`;`#3.01`;`y5`;`y6`]; ASM_REWRITE_TAC[Sphere.ineq;TAUT `a ==> b ==> c <=> a /\ b ==> c`]; DISCH_THEN MATCH_MP_TAC; BY(ASM_TAC THEN REWRITE_TAC[Sphere.h0] THEN REAL_ARITH_TAC); INTRO_TAC (Terminal.get_main_nonlinear "4559601669") [`y1`;`y5`;`y6`;`#3.01`;`y2`;`y3`]; ASM_REWRITE_TAC[Sphere.ineq;TAUT `a ==> b ==> c <=> a /\ b ==> c`]; DISCH_THEN MATCH_MP_TAC; BY(ASM_TAC THEN REWRITE_TAC[Sphere.h0] THEN REAL_ARITH_TAC); INTRO_TAC (Terminal.get_main_nonlinear "4559601669b") [`y1`;`y2`;`y3`;`#3.01`;`y5`;`y6`]; ASM_REWRITE_TAC[Sphere.ineq;TAUT `a ==> b ==> c <=> a /\ b ==> c`]; DISCH_THEN MATCH_MP_TAC; BY(ASM_TAC THEN REWRITE_TAC[Sphere.h0] THEN REAL_ARITH_TAC); INTRO_TAC (Terminal.get_main_nonlinear "4559601669b") [`y1`;`y3`;`y2`;`#3.01`;`y6`;`y5`]; ASM_REWRITE_TAC[Sphere.ineq;TAUT `a ==> b ==> c <=> a /\ b ==> c`]; DISCH_THEN MATCH_MP_TAC; BY(ASM_TAC THEN REWRITE_TAC[Sphere.h0] THEN REAL_ARITH_TAC) ]);; (* }}} *) (* let edge2_generic = prove_by_refinement( `main_nonlinear_terminal_v11 ==> (!vv k d. (let V = IMAGE vv (:num) in let E = IMAGE (\i. {vv i, vv (SUC i)}) (:num) in let s = mk_unadorned_v39 k d (cs_adj k (&2) cstab) (cs_adj k (&2) (&6)) in (BBs_v39 s vv /\ 3 < k /\ taustar_v39 s vv < &0 /\ is_scs_v39 s /\ (!i j. i < k /\ j < k /\ vv i = vv j ==> (i = j)) ==> generic V E)))`, (* {{{ proof *) [ REWRITE_TAC[LET_THM]; REPEAT WEAKER_STRIP_TAC; TYPED_ABBREV_TAC `s = mk_unadorned_v39 k d (cs_adj k (&2) cstab) (cs_adj k (&2) (&6))`; TYPIFY `scs_k_v39 s =k ` (C SUBGOAL_THEN ASSUME_TAC); EXPAND_TAC "s"; BY(ASM_REWRITE_TAC[Terminal.scs_unadorned_explicit]); INTRO_TAC Jkqewgv.JKQEWGV2 [`s`;`vv`]; ASM_REWRITE_TAC[LET_THM]; DISCH_TAC; TYPED_ABBREV_TAC `V = IMAGE vv (:num)`; TYPED_ABBREV_TAC `E = IMAGE (\i. {vv i, vv (SUC i)}) (:num)`; TYPED_ABBREV_TAC `f = IMAGE (\i. (vv i,vv (SUC i))) (:num)`; TYPIFY `convex_local_fan(V,E,f)` (C SUBGOAL_THEN ASSUME_TAC); RULE_ASSUM_TAC (REWRITE_RULE[Appendix.BBs_v39;LET_THM]); BY(ASM_MESON_TAC[arith `3 < k ==> ~(k <= 3)`;LET_THM]); TYPIFY `~(?v w. lunar (v,w) V E)` ENOUGH_TO_SHOW_TAC; BY(ASM_MESON_TAC[Local_lemmas.CVX_LO_IMP_LO; Wrgcvdr_cizmrrh.CIZMRRH]); REPEAT WEAKER_STRIP_TAC; INTRO_TAC Jkqewgv.JKQEWGV3 [`s`;`vv`;`v`;`w`]; ASM_REWRITE_TAC[LET_THM]; TYPIFY `v IN V` (C SUBGOAL_THEN ASSUME_TAC); RULE_ASSUM_TAC(REWRITE_RULE[Wrgcvdr_cizmrrh.lunar]); BY(FIRST_X_ASSUM MP_TAC THEN SET_TAC[]); TYPIFY ` interior_angle1 (vec 0) f v = azim_in_fan (v,rho_node1 f v) E` (C SUBGOAL_THEN SUBST1_TAC); BY(ASM_MESON_TAC[Nkezbfc_local.CONVEX_LOFA_IMP_INANGLE_EQ_AZIM]); TYPIFY `!v. v IN V ==> ?i. v = vv i` (C SUBGOAL_THEN ASSUME_TAC); GEN_TAC; EXPAND_TAC "V"; BY(REWRITE_TAC[IN_IMAGE;IN_UNIV]); FIRST_X_ASSUM (C INTRO_TAC [`v`]); ASM_REWRITE_TAC[]; REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM MP_TAC; ASM_REWRITE_TAC[]; EXPAND_TAC "f"; GMATCH_SIMP_TAC (REWRITE_RULE[LET_THM] Terminal.vv_rho_node1); TYPIFY `periodic vv k /\ 3 <= k` (C SUBGOAL_THEN ASSUME_TAC); RULE_ASSUM_TAC(REWRITE_RULE[Appendix.BBs_v39;LET_THM]); ASM_SIMP_TAC[arith `3 < k ==> 3 <= k`]; EXPAND_TAC "k"; BY(ASM_REWRITE_TAC[]); CONJ_TAC; TYPIFY `k` EXISTS_TAC; BY(ASM_REWRITE_TAC[]); GMATCH_SIMP_TAC azim_in_fan_azim; TYPIFY `k` EXISTS_TAC; ASM_REWRITE_TAC[]; DISCH_TAC (* unfinished need SYN, redo as RRCWNS_WEAK *) ]);; (* }}} *) *)
let scs_diag_2 = 
prove_by_refinement( `!k i. 3 < k ==> scs_diag k (SUC i) (i + k - 1)`,
(* {{{ proof *) [ REPEAT GEN_TAC; REWRITE_TAC[Appendix.scs_diag]; DISCH_TAC; TYPIFY_GOAL_THEN `~(SUC (SUC i) MOD k = (i + k - 1) MOD k)` (unlist REWRITE_TAC); TYPIFY_GOAL_THEN `i + k - 1 = SUC(SUC i) + (k - 3)` (unlist REWRITE_TAC); BY(ASM_TAC THEN ARITH_TAC); BY(ASM_MESON_TAC[Oxl_2012.MOD_INJ1;arith `3 < k ==> ~(k = 0) /\ ~(k - 3 = 0) /\ (k - 3 < k)`]); TYPIFY_GOAL_THEN `SUC (i + k - 1) = SUC i + (k-1)` (unlist REWRITE_TAC); BY(ASM_TAC THEN ARITH_TAC); CONJ2_TAC; BY(ASM_MESON_TAC[Oxl_2012.MOD_INJ1;arith `3 < k ==> ~(k = 0) /\ ~(k - 1 = 0) /\ (k - 1 < k)`]); TYPIFY_GOAL_THEN `i + k - 1 = SUC i + k - 2` (unlist REWRITE_TAC); BY(ASM_TAC THEN ARITH_TAC); BY(ASM_MESON_TAC[Oxl_2012.MOD_INJ1;arith `3 < k ==> ~(k = 0) /\ ~(k - 2 = 0) /\ (k - 2 < k)`]) ]);;
(* }}} *)
let RRCWNS_WEAK = 
prove_by_refinement( `main_nonlinear_terminal_v11 ==> (!s vv. (let V = IMAGE vv (:num) in let E = IMAGE (\i. {vv i, vv (SUC i)}) (:num) in let k = scs_k_v39 s in (BBs_v39 s vv /\ 3 < k /\ taustar_v39 s vv < &0 /\ is_scs_v39 s /\ scs_basic_v39 s /\ (!i j. scs_diag (scs_k_v39 s) i j ==> cstab <= dist(vv i,vv j)) /\ (!i w. lunar(vv i,w) V E ==> dist(vv i,vv(SUC i)) <= &2*h0 /\ dist(vv i,vv(i + k - 1)) <= &2*h0 /\ ((norm (vv (SUC i)) = &2 \/ dist(vv i, vv(SUC i)) = &2)) /\ ((norm (vv (i + k - 1)) = &2 \/ dist(vv i, vv(i + k - 1)) = &2))) ==> scs_generic vv)))`,
(* {{{ proof *) [ DISCH_TAC; REWRITE_TAC[LET_THM;Appendix.scs_generic]; REPEAT WEAKER_STRIP_TAC; INTRO_TAC Jkqewgv.JKQEWGV2 [`s`;`vv`]; ASM_REWRITE_TAC[LET_THM]; DISCH_TAC; TYPED_ABBREV_TAC `V = IMAGE vv (:num)`; TYPED_ABBREV_TAC `E = IMAGE (\i. {vv i, vv (SUC i)}) (:num)`; TYPED_ABBREV_TAC `f = IMAGE (\i. (vv i,vv (SUC i))) (:num)`; TYPIFY `convex_local_fan(V,E,f)` (C SUBGOAL_THEN ASSUME_TAC); RULE_ASSUM_TAC (REWRITE_RULE[Appendix.BBs_v39;LET_THM]); BY(ASM_MESON_TAC[arith `3 < k ==> ~(k <= 3)`;LET_THM]); TYPIFY `~(?v w. lunar (v,w) V E)` ENOUGH_TO_SHOW_TAC; FIRST_X_ASSUM (MP_TAC o (MATCH_MP Local_lemmas.CVX_LO_IMP_LO)); FIRST_X_ASSUM_ST `circular` MP_TAC; BY(MESON_TAC[Wrgcvdr_cizmrrh.CIZMRRH]); REPEAT WEAKER_STRIP_TAC; INTRO_TAC Jkqewgv.JKQEWGV3 [`s`;`vv`;`v`;`w`]; ASM_REWRITE_TAC[LET_THM]; TYPIFY `v IN V /\ w IN V` (C SUBGOAL_THEN ASSUME_TAC); RULE_ASSUM_TAC(REWRITE_RULE[Wrgcvdr_cizmrrh.lunar]); BY(FIRST_X_ASSUM MP_TAC THEN SET_TAC[]); TYPIFY `!v. v IN V ==> ?i. v = vv i` (C SUBGOAL_THEN ASSUME_TAC); GEN_TAC; EXPAND_TAC "V";
BY(REWRITE_TAC[IN_IMAGE;IN_UNIV]); FIRST_X_ASSUM (C INTRO_TAC [`v`]); ASM_REWRITE_TAC[]; REPEAT WEAKER_STRIP_TAC; INTRO_TAC (REWRITE_RULE[LET_THM] (GSYM INTERIOR_ANGLE1_AZIM)) [`s`;`vv`;`i`]; ASM_REWRITE_TAC[IN]; DISCH_TAC; FIRST_X_ASSUM_ST `pi` MP_TAC; ASM_REWRITE_TAC[]; MATCH_MP_TAC (arith `y < x ==> ~(x < y)`); FIRST_X_ASSUM (C INTRO_TAC [`i`;`w`]); ANTS_TAC; BY(ASM_MESON_TAC[]); DISCH_TAC; MATCH_MP_TAC (UNDISCH SYNQIWN); TYPIFY `s` EXISTS_TAC; ASM_REWRITE_TAC[]; TYPIFY_GOAL_THEN `cstab <= dist(vv (SUC i),vv(i+ scs_k_v39 s - 1))` (unlist REWRITE_TAC); FIRST_X_ASSUM MATCH_MP_TAC; MATCH_MP_TAC scs_diag_2; BY(ASM_REWRITE_TAC[]); COMMENT "final kill"; BY(FIRST_X_ASSUM MP_TAC THEN MESON_TAC[]) ]);; (* }}} *)
let EAR_SOL_NN = 
prove_by_refinement( `main_nonlinear_terminal_v11 ==> ( !y1 y2 y3 y4 y5 y6. &2 <= y1 /\ y1 <= &2 * h0 /\ &2 <= y2 /\ y2 <= &2 * h0 /\ &2 <= y3 /\ y3 <= &2 * h0 /\ cstab <= y4 /\ y4 <= #3.915 /\ y5 = &2 /\ y6 = &2 /\ &0 <= delta_y y1 y2 y3 y4 y5 y6 ==> &0 <= sol_y y1 y2 y3 y4 y5 y6)`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; COMMENT "delta=0";
ASM_CASES_TAC `delta_y y1 y2 y3 y4 y5 y6 = &0`; INTRO_TAC (UNDISCH Terminal.EAR_DIH1_DELTA_0) [`y1`;`y2`;`y3`;`y4`;`y5`;`y6`]; ANTS_TAC; BY(REPEAT (FIRST_X_ASSUM MP_TAC) THEN REAL_ARITH_TAC); DISCH_TAC; REWRITE_TAC[Sphere.sol_y]; ASM_REWRITE_TAC[]; INTRO_TAC Terminal.DIH_Y_NN [`y2`;`y3`;`y1`;`(&2)`;`(&2)`;`y4`]; ANTS_TAC; FIRST_X_ASSUM_ST `delta_y` MP_TAC; ASM_REWRITE_TAC[Merge_ineq.delta_y_sym]; BY(ASM_TAC THEN REAL_ARITH_TAC); INTRO_TAC Terminal.DIH_Y_NN [`y3`;`y1`;`y2`;`(&2)`;`y4`;`(&2)`]; ANTS_TAC; FIRST_X_ASSUM_ST `delta_y` MP_TAC; ASM_REWRITE_TAC[Merge_ineq.delta_y_sym]; BY(ASM_TAC THEN REAL_ARITH_TAC); BY(REAL_ARITH_TAC); COMMENT "replace solid angle"; TYPIFY `&0 < delta_y y1 y2 y3 y4 y5 y6` (C SUBGOAL_THEN MP_TAC); BY(REPEAT (FIRST_X_ASSUM MP_TAC) THEN REAL_ARITH_TAC); DISCH_TAC; MATCH_MP_TAC (arith `&0 < x ==> &0 <= x`); REWRITE_TAC[Merge_ineq.sol_y_sol_x]; MATCH_MP_TAC Terminal.sol_x_nn; REPEAT (GMATCH_SIMP_TAC REAL_LT_MUL_EQ); REWRITE_TAC[Trigonometry1.UPS_X_SQUARES]; REPEAT (GMATCH_SIMP_TAC REAL_LT_MUL_EQ); TYPIFY `&0 < eulerA_x (y1 * y1) (y2 * y2) (y3 * y3) (y4 * y4) (y5 * y5) (y6 * y6)` (C SUBGOAL_THEN (unlist REWRITE_TAC)); INTRO_TAC (Terminal.get_main_nonlinear "4821120729") [`y1`;`y2`;`y3`;`y4`;`y5`;`y6`]; REWRITE_TAC[Sphere.ineq;Sphere.y_of_x;arith `x > &0 <=> &0 < x`]; BY(REPEAT (FIRST_X_ASSUM MP_TAC) THEN REWRITE_TAC[Appendix.cstab] THEN REAL_ARITH_TAC); TYPIFY `&0 < delta_x (y1 * y1) (y2 * y2) (y3 * y3) (y4 * y4) (y5 * y5) (y6 * y6)` (C SUBGOAL_THEN (unlist REWRITE_TAC)); FIRST_X_ASSUM MP_TAC; BY(REWRITE_TAC[Sphere.delta_y]); BY(REPEAT (FIRST_X_ASSUM MP_TAC) THEN (REWRITE_TAC[Appendix.cstab;Sphere.h0]) THEN REAL_ARITH_TAC) ]);; (* }}} *)
let scs_mk_unadorned_unadorned = 
prove_by_refinement( `!k d a b. unadorned_v39 (mk_unadorned_v39 k d a b)`,
(* {{{ proof *) [ BY(REWRITE_TAC[Appendix.unadorned_v39;Terminal.scs_unadorned_explicit]) ]);;
(* }}} *)
let scs_basic_unadorned = 
prove_by_refinement( `!k d a b. scs_basic_v39 (mk_unadorned_v39 k d a b)`,
(* {{{ proof *) [ BY(REWRITE_TAC[Appendix.scs_basic;Terminal.scs_unadorned_explicit;scs_mk_unadorned_unadorned]) ]);;
(* }}} *)
let scs_diag_cs_adj = 
prove_by_refinement( `!k a b i j. scs_diag k i j ==> cs_adj k a b i j = b`,
(* {{{ proof *) [ REWRITE_TAC[Appendix.scs_diag;Appendix.cs_adj]; BY(ASM_MESON_TAC[]) ]);;
(* }}} *)
let cs_adj_SUC = 
prove_by_refinement( `!k a b i j. 1 < k ==> cs_adj k a b i (SUC i) = a`,
(* {{{ proof *) [ REWRITE_TAC[Appendix.scs_diag;Appendix.cs_adj]; BY(MESON_TAC[Qknvmlb.SUC_MOD_NOT_EQ]) ]);;
(* }}} *)
let scs_6T1_props = 
prove_by_refinement( `scs_k_v39 scs_6T1 = 6 /\ scs_basic_v39 scs_6T1 /\ (!vv i j. BBs_v39 scs_6T1 vv /\ scs_diag 6 i j ==> cstab <= dist(vv i,vv j)) /\ (!vv i. BBs_v39 scs_6T1 vv ==> dist(vv i, vv(SUC i)) = &2)`,
(* {{{ proof *) [ SUBCONJ_TAC; BY(REWRITE_TAC[Appendix.scs_6T1;Terminal.scs_unadorned_explicit;]); DISCH_TAC; SUBCONJ_TAC; BY(REWRITE_TAC[Appendix.scs_6T1;scs_basic_unadorned]); DISCH_TAC; MP_TAC (REWRITE_RULE[Appendix.scs_6T1] is_scs_6T1); REWRITE_TAC[Appendix.scs_6T1;Appendix.BBs_v39;Terminal.scs_unadorned_explicit;LET_THM;Appendix.is_scs_v39]; REPEAT WEAKER_STRIP_TAC; CONJ_TAC; REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM (MP_TAC o (MATCH_MP scs_diag_cs_adj)); BY(FIRST_X_ASSUM_ST `cs_adj` MP_TAC THEN MESON_TAC[]); REPEAT WEAKER_STRIP_TAC; BY(FIRST_X_ASSUM_ST `cs_adj` MP_TAC THEN MESON_TAC[cs_adj_SUC;arith `&2 <= x /\ x <= &2 ==> x = &2`;arith `1 < 6`]) ]);;
(* }}} *)
let scs_6T1_generic = 
prove_by_refinement( `main_nonlinear_terminal_v11 ==> (!vv. (let V = IMAGE vv (:num) in let E = IMAGE (\i. {vv i, vv (SUC i)}) (:num) in BBs_v39 scs_6T1 vv /\ taustar_v39 scs_6T1 vv < &0 ==> scs_generic vv))`,
(* {{{ proof *) [ REWRITE_TAC[LET_THM]; REPEAT WEAKER_STRIP_TAC; MATCH_MP_TAC (UNDISCH (REWRITE_RULE[LET_THM] RRCWNS_WEAK)); TYPIFY `scs_6T1` EXISTS_TAC; ASM_REWRITE_TAC[is_scs_6T1]; ASSUME_TAC scs_6T1_props; ASM_REWRITE_TAC[]; REWRITE_TAC[arith `3 < 6`;(REWRITE_RULE[GSYM Appendix.scs_6T1] is_scs_6T1)]; CONJ_TAC; BY(ASM_MESON_TAC[]); REPEAT WEAKER_STRIP_TAC; REWRITE_TAC[arith `i+6 - 1 = i+5`]; TYPIFY `dist(vv i,vv(i+5)) = dist(vv(i+5),vv(SUC(i+5)))` (C SUBGOAL_THEN SUBST1_TAC); TYPIFY `vv (SUC (i+5)) = vv(i)` ENOUGH_TO_SHOW_TAC; BY(DISCH_THEN SUBST1_TAC THEN REWRITE_TAC[DIST_SYM]); RULE_ASSUM_TAC(REWRITE_RULE[Appendix.BBs_v39;LET_THM;scs_6T1_props;Sphere.periodic]); BY(ASM_REWRITE_TAC[arith `SUC (i+5) = i + 6`]); ASM_SIMP_TAC[]; BY(REWRITE_TAC[Sphere.h0] THEN REAL_ARITH_TAC) ]);;
(* }}} *)
let empty_6T1 = 
prove_by_refinement( `main_nonlinear_terminal_v11 ==> (!vv. BBs_v39 scs_6T1 vv ==> &0 <= taustar_v39 scs_6T1 vv)` ,
(* {{{ proof *) [ COMMENT "preliminaries, sol < pi";
REPEAT WEAKER_STRIP_TAC; PROOF_BY_CONTR_TAC; ASSUME_TAC (REWRITE_RULE[GSYM Appendix.scs_6T1] (is_scs_6T1)); COMMENT "new material"; TYPIFY `!i j. i < 6 /\ j < 6 /\ vv i = vv j ==> i = j` (C SUBGOAL_THEN ASSUME_TAC); MATCH_MP_TAC vv_inj_lemma; BY(ASM_MESON_TAC[Appendix.scs_6T1;IN;Terminal.scs_unadorned_explicit]); INTRO_TAC Jkqewgv.JKQEWGV1 [`scs_6T1`;`vv`]; ANTS_TAC; ASM_REWRITE_TAC[]; ASM_SIMP_TAC[arith `~(&0 <= t) ==> (t < &0)`]; REWRITE_TAC[Appendix.scs_6T1]; ASM_REWRITE_TAC[Terminal.scs_unadorned_explicit]; BY(ARITH_TAC); DISCH_TAC; TYPIFY `scs_generic vv` (C SUBGOAL_THEN ASSUME_TAC); MATCH_MP_TAC (REWRITE_RULE[LET_THM] (UNDISCH scs_6T1_generic)); BY(ASM_REWRITE_TAC[] THEN ASM_TAC THEN REAL_ARITH_TAC); COMMENT "big expansion"; REPEAT (FIRST_X_ASSUM MP_TAC); REWRITE_TAC[Appendix.taustar_v39;LET_DEF;LET_END_DEF;Appendix.BBs_v39;Terminal.scs_unadorned_explicit;Appendix.scs_6T1]; REWRITE_TAC[arith `~(6 <= 3)`;Terminal.dsv_unadorned]; REPEAT WEAKER_STRIP_TAC; PROOF_BY_CONTR_TAC; FIRST_X_ASSUM_ST `tau_fun` MP_TAC; REWRITE_TAC[]; GMATCH_SIMP_TAC (REWRITE_RULE[LET_THM] Terminal.tau_fun_azim); TYPIFY `6` EXISTS_TAC; ASM_REWRITE_TAC[arith `3 <= 6`;arith `&6 - &2 = &4`]; TYPIFY `!i. dist(vv i,vv (i+1)) = &2` (C SUBGOAL_THEN ASSUME_TAC); REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM_ST `dist` (C INTRO_TAC [`i`;`i+1`]); REWRITE_TAC[Appendix.cs_adj;arith `i + 1 = SUC i`]; SIMP_TAC[Qknvmlb.SUC_MOD_NOT_EQ;arith `1< 6`]; BY(REAL_ARITH_TAC); COMMENT "end expansion"; COMMENT "edge lengths"; TYPIFY `!i. cstab <= dist(vv i,vv (i+2))` (C SUBGOAL_THEN ASSUME_TAC); REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM_ST `dist` (C INTRO_TAC [`i`;`i+2`]); TYPIFY `cs_adj 6 (&2) cstab i (i+2) = cstab` ENOUGH_TO_SHOW_TAC; DISCH_THEN SUBST1_TAC; BY(MESON_TAC[]); REWRITE_TAC[Appendix.cs_adj]; COND_CASES_TAC; FIRST_X_ASSUM MP_TAC; BY(MESON_TAC[arith `~(0=6) /\ (2 < 6) /\ ~(0=2)`;Oxl_2012.MOD_INJ1]); COND_CASES_TAC; FIRST_X_ASSUM MP_TAC; STRIP_TAC; FIRST_X_ASSUM MP_TAC; REWRITE_TAC[arith `SUC i = i+1 /\ i + 2 = (i+1) + 1`]; BY(MESON_TAC[arith `~(0=6) /\ (1 < 6) /\ ~(0=1)`;Oxl_2012.MOD_INJ1]); FIRST_X_ASSUM MP_TAC; REWRITE_TAC[arith `SUC (i+2)=i+3`]; BY(MESON_TAC[arith `~(0=6) /\ (3 < 6) /\ ~(0=3)`;Oxl_2012.MOD_INJ1]); BY(REWRITE_TAC[]); TYPIFY `!i. &2 <= norm (vv i) /\ norm (vv i) <= &2 * h0` (C SUBGOAL_THEN ASSUME_TAC); GEN_TAC; REWRITE_TAC[GSYM Fnjlbxs.in_ball_annulus]; RULE_ASSUM_TAC(REWRITE_RULE[Terminal.IMAGE_SUBSET_IN;IN_UNIV]); BY(ASM_REWRITE_TAC[]); TYPIFY `!i. dist(vv i,vv(i+2)) <= &4` (C SUBGOAL_THEN ASSUME_TAC); GEN_TAC; MATCH_MP_TAC REAL_LE_TRANS; TYPIFY `dist(vv i,vv (i+1)) + dist(vv (i+1),vv(i+2))` EXISTS_TAC; CONJ_TAC; BY(REWRITE_TAC[DIST_TRIANGLE]); ASM_REWRITE_TAC[arith `i+2 = (i+1)+1`]; BY(REAL_ARITH_TAC); TYPIFY `!i. dist(vv i,vv (i+2)) <= #3.915` (C SUBGOAL_THEN ASSUME_TAC); REPEAT WEAKER_STRIP_TAC; INTRO_TAC (Terminal.get_main_nonlinear "6459846571") [`norm(vv (i+1))`;`norm (vv i)`;`norm (vv (i+2))`;`dist(vv i,vv (i+2))`;`dist(vv (i+1),vv(i+2))`;`dist(vv i,vv(i+1))`]; REWRITE_TAC[Sphere.ineq;TAUT `a ==> b ==> c <=> a /\ b ==> c`]; ANTS_TAC; ASM_REWRITE_TAC[arith `(i+2 = (i+1)+1)`]; TYPIFY `#2.52 = &2 * h0` (C SUBGOAL_THEN SUBST1_TAC); BY(REWRITE_TAC[Sphere.h0] THEN REAL_ARITH_TAC); ASM_REWRITE_TAC[arith `&2 <= &2`]; CONJ_TAC; FIRST_X_ASSUM_ST `cstab` (C INTRO_TAC [`i`]); REWRITE_TAC[Sphere.cstab;arith `(i+1)+1 = i+2`]; BY(REAL_ARITH_TAC); BY(FIRST_X_ASSUM (C INTRO_TAC [`i`]) THEN REWRITE_TAC[arith `(i+1)+1 = i+2`] THEN REAL_ARITH_TAC); TYPIFY `dist(vv i,vv(i+1)) = dist(vv(i+1),vv(i))` (C SUBGOAL_THEN SUBST1_TAC); BY(REWRITE_TAC[DIST_SYM]); REWRITE_TAC[arith `x < y <=> ~(y <= x)`;REWRITE_RULE[LET_THM] Tame_lemmas.delta_y_pos]; BY(REAL_ARITH_TAC); COMMENT "azim le pi"; TYPIFY `!i. azim (vec 0) (vv i) (vv (i+1)) (vv (i + 6 -1)) <= pi` (C SUBGOAL_THEN ASSUME_TAC); RULE_ASSUM_TAC(REWRITE_RULE[Localization.convex_local_fan]); ASM_TAC THEN REPEAT WEAKER_STRIP_TAC; REWRITE_TAC[arith `i+1 = SUC i`]; GMATCH_SIMP_TAC (GSYM azim_in_fan_azim); TYPIFY `IMAGE (\i. {vv i, vv (SUC i)}) (:num)` EXISTS_TAC; ASM_REWRITE_TAC[arith `3 <= 6`]; CONJ_TAC; BY(ASM_MESON_TAC[]); BY(ASM_MESON_TAC[IN_IMAGE;IN_UNIV]); COMMENT "expand sol_local"; FIRST_X_ASSUM_ST `sol_local` MP_TAC; GMATCH_SIMP_TAC (REWRITE_RULE[LET_THM] sol_local_azim); TYPIFY `6` EXISTS_TAC; CONJ_TAC; BY(ASM_MESON_TAC[arith `3 <= 6`]); DISCH_TAC; COMMENT "split azim"; RULE_ASSUM_TAC(REWRITE_RULE[Appendix.scs_generic]); TYPIFY `!i. azim(vec 0) (vv i) (vv (SUC i)) (vv (i + 5)) = azim(vec 0) (vv i) (vv (SUC i)) (vv (i+2)) + azim(vec 0) (vv i) (vv (i+2)) (vv (i+4)) + azim (vec 0) (vv i) (vv (i+4)) (vv (i+5))` (C SUBGOAL_THEN ASSUME_TAC); GEN_TAC; INTRO_TAC Terminal.vv_split_azim_generic [`vv`;`6`;`i`;`4`;`5`]; ASM_REWRITE_TAC[LET_THM;arith `3 <= 6 /\ 0 < 4 /\ 4 < 5 /\ 5 < 6`]; DISCH_THEN SUBST1_TAC; INTRO_TAC Terminal.vv_split_azim_generic [`vv`;`6`;`i`;`2`;`4`]; ASM_REWRITE_TAC[LET_THM;arith `3 <= 6 /\ 0 < 2 /\ 2 < 4 /\ 4 < 6`]; BY(REAL_ARITH_TAC); COMMENT "expand sums"; FIRST_X_ASSUM_ST `sum` MP_TAC; TYPIFY `{i | i < 6 } = {0,1,2,3,4,5}` (C SUBGOAL_THEN SUBST1_TAC); REWRITE_TAC[EXTENSION;IN_ELIM_THM;IN_INSERT;NOT_IN_EMPTY]; BY(ARITH_TAC); REPEAT (GMATCH_SIMP_TAC Marchal_cells_2_new.SUM_CLAUSES_alt THEN REWRITE_TAC[NOT_IN_EMPTY;IN_INSERT;arith `~(0=1)/\ ~(0=2)/\ ~(0=3) /\ ~(0=4) /\ ~(0=5) /\ ~(1=2) /\ ~(1 = 3) /\ ~(1 = 4) /\ ~(1=5) /\ ~(2 = 3) /\ ~(2 = 4) /\ ~(2 = 5) /\ ~(3 = 4) /\ ~(3 =5) /\ ~(4 = 5)`]); REWRITE_TAC[SUM_CLAUSES;Geomdetail.FINITE6]; REWRITE_TAC[arith `i + 1 = SUC i`]; FIRST_ASSUM (C INTRO_TAC [`0`]); FIRST_ASSUM (C INTRO_TAC [`2`]); FIRST_X_ASSUM (C INTRO_TAC [`4`]); FIRST_ASSUM (C INTRO_TAC [`0`]); FIRST_ASSUM (C INTRO_TAC [`1`]); FIRST_ASSUM (C INTRO_TAC [`2`]); FIRST_ASSUM (C INTRO_TAC [`3`]); FIRST_ASSUM (C INTRO_TAC [`4`]); FIRST_X_ASSUM (C INTRO_TAC [`5`]); REPEAT WEAKER_STRIP_TAC; TYPIFY `azim (vec 0) (vv 4) (vv (SUC 4)) (vv (4 + 2)) <= pi /\ azim (vec 0) (vv 4) (vv (4 + 2)) (vv (4 + 4)) <= pi /\ azim (vec 0) (vv 4) (vv (4 + 4)) (vv (4 + 5)) <= pi /\ azim (vec 0) (vv 2) (vv (SUC 2)) (vv (2 + 2)) <= pi /\ azim (vec 0) (vv 2) (vv (2 + 2)) (vv (2 + 4)) <= pi /\ azim (vec 0) (vv 2) (vv (2 + 4)) (vv (2 + 5)) <= pi /\ azim (vec 0) (vv 0) (vv (SUC 0)) (vv (0 + 2)) <= pi /\ azim (vec 0) (vv 0) (vv (0 + 2)) (vv (0 + 4)) <= pi /\ azim (vec 0) (vv 0) (vv (0 + 4)) (vv (0 + 5)) <= pi` (C SUBGOAL_THEN ASSUME_TAC); MP_TAC Counting_spheres.AZIM_NN; REPEAT (FIRST_X_ASSUM_ST `x <= pi` MP_TAC); ASM_REWRITE_TAC[arith `i + 1 = SUC i /\ 6 - 1 = 5`]; BY(MESON_TAC[arith `&0 <= x /\ &0 <= y /\ &0 <= z /\ x + y + z <= pi ==> x <= pi /\ y <= pi /\ z <= pi`]); FIRST_X_ASSUM_ST `&6 - &2` MP_TAC; ASM_REWRITE_TAC[arith `6 - 1 = 5`]; RULE_ASSUM_TAC(REWRITE_RULE[arith `6 - 1 = 5 /\ i + 1 = SUC i`]); COMMENT "collinearity"; TYPIFY `!i j. ~(vv i = vv j) ==> ~collinear {vec 0,vv i,vv j}` (C SUBGOAL_THEN ASSUME_TAC); REPEAT WEAKER_STRIP_TAC; INTRO_TAC Nkezbfc_local.PROPERTIES_GENERIC_LOCAL_FAN [`IMAGE vv (:num)`;`IMAGE (\i. {vv i, vv (SUC i)}) (:num)`;`IMAGE (\i. vv i,vv (SUC i)) (:num)`;`vv i`]; ASM_SIMP_TAC[Local_lemmas.CVX_LO_IMP_LO]; REWRITE_TAC[Qknvmlb.IN_IMAGE_VV]; DISCH_THEN (C INTRO_TAC [`vv j`]); BY(ASM_REWRITE_TAC[Qknvmlb.IN_IMAGE_VV]); COMMENT "convert to dih"; ASSUME_TAC (arith `SUC 0 = 1 /\ SUC 1 = 2 /\ SUC 2 = 3 /\ SUC 3 = 4 /\ SUC 4 = 5 /\ SUC 5 = 6 /\ 0+2=2 /\ 0+4=4 /\ 0+5=5 /\ 1+5=6 /\ 3+5 = 8 /\ 5 + 5 = 10 /\ 2 + 2 = 4 /\ 2+4=6 /\ 2+5=7 /\ 4+2=6 /\ 4+4=8 /\ 4+5=9`); ASM_REWRITE_TAC[]; TYPIFY `vv 6 = vv 0 /\ vv 7 = vv 1 /\ vv 8 = vv 2 /\ vv 9 = vv 3 /\ vv 10 = vv 4` (C SUBGOAL_THEN ASSUME_TAC); ONCE_REWRITE_TAC[arith `6 = 0 + 6 /\ 7 = 1 + 6 /\ 8 = 2 + 6 /\ 9 = 3 + 6 /\ 10 = 4 + 6`]; FIRST_X_ASSUM_ST `periodic` MP_TAC; BY(SIMP_TAC [Sphere.periodic]); ASM_REWRITE_TAC[]; REPEAT (FIRST_X_ASSUM_ST `azim` MP_TAC) THEN ASM_REWRITE_TAC[]; REPEAT WEAKER_STRIP_TAC; TYPIFY `!i j. (i < 6 /\ j < 6 /\ ~(i = j)) ==> ~collinear {vec 0 ,vv i ,vv j}` (C SUBGOAL_THEN ASSUME_TAC); REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM MP_TAC; REWRITE_TAC[]; FIRST_X_ASSUM MATCH_MP_TAC; DISCH_TAC; FIRST_X_ASSUM_ST `~` MP_TAC; REWRITE_TAC[]; FIRST_X_ASSUM MATCH_MP_TAC; BY(ASM_REWRITE_TAC[]); TYPIFY `azim (vec 0) (vv 0) (vv 1) (vv 2) = dihV (vec 0) (vv 0) (vv 1) (vv 2) /\ azim (vec 0) (vv 0) (vv 2) (vv 4) = dihV (vec 0) (vv 0) (vv 2) (vv 4) /\ azim (vec 0) (vv 0) (vv 4) (vv 5) = dihV (vec 0) (vv 0) (vv 4) (vv 5) /\ azim (vec 0) (vv 1) (vv 2) (vv 0) = dihV (vec 0) (vv 1) (vv 2) (vv 0) /\ azim (vec 0) (vv 2) (vv 3) (vv 4) = dihV (vec 0) (vv 2) (vv 3) (vv 4) /\ azim (vec 0) (vv 2) (vv 4) (vv 0) = dihV (vec 0) (vv 2) (vv 4) (vv 0) /\ azim (vec 0) (vv 2) (vv 0) (vv 1) = dihV (vec 0) (vv 2) (vv 0) (vv 1) /\ azim (vec 0) (vv 3) (vv 4) (vv 2) = dihV (vec 0) (vv 3) (vv 4) (vv 2) /\ azim (vec 0) (vv 4) (vv 5) (vv 0) = dihV (vec 0) (vv 4) (vv 5) (vv 0) /\ azim (vec 0) (vv 4) (vv 0) (vv 2) = dihV (vec 0) (vv 4) (vv 0) (vv 2) /\ azim (vec 0) (vv 4) (vv 2) (vv 3) = dihV (vec 0) (vv 4) (vv 2) (vv 3) /\ azim (vec 0) (vv 5) (vv 0) (vv 4) = dihV (vec 0) (vv 5) (vv 0) (vv 4)` (C SUBGOAL_THEN ASSUME_TAC); ASSUME_TAC (arith `0 < 6 /\ 1 < 6 /\ 2 < 6 /\ 3 < 6 /\ 4 < 6 /\ 5 < 6 /\ ~(0=1)/\ ~(0=2)/\ ~(0=3) /\ ~(0=4) /\ ~(0=5) /\ ~(1=2) /\ ~(1 = 3) /\ ~(1 = 4) /\ ~(1=5) /\ ~(2 = 3) /\ ~(2 = 4) /\ ~(2 = 5) /\ ~(3 = 4) /\ ~(3 =5) /\ ~(4 = 5)`); BY(REPEAT (CONJ_TAC) THEN MATCH_MP_TAC Polar_fan.AZIM_DIHV_SAME_STRONG THEN ASM_REWRITE_TAC[] THEN CONJ_TAC THEN FIRST_X_ASSUM MATCH_MP_TAC THEN ASM_REWRITE_TAC[]); ASM_REWRITE_TAC[]; TYPIFY `#0.712 <= tau3 (vv 0) (vv 1) (vv 2) + tau3 (vv 0) (vv 2) (vv 4) + tau3 (vv 0) (vv 4) (vv 5) + tau3 (vv 2) (vv 3) (vv 4)` ENOUGH_TO_SHOW_TAC; ONCE_REWRITE_TAC[arith `&0 <= a - b - c <=> c <= a - b`]; MATCH_MP_TAC (arith `d = #0.712 /\ ts = rs ==> (#0.712 <= ts ==> d <= rs)`); REWRITE_TAC[Appendix.d_tame;arith `~( 6=3) /\ ~(6 = 4) /\ ~(6 = 5)`]; REWRITE_TAC[Appendix.tau3;Appendix.rho_rho_fun]; BY(REAL_ARITH_TAC); REPEAT (GMATCH_SIMP_TAC Terminal.tau3_taum_40); ASM_REWRITE_TAC[]; RULE_ASSUM_TAC(REWRITE_RULE[Terminal.IMAGE_SUBSET_IN;IN_UNIV]); ASM_REWRITE_TAC[]; FIRST_X_ASSUM_ST `dist(a,b) = &2` MP_TAC; DISCH_TAC; FIRST_ASSUM (C INTRO_TAC [`0`]); FIRST_ASSUM (C INTRO_TAC [`1`]); FIRST_ASSUM (C INTRO_TAC [`2`]); FIRST_ASSUM (C INTRO_TAC [`3`]); FIRST_ASSUM (C INTRO_TAC [`4`]); FIRST_X_ASSUM (C INTRO_TAC [`5`]); ASM_REWRITE_TAC[DIST_SYM]; REPEAT WEAKER_STRIP_TAC THEN ASM_REWRITE_TAC[]; FIRST_X_ASSUM_ST `cstab <= dist(a,b)` MP_TAC; DISCH_TAC; FIRST_ASSUM (C INTRO_TAC [`0`]); FIRST_ASSUM (C INTRO_TAC [`2`]); FIRST_X_ASSUM (C INTRO_TAC [`4`]); ASM_REWRITE_TAC[DIST_SYM]; REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM_ST `dist(a,b) <= #3.915` MP_TAC; DISCH_TAC; FIRST_ASSUM (C INTRO_TAC [`0`]); FIRST_ASSUM (C INTRO_TAC [`2`]); FIRST_X_ASSUM (C INTRO_TAC [`4`]); ASM_REWRITE_TAC[DIST_SYM]; REPEAT WEAKER_STRIP_TAC; REWRITE_TAC[TAUT `a /\ b /\ c <=> (a /\ b) /\ c`]; CONJ_TAC; BY(REPLICATE_TAC 12 (FIRST_X_ASSUM MP_TAC) THEN REWRITE_TAC[Sphere.cstab] THEN REAL_ARITH_TAC); COMMENT "introduce ineq"; INTRO_TAC Pent_hex.terminal_hex_taum [`norm (vv 0)`;`norm (vv 2)`;`norm (vv 4)`;`dist (vv 2,vv 4)`;`dist(vv 0,vv 4)`;`dist(vv 0,vv 2)`;`norm (vv 3)`;`norm(vv 1)`;`norm (vv 5)`]; REWRITE_TAC[Sphere.ineq;TAUT `a ==> b ==> c <=> a /\ b ==> c`]; ANTS_TAC; REPEAT (FIRST_X_ASSUM_ST `azim` kill); ASM_REWRITE_TAC[]; TYPIFY `#2.52 = &2 * h0` (C SUBGOAL_THEN SUBST1_TAC); BY(REWRITE_TAC[Sphere.h0] THEN REAL_ARITH_TAC); BY(ASM_REWRITE_TAC[DIST_SYM;GSYM Sphere.cstab]); COMMENT "break into final cases"; STRIP_TAC; FIRST_X_ASSUM MP_TAC; REWRITE_TAC[DIST_SYM]; REWRITE_TAC[Terminal.taum_sym]; BY(REAL_ARITH_TAC); PROOF_BY_CONTR_TAC; FIRST_X_ASSUM_ST `delta_y` MP_TAC; INTRO_TAC Tame_lemmas.delta_y_pos [`vv 5`;`vv 0`;`vv 4`]; ASM_REWRITE_TAC[LET_THM;DIST_SYM]; BY(REAL_ARITH_TAC); PROOF_BY_CONTR_TAC; FIRST_X_ASSUM_ST `delta_y` MP_TAC; INTRO_TAC Tame_lemmas.delta_y_pos [`vv 1`;`vv 0`;`vv 2`]; ASM_REWRITE_TAC[LET_THM;DIST_SYM]; BY(REAL_ARITH_TAC); PROOF_BY_CONTR_TAC; FIRST_X_ASSUM_ST `delta_y` MP_TAC; INTRO_TAC Tame_lemmas.delta_y_pos [`vv 3`;`vv 2`;`vv 4`]; ASM_REWRITE_TAC[LET_THM;DIST_SYM]; BY(REAL_ARITH_TAC); PROOF_BY_CONTR_TAC; FIRST_X_ASSUM_ST `eulerA_x` MP_TAC; REWRITE_TAC[]; MATCH_MP_TAC (arith ` e > &0 ==> ~(e < &0)`); INTRO_TAC (UNDISCH DIH_IMP_EULER_A_POS) [`(vec 0):real^3`;`vv 0`;`vv 2`;`vv 4`]; REWRITE_TAC[Sphere.y_of_x;DIST_SYM;LET_THM;DIST_0]; DISCH_THEN MATCH_MP_TAC; ASM_REWRITE_TAC[GSYM Sphere.cstab]; TYPIFY_GOAL_THEN `~collinear {vec 0, vv 0, vv 2} /\ ~collinear {vec 0, vv 2, vv 4} /\ ~collinear {vec 0, vv 0, vv 4}` (unlist REWRITE_TAC); BY(REPEAT CONJ_TAC THEN FIRST_X_ASSUM MATCH_MP_TAC THEN REWRITE_TAC[arith `~(0=2) /\ ~(2 = 4) /\ ~(0=4) /\ 0 < 6 /\ 2 < 6 /\ 4 < 6`]); FIRST_X_ASSUM_ST `(&6 - &2)` MP_TAC; ASM_REWRITE_TAC[]; TYPIFY `pi <= dihV (vec 0) (vv 1) (vv 2) (vv 0) + dihV (vec 0) (vv 2) (vv 0) (vv 1) + dihV (vec 0) (vv 0) (vv 1) (vv 2) /\pi <= dihV (vec 0) (vv 3) (vv 4) (vv 2) + dihV (vec 0) (vv 4) (vv 2) (vv 3)+dihV (vec 0) (vv 2) (vv 3) (vv 4) /\ pi <= dihV (vec 0) (vv 5) (vv 0) (vv 4) + dihV (vec 0) (vv 0) (vv 4) (vv 5) +dihV (vec 0) (vv 4) (vv 5) (vv 0) ` ENOUGH_TO_SHOW_TAC; REWRITE_TAC [DIHV_SYM]; BY(REAL_ARITH_TAC); REPEAT (GMATCH_SIMP_TAC (REWRITE_RULE[LET_THM] Merge_ineq.DIHV_EQ_DIH_Y)); FIRST_X_ASSUM_ST `collinear` (REPEAT o GMATCH_SIMP_TAC); REWRITE_TAC[arith `0 < 6 /\ 1 < 6 /\ 2 < 6 /\ 3 < 6 /\ 4 < 6 /\ 5 < 6 /\ ~(0=1)/\ ~(0=2)/\ ~(0=3) /\ ~(0=4) /\ ~(0=5) /\ ~(1=2) /\ ~(1 = 3) /\ ~(1 = 4) /\ ~(1=5) /\ ~(2 = 3) /\ ~(2 = 4) /\ ~(2 = 5) /\ ~(3 = 4) /\ ~(3 =5) /\ ~(4 = 5)`]; REWRITE_TAC[arith `pi <= a + b + c <=> &0 <= a + b + c - pi`;GSYM Sphere.sol_y;DIST_SYM]; REPEAT CONJ_TAC THEN (MATCH_MP_TAC (UNDISCH EAR_SOL_NN)) THEN ASM_REWRITE_TAC[DIST_0]; INTRO_TAC Tame_lemmas.delta_y_pos [`vv 1`;`vv 2`;`vv 0`]; BY(ASM_REWRITE_TAC[LET_THM;DIST_SYM]); INTRO_TAC Tame_lemmas.delta_y_pos [`vv 3`;`vv 4`;`vv 2`]; BY(ASM_REWRITE_TAC[LET_THM;DIST_SYM]); INTRO_TAC Tame_lemmas.delta_y_pos [`vv 5`;`vv 0`;`vv 4`]; BY(ASM_REWRITE_TAC[LET_THM;DIST_SYM]) ]);; (* }}} *)
let is_scs_5T1 = 
prove_by_refinement( `is_scs_v39 (scs_5T1)`,
(* {{{ proof *) [ REWRITE_TAC[Appendix.scs_5T1]; MATCH_MP_TAC is_scs_adj; REWRITE_TAC[Appendix.d_tame;Sphere.cstab]; REWRITE_TAC[arith `~(5 = 3) /\ (3 <= 5) /\ (5 <= 6) /\ (3 < 5)`]; BY(REWRITE_TAC[Sphere.h0] THEN REAL_ARITH_TAC) ]);;
(* }}} *)
let scs_5T1_props = 
prove_by_refinement( `scs_k_v39 scs_5T1 = 5 /\ scs_basic_v39 scs_5T1 /\ (!vv i j. BBs_v39 scs_5T1 vv /\ scs_diag 5 i j ==> cstab <= dist(vv i,vv j)) /\ (!vv i. BBs_v39 scs_5T1 vv ==> dist(vv i, vv(SUC i)) = &2)`,
(* {{{ proof *) [ SUBCONJ_TAC; BY(REWRITE_TAC[Appendix.scs_5T1;Terminal.scs_unadorned_explicit;]); DISCH_TAC; SUBCONJ_TAC; BY(REWRITE_TAC[Appendix.scs_5T1;scs_basic_unadorned]); DISCH_TAC; MP_TAC is_scs_5T1; REWRITE_TAC[Appendix.scs_5T1;Appendix.BBs_v39;Terminal.scs_unadorned_explicit;LET_THM;Appendix.is_scs_v39]; REPEAT WEAKER_STRIP_TAC; CONJ_TAC; REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM (MP_TAC o (MATCH_MP scs_diag_cs_adj)); BY(FIRST_X_ASSUM_ST `cs_adj` MP_TAC THEN MESON_TAC[]); REPEAT WEAKER_STRIP_TAC; BY(FIRST_X_ASSUM_ST `cs_adj` MP_TAC THEN MESON_TAC[cs_adj_SUC;arith `&2 <= x /\ x <= &2 ==> x = &2`;arith `1 < 5`]) ]);;
(* }}} *)
let scs_5T1_generic = 
prove_by_refinement( `main_nonlinear_terminal_v11 ==> (!vv. (let V = IMAGE vv (:num) in let E = IMAGE (\i. {vv i, vv (SUC i)}) (:num) in BBs_v39 scs_5T1 vv /\ taustar_v39 scs_5T1 vv < &0 ==> scs_generic vv))`,
(* {{{ proof *) [ REWRITE_TAC[LET_THM]; REPEAT WEAKER_STRIP_TAC; MATCH_MP_TAC (UNDISCH (REWRITE_RULE[LET_THM] RRCWNS_WEAK)); TYPIFY `scs_5T1` EXISTS_TAC; ASM_REWRITE_TAC[is_scs_5T1]; ASSUME_TAC scs_5T1_props; ASM_REWRITE_TAC[]; REWRITE_TAC[arith `3 < 5`;(is_scs_5T1)]; CONJ_TAC; BY(ASM_MESON_TAC[]); REPEAT WEAKER_STRIP_TAC; REWRITE_TAC[arith `i+5 - 1 = i+4`]; TYPIFY `dist(vv i,vv(i+4)) = dist(vv(i+4),vv(SUC(i+4)))` (C SUBGOAL_THEN SUBST1_TAC); TYPIFY `vv (SUC (i+4)) = vv(i)` ENOUGH_TO_SHOW_TAC; BY(DISCH_THEN SUBST1_TAC THEN REWRITE_TAC[DIST_SYM]); RULE_ASSUM_TAC(REWRITE_RULE[Appendix.BBs_v39;LET_THM;scs_5T1_props;Sphere.periodic]); BY(ASM_REWRITE_TAC[arith `SUC (i+4) = i + 5`]); ASM_SIMP_TAC[]; BY(REWRITE_TAC[Sphere.h0] THEN REAL_ARITH_TAC) ]);;
(* }}} *)
let periodic_sum_shift = 
prove_by_refinement( `!j f n. periodic f n /\ ~(n = 0) ==> sum { i | i < n} f = sum {i | i < n } (\i. f (j+i))`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; INTRO_TAC Oxl_def.periodic_sum [`f`;`n`]; ASM_REWRITE_TAC[]; DISCH_THEN (C INTRO_TAC [`j`]); TYPIFY `(0.. n - 1) = {i | i < n}` (C SUBGOAL_THEN SUBST1_TAC); REWRITE_TAC[EXTENSION;IN_NUMSEG;IN_ELIM_THM]; GEN_TAC; BY(ASM_TAC THEN ARITH_TAC); DISCH_THEN (SUBST1_TAC o GSYM); INTRO_TAC Oxl_def.BIJ_SUM [`{i | (i:num) < n}`;`j..n - 1 + j`;`f`;`(\i. j+(i:num))`]; ANTS_TAC; REWRITE_TAC[BIJ;INJ;SURJ]; SUBCONJ_TAC; REWRITE_TAC[IN_NUMSEG;IN_ELIM_THM]; BY(ASM_TAC THEN ARITH_TAC); DISCH_THEN (unlist REWRITE_TAC); REWRITE_TAC[IN_NUMSEG;IN_ELIM_THM]; REPEAT WEAKER_STRIP_TAC; TYPIFY `x - (j:num)` EXISTS_TAC; BY(ASM_TAC THEN ARITH_TAC); DISCH_THEN (SUBST1_TAC o GSYM); MATCH_MP_TAC SUM_EQ; BY(REWRITE_TAC[o_THM]) ]);;
(* }}} *) let c110186 = Flyspeck_constants.calc `atn (sqrt (#0.110186)) < #0.3205`;;
let LEMMA_7175074394 = 
prove_by_refinement( `main_nonlinear_terminal_v11 ==> (!y1 y2 y3 y4 y5 y6. ineq [ (&2,y1,#2.52); (&2,y2,#2.52); (&2,y3,#2.52); (&2,y4,&2); (#3.01,y5,#3.237); (&2,y6,&2) ] ( (delta_y y1 y2 y3 y4 y5 y6 <= &20) /\ (&0 <= delta_y y1 y2 y3 y4 y5 y6) ==> (dih_y y1 y2 y3 y4 y5 y6 < #0.3205) ))`,
(* {{{ proof *) [ ASM_REWRITE_TAC[Sphere.ineq;TAUT `a ==> b ==> c <=> a /\ b ==> c`;LET_THM]; REPEAT WEAKER_STRIP_TAC; INTRO_TAC (Terminal.get_main_nonlinear "2485876245a") [`y1`;`y2`;`y3`;`y4`;`y5`;`y6`]; ASM_REWRITE_TAC[Sphere.ineq;TAUT `a ==> b ==> c <=> a /\ b ==> c`;LET_THM]; ANTS_TAC; BY(ASM_TAC THEN REAL_ARITH_TAC); REWRITE_TAC[Sphere.delta4_y;Sphere.y_of_x]; DISCH_TAC; INTRO_TAC (Terminal.get_main_nonlinear "7175074394") [`y1`;`y2`;`y3`;`y4`;`y5`;`y6`]; ASM_REWRITE_TAC[Sphere.ineq;TAUT `a ==> b ==> c <=> a /\ b ==> c`;LET_THM]; ASM_SIMP_TAC [arith `x <= &20 ==> ~(x > &20)`]; DISCH_TAC; REWRITE_TAC[Sphere.dih_y;LET_THM]; GMATCH_SIMP_TAC Merge_ineq.lindih_lt; GMATCH_SIMP_TAC REAL_LT_MUL_EQ; CONJ_TAC; BY(ASM_TAC THEN REAL_ARITH_TAC); CONJ_TAC; CONJ_TAC; BY(MP_TAC Flyspeck_constants.bounds THEN REAL_ARITH_TAC); CONJ_TAC; BY(ASM_TAC THEN REAL_ARITH_TAC); BY(ASM_TAC THEN REAL_ARITH_TAC); TYPIFY `&0 <= (&4 * (y1 * y1) * delta_x (y1 * y1) (y2 * y2) (y3 * y3) (y4 * y4) (y5 * y5) (y6 * y6))` (C SUBGOAL_THEN ASSUME_TAC); REPEAT (GMATCH_SIMP_TAC REAL_LE_MUL); REWRITE_TAC[GSYM Sphere.delta_y]; BY(ASM_TAC THEN REAL_ARITH_TAC); GMATCH_SIMP_TAC Pack1.bp_bdt; GMATCH_SIMP_TAC SQRT_POS_LE; ASM_REWRITE_TAC[]; CONJ_TAC; GMATCH_SIMP_TAC REAL_LE_MUL; GMATCH_SIMP_TAC TAN_POS_PI2_LE; BY(MP_TAC Flyspeck_constants.bounds THEN ASM_TAC THEN REAL_ARITH_TAC); GMATCH_SIMP_TAC SQRT_POW_2; ASM_REWRITE_TAC[]; MATCH_MP_TAC REAL_LT_TRANS; TYPIFY `#0.110186 * delta4_squared_y y1 y2 y3 y4 y5 y6` EXISTS_TAC; CONJ_TAC; FIRST_X_ASSUM_ST `x1_delta_y` MP_TAC; BY(REWRITE_TAC[Sphere.x1_delta_y;Sphere.delta4_squared_y;Sphere.y_of_x;Sphere.x1_delta_x]); REWRITE_TAC[Sphere.delta4_squared_y;Sphere.y_of_x;Sphere.delta4_squared_x]; REWRITE_TAC[arith `(x * y) pow 2 = x pow 2 * y pow 2`]; GMATCH_SIMP_TAC REAL_LT_RMUL_EQ; REWRITE_TAC[GSYM Trigonometry2.NOT_ZERO_EQ_POW2_LT]; CONJ_TAC; BY(ASM_TAC THEN REAL_ARITH_TAC); TYPIFY `#0.110186 = sqrt(#0.110186) pow 2` (C SUBGOAL_THEN SUBST1_TAC); GMATCH_SIMP_TAC SQRT_POW_2; BY(REAL_ARITH_TAC); MATCH_MP_TAC Tame_inequalities.REAL_LT_SQUARE_POS; GMATCH_SIMP_TAC SQRT_POS_LT; CONJ_TAC; BY(REAL_ARITH_TAC); TYPIFY `atn(sqrt #0.110186) < atn(tan #0.3205)` ENOUGH_TO_SHOW_TAC; BY(REWRITE_TAC[ATN_MONO_LT_EQ]); GMATCH_SIMP_TAC TAN_ATN; CONJ_TAC; BY(MP_TAC Flyspeck_constants.bounds THEN REAL_ARITH_TAC); BY(REWRITE_TAC[c110186]) ]);;
(* }}} *)
let angle_sum_5T1 = 
prove_by_refinement( `main_nonlinear_terminal_v11 ==> (!y1 y2 y3 y4 y5 y6 y126 y135. ineq [&2,y1,&2*h0; &2,y2,&2*h0; &2,y3,&2*h0; &2,y126,&2*h0; &2,y135,&2*h0; &2,y4,&2; cstab,y5,#3.237; cstab,y6,#3.237] (dih_y y1 y126 y135 cstab (&2) (&2) <= dih_y y1 y2 y3 y4 y5 y6 + dih_y y1 y2 y126 (&2) (&2) y6 + dih_y y1 y3 y135 (&2) (&2) y5 /\ &0 <= delta_y y1 y2 y126 (&2) (&2) y6 /\ &0 <= delta_y y1 y3 y135 (&2) (&2) y5 ==> (&20 <= delta_y y1 y2 y126 (&2) (&2) y6 \/ &20 <= delta_y y1 y3 y135 (&2) (&2) y5))) `,
(* {{{ proof *) [ ASM_REWRITE_TAC[Sphere.ineq;TAUT `a ==> b ==> c <=> a /\ b ==> c`]; REPEAT WEAKER_STRIP_TAC; PROOF_BY_CONTR_TAC; RULE_ASSUM_TAC(REWRITE_RULE[DE_MORGAN_THM;arith `~(x <= y) <=> y < x`]); TYPIFY `#2.52 = &2 * h0` (C SUBGOAL_THEN ASSUME_TAC); BY(REWRITE_TAC[Sphere.h0] THEN REAL_ARITH_TAC); INTRO_TAC (Terminal.get_main_nonlinear "6789182745") [`y1`;`y2`;`y3`;`y4`;`y5`;`y6`]; ASM_REWRITE_TAC[Sphere.ineq;TAUT `a ==> b ==> c <=> a /\ b ==> c`;GSYM Sphere.cstab]; DISCH_TAC; INTRO_TAC (Terminal.get_main_nonlinear "4887115291") [`y1`;`y126`;`y135`;`cstab`;`(&2)`;`(&2)`]; ASM_REWRITE_TAC[Sphere.ineq;TAUT `a ==> b ==> c <=> a /\ b ==> c`;GSYM Sphere.cstab]; REWRITE_TAC[arith `x <= x`]; DISCH_TAC; INTRO_TAC (UNDISCH LEMMA_7175074394) [`y1`;`y126`;`y2`;`(&2)`;`y6`;`(&2)`]; ASM_REWRITE_TAC[Sphere.ineq;TAUT `a ==> b ==> c <=> a /\ b ==> c`;GSYM Sphere.cstab;LET_THM]; INTRO_TAC (UNDISCH LEMMA_7175074394) [`y1`;`y135`;`y3`;`(&2)`;`y5`;`(&2)`]; ASM_REWRITE_TAC[Sphere.ineq;TAUT `a ==> b ==> c <=> a /\ b ==> c`;GSYM Sphere.cstab;LET_THM]; ONCE_REWRITE_TAC[Nonlinear_lemma.dih_y_sym]; REPEAT (FIRST_X_ASSUM_ST `delta_y` MP_TAC) THEN REWRITE_TAC[Pent_hex.delta_y_hex_cases] THEN REPEAT WEAKER_STRIP_TAC; BY(ASM_TAC THEN REAL_ARITH_TAC) ]);;
(* }}} *)
let terminal_pent_taum2 = 
prove_by_refinement( `main_nonlinear_terminal_v11 ==> (!y1 y2 y3 y4 y5 y6 y126 y135. &0 <= delta_y y126 y1 y2 y6 (&2) (&2) /\ &0 <= delta_y y135 y1 y3 y5 (&2) (&2) /\ dih_y y1 y126 y135 cstab (&2) (&2) <= dih_y y1 y2 y3 y4 y5 y6 + dih_y y1 y2 y126 (&2) (&2) y6 + dih_y y1 y3 y135 (&2) (&2) y5 ==> (ineq [ (&2,y1,&2 * h0); (&2,y2,&2 * h0); (&2,y3,&2 * h0); (&2,y4,&2); (#3.01,y5,#3.237); (#3.01,y6,#3.237); (&2,y126,&2 * h0); (&2,y135,&2 * h0) ] (#0.616 < taum y126 y1 y2 y6 (&2) (&2) + taum y1 y2 y3 y4 y5 y6 + taum y135 y1 y3 y5 (&2) (&2)))) `,
(* {{{ proof *) [ ASM_REWRITE_TAC[Sphere.ineq;TAUT `a ==> b ==> c <=> a /\ b ==> c`]; REPEAT WEAKER_STRIP_TAC; INTRO_TAC (UNDISCH angle_sum_5T1) [`y1`;`y2`;`y3`;`y4`;`y5`;`y6`;`y126`;`y135`]; ASM_REWRITE_TAC[Sphere.ineq;TAUT `a ==> b ==> c <=> a /\ b ==> c`]; ASM_REWRITE_TAC[Pent_hex.delta_y_hex_cases;Sphere.cstab]; STRIP_TAC; INTRO_TAC (UNDISCH Pent_hex.terminal_pent_taum) [`y1`;`y2`;`y3`;`y4`;`y5`;`y6`;`y126`;`y135`]; BY(ASM_REWRITE_TAC[Sphere.ineq;TAUT `a ==> b ==> c <=> a /\ b ==> c`]); INTRO_TAC (UNDISCH Pent_hex.terminal_pent_taum) [`y1`;`y3`;`y2`;`y4`;`y6`;`y5`;`y135`;`y126`]; ASM_REWRITE_TAC[Sphere.ineq;TAUT `a ==> b ==> c <=> a /\ b ==> c`]; TYPIFY `taum y1 y3 y2 y4 y6 y5 = taum y1 y2 y3 y4 y5 y6` ENOUGH_TO_SHOW_TAC; BY(REAL_ARITH_TAC); BY(MESON_TAC[Terminal.taum_sym]) ]);;
(* }}} *)
let delta_diff4 = 
prove_by_refinement( `!x1 x2 x3 x4 x5 x6 z4. delta_x x1 x2 x3 x4 x5 x6 = delta_x x1 x2 x3 z4 x5 x6 + delta_x4 x1 x2 x3 x4 x5 x6 * (x4 - z4) + x1 * (x4 - z4) pow 2`,
(* {{{ proof *) [ BY(REWRITE_TAC[Sphere.delta_x;Sphere.delta_x4] THEN REAL_ARITH_TAC) ]);;
(* }}} *)
let dih_y_mono = 
prove_by_refinement( `!y1 y2 y3 y4 y5 y6 y4'. y4 <= y4' /\ &0 < y1 /\ &0 < y4 /\ &0 < delta_y y1 y2 y3 y4 y5 y6 /\ &0 <= delta_y y1 y2 y3 y4' y5 y6 ==> dih_y y1 y2 y3 y4 y5 y6 <= dih_y y1 y2 y3 y4' y5 y6`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; TYPIFY `y4 = y4'` ASM_CASES_TAC; BY(ASM_REWRITE_TAC[arith `x <= x`]); ASM_CASES_TAC `&0 < delta_y y1 y2 y3 y4' y5 y6`; REWRITE_TAC[Sphere.dih_y;LET_THM]; MATCH_MP_TAC (arith `x < y ==> x <= y`); MATCH_MP_TAC Tame_inequalities.DIH_X_MONO_LT_4; GMATCH_SIMP_TAC Misc_defs_and_lemmas.ABS_SQUARE; GMATCH_SIMP_TAC REAL_LT_MUL_EQ; ASM_REWRITE_TAC[GSYM Sphere.delta_y]; BY(ASM_TAC THEN REAL_ARITH_TAC); TYPIFY `delta_y y1 y2 y3 y4' y5 y6 = &0` (C SUBGOAL_THEN ASSUME_TAC); BY(ASM_TAC THEN REAL_ARITH_TAC); ASM_CASES_TAC `delta4_y y1 y2 y3 y4' y5 y6 <= &0`; MATCH_MP_TAC REAL_LE_TRANS; TYPIFY `pi` EXISTS_TAC; CONJ_TAC; REWRITE_TAC[Sphere.dih_y;LET_THM]; MATCH_MP_TAC (arith (`x < y ==> x <= y`)); MATCH_MP_TAC Oxlzlez.DIH_X_LT_PI; GMATCH_SIMP_TAC REAL_LT_MUL_EQ; BY(ASM_REWRITE_TAC[GSYM Sphere.delta_y]); ASM_REWRITE_TAC[Sphere.dih_y;LET_THM;Sphere.dih_x;GSYM Sphere.delta_y]; REWRITE_TAC[arith `x * &0 = &0`;SQRT_0]; ASM_CASES_TAC `delta4_y y1 y2 y3 y4' y5 y6 = &0`; RULE_ASSUM_TAC(REWRITE_RULE[Sphere.y_of_x;Sphere.delta4_y]); ASM_REWRITE_TAC[]; BY(MESON_TAC[arith `-- &0 = &0`;Merge_ineq.atn2_0;PI_POS;arith `&0 < x ==> x <= x / &2 + x`]); TYPIFY `delta4_y y1 y2 y3 y4' y5 y6 < &0` (C SUBGOAL_THEN MP_TAC); BY(ASM_TAC THEN REAL_ARITH_TAC); REWRITE_TAC[Sphere.y_of_x;Sphere.delta4_y]; TYPED_ABBREV_TAC `u = delta_x4 (y1 * y1) (y2 * y2) (y3 * y3) (y4' * y4') (y5 * y5) (y6 * y6)`; BY(MESON_TAC[arith `u < &0 ==> &0 < -- u`;Merge_ineq.atn2_0;arith `x <= x / &2 + x / &2`]); INTRO_TAC delta_diff4 [`y1*y1`;`y2*y2`;`y3*y3`;`y4'*y4'`;`y5*y5`;`y6*y6`;`y4*y4`]; RULE_ASSUM_TAC(REWRITE_RULE[Sphere.delta_y;Sphere.delta4_y;Sphere.y_of_x]); ASM_REWRITE_TAC[]; ENOUGH_TO_SHOW_TAC `&0 < delta_x (y1 * y1) (y2 * y2) (y3 * y3) (y4 * y4) (y5 * y5) (y6 * y6) /\ &0 <= delta_x4 (y1 * y1) (y2 * y2) (y3 * y3) (y4' * y4') (y5 * y5) (y6 * y6) * (y4' * y4' - y4 * y4) /\ &0 <= (y1 * y1) * (y4' * y4' - y4 * y4) pow 2`; BY(REAL_ARITH_TAC); ASM_REWRITE_TAC[]; CONJ_TAC; GMATCH_SIMP_TAC REAL_LE_MUL; REWRITE_TAC[arith `&0 <= a - b <=> b <= a`]; GMATCH_SIMP_TAC Misc_defs_and_lemmas.ABS_SQUARE_LE; BY(ASM_TAC THEN REAL_ARITH_TAC); GMATCH_SIMP_TAC REAL_LE_MUL; REWRITE_TAC[ REAL_LE_POW_2]; BY(REWRITE_TAC[ REAL_LE_SQUARE]) ]);;
(* }}} *)
let MOD_EQ_MOD_SHIFT = 
prove_by_refinement( `!n x1 x2 y. ~(n=0) ==> (((y + x1) MOD n = (y + x2) MOD n) <=> (x1 MOD n = x2 MOD n))`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; MATCH_MP_TAC (TAUT `((a ==> b) /\ (b ==> a)) ==> (a <=> b)`); CONJ_TAC; BY(ASM_MESON_TAC[Hdplygy.MOD_EQ_MOD]); BY(ASM_MESON_TAC[MOD_ADD_MOD]) ]);;
(* }}} *)
let empty_5T1 = 
prove_by_refinement( `main_nonlinear_terminal_v11 ==> (!vv. BBs_v39 scs_5T1 vv ==> &0 <= taustar_v39 scs_5T1 vv)` ,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; PROOF_BY_CONTR_TAC; ASSUME_TAC ((is_scs_5T1)); COMMENT "new material";
TYPIFY `!i j. i < 5 /\ j < 5 /\ vv i = vv j ==> i = j` (C SUBGOAL_THEN ASSUME_TAC); MATCH_MP_TAC vv_inj_lemma; BY(ASM_MESON_TAC[Appendix.scs_5T1;IN;Terminal.scs_unadorned_explicit]); TYPIFY `scs_generic vv` (C SUBGOAL_THEN ASSUME_TAC); MATCH_MP_TAC (REWRITE_RULE[LET_THM] (UNDISCH scs_5T1_generic)); BY(ASM_REWRITE_TAC[] THEN ASM_TAC THEN REAL_ARITH_TAC); COMMENT "big expansion"; REPEAT (FIRST_X_ASSUM MP_TAC); REWRITE_TAC[Appendix.taustar_v39;LET_DEF;LET_END_DEF;Appendix.BBs_v39;Terminal.scs_unadorned_explicit;Appendix.scs_5T1]; REWRITE_TAC[arith `~(5 <= 3)`;Terminal.dsv_unadorned]; REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM_ST `tau_fun` MP_TAC; REWRITE_TAC[]; GMATCH_SIMP_TAC (REWRITE_RULE[LET_THM] Terminal.tau_fun_azim); TYPIFY `5` EXISTS_TAC; ASM_REWRITE_TAC[arith `3 <= 5`;arith `&5 - &2 = &3`]; TYPIFY `!i. dist(vv i,vv (i+1)) = &2` (C SUBGOAL_THEN ASSUME_TAC); REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM_ST `dist` (C INTRO_TAC [`i`;`i+1`]); REWRITE_TAC[Appendix.cs_adj;arith `i + 1 = SUC i`]; SIMP_TAC[Qknvmlb.SUC_MOD_NOT_EQ;arith `1< 5`]; BY(REAL_ARITH_TAC); COMMENT "end expansion"; COMMENT "edge lengths"; TYPIFY `!i. cstab <= dist(vv i,vv (i+2))` (C SUBGOAL_THEN ASSUME_TAC); REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM_ST `dist` (C INTRO_TAC [`i`;`i+2`]); TYPIFY `cs_adj 5 (&2) cstab i (i+2) = cstab` ENOUGH_TO_SHOW_TAC; DISCH_THEN SUBST1_TAC; BY(MESON_TAC[]); REWRITE_TAC[Appendix.cs_adj]; COND_CASES_TAC; FIRST_X_ASSUM MP_TAC; BY(MESON_TAC[arith `~(0=5) /\ (2 < 5) /\ ~(0=2)`;Oxl_2012.MOD_INJ1]); COND_CASES_TAC; FIRST_X_ASSUM MP_TAC; STRIP_TAC; FIRST_X_ASSUM MP_TAC; REWRITE_TAC[arith `SUC i = i+1 /\ i + 2 = (i+1) + 1`]; BY(MESON_TAC[arith `~(0=5) /\ (1 < 5) /\ ~(0=1)`;Oxl_2012.MOD_INJ1]); FIRST_X_ASSUM MP_TAC; REWRITE_TAC[arith `SUC (i+2)=i+3`]; BY(MESON_TAC[arith `~(0=5) /\ (3 < 5) /\ ~(0=3)`;Oxl_2012.MOD_INJ1]); BY(REWRITE_TAC[]); COMMENT "second diag"; TYPIFY `!i. cstab <= dist(vv i,vv (i+3))` (C SUBGOAL_THEN ASSUME_TAC); REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM_ST `dist` (C INTRO_TAC [`i`;`i+3`]); TYPIFY `cs_adj 5 (&2) cstab i (i+3) = cstab` ENOUGH_TO_SHOW_TAC; DISCH_THEN SUBST1_TAC; BY(MESON_TAC[]); REWRITE_TAC[Appendix.cs_adj]; COND_CASES_TAC; FIRST_X_ASSUM MP_TAC; BY(MESON_TAC[arith `~(0=5) /\ (3 < 5) /\ ~(0=3)`;Oxl_2012.MOD_INJ1]); COND_CASES_TAC; FIRST_X_ASSUM MP_TAC; STRIP_TAC; FIRST_X_ASSUM MP_TAC; REWRITE_TAC[arith `SUC i = i+1 /\ i + 3 = (i+1) + 2`]; BY(MESON_TAC[arith `~(0=5) /\ (2 < 5) /\ ~(0=2)`;Oxl_2012.MOD_INJ1]); FIRST_X_ASSUM MP_TAC; REWRITE_TAC[arith `SUC (i+3)=i+4`]; BY(MESON_TAC[arith `~(0=5) /\ (4 < 5) /\ ~(0=4)`;Oxl_2012.MOD_INJ1]); BY(REWRITE_TAC[]); COMMENT "more distances"; TYPIFY `!i. &2 <= norm (vv i) /\ norm (vv i) <= &2 * h0` (C SUBGOAL_THEN ASSUME_TAC); GEN_TAC; REWRITE_TAC[GSYM Fnjlbxs.in_ball_annulus]; RULE_ASSUM_TAC(REWRITE_RULE[Terminal.IMAGE_SUBSET_IN;IN_UNIV]); BY(ASM_REWRITE_TAC[]); TYPIFY `!i j. i < 5 /\ j < 5 /\ ~(i = j) ==> &2 <= dist(vv i,vv j)` (C SUBGOAL_THEN ASSUME_TAC); REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM (C INTRO_TAC [`i`;`j`]); ASM_REWRITE_TAC[]; DISCH_TAC; FIRST_X_ASSUM (C INTRO_TAC [`i`;`j`]); ASM_REWRITE_TAC[Appendix.cs_adj]; COND_CASES_TAC; BY(ASM_MESON_TAC[MOD_LT]); TYPIFY `&2 <= cstab` (C SUBGOAL_THEN MP_TAC); BY(REWRITE_TAC[Sphere.cstab] THEN REAL_ARITH_TAC); BY(REAL_ARITH_TAC); COMMENT "1+sqrt(5)"; TYPIFY `?j. j < 5 /\ dist(vv j,vv (j+2)) <= &1 + sqrt(&5) /\ dist(vv j,vv (j+3)) <= &1 + sqrt(&5)` (C SUBGOAL_THEN MP_TAC); INTRO_TAC Vpwshto.VPWSHTO_PRIME [`vv`]; ANTS_TAC; ONCE_REWRITE_TAC[GSYM dist]; CONJ_TAC; RULE_ASSUM_TAC(REWRITE_RULE[Terminal.IMAGE_SUBSET_IN;IN_UNIV]); BY(FIRST_X_ASSUM_ST `ball_annulus` MP_TAC THEN SET_TAC[]); REWRITE_TAC[Sphere.packing]; TYPIFY_GOAL_THEN `!a b c d e (f:real^3). {a,b,c,d,e} f <=> (f = a \/ f = b \/ f = c \/ f = d \/ f = e)` (unlist REWRITE_TAC); REWRITE_TAC[INSERT;IN_ELIM_THM;NOT_IN_EMPTY]; BY(MESON_TAC[]); CONJ_TAC; REPEAT WEAKER_STRIP_TAC; TYPIFY `?i j. u = vv i /\ v = vv j /\ i < 5 /\ j < 5 /\ ~(i=j)` (C SUBGOAL_THEN MP_TAC); BY(ASM_MESON_TAC[arith `0 < 5 /\ 1 < 5 /\ 2 < 5 /\ 3 < 5 /\ 4 < 5`]); REPEAT WEAKER_STRIP_TAC; ASM_REWRITE_TAC[]; FIRST_X_ASSUM MATCH_MP_TAC; BY(ASM_REWRITE_TAC[]); TYPIFY_GOAL_THEN `~(vv 0 = vv 1) /\ ~(vv 0 = vv 1) /\ ~(vv 0 = vv 2) /\ ~(vv 0 = vv 3) /\ ~(vv 0 = vv 4) /\ ~(vv 1 = vv 2) /\ ~(vv 1 = vv 3) /\ ~(vv 1 = vv 4) /\ ~(vv 2 = vv 3) /\ ~(vv 2 = vv 4) /\ ~(vv 3 = vv 4)` (unlist REWRITE_TAC); TYPIFY `!i j. i < 5 /\ j < 5 /\ ~(i = j) ==> ~(vv i = vv j)` (C SUBGOAL_THEN ASSUME_TAC); BY(ASM_MESON_TAC[]); BY(REPEAT CONJ_TAC THEN FIRST_X_ASSUM MATCH_MP_TAC THEN ARITH_TAC); TYPIFY `vv 0 = vv 5` (C SUBGOAL_THEN ASSUME_TAC); ONCE_REWRITE_TAC[arith `5 = 0 +5`]; BY(ASM_MESON_TAC[Sphere.periodic]); BY(ASM_MESON_TAC[arith `1 = 0+1 /\ 2 = 1+1 /\ 3 = 2+1 /\ 4 = 3+1 /\ 5 = 4+1`]); REWRITE_TAC[GSYM dist]; REPEAT WEAKER_STRIP_TAC; TYPIFY `i` EXISTS_TAC; CONJ_TAC; FIRST_X_ASSUM_ST `IN` MP_TAC; REWRITE_TAC[IN_NUMSEG]; BY(ARITH_TAC); BY(ASM_MESON_TAC[Oxl_def.periodic_mod;arith `~(5=0)`]); REPEAT WEAKER_STRIP_TAC; COMMENT "pick up the hex flow again"; COMMENT "azim le pi"; TYPIFY `!i. azim (vec 0) (vv i) (vv (i+1)) (vv (i + 5 -1)) <= pi` (C SUBGOAL_THEN ASSUME_TAC); RULE_ASSUM_TAC(REWRITE_RULE[Localization.convex_local_fan]); ASM_TAC THEN REPEAT WEAKER_STRIP_TAC; REWRITE_TAC[arith `i+1 = SUC i`]; GMATCH_SIMP_TAC (GSYM azim_in_fan_azim); TYPIFY `IMAGE (\i. {vv i, vv (SUC i)}) (:num)` EXISTS_TAC; ASM_REWRITE_TAC[arith `3 <= 5`]; CONJ_TAC; BY(ASM_MESON_TAC[]); BY(ASM_MESON_TAC[IN_IMAGE;IN_UNIV]); COMMENT "split azim"; RULE_ASSUM_TAC(REWRITE_RULE[Appendix.scs_generic]); TYPIFY `azim(vec 0) (vv j) (vv (SUC j)) (vv (j + 4)) = azim(vec 0) (vv j) (vv (SUC j)) (vv (j+2)) + azim(vec 0) (vv j) (vv (j+2)) (vv (j+3)) + azim (vec 0) (vv j) (vv (j+3)) (vv (j+4))` (C SUBGOAL_THEN ASSUME_TAC); INTRO_TAC Terminal.vv_split_azim_generic [`vv`;`5`;`j`;`3`;`4`]; ASM_REWRITE_TAC[LET_THM;arith `3 <= 5 /\ 0 < 3 /\ 3 < 4 /\ 4 < 5`]; DISCH_THEN SUBST1_TAC; INTRO_TAC Terminal.vv_split_azim_generic [`vv`;`5`;`j`;`2`;`3`]; ASM_REWRITE_TAC[LET_THM;arith `3 <= 5 /\ 0 < 2 /\ 2 < 3 /\ 3 < 5`]; BY(REAL_ARITH_TAC); COMMENT "split at j+2 and j+3"; TYPIFY `vv (j+5) = vv j /\ vv (j+6) = vv(j+1) /\ vv (j+7) = vv(j+2) /\ vv(j+8)=vv(j+3) /\ vv(j+9) = vv(j+4)` (C SUBGOAL_THEN ASSUME_TAC); FIRST_X_ASSUM_ST `periodic` MP_TAC; BY(MESON_TAC[Sphere.periodic;arith `j+6 = (j+1)+5 /\ j+7 = (j+2)+5 /\ j+8 = (j+3)+5 /\ j+9 = (j+4)+5`]); ASSUME_TAC (arith `SUC(j) = j+1 /\ SUC(j+1)=j+2 /\ SUC(j+2)=j+3 /\ SUC(j+3)=j+4 /\ SUC(j+4)=j+5`); TYPIFY `azim(vec 0) (vv (j+2)) (vv(SUC (j+2))) (vv (j+1)) = azim(vec 0) (vv (j+2)) (vv(SUC (j+2))) (vv(j)) + azim(vec 0) (vv (j+2)) (vv j) (vv (j+1))` (C SUBGOAL_THEN ASSUME_TAC); INTRO_TAC Terminal.vv_split_azim_generic [`vv`;`5`;`j+2`;`3`;`4`]; ASM_REWRITE_TAC[LET_THM;arith `3 <= 5 /\ 0 < 3 /\ 3 < 4 /\ 4 < 5`]; BY(ASM_REWRITE_TAC[arith `(a +b)+(c:num) = a+(b+c) /\ 2+4=6 /\ 2+3 = 5`]); TYPIFY `azim (vec 0) (vv(j+3)) (vv(j+4)) (vv(j+2)) = azim(vec 0) (vv(j+3)) (vv(j+4)) (vv j) + azim(vec 0) (vv(j+3)) (vv j) (vv (j+2))` (C SUBGOAL_THEN ASSUME_TAC); INTRO_TAC Terminal.vv_split_azim_generic [`vv`;`5`;`j+3`;`2`;`4`]; ASM_REWRITE_TAC[LET_THM;arith `3 <= 5 /\ 0 < 2 /\ 2 < 4 /\ 4 < 5`]; BY(ASM_REWRITE_TAC[arith `(a +b)+(c:num) = a+(b+c) /\ 3+4=7 /\ 3+2 = 5`]); COMMENT "expand sum"; INTRO_TAC periodic_sum_shift [`j`]; DISCH_THEN GMATCH_SIMP_TAC; CONJ_TAC; REWRITE_TAC[arith `~(5 = 0)`;Sphere.periodic]; GEN_TAC; REWRITE_TAC[arith `(i+5) + j = (i+j) + 5`]; RULE_ASSUM_TAC(REWRITE_RULE[Sphere.periodic]); BY(ASM_REWRITE_TAC[]); TYPIFY `{i | i < 5 } = {0,1,2,3,4}` (C SUBGOAL_THEN SUBST1_TAC); REWRITE_TAC[EXTENSION;IN_ELIM_THM;IN_INSERT;NOT_IN_EMPTY]; BY(ARITH_TAC); REPEAT (GMATCH_SIMP_TAC Marchal_cells_2_new.SUM_CLAUSES_alt THEN REWRITE_TAC[NOT_IN_EMPTY;IN_INSERT;arith `~(0=1)/\ ~(0=2)/\ ~(0=3) /\ ~(0=4) /\ ~(0=5) /\ ~(1=2) /\ ~(1 = 3) /\ ~(1 = 4) /\ ~(1=5) /\ ~(2 = 3) /\ ~(2 = 4) /\ ~(2 = 5) /\ ~(3 = 4) /\ ~(3 =5) /\ ~(4 = 5)`]); REWRITE_TAC[SUM_CLAUSES;Geomdetail.FINITE6]; FIRST_ASSUM (C INTRO_TAC [`j`]); FIRST_ASSUM (C INTRO_TAC [`j+1`]); FIRST_ASSUM (C INTRO_TAC [`j+2`]); FIRST_ASSUM (C INTRO_TAC [`j+3`]); FIRST_X_ASSUM (C INTRO_TAC [`j+4`]); REWRITE_TAC[arith `5-1=4`]; REPEAT (FIRST_X_ASSUM_ST `azim` MP_TAC); REWRITE_TAC[arith `(a+b)+(c:num) = a+b+c`;arith `SUC i = i+1`]; NUM_REDUCE_TAC; ASM_REWRITE_TAC[]; COMMENT "start again here"; REPEAT WEAKER_STRIP_TAC; TYPIFY `azim (vec 0) (vv j) (vv (j + 3)) (vv (j + 4)) <= pi /\ azim (vec 0) (vv j) (vv (j + 1)) (vv (j + 2)) <= pi /\ azim (vec 0) (vv j) (vv (j + 2)) (vv (j + 3)) <= pi /\ azim (vec 0) (vv (j + 2)) (vv (j + 3)) (vv j) <= pi /\ azim (vec 0) (vv (j + 2)) (vv j) (vv (j + 1)) <= pi /\ azim (vec 0) (vv (j + 3)) (vv (j + 4)) (vv j) <= pi /\ azim (vec 0) (vv (j + 3)) (vv j) (vv (j + 2)) <= pi`(C SUBGOAL_THEN ASSUME_TAC); MP_TAC Counting_spheres.AZIM_NN; REPEAT (FIRST_X_ASSUM_ST `x <= pi` MP_TAC); REPLICATE_TAC 3 (FIRST_X_ASSUM MP_TAC); BY(MESON_TAC[arith `&0 <= x /\ &0 <= y /\ &0 <= z /\ x + y + z <= pi ==> x <= pi /\ y <= pi /\ z <= pi`;arith `&0 <= x /\ &0 <= y /\ x + y <= pi ==> x <= pi /\ y <= pi`]); COMMENT "collinearity"; TYPIFY `!i i'. (i < 5 /\ i' < 5 /\ ~(i=i')) ==> ~collinear {vec 0,vv (j+i),vv (j+i')}` (C SUBGOAL_THEN ASSUME_TAC); REPEAT WEAKER_STRIP_TAC; INTRO_TAC Nkezbfc_local.PROPERTIES_GENERIC_LOCAL_FAN [`IMAGE vv (:num)`;`IMAGE (\i. {vv i, vv (SUC i)}) (:num)`;`IMAGE (\i. vv i,vv (SUC i)) (:num)`;`vv (j+(i:num))`]; ASM_REWRITE_TAC[Qknvmlb.IN_IMAGE_VV]; FIRST_X_ASSUM (MP_TAC o (MATCH_MP Local_lemmas.CVX_LO_IMP_LO)); REWRITE_TAC[arith `SUC i = i+1`]; DISCH_THEN (unlist REWRITE_TAC); DISCH_THEN (C INTRO_TAC [`vv (j+(i':num))`]); (ASM_REWRITE_TAC[Qknvmlb.IN_IMAGE_VV]); TYPIFY `!i. vv i = vv (i MOD 5) ` (C SUBGOAL_THEN MP_TAC); GEN_TAC; MATCH_MP_TAC (Oxl_def.periodic_mod); BY(ASM_REWRITE_TAC[arith `~(0=5)`]); DISCH_THEN (unlist ONCE_REWRITE_TAC); DISCH_TAC; FIRST_X_ASSUM_ST `x ==> (i:num) = j` (C INTRO_TAC [`(j+i') MOD 5`;`(j+i) MOD 5`]); FIRST_X_ASSUM (SUBST1_TAC); SIMP_TAC[arith `~(5 = 0)`;DIVISION]; DISCH_TAC; INTRO_TAC Hdplygy.MOD_EQ_MOD [`i`;`i'`;`j`;`5`]; ASM_REWRITE_TAC[arith `~(5=0)`]; REPEAT (GMATCH_SIMP_TAC MOD_LT); BY(ASM_REWRITE_TAC[]); COMMENT "convert to dih"; TYPIFY `azim (vec 0) (vv j) (vv (j + 1)) (vv (j + 4)) = dihV (vec 0) (vv j) (vv (j + 1)) (vv (j + 4)) /\ azim (vec 0) (vv j) (vv (j + 3)) (vv (j + 4)) = dihV (vec 0) (vv j) (vv (j + 3)) (vv (j + 4)) /\ azim (vec 0) (vv j) (vv (j + 1)) (vv (j + 2)) = dihV (vec 0) (vv j) (vv (j + 1)) (vv (j + 2)) /\ azim (vec 0) (vv j) (vv (j + 2)) (vv (j + 3)) = dihV (vec 0) (vv j) (vv (j + 2)) (vv (j + 3)) /\ azim (vec 0) (vv (j + 2)) (vv (j + 3)) (vv j) = dihV (vec 0) (vv (j + 2)) (vv (j + 3)) (vv j) /\ azim (vec 0) (vv (j + 2)) (vv j) (vv (j + 1)) = dihV (vec 0) (vv (j + 2)) (vv j) (vv (j + 1)) /\ azim (vec 0) (vv (j + 3)) (vv (j + 4)) (vv j) = dihV (vec 0) (vv (j + 3)) (vv (j + 4)) (vv j) /\ azim (vec 0) (vv (j + 3)) (vv j) (vv (j + 2)) = dihV (vec 0) (vv (j + 3)) (vv j) (vv (j + 2)) /\ azim (vec 0) (vv (j + 4)) (vv j) (vv (j + 3)) = dihV (vec 0) (vv (j + 4)) (vv j) (vv (j + 3)) /\ azim (vec 0) (vv (j + 1)) (vv (j + 2)) (vv j) = dihV (vec 0) (vv (j + 1)) (vv (j + 2)) (vv j)` (C SUBGOAL_THEN ASSUME_TAC); REPEAT (FIRST_X_ASSUM_ST `pi` MP_TAC); TYPIFY `vv j = vv (j+0)` (C SUBGOAL_THEN SUBST1_TAC); BY(REWRITE_TAC[arith `j+0=j`]); REPEAT WEAKER_STRIP_TAC; BY((REPEAT (CONJ_TAC) THEN MATCH_MP_TAC Polar_fan.AZIM_DIHV_SAME_STRONG THEN ASM_REWRITE_TAC[] THEN REPEAT CONJ_TAC THEN TRY (FIRST_X_ASSUM MATCH_MP_TAC) THEN NUM_REDUCE_TAC THEN ASM_REWRITE_TAC[])); REWRITE_TAC[arith `j+0=j`]; TYPIFY `#0.616 < tau3 (vv j) (vv (j+1)) (vv (j+2)) + tau3 (vv j) (vv (j+2)) (vv (j+3)) + tau3 (vv j) (vv (j+3)) (vv (j+4))` ENOUGH_TO_SHOW_TAC; ONCE_REWRITE_TAC[arith `&0 <= a - b - c <=> c <= a - b`]; MATCH_MP_TAC (arith `ts = rs ==> (d < ts ==> d <= rs)`); ASM_REWRITE_TAC[Appendix.tau3;Appendix.rho_rho_fun]; BY(REAL_ARITH_TAC); REPEAT (GMATCH_SIMP_TAC Terminal.tau3_taum_40); ASM_REWRITE_TAC[]; RULE_ASSUM_TAC(REWRITE_RULE[Terminal.IMAGE_SUBSET_IN;IN_UNIV]); ASM_REWRITE_TAC[]; FIRST_X_ASSUM_ST `dist(a,b) = &2` MP_TAC; DISCH_TAC; FIRST_ASSUM (C INTRO_TAC [`j`]); FIRST_ASSUM (C INTRO_TAC [`j+1`]); FIRST_ASSUM (C INTRO_TAC [`j+2`]); FIRST_ASSUM (C INTRO_TAC [`j+3`]); FIRST_X_ASSUM (C INTRO_TAC [`j+4`]); ASM_REWRITE_TAC[arith `((a:num) + b) + c = a+b+c`]; NUM_REDUCE_TAC; ASM_REWRITE_TAC[DIST_SYM]; REPEAT WEAKER_STRIP_TAC THEN ASM_REWRITE_TAC[]; FIRST_X_ASSUM_ST `cstab <= dist(a,b)` MP_TAC; TYPIFY `&2 <= cstab` (C SUBGOAL_THEN MP_TAC); BY(REWRITE_TAC[Sphere.cstab] THEN REAL_ARITH_TAC); REPEAT WEAKER_STRIP_TAC; TYPIFY_GOAL_THEN `&2 <= dist(vv j, vv(j+3))` (unlist REWRITE_TAC); BY(REPLICATE_TAC 2 (FIRST_X_ASSUM MP_TAC) THEN MESON_TAC[REAL_LE_TRANS]); FIRST_X_ASSUM_ST `a = a1 + a2 + a3` MP_TAC; ASM_REWRITE_TAC[]; DISCH_TAC; COMMENT "kill azim"; REPEAT (FIRST_X_ASSUM_ST `azim` kill); TYPIFY_GOAL_THEN `&2 <= dist(vv j, vv(j+2))` (unlist REWRITE_TAC); BY(REPEAT (FIRST_X_ASSUM MP_TAC) THEN MESON_TAC[REAL_LE_TRANS]); TYPIFY `&1 + sqrt(&5) < #3.237` (C SUBGOAL_THEN ASSUME_TAC); TYPIFY `sqrt(&5) < sqrt(#2.237 pow 2)` ENOUGH_TO_SHOW_TAC; GMATCH_SIMP_TAC POW_2_SQRT; BY(REAL_ARITH_TAC); GMATCH_SIMP_TAC SQRT_MONO_LT_EQ; BY(REAL_ARITH_TAC); CONJ_TAC; BY(REPEAT (FIRST_X_ASSUM_ST `&5` MP_TAC) THEN REAL_ARITH_TAC); CONJ_TAC; BY(REPEAT (FIRST_X_ASSUM_ST `&5` MP_TAC) THEN REAL_ARITH_TAC); CONJ_TAC; BY(REPEAT (FIRST_X_ASSUM_ST `&5` MP_TAC) THEN REAL_ARITH_TAC); PROOF_BY_CONTR_TAC; FIRST_X_ASSUM_ST `dihV` MP_TAC; REWRITE_TAC[]; REPEAT (GMATCH_SIMP_TAC (REWRITE_RULE[LET_THM] Merge_ineq.DIHV_EQ_DIH_Y)); REWRITE_TAC[DIST_0]; REWRITE_TAC[TAUT `a /\ b /\ c <=> (a /\ b) /\ c`]; CONJ_TAC; TYPIFY `vv j = vv (j+0)` (C SUBGOAL_THEN SUBST1_TAC); BY(REWRITE_TAC[arith `j+0=j`]); BY((REPEAT (CONJ_TAC) THEN TRY (FIRST_X_ASSUM MATCH_MP_TAC) THEN NUM_REDUCE_TAC THEN ASM_REWRITE_TAC[])); DISCH_TAC; TYPIFY `dih_y (norm (vv j)) (norm (vv (j + 1))) (norm (vv (j + 4))) (cstab) (dist (vv j,vv (j + 4))) (dist (vv j,vv (j + 1))) <= dih_y (norm (vv j)) (norm (vv (j + 1))) (norm (vv (j + 4))) (dist (vv (j + 1),vv (j + 4))) (dist (vv j,vv (j + 4))) (dist (vv j,vv (j + 1)))` (C SUBGOAL_THEN ASSUME_TAC); MATCH_MP_TAC dih_y_mono; CONJ_TAC; FIRST_X_ASSUM_ST `cs_adj` (C INTRO_TAC [`j+1`;`j+4`]); INTRO_TAC scs_diag_cs_adj [`5`;`&2`;`cstab`;`j+1`;`j+4`]; ANTS_TAC; REWRITE_TAC[Appendix.scs_diag]; REWRITE_TAC[arith `SUC (j+1) = j+2 /\ SUC (j+4) = j+5`]; SIMP_TAC[MOD_EQ_MOD_SHIFT;arith `~(5 = 0)`]; BY(REWRITE_TAC[Uxckfpe.ARITH_5_TAC]); BY(REAL_ARITH_TAC); CONJ_TAC; FIRST_X_ASSUM_ST `&2 <= norm (vv i)` (C INTRO_TAC [`j`]); BY(REAL_ARITH_TAC); CONJ_TAC; BY(REWRITE_TAC[Sphere.cstab] THEN REAL_ARITH_TAC); CONJ_TAC; INTRO_TAC (Terminal.get_main_nonlinear "2125338128") [`norm(vv(j+1))`;`norm(vv(j+4))`;`norm(vv j)`;`dist(vv j,vv(j+4))`;`dist(vv j, vv(j+1))`;`cstab`]; ASM_REWRITE_TAC[Sphere.ineq;TAUT `a ==> b ==> c <=> a /\ b ==> c`;GSYM Sphere.cstab]; ANTS_TAC; TYPIFY `#2.52 = &2 * h0` (C SUBGOAL_THEN SUBST1_TAC); BY(REWRITE_TAC[Sphere.h0] THEN REAL_ARITH_TAC); ASM_REWRITE_TAC[]; BY(REWRITE_TAC[Sphere.h0;Sphere.cstab] THEN REAL_ARITH_TAC); REWRITE_TAC[Pent_hex.delta_y_hex_cases]; BY(REAL_ARITH_TAC); INTRO_TAC (REWRITE_RULE[LET_THM] Tame_lemmas.delta_y_pos) [`(vv j)`;` (vv (j+1))`;` (vv (j+4))`]; BY(REWRITE_TAC[]); COMMENT "introduce ineq"; INTRO_TAC (UNDISCH terminal_pent_taum2) [`norm (vv(j))`;`norm (vv(j+2))`;`norm (vv(j+3))`;`dist (vv(j+2),vv(j+3))`;`dist(vv(j),vv(j+3))`;`dist(vv(j),vv(j+2))`;`norm (vv(j+1))`;`norm(vv(j+4))`]; REWRITE_TAC[Sphere.ineq;TAUT `a ==> b ==> c <=> a /\ b ==> c`]; DISCH_THEN MP_TAC THEN ANTS_TAC; ASM_REWRITE_TAC[]; REWRITE_TAC[TAUT `(a /\ b) /\ c <=> a /\ b /\ c`]; CONJ_TAC; INTRO_TAC (REWRITE_RULE[LET_THM] Tame_lemmas.delta_y_pos) [`(vv (j+1))`;` (vv (j))`;` (vv (j+2))`]; ASM_REWRITE_TAC[]; BY(ASM_REWRITE_TAC[DIST_SYM]); CONJ_TAC; INTRO_TAC (REWRITE_RULE[LET_THM] Tame_lemmas.delta_y_pos) [`(vv (j+4))`;` (vv (j))`;` (vv (j+3))`]; BY(ASM_REWRITE_TAC[DIST_SYM]); CONJ_TAC; REPLICATE_TAC 2 (FIRST_X_ASSUM MP_TAC) THEN ASM_REWRITE_TAC[]; TYPED_ABBREV_TAC `df = dih_y (norm (vv j)) (norm (vv (j + 1))) (norm (vv (j + 4))) (dist (vv (j + 1),vv (j + 4))) (&2) (&2)`; TYPED_ABBREV_TAC `dc = dih_y (norm (vv j)) (norm (vv (j + 1))) (norm (vv (j + 4))) cstab (&2) (&2)`; DISCH_THEN SUBST1_TAC; MATCH_MP_TAC (arith `(a12 = a21' /\ a23 = a23' /\ a34 = a34') ==> (dc <= a12 + a23 + a34 ==> dc <= a23' + a21' + a34')`); ASM_REWRITE_TAC[]; ASM_REWRITE_TAC[DIST_SYM]; BY(MESON_TAC[Nonlinear_lemma.dih_y_sym]); CONJ_TAC; BY(REAL_ARITH_TAC); ASM_REWRITE_TAC[GSYM Sphere.cstab]; BY(REPEAT (FIRST_X_ASSUM_ST `&5` MP_TAC) THEN REAL_ARITH_TAC); FIRST_X_ASSUM_ST `taum` MP_TAC; REWRITE_TAC[]; MATCH_MP_TAC (arith `a = b ==> ~(d < a) ==> ~(d < b)`); MATCH_MP_TAC (arith `a1 = b1 /\ a2 = b2 /\ a3 = b3 ==> (a1 + a2 + a3 = b1 + b2 +b3)`); ASM_REWRITE_TAC[DIST_SYM]; BY(MESON_TAC[Terminal.taum_sym]) ]);; (* }}} *)
let psort_4 = 
prove_by_refinement( `!i. psort 4(i,4) = psort 4(i,0) /\ psort 4 (4,i)=psort 4 (0,i)`,
(* {{{ proof *) [ REWRITE_TAC[Appendix.psort;LET_THM;Uxckfpe.ARITH_4_TAC] ]);;
(* }}} *)
let I_LT_J_LT_5_EXPLICIT = 
prove_by_refinement( `!i j. (i < j /\ j < 5) <=> ((i = 0 /\ j = 1) \/ (i = 0 /\ j = 2) \/ (i = 0 /\ j = 3) \/ (i = 1 /\ j = 2) \/ (i = 1 /\ j = 3) \/ (i = 2 /\ j = 3) \/ (i=0 /\ j=4) \/ (i=1 /\ j=4) \/ (i=2 /\ j=4) \/ (i=3 /\ j=4))`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; REWRITE_TAC[Geomdetail.EQ_EXPAND]; CONJ2_TAC; BY(ARITH_TAC); REPEAT WEAKER_STRIP_TAC; TYPIFY `j = 1 \/ j = 2 \/ j = 3 \/ j= 4` (C SUBGOAL_THEN ASSUME_TAC); BY(REPEAT (FIRST_X_ASSUM MP_TAC) THEN ARITH_TAC); REPEAT (FIRST_X_ASSUM DISJ_CASES_TAC) THEN ASM_REWRITE_TAC[] THEN REPEAT (FIRST_X_ASSUM MP_TAC); BY(ARITH_TAC); BY(ARITH_TAC); BY(ARITH_TAC); BY(ARITH_TAC) ]);;
(* }}} *)
let MOD_5_EXPLICIT = 
prove_by_refinement( `0 MOD 5 = 0 /\ 1 MOD 5 = 1 /\ 2 MOD 5 = 2 /\ 3 MOD 5 = 3 /\ 4 MOD 5 = 4 /\ 5 MOD 5 = 0 /\ 6 MOD 5 = 1 /\ 7 MOD 5 = 2`,
(* {{{ proof *) [ ASM_SIMP_TAC[MOD_LT;MOD_MULT_ADD;arith `0 < 5 /\ 1 < 5 /\ 2 < 5 /\ 3 < 5 /\ 4 < 5 /\ 6 = 1*5 + 1 /\ 7 = 1*5 + 2`]; BY(ASM_SIMP_TAC[Oxlzlez.MOD_REFL_ALT;arith `~(5 =0)`]) ]);;
(* }}} *)
let psort_5 = 
prove_by_refinement( ` psort 5 (0,1) = (0,1) /\ psort 5 (0,2) = (0,2) /\ psort 5(0,3) = (0,3) /\ psort 5 (0,4)=(0,4) /\ psort 5 (1,1) = (1,1) /\ psort 5 (1,2) = (1,2) /\ psort 5(1,3) = (1,3) /\ psort 5 (1,4)=(1,4) /\ psort 5 (2,1) = (1,2) /\ psort 5 (2,2) = (2,2) /\ psort 5(2,3) = (2,3) /\ psort 5 (2,4)=(2,4) /\ psort 5 (3,1) = (1,3) /\ psort 5 (3,2) = (2,3) /\ psort 5(3,3) = (3,3) /\ psort 5 (3,4)=(3,4) /\ psort 5 (4,1) = (1,4) /\ psort 5 (4,2) = (2,4) /\ psort 5(4,3) = (3,4) /\ psort 5 (4,4)=(4,4) /\ psort 5 (4,5) = (0,4) /\ psort 5 (5,4) = (0,4) `,
(* {{{ proof *) [ REWRITE_TAC[Appendix.psort;LET_DEF;LET_END_DEF]; REWRITE_TAC[MOD_5_EXPLICIT;PAIR_EQ]; NUM_REDUCE_TAC ]);;
(* }}} *) (* NOW FINISH OTHER TERMINAL CASES *) is_scs_6T1;; is_scs_5T1;;
let is_scs_4T1 = 
prove_by_refinement( `is_scs_v39 scs_4T1`,
(* {{{ proof *) [ REWRITE_TAC[Appendix.scs_4T1]; MATCH_MP_TAC is_scs_adj; REWRITE_TAC[Appendix.d_tame;Sphere.cstab]; NUM_REDUCE_TAC; BY(REWRITE_TAC[Sphere.h0] THEN REAL_ARITH_TAC) ]);;
(* }}} *)
let is_scs_4T2 = 
prove_by_refinement( `is_scs_v39 scs_4T2`,
(* {{{ proof *) [ REWRITE_TAC[Appendix.scs_4T2]; MATCH_MP_TAC is_scs_adj; REWRITE_TAC[Appendix.d_tame;Sphere.cstab]; NUM_REDUCE_TAC; BY(REWRITE_TAC[Sphere.h0] THEN REAL_ARITH_TAC) ]);;
(* }}} *)
let is_scs_4T3 = 
prove_by_refinement( `is_scs_v39 scs_4T3`,
(* {{{ proof *) [ REWRITE_TAC[Appendix.scs_4T3]; REWRITE_TAC[Appendix.mk_unadorned_v39]; MATCH_MP_TAC is_scs_funlist_basic; REWRITE_TAC[Appendix.d_tame;Sphere.cstab;Sphere.h0;Terminal.I_LT_J_LT_4_EXPLICIT]; TYPED_ABBREV_TAC `s = {i | i < 4 /\ (&2 * #1.26 < funlist_v39 [(0,1), #3.01; (0,2),&6; (1,3),&6] (&2) 4 i (SUC i) \/ &2 < funlist_v39 [(0,1), #3.01; (0,2), #3.01; (1,3), #3.01] (&2) 4 i (SUC i))}`; REWRITE_TAC[arith `i < 4 <=> i=0 \/ i=1 \/ i=2 \/ i=3`]; NUM_REDUCE_TAC; REPEAT CONJ_TAC THEN REPEAT STRIP_TAC THEN ASM_REWRITE_TAC[Terminal.FUNLIST_EXPLICIT;Uxckfpe.ARITH_4_TAC;psort_4] THEN TRY (REAL_ARITH_TAC); TYPIFY `CARD s = 1` ENOUGH_TO_SHOW_TAC; BY(ARITH_TAC); MATCH_MP_TAC Misc_defs_and_lemmas.CARD_SING; REWRITE_TAC[SING]; TYPIFY `0` EXISTS_TAC; EXPAND_TAC "s";
REWRITE_TAC[EXTENSION;IN_ELIM_THM;IN_INSERT;NOT_IN_EMPTY]; REWRITE_TAC[arith `i < 4 <=> i=0 \/ i=1 \/ i=2 \/ i=3`]; GEN_TAC; ASM_CASES_TAC `x = 0`; ASM_REWRITE_TAC[Terminal.FUNLIST_EXPLICIT;Uxckfpe.ARITH_4_TAC;psort_4]; BY(REAL_ARITH_TAC); ASM_REWRITE_TAC[]; REWRITE_TAC[TAUT `~(a /\ b) <=> (a ==> ~b)`]; BY(STRIP_TAC THEN ASM_REWRITE_TAC[Terminal.FUNLIST_EXPLICIT;Uxckfpe.ARITH_4_TAC;psort_4] THEN TRY (REAL_ARITH_TAC)) ]);; (* }}} *)
let is_scs_4T4 = 
prove_by_refinement( `is_scs_v39 scs_4T4`,
(* {{{ proof *) [ REWRITE_TAC[Appendix.scs_4T4]; REWRITE_TAC[Appendix.mk_unadorned_v39]; MATCH_MP_TAC is_scs_funlist_basic; REWRITE_TAC[Appendix.d_tame;Sphere.cstab;Sphere.h0;Terminal.I_LT_J_LT_4_EXPLICIT]; TYPED_ABBREV_TAC `s = {i | i < 4 /\ (&2 * #1.26 < funlist_v39 [(0,1),sqrt8; (0,2),&6; (1,3), #3.01] (&2 * #1.26) 4 i (SUC i) \/ &2 < funlist_v39 [(0,1),&2 * #1.26; (0,2),sqrt8; (1,3),sqrt8] (&2) 4 i (SUC i))}`; REWRITE_TAC[arith `i < 4 <=> i=0 \/ i=1 \/ i=2 \/ i=3`]; NUM_REDUCE_TAC; REPEAT CONJ_TAC THEN REPEAT STRIP_TAC THEN ASM_REWRITE_TAC[Terminal.FUNLIST_EXPLICIT;Uxckfpe.ARITH_4_TAC;psort_4] THEN MP_TAC sqrt8_flyspeck (* Flyspeck_constants.bounds *) THEN TRY (REAL_ARITH_TAC); DISCH_THEN kill; TYPIFY `CARD s = 1` ENOUGH_TO_SHOW_TAC; BY(ARITH_TAC); MATCH_MP_TAC Misc_defs_and_lemmas.CARD_SING; REWRITE_TAC[SING]; TYPIFY `0` EXISTS_TAC; EXPAND_TAC "s";
REWRITE_TAC[EXTENSION;IN_ELIM_THM;IN_INSERT;NOT_IN_EMPTY]; REWRITE_TAC[arith `i < 4 <=> i=0 \/ i=1 \/ i=2 \/ i=3`]; GEN_TAC; ASM_CASES_TAC `x = 0`; ASM_REWRITE_TAC[Terminal.FUNLIST_EXPLICIT;Uxckfpe.ARITH_4_TAC;psort_4]; BY(REAL_ARITH_TAC); ASM_REWRITE_TAC[]; REWRITE_TAC[TAUT `~(a /\ b) <=> (a ==> ~b)`]; BY(STRIP_TAC THEN ASM_REWRITE_TAC[Terminal.FUNLIST_EXPLICIT;Uxckfpe.ARITH_4_TAC;psort_4] THEN TRY (REAL_ARITH_TAC)) ]);; (* }}} *)
let is_scs_4T5 = 
prove_by_refinement( `is_scs_v39 scs_4T5`,
(* {{{ proof *) [ REWRITE_TAC[Appendix.scs_4T5]; REWRITE_TAC[Appendix.mk_unadorned_v39]; MATCH_MP_TAC is_scs_funlist_basic; REWRITE_TAC[Appendix.d_tame;Sphere.cstab;Sphere.h0;Terminal.I_LT_J_LT_4_EXPLICIT]; TYPED_ABBREV_TAC `s = {i | i < 4 /\ (&2 * #1.26 < funlist_v39 [(0,1), #3.01; (0,2),&6; (1,3), #3.01] (&2 * #1.26) 4 i (SUC i) \/ &2 < funlist_v39 [(0,1),&2 * #1.26; (0,2), #3.01; (1,3), #3.01] (&2) 4 i (SUC i))}`; REWRITE_TAC[arith `i < 4 <=> i=0 \/ i=1 \/ i=2 \/ i=3`]; NUM_REDUCE_TAC; REPEAT CONJ_TAC THEN REPEAT STRIP_TAC THEN ASM_REWRITE_TAC[Terminal.FUNLIST_EXPLICIT;Uxckfpe.ARITH_4_TAC;psort_4] THEN TRY (REAL_ARITH_TAC); TYPIFY `CARD s = 1` ENOUGH_TO_SHOW_TAC; BY(ARITH_TAC); MATCH_MP_TAC Misc_defs_and_lemmas.CARD_SING; REWRITE_TAC[SING]; TYPIFY `0` EXISTS_TAC; EXPAND_TAC "s";
REWRITE_TAC[EXTENSION;IN_ELIM_THM;IN_INSERT;NOT_IN_EMPTY]; REWRITE_TAC[arith `i < 4 <=> i=0 \/ i=1 \/ i=2 \/ i=3`]; GEN_TAC; ASM_CASES_TAC `x = 0`; ASM_REWRITE_TAC[Terminal.FUNLIST_EXPLICIT;Uxckfpe.ARITH_4_TAC;psort_4]; BY(REAL_ARITH_TAC); ASM_REWRITE_TAC[]; REWRITE_TAC[TAUT `~(a /\ b) <=> (a ==> ~b)`]; BY(STRIP_TAC THEN ASM_REWRITE_TAC[Terminal.FUNLIST_EXPLICIT;Uxckfpe.ARITH_4_TAC;psort_4] THEN TRY (REAL_ARITH_TAC)) ]);; (* }}} *)
let CARD_3_SUBSET = 
prove_by_refinement( `!f. CARD {i | i < 3 /\ f i} <= 3`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; TYPIFY `CARD {i | i < 3 } = 3` ENOUGH_TO_SHOW_TAC; DISCH_TAC; INTRO_TAC CARD_SUBSET [`{i | i < 3 /\ f i}`;`{i | i < 3}`]; ANTS_TAC; CONJ_TAC; BY(SET_TAC[]); BY(REWRITE_TAC[FINITE_NUMSEG_LT]); BY(ASM_TAC THEN ARITH_TAC); BY(REWRITE_TAC[CARD_NUMSEG_LT]) ]);;
(* }}} *)
let is_scs_3T1 = 
prove_by_refinement( `is_scs_v39 scs_3T1`,
(* {{{ proof *) [ REWRITE_TAC[Appendix.scs_3T1]; REWRITE_TAC[Appendix.mk_unadorned_v39]; MATCH_MP_TAC is_scs_funlist_basic; REWRITE_TAC[Appendix.d_tame;Sphere.cstab;Sphere.h0;Terminal.I_LT_J_LT_3_EXPLICIT;arith `x + 3 <= 6 <=> x <= 3`;CARD_3_SUBSET]; REWRITE_TAC[arith `i < 3 <=> i=0 \/ i=1 \/ i=2`]; NUM_REDUCE_TAC; BY(REPEAT CONJ_TAC THEN REPEAT STRIP_TAC THEN ASM_REWRITE_TAC[Terminal.FUNLIST_EXPLICIT;Uxckfpe.ARITH_3_TAC] THEN MP_TAC sqrt8_flyspeck (* 1 *) THEN TRY (REAL_ARITH_TAC)) ]);;
(* }}} *)
let is_scs_3M1 = 
prove_by_refinement( `is_scs_v39 scs_3M1`,
(* {{{ proof *) [ REWRITE_TAC[Appendix.scs_3M1]; REWRITE_TAC[Appendix.mk_unadorned_v39]; MATCH_MP_TAC is_scs_funlist_basic; REWRITE_TAC[Appendix.d_tame;Sphere.cstab;Sphere.h0;Terminal.I_LT_J_LT_3_EXPLICIT;arith `x + 3 <= 6 <=> x <= 3`;CARD_3_SUBSET]; REWRITE_TAC[arith `i < 3 <=> i=0 \/ i=1 \/ i=2`]; NUM_REDUCE_TAC; BY(REPEAT CONJ_TAC THEN REPEAT STRIP_TAC THEN ASM_REWRITE_TAC[Terminal.FUNLIST_EXPLICIT;Uxckfpe.ARITH_3_TAC] THEN MP_TAC sqrt8_flyspeck (* 1 *) THEN TRY (REAL_ARITH_TAC)) ]);;
(* }}} *)
let is_scs_3T2 = 
prove_by_refinement( `is_scs_v39 scs_3T2`,
(* {{{ proof *) [ REWRITE_TAC[Appendix.scs_3T2]; REWRITE_TAC[Appendix.mk_unadorned_v39]; MATCH_MP_TAC is_scs_funlist_basic; REWRITE_TAC[Appendix.d_tame;Sphere.cstab;Sphere.h0;Terminal.I_LT_J_LT_3_EXPLICIT;arith `x + 3 <= 6 <=> x <= 3`;CARD_3_SUBSET]; REWRITE_TAC[arith `i < 3 <=> i=0 \/ i=1 \/ i=2`]; NUM_REDUCE_TAC; BY(REPEAT CONJ_TAC THEN REPEAT STRIP_TAC THEN ASM_REWRITE_TAC[Terminal.FUNLIST_EXPLICIT;Uxckfpe.ARITH_3_TAC] THEN MP_TAC sqrt8_flyspeck (* 1 *) THEN TRY (REAL_ARITH_TAC)) ]);;
(* }}} *)
let is_scs_3T3 = 
prove_by_refinement( `is_scs_v39 scs_3T3`,
(* {{{ proof *) [ REWRITE_TAC[Appendix.scs_3T3]; REWRITE_TAC[Appendix.mk_unadorned_v39]; MATCH_MP_TAC is_scs_funlist_basic; REWRITE_TAC[Appendix.d_tame;Sphere.cstab;Sphere.h0;Terminal.I_LT_J_LT_3_EXPLICIT;arith `x + 3 <= 6 <=> x <= 3`;CARD_3_SUBSET]; REWRITE_TAC[arith `i < 3 <=> i=0 \/ i=1 \/ i=2`]; NUM_REDUCE_TAC; BY(REPEAT CONJ_TAC THEN REPEAT STRIP_TAC THEN ASM_REWRITE_TAC[Terminal.FUNLIST_EXPLICIT;Uxckfpe.ARITH_3_TAC] THEN MP_TAC sqrt8_flyspeck (* 1 *) THEN TRY (REAL_ARITH_TAC)) ]);;
(* }}} *)
let is_scs_3T4 = 
prove_by_refinement( `is_scs_v39 scs_3T4`,
(* {{{ proof *) [ REWRITE_TAC[Appendix.scs_3T4]; REWRITE_TAC[Appendix.mk_unadorned_v39]; MATCH_MP_TAC is_scs_funlist_basic; REWRITE_TAC[Appendix.d_tame;Sphere.cstab;Sphere.h0;Terminal.I_LT_J_LT_3_EXPLICIT;arith `x + 3 <= 6 <=> x <= 3`;CARD_3_SUBSET]; REWRITE_TAC[arith `i < 3 <=> i=0 \/ i=1 \/ i=2`]; NUM_REDUCE_TAC; BY(REPEAT CONJ_TAC THEN REPEAT STRIP_TAC THEN ASM_REWRITE_TAC[Terminal.FUNLIST_EXPLICIT;Uxckfpe.ARITH_3_TAC] THEN MP_TAC sqrt8_flyspeck (* 1 *) THEN TRY (REAL_ARITH_TAC)) ]);;
(* }}} *)
let is_scs_3T5 = 
prove_by_refinement( `is_scs_v39 scs_3T5`,
(* {{{ proof *) [ REWRITE_TAC[Appendix.scs_3T5]; REWRITE_TAC[Appendix.mk_unadorned_v39]; MATCH_MP_TAC is_scs_funlist_basic; REWRITE_TAC[Appendix.d_tame;Sphere.cstab;Sphere.h0;Terminal.I_LT_J_LT_3_EXPLICIT;arith `x + 3 <= 6 <=> x <= 3`;CARD_3_SUBSET]; REWRITE_TAC[arith `i < 3 <=> i=0 \/ i=1 \/ i=2`]; NUM_REDUCE_TAC; BY(REPEAT CONJ_TAC THEN REPEAT STRIP_TAC THEN ASM_REWRITE_TAC[Terminal.FUNLIST_EXPLICIT;Uxckfpe.ARITH_3_TAC] THEN MP_TAC sqrt8_flyspeck (* 1 *) THEN TRY (REAL_ARITH_TAC)) ]);;
(* }}} *)
let is_scs_3T6 = 
prove_by_refinement( `is_scs_v39 scs_3T6'`,
(* {{{ proof *) [ REWRITE_TAC[Appendix.scs_3T6]; REWRITE_TAC[Appendix.mk_unadorned_v39]; MATCH_MP_TAC is_scs_funlist_basic; REWRITE_TAC[Appendix.d_tame;Sphere.cstab;Sphere.h0;Terminal.I_LT_J_LT_3_EXPLICIT;arith `x + 3 <= 6 <=> x <= 3`;CARD_3_SUBSET]; REWRITE_TAC[arith `i < 3 <=> i=0 \/ i=1 \/ i=2`]; NUM_REDUCE_TAC; BY(REPEAT CONJ_TAC THEN REPEAT STRIP_TAC THEN ASM_REWRITE_TAC[Terminal.FUNLIST_EXPLICIT;Uxckfpe.ARITH_3_TAC] THEN MP_TAC sqrt8_flyspeck (* 1 *) THEN TRY (REAL_ARITH_TAC)) ]);;
(* }}} *)
let is_scs_3T7 = 
prove_by_refinement( `is_scs_v39 scs_3T7`,
(* {{{ proof *) [ REWRITE_TAC[Appendix.scs_3T7]; REWRITE_TAC[Appendix.mk_unadorned_v39]; MATCH_MP_TAC is_scs_funlist_basic; REWRITE_TAC[Appendix.d_tame;Sphere.cstab;Sphere.h0;Terminal.I_LT_J_LT_3_EXPLICIT;arith `x + 3 <= 6 <=> x <= 3`;CARD_3_SUBSET]; REWRITE_TAC[arith `i < 3 <=> i=0 \/ i=1 \/ i=2`]; NUM_REDUCE_TAC; BY(REPEAT CONJ_TAC THEN REPEAT STRIP_TAC THEN ASM_REWRITE_TAC[Terminal.FUNLIST_EXPLICIT;Uxckfpe.ARITH_3_TAC] THEN MP_TAC sqrt8_flyspeck (* 1 *) THEN TRY (REAL_ARITH_TAC)) ]);;
(* }}} *)
let is_scs_6I1 = 
prove_by_refinement( `is_scs_v39 scs_6I1`,
(* {{{ proof *) [ REWRITE_TAC[Appendix.scs_6I1]; MATCH_MP_TAC is_scs_adj; REWRITE_TAC[Appendix.d_tame;Sphere.cstab]; NUM_REDUCE_TAC; BY(REWRITE_TAC[Sphere.h0] THEN REAL_ARITH_TAC) ]);;
(* }}} *)
let is_scs_5I1 = 
prove_by_refinement( `is_scs_v39 scs_5I1`,
(* {{{ proof *) [ REWRITE_TAC[Appendix.scs_5I1]; MATCH_MP_TAC is_scs_adj; REWRITE_TAC[Appendix.d_tame;Sphere.cstab]; NUM_REDUCE_TAC; BY(REWRITE_TAC[Sphere.h0] THEN REAL_ARITH_TAC) ]);;
(* }}} *)
let is_scs_5I2 = 
prove_by_refinement( `is_scs_v39 scs_5I2`,
(* {{{ proof *) [ REWRITE_TAC[Appendix.scs_5I2]; MATCH_MP_TAC is_scs_adj; REWRITE_TAC[Appendix.d_tame;Sphere.cstab]; NUM_REDUCE_TAC; BY(REWRITE_TAC[Sphere.h0] THEN MP_TAC sqrt8_flyspeck (* 1 *) THEN REAL_ARITH_TAC) ]);;
(* }}} *)
let is_scs_5I3 = 
prove_by_refinement( `is_scs_v39 scs_5I3`,
(* {{{ proof *) [ REWRITE_TAC[Appendix.scs_5I3]; REWRITE_TAC[Appendix.mk_unadorned_v39]; MATCH_MP_TAC is_scs_funlist_basic; REWRITE_TAC[Appendix.d_tame;Sphere.cstab;Sphere.h0;I_LT_J_LT_5_EXPLICIT]; TYPED_ABBREV_TAC `s = {i | i < 5 /\ (&2 * #1.26 < funlist_v39 [(0,1),sqrt8; (0,2),&6; (0,3),&6; (1,3),&6; (1,4),&6; (2,4),&6] (&2 * #1.26) 5 i (SUC i) \/ &2 < funlist_v39 [(0,1),&2 * #1.26; (0,2),&2 * #1.26; (0,3),&2 * #1.26; (1,3), &2 * #1.26; (1,4), &2 * #1.26; (2,4),&2 * #1.26] (&2) 5 i (SUC i))}`; REWRITE_TAC[arith `i < 5 <=> i=0 \/ i=1 \/ i=2 \/ i=3 \/ i=4`]; NUM_REDUCE_TAC; REPEAT CONJ_TAC THEN REPEAT STRIP_TAC THEN ASM_REWRITE_TAC[Terminal.FUNLIST_EXPLICIT;Uxckfpe.ARITH_5_TAC;psort_5] THEN MP_TAC sqrt8_flyspeck (* 1 *) THEN TRY (REAL_ARITH_TAC); DISCH_THEN kill; TYPIFY `CARD s = 1` ENOUGH_TO_SHOW_TAC; BY(ARITH_TAC); MATCH_MP_TAC Misc_defs_and_lemmas.CARD_SING; REWRITE_TAC[SING]; TYPIFY `0` EXISTS_TAC; EXPAND_TAC "s";
REWRITE_TAC[EXTENSION;IN_ELIM_THM;IN_INSERT;NOT_IN_EMPTY]; REWRITE_TAC[arith `i < 5 <=> i=0 \/ i=1 \/ i=2 \/ i=3 \/ i=4`]; GEN_TAC; ASM_CASES_TAC `x = 0`; ASM_REWRITE_TAC[Terminal.FUNLIST_EXPLICIT;Uxckfpe.ARITH_5_TAC;psort_5]; BY(MP_TAC sqrt8_flyspeck (* 1 *) THEN REAL_ARITH_TAC); ASM_REWRITE_TAC[]; REWRITE_TAC[TAUT `~(a /\ b) <=> (a ==> ~b)`]; BY(STRIP_TAC THEN ASM_REWRITE_TAC[Terminal.FUNLIST_EXPLICIT;Uxckfpe.ARITH_5_TAC;psort_5] THEN TRY (REAL_ARITH_TAC)) ]);; (* }}} *)
let is_scs_4I1 = 
prove_by_refinement( `is_scs_v39 scs_4I1`,
(* {{{ proof *) [ REWRITE_TAC[Appendix.scs_4I1]; MATCH_MP_TAC is_scs_adj; REWRITE_TAC[Appendix.d_tame;Sphere.cstab]; NUM_REDUCE_TAC; BY(REWRITE_TAC[Sphere.h0] THEN MP_TAC sqrt8_flyspeck (* 1 *) THEN REAL_ARITH_TAC) ]);;
(* }}} *)
let is_scs_4I2 = 
prove_by_refinement( `is_scs_v39 scs_4I2`,
(* {{{ proof *) [ REWRITE_TAC[Appendix.scs_4I2]; MATCH_MP_TAC is_scs_adj; REWRITE_TAC[Appendix.d_tame;Sphere.cstab]; NUM_REDUCE_TAC; BY(REWRITE_TAC[Sphere.h0] THEN MP_TAC sqrt8_flyspeck (* 1 *) THEN REAL_ARITH_TAC) ]);;
(* }}} *)
let is_scs_4I3 = 
prove_by_refinement( `is_scs_v39 scs_4I3`,
(* {{{ proof *) [ REWRITE_TAC[Appendix.scs_4I3]; REWRITE_TAC[Appendix.mk_unadorned_v39]; MATCH_MP_TAC is_scs_funlist_basic; REWRITE_TAC[Appendix.d_tame;Sphere.cstab;Sphere.h0;Terminal.I_LT_J_LT_4_EXPLICIT]; TYPED_ABBREV_TAC `s = {i | i < 4 /\ (&2 * #1.26 < funlist_v39 [(0,1),sqrt8; (0,2),&6; (1,3),&6] (&2 * #1.26) 4 i (SUC i) \/ &2 < funlist_v39 [(0,1),&2 * #1.26; (0,2),sqrt8; (1,3),sqrt8] (&2) 4 i (SUC i))}`; REWRITE_TAC[arith `i < 4 <=> i=0 \/ i=1 \/ i=2 \/ i=3`]; NUM_REDUCE_TAC; REPEAT CONJ_TAC THEN REPEAT STRIP_TAC THEN ASM_REWRITE_TAC[Terminal.FUNLIST_EXPLICIT;Uxckfpe.ARITH_4_TAC;psort_4] THEN TRY (MP_TAC sqrt8_flyspeck (* 1 *) THEN REAL_ARITH_TAC); TYPIFY `CARD s = 1` ENOUGH_TO_SHOW_TAC; BY(ARITH_TAC); MATCH_MP_TAC Misc_defs_and_lemmas.CARD_SING; REWRITE_TAC[SING]; TYPIFY `0` EXISTS_TAC; EXPAND_TAC "s";
REWRITE_TAC[EXTENSION;IN_ELIM_THM;IN_INSERT;NOT_IN_EMPTY]; REWRITE_TAC[arith `i < 4 <=> i=0 \/ i=1 \/ i=2 \/ i=3`]; GEN_TAC; ASM_CASES_TAC `x = 0`; ASM_REWRITE_TAC[Terminal.FUNLIST_EXPLICIT;Uxckfpe.ARITH_4_TAC;psort_4]; BY(MP_TAC sqrt8_flyspeck (* 1 *) THEN REAL_ARITH_TAC); ASM_REWRITE_TAC[]; REWRITE_TAC[TAUT `~(a /\ b) <=> (a ==> ~b)`]; BY(STRIP_TAC THEN ASM_REWRITE_TAC[Terminal.FUNLIST_EXPLICIT;Uxckfpe.ARITH_4_TAC;psort_4] THEN TRY (MP_TAC sqrt8_flyspeck (* 1 *) THEN REAL_ARITH_TAC)) ]);; (* }}} *)
let is_scs_3I1 = 
prove_by_refinement( `is_scs_v39 scs_3I1`,
(* {{{ proof *) [ REWRITE_TAC[Appendix.scs_3I1]; MATCH_MP_TAC is_scs_adj; REWRITE_TAC[Appendix.d_tame;Sphere.cstab]; NUM_REDUCE_TAC; BY(REWRITE_TAC[Sphere.h0] THEN REAL_ARITH_TAC) ]);;
(* }}} *) (* let stab_diag_basic = prove_by_refinement( `!s i j. scs_basic_v39 s /\ ~(i = j) ==> scs_basic_v39 (scs_stab_diag_v39 s i j)`, (* {{{ proof *) [ rt[Appendix.scs_is_basic;Appendix.is_scs_v39;Appendix.unadorned_v39;Appendix.scs_stab_diag_v39] ]);; (* }}} *) *)
let is_scs_6M1 = 
prove_by_refinement( `is_scs_v39 scs_6M1`,
(* {{{ proof *) [ REWRITE_TAC[Appendix.scs_6M1]; MATCH_MP_TAC is_scs_adj; REWRITE_TAC[Appendix.d_tame;Sphere.cstab]; NUM_REDUCE_TAC; BY(REWRITE_TAC[Sphere.h0] THEN REAL_ARITH_TAC) ]);;
(* }}} *)
let is_scs_5M1 = 
prove_by_refinement( `is_scs_v39 scs_5M1`,
(* {{{ proof *) [ REWRITE_TAC[Appendix.scs_5M1]; REWRITE_TAC[Appendix.mk_unadorned_v39]; MATCH_MP_TAC is_scs_funlist_basic; REWRITE_TAC[Appendix.d_tame;Sphere.cstab;Sphere.h0;I_LT_J_LT_5_EXPLICIT]; TYPED_ABBREV_TAC `s = {i | i < 5 /\ (&2 * #1.26 < funlist_v39 [(0,1), #3.01; (0,2),&6; (0,3),&6; (1,3),&6; (1,4),&6; (2,4),&6] (&2 * #1.26) 5 i (SUC i) \/ &2 < funlist_v39 [(0,1),&2 * #1.26; (0,2),&2 * #1.26; (0,3),&2 * #1.26; (1,3), &2 * #1.26; (1,4), &2 * #1.26; (2,4),&2 * #1.26] (&2) 5 i (SUC i))}`; REWRITE_TAC[arith `i < 5 <=> i=0 \/ i=1 \/ i=2 \/ i=3 \/ i=4`]; NUM_REDUCE_TAC; REPEAT CONJ_TAC THEN REPEAT STRIP_TAC THEN ASM_REWRITE_TAC[Terminal.FUNLIST_EXPLICIT;Uxckfpe.ARITH_5_TAC;psort_5] THEN TRY (REAL_ARITH_TAC); TYPIFY `CARD s = 1` ENOUGH_TO_SHOW_TAC; BY(ARITH_TAC); MATCH_MP_TAC Misc_defs_and_lemmas.CARD_SING; REWRITE_TAC[SING]; TYPIFY `0` EXISTS_TAC; EXPAND_TAC "s";
REWRITE_TAC[EXTENSION;IN_ELIM_THM;IN_INSERT;NOT_IN_EMPTY]; REWRITE_TAC[arith `i < 5 <=> i=0 \/ i=1 \/ i=2 \/ i=3 \/ i=4`]; GEN_TAC; ASM_CASES_TAC `x = 0`; ASM_REWRITE_TAC[Terminal.FUNLIST_EXPLICIT;Uxckfpe.ARITH_5_TAC;psort_5]; BY(MP_TAC sqrt8_flyspeck (* 1 *) THEN REAL_ARITH_TAC); ASM_REWRITE_TAC[]; REWRITE_TAC[TAUT `~(a /\ b) <=> (a ==> ~b)`]; BY(STRIP_TAC THEN ASM_REWRITE_TAC[Terminal.FUNLIST_EXPLICIT;Uxckfpe.ARITH_5_TAC;psort_5] THEN TRY (REAL_ARITH_TAC)) ]);; (* }}} *)
let is_scs_5M2 = 
prove_by_refinement( `is_scs_v39 scs_5M2`,
(* {{{ proof *) [ REWRITE_TAC[Appendix.scs_5M2]; REWRITE_TAC[Appendix.mk_unadorned_v39]; MATCH_MP_TAC is_scs_funlist_basic; REWRITE_TAC[Appendix.d_tame;Sphere.cstab;Sphere.h0;I_LT_J_LT_5_EXPLICIT]; TYPED_ABBREV_TAC `s = {i | i < 5 /\ (&2 * #1.26 < funlist_v39 [(0,1), #3.01; (0,2),&6; (0,3),&6; (1,3),&6; (1,4),&6; (2,4),&6] (&2 * #1.26) 5 i (SUC i) \/ &2 < funlist_v39 [(0,1),&2; (0,2), #3.01; (0,3), #3.01; (1,3), #3.01; (1,4), #3.01; (2,4), #3.01] (&2) 5 i (SUC i))}`; REWRITE_TAC[arith `i < 5 <=> i=0 \/ i=1 \/ i=2 \/ i=3 \/ i=4`]; NUM_REDUCE_TAC; REPEAT CONJ_TAC THEN REPEAT STRIP_TAC THEN ASM_REWRITE_TAC[Terminal.FUNLIST_EXPLICIT;Uxckfpe.ARITH_5_TAC;psort_5] THEN TRY (REAL_ARITH_TAC); TYPIFY `CARD s = 1` ENOUGH_TO_SHOW_TAC; BY(ARITH_TAC); MATCH_MP_TAC Misc_defs_and_lemmas.CARD_SING; REWRITE_TAC[SING]; TYPIFY `0` EXISTS_TAC; EXPAND_TAC "s";
REWRITE_TAC[EXTENSION;IN_ELIM_THM;IN_INSERT;NOT_IN_EMPTY]; REWRITE_TAC[arith `i < 5 <=> i=0 \/ i=1 \/ i=2 \/ i=3 \/ i=4`]; GEN_TAC; ASM_CASES_TAC `x = 0`; ASM_REWRITE_TAC[Terminal.FUNLIST_EXPLICIT;Uxckfpe.ARITH_5_TAC;psort_5]; BY(MP_TAC sqrt8_flyspeck (* 1 *) THEN REAL_ARITH_TAC); ASM_REWRITE_TAC[]; REWRITE_TAC[TAUT `~(a /\ b) <=> (a ==> ~b)`]; BY(STRIP_TAC THEN ASM_REWRITE_TAC[Terminal.FUNLIST_EXPLICIT;Uxckfpe.ARITH_5_TAC;psort_5] THEN TRY (REAL_ARITH_TAC)) ]);; (* }}} *)
let is_scs_4M1 = 
prove_by_refinement( `is_scs_v39 scs_4M1`,
(* {{{ proof *) [ REWRITE_TAC[Appendix.scs_4M1]; REWRITE_TAC[Appendix.mk_unadorned_v39]; MATCH_MP_TAC is_scs_funlist_basic; REWRITE_TAC[Appendix.d_tame;Sphere.cstab;Sphere.h0;Terminal.I_LT_J_LT_4_EXPLICIT]; TYPED_ABBREV_TAC `s = {i | i < 4 /\ (&2 * #1.26 < funlist_v39 [(0,1), #3.01; (0,2),&6; (1,3),&6] (&2 * #1.26) 4 i (SUC i) \/ &2 < funlist_v39 [(0,1),&2 * #1.26; (0,2),&2 * #1.26; (1,3),&2 * #1.26] (&2) 4 i (SUC i))}`; REWRITE_TAC[arith `i < 4 <=> i=0 \/ i=1 \/ i=2 \/ i=3`]; NUM_REDUCE_TAC; REPEAT CONJ_TAC THEN REPEAT STRIP_TAC THEN ASM_REWRITE_TAC[Terminal.FUNLIST_EXPLICIT;Uxckfpe.ARITH_4_TAC;psort_4] THEN TRY (MP_TAC sqrt8_flyspeck (* 1 *) THEN REAL_ARITH_TAC); TYPIFY `CARD s = 1` ENOUGH_TO_SHOW_TAC; BY(ARITH_TAC); MATCH_MP_TAC Misc_defs_and_lemmas.CARD_SING; REWRITE_TAC[SING]; TYPIFY `0` EXISTS_TAC; EXPAND_TAC "s";
REWRITE_TAC[EXTENSION;IN_ELIM_THM;IN_INSERT;NOT_IN_EMPTY]; REWRITE_TAC[arith `i < 4 <=> i=0 \/ i=1 \/ i=2 \/ i=3`]; GEN_TAC; ASM_CASES_TAC `x = 0`; ASM_REWRITE_TAC[Terminal.FUNLIST_EXPLICIT;Uxckfpe.ARITH_4_TAC;psort_4]; BY(MP_TAC sqrt8_flyspeck (* 1 *) THEN REAL_ARITH_TAC); ASM_REWRITE_TAC[]; REWRITE_TAC[TAUT `~(a /\ b) <=> (a ==> ~b)`]; BY(STRIP_TAC THEN ASM_REWRITE_TAC[Terminal.FUNLIST_EXPLICIT;Uxckfpe.ARITH_4_TAC;psort_4] THEN TRY (MP_TAC sqrt8_flyspeck (* 1 *) THEN REAL_ARITH_TAC)) ]);; (* }}} *)
let is_scs_4M2 = 
prove_by_refinement( `is_scs_v39 scs_4M2`,
(* {{{ proof *) [ REWRITE_TAC[Appendix.scs_4M2]; REWRITE_TAC[Appendix.mk_unadorned_v39]; MATCH_MP_TAC is_scs_funlist_basic; REWRITE_TAC[Appendix.d_tame;Sphere.cstab;Sphere.h0;Terminal.I_LT_J_LT_4_EXPLICIT]; TYPED_ABBREV_TAC `s = {i | i < 4 /\ (&2 * #1.26 < funlist_v39 [(0,1), #3.01; (0,2),&6; (1,3),&6] (&2 * #1.26) 4 i (SUC i) \/ &2 < funlist_v39 [(0,1),&2 * #1.26; (0,2),&2 * #1.26; (1,3),&2 * #1.26] (&2) 4 i (SUC i))}`; REWRITE_TAC[arith `i < 4 <=> i=0 \/ i=1 \/ i=2 \/ i=3`]; NUM_REDUCE_TAC; REPEAT CONJ_TAC THEN REPEAT STRIP_TAC THEN ASM_REWRITE_TAC[Terminal.FUNLIST_EXPLICIT;Uxckfpe.ARITH_4_TAC;psort_4] THEN TRY (MP_TAC sqrt8_flyspeck (* 1 *) THEN REAL_ARITH_TAC); TYPIFY `CARD s = 1` ENOUGH_TO_SHOW_TAC; BY(ARITH_TAC); MATCH_MP_TAC Misc_defs_and_lemmas.CARD_SING; REWRITE_TAC[SING]; TYPIFY `0` EXISTS_TAC; EXPAND_TAC "s";
REWRITE_TAC[EXTENSION;IN_ELIM_THM;IN_INSERT;NOT_IN_EMPTY]; REWRITE_TAC[arith `i < 4 <=> i=0 \/ i=1 \/ i=2 \/ i=3`]; GEN_TAC; ASM_CASES_TAC `x = 0`; ASM_REWRITE_TAC[Terminal.FUNLIST_EXPLICIT;Uxckfpe.ARITH_4_TAC;psort_4]; BY(MP_TAC sqrt8_flyspeck (* 1 *) THEN REAL_ARITH_TAC); ASM_REWRITE_TAC[]; REWRITE_TAC[TAUT `~(a /\ b) <=> (a ==> ~b)`]; BY(STRIP_TAC THEN ASM_REWRITE_TAC[Terminal.FUNLIST_EXPLICIT;Uxckfpe.ARITH_4_TAC;psort_4] THEN TRY (MP_TAC sqrt8_flyspeck (* 1 *) THEN REAL_ARITH_TAC)) ]);; (* }}} *)
let is_scs_4M3 = 
prove_by_refinement( `is_scs_v39 scs_4M3'`,
(* {{{ proof *) [ REWRITE_TAC[Appendix.scs_4M3]; REWRITE_TAC[Appendix.mk_unadorned_v39]; MATCH_MP_TAC is_scs_funlist_basic; REWRITE_TAC[Appendix.d_tame;Sphere.cstab;Sphere.h0;Terminal.I_LT_J_LT_4_EXPLICIT]; TYPED_ABBREV_TAC `s = {i | i < 4 /\ (&2 * #1.26 < funlist_v39 [(0,1), #3.01; (0,2),&6; (1,3),&6] (&2 * #1.26) 4 i (SUC i) \/ &2 < funlist_v39 [(0,1),sqrt8; (0,2),sqrt8; (1,3),sqrt8] (&2) 4 i (SUC i))}`; REWRITE_TAC[arith `i < 4 <=> i=0 \/ i=1 \/ i=2 \/ i=3`]; NUM_REDUCE_TAC; REPEAT CONJ_TAC THEN REPEAT STRIP_TAC THEN ASM_REWRITE_TAC[Terminal.FUNLIST_EXPLICIT;Uxckfpe.ARITH_4_TAC;psort_4] THEN TRY (MP_TAC sqrt8_flyspeck (* 1 *) THEN REAL_ARITH_TAC); TYPIFY `CARD s = 1` ENOUGH_TO_SHOW_TAC; BY(ARITH_TAC); MATCH_MP_TAC Misc_defs_and_lemmas.CARD_SING; REWRITE_TAC[SING]; TYPIFY `0` EXISTS_TAC; EXPAND_TAC "s";
REWRITE_TAC[EXTENSION;IN_ELIM_THM;IN_INSERT;NOT_IN_EMPTY]; REWRITE_TAC[arith `i < 4 <=> i=0 \/ i=1 \/ i=2 \/ i=3`]; GEN_TAC; ASM_CASES_TAC `x = 0`; ASM_REWRITE_TAC[Terminal.FUNLIST_EXPLICIT;Uxckfpe.ARITH_4_TAC;psort_4]; BY(MP_TAC sqrt8_flyspeck (* 1 *) THEN REAL_ARITH_TAC); ASM_REWRITE_TAC[]; REWRITE_TAC[TAUT `~(a /\ b) <=> (a ==> ~b)`]; BY(STRIP_TAC THEN ASM_REWRITE_TAC[Terminal.FUNLIST_EXPLICIT;Uxckfpe.ARITH_4_TAC;psort_4] THEN TRY (MP_TAC sqrt8_flyspeck (* 1 *) THEN REAL_ARITH_TAC)) ]);; (* }}} *)
let is_scs_4M4 = 
prove_by_refinement( `is_scs_v39 scs_4M4'`,
(* {{{ proof *) [ REWRITE_TAC[Appendix.scs_4M4]; REWRITE_TAC[Appendix.mk_unadorned_v39]; MATCH_MP_TAC is_scs_funlist_basic; REWRITE_TAC[Appendix.d_tame;Sphere.cstab;Sphere.h0;Terminal.I_LT_J_LT_4_EXPLICIT]; TYPED_ABBREV_TAC `s = {i | i < 4 /\ (&2 * #1.26 < funlist_v39 [(0,1), #3.01; (1,2), #3.01; (0,2),&6; (1,3),&6] (&2 * #1.26) 4 i (SUC i) \/ &2 < funlist_v39 [(0,1),&2 * #1.26; (1,2),&2 * #1.26; (0,2),&2 * #1.26; (1,3), &2 * #1.26] (&2) 4 i (SUC i))}`; REWRITE_TAC[arith `i < 4 <=> i=0 \/ i=1 \/ i=2 \/ i=3`]; NUM_REDUCE_TAC; REPEAT CONJ_TAC THEN REPEAT STRIP_TAC THEN ASM_REWRITE_TAC[Terminal.FUNLIST_EXPLICIT;Uxckfpe.ARITH_4_TAC;psort_4] THEN TRY (REAL_ARITH_TAC); TYPIFY `s = {0,1}` ENOUGH_TO_SHOW_TAC; DISCH_THEN SUBST1_TAC; BY(MESON_TAC[Geomdetail.CARD2;arith `x <= 2 ==> x + 4 <= 6`]); EXPAND_TAC "s";
REWRITE_TAC[EXTENSION;IN_ELIM_THM;IN_INSERT;NOT_IN_EMPTY]; REWRITE_TAC[arith `i < 4 <=> i=0 \/ i=1 \/ i=2 \/ i=3`]; GEN_TAC; ASM_CASES_TAC `x = 0`; ASM_REWRITE_TAC[Terminal.FUNLIST_EXPLICIT;Uxckfpe.ARITH_4_TAC;psort_4]; BY( REAL_ARITH_TAC); ASM_CASES_TAC `x = 1`; ASM_REWRITE_TAC[Terminal.FUNLIST_EXPLICIT;Uxckfpe.ARITH_4_TAC;psort_4]; BY( REAL_ARITH_TAC); ASM_REWRITE_TAC[]; REWRITE_TAC[TAUT `~(a /\ b) <=> (a ==> ~b)`]; BY(STRIP_TAC THEN ASM_REWRITE_TAC[Terminal.FUNLIST_EXPLICIT;Uxckfpe.ARITH_4_TAC;psort_4] THEN TRY (REAL_ARITH_TAC)) ]);; (* }}} *)
let is_scs_4M5 = 
prove_by_refinement( `is_scs_v39 scs_4M5'`,
(* {{{ proof *) [ REWRITE_TAC[Appendix.scs_4M5]; REWRITE_TAC[Appendix.mk_unadorned_v39]; MATCH_MP_TAC is_scs_funlist_basic; REWRITE_TAC[Appendix.d_tame;Sphere.cstab;Sphere.h0;Terminal.I_LT_J_LT_4_EXPLICIT]; TYPED_ABBREV_TAC `s = {i | i < 4 /\ (&2 * #1.26 < funlist_v39 [(0,1), #3.01; (2,3), #3.01; (0,2),&6; (1,3),&6] (&2 * #1.26) 4 i (SUC i) \/ &2 < funlist_v39 [(0,1),&2 * #1.26; (2,3),&2 * #1.26; (0,2),&2 * #1.26; (1,3), &2 * #1.26] (&2) 4 i (SUC i))}`; REWRITE_TAC[arith `i < 4 <=> i=0 \/ i=1 \/ i=2 \/ i=3`]; NUM_REDUCE_TAC; REPEAT CONJ_TAC THEN REPEAT STRIP_TAC THEN ASM_REWRITE_TAC[Terminal.FUNLIST_EXPLICIT;Uxckfpe.ARITH_4_TAC;psort_4] THEN TRY (REAL_ARITH_TAC); TYPIFY `s = {0,2}` ENOUGH_TO_SHOW_TAC; DISCH_THEN SUBST1_TAC; BY(MESON_TAC[Geomdetail.CARD2;arith `x <= 2 ==> x + 4 <= 6`]); EXPAND_TAC "s";
REWRITE_TAC[EXTENSION;IN_ELIM_THM;IN_INSERT;NOT_IN_EMPTY]; REWRITE_TAC[arith `i < 4 <=> i=0 \/ i=1 \/ i=2 \/ i=3`]; GEN_TAC; ASM_CASES_TAC `x = 0`; ASM_REWRITE_TAC[Terminal.FUNLIST_EXPLICIT;Uxckfpe.ARITH_4_TAC;psort_4]; BY( REAL_ARITH_TAC); ASM_CASES_TAC `x = 2`; ASM_REWRITE_TAC[Terminal.FUNLIST_EXPLICIT;Uxckfpe.ARITH_4_TAC;psort_4]; BY( REAL_ARITH_TAC); ASM_REWRITE_TAC[]; REWRITE_TAC[TAUT `~(a /\ b) <=> (a ==> ~b)`]; BY(STRIP_TAC THEN ASM_REWRITE_TAC[Terminal.FUNLIST_EXPLICIT;Uxckfpe.ARITH_4_TAC;psort_4] THEN TRY (REAL_ARITH_TAC)) ]);; (* }}} *)
let is_scs_4M6 = 
prove_by_refinement( `is_scs_v39 scs_4M6'`,
(* {{{ proof *) [ REWRITE_TAC[Appendix.scs_4M6]; REWRITE_TAC[Appendix.mk_unadorned_v39]; MATCH_MP_TAC is_scs_funlist_basic; REWRITE_TAC[Appendix.d_tame;Sphere.cstab;Sphere.h0;Terminal.I_LT_J_LT_4_EXPLICIT]; TYPED_ABBREV_TAC `s = {i | i < 4 /\ (&2 * #1.26 < funlist_v39 [(0,1), #3.01; (0,2),&6; (1,3),&6] (&2 * #1.26) 4 i (SUC i) \/ &2 < funlist_v39 [(0,1),&2 * #1.26; (0,2), #3.01; (1,3), #3.01] (&2) 4 i (SUC i))}`; REWRITE_TAC[arith `i < 4 <=> i=0 \/ i=1 \/ i=2 \/ i=3`]; NUM_REDUCE_TAC; REPEAT CONJ_TAC THEN REPEAT STRIP_TAC THEN ASM_REWRITE_TAC[Terminal.FUNLIST_EXPLICIT;Uxckfpe.ARITH_4_TAC;psort_4] THEN TRY (MP_TAC sqrt8_flyspeck (* 1 *) THEN REAL_ARITH_TAC); TYPIFY `CARD s = 1` ENOUGH_TO_SHOW_TAC; BY(ARITH_TAC); MATCH_MP_TAC Misc_defs_and_lemmas.CARD_SING; REWRITE_TAC[SING]; TYPIFY `0` EXISTS_TAC; EXPAND_TAC "s";
REWRITE_TAC[EXTENSION;IN_ELIM_THM;IN_INSERT;NOT_IN_EMPTY]; REWRITE_TAC[arith `i < 4 <=> i=0 \/ i=1 \/ i=2 \/ i=3`]; GEN_TAC; ASM_CASES_TAC `x = 0`; ASM_REWRITE_TAC[Terminal.FUNLIST_EXPLICIT;Uxckfpe.ARITH_4_TAC;psort_4]; BY(MP_TAC sqrt8_flyspeck (* 1 *) THEN REAL_ARITH_TAC); ASM_REWRITE_TAC[]; REWRITE_TAC[TAUT `~(a /\ b) <=> (a ==> ~b)`]; BY(STRIP_TAC THEN ASM_REWRITE_TAC[Terminal.FUNLIST_EXPLICIT;Uxckfpe.ARITH_4_TAC;psort_4] THEN TRY (MP_TAC sqrt8_flyspeck (* 1 *) THEN REAL_ARITH_TAC)) ]);; (* }}} *)
let is_scs_4M7 = 
prove_by_refinement( `is_scs_v39 scs_4M7`,
(* {{{ proof *) [ REWRITE_TAC[Appendix.scs_4M7]; REWRITE_TAC[Appendix.mk_unadorned_v39]; MATCH_MP_TAC is_scs_funlist_basic; REWRITE_TAC[Appendix.d_tame;Sphere.cstab;Sphere.h0;Terminal.I_LT_J_LT_4_EXPLICIT]; TYPED_ABBREV_TAC `s = {i | i < 4 /\ (&2 * #1.26 < funlist_v39 [(0,1), #3.01; (1,2), #3.01; (0,2),&6; (1,3),&6; (1,3),&6] (&2 * #1.26) 4 i (SUC i) \/ &2 < funlist_v39 [(0,1),&2 * #1.26; (1,2),&2 * #1.26; (0,2), #3.01; (1,3), #3.01] (&2) 4 i (SUC i))}`; REWRITE_TAC[arith `i < 4 <=> i=0 \/ i=1 \/ i=2 \/ i=3`]; NUM_REDUCE_TAC; REPEAT CONJ_TAC THEN REPEAT STRIP_TAC THEN ASM_REWRITE_TAC[Terminal.FUNLIST_EXPLICIT;Uxckfpe.ARITH_4_TAC;psort_4] THEN TRY (REAL_ARITH_TAC); TYPIFY `s = {0,1}` ENOUGH_TO_SHOW_TAC; DISCH_THEN SUBST1_TAC; BY(MESON_TAC[Geomdetail.CARD2;arith `x <= 2 ==> x + 4 <= 6`]); EXPAND_TAC "s";
REWRITE_TAC[EXTENSION;IN_ELIM_THM;IN_INSERT;NOT_IN_EMPTY]; REWRITE_TAC[arith `i < 4 <=> i=0 \/ i=1 \/ i=2 \/ i=3`]; GEN_TAC; ASM_CASES_TAC `x = 0`; ASM_REWRITE_TAC[Terminal.FUNLIST_EXPLICIT;Uxckfpe.ARITH_4_TAC;psort_4]; BY( REAL_ARITH_TAC); ASM_CASES_TAC `x = 1`; ASM_REWRITE_TAC[Terminal.FUNLIST_EXPLICIT;Uxckfpe.ARITH_4_TAC;psort_4]; BY( REAL_ARITH_TAC); ASM_REWRITE_TAC[]; REWRITE_TAC[TAUT `~(a /\ b) <=> (a ==> ~b)`]; BY(STRIP_TAC THEN ASM_REWRITE_TAC[Terminal.FUNLIST_EXPLICIT;Uxckfpe.ARITH_4_TAC;psort_4] THEN TRY (REAL_ARITH_TAC)) ]);; (* }}} *)
let is_scs_4M8 = 
prove_by_refinement( `is_scs_v39 scs_4M8`,
(* {{{ proof *) [ REWRITE_TAC[Appendix.scs_4M8]; REWRITE_TAC[Appendix.mk_unadorned_v39]; MATCH_MP_TAC is_scs_funlist_basic; REWRITE_TAC[Appendix.d_tame;Sphere.cstab;Sphere.h0;Terminal.I_LT_J_LT_4_EXPLICIT]; TYPED_ABBREV_TAC `s = {i | i < 4 /\ (&2 * #1.26 < funlist_v39 [(0,1), #3.01; (2,3), #3.01; (0,2),&6; (1,3),&6; (1,3),&6] (&2 * #1.26) 4 i (SUC i) \/ &2 < funlist_v39 [(0,1),&2 * #1.26; (2,3),&2 * #1.26; (0,2), #3.01; (1,3), #3.01] (&2) 4 i (SUC i))} `; REWRITE_TAC[arith `i < 4 <=> i=0 \/ i=1 \/ i=2 \/ i=3`]; NUM_REDUCE_TAC; REPEAT CONJ_TAC THEN REPEAT STRIP_TAC THEN ASM_REWRITE_TAC[Terminal.FUNLIST_EXPLICIT;Uxckfpe.ARITH_4_TAC;psort_4] THEN TRY (REAL_ARITH_TAC); TYPIFY `s = {0,2}` ENOUGH_TO_SHOW_TAC; DISCH_THEN SUBST1_TAC; BY(MESON_TAC[Geomdetail.CARD2;arith `x <= 2 ==> x + 4 <= 6`]); EXPAND_TAC "s";
REWRITE_TAC[EXTENSION;IN_ELIM_THM;IN_INSERT;NOT_IN_EMPTY]; REWRITE_TAC[arith `i < 4 <=> i=0 \/ i=1 \/ i=2 \/ i=3`]; GEN_TAC; ASM_CASES_TAC `x = 0`; ASM_REWRITE_TAC[Terminal.FUNLIST_EXPLICIT;Uxckfpe.ARITH_4_TAC;psort_4]; BY( REAL_ARITH_TAC); ASM_CASES_TAC `x = 2`; ASM_REWRITE_TAC[Terminal.FUNLIST_EXPLICIT;Uxckfpe.ARITH_4_TAC;psort_4]; BY( REAL_ARITH_TAC); ASM_REWRITE_TAC[]; REWRITE_TAC[TAUT `~(a /\ b) <=> (a ==> ~b)`]; BY(STRIP_TAC THEN ASM_REWRITE_TAC[Terminal.FUNLIST_EXPLICIT;Uxckfpe.ARITH_4_TAC;psort_4] THEN TRY (REAL_ARITH_TAC)) ]);; (* }}} *)
let is_scs_examples = 
prove_by_refinement( `is_scs_v39 scs_6I1 /\ is_scs_v39 scs_5I1 /\ is_scs_v39 scs_5I2 /\ is_scs_v39 scs_5I3 /\ is_scs_v39 scs_4I1 /\ is_scs_v39 scs_4I2 /\ is_scs_v39 scs_4I3 /\ is_scs_v39 scs_3I1 /\ is_scs_v39 scs_6T1 /\ is_scs_v39 scs_5T1 /\ is_scs_v39 scs_4T1 /\ is_scs_v39 scs_4T2 /\ is_scs_v39 scs_4T3 /\ is_scs_v39 scs_4T4 /\ is_scs_v39 scs_4T5 /\ is_scs_v39 scs_3T1 /\ is_scs_v39 scs_3T2 /\ is_scs_v39 scs_3T3 /\ is_scs_v39 scs_3T4 /\ is_scs_v39 scs_3T5 /\ is_scs_v39 scs_3T6' /\ is_scs_v39 scs_3T7 /\ is_scs_v39 scs_6M1 /\ is_scs_v39 scs_5M1 /\ is_scs_v39 scs_5M2 /\ is_scs_v39 scs_4M1 /\ is_scs_v39 scs_4M2 /\ is_scs_v39 scs_4M3' /\ is_scs_v39 scs_4M4' /\ is_scs_v39 scs_4M5' /\ is_scs_v39 scs_4M6' /\ is_scs_v39 scs_4M7 /\ is_scs_v39 scs_4M8 /\ is_scs_v39 scs_3M1 `,
(* }}} *) let scs_example_list = [Appendix.scs_6I1;Appendix.scs_5I1;Appendix.scs_5I2;Appendix.scs_5I3;Appendix.scs_4I1;Appendix.scs_4I2;Appendix.scs_4I3;Appendix.scs_3I1; Appendix.scs_6T1;Appendix.scs_5T1;Appendix.scs_4T1;Appendix.scs_4T2;Appendix.scs_4T3;Appendix.scs_4T4;Appendix.scs_4T5;Appendix.scs_3T1;Appendix.scs_3T2;Appendix.scs_3T3;Appendix.scs_3T4;Appendix.scs_3T5;Appendix.scs_3T6;Appendix.scs_3T7;Appendix.scs_6M1;Appendix.scs_5M1;Appendix.scs_5M2;Appendix.scs_4M1;Appendix.scs_4M2;Appendix.scs_4M3;Appendix.scs_4M4;Appendix.scs_4M5;Appendix.scs_4M6;Appendix.scs_4M7;Appendix.scs_4M8;Appendix.scs_3M1];;
let unadorned_examples = 
prove_by_refinement( `unadorned_v39 scs_6I1 /\ unadorned_v39 scs_5I1 /\ unadorned_v39 scs_5I2 /\ unadorned_v39 scs_5I3 /\ unadorned_v39 scs_4I1 /\ unadorned_v39 scs_4I2 /\ unadorned_v39 scs_4I3 /\ unadorned_v39 scs_3I1 /\ unadorned_v39 scs_6T1 /\ unadorned_v39 scs_5T1 /\ unadorned_v39 scs_4T1 /\ unadorned_v39 scs_4T2 /\ unadorned_v39 scs_4T3 /\ unadorned_v39 scs_4T4 /\ unadorned_v39 scs_4T5 /\ unadorned_v39 scs_3T1 /\ unadorned_v39 scs_3T2 /\ unadorned_v39 scs_3T3 /\ unadorned_v39 scs_3T4 /\ unadorned_v39 scs_3T5 /\ unadorned_v39 scs_3T6' /\ unadorned_v39 scs_3T7 /\ unadorned_v39 scs_6M1 /\ unadorned_v39 scs_5M1 /\ unadorned_v39 scs_5M2 /\ unadorned_v39 scs_4M1 /\ unadorned_v39 scs_4M2 /\ unadorned_v39 scs_4M3' /\ unadorned_v39 scs_4M4' /\ unadorned_v39 scs_4M5' /\ unadorned_v39 scs_4M6' /\ unadorned_v39 scs_4M7 /\ unadorned_v39 scs_4M8 /\ unadorned_v39 scs_3M1 `,
(* {{{ proof *) [ REWRITE_TAC scs_example_list; BY(REWRITE_TAC[scs_mk_unadorned_unadorned]) ]);;
(* }}} *)
let basic_examples = 
prove_by_refinement( `scs_basic_v39 scs_6I1 /\ scs_basic_v39 scs_5I1 /\ scs_basic_v39 scs_5I2 /\ scs_basic_v39 scs_5I3 /\ scs_basic_v39 scs_4I1 /\ scs_basic_v39 scs_4I2 /\ scs_basic_v39 scs_4I3 /\ scs_basic_v39 scs_3I1 /\ scs_basic_v39 scs_6T1 /\ scs_basic_v39 scs_5T1 /\ scs_basic_v39 scs_4T1 /\ scs_basic_v39 scs_4T2 /\ scs_basic_v39 scs_4T3 /\ scs_basic_v39 scs_4T4 /\ scs_basic_v39 scs_4T5 /\ scs_basic_v39 scs_3T1 /\ scs_basic_v39 scs_3T2 /\ scs_basic_v39 scs_3T3 /\ scs_basic_v39 scs_3T4 /\ scs_basic_v39 scs_3T5 /\ scs_basic_v39 scs_3T6' /\ scs_basic_v39 scs_3T7 /\ scs_basic_v39 scs_6M1 /\ scs_basic_v39 scs_5M1 /\ scs_basic_v39 scs_5M2 /\ scs_basic_v39 scs_4M1 /\ scs_basic_v39 scs_4M2 /\ scs_basic_v39 scs_4M3' /\ scs_basic_v39 scs_4M4' /\ scs_basic_v39 scs_4M5' /\ scs_basic_v39 scs_4M6' /\ scs_basic_v39 scs_4M7 /\ scs_basic_v39 scs_4M8 /\ scs_basic_v39 scs_3M1 `,
(* {{{ proof *) [ REWRITE_TAC[Appendix.scs_basic]; REWRITE_TAC[is_scs_examples;unadorned_examples]; REWRITE_TAC scs_example_list; BY(REWRITE_TAC[Terminal.scs_unadorned_explicit]) ]);;
(* }}} *)
let scs_arrow_sing_empty = 
prove_by_refinement( `!s. scs_arrow_v39 {s} {} <=> (MMs_v39 s = {})`,
(* {{{ proof *) [ REWRITE_TAC[Appendix.scs_arrow_v39;NOT_IN_EMPTY;IN_SING]; BY(MESON_TAC[]) ]);;
(* }}} *)
let pos_imp_scs_arrow_empty = 
prove_by_refinement( `!s. (!vv. BBs_v39 s vv ==> &0 <= taustar_v39 s vv) ==> scs_arrow_v39 {s} {}`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; REWRITE_TAC[scs_arrow_sing_empty;EXTENSION;NOT_IN_EMPTY]; REWRITE_TAC[IN;Appendix.MMs_v39;Appendix.BBprime2_v39;Appendix.BBprime_v39]; REPEAT WEAKER_STRIP_TAC; BY(ASM_MESON_TAC[arith `x < &0 ==> ~(&0 <= x)`]) ]);;
(* }}} *) let arrow_rewrite_list = map (UNDISCH o (REWRITE_RULE ((map GSYM scs_example_list) @ [LET_THM]))) [Terminal.empty_3T1;Terminal.empty_3T2;Terminal.empty_3T3;Terminal.empty_3T4; Terminal.empty_3T5;Terminal.empty_3T6;Terminal.empty_3T6;Terminal.empty_3T7; Terminal.empty_4T1;Terminal.empty_4T2;Terminal.empty_4T3;Terminal.empty_4T4; Terminal.empty_4T5;empty_5T1;empty_6T1];;
let OCBICBY = 
prove_by_refinement( `main_nonlinear_terminal_v11 ==> scs_arrow_v39 {scs_6T1} {} /\ scs_arrow_v39 {scs_5T1} {} /\ scs_arrow_v39 {scs_4T1} {} /\ scs_arrow_v39 {scs_4T2} {} /\ scs_arrow_v39 {scs_4T3} {} /\ scs_arrow_v39 {scs_4T4} {} /\ scs_arrow_v39 {scs_4T5} {} /\ scs_arrow_v39 {scs_3T1} {} /\ scs_arrow_v39 {scs_3T2} {} /\ scs_arrow_v39 {scs_3T3} {} /\ scs_arrow_v39 {scs_3T4} {} /\ scs_arrow_v39 {scs_3T5} {} /\ scs_arrow_v39 {scs_3T6' } {} /\ scs_arrow_v39 {scs_3T7} {} `,
(* {{{ proof *) [ DISCH_TAC; REPEAT (GMATCH_SIMP_TAC pos_imp_scs_arrow_empty); BY(REWRITE_TAC arrow_rewrite_list) ]);;
(* }}} *) end;;