(* ============================================================= *)
(* ============================================================= *)
(* ============================================================= *)
(* =============================================================
#use "/home/user1/flyspeck/working/boot.hl";;
needs "/home/user1/flyspeck/working/local_lemmas1.hl";;
   ============================================================= *)

(*

let build_sequence = 
  ["general/sphere.hl";
   "leg/geomdetail.hl";
   "leg/affprops.hl";
   "leg/cayleyR_def.hl";
   "leg/enclosed_def.hl";
   "leg/collect_geom.hl";
(* flyspeck_needs  "leg/collect_geom2.hl";*) (* slow and rarely needed *)

  "jordan/refinement.hl"; 
  "jordan/lib_ext.hl"; 
  "jordan/hash_term.hl"; 
  "jordan/parse_ext_override_interface.hl"; 
  "jordan/goal_printer.hl"; 
  "jordan/real_ext.hl";  
  "jordan/tactics_jordan.hl"; 
  "jordan/num_ext_nabs.hl";   
  "jordan/taylor_atn.hl";
  "jordan/float.hl"; 
  "jordan/flyspeck_constants.hl";
  "jordan/misc_defs_and_lemmas.hl"; 

   "nonlinear/ineqdata3q1h.hl";
   "nonlinear/ineq.hl";
   "nonlinear/parse_ineq.hl";
   "nonlinear/vukhacky_tactics.hl" ;

   "trigonometry/trig1.hl";
   "trigonometry/trig2.hl";
   "nonlinear/compute_2158872499.hl"; (* need trig1.hl trig2.hl *)

   "trigonometry/trigonometry.hl";
   "trigonometry/delta_x.hl";
   "trigonometry/euler_complement.hl";
   "trigonometry/euler_multivariate.hl";
   "trigonometry/euler_main_theorem.hl";

   "volume/vol1.hl";
   "hypermap/hypermap.hl";  (*  svn 1898 not compatible with other files *)

   "fan/fan_defs.hl";
   "fan/introduction.hl";
   "fan/topology.hl";
   "fan/fan_misc.hl";
   "fan/planarity.hl";   (* svn 1717 -- 1792 has errors. Build fails. *)
   "fan/polyhedron.hl";
   "fan/HypermapAndFan.hl";
   "fan/Conforming.hl";  

   "packing/pack1.hl"; 
   "packing/pack2.hl";
   "packing/pack_defs.hl";
   "packing/pack_concl.hl";
   "packing/pack3.hl";  (* needs pack_defs.hl *)
   "packing/Rogers.hl";

   "packing/TARJJUW.hl"; (* weakly_saturated def. modified in svn 1912.  *)
   "packing/TIWWFYQ.hl";
   "packing/RHWVGNP.hl";
   "packing/DRUQUFE.hl";
   "packing/BBDTRGC_def.hl";
   "packing/NOPZSEH_def.hl";
   "packing/JNRJQSM_def.hl";
   "packing/KHEJKCI.hl";
   "packing/IDBEZAL.hl";
   "packing/JJGTQMN_def.hl";
   "packing/PHZVPFY_def.hl";

   (* ky's stuff *)
   "packing/beta_pair_thm.hl";
   "packing/lemma_negligible.hl";


 (*   "local/local_defs.hl"; *)
   "local/WRGCVDR_CIZMRRH.hl";
   "local/LVDUCXU.hl";
   "local/LDURDPN.hl";
   "local/LOCAL_LEMMAS.hl"];;

(* 1897 has an error Unbound value ivs_rho_node1*)

let build_all() =
  (* (needs "Multivariate/flyspeck.ml"; *)
   map flyspeck_needs build_sequence;;
build_all();;

*)

(* ============================================================== *)
(* ============================================================== *)
(* ============================================================== *)

module Local_lemmas1 = struct

open Ldurdpn;;
open Lvducxu;;
open Sphere;;
open Trigonometry1;;
open Trigonometry2;;
open Hypermap;;
open Fan;;
open Prove_by_refinement;;
open Wrgcvdr_cizmrrh;;
open Aff_sgn_tac;;
open Fan_misc;;
open Fan_defs;;
open Planarity;;
open Topology;;
open Local_lemmas;;


(* deprecated 2013-02-22:

let spherical_map = new_definition ` spherical_map (e1,e2,e3) (r,theta, phi) = 
(r * cos theta * sin phi) % e1 +
(r * sin theta * sin phi ) % e2 + (r * cos phi) % e3 `;;

` spherical_coor v0 (e1,e2,e3) v = (dist (v0,v), azim v0 (v0 + e3) (v0 + e1) v, arcV v0 (v0 + e3) v)`;;

*)

let lunar_deform = new_definition ` lunar_deform (e1,e2,e3) t x = 
(norm x * cos (( &1 - t) * (azim (vec 0) e3 e1 x )) * sin (arcV (vec 0) e3 x)) % e1 +
(norm x * sin ( ( &1 - t ) * (azim (vec 0) e3 e1 x )) * sin (arcV (vec 0) e3 x)) % e2 +
(norm x * cos (arcV (vec 0) e3 x )) % e3`;;
let normize = new_definition` normize (v:real^N) = (&1 / norm v) % v`;;
let deformation = new_definition 
` deformation ff V (a,b) <=> (&0) IN real_interval (a,b) /\
(! v r. v IN V /\ r IN real_interval (a,b) ==> (ff v) continuous atreal r) /\
(!v. v IN V ==> ff v (&0) = v )`;;
let localization = new_definition `localization (V, E) FF = (v_prime V FF, e_prime E FF) `;;
(* deprecated 2013-02-22: let v_slice = new_definition ` v_slice f (v,w) = { ITER i f v | ! j. j < i ==> ~( ITER j f v = w ) }`;; let e_slice = new_definition ` e_slice f (v,w) = {w,v} INSERT { {ITER i f v, ITER (i + 1) f v} | ! j. j < i + 1 ==> ~( ITER j f v = w)} `;; let f_slice = new_definition ` f_slice f (v,w) = (w,v) INSERT { (ITER i f v, ITER (i + 1) f v) | ! j. j < i + 1 ==> ~ (ITER j f v = w)} `;; *)
let LUNAR_DEFORM_PRESERVE_NORM = 
prove(`orthonormal e1 e2 e3 ==> norm (lunar_deform (e1,e2,e3) t x) = norm x `,
SIMP_TAC[NORM_EQ; lunar_deform; orthonormal; DOT_RADD; DOT_LADD; DOT_RMUL; DOT_LMUL; DOT_SYM; REAL_MUL_RZERO; Collect_geom.ZERO_NEUTRAL] THEN ABBREV_TAC` aa = ((&1 - t) * azim (vec 0) e3 e1 x) ` THEN ABBREV_TAC` bb = arcV (vec 0) e3 (x:real^3)` THEN REWRITE_TAC[ REAL_ARITH` (norm x * cos aa * sin bb) * (norm x * cos aa * sin bb) * &1 + (norm x * sin aa * sin bb) * (norm x * sin aa * sin bb) * &1 + (norm x * cos bb) * (norm x * cos bb) * &1 = (norm x pow 2 ) * (sin bb pow 2 * ( sin aa pow 2 + cos aa pow 2 ) + cos bb pow 2 )`] THEN REWRITE_TAC[SIN_CIRCLE; REAL_MUL_RID; DOT_SQUARE_NORM]);;
let ACR_REFL = 
prove(` ~( u = v ) ==> arcV u v v = &0 `,
REWRITE_TAC[arcV; DOT_SQUARE_NORM; GSYM POW_2] THEN NHANH (NORM_ARITH` ~( u = v ) ==> ~(norm (v - u) = &0)`) THEN SIMP_TAC[REAL_FIELD` ~(x = &0) ==> x pow 2 / x pow 2 = &1 `; ACS_1]);;
let ARC_OPPOSITE = 
prove(` ~(u = v) ==> arcV u v (&2 % u - v ) = pi `,
REWRITE_TAC[arcV; VECTOR_ARITH` &2 % u - v - u = -- (v - u)`; DOT_RNEG; NORM_NEG; DOT_SQUARE_NORM; GSYM POW_2] THEN NHANH (NORM_ARITH` ~(u = v) ==> ~( norm (v - u)= &0 )`) THEN SIMP_TAC[ACS_NEG_1; REAL_FIELD` ~( x = &0 ) ==> -- ( x pow 2) / ( x pow 2 ) = -- &1 `]);;
let ARCV_EQ_0 = 
prove(` ~(u = v) /\ &0 < t ==> arcV u v (u + t % (v - u)) = &0`,
NHANH ACR_REFL THEN ONCE_REWRITE_TAC[Trigonometry2.ARCV_VEC0_FORM] THEN SIMP_TAC[VECTOR_ARITH`(a + b) - a:real^N = b`; GSYM Trigonometry2.WHEN_K_POS_ARCV_STABLE]);;
let ARCV_EQ_0_ORIGIN = 
prove(`~( u = vec 0) /\ &0 < t ==> arcV (vec 0) u (t % u) = &0`,
ONCE_REWRITE_TAC[EQ_SYM_EQ] THEN NHANH ARCV_EQ_0 THEN SIMP_TAC[VECTOR_ARITH` vec 0 + t % (u - vec 0) = t % u`]);;
let ARCV_PI_OPPOSITE = 
prove(`~(u = v) /\ t < &0 ==> arcV u v (u + t % (v - u)) = pi`,
NHANH ARC_OPPOSITE THEN ONCE_REWRITE_TAC[Trigonometry2.ARCV_VEC0_FORM] THEN SIMP_TAC[VECTOR_ARITH`(a + b) - a:real^N = b`; VECTOR_ARITH` &2 % u - v - u = -- (v - u)`] THEN ONCE_REWRITE_TAC[VECTOR_ARITH` a % x = (-- a) % ( -- x)`] THEN SIMP_TAC[GSYM Trigonometry2.WHEN_K_POS_ARCV_STABLE; REAL_ARITH` t < &0 <=> &0 < -- t `]);;
let DOT_0_ARCV = 
prove(` (v - u) dot (w - u) = &0 ==> arcV u v w = pi / &2 `,
SIMP_TAC[arcV; Collect_geom.REAL_DIV_LZERO; ACS_0]);;
let ARCV_DEGENERATE = 
prove(` arcV u u v = pi / &2 /\ arcV u v u = pi / &2 `,
CONJ_TAC THENL [MATCH_MP_TAC DOT_0_ARCV THEN REWRITE_TAC[VECTOR_SUB_REFL; DOT_LZERO]; MATCH_MP_TAC DOT_0_ARCV THEN REWRITE_TAC[VECTOR_SUB_REFL; DOT_RZERO]]);;
let ARCV_DIRECTIONS = 
prove(`~( u = v) ==> (arcV u v (u + t % (v - u)) = &0 <=> &0 < t) /\ (arcV u v (u + t % (v - u)) = pi <=> t < &0)`,
ASM_CASES_TAC` t = &0` THENL [ ASM_REWRITE_TAC[REAL_LT_REFL; VECTOR_MUL_LZERO; VECTOR_ADD_RID; ARCV_DEGENERATE] THEN STRIP_TAC THEN MP_TAC PI_NZ THEN REAL_ARITH_TAC; DOWN THEN REWRITE_TAC[REAL_ARITH` ~(a = &0) <=> &0 < a \/ a < &0`] THEN MESON_TAC[ARCV_EQ_0; ARCV_PI_OPPOSITE; PI_NZ]]);;
let ARCV_ORI_DIRECTIONS = 
prove(` ~( v = vec 0) ==> (arcV (vec 0) v (t % v) = &0 <=> &0 < t) /\ (arcV (vec 0) v (t % v) = pi <=> t < &0)`,
ONCE_REWRITE_TAC[EQ_SYM_EQ] THEN NHANH ARCV_DIRECTIONS THEN SIMP_TAC[EQ_SYM_EQ; VECTOR_ADD_LID; VECTOR_SUB_RZERO]);;
let REAL_NEG_MUL_EQ = 
prove(` a < &0 ==> ( a * x < &0 <=> &0 < x ) /\ (&0 < a * x <=> x < &0) `,
REWRITE_TAC[REAL_ARITH` a < &0 <=> &0 < -- a `; REAL_ARITH` -- ( a * x) = -- a * x `] THEN SIMP_TAC[REAL_LT_MUL_EQ] THEN ONCE_REWRITE_TAC[REAL_ARITH` a * b = -- a * -- b `] THEN SIMP_TAC[REAL_LT_MUL_EQ]);;
let NOT_EQ_0 = REAL_ARITH` ~( x = &0 ) <=> &0 < x \/ x < &0 `;;
let SIN_ARCV_EQ_0 = 
prove(` ~( u = v) /\ ~( t = &0) ==> sin (arcV u v (u + t % (v - u))) = &0`,
REWRITE_TAC[NOT_EQ_0] THEN STRIP_TAC THENL [ ASM_SIMP_TAC[ARCV_EQ_0; SIN_0]; ASM_SIMP_TAC[ARCV_PI_OPPOSITE; SIN_PI]]);;
let COLLINEAR_SIN_ARCV_0 = 
prove(` collinear {u,v,x} /\ ~(u = x) /\ ~(u = v) ==> sin (arcV u v (x:real^N)) = &0`,
REWRITE_TAC[Local_lemmas.collinear_fan22; AFF2; IN_ELIM_THM] THEN STRIP_TAC THENL [ ASM_REWRITE_TAC[] THEN UNDISCH_TAC` x = t % u + (&1 - t) % (v:real^N)` THEN ASM_CASES_TAC` t = &1 ` THENL [ ASM_REWRITE_TAC[REAL_SUB_REFL; VECTOR_ADD_RID; VECTOR_MUL_LZERO; VECTOR_MUL_LID]; REWRITE_TAC[VECTOR_ARITH` t % u + (&1 - t) % v = u + (&1 - t) % ( v - u)`] THEN STRIP_TAC THEN MATCH_MP_TAC SIN_ARCV_EQ_0 THEN ASM_REWRITE_TAC[REAL_ARITH` a - b = &0 <=> b = a`]]; DOWN THEN ASM_REWRITE_TAC[]]);;
let COLL_AFF_GT_2_1 = 
prove(`!x v w:real^N. ~collinear {x, v, w} ==> aff_gt {x, v} {w} = {y | ?t1 t2 t3. &0 < t3 /\ t1 + t2 + t3 = &1 /\ y = t1 % x + t2 % v + t3 % w}`,
NHANH Fan.th3a THEN SIMP_TAC[AFF_GT_2_1]);;
let COLL_EQ_DEPENDENT = 
prove_by_refinement ( ` collinear {vec 0, x, y:real^N} <=> ? tx ty. ~( tx = &0 /\ ty = &0) /\ tx % x + ty % y = vec 0`,
[EQ_TAC; REWRITE_TAC[COLLINEAR_LEMMA_ALT]; STRIP_TAC; EXISTS_TAC` &1 `; EXISTS_TAC` &0`; ASM_REWRITE_TAC[VECTOR_MUL_LZERO; VECTOR_MUL_RZERO; VECTOR_ADD_LID]; REAL_ARITH_TAC; EXISTS_TAC` -- (c:real)`; EXISTS_TAC` &1 `; ASM_REWRITE_TAC[VECTOR_MUL_LID; REAL_ARITH` ~( &1 = &0)`]; VECTOR_ARITH_TAC; SPEC_TAC (`y:real^N`,`y:real^N`); SPEC_TAC (`x:real^N`,`x:real^N`); MATCH_MP_TAC ( MESON[]` (!x y tx ty. P x y tx ty ==> P y x ty tx) /\ (!x y. Q x y ==> Q y x) /\ (!x y tx ty. ~(ty = &0) /\ P x y tx ty ==> Q x y) ==> ! x y. (?tx ty. ~(tx = &0 /\ ty = &0) /\ P x y tx ty) ==> Q x y `); SIMP_TAC[VECTOR_ADD_SYM; INSERT_COMM]; REWRITE_TAC[SIMP_RULE[INSERT_COMM] COLLINEAR_LEMMA_ALT]; REPEAT STRIP_TAC; DISJ2_TAC; EXISTS_TAC` ( -- tx ) / ty `; DOWN; NHANH_PAT`\x. x ==> y` (MESON[]` x = y ==> &1 / ty % x = &1 / ty % y`); REWRITE_TAC[VECTOR_ADD_LDISTRIB; VECTOR_MUL_ASSOC; VECTOR_MUL_RZERO]; ASM_SIMP_TAC[REAL_FIELD` ~(x = &0) ==> &1 / x * x = &1 `; VECTOR_MUL_LID]; SIMP_TAC[VECTOR_ARITH` a + b = vec 0 <=> b = -- a `]; STRIP_TAC; VECTOR_ARITH_TAC]);;
let NOT_COLL_ORTHONORMAL = 
prove_by_refinement ( ` ~ collinear {vec 0, x, y:real^N} ==> ?u. u IN aff {vec 0, x, y} /\ norm u = &1 /\ x dot u = &0 `,
[NHANH Fan.th3b; REWRITE_TAC[COLL_EQ_DEPENDENT; NOT_EXISTS_THM; DE_MORGAN_THM]; STRIP_TAC; EXISTS_TAC` normize ((x dot y) % x + -- (x dot x) % (y:real^N))`; REWRITE_TAC[aff; AFFINE_HULL_3; IN_ELIM_THM]; CONJ_TAC; REWRITE_TAC[normize; Local_lemmas.VECTOR_ADD_LDISTRIB1; VECTOR_MUL_RZERO; VECTOR_ADD_LID]; MESON_TAC[REAL_ARITH`&1 - a + a = &1 `]; REWRITE_TAC[normize; GSYM Trigonometry2.NOT_VEC0_UNITABLE]; CONJ_TAC; SUBGOAL_THEN` ~(x dot (x:real^N) = &0)` MP_TAC; ASM_REWRITE_TAC[DOT_EQ_0]; ONCE_REWRITE_TAC[REAL_ARITH` a = &0 <=> -- a = &0`]; ASM_MESON_TAC[]; REWRITE_TAC[DOT_RADD; DOT_RMUL; REAL_ARITH` a * b + -- b * a = &0`; REAL_MUL_RZERO]]);;
let NORM1_NOT_0 = 
prove(` norm x = &1 ==> ~( x = vec 0) `,
NHANH (REAL_ARITH` x = &1 ==> &0 < x `) THEN SIMP_TAC[NORM_POS_LT]);;
let ARCV_DETER_DIRECTION = 
prove_by_refinement ( ` (x:real^N) = tu % u + ty % y /\ &0 < ty /\ ~( collinear {vec 0, u, y}) /\ norm x = &1 /\ norm y = &1 /\ arcV (vec 0) u x = arcV (vec 0) u y ==> x = y`,
[NHANH NOT_COLL_ORTHONORMAL; NHANH Fan.th3b; NHANH NORM1_NOT_0; STRIP_TAC; MP_TAC (ISPECL [`u' :real^N`;` u:real^N` ] Rogers.IN_PLANE_NOT_COLLINEAR); ANTS_TAC; ASM_REWRITE_TAC[]; STRIP_TAC; UNDISCH_TAC` u' IN aff {vec 0, u, y:real^N}`; REWRITE_TAC[aff; AFFINE_HULL_3; IN_ELIM_THM]; STRIP_TAC; ASM_CASES_TAC` w = &0`; UNDISCH_TAC` u dot (u':real^N) = &0`; ASM_REWRITE_TAC[VECTOR_MUL_RZERO; VECTOR_MUL_LZERO; VECTOR_ADD_LID; VECTOR_ADD_RID; DOT_RMUL; REAL_ENTIRE; DOT_EQ_0]; DISCH_THEN SUBST_ALL_TAC; UNDISCH_TAC` u' = u'' % vec 0 + &0 % u + w % (y:real^N)`; ASM_REWRITE_TAC[VECTOR_MUL_RZERO; VECTOR_MUL_LZERO; VECTOR_ADD_LID; VECTOR_ADD_RID]; UNDISCH_TAC`u' = u'' % vec 0 + v % u + w % (y:real^N) `; REWRITE_TAC[VECTOR_MUL_RZERO; VECTOR_ADD_LID]; ONCE_REWRITE_TAC[VECTOR_ARITH` a = u % x + (y:real^N) <=> y = ( -- u) % x + a`]; ABBREV_TAC` tt <=> x = (y:real^N)`; ASM_SIMP_TAC[Ldurdpn.VECTOR_SCALE_CHANGE; VECTOR_ADD_LDISTRIB; VECTOR_MUL_ASSOC]; STRIP_TAC; UNDISCH_TAC` x = tu % u + ty % (y:real^N)`; ASM_SIMP_TAC[VECTOR_ADD_LDISTRIB; VECTOR_MUL_ASSOC; VECTOR_ARITH` a % x + b % x + c = (a + b) % x + c`]; ABBREV_TAC` x1 = tu + ty * &1 / w * --v `; ABBREV_TAC` x2 = ty * &1 / w `; STRIP_TAC; UNDISCH_TAC` arcV (vec 0) u x = arcV (vec 0) u (y:real^N)`; NHANH (MESON[]` a = b ==> cos a = cos b `); SWITCH_TAC` ~(y:real^N = vec 0)`; ASSUME_TAC2 (ISPEC`x:real^N` (GEN_ALL NORM1_NOT_0)); SWITCH_TAC` ~(x:real^N = vec 0)`; SWITCH_TAC` x = x1 % u + x2 % (u':real^N)`; SWITCH_TAC` (y:real^N) = (&1 / w * --v) % u + &1 / w % u'`; ASM_SIMP_TAC[Trigonometry2.NOT_EQ_IMPCOS_ARC; VECTOR_SUB_RZERO; REAL_MUL_RID]; SUBGOAL_THEN` &0 < norm (u:real^N)` MP_TAC; ASM_REWRITE_TAC[NORM_POS_LT]; SIMP_TAC[REAL_FIELD` &0 < x ==> (a / x = b / x <=> a = b )`]; EXPAND_TAC "x";
EXPAND_TAC "y"; REWRITE_TAC[DOT_RADD; DOT_RMUL]; ASM_REWRITE_TAC[REAL_MUL_RZERO; REAL_ADD_RID]; SIMP_TAC[NORM_POS_LT; GSYM DOT_EQ_0; REAL_EQ_MUL_RCANCEL]; REPEAT STRIP_TAC; SUBGOAL_THEN` x dot (x:real^N) = y dot (y:real^N)` MP_TAC; ASM_REWRITE_TAC[DOT_SQUARE_NORM]; EXPAND_TAC "x"; EXPAND_TAC "y"; REWRITE_TAC[DOT_LADD; DOT_RADD; DOT_LMUL; DOT_RMUL]; ASM_REWRITE_TAC[DOT_SYM; REAL_MUL_RZERO; REAL_ADD_LID; REAL_ADD_RID; REAL_ARITH` a + b = a + c <=> b = c`]; ASM_REWRITE_TAC[REAL_EQ_MUL_RCANCEL; REAL_RING`a * b * c = (a*b)*c`; DOT_EQ_0]; REWRITE_TAC[REAL_ARITH` a * a = b * b <=> (a - b) * ( a + b ) = &0`; REAL_ENTIRE; REAL_SUB_0]; STRIP_TAC; EXPAND_TAC "tt"; EXPAND_TAC "x"; EXPAND_TAC "y"; REPLICATE_TAC 2 (FIRST_X_ASSUM SUBST1_TAC); REWRITE_TAC[]; DOWN; EXPAND_TAC "x2"; REWRITE_TAC[REAL_ARITH` a * x + x = ( a + &1) * x `; REAL_ENTIRE]; ASM_SIMP_TAC[REAL_ARITH` &0 < a ==> ~( a + &1 = &0) `; REAL_FIELD` ~( x = &0) ==> ~( &1 / x = &0) `]]);; let NORM_NORMIZE = REWRITE_RULE[GSYM normize] Trigonometry2.NOT_VEC0_UNITABLE;;
let ARCV_EQ_IMP_NORMIZE = 
prove_by_refinement ( ` (x:real^N) IN aff_gt {vec 0, u} {y} /\ ~ collinear {vec 0, u, y} /\ arcV (vec 0) u x = arcV (vec 0) u y ==> normize x = normize y `,
[NHANH COLL_AFF_GT_2_1; STRIP_TAC; UNDISCH_TAC` x IN aff_gt {vec 0, u} {y:real^N} `; ASM_REWRITE_TAC[IN_ELIM_THM; VECTOR_MUL_RZERO; VECTOR_ADD_LID]; NHANH_PAT`\x. x ==> y` (MESON[]` x = y ==> (&1 /norm x) % x = (&1 / norm x) % y `); STRIP_TAC; MP_TAC (ISPECL [`&1 `;` &1 / norm (y:real^N)`;`u:real^N`;` y:real^N`] COLLINEAR_SCALE_ALL); SUBGOAL_THEN` &0 < norm (y:real^N) /\ &0 < norm (x:real^N)` ASSUME_TAC; REWRITE_TAC[NORM_POS_LT]; UNDISCH_TAC` ~ collinear {vec 0, u, y:real^N}`; NHANH Trigonometry2.NOT_COLLINEAR_IMP_2_UNEQUAL; SIMP_TAC[]; REPEAT STRIP_TAC; UNDISCH_TAC` x = t2 % u + t3 % (y:real^N)`; ASM_REWRITE_TAC[]; ASSUME_TAC2 (REAL_ARITH` &0 < t3 ==> ~( t3 = &0) `); ASM_MESON_TAC[COLL_EQ_DEPENDENT]; ANTS_TAC; DOWN; CONV_TAC REAL_FIELD; SUBGOAL_THEN `&0 < &1 / norm (x:real^N) * t3 ` MP_TAC; REWRITE_TAC[REAL_ARITH` &1 / a * b = b / a `]; MATCH_MP_TAC REAL_LT_DIV; ASM_REWRITE_TAC[]; REWRITE_TAC[VECTOR_MUL_LID]; STRIP_TAC; DISCH_THEN (ASSUME_TAC o SYM); DOWN THEN DOWN THEN DOWN; ONCE_REWRITE_TAC[Collect_geom.POS_EQ_INV_POS]; NHANH (ISPECL [`u:real^N`;` &1 / norm (v:real^N)`;`v:real^N`] (GEN_ALL Trigonometry2.WHEN_K_POS_ARCV_STABLE)); REWRITE_TAC[GSYM Collect_geom.POS_EQ_INV_POS]; DOWN; REWRITE_TAC[NORM_POS_LT; Trigonometry2.NOT_VEC0_UNITABLE; VECTOR_ADD_LDISTRIB; VECTOR_MUL_ASSOC]; REPEAT STRIP_TAC; REWRITE_TAC[normize]; MATCH_MP_TAC (GEN_ALL ARCV_DETER_DIRECTION); EXISTS_TAC` (&1 / norm (x:real^N) * t2)`; EXISTS_TAC` (&1 / norm (x:real^N) * t3) * (norm (y:real^N)) `; EXISTS_TAC` u:real^N`; FIRST_X_ASSUM (SUBST1_TAC o SYM); ABBREV_TAC` nx = &1 / norm x % (x:real^N)`; ABBREV_TAC` ny = &1 / norm y % (y:real^N)`; SWITCH_TAC` x = t2 % u + t3 % (y:real^N)`; SWITCH_TAC` nx = (&1 / norm (x:real^N) * t2) % u + (&1 / norm x * t3) % (y:real^N)`; ASM_REWRITE_TAC[]; CONJ_TAC; EXPAND_TAC "ny";
REWRITE_TAC[VECTOR_MUL_ASSOC; REAL_ARITH` (a*b)*c = a*b*c`]; SUBGOAL_THEN` norm (y:real^N) * &1 / norm y = &1 ` SUBST1_TAC; MATCH_MP_TAC (REAL_FIELD` &0 < a ==> a * &1 / a = &1 `); UNDISCH_TAC` norm (ny:real^N) = &1 `; EXPAND_TAC "ny"; REWRITE_TAC[NORM_POS_LT; GSYM normize; NORM_NORMIZE]; ASM_REWRITE_TAC[REAL_MUL_RID]; CONJ_TAC; MATCH_MP_TAC REAL_LT_MUL; UNDISCH_TAC` norm (ny:real^N) = &1 `; EXPAND_TAC "ny"; SIMP_TAC[NORM_POS_LT; GSYM normize; NORM_NORMIZE]; ASM_REWRITE_TAC[]; ASM_MESON_TAC[]]);;
let AZIM_AND_ARCV_EQ_IMP_PARA = 
prove_by_refinement ( ` ~ collinear {v0,u,v} /\ azim v0 u v x = azim v0 u v y /\ arcV v0 u x = arcV v0 u y ==> y = v0 \/ (? t. &0 <= t /\ x - v0 = t % (y - v0)) `,
[ASM_CASES_TAC` collinear {v0,u,y:real^3}`; ASM_SIMP_TAC[AZIM_DEGENERATE]; ASM_CASES_TAC` collinear {v0,u,x:real^3}`; NHANH Fan.th3b; NHANH (REWRITE_RULE[GSYM RIGHT_IMP_FORALL_THM] Trigonometry2.NOT_EQ_IMP_AFF_AND_COLL3); STRIP_TAC; SWITCH_TAC` !u'. u' IN aff {v0, u} <=> collinear {v0, u, u':real^3}`; UNDISCH_TAC` collinear {v0, u, y:real^3}`; UNDISCH_TAC` collinear {v0, u, x:real^3}`; ASM_REWRITE_TAC[Trigonometry2.AFF2; IN_ELIM_THM]; REPEAT STRIP_TAC; ASM_REWRITE_TAC[VECTOR_ARITH` (t % v0 + (&1 - t) % u) - v0 = (&1 - t) % ( u - v0)`]; ASM_CASES_TAC` t' = &1 `; DISJ1_TAC; ASM_REWRITE_TAC[REAL_SUB_REFL; VECTOR_MUL_LZERO; VECTOR_MUL_LID; VECTOR_ADD_RID]; DISJ2_TAC; EXISTS_TAC` ( &1 - t ) / ( &1 - t')`; ASM_SIMP_TAC[VECTOR_MUL_ASSOC; REAL_FIELD` ~(t' = &1) ==> ((&1 - t) / (&1 - t')) * (&1 - t') = &1 - t `]; UNDISCH_TAC` arcV v0 u x = arcV v0 (u:real^3) y `; ONCE_REWRITE_TAC[Trigonometry2.ARCV_VEC0_FORM]; ASM_REWRITE_TAC[VECTOR_ARITH` (t % v0 + (&1 - t) % u) - v0 = (&1 - t) % (u - v0)`]; ASSUME_TAC2 (REAL_FIELD` ~( t' = &1 ) ==> &1 - t = ((&1 - t)/ (&1 - t')) * ( &1 - t')`); ABBREV_TAC` tt = (&1 - t) / (&1 - t') `; ASM_REWRITE_TAC[]; ASSUME_TAC2 (REAL_ARITH`~( t' = &1 ) ==> &0 < &1 - t' \/ &1 - t' < &0 `); FIRST_X_ASSUM DISJ_CASES_TAC; SUBGOAL_THEN` arcV (vec 0) (u:real^3 - v0) ((&1 - t') % (u - v0)) = &0` SUBST1_TAC; MATCH_MP_TAC ARCV_EQ_0_ORIGIN; ASM_REWRITE_TAC[VECTOR_ARITH` a - b = vec 0 <=> b = a `]; UNDISCH_TAC` ~(v0 = u:real^3)`; ONCE_REWRITE_TAC[VECTOR_ARITH`a = b <=> b - a = vec 0`]; SIMP_TAC[ARCV_ORI_DIRECTIONS]; STRIP_TAC; UNDISCH_TAC` &0 < &1 - t'`; SIMP_TAC[REAL_LT_MUL_EQ; REAL_LT_IMP_LE]; ASSUME_TAC2 (ISPECL [`&1 - t'`;` u:real^3`;`v0:real^3`] (GEN_ALL ( ONCE_REWRITE_RULE[Trigonometry2.ARCV_VEC0_FORM] ARCV_PI_OPPOSITE))); DOWN; SIMP_TAC[VECTOR_ARITH`(a + b:real^N) - a = b `]; STRIP_TAC; UNDISCH_TAC` ~( v0 = u:real^3)`; ONCE_REWRITE_TAC[VECTOR_ARITH` a = b <=> b - a = vec 0`]; SIMP_TAC[ARCV_ORI_DIRECTIONS]; STRIP_TAC; UNDISCH_TAC` &1 - t' < &0 `; SIMP_TAC[ONCE_REWRITE_RULE[REAL_MUL_SYM] REAL_NEG_MUL_EQ; REAL_LT_IMP_LE]; UNDISCH_TAC` collinear {v0, u, y:real^3}`; NHANH Fan.th3b; ASM_CASES_TAC` y = v0:real^3`; ASM_REWRITE_TAC[]; REPEAT STRIP_TAC; SUBGOAL_THEN` sin (arcV v0 u (y:real^3)) = &0` MP_TAC; MATCH_MP_TAC COLLINEAR_SIN_ARCV_0; ASM_REWRITE_TAC[]; SUBGOAL_THEN` ~(sin (arcV v0 u (x:real^3)) = &0 )` MP_TAC; MATCH_MP_TAC Trigonometry2.NOT_COLLINEAR_IMP_NOT_SIN0; ASM_REWRITE_TAC[]; ASM_SIMP_TAC[]; ASM_CASES_TAC` x = v0:real^3`; STRIP_TAC; DISJ2_TAC; EXISTS_TAC` &0 `; ASM_REWRITE_TAC[REAL_LE_REFL; VECTOR_SUB_REFL; VECTOR_MUL_LZERO]; ASM_CASES_TAC` collinear {v0, u, x:real^3}`; STRIP_TAC; SUBGOAL_THEN` sin (arcV v0 u (x:real^3)) = &0` MP_TAC; MATCH_MP_TAC COLLINEAR_SIN_ARCV_0; ASM_REWRITE_TAC[]; MATCH_MP_TAC Fan.th3b; EXISTS_TAC` v:real^3`; FIRST_ASSUM ACCEPT_TAC; UNDISCH_TAC` ~collinear {v0, u, y:real^3}`; ASM_SIMP_TAC[Trigonometry2.NOT_COLLINEAR_IMP_NOT_SIN0]; STRIP_TAC; ASSUME_TAC2 (ISPECL [`v0:real^3`;` u:real^3`;`v:real^3`; ` x:real^3`;` y:real^3`] AZIM_EQ_ALT); UNDISCH_TAC` ~collinear {v0, u, y:real^3}`; NHANH COLL_AFF_GT_2_1; STRIP_TAC; DISJ2_TAC; UNDISCH_TAC` azim v0 u v x = azim v0 u v (y:real^3)`; ASM_REWRITE_TAC[IN_ELIM_THM; REAL_ARITH` a + b = &1 <=> a = &1 - b`]; STRIP_TAC; DOWN; ASM_REWRITE_TAC[VECTOR_ARITH` x = (&1 - (t2 + t3)) % v0 + t2 % u + t3 % y <=> x - v0 = t2 % ( u - v0) + t3 % (y - v0) `]; ABBREV_TAC` xx = x - v0:real^3`; ABBREV_TAC` uu = u - v0:real^3 `; ABBREV_TAC` yy = y - v0:real^3`; STRIP_TAC; EXISTS_TAC` t3:real`; UNDISCH_TAC` arcV v0 u x = arcV v0 u (y:real^3)`; NHANH (MESON[]`arcV v0 u x = arcV v0 u y ==> cos (arcV v0 u x) = cos (arcV v0 u y)`); ASSUME_TAC2 (ISPECL [`v0:real^3`;`u:real^3`;` x:real^3`] Collect_geom.NOT_COL3_IMP_DIFF); ASSUME_TAC2 (ISPECL [`v0:real^3`;`u:real^3`;` y:real^3`] Collect_geom.NOT_COL3_IMP_DIFF); DOWN THEN DOWN; REWRITE_TAC[DE_MORGAN_THM]; ASM_SIMP_TAC[Trigonometry2.NOT_EQ_IMPCOS_ARC]; STRIP_TAC THEN STRIP_TAC; SUBGOAL_THEN` &0 < norm (xx:real^3) /\ &0 < norm (uu:real^3) /\ &0 < norm (yy:real^3)` MP_TAC; REWRITE_TAC[NORM_POS_LT]; EXPAND_TAC "xx";
EXPAND_TAC "uu"; EXPAND_TAC "yy"; REWRITE_TAC[VECTOR_SUB_EQ]; ASM_REWRITE_TAC[]; REPEAT STRIP_TAC; ASM_SIMP_TAC[REAL_LT_IMP_LE]; SUBGOAL_THEN` normize (xx:real^3) = normize (yy:real^3)` MP_TAC; MATCH_MP_TAC (GEN_ALL ARCV_EQ_IMP_NORMIZE); EXISTS_TAC` uu:real^3`; CONJ_TAC; UNDISCH_TAC` ~collinear {v0, u, y:real^3}`; ONCE_REWRITE_TAC[Trigonometry2.COLLINEAR_TRANSABLE]; NHANH_PAT`\x. x ==> y` COLL_AFF_GT_2_1; ASM_SIMP_TAC[]; STRIP_TAC; REWRITE_TAC[IN_ELIM_THM]; EXISTS_TAC` t1:real`; EXISTS_TAC` t2:real`; EXISTS_TAC` t3:real`; ASM_REWRITE_TAC[VECTOR_MUL_RZERO; VECTOR_ADD_LID]; REAL_ARITH_TAC; UNDISCH_TAC` ~ collinear {v0, u, y:real^3}`; UNDISCH_TAC` arcV v0 u x = arcV v0 u (y:real^3)`; ONCE_REWRITE_TAC[Trigonometry2.ARCV_VEC0_FORM]; ONCE_REWRITE_TAC[Trigonometry2.COLLINEAR_TRANSABLE]; ASM_SIMP_TAC[VECTOR_SUB_RZERO]; ASM_REWRITE_TAC[normize; VECTOR_ADD_LDISTRIB; VECTOR_MUL_ASSOC]; ONCE_REWRITE_TAC[VECTOR_ARITH` a + x % b = y % b <=> a + (x - y) % b = vec 0`]; ASM_CASES_TAC` ~( (&1 / norm (t2 % uu + t3 % (yy:real^3)) * t2) = &0)`; STRIP_TAC; SUBGOAL_THEN` collinear {vec 0, uu, yy:real^3}` MP_TAC; REWRITE_TAC[COLL_EQ_DEPENDENT]; DOWN THEN DOWN THEN MESON_TAC[]; UNDISCH_TAC` ~ collinear {v0, u, y:real^3}`; ONCE_REWRITE_TAC[Trigonometry2.COLLINEAR_TRANSABLE]; ASM_SIMP_TAC[VECTOR_SUB_RZERO]; DOWN; SIMP_TAC[REAL_ENTIRE]; ASSUME_TAC2 (REAL_FIELD` &0 < norm (xx:real^3) ==> ~( &1 / norm xx = &0) `); DOWN; ASM_SIMP_TAC[VECTOR_MUL_LZERO; REAL_SUB_REFL; VECTOR_ADD_LID]]);;
let NORM_CAUCHY_SCHWARZ_FRAC2 = 
prove(` -- &1 <= (u dot v) / (norm u * norm v) /\ (u dot v) / (norm u * norm (v:real^N)) <= &1 `,
ASM_CASES_TAC`~((u:real^N) = vec 0) /\ ~((v: real^N) = vec 0)` THEN ASM_SIMP_TAC[Trigonometry1.NORM_CAUCHY_SCHWARZ_FRAC] THEN DOWN THEN REWRITE_TAC[DE_MORGAN_THM] THEN STRIP_TAC THENL [ ASM_REWRITE_TAC[DOT_LZERO] THEN REAL_ARITH_TAC; ASM_REWRITE_TAC[DOT_RZERO] THEN REAL_ARITH_TAC]);;
let COS_ARCV_EQ_ARCV = 
prove( ` cos (arcV x y z) = cos (arcV xx yy zz) <=> arcV x y z = arcV xx yy zz `,
EQ_TAC THENL [REWRITE_TAC[arcV] THEN STRIP_TAC THEN MATCH_MP_TAC COS_INJ_PI THEN DOWN THEN MESON_TAC[ACS_BOUNDS; NORM_CAUCHY_SCHWARZ_FRAC2];SIMP_TAC[]]);;
let ARCV_BOUNDS = 
prove(` &0 <= arcV (x:real^N) y z /\ arcV x y z <= pi `,
REWRITE_TAC[arcV] THEN MATCH_MP_TAC ACS_BOUNDS THEN REWRITE_TAC[NORM_CAUCHY_SCHWARZ_FRAC2]);;
let SIN_ARCV_EQ_0_EQ_LAP = 
prove( ` sin (arcV x y (z:real^N)) = &0 <=> arcV x y z = &0 \/ arcV x y z = pi `,
MP_TAC ARCV_BOUNDS THEN MP_TAC PI_POS THEN MESON_TAC[REAL_ARITH` &0 < x /\ &0 <= a ==> -- x < a`; Trigonometry1.SIN_NEGPOS_PI]);;
let ORTHONORMAL_NOT_COLLINEAR = 
prove( ` orthonormal e1 e2 e3 ==> ~ collinear {vec 0, e3, e1} `,
REWRITE_TAC[orthonormal; GSYM CROSS_EQ_0] THEN ONCE_REWRITE_TAC[GSYM CROSS_TRIPLE] THEN REPEAT STRIP_TAC THEN FIRST_X_ASSUM SUBST_ALL_TAC THEN DOWN THEN REWRITE_TAC[DOT_LZERO; REAL_LT_REFL]);;
let LUNAR_DEFORM_INJ = 
prove_by_refinement ( ` orthonormal e1 e2 e3 /\ &0 <= t /\ t < &1 ==> (! x y. lunar_deform (e1,e2,e3) t x = lunar_deform (e1,e2,e3) t y ==> x = y )`,
[REPEAT STRIP_TAC; ASM_CASES_TAC` (x:real^3) = vec 0`; ASSUME_TAC2 (SPEC` y:real^3 ` (GEN `x:real^3 ` LUNAR_DEFORM_PRESERVE_NORM)); ASSUME_TAC2 LUNAR_DEFORM_PRESERVE_NORM; DOWN; DOWN; ASM_SIMP_TAC[NORM_0; NORM_EQ_0]; DOWN THEN DOWN; NHANH_PAT`\a. a ==> b ` (MESON[]` a = b ==> norm a = norm b `); ASM_SIMP_TAC[LUNAR_DEFORM_PRESERVE_NORM]; REWRITE_TAC[lunar_deform]; ASM_SIMP_TAC[ORTHONORMAL_IMP_INDEPENDENT_EXPLICIT; GSYM NORM_POS_LT]; REPEAT STRIP_TAC; UNDISCH_TAC` norm (x:real^3) * cos (arcV (vec 0) e3 x) = norm y * cos (arcV (vec 0) e3 (y:real^3))`; ASM_SIMP_TAC[REAL_EQ_MUL_LCANCEL; REAL_POS_NZ; COS_ARCV_EQ_ARCV]; STRIP_TAC; ASM_CASES_TAC` sin (arcV (vec 0) e3 (x:real^3)) = &0`; DOWN; NHANH (REWRITE_RULE[CONTRAPOS_THM] Trigonometry2.NOT_COLLINEAR_IMP_NOT_SIN0); ASM_REWRITE_TAC[]; NHANH (REWRITE_RULE[CONTRAPOS_THM] Trigonometry2.NOT_COLLINEAR_IMP_NOT_SIN0); REWRITE_TAC[COLLINEAR_LEMMA_ALT]; SUBGOAL_THEN` ~(e3:real^3 = vec 0) ` MP_TAC; UNDISCH_TAC` orthonormal e1 e2 e3`; REWRITE_TAC[orthonormal]; REPEAT STRIP_TAC; FIRST_X_ASSUM SUBST_ALL_TAC; UNDISCH_TAC` vec 0 dot (vec 0: real^3) = &1`; REWRITE_TAC[DOT_LZERO]; REAL_ARITH_TAC; SIMP_TAC[SIN_ARCV_EQ_0_EQ_LAP]; STRIP_TAC THEN STRIP_TAC; REPEAT STRIP_TAC; SUBGOAL_THEN` arcV (vec 0) e3 (x:real^3) = &0` MP_TAC; ASM_REWRITE_TAC[]; UNDISCH_TAC` arcV (vec 0) e3 (y:real^3) = &0`; PHA; UNDISCH_TAC` ~( (e3:real^3) = vec 0) `; DOWN THEN DOWN; SIMP_TAC[ARCV_ORI_DIRECTIONS]; REPEAT STRIP_TAC; UNDISCH_TAC` norm (x:real^3) = norm (y:real^3)`; ASM_SIMP_TAC[NORM_MUL; Trigonometry2.LT_IMP_ABS_REFL; REAL_EQ_MUL_RCANCEL; NORM_EQ_0]; SUBGOAL_THEN` arcV (vec 0) e3 (x:real^3) = pi` MP_TAC; ASM_REWRITE_TAC[]; UNDISCH_TAC` arcV (vec 0) e3 (y:real^3) = pi`; PHA; UNDISCH_TAC` ~( (e3:real^3) = vec 0) `; DOWN THEN DOWN; SIMP_TAC[ARCV_ORI_DIRECTIONS]; REPEAT STRIP_TAC; UNDISCH_TAC` norm (x:real^3) = norm (y:real^3)`; ASM_REWRITE_TAC[NORM_MUL]; ONCE_REWRITE_TAC[GSYM REAL_ABS_NEG]; DOWN THEN DOWN; REWRITE_TAC[REAL_ARITH` a < &0 <=> &0 < -- a `]; ASM_SIMP_TAC[NORM_MUL; Trigonometry2.LT_IMP_ABS_REFL; REAL_EQ_MUL_RCANCEL; NORM_EQ_0]; SIMP_TAC[REAL_ARITH` -- a = -- b <=> a = b `]; UNDISCH_TAC` norm x * sin ((&1 - t) * azim (vec 0) e3 e1 x) * sin (arcV (vec 0) e3 x) = norm y * sin ((&1 - t) * azim (vec 0) e3 e1 y) * sin (arcV (vec 0) e3 y)`; UNDISCH_TAC` norm x * cos ((&1 - t) * azim (vec 0) e3 e1 x) * sin (arcV (vec 0) e3 x) = norm y * cos ((&1 - t) * azim (vec 0) e3 e1 y) * sin (arcV (vec 0) e3 y)`; DOWN; ASM_SIMP_TAC[REAL_EQ_MUL_RCANCEL; REAL_EQ_MUL_LCANCEL; REAL_POS_NZ]; REPEAT STRIP_TAC; SUBGOAL_THEN` (&1 - t) * azim (vec 0) e3 e1 x = (&1 - t) * azim (vec 0) e3 e1 y` MP_TAC; MATCH_MP_TAC SIN_COS_INJ; ASM_REWRITE_TAC[]; MATCH_MP_TAC (REAL_FIELD` &0 <= x /\ x < a /\ &0 <= y /\ y < a ==> abs ( x - y) < a `); SPEC_TAC (`x:real^3`,`x:real^3`); SPEC_TAC (`y:real^3`,`y:real^3`); MATCH_MP_TAC (MESON[]`(! x. P x /\ L x ) ==> (! y x. P x /\ L x /\ P y /\ L y)`); GEN_TAC; CONJ_TAC; MATCH_MP_TAC REAL_LE_MUL; REWRITE_TAC[AZIM_RANGE]; UNDISCH_TAC` t < &1 ` THEN REAL_ARITH_TAC; REWRITE_TAC[REAL_SUB_RDISTRIB; REAL_MUL_LID]; MATCH_MP_TAC ( REAL_FIELD` azim (vec 0) e3 e1 x' < &2 * pi /\ &0 <= t * azim (vec 0) e3 e1 x' ==> azim (vec 0) e3 e1 x' - t * azim (vec 0) e3 e1 x' < &2 * pi`); REWRITE_TAC[AZIM_RANGE]; MATCH_MP_TAC REAL_LE_MUL; ASM_REWRITE_TAC[AZIM_RANGE]; ASM_SIMP_TAC[REAL_EQ_MUL_LCANCEL; REAL_ARITH` t < a ==> ~( a - t = &0)`]; ASSUME_TAC2 ORTHONORMAL_NOT_COLLINEAR; STRIP_TAC; ASSUME_TAC2 ( SPECL[`e1:real^3`;`e3:real^3`;`x:real^3`;`y:real^3`;` vec 0:real^3`] (GEN_ALL AZIM_AND_ARCV_EQ_IMP_PARA)); DOWN; ASM_SIMP_TAC[GSYM NORM_EQ_0; REAL_POS_NZ; VECTOR_SUB_RZERO]; STRIP_TAC; UNDISCH_TAC` norm (x:real^3) = norm (y:real^3)`; ASM_SIMP_TAC[NORM_MUL; REAL_ARITH` a * x = x <=> ( a - &1 ) * x = &0`; REAL_ENTIRE; REAL_POS_NZ]; UNDISCH_TAC` &0 <= t'`; SIMP_TAC[GSYM REAL_ABS_REFL; REAL_SUB_0; VECTOR_MUL_LID]]);;
let GRAPH_IMAGE_IMAGE = 
prove_by_refinement ( `graph E /\ (! x y. (f:real^N -> real^M) x = f y ==> x = y) ==> graph (IMAGE (IMAGE f) E)`,
[REWRITE_TAC[graph; HAS_SIZE_2_EXISTS; IMAGE; IN_ELIM_THM; IN]; IMP_TAC; DISCH_THEN NHANH; REPEAT STRIP_TAC; EXISTS_TAC` (f:real^N -> real^M) x' `; EXISTS_TAC` (f:real^N -> real^M) y `; CONJ_TAC; ASM_MESON_TAC[]; STRIP_TAC; ASM_REWRITE_TAC[IN_ELIM_THM]; MESON_TAC[]]);;
let LUNAR_DEFORM_ORIGIN = 
prove(` lunar_deform (e1,e2,e3) t (vec 0) = vec 0`,
let orthonormal1 = 
prove(`!e1 e2 e3. orthonormal e1 e2 e3 <=> norm e1 = &1 /\ norm e2 = &1 /\ norm e3 = &1 /\ e1 dot e2 = &0 /\ e1 dot e3 = &0 /\ e2 dot e3 = &0 /\ &0 < (e1 cross e2) dot e3 `,
REWRITE_TAC[orthonormal; NORM_EQ_1]);;
let ORTHO_SPHERICAL_AZIM = 
prove_by_refinement(`orthonormal e1 e2 e3 /\ x = ( r * cos theta) % e1 + (r * sin theta) % e2 + h % e3 /\ &0 < r /\ &0 <= theta /\ theta < &2 * pi ==> azim (vec 0) e3 e1 x = theta `,
[STRIP_TAC; MP_TAC (ISPECL [` vec 0:real^3 `;` e3: real^3 `;` e1: real^3 `;` x:real^3 `;` &0 `; `h:real`;` &1 `;` r:real`;` e1:real^3 `;` e2: real^3`;` e3:real^3`;` &0`; `theta: real`] AZIM_UNIQUE); ANTS_TAC; ASM_REWRITE_TAC[VECTOR_SUB_RZERO; dist; SIN_0; COS_0; REAL_ADD_LID; VECTOR_MUL_LZERO; REAL_MUL_RZERO; VECTOR_ADD_RID; REAL_MUL_RID; VECTOR_MUL_LID]; REWRITE_TAC[REAL_ARITH` &0 < &1 `]; DOWN_TAC; SIMP_TAC[orthonormal1; VECTOR_MUL_LID; GSYM NORM_EQ_0; REAL_ARITH` ~(&1 = &0)`]; SIMP_TAC[]]);;
let COS_ARCV = 
prove_by_refinement(`cos (arcV v0 u (w:real^N)) = ((u - v0) dot (w - v0)) / (norm (u - v0) * norm (w - v0))`,
[ASM_CASES_TAC` ~(v0 = u) /\ ~(v0 = w:real^N)`; DOWN THEN REWRITE_TAC[Trigonometry2.NOT_EQ_IMPCOS_ARC]; DOWN; REWRITE_TAC[DE_MORGAN_THM]; STRIP_TAC; ASM_SIMP_TAC[VECTOR_SUB_REFL; arcV; DOT_LZERO; REAL_ARITH` &0 / x = &0`; ACS_0; COS_PI2]; ASM_SIMP_TAC[VECTOR_SUB_REFL; arcV; DOT_RZERO; REAL_ARITH` &0 / x = &0`; ACS_0; COS_PI2]]);;
let LUNAR_DEFORM_ARCV_PRESERVED = 
prove(`orthonormal e1 e2 e3 ==> arcV (vec 0) e3 x = arcV (vec 0) e3 (lunar_deform (e1,e2,e3) t x) `,
ASM_CASES_TAC` (x:real^3) = vec 0 ` THENL [ ASM_REWRITE_TAC[LUNAR_DEFORM_ORIGIN]; SIMP_TAC[LUNAR_DEFORM_PRESERVE_NORM; arcV; orthonormal; VECTOR_SUB_RZERO] THEN SIMP_TAC[lunar_deform; DOT_RADD; DOT_RMUL; DOT_SYM; REAL_MUL_RZERO; REAL_ADD_LID; REAL_MUL_RID; COS_ARCV; VECTOR_SUB_RZERO; GSYM NORM_EQ_1; REAL_MUL_LID] THEN DOWN THEN SIMP_TAC[GSYM NORM_EQ_0; REAL_FIELD` ~( a = &0) ==> a * b / a = b`; NORM_EQ_1; REAL_MUL_RID]]);;
(* ========================================================================= *) (* ========================================================================= *) Local_lemmas.LUNAR_IMP_INTERIOR_ANGLE1_EQ_PI;; Local_lemmas.interior_angle1;; Wrgcvdr_cizmrrh.lunar;; Local_lemmas.HKIRPEP;; (* because interior_angle1 (vec 0) FF v <= pi and interior_angle1 x FF v = azim x v (rho_node1 FF v) (@a. a,v IN FF) , the condition theta (ivs_rho_node1 FF v) <= &0 is satisfied automatically *) g ` convex_local_fan (V,E,FF) /\ lunar (v,w) V E /\ orthonormal e1 e2 e3 /\ v = a % e3 /\ &0 < a /\ rho_node1 FF v IN aff_gt {vec 0, e3} {e1} /\ lunar_deform (e1,e2,e3) t = f /\ &0 <= t /\ t < &1 ==> convex_local_fan (IMAGE f V, IMAGE (\S. IMAGE f S) E, IMAGE (\ (m,n). f m, f n) FF) /\ lunar (v,w) (IMAGE f V) (IMAGE (\S. IMAGE f S) E) /\ CARD (IMAGE f V) = CARD V`;; g ` convex_local_fan (V,E,FF) /\ lunar (v,w) V E /\ orthonormal e1 e2 e3 /\ v = a % e3 /\ &0 < a /\ rho_node1 FF v IN aff_gt {vec 0, e3} {e1} /\ lunar_deform (e1,e2,e3) t = f /\ &0 <= t /\ t < &1 ==> FAN (vec 0,IMAGE f V,IMAGE ( IMAGE f ) E) `;; e (REWRITE_TAC[convex_local_fan]);; e (NHANH Local_lemmas.LOCAL_FAN_ORBIT_MAP_V);; e (REWRITE_TAC[local_fan; FAN]);; e (LET_TAC);; e (STRIP_TAC);; e (CONJ_TAC);; e (UNDISCH_TAC` UNIONS E SUBSET (V:real^3 -> bool) `);; e (REWRITE_TAC[GSYM IMAGE_UNIONS]);; e (SET_TAC[]);; e (CONJ_TAC);; e (MATCH_MP_TAC GRAPH_IMAGE_IMAGE);; e (ASM_REWRITE_TAC[]);; e (EXPAND_TAC "f");; e (MATCH_MP_TAC LUNAR_DEFORM_INJ);; e (ASM_REWRITE_TAC[]);; e (REWRITE_TAC[fan1; fan2; fan6; fan7]);; e (CONJ_TAC);; e (UNDISCH_TAC` fan1 ((vec 0:real^3),(V:real^3 -> bool),(E:(real^3 -> bool) -> bool))`);; e (REWRITE_TAC[fan1]);; e (SIMP_TAC[FINITE_IMAGE]);; e (SET_TAC[]);; e (ASSUME_TAC2 LUNAR_DEFORM_INJ);; e (CONJ_TAC);; e (UNDISCH_TAC` fan2 (vec 0,V: real^3 -> bool,(E:(real^3 -> bool) -> bool)) `);; e (REWRITE_TAC[fan2]);; e (DOWN);; e (MP_TAC LUNAR_DEFORM_ORIGIN);; e (ASM_REWRITE_TAC[IN_IMAGE]);; e (MESON_TAC[]);; e (CONJ_TAC);; e (GEN_TAC);; e (UNDISCH_TAC` fan6 (vec 0,V:real^3 -> bool,E:(real^3 -> bool) -> bool ) `);; e (REWRITE_TAC[IN_IMAGE; IMAGE; fan6]);; e (STRIP_TAC);; e (FIRST_ASSUM NHANH);; e (STRIP_TAC);; e (MP_TAC Local_lemmas.HKIRPEP);; e (ANTS_TAC);; e (ASM_REWRITE_TAC[convex_local_fan; local_fan]);; e (CONV_TAC (ONCE_DEPTH_CONV let_CONV));; e (SWITCH_TAC ` FF = face H (x:real^3 # real^3 )`);; e (ASM_REWRITE_TAC[FAN; fan6]);; e (EXISTS_TAC `x:(real^3 #real^3)`);; e (ASM_REWRITE_TAC[]);; e (STRIP_TAC);; e (UNDISCH_TAC` graph (E: (real^3 -> bool) -> bool) `);; e (REWRITE_TAC[graph]);; e (STRIP_TAC);; e (UNDISCH_TAC`(x': real^3 -> bool) IN E `);; e (REWRITE_TAC[IN]);; e (FIRST_ASSUM NHANH);; e (REWRITE_TAC[HAS_SIZE]);; e (NHANH Rogers.CARD_2_IMP_DOUBLE);; e (STRIP_TAC);; e (UNDISCH_TAC` v = ITER j (rho_node1 FF) w`);; e (USE_FIRST `w = ITER i (rho_node1 FF) v` (fun x -> REWRITE_TAC[x; ITER_ADD]));; e (ASSUME_TAC2 (ARITH_RULE` ~(j = 0) ==> 0 < j + i `));; e (DOWN THEN PHA);; e (ONCE_REWRITE_TAC[EQ_SYM_EQ]);; e (NHANH Lvducxu.ITER_CYCLIC_ORBIT);; (* ` special_fan (V,E,FF,S) <=> packing V /\ V SUBSET ball (vec 0, &1) /\ convex_local_fan (V,E,FF) /\ S SUBSET E /\ (! v w. {v,w} IN S ==> dist (v,w) = &2 * t0 ) /\ (! v w. {v,w} IN E ==> dist (v,w) <= &2 * t0 ) /\ (! v w. v IN V /\ w IN V /\ ~( v = w ) /\ ~( {v,w} IN E ) ==> &2 * t0 <= dist (v,w)) /\ let r = CARD E - CARD S in CARD S <= 3 /\ 3 - CARD S <= r /\ r <= 6 - 2 * (CARD S)`;; *) (* ================================================== *) (* LEMMA YOLCBTG *) (* ============= *)
let AFF_CONV0_INTERSECTION_LEMMA = 
prove_by_refinement (`! u x y (z:real^3). coplanar {u,x,y,z} /\ ~ collinear {u,x,y} /\ ~ collinear {u,y,z} /\ ~ collinear {u,z,x} ==> ~ ( aff {u,x} INTER conv0 {y,z} = {} /\ aff {u,y} INTER conv0 {x,z} = {} /\ aff {u,z} INTER conv0 {x,y} = {} ) `,
[REWRITE_TAC[coplanar]; REPEAT STRIP_TAC; SUBGOAL_THEN` affine hull {u', v, w} = affine hull {u,x,y:real^3}` MP_TAC; MATCH_MP_TAC Local_lemmas.SUBSET_NOT_COLLINEAR_AFFINE_HULL_EQ; ASM_REWRITE_TAC[]; MATCH_MP_TAC SUBSET_TRANS; EXISTS_TAC` {u,x,y,z:real^3}` ; ASM_REWRITE_TAC[INSERT_SUBSET; IN_INSERT; EMPTY_SUBSET]; STRIP_TAC; SUBGOAL_THEN` {z:real^3} SUBSET affine hull {u', v, w} ` MP_TAC; MATCH_MP_TAC SUBSET_TRANS; EXISTS_TAC` {u,x,y,z:real^3}`; ASM_REWRITE_TAC[INSERT_SUBSET; IN_INSERT; EMPTY_SUBSET]; ASM_REWRITE_TAC[INSERT_SUBSET; EMPTY_SUBSET; AFFINE_HULL_3; IN_ELIM_THM]; STRIP_TAC; ASM_CASES_TAC` &0 < v' /\ &0 < w' `; ABBREV_TAC` tt = &0 % u + &1 % (z:real^3) `; SUBGOAL_THEN` (?tt. tt IN aff {u, z:real^3} /\ tt IN conv0 {x, y})` MP_TAC; MATCH_MP_TAC (GEN_ALL Local_lemmas.CONDS_FOR_INTER_AFF_CONV0); EXISTS_TAC` u'': real` ; EXISTS_TAC` v': real `; EXISTS_TAC` w': real`; EXISTS_TAC` &1 `; EXISTS_TAC` tt: real^3 `; EXISTS_TAC`&0 `; EXISTS_TAC` &1 `; ASM_REWRITE_TAC[REAL_ADD_LID]; EXPAND_TAC "tt";
REWRITE_TAC[VECTOR_MUL_LID; VECTOR_MUL_LZERO; VECTOR_ADD_LID]; ASM_REWRITE_TAC[]; UNDISCH_TAC` aff {u, z} INTER conv0 {x, y:real^3} = {}`; REWRITE_TAC[Local_lemmas.INTER_EQ_EM_EXPAND]; DOWN_TAC; SPEC_TAC (`v':real`,`v':real`); SPEC_TAC (`w':real`,`w':real`); SPEC_TAC (`x:real^3`,` x:real^3 `); SPEC_TAC (`y:real^3`,` y:real^3`); MATCH_MP_TAC (MESON[REAL_ARITH` a <= b \/ b <= a`]` (! y x b a. P y x b a ==> P x y a b) /\ (! y x b a. b <= a ==> P y x b a) ==> (! y x b a. P y x b a) `); SIMP_TAC[INSERT_COMM; REAL_ADD_SYM; VECTOR_ADD_SYM; CONJ_SYM]; CONJ_TAC; MESON_TAC[]; REPEAT STRIP_TAC; ASM_CASES_TAC` &0 < w' `; UNDISCH_TAC` w' <= v':real`; DOWN THEN DOWN THEN PHA; REAL_ARITH_TAC; ASM_CASES_TAC` w' = &0 `; FIRST_X_ASSUM SUBST_ALL_TAC; DOWN_TAC; REWRITE_TAC[REAL_ADD_RID; VECTOR_MUL_LZERO; VECTOR_ADD_RID; Local_lemmas.collinear_fan22; Collect_geom.AFF_2POINTS_INTERPRET; IN_ELIM_THM]; STRIP_TAC; UNDISCH_TAC` z = u'' % u + v' % (x:real^3)`; UNDISCH_TAC` u'' + v' = &1 `; UNDISCH_TAC` ~((?ta tb. ta + tb = &1 /\ z = ta % u + tb % x) \/ u = (x:real^3))`; MESON_TAC[]; ASM_CASES_TAC` v' = &0 `; FIRST_X_ASSUM SUBST_ALL_TAC; DOWN_TAC; REWRITE_TAC[REAL_ADD_LID; VECTOR_MUL_LZERO; VECTOR_ADD_LID; Local_lemmas.collinear_fan22; Collect_geom.AFF_2POINTS_INTERPRET; IN_ELIM_THM]; MESON_TAC[]; DOWN; REWRITE_TAC[REAL_ARITH` a = &0 <=> ~( &0 < a \/ a < &0 )`]; STRIP_TAC; UNDISCH_TAC` z = u'' % u + v' % x + w' % (y:real^3)`; PURE_ONCE_REWRITE_TAC[VECTOR_ARITH` z = a % x + b + w' % (y:real^N) <=> b = ( -- a) % x + ( -- w') % y + &1 % z `]; STRIP_TAC; SUBGOAL_THEN` (?tt. tt IN aff {u, x:real^3} /\ tt IN conv0 {y, z})` MP_TAC; MATCH_MP_TAC (GEN_ALL Local_lemmas.CONDS_FOR_INTER_AFF_CONV0); EXISTS_TAC` -- u'':real `; EXISTS_TAC` -- w':real `; EXISTS_TAC` &1 `; EXISTS_TAC` v': real `; EXISTS_TAC` v' % x:real^3 `; EXISTS_TAC` &0 `; EXISTS_TAC` v':real`; ASM_REWRITE_TAC[REAL_ARITH` &0 < &1 `; REAL_ADD_LID; VECTOR_MUL_LZERO; VECTOR_ADD_LID]; ASM_REAL_ARITH_TAC; UNDISCH_TAC` aff {u, x} INTER conv0 {y, z:real^3} = {}`; REWRITE_TAC[Local_lemmas.INTER_EQ_EM_EXPAND]; UNDISCH_TAC` z = u'' % u + v' % x + w' % (y:real^3)`; PURE_ONCE_REWRITE_TAC[VECTOR_ARITH` z = u'' % u + v' % x + w' % y <=> -- z = ( -- u'') % u + ( -- v') % x + ( -- w') % y `]; STRIP_TAC; SUBGOAL_THEN` (?tt. tt IN aff {u, z:real^3} /\ tt IN conv0 {x, y})` MP_TAC; MATCH_MP_TAC (GEN_ALL Local_lemmas.CONDS_FOR_INTER_AFF_CONV0); EXISTS_TAC` -- u'':real `; EXISTS_TAC` -- v':real `; EXISTS_TAC` -- w' `; EXISTS_TAC` -- &1 `; EXISTS_TAC` -- z :real^3 `; EXISTS_TAC` &0 `; EXISTS_TAC` -- &1`; ASM_REWRITE_TAC[REAL_ADD_LID; VECTOR_MUL_LZERO; VECTOR_ADD_LID]; ASM_REWRITE_TAC[VECTOR_ARITH` -- &1 % x = -- (x:real^N)`]; ASM_REAL_ARITH_TAC; UNDISCH_TAC` aff {u, z} INTER conv0 {x, y:real^3} = {}`; REWRITE_TAC[Local_lemmas.INTER_EQ_EM_EXPAND]]);;
let CVLF_COLLINEAR_CIRCULAR_LUNAR = 
prove( ` convex_local_fan (V,E,FF) /\ {v,w} SUBSET V /\ collinear {vec 0, v, w} /\ ~ (v = w) ==> circular V E \/ lunar (v,w) V E `,
ASM_CASES_TAC` circular (V:real^3 -> bool) E` THENL [ ASM_REWRITE_TAC[]; STRIP_TAC THEN DISJ2_TAC THEN REWRITE_TAC[lunar] THEN ASM_REWRITE_TAC[]]);;
let CVLF_FLAT_ANGLE_LEMMA = 
prove_by_refinement( ` convex_local_fan (V,E,FF) /\ {v, w} SUBSET V /\ collinear {vec 0, v, w} /\ ~(v = w) ==> ! z. z IN V /\ ~( z = v ) /\ ~( z = w ) ==> interior_angle1 (vec 0) FF z = pi `,
[NHANH CVLF_COLLINEAR_CIRCULAR_LUNAR; STRIP_TAC; ASSUME_TAC2 Local_lemmas.KCHMAMG; DOWN THEN IMP_TAC; DISCH_TAC THEN REMOVE_TAC; ASM_SIMP_TAC[]; ASSUME_TAC2 Local_lemmas.HKIRPEP; DOWN; SIMP_TAC[IN_DIFF; IN_INSERT; DE_MORGAN_THM; NOT_IN_EMPTY]]);;
(* ============================================================== *)
let TOW_REAL_EXISTS_COMBINED = 
prove_by_refinement (` (? e1. &0 < e1 /\ (! t. -- e1 < t /\ t < e1 ==> P t )) /\ (? e1. &0 < e1 /\ (! t. -- e1 < t /\ t < e1 ==> Q t )) ==> (? e1. &0 < e1 /\ (! t. -- e1 < t /\ t < e1 ==> P t /\ Q t ))`,
[STRIP_TAC; ASM_CASES_TAC` e1 < e1':real `; EXISTS_TAC` e1:real `; ASM_REWRITE_TAC[]; GEN_TAC; ASM_SIMP_TAC[]; SUBGOAL_THEN` -- e1' < -- (e1:real) ` MP_TAC; DOWN; REAL_ARITH_TAC; ASM_MESON_TAC[REAL_LT_TRANS]; EXISTS_TAC` e1':real`; ASM_REWRITE_TAC[]; GEN_TAC; ASM_SIMP_TAC[]; SUBGOAL_THEN` ~(-- e1' < -- e1:real) ` MP_TAC; DOWN; REAL_ARITH_TAC; ASM_MESON_TAC[REAL_ARITH` ~( a < b) /\ a < c ==> b < (c:real) `]]);;
let CONTINUOUS_FUNS_DISTINCT_POINTS = 
prove_by_refinement (`f continuous atreal r /\ g continuous atreal rr /\ ~ ((f:real -> real^N) r = g rr) ==> ? d. &0 < d /\ (! x y. abs (x - r) < d /\ abs ( y - rr) < d ==> ~( f x = g y) )`,
[REWRITE_TAC[continuous_atreal]; STRIP_TAC; FIRST_X_ASSUM (MP_TAC o (SPEC` dist ((f:real -> real^N) r, g (rr:real)) / &2`)); FIRST_X_ASSUM (MP_TAC o (SPEC` dist ((f:real -> real^N) r, g (rr:real)) / &2`)); SUBGOAL_THEN` &0 < dist ((f:real -> real^N) r,g (rr:real)) / &2 ` ASSUME_TAC; ASM_REWRITE_TAC[REAL_ARITH` &0 < a / &2 <=> &0 < a `; GSYM DIST_NZ]; ANTS_TAC; FIRST_ASSUM ACCEPT_TAC; STRIP_TAC; ANTS_TAC; FIRST_ASSUM ACCEPT_TAC; STRIP_TAC; EXISTS_TAC` min d d' `; ASM_REWRITE_TAC[REAL_LT_MIN]; FIRST_X_ASSUM NHANH; FIRST_X_ASSUM NHANH; REPEAT STRIP_TAC; MP_TAC (SPECL [` (f:real -> real^N) r`; `(f:real -> real^N) x`; `(g:real -> real^N) rr `] DIST_TRIANGLE); MP_TAC (SPECL [` (f:real -> real^N) x`; `(g:real -> real^N) y`; `(g:real -> real^N) rr `] DIST_TRIANGLE); PHA; NHANH (REAL_ARITH` a <= b + c /\ x <= y + a ==> x - y - c <= b `); STRIP_TAC; SUBGOAL_THEN` &0 < dist ((f:real -> real^N) x,(g:real -> real^N) y)` MP_TAC; DOWN; MATCH_MP_TAC (REAL_ARITH` &0 < b ==> b <= a ==> &0 < a `); MATCH_MP_TAC (REAL_ARITH` a < x / &2 /\ b < x / &2 ==> &0 < x - a - b `); UNDISCH_TAC` dist ((f:real -> real^N) x,f (r:real)) < dist ((f:real -> real^N) r,g (rr:real)) / &2`; ASM_REWRITE_TAC[DIST_SYM]; ASM_REWRITE_TAC[GSYM DIST_NZ]]);;
let CONTINUOUS_TWO_POINTS_DISTINCT = MESON[CONTINUOUS_FUNS_DISTINCT_POINTS] ` ff (v1:real^N) continuous atreal r /\ ff v2 continuous atreal r /\ ~(ff v1 r = ff v2 r ) ==> ? d. &0 < d /\ (! t. abs ( t - r ) < d ==> ~( ff v1 t = ((ff v2 t ):real^M))) `;;
let CONTINUOUS_FUN_DISTINCT_FINITE_SET = 
prove_by_refinement (`! V. FINITE (V:real^N -> bool) ==> (! v1. v1 IN V /\ ~( v0 = v1) ==> ~ (ff v0 r = ff v1 r)) /\ (! v. v IN v0 INSERT V ==> ff v continuous atreal r ) ==> ? d. &0 < d /\ (! t. abs (t - r) < d ==> (! v1. v1 IN V /\ ~(v0 = v1 ) ==> ~( ff v0 t = ((ff v1 t):real^M))))`,
[MATCH_MP_TAC FINITE_INDUCT_STRONG; REWRITE_TAC[NOT_IN_EMPTY]; CONJ_TAC; DISCH_TAC; EXISTS_TAC` &1 `; REAL_ARITH_TAC; REPEAT STRIP_TAC; UNDISCH_TAC` (!v1. (v1:real^N) IN V /\ ~(v0 = v1) ==> ~((ff v0 r):real^M = ff v1 r)) /\ (!v. v IN v0 INSERT V ==> ff v continuous atreal r) ==> (?d. &0 < d /\ (!t. abs (t - r) < d ==> (!v1. v1 IN V /\ ~(v0 = v1) ==> ~(ff v0 t = ff v1 t)))) `; ANTS_TAC; DOWN THEN DOWN THEN PHA; SIMP_TAC[IN_INSERT]; MESON_TAC[]; STRIP_TAC; ASM_CASES_TAC` v0 = x:real^N `; EXISTS_TAC` d:real `; ASM_REWRITE_TAC[IN_INSERT]; DOWN THEN DOWN THEN PHA; MESON_TAC[]; SUBGOAL_THEN` ff (v0:real^N) continuous atreal r /\ ff x continuous atreal r /\ ~(ff v0 r = (ff x r):real^M) ` MP_TAC; DOWN_TAC; REWRITE_TAC[IN_INSERT]; MESON_TAC[]; NHANH CONTINUOUS_TWO_POINTS_DISTINCT; STRIP_TAC; EXISTS_TAC` min d d'`; ASM_REWRITE_TAC[REAL_LT_MIN; IN_INSERT]; ASM_MESON_TAC[]]);;
let CONTINUOUS_ATREAL_INJ_PRESERVED = 
prove_by_refinement (`! V. FINITE (V:real^N -> bool) ==> (! v1 v2. v1 IN V /\ v2 IN V /\ ~( v1 = v2) ==> ~ (ff v1 r = ff v2 r)) /\ (! v. v IN V ==> ff v continuous atreal r ) ==> ? d. &0 < d /\ (! t. abs (t - r) < d ==> (! v1 v2. v1 IN V /\ v2 IN V /\ ~(v1 = v2 ) ==> ~( ff v1 t = ((ff v2 t):real^M))))`,
[MATCH_MP_TAC FINITE_INDUCT_STRONG; REWRITE_TAC[NOT_IN_EMPTY]; CONJ_TAC; EXISTS_TAC` &1 `; REAL_ARITH_TAC; REPEAT STRIP_TAC; SUBGOAL_THEN` (!v1 v2. (v1:real^N) IN V /\ v2 IN V /\ ~(v1 = v2) ==> ~(ff v1 r = (ff v2 r):real^M)) /\ (!v. v IN V ==> ff v continuous atreal r) ` MP_TAC; DOWN THEN DOWN THEN PHA; SIMP_TAC[IN_INSERT]; DISCH_TAC; SUBGOAL_THEN` (?d. &0 < d /\ (!t. abs (t - r) < d ==> (!v1 v2. v1 IN V /\ v2 IN V /\ ~(v1 = (v2:real^N)) ==> ~(ff v1 t = (ff v2 t):real^M))))` MP_TAC; DOWN; FIRST_X_ASSUM ACCEPT_TAC; STRIP_TAC; MP_TAC (SPEC_ALL ( ISPECL [`r:real `;` x:real^N `] (GEN_ALL CONTINUOUS_FUN_DISTINCT_FINITE_SET))); PHA; ANTS_TAC; UNDISCH_TAC `!(v1:real^N) v2. v1 IN x INSERT V /\ v2 IN x INSERT V /\ ~(v1 = v2) ==> ~(ff v1 (r:real) = (ff v2 r):real^M) `; ASM_SIMP_TAC[IN_INSERT]; STRIP_TAC; EXISTS_TAC` min d d' `; REWRITE_TAC[REAL_LT_MIN]; ASM_REWRITE_TAC[]; FIRST_X_ASSUM NHANH; DOWN; FIRST_X_ASSUM NHANH; SIMP_TAC[IN_INSERT]; MESON_TAC[]]);;
let CONTINUOUS_ATREAL_DISTINCT = 
prove_by_refinement (`ff v continuous atreal r /\ ~((ff: real^N -> real -> real^M) v r = v0) ==> (?d. &0 < d /\ (!t. abs (t - r) < d ==> ~(ff v t = v0)))`,
[REWRITE_TAC[continuous_atreal; DIST_NZ]; IMP_TAC; DISCH_THEN (NHANH_PAT`\x. x ==> y `); STRIP_TAC; EXISTS_TAC` d:real `; ASM_REWRITE_TAC[]; FIRST_X_ASSUM NHANH; REPEAT STRIP_TAC; MP_TAC (ISPECL[` (ff:real^N -> real -> real^M ) v r `;` (ff:real^N -> real -> real^M ) v t `; `v0:real^M `] DIST_TRIANGLE); DOWN; REWRITE_TAC[DIST_SYM]; REAL_ARITH_TAC]);;
let CONTINUOUS_ATREAL_DISTINCT_FINITE = 
prove_by_refinement (`! V. FINITE (V:real^N -> bool) ==> (!v1. v1 IN V ==> ~(ff v1 r = (v0:real^M))) /\ (!v. v IN V ==> ff v continuous atreal r) ==> (?d. &0 < d /\ (!t. abs (t - r) < d ==> (!v1. v1 IN V ==> ~(ff v1 t = v0))))`,
[MATCH_MP_TAC FINITE_INDUCT; REWRITE_TAC[NOT_IN_EMPTY]; CONJ_TAC; EXISTS_TAC ` &1 `; REAL_ARITH_TAC; REPEAT STRIP_TAC; UNDISCH_TAC ` (!v1. (v1:real^N) IN s ==> ~(ff v1 r = (v0:real^M))) /\ (!v. v IN s ==> ff v continuous atreal r) ==> (?d. &0 < d /\ (!t. abs (t - r) < d ==> (!v1. v1 IN s ==> ~(ff v1 t = v0)))) `; ANTS_TAC; DOWN_TAC; SIMP_TAC[IN_INSERT]; STRIP_TAC; MP_TAC (SPEC`x:real^N ` (GEN`v:real^N` CONTINUOUS_ATREAL_DISTINCT)); ANTS_TAC; DOWN_TAC; SIMP_TAC[IN_INSERT]; STRIP_TAC; EXISTS_TAC` min d d' `; ASM_REWRITE_TAC[REAL_LT_MIN]; FIRST_X_ASSUM NHANH; DOWN; FIRST_X_ASSUM NHANH; SIMP_TAC[IN_INSERT]; MESON_TAC[]]);;
let REAL_CONTINUOUS_SUM_FUNS = 
prove_by_refinement (` f real_continuous at x /\ g real_continuous at x ==> (\x. f x + g x) real_continuous at x `,
[REWRITE_TAC[real_continuous_at]; STRIP_TAC; STRIP_TAC; PAT_ONCE_REWRITE_TAC`\x. x ==> y `[REAL_ARITH` &0 < a <=> &0 < a / &2 `]; FIRST_X_ASSUM (NHANH_PAT`\x. x ==> y `); FIRST_X_ASSUM (NHANH_PAT`\x. x /\ z ==> y `); STRIP_TAC; EXISTS_TAC` min d d' `; ASM_REWRITE_TAC[REAL_LT_MIN]; FIRST_X_ASSUM NHANH; DOWN; FIRST_X_ASSUM NHANH; STRIP_TAC THEN GEN_TAC; REAL_ARITH_TAC]);;
let REAL_CON_IMP_OPP_FUN_TOO = 
prove_by_refinement( ` f real_continuous at (x:real^N) ==> (\x. -- f x) real_continuous at x`,
[REWRITE_TAC[real_continuous_at]; REPEAT STRIP_TAC; SUBGOAL_THEN` (?d. &0 < d /\ (!x'. dist (x',(x:real^N)) < d ==> abs (f x' - f x) < e))` MP_TAC; DOWN; ASM_REWRITE_TAC[]; STRIP_TAC; EXISTS_TAC` d:real `; ASM_REWRITE_TAC[REAL_ARITH` -- x - -- y = -- (x - y ) `; REAL_ABS_NEG]]);;
let REAL_CONTINUOUS_SUB_FUNS = 
prove( ` f real_continuous at (x:real^N) /\ g real_continuous at x ==> (\x. f x - g x) real_continuous at x `,
STRIP_TAC THEN DOWN THEN NHANH_PAT`\x. x ==> y ` REAL_CON_IMP_OPP_FUN_TOO THEN STRIP_TAC THEN REWRITE_TAC[REAL_ARITH` a - b = a + -- b `] THEN MATCH_MP_TAC REAL_CONTINUOUS_SUM_FUNS THEN ASM_REWRITE_TAC[]);;
let INV_VNI = 
prove(` inv x = &1 / x `,
PAT_ONCE_REWRITE_TAC `\x. inv x = y` [REAL_ARITH` x = x / &1 `] THEN REWRITE_TAC[REAL_INV_DIV]);;
let INV_INEQUAL_GENERAL = 
prove( ` &0 < e /\ &0 < x /\ x < y ==> e / y < e / x `,
NHANH REAL_LT_INV2 THEN ONCE_REWRITE_TAC[REAL_ARITH` a / b = a * ( &1 / b ) `] THEN REWRITE_TAC[INV_VNI] THEN STRIP_TAC THEN MATCH_MP_TAC REAL_LT_LMUL THEN ASM_REWRITE_TAC[]);;
let REAL_CONTINUOUS_IMP_MUL_FUN = 
prove_by_refinement (` f real_continuous at (x:real^N) /\ g real_continuous at x ==> (\x. (f x) * (g x)) real_continuous at x `,
[REWRITE_TAC[real_continuous_at]; REPEAT STRIP_TAC; ONCE_REWRITE_TAC[REAL_RING` a * b - x * y = (a - x ) * b + (b - y) * x`]; FIRST_X_ASSUM (MP_TAC o (SPEC` e / (&2 * max (abs (f (x:real^N))) (&1))`)); ANTS_TAC; MATCH_MP_TAC REAL_LT_DIV; ASM_REWRITE_TAC[REAL_LT_MAX; REAL_ARITH` &0 < &2 * z <=> &0 < z `]; REAL_ARITH_TAC; STRIP_TAC; FIRST_X_ASSUM (MP_TAC o (SPEC` e / (&2 * (abs (g (x:real^N)) + e / (&2 * max (abs (f (x:real^N))) (&1))) )`)); ANTS_TAC; MATCH_MP_TAC REAL_LT_DIV; ASM_REWRITE_TAC[REAL_LT_MAX; REAL_ARITH` &0 < &2 * z <=> &0 < z `]; MATCH_MP_TAC (REAL_ARITH` &0 < x ==> &0 < abs a + x `); MATCH_MP_TAC REAL_LT_DIV; ASM_REWRITE_TAC[REAL_LT_MAX; REAL_ARITH` &0 < &2 * z <=> &0 < z `]; REAL_ARITH_TAC; STRIP_TAC; EXISTS_TAC `min d d'`; ASM_REWRITE_TAC[REAL_LT_MIN]; GEN_TAC; FIRST_X_ASSUM NHANH; FIRST_X_ASSUM NHANH; STRIP_TAC; SUBGOAL_THEN` abs (g (x':real^N)) < abs (g x) + e / (&2 * max (abs (f (x:real^N))) (&1))` MP_TAC; ASM_REAL_ARITH_TAC; ASM_CASES_TAC` f (x:real^N) = &0 `; FIRST_X_ASSUM SUBST_ALL_TAC; DOWN; SIMP_TAC[REAL_MUL_RZERO; REAL_ADD_RID; REAL_SUB_RZERO]; UNDISCH_TAC` &0 < e `; REWRITE_TAC[REAL_ABS_MUL]; REPEAT STRIP_TAC; SUBGOAL_THEN` abs (f (x':real^N)) * abs (g (x':real^N)) < ( e / (&2 * (abs (g x) + e / (&2 * max (abs (&0)) (&1))))) * (abs (g x) + e / (&2 * max (abs (&0)) (&1)))` MP_TAC; MATCH_MP_TAC REAL_LT_MUL2; ASM_REWRITE_TAC[REAL_ABS_POS; REAL_ABS_0; real_max; REAL_ARITH` &0 <= &1 `; REAL_MUL_RID]; ASSUME_TAC2 (REAL_ARITH` &0 < e ==> &0 < abs (g (x:real^N)) + e / &2`); DOWN; UNDISCH_TAC` &0 < e `; SIMP_TAC[REAL_FIELD` &0 < a ==> e / (&2 * a) * a = e / &2 `; REAL_ABS_0; real_max; REAL_ARITH` &0 <= &1 `; REAL_MUL_RID]; REAL_ARITH_TAC; STRIP_TAC; MATCH_MP_TAC (REAL_ARITH` abs a + abs b < e ==> abs ( a + b ) < e `); REWRITE_TAC[REAL_ABS_MUL]; MATCH_MP_TAC (REAL_ARITH` a < e / &2 /\ b < e / &2 ==> a + b < e `); CONJ_TAC; SUBGOAL_THEN` abs (f x' - f (x:real^N)) * abs (g x') < ( e / (&2 * (abs (g x) + e / (&2 * max (abs (f x)) (&1))))) * (abs (g x) + e / (&2 * max (abs (f x)) (&1)))` MP_TAC; MATCH_MP_TAC REAL_LT_MUL2; ASM_REWRITE_TAC[REAL_ABS_POS]; SUBGOAL_THEN` &0 < abs (g (x:real^N)) + e / (&2 * max (abs (f x)) (&1))` MP_TAC; MATCH_MP_TAC (REAL_ARITH` &0 < b ==> &0 < abs a + b `); MATCH_MP_TAC REAL_LT_DIV; ASM_REWRITE_TAC[]; REAL_ARITH_TAC; SIMP_TAC[REAL_FIELD` &0 < a ==> e / ( &2 * a ) * a = e / &2 `]; ASM_CASES_TAC` max (abs (f x)) (&1) = abs (f (x:real^N)) `; UNDISCH_TAC` ~( f (x:real^N) = &0) `; REWRITE_TAC[REAL_ABS_NZ]; UNDISCH_TAC` abs (g x' - g (x:real^N)) < e / (&2 * max (abs (f (x:real^N))) (&1))`; PHA; NHANH REAL_LT_RMUL; ASM_REWRITE_TAC[]; IMP_TAC; SIMP_TAC[REAL_FIELD` &0 < a ==> x / (&2 * a ) * a = x / &2 `]; SUBGOAL_THEN` e / &2 / max (abs (f x)) (&1) < e / &2 / abs (f (x:real^N))` MP_TAC; MATCH_MP_TAC INV_INEQUAL_GENERAL; ASM_REWRITE_TAC[REAL_ARITH`&0 < a / &2 <=> &0 < a `; GSYM REAL_ABS_NZ]; DOWN; REAL_ARITH_TAC; UNDISCH_TAC` abs (g x' - g (x:real^N)) < e / (&2 * max (abs (f (x:real^N))) (&1))`; PHA; REWRITE_TAC[REAL_FIELD` a / &2 / c = a / ( &2 * c ) `]; NHANH (REAL_ARITH` a < b /\ b < c ==> a < c `); STRIP_TAC; UNDISCH_TAC` ~( f (x:real^N) = &0)`; REWRITE_TAC[REAL_ABS_NZ]; DOWN THEN PHA; NHANH REAL_LT_RMUL; IMP_TAC; SIMP_TAC[REAL_FIELD` &0 < a ==> e / (&2 * a ) * a = e / &2 `]]);;
(* tch 2013/07/27. renamed variables t0 -> t in CON_ATREAL_REAL_CON CON_ATREAL_REAL_CON2 to avoid clash with constant t0 in Geomdetail. *)
let CON_ATREAL_REAL_CON = 
prove(`! f (v0:real^N). f continuous atreal t ==> (\t. dist ( f t, v0)) real_continuous atreal t `,
REWRITE_TAC[continuous_atreal; real_continuous_atreal] THEN REPEAT STRIP_TAC THEN DOWN THEN FIRST_X_ASSUM (NHANH_PAT `\x. x ==> y `) THEN STRIP_TAC THEN EXISTS_TAC` d:real` THEN ASM_REWRITE_TAC[] THEN FIRST_X_ASSUM NHANH THEN STRIP_TAC THEN CONV_TAC NORM_ARITH);;
let CON_ATREAL_REAL_CON2 = 
prove( `! f (v0:real^N). f continuous atreal t /\ g continuous atreal t ==> (\t. dist ( f t, g t)) real_continuous atreal t `,
REWRITE_TAC[continuous_atreal; real_continuous_atreal] THEN REPEAT STRIP_TAC THEN DOWN THEN PAT_ONCE_REWRITE_TAC`\x. x ==> y `[REAL_ARITH` &0 < a <=> &0 < a / &2 `] THEN REPEAT (FIRST_X_ASSUM (NHANH_PAT `\x. x ==> y `)) THEN STRIP_TAC THEN EXISTS_TAC `min d d'` THEN ASM_REWRITE_TAC[REAL_LT_MIN] THEN REPEAT (FIRST_X_ASSUM NHANH) THEN STRIP_TAC THEN CONV_TAC NORM_ARITH);;
(* ============================================================== *)
let SET2_HAS_SIZE2 = 
prove_by_refinement (` {(a: A),b} HAS_SIZE 2 <=> ~( a = b) `,
[REWRITE_TAC[HAS_SIZE_2_EXISTS; IN_INSERT; NOT_IN_EMPTY]; (* !s. s HAS_SIZE 2 <=> (?x y. ~(x = y) /\ (!z. z IN s <=> z = x \/ z = y))) *) EQ_TAC; STRIP_TAC; DOWN_TAC; MESON_TAC[]; STRIP_TAC; EXISTS_TAC` a: A`; EXISTS_TAC` b:A`; ASM_REWRITE_TAC[]]);;
let DIJ_AFF_GE_PARTITION = 
prove_by_refinement (` DISJOINT {u,v} {w} ==> aff_ge {u,v} {w} = aff {u,v} UNION aff_gt {u, v} {w} `,
[SIMP_TAC[Fan.AFF_GE_2_1; AFF2; AFF_GT_2_1]; STRIP_TAC; REWRITE_TAC[FUN_EQ_THM; IN_ELIM_THM; REWRITE_RULE[IN] IN_UNION]; STRIP_TAC; EQ_TAC; STRIP_TAC; ASM_CASES_TAC` t3 = &0 `; DISJ1_TAC; EXISTS_TAC `t1: real `; ASM_REWRITE_TAC[VECTOR_MUL_LZERO; VECTOR_ADD_RID]; UNDISCH_TAC` t1 + t2 + t3 = &1 `; ASM_SIMP_TAC[REAL_ADD_RID; REAL_ARITH` a + b = &1 <=> b = &1 - a `]; DISJ2_TAC; ASM_MESON_TAC[REAL_ARITH` &0 <= a /\ ~( a = &0) ==> &0 < a `]; STRIP_TAC; EXISTS_TAC` t: real `; EXISTS_TAC` &1 - t `; EXISTS_TAC` &0 `; ASM_REWRITE_TAC[REAL_LE_REFL; VECTOR_MUL_LZERO; VECTOR_ADD_RID]; REAL_ARITH_TAC; ASM_MESON_TAC[REAL_LT_IMP_LE]]);;
let AFF_GE_WEDGE_DISJOINTION = 
prove_by_refinement ( ` aff_ge {v0, v1} {w1} INTER wedge v0 v1 w1 w2 = {} /\ aff_ge {v0, v1} {w2} INTER wedge v0 v1 w1 w2 = {}`,
[ASM_CASES_TAC` collinear {v0, v1, w1:real^3} `; ASM_SIMP_TAC[WEDGE_DEGENERATE; INTER_EMPTY]; REWRITE_TAC[wedge]; CONJ_TAC; DOWN; ASM_SIMP_TAC[Local_lemmas.INTER_EQ_EM_EXPAND; GSYM Local_lemmas.AZIM_EQ_0_GE_ALT2]; REWRITE_TAC[IN_ELIM_THM]; REPEAT STRIP_TAC; DOWN THEN DOWN; ASM_REWRITE_TAC[]; REAL_ARITH_TAC; ASM_CASES_TAC` collinear {v0, v1, w2:real^3 } `; ASM_SIMP_TAC[AZIM_DEGENERATE; Local_lemmas.INTER_EQ_EM_EXPAND; IN_ELIM_THM]; REWRITE_TAC[REAL_ARITH` ~( a < x /\ x < a )`]; DOWN; NHANH Fan.th3a; NHANH DIJ_AFF_GE_PARTITION; SIMP_TAC[IN_UNION; Local_lemmas.INTER_EQ_EM_EXPAND; IN_ELIM_THM]; NHANH (REWRITE_RULE[CONTRAPOS_THM] Fan.th3c); REPEAT STRIP_TAC; DOWN THEN DOWN; ASM_SIMP_TAC[AZIM_DEGENERATE]; REAL_ARITH_TAC; ASSUME_TAC2 (SPECL [`v0:real^3 `;` v1:real^3`;` w1: real^3 `;`x:real^3 `;` w2: real^3 `]AZIM_EQ_ALT); ASM_MESON_TAC[REAL_ARITH` ~( a < a ) `]]);;
let HAS_SIZE_2_EXISTS2 = 
prove( ` S HAS_SIZE 2 <=> ? x y. ~( x = y) /\ S = {x,y} `,
REWRITE_TAC[HAS_SIZE_2_EXISTS] THEN SET_TAC[]);;
let FAN_E_SUB_V = 
prove( ` FAN (vec 0, V, E) /\ {x,y} IN E ==> x IN V /\ y IN V `,
REWRITE_TAC[FAN; UNIONS_SUBSET; SUBSET] THEN STRIP_TAC THEN DOWN THEN FIRST_ASSUM NHANH THEN SIMP_TAC[IN_INSERT]);;
let LOCAL_E_SUB_V = 
prove( ` local_fan (V,E,FF) /\ {x,y} IN E ==> x IN V /\ y IN V `,
REWRITE_TAC[local_fan] THEN LET_TAC THEN MESON_TAC[FAN_E_SUB_V]);;
let EDGE_NOT_INTER_WITH_WEDGE 
= 
prove(` aff {v0, v1} INTER wedge v0 v1 w1 w2 = {} `,
REWRITE_TAC[wedge; Local_lemmas.INTER_EQ_EM_EXPAND; IN_ELIM_THM] THEN NHANH Fan.th3c THEN MESON_TAC[]);;
let AFF_GE11_SUB_AFF2 = 
prove(` aff_ge {v0} {v1} SUBSET aff {v0, v1} `,
REWRITE_TAC[HALFLINE; AFF2; SUBSET; IN_ELIM_THM] THEN REPEAT STRIP_TAC THEN EXISTS_TAC` &1 - t ` THEN ASM_REWRITE_TAC[REAL_ARITH` a - (a - b) = b `]);;
let PROVE_SLICING_FAN = 
prove_by_refinement (`local_fan (V,E,FF) /\ v IN V /\ w IN V /\ ~( v = w) /\ (! z t. z IN {v, w} /\ t IN (V DIFF {z}) ==> ~ collinear {vec 0, z, t}) /\ (! x. x IN FF ==> aff_gt {vec 0} {v,w} SUBSET wedge_in_fan_gt x E) ==> FAN (vec 0, V, E UNION {{v,w}}) `,
[REWRITE_TAC[FAN; local_fan; UNIONS_UNION; UNIONS_1; UNION_SUBSET]; LET_TAC; SIMP_TAC[INSERT_SUBSET; EMPTY_SUBSET; graph; SET_RULE` (A UNION B) x <=> A x \/ B x `; MESON[]`(!x. P x \/ Q x ==> L x) <=> (! x. P x ==> L x ) /\ (! x. Q x ==> L x )`]; SIMP_TAC[SET2_HAS_SIZE2; Geomdetail.IN_ACT_SING]; ONCE_REWRITE_TAC[EQ_SYM_EQ]; SIMP_TAC[SET2_HAS_SIZE2; fan1; fan2; fan6; fan7; IN_UNION; MESON[]` (!x. P x \/ Q x ==> L x) <=> (! x. P x ==> L x) /\ (!x. Q x ==> L x) `; Geomdetail.IN_ACT_SING]; STRIP_TAC; CONJ_TAC; GEN_TAC; SIMP_TAC[Local_lemmas.INSERT_UNION2; UNION_EMPTY]; STRIP_TAC; FIRST_X_ASSUM MATCH_MP_TAC; ASM_REWRITE_TAC[IN_INSERT; IN_DIFF; NOT_IN_EMPTY]; ONCE_REWRITE_TAC[TAUT` (a \/ b) \/ c <=> b \/ a \/ c `]; ONCE_REWRITE_TAC[TAUT` (a \/ b) /\ (x \/ y) ==> l <=> ( a /\ x ==> l) /\ ( a /\ y ==> l ) /\ ( b /\ x ==> l) /\ (b /\ y ==> l) `]; ASM_SIMP_TAC[INTER_IDEMPOT]; MATCH_MP_TAC ( MESON[]` (! e1 e2. L e1 e2 ==> L e2 e1) /\ (! e1 e2. e1 = x /\ Q e2 ==> L x e2) ==> (! e1 e2. (e1 = x /\ Q e2 ==> L x e2) /\ (Q e1 /\ e2 = x ==> L e1 x))`); SIMP_TAC[INTER_COMM]; REPEAT STRIP_TAC; SUBGOAL_THEN` (e2: real^3 -> bool) HAS_SIZE 2` ASSUME_TAC; DOWN; ASM_REWRITE_TAC[IN]; DOWN; REWRITE_TAC[HAS_SIZE_2_EXISTS2]; STRIP_TAC; SUBGOAL_THEN` (x':real^3, y:real^3) IN FF \/ (y,x') IN FF ` MP_TAC; MATCH_MP_TAC Local_lemmas.LOFA_IN_E_IMP_IN_FF; ASM_REWRITE_TAC[local_fan]; LET_TAC; ASM_REWRITE_TAC[FAN; graph; fan1; fan6; fan7; fan2; IN_UNION]; CONJ_TAC; EXISTS_TAC` x:real^3 # real^3 `; ASM_REWRITE_TAC[]; FIRST_X_ASSUM (SUBST1_TAC o SYM); FIRST_ASSUM ACCEPT_TAC; ASM_REWRITE_TAC[]; DOWN THEN DOWN THEN PHA; SPEC_TAC (`x':real^3 `,` x': real^3 `); SPEC_TAC (`y:real^3 `,` y: real^3 `); REWRITE_TAC[TAUT` a /\ b /\ c <=> (a/\b) /\ c `]; MATCH_MP_TAC (MESON[]`(! x y. Q x y ==> Q y x) /\ (! x y. Q x y /\ P x y ==> L x y ) /\ (! x y. L x y ==> L y x) ==> (! (x:real^3) (y:real^3). Q x y /\ (P x y \/ P y x) ==> L x y )`); SIMP_TAC[INSERT_COMM]; REPEAT STRIP_TAC; SUBGOAL_THEN `~collinear {vec 0, v, w:real^3}` ASSUME_TAC; FIRST_X_ASSUM MATCH_MP_TAC; ASM_REWRITE_TAC[IN_INSERT; IN_DIFF; DE_MORGAN_THM; NOT_IN_EMPTY]; DOWN; NHANH Planarity.aff_ge_eq_aff_gt_union_aff_ge; SIMP_TAC[UNION_OVER_INTER]; STRIP_TAC; UNDISCH_TAC `y':real^3, y:real^3 IN FF `; FIRST_ASSUM NHANH; REWRITE_TAC[wedge_in_fan_gt]; SUBGOAL_THEN` local_fan (V,E,FF)` MP_TAC; ASM_REWRITE_TAC[IN_UNION; local_fan; FAN; fan1; fan2; fan6; fan7; graph]; LET_TAC; ASM_REWRITE_TAC[]; EXISTS_TAC` x:real^3 # real^3 `; ASM_REWRITE_TAC[]; STRIP_TAC; STRIP_TAC; ASSUME_TAC2 (SPEC`y': real^3 ` (GEN `x:real^3 ` Local_lemmas.LOCAL_FAN_IMP_IN_V)); SUBGOAL_THEN` CARD (EE (y':real^3) E) = 2 ` ASSUME_TAC; MATCH_MP_TAC Local_lemmas.LOFA_CARD_EE_V_1; ASM_SIMP_TAC[]; FIRST_X_ASSUM SUBST_ALL_TAC; DOWN THEN DOWN THEN PHA; REWRITE_TAC[ARITH_RULE` 2 > 1 `]; STRIP_TAC; MP_TAC (REWRITE_RULE[EMPTY_SUBSET; INSERT_SUBSET; IN_INSERT] (ISPECL [` {y':real^3} `;` {vec 0, y':real^3}`; `{y:real^3 }`] (GEN_ALL Local_lemmas.AFF_GE_MONO_TRANS))); SUBGOAL_THEN` ~ (y':real^3 = vec 0 )` MP_TAC; UNDISCH_TAC` y':real^3 IN V `; UNDISCH_TAC` ~( vec 0 IN (V:real^3 -> bool)) `; MESON_TAC[]; SIMP_TAC[SET_RULE` ~( y' = vec 0) ==> {vec 0, y'} DIFF {y'} = {vec 0} `]; REWRITE_TAC[Local_lemmas.INSERT_UNION2; UNION_EMPTY]; REPEAT STRIP_TAC; MP_TAC (SPECL [` vec 0:real^3 `;` y':real^3`;` y:real^3 `; ` (azim_cycle (EE y' E) (vec 0) y' y) `] (GEN_ALL AFF_GE_WEDGE_DISJOINTION)); STRIP_TAC; SUBGOAL_THEN` aff_ge {vec 0} {y:real^3, y'} INTER aff_gt {vec 0} {v, w} = {} ` MP_TAC; REPLICATE_TAC 3 DOWN THEN PHA; SET_TAC[]; SIMP_TAC[UNION_EMPTY]; STRIP_TAC; UNDISCH_TAC` !e1 e2. (e1 IN E \/ e1 IN {{v:real^3} | v IN V}) /\ (e2 IN E \/ e2 IN {{v} | v IN V}) ==> aff_ge {vec 0} e1 INTER aff_ge {vec 0} e2 = aff_ge {vec 0} (e1 INTER e2) `; STRIP_TAC; SUBGOAL_THEN` ({y, y'} IN E \/ {y, y'} IN {{v:real^3} | v IN V}) /\ ({v} IN E \/ {v} IN {{v} | v IN V})` MP_TAC; UNDISCH_TAC` (e2:real^3 -> bool) IN E `; ASM_SIMP_TAC[IN_ELIM_THM]; STRIP_TAC; DISJ2_TAC; EXISTS_TAC` v:real^3 `; ASM_REWRITE_TAC[]; FIRST_ASSUM NHANH; SIMP_TAC[]; REMOVE_TAC; SUBGOAL_THEN` ({y, y'} IN E \/ {y, y'} IN {{v:real^3} | v IN V}) /\ ({w} IN E \/ {w} IN {{v} | v IN V})` MP_TAC; UNDISCH_TAC` (e2:real^3 -> bool) IN E `; ASM_SIMP_TAC[IN_ELIM_THM]; STRIP_TAC; DISJ2_TAC; EXISTS_TAC` w:real^3 `; ASM_REWRITE_TAC[]; FIRST_ASSUM NHANH; SIMP_TAC[]; REMOVE_TAC; ASM_CASES_TAC` {y, y'} INTER {v, w:real^3} = {} `; DOWN; NHANH (SET_RULE` S INTER {a,b} = {} ==> S INTER {a} = {} /\ S INTER {b} = {}`); SIMP_TAC[UNION_IDEMPOT]; ASM_CASES_TAC` {y, y': real^3} INTER {v} = {} \/ {y, y': real^3} INTER {w} = {}`; DOWN THEN DOWN; SPEC_TAC (`w:real^3 `,` w:real^ 3 `); SPEC_TAC (`v:real^3 `,` v:real^ 3 `); MATCH_MP_TAC (MESON[]` (! x y. A x y ==> A y x) /\ (! x y. B x y ==> B y x ) /\ (! x y. A x y ==> M x ==> B x y) ==> (! x y. A x y ==> M x \/ M y ==> B x y ) `); SIMP_TAC[INSERT_COMM; UNION_COMM]; PHA; NHANH (SET_RULE` ~({y, y'} INTER {v, w} = {}) /\ {y, y'} INTER {v} = {} ==> {y, y'} INTER {v, w} = {w} /\ {y, y'} INTER {w} = {w}`); SIMP_TAC[]; REPEAT STRIP_TAC; REWRITE_TAC[AFF_GE_EQ_AFFINE_HULL; AFFINE_HULL_SING]; MATCH_MP_TAC (SET_RULE` x IN S ==> {x} UNION S = S `); REWRITE_TAC[IN_ELIM_THM; HALFLINE]; EXISTS_TAC ` &0 `; REWRITE_TAC[REAL_LE_REFL]; VECTOR_ARITH_TAC; DOWN THEN DOWN THEN PHA; UNDISCH_TAC` ~ ( w = v:real^3)`; PHA; NHANH (SET_RULE `~(w = v) /\ ~({y, y'} INTER {v, w} = {}) /\ ~({y, y'} INTER {v} = {} \/ {y, y'} INTER {w} = {}) ==> {y,y'} = {v, w} `); STRIP_TAC; UNDISCH_TAC` aff_ge {vec 0} {y, y'} INTER aff_gt {vec 0} {v:real^3, w} = {}`; ASM_REWRITE_TAC[]; NHANH (SET_RULE` (A UNION B) INTER A = {} ==> A = {} `); SUBGOAL_THEN` DISJOINT {vec 0} {v, w:real^3 }` MP_TAC; UNDISCH_TAC` ~( vec 0 IN (V:real^3 -> bool)) `; UNDISCH_TAC` (v:real^3) IN V `; UNDISCH_TAC` (w:real^3) IN V `; REWRITE_TAC[DISJOINT; Trigonometry2.INSERT_INTER_EMPTY; IN_INSERT; NOT_IN_EMPTY]; MESON_TAC[]; NHANH Planarity.AFF_GT_1_2; SIMP_TAC[]; REPEAT STRIP_TAC; DOWN; REWRITE_TAC[EXTENSION; IN_ELIM_THM; NOT_IN_EMPTY]; DISCH_THEN (MP_TAC o (SPEC` (&1 / &2) % v + (&1 / &2 ) % (w:real^3)`)); REWRITE_TAC[NOT_EXISTS_THM]; DISCH_THEN (MP_TAC o (SPECL [` &0 `;` &1 / &2`;` &1 / &2 `])); REWRITE_TAC[VECTOR_MUL_RZERO; VECTOR_ADD_LID; REAL_ARITH` &0 < &1 / &2 /\ &0 + &1 / &2 + &1 / &2 = &1`]; DOWN; REWRITE_TAC[IN_ELIM_THM]; STRIP_TAC; SUBGOAL_THEN` local_fan (V,E, FF) ` MP_TAC; ASM_REWRITE_TAC[local_fan; FAN; fan1; fan2; fan6; fan7; graph]; LET_TAC; ASM_REWRITE_TAC[IN_UNION]; EXISTS_TAC` x: real^3 # real^3 `; ASM_REWRITE_TAC[]; NHANH Local_lemmas.LOCAL_FAN_RHO_NODE_PROS2; STRIP_TAC; FIRST_ASSUM (ASSUME_TAC2 o (SPEC`v': real^3`)); UNDISCH_TAC` !x. x IN FF ==> aff_gt {vec 0} {v, w} SUBSET wedge_in_fan_gt x E`; DISCH_THEN (ASSUME_TAC2 o (SPEC `v',rho_node1 FF v' `)); SUBGOAL_THEN` ~((v:real^3 ) = vec 0)/\ ~( (w:real^3) = vec 0) ` MP_TAC; UNDISCH_TAC` v:real^3 IN V `; UNDISCH_TAC` w:real^3 IN V `; UNDISCH_TAC` ~( vec 0 IN (V:real^3 -> bool)) `; MESON_TAC[]; NHANH Wrgcvdr_cizmrrh.AFF_GE_TO_AFF_GT2_GE1; DOWN; REWRITE_TAC[wedge_in_fan_gt]; ASSUME_TAC2 ( SPEC` v':real^3 ` (GEN `v:real^3 ` Local_lemmas.LOFA_CARD_EE_V_1)); ASM_REWRITE_TAC[ARITH_RULE` 2 > 1 `]; MP_TAC (SPECL [` vec 0: real^3 `;` v': real^3 `; ` rho_node1 FF v' `; `(azim_cycle (EE v' E) (vec 0) v' (rho_node1 FF v')) `] (GEN_ALL EDGE_NOT_INTER_WITH_WEDGE)); MP_TAC (ISPECL [` vec 0:real^3 `;` v':real^3`] (GEN_ALL AFF_GE11_SUB_AFF2)); PHA; NHANH (SET_RULE` a SUBSET B /\ B INTER S = {} /\ l ==> a INTER S = {} `); STRIP_TAC; ASM_REWRITE_TAC[UNION_OVER_INTER]; SUBGOAL_THEN` aff_ge {vec 0} {v'} INTER aff_gt {vec 0} {v, w:real^3} = {}` ASSUME_TAC; DOWN; MATCH_MP_TAC (SET_RULE` a SUBSET b ==> x INTER b = {} ==> x INTER a = {} `); FIRST_X_ASSUM ACCEPT_TAC; ASM_REWRITE_TAC[UNION_EMPTY]; UNDISCH_TAC` !e1 e2. (e1 IN E \/ e1 IN {{v:real^3} | v IN V}) /\ (e2 IN E \/ e2 IN {{v} | v IN V}) ==> aff_ge {vec 0} e1 INTER aff_ge {vec 0} e2 = aff_ge {vec 0} (e1 INTER e2)`; STRIP_TAC; FIRST_ASSUM (MP_TAC o (SPECL [` {v':real^3} `;` {v:real^3}`])); ANTS_TAC; ASM_REWRITE_TAC[IN_ELIM_THM]; UNDISCH_TAC` v:real^3 IN V `; UNDISCH_TAC` v':real^3 IN V `; MESON_TAC[]; FIRST_ASSUM (MP_TAC o (SPECL [` {v':real^3} `;` {w:real^3}`])); ANTS_TAC; ASM_REWRITE_TAC[IN_ELIM_THM]; UNDISCH_TAC` w:real^3 IN V `; UNDISCH_TAC` v':real^3 IN V `; MESON_TAC[]; SIMP_TAC[]; REPEAT STRIP_TAC; ASM_CASES_TAC` {v'} INTER {v, w} = {v':real^3} `; DOWN; SIMP_TAC[]; UNDISCH_TAC` ~( w = (v:real^3) )`; PHA; NHANH (SET_RULE`{v'} INTER {v, w} = {v'} ==> v = v' \/ w = v' `); NHANH (SET_RULE` ~( a = b ) ==> {a} INTER {b} = {} `); STRIP_TAC; ASM_REWRITE_TAC[]; FIRST_X_ASSUM SUBST_ALL_TAC; DOWN THEN DOWN THEN PHA; SIMP_TAC[INTER_IDEMPOT; INTER_COMM; AFF_GE_EQ_AFFINE_HULL; AFFINE_HULL_SING]; STRIP_TAC; MP_TAC (ISPECL [` {vec 0:real^3 }`;` {v': real^3 }`] AFFINE_HULL_SUBSET_AFF_GE); ANTS_TAC; UNDISCH_TAC` ~((v':real^3) = vec 0) `; REWRITE_TAC[DISJOINT]; SET_TAC[]; REWRITE_TAC[AFFINE_HULL_SING]; SET_TAC[]; FIRST_X_ASSUM SUBST_ALL_TAC; ASM_REWRITE_TAC[]; DOWN THEN DOWN THEN PHA; SIMP_TAC[INTER_IDEMPOT; INTER_COMM; AFF_GE_EQ_AFFINE_HULL; AFFINE_HULL_SING]; MP_TAC (ISPECL [` {vec 0:real^3 }`;` {v': real^3 }`] AFFINE_HULL_SUBSET_AFF_GE); ANTS_TAC; UNDISCH_TAC` ~((v':real^3) = vec 0) `; REWRITE_TAC[DISJOINT]; SET_TAC[]; REWRITE_TAC[AFFINE_HULL_SING]; SET_TAC[]; DOWN; NHANH (SET_RULE` ~({v'} INTER {v, w} = {v'}) ==> {v'} INTER {v} = {} /\ {v'} INTER {w} = {} /\ {v, w} INTER {v'} = {}`); SIMP_TAC[UNION_IDEMPOT; INTER_COMM]]);;
let FACE_MAP_ADD_SET2_EQ = 
prove_by_refinement (` (x,y) IN darts_of_hyp ( E UNION {{a,b}}) V /\ ~( y = a) /\ ~ ( y = b ) /\ FAN (vec 0, V, E) /\ FAN (vec 0, V, E UNION {{a,b}} ) ==> (face_map (hypermap ( HYP (vec 0, V, (E UNION {{a,b}}))))) (x,y) = (face_map (hypermap (HYP (vec 0, V, E)))) (x,y) `,
[NHANH Wrgcvdr_cizmrrh.ELMS_OF_HYPERMAP_HYP; SIMP_TAC[]; STRIP_TAC; SUBGOAL_THEN` (x,y) IN darts_of_hyp ( E UNION {{a,b:real^3}}) V ` MP_TAC; ASM_REWRITE_TAC[]; REWRITE_TAC[darts_of_hyp; IN_UNION]; DISCH_TAC; SUBGOAL_THEN` (x,y) IN darts_of_hyp E (V:real^3 -> bool) ` MP_TAC; REWRITE_TAC[darts_of_hyp; IN_UNION]; DOWN THEN STRIP_TAC; DISJ1_TAC; DOWN; REWRITE_TAC[ord_pairs; IN_ELIM_THM; IN_UNION]; STRIP_TAC; EXISTS_TAC` a': real^3 `; EXISTS_TAC` b': real^3 `; ASM_REWRITE_TAC[]; DOWN THEN DOWN; REWRITE_TAC[IN_SING; PAIR_EQ; Collect_geom.PAIR_EQ_EXPAND]; REPEAT STRIP_TAC; UNDISCH_TAC` ~( y = b:real^3 ) `; ASM_REWRITE_TAC[]; UNDISCH_TAC` ~( y = a:real^3) `; ASM_REWRITE_TAC[]; DOWN; REWRITE_TAC[self_pairs; IN_ELIM_THM]; STRIP_TAC; DISJ2_TAC; EXISTS_TAC` v:real^3 `; ASM_REWRITE_TAC[]; DOWN THEN DOWN; SIMP_TAC[EE; IN_UNION]; SET_TAC[]; ASM_SIMP_TAC[ff_of_hyp]; SUBGOAL_THEN` (EE y (E UNION {{a, b}})) = (EE (y:real^3) E)` SUBST1_TAC; REWRITE_TAC[EE; EXTENSION; IN_ELIM_THM; IN_UNION]; GEN_TAC; MATCH_MP_TAC (TAUT` (a ==> b) ==> ( b \/ a <=> b )`); REWRITE_TAC[IN_SING; Collect_geom.PAIR_EQ_EXPAND]; ASM_REWRITE_TAC[]; PHA]);;
(* ========================================================== *) (* ========================================================== *)
let LOCAL_FACE_MAP_RHO_NODE1 = 
prove_by_refinement (` local_fan (V,E,FF) /\ (x,y) IN FF ==> face_map ( hypermap (HYP (vec 0,V,E))) (x,y) = (rho_node1 FF x, rho_node1 FF y ) `,
[NHANH Wrgcvdr_cizmrrh.LOCAL_FAN_IMP_FAN; NHANH Wrgcvdr_cizmrrh.ELMS_OF_HYPERMAP_HYP; SIMP_TAC[]; NHANH Local_lemmas.LOFA_DARTS_FF_UNION_SWITCH_FF; STRIP_TAC; SUBGOAL_THEN` x,y IN darts_of_hyp E (V:real^3 -> bool) ` MP_TAC; ASM_REWRITE_TAC[IN_UNION]; SIMP_TAC[ff_of_hyp]; ASSUME_TAC2 (SPECL [` x:real^3 `;` y:real^3 `] ( GENL [`v: real^3 `;` w:real^3 `] Local_lemmas.DETER_RHO_NODE)); ASM_REWRITE_TAC[PAIR_EQ]; ASSUME_TAC2 Local_lemmas.LOCAL_FAN_IMP_IN_V; DOWN THEN STRIP_TAC; ASSUME_TAC2 (SPECL [`x:real^3 `;` y:real^3 `] ( GENL [`vv: real^ 3 `;` v: real^3 `] Local_lemmas.LOFA_IMP_EE_TWO_ELMS)); ASM_REWRITE_TAC[ivs_azim_cycle; SET_RULE` ~( x INSERT S = {} )`]; ABBREV_TAC` tt = (@x'. x' IN {rho_node1 FF y, x} /\ azim_cycle {rho_node1 FF y, x} (vec 0) y x' = x)` ; SUBGOAL_THEN`tt IN {rho_node1 FF y, x} /\ azim_cycle {rho_node1 FF y, x} (vec 0) y tt = x` MP_TAC; EXPAND_TAC "tt";
REWRITE_TAC[MESON[EXISTS_THM]` (@x'. x' IN {rho_node1 FF y, x} /\ azim_cycle {rho_node1 FF y, x} (vec 0) y x' = x) IN {rho_node1 FF y, x} /\ azim_cycle {rho_node1 FF y, x} (vec 0) y (@x'. x' IN {rho_node1 FF y, x} /\ azim_cycle {rho_node1 FF y, x} (vec 0) y x' = x) = x <=> ? x'. x' IN {rho_node1 FF y, x} /\ azim_cycle {rho_node1 FF y, x} (vec 0) y x' = x `]; EXISTS_TAC` rho_node1 FF y `; REWRITE_TAC[IN_INSERT; Local_lemmas.AZIM_CYCLE_TWO_POINT_SET; IN_INSERT; NOT_IN_EMPTY]; REWRITE_TAC[IN_INSERT; Local_lemmas.AZIM_CYCLE_TWO_POINT_SET; IN_INSERT; NOT_IN_EMPTY]; STRIP_TAC; ASM_REWRITE_TAC[]; DOWN; ASM_REWRITE_TAC[INSERT_COMM; Local_lemmas.AZIM_CYCLE_TWO_POINT_SET]; ASSUME_TAC2 (SPEC `y:real^3 ` (GEN `v:real^3 ` Local_lemmas.LOFA_CARD_EE_V_1)); DOWN; ASM_SIMP_TAC[Geomdetail.CARD2]]);;
let IN_DARTS_EXTENSION = 
prove( ` {x:A,y} IN E ==> x,y IN darts_of_hyp (E UNION S) V `,
REWRITE_TAC[darts_of_hyp; IN_UNION; ord_pairs; IN_ELIM_THM; PAIR_EQ] THEN STRIP_TAC THEN DISJ1_TAC THEN EXISTS_TAC` x:A` THEN EXISTS_TAC` y:A ` THEN ASM_REWRITE_TAC[]);;
let LOCAL_RHO_NODE_PAIR_E = 
prove( `! v. local_fan (V,E,FF) /\ v IN V ==> {v, rho_node1 FF v} IN E `,
NHANH Local_lemmas.LOCAL_FAN_RHO_NODE_PROS2 THEN REPEAT STRIP_TAC THEN DOWN THEN FIRST_X_ASSUM NHANH THEN ASM_MESON_TAC[Local_lemmas.LOCAL_FAN_IN_FF_IN_ORD_PAIRS2]);;
let LOFA_HYP_UNION_CARD_GT2 = 
prove_by_refinement (`(local_fan (V,E,FF) /\ v IN V /\ w IN V /\ ~(v = w) /\ (!z t. z IN {v, w} /\ t IN V DIFF {z} ==> ~collinear {vec 0, z, t}) /\ (!x. x IN FF ==> aff_gt {vec 0} {v, w} SUBSET wedge_in_fan_gt x E)) /\ HS = hypermap ( HYP (vec 0,V,E UNION {{v, w}})) /\ fv = face HS (v, rho_node1 FF v) ==> 2 < CARD fv `,
[NHANH PROVE_SLICING_FAN; NHANH Local_lemmas.LOCAL_FAN_CHARACTER_OF_RHO_NODE; NHANH Local_lemmas.LOCAL_FAN_RHO_NODE_PROS2; STRIP_TAC; SUBGOAL_THEN` ~(rho_node1 FF v = w) ` ASSUME_TAC; USE_FIRST ` !x. x IN V ==> x,rho_node1 FF x IN FF ` (ASSUME_TAC2 o (SPEC`v: real^3 `)); DOWN; USE_FIRST` !x. x IN FF ==> aff_gt {vec 0} {v, w} SUBSET wedge_in_fan_gt x E ` NHANH; REWRITE_TAC[wedge_in_fan_gt]; ASSUME_TAC2 Local_lemmas.LOFA_CARD_EE_V_1; ASM_REWRITE_TAC[ARITH_RULE` 2 > 1 `]; MP_TAC (ISPECL [` {v:real^3} `; ` {vec 0, v:real^3} `;` {rho_node1 FF v} `] (GEN_ALL Local_lemmas.AFF_GE_MONO_TRANS)); ANTS_TAC; SIMP_TAC[SUBSET; IN_SING; IN_INSERT]; SUBGOAL_THEN` FAN (vec 0,V,E UNION {{v:real^3, w}}) ` MP_TAC; FIRST_X_ASSUM ACCEPT_TAC; REWRITE_TAC[FAN; fan1; fan2]; STRIP_TAC; SUBGOAL_THEN ` ~( v:real^3 = vec 0) ` MP_TAC; ASM_MESON_TAC[]; SIMP_TAC[SET_RULE` ~( a = b) ==> {b,a} DIFF {a} = {b} `; SET_RULE` {a} UNION {b} = {b,a}`]; REPEAT STRIP_TAC; MP_TAC (SPECL [`vec 0: real^3 `;` v: real^3 `;` rho_node1 FF v `; ` (azim_cycle (EE v E) (vec 0) v (rho_node1 FF v)) ` ] (GEN_ALL AFF_GE_WEDGE_DISJOINTION)); ABBREV_TAC` tv = azim_cycle (EE v E) (vec 0) v (rho_node1 FF v) `; STRIP_TAC; UNDISCH_TAC` aff_gt {vec 0} {v, w} SUBSET wedge (vec 0) v (rho_node1 FF v) tv `; UNDISCH_TAC` aff_ge {vec 0, v} {rho_node1 FF v} INTER wedge (vec 0) v (rho_node1 FF v) tv = {} `; MP_TAC (ISPECL [` {vec 0: real^ 3} `; ` {v, w:real^3} `] AFF_GT_SUBSET_AFF_GE); ASM_REWRITE_TAC[]; MATCH_MP_TAC ( SET_RULE` ge12 SUBSET ge21 /\ ~( gt = {} ) ==> gt SUBSET ge12 ==> ge21 INTER we = {} ==> ~( gt SUBSET we ) `); UNDISCH_TAC` aff_ge {vec 0} {v, rho_node1 FF v} SUBSET aff_ge {vec 0, v} {rho_node1 FF v}`; ASM_SIMP_TAC[]; STRIP_TAC; SUBGOAL_THEN` DISJOINT {vec 0} {v, w:real^3}` MP_TAC; REWRITE_TAC[SET_RULE` DISJOINT {a} {x,y} <=> ~( x = a) /\ ~( y = a) `]; ASM_REWRITE_TAC[]; UNDISCH_TAC` ~( vec 0:real^3 IN V ) `; UNDISCH_TAC` w:real^3 IN V `; MESON_TAC[]; SIMP_TAC[Planarity.AFF_GT_1_2; EXTENSION; IN_ELIM_THM; NOT_IN_EMPTY]; REPEAT STRIP_TAC; FIRST_ASSUM (MP_TAC o (SPEC` &1 / &2 % v + &1 / &2 % (w:real^3) `)); REWRITE_TAC[]; EXISTS_TAC` &0 `; EXISTS_TAC` &1 / &2 `; EXISTS_TAC` &1 / &2 `; REWRITE_TAC[REAL_ARITH` &0 < &1 / &2 /\ &0 < &1 / &2 /\ &0 + &1 / &2 + &1 / &2 = &1 `]; REWRITE_TAC[VECTOR_ARITH` &0 % v + x = x `]; ASM_CASES_TAC` rho_node1 FF ( rho_node1 FF v) = v `; ASSUME_TAC2 Local_lemmas.LOCAL_FAN_ORBIT_MAP_V; FIRST_ASSUM (ASSUME_TAC2 o (SPEC `v:real^3 `)); REPLICATE_TAC 3 DOWN; NHANH (GEN_ALL Local_lemmas.ORD2_ORBIT_MAP); SIMP_TAC[]; REPEAT STRIP_TAC; UNDISCH_TAC` w IN (V:real^3 -> bool) `; EXPAND_TAC "V";
REWRITE_TAC[IN_INSERT; NOT_IN_EMPTY]; ASM_REWRITE_TAC[]; ASSUME_TAC2 (SPEC_ALL LOCAL_RHO_NODE_PAIR_E); DOWN; NHANH (ISPEC ` {{v, w:real^3}} ` (GEN `S: (A -> bool) -> bool` IN_DARTS_EXTENSION)); DOWN THEN STRIP_TAC; ASSUME_TAC2 Wrgcvdr_cizmrrh.LOCAL_FAN_IMP_FAN; NHANH (ONCE_REWRITE_RULE[TAUT` a /\ b ==> c <=> a ==> b ==> c `] FACE_MAP_ADD_SET2_EQ); STRIP_TAC; DOWN; ANTS_TAC; USE_FIRST` !v. v IN V ==> ~(rho_node1 FF v = v) /\ v,rho_node1 FF v IN ord_pairs E /\ ~collinear {vec 0, v, rho_node1 FF v} ` (ASSUME_TAC2 o SPEC_ALL); ASM_REWRITE_TAC[]; USE_FIRST` !x. x IN V ==> x,rho_node1 FF x IN FF ` (ASSUME_TAC2 o (SPEC` v:real^3 `)); ASSUME_TAC2 ( SPECL [` v:real^3 `;` rho_node1 FF v `] ( GENL [`x:real^3`;` y:real^3 `] LOCAL_FACE_MAP_RHO_NODE1)); SWITCH_TAC` HS = hypermap (HYP (vec 0,V,E UNION {{v, w:real^3}})) `; SWITCH_TAC` fv = face HS (v,rho_node1 FF (v:real^3))`; ASM_REWRITE_TAC[]; ASSUME_TAC2 Local_lemmas.LOFA_IN_V_SO_DO_RHO_NODE_V; ASSUME_TAC2 (SPEC ` rho_node1 FF v` LOCAL_RHO_NODE_PAIR_E); DOWN; NHANH (ISPEC ` {{v, w:real^3}} ` (GEN `S: (A -> bool) -> bool` IN_DARTS_EXTENSION)); REPEAT STRIP_TAC; SUBGOAL_THEN` v, rho_node1 FF v IN fv /\ rho_node1 FF v,rho_node1 FF (rho_node1 FF v) IN fv /\ face_map HS (rho_node1 FF v,rho_node1 FF (rho_node1 FF v)) IN fv ` MP_TAC; SUBGOAL_THEN` v,rho_node1 FF v IN fv /\ rho_node1 FF v,rho_node1 FF (rho_node1 FF v) IN fv ` MP_TAC; EXPAND_TAC "fv"; REWRITE_TAC[face; orbit_map; IN_ELIM_THM]; CONJ_TAC; EXISTS_TAC `0`; REWRITE_TAC[ARITH_RULE` 0 >= 0`; POWER; I_THM]; EXISTS_TAC` 1 `; ASM_REWRITE_TAC[POWER_TO_ITER; ITER12; ARITH_RULE` 1 >= 0 `]; SIMP_TAC[]; EXPAND_TAC "fv"; SIMP_TAC[face; Wrgcvdr_cizmrrh.IN_ORBIT_MAP_IMP_F_Y]; UNDISCH_TAC` FAN (vec 0,V,E UNION {{v, w:real^3}})`; NHANH Wrgcvdr_cizmrrh.ELMS_OF_HYPERMAP_HYP; ASM_SIMP_TAC[]; STRIP_TAC; UNDISCH_TAC` rho_node1 FF v,rho_node1 FF (rho_node1 FF v) IN darts_of_hyp (E UNION {{v, w}}) V `; SIMP_TAC[ff_of_hyp]; ABBREV_TAC` rh1 = rho_node1 FF v `; ABBREV_TAC` rr2 = ivs_azim_cycle (EE (rho_node1 FF rh1) (E UNION {{v, w}})) (vec 0) (rho_node1 FF rh1) rh1 `; REPEAT STRIP_TAC; SUBGOAL_THEN` ~((v:real^3, rh1 :real^3) = rh1,rho_node1 FF rh1) /\ ~( rh1,rho_node1 FF rh1 = rho_node1 FF rh1, rr2 ) /\ ~( v, rh1 = rho_node1 FF rh1, rr2 ) ` MP_TAC; ASM_REWRITE_TAC[PAIR_EQ]; USE_FIRST` !v. v IN V ==> ~(rho_node1 FF v = v) /\ v,rho_node1 FF v IN ord_pairs E /\ ~collinear {vec 0, v, rho_node1 FF v} ` (MP_TAC o SPEC_ALL); ANTS_TAC; FIRST_ASSUM ACCEPT_TAC; FIRST_ASSUM (ASSUME_TAC2 o (SPEC` rh1: real^3 `)); ASM_SIMP_TAC[]; STRIP_TAC; MP_TAC (ISPECL [` HS: (real^3#real^3)hypermap `; ` (v:real^3, rh1: real^3) `] Hypermap.FACE_FINITE); STRIP_TAC; SUBGOAL_THEN` CARD {(v,rh1), (rh1,rho_node1 FF rh1), (rho_node1 FF rh1,rr2)} <= CARD (fv:real^3 # real^3 -> bool) ` MP_TAC; MATCH_MP_TAC CARD_SUBSET; DOWN; ASM_SIMP_TAC[INSERT_SUBSET; EMPTY_SUBSET]; SUBGOAL_THEN` CARD {(v,rh1), (rh1,rho_node1 FF rh1), (rho_node1 FF rh1,rr2)} = 3 ` SUBST1_TAC; ASM_REWRITE_TAC[Geomdetail.CARD3]; ARITH_TAC]);; (* = *)
let LOCAL_FAN_SIMPLE_HYP = 
prove_by_refinement (` local_fan (V,E,FF) ==> simple_hypermap (hypermap (HYP (vec 0, V,E))) `,
[REWRITE_TAC[local_fan]; LET_TAC; STRIP_TAC; ASM_CASES_TAC` CARD (FF:real^3 # real^3 -> bool) = 0 `; DOWN; ASM_REWRITE_TAC[]; REWRITE_TAC[MATCH_MP (ISPEC` face H (x:A)` CARD_EQ_0) (SPEC_ALL Hypermap.FACE_FINITE)]; REWRITE_TAC[EXTENSION; NOT_IN_EMPTY]; MESON_TAC[Hypermap.face_refl]; DOWN THEN DOWN THEN PHA; REWRITE_TAC[Lvducxu.DIH2K_IMP_SIMPLE_HYPERMAP2]]);;
(* RITE_TAC[Lvducxu.DIH2K_IMP_SIMPLE_HYPERMAP2];; *)
let EE_UNION = 
prove(` EE v ( E UNION S) = EE v E UNION EE v S `,
REWRITE_TAC[EE; IN_UNION; EXTENSION; IN_ELIM_THM]);;
let EE_SING_SING = 
prove(` EE v {{v,w}} = {w} `,
REWRITE_TAC[EE; EXTENSION; IN_ELIM_THM; IN_SING; IN_INSERT] THEN MESON_TAC[]);;
let CROSS_PAIR_NOT_IN_FF = 
prove_by_refinement (` local_fan (V,E,FF) /\ v IN V /\ w IN V /\ ~(v = w) /\ (!x. x IN FF ==> aff_gt {vec 0} {v, w} SUBSET wedge_in_fan_gt x E) ==> ~((v,w) IN FF) `,
[STRIP_TAC; FIRST_ASSUM NHANH; REWRITE_TAC[wedge_in_fan_gt]; ASSUME_TAC2 Local_lemmas.LOFA_CARD_EE_V_1; ASM_REWRITE_TAC[ARITH_RULE` 2 > 1 `]; MP_TAC (SPECL [` vec 0: real^3 `;` v:real^3 `;`w:real^3 `; ` azim_cycle (EE v E) (vec 0) v w`] (GEN_ALL AFF_GE_WEDGE_DISJOINTION)); SUBGOAL_THEN` &1 / &2 % v + &1 / &2 % (w:real^3) IN aff_ge {vec 0, v} {w} /\ &1 / &2 % v + &1 / &2 % (w:real^3) IN aff_gt {vec 0} {v, w} ` MP_TAC; SUBGOAL_THEN` DISJOINT {vec 0, v:real^3} {w} /\ DISJOINT {vec 0} {v, w:real^3} ` MP_TAC; REWRITE_TAC[DISJOINT]; ASSUME_TAC2 Local_lemmas.LOFA_IMP_V_DIFF; REWRITE_TAC[EXTENSION; NOT_IN_EMPTY; IN_INTER; IN_INSERT]; ASM_MESON_TAC[]; SIMP_TAC[Fan.AFF_GE_2_1; Planarity.AFF_GT_1_2; IN_ELIM_THM]; STRIP_TAC; CONJ_TAC; EXISTS_TAC` &0 `; EXISTS_TAC` &1 / &2 `; EXISTS_TAC` &1 / &2 `; REWRITE_TAC[VECTOR_MUL_LZERO; VECTOR_ADD_LID]; REAL_ARITH_TAC; EXISTS_TAC` &0 `; EXISTS_TAC` &1 / &2 `; EXISTS_TAC` &1 / &2 `; REWRITE_TAC[VECTOR_MUL_LZERO; VECTOR_ADD_LID]; REAL_ARITH_TAC; SET_TAC[]]);;
(* = *) let AZ_REFL11 = REWRITE_RULE[] (SPECL [`v:real^3`;` v:real^3`] (CONJUNCT1 AZIM_DEGENERATE));;
let AZIM_POS_IMP_CYCLIC_SET = 
prove_by_refinement (` &0 < azim v0 v1 w1 w2 ==> cyclic_set {w1, w2} v0 v1 `,
[REWRITE_TAC[cyclic_set]; STRIP_TAC; CONJ_TAC; STRIP_TAC; FIRST_X_ASSUM SUBST_ALL_TAC; DOWN; REWRITE_TAC[AZ_REFL11]; REAL_ARITH_TAC; REWRITE_TAC[Geomdetail.FINITE6]; ASM_CASES_TAC` v0 = v1:real^3 `; FIRST_X_ASSUM SUBST_ALL_TAC; DOWN; REWRITE_TAC[AZ_REFL11; REAL_ARITH` ~( a < a ) `]; ASM_CASES_TAC` w1 IN affine hull {v0, v1:real^3}`; DOWN; NHANH (REWRITE_RULE[CONTRAPOS_THM; aff] Fan.th3c); STRIP_TAC; UNDISCH_TAC` &0 < azim v0 v1 w1 w2 `; ASM_SIMP_TAC[AZIM_DEGENERATE; REAL_ARITH` ~( a < a ) `]; ASM_CASES_TAC` w2 IN affine hull {v0, v1:real^3}`; DOWN; NHANH (REWRITE_RULE[CONTRAPOS_THM; aff] Fan.th3c); STRIP_TAC; UNDISCH_TAC` &0 < azim v0 v1 w1 w2 `; ASM_SIMP_TAC[AZIM_DEGENERATE; REAL_ARITH` ~( a < a ) `]; REWRITE_TAC[EXTENSION; IN_ELIM_THM; NOT_IN_EMPTY; IN_INSERT; IN_INTER]; CONJ_TAC; REWRITE_TAC[SET_RULE` ( {w1, w2} p /\ {w1, w2} q /\ L ==> p = q ) <=> ( p = w1 /\ q = w2 /\ L ==> p = q ) /\ (p = w2 /\ q = w1 /\ L ==> p = q )`]; MATCH_MP_TAC ( MESON[]` ( ! h. w1 = w2 + h % (v0 - v1) ==> w1 = w2 ) /\ (! h. w2 = w1 + h % (v0 - v1) ==> w1 = w2 + ( -- h) % ( v0 - v1 )) ==> !p q h. (p = w1 /\ q = w2 /\ p = q + h % (v0 - v1) ==> p = q) /\ (p = w2 /\ q = w1 /\ p = q + h % (v0 - v1) ==> p = q)`); CONJ_TAC; REPEAT STRIP_TAC; SUBGOAL_THEN` w1 IN aff_ge {v0, v1} {w2:real^3} ` MP_TAC; DOWN; ASSUME_TAC2 (ISPECL [` v0:real^3 `;` v1:real^3 `; `w2:real^3 `] COLLINEAR_3_AFFINE_HULL); UNDISCH_TAC` ~(w2 IN affine hull {v0, v1: real^3})`; FIRST_X_ASSUM (SUBST1_TAC o SYM); NHANH Fan.th3a; NHANH Collect_geom.simp_def_ge; SIMP_TAC[IN_ELIM_THM]; REPEAT STRIP_TAC; EXISTS_TAC` h:real` ; EXISTS_TAC` -- h:real` ; EXISTS_TAC` &1 `; REWRITE_TAC[REAL_ARITH` a + -- a + b = b /\ &0 <= &1 `]; VECTOR_ARITH_TAC; ASSUME_TAC2 (ISPECL [` v1:real^3 `;` v0: real^3 `; ` w2:real ^3 `] (GSYM COLLINEAR_3_AFFINE_HULL)); UNDISCH_TAC ` ~(w2 IN affine hull {v0, v1:real^3})`; DOWN; ASM_SIMP_TAC[INSERT_COMM]; SIMP_TAC[ GSYM Local_lemmas.AZIM_EQ_0_GE_ALT2]; FIRST_X_ASSUM (SUBST_ALL_TAC o SYM); REPEAT STRIP_TAC; UNDISCH_TAC` &0 < azim v0 v1 w1 w2 `; DOWN; ASM_SIMP_TAC[Local_lemmas.AZIM_EQ_0_SYM2; REAL_ARITH` ~( a < a ) `]; GEN_TAC; VECTOR_ARITH_TAC; GEN_TAC; REWRITE_TAC[DE_MORGAN_THM]; ASM_MESON_TAC[]]);;
let AZIM_POS_IMP_SUM_2PI = 
prove( ` &0 < azim a b c d ==> azim a b c d + azim a b d c = &2 * pi `,
NHANH AZIM_POS_IMP_CYCLIC_SET THEN NHANH Trigonometry2.YVREJIS THEN MESON_TAC[REAL_ARITH` a < b ==> ~( b = a ) `]);;
(* = *)
let FACE_MAP_AT_TURNING_DART = 
prove_by_refinement (` (local_fan (V,E,FF) /\ v IN V /\ w IN V /\ ~(v = w) /\ (!z t. z IN {v, w} /\ t IN V DIFF {z} ==> ~collinear {vec 0, z, t}) /\ (!x. x IN FF ==> aff_gt {vec 0} {v, w} SUBSET wedge_in_fan_gt x E)) /\ (x,v) IN FF ==> face_map (hypermap (HYP (vec 0,V,E UNION {{v, w}}))) (x,v) = (v, w)`,
[NHANH PROVE_SLICING_FAN; NHANH Wrgcvdr_cizmrrh.ELMS_OF_HYPERMAP_HYP; SIMP_TAC[]; STRIP_TAC; ASSUME_TAC2 (SPECL [`x:real^3 `;` v:real^3 `] ( GENL [`x:real^3 `;` y:real^3 `] Local_lemmas.LOCAL_FAN_IN_FF_IN_ORD_PAIRS2)); DOWN THEN NHANH (ISPEC `{{v, w:real^3}} ` (GEN` S: (A -> bool) -> bool ` IN_DARTS_EXTENSION)); SIMP_TAC[ff_of_hyp; PAIR_EQ]; STRIP_TAC; ASSUME_TAC2 (SET_RULE` {x,v:real^3} IN E ==> {x,v} IN E UNION {{v,w}} `); DOWN; PAT_ONCE_REWRITE_TAC`\x. x IN Y ==> L ` [INSERT_COMM]; UNDISCH_TAC` FAN (vec 0,V,E UNION {{v, w:real^3}})`; PHA; NHANH Wrgcvdr_cizmrrh.IVS_AZIM_EQ_INVERSE_SIGMA_FAN; SIMP_TAC[]; NHANH (GSYM Wrgcvdr_cizmrrh.FAN_IMP_EE_EQ_SET_OF_EDGE); STRIP_TAC; MATCH_MP_TAC (REWRITE_RULE[TAUT` a ==> b ==> c <=> a /\ b ==> c `] Wrgcvdr_cizmrrh.SIG_AND_INVERSE1_SIG); ASM_REWRITE_TAC[IN_UNION; IN_SING]; MATCH_MP_TAC Fan.UNIQUE_SIGMA_FAN; ASM_REWRITE_TAC[]; ASSUME_TAC2 (SPECL [` x:real^3 `;` v:real^3 `] (GENL [` v:real^3 `;` w:real^3 `] Local_lemmas.DETER_RHO_NODE)); SUBGOAL_THEN` x:real^3 IN V /\ v IN V ` MP_TAC; MATCH_MP_TAC Local_lemmas.LOCAL_FAN_IMP_IN_V; ASM_REWRITE_TAC[]; STRIP_TAC; ASSUME_TAC2 (SPEC` x:real^3 ` (GEN `vv:real^3 ` Local_lemmas.LOFA_IMP_EE_TWO_ELMS)); ASM_REWRITE_TAC[EE_UNION; EE_SING_SING; IN_UNION; IN_SING; IN_INSERT]; SUBGOAL_THEN` ~( x = w:real^3 ) ` MP_TAC; STRIP_TAC; FIRST_X_ASSUM SUBST_ALL_TAC; ASSUME_TAC2 Local_lemmas.LOCAL_FAN_RHO_NODE_PROS2; DOWN THEN STRIP_TAC; UNDISCH_TAC` w:real^3 IN V `; PHA; FIRST_ASSUM NHANH; STRIP_TAC; DOWN THEN PHA; MATCH_MP_TAC CROSS_PAIR_NOT_IN_FF; ASM_REWRITE_TAC[]; ONCE_REWRITE_TAC[INSERT_COMM]; FIRST_ASSUM ACCEPT_TAC; SIMP_TAC[]; STRIP_TAC; CONJ_TAC; DOWN THEN SET_TAC[]; REPEAT STRIP_TAC; ASSUME_TAC2 Local_lemmas.LOCAL_FAN_RHO_NODE_PROS2; DOWN THEN STRIP_TAC; UNDISCH_TAC` v:real^3 IN V `; FIRST_ASSUM NHANH; USE_FIRST` !x. x IN FF ==> aff_gt {vec 0} {v, w} SUBSET wedge_in_fan_gt x E` NHANH; STRIP_TAC; DOWN; ASSUME_TAC2 Local_lemmas.LOFA_CARD_EE_V_1; DOWN THEN SIMP_TAC[wedge_in_fan_gt]; REWRITE_TAC[ARITH_RULE` 2 > 1 `]; ASSUME_TAC2 (SPECL [` x:real^3 `] (GENL [` vv:real^3 `] Local_lemmas.LOFA_IMP_EE_TWO_ELMS)); ASM_REWRITE_TAC[Local_lemmas.AZIM_CYCLE_TWO_POINT_SET]; SUBGOAL_THEN` &1 / &2 % v + &1 / &2 % w IN aff_gt {vec 0} {v, w:real^3}` ASSUME_TAC; SUBGOAL_THEN` DISJOINT {vec 0} {v, w:real^3} ` MP_TAC; ASSUME_TAC2 Local_lemmas.LOFA_IMP_V_DIFF; FIRST_ASSUM (ASSUME_TAC2 o (SPEC` v:real^3`)); FIRST_ASSUM (ASSUME_TAC2 o (SPEC` w:real^3`)); DOWN THEN DOWN THEN PHA; REWRITE_TAC[DISJOINT; EXTENSION; NOT_IN_EMPTY; IN_INTER; IN_INSERT]; MESON_TAC[]; SIMP_TAC[Planarity.AFF_GT_1_2; IN_ELIM_THM]; STRIP_TAC; EXISTS_TAC` &0 `; EXISTS_TAC` &1 / &2 `; EXISTS_TAC` &1 / &2 `; REWRITE_TAC[VECTOR_MUL_LZERO; VECTOR_ADD_LID]; REAL_ARITH_TAC; ABBREV_TAC` vw: real^3 = &1 / &2 % v + &1 / &2 % w `; REWRITE_TAC[SUBSET]; REPEAT STRIP_TAC; FIRST_ASSUM (ASSUME_TAC2 o (SPEC` vw: real^3 `)); DOWN; REWRITE_TAC[wedge; IN_ELIM_THM]; SUBGOAL_THEN` vw IN aff_gt {vec 0, v} {w:real^3} ` MP_TAC; SUBGOAL_THEN` DISJOINT {vec 0, v} {w:real^3} ` MP_TAC; ASM_REWRITE_TAC[DISJOINT; EXTENSION; IN_INSERT; IN_INTER; NOT_IN_EMPTY]; UNDISCH_TAC` ~( v = w:real^3 ) `; ASSUME_TAC2 Local_lemmas.LOFA_IMP_V_DIFF; FIRST_X_ASSUM (ASSUME_TAC2 o (SPEC` w:real^3 `)); DOWN; MESON_TAC[]; SIMP_TAC[AFF_GT_2_1; IN_ELIM_THM]; STRIP_TAC; EXISTS_TAC` &0 `; EXISTS_TAC` &1 / &2 `; EXISTS_TAC` &1 / &2 `; EXPAND_TAC "vw";
REWRITE_TAC[VECTOR_MUL_LZERO; VECTOR_ADD_LID]; REAL_ARITH_TAC; REPEAT STRIP_TAC; SUBGOAL_THEN` ~ collinear {vec 0, v, rho_node1 FF v} /\ ~ collinear {vec 0, v, vw} /\ ~ collinear {vec 0, v, w} ` MP_TAC; ASSUME_TAC2 Local_lemmas.LOCAL_FAN_CHARACTER_OF_RHO_NODE; FIRST_X_ASSUM (ASSUME_TAC2 o (SPEC` v:real^3 `)); ASM_REWRITE_TAC[]; USE_FIRST ` !z t. z IN {v:real^3, w} /\ t IN V DIFF {z} ==> ~collinear {vec 0, z, t}` MATCH_MP_TAC; ASM_REWRITE_TAC[IN_INSERT; IN_DIFF; NOT_IN_EMPTY]; NHANH AZIM_EQ_ALT; ASM_REWRITE_TAC[]; STRIP_TAC; UNDISCH_TAC` azim (vec 0) v (rho_node1 FF v) vw < azim (vec 0) v (rho_node1 FF v) x `; NHANH REAL_LT_IMP_LE; ASM_REWRITE_TAC[]; STRIP_TAC; SUBGOAL_THEN` azim (vec 0) v (rho_node1 FF v) x = azim (vec 0) v (rho_node1 FF v) w + azim (vec 0) v w x ` MP_TAC; MATCH_MP_TAC Fan.sum4_azim_fan; ASM_REWRITE_TAC[]; ASSUME_TAC2 (SPEC` x:real^3 ` (GEN` v:real^3 ` Local_lemmas.LOCAL_FAN_CHARACTER_OF_RHO_NODE2)); DOWN; ASM_SIMP_TAC[INSERT_COMM]; STRIP_TAC; UNDISCH_TAC` &0 < azim (vec 0) v (rho_node1 FF v) vw `; UNDISCH_TAC` azim (vec 0) v (rho_node1 FF v) w < azim (vec 0) v (rho_node1 FF v) x `; PHA; ASM_REWRITE_TAC[]; NHANH (REAL_ARITH` a < b /\ &0 < a ==> &0 < b `); FIRST_ASSUM (SUBST1_TAC o SYM); NHANH AZIM_POS_IMP_SUM_2PI; SIMP_TAC[REAL_ARITH` a + b = c <=> b = c - a `]; STRIP_TAC; UNDISCH_TAC` azim (vec 0) v (rho_node1 FF v) x = azim (vec 0) v (rho_node1 FF v) w + azim (vec 0) v w x`; SIMP_TAC[REAL_ARITH` a = b + c <=> c = a - b `]; STRIP_TAC; UNDISCH_TAC` azim (vec 0) v x (rho_node1 FF v) = &2 * pi - azim (vec 0) v (rho_node1 FF v) x `; SIMP_TAC[REAL_ARITH` a = b - c <=> c = b + -- a `]; STRIP_TAC; MATCH_MP_TAC (REAL_ARITH` &0 <= a ==> ( x + -- a ) - y <= x - y `); REWRITE_TAC[AZIM_RANGE]; ASM_REWRITE_TAC[REAL_LE_REFL]; DOWN; ASM_REWRITE_TAC[]]);; (* = *)
let WEDGE_IN_FAN_LOFA_DETER = 
prove_by_refinement (`local_fan (V,E,FF) /\ v IN V /\ rho_node1 FF v = w ==> wedge_in_fan_gt (w, rho_node1 FF w) E = wedge (vec 0) w (rho_node1 FF w) v`,
[REWRITE_TAC[wedge_in_fan_gt]; NHANH Local_lemmas.LOFA_IMP_EE_TWO_ELMS; STRIP_TAC; ASSUME_TAC2 Local_lemmas.LOFA_IN_V_SO_DO_RHO_NODE_V; DOWN; ASM_REWRITE_TAC[]; STRIP_TAC; ASSUME_TAC2 (SPEC` w:real^3 ` (GEN` v: real^3 ` Local_lemmas.LOFA_CARD_EE_V_1)); DOWN; ASM_SIMP_TAC[ARITH_RULE` 2 > 1 `]; REWRITE_TAC[Local_lemmas.AZIM_CYCLE_TWO_POINT_SET]]);;
let FACE_MAP_SLICING_HYP_TRANS_POINT = 
prove_by_refinement ( `(local_fan (V,E,FF) /\ v IN V /\ w IN V /\ ~(v = w) /\ (!z t. z IN {v, w} /\ t IN V DIFF {z} ==> ~collinear {vec 0, z, t}) /\ (!x. x IN FF ==> aff_gt {vec 0} {v, w} SUBSET wedge_in_fan_gt x E)) ==> face_map (hypermap (HYP (vec 0,V,E UNION {{v, w}}))) (v,w) = w, rho_node1 FF w `,
[NHANH PROVE_SLICING_FAN; NHANH Wrgcvdr_cizmrrh.ELMS_OF_HYPERMAP_HYP; SIMP_TAC[]; STRIP_TAC; REPLICATE_TAC 4 (DOWN THEN REMOVE_TAC); REWRITE_TAC[ff_of_hyp]; SUBGOAL_THEN` v,w IN darts_of_hyp (E UNION {{v, w:real^3}}) V ` MP_TAC; MATCH_MP_TAC (ONCE_REWRITE_RULE[UNION_COMM] IN_DARTS_EXTENSION); REWRITE_TAC[IN_SING]; SIMP_TAC[PAIR_EQ]; STRIP_TAC; SUBGOAL_THEN` {v,w:real^3} IN E UNION {{v, w}} ` MP_TAC; REWRITE_TAC[IN_UNION; IN_SING]; UNDISCH_TAC` FAN (vec 0,V,E UNION {{v, w:real^3}})`; PHA; NHANH (ONCE_REWRITE_RULE[INSERT_COMM] Wrgcvdr_cizmrrh.IVS_AZIM_EQ_INVERSE_SIGMA_FAN); SIMP_TAC[]; STRIP_TAC; MATCH_MP_TAC (REWRITE_RULE[TAUT` a ==> b ==> c <=> a /\ b ==> c `] Wrgcvdr_cizmrrh.SIG_AND_INVERSE1_SIG); ASSUME_TAC2 (SPEC `w:real^3 ` LOCAL_RHO_NODE_PAIR_E); ASM_REWRITE_TAC[IN_UNION]; ASSUME_TAC2 Local_lemmas.LOFA_IMAGE_RHO_NODE_IDE; DOWN; REWRITE_TAC[IMAGE]; STRIP_TAC; UNDISCH_TAC` w:real^3 IN V `; EXPAND_TAC "V";
REWRITE_TAC[IN_ELIM_THM]; STRIP_TAC; MP_TAC (SPECL [`x:real^3 `;` w:real^3 `] (GENL [`vv:real^3 `;` v:real^3 `] Local_lemmas.LOFA_IMP_EE_TWO_ELMS)); ANTS_TAC; ASM_REWRITE_TAC[]; STRIP_TAC; SWITCH_TAC` w = rho_node1 FF x`; SUBGOAL_THEN` EE w ( E UNION {{v,w:real^3}}) = {v, x, rho_node1 FF w}` MP_TAC; ASM_SIMP_TAC[EE_UNION]; ONCE_REWRITE_TAC[INSERT_COMM]; REWRITE_TAC[EE_SING_SING]; ASM_REWRITE_TAC[SET_RULE` S UNION {x} = x INSERT S`; INSERT_COMM]; STRIP_TAC; ASM_REWRITE_TAC[]; SUBGOAL_THEN` rho_node1 FF w IN set_of_edge w V (E UNION {{v,w}})` MP_TAC; UNDISCH_TAC` FAN (vec 0,V,E UNION {{v, w:real^3}}) `; NHANH (ISPEC `w:real^3 ` (GEN`v:real^N` (GSYM Wrgcvdr_cizmrrh.FAN_IMP_EE_EQ_SET_OF_EDGE))); ASM_SIMP_TAC[IN_INSERT]; UNDISCH_TAC` FAN (vec 0,V,E UNION {{v, w:real^3}})`; PHA; NHANH (GSYM Wrgcvdr_cizmrrh.AZIM_CYCLE_EQ_SIGMA_FAN); ASM_SIMP_TAC[]; STRIP_TAC; ASSUME_TAC2 Local_lemmas.LOCAL_FAN_IMP_NOT_SEMI_IDE; FIRST_ASSUM (ASSUME_TAC2 o (SPEC` x:real^3 `)); SUBGOAL_THEN` ~( {v, x, rho_node1 FF w} SUBSET {rho_node1 FF w}) /\ FINITE {v, x, rho_node1 FF w}` MP_TAC; DOWN; ASM_REWRITE_TAC[Geomdetail.FINITE6]; CONV_TAC SET_RULE; NHANH (SPEC` vec 0: real^3` (GEN` v:real^3 ` Wrgcvdr_cizmrrh.AZIM_CYCLE_PROPERTIES)); ABBREV_TAC` W = {v, x, rho_node1 FF w} `; ABBREV_TAC` az = azim_cycle W (vec 0) w (rho_node1 FF w) `; STRIP_TAC; ASSUME_TAC2 Local_lemmas.LOCAL_FAN_RHO_NODE_PROS2; DOWN THEN STRIP_TAC; FIRST_ASSUM (ASSUME_TAC2 o (SPEC`w: real^3 `)); DOWN; USE_FIRST` !x. x IN FF ==> aff_gt {vec 0} {v, w} SUBSET wedge_in_fan_gt x E` NHANH; ASSUME_TAC2 (SPEC` x:real^3` (GEN` v:real^3 ` WEDGE_IN_FAN_LOFA_DETER)); ASM_REWRITE_TAC[SUBSET]; SUBGOAL_THEN` DISJOINT {vec 0} {v, w:real^3}` MP_TAC; REWRITE_TAC[DISJOINT; EXTENSION; IN_INTER; NOT_IN_EMPTY; IN_INSERT]; ASSUME_TAC2 (SPEC` x:real^3 ` (GEN` v:real^3 ` Local_lemmas.LOFA_IN_V_SO_DO_RHO_NODE_V)); GEN_TAC; DOWN; ASM_REWRITE_TAC[]; ASSUME_TAC2 Local_lemmas.LOFA_IMP_V_DIFF; UNDISCH_TAC` v:real^3 IN V `; FIRST_ASSUM NHANH; MESON_TAC[]; REPEAT STRIP_TAC; SUBGOAL_THEN` &1 / &2 % v + &1 / &2 % (w:real^3) IN aff_gt { vec 0} {v, w}` MP_TAC; ASSUME_TAC2 (ISPEC` vec 0:real^3 ` Planarity.AFF_GT_1_2); FIRST_X_ASSUM SUBST1_TAC; REWRITE_TAC[IN_ELIM_THM]; EXISTS_TAC` &0 `; EXISTS_TAC` &1 / &2 `; EXISTS_TAC` &1 / &2 `; REWRITE_TAC[VECTOR_MUL_RZERO; VECTOR_ADD_LID]; REAL_ARITH_TAC; FIRST_X_ASSUM NHANH; REWRITE_TAC[wedge; IN_ELIM_THM]; STRIP_TAC; SUBGOAL_THEN` ~ collinear {vec 0, w, rho_node1 FF w} /\ ~ collinear {vec 0, v, w}` MP_TAC; ASSUME_TAC2 (SPEC` w:real^3` (GEN` v:real^3 ` Local_lemmas.LOCAL_FAN_CHARACTER_OF_RHO_NODE2)); ASM_REWRITE_TAC[]; USE_FIRST` !z t. z IN {v:real^3, w} /\ t IN V DIFF {z} ==> ~collinear {vec 0, z, t}` MATCH_MP_TAC; ASM_REWRITE_TAC[IN_DIFF; IN_SING; IN_INSERT; NOT_IN_EMPTY]; EXPAND_TAC "w"; MATCH_MP_TAC Local_lemmas.LOFA_IN_V_SO_DO_RHO_NODE_V; ASM_REWRITE_TAC[]; STRIP_TAC; MP_TAC (SPECL [` vec 0: real^3 `;` w:real^3 `;` rho_node1 FF w `; ` &1 / &2 % v + &1 / &2 % (w:real^3) `; `v:real^3 ` ] AZIM_EQ_ALT); ANTS_TAC; DOWN; ASM_REWRITE_TAC[INSERT_COMM]; ABBREV_TAC` vw = &1 / &2 % v + &1 / &2 % (w:real^3) `; DOWN THEN DOWN; ONCE_REWRITE_TAC[SET_RULE` {a,b,c} = {a,c,b} `]; NHANH COLL_AFF_GT_2_1; REPEAT STRIP_TAC; SUBGOAL_THEN` vw IN aff_gt {vec 0, w} {v:real^3} ` MP_TAC; ASM_REWRITE_TAC[IN_ELIM_THM]; EXPAND_TAC "vw"; EXISTS_TAC` &0 `; EXISTS_TAC` &1 / &2 `; EXISTS_TAC` &1 / &2 `; REWRITE_TAC[VECTOR_MUL_RZERO; VECTOR_ADD_LID; VECTOR_ADD_SYM]; REAL_ARITH_TAC; FIRST_X_ASSUM (SUBST1_TAC o SYM); STRIP_TAC; UNDISCH_TAC` (W:real^3 -> bool) (az:real^3)`; EXPAND_TAC "W"; REWRITE_TAC[SET_RULE` (x INSERT s) y <=> y = x \/ y IN s`; IN_INSERT; NOT_IN_EMPTY]; STRIP_TAC; USE_FIRST` !q. ~(q = rho_node1 FF w) /\ W q ==> azim (vec 0) w (rho_node1 FF w) az < azim (vec 0) w (rho_node1 FF w) q \/ azim (vec 0) w (rho_node1 FF w) az = azim (vec 0) w (rho_node1 FF w) q /\ norm (projection (w - vec 0) (az - vec 0)) <= norm (projection (w - vec 0) (q - vec 0)) ` (MP_TAC o (SPEC` v:real^3 `)); ANTS_TAC; CONJ_TAC; STRIP_TAC; MP_TAC (SPECL [`w:real^3 `;` v:real^3 `] (GENL [` v:real^3 `;` w:real^3 `] CROSS_PAIR_NOT_IN_FF)); ANTS_TAC; ASM_REWRITE_TAC[]; CONJ_TAC; EXPAND_TAC "w"; MATCH_MP_TAC Local_lemmas.LOFA_IN_V_SO_DO_RHO_NODE_V; ASM_REWRITE_TAC[]; FIRST_X_ASSUM (SUBST1_TAC o SYM); ASM_REWRITE_TAC[INSERT_COMM]; ASM_REWRITE_TAC[]; EXPAND_TAC "W"; REWRITE_TAC[SET_RULE` (x INSERT S) y <=> y = x \/ y IN S`; IN_INSERT]; ASM_REWRITE_TAC[]; UNDISCH_TAC` azim (vec 0) w (rho_node1 FF w) vw < azim (vec 0) w (rho_node1 FF w) x `; ASM_SIMP_TAC[REAL_ARITH` a < b ==> ~( b < a ) /\ ~( b = a)`]; DOWN; ASM_SIMP_TAC[]]);; (* = *)
let FACE_MAP_AT_TURNING_DART1 = 
prove( ` (local_fan (V,E,FF) /\ v IN V /\ w IN V /\ ~(v = w) /\ (!z t. z IN {v, w} /\ t IN V DIFF {z} ==> ~collinear {vec 0, z, t}) /\ (!x. x IN FF ==> aff_gt {vec 0} {v, w} SUBSET wedge_in_fan_gt x E)) /\ x,w IN FF ==> face_map (hypermap (HYP (vec 0,V,E UNION {{v, w}}))) (x,w) = w, v`,
STRIP_TAC THEN ONCE_REWRITE_TAC[INSERT_COMM] THEN MATCH_MP_TAC FACE_MAP_AT_TURNING_DART THEN DOWN_TAC THEN SIMP_TAC[INSERT_COMM]);;
let LOCAL_FAN_ORBIT_MAP_VITERFF = 
prove( `local_fan (V,E,FF) /\ v IN V ==> (!n. ITER n (rho_node1 FF) v, ITER (n + 1) (rho_node1 FF) v IN FF)`,
NHANH Local_lemmas.LOCAL_FAN_ORBIT_MAP_VITER THEN NHANH Local_lemmas.LOCAL_FAN_RHO_NODE_PROS2 THEN REPEAT STRIP_TAC THEN REWRITE_TAC[GSYM ADD1; ITER] THEN ASM_MESON_TAC[]);;
let DETERMINE_FV = 
prove_by_refinement (`(local_fan (V,E,FF) /\ v IN V /\ w IN V /\ ~(v = w) /\ (!z t. z IN {v, w} /\ t IN V DIFF {z} ==> ~collinear {vec 0, z, t}) /\ (!x. x IN FF ==> aff_gt {vec 0} {v, w} SUBSET wedge_in_fan_gt x E)) /\ HS = hypermap ( HYP (vec 0,V,E UNION {{v, w}})) /\ fv = face HS (v, rho_node1 FF v) ==> fv = (w,v) INSERT { (ITER n (rho_node1 FF) v, ITER (n + 1) (rho_node1 FF) v) | n | ! m. m < n + 1 ==> ~(ITER m (rho_node1 FF) v = w)} `,
[NHANH FACE_MAP_SLICING_HYP_TRANS_POINT; NHANH ( REWRITE_RULE[RIGHT_FORALL_IMP_THM ] ( GEN`x: real^3 ` (ONCE_REWRITE_RULE[TAUT` a /\ b ==> c <=> a ==> b ==> c`] FACE_MAP_AT_TURNING_DART))); STRIP_TAC; DOWN THEN DOWN THEN PHA; ONCE_REWRITE_TAC[EQ_SYM_EQ]; STRIP_TAC; REWRITE_TAC[EXTENSION; IN_INSERT]; GEN_TAC; ASSUME_TAC2 Local_lemmas.LOCAL_FAN_ORBIT_MAP_V; DOWN; NHANH Local_lemmas.LOOP_SET_DETER_FIRTS_ELMS; STRIP_TAC; EQ_TAC; SUBGOAL_THEN` {ITER n (rho_node1 FF) v,ITER (n + 1) (rho_node1 FF) v | n | !m. m < n + 1 ==> ~ (ITER m (rho_node1 FF) v = w)} SUBSET fv ` ASSUME_TAC; REWRITE_TAC[SUBSET; IN_ELIM_THM]; REPEAT STRIP_TAC; FIRST_ASSUM (ASSUME_TAC2 o (SPEC`v:real^3`)); UNDISCH_TAC` w:real^3 IN V `; EXPAND_TAC "V";
REWRITE_TAC[IN_ELIM_THM]; STRIP_TAC; SUBGOAL_THEN` ! j. j < n + 1 ==> ITER j (face_map HS) (v,rho_node1 FF v) = ITER j (rho_node1 FF) v,ITER (j + 1) (rho_node1 FF) v ` ASSUME_TAC; INDUCT_TAC; REWRITE_TAC[ITER; GSYM ADD1]; NHANH (ARITH_RULE` SUC a < b + 1 ==> a < b + 1 `); FIRST_X_ASSUM NHANH; SIMP_TAC[ITER]; STRIP_TAC; ABBREV_TAC` xi = ITER j (rho_node1 FF) v `; ABBREV_TAC` yi = ITER (j + 1) (rho_node1 FF) v`; SUBGOAL_THEN` xi,yi IN darts_of_hyp (E UNION {{v:real^3, w}}) V /\ ~(yi = v) /\ ~(yi = w) /\ FAN (vec 0,V,E) /\ FAN (vec 0,V,E UNION {{v, w}}) ` MP_TAC; CONJ_TAC; UNDISCH_TAC` !v. v IN V ==> orbit_map (rho_node1 FF) v = V `; DISCH_THEN (ASSUME_TAC2 o SPEC_ALL); MP_TAC (ISPECL [`rho_node1 FF `; `j:num `; `v:real^3` ] Local_lemmas.lemma_in_orbit_iter); ASM_REWRITE_TAC[]; STRIP_TAC; ASSUME_TAC2 (SPEC` xi:real^3 ` LOCAL_RHO_NODE_PAIR_E); EXPAND_TAC "yi"; REWRITE_TAC[ITER; GSYM ADD1]; ASM_REWRITE_TAC[]; DOWN; REWRITE_TAC[IN_DARTS_EXTENSION]; UNDISCH_TAC` SUC j < n + 1 `; FIRST_ASSUM NHANH; SWITCH_TAC` w = ITER n' (rho_node1 FF) v `; ASM_SIMP_TAC[ADD1]; ASSUME_TAC2 (Local_lemmas.LOFA_IMP_DIS_ELMS23); FIRST_X_ASSUM (MP_TAC o (SPECL [` 0 `;` j + 1 `])); ANTS_TAC; ARITH_TAC; STRIP_TAC THEN STRIP_TAC; ASM_CASES_TAC` n' < j + 1 `; ASSUME_TAC2 (ARITH_RULE` j + 1 < n + 1 /\ n' < j + 1 ==> n' < n + 1 `); DOWN; FIRST_X_ASSUM NHANH; FIRST_X_ASSUM NHANH; ASM_REWRITE_TAC[]; ASSUME_TAC2 (ARITH_RULE` n' < CARD (V:real^3 -> bool) /\ ~( n' < j + 1) ==> j + 1 < CARD V `); DOWN; FIRST_X_ASSUM NHANH; ASM_SIMP_TAC[ITER]; STRIP_TAC; ASSUME_TAC2 Wrgcvdr_cizmrrh.LOCAL_FAN_IMP_FAN; ASM_REWRITE_TAC[]; MATCH_MP_TAC PROVE_SLICING_FAN; ASM_REWRITE_TAC[]; EXPAND_TAC "V"; REWRITE_TAC[IN_ELIM_THM]; EXISTS_TAC`n':num`; ASM_REWRITE_TAC[]; NHANH FACE_MAP_ADD_SET2_EQ; ASM_SIMP_TAC[]; ASSUME_TAC2 Local_lemmas.LOCAL_FAN_ITER_RHO_NODE_IN_V; FIRST_X_ASSUM (MP_TAC o (SPEC` j:num `)); ASM_REWRITE_TAC[]; ASSUME_TAC2 Local_lemmas.LOCAL_FAN_RHO_NODE_PROS2; DOWN THEN STRIP_TAC; FIRST_ASSUM NHANH; STRIP_TAC THEN STRIP_TAC; ASSUME_TAC2 (SPECL [` xi:real^3 `;` rho_node1 FF xi `] (GENL [`x:real^3 `;` y:real^3 `] LOCAL_FACE_MAP_RHO_NODE1)); DOWN; EXPAND_TAC "xi"; REWRITE_TAC[GSYM ITER; ADD1]; ASM_REWRITE_TAC[]; FIRST_ASSUM (MP_TAC o (SPEC` n:num`)); ANTS_TAC; ARITH_TAC; ASM_REWRITE_TAC[]; DISCH_THEN (SUBST1_TAC o SYM); EXPAND_TAC "fv"; REWRITE_TAC[face; orbit_map; Wrgcvdr_cizmrrh.POWER_TO_ITER; IN_ELIM_THM]; EXISTS_TAC`n:num`; REWRITE_TAC[ARITH_RULE` a >= 0 `]; STRIP_TAC; UNDISCH_TAC` w:real^3 IN V `; FIRST_ASSUM (ASSUME_TAC2 o (SPEC` v:real^3 `)); EXPAND_TAC "V"; REWRITE_TAC[IN_ELIM_THM]; STRIP_TAC; ABBREV_TAC` SS = {ITER n (rho_node1 FF) v,ITER (n + 1) (rho_node1 FF) v | n | !m. m < n + 1 ==> ~ (ITER m (rho_node1 FF) v = w)} `; SUBGOAL_THEN` ITER (n - 1) (rho_node1 FF) v, (w:real^3) IN SS ` MP_TAC; EXPAND_TAC "SS"; REWRITE_TAC[IN_ELIM_THM]; EXISTS_TAC` n - 1 `; REWRITE_TAC[PAIR_EQ]; ASM_CASES_TAC` n = 0 `; FIRST_X_ASSUM SUBST_ALL_TAC; DOWN THEN DOWN; ASM_REWRITE_TAC[ITER]; DOWN; ASM_SIMP_TAC[ARITH_RULE` ~( n = 0) ==> n - 1 + 1 = n `]; STRIP_TAC; GEN_TAC; ASSUME_TAC2 Local_lemmas.LOFA_IMP_DIS_ELMS23; STRIP_TAC; FIRST_X_ASSUM (MP_TAC o (SPECL [`m:num `;` n:num`])); PHA; ANTS_TAC; ASM_REWRITE_TAC[]; SIMP_TAC[]; ASM_CASES_TAC` n = 0`; FIRST_X_ASSUM SUBST_ALL_TAC; DOWN THEN DOWN; ASM_REWRITE_TAC[ITER]; ABBREV_TAC` lp = ITER (n - 1) (rho_node1 FF) v `; SUBGOAL_THEN` lp IN (V:real^3 -> bool) ` MP_TAC; EXPAND_TAC "V"; EXPAND_TAC "lp"; REWRITE_TAC[IN_ELIM_THM]; EXISTS_TAC` n - 1 `; REWRITE_TAC[]; UNDISCH_TAC` n < CARD (V:real^3 -> bool) `; ARITH_TAC; ASSUME_TAC2 Local_lemmas.LOCAL_FAN_RHO_NODE_PROS2; DOWN THEN STRIP_TAC; FIRST_ASSUM NHANH; EXPAND_TAC "lp"; REWRITE_TAC[GSYM ITER; ADD1]; SWITCH_TAC` w = ITER n (rho_node1 FF) v`; ASM_SIMP_TAC[ARITH_RULE` ~(n = 0) ==> n - 1 + 1 = n `]; REPEAT STRIP_TAC; MP_TAC (SPEC` lp:real^3` (GEN `x:real^3` FACE_MAP_AT_TURNING_DART1)); ANTS_TAC; ASM_REWRITE_TAC[]; EXPAND_TAC "w"; EXPAND_TAC "V"; REWRITE_TAC[IN_ELIM_THM]; EXISTS_TAC `n:num`; ASM_REWRITE_TAC[]; DISCH_THEN (SUBST1_TAC o SYM); EXPAND_TAC "fv"; REWRITE_TAC[face]; EXPAND_TAC "HS"; MATCH_MP_TAC Wrgcvdr_cizmrrh.IN_ORBIT_MAP_IMP_F_Y; MATCH_MP_TAC Hypermap.lemma_in_subset; EXISTS_TAC` SS:real^3 # real^3 -> bool`; ASM_REWRITE_TAC[GSYM face]; DOWN THEN DOWN THEN PHA; REWRITE_TAC[Hypermap.lemma_in_subset]; FIRST_X_ASSUM (ASSUME_TAC2 o (SPEC`v:real^3 `)); SUBGOAL_THEN` w:real^3 IN V ` MP_TAC; FIRST_X_ASSUM ACCEPT_TAC; EXPAND_TAC "V"; REWRITE_TAC[IN_ELIM_THM]; STRIP_TAC; STRIP_TAC; SUBGOAL_THEN` ! j. j < n ==> ITER j (face_map HS ) (v, rho_node1 FF v) = ITER j (rho_node1 FF) v, ITER (j + 1) (rho_node1 FF) v` MP_TAC; INDUCT_TAC; REWRITE_TAC[ITER; GSYM ADD1]; NHANH (ARITH_RULE` SUC j < n ==> j < n `); FIRST_X_ASSUM NHANH; SIMP_TAC[ITER]; ABBREV_TAC` vi = ITER j (rho_node1 FF) v `; ABBREV_TAC` vj = ITER (j + 1) (rho_node1 FF) v`; STRIP_TAC; SUBGOAL_THEN` face_map (hypermap (HYP (vec 0,V,E UNION {{v, w:real^3}}))) (vi, vj) = face_map (hypermap (HYP (vec 0,V,E))) (vi, vj:real^3)` MP_TAC; MATCH_MP_TAC FACE_MAP_ADD_SET2_EQ; ASSUME_TAC2 LOCAL_FAN_ORBIT_MAP_VITERFF; FIRST_X_ASSUM (MP_TAC o (SPEC` j: num`)); ASM_REWRITE_TAC[]; UNDISCH_TAC` local_fan (V,E,FF) `; PHA; NHANH Local_lemmas.LOCAL_FAN_IN_FF_IN_ORD_PAIRS2; SIMP_TAC[IN_DARTS_EXTENSION]; STRIP_TAC; ASSUME_TAC2 Local_lemmas.LOFA_IMP_DIS_ELMS23; FIRST_ASSUM (MP_TAC o (SPECL [`j + 1 `;` n: num `])); PHA; ANTS_TAC; ASM_REWRITE_TAC[GSYM ADD1]; ASM_SIMP_TAC[]; STRIP_TAC; FIRST_ASSUM (MP_TAC o (SPECL [` 0`;` j + 1 `])); ANTS_TAC; ARITH_TAC; ANTS_TAC; MATCH_MP_TAC LT_TRANS; EXISTS_TAC` n:num`; ASM_REWRITE_TAC[GSYM ADD1]; ASM_SIMP_TAC[ITER]; STRIP_TAC; ASSUME_TAC2 Wrgcvdr_cizmrrh.LOCAL_FAN_IMP_FAN; ASM_REWRITE_TAC[]; MATCH_MP_TAC PROVE_SLICING_FAN; SWITCH_TAC` w = ITER n (rho_node1 FF) v `; ASM_REWRITE_TAC[]; ASM_SIMP_TAC[]; ASSUME_TAC2 LOCAL_FAN_ORBIT_MAP_VITERFF; STRIP_TAC; FIRST_X_ASSUM (MP_TAC o (SPEC` j:num `)); UNDISCH_TAC` local_fan (V,E,FF) `; PHA; NHANH LOCAL_FACE_MAP_RHO_NODE1; ASM_SIMP_TAC[GSYM ADD1]; EXPAND_TAC "vj"; REWRITE_TAC[GSYM ADD1; ITER]; SUBGOAL_THEN` face_map (hypermap (HYP (vec 0,V,E UNION {{v, w}}))) (w,v) = v,rho_node1 FF v` MP_TAC; ONCE_REWRITE_TAC[INSERT_COMM]; MATCH_MP_TAC FACE_MAP_SLICING_HYP_TRANS_POINT; SWITCH_TAC` w = ITER n (rho_node1 FF) v `; ONCE_REWRITE_TAC[INSERT_COMM]; ASM_REWRITE_TAC[]; UNDISCH_TAC` !z t. z IN {v, w} /\ t IN V DIFF {z} ==> ~collinear {vec 0, z, t:real^3}`; SIMP_TAC[INSERT_COMM]; SWITCH_TAC` w = ITER n (rho_node1 FF) v `; ASM_REWRITE_TAC[]; REPEAT STRIP_TAC; ASSUME_TAC2 LOCAL_FAN_ORBIT_MAP_VITERFF; FIRST_ASSUM (MP_TAC o (SPEC `n - 1 `)); ASM_CASES_TAC` n = 0 `; FIRST_X_ASSUM SUBST_ALL_TAC; REPLICATE_TAC 4 DOWN; ASM_REWRITE_TAC[ITER]; ASSUME_TAC2 (ARITH_RULE` ~( n = 0) ==> n - 1 + 1 = n `); FIRST_ASSUM SUBST1_TAC; ASM_REWRITE_TAC[]; ABBREV_TAC` xx = ITER (n - 1) (rho_node1 FF) v `; STRIP_TAC; MP_TAC (SPEC` xx:real^3 ` (GEN`x:real^3 ` FACE_MAP_AT_TURNING_DART1)); ANTS_TAC; ASM_REWRITE_TAC[]; ASM_REWRITE_TAC[]; STRIP_TAC; SUBGOAL_THEN` ITER (n + 1) (face_map HS) (v, rho_node1 FF v) = (v, rho_node1 FF v ) ` MP_TAC; SUBGOAL_THEN` ITER (n - 1) (face_map HS) (v,rho_node1 FF v) = ITER (n - 1) (rho_node1 FF) v,ITER (n - 1 + 1) (rho_node1 FF) v` MP_TAC; FIRST_ASSUM MATCH_MP_TAC; MATCH_MP_TAC (ARITH_RULE` ~( n = 0) ==> n - 1 < n `); FIRST_X_ASSUM ACCEPT_TAC; ASM_REWRITE_TAC[GSYM ADD1]; STRIP_TAC; EXPAND_TAC "n"; REWRITE_TAC[GSYM ADD1; ITER]; ASM_REWRITE_TAC[]; MP_TAC (ARITH_RULE` 0 < n + 1 `); PHA; NHANH Lvducxu.ITER_CYCLIC_ORBIT; ASM_REWRITE_TAC[GSYM face]; STRIP_TAC; UNDISCH_TAC` x:real^3 # real^3 IN fv `; ASM_REWRITE_TAC[IN_ELIM_THM]; STRIP_TAC; ASM_CASES_TAC` n' = n:num `; DISJ1_TAC; FIRST_X_ASSUM SUBST_ALL_TAC; ASM_REWRITE_TAC[]; EXPAND_TAC "n"; REWRITE_TAC[GSYM ADD1; ITER]; ASSUME_TAC2 (ARITH_RULE`~( n = 0) ==> n - 1 < n `); DOWN; FIRST_X_ASSUM NHANH; ASM_SIMP_TAC[]; DISJ2_TAC; EXISTS_TAC` n':num`; ASSUME_TAC2 (ARITH_RULE` n' < n + 1 /\ ~(n' = n) ==> n' < n `); DOWN; FIRST_ASSUM NHANH; ASM_SIMP_TAC[]; REPEAT STRIP_TAC; ASSUME_TAC2 Local_lemmas.LOFA_IMP_DIS_ELMS23; FIRST_X_ASSUM (MP_TAC o SPECL[`m:num `;` n:num `]); ANTS_TAC; UNDISCH_TAC` n' < n + 1 `; UNDISCH_TAC` m< n' + 1 `; UNDISCH_TAC` ~( n' = n:num) `; ARITH_TAC; ANTS_TAC; FIRST_X_ASSUM ACCEPT_TAC; ASM_REWRITE_TAC[]]);;
let TWO_EQ_SYSTEM_THM = 
prove_by_refinement ( ` FAN (vec 0,V,E) /\ graph E /\ UNIONS E SUBSET V ==> dart_of_fan (V,E), res (e_fan_pair (V,E)) (dart1_of_fan (V,E)), res (n_fan_pair (V,E)) (dart1_of_fan (V,E)), res (f_fan_pair (V,E)) (dart1_of_fan (V,E)) = darts_of_hyp E V, ee_of_hyp (vec 0,V,E), nn_of_hyp (vec 0,V,E), ff_of_hyp (vec 0,V,E)`,
[REWRITE_TAC[PAIR_EQ]; STRIP_TAC; SUBGOAL_THEN` dart_of_fan (V,E) = darts_of_hyp E V ` MP_TAC; REWRITE_TAC[dart_of_fan; darts_of_hyp; ord_pairs; self_pairs]; DOWN; NHANH (REWRITE_RULE[RIGHT_FORALL_IMP_THM] (GEN `v: A` Wrgcvdr_cizmrrh.UNI_E_IMP_EE_EQ_SET_OF_EDGE)); SIMP_TAC[EXTENSION; IN_UNION]; MESON_TAC[]; SIMP_TAC[]; STRIP_TAC; REWRITE_TAC[res; FUN_EQ_THM; ee_of_hyp2]; CONJ_TAC; GEN_TAC; REWRITE_TAC[dart1_of_fan; darts_of_hyp; IN_UNION; ord_pairs]; ASM_CASES_TAC` x IN {a,b | {a, b:real^3} IN E}`; ASM_REWRITE_TAC[]; PAT_ONCE_REWRITE_TAC`\p. P p = PP `[GSYM PAIR]; PURE_ONCE_REWRITE_TAC[e_fan_pair]; REWRITE_TAC[]; ASM_REWRITE_TAC[self_pairs; IN_ELIM_THM]; MESON_TAC[PAIR_EQ; FST; SND]; CONJ_TAC; REWRITE_TAC[nn_of_hyp3; dart1_of_fan]; GEN_TAC; ASM_CASES_TAC` x IN {v,w | {v:real^3, w} IN E}`; ASM_REWRITE_TAC[darts_of_hyp; ord_pairs; self_pairs; IN_UNION; EE]; DOWN; REWRITE_TAC[IN_ELIM_THM]; STRIP_TAC; ASM_REWRITE_TAC[n_fan_pair]; DOWN_TAC; REWRITE_TAC[graph]; STRIP_TAC; FIRST_X_ASSUM (MP_TAC o (SPEC` {v, w:real^3}`)); ANTS_TAC; DOWN_TAC; SIMP_TAC[IN]; REWRITE_TAC[SET2_HAS_SIZE2]; STRIP_TAC; SUBGOAL_THEN` ~( {w | {v, w:real^3} IN E} = {} ) ` MP_TAC; UNDISCH_TAC` {v:real^3,w} IN E `; SET_TAC[]; SIMP_TAC[]; NHANH (MESON[PAIR_EQ]` (?v'. v' IN V /\ {w | {v', w} IN E} = {} /\ v,w = v',v') ==> {w | {v, w} IN E} = {} `); SIMP_TAC[PAIR_EQ]; STRIP_TAC; UNDISCH_TAC` {v, w:real^3} IN E `; UNDISCH_TAC` FAN (vec 0, V:real^3 -> bool, E) `; PHA; NHANH Wrgcvdr_cizmrrh.ITER_AZIM_CYCLE_EQ_ITER_SIGMA; STRIP_TAC; FIRST_X_ASSUM (MP_TAC o (SPEC` w:real^3 `)); ANTS_TAC; REWRITE_TAC[EE; IN_ELIM_THM]; FIRST_ASSUM ACCEPT_TAC; DISCH_THEN (MP_TAC o (SPEC` 1 `)); SIMP_TAC[ITER12; EE]; ASM_REWRITE_TAC[darts_of_hyp; IN_UNION; TAUT`~( a \/ b) \/ b <=> ~ a \/ b`]; ASM_REWRITE_TAC[ord_pairs]; (* ------------------ *) GEN_TAC; REWRITE_TAC[dart1_of_fan; f_fan_pair; Wrgcvdr_cizmrrh.ff_of_hyp3; f_fan_pair]; ASM_CASES_TAC` (x:real^3#real^3) IN {v,w | {v, w} IN E}`; ASM_REWRITE_TAC[darts_of_hyp; IN_UNION; TAUT` ~(a \/ b) \/ b <=> ~ a \/ b `; ord_pairs]; DOWN_TAC; REWRITE_TAC[graph; IN_ELIM_THM]; STRIP_TAC; SUBGOAL_THEN` ~ ( x IN self_pairs E (V:real^3 -> bool))` MP_TAC; REWRITE_TAC[self_pairs; IN_ELIM_THM]; DOWN THEN DOWN THEN PHA; REWRITE_TAC[IN]; FIRST_X_ASSUM NHANH; SIMP_TAC[SET2_HAS_SIZE2; PAIR_EQ]; MESON_TAC[]; ASM_SIMP_TAC[f_fan_pair; PAIR_EQ]; STRIP_TAC; UNDISCH_TAC` {v, w:real^3} IN E `; UNDISCH_TAC` FAN (vec 0, V:real^3 -> bool, E) `; ONCE_REWRITE_TAC[INSERT_COMM]; PHA; NHANH Fan_misc.INVERSE_SIGMA_FAN_EQ_INVERSE1_SIGMA_FAN; NHANH Wrgcvdr_cizmrrh.IVS_AZIM_EQ_INVERSE_SIGMA_FAN; STRIP_TAC; FIRST_X_ASSUM (ASSUME_TAC o SYM); ASM_REWRITE_TAC[]; ASM_REWRITE_TAC[darts_of_hyp; IN_UNION; TAUT` ~( a \/ b) \/ b <=> ~ a \/ b `]; ASM_REWRITE_TAC[ord_pairs]]);;
let LOFA_FST_IDENTIFY = 
prove( ` local_fan (V,E,FF) /\ x IN FF /\ y IN FF /\ FST x = FST y ==> x = y `,
NHANH Local_lemmas.LOFA_IMP_BIJ_FF_V THEN REWRITE_TAC[BIJ; INJ] THEN MESON_TAC[]);;
let CARD_IS_LEAST_CYCLE = 
prove_by_refinement ( ` local_fan (V,E,FF) /\ v IN V /\ ITER n (rho_node1 FF) v = v /\ ~( n = 0) ==> CARD V <= n`,
[STRIP_TAC; ASSUME_TAC2 Local_lemmas.LOFA_IMP_DIS_ELMS23; ASM_CASES_TAC` n < CARD (V:real^3 -> bool) `; FIRST_X_ASSUM (MP_TAC o (SPECL [`0`;` n:num`])); PHA; ANTS_TAC; ASM_REWRITE_TAC[]; ASM_ARITH_TAC; ASM_REWRITE_TAC[ITER]; DOWN; ARITH_TAC]);;
(* = *) (* = *)
let HAFL_CIRCLE_FORM_LOCAL_FAN = 
prove_by_refinement (`(local_fan (V,E,FF) /\ v IN V /\ w IN V /\ ~(v = w) /\ (!z t. z IN {v, w} /\ t IN V DIFF {z} ==> ~collinear {vec 0, z, t}) /\ (!x. x IN FF ==> aff_gt {vec 0} {v, w} SUBSET wedge_in_fan_gt x E)) /\ HS = hypermap ( HYP (vec 0,V,E UNION {{v, w}})) /\ fv = face HS (v, rho_node1 FF v) ==> local_fan (v_prime V fv, e_prime (E UNION {{v, w}}) fv, fv) `,
[NHANH PROVE_SLICING_FAN; STRIP_TAC; SUBGOAL_THEN` (v,rho_node1 FF v) IN darts_of_hyp (E UNION {{v,w}}) V` ASSUME_TAC; REWRITE_TAC[darts_of_hyp]; ASSUME_TAC2 Local_lemmas.LOCAL_FAN_RHO_NODE_PROS2; DOWN THEN STRIP_TAC; FIRST_ASSUM (ASSUME_TAC2 o (SPEC` v:real^3 `)); DOWN; UNDISCH_TAC` local_fan (V,E,FF) `; PHA; NHANH Local_lemmas.LOCAL_FAN_IN_FF_IN_ORD_PAIRS2; REWRITE_TAC[IN_ELIM_THM; IN_UNION; ord_pairs]; STRIP_TAC; DISJ1_TAC; EXISTS_TAC` v:real^3 `; EXISTS_TAC` rho_node1 FF v `; ASM_REWRITE_TAC[]; MP_TAC LOFA_HYP_UNION_CARD_GT2; ANTS_TAC; ASM_REWRITE_TAC[]; STRIP_TAC; SUBGOAL_THEN` simple_hypermap (hypermap (HYP (vec 0, v_prime V fv, e_prime (E UNION {{v, w}} ) fv)))` MP_TAC; REWRITE_TAC[simple_hypermap]; SUBGOAL_THEN` FAN (vec 0:real^3,v_prime (V:real^3 -> bool) fv,e_prime (E UNION {{v,w}} ) fv) ` MP_TAC; MATCH_MP_TAC Wrgcvdr_cizmrrh.IMP_FAN_V_PRIME_E_PRIME; ASM_REWRITE_TAC[]; EXISTS_TAC` (v, rho_node1 FF v) `; ASM_REWRITE_TAC[]; UNDISCH_TAC `FAN (vec 0, V:real^3 -> bool, E UNION {{v, w}})`; NHANH Wrgcvdr_cizmrrh.ELMS_OF_HYPERMAP_HYP; ASM_SIMP_TAC[]; SWITCH_TAC` HS = hypermap (HYP (vec 0,V,E UNION {{v, w: real^3}})) `; SWITCH_TAC` fv = face HS (v,rho_node1 FF v) `; STRIP_TAC; SUBGOAL_THEN` 1 < CARD (fv:real^3 # real^3 -> bool) ` MP_TAC; ASM_ARITH_TAC; SUBGOAL_THEN` fv = face (hypermap (HYP (vec 0,V,(E UNION {{v,w:real^3}})))) (v,rho_node1 FF v)` MP_TAC; ASM_REWRITE_TAC[]; SUBGOAL_THEN` FAN (vec 0, V, E UNION {{v,w:real^3}}) ` MP_TAC; FIRST_X_ASSUM ACCEPT_TAC; PHA; NHANH Lvducxu.DARTS_E_PRIME_GT1_SWITCH; STRIP_TAC; UNDISCH_TAC` FAN (vec 0,v_prime V fv,e_prime (E UNION {{v:real^3, w}}) fv) `; NHANH Wrgcvdr_cizmrrh.ELMS_OF_HYPERMAP_HYP; SIMP_TAC[]; STRIP_TAC; SWITCH_TAC` fv = face (hypermap (HYP (vec 0,V,E UNION {{v, w}}))) (v,rho_node1 FF v)`; ASM_REWRITE_TAC[]; REWRITE_TAC[IN_UNION]; GEN_TAC THEN STRIP_TAC; DOWN; ASSUME_TAC2 LOCAL_FAN_SIMPLE_HYP; MP_TAC DETERMINE_FV; ANTS_TAC; ASM_REWRITE_TAC[]; STRIP_TAC; ASM_REWRITE_TAC[]; REWRITE_TAC[IN_ELIM_THM; IN_INSERT]; FIRST_X_ASSUM (ASSUME_TAC o SYM); ASM_REWRITE_TAC[]; MP_TAC (SPECL [`E UNION {{v,w:real^3 }} `; ` fv: real^3 # real^3 -> bool `;` v, rho_node1 FF v`;` vec 0: real^3 `] ( GENL [`E:(real^3 -> bool) -> bool `;` FF: real^3 # real^3 -> bool`; `x:real^3 # real^3`;`v:real^3`] Lvducxu.LOCALIZE_PRESERVE_FACE)); ANTS_TAC; ASM_REWRITE_TAC[]; UNDISCH_TAC` v,rho_node1 FF v IN darts_of_hyp (E UNION {{v, w}}) V`; UNDISCH_TAC` FAN (vec 0,V,E UNION {{v, w:real^3}})`; NHANH Lvducxu.FAN_DART_DARTS; ASM_SIMP_TAC[]; STRIP_TAC; DISCH_TAC; SUBGOAL_THEN` x IN face (hypermap (HYP (vec 0,v_prime V fv,e_prime (E UNION {{v, w}}) fv))) (v,rho_node1 FF v) ` MP_TAC; UNDISCH_TAC` fv = face (hypermap (HYP (vec 0,v_prime V fv,e_prime (E UNION {{v, w}}) fv))) (v,rho_node1 FF v) `; DISCH_THEN (SUBST1_TAC o SYM); EXPAND_TAC "fv";
REWRITE_TAC[IN_ELIM_THM; IN_INSERT]; ASM_REWRITE_TAC[]; NHANH Hypermap.lemma_face_identity; ONCE_REWRITE_TAC[EQ_SYM_EQ]; ASM_SIMP_TAC[]; STRIP_TAC; REWRITE_TAC[EXTENSION; IN_INSERT; NOT_IN_EMPTY]; GEN_TAC; SWITCH_TAC` fv = face (hypermap (HYP (vec 0,v_prime V fv,e_prime (E UNION {{v, w}}) fv))) (v,rho_node1 FF v) `; ASM_REWRITE_TAC[]; EQ_TAC; DOWN THEN DOWN; SIMP_TAC[IN_INTER; Wrgcvdr_cizmrrh.X_IN_HYP_ORBITS]; MESON_TAC[Wrgcvdr_cizmrrh.X_IN_HYP_ORBITS]; UNDISCH_TAC` x = w,v \/ (?n. (!m. m < n + 1 ==> ~(ITER m (rho_node1 FF) v = w)) /\ x = ITER n (rho_node1 FF) v,ITER (n + 1) (rho_node1 FF) v)`; STRIP_TAC; REWRITE_TAC[IN_INTER]; UNDISCH_TAC` FAN (vec 0,v_prime V fv,e_prime (E UNION {{v, w:real^3}}) fv) `; PHA; NGOAC; NHANH Wrgcvdr_cizmrrh.IN_NODE_IMP_FIRST_EQ; STRIP_TAC; DOWN; USE_FIRST` (w,v) INSERT {ITER n (rho_node1 FF) v,ITER (n + 1) (rho_node1 FF) v | n | !m. m < n + 1 ==> ~ (ITER m (rho_node1 FF) v = w)} = fv ` (SUBST1_TAC o SYM); REWRITE_TAC[IN_INSERT; IN_ELIM_THM]; STRIP_TAC; ASM_REWRITE_TAC[]; UNDISCH_TAC` FST (x':real^3 # real^3) = FST (x:real^3 # real^3)`; ASM_REWRITE_TAC[]; FIRST_X_ASSUM (MP_TAC o (SPEC` n:num`)); ANTS_TAC; ARITH_TAC; SIMP_TAC[]; REWRITE_TAC[IN_INTER]; UNDISCH_TAC` FAN (vec 0,v_prime V fv,e_prime (E UNION {{v, w:real^3}}) fv) `; PHA; NGOAC; NHANH Wrgcvdr_cizmrrh.IN_NODE_IMP_FIRST_EQ; STRIP_TAC; DOWN; USE_FIRST` (w,v) INSERT {ITER n (rho_node1 FF) v,ITER (n + 1) (rho_node1 FF) v | n | !m. m < n + 1 ==> ~ (ITER m (rho_node1 FF) v = w)} = fv ` (SUBST1_TAC o SYM); REWRITE_TAC[IN_INSERT; IN_ELIM_THM]; STRIP_TAC; UNDISCH_TAC` FST (x':real^3 # real^3) = FST (x:real^3 # real^3)`; ASM_REWRITE_TAC[]; FIRST_X_ASSUM (MP_TAC o (SPEC` n:num`)); ANTS_TAC; ARITH_TAC; SIMP_TAC[]; UNDISCH_TAC` FST (x':real^3 # real^3) = FST (x:real^3 # real^3)`; ASM_REWRITE_TAC[]; ASSUME_TAC2 Local_lemmas.LOCAL_FAN_ORBIT_MAP_V; DOWN; NHANH Local_lemmas.LOOP_SET_DETER_FIRTS_ELMS; STRIP_TAC; FIRST_X_ASSUM (ASSUME_TAC2 o (SPEC`v: real^3 `)); UNDISCH_TAC` w:real^3 IN V `; EXPAND_TAC "V"; REWRITE_TAC[IN_ELIM_THM]; STRIP_TAC; ASM_CASES_TAC` ~( n < CARD (V:real^3 -> bool))`; ASSUME_TAC2 (ARITH_RULE` ~( n < CARD (V:real^3 -> bool)) /\ n'' < CARD V ==> n'' < n + 1 `); USE_FIRST` !m. m < n + 1 ==> ~(ITER m (rho_node1 FF) v = w) ` (ASSUME_TAC2 o (SPEC`n'': num `)); DOWN; ASM_REWRITE_TAC[]; ASM_CASES_TAC` ~( n' < CARD (V:real^3 -> bool)) `; ASSUME_TAC2 (ARITH_RULE` ~( n' < CARD (V:real^3 -> bool)) /\ n'' < CARD V ==> n'' < n' + 1 `); USE_FIRST` !m. m < n' + 1 ==> ~(ITER m (rho_node1 FF) v = w) ` (ASSUME_TAC2 o (SPEC`n'': num `)); DOWN; ASM_REWRITE_TAC[]; DOWN THEN DOWN; ASSUME_TAC2 Local_lemmas.LOFA_IMP_DIS_ELMS23; PHA; ASM_CASES_TAC` n < n':num `; STRIP_TAC; FIRST_X_ASSUM (MP_TAC o (SPECL[` n:num`;` n':num`])); DISCH_THEN ASSUME_TAC2; DOWN; ASM_REWRITE_TAC[]; ASM_CASES_TAC` n' < n:num `; STRIP_TAC; FIRST_X_ASSUM (MP_TAC o (SPECL[` n':num `;` n:num`])); DISCH_THEN ASSUME_TAC2; DOWN THEN ASM_REWRITE_TAC[]; ASSUME_TAC2 (ARITH_RULE` ~( n < n':num) /\ ~(n' < n) ==> n' = n `); ASM_REWRITE_TAC[]; (* ================================== *) MP_TAC DETERMINE_FV; ANTS_TAC; ASM_REWRITE_TAC[]; DISCH_THEN (ASSUME_TAC o SYM); (* ================================== *) UNDISCH_TAC` x IN {v,w | w,v IN (fv:real^3 # real^3 -> bool)} `; EXPAND_TAC "fv"; REWRITE_TAC[IN_ELIM_THM; IN_INSERT]; ASM_REWRITE_TAC[]; STRIP_TAC; SUBGOAL_THEN `x IN dart (hypermap (HYP (vec 0,v_prime V fv,e_prime (E UNION {{v, w}}) fv))) ` MP_TAC; ASM_REWRITE_TAC[IN_UNION; IN_ELIM_THM]; DISJ2_TAC; EXISTS_TAC` v:real^3`; EXISTS_TAC` w:real^3 `; DOWN THEN DOWN; SIMP_TAC[PAIR_EQ]; EXPAND_TAC "fv"; REWRITE_TAC[IN_INSERT]; NHANH Hypermap.lemma_node_subset; ASM_REWRITE_TAC[]; STRIP_TAC; REWRITE_TAC[EXTENSION; IN_INTER]; GEN_TAC; EQ_TAC; STRIP_TAC; MP_TAC ( ISPECL [`vec 0: real^3 `; ` v_prime (V:real^3 -> bool) (fv:real^3#real^3->bool) `; `e_prime (E UNION {{v:real^3, w}}) (fv: real^3#real^3->bool) `;` x': real^3#real^3`; `(v':real^3, w':real^3) `] (GEN_ALL Wrgcvdr_cizmrrh.IN_NODE_IMP_FIRST_EQ)); ANTS_TAC; ASM_REWRITE_TAC[]; REPLICATE_TAC 3 DOWN; REWRITE_TAC[SUBSET]; STRIP_TAC; FIRST_ASSUM NHANH; REWRITE_TAC[IN_UNION]; STRIP_TAC; UNDISCH_TAC` w':real^3, v':real^3 = w:real^3, v:real^3 `; SIMP_TAC[PAIR_EQ]; REPEAT STRIP_TAC; UNDISCH_TAC` x':real^3#real^3 IN fv `; UNDISCH_TAC` face (hypermap (HYP (vec 0,V,E UNION {{v, w}}))) (v,rho_node1 FF v) = fv`; STRIP_TAC; EXPAND_TAC "fv"; NHANH Hypermap.lemma_face_identity; ASM_REWRITE_TAC[]; UNDISCH_TAC` x' IN face (hypermap (HYP (vec 0,v_prime V fv,e_prime (E UNION {{v, w}}) fv))) (v,w) `; NHANH Hypermap.lemma_face_identity; ASM_REWRITE_TAC[]; REPEAT STRIP_TAC; SUBGOAL_THEN` fv = face (hypermap (HYP (vec 0,v_prime V fv,e_prime (E UNION {{v, w}}) fv))) x'` MP_TAC; MATCH_MP_TAC Lvducxu.LOCALIZE_PRESERVE_FACE; ASM_REWRITE_TAC[]; SUBGOAL_THEN` v, rho_node1 FF v IN dart HS ` MP_TAC; EXPAND_TAC "HS"; UNDISCH_TAC` FAN (vec 0,V,E UNION {{v, w:real^3}})`; NHANH Lvducxu.FAN_DART_DARTS; SIMP_TAC[]; STRIP_TAC; MATCH_MP_TAC IN_DARTS_EXTENSION; MATCH_MP_TAC LOCAL_RHO_NODE_PAIR_E; ASM_REWRITE_TAC[]; NHANH_PAT`\x. x ==> y ` Hypermap.lemma_face_subset; ASM_REWRITE_TAC[SUBSET]; DOWN THEN DOWN; MESON_TAC[]; STRIP_TAC; SUBGOAL_THEN ` (v:real^3, w:real^3) IN face (hypermap (HYP (vec 0,v_prime V fv,e_prime (E UNION {{v, w}}) fv))) (v,w)` MP_TAC; REWRITE_TAC[Hypermap.face_refl]; DOWN THEN DOWN; DISCH_THEN (ASSUME_TAC o SYM); DISCH_THEN (ASSUME_TAC o SYM); ASM_REWRITE_TAC[]; UNDISCH_TAC` (w,v) INSERT {ITER n (rho_node1 FF) v,ITER (n + 1) (rho_node1 FF) v | n | !m. m < n + 1 ==> ~ (ITER m (rho_node1 FF) v = w)} = fv`; DISCH_TAC; EXPAND_TAC "fv"; ASM_REWRITE_TAC[IN_INSERT; PAIR_EQ]; REWRITE_TAC[IN_ELIM_THM]; STRIP_TAC; SUBGOAL_THEN` ~((v:real^3,w:real^3) IN FF) ` MP_TAC; MATCH_MP_TAC CROSS_PAIR_NOT_IN_FF; ASM_REWRITE_TAC[]; ASSUME_TAC2 LOCAL_FAN_ORBIT_MAP_VITERFF; DOWN THEN DOWN; MESON_TAC[]; (* ======================= *) STRIP_TAC THEN STRIP_TAC; UNDISCH_TAC` x' IN {(v:real^3 ,w:real^3) | w,v IN fv}`; EXPAND_TAC "fv"; REWRITE_TAC[IN_ELIM_THM; IN_INSERT]; STRIP_TAC; DOWN THEN DOWN; UNDISCH_TAC` w',v' = (w:real^3,v:real^3) `; ASM_SIMP_TAC[PAIR_EQ]; UNDISCH_TAC` w'',v'' = ITER n (rho_node1 FF) v,ITER (n + 1) (rho_node1 FF) v`; UNDISCH_TAC` FST (x':real^3#real^3) = v'`; ASM_SIMP_TAC[PAIR_EQ]; UNDISCH_TAC` w',v' = w:real^3, v:real^3 `; SIMP_TAC[PAIR_EQ]; ASSUME_TAC2 Local_lemmas.LOFA_IMP_LT_CARD_SET_V; REPEAT STRIP_TAC; ASSUME_TAC (ARITH_RULE` ~( n + 1 = 0) `); MP_TAC (SPEC` n + 1 ` (GEN `n:num ` CARD_IS_LEAST_CYCLE)); ANTS_TAC; DOWN THEN DOWN; ASM_REWRITE_TAC[]; SIMP_TAC[EQ_SYM_EQ]; MESON_TAC[]; STRIP_TAC; UNDISCH_TAC` w:real^3 IN V `; EXPAND_TAC "V"; REWRITE_TAC[IN_ELIM_THM]; STRIP_TAC; ASSUME_TAC2 (ARITH_RULE` CARD (V:real^3 -> bool) <= n + 1 /\ n' < CARD V ==> n' < n + 1 `); ASM_MESON_TAC[]; SIMP_TAC[IN_INSERT; NOT_IN_EMPTY; Wrgcvdr_cizmrrh.X_IN_HYP_ORBITS]; (* =============================== *) REWRITE_TAC[EXTENSION; IN_INSERT; NOT_IN_EMPTY; IN_INTER]; GEN_TAC; EQ_TAC; ONCE_REWRITE_TAC[CONJ_SYM]; STRIP_TAC; DOWN; UNDISCH_TAC` FAN (vec 0,v_prime V fv,e_prime (E UNION {{v:real^3, w}}) fv)`; PHA; NHANH Wrgcvdr_cizmrrh.IN_NODE_IMP_FIRST_EQ; SUBGOAL_THEN` x IN dart (hypermap (HYP (vec 0,v_prime V fv,e_prime (E UNION {{v:real^3, w}}) fv)))` MP_TAC; ASM_REWRITE_TAC[IN_UNION]; DISJ2_TAC; REWRITE_TAC[IN_ELIM_THM]; EXISTS_TAC` ITER (n + 1) (rho_node1 FF) v `; EXISTS_TAC` ITER n (rho_node1 FF) v `; UNDISCH_TAC` w',v' = ITER n (rho_node1 FF) v,ITER (n + 1) (rho_node1 FF) v `; SIMP_TAC[PAIR_EQ]; EXPAND_TAC "fv"; STRIP_TAC; REWRITE_TAC[IN_INSERT; IN_ELIM_THM]; DISJ2_TAC; EXISTS_TAC`n:num`; ASM_REWRITE_TAC[]; NHANH Hypermap.lemma_node_subset; REWRITE_TAC[SUBSET]; STRIP_TAC; FIRST_ASSUM NHANH; ASM_REWRITE_TAC[IN_UNION]; STRIP_TAC; SUBGOAL_THEN` (v,rho_node1 FF v) IN dart (hypermap (HYP (vec 0,V,E UNION {{v, w}})))` MP_TAC; ASM_REWRITE_TAC[]; UNDISCH_TAC` FAN (vec 0,V,E UNION {{v, w:real^3}}) `; NHANH Lvducxu.FAN_DART_DARTS; ASM_SIMP_TAC[]; STRIP_TAC; UNDISCH_TAC` face HS (v,rho_node1 FF v) = fv `; DISCH_THEN (MP_TAC o SYM); DOWN; UNDISCH_TAC` FAN (vec 0,V,E UNION {{v, w:real^3}})`; PHA; ASM_REWRITE_TAC[]; EXPAND_TAC "HS"; NHANH Lvducxu.LOCALIZE_PRESERVE_FACE; ASM_REWRITE_TAC[]; STRIP_TAC; UNDISCH_TAC` x':real^3#real^3 IN fv `; FIRST_ASSUM (SUBST1_TAC); NHANH Hypermap.lemma_face_identity; FIRST_X_ASSUM (ASSUME_TAC o SYM); ASM_REWRITE_TAC[]; UNDISCH_TAC ` x' IN face (hypermap (HYP (vec 0,v_prime V fv,e_prime (E UNION {{v, w}}) fv))) x`; NHANH Hypermap.lemma_face_identity; STRIP_TAC; STRIP_TAC; MP_TAC (ISPECL [` (hypermap (HYP (vec 0,v_prime V fv,e_prime (E UNION {{v, w:real^3}}) fv))) `;` x:real^3# real^3 `] Hypermap.face_refl); ASM_REWRITE_TAC[]; FIRST_ASSUM (SUBST1_TAC o SYM); UNDISCH_TAC` (w,v) INSERT {ITER n (rho_node1 FF) v,ITER (n + 1) (rho_node1 FF) v | n | !m. m < n + 1 ==> ~ (ITER m (rho_node1 FF) v = w)} = fv `; STRIP_TAC; FIRST_ASSUM (SUBST1_TAC o SYM); REWRITE_TAC[IN_INSERT]; STRIP_TAC; UNDISCH_TAC`w',v' = ITER n (rho_node1 FF) v,ITER (n + 1) (rho_node1 FF) v `; DOWN; SIMP_TAC[PAIR_EQ]; STRIP_TAC THEN STRIP_TAC; DOWN; ASM_REWRITE_TAC[GSYM ADD1; ITER]; ASSUME_TAC2 Local_lemmas.LOCAL_FAN_RHO_NODE_PROS2; DOWN THEN STRIP_TAC; FIRST_X_ASSUM (ASSUME_TAC2 o (SPEC`v: real^3`)); STRIP_TAC; ASSUME_TAC2 CROSS_PAIR_NOT_IN_FF; DOWN; UNDISCH_TAC` v,rho_node1 FF v IN FF `; ASM_REWRITE_TAC[]; REPLICATE_TAC 3 DOWN; MESON_TAC[]; (* ============================ *) (* ============================ *) DOWN; REWRITE_TAC[IN_ELIM_THM]; STRIP_TAC; DOWN; UNDISCH_TAC` w',v' = ITER n (rho_node1 FF) v,ITER (n + 1) (rho_node1 FF) v `; REWRITE_TAC[PAIR_EQ; GSYM ADD1; ITER]; STRIP_TAC; (* 33 [`v' = rho_node1 FF (ITER n (rho_node1 FF) v)`] `v' = ITER n' (rho_node1 FF) v /\ w' = rho_node1 FF (ITER n' (rho_node1 FF) v) ==> x' = v',w'` *) IMP_TAC; DISCH_THEN (SUBST1_TAC o SYM); ASM_REWRITE_TAC[]; (* *) ASSUME_TAC2 Local_lemmas.LOCAL_FAN_IMP_NOT_SEMI_IDE; FIRST_X_ASSUM (MP_TAC o (SPEC` ITER n (rho_node1 FF) v `)); ANTS_TAC; ASSUME_TAC2 Local_lemmas.LOCAL_FAN_ORBIT_MAP_VITER; FIRST_X_ASSUM MATCH_MP_TAC; FIRST_X_ASSUM ACCEPT_TAC; MESON_TAC[]; (* =============== *) (* =============== *) DOWN THEN DOWN; REWRITE_TAC[IN_ELIM_THM]; EXPAND_TAC "fv"; REWRITE_TAC[IN_ELIM_THM; IN_INSERT]; STRIP_TAC; DOWN THEN DOWN; UNDISCH_TAC` w',v' = ITER n (rho_node1 FF) v,ITER (n + 1) (rho_node1 FF) v `; SIMP_TAC[PAIR_EQ]; REPEAT STRIP_TAC; MP_TAC (SPEC` n + 1 ` (GEN `n:num ` CARD_IS_LEAST_CYCLE)); ANTS_TAC; FIRST_X_ASSUM (SUBST1_TAC o SYM); ASM_REWRITE_TAC[ARITH_RULE` ~( n + 1 = 0) `]; ASSUME_TAC2 Local_lemmas.LOFA_IMP_LT_CARD_SET_V; UNDISCH_TAC` (w:real^3) IN V `; EXPAND_TAC "V"; REWRITE_TAC[IN_ELIM_THM]; ASM_REWRITE_TAC[]; UNDISCH_TAC` !m. m < n + 1 ==> ~(ITER m (rho_node1 FF) v = w) `; MESON_TAC[ARITH_RULE` a < b /\ b <= c ==> a < (c:num) `]; (* OK *) ASM_CASES_TAC` CARD (V:real^3 -> bool) <= n + 1 `; ASSUME_TAC2 Local_lemmas.LOFA_IMP_LT_CARD_SET_V; UNDISCH_TAC` w:real^3 IN V `; EXPAND_TAC "V"; REWRITE_TAC[IN_ELIM_THM]; UNDISCH_TAC` !m. m < n + 1 ==> ~(ITER m (rho_node1 FF) v = w)`; UNDISCH_TAC` CARD (V:real^3 -> bool) <= n + 1 `; MESON_TAC[ARITH_RULE` a < b /\ b <= n + 1 ==> a < n + 1 `]; (* ???? *) ASSUME_TAC2 Local_lemmas.LOFA_IMP_DIS_ELMS23; FIRST_X_ASSUM (MP_TAC o (SPECL[` 0`; `n + 1 `])); ANTS_TAC; ARITH_TAC; ANTS_TAC; DOWN THEN ARITH_TAC; DOWN THEN DOWN; REWRITE_TAC[ITER]; MESON_TAC[]; (* ok *) ASM_CASES_TAC` CARD (V:real^3 -> bool) <= n' + 1 `; ASSUME_TAC2 Local_lemmas.LOFA_IMP_LT_CARD_SET_V; UNDISCH_TAC` w:real^3 IN V `; EXPAND_TAC "V"; REWRITE_TAC[IN_ELIM_THM]; UNDISCH_TAC` !m. m < n' + 1 ==> ~(ITER m (rho_node1 FF) v = w)`; UNDISCH_TAC` CARD (V:real^3 -> bool) <= n' + 1 `; MESON_TAC[ARITH_RULE` a < b /\ b <= n + 1 ==> a < n + 1 `]; (* * *) ASM_CASES_TAC` CARD (V:real^3 -> bool) <= n + 1 `; ASSUME_TAC2 Local_lemmas.LOFA_IMP_LT_CARD_SET_V; UNDISCH_TAC` w:real^3 IN V `; EXPAND_TAC "V"; REWRITE_TAC[IN_ELIM_THM]; UNDISCH_TAC` !m. m < n + 1 ==> ~(ITER m (rho_node1 FF) v = w)`; UNDISCH_TAC` CARD (V:real^3 -> bool) <= n + 1 `; MESON_TAC[ARITH_RULE` a < b /\ b <= n + 1 ==> a < n + 1 `]; DOWN THEN DOWN; REWRITE_TAC[ARITH_RULE` ~( a <= n + 1 ) <=> n + 1 < a `]; DOWN THEN DOWN; UNDISCH_TAC` w',v' = ITER n (rho_node1 FF) v,ITER (n + 1) (rho_node1 FF) v `; SIMP_TAC[PAIR_EQ]; REPEAT STRIP_TAC; ASM_CASES_TAC` n + 1 < n' + 1 \/ n' + 1 < n + 1 `; ASSUME_TAC2 Local_lemmas.LOFA_IMP_DIS_ELMS23; REPLICATE_TAC 5 DOWN; MESON_TAC[]; DOWN; REWRITE_TAC[DE_MORGAN_THM; ARITH_RULE` ~( a < b) /\ ~( b < a:num) <=> a = b `; ARITH_RULE` a + 1 = b + 1 <=> a = b `]; SIMP_TAC[]; SIMP_TAC[Wrgcvdr_cizmrrh.X_IN_HYP_ORBITS]; DOWN; PHA; MATCH_MP_TAC (prove(`!x. FAN (vec 0,V,E) /\ x IN darts_of_hyp E V /\ FF = face (hypermap (HYP (vec 0,V,E))) x ==> 2 < CARD FF /\ simple_hypermap (hypermap (HYP (vec 0,v_prime V FF,e_prime E FF))) ==> local_fan (v_prime V FF,e_prime E FF,FF)`, NHANH Lvducxu.LVDUCXU THEN SIMP_TAC[])); EXISTS_TAC` v, rho_node1 FF v `; ASM_REWRITE_TAC[]]);;
let HAFL_CIRCLE_FORM_LOCAL_FAN2 = 
prove_by_refinement (` (local_fan (V,E,FF) /\ v IN V /\ w IN V /\ ~(v = w) /\ (!z t. z IN {v, w} /\ t IN V DIFF {z} ==> ~collinear {vec 0, z, t}) /\ (!x. x IN FF ==> aff_gt {vec 0} {v, w} SUBSET wedge_in_fan_gt x E)) /\ HS = hypermap (HYP (vec 0,V,E UNION {{v, w}})) /\ fv = face HS (v,rho_node1 FF v) /\ fw = face HS (w,rho_node1 FF w) ==> local_fan (v_prime V fv,e_prime (E UNION {{v, w}}) fv,fv) /\ local_fan (v_prime V fw,e_prime (E UNION {{w, v}}) fw,fw) `,
[STRIP_TAC; CONJ_TAC; MATCH_MP_TAC HAFL_CIRCLE_FORM_LOCAL_FAN; ASM_REWRITE_TAC[]; MATCH_MP_TAC HAFL_CIRCLE_FORM_LOCAL_FAN; ASM_REWRITE_TAC[INSERT_COMM]; UNDISCH_TAC` !z t. z IN {v, w} /\ t IN V DIFF {z} ==> ~collinear {vec 0, z, t:real^3} `; DISCH_THEN NHANH; SIMP_TAC[INSERT_COMM]]);;
let LOCAL_FAN_RHO_NODE_IVS = 
prove_by_refinement ( ` local_fan (V,E,FF) /\ v IN V ==> rho_node1 FF (ivs_rho_node1 FF v ) = v `,
[NHANH Local_lemmas.ITER_CARD_MINUS1_EQ_IVS_RN1; STRIP_TAC; DOWN; FIRST_X_ASSUM NHANH; STRIP_TAC; FIRST_X_ASSUM (SUBST1_TAC o SYM); REWRITE_TAC[GSYM ITER]; ASSUME_TAC2 Local_lemmas.LOCAL_FAN_FINITE_V; DOWN THEN DOWN THEN PHA; REWRITE_TAC[SET_RULE` a IN X <=> {a} SUBSET X `]; NHANH CARD_SUBSET; STRIP_TAC; DOWN; SUBST1_TAC (ISPEC`v:real^3` Trigonometry2.CARD_SING); NHANH (ARITH_RULE` 1 <= a ==> SUC (a - 1) = a`); SIMP_TAC[]; STRIP_TAC; ASSUME_TAC2 Local_lemmas.LOFA_IMP_ITER_RHO_NODE_ID; FIRST_X_ASSUM MATCH_MP_TAC; DOWN_TAC; SIMP_TAC[INSERT_SUBSET]]);;
let LOCAL_FAN_IVS_IN_V = 
prove(` local_fan (V,E,FF) /\ v IN V ==> ivs_rho_node1 FF v IN V `,
NHANH Local_lemmas.LOCAL_FAN_ITER_RHO_NODE_IN_V THEN NHANH Local_lemmas.ITER_CARD_MINUS1_EQ_IVS_RN1 THEN MESON_TAC[]);;
let LF_AZIM_CYCLE_EQ_IVS_ND = 
prove(` local_fan (V,E,FF) /\ v IN V ==> azim_cycle (EE v E) (vec 0) v (rho_node1 FF v) = ivs_rho_node1 FF v `,
NHANH LOCAL_FAN_RHO_NODE_IVS THEN NHANH LOCAL_FAN_IVS_IN_V THEN ABBREV_TAC` vv = ivs_rho_node1 FF v ` THEN STRIP_TAC THEN ASSUME_TAC2 Local_lemmas.LOFA_IMP_EE_TWO_ELMS THEN ASM_REWRITE_TAC[Local_lemmas.AZIM_CYCLE_TWO_POINT_SET]);;
let AZIM_IN_FAN_RHOND_IVS_RHOND = 
prove(` local_fan (V,E,FF) /\ v IN V ==> azim_in_fan (v, rho_node1 FF v) E = azim (vec 0) v (rho_node1 FF v) (ivs_rho_node1 FF v) `,
STRIP_TAC THEN ASSUME_TAC2 Local_lemmas.LOCAL_FAN_RHO_NODE_PROS2 THEN DOWN THEN STRIP_TAC THEN FIRST_X_ASSUM (ASSUME_TAC2 o (SPEC`v:real^3`)) THEN DOWN THEN UNDISCH_TAC` local_fan (V,E,FF)` THEN PHA THEN NHANH Local_lemmas.LOFA_DETERMINE_AZIM_IN_FA THEN SIMP_TAC[] THEN STRIP_TAC THEN ASSUME_TAC2 LF_AZIM_CYCLE_EQ_IVS_ND THEN ASM_REWRITE_TAC[]);;
let LOFA_IMP_EE_TWO_ELMS_INS_ND = 
prove(` local_fan (V,E,FF) /\ v IN V ==> EE v E = {rho_node1 FF v, ivs_rho_node1 FF v} `,
NHANH LOCAL_FAN_IVS_IN_V THEN NHANH LOCAL_FAN_RHO_NODE_IVS THEN STRIP_TAC THEN ABBREV_TAC `vv = ivs_rho_node1 FF v ` THEN ASSUME_TAC2 Local_lemmas.LOFA_IMP_EE_TWO_ELMS THEN FIRST_X_ASSUM ACCEPT_TAC);;
let WEDGE_IN_FAN_RHOND_IVS_RHOND = 
prove(` local_fan (V,E,FF) /\ v IN V ==> wedge_in_fan_ge (v,rho_node1 FF v) E = wedge_ge (vec 0) v (rho_node1 FF v) (ivs_rho_node1 FF v) `,
NHANH Local_lemmas.LOCAL_FAN_RHO_NODE_PROS2 THEN STRIP_TAC THEN DOWN THEN FIRST_X_ASSUM NHANH THEN STRIP_TAC THEN DOWN THEN UNDISCH_TAC `local_fan (V,E,FF) ` THEN PHA THEN NHANH Local_lemmas.DETERMINE_WEDGE_IN_FAN THEN SIMP_TAC[] THEN STRIP_TAC THEN ASSUME_TAC2 LOFA_IMP_EE_TWO_ELMS_INS_ND THEN ASM_SIMP_TAC[Local_lemmas.AZIM_CYCLE_TWO_POINT_SET]);;
let FST_LST_IN_WEDGE_GE = 
prove(` w1 IN wedge_ge v0 v1 w1 w2 /\ w2 IN wedge_ge v0 v1 w1 w2`,
REWRITE_TAC[wedge_ge; IN_ELIM_THM; AZIM_REFL; Local_lemmas.AZIM_RANGE] THEN REWRITE_TAC[REAL_LE_REFL]);;
let IVS_RHO_NODE_DIFF_ID = 
prove(`!v. local_fan (V,E,FF) /\ v IN V ==> ~(ivs_rho_node1 FF v = v)`,
NHANH LOCAL_FAN_IVS_IN_V THEN NHANH Local_lemmas.LOCAL_FAN_CHARACTER_OF_RHO_NODE THEN REPEAT STRIP_TAC THEN FIRST_X_ASSUM (ASSUME_TAC2 o (SPEC` ivs_rho_node1 FF v `)) THEN ASSUME_TAC2 LOCAL_FAN_RHO_NODE_IVS THEN FIRST_X_ASSUM SUBST_ALL_TAC THEN DOWN THEN ASM_REWRITE_TAC[]);;
let POINT_PRESENTED_IN_RHOND1 = 
prove( ` local_fan (V,E,FF) /\ v IN V /\ w IN V ==> ? n. n < CARD V /\ ITER n (rho_node1 FF) v = w /\ (! m. m < n ==> ~( ITER m (rho_node1 FF) v = w )) `,
STRIP_TAC THEN ASSUME_TAC2 Local_lemmas.LOFA_IMP_LT_CARD_SET_V THEN UNDISCH_TAC ` w:real^3 IN V ` THEN EXPAND_TAC "V" THEN REWRITE_TAC[IN_ELIM_THM] THEN ASM_REWRITE_TAC[] THEN STRIP_TAC THEN EXISTS_TAC `n:num` THEN ASM_REWRITE_TAC[] THEN ASSUME_TAC2 Local_lemmas.LOFA_IMP_DIS_ELMS23 THEN GEN_TAC THEN STRIP_TAC THEN FIRST_X_ASSUM (MP_TAC o (SPECL [`m:num `;` n:num`])) THEN PHA THEN PHA THEN ANTS_TAC THENL [ASM_REWRITE_TAC[]; SIMP_TAC[]]);;
let POINTS_IN_HAFL_CIRCLE = 
prove_by_refinement (` (local_fan (V,E,FF) /\ v IN V /\ w IN V /\ ~(v = w) /\ (!z t. z IN {v, w} /\ t IN V DIFF {z} ==> ~collinear {vec 0, z, t}) /\ (!x. x IN FF ==> aff_gt {vec 0} {v, w} SUBSET wedge_in_fan_gt x E)) /\ HS = hypermap (HYP (vec 0,V,E UNION {{v, w}})) /\ fv = face HS (v,rho_node1 FF v) ==> v_prime V fv = {ITER n (rho_node1 FF) v| n | ! m . m < n ==> ~(ITER m (rho_node1 FF ) v = w)} `,
[NHANH DETERMINE_FV; REWRITE_TAC[v_prime]; STRIP_TAC; REWRITE_TAC[EXTENSION]; GEN_TAC; EQ_TAC; REWRITE_TAC[IN_ELIM_THM]; FIRST_X_ASSUM (ASSUME_TAC o SYM); EXPAND_TAC "fv";
REWRITE_TAC[IN_INSERT; IN_ELIM_THM]; STRIP_TAC; ASSUME_TAC2 POINT_PRESENTED_IN_RHOND1; DOWN THEN STRIP_TAC; EXISTS_TAC `n:num`; REPLICATE_TAC 4 DOWN THEN PHA; REWRITE_TAC[PAIR_EQ]; ASM_SIMP_TAC[]; DOWN; REWRITE_TAC[PAIR_EQ]; STRIP_TAC; EXISTS_TAC` n:num `; ASM_REWRITE_TAC[]; GEN_TAC; NHANH (ARITH_RULE` a < (b:num) ==> a < b + 1 `); FIRST_X_ASSUM NHANH; SIMP_TAC[]; REWRITE_TAC[IN_ELIM_THM]; STRIP_TAC; ASSUME_TAC2 Local_lemmas.LOCAL_FAN_ITER_RHO_NODE_IN_V; FIRST_X_ASSUM (MP_TAC o (SPEC` n:num `)); ASM_SIMP_TAC[]; STRIP_TAC; UNDISCH_TAC` fv = face HS (v,rho_node1 FF v) `; DISCH_THEN (ASSUME_TAC o SYM); UNDISCH_TAC` HS = hypermap (HYP (vec 0,V,E UNION {{v, w:real^3}}))`; DISCH_THEN (ASSUME_TAC o SYM); ASM_REWRITE_TAC[]; REWRITE_TAC[IN_INSERT; IN_ELIM_THM]; ASM_CASES_TAC` x = (w:real^3) `; EXISTS_TAC `v:real^3 `; DISJ1_TAC; FIRST_X_ASSUM (ASSUME_TAC o SYM); ASM_REWRITE_TAC[]; EXISTS_TAC` ITER (n + 1) (rho_node1 FF) v`; DISJ2_TAC; EXISTS_TAC` n:num`; REWRITE_TAC[]; GEN_TAC; ASM_CASES_TAC` m = n:num `; UNDISCH_TAC` x = ITER n (rho_node1 FF) v `; ASM_REWRITE_TAC[]; DISCH_THEN (SUBST1_TAC o SYM); ASM_REWRITE_TAC[]; DOWN THEN PHA; REWRITE_TAC[ARITH_RULE` ~(m = n) /\ m < n + 1 <=> m < n `]; FIRST_X_ASSUM NHANH; SIMP_TAC[]]);;
let COVEX_OF_LOFA_HALF_CIRCLE = 
prove_by_refinement (`convex_local_fan (V,E,FF) /\ (local_fan (V,E,FF) /\ v IN V /\ w IN V /\ ~(v = w) /\ (!z t. z IN {v, w} /\ t IN V DIFF {z} ==> ~collinear {vec 0, z, t}) /\ (!x. x IN FF ==> aff_gt {vec 0} {v, w} SUBSET wedge_in_fan_gt x E)) /\ HS = hypermap (HYP (vec 0,V,E UNION {{v, w}})) /\ fv = face HS (v,rho_node1 FF v) ==> convex_local_fan (v_prime V fv,e_prime (E UNION {{v, w}}) fv,fv) `,
[NHANH HAFL_CIRCLE_FORM_LOCAL_FAN; REWRITE_TAC[convex_local_fan]; NHANH DETERMINE_FV; ONCE_REWRITE_TAC[EQ_SYM_EQ]; SIMP_TAC[]; STRIP_TAC; EXPAND_TAC "fv";
REWRITE_TAC[IN_ELIM_THM; IN_INSERT]; ASM_REWRITE_TAC[]; GEN_TAC; STRIP_TAC; SUBGOAL_THEN ` (w:real^3,v:real^3) IN fv ` MP_TAC; EXPAND_TAC "fv"; REWRITE_TAC[IN_INSERT]; UNDISCH_TAC` local_fan (v_prime V fv,e_prime (E UNION {{v, w:real^3}}) fv,fv)`; PHA; NHANH Local_lemmas.LOFA_DETERMINE_AZIM_IN_FA; ASM_SIMP_TAC[]; STRIP_TAC; SUBGOAL_THEN ` e_prime (E UNION {{v, w}}) fv = {{v,w:real^3} | v,w IN fv }` MP_TAC; REWRITE_TAC[EXTENSION]; GEN_TAC; REWRITE_TAC[e_prime; IN_ELIM_THM]; EQ_TAC; MESON_TAC[]; STRIP_TAC; EXISTS_TAC` v':real^3`; EXISTS_TAC` w': real^3 `; ASM_REWRITE_TAC[]; UNDISCH_TAC` v':real^3, w': real^3 IN fv `; EXPAND_TAC "fv"; REWRITE_TAC[IN_INSERT; IN_ELIM_THM]; STRIP_TAC; DOWN; SIMP_TAC[PAIR_EQ; INSERT_COMM; IN_UNION; IN_INSERT]; ASSUME_TAC2 LOCAL_FAN_ORBIT_MAP_VITERFF; FIRST_X_ASSUM (ASSUME_TAC o (SPEC`n: num`)); DOWN; UNDISCH_TAC` local_fan (V,E,FF) `; PHA; NHANH Local_lemmas.LOCAL_FAN_IN_FF_IN_ORD_PAIRS2; DOWN; SIMP_TAC[PAIR_EQ; IN_UNION]; STRIP_TAC; ASM_REWRITE_TAC[]; SUBGOAL_THEN` EE w {{v, w} | v,w IN fv} = {v:real^3, ivs_rho_node1 FF w}` MP_TAC; REWRITE_TAC[EE; EXTENSION]; GEN_TAC; EQ_TAC; REWRITE_TAC[IN_ELIM_THM; IN_INSERT; NOT_IN_EMPTY]; EXPAND_TAC "fv"; REWRITE_TAC[IN_INSERT; IN_ELIM_THM]; STRIP_TAC; DOWN THEN DOWN THEN PHA; REWRITE_TAC[PAIR_EQ]; SET_TAC[]; DOWN THEN REWRITE_TAC[Geomdetail.PAIR_EQ_EXPAND]; DOWN; REWRITE_TAC[PAIR_EQ]; FIRST_ASSUM (MP_TAC o (SPEC` n: num `)); ANTS_TAC; ARITH_TAC; SIMP_TAC[]; REPEAT STRIP_TAC; DISJ2_TAC; ASSUME_TAC2 Local_lemmas.LOCAL_FAN_ITER_RHO_NODE_IN_V; FIRST_X_ASSUM (MP_TAC o (SPEC` n:num `)); UNDISCH_TAC ` local_fan (V,E,FF) `; PHA; NHANH Local_lemmas.IVS_RHO_IDD; REWRITE_TAC[GSYM ITER; ADD1]; SIMP_TAC[]; REWRITE_TAC[IN_INSERT; NOT_IN_EMPTY; IN_ELIM_THM]; STRIP_TAC; EXISTS_TAC` w:real^3 `; EXISTS_TAC` v:real^3 `; EXPAND_TAC "fv"; REWRITE_TAC[IN_INSERT]; FIRST_X_ASSUM SUBST1_TAC; REWRITE_TAC[]; ASSUME_TAC2 Local_lemmas.LOFA_IMP_LT_CARD_SET_V; UNDISCH_TAC` w:real^3 IN V `; EXPAND_TAC "V"; REWRITE_TAC[IN_ELIM_THM]; STRIP_TAC; ASM_CASES_TAC` n = 0 `; FIRST_X_ASSUM SUBST_ALL_TAC; DOWN THEN REWRITE_TAC[ITER]; ASM_REWRITE_TAC[]; EXISTS_TAC` ITER (n - 1) (rho_node1 FF) v `; EXISTS_TAC` ITER (n - 1 + 1) (rho_node1 FF) v `; EXPAND_TAC "fv"; REWRITE_TAC[IN_INSERT; IN_ELIM_THM]; CONJ_TAC; DISJ2_TAC; EXISTS_TAC `n - 1 `; DOWN; REWRITE_TAC[]; NHANH (ARITH_RULE` ~( n = 0) ==> n - 1 + 1 = n `); SIMP_TAC[]; ASSUME_TAC2 Local_lemmas.LOFA_IMP_DIS_ELMS23; ASM_REWRITE_TAC[]; DOWN; UNDISCH_TAC` n < CARD (V:real^3 -> bool) `; PHA THEN MESON_TAC[]; MATCH_MP_TAC (SET_RULE` a = d /\ b = c ==> {a,b} = {c,d} `); ASM_REWRITE_TAC[]; DOWN; NHANH (ARITH_RULE` ~( n = 0) ==> n - 1 + 1 = n `); SIMP_TAC[]; ASSUME_TAC2 Local_lemmas.ITER_CARD_MINUS1_EQ_IVS_RN1; ASSUME_TAC2 Local_lemmas.LOCAL_FAN_ITER_RHO_NODE_IN_V; FIRST_X_ASSUM (MP_TAC o (SPEC` n:num `)); FIRST_X_ASSUM NHANH; REWRITE_TAC[ITER_ADD]; ASM_CASES_TAC` n = 0 `; FIRST_X_ASSUM SUBST_ALL_TAC; DOWN; ASM_REWRITE_TAC[ITER]; ASSUME_TAC2 (SPEC` CARD (V:real^3 -> bool)` (ARITH_RULE`!m. n < m /\ ~( n = 0) ==> m - 1 + n = m + n - 1 `)); ASM_REWRITE_TAC[]; REWRITE_TAC[GSYM ITER_ADD]; ASSUME_TAC2 Local_lemmas.LOCAL_FAN_ITER_RHO_NODE_IN_V; FIRST_X_ASSUM (ASSUME_TAC o (SPEC` n - 1 `)); REPEAT STRIP_TAC; UNDISCH_TAC` ITER (n - 1) (rho_node1 FF) v IN V `; ASSUME_TAC2 Local_lemmas.LOFA_IMP_ITER_RHO_NODE_ID; FIRST_X_ASSUM NHANH; ASM_SIMP_TAC[]; SIMP_TAC[Local_lemmas.AZIM_CYCLE_TWO_POINT_SET]; STRIP_TAC; ASSUME_TAC2 (SPEC` w:real^3 ` (GEN`v: real^3 ` WEDGE_IN_FAN_RHOND_IVS_RHOND)); ASSUME_TAC2 Local_lemmas.LOCAL_FAN_RHO_NODE_PROS2; DOWN THEN STRIP_TAC; FIRST_X_ASSUM (ASSUME_TAC2 o (SPEC` w:real^3`)); DOWN; UNDISCH_TAC` !x. (x:real^3#real^3) IN FF ==> azim_in_fan x E <= pi /\ V SUBSET wedge_in_fan_ge x E`; STRIP_TAC; FIRST_ASSUM NHANH; ASM_REWRITE_TAC[]; ASSUME_TAC2 (SPEC` w:real^3` (GEN `v:real^3` AZIM_IN_FAN_RHOND_IVS_RHOND)); ASM_REWRITE_TAC[]; REWRITE_TAC[wedge_ge; SUBSET]; STRIP_TAC; FIRST_X_ASSUM (ASSUME_TAC2 o (SPEC` v:real^3 `)); DOWN; REWRITE_TAC[IN_ELIM_THM]; STRIP_TAC; MP_TAC (SPECL [` vec 0: real^3 `;` w:real^3 `;` rho_node1 FF w `;` ivs_rho_node1 FF w`; ` v:real^3 `; ` ivs_rho_node1 FF w `] (GEN_ALL Local_lemmas.IN_WEDGE_IMP_AZIM_LE)); ANTS_TAC; ASM_REWRITE_TAC[FST_LST_IN_WEDGE_GE]; UNDISCH_TAC` !z t. z IN {v:real^3, w} /\ t IN V DIFF {z} ==> ~collinear {vec 0, z, t}`; DISCH_THEN (ASSUME_TAC o (SPEC` w:real^3 `)); FIRST_ASSUM (MP_TAC o (SPEC` v:real^3 `)); ANTS_TAC; ASM_REWRITE_TAC[IN_INSERT; IN_DIFF; NOT_IN_EMPTY]; FIRST_ASSUM (MP_TAC o (SPEC` ivs_rho_node1 FF w `)); ANTS_TAC; REWRITE_TAC[IN_INSERT; IN_DIFF; NOT_IN_EMPTY]; ASSUME_TAC2 (SPEC` w:real^3` (GEN `v:real^3 ` LOCAL_FAN_IVS_IN_V)); ASSUME_TAC2 (SPEC` w: real^3 ` IVS_RHO_NODE_DIFF_ID); ASM_REWRITE_TAC[]; FIRST_ASSUM (MP_TAC o (SPEC`rho_node1 FF w `)); ANTS_TAC; REWRITE_TAC[IN_INSERT; IN_DIFF; NOT_IN_EMPTY]; ASSUME_TAC2 (SPEC` w:real^3 ` (GEN`v: real^3 ` Local_lemmas.LOFA_IN_V_SO_DO_RHO_NODE_V)); ASSUME_TAC2 Local_lemmas.LOCAL_FAN_CHARACTER_OF_RHO_NODE; FIRST_X_ASSUM (ASSUME_TAC2 o (SPEC` w:real^3 `)); ASM_REWRITE_TAC[]; SIMP_TAC[]; STRIP_TAC; CONJ_TAC; UNDISCH_TAC` azim (vec 0) w (rho_node1 FF w) (ivs_rho_node1 FF w) <= pi `; DOWN; PHA THEN REWRITE_TAC[REAL_LE_TRANS]; SUBGOAL_THEN `(w:real^3) IN v_prime V (fv: real^3#real^3 -> bool)` MP_TAC; MP_TAC POINTS_IN_HAFL_CIRCLE; ANTS_TAC; ASM_REWRITE_TAC[]; SIMP_TAC[IN_ELIM_THM]; ASSUME_TAC2 POINT_PRESENTED_IN_RHOND1; DOWN THEN STRIP_TAC; STRIP_TAC; EXISTS_TAC` n: num `; ASM_REWRITE_TAC[]; UNDISCH_TAC` local_fan (v_prime V fv,e_prime (E UNION {{v:real^3, w}}) fv,fv) `; PHA; NHANH WEDGE_IN_FAN_RHOND_IVS_RHOND; STRIP_TAC; UNDISCH_TAC` (w:real^3,v:real^3) IN fv`; UNDISCH_TAC` local_fan (v_prime V fv,e_prime (E UNION {{v:real^3, w}}) fv,fv)`; PHA; NHANH Local_lemmas.DETER_RHO_NODE; STRIP_TAC; UNDISCH_TAC` wedge_in_fan_ge (w,rho_node1 fv w) (e_prime (E UNION {{v, w}}) fv) = wedge_ge (vec 0) w (rho_node1 fv w) (ivs_rho_node1 fv w) `; ASM_SIMP_TAC[]; STRIP_TAC; SUBGOAL_THEN` ivs_rho_node1 FF w, w IN fv ` MP_TAC; ASSUME_TAC2 POINT_PRESENTED_IN_RHOND1; DOWN THEN STRIP_TAC; EXPAND_TAC "fv"; REWRITE_TAC[IN_INSERT; IN_ELIM_THM]; DISJ2_TAC; EXISTS_TAC` n - 1 `; ASM_CASES_TAC` n = 0 `; FIRST_X_ASSUM SUBST_ALL_TAC; DOWN THEN DOWN; ASM_REWRITE_TAC[ITER]; ASSUME_TAC2 (ARITH_RULE` ~( n = 0) ==> n - 1 + 1 = n `); ASM_REWRITE_TAC[PAIR_EQ]; EXPAND_TAC "w"; EXPAND_TAC "n"; REWRITE_TAC[GSYM ADD1; ITER]; ASSUME_TAC2 Local_lemmas.LOCAL_FAN_ITER_RHO_NODE_IN_V; FIRST_X_ASSUM (MP_TAC o (SPEC` n - 1 `)); UNDISCH_TAC` local_fan (V,E,FF) `; PHA; NHANH Local_lemmas.IVS_RHO_IDD; SIMP_TAC[ADD1; ARITH_RULE` (a + 1) - 1 = a `]; UNDISCH_TAC` local_fan (v_prime V fv,e_prime (E UNION {{v, w}}) fv,fv) `; PHA; NHANH Local_lemmas.IVS_RHO_NODE1_DETE; SIMP_TAC[] THEN STRIP_TAC; MP_TAC (REWRITE_RULE[] ( SPECL [` w:real^3 `;` CARD (V:real^3 -> bool) `;` \i. ITER i (rho_node1 FF) w `;` \i. azim (vec 0) w (ITER 1 (rho_node1 FF) w) (ITER i (rho_node1 FF) w) `] (GENL [` v0:real^3 `;` k: num `;` vv: num -> real^3 `;` bta: num -> real`] Local_lemmas.MONO_AZIM_AS_BTA_I))); ANTS_TAC; ASM_REWRITE_TAC[convex_local_fan]; UNDISCH_TAC` !z t. z IN {v, w} /\ t IN V DIFF {z:real^3} ==> ~collinear {vec 0, z, t} `; DISCH_THEN (MP_TAC o (SPEC` w:real^3 `)); REWRITE_TAC[IN_INSERT; IN_DIFF; NOT_IN_EMPTY]; MP_TAC POINTS_IN_HAFL_CIRCLE; ANTS_TAC; ASM_REWRITE_TAC[]; SIMP_TAC[]; REWRITE_TAC[IN_ELIM_THM]; REPEAT STRIP_TAC; MP_TAC (SPECL [` w:real^3 `;` v:real^3 `] (GENL [` v:real^3`;` w:real^3 `] POINT_PRESENTED_IN_RHOND1)); ANTS_TAC; ASM_REWRITE_TAC[]; STRIP_TAC; ASM_CASES_TAC` CARD (V:real^3 -> bool) < n + n' `; DOWN; UNDISCH_TAC` n' < CARD (V:real^3 -> bool) `; PHA; NHANH (ARITH_RULE` (c:num) < a /\ a < b + c ==> a - c < b `); UNDISCH_TAC` !m. m < n ==> ~(ITER m (rho_node1 FF) v = w) `; STRIP_TAC; FIRST_ASSUM NHANH; EXPAND_TAC "v"; SIMP_TAC[ITER_ADD]; NHANH ( ARITH_RULE` b < CARD (V:real^3 -> bool) ==> CARD V - b + b = CARD V`); STRIP_TAC; DOWN; ASM_REWRITE_TAC[]; ASSUME_TAC2 Local_lemmas.LOFA_IMP_ITER_RHO_NODE_ID; FIRST_X_ASSUM (ASSUME_TAC2 o (SPEC` w:real^3 `)); ASM_REWRITE_TAC[]; ASM_CASES_TAC` n + n' = CARD (V:real^3 -> bool) `; ASM_REWRITE_TAC[]; EXPAND_TAC "v"; REWRITE_TAC[ITER_ADD]; ASM_REWRITE_TAC[]; ASSUME_TAC2 Local_lemmas.LOFA_IMP_ITER_RHO_NODE_ID; FIRST_X_ASSUM (ASSUME_TAC2 o (SPEC` w:real^3 `)); ASM_REWRITE_TAC[wedge_ge; IN_ELIM_THM; Local_lemmas.AZIM_SPEC_DEGENERATE]; REWRITE_TAC[REAL_LE_REFL; Local_lemmas.AZIM_RANGE]; ASM_CASES_TAC` n = 0 `; FIRST_X_ASSUM SUBST_ALL_TAC; UNDISCH_TAC` x' = ITER 0 (rho_node1 FF) v `; REWRITE_TAC[ITER]; SIMP_TAC[wedge_ge; IN_ELIM_THM; AZIM_REFL; REAL_LE_REFL; Local_lemmas.AZIM_RANGE]; FIRST_ASSUM (MP_TAC o (SPECL[` n':num `;` n + (n':num) `])); ANTS_TAC; REPLICATE_TAC 3 DOWN THEN PHA; ARITH_TAC; ASM_REWRITE_TAC[GSYM ITER_ADD]; UNDISCH_TAC` x' = ITER n (rho_node1 FF) v `; DISCH_THEN (ASSUME_TAC o SYM); ASM_REWRITE_TAC[Wrgcvdr_cizmrrh.ITER1]; REWRITE_TAC[wedge_ge; IN_ELIM_THM; Local_lemmas.AZIM_RANGE]; STRIP_TAC; ASM_CASES_TAC` n + n' = CARD (V:real^3 -> bool) - 1`; EXPAND_TAC "x'"; EXPAND_TAC "v"; REWRITE_TAC[ITER_ADD]; ASM_REWRITE_TAC[]; ASSUME_TAC2 Local_lemmas.ITER_CARD_MINUS1_EQ_IVS_RN1; FIRST_X_ASSUM (ASSUME_TAC2 o (SPEC` w: real^3 `)); FIRST_X_ASSUM SUBST1_TAC; REWRITE_TAC[REAL_LE_REFL]; FIRST_ASSUM (MP_TAC o (SPECL [` n + n':num `;` CARD (V:real^3 -> bool) - 1 `])); ANTS_TAC; DOWN; UNDISCH_TAC` ~(CARD (V:real^3 -> bool) < n + n')`; UNDISCH_TAC` ~(n + n' = CARD (V:real^3 -> bool))`; ARITH_TAC; REWRITE_TAC[Wrgcvdr_cizmrrh.ITER1]; ASSUME_TAC2 Local_lemmas.ITER_CARD_MINUS1_EQ_IVS_RN1; FIRST_ASSUM (ASSUME_TAC2 o (SPEC`w:real^3 `)); ASM_REWRITE_TAC[GSYM ITER_ADD]; STRIP_TAC; SUBGOAL_THEN` ~ (collinear {vec 0, w, v:real^3}) /\ ~( collinear {vec 0, w, x'}) /\ ~( collinear {vec 0, w, rho_node1 FF w})` MP_TAC; CONJ_TAC; FIRST_ASSUM MATCH_MP_TAC; ASM_REWRITE_TAC[IN_INSERT; IN_DIFF; NOT_IN_EMPTY]; CONJ_TAC; FIRST_ASSUM MATCH_MP_TAC; REWRITE_TAC[IN_INSERT; IN_DIFF; NOT_IN_EMPTY]; EXPAND_TAC "x'"; EXPAND_TAC "v"; REWRITE_TAC[ITER_ADD]; ASSUME_TAC2 (SPEC` w:real^3 ` (GEN` v:real^3 ` Local_lemmas.LOCAL_FAN_ITER_RHO_NODE_IN_V)); FIRST_X_ASSUM (MP_TAC o (SPEC` n + n': num `)); SIMP_TAC[]; STRIP_TAC; MP_TAC (SPEC` w:real^3` (GEN` v:real^3 ` Local_lemmas.LOFA_IMP_DIS_ELMS23)); ANTS_TAC; ASM_REWRITE_TAC[]; DISCH_THEN (MP_TAC o (SPECL [`0 `;` n + n': num `])); ANTS_TAC; UNDISCH_TAC` ~( n = 0) `; UNDISCH_TAC` ~(CARD (V:real^3 -> bool) < n + n')`; UNDISCH_TAC` ~(n + n' = CARD (V:real^3 -> bool))`; ARITH_TAC; SIMP_TAC[ITER]; ASSUME_TAC2 (SPEC` w:real^3` (GEN` v:real^3 ` Local_lemmas.LOCAL_FAN_CHARACTER_OF_RHO_NODE2)); FIRST_X_ASSUM ACCEPT_TAC; UNDISCH_TAC` azim (vec 0) w (rho_node1 FF w) v <= azim (vec 0) w (rho_node1 FF w) x' `; PHA; NHANH Fan.sum4_azim_fan; STRIP_TAC; SUBGOAL_THEN` ~ collinear {vec 0, w, v:real^3} /\ ~ collinear {vec 0, w, ivs_rho_node1 FF w} /\ ~ collinear {vec 0, w, rho_node1 FF w} ` MP_TAC; ASM_REWRITE_TAC[]; ASSUME_TAC2 (SPEC` w:real^3 ` Local_lemmas.LOFA_IMP_NOT_COLL_IVS); FIRST_X_ASSUM ACCEPT_TAC; SUBGOAL_THEN` azim (vec 0) w (rho_node1 FF w) v <= azim (vec 0) w (rho_node1 FF w) (ivs_rho_node1 FF w)` MP_TAC; MATCH_MP_TAC REAL_LE_TRANS; EXISTS_TAC` azim (vec 0) w (rho_node1 FF w) x' `; ASM_REWRITE_TAC[]; PHA; NHANH Fan.sum4_azim_fan; STRIP_TAC; UNDISCH_TAC` azim (vec 0) w (rho_node1 FF w) x' <= azim (vec 0) w (rho_node1 FF w) (ivs_rho_node1 FF w) `; ASM_REWRITE_TAC[]; REAL_ARITH_TAC; ASM_CASES_TAC` n = 0 `; FIRST_X_ASSUM SUBST_ALL_TAC; MP_TAC POINTS_IN_HAFL_CIRCLE; ANTS_TAC; ASM_REWRITE_TAC[]; STRIP_TAC; SUBGOAL_THEN` (v:real^3) IN v_prime V (fv:real^3 #real^3 -> bool) ` MP_TAC; ASM_REWRITE_TAC[IN_ELIM_THM]; EXISTS_TAC `0`; REWRITE_TAC[ITER; LT]; UNDISCH_TAC` local_fan (v_prime V fv,e_prime (E UNION {{v:real^3, w}}) fv,fv)`; PHA; NHANH AZIM_IN_FAN_RHOND_IVS_RHOND; DOWN THEN DOWN; REWRITE_TAC[ITER; ADD; Lvducxu.ITER12]; DISCH_THEN (ASSUME_TAC o SYM); DISCH_THEN (ASSUME_TAC o SYM); STRIP_TAC; SUBGOAL_THEN` v,rho_node1 FF v IN fv ` MP_TAC; EXPAND_TAC "fv"; REWRITE_TAC[IN_INSERT; IN_ELIM_THM]; DISJ2_TAC; EXISTS_TAC` 0 `; ASM_REWRITE_TAC[]; EXPAND_TAC "x"; REWRITE_TAC[ITER; ADD; Lvducxu.ITER12]; UNDISCH_TAC` local_fan (v_prime V fv,e_prime (E UNION {{v, w:real^3}}) fv,fv) `; PHA; NHANH Local_lemmas.DETER_RHO_NODE; STRIP_TAC; SUBGOAL_THEN` (w:real^3, v:real^3) IN fv ` MP_TAC; EXPAND_TAC "fv"; REWRITE_TAC[IN_INSERT]; UNDISCH_TAC` local_fan (v_prime V fv,e_prime (E UNION {{v:real^3, w}}) fv,fv) `; PHA; NHANH Local_lemmas.IVS_RHO_NODE1_DETE; STRIP_TAC; UNDISCH_TAC` azim_in_fan (v,rho_node1 fv v) (e_prime (E UNION {{v, w}}) fv) = azim (vec 0) v (rho_node1 fv v) (ivs_rho_node1 fv v) `; ASM_SIMP_TAC[]; STRIP_TAC; UNDISCH_TAC` !x. (x:real^3#real^3) IN FF ==> azim_in_fan x E <= pi /\ V SUBSET wedge_in_fan_ge x E `; ASSUME_TAC2 Local_lemmas.LOCAL_FAN_RHO_NODE_PROS2; DOWN THEN STRIP_TAC; STRIP_TAC; FIRST_ASSUM (ASSUME_TAC2 o (SPEC` v:real^3 `)); DOWN; FIRST_ASSUM NHANH; ASSUME_TAC2 AZIM_IN_FAN_RHOND_IVS_RHOND; ASSUME_TAC2 WEDGE_IN_FAN_RHOND_IVS_RHOND; ASM_REWRITE_TAC[SUBSET]; STRIP_TAC; FIRST_ASSUM (ASSUME_TAC2 o (SPEC` w:real^3 `)); DOWN; REWRITE_TAC[wedge_ge; IN_ELIM_THM]; STRIP_TAC; CONJ_TAC; MATCH_MP_TAC REAL_LE_TRANS; EXISTS_TAC` azim (vec 0) v (rho_node1 FF v) (ivs_rho_node1 FF v) `; ASM_REWRITE_TAC[]; GEN_TAC; STRIP_TAC; UNDISCH_TAC` v IN v_prime V (fv:real^3#real^3 -> bool) `; UNDISCH_TAC` local_fan (v_prime V fv,e_prime (E UNION {{v, w:real^3}}) fv,fv) `; PHA; NHANH WEDGE_IN_FAN_RHOND_IVS_RHOND; ASM_SIMP_TAC[]; STRIP_TAC; SUBGOAL_THEN` (x':real^3) IN {ITER n (rho_node1 FF) v | n | !m. m < n ==> ~(ITER m (rho_node1 FF) v = w)}` MP_TAC; ASM_REWRITE_TAC[]; REWRITE_TAC[IN_ELIM_THM]; STRIP_TAC; ASSUME_TAC2 POINT_PRESENTED_IN_RHOND1; DOWN THEN STRIP_TAC; ASM_CASES_TAC` n'' < (n':num) `; DOWN; UNDISCH_TAC` !m. m < n' ==> ~(ITER m (rho_node1 FF) v = w)`; DISCH_THEN NHANH; ASM_REWRITE_TAC[]; ASM_CASES_TAC` n'' = (n': num) `; FIRST_X_ASSUM SUBST_ALL_TAC; ASM_REWRITE_TAC[FST_LST_IN_WEDGE_GE]; MP_TAC ( SPEC` CARD (V:real^3 -> bool) ` ( GEN `k: num ` ( REWRITE_RULE[] ( SPECL [`v:real^3 `; `\i. ITER i (rho_node1 FF) v `; `\i. azim (vec 0) v (rho_node1 FF v) ( ITER i (rho_node1 FF) v) `] (GENL [` v0:real^3`; ` vv: num -> real^3 `;` bta: num -> real`] Local_lemmas.MONO_AZIM_AS_BTA_I))))); ANTS_TAC; ASM_REWRITE_TAC[convex_local_fan; Lvducxu.ITER12]; GEN_TAC THEN STRIP_TAC; FIRST_X_ASSUM MATCH_MP_TAC; ASM_REWRITE_TAC[IN_INSERT; IN_DIFF; NOT_IN_EMPTY]; DISCH_THEN (MP_TAC o (SPECL [` n':num `;` n'': num `])); ANTS_TAC; ASM_REWRITE_TAC[]; DOWN THEN DOWN THEN ARITH_TAC; ASM_SIMP_TAC[wedge_ge; IN_ELIM_THM; Local_lemmas.AZIM_RANGE]; DOWN THEN DOWN; DISCH_THEN (ASSUME_TAC o SYM); STRIP_TAC; MP_TAC POINTS_IN_HAFL_CIRCLE; ANTS_TAC; ASM_REWRITE_TAC[]; DISCH_THEN (ASSUME_TAC o SYM); SUBGOAL_THEN` ITER n (rho_node1 FF) v IN {ITER n (rho_node1 FF) v | n | !m. m < n ==> ~(ITER m (rho_node1 FF) v = w)} ` MP_TAC; REWRITE_TAC[IN_ELIM_THM]; EXISTS_TAC` n: num `; REWRITE_TAC[]; NHANH (ARITH_RULE` m < n:num ==> m < n + 1 `); FIRST_ASSUM NHANH; SIMP_TAC[]; ASM_REWRITE_TAC[]; UNDISCH_TAC` local_fan (v_prime V fv,e_prime (E UNION {{v:real^3, w}}) fv,fv) `; PHA; NHANH AZIM_IN_FAN_RHOND_IVS_RHOND; STRIP_TAC; SUBGOAL_THEN` (x:real^3 # real^3) IN fv ` MP_TAC; EXPAND_TAC "fv"; REWRITE_TAC[IN_INSERT; IN_ELIM_THM]; DISJ2_TAC; EXISTS_TAC` n:num `; ASM_REWRITE_TAC[]; EXPAND_TAC "x"; UNDISCH_TAC` local_fan (v_prime V fv,e_prime (E UNION {{v, w:real^3}}) fv,fv) `; PHA; NHANH Local_lemmas.DETER_RHO_NODE; ASM_REWRITE_TAC[]; STRIP_TAC; SUBGOAL_THEN` (ivs_rho_node1 FF (ITER n (rho_node1 FF) v)), ITER n (rho_node1 FF) v IN fv ` MP_TAC; EXPAND_TAC "fv"; REWRITE_TAC[IN_INSERT; IN_ELIM_THM]; DISJ2_TAC; EXISTS_TAC` n - 1 `; ASSUME_TAC2 (ARITH_RULE` ~( n = 0) ==> n - 1 + 1 = n `); ASM_REWRITE_TAC[]; NHANH (ARITH_RULE` m < n ==> m < n + 1 `); FIRST_ASSUM NHANH; SIMP_TAC[]; ASSUME_TAC2 Local_lemmas.LOCAL_FAN_ITER_RHO_NODE_IN_V; REWRITE_TAC[PAIR_EQ]; EXPAND_TAC "n"; ONCE_REWRITE_TAC[ADD_SYM]; REWRITE_TAC[GSYM ITER_ADD; Lvducxu.ITER12]; FIRST_ASSUM (ASSUME_TAC o (SPEC` n - 1 `)); ASSUME_TAC2 ( SPEC` ITER (n - 1) (rho_node1 FF) v ` (GEN`v: real^3 ` Local_lemmas.IVS_RHO_IDD)); ONCE_REWRITE_TAC[ADD_SYM]; ASM_REWRITE_TAC[]; UNDISCH_TAC` local_fan (v_prime V fv,e_prime (E UNION {{v, w:real^3}}) fv,fv) `; PHA; NHANH Local_lemmas.IVS_RHO_NODE1_DETE; STRIP_TAC; UNDISCH_TAC` azim_in_fan (ITER n (rho_node1 FF) v,rho_node1 fv (ITER n (rho_node1 FF) v)) (e_prime (E UNION {{v, w}}) fv) = azim (vec 0) (ITER n (rho_node1 FF) v) (rho_node1 fv (ITER n (rho_node1 FF) v)) (ivs_rho_node1 fv (ITER n (rho_node1 FF) v)) `; ASM_REWRITE_TAC[]; SIMP_TAC[]; STRIP_TAC; ASSUME_TAC2 LOCAL_FAN_ORBIT_MAP_VITERFF; FIRST_ASSUM (MP_TAC o (SPEC` n:num `)); UNDISCH_TAC` !x. (x:real^3#real^3) IN FF ==> azim_in_fan x E <= pi /\ V SUBSET wedge_in_fan_ge x E`; STRIP_TAC; FIRST_ASSUM NHANH; ASSUME_TAC2 Local_lemmas.LOCAL_FAN_ITER_RHO_NODE_IN_V; STRIP_TAC; FIRST_ASSUM (MP_TAC o (SPEC` n:num `)); UNDISCH_TAC` local_fan (V,E,FF) `; PHA; NHANH AZIM_IN_FAN_RHOND_IVS_RHOND; REWRITE_TAC[GSYM ITER; ADD1]; STRIP_TAC; FIRST_X_ASSUM (ASSUME_TAC o SYM); UNDISCH_TAC` azim_in_fan (ITER n (rho_node1 FF) v,ITER (n + 1) (rho_node1 FF) v) E <= pi `; ASM_REWRITE_TAC[]; SIMP_TAC[]; STRIP_TAC; MP_TAC POINTS_IN_HAFL_CIRCLE; ANTS_TAC; ASM_REWRITE_TAC[]; DISCH_THEN (ASSUME_TAC o SYM); SUBGOAL_THEN ` ITER n (rho_node1 FF) v IN v_prime V (fv:real^3#real^3 -> bool) ` MP_TAC; FIRST_X_ASSUM (SUBST1_TAC o SYM); REWRITE_TAC[IN_ELIM_THM]; EXISTS_TAC` n:num `; ASM_REWRITE_TAC[]; UNDISCH_TAC` !m. m < n + 1 ==> ~(ITER m (rho_node1 FF) v = w) `; MESON_TAC[ARITH_RULE` m < n ==> m < n + 1 `]; UNDISCH_TAC` local_fan (v_prime V fv,e_prime (E UNION {{v:real^3, w}}) fv,fv) `; PHA; NHANH WEDGE_IN_FAN_RHOND_IVS_RHOND; ASM_SIMP_TAC[]; STRIP_TAC; ASSUME_TAC2 (SPEC` ITER n (rho_node1 FF) v ` (GEN`v:real^3 ` WEDGE_IN_FAN_RHOND_IVS_RHOND)); FIRST_X_ASSUM (MP_TAC o SYM); ASM_REWRITE_TAC[GSYM ITER; ADD1]; SIMP_TAC[]; STRIP_TAC; MATCH_MP_TAC SUBSET_TRANS; EXISTS_TAC` V:real^3 -> bool` ; ASM_REWRITE_TAC[]; UNDISCH_TAC` V SUBSET wedge_in_fan_ge (ITER n (rho_node1 FF) v,ITER (n + 1) (rho_node1 FF) v) E `; ASM_REWRITE_TAC[]; SIMP_TAC[]; UNDISCH_TAC` {ITER n (rho_node1 FF) v | n | !m. m < n ==> ~(ITER m (rho_node1 FF) v = w)} = v_prime V (fv:real^3#real^3 -> bool) `; DISCH_THEN (SUBST1_TAC o SYM); REWRITE_TAC[SUBSET; IN_ELIM_THM]; REPEAT STRIP_TAC; ASM_REWRITE_TAC[]]);;
let COVEX_OF_LOFA_HALF_CIRCLE2 = 
prove( ` convex_local_fan (V,E,FF) /\ (local_fan (V,E,FF) /\ v IN V /\ w IN V /\ ~(v = w) /\ (!z t. z IN {v, w} /\ t IN V DIFF {z} ==> ~collinear {vec 0, z, t}) /\ (!x. x IN FF ==> aff_gt {vec 0} {v, w} SUBSET wedge_in_fan_gt x E)) /\ HS = hypermap (HYP (vec 0,V,E UNION {{v, w}})) /\ fv = face HS (v,rho_node1 FF v) /\ fw = face HS (w, rho_node1 FF w) ==> convex_local_fan (v_prime V fv,e_prime (E UNION {{v, w}}) fv,fv) /\ convex_local_fan (v_prime V fw,e_prime (E UNION {{w, v}}) fw,fw)`,
STRIP_TAC THEN CONJ_TAC THENL [MATCH_MP_TAC COVEX_OF_LOFA_HALF_CIRCLE THEN ASM_REWRITE_TAC[]; MATCH_MP_TAC COVEX_OF_LOFA_HALF_CIRCLE THEN DOWN_TAC THEN SIMP_TAC[INSERT_COMM]]);;
(* ======================================================================== *)
let CARD_V_TWO_HAFL_CIRCLE = 
prove_by_refinement (` local_fan (V,E,FF) /\ v IN V /\ w IN V /\ ~ (v = w) /\ ITER n (rho_node1 FF) v = w /\ ITER n' (rho_node1 FF) w = v /\ n < CARD V /\ n' < CARD V ==> n + n' = CARD V `,
[STRIP_TAC; MP_TAC (SPEC` w:real^3 ` (GEN` v: real^3 ` Local_lemmas.LOFA_IMP_DIS_ELMS23)); ANTS_TAC; ASM_REWRITE_TAC[]; STRIP_TAC; UNDISCH_TAC` ITER n (rho_node1 FF) v = w `; EXPAND_TAC "v";
REWRITE_TAC[ITER_ADD]; ASM_CASES_TAC` n + n': num = 0 `; DOWN; REWRITE_TAC[ADD_EQ_0]; STRIP_TAC; FIRST_X_ASSUM SUBST_ALL_TAC; DOWN_TAC; REWRITE_TAC[ITER]; MESON_TAC[]; STRIP_TAC; ASSUME_TAC2 (SPECL [` w:real^3 `;` n + n':num` ] (GENL [` v:real^3 `;` n: num `] CARD_IS_LEAST_CYCLE)); ASM_CASES_TAC` CARD (V:real^3 -> bool) = n + n' `; ASM_REWRITE_TAC[]; FIRST_X_ASSUM (MP_TAC o (SPECL [` 0`;` (n + n') - CARD (V:real^3 -> bool) `])); ANTS_TAC; DOWN THEN DOWN; UNDISCH_TAC` n < CARD (V:real^3 -> bool) `; UNDISCH_TAC` n' < CARD (V:real^3 -> bool) `; PHA THEN ARITH_TAC; ASM_REWRITE_TAC[ITER]; ASSUME_TAC2 Local_lemmas.LOFA_IMP_ITER_RHO_NODE_ID; ASSUME_TAC2 Local_lemmas.LOCAL_FAN_ORBIT_MAP_VITER; FIRST_X_ASSUM (ASSUME_TAC2 o (SPECL [` w:real^3 `;` (n + n') - CARD (V:real^3 -> bool) `])); DOWN; FIRST_X_ASSUM NHANH; REWRITE_TAC[ITER_ADD]; ASSUME_TAC2 (ARITH_RULE` CARD (V:real^3 -> bool) <= n + n' ==> CARD V + (n + n') - CARD V = n + n'`); ASM_REWRITE_TAC[]; MESON_TAC[]]);;
let DIFFERENCE_IMP_LT_CARDV = 
prove_by_refinement (` local_fan (V,E,FF) /\ v IN V /\ w IN V /\ (! n. n < m ==> ~(ITER n (rho_node1 FF) v = w)) ==> m < CARD V `,
[STRIP_TAC; ASM_CASES_TAC` m < CARD (V:real^3 -> bool) `; FIRST_ASSUM ACCEPT_TAC; ASSUME_TAC2 Local_lemmas.LOFA_IMP_LT_CARD_SET_V; UNDISCH_TAC` (w:real^3) IN V `; EXPAND_TAC "V";
REWRITE_TAC[IN_ELIM_THM]; STRIP_TAC; ASM_REWRITE_TAC[]; DOWN; REWRITE_TAC[]; ONCE_REWRITE_TAC[EQ_SYM_EQ]; FIRST_X_ASSUM MATCH_MP_TAC; DOWN; UNDISCH_TAC` ~(m < CARD (V:real^3 -> bool)) `; ARITH_TAC]);;
let LT_CARD_MONO_LOFA = 
prove(`local_fan (V,E,FF) /\ v IN V ==> (! i j. i < CARD V /\ j < CARD V /\ ITER i (rho_node1 FF) v = ITER j (rho_node1 FF) v ==> i = j )`,
NHANH Local_lemmas.LOFA_IMP_DIS_ELMS23 THEN REPEAT STRIP_TAC THEN ASM_CASES_TAC` i = (j:num) ` THENL [FIRST_X_ASSUM ACCEPT_TAC; DOWN] THEN REWRITE_TAC[ARITH_RULE` ~( a = (b:num)) <=> a < b \/ b < a `] THEN DOWN_TAC THEN PHA THEN MESON_TAC[]);;
let CONDS_IN_V_PRIME_NUM = 
prove_by_refinement (` (local_fan (V,E,FF) /\ v IN V /\ w IN V /\ ~(v = w) /\ (!z t. z IN {v, w} /\ t IN V DIFF {z} ==> ~collinear {vec 0, z, t}) /\ (!x. x IN FF ==> aff_gt {vec 0} {v, w} SUBSET wedge_in_fan_gt x E)) /\ HS = hypermap (HYP (vec 0,V,E UNION {{v, w}})) /\ fv = face HS (v,rho_node1 FF v) ==> n < CARD V /\ ITER n (rho_node1 FF) v = w ==> ! i. i < CARD V /\ ITER i (rho_node1 FF) v IN v_prime V fv <=> i < n + 1 `,
[NHANH POINTS_IN_HAFL_CIRCLE; STRIP_TAC THEN STRIP_TAC; GEN_TAC; EQ_TAC; ASM_REWRITE_TAC[IN_ELIM_THM]; STRIP_TAC; ASSUME_TAC2 Local_lemmas.LOCAL_FAN_ITER_RHO_NODE_IN_V; ASSUME_TAC2 (SPECL [` n': num `] (GENL [` m:num `] DIFFERENCE_IMP_LT_CARDV)); ASSUME_TAC2 LT_CARD_MONO_LOFA; FIRST_X_ASSUM (MP_TAC o (SPECL [`i:num `;` n': num `])); PHA; ANTS_TAC; ASM_REWRITE_TAC[]; DISCH_THEN (SUBST_ALL_TAC o SYM); ASM_CASES_TAC` i < n + 1 `; FIRST_X_ASSUM ACCEPT_TAC; ASSUME_TAC2 (ARITH_RULE` ~(i < n + 1) ==> n < i `); DOWN; FIRST_X_ASSUM NHANH; ASM_REWRITE_TAC[]; STRIP_TAC; CONJ_TAC; REPLICATE_TAC 3 DOWN THEN PHA; ARITH_TAC; ASM_REWRITE_TAC[IN_ELIM_THM]; EXISTS_TAC`i: num `; REWRITE_TAC[]; REPEAT STRIP_TAC; ASSUME_TAC2 (ARITH_RULE` i < n + 1 /\ m < i ==> m < n `); MP_TAC Local_lemmas.LOFA_IMP_DIS_ELMS23; ANTS_TAC; ASM_REWRITE_TAC[]; ASM_MESON_TAC[]]);;
let LOFA_IMP_ITER_RHO_NODE_ID2 = MESON[ Local_lemmas.LOFA_IMP_ITER_RHO_NODE_ID]` local_fan (V,E,FF) /\ v IN V ==> ITER (CARD V) (rho_node1 FF) v = v`;;
let CONDS_IN_V_PRIME_NUM2 = 
prove_by_refinement (`(local_fan (V,E,FF) /\ v IN V /\ w IN V /\ ~(v = w) /\ (!z t. z IN {v, w} /\ t IN V DIFF {z} ==> ~collinear {vec 0, z, t}) /\ (!x. x IN FF ==> aff_gt {vec 0} {v, w} SUBSET wedge_in_fan_gt x E)) /\ HS = hypermap (HYP (vec 0,V,E UNION {{v, w}})) /\ fw = face HS (w,rho_node1 FF w) ==> n < CARD V /\ ITER n (rho_node1 FF) v = w ==> (!i. i < CARD V /\ ITER i (rho_node1 FF) v IN v_prime V fw <=> i = 0 \/ n <= i /\ i < CARD V )`,
[STRIP_TAC; ASSUME_TAC2 (SPECL [` w:real^3 `;` v:real^3 `] (GENL [`v:real^3 `;` w:real^3 `] POINT_PRESENTED_IN_RHOND1)); DOWN THEN STRIP_TAC; MP_TAC (SPECL [` w:real^3 `;` v:real^3 `; ` fw: real^3#real^3 -> bool`;` n': num `] (GENL [` v: real^3`;` w:real^3 `;` fv: real^3#real^3 -> bool`; `n:num `] CONDS_IN_V_PRIME_NUM)); ANTS_TAC; DOWN_TAC; SIMP_TAC[INSERT_COMM]; ANTS_TAC; ASM_REWRITE_TAC[]; STRIP_TAC; STRIP_TAC; GEN_TAC; UNDISCH_TAC` !i. i < CARD (V:real^3 -> bool) /\ ITER i (rho_node1 FF) w IN v_prime V (fw:real^3 # real^3 -> bool) <=> i < n' + 1 `; EXPAND_TAC "w";
REWRITE_TAC[ITER_ADD]; ASSUME_TAC2 CARD_V_TWO_HAFL_CIRCLE; ASM_CASES_TAC` i = 0 `; UNDISCH_TAC` HS = hypermap (HYP (vec 0,V,E UNION {{v:real^3, w}}))`; DISCH_THEN (ASSUME_TAC o SYM); UNDISCH_TAC` fw = face HS (w,rho_node1 FF w) `; DISCH_THEN (ASSUME_TAC o SYM); ASM_REWRITE_TAC[ITER]; STRIP_TAC; ASSUME_TAC2 Local_lemmas.LOFA_IMP_ITER_RHO_NODE_ID; FIRST_X_ASSUM (ASSUME_TAC2 o (SPEC` v:real^3 `)); EXPAND_TAC "v"; UNDISCH_TAC` n + n' = CARD (V:real^3 -> bool) `; DISCH_THEN (ASSUME_TAC o SYM); FIRST_ASSUM SUBST1_TAC; ONCE_REWRITE_TAC[ADD_SYM]; CONJ_TAC; DOWN; UNDISCH_TAC` n < CARD (V:real^3 -> bool) `; ARITH_TAC; UNDISCH_TAC` n' < CARD (V:real^3 -> bool) `; UNDISCH_TAC` !i. i < CARD V /\ ITER (i + n) (rho_node1 FF) v IN v_prime V (fw:real^3#real^3 -> bool) <=> i < n' + 1 `; MP_TAC (ARITH_RULE` n' < n' + 1 `); MESON_TAC[]; ASM_CASES_TAC` i < CARD (V:real^3 -> bool) `; UNDISCH_TAC` HS = hypermap (HYP (vec 0,V,E UNION {{v:real^3, w}}))`; DISCH_THEN (ASSUME_TAC o SYM); UNDISCH_TAC` fw = face HS (w,rho_node1 FF w) `; DISCH_THEN (ASSUME_TAC o SYM); ASM_REWRITE_TAC[]; STRIP_TAC; MP_TAC (SPECL [`w:real^3 `;` v:real^3 `;` fw: real^3 #real^3 -> bool`] ( GENL [`v:real^3 `;` w:real^3 `;` fv: real^3 #real^3 -> bool` ] POINTS_IN_HAFL_CIRCLE)); ANTS_TAC; DOWN_TAC; SIMP_TAC[INSERT_COMM]; DISCH_THEN (ASSUME_TAC o SYM); ASM_REWRITE_TAC[]; ASM_CASES_TAC` n <= (i:num) `; ASM_REWRITE_TAC[]; ASSUME_TAC2 (ARITH_RULE` n <= (i:num) ==> i = (i - n) + n `); ABBREV_TAC` nn = i - (n:num) `; SUBGOAL_THEN` nn + n < n + (n':num) ` MP_TAC; ASM_REWRITE_TAC[]; DOWN; FIRST_X_ASSUM (SUBST1_TAC o SYM); ASM_REWRITE_TAC[]; NHANH (ARITH_RULE` a + b < b + (c:num) ==> a < c + 1 `); UNDISCH_TAC` !i. i < CARD V /\ ITER (i + n) (rho_node1 FF) v IN v_prime V (fw:real^3 #real^3 -> bool) <=> i < n' + 1`; DISCH_THEN (fun x -> REWRITE_TAC[GSYM x]); ASM_REWRITE_TAC[]; SIMP_TAC[]; ASM_REWRITE_TAC[]; ASSUME_TAC2 (ARITH_RULE` ~(i = 0) ==> ~( i + n' < n' + 1 ) `); DOWN; UNDISCH_TAC` !i. i < CARD V /\ ITER (i + n) (rho_node1 FF) v IN v_prime V (fw:real^3 #real^3 -> bool) <=> i < n' + 1`; DISCH_THEN (fun x -> REWRITE_TAC[GSYM x]); SUBGOAL_THEN` i + n' < n + (n':num) ` MP_TAC; DOWN THEN ARITH_TAC; ASM_SIMP_TAC[]; ASM_SIMP_TAC[ARITH_RULE` (a + b) + (c:num) = a + c + b `]; REWRITE_TAC[GSYM ITER_ADD]; ASSUME_TAC2 LOFA_IMP_ITER_RHO_NODE_ID2; ASM_SIMP_TAC[]; ASM_REWRITE_TAC[]]);;
let DETERMINE_FV2 = 
prove_by_refinement (`(local_fan (V,E,FF) /\ v IN V /\ w IN V /\ ~(v = w) /\ (!z t. z IN {v, w} /\ t IN V DIFF {z} ==> ~collinear {vec 0, z, t}) /\ (!x. x IN FF ==> aff_gt {vec 0} {v, w} SUBSET wedge_in_fan_gt x E)) /\ HS = hypermap (HYP (vec 0,V,E UNION {{v, w}})) /\ fv = face HS (v,rho_node1 FF v) ==> n < CARD V /\ ITER n (rho_node1 FF) v = w ==> fv = (w,v) INSERT {ITER m (rho_node1 FF) v,ITER (m + 1) (rho_node1 FF) v | m | m < n} `,
[NHANH DETERMINE_FV; SIMP_TAC[]; REPEAT STRIP_TAC; MATCH_MP_TAC (SET_RULE` X = Y ==> a INSERT X = a INSERT Y `); REWRITE_TAC[EXTENSION; IN_ELIM_THM]; GEN_TAC; EQ_TAC; STRIP_TAC; EXISTS_TAC` n':num`; ASM_REWRITE_TAC[]; ASM_CASES_TAC` n' < (n:num) `; FIRST_ASSUM ACCEPT_TAC; ASSUME_TAC2 (ARITH_RULE` ~(n' < (n:num)) ==> n < n' + 1 `); DOWN; FIRST_X_ASSUM NHANH; ASM_REWRITE_TAC[]; STRIP_TAC; EXISTS_TAC` m:num`; ASM_REWRITE_TAC[]; GEN_TAC; STRIP_TAC; ASSUME_TAC2 Local_lemmas.LOFA_IMP_DIS_ELMS23; FIRST_X_ASSUM (MP_TAC o (SPECL [`m': num `;` n:num`])); PHA; ANTS_TAC; ASM_REWRITE_TAC[]; DOWN; UNDISCH_TAC` m < n:num`; ARITH_TAC; ASM_SIMP_TAC[]]);;
let INTERIOR_ANGLE_LEM_SLICING_FAN = 
prove_by_refinement (`convex_local_fan (V,E,FF) /\ (local_fan (V,E,FF) /\ v IN V /\ w IN V /\ ~(v = w) /\ (!z t. z IN {v, w} /\ t IN V DIFF {z} ==> ~collinear {vec 0, z, t}) /\ (!x. x IN FF ==> aff_gt {vec 0} {v, w} SUBSET wedge_in_fan_gt x E)) /\ HS = hypermap (HYP (vec 0,V,E UNION {{v, w}})) /\ fv = face HS (v,rho_node1 FF v) /\ fw = face HS (w,rho_node1 FF w) ==> interior_angle1 (vec 0) fv v + interior_angle1 (vec 0) fw v = interior_angle1 (vec 0) FF v `,
[REWRITE_TAC[convex_local_fan] THEN STRIP_TAC THEN ASSUME_TAC2 POINT_PRESENTED_IN_RHOND1 THEN DOWN THEN STRIP_TAC THEN MP_TAC DETERMINE_FV2 THEN PHA THEN ANTS_TAC THENL [ASM_REWRITE_TAC[]; DISCH_THEN (ASSUME_TAC o SYM)] THEN ASSUME_TAC2 (SPECL [` w:real^3 `;` v:real^3 `] (GENL [` v:real^3 `;` w:real^3 `] POINT_PRESENTED_IN_RHOND1)) THEN DOWN THEN STRIP_TAC THEN MP_TAC (SPECL [` w:real^3`;` v:real^3 `;`n': num`;` fw: real^3 #real^3 -> bool`] (GENL [` v:real^3`;` w:real^3 `;`n: num`;` fv: real^3 #real^3 -> bool`] DETERMINE_FV2)) THEN PHA THEN ANTS_TAC THENL [ASM_REWRITE_TAC[INSERT_COMM] THEN UNDISCH_TAC` !z t. z IN {v, w} /\ t IN V DIFF {z} ==> ~collinear {vec 0, z:real^3, t} ` THEN DISCH_THEN NHANH THEN SIMP_TAC[INSERT_COMM]; DISCH_THEN (ASSUME_TAC o SYM)] THEN REWRITE_TAC[interior_angle1; GSYM ivs_rho_node1] THEN MP_TAC2 HAFL_CIRCLE_FORM_LOCAL_FAN2 THEN STRIP_TAC; SUBGOAL_THEN ` v, rho_node1 FF v IN fv /\ (w,v) IN fv ` MP_TAC; EXPAND_TAC "fv" THEN REWRITE_TAC[IN_INSERT; IN_ELIM_THM] THEN DISJ2_TAC THEN EXISTS_TAC` 0` THEN REWRITE_TAC[ITER; GSYM ADD1] THEN ASM_CASES_TAC` 0 < n ` THENL [FIRST_X_ASSUM ACCEPT_TAC; DOWN] THEN REWRITE_TAC[ARITH_RULE` ~( 0 < n) <=> n = 0 `] THEN DISCH_THEN SUBST_ALL_TAC THEN UNDISCH_TAC` ITER 0 (rho_node1 FF) v = w ` THEN ASM_REWRITE_TAC[ITER]; STRIP_TAC; DOWN; UNDISCH_TAC` local_fan (v_prime V fv,e_prime (E UNION {{v, w}}) fv,fv) `; PHA; NHANH Local_lemmas.IVS_RHO_NODE1_DETE; STRIP_TAC; UNDISCH_TAC` v,rho_node1 FF v IN fv `; UNDISCH_TAC` local_fan (v_prime V fv,e_prime (E UNION {{v, w}}) fv,fv) `; PHA; NHANH Local_lemmas.DETER_RHO_NODE; STRIP_TAC; UNDISCH_TAC` fw = face HS (w,rho_node1 FF w) `; DISCH_THEN (ASSUME_TAC o SYM); UNDISCH_TAC` fv = face HS (v,rho_node1 FF v) `; DISCH_THEN (ASSUME_TAC o SYM); ASM_REWRITE_TAC[]; SUBGOAL_THEN` (v,w) IN fw /\ ivs_rho_node1 FF v, v IN fw ` MP_TAC; UNDISCH_TAC`(v,w) INSERT {ITER m (rho_node1 FF) w,ITER (m + 1) (rho_node1 FF) w | m < n'} = fw `; STRIP_TAC; ASM_REWRITE_TAC[]; EXPAND_TAC "fw";
REWRITE_TAC[IN_INSERT; IN_ELIM_THM]; DISJ2_TAC; EXISTS_TAC` n' - 1 `; ASM_CASES_TAC` n' = 0`; FIRST_X_ASSUM SUBST_ALL_TAC; UNDISCH_TAC` ITER 0 (rho_node1 FF) w = v `; ASM_REWRITE_TAC[ITER]; ASSUME_TAC2 (ARITH_RULE` ~(n' = 0) ==> n' - 1 < n' /\ n' - 1 + 1 = n' `); ASM_REWRITE_TAC[PAIR_EQ]; UNDISCH_TAC` ITER n (rho_node1 FF) v = w`; STRIP_TAC; EXPAND_TAC "w"; REWRITE_TAC[ITER_ADD]; ASSUME_TAC2 (ARITH_RULE` ~( n' = 0) ==> n' - 1 + n = (n + n') - 1`); ASM_REWRITE_TAC[]; ASSUME_TAC2 Local_lemmas.ITER_CARD_MINUS1_EQ_IVS_RN1; FIRST_X_ASSUM (ASSUME_TAC2 o (SPEC`v:real^3 `)); ASSUME_TAC2 CARD_V_TWO_HAFL_CIRCLE; ASM_REWRITE_TAC[]; STRIP_TAC; DOWN; UNDISCH_TAC` local_fan (v_prime V fw,e_prime (E UNION {{w, v}}) fw,fw) `; PHA; NHANH Local_lemmas.IVS_RHO_NODE1_DETE; STRIP_TAC; UNDISCH_TAC` (v:real^3,w:real^3) IN fw`; UNDISCH_TAC` local_fan (v_prime V fw,e_prime (E UNION {{w, v}}) fw,fw) `; PHA; NHANH Local_lemmas.IVS_RHO_NODE1_DETE; NHANH Local_lemmas.DETER_RHO_NODE; STRIP_TAC; ASM_REWRITE_TAC[]; ASSUME_TAC2 WEDGE_IN_FAN_RHOND_IVS_RHOND; ASSUME_TAC2 Local_lemmas.LOCAL_FAN_RHO_NODE_PROS2; DOWN THEN STRIP_TAC; FIRST_X_ASSUM (ASSUME_TAC2 o (SPEC`v:real^3 `)); DOWN; UNDISCH_TAC` !x. x IN FF ==> azim_in_fan (x:real^3#real^3) E <= pi /\ V SUBSET wedge_in_fan_ge x E`; DISCH_THEN NHANH; ASM_REWRITE_TAC[SUBSET]; STRIP_TAC; FIRST_X_ASSUM (ASSUME_TAC2 o (SPEC` w:real^3 `)); DOWN; REWRITE_TAC[wedge_ge; IN_ELIM_THM]; STRIP_TAC; SUBGOAL_THEN` ~ collinear {vec 0, v, w} /\ ~ collinear {vec 0, v, ivs_rho_node1 FF v} /\ ~ collinear {vec 0, v, rho_node1 FF v} ` MP_TAC; CONJ_TAC; FIRST_X_ASSUM MATCH_MP_TAC; ASM_REWRITE_TAC[IN_INSERT; IN_DIFF; NOT_IN_EMPTY]; ASSUME_TAC2 (SPEC` v:real^3 ` Local_lemmas.LOFA_IMP_NOT_COLL_IVS); ASSUME_TAC2 Local_lemmas.LOCAL_FAN_CHARACTER_OF_RHO_NODE2; ASM_REWRITE_TAC[]; DOWN THEN PHA; NHANH Fan.sum4_azim_fan; SIMP_TAC[]]);;
let INTERIOR_ANGLE_LEM_SLICING_FAN2 = 
prove_by_refinement (`convex_local_fan (V,E,FF) /\ (local_fan (V,E,FF) /\ v IN V /\ w IN V /\ ~(v = w) /\ (!z t. z IN {v, w} /\ t IN V DIFF {z} ==> ~collinear {vec 0, z, t}) /\ (!x. x IN FF ==> aff_gt {vec 0} {v, w} SUBSET wedge_in_fan_gt x E)) /\ HS = hypermap (HYP (vec 0,V,E UNION {{v, w}})) /\ fv = face HS (v,rho_node1 FF v) /\ fw = face HS (w,rho_node1 FF w) ==> interior_angle1 (vec 0) fv v + interior_angle1 (vec 0) fw v = interior_angle1 (vec 0) FF v /\ interior_angle1 (vec 0) fw w + interior_angle1 (vec 0) fv w = interior_angle1 (vec 0) FF w`,
[NHANH INTERIOR_ANGLE_LEM_SLICING_FAN; STRIP_TAC; CONJ_TAC; FIRST_X_ASSUM ACCEPT_TAC; MATCH_MP_TAC (GENL [`w:real^3`] INTERIOR_ANGLE_LEM_SLICING_FAN); EXISTS_TAC` v:real^3 `; ASM_REWRITE_TAC[INSERT_COMM]; FIRST_X_ASSUM NHANH; FIRST_X_ASSUM NHANH; SIMP_TAC[INSERT_COMM]]);;
let INTERIOR_AGL_EQ = 
prove_by_refinement (`(local_fan (V,E,FF) /\ v IN V /\ w IN V /\ ~(v = w) /\ (!z t. z IN {v, w} /\ t IN V DIFF {z} ==> ~collinear {vec 0, z, t}) /\ (!x. x IN FF ==> aff_gt {vec 0} {v, w} SUBSET wedge_in_fan_gt x E)) /\ HS = hypermap (HYP (vec 0,V,E UNION {{v, w}})) /\ fv = face HS (v,rho_node1 FF v) ==> n < CARD V /\ ITER n (rho_node1 FF) v = w ==> ! i. 0 < i /\ i < n ==> interior_angle1 (vec 0) fv (ITER i (rho_node1 FF) v) = interior_angle1 (vec 0) FF (ITER i (rho_node1 FF) v) `,
[REPEAT STRIP_TAC; MP_TAC DETERMINE_FV2; PHA; ANTS_TAC; ASM_REWRITE_TAC[]; DISCH_THEN (ASSUME_TAC o SYM); REWRITE_TAC[interior_angle1; GSYM ivs_rho_node1]; SUBGOAL_THEN` ITER i (rho_node1 FF) v, rho_node1 FF (ITER i (rho_node1 FF) v) IN fv ` MP_TAC; EXPAND_TAC "fv";
REWRITE_TAC[IN_INSERT; IN_ELIM_THM]; DISJ2_TAC; EXISTS_TAC` i:num`; ASM_REWRITE_TAC[ITER; GSYM ADD1]; MP_TAC HAFL_CIRCLE_FORM_LOCAL_FAN; ANTS_TAC; ASM_REWRITE_TAC[]; PHA; NHANH Local_lemmas.DETER_RHO_NODE; SIMP_TAC[]; STRIP_TAC; SUBGOAL_THEN` ivs_rho_node1 FF (ITER i (rho_node1 FF) v), ITER i (rho_node1 FF) v IN fv ` MP_TAC; EXPAND_TAC "fv"; REWRITE_TAC[IN_INSERT; IN_ELIM_THM]; DISJ2_TAC; EXISTS_TAC` i - 1 `; ABBREV_TAC ` i' = i - 1 `; ASSUME_TAC2 (ARITH_RULE` 0 < i ==> i = i - 1 + 1 `); DOWN; ASM_REWRITE_TAC[]; SIMP_TAC[GSYM ADD1; ITER; PAIR_EQ]; STRIP_TAC; CONJ_TAC; UNDISCH_TAC` i < (n:num) `; DOWN; ARITH_TAC; ASSUME_TAC2 Local_lemmas.LOCAL_FAN_ITER_RHO_NODE_IN_V; FIRST_X_ASSUM (MP_TAC o (SPEC` i': num`)); UNDISCH_TAC` local_fan (V,E,FF)`; PHA; NHANH Local_lemmas.IVS_RHO_IDD; SIMP_TAC[]; UNDISCH_TAC` local_fan (v_prime V fv,e_prime (E UNION {{v, w}}) fv,fv) `; PHA; NHANH Local_lemmas.IVS_RHO_NODE1_DETE; SIMP_TAC[]]);;
let SUM_INTERIOR_AGL_LEMMA = 
prove_by_refinement (`convex_local_fan (V,E,FF) /\ (local_fan (V,E,FF) /\ v IN V /\ w IN V /\ ~(v = w) /\ (!z t. z IN {v, w} /\ t IN V DIFF {z} ==> ~collinear {vec 0, z, t}) /\ (!x. x IN FF ==> aff_gt {vec 0} {v, w} SUBSET wedge_in_fan_gt x E)) /\ HS = hypermap (HYP (vec 0,V,E UNION {{v, w}})) /\ fv = face HS (v,rho_node1 FF v) /\ fw = face HS (w, rho_node1 FF w) ==> ! ff. sum {i | i < CARD V } (\i. (ff i) * (interior_angle1 (vec 0) FF (ITER i (rho_node1 FF) v))) = sum { i | i < CARD V /\ ITER i (rho_node1 FF) v IN v_prime V fv} (\i. ff i * interior_angle1 (vec 0) fv (ITER i (rho_node1 FF) v)) + sum { i | i < CARD V /\ ITER i (rho_node1 FF) v IN v_prime V fw} (\i. ff i * interior_angle1 (vec 0) fw (ITER i (rho_node1 FF) v)) `,
[STRIP_TAC; GEN_TAC; ASSUME_TAC2 POINT_PRESENTED_IN_RHOND1; DOWN THEN STRIP_TAC; MP_TAC POINTS_IN_HAFL_CIRCLE; ANTS_TAC; ASM_REWRITE_TAC[]; ASSUME_TAC2 (SPECL [`w:real^3 `;` v:real^3` ] (GENL [` v:real^3 `;` w:real^3 `] POINT_PRESENTED_IN_RHOND1)); DOWN THEN STRIP_TAC; STRIP_TAC; MP_TAC (SPECL [` w:real^3 `;` v:real^3`;` fw:real^3#real^3 -> bool` ] (GENL [` v:real^3 `;` w:real^3 `; `fv:real^3#real^3 -> bool`] POINTS_IN_HAFL_CIRCLE)); ANTS_TAC; ASM_REWRITE_TAC[INSERT_COMM]; UNDISCH_TAC` !z t. z IN {v, w} /\ t IN V DIFF {z} ==> ~collinear {vec 0, z, t:real^3}`; DISCH_THEN NHANH; SIMP_TAC[INSERT_COMM]; STRIP_TAC; MP_TAC CONDS_IN_V_PRIME_NUM; ANTS_TAC; ASM_REWRITE_TAC[]; ANTS_TAC; ASM_REWRITE_TAC[]; SIMP_TAC[]; STRIP_TAC; MP_TAC CONDS_IN_V_PRIME_NUM2; PHA; ANTS_TAC; ASM_REWRITE_TAC[]; SIMP_TAC[]; STRIP_TAC; SUBGOAL_THEN` {i | i < n + 1} = {i | 0 < i /\ i < n} UNION {0, n} ` MP_TAC; REWRITE_TAC[EXTENSION]; REWRITE_TAC[IN_UNION; IN_INSERT; NOT_IN_EMPTY; IN_ELIM_THM]; GEN_TAC; ARITH_TAC; SIMP_TAC[]; STRIP_TAC; SUBGOAL_THEN` {i | i = 0 \/ n <= i /\ i < CARD V} = {i | n < i /\ i < CARD (V:real^3 -> bool) } UNION {0, n} ` MP_TAC; REWRITE_TAC[EXTENSION; IN_UNION; IN_INSERT; NOT_IN_EMPTY; IN_ELIM_THM]; GEN_TAC; SIMP_TAC[ARITH_RULE` (n:num) <= x <=> n < x \/ x = n `]; UNDISCH_TAC` n < CARD (V:real^3 -> bool) `; MESON_TAC[]; SIMP_TAC[]; STRIP_TAC; MP_TAC (SPEC` n + 1 ` FINITE_NUMSEG_LT); ASM_REWRITE_TAC[]; UNDISCH_TAC` fv = face HS (v,rho_node1 FF v) `; UNDISCH_TAC` fw = face HS (w,rho_node1 FF w) `; DISCH_THEN (ASSUME_TAC o SYM); DISCH_THEN (ASSUME_TAC o SYM); ASM_REWRITE_TAC[FINITE_UNION]; SUBGOAL_THEN` {i | n < i /\ i < CARD (V:real^3 -> bool)} = {i | n < i } INTER {i | i < CARD V} ` MP_TAC; SET_TAC[]; STRIP_TAC; SUBGOAL_THEN` FINITE {i | n < i /\ i < CARD (V:real^3 -> bool)}` MP_TAC; ASM_REWRITE_TAC[]; MATCH_MP_TAC FINITE_INTER; DISJ2_TAC; REWRITE_TAC[FINITE_NUMSEG_LT]; DISCH_TAC; STRIP_TAC; SUBGOAL_THEN` DISJOINT {m | 0 < m /\ m < n } {0, n} ` ASSUME_TAC; REWRITE_TAC[DISJOINT; EXTENSION; IN_INTER; NOT_IN_EMPTY; IN_INSERT; IN_ELIM_THM]; GEN_TAC; ARITH_TAC; SUBGOAL_THEN` DISJOINT {i | n < i /\ i < CARD (V:real^3 -> bool)} {0, n}` ASSUME_TAC; REWRITE_TAC[DISJOINT; EXTENSION; IN_INTER; NOT_IN_EMPTY; IN_INSERT; IN_ELIM_THM]; GEN_TAC; ARITH_TAC; MP_TAC (ISPECL [` (\i. ff i * interior_angle1 (vec 0) fv (ITER i (rho_node1 FF) v)) `; `{i | 0 < i /\ i < n} `; ` {0, n} `] SUM_UNION); ANTS_TAC; ASM_REWRITE_TAC[]; SIMP_TAC[]; MP_TAC (ISPECL [` (\i. ff i * interior_angle1 (vec 0) fw (ITER i (rho_node1 FF) v)) `; `{i | n < i /\ i < CARD (V:real^3 -> bool)}`; ` {0, n} `] SUM_UNION); ANTS_TAC; ASM_REWRITE_TAC[]; SIMP_TAC[]; STRIP_TAC THEN STRIP_TAC; SUBGOAL_THEN` sum {i | n < i /\ i < CARD (V:real^3 -> bool)} (\i. ff i * interior_angle1 (vec 0) fw (ITER i (rho_node1 FF) v)) = sum {i | n < i /\ i < CARD V} (\i. ff i * interior_angle1 (vec 0) FF (ITER i (rho_node1 FF) v)) ` MP_TAC; MATCH_MP_TAC SUM_EQ; GEN_TAC; REWRITE_TAC[IN_ELIM_THM]; STRIP_TAC; REWRITE_TAC[REAL_EQ_MUL_LCANCEL]; DISJ2_TAC; REWRITE_TAC[Local_lemmas.interior_angle1; GSYM ivs_rho_node1]; MP_TAC HAFL_CIRCLE_FORM_LOCAL_FAN2; ANTS_TAC; ASM_REWRITE_TAC[]; STRIP_TAC; MP_TAC (SPECL [` w:real^3 `;` v:real^3 `;` n':num`; `fw:real^3#real^3 -> bool`] (GENL [` v:real^3`;` w:real^3 `;` n:num`;` fv:real^3#real^3 -> bool`] DETERMINE_FV2)); PHA; ANTS_TAC; ASM_REWRITE_TAC[]; DOWN_TAC; SIMP_TAC[INSERT_COMM]; DISCH_THEN (ASSUME_TAC o SYM); SUBGOAL_THEN` ITER x (rho_node1 FF) v, rho_node1 FF (ITER x (rho_node1 FF) v) IN fw ` MP_TAC; EXPAND_TAC "fw";
REWRITE_TAC[IN_INSERT; IN_ELIM_THM]; DISJ2_TAC; EXISTS_TAC`(x:num) - n `; EXPAND_TAC "w"; REWRITE_TAC[ITER_ADD]; ASSUME_TAC2 (ARITH_RULE` n < (x:num) ==> x - n + n = x `); ASM_REWRITE_TAC[ARITH_RULE`(x - n + 1) + n = (x - n + n ) + 1 `; GSYM ITER; ADD1]; ASSUME_TAC2 CARD_V_TWO_HAFL_CIRCLE; DOWN; UNDISCH_TAC` x < CARD (V:real^3 -> bool) `; UNDISCH_TAC` n < x:num `; ARITH_TAC; UNDISCH_TAC` local_fan (v_prime V fw,e_prime (E UNION {{w, v}}) fw,fw) `; PHA; NHANH Local_lemmas.DETER_RHO_NODE; SIMP_TAC[]; STRIP_TAC; SUBGOAL_THEN` ivs_rho_node1 FF (ITER x (rho_node1 FF) v), ITER x (rho_node1 FF) v IN fw ` MP_TAC; ASSUME_TAC2 Local_lemmas.LOCAL_FAN_ITER_RHO_NODE_IN_V; FIRST_X_ASSUM (MP_TAC o (SPEC` x:num`)); ASSUME_TAC2 Local_lemmas.ITER_CARD_MINUS1_EQ_IVS_RN1; FIRST_X_ASSUM NHANH; STRIP_TAC; FIRST_ASSUM (SUBST1_TAC o SYM); REWRITE_TAC[ITER_ADD]; ASSUME_TAC2 (ARITH_RULE` n < x /\ x < CARD (V:real^3 -> bool) ==> CARD V - 1 + x = x - 1 + CARD V `); ASM_REWRITE_TAC[]; REWRITE_TAC[GSYM ITER_ADD]; ASSUME_TAC2 LOFA_IMP_ITER_RHO_NODE_ID2; ASM_REWRITE_TAC[]; EXPAND_TAC "fw"; REWRITE_TAC[IN_INSERT; IN_ELIM_THM]; DISJ2_TAC; EXISTS_TAC` x - ( n + 1) `; EXPAND_TAC "w"; REWRITE_TAC[ITER_ADD]; ASSUME_TAC2 (ARITH_RULE` n < x ==> x - (n + 1) + n = x - 1 /\ (x - (n + 1) + 1) + n = x`); ASM_REWRITE_TAC[]; ASSUME_TAC2 CARD_V_TWO_HAFL_CIRCLE; DOWN; UNDISCH_TAC` n < (x:num) `; UNDISCH_TAC` x < CARD (V:real^3 -> bool) `; ARITH_TAC; UNDISCH_TAC` local_fan (v_prime V fw,e_prime (E UNION {{w, v}}) fw,fw) `; PHA; NHANH Local_lemmas.IVS_RHO_NODE1_DETE; SIMP_TAC[]; ASM_REWRITE_TAC[]; UNDISCH_TAC` HS = hypermap (HYP (vec 0,V,E UNION {{v, w:real^3}}))`; DISCH_THEN (ASSUME_TAC o SYM); UNDISCH_TAC` {i | n < i /\ i < CARD V} = {i | n < i} INTER {i | i < CARD (V:real^3 -> bool)} `; DISCH_THEN (ASSUME_TAC o SYM); ASM_SIMP_TAC[]; SUBGOAL_THEN` sum {i | 0 < i /\ i < n} (\i. ff i * interior_angle1 (vec 0) fv (ITER i (rho_node1 FF) v)) = sum {i | 0 < i /\ i < n} (\i. ff i * interior_angle1 (vec 0) FF (ITER i (rho_node1 FF) v))` MP_TAC; MATCH_MP_TAC SUM_EQ; GEN_TAC; REWRITE_TAC[IN_ELIM_THM]; STRIP_TAC; REWRITE_TAC[REAL_EQ_MUL_LCANCEL]; DISJ2_TAC; REWRITE_TAC[interior_angle1; GSYM ivs_rho_node1]; MP_TAC HAFL_CIRCLE_FORM_LOCAL_FAN2; ANTS_TAC; ASM_REWRITE_TAC[]; STRIP_TAC; MP_TAC DETERMINE_FV2; PHA; ANTS_TAC; ASM_REWRITE_TAC[]; DISCH_THEN (ASSUME_TAC o SYM); SUBGOAL_THEN` ITER x (rho_node1 FF) v, rho_node1 FF (ITER x (rho_node1 FF) v) IN fv ` MP_TAC; EXPAND_TAC "fv"; REWRITE_TAC[IN_INSERT; IN_ELIM_THM]; DISJ2_TAC; EXISTS_TAC`x:num `; REWRITE_TAC[GSYM ITER; ADD1]; ASM_REWRITE_TAC[]; UNDISCH_TAC` local_fan (v_prime V fv,e_prime (E UNION {{v, w}}) fv,fv) `; PHA; NHANH Local_lemmas.DETER_RHO_NODE; SIMP_TAC[]; STRIP_TAC; SUBGOAL_THEN` ivs_rho_node1 FF (ITER x (rho_node1 FF) v), ITER x (rho_node1 FF) v IN fv ` MP_TAC; EXPAND_TAC "fv"; REWRITE_TAC[IN_INSERT; IN_ELIM_THM]; DISJ2_TAC; EXISTS_TAC` x - 1 `; ASSUME_TAC2 (ARITH_RULE` 0 < x ==> x - 1 + 1 = x `); EXPAND_TAC "x"; REWRITE_TAC[ITER; GSYM ADD1]; ASSUME_TAC2 Local_lemmas.LOCAL_FAN_ITER_RHO_NODE_IN_V; FIRST_X_ASSUM (ASSUME_TAC o (SPEC ` x - 1 `)); ASSUME_TAC2 (SPEC` ITER (x - 1) (rho_node1 FF) v ` (GEN`v: real^3 ` Local_lemmas.IVS_RHO_IDD)); FIRST_X_ASSUM SUBST1_TAC; ASM_REWRITE_TAC[ADD1]; UNDISCH_TAC` x < (n:num) `; UNDISCH_TAC` 0 < x `; ARITH_TAC; UNDISCH_TAC` local_fan (v_prime V fv,e_prime (E UNION {{v, w}}) fv,fv) `; PHA; NHANH Local_lemmas.IVS_RHO_NODE1_DETE; SIMP_TAC[]; SIMP_TAC[]; REPEAT STRIP_TAC THEN ASM_CASES_TAC` 0 = n ` THEN UNDISCH_TAC` ITER n (rho_node1 FF) v = w ` THEN FIRST_X_ASSUM (SUBST_ALL_TAC o SYM) THEN ASM_REWRITE_TAC[ITER]; DOWN THEN NHANH (REWRITE_RULE[RIGHT_FORALL_IMP_THM] Collect_geom.SUM_DIS2) THEN STRIP_TAC THEN ASM_REWRITE_TAC[]; SIMP_TAC[ITER]; STRIP_TAC; SUBGOAL_THEN` interior_angle1 (vec 0) fv v + interior_angle1 (vec 0) fw v = interior_angle1 (vec 0) FF v /\ interior_angle1 (vec 0) fv w + interior_angle1 (vec 0) fw w = interior_angle1 (vec 0) FF w ` MP_TAC; REWRITE_TAC[interior_angle1; GSYM ivs_rho_node1]; MP_TAC INTERIOR_ANGLE_LEM_SLICING_FAN2; ANTS_TAC; ASM_REWRITE_TAC[]; SIMP_TAC[REAL_ADD_SYM; interior_angle1; GSYM ivs_rho_node1]; REWRITE_TAC[REAL_ARITH` (a + b) + c = a + b + c `]; REWRITE_TAC[REAL_ARITH` a + b + c + aa + bb + cc = a + aa + (b + bb) + (c + cc)`]; SIMP_TAC[GSYM REAL_ADD_LDISTRIB]; STRIP_TAC; SUBGOAL_THEN` ff 0 * interior_angle1 (vec 0) FF v + ff n * interior_angle1 (vec 0) FF w = sum {0, n} (\i. ff i * interior_angle1 (vec 0) FF (ITER i (rho_node1 FF) v))` MP_TAC; ASM_REWRITE_TAC[ITER]; SIMP_TAC[]; STRIP_TAC; UNDISCH_TAC` DISJOINT {i | n < i /\ i < CARD (V:real^3 -> bool)} {0, n} `; UNDISCH_TAC` FINITE {0, n} `; UNDISCH_TAC` FINITE {i | n < i /\ i < CARD (V:real^3 -> bool)}`; PHA; NHANH (MESON[SUM_UNION]` FINITE s /\ FINITE t /\ DISJOINT s t ==> ! f. sum (s UNION t) f = sum s f + sum t f `); STRIP_TAC; SUBGOAL_THEN` !i. n < i /\ i < CARD (V:real^3 -> bool) ==> interior_angle1 (vec 0) fw (ITER i (rho_node1 FF) v) = interior_angle1 (vec 0) FF (ITER i (rho_node1 FF) v) ` MP_TAC; MP_TAC (SPECL [` w:real^3 `;` v:real^3 `;`n':num `;` fw:real^3#real^3 -> bool`] (GENL [` v:real^3 `;` w:real^3 `;` n: num `; `fv:real^3 # real^3 -> bool`] INTERIOR_AGL_EQ)); PHA; ANTS_TAC; ASM_REWRITE_TAC[INSERT_COMM]; UNDISCH_TAC` !z t. z IN {v, w} /\ t IN V DIFF {z} ==> ~collinear {vec 0, z, t:real^3} `; DISCH_THEN NHANH; SIMP_TAC[INSERT_COMM]; ASSUME_TAC2 CARD_V_TWO_HAFL_CIRCLE; STRIP_TAC; ONCE_REWRITE_TAC[ARITH_RULE` n < i /\ i < m <=> 0 < i - n /\ i - n < m - n `]; ASSUME_TAC2 (ARITH_RULE` n + n' = CARD (V:real^3 -> bool) ==> CARD V - n = n'`); FIRST_X_ASSUM SUBST1_TAC; FIRST_X_ASSUM NHANH; EXPAND_TAC "w"; REWRITE_TAC[ITER_ADD]; NHANH (ARITH_RULE` 0 < i - n ==> i - n + n = i `); MESON_TAC[]; STRIP_TAC; SUBGOAL_THEN` sum {i | n < i /\ i < CARD (V:real^3 -> bool)} (\i. ff i * interior_angle1 (vec 0) fw (ITER i (rho_node1 FF) v)) = sum {i | n < i /\ i < CARD V} (\i. ff i * interior_angle1 (vec 0) FF (ITER i (rho_node1 FF) v))` MP_TAC; MATCH_MP_TAC SUM_EQ; REWRITE_TAC[IN_ELIM_THM]; FIRST_X_ASSUM NHANH; SIMP_TAC[]; DISCH_THEN SUBST1_TAC; DOWN THEN DOWN; DISCH_THEN (ASSUME_TAC o GSYM); UNDISCH_TAC` !f. sum {0, n} f = f 0 + f n `; DISCH_THEN (ASSUME_TAC o GSYM); ASM_REWRITE_TAC[]; STRIP_TAC; UNDISCH_TAC` FINITE {0, n} `; UNDISCH_TAC` FINITE {i | n < i /\ i < CARD (V:real^3 -> bool)} `; PHA; REWRITE_TAC[GSYM FINITE_UNION]; STRIP_TAC; SUBGOAL_THEN` DISJOINT {x | 0 < x /\ x < n} ({i | n < i /\ i < CARD (V:real^3 -> bool)} UNION {0, n}) ` MP_TAC; REWRITE_TAC[DISJOINT; EXTENSION; NOT_IN_EMPTY; IN_INTER; IN_ELIM_THM; IN_UNION; IN_INSERT]; GEN_TAC; ARITH_TAC; DOWN; UNDISCH_TAC` FINITE {m | 0 < m /\ m < n} `; PHA; NHANH (MESON[SUM_UNION]` FINITE s /\ FINITE t /\ DISJOINT s t ==> ! f. sum (s UNION t) f = sum s f + sum t f`); STRIP_TAC; FIRST_X_ASSUM (ASSUME_TAC o GSYM); ASM_SIMP_TAC[]; MATCH_MP_TAC (MESON[]` s = ss ==> sum s f = sum ss f `); REWRITE_TAC[EXTENSION; IN_ELIM_THM; IN_UNION; IN_INSERT; NOT_IN_EMPTY]; GEN_TAC; UNDISCH_TAC` n < CARD (V:real^3 -> bool) `; ARITH_TAC]);;
let THE_SLICING_INTO_2_LEMMA = 
prove(` convex_local_fan (V,E,FF) /\ (local_fan (V,E,FF) /\ v IN V /\ w IN V /\ ~(v = w) /\ (!z t. z IN {v, w} /\ t IN V DIFF {z} ==> ~collinear {vec 0, z, t}) /\ (!x. x IN FF ==> aff_gt {vec 0} {v, w} SUBSET wedge_in_fan_gt x E)) /\ HS = hypermap (HYP (vec 0,V,E UNION {{v, w}})) /\ fv = face HS (v,rho_node1 FF v) /\ fw = face HS (w,rho_node1 FF w) ==> convex_local_fan (v_prime V fv,e_prime (E UNION {{v, w}}) fv,fv) /\ convex_local_fan (v_prime V fw,e_prime (E UNION {{w, v}}) fw,fw) /\ (!ff. sum {i | i < CARD V} (\i. ff i * interior_angle1 (vec 0) FF (ITER i (rho_node1 FF) v)) = sum {i | i < CARD V /\ ITER i (rho_node1 FF) v IN v_prime V fv} (\i. ff i * interior_angle1 (vec 0) fv (ITER i (rho_node1 FF) v)) + sum {i | i < CARD V /\ ITER i (rho_node1 FF) v IN v_prime V fw} (\i. ff i * interior_angle1 (vec 0) fw (ITER i (rho_node1 FF) v)))`,
NHANH COVEX_OF_LOFA_HALF_CIRCLE2 THEN NHANH SUM_INTERIOR_AGL_LEMMA THEN SIMP_TAC[]);;
let WEDGE_IN_FAN_LOFA_DETER2 = 
prove(`local_fan (V,E,FF) /\ v IN V ==> wedge_in_fan_gt (v,rho_node1 FF v) E = wedge (vec 0) v (rho_node1 FF v) (ivs_rho_node1 FF v)`,
NHANH LOCAL_FAN_IVS_IN_V THEN NHANH LOCAL_FAN_RHO_NODE_IVS THEN ABBREV_TAC` vv = ivs_rho_node1 FF v` THEN MESON_TAC[WEDGE_IN_FAN_LOFA_DETER]);;
let AZIM_COND_FOR_COPLANAR = 
prove_by_refinement (`azim v0 v1 w1 w2 = &0 \/ azim v0 v1 w1 w2 = pi <=> coplanar {v0, v1, w1, w2} `,
[EQ_TAC; REWRITE_TAC[AZIM_EQ_0_PI_IMP_COPLANAR]; ASM_CASES_TAC` collinear {v0, v1, w1:real^3} `; STRIP_TAC; DISJ1_TAC; UNDISCH_TAC` collinear {v0, v1, w1:real^3}`; REWRITE_TAC[AZIM_DEGENERATE]; STRIP_TAC; ASM_CASES_TAC` collinear {v0, v1, w2:real^3}`; DISJ1_TAC; DOWN; REWRITE_TAC[AZIM_DEGENERATE]; DOWN_TAC; MESON_TAC[AZIM_EQ_0_PI_EQ_COPLANAR]]);;
let AFF_SUB_PLANE = 
prove(`plane P /\ S SUBSET P ==> aff S SUBSET P `,
REWRITE_TAC[plane; aff] THEN MESON_TAC[AFFINE_AFFINE_HULL; HULL_MINIMAL]);;
let PROVE_THE_SLICE_ASSUMPTION = 
prove_by_refinement (`! v w. convex_local_fan (V,E,FF) /\ v IN V /\ w IN V /\ ~(v = w) /\ (!x. x IN FF ==> aff_gt {vec 0} {v, w} SUBSET wedge_in_fan_gt x E) ==> (!z t. z IN {v, w} /\ t IN V DIFF {z} ==> ~collinear {vec 0, z, t})`,
[REWRITE_TAC[IN_INSERT; NOT_IN_EMPTY]; MATCH_MP_TAC (MESON[]`(!v w. P v w ==> P w v) /\ (!v w. P v w ==> (!z t. z = v /\ Q z t ==> R z t)) ==> (!v w. P v w ==> (!z t. (z = v \/ z = w) /\ Q z t ==> R z t))`); SIMP_TAC[INSERT_COMM; IN_DIFF; IN_SING]; REPEAT STRIP_TAC; MP_TAC (SPEC` t:real^3 ` (GEN`w:real^3 ` CVLF_COLLINEAR_CIRCULAR_LUNAR)); ANTS_TAC; ASM_REWRITE_TAC[INSERT_SUBSET; EMPTY_SUBSET; INSERT_COMM]; UNDISCH_TAC` ~(t = z:real^3)`; ASM_SIMP_TAC[]; STRIP_TAC; ASSUME_TAC2 Local_lemmas.KCHMAMG; DOWN THEN STRIP_TAC; SUBGOAL_THEN` interior_angle1 (vec 0) FF v = pi` MP_TAC; FIRST_X_ASSUM MATCH_MP_TAC; FIRST_ASSUM ACCEPT_TAC; SUBGOAL_THEN` convex_local_fan (V,E,FF) ` MP_TAC; ASM_REWRITE_TAC[]; REWRITE_TAC[convex_local_fan]; STRIP_TAC; ASSUME_TAC2 WEDGE_IN_FAN_LOFA_DETER2; SUBGOAL_THEN` aff {vec 0, v, w:real^3} SUBSET A` MP_TAC; MATCH_MP_TAC AFF_SUB_PLANE; ASM_REWRITE_TAC[INSERT_SUBSET; EMPTY_SUBSET]; UNDISCH_TAC` (V:real^3 -> bool) SUBSET A `; REWRITE_TAC[SUBSET]; STRIP_TAC; CONJ_TAC; FIRST_X_ASSUM MATCH_MP_TAC; FIRST_ASSUM ACCEPT_TAC; FIRST_X_ASSUM MATCH_MP_TAC; FIRST_ASSUM ACCEPT_TAC; MP_TAC (ISPECL[`{vec 0: real^3}`;` {v,w:real^3}`] (GEN_ALL Local_lemmas.AFF_GT_SUB_AFF_UNION)); REWRITE_TAC[SET_RULE` {a} UNION S = a INSERT S `]; PHA; NHANH (SUBSET_TRANS); STRIP_TAC; DOWN; REWRITE_TAC[SUBSET]; SUBGOAL_THEN` DISJOINT {vec 0} {v,w:real^3} ` MP_TAC; ASM_REWRITE_TAC[SET_RULE` DISJOINT {a} S <=> ~( a IN S) `; IN_INSERT; NOT_IN_EMPTY; DE_MORGAN_THM]; ASSUME_TAC2 Local_lemmas.LOFA_IMP_V_DIFF; UNDISCH_TAC` v:real^3 IN V `; UNDISCH_TAC` w:real^3 IN V `; FIRST_X_ASSUM NHANH; SIMP_TAC[]; NHANH Planarity.exists_in_aff_gt_disjoint; STRIP_TAC; DISCH_THEN (ASSUME_TAC2 o (SPEC` y:real^3 `)); SUBGOAL_THEN` coplanar {vec 0, v, rho_node1 FF v, y} ` MP_TAC; UNDISCH_TAC` plane (A:real^3 -> bool) `; REWRITE_TAC[coplanar; plane]; STRIP_TAC; EXISTS_TAC` u:real^3 `; EXISTS_TAC` v':real^3 `; EXISTS_TAC` w':real^3 `; FIRST_X_ASSUM (SUBST1_TAC o SYM); ASM_REWRITE_TAC[INSERT_SUBSET; EMPTY_SUBSET]; ASSUME_TAC2 Local_lemmas.LOFA_IN_V_SO_DO_RHO_NODE_V; DOWN; UNDISCH_TAC` v:real^3 IN V `; UNDISCH_TAC` (V:real^3 -> bool) SUBSET A `; REWRITE_TAC[SUBSET]; DISCH_THEN NHANH; SIMP_TAC[]; REWRITE_TAC[ GSYM AZIM_COND_FOR_COPLANAR]; ASSUME_TAC2 Local_lemmas.LOCAL_FAN_RHO_NODE_PROS2; DOWN THEN STRIP_TAC; FIRST_X_ASSUM (ASSUME_TAC2 o (SPEC` v:real^3 `)); DOWN; UNDISCH_TAC` !x. x IN FF ==> aff_gt {vec 0} {v, w} SUBSET wedge_in_fan_gt x E `; DISCH_THEN NHANH; ASM_REWRITE_TAC[SUBSET]; STRIP_TAC; FIRST_X_ASSUM (ASSUME_TAC2 o (SPEC`y: real^3 `)); DOWN; REWRITE_TAC[wedge; IN_ELIM_THM; interior_angle1; GSYM ivs_rho_node1]; REAL_ARITH_TAC; MP_TAC (SPEC`t:real^3 ` (GEN` w:real^3 ` Local_lemmas.HKIRPEP)); ANTS_TAC; ASM_REWRITE_TAC[]; STRIP_TAC; ASSUME_TAC2 Local_lemmas.CVX_LO_IMP_LO; ASSUME_TAC2 WEDGE_IN_FAN_LOFA_DETER2; SUBGOAL_THEN` i + j = CARD (V:real^3 -> bool) ` MP_TAC; MATCH_MP_TAC (GEN`w:real^3 ` CARD_V_TWO_HAFL_CIRCLE); EXISTS_TAC` t: real^3 `; SWITCH_TAC` t = ITER i (rho_node1 FF) v `; SWITCH_TAC` v = ITER j (rho_node1 FF) t `; ASM_REWRITE_TAC[]; UNDISCH_TAC` ~(t = (z:real^3))`; ASM_REWRITE_TAC[EQ_SYM_EQ]; ASSUME_TAC2 POINT_PRESENTED_IN_RHOND1; DOWN THEN STRIP_TAC; ASM_CASES_TAC` n = 0 `; FIRST_X_ASSUM SUBST_ALL_TAC; DOWN THEN DOWN; SWITCH_TAC` t = ITER i (rho_node1 FF) v `; SWITCH_TAC` v = ITER j (rho_node1 FF) t `; ASM_REWRITE_TAC[ITER]; ASM_CASES_TAC` n < (i:num) `; SUBGOAL_THEN` w IN {ITER l (rho_node1 FF) v | 0 < l /\ l < i} ` MP_TAC; REWRITE_TAC[IN_ELIM_THM]; EXISTS_TAC`n:num `; ASM_REWRITE_TAC[]; DOWN THEN DOWN; ARITH_TAC; SWITCH_TAC` t = ITER i (rho_node1 FF) v `; SWITCH_TAC` v = ITER j (rho_node1 FF) t `; ASM_REWRITE_TAC[IN_INTER]; STRIP_TAC; SUBGOAL_THEN` aff_gt {vec 0, v} {rho_node1 FF v} = aff_gt {vec 0, v} {w}` MP_TAC; MATCH_MP_TAC Local_lemmas.COLL_IN_AFF_GT_AFF_GT_EQ; ASM_REWRITE_TAC[]; MATCH_MP_TAC Local_lemmas.LOCAL_FAN_CHARACTER_OF_RHO_NODE2; ASM_REWRITE_TAC[]; MP_TAC (REWRITE_RULE[SING_SUBSET; IN_INSERT] ( ISPECL [`{v:real^3}`;` {vec 0, v:real^3}`; `{w:real^3}`] (GEN_ALL Local_lemmas.AFF_GT_MONO_TRANS))); REWRITE_TAC[Packing3.SING_UNION_EQ_INSERT]; ASSUME_TAC2 Local_lemmas.LOFA_IMP_V_DIFF; SUBGOAL_THEN` {vec 0, v} DIFF {v:real^3} = {vec 0}` MP_TAC; REWRITE_TAC[DIFF; EXTENSION; IN_ELIM_THM; IN_INSERT; NOT_IN_EMPTY]; GEN_TAC; FIRST_X_ASSUM (ASSUME_TAC2 o (SPEC` v:real^3`)); DOWN; MESON_TAC[]; SIMP_TAC[]; PHA THEN STRIP_TAC; SUBGOAL_THEN` DISJOINT {vec 0} {w, v:real^3}` MP_TAC; REWRITE_TAC[SET_RULE` DISJOINT {a} S <=> ~( a IN S)`; IN_INSERT; NOT_IN_EMPTY; DE_MORGAN_THM]; FIRST_ASSUM (ASSUME_TAC2 o (SPEC` v:real^3 `)); FIRST_ASSUM (ASSUME_TAC2 o (SPEC` w:real^3 `)); DOWN THEN DOWN; SIMP_TAC[]; NHANH Planarity.exists_in_aff_gt_disjoint; STRIP_TAC; SUBGOAL_THEN` y IN aff_gt {vec 0, v} {rho_node1 FF v}` MP_TAC; ASM_REWRITE_TAC[]; UNDISCH_TAC` aff_gt {vec 0} {w, v} SUBSET aff_gt {vec 0, v} {w:real^3} `; REWRITE_TAC[SUBSET]; DISCH_THEN MATCH_MP_TAC; FIRST_X_ASSUM ACCEPT_TAC; ASSUME_TAC2 Local_lemmas.LOCAL_FAN_CHARACTER_OF_RHO_NODE2; STRIP_TAC; SUBGOAL_THEN` ~collinear {vec 0, v, y:real^3}` MP_TAC; MATCH_MP_TAC (GEN_ALL Local_lemmas.COLL_IN_AFF_GT_TOO); EXISTS_TAC` rho_node1 FF v `; ASM_REWRITE_TAC[]; UNDISCH_TAC` ~collinear {vec 0, v, rho_node1 FF v}`; PHA; NHANH AZIM_EQ_0_ALT; STRIP_TAC; FIRST_X_ASSUM (SUBST_ALL_TAC o SYM); ASSUME_TAC2 Local_lemmas.LOCAL_FAN_RHO_NODE_PROS2; DOWN THEN STRIP_TAC; FIRST_X_ASSUM (ASSUME_TAC2 o (SPEC` v:real^3 `)); DOWN; UNDISCH_TAC` !x. x IN FF ==> aff_gt {vec 0} {v, w} SUBSET wedge_in_fan_gt x E `; DISCH_THEN NHANH; REWRITE_TAC[SUBSET]; ONCE_REWRITE_TAC[INSERT_COMM]; STRIP_TAC; FIRST_X_ASSUM (ASSUME_TAC2 o (SPEC`y: real^3 `)); DOWN; ASM_REWRITE_TAC[wedge; IN_ELIM_THM]; REAL_ARITH_TAC; SWITCH_TAC` v = ITER j (rho_node1 FF) t `; SWITCH_TAC` t = ITER i (rho_node1 FF) v `; ASSUME_TAC2 Local_lemmas.LOCAL_FAN_RHO_NODE_PROS2; DOWN THEN STRIP_TAC; FIRST_X_ASSUM (ASSUME_TAC2 o (SPEC` v:real^3 `)); DOWN; UNDISCH_TAC` !x. x IN FF ==> aff_gt {vec 0} {v, w} SUBSET wedge_in_fan_gt x E `; STRIP_TAC; PHA; FIRST_ASSUM NHANH; ASM_REWRITE_TAC[]; STRIP_TAC; ASSUME_TAC2 Local_lemmas.LOFA_IMP_V_DIFF; SUBGOAL_THEN` DISJOINT {vec 0} {v, w:real^3} ` MP_TAC; REWRITE_TAC[DISJOINT; INTER; EXTENSION; IN_ELIM_THM; IN_INSERT; NOT_IN_EMPTY]; DOWN; UNDISCH_TAC` (v:real^3) IN V `; UNDISCH_TAC` (w:real^3) IN V `; MESON_TAC[]; PHA; NHANH Planarity.exists_in_aff_gt_disjoint; STRIP_TAC; ASM_CASES_TAC` n = (i:num) `; UNDISCH_TAC` collinear {t, v:real^3, vec 0} `; FIRST_X_ASSUM SUBST_ALL_TAC; ASM_REWRITE_TAC[]; ONCE_REWRITE_TAC[GSYM COLLINEAR_AFFINE_HULL_COLLINEAR]; REWRITE_TAC[GSYM aff]; SUBGOAL_THEN` {vec 0, v, (y:real^3)} SUBSET aff {t,v, vec 0} ` MP_TAC; MP_TAC (ISPECL [` {t, v:real^3, vec 0} `] (ISPECL [` affine` ] HULL_SUBSET)); SIMP_TAC[GSYM aff; INSERT_SUBSET; EMPTY_SUBSET]; SUBGOAL_THEN` t = (w:real^3) ` SUBST_ALL_TAC; EXPAND_TAC "t";
EXPAND_TAC "w"; REWRITE_TAC[]; DOWN; MP_TAC (ISPECL [` {vec 0:real^3} `; `{v, w:real^3 }`] (GEN_ALL Local_lemmas.AFF_GT_SUB_AFF_UNION)); REWRITE_TAC[SUBSET]; DISCH_THEN NHANH; SIMP_TAC[SET_RULE` {a} UNION S = a INSERT S`; INSERT_COMM]; REPEAT STRIP_TAC; SUBGOAL_THEN` collinear {vec 0, v, y:real^3} ` MP_TAC; MATCH_MP_TAC COLLINEAR_SUBSET; EXISTS_TAC` aff {t, v:real^3, vec 0} `; ASM_REWRITE_TAC[]; STRIP_TAC; SUBGOAL_THEN` azim (vec 0) v (rho_node1 FF v) y = &0 ` MP_TAC; DOWN; REWRITE_TAC[AZIM_DEGENERATE]; UNDISCH_TAC` y IN aff_gt {vec 0} {v, w:real^3} `; PHA; UNDISCH_TAC` aff_gt {vec 0} {v, w} SUBSET wedge (vec 0) v (rho_node1 FF v) (ivs_rho_node1 FF v) `; REWRITE_TAC[SUBSET]; DISCH_THEN NHANH; ASM_REWRITE_TAC[wedge; IN_ELIM_THM]; SUBGOAL_THEN` w IN {ITER l (rho_node1 FF) t | 0 < l /\ l < j} ` MP_TAC; REWRITE_TAC[IN_ELIM_THM]; EXISTS_TAC` n - (i:num) `; EXPAND_TAC "t"; REWRITE_TAC[ITER_ADD]; UNDISCH_TAC` ~( n < (i:num)) `; NHANH (ARITH_RULE` ~( a < (b:num)) ==> a - b + b = a `); ASM_SIMP_TAC[]; STRIP_TAC; CONJ_TAC; REPLICATE_TAC 3 DOWN; PHA; ARITH_TAC; ASSUME_TAC2 (ARITH_RULE`~(n < i ) ==> (n - i < (j:num) <=> n < i + j) `); ASM_REWRITE_TAC[]; ASM_REWRITE_TAC[IN_INTER]; ASSUME_TAC2 Local_lemmas.LOFA_IMP_NOT_COLL_IVS; STRIP_TAC; UNDISCH_TAC` ~( n = (i:num)) `; PHA; DOWN THEN DOWN THEN PHA; NHANH Local_lemmas.COLL_IN_AFF_GT_AFF_GT_EQ; STRIP_TAC; MP_TAC ( REWRITE_RULE[INSERT_SUBSET; EMPTY_SUBSET; IN_INSERT] ( ISPECL [`{vec 0: real^3}`;`{v, w:real^3}`; ` {v:real^3} `] (GEN_ALL Local_lemmas.AFF_GT_MONO))); SUBGOAL_THEN` {v,w} DIFF {v:real^3} = {w} ` SUBST1_TAC; UNDISCH_TAC` ~( v = w:real^3) `; SET_TAC[]; REWRITE_TAC[Packing3.SING_UNION_EQ_INSERT]; STRIP_TAC; SUBGOAL_THEN` y IN aff_gt {vec 0, v} {ivs_rho_node1 FF v} ` MP_TAC; DOWN; ASM_REWRITE_TAC[SUBSET]; DISCH_THEN MATCH_MP_TAC; ASM_REWRITE_TAC[]; SUBGOAL_THEN` ~ collinear {vec 0, v, rho_node1 FF v} /\ ~ collinear {vec 0, v, y} /\ ~ collinear {vec 0, v, ivs_rho_node1 FF v } ` MP_TAC; ASSUME_TAC2 Local_lemmas.LOCAL_FAN_CHARACTER_OF_RHO_NODE2; ASM_REWRITE_TAC[]; MATCH_MP_TAC (GEN_ALL Local_lemmas.COLL_IN_AFF_GT_TOO); EXISTS_TAC` ivs_rho_node1 FF v `; ASM_REWRITE_TAC[]; UNDISCH_TAC` aff_gt {vec 0} {v, w} SUBSET aff_gt {vec 0, v} {w:real^3} `; REWRITE_TAC[SUBSET]; DISCH_THEN MATCH_MP_TAC; ASM_REWRITE_TAC[]; NHANH AZIM_EQ_ALT; STRIP_TAC; FIRST_X_ASSUM (SUBST1_TAC o SYM); UNDISCH_TAC` y IN aff_gt {vec 0} {v, w:real^3} `; UNDISCH_TAC` aff_gt {vec 0} {v, w} SUBSET wedge (vec 0) v (rho_node1 FF v) (ivs_rho_node1 FF v) `; REWRITE_TAC[SUBSET]; DISCH_THEN NHANH; REWRITE_TAC[IN_ELIM_THM; wedge]; STRIP_TAC; DOWN; REAL_ARITH_TAC]);;
let EJRCFJD = 
prove(` convex_local_fan (V,E,FF) /\ v IN V /\ w IN V /\ ~(v = w) /\ (!x. x IN FF ==> aff_gt {vec 0} {v, w} SUBSET wedge_in_fan_gt x E) /\ HS = hypermap (HYP (vec 0,V,E UNION {{v, w}})) /\ fv = face HS (v,rho_node1 FF v) /\ fw = face HS (w,rho_node1 FF w) ==> convex_local_fan (v_prime V fv,e_prime (E UNION {{v, w}}) fv,fv) /\ convex_local_fan (v_prime V fw,e_prime (E UNION {{w, v}}) fw,fw) /\ (!ff. sum {i | i < CARD V} (\i. ff i * interior_angle1 (vec 0) FF (ITER i (rho_node1 FF) v)) = sum {i | i < CARD V /\ ITER i (rho_node1 FF) v IN v_prime V fv} (\i. ff i * interior_angle1 (vec 0) fv (ITER i (rho_node1 FF) v)) + sum {i | i < CARD V /\ ITER i (rho_node1 FF) v IN v_prime V fw} (\i. ff i * interior_angle1 (vec 0) fw (ITER i (rho_node1 FF) v)))`,
STRIP_TAC THEN ASSUME_TAC2 PROVE_THE_SLICE_ASSUMPTION THEN MATCH_MP_TAC THE_SLICING_INTO_2_LEMMA THEN ASSUME_TAC2 Local_lemmas.CVX_LO_IMP_LO THEN ASM_REWRITE_TAC[] THEN REPEAT GEN_TAC THEN STRIP_TAC THEN DOWN THEN FIRST_X_ASSUM MATCH_MP_TAC THEN FIRST_X_ASSUM ACCEPT_TAC);;
let DIST_TRIANGLE_AS_ABS = 
prove(` abs ( dist (x,y) - dist (x,z:real^N)) <= dist (y,z) `,
REWRITE_TAC[REAL_ABS_BOUNDS] THEN CONJ_TAC THENL [ REWRITE_TAC[REAL_ARITH` -- a <= b - c <=> c <= b + a `; DIST_TRIANGLE]; REWRITE_TAC[REAL_ARITH` a - b <= c <=> a <= b + c `] THEN MESON_TAC[DIST_TRIANGLE; DIST_SYM]]);;
let CON_ATREAL_REAL_CON2_REDO = 
prove_by_refinement (` (f:real -> real^N) continuous atreal r /\ g continuous atreal r ==> (\t. dist (f t,g t)) real_continuous atreal r`,
[REWRITE_TAC[real_continuous_atreal; continuous_atreal]; REPEAT STRIP_TAC; SUBGOAL_THEN` &0 < e / &2 ` ASSUME_TAC; DOWN; REAL_ARITH_TAC; ASM_REWRITE_TAC[]; FIRST_X_ASSUM (MP_TAC o (SPEC` e / &2 `)); ANTS_TAC; FIRST_X_ASSUM ACCEPT_TAC; FIRST_X_ASSUM (MP_TAC o (SPEC` e / &2 `)); ANTS_TAC; FIRST_X_ASSUM ACCEPT_TAC; STRIP_TAC; STRIP_TAC; EXISTS_TAC` min d d'`; ASM_REWRITE_TAC[REAL_LT_MIN]; GEN_TAC; FIRST_X_ASSUM NHANH; FIRST_X_ASSUM NHANH; STRIP_TAC; SUBST1_TAC (REAL_ARITH` dist ((f:real -> real^N) x',g x') - dist (f r,g r) = (dist (f x',g x') - dist (f x', g r)) + ( dist (f x', g r) - dist (f r,g r))`); MP_TAC (SPECL [` dist ((f:real -> real^N) x',g x') - dist (f x',g r)`; ` dist ((f:real -> real^N) x',g r) - dist (f r,g r) `] REAL_ABS_TRIANGLE); SUBGOAL_THEN` abs (dist ((f:real -> real^N) x',g x') - dist (f x',g r)) + abs (dist (f x',g r) - dist (f r,g r)) < e ` MP_TAC; MATCH_MP_TAC REAL_LET_TRANS; EXISTS_TAC`dist (g x',(g:real -> real^N) r) + dist (f x',(f:real -> real^N) r)`; CONJ_TAC; MATCH_MP_TAC (REAL_ARITH` a <= b /\ d <= c ==> a + d <= b + c `); REWRITE_TAC[DIST_TRIANGLE_AS_ABS]; REWRITE_TAC[DIST_SYM]; ONCE_REWRITE_TAC[DIST_SYM]; REWRITE_TAC[DIST_TRIANGLE_AS_ABS]; ASM_REAL_ARITH_TAC; REAL_ARITH_TAC]);;
let REAL_POS_LT_MUL = 
prove( ` &0 <= a /\ a < b /\ &0 <= x /\ x < y ==> a * x < b * y `,
NHANH REAL_LET_TRANS THEN STRIP_TAC THEN ASSUME_TAC2 (SPECL [` a:real`;` b:real`;` y:real `] REAL_LT_RMUL) THEN MATCH_MP_TAC REAL_LET_TRANS THEN EXISTS_TAC` a * (y:real) ` THEN ASM_REWRITE_TAC[] THEN MATCH_MP_TAC REAL_LE_LMUL THEN ASM_REWRITE_TAC[] THEN MATCH_MP_TAC REAL_LT_IMP_LE THEN FIRST_X_ASSUM ACCEPT_TAC);;
let REAL_CONTINUOUS_ATREAL_IMP_MUL_FUN = 
prove_by_refinement (` f real_continuous atreal r /\ g real_continuous atreal r ==> (\t. (f t) * (g t)) real_continuous atreal r `,
[REWRITE_TAC[real_continuous_atreal]; STRIP_TAC; GEN_TAC; STRIP_TAC; SUBGOAL_THEN` &0 < e / (&2 * ( abs (f (r:real)) + &1)) ` MP_TAC; MATCH_MP_TAC REAL_LT_DIV; ASM_REWRITE_TAC[]; REAL_ARITH_TAC; STRIP_TAC; FIRST_X_ASSUM (MP_TAC o (SPEC` e / (&2 * (abs (f (r:real)) + &1))`)); ANTS_TAC; FIRST_X_ASSUM ACCEPT_TAC; STRIP_TAC; ABBREV_TAC` dd = e / (&2 * (abs (f (r:real)) + &1)) `; SUBGOAL_THEN` &0 < e / (&2 * (abs (g (r:real)) + dd)) ` ASSUME_TAC; MATCH_MP_TAC REAL_LT_DIV; ASM_REWRITE_TAC[]; UNDISCH_TAC` &0 < dd `; REAL_ARITH_TAC; UNDISCH_TAC` !e. &0 < e ==> (?d. &0 < d /\ (!x'. abs (x' - r) < d ==> abs (f x' - f (r:real)) < e))`; STRIP_TAC; FIRST_X_ASSUM (ASSUME_TAC2 o (SPEC` e / (&2 * (abs (g (r:real)) + dd))`)); DOWN THEN STRIP_TAC; EXISTS_TAC` min d d' `; ASM_REWRITE_TAC[REAL_LT_MIN]; GEN_TAC; FIRST_X_ASSUM NHANH; FIRST_X_ASSUM NHANH; STRIP_TAC; SUBST1_TAC (REAL_ARITH` f (x':real) * g x' - f r * g r = (f x' - f r) * g x' + ( g x' - g r) * f r `); MATCH_MP_TAC REAL_LET_TRANS; EXISTS_TAC` abs ((f x' - f r) * g x') + abs ((g x' - g r) * f (r:real)) `; REWRITE_TAC[REAL_ABS_TRIANGLE; REAL_ABS_MUL]; MP_TAC (SPECL[`abs (g x' - g (r:real)) `;` dd:real `; ` abs (f (r:real))`] REAL_LE_RMUL); ANTS_TAC; REWRITE_TAC[ REAL_ABS_POS]; MATCH_MP_TAC REAL_LT_IMP_LE; FIRST_X_ASSUM ACCEPT_TAC; MP_TAC (SPECL [`(g:real -> real) x' `; `(g:real -> real) r`] REAL_SUB_ABS); REWRITE_TAC[REAL_ARITH` a - b <= c <=> a <= b + c `]; STRIP_TAC; ASSUME_TAC2 (REAL_ARITH` abs (g x' - g (r:real)) < dd /\ abs (g x') <= abs (g r) + abs (g x' - g r) ==> abs (g x') < abs (g r) + dd`); STRIP_TAC; MP_TAC (ISPECL [`abs (f x' - f (r:real)) `;` abs ( g (x':real)) `; ` e / (&2 * (abs (g (r:real)) + dd)) `;` abs (g (r:real)) + dd`] (GEN_ALL REAL_POS_LT_MUL)); ANTS_TAC; ASM_REWRITE_TAC[REAL_ABS_POS]; DOWN THEN PHA; NHANH (REAL_ARITH` a <= b /\ c < d ==> c + a < b + d `); STRIP_TAC; DOWN; SUBGOAL_THEN` e / (&2 * (abs (g r) + dd)) * (abs (g (r:real)) + dd) = e / &2 ` SUBST1_TAC; UNDISCH_TAC` &0 < dd `; CONV_TAC REAL_FIELD; EXPAND_TAC "dd";
SUBST1_TAC (REAL_FIELD` e / (&2 * (abs (f (r:real)) + &1)) * abs (f r) = (e / &2) * (abs (f r) / ( abs (f r) + &1))`); SUBGOAL_THEN` abs (f r) / (abs (f (r:real)) + &1) < &1 ` MP_TAC; MATCH_MP_TAC Real_ext.REAL_PROP_LT_LCANCEL; EXISTS_TAC` abs (f (r:real)) + &1`; SUBGOAL_THEN` &0 < abs (f (r:real)) + &1 ` MP_TAC; REAL_ARITH_TAC; SIMP_TAC[REAL_FIELD` &0 < a ==> a * x / a = x `; REAL_MUL_RID]; REAL_ARITH_TAC; DISCH_TAC; MP_TAC (SPECL [` e / &2 `;` abs (f r) / (abs (f (r:real)) + &1)`; `&1 `] REAL_LT_LMUL); ANTS_TAC; ASM_REWRITE_TAC[REAL_ARITH` &0 < e / &2 <=> &0 < e `]; ABBREV_TAC` dx = abs (f x' - f r) * abs (g x') + abs (g x' - g r) * abs (f (r:real))`; REAL_ARITH_TAC]);; let REAL_CONTINUOUS_ATREAL_POW_2 = REWRITE_RULE[CONJ_ACI; GSYM POW_2] ( SPEC` f:real -> real ` (GEN`g:real -> real ` REAL_CONTINUOUS_ATREAL_IMP_MUL_FUN));;
let CONSTANCE_FUN_CONTINUOUS = 
prove(` ! c. (\t. c) real_continuous atreal r `,
REWRITE_TAC[real_continuous_atreal] THEN REPEAT STRIP_TAC THEN EXISTS_TAC ` e:real ` THEN ASM_REWRITE_TAC[REAL_SUB_REFL; REAL_ABS_0]);;
let REAL_CONS_IMP_SCALAR_MUL = 
prove( ` f real_continuous atreal r ==> ! c. (\t. c * f t) real_continuous atreal r `,
STRIP_TAC THEN GEN_TAC THEN MP_TAC (SPEC_ALL CONSTANCE_FUN_CONTINUOUS) THEN DOWN THEN PHA THEN NHANH REAL_CONTINUOUS_ATREAL_IMP_MUL_FUN THEN SIMP_TAC[BETA_THM; REAL_MUL_SYM]);;
let CONS_IMP_SO_IVS = 
prove(` f real_continuous atreal r ==> (\t. -- f t) real_continuous atreal r `,
MP_TAC (SPEC` -- &1 ` CONSTANCE_FUN_CONTINUOUS) THEN PHA THEN NHANH REAL_CONTINUOUS_ATREAL_IMP_MUL_FUN THEN SIMP_TAC[BETA_THM; GSYM REAL_NEG_MINUS1]);;
let REAL_CONS_IMP_SUM_CONS = 
prove_by_refinement( ` f real_continuous atreal r /\ g real_continuous atreal r ==> (\t. f t + g t) real_continuous atreal r `,
[REWRITE_TAC[real_continuous_atreal] ; REPEAT STRIP_TAC ; ASSUME_TAC2 (REAL_ARITH` &0 < e ==> &0 < e / &2 `) ; FIRST_X_ASSUM (ASSUME_TAC2 o (SPEC` e / &2 `)) ; FIRST_X_ASSUM (ASSUME_TAC2 o (SPEC` e / &2 `)) ; DOWN THEN DOWN ; PHA THEN STRIP_TAC ; EXISTS_TAC` min d d' ` ; REWRITE_TAC[REAL_LT_MIN] ; ASM_REWRITE_TAC[] ; GEN_TAC ; FIRST_X_ASSUM NHANH ; FIRST_X_ASSUM NHANH ; STRIP_TAC ; MATCH_MP_TAC REAL_LET_TRANS ; EXISTS_TAC` abs (g x' - g r) + abs (f x' - f (r:real))` ; CONJ_TAC ; REAL_ARITH_TAC ; REPLICATE_TAC 3 DOWN THEN PHA ; REAL_ARITH_TAC]);;
let REAL_CONS_IMP_SCALAR_MUL_ALT = REWRITE_RULE[RIGHT_IMP_FORALL_THM] REAL_CONS_IMP_SCALAR_MUL;;
let UPS_X_CONTS_FUNC = 
prove_by_refinement (` (f:real -> real^N) continuous atreal r /\ (g: real -> real^N) continuous atreal r /\ (h: real -> real^N) continuous atreal r ==> (\r. ups_x (dist (f r,g r) pow 2) (dist (h r,f r) pow 2) (dist (g r, h r) pow 2)) real_continuous atreal r `,
[REWRITE_TAC[ups_x]; STRIP_TAC; ASSUME_TAC2 CON_ATREAL_REAL_CON2_REDO; ASSUME_TAC2 (SPECL [` g:real -> real^N `;` h:real -> real^N`;` r:real `] (GEN_ALL CON_ATREAL_REAL_CON2_REDO)); ASSUME_TAC2 (SPECL [` h:real -> real^N `;` f:real -> real^N`;` r:real `] (GEN_ALL CON_ATREAL_REAL_CON2_REDO)); REPLICATE_TAC 3 DOWN THEN PHA; NHANH_PAT `\x. x ==> y ` REAL_CONTINUOUS_ATREAL_POW_2; REWRITE_TAC[BETA_THM]; NHANH_PAT `\x. x ==> y ` REAL_CONTINUOUS_ATREAL_POW_2; REWRITE_TAC[BETA_THM]; STRIP_TAC; SUBGOAL_THEN`(\r. dist ((f:real -> real^N) r,g r) pow 2 * dist (g r,h r) pow 2) real_continuous atreal r ` ASSUME_TAC; MATCH_MP_TAC REAL_CONTINUOUS_ATREAL_IMP_MUL_FUN; ASM_REWRITE_TAC[]; SUBGOAL_THEN `(\r. dist ((f:real -> real^N) r,g r) pow 2 * dist (h r,f r) pow 2) real_continuous atreal r ` ASSUME_TAC; MATCH_MP_TAC REAL_CONTINUOUS_ATREAL_IMP_MUL_FUN; ASM_REWRITE_TAC[]; SUBGOAL_THEN`(\r. dist ((h:real -> real^N) r,f r) pow 2 * dist (g r,h r) pow 2) real_continuous atreal r ` ASSUME_TAC; MATCH_MP_TAC REAL_CONTINUOUS_ATREAL_IMP_MUL_FUN; ASM_REWRITE_TAC[]; REWRITE_TAC[REAL_ARITH` a - b = a + -- b `]; MATCH_MP_TAC REAL_CONS_IMP_SUM_CONS; CONJ_TAC; MATCH_MP_TAC REAL_CONS_IMP_SUM_CONS; CONJ_TAC; MATCH_MP_TAC REAL_CONS_IMP_SUM_CONS; CONJ_TAC; REWRITE_TAC[REAL_ARITH` -- a * b = -- ( a * b) `]; MATCH_MP_TAC CONS_IMP_SO_IVS; ASM_REWRITE_TAC[GSYM REAL_POW_2]; MATCH_MP_TAC CONS_IMP_SO_IVS; ASM_REWRITE_TAC[GSYM REAL_POW_2]; MATCH_MP_TAC CONS_IMP_SO_IVS; ASM_REWRITE_TAC[GSYM REAL_POW_2]; MATCH_MP_TAC REAL_CONS_IMP_SUM_CONS; CONJ_TAC; MATCH_MP_TAC REAL_CONS_IMP_SCALAR_MUL_ALT; FIRST_X_ASSUM ACCEPT_TAC; MATCH_MP_TAC REAL_CONS_IMP_SUM_CONS; CONJ_TAC; MATCH_MP_TAC REAL_CONS_IMP_SCALAR_MUL_ALT; FIRST_X_ASSUM ACCEPT_TAC; MATCH_MP_TAC REAL_CONS_IMP_SCALAR_MUL_ALT; FIRST_X_ASSUM ACCEPT_TAC]);;
let CONTS_FUN_CONTINUOUS_ATREAL = 
prove( `! v0. (\t. (v0: real^N)) continuous atreal r `,
SIMP_TAC[continuous_atreal; DIST_REFL] THEN MESON_TAC[]);;
let REAL_CONS_STILL_DIFF = 
prove(` f real_continuous atreal r /\ ~( f r = a) ==> ?d. &0 < d /\ (! rr. abs (rr - r) < d ==> ~( f rr = a)) `,
ONCE_REWRITE_TAC[REAL_ARITH` a = b <=> a - b = &0 `] THEN REWRITE_TAC[real_continuous_atreal; REAL_ABS_NZ] THEN STRIP_TAC THEN FIRST_X_ASSUM (ASSUME_TAC2 o (SPEC` abs ((f:real -> real) r - a)`)) THEN DOWN THEN STRIP_TAC THEN EXISTS_TAC` d:real ` THEN ASM_REWRITE_TAC[] THEN GEN_TAC THEN FIRST_X_ASSUM NHANH THEN REAL_ARITH_TAC);;
let CONTINUOUS_PRESERVE_COLLINEAR = 
prove_by_refinement (` f continuous atreal r /\ g continuous atreal r /\ ~ collinear {v0:real^3, f r, g r} ==> ? e. &0 < e /\ (! r'. abs ( r - r') < e ==> ~ collinear {v0, f r', g r'} ) `,
[REWRITE_TAC[Collect_geom.COL_EQ_UPS_0]; MP_TAC (ISPECL [` (f:real -> real^3) r `;` v0:real^3 `; `(g:real -> real^3) r `] (GEN_ALL Collect_geom.TROI_OI_DAT_HOI)); PHA; REWRITE_TAC[Collect_geom.UPS_X_SYM]; STRIP_TAC; MP_TAC (ISPEC` v0:real^3` CONTS_FUN_CONTINUOUS_ATREAL); UNDISCH_TAC` (g:real -> real^3) continuous atreal r `; UNDISCH_TAC` (f:real -> real^3) continuous atreal r `; PHA; NHANH UPS_X_CONTS_FUNC; REWRITE_TAC[BETA_THM]; STRIP_TAC; MP_TAC (ISPECL [` r:real `; `(\r. ups_x (dist ((f:real -> real^3) r,g r) pow 2) (dist (v0,f r) pow 2) (dist (v0,g r) pow 2)) `; ` &0 `] (GEN_ALL REAL_CONS_STILL_DIFF)); ANTS_TAC; ASM_REWRITE_TAC[]; DOWN; REWRITE_TAC[DIST_SYM]; SIMP_TAC[REAL_ARITH` abs ( a - b) = abs ( b - a) `]]);;
let EACH_ELM_PRESERVED_IMP_ALL = 
prove_by_refinement (` (!x. x IN (E: A -> bool) ==> (?e. &0 < e /\ (!t. abs t < e ==> P x t))) /\ FINITE E ==> (?e. &0 < e /\ (!t. abs t < e ==> ! x. x IN E ==> P x t))`,
[ABBREV_TAC` n = CARD (E: A -> bool) `; DOWN; SPEC_TAC (` E: A -> bool `,` E:A -> bool `); SPEC_TAC (`n:num `,` n:num `); INDUCT_TAC; NHANH CARD_EQ_0; STRIP_TAC THEN STRIP_TAC THEN STRIP_TAC; FIRST_X_ASSUM SUBST_ALL_TAC; ASM_REWRITE_TAC[IMAGE_CLAUSES; NOT_IN_EMPTY]; EXISTS_TAC` &1 `; REAL_ARITH_TAC; GEN_TAC; ASM_CASES_TAC` (E: A -> bool) = {} `; ASM_REWRITE_TAC[CARD_CLAUSES; ADD1]; REWRITE_TAC[ARITH_RULE` ~( 0 = n + 1) `]; DOWN; REWRITE_TAC[Local_lemmas.EMPTY_NOT_EXISTS_IN]; REPEAT STRIP_TAC; UNDISCH_TAC` (x:A) IN E `; FIRST_ASSUM NHANH; STRIP_TAC; UNDISCH_TAC` !E. CARD (E: A -> bool) = n ==> (!x. x IN E ==> (?e. &0 < e /\ (!t. abs t < e ==> P x t))) /\ FINITE E ==> (?e. &0 < e /\ (!t. abs t < e ==> (!x. x IN E ==> P x t))) `; STRIP_TAC; FIRST_X_ASSUM (MP_TAC o (SPEC` E DELETE (x:A)`)); PHA; ANTS_TAC; ASSUME_TAC2 (ISPECL [` x:A `;` E: A -> bool `] CARD_DELETE); ASM_REWRITE_TAC[ARITH_RULE` SUC n - 1 = n `; IN_DELETE; FINITE_DELETE]; REPEAT STRIP_TAC; FIRST_X_ASSUM MATCH_MP_TAC; FIRST_X_ASSUM ACCEPT_TAC; STRIP_TAC; EXISTS_TAC` min e e' `; REWRITE_TAC[REAL_LT_MIN]; ASM_REWRITE_TAC[]; FIRST_X_ASSUM NHANH; FIRST_X_ASSUM NHANH; GEN_TAC; SET_TAC[]]);;
let EACH_ELM_PRESERVED_IMP_ALLL =
prove_by_refinement ( ` (! x. (x:real^3 -> bool) IN E ==> (? e. &0 < e /\ (! t. abs t < e ==> ~collinear ({vec 0} UNION (IMAGE (\v. (phii: real ^3 -> real -> real^3) v t) x))))) /\ FINITE E ==> ?e. &0 < e /\ (!t. abs t < e ==> (!e. e IN IMAGE (IMAGE (\v. phii v t)) E ==> ~collinear ({vec 0} UNION e))) `,
[ABBREV_TAC` n = CARD (E:(real^3 -> bool) -> bool) `; DOWN; SPEC_TAC (` E:(real^3 -> bool) -> bool `,` E:(real^3 -> bool) -> bool `); SPEC_TAC (`n:num `,` n:num `); INDUCT_TAC; NHANH CARD_EQ_0; STRIP_TAC THEN STRIP_TAC THEN STRIP_TAC; FIRST_X_ASSUM SUBST_ALL_TAC; ASM_REWRITE_TAC[IMAGE_CLAUSES; NOT_IN_EMPTY]; EXISTS_TAC` &1 `; REAL_ARITH_TAC; GEN_TAC; ASM_CASES_TAC` (E:(real^3 -> bool) -> bool) = {} `; ASM_REWRITE_TAC[CARD_CLAUSES; ADD1]; REWRITE_TAC[ARITH_RULE` ~( 0 = n + 1) `]; DOWN; REWRITE_TAC[Local_lemmas.EMPTY_NOT_EXISTS_IN]; REPEAT STRIP_TAC; UNDISCH_TAC` (x:real^3 -> bool) IN E `; FIRST_ASSUM NHANH; STRIP_TAC; UNDISCH_TAC` !E. CARD (E: (real^3 -> bool) -> bool) = n ==> (!x. x IN E ==> (?e. &0 < e /\ (!t. abs t < e ==> ~collinear ({vec 0} UNION IMAGE (\v. (phii:real^3 -> real -> real^3) v t ) x)))) /\ FINITE E ==> (?e. &0 < e /\ (!t. abs t < e ==> (!e. e IN IMAGE (IMAGE (\v. phii v t)) E ==> ~collinear ({vec 0} UNION e)))) `; STRIP_TAC; FIRST_X_ASSUM (MP_TAC o (SPEC` E DELETE (x:real^3 -> bool)`)); PHA; ANTS_TAC; ASSUME_TAC2 (ISPECL [` x:real ^3 -> bool `;` E: (real^3 -> bool) -> bool `] CARD_DELETE); ASM_REWRITE_TAC[ARITH_RULE` SUC n - 1 = n `; IN_DELETE; FINITE_DELETE]; REPEAT STRIP_TAC; FIRST_X_ASSUM MATCH_MP_TAC; FIRST_X_ASSUM ACCEPT_TAC; STRIP_TAC; EXISTS_TAC` min e e' `; REWRITE_TAC[REAL_LT_MIN]; ASM_REWRITE_TAC[]; FIRST_X_ASSUM NHANH; FIRST_X_ASSUM NHANH; GEN_TAC; SET_TAC[]]);;
let ALL_TO_THE_NONPARALLEL_PART = 
prove_by_refinement (` deformation phii (V:real^3 -> bool) (a,b) /\ FAN (vec 0, V,E) ==> (?e. &0 < e /\ (!t. --e < t /\ t < e ==> UNIONS (IMAGE (IMAGE (\v. phii v t)) E) SUBSET IMAGE (\v. phii v t) V /\ graph (IMAGE (IMAGE (\v. phii v t)) E) /\ fan1 (vec 0, IMAGE (\v. phii v t) V, IMAGE (IMAGE (\v. phii v t)) E) /\ fan2 (vec 0, IMAGE (\v. phii v t) V, IMAGE (IMAGE (\v. phii v t)) E) /\ fan6 (vec 0, IMAGE (\v. phii v t) V, IMAGE (IMAGE (\v. phii v t)) E) ))`,
[REWRITE_TAC[FAN]; STRIP_TAC; MATCH_MP_TAC (GEN_ALL TOW_REAL_EXISTS_COMBINED); CONJ_TAC; EXISTS_TAC` &1 `; REWRITE_TAC[REAL_ARITH` &0 < &1 `]; GEN_TAC; STRIP_TAC; REWRITE_TAC[GSYM IMAGE_UNIONS]; MATCH_MP_TAC IMAGE_SUBSET; ASM_REWRITE_TAC[]; MATCH_MP_TAC (GEN_ALL TOW_REAL_EXISTS_COMBINED); CONJ_TAC; DOWN_TAC; REWRITE_TAC[deformation; graph; fan1; fan2]; STRIP_TAC; MP_TAC (ISPECL [` &0 `;`phii:real^3 -> real -> real^3 `;`V:real^3 -> bool`] (GEN_ALL CONTINUOUS_ATREAL_INJ_PRESERVED)); PHA; ANTS_TAC; ASM_SIMP_TAC[]; ASM_SIMP_TAC[REAL_SUB_RZERO]; STRIP_TAC; EXISTS_TAC `d:real `; ASM_REWRITE_TAC[REAL_BOUNDS_LT; IMAGE; IN_ELIM_THM]; FIRST_X_ASSUM NHANH; DOWN_TAC; REWRITE_TAC[HAS_SIZE_2_EXISTS; IN]; REPEAT STRIP_TAC; SUBGOAL_THEN` (?xx y. ~(xx = y) /\ (!z. x (z:real^3) <=> z = xx \/ z = y))` MP_TAC; UNDISCH_TAC` (E:(real^3 -> bool) -> bool) x `; ASM_REWRITE_TAC[]; STRIP_TAC; EXISTS_TAC` (phii: real^3 -> (real -> real^3)) xx t `; EXISTS_TAC` (phii: real^3 -> (real -> real^3)) y t `; CONJ_TAC; FIRST_X_ASSUM MATCH_MP_TAC; ASM_REWRITE_TAC[]; ASSUME_TAC2 (SET_RULE` UNIONS E SUBSET (V:real^3 -> bool) /\ E x ==> (! z. x z ==> V z) `); DOWN THEN DOWN; MESON_TAC[]; ASM_REWRITE_TAC[IN_ELIM_THM]; MESON_TAC[]; MATCH_MP_TAC (GEN_ALL TOW_REAL_EXISTS_COMBINED); CONJ_TAC; REWRITE_TAC[fan1]; EXISTS_TAC` &1 `; REWRITE_TAC[REAL_ARITH` &0 < &1 `]; REPEAT STRIP_TAC; MATCH_MP_TAC FINITE_IMAGE; DOWN_TAC; SIMP_TAC[fan1]; DOWN_TAC; SIMP_TAC[SET_RULE` s SUBSET {} <=> s = {} `; fan1; IMAGE_EQ_EMPTY]; CONV_TAC TAUT; MATCH_MP_TAC (GEN_ALL TOW_REAL_EXISTS_COMBINED); CONJ_TAC; DOWN_TAC; REWRITE_TAC[fan2; deformation]; STRIP_TAC; MP_TAC (ISPECL [`&0`;` phii:real^3 -> real -> real^ 3 `;` vec 0:real^3 `; ` V:real^3 -> bool `] (GEN_ALL CONTINUOUS_ATREAL_DISTINCT_FINITE)); ANTS_TAC; DOWN_TAC; SIMP_TAC[fan2; fan1]; ANTS_TAC; DOWN_TAC; SIMP_TAC[fan2; fan1]; STRIP_TAC; UNDISCH_TAC` ~( vec 0 IN (V:real^3 -> bool)) `; MESON_TAC[]; REWRITE_TAC[REAL_SUB_RZERO; REAL_BOUNDS_LT; IN_IMAGE]; MESON_TAC[]; REWRITE_TAC[fan6]; UNDISCH_TAC` graph (E:(real^3 -> bool) -> bool) `; REWRITE_TAC[Fan.GRAPH]; DOWN_TAC; REWRITE_TAC[fan1; fan2]; STRIP_TAC; ASSUME_TAC2 (ISPECL [` UNIONS (E:(real^3 -> bool) -> bool) `;` V:real^3 -> bool`] FINITE_SUBSET); DOWN; REWRITE_TAC[FINITE_UNIONS; REAL_BOUNDS_LT]; STRIP_TAC; MATCH_MP_TAC EACH_ELM_PRESERVED_IMP_ALLL; ASM_REWRITE_TAC[]; GEN_TAC; STRIP_TAC; SUBGOAL_THEN` (x:real^3 -> bool) HAS_SIZE 2 ` MP_TAC; DOWN; ASM_REWRITE_TAC[]; DOWN_TAC; REWRITE_TAC[fan6; deformation; HAS_SIZE_2_EXISTS2]; STRIP_TAC; SUBGOAL_THEN` ~collinear ({vec 0: real^3} UNION x)` MP_TAC; FIRST_X_ASSUM MATCH_MP_TAC; FIRST_X_ASSUM ACCEPT_TAC; ASM_REWRITE_TAC[IMAGE_CLAUSES; Local_lemmas.INSERT_UNION2; UNION_EMPTY]; ONCE_REWRITE_TAC[REAL_ARITH` abs t = abs (&0 - t) `]; STRIP_TAC; MATCH_MP_TAC CONTINUOUS_PRESERVE_COLLINEAR; ASSUME_TAC2 (SET_RULE` UNIONS E SUBSET V /\ (x:real^3 -> bool) IN E ==> x SUBSET V `); DOWN; ASM_REWRITE_TAC[INSERT_SUBSET; EMPTY_SUBSET]; UNDISCH_TAC` !v. (v:real^3) IN V ==> phii v (&0) = v`; DISCH_THEN NHANH; ASM_SIMP_TAC[ETA_AX]]);;
(* ================================================================== *) (* ================================================================== *) end;;