(* ========================================================================== *)
(* FLYSPECK - BOOK FORMALIZATION                                              *)
(* Section: Appendix, Main Estimate, check_completeness                       *)
(* Chapter: Local Fan                                                         *)
(* Lemma: CUXVZOZ                                                             *)
(* Author: Thomas Hales                                                       *)
(* Date: 2013-07-22                                                           *)
(* ========================================================================== *)



module Cuxvzoz = struct

  open Hales_tactic;;

let LET_THM = CONJ LET_DEF LET_END_DEF;;

let VV_SUC_EQ_IVS_RHO_NODE_PRIME = 
prove_by_refinement( `!V E FF s vv u k p1. scs_k_v39 s = k /\ vv p1 = u /\ IMAGE vv (:num) = V /\ IMAGE (\i. {vv i, vv (SUC i)}) (:num) = E /\ IMAGE (\i. vv i,vv (SUC i)) (:num) = FF /\ is_scs_v39 s /\ ~(k <= 3) /\ BBs_v39 s vv ==> (ivs_rho_node1 FF u = vv (p1 + (k-1)))`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; INTRO_TAC Appendix.BBs_v39 [`s`;`vv`]; ASM_REWRITE_TAC[LET_DEF;LET_END_DEF;Terminal.IMAGE_SUBSET_IN;IN_UNIV]; REPEAT WEAKER_STRIP_TAC; TYPIFY `local_fan (V,E,FF)` (C SUBGOAL_THEN ASSUME_TAC); MATCH_MP_TAC Local_lemmas.CVX_LO_IMP_LO; BY(ASM_REWRITE_TAC[]); TYPIFY `!i. vv i IN V` (C SUBGOAL_THEN ASSUME_TAC); REPEAT WEAKER_STRIP_TAC; EXPAND_TAC "V";
REWRITE_TAC[IN_IMAGE;IN_UNIV]; BY(MESON_TAC[]); TYPIFY `ivs_rho_node1 FF u IN V` (C SUBGOAL_THEN ASSUME_TAC); MATCH_MP_TAC Local_lemmas1.LOCAL_FAN_IVS_IN_V; BY(ASM_MESON_TAC[]); TYPIFY `rho_node1 FF (ivs_rho_node1 FF u) = rho_node1 FF (vv (p1 + k - 1))` ENOUGH_TO_SHOW_TAC; BY(ASM_MESON_TAC[Polar_fan.RHO_NODE1_INJECTIVE]); GMATCH_SIMP_TAC Local_lemmas1.LOCAL_FAN_RHO_NODE_IVS; CONJ_TAC; BY(ASM_MESON_TAC[]); INTRO_TAC (GEN_ALL Qknvmlb.VV_SUC_EQ_RHO_NODE_PRIME) [`V`;`E`;`k`;`s`;`FF`;`vv (p1+(k-1))`;`vv`;`p1 + (k-1)`]; ASM_REWRITE_TAC[]; DISCH_THEN (C INTRO_TAC [`1`]); REWRITE_TAC[ITER_1]; DISCH_THEN SUBST1_TAC; ASM_SIMP_TAC[arith `~(k <= 3) ==> 1 + p1 + k - 1 = p1 + k`]; BY(ASM_MESON_TAC[Oxl_def.periodic]) ]);; (* }}} *)
let PQCSXWG1_SYM = 
prove_by_refinement( `!v0 v1 v2 v3 x1 x2 x3 x4 x5 x6. &0 < x1 /\ &0 < x2 /\ &0 < x3 /\ &0 < x4 /\ &0 < x5 /\ &0 < x6 /\ ~collinear {v0, v1, v2} /\ x1 = dist (v1,v0) pow 2 /\ x2 = dist (v2,v0) pow 2 /\ x6 = dist (v1,v2) pow 2 /\ &0 < delta_x x1 x2 x3 x4 x5 x6 /\ v3 = mk_simplex1 v0 v2 v1 x2 x1 x3 x5 x4 x6 ==> x3 = dist (v3,v0) pow 2 /\ x5 = dist (v3,v1) pow 2 /\ x4 = dist (v3,v2) pow 2 /\ (v2 - v0) dot ((v1 - v0) cross (v3 - v0)) > &0`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; INTRO_TAC Pqcsxwg.PQCSXWG1 [`v0`;`v2`;`v1`;`v3`;`x2`;`x1`;`x3`;`x5`;`x4`;`x6`]; ASM_TAC THEN REWRITE_TAC[DIST_SYM] THEN REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM MP_TAC; RULE_ASSUM_TAC(ONCE_REWRITE_RULE[EQ_SYM_EQ]); ASM_REWRITE_TAC[]; ANTS_TAC; CONJ_TAC; FIRST_X_ASSUM_ST `collinear` MP_TAC; MATCH_MP_TAC (TAUT `(a = b) ==> (a ==> b)`); REPEAT AP_TERM_TAC; BY(SET_TAC[]); FIRST_X_ASSUM_ST `delta_x` MP_TAC; BY(MESON_TAC[Merge_ineq.delta_x_sym]); BY(MESON_TAC[]) ]);;
(* }}} *)
let homog_2x2 = 
prove_by_refinement( `!a b c d x y. ~(a*d - b*c = &0) /\ a * x + b * y = &0 /\ c * x + d * y = &0 ==> (x = &0 /\ y = &0)`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; TYPIFY `d * (a * x + b * y) - b* (c * x + d*y) = &0 /\ a * (c * x + d *y) - c * (a * x + b* y) = &0` (C SUBGOAL_THEN MP_TAC); ASM_REWRITE_TAC[]; BY(REAL_ARITH_TAC); TYPIFY_GOAL_THEN `d * (a * x + b * y) - b * (c * x + d * y) = (a*d-b*c)*x /\ a * (c * x + d *y) - c * (a * x + b* y) = (a*d-b*c)* y` (unlist REWRITE_TAC); BY(REAL_ARITH_TAC); BY(ASM_REWRITE_TAC[REAL_ENTIRE]) ]);;
(* }}} *)
let simplex_unique = 
prove_by_refinement( `!v0 v1 v2 v3 v3'. ~collinear {v0,v1,v2} /\ dist(v0,v3) = dist(v0,v3') /\ dist(v1,v3) = dist(v1,v3') /\ dist(v2,v3) = dist(v2,v3') /\ re_eqvl ((v3 - v0) dot ((v1 - v0) cross (v2 - v0))) ((v3' - v0) dot ((v1 - v0) cross (v2 - v0))) ==> (v3 = v3')`,
(* {{{ proof *) [ GEOM_ORIGIN_TAC `v0:real^3` THEN REPEAT GEN_TAC; REWRITE_TAC[VECTOR_SUB_RZERO]; REPEAT WEAKER_STRIP_TAC; INTRO_TAC (GEN_ALL Local_lemmas.NOT_COLL_IMP_COPL) [`v1`;`v2`]; ASM_REWRITE_TAC[]; DISCH_TAC; INTRO_TAC Trigonometry2.NONCOPLANAR_3_BASIS [`v1`;`v2`;`v1 cross v2`;`(vec 0):real^3`;`v3`]; INTRO_TAC Trigonometry2.NONCOPLANAR_3_BASIS [`v1`;`v2`;`v1 cross v2`;`(vec 0):real^3`;`v3'`]; ASM_REWRITE_TAC[VECTOR_SUB_RZERO]; REPEAT WEAKER_STRIP_TAC; TYPIFY `~(v1 cross v2 = vec 0)` (C SUBGOAL_THEN ASSUME_TAC); BY(ASM_REWRITE_TAC[CROSS_EQ_0]); TYPIFY `~((v1 cross v2) dot (v1 cross v2) = &0)` (C SUBGOAL_THEN ASSUME_TAC); BY(ASM_REWRITE_TAC[DOT_EQ_0]); TYPIFY `!a1 a2 a3. (a1 % v1 + a2 % v2 + a3 % (v1 cross v2)) dot (v1 cross v2) = a3 * ((v1 cross v2) dot (v1 cross v2))` (C SUBGOAL_THEN ASSUME_TAC); REWRITE_TAC[DOT_LADD;DOT_LMUL;DOT_CROSS_SELF]; BY(REAL_ARITH_TAC); FIRST_X_ASSUM_ST `re_eqvl` MP_TAC; ASM_REWRITE_TAC[Trigonometry2.re_eqvl;REAL_ENTIRE;arith `t3' * u = t * t3 * u <=> (t3' - t * t3) * u = &0`;arith `t3' - t *t3 = &0 <=> t3' = t * t3`]; REPEAT WEAKER_STRIP_TAC; PROOF_BY_CONTR_TAC; TYPIFY `t1' = t1 /\ t2' = t2` ENOUGH_TO_SHOW_TAC; DISCH_TAC; ASM_REWRITE_TAC[]; FIRST_X_ASSUM (RULE_ASSUM_TAC o (unlist REWRITE_RULE)); TYPIFY `norm v3 pow 2 = norm v3' pow 2` (C SUBGOAL_THEN MP_TAC); BY(ASM_MESON_TAC[DIST_0]); ASM_REWRITE_TAC[]; REWRITE_TAC[arith `(a:real^3) + b + c = (a + b) + c`]; TYPED_ABBREV_TAC `a = t1 % v1 + t2 % v2`; REPEAT (GMATCH_SIMP_TAC NORM_ADD_PYTHAGOREAN ); EXPAND_TAC "a";
REWRITE_TAC[CONJ_ASSOC]; CONJ_TAC; BY(REWRITE_TAC[orthogonal] THEN VEC3_TAC); REWRITE_TAC[arith `a +b = a + c <=> b = c`]; REWRITE_TAC[NORM_MUL;arith `(a * b) pow 2 = a pow 2 * b pow 2`;arith `abs t pow 2 = t pow 2`]; REWRITE_TAC[NORM_POW_2]; ONCE_REWRITE_TAC[EQ_SYM_EQ]; ASM_REWRITE_TAC[REAL_ENTIRE;arith `t3' * u = (t * t3) * u <=> (t3' - t * t3) * u = &0`;arith `t3' - t *t3 = &0 <=> t3' = t * t3`]; REWRITE_TAC[REAL_ENTIRE;arith `a = b * a <=> (b - &1) * (a) = &0`;arith `a - &1 = &0 <=> a = &1`;ABS_SQUARE_EQ_1;Trigonometry2.POW2_EQ_0]; GMATCH_SIMP_TAC (arith `&0 < t ==> (abs t = &1 <=> t = &1)`); ASM_REWRITE_TAC[]; DISCH_TAC; TYPIFY `t3' = t3` (C SUBGOAL_THEN ASSUME_TAC); FIRST_X_ASSUM DISJ_CASES_TAC; ASM_REWRITE_TAC[]; BY(REAL_ARITH_TAC); ASM_REWRITE_TAC[]; BY(REAL_ARITH_TAC); BY(ASM_MESON_TAC[]); COMMENT "down to t1 and t2"; TYPED_ABBREV_TAC `x3 = dist(v3,vec 0) pow 2`; TYPED_ABBREV_TAC `x5 = dist(v3,v1) pow 2`; TYPED_ABBREV_TAC ` x4 = dist(v3,v2) pow 2`; TYPIFY `!a1 a2 a3. (let u = a1 % v1 + a2 % v2 + a3 % (v1 cross v2) in (dist(vec 0,v3) = dist(vec 0,u) /\ dist(v1,v3) = dist(v1,u) /\ dist(v2,v3) = dist(v2,u) ==> ((v1 dot v1) * a1 + (v1 dot v2) * a2 = ((v1 dot v1) + x3 - x5) / &2 /\ ((v1 dot v2) * a1 + (v2 dot v2) * a2 = ((v2 dot v2) + x3 - x4) / &2))))` ENOUGH_TO_SHOW_TAC; DISCH_TAC; FIRST_ASSUM (C INTRO_TAC [`t1`;`t2`;`t3`]); FIRST_X_ASSUM (C INTRO_TAC [`t1'`;`t2'`;`t3'`]); REWRITE_TAC[LET_DEF;LET_END_DEF]; ANTS_TAC; BY(ASM_MESON_TAC[]); DISCH_TAC; ANTS_TAC; BY(ASM_MESON_TAC[]); DISCH_TAC; TYPIFY `(v1 dot v1) * (t1-t1') + (v1 dot v2) * (t2-t2') = &0 /\ (v1 dot v2) * (t1-t1') + (v2 dot v2) * (t2-t2') = &0` (C SUBGOAL_THEN ASSUME_TAC); BY(REPLICATE_TAC 2 (FIRST_X_ASSUM MP_TAC) THEN REAL_ARITH_TAC); ONCE_REWRITE_TAC[arith `a = b <=> b - a = &0`]; MATCH_MP_TAC homog_2x2; GEXISTL_TAC [ `(v1 dot v1)`;`(v1 dot v2)`;`(v1 dot v2)`;`(v2 dot v2)`]; ASM_REWRITE_TAC[]; TYPIFY `(v1 dot v1) * (v2 dot v2) - (v1 dot v2) * (v1 dot v2) = (v1 cross v2) dot (v1 cross v2)` (C SUBGOAL_THEN ASSUME_TAC); ONCE_REWRITE_TAC[CROSS_TRIPLE]; BY(VEC3_TAC); BY(ASM_REWRITE_TAC[]); REWRITE_TAC[LET_DEF;LET_END_DEF]; REPEAT WEAKER_STRIP_TAC; MAP_EVERY EXPAND_TAC ["x3";"x4";"x5"]; REPLICATE_TAC 3 (FIRST_X_ASSUM MP_TAC) THEN REWRITE_TAC[DIST_SYM] THEN REPEAT (FIRST_X_ASSUM_ST `%` kill) THEN REPEAT (FIRST_X_ASSUM_ST `dist` kill) THEN REPEAT WEAKER_STRIP_TAC THEN ASM_REWRITE_TAC[]; ONCE_REWRITE_TAC[DIST_SYM]; REWRITE_TAC[dist;VECTOR_SUB_RZERO]; REWRITE_TAC[VECTOR_ARITH `(a + x % b + c) - b:real^N = a + (x - &1) % b + c`; VECTOR_ARITH `(x % a + b + c) - a:real^N = (x - &1) % a + b + c`]; SUBGOAL_THEN `!a b c. norm(a % v1 + b % v2 + c % (v1 cross v2)) pow 2 = norm(a % v1 + b % v2) pow 2 + norm(c % (v1 cross v2)) pow 2` (unlist REWRITE_TAC); REPEAT GEN_TAC THEN REWRITE_TAC[arith `(a:real^3) + b + c = (a + b) + c`]; TYPED_ABBREV_TAC `u = a % v1 + b % v2`; REPEAT (GMATCH_SIMP_TAC NORM_ADD_PYTHAGOREAN ); EXPAND_TAC "u"; BY(REWRITE_TAC[orthogonal] THEN VEC3_TAC); REWRITE_TAC[GSYM DOT_SQUARE_NORM;DOT_LADD;DOT_RADD;DOT_LMUL;DOT_RMUL]; REWRITE_TAC[DOT_SYM]; BY(REAL_ARITH_TAC) ]);; (* }}} *)
let re_eqvl_pos_pos = 
prove_by_refinement( `!a b. &0 < a /\ &0 < b ==> re_eqvl a b`,
(* {{{ proof *) [ REWRITE_TAC[Trigonometry2.re_eqvl]; REPEAT WEAKER_STRIP_TAC; TYPIFY `a/b` EXISTS_TAC; GMATCH_SIMP_TAC REAL_LT_DIV; ASM_REWRITE_TAC[]; Calc_derivative.CALC_ID_TAC; BY(ASM_TAC THEN REAL_ARITH_TAC) ]);;
(* }}} *)
let mk_simplex_uniq = 
prove_by_refinement( `!v0 v1 v2 v3. ~coplanar {v0,v1,v2,v3} /\ (v1 - v0) dot ((v2 - v0) cross (v3 - v0)) > &0 ==> mk_simplex1 v0 v1 v2 (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) = v3`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; MATCH_MP_TAC simplex_unique; GEXISTL_TAC [`v0`;`v1`;`v2`]; TYPED_ABBREV_TAC `v3' = mk_simplex1 v0 v1 v2 (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)`; INTRO_TAC Pqcsxwg.PQCSXWG1 [`v0`;`v1`;`v2`;`v3'`;`(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)`]; ASM_REWRITE_TAC[DIST_SYM]; REWRITE_TAC[GSYM Trigonometry2.NOT_ZERO_EQ_POW2_LT]; REWRITE_TAC[DIST_EQ_0]; TYPIFY `~collinear {v0,v1,v2}` (C SUBGOAL_THEN ASSUME_TAC); MATCH_MP_TAC NOT_COPLANAR_NOT_COLLINEAR; BY(ASM_MESON_TAC[]); TYPIFY_GOAL_THEN `~(v0 = v1) /\ ~(v0 = v2) /\ ~(v0 = v3) /\ ~(v2 = v3) /\ ~(v1 = v3) /\ ~(v1 = v2)` (unlist REWRITE_TAC); BY(ASM_MESON_TAC[Planarity.notcoplanar_disjoint]); ASM_REWRITE_TAC[]; ANTS_TAC; REWRITE_TAC[GSYM Sphere.delta_y;arith `x pow 2 = x*x`]; BY(ASM_MESON_TAC[Oxlzlez.coplanar_delta_y]); REPEAT (GMATCH_SIMP_TAC (GSYM Collect_geom.EQ_POW2_COND)); REWRITE_TAC[DIST_POS_LE]; REPEAT WEAKER_STRIP_TAC; ASM_REWRITE_TAC[]; MATCH_MP_TAC re_eqvl_pos_pos; REPEAT (FIRST_X_ASSUM_ST `cross` MP_TAC); MATCH_MP_TAC (arith `a = b /\ c = d ==> (a > &0 ==> c > &0 ==> &0 < d /\ &0 < b)`); BY(VEC3_TAC) ]);;
(* }}} *)
let continuous_nbd_pos = 
prove_by_refinement( `!f t. f real_continuous atreal t /\ &0 < f t ==> (?e. &0 < e /\ (!t'. abs (t' - t) < e ==> &0 < f t'))`,
(* {{{ proof *) [ REWRITE_TAC[real_continuous_atreal]; REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM (C INTRO_TAC [`f t`]); ASM_REWRITE_TAC[]; REPEAT WEAKER_STRIP_TAC; TYPIFY `d` EXISTS_TAC; ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM (C INTRO_TAC [`t'`]); ASM_REWRITE_TAC[]; BY(REAL_ARITH_TAC) ]);;
(* }}} *)
let epsilon_pair = 
prove_by_refinement( `!e e'. &0 < e /\ &0 < e' ==> (?e''. &0 < e'' /\ (!t. abs t < e'' ==> abs t < e) /\ (!t. abs t < e'' ==> abs t < e'))`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; TYPIFY `if e <= e' then e else e'` EXISTS_TAC; CONJ_TAC; BY(ASM_TAC THEN REAL_ARITH_TAC); BY(CONJ_TAC THEN REPEAT WEAKER_STRIP_TAC THEN ASM_TAC THEN REAL_ARITH_TAC) ]);;
(* }}} *)
let epsilon_triple = 
prove_by_refinement( `!e e' e''. &0 < e /\ &0 < e' /\ &0 < e'' ==> (?e'''. &0 < e''' /\ (!t. abs t < e''' ==> abs t < e) /\ (!t. abs t < e''' ==> abs t < e') /\ (!t. abs t < e''' ==> abs t < e''))`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; INTRO_TAC epsilon_pair [`e`;`e'`] THEN ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; INTRO_TAC epsilon_pair [`e''`;`e'''`] THEN ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; TYPIFY `e''''` EXISTS_TAC; BY(ASM_REWRITE_TAC[] THEN REPEAT CONJ_TAC THEN REPEAT WEAKER_STRIP_TAC THEN (REPEAT (FIRST_X_ASSUM MATCH_MP_TAC)) THEN ASM_REWRITE_TAC[]) ]);;
(* }}} *)
let epsilon_quad = 
prove_by_refinement( `!e e' e'' e'''. &0 < e /\ &0 < e' /\ &0 < e'' /\ &0 < e''' ==> (?e''''. &0 < e'''' /\ (!t. abs t < e'''' ==> abs t < e) /\ (!t. abs t < e'''' ==> abs t < e') /\ (!t. abs t < e'''' ==> abs t < e'') /\ (!t. abs t < e'''' ==> abs t < e'''))`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; INTRO_TAC epsilon_triple [`e`;`e'`;`e''`] THEN ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; INTRO_TAC epsilon_pair [`e'''`;`e''''`] THEN ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; TYPIFY `e'''''` EXISTS_TAC; BY(ASM_REWRITE_TAC[] THEN REPEAT CONJ_TAC THEN REPEAT WEAKER_STRIP_TAC THEN (REPEAT (FIRST_X_ASSUM MATCH_MP_TAC)) THEN ASM_REWRITE_TAC[]) ]);;
(* }}} *)
let deform_simplex_decrease_edge23 = 
prove_by_refinement( `!V g01 g12 v0 v1 v2 e. ( let f = (\ w t. if w = v1 then mk_simplex1 (vec 0) v2 v0 (norm v2 pow 2) (norm v0 pow 2) (norm v1 pow 2) ((dist(v0,v1)+g01 t) pow 2) ((dist(v2,v1) + g12 t) pow 2) (dist(v0,v2) pow 2) else w) in (~coplanar {vec 0,v0,v1,v2} /\ v1 dot (v2 cross v0) > &0 /\ &0 < e /\ g01 real_continuous_on (real_interval (--e,e)) /\ g12 real_continuous_on (real_interval (--e,e)) /\ g01 (&0) = &0 /\ g12 (&0) = &0 ==> (?e'. &0 < e' /\ deformation f V (-- e', e') /\ (!v t. ~(v = v1) ==> f v t = v) /\ (!t. abs t < e' ==> dist(v0,f v1 t) = dist(v0,v1) + g01 t /\ dist(v2,f v1 t) = dist(v2,v1) + g12 t /\ norm(f v1 t) = norm(v1)))))`,
(* {{{ proof *) [ REPEAT GEN_TAC; REPEAT LET_TAC; REWRITE_TAC[Localization.deformation]; REPEAT WEAKER_STRIP_TAC; TYPIFY `{vec 0,v2,v0,v1} = { vec 0,v0,v1,v2} /\ {vec 0, v0, v2, v1} = {vec 0,v0,v1,v2}` (C SUBGOAL_THEN ASSUME_TAC); BY(SET_TAC[]); COMMENT "easy continuity";
TYPIFY `&0 IN real_interval( --e,e)` (C SUBGOAL_THEN ASSUME_TAC); REWRITE_TAC[IN_REAL_INTERVAL]; BY(ASM_SIMP_TAC[arith `&0 < e ==> --e < &0`]); TYPIFY `g01 real_continuous atreal (&0) /\ g12 real_continuous atreal (&0)` (C SUBGOAL_THEN ASSUME_TAC); BY(ASM_MESON_TAC[REAL_CONTINUOUS_ON_EQ_REAL_CONTINUOUS_AT;Ocbicby.REAL_OPEN_REAL_INTERVAL]); TYPIFY `(\t. delta_x (norm v2 pow 2) (norm v0 pow 2) (norm v1 pow 2) ((dist(v0,v1)+g01 t) pow 2) ((dist(v2,v1) + g12 t) pow 2) (dist(v0,v2) pow 2)) real_continuous atreal (&0)` (C SUBGOAL_THEN ASSUME_TAC); REWRITE_TAC[Sphere.delta_x]; BY(REPEAT (ASM_REWRITE_TAC[REAL_CONTINUOUS_CONST] THEN REPEAT CONJ_TAC THEN (MATCH_MP_TAC REAL_CONTINUOUS_ADD ORELSE MATCH_MP_TAC REAL_CONTINUOUS_MUL ORELSE MATCH_MP_TAC REAL_CONTINUOUS_POW ORELSE MATCH_MP_TAC REAL_CONTINUOUS_SUB))); TYPIFY `&0 < delta_x (norm v2 pow 2) (norm v0 pow 2) (norm v1 pow 2) ((dist (v0,v1)) pow 2) ((dist (v2,v1)) pow 2) (dist (v0,v2) pow 2)` (C SUBGOAL_THEN ASSUME_TAC); REWRITE_TAC[GSYM Sphere.delta_y;arith `x pow 2 = x*x`;GSYM DIST_0]; FIRST_X_ASSUM_ST `coplanar` MP_TAC; ONCE_REWRITE_TAC[SET_RULE `{a,b,c,d} = {a,d,b,c}`]; REWRITE_TAC[ Oxlzlez.coplanar_delta_y]; BY(REWRITE_TAC[DIST_SYM]); TYPIFY `?e1. &0 < e1 /\ (!t. abs t < e1 ==> &0 < delta_x (norm v2 pow 2) (norm v0 pow 2) (norm v1 pow 2) ((dist(v0,v1)+g01 t) pow 2) ((dist(v2,v1) + g12 t) pow 2) (dist(v0,v2) pow 2))` (C SUBGOAL_THEN ASSUME_TAC); FIRST_X_ASSUM_ST `real_continuous` MP_TAC; REWRITE_TAC[real_continuous_atreal]; DISCH_THEN (C INTRO_TAC [`delta_x (norm v2 pow 2) (norm v0 pow 2) (norm v1 pow 2) ((dist (v0,v1)) pow 2) ((dist (v2,v1)) pow 2) (dist (v0,v2) pow 2)`]); ASM_REWRITE_TAC[arith `abs(x - &0) = abs x`]; REPEAT WEAKER_STRIP_TAC; TYPIFY `d` EXISTS_TAC; ASM_REWRITE_TAC[]; REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM (C INTRO_TAC [`t`]); ASM_REWRITE_TAC[arith `x + &0 = x`]; BY(REPLICATE_TAC 3 (FIRST_X_ASSUM MP_TAC) THEN REAL_ARITH_TAC); FIRST_X_ASSUM MP_TAC THEN REPEAT WEAKER_STRIP_TAC; TYPIFY `?e2. &0 < e2 /\ (!t. abs t < e2 ==> &0 < (dist (v0,v1) + g01 t) /\ &0 < ((dist (v2,v1) + g12 t) ))` (C SUBGOAL_THEN ASSUME_TAC); TYPIFY `(\t. (dist (v0,v1) + g01 t) ) real_continuous atreal (&0) /\ (\t. ((dist (v2,v1) + g12 t) )) real_continuous atreal (&0)` ENOUGH_TO_SHOW_TAC; REPEAT WEAKER_STRIP_TAC; INTRO_TAC continuous_nbd_pos [`(\t. (dist (v0,v1) + g01 t) )`;`&0`]; INTRO_TAC continuous_nbd_pos [`(\t. (dist (v2,v1) + g12 t) )`;`&0`]; ASM_REWRITE_TAC[]; REWRITE_TAC[arith `x + &0 = x`]; REWRITE_TAC[DIST_POS_LT]; REWRITE_TAC[GSYM DIST_POS_LT]; REWRITE_TAC[GSYM DIST_NZ]; TYPIFY_GOAL_THEN `~(v2 = v1) /\ ~(v0 = v1)` (unlist REWRITE_TAC); BY(ASM_MESON_TAC[Planarity.notcoplanar_disjoint]); REWRITE_TAC[arith `abs (t' - &0) = abs t'`]; REPEAT WEAKER_STRIP_TAC; INTRO_TAC epsilon_pair [`e'`;`e''`] THEN ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; TYPIFY `e'''` EXISTS_TAC; BY(ASM_MESON_TAC[]); BY(CONJ_TAC THEN REPEAT (ASM_REWRITE_TAC[REAL_CONTINUOUS_CONST] THEN REPEAT CONJ_TAC THEN (MATCH_MP_TAC REAL_CONTINUOUS_ADD ORELSE MATCH_MP_TAC REAL_CONTINUOUS_MUL ORELSE MATCH_MP_TAC REAL_CONTINUOUS_POW ORELSE MATCH_MP_TAC REAL_CONTINUOUS_SUB))); FIRST_X_ASSUM MP_TAC THEN REPEAT WEAKER_STRIP_TAC; TYPIFY ` (!t. abs t < e2 ==> &0 < (dist (v0,v1) + g01 t) pow 2 /\ &0 < ((dist (v2,v1) + g12 t) pow 2 ))` (C SUBGOAL_THEN ASSUME_TAC); REPEAT WEAKER_STRIP_TAC; REWRITE_TAC[GSYM Trigonometry2.NOT_ZERO_EQ_POW2_LT]; BY(ASM_SIMP_TAC[arith `&0 < x ==> ~(x = &0)`]); INTRO_TAC epsilon_pair [`e1`;`e2`] THEN ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; COMMENT "distances"; TYPIFY `!t. abs t < e'' ==> norm v1 pow 2 = dist (f v1 t,vec 0) pow 2 /\ (dist (v0,v1) + g01 t) pow 2 = dist (f v1 t,v0) pow 2 /\ (dist (v2,v1) + g12 t) pow 2 = dist (f v1 t,v2) pow 2 /\ v2 dot (v0 cross f v1 t) > &0` (C SUBGOAL_THEN ASSUME_TAC); REPEAT WEAKER_STRIP_TAC; INTRO_TAC PQCSXWG1_SYM [`(vec 0):real^3`;` v0 `;`v2`;`f v1 t`;` (norm v0 pow 2)`;` (norm v2 pow 2)`;`(norm v1 pow 2)`;` ((dist (v2,v1) + g12 t) pow 2)`;` ((dist (v0,v1) + g01 t) pow 2)`;` (dist (v0,v2) pow 2)`]; REWRITE_TAC[VECTOR_SUB_RZERO]; DISCH_THEN MATCH_MP_TAC; ASM_SIMP_TAC[]; REWRITE_TAC[CONJ_ASSOC] THEN CONJ2_TAC; EXPAND_TAC "f"; BY(REWRITE_TAC[]); CONJ2_TAC; FIRST_X_ASSUM_ST `delta_x` (C INTRO_TAC [`t`]); ASM_SIMP_TAC[]; BY(MESON_TAC[Merge_ineq.delta_x_sym]); REWRITE_TAC[DIST_0]; REWRITE_TAC[GSYM Trigonometry2.NOT_ZERO_EQ_POW2_LT]; REWRITE_TAC[GSYM DIST_0]; REWRITE_TAC[DIST_EQ_0]; CONJ_TAC; BY(ASM_MESON_TAC[Planarity.notcoplanar_disjoint]); MATCH_MP_TAC NOT_COPLANAR_NOT_COLLINEAR; TYPIFY `v1` EXISTS_TAC; BY(ASM_REWRITE_TAC[]); COMMENT "continuity"; INTRO_TAC epsilon_pair [`e`;`e''`] THEN ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; TYPIFY `!t. abs t < e''' /\ ~coplanar{vec 0,v0,f v1 t,v2} ==> f v1 continuous atreal t` (C SUBGOAL_THEN ASSUME_TAC); REPEAT WEAKER_STRIP_TAC; TYPIFY `g01 real_continuous atreal t /\ g12 real_continuous atreal t` (C SUBGOAL_THEN ASSUME_TAC); REPEAT (FIRST_X_ASSUM_ST `real_continuous_on` MP_TAC); REPEAT (GMATCH_SIMP_TAC REAL_CONTINUOUS_ON_EQ_REAL_CONTINUOUS_AT); REWRITE_TAC[ Ocbicby.REAL_OPEN_REAL_INTERVAL;IN_REAL_INTERVAL;arith `-- e < t /\ t < e <=> abs t < e`]; BY(ASM_MESON_TAC[]); INTRO_TAC Pqcsxwg.PQCSXWG2_ATREAL [`(\ (t:real). (vec 0):real^3)`;`\ (t:real). v2`;`\ (t:real). v0`;`\ (t:real). (norm v2 pow 2)`;`\ (t:real). (norm v0 pow 2)`;`\ (t:real). (norm v1 pow 2)`;`\ (t:real). ((dist (v0,v1)+ g01 t) pow 2)`;`\ (t:real). ((dist (v2,v1)+ g12 t) pow 2)`;`\ (t:real). (dist (v0,v2) pow 2)`;`t`]; REWRITE_TAC[CONTINUOUS_CONST;REAL_CONTINUOUS_CONST]; EXPAND_TAC "f"; REWRITE_TAC[]; DISCH_THEN MATCH_MP_TAC; ASM_SIMP_TAC[]; REWRITE_TAC[DIST_0;DIST_SYM]; CONJ_TAC; MATCH_MP_TAC NOT_COPLANAR_NOT_COLLINEAR; TYPIFY `v1` EXISTS_TAC; BY(ASM_REWRITE_TAC[]); BY((CONJ_TAC THEN REPEAT (ASM_REWRITE_TAC[REAL_CONTINUOUS_CONST] THEN REPEAT CONJ_TAC THEN (MATCH_MP_TAC REAL_CONTINUOUS_ADD ORELSE MATCH_MP_TAC REAL_CONTINUOUS_MUL ORELSE MATCH_MP_TAC REAL_CONTINUOUS_POW ORELSE MATCH_MP_TAC REAL_CONTINUOUS_SUB)))); COMMENT "coplanarity"; TYPIFY `f v1 (&0) = v1` (C SUBGOAL_THEN ASSUME_TAC); EXPAND_TAC "f"; ASM_REWRITE_TAC[arith `x + &0 = x`]; INTRO_TAC mk_simplex_uniq [`(vec 0):real^3`;`v2`;`v0`;`v1`]; REWRITE_TAC[GSYM DIST_0;DIST_SYM]; DISCH_THEN MATCH_MP_TAC; REWRITE_TAC[VECTOR_SUB_RZERO]; ASM_REWRITE_TAC[]; FIRST_X_ASSUM_ST `cross` kill; FIRST_X_ASSUM_ST `cross` MP_TAC; MATCH_MP_TAC (arith `a = b ==> a > &0 ==> b > &0`); BY(VEC3_TAC); TYPIFY `f v1 continuous atreal (&0)` (C SUBGOAL_THEN ASSUME_TAC); FIRST_X_ASSUM MATCH_MP_TAC; BY(ASM_REWRITE_TAC[arith `abs(&0) = &0`]); INTRO_TAC Zlzthic.NONPLANAR_OPEN [`\ (t:real). (vec 0):real^3`;`\ (t:real). v0`;`\ (t:real). v2`;`f v1`;`&0`]; ASM_REWRITE_TAC[CONTINUOUS_CONST;arith `abs(&0 - t)= abs t`]; REPEAT WEAKER_STRIP_TAC; COMMENT "final kill"; INTRO_TAC epsilon_pair [`e'''`;`e'`] THEN ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; TYPIFY `e''''` EXISTS_TAC; ASM_REWRITE_TAC[IN_REAL_INTERVAL;arith `-- e < t /\ t < e <=> abs t < e`;arith `abs(&0) = &0`;GSYM CONJ_ASSOC]; REWRITE_TAC[CONJ_ASSOC] THEN CONJ2_TAC; REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM_ST `cross` (C INTRO_TAC [`t`]); ANTS_TAC; BY(ASM_SIMP_TAC[]); REPEAT (GMATCH_SIMP_TAC (GSYM Collect_geom.EQ_POW2_COND)); REWRITE_TAC[DIST_POS_LE]; REWRITE_TAC[NORM_POS_LE]; CONJ_TAC; BY(ASM_MESON_TAC[arith `&0 < x ==> &0 <= x`]); CONJ_TAC; BY(ASM_MESON_TAC[arith `&0 < x ==> &0 <= x`]); DISCH_THEN (unlist REWRITE_TAC); BY(MESON_TAC[DIST_SYM;DIST_0]); SUBCONJ2_TAC; REPEAT WEAKER_STRIP_TAC; EXPAND_TAC "f"; BY(ASM_REWRITE_TAC[]); DISCH_TAC; CONJ2_TAC; REPEAT WEAKER_STRIP_TAC; TYPIFY `v = v1` ASM_CASES_TAC; BY(ASM_REWRITE_TAC[]); FIRST_X_ASSUM MATCH_MP_TAC; BY(ASM_REWRITE_TAC[]); REPEAT WEAKER_STRIP_TAC; TYPIFY `v = v1` ASM_CASES_TAC; ASM_REWRITE_TAC[]; FIRST_X_ASSUM MATCH_MP_TAC; ASM_SIMP_TAC[]; ONCE_REWRITE_TAC[SET_RULE `{a,b,c,d} = {a,b,d,c}`]; FIRST_X_ASSUM MATCH_MP_TAC; BY(ASM_SIMP_TAC[]); TYPIFY `f v = (\t. v)` (C SUBGOAL_THEN SUBST1_TAC); REWRITE_TAC[FUN_EQ_THM]; GEN_TAC; FIRST_X_ASSUM MATCH_MP_TAC; BY(ASM_REWRITE_TAC[]); BY(REWRITE_TAC[CONTINUOUS_CONST]) ]);; (* }}} *)
let deform_simplex_edge_exists = 
prove_by_refinement( `!V g01 g12 v0 v1 v2 e. ?f. (~coplanar {vec 0,v0,v1,v2} /\ v1 dot (v2 cross v0) > &0 /\ &0 < e /\ g01 real_continuous_on (real_interval (--e,e)) /\ g12 real_continuous_on (real_interval (--e,e)) /\ g01 (&0) = &0 /\ g12 (&0) = &0 ==> (?e'. &0 < e' /\ deformation f V (-- e', e') /\ (!v t. ~(v = v1) ==> f v t = v) /\ (!t. abs t < e' ==> dist(v0,f v1 t) = dist(v0,v1) + g01 t /\ dist(v2,f v1 t) = dist(v2,v1) + g12 t /\ norm(f v1 t) = norm(v1))))`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; TYPED_ABBREV_TAC `f = (\w t. if w = v1 then mk_simplex1 (vec 0) v2 v0 (norm v2 pow 2) (norm v0 pow 2) (norm v1 pow 2) ((dist (v0,v1) + g01 t) pow 2) ((dist (v2,v1) + g12 t) pow 2) (dist (v0,v2) pow 2) else w)`; TYPIFY `f` EXISTS_TAC; REPEAT WEAKER_STRIP_TAC; INTRO_TAC deform_simplex_decrease_edge23 [`V`;`g01`;`g12`;`v0`;`v1`;`v2`;`e`]; ASM_REWRITE_TAC[]; BY(REWRITE_TAC[LET_DEF;LET_END_DEF]) ]);;
(* }}} *)
let deform_simplex_684_pent = 
prove_by_refinement( `!V g23 v0 v1 v2 v3 e. ( let f1 = (\ w t. if w = v2 then mk_simplex1 (vec 0) v3 v0 (norm v3 pow 2) (norm v0 pow 2) (norm v2 pow 2) ((dist(v0,v2)) pow 2) ((dist(v3,v2) + g23 t) pow 2) (dist(v0,v3) pow 2) else w) in let f = (\ w t. if w = v2 then f1 v2 t else if w = v1 then mk_simplex1 (vec 0) (f1 v2 t) v0 (norm v2 pow 2) (norm v0 pow 2) (norm v1 pow 2) ((dist(v0,v1)) pow 2) ((dist(v2,v1)) pow 2) (dist(v0,v2) pow 2) else w) in (~coplanar {vec 0,v0,v2,v3} /\ ~coplanar {vec 0,v0,v1,v2} /\ v2 dot (v3 cross v0) > &0 /\ v1 dot (v2 cross v0) > &0 /\ &0 < e /\ g23 real_continuous_on (real_interval (--e,e)) /\ g23 (&0) = &0 ==> (?e'. &0 < e' /\ deformation f V (-- e', e') /\ (!v t. ~(v = v1) /\ ~(v = v2) ==> f v t = v) /\ (!t. abs t < e' ==> dist(v0,f v1 t) = dist(v0,v1) /\ dist(f v2 t,f v1 t) = dist(v2,v1) /\ norm(f v1 t) = norm(v1) /\ dist (f v2 t,v0) = dist(v2,v0) /\ dist (f v2 t,v3) = dist(v2,v3)+ g23 t /\ norm(f v2 t) = norm (v2) ))))`,
(* {{{ proof *) [ REPEAT GEN_TAC; REPEAT LET_TAC; REWRITE_TAC[Localization.deformation]; REPEAT WEAKER_STRIP_TAC; COMMENT "preliminaries";
TYPIFY `{vec 0,v3,v0,v2} = { vec 0,v0,v2,v3} /\ {vec 0, v0, v3, v2} = {vec 0,v0,v2,v3}` (C SUBGOAL_THEN ASSUME_TAC); BY(SET_TAC[]); COMMENT "easy continuity"; TYPIFY `&0 IN real_interval( --e,e)` (C SUBGOAL_THEN ASSUME_TAC); REWRITE_TAC[IN_REAL_INTERVAL]; BY(ASM_SIMP_TAC[arith `&0 < e ==> --e < &0`]); TYPIFY `g23 real_continuous atreal (&0)` (C SUBGOAL_THEN ASSUME_TAC); BY(ASM_MESON_TAC[REAL_CONTINUOUS_ON_EQ_REAL_CONTINUOUS_AT;Ocbicby.REAL_OPEN_REAL_INTERVAL]); TYPIFY `(\t. delta_x (norm v3 pow 2) (norm v0 pow 2) (norm v2 pow 2) ((dist(v0,v2)) pow 2) ((dist(v3,v2) + g23 t) pow 2) (dist(v0,v3) pow 2)) real_continuous atreal (&0)` (C SUBGOAL_THEN ASSUME_TAC); REWRITE_TAC[Sphere.delta_x]; BY(REPEAT (ASM_REWRITE_TAC[REAL_CONTINUOUS_CONST] THEN REPEAT CONJ_TAC THEN (MATCH_MP_TAC REAL_CONTINUOUS_ADD ORELSE MATCH_MP_TAC REAL_CONTINUOUS_MUL ORELSE MATCH_MP_TAC REAL_CONTINUOUS_POW ORELSE MATCH_MP_TAC REAL_CONTINUOUS_SUB))); TYPIFY `&0 < delta_x (norm v3 pow 2) (norm v0 pow 2) (norm v2 pow 2) ((dist (v0,v2)) pow 2) ((dist (v3,v2)) pow 2) (dist (v0,v3) pow 2)` (C SUBGOAL_THEN ASSUME_TAC); REWRITE_TAC[GSYM Sphere.delta_y;arith `x pow 2 = x*x`;GSYM DIST_0]; FIRST_X_ASSUM_ST `coplanar` kill; FIRST_X_ASSUM_ST `coplanar` MP_TAC; ONCE_REWRITE_TAC[SET_RULE `{a,b,c,d} = {a,d,b,c}`]; REWRITE_TAC[ Oxlzlez.coplanar_delta_y]; BY(REWRITE_TAC[DIST_SYM]); TYPIFY `&0 < delta_x (norm v2 pow 2) (norm v0 pow 2) (norm v1 pow 2) ((dist (v0,v1)) pow 2) ((dist (v2,v1)) pow 2) (dist (v0,v2) pow 2)` (C SUBGOAL_THEN ASSUME_TAC); REWRITE_TAC[GSYM Sphere.delta_y;arith `x pow 2 = x*x`;GSYM DIST_0]; FIRST_X_ASSUM_ST `coplanar` MP_TAC; ONCE_REWRITE_TAC[SET_RULE `{a,b,c,d} = {a,d,b,c}`]; REWRITE_TAC[ Oxlzlez.coplanar_delta_y]; BY(REWRITE_TAC[DIST_SYM]); TYPIFY `?e1. &0 < e1 /\ (!t. abs t < e1 ==> &0 < delta_x (norm v3 pow 2) (norm v0 pow 2) (norm v2 pow 2) ((dist(v0,v2)) pow 2) ((dist(v3,v2) + g23 t) pow 2) (dist(v0,v3) pow 2))` (C SUBGOAL_THEN ASSUME_TAC); INTRO_TAC continuous_nbd_pos [`(\t. delta_x (norm v3 pow 2) (norm v0 pow 2) (norm v2 pow 2) (dist (v0,v2) pow 2) ((dist (v3,v2) + g23 t) pow 2) (dist (v0,v3) pow 2))`;`&0`]; BY(ASM_REWRITE_TAC[arith `x + &0 = x`;arith `abs (t' - &0) = abs t'`]); FIRST_X_ASSUM MP_TAC THEN REPEAT WEAKER_STRIP_TAC; TYPIFY `?e2. &0 < e2 /\ (!t. abs t < e2 ==> &0 < dist (v3,v2) + g23 t)` (C SUBGOAL_THEN ASSUME_TAC); TYPIFY `(\t. (dist (v3,v2) + g23 t) ) real_continuous atreal (&0)` ENOUGH_TO_SHOW_TAC; REPEAT WEAKER_STRIP_TAC; INTRO_TAC continuous_nbd_pos [`(\t. (dist (v3,v2) + g23 t) )`;`&0`]; ASM_REWRITE_TAC[arith `x + &0 = x`;GSYM DIST_NZ;arith `abs (t' - &0) = abs t'`]; TYPIFY_GOAL_THEN `~(v3 = v2)` (unlist REWRITE_TAC); BY(ASM_MESON_TAC[Planarity.notcoplanar_disjoint]); BY(REPEAT (ASM_REWRITE_TAC[REAL_CONTINUOUS_CONST] THEN REPEAT CONJ_TAC THEN (MATCH_MP_TAC REAL_CONTINUOUS_ADD ORELSE MATCH_MP_TAC REAL_CONTINUOUS_MUL ORELSE MATCH_MP_TAC REAL_CONTINUOUS_POW ORELSE MATCH_MP_TAC REAL_CONTINUOUS_SUB))); FIRST_X_ASSUM MP_TAC THEN REPEAT WEAKER_STRIP_TAC; TYPIFY `!t. abs t < e2 ==> &0 < (dist (v3,v2) + g23 t) pow 2` (C SUBGOAL_THEN ASSUME_TAC); REPEAT WEAKER_STRIP_TAC; REWRITE_TAC[GSYM Trigonometry2.NOT_ZERO_EQ_POW2_LT]; BY(ASM_SIMP_TAC[arith `&0 < x ==> ~(x = &0)`]); INTRO_TAC epsilon_pair [`e1`;`e2`] THEN ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; COMMENT "distances on 023 triangle"; TYPIFY `!t. abs t < e'' ==> norm v2 pow 2 = dist (f v2 t,vec 0) pow 2 /\ (dist (v0,v2)) pow 2 = dist (f v2 t,v0) pow 2 /\ (dist (v3,v2) + g23 t) pow 2 = dist (f v2 t,v3) pow 2 /\ v3 dot (v0 cross f v2 t) > &0` (C SUBGOAL_THEN ASSUME_TAC); REPEAT WEAKER_STRIP_TAC; INTRO_TAC PQCSXWG1_SYM [`(vec 0):real^3`;` v0 `;`v3`;`f v2 t`;` (norm v0 pow 2)`;` (norm v3 pow 2)`;`(norm v2 pow 2)`;` ((dist (v3,v2) + g23 t) pow 2)`;` ((dist (v0,v2) ) pow 2)`;` (dist (v0,v3) pow 2)`]; REWRITE_TAC[VECTOR_SUB_RZERO]; DISCH_THEN MATCH_MP_TAC; ASM_SIMP_TAC[]; REWRITE_TAC[CONJ_ASSOC] THEN CONJ2_TAC; EXPAND_TAC "f"; (REWRITE_TAC[]); EXPAND_TAC "f1"; BY(REWRITE_TAC[]); CONJ2_TAC; FIRST_X_ASSUM_ST `delta_x` (C INTRO_TAC [`t`]); ASM_SIMP_TAC[]; BY(MESON_TAC[Merge_ineq.delta_x_sym]); REWRITE_TAC[DIST_0]; REWRITE_TAC[GSYM Trigonometry2.NOT_ZERO_EQ_POW2_LT]; REWRITE_TAC[GSYM DIST_0]; REWRITE_TAC[DIST_EQ_0]; CONJ_TAC; BY(ASM_MESON_TAC[Planarity.notcoplanar_disjoint]); MATCH_MP_TAC NOT_COPLANAR_NOT_COLLINEAR; TYPIFY `v2` EXISTS_TAC; BY(ASM_REWRITE_TAC[]); COMMENT "continuity at f v2 t"; INTRO_TAC epsilon_pair [`e`;`e''`] THEN ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; TYPIFY `!t. abs t < e''' /\ ~coplanar{vec 0,v0,f v2 t,v3} ==> f v2 continuous atreal t` (C SUBGOAL_THEN ASSUME_TAC); REPEAT WEAKER_STRIP_TAC; TYPIFY `g23 real_continuous atreal t` (C SUBGOAL_THEN ASSUME_TAC); REPEAT (FIRST_X_ASSUM_ST `real_continuous_on` MP_TAC); REPEAT (GMATCH_SIMP_TAC REAL_CONTINUOUS_ON_EQ_REAL_CONTINUOUS_AT); REWRITE_TAC[ Ocbicby.REAL_OPEN_REAL_INTERVAL;IN_REAL_INTERVAL;arith `-- e < t /\ t < e <=> abs t < e`]; DISCH_THEN MATCH_MP_TAC; FIRST_X_ASSUM MATCH_MP_TAC; BY(ASM_REWRITE_TAC[]); INTRO_TAC Pqcsxwg.PQCSXWG2_ATREAL [`(\ (t:real). (vec 0):real^3)`;`\ (t:real). v3`;`\ (t:real). v0`;`\ (t:real). (norm v3 pow 2)`;`\ (t:real). (norm v0 pow 2)`;`\ (t:real). (norm v2 pow 2)`;`\ (t:real). ((dist (v0,v2)) pow 2)`;`\ (t:real). ((dist (v3,v2)+ g23 t) pow 2)`;`\ (t:real). (dist (v0,v3) pow 2)`;`t`]; REWRITE_TAC[CONTINUOUS_CONST;REAL_CONTINUOUS_CONST]; EXPAND_TAC "f"; REWRITE_TAC[]; EXPAND_TAC "f1"; REWRITE_TAC[]; DISCH_THEN MATCH_MP_TAC; ASM_SIMP_TAC[]; REWRITE_TAC[DIST_0;DIST_SYM]; CONJ_TAC; MATCH_MP_TAC NOT_COPLANAR_NOT_COLLINEAR; TYPIFY `v2` EXISTS_TAC; BY(ASM_REWRITE_TAC[]); BY((REPEAT (ASM_REWRITE_TAC[REAL_CONTINUOUS_CONST] THEN REPEAT CONJ_TAC THEN (MATCH_MP_TAC REAL_CONTINUOUS_ADD ORELSE MATCH_MP_TAC REAL_CONTINUOUS_MUL ORELSE MATCH_MP_TAC REAL_CONTINUOUS_POW ORELSE MATCH_MP_TAC REAL_CONTINUOUS_SUB)))); COMMENT "coplanarity"; TYPIFY `f v2 (&0) = v2` (C SUBGOAL_THEN ASSUME_TAC); EXPAND_TAC "f"; EXPAND_TAC "f1"; ASM_REWRITE_TAC[arith `x + &0 = x`]; INTRO_TAC mk_simplex_uniq [`(vec 0):real^3`;`v3`;`v0`;`v2`]; REWRITE_TAC[GSYM DIST_0;DIST_SYM]; DISCH_THEN MATCH_MP_TAC; REWRITE_TAC[VECTOR_SUB_RZERO]; ASM_REWRITE_TAC[]; REPLICATE_TAC 2 (FIRST_X_ASSUM_ST `cross` kill); FIRST_X_ASSUM_ST `cross` MP_TAC; MATCH_MP_TAC (arith `a = b ==> a > &0 ==> b > &0`); BY(VEC3_TAC); TYPIFY `f v2 continuous atreal (&0)` (C SUBGOAL_THEN ASSUME_TAC); FIRST_X_ASSUM MATCH_MP_TAC; BY(ASM_REWRITE_TAC[arith `abs(&0) = &0`]); INTRO_TAC Zlzthic.NONPLANAR_OPEN [`\ (t:real). (vec 0):real^3`;`\ (t:real). v0`;`\ (t:real). v3`;`f v2`;`&0`]; ASM_REWRITE_TAC[CONTINUOUS_CONST;arith `abs(&0 - t)= abs t`]; REPEAT WEAKER_STRIP_TAC; COMMENT "distances on 012 triangle"; TYPIFY `f v2 = f1 v2` (C SUBGOAL_THEN ASSUME_TAC); EXPAND_TAC "f"; BY(REWRITE_TAC[FUN_EQ_THM]); INTRO_TAC epsilon_pair [`e'`;`e'''`] THEN ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; TYPIFY `!t. abs t < e'''' ==> norm v1 pow 2 = dist (f v1 t,vec 0) pow 2 /\ dist (v0,v1) pow 2 = dist (f v1 t,v0) pow 2 /\ dist (v2,v1) pow 2 = dist (f v1 t,f v2 t) pow 2 /\ f v2 t dot (v0 cross f v1 t) > &0` (C SUBGOAL_THEN ASSUME_TAC); REPEAT WEAKER_STRIP_TAC; INTRO_TAC PQCSXWG1_SYM [`(vec 0):real^3`;` v0 `;`f v2 t`;`f v1 t`;` (norm v0 pow 2)`;` (norm v2 pow 2)`;`(norm v1 pow 2)`;` ((dist (v2,v1)) pow 2)`;` ((dist (v0,v1) ) pow 2)`;` (dist (v0,v2) pow 2)`]; REWRITE_TAC[VECTOR_SUB_RZERO]; DISCH_THEN MATCH_MP_TAC; ASM_SIMP_TAC[]; REWRITE_TAC[CONJ_ASSOC] THEN CONJ2_TAC; EXPAND_TAC "f"; (REWRITE_TAC[]); TYPIFY_GOAL_THEN `~(v1 = v2)` (unlist REWRITE_TAC); BY(ASM_MESON_TAC[Planarity.notcoplanar_disjoint]); BY(ASM_SIMP_TAC[]); CONJ2_TAC; TYPIFY `(dist (f1 v2 t,vec 0) pow 2) = norm v2 pow 2 /\ dist (f1 v2 t,v0) pow 2 = dist(v2,v0) pow 2` ENOUGH_TO_SHOW_TAC; DISCH_THEN (unlist REWRITE_TAC); FIRST_X_ASSUM_ST `delta_x` kill; FIRST_X_ASSUM_ST `delta_x` MP_TAC; MATCH_MP_TAC (arith `(a = b) ==> &0 < a ==> &0 < b`); REWRITE_TAC[DIST_SYM]; BY(MESON_TAC[Merge_ineq.delta_x_sym]); FIRST_X_ASSUM_ST `(=)` (SUBST1_TAC o GSYM); BY(REPLICATE_TAC 15 (FIRST_X_ASSUM MP_TAC) THEN MESON_TAC[DIST_SYM]); REWRITE_TAC[DIST_0]; REWRITE_TAC[GSYM Trigonometry2.NOT_ZERO_EQ_POW2_LT]; REWRITE_TAC[GSYM DIST_0;DIST_SYM]; REWRITE_TAC[DIST_EQ_0]; CONJ_TAC; FIRST_X_ASSUM_ST `coplanar` (C INTRO_TAC [`t`]); ASM_SIMP_TAC[]; REPEAT (FIRST_X_ASSUM_ST `coplanar` MP_TAC); BY(MESON_TAC[Planarity.notcoplanar_disjoint]); MATCH_MP_TAC NOT_COPLANAR_NOT_COLLINEAR; TYPIFY `v3` EXISTS_TAC; ONCE_REWRITE_TAC[SET_RULE `{a,b,c,d} = {a,b,d,c}`]; FIRST_X_ASSUM_ST `=` (SUBST1_TAC o GSYM); FIRST_X_ASSUM MATCH_MP_TAC; BY(ASM_SIMP_TAC[]); COMMENT "continuity at f v1 t"; TYPIFY `!t. abs t < e'''' ==> f v1 continuous atreal t` (C SUBGOAL_THEN ASSUME_TAC); REPEAT WEAKER_STRIP_TAC; INTRO_TAC Pqcsxwg.PQCSXWG2_ATREAL [`(\ (t:real). (vec 0):real^3)`;`f1 v2`;`\ (t:real). v0`;`\ (t:real). (norm v2 pow 2)`;`\ (t:real). (norm v0 pow 2)`;`\ (t:real). (norm v1 pow 2)`;`\ (t:real). ((dist (v0,v1)) pow 2)`;`\ (t:real). ((dist (v2,v1)) pow 2)`;`\ (t:real). (dist (v0,v2) pow 2)`;`t`]; REWRITE_TAC[CONTINUOUS_CONST;REAL_CONTINUOUS_CONST]; EXPAND_TAC "f"; REWRITE_TAC[]; TYPIFY_GOAL_THEN `~(v1 = v2)` (unlist REWRITE_TAC); BY(ASM_MESON_TAC[Planarity.notcoplanar_disjoint]); DISCH_THEN MATCH_MP_TAC; ASM_SIMP_TAC[]; REWRITE_TAC[DIST_0;DIST_SYM]; CONJ_TAC; MATCH_MP_TAC NOT_COPLANAR_NOT_COLLINEAR; TYPIFY `v3` EXISTS_TAC; ONCE_REWRITE_TAC[SET_RULE `{a,b,c,d} = {a,c,d,b}`]; FIRST_X_ASSUM_ST `(v:real->real^3) = w` (SUBST1_TAC o GSYM); FIRST_X_ASSUM MATCH_MP_TAC; BY(ASM_SIMP_TAC[]); BY(ASM_MESON_TAC[SET_RULE `{a,b,c,d} = {a,b,d,c}`]); COMMENT "final kill"; TYPIFY `e''''` EXISTS_TAC; ASM_REWRITE_TAC[IN_REAL_INTERVAL;arith `-- e < t /\ t < e <=> abs t < e`;arith `abs(&0) = &0`;GSYM CONJ_ASSOC]; REWRITE_TAC[CONJ_ASSOC] THEN CONJ2_TAC; REPEAT WEAKER_STRIP_TAC; REPLICATE_TAC 2 (FIRST_X_ASSUM_ST `cross` (C INTRO_TAC [`t`])); (ASM_SIMP_TAC[]); REPEAT (GMATCH_SIMP_TAC (GSYM Collect_geom.EQ_POW2_COND)); REWRITE_TAC[DIST_POS_LE;NORM_POS_LE]; CONJ_TAC; BY(ASM_MESON_TAC[arith `&0 < x ==> &0 <= x`]); REWRITE_TAC[DIST_SYM]; DISCH_THEN (unlist REWRITE_TAC); DISCH_THEN (unlist REWRITE_TAC); BY(MESON_TAC[DIST_SYM;DIST_0]); SUBCONJ2_TAC; REPEAT WEAKER_STRIP_TAC; EXPAND_TAC "f"; BY(ASM_REWRITE_TAC[]); DISCH_TAC; COMMENT "insert"; TYPIFY `~(v1 = v2)` (C SUBGOAL_THEN ASSUME_TAC); BY(ASM_MESON_TAC[Planarity.notcoplanar_disjoint]); TYPIFY `f v1 (&0) = v1` (C SUBGOAL_THEN ASSUME_TAC); EXPAND_TAC "f"; ASM_REWRITE_TAC[]; TYPIFY `f1 v2 (&0) = v2` (C SUBGOAL_THEN SUBST1_TAC); BY(ASM_MESON_TAC[]); INTRO_TAC mk_simplex_uniq [`(vec 0):real^3`;`v2`;`v0`;`v1`]; REWRITE_TAC[GSYM DIST_0;DIST_SYM]; DISCH_THEN MATCH_MP_TAC; REWRITE_TAC[VECTOR_SUB_RZERO]; ONCE_REWRITE_TAC[SET_RULE `{a,b,c,d} = {a,c,d,b}`]; ASM_REWRITE_TAC[]; REPLICATE_TAC 2 (FIRST_X_ASSUM_ST `cross` kill); FIRST_X_ASSUM_ST `cross` MP_TAC; MATCH_MP_TAC (arith `a = b ==> a > &0 ==> b > &0`); BY(VEC3_TAC); COMMENT "end insert"; CONJ2_TAC; REPEAT WEAKER_STRIP_TAC; TYPIFY `v = v2` ASM_CASES_TAC; BY(ASM_MESON_TAC[]); TYPIFY `v = v1` ASM_CASES_TAC; BY(ASM_MESON_TAC[]); FIRST_X_ASSUM MATCH_MP_TAC; BY(ASM_REWRITE_TAC[]); REPEAT WEAKER_STRIP_TAC; TYPIFY `v = v1` ASM_CASES_TAC; BY(ASM_MESON_TAC[]); TYPIFY `v = v2` ASM_CASES_TAC; FIRST_X_ASSUM_ST `f (v2:real^3) = f1 v2` kill; ASM_REWRITE_TAC[]; FIRST_X_ASSUM MATCH_MP_TAC; ONCE_REWRITE_TAC[SET_RULE `{a,b,c,d} = {a,b,d,c}`]; BY(ASM_MESON_TAC[]); TYPIFY `f v = (\t. v)` (C SUBGOAL_THEN SUBST1_TAC); REWRITE_TAC[FUN_EQ_THM]; GEN_TAC; FIRST_X_ASSUM MATCH_MP_TAC; BY(ASM_REWRITE_TAC[]); BY(REWRITE_TAC[CONTINUOUS_CONST]) ]);; (* }}} *)
let deform_684_pent_exists = 
prove_by_refinement( `!V g23 v0 v1 v2 v3 e. ?f. ( (~coplanar {vec 0,v0,v2,v3} /\ ~coplanar {vec 0,v0,v1,v2} /\ v2 dot (v3 cross v0) > &0 /\ v1 dot (v2 cross v0) > &0 /\ &0 < e /\ g23 real_continuous_on (real_interval (--e,e)) /\ g23 (&0) = &0 ==> (?e'. &0 < e' /\ deformation f V (-- e', e') /\ (!v t. ~(v = v1) /\ ~(v = v2) ==> f v t = v) /\ (!t. abs t < e' ==> dist(v0,f v1 t) = dist(v0,v1) /\ dist(f v2 t,f v1 t) = dist(v2,v1) /\ norm(f v1 t) = norm(v1) /\ dist (f v2 t,v0) = dist(v2,v0) /\ dist (f v2 t,v3) = dist(v2,v3)+ g23 t /\ norm(f v2 t) = norm (v2) ))))`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; TYPED_ABBREV_TAC `f1 = (\ w t. if w = v2 then mk_simplex1 (vec 0) v3 v0 (norm v3 pow 2) (norm v0 pow 2) (norm v2 pow 2) ((dist(v0,v2)) pow 2) ((dist(v3,v2) + g23 t) pow 2) (dist(v0,v3) pow 2) else w)`; TYPED_ABBREV_TAC `f = (\ w t. if w = v2 then f1 v2 t else if w = v1 then mk_simplex1 (vec 0) (f1 v2 t) v0 (norm v2 pow 2) (norm v0 pow 2) (norm v1 pow 2) ((dist(v0,v1)) pow 2) ((dist(v2,v1)) pow 2) (dist(v0,v2) pow 2) else w)`; TYPIFY `f` EXISTS_TAC; REPEAT WEAKER_STRIP_TAC; INTRO_TAC deform_simplex_684_pent [`V`;`g23`;`v0`;`v1`;`v2`;`v3`;`e`]; ASM_REWRITE_TAC[]; LET_TAC; ASM_REWRITE_TAC[]; BY((ASM_REWRITE_TAC[LET_DEF;LET_END_DEF])) ]);;
(* }}} *)
let mk_planar_unique = 
prove_by_refinement( `!v0 v1 v2 v3 v3'. ~collinear {v0,v1,v2} /\ dist(v0,v3) = dist(v0,v3') /\ dist(v1,v3) = dist(v1,v3') /\ coplanar {v0,v1,v2,v3} /\ coplanar {v0,v1,v2,v3'} /\ (?t. &0 < t /\ t % ((v3 - v0) cross (v1 - v0)) = ((v3' - v0) cross (v1 - v0))) ==> (v3 = v3')`,
(* {{{ proof *) [ GEOM_ORIGIN_TAC `v0:real^3` THEN REPEAT GEN_TAC; REWRITE_TAC[VECTOR_SUB_RZERO]; REPEAT WEAKER_STRIP_TAC; TYPED_ABBREV_TAC `n = v1 cross (v1 cross v2)`; TYPIFY `n dot n = (v1 dot v1) * ((v1 cross v2) dot (v1 cross v2))` (C SUBGOAL_THEN ASSUME_TAC); EXPAND_TAC "n";
BY(VEC3_TAC); TYPIFY `~(n = vec 0)` (C SUBGOAL_THEN ASSUME_TAC); ASM_REWRITE_TAC[GSYM DOT_POS_LT]; GMATCH_SIMP_TAC REAL_LT_MUL_EQ; REWRITE_TAC[DOT_POS_LT]; CONJ_TAC; BY(ASM_MESON_TAC[COLLINEAR_2;SET_RULE `{a,a,b} = {a,b}`]); BY(ASM_MESON_TAC[CROSS_EQ_0]); TYPIFY `~coplanar {vec 0,v1,v1 cross v2,n}` (C SUBGOAL_THEN ASSUME_TAC); EXPAND_TAC "n"; MATCH_MP_TAC Local_lemmas.NOT_COLL_IMP_COPL; BY(ASM_MESON_TAC[Local_lemmas.COLL_IFF_COLL_CROSS]); INTRO_TAC Trigonometry2.NONCOPLANAR_3_BASIS [`v1`;`v1 cross v2`;`n`;`(vec 0):real^3`]; ASM_REWRITE_TAC[VECTOR_SUB_RZERO]; DISCH_TAC; TYPIFY `!u. coplanar {vec 0,v1,v2,u} ==> ?t1 tn. u = t1 % v1 + tn % n` (C SUBGOAL_THEN ASSUME_TAC); REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM (C INTRO_TAC [`u`]); REPEAT WEAKER_STRIP_TAC; ASM_REWRITE_TAC[]; GEXISTL_TAC [`t1`;`t3`]; INTRO_TAC Zlzthic.coplanar_in_affine_hull [`(vec 0):real^3`;`v1`;`v2`;`u`]; ONCE_REWRITE_TAC[SET_RULE `{a,b,c,d} = {b,c,d,a}`]; ANTS_TAC; BY(ASM_MESON_TAC[]); REPEAT WEAKER_STRIP_TAC; INTRO_TAC Ckqowsa_4_points.in_affine_hull_lemma [`v1`;`v2`;`u`]; ANTS_TAC; BY(ASM_MESON_TAC[]); REPEAT WEAKER_STRIP_TAC; PROOF_BY_CONTR_TAC; TYPIFY `(t1' % v1 + t2' % v2) dot (v1 cross v2) = (t1 % v1 + t2 % (v1 cross v2) + t3 % n) dot (v1 cross v2)` (C SUBGOAL_THEN MP_TAC); BY(ASM_MESON_TAC[]); EXPAND_TAC "n"; REWRITE_TAC[DOT_LADD;DOT_LMUL;DOT_CROSS_SELF]; REWRITE_TAC[arith `a * &0 + b * &0 = c * &0 + e + f* &0 <=> e = &0`]; REWRITE_TAC[REAL_ENTIRE]; REWRITE_TAC[DOT_EQ_0]; DISCH_TAC; FIRST_X_ASSUM_ST `~` MP_TAC; FIRST_X_ASSUM DISJ_CASES_TAC; ASM_REWRITE_TAC[]; BY(VECTOR_ARITH_TAC); BY(ASM_MESON_TAC[CROSS_EQ_0]); FIRST_ASSUM (C INTRO_TAC [`v3`]); FIRST_X_ASSUM (C INTRO_TAC [`v3'`]); ASM_REWRITE_TAC[]; REPEAT WEAKER_STRIP_TAC; ASM_REWRITE_TAC[]; TYPIFY `!a b. norm (a % v1 + b % n) pow 2 = a pow 2 * (v1 dot v1) + b pow 2 * (n dot n)` (C SUBGOAL_THEN ASSUME_TAC); REPEAT WEAKER_STRIP_TAC; (GMATCH_SIMP_TAC NORM_ADD_PYTHAGOREAN ); CONJ_TAC; BY(REWRITE_TAC[orthogonal] THEN EXPAND_TAC "n" THEN VEC3_TAC); REWRITE_TAC[NORM_MUL]; BY(REWRITE_TAC[arith `(a * b) pow 2 = a pow 2 * b pow 2`;GSYM Collect_geom.X_DOT_X_EQ;arith `abs a pow 2 = a pow 2`]); TYPIFY `t1' = t1` ENOUGH_TO_SHOW_TAC; DISCH_TAC; ASM_REWRITE_TAC[]; FIRST_X_ASSUM (RULE_ASSUM_TAC o (unlist REWRITE_RULE)); TYPIFY `norm v3 pow 2 = norm v3' pow 2` (C SUBGOAL_THEN MP_TAC); BY(ASM_MESON_TAC[DIST_0;Collect_geom.X_DOT_X_EQ]); ASM_REWRITE_TAC[]; DISCH_TAC; TYPIFY `tn pow 2 * (n dot n) = tn' pow 2 * (n dot n)` (C SUBGOAL_THEN MP_TAC); RULE_ASSUM_TAC(REWRITE_RULE[arith `a + b = a + c <=> b = c`]); BY(ASM_REWRITE_TAC[]); REWRITE_TAC[REAL_EQ_MUL_RCANCEL]; REWRITE_TAC[DOT_EQ_0]; ASM_REWRITE_TAC[]; REWRITE_TAC[GSYM REAL_EQ_SQUARE_ABS]; DISCH_TAC; PROOF_BY_CONTR_TAC; FIRST_X_ASSUM_ST `t % (v3 cross v1) = u` MP_TAC; ASM_REWRITE_TAC[] THEN EXPAND_TAC "n" THEN REWRITE_TAC[CROSS_LADD;CROSS_LMUL;DOT_CROSS_SELF;CROSS_REFL]; TYPIFY `((v1 cross v1 cross v2) cross v1) = (v1 dot v1) % (v1 cross v2)` (C SUBGOAL_THEN SUBST1_TAC); BY(VEC3_TAC); REWRITE_TAC[arith `t % vec 0 + b = b`]; REWRITE_TAC[VECTOR_MUL_ASSOC]; REWRITE_TAC[VECTOR_MUL_RCANCEL]; REWRITE_TAC[REAL_EQ_MUL_RCANCEL]; REWRITE_TAC[GSYM DISJ_ASSOC]; DISCH_TAC; FIRST_X_ASSUM_ST `~` MP_TAC; REPEAT (FIRST_X_ASSUM DISJ_CASES_TAC); RULE_ASSUM_TAC(REWRITE_RULE[arith `abs a = abs b <=> (a = b \/ a = --b)`]); FIRST_X_ASSUM DISJ_CASES_TAC; BY(ASM_REWRITE_TAC[]); TYPIFY `(t + &1) * tn' = &0` (C SUBGOAL_THEN MP_TAC); BY(REPLICATE_TAC 2 (FIRST_X_ASSUM MP_TAC) THEN REAL_ARITH_TAC); REWRITE_TAC[REAL_ENTIRE]; ASM_SIMP_TAC[arith `&0 <t ==> ~(t + &1 = &0)`]; DISCH_TAC THEN ASM_REWRITE_TAC[]; BY(VECTOR_ARITH_TAC); FIRST_X_ASSUM MP_TAC; REWRITE_TAC[DOT_EQ_0]; BY(ASM_MESON_TAC[COLLINEAR_2;SET_RULE `{a,a,b} = {a,b}`]); BY(ASM_MESON_TAC[CROSS_EQ_0]); TYPIFY `!a b. dist(vec 0,a % v1 + b % n) pow 2 - dist(v1,a % v1 + b % n) pow 2 = dist(vec 0,v3) pow 2 - dist(v1,v3) pow 2 ==> a = t1'` ENOUGH_TO_SHOW_TAC; BY(ASM_MESON_TAC[]); ONCE_REWRITE_TAC[DIST_SYM]; REWRITE_TAC[dist]; REWRITE_TAC[VECTOR_SUB_RZERO]; FIRST_X_ASSUM_ST `(v3:real^3) = b` SUBST1_TAC; REWRITE_TAC[arith `(a % v1 + b % n) - v1 = (a - &1) % v1 + b % n`]; REPEAT GEN_TAC; FIRST_X_ASSUM (unlist REWRITE_TAC); REWRITE_TAC[arith `(u + v) - (w + v) = u - w`]; REWRITE_TAC[arith `a pow 2 * b - (a - &1) pow 2 * b = (&2 * a - &1) *b`]; REWRITE_TAC[REAL_EQ_MUL_RCANCEL]; DISCH_THEN DISJ_CASES_TAC; BY(FIRST_X_ASSUM MP_TAC THEN REAL_ARITH_TAC); FIRST_X_ASSUM MP_TAC; REWRITE_TAC[DOT_EQ_0]; BY(ASM_MESON_TAC[COLLINEAR_2;SET_RULE `{a,a,b} = {a,b}`]) ]);; (* }}} *)
let mk_planar2_continuous = 
prove_by_refinement( `!v0 v1 v2 x1 x2 x3 x5 x6 a s. &0 < x1 a /\ &0 < ups_x (x1 a) (x2 a) (x6 a) /\ &0 < ups_x (x1 a) (x3 a) (x5 a) /\ v0 continuous (atreal a) /\ v1 continuous (atreal a) /\ v2 continuous (atreal a) /\ x1 real_continuous (atreal a) /\ x2 real_continuous (atreal a) /\ x3 real_continuous (atreal a) /\ x5 real_continuous (atreal a) /\ x6 real_continuous (atreal a) ==> (\t. mk_planar2 (v0 t) (v1 t) (v2 t) (x1 t) (x2 t) (x3 t) (x5 t) (x6 t) s) continuous (atreal a)`,
(* {{{ proof *) [ REWRITE_TAC[Appendix.mk_planar2;LET_DEF;LET_END_DEF]; REPEAT WEAKER_STRIP_TAC; REPEAT (REPEAT CONJ_TAC THEN (MATCH_MP_TAC CONTINUOUS_ADD ORELSE MATCH_MP_TAC CONTINUOUS_MUL ORELSE MATCH_MP_TAC REAL_CONTINUOUS_AT_SQRT ORELSE MATCH_MP_TAC (* Xbjrphc. *)CONTINUOUS_CROSS ORELSE MATCH_MP_TAC CONTINUOUS_SUB ORELSE MATCH_MP_TAC REAL_CONTINUOUS_MUL ORELSE MATCH_MP_TAC REAL_CONTINUOUS_ADD ORELSE MATCH_MP_TAC REAL_CONTINUOUS_SUB ORELSE MATCH_MP_TAC REAL_CONTINUOUS_DIV_ATREAL ORELSE MATCH_MP_TAC Pqcsxwg.REAL_CONTINUOUS_ATREAL_SQRT_COMPOSE) THEN ASM_SIMP_TAC[GSYM REAL_CONTINUOUS_CONTINUOUS1;REAL_ENTIRE;arith `&0 < x ==> ~(x = &0)`;arith `~(&2 = &0)`;REAL_CONTINUOUS_CONST]); GMATCH_SIMP_TAC REAL_LT_DIV; ASM_REWRITE_TAC[]; MATCH_MP_TAC REAL_CONTINUOUS_DIV_ATREAL; ASM_SIMP_TAC[arith `&0 < x ==> ~(x = &0)`]; REWRITE_TAC[Sphere.ups_x]; BY(CONJ_TAC THEN REPEAT (REPEAT CONJ_TAC THEN (MATCH_MP_TAC REAL_CONTINUOUS_ADD ORELSE MATCH_MP_TAC REAL_CONTINUOUS_MUL ORELSE MATCH_MP_TAC REAL_CONTINUOUS_SUB ORELSE MATCH_MP_TAC REAL_CONTINUOUS_NEG) THEN ASM_REWRITE_TAC[REAL_CONTINUOUS_CONST])) ]);;
(* }}} *)
let collinear_expand = 
prove_by_refinement( `!(v1:real^A) v2 v3. ~collinear {vec 0,v1,v2} /\ coplanar {vec 0,v1,v2,v3} ==> (?t1 t2. v3 = t1 % v1 + t2 % v2)`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM (ASSUME_TAC o (MATCH_MP Counting_spheres.NOT_COLLINEAR_AFF_DIM_2)); FIRST_X_ASSUM (ASSUME_TAC o (MATCH_MP Leaf_cell.COPLANAR_IMP_AFF_DIM)); INTRO_TAC AFF_DIM_EQ_AFFINE_HULL [`{vec 0,v1,v2}`;`{vec 0,v1,v2,v3}`]; ANTS_TAC; CONJ_TAC; BY(SET_TAC[]); BY(ASM_TAC THEN INT_ARITH_TAC); DISCH_TAC; TYPIFY `v3 IN affine hull {vec 0,v1,v2}` (C SUBGOAL_THEN ASSUME_TAC); ASM_REWRITE_TAC[]; MATCH_MP_TAC Marchal_cells_2_new.IN_AFFINE_KY_LEMMA1; BY(SET_TAC[]); FIRST_X_ASSUM MP_TAC; REWRITE_TAC[AFFINE_HULL_3;IN_ELIM_THM]; REPEAT WEAKER_STRIP_TAC; GEXISTL_TAC [`v`;`w`]; ASM_REWRITE_TAC[]; BY(VECTOR_ARITH_TAC) ]);;
(* }}} *)
let deform_planar = 
prove_by_refinement( `!V g01 g02 g23 v0 v1 v2 v3 e. ( let f1 = (\ w t. if w = v2 then mk_simplex1 (vec 0) v3 v0 (norm v3 pow 2) (norm v0 pow 2) (norm v2 pow 2) ((dist(v0,v2) + g02 t) pow 2) ((dist(v3,v2) + g23 t) pow 2) (dist(v0,v3) pow 2) else w) in let f = (\ w t. if w = v2 then f1 v2 t else if w = v1 then mk_planar2 (vec 0) v0 (f1 v2 t) (norm v0 pow 2) (norm v2 pow 2) (norm v1 pow 2) // skip4 ((dist(v0,v1) + g01 t) pow 2) ((dist(v0,v2) + g02 t) pow 2) (-- &1) else w) in (~coplanar {vec 0,v0,v2,v3} /\ coplanar {vec 0,v0,v1,v2} /\ v2 dot (v3 cross v0) > &0 /\ (v1 cross v0) dot (v2 cross v0) > &0 /\ ~(v1 = v2) /\ &0 < e /\ g23 real_continuous_on (real_interval (--e,e)) /\ g23 (&0) = &0 /\ g01 real_continuous_on (real_interval (--e,e)) /\ g01 (&0) = &0 /\ g02 real_continuous_on (real_interval (--e,e)) /\ g02 (&0) = &0 ==> (?e'. &0 < e' /\ deformation f V (-- e', e') /\ (!v t. ~(v = v1) /\ ~(v = v2) ==> f v t = v) /\ (!t. abs t < e' ==> coplanar {vec 0,v0,f v1 t,f v2 t} /\ dist(v0,f v1 t) = dist(v0,v1) + g01 t /\ norm(f v1 t) = norm(v1) /\ dist (f v2 t,v0) = dist(v2,v0) + g02 t /\ dist (f v2 t,v3) = dist(v2,v3)+ g23 t /\ norm(f v2 t) = norm (v2) ))))`,
(* {{{ proof *) [ REPEAT GEN_TAC; REPEAT LET_TAC; REWRITE_TAC[Localization.deformation]; REPEAT WEAKER_STRIP_TAC; COMMENT "preliminaries";
TYPIFY `{vec 0,v3,v0,v2} = { vec 0,v0,v2,v3} /\ {vec 0, v0, v3, v2} = {vec 0,v0,v2,v3}` (C SUBGOAL_THEN ASSUME_TAC); BY(SET_TAC[]); TYPIFY `~(v1 = vec 0) /\ ~(v1 = v0)` (C SUBGOAL_THEN ASSUME_TAC); REWRITE_TAC[GSYM DE_MORGAN_THM] THEN DISCH_TAC THEN FIRST_X_ASSUM DISJ_CASES_TAC THEN FIRST_X_ASSUM_ST `(v1 cross v0) dot (v2 cross v0)` MP_TAC THEN ASM_REWRITE_TAC[]; BY(REWRITE_TAC[CROSS_LZERO;DOT_LZERO] THEN REAL_ARITH_TAC); BY(REWRITE_TAC[CROSS_REFL;DOT_LZERO] THEN REAL_ARITH_TAC); TYPIFY `~(v0 = vec 0) /\ ~(v2 = vec 0) /\ ~(v3 = vec 0) /\ ~(v0 = v2) /\ ~(v0 = v3) /\ ~(v2 = v3)` (C SUBGOAL_THEN ASSUME_TAC); BY(ASM_MESON_TAC[Planarity.notcoplanar_disjoint]); COMMENT "easy continuity"; TYPIFY `&0 IN real_interval( --e,e)` (C SUBGOAL_THEN ASSUME_TAC); REWRITE_TAC[IN_REAL_INTERVAL]; BY(ASM_SIMP_TAC[arith `&0 < e ==> --e < &0`]); TYPIFY `g23 real_continuous atreal (&0) /\ g01 real_continuous atreal (&0) /\ g02 real_continuous atreal (&0)` (C SUBGOAL_THEN ASSUME_TAC); BY(ASM_MESON_TAC[REAL_CONTINUOUS_ON_EQ_REAL_CONTINUOUS_AT;Ocbicby.REAL_OPEN_REAL_INTERVAL]); TYPIFY `(\t. delta_x (norm v3 pow 2) (norm v0 pow 2) (norm v2 pow 2) ((dist(v0,v2)+g02 t) pow 2) ((dist(v3,v2) + g23 t) pow 2) (dist(v0,v3) pow 2)) real_continuous atreal (&0)` (C SUBGOAL_THEN ASSUME_TAC); REWRITE_TAC[Sphere.delta_x]; BY(REPEAT (ASM_REWRITE_TAC[REAL_CONTINUOUS_CONST] THEN REPEAT CONJ_TAC THEN (MATCH_MP_TAC REAL_CONTINUOUS_ADD ORELSE MATCH_MP_TAC REAL_CONTINUOUS_MUL ORELSE MATCH_MP_TAC REAL_CONTINUOUS_POW ORELSE MATCH_MP_TAC REAL_CONTINUOUS_SUB))); TYPIFY `&0 < delta_x (norm v3 pow 2) (norm v0 pow 2) (norm v2 pow 2) ((dist (v0,v2)) pow 2) ((dist (v3,v2)) pow 2) (dist (v0,v3) pow 2)` (C SUBGOAL_THEN ASSUME_TAC); REWRITE_TAC[GSYM Sphere.delta_y;arith `x pow 2 = x*x`;GSYM DIST_0]; FIRST_X_ASSUM_ST `coplanar` kill; FIRST_X_ASSUM_ST `coplanar` MP_TAC; ONCE_REWRITE_TAC[SET_RULE `{a,b,c,d} = {a,d,b,c}`]; REWRITE_TAC[ Oxlzlez.coplanar_delta_y]; BY(REWRITE_TAC[DIST_SYM]); TYPIFY `~collinear {vec 0,v0,v2}` (C SUBGOAL_THEN ASSUME_TAC); BY(ASM_MESON_TAC[Planarity.notcoplanar_imp_notcollinear_fan]); TYPIFY `&0 < ups_x (norm v0 pow 2) (norm v2 pow 2) ((dist (v0,v2)) pow 2)` (C SUBGOAL_THEN ASSUME_TAC); FIRST_X_ASSUM_ST `collinear` MP_TAC; BY(REWRITE_TAC[Collect_geom2.NOT_COL_EQ_UPS_X_POS;DIST_0]); TYPIFY `~collinear {vec 0,v0,v1}` (C SUBGOAL_THEN ASSUME_TAC); REWRITE_TAC[GSYM CROSS_EQ_0]; ONCE_REWRITE_TAC[CROSS_SKEW]; REWRITE_TAC[arith `-- v = vec 0 <=> v = vec 0`]; DISCH_TAC; FIRST_X_ASSUM_ST `(a cross b) dot (c cross d)` MP_TAC; ASM_REWRITE_TAC[DOT_LZERO]; BY(REAL_ARITH_TAC); TYPIFY `&0 < ups_x (norm v0 pow 2) (norm v1 pow 2) ((dist (v0,v1)) pow 2)` (C SUBGOAL_THEN ASSUME_TAC); FIRST_X_ASSUM_ST `collinear` MP_TAC; BY(REWRITE_TAC[Collect_geom2.NOT_COL_EQ_UPS_X_POS;DIST_0]); TYPIFY `?e1. &0 < e1 /\ (!t. abs t < e1 ==> &0 < delta_x (norm v3 pow 2) (norm v0 pow 2) (norm v2 pow 2) ((dist(v0,v2) + g02 t) pow 2) ((dist(v3,v2) + g23 t) pow 2) (dist(v0,v3) pow 2))` (C SUBGOAL_THEN ASSUME_TAC); INTRO_TAC continuous_nbd_pos [`(\t. delta_x (norm v3 pow 2) (norm v0 pow 2) (norm v2 pow 2) ((dist (v0,v2)+g02 t) pow 2) ((dist (v3,v2) + g23 t) pow 2) (dist (v0,v3) pow 2))`;`&0`]; BY((ASM_REWRITE_TAC[arith `x + &0 = x`;arith `abs (t' - &0) = abs t'`])); FIRST_X_ASSUM MP_TAC THEN REPEAT WEAKER_STRIP_TAC; TYPIFY `?e2. &0 < e2 /\ (!t. abs t < e2 ==> &0 < dist (v3,v2) + g23 t /\ &0 < dist(v0,v2)+g02 t /\ &0 < dist(v0,v1)+g01 t)` (C SUBGOAL_THEN ASSUME_TAC); TYPIFY `(\t. (dist (v3,v2) + g23 t) ) real_continuous atreal (&0) /\ (\t. (dist (v0,v2) + g02 t) ) real_continuous atreal (&0) /\ (\t. (dist (v0,v1) + g01 t) ) real_continuous atreal (&0)` ENOUGH_TO_SHOW_TAC; REPEAT WEAKER_STRIP_TAC; INTRO_TAC continuous_nbd_pos [`(\t. (dist (v3,v2) + g23 t) )`;`&0`]; INTRO_TAC continuous_nbd_pos [`(\t. (dist (v0,v2) + g02 t) )`;`&0`]; INTRO_TAC continuous_nbd_pos [`(\t. (dist (v0,v1) + g01 t) )`;`&0`]; ASM_REWRITE_TAC[arith `x + &0 = x`;GSYM DIST_NZ;arith `abs (t' - &0) = abs t'`]; REPEAT WEAKER_STRIP_TAC; INTRO_TAC epsilon_pair [`e'`;`e''`] THEN ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; INTRO_TAC epsilon_pair [`e''''`;`e'''`] THEN ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; BY(TYPIFY `e'''''` EXISTS_TAC THEN ASM_MESON_TAC[]); BY(REPEAT CONJ_TAC THEN (REPEAT (ASM_REWRITE_TAC[REAL_CONTINUOUS_CONST] THEN REPEAT CONJ_TAC THEN (MATCH_MP_TAC REAL_CONTINUOUS_ADD ORELSE MATCH_MP_TAC REAL_CONTINUOUS_MUL ORELSE MATCH_MP_TAC REAL_CONTINUOUS_POW ORELSE MATCH_MP_TAC REAL_CONTINUOUS_SUB)))); FIRST_X_ASSUM MP_TAC THEN REPEAT WEAKER_STRIP_TAC; TYPIFY `!t. abs t < e2 ==> &0 < (dist (v3,v2) + g23 t) pow 2 /\ &0 < (dist (v0,v2) + g02 t) pow 2 /\ &0 < (dist (v0,v1) + g01 t) pow 2` (C SUBGOAL_THEN ASSUME_TAC); REPEAT WEAKER_STRIP_TAC; REWRITE_TAC[GSYM Trigonometry2.NOT_ZERO_EQ_POW2_LT]; BY(ASM_SIMP_TAC[arith `&0 < x ==> ~(x = &0)`]); INTRO_TAC epsilon_pair [`e1`;`e2`] THEN ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; COMMENT "distances on 023 triangle"; TYPIFY `!t. abs t < e'' ==> norm v2 pow 2 = dist (f v2 t,vec 0) pow 2 /\ (dist (v0,v2)+g02 t) pow 2 = dist (f v2 t,v0) pow 2 /\ (dist (v3,v2) + g23 t) pow 2 = dist (f v2 t,v3) pow 2 /\ v3 dot (v0 cross f v2 t) > &0` (C SUBGOAL_THEN ASSUME_TAC); REPEAT WEAKER_STRIP_TAC; INTRO_TAC PQCSXWG1_SYM [`(vec 0):real^3`;` v0 `;`v3`;`f v2 t`;` (norm v0 pow 2)`;` (norm v3 pow 2)`;`(norm v2 pow 2)`;` ((dist (v3,v2) + g23 t) pow 2)`;` ((dist (v0,v2)+ g02 t ) pow 2)`;` (dist (v0,v3) pow 2)`]; REWRITE_TAC[VECTOR_SUB_RZERO]; DISCH_THEN MATCH_MP_TAC; ASM_SIMP_TAC[]; REWRITE_TAC[CONJ_ASSOC] THEN CONJ2_TAC; EXPAND_TAC "f"; (REWRITE_TAC[]); EXPAND_TAC "f1"; BY(REWRITE_TAC[]); CONJ2_TAC; FIRST_X_ASSUM_ST `delta_x` (C INTRO_TAC [`t`]); ASM_SIMP_TAC[]; BY(MESON_TAC[Merge_ineq.delta_x_sym]); REWRITE_TAC[DIST_0]; REWRITE_TAC[GSYM Trigonometry2.NOT_ZERO_EQ_POW2_LT]; REWRITE_TAC[GSYM DIST_0]; ASM_REWRITE_TAC[DIST_EQ_0]; MATCH_MP_TAC NOT_COPLANAR_NOT_COLLINEAR; TYPIFY `v2` EXISTS_TAC; BY(ASM_REWRITE_TAC[]); COMMENT "continuity at f v2 t"; INTRO_TAC epsilon_pair [`e`;`e''`] THEN ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; TYPIFY `!t. abs t < e''' /\ ~coplanar{vec 0,v0,f v2 t,v3} ==> f v2 continuous atreal t` (C SUBGOAL_THEN ASSUME_TAC); REPEAT WEAKER_STRIP_TAC; TYPIFY `g23 real_continuous atreal t /\ g02 real_continuous atreal t` (C SUBGOAL_THEN ASSUME_TAC); REPEAT (FIRST_X_ASSUM_ST `real_continuous_on` MP_TAC); REPEAT (GMATCH_SIMP_TAC REAL_CONTINUOUS_ON_EQ_REAL_CONTINUOUS_AT); REWRITE_TAC[ Ocbicby.REAL_OPEN_REAL_INTERVAL;IN_REAL_INTERVAL;arith `-- e < t /\ t < e <=> abs t < e`]; BY(REPEAT WEAKER_STRIP_TAC THEN CONJ_TAC THEN FIRST_X_ASSUM MATCH_MP_TAC THEN FIRST_X_ASSUM MATCH_MP_TAC THEN ASM_REWRITE_TAC[]); INTRO_TAC Pqcsxwg.PQCSXWG2_ATREAL [`(\ (t:real). (vec 0):real^3)`;`\ (t:real). v3`;`\ (t:real). v0`;`\ (t:real). (norm v3 pow 2)`;`\ (t:real). (norm v0 pow 2)`;`\ (t:real). (norm v2 pow 2)`;`\ (t:real). ((dist (v0,v2)+g02 t) pow 2)`;`\ (t:real). ((dist (v3,v2)+ g23 t) pow 2)`;`\ (t:real). (dist (v0,v3) pow 2)`;`t`]; REWRITE_TAC[CONTINUOUS_CONST;REAL_CONTINUOUS_CONST]; EXPAND_TAC "f"; REWRITE_TAC[]; EXPAND_TAC "f1"; REWRITE_TAC[]; DISCH_THEN MATCH_MP_TAC; ASM_SIMP_TAC[]; REWRITE_TAC[DIST_0;DIST_SYM]; CONJ_TAC; MATCH_MP_TAC NOT_COPLANAR_NOT_COLLINEAR; TYPIFY `v2` EXISTS_TAC; BY(ASM_REWRITE_TAC[]); BY(CONJ_TAC THEN ((REPEAT (ASM_REWRITE_TAC[REAL_CONTINUOUS_CONST] THEN REPEAT CONJ_TAC THEN (MATCH_MP_TAC REAL_CONTINUOUS_ADD ORELSE MATCH_MP_TAC REAL_CONTINUOUS_MUL ORELSE MATCH_MP_TAC REAL_CONTINUOUS_POW ORELSE MATCH_MP_TAC REAL_CONTINUOUS_SUB))))); COMMENT "coplanarity"; TYPIFY `f v2 (&0) = v2` (C SUBGOAL_THEN ASSUME_TAC); EXPAND_TAC "f"; EXPAND_TAC "f1"; ASM_REWRITE_TAC[arith `x + &0 = x`]; INTRO_TAC mk_simplex_uniq [`(vec 0):real^3`;`v3`;`v0`;`v2`]; REWRITE_TAC[GSYM DIST_0;DIST_SYM]; DISCH_THEN MATCH_MP_TAC; REWRITE_TAC[VECTOR_SUB_RZERO]; ASM_REWRITE_TAC[]; REPLICATE_TAC 2 (FIRST_X_ASSUM_ST `cross` kill); FIRST_X_ASSUM_ST `cross` MP_TAC; MATCH_MP_TAC (arith `a = b ==> a > &0 ==> b > &0`); BY(VEC3_TAC); TYPIFY `f v2 continuous atreal (&0)` (C SUBGOAL_THEN ASSUME_TAC); FIRST_X_ASSUM MATCH_MP_TAC; BY(ASM_REWRITE_TAC[arith `abs(&0) = &0`]); INTRO_TAC Zlzthic.NONPLANAR_OPEN [`\ (t:real). (vec 0):real^3`;`\ (t:real). v0`;`\ (t:real). v3`;`f v2`;`&0`]; ASM_REWRITE_TAC[CONTINUOUS_CONST;arith `abs(&0 - t)= abs t`]; REPEAT WEAKER_STRIP_TAC; COMMENT "non collinearity 0, v0, v1"; TYPIFY `?e3. &0 < e3 /\ (!t. abs t < e3 ==> &0 < ups_x (norm v0 pow 2) (norm v1 pow 2) ((dist (v0,v1) + g01 t) pow 2) /\ &0 < ups_x (norm v0 pow 2) (norm v2 pow 2) ((dist (v0,v2) + g02 t) pow 2))` (C SUBGOAL_THEN ASSUME_TAC); TYPIFY `(\t. ups_x (norm v0 pow 2) (norm v1 pow 2) ((dist (v0,v1) + g01 t) pow 2)) real_continuous atreal (&0) /\ (\t. ups_x (norm v0 pow 2) (norm v2 pow 2) ((dist (v0,v2) + g02 t) pow 2)) real_continuous atreal (&0)` ENOUGH_TO_SHOW_TAC; REPEAT WEAKER_STRIP_TAC; INTRO_TAC continuous_nbd_pos [`(\t. ups_x (norm v0 pow 2) (norm v1 pow 2) ((dist (v0,v1) + g01 t) pow 2))`;`&0`]; INTRO_TAC continuous_nbd_pos [`(\t. ups_x (norm v0 pow 2) (norm v2 pow 2) ((dist (v0,v2) + g02 t) pow 2))`;`&0`]; ASM_REWRITE_TAC[arith `x + &0 = x`;arith `abs (t - &0) = abs t`]; REPEAT WEAKER_STRIP_TAC; INTRO_TAC epsilon_pair [`e''''`;`e'''''`] THEN ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; TYPIFY `e''''''` EXISTS_TAC; ASM_REWRITE_TAC[]; BY(REPLICATE_TAC 7 (FIRST_X_ASSUM MP_TAC) THEN MESON_TAC[]); BY(REWRITE_TAC[Sphere.ups_x] THEN CONJ_TAC THEN ((REPEAT (ASM_REWRITE_TAC[REAL_CONTINUOUS_CONST] THEN REPEAT CONJ_TAC THEN (MATCH_MP_TAC REAL_CONTINUOUS_ADD ORELSE MATCH_MP_TAC REAL_CONTINUOUS_MUL ORELSE MATCH_MP_TAC REAL_CONTINUOUS_POW ORELSE MATCH_MP_TAC REAL_CONTINUOUS_SUB))))); FIRST_X_ASSUM MP_TAC THEN REPEAT WEAKER_STRIP_TAC; INTRO_TAC epsilon_pair [`e3`;`e'`] THEN ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; INTRO_TAC epsilon_pair [`e'''`;`e''''`] THEN ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; TYPIFY `!t. abs t < e''''' ==> f v1 continuous atreal t` (C SUBGOAL_THEN ASSUME_TAC); REPEAT WEAKER_STRIP_TAC; TYPIFY `f v2 continuous atreal t /\ g01 real_continuous atreal t /\ g02 real_continuous atreal t` (C SUBGOAL_THEN ASSUME_TAC); CONJ_TAC; FIRST_X_ASSUM MATCH_MP_TAC; ASM_REWRITE_TAC[]; ONCE_REWRITE_TAC[SET_RULE `{a,b,c,d} = {a,b,d,c}`]; BY(CONJ_TAC THEN ASM_MESON_TAC[]); REPEAT (FIRST_X_ASSUM_ST `real_continuous_on` MP_TAC); REPEAT (GMATCH_SIMP_TAC REAL_CONTINUOUS_ON_EQ_REAL_CONTINUOUS_AT); REWRITE_TAC[ Ocbicby.REAL_OPEN_REAL_INTERVAL;IN_REAL_INTERVAL;arith `-- e < t /\ t < e <=> abs t < e`]; REPEAT WEAKER_STRIP_TAC THEN CONJ_TAC THEN FIRST_X_ASSUM MATCH_MP_TAC THEN FIRST_X_ASSUM MATCH_MP_TAC THEN ASM_REWRITE_TAC[]; BY(ASM_MESON_TAC[]); BY(ASM_MESON_TAC[]); INTRO_TAC mk_planar2_continuous [`(\ (t:real). (vec 0):real^3)`;`\ (t:real). v0`;`f1 v2`;`\ (t:real). (norm v0 pow 2)`;`\ (t:real). (norm v2 pow 2)`;`\ (t:real). (norm v1 pow 2)`;`\ (t:real). ((dist (v0,v1)+g01 t) pow 2)`;`\ (t:real). ((dist (v0,v2)+ g02 t) pow 2)`;`t`;`-- &1`]; REWRITE_TAC[CONTINUOUS_CONST;REAL_CONTINUOUS_CONST]; EXPAND_TAC "f"; ASM_REWRITE_TAC[]; DISCH_THEN MATCH_MP_TAC; ASM_SIMP_TAC[]; REWRITE_TAC[DIST_0;DIST_SYM]; REWRITE_TAC[GSYM Trigonometry2.NOT_ZERO_EQ_POW2_LT]; REWRITE_TAC[NORM_EQ_0]; ASM_REWRITE_TAC[]; CONJ_TAC; FIRST_X_ASSUM MP_TAC; EXPAND_TAC "f"; ASM_REWRITE_TAC[]; TYPIFY `(\t. f1 v2 t) = f1 v2` (C SUBGOAL_THEN SUBST1_TAC); BY(REWRITE_TAC[FUN_EQ_THM]); BY(MESON_TAC[]); BY(CONJ_TAC THEN REPEAT (REPEAT CONJ_TAC THEN (MATCH_MP_TAC REAL_CONTINUOUS_ADD ORELSE MATCH_MP_TAC REAL_CONTINUOUS_MUL ORELSE MATCH_MP_TAC REAL_CONTINUOUS_POW ORELSE MATCH_MP_TAC REAL_CONTINUOUS_SUB) THEN (ASM_REWRITE_TAC[REAL_CONTINUOUS_CONST] ))); COMMENT "distances on 012 triangle"; TYPIFY `f1 v2 = f v2` (C SUBGOAL_THEN ASSUME_TAC); EXPAND_TAC "f"; BY(REWRITE_TAC[FUN_EQ_THM]); TYPIFY `!t. abs t < e''''' ==> coplanar {vec 0, v0, f v2 t, f v1 t} /\ norm v1 pow 2 = dist (f v1 t,vec 0) pow 2 /\ (dist (v0,v1) + g01 t) pow 2 = dist (f v1 t,v0) pow 2 /\ (?t'. &0 < t' /\ t' % (f v1 t cross v0) = -- &1 % (v0 cross f v2 t))` (C SUBGOAL_THEN ASSUME_TAC); REPEAT WEAKER_STRIP_TAC; INTRO_TAC Eyypqdw.EYYPQDW [`(vec 0):real^3`;` v0 `;`f v2 t`;`f v1 t`;`(norm v0 pow 2)`;`(norm v2 pow 2)`;`(norm v1 pow 2)`;`((dist (v0,v1)+g01 t) pow 2)`;`((dist (v0,v2)+g02 t) pow 2)`;`-- &1`]; REWRITE_TAC[VECTOR_SUB_RZERO]; DISCH_THEN MATCH_MP_TAC; ASM_SIMP_TAC[]; REWRITE_TAC[CONJ_ASSOC] THEN CONJ2_TAC; EXPAND_TAC "f"; (ASM_REWRITE_TAC[DIST_0]); TYPIFY `norm (f v2 t) pow 2 = norm v2 pow 2 /\ dist(f v2 t,v0) pow 2 = (dist(v0,v2) + g02 t) pow 2` ENOUGH_TO_SHOW_TAC; BY(DISCH_THEN (unlist REWRITE_TAC)); BY(REPLICATE_TAC 20 (FIRST_X_ASSUM MP_TAC) THEN MESON_TAC[DIST_0]); ASM_SIMP_TAC[]; REWRITE_TAC[DIST_0;DIST_SYM]; REWRITE_TAC[GSYM Trigonometry2.NOT_ZERO_EQ_POW2_LT]; REWRITE_TAC[NORM_EQ_0]; REWRITE_TAC[DIST_EQ_0]; ASM_REWRITE_TAC[]; CONJ2_TAC; BY(ASM_MESON_TAC[Planarity.notcoplanar_imp_notcollinear_fan]); TYPIFY_GOAL_THEN `(~(f v2 t = vec 0) ) /\ ~(f v2 t = v0)` (unlist REWRITE_TAC); BY(REPLICATE_TAC 12 (FIRST_X_ASSUM MP_TAC) THEN MESON_TAC[Planarity.notcoplanar_disjoint]); MATCH_MP_TAC (arith `&0 < x ==> ~(x = &0)`); BY(ASM_MESON_TAC[]); COMMENT "final kill"; TYPIFY `e'''''` EXISTS_TAC; ASM_REWRITE_TAC[IN_REAL_INTERVAL;arith `-- e < t /\ t < e <=> abs t < e`;arith `abs(&0) = &0`;GSYM CONJ_ASSOC]; REWRITE_TAC[CONJ_ASSOC] THEN CONJ2_TAC; REPEAT WEAKER_STRIP_TAC; ASM_SIMP_TAC[]; REPLICATE_TAC 2 (FIRST_X_ASSUM_ST `cross` (C INTRO_TAC [`t`])); (ASM_SIMP_TAC[]); REPEAT (GMATCH_SIMP_TAC (GSYM Collect_geom.EQ_POW2_COND)); REWRITE_TAC[DIST_POS_LE;NORM_POS_LE]; REPEAT (GMATCH_SIMP_TAC (arith `&0 < x ==> &0 <= x`)); TYPIFY_GOAL_THEN ` &0 < dist (v3,v2) + g23 t /\ &0 < dist (v0,v2) + g02 t /\ &0 < dist (v0,v1) + g01 t` (unlist REWRITE_TAC); FIRST_X_ASSUM MATCH_MP_TAC; BY(ASM_MESON_TAC[]); REWRITE_TAC[DIST_SYM]; DISCH_THEN (unlist REWRITE_TAC); DISCH_TAC; ONCE_REWRITE_TAC[SET_RULE `{a,b,c,d} = {a,b,d,c}`]; FIRST_X_ASSUM (unlist REWRITE_TAC); BY(REWRITE_TAC[DIST_0]); SUBCONJ2_TAC; REPEAT WEAKER_STRIP_TAC; EXPAND_TAC "f"; BY(ASM_REWRITE_TAC[]); DISCH_TAC; TYPIFY `f v1 (&0) = v1` (C SUBGOAL_THEN ASSUME_TAC); INTRO_TAC mk_planar_unique [`(vec 0):real^3`;`v0`;`v2`;`f v1 (&0)`;`v1`]; REWRITE_TAC[VECTOR_SUB_RZERO]; DISCH_THEN MATCH_MP_TAC; (TYPIFY `abs (&0) < e'''''` (C SUBGOAL_THEN ASSUME_TAC)); BY(REPLICATE_TAC 7 (FIRST_X_ASSUM MP_TAC) THEN REAL_ARITH_TAC); TYPIFY_GOAL_THEN `coplanar {vec 0, v0, v2, f v1 (&0)} /\ coplanar {vec 0, v0, v2, v1}` (unlist REWRITE_TAC); CONJ_TAC; FIRST_X_ASSUM_ST `coplanar` (C INTRO_TAC [`&0`]); ASM_REWRITE_TAC[]; BY(MESON_TAC[]); BY(ONCE_REWRITE_TAC[SET_RULE `{a,b,c,d} = {a,b,d,c}`] THEN ASM_REWRITE_TAC[]); CONJ_TAC; REPLICATE_TAC 4 (FIRST_X_ASSUM_ST `coplanar` kill); FIRST_X_ASSUM_ST `coplanar` MP_TAC; BY(MESON_TAC[Planarity.notcoplanar_imp_notcollinear_fan]); FIRST_X_ASSUM_ST `norm` (C INTRO_TAC [`&0`]); ASM_REWRITE_TAC[]; REPEAT (GMATCH_SIMP_TAC (GSYM Collect_geom.EQ_POW2_COND)); REWRITE_TAC[DIST_POS_LE;NORM_POS_LE;arith `x + &0 = x`]; REWRITE_TAC[DIST_0;DIST_SYM]; REPEAT WEAKER_STRIP_TAC; ASM_REWRITE_TAC[]; INTRO_TAC collinear_expand [`v0`;`v1`;`v2`]; ASM_REWRITE_TAC[]; REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM_ST `cross` MP_TAC; ASM_REWRITE_TAC[CROSS_RADD;CROSS_RMUL;CROSS_REFL]; DISCH_TAC; TYPIFY `t'/ t2` EXISTS_TAC; GMATCH_SIMP_TAC REAL_LT_DIV; FIRST_X_ASSUM_ST `(a cross b) dot (c cross d)` MP_TAC; ASM_REWRITE_TAC[CROSS_LADD;CROSS_LMUL;DOT_RADD;DOT_RMUL;CROSS_REFL;DOT_RZERO]; REWRITE_TAC[arith `t1 * &0 + x > &0 <=> &0 < x`]; GMATCH_SIMP_TAC (CONJUNCT2 Real_ext.REAL_PROP_POS_LMUL); REWRITE_TAC[DOT_POS_LT]; CONJ_TAC; REWRITE_TAC[CROSS_EQ_0]; ONCE_REWRITE_TAC[SET_RULE `{a,b,c} = {a,c,b}`]; BY(ASM_REWRITE_TAC[]); DISCH_TAC; ASM_REWRITE_TAC[]; TYPIFY `t2 % ((t' / t2) % (f v1 (&0) cross v0)) = t2 % (v1 cross v0)` ENOUGH_TO_SHOW_TAC; BY(FIRST_X_ASSUM MP_TAC THEN MESON_TAC[VECTOR_MUL_LCANCEL_IMP;arith `&0 < t ==> ~(t = &0)`]); REWRITE_TAC[VECTOR_MUL_ASSOC]; TYPIFY `t2 * t' / t2 = t'` (C SUBGOAL_THEN SUBST1_TAC); Calc_derivative.CALC_ID_TAC; BY(FIRST_X_ASSUM MP_TAC THEN REAL_ARITH_TAC); FIRST_X_ASSUM_ST `=` SUBST1_TAC; BY(VEC3_TAC); CONJ2_TAC; REPEAT WEAKER_STRIP_TAC; TYPIFY `v = v2` ASM_CASES_TAC; BY(ASM_MESON_TAC[]); TYPIFY `v = v1` ASM_CASES_TAC; BY(ASM_MESON_TAC[]); FIRST_X_ASSUM MATCH_MP_TAC; BY(ASM_REWRITE_TAC[]); REPEAT WEAKER_STRIP_TAC; TYPIFY `v = v1` ASM_CASES_TAC; BY(ASM_MESON_TAC[]); TYPIFY `v = v2` ASM_CASES_TAC; FIRST_X_ASSUM_ST `f (v2:real^3) = f1 v2` kill; ASM_REWRITE_TAC[]; FIRST_X_ASSUM MATCH_MP_TAC; ONCE_REWRITE_TAC[SET_RULE `{a,b,c,d} = {a,b,d,c}`]; BY(ASM_MESON_TAC[]); TYPIFY `f v = (\t. v)` (C SUBGOAL_THEN SUBST1_TAC); REWRITE_TAC[FUN_EQ_THM]; GEN_TAC; FIRST_X_ASSUM MATCH_MP_TAC; BY(ASM_REWRITE_TAC[]); BY(REWRITE_TAC[CONTINUOUS_CONST]) ]);; (* }}} *)
let deform_planar_exists = 
prove_by_refinement( `!V g01 g02 g23 v0 v1 v2 v3 e. ?f. ( (~coplanar {vec 0,v0,v2,v3} /\ coplanar {vec 0,v0,v1,v2} /\ v2 dot (v3 cross v0) > &0 /\ (v1 cross v0) dot (v2 cross v0) > &0 /\ ~(v1 = v2) /\ &0 < e /\ g23 real_continuous_on (real_interval (--e,e)) /\ g23 (&0) = &0 /\ g01 real_continuous_on (real_interval (--e,e)) /\ g01 (&0) = &0 /\ g02 real_continuous_on (real_interval (--e,e)) /\ g02 (&0) = &0 ==> (?e'. &0 < e' /\ deformation f V (-- e', e') /\ (!v t. ~(v = v1) /\ ~(v = v2) ==> f v t = v) /\ (!t. abs t < e' ==> coplanar {vec 0,v0,f v1 t,f v2 t} /\ dist(v0,f v1 t) = dist(v0,v1) + g01 t /\ norm(f v1 t) = norm(v1) /\ dist (f v2 t,v0) = dist(v2,v0) + g02 t /\ dist (f v2 t,v3) = dist(v2,v3)+ g23 t /\ norm(f v2 t) = norm (v2) ))))`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; TYPED_ABBREV_TAC`f1 = (\ w t. if w = v2 then mk_simplex1 (vec 0) v3 v0 (norm v3 pow 2) (norm v0 pow 2) (norm v2 pow 2) ((dist(v0,v2) + g02 t) pow 2) ((dist(v3,v2) + g23 t) pow 2) (dist(v0,v3) pow 2) else w)`; TYPED_ABBREV_TAC` f = (\ w t. if w = v2 then f1 v2 t else if w = v1 then mk_planar2 (vec 0) v0 (f1 v2 t) (norm v0 pow 2) (norm v2 pow 2) (norm v1 pow 2) ((dist(v0,v1) + g01 t) pow 2) ((dist(v0,v2) + g02 t) pow 2) (-- &1) else w) `; TYPIFY `f` EXISTS_TAC; REPEAT WEAKER_STRIP_TAC; INTRO_TAC deform_planar [`V`;` g01`;` g02`;` g23`;` v0`;` v1`;` v2`;` v3`;` e`]; ASM_REWRITE_TAC[]; LET_TAC; ASM_REWRITE_TAC[]; LET_TAC; BY(REWRITE_TAC[]) ]);;
(* }}} *)
let deform_planar_second_version = 
prove_by_refinement( `!V g12 g02 g23 v0 v1 v2 v3 e. ( let f1 = (\ w t. if w = v2 then mk_simplex1 (vec 0) v3 v0 (norm v3 pow 2) (norm v0 pow 2) (norm v2 pow 2) ((dist(v0,v2) + g02 t) pow 2) ((dist(v3,v2) + g23 t) pow 2) (dist(v0,v3) pow 2) else w) in let f = (\ w t. if w = v2 then f1 v2 t else if w = v1 then mk_planar2 (vec 0) (f1 v2 t) v0 (norm v2 pow 2) (norm v0 pow 2) (norm v1 pow 2) // skip4 ((dist(v1,v2)+ g12 t) pow 2) ((dist(v0,v2) + g02 t) pow 2) (-- &1) else w) in (~coplanar {vec 0,v0,v2,v3} /\ coplanar {vec 0,v0,v1,v2} /\ v2 dot (v3 cross v0) > &0 /\ (v1 cross v2) dot (v0 cross v2) > &0 /\ ~(v1 = v0) /\ &0 < e /\ g23 real_continuous_on (real_interval (--e,e)) /\ g23 (&0) = &0 /\ g12 real_continuous_on (real_interval (--e,e)) /\ g12 (&0) = &0 /\ g02 real_continuous_on (real_interval (--e,e)) /\ g02 (&0) = &0 ==> (?e'. &0 < e' /\ deformation f V (-- e', e') /\ (!v t. ~(v = v1) /\ ~(v = v2) ==> f v t = v) /\ (!t. abs t < e' ==> coplanar {vec 0,v0,f v1 t,f v2 t} /\ dist(f v1 t,f v2 t) = dist(v1,v2) + g12 t /\ norm(f v1 t) = norm(v1) /\ dist (f v2 t,v0) = dist(v2,v0) + g02 t /\ dist (f v2 t,v3) = dist(v2,v3)+ g23 t /\ norm(f v2 t) = norm (v2) ))))`,
(* {{{ proof *) [ REPEAT GEN_TAC; REPEAT LET_TAC; REWRITE_TAC[Localization.deformation]; REPEAT WEAKER_STRIP_TAC; COMMENT "preliminaries";
TYPIFY `{vec 0,v3,v0,v2} = { vec 0,v0,v2,v3} /\ {vec 0, v0, v3, v2} = {vec 0,v0,v2,v3}` (C SUBGOAL_THEN ASSUME_TAC); BY(SET_TAC[]); TYPIFY `~(v1 = vec 0) /\ ~(v1 = v2)` (C SUBGOAL_THEN ASSUME_TAC); REWRITE_TAC[GSYM DE_MORGAN_THM] THEN DISCH_TAC THEN FIRST_X_ASSUM DISJ_CASES_TAC THEN FIRST_X_ASSUM_ST `(v1 cross v0) dot (v2 cross v0)` MP_TAC THEN ASM_REWRITE_TAC[]; BY(REWRITE_TAC[CROSS_LZERO;DOT_LZERO] THEN REAL_ARITH_TAC); BY(REWRITE_TAC[CROSS_REFL;DOT_LZERO] THEN REAL_ARITH_TAC); TYPIFY `~(v0 = vec 0) /\ ~(v2 = vec 0) /\ ~(v3 = vec 0) /\ ~(v0 = v2) /\ ~(v0 = v3) /\ ~(v2 = v3)` (C SUBGOAL_THEN ASSUME_TAC); BY(ASM_MESON_TAC[Planarity.notcoplanar_disjoint]); TYPIFY `~collinear {vec 0,v0,v3} /\ ~collinear {vec 0,v0,v2} /\ ~collinear {vec 0,v2,v3}` (C SUBGOAL_THEN ASSUME_TAC); BY(ASM_MESON_TAC[Planarity.notcoplanar_imp_notcollinear_fan]); COMMENT "easy continuity"; TYPIFY `&0 IN real_interval( --e,e)` (C SUBGOAL_THEN ASSUME_TAC); REWRITE_TAC[IN_REAL_INTERVAL]; BY(ASM_SIMP_TAC[arith `&0 < e ==> --e < &0`]); TYPIFY `g23 real_continuous atreal (&0) /\ g12 real_continuous atreal (&0) /\ g02 real_continuous atreal (&0)` (C SUBGOAL_THEN ASSUME_TAC); BY(ASM_MESON_TAC[REAL_CONTINUOUS_ON_EQ_REAL_CONTINUOUS_AT;Ocbicby.REAL_OPEN_REAL_INTERVAL]); TYPIFY `(\t. delta_x (norm v3 pow 2) (norm v0 pow 2) (norm v2 pow 2) ((dist(v0,v2)+g02 t) pow 2) ((dist(v3,v2) + g23 t) pow 2) (dist(v0,v3) pow 2)) real_continuous atreal (&0)` (C SUBGOAL_THEN ASSUME_TAC); REWRITE_TAC[Sphere.delta_x]; BY(REPEAT (ASM_REWRITE_TAC[REAL_CONTINUOUS_CONST] THEN REPEAT CONJ_TAC THEN (MATCH_MP_TAC REAL_CONTINUOUS_ADD ORELSE MATCH_MP_TAC REAL_CONTINUOUS_MUL ORELSE MATCH_MP_TAC REAL_CONTINUOUS_POW ORELSE MATCH_MP_TAC REAL_CONTINUOUS_SUB))); TYPIFY `&0 < delta_x (norm v3 pow 2) (norm v0 pow 2) (norm v2 pow 2) ((dist (v0,v2)) pow 2) ((dist (v3,v2)) pow 2) (dist (v0,v3) pow 2)` (C SUBGOAL_THEN ASSUME_TAC); REWRITE_TAC[GSYM Sphere.delta_y;arith `x pow 2 = x*x`;GSYM DIST_0]; FIRST_X_ASSUM_ST `coplanar` kill; FIRST_X_ASSUM_ST `coplanar` MP_TAC; ONCE_REWRITE_TAC[SET_RULE `{a,b,c,d} = {a,d,b,c}`]; REWRITE_TAC[ Oxlzlez.coplanar_delta_y]; BY(REWRITE_TAC[DIST_SYM]); TYPIFY `&0 < ups_x (norm v0 pow 2) (norm v2 pow 2) ((dist (v0,v2)) pow 2)` (C SUBGOAL_THEN ASSUME_TAC); FIRST_X_ASSUM_ST `collinear` MP_TAC; (REWRITE_TAC[Collect_geom2.NOT_COL_EQ_UPS_X_POS;DIST_0]); BY(DISCH_THEN (unlist REWRITE_TAC)); TYPIFY `~collinear {vec 0,v1,v2}` (C SUBGOAL_THEN ASSUME_TAC); REWRITE_TAC[GSYM CROSS_EQ_0]; DISCH_TAC; FIRST_X_ASSUM_ST `(a cross b) dot (c cross d)` MP_TAC; ASM_REWRITE_TAC[DOT_LZERO]; BY(REAL_ARITH_TAC); TYPIFY `&0 < ups_x (norm v1 pow 2) (norm v2 pow 2) ((dist (v1,v2)) pow 2)` (C SUBGOAL_THEN ASSUME_TAC); FIRST_X_ASSUM_ST `collinear` MP_TAC; BY(REWRITE_TAC[Collect_geom2.NOT_COL_EQ_UPS_X_POS;DIST_0]); TYPIFY `?e1. &0 < e1 /\ (!t. abs t < e1 ==> &0 < delta_x (norm v3 pow 2) (norm v0 pow 2) (norm v2 pow 2) ((dist(v0,v2) + g02 t) pow 2) ((dist(v3,v2) + g23 t) pow 2) (dist(v0,v3) pow 2))` (C SUBGOAL_THEN ASSUME_TAC); INTRO_TAC continuous_nbd_pos [`(\t. delta_x (norm v3 pow 2) (norm v0 pow 2) (norm v2 pow 2) ((dist (v0,v2)+g02 t) pow 2) ((dist (v3,v2) + g23 t) pow 2) (dist (v0,v3) pow 2))`;`&0`]; BY((ASM_REWRITE_TAC[arith `x + &0 = x`;arith `abs (t' - &0) = abs t'`])); FIRST_X_ASSUM MP_TAC THEN REPEAT WEAKER_STRIP_TAC; TYPIFY `?e2. &0 < e2 /\ (!t. abs t < e2 ==> &0 < dist (v3,v2) + g23 t /\ &0 < dist(v0,v2)+g02 t /\ &0 < dist(v1,v2)+g12 t)` (C SUBGOAL_THEN ASSUME_TAC); TYPIFY `(\t. (dist (v3,v2) + g23 t) ) real_continuous atreal (&0) /\ (\t. (dist (v0,v2) + g02 t) ) real_continuous atreal (&0) /\ (\t. (dist (v1,v2) + g12 t) ) real_continuous atreal (&0)` ENOUGH_TO_SHOW_TAC; REPEAT WEAKER_STRIP_TAC; INTRO_TAC continuous_nbd_pos [`(\t. (dist (v3,v2) + g23 t) )`;`&0`]; INTRO_TAC continuous_nbd_pos [`(\t. (dist (v0,v2) + g02 t) )`;`&0`]; INTRO_TAC continuous_nbd_pos [`(\t. (dist (v1,v2) + g12 t) )`;`&0`]; ASM_REWRITE_TAC[arith `x + &0 = x`;GSYM DIST_NZ;arith `abs (t' - &0) = abs t'`]; REPEAT WEAKER_STRIP_TAC; INTRO_TAC epsilon_pair [`e'`;`e''`] THEN ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; INTRO_TAC epsilon_pair [`e''''`;`e'''`] THEN ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; BY(TYPIFY `e'''''` EXISTS_TAC THEN ASM_MESON_TAC[]); BY(REPEAT CONJ_TAC THEN (REPEAT (ASM_REWRITE_TAC[REAL_CONTINUOUS_CONST] THEN REPEAT CONJ_TAC THEN (MATCH_MP_TAC REAL_CONTINUOUS_ADD ORELSE MATCH_MP_TAC REAL_CONTINUOUS_MUL ORELSE MATCH_MP_TAC REAL_CONTINUOUS_POW ORELSE MATCH_MP_TAC REAL_CONTINUOUS_SUB)))); FIRST_X_ASSUM MP_TAC THEN REPEAT WEAKER_STRIP_TAC; TYPIFY `!t. abs t < e2 ==> &0 < (dist (v3,v2) + g23 t) pow 2 /\ &0 < (dist (v0,v2) + g02 t) pow 2 /\ &0 < (dist (v1,v2) + g12 t) pow 2` (C SUBGOAL_THEN ASSUME_TAC); REPEAT WEAKER_STRIP_TAC; REWRITE_TAC[GSYM Trigonometry2.NOT_ZERO_EQ_POW2_LT]; BY(ASM_SIMP_TAC[arith `&0 < x ==> ~(x = &0)`]); INTRO_TAC epsilon_pair [`e1`;`e2`] THEN ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; COMMENT "distances on 023 triangle"; TYPIFY `!t. abs t < e'' ==> norm v2 pow 2 = dist (f v2 t,vec 0) pow 2 /\ (dist (v0,v2)+g02 t) pow 2 = dist (f v2 t,v0) pow 2 /\ (dist (v3,v2) + g23 t) pow 2 = dist (f v2 t,v3) pow 2 /\ v3 dot (v0 cross f v2 t) > &0` (C SUBGOAL_THEN ASSUME_TAC); REPEAT WEAKER_STRIP_TAC; INTRO_TAC PQCSXWG1_SYM [`(vec 0):real^3`;` v0 `;`v3`;`f v2 t`;` (norm v0 pow 2)`;` (norm v3 pow 2)`;`(norm v2 pow 2)`;` ((dist (v3,v2) + g23 t) pow 2)`;` ((dist (v0,v2)+ g02 t ) pow 2)`;` (dist (v0,v3) pow 2)`]; REWRITE_TAC[VECTOR_SUB_RZERO]; DISCH_THEN MATCH_MP_TAC; ASM_SIMP_TAC[]; REWRITE_TAC[CONJ_ASSOC] THEN CONJ2_TAC; EXPAND_TAC "f"; (REWRITE_TAC[]); EXPAND_TAC "f1"; BY(REWRITE_TAC[]); CONJ2_TAC; FIRST_X_ASSUM_ST `delta_x` (C INTRO_TAC [`t`]); ASM_SIMP_TAC[]; BY(MESON_TAC[Merge_ineq.delta_x_sym]); REWRITE_TAC[DIST_0]; REWRITE_TAC[GSYM Trigonometry2.NOT_ZERO_EQ_POW2_LT]; REWRITE_TAC[GSYM DIST_0]; BY(ASM_REWRITE_TAC[DIST_EQ_0]); COMMENT "continuity at f v2 t"; INTRO_TAC epsilon_pair [`e`;`e''`] THEN ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; TYPIFY `!t. abs t < e''' /\ ~coplanar{vec 0,v0,f v2 t,v3} ==> f v2 continuous atreal t` (C SUBGOAL_THEN ASSUME_TAC); REPEAT WEAKER_STRIP_TAC; TYPIFY `g23 real_continuous atreal t /\ g02 real_continuous atreal t` (C SUBGOAL_THEN ASSUME_TAC); REPEAT (FIRST_X_ASSUM_ST `real_continuous_on` MP_TAC); REPEAT (GMATCH_SIMP_TAC REAL_CONTINUOUS_ON_EQ_REAL_CONTINUOUS_AT); REWRITE_TAC[ Ocbicby.REAL_OPEN_REAL_INTERVAL;IN_REAL_INTERVAL;arith `-- e < t /\ t < e <=> abs t < e`]; BY(REPEAT WEAKER_STRIP_TAC THEN CONJ_TAC THEN FIRST_X_ASSUM MATCH_MP_TAC THEN FIRST_X_ASSUM MATCH_MP_TAC THEN ASM_REWRITE_TAC[]); INTRO_TAC Pqcsxwg.PQCSXWG2_ATREAL [`(\ (t:real). (vec 0):real^3)`;`\ (t:real). v3`;`\ (t:real). v0`;`\ (t:real). (norm v3 pow 2)`;`\ (t:real). (norm v0 pow 2)`;`\ (t:real). (norm v2 pow 2)`;`\ (t:real). ((dist (v0,v2)+g02 t) pow 2)`;`\ (t:real). ((dist (v3,v2)+ g23 t) pow 2)`;`\ (t:real). (dist (v0,v3) pow 2)`;`t`]; REWRITE_TAC[CONTINUOUS_CONST;REAL_CONTINUOUS_CONST]; EXPAND_TAC "f"; REWRITE_TAC[]; EXPAND_TAC "f1"; REWRITE_TAC[]; DISCH_THEN MATCH_MP_TAC; ASM_SIMP_TAC[]; REWRITE_TAC[DIST_0;DIST_SYM]; ONCE_REWRITE_TAC[SET_RULE `{a,b,c} = {a,c,b}`] THEN ASM_REWRITE_TAC[]; BY(CONJ_TAC THEN ((REPEAT (ASM_REWRITE_TAC[REAL_CONTINUOUS_CONST] THEN REPEAT CONJ_TAC THEN (MATCH_MP_TAC REAL_CONTINUOUS_ADD ORELSE MATCH_MP_TAC REAL_CONTINUOUS_MUL ORELSE MATCH_MP_TAC REAL_CONTINUOUS_POW ORELSE MATCH_MP_TAC REAL_CONTINUOUS_SUB))))); COMMENT "coplanarity"; TYPIFY `f v2 (&0) = v2` (C SUBGOAL_THEN ASSUME_TAC); EXPAND_TAC "f"; EXPAND_TAC "f1"; ASM_REWRITE_TAC[arith `x + &0 = x`]; INTRO_TAC mk_simplex_uniq [`(vec 0):real^3`;`v3`;`v0`;`v2`]; REWRITE_TAC[GSYM DIST_0;DIST_SYM]; DISCH_THEN MATCH_MP_TAC; REWRITE_TAC[VECTOR_SUB_RZERO]; ASM_REWRITE_TAC[]; REPLICATE_TAC 2 (FIRST_X_ASSUM_ST `cross` kill); FIRST_X_ASSUM_ST `cross` MP_TAC; MATCH_MP_TAC (arith `a = b ==> a > &0 ==> b > &0`); BY(VEC3_TAC); TYPIFY `f v2 continuous atreal (&0)` (C SUBGOAL_THEN ASSUME_TAC); FIRST_X_ASSUM MATCH_MP_TAC; BY(ASM_REWRITE_TAC[arith `abs(&0) = &0`]); INTRO_TAC Zlzthic.NONPLANAR_OPEN [`\ (t:real). (vec 0):real^3`;`\ (t:real). v0`;`\ (t:real). v3`;`f v2`;`&0`]; ASM_REWRITE_TAC[CONTINUOUS_CONST;arith `abs(&0 - t)= abs t`]; REPEAT WEAKER_STRIP_TAC; COMMENT "non collinearity 0, v0, v1"; TYPIFY `?e3. &0 < e3 /\ (!t. abs t < e3 ==> &0 < ups_x (norm v1 pow 2) (norm v2 pow 2) ((dist (v1,v2) + g12 t) pow 2) /\ &0 < ups_x (norm v0 pow 2) (norm v2 pow 2) ((dist (v0,v2) + g02 t) pow 2))` (C SUBGOAL_THEN ASSUME_TAC); TYPIFY `(\t. ups_x (norm v1 pow 2) (norm v2 pow 2) ((dist (v1,v2) + g12 t) pow 2)) real_continuous atreal (&0) /\ (\t. ups_x (norm v0 pow 2) (norm v2 pow 2) ((dist (v0,v2) + g02 t) pow 2)) real_continuous atreal (&0)` ENOUGH_TO_SHOW_TAC; REPEAT WEAKER_STRIP_TAC; INTRO_TAC continuous_nbd_pos [`(\t. ups_x (norm v1 pow 2) (norm v2 pow 2) ((dist (v1,v2) + g12 t) pow 2))`;`&0`]; INTRO_TAC continuous_nbd_pos [`(\t. ups_x (norm v0 pow 2) (norm v2 pow 2) ((dist (v0,v2) + g02 t) pow 2))`;`&0`]; ASM_REWRITE_TAC[arith `x + &0 = x`;arith `abs (t - &0) = abs t`]; REPEAT WEAKER_STRIP_TAC; INTRO_TAC epsilon_pair [`e''''`;`e'''''`] THEN ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; TYPIFY `e''''''` EXISTS_TAC; ASM_REWRITE_TAC[]; BY(REPLICATE_TAC 7 (FIRST_X_ASSUM MP_TAC) THEN MESON_TAC[]); BY(REWRITE_TAC[Sphere.ups_x] THEN CONJ_TAC THEN ((REPEAT (ASM_REWRITE_TAC[REAL_CONTINUOUS_CONST] THEN REPEAT CONJ_TAC THEN (MATCH_MP_TAC REAL_CONTINUOUS_ADD ORELSE MATCH_MP_TAC REAL_CONTINUOUS_MUL ORELSE MATCH_MP_TAC REAL_CONTINUOUS_POW ORELSE MATCH_MP_TAC REAL_CONTINUOUS_SUB))))); FIRST_X_ASSUM MP_TAC THEN REPEAT WEAKER_STRIP_TAC; INTRO_TAC epsilon_pair [`e3`;`e'`] THEN ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; INTRO_TAC epsilon_pair [`e'''`;`e''''`] THEN ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; COMMENT "continuity of f v1"; TYPIFY `!t. abs t < e''''' ==> f v1 continuous atreal t` (C SUBGOAL_THEN ASSUME_TAC); REPEAT WEAKER_STRIP_TAC; TYPIFY `f v2 continuous atreal t /\ g12 real_continuous atreal t /\ g02 real_continuous atreal t` (C SUBGOAL_THEN ASSUME_TAC); CONJ_TAC; FIRST_X_ASSUM MATCH_MP_TAC; ASM_REWRITE_TAC[]; ONCE_REWRITE_TAC[SET_RULE `{a,b,c,d} = {a,b,d,c}`]; BY(CONJ_TAC THEN ASM_MESON_TAC[]); REPEAT (FIRST_X_ASSUM_ST `real_continuous_on` MP_TAC); REPEAT (GMATCH_SIMP_TAC REAL_CONTINUOUS_ON_EQ_REAL_CONTINUOUS_AT); REWRITE_TAC[ Ocbicby.REAL_OPEN_REAL_INTERVAL;IN_REAL_INTERVAL;arith `-- e < t /\ t < e <=> abs t < e`]; REPEAT WEAKER_STRIP_TAC THEN CONJ_TAC THEN FIRST_X_ASSUM MATCH_MP_TAC THEN FIRST_X_ASSUM MATCH_MP_TAC THEN ASM_REWRITE_TAC[]; BY(ASM_MESON_TAC[]); BY(ASM_MESON_TAC[]); INTRO_TAC mk_planar2_continuous [`(\ (t:real). (vec 0):real^3)`;`f1 v2`;`\ (t:real). v0`; `\ (t:real). (norm v2 pow 2)`;`\ (t:real). (norm v0 pow 2)`;`\ (t:real). (norm v1 pow 2)`; `\ (t:real). ((dist (v1,v2)+g12 t) pow 2)`;`\ (t:real). ((dist (v0,v2)+ g02 t) pow 2)`;`t`;`-- &1`]; REWRITE_TAC[CONTINUOUS_CONST;REAL_CONTINUOUS_CONST]; EXPAND_TAC "f"; ASM_REWRITE_TAC[]; DISCH_THEN MATCH_MP_TAC; TYPIFY_GOAL_THEN `&0 < ups_x (norm v2 pow 2) (norm v0 pow 2) ((dist (v0,v2) + g02 t) pow 2) /\ &0 < ups_x (norm v2 pow 2) (norm v1 pow 2) ((dist (v1,v2) + g12 t) pow 2)` (unlist REWRITE_TAC); FIRST_X_ASSUM_ST `ups_x` (C INTRO_TAC [`t`]); ANTS_TAC; BY(ASM_MESON_TAC[]); REWRITE_TAC[DIST_SYM]; BY(MESON_TAC[Merge_ineq.ups_x_sym]); REWRITE_TAC[GSYM Trigonometry2.NOT_ZERO_EQ_POW2_LT]; REWRITE_TAC[NORM_EQ_0]; ASM_REWRITE_TAC[]; CONJ_TAC; FIRST_X_ASSUM MP_TAC; EXPAND_TAC "f"; ASM_REWRITE_TAC[]; TYPIFY `(\t. f1 v2 t) = f1 v2` (C SUBGOAL_THEN SUBST1_TAC); BY(REWRITE_TAC[FUN_EQ_THM]); BY(MESON_TAC[]); BY(CONJ_TAC THEN REPEAT (REPEAT CONJ_TAC THEN (MATCH_MP_TAC REAL_CONTINUOUS_ADD ORELSE MATCH_MP_TAC REAL_CONTINUOUS_MUL ORELSE MATCH_MP_TAC REAL_CONTINUOUS_POW ORELSE MATCH_MP_TAC REAL_CONTINUOUS_SUB) THEN (ASM_REWRITE_TAC[REAL_CONTINUOUS_CONST] ))); COMMENT "distances on 012 triangle"; TYPIFY `f1 v2 = f v2` (C SUBGOAL_THEN ASSUME_TAC); EXPAND_TAC "f"; BY(REWRITE_TAC[FUN_EQ_THM]); TYPIFY `!t. abs t < e''''' ==> coplanar {vec 0, f v2 t, v0, f v1 t} /\ norm v1 pow 2 = dist (f v1 t,vec 0) pow 2 /\ (dist (v1,v2) + g12 t) pow 2 = dist (f v1 t,f v2 t) pow 2 /\ (?t'. &0 < t' /\ t' % (f v1 t cross f v2 t) = -- &1 % (f v2 t cross v0))` (C SUBGOAL_THEN ASSUME_TAC); REPEAT WEAKER_STRIP_TAC; INTRO_TAC Eyypqdw.EYYPQDW [`(vec 0):real^3`;`f v2 t`;` v0 `;`f v1 t`;`(norm v2 pow 2)`;`(norm v0 pow 2)`;`(norm v1 pow 2)`;`((dist (v1,v2)+g12 t) pow 2)`;`((dist (v0,v2)+g02 t) pow 2)`;`-- &1`]; REWRITE_TAC[VECTOR_SUB_RZERO]; DISCH_THEN MATCH_MP_TAC; ASM_SIMP_TAC[]; REWRITE_TAC[CONJ_ASSOC] THEN CONJ2_TAC; EXPAND_TAC "f"; (ASM_REWRITE_TAC[DIST_0]); TYPIFY `norm (f v2 t) pow 2 = norm v2 pow 2 /\ dist(f v2 t,v0) pow 2 = (dist(v0,v2) + g02 t) pow 2` ENOUGH_TO_SHOW_TAC; BY(DISCH_THEN (unlist REWRITE_TAC)); BY(REPLICATE_TAC 20 (FIRST_X_ASSUM MP_TAC) THEN MESON_TAC[DIST_0]); TYPIFY `dist(f v2 t,vec 0) pow 2 = norm v2 pow 2` (C SUBGOAL_THEN SUBST1_TAC); BY(REPLICATE_TAC 20 (FIRST_X_ASSUM MP_TAC) THEN MESON_TAC[]); CONJ2_TAC; FIRST_X_ASSUM_ST `ups_x` (C INTRO_TAC [`t`]); ANTS_TAC; BY(ASM_MESON_TAC[]); BY(MESON_TAC[Merge_ineq.ups_x_sym]); REWRITE_TAC[DIST_0;DIST_SYM]; REWRITE_TAC[GSYM Trigonometry2.NOT_ZERO_EQ_POW2_LT]; REWRITE_TAC[NORM_EQ_0]; REWRITE_TAC[DIST_EQ_0]; ASM_REWRITE_TAC[]; CONJ2_TAC; ONCE_REWRITE_TAC[SET_RULE `{a,b,c} = {a,c,b}`]; BY(ASM_MESON_TAC[Planarity.notcoplanar_imp_notcollinear_fan]); CONJ2_TAC; BY(REPLICATE_TAC 12 (FIRST_X_ASSUM MP_TAC) THEN MESON_TAC[Planarity.notcoplanar_disjoint]); MATCH_MP_TAC (arith `&0 < x ==> ~(x = &0)`); BY(ASM_MESON_TAC[]); COMMENT "final kill"; TYPIFY `e'''''` EXISTS_TAC; ASM_REWRITE_TAC[IN_REAL_INTERVAL;arith `-- e < t /\ t < e <=> abs t < e`;arith `abs(&0) = &0`;GSYM CONJ_ASSOC]; REWRITE_TAC[CONJ_ASSOC] THEN CONJ2_TAC; REPEAT WEAKER_STRIP_TAC; ASM_SIMP_TAC[]; REPLICATE_TAC 2 (FIRST_X_ASSUM_ST `cross` (C INTRO_TAC [`t`])); (ASM_SIMP_TAC[]); REPEAT (GMATCH_SIMP_TAC (GSYM Collect_geom.EQ_POW2_COND)); REWRITE_TAC[DIST_POS_LE;NORM_POS_LE]; REPEAT (GMATCH_SIMP_TAC (arith `&0 < x ==> &0 <= x`)); TYPIFY_GOAL_THEN ` &0 < dist (v3,v2) + g23 t /\ &0 < dist (v0,v2) + g02 t /\ &0 < dist (v1,v2) + g12 t` (unlist REWRITE_TAC); FIRST_X_ASSUM MATCH_MP_TAC; BY(ASM_MESON_TAC[]); REWRITE_TAC[DIST_SYM]; DISCH_THEN (unlist REWRITE_TAC); DISCH_TAC; ONCE_REWRITE_TAC[SET_RULE `{a,b,c,d} = {a,d,b,c}`]; FIRST_X_ASSUM (unlist REWRITE_TAC); BY(REWRITE_TAC[DIST_0]); SUBCONJ2_TAC; REPEAT WEAKER_STRIP_TAC; EXPAND_TAC "f"; BY(ASM_REWRITE_TAC[]); DISCH_TAC; TYPIFY `f v1 (&0) = v1` (C SUBGOAL_THEN ASSUME_TAC); INTRO_TAC mk_planar_unique [`(vec 0):real^3`;`v2`;`v0`;`f v1 (&0)`;`v1`]; REWRITE_TAC[VECTOR_SUB_RZERO]; DISCH_THEN MATCH_MP_TAC; (TYPIFY `abs (&0) < e'''''` (C SUBGOAL_THEN ASSUME_TAC)); BY(REPLICATE_TAC 7 (FIRST_X_ASSUM MP_TAC) THEN REAL_ARITH_TAC); TYPIFY_GOAL_THEN `coplanar {vec 0, v2, v0, f v1 (&0)} /\ coplanar {vec 0, v2, v0, v1}` (unlist REWRITE_TAC); CONJ_TAC; FIRST_X_ASSUM_ST `coplanar` (C INTRO_TAC [`&0`]); ASM_REWRITE_TAC[]; BY(MESON_TAC[]); BY(ONCE_REWRITE_TAC[SET_RULE `{a,b,c,d} = {a,c,d,b}`] THEN ASM_REWRITE_TAC[]); CONJ_TAC; REPLICATE_TAC 4 (FIRST_X_ASSUM_ST `coplanar` kill); ONCE_REWRITE_TAC[SET_RULE `{a,b,c} = {a,c,b}`]; FIRST_X_ASSUM_ST `coplanar` MP_TAC; BY(MESON_TAC[Planarity.notcoplanar_imp_notcollinear_fan]); FIRST_X_ASSUM_ST `norm` (C INTRO_TAC [`&0`]); ASM_REWRITE_TAC[]; REPEAT (GMATCH_SIMP_TAC (GSYM Collect_geom.EQ_POW2_COND)); REWRITE_TAC[DIST_POS_LE;NORM_POS_LE;arith `x + &0 = x`]; REWRITE_TAC[DIST_0;DIST_SYM]; REPEAT WEAKER_STRIP_TAC; ASM_REWRITE_TAC[]; INTRO_TAC collinear_expand [`v1`;`v2`;`v0`]; ONCE_REWRITE_TAC[SET_RULE `{a,b,c,d} = {a,d,b,c}`]; ASM_REWRITE_TAC[]; REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM_ST `cross` MP_TAC; ASM_REWRITE_TAC[CROSS_RADD;CROSS_RMUL;CROSS_REFL]; DISCH_TAC; TYPIFY `t'/ t1` EXISTS_TAC; GMATCH_SIMP_TAC REAL_LT_DIV; FIRST_X_ASSUM_ST `(a cross b) dot (c cross d)` MP_TAC; ASM_REWRITE_TAC[CROSS_LADD;CROSS_LMUL;DOT_RADD;DOT_RMUL;CROSS_REFL;DOT_RZERO]; REWRITE_TAC[arith `x + t2 * &0 > &0 <=> &0 < x`]; GMATCH_SIMP_TAC (CONJUNCT2 Real_ext.REAL_PROP_POS_LMUL); REWRITE_TAC[DOT_POS_LT]; CONJ_TAC; REWRITE_TAC[CROSS_EQ_0]; BY(ASM_REWRITE_TAC[]); DISCH_TAC; ASM_REWRITE_TAC[]; TYPIFY `t1 % ((t' / t1) % (f v1 (&0) cross v2)) = t1 % (v1 cross v2)` ENOUGH_TO_SHOW_TAC; BY(FIRST_X_ASSUM MP_TAC THEN MESON_TAC[VECTOR_MUL_LCANCEL_IMP;arith `&0 < t ==> ~(t = &0)`]); REWRITE_TAC[VECTOR_MUL_ASSOC]; TYPIFY `t1 * t' / t1 = t'` (C SUBGOAL_THEN SUBST1_TAC); Calc_derivative.CALC_ID_TAC; BY(FIRST_X_ASSUM MP_TAC THEN REAL_ARITH_TAC); FIRST_X_ASSUM_ST `=` SUBST1_TAC; BY(VEC3_TAC); CONJ2_TAC; REPEAT WEAKER_STRIP_TAC; TYPIFY `v = v2` ASM_CASES_TAC; BY(ASM_MESON_TAC[]); TYPIFY `v = v1` ASM_CASES_TAC; BY(ASM_MESON_TAC[]); FIRST_X_ASSUM MATCH_MP_TAC; BY(ASM_REWRITE_TAC[]); REPEAT WEAKER_STRIP_TAC; TYPIFY `v = v1` ASM_CASES_TAC; BY(ASM_MESON_TAC[]); TYPIFY `v = v2` ASM_CASES_TAC; FIRST_X_ASSUM_ST `f (v2:real^3) = f1 v2` kill; ASM_REWRITE_TAC[]; FIRST_X_ASSUM MATCH_MP_TAC; ONCE_REWRITE_TAC[SET_RULE `{a,b,c,d} = {a,b,d,c}`]; BY(ASM_MESON_TAC[]); TYPIFY `f v = (\t. v)` (C SUBGOAL_THEN SUBST1_TAC); REWRITE_TAC[FUN_EQ_THM]; GEN_TAC; FIRST_X_ASSUM MATCH_MP_TAC; BY(ASM_REWRITE_TAC[]); BY(REWRITE_TAC[CONTINUOUS_CONST]) ]);; (* }}} *)
let deform_planar_exists_second_version = 
prove_by_refinement( `!V g12 g02 g23 v0 v1 v2 v3 e. ?f. ( (~coplanar {vec 0,v0,v2,v3} /\ coplanar {vec 0,v0,v1,v2} /\ v2 dot (v3 cross v0) > &0 /\ (v1 cross v2) dot (v0 cross v2) > &0 /\ ~(v1 = v0) /\ &0 < e /\ g23 real_continuous_on (real_interval (--e,e)) /\ g23 (&0) = &0 /\ g12 real_continuous_on (real_interval (--e,e)) /\ g12 (&0) = &0 /\ g02 real_continuous_on (real_interval (--e,e)) /\ g02 (&0) = &0 ==> (?e'. &0 < e' /\ deformation f V (-- e', e') /\ (!v t. ~(v = v1) /\ ~(v = v2) ==> f v t = v) /\ (!t. abs t < e' ==> coplanar {vec 0,v0,f v1 t,f v2 t} /\ dist(f v1 t,f v2 t) = dist(v1,v2) + g12 t /\ norm(f v1 t) = norm(v1) /\ dist (f v2 t,v0) = dist(v2,v0) + g02 t /\ dist (f v2 t,v3) = dist(v2,v3)+ g23 t /\ norm(f v2 t) = norm (v2) ))))`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; TYPED_ABBREV_TAC `f1 = (\ w t. if w = v2 then mk_simplex1 (vec 0) v3 v0 (norm v3 pow 2) (norm v0 pow 2) (norm v2 pow 2) ((dist(v0,v2) + g02 t) pow 2) ((dist(v3,v2) + g23 t) pow 2) (dist(v0,v3) pow 2) else w)`; TYPED_ABBREV_TAC `f = (\ w t. if w = v2 then f1 v2 t else if w = v1 then mk_planar2 (vec 0) (f1 v2 t) v0 (norm v2 pow 2) (norm v0 pow 2) (norm v1 pow 2) ((dist(v1,v2)+ g12 t) pow 2) ((dist(v0,v2) + g02 t) pow 2) (-- &1) else w)`; TYPIFY `f` EXISTS_TAC; REPEAT WEAKER_STRIP_TAC; INTRO_TAC deform_planar_second_version [`V`;` g12`;` g02`;` g23`;` v0`;` v1`;` v2`;` v3`;` e`]; ASM_REWRITE_TAC[]; LET_TAC; ASM_REWRITE_TAC[]; LET_TAC; BY(REWRITE_TAC[]) ]);;
(* }}} *)
let SKOLEM_PERIODIC = 
prove_by_refinement( `!P k. (periodic P k) /\ ~(k = 0) /\ (!i e e'. e <= e' /\ P i e' ==> P i e) ==> ((!i. ?e. &0 < e /\ P i e) <=> (?e. &0 < e /\ (!i. P i e)))`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; REWRITE_TAC[TAUT `(a <=> b) <=> ((b ==> a) /\ (a ==> b))`]; CONJ_TAC; BY(MESON_TAC[]); DISCH_TAC; TYPIFY `?e1. !i. &0 < e1 /\ (i IN (0..(k-1)) ==> (P i e1))` (C SUBGOAL_THEN MP_TAC); GMATCH_SIMP_TAC (GSYM Zlzthic.SKOLEM_EPSILON); REWRITE_TAC[FINITE_NUMSEG]; CONJ_TAC; BY(ASM_MESON_TAC[arith `t < e1 /\ e1 <= e' ==> t < e'`]); GEN_TAC; BY(ASM_MESON_TAC[]); REPEAT WEAKER_STRIP_TAC; TYPIFY `e1` EXISTS_TAC; ASM_REWRITE_TAC[]; MATCH_MP_TAC Terminal.periodic_mod_reduce; TYPIFY `k` EXISTS_TAC; ASM_REWRITE_TAC[]; CONJ2_TAC; RULE_ASSUM_TAC(REWRITE_RULE[IN_NUMSEG;arith `!i. 0 <= i`]); BY(ASM_SIMP_TAC[arith `!i. ~(k=0) ==> (i < k <=> i <= k-1)`]); FIRST_X_ASSUM_ST `periodic` MP_TAC; REWRITE_TAC[Oxl_def.periodic;FUN_EQ_THM]; BY(MESON_TAC[]) ]);;
(* }}} *)
let SKOLEM_PERIODIC2 = 
prove_by_refinement( `!P k. (periodic2 P k) /\ ~(k = 0) /\ (!i j e e'. e <= e' /\ P i j e' ==> P i j e) ==> ((!i j. ?e. &0 < e /\ P i j e) <=> (?e. &0 < e /\ (!i j. P i j e)))`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; REWRITE_TAC[TAUT `(a <=> b) <=> ((b ==> a) /\ (a ==> b))`]; CONJ_TAC; BY(MESON_TAC[]); DISCH_TAC; TYPIFY `?e1. !i. &0 < e1 /\ (i IN (0..(k-1)) ==> (!j. j IN (0..(k-1)) ==> P i j e1))` (C SUBGOAL_THEN MP_TAC); GMATCH_SIMP_TAC (GSYM Zlzthic.SKOLEM_EPSILON); REWRITE_TAC[FINITE_NUMSEG]; CONJ_TAC; BY(ASM_MESON_TAC[arith `t < e1 /\ e1 <= e' ==> t < e'`]); GEN_TAC; REWRITE_TAC[MESON[arith `&0 < &1`] `(?e1. &0 < e1 /\ (a ==> (!j. j IN s ==> b j e1))) <=> (a ==> (?e1. !j. &0 < e1 /\ (j IN s ==> b j e1)))`]; DISCH_TAC; GMATCH_SIMP_TAC (GSYM Zlzthic.SKOLEM_EPSILON); REWRITE_TAC[FINITE_NUMSEG]; CONJ_TAC; BY(ASM_MESON_TAC[arith `t < e1 /\ e1 <= e' ==> t < e'`]); GEN_TAC; BY(ASM_MESON_TAC[]); REPEAT WEAKER_STRIP_TAC; TYPIFY `e1` EXISTS_TAC; SUBCONJ_TAC; BY(ASM_REWRITE_TAC[]); DISCH_TAC; MATCH_MP_TAC Terminal.periodic2_mod_reduce; TYPIFY `k` EXISTS_TAC; ASM_REWRITE_TAC[]; CONJ2_TAC; RULE_ASSUM_TAC(REWRITE_RULE[IN_NUMSEG;arith `!i. 0 <= i`]); BY(ASM_SIMP_TAC[arith `!i. ~(k=0) ==> (i < k <=> i <= k-1)`]); FIRST_X_ASSUM_ST `periodic2` MP_TAC; REWRITE_TAC[Appendix.periodic2;FUN_EQ_THM]; BY(MESON_TAC[]) ]);;
(* }}} *)
let scs_k_bounds = 
prove_by_refinement( `!s. is_scs_v39 s ==> 3 <= scs_k_v39 s /\ scs_k_v39 s <= 6`,
(* {{{ proof *) [ BY(REWRITE_TAC[Appendix.is_scs_v39] THEN REPEAT WEAKER_STRIP_TAC THEN ASM_REWRITE_TAC[]) ]);;
(* }}} *)
let deformation_BBs = 
prove_by_refinement( `!s k f v e. is_scs_v39 s /\ scs_k_v39 s = k /\ BBs_v39 s v /\ scs_generic v /\ &0 < e /\ deformation f (IMAGE v (:num)) (--e,e) /\ (!i t. (let FF = IMAGE (\i. (v i, v (SUC i))) (:num) in (t IN real_interval (-- e, e) /\ interior_angle1 (vec 0) FF (v i) = pi ==> interior_angle1 (vec 0) (IMAGE (\uv. f (FST uv) t,f (SND uv) t) FF) (f (v i) t) <= pi))) /\ // (!i. ?e0. azim (vec 0) (v i) (v (i+1)) (v (i + (k-1))) = pi ==> // (!t. abs t < e0 ==> azim (vec 0) (f (v i) t) (f (v (i+1)) t) (f (v (i+(k-1))) t) <= pi)) /\ (!i. (!t. abs t < e ==> norm (f (v i) t) = norm (v i))) /\ (!i j. ?e1. &0 < e1 /\ (scs_a_v39 s i j = dist(v i,v j) ==> (!t. abs t < e1 ==> scs_a_v39 s i j <= dist(f (v i) t,f (v j) t)))) /\ (!i j. ?e2. &0 < e2 /\ (dist(v i,v j) = scs_b_v39 s i j ==> (!t. abs t < e2 ==> dist(f (v i) t,f (v j) t) <= scs_b_v39 s i j))) ==> (?e'. &0 < e' /\ (!t. abs t < e' ==> BBs_v39 s (\i. f (v i) t))) `,
(* {{{ proof *) [ REWRITE_TAC[Appendix.BBs_v39;LET_DEF;LET_END_DEF]; REPEAT WEAKER_STRIP_TAC; TYPIFY `!t. periodic (\i. f (v i) t) (scs_k_v39 s)` (C SUBGOAL_THEN ASSUME_TAC); GEN_TAC; FIRST_X_ASSUM_ST `periodic` MP_TAC; REWRITE_TAC[Oxl_def.periodic]; BY(MESON_TAC[]); ASM_REWRITE_TAC[]; COMMENT "skolem reduction";
TYPIFY `(?e3. &0 < e3 /\ (~(k<= 3) ==> (!t. (abs t < e3 ==> convex_local_fan (IMAGE (\i. f (v i) t) (:num), IMAGE (\i. {f (v i) t, f (v (SUC i)) t}) (:num), IMAGE (\i. f (v i) t,f (v (SUC i)) t) (:num)))))) /\ (!i j. ?e1. &0 < e1 /\ (!t. abs t < e1 ==> scs_a_v39 s i j <= dist (f (v i) t,f (v j) t))) /\ (!i j. ?e2. &0 < e2 /\ (!t. abs t < e2 ==> dist (f (v i) t,f (v j) t) <= scs_b_v39 s i j))` ENOUGH_TO_SHOW_TAC; REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM_ST `scs_a_v39` MP_TAC; GMATCH_SIMP_TAC SKOLEM_PERIODIC2; CONJ_TAC; TYPIFY `k` EXISTS_TAC; nCONJ_TAC 1; BY(ASM_MESON_TAC[scs_k_bounds;arith `3 <= k ==> ~(k=0)`]); CONJ_TAC; REWRITE_TAC[Appendix.periodic2]; FIRST_X_ASSUM_ST `periodic` MP_TAC; ASM_REWRITE_TAC[Oxl_def.periodic;FUN_EQ_THM]; DISCH_TAC THEN ASM_REWRITE_TAC[]; FIRST_X_ASSUM_ST `is_scs_v39` MP_TAC; ASM_REWRITE_TAC[Appendix.is_scs_v39;Appendix.periodic2]; BY(REPEAT WEAKER_STRIP_TAC THEN ASM_REWRITE_TAC[]); ASM_REWRITE_TAC[]; REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM MATCH_MP_TAC; BY(REPLICATE_TAC 2 (FIRST_X_ASSUM MP_TAC) THEN REAL_ARITH_TAC); REPEAT WEAKER_STRIP_TAC; COMMENT "skolem on b"; FIRST_X_ASSUM_ST `scs_b_v39` MP_TAC; GMATCH_SIMP_TAC SKOLEM_PERIODIC2; CONJ_TAC; TYPIFY `k` EXISTS_TAC; nCONJ_TAC 1; BY(ASM_MESON_TAC[scs_k_bounds;arith `3 <= k ==> ~(k=0)`]); CONJ_TAC; REWRITE_TAC[Appendix.periodic2]; FIRST_X_ASSUM_ST `periodic` MP_TAC; ASM_REWRITE_TAC[Oxl_def.periodic;FUN_EQ_THM]; DISCH_TAC THEN ASM_REWRITE_TAC[]; FIRST_X_ASSUM_ST `is_scs_v39` MP_TAC; ASM_REWRITE_TAC[Appendix.is_scs_v39;Appendix.periodic2]; BY(REPEAT WEAKER_STRIP_TAC THEN ASM_REWRITE_TAC[]); ASM_REWRITE_TAC[]; REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM MATCH_MP_TAC; BY(REPLICATE_TAC 2 (FIRST_X_ASSUM MP_TAC) THEN REAL_ARITH_TAC); REPEAT WEAKER_STRIP_TAC; INTRO_TAC epsilon_quad [`e1`;`e2`;`e3`;`e`] THEN ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; TYPIFY `e''''` EXISTS_TAC; ASM_REWRITE_TAC[]; REPEAT WEAKER_STRIP_TAC; CONJ_TAC; FIRST_X_ASSUM_ST `ball_annulus` MP_TAC; REWRITE_TAC[Terminal.IMAGE_SUBSET_IN;IN_UNIV;Fnjlbxs.in_ball_annulus]; BY(ASM_SIMP_TAC[]); CONJ_TAC; REPEAT STRIP_TAC; FIRST_X_ASSUM MATCH_MP_TAC; BY(ASM_SIMP_TAC[]); FIRST_X_ASSUM MATCH_MP_TAC; BY(ASM_SIMP_TAC[]); BY(REPLICATE_TAC 12 (FIRST_X_ASSUM MP_TAC) THEN MESON_TAC[]); TYPIFY `!i. f (v i) (&0) = v i` (C SUBGOAL_THEN ASSUME_TAC); RULE_ASSUM_TAC(REWRITE_RULE[Localization.deformation;Terminal.IMAGE_SUBSET_IN;IN_UNIV]); ASM_TAC THEN REPEAT WEAKER_STRIP_TAC THEN FIRST_X_ASSUM MATCH_MP_TAC; REWRITE_TAC[IN_IMAGE;IN_UNIV]; BY(MESON_TAC[]); TYPIFY `!i j. ( \ t. dist(f (v i) t,f (v j) t)) real_continuous atreal (&0)` (C SUBGOAL_THEN ASSUME_TAC); REPEAT WEAKER_STRIP_TAC; RULE_ASSUM_TAC (REWRITE_RULE[Localization.deformation]) THEN ASM_TAC THEN REPEAT WEAKER_STRIP_TAC; TYPIFY `!i. (f (v i)) continuous atreal (&0)` (C SUBGOAL_THEN ASSUME_TAC); GEN_TAC; FIRST_X_ASSUM_ST `continuous` (C INTRO_TAC [`v i`;`&0`]); DISCH_THEN MATCH_MP_TAC; ASM_REWRITE_TAC[IN_IMAGE;IN_UNIV]; BY(MESON_TAC[]); (REPEAT (REPEAT CONJ_TAC THEN (MATCH_MP_TAC Local_lemmas1.CON_ATREAL_REAL_CON2_REDO ORELSE MATCH_MP_TAC REAL_CONTINUOUS_ADD ORELSE MATCH_MP_TAC REAL_CONTINUOUS_MUL ORELSE MATCH_MP_TAC REAL_CONTINUOUS_POW ORELSE MATCH_MP_TAC REAL_CONTINUOUS_SUB) THEN (ASM_REWRITE_TAC[REAL_CONTINUOUS_CONST] ))); TYPIFY_GOAL_THEN `!i w. (\ t. f w t) = f w` (unlist ASM_REWRITE_TAC); BY(REWRITE_TAC[FUN_EQ_THM]); nCONJ_TAC 2; REPEAT WEAKER_STRIP_TAC; TYPIFY `dist(v i,v j) = scs_b_v39 s i j` ASM_CASES_TAC; BY(REPLICATE_TAC 6 (FIRST_X_ASSUM MP_TAC) THEN MESON_TAC[]); INTRO_TAC continuous_nbd_pos [`(\t. scs_b_v39 s i j - dist(f (v i) t,f (v j) t))`;`&0`]; ANTS_TAC; CONJ2_TAC; REWRITE_TAC[]; BY(ASM_MESON_TAC[arith `d <= b /\ ~(d = b) ==> &0 < b - d`]); BY((REPEAT (REPEAT CONJ_TAC THEN ( MATCH_MP_TAC REAL_CONTINUOUS_ADD ORELSE MATCH_MP_TAC REAL_CONTINUOUS_MUL ORELSE MATCH_MP_TAC REAL_CONTINUOUS_POW ORELSE MATCH_MP_TAC REAL_CONTINUOUS_SUB) THEN (ASM_REWRITE_TAC[REAL_CONTINUOUS_CONST] )))); REWRITE_TAC[arith `abs (t - &0) = abs t`]; BY(MESON_TAC[arith `&0 < b - d ==> d <= b`]); ASM_REWRITE_TAC[]; CONJ2_TAC; REPEAT WEAKER_STRIP_TAC; TYPIFY `scs_a_v39 s i j = dist(v i,v j)` ASM_CASES_TAC; BY(REPLICATE_TAC 9 (FIRST_X_ASSUM MP_TAC) THEN MESON_TAC[]); INTRO_TAC continuous_nbd_pos [`(\t. dist(f (v i) t,f (v j) t) - scs_a_v39 s i j) `;`&0`]; ANTS_TAC; CONJ2_TAC; REWRITE_TAC[]; BY(ASM_MESON_TAC[arith `a <= d /\ ~(a =d) ==> &0 < d - a`]); BY((REPEAT (REPEAT CONJ_TAC THEN ( MATCH_MP_TAC REAL_CONTINUOUS_ADD ORELSE MATCH_MP_TAC REAL_CONTINUOUS_MUL ORELSE MATCH_MP_TAC REAL_CONTINUOUS_POW ORELSE MATCH_MP_TAC REAL_CONTINUOUS_SUB) THEN (ASM_REWRITE_TAC[REAL_CONTINUOUS_CONST] )))); REWRITE_TAC[arith `abs (t - &0) = abs t`]; BY(MESON_TAC[arith `&0 < d - a ==> a <= d`]); TYPED_ABBREV_TAC `V = IMAGE v (:num)`; TYPED_ABBREV_TAC `E = IMAGE (\i. {v i, v (SUC i)}) (:num)`; TYPED_ABBREV_TAC `FF = IMAGE (\i. (v i, v (SUC i))) (:num)`; ASM_CASES_TAC `(k <= 3)`; ASM_REWRITE_TAC[]; BY(MESON_TAC[arith `&0 < &1`]); ASM_REWRITE_TAC[]; INTRO_TAC Zlzthic.ZLZTHIC [`-- e`;`e`;`V`;`E`;`FF`;`f`]; MATCH_MP_TAC (TAUT (`(b ==> c) /\ a ==> ((a ==> b) ==> c)`)); CONJ_TAC; REWRITE_TAC[arith `-- e < t /\ t < e <=> abs t < e`]; REPEAT WEAKER_STRIP_TAC; TYPIFY `e'` EXISTS_TAC; ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM_ST `convex_local_fan` (C INTRO_TAC [`t`]); ASM_REWRITE_TAC[]; TYPIFY `IMAGE (\v. f v t) V = IMAGE (\i. f (v i) t) (:num) /\ IMAGE (IMAGE (\v. f v t)) E = IMAGE (\i. {f (v i) t, f (v (SUC i)) t}) (:num) /\ IMAGE (\uv. f (FST uv) t,f (SND uv) t) FF = IMAGE (\i. f (v i) t,f (v (SUC i)) t) (:num)` ENOUGH_TO_SHOW_TAC; DISCH_THEN (unlist REWRITE_TAC); BY(DISCH_THEN (unlist REWRITE_TAC)); MAP_EVERY EXPAND_TAC ["V";"E";"FF"]; REWRITE_TAC[GSYM IMAGE_o]; BY(REPEAT CONJ_TAC THEN AP_THM_TAC THEN AP_TERM_TAC THEN REWRITE_TAC[FUN_EQ_THM;o_THM;IMAGE_CLAUSES]); ASM_REWRITE_TAC[]; CONJ_TAC; BY(ASM_MESON_TAC[]); CONJ_TAC; BY(ASM_MESON_TAC[Appendix.scs_generic]); REPEAT WEAKER_STRIP_TAC; TYPIFY `?i. v' = v i` (C SUBGOAL_THEN MP_TAC); FIRST_X_ASSUM_ST `(v':real^3) IN V` MP_TAC; EXPAND_TAC "V"; BY(REWRITE_TAC[IN_IMAGE;IN_UNIV]); REPEAT WEAKER_STRIP_TAC; ASM_REWRITE_TAC[]; FIRST_X_ASSUM MATCH_MP_TAC; ASM_REWRITE_TAC[]; BY(REPLICATE_TAC 2 (FIRST_X_ASSUM MP_TAC) THEN MESON_TAC[]) ]);; (* }}} *)
let vv_azim_le_alt = 
prove_by_refinement( `!vv k i j. (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 ( periodic vv k /\ 3 <= k /\ convex_local_fan (V,E,f) /\ (!i j. i < k /\ j < k /\ vv i = vv j ==> (i = j)) ==> azim (vec 0) (vv i) (vv (SUC i)) (vv j) <= azim (vec 0) (vv i) (vv (SUC i)) (vv (i + k - 1))))`,
(* {{{ proof *) [ REWRITE_TAC[LET_DEF;LET_END_DEF]; REPEAT WEAKER_STRIP_TAC; TYPIFY `~(k=0)` (C SUBGOAL_THEN ASSUME_TAC); BY(REPEAT (FIRST_X_ASSUM MP_TAC) THEN ARITH_TAC); INTRO_TAC Terminal.PRIOR_TO_LESS_THAN_PI_LEMMA_ALT [`IMAGE vv (:num)`; `IMAGE (\i. {vv i, vv (SUC i)}) (:num)`; `IMAGE (\i. vv i,vv (SUC i)) (:num)`;`vv i`]; ASM_REWRITE_TAC[]; ANTS_TAC; BY(SET_TAC[]); DISCH_THEN (C INTRO_TAC [`vv j`]); ANTS_TAC; BY(SET_TAC[]); INTRO_TAC Terminal.vv_rho_node1 [`vv`;`k`]; REWRITE_TAC[LET_DEF;LET_END_DEF]; ANTS_TAC; BY(ASM_REWRITE_TAC[]); DISCH_THEN (unlist REWRITE_TAC); GMATCH_SIMP_TAC Terminal.EE_vv; TYPIFY `k` EXISTS_TAC; ASM_REWRITE_TAC[]; REWRITE_TAC[Local_lemmas.AZIM_CYCLE_TWO_POINT_SET]; ]);;
(* }}} *)
let vv_split_azim_alt = 
prove_by_refinement( `!vv k i j. (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 (periodic vv k /\ 3 <= k /\ ~collinear {vec 0, vv i, vv j} /\ ~collinear {vec 0, vv i, vv (i + k - 1)} /\ ~collinear {vec 0, vv i, vv (SUC i)} /\ convex_local_fan (V,E,f) /\ (!i j. i < k /\ j < k /\ vv i = vv j ==> (i = j)) ==> azim (vec 0) (vv i) (vv (SUC i)) (vv (i + k - 1)) = azim (vec 0) (vv i) (vv (SUC i)) (vv j) + azim (vec 0) (vv i) (vv j) (vv (i + k - 1))))`,
(* {{{ proof *) [ REWRITE_TAC[LET_DEF;LET_END_DEF]; REPEAT WEAKER_STRIP_TAC; TYPIFY `~(k=0)` (C SUBGOAL_THEN ASSUME_TAC); BY(REPEAT (FIRST_X_ASSUM MP_TAC) THEN ARITH_TAC); INTRO_TAC vv_azim_le_alt [`vv`;`k`;`i`;`j`]; REWRITE_TAC[LET_DEF;LET_END_DEF]; ANTS_TAC; BY(ASM_REWRITE_TAC[]); DISCH_TAC; MATCH_MP_TAC Fan.sum4_azim_fan; ASM_REWRITE_TAC[]; ]);;
(* }}} *) (* vv_split_azim_generic_alt -> Terminal.vv_split_azim_generic *)
let interior_angle1_azim = 
prove_by_refinement( `!V E FF v. local_fan (V,E,FF) /\ v IN V ==> interior_angle1 (vec 0) FF v = azim (vec 0) v (rho_node1 FF v) (ivs_rho_node1 FF v)`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; GMATCH_SIMP_TAC Zlzthic.LOFA_IMP_INANGLE_EQ_AZIM; TYPIFY `E` EXISTS_TAC; CONJ_TAC; BY(ASM_MESON_TAC[]); BY(ASM_MESON_TAC[Local_lemmas1.AZIM_IN_FAN_RHOND_IVS_RHOND]) ]);;
(* }}} *) (* Ocbicby.INTERIOR_ANGLE1_AZIM *)
let LOFA_IMP_INANGLE_EQ_AZIM_IVS = 
prove_by_refinement( `!V E FF v. local_fan (V,E,FF) /\ v IN V ==> (interior_angle1 (vec 0) FF v = azim (vec 0) v (rho_node1 FF v) (ivs_rho_node1 FF v)) `,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; GMATCH_SIMP_TAC Zlzthic.LOFA_IMP_INANGLE_EQ_AZIM; TYPIFY `E` EXISTS_TAC; CONJ_TAC; BY(ASM_MESON_TAC[]); BY(ASM_MESON_TAC[Local_lemmas1.AZIM_IN_FAN_RHOND_IVS_RHOND]) ]);;
(* }}} *)
let BBs_inj = 
prove_by_refinement( `!s v k. is_scs_v39 s /\ scs_k_v39 s = k /\ BBs_v39 s v ==> (!i j. i < k /\ j < k /\ v i = v j ==> i = j)`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; PROOF_BY_CONTR_TAC; INTRO_TAC Ocbicby.scs_lb_2 [`s`;`v`;`i`;`j`]; ASM_REWRITE_TAC[DIST_REFL;arith `~(&2 <= &0)`]; BY(ASM_SIMP_TAC[MOD_LT]) ]);;
(* }}} *)
let IMAGE_FF = 
prove_by_refinement( `!FF f t. IMAGE (\uv. f (FST uv) t,f (SND uv) t) FF = IMAGE (\ (u,v). f u t,f v t) FF`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; BY((REWRITE_TAC[EXTENSION;IN_IMAGE;EXISTS_PAIR_THM])) ]);;
(* }}} *)
let interior_angle1_azim_scs = 
prove_by_refinement( `!s v k i f e. (let V = IMAGE v (:num) in let FF = IMAGE (\i. v i,v (SUC i)) (:num) in ( &0 < e /\ deformation f V (-- e, e) /\ is_scs_v39 s /\ scs_k_v39 s = k /\ 3 < k /\ BBs_v39 s v ==> (?e'. &0 < e' /\ (!t. abs t < e' ==> interior_angle1 (vec 0) (IMAGE (\ (u,v). (f u t, f v t)) FF) (f (v i) t) = azim (vec 0) (f (v i) t) (f (v (i+1)) t) (f (v (i + (k-1))) t)))))`,
(* {{{ proof *) [ REPEAT GEN_TAC; REPEAT (LET_TAC); TYPED_ABBREV_TAC `E = IMAGE (\i. {v i, v (SUC i)}) (:num)`; REPEAT WEAKER_STRIP_TAC; TYPIFY `local_fan (V,E,FF)` (C SUBGOAL_THEN ASSUME_TAC); FIRST_X_ASSUM_ST `BBs_v39` MP_TAC; ASM_REWRITE_TAC[Appendix.BBs_v39;LET_DEF;LET_END_DEF]; BY(ASM_MESON_TAC[arith `3 < k ==> ~(k <= 3)`;Local_lemmas.CVX_LO_IMP_LO]); INTRO_TAC (GEN_ALL Lunar_deform.XRECQNS_UPDATE) [`--e`;`e`;`V`;`E`;`f`;`FF`]; ANTS_TAC; BY(ASM_REWRITE_TAC[]); REPEAT WEAKER_STRIP_TAC; TYPIFY `v i IN V` (C SUBGOAL_THEN ASSUME_TAC); EXPAND_TAC "V";
REWRITE_TAC[IN_IMAGE;IN_UNIV]; BY(MESON_TAC[]); INTRO_TAC Zlzthic.deformation_rho_node1_equivariant1 [`f`;`V`;`E`;`FF`;`-- e`;`e`;`v i`]; ASM_REWRITE_TAC[]; DISCH_TAC; INTRO_TAC Zlzthic.deformation_ivs_rho_node1_equivariant1 [`f`;`V`;`E`;`FF`;`-- e`;`e`;`v i`]; ASM_REWRITE_TAC[]; REPEAT WEAKER_STRIP_TAC; TYPIFY `!t. IMAGE (\uv. f (FST uv) t,f (SND uv) t) FF = IMAGE (\ (u,v). f u t,f v t) FF` (C SUBGOAL_THEN ASSUME_TAC); BY((REWRITE_TAC[EXTENSION;IN_IMAGE;EXISTS_PAIR_THM])); TYPIFY `e'` EXISTS_TAC; ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; REPEAT (FIRST_X_ASSUM_ST `local_fan` (C INTRO_TAC [`t`])) THEN ASM_REWRITE_TAC[] THEN DISCH_TAC THEN ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; INTRO_TAC LOFA_IMP_INANGLE_EQ_AZIM_IVS [`IMAGE (\v. f v t) V`;` IMAGE (\s. IMAGE (\v. f v t) s) E`;` IMAGE (\(u,v). f u t,f v t) FF`;`f (v i) t`]; ANTS_TAC; ASM_SIMP_TAC[]; EXPAND_TAC "V"; REWRITE_TAC[GSYM IMAGE_o]; REWRITE_TAC[IN_IMAGE;IN_UNIV;o_THM]; BY(MESON_TAC[]); DISCH_THEN SUBST1_TAC; REPLICATE_TAC 2 (FIRST_X_ASSUM (SUBST1_TAC o GSYM)); INTRO_TAC BBs_inj [`s`;`v`;`k`]; ASM_REWRITE_TAC[]; DISCH_TAC; TYPIFY `periodic v k` (C SUBGOAL_THEN ASSUME_TAC); FIRST_X_ASSUM_ST `BBs_v39` MP_TAC; REWRITE_TAC[Appendix.BBs_v39]; ASM_REWRITE_TAC[LET_DEF;LET_END_DEF]; BY((DISCH_THEN (unlist REWRITE_TAC))); INTRO_TAC Terminal.vv_rho_node1 [`v`;`k`]; ASM_REWRITE_TAC[LET_DEF;LET_END_DEF]; ASM_SIMP_TAC[arith `3 < k==> 3 <= k`]; DISCH_THEN (unlist REWRITE_TAC); INTRO_TAC VV_SUC_EQ_IVS_RHO_NODE_PRIME [`V`;`E`;`FF`;`s`;`v`;`v i`;`k`;`i`]; ASM_REWRITE_TAC[]; BY(ASM_SIMP_TAC[arith `3 < k==> ~(k <= 3)`;arith `SUC i = i +1`]) ]);; (* }}} *)
let deformation_BBs_ALT = 
prove_by_refinement( `!s k f v e. is_scs_v39 s /\ scs_k_v39 s = k /\ 3 < k /\ BBs_v39 s v /\ scs_generic v /\ &0 < e /\ deformation f (IMAGE v (:num)) (--e,e) /\ (!i. ?e0. &0 < e0 /\ (azim (vec 0) (v i) (v (i+1)) (v (i + (k-1))) = pi ==> (!t. abs t < e0 ==> azim (vec 0) (f (v i) t) (f (v (i+1)) t) (f (v (i+(k-1))) t) <= pi))) /\ (!i. (!t. abs t < e ==> norm (f (v i) t) = norm (v i))) /\ (!i j. ?e1. &0 < e1 /\ (scs_a_v39 s i j = dist(v i,v j) ==> (!t. abs t < e1 ==> scs_a_v39 s i j <= dist(f (v i) t,f (v j) t)))) /\ (!i j. ?e2. &0 < e2 /\ (dist(v i,v j) = scs_b_v39 s i j ==> (!t. abs t < e2 ==> dist(f (v i) t,f (v j) t) <= scs_b_v39 s i j))) ==> (?e'. &0 < e' /\ (!t. abs t < e' ==> BBs_v39 s (\i. f (v i) t))) `,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; MATCH_MP_TAC deformation_BBs; TYPIFY `k` EXISTS_TAC; ASM_REWRITE_TAC[]; FIRST_X_ASSUM_ST `azim` MP_TAC; TYPIFY `periodic v k` (C SUBGOAL_THEN MP_TAC); FIRST_X_ASSUM_ST `BBs_v39` MP_TAC; ASM_REWRITE_TAC[LET_DEF;LET_END_DEF;Appendix.BBs_v39]; BY(MESON_TAC[]); DISCH_TAC; GMATCH_SIMP_TAC SKOLEM_PERIODIC; CONJ_TAC; TYPIFY `k` EXISTS_TAC; ASM_SIMP_TAC[arith `3 < k ==> ~(k=0)`]; CONJ_TAC; FIRST_X_ASSUM MP_TAC; REWRITE_TAC[Oxl_def.periodic;FUN_EQ_THM]; BY(ASM_SIMP_TAC[arith `3 < k ==> ((i + k) + 1 = (i+1)+k /\ (i+k)+k-1 = (i+k-1) + k)`]); BY(MESON_TAC[arith `e0 <= e' /\ t < e0 ==> t < e'`]); REPEAT WEAKER_STRIP_TAC; TYPED_ABBREV_TAC ` FF = IMAGE (\i. (v i,v (SUC i))) (:num)`; TYPIFY `!i. (?e'. &0 < e' /\ (!t. abs t < e' ==> interior_angle1 (vec 0) (IMAGE (\ (u,v). (f u t, f v t)) FF) (f (v i) t) = azim (vec 0) (f (v i) t) (f (v (i+1)) t) (f (v (i + (k-1))) t)))` (C SUBGOAL_THEN ASSUME_TAC); GEN_TAC; EXPAND_TAC "FF";
MATCH_MP_TAC (REWRITE_RULE[LET_DEF;LET_END_DEF] interior_angle1_azim_scs); BY(ASM_MESON_TAC[]); FIRST_X_ASSUM MP_TAC; GMATCH_SIMP_TAC SKOLEM_PERIODIC; CONJ_TAC; TYPIFY `k` EXISTS_TAC; ASM_SIMP_TAC[arith `3 < k ==> ~(k=0)`]; CONJ_TAC; FIRST_X_ASSUM_ST `periodic` MP_TAC; REWRITE_TAC[Oxl_def.periodic;FUN_EQ_THM]; BY(ASM_SIMP_TAC[arith `3 < k ==> ((i + k) + 1 = (i+1)+k /\ (i+k)+k-1 = (i+k-1) + k)`]); BY(MESON_TAC[arith `e0 <= e' /\ t < e0 ==> t < e'`]); REPEAT WEAKER_STRIP_TAC; INTRO_TAC epsilon_triple [`e'`;`e0`;`e`] THEN ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; TYPIFY `e''''` EXISTS_TAC; ASM_REWRITE_TAC[]; CONJ_TAC; FIRST_X_ASSUM_ST `deformation` MP_TAC; REWRITE_TAC[Localization.deformation]; TYPIFY `!r. r IN real_interval (--e'''',e'''') ==> r IN real_interval (--e,e)` ENOUGH_TO_SHOW_TAC; REPEAT WEAKER_STRIP_TAC; CONJ_TAC; REWRITE_TAC[IN_REAL_INTERVAL]; BY(ASM_SIMP_TAC[arith `&0 < e ==> -- e < &0`]); ASM_REWRITE_TAC[]; BY(REPLICATE_TAC 4 (FIRST_X_ASSUM MP_TAC) THEN MESON_TAC[]); BY(ASM_REWRITE_TAC[IN_REAL_INTERVAL;arith `-- e < r /\ r < e <=> abs r < e`]); CONJ2_TAC; REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM MATCH_MP_TAC; FIRST_X_ASSUM MATCH_MP_TAC; BY(ASM_REWRITE_TAC[]); REWRITE_TAC[LET_DEF;LET_END_DEF]; ASM_REWRITE_TAC[IN_REAL_INTERVAL;arith `-- e < r /\ r < e <=> abs r < e`]; REPEAT WEAKER_STRIP_TAC; REWRITE_TAC[IMAGE_FF]; FIRST_X_ASSUM GMATCH_SIMP_TAC; ASM_SIMP_TAC[]; TYPIFY `interior_angle1 (vec 0) FF (v i) = azim (vec 0) (v i) (v (i + 1)) (v (i + k - 1))` ENOUGH_TO_SHOW_TAC; BY(ASM_MESON_TAC[]); EXPAND_TAC "FF"; GMATCH_SIMP_TAC (GSYM (REWRITE_RULE[LET_DEF;LET_END_DEF] Ocbicby.INTERIOR_ANGLE1_AZIM)); TYPIFY `s` EXISTS_TAC; BY(ASM_REWRITE_TAC[arith `SUC i = i+1`;IN]) ]);; (* }}} *)
let periodic2_MOD = 
prove_by_refinement( `!(a:num->num->A) i j k. ~(k=0) /\ periodic2 a k ==> a i j = a (i MOD k) (j MOD k)`,
(* {{{ proof *) [ REWRITE_TAC[Appendix.periodic2]; REPEAT WEAKER_STRIP_TAC; TYPIFY `periodic (a i) k` (C SUBGOAL_THEN ASSUME_TAC); REWRITE_TAC[Oxl_def.periodic]; BY(ASM_REWRITE_TAC[]); INTRO_TAC (Oxl_def.periodic_mod) [`a i`;`k`;`j`]; DISCH_THEN GMATCH_SIMP_TAC; TYPIFY `periodic (\i. a i (j MOD k)) k` (C SUBGOAL_THEN ASSUME_TAC); REWRITE_TAC[Oxl_def.periodic]; BY(ASM_REWRITE_TAC[]); INTRO_TAC (Oxl_def.periodic_mod) [`\i. a i (j MOD k)`;`k`;`i`]; BY(ASM_MESON_TAC[]) ]);;
(* }}} *)
let MOD_periodic2 = 
prove_by_refinement( `!(a:num->num->A) k. ~(k=0) /\ (!i j. a i j = a (i MOD k) (j MOD k)) ==> periodic2 a k`,
(* {{{ proof *) [ REWRITE_TAC[Appendix.periodic2]; REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM (unlist ONCE_REWRITE_TAC); ONCE_REWRITE_TAC[arith `i+k = 1*k + i`]; BY(REWRITE_TAC[MOD_MULT_ADD]) ]);;
(* }}} *)
let azim_dominated_split = 
prove_by_refinement( `!v0 v1 v2 v3 v4 v0' v1' v2' v3' v4'. ~collinear {v0', v1', v3'} /\ ~collinear {v0', v1', v4'} /\ ~collinear {v0', v1', v2'} /\ azim v0 v1 v2 v3 + azim v0 v1 v3 v4 = azim v0 v1 v2 v4 /\ azim v0' v1' v2' v3' <= azim v0 v1 v2 v3 /\ azim v0' v1' v3' v4' <= azim v0 v1 v3 v4 ==> azim v0' v1' v2' v3' + azim v0' v1' v3' v4' = azim v0' v1' v2' v4'`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; GMATCH_SIMP_TAC (GSYM Fan.sum3_azim_fan); INTRO_TAC Local_lemmas.AZIM_RANGE [`v0`;`v1`;`v2`;`v4`]; ASM_REWRITE_TAC[]; BY(ASM_TAC THEN REAL_ARITH_TAC) ]);;
(* }}} *) let assumptions = `(!i. ?e0. &0 < e0 /\ (azim (vec 0) (v i) (v (i+1)) (v (i + (k-1))) = pi ==> (!t. abs t < e0 ==> azim (vec 0) (f (v i) t) (f (v (i+1)) t) (f (v (i+(k-1))) t) <= pi))) /\ (!i. (!t. abs t < e ==> norm (f (v i) t) = norm (v i))) /\ (!i j. ?e1. &0 < e1 /\ (scs_a_v39 s i j = dist(v i,v j) ==> (!t. abs t < e1 ==> scs_a_v39 s i j <= dist(f (v i) t,f (v j) t)))) /\ (!i j. ?e2. &0 < e2 /\ (dist(v i,v j) = scs_b_v39 s i j ==> (!t. abs t < e2 ==> dist(f (v i) t,f (v j) t) <= scs_b_v39 s i j)))`;;
let I_IMP = 
prove_by_refinement( `!(x:bool). I x ==> x`,
(* {{{ proof *) [ BY(REWRITE_TAC[I_THM]) ]);;
(* }}} *)
let psort_inj = 
prove_by_refinement( `!k a b c d. psort k (a,b) = psort k (c,d) ==> ((a MOD k = c MOD k) \/ (a MOD k = d MOD k))`,
(* {{{ proof *) [ REWRITE_TAC[Appendix.psort;LET_THM]; REPEAT GEN_TAC; BY(REPEAT COND_CASES_TAC THEN REWRITE_TAC[PAIR_EQ] THEN DISCH_THEN (unlist ASM_REWRITE_TAC)) ]);;
(* }}} *)
let a_assumption_reduction = 
prove_by_refinement( `!s k p1 f v e. is_scs_v39 s /\ scs_k_v39 s = k /\ BBs_v39 s v /\ 3 < k /\ (!i j. scs_diag k i j /\ ~(psort k (i, j) = psort k (p1+1,p1+k-1)) ==> scs_a_v39 s i j < dist(v i,v j)) /\ deformation f (IMAGE v (:num)) (--e,e) /\ (!w t. ~(w = v p1) ==> (f w t = w)) /\ (?e1. &0 < e1 /\ (scs_a_v39 s p1 (p1 + 1) = dist (v p1, v(p1+1)) ==> (!t. abs t < e1 ==> scs_a_v39 s p1 (p1+1) <= dist(f (v p1) t,f (v (p1+1)) t)))) /\ (?e1. &0 < e1 /\ (scs_a_v39 s p1 (p1 + k-1) = dist (v p1, v(p1+ k - 1)) ==> (!t. abs t < e1 ==> scs_a_v39 s p1 (p1+k-1) <= dist(f (v p1) t,f (v (p1+k - 1)) t)))) ==> (!i j. ?e1. &0 < e1 /\ (scs_a_v39 s i j = dist(v i,v j) ==> (!t. abs t < e1 ==> scs_a_v39 s i j <= dist(f (v i) t,f (v j) t)))) `,
(* {{{ proof *) [ REPEAT GEN_TAC THEN DISCH_TAC THEN MATCH_MP_TAC I_IMP THEN ASM_TAC THEN REPEAT WEAKER_STRIP_TAC; TYPIFY `~(k=0)` (C SUBGOAL_THEN ASSUME_TAC); BY(ASM_SIMP_TAC[arith `3 < k ==> ~(k=0)`]); TYPIFY `!i j.scs_a_v39 s (i MOD k) (j MOD k) = scs_a_v39 s i j /\ scs_b_v39 s (i MOD k) (j MOD k) = scs_b_v39 s i j ` (C SUBGOAL_THEN ASSUME_TAC); FIRST_X_ASSUM_ST `is_scs_v39` MP_TAC; ASM_REWRITE_TAC[Appendix.is_scs_v39]; BY(FIRST_X_ASSUM MP_TAC THEN MESON_TAC[periodic2_MOD]); TYPIFY `!i. i MOD k < k` (C SUBGOAL_THEN ASSUME_TAC); BY(REPLICATE_TAC 3 (FIRST_X_ASSUM MP_TAC) THEN MESON_TAC[DIVISION]); TYPIFY `periodic v k` (C SUBGOAL_THEN ASSUME_TAC); BY(FIRST_X_ASSUM_ST `BBs_v39` MP_TAC THEN ASM_REWRITE_TAC[Appendix.BBs_v39;LET_THM] THEN MESON_TAC[]); TYPIFY `!i. v (i MOD k) = v i` (C SUBGOAL_THEN ASSUME_TAC); GEN_TAC; MATCH_MP_TAC (GSYM Oxl_def.periodic_mod); BY(ASM_REWRITE_TAC[]); INTRO_TAC BBs_inj [`s`;`v`;`k`]; ASM_REWRITE_TAC[]; DISCH_TAC; TYPIFY `!j. j < k ==> (j MOD k = j)` (C SUBGOAL_THEN ASSUME_TAC); BY(REWRITE_TAC[MOD_LT]); COMMENT "scs_a_v39";
REWRITE_TAC[I_THM]; MATCH_MP_TAC Terminal.periodic2_mod_reduce; TYPIFY `k` EXISTS_TAC; ASM_REWRITE_TAC[]; CONJ_TAC; MATCH_MP_TAC MOD_periodic2; BY(REPLICATE_TAC 7 (FIRST_X_ASSUM MP_TAC) THEN REWRITE_TAC[] THEN MESON_TAC[]); TYPIFY `!j. j < k ==> (?e1. &0 < e1 /\ (scs_a_v39 s p1 j = dist (v p1,v j) ==> (!t. abs t < e1 ==> scs_a_v39 s p1 j <= dist (f (v p1) t,f (v j) t))))` ENOUGH_TO_SHOW_TAC; REPEAT WEAKER_STRIP_TAC; TYPIFY `i = ( p1 MOD k)` ASM_CASES_TAC; FIRST_X_ASSUM_ST `dist` (C INTRO_TAC [`j`]); ASM_REWRITE_TAC[]; REPEAT WEAKER_STRIP_TAC; TYPIFY `e1''` EXISTS_TAC; ASM_REWRITE_TAC[]; TYPIFY_GOAL_THEN `scs_a_v39 s (p1 MOD k) j = scs_a_v39 s p1 j ` (unlist REWRITE_TAC); BY(REPLICATE_TAC 12 (FIRST_X_ASSUM MP_TAC) THEN MESON_TAC[]); BY(FIRST_X_ASSUM MP_TAC THEN MESON_TAC[]); TYPIFY `j = p1 MOD k` ASM_CASES_TAC; FIRST_X_ASSUM_ST `dist` (C INTRO_TAC [`i`]); ASM_REWRITE_TAC[DIST_SYM]; REPEAT WEAKER_STRIP_TAC; TYPIFY `e1''` EXISTS_TAC; ASM_REWRITE_TAC[]; TYPIFY_GOAL_THEN `scs_a_v39 s i (p1 MOD k) = scs_a_v39 s i p1 ` (unlist REWRITE_TAC); BY(REPLICATE_TAC 12 (FIRST_X_ASSUM MP_TAC) THEN MESON_TAC[]); BY(FIRST_X_ASSUM MP_TAC THEN FIRST_X_ASSUM_ST `is_scs_v39` MP_TAC THEN REWRITE_TAC[Appendix.is_scs_v39] THEN MESON_TAC[]); TYPIFY `&1` EXISTS_TAC; REWRITE_TAC[arith `&0 < &1`]; REPEAT WEAKER_STRIP_TAC; TYPIFY `!w t. ~(w = v p1) ==> f w t = w` ( (C FIRST_ASSUM_ST GMATCH_SIMP_TAC)); TYPIFY `!w t. ~(w = v p1) ==> f w t = w` ( (C FIRST_X_ASSUM_ST GMATCH_SIMP_TAC)); ASM_SIMP_TAC[arith `a = b ==> a <= b`]; BY(REPLICATE_TAC 12 (FIRST_X_ASSUM MP_TAC) THEN MESON_TAC[]); REPEAT WEAKER_STRIP_TAC; TYPIFY `~(p1 MOD k = (p1+1) MOD k) /\ ~(p1 MOD k = (p1 + k-1) MOD k)` (C SUBGOAL_THEN ASSUME_TAC); TYPIFY `(p1 MOD k = (p1 +0) MOD k)` (C SUBGOAL_THEN SUBST1_TAC); BY(REWRITE_TAC[arith `i+0=i`]); REPEAT (GMATCH_SIMP_TAC Ocbicby.MOD_EQ_MOD_SHIFT); REPEAT (GMATCH_SIMP_TAC MOD_LT); BY(FIRST_X_ASSUM_ST `3 < k` MP_TAC THEN ARITH_TAC); TYPIFY `~(psort k (p1,j) = psort k (p1+1,p1+k-1))` (C SUBGOAL_THEN ASSUME_TAC); BY(FIRST_X_ASSUM MP_TAC THEN MESON_TAC[psort_inj]); TYPIFY `scs_diag k p1 j` ASM_CASES_TAC; TYPIFY `&1` EXISTS_TAC; BY(REWRITE_TAC[arith `&0 < &1`] THEN ASM_MESON_TAC[arith `a < b ==> ~(a =b)`]); FIRST_X_ASSUM_ST `scs_diag` MP_TAC; REWRITE_TAC[Appendix.scs_diag;DE_MORGAN_THM]; COMMENT "final cases"; STRIP_TAC; TYPIFY `&1` EXISTS_TAC; REWRITE_TAC[arith `&0 < &1`]; TYPIFY `dist (v p1, v j) = dist(v (p1 MOD k),v (p1 MOD k))` (C SUBGOAL_THEN SUBST1_TAC); BY(ASM_MESON_TAC[]); REWRITE_TAC[DIST_REFL]; REPEAT WEAKER_STRIP_TAC; ASM_REWRITE_TAC[]; BY(REWRITE_TAC[DIST_POS_LE]); TYPIFY `e1` EXISTS_TAC; ASM_REWRITE_TAC[]; TYPIFY `v j = v (p1 + 1)` (C SUBGOAL_THEN SUBST1_TAC); BY(ASM_MESON_TAC[arith `SUC p1 = (p1 + 1)`]); TYPIFY `scs_a_v39 s p1 j = scs_a_v39 s p1 (p1+1)` (C SUBGOAL_THEN SUBST1_TAC); BY(ASM_MESON_TAC[arith `SUC p1 = (p1+1)`]); BY(ASM_REWRITE_TAC[]); TYPIFY `e1'` EXISTS_TAC; ASM_REWRITE_TAC[]; TYPIFY `j MOD k = (p1 + k - 1) MOD k` (C SUBGOAL_THEN ASSUME_TAC); TYPIFY `j MOD k = (SUC j+ (k-1)) MOD k` ENOUGH_TO_SHOW_TAC; DISCH_THEN SUBST1_TAC; ONCE_REWRITE_TAC[arith `(a:num) + b = b + a`]; GMATCH_SIMP_TAC Ocbicby.MOD_EQ_MOD_SHIFT; BY(ASM_REWRITE_TAC[]); ASM_SIMP_TAC [arith `3< k ==> SUC j + k - 1 = 1 * k + j`]; REWRITE_TAC[MOD_MULT_ADD]; BY(ASM_MESON_TAC[]); TYPIFY `v j = v (p1 + k - 1)` (C SUBGOAL_THEN SUBST1_TAC); BY(ASM_MESON_TAC[]); TYPIFY `scs_a_v39 s p1 j = scs_a_v39 s p1 (p1+k-1)` (C SUBGOAL_THEN SUBST1_TAC); BY(ASM_MESON_TAC[]); BY(ASM_REWRITE_TAC[]) ]);; (* }}} *)
let b_assumption_reduction = 
prove_by_refinement( `!s k p1 f v e. is_scs_v39 s /\ scs_k_v39 s = k /\ BBs_v39 s v /\ 3 < k /\ (!i j. scs_diag k i j ==> &4 * h0 < scs_b_v39 s i j) /\ // (!t. norm (f (v p1) t) = norm (v p1)) /\ deformation f (IMAGE v (:num)) (--e,e) /\ (!w t. ~(w = v p1) ==> (f w t = w)) /\ (?e1. &0 < e1 /\ (dist (v p1, v(p1+1)) = scs_b_v39 s p1 (p1 + 1) ==> (!t. abs t < e1 ==> dist(f (v p1) t,f (v (p1+1)) t) <= scs_b_v39 s p1 (p1+1)))) /\ (?e1. &0 < e1 /\ (dist (v p1, v(p1+ k - 1)) = scs_b_v39 s p1 (p1 + k-1) ==> (!t. abs t < e1 ==> dist(f (v p1) t,f (v (p1+k - 1)) t) <= scs_b_v39 s p1 (p1+k-1)))) ==> (!i j. ?e1. &0 < e1 /\ (dist(v i,v j) = scs_b_v39 s i j ==> (!t. abs t < e1 ==> dist(f (v i) t,f (v j) t) <= scs_b_v39 s i j))) `,
(* {{{ proof *) [ REPEAT GEN_TAC THEN DISCH_TAC THEN MATCH_MP_TAC I_IMP THEN ASM_TAC THEN REPEAT WEAKER_STRIP_TAC; TYPIFY `~(k=0)` (C SUBGOAL_THEN ASSUME_TAC); BY(ASM_SIMP_TAC[arith `3 < k ==> ~(k=0)`]); TYPIFY `!i j.scs_b_v39 s (i MOD k) (j MOD k) = scs_b_v39 s i j /\ scs_b_v39 s (i MOD k) (j MOD k) = scs_b_v39 s i j ` (C SUBGOAL_THEN ASSUME_TAC); FIRST_X_ASSUM_ST `is_scs_v39` MP_TAC; ASM_REWRITE_TAC[Appendix.is_scs_v39]; BY(FIRST_X_ASSUM MP_TAC THEN MESON_TAC[periodic2_MOD]); TYPIFY `!i. i MOD k < k` (C SUBGOAL_THEN ASSUME_TAC); BY(REPLICATE_TAC 3 (FIRST_X_ASSUM MP_TAC) THEN MESON_TAC[DIVISION]); TYPIFY `periodic v k` (C SUBGOAL_THEN ASSUME_TAC); BY(FIRST_X_ASSUM_ST `BBs_v39` MP_TAC THEN ASM_REWRITE_TAC[Appendix.BBs_v39;LET_THM] THEN MESON_TAC[]); TYPIFY `!i. v (i MOD k) = v i` (C SUBGOAL_THEN ASSUME_TAC); GEN_TAC; MATCH_MP_TAC (GSYM Oxl_def.periodic_mod); BY(ASM_REWRITE_TAC[]); INTRO_TAC BBs_inj [`s`;`v`;`k`]; ASM_REWRITE_TAC[]; DISCH_TAC; TYPIFY `!j. j < k ==> (j MOD k = j)` (C SUBGOAL_THEN ASSUME_TAC); BY(REWRITE_TAC[MOD_LT]); COMMENT "scs_b_v39";
REWRITE_TAC[I_THM]; MATCH_MP_TAC Terminal.periodic2_mod_reduce; TYPIFY `k` EXISTS_TAC; ASM_REWRITE_TAC[]; CONJ_TAC; MATCH_MP_TAC MOD_periodic2; BY(REPLICATE_TAC 7 (FIRST_X_ASSUM MP_TAC) THEN REWRITE_TAC[] THEN MESON_TAC[]); TYPIFY `!j. j < k ==> (?e1. &0 < e1 /\ (dist (v p1,v j) = scs_b_v39 s p1 j ==> (!t. abs t < e1 ==> dist (f (v p1) t,f (v j) t) <= scs_b_v39 s p1 j)))` ENOUGH_TO_SHOW_TAC; REPEAT WEAKER_STRIP_TAC; TYPIFY `i = ( p1 MOD k)` ASM_CASES_TAC; FIRST_X_ASSUM_ST `dist` (C INTRO_TAC [`j`]); ASM_REWRITE_TAC[]; REPEAT WEAKER_STRIP_TAC; TYPIFY `e1''` EXISTS_TAC; ASM_REWRITE_TAC[]; TYPIFY_GOAL_THEN `scs_b_v39 s (p1 MOD k) j = scs_b_v39 s p1 j ` (unlist REWRITE_TAC); BY(REPLICATE_TAC 12 (FIRST_X_ASSUM MP_TAC) THEN MESON_TAC[]); BY(FIRST_X_ASSUM MP_TAC THEN MESON_TAC[]); TYPIFY `j = p1 MOD k` ASM_CASES_TAC; FIRST_X_ASSUM_ST `dist` (C INTRO_TAC [`i`]); ASM_REWRITE_TAC[DIST_SYM]; REPEAT WEAKER_STRIP_TAC; TYPIFY `e1''` EXISTS_TAC; ASM_REWRITE_TAC[]; TYPIFY_GOAL_THEN `scs_b_v39 s i (p1 MOD k) = scs_b_v39 s i p1 ` (unlist REWRITE_TAC); BY(REPLICATE_TAC 12 (FIRST_X_ASSUM MP_TAC) THEN MESON_TAC[]); BY(FIRST_X_ASSUM MP_TAC THEN FIRST_X_ASSUM_ST `is_scs_v39` MP_TAC THEN REWRITE_TAC[Appendix.is_scs_v39] THEN MESON_TAC[]); TYPIFY `&1` EXISTS_TAC; REWRITE_TAC[arith `&0 < &1`]; REPEAT WEAKER_STRIP_TAC; TYPIFY `!w t. ~(w = v p1) ==> f w t = w` ( (C FIRST_ASSUM_ST GMATCH_SIMP_TAC)); TYPIFY `!w t. ~(w = v p1) ==> f w t = w` ( (C FIRST_X_ASSUM_ST GMATCH_SIMP_TAC)); ASM_SIMP_TAC[arith `a = b ==> a <= b`]; BY(REPLICATE_TAC 12 (FIRST_X_ASSUM MP_TAC) THEN MESON_TAC[]); REPEAT WEAKER_STRIP_TAC; TYPIFY `~(p1 MOD k = (p1+1) MOD k) /\ ~(p1 MOD k = (p1 + k-1) MOD k)` (C SUBGOAL_THEN ASSUME_TAC); TYPIFY `(p1 MOD k = (p1 +0) MOD k)` (C SUBGOAL_THEN SUBST1_TAC); BY(REWRITE_TAC[arith `i+0=i`]); REPEAT (GMATCH_SIMP_TAC Ocbicby.MOD_EQ_MOD_SHIFT); REPEAT (GMATCH_SIMP_TAC MOD_LT); BY(FIRST_X_ASSUM_ST `3 < k` MP_TAC THEN ARITH_TAC); TYPIFY `~(psort k (p1,j) = psort k (p1+1,p1+k-1))` (C SUBGOAL_THEN ASSUME_TAC); BY(FIRST_X_ASSUM MP_TAC THEN MESON_TAC[psort_inj]); TYPIFY `scs_diag k p1 j` ASM_CASES_TAC; TYPIFY `&1` EXISTS_TAC; (REWRITE_TAC[arith `&0 < &1`]); TYPIFY `dist(v p1,v j) <= &4 * h0` ENOUGH_TO_SHOW_TAC; FIRST_X_ASSUM_ST `&4 * h0` (C INTRO_TAC [`p1`;`j`]); ASM_REWRITE_TAC[]; BY(REAL_ARITH_TAC); INTRO_TAC DIST_TRIANGLE [`v p1`;`(vec 0):real^3`;`v j`]; REWRITE_TAC[DIST_0]; TYPIFY `!i. norm (v i) <= &2 * h0` ENOUGH_TO_SHOW_TAC; BY(DISCH_TAC THEN FIRST_ASSUM (C INTRO_TAC [`p1`]) THEN FIRST_X_ASSUM (C INTRO_TAC [`j`]) THEN REAL_ARITH_TAC); FIRST_X_ASSUM_ST `BBs_v39` MP_TAC THEN REWRITE_TAC[Appendix.BBs_v39;LET_THM] THEN REPEAT WEAKER_STRIP_TAC; BY(FIRST_X_ASSUM_ST `ball_annulus` MP_TAC THEN REWRITE_TAC[Terminal.IMAGE_SUBSET_IN;IN_UNIV] THEN MESON_TAC[Fnjlbxs.in_ball_annulus]); FIRST_X_ASSUM_ST `scs_diag` MP_TAC; REWRITE_TAC[Appendix.scs_diag;DE_MORGAN_THM]; COMMENT "final cases"; STRIP_TAC; TYPIFY `&1` EXISTS_TAC; REWRITE_TAC[arith `&0 < &1`]; TYPIFY `v j = v p1` (C SUBGOAL_THEN SUBST1_TAC); BY(ASM_MESON_TAC[]); REWRITE_TAC[DIST_REFL]; BY(MESON_TAC[arith `&0 <= &0`]); TYPIFY `e1` EXISTS_TAC; ASM_REWRITE_TAC[]; TYPIFY `v j = v (p1 + 1)` (C SUBGOAL_THEN SUBST1_TAC); BY(ASM_MESON_TAC[arith `SUC p1 = (p1 + 1)`]); TYPIFY `scs_b_v39 s p1 j = scs_b_v39 s p1 (p1+1)` (C SUBGOAL_THEN SUBST1_TAC); BY(ASM_MESON_TAC[arith `SUC p1 = (p1+1)`]); BY(ASM_REWRITE_TAC[]); TYPIFY `e1'` EXISTS_TAC; ASM_REWRITE_TAC[]; TYPIFY `j MOD k = (p1 + k - 1) MOD k` (C SUBGOAL_THEN ASSUME_TAC); TYPIFY `j MOD k = (SUC j+ (k-1)) MOD k` ENOUGH_TO_SHOW_TAC; DISCH_THEN SUBST1_TAC; ONCE_REWRITE_TAC[arith `(a:num) + b = b + a`]; GMATCH_SIMP_TAC Ocbicby.MOD_EQ_MOD_SHIFT; BY(ASM_REWRITE_TAC[]); ASM_SIMP_TAC [arith `3< k ==> SUC j + k - 1 = 1 * k + j`]; REWRITE_TAC[MOD_MULT_ADD]; BY(ASM_MESON_TAC[]); TYPIFY `v j = v (p1 + k - 1)` (C SUBGOAL_THEN SUBST1_TAC); BY(ASM_MESON_TAC[]); TYPIFY `scs_b_v39 s p1 j = scs_b_v39 s p1 (p1+k-1)` (C SUBGOAL_THEN SUBST1_TAC); BY(ASM_MESON_TAC[]); BY(ASM_REWRITE_TAC[]) ]);; (* }}} *)
let MOD_SHIFT = 
prove_by_refinement( `!k a b c. ~(k=0) /\ a MOD k = b MOD k ==> (a + c) MOD k = (b + c) MOD k`,
(* {{{ proof *) [ BY(MESON_TAC[MOD_ADD_MOD]) ]);;
(* }}} *)
let WNWSHJT_ALT = 
prove_by_refinement( `!w0 w1 w2 f a b c. deformation f {w0,w1,w2} (a,b) /\ ~collinear {vec 0, w1,w2} /\ ~collinear {vec 0, w1,w0} /\ &0 < azim (vec 0) w1 w2 w0 /\ azim (vec 0) w1 w2 w0 < c ==> (?e. &0 < e /\ (!t. abs t < e ==> &0 < azim (vec 0) (f w1 t) (f w2 t) (f w0 t) /\ azim (vec 0) (f w1 t) (f w2 t) (f w0 t) < c))`,
(* {{{ proof *) [ REWRITE_TAC[IN_ELIM_THM;IN_INSERT;NOT_IN_EMPTY;Localization.deformation]; REPEAT WEAKER_STRIP_TAC; TYPIFY `(?e. &0 < e /\ (!t. abs t < e ==> azim (vec 0) (f w1 t) (f w2 t) (f w0 t) < c)) /\ (?e. &0 < e /\ (!t. abs t < e ==> &0 < azim (vec 0) (f w1 t) (f w2 t) (f w0 t)))` ENOUGH_TO_SHOW_TAC; REPEAT WEAKER_STRIP_TAC; INTRO_TAC epsilon_pair [`e`;`e'`] THEN ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; TYPIFY `e''` EXISTS_TAC; BY(ASM_MESON_TAC[]); TYPIFY `(f w1) continuous atreal (&0) /\ (f w2) continuous atreal (&0) /\ (f w0) continuous atreal (&0)` (C SUBGOAL_THEN ASSUME_TAC); BY(ASM_MESON_TAC[]); TYPIFY `!a b. (\t. a + b * azim ((\ t. (vec 0)) t) (f w1 t) (f w2 t) (f w0 t)) real_continuous atreal (&0)` (C SUBGOAL_THEN ASSUME_TAC); REPEAT GEN_TAC; REPEAT (MATCH_MP_TAC REAL_CONTINUOUS_ADD ORELSE MATCH_MP_TAC REAL_CONTINUOUS_MUL ORELSE MATCH_MP_TAC (* Xbjrphc. *)REAL_CONTINUOUS_ATREAL_AZIM_COMPOSE THEN ASM_REWRITE_TAC[REAL_CONTINUOUS_CONST;CONTINUOUS_CONST]); GMATCH_SIMP_TAC (GSYM Local_lemmas.AZIM_EQ_0_GE_ALT2); FIRST_X_ASSUM_ST `f v (&0) = v` (REPEAT o GMATCH_SIMP_TAC); TYPIFY_GOAL_THEN `!v. (\t . f v t) = f v` (unlist REWRITE_TAC); BY(REWRITE_TAC[FUN_EQ_THM]); ASM_REWRITE_TAC[]; BY(ASM_REWRITE_TAC[GSYM Zlzthic.azim_pos_iff_nz]); CONJ_TAC; FIRST_X_ASSUM (C INTRO_TAC [`c`;`-- &1`]); DISCH_TAC; INTRO_TAC continuous_nbd_pos [`(\t. c + -- &1 * azim ((\t. vec 0) t) (f w1 t) (f w2 t) (f w0 t))`;`&0`]; ASM_REWRITE_TAC[arith `&0 < c + -- &1 * a <=> a < c`;arith `abs(t' - &0) = abs t'`]; BY(ASM_MESON_TAC[]); FIRST_X_ASSUM (C INTRO_TAC [`&0`;`&1`]); DISCH_TAC; INTRO_TAC continuous_nbd_pos [`(\t. &0 + &1 * azim ((\t. vec 0) t) (f w1 t) (f w2 t) (f w0 t))`;`&0`]; ASM_REWRITE_TAC[arith `&0 < &0 + &1 * a <=> &0 < a`;arith `abs(t' - &0) = abs t'`]; BY(ASM_MESON_TAC[]) ]);;
(* }}} *)
let azim_assumption_reduction = 
prove_by_refinement( `!s k p1 f v e. is_scs_v39 s /\ scs_k_v39 s = k /\ BBs_v39 s v /\ scs_generic v /\ 3 < k /\ ~coplanar {vec 0,v p1,v (p1+1),v(p1 + k-1)} /\ deformation f (IMAGE v (:num)) (--e,e) /\ (!w t. ~(w = v p1) ==> f w t = w) /\ azim (vec 0) (v p1) (v (p1 + 1)) (v (p1 + k - 1)) < pi /\ (azim (vec 0) (v (p1 + k - 1)) (v p1) (v (p1 + k - 2)) < pi \/ (?e1. &0 < e1 /\ (!t. abs t < e1 ==> azim (vec 0) (v (p1 + k - 1)) (f (v p1) t) (v (p1 + 1)) <= azim (vec 0) (v (p1 + k - 1)) (v p1) (v (p1 + 1))))) /\ (azim (vec 0) (v (p1 + 1)) (v (p1 + 2)) (v p1) < pi \/ (?e1. &0 < e1 /\ (!t. abs t < e1 ==> azim (vec 0) (v (p1 + 1)) (v (p1 + k - 1)) (f (v p1) t) <= azim (vec 0) (v (p1 + 1)) (v (p1 + k - 1)) ( (v p1))))) ==> ( azim (vec 0) (v (p1 + k - 1)) (v p1) (v (p1 + k - 2)) = azim (vec 0) (v (p1 + k - 1)) (v p1) (v (p1 + 1)) + azim (vec 0) (v (p1 + k - 1)) (v (p1 + 1)) (v (p1 + k - 2)) /\ azim (vec 0) (v (p1 + 1)) (v (p1 + 2)) (v p1) = azim (vec 0) (v (p1 + 1)) (v (p1 + 2)) (v (p1 + k - 1)) + azim (vec 0) (v (p1 + 1)) (v (p1 + k - 1)) (v p1) /\ (!i t. ~(p1 MOD k = i MOD k) /\ ~(p1 MOD k = (i+1) MOD k) /\ ~(p1 MOD k = (i+k-1) MOD k) ==> azim (vec 0) (f(v i) t) (f (v(i+1)) t) (f(v(i+k-1))t) = azim (vec 0) (v i) (v (i+1)) (v(i+k-1))) /\ (!i t. (p1 MOD k = (i) MOD k) ==> azim (vec 0) (f(v i) t) (f (v(i+1)) t) (f(v(i+k-1))t) = azim (vec 0) (f(v p1)t) (v (p1+1)) (v(p1+k-1))) /\ (!i t. (p1 MOD k = (i+1) MOD k) ==> azim (vec 0) (f(v i) t) (f (v(i+1)) t) (f(v(i+k-1))t) = azim (vec 0) ((v (p1+k-1))) (f(v(p1))t) (v(p1+k-2))) /\ (!i t. (p1 MOD k = (i+k-1) MOD k) ==> azim (vec 0) (f(v i) t) (f (v(i+1)) t) (f(v(i+k-1))t) = azim (vec 0) ((v( p1+1))) (v (p1+2)) (f(v p1)t)) /\ (!i. ?e0. &0 < e0 /\ (azim (vec 0) (v i) (v (i + 1)) (v (i + k - 1)) = pi ==> (!t. abs t < e0 ==> azim (vec 0) (f (v i) t) (f (v (i + 1)) t) (f (v (i + k - 1)) t) <= pi))) /\ (?e1. &0 < e1 /\ (!t. abs t < e1 ==> azim (vec 0) (v (p1 + k - 1)) (f (v p1) t) (v (p1 + k - 2)) = azim (vec 0) (v (p1 + k - 1)) (f (v p1) t) (v (p1 + 1)) + azim (vec 0) (v (p1 + k - 1)) (v (p1 + 1)) (v (p1 + k - 2)) /\ azim (vec 0) (v (p1 + 1)) (v (p1 + 2)) (f (v p1) t) = azim (vec 0) (v (p1 + 1)) (v (p1 + 2)) (v (p1 + k - 1)) + azim (vec 0) (v (p1 + 1)) (v (p1 + k - 1)) (f (v p1) t))) /\ (!t. f (v (p1 + 1)) t = v (p1 + 1) /\ f (v (p1 + k - 1)) t = v (p1 + k - 1) /\ f (v (p1 + k - 2)) t = v (p1 + k - 2) /\ f (v (p1 + 2)) t = v (p1 + 2)) )`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; TYPIFY `~(k=0) /\ ~(k<= 3)` (C SUBGOAL_THEN ASSUME_TAC); BY(ASM_SIMP_TAC[arith `3 < k ==> ~(k=0) /\ ~(k<= 3)`]); TYPIFY `!i. i MOD k < k` (C SUBGOAL_THEN ASSUME_TAC); BY(REPLICATE_TAC 3 (FIRST_X_ASSUM MP_TAC) THEN MESON_TAC[DIVISION]); TYPIFY `periodic v k` (C SUBGOAL_THEN ASSUME_TAC); BY(FIRST_X_ASSUM_ST `BBs_v39` MP_TAC THEN ASM_REWRITE_TAC[Appendix.BBs_v39;LET_THM] THEN MESON_TAC[]); TYPIFY `!i. v (i MOD k) = v i` (C SUBGOAL_THEN ASSUME_TAC); GEN_TAC; MATCH_MP_TAC (GSYM Oxl_def.periodic_mod); BY(ASM_REWRITE_TAC[]); INTRO_TAC BBs_inj [`s`;`v`;`k`]; ASM_REWRITE_TAC[]; DISCH_TAC; TYPIFY `!j. j < k ==> (j MOD k = j)` (C SUBGOAL_THEN ASSUME_TAC); BY(REWRITE_TAC[MOD_LT]); TYPIFY ` generic (IMAGE v (:num)) (IMAGE (\i. {v i, v (SUC i)}) (:num)) /\ convex_local_fan (IMAGE v (:num), IMAGE (\i. {v i, v (SUC i)}) (:num), IMAGE (\i. v i,v (SUC i)) (:num))` (C SUBGOAL_THEN ASSUME_TAC); CONJ2_TAC; FIRST_X_ASSUM_ST `BBs_v39` MP_TAC THEN ASM_REWRITE_TAC[LET_THM;Appendix.BBs_v39]; BY(MESON_TAC[]); BY(FIRST_X_ASSUM_ST `scs_generic` MP_TAC THEN MESON_TAC[Appendix.scs_generic]); FIRST_X_ASSUM MP_TAC THEN BURY_MP_TAC; COMMENT "first addition";
SUBCONJ_TAC; INTRO_TAC Terminal.vv_split_azim_generic [`v`;`k`;`p1 + k - 1`;`2`;`k-1`]; TYPIFY_GOAL_THEN `v (SUC (p1+k-1)) = v p1 /\ v ((p1 + k - 1) + (k-1)) = v(p1 + k - 2) /\ v ((p1 + k - 1) + 2) = v (p1 + 1)` (unlist REWRITE_TAC); FIRST_X_ASSUM_ST `3 <k` MP_TAC THEN SIMP_TAC[arith `3 < k ==> (SUC (p1 + k - 1) = (1* k + p1) /\ (p1+k-1)+k-1 = (1*k + (p1 + k - 2)) /\ (p1+k-1)+2 = (1*k + (p1+1)))`]; BY(REPLICATE_TAC 3 (FIRST_X_ASSUM MP_TAC) THEN MESON_TAC[MOD_MULT_ADD]); REWRITE_TAC[LET_THM] THEN DISCH_THEN MATCH_MP_TAC; ASM_REWRITE_TAC[]; BY(FIRST_X_ASSUM_ST `3 <k` MP_TAC THEN ARITH_TAC); DISCH_TAC; COMMENT "second addition"; SUBCONJ_TAC; INTRO_TAC Terminal.vv_split_azim_generic [`v`;`k`;`p1 + 1`;`k-2`;`k-1`]; TYPIFY_GOAL_THEN `v(SUC (p1+1)) = v( p1+2) /\ v ((p1 + 1)+ k - 1) = v(p1) /\ v ((p1 + 1) + (k-2)) = v (p1 + k-1)` (unlist REWRITE_TAC); FIRST_X_ASSUM_ST `3 <k` MP_TAC THEN SIMP_TAC[arith `3 < k ==> (SUC (p1 +1) = (p1+2) /\ (p1+1)+k-1 = (1*k + (p1)) /\ (p1+1)+k-2 = ((p1+k-1)))`]; BY(REPLICATE_TAC 4 (FIRST_X_ASSUM MP_TAC) THEN MESON_TAC[MOD_MULT_ADD;arith `SUC (p1+1)=p1+2`]); REWRITE_TAC[LET_THM] THEN DISCH_THEN MATCH_MP_TAC; ASM_REWRITE_TAC[]; BY(FIRST_X_ASSUM_ST `3 <k` MP_TAC THEN ARITH_TAC); DISCH_TAC; TYPIFY `~((p1 + 1) MOD k = p1 MOD k) /\ ~((p1 + k - 1) MOD k = p1 MOD k) /\ ~((p1 + k - 2) MOD k = p1 MOD k) /\ ~((p1 + 2) MOD k = p1 MOD k)` (C SUBGOAL_THEN ASSUME_TAC); TYPIFY `p1 MOD k = (p1 + 0) MOD k` (C SUBGOAL_THEN SUBST1_TAC); BY(REWRITE_TAC[arith `p1 + 0 = p1`]); REPEAT (GMATCH_SIMP_TAC Ocbicby.MOD_EQ_MOD_SHIFT); REPEAT (GMATCH_SIMP_TAC MOD_LT); BY(FIRST_X_ASSUM_ST `~(k <= 3)` MP_TAC THEN ARITH_TAC); TYPIFY `!t. (f (v (p1+1))t = v(p1+1)) /\ f (v (p1+k-1)) t = v(p1+k-1) /\ f (v(p1+k-2)) t = v(p1+k-2) /\ f (v(p1+2)) t = v(p1+2)` (C SUBGOAL_THEN ASSUME_TAC); BY(GEN_TAC THEN REPEAT CONJ_TAC THEN (FIRST_X_ASSUM MATCH_MP_TAC) THEN FIRST_X_ASSUM_ST `v (i MOD k) = v i` ((unlist ONCE_REWRITE_TAC) o GSYM) THEN ASM_REWRITE_TAC[] THEN REPLICATE_TAC 10 (FIRST_X_ASSUM MP_TAC) THEN MESON_TAC[]); nCONJ_TAC 0; REPEAT WEAKER_STRIP_TAC; TYPIFY `!i j. ~(i MOD k = j MOD k) ==> ~(v i = v j)` (C SUBGOAL_THEN ASSUME_TAC); BY(ASM_MESON_TAC[]); TYPIFY `~(v i = v p1) /\ ~(v (i+1) = v p1) /\ ~(v (i+k-1) = v p1)` (C SUBGOAL_THEN ASSUME_TAC); BY(REPEAT CONJ_TAC THEN ONCE_REWRITE_TAC[EQ_SYM_EQ] THEN FIRST_X_ASSUM MATCH_MP_TAC THEN ASM_REWRITE_TAC[]); BY((FIRST_X_ASSUM MP_TAC) THEN FIRST_X_ASSUM_ST `!w t. ~(w = v p1) ==> f w t = w` MP_TAC THEN MESON_TAC[]); ASM_REWRITE_TAC[]; SUBCONJ_TAC; REPEAT WEAKER_STRIP_TAC; FIRST_ASSUM_ST `v (i MOD k) = v i` ((unlist ONCE_REWRITE_TAC) o GSYM); INTRO_TAC MOD_SHIFT [`k`;`i`;`p1`]; FIRST_X_ASSUM_ST `~(k=0)` MP_TAC THEN FIRST_X_ASSUM (MP_TAC o GSYM) THEN SIMP_TAC[]; BY(ASM_REWRITE_TAC[]); DISCH_TAC; SUBCONJ_TAC; REPEAT WEAKER_STRIP_TAC; TYPIFY `i MOD k = (p1 + k - 1) MOD k` (C SUBGOAL_THEN ASSUME_TAC); INTRO_TAC MOD_SHIFT [`k`;`p1`;`i+1`;`k-1`]; ASM_REWRITE_TAC[]; DISCH_THEN SUBST1_TAC; BY(ASM_SIMP_TAC[arith `~(k=0) ==> ((i+1)+ k - 1 = 1*k+i)`;MOD_MULT_ADD]); FIRST_ASSUM_ST `v (i MOD k) = v i` ((unlist ONCE_REWRITE_TAC) o GSYM); INTRO_TAC MOD_SHIFT [`k`;`i`;`p1+k-1`]; FIRST_X_ASSUM_ST `~(k=0)` MP_TAC THEN FIRST_X_ASSUM (MP_TAC) THEN SIMP_TAC[]; SIMP_TAC[arith `~(k <= 3) ==> ((p1 +k-1)+1 = 1*k+p1 /\ (p1+k-1)+k-1 = 1*k + (p1+k-2))`;MOD_MULT_ADD]; BY(ASM_REWRITE_TAC[]); DISCH_TAC; SUBCONJ_TAC; REPEAT WEAKER_STRIP_TAC; TYPIFY `i MOD k = (p1 + 1) MOD k` (C SUBGOAL_THEN ASSUME_TAC); INTRO_TAC MOD_SHIFT [`k`;`p1`;`i+k-1`;`1`]; ASM_REWRITE_TAC[]; DISCH_THEN SUBST1_TAC; BY(ASM_SIMP_TAC[arith `~(k=0) ==> ((i+k-1)+ 1 = 1*k+i)`;MOD_MULT_ADD]); FIRST_ASSUM_ST `v (i MOD k) = v i` ((unlist ONCE_REWRITE_TAC) o GSYM); INTRO_TAC MOD_SHIFT [`k`;`i`;`p1+1`]; FIRST_X_ASSUM_ST `~(k=0)` MP_TAC THEN FIRST_X_ASSUM (MP_TAC) THEN SIMP_TAC[]; SIMP_TAC[arith `(p1+1)+1 = p1+2 /\ (~(k <= 3) ==> (p1+1)+k-1 = 1*k + (p1))`;MOD_MULT_ADD]; BY(ASM_REWRITE_TAC[]); (DISCH_TAC); COMMENT "restart here"; TYPIFY `!i j. ~(v i = v j) ==> ~collinear {vec 0,v i, v j}` (C SUBGOAL_THEN ASSUME_TAC); REPEAT GEN_TAC THEN DISCH_TAC; MATCH_MP_TAC Zlzthic.PROPERTIES_GENERIC_LOCAL_FAN_ALT; GEXISTL_TAC [`IMAGE v (:num)`;`IMAGE (\i. {v i, v (SUC i)}) (:num)`;`IMAGE (\i. (v i, v (SUC i))) (:num)`]; ASM_REWRITE_TAC[IN_IMAGE;IN_UNIV]; CONJ_TAC; MATCH_MP_TAC Local_lemmas.CVX_LO_IMP_LO; BY(FIRST_X_ASSUM_ST `BBs_v39` MP_TAC THEN ASM_REWRITE_TAC[Appendix.BBs_v39;LET_THM]); BY(MESON_TAC[]); TYPIFY `~collinear {vec 0,v (p1+k-1),v (p1+1)} /\ ~collinear {vec 0,v (p1+k-1),v p1} /\ ~collinear {vec 0,v(p1+k-2),v(p1+k-1)} /\ ~collinear {vec 0,v (p1+1),v p1} /\ ~collinear {vec 0,v (p1+1),v(p1+2)}` (C SUBGOAL_THEN ASSUME_TAC); TYPIFY `v p1 = v (p1 + 0)` (C SUBGOAL_THEN SUBST1_TAC); BY(REWRITE_TAC[arith `p1 + 0 = p1`]); TYPIFY `!i j. i < k /\ j < k /\ ~(i = j) ==> ~collinear {vec 0,v (p1 + i), v(p1 + (j:num))}` (C SUBGOAL_THEN ASSUME_TAC); REPEAT GEN_TAC THEN DISCH_TAC THEN FIRST_X_ASSUM MATCH_MP_TAC THEN (FIRST_ASSUM_ST `v (i MOD k ) = v i` ((unlist ONCE_REWRITE_TAC) o GSYM)); TYPIFY_GOAL_THEN `!i j. i < k /\ j < (k:num) /\ ~(i = j) ==> ~(v i = v j)` MATCH_MP_TAC; BY(REPEAT (FIRST_X_ASSUM_ST `(i< (k:num))` MP_TAC) THEN MESON_TAC[]); GMATCH_SIMP_TAC Ocbicby.MOD_EQ_MOD_SHIFT; ASM_REWRITE_TAC[]; BY(ASM_SIMP_TAC[]); BY(REPEAT CONJ_TAC THEN FIRST_X_ASSUM MATCH_MP_TAC THEN FIRST_X_ASSUM_ST `~(k=0)` MP_TAC THEN TRY ARITH_TAC); COMMENT "deform collinear"; TYPIFY `!i. ~collinear {vec 0,v i,v p1} ==> (?e1. &0 < e1 /\ (!t. abs t < e1 ==> ~collinear {vec 0, v i, f (v p1) t}))` (C SUBGOAL_THEN ASSUME_TAC); REPEAT WEAKER_STRIP_TAC; INTRO_TAC (GEN_ALL Local_lemmas1.CONTINUOUS_PRESERVE_COLLINEAR) [`&0`;`(vec 0):real^3`;`( \ (t:real). v i)`;`f (v p1)`]; ANTS_TAC; ASM_REWRITE_TAC[CONTINUOUS_CONST]; FIRST_X_ASSUM_ST `deformation` MP_TAC THEN REWRITE_TAC[Localization.deformation]; REWRITE_TAC[IN_IMAGE;IN_UNIV]; BY(FIRST_X_ASSUM MP_TAC THEN MESON_TAC[]); BY(REWRITE_TAC[arith `abs(&0 - r') = abs r'`]); COMMENT "insert"; TYPIFY `!i. azim (vec 0) (v i) (v (i+1)) (v(i+k-1)) <= pi` (C SUBGOAL_THEN ASSUME_TAC); REWRITE_TAC[arith `i+1 = SUC i`]; GEN_TAC; MATCH_MP_TAC (REWRITE_RULE[LET_THM] Terminal.convex_local_fan_azim_le_pi); ASM_REWRITE_TAC[]; ASM_SIMP_TAC [arith `~(k <= 3) ==> 3 <= k`]; FIRST_X_ASSUM_ST `BBs_v39` MP_TAC THEN REWRITE_TAC[Appendix.BBs_v39;LET_THM]; BY(DISCH_THEN (unlist REWRITE_TAC)); COMMENT "do sums"; TYPIFY `(?e1. &0 < e1 /\ (!t. abs t < e1 ==> azim (vec 0) (v (p1 + k - 1)) (f (v p1) t) (v (p1 + k - 2)) = azim (vec 0) (v (p1 + k - 1)) (f (v p1) t) (v (p1 + 1)) + azim (vec 0) (v (p1 + k - 1)) (v (p1 + 1)) (v (p1 + k - 2)) /\ azim (vec 0) (v (p1 + k - 1)) (f (v p1) t) (v (p1 + k - 2)) <= pi)) /\ (?e1. &0 < e1 /\ (!t. abs t < e1 ==> azim (vec 0) (v (p1 + 1)) (v (p1 + 2)) (f (v p1) t) = azim (vec 0) (v (p1 + 1)) (v (p1 + 2)) (v (p1 + k - 1)) + azim (vec 0) (v (p1 + 1)) (v (p1 + k - 1)) (f (v p1) t) /\ azim (vec 0) (v (p1 + 1)) (v (p1 + 2)) (f (v p1) t) <= pi))` (C SUBGOAL_THEN ASSUME_TAC); TYPIFY `&0 < azim (vec 0) (v (p1+k-1)) (v p1) (v (p1+1)) /\ &0 < azim (vec 0) (v (p1+1)) (v (p1+k-1)) (v p1)` (C SUBGOAL_THEN ASSUME_TAC); REWRITE_TAC[Zlzthic.azim_pos_iff_nz]; FIRST_X_ASSUM_ST `coplanar` MP_TAC; BY(MESON_TAC[Local_lemmas1.AZIM_COND_FOR_COPLANAR;SET_RULE `{a,b,c,d} = {a,d,b,c}`;SET_RULE `{a,b,c,d}={a,c,d,b}`]); CONJ_TAC; TYPIFY `azim (vec 0) (v (p1 + k - 1)) ( (v p1) ) (v (p1 + k - 2)) < pi` ASM_CASES_TAC; INTRO_TAC WNWSHJT_ALT [`v(p1+1)`;`v (p1+k-1)`;`v p1`;`f`;`-- e`;`e`;`pi - azim (vec 0) (v (p1+k-1)) (v (p1+1)) (v (p1+k-2))`]; ANTS_TAC; ASM_REWRITE_TAC[arith `a < pi - b <=> a + b < pi`]; CONJ_TAC; MATCH_MP_TAC Zlzthic.deformation_subset; TYPIFY `IMAGE v (:num)` EXISTS_TAC; ASM_REWRITE_TAC[SUBSET;IN_INSERT;NOT_IN_EMPTY;IN_UNIV]; REWRITE_TAC[IN_IMAGE;IN_UNIV]; BY(MESON_TAC[]); BY(FIRST_X_ASSUM MP_TAC THEN ASM_REWRITE_TAC[]); ASM_REWRITE_TAC[]; REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM_ST `collinear` (C INTRO_TAC [`p1 +k-1`]); ASM_REWRITE_TAC[]; REPEAT WEAKER_STRIP_TAC; INTRO_TAC epsilon_pair [`e1`;`e'`] THEN ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; TYPIFY `e''` EXISTS_TAC THEN ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; SUBCONJ_TAC; MATCH_MP_TAC Fan.sum3_azim_fan; ASM_REWRITE_TAC[]; CONJ_TAC; FIRST_X_ASSUM_ST `( /\ )` (C INTRO_TAC [`t`]); ASM_REWRITE_TAC[]; ANTS_TAC; BY(FIRST_X_ASSUM MATCH_MP_TAC THEN ASM_REWRITE_TAC[]); BY(MP_TAC PI_POS THEN REAL_ARITH_TAC); CONJ_TAC; BY(ONCE_REWRITE_TAC[SET_RULE `{a,b,c} = {a,c,b}`] THEN ASM_REWRITE_TAC[]); BY(FIRST_X_ASSUM MATCH_MP_TAC THEN FIRST_X_ASSUM MATCH_MP_TAC THEN ASM_REWRITE_TAC[]); DISCH_THEN SUBST1_TAC; FIRST_X_ASSUM_ST `( /\ )` (C INTRO_TAC [`t`]); ANTS_TAC; BY(FIRST_X_ASSUM MATCH_MP_TAC THEN ASM_REWRITE_TAC[]); BY(REAL_ARITH_TAC); TYPIFY `(?e1. &0 < e1 /\ (!t. abs t < e1 ==> azim (vec 0) (v (p1 + k - 1)) (f (v p1) t) (v (p1 + 1)) <= azim (vec 0) (v (p1 + k - 1)) (v p1) (v (p1 + 1))))` (C SUBGOAL_THEN MP_TAC); BY(FIRST_X_ASSUM MP_TAC THEN REPEAT (FIRST_X_ASSUM_ST `( \/ )` MP_TAC) THEN MESON_TAC[]); REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM_ST `collinear` (C INTRO_TAC [`(p1+k-1)`]); ASM_REWRITE_TAC[]; REPEAT WEAKER_STRIP_TAC; INTRO_TAC epsilon_pair [`e1`;`e1'`] THEN ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; TYPIFY `e''` EXISTS_TAC THEN ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; INTRO_TAC azim_dominated_split [`(vec 0):real^3`;`v (p1+k-1)`;`v p1`;`v (p1+1)`;`v (p1+k-2)`;`(vec 0):real^3`;`v (p1+k-1)`;`f (v p1) t`;`v (p1+1)`;`v (p1+k-2)`]; ANTS_TAC; ASM_REWRITE_TAC[]; CONJ_TAC; BY(ONCE_REWRITE_TAC[SET_RULE `{a,b,c} = {a,c,b}`] THEN ASM_REWRITE_TAC[]); CONJ_TAC; BY(FIRST_X_ASSUM MATCH_MP_TAC THEN FIRST_X_ASSUM MATCH_MP_TAC THEN ASM_REWRITE_TAC[]); REWRITE_TAC[arith `x <= x`]; BY(FIRST_X_ASSUM MATCH_MP_TAC THEN FIRST_X_ASSUM MATCH_MP_TAC THEN ASM_REWRITE_TAC[]); DISCH_TAC; ASM_REWRITE_TAC[]; FIRST_X_ASSUM (SUBST1_TAC o GSYM); TYPIFY `azim (vec 0) (v (p1 + k - 1)) (v p1) (v (p1 + k - 2)) <= pi` ENOUGH_TO_SHOW_TAC; ASM_REWRITE_TAC[]; FIRST_X_ASSUM_ST `azim` (C INTRO_TAC [`t`]); ANTS_TAC; BY(FIRST_X_ASSUM MATCH_MP_TAC THEN ASM_REWRITE_TAC[]); BY(REAL_ARITH_TAC); FIRST_X_ASSUM_ST `x <= pi` (C INTRO_TAC [`p1 + k - 1`]); FIRST_ASSUM_ST `v (i MOD k) = v i` ((unlist ONCE_REWRITE_TAC) o GSYM); TYPIFY `((p1 + k - 1) + 1 ) MOD k = p1 MOD k /\ ((p1+k-1) + k-1) MOD k = (p1+k - 2) MOD k` ENOUGH_TO_SHOW_TAC; BY(DISCH_THEN (unlist REWRITE_TAC)); FIRST_X_ASSUM_ST `~(k=0)` MP_TAC; BY(SIMP_TAC[arith `~(k <= 3) ==> (p1 + k - 1) + 1 = (1*k + p1) /\ ((p1+k-1)+k-1 = 1*k + (p1+k-2))`;MOD_MULT_ADD]); COMMENT "second branch"; TYPIFY `azim (vec 0) (v (p1 + 1)) (v (p1 + 2) ) (v (p1)) < pi` ASM_CASES_TAC; INTRO_TAC WNWSHJT_ALT [`v(p1)`;`v (p1+1)`;`v (p1+k-1)`;`f`;`-- e`;`e`;`pi - azim (vec 0) (v (p1+1)) (v (p1+2)) (v (p1+k-1))`]; ANTS_TAC; ASM_REWRITE_TAC[arith `a < pi - b <=> b + a < pi`]; CONJ_TAC; MATCH_MP_TAC Zlzthic.deformation_subset; TYPIFY `IMAGE v (:num)` EXISTS_TAC; ASM_REWRITE_TAC[SUBSET;IN_INSERT;NOT_IN_EMPTY;IN_UNIV;IN_IMAGE;IN_UNIV]; BY(MESON_TAC[]); CONJ_TAC; BY(ONCE_REWRITE_TAC[SET_RULE `{a,b,c} = {a,c,b}`] THEN ASM_REWRITE_TAC[]); BY(FIRST_X_ASSUM MP_TAC THEN ASM_REWRITE_TAC[]); REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM_ST `collinear` (C INTRO_TAC [`p1 +1`]); ASM_REWRITE_TAC[]; REPEAT WEAKER_STRIP_TAC; INTRO_TAC epsilon_pair [`e1`;`e'`] THEN ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; TYPIFY `e''` EXISTS_TAC THEN ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; SUBCONJ_TAC; MATCH_MP_TAC Fan.sum3_azim_fan; ASM_REWRITE_TAC[]; CONJ_TAC; FIRST_X_ASSUM_ST `( /\ )` (C INTRO_TAC [`t`]); ASM_REWRITE_TAC[]; ANTS_TAC; BY(FIRST_X_ASSUM MATCH_MP_TAC THEN ASM_REWRITE_TAC[]); BY(MP_TAC PI_POS THEN REAL_ARITH_TAC); CONJ_TAC; BY(ONCE_REWRITE_TAC[SET_RULE `{a,b,c} = {a,c,b}`] THEN ASM_REWRITE_TAC[]); BY(FIRST_X_ASSUM MATCH_MP_TAC THEN FIRST_X_ASSUM MATCH_MP_TAC THEN ASM_REWRITE_TAC[]); DISCH_THEN SUBST1_TAC; FIRST_X_ASSUM_ST `( /\ )` (C INTRO_TAC [`t`]); ANTS_TAC; BY(FIRST_X_ASSUM MATCH_MP_TAC THEN ASM_REWRITE_TAC[]); ASM_REWRITE_TAC[]; BY(REAL_ARITH_TAC); COMMENT "second asm"; TYPIFY `(?e1. &0 < e1 /\ (!t. abs t < e1 ==> azim (vec 0) (v (p1 + 1)) (v (p1 + k - 1)) (f (v p1) t) <= azim (vec 0) (v (p1 + 1)) (v (p1 + k - 1)) ( (v p1) )))` (C SUBGOAL_THEN MP_TAC); BY(FIRST_X_ASSUM MP_TAC THEN REPEAT (FIRST_X_ASSUM_ST `( \/ )` MP_TAC) THEN MESON_TAC[]); REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM_ST `collinear` (C INTRO_TAC [`(p1+1)`]); ASM_REWRITE_TAC[]; REPEAT WEAKER_STRIP_TAC; INTRO_TAC epsilon_pair [`e1`;`e1'`] THEN ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; TYPIFY `e''` EXISTS_TAC THEN ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; INTRO_TAC azim_dominated_split [`(vec 0):real^3`;`v (p1+1)`;`v (p1+2)`;`v (p1+k-1)`;`v (p1)`;`(vec 0):real^3`;`v (p1+1)`;`v (p1+2)`;`v (p1+k-1)`;`f (v p1) t`]; ANTS_TAC; ASM_REWRITE_TAC[]; CONJ_TAC; BY(ONCE_REWRITE_TAC[SET_RULE `{a,b,c} = {a,c,b}`] THEN ASM_REWRITE_TAC[]); CONJ_TAC; BY(FIRST_X_ASSUM MATCH_MP_TAC THEN FIRST_X_ASSUM MATCH_MP_TAC THEN ASM_REWRITE_TAC[]); REWRITE_TAC[arith `x <= x`]; BY(FIRST_X_ASSUM MATCH_MP_TAC THEN FIRST_X_ASSUM MATCH_MP_TAC THEN ASM_REWRITE_TAC[]); DISCH_TAC; ASM_REWRITE_TAC[]; FIRST_X_ASSUM (SUBST1_TAC o GSYM); TYPIFY `azim (vec 0) (v (p1 + 1)) (v (p1+2)) (v (p1)) <= pi` ENOUGH_TO_SHOW_TAC; ASM_REWRITE_TAC[]; FIRST_X_ASSUM_ST `azim` (C INTRO_TAC [`t`]); ANTS_TAC; BY(FIRST_X_ASSUM MATCH_MP_TAC THEN ASM_REWRITE_TAC[]); BY(REAL_ARITH_TAC); FIRST_X_ASSUM_ST `x <= pi` (C INTRO_TAC [`p1 + 1`]); FIRST_ASSUM_ST `v (i MOD k) = v i` ((unlist ONCE_REWRITE_TAC) o GSYM); TYPIFY `((p1 + 1) + k - 1) MOD k = p1 MOD k` ENOUGH_TO_SHOW_TAC; DISCH_THEN (unlist REWRITE_TAC); BY(REWRITE_TAC[arith `(p1 + 1) + 1 = p1 + 2`]); FIRST_X_ASSUM_ST `~(k=0)` MP_TAC; BY(SIMP_TAC[arith `~(k <= 3) ==> ((p1 + 1) + k - 1 = 1*k + p1)`;MOD_MULT_ADD]); COMMENT "final kill"; TYPIFY `!i. (f (v i) (&0)) = v i` (C SUBGOAL_THEN ASSUME_TAC); FIRST_X_ASSUM_ST `deformation` MP_TAC THEN REWRITE_TAC[Localization.deformation]; REWRITE_TAC[IN_IMAGE;IN_UNIV]; BY(MESON_TAC[]); COMMENT "final kill"; FIRST_X_ASSUM_ST `azim` MP_TAC THEN REPEAT WEAKER_STRIP_TAC; CONJ_TAC; GEN_TAC; TYPIFY `~(p1 MOD k = i MOD k) /\ ~(p1 MOD k = (i + 1) MOD k) /\ ~(p1 MOD k = (i + k - 1) MOD k)` ASM_CASES_TAC; TYPIFY `&1` EXISTS_TAC; REWRITE_TAC[arith `&0 < &1`]; ASM_SIMP_TAC[]; BY(REWRITE_TAC[arith `pi <= pi`]); RULE_ASSUM_TAC (REWRITE_RULE[DE_MORGAN_THM]); FIRST_X_ASSUM MP_TAC THEN REPEAT STRIP_TAC; TYPIFY ` azim (vec 0) (v i) (v (i + 1)) (v (i + k - 1)) < pi` ENOUGH_TO_SHOW_TAC; BY(MESON_TAC[arith `x < pi ==> ~(x =pi)`;arith `&0 < &1`]); TYPIFY `azim (vec 0) (v i) (v (i + 1)) (v (i + k - 1)) = azim (vec 0) (v p1) (v (p1 + 1)) (v (p1 + k - 1))` ENOUGH_TO_SHOW_TAC; BY(DISCH_THEN SUBST1_TAC THEN ASM_REWRITE_TAC[]); REPEAT (FIRST_X_ASSUM_ST `MOD` (C INTRO_TAC [`i`;`&0`])) THEN ASM_REWRITE_TAC[]; BY(MESON_TAC[]); TYPIFY `e1` EXISTS_TAC; ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; ASM_SIMP_TAC[]; FIRST_X_ASSUM_ST `p1+k-2` (C INTRO_TAC [`t`]); ASM_REWRITE_TAC[]; BY(REAL_ARITH_TAC); TYPIFY `e1'` EXISTS_TAC; ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; ASM_SIMP_TAC[]; FIRST_X_ASSUM (C INTRO_TAC [`t`]); ASM_REWRITE_TAC[]; BY(REAL_ARITH_TAC); COMMENT "last one"; INTRO_TAC epsilon_pair [`e1`;`e1'`] THEN ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; TYPIFY `e''` EXISTS_TAC; ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; BY(CONJ_TAC THEN FIRST_X_ASSUM MP_TAC THEN (REPLICATE_TAC 4 (FIRST_X_ASSUM (C INTRO_TAC [`t`]))) THEN TRY REAL_ARITH_TAC) ]);; (* }}} *)
let sin_azim_pos = 
prove_by_refinement( `!v1 v2 v3 v4. &0 < sin (azim v1 v2 v3 v4) <=> (&0 < azim v1 v2 v3 v4 /\ azim v1 v2 v3 v4 < pi)`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; BY(MESON_TAC[SIN_POS_PI;SIN_POS_PI_REV;Local_lemmas.AZIM_RANGE;arith `x < y ==> x <= y`]) ]);;
(* }}} *)
let dih_x5_mono = 
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 /\ delta_x6 x1 x2 x3 x4 x5 x6 < &0 ==> (?e. &0 < e /\ (!t. abs t < e /\ (t <= &0) ==> dih_x x1 x2 x3 x4 (x5+t) x6 <= dih_x x1 x2 x3 x4 x5 x6))`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; TYPIFY ` (?e1. &0 < e1 /\ (!t. abs t < e1 ==> &0 < delta_x x1 x2 x3 x4 (x5+t) x6)) /\ (?e2. &0 < e2 /\ (!t. abs t < e2 ==> &0 < ups_x x1 x3 (x5+t))) /\ (?e3. &0 < e3 /\ (!t. abs t < e3 ==> delta_x6 x1 x2 x3 x4 (x5+t) x6 < &0))` ENOUGH_TO_SHOW_TAC; REPEAT WEAKER_STRIP_TAC; INTRO_TAC epsilon_triple [`e1`;`e2`;`e3`] THEN ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; TYPIFY `e'''` EXISTS_TAC; ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; TYPIFY `!x. x IN real_interval [x5 + t,x5] ==> (?t1. t1 <= &0 /\ abs t1 < e''' /\ x = x5 + t1)` (C SUBGOAL_THEN ASSUME_TAC); BY(GEN_TAC THEN REWRITE_TAC[IN_REAL_INTERVAL] THEN DISCH_TAC THEN TYPIFY `x - x5` EXISTS_TAC THEN REPLICATE_TAC 3(FIRST_X_ASSUM MP_TAC) THEN REAL_ARITH_TAC); INTRO_TAC REAL_MVT_VERY_SIMPLE [`\q. dih_x x1 x2 x3 x4 q x6`;`\ q. (--sqrt x1 * delta_x6 x1 x2 x3 x4 q x6 / (ups_x x1 x3 q * sqrt (delta_x x1 x2 x3 x4 q x6)))`;`x5+t`;`x5`]; REWRITE_TAC[]; ANTS_TAC; ASM_SIMP_TAC[arith `t <= &0 ==> x5 + t <= x5`]; X_GEN_TAC `x5':real`; REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM (C INTRO_TAC [`x5'`]) THEN ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; INTRO_TAC Ocbicby.derived_form_dih_x_wrt_x5 [`x1`;`x2`;`x3`;`x4`;`x5'`;`x6`]; REWRITE_TAC[Calc_derivative.derived_form;WITHINREAL_UNIV]; ASM_SIMP_TAC[]; DISCH_TAC; MATCH_MP_TAC HAS_REAL_DERIVATIVE_ATREAL_WITHIN; BY(ASM_REWRITE_TAC[]); REPEAT WEAKER_STRIP_TAC; ONCE_REWRITE_TAC[arith `a <= b <=> &0 <= b - a`]; ASM_REWRITE_TAC[]; REWRITE_TAC[arith `&0 <= (-- s * d / dn) * (x5 - (x5 + t)) <=> &0 <= s * (-- d) * (-- t) / dn`]; REPEAT (GMATCH_SIMP_TAC REAL_LE_MUL); GMATCH_SIMP_TAC REAL_LE_DIV; GMATCH_SIMP_TAC REAL_LE_MUL; GMATCH_SIMP_TAC SQRT_POS_LE; GMATCH_SIMP_TAC SQRT_POS_LE; FIRST_X_ASSUM (C INTRO_TAC [`x`]) THEN ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; ASM_SIMP_TAC[arith `&0 < x ==> &0 <= x`;arith `t <= &0 ==> &0 <= --t`]; BY(ASM_SIMP_TAC[arith `d < &0 ==> &0 <= -- d`]); COMMENT "continuity";
INTRO_TAC continuous_nbd_pos [`\t. delta_x x1 x2 x3 x4 (x5 + t) x6`;`&0`]; INTRO_TAC continuous_nbd_pos [`\t. ups_x x1 x3 (x5 + t)`;`&0`]; INTRO_TAC continuous_nbd_pos [`\t. -- delta_x6 x1 x2 x3 x4 (x5 + t) x6`;`&0`]; ASM_SIMP_TAC[arith `d < &0 ==> &0 < --d`;arith `abs(t' - &0) = abs t'`;arith `x + &0 = x`]; TYPIFY_GOAL_THEN `(\t. --delta_x6 x1 x2 x3 x4 (x5 + t) x6) real_continuous atreal (&0) /\ (\t. ups_x x1 x3 (x5 + t)) real_continuous atreal (&0) /\ (\t. delta_x x1 x2 x3 x4 (x5 + t) x6) real_continuous atreal (&0)` (unlist REWRITE_TAC); REWRITE_TAC[Sphere.delta_x6;Sphere.ups_x;Sphere.delta_x]; BY(REPEAT (REPEAT CONJ_TAC THEN ( MATCH_MP_TAC REAL_CONTINUOUS_ADD ORELSE MATCH_MP_TAC REAL_CONTINUOUS_NEG ORELSE MATCH_MP_TAC REAL_CONTINUOUS_MUL ORELSE MATCH_MP_TAC REAL_CONTINUOUS_SUB THEN ASM_REWRITE_TAC[REAL_CONTINUOUS_AT_ID;REAL_CONTINUOUS_CONST;CONTINUOUS_CONST]))); REPEAT WEAKER_STRIP_TAC; BY(ASM_MESON_TAC[arith `&0 < --d <=> d < &0`]) ]);; (* }}} *)
let delta_x5_delta_x6 = 
prove_by_refinement( `!x1 x2 x3 x4 x5 x6. delta_x6 x1 x3 x2 x4 x6 x5 = delta_x5 x1 x2 x3 x4 x5 x6`,
(* {{{ proof *) [ REWRITE_TAC[Sphere.delta_x6;Nonlin_def.delta_x5]; BY(REAL_ARITH_TAC) ]);;
(* }}} *)
let dih_obtuse_mono = 
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 /\ delta_x5 x1 x2 x3 x4 x5 x6 < &0 ==> (?e. &0 < e /\ (!t. abs t < e /\ t <= &0 ==> dih_x x1 x2 x3 (x4+t) x5 (x6) <= dih_x x1 x2 x3 x4 x5 x6 /\ dih_x x1 x2 x3 (x4) x5 (x6+t) <= dih_x x1 x2 x3 x4 x5 x6))`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; TYPIFY ` (?e1. &0 < e1 /\ (!t. abs t < e1 ==> &0 < delta_x x1 x2 x3 (x4+t) (x5) x6))` (C SUBGOAL_THEN MP_TAC); INTRO_TAC continuous_nbd_pos [`\t. delta_x x1 x2 x3 (x4+t) x5 x6`;`&0`]; ASM_SIMP_TAC[arith `d < &0 ==> &0 < --d`;arith `abs(t' - &0) = abs t'`;arith `x + &0 = x`]; DISCH_THEN MATCH_MP_TAC; REWRITE_TAC[Sphere.delta_x6;Sphere.ups_x;Sphere.delta_x]; BY(REPEAT (REPEAT CONJ_TAC THEN ( MATCH_MP_TAC REAL_CONTINUOUS_ADD ORELSE MATCH_MP_TAC REAL_CONTINUOUS_NEG ORELSE MATCH_MP_TAC REAL_CONTINUOUS_MUL ORELSE MATCH_MP_TAC REAL_CONTINUOUS_SUB THEN ASM_REWRITE_TAC[REAL_CONTINUOUS_AT_ID;REAL_CONTINUOUS_CONST;CONTINUOUS_CONST]))); REPEAT WEAKER_STRIP_TAC; INTRO_TAC dih_x5_mono [`x1`;`x3`;`x2`;`x4`;`x6`;`x5`]; ANTS_TAC; ASM_REWRITE_TAC[]; CONJ_TAC; REPEAT (FIRST_X_ASSUM_ST `delta_x` MP_TAC); BY(MESON_TAC[Merge_ineq.delta_x_sym]); FIRST_X_ASSUM_ST `delta_x5` MP_TAC; BY(REWRITE_TAC[delta_x5_delta_x6]); REPEAT WEAKER_STRIP_TAC; INTRO_TAC epsilon_pair [`e1`;`e`] THEN ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; TYPIFY `e''` EXISTS_TAC; ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; CONJ2_TAC; ONCE_REWRITE_TAC[Nonlinear_lemma.dih_x_sym]; FIRST_X_ASSUM MATCH_MP_TAC; BY(ASM_MESON_TAC[]); TYPIFY `t = &0` ASM_CASES_TAC; BY(ASM_REWRITE_TAC[arith `x + &0 = x`;arith `x <= x`]); INTRO_TAC Tame_inequalities.DIH_X_MONO_LT_4 [`x1`;`x2`;`x3`;`x4+t`;`x5`;`x6`;`x4`]; ANTS_TAC; ASM_SIMP_TAC[]; BY(REPLICATE_TAC 2 (FIRST_X_ASSUM MP_TAC) THEN REAL_ARITH_TAC); BY(REAL_ARITH_TAC) ]);;
(* }}} *)
let dih_obtuse_mono_b = 
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 ==> (?e. &0 < e /\ (!t. abs t < e /\ t <= &0 ==> dih_x x1 x2 x3 (x4+t) x5 (x6) <= dih_x x1 x2 x3 x4 x5 x6))`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; TYPIFY ` (?e1. &0 < e1 /\ (!t. abs t < e1 ==> &0 < delta_x x1 x2 x3 (x4+t) (x5) x6))` (C SUBGOAL_THEN MP_TAC); INTRO_TAC continuous_nbd_pos [`\t. delta_x x1 x2 x3 (x4+t) x5 x6`;`&0`]; ASM_SIMP_TAC[arith `d < &0 ==> &0 < --d`;arith `abs(t' - &0) = abs t'`;arith `x + &0 = x`]; DISCH_THEN MATCH_MP_TAC; REWRITE_TAC[Sphere.delta_x6;Sphere.ups_x;Sphere.delta_x]; BY(REPEAT (REPEAT CONJ_TAC THEN ( MATCH_MP_TAC REAL_CONTINUOUS_ADD ORELSE MATCH_MP_TAC REAL_CONTINUOUS_NEG ORELSE MATCH_MP_TAC REAL_CONTINUOUS_MUL ORELSE MATCH_MP_TAC REAL_CONTINUOUS_SUB THEN ASM_REWRITE_TAC[REAL_CONTINUOUS_AT_ID;REAL_CONTINUOUS_CONST;CONTINUOUS_CONST]))); REPEAT WEAKER_STRIP_TAC; TYPIFY `e1` EXISTS_TAC; ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; TYPIFY `t = &0` ASM_CASES_TAC; BY(ASM_REWRITE_TAC[arith `x + &0 = x`;arith `x <= x`]); INTRO_TAC Tame_inequalities.DIH_X_MONO_LT_4 [`x1`;`x2`;`x3`;`x4+t`;`x5`;`x6`;`x4`]; ANTS_TAC; ASM_SIMP_TAC[]; BY(REPLICATE_TAC 2 (FIRST_X_ASSUM MP_TAC) THEN REAL_ARITH_TAC); BY(REAL_ARITH_TAC) ]);;
(* }}} *)
let square_add_neg_lemma = 
prove_by_refinement( `!y t. t <= &0 /\ &0 <= t + &2 * y ==> &2 * y * t + t*t <= &0`,
(* {{{ proof *) [ REWRITE_TAC[arith `a <= &0 <=> &0 <= --a` ;arith `--(&2 * y * t + t*t) = (--t) * (t+ &2 * y)`]; REPEAT WEAKER_STRIP_TAC; GMATCH_SIMP_TAC REAL_LE_MUL; BY(ASM_REWRITE_TAC[]) ]);;
(* }}} *)
let dihV_obtuse_mono_a = 
prove_by_refinement( `!(v0:real^3) v1 v2 v3. ~coplanar {v0,v1,v2,v3} /\ pi / &2 < dihV v0 v2 v3 v1 ==> (?e. (!v2'. &0 < e /\ (!t. abs t < e /\ t <= &0 /\ dist (v0,v2') = dist(v0,v2) /\ dist (v1,v2') = dist(v1,v2) /\ dist(v2',v3)=dist(v2,v3) + t ==> dihV v0 v3 v2' v1 <= dihV v0 v3 v2 v1)))`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; INTRO_TAC Merge_ineq.DIHV_DIH_X [`v0`;`v2`;`v3`;`v1`]; INTRO_TAC Merge_ineq.DIHV_DIH_X [`v0`;`v3`;`v2`;`v1`]; REWRITE_TAC[LET_THM;GSYM Collect_geom2.NOT_COL_EQ_UPS_X_POS]; TYPIFY `~collinear {v0, v3, v2} /\ ~collinear {v0, v3, v1} /\ ~collinear {v0, v2, v3} /\ ~collinear {v0, v2, v1} /\ ~collinear {v0, v1, v2} /\ ~collinear {v0, v1, v3}` (C SUBGOAL_THEN ASSUME_TAC); BY(ASM_MESON_TAC[Planarity.notcoplanar_imp_notcollinear_fan;SET_RULE `{a,b,c} = {a,c,b}`]); ASM_REWRITE_TAC[]; REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM_ST `pi` MP_TAC THEN ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; ASM_TAC THEN REWRITE_TAC[DIST_SYM] THEN REPEAT WEAKER_STRIP_TAC; TYPIFY `&0 < dist (v0,v3) pow 2 /\ &0 < dist (v0,v2) pow 2 /\ &0 < dist(v2,v3) /\ &0 < delta_x (dist (v0,v2) pow 2) (dist (v0,v3) pow 2) (dist (v0,v1) pow 2) (dist (v1,v3) pow 2) (dist (v1,v2) pow 2) (dist (v2,v3) pow 2)` (C SUBGOAL_THEN ASSUME_TAC); REWRITE_TAC[GSYM Trigonometry2.NOT_ZERO_EQ_POW2_LT]; REWRITE_TAC[GSYM DIST_NZ]; REWRITE_TAC[DIST_EQ_0]; REWRITE_TAC[CONJ_ASSOC]; CONJ_TAC; BY(ASM_MESON_TAC[ COPLANAR_3;SET_RULE `{a,b,a,c} = {a,b,c}`;SET_RULE `{a,b,c,a}={a,b,c}`;SET_RULE `{a,b,c,c} = {a,b,c}`]); REWRITE_TAC[GSYM Sphere.delta_y;arith `x pow 2 = x*x`]; FIRST_X_ASSUM_ST `coplanar` MP_TAC THEN REWRITE_TAC[Oxlzlez.coplanar_delta_y]; REWRITE_TAC[DIST_SYM;Sphere.delta_y]; BY(MESON_TAC[Merge_ineq.delta_x_sym]); MP_TAC (ONCE_REWRITE_RULE[MESON[] `!a b c d. (a /\ b /\ c ==> d) <=> (c ==> (a /\ b ==> d))`] Merge_ineq.dih_gt_pi2); DISCH_THEN (fun t -> FIRST_X_ASSUM (MP_TAC o (MATCH_MP t))); ANTS_TAC; BY(ASM_REWRITE_TAC[]); DISCH_TAC; INTRO_TAC continuous_nbd_pos [`\t. ups_x (dist(v0,v3) pow 2) (dist(v0,v2) pow 2) ( (dist(v2,v3)+t) pow 2)`;`&0`]; ASM_SIMP_TAC[arith `d < &0 ==> &0 < --d`;arith `abs(t' - &0) = abs t'`;arith `x + &0 = x`]; ANTS_TAC; CONJ_TAC; REWRITE_TAC[Sphere.delta_x6;Sphere.ups_x;Sphere.delta_x]; BY(REPEAT (REPEAT CONJ_TAC THEN ( MATCH_MP_TAC REAL_CONTINUOUS_ADD ORELSE MATCH_MP_TAC REAL_CONTINUOUS_NEG ORELSE MATCH_MP_TAC REAL_CONTINUOUS_MUL ORELSE MATCH_MP_TAC REAL_CONTINUOUS_SUB ORELSE MATCH_MP_TAC REAL_CONTINUOUS_POW THEN ASM_REWRITE_TAC[REAL_CONTINUOUS_AT_ID;REAL_CONTINUOUS_CONST;CONTINUOUS_CONST]))); REPEAT (FIRST_X_ASSUM_ST `collinear` MP_TAC) THEN REWRITE_TAC[Collect_geom2.NOT_COL_EQ_UPS_X_POS;DIST_SYM]; BY(DISCH_THEN (unlist REWRITE_TAC)); REPEAT WEAKER_STRIP_TAC; INTRO_TAC continuous_nbd_pos [`\t. delta_x (dist (v0,v2) pow 2) (dist (v0,v3) pow 2) (dist (v0,v1) pow 2) (dist (v1,v3) pow 2) (dist (v1,v2) pow 2) ((dist (v2,v3)+t) pow 2)`;`&0`]; ASM_SIMP_TAC[arith `d < &0 ==> &0 < --d`;arith `abs(t' - &0) = abs t'`;arith `x + &0 = x`]; ANTS_TAC; REWRITE_TAC[Sphere.delta_x6;Sphere.ups_x;Sphere.delta_x]; BY(REPEAT (REPEAT CONJ_TAC THEN ( MATCH_MP_TAC REAL_CONTINUOUS_ADD ORELSE MATCH_MP_TAC REAL_CONTINUOUS_NEG ORELSE MATCH_MP_TAC REAL_CONTINUOUS_MUL ORELSE MATCH_MP_TAC REAL_CONTINUOUS_SUB ORELSE MATCH_MP_TAC REAL_CONTINUOUS_POW THEN ASM_REWRITE_TAC[REAL_CONTINUOUS_AT_ID;REAL_CONTINUOUS_CONST;CONTINUOUS_CONST]))); REPEAT WEAKER_STRIP_TAC; INTRO_TAC dih_obtuse_mono [`dist(v0,v3) pow 2`;`dist(v0,v2) pow 2`;`dist(v0,v1) pow 2`;`dist(v1,v2) pow 2`;`dist(v1,v3) pow 2`;`(dist(v2,v3)) pow 2`]; ANTS_TAC; ASM_REWRITE_TAC[]; CONJ_TAC; BY(REPEAT (FIRST_X_ASSUM_ST `delta_x` MP_TAC) THEN REWRITE_TAC[DIST_SYM] THEN MESON_TAC[Merge_ineq.delta_x_sym]); REWRITE_TAC[CONJ_ASSOC]; CONJ_TAC; BY(REPEAT (FIRST_X_ASSUM_ST `collinear` MP_TAC) THEN ONCE_REWRITE_TAC[SET_RULE `{a,b,c} = {a,c,b}`] THEN REWRITE_TAC[Collect_geom2.NOT_COL_EQ_UPS_X_POS;DIST_SYM] THEN MESON_TAC[]); BY(FIRST_X_ASSUM_ST `delta_x4` MP_TAC THEN REWRITE_TAC[Sphere.delta_x4;Nonlin_def.delta_x5;DIST_SYM] THEN REAL_ARITH_TAC); REPEAT WEAKER_STRIP_TAC; TYPIFY `?e2. &0 < e2 /\ (!t. abs t < e2 /\ t <= &0 ==> &2 * dist(v2,v3) * t + t * t <= &0 /\ abs(&2 * dist(v2,v3)*t + t*t ) < e'')` (C SUBGOAL_THEN MP_TAC); TYPIFY `(?e2. &0 < e2 /\ (!t. abs t < e2 /\ t <= &0 ==> &2 * dist(v2,v3) * t + t * t <= &0 )) /\ (?e2. &0 < e2 /\ (!t. abs t < e2 /\ t <= &0 ==> abs(&2 * dist(v2,v3)*t + t*t ) < e''))` ENOUGH_TO_SHOW_TAC; REPEAT WEAKER_STRIP_TAC; INTRO_TAC epsilon_pair [`e2`;`e2'`] THEN ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; TYPIFY `e'''` EXISTS_TAC; ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; BY(CONJ_TAC THEN FIRST_X_ASSUM MATCH_MP_TAC THEN ASM_REWRITE_TAC[] THEN FIRST_X_ASSUM MATCH_MP_TAC THEN ASM_REWRITE_TAC[]); CONJ_TAC; TYPIFY `&2 * dist(v2,v3)` EXISTS_TAC; REWRITE_TAC[arith `&0 < &2 * x <=> &0 < x`]; REWRITE_TAC[GSYM DIST_NZ]; CONJ_TAC; BY(ASM_MESON_TAC[ COPLANAR_3;SET_RULE `{a,b,c,c} = {a,b,c}`]); REPEAT WEAKER_STRIP_TAC; MATCH_MP_TAC square_add_neg_lemma; ASM_REWRITE_TAC[]; BY(FIRST_X_ASSUM_ST `abs` MP_TAC THEN REAL_ARITH_TAC); REPEAT WEAKER_STRIP_TAC; INTRO_TAC continuous_nbd_pos [`\t. e'' - abs(&2 * dist(v2,v3)*t + t*t)`;`&0`]; ASM_SIMP_TAC[arith `d < &0 ==> &0 < --d`;arith `abs(t' - &0) = abs t'`;arith `x + &0 = x`]; ANTS_TAC; CONJ2_TAC; BY(FIRST_X_ASSUM_ST `&0 < e''` MP_TAC THEN REAL_ARITH_TAC); BY(REPEAT (REPEAT CONJ_TAC THEN ( MATCH_MP_TAC REAL_CONTINUOUS_ADD ORELSE MATCH_MP_TAC REAL_CONTINUOUS_NEG ORELSE MATCH_MP_TAC REAL_CONTINUOUS_ABS ORELSE MATCH_MP_TAC REAL_CONTINUOUS_MUL ORELSE MATCH_MP_TAC REAL_CONTINUOUS_SUB ORELSE MATCH_MP_TAC REAL_CONTINUOUS_POW THEN ASM_REWRITE_TAC[REAL_CONTINUOUS_AT_ID;REAL_CONTINUOUS_CONST;CONTINUOUS_CONST]))); BY(MESON_TAC[arith `&0 < e'' - a <=> a < e''`]); REPEAT WEAKER_STRIP_TAC; INTRO_TAC epsilon_quad [`e`;`e'`;`e2`;`e''`] THEN ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; TYPIFY `e''''` EXISTS_TAC; ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; INTRO_TAC Merge_ineq.DIHV_DIH_X [`v0`;`v3`;`v2'`;`v1`]; ASM_REWRITE_TAC[LET_THM]; ANTS_TAC; ASM_TAC THEN REWRITE_TAC[DIST_SYM] THEN REPEAT WEAKER_STRIP_TAC; ASM_REWRITE_TAC[]; CONJ_TAC; BY(FIRST_X_ASSUM MATCH_MP_TAC THEN FIRST_X_ASSUM MATCH_MP_TAC THEN ASM_REWRITE_TAC[]); BY(FIRST_X_ASSUM_ST `collinear` MP_TAC THEN ONCE_REWRITE_TAC[SET_RULE `{a,b,c} = {a,c,b}`] THEN REWRITE_TAC[Collect_geom2.NOT_COL_EQ_UPS_X_POS;DIST_SYM]); DISCH_THEN SUBST1_TAC; ASM_REWRITE_TAC[arith `(x+y) pow 2 = x pow 2 + (&2 * x * y + y* y)`;DIST_SYM]; FIRST_X_ASSUM_ST `dist` (C INTRO_TAC [`t`]) THEN ANTS_TAC THEN ASM_REWRITE_TAC[]; BY(FIRST_X_ASSUM MATCH_MP_TAC THEN ASM_REWRITE_TAC[]); REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM_ST `dih_x` (C INTRO_TAC [`&2 * dist(v2,v3) *t + t*t`]); ASM_REWRITE_TAC[]; BY(MESON_TAC[]) ]);;
(* }}} *) (* redo with dih_obtuse_mono_b w/o obtuse *) (* let dihV_obtuse_mono_b = prove_by_refinement( `!(v0:real^3) v1 v2 v3. ~coplanar {v0,v1,v2,v3} /\ pi / &2 < dihV v0 v2 v3 v1 ==> (?e. (!v2'. &0 < e /\ (!t. abs t < e /\ t <= &0 /\ dist (v0,v2') = dist(v0,v2) /\ dist (v1,v2') = dist(v1,v2) /\ dist(v2',v3)=dist(v2,v3) + t ==> dihV v0 v1 v2' v3 <= dihV v0 v1 v2 v3)))`, (* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; INTRO_TAC Merge_ineq.DIHV_DIH_X [`v0`;`v2`;`v3`;`v1`]; INTRO_TAC Merge_ineq.DIHV_DIH_X [`v0`;`v3`;`v2`;`v1`]; INTRO_TAC Merge_ineq.DIHV_DIH_X [`v0`;`v1`;`v2`;`v3`]; REWRITE_TAC[LET_THM;GSYM Collect_geom2.NOT_COL_EQ_UPS_X_POS]; TYPIFY `~collinear {v0, v3, v2} /\ ~collinear {v0, v3, v1} /\ ~collinear {v0, v2, v3} /\ ~collinear {v0, v2, v1} /\ ~collinear {v0, v1, v2} /\ ~collinear {v0, v1, v3}` (C SUBGOAL_THEN ASSUME_TAC); BY(ASM_MESON_TAC[Planarity.notcoplanar_imp_notcollinear_fan;SET_RULE `{a,b,c} = {a,c,b}`]); ASM_REWRITE_TAC[]; REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM_ST `pi` MP_TAC THEN ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; ASM_TAC THEN REWRITE_TAC[DIST_SYM] THEN REPEAT WEAKER_STRIP_TAC; TYPIFY `&0 < dist(v0,v1) pow 2 /\ &0 < dist (v0,v3) pow 2 /\ &0 < dist (v0,v2) pow 2 /\ &0 < dist(v2,v3) /\ &0 < delta_x (dist (v0,v2) pow 2) (dist (v0,v3) pow 2) (dist (v0,v1) pow 2) (dist (v1,v3) pow 2) (dist (v1,v2) pow 2) (dist (v2,v3) pow 2)` (C SUBGOAL_THEN ASSUME_TAC); REWRITE_TAC[GSYM Trigonometry2.NOT_ZERO_EQ_POW2_LT]; REWRITE_TAC[GSYM DIST_NZ]; REWRITE_TAC[DIST_EQ_0]; REWRITE_TAC[CONJ_ASSOC]; CONJ_TAC; BY(ASM_MESON_TAC[ COPLANAR_3;SET_RULE `{a,a,b,c} = {a,b,c}`;SET_RULE `{a,b,a,c} = {a,b,c}`;SET_RULE `{a,b,c,a}={a,b,c}`;SET_RULE `{a,b,c,c} = {a,b,c}`]); REWRITE_TAC[GSYM Sphere.delta_y;arith `x pow 2 = x*x`]; FIRST_X_ASSUM_ST `coplanar` MP_TAC THEN REWRITE_TAC[Oxlzlez.coplanar_delta_y]; REWRITE_TAC[DIST_SYM;Sphere.delta_y]; BY(MESON_TAC[Merge_ineq.delta_x_sym]); MP_TAC (ONCE_REWRITE_RULE[MESON[] `!a b c d. (a /\ b /\ c ==> d) <=> (c ==> (a /\ b ==> d))`] Merge_ineq.dih_gt_pi2); DISCH_THEN (fun t -> FIRST_X_ASSUM (MP_TAC o (MATCH_MP t))); ANTS_TAC; BY(ASM_REWRITE_TAC[]); DISCH_TAC; INTRO_TAC continuous_nbd_pos [`\t. ups_x (dist(v0,v3) pow 2) (dist(v0,v2) pow 2) ( (dist(v2,v3)+t) pow 2)`;`&0`]; ASM_SIMP_TAC[arith `d < &0 ==> &0 < --d`;arith `abs(t' - &0) = abs t'`;arith `x + &0 = x`]; ANTS_TAC; CONJ_TAC; REWRITE_TAC[Sphere.delta_x6;Sphere.ups_x;Sphere.delta_x]; BY(REPEAT (REPEAT CONJ_TAC THEN ( MATCH_MP_TAC REAL_CONTINUOUS_ADD ORELSE MATCH_MP_TAC REAL_CONTINUOUS_NEG ORELSE MATCH_MP_TAC REAL_CONTINUOUS_MUL ORELSE MATCH_MP_TAC REAL_CONTINUOUS_SUB ORELSE MATCH_MP_TAC REAL_CONTINUOUS_POW THEN ASM_REWRITE_TAC[REAL_CONTINUOUS_AT_ID;REAL_CONTINUOUS_CONST;CONTINUOUS_CONST]))); REPEAT (FIRST_X_ASSUM_ST `collinear` MP_TAC) THEN REWRITE_TAC[Collect_geom2.NOT_COL_EQ_UPS_X_POS;DIST_SYM]; BY(DISCH_THEN (unlist REWRITE_TAC)); REPEAT WEAKER_STRIP_TAC; INTRO_TAC continuous_nbd_pos [`\t. delta_x (dist (v0,v2) pow 2) (dist (v0,v3) pow 2) (dist (v0,v1) pow 2) (dist (v1,v3) pow 2) (dist (v1,v2) pow 2) ((dist (v2,v3)+t) pow 2)`;`&0`]; ASM_SIMP_TAC[arith `d < &0 ==> &0 < --d`;arith `abs(t' - &0) = abs t'`;arith `x + &0 = x`]; ANTS_TAC; REWRITE_TAC[Sphere.delta_x6;Sphere.ups_x;Sphere.delta_x]; BY(REPEAT (REPEAT CONJ_TAC THEN ( MATCH_MP_TAC REAL_CONTINUOUS_ADD ORELSE MATCH_MP_TAC REAL_CONTINUOUS_NEG ORELSE MATCH_MP_TAC REAL_CONTINUOUS_MUL ORELSE MATCH_MP_TAC REAL_CONTINUOUS_SUB ORELSE MATCH_MP_TAC REAL_CONTINUOUS_POW THEN ASM_REWRITE_TAC[REAL_CONTINUOUS_AT_ID;REAL_CONTINUOUS_CONST;CONTINUOUS_CONST]))); REPEAT WEAKER_STRIP_TAC; INTRO_TAC dih_obtuse_mono [`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`]; ANTS_TAC; ASM_REWRITE_TAC[]; CONJ_TAC; BY(REPEAT (FIRST_X_ASSUM_ST `delta_x` MP_TAC) THEN REWRITE_TAC[DIST_SYM] THEN MESON_TAC[Merge_ineq.delta_x_sym]); REWRITE_TAC[CONJ_ASSOC]; CONJ_TAC; BY(REPEAT (FIRST_X_ASSUM_ST `collinear` MP_TAC) THEN REWRITE_TAC[Collect_geom2.NOT_COL_EQ_UPS_X_POS;DIST_SYM] THEN MESON_TAC[]); BY(FIRST_X_ASSUM_ST `delta_x4` MP_TAC THEN REWRITE_TAC[Sphere.delta_x4;Nonlin_def.delta_x5;DIST_SYM] THEN REAL_ARITH_TAC); REPEAT WEAKER_STRIP_TAC; TYPIFY `?e2. &0 < e2 /\ (!t. abs t < e2 /\ t <= &0 ==> &2 * dist(v2,v3) * t + t * t <= &0 /\ abs(&2 * dist(v2,v3)*t + t*t ) < e'')` (C SUBGOAL_THEN MP_TAC); TYPIFY `(?e2. &0 < e2 /\ (!t. abs t < e2 /\ t <= &0 ==> &2 * dist(v2,v3) * t + t * t <= &0 )) /\ (?e2. &0 < e2 /\ (!t. abs t < e2 /\ t <= &0 ==> abs(&2 * dist(v2,v3)*t + t*t ) < e''))` ENOUGH_TO_SHOW_TAC; REPEAT WEAKER_STRIP_TAC; INTRO_TAC epsilon_pair [`e2`;`e2'`] THEN ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; TYPIFY `e'''` EXISTS_TAC; ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; BY(CONJ_TAC THEN FIRST_X_ASSUM MATCH_MP_TAC THEN ASM_REWRITE_TAC[] THEN FIRST_X_ASSUM MATCH_MP_TAC THEN ASM_REWRITE_TAC[]); CONJ_TAC; TYPIFY `&2 * dist(v2,v3)` EXISTS_TAC; REWRITE_TAC[arith `&0 < &2 * x <=> &0 < x`]; REWRITE_TAC[GSYM DIST_NZ]; CONJ_TAC; BY(ASM_MESON_TAC[ COPLANAR_3;SET_RULE `{a,b,c,c} = {a,b,c}`]); REPEAT WEAKER_STRIP_TAC; MATCH_MP_TAC square_add_neg_lemma; ASM_REWRITE_TAC[]; BY(FIRST_X_ASSUM_ST `abs` MP_TAC THEN REAL_ARITH_TAC); REPEAT WEAKER_STRIP_TAC; INTRO_TAC continuous_nbd_pos [`\t. e'' - abs(&2 * dist(v2,v3)*t + t*t)`;`&0`]; ASM_SIMP_TAC[arith `d < &0 ==> &0 < --d`;arith `abs(t' - &0) = abs t'`;arith `x + &0 = x`]; ANTS_TAC; CONJ2_TAC; BY(FIRST_X_ASSUM_ST `&0 < e''` MP_TAC THEN REAL_ARITH_TAC); BY(REPEAT (REPEAT CONJ_TAC THEN ( MATCH_MP_TAC REAL_CONTINUOUS_ADD ORELSE MATCH_MP_TAC REAL_CONTINUOUS_NEG ORELSE MATCH_MP_TAC REAL_CONTINUOUS_ABS ORELSE MATCH_MP_TAC REAL_CONTINUOUS_MUL ORELSE MATCH_MP_TAC REAL_CONTINUOUS_SUB ORELSE MATCH_MP_TAC REAL_CONTINUOUS_POW THEN ASM_REWRITE_TAC[REAL_CONTINUOUS_AT_ID;REAL_CONTINUOUS_CONST;CONTINUOUS_CONST]))); BY(MESON_TAC[arith `&0 < e'' - a <=> a < e''`]); REPEAT WEAKER_STRIP_TAC; INTRO_TAC epsilon_quad [`e`;`e'`;`e2`;`e''`] THEN ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; TYPIFY `e''''` EXISTS_TAC; ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; INTRO_TAC Merge_ineq.DIHV_DIH_X [`v0`;`v1`;`v2'`;`v3`]; ASM_REWRITE_TAC[LET_THM]; ANTS_TAC; ASM_TAC THEN REWRITE_TAC[DIST_SYM] THEN REPEAT WEAKER_STRIP_TAC; ASM_REWRITE_TAC[]; (REPEAT (FIRST_X_ASSUM_ST `collinear` MP_TAC) THEN REWRITE_TAC[Collect_geom2.NOT_COL_EQ_UPS_X_POS;DIST_SYM]); BY(MESON_TAC[]); DISCH_THEN SUBST1_TAC; ASM_REWRITE_TAC[arith `(x+y) pow 2 = x pow 2 + (&2 * x * y + y* y)`;DIST_SYM]; FIRST_X_ASSUM_ST `dist` (C INTRO_TAC [`t`]) THEN ANTS_TAC THEN ASM_REWRITE_TAC[]; BY(FIRST_X_ASSUM MATCH_MP_TAC THEN ASM_REWRITE_TAC[]); REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM_ST `dih_x` (C INTRO_TAC [`&2 * dist(v2,v3) *t + t*t`]); ASM_REWRITE_TAC[]; BY(MESON_TAC[]) ]);; (* }}} *) *)
let dihV_obtuse_mono_b = 
prove_by_refinement( `!(v0:real^3) v1 v2 v3. ~coplanar {v0,v1,v2,v3} ==> (?e. (!v2'. &0 < e /\ (!t. abs t < e /\ t <= &0 /\ dist (v0,v2') = dist(v0,v2) /\ dist (v1,v2') = dist(v1,v2) /\ dist(v2',v3)=dist(v2,v3) + t ==> dihV v0 v1 v2' v3 <= dihV v0 v1 v2 v3)))`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; INTRO_TAC Merge_ineq.DIHV_DIH_X [`v0`;`v2`;`v3`;`v1`]; INTRO_TAC Merge_ineq.DIHV_DIH_X [`v0`;`v3`;`v2`;`v1`]; INTRO_TAC Merge_ineq.DIHV_DIH_X [`v0`;`v1`;`v2`;`v3`]; REWRITE_TAC[LET_THM;GSYM Collect_geom2.NOT_COL_EQ_UPS_X_POS]; TYPIFY `~collinear {v0, v3, v2} /\ ~collinear {v0, v3, v1} /\ ~collinear {v0, v2, v3} /\ ~collinear {v0, v2, v1} /\ ~collinear {v0, v1, v2} /\ ~collinear {v0, v1, v3}` (C SUBGOAL_THEN ASSUME_TAC); BY(ASM_MESON_TAC[Planarity.notcoplanar_imp_notcollinear_fan;SET_RULE `{a,b,c} = {a,c,b}`]); ASM_REWRITE_TAC[]; REPEAT WEAKER_STRIP_TAC; ASM_TAC THEN REWRITE_TAC[DIST_SYM] THEN REPEAT WEAKER_STRIP_TAC; TYPIFY `&0 < dist(v0,v1) pow 2 /\ &0 < dist (v0,v3) pow 2 /\ &0 < dist (v0,v2) pow 2 /\ &0 < dist(v2,v3) /\ &0 < delta_x (dist (v0,v2) pow 2) (dist (v0,v3) pow 2) (dist (v0,v1) pow 2) (dist (v1,v3) pow 2) (dist (v1,v2) pow 2) (dist (v2,v3) pow 2)` (C SUBGOAL_THEN ASSUME_TAC); REWRITE_TAC[GSYM Trigonometry2.NOT_ZERO_EQ_POW2_LT]; REWRITE_TAC[GSYM DIST_NZ]; REWRITE_TAC[DIST_EQ_0]; REWRITE_TAC[CONJ_ASSOC]; CONJ_TAC; BY(ASM_MESON_TAC[ COPLANAR_3;SET_RULE `{a,a,b,c} = {a,b,c}`;SET_RULE `{a,b,a,c} = {a,b,c}`;SET_RULE `{a,b,c,a}={a,b,c}`;SET_RULE `{a,b,c,c} = {a,b,c}`]); REWRITE_TAC[GSYM Sphere.delta_y;arith `x pow 2 = x*x`]; FIRST_X_ASSUM_ST `coplanar` MP_TAC THEN REWRITE_TAC[Oxlzlez.coplanar_delta_y]; REWRITE_TAC[DIST_SYM;Sphere.delta_y]; BY(MESON_TAC[Merge_ineq.delta_x_sym]); INTRO_TAC continuous_nbd_pos [`\t. ups_x (dist(v0,v3) pow 2) (dist(v0,v2) pow 2) ( (dist(v2,v3)+t) pow 2)`;`&0`]; ASM_SIMP_TAC[arith `d < &0 ==> &0 < --d`;arith `abs(t' - &0) = abs t'`;arith `x + &0 = x`]; ANTS_TAC; CONJ_TAC; REWRITE_TAC[Sphere.delta_x6;Sphere.ups_x;Sphere.delta_x]; BY(REPEAT (REPEAT CONJ_TAC THEN ( MATCH_MP_TAC REAL_CONTINUOUS_ADD ORELSE MATCH_MP_TAC REAL_CONTINUOUS_NEG ORELSE MATCH_MP_TAC REAL_CONTINUOUS_MUL ORELSE MATCH_MP_TAC REAL_CONTINUOUS_SUB ORELSE MATCH_MP_TAC REAL_CONTINUOUS_POW THEN ASM_REWRITE_TAC[REAL_CONTINUOUS_AT_ID;REAL_CONTINUOUS_CONST;CONTINUOUS_CONST]))); REPEAT (FIRST_X_ASSUM_ST `collinear` MP_TAC) THEN REWRITE_TAC[Collect_geom2.NOT_COL_EQ_UPS_X_POS;DIST_SYM]; BY(DISCH_THEN (unlist REWRITE_TAC)); REPEAT WEAKER_STRIP_TAC; INTRO_TAC continuous_nbd_pos [`\t. delta_x (dist (v0,v2) pow 2) (dist (v0,v3) pow 2) (dist (v0,v1) pow 2) (dist (v1,v3) pow 2) (dist (v1,v2) pow 2) ((dist (v2,v3)+t) pow 2)`;`&0`]; ASM_SIMP_TAC[arith `d < &0 ==> &0 < --d`;arith `abs(t' - &0) = abs t'`;arith `x + &0 = x`]; ANTS_TAC; REWRITE_TAC[Sphere.delta_x6;Sphere.ups_x;Sphere.delta_x]; BY(REPEAT (REPEAT CONJ_TAC THEN ( MATCH_MP_TAC REAL_CONTINUOUS_ADD ORELSE MATCH_MP_TAC REAL_CONTINUOUS_NEG ORELSE MATCH_MP_TAC REAL_CONTINUOUS_MUL ORELSE MATCH_MP_TAC REAL_CONTINUOUS_SUB ORELSE MATCH_MP_TAC REAL_CONTINUOUS_POW THEN ASM_REWRITE_TAC[REAL_CONTINUOUS_AT_ID;REAL_CONTINUOUS_CONST;CONTINUOUS_CONST]))); REPEAT WEAKER_STRIP_TAC; INTRO_TAC dih_obtuse_mono_b [`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`]; ANTS_TAC; ASM_REWRITE_TAC[]; CONJ_TAC; BY(REPEAT (FIRST_X_ASSUM_ST `delta_x` MP_TAC) THEN REWRITE_TAC[DIST_SYM] THEN MESON_TAC[Merge_ineq.delta_x_sym]); BY(REPEAT (FIRST_X_ASSUM_ST `collinear` MP_TAC) THEN REWRITE_TAC[Collect_geom2.NOT_COL_EQ_UPS_X_POS;DIST_SYM] THEN MESON_TAC[]); REPEAT WEAKER_STRIP_TAC; TYPIFY `?e2. &0 < e2 /\ (!t. abs t < e2 /\ t <= &0 ==> &2 * dist(v2,v3) * t + t * t <= &0 /\ abs(&2 * dist(v2,v3)*t + t*t ) < e'')` (C SUBGOAL_THEN MP_TAC); TYPIFY `(?e2. &0 < e2 /\ (!t. abs t < e2 /\ t <= &0 ==> &2 * dist(v2,v3) * t + t * t <= &0 )) /\ (?e2. &0 < e2 /\ (!t. abs t < e2 /\ t <= &0 ==> abs(&2 * dist(v2,v3)*t + t*t ) < e''))` ENOUGH_TO_SHOW_TAC; REPEAT WEAKER_STRIP_TAC; INTRO_TAC epsilon_pair [`e2`;`e2'`] THEN ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; TYPIFY `e'''` EXISTS_TAC; ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; BY(CONJ_TAC THEN FIRST_X_ASSUM MATCH_MP_TAC THEN ASM_REWRITE_TAC[] THEN FIRST_X_ASSUM MATCH_MP_TAC THEN ASM_REWRITE_TAC[]); CONJ_TAC; TYPIFY `&2 * dist(v2,v3)` EXISTS_TAC; REWRITE_TAC[arith `&0 < &2 * x <=> &0 < x`]; REWRITE_TAC[GSYM DIST_NZ]; CONJ_TAC; BY(ASM_MESON_TAC[ COPLANAR_3;SET_RULE `{a,b,c,c} = {a,b,c}`]); REPEAT WEAKER_STRIP_TAC; MATCH_MP_TAC square_add_neg_lemma; ASM_REWRITE_TAC[]; BY(FIRST_X_ASSUM_ST `abs` MP_TAC THEN REAL_ARITH_TAC); REPEAT WEAKER_STRIP_TAC; INTRO_TAC continuous_nbd_pos [`\t. e'' - abs(&2 * dist(v2,v3)*t + t*t)`;`&0`]; ASM_SIMP_TAC[arith `d < &0 ==> &0 < --d`;arith `abs(t' - &0) = abs t'`;arith `x + &0 = x`]; ANTS_TAC; CONJ2_TAC; BY(FIRST_X_ASSUM_ST `&0 < e''` MP_TAC THEN REAL_ARITH_TAC); BY(REPEAT (REPEAT CONJ_TAC THEN ( MATCH_MP_TAC REAL_CONTINUOUS_ADD ORELSE MATCH_MP_TAC REAL_CONTINUOUS_NEG ORELSE MATCH_MP_TAC REAL_CONTINUOUS_ABS ORELSE MATCH_MP_TAC REAL_CONTINUOUS_MUL ORELSE MATCH_MP_TAC REAL_CONTINUOUS_SUB ORELSE MATCH_MP_TAC REAL_CONTINUOUS_POW THEN ASM_REWRITE_TAC[REAL_CONTINUOUS_AT_ID;REAL_CONTINUOUS_CONST;CONTINUOUS_CONST]))); BY(MESON_TAC[arith `&0 < e'' - a <=> a < e''`]); REPEAT WEAKER_STRIP_TAC; INTRO_TAC epsilon_quad [`e`;`e'`;`e2`;`e''`] THEN ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; TYPIFY `e''''` EXISTS_TAC; ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; INTRO_TAC Merge_ineq.DIHV_DIH_X [`v0`;`v1`;`v2'`;`v3`]; ASM_REWRITE_TAC[LET_THM]; ANTS_TAC; ASM_TAC THEN REWRITE_TAC[DIST_SYM] THEN REPEAT WEAKER_STRIP_TAC; ASM_REWRITE_TAC[]; (REPEAT (FIRST_X_ASSUM_ST `collinear` MP_TAC) THEN REWRITE_TAC[Collect_geom2.NOT_COL_EQ_UPS_X_POS;DIST_SYM]); BY(MESON_TAC[]); DISCH_THEN SUBST1_TAC; ASM_REWRITE_TAC[arith `(x+y) pow 2 = x pow 2 + (&2 * x * y + y* y)`;DIST_SYM]; FIRST_X_ASSUM_ST `dist` (C INTRO_TAC [`t`]) THEN ANTS_TAC THEN ASM_REWRITE_TAC[]; BY(FIRST_X_ASSUM MATCH_MP_TAC THEN ASM_REWRITE_TAC[]); REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM_ST `dih_x` (C INTRO_TAC [`&2 * dist(v2,v3) *t + t*t`]); BY(ASM_REWRITE_TAC[]) ]);;
(* }}} *)
let dihV_obtuse_mono = 
prove_by_refinement( `!(v0:real^3) v1 v2 v3. ~coplanar {v0, v1, v2, v3} ==> (?e. &0 < e /\ (pi / &2 < dihV v0 v2 v3 v1 ==> (!v2' t. abs t < e /\ t <= &0 /\ dist (v0,v2') = dist (v0,v2) /\ dist (v1,v2') = dist (v1,v2) /\ dist (v2',v3) = dist (v2,v3) + t ==> dihV v0 v3 v2' v1 <= dihV v0 v3 v2 v1)) /\ (!v2' t. (abs t < e /\ t <= &0 /\ dist (v0,v2') = dist (v0,v2) /\ dist (v1,v2') = dist (v1,v2) /\ dist (v2',v3) = dist (v2,v3) + t ==> dihV v0 v1 v2' v3 <= dihV v0 v1 v2 v3) ))`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; INTRO_TAC (REWRITE_RULE[MESON[] `(a ==> (?e. P e)) <=> (?e. a ==> P e)`] dihV_obtuse_mono_a) [`v0`;`v1`;`v2`;`v3`]; ASM_REWRITE_TAC[]; REPEAT WEAKER_STRIP_TAC; INTRO_TAC dihV_obtuse_mono_b [`v0`;`v1`;`v2`;`v3`]; ASM_REWRITE_TAC[]; REPEAT WEAKER_STRIP_TAC; TYPED_ABBREV_TAC `b <=> pi / &2 < dihV v0 v2 v3 v1`; TYPED_ABBREV_TAC `e1 = if b then e else &1`; INTRO_TAC epsilon_pair [`e1`;`e'`]; ASM_REWRITE_TAC[]; ANTS_TAC; EXPAND_TAC "e1";
COND_CASES_TAC; BY(ASM_MESON_TAC[]); BY(REAL_ARITH_TAC); REPEAT WEAKER_STRIP_TAC; TYPIFY `e''` EXISTS_TAC; BY(ASM_MESON_TAC[]) ]);; (* }}} *)
let real_continuous_abs = 
prove_by_refinement( `!x. abs real_continuous atreal x`,
(* {{{ proof *) [ TYPIFY `abs = (\x. abs ((\ (u:real). u) x))` (C SUBGOAL_THEN SUBST1_TAC); BY(REWRITE_TAC[FUN_EQ_THM;I_THM]); GEN_TAC; MATCH_MP_TAC REAL_CONTINUOUS_ABS; BY(REWRITE_TAC[REAL_CONTINUOUS_AT_ID]) ]);;
(* }}} *)
let deformation_restrict = 
prove_by_refinement( `!e f (V:real^A->bool) e'. deformation f V (-- e,e) /\ &0 < e' /\ (!t. abs t < e' ==> abs t < e) ==> deformation f V (-- e',e')`,
(* {{{ proof *) [ REWRITE_TAC[Localization.deformation;IN_REAL_INTERVAL;arith `-- e < t /\ t < e <=> abs t < e`;arith `abs(&0) = &0`]; BY(MESON_TAC[]) ]);;
(* }}} *)
let psort_mod = 
prove_by_refinement( `!k a b. ~(k=0) ==> psort k (a MOD k,b MOD k) = psort k (a,b)`,
(* {{{ proof *) [ REWRITE_TAC[Appendix.psort]; REPEAT WEAKER_STRIP_TAC; BY(ASM_SIMP_TAC[MOD_MOD_REFL]) ]);;
(* }}} *)
let MMs_minimize_tau_fun = 
prove_by_refinement( `!s k v w. is_scs_v39 s /\ scs_basic_v39 s /\ (scs_k_v39 s = k) /\ (3 < k) /\ BBprime_v39 s v /\ BBs_v39 s w ==> sum {i | i < k} (\i. rho_fun (norm (v i)) * azim (vec 0) (v i) (v (i + 1)) (v (i + k - 1))) <= sum {i | i < k} (\i. rho_fun (norm (w i)) * azim (vec 0) (w i) (w (i + 1)) (w (i + k - 1)))`,
(* {{{ proof *) [ REWRITE_TAC[Appendix.taustar_v39;Appendix.BBprime_v39;LET_THM]; REPEAT WEAKER_STRIP_TAC; REPEAT (FIRST_X_ASSUM_ST `COND` MP_TAC) THEN ASM_SIMP_TAC[arith `3 < k ==> ~(k <= 3)`] THEN REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM (C INTRO_TAC [`w`]); ASM_REWRITE_TAC[]; REPEAT (FIRST_X_ASSUM_ST `tau_fun` MP_TAC) THEN REPEAT (GMATCH_SIMP_TAC (REWRITE_RULE[LET_THM] Terminal.tau_fun_azim)); TYPIFY `k` EXISTS_TAC; CONJ_TAC; ASM_SIMP_TAC[arith `3 < k ==> 3 <= k`]; CONJ_TAC; BY(FIRST_X_ASSUM_ST `BBs_v39` MP_TAC THEN ASM_REWRITE_TAC[Appendix.BBs_v39;LET_THM] THEN MESON_TAC[]); MATCH_MP_TAC BBs_inj; BY(ASM_MESON_TAC[]); TYPIFY `k` EXISTS_TAC; CONJ_TAC; ASM_SIMP_TAC[arith `3 < k ==> 3 <= k`]; CONJ_TAC; BY(REPLICATE_TAC 2 (FIRST_X_ASSUM_ST `BBs_v39` MP_TAC) THEN ASM_REWRITE_TAC[Appendix.BBs_v39;LET_THM] THEN MESON_TAC[]); MATCH_MP_TAC BBs_inj; BY(ASM_MESON_TAC[]); DISCH_THEN kill; TYPIFY `dsv_v39 s v = dsv_v39 s w` ENOUGH_TO_SHOW_TAC; TYPED_ABBREV_TAC `sv = sum {i | i < k} (\i. rho_fun (norm (v i)) * azim (vec 0) (v i) (v (i + 1)) (v (i + k - 1)))`; TYPED_ABBREV_TAC `sw = sum {i | i < k} (\i. rho_fun (norm (w i)) * azim (vec 0) (w i) (w (i + 1)) (w (i + k - 1)))`; BY(REAL_ARITH_TAC); REPEAT (GMATCH_SIMP_TAC Appendix.dsv_J_empty); REWRITE_TAC[FUN_EQ_THM]; BY(ASM_MESON_TAC[Appendix.scs_basic]) ]);;
(* }}} *)
let solve_mod_k = 
prove_by_refinement( `!k a b x. ~(k = 0) /\ b= (x + a) MOD k ==> (x MOD k = (b + k - (a MOD k)) MOD k)`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; INTRO_TAC MOD_SHIFT[`k`;`b`;`(x+(a:num))`;`k - a MOD k`]; ANTS_TAC; ASM_REWRITE_TAC[]; BY(ASM_MESON_TAC[MOD_MOD_REFL]); DISCH_THEN SUBST1_TAC; TYPIFY `((x+a) + k - a MOD k = x + (k + (a - a MOD k)))` (C SUBGOAL_THEN SUBST1_TAC); BY(ASM_TAC THEN ARITH_TAC); TYPIFY `x + k + a - a MOD k = (a DIV k + 1) * k + x` (C SUBGOAL_THEN SUBST1_TAC); INTRO_TAC DIVISION [`a`;`k`]; BY(ASM_TAC THEN ARITH_TAC); BY(REWRITE_TAC[MOD_MULT_ADD]) ]);;
(* }}} *)
let tau3_taum_nonplanar = 
prove_by_refinement( `!(v0:real^3) v1 v2. ~coplanar {vec 0,v0,v1,v2} ==> tau3 v0 v1 v2 = taum (norm v0) (norm v1) (norm v2) (dist(v1,v2)) (dist(v0,v2)) (dist(v0,v1))`,
(* {{{ proof *) [ REWRITE_TAC[Appendix.tau3;Nonlinear_lemma.taum_123;Sphere.rhazim2;Sphere.rhazim3;Sphere.node2_y;Sphere.node3_y]; REWRITE_TAC[Sphere.rhazim;Nonlinear_lemma.sol0_const1]; REPEAT WEAKER_STRIP_TAC; TYPIFY `dihV (vec 0) v0 v1 v2 = dih_y (norm v0) (norm v1) (norm v2) (dist (v1,v2)) (dist (v0,v2)) (dist (v0,v1)) /\ dihV (vec 0) v1 v2 v0 = dih_y (norm v1) (norm v2) (norm v0) (dist (v0,v2)) (dist (v0,v1)) (dist (v1,v2)) /\ dihV (vec 0) v2 v0 v1 = dih_y (norm v2) (norm v0) (norm v1) (dist (v0,v1)) (dist (v1,v2)) (dist (v0,v2))` ENOUGH_TO_SHOW_TAC; DISCH_THEN (unlist REWRITE_TAC); BY(REAL_ARITH_TAC); REPEAT (GMATCH_SIMP_TAC (REWRITE_RULE[LET_DEF;LET_END_DEF] Merge_ineq.DIHV_EQ_DIH_Y)); REWRITE_TAC[DIST_0]; REWRITE_TAC[DIST_SYM]; ASM_REWRITE_TAC[]; FIRST_X_ASSUM_ST `coplanar` (MP_TAC o MATCH_MP Planarity.notcoplanar_imp_notcollinear_fan); BY(MESON_TAC[SET_RULE `{a,b,c} = {a,c,b}`]) ]);;
(* }}} *)
let tau3_azim = 
prove_by_refinement( `!(v0:real^3) v1 v2. ~coplanar {vec 0,v0,v1,v2} /\ azim (vec 0) v0 v1 v2 <= pi ==> tau3 v0 v1 v2 = rho (norm (v0)) * azim (vec 0) v0 v1 v2 + rho (norm (v1)) * azim (vec 0) v1 v2 v0 + rho (norm (v2)) * azim (vec 0) v2 v0 v1 - (pi + sol0) `,
(* {{{ proof *) [ REWRITE_TAC[Appendix.tau3]; REPEAT WEAKER_STRIP_TAC; MATCH_MP_TAC (arith `a = a' /\ b = b' /\ c = c' ==> r1 *a + r2*b + r3*c -x = r1*a' + r2*b' + r3*c' - x`); REPEAT (GMATCH_SIMP_TAC (GSYM Polar_fan.AZIM_DIHV_SAME_STRONG)); ASM_REWRITE_TAC[]; FIRST_X_ASSUM_ST `coplanar` (MP_TAC o MATCH_MP Planarity.notcoplanar_imp_notcollinear_fan); BY(ASM_MESON_TAC[Xivphks.FSQKWKK;SET_RULE `{a,b,c} = {a,c,b}`]) ]);;
(* }}} *) (* let general_482_deformation = prove_by_refinement( `main_nonlinear_terminal_v11 ==> (!s FF k p0 p1 p2 v. {v p0,v p2} = {v (p1+1),v (p1 + (k-1))} /\ FF = IMAGE (\i. (v i,v (SUC i))) (:num) /\ is_scs_v39 s /\ k = scs_k_v39 s /\ 3 < k /\ MMs_v39 s v /\ scs_basic_v39 s /\ scs_generic v /\ &3 <= dist(v p0,v p2) /\ (!i j. scs_diag k i j /\ ~(psort k (i, j) = psort k (p0,p2)) ==> scs_a_v39 s i j < dist(v i,v j)) /\ (!i j. scs_diag k i j ==> &4 * h0 < scs_b_v39 s i j) /\ interior_angle1 (vec 0) FF (v p1) < pi /\ (pi/ &2 < interior_angle1 (vec 0) FF (v p1) \/ interior_angle1 (vec 0) FF (v p2) < pi) /\ scs_a_v39 s p1 p2 = &2 /\ scs_b_v39 s p1 p2 = &2 * h0 /\ &2 <= dist(v p0,v p1) /\ dist(v p0, v p1) <= cstab ==> dist(v p1,v p2) = &2)`, (* {{{ proof *) [ COMMENT "preliminaries"; REPEAT WEAKER_STRIP_TAC; TYPIFY `~(k<=3)` (C SUBGOAL_THEN ASSUME_TAC); MATCH_MP_TAC (arith `3 < k ==> ~(k <= 3)`); BY(ASM_REWRITE_TAC[]); RULE_ASSUM_TAC (ONCE_REWRITE_RULE[EQ_SYM_EQ]); FIRST_X_ASSUM_ST `&2 = x` (ASSUME_TAC o (ONCE_REWRITE_RULE[EQ_SYM_EQ])); FIRST_X_ASSUM_ST `&2 *h0 = x` (ASSUME_TAC o (ONCE_REWRITE_RULE[EQ_SYM_EQ])); TYPIFY `unadorned_v39 s` (C SUBGOAL_THEN ASSUME_TAC); BY(ASM_MESON_TAC[Appendix.scs_basic]); TYPIFY `BBprime2_v39 s v` (C SUBGOAL_THEN ASSUME_TAC); BY(ASM_MESON_TAC[Appendix.scs_basic;Ayqjtmd.unadorned_MMs]); TYPIFY `BBprime_v39 s v` (C SUBGOAL_THEN ASSUME_TAC); BY(ASM_MESON_TAC[Appendix.BBprime2_v39]); TYPIFY `BBs_v39 s v` (C SUBGOAL_THEN ASSUME_TAC); BY(ASM_MESON_TAC[Appendix.BBprime_v39]); INTRO_TAC Appendix.BBs_v39 [`s`;`v`]; ASM_REWRITE_TAC[LET_DEF;LET_END_DEF;Terminal.IMAGE_SUBSET_IN;IN_UNIV]; REPEAT WEAKER_STRIP_TAC; TYPED_ABBREV_TAC `V = IMAGE v (:num)`; TYPED_ABBREV_TAC `E = IMAGE (\i. {v i, v (SUC i)}) (:num)`; TYPIFY `local_fan (V,E,FF)` (C SUBGOAL_THEN ASSUME_TAC); MATCH_MP_TAC Local_lemmas.CVX_LO_IMP_LO; BY(ASM_REWRITE_TAC[]); TYPIFY `!i. v i IN V` (C SUBGOAL_THEN ASSUME_TAC); REPEAT WEAKER_STRIP_TAC; EXPAND_TAC "V"; REWRITE_TAC[IN_IMAGE;IN_UNIV]; BY(MESON_TAC[]); INTRO_TAC (GEN_ALL Local_lemmas.INTERIOR_ANGLE1_POS) [`E`;`V`;`FF`;`v p1`]; ASM_REWRITE_TAC[]; DISCH_TAC; INTRO_TAC (GEN_ALL Nkezbfc_local.CONVEX_LOFA_IMP_INANGLE_EQ_AZIM_IVS ) [`E`;`V`;`FF`]; ASM_REWRITE_TAC[]; DISCH_TAC; TYPIFY `!i m. ITER m (rho_node1 FF) (v i) = v (m + i)` (C SUBGOAL_THEN ASSUME_TAC); GEN_TAC; INTRO_TAC (GEN_ALL Qknvmlb.VV_SUC_EQ_RHO_NODE_PRIME) [`V`;`E`;`k`;`s`;`FF`;`v i`;`v`;`i`]; BY(ASM_REWRITE_TAC[]); TYPIFY `!i. v (i + (k:num)) = v i` (C SUBGOAL_THEN ASSUME_TAC); BY(ASM_MESON_TAC[Oxl_def.periodic]); TYPIFY `!i. ivs_rho_node1 FF (v i) = v ( i + (k-1))` (C SUBGOAL_THEN ASSUME_TAC); GEN_TAC; MATCH_MP_TAC VV_SUC_EQ_IVS_RHO_NODE_PRIME; GEXISTL_TAC [`V`;`E`;`s`]; BY(ASM_REWRITE_TAC[]); TYPIFY `generic V E` (C SUBGOAL_THEN ASSUME_TAC); BY(ASM_MESON_TAC[Appendix.scs_generic]); COMMENT "collinearity"; TYPIFY `~collinear {vec 0,v (p1 + (k-1)),v (p1 + 1)}` (C SUBGOAL_THEN ASSUME_TAC); MATCH_MP_TAC Zlzthic.PROPERTIES_GENERIC_LOCAL_FAN_ALT; GEXISTL_TAC [`V`;`E`;`FF`]; ASM_REWRITE_TAC[]; DISCH_TAC; INTRO_TAC Ocbicby.scs_lb_2 [`s`;`v`;`(p1+1)`;`(p1+(k-1))`]; ASM_REWRITE_TAC[DIST_REFL;arith `~(&2 <= &0)`]; GMATCH_SIMP_TAC Ocbicby.MOD_EQ_MOD_SHIFT; ASM_SIMP_TAC[arith `3 < k ==> ~(k=0)`]; REPEAT (GMATCH_SIMP_TAC MOD_LT); BY(FIRST_X_ASSUM_ST `3 < k` MP_TAC THEN ARITH_TAC); COMMENT "coplanarity"; TYPIFY `interior_angle1 (vec 0) FF (v p1) = azim (vec 0) (v p1) (v (p1+1)) (v (p1 + k -1))` (C SUBGOAL_THEN ASSUME_TAC); FIRST_X_ASSUM_ST `interior_angle1` (C INTRO_TAC [`v p1`]); ASM_REWRITE_TAC[]; FIRST_X_ASSUM_ST `ITER` (C INTRO_TAC [`p1`;`1`]); REWRITE_TAC[ITER_1]; BY(MESON_TAC[arith `1 + p1 = p1 + 1`]); TYPIFY `~coplanar {vec 0, v p1,v(p1+1),v(p1 + k- 1)}` (C SUBGOAL_THEN ASSUME_TAC); ASM_REWRITE_TAC[GSYM Local_lemmas1.AZIM_COND_FOR_COPLANAR]; FIRST_X_ASSUM (SUBST1_TAC o GSYM); BY(ASM_SIMP_TAC[DE_MORGAN_THM;arith `&0 <x ==> ~(x = &0)`; arith `(x < pi ==> ~(x = pi))`]); COMMENT "482"; INTRO_TAC (UNDISCH Ocbicby.LEMMA_4828966562) [`norm (v p0)`;`norm (v p2)`;`norm (v p1)`;`dist(v p1,v p2)`;`dist (v p0,v p1)`;`dist(v p0,v p2)`]; ANTS_TAC; ASM_REWRITE_TAC[GSYM Sphere.cstab]; TYPIFY_GOAL_THEN `&2 <= norm (v p0) /\ norm (v p0) <= &2 * h0 /\ &2 <= norm (v p2) /\ norm (v p2) <= &2 * h0 /\ &2 <= norm (v p1) /\ norm (v p1) <= &2 * h0 /\ &2 <= dist (v p1,v p2) /\ dist (v p1,v p2) <= &2 * h0 ` (unlist REWRITE_TAC); BY(ASM_MESON_TAC[ ( Fnjlbxs.in_ball_annulus)]); CONJ_TAC; TYPIFY `dist(v p1, v p2) = dist(v p2,v p1)` (C SUBGOAL_THEN SUBST1_TAC); BY(REWRITE_TAC[DIST_SYM]); REWRITE_TAC[GSYM Trigonometry1.DIST_L_ZERO]; REWRITE_TAC[GSYM Oxlzlez.coplanar_delta_y]; FIRST_X_ASSUM MP_TAC; MATCH_MP_TAC (TAUT `(a = b) ==> (a ==> b)`); AP_TERM_TAC; AP_TERM_TAC; AP_TERM_TAC; BY(FIRST_X_ASSUM_ST `{a,b} = y` MP_TAC THEN SET_TAC[]); COMMENT "ups"; REWRITE_TAC[GSYM Trigonometry1.DIST_L_ZERO;arith `x*x = x pow 2`]; REWRITE_TAC[GSYM Collect_geom2.NOT_COL_EQ_UPS_X_POS]; FIRST_X_ASSUM_ST `collinear` MP_TAC; MATCH_MP_TAC (TAUT `(a = b) ==> (a ==> b)`); REPEAT AP_TERM_TAC; BY(FIRST_X_ASSUM_ST `{a,b} = y` MP_TAC THEN SET_TAC[]); REPEAT WEAKER_STRIP_TAC; (PROOF_BY_CONTR_TAC); TYPIFY `v p1 dot (v (p1 + 1) cross v (p1 + k -1)) > &0` (C SUBGOAL_THEN ASSUME_TAC); TYPIFY `v p1 dot (v (p1 + 1) cross v (p1 + k -1)) = (v p1 cross (v (p1 + 1))) dot ( v (p1 + k -1))` (C SUBGOAL_THEN SUBST1_TAC); BY(VEC3_TAC); REWRITE_TAC[arith `a > &0 <=> &0 < a`;GSYM Zlzthic.azim_lt_pi_cross]; BY(ASM_MESON_TAC[]); COMMENT "fix abs"; TYPIFY `(?f e'. &0 < e' /\ deformation f V (--e',e') /\ (!w t. ~(w = v p1) ==> f w t = w) /\ (!t. abs t < e' ==> dist (v p0,f (v p1) t) = dist (v p0,v p1) /\ dist (v p2,f (v p1) t) = dist (v p2,v p1) -abs t /\ norm (f (v p1) t) = norm (v p1)))` (C SUBGOAL_THEN MP_TAC); FIRST_X_ASSUM_ST `{a,b} = {c,d}` MP_TAC; REWRITE_TAC[Collect_geom.PAIR_EQ_EXPAND] THEN DISCH_THEN DISJ_CASES_TAC; INTRO_TAC deform_simplex_edge_exists [`V`;`(\t. -- abs t)`;`(\ (t:real). &0)`;`v (p1 + k -1)`;`v p1`;`v (p1 +1)`;`&1`]; STRIP_TAC; FIRST_X_ASSUM MP_TAC THEN ANTS_TAC; REWRITE_TAC[arith `&0 < &1 /\ -- &0 = &0`;REAL_CONTINUOUS_CONST]; REPEAT (GMATCH_SIMP_TAC REAL_CONTINUOUS_ON_EQ_REAL_CONTINUOUS_AT); REWRITE_TAC[REAL_OPEN_REAL_INTERVAL;REAL_CONTINUOUS_CONST;arith `--abs (&0) = &0`]; nCONJ_TAC 2; REPEAT WEAKER_STRIP_TAC; MATCH_MP_TAC REAL_CONTINUOUS_NEG; BY(REWRITE_TAC[real_continuous_abs]); FIRST_X_ASSUM (unlist REWRITE_TAC); FIRST_X_ASSUM_ST `cross` (unlist REWRITE_TAC); BY(ONCE_REWRITE_TAC[SET_RULE `{a,b,c,d} = {a,c,d,b}`] THEN FIRST_X_ASSUM_ST `coplanar` (unlist REWRITE_TAC)); ASM_REWRITE_TAC[arith `x + &0 = x`;arith `x + -- t = x - t`;DIST_SYM]; REPEAT WEAKER_STRIP_TAC; GEXISTL_TAC [`f`;`e'`]; ASM_REWRITE_TAC[]; BY(FIRST_X_ASSUM MP_TAC THEN MESON_TAC[]); INTRO_TAC deform_simplex_edge_exists [`V`;`(\ (t:real). &0)`;`(\t. --abs t)`;`v (p1 +k - 1)`;`v p1`;`v (p1 +1)`;`&1`]; STRIP_TAC; FIRST_X_ASSUM MP_TAC THEN ANTS_TAC; REWRITE_TAC[arith `&0 < &1 /\ -- &0 = &0`;REAL_CONTINUOUS_CONST]; REPEAT (GMATCH_SIMP_TAC REAL_CONTINUOUS_ON_EQ_REAL_CONTINUOUS_AT); REWRITE_TAC[REAL_OPEN_REAL_INTERVAL;REAL_CONTINUOUS_CONST;arith `--abs(&0)= &0`]; FIRST_X_ASSUM_ST `cross` (unlist REWRITE_TAC); ONCE_REWRITE_TAC[SET_RULE `{a,b,c,d} = {a,c,d,b}`] THEN FIRST_X_ASSUM_ST `coplanar` (unlist REWRITE_TAC); REPEAT WEAKER_STRIP_TAC THEN MATCH_MP_TAC REAL_CONTINUOUS_NEG; BY(REWRITE_TAC[real_continuous_abs]); ASM_REWRITE_TAC[arith `x + &0 = x`;arith `x + -- t = x - t`;DIST_SYM]; REPEAT WEAKER_STRIP_TAC; GEXISTL_TAC [`f`;`e'`]; BY(ASM_REWRITE_TAC[]); (REPEAT WEAKER_STRIP_TAC); TYPIFY `~(k=0)` (C SUBGOAL_THEN ASSUME_TAC); BY(ASM_SIMP_TAC[arith `3 < k ==> ~(k=0)`]); TYPIFY `!i j.scs_a_v39 s (i MOD k) (j MOD k) = scs_a_v39 s i j /\ scs_b_v39 s (i MOD k) (j MOD k) = scs_b_v39 s i j ` (C SUBGOAL_THEN ASSUME_TAC); FIRST_X_ASSUM_ST `is_scs_v39` MP_TAC; ASM_REWRITE_TAC[Appendix.is_scs_v39]; BY(FIRST_X_ASSUM MP_TAC THEN MESON_TAC[periodic2_MOD]); TYPIFY `!i. i MOD k < k` (C SUBGOAL_THEN ASSUME_TAC); BY(REPLICATE_TAC 3 (FIRST_X_ASSUM MP_TAC) THEN MESON_TAC[DIVISION]); TYPIFY `!i. v (i MOD k) = v i` (C SUBGOAL_THEN ASSUME_TAC); GEN_TAC; MATCH_MP_TAC (GSYM Oxl_def.periodic_mod); BY(ASM_REWRITE_TAC[]); INTRO_TAC BBs_inj [`s`;`v`;`k`]; ASM_REWRITE_TAC[]; DISCH_TAC; TYPIFY `!j. j < k ==> (j MOD k = j)` (C SUBGOAL_THEN ASSUME_TAC); BY(REWRITE_TAC[MOD_LT]); COMMENT "restart here"; TYPIFY `~(v (p1+1) = v p1) /\ ~(v (p1 + k -1) = v p1)` (C SUBGOAL_THEN ASSUME_TAC); TYPIFY `v p1 = v (p1+0)` (C SUBGOAL_THEN SUBST1_TAC); BY(REWRITE_TAC[arith `p1+0 = p1`]); FIRST_ASSUM_ST `v(i MOD k) = v i` ((unlist ONCE_REWRITE_TAC) o GSYM); TYPIFY_GOAL_THEN `!i j. i < k /\ j < k /\ ~(i = j) ==> ~(v i = v (j:num))` (REPEAT o GMATCH_SIMP_TAC); BY(REPLICATE_TAC 2 (FIRST_X_ASSUM MP_TAC) THEN MESON_TAC[]); REPEAT (GMATCH_SIMP_TAC Ocbicby.MOD_EQ_MOD_SHIFT); ASM_REWRITE_TAC[]; FIRST_X_ASSUM (REPEAT o GMATCH_SIMP_TAC); BY(FIRST_X_ASSUM_ST `3 < k` MP_TAC THEN ARITH_TAC); TYPIFY `(!t. f (v (p1+1)) t = v(p1+1)) /\ (!t. f (v (p1+k-1)) t = v (p1+k-1))` (C SUBGOAL_THEN ASSUME_TAC); BY(CONJ_TAC THEN GEN_TAC THEN FIRST_X_ASSUM_ST `(f w t = w)` MATCH_MP_TAC THEN ASM_REWRITE_TAC[]); TYPIFY `?e1. &0 < e1 /\ (!t. abs t < e1 ==> &0 < azim (vec 0) (f (v p1) t) (v (p1+1)) (v (p1+k-1)) /\ azim (vec 0) (f(v p1) t) (v (p1+1)) (v (p1+k-1)) < pi)` (C SUBGOAL_THEN MP_TAC); INTRO_TAC WNWSHJT_ALT [`v(p1+k-1)`;`v (p1)`;`v (p1+1)`;`f`;`-- e'`;`e'`;`pi`]; ASM_REWRITE_TAC[]; ANTS_TAC; CONJ_TAC; MATCH_MP_TAC Zlzthic.deformation_subset; TYPIFY `V` EXISTS_TAC; ASM_REWRITE_TAC[]; EXPAND_TAC "V"; BY(REWRITE_TAC[SUBSET;IN_INSERT;NOT_IN_EMPTY;IN_IMAGE;IN_UNIV] THEN MESON_TAC[]); TYPIFY_GOAL_THEN `~collinear {vec 0, v p1, v (p1 + 1)} /\ ~collinear {vec 0, v p1, v (p1 + k - 1)}` (unlist REWRITE_TAC); BY(FIRST_X_ASSUM_ST `coplanar` MP_TAC THEN MESON_TAC[Planarity.notcoplanar_imp_notcollinear_fan]); BY(ASM_MESON_TAC[]); BY(MESON_TAC[]); REPEAT WEAKER_STRIP_TAC; TYPIFY `!t. abs t < e1 ==> ((&0 < azim (vec 0) (v(p1+1)) (v(p1+k-1)) (f (v p1) t) /\ azim (vec 0) (v(p1+1)) (v(p1+k-1)) (f (v p1) t) < pi) /\ (&0 < azim (vec 0) (v(p1+k-1)) (f (v p1) t) (v(p1+1)) /\ azim (vec 0) (v(p1+k-1)) (f (v p1) t) (v(p1+1)) < pi))` (C SUBGOAL_THEN ASSUME_TAC); REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM_ST `azim` (C INTRO_TAC [`t`]); ASM_REWRITE_TAC[GSYM sin_azim_pos]; INTRO_TAC Trigonometry.JBDNJJB [`f (v p1) t`;`v(p1 + 1)`;`v (p1+k-1)`]; INTRO_TAC Trigonometry.JBDNJJB [`v(p1 + 1)`;`v (p1+k-1)`;`f (v p1) t`]; INTRO_TAC Trigonometry.JBDNJJB [`v (p1+k-1)`;`f (v p1) t`;`v(p1 + 1)`]; TYPIFY_GOAL_THEN `((v (p1 + k - 1) cross f (v p1) t) dot v (p1 + 1)) = ((f (v p1) t cross v (p1 + 1)) dot v (p1 + k - 1)) /\ ((v (p1 + 1) cross v (p1 + k - 1)) dot f (v p1) t) = ((f (v p1) t cross v (p1 + 1)) dot v (p1 + k - 1))` (unlist REWRITE_TAC); BY(MESON_TAC[CROSS_TRIPLE]); TYPIFY `!a b. re_eqvl a b ==> (&0 < a <=> &0 < b)` ENOUGH_TO_SHOW_TAC; BY(MESON_TAC[]); REWRITE_TAC[Trigonometry2.re_eqvl]; REPEAT WEAKER_STRIP_TAC; ASM_REWRITE_TAC[]; GMATCH_SIMP_TAC REAL_LT_MUL_EQ; BY(ASM_REWRITE_TAC[]); TYPIFY `!w. w IN V ==> f w (&0) = w` (C SUBGOAL_THEN ASSUME_TAC); REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM_ST `deformation` MP_TAC THEN REWRITE_TAC[Localization.deformation]; BY(FIRST_X_ASSUM MP_TAC THEN MESON_TAC[]); TYPIFY `?e2. &0 < e2 /\ (!t. abs t < e2 ==> ~coplanar {vec 0, (f (v p1) t),v (p1+k-1),v(p1+1)})` (C SUBGOAL_THEN MP_TAC); INTRO_TAC Zlzthic.NONPLANAR_OPEN [`( \ (t:real). (vec 0):real^3)`;`f (v p1)`;`\ (t:real). v (p1+k-1)`;`\ (t:real). v (p1+1)`;`&0`]; ASM_REWRITE_TAC[CONTINUOUS_CONST]; ANTS_TAC; CONJ_TAC; FIRST_X_ASSUM GMATCH_SIMP_TAC; ONCE_REWRITE_TAC[SET_RULE `{a,b,c,d} = {a,b,d,c}`]; BY(ASM_REWRITE_TAC[]); FIRST_X_ASSUM_ST `deformation` MP_TAC THEN REWRITE_TAC[Localization.deformation]; BY(REPEAT WEAKER_STRIP_TAC THEN FIRST_X_ASSUM MATCH_MP_TAC THEN ASM_REWRITE_TAC[]); BY(REWRITE_TAC[arith `abs (&0 - t') = abs t'`] THEN MESON_TAC[]); REPEAT WEAKER_STRIP_TAC; COMMENT "insert"; INTRO_TAC dihV_obtuse_mono [`(vec 0):real^3`;`v p0`;`v p1`;`v p2`]; ANTS_TAC; ASM_REWRITE_TAC[]; TYPIFY `{vec 0,v p0, v p1,v p2} = {vec 0,v p1,v (p1+1),v(p1+k-1)}` (C SUBGOAL_THEN SUBST1_TAC); FIRST_X_ASSUM_ST `{a,b} ={c,d}` MP_TAC; BY(SET_TAC[]); BY(ASM_REWRITE_TAC[]); REPEAT WEAKER_STRIP_TAC; REPLICATE_TAC 2(FIRST_X_ASSUM MP_TAC THEN BURY_MP_TAC); COMMENT "end insert"; INTRO_TAC epsilon_quad [`e1`;`e2`;`e'`;`e`] THEN ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; TYPIFY `!t. abs t < e'''' ==> azim (vec 0) (f(v p1) t) (v (p1+1)) (v (p1+k-1)) = dihV (vec 0) (f (v p1) t) (v (p1 + 1)) (v (p1 + k - 1)) /\ azim (vec 0) (v (p1 + 1)) (v (p1 + k - 1)) (f (v p1) t) = dihV (vec 0) (v (p1 + 1)) (v (p1 + k - 1)) (f (v p1) t) /\ azim (vec 0) (v (p1 + k - 1)) (f (v p1) t) (v (p1 + 1)) = dihV (vec 0) (v (p1 + k - 1)) (f (v p1) t) (v (p1 + 1))` (C SUBGOAL_THEN ASSUME_TAC); GEN_TAC THEN ASM_REWRITE_TAC[] THEN DISCH_TAC; REPEAT (GMATCH_SIMP_TAC (GSYM AZIM_DIHV_SAME)); INTRO_TAC Planarity.notcoplanar_imp_notcollinear_fan [`(vec 0):real^3`;`f (v p1) t`;`v(p1+k-1)`;`v(p1+1)`]; ANTS_TAC; BY((FIRST_X_ASSUM MATCH_MP_TAC THEN FIRST_X_ASSUM MATCH_MP_TAC THEN ASM_REWRITE_TAC[])); REWRITE_TAC[SET_RULE `{a,b,c} = {a,c,b}`]; DISCH_THEN (unlist REWRITE_TAC); BY(REPLICATE_TAC 12 (FIRST_X_ASSUM MP_TAC) THEN MESON_TAC[]); COMMENT "introduce azim"; INTRO_TAC azim_assumption_reduction [`s`;`k`;`p1`;`f`;`v`;`e''''`]; ASM_REWRITE_TAC[]; DISCH_THEN MP_TAC THEN ANTS_TAC; CONJ_TAC; FIRST_X_ASSUM_ST `deformation` MP_TAC; REWRITE_TAC[Localization.deformation]; REWRITE_TAC[IN_REAL_INTERVAL;arith `--e < t /\ t < e <=> abs t < e`]; BY(REPLICATE_TAC 7 (FIRST_X_ASSUM MP_TAC) THEN MESON_TAC[arith `abs(&0) = &0`]); CONJ_TAC; BY(ASM_MESON_TAC[]); TYPIFY `(azim (vec 0) (v (p1 + k - 1)) (v p1) (v (p1 + k - 2)) < pi \/ ( (!t. abs t < e'''' ==> dihV (vec 0) (v (p1 + k - 1)) (f (v p1) t) (v (p1 + 1)) <= dihV (vec 0) (v (p1 + k - 1)) (v p1) (v (p1 + 1))))) /\ (azim (vec 0) (v (p1 + 1)) (v (p1 + 2)) (v p1) < pi \/ ( (!t. abs t < e'''' ==> dihV (vec 0) (v (p1 + 1)) (v (p1 + k - 1)) (f (v p1) t) <= dihV (vec 0) (v (p1 + 1)) (v (p1 + k - 1)) (v p1))))` ENOUGH_TO_SHOW_TAC; REPEAT WEAKER_STRIP_TAC; REWRITE_TAC[MESON [] `(a \/ (?e1. P e1)) <=> (?e1. (a \/ P e1))`;MESON[] `(a /\ (?e1. P e1)) <=> (?e1. a /\ P e1)`;MESON[] `((?e1. P e1) /\ b) <=> (?e1. P e1 /\ b)`]; GEXISTL_TAC [`e''''`;`e''''`]; FIRST_X_ASSUM_ST `w IN V ==> f w (&0) = (w:real^3)` (C INTRO_TAC [`v p1`]); ASM_REWRITE_TAC[]; BY(REPLICATE_TAC 12 (FIRST_X_ASSUM MP_TAC) THEN MESON_TAC[arith `abs(&0) = &0`]); COMMENT "obtuse case"; (TYPIFY `pi/ &2 < dihV (vec 0) (v p1) (v (p1+1)) (v (p1+k-1))` ASM_CASES_TAC); TYPIFY `dihV (vec 0) (v p1) (v(p1+1)) (v (p1+k-1)) = dihV (vec 0) (v p1) (v p2) (v p0)` (C SUBGOAL_THEN ASSUME_TAC); BY(FIRST_X_ASSUM_ST `{a,b}={c,d}` MP_TAC THEN REWRITE_TAC[Collect_geom.PAIR_EQ_EXPAND] THEN MESON_TAC[DIHV_SYM]); TYPIFY `!t. abs t < e'''' ==> dihV (vec 0) (v p0) (f (v p1) t) (v p2) <= dihV (vec 0) (v p0) (v p1) (v p2) /\ dihV (vec 0) (v p2) (f (v p1) t) (v p0) <= dihV (vec 0) (v p2) (v p1) (v p0)` ENOUGH_TO_SHOW_TAC; BY(FIRST_X_ASSUM_ST `{a,b}={c,d}` MP_TAC THEN REWRITE_TAC[Collect_geom.PAIR_EQ_EXPAND] THEN DISCH_THEN DISJ_CASES_TAC THEN FIRST_X_ASSUM (unlist REWRITE_TAC) THEN MESON_TAC[DIHV_SYM]); REPEAT WEAKER_STRIP_TAC; REPEAT (FIRST_X_ASSUM_ST `dihV a b c d <= dihV a' b' c' d'` MP_TAC THEN ASM_REWRITE_TAC[] THEN DISCH_THEN (C INTRO_TAC [`f (v p1) t`;`-- abs t`])); (FIRST_X_ASSUM_ST `dihV a b c d <= dihV a' b' c' d'` MP_TAC THEN ANTS_TAC THENL [REPLICATE_TAC 3 (FIRST_X_ASSUM MP_TAC) THEN MESON_TAC[];ALL_TAC] THEN DISCH_THEN (C INTRO_TAC [`f (v p1) t`;`-- abs t`])); REWRITE_TAC[DIST_SYM;arith `abs(-- abs t) = abs t`;arith `--abs t <= &0`]; REPEAT (DISCH_THEN GMATCH_SIMP_TAC); REWRITE_TAC[arith `a + -- b = a - b`]; FIRST_X_ASSUM_ST `norm` (C INTRO_TAC [` t`]); ANTS_TAC; BY(FIRST_X_ASSUM MATCH_MP_TAC THEN FIRST_X_ASSUM (unlist REWRITE_TAC)); TYPIFY_GOAL_THEN `abs t < e` (unlist REWRITE_TAC); BY(FIRST_X_ASSUM MATCH_MP_TAC THEN FIRST_X_ASSUM (unlist REWRITE_TAC)); BY(REWRITE_TAC[DIST_SYM;DIST_0] THEN MESON_TAC[]); COMMENT "nonobtuse case"; FIRST_X_ASSUM_ST `pi / &2 < interior_angle1 (vec 0) FF (v p1)` MP_TAC; DISCH_TAC; TYPIFY `interior_angle1 (vec 0) FF (v p2) < pi` (C SUBGOAL_THEN ASSUME_TAC); TYPIFY `dihV (vec 0) (v p1) (v (p1+1)) (v (p1+k-1)) = interior_angle1 (vec 0) FF (v p1)` ENOUGH_TO_SHOW_TAC; BY(REPLICATE_TAC 2 (FIRST_X_ASSUM MP_TAC) THEN MESON_TAC[]); FIRST_X_ASSUM_ST `azim` (C INTRO_TAC [`&0`]); BY(ASM_SIMP_TAC[arith `abs(&0) = &0`]); FIRST_X_ASSUM_ST `{a,b}={c,d}` (MP_TAC o GSYM) THEN REWRITE_TAC[Collect_geom.PAIR_EQ_EXPAND] THEN DISCH_THEN DISJ_CASES_TAC; FIRST_X_ASSUM_ST `interior_angle1` MP_TAC THEN (FIRST_ASSUM (unlist REWRITE_TAC)); INTRO_TAC Ocbicby.INTERIOR_ANGLE1_AZIM [`s`;`v`;`p1 + k - 1`]; ASM_REWRITE_TAC[LET_THM;IN]; DISCH_THEN (SUBST1_TAC o GSYM); TYPIFY_GOAL_THEN `v (SUC (p1+k-1)) = v p1 /\ v ((p1+k-1)+(k-1)) = v (p1 + k - 2)` (unlist REWRITE_TAC); FIRST_ASSUM_ST `v(i MOD k) = v i` ((unlist ONCE_REWRITE_TAC) o GSYM); FIRST_X_ASSUM_ST `3 < k` MP_TAC; BY(SIMP_TAC[arith `3 < k ==> SUC (p1+k-1) = 1*k + p1 /\ ((p1+k-1)+(k-1) = (1*k + (p1+k-2)))`;MOD_MULT_ADD]); DISCH_THEN (unlist REWRITE_TAC); DISJ2_TAC; REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM_ST ` /\ ` ((unlist REWRITE_TAC) o GSYM); ONCE_REWRITE_TAC[DIHV_SYM]; FIRST_X_ASSUM MATCH_MP_TAC; TYPIFY `-- abs t` EXISTS_TAC; REWRITE_TAC[arith `abs(-- abs t) = abs (t)`;arith `-- abs t <= &0`;arith `x + -- t = x - t`;DIST_0;DIST_SYM]; CONJ_TAC; BY(FIRST_X_ASSUM MATCH_MP_TAC THEN FIRST_X_ASSUM (unlist REWRITE_TAC)); FIRST_X_ASSUM_ST `norm` (C INTRO_TAC [`t`]); ANTS_TAC; BY(FIRST_X_ASSUM MATCH_MP_TAC THEN FIRST_X_ASSUM (unlist REWRITE_TAC)); BY(REWRITE_TAC[DIST_SYM] THEN MESON_TAC[]); COMMENT "second nonobtuse case"; FIRST_X_ASSUM_ST `interior_angle1` MP_TAC THEN (FIRST_ASSUM (unlist REWRITE_TAC)); INTRO_TAC Ocbicby.INTERIOR_ANGLE1_AZIM [`s`;`v`;`p1 +1`]; ASM_REWRITE_TAC[LET_THM;IN]; DISCH_THEN (SUBST1_TAC o GSYM); REWRITE_TAC[arith `SUC (p1+1) = p1+2`]; TYPIFY_GOAL_THEN `v ((p1+1)+k-1) = v p1` (unlist REWRITE_TAC); FIRST_ASSUM_ST `v(i MOD k) = v i` ((unlist ONCE_REWRITE_TAC) o GSYM); FIRST_X_ASSUM_ST `3 < k` MP_TAC; BY(SIMP_TAC[arith `3 < k ==> (p1+1)+k-1 = 1*k + p1`;MOD_MULT_ADD]); DISCH_THEN (unlist REWRITE_TAC); DISJ2_TAC; REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM_ST ` /\ ` ((unlist REWRITE_TAC) o GSYM); FIRST_X_ASSUM MATCH_MP_TAC; TYPIFY `-- abs t` EXISTS_TAC; REWRITE_TAC[arith `abs(-- abs t) = abs (t)`;arith `-- abs t <= &0`;arith `x + -- t = x - t`;DIST_0;DIST_SYM]; CONJ_TAC; BY(FIRST_X_ASSUM MATCH_MP_TAC THEN FIRST_X_ASSUM (unlist REWRITE_TAC)); FIRST_X_ASSUM_ST `norm` (C INTRO_TAC [`t`]); ANTS_TAC; BY(FIRST_X_ASSUM MATCH_MP_TAC THEN FIRST_X_ASSUM (unlist REWRITE_TAC)); BY(REWRITE_TAC[DIST_SYM] THEN MESON_TAC[]); REPEAT WEAKER_STRIP_TAC; COMMENT "finally back to root goal"; TYPIFY `!i j. (v i = v j) ==> (i MOD k = j MOD k)` (C SUBGOAL_THEN ASSUME_TAC); FIRST_ASSUM_ST `v (i MOD k) = v i` ((unlist ONCE_REWRITE_TAC) o GSYM); FIRST_X_ASSUM_ST `!i (j:num). i < k /\ j < k /\ v i = v j ==> i = j` MP_TAC; FIRST_X_ASSUM_ST `!i. i MOD k < k` MP_TAC; BY(MESON_TAC[]); TYPIFY `psort k (p0,p2) = psort k (p1+1,p1+k-1)` (C SUBGOAL_THEN ASSUME_TAC); FIRST_X_ASSUM_ST `~(k=0)` MP_TAC; DISCH_TAC; INTRO_TAC psort_mod [`k`]; FIRST_X_ASSUM (unlist REWRITE_TAC); DISCH_THEN ((unlist ONCE_REWRITE_TAC) o GSYM); FIRST_X_ASSUM_ST `{a,b}={c,d}` (MP_TAC) THEN REWRITE_TAC[Collect_geom.PAIR_EQ_EXPAND] THEN DISCH_THEN DISJ_CASES_TAC; BY(REPLICATE_TAC 2 (FIRST_X_ASSUM MP_TAC) THEN MESON_TAC[]); BY(REPLICATE_TAC 2 (FIRST_X_ASSUM MP_TAC) THEN MESON_TAC[Terminal.psort_sym]); INTRO_TAC deformation_BBs_ALT [`s`;`k`;`f`;`v`;`e''''`]; ANTS_TAC; ASM_REWRITE_TAC[]; CONJ_TAC; MATCH_MP_TAC deformation_restrict; TYPIFY `e'` EXISTS_TAC; BY(ASM_REWRITE_TAC[]); CONJ_TAC; REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM_ST `norm` (C INTRO_TAC [`t`]); ANTS_TAC; BY(FIRST_X_ASSUM MATCH_MP_TAC THEN (FIRST_X_ASSUM (unlist REWRITE_TAC))); TYPIFY `v i = v p1` ASM_CASES_TAC; BY(FIRST_X_ASSUM (unlist REWRITE_TAC) THEN MESON_TAC[]); FIRST_X_ASSUM_ST `!w t. ~(w = v p1) ==> f w t = w` (C INTRO_TAC [`v i`;`t`]); BY(FIRST_X_ASSUM MP_TAC THEN MESON_TAC[]); CONJ_TAC; MATCH_MP_TAC a_assumption_reduction; GEXISTL_TAC [`k`;`p1`;`e'`]; ASM_REWRITE_TAC[]; CONJ_TAC; REPEAT (FIRST_X_ASSUM_ST `psort` MP_TAC); BY(MESON_TAC[]); TYPIFY `(?e1. &0 < e1 /\ (scs_a_v39 s p1 p2 = dist (v p1,v p2) ==> (!t. abs t < e1 ==> scs_a_v39 s p1 (p2) <= dist (f (v p1) t,v (p2))))) /\ (?e1. &0 < e1 /\ (scs_a_v39 s p1 (p0) = dist (v p1,v (p0)) ==> (!t. abs t < e1 ==> scs_a_v39 s p1 (p0) <= dist (f (v p1) t,v (p0)))))` (C SUBGOAL_THEN ASSUME_TAC); CONJ2_TAC; ASM_REWRITE_TAC[]; TYPIFY `e'` EXISTS_TAC; ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM_ST `norm` (C INTRO_TAC [`t`]); BY(FIRST_X_ASSUM (unlist REWRITE_TAC) THEN (REPLICATE_TAC 2 (FIRST_X_ASSUM MP_TAC)) THEN REWRITE_TAC[DIST_SYM] THEN REAL_ARITH_TAC); TYPIFY `&1` EXISTS_TAC; BY(ASM_REWRITE_TAC[arith `&0 < &1`]); FIRST_X_ASSUM_ST `{a,b}={c,d}` (MP_TAC) THEN REWRITE_TAC[Collect_geom.PAIR_EQ_EXPAND] THEN DISCH_THEN DISJ_CASES_TAC; TYPIFY `(p1 + 1) MOD k = p0 MOD k /\ (p1+k-1) MOD k = p2 MOD k` (C SUBGOAL_THEN ASSUME_TAC); BY(REPLICATE_TAC 5 (FIRST_X_ASSUM MP_TAC) THEN MESON_TAC[]); TYPIFY_GOAL_THEN `scs_a_v39 s p1 (p1+1) = scs_a_v39 s p1 p0 /\ scs_a_v39 s p1 (p1+k-1) = scs_a_v39 s p1 p2` (unlist REWRITE_TAC); FIRST_X_ASSUM_ST `is_scs_v39` MP_TAC; BY(FIRST_X_ASSUM MP_TAC THEN FIRST_X_ASSUM_ST `scs_k_v39 s = k` MP_TAC THEN MESON_TAC[Nuxcoea.CHANGE_A_SCS_MODR]); FIRST_X_ASSUM kill THEN FIRST_X_ASSUM (unlist REWRITE_TAC); BY(FIRST_X_ASSUM MP_TAC THEN MESON_TAC[]); TYPIFY `(p1 + 1) MOD k = p2 MOD k /\ (p1+k-1) MOD k = p0 MOD k` (C SUBGOAL_THEN ASSUME_TAC); BY(REPLICATE_TAC 5 (FIRST_X_ASSUM MP_TAC) THEN MESON_TAC[]); TYPIFY_GOAL_THEN `scs_a_v39 s p1 (p1+1) = scs_a_v39 s p1 p2 /\ scs_a_v39 s p1 (p1+k-1) = scs_a_v39 s p1 p0` (unlist REWRITE_TAC); FIRST_X_ASSUM_ST `is_scs_v39` MP_TAC; BY(FIRST_X_ASSUM MP_TAC THEN FIRST_X_ASSUM_ST `scs_k_v39 s = k` MP_TAC THEN MESON_TAC[Nuxcoea.CHANGE_A_SCS_MODR]); FIRST_X_ASSUM kill THEN FIRST_X_ASSUM (unlist REWRITE_TAC); BY(FIRST_X_ASSUM MP_TAC THEN MESON_TAC[]); COMMENT "b assumption"; MATCH_MP_TAC b_assumption_reduction; GEXISTL_TAC [`k`;`p1`;`e'`]; ASM_REWRITE_TAC[]; TYPIFY `(?e2. &0 < e2 /\ (dist (v p1,v (p2)) = scs_b_v39 s p1 (p2) ==> (!t. abs t < e2 ==> dist (f (v p1) t,v (p2)) <= scs_b_v39 s p1 (p2)))) /\ (?e2. &0 < e2 /\ (dist (v p1,v (p0)) = scs_b_v39 s p1 (p0) ==> (!t. abs t < e2 ==> dist (f (v p1) t,v (p0)) <= scs_b_v39 s p1 (p0))))` (C SUBGOAL_THEN ASSUME_TAC); CONJ2_TAC; ASM_REWRITE_TAC[]; TYPIFY `e'` EXISTS_TAC; ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM_ST `norm` (C INTRO_TAC [`t`]); BY(FIRST_X_ASSUM (unlist REWRITE_TAC) THEN (REPLICATE_TAC 2 (FIRST_X_ASSUM MP_TAC)) THEN REWRITE_TAC[DIST_SYM] THEN REAL_ARITH_TAC); TYPIFY `e'` EXISTS_TAC; ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM_ST `norm` (C INTRO_TAC [`t`]); BY(FIRST_X_ASSUM (unlist REWRITE_TAC) THEN (REPLICATE_TAC 2 (FIRST_X_ASSUM MP_TAC)) THEN REWRITE_TAC[DIST_SYM] THEN REAL_ARITH_TAC); FIRST_X_ASSUM_ST `{a,b}={c,d}` (MP_TAC) THEN REWRITE_TAC[Collect_geom.PAIR_EQ_EXPAND] THEN DISCH_THEN DISJ_CASES_TAC; TYPIFY `(p1 + 1) MOD k = p0 MOD k /\ (p1+k-1) MOD k = p2 MOD k` (C SUBGOAL_THEN ASSUME_TAC); BY(REPLICATE_TAC 5 (FIRST_X_ASSUM MP_TAC) THEN MESON_TAC[]); TYPIFY_GOAL_THEN `scs_b_v39 s p1 (p1+1) = scs_b_v39 s p1 p0 /\ scs_b_v39 s p1 (p1+k-1) = scs_b_v39 s p1 p2` (unlist REWRITE_TAC); FIRST_X_ASSUM_ST `is_scs_v39` MP_TAC; BY(FIRST_X_ASSUM MP_TAC THEN FIRST_X_ASSUM_ST `scs_k_v39 s = k` MP_TAC THEN MESON_TAC[Nuxcoea.CHANGE_B_SCS_MODR]); FIRST_X_ASSUM kill THEN FIRST_X_ASSUM (unlist REWRITE_TAC); BY(FIRST_X_ASSUM MP_TAC THEN MESON_TAC[]); TYPIFY `(p1 + 1) MOD k = p2 MOD k /\ (p1+k-1) MOD k = p0 MOD k` (C SUBGOAL_THEN ASSUME_TAC); BY(REPLICATE_TAC 5 (FIRST_X_ASSUM MP_TAC) THEN MESON_TAC[]); TYPIFY_GOAL_THEN `scs_b_v39 s p1 (p1+1) = scs_b_v39 s p1 p2 /\ scs_b_v39 s p1 (p1+k-1) = scs_b_v39 s p1 p0` (unlist REWRITE_TAC); FIRST_X_ASSUM_ST `is_scs_v39` MP_TAC; BY(FIRST_X_ASSUM MP_TAC THEN FIRST_X_ASSUM_ST `scs_k_v39 s = k` MP_TAC THEN MESON_TAC[Nuxcoea.CHANGE_B_SCS_MODR]); FIRST_X_ASSUM kill THEN FIRST_X_ASSUM (unlist REWRITE_TAC); BY(FIRST_X_ASSUM MP_TAC THEN MESON_TAC[]); REPEAT WEAKER_STRIP_TAC; COMMENT "back to root, next tau"; TYPIFY `!t. abs t < e'' ==> sum {i | i < k} (\i. rho_fun (norm (v i)) * azim (vec 0) (v i) (v (i + 1)) (v (i + k - 1))) <= sum {i | i < k} (\i. rho_fun (norm (f (v i) t)) * azim (vec 0) (f (v i) t) (f(v(i+1)) t) (f (v (i + k - 1)) t))` (C SUBGOAL_THEN ASSUME_TAC); REPEAT WEAKER_STRIP_TAC; MATCH_MP_TAC MMs_minimize_tau_fun; TYPIFY `s` EXISTS_TAC; ASM_REWRITE_TAC[]; FIRST_X_ASSUM MATCH_MP_TAC; BY(FIRST_X_ASSUM (unlist REWRITE_TAC)); TYPIFY `!t. abs t < e'' ==> sum ({i | i < k} DIFF {p1 MOD k,(p1+1) MOD k, (p1+k-1) MOD k}) (\i. rho_fun (norm (f (v i) t)) * azim (vec 0) (f (v i) t) (f (v (i + 1)) t) (f (v (i + k - 1)) t)) = sum {i | i < k} (\i. rho_fun (norm (f (v i) t)) * azim (vec 0) (f (v i) t) (f (v (i + 1)) t) (f (v (i + k - 1)) t)) - sum {p1 MOD k,(p1+1) MOD k, (p1+k-1) MOD k} (\i. rho_fun (norm (f (v i) t)) * azim (vec 0) (f (v i) t) (f (v (i + 1)) t) (f (v (i + k - 1)) t))` (C SUBGOAL_THEN ASSUME_TAC); REPEAT WEAKER_STRIP_TAC; MATCH_MP_TAC SUM_DIFF; REWRITE_TAC[FINITE_NUMSEG_LT]; ASM_REWRITE_TAC[SUBSET;IN_INSERT;NOT_IN_EMPTY;IN_ELIM_THM]; BY(REPEAT WEAKER_STRIP_TAC THEN REPEAT (FIRST_X_ASSUM DISJ_CASES_TAC) THEN ASM_REWRITE_TAC[]); TYPIFY `(\i. rho_fun (norm (f (v i) (&0))) * azim (vec 0) (f (v i) (&0)) (f (v (i + 1)) (&0)) (f (v (i + k - 1)) (&0))) = (\i. rho_fun (norm ((v i) )) * azim (vec 0) ( (v i) ) ( (v (i + 1)) ) ( (v (i + k - 1)) ))` (C SUBGOAL_THEN ASSUME_TAC); ASM_REWRITE_TAC[FUN_EQ_THM]; GEN_TAC; BY(ASM_SIMP_TAC[]); TYPIFY `?e3. &0 < e3 /\ (!t. abs t < e3 ==> dist(v p1,v p2) + t IN real_interval(a,b))` (C SUBGOAL_THEN MP_TAC); INTRO_TAC Zlzthic.real_interval_contains_0_ball [`a-dist(v p1,v p2)`;`b - dist(v p1,v p2)`;`&1`]; REWRITE_TAC[arith `&0 < &1`;arith `a - d < &0 <=> a < d`;arith `&0 < b - d <=> d < b`]; ANTS_TAC; FIRST_X_ASSUM_ST `dist s IN real_interval (a,b)` MP_TAC; BY(REWRITE_TAC[IN_REAL_INTERVAL]); REPEAT WEAKER_STRIP_TAC; TYPIFY `e'''` EXISTS_TAC; BY(ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC THEN (FIRST_X_ASSUM (C INTRO_TAC [`t`])) THEN REPLICATE_TAC 6 (FIRST_X_ASSUM MP_TAC) THEN REWRITE_TAC[IN_REAL_INTERVAL] THEN REAL_ARITH_TAC); REPEAT WEAKER_STRIP_TAC; COMMENT "combine e'' e1' e'''' e3 "; INTRO_TAC epsilon_quad [`e''`;`e1'`;`e''''`;`e3`] THEN ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; TYPIFY ` ((p1+1) MOD k + k-1) MOD k = p1 MOD k /\ ((p1+k-1) MOD k + 1) MOD k = p1 MOD k` (C SUBGOAL_THEN ASSUME_TAC); GMATCH_SIMP_TAC MOD_SHIFT; TYPIFY `p1+1` EXISTS_TAC; FIRST_X_ASSUM_ST `~(k=0)` MP_TAC THEN SIMP_TAC[arith `~(k=0) ==> (p1+1) + k -1 = 1 *k + p1`;MOD_MULT_ADD;MOD_MOD_REFL]; DISCH_TAC; GMATCH_SIMP_TAC MOD_SHIFT; TYPIFY `p1+k-1` EXISTS_TAC; BY(FIRST_X_ASSUM_ST `~(k=0)` MP_TAC THEN SIMP_TAC[arith `~(k=0) ==> (p1+k-1) +1 = 1 *k + p1`;MOD_MULT_ADD;MOD_MOD_REFL]); TYPIFY `!t. abs t < e'''''' ==> sum {p1 MOD k, (p1 + 1) MOD k, (p1 + k - 1) MOD k} (\i. rho_fun (norm (v i)) * azim (vec 0) (v i) (v (i + 1)) (v (i + k - 1))) <= sum {p1 MOD k, (p1 + 1) MOD k, (p1 + k - 1) MOD k} (\i. rho_fun (norm (f (v i) t)) * azim (vec 0) (f (v i) t) (f (v (i + 1)) t) (f (v (i + k - 1)) t))` (C SUBGOAL_THEN ASSUME_TAC); REPEAT WEAKER_STRIP_TAC; FIRST_ASSUM_ST `sum` (C INTRO_TAC [`&0`]); FIRST_X_ASSUM_ST `sum` (C INTRO_TAC [`t`]); ASM_REWRITE_TAC[arith `abs(&0) = &0`]; ANTS_TAC; BY(REPEAT (FIRST_X_ASSUM MATCH_MP_TAC) THEN FIRST_X_ASSUM (unlist REWRITE_TAC)); ONCE_REWRITE_TAC[arith `sdiff = sfull - s3 <=> s3 = sfull - sdiff`]; DISCH_THEN SUBST1_TAC; DISCH_THEN SUBST1_TAC; FIRST_X_ASSUM_ST `sum` (C INTRO_TAC [`t`]); ANTS_TAC; BY(REPEAT (FIRST_X_ASSUM MATCH_MP_TAC) THEN FIRST_X_ASSUM (unlist REWRITE_TAC)); ASM_REWRITE_TAC[]; TYPIFY `sum ({i | i < k} DIFF {p1 MOD k, (p1 + 1) MOD k, (p1 + k - 1) MOD k}) (\i. rho_fun (norm (v i)) * azim (vec 0) (v i) (v (i + 1)) (v (i + k - 1))) = sum ({i | i < k} DIFF {p1 MOD k, (p1 + 1) MOD k, (p1 + k - 1) MOD k}) (\i. rho_fun (norm (f (v i) t)) * azim (vec 0) (f (v i) t) (f (v (i + 1)) t) (f (v (i + k - 1)) t))` ENOUGH_TO_SHOW_TAC; DISCH_THEN SUBST1_TAC; BY(REWRITE_TAC[arith `(a <= b) ==> a - u <= b - u`]); MATCH_MP_TAC SUM_EQ; REWRITE_TAC[IN_DIFF;IN_INSERT;NOT_IN_EMPTY;IN_ELIM_THM]; REPEAT WEAKER_STRIP_TAC; TYPIFY ` ~(p1 MOD k = x MOD k) /\ ~(p1 MOD k = (x + 1) MOD k) /\ ~(p1 MOD k = (x + k - 1) MOD k)` (C SUBGOAL_THEN ASSUME_TAC); TYPIFY `x MOD k = (x + 0) MOD k` (C SUBGOAL_THEN SUBST1_TAC); BY(REWRITE_TAC[arith `x + 0 = x`]); PROOF_BY_CONTR_TAC; INTRO_TAC solve_mod_k [`k`] THEN ASM_REWRITE_TAC[]; ONCE_REWRITE_TAC[TAUT `!a b. (a ==> b) <=> (~b ==> ~a)`]; DISCH_TAC; FIRST_X_ASSUM_ST `x+k-1` MP_TAC THEN REWRITE_TAC[] THEN REPEAT CONJ_TAC THEN FIRST_X_ASSUM MATCH_MP_TAC; GMATCH_SIMP_TAC MOD_0; ASM_REWRITE_TAC[MOD_MOD_REFL;MOD_MULT_ADD;arith `a + k - 0 = 1*k + a`]; GMATCH_SIMP_TAC MOD_MOD_REFL; BY(ASM_REWRITE_TAC[] THEN REPLICATE_TAC 2(FIRST_X_ASSUM MP_TAC) THEN MESON_TAC[MOD_LT]); TYPIFY `x MOD k = x` (C SUBGOAL_THEN SUBST1_TAC); BY(FIRST_X_ASSUM_ST `x < (k:num)` MP_TAC THEN MESON_TAC[MOD_LT]); DISCH_TAC; FIRST_X_ASSUM_ST `~` MP_TAC; ASM_REWRITE_TAC[]; DISJ2_TAC; DISJ2_TAC; TYPIFY `1 MOD k = 1` (C SUBGOAL_THEN SUBST1_TAC); BY(FIRST_X_ASSUM_ST `3 < k` MP_TAC THEN MESON_TAC[MOD_LT;arith `3 < k ==> 1 < k`]); MATCH_MP_TAC MOD_SHIFT; BY(FIRST_X_ASSUM_ST `~(k = 0)` MP_TAC THEN MESON_TAC[MOD_MOD_REFL]); TYPIFY `x MOD k = x` (C SUBGOAL_THEN SUBST1_TAC); BY(FIRST_X_ASSUM_ST `x < (k:num)` MP_TAC THEN MESON_TAC[MOD_LT]); DISCH_TAC; FIRST_X_ASSUM_ST `~` MP_TAC; ASM_REWRITE_TAC[]; DISJ2_TAC; DISJ1_TAC; TYPIFY `(k-1) MOD k = (k-1)` (C SUBGOAL_THEN SUBST1_TAC); BY(FIRST_X_ASSUM_ST `~(k=0)` MP_TAC THEN MESON_TAC[MOD_LT;arith `~(k=0) ==> k - 1 < k`]); TYPIFY `k - (k-1) = 1` (C SUBGOAL_THEN SUBST1_TAC); BY(FIRST_X_ASSUM_ST `~(k=0)` MP_TAC THEN ARITH_TAC); MATCH_MP_TAC MOD_SHIFT; BY(FIRST_X_ASSUM_ST `~(k = 0)` MP_TAC THEN MESON_TAC[MOD_MOD_REFL]); POP_ASSUM (fun t -> FIRST_X_ASSUM (MP_TAC o (C MATCH_MP t))); (DISCH_THEN (unlist REWRITE_TAC)); AP_THM_TAC; AP_TERM_TAC; AP_TERM_TAC; FIRST_X_ASSUM_ST `norm` (C INTRO_TAC [`t`]); ANTS_TAC; BY(REPEAT (FIRST_X_ASSUM MATCH_MP_TAC) THEN (FIRST_X_ASSUM_ST `abs` (unlist REWRITE_TAC))); TYPIFY `v x = v p1` ASM_CASES_TAC; BY(FIRST_X_ASSUM (unlist REWRITE_TAC) THEN MESON_TAC[]); POP_ASSUM (fun t -> FIRST_X_ASSUM (MP_TAC o (C MATCH_MP t))); BY(DISCH_THEN (unlist REWRITE_TAC)); COMMENT "back to root: relate sum to taum"; TYPIFY `!i. f (v i) (&0) = (v i)` (C SUBGOAL_THEN ASSUME_TAC); BY(REPEAT (FIRST_X_ASSUM_ST `IN` MP_TAC) THEN REPEAT (FIRST_X_ASSUM_ST `f w (&0) = w` MP_TAC) THEN MESON_TAC[]); TYPIFY `?t'. abs t' < e'''''' /\ ~(t' = &0)` (C SUBGOAL_THEN MP_TAC); BY(TYPIFY `e'''''' / &2` EXISTS_TAC THEN FIRST_X_ASSUM_ST `&0 < e''''''` MP_TAC THEN REAL_ARITH_TAC); REPEAT WEAKER_STRIP_TAC; REPLICATE_TAC 5 (FIRST_X_ASSUM (C INTRO_TAC [`t'`]) THEN ANTS_TAC THEN REPEAT (FIRST_X_ASSUM MATCH_MP_TAC) THEN ASM_REWRITE_TAC[]); REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM MP_TAC; REWRITE_TAC[arith `~(x <= y) <=> y < x`]; TYPIFY_GOAL_THEN `!f. sum {p1 MOD k, (p1 + 1) MOD k, (p1 + k - 1) MOD k} f = f (p1 MOD k) + f ((p1 + 1) MOD k) + f ((p1+k-1) MOD k)` (unlist REWRITE_TAC); GEN_TAC; MATCH_MP_TAC Geomdetail.SUM_DIS3; TYPIFY `p1 MOD k = (p1 + 0) MOD k` (C SUBGOAL_THEN SUBST1_TAC); BY(REWRITE_TAC[arith `p1 + 0 = p1`]); REWRITE_TAC[DE_MORGAN_THM]; REPEAT (GMATCH_SIMP_TAC Ocbicby.MOD_EQ_MOD_SHIFT); REPEAT (GMATCH_SIMP_TAC MOD_LT); BY(FIRST_X_ASSUM_ST `3 < k` MP_TAC THEN ARITH_TAC); REWRITE_TAC[Appendix.rho_rho_fun]; FIRST_X_ASSUM_ST `DIFF` kill; REPEAT (FIRST_X_ASSUM_ST `sum` kill); FIRST_X_ASSUM_ST `MOD` (MP_TAC o GSYM) THEN REPEAT WEAKER_STRIP_TAC; POP_ASSUM (fun t -> FIRST_X_ASSUM (MP_TAC o (C MATCH_MP t))); DISCH_TAC; FIRST_ASSUM (C INTRO_TAC [`&0`]); FIRST_X_ASSUM (C INTRO_TAC [`t'`]); FIRST_X_ASSUM MP_TAC THEN ASM_REWRITE_TAC[] THEN DISCH_TAC; DISCH_THEN (unlist REWRITE_TAC); DISCH_THEN (unlist REWRITE_TAC); POP_ASSUM (fun t -> FIRST_X_ASSUM (MP_TAC o (C MATCH_MP t))); DISCH_TAC; FIRST_ASSUM (C INTRO_TAC [`&0`]); FIRST_X_ASSUM (C INTRO_TAC [`t'`]); ASM_REWRITE_TAC[]; DISCH_THEN (unlist REWRITE_TAC); DISCH_THEN (unlist REWRITE_TAC); TYPIFY `p1 MOD k = (p1 MOD k) MOD k` (C SUBGOAL_THEN ASSUME_TAC); BY(FIRST_X_ASSUM_ST `~(k=0)` MP_TAC THEN MESON_TAC[MOD_MOD_REFL]); POP_ASSUM (fun t -> FIRST_X_ASSUM (MP_TAC o (C MATCH_MP t))); ASM_REWRITE_TAC[]; DISCH_TAC; FIRST_ASSUM (C INTRO_TAC [`&0`]); FIRST_X_ASSUM (C INTRO_TAC [`t'`]); ASM_REWRITE_TAC[]; DISCH_THEN (unlist REWRITE_TAC); DISCH_THEN (unlist REWRITE_TAC); FIRST_X_ASSUM_ST `azim` (C INTRO_TAC [`t'`]); ASM_REWRITE_TAC[]; DISCH_THEN (unlist REWRITE_TAC); MATCH_MP_TAC (arith `r1 * a1 + r2 * (a2) + r3 * (b2) - (pi + sol0) < r1' * a1' + r2 * (a2') + r3 * (b3') - (pi + sol0) ==> r1 * a1 + r2 * (a + a2) + r3 * (b2 + b) < r1' * a1' + r2 * (a + a2') + r3 * (b3' + b)`); REPEAT (GMATCH_SIMP_TAC (GSYM tau3_azim)); REPEAT (GMATCH_SIMP_TAC tau3_taum_nonplanar); FIRST_X_ASSUM_ST `taum` MP_TAC; DISCH_TAC; REPEAT (FIRST_X_ASSUM_ST `coplanar` MP_TAC) THEN REPEAT DISCH_TAC; REPEAT (FIRST_X_ASSUM_ST `azim a b c d <= pi` MP_TAC) THEN REPEAT DISCH_TAC; REPEAT (FIRST_X_ASSUM_ST `azim a b c d < pi` MP_TAC) THEN REPEAT DISCH_TAC; TYPIFY `abs t' < e1 /\ abs t' < e2` (C SUBGOAL_THEN ASSUME_TAC); BY(CONJ_TAC THEN REPEAT (FIRST_X_ASSUM MATCH_MP_TAC) THEN ASM_REWRITE_TAC[]); REPEAT (FIRST_X_ASSUM_ST `&0 < e2` MP_TAC) THEN REPEAT DISCH_TAC; TYPIFY_GOAL_THEN `azim (vec 0) (v p1) (v (p1 + 1)) (v (p1 + k - 1)) <= pi /\ azim (vec 0) (f (v p1) t') (v (p1 + 1)) (v (p1 + k - 1)) <= pi` (unlist REWRITE_TAC); BY(REPLICATE_TAC 25 (FIRST_X_ASSUM MP_TAC) THEN MESON_TAC[arith `abs(&0) = &0`;arith `x < y ==> x <= y`]); REPEAT (FIRST_X_ASSUM_ST `azim` kill); ASM_REWRITE_TAC[]; TYPIFY_GOAL_THEN `~coplanar {vec 0, f (v p1) t', v p0, v p2} ` (unlist REWRITE_TAC); TYPIFY `{vec 0,f(v p1) t',v p0,v p2} = {vec 0,f (v p1) t',v (p1+k-1),v(p1+1)}` (C SUBGOAL_THEN SUBST1_TAC); BY(FIRST_X_ASSUM_ST `{a,b}={c,d}` MP_TAC THEN SET_TAC[]); FIRST_X_ASSUM MATCH_MP_TAC; BY(REPEAT (FIRST_X_ASSUM MATCH_MP_TAC) THEN ASM_REWRITE_TAC[]); TYPIFY_GOAL_THEN `!w. taum (norm w) (norm (v (p1 + 1))) (norm (v (p1 + k - 1))) (dist (v (p1 + 1),v (p1 + k - 1))) (dist (w,v (p1 + k - 1))) (dist (w,v (p1 + 1))) = taum (norm (v p0)) (norm (v p2)) (norm (w)) (dist(w,v p2)) (dist (v p0,w)) (dist (v p0,v p2))` (unlist REWRITE_TAC); GEN_TAC; FIRST_X_ASSUM_ST `{a,b}={c,d}` (MP_TAC) THEN REWRITE_TAC[Collect_geom.PAIR_EQ_EXPAND] THEN DISCH_THEN DISJ_CASES_TAC; ASM_REWRITE_TAC[DIST_SYM]; BY(MESON_TAC[Terminal.taum_sym]); ASM_REWRITE_TAC[DIST_SYM]; BY(MESON_TAC[Terminal.taum_sym]); FIRST_X_ASSUM_ST `norm a = norm b` (C INTRO_TAC [`t'`]); ANTS_TAC; BY(REPEAT (FIRST_X_ASSUM MATCH_MP_TAC) THEN ASM_REWRITE_TAC[]); REWRITE_TAC[DIST_SYM] THEN (DISCH_THEN (unlist REWRITE_TAC)); FIRST_X_ASSUM MATCH_MP_TAC; CONJ_TAC; REWRITE_TAC[arith `x - y = x + -- y`]; FIRST_X_ASSUM MATCH_MP_TAC; BY(ASM_REWRITE_TAC[arith `abs(-- abs t') = abs t'`]); ASM_REWRITE_TAC[]; BY(FIRST_X_ASSUM_ST `~(t' = &0)` MP_TAC THEN REAL_ARITH_TAC) ]);; (* }}} *) *)
let general_482_deformation = 
prove_by_refinement( `main_nonlinear_terminal_v11 ==> (!s FF k p0 p1 p2 v. {v p0,v p2} = {v (p1+1),v (p1 + (k-1))} /\ FF = IMAGE (\i. (v i,v (SUC i))) (:num) /\ is_scs_v39 s /\ k = scs_k_v39 s /\ 3 < k /\ MMs_v39 s v /\ scs_basic_v39 s /\ scs_generic v /\ &3 <= dist(v p0,v p2) /\ (!i j. scs_diag k i j /\ ~(psort k (i, j) = psort k (p0,p2)) ==> scs_a_v39 s i j < dist(v i,v j)) /\ (!i j. scs_diag k i j ==> &4 * h0 < scs_b_v39 s i j) /\ interior_angle1 (vec 0) FF (v p1) < pi /\ (pi/ &2 < interior_angle1 (vec 0) FF (v p1) \/ interior_angle1 (vec 0) FF (v p2) < pi) /\ scs_a_v39 s p1 p2 = &2 /\ scs_b_v39 s p1 p2 <= &2 * h0 /\ &2 <= dist(v p0,v p1) /\ dist(v p0, v p1) <= cstab ==> dist(v p1,v p2) = &2)`,
(* {{{ proof *) [ COMMENT "preliminaries";
REPEAT WEAKER_STRIP_TAC; TYPIFY `~(k<=3)` (C SUBGOAL_THEN ASSUME_TAC); MATCH_MP_TAC (arith `3 < k ==> ~(k <= 3)`); BY(ASM_REWRITE_TAC[]); RULE_ASSUM_TAC (ONCE_REWRITE_RULE[EQ_SYM_EQ]); FIRST_X_ASSUM_ST `&2 = x` (ASSUME_TAC o (ONCE_REWRITE_RULE[EQ_SYM_EQ])); (* FIRST_X_ASSUM_ST `&2 *h0 = x` (ASSUME_TAC o (ONCE_REWRITE_RULE[EQ_SYM_EQ])); *) TYPIFY `unadorned_v39 s` (C SUBGOAL_THEN ASSUME_TAC); BY(ASM_MESON_TAC[Appendix.scs_basic]); TYPIFY `BBprime2_v39 s v` (C SUBGOAL_THEN ASSUME_TAC); BY(ASM_MESON_TAC[Appendix.scs_basic;Ayqjtmd.unadorned_MMs]); TYPIFY `BBprime_v39 s v` (C SUBGOAL_THEN ASSUME_TAC); BY(ASM_MESON_TAC[Appendix.BBprime2_v39]); TYPIFY `BBs_v39 s v` (C SUBGOAL_THEN ASSUME_TAC); BY(ASM_MESON_TAC[Appendix.BBprime_v39]); INTRO_TAC Appendix.BBs_v39 [`s`;`v`]; ASM_REWRITE_TAC[LET_DEF;LET_END_DEF;Terminal.IMAGE_SUBSET_IN;IN_UNIV]; REPEAT WEAKER_STRIP_TAC; TYPED_ABBREV_TAC `V = IMAGE v (:num)`; TYPED_ABBREV_TAC `E = IMAGE (\i. {v i, v (SUC i)}) (:num)`; TYPIFY `local_fan (V,E,FF)` (C SUBGOAL_THEN ASSUME_TAC); MATCH_MP_TAC Local_lemmas.CVX_LO_IMP_LO; BY(ASM_REWRITE_TAC[]); TYPIFY `!i. v i IN V` (C SUBGOAL_THEN ASSUME_TAC); REPEAT WEAKER_STRIP_TAC; EXPAND_TAC "V"; REWRITE_TAC[IN_IMAGE;IN_UNIV]; BY(MESON_TAC[]); INTRO_TAC (GEN_ALL Local_lemmas.INTERIOR_ANGLE1_POS) [`E`;`V`;`FF`;`v p1`]; ASM_REWRITE_TAC[]; DISCH_TAC; INTRO_TAC (GEN_ALL Nkezbfc_local.CONVEX_LOFA_IMP_INANGLE_EQ_AZIM_IVS ) [`E`;`V`;`FF`]; ASM_REWRITE_TAC[]; DISCH_TAC; TYPIFY `!i m. ITER m (rho_node1 FF) (v i) = v (m + i)` (C SUBGOAL_THEN ASSUME_TAC); GEN_TAC; INTRO_TAC (GEN_ALL Qknvmlb.VV_SUC_EQ_RHO_NODE_PRIME) [`V`;`E`;`k`;`s`;`FF`;`v i`;`v`;`i`]; BY(ASM_REWRITE_TAC[]); TYPIFY `!i. v (i + (k:num)) = v i` (C SUBGOAL_THEN ASSUME_TAC); BY(ASM_MESON_TAC[Oxl_def.periodic]); TYPIFY `!i. ivs_rho_node1 FF (v i) = v ( i + (k-1))` (C SUBGOAL_THEN ASSUME_TAC); GEN_TAC; MATCH_MP_TAC VV_SUC_EQ_IVS_RHO_NODE_PRIME; GEXISTL_TAC [`V`;`E`;`s`]; BY(ASM_REWRITE_TAC[]); TYPIFY `generic V E` (C SUBGOAL_THEN ASSUME_TAC); BY(ASM_MESON_TAC[Appendix.scs_generic]); COMMENT "collinearity"; TYPIFY `~collinear {vec 0,v (p1 + (k-1)),v (p1 + 1)}` (C SUBGOAL_THEN ASSUME_TAC); MATCH_MP_TAC Zlzthic.PROPERTIES_GENERIC_LOCAL_FAN_ALT; GEXISTL_TAC [`V`;`E`;`FF`]; ASM_REWRITE_TAC[]; DISCH_TAC; INTRO_TAC Ocbicby.scs_lb_2 [`s`;`v`;`(p1+1)`;`(p1+(k-1))`]; ASM_REWRITE_TAC[DIST_REFL;arith `~(&2 <= &0)`]; GMATCH_SIMP_TAC Ocbicby.MOD_EQ_MOD_SHIFT; ASM_SIMP_TAC[arith `3 < k ==> ~(k=0)`]; REPEAT (GMATCH_SIMP_TAC MOD_LT); BY(FIRST_X_ASSUM_ST `3 < k` MP_TAC THEN ARITH_TAC); COMMENT "coplanarity"; TYPIFY `interior_angle1 (vec 0) FF (v p1) = azim (vec 0) (v p1) (v (p1+1)) (v (p1 + k -1))` (C SUBGOAL_THEN ASSUME_TAC); FIRST_X_ASSUM_ST `interior_angle1` (C INTRO_TAC [`v p1`]); ASM_REWRITE_TAC[]; FIRST_X_ASSUM_ST `ITER` (C INTRO_TAC [`p1`;`1`]); REWRITE_TAC[ITER_1]; BY(MESON_TAC[arith `1 + p1 = p1 + 1`]); TYPIFY `~coplanar {vec 0, v p1,v(p1+1),v(p1 + k- 1)}` (C SUBGOAL_THEN ASSUME_TAC); ASM_REWRITE_TAC[GSYM Local_lemmas1.AZIM_COND_FOR_COPLANAR]; FIRST_X_ASSUM (SUBST1_TAC o GSYM); BY(ASM_SIMP_TAC[DE_MORGAN_THM;arith `&0 <x ==> ~(x = &0)`; arith `(x < pi ==> ~(x = pi))`]); COMMENT "482"; INTRO_TAC (UNDISCH Ocbicby.LEMMA_4828966562) [`norm (v p0)`;`norm (v p2)`;`norm (v p1)`;`dist(v p1,v p2)`;`dist (v p0,v p1)`;`dist(v p0,v p2)`]; ANTS_TAC; ASM_REWRITE_TAC[GSYM Sphere.cstab]; TYPIFY_GOAL_THEN `&2 <= norm (v p0) /\ norm (v p0) <= &2 * h0 /\ &2 <= norm (v p2) /\ norm (v p2) <= &2 * h0 /\ &2 <= norm (v p1) /\ norm (v p1) <= &2 * h0 /\ &2 <= dist (v p1,v p2) /\ dist (v p1,v p2) <= &2 * h0 ` (unlist REWRITE_TAC); BY(ASM_MESON_TAC[ ( Fnjlbxs.in_ball_annulus);REAL_LE_TRANS]); CONJ_TAC; TYPIFY `dist(v p1, v p2) = dist(v p2,v p1)` (C SUBGOAL_THEN SUBST1_TAC); BY(REWRITE_TAC[DIST_SYM]); REWRITE_TAC[GSYM Trigonometry1.DIST_L_ZERO]; REWRITE_TAC[GSYM Oxlzlez.coplanar_delta_y]; FIRST_X_ASSUM MP_TAC; MATCH_MP_TAC (TAUT `(a = b) ==> (a ==> b)`); AP_TERM_TAC; AP_TERM_TAC; AP_TERM_TAC; BY(FIRST_X_ASSUM_ST `{a,b} = y` MP_TAC THEN SET_TAC[]); COMMENT "ups"; REWRITE_TAC[GSYM Trigonometry1.DIST_L_ZERO;arith `x*x = x pow 2`]; REWRITE_TAC[GSYM Collect_geom2.NOT_COL_EQ_UPS_X_POS]; FIRST_X_ASSUM_ST `collinear` MP_TAC; MATCH_MP_TAC (TAUT `(a = b) ==> (a ==> b)`); REPEAT AP_TERM_TAC; BY(FIRST_X_ASSUM_ST `{a,b} = y` MP_TAC THEN SET_TAC[]); REPEAT WEAKER_STRIP_TAC; (PROOF_BY_CONTR_TAC); TYPIFY `v p1 dot (v (p1 + 1) cross v (p1 + k -1)) > &0` (C SUBGOAL_THEN ASSUME_TAC); TYPIFY `v p1 dot (v (p1 + 1) cross v (p1 + k -1)) = (v p1 cross (v (p1 + 1))) dot ( v (p1 + k -1))` (C SUBGOAL_THEN SUBST1_TAC); BY(VEC3_TAC); REWRITE_TAC[arith `a > &0 <=> &0 < a`;GSYM Zlzthic.azim_lt_pi_cross]; BY(ASM_MESON_TAC[]); COMMENT "fix abs"; TYPIFY `(?f e'. &0 < e' /\ deformation f V (--e',e') /\ (!w t. ~(w = v p1) ==> f w t = w) /\ (!t. abs t < e' ==> dist (v p0,f (v p1) t) = dist (v p0,v p1) /\ dist (v p2,f (v p1) t) = dist (v p2,v p1) -abs t /\ norm (f (v p1) t) = norm (v p1)))` (C SUBGOAL_THEN MP_TAC); FIRST_X_ASSUM_ST `{a,b} = {c,d}` MP_TAC; REWRITE_TAC[Collect_geom.PAIR_EQ_EXPAND] THEN DISCH_THEN DISJ_CASES_TAC; INTRO_TAC deform_simplex_edge_exists [`V`;`(\t. -- abs t)`;`(\ (t:real). &0)`;`v (p1 + k -1)`;`v p1`;`v (p1 +1)`;`&1`]; STRIP_TAC; FIRST_X_ASSUM MP_TAC THEN ANTS_TAC; REWRITE_TAC[arith `&0 < &1 /\ -- &0 = &0`;REAL_CONTINUOUS_CONST]; REPEAT (GMATCH_SIMP_TAC REAL_CONTINUOUS_ON_EQ_REAL_CONTINUOUS_AT); REWRITE_TAC[REAL_OPEN_REAL_INTERVAL;REAL_CONTINUOUS_CONST;arith `--abs (&0) = &0`]; nCONJ_TAC 2; REPEAT WEAKER_STRIP_TAC; MATCH_MP_TAC REAL_CONTINUOUS_NEG; BY(REWRITE_TAC[real_continuous_abs]); FIRST_X_ASSUM (unlist REWRITE_TAC); FIRST_X_ASSUM_ST `cross` (unlist REWRITE_TAC); BY(ONCE_REWRITE_TAC[SET_RULE `{a,b,c,d} = {a,c,d,b}`] THEN FIRST_X_ASSUM_ST `coplanar` (unlist REWRITE_TAC)); ASM_REWRITE_TAC[arith `x + &0 = x`;arith `x + -- t = x - t`;DIST_SYM]; REPEAT WEAKER_STRIP_TAC; GEXISTL_TAC [`f`;`e'`]; ASM_REWRITE_TAC[]; BY(FIRST_X_ASSUM MP_TAC THEN MESON_TAC[]); INTRO_TAC deform_simplex_edge_exists [`V`;`(\ (t:real). &0)`;`(\t. --abs t)`;`v (p1 +k - 1)`;`v p1`;`v (p1 +1)`;`&1`]; STRIP_TAC; FIRST_X_ASSUM MP_TAC THEN ANTS_TAC; REWRITE_TAC[arith `&0 < &1 /\ -- &0 = &0`;REAL_CONTINUOUS_CONST]; REPEAT (GMATCH_SIMP_TAC REAL_CONTINUOUS_ON_EQ_REAL_CONTINUOUS_AT); REWRITE_TAC[REAL_OPEN_REAL_INTERVAL;REAL_CONTINUOUS_CONST;arith `--abs(&0)= &0`]; FIRST_X_ASSUM_ST `cross` (unlist REWRITE_TAC); ONCE_REWRITE_TAC[SET_RULE `{a,b,c,d} = {a,c,d,b}`] THEN FIRST_X_ASSUM_ST `coplanar` (unlist REWRITE_TAC); REPEAT WEAKER_STRIP_TAC THEN MATCH_MP_TAC REAL_CONTINUOUS_NEG; BY(REWRITE_TAC[real_continuous_abs]); ASM_REWRITE_TAC[arith `x + &0 = x`;arith `x + -- t = x - t`;DIST_SYM]; REPEAT WEAKER_STRIP_TAC; GEXISTL_TAC [`f`;`e'`]; BY(ASM_REWRITE_TAC[]); (REPEAT WEAKER_STRIP_TAC); TYPIFY `~(k=0)` (C SUBGOAL_THEN ASSUME_TAC); BY(ASM_SIMP_TAC[arith `3 < k ==> ~(k=0)`]); TYPIFY `!i j.scs_a_v39 s (i MOD k) (j MOD k) = scs_a_v39 s i j /\ scs_b_v39 s (i MOD k) (j MOD k) = scs_b_v39 s i j ` (C SUBGOAL_THEN ASSUME_TAC); FIRST_X_ASSUM_ST `is_scs_v39` MP_TAC; ASM_REWRITE_TAC[Appendix.is_scs_v39]; BY(FIRST_X_ASSUM MP_TAC THEN MESON_TAC[periodic2_MOD]); TYPIFY `!i. i MOD k < k` (C SUBGOAL_THEN ASSUME_TAC); BY(REPLICATE_TAC 3 (FIRST_X_ASSUM MP_TAC) THEN MESON_TAC[DIVISION]); TYPIFY `!i. v (i MOD k) = v i` (C SUBGOAL_THEN ASSUME_TAC); GEN_TAC; MATCH_MP_TAC (GSYM Oxl_def.periodic_mod); BY(ASM_REWRITE_TAC[]); INTRO_TAC BBs_inj [`s`;`v`;`k`]; ASM_REWRITE_TAC[]; DISCH_TAC; TYPIFY `!j. j < k ==> (j MOD k = j)` (C SUBGOAL_THEN ASSUME_TAC); BY(REWRITE_TAC[MOD_LT]); COMMENT "restart here"; TYPIFY `~(v (p1+1) = v p1) /\ ~(v (p1 + k -1) = v p1)` (C SUBGOAL_THEN ASSUME_TAC); TYPIFY `v p1 = v (p1+0)` (C SUBGOAL_THEN SUBST1_TAC); BY(REWRITE_TAC[arith `p1+0 = p1`]); FIRST_ASSUM_ST `v(i MOD k) = v i` ((unlist ONCE_REWRITE_TAC) o GSYM); TYPIFY_GOAL_THEN `!i j. i < k /\ j < k /\ ~(i = j) ==> ~(v i = v (j:num))` (REPEAT o GMATCH_SIMP_TAC); BY(REPLICATE_TAC 2 (FIRST_X_ASSUM MP_TAC) THEN MESON_TAC[]); REPEAT (GMATCH_SIMP_TAC Ocbicby.MOD_EQ_MOD_SHIFT); ASM_REWRITE_TAC[]; FIRST_X_ASSUM (REPEAT o GMATCH_SIMP_TAC); BY(FIRST_X_ASSUM_ST `3 < k` MP_TAC THEN ARITH_TAC); TYPIFY `(!t. f (v (p1+1)) t = v(p1+1)) /\ (!t. f (v (p1+k-1)) t = v (p1+k-1))` (C SUBGOAL_THEN ASSUME_TAC); BY(CONJ_TAC THEN GEN_TAC THEN FIRST_X_ASSUM_ST `(f w t = w)` MATCH_MP_TAC THEN ASM_REWRITE_TAC[]); TYPIFY `?e1. &0 < e1 /\ (!t. abs t < e1 ==> &0 < azim (vec 0) (f (v p1) t) (v (p1+1)) (v (p1+k-1)) /\ azim (vec 0) (f(v p1) t) (v (p1+1)) (v (p1+k-1)) < pi)` (C SUBGOAL_THEN MP_TAC); INTRO_TAC WNWSHJT_ALT [`v(p1+k-1)`;`v (p1)`;`v (p1+1)`;`f`;`-- e'`;`e'`;`pi`]; ASM_REWRITE_TAC[]; ANTS_TAC; CONJ_TAC; MATCH_MP_TAC Zlzthic.deformation_subset; TYPIFY `V` EXISTS_TAC; ASM_REWRITE_TAC[]; EXPAND_TAC "V"; BY(REWRITE_TAC[SUBSET;IN_INSERT;NOT_IN_EMPTY;IN_IMAGE;IN_UNIV] THEN MESON_TAC[]); TYPIFY_GOAL_THEN `~collinear {vec 0, v p1, v (p1 + 1)} /\ ~collinear {vec 0, v p1, v (p1 + k - 1)}` (unlist REWRITE_TAC); BY(FIRST_X_ASSUM_ST `coplanar` MP_TAC THEN MESON_TAC[Planarity.notcoplanar_imp_notcollinear_fan]); BY(ASM_MESON_TAC[]); BY(MESON_TAC[]); REPEAT WEAKER_STRIP_TAC; TYPIFY `!t. abs t < e1 ==> ((&0 < azim (vec 0) (v(p1+1)) (v(p1+k-1)) (f (v p1) t) /\ azim (vec 0) (v(p1+1)) (v(p1+k-1)) (f (v p1) t) < pi) /\ (&0 < azim (vec 0) (v(p1+k-1)) (f (v p1) t) (v(p1+1)) /\ azim (vec 0) (v(p1+k-1)) (f (v p1) t) (v(p1+1)) < pi))` (C SUBGOAL_THEN ASSUME_TAC); REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM_ST `azim` (C INTRO_TAC [`t`]); ASM_REWRITE_TAC[GSYM sin_azim_pos]; INTRO_TAC Trigonometry.JBDNJJB [`f (v p1) t`;`v(p1 + 1)`;`v (p1+k-1)`]; INTRO_TAC Trigonometry.JBDNJJB [`v(p1 + 1)`;`v (p1+k-1)`;`f (v p1) t`]; INTRO_TAC Trigonometry.JBDNJJB [`v (p1+k-1)`;`f (v p1) t`;`v(p1 + 1)`]; TYPIFY_GOAL_THEN `((v (p1 + k - 1) cross f (v p1) t) dot v (p1 + 1)) = ((f (v p1) t cross v (p1 + 1)) dot v (p1 + k - 1)) /\ ((v (p1 + 1) cross v (p1 + k - 1)) dot f (v p1) t) = ((f (v p1) t cross v (p1 + 1)) dot v (p1 + k - 1))` (unlist REWRITE_TAC); BY(MESON_TAC[CROSS_TRIPLE]); TYPIFY `!a b. re_eqvl a b ==> (&0 < a <=> &0 < b)` ENOUGH_TO_SHOW_TAC; BY(MESON_TAC[]); REWRITE_TAC[Trigonometry2.re_eqvl]; REPEAT WEAKER_STRIP_TAC; ASM_REWRITE_TAC[]; GMATCH_SIMP_TAC REAL_LT_MUL_EQ; BY(ASM_REWRITE_TAC[]); TYPIFY `!w. w IN V ==> f w (&0) = w` (C SUBGOAL_THEN ASSUME_TAC); REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM_ST `deformation` MP_TAC THEN REWRITE_TAC[Localization.deformation]; BY(FIRST_X_ASSUM MP_TAC THEN MESON_TAC[]); TYPIFY `?e2. &0 < e2 /\ (!t. abs t < e2 ==> ~coplanar {vec 0, (f (v p1) t),v (p1+k-1),v(p1+1)})` (C SUBGOAL_THEN MP_TAC); INTRO_TAC Zlzthic.NONPLANAR_OPEN [`( \ (t:real). (vec 0):real^3)`;`f (v p1)`;`\ (t:real). v (p1+k-1)`;`\ (t:real). v (p1+1)`;`&0`]; ASM_REWRITE_TAC[CONTINUOUS_CONST]; ANTS_TAC; CONJ_TAC; FIRST_X_ASSUM GMATCH_SIMP_TAC; ONCE_REWRITE_TAC[SET_RULE `{a,b,c,d} = {a,b,d,c}`]; BY(ASM_REWRITE_TAC[]); FIRST_X_ASSUM_ST `deformation` MP_TAC THEN REWRITE_TAC[Localization.deformation]; BY(REPEAT WEAKER_STRIP_TAC THEN FIRST_X_ASSUM MATCH_MP_TAC THEN ASM_REWRITE_TAC[]); BY(REWRITE_TAC[arith `abs (&0 - t') = abs t'`] THEN MESON_TAC[]); REPEAT WEAKER_STRIP_TAC; COMMENT "insert"; INTRO_TAC dihV_obtuse_mono [`(vec 0):real^3`;`v p0`;`v p1`;`v p2`]; ANTS_TAC; ASM_REWRITE_TAC[]; TYPIFY `{vec 0,v p0, v p1,v p2} = {vec 0,v p1,v (p1+1),v(p1+k-1)}` (C SUBGOAL_THEN SUBST1_TAC); FIRST_X_ASSUM_ST `{a,b} ={c,d}` MP_TAC; BY(SET_TAC[]); BY(ASM_REWRITE_TAC[]); REPEAT WEAKER_STRIP_TAC; REPLICATE_TAC 2(FIRST_X_ASSUM MP_TAC THEN BURY_MP_TAC); COMMENT "end insert"; INTRO_TAC epsilon_quad [`e1`;`e2`;`e'`;`e`] THEN ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; TYPIFY `!t. abs t < e'''' ==> azim (vec 0) (f(v p1) t) (v (p1+1)) (v (p1+k-1)) = dihV (vec 0) (f (v p1) t) (v (p1 + 1)) (v (p1 + k - 1)) /\ azim (vec 0) (v (p1 + 1)) (v (p1 + k - 1)) (f (v p1) t) = dihV (vec 0) (v (p1 + 1)) (v (p1 + k - 1)) (f (v p1) t) /\ azim (vec 0) (v (p1 + k - 1)) (f (v p1) t) (v (p1 + 1)) = dihV (vec 0) (v (p1 + k - 1)) (f (v p1) t) (v (p1 + 1))` (C SUBGOAL_THEN ASSUME_TAC); GEN_TAC THEN ASM_REWRITE_TAC[] THEN DISCH_TAC; REPEAT (GMATCH_SIMP_TAC (GSYM AZIM_DIHV_SAME)); INTRO_TAC Planarity.notcoplanar_imp_notcollinear_fan [`(vec 0):real^3`;`f (v p1) t`;`v(p1+k-1)`;`v(p1+1)`]; ANTS_TAC; BY((FIRST_X_ASSUM MATCH_MP_TAC THEN FIRST_X_ASSUM MATCH_MP_TAC THEN ASM_REWRITE_TAC[])); REWRITE_TAC[SET_RULE `{a,b,c} = {a,c,b}`]; DISCH_THEN (unlist REWRITE_TAC); BY(REPLICATE_TAC 12 (FIRST_X_ASSUM MP_TAC) THEN MESON_TAC[]); COMMENT "introduce azim"; INTRO_TAC azim_assumption_reduction [`s`;`k`;`p1`;`f`;`v`;`e''''`]; ASM_REWRITE_TAC[]; DISCH_THEN MP_TAC THEN ANTS_TAC; CONJ_TAC; FIRST_X_ASSUM_ST `deformation` MP_TAC; REWRITE_TAC[Localization.deformation]; REWRITE_TAC[IN_REAL_INTERVAL;arith `--e < t /\ t < e <=> abs t < e`]; BY(REPLICATE_TAC 7 (FIRST_X_ASSUM MP_TAC) THEN MESON_TAC[arith `abs(&0) = &0`]); CONJ_TAC; BY(ASM_MESON_TAC[]); TYPIFY `(azim (vec 0) (v (p1 + k - 1)) (v p1) (v (p1 + k - 2)) < pi \/ ( (!t. abs t < e'''' ==> dihV (vec 0) (v (p1 + k - 1)) (f (v p1) t) (v (p1 + 1)) <= dihV (vec 0) (v (p1 + k - 1)) (v p1) (v (p1 + 1))))) /\ (azim (vec 0) (v (p1 + 1)) (v (p1 + 2)) (v p1) < pi \/ ( (!t. abs t < e'''' ==> dihV (vec 0) (v (p1 + 1)) (v (p1 + k - 1)) (f (v p1) t) <= dihV (vec 0) (v (p1 + 1)) (v (p1 + k - 1)) (v p1))))` ENOUGH_TO_SHOW_TAC; REPEAT WEAKER_STRIP_TAC; REWRITE_TAC[MESON [] `(a \/ (?e1. P e1)) <=> (?e1. (a \/ P e1))`;MESON[] `(a /\ (?e1. P e1)) <=> (?e1. a /\ P e1)`;MESON[] `((?e1. P e1) /\ b) <=> (?e1. P e1 /\ b)`]; GEXISTL_TAC [`e''''`;`e''''`]; FIRST_X_ASSUM_ST `w IN V ==> f w (&0) = (w:real^3)` (C INTRO_TAC [`v p1`]); ASM_REWRITE_TAC[]; BY(REPLICATE_TAC 12 (FIRST_X_ASSUM MP_TAC) THEN MESON_TAC[arith `abs(&0) = &0`]); COMMENT "obtuse case"; (TYPIFY `pi/ &2 < dihV (vec 0) (v p1) (v (p1+1)) (v (p1+k-1))` ASM_CASES_TAC); TYPIFY `dihV (vec 0) (v p1) (v(p1+1)) (v (p1+k-1)) = dihV (vec 0) (v p1) (v p2) (v p0)` (C SUBGOAL_THEN ASSUME_TAC); BY(FIRST_X_ASSUM_ST `{a,b}={c,d}` MP_TAC THEN REWRITE_TAC[Collect_geom.PAIR_EQ_EXPAND] THEN MESON_TAC[DIHV_SYM]); TYPIFY `!t. abs t < e'''' ==> dihV (vec 0) (v p0) (f (v p1) t) (v p2) <= dihV (vec 0) (v p0) (v p1) (v p2) /\ dihV (vec 0) (v p2) (f (v p1) t) (v p0) <= dihV (vec 0) (v p2) (v p1) (v p0)` ENOUGH_TO_SHOW_TAC; BY(FIRST_X_ASSUM_ST `{a,b}={c,d}` MP_TAC THEN REWRITE_TAC[Collect_geom.PAIR_EQ_EXPAND] THEN DISCH_THEN DISJ_CASES_TAC THEN FIRST_X_ASSUM (unlist REWRITE_TAC) THEN MESON_TAC[DIHV_SYM]); REPEAT WEAKER_STRIP_TAC; REPEAT (FIRST_X_ASSUM_ST `dihV a b c d <= dihV a' b' c' d'` MP_TAC THEN ASM_REWRITE_TAC[] THEN DISCH_THEN (C INTRO_TAC [`f (v p1) t`;`-- abs t`])); (FIRST_X_ASSUM_ST `dihV a b c d <= dihV a' b' c' d'` MP_TAC THEN ANTS_TAC THENL [REPLICATE_TAC 3 (FIRST_X_ASSUM MP_TAC) THEN MESON_TAC[];ALL_TAC] THEN DISCH_THEN (C INTRO_TAC [`f (v p1) t`;`-- abs t`])); REWRITE_TAC[DIST_SYM;arith `abs(-- abs t) = abs t`;arith `--abs t <= &0`]; REPEAT (DISCH_THEN GMATCH_SIMP_TAC); REWRITE_TAC[arith `a + -- b = a - b`]; FIRST_X_ASSUM_ST `norm` (C INTRO_TAC [` t`]); ANTS_TAC; BY(FIRST_X_ASSUM MATCH_MP_TAC THEN FIRST_X_ASSUM (unlist REWRITE_TAC)); TYPIFY_GOAL_THEN `abs t < e` (unlist REWRITE_TAC); BY(FIRST_X_ASSUM MATCH_MP_TAC THEN FIRST_X_ASSUM (unlist REWRITE_TAC)); BY(REWRITE_TAC[DIST_SYM;DIST_0] THEN MESON_TAC[]); COMMENT "nonobtuse case"; FIRST_X_ASSUM_ST `pi / &2 < interior_angle1 (vec 0) FF (v p1)` MP_TAC; DISCH_TAC; TYPIFY `interior_angle1 (vec 0) FF (v p2) < pi` (C SUBGOAL_THEN ASSUME_TAC); TYPIFY `dihV (vec 0) (v p1) (v (p1+1)) (v (p1+k-1)) = interior_angle1 (vec 0) FF (v p1)` ENOUGH_TO_SHOW_TAC; BY(REPLICATE_TAC 2 (FIRST_X_ASSUM MP_TAC) THEN MESON_TAC[]); FIRST_X_ASSUM_ST `azim` (C INTRO_TAC [`&0`]); BY(ASM_SIMP_TAC[arith `abs(&0) = &0`]); FIRST_X_ASSUM_ST `{a,b}={c,d}` (MP_TAC o GSYM) THEN REWRITE_TAC[Collect_geom.PAIR_EQ_EXPAND] THEN DISCH_THEN DISJ_CASES_TAC; FIRST_X_ASSUM_ST `interior_angle1` MP_TAC THEN (FIRST_ASSUM (unlist REWRITE_TAC)); INTRO_TAC Ocbicby.INTERIOR_ANGLE1_AZIM [`s`;`v`;`p1 + k - 1`]; ASM_REWRITE_TAC[LET_THM;IN]; DISCH_THEN (SUBST1_TAC o GSYM); TYPIFY_GOAL_THEN `v (SUC (p1+k-1)) = v p1 /\ v ((p1+k-1)+(k-1)) = v (p1 + k - 2)` (unlist REWRITE_TAC); FIRST_ASSUM_ST `v(i MOD k) = v i` ((unlist ONCE_REWRITE_TAC) o GSYM); FIRST_X_ASSUM_ST `3 < k` MP_TAC; BY(SIMP_TAC[arith `3 < k ==> SUC (p1+k-1) = 1*k + p1 /\ ((p1+k-1)+(k-1) = (1*k + (p1+k-2)))`;MOD_MULT_ADD]); DISCH_THEN (unlist REWRITE_TAC); DISJ2_TAC; REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM_ST ` /\ ` ((unlist REWRITE_TAC) o GSYM); ONCE_REWRITE_TAC[DIHV_SYM]; FIRST_X_ASSUM MATCH_MP_TAC; TYPIFY `-- abs t` EXISTS_TAC; REWRITE_TAC[arith `abs(-- abs t) = abs (t)`;arith `-- abs t <= &0`;arith `x + -- t = x - t`;DIST_0;DIST_SYM]; CONJ_TAC; BY(FIRST_X_ASSUM MATCH_MP_TAC THEN FIRST_X_ASSUM (unlist REWRITE_TAC)); FIRST_X_ASSUM_ST `norm` (C INTRO_TAC [`t`]); ANTS_TAC; BY(FIRST_X_ASSUM MATCH_MP_TAC THEN FIRST_X_ASSUM (unlist REWRITE_TAC)); BY(REWRITE_TAC[DIST_SYM] THEN MESON_TAC[]); COMMENT "second nonobtuse case"; FIRST_X_ASSUM_ST `interior_angle1` MP_TAC THEN (FIRST_ASSUM (unlist REWRITE_TAC)); INTRO_TAC Ocbicby.INTERIOR_ANGLE1_AZIM [`s`;`v`;`p1 +1`]; ASM_REWRITE_TAC[LET_THM;IN]; DISCH_THEN (SUBST1_TAC o GSYM); REWRITE_TAC[arith `SUC (p1+1) = p1+2`]; TYPIFY_GOAL_THEN `v ((p1+1)+k-1) = v p1` (unlist REWRITE_TAC); FIRST_ASSUM_ST `v(i MOD k) = v i` ((unlist ONCE_REWRITE_TAC) o GSYM); FIRST_X_ASSUM_ST `3 < k` MP_TAC; BY(SIMP_TAC[arith `3 < k ==> (p1+1)+k-1 = 1*k + p1`;MOD_MULT_ADD]); DISCH_THEN (unlist REWRITE_TAC); DISJ2_TAC; REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM_ST ` /\ ` ((unlist REWRITE_TAC) o GSYM); FIRST_X_ASSUM MATCH_MP_TAC; TYPIFY `-- abs t` EXISTS_TAC; REWRITE_TAC[arith `abs(-- abs t) = abs (t)`;arith `-- abs t <= &0`;arith `x + -- t = x - t`;DIST_0;DIST_SYM]; CONJ_TAC; BY(FIRST_X_ASSUM MATCH_MP_TAC THEN FIRST_X_ASSUM (unlist REWRITE_TAC)); FIRST_X_ASSUM_ST `norm` (C INTRO_TAC [`t`]); ANTS_TAC; BY(FIRST_X_ASSUM MATCH_MP_TAC THEN FIRST_X_ASSUM (unlist REWRITE_TAC)); BY(REWRITE_TAC[DIST_SYM] THEN MESON_TAC[]); REPEAT WEAKER_STRIP_TAC; COMMENT "finally back to root goal"; TYPIFY `!i j. (v i = v j) ==> (i MOD k = j MOD k)` (C SUBGOAL_THEN ASSUME_TAC); FIRST_ASSUM_ST `v (i MOD k) = v i` ((unlist ONCE_REWRITE_TAC) o GSYM); FIRST_X_ASSUM_ST `!i (j:num). i < k /\ j < k /\ v i = v j ==> i = j` MP_TAC; FIRST_X_ASSUM_ST `!i. i MOD k < k` MP_TAC; BY(MESON_TAC[]); TYPIFY `psort k (p0,p2) = psort k (p1+1,p1+k-1)` (C SUBGOAL_THEN ASSUME_TAC); FIRST_X_ASSUM_ST `~(k=0)` MP_TAC; DISCH_TAC; INTRO_TAC psort_mod [`k`]; FIRST_X_ASSUM (unlist REWRITE_TAC); DISCH_THEN ((unlist ONCE_REWRITE_TAC) o GSYM); FIRST_X_ASSUM_ST `{a,b}={c,d}` (MP_TAC) THEN REWRITE_TAC[Collect_geom.PAIR_EQ_EXPAND] THEN DISCH_THEN DISJ_CASES_TAC; BY(REPLICATE_TAC 2 (FIRST_X_ASSUM MP_TAC) THEN MESON_TAC[]); BY(REPLICATE_TAC 2 (FIRST_X_ASSUM MP_TAC) THEN MESON_TAC[Terminal.psort_sym]); INTRO_TAC deformation_BBs_ALT [`s`;`k`;`f`;`v`;`e''''`]; ANTS_TAC; ASM_REWRITE_TAC[]; CONJ_TAC; MATCH_MP_TAC deformation_restrict; TYPIFY `e'` EXISTS_TAC; BY(ASM_REWRITE_TAC[]); CONJ_TAC; REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM_ST `norm` (C INTRO_TAC [`t`]); ANTS_TAC; BY(FIRST_X_ASSUM MATCH_MP_TAC THEN (FIRST_X_ASSUM (unlist REWRITE_TAC))); TYPIFY `v i = v p1` ASM_CASES_TAC; BY(FIRST_X_ASSUM (unlist REWRITE_TAC) THEN MESON_TAC[]); FIRST_X_ASSUM_ST `!w t. ~(w = v p1) ==> f w t = w` (C INTRO_TAC [`v i`;`t`]); BY(FIRST_X_ASSUM MP_TAC THEN MESON_TAC[]); CONJ_TAC; MATCH_MP_TAC a_assumption_reduction; GEXISTL_TAC [`k`;`p1`;`e'`]; ASM_REWRITE_TAC[]; CONJ_TAC; REPEAT (FIRST_X_ASSUM_ST `psort` MP_TAC); BY(MESON_TAC[]); TYPIFY `(?e1. &0 < e1 /\ (scs_a_v39 s p1 p2 = dist (v p1,v p2) ==> (!t. abs t < e1 ==> scs_a_v39 s p1 (p2) <= dist (f (v p1) t,v (p2))))) /\ (?e1. &0 < e1 /\ (scs_a_v39 s p1 (p0) = dist (v p1,v (p0)) ==> (!t. abs t < e1 ==> scs_a_v39 s p1 (p0) <= dist (f (v p1) t,v (p0)))))` (C SUBGOAL_THEN ASSUME_TAC); CONJ2_TAC; ASM_REWRITE_TAC[]; TYPIFY `e'` EXISTS_TAC; ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM_ST `norm` (C INTRO_TAC [`t`]); BY(FIRST_X_ASSUM (unlist REWRITE_TAC) THEN (REPLICATE_TAC 2 (FIRST_X_ASSUM MP_TAC)) THEN REWRITE_TAC[DIST_SYM] THEN REAL_ARITH_TAC); TYPIFY `&1` EXISTS_TAC; BY(ASM_REWRITE_TAC[arith `&0 < &1`]); FIRST_X_ASSUM_ST `{a,b}={c,d}` (MP_TAC) THEN REWRITE_TAC[Collect_geom.PAIR_EQ_EXPAND] THEN DISCH_THEN DISJ_CASES_TAC; TYPIFY `(p1 + 1) MOD k = p0 MOD k /\ (p1+k-1) MOD k = p2 MOD k` (C SUBGOAL_THEN ASSUME_TAC); BY(REPLICATE_TAC 5 (FIRST_X_ASSUM MP_TAC) THEN MESON_TAC[]); TYPIFY_GOAL_THEN `scs_a_v39 s p1 (p1+1) = scs_a_v39 s p1 p0 /\ scs_a_v39 s p1 (p1+k-1) = scs_a_v39 s p1 p2` (unlist REWRITE_TAC); FIRST_X_ASSUM_ST `is_scs_v39` MP_TAC; BY(FIRST_X_ASSUM MP_TAC THEN FIRST_X_ASSUM_ST `scs_k_v39 s = k` MP_TAC THEN MESON_TAC[Nuxcoea.CHANGE_A_SCS_MODR]); FIRST_X_ASSUM kill THEN FIRST_X_ASSUM (unlist REWRITE_TAC); BY(FIRST_X_ASSUM MP_TAC THEN MESON_TAC[]); TYPIFY `(p1 + 1) MOD k = p2 MOD k /\ (p1+k-1) MOD k = p0 MOD k` (C SUBGOAL_THEN ASSUME_TAC); BY(REPLICATE_TAC 5 (FIRST_X_ASSUM MP_TAC) THEN MESON_TAC[]); TYPIFY_GOAL_THEN `scs_a_v39 s p1 (p1+1) = scs_a_v39 s p1 p2 /\ scs_a_v39 s p1 (p1+k-1) = scs_a_v39 s p1 p0` (unlist REWRITE_TAC); FIRST_X_ASSUM_ST `is_scs_v39` MP_TAC; BY(FIRST_X_ASSUM MP_TAC THEN FIRST_X_ASSUM_ST `scs_k_v39 s = k` MP_TAC THEN MESON_TAC[Nuxcoea.CHANGE_A_SCS_MODR]); FIRST_X_ASSUM kill THEN FIRST_X_ASSUM (unlist REWRITE_TAC); BY(FIRST_X_ASSUM MP_TAC THEN MESON_TAC[]); COMMENT "b assumption"; MATCH_MP_TAC b_assumption_reduction; GEXISTL_TAC [`k`;`p1`;`e'`]; ASM_REWRITE_TAC[]; TYPIFY `(?e2. &0 < e2 /\ (dist (v p1,v (p2)) = scs_b_v39 s p1 (p2) ==> (!t. abs t < e2 ==> dist (f (v p1) t,v (p2)) <= scs_b_v39 s p1 (p2)))) /\ (?e2. &0 < e2 /\ (dist (v p1,v (p0)) = scs_b_v39 s p1 (p0) ==> (!t. abs t < e2 ==> dist (f (v p1) t,v (p0)) <= scs_b_v39 s p1 (p0))))` (C SUBGOAL_THEN ASSUME_TAC); CONJ2_TAC; ASM_REWRITE_TAC[]; TYPIFY `e'` EXISTS_TAC; ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM_ST `norm` (C INTRO_TAC [`t`]); BY(FIRST_X_ASSUM (unlist REWRITE_TAC) THEN (REPLICATE_TAC 2 (FIRST_X_ASSUM MP_TAC)) THEN REWRITE_TAC[DIST_SYM] THEN REAL_ARITH_TAC); TYPIFY `e'` EXISTS_TAC; ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM_ST `norm` (C INTRO_TAC [`t`]); BY(FIRST_X_ASSUM (unlist REWRITE_TAC) THEN (REPLICATE_TAC 2 (FIRST_X_ASSUM MP_TAC)) THEN REWRITE_TAC[DIST_SYM] THEN REAL_ARITH_TAC); FIRST_X_ASSUM_ST `{a,b}={c,d}` (MP_TAC) THEN REWRITE_TAC[Collect_geom.PAIR_EQ_EXPAND] THEN DISCH_THEN DISJ_CASES_TAC; TYPIFY `(p1 + 1) MOD k = p0 MOD k /\ (p1+k-1) MOD k = p2 MOD k` (C SUBGOAL_THEN ASSUME_TAC); BY(REPLICATE_TAC 5 (FIRST_X_ASSUM MP_TAC) THEN MESON_TAC[]); TYPIFY_GOAL_THEN `scs_b_v39 s p1 (p1+1) = scs_b_v39 s p1 p0 /\ scs_b_v39 s p1 (p1+k-1) = scs_b_v39 s p1 p2` (unlist REWRITE_TAC); FIRST_X_ASSUM_ST `is_scs_v39` MP_TAC; BY(FIRST_X_ASSUM MP_TAC THEN FIRST_X_ASSUM_ST `scs_k_v39 s = k` MP_TAC THEN MESON_TAC[Nuxcoea.CHANGE_B_SCS_MODR]); FIRST_X_ASSUM kill THEN FIRST_X_ASSUM (unlist REWRITE_TAC); BY(FIRST_X_ASSUM MP_TAC THEN MESON_TAC[]); TYPIFY `(p1 + 1) MOD k = p2 MOD k /\ (p1+k-1) MOD k = p0 MOD k` (C SUBGOAL_THEN ASSUME_TAC); BY(REPLICATE_TAC 5 (FIRST_X_ASSUM MP_TAC) THEN MESON_TAC[]); TYPIFY_GOAL_THEN `scs_b_v39 s p1 (p1+1) = scs_b_v39 s p1 p2 /\ scs_b_v39 s p1 (p1+k-1) = scs_b_v39 s p1 p0` (unlist REWRITE_TAC); FIRST_X_ASSUM_ST `is_scs_v39` MP_TAC; BY(FIRST_X_ASSUM MP_TAC THEN FIRST_X_ASSUM_ST `scs_k_v39 s = k` MP_TAC THEN MESON_TAC[Nuxcoea.CHANGE_B_SCS_MODR]); FIRST_X_ASSUM kill THEN FIRST_X_ASSUM (unlist REWRITE_TAC); BY(FIRST_X_ASSUM MP_TAC THEN MESON_TAC[]); REPEAT WEAKER_STRIP_TAC; COMMENT "back to root, next tau"; TYPIFY `!t. abs t < e'' ==> sum {i | i < k} (\i. rho_fun (norm (v i)) * azim (vec 0) (v i) (v (i + 1)) (v (i + k - 1))) <= sum {i | i < k} (\i. rho_fun (norm (f (v i) t)) * azim (vec 0) (f (v i) t) (f(v(i+1)) t) (f (v (i + k - 1)) t))` (C SUBGOAL_THEN ASSUME_TAC); REPEAT WEAKER_STRIP_TAC; MATCH_MP_TAC MMs_minimize_tau_fun; TYPIFY `s` EXISTS_TAC; ASM_REWRITE_TAC[]; FIRST_X_ASSUM MATCH_MP_TAC; BY(FIRST_X_ASSUM (unlist REWRITE_TAC)); TYPIFY `!t. abs t < e'' ==> sum ({i | i < k} DIFF {p1 MOD k,(p1+1) MOD k, (p1+k-1) MOD k}) (\i. rho_fun (norm (f (v i) t)) * azim (vec 0) (f (v i) t) (f (v (i + 1)) t) (f (v (i + k - 1)) t)) = sum {i | i < k} (\i. rho_fun (norm (f (v i) t)) * azim (vec 0) (f (v i) t) (f (v (i + 1)) t) (f (v (i + k - 1)) t)) - sum {p1 MOD k,(p1+1) MOD k, (p1+k-1) MOD k} (\i. rho_fun (norm (f (v i) t)) * azim (vec 0) (f (v i) t) (f (v (i + 1)) t) (f (v (i + k - 1)) t))` (C SUBGOAL_THEN ASSUME_TAC); REPEAT WEAKER_STRIP_TAC; MATCH_MP_TAC SUM_DIFF; REWRITE_TAC[FINITE_NUMSEG_LT]; ASM_REWRITE_TAC[SUBSET;IN_INSERT;NOT_IN_EMPTY;IN_ELIM_THM]; BY(REPEAT WEAKER_STRIP_TAC THEN REPEAT (FIRST_X_ASSUM DISJ_CASES_TAC) THEN ASM_REWRITE_TAC[]); TYPIFY `(\i. rho_fun (norm (f (v i) (&0))) * azim (vec 0) (f (v i) (&0)) (f (v (i + 1)) (&0)) (f (v (i + k - 1)) (&0))) = (\i. rho_fun (norm ((v i) )) * azim (vec 0) ( (v i) ) ( (v (i + 1)) ) ( (v (i + k - 1)) ))` (C SUBGOAL_THEN ASSUME_TAC); ASM_REWRITE_TAC[FUN_EQ_THM]; GEN_TAC; BY(ASM_SIMP_TAC[]); TYPIFY `?e3. &0 < e3 /\ (!t. abs t < e3 ==> dist(v p1,v p2) + t IN real_interval(a,b))` (C SUBGOAL_THEN MP_TAC); INTRO_TAC Zlzthic.real_interval_contains_0_ball [`a-dist(v p1,v p2)`;`b - dist(v p1,v p2)`;`&1`]; REWRITE_TAC[arith `&0 < &1`;arith `a - d < &0 <=> a < d`;arith `&0 < b - d <=> d < b`]; ANTS_TAC; FIRST_X_ASSUM_ST `dist s IN real_interval (a,b)` MP_TAC; BY(REWRITE_TAC[IN_REAL_INTERVAL]); REPEAT WEAKER_STRIP_TAC; TYPIFY `e'''` EXISTS_TAC; BY(ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC THEN (FIRST_X_ASSUM (C INTRO_TAC [`t`])) THEN REPLICATE_TAC 6 (FIRST_X_ASSUM MP_TAC) THEN REWRITE_TAC[IN_REAL_INTERVAL] THEN REAL_ARITH_TAC); REPEAT WEAKER_STRIP_TAC; COMMENT "combine e'' e1' e'''' e3 "; INTRO_TAC epsilon_quad [`e''`;`e1'`;`e''''`;`e3`] THEN ASM_REWRITE_TAC[] THEN REPEAT WEAKER_STRIP_TAC; TYPIFY ` ((p1+1) MOD k + k-1) MOD k = p1 MOD k /\ ((p1+k-1) MOD k + 1) MOD k = p1 MOD k` (C SUBGOAL_THEN ASSUME_TAC); GMATCH_SIMP_TAC MOD_SHIFT; TYPIFY `p1+1` EXISTS_TAC; FIRST_X_ASSUM_ST `~(k=0)` MP_TAC THEN SIMP_TAC[arith `~(k=0) ==> (p1+1) + k -1 = 1 *k + p1`;MOD_MULT_ADD;MOD_MOD_REFL]; DISCH_TAC; GMATCH_SIMP_TAC MOD_SHIFT; TYPIFY `p1+k-1` EXISTS_TAC; BY(FIRST_X_ASSUM_ST `~(k=0)` MP_TAC THEN SIMP_TAC[arith `~(k=0) ==> (p1+k-1) +1 = 1 *k + p1`;MOD_MULT_ADD;MOD_MOD_REFL]); TYPIFY `!t. abs t < e'''''' ==> sum {p1 MOD k, (p1 + 1) MOD k, (p1 + k - 1) MOD k} (\i. rho_fun (norm (v i)) * azim (vec 0) (v i) (v (i + 1)) (v (i + k - 1))) <= sum {p1 MOD k, (p1 + 1) MOD k, (p1 + k - 1) MOD k} (\i. rho_fun (norm (f (v i) t)) * azim (vec 0) (f (v i) t) (f (v (i + 1)) t) (f (v (i + k - 1)) t))` (C SUBGOAL_THEN ASSUME_TAC); REPEAT WEAKER_STRIP_TAC; FIRST_ASSUM_ST `sum` (C INTRO_TAC [`&0`]); FIRST_X_ASSUM_ST `sum` (C INTRO_TAC [`t`]); ASM_REWRITE_TAC[arith `abs(&0) = &0`]; ANTS_TAC; BY(REPEAT (FIRST_X_ASSUM MATCH_MP_TAC) THEN FIRST_X_ASSUM (unlist REWRITE_TAC)); ONCE_REWRITE_TAC[arith `sdiff = sfull - s3 <=> s3 = sfull - sdiff`]; DISCH_THEN SUBST1_TAC; DISCH_THEN SUBST1_TAC; FIRST_X_ASSUM_ST `sum` (C INTRO_TAC [`t`]); ANTS_TAC; BY(REPEAT (FIRST_X_ASSUM MATCH_MP_TAC) THEN FIRST_X_ASSUM (unlist REWRITE_TAC)); ASM_REWRITE_TAC[]; TYPIFY `sum ({i | i < k} DIFF {p1 MOD k, (p1 + 1) MOD k, (p1 + k - 1) MOD k}) (\i. rho_fun (norm (v i)) * azim (vec 0) (v i) (v (i + 1)) (v (i + k - 1))) = sum ({i | i < k} DIFF {p1 MOD k, (p1 + 1) MOD k, (p1 + k - 1) MOD k}) (\i. rho_fun (norm (f (v i) t)) * azim (vec 0) (f (v i) t) (f (v (i + 1)) t) (f (v (i + k - 1)) t))` ENOUGH_TO_SHOW_TAC; DISCH_THEN SUBST1_TAC; BY(REWRITE_TAC[arith `(a <= b) ==> a - u <= b - u`]); MATCH_MP_TAC SUM_EQ; REWRITE_TAC[IN_DIFF;IN_INSERT;NOT_IN_EMPTY;IN_ELIM_THM]; REPEAT WEAKER_STRIP_TAC; TYPIFY ` ~(p1 MOD k = x MOD k) /\ ~(p1 MOD k = (x + 1) MOD k) /\ ~(p1 MOD k = (x + k - 1) MOD k)` (C SUBGOAL_THEN ASSUME_TAC); TYPIFY `x MOD k = (x + 0) MOD k` (C SUBGOAL_THEN SUBST1_TAC); BY(REWRITE_TAC[arith `x + 0 = x`]); PROOF_BY_CONTR_TAC; INTRO_TAC solve_mod_k [`k`] THEN ASM_REWRITE_TAC[]; ONCE_REWRITE_TAC[TAUT `!a b. (a ==> b) <=> (~b ==> ~a)`]; DISCH_TAC; FIRST_X_ASSUM_ST `x+k-1` MP_TAC THEN REWRITE_TAC[] THEN REPEAT CONJ_TAC THEN FIRST_X_ASSUM MATCH_MP_TAC; GMATCH_SIMP_TAC MOD_0; ASM_REWRITE_TAC[MOD_MOD_REFL;MOD_MULT_ADD;arith `a + k - 0 = 1*k + a`]; GMATCH_SIMP_TAC MOD_MOD_REFL; BY(ASM_REWRITE_TAC[] THEN REPLICATE_TAC 2(FIRST_X_ASSUM MP_TAC) THEN MESON_TAC[MOD_LT]); TYPIFY `x MOD k = x` (C SUBGOAL_THEN SUBST1_TAC); BY(FIRST_X_ASSUM_ST `x < (k:num)` MP_TAC THEN MESON_TAC[MOD_LT]); DISCH_TAC; FIRST_X_ASSUM_ST `~` MP_TAC; ASM_REWRITE_TAC[]; DISJ2_TAC; DISJ2_TAC; TYPIFY `1 MOD k = 1` (C SUBGOAL_THEN SUBST1_TAC); BY(FIRST_X_ASSUM_ST `3 < k` MP_TAC THEN MESON_TAC[MOD_LT;arith `3 < k ==> 1 < k`]); MATCH_MP_TAC MOD_SHIFT; BY(FIRST_X_ASSUM_ST `~(k = 0)` MP_TAC THEN MESON_TAC[MOD_MOD_REFL]); TYPIFY `x MOD k = x` (C SUBGOAL_THEN SUBST1_TAC); BY(FIRST_X_ASSUM_ST `x < (k:num)` MP_TAC THEN MESON_TAC[MOD_LT]); DISCH_TAC; FIRST_X_ASSUM_ST `~` MP_TAC; ASM_REWRITE_TAC[]; DISJ2_TAC; DISJ1_TAC; TYPIFY `(k-1) MOD k = (k-1)` (C SUBGOAL_THEN SUBST1_TAC); BY(FIRST_X_ASSUM_ST `~(k=0)` MP_TAC THEN MESON_TAC[MOD_LT;arith `~(k=0) ==> k - 1 < k`]); TYPIFY `k - (k-1) = 1` (C SUBGOAL_THEN SUBST1_TAC); BY(FIRST_X_ASSUM_ST `~(k=0)` MP_TAC THEN ARITH_TAC); MATCH_MP_TAC MOD_SHIFT; BY(FIRST_X_ASSUM_ST `~(k = 0)` MP_TAC THEN MESON_TAC[MOD_MOD_REFL]); POP_ASSUM (fun t -> FIRST_X_ASSUM (MP_TAC o (C MATCH_MP t))); (DISCH_THEN (unlist REWRITE_TAC)); AP_THM_TAC; AP_TERM_TAC; AP_TERM_TAC; FIRST_X_ASSUM_ST `norm` (C INTRO_TAC [`t`]); ANTS_TAC; BY(REPEAT (FIRST_X_ASSUM MATCH_MP_TAC) THEN (FIRST_X_ASSUM_ST `abs` (unlist REWRITE_TAC))); TYPIFY `v x = v p1` ASM_CASES_TAC; BY(FIRST_X_ASSUM (unlist REWRITE_TAC) THEN MESON_TAC[]); POP_ASSUM (fun t -> FIRST_X_ASSUM (MP_TAC o (C MATCH_MP t))); BY(DISCH_THEN (unlist REWRITE_TAC)); COMMENT "back to root: relate sum to taum"; TYPIFY `!i. f (v i) (&0) = (v i)` (C SUBGOAL_THEN ASSUME_TAC); BY(REPEAT (FIRST_X_ASSUM_ST `IN` MP_TAC) THEN REPEAT (FIRST_X_ASSUM_ST `f w (&0) = w` MP_TAC) THEN MESON_TAC[]); TYPIFY `?t'. abs t' < e'''''' /\ ~(t' = &0)` (C SUBGOAL_THEN MP_TAC); BY(TYPIFY `e'''''' / &2` EXISTS_TAC THEN FIRST_X_ASSUM_ST `&0 < e''''''` MP_TAC THEN REAL_ARITH_TAC); REPEAT WEAKER_STRIP_TAC; REPLICATE_TAC 5 (FIRST_X_ASSUM (C INTRO_TAC [`t'`]) THEN ANTS_TAC THEN REPEAT (FIRST_X_ASSUM MATCH_MP_TAC) THEN ASM_REWRITE_TAC[]); REPEAT WEAKER_STRIP_TAC; FIRST_X_ASSUM MP_TAC; REWRITE_TAC[arith `~(x <= y) <=> y < x`]; TYPIFY_GOAL_THEN `!f. sum {p1 MOD k, (p1 + 1) MOD k, (p1 + k - 1) MOD k} f = f (p1 MOD k) + f ((p1 + 1) MOD k) + f ((p1+k-1) MOD k)` (unlist REWRITE_TAC); GEN_TAC; MATCH_MP_TAC Geomdetail.SUM_DIS3; TYPIFY `p1 MOD k = (p1 + 0) MOD k` (C SUBGOAL_THEN SUBST1_TAC); BY(REWRITE_TAC[arith `p1 + 0 = p1`]); REWRITE_TAC[DE_MORGAN_THM]; REPEAT (GMATCH_SIMP_TAC Ocbicby.MOD_EQ_MOD_SHIFT); REPEAT (GMATCH_SIMP_TAC MOD_LT); BY(FIRST_X_ASSUM_ST `3 < k` MP_TAC THEN ARITH_TAC); REWRITE_TAC[Appendix.rho_rho_fun]; FIRST_X_ASSUM_ST `DIFF` kill; REPEAT (FIRST_X_ASSUM_ST `sum` kill); FIRST_X_ASSUM_ST `MOD` (MP_TAC o GSYM) THEN REPEAT WEAKER_STRIP_TAC; POP_ASSUM (fun t -> FIRST_X_ASSUM (MP_TAC o (C MATCH_MP t))); DISCH_TAC; FIRST_ASSUM (C INTRO_TAC [`&0`]); FIRST_X_ASSUM (C INTRO_TAC [`t'`]); FIRST_X_ASSUM MP_TAC THEN ASM_REWRITE_TAC[] THEN DISCH_TAC; DISCH_THEN (unlist REWRITE_TAC); DISCH_THEN (unlist REWRITE_TAC); POP_ASSUM (fun t -> FIRST_X_ASSUM (MP_TAC o (C MATCH_MP t))); DISCH_TAC; FIRST_ASSUM (C INTRO_TAC [`&0`]); FIRST_X_ASSUM (C INTRO_TAC [`t'`]); ASM_REWRITE_TAC[]; DISCH_THEN (unlist REWRITE_TAC); DISCH_THEN (unlist REWRITE_TAC); TYPIFY `p1 MOD k = (p1 MOD k) MOD k` (C SUBGOAL_THEN ASSUME_TAC); BY(FIRST_X_ASSUM_ST `~(k=0)` MP_TAC THEN MESON_TAC[MOD_MOD_REFL]); POP_ASSUM (fun t -> FIRST_X_ASSUM (MP_TAC o (C MATCH_MP t))); ASM_REWRITE_TAC[]; DISCH_TAC; FIRST_ASSUM (C INTRO_TAC [`&0`]); FIRST_X_ASSUM (C INTRO_TAC [`t'`]); ASM_REWRITE_TAC[]; DISCH_THEN (unlist REWRITE_TAC); DISCH_THEN (unlist REWRITE_TAC); FIRST_X_ASSUM_ST `azim` (C INTRO_TAC [`t'`]); ASM_REWRITE_TAC[]; DISCH_THEN (unlist REWRITE_TAC); MATCH_MP_TAC (arith `r1 * a1 + r2 * (a2) + r3 * (b2) - (pi + sol0) < r1' * a1' + r2 * (a2') + r3 * (b3') - (pi + sol0) ==> r1 * a1 + r2 * (a + a2) + r3 * (b2 + b) < r1' * a1' + r2 * (a + a2') + r3 * (b3' + b)`); REPEAT (GMATCH_SIMP_TAC (GSYM tau3_azim)); REPEAT (GMATCH_SIMP_TAC tau3_taum_nonplanar); FIRST_X_ASSUM_ST `taum` MP_TAC; DISCH_TAC; REPEAT (FIRST_X_ASSUM_ST `coplanar` MP_TAC) THEN REPEAT DISCH_TAC; REPEAT (FIRST_X_ASSUM_ST `azim a b c d <= pi` MP_TAC) THEN REPEAT DISCH_TAC; REPEAT (FIRST_X_ASSUM_ST `azim a b c d < pi` MP_TAC) THEN REPEAT DISCH_TAC; TYPIFY `abs t' < e1 /\ abs t' < e2` (C SUBGOAL_THEN ASSUME_TAC); BY(CONJ_TAC THEN REPEAT (FIRST_X_ASSUM MATCH_MP_TAC) THEN ASM_REWRITE_TAC[]); REPEAT (FIRST_X_ASSUM_ST `&0 < e2` MP_TAC) THEN REPEAT DISCH_TAC; TYPIFY_GOAL_THEN `azim (vec 0) (v p1) (v (p1 + 1)) (v (p1 + k - 1)) <= pi /\ azim (vec 0) (f (v p1) t') (v (p1 + 1)) (v (p1 + k - 1)) <= pi` (unlist REWRITE_TAC); BY(REPLICATE_TAC 25 (FIRST_X_ASSUM MP_TAC) THEN MESON_TAC[arith `abs(&0) = &0`;arith `x < y ==> x <= y`]); REPEAT (FIRST_X_ASSUM_ST `azim` kill); ASM_REWRITE_TAC[]; TYPIFY_GOAL_THEN `~coplanar {vec 0, f (v p1) t', v p0, v p2} ` (unlist REWRITE_TAC); TYPIFY `{vec 0,f(v p1) t',v p0,v p2} = {vec 0,f (v p1) t',v (p1+k-1),v(p1+1)}` (C SUBGOAL_THEN SUBST1_TAC); BY(FIRST_X_ASSUM_ST `{a,b}={c,d}` MP_TAC THEN SET_TAC[]); FIRST_X_ASSUM MATCH_MP_TAC; BY(REPEAT (FIRST_X_ASSUM MATCH_MP_TAC) THEN ASM_REWRITE_TAC[]); TYPIFY_GOAL_THEN `!w. taum (norm w) (norm (v (p1 + 1))) (norm (v (p1 + k - 1))) (dist (v (p1 + 1),v (p1 + k - 1))) (dist (w,v (p1 + k - 1))) (dist (w,v (p1 + 1))) = taum (norm (v p0)) (norm (v p2)) (norm (w)) (dist(w,v p2)) (dist (v p0,w)) (dist (v p0,v p2))` (unlist REWRITE_TAC); GEN_TAC; FIRST_X_ASSUM_ST `{a,b}={c,d}` (MP_TAC) THEN REWRITE_TAC[Collect_geom.PAIR_EQ_EXPAND] THEN DISCH_THEN DISJ_CASES_TAC; ASM_REWRITE_TAC[DIST_SYM]; BY(MESON_TAC[Terminal.taum_sym]); ASM_REWRITE_TAC[DIST_SYM]; BY(MESON_TAC[Terminal.taum_sym]); FIRST_X_ASSUM_ST `norm a = norm b` (C INTRO_TAC [`t'`]); ANTS_TAC; BY(REPEAT (FIRST_X_ASSUM MATCH_MP_TAC) THEN ASM_REWRITE_TAC[]); REWRITE_TAC[DIST_SYM] THEN (DISCH_THEN (unlist REWRITE_TAC)); FIRST_X_ASSUM MATCH_MP_TAC; CONJ_TAC; REWRITE_TAC[arith `x - y = x + -- y`]; FIRST_X_ASSUM MATCH_MP_TAC; BY(ASM_REWRITE_TAC[arith `abs(-- abs t') = abs t'`]); ASM_REWRITE_TAC[]; BY(FIRST_X_ASSUM_ST `~(t' = &0)` MP_TAC THEN REAL_ARITH_TAC) ]);; (* }}} *)
let CUXVZOZ = 
prove_by_refinement( `main_nonlinear_terminal_v11 ==> (!s FF k p1 v. FF = IMAGE (\i. (v i,v (SUC i))) (:num) /\ is_scs_v39 s /\ k = scs_k_v39 s /\ 3 < k /\ MMs_v39 s v /\ scs_basic_v39 s /\ scs_generic v /\ &3 <= dist(v (p1+k-1),v (p1+1)) /\ (!i j. scs_diag k i j /\ ~(psort k (i, j) = psort k ((p1+k-1),(p1+1))) ==> scs_a_v39 s i j < dist(v i,v j)) /\ (!i j. scs_diag k i j ==> &4 * h0 < scs_b_v39 s i j) /\ interior_angle1 (vec 0) FF (v p1) < pi /\ (pi/ &2 < interior_angle1 (vec 0) FF (v p1) \/ interior_angle1 (vec 0) FF (v (p1+1)) < pi) /\ scs_a_v39 s p1 (p1+1) = &2 /\ scs_b_v39 s p1 (p1+1) <= &2 * h0 /\ &2 <= dist(v (p1+k-1),v p1) /\ dist(v (p1+k-1), v p1) <= cstab ==> dist(v p1,v (p1+1)) = &2)`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; INTRO_TAC (UNDISCH general_482_deformation) [`s`;`FF`;`k`;`p1 + k - 1`;`p1`;`p1+1`;`v`]; DISCH_THEN MATCH_MP_TAC; ASM_REWRITE_TAC[]; BY(SET_TAC[]) ]);;
(* }}} *)
let CJBDXXN = 
prove_by_refinement( `main_nonlinear_terminal_v11 ==> (!s FF k p1 v. FF = IMAGE (\i. (v i,v (SUC i))) (:num) /\ is_scs_v39 s /\ k = scs_k_v39 s /\ 3 < k /\ MMs_v39 s v /\ scs_basic_v39 s /\ scs_generic v /\ &3 <= dist(v (p1+1),v (p1+k-1)) /\ (!i j. scs_diag k i j /\ ~(psort k (i, j) = psort k ((p1+1),(p1+k-1))) ==> scs_a_v39 s i j < dist(v i,v j)) /\ (!i j. scs_diag k i j ==> &4 * h0 < scs_b_v39 s i j) /\ interior_angle1 (vec 0) FF (v p1) < pi /\ (pi/ &2 < interior_angle1 (vec 0) FF (v p1) \/ interior_angle1 (vec 0) FF (v (p1+k-1)) < pi) /\ scs_a_v39 s p1 (p1+k-1) = &2 /\ scs_b_v39 s p1 (p1+k-1) <= &2 * h0 /\ &2 <= dist(v (p1+1),v p1) /\ dist(v (p1+1), v p1) <= cstab ==> dist(v p1,v (p1+k-1)) = &2)`,
(* {{{ proof *) [ REPEAT WEAKER_STRIP_TAC; INTRO_TAC (UNDISCH general_482_deformation) [`s`;`FF`;`k`;`p1 + 1`;`p1`;`p1+k-1`;`v`]; DISCH_THEN MATCH_MP_TAC; ASM_REWRITE_TAC[]; ]);;
(* }}} *) end;;