(* ========================================================================== *)
(* FLYSPECK - BOOK FORMALIZATION                                              *)
(*                                                                            *)
(* Chapter: Local Fan                                              *)
(* Author: Hoang Le Truong                                        *)
(* Date: 2012-04-01                                                           *)
(* ========================================================================= *)


(*
remaining conclusions from appendix to Local Fan chapter
*)


module Qknvmlb = struct

open Polyhedron;;
open Sphere;;
open Topology;;		
open Fan_misc;;
open Planarity;; 
open Conforming;;
open Hypermap;;
open Fan;;
open Topology;;
open Wrgcvdr_cizmrrh;;
open Local_lemmas;;
open Collect_geom;;
open Dih2k_hypermap;;
open Wjscpro;;
open Tecoxbm;;
open Hdplygy;;
open Nkezbfc_local;;
open Flyspeck_constants;;
open Gbycpxs;;
open Pcrttid;;
open Local_lemmas;;
open Pack_defs;;

open Hales_tactic;;

open Appendix;;





open Hypermap;;
open Fan;;
open Wrgcvdr_cizmrrh;;
open Local_lemmas;;
open Flyspeck_constants;;
open Pack_defs;;

open Hales_tactic;;

open Appendix;;


open Zithlqn;;


open Xwitccn;;

open Ayqjtmd;;

open Jkqewgv;;


let MOD_EQ_IMP_MOD_EQ_0=
prove( `~(k=0)/\ p MOD k = q MOD k/\ q<= p ==> (p-q) MOD k =0`,
REPEAT STRIP_TAC THEN MRESA_TAC DIVISION[`p:num`;`k:num`] THEN MRESA_TAC DIVISION[`q:num`;`k:num`] THEN MP_TAC(ARITH_RULE`p = p DIV k * k + q MOD k /\ q = q DIV k * k + q MOD k /\ q<=p ==> p-q = (p DIV k *k - q DIV k *k)`) THEN ASM_REWRITE_TAC[] THEN POP_ASSUM(fun th-> REMOVE_ASSUM_TAC THEN POP_ASSUM(fun th1-> GEN_REWRITE_TAC(LAND_CONV o LAND_CONV o LAND_CONV o LAND_CONV o ONCE_DEPTH_CONV)[th1]) THEN REWRITE_TAC[] THEN GEN_REWRITE_TAC( LAND_CONV o LAND_CONV o LAND_CONV o ONCE_DEPTH_CONV)[th]) THEN ASM_REWRITE_TAC[] THEN MRESA_TAC DIV_MONO[`q:num`;`p:num`;`k:num`] THEN REWRITE_TAC[GSYM RIGHT_SUB_DISTRIB] THEN RESA_TAC THEN MRESA_TAC MOD_MULT[`k:num`;`(p DIV k - q DIV k)`] THEN ONCE_REWRITE_TAC[ARITH_RULE`(p DIV k - q DIV k) * k=k* (p DIV k - q DIV k) `] THEN ASM_REWRITE_TAC[]);;
let SCS_K_PRIME_CASE_4=
prove(`s' = scs_half_slice_v39 s p q d' mkj /\ is_scs_v39 s /\ scs_k_v39 s=4 /\ scs_diag (scs_k_v39 s) p q ==> scs_k_v39 s' =3`,
let CASE_DIAGONAL_MOD= fun (so:term) (so1:term) (so2:term)-> MRESAL_TAC(GEN_ALL IMP_SUC_MOD_EQ)[`p:num`;so;`4`][ARITH_RULE`~(4=0)/\ 4 MOD 4=0/\ SUC 0 MOD 4=1/\ 1 MOD 4=1 /\ 2 MOD 4=2 /\ 3 MOD 4=3/\ 0 MOD 4=0 /\ SUC 1=2 /\ SUC 2=3/\ SUC 3=4`] THEN POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[th] THEN REPEAT STRIP_TAC) THEN POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[th] THEN REPEAT STRIP_TAC) THEN MRESAL_TAC MOD_ADD_MOD[`q:num`;so1;`4`][ARITH_RULE`~(4=0) /\ 1 MOD 4=1/\ 1+4-0=5/\ 1+4-1=4 /\ 5 MOD 4=1/\ 4 MOD 4=0/\ 1+4-2=3 /\ 3 MOD 4=3/\ 2 MOD 4=2 /\ 1+4-3=2`;ADD1] THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN MRESAL_TAC DIVISION[`q:num`;`4:num`][ARITH_RULE`~(4=0)`] THEN MP_TAC(ARITH_RULE`q MOD 4 < 4 ==> q MOD 4 =0 \/ q MOD 4 =1 \/ q MOD 4 =2 \/ q MOD 4 =3`) THEN RESA_TAC THEN ASM_REWRITE_TAC[ARITH_RULE`(3) MOD 4=3 /\ 2 +1=3 /\ 3+0=3/\ 0+3=3 /\ 1+2=3`] THEN MRESAL_TAC(GEN_ALL IMP_SUC_MOD_EQ)[`q:num`;so2;`4`][ARITH_RULE`~(4=0)/\ 4 MOD 4=0/\ SUC 0 MOD 4=1/\ 1 MOD 4=1 /\ 2 MOD 4=2 /\ 3 MOD 4=3/\ 0 MOD 4=0/\ SUC 3=4/\ SUC 1=2/\ SUC 2=3`] in REPEAT STRIP_TAC THEN POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[scs_half_slice_v39;LET_DEF;LET_END_DEF;scs_k_v39_explicit;scs_diag] THEN STRIP_TAC THEN MRESAL_TAC DIVISION[`p:num`;`4:num`][ARITH_RULE`~(4=0)`] THEN MP_TAC(ARITH_RULE`p MOD 4 < 4 ==> p MOD 4 =0 \/ p MOD 4 =1 \/ p MOD 4 =2 \/ p MOD 4 =3`) THEN RESA_TAC THENL[ CASE_DIAGONAL_MOD `0` `5` `3`; CASE_DIAGONAL_MOD `1` `4` `0`; CASE_DIAGONAL_MOD `2` `3` `1`; CASE_DIAGONAL_MOD `3` `2` `2`]);;
let SCS_K_PRIME_CASE_5=
prove( `s' = scs_half_slice_v39 s p q d' mkj /\ s'' = scs_half_slice_v39 s q p d' mkj /\ is_scs_v39 s /\ scs_k_v39 s=5 /\ scs_diag (scs_k_v39 s) p q ==> (scs_k_v39 s' =3 /\ scs_k_v39 s'' =4) \/ (scs_k_v39 s' =4 /\ scs_k_v39 s'' =3)`,
let CASE_DIAGONAL_MOD= fun (so:term) (so1:term) (so2:term) -> MRESAL_TAC(GEN_ALL IMP_SUC_MOD_EQ)[`p:num`;so;`5`][ARITH_RULE`~(5=0)/\ 5 MOD 5=0/\ SUC 0 MOD 5=1/\ 1 MOD 5=1 /\ 2 MOD 5=2 /\ 3 MOD 5=3/\ 0 MOD 5=0 /\ SUC 1=2 /\ SUC 2=3/\ SUC 3=4/\ 4 MOD 5=4 /\ SUC 4=5`] THEN POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[th] THEN REPEAT STRIP_TAC) THEN POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[th] THEN REPEAT STRIP_TAC THEN ASSUME_TAC th) THEN MRESAL_TAC MOD_ADD_MOD[`q:num`;so1;`5`][ARITH_RULE`~(5=0) /\ 1 MOD 5=1/\ 1+5-0=6/\ 1+5-1=5 /\ 6 MOD 5=1/\ 5 MOD 5=0/\ 1+5-2=4 /\ 3 MOD 5=3/\ 2 MOD 5=2 /\ 1+5-3=3/\ 1+5-4=2`;ADD1] THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN MRESAL_TAC DIVISION[`q:num`;`5:num`][ARITH_RULE`~(5=0)`]THEN MP_TAC(ARITH_RULE`q MOD 5 < 5 ==> q MOD 5 =0 \/ q MOD 5 =1 \/ q MOD 5 =2 \/ q MOD 5 = 3\/ q MOD 5=4`) THEN RESA_TAC THEN ASM_REWRITE_TAC[ARITH_RULE`(3) MOD 5=3 /\ 2 +1=3 /\ 3+0=3/\ 0+3=3 /\ 1+2=3`] THEN MRESAL_TAC(GEN_ALL IMP_SUC_MOD_EQ)[`q:num`;so2;`5`][ARITH_RULE`~(5=0)/\ 5 MOD 5=0/\ SUC 0 MOD 5=1/\ 1 MOD 5=1 /\ 2 MOD 5=2 /\ 3 MOD 5=3/\ 0 MOD 5=0/\ SUC 3=4/\ SUC 1=2/\ SUC 2=3/\ SUC 4=5/\ 4 MOD 5=4`] THEN MRESAL_TAC MOD_ADD_MOD[`p:num`;`4`;`5`][ARITH_RULE`~(5=0) /\ 1 MOD 5=1/\ 1+5-0=6/\ 1+5-1=5 /\ 6 MOD 5=1/\ 5 MOD 5=0/\ 1+5-2=4 /\ 3 MOD 5=3/\ 2 MOD 5=2 /\ 1+5-3=3/\ 1+5-4=2/\ 4 MOD 5=4 /\ 0+4=4`;ADD1] THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN MRESAL_TAC MOD_ADD_MOD[`p:num`;`3`;`5`][ARITH_RULE`~(5=0) /\ 1 MOD 5=1/\ 1+5-0=6/\ 1+5-1=5 /\ 6 MOD 5=1/\ 5 MOD 5=0/\ 1+5-2=4 /\ 3 MOD 5=3/\ 2 MOD 5=2 /\ 1+5-3=3/\ 1+5-4=2/\ 4 MOD 5=4 /\ 0+3=3 /\ 3+1=4/\ 1+3=4/\ 4+0=4`;ADD1] THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN MRESAL_TAC MOD_ADD_MOD[`p:num`;`2`;`5`][ARITH_RULE`~(5=0) /\ 1 MOD 5=1/\ 1+5-0=6/\ 1+5-1=5 /\ 6 MOD 5=1/\ 5 MOD 5=0/\ 1+5-2=4 /\ 3 MOD 5=3/\ 2 MOD 5=2 /\ 1+5-3=3/\ 1+5-4=2/\ 4 MOD 5=4 /\ 0+3=3 /\ 3+1=4/\ 1+3=4/\ 4+0=4/\ 1+2=3`;ADD1] THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN MRESAL_TAC MOD_ADD_MOD[`p:num`;`6`;`5`][ARITH_RULE`~(5=0) /\ 1 MOD 5=1/\ 1+5-0=6/\ 1+5-1=5 /\ 6 MOD 5=1/\ 5 MOD 5=0/\ 1+5-2=4 /\ 3 MOD 5=3/\ 2 MOD 5=2 /\ 1+5-3=3/\ 1+5-4=2/\ 4 MOD 5=4 /\ 0+3=3 /\ 3+1=4/\ 1+3=4/\ 4+0=4/\ 1+2=3/\ 2+1=3 /\ 4+4=8 /\ 8 MOD 5=3 /\ 2+2=4`;ADD1] THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN MRESAL_TAC MOD_ADD_MOD[`p:num`;`5`;`5`][ARITH_RULE`~(5=0) /\ 1 MOD 5=1/\ 1+5-0=6/\ 1+5-1=5 /\ 6 MOD 5=1/\ 5 MOD 5=0/\ 1+5-2=4 /\ 3 MOD 5=3/\ 2 MOD 5=2 /\ 1+5-3=3/\ 1+5-4=2/\ 4 MOD 5=4 /\ 0+3=3 /\ 3+1=4/\ 1+3=4/\ 4+0=4/\ 1+2=3/\ 2+1=3 /\ 4+4=8 /\ 8 MOD 5=3 /\ 2+2=4/\ 3+0=3`;ADD1] THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) in REPEAT STRIP_TAC THEN POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[scs_half_slice_v39;LET_DEF;LET_END_DEF;scs_k_v39_explicit;scs_diag] THEN STRIP_TAC THEN MRESAL_TAC DIVISION[`p:num`;`5:num`][ARITH_RULE`~(5=0)`] THEN MP_TAC(ARITH_RULE`p MOD 5 < 5 ==> p MOD 5 =0 \/ p MOD 5 =1 \/ p MOD 5 =2 \/ p MOD 5 =3\/ p MOD 5=4`) THEN RESA_TAC THENL[ CASE_DIAGONAL_MOD `0` `6` `4`; CASE_DIAGONAL_MOD `1` `5` `0`; CASE_DIAGONAL_MOD `2` `4` `1`; CASE_DIAGONAL_MOD `3` `3` `2`; CASE_DIAGONAL_MOD `4` `2` `3`]);;
let SCS_K_PRIME_CASE_6=
prove( `s' = scs_half_slice_v39 s p q d' mkj /\ s'' = scs_half_slice_v39 s q p d' mkj /\ is_scs_v39 s /\ scs_k_v39 s=6 /\ scs_diag (scs_k_v39 s) p q ==> (scs_k_v39 s' =3 /\ scs_k_v39 s'' =5) \/ (scs_k_v39 s' =5 /\ scs_k_v39 s'' =3) \/ (scs_k_v39 s' =4 /\ scs_k_v39 s'' =4)`,
let CASE_DIAGONAL_MOD= fun (so:term) (so1:term) (so2:term) -> MRESAL_TAC(GEN_ALL IMP_SUC_MOD_EQ)[`p:num`;so;`6`][ARITH_RULE`~(6=0)/\ 6 MOD 6=0/\ SUC 0 MOD 6=1/\ 1 MOD 6=1 /\ 2 MOD 6=2 /\ 3 MOD 6=3/\ 0 MOD 6=0 /\ SUC 1=2 /\ SUC 2=3/\ SUC 3=4/\ 4 MOD 6=4 /\ SUC 4=5/\ SUC 5=6 /\ 5 MOD 6=5`] THEN POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[th] THEN REPEAT STRIP_TAC) THEN POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[th] THEN REPEAT STRIP_TAC THEN ASSUME_TAC th) THEN MRESAL_TAC MOD_ADD_MOD[`q:num`;so1;`6`][ARITH_RULE`~(6=0) /\ 1 MOD 6=1/\ 1+6-0=7/\ 1+6-1=6 /\ 7 MOD 6=1/\ 6 MOD 6=0/\ 1+6-2=5 /\ 3 MOD 6=3/\ 2 MOD 6=2 /\ 1+6-3=4/\ 1+6-4=3/\ 1+6-5=2`;ADD1] THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN MRESAL_TAC DIVISION[`q:num`;`6:num`][ARITH_RULE`~(6=0)`]THEN MP_TAC(ARITH_RULE`q MOD 6 < 6 ==> q MOD 6 =0 \/ q MOD 6 =1 \/ q MOD 6 =2 \/ q MOD 6 = 3\/ q MOD 6=4\/ q MOD 6=5`) THEN RESA_TAC THEN ASM_REWRITE_TAC[ARITH_RULE`(3) MOD 6=3 /\ 2 +1=3 /\ 3+0=3/\ 0+3=3 /\ 1+2=3`] THEN MRESAL_TAC(GEN_ALL IMP_SUC_MOD_EQ)[`q:num`;so2;`6`][ARITH_RULE`~(6=0)/\ 6 MOD 6=0/\ SUC 0 MOD 6=1/\ 1 MOD 6=1 /\ 2 MOD 6=2 /\ 3 MOD 6=3/\ 0 MOD 6=0/\ SUC 3=4/\ SUC 1=2/\ SUC 2=3/\ SUC 4=5/\ SUC 5=6/\ 4 MOD 6=4/\ 5 MOD 6=5`] THEN MRESAL_TAC MOD_ADD_MOD[`p:num`;`4`;`6`][ARITH_RULE`~(6=0) /\ 1 MOD 6=1/\ 1+6-0=7/\ 1+6-1=6 /\ 7 MOD 6=1/\ 6 MOD 6=0/\ 1+6-2=5 /\ 3 MOD 6=3/\ 2 MOD 6=2 /\ 1+6-3=4/\ 1+6-4=3/\ 4 MOD 6=4 /\ 0+3=3 /\ 3+1=4/\ 1+3=4/\ 4+0=4/\ 1+2=3/\ 2+1=3 /\ 4+4=8 /\ 8 MOD 6=2 /\ 2+2=4/\ 3+0=3/\ 1+6-5=2`;ADD1] THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN MRESAL_TAC MOD_ADD_MOD[`p:num`;`3`;`6`][ARITH_RULE`~(6=0) /\ 1 MOD 6=1/\ 1+6-0=7/\ 1+6-1=6 /\ 7 MOD 6=1/\ 6 MOD 6=0/\ 1+6-2=5 /\ 3 MOD 6=3/\ 2 MOD 6=2 /\ 1+6-3=4/\ 1+6-4=3/\ 4 MOD 6=4 /\ 0+3=3 /\ 3+1=4/\ 1+3=4/\ 4+0=4/\ 1+2=3/\ 2+1=3 /\ 4+4=8 /\ 8 MOD 6=2 /\ 2+2=4/\ 3+0=3`;ADD1] THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN MRESAL_TAC MOD_ADD_MOD[`p:num`;`2`;`6`][ARITH_RULE`~(6=0) /\ 1 MOD 6=1/\ 1+6-0=7/\ 1+6-1=6 /\ 7 MOD 6=1/\ 6 MOD 6=0/\ 1+6-2=5 /\ 3 MOD 6=3/\ 2 MOD 6=2 /\ 1+6-3=4/\ 1+6-4=3/\ 4 MOD 6=4 /\ 0+3=3 /\ 3+1=4/\ 1+3=4/\ 4+0=4/\ 1+2=3/\ 2+1=3 /\ 4+4=8 /\ 8 MOD 6=2 /\ 2+2=4/\ 3+0=3`;ADD1] THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN MRESAL_TAC MOD_ADD_MOD[`p:num`;`6`;`6`][ARITH_RULE`~(6=0) /\ 1 MOD 6=1/\ 1+6-0=7/\ 1+6-1=6 /\ 7 MOD 6=1/\ 6 MOD 6=0/\ 1+6-2=5 /\ 3 MOD 6=3/\ 2 MOD 6=2 /\ 1+6-3=4/\ 1+6-4=3/\ 4 MOD 6=4 /\ 0+3=3 /\ 3+1=4/\ 1+3=4/\ 4+0=4/\ 1+2=3/\ 2+1=3 /\ 4+4=8 /\ 8 MOD 6=2 /\ 2+2=4/\ 3+0=3`;ADD1] THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN MRESAL_TAC MOD_ADD_MOD[`p:num`;`5`;`6`][ARITH_RULE`~(6=0) /\ 1 MOD 6=1/\ 1+6-0=7/\ 1+6-1=6 /\ 7 MOD 6=1/\ 6 MOD 6=0/\ 1+6-2=5 /\ 3 MOD 6=3/\ 2 MOD 6=2 /\ 1+6-3=4/\ 1+6-4=3/\ 4 MOD 6=4 /\ 0+3=3 /\ 3+1=4/\ 1+3=4/\ 4+0=4/\ 1+2=3/\ 2+1=3 /\ 4+4=8 /\ 8 MOD 6=2 /\ 2+2=4/\ 3+0=3/\ 5 MOD 6=5/\ 0+5=5/\0+4= 4/\ 4+1=5/\ 1+4=5 /\ 5+0=5`;ADD1] THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN MRESAL_TAC MOD_ADD_MOD[`p:num`;`7`;`6`][ARITH_RULE`~(6=0) /\ 1 MOD 6=1/\ 1+6-0=7/\ 1+6-1=6 /\ 7 MOD 6=1/\ 6 MOD 6=0/\ 1+6-2=5 /\ 3 MOD 6=3/\ 2 MOD 6=2 /\ 1+6-3=4/\ 1+6-4=3/\ 4 MOD 6=4 /\ 0+3=3 /\ 3+1=4/\ 1+3=4/\ 4+0=4/\ 1+2=3/\ 2+1=3 /\ 4+4=8 /\ 8 MOD 6=2 /\ 2+2=4/\ 3+0=3/\ 5 MOD 6=5/\ 0+5=5/\0+4= 4/\ 4+1=5/\ 1+4=5 /\ 5+0=5/\ 4+5=9/\ 9 MOD 6=3/\ 2+3=5/\ 5+5=10/\ 10 MOD 6=4/\ 5+4=9/\ 3+2=5`;ADD1] THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) in REPEAT STRIP_TAC THEN POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[scs_half_slice_v39;LET_DEF;LET_END_DEF;scs_k_v39_explicit;scs_diag] THEN STRIP_TAC THEN MRESAL_TAC DIVISION[`p:num`;`6:num`][ARITH_RULE`~(6=0)`] THEN MP_TAC(ARITH_RULE`p MOD 6 < 6 ==> p MOD 6 =0 \/ p MOD 6 =1 \/ p MOD 6 =2 \/ p MOD 6 =3\/ p MOD 6=4\/ p MOD 6=5`) THEN RESA_TAC THENL[ CASE_DIAGONAL_MOD `0` `7` `5`; CASE_DIAGONAL_MOD `1` `6` `0`; CASE_DIAGONAL_MOD `2` `5` `1`; CASE_DIAGONAL_MOD `3` `4` `2`; CASE_DIAGONAL_MOD `4` `3` `3`; CASE_DIAGONAL_MOD `5` `2` `4`]);;
let SCS_K_PRIME_CASE_3=
prove(`is_scs_v39 s /\ scs_diag (scs_k_v39 s) p q ==> 3< scs_k_v39 s`,
let LEMMA_TAC= fun (so:term) (so1:term)-> MRESAL_TAC(GEN_ALL IMP_SUC_MOD_EQ)[`p:num`;so;`3`][ARITH_RULE`~(3=0)/\ 3 MOD 3=0/\ SUC 0 MOD 3=1/\ 1 MOD 3=1 /\ 2 MOD 3=2 /\ 0 MOD 3=0 /\ SUC 1=2 /\ SUC 2=3/\ SUC 3=4`] THEN MRESAL_TAC DIVISION[`q:num`;`3:num`][ARITH_RULE`~(3=0)`] THEN MP_TAC(ARITH_RULE`q MOD 3< 3 ==> q MOD 3 =0\/ q MOD 3 =1 \/ q MOD 3 =2`) THEN RESA_TAC THEN MRESAL_TAC(GEN_ALL IMP_SUC_MOD_EQ)[`q:num`;so1;`3`][ARITH_RULE`~(3=0)/\ 3 MOD 3=0/\ SUC 0 MOD 3=1/\ 1 MOD 3=1 /\ 2 MOD 3=2 /\ 0 MOD 3=0 /\ SUC 1=2 /\ SUC 2=3/\ SUC 3=4`] in REWRITE_TAC[LET_DEF;LET_END_DEF;scs_half_slice_v39;is_scs_v39;scs_diag;scs_v39_explicit] THEN STRIP_TAC THEN MP_TAC(ARITH_RULE`3<= scs_k_v39 s ==> scs_k_v39 s =3\/ 3<scs_k_v39 s`) THEN ASM_REWRITE_TAC[] THEN STRIP_TAC THEN POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[th] THEN REPEAT STRIP_TAC) THEN REPLICATE_TAC 3 (POP_ASSUM MP_TAC) THEN MRESAL_TAC DIVISION[`p:num`;`3:num`][ARITH_RULE`~(3=0)`] THEN MP_TAC(ARITH_RULE`p MOD 3< 3 ==> p MOD 3 =0\/ p MOD 3 =1 \/ p MOD 3 =2`) THEN RESA_TAC THENL[LEMMA_TAC `0` `2`; LEMMA_TAC `1` `0`; LEMMA_TAC `2` `1`]);;
let SCS_K_PRIME_LE_GE=
prove(` let s' = scs_half_slice_v39 s p q d' mkj in is_scs_v39 s /\ scs_diag (scs_k_v39 s) p q ==> 3<= scs_k_v39 s' /\ scs_k_v39 s'<=6 /\ scs_k_v39 s'< scs_k_v39 s `,
REWRITE_TAC[LET_DEF;LET_END_DEF;] THEN STRIP_TAC THEN MP_TAC SCS_K_PRIME_CASE_3 THEN RESA_TAC THEN POP_ASSUM MP_TAC THEN POP_ASSUM MP_TAC THEN POP_ASSUM(fun th-> REPEAT DISCH_TAC THEN MP_TAC th THEN REWRITE_TAC[is_scs_v39] THEN ASSUME_TAC th THEN STRIP_TAC) THEN ABBREV_TAC`s' = scs_half_slice_v39 s p q d' mkj` THEN ABBREV_TAC`s'' = scs_half_slice_v39 s q p d' mkj` THEN MP_TAC(ARITH_RULE`3 < scs_k_v39 s /\ scs_k_v39 s<=6 ==> scs_k_v39 s = 4\/ scs_k_v39 s = 5\/ scs_k_v39 s = 6`) THEN RESA_TAC THENL[ MP_TAC SCS_K_PRIME_CASE_4 THEN RESA_TAC THEN ARITH_TAC; MP_TAC SCS_K_PRIME_CASE_5 THEN RESA_TAC THEN ARITH_TAC; MP_TAC SCS_K_PRIME_CASE_6 THEN RESA_TAC THEN ARITH_TAC]);;
let SCS_HALF_SLICE_IS_SCS=
prove_by_refinement( ` s' = scs_half_slice_v39 s p q d' mkj /\ s'' = scs_half_slice_v39 s q p d'' mkj /\ (scs_J_v39 s' 0 (scs_k_v39 s' -1))= mkj /\ (~(scs_J_v39 s' 0 (scs_k_v39 s' -1))) /\ vv' = (\i. (vv:num->real^3) (i MOD (scs_k_v39 s')+p MOD (scs_k_v39 s))) /\ is_scs_v39 s /\ scs_diag (scs_k_v39 s) p q /\ d'< #0.9 /\ scs_bm_v39 s p q < &4 /\ (4<scs_k_v39 s ==> scs_bm_v39 s p q <= cstab) ==> is_scs_v39 s'`,
(* {{{ proof *) [ STRIP_TAC THEN MRESA_TAC (GEN_ALL SCS_K_PRIME_LE_GE)[`s:scs_v39`;`p:num`;`q:num`;`d':real`;`scs_J_v39 s' p q`] THEN POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[LET_DEF;LET_END_DEF;] THEN REPLICATE_TAC 5 (POP_ASSUM MP_TAC) THEN ASM_REWRITE_TAC[LET_DEF;LET_END_DEF;scs_half_slice_v39;is_scs_v39;scs_diag;scs_v39_explicit] THEN ABBREV_TAC`k'=(q + 1 + scs_k_v39 s - p MOD scs_k_v39 s) MOD scs_k_v39 s` THEN REPEAT RESA_TAC; REWRITE_TAC[periodic] THEN SET_TAC[] ; REWRITE_TAC[periodic] THEN SET_TAC[] ; REWRITE_TAC[periodic] THEN SET_TAC[] ; REWRITE_TAC[periodic] THEN SET_TAC[] ; REWRITE_TAC[periodic2] THEN REPEAT STRIP_TAC ; MRESAL_TAC MOD_EQ [`i+k':num`;`i:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ (i + k') + p = i+p+k'`] THEN MRESAL_TAC MOD_EQ [`i+p+k':num`;`i+p:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ i + p + k' = (i + p) + k'`] ; MRESAL_TAC MOD_EQ [`j+k':num`;`j:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ (i + k') + p = i+p+k'`] THEN MRESAL_TAC MOD_EQ [`j+p+k':num`;`j+p:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ i + p + k' = (i + p) + k'`] ; REWRITE_TAC[periodic2] THEN REPEAT STRIP_TAC ; MRESAL_TAC MOD_EQ [`i+k':num`;`i:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ (i + k') + p = i+p+k'`] THEN MRESAL_TAC MOD_EQ [`i+p+k':num`;`i+p:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ i + p + k' = (i + p) + k'`]; MRESAL_TAC MOD_EQ [`j+k':num`;`j:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ (i + k') + p = i+p+k'`] THEN MRESAL_TAC MOD_EQ [`j+p+k':num`;`j+p:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ i + p + k' = (i + p) + k'`]; REWRITE_TAC[periodic2] THEN REPEAT STRIP_TAC; MRESAL_TAC MOD_EQ [`i+k':num`;`i:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ (i + k') + p = i+p+k'`] THEN MRESAL_TAC MOD_EQ [`i+p+k':num`;`i+p:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ i + p + k' = (i + p) + k'`]; MRESAL_TAC MOD_EQ [`j+k':num`;`j:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ (i + k') + p = i+p+k'`] THEN MRESAL_TAC MOD_EQ [`j+p+k':num`;`j+p:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ i + p + k' = (i + p) + k'`]; REWRITE_TAC[periodic2] THEN REPEAT STRIP_TAC ; MRESAL_TAC MOD_EQ [`i+k':num`;`i:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ (i + k') + p = i+p+k'`] THEN MRESAL_TAC MOD_EQ [`i+p+k':num`;`i+p:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ i + p + k' = (i + p) + k'`]; MRESAL_TAC MOD_EQ [`j+k':num`;`j:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ (i + k') + p = i+p+k'`] THEN MRESAL_TAC MOD_EQ [`j+p+k':num`;`j+p:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ i + p + k' = (i + p) + k'`] ; REWRITE_TAC[periodic2] THEN REPEAT STRIP_TAC ; MRESAL_TAC MOD_EQ [`i+k':num`;`i:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ (i + k') + p = i+p+k'`] THEN MRESAL_TAC MOD_EQ [`i+p+k':num`;`i+p:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ i + p + k' = (i + p) + k'`]; MRESAL_TAC MOD_EQ [`j+k':num`;`j:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ (i + k') + p = i+p+k'`] THEN MRESAL_TAC MOD_EQ [`j+p+k':num`;`j+p:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ i + p + k' = (i + p) + k'`]; GEN_REWRITE_TAC(LAND_CONV o ONCE_DEPTH_CONV)[SET_RULE`({A,B}={C,D})<=> ({B,A}={C,D}) `] THEN REWRITE_TAC[]; GEN_REWRITE_TAC(LAND_CONV o ONCE_DEPTH_CONV)[SET_RULE`({A,B}={C,D})<=> ({B,A}={C,D}) `] THEN REWRITE_TAC[]; GEN_REWRITE_TAC(LAND_CONV o ONCE_DEPTH_CONV)[SET_RULE`({A,B}={C,D})<=> ({B,A}={C,D}) `] THEN REWRITE_TAC[]; GEN_REWRITE_TAC(LAND_CONV o ONCE_DEPTH_CONV)[SET_RULE`({A,B}={C,D})<=> ({B,A}={C,D}) `] THEN REWRITE_TAC[]; GEN_REWRITE_TAC(LAND_CONV o ONCE_DEPTH_CONV)[SET_RULE`({A,B}={C,D})<=> ({B,A}={C,D}) `] THEN REWRITE_TAC[]; REAL_ARITH_TAC; DISJ_CASES_TAC(SET_RULE`{i MOD k', j MOD k'} = {0, k'-1} \/ ~({i MOD k', j MOD k'} = {0, k'-1})`); ASM_REWRITE_TAC[]; ASM_REWRITE_TAC[] THEN REPLICATE_TAC (17)(REMOVE_ASSUM_TAC) THEN POP_ASSUM(fun th-> MRESA_TAC th[`i MOD k' + p MOD scs_k_v39 s`;`j MOD k' + p MOD scs_k_v39 s`]) THEN REPLICATE_TAC 3 (POP_ASSUM MP_TAC) THEN REAL_ARITH_TAC ; REAL_ARITH_TAC; MP_TAC(ARITH_RULE`3<=k' ==> ~(0=k'-1)`) THEN RESA_TAC THEN DISJ_CASES_TAC(SET_RULE`{i MOD k', i MOD k'} = {0, k'-1} \/ ~({i MOD k', i MOD k'} = {0, k'-1})`); MP_TAC(SET_RULE`{i MOD k', i MOD k'} = {0, k'-1}==> i MOD k'= 0 /\ i MOD k'= k'-1`) THEN RESA_TAC THEN POP_ASSUM MP_TAC THEN RESA_TAC; ASM_REWRITE_TAC[]; DISJ_CASES_TAC(SET_RULE`{i MOD k', j MOD k'} = {0, k'-1} \/ ~({i MOD k', j MOD k'} = {0, k'-1})`); ASM_REWRITE_TAC[] THEN ASM_TAC THEN REWRITE_TAC[periodic2;] THEN REPEAT STRIP_TAC THEN MP_TAC(ARITH_RULE`3<= scs_k_v39 s ==> ~(scs_k_v39 s = 0)`) THEN RESA_TAC THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`scs_am_v39 s p`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th `q:num`) THEN POP_ASSUM(fun th-> ASM_REWRITE_TAC[SYM th]) THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`scs_am_v39 s (q MOD scs_k_v39 s)`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th `p:num`) THEN POP_ASSUM(fun th-> ASM_REWRITE_TAC[SYM th]) THEN MRESAL_TAC DIVISION[`p:num`;`scs_k_v39 s`][ARITH_RULE`~(6=0)`] THEN MRESAL_TAC DIVISION[`q:num`;`scs_k_v39 s`][ARITH_RULE`~(6=0)`] THEN REPLICATE_TAC 23 (POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESA_TAC th[`p MOD scs_k_v39 s`;`q MOD scs_k_v39 s`]) THEN REPLICATE_TAC 25(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESA_TAC th[`p MOD scs_k_v39 s`;`q MOD scs_k_v39 s`]) THEN REPLICATE_TAC 4(POP_ASSUM MP_TAC) THEN REAL_ARITH_TAC; ASM_REWRITE_TAC[] THEN ASM_TAC THEN REWRITE_TAC[periodic2;] THEN REPEAT STRIP_TAC THEN MP_TAC(ARITH_RULE`3<= scs_k_v39 s ==> ~(scs_k_v39 s = 0)`) THEN RESA_TAC THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`scs_a_v39 s (i MOD k' + p MOD scs_k_v39 s)`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th `(j MOD k' + p MOD scs_k_v39 s):num`) THEN POP_ASSUM(fun th-> ASM_REWRITE_TAC[SYM th]) THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`scs_a_v39 s (((j MOD k' + p MOD scs_k_v39 s) MOD scs_k_v39 s))`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th `((i MOD k' + p MOD scs_k_v39 s)):num`) THEN POP_ASSUM(fun th-> ASM_REWRITE_TAC[SYM th]) THEN REPLICATE_TAC (34-15)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MATCH_MP_TAC th) THEN MRESAL_TAC DIVISION[`(i MOD k' + p MOD scs_k_v39 s):num`;`scs_k_v39 s:num`][ARITH_RULE`~(6=0)`] THEN MRESAL_TAC DIVISION[`(j MOD k' + p MOD scs_k_v39 s):num`;`scs_k_v39 s`][ARITH_RULE`~(6=0)`] THEN STRIP_TAC THEN MRESAL_TAC Hdplygy.MOD_EQ_MOD[`i MOD k':num`;`j MOD k':num`;`p MOD scs_k_v39 s`;`scs_k_v39 s`][ADD_SYM] THEN POP_ASSUM MP_TAC THEN MRESA_TAC MOD_LT[`i:num`;`k':num`] THEN MRESA_TAC MOD_LT[`j:num`;`k':num`] THEN MP_TAC(ARITH_RULE`i< k' /\ k'< scs_k_v39 s /\ j<k' ==> i< scs_k_v39 s /\ j< scs_k_v39 s`) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`i:num`;`scs_k_v39 s`] THEN MRESA_TAC MOD_LT[`j:num`;`scs_k_v39 s`] ; DISJ_CASES_TAC(SET_RULE`{i MOD 3, SUC i MOD 3} = {0, 3-1} \/ ~({i MOD 3, SUC i MOD 3} = {0, 3-1})`); ASM_REWRITE_TAC[] ; ASM_REWRITE_TAC[] THEN MRESAL_TAC DIVISION[`i:num`;`k':num`][ARITH_RULE`~(3=0)`] THEN MP_TAC(ARITH_RULE`3<= k' /\ k' <scs_k_v39 s ==> 3< scs_k_v39 s`) THEN RESA_TAC THEN ASM_TAC THEN REWRITE_TAC[periodic2;] THEN REPEAT STRIP_TAC THEN MP_TAC(ARITH_RULE`3<= scs_k_v39 s ==> ~(scs_k_v39 s = 0)`) THEN RESA_TAC THEN MP_TAC(ARITH_RULE`(i ) MOD 3 < 3 ==> (i ) MOD 3 =0 \/ (i ) MOD 3 =1 \/ (i ) MOD 3 =2`) THEN RESA_TAC ; MRESAL_TAC(GEN_ALL IMP_SUC_MOD_EQ)[`i:num`;`0`;`3`][ARITH_RULE`0 MOD 3=0 /\ 1 MOD 3=1/\ 2 MOD 3=2/\ SUC 0=1/\ SUC 1=2 /\ SUC 2=3/\ 3 MOD 3=0/\ ~(3=0)/\ 0+A=A /\ 1+A= SUC A`] THEN REPLICATE_TAC (37-17)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESAL1_TAC th `p MOD scs_k_v39 s` [ARITH_RULE`SUC 0=1/\ SUC 1=2/\ SUC 2=3`;cstab]) THEN POP_ASSUM MP_TAC THEN REAL_ARITH_TAC; MRESAL_TAC(GEN_ALL IMP_SUC_MOD_EQ)[`i:num`;`1`;`3`][ARITH_RULE`0 MOD 3=0 /\ 1 MOD 3=1/\ 2 MOD 3=2/\ SUC 0=1/\ SUC 1=2 /\ SUC 2=3/\ 3 MOD 3=0/\ ~(3=0)/\ 2+A=SUC(1+A) `] THEN REPLICATE_TAC (37-17)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESAL1_TAC th `1+p MOD scs_k_v39 s` [ARITH_RULE`SUC 0=1/\ SUC 1=2/\ SUC 2=3`;cstab]) THEN POP_ASSUM MP_TAC THEN REAL_ARITH_TAC; MRESAL_TAC(GEN_ALL IMP_SUC_MOD_EQ)[`i:num`;`2`;`3`][ARITH_RULE`0 MOD 3=0 /\ 1 MOD 3=1/\ 2 MOD 3=2/\ SUC 0=1/\ SUC 1=2 /\ SUC 2=3/\ 3 MOD 3=0/\ ~(3=0)/\ 2+A=SUC(1+A) `] THEN POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[th;ARITH_RULE`3-1=2`] THEN REPEAT STRIP_TAC) THEN POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[th;ARITH_RULE`3-1=2`] THEN REPEAT STRIP_TAC) THEN REPLICATE_TAC (4) REMOVE_ASSUM_TAC THEN POP_ASSUM MP_TAC THEN SET_TAC[]; DISJ_CASES_TAC(SET_RULE`{i MOD k', SUC i MOD k'} = {0, k'-1} \/ ~({i MOD k', SUC i MOD k'} = {0, k'-1})`); ASM_REWRITE_TAC[] THEN MP_TAC(ARITH_RULE`3<k' /\ k'< scs_k_v39 s ==> 4< scs_k_v39 s`) THEN RESA_TAC THEN REPLICATE_TAC (6) (POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th) THEN RESA_TAC ; ASM_REWRITE_TAC[] THEN MP_TAC(ARITH_RULE`3<= k' /\ k' <scs_k_v39 s ==> 3< scs_k_v39 s/\ ~(k'=0) /\ 1< k'/\ k'-1< k'/\ SUC(k'-1)= k'`) THEN RESA_TAC THEN MRESAL_TAC DIVISION[`i:num`;`k':num`][ARITH_RULE`~(3=0)`] THEN ASM_TAC THEN REWRITE_TAC[periodic2;] THEN REPEAT STRIP_TAC THEN MP_TAC(ARITH_RULE`3<= scs_k_v39 s ==> ~(scs_k_v39 s = 0)`) THEN RESA_TAC THEN REWRITE_TAC[ADD1] THEN MRESA_TAC MOD_ADD_MOD[`i:num`;`1:num`;`k':num`] THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN MRESA_TAC MOD_LT[`1`;`k':num`] THEN MP_TAC(ARITH_RULE`3<k' /\ i MOD k' < k' ==> i MOD k' =k'-1 \/ i MOD k' +1 < k' `) THEN RESA_TAC ; MRESA_TAC MOD_LT[`k'-1`;`k':num`] THEN MRESAL_TAC MOD_MULT[`k':num`;`1`][ARITH_RULE`A* 1=A`] THEN MRESAL_TAC(GEN_ALL IMP_SUC_MOD_EQ)[`i:num`;`k'-1`;`k':num`][ARITH_RULE`0 MOD 3=0 /\ 1 MOD 3=1/\ 2 MOD 3=2/\ SUC 0=1/\ SUC 1=2 /\ SUC 2=3/\ 3 MOD 3=0/\ ~(3=0)/\ 2+A=SUC(1+A) `] THEN POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[th] THEN REPEAT STRIP_TAC) THEN REPLICATE_TAC (2) REMOVE_ASSUM_TAC THEN POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[th] THEN REPEAT STRIP_TAC) THEN REPLICATE_TAC (8) REMOVE_ASSUM_TAC THEN POP_ASSUM MP_TAC THEN SET_TAC[]; MRESAL_TAC MOD_LT[`i MOD k' +1`;`k':num`][ARITH_RULE`(i MOD k' + 1) + p MOD scs_k_v39 s= SUC(i MOD k' + p MOD scs_k_v39 s)`] THEN REPLICATE_TAC (42-17)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MATCH_MP_TAC th) THEN ASM_REWRITE_TAC[]; POP_ASSUM MP_TAC THEN DISJ_CASES_TAC(SET_RULE`{i MOD k', j MOD k'} = {0, k' - 1} \/ ~({i MOD k', j MOD k'} = {0, k' - 1})`) ; ASM_REWRITE_TAC[]; MP_TAC(SET_RULE`{i MOD k', j MOD k'} = {0, k' - 1} ==> (i MOD k'= 0 /\ j MOD k' = k'-1)\/ (i MOD k'= k'-1 /\ j MOD k' = 0)`) THEN RESA_TAC; MP_TAC(ARITH_RULE`3<= k' /\ k' <scs_k_v39 s ==> 3< scs_k_v39 s/\ ~(k'=0) /\ 1< k'/\ k'-1< k'/\ SUC(k'-1)= k'`) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`k'-1`;`k':num`] THEN MRESAL_TAC MOD_MULT[`k':num`;`1`][ARITH_RULE`A* 1=A`] THEN MRESAL_TAC(GEN_ALL IMP_SUC_MOD_EQ)[`j:num`;`k'-1`;`k':num`][ARITH_RULE`0 MOD 3=0 /\ 1 MOD 3=1/\ 2 MOD 3=2/\ SUC 0=1/\ SUC 1=2 /\ SUC 2=3/\ 3 MOD 3=0/\ ~(3=0)/\ 2+A=SUC(1+A) `] ; MP_TAC(ARITH_RULE`3<= k' /\ k' <scs_k_v39 s ==> 3< scs_k_v39 s/\ ~(k'=0) /\ 1< k'/\ k'-1< k'/\ SUC(k'-1)= k'/\ ~(scs_k_v39 s =0)`) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`k'-1`;`k':num`] THEN MRESAL_TAC MOD_MULT[`k':num`;`1`][ARITH_RULE`A* 1=A`] THEN MRESAL_TAC(GEN_ALL IMP_SUC_MOD_EQ)[`i:num`;`k'-1`;`k':num`][ARITH_RULE`0 MOD 3=0 /\ 1 MOD 3=1/\ 2 MOD 3=2/\ SUC 0=1/\ SUC 1=2 /\ SUC 2=3/\ 3 MOD 3=0/\ ~(3=0)/\ 2+A=SUC(1+A) `] ; ASM_REWRITE_TAC[] THEN STRIP_TAC THEN REPLICATE_TAC (31-18)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESAL_TAC th[`(i MOD k' + p MOD scs_k_v39 s)`;`(j MOD k' + p MOD scs_k_v39 s)`][ARITH_RULE`SUC(A+B)= SUC A+B`]) ; MP_TAC(ARITH_RULE`3<= k' /\ k' <scs_k_v39 s ==> 3< scs_k_v39 s/\ ~(k'=0) /\ 1< k'/\ k'-1< k'/\ SUC(k'-1)= k'/\ ~(scs_k_v39 s =0)`) THEN RESA_TAC THEN MRESAL_TAC Hdplygy.MOD_EQ_MOD[`j MOD k':num`;`SUC(i MOD k'):num`;`p MOD scs_k_v39 s`;`scs_k_v39 s`][ADD_SYM] THEN POP_ASSUM MP_TAC THEN MRESAL_TAC DIVISION[`(i):num`;`k':num`][ARITH_RULE`~(6=0)`] THEN MRESAL_TAC DIVISION[`(j):num`;`k':num`][ARITH_RULE`~(6=0)`] THEN MP_TAC(ARITH_RULE`j MOD k' < k' /\ k'< scs_k_v39 s /\ i MOD k' < k' ==> j MOD k' < scs_k_v39 s /\ SUC (i MOD k') < scs_k_v39 s`) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`j MOD k'`;`scs_k_v39 s:num`] THEN MRESA_TAC MOD_LT[`SUC(i MOD k')`;`scs_k_v39 s:num`] THEN RESA_TAC THEN MP_TAC(ARITH_RULE`3<=k' /\ i MOD k' < k' ==> i MOD k' =k'-1 \/ i MOD k' +1 < k' `) THEN RESA_TAC ; POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[th] THEN REPEAT STRIP_TAC) THEN POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[] THEN REPLICATE_TAC (4) REMOVE_ASSUM_TAC THEN POP_ASSUM MP_TAC THEN ARITH_TAC; REWRITE_TAC[ADD1] THEN MRESA_TAC MOD_ADD_MOD[`i:num`;`1:num`;`k':num`] THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN MRESA_TAC MOD_LT[`1`;`k':num`] THEN MRESA_TAC MOD_LT[`i MOD k' + 1`;`k':num`] ; MP_TAC(ARITH_RULE`3<= k' /\ k' <scs_k_v39 s ==> 3< scs_k_v39 s/\ ~(k'=0) /\ 1< k'/\ k'-1< k'/\ SUC(k'-1)= k'/\ ~(scs_k_v39 s =0)`) THEN RESA_TAC THEN MRESAL_TAC Hdplygy.MOD_EQ_MOD[`i MOD k':num`;`SUC(j MOD k'):num`;`p MOD scs_k_v39 s`;`scs_k_v39 s`][ADD_SYM] THEN POP_ASSUM MP_TAC THEN MRESAL_TAC DIVISION[`(i):num`;`k':num`][ARITH_RULE`~(6=0)`] THEN MRESAL_TAC DIVISION[`(j):num`;`k':num`][ARITH_RULE`~(6=0)`] THEN MP_TAC(ARITH_RULE`j MOD k' < k' /\ k'< scs_k_v39 s /\ i MOD k' < k' ==> SUC(j MOD k') < scs_k_v39 s /\ (i MOD k') < scs_k_v39 s`) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`i MOD k'`;`scs_k_v39 s:num`] THEN MRESA_TAC MOD_LT[`SUC(j MOD k')`;`scs_k_v39 s:num`] THEN RESA_TAC THEN MP_TAC(ARITH_RULE`3<=k' /\ j MOD k' < k' ==> j MOD k' =k'-1 \/ j MOD k' +1 < k' `) THEN RESA_TAC ; POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[th] THEN REPEAT STRIP_TAC) THEN POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[] THEN REPLICATE_TAC (5) REMOVE_ASSUM_TAC THEN POP_ASSUM MP_TAC THEN ARITH_TAC; REWRITE_TAC[ADD1] THEN MRESA_TAC MOD_ADD_MOD[`j:num`;`1:num`;`k':num`] THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN MRESA_TAC MOD_LT[`1`;`k':num`] THEN MRESA_TAC MOD_LT[`j MOD k' + 1`;`k':num`] ; POP_ASSUM MP_TAC THEN DISJ_CASES_TAC(SET_RULE`{i MOD k', j MOD k'} = {0, k' - 1} \/ ~({i MOD k', j MOD k'} = {0, k' - 1})`) ; ASM_REWRITE_TAC[] THEN REPLICATE_TAC (33)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th) THEN ASM_REWRITE_TAC[]; ASM_REWRITE_TAC[] THEN STRIP_TAC THEN REPLICATE_TAC (36-24)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESA_TAC th[`(i MOD k' + p MOD scs_k_v39 s)`;`(j MOD k' + p MOD scs_k_v39 s)`]) ; POP_ASSUM MP_TAC THEN DISJ_CASES_TAC(SET_RULE`{i MOD k', j MOD k'} = {0, k' - 1} \/ ~({i MOD k', j MOD k'} = {0, k' - 1})`) ; ASM_REWRITE_TAC[] THEN REPLICATE_TAC (33)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th) THEN ASM_REWRITE_TAC[]; ASM_REWRITE_TAC[] THEN STRIP_TAC THEN REPLICATE_TAC (36-24)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESA_TAC th[`(i MOD k' + p MOD scs_k_v39 s)`;`(j MOD k' + p MOD scs_k_v39 s)`]) ; SUBGOAL_THEN`IMAGE (\x. (x+p MOD scs_k_v39 s )MOD scs_k_v39 s ) {i | i < k' /\ (&2 * h0 < (if {i MOD k', SUC i MOD k'} = {0, k' - 1} then scs_bm_v39 s p q else scs_b_v39 s (i MOD k' + p MOD scs_k_v39 s) (SUC i MOD k' + p MOD scs_k_v39 s)) \/ &2 < (if {i MOD k', SUC i MOD k'} = {0, k' - 1} then scs_am_v39 s p q else scs_a_v39 s (i MOD k' + p MOD scs_k_v39 s) (SUC i MOD k' + p MOD scs_k_v39 s)))} SUBSET {i | i < scs_k_v39 s /\ (&2 * h0 < scs_b_v39 s i (SUC i) \/ &2 < scs_a_v39 s i (SUC i))} UNION {(k'-1 + p MOD scs_k_v39 s) MOD scs_k_v39 s}` ASSUME_TAC; REWRITE_TAC[SUBSET;UNION;IN_ELIM_THM;IN_SING;IMAGE] THEN GEN_TAC THEN RESA_TAC; REMOVE_ASSUM_TAC THEN POP_ASSUM MP_TAC THEN MP_TAC(ARITH_RULE`x'<k'==> x'= k'-1\/ SUC x' < k' `) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`x':num`;`k':num`] THEN MRESA_TAC MOD_LT[`SUC x':num`;`k':num`] THEN DISJ_CASES_TAC(SET_RULE`{x', SUC x'} = {0, k' - 1} \/ ~({x', SUC x'} = {0, k' - 1})`) ; MP_TAC(SET_RULE`{x', SUC x'} = {0, k' - 1} ==> (x' =0 /\ SUC x' = k'-1)\/ (x' =k'-1/\ SUC x' =0)`) THEN RESA_TAC THEN POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[ARITH_RULE`SUC 0= k'-1<=> k'=2`] THEN STRIP_TAC THEN POP_ASSUM (fun th-> REPLICATE_TAC (40-32)(REMOVE_ASSUM_TAC) THEN POP_ASSUM MP_TAC THEN REWRITE_TAC[th]) THEN ARITH_TAC ; ASM_REWRITE_TAC[] THEN STRIP_TAC THEN MATCH_MP_TAC(SET_RULE`A==>A \/ B`) THEN MP_TAC(ARITH_RULE`k' < scs_k_v39 s /\ 3<= k' /\ x'< k' /\ SUC x' < k' ==> ~(scs_k_v39 s=0) /\ x'< scs_k_v39 s/\ SUC x' < scs_k_v39 s/\ 1< scs_k_v39 s`) THEN RESA_TAC THEN MRESAL_TAC DIVISION[`x' + p MOD scs_k_v39 s`;`scs_k_v39 s`][ARITH_RULE`~(6=0)`] THEN MATCH_MP_TAC(SET_RULE`A==>A \/ B`) THEN MRESA_TAC MOD_LT[`x':num`;`scs_k_v39 s`] THEN MRESA_TAC MOD_LT[`SUC x':num`;`scs_k_v39 s`] THEN MRESA_TAC MOD_ADD_MOD[`x':num`;`p:num`;`scs_k_v39 s`] THEN MRESA_TAC MOD_ADD_MOD[`SUC x':num`;`p:num`;`scs_k_v39 s`] THEN REPLICATE_TAC (10)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th) THEN ASM_TAC THEN REWRITE_TAC[periodic2;] THEN REPEAT STRIP_TAC THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`scs_b_v39 s (x' + p MOD scs_k_v39 s)`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th `(SUC x' + p MOD scs_k_v39 s):num`) THEN POP_ASSUM(fun th-> POP_ASSUM MP_TAC THEN REWRITE_TAC[SYM th]) THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`scs_b_v39 s ((SUC x' + p) MOD scs_k_v39 s)`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th `(x' + p MOD scs_k_v39 s):num`) THEN POP_ASSUM(fun th-> ASM_REWRITE_TAC[SYM th]) THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`scs_b_v39 s ((x' + p) MOD scs_k_v39 s)`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th `(SUC ((x' + p) MOD scs_k_v39 s)):num`) THEN POP_ASSUM(fun th-> ASM_REWRITE_TAC[SYM th;ADD1]) THEN MRESA_TAC MOD_LT[`1:num`;`scs_k_v39 s`] THEN MRESA_TAC MOD_ADD_MOD[`(x' + p):num`;`1:num`;`scs_k_v39 s`] THEN STRIP_TAC THEN ASM_REWRITE_TAC[ARITH_RULE`(x' + p) + 1=(x' + 1) + p`] ; REMOVE_ASSUM_TAC THEN POP_ASSUM MP_TAC THEN MP_TAC(ARITH_RULE`x'<k'==> x'= k'-1\/ SUC x' < k' `) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`x':num`;`k':num`] THEN MRESA_TAC MOD_LT[`SUC x':num`;`k':num`] THEN DISJ_CASES_TAC(SET_RULE`{x', SUC x'} = {0, k' - 1} \/ ~({x', SUC x'} = {0, k' - 1})`) ; MP_TAC(SET_RULE`{x', SUC x'} = {0, k' - 1} ==> (x' =0 /\ SUC x' = k'-1)\/ (x' =k'-1/\ SUC x' =0)`) THEN RESA_TAC THEN POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[ARITH_RULE`SUC 0= k'-1<=> k'=2`] THEN STRIP_TAC THEN POP_ASSUM (fun th-> REPLICATE_TAC (40-32)(REMOVE_ASSUM_TAC) THEN POP_ASSUM MP_TAC THEN REWRITE_TAC[th]) THEN ARITH_TAC ; ASM_REWRITE_TAC[] THEN STRIP_TAC THEN MATCH_MP_TAC(SET_RULE`A==>A \/ B`) THEN MP_TAC(ARITH_RULE`k' < scs_k_v39 s /\ 3<= k' /\ x'< k' /\ SUC x' < k' ==> ~(scs_k_v39 s=0) /\ x'< scs_k_v39 s/\ SUC x' < scs_k_v39 s/\ 1< scs_k_v39 s`) THEN RESA_TAC THEN MRESAL_TAC DIVISION[`x' + p MOD scs_k_v39 s`;`scs_k_v39 s`][ARITH_RULE`~(6=0)`] THEN MATCH_MP_TAC(SET_RULE`B==>A \/ B`) THEN MRESA_TAC MOD_LT[`x':num`;`scs_k_v39 s`] THEN MRESA_TAC MOD_LT[`SUC x':num`;`scs_k_v39 s`] THEN MRESA_TAC MOD_ADD_MOD[`x':num`;`p:num`;`scs_k_v39 s`] THEN MRESA_TAC MOD_ADD_MOD[`SUC x':num`;`p:num`;`scs_k_v39 s`] THEN REPLICATE_TAC (10)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th) THEN ASM_TAC THEN REWRITE_TAC[periodic2;] THEN REPEAT STRIP_TAC THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`scs_a_v39 s (x' + p MOD scs_k_v39 s)`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th `(SUC x' + p MOD scs_k_v39 s):num`) THEN POP_ASSUM(fun th-> POP_ASSUM MP_TAC THEN REWRITE_TAC[SYM th]) THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`scs_a_v39 s ((SUC x' + p) MOD scs_k_v39 s)`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th `(x' + p MOD scs_k_v39 s):num`) THEN POP_ASSUM(fun th-> ASM_REWRITE_TAC[SYM th]) THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`scs_a_v39 s ((x' + p) MOD scs_k_v39 s)`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th `(SUC ((x' + p) MOD scs_k_v39 s)):num`) THEN POP_ASSUM(fun th-> ASM_REWRITE_TAC[SYM th;ADD1]) THEN MRESA_TAC MOD_LT[`1:num`;`scs_k_v39 s`] THEN MRESA_TAC MOD_ADD_MOD[`(x' + p):num`;`1:num`;`scs_k_v39 s`] THEN STRIP_TAC THEN ASM_REWRITE_TAC[ARITH_RULE`(x' + p) + 1=(x' + 1) + p`] ; SUBGOAL_THEN`CARD(IMAGE (\x. (x+p MOD scs_k_v39 s )MOD scs_k_v39 s ) {i | i < k' /\ (&2 * h0 < (if {i MOD k', SUC i MOD k'} = {0, k' - 1} then scs_bm_v39 s p q else scs_b_v39 s (i MOD k' + p MOD scs_k_v39 s) (SUC i MOD k' + p MOD scs_k_v39 s)) \/ &2 < (if {i MOD k', SUC i MOD k'} = {0, k' - 1} then scs_am_v39 s p q else scs_a_v39 s (i MOD k' + p MOD scs_k_v39 s) (SUC i MOD k' + p MOD scs_k_v39 s)))}) = CARD {i | i < k' /\ (&2 * h0 < (if {i MOD k', SUC i MOD k'} = {0, k' - 1} then scs_bm_v39 s p q else scs_b_v39 s (i MOD k' + p MOD scs_k_v39 s) (SUC i MOD k' + p MOD scs_k_v39 s)) \/ &2 < (if {i MOD k', SUC i MOD k'} = {0, k' - 1} then scs_am_v39 s p q else scs_a_v39 s (i MOD k' + p MOD scs_k_v39 s) (SUC i MOD k' + p MOD scs_k_v39 s)))}`ASSUME_TAC ; MATCH_MP_TAC CARD_IMAGE_INJ THEN STRIP_TAC; REWRITE_TAC[IN_ELIM_THM] THEN REPEAT STRIP_TAC THEN MP_TAC(ARITH_RULE`3<= k' /\ k' <scs_k_v39 s /\ x<k' /\y< k' ==> 3< scs_k_v39 s/\ ~(k'=0) /\ 1< k'/\ k'-1< k'/\ SUC(k'-1)= k'/\ ~(scs_k_v39 s =0) /\ x< scs_k_v39 s/\ y< scs_k_v39 s`) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`x:num`;`scs_k_v39 s`] THEN MRESA_TAC MOD_LT[`y:num`;`scs_k_v39 s`] THEN MRESAL_TAC Hdplygy.MOD_EQ_MOD[`x:num`;`y:num`;`p MOD scs_k_v39 s`;`scs_k_v39 s`][ADD_SYM] ; MATCH_MP_TAC FINITE_SUBSET THEN EXISTS_TAC`0.. k'` THEN REWRITE_TAC[FINITE_NUMSEG;SUBSET;IN_ELIM_THM;IN_NUMSEG] THEN ARITH_TAC; POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN SUBGOAL_THEN`FINITE ({i | i < scs_k_v39 s /\ (&2 * h0 < scs_b_v39 s i (SUC i) \/ &2 < scs_a_v39 s i (SUC i))} UNION {(k' - 1 + p MOD scs_k_v39 s) MOD scs_k_v39 s})`ASSUME_TAC ; REWRITE_TAC[FINITE_UNION;FINITE_SING] THEN MATCH_MP_TAC FINITE_SUBSET THEN EXISTS_TAC`0.. (scs_k_v39 s)` THEN REWRITE_TAC[FINITE_NUMSEG;SUBSET;IN_ELIM_THM;IN_NUMSEG] THEN ARITH_TAC; MRESA_TAC CARD_SUBSET[`IMAGE (\x. (x+p MOD scs_k_v39 s )MOD scs_k_v39 s ) {i | i < k' /\ (&2 * h0 < (if {i MOD k', SUC i MOD k'} = {0, k' - 1} then scs_bm_v39 s p q else scs_b_v39 s (i MOD k' + p MOD scs_k_v39 s) (SUC i MOD k' + p MOD scs_k_v39 s)) \/ &2 < (if {i MOD k', SUC i MOD k'} = {0, k' - 1} then scs_am_v39 s p q else scs_a_v39 s (i MOD k' + p MOD scs_k_v39 s) (SUC i MOD k' + p MOD scs_k_v39 s)))}`;`{i | i < scs_k_v39 s /\ (&2 * h0 < scs_b_v39 s i (SUC i) \/ &2 < scs_a_v39 s i (SUC i))} UNION {(k'-1 + p MOD scs_k_v39 s) MOD scs_k_v39 s}`] THEN SUBGOAL_THEN`FINITE ({i | i < scs_k_v39 s /\ (&2 * h0 < scs_b_v39 s i (SUC i) \/ &2 < scs_a_v39 s i (SUC i))})`ASSUME_TAC ; REWRITE_TAC[FINITE_UNION;FINITE_SING] THEN MATCH_MP_TAC FINITE_SUBSET THEN EXISTS_TAC`0.. (scs_k_v39 s)` THEN REWRITE_TAC[FINITE_NUMSEG;SUBSET;IN_ELIM_THM;IN_NUMSEG] THEN ARITH_TAC; MRESAL_TAC CARD_UNION_LE[`{i | i < scs_k_v39 s /\ (&2 * h0 < scs_b_v39 s i (SUC i) \/ &2 < scs_a_v39 s i (SUC i))}`; `{(k' - 1 + p MOD scs_k_v39 s) MOD scs_k_v39 s}`][FINITE_SING;Geomdetail.CARD_SING] THEN POP_ASSUM MP_TAC THEN REMOVE_ASSUM_TAC THEN POP_ASSUM MP_TAC THEN REMOVE_ASSUM_TAC THEN REMOVE_ASSUM_TAC THEN POP_ASSUM MP_TAC THEN REPLICATE_TAC (8) REMOVE_ASSUM_TAC THEN REPEAT STRIP_TAC THEN ABBREV_TAC`a= CARD ({i | i < scs_k_v39 s /\ (&2 * h0 < scs_b_v39 s i (SUC i) \/ &2 < scs_a_v39 s i (SUC i))} UNION {(k' - 1 + p MOD scs_k_v39 s) MOD scs_k_v39 s})` THEN ABBREV_TAC`b=CARD {i | i < scs_k_v39 s /\ (&2 * h0 < scs_b_v39 s i (SUC i) \/ &2 < scs_a_v39 s i (SUC i))}` THEN ABBREV_TAC`c=CARD (IMAGE (\x. (x + p MOD scs_k_v39 s) MOD scs_k_v39 s) {i | i < k' /\ (&2 * h0 < (if {i MOD k', SUC i MOD k'} = {0, k' - 1} then scs_bm_v39 s p q else scs_b_v39 s (i MOD k' + p MOD scs_k_v39 s) (SUC i MOD k' + p MOD scs_k_v39 s)) \/ &2 < (if {i MOD k', SUC i MOD k'} = {0, k' - 1} then scs_am_v39 s p q else scs_a_v39 s (i MOD k' + p MOD scs_k_v39 s) (SUC i MOD k' + p MOD scs_k_v39 s)))})` THEN MP_TAC(ARITH_RULE`c<=a /\ a<= b+1 /\ k'< scs_k_v39 s/\ b + scs_k_v39 s <= 6 ==> c+k' <=6`) THEN RESA_TAC;]);;
let SCS_HALF_SLICE_IS_SCS_4=
prove_by_refinement(` s' = scs_half_slice_v39 s p q d' mkj /\ s'' = scs_half_slice_v39 s q p d'' mkj /\ (scs_J_v39 s' 0 (scs_k_v39 s' -1))= mkj /\ (~(scs_J_v39 s' 0 (scs_k_v39 s' -1))) /\ vv' = (\i. (vv:num->real^3) (i MOD (scs_k_v39 s')+p MOD (scs_k_v39 s))) /\ is_scs_v39 s /\ scs_diag (scs_k_v39 s) p q /\ d'< #0.9 /\ scs_bm_v39 s p q < &4 /\ scs_k_v39 s =4 ==> is_scs_v39 s'`,
[STRIP_TAC THEN MRESA_TAC (GEN_ALL SCS_K_PRIME_LE_GE)[`s:scs_v39`;`p:num`;`q:num`;`d':real`;`scs_J_v39 s' p q`] THEN POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[LET_DEF;LET_END_DEF;] THEN REPLICATE_TAC 5 (POP_ASSUM MP_TAC) THEN ASM_REWRITE_TAC[LET_DEF;LET_END_DEF;scs_half_slice_v39;is_scs_v39;scs_diag;scs_v39_explicit] THEN ABBREV_TAC`k'=(q + 1 + scs_k_v39 s - p MOD scs_k_v39 s) MOD scs_k_v39 s` THEN REPEAT RESA_TAC; REWRITE_TAC[periodic] THEN SET_TAC[] ; REWRITE_TAC[periodic] THEN SET_TAC[] ; REWRITE_TAC[periodic] THEN SET_TAC[] ; REWRITE_TAC[periodic] THEN SET_TAC[] ; REWRITE_TAC[periodic2] THEN REPEAT STRIP_TAC ; MRESAL_TAC MOD_EQ [`i+k':num`;`i:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ (i + k') + p = i+p+k'`] THEN MRESAL_TAC MOD_EQ [`i+p+k':num`;`i+p:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ i + p + k' = (i + p) + k'`] ; MRESAL_TAC MOD_EQ [`j+k':num`;`j:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ (i + k') + p = i+p+k'`] THEN MRESAL_TAC MOD_EQ [`j+p+k':num`;`j+p:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ i + p + k' = (i + p) + k'`] ; REWRITE_TAC[periodic2] THEN REPEAT STRIP_TAC ; MRESAL_TAC MOD_EQ [`i+k':num`;`i:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ (i + k') + p = i+p+k'`] THEN MRESAL_TAC MOD_EQ [`i+p+k':num`;`i+p:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ i + p + k' = (i + p) + k'`]; MRESAL_TAC MOD_EQ [`j+k':num`;`j:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ (i + k') + p = i+p+k'`] THEN MRESAL_TAC MOD_EQ [`j+p+k':num`;`j+p:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ i + p + k' = (i + p) + k'`]; REWRITE_TAC[periodic2] THEN REPEAT STRIP_TAC; MRESAL_TAC MOD_EQ [`i+k':num`;`i:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ (i + k') + p = i+p+k'`] THEN MRESAL_TAC MOD_EQ [`i+p+k':num`;`i+p:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ i + p + k' = (i + p) + k'`]; MRESAL_TAC MOD_EQ [`j+k':num`;`j:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ (i + k') + p = i+p+k'`] THEN MRESAL_TAC MOD_EQ [`j+p+k':num`;`j+p:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ i + p + k' = (i + p) + k'`]; REWRITE_TAC[periodic2] THEN REPEAT STRIP_TAC ; MRESAL_TAC MOD_EQ [`i+k':num`;`i:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ (i + k') + p = i+p+k'`] THEN MRESAL_TAC MOD_EQ [`i+p+k':num`;`i+p:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ i + p + k' = (i + p) + k'`]; MRESAL_TAC MOD_EQ [`j+k':num`;`j:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ (i + k') + p = i+p+k'`] THEN MRESAL_TAC MOD_EQ [`j+p+k':num`;`j+p:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ i + p + k' = (i + p) + k'`] ; REWRITE_TAC[periodic2] THEN REPEAT STRIP_TAC ; MRESAL_TAC MOD_EQ [`i+k':num`;`i:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ (i + k') + p = i+p+k'`] THEN MRESAL_TAC MOD_EQ [`i+p+k':num`;`i+p:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ i + p + k' = (i + p) + k'`]; MRESAL_TAC MOD_EQ [`j+k':num`;`j:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ (i + k') + p = i+p+k'`] THEN MRESAL_TAC MOD_EQ [`j+p+k':num`;`j+p:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ i + p + k' = (i + p) + k'`]; GEN_REWRITE_TAC(LAND_CONV o ONCE_DEPTH_CONV)[SET_RULE`({A,B}={C,D})<=> ({B,A}={C,D}) `] THEN REWRITE_TAC[]; GEN_REWRITE_TAC(LAND_CONV o ONCE_DEPTH_CONV)[SET_RULE`({A,B}={C,D})<=> ({B,A}={C,D}) `] THEN REWRITE_TAC[]; GEN_REWRITE_TAC(LAND_CONV o ONCE_DEPTH_CONV)[SET_RULE`({A,B}={C,D})<=> ({B,A}={C,D}) `] THEN REWRITE_TAC[]; GEN_REWRITE_TAC(LAND_CONV o ONCE_DEPTH_CONV)[SET_RULE`({A,B}={C,D})<=> ({B,A}={C,D}) `] THEN REWRITE_TAC[]; GEN_REWRITE_TAC(LAND_CONV o ONCE_DEPTH_CONV)[SET_RULE`({A,B}={C,D})<=> ({B,A}={C,D}) `] THEN REWRITE_TAC[]; REAL_ARITH_TAC; DISJ_CASES_TAC(SET_RULE`{i MOD k', j MOD k'} = {0, k'-1} \/ ~({i MOD k', j MOD k'} = {0, k'-1})`); ASM_REWRITE_TAC[]; ASM_REWRITE_TAC[] THEN REPLICATE_TAC (17)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT DISCH_TAC THEN MRESA_TAC th[`i MOD k' + p MOD scs_k_v39 s`;`j MOD k' + p MOD scs_k_v39 s`]) THEN REPLICATE_TAC 3 (POP_ASSUM MP_TAC) THEN REAL_ARITH_TAC; REAL_ARITH_TAC; MP_TAC(ARITH_RULE`3<=k' ==> ~(0=k'-1)`) THEN RESA_TAC THEN DISJ_CASES_TAC(SET_RULE`{i MOD k', i MOD k'} = {0, k'-1} \/ ~({i MOD k', i MOD k'} = {0, k'-1})`); MP_TAC(SET_RULE`{i MOD k', i MOD k'} = {0, k'-1}==> i MOD k'= 0 /\ i MOD k'= k'-1`) THEN RESA_TAC THEN POP_ASSUM MP_TAC THEN RESA_TAC; ASM_REWRITE_TAC[]; DISJ_CASES_TAC(SET_RULE`{i MOD k', j MOD k'} = {0, k'-1} \/ ~({i MOD k', j MOD k'} = {0, k'-1})`); ASM_REWRITE_TAC[] THEN ASM_TAC THEN REWRITE_TAC[periodic2;] THEN REPEAT STRIP_TAC THEN MP_TAC(ARITH_RULE`3<= scs_k_v39 s ==> ~(scs_k_v39 s = 0)`) THEN RESA_TAC THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`scs_am_v39 s p`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th `q:num`) THEN POP_ASSUM(fun th-> ASM_REWRITE_TAC[SYM th]) THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`scs_am_v39 s (q MOD scs_k_v39 s)`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th `p:num`) THEN POP_ASSUM(fun th-> ASM_REWRITE_TAC[SYM th]) THEN MRESAL_TAC DIVISION[`p:num`;`scs_k_v39 s`][ARITH_RULE`~(6=0)`] THEN MRESAL_TAC DIVISION[`q:num`;`scs_k_v39 s`][ARITH_RULE`~(6=0)`] THEN REPLICATE_TAC 23 (POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESA_TAC th[`p MOD scs_k_v39 s`;`q MOD scs_k_v39 s`]) THEN REPLICATE_TAC 25(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESA_TAC th[`p MOD scs_k_v39 s`;`q MOD scs_k_v39 s`]) THEN REPLICATE_TAC 4(POP_ASSUM MP_TAC) THEN REAL_ARITH_TAC; ASM_REWRITE_TAC[] THEN ASM_TAC THEN REWRITE_TAC[periodic2;] THEN REPEAT STRIP_TAC THEN MP_TAC(ARITH_RULE`3<= scs_k_v39 s ==> ~(scs_k_v39 s = 0)`) THEN RESA_TAC THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`scs_a_v39 s (i MOD k' + p MOD scs_k_v39 s)`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th `(j MOD k' + p MOD scs_k_v39 s):num`) THEN POP_ASSUM(fun th-> ASM_REWRITE_TAC[SYM th]) THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`scs_a_v39 s (((j MOD k' + p MOD scs_k_v39 s) MOD scs_k_v39 s))`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th `((i MOD k' + p MOD scs_k_v39 s)):num`) THEN POP_ASSUM(fun th-> ASM_REWRITE_TAC[SYM th]) THEN REPLICATE_TAC (34-15)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MATCH_MP_TAC th) THEN MRESAL_TAC DIVISION[`(i MOD k' + p MOD scs_k_v39 s):num`;`scs_k_v39 s:num`][ARITH_RULE`~(6=0)`] THEN MRESAL_TAC DIVISION[`(j MOD k' + p MOD scs_k_v39 s):num`;`scs_k_v39 s`][ARITH_RULE`~(6=0)`] THEN STRIP_TAC THEN MRESAL_TAC Hdplygy.MOD_EQ_MOD[`i MOD k':num`;`j MOD k':num`;`p MOD scs_k_v39 s`;`scs_k_v39 s`][ADD_SYM] THEN POP_ASSUM MP_TAC THEN MRESA_TAC MOD_LT[`i:num`;`k':num`] THEN MRESA_TAC MOD_LT[`j:num`;`k':num`] THEN MP_TAC(ARITH_RULE`i< k' /\ k'< scs_k_v39 s /\ j<k' ==> i< scs_k_v39 s /\ j< scs_k_v39 s`) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`i:num`;`scs_k_v39 s`] THEN MRESA_TAC MOD_LT[`j:num`;`scs_k_v39 s`] ; DISJ_CASES_TAC(SET_RULE`{i MOD 3, SUC i MOD 3} = {0, 3-1} \/ ~({i MOD 3, SUC i MOD 3} = {0, 3-1})`); ASM_REWRITE_TAC[] ; ASM_REWRITE_TAC[] THEN MRESAL_TAC DIVISION[`i:num`;`k':num`][ARITH_RULE`~(3=0)`] THEN ASM_TAC THEN REWRITE_TAC[periodic2;] THEN REPEAT STRIP_TAC THEN MP_TAC(ARITH_RULE`3<= scs_k_v39 s ==> ~(scs_k_v39 s = 0)`) THEN RESA_TAC THEN MP_TAC(ARITH_RULE`(i ) MOD 3 < 3 ==> (i ) MOD 3 =0 \/ (i ) MOD 3 =1 \/ (i ) MOD 3 =2`) THEN RESA_TAC ; MRESAL_TAC(GEN_ALL IMP_SUC_MOD_EQ)[`i:num`;`0`;`3`][ARITH_RULE`0 MOD 3=0 /\ 1 MOD 3=1/\ 2 MOD 3=2/\ SUC 0=1/\ SUC 1=2 /\ SUC 2=3/\ 3 MOD 3=0/\ ~(3=0)/\ 0+A=A /\ 1+A= SUC A`] THEN REPLICATE_TAC (41-22)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESAL1_TAC th `p MOD scs_k_v39 s` [ARITH_RULE`SUC 0=1/\ SUC 1=2/\ SUC 2=3/\ 3<4`;cstab]) THEN POP_ASSUM MP_TAC THEN REAL_ARITH_TAC; MRESAL_TAC(GEN_ALL IMP_SUC_MOD_EQ)[`i:num`;`1`;`3`][ARITH_RULE`0 MOD 3=0 /\ 1 MOD 3=1/\ 2 MOD 3=2/\ SUC 0=1/\ SUC 1=2 /\ SUC 2=3/\ 3 MOD 3=0/\ ~(3=0)/\ 2+A=SUC(1+A) `] THEN REPLICATE_TAC (41-22)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESAL1_TAC th `1+p MOD scs_k_v39 s` [ARITH_RULE`SUC 0=1/\ SUC 1=2/\ SUC 2=3/\3<4`;cstab]) THEN POP_ASSUM MP_TAC THEN REAL_ARITH_TAC; MRESAL_TAC(GEN_ALL IMP_SUC_MOD_EQ)[`i:num`;`2`;`3`][ARITH_RULE`0 MOD 3=0 /\ 1 MOD 3=1/\ 2 MOD 3=2/\ SUC 0=1/\ SUC 1=2 /\ SUC 2=3/\ 3 MOD 3=0/\ ~(3=0)/\ 2+A=SUC(1+A) `] THEN POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[th;ARITH_RULE`3-1=2`] THEN REPEAT STRIP_TAC) THEN POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[th;ARITH_RULE`3-1=2`] THEN REPEAT STRIP_TAC) THEN REPLICATE_TAC (3) REMOVE_ASSUM_TAC THEN POP_ASSUM MP_TAC THEN SET_TAC[]; POP_ASSUM MP_TAC THEN POP_ASSUM MP_TAC THEN ARITH_TAC ; POP_ASSUM MP_TAC THEN DISJ_CASES_TAC(SET_RULE`{i MOD k', j MOD k'} = {0, k' - 1} \/ ~({i MOD k', j MOD k'} = {0, k' - 1})`) ; ASM_REWRITE_TAC[]; MP_TAC(SET_RULE`{i MOD k', j MOD k'} = {0, k' - 1} ==> (i MOD k'= 0 /\ j MOD k' = k'-1)\/ (i MOD k'= k'-1 /\ j MOD k' = 0)`) THEN RESA_TAC; MP_TAC(ARITH_RULE`3<= k' /\ k' <scs_k_v39 s ==> 3< scs_k_v39 s/\ ~(k'=0) /\ 1< k'/\ k'-1< k'/\ SUC(k'-1)= k'`) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`k'-1`;`k':num`] THEN MRESAL_TAC MOD_MULT[`k':num`;`1`][ARITH_RULE`A* 1=A`] THEN MRESAL_TAC(GEN_ALL IMP_SUC_MOD_EQ)[`j:num`;`k'-1`;`k':num`][ARITH_RULE`0 MOD 3=0 /\ 1 MOD 3=1/\ 2 MOD 3=2/\ SUC 0=1/\ SUC 1=2 /\ SUC 2=3/\ 3 MOD 3=0/\ ~(3=0)/\ 2+A=SUC(1+A) `] ; MP_TAC(ARITH_RULE`3<= k' /\ k' <scs_k_v39 s ==> 3< scs_k_v39 s/\ ~(k'=0) /\ 1< k'/\ k'-1< k'/\ SUC(k'-1)= k'/\ ~(scs_k_v39 s =0)`) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`k'-1`;`k':num`] THEN MRESAL_TAC MOD_MULT[`k':num`;`1`][ARITH_RULE`A* 1=A`] THEN MRESAL_TAC(GEN_ALL IMP_SUC_MOD_EQ)[`i:num`;`k'-1`;`k':num`][ARITH_RULE`0 MOD 3=0 /\ 1 MOD 3=1/\ 2 MOD 3=2/\ SUC 0=1/\ SUC 1=2 /\ SUC 2=3/\ 3 MOD 3=0/\ ~(3=0)/\ 2+A=SUC(1+A) `] ; ASM_REWRITE_TAC[] THEN STRIP_TAC THEN REPLICATE_TAC (36-23)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESAL_TAC th[`(i MOD k' + p MOD scs_k_v39 s)`;`(j MOD k' + p MOD scs_k_v39 s)`][ARITH_RULE`SUC(A+B)= SUC A+B`]) ; MP_TAC(ARITH_RULE`3<= k' /\ k' <scs_k_v39 s ==> 3< scs_k_v39 s/\ ~(k'=0) /\ 1< k'/\ k'-1< k'/\ SUC(k'-1)= k'/\ ~(scs_k_v39 s =0)`) THEN RESA_TAC THEN MRESAL_TAC Hdplygy.MOD_EQ_MOD[`j MOD k':num`;`SUC(i MOD k'):num`;`p MOD scs_k_v39 s`;`scs_k_v39 s`][ADD_SYM] THEN POP_ASSUM MP_TAC THEN MRESAL_TAC DIVISION[`(i):num`;`k':num`][ARITH_RULE`~(6=0)`] THEN MRESAL_TAC DIVISION[`(j):num`;`k':num`][ARITH_RULE`~(6=0)`] THEN MP_TAC(ARITH_RULE`j MOD k' < k' /\ k'< scs_k_v39 s /\ i MOD k' < k' ==> j MOD k' < scs_k_v39 s /\ SUC (i MOD k') < scs_k_v39 s`) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`j MOD k'`;`scs_k_v39 s:num`] THEN MRESA_TAC MOD_LT[`SUC(i MOD k')`;`scs_k_v39 s:num`] THEN RESA_TAC THEN MP_TAC(ARITH_RULE`3<=k' /\ i MOD k' < k' ==> i MOD k' =k'-1 \/ i MOD k' +1 < k' `) THEN RESA_TAC ; POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[th] THEN REPEAT STRIP_TAC) THEN POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[] THEN REPLICATE_TAC (4) REMOVE_ASSUM_TAC THEN POP_ASSUM MP_TAC THEN ARITH_TAC; REWRITE_TAC[ADD1] THEN MRESA_TAC MOD_ADD_MOD[`i:num`;`1:num`;`k':num`] THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN MRESA_TAC MOD_LT[`1`;`k':num`] THEN MRESA_TAC MOD_LT[`i MOD k' + 1`;`k':num`] ; MP_TAC(ARITH_RULE`3<= k' /\ k' <scs_k_v39 s ==> 3< scs_k_v39 s/\ ~(k'=0) /\ 1< k'/\ k'-1< k'/\ SUC(k'-1)= k'/\ ~(scs_k_v39 s =0)`) THEN RESA_TAC THEN MRESAL_TAC Hdplygy.MOD_EQ_MOD[`i MOD k':num`;`SUC(j MOD k'):num`;`p MOD scs_k_v39 s`;`scs_k_v39 s`][ADD_SYM] THEN POP_ASSUM MP_TAC THEN MRESAL_TAC DIVISION[`(i):num`;`k':num`][ARITH_RULE`~(6=0)`] THEN MRESAL_TAC DIVISION[`(j):num`;`k':num`][ARITH_RULE`~(6=0)`] THEN MP_TAC(ARITH_RULE`j MOD k' < k' /\ k'< scs_k_v39 s /\ i MOD k' < k' ==> SUC(j MOD k') < scs_k_v39 s /\ (i MOD k') < scs_k_v39 s`) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`i MOD k'`;`scs_k_v39 s:num`] THEN MRESA_TAC MOD_LT[`SUC(j MOD k')`;`scs_k_v39 s:num`] THEN RESA_TAC THEN MP_TAC(ARITH_RULE`3<=k' /\ j MOD k' < k' ==> j MOD k' =k'-1 \/ j MOD k' +1 < k' `) THEN RESA_TAC ; POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[th] THEN REPEAT STRIP_TAC) THEN POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[] THEN REPLICATE_TAC (5) REMOVE_ASSUM_TAC THEN POP_ASSUM MP_TAC THEN ARITH_TAC; REWRITE_TAC[ADD1] THEN MRESA_TAC MOD_ADD_MOD[`j:num`;`1:num`;`k':num`] THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN MRESA_TAC MOD_LT[`1`;`k':num`] THEN MRESA_TAC MOD_LT[`j MOD k' + 1`;`k':num`] ; POP_ASSUM MP_TAC THEN DISJ_CASES_TAC(SET_RULE`{i MOD k', j MOD k'} = {0, k' - 1} \/ ~({i MOD k', j MOD k'} = {0, k' - 1})`) ; ASM_REWRITE_TAC[] THEN REPLICATE_TAC (33)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th) THEN ASM_REWRITE_TAC[]; ASM_REWRITE_TAC[] THEN STRIP_TAC THEN REPLICATE_TAC (36-24)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESA_TAC th[`(i MOD k' + p MOD scs_k_v39 s)`;`(j MOD k' + p MOD scs_k_v39 s)`]) ; POP_ASSUM MP_TAC THEN DISJ_CASES_TAC(SET_RULE`{i MOD k', j MOD k'} = {0, k' - 1} \/ ~({i MOD k', j MOD k'} = {0, k' - 1})`) ; ASM_REWRITE_TAC[] THEN REPLICATE_TAC (33)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th) THEN ASM_REWRITE_TAC[]; ASM_REWRITE_TAC[] THEN STRIP_TAC THEN REPLICATE_TAC (36-24)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESA_TAC th[`(i MOD k' + p MOD scs_k_v39 s)`;`(j MOD k' + p MOD scs_k_v39 s)`]) ; SUBGOAL_THEN`IMAGE (\x. (x+p MOD scs_k_v39 s )MOD scs_k_v39 s ) {i | i < k' /\ (&2 * h0 < (if {i MOD k', SUC i MOD k'} = {0, k' - 1} then scs_bm_v39 s p q else scs_b_v39 s (i MOD k' + p MOD scs_k_v39 s) (SUC i MOD k' + p MOD scs_k_v39 s)) \/ &2 < (if {i MOD k', SUC i MOD k'} = {0, k' - 1} then scs_am_v39 s p q else scs_a_v39 s (i MOD k' + p MOD scs_k_v39 s) (SUC i MOD k' + p MOD scs_k_v39 s)))} SUBSET {i | i < scs_k_v39 s /\ (&2 * h0 < scs_b_v39 s i (SUC i) \/ &2 < scs_a_v39 s i (SUC i))} UNION {(k'-1 + p MOD scs_k_v39 s) MOD scs_k_v39 s}` ASSUME_TAC; REWRITE_TAC[SUBSET;UNION;IN_ELIM_THM;IN_SING;IMAGE] THEN GEN_TAC THEN RESA_TAC; REMOVE_ASSUM_TAC THEN POP_ASSUM MP_TAC THEN MP_TAC(ARITH_RULE`x'<k'==> x'= k'-1\/ SUC x' < k' `) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`x':num`;`k':num`] THEN MRESA_TAC MOD_LT[`SUC x':num`;`k':num`] THEN DISJ_CASES_TAC(SET_RULE`{x', SUC x'} = {0, k' - 1} \/ ~({x', SUC x'} = {0, k' - 1})`) ; MP_TAC(SET_RULE`{x', SUC x'} = {0, k' - 1} ==> (x' =0 /\ SUC x' = k'-1)\/ (x' =k'-1/\ SUC x' =0)`) THEN RESA_TAC THEN POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[ARITH_RULE`SUC 0= k'-1<=> k'=2`] THEN STRIP_TAC THEN POP_ASSUM (fun th-> REPLICATE_TAC (40-32)(REMOVE_ASSUM_TAC) THEN POP_ASSUM MP_TAC THEN REWRITE_TAC[th]) THEN ARITH_TAC ; ASM_REWRITE_TAC[] THEN STRIP_TAC THEN MATCH_MP_TAC(SET_RULE`A==>A \/ B`) THEN MP_TAC(ARITH_RULE`k' < scs_k_v39 s /\ 3<= k' /\ x'< k' /\ SUC x' < k' ==> ~(scs_k_v39 s=0) /\ x'< scs_k_v39 s/\ SUC x' < scs_k_v39 s/\ 1< scs_k_v39 s`) THEN RESA_TAC THEN MRESAL_TAC DIVISION[`x' + p MOD scs_k_v39 s`;`scs_k_v39 s`][ARITH_RULE`~(6=0)`] THEN MATCH_MP_TAC(SET_RULE`A==>A \/ B`) THEN MRESA_TAC MOD_LT[`x':num`;`scs_k_v39 s`] THEN MRESA_TAC MOD_LT[`SUC x':num`;`scs_k_v39 s`] THEN MRESA_TAC MOD_ADD_MOD[`x':num`;`p:num`;`scs_k_v39 s`] THEN MRESA_TAC MOD_ADD_MOD[`SUC x':num`;`p:num`;`scs_k_v39 s`] THEN REPLICATE_TAC (10)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th) THEN ASM_TAC THEN REWRITE_TAC[periodic2;] THEN REPEAT STRIP_TAC THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`scs_b_v39 s (x' + p MOD scs_k_v39 s)`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th `(SUC x' + p MOD scs_k_v39 s):num`) THEN POP_ASSUM(fun th-> POP_ASSUM MP_TAC THEN REWRITE_TAC[SYM th]) THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`scs_b_v39 s ((SUC x' + p) MOD scs_k_v39 s)`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th `(x' + p MOD scs_k_v39 s):num`) THEN POP_ASSUM(fun th-> ASM_REWRITE_TAC[SYM th]) THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`scs_b_v39 s ((x' + p) MOD scs_k_v39 s)`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th `(SUC ((x' + p) MOD scs_k_v39 s)):num`) THEN POP_ASSUM(fun th-> ASM_REWRITE_TAC[SYM th;ADD1]) THEN MRESA_TAC MOD_LT[`1:num`;`scs_k_v39 s`] THEN MRESA_TAC MOD_ADD_MOD[`(x' + p):num`;`1:num`;`scs_k_v39 s`] THEN STRIP_TAC THEN ASM_REWRITE_TAC[ARITH_RULE`(x' + p) + 1=(x' + 1) + p`] ; REMOVE_ASSUM_TAC THEN POP_ASSUM MP_TAC THEN MP_TAC(ARITH_RULE`x'<k'==> x'= k'-1\/ SUC x' < k' `) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`x':num`;`k':num`] THEN MRESA_TAC MOD_LT[`SUC x':num`;`k':num`] THEN DISJ_CASES_TAC(SET_RULE`{x', SUC x'} = {0, k' - 1} \/ ~({x', SUC x'} = {0, k' - 1})`) ; MP_TAC(SET_RULE`{x', SUC x'} = {0, k' - 1} ==> (x' =0 /\ SUC x' = k'-1)\/ (x' =k'-1/\ SUC x' =0)`) THEN RESA_TAC THEN POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[ARITH_RULE`SUC 0= k'-1<=> k'=2`] THEN STRIP_TAC THEN POP_ASSUM (fun th-> REPLICATE_TAC (40-32)(REMOVE_ASSUM_TAC) THEN POP_ASSUM MP_TAC THEN REWRITE_TAC[th]) THEN ARITH_TAC ; ASM_REWRITE_TAC[] THEN STRIP_TAC THEN MATCH_MP_TAC(SET_RULE`A==>A \/ B`) THEN MP_TAC(ARITH_RULE`k' < scs_k_v39 s /\ 3<= k' /\ x'< k' /\ SUC x' < k' ==> ~(scs_k_v39 s=0) /\ x'< scs_k_v39 s/\ SUC x' < scs_k_v39 s/\ 1< scs_k_v39 s`) THEN RESA_TAC THEN MRESAL_TAC DIVISION[`x' + p MOD scs_k_v39 s`;`scs_k_v39 s`][ARITH_RULE`~(6=0)`] THEN MATCH_MP_TAC(SET_RULE`B==>A \/ B`) THEN MRESA_TAC MOD_LT[`x':num`;`scs_k_v39 s`] THEN MRESA_TAC MOD_LT[`SUC x':num`;`scs_k_v39 s`] THEN MRESA_TAC MOD_ADD_MOD[`x':num`;`p:num`;`scs_k_v39 s`] THEN MRESA_TAC MOD_ADD_MOD[`SUC x':num`;`p:num`;`scs_k_v39 s`] THEN REPLICATE_TAC (10)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th) THEN ASM_TAC THEN REWRITE_TAC[periodic2;] THEN REPEAT STRIP_TAC THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`scs_a_v39 s (x' + p MOD scs_k_v39 s)`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th `(SUC x' + p MOD scs_k_v39 s):num`) THEN POP_ASSUM(fun th-> POP_ASSUM MP_TAC THEN REWRITE_TAC[SYM th]) THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`scs_a_v39 s ((SUC x' + p) MOD scs_k_v39 s)`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th `(x' + p MOD scs_k_v39 s):num`) THEN POP_ASSUM(fun th-> ASM_REWRITE_TAC[SYM th]) THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`scs_a_v39 s ((x' + p) MOD scs_k_v39 s)`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th `(SUC ((x' + p) MOD scs_k_v39 s)):num`) THEN POP_ASSUM(fun th-> ASM_REWRITE_TAC[SYM th;ADD1]) THEN MRESA_TAC MOD_LT[`1:num`;`scs_k_v39 s`] THEN MRESA_TAC MOD_ADD_MOD[`(x' + p):num`;`1:num`;`scs_k_v39 s`] THEN STRIP_TAC THEN ASM_REWRITE_TAC[ARITH_RULE`(x' + p) + 1=(x' + 1) + p`] ; SUBGOAL_THEN`CARD(IMAGE (\x. (x+p MOD scs_k_v39 s )MOD scs_k_v39 s ) {i | i < k' /\ (&2 * h0 < (if {i MOD k', SUC i MOD k'} = {0, k' - 1} then scs_bm_v39 s p q else scs_b_v39 s (i MOD k' + p MOD scs_k_v39 s) (SUC i MOD k' + p MOD scs_k_v39 s)) \/ &2 < (if {i MOD k', SUC i MOD k'} = {0, k' - 1} then scs_am_v39 s p q else scs_a_v39 s (i MOD k' + p MOD scs_k_v39 s) (SUC i MOD k' + p MOD scs_k_v39 s)))}) = CARD {i | i < k' /\ (&2 * h0 < (if {i MOD k', SUC i MOD k'} = {0, k' - 1} then scs_bm_v39 s p q else scs_b_v39 s (i MOD k' + p MOD scs_k_v39 s) (SUC i MOD k' + p MOD scs_k_v39 s)) \/ &2 < (if {i MOD k', SUC i MOD k'} = {0, k' - 1} then scs_am_v39 s p q else scs_a_v39 s (i MOD k' + p MOD scs_k_v39 s) (SUC i MOD k' + p MOD scs_k_v39 s)))}`ASSUME_TAC ; MATCH_MP_TAC CARD_IMAGE_INJ THEN STRIP_TAC; ASM_REWRITE_TAC[IN_ELIM_THM] THEN REPEAT STRIP_TAC THEN MP_TAC(ARITH_RULE`3<= k' /\ k' <scs_k_v39 s /\ x<k' /\y< k' ==> 3< scs_k_v39 s/\ ~(k'=0) /\ 1< k'/\ k'-1< k'/\ SUC(k'-1)= k'/\ ~(scs_k_v39 s =0) /\ x< scs_k_v39 s/\ y< scs_k_v39 s`) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`x:num`;`scs_k_v39 s`] THEN MRESA_TAC MOD_LT[`y:num`;`scs_k_v39 s`] THEN MRESAL_TAC Hdplygy.MOD_EQ_MOD[`x:num`;`y:num`;`p MOD scs_k_v39 s`;`scs_k_v39 s`][ADD_SYM] ; MATCH_MP_TAC FINITE_SUBSET THEN EXISTS_TAC`0.. k'` THEN REWRITE_TAC[FINITE_NUMSEG;SUBSET;IN_ELIM_THM;IN_NUMSEG] THEN ARITH_TAC; POP_ASSUM MP_TAC THEN RESA_TAC THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN SUBGOAL_THEN`FINITE ({i | i < scs_k_v39 s /\ (&2 * h0 < scs_b_v39 s i (SUC i) \/ &2 < scs_a_v39 s i (SUC i))} UNION {(k' - 1 + p MOD scs_k_v39 s) MOD scs_k_v39 s})`ASSUME_TAC ; REWRITE_TAC[FINITE_UNION;FINITE_SING] THEN MATCH_MP_TAC FINITE_SUBSET THEN EXISTS_TAC`0.. (scs_k_v39 s)` THEN REWRITE_TAC[FINITE_NUMSEG;SUBSET;IN_ELIM_THM;IN_NUMSEG] THEN ARITH_TAC; POP_ASSUM MP_TAC THEN RESA_TAC THEN MRESA_TAC CARD_SUBSET[`IMAGE (\x. (x+p MOD scs_k_v39 s )MOD scs_k_v39 s ) {i | i < k' /\ (&2 * h0 < (if {i MOD k', SUC i MOD k'} = {0, k' - 1} then scs_bm_v39 s p q else scs_b_v39 s (i MOD k' + p MOD scs_k_v39 s) (SUC i MOD k' + p MOD scs_k_v39 s)) \/ &2 < (if {i MOD k', SUC i MOD k'} = {0, k' - 1} then scs_am_v39 s p q else scs_a_v39 s (i MOD k' + p MOD scs_k_v39 s) (SUC i MOD k' + p MOD scs_k_v39 s)))}`;`{i | i < scs_k_v39 s /\ (&2 * h0 < scs_b_v39 s i (SUC i) \/ &2 < scs_a_v39 s i (SUC i))} UNION {(k'-1 + p MOD scs_k_v39 s) MOD scs_k_v39 s}`] THEN SUBGOAL_THEN`FINITE ({i | i < scs_k_v39 s /\ (&2 * h0 < scs_b_v39 s i (SUC i) \/ &2 < scs_a_v39 s i (SUC i))})`ASSUME_TAC ; REWRITE_TAC[FINITE_UNION;FINITE_SING] THEN MATCH_MP_TAC FINITE_SUBSET THEN EXISTS_TAC`0.. (scs_k_v39 s)` THEN REWRITE_TAC[FINITE_NUMSEG;SUBSET;IN_ELIM_THM;IN_NUMSEG] THEN ARITH_TAC; POP_ASSUM MP_TAC THEN RESA_TAC THEN MRESAL_TAC CARD_UNION_LE[`{i | i < scs_k_v39 s /\ (&2 * h0 < scs_b_v39 s i (SUC i) \/ &2 < scs_a_v39 s i (SUC i))}`;`{(k' - 1 + p MOD scs_k_v39 s) MOD scs_k_v39 s}`][FINITE_SING;Geomdetail.CARD_SING] THEN POP_ASSUM MP_TAC THEN REMOVE_ASSUM_TAC THEN POP_ASSUM MP_TAC THEN REMOVE_ASSUM_TAC THEN REMOVE_ASSUM_TAC THEN POP_ASSUM MP_TAC THEN REMOVE_ASSUM_TAC THEN REMOVE_ASSUM_TAC THEN POP_ASSUM (fun th-> REPLICATE_TAC (5) REMOVE_ASSUM_TAC THEN POP_ASSUM MP_TAC THEN REWRITE_TAC[th]) THEN ABBREV_TAC`a={i | i < 4 /\ (&2 * h0 < scs_b_v39 s i (SUC i) \/ &2 < scs_a_v39 s i (SUC i))}` THEN ABBREV_TAC`b=CARD (IMAGE (\x. (x + p MOD 4) MOD 4) {i | i < k' /\ (&2 * h0 < (if {i MOD k', SUC i MOD k'} = {0, k' - 1} then scs_bm_v39 s p q else scs_b_v39 s (i MOD k' + p MOD 4) (SUC i MOD k' + p MOD 4)) \/ &2 < (if {i MOD k', SUC i MOD k'} = {0, k' - 1} then scs_am_v39 s p q else scs_a_v39 s (i MOD k' + p MOD 4) (SUC i MOD k' + p MOD 4)))})` THEN ABBREV_TAC`c=CARD (a UNION {(k' - 1 + p MOD 4) MOD 4})` THEN ASM_REWRITE_TAC[] THEN ARITH_TAC;]);;
let IS_EAR_IS_SCS=
prove(`is_ear_v39 s ==> is_scs_v39 s`,
REWRITE_TAC[is_ear_v39;is_scs_v39] THEN RESA_TAC);;
let SCS_HALF_SLICE_IS_SCS_4_PRIME=
prove_by_refinement( ` s' = scs_half_slice_v39 s p q d' mkj /\ s'' = scs_half_slice_v39 s q p d'' mkj /\ (scs_J_v39 s' 0 (scs_k_v39 s' -1))= mkj /\ (is_ear_v39 s'') /\ vv' = (\i. (vv:num->real^3) (i MOD (scs_k_v39 s')+p MOD (scs_k_v39 s))) /\ is_scs_v39 s /\ scs_diag (scs_k_v39 s) p q /\ d'< #0.9 /\ scs_bm_v39 s p q < &4 /\ scs_k_v39 s =4 ==> is_scs_v39 s'`,
[ STRIP_TAC THEN MRESA_TAC (GEN_ALL SCS_K_PRIME_LE_GE)[`s:scs_v39`;`p:num`;`q:num`;`d':real`;`scs_J_v39 s' p q`] THEN POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[LET_DEF;LET_END_DEF;] THEN REPLICATE_TAC 5 (POP_ASSUM MP_TAC) THEN ASM_REWRITE_TAC[LET_DEF;LET_END_DEF;scs_half_slice_v39;is_scs_v39;scs_diag;scs_v39_explicit] THEN ABBREV_TAC`k'=(q + 1 + scs_k_v39 s - p MOD scs_k_v39 s) MOD scs_k_v39 s` THEN REPEAT RESA_TAC; REWRITE_TAC[periodic] THEN SET_TAC[] ; REWRITE_TAC[periodic] THEN SET_TAC[] ; REWRITE_TAC[periodic] THEN SET_TAC[] ; REWRITE_TAC[periodic] THEN SET_TAC[] ; REWRITE_TAC[periodic2] THEN REPEAT STRIP_TAC ; MRESAL_TAC MOD_EQ [`i+k':num`;`i:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ (i + k') + p = i+p+k'`] THEN MRESAL_TAC MOD_EQ [`i+p+k':num`;`i+p:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ i + p + k' = (i + p) + k'`] ; MRESAL_TAC MOD_EQ [`j+k':num`;`j:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ (i + k') + p = i+p+k'`] THEN MRESAL_TAC MOD_EQ [`j+p+k':num`;`j+p:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ i + p + k' = (i + p) + k'`] ; REWRITE_TAC[periodic2] THEN REPEAT STRIP_TAC ; MRESAL_TAC MOD_EQ [`i+k':num`;`i:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ (i + k') + p = i+p+k'`] THEN MRESAL_TAC MOD_EQ [`i+p+k':num`;`i+p:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ i + p + k' = (i + p) + k'`]; MRESAL_TAC MOD_EQ [`j+k':num`;`j:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ (i + k') + p = i+p+k'`] THEN MRESAL_TAC MOD_EQ [`j+p+k':num`;`j+p:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ i + p + k' = (i + p) + k'`]; REWRITE_TAC[periodic2] THEN REPEAT STRIP_TAC; MRESAL_TAC MOD_EQ [`i+k':num`;`i:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ (i + k') + p = i+p+k'`] THEN MRESAL_TAC MOD_EQ [`i+p+k':num`;`i+p:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ i + p + k' = (i + p) + k'`]; MRESAL_TAC MOD_EQ [`j+k':num`;`j:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ (i + k') + p = i+p+k'`] THEN MRESAL_TAC MOD_EQ [`j+p+k':num`;`j+p:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ i + p + k' = (i + p) + k'`]; REWRITE_TAC[periodic2] THEN REPEAT STRIP_TAC ; MRESAL_TAC MOD_EQ [`i+k':num`;`i:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ (i + k') + p = i+p+k'`] THEN MRESAL_TAC MOD_EQ [`i+p+k':num`;`i+p:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ i + p + k' = (i + p) + k'`]; MRESAL_TAC MOD_EQ [`j+k':num`;`j:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ (i + k') + p = i+p+k'`] THEN MRESAL_TAC MOD_EQ [`j+p+k':num`;`j+p:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ i + p + k' = (i + p) + k'`] ; REWRITE_TAC[periodic2] THEN REPEAT STRIP_TAC ; MRESAL_TAC MOD_EQ [`i+k':num`;`i:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ (i + k') + p = i+p+k'`] THEN MRESAL_TAC MOD_EQ [`i+p+k':num`;`i+p:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ i + p + k' = (i + p) + k'`]; MRESAL_TAC MOD_EQ [`j+k':num`;`j:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ (i + k') + p = i+p+k'`] THEN MRESAL_TAC MOD_EQ [`j+p+k':num`;`j+p:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ i + p + k' = (i + p) + k'`]; GEN_REWRITE_TAC(LAND_CONV o ONCE_DEPTH_CONV)[SET_RULE`({A,B}={C,D})<=> ({B,A}={C,D}) `] THEN REWRITE_TAC[]; GEN_REWRITE_TAC(LAND_CONV o ONCE_DEPTH_CONV)[SET_RULE`({A,B}={C,D})<=> ({B,A}={C,D}) `] THEN REWRITE_TAC[]; GEN_REWRITE_TAC(LAND_CONV o ONCE_DEPTH_CONV)[SET_RULE`({A,B}={C,D})<=> ({B,A}={C,D}) `] THEN REWRITE_TAC[]; GEN_REWRITE_TAC(LAND_CONV o ONCE_DEPTH_CONV)[SET_RULE`({A,B}={C,D})<=> ({B,A}={C,D}) `] THEN REWRITE_TAC[]; GEN_REWRITE_TAC(LAND_CONV o ONCE_DEPTH_CONV)[SET_RULE`({A,B}={C,D})<=> ({B,A}={C,D}) `] THEN REWRITE_TAC[]; REAL_ARITH_TAC; DISJ_CASES_TAC(SET_RULE`{i MOD k', j MOD k'} = {0, k'-1} \/ ~({i MOD k', j MOD k'} = {0, k'-1})`); ASM_REWRITE_TAC[]; ASM_REWRITE_TAC[] THEN REPLICATE_TAC (17)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT DISCH_TAC THEN MRESA_TAC th[`i MOD k' + p MOD scs_k_v39 s`;`j MOD k' + p MOD scs_k_v39 s`]) THEN REPLICATE_TAC 3 (POP_ASSUM MP_TAC) THEN REAL_ARITH_TAC; REAL_ARITH_TAC; MP_TAC(ARITH_RULE`3<=k' ==> ~(0=k'-1)`) THEN RESA_TAC THEN DISJ_CASES_TAC(SET_RULE`{i MOD k', i MOD k'} = {0, k'-1} \/ ~({i MOD k', i MOD k'} = {0, k'-1})`); MP_TAC(SET_RULE`{i MOD k', i MOD k'} = {0, k'-1}==> i MOD k'= 0 /\ i MOD k'= k'-1`) THEN RESA_TAC THEN POP_ASSUM MP_TAC THEN RESA_TAC; ASM_REWRITE_TAC[]; DISJ_CASES_TAC(SET_RULE`{i MOD k', j MOD k'} = {0, k'-1} \/ ~({i MOD k', j MOD k'} = {0, k'-1})`); ASM_REWRITE_TAC[] THEN ASM_TAC THEN REWRITE_TAC[periodic2;] THEN REPEAT STRIP_TAC THEN MP_TAC(ARITH_RULE`3<= scs_k_v39 s ==> ~(scs_k_v39 s = 0)`) THEN RESA_TAC THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`scs_am_v39 s p`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th `q:num`) THEN POP_ASSUM(fun th-> ASM_REWRITE_TAC[SYM th]) THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`scs_am_v39 s (q MOD scs_k_v39 s)`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th `p:num`) THEN POP_ASSUM(fun th-> ASM_REWRITE_TAC[SYM th]) THEN MRESAL_TAC DIVISION[`p:num`;`scs_k_v39 s`][ARITH_RULE`~(6=0)`] THEN MRESAL_TAC DIVISION[`q:num`;`scs_k_v39 s`][ARITH_RULE`~(6=0)`] THEN REPLICATE_TAC 23 (POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESA_TAC th[`p MOD scs_k_v39 s`;`q MOD scs_k_v39 s`]) THEN REPLICATE_TAC 25(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESA_TAC th[`p MOD scs_k_v39 s`;`q MOD scs_k_v39 s`]) THEN REPLICATE_TAC 4(POP_ASSUM MP_TAC) THEN REAL_ARITH_TAC; ASM_REWRITE_TAC[] THEN ASM_TAC THEN REWRITE_TAC[periodic2;] THEN REPEAT STRIP_TAC THEN MP_TAC(ARITH_RULE`3<= scs_k_v39 s ==> ~(scs_k_v39 s = 0)`) THEN RESA_TAC THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`scs_a_v39 s (i MOD k' + p MOD scs_k_v39 s)`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th `(j MOD k' + p MOD scs_k_v39 s):num`) THEN POP_ASSUM(fun th-> ASM_REWRITE_TAC[SYM th]) THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`scs_a_v39 s (((j MOD k' + p MOD scs_k_v39 s) MOD scs_k_v39 s))`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th `((i MOD k' + p MOD scs_k_v39 s)):num`) THEN POP_ASSUM(fun th-> ASM_REWRITE_TAC[SYM th]) THEN REPLICATE_TAC (34-15)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MATCH_MP_TAC th) THEN MRESAL_TAC DIVISION[`(i MOD k' + p MOD scs_k_v39 s):num`;`scs_k_v39 s:num`][ARITH_RULE`~(6=0)`] THEN MRESAL_TAC DIVISION[`(j MOD k' + p MOD scs_k_v39 s):num`;`scs_k_v39 s`][ARITH_RULE`~(6=0)`] THEN STRIP_TAC THEN MRESAL_TAC Hdplygy.MOD_EQ_MOD[`i MOD k':num`;`j MOD k':num`;`p MOD scs_k_v39 s`;`scs_k_v39 s`][ADD_SYM] THEN POP_ASSUM MP_TAC THEN MRESA_TAC MOD_LT[`i:num`;`k':num`] THEN MRESA_TAC MOD_LT[`j:num`;`k':num`] THEN MP_TAC(ARITH_RULE`i< k' /\ k'< scs_k_v39 s /\ j<k' ==> i< scs_k_v39 s /\ j< scs_k_v39 s`) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`i:num`;`scs_k_v39 s`] THEN MRESA_TAC MOD_LT[`j:num`;`scs_k_v39 s`] ; DISJ_CASES_TAC(SET_RULE`{i MOD 3, SUC i MOD 3} = {0, 3-1} \/ ~({i MOD 3, SUC i MOD 3} = {0, 3-1})`); ASM_REWRITE_TAC[] ; ASM_REWRITE_TAC[] THEN MRESAL_TAC DIVISION[`i:num`;`k':num`][ARITH_RULE`~(3=0)`] THEN ASM_TAC THEN REWRITE_TAC[periodic2;] THEN REPEAT STRIP_TAC THEN MP_TAC(ARITH_RULE`3<= scs_k_v39 s ==> ~(scs_k_v39 s = 0)`) THEN RESA_TAC THEN MP_TAC(ARITH_RULE`(i ) MOD 3 < 3 ==> (i ) MOD 3 =0 \/ (i ) MOD 3 =1 \/ (i ) MOD 3 =2`) THEN RESA_TAC ; MRESAL_TAC(GEN_ALL IMP_SUC_MOD_EQ)[`i:num`;`0`;`3`][ARITH_RULE`0 MOD 3=0 /\ 1 MOD 3=1/\ 2 MOD 3=2/\ SUC 0=1/\ SUC 1=2 /\ SUC 2=3/\ 3 MOD 3=0/\ ~(3=0)/\ 0+A=A /\ 1+A= SUC A`] THEN REPLICATE_TAC (41-22)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESAL1_TAC th `p MOD scs_k_v39 s` [ARITH_RULE`SUC 0=1/\ SUC 1=2/\ SUC 2=3/\ 3<4`;cstab]) THEN POP_ASSUM MP_TAC THEN REAL_ARITH_TAC; MRESAL_TAC(GEN_ALL IMP_SUC_MOD_EQ)[`i:num`;`1`;`3`][ARITH_RULE`0 MOD 3=0 /\ 1 MOD 3=1/\ 2 MOD 3=2/\ SUC 0=1/\ SUC 1=2 /\ SUC 2=3/\ 3 MOD 3=0/\ ~(3=0)/\ 2+A=SUC(1+A) `] THEN REPLICATE_TAC (41-22)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESAL1_TAC th `1+p MOD scs_k_v39 s` [ARITH_RULE`SUC 0=1/\ SUC 1=2/\ SUC 2=3/\3<4`;cstab]) THEN POP_ASSUM MP_TAC THEN REAL_ARITH_TAC; MRESAL_TAC(GEN_ALL IMP_SUC_MOD_EQ)[`i:num`;`2`;`3`][ARITH_RULE`0 MOD 3=0 /\ 1 MOD 3=1/\ 2 MOD 3=2/\ SUC 0=1/\ SUC 1=2 /\ SUC 2=3/\ 3 MOD 3=0/\ ~(3=0)/\ 2+A=SUC(1+A) `] THEN POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[th;ARITH_RULE`3-1=2`] THEN REPEAT STRIP_TAC) THEN POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[th;ARITH_RULE`3-1=2`] THEN REPEAT STRIP_TAC) THEN REPLICATE_TAC (3) REMOVE_ASSUM_TAC THEN POP_ASSUM MP_TAC THEN SET_TAC[]; POP_ASSUM MP_TAC THEN POP_ASSUM MP_TAC THEN ARITH_TAC ; POP_ASSUM MP_TAC THEN DISJ_CASES_TAC(SET_RULE`{i MOD k', j MOD k'} = {0, k' - 1} \/ ~({i MOD k', j MOD k'} = {0, k' - 1})`) ; ASM_REWRITE_TAC[]; MP_TAC(SET_RULE`{i MOD k', j MOD k'} = {0, k' - 1} ==> (i MOD k'= 0 /\ j MOD k' = k'-1)\/ (i MOD k'= k'-1 /\ j MOD k' = 0)`) THEN RESA_TAC; MP_TAC(ARITH_RULE`3<= k' /\ k' <scs_k_v39 s ==> 3< scs_k_v39 s/\ ~(k'=0) /\ 1< k'/\ k'-1< k'/\ SUC(k'-1)= k'`) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`k'-1`;`k':num`] THEN MRESAL_TAC MOD_MULT[`k':num`;`1`][ARITH_RULE`A* 1=A`] THEN MRESAL_TAC(GEN_ALL IMP_SUC_MOD_EQ)[`j:num`;`k'-1`;`k':num`][ARITH_RULE`0 MOD 3=0 /\ 1 MOD 3=1/\ 2 MOD 3=2/\ SUC 0=1/\ SUC 1=2 /\ SUC 2=3/\ 3 MOD 3=0/\ ~(3=0)/\ 2+A=SUC(1+A) `] ; MP_TAC(ARITH_RULE`3<= k' /\ k' <scs_k_v39 s ==> 3< scs_k_v39 s/\ ~(k'=0) /\ 1< k'/\ k'-1< k'/\ SUC(k'-1)= k'/\ ~(scs_k_v39 s =0)`) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`k'-1`;`k':num`] THEN MRESAL_TAC MOD_MULT[`k':num`;`1`][ARITH_RULE`A* 1=A`] THEN MRESAL_TAC(GEN_ALL IMP_SUC_MOD_EQ)[`i:num`;`k'-1`;`k':num`][ARITH_RULE`0 MOD 3=0 /\ 1 MOD 3=1/\ 2 MOD 3=2/\ SUC 0=1/\ SUC 1=2 /\ SUC 2=3/\ 3 MOD 3=0/\ ~(3=0)/\ 2+A=SUC(1+A) `] ; ASM_REWRITE_TAC[] THEN STRIP_TAC THEN REPLICATE_TAC (36-23)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESAL_TAC th[`(i MOD k' + p MOD scs_k_v39 s)`;`(j MOD k' + p MOD scs_k_v39 s)`][ARITH_RULE`SUC(A+B)= SUC A+B`]) ; MP_TAC(ARITH_RULE`3<= k' /\ k' <scs_k_v39 s ==> 3< scs_k_v39 s/\ ~(k'=0) /\ 1< k'/\ k'-1< k'/\ SUC(k'-1)= k'/\ ~(scs_k_v39 s =0)`) THEN RESA_TAC THEN MRESAL_TAC Hdplygy.MOD_EQ_MOD[`j MOD k':num`;`SUC(i MOD k'):num`;`p MOD scs_k_v39 s`;`scs_k_v39 s`][ADD_SYM] THEN POP_ASSUM MP_TAC THEN MRESAL_TAC DIVISION[`(i):num`;`k':num`][ARITH_RULE`~(6=0)`] THEN MRESAL_TAC DIVISION[`(j):num`;`k':num`][ARITH_RULE`~(6=0)`] THEN MP_TAC(ARITH_RULE`j MOD k' < k' /\ k'< scs_k_v39 s /\ i MOD k' < k' ==> j MOD k' < scs_k_v39 s /\ SUC (i MOD k') < scs_k_v39 s`) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`j MOD k'`;`scs_k_v39 s:num`] THEN MRESA_TAC MOD_LT[`SUC(i MOD k')`;`scs_k_v39 s:num`] THEN RESA_TAC THEN MP_TAC(ARITH_RULE`3<=k' /\ i MOD k' < k' ==> i MOD k' =k'-1 \/ i MOD k' +1 < k' `) THEN RESA_TAC ; POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[th] THEN REPEAT STRIP_TAC) THEN POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[] THEN REPLICATE_TAC (4) REMOVE_ASSUM_TAC THEN POP_ASSUM MP_TAC THEN ARITH_TAC; REWRITE_TAC[ADD1] THEN MRESA_TAC MOD_ADD_MOD[`i:num`;`1:num`;`k':num`] THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN MRESA_TAC MOD_LT[`1`;`k':num`] THEN MRESA_TAC MOD_LT[`i MOD k' + 1`;`k':num`] ; MP_TAC(ARITH_RULE`3<= k' /\ k' <scs_k_v39 s ==> 3< scs_k_v39 s/\ ~(k'=0) /\ 1< k'/\ k'-1< k'/\ SUC(k'-1)= k'/\ ~(scs_k_v39 s =0)`) THEN RESA_TAC THEN MRESAL_TAC Hdplygy.MOD_EQ_MOD[`i MOD k':num`;`SUC(j MOD k'):num`;`p MOD scs_k_v39 s`;`scs_k_v39 s`][ADD_SYM] THEN POP_ASSUM MP_TAC THEN MRESAL_TAC DIVISION[`(i):num`;`k':num`][ARITH_RULE`~(6=0)`] THEN MRESAL_TAC DIVISION[`(j):num`;`k':num`][ARITH_RULE`~(6=0)`] THEN MP_TAC(ARITH_RULE`j MOD k' < k' /\ k'< scs_k_v39 s /\ i MOD k' < k' ==> SUC(j MOD k') < scs_k_v39 s /\ (i MOD k') < scs_k_v39 s`) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`i MOD k'`;`scs_k_v39 s:num`] THEN MRESA_TAC MOD_LT[`SUC(j MOD k')`;`scs_k_v39 s:num`] THEN RESA_TAC THEN MP_TAC(ARITH_RULE`3<=k' /\ j MOD k' < k' ==> j MOD k' =k'-1 \/ j MOD k' +1 < k' `) THEN RESA_TAC ; POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[th] THEN REPEAT STRIP_TAC) THEN POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[] THEN REPLICATE_TAC (5) REMOVE_ASSUM_TAC THEN POP_ASSUM MP_TAC THEN ARITH_TAC; REWRITE_TAC[ADD1] THEN MRESA_TAC MOD_ADD_MOD[`j:num`;`1:num`;`k':num`] THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN MRESA_TAC MOD_LT[`1`;`k':num`] THEN MRESA_TAC MOD_LT[`j MOD k' + 1`;`k':num`] ; POP_ASSUM MP_TAC THEN DISJ_CASES_TAC(SET_RULE`{i MOD k', j MOD k'} = {0, k' - 1} \/ ~({i MOD k', j MOD k'} = {0, k' - 1})`) ; ASM_REWRITE_TAC[] THEN STRIP_TAC THEN REPLICATE_TAC (36-3)(POP_ASSUM MP_TAC) THEN POP_ASSUM (fun th-> REPEAT STRIP_TAC THEN MP_TAC th THEN ASM_REWRITE_TAC[is_ear_v39;scs_half_slice_v39;LET_DEF;LET_END_DEF;scs_half_slice_v39;is_scs_v39;scs_diag;scs_v39_explicit]) THEN STRIP_TAC THEN ABBREV_TAC`k''=(p + 1 + 4 - q MOD 4) MOD 4` THEN SUBGOAL_THEN`k'' -1 IN {i | i < 3 /\ (if {i MOD k'', SUC i MOD k''} = {0, k'' - 1} then T else scs_J_v39 s (i MOD k'' + q MOD 4) (SUC i MOD k'' + q MOD 4))}` ASSUME_TAC ; REWRITE_TAC[IN_ELIM_THM] THEN ASM_REWRITE_TAC[ARITH_RULE`3-1=2 /\ 2<3 /\ 2 MOD 3=2/\ SUC 2=3/\ 3 MOD 3=0 `]; POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[ARITH_RULE`3-1=2`;SET_RULE`( a = b <=> b=a)`;IN_SING] THEN REPLICATE_TAC (3)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th) THEN ASM_REWRITE_TAC[ARITH_RULE`3-1=2 /\ 2<3 /\ 2 MOD 3=2/\ SUC 2=3/\ 3 MOD 3=0 `]; ASM_REWRITE_TAC[] THEN STRIP_TAC THEN REPLICATE_TAC (36-24)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESA_TAC th[`(i MOD k' + p MOD scs_k_v39 s)`;`(j MOD k' + p MOD scs_k_v39 s)`]) ; POP_ASSUM MP_TAC THEN DISJ_CASES_TAC(SET_RULE`{i MOD k', j MOD k'} = {0, k' - 1} \/ ~({i MOD k', j MOD k'} = {0, k' - 1})`) ; ASM_REWRITE_TAC[] THEN STRIP_TAC THEN REPLICATE_TAC (36-3)(POP_ASSUM MP_TAC) THEN POP_ASSUM (fun th-> REPEAT STRIP_TAC THEN MP_TAC th THEN ASM_REWRITE_TAC[is_ear_v39;scs_half_slice_v39;LET_DEF;LET_END_DEF;scs_half_slice_v39;is_scs_v39;scs_diag;scs_v39_explicit]) THEN STRIP_TAC THEN ABBREV_TAC`k''=(p + 1 + 4 - q MOD 4) MOD 4` THEN SUBGOAL_THEN`k'' -1 IN {i | i < 3 /\ (if {i MOD k'', SUC i MOD k''} = {0, k'' - 1} then T else scs_J_v39 s (i MOD k'' + q MOD 4) (SUC i MOD k'' + q MOD 4))}` ASSUME_TAC ; REWRITE_TAC[IN_ELIM_THM] THEN ASM_REWRITE_TAC[ARITH_RULE`3-1=2 /\ 2<3 /\ 2 MOD 3=2/\ SUC 2=3/\ 3 MOD 3=0 `]; POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[ARITH_RULE`3-1=2`;SET_RULE`( a = b <=> b=a)`;IN_SING] THEN REPLICATE_TAC (2)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th) THEN ASM_REWRITE_TAC[ARITH_RULE`3-1=2 /\ 2<3 /\ 2 MOD 3=2/\ SUC 2=3/\ 3 MOD 3=0 `] THEN RESA_TAC; ASM_REWRITE_TAC[] THEN STRIP_TAC THEN REPLICATE_TAC (36-24)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESA_TAC th[`(i MOD k' + p MOD scs_k_v39 s)`;`(j MOD k' + p MOD scs_k_v39 s)`]) ; SUBGOAL_THEN`IMAGE (\x. (x+p MOD scs_k_v39 s )MOD scs_k_v39 s ) {i | i < k' /\ (&2 * h0 < (if {i MOD k', SUC i MOD k'} = {0, k' - 1} then scs_bm_v39 s p q else scs_b_v39 s (i MOD k' + p MOD scs_k_v39 s) (SUC i MOD k' + p MOD scs_k_v39 s)) \/ &2 < (if {i MOD k', SUC i MOD k'} = {0, k' - 1} then scs_am_v39 s p q else scs_a_v39 s (i MOD k' + p MOD scs_k_v39 s) (SUC i MOD k' + p MOD scs_k_v39 s)))} SUBSET {i | i < scs_k_v39 s /\ (&2 * h0 < scs_b_v39 s i (SUC i) \/ &2 < scs_a_v39 s i (SUC i))} UNION {(k'-1 + p MOD scs_k_v39 s) MOD scs_k_v39 s}` ASSUME_TAC; REWRITE_TAC[SUBSET;UNION;IN_ELIM_THM;IN_SING;IMAGE] THEN GEN_TAC THEN RESA_TAC; REMOVE_ASSUM_TAC THEN POP_ASSUM MP_TAC THEN MP_TAC(ARITH_RULE`x'<k'==> x'= k'-1\/ SUC x' < k' `) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`x':num`;`k':num`] THEN MRESA_TAC MOD_LT[`SUC x':num`;`k':num`] THEN DISJ_CASES_TAC(SET_RULE`{x', SUC x'} = {0, k' - 1} \/ ~({x', SUC x'} = {0, k' - 1})`) ; MP_TAC(SET_RULE`{x', SUC x'} = {0, k' - 1} ==> (x' =0 /\ SUC x' = k'-1)\/ (x' =k'-1/\ SUC x' =0)`) THEN RESA_TAC THEN POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[ARITH_RULE`SUC 0= k'-1<=> k'=2`] THEN STRIP_TAC THEN POP_ASSUM (fun th-> REPLICATE_TAC (40-32)(REMOVE_ASSUM_TAC) THEN POP_ASSUM MP_TAC THEN REWRITE_TAC[th]) THEN ARITH_TAC ; ASM_REWRITE_TAC[] THEN STRIP_TAC THEN MATCH_MP_TAC(SET_RULE`A==>A \/ B`) THEN MP_TAC(ARITH_RULE`k' < scs_k_v39 s /\ 3<= k' /\ x'< k' /\ SUC x' < k' ==> ~(scs_k_v39 s=0) /\ x'< scs_k_v39 s/\ SUC x' < scs_k_v39 s/\ 1< scs_k_v39 s`) THEN RESA_TAC THEN MRESAL_TAC DIVISION[`x' + p MOD scs_k_v39 s`;`scs_k_v39 s`][ARITH_RULE`~(6=0)`] THEN MATCH_MP_TAC(SET_RULE`A==>A \/ B`) THEN MRESA_TAC MOD_LT[`x':num`;`scs_k_v39 s`] THEN MRESA_TAC MOD_LT[`SUC x':num`;`scs_k_v39 s`] THEN MRESA_TAC MOD_ADD_MOD[`x':num`;`p:num`;`scs_k_v39 s`] THEN MRESA_TAC MOD_ADD_MOD[`SUC x':num`;`p:num`;`scs_k_v39 s`] THEN REPLICATE_TAC (10)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th) THEN ASM_TAC THEN REWRITE_TAC[periodic2;] THEN REPEAT STRIP_TAC THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`scs_b_v39 s (x' + p MOD scs_k_v39 s)`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th `(SUC x' + p MOD scs_k_v39 s):num`) THEN POP_ASSUM(fun th-> POP_ASSUM MP_TAC THEN REWRITE_TAC[SYM th]) THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`scs_b_v39 s ((SUC x' + p) MOD scs_k_v39 s)`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th `(x' + p MOD scs_k_v39 s):num`) THEN POP_ASSUM(fun th-> ASM_REWRITE_TAC[SYM th]) THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`scs_b_v39 s ((x' + p) MOD scs_k_v39 s)`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th `(SUC ((x' + p) MOD scs_k_v39 s)):num`) THEN POP_ASSUM(fun th-> ASM_REWRITE_TAC[SYM th;ADD1]) THEN MRESA_TAC MOD_LT[`1:num`;`scs_k_v39 s`] THEN MRESA_TAC MOD_ADD_MOD[`(x' + p):num`;`1:num`;`scs_k_v39 s`] THEN STRIP_TAC THEN ASM_REWRITE_TAC[ARITH_RULE`(x' + p) + 1=(x' + 1) + p`] ; REMOVE_ASSUM_TAC THEN POP_ASSUM MP_TAC THEN MP_TAC(ARITH_RULE`x'<k'==> x'= k'-1\/ SUC x' < k' `) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`x':num`;`k':num`] THEN MRESA_TAC MOD_LT[`SUC x':num`;`k':num`] THEN DISJ_CASES_TAC(SET_RULE`{x', SUC x'} = {0, k' - 1} \/ ~({x', SUC x'} = {0, k' - 1})`) ; MP_TAC(SET_RULE`{x', SUC x'} = {0, k' - 1} ==> (x' =0 /\ SUC x' = k'-1)\/ (x' =k'-1/\ SUC x' =0)`) THEN RESA_TAC THEN POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[ARITH_RULE`SUC 0= k'-1<=> k'=2`] THEN STRIP_TAC THEN POP_ASSUM (fun th-> REPLICATE_TAC (40-32)(REMOVE_ASSUM_TAC) THEN POP_ASSUM MP_TAC THEN REWRITE_TAC[th]) THEN ARITH_TAC ; ASM_REWRITE_TAC[] THEN STRIP_TAC THEN MATCH_MP_TAC(SET_RULE`A==>A \/ B`) THEN MP_TAC(ARITH_RULE`k' < scs_k_v39 s /\ 3<= k' /\ x'< k' /\ SUC x' < k' ==> ~(scs_k_v39 s=0) /\ x'< scs_k_v39 s/\ SUC x' < scs_k_v39 s/\ 1< scs_k_v39 s`) THEN RESA_TAC THEN MRESAL_TAC DIVISION[`x' + p MOD scs_k_v39 s`;`scs_k_v39 s`][ARITH_RULE`~(6=0)`] THEN MATCH_MP_TAC(SET_RULE`B==>A \/ B`) THEN MRESA_TAC MOD_LT[`x':num`;`scs_k_v39 s`] THEN MRESA_TAC MOD_LT[`SUC x':num`;`scs_k_v39 s`] THEN MRESA_TAC MOD_ADD_MOD[`x':num`;`p:num`;`scs_k_v39 s`] THEN MRESA_TAC MOD_ADD_MOD[`SUC x':num`;`p:num`;`scs_k_v39 s`] THEN REPLICATE_TAC (10)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th) THEN ASM_TAC THEN REWRITE_TAC[periodic2;] THEN REPEAT STRIP_TAC THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`scs_a_v39 s (x' + p MOD scs_k_v39 s)`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th `(SUC x' + p MOD scs_k_v39 s):num`) THEN POP_ASSUM(fun th-> POP_ASSUM MP_TAC THEN REWRITE_TAC[SYM th]) THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`scs_a_v39 s ((SUC x' + p) MOD scs_k_v39 s)`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th `(x' + p MOD scs_k_v39 s):num`) THEN POP_ASSUM(fun th-> ASM_REWRITE_TAC[SYM th]) THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`scs_a_v39 s ((x' + p) MOD scs_k_v39 s)`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th `(SUC ((x' + p) MOD scs_k_v39 s)):num`) THEN POP_ASSUM(fun th-> ASM_REWRITE_TAC[SYM th;ADD1]) THEN MRESA_TAC MOD_LT[`1:num`;`scs_k_v39 s`] THEN MRESA_TAC MOD_ADD_MOD[`(x' + p):num`;`1:num`;`scs_k_v39 s`] THEN STRIP_TAC THEN ASM_REWRITE_TAC[ARITH_RULE`(x' + p) + 1=(x' + 1) + p`] ; SUBGOAL_THEN`CARD(IMAGE (\x. (x+p MOD scs_k_v39 s )MOD scs_k_v39 s ) {i | i < k' /\ (&2 * h0 < (if {i MOD k', SUC i MOD k'} = {0, k' - 1} then scs_bm_v39 s p q else scs_b_v39 s (i MOD k' + p MOD scs_k_v39 s) (SUC i MOD k' + p MOD scs_k_v39 s)) \/ &2 < (if {i MOD k', SUC i MOD k'} = {0, k' - 1} then scs_am_v39 s p q else scs_a_v39 s (i MOD k' + p MOD scs_k_v39 s) (SUC i MOD k' + p MOD scs_k_v39 s)))}) = CARD {i | i < k' /\ (&2 * h0 < (if {i MOD k', SUC i MOD k'} = {0, k' - 1} then scs_bm_v39 s p q else scs_b_v39 s (i MOD k' + p MOD scs_k_v39 s) (SUC i MOD k' + p MOD scs_k_v39 s)) \/ &2 < (if {i MOD k', SUC i MOD k'} = {0, k' - 1} then scs_am_v39 s p q else scs_a_v39 s (i MOD k' + p MOD scs_k_v39 s) (SUC i MOD k' + p MOD scs_k_v39 s)))}`ASSUME_TAC ; MATCH_MP_TAC CARD_IMAGE_INJ THEN STRIP_TAC; ASM_REWRITE_TAC[IN_ELIM_THM] THEN REPEAT STRIP_TAC THEN MP_TAC(ARITH_RULE`3<= k' /\ k' <scs_k_v39 s /\ x<k' /\y< k' ==> 3< scs_k_v39 s/\ ~(k'=0) /\ 1< k'/\ k'-1< k'/\ SUC(k'-1)= k'/\ ~(scs_k_v39 s =0) /\ x< scs_k_v39 s/\ y< scs_k_v39 s`) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`x:num`;`scs_k_v39 s`] THEN MRESA_TAC MOD_LT[`y:num`;`scs_k_v39 s`] THEN MRESAL_TAC Hdplygy.MOD_EQ_MOD[`x:num`;`y:num`;`p MOD scs_k_v39 s`;`scs_k_v39 s`][ADD_SYM] ; MATCH_MP_TAC FINITE_SUBSET THEN EXISTS_TAC`0.. k'` THEN REWRITE_TAC[FINITE_NUMSEG;SUBSET;IN_ELIM_THM;IN_NUMSEG] THEN ARITH_TAC; POP_ASSUM MP_TAC THEN RESA_TAC THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN SUBGOAL_THEN`FINITE ({i | i < scs_k_v39 s /\ (&2 * h0 < scs_b_v39 s i (SUC i) \/ &2 < scs_a_v39 s i (SUC i))} UNION {(k' - 1 + p MOD scs_k_v39 s) MOD scs_k_v39 s})`ASSUME_TAC ; REWRITE_TAC[FINITE_UNION;FINITE_SING] THEN MATCH_MP_TAC FINITE_SUBSET THEN EXISTS_TAC`0.. (scs_k_v39 s)` THEN REWRITE_TAC[FINITE_NUMSEG;SUBSET;IN_ELIM_THM;IN_NUMSEG] THEN ARITH_TAC; POP_ASSUM MP_TAC THEN RESA_TAC THEN MRESA_TAC CARD_SUBSET[`IMAGE (\x. (x+p MOD scs_k_v39 s )MOD scs_k_v39 s ) {i | i < k' /\ (&2 * h0 < (if {i MOD k', SUC i MOD k'} = {0, k' - 1} then scs_bm_v39 s p q else scs_b_v39 s (i MOD k' + p MOD scs_k_v39 s) (SUC i MOD k' + p MOD scs_k_v39 s)) \/ &2 < (if {i MOD k', SUC i MOD k'} = {0, k' - 1} then scs_am_v39 s p q else scs_a_v39 s (i MOD k' + p MOD scs_k_v39 s) (SUC i MOD k' + p MOD scs_k_v39 s)))}`;`{i | i < scs_k_v39 s /\ (&2 * h0 < scs_b_v39 s i (SUC i) \/ &2 < scs_a_v39 s i (SUC i))} UNION {(k'-1 + p MOD scs_k_v39 s) MOD scs_k_v39 s}`] THEN SUBGOAL_THEN`FINITE ({i | i < scs_k_v39 s /\ (&2 * h0 < scs_b_v39 s i (SUC i) \/ &2 < scs_a_v39 s i (SUC i))})`ASSUME_TAC ; REWRITE_TAC[FINITE_UNION;FINITE_SING] THEN MATCH_MP_TAC FINITE_SUBSET THEN EXISTS_TAC`0.. (scs_k_v39 s)` THEN REWRITE_TAC[FINITE_NUMSEG;SUBSET;IN_ELIM_THM;IN_NUMSEG] THEN ARITH_TAC; POP_ASSUM MP_TAC THEN RESA_TAC THEN MRESAL_TAC CARD_UNION_LE[`{i | i < scs_k_v39 s /\ (&2 * h0 < scs_b_v39 s i (SUC i) \/ &2 < scs_a_v39 s i (SUC i))}`;`{(k' - 1 + p MOD scs_k_v39 s) MOD scs_k_v39 s}`][FINITE_SING;Geomdetail.CARD_SING] THEN POP_ASSUM MP_TAC THEN REMOVE_ASSUM_TAC THEN POP_ASSUM MP_TAC THEN REMOVE_ASSUM_TAC THEN REMOVE_ASSUM_TAC THEN POP_ASSUM MP_TAC THEN REMOVE_ASSUM_TAC THEN REMOVE_ASSUM_TAC THEN POP_ASSUM (fun th-> REPLICATE_TAC (5) REMOVE_ASSUM_TAC THEN POP_ASSUM MP_TAC THEN REWRITE_TAC[th]) THEN ABBREV_TAC`a={i | i < 4 /\ (&2 * h0 < scs_b_v39 s i (SUC i) \/ &2 < scs_a_v39 s i (SUC i))}` THEN ABBREV_TAC`b=CARD (IMAGE (\x. (x + p MOD 4) MOD 4) {i | i < k' /\ (&2 * h0 < (if {i MOD k', SUC i MOD k'} = {0, k' - 1} then scs_bm_v39 s p q else scs_b_v39 s (i MOD k' + p MOD 4) (SUC i MOD k' + p MOD 4)) \/ &2 < (if {i MOD k', SUC i MOD k'} = {0, k' - 1} then scs_am_v39 s p q else scs_a_v39 s (i MOD k' + p MOD 4) (SUC i MOD k' + p MOD 4)))})` THEN ABBREV_TAC`c=CARD (a UNION {(k' - 1 + p MOD 4) MOD 4})` THEN ASM_REWRITE_TAC[] THEN ARITH_TAC]);;
let SCS_HALF_SLICE_IS_SCS_PRIME=
prove_by_refinement( ` s' = scs_half_slice_v39 s p q d' mkj /\ s'' = scs_half_slice_v39 s q p d'' mkj /\ (scs_J_v39 s' 0 (scs_k_v39 s' -1))= mkj /\ (is_ear_v39 s'') /\ vv' = (\i. (vv:num->real^3) (i MOD (scs_k_v39 s')+p MOD (scs_k_v39 s))) /\ is_scs_v39 s /\ scs_diag (scs_k_v39 s) p q /\ d'< #0.9 /\ scs_bm_v39 s p q < &4 /\ (4<scs_k_v39 s ==> scs_bm_v39 s p q <= cstab) ==> is_scs_v39 s'`,
[ STRIP_TAC THEN MRESA_TAC (GEN_ALL SCS_K_PRIME_LE_GE)[`s:scs_v39`;`p:num`;`q:num`;`d':real`;`scs_J_v39 s' p q`] THEN POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[LET_DEF;LET_END_DEF;] THEN REPLICATE_TAC 5 (POP_ASSUM MP_TAC) THEN ASM_REWRITE_TAC[LET_DEF;LET_END_DEF;scs_half_slice_v39;is_scs_v39;scs_diag;scs_v39_explicit] THEN ABBREV_TAC`k'=(q + 1 + scs_k_v39 s - p MOD scs_k_v39 s) MOD scs_k_v39 s` THEN REPEAT RESA_TAC; REWRITE_TAC[periodic] THEN SET_TAC[] ; REWRITE_TAC[periodic] THEN SET_TAC[] ; REWRITE_TAC[periodic] THEN SET_TAC[] ; REWRITE_TAC[periodic] THEN SET_TAC[] ; REWRITE_TAC[periodic2] THEN REPEAT STRIP_TAC ; MRESAL_TAC MOD_EQ [`i+k':num`;`i:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ (i + k') + p = i+p+k'`] THEN MRESAL_TAC MOD_EQ [`i+p+k':num`;`i+p:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ i + p + k' = (i + p) + k'`] ; MRESAL_TAC MOD_EQ [`j+k':num`;`j:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ (i + k') + p = i+p+k'`] THEN MRESAL_TAC MOD_EQ [`j+p+k':num`;`j+p:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ i + p + k' = (i + p) + k'`] ; REWRITE_TAC[periodic2] THEN REPEAT STRIP_TAC ; MRESAL_TAC MOD_EQ [`i+k':num`;`i:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ (i + k') + p = i+p+k'`] THEN MRESAL_TAC MOD_EQ [`i+p+k':num`;`i+p:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ i + p + k' = (i + p) + k'`]; MRESAL_TAC MOD_EQ [`j+k':num`;`j:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ (i + k') + p = i+p+k'`] THEN MRESAL_TAC MOD_EQ [`j+p+k':num`;`j+p:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ i + p + k' = (i + p) + k'`]; REWRITE_TAC[periodic2] THEN REPEAT STRIP_TAC; MRESAL_TAC MOD_EQ [`i+k':num`;`i:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ (i + k') + p = i+p+k'`] THEN MRESAL_TAC MOD_EQ [`i+p+k':num`;`i+p:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ i + p + k' = (i + p) + k'`]; MRESAL_TAC MOD_EQ [`j+k':num`;`j:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ (i + k') + p = i+p+k'`] THEN MRESAL_TAC MOD_EQ [`j+p+k':num`;`j+p:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ i + p + k' = (i + p) + k'`]; REWRITE_TAC[periodic2] THEN REPEAT STRIP_TAC ; MRESAL_TAC MOD_EQ [`i+k':num`;`i:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ (i + k') + p = i+p+k'`] THEN MRESAL_TAC MOD_EQ [`i+p+k':num`;`i+p:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ i + p + k' = (i + p) + k'`]; MRESAL_TAC MOD_EQ [`j+k':num`;`j:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ (i + k') + p = i+p+k'`] THEN MRESAL_TAC MOD_EQ [`j+p+k':num`;`j+p:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ i + p + k' = (i + p) + k'`] ; REWRITE_TAC[periodic2] THEN REPEAT STRIP_TAC ; MRESAL_TAC MOD_EQ [`i+k':num`;`i:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ (i + k') + p = i+p+k'`] THEN MRESAL_TAC MOD_EQ [`i+p+k':num`;`i+p:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ i + p + k' = (i + p) + k'`]; MRESAL_TAC MOD_EQ [`j+k':num`;`j:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ (i + k') + p = i+p+k'`] THEN MRESAL_TAC MOD_EQ [`j+p+k':num`;`j+p:num`;`k':num`;`1`][ARITH_RULE`1* k'=k'/\ i + p + k' = (i + p) + k'`]; GEN_REWRITE_TAC(LAND_CONV o ONCE_DEPTH_CONV)[SET_RULE`({A,B}={C,D})<=> ({B,A}={C,D}) `] THEN REWRITE_TAC[]; GEN_REWRITE_TAC(LAND_CONV o ONCE_DEPTH_CONV)[SET_RULE`({A,B}={C,D})<=> ({B,A}={C,D}) `] THEN REWRITE_TAC[]; GEN_REWRITE_TAC(LAND_CONV o ONCE_DEPTH_CONV)[SET_RULE`({A,B}={C,D})<=> ({B,A}={C,D}) `] THEN REWRITE_TAC[]; GEN_REWRITE_TAC(LAND_CONV o ONCE_DEPTH_CONV)[SET_RULE`({A,B}={C,D})<=> ({B,A}={C,D}) `] THEN REWRITE_TAC[]; GEN_REWRITE_TAC(LAND_CONV o ONCE_DEPTH_CONV)[SET_RULE`({A,B}={C,D})<=> ({B,A}={C,D}) `] THEN REWRITE_TAC[]; REAL_ARITH_TAC; DISJ_CASES_TAC(SET_RULE`{i MOD k', j MOD k'} = {0, k'-1} \/ ~({i MOD k', j MOD k'} = {0, k'-1})`); ASM_REWRITE_TAC[]; ASM_REWRITE_TAC[] THEN REPLICATE_TAC (17)(REMOVE_ASSUM_TAC) THEN POP_ASSUM(fun th-> MRESA_TAC th[`i MOD k' + p MOD scs_k_v39 s`;`j MOD k' + p MOD scs_k_v39 s`]) THEN REPLICATE_TAC 3 (POP_ASSUM MP_TAC) THEN REAL_ARITH_TAC ; REAL_ARITH_TAC; MP_TAC(ARITH_RULE`3<=k' ==> ~(0=k'-1)`) THEN RESA_TAC THEN DISJ_CASES_TAC(SET_RULE`{i MOD k', i MOD k'} = {0, k'-1} \/ ~({i MOD k', i MOD k'} = {0, k'-1})`); MP_TAC(SET_RULE`{i MOD k', i MOD k'} = {0, k'-1}==> i MOD k'= 0 /\ i MOD k'= k'-1`) THEN RESA_TAC THEN POP_ASSUM MP_TAC THEN RESA_TAC; ASM_REWRITE_TAC[]; DISJ_CASES_TAC(SET_RULE`{i MOD k', j MOD k'} = {0, k'-1} \/ ~({i MOD k', j MOD k'} = {0, k'-1})`); ASM_REWRITE_TAC[] THEN ASM_TAC THEN REWRITE_TAC[periodic2;] THEN REPEAT STRIP_TAC THEN MP_TAC(ARITH_RULE`3<= scs_k_v39 s ==> ~(scs_k_v39 s = 0)`) THEN RESA_TAC THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`scs_am_v39 s p`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th `q:num`) THEN POP_ASSUM(fun th-> ASM_REWRITE_TAC[SYM th]) THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`scs_am_v39 s (q MOD scs_k_v39 s)`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th `p:num`) THEN POP_ASSUM(fun th-> ASM_REWRITE_TAC[SYM th]) THEN MRESAL_TAC DIVISION[`p:num`;`scs_k_v39 s`][ARITH_RULE`~(6=0)`] THEN MRESAL_TAC DIVISION[`q:num`;`scs_k_v39 s`][ARITH_RULE`~(6=0)`] THEN REPLICATE_TAC 23 (POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESA_TAC th[`p MOD scs_k_v39 s`;`q MOD scs_k_v39 s`]) THEN REPLICATE_TAC 25(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESA_TAC th[`p MOD scs_k_v39 s`;`q MOD scs_k_v39 s`]) THEN REPLICATE_TAC 4(POP_ASSUM MP_TAC) THEN REAL_ARITH_TAC; ASM_REWRITE_TAC[] THEN ASM_TAC THEN REWRITE_TAC[periodic2;] THEN REPEAT STRIP_TAC THEN MP_TAC(ARITH_RULE`3<= scs_k_v39 s ==> ~(scs_k_v39 s = 0)`) THEN RESA_TAC THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`scs_a_v39 s (i MOD k' + p MOD scs_k_v39 s)`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th `(j MOD k' + p MOD scs_k_v39 s):num`) THEN POP_ASSUM(fun th-> ASM_REWRITE_TAC[SYM th]) THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`scs_a_v39 s (((j MOD k' + p MOD scs_k_v39 s) MOD scs_k_v39 s))`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th `((i MOD k' + p MOD scs_k_v39 s)):num`) THEN POP_ASSUM(fun th-> ASM_REWRITE_TAC[SYM th]) THEN REPLICATE_TAC (34-15)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MATCH_MP_TAC th) THEN MRESAL_TAC DIVISION[`(i MOD k' + p MOD scs_k_v39 s):num`;`scs_k_v39 s:num`][ARITH_RULE`~(6=0)`] THEN MRESAL_TAC DIVISION[`(j MOD k' + p MOD scs_k_v39 s):num`;`scs_k_v39 s`][ARITH_RULE`~(6=0)`] THEN STRIP_TAC THEN MRESAL_TAC Hdplygy.MOD_EQ_MOD[`i MOD k':num`;`j MOD k':num`;`p MOD scs_k_v39 s`;`scs_k_v39 s`][ADD_SYM] THEN POP_ASSUM MP_TAC THEN MRESA_TAC MOD_LT[`i:num`;`k':num`] THEN MRESA_TAC MOD_LT[`j:num`;`k':num`] THEN MP_TAC(ARITH_RULE`i< k' /\ k'< scs_k_v39 s /\ j<k' ==> i< scs_k_v39 s /\ j< scs_k_v39 s`) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`i:num`;`scs_k_v39 s`] THEN MRESA_TAC MOD_LT[`j:num`;`scs_k_v39 s`] ; DISJ_CASES_TAC(SET_RULE`{i MOD 3, SUC i MOD 3} = {0, 3-1} \/ ~({i MOD 3, SUC i MOD 3} = {0, 3-1})`); ASM_REWRITE_TAC[] ; ASM_REWRITE_TAC[] THEN MRESAL_TAC DIVISION[`i:num`;`k':num`][ARITH_RULE`~(3=0)`] THEN MP_TAC(ARITH_RULE`3<= k' /\ k' <scs_k_v39 s ==> 3< scs_k_v39 s`) THEN RESA_TAC THEN ASM_TAC THEN REWRITE_TAC[periodic2;] THEN REPEAT STRIP_TAC THEN MP_TAC(ARITH_RULE`3<= scs_k_v39 s ==> ~(scs_k_v39 s = 0)`) THEN RESA_TAC THEN MP_TAC(ARITH_RULE`(i ) MOD 3 < 3 ==> (i ) MOD 3 =0 \/ (i ) MOD 3 =1 \/ (i ) MOD 3 =2`) THEN RESA_TAC ; MRESAL_TAC(GEN_ALL IMP_SUC_MOD_EQ)[`i:num`;`0`;`3`][ARITH_RULE`0 MOD 3=0 /\ 1 MOD 3=1/\ 2 MOD 3=2/\ SUC 0=1/\ SUC 1=2 /\ SUC 2=3/\ 3 MOD 3=0/\ ~(3=0)/\ 0+A=A /\ 1+A= SUC A`] THEN REPLICATE_TAC (37-17)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESAL1_TAC th `p MOD scs_k_v39 s` [ARITH_RULE`SUC 0=1/\ SUC 1=2/\ SUC 2=3`;cstab]) THEN POP_ASSUM MP_TAC THEN REAL_ARITH_TAC; MRESAL_TAC(GEN_ALL IMP_SUC_MOD_EQ)[`i:num`;`1`;`3`][ARITH_RULE`0 MOD 3=0 /\ 1 MOD 3=1/\ 2 MOD 3=2/\ SUC 0=1/\ SUC 1=2 /\ SUC 2=3/\ 3 MOD 3=0/\ ~(3=0)/\ 2+A=SUC(1+A) `] THEN REPLICATE_TAC (37-17)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESAL1_TAC th `1+p MOD scs_k_v39 s` [ARITH_RULE`SUC 0=1/\ SUC 1=2/\ SUC 2=3`;cstab]) THEN POP_ASSUM MP_TAC THEN REAL_ARITH_TAC; MRESAL_TAC(GEN_ALL IMP_SUC_MOD_EQ)[`i:num`;`2`;`3`][ARITH_RULE`0 MOD 3=0 /\ 1 MOD 3=1/\ 2 MOD 3=2/\ SUC 0=1/\ SUC 1=2 /\ SUC 2=3/\ 3 MOD 3=0/\ ~(3=0)/\ 2+A=SUC(1+A) `] THEN POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[th;ARITH_RULE`3-1=2`] THEN REPEAT STRIP_TAC) THEN POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[th;ARITH_RULE`3-1=2`] THEN REPEAT STRIP_TAC) THEN REPLICATE_TAC (4) REMOVE_ASSUM_TAC THEN POP_ASSUM MP_TAC THEN SET_TAC[]; DISJ_CASES_TAC(SET_RULE`{i MOD k', SUC i MOD k'} = {0, k'-1} \/ ~({i MOD k', SUC i MOD k'} = {0, k'-1})`); ASM_REWRITE_TAC[] THEN MP_TAC(ARITH_RULE`3<k' /\ k'< scs_k_v39 s ==> 4< scs_k_v39 s`) THEN RESA_TAC THEN REPLICATE_TAC (6) (POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th) THEN RESA_TAC ; ASM_REWRITE_TAC[] THEN MP_TAC(ARITH_RULE`3<= k' /\ k' <scs_k_v39 s ==> 3< scs_k_v39 s/\ ~(k'=0) /\ 1< k'/\ k'-1< k'/\ SUC(k'-1)= k'`) THEN RESA_TAC THEN MRESAL_TAC DIVISION[`i:num`;`k':num`][ARITH_RULE`~(3=0)`] THEN ASM_TAC THEN REWRITE_TAC[periodic2;] THEN REPEAT STRIP_TAC THEN MP_TAC(ARITH_RULE`3<= scs_k_v39 s ==> ~(scs_k_v39 s = 0)`) THEN RESA_TAC THEN REWRITE_TAC[ADD1] THEN MRESA_TAC MOD_ADD_MOD[`i:num`;`1:num`;`k':num`] THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN MRESA_TAC MOD_LT[`1`;`k':num`] THEN MP_TAC(ARITH_RULE`3<k' /\ i MOD k' < k' ==> i MOD k' =k'-1 \/ i MOD k' +1 < k' `) THEN RESA_TAC ; MRESA_TAC MOD_LT[`k'-1`;`k':num`] THEN MRESAL_TAC MOD_MULT[`k':num`;`1`][ARITH_RULE`A* 1=A`] THEN MRESAL_TAC(GEN_ALL IMP_SUC_MOD_EQ)[`i:num`;`k'-1`;`k':num`][ARITH_RULE`0 MOD 3=0 /\ 1 MOD 3=1/\ 2 MOD 3=2/\ SUC 0=1/\ SUC 1=2 /\ SUC 2=3/\ 3 MOD 3=0/\ ~(3=0)/\ 2+A=SUC(1+A) `] THEN POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[th] THEN REPEAT STRIP_TAC) THEN REPLICATE_TAC (2) REMOVE_ASSUM_TAC THEN POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[th] THEN REPEAT STRIP_TAC) THEN REPLICATE_TAC (8) REMOVE_ASSUM_TAC THEN POP_ASSUM MP_TAC THEN SET_TAC[]; MRESAL_TAC MOD_LT[`i MOD k' +1`;`k':num`][ARITH_RULE`(i MOD k' + 1) + p MOD scs_k_v39 s= SUC(i MOD k' + p MOD scs_k_v39 s)`] THEN REPLICATE_TAC (42-17)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MATCH_MP_TAC th) THEN ASM_REWRITE_TAC[]; POP_ASSUM MP_TAC THEN DISJ_CASES_TAC(SET_RULE`{i MOD k', j MOD k'} = {0, k' - 1} \/ ~({i MOD k', j MOD k'} = {0, k' - 1})`) ; ASM_REWRITE_TAC[]; MP_TAC(SET_RULE`{i MOD k', j MOD k'} = {0, k' - 1} ==> (i MOD k'= 0 /\ j MOD k' = k'-1)\/ (i MOD k'= k'-1 /\ j MOD k' = 0)`) THEN RESA_TAC; MP_TAC(ARITH_RULE`3<= k' /\ k' <scs_k_v39 s ==> 3< scs_k_v39 s/\ ~(k'=0) /\ 1< k'/\ k'-1< k'/\ SUC(k'-1)= k'`) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`k'-1`;`k':num`] THEN MRESAL_TAC MOD_MULT[`k':num`;`1`][ARITH_RULE`A* 1=A`] THEN MRESAL_TAC(GEN_ALL IMP_SUC_MOD_EQ)[`j:num`;`k'-1`;`k':num`][ARITH_RULE`0 MOD 3=0 /\ 1 MOD 3=1/\ 2 MOD 3=2/\ SUC 0=1/\ SUC 1=2 /\ SUC 2=3/\ 3 MOD 3=0/\ ~(3=0)/\ 2+A=SUC(1+A) `] ; MP_TAC(ARITH_RULE`3<= k' /\ k' <scs_k_v39 s ==> 3< scs_k_v39 s/\ ~(k'=0) /\ 1< k'/\ k'-1< k'/\ SUC(k'-1)= k'/\ ~(scs_k_v39 s =0)`) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`k'-1`;`k':num`] THEN MRESAL_TAC MOD_MULT[`k':num`;`1`][ARITH_RULE`A* 1=A`] THEN MRESAL_TAC(GEN_ALL IMP_SUC_MOD_EQ)[`i:num`;`k'-1`;`k':num`][ARITH_RULE`0 MOD 3=0 /\ 1 MOD 3=1/\ 2 MOD 3=2/\ SUC 0=1/\ SUC 1=2 /\ SUC 2=3/\ 3 MOD 3=0/\ ~(3=0)/\ 2+A=SUC(1+A) `] ; ASM_REWRITE_TAC[] THEN STRIP_TAC THEN REPLICATE_TAC (31-18)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESAL_TAC th[`(i MOD k' + p MOD scs_k_v39 s)`;`(j MOD k' + p MOD scs_k_v39 s)`][ARITH_RULE`SUC(A+B)= SUC A+B`]) ; MP_TAC(ARITH_RULE`3<= k' /\ k' <scs_k_v39 s ==> 3< scs_k_v39 s/\ ~(k'=0) /\ 1< k'/\ k'-1< k'/\ SUC(k'-1)= k'/\ ~(scs_k_v39 s =0)`) THEN RESA_TAC THEN MRESAL_TAC Hdplygy.MOD_EQ_MOD[`j MOD k':num`;`SUC(i MOD k'):num`;`p MOD scs_k_v39 s`;`scs_k_v39 s`][ADD_SYM] THEN POP_ASSUM MP_TAC THEN MRESAL_TAC DIVISION[`(i):num`;`k':num`][ARITH_RULE`~(6=0)`] THEN MRESAL_TAC DIVISION[`(j):num`;`k':num`][ARITH_RULE`~(6=0)`] THEN MP_TAC(ARITH_RULE`j MOD k' < k' /\ k'< scs_k_v39 s /\ i MOD k' < k' ==> j MOD k' < scs_k_v39 s /\ SUC (i MOD k') < scs_k_v39 s`) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`j MOD k'`;`scs_k_v39 s:num`] THEN MRESA_TAC MOD_LT[`SUC(i MOD k')`;`scs_k_v39 s:num`] THEN RESA_TAC THEN MP_TAC(ARITH_RULE`3<=k' /\ i MOD k' < k' ==> i MOD k' =k'-1 \/ i MOD k' +1 < k' `) THEN RESA_TAC ; POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[th] THEN REPEAT STRIP_TAC) THEN POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[] THEN REPLICATE_TAC (4) REMOVE_ASSUM_TAC THEN POP_ASSUM MP_TAC THEN ARITH_TAC; REWRITE_TAC[ADD1] THEN MRESA_TAC MOD_ADD_MOD[`i:num`;`1:num`;`k':num`] THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN MRESA_TAC MOD_LT[`1`;`k':num`] THEN MRESA_TAC MOD_LT[`i MOD k' + 1`;`k':num`] ; MP_TAC(ARITH_RULE`3<= k' /\ k' <scs_k_v39 s ==> 3< scs_k_v39 s/\ ~(k'=0) /\ 1< k'/\ k'-1< k'/\ SUC(k'-1)= k'/\ ~(scs_k_v39 s =0)`) THEN RESA_TAC THEN MRESAL_TAC Hdplygy.MOD_EQ_MOD[`i MOD k':num`;`SUC(j MOD k'):num`;`p MOD scs_k_v39 s`;`scs_k_v39 s`][ADD_SYM] THEN POP_ASSUM MP_TAC THEN MRESAL_TAC DIVISION[`(i):num`;`k':num`][ARITH_RULE`~(6=0)`] THEN MRESAL_TAC DIVISION[`(j):num`;`k':num`][ARITH_RULE`~(6=0)`] THEN MP_TAC(ARITH_RULE`j MOD k' < k' /\ k'< scs_k_v39 s /\ i MOD k' < k' ==> SUC(j MOD k') < scs_k_v39 s /\ (i MOD k') < scs_k_v39 s`) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`i MOD k'`;`scs_k_v39 s:num`] THEN MRESA_TAC MOD_LT[`SUC(j MOD k')`;`scs_k_v39 s:num`] THEN RESA_TAC THEN MP_TAC(ARITH_RULE`3<=k' /\ j MOD k' < k' ==> j MOD k' =k'-1 \/ j MOD k' +1 < k' `) THEN RESA_TAC ; POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[th] THEN REPEAT STRIP_TAC) THEN POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[] THEN REPLICATE_TAC (5) REMOVE_ASSUM_TAC THEN POP_ASSUM MP_TAC THEN ARITH_TAC; REWRITE_TAC[ADD1] THEN MRESA_TAC MOD_ADD_MOD[`j:num`;`1:num`;`k':num`] THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN MRESA_TAC MOD_LT[`1`;`k':num`] THEN MRESA_TAC MOD_LT[`j MOD k' + 1`;`k':num`] ; POP_ASSUM MP_TAC THEN DISJ_CASES_TAC(SET_RULE`{i MOD k', j MOD k'} = {0, k' - 1} \/ ~({i MOD k', j MOD k'} = {0, k' - 1})`) ; ASM_REWRITE_TAC[] THEN STRIP_TAC THEN REPLICATE_TAC (36-3)(POP_ASSUM MP_TAC) THEN POP_ASSUM (fun th-> REPEAT STRIP_TAC THEN MP_TAC th THEN ASM_REWRITE_TAC[is_ear_v39;scs_half_slice_v39;LET_DEF;LET_END_DEF;scs_half_slice_v39;is_scs_v39;scs_diag;scs_v39_explicit]) THEN STRIP_TAC THEN ABBREV_TAC`k''=(p + 1 + scs_k_v39 s - q MOD scs_k_v39 s) MOD scs_k_v39 s` THEN SUBGOAL_THEN`k'' -1 IN {i | i < 3 /\ (if {i MOD k'', SUC i MOD k''} = {0, k'' - 1} then T else scs_J_v39 s (i MOD k'' + q MOD scs_k_v39 s) (SUC i MOD k'' + q MOD scs_k_v39 s))}` ASSUME_TAC ; REWRITE_TAC[IN_ELIM_THM] THEN ASM_REWRITE_TAC[ARITH_RULE`3-1=2 /\ 2<3 /\ 2 MOD 3=2/\ SUC 2=3/\ 3 MOD 3=0 `;SET_RULE`{A,B}={B,A}`]; POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[ARITH_RULE`3-1=2`;SET_RULE`( a = b <=> b=a)`;IN_SING] THEN REPLICATE_TAC (3)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th) THEN ASM_REWRITE_TAC[ARITH_RULE`3-1=2 /\ 2<3 /\ 2 MOD 3=2/\ SUC 2=3/\ 3 MOD 3=0 `] THEN RESA_TAC; ASM_REWRITE_TAC[] THEN STRIP_TAC THEN REPLICATE_TAC (36-24)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESA_TAC th[`(i MOD k' + p MOD scs_k_v39 s)`;`(j MOD k' + p MOD scs_k_v39 s)`]) ; POP_ASSUM MP_TAC THEN DISJ_CASES_TAC(SET_RULE`{i MOD k', j MOD k'} = {0, k' - 1} \/ ~({i MOD k', j MOD k'} = {0, k' - 1})`) ; ASM_REWRITE_TAC[] THEN STRIP_TAC THEN REPLICATE_TAC (36-3)(POP_ASSUM MP_TAC) THEN POP_ASSUM (fun th-> REPEAT STRIP_TAC THEN MP_TAC th THEN ASM_REWRITE_TAC[is_ear_v39;scs_half_slice_v39;LET_DEF;LET_END_DEF;scs_half_slice_v39;is_scs_v39;scs_diag;scs_v39_explicit]) THEN STRIP_TAC THEN ABBREV_TAC`k''=(p + 1 + scs_k_v39 s - q MOD scs_k_v39 s) MOD scs_k_v39 s` THEN SUBGOAL_THEN`k'' -1 IN {i | i < 3 /\ (if {i MOD k'', SUC i MOD k''} = {0, k'' - 1} then T else scs_J_v39 s (i MOD k'' + q MOD scs_k_v39 s) (SUC i MOD k'' + q MOD scs_k_v39 s))}` ASSUME_TAC ; REWRITE_TAC[IN_ELIM_THM] THEN ASM_REWRITE_TAC[ARITH_RULE`3-1=2 /\ 2<3 /\ 2 MOD 3=2/\ SUC 2=3/\ 3 MOD 3=0 `;SET_RULE`{A,B}={B,A}`]; POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[ARITH_RULE`3-1=2`;SET_RULE`( a = b <=> b=a)`;IN_SING] THEN REPLICATE_TAC (2)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th) THEN ASM_REWRITE_TAC[ARITH_RULE`3-1=2 /\ 2<3 /\ 2 MOD 3=2/\ SUC 2=3/\ 3 MOD 3=0 `] THEN RESA_TAC; ASM_REWRITE_TAC[] THEN STRIP_TAC THEN REPLICATE_TAC (36-24)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESA_TAC th[`(i MOD k' + p MOD scs_k_v39 s)`;`(j MOD k' + p MOD scs_k_v39 s)`]) ; SUBGOAL_THEN`IMAGE (\x. (x+p MOD scs_k_v39 s )MOD scs_k_v39 s ) {i | i < k' /\ (&2 * h0 < (if {i MOD k', SUC i MOD k'} = {0, k' - 1} then scs_bm_v39 s p q else scs_b_v39 s (i MOD k' + p MOD scs_k_v39 s) (SUC i MOD k' + p MOD scs_k_v39 s)) \/ &2 < (if {i MOD k', SUC i MOD k'} = {0, k' - 1} then scs_am_v39 s p q else scs_a_v39 s (i MOD k' + p MOD scs_k_v39 s) (SUC i MOD k' + p MOD scs_k_v39 s)))} SUBSET {i | i < scs_k_v39 s /\ (&2 * h0 < scs_b_v39 s i (SUC i) \/ &2 < scs_a_v39 s i (SUC i))} UNION {(k'-1 + p MOD scs_k_v39 s) MOD scs_k_v39 s}` ASSUME_TAC; REWRITE_TAC[SUBSET;UNION;IN_ELIM_THM;IN_SING;IMAGE] THEN GEN_TAC THEN RESA_TAC; REMOVE_ASSUM_TAC THEN POP_ASSUM MP_TAC THEN MP_TAC(ARITH_RULE`x'<k'==> x'= k'-1\/ SUC x' < k' `) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`x':num`;`k':num`] THEN MRESA_TAC MOD_LT[`SUC x':num`;`k':num`] THEN DISJ_CASES_TAC(SET_RULE`{x', SUC x'} = {0, k' - 1} \/ ~({x', SUC x'} = {0, k' - 1})`) ; MP_TAC(SET_RULE`{x', SUC x'} = {0, k' - 1} ==> (x' =0 /\ SUC x' = k'-1)\/ (x' =k'-1/\ SUC x' =0)`) THEN RESA_TAC THEN POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[ARITH_RULE`SUC 0= k'-1<=> k'=2`] THEN STRIP_TAC THEN POP_ASSUM (fun th-> REPLICATE_TAC (40-32)(REMOVE_ASSUM_TAC) THEN POP_ASSUM MP_TAC THEN REWRITE_TAC[th]) THEN ARITH_TAC ; ASM_REWRITE_TAC[] THEN STRIP_TAC THEN MATCH_MP_TAC(SET_RULE`A==>A \/ B`) THEN MP_TAC(ARITH_RULE`k' < scs_k_v39 s /\ 3<= k' /\ x'< k' /\ SUC x' < k' ==> ~(scs_k_v39 s=0) /\ x'< scs_k_v39 s/\ SUC x' < scs_k_v39 s/\ 1< scs_k_v39 s`) THEN RESA_TAC THEN MRESAL_TAC DIVISION[`x' + p MOD scs_k_v39 s`;`scs_k_v39 s`][ARITH_RULE`~(6=0)`] THEN MATCH_MP_TAC(SET_RULE`A==>A \/ B`) THEN MRESA_TAC MOD_LT[`x':num`;`scs_k_v39 s`] THEN MRESA_TAC MOD_LT[`SUC x':num`;`scs_k_v39 s`] THEN MRESA_TAC MOD_ADD_MOD[`x':num`;`p:num`;`scs_k_v39 s`] THEN MRESA_TAC MOD_ADD_MOD[`SUC x':num`;`p:num`;`scs_k_v39 s`] THEN REPLICATE_TAC (10)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th) THEN ASM_TAC THEN REWRITE_TAC[periodic2;] THEN REPEAT STRIP_TAC THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`scs_b_v39 s (x' + p MOD scs_k_v39 s)`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th `(SUC x' + p MOD scs_k_v39 s):num`) THEN POP_ASSUM(fun th-> POP_ASSUM MP_TAC THEN REWRITE_TAC[SYM th]) THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`scs_b_v39 s ((SUC x' + p) MOD scs_k_v39 s)`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th `(x' + p MOD scs_k_v39 s):num`) THEN POP_ASSUM(fun th-> ASM_REWRITE_TAC[SYM th]) THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`scs_b_v39 s ((x' + p) MOD scs_k_v39 s)`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th `(SUC ((x' + p) MOD scs_k_v39 s)):num`) THEN POP_ASSUM(fun th-> ASM_REWRITE_TAC[SYM th;ADD1]) THEN MRESA_TAC MOD_LT[`1:num`;`scs_k_v39 s`] THEN MRESA_TAC MOD_ADD_MOD[`(x' + p):num`;`1:num`;`scs_k_v39 s`] THEN STRIP_TAC THEN ASM_REWRITE_TAC[ARITH_RULE`(x' + p) + 1=(x' + 1) + p`] ; REMOVE_ASSUM_TAC THEN POP_ASSUM MP_TAC THEN MP_TAC(ARITH_RULE`x'<k'==> x'= k'-1\/ SUC x' < k' `) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`x':num`;`k':num`] THEN MRESA_TAC MOD_LT[`SUC x':num`;`k':num`] THEN DISJ_CASES_TAC(SET_RULE`{x', SUC x'} = {0, k' - 1} \/ ~({x', SUC x'} = {0, k' - 1})`) ; MP_TAC(SET_RULE`{x', SUC x'} = {0, k' - 1} ==> (x' =0 /\ SUC x' = k'-1)\/ (x' =k'-1/\ SUC x' =0)`) THEN RESA_TAC THEN POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[ARITH_RULE`SUC 0= k'-1<=> k'=2`] THEN STRIP_TAC THEN POP_ASSUM (fun th-> REPLICATE_TAC (40-32)(REMOVE_ASSUM_TAC) THEN POP_ASSUM MP_TAC THEN REWRITE_TAC[th]) THEN ARITH_TAC ; ASM_REWRITE_TAC[] THEN STRIP_TAC THEN MATCH_MP_TAC(SET_RULE`A==>A \/ B`) THEN MP_TAC(ARITH_RULE`k' < scs_k_v39 s /\ 3<= k' /\ x'< k' /\ SUC x' < k' ==> ~(scs_k_v39 s=0) /\ x'< scs_k_v39 s/\ SUC x' < scs_k_v39 s/\ 1< scs_k_v39 s`) THEN RESA_TAC THEN MRESAL_TAC DIVISION[`x' + p MOD scs_k_v39 s`;`scs_k_v39 s`][ARITH_RULE`~(6=0)`] THEN MATCH_MP_TAC(SET_RULE`B==>A \/ B`) THEN MRESA_TAC MOD_LT[`x':num`;`scs_k_v39 s`] THEN MRESA_TAC MOD_LT[`SUC x':num`;`scs_k_v39 s`] THEN MRESA_TAC MOD_ADD_MOD[`x':num`;`p:num`;`scs_k_v39 s`] THEN MRESA_TAC MOD_ADD_MOD[`SUC x':num`;`p:num`;`scs_k_v39 s`] THEN REPLICATE_TAC (10)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th) THEN ASM_TAC THEN REWRITE_TAC[periodic2;] THEN REPEAT STRIP_TAC THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`scs_a_v39 s (x' + p MOD scs_k_v39 s)`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th `(SUC x' + p MOD scs_k_v39 s):num`) THEN POP_ASSUM(fun th-> POP_ASSUM MP_TAC THEN REWRITE_TAC[SYM th]) THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`scs_a_v39 s ((SUC x' + p) MOD scs_k_v39 s)`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th `(x' + p MOD scs_k_v39 s):num`) THEN POP_ASSUM(fun th-> ASM_REWRITE_TAC[SYM th]) THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`scs_a_v39 s ((x' + p) MOD scs_k_v39 s)`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th `(SUC ((x' + p) MOD scs_k_v39 s)):num`) THEN POP_ASSUM(fun th-> ASM_REWRITE_TAC[SYM th;ADD1]) THEN MRESA_TAC MOD_LT[`1:num`;`scs_k_v39 s`] THEN MRESA_TAC MOD_ADD_MOD[`(x' + p):num`;`1:num`;`scs_k_v39 s`] THEN STRIP_TAC THEN ASM_REWRITE_TAC[ARITH_RULE`(x' + p) + 1=(x' + 1) + p`] ; SUBGOAL_THEN`CARD(IMAGE (\x. (x+p MOD scs_k_v39 s )MOD scs_k_v39 s ) {i | i < k' /\ (&2 * h0 < (if {i MOD k', SUC i MOD k'} = {0, k' - 1} then scs_bm_v39 s p q else scs_b_v39 s (i MOD k' + p MOD scs_k_v39 s) (SUC i MOD k' + p MOD scs_k_v39 s)) \/ &2 < (if {i MOD k', SUC i MOD k'} = {0, k' - 1} then scs_am_v39 s p q else scs_a_v39 s (i MOD k' + p MOD scs_k_v39 s) (SUC i MOD k' + p MOD scs_k_v39 s)))}) = CARD {i | i < k' /\ (&2 * h0 < (if {i MOD k', SUC i MOD k'} = {0, k' - 1} then scs_bm_v39 s p q else scs_b_v39 s (i MOD k' + p MOD scs_k_v39 s) (SUC i MOD k' + p MOD scs_k_v39 s)) \/ &2 < (if {i MOD k', SUC i MOD k'} = {0, k' - 1} then scs_am_v39 s p q else scs_a_v39 s (i MOD k' + p MOD scs_k_v39 s) (SUC i MOD k' + p MOD scs_k_v39 s)))}`ASSUME_TAC ; MATCH_MP_TAC CARD_IMAGE_INJ THEN STRIP_TAC; REWRITE_TAC[IN_ELIM_THM] THEN REPEAT STRIP_TAC THEN MP_TAC(ARITH_RULE`3<= k' /\ k' <scs_k_v39 s /\ x<k' /\y< k' ==> 3< scs_k_v39 s/\ ~(k'=0) /\ 1< k'/\ k'-1< k'/\ SUC(k'-1)= k'/\ ~(scs_k_v39 s =0) /\ x< scs_k_v39 s/\ y< scs_k_v39 s`) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`x:num`;`scs_k_v39 s`] THEN MRESA_TAC MOD_LT[`y:num`;`scs_k_v39 s`] THEN MRESAL_TAC Hdplygy.MOD_EQ_MOD[`x:num`;`y:num`;`p MOD scs_k_v39 s`;`scs_k_v39 s`][ADD_SYM] ; MATCH_MP_TAC FINITE_SUBSET THEN EXISTS_TAC`0.. k'` THEN REWRITE_TAC[FINITE_NUMSEG;SUBSET;IN_ELIM_THM;IN_NUMSEG] THEN ARITH_TAC; POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN SUBGOAL_THEN`FINITE ({i | i < scs_k_v39 s /\ (&2 * h0 < scs_b_v39 s i (SUC i) \/ &2 < scs_a_v39 s i (SUC i))} UNION {(k' - 1 + p MOD scs_k_v39 s) MOD scs_k_v39 s})`ASSUME_TAC ; REWRITE_TAC[FINITE_UNION;FINITE_SING] THEN MATCH_MP_TAC FINITE_SUBSET THEN EXISTS_TAC`0.. (scs_k_v39 s)` THEN REWRITE_TAC[FINITE_NUMSEG;SUBSET;IN_ELIM_THM;IN_NUMSEG] THEN ARITH_TAC; MRESA_TAC CARD_SUBSET[`IMAGE (\x. (x+p MOD scs_k_v39 s )MOD scs_k_v39 s ) {i | i < k' /\ (&2 * h0 < (if {i MOD k', SUC i MOD k'} = {0, k' - 1} then scs_bm_v39 s p q else scs_b_v39 s (i MOD k' + p MOD scs_k_v39 s) (SUC i MOD k' + p MOD scs_k_v39 s)) \/ &2 < (if {i MOD k', SUC i MOD k'} = {0, k' - 1} then scs_am_v39 s p q else scs_a_v39 s (i MOD k' + p MOD scs_k_v39 s) (SUC i MOD k' + p MOD scs_k_v39 s)))}`;`{i | i < scs_k_v39 s /\ (&2 * h0 < scs_b_v39 s i (SUC i) \/ &2 < scs_a_v39 s i (SUC i))} UNION {(k'-1 + p MOD scs_k_v39 s) MOD scs_k_v39 s}`] THEN SUBGOAL_THEN`FINITE ({i | i < scs_k_v39 s /\ (&2 * h0 < scs_b_v39 s i (SUC i) \/ &2 < scs_a_v39 s i (SUC i))})`ASSUME_TAC ; REWRITE_TAC[FINITE_UNION;FINITE_SING] THEN MATCH_MP_TAC FINITE_SUBSET THEN EXISTS_TAC`0.. (scs_k_v39 s)` THEN REWRITE_TAC[FINITE_NUMSEG;SUBSET;IN_ELIM_THM;IN_NUMSEG] THEN ARITH_TAC; MRESAL_TAC CARD_UNION_LE[`{i | i < scs_k_v39 s /\ (&2 * h0 < scs_b_v39 s i (SUC i) \/ &2 < scs_a_v39 s i (SUC i))}`;`{(k' - 1 + p MOD scs_k_v39 s) MOD scs_k_v39 s}`][FINITE_SING;Geomdetail.CARD_SING] THEN POP_ASSUM MP_TAC THEN REMOVE_ASSUM_TAC THEN POP_ASSUM MP_TAC THEN REMOVE_ASSUM_TAC THEN REMOVE_ASSUM_TAC THEN POP_ASSUM MP_TAC THEN REPLICATE_TAC (8) REMOVE_ASSUM_TAC THEN REPEAT STRIP_TAC THEN ABBREV_TAC`a= CARD ({i | i < scs_k_v39 s /\ (&2 * h0 < scs_b_v39 s i (SUC i) \/ &2 < scs_a_v39 s i (SUC i))} UNION {(k' - 1 + p MOD scs_k_v39 s) MOD scs_k_v39 s})` THEN ABBREV_TAC`b=CARD {i | i < scs_k_v39 s /\ (&2 * h0 < scs_b_v39 s i (SUC i) \/ &2 < scs_a_v39 s i (SUC i))}` THEN ABBREV_TAC`c=CARD (IMAGE (\x. (x + p MOD scs_k_v39 s) MOD scs_k_v39 s) {i | i < k' /\ (&2 * h0 < (if {i MOD k', SUC i MOD k'} = {0, k' - 1} then scs_bm_v39 s p q else scs_b_v39 s (i MOD k' + p MOD scs_k_v39 s) (SUC i MOD k' + p MOD scs_k_v39 s)) \/ &2 < (if {i MOD k', SUC i MOD k'} = {0, k' - 1} then scs_am_v39 s p q else scs_a_v39 s (i MOD k' + p MOD scs_k_v39 s) (SUC i MOD k' + p MOD scs_k_v39 s)))})` THEN MP_TAC(ARITH_RULE`c<=a /\ a<= b+1 /\ k'< scs_k_v39 s/\ b + scs_k_v39 s <= 6 ==> c+k' <=6`) THEN RESA_TAC]);;
let SCS_HALF_SLICE_IS_A_SCS=
prove_by_refinement( ` is_scs_v39 s /\ scs_diag (scs_k_v39 s) p q /\ is_scs_slice_v39 s s' s'' p q ==> is_scs_v39 s'`,
(* {{{ proof *) [ STRIP_TAC THEN POP_ASSUM MP_TAC THEN MP_TAC SCS_K_PRIME_CASE_3 THEN RESA_TAC THEN MP_TAC(ARITH_RULE`3 < scs_k_v39 s ==> scs_k_v39 s =4\/ (4 < scs_k_v39 s /\ ~(scs_k_v39 s=4))`) THEN RESA_TAC; ASM_REWRITE_TAC[is_scs_slice_v39;LET_DEF;LET_END_DEF;scs_diag;scs_v39_explicit;scs_slice_v39;PAIR_EQ] THEN STRIP_TAC THEN ABBREV_TAC`k'=scs_k_v39 s'` THEN ABBREV_TAC`d'=scs_d_v39 s'` THEN ABBREV_TAC`d''=scs_d_v39 s''` THEN ABBREV_TAC`mkj=scs_J_v39 s' 0 (k'-1)` THEN ABBREV_TAC`vv' = (\i. (vv:num->real^3) ((i) MOD k'+p MOD (scs_k_v39 s)))` THEN REPLICATE_TAC 4 (POP_ASSUM MP_TAC) THEN ASM_REWRITE_TAC[] THEN REPEAT STRIP_TAC; DISJ_CASES_TAC(SET_RULE`~(scs_J_v39 s' 0 (k'-1)) \/ scs_J_v39 s' 0 (k'-1)`); MP_TAC SCS_HALF_SLICE_IS_SCS_4 THEN ASM_REWRITE_TAC[scs_diag] THEN POP_ASSUM MP_TAC THEN RESA_TAC; REPLICATE_TAC 6 (POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th THEN POP_ASSUM MP_TAC THEN RESA_TAC) THEN STRIP_TAC; MATCH_MP_TAC IS_EAR_IS_SCS THEN ASM_REWRITE_TAC[]; MP_TAC SCS_HALF_SLICE_IS_SCS_4_PRIME THEN ASM_REWRITE_TAC[scs_diag] THEN RESA_TAC THEN REPLICATE_TAC 4 (POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN POP_ASSUM MP_TAC THEN MP_TAC th) THEN RESA_TAC; ASM_REWRITE_TAC[is_scs_slice_v39;LET_DEF;LET_END_DEF;scs_diag;scs_v39_explicit;scs_slice_v39;PAIR_EQ] THEN STRIP_TAC THEN ABBREV_TAC`k'=scs_k_v39 s'` THEN ABBREV_TAC`d'=scs_d_v39 s'` THEN ABBREV_TAC`d''=scs_d_v39 s''` THEN ABBREV_TAC`mkj=scs_J_v39 s' 0 (k'-1)` THEN ABBREV_TAC`vv' = (\i. (vv:num->real^3) ((i) MOD k'+p MOD (scs_k_v39 s)))` THEN REPLICATE_TAC 4 (POP_ASSUM MP_TAC) THEN ASM_REWRITE_TAC[] THEN REPEAT STRIP_TAC; DISJ_CASES_TAC(SET_RULE`~(scs_J_v39 s' 0 (k'-1)) \/ scs_J_v39 s' 0 (k'-1)`); MP_TAC SCS_HALF_SLICE_IS_SCS THEN ASM_REWRITE_TAC[scs_diag] THEN POP_ASSUM MP_TAC THEN RESA_TAC; REPLICATE_TAC 6 (POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th THEN POP_ASSUM MP_TAC THEN RESA_TAC) THEN STRIP_TAC; MATCH_MP_TAC IS_EAR_IS_SCS THEN ASM_REWRITE_TAC[]; MP_TAC SCS_HALF_SLICE_IS_SCS_PRIME THEN ASM_REWRITE_TAC[scs_diag] THEN RESA_TAC THEN REPLICATE_TAC 4 (POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN POP_ASSUM MP_TAC THEN MP_TAC th) THEN RESA_TAC]);;
let NOT_EQ_DIAG=
prove(` is_scs_v39 s /\ scs_diag (scs_k_v39 s) p q /\ dist(vv (p MOD (scs_k_v39 s)) ,vv (q MOD (scs_k_v39 s))) <= cstab /\ BBs_v39 s vv ==> ~(vv (p MOD (scs_k_v39 s)) =vv (q MOD (scs_k_v39 s)))`,
STRIP_TAC THEN POP_ASSUM(fun thH-> ASSUME_TAC thH THEN MP_TAC SCS_K_PRIME_CASE_3 THEN RESA_TAC THEN POP_ASSUM(fun th-> ASM_TAC THEN ASSUME_TAC th THEN MP_TAC(ARITH_RULE`3<scs_k_v39 s==> ~(scs_k_v39 s<=3)`)) THEN ASM_REWRITE_TAC[scs_diag;BBs_v39;LET_DEF;LET_END_DEF;] THEN RESA_TAC THEN ASSUME_TAC thH) THEN ABBREV_TAC`k= scs_k_v39 s` THEN REPEAT STRIP_TAC THEN POP_ASSUM MP_TAC THEN MRESAL_TAC (GEN_ALL IS_SCS_NOT_COLLINEAR_BBs_CASE_LE_3)[`p:num`;`vv:num->real^3`;`q:num`;`s:scs_v39`][IN] THEN POP_ASSUM MP_TAC THEN ONCE_REWRITE_TAC[SET_RULE`{A,B,C}={B,A,C}`] THEN STRIP_TAC THEN MRESA_TAC th3[`(vv:num->real^3) (p MOD k)`;`vec 0:real^3`;`(vv:num->real^3) (q MOD k)`]);;
let IN_IMAGE_VV=
prove(` vv p IN IMAGE vv (:num)`,
REWRITE_TAC[IMAGE;IN_ELIM_THM] THEN EXISTS_TAC`p:num` THEN SET_TAC[]);;
let SUC_MOD_NOT_EQ=
prove(` 1<k ==> !i. ~(i MOD k= SUC i MOD k)`,
STRIP_TAC THEN INDUCT_TAC THENL[ MP_TAC(ARITH_RULE`1<k==> 0<k/\ SUC 0=1`) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`0`;`k:num`] THEN MRESAL_TAC MOD_LT[`1`;`k:num`][ADD1] THEN ARITH_TAC; POP_ASSUM MP_TAC THEN REWRITE_TAC[ADD1] THEN MP_TAC(ARITH_RULE`1<k ==> ~(k=0)/\ SUC 0=1/\ i<= i+1 `) THEN RESA_TAC THEN STRIP_TAC THEN MRESAL_TAC (GEN_ALL Hdplygy.MOD_EQ_MOD1)[`i+1:num`;`i:num`;`1`;`k:num`][ADD_SYM]]);;
let IS_SCS_NOT_COLLINEAR_BBs_CASE_LE_PRIME_3=
prove_by_refinement( `3< scs_k_v39 s/\ is_scs_v39 s /\ vv IN BBs_v39 s ==> ~collinear{vec 0, vv (i MOD (scs_k_v39 s)) ,vv ((SUC i) MOD (scs_k_v39 s))}`,
[ REWRITE_TAC[Local_lemmas.collinear_fan22;aff;AFFINE_HULL_2;IN_ELIM_THM;VECTOR_ARITH`A % vec 0+B=B`;cstab] THEN STRIP_TAC THEN MRESA_TAC( GEN_ALL IS_SCS_POINT_IN_BBS_IS_NOT_0_LE_3)[`s:scs_v39`;`vv:num->real^3`;`i MOD scs_k_v39 s`] THEN RESA_TAC THEN ASM_TAC THEN REWRITE_TAC[IN] THEN STRIP_TAC THEN ASM_REWRITE_TAC[scs_k_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;LET_DEF;LET_END_DEF;BBs_v39;ARITH_RULE`3<=3`;mk_unadorned_v39;CS_ADJ;is_scs_v39] THEN POP_ASSUM(fun th-> STRIP_TAC THEN ASSUME_TAC th) THEN REPEAT STRIP_TAC; MP_TAC(ARITH_RULE`3 < scs_k_v39 s==> ~(scs_k_v39 s <= 3)`) THEN RESA_TAC; ABBREV_TAC`k=scs_k_v39 s` THEN POP_ASSUM MP_TAC THEN MP_TAC(ARITH_RULE`3<=k ==> ~(k=0)/\ 1<k`) THEN RESA_TAC THEN STRIP_TAC THEN MRESA_TAC DIVISION[`i:num`;`k:num`] THEN MRESA_TAC DIVISION[`SUC i:num`;`k:num`] THEN POP_ASSUM MP_TAC THEN MP_TAC SUC_MOD_NOT_EQ THEN RESA_TAC THEN POP_ASSUM(fun th-> MRESA1_TAC th`i:num`) THEN STRIP_TAC THEN REPLICATE_TAC (35-14) (POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESAL_TAC th[`i MOD k`;`(SUC i) MOD k`][scs_k_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;LET_DEF;LET_END_DEF;BBs_v39;ARITH_RULE`3<=3`;mk_unadorned_v39;CS_ADJ; ARITH_RULE`1 MOD 3 =1 /\ 2 MOD 3=2/\ ~(1=2) /\ SUC 1=2 /\ SUC 2=3/\ 3 MOD 3=0/\ 1<3/\ 2<3`;dist;VECTOR_ARITH`A- B%A=(&1-B)%A`;NORM_MUL]) THEN REPLICATE_TAC (35-25)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th) THEN REPLICATE_TAC (34-22) (POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN POP_ASSUM MP_TAC THEN MRESAL_TAC th[`i MOD k`;`(SUC i) MOD k`][scs_k_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;LET_DEF;LET_END_DEF;BBs_v39;ARITH_RULE`3<=3`;mk_unadorned_v39;CS_ADJ; ARITH_RULE`1 MOD 3 =1 /\ 2 MOD 3=2/\ ~(1=2) /\ SUC 1=2 /\ SUC 2=3/\ 3 MOD 3=0`;dist;VECTOR_ARITH`A- B%A=(&1-B)%A`;NORM_MUL]) THEN REPLICATE_TAC (35-20)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th) THEN SUBGOAL_THEN`(?x. x IN (:num) /\ vv (i MOD k) = (vv:num->real^3) x)`ASSUME_TAC; EXISTS_TAC`i MOD k` THEN ASM_REWRITE_TAC[SET_RULE`(a:num)IN (:num)`]; SUBGOAL_THEN`(?x. x IN (:num) /\ vv ((SUC i) MOD k) = (vv:num->real^3) x)`ASSUME_TAC; EXISTS_TAC`SUC(i) MOD k` THEN ASM_REWRITE_TAC[SET_RULE`(a:num)IN (:num)`]; REWRITE_TAC[IMAGE;SUBSET;IN_ELIM_THM] THEN STRIP_TAC THEN POP_ASSUM(fun th-> MRESAL1_TAC th`(vv:num->real^3) (i MOD k)`[ball_annulus;IN_ELIM_THM;DIFF;cball;ball;dist;VECTOR_ARITH`vec 0- B= --B`;NORM_NEG;NORM_MUL;REAL_ARITH`~(a<b) <=> b<=a`] THEN MRESAL1_TAC th`(vv:num->real^3) ((SUC i) MOD k)`[ball_annulus;IN_ELIM_THM;DIFF;cball;ball;dist;VECTOR_ARITH`vec 0- B= --B`;NORM_NEG;NORM_MUL;REAL_ARITH`~(a<b) <=> b<=a`]) THEN MP_TAC(REAL_ARITH`&0<= &1-v\/ &0<= --( &1-v)`) THEN STRIP_TAC; MP_TAC(REAL_ARITH`&0<= v\/ &0<= --( v)`) THEN STRIP_TAC; MRESA1_TAC Trigonometry2.ABS_REFL `v:real` THEN MRESA1_TAC Trigonometry2.ABS_REFL `&1- v:real` THEN POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[th] THEN REPEAT STRIP_TAC) THEN POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[th] THEN REPEAT STRIP_TAC) THEN MP_TAC(REAL_ARITH`&2 <=scs_a_v39 s (i MOD k) ((SUC i) MOD k)/\ scs_a_v39 s (i MOD k) ((SUC i) MOD k)<= (&1 - v) * norm (vv (i MOD k)) /\ &2 <= v * norm (vv (i MOD k)) ==> &4<= norm ((vv:num->real^3) (i MOD k))`) THEN REPLICATE_TAC 6(POP_ASSUM MP_TAC) THEN ASM_REWRITE_TAC[h0] THEN REAL_ARITH_TAC; MRESAL1_TAC Trigonometry2.ABS_REFL `-- v:real`[REAL_ABS_NEG] THEN MRESA1_TAC Trigonometry2.ABS_REFL `&1- v:real` THEN POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[th] THEN REPEAT STRIP_TAC) THEN POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[th; ] THEN REPEAT STRIP_TAC) THEN MP_TAC(REAL_ARITH`&2 <= --v * norm (vv (i MOD k)) /\ &2 <= norm (vv (i MOD k)) ==> &4<=(&1- v) *norm ((vv:num->real^3) (i MOD k) )`) THEN ASM_REWRITE_TAC[] THEN REPLICATE_TAC (45-15)(POP_ASSUM MP_TAC) THEN POP_ASSUM (fun th-> REPEAT STRIP_TAC THEN POP_ASSUM MP_TAC THEN MRESA1_TAC th`i:num` THEN ASM_REWRITE_TAC[]) THEN ASM_TAC THEN REWRITE_TAC[periodic2] THEN REPEAT STRIP_TAC THEN REPLICATE_TAC (2)(POP_ASSUM MP_TAC) THEN MRESAL_TAC (GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`scs_b_v39 s i`][periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th`SUC i:num`) THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN MRESAL_TAC (GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`scs_b_v39 s ((SUC i MOD k))`][periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th`i:num`) THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN REPLICATE_TAC (44-33)(POP_ASSUM MP_TAC) THEN POP_ASSUM (fun th-> REPEAT STRIP_TAC THEN POP_ASSUM MP_TAC THEN POP_ASSUM MP_TAC THEN MP_TAC th) THEN ASM_REWRITE_TAC[cstab] THEN REAL_ARITH_TAC; MP_TAC(REAL_ARITH`&0<= v\/ &0<= --( v)`) THEN STRIP_TAC; MRESAL1_TAC Trigonometry2.ABS_REFL ` v:real`[REAL_ABS_NEG] THEN MRESAL1_TAC Trigonometry2.ABS_REFL `--(&1- v):real` [REAL_ABS_NEG] THEN POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[th] THEN REPEAT STRIP_TAC) THEN POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[th; ] THEN REPEAT STRIP_TAC) THEN MP_TAC(REAL_ARITH`&2 <= norm (vv (i MOD k)) /\ &2 <= scs_a_v39 s (i MOD k) ((SUC i) MOD k)/\ scs_a_v39 s (i MOD k) ((SUC i) MOD k)<= --(&1 - v) * norm (vv (i MOD k)) ==> &4<= v *norm ((vv:num->real^3) (i MOD k))`) THEN ASM_REWRITE_TAC[] THEN REPLICATE_TAC 3(POP_ASSUM MP_TAC) THEN POP_ASSUM (fun th-> REPEAT STRIP_TAC THEN MP_TAC th) THEN POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[h0] THEN REAL_ARITH_TAC; MRESAL1_TAC Trigonometry2.ABS_REFL ` --v:real`[REAL_ABS_NEG] THEN MRESAL1_TAC Trigonometry2.ABS_REFL `--(&1- v):real` [REAL_ABS_NEG] THEN POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[th] THEN REPEAT STRIP_TAC) THEN POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[th; ] THEN REPEAT STRIP_TAC) THEN MP_TAC(REAL_ARITH`&2 <= norm (vv (i MOD k)) /\ &2 <= --v * norm (vv (i MOD k)) ==> &4<= (&1-v) *norm ((vv:num->real^3) (i MOD k))`) THEN ASM_REWRITE_TAC[REAL_ARITH`~(a<= b) <=> b<a`] THEN REPLICATE_TAC (45-32)(POP_ASSUM MP_TAC) THEN POP_ASSUM (fun th-> REPEAT STRIP_TAC THEN MP_TAC th) THEN REPLICATE_TAC (44-32)(POP_ASSUM MP_TAC) THEN POP_ASSUM (fun th-> REPEAT STRIP_TAC THEN MP_TAC th) THEN POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[] THEN REAL_ARITH_TAC;]);;
(* }}} *)
let DIAG_NOT_IN_EDGES=
prove_by_refinement( `is_scs_v39 s /\ scs_diag (scs_k_v39 s) p q /\ dist(u ,w) <= cstab /\ (vv:num->real^3) (p MOD (scs_k_v39 s))=u /\ (vv:num->real^3) (q MOD (scs_k_v39 s))=w /\ E= IMAGE (\i. {vv i, vv (SUC i)}) (:num) /\ BBs_v39 s vv ==> ~({u,w} IN E)`,
[RESA_TAC THEN MP_TAC SCS_K_PRIME_CASE_3 THEN RESA_TAC THEN REWRITE_TAC[IMAGE;IN_ELIM_THM;scs_diag] THEN STRIP_TAC THEN MP_TAC(SET_RULE`{u, w} = {vv x, vv (SUC x)}==> (u= vv x /\ w= vv (SUC x))\/(u= (vv:num->real^3) (SUC x) /\ w= vv (x))`) THEN RESA_TAC; ASM_TAC THEN REWRITE_TAC[scs_k_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;LET_DEF;LET_END_DEF;BBs_v39;ARITH_RULE`3<=3`;mk_unadorned_v39;CS_ADJ;BBs_v39;is_scs_v39;scs_diag] THEN REPEAT RESA_TAC; MP_TAC(ARITH_RULE`3< scs_k_v39 s==> ~(scs_k_v39 s<= 3)`) THEN RESA_TAC; POP_ASSUM MP_TAC THEN POP_ASSUM MP_TAC THEN MP_TAC(ARITH_RULE`3< scs_k_v39 s==> ~(scs_k_v39 s= 0)`) THEN RESA_TAC THEN MRESAL_TAC (GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`vv:num->real^3`][periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th`x:num` THEN MRESA1_TAC th`SUC x:num`) THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN MRESA_TAC DIVISION[`x:num`;`scs_k_v39 s`] THEN MRESA_TAC DIVISION[`p:num`;`scs_k_v39 s`] THEN MRESA_TAC DIVISION[`q:num`;`scs_k_v39 s`] THEN MRESA_TAC DIVISION[`SUC x:num`;`scs_k_v39 s`] THEN REPLICATE_TAC (42-14) (POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESA_TAC th[`x MOD scs_k_v39 s`;`p MOD scs_k_v39 s`] THEN MRESA_TAC th[`SUC x MOD scs_k_v39 s`;`q MOD scs_k_v39 s`]) THEN REPLICATE_TAC (45-28) (POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESAL_TAC th[`x MOD scs_k_v39 s`;`p MOD scs_k_v39 s`][DIST_REFL] THEN MRESAL_TAC th[`SUC x MOD scs_k_v39 s`;`q MOD scs_k_v39 s`][DIST_REFL]) THEN REPLICATE_TAC (6) (POP_ASSUM MP_TAC) THEN MP_TAC(SET_RULE`~(x MOD scs_k_v39 s = p MOD scs_k_v39 s) \/ (x MOD scs_k_v39 s = p MOD scs_k_v39 s)`) THEN RESA_TAC; REAL_ARITH_TAC; MP_TAC(SET_RULE`~(SUC x MOD scs_k_v39 s = q MOD scs_k_v39 s) \/ (SUC x MOD scs_k_v39 s = q MOD scs_k_v39 s)`) THEN RESA_TAC; REAL_ARITH_TAC; REPEAT STRIP_TAC THEN REPLICATE_TAC (3) (REMOVE_ASSUM_TAC) THEN POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[SYM th;]) THEN REPEAT STRIP_TAC THEN MRESAL_TAC (GEN_ALL Zithlqn.IMP_SUC_MOD_EQ)[`x:num`;`p:num`;`scs_k_v39 s`][]; ASM_TAC THEN REWRITE_TAC[scs_k_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;LET_DEF;LET_END_DEF;BBs_v39;ARITH_RULE`3<=3`;mk_unadorned_v39;CS_ADJ;BBs_v39;is_scs_v39;scs_diag] THEN REPEAT RESA_TAC; MP_TAC(ARITH_RULE`3< scs_k_v39 s==> ~(scs_k_v39 s<= 3)`) THEN RESA_TAC; POP_ASSUM MP_TAC THEN POP_ASSUM MP_TAC THEN MP_TAC(ARITH_RULE`3< scs_k_v39 s==> ~(scs_k_v39 s= 0)`) THEN RESA_TAC THEN MRESAL_TAC (GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`vv:num->real^3`][periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th`x:num` THEN MRESA1_TAC th`SUC x:num`) THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN MRESA_TAC DIVISION[`x:num`;`scs_k_v39 s`] THEN MRESA_TAC DIVISION[`p:num`;`scs_k_v39 s`] THEN MRESA_TAC DIVISION[`q:num`;`scs_k_v39 s`] THEN MRESA_TAC DIVISION[`SUC x:num`;`scs_k_v39 s`] THEN REPLICATE_TAC (42-14) (POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESA_TAC th[`x MOD scs_k_v39 s`;`q MOD scs_k_v39 s`] THEN MRESA_TAC th[`SUC x MOD scs_k_v39 s`;`p MOD scs_k_v39 s`]) THEN REPLICATE_TAC (45-28) (POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESAL_TAC th[`x MOD scs_k_v39 s`;`q MOD scs_k_v39 s`][DIST_REFL] THEN MRESAL_TAC th[`SUC x MOD scs_k_v39 s`;`p MOD scs_k_v39 s`][DIST_REFL]) THEN REPLICATE_TAC (6) (POP_ASSUM MP_TAC) THEN MP_TAC(SET_RULE`~(x MOD scs_k_v39 s = q MOD scs_k_v39 s) \/ (x MOD scs_k_v39 s = q MOD scs_k_v39 s)`) THEN RESA_TAC; REAL_ARITH_TAC; MP_TAC(SET_RULE`~(SUC x MOD scs_k_v39 s = p MOD scs_k_v39 s) \/ (SUC x MOD scs_k_v39 s = p MOD scs_k_v39 s)`) THEN RESA_TAC; REAL_ARITH_TAC; REPEAT STRIP_TAC THEN REPLICATE_TAC (3) (REMOVE_ASSUM_TAC) THEN POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[SYM th;]) THEN REPEAT STRIP_TAC THEN MRESAL_TAC (GEN_ALL Zithlqn.IMP_SUC_MOD_EQ)[`x:num`;`q:num`;`scs_k_v39 s`][]]);;
let SCS_K_LE_6=
prove(`is_scs_v39 s ==> scs_k_v39 s<=6`,
let TECOXBMv2=
prove_by_refinement( `is_scs_v39 s /\ scs_diag (scs_k_v39 s) p q /\ dist(u ,w) <= cstab /\ (vv:num->real^3) (p MOD (scs_k_v39 s))=u /\ (vv:num->real^3) (q MOD (scs_k_v39 s))=w /\ IMAGE (vv:num->real^3) (:num)=V/\ IMAGE (\i. {vv i,(vv:num->real^3) (SUC i)}) (:num) =E/\ IMAGE (\i. (vv i,(vv:num->real^3) (SUC i))) (:num)=FF /\ BBs_v39 s vv ==> (!x. x IN FF ==> aff_gt {vec 0} {u, w} SUBSET wedge_in_fan_gt x E)`,
[ REWRITE_TAC[dist] THEN REPEAT STRIP_TAC THEN MP_TAC IS_SCS_STABLE_SYSTEM THEN ASM_REWRITE_TAC[ARITH_RULE`3<4`] THEN MP_TAC SCS_K_PRIME_CASE_3 THEN RESA_TAC THEN MP_TAC SCS_K_LE_6 THEN RESA_TAC THEN STRIP_TAC THEN ABBREV_TAC`s1 =stable_sy((scs_k_v39 s),(scs_d_v39 s),(0..scs_k_v39 s - 1), (change_type_v3 (scs_a_v39 s)), (change_type_v3 (scs_b_v39 s)), (change_type_v2 (scs_J_v39 s) (scs_k_v39 s)), (\i. (1 + i) MOD scs_k_v39 s))` THEN MRESA_TAC stable_sy_explicit[`(scs_k_v39 s)`;`(scs_d_v39 s)`;`(0..scs_k_v39 s - 1)`;` (change_type_v3 (scs_a_v39 s))`;` (change_type_v3 (scs_b_v39 s))`;` (change_type_v2 (scs_J_v39 s) (scs_k_v39 s))`;` (\i. (1 + i) MOD scs_k_v39 s)`] THEN MP_TAC(ARITH_RULE`3 < scs_k_v39 s /\ scs_k_v39 s<=6 ==> scs_k_v39 s=4 \/ scs_k_v39 s=5 \/ scs_k_v39 s=6`) THEN RESA_TAC; POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[th] THEN ASSUME_TAC th) THEN REPEAT STRIP_TAC THEN ABBREV_TAC`v=vector[(vv:num->real^3) 1;(vv:num->real^3) 2;(vv:num->real^3) 3;(vv:num->real^3) 0]:real^3^(2+2)` THEN ABBREV_TAC`a=matvec (v:real^3^(2+2))` THEN MP_TAC(INST_TYPE [`:2+2`,`:M`]V_E_FF_IS_SCS_CASES_4) THEN ASM_REWRITE_TAC[Basics.DIMINDEX_4;IN] THEN STRIP_TAC THEN MP_TAC(INST_TYPE [`:2+2`,`:M`]IN_IS_SCS_CASE_4) THEN ASM_REWRITE_TAC[Basics.DIMINDEX_4;IN] THEN STRIP_TAC THEN SUBGOAL_THEN`{u, w} SUBSET V_SY (v:real^3^(2+2))` ASSUME_TAC; REWRITE_TAC[SET_RULE`{a,b} SUBSET A<=> a IN A /\ b IN A`] THEN MRESA_TAC (GEN_ALL IN_IMAGE_VV)[`p MOD scs_k_v39 s`;`vv:num->real^3`] THEN MRESA_TAC (GEN_ALL IN_IMAGE_VV)[`q MOD scs_k_v39 s`;`vv:num->real^3`]; SUBGOAL_THEN`&2 <= norm (u - w:real^3)` ASSUME_TAC; ASM_TAC THEN REWRITE_TAC[is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;IN;mk_unadorned_v39;scs_diag] THEN REPEAT RESA_TAC; ASM_TAC THEN ARITH_TAC; REPLICATE_TAC (51-32)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESAL_TAC th [`p MOD scs_k_v39 s`;`q MOD scs_k_v39 s`] [ARITH_RULE`SUC 0=1/\ SUC 1=2/\ SUC 2=3`;cstab;dist]) THEN MRESAL_TAC DIVISION[`p:num`;`scs_k_v39 s`][ARITH_RULE`~(4=0)`] THEN MRESAL_TAC DIVISION[`q:num`;`scs_k_v39 s`][ARITH_RULE`~(4=0)`] THEN REPLICATE_TAC (56-15)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESAL_TAC th [`p MOD scs_k_v39 s`;`q MOD scs_k_v39 s`] [ARITH_RULE`SUC 0=1/\ SUC 1=2/\ SUC 2=3`;cstab;dist]) THEN REPLICATE_TAC (58-48)(POP_ASSUM MP_TAC) THEN REAL_ARITH_TAC; MP_TAC DIAG_NOT_IN_EDGES THEN ASM_REWRITE_TAC[dist;IN] THEN STRIP_TAC THEN MRESA_TAC(GEN_ALL (INST_TYPE [`:2+2`,`:M`]Tecoxbm.TECOXBM))[`scs_d_v39 s`; `(change_type_v2 (scs_J_v39 s) (scs_k_v39 s))`;`(scs_k_v39 s)`;`(change_type_v3 (scs_a_v39 s))`;`(change_type_v3 (scs_b_v39 s))`;`u:real^3`;`w:real^3`;`matvec (v:real^3^(2+2))`] THEN POP_ASSUM MP_TAC THEN EXPAND_TAC"a" THEN REWRITE_TAC[Dih2k_hypermap.VECMATS_MATVEC_ID] THEN ASM_REWRITE_TAC[Basics.DIMINDEX_4;IN;B_SY1;ARITH_RULE`2<4`] THEN STRIP_TAC THEN POP_ASSUM MATCH_MP_TAC THEN ASM_TAC THEN REWRITE_TAC[IN] THEN REPEAT RESA_TAC; POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[th] THEN ASSUME_TAC th) THEN REPEAT STRIP_TAC THEN ABBREV_TAC`v=vector[(vv:num->real^3) 1;(vv:num->real^3) 2;(vv:num->real^3) 3;(vv:num->real^3) 4;(vv:num->real^3) 0]:real^3^(2+3)` THEN ABBREV_TAC`a=matvec (v:real^3^(2+3))` THEN MP_TAC(INST_TYPE [`:2+3`,`:M`]V_E_FF_IS_SCS_CASES_5) THEN ASM_REWRITE_TAC[Basics.DIMINDEX_5;IN] THEN STRIP_TAC THEN MP_TAC(INST_TYPE [`:2+3`,`:M`]IN_IS_SCS_CASE_5) THEN ASM_REWRITE_TAC[Basics.DIMINDEX_5;IN] THEN STRIP_TAC THEN SUBGOAL_THEN`{u, w} SUBSET V_SY (v:real^3^(2+3))` ASSUME_TAC; REWRITE_TAC[SET_RULE`{a,b} SUBSET A<=> a IN A /\ b IN A`] THEN MRESA_TAC (GEN_ALL IN_IMAGE_VV)[`p MOD scs_k_v39 s`;`vv:num->real^3`] THEN MRESA_TAC (GEN_ALL IN_IMAGE_VV)[`q MOD scs_k_v39 s`;`vv:num->real^3`]; SUBGOAL_THEN`&2 <= norm (u - w:real^3)` ASSUME_TAC; ASM_TAC THEN REWRITE_TAC[is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;IN;mk_unadorned_v39;scs_diag] THEN REPEAT RESA_TAC; ASM_TAC THEN ARITH_TAC; REPLICATE_TAC (50-31)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESAL_TAC th [`p MOD scs_k_v39 s`;`q MOD scs_k_v39 s`] [ARITH_RULE`SUC 0=1/\ SUC 1=2/\ SUC 2=3`;cstab;dist]) THEN MRESAL_TAC DIVISION[`p:num`;`scs_k_v39 s`][ARITH_RULE`~(5=0)`] THEN MRESAL_TAC DIVISION[`q:num`;`scs_k_v39 s`][ARITH_RULE`~(5=0)`] THEN REPLICATE_TAC (56-15)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESAL_TAC th [`p MOD scs_k_v39 s`;`q MOD scs_k_v39 s`] [ARITH_RULE`SUC 0=1/\ SUC 1=2/\ SUC 2=3`;cstab;dist]) THEN REPLICATE_TAC (57-48)(POP_ASSUM MP_TAC) THEN REAL_ARITH_TAC; MP_TAC DIAG_NOT_IN_EDGES THEN ASM_REWRITE_TAC[dist;IN] THEN STRIP_TAC THEN MRESA_TAC(GEN_ALL (INST_TYPE [`:2+3`,`:M`]Tecoxbm.TECOXBM))[`scs_d_v39 s`; `(change_type_v2 (scs_J_v39 s) (scs_k_v39 s))`;`(scs_k_v39 s)`;`(change_type_v3 (scs_a_v39 s))`;`(change_type_v3 (scs_b_v39 s))`;`u:real^3`;`w:real^3`;`matvec (v:real^3^(2+3))`] THEN POP_ASSUM MP_TAC THEN EXPAND_TAC"a" THEN REWRITE_TAC[Dih2k_hypermap.VECMATS_MATVEC_ID] THEN ASM_REWRITE_TAC[Basics.DIMINDEX_5;IN;B_SY1;ARITH_RULE`2<5`] THEN STRIP_TAC THEN POP_ASSUM MATCH_MP_TAC THEN ASM_TAC THEN REWRITE_TAC[IN] THEN REPEAT RESA_TAC; POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[th] THEN ASSUME_TAC th) THEN REPEAT STRIP_TAC THEN ABBREV_TAC`v=vector[(vv:num->real^3) 1;(vv:num->real^3) 2;(vv:num->real^3) 3;(vv:num->real^3) 4;(vv:num->real^3) 5;(vv:num->real^3) 0]:real^3^(3+3)` THEN ABBREV_TAC`a=matvec (v:real^3^(3+3))` THEN MP_TAC(INST_TYPE [`:3+3`,`:M`]V_E_FF_IS_SCS_CASES_6) THEN ASM_REWRITE_TAC[Basics.DIMINDEX_6;IN] THEN STRIP_TAC THEN MP_TAC(INST_TYPE [`:3+3`,`:M`]IN_IS_SCS_CASE_6) THEN ASM_REWRITE_TAC[Basics.DIMINDEX_6;IN] THEN STRIP_TAC THEN SUBGOAL_THEN`{u, w} SUBSET V_SY (v:real^3^(3+3))` ASSUME_TAC; REWRITE_TAC[SET_RULE`{a,b} SUBSET A<=> a IN A /\ b IN A`] THEN MRESA_TAC (GEN_ALL IN_IMAGE_VV)[`p MOD scs_k_v39 s`;`vv:num->real^3`] THEN MRESA_TAC (GEN_ALL IN_IMAGE_VV)[`q MOD scs_k_v39 s`;`vv:num->real^3`]; SUBGOAL_THEN`&2 <= norm (u - w:real^3)` ASSUME_TAC; ASM_TAC THEN REWRITE_TAC[is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;IN;mk_unadorned_v39;scs_diag] THEN REPEAT RESA_TAC; ASM_TAC THEN ARITH_TAC; REPLICATE_TAC (50-31)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESAL_TAC th [`p MOD scs_k_v39 s`;`q MOD scs_k_v39 s`] [ARITH_RULE`SUC 0=1/\ SUC 1=2/\ SUC 2=3`;cstab;dist]) THEN MRESAL_TAC DIVISION[`p:num`;`scs_k_v39 s`][ARITH_RULE`~(6=0)`] THEN MRESAL_TAC DIVISION[`q:num`;`scs_k_v39 s`][ARITH_RULE`~(6=0)`] THEN REPLICATE_TAC (56-15)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESAL_TAC th [`p MOD scs_k_v39 s`;`q MOD scs_k_v39 s`] [ARITH_RULE`SUC 0=1/\ SUC 1=2/\ SUC 2=3`;cstab;dist]) THEN REPLICATE_TAC (57-48)(POP_ASSUM MP_TAC) THEN REAL_ARITH_TAC; MP_TAC DIAG_NOT_IN_EDGES THEN ASM_REWRITE_TAC[dist;IN] THEN STRIP_TAC THEN MRESA_TAC(GEN_ALL (INST_TYPE [`:3+3`,`:M`]Tecoxbm.TECOXBM))[`scs_d_v39 s`; `(change_type_v2 (scs_J_v39 s) (scs_k_v39 s))`;`(scs_k_v39 s)`;`(change_type_v3 (scs_a_v39 s))`;`(change_type_v3 (scs_b_v39 s))`;`u:real^3`;`w:real^3`;`matvec (v:real^3^(3+3))`] THEN POP_ASSUM MP_TAC THEN EXPAND_TAC"a" THEN REWRITE_TAC[Dih2k_hypermap.VECMATS_MATVEC_ID] THEN ASM_REWRITE_TAC[Basics.DIMINDEX_6;IN;B_SY1;ARITH_RULE`2<6`] THEN STRIP_TAC THEN POP_ASSUM MATCH_MP_TAC THEN ASM_TAC THEN REWRITE_TAC[IN] THEN REPEAT RESA_TAC; ]);;
let VV_SUC_EQ_RHO_NODE=
prove_by_refinement(`scs_k_v39 s =k /\ (vv:num->real^3) p1=u /\ IMAGE (vv:num->real^3) (:num)=V/\ IMAGE (\i. {vv i,(vv:num->real^3) (SUC i)}) (:num) =E/\ IMAGE (\i. (vv i,(vv:num->real^3) (SUC i))) (:num)=FF /\ is_scs_v39 s /\ scs_diag (scs_k_v39 s) p q /\ BBs_v39 s vv ==> (!m. ITER m (rho_node1 FF) u= vv (m+p1))`,
[STRIP_TAC THEN INDUCT_TAC; ASM_REWRITE_TAC[ITER;ARITH_RULE`0+p=p`]; ASM_REWRITE_TAC[ITER] THEN SUBGOAL_THEN`(vv:num->real^3) (m+p1), (vv:num->real^3) (SUC m+p1) IN FF ` ASSUME_TAC; EXPAND_TAC"FF" THEN REWRITE_TAC[IMAGE;IN_ELIM_THM] THEN EXISTS_TAC`m+p1:num` THEN REWRITE_TAC[ARITH_RULE`SUC m+p= SUC(m+p)`;SET_RULE`(a:num)IN(:num)`]; MATCH_MP_TAC(GEN_ALL Local_lemmas.DETER_RHO_NODE) THEN EXISTS_TAC`V:real^3->bool` THEN EXISTS_TAC`E:(real^3->bool)->bool` THEN ASM_REWRITE_TAC[] THEN MP_TAC SCS_K_PRIME_CASE_3 THEN RESA_TAC THEN POP_ASSUM(fun th-> ASM_TAC THEN ASSUME_TAC th THEN MP_TAC(ARITH_RULE`3<k==> ~(k<=3)`)) THEN ASM_REWRITE_TAC[scs_diag;BBs_v39;LET_DEF;LET_END_DEF;convex_local_fan] THEN REPEAT RESA_TAC]);;
let W_EW_K_SCS_ADD_P=
prove_by_refinement( ` scs_half_slice_v39 s p q d' mkj= s' /\ scs_k_v39 s'=k' /\ scs_k_v39 s =k /\ (vv:num->real^3) (p MOD k)=u /\ (vv:num->real^3) (q MOD k)=w /\ is_scs_v39 s /\ scs_diag (scs_k_v39 s) p q /\ BBs_v39 s vv ==> vv (k' - 1 + p MOD k) = w`,
[ ABBREV_TAC`V= IMAGE (vv:num->real^3) (:num)` THEN ABBREV_TAC`E= IMAGE (\i. {vv i,(vv:num->real^3) (SUC i)}) (:num)` THEN ABBREV_TAC`FF= IMAGE (\i. (vv i,(vv:num->real^3) (SUC i))) (:num)` THEN REPEAT STRIP_TAC THEN MP_TAC SCS_K_PRIME_CASE_3 THEN RESA_TAC THEN MP_TAC(ARITH_RULE`3<scs_k_v39 s ==> ~(scs_k_v39 s<=3)`) THEN RESA_TAC THEN POP_ASSUM (fun th-> REPLICATE_TAC 7 (POP_ASSUM MP_TAC) THEN ASSUME_TAC th) THEN ASM_REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;scs_half_slice_v39;is_scs_v39;scs_diag;scs_v39_explicit] THEN REPEAT RESA_TAC THEN REPLICATE_TAC (1) (POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN ASSUME_TAC th THEN MP_TAC th THEN REWRITE_TAC[convex_local_fan] THEN STRIP_TAC) THEN MRESA_TAC (GEN_ALL IN_IMAGE_VV)[`p MOD scs_k_v39 s`;`vv:num->real^3`] THEN MRESA_TAC (GEN_ALL IN_IMAGE_VV)[`q MOD scs_k_v39 s`;`vv:num->real^3`] THEN MRESA_TAC (GEN_ALL Local_lemmas1.POINT_PRESENTED_IN_RHOND1)[`E:(real^3->bool)->bool`;`V:real^3->bool`;`FF:real^3#real^3->bool`;`u:real^3`;`w:real^3`] THEN SUBGOAL_THEN`(!i. scs_b_v39 s i (SUC i) <= cstab)`ASSUME_TAC; REPLICATE_TAC (45-27)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MATCH_MP_TAC th) THEN ASM_REWRITE_TAC[]; REPLICATE_TAC (43-3)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th) THEN EXPAND_TAC"s'" THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist;periodic2;scs_half_slice_v39] THEN ASM_SIMP_TAC[REAL_ARITH`&0<= A+B -C<=> C<= A+B`] THEN STRIP_TAC THEN MRESA_TAC (GEN_ALL SCS_K_PRIME_LE_GE)[`s:scs_v39`;`p:num`;`q:num`;`d':real`;`scs_J_v39 s' p q`] THEN POP_ASSUM MP_TAC THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist;scs_half_slice_v39] THEN ASM_SIMP_TAC[REAL_ARITH`&0<= A+B -C<=> C<= A+B`] THEN RESA_TAC THEN MP_TAC(ARITH_RULE`3<=k==> ~(k=0)`) THEN RESA_TAC THEN MRESA_TAC DIVISION[`p:num`;`k:num`] THEN MP_TAC(ARITH_RULE`p MOD k< k==> 0< q + 1 + k - p MOD k`) THEN RESA_TAC THEN MP_TAC(ARITH_RULE`3<=k/\ 3<= (q + 1 + k - p MOD k) MOD k /\ p MOD k<k ==> (((q + 1 + k - p MOD k) MOD k - 1 + p MOD k) + k) =(q + 1 + k - p MOD k) MOD k +(k- 1 + p MOD k) `) THEN RESA_TAC THEN REPLICATE_TAC (52-32)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th) THEN REWRITE_TAC[periodic] THEN STRIP_TAC THEN POP_ASSUM(fun th-> MRESA1_TAC th`(q + 1 + k - p MOD k) MOD k - 1 + p MOD k` THEN POP_ASSUM(fun th1-> REWRITE_TAC[SYM th1]) THEN ASSUME_TAC th) THEN MRESA_TAC MOD_MOD_REFL[`(q + 1 + k - p MOD k)`;`k:num`] THEN MRESA_TAC MOD_ADD_MOD[`(q + 1 + k - p MOD k) :num`;`k - 1 + p MOD k:num`;`scs_k_v39 s`] THEN MP_TAC(ARITH_RULE`p MOD k< k /\ 3<=k==> (q + 1 + k - p MOD k) + k - 1 + p MOD k =q+ 2*k`) THEN RESA_TAC THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`vv:num->real^3`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th`q :num` THEN MRESA1_TAC th`q +2*k:num` THEN MRESA1_TAC th `((q + 1 + k - p MOD k) MOD k + k - 1 + p MOD k):num`) THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN MRESA_TAC MOD_ADD_MOD[`(q + 1 + k - p MOD k) MOD k:num`;`k - 1 + p MOD k:num`;`scs_k_v39 s`] THEN POP_ASSUM(fun th-> ASM_REWRITE_TAC[SYM th]) THEN REPLICATE_TAC (5)(REMOVE_ASSUM_TAC) THEN POP_ASSUM(fun th-> MRESA1_TAC th`q:num` THEN MRESAL1_TAC th`q+k:num`[ARITH_RULE`(A+B)+B=A+2*B`])]);;
let VV_INJ=
prove(` scs_k_v39 s =k /\ is_scs_v39 s /\ BBs_v39 s vv ==>(!i j. i<k /\ j< k /\ ~(i=j)==> ~(vv i= vv j))`,
REWRITE_TAC[is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist] THEN REPEAT STRIP_TAC THEN REPLICATE_TAC (5)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESAL_TAC th[`i:num`;`j:num`][VECTOR_ARITH`a-a= vec 0`;NORM_0]) THEN REPLICATE_TAC (29-15)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESA_TAC th[`i:num`;`j:num`]) THEN REPLICATE_TAC (3)(POP_ASSUM MP_TAC) THEN REAL_ARITH_TAC);;
let CARD_V_EQ_SCS_K=
prove_by_refinement( ` scs_k_v39 s =k /\ IMAGE (vv:num->real^3) (:num)=V/\ is_scs_v39 s /\ scs_diag (scs_k_v39 s) p q /\ BBs_v39 s vv ==> CARD V=k`,
[ REPEAT STRIP_TAC THEN MP_TAC IS_SCS_STABLE_SYSTEM THEN ASM_REWRITE_TAC[ARITH_RULE`3<4`] THEN MP_TAC SCS_K_PRIME_CASE_3 THEN RESA_TAC THEN MP_TAC SCS_K_LE_6 THEN RESA_TAC THEN STRIP_TAC THEN ABBREV_TAC`s1 =stable_sy((scs_k_v39 s),(scs_d_v39 s),(0..scs_k_v39 s - 1), (change_type_v3 (scs_a_v39 s)), (change_type_v3 (scs_b_v39 s)), (change_type_v2 (scs_J_v39 s) (scs_k_v39 s)), (\i. (1 + i) MOD scs_k_v39 s))` THEN MRESA_TAC stable_sy_explicit[`(scs_k_v39 s)`;`(scs_d_v39 s)`;`(0..scs_k_v39 s - 1)`;` (change_type_v3 (scs_a_v39 s))`;` (change_type_v3 (scs_b_v39 s))`;` (change_type_v2 (scs_J_v39 s) (scs_k_v39 s))`;` (\i. (1 + i) MOD scs_k_v39 s)`] THEN MP_TAC(ARITH_RULE`3 < scs_k_v39 s /\ scs_k_v39 s<=6 ==> scs_k_v39 s=4 \/ scs_k_v39 s=5 \/ scs_k_v39 s=6`) THEN RESA_TAC; POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[th] THEN ASSUME_TAC th) THEN REPEAT STRIP_TAC THEN ABBREV_TAC`v=vector[(vv:num->real^3) 1;(vv:num->real^3) 2;(vv:num->real^3) 3;(vv:num->real^3) 0]:real^3^(2+2)` THEN ABBREV_TAC`a=matvec (v:real^3^(2+2))` THEN MP_TAC(INST_TYPE [`:2+2`,`:M`]V_E_FF_IS_SCS_CASES_4) THEN ASM_REWRITE_TAC[Basics.DIMINDEX_4;IN] THEN STRIP_TAC THEN MRESAL_TAC (INST_TYPE [`:2+2`,`:M`]VECTOR_3_4)[`(vv:num->real^3) 1`;`(vv:num->real^3) 2`;`(vv:num->real^3) 3`;`(vv:num->real^3) 0`][ARITH_RULE`1<=4/\ 2<=4/\ 3<=4/\ 4<=4/\ 4 MOD 4= 0 /\ 1 MOD 4= 1 /\ 2 MOD 4= 2/\ 3 MOD 4= 3/\ ~(2=1) /\ SUC 4 MOD 4= 1 /\ SUC 1 MOD 4= 2 /\ SUC 2 MOD 4= 3/\ SUC 3 MOD 4= 0/\ ~(3=1)/\ ~(1=0)`;Basics.DIMINDEX_4] THEN EXPAND_TAC "V" THEN REWRITE_TAC[V_SY;rows;Basics.DIMINDEX_4;ARITH_RULE`1<=i /\ i<=4 <=> i=1\/ i=2\/ i=3 \/ i=4`;SET_RULE`{row i v | i = 1 \/ i = 2 \/ i = 3 \/ i = 4}={row 1 v, row 2 v, row 3 v,row 4 v}`] THEN ASM_REWRITE_TAC[] THEN MP_TAC VV_INJ THEN RESA_TAC THEN POP_ASSUM(fun th-> MRESAL_TAC th[`1`;`2`][ARITH_RULE`~(1=2)/\ ~(1=0) /\ ~(1=3)/\ ~(2=3)/\ ~(2=0)/\ ~(3=0)/\ 0<4/\ 1<4/\ 2<4/\ 3<4`] THEN MRESAL_TAC th[`1`;`3`][ARITH_RULE`~(1=2)/\ ~(1=0) /\ ~(1=3)/\ ~(2=3)/\ ~(2=0)/\ ~(3=0)/\ 0<4/\ 1<4/\ 2<4/\ 3<4`] THEN MRESAL_TAC th[`1`;`0`][ARITH_RULE`~(1=2)/\ ~(1=0) /\ ~(1=3)/\ ~(2=3)/\ ~(2=0)/\ ~(3=0)/\ 0<4/\ 1<4/\ 2<4/\ 3<4`] THEN MRESAL_TAC th[`2`;`0`][ARITH_RULE`~(1=2)/\ ~(1=0) /\ ~(1=3)/\ ~(2=3)/\ ~(2=0)/\ ~(3=0)/\ 0<4/\ 1<4/\ 2<4/\ 3<4`] THEN MRESAL_TAC th[`3`;`0`][ARITH_RULE`~(1=2)/\ ~(1=0) /\ ~(1=3)/\ ~(2=3)/\ ~(2=0)/\ ~(3=0)/\ 0<4/\ 1<4/\ 2<4/\ 3<4`] THEN MRESAL_TAC th[`2`;`3`][ARITH_RULE`~(1=2)/\ ~(1=0) /\ ~(1=3)/\ ~(2=3)/\ ~(2=0)/\ ~(3=0)/\ 0<4/\ 1<4/\ 2<4/\ 3<4`]) THEN SIMP_TAC[HAS_SIZE; CARD_CLAUSES; FINITE_INSERT; FINITE_EMPTY; IN_INSERT; NOT_IN_EMPTY] THEN ASM_REWRITE_TAC[] THEN ARITH_TAC; POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[th] THEN ASSUME_TAC th) THEN REPEAT STRIP_TAC THEN ABBREV_TAC`v=vector[(vv:num->real^3) 1;(vv:num->real^3) 2;(vv:num->real^3) 3;(vv:num->real^3) 4;(vv:num->real^3) 0]:real^3^(2+3)` THEN ABBREV_TAC`a=matvec (v:real^3^(2+3))` THEN MP_TAC(INST_TYPE [`:2+3`,`:M`]V_E_FF_IS_SCS_CASES_5) THEN ASM_REWRITE_TAC[Basics.DIMINDEX_5;IN] THEN STRIP_TAC THEN MRESAL_TAC (INST_TYPE [`:2+3`,`:M`]VECTOR_3_5)[`(vv:num->real^3) 1`;`(vv:num->real^3) 2`;`(vv:num->real^3) 3`;`(vv:num->real^3) 4`;`(vv:num->real^3) 0`;][ARITH_RULE`1<=5/\ 2<=5/\ 3<=5/\ 4<=5/\ 5<=5/\ 0 MOD 5= 0 /\ 1 MOD 5= 1 /\ 2 MOD 5= 2/\ 3 MOD 5= 3 /\ 4 MOD 5= 4 /\ 5 MOD 5=0 /\ ~(2=1) /\ SUC 0 MOD 5= 1 /\ SUC 1 MOD 5= 2 /\ SUC 2 MOD 5= 3/\ SUC 3 MOD 5= 4 /\ SUC 4 MOD 5= 0 /\ SUC 5 MOD 5 = 1 /\ ~(3=1)/\ ~(1=0)`;SET_RULE`(a:num) IN (:num)`;Basics.DIMINDEX_5] THEN EXPAND_TAC "V" THEN REWRITE_TAC[V_SY;rows;Basics.DIMINDEX_5;ARITH_RULE`1<=i /\ i<=5 <=> i=1\/ i=2\/ i=3 \/ i=4 \/ i=5`;SET_RULE`{row i v | i = 1 \/ i = 2 \/ i = 3 \/ i = 4\/ i=5}={row 1 v, row 2 v, row 3 v,row 4 v, row 5 v}`] THEN ASM_REWRITE_TAC[] THEN MP_TAC VV_INJ THEN RESA_TAC THEN POP_ASSUM(fun th-> MRESAL_TAC th[`1`;`2`][ARITH_RULE`~(1=2)/\ ~(1=0) /\ ~(1=3)/\ ~(2=3)/\ ~(2=0)/\ ~(3=0)/\ 0<5/\ 1<5/\ 2<5/\ 3<5/\ 4<5 /\ ~(3=4)/\ ~(1=4)/\ ~(2=4)/\ ~(0=4)`] THEN MRESAL_TAC th[`1`;`3`][ARITH_RULE`~(1=2)/\ ~(1=0) /\ ~(1=3)/\ ~(2=3)/\ ~(2=0)/\ ~(3=0)/\ 0<5/\ 1<5/\ 2<5/\ 3<5/\ 4<5 /\ ~(3=4)/\ ~(1=4)/\ ~(2=4)/\ ~(0=4)`] THEN MRESAL_TAC th[`1`;`0`][ARITH_RULE`~(1=2)/\ ~(1=0) /\ ~(1=3)/\ ~(2=3)/\ ~(2=0)/\ ~(3=0)/\ 0<5/\ 1<5/\ 2<5/\ 3<5/\ 4<5 /\ ~(3=4)/\ ~(1=4)/\ ~(2=4)/\ ~(0=4)`] THEN MRESAL_TAC th[`2`;`0`][ARITH_RULE`~(1=2)/\ ~(1=0) /\ ~(1=3)/\ ~(2=3)/\ ~(2=0)/\ ~(3=0)/\ 0<5/\ 1<5/\ 2<5/\ 3<5/\ 4<5 /\ ~(3=4)/\ ~(1=4)/\ ~(2=4)/\ ~(0=4)`] THEN MRESAL_TAC th[`3`;`0`][ARITH_RULE`~(1=2)/\ ~(1=0) /\ ~(1=3)/\ ~(2=3)/\ ~(2=0)/\ ~(3=0)/\ 0<5/\ 1<5/\ 2<5/\ 3<5/\ 4<5 /\ ~(3=4)/\ ~(1=4)/\ ~(2=4)/\ ~(0=4)`] THEN MRESAL_TAC th[`2`;`3`][ARITH_RULE`~(1=2)/\ ~(1=0) /\ ~(1=3)/\ ~(2=3)/\ ~(2=0)/\ ~(3=0)/\ 0<5/\ 1<5/\ 2<5/\ 3<5/\ 4<5 /\ ~(3=4)/\ ~(1=4)/\ ~(2=4)/\ ~(0=4)`] THEN MRESAL_TAC th[`1`;`4`][ARITH_RULE`~(1=2)/\ ~(1=0) /\ ~(1=3)/\ ~(2=3)/\ ~(2=0)/\ ~(3=0)/\ 0<5/\ 1<5/\ 2<5/\ 3<5/\ 4<5 /\ ~(3=4)/\ ~(1=4)/\ ~(2=4)/\ ~(0=4)`] THEN MRESAL_TAC th[`2`;`4`][ARITH_RULE`~(1=2)/\ ~(1=0) /\ ~(1=3)/\ ~(2=3)/\ ~(2=0)/\ ~(3=0)/\ 0<5/\ 1<5/\ 2<5/\ 3<5/\ 4<5 /\ ~(3=4)/\ ~(1=4)/\ ~(2=4)/\ ~(0=4)`] THEN MRESAL_TAC th[`3`;`4`][ARITH_RULE`~(1=2)/\ ~(1=0) /\ ~(1=3)/\ ~(2=3)/\ ~(2=0)/\ ~(3=0)/\ 0<5/\ 1<5/\ 2<5/\ 3<5/\ 4<5 /\ ~(3=4)/\ ~(1=4)/\ ~(2=4)/\ ~(0=4)`] THEN MRESAL_TAC th[`0`;`4`][ARITH_RULE`~(1=2)/\ ~(1=0) /\ ~(1=3)/\ ~(2=3)/\ ~(2=0)/\ ~(3=0)/\ 0<5/\ 1<5/\ 2<5/\ 3<5/\ 4<5 /\ ~(3=4)/\ ~(1=4)/\ ~(2=4)/\ ~(0=4)`]) THEN SIMP_TAC[HAS_SIZE; CARD_CLAUSES; FINITE_INSERT; FINITE_EMPTY; IN_INSERT; NOT_IN_EMPTY] THEN ASM_REWRITE_TAC[] THEN ARITH_TAC; POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[th] THEN ASSUME_TAC th) THEN REPEAT STRIP_TAC THEN ABBREV_TAC`v=vector[(vv:num->real^3) 1;(vv:num->real^3) 2;(vv:num->real^3) 3;(vv:num->real^3) 4;(vv:num->real^3) 5;(vv:num->real^3) 0]:real^3^(3+3)` THEN ABBREV_TAC`a=matvec (v:real^3^(3+3))` THEN MP_TAC(INST_TYPE [`:3+3`,`:M`]V_E_FF_IS_SCS_CASES_6) THEN ASM_REWRITE_TAC[Basics.DIMINDEX_6;IN] THEN STRIP_TAC THEN MRESAL_TAC (INST_TYPE [`:3+3`,`:M`]VECTOR_3_6)[`(vv:num->real^3) 1`;`(vv:num->real^3) 2`;`(vv:num->real^3) 3`;`(vv:num->real^3) 4`;`(vv:num->real^3) 5`;`(vv:num->real^3) 0`][ARITH_RULE`1<=6/\ 2<=6/\ 3<=6/\ 4<=6/\ 5<=6 /\ 6<=6 /\ 0 MOD 6= 0 /\ 1 MOD 6= 1 /\ 2 MOD 6= 2/\ 3 MOD 6= 3 /\ 4 MOD 6= 4 /\ 5 MOD 6=5 /\ 6 MOD 6=0 /\ ~(2=1) /\ SUC 0 MOD 6= 1 /\ SUC 1 MOD 6= 2 /\ SUC 2 MOD 6= 3/\ SUC 3 MOD 6= 4 /\ SUC 4 MOD 6= 5 /\ SUC 5 MOD 6 = 0 /\ SUC 6 MOD 6 =1 /\ ~(3=1)/\ ~(1=0)`;Basics.DIMINDEX_6] THEN EXPAND_TAC "V" THEN REWRITE_TAC[V_SY;rows;Basics.DIMINDEX_6;ARITH_RULE`1<=i /\ i<=6 <=> i=1\/ i=2\/ i=3 \/ i=4 \/ i=5\/ i=6`;SET_RULE`{row i v | i = 1 \/ i = 2 \/ i = 3 \/ i = 4\/ i=5 \/ i=6}={row 1 v, row 2 v, row 3 v,row 4 v, row 5 v, row 6 v}`] THEN ASM_REWRITE_TAC[] THEN MP_TAC VV_INJ THEN RESA_TAC THEN POP_ASSUM(fun th-> MRESAL_TAC th[`1`;`2`][ARITH_RULE`~(1=2)/\ ~(1=0) /\ ~(1=3)/\ ~(2=3)/\ ~(2=0)/\ ~(3=0) /\ ~(3=4)/\ ~(1=4)/\ ~(2=4)/\ ~(0=4)/\ 0<6/\ 1<6/\ 2<6/\ 3<6/\ 4<6/\ 5<6 /\ ~(0=5) /\ ~(1=5) /\ ~(2=5)/\ ~(3=5)/\ ~(4=5)`] THEN MRESAL_TAC th[`1`;`3`][ARITH_RULE`~(1=2)/\ ~(1=0) /\ ~(1=3)/\ ~(2=3)/\ ~(2=0)/\ ~(3=0)/\ ~(3=4)/\ ~(1=4)/\ ~(2=4)/\ ~(0=4)/\ 0<6/\ 1<6/\ 2<6/\ 3<6/\ 4<6/\ 5<6 /\ ~(0=5) /\ ~(1=5) /\ ~(2=5)/\ ~(3=5)/\ ~(4=5)`] THEN MRESAL_TAC th[`1`;`0`][ARITH_RULE`~(1=2)/\ ~(1=0) /\ ~(1=3)/\ ~(2=3)/\ ~(2=0)/\ ~(3=0)/\ ~(3=4)/\ ~(1=4)/\ ~(2=4)/\ ~(0=4)/\ 0<6/\ 1<6/\ 2<6/\ 3<6/\ 4<6/\ 5<6 /\ ~(0=5) /\ ~(1=5) /\ ~(2=5)/\ ~(3=5)/\ ~(4=5)`] THEN MRESAL_TAC th[`2`;`0`][ARITH_RULE`~(1=2)/\ ~(1=0) /\ ~(1=3)/\ ~(2=3)/\ ~(2=0)/\ ~(3=0)/\ ~(3=4)/\ ~(1=4)/\ ~(2=4)/\ ~(0=4)/\ 0<6/\ 1<6/\ 2<6/\ 3<6/\ 4<6/\ 5<6 /\ ~(0=5) /\ ~(1=5) /\ ~(2=5)/\ ~(3=5)/\ ~(4=5)`] THEN MRESAL_TAC th[`3`;`0`][ARITH_RULE`~(1=2)/\ ~(1=0) /\ ~(1=3)/\ ~(2=3)/\ ~(2=0)/\ ~(3=0)/\ ~(3=4)/\ ~(1=4)/\ ~(2=4)/\ ~(0=4)/\ 0<6/\ 1<6/\ 2<6/\ 3<6/\ 4<6/\ 5<6 /\ ~(0=5) /\ ~(1=5) /\ ~(2=5)/\ ~(3=5)/\ ~(4=5)`] THEN MRESAL_TAC th[`2`;`3`][ARITH_RULE`~(1=2)/\ ~(1=0) /\ ~(1=3)/\ ~(2=3)/\ ~(2=0)/\ ~(3=0)/\ ~(3=4)/\ ~(1=4)/\ ~(2=4)/\ ~(0=4)/\ 0<6/\ 1<6/\ 2<6/\ 3<6/\ 4<6/\ 5<6 /\ ~(0=5) /\ ~(1=5) /\ ~(2=5)/\ ~(3=5)/\ ~(4=5)`] THEN MRESAL_TAC th[`1`;`4`][ARITH_RULE`~(1=2)/\ ~(1=0) /\ ~(1=3)/\ ~(2=3)/\ ~(2=0)/\ ~(3=0)/\ ~(3=4)/\ ~(1=4)/\ ~(2=4)/\ ~(0=4)/\ 0<6/\ 1<6/\ 2<6/\ 3<6/\ 4<6/\ 5<6 /\ ~(0=5) /\ ~(1=5) /\ ~(2=5)/\ ~(3=5)/\ ~(4=5)`] THEN MRESAL_TAC th[`2`;`4`][ARITH_RULE`~(1=2)/\ ~(1=0) /\ ~(1=3)/\ ~(2=3)/\ ~(2=0)/\ ~(3=0)/\ ~(3=4)/\ ~(1=4)/\ ~(2=4)/\ ~(0=4)/\ 0<6/\ 1<6/\ 2<6/\ 3<6/\ 4<6/\ 5<6 /\ ~(0=5) /\ ~(1=5) /\ ~(2=5)/\ ~(3=5)/\ ~(4=5)`] THEN MRESAL_TAC th[`3`;`4`][ARITH_RULE`~(1=2)/\ ~(1=0) /\ ~(1=3)/\ ~(2=3)/\ ~(2=0)/\ ~(3=0)/\ ~(3=4)/\ ~(1=4)/\ ~(2=4)/\ ~(0=4)/\ 0<6/\ 1<6/\ 2<6/\ 3<6/\ 4<6/\ 5<6 /\ ~(0=5) /\ ~(1=5) /\ ~(2=5)/\ ~(3=5)/\ ~(4=5)`] THEN MRESAL_TAC th[`0`;`4`][ARITH_RULE`~(1=2)/\ ~(1=0) /\ ~(1=3)/\ ~(2=3)/\ ~(2=0)/\ ~(3=0)/\ ~(3=4)/\ ~(1=4)/\ ~(2=4)/\ ~(0=4)/\ 0<6/\ 1<6/\ 2<6/\ 3<6/\ 4<6/\ 5<6 /\ ~(0=5) /\ ~(1=5) /\ ~(2=5)/\ ~(3=5)/\ ~(4=5)`] THEN MRESAL_TAC th[`1`;`5`][ARITH_RULE`~(1=2)/\ ~(1=0) /\ ~(1=3)/\ ~(2=3)/\ ~(2=0)/\ ~(3=0)/\ ~(3=4)/\ ~(1=4)/\ ~(2=4)/\ ~(0=4)/\ 0<6/\ 1<6/\ 2<6/\ 3<6/\ 4<6/\ 5<6 /\ ~(0=5) /\ ~(1=5) /\ ~(2=5)/\ ~(3=5)/\ ~(4=5)`] THEN MRESAL_TAC th[`2`;`5`][ARITH_RULE`~(1=2)/\ ~(1=0) /\ ~(1=3)/\ ~(2=3)/\ ~(2=0)/\ ~(3=0)/\ ~(3=4)/\ ~(1=4)/\ ~(2=4)/\ ~(0=4)/\ 0<6/\ 1<6/\ 2<6/\ 3<6/\ 4<6/\ 5<6 /\ ~(0=5) /\ ~(1=5) /\ ~(2=5)/\ ~(3=5)/\ ~(4=5)`] THEN MRESAL_TAC th[`3`;`5`][ARITH_RULE`~(1=2)/\ ~(1=0) /\ ~(1=3)/\ ~(2=3)/\ ~(2=0)/\ ~(3=0)/\ ~(3=4)/\ ~(1=4)/\ ~(2=4)/\ ~(0=4)/\ 0<6/\ 1<6/\ 2<6/\ 3<6/\ 4<6/\ 5<6 /\ ~(0=5) /\ ~(1=5) /\ ~(2=5)/\ ~(3=5)/\ ~(4=5)`] THEN MRESAL_TAC th[`0`;`5`][ARITH_RULE`~(1=2)/\ ~(1=0) /\ ~(1=3)/\ ~(2=3)/\ ~(2=0)/\ ~(3=0)/\ ~(3=4)/\ ~(1=4)/\ ~(2=4)/\ ~(0=4)/\ 0<6/\ 1<6/\ 2<6/\ 3<6/\ 4<6/\ 5<6 /\ ~(0=5) /\ ~(1=5) /\ ~(2=5)/\ ~(3=5)/\ ~(4=5)`] THEN MRESAL_TAC th[`4`;`5`][ARITH_RULE`~(1=2)/\ ~(1=0) /\ ~(1=3)/\ ~(2=3)/\ ~(2=0)/\ ~(3=0)/\ ~(3=4)/\ ~(1=4)/\ ~(2=4)/\ ~(0=4)/\ 0<6/\ 1<6/\ 2<6/\ 3<6/\ 4<6/\ 5<6 /\ ~(0=5) /\ ~(1=5) /\ ~(2=5)/\ ~(3=5)/\ ~(4=5)`]) THEN SIMP_TAC[HAS_SIZE; CARD_CLAUSES; FINITE_INSERT; FINITE_EMPTY; IN_INSERT; NOT_IN_EMPTY] THEN ASM_REWRITE_TAC[] THEN ARITH_TAC]);;
let V_PRIME_EQ_V_vv= 
prove_by_refinement( ` scs_half_slice_v39 s p q d' mkj= s' /\ scs_half_slice_v39 s q p d'' mkj =s''/\ scs_k_v39 s'=k' /\ scs_k_v39 s =k /\ (vv:num->real^3) (p MOD k)=u /\ (vv:num->real^3) (q MOD k)=w /\ IMAGE (vv:num->real^3) (:num)=V/\ IMAGE (\i. {vv i,(vv:num->real^3) (SUC i)}) (:num) =E/\ IMAGE (\i. (vv i,(vv:num->real^3) (SUC i))) (:num)=FF /\ norm (u - w) <= cstab /\ is_scs_v39 s /\ scs_diag (scs_k_v39 s) p q /\ BBs_v39 s vv ==> IMAGE (\i. vv (i MOD k' + p MOD k)) (:num)=v_prime V (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u)) `,
[ REPEAT STRIP_TAC THEN MP_TAC SCS_K_PRIME_CASE_3 THEN RESA_TAC THEN MP_TAC(ARITH_RULE`3<scs_k_v39 s ==> ~(scs_k_v39 s<=3) `) THEN RESA_TAC THEN POP_ASSUM (fun th-> REPLICATE_TAC 7 (POP_ASSUM MP_TAC) THEN ASSUME_TAC th) THEN ASM_REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;scs_half_slice_v39;is_scs_v39;scs_diag;scs_v39_explicit] THEN REPEAT RESA_TAC THEN REPLICATE_TAC (1) (POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN ASSUME_TAC th THEN MP_TAC th THEN REWRITE_TAC[convex_local_fan] THEN STRIP_TAC) THEN MRESA_TAC (GEN_ALL IN_IMAGE_VV)[`p MOD scs_k_v39 s`;`vv:num->real^3`] THEN MRESA_TAC (GEN_ALL IN_IMAGE_VV)[`q MOD scs_k_v39 s`;`vv:num->real^3`] THEN MRESA_TAC (GEN_ALL Local_lemmas1.POINT_PRESENTED_IN_RHOND1)[`E:(real^3->bool)->bool`;`V:real^3->bool`;`FF:real^3#real^3->bool`;`u:real^3`;`w:real^3`] THEN SUBGOAL_THEN`(!i. scs_b_v39 s i (SUC i) <= cstab)`ASSUME_TAC; REPLICATE_TAC (45-27)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MATCH_MP_TAC th) THEN ASM_REWRITE_TAC[]; MP_TAC NOT_EQ_DIAG THEN ASM_REWRITE_TAC[is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist] THEN STRIP_TAC THEN MP_TAC TECOXBMv2 THEN ASM_REWRITE_TAC[is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist] THEN STRIP_TAC THEN MRESA_TAC(GEN_ALL Local_lemmas1.PROVE_THE_SLICE_ASSUMPTION)[`FF:real^3#real^3->bool`;`E:(real^3->bool)->bool`;`V:real^3->bool`;`u:real^3`;`w:real^3`] THEN MRESA_TAC (GEN_ALL Nkezbfc_local.COMPATIBLE_BW_TWO_LEMMAS) [`hypermap (HYP (vec 0,V,(E:(real^3->bool)->bool) UNION {{u, w}}))`;`V:real^3->bool`;`face (hypermap (HYP (vec 0,V,(E:(real^3->bool)->bool) UNION {{u, w}}))) (u,rho_node1 FF u)`;`(E:(real^3->bool)->bool)`;`FF:real^3#real^3->bool`;`u:real^3`;`w:real^3`;] THEN REWRITE_TAC[slicev] THEN MP_TAC W_EW_K_SCS_ADD_P THEN ASM_REWRITE_TAC[is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist] THEN STRIP_TAC THEN SUBGOAL_THEN`order (rho_node1 FF) u w= k'-1` ASSUME_TAC; MATCH_MP_TAC Nkezbfc_local.UNIQUE_ORDER THEN ASM_REWRITE_TAC[] THEN MRESAL_TAC(GEN_ALL VV_SUC_EQ_RHO_NODE)[`scs_k_v39 s`;`V:real^3->bool`;`E:(real^3->bool)->bool`;`p:num`;`q:num`;`s:scs_v39`;`FF:real^3#real^3->bool`;`u:real^3`;`vv:num->real^3`;`p:num MOD k`] [is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist] THEN GEN_TAC THEN STRIP_TAC THEN REPLICATE_TAC (2)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPLICATE_TAC 2 STRIP_TAC THEN MRESA1_TAC th`k'-1:num` THEN MRESA1_TAC th`i:num`) THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN MP_TAC CARD_V_EQ_SCS_K THEN MP_TAC SCS_K_PRIME_LE_GE THEN ASM_REWRITE_TAC[is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist] THEN STRIP_TAC THEN STRIP_TAC THEN MP_TAC(ARITH_RULE`3<=k' /\ k'<k ==> k'-1<k`) THEN RESA_TAC THEN MRESA_TAC(GEN_ALL Local_lemmas.LOFA_IMP_DIS_ELMS23) [`E:(real^3->bool)->bool`;`V:real^3->bool`;`FF:real^3#real^3->bool`;`u:real^3`;] THEN POP_ASSUM(fun th-> MRESA_TAC th[`i:num`;`k'-1`]); ASM_REWRITE_TAC[IMAGE;IN_ELIM_THM;EXTENSION] THEN GEN_TAC THEN EQ_TAC; STRIP_TAC THEN ASM_REWRITE_TAC[] THEN MP_TAC SCS_K_PRIME_LE_GE THEN ASM_REWRITE_TAC[is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist] THEN STRIP_TAC THEN MP_TAC(ARITH_RULE`3<=k/\ 3<=k' ==> ~(k=0) /\ ~(k'=0)`) THEN RESA_TAC THEN MRESAL_TAC DIVISION[`x':num`;`k':num`][ARITH_RULE`~(3=0)`] THEN MP_TAC(ARITH_RULE`x' MOD k'< k' /\ k'<k/\ 3<=k' ==> x' MOD k'< k/\ x' MOD k'<= k'-1`) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`(x') MOD k':num`;`k:num`] THEN MRESA_TAC MOD_ADD_MOD[`x' MOD k':num`;`p:num`;`k:num`] THEN EXISTS_TAC`x' MOD k'` THEN ASM_REWRITE_TAC[ARITH_RULE`0<= a`] THEN MRESAL_TAC(GEN_ALL VV_SUC_EQ_RHO_NODE)[`scs_k_v39 s`;`V:real^3->bool`;`E:(real^3->bool)->bool`;`p:num`;`q:num`;`s:scs_v39`;`FF:real^3#real^3->bool`;`u:real^3`;`vv:num->real^3`;`p:num MOD k`] [is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist]; RESA_TAC THEN EXISTS_TAC`n':num` THEN ASM_REWRITE_TAC[SET_RULE`(a:num)IN(:num)`] THEN MP_TAC SCS_K_PRIME_LE_GE THEN ASM_REWRITE_TAC[is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist] THEN STRIP_TAC THEN MRESAL_TAC(GEN_ALL VV_SUC_EQ_RHO_NODE)[`scs_k_v39 s`;`V:real^3->bool`;`E:(real^3->bool)->bool`;`p:num`;`q:num`;`s:scs_v39`;`FF:real^3#real^3->bool`;`u:real^3`;`vv:num->real^3`;`p:num MOD k`] [is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist] THEN MP_TAC(ARITH_RULE`n'<= k'-1 /\ 3<=k'/\ k'<k==> n'< k'`) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`n':num`;`k':num`]]);;
let E_PRIME_EQ_E_vv= 
prove_by_refinement( ` scs_half_slice_v39 s p q d' mkj= s' /\ scs_half_slice_v39 s q p d'' mkj =s''/\ scs_k_v39 s'=k' /\ scs_k_v39 s =k /\ (vv:num->real^3) (p MOD k)=u /\ (vv:num->real^3) (q MOD k)=w /\ IMAGE (vv:num->real^3) (:num)=V/\ IMAGE (\i. {vv i,(vv:num->real^3) (SUC i)}) (:num) =E/\ IMAGE (\i. (vv i,(vv:num->real^3) (SUC i))) (:num)=FF /\ norm (u - w) <= cstab /\ is_scs_v39 s /\ scs_diag (scs_k_v39 s) p q /\ BBs_v39 s vv ==> IMAGE (\i. {vv (i MOD k' + p MOD k), vv (SUC i MOD k' + p MOD k)}) (:num) = e_prime (E UNION {{u, w}}) (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u)) `,
[REPEAT STRIP_TAC THEN MP_TAC SCS_K_PRIME_CASE_3 THEN RESA_TAC THEN MP_TAC(ARITH_RULE`3<scs_k_v39 s ==> ~(scs_k_v39 s<=3) `) THEN RESA_TAC THEN POP_ASSUM (fun th-> REPLICATE_TAC 7 (POP_ASSUM MP_TAC) THEN ASSUME_TAC th) THEN ASM_REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;scs_half_slice_v39;is_scs_v39;scs_diag;scs_v39_explicit] THEN REPEAT RESA_TAC THEN REPLICATE_TAC (1) (POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN ASSUME_TAC th THEN MP_TAC th THEN REWRITE_TAC[convex_local_fan] THEN STRIP_TAC) THEN MRESA_TAC (GEN_ALL IN_IMAGE_VV)[`p MOD scs_k_v39 s`;`vv:num->real^3`] THEN MRESA_TAC (GEN_ALL IN_IMAGE_VV)[`q MOD scs_k_v39 s`;`vv:num->real^3`] THEN MRESA_TAC (GEN_ALL Local_lemmas1.POINT_PRESENTED_IN_RHOND1)[`E:(real^3->bool)->bool`;`V:real^3->bool`;`FF:real^3#real^3->bool`;`u:real^3`;`w:real^3`] THEN SUBGOAL_THEN`(!i. scs_b_v39 s i (SUC i) <= cstab)`ASSUME_TAC; REPLICATE_TAC (45-27)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MATCH_MP_TAC th) THEN ASM_REWRITE_TAC[]; MP_TAC NOT_EQ_DIAG THEN ASM_REWRITE_TAC[is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist] THEN STRIP_TAC THEN MP_TAC TECOXBMv2 THEN ASM_REWRITE_TAC[is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist] THEN STRIP_TAC THEN MRESA_TAC(GEN_ALL Local_lemmas1.PROVE_THE_SLICE_ASSUMPTION)[`FF:real^3#real^3->bool`;`E:(real^3->bool)->bool`;`V:real^3->bool`;`u:real^3`;`w:real^3`] THEN MRESA_TAC (GEN_ALL Nkezbfc_local.COMPATIBLE_BW_TWO_LEMMAS) [`hypermap (HYP (vec 0,V,(E:(real^3->bool)->bool) UNION {{u, w}}))`;`V:real^3->bool`;`face (hypermap (HYP (vec 0,V,(E:(real^3->bool)->bool) UNION {{u, w}}))) (u,rho_node1 FF u)`;`(E:(real^3->bool)->bool)`;`FF:real^3#real^3->bool`;`u:real^3`;`w:real^3`;] THEN REWRITE_TAC[slicee] THEN MP_TAC W_EW_K_SCS_ADD_P THEN ASM_REWRITE_TAC[is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist] THEN STRIP_TAC THEN SUBGOAL_THEN`order (rho_node1 FF) u w= k'-1` ASSUME_TAC; MATCH_MP_TAC Nkezbfc_local.UNIQUE_ORDER THEN ASM_REWRITE_TAC[] THEN MRESAL_TAC(GEN_ALL VV_SUC_EQ_RHO_NODE)[`scs_k_v39 s`;`V:real^3->bool`;`E:(real^3->bool)->bool`;`p:num`;`q:num`;`s:scs_v39`;`FF:real^3#real^3->bool`;`u:real^3`;`vv:num->real^3`;`p:num MOD k`] [is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist] THEN GEN_TAC THEN STRIP_TAC THEN REPLICATE_TAC (2)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPLICATE_TAC 2 STRIP_TAC THEN MRESA1_TAC th`k'-1:num` THEN MRESA1_TAC th`i:num`) THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN MP_TAC CARD_V_EQ_SCS_K THEN MP_TAC SCS_K_PRIME_LE_GE THEN ASM_REWRITE_TAC[is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist] THEN STRIP_TAC THEN STRIP_TAC THEN MP_TAC(ARITH_RULE`3<=k' /\ k'<k ==> k'-1<k`) THEN RESA_TAC THEN MRESA_TAC(GEN_ALL Local_lemmas.LOFA_IMP_DIS_ELMS23) [`E:(real^3->bool)->bool`;`V:real^3->bool`;`FF:real^3#real^3->bool`;`u:real^3`;] THEN POP_ASSUM(fun th-> MRESA_TAC th[`i:num`;`k'-1`]); ASM_REWRITE_TAC[IMAGE;IN_ELIM_THM;EXTENSION;UNION] THEN GEN_TAC THEN REWRITE_TAC[GSYM EXTENSION] THEN EQ_TAC; MP_TAC V_PRIME_EQ_V_vv THEN ASM_REWRITE_TAC[is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist] THEN STRIP_TAC THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN STRIP_TAC THEN ASM_REWRITE_TAC[IMAGE;IN_ELIM_THM;DELETE;IN_SING] THEN MP_TAC SCS_K_PRIME_LE_GE THEN ASM_REWRITE_TAC[is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist] THEN STRIP_TAC THEN MP_TAC(ARITH_RULE`3<=k/\ 3<=k' ==> ~(k=0) /\ ~(k'=0)`) THEN RESA_TAC THEN MRESAL_TAC DIVISION[`x':num`;`k':num`][ARITH_RULE`~(3=0)`] THEN MP_TAC(ARITH_RULE`x' MOD k'< k' /\ k'<k/\ 3<=k' ==> x' MOD k'< k/\ x' MOD k'<= k'-1/\ k'-1<k'/\ SUC(k'-1)=k'/\ 1<k'`) THEN RESA_TAC THEN MP_TAC(ARITH_RULE`x' MOD k'<= k'-1 /\3<=k' ==> x' MOD k' = k'-1\/ x' MOD k'< k'-1`) THEN RESA_TAC ; MRESA_TAC MOD_LT[`k'-1:num`;`k':num`] THEN MRESA_TAC(GEN_ALL IMP_SUC_MOD_EQ)[`x':num`;`k'-1`;`k':num`] THEN MRESAL_TAC MOD_MULT[`k':num`;`1:num`][ARITH_RULE`k'*1 =k'/\ 0+A=A`] ; MATCH_MP_TAC(SET_RULE`A==> A\/B`) THEN EXISTS_TAC`(vv:num->real^3) (x' MOD k' + p MOD k)` THEN MRESAL_TAC(GEN_ALL VV_SUC_EQ_RHO_NODE)[`scs_k_v39 s`;`V:real^3->bool`;`E:(real^3->bool)->bool`;`p:num`;`q:num`;`s:scs_v39`;`FF:real^3#real^3->bool`;`(vv (x' MOD k' + p MOD k)):real^3`;`vv:num->real^3`;`x' MOD k'+p:num MOD k`] [is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist] THEN POP_ASSUM (fun th-> MRESAL1_TAC th` SUC 0`[ITER]) THEN REWRITE_TAC[ARITH_RULE`SUC 0=1`;ADD1] THEN MRESA_TAC MOD_LT[`1`;`k':num`] THEN MP_TAC(ARITH_RULE`3<=k' /\ x' MOD k'<k'-1==> 1+x' MOD k'<k'`) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`1+x' MOD k'`;`k':num`] THEN MRESA_TAC MOD_ADD_MOD[`1`;`x':num`;`k':num`] THEN ASM_REWRITE_TAC[(ARITH_RULE`1 + x' MOD k' + p MOD k =(1 + x' MOD k') + p MOD k`);ADD_SYM] THEN STRIP_TAC ; EXISTS_TAC`x':num` THEN ASM_REWRITE_TAC[] ; MRESA_TAC DIVISION[`x' MOD k' + p MOD k`;`k:num`] THEN MRESA_TAC DIVISION[`k' - 1 + p MOD k`;`k:num`] THEN MP_TAC VV_INJ THEN ASM_REWRITE_TAC[is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist] THEN STRIP_TAC THEN POP_ASSUM(fun th-> MRESA_TAC th[`(x' MOD k' +p MOD k)MOD k`;`(k'-1+p MOD k) MOD k`]) THEN ONCE_REWRITE_TAC[ADD_SYM] THEN ASM_TAC THEN REWRITE_TAC[periodic;] THEN REPEAT STRIP_TAC THEN POP_ASSUM MP_TAC THEN POP_ASSUM MP_TAC THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`vv:num->real^3`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th `y + p MOD k:num`) THEN POP_ASSUM(fun th-> ASM_REWRITE_TAC[SYM th]) THEN MP_TAC(SET_RULE`~((x' MOD k' + p MOD k) MOD k = (k' - 1 + p MOD k) MOD k) \/ ((x' MOD k' + p MOD k) MOD k = (k' - 1 + p MOD k) MOD k)`) THEN RESA_TAC THEN MRESAL_TAC(GEN_ALL Hdplygy.MOD_EQ_MOD)[`x' MOD k':num`;`k'-1`;`p MOD k`;`k:num`][] THEN POP_ASSUM MP_TAC THEN ONCE_REWRITE_TAC[ADD_SYM] THEN RESA_TAC THEN MRESA_TAC MOD_LT[`x' MOD k'`;`k:num`] THEN MP_TAC(ARITH_RULE`3<=k' /\k'<k/\ x' MOD k' < k' - 1==> k'-1<k/\ ~(x' MOD k' = k' - 1)`) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`k'-1`;`k:num`] ; ASM_REWRITE_TAC[slicev;IN_ELIM_THM;DELETE;IN_SING] THEN RESA_TAC; MRESAL_TAC(GEN_ALL VV_SUC_EQ_RHO_NODE)[`scs_k_v39 s`;`V:real^3->bool`;`E:(real^3->bool)->bool`;`p:num`;`q:num`;`s:scs_v39`;`FF:real^3#real^3->bool`;`(vv ( p MOD k)):real^3`;`vv:num->real^3`;`p:num MOD k`] [is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist] THEN POP_ASSUM (fun th-> MRESA1_TAC th` n':num` THEN MRESAL1_TAC th` SUC n'`[ITER] ) THEN EXISTS_TAC`n':num` THEN ASM_REWRITE_TAC[SET_RULE`(a:num) IN(:num)`] THEN MP_TAC(ARITH_RULE`n'<= k'-1 ==> n'=k'-1 \/ (SUC n'<k'/\ n'<k')`) THEN RESA_TAC; POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[th] THEN REPEAT RESA_TAC) ; MRESA_TAC MOD_LT[`n':num`;`k':num`] THEN MRESA_TAC MOD_LT[`SUC n':num`;`k':num`] ; ASM_REWRITE_TAC[] THEN EXISTS_TAC`k'-1` THEN ASM_REWRITE_TAC[SET_RULE`(a:num)IN (:num)`] THEN MP_TAC SCS_K_PRIME_LE_GE THEN ASM_REWRITE_TAC[is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist] THEN STRIP_TAC THEN MP_TAC(ARITH_RULE`3<=k' /\k'<k==> k'-1<k' /\ SUC(k'-1)=k' /\ ~(k'=0)`) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`k'-1`;`k':num`] THEN MRESAL_TAC MOD_MULT[`k':num`;`1`][ARITH_RULE`A* 1=A/\ 0+A=A`] ; ]);;
let F_PRIME_EQ_F_vv= 
prove_by_refinement( ` scs_half_slice_v39 s p q d' mkj= s' /\ scs_half_slice_v39 s q p d'' mkj =s''/\ scs_k_v39 s'=k' /\ scs_k_v39 s =k /\ (vv:num->real^3) (p MOD k)=u /\ (vv:num->real^3) (q MOD k)=w /\ IMAGE (vv:num->real^3) (:num)=V/\ IMAGE (\i. {vv i,(vv:num->real^3) (SUC i)}) (:num) =E/\ IMAGE (\i. (vv i,(vv:num->real^3) (SUC i))) (:num)=FF /\ norm (u - w) <= cstab /\ is_scs_v39 s /\ scs_diag (scs_k_v39 s) p q /\ BBs_v39 s vv ==> IMAGE (\i. vv (i MOD k' + p MOD k),vv (SUC i MOD k' + p MOD k)) (:num) = face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u) `,
[ REPEAT STRIP_TAC THEN MP_TAC SCS_K_PRIME_CASE_3 THEN RESA_TAC THEN MP_TAC(ARITH_RULE`3<scs_k_v39 s ==> ~(scs_k_v39 s<=3) `) THEN RESA_TAC THEN POP_ASSUM (fun th-> REPLICATE_TAC 7 (POP_ASSUM MP_TAC) THEN ASSUME_TAC th) THEN ASM_REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;scs_half_slice_v39;is_scs_v39;scs_diag;scs_v39_explicit] THEN REPEAT RESA_TAC THEN REPLICATE_TAC (1) (POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN ASSUME_TAC th THEN MP_TAC th THEN REWRITE_TAC[convex_local_fan] THEN STRIP_TAC) THEN MRESA_TAC (GEN_ALL IN_IMAGE_VV)[`p MOD scs_k_v39 s`;`vv:num->real^3`] THEN MRESA_TAC (GEN_ALL IN_IMAGE_VV)[`q MOD scs_k_v39 s`;`vv:num->real^3`] THEN MRESA_TAC (GEN_ALL Local_lemmas1.POINT_PRESENTED_IN_RHOND1)[`E:(real^3->bool)->bool`;`V:real^3->bool`;`FF:real^3#real^3->bool`;`u:real^3`;`w:real^3`] THEN SUBGOAL_THEN`(!i. scs_b_v39 s i (SUC i) <= cstab)`ASSUME_TAC; REPLICATE_TAC (45-27)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MATCH_MP_TAC th) THEN ASM_REWRITE_TAC[]; MP_TAC NOT_EQ_DIAG THEN ASM_REWRITE_TAC[is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist] THEN STRIP_TAC THEN MP_TAC TECOXBMv2 THEN ASM_REWRITE_TAC[is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist] THEN STRIP_TAC THEN MRESA_TAC(GEN_ALL Local_lemmas1.PROVE_THE_SLICE_ASSUMPTION)[`FF:real^3#real^3->bool`;`E:(real^3->bool)->bool`;`V:real^3->bool`;`u:real^3`;`w:real^3`] THEN MRESA_TAC (GEN_ALL Nkezbfc_local.COMPATIBLE_BW_TWO_LEMMAS) [`hypermap (HYP (vec 0,V,(E:(real^3->bool)->bool) UNION {{u, w}}))`;`V:real^3->bool`;`face (hypermap (HYP (vec 0,V,(E:(real^3->bool)->bool) UNION {{u, w}}))) (u,rho_node1 FF u)`;`(E:(real^3->bool)->bool)`;`FF:real^3#real^3->bool`;`u:real^3`;`w:real^3`;] THEN REWRITE_TAC[slicef] THEN MP_TAC W_EW_K_SCS_ADD_P THEN ASM_REWRITE_TAC[is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist] THEN STRIP_TAC THEN SUBGOAL_THEN`order (rho_node1 FF) u w= k'-1` ASSUME_TAC; MATCH_MP_TAC Nkezbfc_local.UNIQUE_ORDER THEN ASM_REWRITE_TAC[] THEN MRESAL_TAC(GEN_ALL VV_SUC_EQ_RHO_NODE)[`scs_k_v39 s`;`V:real^3->bool`;`E:(real^3->bool)->bool`;`p:num`;`q:num`;`s:scs_v39`;`FF:real^3#real^3->bool`;`u:real^3`;`vv:num->real^3`;`p:num MOD k`] [is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist] THEN GEN_TAC THEN STRIP_TAC THEN REPLICATE_TAC (2)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPLICATE_TAC 2 STRIP_TAC THEN MRESA1_TAC th`k'-1:num` THEN MRESA1_TAC th`i:num`) THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN MP_TAC CARD_V_EQ_SCS_K THEN MP_TAC SCS_K_PRIME_LE_GE THEN ASM_REWRITE_TAC[is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist] THEN STRIP_TAC THEN STRIP_TAC THEN MP_TAC(ARITH_RULE`3<=k' /\ k'<k ==> k'-1<k`) THEN RESA_TAC THEN MRESA_TAC(GEN_ALL Local_lemmas.LOFA_IMP_DIS_ELMS23) [`E:(real^3->bool)->bool`;`V:real^3->bool`;`FF:real^3#real^3->bool`;`u:real^3`;] THEN POP_ASSUM(fun th-> MRESA_TAC th[`i:num`;`k'-1`]); ASM_REWRITE_TAC[IMAGE;IN_ELIM_THM;EXTENSION;UNION] THEN GEN_TAC THEN REWRITE_TAC[GSYM EXTENSION] THEN EQ_TAC; MP_TAC V_PRIME_EQ_V_vv THEN ASM_REWRITE_TAC[is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist] THEN STRIP_TAC THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN STRIP_TAC THEN ASM_REWRITE_TAC[IMAGE;IN_ELIM_THM;DELETE;IN_SING] THEN MP_TAC SCS_K_PRIME_LE_GE THEN ASM_REWRITE_TAC[is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist] THEN STRIP_TAC THEN MP_TAC(ARITH_RULE`3<=k/\ 3<=k' ==> ~(k=0) /\ ~(k'=0)`) THEN RESA_TAC THEN MRESAL_TAC DIVISION[`x':num`;`k':num`][ARITH_RULE`~(3=0)`] THEN MP_TAC(ARITH_RULE`x' MOD k'< k' /\ k'<k/\ 3<=k' ==> x' MOD k'< k/\ x' MOD k'<= k'-1/\ k'-1<k'/\ SUC(k'-1)=k'/\ 1<k'`) THEN RESA_TAC THEN MP_TAC(ARITH_RULE`x' MOD k'<= k'-1 /\3<=k' ==> x' MOD k' = k'-1\/ x' MOD k'< k'-1`) THEN RESA_TAC ; MRESA_TAC MOD_LT[`k'-1:num`;`k':num`] THEN MRESA_TAC(GEN_ALL IMP_SUC_MOD_EQ)[`x':num`;`k'-1`;`k':num`] THEN MRESAL_TAC MOD_MULT[`k':num`;`1:num`][ARITH_RULE`k'*1 =k'/\ 0+A=A`] ; MATCH_MP_TAC(SET_RULE`A==> A\/B`) THEN EXISTS_TAC`(vv:num->real^3) (x' MOD k' + p MOD k)` THEN MRESAL_TAC(GEN_ALL VV_SUC_EQ_RHO_NODE)[`scs_k_v39 s`;`V:real^3->bool`;`E:(real^3->bool)->bool`;`p:num`;`q:num`;`s:scs_v39`;`FF:real^3#real^3->bool`;`(vv (x' MOD k' + p MOD k)):real^3`;`vv:num->real^3`;`x' MOD k'+p:num MOD k`] [is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist] THEN POP_ASSUM (fun th-> MRESAL1_TAC th` SUC 0`[ITER]) THEN REWRITE_TAC[ARITH_RULE`SUC 0=1`;ADD1] THEN MRESA_TAC MOD_LT[`1`;`k':num`] THEN MP_TAC(ARITH_RULE`3<=k' /\ x' MOD k'<k'-1==> 1+x' MOD k'<k'`) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`1+x' MOD k'`;`k':num`] THEN MRESA_TAC MOD_ADD_MOD[`1`;`x':num`;`k':num`] THEN ASM_REWRITE_TAC[(ARITH_RULE`1 + x' MOD k' + p MOD k =(1 + x' MOD k') + p MOD k`);ADD_SYM] THEN STRIP_TAC ; EXISTS_TAC`x':num` THEN ASM_REWRITE_TAC[] ; MRESA_TAC DIVISION[`x' MOD k' + p MOD k`;`k:num`] THEN MRESA_TAC DIVISION[`k' - 1 + p MOD k`;`k:num`] THEN MP_TAC VV_INJ THEN ASM_REWRITE_TAC[is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist] THEN STRIP_TAC THEN POP_ASSUM(fun th-> MRESA_TAC th[`(x' MOD k' +p MOD k)MOD k`;`(k'-1+p MOD k) MOD k`]) THEN ONCE_REWRITE_TAC[ADD_SYM] THEN ASM_TAC THEN REWRITE_TAC[periodic;] THEN REPEAT STRIP_TAC THEN POP_ASSUM MP_TAC THEN POP_ASSUM MP_TAC THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`vv:num->real^3`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th `y + p MOD k:num`) THEN POP_ASSUM(fun th-> ASM_REWRITE_TAC[SYM th]) THEN MP_TAC(SET_RULE`~((x' MOD k' + p MOD k) MOD k = (k' - 1 + p MOD k) MOD k) \/ ((x' MOD k' + p MOD k) MOD k = (k' - 1 + p MOD k) MOD k)`) THEN RESA_TAC THEN MRESAL_TAC(GEN_ALL Hdplygy.MOD_EQ_MOD)[`x' MOD k':num`;`k'-1`;`p MOD k`;`k:num`][] THEN POP_ASSUM MP_TAC THEN ONCE_REWRITE_TAC[ADD_SYM] THEN RESA_TAC THEN MRESA_TAC MOD_LT[`x' MOD k'`;`k:num`] THEN MP_TAC(ARITH_RULE`3<=k' /\k'<k/\ x' MOD k' < k' - 1==> k'-1<k/\ ~(x' MOD k' = k' - 1)`) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`k'-1`;`k:num`] ; ASM_REWRITE_TAC[slicev;IN_ELIM_THM;DELETE;IN_SING] THEN RESA_TAC; MRESAL_TAC(GEN_ALL VV_SUC_EQ_RHO_NODE)[`scs_k_v39 s`;`V:real^3->bool`;`E:(real^3->bool)->bool`;`p:num`;`q:num`;`s:scs_v39`;`FF:real^3#real^3->bool`;`(vv ( p MOD k)):real^3`;`vv:num->real^3`;`p:num MOD k`] [is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist] THEN POP_ASSUM (fun th-> MRESA1_TAC th` n':num` THEN MRESAL1_TAC th` SUC n'`[ITER] ) THEN EXISTS_TAC`n':num` THEN ASM_REWRITE_TAC[SET_RULE`(a:num) IN(:num)`] THEN MP_TAC(ARITH_RULE`n'<= k'-1 ==> n'=k'-1 \/ (SUC n'<k'/\ n'<k')`) THEN RESA_TAC; POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[th] THEN REPEAT RESA_TAC) ; MRESA_TAC MOD_LT[`n':num`;`k':num`] THEN MRESA_TAC MOD_LT[`SUC n':num`;`k':num`] ; ASM_REWRITE_TAC[] THEN EXISTS_TAC`k'-1` THEN ASM_REWRITE_TAC[SET_RULE`(a:num)IN (:num)`] THEN MP_TAC SCS_K_PRIME_LE_GE THEN ASM_REWRITE_TAC[is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist] THEN STRIP_TAC THEN MP_TAC(ARITH_RULE`3<=k' /\k'<k==> k'-1<k' /\ SUC(k'-1)=k' /\ ~(k'=0)`) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`k'-1`;`k':num`] THEN MRESAL_TAC MOD_MULT[`k':num`;`1`][ARITH_RULE`A* 1=A/\ 0+A=A`] ; ]);;
let QKNVMLB1_LE4F= 
prove_by_refinement( ` s' = scs_half_slice_v39 s p q d' mkj /\ s'' = scs_half_slice_v39 s q p d'' mkj /\ vv' = (\i. (vv:num->real^3) (i MOD (scs_k_v39 s')+p MOD (scs_k_v39 s))) /\ is_scs_v39 s /\ scs_diag (scs_k_v39 s) p q /\ d'< #0.9 /\ (4<scs_k_v39 s /\ scs_bm_v39 s p q <= cstab) /\ MMs_v39 s vv ==> BBs_v39 s' vv'`,
[ STRIP_TAC THEN POP_ASSUM MP_TAC (*THEN MP_TAC SCS_HALF_SLICE_IS_SCS THEN RESA_TAC*) THEN MRESA_TAC (GEN_ALL SCS_K_PRIME_LE_GE)[`s:scs_v39`;`p:num`;`q:num`;`d':real`;`scs_J_v39 s' p q`] THEN POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[LET_DEF;LET_END_DEF;] THEN MP_TAC SCS_K_PRIME_CASE_3 THEN RESA_TAC THEN MP_TAC(ARITH_RULE`3<scs_k_v39 s ==> ~(scs_k_v39 s<=3)`) THEN RESA_TAC THEN REPLICATE_TAC 7 (POP_ASSUM MP_TAC) THEN ASM_REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;scs_half_slice_v39;is_scs_v39;scs_diag;scs_v39_explicit] THEN ABBREV_TAC`k'=(q + 1 + scs_k_v39 s - p MOD scs_k_v39 s) MOD scs_k_v39 s` THEN ABBREV_TAC`k= scs_k_v39 s` THEN REPEAT RESA_TAC; ASM_TAC THEN REWRITE_TAC[IMAGE;SUBSET;IN_ELIM_THM] THEN REPEAT STRIP_TAC THEN ASM_REWRITE_TAC[] THEN REPLICATE_TAC (51-38) (POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MATCH_MP_TAC th) THEN EXISTS_TAC`((x') MOD k'+p MOD k)` THEN REWRITE_TAC[SET_RULE`(a:num) IN (:num)`]; REWRITE_TAC[periodic;] THEN GEN_TAC THEN MRESAL_TAC MOD_MULT_ADD[`1:num`;`k':num`;`i:num`][ARITH_RULE`1 * k' + i = (i+k')`] ; DISJ_CASES_TAC(SET_RULE`{i MOD k', j MOD k'} = {0, k'-1} \/ ~({i MOD k', j MOD k'} = {0, k'-1})`); ASM_REWRITE_TAC[] THEN REPLICATE_TAC 2 (POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> MRESA_TAC th[`((i) MOD k'+p MOD k)`;`((j) MOD k'+p MOD k)`]) THEN STRIP_TAC THEN STRIP_TAC THEN SUBGOAL_THEN`scs_am_v39 s ((i) MOD k'+p MOD k) ((j) MOD k'+p MOD k) =scs_am_v39 s p q`ASSUME_TAC; MP_TAC(SET_RULE`{i MOD k', j MOD k'} = {0, k' - 1} ==> (i MOD k' =0 /\ j MOD k'=k'-1)\/ (i MOD k' =k'-1 /\ j MOD k'=0)`) THEN RESA_TAC THEN REWRITE_TAC[ARITH_RULE`0+p=p`] THEN ASM_TAC THEN REWRITE_TAC[periodic2;] THEN REPEAT STRIP_TAC THEN MP_TAC(ARITH_RULE`3<= scs_k_v39 s ==> ~(scs_k_v39 s = 0) /\ 0<scs_k_v39 s`) THEN RESA_TAC THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`scs_am_v39 s p`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th `k'+(k-1)+p MOD k:num`) THEN POP_ASSUM MP_TAC THEN MRESA_TAC MOD_LT[`k':num`;`k:num`] THEN MRESA_TAC MOD_ADD_MOD[`k':num`;`k-1+p MOD k`;`k:num`] THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN REMOVE_ASSUM_TAC THEN MRESA_TAC MOD_ADD_MOD[`q + 1 + k - p MOD k`;`k-1+p MOD k`;`k:num`] THEN EXPAND_TAC"k'" THEN MRESA_TAC DIVISION[`p:num`;`k:num`] THEN MP_TAC(ARITH_RULE`p MOD k< k==>(((q + 1 + k - p MOD k) + k - 1 + p MOD k)) =(q+ 2*k) `) THEN RESA_TAC THEN MRESA_TAC MOD_EQ[`q+2*k`;`q:num`;`k:num`;`2`] THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`scs_am_v39 s p`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th `q:num`) THEN REPLICATE_TAC (60-14) (POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC(ARITH_RULE`0<k/\ 3<= k'==> (k' - 1 + p MOD k) + k =k' + k - 1 + p MOD k`) THEN RESA_TAC THEN MRESA_TAC th[`k'-1+p MOD k`;`p:num`] THEN REMOVE_ASSUM_TAC THEN ASSUME_TAC th) THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`scs_am_v39 s (k' - 1 + p MOD k)`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th `p:num`) ; POP_ASSUM(fun th1->ASM_REWRITE_TAC[SYM th1]) ; ASM_REWRITE_TAC[]; DISJ_CASES_TAC(SET_RULE`{i MOD k', j MOD k'} = {0, k'-1} \/ ~({i MOD k', j MOD k'} = {0, k'-1})`); ASM_REWRITE_TAC[] THEN REPLICATE_TAC 1 (POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> MRESA_TAC th[`((i) MOD k'+p MOD k)`;`((j) MOD k'+p MOD k)`]) THEN STRIP_TAC THEN SUBGOAL_THEN`scs_bm_v39 s ((i) MOD k'+p MOD k) ((j) MOD k'+p MOD k) =scs_bm_v39 s p q`ASSUME_TAC; MP_TAC(SET_RULE`{i MOD k', j MOD k'} = {0, k' - 1} ==> (i MOD k' =0 /\ j MOD k'=k'-1)\/ (i MOD k' =k'-1 /\ j MOD k'=0)`) THEN RESA_TAC THEN REWRITE_TAC[ARITH_RULE`0+p=p`] THEN ASM_TAC THEN REWRITE_TAC[periodic2;] THEN REPEAT STRIP_TAC THEN MP_TAC(ARITH_RULE`3<= scs_k_v39 s ==> ~(scs_k_v39 s = 0) /\ 0<scs_k_v39 s`) THEN RESA_TAC THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`scs_bm_v39 s p`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th `k'+(k-1)+p MOD k:num`) THEN POP_ASSUM MP_TAC THEN MRESA_TAC MOD_LT[`k':num`;`k:num`] THEN MRESA_TAC MOD_ADD_MOD[`k':num`;`k-1+p MOD k`;`k:num`] THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN REMOVE_ASSUM_TAC THEN MRESA_TAC MOD_ADD_MOD[`q + 1 + k - p MOD k`;`k-1+p MOD k`;`k:num`] THEN EXPAND_TAC"k'" THEN MRESA_TAC DIVISION[`p:num`;`k:num`] THEN MP_TAC(ARITH_RULE`p MOD k< k==>(((q + 1 + k - p MOD k) + k - 1 + p MOD k)) =(q+ 2*k) `) THEN RESA_TAC THEN MRESA_TAC MOD_EQ[`q+2*k`;`q:num`;`k:num`;`2`] THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`scs_bm_v39 s p`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th `q:num`) THEN REPLICATE_TAC (60-15) (POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC(ARITH_RULE`0<k/\ 3<= k'==> (k' - 1 + p MOD k) + k =k' + k - 1 + p MOD k`) THEN RESA_TAC THEN MRESA_TAC th[`k'-1+p MOD k`;`p:num`] THEN REMOVE_ASSUM_TAC THEN ASSUME_TAC th) THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`scs_bm_v39 s (k' - 1 + p MOD k)`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th `p:num`) ; POP_ASSUM(fun th1->ASM_REWRITE_TAC[SYM th1]) ; ASM_REWRITE_TAC[]; ABBREV_TAC`u= (vv:num->real^3) (p MOD k)` THEN ABBREV_TAC `w= (vv:num->real^3) (q MOD k)` THEN ABBREV_TAC`V= IMAGE (vv:num->real^3) (:num)` THEN ABBREV_TAC`E= IMAGE (\i. {vv i,(vv:num->real^3) (SUC i)}) (:num)` THEN ABBREV_TAC`FF= IMAGE (\i. (vv i,(vv:num->real^3) (SUC i))) (:num)` THEN MP_TAC(ARITH_RULE`3<=k'==> k'<=3 \/ ~(k'<=3)`) THEN RESA_TAC THEN MRESA_TAC (GEN_ALL IN_IMAGE_VV)[`p MOD scs_k_v39 s`;`vv:num->real^3`] THEN MRESA_TAC (GEN_ALL IN_IMAGE_VV)[`q MOD scs_k_v39 s`;`vv:num->real^3`] THEN SUBGOAL_THEN`(!i. scs_b_v39 s i (SUC i) <= cstab)`ASSUME_TAC ; REPLICATE_TAC (57-23)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MATCH_MP_TAC th) THEN ASM_REWRITE_TAC[]; SUBGOAL_THEN`norm (u - w:real^3) <= cstab`ASSUME_TAC ; MP_TAC(ARITH_RULE`3<=k==> ~(k=0)`) THEN RESA_TAC THEN ASM_TAC THEN REWRITE_TAC[periodic2;] THEN REPEAT STRIP_TAC THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`scs_bm_v39 s (p)`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th `q:num`) THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`scs_bm_v39 s (q MOD k)`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th `p:num`) THEN REPLICATE_TAC (61-49)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESAL_TAC th [`p MOD scs_k_v39 s`;`q MOD scs_k_v39 s`] [ARITH_RULE`SUC 0=1/\ SUC 1=2/\ SUC 2=3`;dist]) THEN POP_ASSUM MP_TAC THEN REPLICATE_TAC (60-32)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th) THEN POP_ASSUM MP_TAC THEN REAL_ARITH_TAC ; MP_TAC NOT_EQ_DIAG THEN ASM_REWRITE_TAC[is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist] THEN STRIP_TAC THEN MP_TAC TECOXBMv2 THEN ASM_REWRITE_TAC[is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist] THEN STRIP_TAC THEN MRESA_TAC(GEN_ALL Local_lemmas1.EJRCFJD)[`hypermap (HYP (vec 0,V,(E:(real^3->bool)->bool) UNION {{u, w}}))`;`(E:(real^3->bool)->bool)`;`w:real^3`;`face (hypermap (HYP (vec 0,V,(E:(real^3->bool)->bool) UNION {{u, w}}))) (u,rho_node1 FF u)`;`V:real^3->bool`;`face (hypermap (HYP (vec 0,V,(E:(real^3->bool)->bool) UNION {{u, w}}))) (w,rho_node1 FF w)`;`FF:real^3#real^3->bool`;`u:real^3`] THEN MP_TAC F_PRIME_EQ_F_vv THEN ASM_REWRITE_TAC[is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist;scs_half_slice_v39] THEN STRIP_TAC THEN MP_TAC E_PRIME_EQ_E_vv THEN ASM_REWRITE_TAC[is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist;scs_half_slice_v39] THEN STRIP_TAC THEN MP_TAC V_PRIME_EQ_V_vv THEN ASM_REWRITE_TAC[is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist;scs_half_slice_v39] THEN STRIP_TAC THEN ASM_REWRITE_TAC[]]);;
let QKNVMLB1_EQ4F= 
prove_by_refinement( ` s' = scs_half_slice_v39 s p q d' mkj /\ s'' = scs_half_slice_v39 s q p d'' mkj /\ vv' = (\i. (vv:num->real^3) (i MOD (scs_k_v39 s')+p MOD (scs_k_v39 s))) /\ is_scs_v39 s /\ scs_diag (scs_k_v39 s) p q /\ d'< #0.9 /\ (4=scs_k_v39 s /\ scs_bm_v39 s p q <= &4) /\ MMs_v39 s vv ==> BBs_v39 s' vv'`,
[ STRIP_TAC THEN POP_ASSUM MP_TAC (*THEN MP_TAC SCS_HALF_SLICE_IS_SCS THEN RESA_TAC*) THEN MRESA_TAC (GEN_ALL SCS_K_PRIME_LE_GE)[`s:scs_v39`;`p:num`;`q:num`;`d':real`;`scs_J_v39 s' p q`] THEN POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[LET_DEF;LET_END_DEF;] THEN MP_TAC SCS_K_PRIME_CASE_3 THEN RESA_TAC THEN MP_TAC(ARITH_RULE`3<scs_k_v39 s ==> ~(scs_k_v39 s<=3)`) THEN RESA_TAC THEN REPLICATE_TAC 7 (POP_ASSUM MP_TAC) THEN ASM_REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;scs_half_slice_v39;is_scs_v39;scs_diag;scs_v39_explicit] THEN ABBREV_TAC`k'=(q + 1 + scs_k_v39 s - p MOD scs_k_v39 s) MOD scs_k_v39 s` THEN ABBREV_TAC`k= scs_k_v39 s` THEN REPEAT RESA_TAC; ASM_TAC THEN REWRITE_TAC[IMAGE;SUBSET;IN_ELIM_THM] THEN REPEAT STRIP_TAC THEN ASM_REWRITE_TAC[] THEN REPLICATE_TAC (51-38) (POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MATCH_MP_TAC th) THEN EXISTS_TAC`((x') MOD k'+p MOD k)` THEN ASM_REWRITE_TAC[SET_RULE`(a:num) IN (:num)`]; REWRITE_TAC[periodic;] THEN GEN_TAC THEN MRESAL_TAC MOD_MULT_ADD[`1:num`;`k':num`;`i:num`][ARITH_RULE`1 * k' + i = (i+k')`]; DISJ_CASES_TAC(SET_RULE`{i MOD k', j MOD k'} = {0, k'-1} \/ ~({i MOD k', j MOD k'} = {0, k'-1})`); ASM_REWRITE_TAC[] THEN REPLICATE_TAC 2 (POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> MRESA_TAC th[`((i) MOD k'+p MOD k)`;`((j) MOD k'+p MOD k)`]) THEN STRIP_TAC THEN STRIP_TAC THEN SUBGOAL_THEN`scs_am_v39 s ((i) MOD k'+p MOD k) ((j) MOD k'+p MOD k) =scs_am_v39 s p q`ASSUME_TAC; MP_TAC(SET_RULE`{i MOD k', j MOD k'} = {0, k' - 1} ==> (i MOD k' =0 /\ j MOD k'=k'-1)\/ (i MOD k' =k'-1 /\ j MOD k'=0)`) THEN RESA_TAC THEN REWRITE_TAC[ARITH_RULE`0+p=p`] THEN ASM_TAC THEN REWRITE_TAC[periodic2;] THEN REPEAT STRIP_TAC THEN MP_TAC(ARITH_RULE`3<= scs_k_v39 s ==> ~(scs_k_v39 s = 0) /\ 0<scs_k_v39 s`) THEN RESA_TAC THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`scs_am_v39 s p`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th `k'+(k-1)+p MOD k:num`) THEN POP_ASSUM MP_TAC THEN MRESA_TAC MOD_LT[`k':num`;`k:num`] THEN MRESA_TAC MOD_ADD_MOD[`k':num`;`k-1+p MOD k`;`k:num`] THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN REMOVE_ASSUM_TAC THEN MRESA_TAC MOD_ADD_MOD[`q + 1 + k - p MOD k`;`k-1+p MOD k`;`k:num`] THEN EXPAND_TAC"k'" THEN MRESA_TAC DIVISION[`p:num`;`k:num`] THEN MP_TAC(ARITH_RULE`p MOD k< k==>(((q + 1 + k - p MOD k) + k - 1 + p MOD k)) =(q+ 2*k) `) THEN RESA_TAC THEN MRESA_TAC MOD_EQ[`q+2*k`;`q:num`;`k:num`;`2`] THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`scs_am_v39 s p`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th `q:num`) THEN REPLICATE_TAC (60-14) (POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC(ARITH_RULE`0<k/\ 3<= k'==> (k' - 1 + p MOD k) + k =k' + k - 1 + p MOD k`) THEN RESA_TAC THEN MRESA_TAC th[`k'-1+p MOD k`;`p:num`] THEN REMOVE_ASSUM_TAC THEN ASSUME_TAC th) THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`scs_am_v39 s (k' - 1 + p MOD k)`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th `p:num`); POP_ASSUM(fun th1->ASM_REWRITE_TAC[SYM th1]); ASM_REWRITE_TAC[]; DISJ_CASES_TAC(SET_RULE`{i MOD k', j MOD k'} = {0, k'-1} \/ ~({i MOD k', j MOD k'} = {0, k'-1})`); ASM_REWRITE_TAC[] THEN REPLICATE_TAC 1 (POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> MRESA_TAC th[`((i) MOD k'+p MOD k)`;`((j) MOD k'+p MOD k)`]) THEN STRIP_TAC THEN SUBGOAL_THEN`scs_bm_v39 s ((i) MOD k'+p MOD k) ((j) MOD k'+p MOD k) =scs_bm_v39 s p q`ASSUME_TAC; MP_TAC(SET_RULE`{i MOD k', j MOD k'} = {0, k' - 1} ==> (i MOD k' =0 /\ j MOD k'=k'-1)\/ (i MOD k' =k'-1 /\ j MOD k'=0)`) THEN RESA_TAC THEN REWRITE_TAC[ARITH_RULE`0+p=p`] THEN ASM_TAC THEN REWRITE_TAC[periodic2;] THEN REPEAT STRIP_TAC THEN MP_TAC(ARITH_RULE`3<= scs_k_v39 s ==> ~(scs_k_v39 s = 0) /\ 0<scs_k_v39 s`) THEN RESA_TAC THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`scs_bm_v39 s p`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th `k'+(k-1)+p MOD k:num`) THEN POP_ASSUM MP_TAC THEN MRESA_TAC MOD_LT[`k':num`;`k:num`] THEN MRESA_TAC MOD_ADD_MOD[`k':num`;`k-1+p MOD k`;`k:num`] THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN REMOVE_ASSUM_TAC THEN MRESA_TAC MOD_ADD_MOD[`q + 1 + k - p MOD k`;`k-1+p MOD k`;`k:num`] THEN EXPAND_TAC"k'" THEN MRESA_TAC DIVISION[`p:num`;`k:num`] THEN MP_TAC(ARITH_RULE`p MOD k< k==>(((q + 1 + k - p MOD k) + k - 1 + p MOD k)) =(q+ 2*k) `) THEN RESA_TAC THEN MRESA_TAC MOD_EQ[`q+2*k`;`q:num`;`k:num`;`2`] THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`scs_bm_v39 s p`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th `q:num`) THEN REPLICATE_TAC (60-15) (POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC(ARITH_RULE`0<k/\ 3<= k'==> (k' - 1 + p MOD k) + k =k' + k - 1 + p MOD k`) THEN RESA_TAC THEN MRESA_TAC th[`k'-1+p MOD k`;`p:num`] THEN REMOVE_ASSUM_TAC THEN ASSUME_TAC th) THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`scs_bm_v39 s (k' - 1 + p MOD k)`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th `p:num`); POP_ASSUM(fun th1->ASM_REWRITE_TAC[SYM th1]); ASM_REWRITE_TAC[]; MP_TAC SCS_K_PRIME_CASE_4 THEN ASM_REWRITE_TAC[is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist;scs_half_slice_v39] THEN RESA_TAC THEN REPLICATE_TAC (50-31)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[SYM th] THEN REPEAT RESA_TAC) THEN POP_ASSUM MP_TAC THEN SUBGOAL_THEN`(!i. scs_b_v39 s i (SUC i) <= cstab)`ASSUME_TAC; REPLICATE_TAC (48-23)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MATCH_MP_TAC th) THEN ASM_REWRITE_TAC[]; ASM_REWRITE_TAC[] THEN ARITH_TAC]);;
let QKNVMLB1=
prove_by_refinement( ` (let s' = scs_half_slice_v39 s p q d' mkj in let vv' = (\i. vv (i MOD (scs_k_v39 s')+ p MOD (scs_k_v39 s))) in MMs_v39 s vv /\ scs_bm_v39 s p q < &4 /\ ((scs_k_v39 s = 4) \/ scs_bm_v39 s p q <= cstab) /\ is_scs_v39 s /\ d' < #0.9 /\ scs_diag (scs_k_v39 s) p q ==> BBs_v39 s' vv')`,
[REPEAT GEN_TAC THEN REWRITE_TAC[LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;IN;mk_unadorned_v39;] THEN STRIP_TAC; ABBREV_TAC`s' = scs_half_slice_v39 s p q d' mkj` THEN ABBREV_TAC`s'' = scs_half_slice_v39 s q p d'' mkj` THEN ABBREV_TAC`vv' = (\i. (vv:num->real^3) (i MOD (scs_k_v39 s')+ p MOD (scs_k_v39 s)))` THEN MP_TAC(REAL_ARITH`scs_bm_v39 s p q < &4==> scs_bm_v39 s p q <= &4`) THEN RESA_TAC THEN MP_TAC QKNVMLB1_EQ4F THEN RESA_TAC; ABBREV_TAC`s' = scs_half_slice_v39 s p q d' mkj` THEN ABBREV_TAC`s'' = scs_half_slice_v39 s q p d'' mkj` THEN ABBREV_TAC`vv' = (\i. (vv:num->real^3) (i MOD (scs_k_v39 s')+ p MOD (scs_k_v39 s)))` THEN MP_TAC SCS_K_PRIME_CASE_3 THEN RESA_TAC THEN MP_TAC(ARITH_RULE`3 < scs_k_v39 s ==> scs_k_v39 s =4 \/ 4 < scs_k_v39 s`) THEN RESA_TAC; ASM_TAC THEN REWRITE_TAC[cstab] THEN REPEAT STRIP_TAC THEN MP_TAC(REAL_ARITH`scs_bm_v39 s p q <= #3.01 ==> scs_bm_v39 s p q <= &4`) THEN RESA_TAC THEN MP_TAC QKNVMLB1_EQ4F THEN RESA_TAC; MP_TAC QKNVMLB1_LE4F THEN RESA_TAC]);;
let DIAG_IS_NOT_EAR=
prove(`is_scs_v39 s /\ scs_diag (scs_k_v39 s) p q ==> ~(is_ear_v39 s)`,
STRIP_TAC THEN MP_TAC SCS_K_PRIME_CASE_3 THEN RESA_TAC THEN REWRITE_TAC[is_ear_v39] THEN POP_ASSUM (fun th-> STRIP_TAC THEN MP_TAC th THEN ASM_REWRITE_TAC[]) THEN ARITH_TAC);;
let SCS_J_DIAG_EQ=
prove(`s'= scs_half_slice_v39 s p q d' mkj /\ s''= scs_half_slice_v39 s q p d'' mkj /\ is_scs_v39 s /\ scs_diag (scs_k_v39 s) p q /\ is_scs_slice_v39 s s' s'' p q ==> scs_J_v39 s' 0 (scs_k_v39 s' - 1) =scs_J_v39 s'' 0 (scs_k_v39 s'' - 1)`,
ASM_REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ] THEN RESA_TAC THEN ABBREV_TAC`k'=(q + 1 + scs_k_v39 s - p MOD scs_k_v39 s) MOD scs_k_v39 s` THEN ABBREV_TAC`k''=(p + 1 + scs_k_v39 s - q MOD scs_k_v39 s) MOD scs_k_v39 s` THEN ASM_REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;scs_half_slice_v39] THEN MP_TAC SCS_K_PRIME_LE_GE THEN ASM_REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;scs_half_slice_v39] THEN RESA_TAC THEN MRESAL_TAC(GEN_ALL SCS_K_PRIME_LE_GE)[`s:scs_v39`;`q:num`;`p:num`;`d'':real`;`mkj:bool`] [MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;scs_half_slice_v39] THEN MP_TAC(ARITH_RULE`3<=k' /\ 3<=k''==>0< k' /\ k'-1<k'/\ 0< k'' /\ k''-1<k''`) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`0`;`k':num`] THEN MRESA_TAC MOD_LT[`0`;`k'':num`] THEN MRESA_TAC MOD_LT[`k'-1`;`k':num`] THEN MRESA_TAC MOD_LT[`k''-1`;`k'':num`]);;
let DIAG_NOT_IN_SCS_J=
prove(` is_scs_v39 s /\ scs_diag (scs_k_v39 s) p q ==> ~(scs_J_v39 s p q)`,
ASM_REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ] THEN RESA_TAC THEN REPLICATE_TAC (22-17) (POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESAL_TAC th[`p:num`;`q:num`][ADD1;ARITH_RULE`1+i=i+1`]));;
let SCS_J_PRIME_SUBSET_SCS_J=
prove_by_refinement( `scs_half_slice_v39 s p q d' mkj =s'/\ is_scs_v39 s /\ scs_diag (scs_k_v39 s) p q /\ i< scs_k_v39 s'-1 /\ scs_J_v39 s' i (SUC i) ==> scs_J_v39 s ((i+ p MOD scs_k_v39 s)MOD scs_k_v39 s) (SUC ((i + p MOD scs_k_v39 s)MOD scs_k_v39 s))`,
[REPEAT STRIP_TAC THEN POP_ASSUM MP_TAC THEN POP_ASSUM MP_TAC THEN EXPAND_TAC"s'" THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;scs_half_slice_v39] THEN ABBREV_TAC`k'=(q + 1 + scs_k_v39 s - p MOD scs_k_v39 s) MOD scs_k_v39 s` THEN STRIP_TAC THEN ABBREV_TAC`k= scs_k_v39 s` THEN MP_TAC SCS_K_PRIME_CASE_3 THEN RESA_TAC THEN MRESAL_TAC (GEN_ALL SCS_K_PRIME_LE_GE)[`s:scs_v39`;`p:num`;`q:num`;`d':real`;`scs_J_v39 s' p q`][MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;scs_half_slice_v39] THEN MP_TAC(ARITH_RULE`i<k'-1/\ k'< k==> i<k'/\ SUC i<k'/\ i<k/\ SUC i<k`) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`i:num`;`k':num`] THEN MRESA_TAC MOD_LT[`i:num`;`k:num`] THEN MRESA_TAC MOD_LT[`SUC i:num`;`k':num`] THEN MRESA_TAC MOD_LT[`SUC i:num`;`k:num`] THEN MP_TAC(SET_RULE`{i, SUC i} = {0, k' - 1} \/ ~({i, SUC i} = {0, k' - 1})`) THEN RESA_TAC; MP_TAC(SET_RULE`{i, SUC i} = {0, k' - 1} ==> (i=0 /\ SUC i= k'-1) \/ (i= k'-1 /\ SUC i=0)`) THEN RESA_TAC; REWRITE_TAC[ADD1;ARITH_RULE`SUC i+A=SUC(i+A)`]; POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[ARITH_RULE`SUC 0 = k' - 1<=> k'=2`] THEN REPLICATE_TAC (19-7) (POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th) THEN ASM_REWRITE_TAC[] THEN ARITH_TAC; POP_ASSUM MP_TAC THEN ARITH_TAC; STRIP_TAC THEN ASM_TAC THEN REWRITE_TAC[periodic;periodic2;is_scs_v39] THEN REPEAT STRIP_TAC THEN MP_TAC(ARITH_RULE`3<k==> ~(k=0)/\ 1<k /\ 1 + (i + p) MOD k =SUC((i+p) MOD k)/\ 1 + i + p= SUC i+p`) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`1`;`k:num`] THEN MRESA_TAC MOD_ADD_MOD[`i:num`;`p:num`;`k:num`] THEN MRESA_TAC MOD_ADD_MOD[`SUC i:num`;`p:num`;`k:num`] THEN MRESA_TAC MOD_ADD_MOD[`1:num`;`i+p:num`;`k:num`] THEN MRESAL_TAC (GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`scs_J_v39 s (SUC i + p MOD k)`][periodic;ARITH_RULE`1 MOD 4=1 /\ SUC 1=2/\ 1<4/\ ~(4=0)`] THEN POP_ASSUM(fun th-> MRESA1_TAC th`(i + p MOD k):num`) THEN MRESAL_TAC (GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`scs_J_v39 s ((i + p MOD k) MOD k)`][periodic;ARITH_RULE`1 MOD 4=1 /\ SUC 1=2/\ 1<4/\ ~(4=0)`] THEN POP_ASSUM(fun th-> MRESA1_TAC th`(SUC i + p MOD k):num` THEN MRESA1_TAC th`SUC((i+p) MOD k)`)]);;
let INTER_SLICE_SCS_EMPTY1=
prove_by_refinement( ` scs_half_slice_v39 s p q d' mkj =s'/\ scs_half_slice_v39 s q p d'' mkj =s'' /\ is_scs_v39 s /\ scs_diag (scs_k_v39 s) p q /\ p MOD scs_k_v39 s <q MOD scs_k_v39 s ==> {(i + p MOD scs_k_v39 s) MOD scs_k_v39 s | i < scs_k_v39 s'-1 } INTER {(i + q MOD scs_k_v39 s)MOD scs_k_v39 s | i < scs_k_v39 s''-1 }={} `,
[ REWRITE_TAC[SET_RULE`A INTER B={}<=> ~(?a. a IN A INTER B)`;INTER] THEN STRIP_TAC THEN EXPAND_TAC"s'" THEN EXPAND_TAC"s''" THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;scs_half_slice_v39;IN_ELIM_THM] THEN ABBREV_TAC`k'=(q + 1 + scs_k_v39 s - p MOD scs_k_v39 s) MOD scs_k_v39 s` THEN ABBREV_TAC`k''=(p + 1 + scs_k_v39 s - q MOD scs_k_v39 s) MOD scs_k_v39 s` THEN ABBREV_TAC`k= scs_k_v39 s` THEN REPEAT STRIP_TAC THEN POP_ASSUM (fun th->ASM_TAC THEN REWRITE_TAC[th] THEN REPEAT STRIP_TAC) THEN MRESAL_TAC (GEN_ALL SCS_K_PRIME_LE_GE)[`s:scs_v39`;`p:num`;`q:num`;`d':real`;`scs_J_v39 s' p q`][MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;scs_half_slice_v39;IN_ELIM_THM] THEN SUBGOAL_THEN`(k'-1 +p MOD k) <= q MOD k `ASSUME_TAC; MP_TAC(ARITH_RULE`3<= k' /\ k'<k /\ p MOD k< q MOD k ==> ~(k=0)/\ (q +k -p MOD k)+1=q + 1 + k - p MOD k/\ 1<k `) THEN RESA_TAC THEN MRESA_TAC MOD_LE[`q:num`;`k:num`] THEN MRESA_TAC DIVISION[`p:num`;`k:num`] THEN MP_TAC(ARITH_RULE`q MOD k <= q /\ p MOD k< q MOD k/\ p MOD k< k ==> q+k- p MOD k= 1*k + (q- p MOD k)`) THEN RESA_TAC THEN MRESA_TAC MOD_MULT_ADD[`1`;`k:num`;`q-p MOD k`] THEN MRESA_TAC MOD_LT[`1`;`k:num`] THEN MRESA_TAC DIVISION[`q:num`;`k:num`] THEN MRESA_TAC MOD_ADD_MOD[`q+k-p MOD k`;`1`;`k:num`] THEN POP_ASSUM MP_TAC THEN REMOVE_ASSUM_TAC THEN POP_ASSUM(fun th-> ONCE_REWRITE_TAC[th]) THEN MP_TAC(ARITH_RULE`q MOD k <= q /\ p MOD k< q MOD k/\ p MOD k< k ==> (q DIV k * k + q MOD k)- p MOD k= (q DIV k)*k + (q MOD k- p MOD k)`) THEN RESA_TAC THEN MRESA_TAC MOD_MULT_ADD[`q DIV k `;`k:num`;`q MOD k-p MOD k`] THEN MRESA_TAC DIVISION[`q:num`;`k:num`] THEN MP_TAC(ARITH_RULE` p MOD k< q MOD k/\ q MOD k< k ==> q MOD k- p MOD k<k`) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`q MOD k - p MOD k`;`k:num`] THEN STRIP_TAC THEN MRESA_TAC MOD_LE[`q MOD k - p MOD k +1:num`;`k:num`] THEN MP_TAC(ARITH_RULE`k' <= q MOD k - p MOD k + 1 /\ 3<= k' ==> k' -1 + p MOD k <= q MOD k`) THEN RESA_TAC THEN REPLICATE_TAC (32-26) (POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN ONCE_REWRITE_TAC[SYM th] THEN ASSUME_TAC(SYM th)) THEN ASM_REWRITE_TAC[]; MP_TAC(ARITH_RULE`3<= k' /\ k'<k /\ p MOD k< q MOD k ==> ~(k=0)/\ (q +k -p MOD k)+1=q + 1 + k - p MOD k/\ 1<k `) THEN RESA_TAC THEN MRESA_TAC DIVISION[`q:num`;`k:num`] THEN MP_TAC(ARITH_RULE`i< k'-1 /\ k'-1 + p MOD k <= q MOD k/\ 3<=k' /\ q MOD k < k ==> i + p MOD k < q MOD k/\ i + p MOD k<k`) THEN RESA_TAC THEN SUBGOAL_THEN`(k'' +q MOD k) <= k+ p MOD k+1 `ASSUME_TAC; MP_TAC(ARITH_RULE`(p +k -q MOD k)+1=(p + 1 + k - q MOD k) `) THEN RESA_TAC THEN EXPAND_TAC"k''" THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN MRESA_TAC MOD_LT[`1`;`k:num`] THEN MRESA_TAC MOD_ADD_MOD[`p+k-q MOD k`;`1`;`k:num`] THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN MRESA_TAC DIVISION[`p:num`;`k:num`] THEN REMOVE_ASSUM_TAC THEN POP_ASSUM(fun th-> ONCE_REWRITE_TAC[th] THEN MP_TAC(ARITH_RULE`(p DIV k * k + p MOD k) + k - q MOD k= (p DIV k)*k + (p MOD k + k - q MOD k)`) THEN RESA_TAC THEN MRESA_TAC MOD_MULT_ADD[`p DIV k `;`k:num`;`p MOD k + k - q MOD k`] THEN ONCE_REWRITE_TAC[SYM th]) THEN MRESA_TAC MOD_LE[`p MOD k + k - q MOD k:num`;`k:num`] THEN MRESA_TAC MOD_LE[`(p MOD k + k - q MOD k) MOD k +1:num`;`k:num`] THEN MP_TAC(ARITH_RULE`(p MOD k + k - q MOD k) MOD k <= p MOD k + k - q MOD k /\ ((p MOD k + k - q MOD k) MOD k + 1) MOD k <= (p MOD k + k - q MOD k) MOD k + 1 /\ q MOD k <k ==> ((p MOD k + k - q MOD k) MOD k + 1) MOD k + q MOD k <= k+ p MOD k +1`) THEN RESA_TAC; ASM_TAC THEN REWRITE_TAC[scs_diag] THEN REPEAT STRIP_TAC THEN MRESAL_TAC (GEN_ALL SCS_K_PRIME_LE_GE)[`s:scs_v39`;`q:num`;`p:num`;`d'':real`;`scs_J_v39 s' p q`][MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;scs_diag;is_scs_v39;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;scs_half_slice_v39;IN_ELIM_THM] THEN MP_TAC(ARITH_RULE`i'<k''-1 /\ 3<= k'' /\ k'' + q MOD k <= k + p MOD k + 1 ==> i'+ q MOD k < k + p MOD k `) THEN RESA_TAC THEN MP_TAC(ARITH_RULE`i'+ q MOD k< k \/ k <= i' + q MOD k `) THEN RESA_TAC; MRESA_TAC MOD_LT[`i' + q MOD k`;`k:num`] THEN MRESA_TAC MOD_LT[`i + p MOD k`;`k:num`] THEN MP_TAC(ARITH_RULE`q MOD k<= i'+ q MOD k`) THEN RESA_TAC THEN POP_ASSUM MP_TAC THEN REWRITE_TAC[] THEN ASM_REWRITE_TAC[ARITH_RULE`~(q MOD k <= i + p MOD k)<=> i + p MOD k< q MOD k`]; MRESA_TAC DIVISION[`p:num`;`k:num`] THEN MP_TAC(ARITH_RULE`i' + q MOD k < k + p MOD k /\ k <= i' + q MOD k /\ p MOD k<k ==> 1 * k + (i' + q MOD k) - k = i' + q MOD k /\ (i' + q MOD k) - k <k /\ (i' + q MOD k) - k < p MOD k`) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`(i' + q MOD k)-k`;`k:num`] THEN MRESA_TAC MOD_LT[`i + p MOD k`;`k:num`] THEN MRESA_TAC MOD_MULT_ADD[`1 `;`k:num`;`(i' + q MOD k) -k`] THEN MP_TAC(ARITH_RULE`i< k'-1 /\ k'-1 + p MOD k <= q MOD k/\ 3<=k' /\ q MOD k < k ==> p MOD k <= i + p MOD k/\ i + p MOD k < q MOD k/\ i + p MOD k<k`) THEN RESA_TAC THEN POP_ASSUM MP_TAC THEN REMOVE_ASSUM_TAC THEN REMOVE_ASSUM_TAC THEN REMOVE_ASSUM_TAC THEN POP_ASSUM MP_TAC THEN ARITH_TAC]);;
let INTER_SLICE_SCS_EMPTY=
prove(` scs_half_slice_v39 s p q d' mkj =s'/\ scs_half_slice_v39 s q p d'' mkj =s'' /\ is_scs_v39 s /\ scs_diag (scs_k_v39 s) p q ==> {(i + p MOD scs_k_v39 s) MOD scs_k_v39 s | i < scs_k_v39 s'-1 } INTER {(i + q MOD scs_k_v39 s)MOD scs_k_v39 s | i < scs_k_v39 s''-1 }={} `,
REWRITE_TAC[scs_diag] THEN STRIP_TAC THEN MP_TAC(ARITH_RULE`~(p MOD scs_k_v39 s = q MOD scs_k_v39 s) ==> (p MOD scs_k_v39 s < q MOD scs_k_v39 s)\/ (q MOD scs_k_v39 s < p MOD scs_k_v39 s)`) THEN RESA_TAC THENL[ MATCH_MP_TAC INTER_SLICE_SCS_EMPTY1 THEN ASM_REWRITE_TAC[scs_diag]; ONCE_REWRITE_TAC[SET_RULE`A INTER B= B INTER A`] THEN MATCH_MP_TAC (GEN_ALL INTER_SLICE_SCS_EMPTY1) THEN ASM_REWRITE_TAC[scs_diag] THEN EXISTS_TAC`d'':real` THEN EXISTS_TAC`d':real` THEN EXISTS_TAC`mkj:bool` THEN ASM_REWRITE_TAC[]]);;
let QKNVMLB2 = 
prove_by_refinement( ` scs_half_slice_v39 s p q d' mkj =s'/\ scs_half_slice_v39 s q p d'' mkj =s'' /\ vv' = (\i. (vv:num->real^3) (i MOD (scs_k_v39 s')+p MOD (scs_k_v39 s))) /\ vv'' = (\i. (vv:num->real^3) (i MOD (scs_k_v39 s'')+q MOD (scs_k_v39 s))) /\ MMs_v39 s vv /\ is_scs_v39 s /\ scs_diag (scs_k_v39 s) p q /\ is_scs_slice_v39 s s' s'' p q /\ scs_d_v39 s <= d' + d'' ==> dsv_v39 s vv <= dsv_v39 s' vv' + dsv_v39 s'' vv''`,
[ STRIP_TAC THEN POP_ASSUM MP_TAC (*THEN MP_TAC SCS_HALF_SLICE_IS_SCS THEN RESA_TAC*) THEN MRESA_TAC (GEN_ALL SCS_K_PRIME_LE_GE)[`s:scs_v39`;`p:num`;`q:num`;`d':real`;`scs_J_v39 s' p q`] THEN POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[LET_DEF;LET_END_DEF;] THEN MRESA_TAC (GEN_ALL SCS_K_PRIME_LE_GE)[`s:scs_v39`;`q:num`;`p:num`;`d'':real`;`scs_J_v39 s' p q`] THEN POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[LET_DEF;LET_END_DEF;] THEN MP_TAC SCS_K_PRIME_CASE_3 THEN RESA_TAC THEN MP_TAC DIAG_IS_NOT_EAR THEN RESA_TAC THEN MP_TAC(ARITH_RULE`3<scs_k_v39 s ==> ~(scs_k_v39 s<=3)`) THEN RESA_TAC THEN MP_TAC DIAG_NOT_IN_SCS_J THEN RESA_TAC THEN REPLICATE_TAC 7 (POP_ASSUM MP_TAC) THEN ASM_REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;] THEN ABBREV_TAC`k'=(q + 1 + scs_k_v39 s - p MOD scs_k_v39 s) MOD scs_k_v39 s` THEN ABBREV_TAC`k''=(p + 1 + scs_k_v39 s - q MOD scs_k_v39 s) MOD scs_k_v39 s` THEN ABBREV_TAC`k= scs_k_v39 s` THEN REPEAT RESA_TAC ; REPLICATE_TAC (49-37) (POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th] THEN ASSUME_TAC(SYM th)) THEN REPEAT STRIP_TAC THEN REPLICATE_TAC (7) (POP_ASSUM MP_TAC) THEN ASM_REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;scs_half_slice_v39] THEN REPEAT RESA_TAC THEN SUBGOAL_THEN`FINITE {i | i < scs_k_v39 s' - 1 /\ scs_J_v39 s' i (SUC i)} ` ASSUME_TAC ; MATCH_MP_TAC FINITE_SUBSET THEN EXISTS_TAC`0.. (scs_k_v39 s' -1)` THEN REWRITE_TAC[FINITE_NUMSEG;SUBSET;IN_ELIM_THM;IN_NUMSEG] THEN ARITH_TAC; SUBGOAL_THEN`{i | i < scs_k_v39 s' - 1 /\ scs_J_v39 s' i (SUC i)} INTER {i| i=scs_k_v39 s' - 1/\ scs_J_v39 s' (scs_k_v39 s' - 1) (SUC (scs_k_v39 s' - 1)) }={}` ASSUME_TAC ; REWRITE_TAC[INTER;SET_RULE`A={}<=> ~(?a. a IN A)`;IN_ELIM_THM;IN_SING] THEN ARITH_TAC; SUBGOAL_THEN`{i | i < scs_k_v39 s' - 1 /\ scs_J_v39 s' i (SUC i)} UNION {i| i=scs_k_v39 s' - 1/\ scs_J_v39 s' (scs_k_v39 s' - 1) (SUC(scs_k_v39 s'-1)) }={i | i < scs_k_v39 s' /\ scs_J_v39 s' i (SUC i)}` ASSUME_TAC; REWRITE_TAC[UNION;IN_SING;IN_ELIM_THM;EXTENSION] THEN GEN_TAC THEN EXPAND_TAC "s'" THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;scs_half_slice_v39] THEN ASM_REWRITE_TAC[] THEN REPLICATE_TAC (47-43) REMOVE_ASSUM_TAC THEN EQ_TAC ; RESA_TAC ; REPLICATE_TAC (47-40) (POP_ASSUM MP_TAC) THEN ARITH_TAC ; MP_TAC(ARITH_RULE`3<=k' ==>SUC (k' - 1) =k'/\ k'-1<k'`) THEN RESA_TAC; RESA_TAC THEN MP_TAC(ARITH_RULE`x<k' /\ 3<= k' ==> x< k'-1 \/ (x=k'-1)`) THEN RESA_TAC THEN POP_ASSUM (fun th-> POP_ASSUM MP_TAC THEN REWRITE_TAC[th] THEN RESA_TAC) ; SUBGOAL_THEN`FINITE {i | i = scs_k_v39 s' - 1 /\ scs_J_v39 s' (scs_k_v39 s' - 1) (SUC (scs_k_v39 s' - 1))}`ASSUME_TAC ; MATCH_MP_TAC FINITE_SUBSET THEN EXISTS_TAC`{(scs_k_v39 s' -1)}` THEN REWRITE_TAC[FINITE_NUMSEG;SUBSET;IN_ELIM_THM;IN_SING;FINITE_SING] THEN SET_TAC[]; MRESAL_TAC SUM_INCL_EXCL[`{i | i < scs_k_v39 s'-1 /\ scs_J_v39 s' i (SUC i)}`;`{i| i=scs_k_v39 s' - 1/\ scs_J_v39 s' (scs_k_v39 s' - 1) (SUC(scs_k_v39 s'-1)) }`;`(\i. cstab - dist ((vv:num->real^3) (i MOD scs_k_v39 s' + p MOD k), vv (SUC i MOD scs_k_v39 s' + p MOD k)))`][FINITE_SING;SUM_SING;SUM_CLAUSES;REAL_ARITH`a+ &0=a`] THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN SUBGOAL_THEN`FINITE {i | i < scs_k_v39 s'' - 1 /\ scs_J_v39 s'' i (SUC i)} ` ASSUME_TAC ; MATCH_MP_TAC FINITE_SUBSET THEN EXISTS_TAC`0.. (scs_k_v39 s'' -1)` THEN REWRITE_TAC[FINITE_NUMSEG;SUBSET;IN_ELIM_THM;IN_NUMSEG] THEN ARITH_TAC; SUBGOAL_THEN`{i | i < scs_k_v39 s'' - 1 /\ scs_J_v39 s'' i (SUC i)} INTER {i| i=scs_k_v39 s'' - 1/\ scs_J_v39 s'' (scs_k_v39 s'' - 1) (SUC (scs_k_v39 s'' - 1)) }={}` ASSUME_TAC ; REWRITE_TAC[INTER;SET_RULE`A={}<=> ~(?a. a IN A)`;IN_ELIM_THM;IN_SING] THEN ARITH_TAC; SUBGOAL_THEN`{i | i < scs_k_v39 s'' - 1 /\ scs_J_v39 s'' i (SUC i)} UNION {i| i=scs_k_v39 s'' - 1/\ scs_J_v39 s'' (scs_k_v39 s'' - 1) (SUC(scs_k_v39 s''-1)) }={i | i < scs_k_v39 s'' /\ scs_J_v39 s'' i (SUC i)}` ASSUME_TAC; REWRITE_TAC[UNION;IN_SING;IN_ELIM_THM;EXTENSION] THEN GEN_TAC THEN EXPAND_TAC "s''" THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;scs_half_slice_v39] THEN ASM_REWRITE_TAC[] THEN REPLICATE_TAC (47-43) REMOVE_ASSUM_TAC THEN EQ_TAC ; RESA_TAC ; REPLICATE_TAC (47-40) (POP_ASSUM MP_TAC) THEN ARITH_TAC ; MP_TAC(ARITH_RULE`3<=k'' ==>SUC (k'' - 1) =k''/\ k''-1<k''`) THEN RESA_TAC; RESA_TAC THEN MP_TAC(ARITH_RULE`x<k'' /\ 3<= k'' ==> x< k''-1 \/ (x=k''-1)`) THEN RESA_TAC THEN POP_ASSUM (fun th-> POP_ASSUM MP_TAC THEN REWRITE_TAC[th] THEN RESA_TAC) ; SUBGOAL_THEN`FINITE {i | i = scs_k_v39 s'' - 1 /\ scs_J_v39 s'' (scs_k_v39 s'' - 1) (SUC (scs_k_v39 s'' - 1))}`ASSUME_TAC ; MATCH_MP_TAC FINITE_SUBSET THEN EXISTS_TAC`{(scs_k_v39 s'' -1)}` THEN REWRITE_TAC[FINITE_NUMSEG;SUBSET;IN_ELIM_THM;IN_SING;FINITE_SING] THEN SET_TAC[]; MRESAL_TAC SUM_INCL_EXCL[`{i | i < scs_k_v39 s''-1 /\ scs_J_v39 s'' i (SUC i)}`;`{i| i=scs_k_v39 s'' - 1/\ scs_J_v39 s'' (scs_k_v39 s'' - 1) (SUC(scs_k_v39 s''-1)) }`;`(\i. cstab - dist ((vv:num->real^3) (i MOD scs_k_v39 s'' + q MOD k), vv (SUC i MOD scs_k_v39 s'' + q MOD k)))`][FINITE_SING;SUM_SING;SUM_CLAUSES;REAL_ARITH`a+ &0=a`] THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN SUBGOAL_THEN`sum {i | i < scs_k_v39 s' - 1 /\ scs_J_v39 s' i (SUC i)} (\i. cstab - dist (vv (i MOD scs_k_v39 s' + p MOD k), (vv:num->real^3) (SUC i MOD scs_k_v39 s' + p MOD k))) = sum {(i + p MOD scs_k_v39 s) MOD scs_k_v39 s | i < scs_k_v39 s'-1 /\ scs_J_v39 s' i (SUC i)} (\i. cstab - dist (vv (i ), vv (SUC i )))`ASSUME_TAC ; MATCH_MP_TAC SUM_EQ_GENERAL THEN REWRITE_TAC[IN_ELIM_THM] THEN EXISTS_TAC`(\i. (i + p MOD scs_k_v39 s) MOD scs_k_v39 s)` THEN ASM_REWRITE_TAC[EXISTS_UNIQUE] THEN REPEAT RESA_TAC; EXISTS_TAC`i:num` THEN ASM_REWRITE_TAC[] ; REPEAT STRIP_TAC THEN REPLICATE_TAC (47-40) (POP_ASSUM MP_TAC) THEN EXPAND_TAC "s'" THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;scs_half_slice_v39] THEN ASM_REWRITE_TAC[] THEN REPEAT STRIP_TAC THEN MP_TAC(ARITH_RULE`i<k'-1/\ y'<k'-1 /\ k'< k/\ 3<=k' ==> i<k /\ y'<k/\ ~(k=0)`) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`i:num`;`k:num`] THEN MRESA_TAC MOD_LT[`y':num`;`k:num`] THEN MRESAL_TAC Hdplygy.MOD_EQ_MOD[`i:num`;`y':num`;`p MOD k`;`k:num`][ADD_SYM]; EXISTS_TAC`x:num` THEN ASM_REWRITE_TAC[] ; POP_ASSUM MP_TAC THEN POP_ASSUM MP_TAC THEN EXPAND_TAC "s'" THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;scs_half_slice_v39] THEN ASM_REWRITE_TAC[] THEN REPEAT STRIP_TAC THEN MP_TAC(ARITH_RULE`x<k'-1/\ 3<=k'/\k'<k ==> x<k'/\ ~(k'=0)/\ SUC x< k'/\ ~(k=0)/\ 1<k`) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`x:num`;`k':num`] THEN MRESA_TAC MOD_LT[`SUC x:num`;`k':num`] THEN ASM_TAC THEN REWRITE_TAC[periodic2;MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;scs_half_slice_v39] THEN REPEAT STRIP_TAC THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`vv:num-> real^3`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th `(x + p MOD k):num` THEN MRESA1_TAC th ` ((x + p MOD k) +1):num` THEN MRESA1_TAC th ` SUC ((x + p MOD k) MOD k):num`) THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN REWRITE_TAC[ADD1] THEN MRESA_TAC MOD_LT[`1`;`k:num`] THEN MRESA_TAC MOD_ADD_MOD[`x+p MOD k`;`1`;`k:num`] THEN REWRITE_TAC[ARITH_RULE`((x + p MOD k) + 1)= (x+ 1) + p MOD k`] ; SUBGOAL_THEN`sum {i | i < scs_k_v39 s'' - 1 /\ scs_J_v39 s'' i (SUC i)} (\i. cstab - dist (vv (i MOD scs_k_v39 s'' + q MOD k), (vv:num->real^3) (SUC i MOD scs_k_v39 s'' + q MOD k))) = sum {(i + q MOD scs_k_v39 s) MOD scs_k_v39 s | i < scs_k_v39 s''-1 /\ scs_J_v39 s'' i (SUC i)} (\i. cstab - dist (vv (i ), vv (SUC i )))`ASSUME_TAC ; MATCH_MP_TAC SUM_EQ_GENERAL THEN REWRITE_TAC[IN_ELIM_THM] THEN EXISTS_TAC`(\i. (i + q MOD scs_k_v39 s) MOD scs_k_v39 s)` THEN ASM_REWRITE_TAC[EXISTS_UNIQUE] THEN REPEAT RESA_TAC; EXISTS_TAC`i:num` THEN ASM_REWRITE_TAC[] ; REPEAT STRIP_TAC THEN REPLICATE_TAC (47-40) (POP_ASSUM MP_TAC) THEN EXPAND_TAC "s''" THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;scs_half_slice_v39] THEN ASM_REWRITE_TAC[] THEN REPEAT STRIP_TAC THEN MP_TAC(ARITH_RULE`i<k''-1/\ y'<k''-1 /\ k''< k/\ 3<=k'' ==> i<k /\ y'<k/\ ~(k=0)`) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`i:num`;`k:num`] THEN MRESA_TAC MOD_LT[`y':num`;`k:num`] THEN MRESAL_TAC Hdplygy.MOD_EQ_MOD[`i:num`;`y':num`;`q MOD k`;`k:num`][ADD_SYM]; EXISTS_TAC`x:num` THEN ASM_REWRITE_TAC[] ; POP_ASSUM MP_TAC THEN POP_ASSUM MP_TAC THEN EXPAND_TAC "s''" THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;scs_half_slice_v39] THEN ASM_REWRITE_TAC[] THEN REPEAT STRIP_TAC THEN MP_TAC(ARITH_RULE`x<k''-1/\ 3<=k''/\k''<k ==> x<k''/\ ~(k''=0)/\ SUC x< k''/\ ~(k=0)/\ 1<k`) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`x:num`;`k'':num`] THEN MRESA_TAC MOD_LT[`SUC x:num`;`k'':num`] THEN ASM_TAC THEN REWRITE_TAC[periodic2;MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;scs_half_slice_v39] THEN REPEAT STRIP_TAC THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`vv:num-> real^3`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th `(x + q MOD k):num` THEN MRESA1_TAC th ` ((x + q MOD k) +1):num` THEN MRESA1_TAC th ` SUC ((x + q MOD k) MOD k):num`) THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN REWRITE_TAC[ADD1] THEN MRESA_TAC MOD_LT[`1`;`k:num`] THEN MRESA_TAC MOD_ADD_MOD[`x+q MOD k`;`1`;`k:num`] THEN REWRITE_TAC[ARITH_RULE`((x + q MOD k) + 1)= (x+ 1) + q MOD k`] ; ASM_REWRITE_TAC[ REAL_ARITH`a + b * (-- &1) *c <= (a1 + b * d1 *(c1+c2)) + a2 + b * d2 *(c3+c4) <=> &0<= (a1+ a2-a) + b*(c+ d1* c1 +d2*c3)+ b*(d1* c2+ d2* c4)`] THEN MATCH_MP_TAC(REAL_ARITH`&0<=a /\ &0<=b /\ &0<=c==> &0<= a+b+c`) THEN STRIP_TAC; EXPAND_TAC "s'" THEN EXPAND_TAC "s''" THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;scs_half_slice_v39] THEN ASM_REWRITE_TAC[REAL_ARITH`&0<= A+B -C<=> C<= A+B`] ; STRIP_TAC; MATCH_MP_TAC(REAL_ARITH`&0<= a==> &0<= #0.1 *a`) THEN SUBGOAL_THEN`-- &1<= if is_ear_v39 s' then &1 else -- &1` ASSUME_TAC; MP_TAC(SET_RULE`is_ear_v39 s' \/ ~(is_ear_v39 s')`) THEN RESA_TAC THEN REAL_ARITH_TAC; SUBGOAL_THEN`-- &1<= if is_ear_v39 s'' then &1 else -- &1` ASSUME_TAC; MP_TAC(SET_RULE`is_ear_v39 s'' \/ ~(is_ear_v39 s'')`) THEN RESA_TAC THEN REAL_ARITH_TAC; SUBGOAL_THEN`&0<= sum {(i + p MOD k) MOD k | i < scs_k_v39 s' - 1 /\ scs_J_v39 s' i (SUC i)} (\i. cstab - dist ((vv:num->real^3) i,vv (SUC i)))`ASSUME_TAC ; MATCH_MP_TAC SUM_POS_LE THEN ASM_REWRITE_TAC[] THEN STRIP_TAC; MATCH_MP_TAC FINITE_SUBSET THEN EXISTS_TAC`0.. k` THEN REWRITE_TAC[FINITE_NUMSEG;SUBSET;IN_ELIM_THM;IN_NUMSEG;ARITH_RULE`0<= a`] THEN GEN_TAC THEN RESA_TAC THEN MP_TAC(ARITH_RULE`3<=k ==> ~(k=0)`) THEN RESA_TAC THEN MRESA_TAC DIVISION[`i + p MOD k`;`k:num`] THEN POP_ASSUM MP_TAC THEN ARITH_TAC; REWRITE_TAC[IN_ELIM_THM] THEN REPEAT RESA_TAC THEN ASM_TAC THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist] THEN ASM_REWRITE_TAC[REAL_ARITH`&0<= A+B -C<=> C<= A+B`] THEN REPEAT RESA_TAC THEN REPLICATE_TAC (75-6)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESA_TAC th[`(i + p MOD k) MOD k`;`SUC ((i + p MOD k) MOD k)`]) THEN REPLICATE_TAC (76-34)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESA1_TAC th`(i + p MOD k) MOD k`) THEN POP_ASSUM MP_TAC THEN POP_ASSUM MP_TAC THEN REAL_ARITH_TAC ; SUBGOAL_THEN`&0<= sum {(i + q MOD k) MOD k | i < scs_k_v39 s'' - 1 /\ scs_J_v39 s'' i (SUC i)} (\i. cstab - dist ((vv:num->real^3) i,vv (SUC i)))`ASSUME_TAC ; MATCH_MP_TAC SUM_POS_LE THEN ASM_REWRITE_TAC[] THEN STRIP_TAC; MATCH_MP_TAC FINITE_SUBSET THEN EXISTS_TAC`0.. k` THEN REWRITE_TAC[FINITE_NUMSEG;SUBSET;IN_ELIM_THM;IN_NUMSEG;ARITH_RULE`0<= a`] THEN GEN_TAC THEN RESA_TAC THEN MP_TAC(ARITH_RULE`3<=k ==> ~(k=0)`) THEN RESA_TAC THEN MRESA_TAC DIVISION[`i + q MOD k`;`k:num`] THEN POP_ASSUM MP_TAC THEN ARITH_TAC; REWRITE_TAC[IN_ELIM_THM] THEN REPEAT RESA_TAC THEN ASM_TAC THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist] THEN ASM_REWRITE_TAC[REAL_ARITH`&0<= A+B -C<=> C<= A+B`] THEN REPEAT RESA_TAC THEN REPLICATE_TAC (76-6)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESA_TAC th[`(i + q MOD k) MOD k`;`SUC ((i + q MOD k) MOD k)`]) THEN REPLICATE_TAC (77-34)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESA1_TAC th`(i + q MOD k) MOD k`) THEN POP_ASSUM MP_TAC THEN POP_ASSUM MP_TAC THEN REAL_ARITH_TAC ; MRESA_TAC REAL_LE_RMUL[`-- &1`;`(if is_ear_v39 s' then &1 else -- &1)`;`sum {(i + p MOD k) MOD k | i < scs_k_v39 s' - 1 /\ scs_J_v39 s' i (SUC i)} (\i. cstab - dist (vv i,(vv:num->real^3) (SUC i)))`] THEN MRESA_TAC REAL_LE_RMUL[`-- &1`;`(if is_ear_v39 s'' then &1 else -- &1)`;`sum {(i + q MOD k) MOD k | i < scs_k_v39 s'' - 1 /\ scs_J_v39 s'' i (SUC i)} (\i. cstab - dist (vv i,(vv:num->real^3) (SUC i)))`] THEN SUBGOAL_THEN`FINITE {(i + p MOD k) MOD k | i < scs_k_v39 s' - 1 /\ scs_J_v39 s' i (SUC i)}`ASSUME_TAC ; MATCH_MP_TAC FINITE_SUBSET THEN EXISTS_TAC`0.. k` THEN REWRITE_TAC[FINITE_NUMSEG;SUBSET;IN_ELIM_THM;IN_NUMSEG;ARITH_RULE`0<= a`] THEN GEN_TAC THEN RESA_TAC THEN MP_TAC(ARITH_RULE`3<=k ==> ~(k=0)`) THEN RESA_TAC THEN MRESA_TAC DIVISION[`i + q MOD k`;`k:num`] THEN POP_ASSUM MP_TAC THEN ARITH_TAC; SUBGOAL_THEN`FINITE {(i + q MOD k) MOD k | i < scs_k_v39 s'' - 1 /\ scs_J_v39 s'' i (SUC i)}`ASSUME_TAC ; MATCH_MP_TAC FINITE_SUBSET THEN EXISTS_TAC`0.. k` THEN REWRITE_TAC[FINITE_NUMSEG;SUBSET;IN_ELIM_THM;IN_NUMSEG;ARITH_RULE`0<= a`] THEN GEN_TAC THEN RESA_TAC THEN MP_TAC(ARITH_RULE`3<=k ==> ~(k=0)`) THEN RESA_TAC THEN MRESA_TAC DIVISION[`i + q MOD k`;`k:num`] THEN POP_ASSUM MP_TAC THEN ARITH_TAC; SUBGOAL_THEN`&0 <= sum {i | i < k /\ scs_J_v39 s i (SUC i)} (\i. cstab - dist (vv i,vv (SUC i))) - (sum {(i + p MOD k) MOD k | i < scs_k_v39 s' - 1 /\ scs_J_v39 s' i (SUC i)} (\i. cstab - dist (vv i,vv (SUC i))) + sum {(i + q MOD k) MOD k | i < scs_k_v39 s'' - 1 /\ scs_J_v39 s'' i (SUC i)} (\i. cstab - dist (vv i,(vv:num->real^3) (SUC i))))` ASSUME_TAC ; SUBGOAL_THEN`(!i. scs_b_v39 s i (SUC i) <= cstab)`ASSUME_TAC; REPLICATE_TAC (67-24)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MATCH_MP_TAC th) THEN ASM_REWRITE_TAC[]; MP_TAC INTER_SLICE_SCS_EMPTY THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist] THEN ASM_REWRITE_TAC[REAL_ARITH`&0<= A+B -C<=> C<= A+B`] THEN REPLICATE_TAC (68-37)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[th] THEN ASSUME_TAC th THEN REPEAT RESA_TAC) THEN SUBGOAL_THEN`{(i + p MOD k) MOD k | i < scs_k_v39 s' - 1 /\ scs_J_v39 s' i (SUC i)} INTER {(i + q MOD k) MOD k | i < scs_k_v39 s'' - 1 /\ scs_J_v39 s'' i (SUC i)}={}`ASSUME_TAC ; POP_ASSUM MP_TAC THEN REWRITE_TAC[INTER;IN_ELIM_THM] THEN SET_TAC[]; MRESAL_TAC SUM_INCL_EXCL[`{(i + p MOD k) MOD k | i < scs_k_v39 s' - 1 /\ scs_J_v39 s' i (SUC i)}`;`{(i + q MOD k) MOD k | i < scs_k_v39 s'' - 1 /\ scs_J_v39 s'' i (SUC i)}`;`(\i. cstab - dist ((vv:num->real^3) i,vv (SUC i)))`][SUM_CLAUSES;REAL_ARITH`a+ &0=a`;dist] THEN SUBGOAL_THEN`{(i + p MOD k) MOD k | i < scs_k_v39 s' - 1 /\ scs_J_v39 s' i (SUC i)} UNION {(i + q MOD k) MOD k | i < scs_k_v39 s'' - 1 /\ scs_J_v39 s'' i (SUC i)} SUBSET {i | i < k /\ scs_J_v39 s i (SUC i)}`ASSUME_TAC ; REWRITE_TAC[UNION;IN_ELIM_THM;SUBSET] THEN REPEAT RESA_TAC ; MP_TAC(ARITH_RULE`3<k==> ~(k=0)`) THEN RESA_TAC THEN MRESA_TAC DIVISION[`i + p MOD k`;`k:num`] ; MP_TAC SCS_J_PRIME_SUBSET_SCS_J THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist] THEN ASM_REWRITE_TAC[REAL_ARITH`&0<= A+B -C<=> C<= A+B`] ; MP_TAC(ARITH_RULE`3<k==> ~(k=0)`) THEN RESA_TAC THEN MRESA_TAC DIVISION[`i + q MOD k`;`k:num`] ; MRESA_TAC(GEN_ALL SCS_J_PRIME_SUBSET_SCS_J)[`d'':real`;`mkj:bool`;`p:num`;`s'':scs_v39`;`i:num`;`q:num`;`s:scs_v39`] THEN POP_ASSUM MATCH_MP_TAC THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist] THEN ASM_REWRITE_TAC[REAL_ARITH`&0<= A+B -C<=> C<= A+B`]; SUBGOAL_THEN`FINITE {i | i < k /\ scs_J_v39 s i (SUC i)}` ASSUME_TAC ; MATCH_MP_TAC FINITE_SUBSET THEN EXISTS_TAC`0..k` THEN REWRITE_TAC[FINITE_NUMSEG;SUBSET;IN_ELIM_THM;IN_NUMSEG] THEN ARITH_TAC; MRESA_TAC SUM_DIFF[`(\i. cstab - norm (vv i - (vv:num->real^3) (SUC i)))`;`{i | i < k /\ scs_J_v39 s i (SUC i)}`;`{(i + p MOD k) MOD k | i < scs_k_v39 s' - 1 /\ scs_J_v39 s' i (SUC i)} UNION {(i + q MOD k) MOD k | i < scs_k_v39 s'' - 1 /\ scs_J_v39 s'' i (SUC i)}`;] THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN MATCH_MP_TAC SUM_POS_LE THEN ASM_REWRITE_TAC[] THEN STRIP_TAC; MATCH_MP_TAC FINITE_SUBSET THEN EXISTS_TAC`0.. k` THEN REWRITE_TAC[FINITE_NUMSEG;SUBSET; DIFF;IN_ELIM_THM;IN_NUMSEG;ARITH_RULE`0<= a`] THEN ARITH_TAC; REWRITE_TAC[IN_ELIM_THM;DIFF] THEN REPEAT RESA_TAC THEN ASM_TAC THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist] THEN ASM_REWRITE_TAC[REAL_ARITH`&0<= A+B -C<=> C<= A+B`] THEN REPEAT RESA_TAC THEN REPLICATE_TAC (87-7)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESA_TAC th[`x:num`;`SUC (x)`]) THEN REPLICATE_TAC (88-78)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESA1_TAC th`x:num`) THEN POP_ASSUM MP_TAC THEN POP_ASSUM MP_TAC THEN REAL_ARITH_TAC; MATCH_MP_TAC(REAL_ARITH`-- &1 *a <=c* a /\ -- &1 *b<= d*b /\ &0<= a1-(a+b) ==> &0<= a1+ c*a+d*b`) THEN ASM_REWRITE_TAC[] ; MATCH_MP_TAC(REAL_ARITH`&0<=a ==> &0<= #0.1 *a`) THEN MP_TAC SCS_J_DIAG_EQ THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist;] THEN ASM_SIMP_TAC[REAL_ARITH`&0<= A+B -C<=> C<= A+B`] THEN REPLICATE_TAC (59-31)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN REPLICATE_TAC (1)(POP_ASSUM MP_TAC) THEN GEN_REWRITE_TAC(LAND_CONV o LAND_CONV o LAND_CONV o LAND_CONV o ONCE_DEPTH_CONV)[th] THEN ASSUME_TAC th) THEN REWRITE_TAC[] THEN REPLICATE_TAC (59-31)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN REPLICATE_TAC (1)(POP_ASSUM MP_TAC) THEN GEN_REWRITE_TAC(LAND_CONV o LAND_CONV o LAND_CONV o ONCE_DEPTH_CONV)[th] THEN ASSUME_TAC th) THEN RESA_TAC THEN SUBGOAL_THEN`scs_k_v39 s'=k'`ASSUME_TAC ; EXPAND_TAC"s'" THEN EXPAND_TAC"s''" THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist;scs_half_slice_v39] THEN ASM_REWRITE_TAC[REAL_ARITH`&0<= A+B -C<=> C<= A+B`] ; SUBGOAL_THEN`scs_k_v39 s''=k''`ASSUME_TAC ; EXPAND_TAC"s'" THEN EXPAND_TAC"s''" THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist;scs_half_slice_v39] THEN ASM_REWRITE_TAC[REAL_ARITH`&0<= A+B -C<=> C<= A+B`] ; MP_TAC(ARITH_RULE`3<=k'/\ 3<=k'' ==> SUC(k'-1)=k' /\ SUC (k''-1)=k''`) THEN RESA_TAC THEN MP_TAC(SET_RULE`scs_J_v39 s' (scs_k_v39 s' - 1) (SUC (scs_k_v39 s' - 1)) \/ ~(scs_J_v39 s' (scs_k_v39 s' - 1) (SUC (scs_k_v39 s' - 1)))`) THEN RESA_TAC; ASM_TAC THEN REWRITE_TAC[periodic2] THEN REPEAT STRIP_TAC THEN POP_ASSUM MP_TAC THEN MP_TAC SCS_HALF_SLICE_IS_A_SCS THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist;periodic2] THEN ASM_SIMP_TAC[REAL_ARITH`&0<= A+B -C<=> C<= A+B`] THEN REPLICATE_TAC (64-58)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN REPLICATE_TAC (2)(POP_ASSUM MP_TAC) THEN GEN_REWRITE_TAC(LAND_CONV o LAND_CONV o LAND_CONV o LAND_CONV o ONCE_DEPTH_CONV)[th] THEN ASSUME_TAC th THEN ASM_REWRITE_TAC[]) THEN REPLICATE_TAC (64-58)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN REPLICATE_TAC (2)(POP_ASSUM MP_TAC) THEN GEN_REWRITE_TAC( LAND_CONV o LAND_CONV o LAND_CONV o ONCE_DEPTH_CONV)[th] THEN ASSUME_TAC th) THEN RESA_TAC THEN REPLICATE_TAC (81-72)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESAL_TAC th[`0`;`k'-1`;][ARITH_RULE`0+A=A`]) THEN SUBGOAL_THEN`(!i. scs_b_v39 s i (SUC i) <= cstab)`ASSUME_TAC; REPLICATE_TAC (83-24)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MATCH_MP_TAC th) THEN ASM_REWRITE_TAC[]; MRESAL_TAC(GEN_ALL SCS_HALF_SLICE_IS_A_SCS)[`s:scs_v39`;`s':scs_v39`;`q:num`;`p:num`;`s'':scs_v39`] [MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist;periodic2] THEN REPLICATE_TAC (85-35)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[th] THEN ASSUME_TAC th THEN REPEAT RESA_TAC) THEN REPLICATE_TAC (85-36)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN POP_ASSUM MP_TAC THEN MP_TAC th THEN RESA_TAC) THEN ASM_REWRITE_TAC[SET_RULE`A\/B<=> B\/A`] THEN REPLICATE_TAC (84-63)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN REPLICATE_TAC (1)(POP_ASSUM MP_TAC) THEN GEN_REWRITE_TAC(LAND_CONV o LAND_CONV o LAND_CONV o LAND_CONV o LAND_CONV o ONCE_DEPTH_CONV)[th] THEN ASSUME_TAC th THEN ASM_REWRITE_TAC[]) THEN REPLICATE_TAC (84-62)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN REPLICATE_TAC (1)(POP_ASSUM MP_TAC) THEN GEN_REWRITE_TAC( LAND_CONV o LAND_CONV o LAND_CONV o LAND_CONV o ONCE_DEPTH_CONV)[th] THEN ASSUME_TAC th) THEN ASM_REWRITE_TAC[REAL_ARITH`a<=b+c<=> a<= c+b`] THEN STRIP_TAC THEN REPLICATE_TAC (101-92)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESAL_TAC th[`0`;`k''-1`;][ARITH_RULE`0+A=A`]) THEN REPLICATE_TAC (102-57)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th) THEN RESA_TAC THEN REWRITE_TAC[SET_RULE`{a|a=b}={b}`;SUM_SING] THEN MP_TAC(ARITH_RULE`3<=k'/\ 3<=k'' ==> (k'-1)<k' /\ (k''-1)<k''`) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`k'-1`;`k':num`] THEN MRESA_TAC MOD_LT[`k''-1`;`k'':num`] THEN MRESA_TAC (GEN_ALL W_EW_K_SCS_ADD_P)[ `d':real`;`mkj:bool`;`s':scs_v39`;`(vv:num->real^3)(p MOD k)`;`q:num`;`s:scs_v39`;`(vv:num->real^3)`;`k':num`;`p:num`;`k:num`;`(vv:num->real^3) (q MOD k)`] THEN MRESA_TAC (GEN_ALL W_EW_K_SCS_ADD_P)[ `d'':real`;`mkj:bool`;`s'':scs_v39`;`(vv:num->real^3)(q MOD k)`;`p:num`;`s:scs_v39`;`(vv:num->real^3)`;`k'':num`;`q:num`;`k:num`;`(vv:num->real^3) (p MOD k)`] THEN ASM_TAC THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist;periodic2] THEN REPEAT RESA_TAC THEN MP_TAC(ARITH_RULE`3<=k'/\ 3<=k'' ==> ~(k'=0) /\ ~(k''=0)`) THEN RESA_TAC THEN MRESAL_TAC MOD_MULT[`k':num`;`1:num`][ARITH_RULE`k'*1 =k'/\ 0+A=A`] THEN MRESAL_TAC MOD_MULT[`k'':num`;`1:num`][ARITH_RULE`k'*1 =k'/\ 0+A=A`] THEN SUBGOAL_THEN`norm ((vv:num->real^3) (q MOD k) - vv (p MOD k)) =norm (vv (p MOD k) - vv (q MOD k))`ASSUME_TAC ; MP_TAC(VECTOR_ARITH`vv (q MOD k) - vv (p MOD k) = --(vv (p MOD k) - (vv:num->real^3) (q MOD k))`) THEN STRIP_TAC THEN POP_ASSUM(fun th-> ONCE_REWRITE_TAC[th]) THEN REWRITE_TAC[NORM_NEG]; ASM_REWRITE_TAC[ARITH_RULE`a*b+c*b=(a+c)*b`] THEN MATCH_MP_TAC REAL_LE_MUL THEN STRIP_TAC; REPLICATE_TAC (124-92)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th THEN RESA_TAC) THEN REAL_ARITH_TAC ; REPLICATE_TAC (124-92)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th THEN RESA_TAC) ; POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[is_ear_v39] THEN STRIP_TAC THEN SUBGOAL_THEN`k'-1 IN {i | i < 3 /\ scs_J_v39 s' i (SUC i)}`ASSUME_TAC; ASM_REWRITE_TAC[IN_ELIM_THM;ARITH_RULE`3-1<3`] THEN REPLICATE_TAC (132-88)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th THEN ASM_REWRITE_TAC[]); POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[IN_SING;ARITH_RULE`3-1=2`] THEN STRIP_TAC THEN POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[SYM th]) THEN REPEAT STRIP_TAC THEN SUBGOAL_THEN`d' = scs_d_v39 s' `ASSUME_TAC ; EXPAND_TAC"s'" THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist;periodic2;scs_half_slice_v39] ; MP_TAC QKNVMLB1 THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist;periodic2;] THEN REPEAT RESA_TAC THEN POP_ASSUM MP_TAC THEN REWRITE_TAC[REAL_ARITH`#0.11 < #0.9`;ARITH_RULE`3<=3`] THEN STRIP_TAC THEN POP_ASSUM(fun th-> MRESA_TAC th[`2`;`SUC 2`]) THEN POP_ASSUM MP_TAC THEN REWRITE_TAC[ARITH_RULE`SUC 2 MOD 3=0/\ 0+A=A/\ 2 MOD 3=2`] THEN REPLICATE_TAC (136-117)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN POP_ASSUM MP_TAC THEN MP_TAC th THEN ASM_REWRITE_TAC[ARITH_RULE`3-1=2`]) THEN RESA_TAC THEN REAL_ARITH_TAC; POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[is_ear_v39] THEN STRIP_TAC THEN SUBGOAL_THEN`k''-1 IN {i | i < 3 /\ scs_J_v39 s'' i (SUC i)}`ASSUME_TAC; ASM_REWRITE_TAC[IN_ELIM_THM;ARITH_RULE`3-1<3`] THEN REPLICATE_TAC (132-110)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th THEN ASM_REWRITE_TAC[]); POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[IN_SING;ARITH_RULE`3-1=2`] THEN STRIP_TAC THEN POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[SYM th]) THEN REPEAT STRIP_TAC THEN SUBGOAL_THEN`d'' = scs_d_v39 s'' `ASSUME_TAC ; EXPAND_TAC"s''" THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist;periodic2;scs_half_slice_v39] ; MRESAL_TAC (GEN_ALL QKNVMLB1)[`vv:num->real^3`;`s:scs_v39`;`q:num`;`p:num`;`d'':real`;`mkj:bool`] [MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist;periodic2;] THEN REPLICATE_TAC (134-9)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN POP_ASSUM MP_TAC THEN MP_TAC th THEN RESA_TAC) THEN REWRITE_TAC[REAL_ARITH`#0.11 < #0.9`;ARITH_RULE`3<=3`] THEN STRIP_TAC THEN POP_ASSUM(fun th-> MRESA_TAC th[`2`;`SUC 2`]) THEN POP_ASSUM MP_TAC THEN REWRITE_TAC[ARITH_RULE`SUC 2 MOD 3=0/\ 0+A=A/\ 2 MOD 3=2`] THEN REPLICATE_TAC (136-117)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN POP_ASSUM MP_TAC THEN MP_TAC th THEN ASM_REWRITE_TAC[ARITH_RULE`3-1=2`]) THEN RESA_TAC THEN REAL_ARITH_TAC; MP_TAC(VECTOR_ARITH`vv (q MOD k) - vv (p MOD k) = --(vv (p MOD k) - (vv:num->real^3) (q MOD k))`) THEN STRIP_TAC THEN POP_ASSUM(fun th-> ONCE_REWRITE_TAC[th]) THEN REWRITE_TAC[NORM_NEG]; ASM_REWRITE_TAC[ARITH_RULE`a*b+c*b=(a+c)*b`] THEN MATCH_MP_TAC REAL_LE_MUL THEN STRIP_TAC; REPLICATE_TAC (124-92)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th THEN RESA_TAC) THEN REAL_ARITH_TAC ; REPLICATE_TAC (124-92)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th THEN RESA_TAC) ; POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[is_ear_v39] THEN STRIP_TAC THEN SUBGOAL_THEN`k'-1 IN {i | i < 3 /\ scs_J_v39 s' i (SUC i)}`ASSUME_TAC; ASM_REWRITE_TAC[IN_ELIM_THM;ARITH_RULE`3-1<3`] THEN REPLICATE_TAC (132-88)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th THEN ASM_REWRITE_TAC[]); POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[IN_SING;ARITH_RULE`3-1=2`] THEN STRIP_TAC THEN POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[SYM th]) THEN REPEAT STRIP_TAC THEN SUBGOAL_THEN`d' = scs_d_v39 s' `ASSUME_TAC ; EXPAND_TAC"s'" THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist;periodic2;scs_half_slice_v39] ; MP_TAC QKNVMLB1 THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist;periodic2;] THEN REPEAT RESA_TAC THEN POP_ASSUM MP_TAC THEN REWRITE_TAC[REAL_ARITH`#0.11 < #0.9`;ARITH_RULE`3<=3`] THEN STRIP_TAC THEN POP_ASSUM(fun th-> MRESA_TAC th[`2`;`SUC 2`]) THEN POP_ASSUM MP_TAC THEN REWRITE_TAC[ARITH_RULE`SUC 2 MOD 3=0/\ 0+A=A/\ 2 MOD 3=2`] THEN REPLICATE_TAC (136-117)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN POP_ASSUM MP_TAC THEN MP_TAC th THEN ASM_REWRITE_TAC[ARITH_RULE`3-1=2`]) THEN RESA_TAC THEN REAL_ARITH_TAC; POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[is_ear_v39] THEN STRIP_TAC THEN SUBGOAL_THEN`k''-1 IN {i | i < 3 /\ scs_J_v39 s'' i (SUC i)}`ASSUME_TAC; ASM_REWRITE_TAC[IN_ELIM_THM;ARITH_RULE`3-1<3`] THEN REPLICATE_TAC (132-110)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th THEN ASM_REWRITE_TAC[]); POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[IN_SING;ARITH_RULE`3-1=2`] THEN STRIP_TAC THEN POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[SYM th]) THEN REPEAT STRIP_TAC THEN SUBGOAL_THEN`d'' = scs_d_v39 s'' `ASSUME_TAC ; EXPAND_TAC"s''" THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist;periodic2;scs_half_slice_v39] ; MRESAL_TAC (GEN_ALL QKNVMLB1)[`vv:num->real^3`;`s:scs_v39`;`q:num`;`p:num`;`d'':real`;`mkj:bool`] [MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist;periodic2;] THEN REPLICATE_TAC (134-9)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN POP_ASSUM MP_TAC THEN MP_TAC th THEN RESA_TAC) THEN REWRITE_TAC[REAL_ARITH`#0.11 < #0.9`;ARITH_RULE`3<=3`] THEN STRIP_TAC THEN POP_ASSUM(fun th-> MRESA_TAC th[`2`;`SUC 2`]) THEN POP_ASSUM MP_TAC THEN REWRITE_TAC[ARITH_RULE`SUC 2 MOD 3=0/\ 0+A=A/\ 2 MOD 3=2`] THEN REPLICATE_TAC (136-117)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN POP_ASSUM MP_TAC THEN MP_TAC th THEN ASM_REWRITE_TAC[ARITH_RULE`3-1=2`]) THEN RESA_TAC THEN REAL_ARITH_TAC; ASM_TAC THEN REWRITE_TAC[periodic2] THEN REPEAT STRIP_TAC THEN POP_ASSUM MP_TAC THEN MP_TAC SCS_HALF_SLICE_IS_A_SCS THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist;periodic2] THEN ASM_SIMP_TAC[REAL_ARITH`&0<= A+B -C<=> C<= A+B`] THEN REPLICATE_TAC (64-58)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN REPLICATE_TAC (2)(POP_ASSUM MP_TAC) THEN GEN_REWRITE_TAC(LAND_CONV o LAND_CONV o LAND_CONV o LAND_CONV o ONCE_DEPTH_CONV)[th] THEN ASSUME_TAC th THEN ASM_REWRITE_TAC[]) THEN REPLICATE_TAC (64-58)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN REPLICATE_TAC (2)(POP_ASSUM MP_TAC) THEN GEN_REWRITE_TAC( LAND_CONV o LAND_CONV o LAND_CONV o ONCE_DEPTH_CONV)[th] THEN ASSUME_TAC th) THEN RESA_TAC THEN REPLICATE_TAC (81-72)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESAL_TAC th[`0`;`k'-1`;][ARITH_RULE`0+A=A`]) THEN SUBGOAL_THEN`(!i. scs_b_v39 s i (SUC i) <= cstab)`ASSUME_TAC; REPLICATE_TAC (83-24)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MATCH_MP_TAC th) THEN ASM_REWRITE_TAC[]; MRESAL_TAC(GEN_ALL SCS_HALF_SLICE_IS_A_SCS)[`s:scs_v39`;`s':scs_v39`;`q:num`;`p:num`;`s'':scs_v39`] [MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist;periodic2] THEN REPLICATE_TAC (85-35)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[th] THEN ASSUME_TAC th THEN REPEAT RESA_TAC) THEN REPLICATE_TAC (85-36)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN POP_ASSUM MP_TAC THEN MP_TAC th THEN RESA_TAC) THEN ASM_REWRITE_TAC[SET_RULE`A\/B<=> B\/A`] THEN REPLICATE_TAC (84-63)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN REPLICATE_TAC (1)(POP_ASSUM MP_TAC) THEN GEN_REWRITE_TAC(LAND_CONV o LAND_CONV o LAND_CONV o LAND_CONV o LAND_CONV o ONCE_DEPTH_CONV)[th] THEN ASSUME_TAC th THEN ASM_REWRITE_TAC[]) THEN REPLICATE_TAC (84-62)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN REPLICATE_TAC (1)(POP_ASSUM MP_TAC) THEN GEN_REWRITE_TAC( LAND_CONV o LAND_CONV o LAND_CONV o LAND_CONV o ONCE_DEPTH_CONV)[th] THEN ASSUME_TAC th) THEN ASM_REWRITE_TAC[REAL_ARITH`a<=b+c<=> a<= c+b`] THEN STRIP_TAC THEN REPLICATE_TAC (101-92)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESAL_TAC th[`0`;`k''-1`;][ARITH_RULE`0+A=A`]) THEN REPLICATE_TAC (102-57)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th) THEN RESA_TAC THEN REWRITE_TAC[SET_RULE`{a|F}={}`;SUM_SING;SUM_CLAUSES] THEN REAL_ARITH_TAC; (********************************) REPLICATE_TAC (7) (POP_ASSUM MP_TAC) THEN ASM_REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;scs_half_slice_v39] THEN REPEAT RESA_TAC THEN SUBGOAL_THEN`FINITE {i | i < scs_k_v39 s' - 1 /\ scs_J_v39 s' i (SUC i)} ` ASSUME_TAC ; MATCH_MP_TAC FINITE_SUBSET THEN EXISTS_TAC`0.. (scs_k_v39 s' -1)` THEN REWRITE_TAC[FINITE_NUMSEG;SUBSET;IN_ELIM_THM;IN_NUMSEG] THEN ARITH_TAC; SUBGOAL_THEN`{i | i < scs_k_v39 s' - 1 /\ scs_J_v39 s' i (SUC i)} INTER {i| i=scs_k_v39 s' - 1/\ scs_J_v39 s' (scs_k_v39 s' - 1) (SUC (scs_k_v39 s' - 1)) }={}` ASSUME_TAC ; REWRITE_TAC[INTER;SET_RULE`A={}<=> ~(?a. a IN A)`;IN_ELIM_THM;IN_SING] THEN ARITH_TAC; SUBGOAL_THEN`{i | i < scs_k_v39 s' - 1 /\ scs_J_v39 s' i (SUC i)} UNION {i| i=scs_k_v39 s' - 1/\ scs_J_v39 s' (scs_k_v39 s' - 1) (SUC(scs_k_v39 s'-1)) }={i | i < scs_k_v39 s' /\ scs_J_v39 s' i (SUC i)}` ASSUME_TAC; REWRITE_TAC[UNION;IN_SING;IN_ELIM_THM;EXTENSION] THEN GEN_TAC THEN EXPAND_TAC "s'" THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;scs_half_slice_v39] THEN ASM_REWRITE_TAC[] THEN REPLICATE_TAC (47-43) REMOVE_ASSUM_TAC THEN EQ_TAC ; RESA_TAC ; REPLICATE_TAC (47-40) (POP_ASSUM MP_TAC) THEN ARITH_TAC ; MP_TAC(ARITH_RULE`3<=k' ==>SUC (k' - 1) =k'/\ k'-1<k'`) THEN RESA_TAC; RESA_TAC THEN MP_TAC(ARITH_RULE`x<k' /\ 3<= k' ==> x< k'-1 \/ (x=k'-1)`) THEN RESA_TAC THEN POP_ASSUM (fun th-> POP_ASSUM MP_TAC THEN REWRITE_TAC[th] THEN RESA_TAC) ; SUBGOAL_THEN`FINITE {i | i = scs_k_v39 s' - 1 /\ scs_J_v39 s' (scs_k_v39 s' - 1) (SUC (scs_k_v39 s' - 1))}`ASSUME_TAC ; MATCH_MP_TAC FINITE_SUBSET THEN EXISTS_TAC`{(scs_k_v39 s' -1)}` THEN REWRITE_TAC[FINITE_NUMSEG;SUBSET;IN_ELIM_THM;IN_SING;FINITE_SING] THEN SET_TAC[]; MRESAL_TAC SUM_INCL_EXCL[`{i | i < scs_k_v39 s'-1 /\ scs_J_v39 s' i (SUC i)}`;`{i| i=scs_k_v39 s' - 1/\ scs_J_v39 s' (scs_k_v39 s' - 1) (SUC(scs_k_v39 s'-1)) }`;`(\i. cstab - dist ((vv:num->real^3) (i MOD scs_k_v39 s' + p MOD k), vv (SUC i MOD scs_k_v39 s' + p MOD k)))`][FINITE_SING;SUM_SING;SUM_CLAUSES;REAL_ARITH`a+ &0=a`] THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN SUBGOAL_THEN`FINITE {i | i < scs_k_v39 s'' - 1 /\ scs_J_v39 s'' i (SUC i)} ` ASSUME_TAC ; MATCH_MP_TAC FINITE_SUBSET THEN EXISTS_TAC`0.. (scs_k_v39 s'' -1)` THEN REWRITE_TAC[FINITE_NUMSEG;SUBSET;IN_ELIM_THM;IN_NUMSEG] THEN ARITH_TAC; SUBGOAL_THEN`{i | i < scs_k_v39 s'' - 1 /\ scs_J_v39 s'' i (SUC i)} INTER {i| i=scs_k_v39 s'' - 1/\ scs_J_v39 s'' (scs_k_v39 s'' - 1) (SUC (scs_k_v39 s'' - 1)) }={}` ASSUME_TAC ; REWRITE_TAC[INTER;SET_RULE`A={}<=> ~(?a. a IN A)`;IN_ELIM_THM;IN_SING] THEN ARITH_TAC; SUBGOAL_THEN`{i | i < scs_k_v39 s'' - 1 /\ scs_J_v39 s'' i (SUC i)} UNION {i| i=scs_k_v39 s'' - 1/\ scs_J_v39 s'' (scs_k_v39 s'' - 1) (SUC(scs_k_v39 s''-1)) }={i | i < scs_k_v39 s'' /\ scs_J_v39 s'' i (SUC i)}` ASSUME_TAC; REWRITE_TAC[UNION;IN_SING;IN_ELIM_THM;EXTENSION] THEN GEN_TAC THEN EXPAND_TAC "s''" THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;scs_half_slice_v39] THEN ASM_REWRITE_TAC[] THEN REPLICATE_TAC (47-43) REMOVE_ASSUM_TAC THEN EQ_TAC ; RESA_TAC ; REPLICATE_TAC (47-40) (POP_ASSUM MP_TAC) THEN ARITH_TAC ; MP_TAC(ARITH_RULE`3<=k'' ==>SUC (k'' - 1) =k''/\ k''-1<k''`) THEN RESA_TAC; RESA_TAC THEN MP_TAC(ARITH_RULE`x<k'' /\ 3<= k'' ==> x< k''-1 \/ (x=k''-1)`) THEN RESA_TAC THEN POP_ASSUM (fun th-> POP_ASSUM MP_TAC THEN REWRITE_TAC[th] THEN RESA_TAC) ; SUBGOAL_THEN`FINITE {i | i = scs_k_v39 s'' - 1 /\ scs_J_v39 s'' (scs_k_v39 s'' - 1) (SUC (scs_k_v39 s'' - 1))}`ASSUME_TAC ; MATCH_MP_TAC FINITE_SUBSET THEN EXISTS_TAC`{(scs_k_v39 s'' -1)}` THEN REWRITE_TAC[FINITE_NUMSEG;SUBSET;IN_ELIM_THM;IN_SING;FINITE_SING] THEN SET_TAC[]; MRESAL_TAC SUM_INCL_EXCL[`{i | i < scs_k_v39 s''-1 /\ scs_J_v39 s'' i (SUC i)}`;`{i| i=scs_k_v39 s'' - 1/\ scs_J_v39 s'' (scs_k_v39 s'' - 1) (SUC(scs_k_v39 s''-1)) }`;`(\i. cstab - dist ((vv:num->real^3) (i MOD scs_k_v39 s'' + q MOD k), vv (SUC i MOD scs_k_v39 s'' + q MOD k)))`][FINITE_SING;SUM_SING;SUM_CLAUSES;REAL_ARITH`a+ &0=a`] THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN SUBGOAL_THEN`sum {i | i < scs_k_v39 s' - 1 /\ scs_J_v39 s' i (SUC i)} (\i. cstab - dist (vv (i MOD scs_k_v39 s' + p MOD k), (vv:num->real^3) (SUC i MOD scs_k_v39 s' + p MOD k))) = sum {(i + p MOD scs_k_v39 s) MOD scs_k_v39 s | i < scs_k_v39 s'-1 /\ scs_J_v39 s' i (SUC i)} (\i. cstab - dist (vv (i ), vv (SUC i )))`ASSUME_TAC ; MATCH_MP_TAC SUM_EQ_GENERAL THEN REWRITE_TAC[IN_ELIM_THM] THEN EXISTS_TAC`(\i. (i + p MOD scs_k_v39 s) MOD scs_k_v39 s)` THEN ASM_REWRITE_TAC[EXISTS_UNIQUE] THEN REPEAT RESA_TAC; EXISTS_TAC`i:num` THEN ASM_REWRITE_TAC[] ; REPEAT STRIP_TAC THEN REPLICATE_TAC (47-40) (POP_ASSUM MP_TAC) THEN EXPAND_TAC "s'" THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;scs_half_slice_v39] THEN ASM_REWRITE_TAC[] THEN REPEAT STRIP_TAC THEN MP_TAC(ARITH_RULE`i<k'-1/\ y'<k'-1 /\ k'< k/\ 3<=k' ==> i<k /\ y'<k/\ ~(k=0)`) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`i:num`;`k:num`] THEN MRESA_TAC MOD_LT[`y':num`;`k:num`] THEN MRESAL_TAC Hdplygy.MOD_EQ_MOD[`i:num`;`y':num`;`p MOD k`;`k:num`][ADD_SYM]; EXISTS_TAC`x:num` THEN ASM_REWRITE_TAC[] ; POP_ASSUM MP_TAC THEN POP_ASSUM MP_TAC THEN EXPAND_TAC "s'" THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;scs_half_slice_v39] THEN ASM_REWRITE_TAC[] THEN REPEAT STRIP_TAC THEN MP_TAC(ARITH_RULE`x<k'-1/\ 3<=k'/\k'<k ==> x<k'/\ ~(k'=0)/\ SUC x< k'/\ ~(k=0)/\ 1<k`) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`x:num`;`k':num`] THEN MRESA_TAC MOD_LT[`SUC x:num`;`k':num`] THEN ASM_TAC THEN REWRITE_TAC[periodic2;MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;scs_half_slice_v39] THEN REPEAT STRIP_TAC THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`vv:num-> real^3`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th `(x + p MOD k):num` THEN MRESA1_TAC th ` ((x + p MOD k) +1):num` THEN MRESA1_TAC th ` SUC ((x + p MOD k) MOD k):num`) THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN REWRITE_TAC[ADD1] THEN MRESA_TAC MOD_LT[`1`;`k:num`] THEN MRESA_TAC MOD_ADD_MOD[`x+p MOD k`;`1`;`k:num`] THEN REWRITE_TAC[ARITH_RULE`((x + p MOD k) + 1)= (x+ 1) + p MOD k`] ; SUBGOAL_THEN`sum {i | i < scs_k_v39 s'' - 1 /\ scs_J_v39 s'' i (SUC i)} (\i. cstab - dist (vv (i MOD scs_k_v39 s'' + q MOD k), (vv:num->real^3) (SUC i MOD scs_k_v39 s'' + q MOD k))) = sum {(i + q MOD scs_k_v39 s) MOD scs_k_v39 s | i < scs_k_v39 s''-1 /\ scs_J_v39 s'' i (SUC i)} (\i. cstab - dist (vv (i ), vv (SUC i )))`ASSUME_TAC ; MATCH_MP_TAC SUM_EQ_GENERAL THEN REWRITE_TAC[IN_ELIM_THM] THEN EXISTS_TAC`(\i. (i + q MOD scs_k_v39 s) MOD scs_k_v39 s)` THEN ASM_REWRITE_TAC[EXISTS_UNIQUE] THEN REPEAT RESA_TAC; EXISTS_TAC`i:num` THEN ASM_REWRITE_TAC[] ; REPEAT STRIP_TAC THEN REPLICATE_TAC (47-40) (POP_ASSUM MP_TAC) THEN EXPAND_TAC "s''" THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;scs_half_slice_v39] THEN ASM_REWRITE_TAC[] THEN REPEAT STRIP_TAC THEN MP_TAC(ARITH_RULE`i<k''-1/\ y'<k''-1 /\ k''< k/\ 3<=k'' ==> i<k /\ y'<k/\ ~(k=0)`) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`i:num`;`k:num`] THEN MRESA_TAC MOD_LT[`y':num`;`k:num`] THEN MRESAL_TAC Hdplygy.MOD_EQ_MOD[`i:num`;`y':num`;`q MOD k`;`k:num`][ADD_SYM]; EXISTS_TAC`x:num` THEN ASM_REWRITE_TAC[] ; POP_ASSUM MP_TAC THEN POP_ASSUM MP_TAC THEN EXPAND_TAC "s''" THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;scs_half_slice_v39] THEN ASM_REWRITE_TAC[] THEN REPEAT STRIP_TAC THEN MP_TAC(ARITH_RULE`x<k''-1/\ 3<=k''/\k''<k ==> x<k''/\ ~(k''=0)/\ SUC x< k''/\ ~(k=0)/\ 1<k`) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`x:num`;`k'':num`] THEN MRESA_TAC MOD_LT[`SUC x:num`;`k'':num`] THEN ASM_TAC THEN REWRITE_TAC[periodic2;MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;scs_half_slice_v39] THEN REPEAT STRIP_TAC THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`vv:num-> real^3`][ARITH_RULE`~(4=0)`;periodic] THEN POP_ASSUM(fun th-> MRESA1_TAC th `(x + q MOD k):num` THEN MRESA1_TAC th ` ((x + q MOD k) +1):num` THEN MRESA1_TAC th ` SUC ((x + q MOD k) MOD k):num`) THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN REWRITE_TAC[ADD1] THEN MRESA_TAC MOD_LT[`1`;`k:num`] THEN MRESA_TAC MOD_ADD_MOD[`x+q MOD k`;`1`;`k:num`] THEN REWRITE_TAC[ARITH_RULE`((x + q MOD k) + 1)= (x+ 1) + q MOD k`] ; ASM_REWRITE_TAC[ REAL_ARITH`a + b * (-- &1) *c <= (a1 + b * d1 *(c1+c2)) + a2 + b * d2 *(c3+c4) <=> &0<= (a1+ a2-a) + b*(c+ d1* c1 +d2*c3)+ b*(d1* c2+ d2* c4)`] THEN MATCH_MP_TAC(REAL_ARITH`&0<=a /\ &0<=b /\ &0<=c==> &0<= a+b+c`) THEN STRIP_TAC; EXPAND_TAC "s'" THEN EXPAND_TAC "s''" THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;scs_half_slice_v39] THEN ASM_REWRITE_TAC[REAL_ARITH`&0<= A+B -C<=> C<= A+B`] ; STRIP_TAC; MATCH_MP_TAC(REAL_ARITH`&0<= a==> &0<= #0.1 *a`) THEN SUBGOAL_THEN`-- &1<= if is_ear_v39 s' then &1 else -- &1` ASSUME_TAC; MP_TAC(SET_RULE`is_ear_v39 s' \/ ~(is_ear_v39 s')`) THEN RESA_TAC THEN REAL_ARITH_TAC; SUBGOAL_THEN`-- &1<= if is_ear_v39 s'' then &1 else -- &1` ASSUME_TAC; MP_TAC(SET_RULE`is_ear_v39 s'' \/ ~(is_ear_v39 s'')`) THEN RESA_TAC THEN REAL_ARITH_TAC; SUBGOAL_THEN`&0<= sum {(i + p MOD k) MOD k | i < scs_k_v39 s' - 1 /\ scs_J_v39 s' i (SUC i)} (\i. cstab - dist ((vv:num->real^3) i,vv (SUC i)))`ASSUME_TAC ; MATCH_MP_TAC SUM_POS_LE THEN ASM_REWRITE_TAC[] THEN STRIP_TAC; MATCH_MP_TAC FINITE_SUBSET THEN EXISTS_TAC`0.. k` THEN REWRITE_TAC[FINITE_NUMSEG;SUBSET;IN_ELIM_THM;IN_NUMSEG;ARITH_RULE`0<= a`] THEN GEN_TAC THEN RESA_TAC THEN MP_TAC(ARITH_RULE`3<=k ==> ~(k=0)`) THEN RESA_TAC THEN MRESA_TAC DIVISION[`i + p MOD k`;`k:num`] THEN POP_ASSUM MP_TAC THEN ARITH_TAC; REWRITE_TAC[IN_ELIM_THM] THEN REPEAT RESA_TAC THEN ASM_TAC THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist] THEN ASM_REWRITE_TAC[REAL_ARITH`&0<= A+B -C<=> C<= A+B`] THEN REPEAT RESA_TAC THEN REPLICATE_TAC (75-6)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESA_TAC th[`(i + p MOD k) MOD k`;`SUC ((i + p MOD k) MOD k)`]) THEN REPLICATE_TAC (76-34)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESA1_TAC th`(i + p MOD k) MOD k`) THEN POP_ASSUM MP_TAC THEN POP_ASSUM MP_TAC THEN REAL_ARITH_TAC ; SUBGOAL_THEN`&0<= sum {(i + q MOD k) MOD k | i < scs_k_v39 s'' - 1 /\ scs_J_v39 s'' i (SUC i)} (\i. cstab - dist ((vv:num->real^3) i,vv (SUC i)))`ASSUME_TAC ; MATCH_MP_TAC SUM_POS_LE THEN ASM_REWRITE_TAC[] THEN STRIP_TAC; MATCH_MP_TAC FINITE_SUBSET THEN EXISTS_TAC`0.. k` THEN REWRITE_TAC[FINITE_NUMSEG;SUBSET;IN_ELIM_THM;IN_NUMSEG;ARITH_RULE`0<= a`] THEN GEN_TAC THEN RESA_TAC THEN MP_TAC(ARITH_RULE`3<=k ==> ~(k=0)`) THEN RESA_TAC THEN MRESA_TAC DIVISION[`i + q MOD k`;`k:num`] THEN POP_ASSUM MP_TAC THEN ARITH_TAC; REWRITE_TAC[IN_ELIM_THM] THEN REPEAT RESA_TAC THEN ASM_TAC THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist] THEN ASM_REWRITE_TAC[REAL_ARITH`&0<= A+B -C<=> C<= A+B`] THEN REPEAT RESA_TAC THEN REPLICATE_TAC (76-6)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESA_TAC th[`(i + q MOD k) MOD k`;`SUC ((i + q MOD k) MOD k)`]) THEN REPLICATE_TAC (77-34)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESA1_TAC th`(i + q MOD k) MOD k`) THEN POP_ASSUM MP_TAC THEN POP_ASSUM MP_TAC THEN REAL_ARITH_TAC ; MRESA_TAC REAL_LE_RMUL[`-- &1`;`(if is_ear_v39 s' then &1 else -- &1)`;`sum {(i + p MOD k) MOD k | i < scs_k_v39 s' - 1 /\ scs_J_v39 s' i (SUC i)} (\i. cstab - dist (vv i,(vv:num->real^3) (SUC i)))`] THEN MRESA_TAC REAL_LE_RMUL[`-- &1`;`(if is_ear_v39 s'' then &1 else -- &1)`;`sum {(i + q MOD k) MOD k | i < scs_k_v39 s'' - 1 /\ scs_J_v39 s'' i (SUC i)} (\i. cstab - dist (vv i,(vv:num->real^3) (SUC i)))`] THEN SUBGOAL_THEN`FINITE {(i + p MOD k) MOD k | i < scs_k_v39 s' - 1 /\ scs_J_v39 s' i (SUC i)}`ASSUME_TAC ; MATCH_MP_TAC FINITE_SUBSET THEN EXISTS_TAC`0.. k` THEN REWRITE_TAC[FINITE_NUMSEG;SUBSET;IN_ELIM_THM;IN_NUMSEG;ARITH_RULE`0<= a`] THEN GEN_TAC THEN RESA_TAC THEN MP_TAC(ARITH_RULE`3<=k ==> ~(k=0)`) THEN RESA_TAC THEN MRESA_TAC DIVISION[`i + q MOD k`;`k:num`] THEN POP_ASSUM MP_TAC THEN ARITH_TAC; SUBGOAL_THEN`FINITE {(i + q MOD k) MOD k | i < scs_k_v39 s'' - 1 /\ scs_J_v39 s'' i (SUC i)}`ASSUME_TAC ; MATCH_MP_TAC FINITE_SUBSET THEN EXISTS_TAC`0.. k` THEN REWRITE_TAC[FINITE_NUMSEG;SUBSET;IN_ELIM_THM;IN_NUMSEG;ARITH_RULE`0<= a`] THEN GEN_TAC THEN RESA_TAC THEN MP_TAC(ARITH_RULE`3<=k ==> ~(k=0)`) THEN RESA_TAC THEN MRESA_TAC DIVISION[`i + q MOD k`;`k:num`] THEN POP_ASSUM MP_TAC THEN ARITH_TAC; SUBGOAL_THEN`&0 <= sum {i | i < k /\ scs_J_v39 s i (SUC i)} (\i. cstab - dist (vv i,vv (SUC i))) - (sum {(i + p MOD k) MOD k | i < scs_k_v39 s' - 1 /\ scs_J_v39 s' i (SUC i)} (\i. cstab - dist (vv i,vv (SUC i))) + sum {(i + q MOD k) MOD k | i < scs_k_v39 s'' - 1 /\ scs_J_v39 s'' i (SUC i)} (\i. cstab - dist (vv i,(vv:num->real^3) (SUC i))))` ASSUME_TAC ; SUBGOAL_THEN`(!i. scs_b_v39 s i (SUC i) <= cstab)`ASSUME_TAC; REPLICATE_TAC (67-24)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MATCH_MP_TAC th) THEN ASM_REWRITE_TAC[]; MP_TAC INTER_SLICE_SCS_EMPTY THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist] THEN ASM_REWRITE_TAC[REAL_ARITH`&0<= A+B -C<=> C<= A+B`] THEN REPLICATE_TAC (68-37)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[th] THEN ASSUME_TAC th THEN REPEAT RESA_TAC) THEN SUBGOAL_THEN`{(i + p MOD k) MOD k | i < scs_k_v39 s' - 1 /\ scs_J_v39 s' i (SUC i)} INTER {(i + q MOD k) MOD k | i < scs_k_v39 s'' - 1 /\ scs_J_v39 s'' i (SUC i)}={}`ASSUME_TAC ; POP_ASSUM MP_TAC THEN REWRITE_TAC[INTER;IN_ELIM_THM] THEN SET_TAC[]; MRESAL_TAC SUM_INCL_EXCL[`{(i + p MOD k) MOD k | i < scs_k_v39 s' - 1 /\ scs_J_v39 s' i (SUC i)}`;`{(i + q MOD k) MOD k | i < scs_k_v39 s'' - 1 /\ scs_J_v39 s'' i (SUC i)}`;`(\i. cstab - dist ((vv:num->real^3) i,vv (SUC i)))`][SUM_CLAUSES;REAL_ARITH`a+ &0=a`;dist] THEN SUBGOAL_THEN`{(i + p MOD k) MOD k | i < scs_k_v39 s' - 1 /\ scs_J_v39 s' i (SUC i)} UNION {(i + q MOD k) MOD k | i < scs_k_v39 s'' - 1 /\ scs_J_v39 s'' i (SUC i)} SUBSET {i | i < k /\ scs_J_v39 s i (SUC i)}`ASSUME_TAC ; REWRITE_TAC[UNION;IN_ELIM_THM;SUBSET] THEN REPEAT RESA_TAC ; MP_TAC(ARITH_RULE`3<k==> ~(k=0)`) THEN RESA_TAC THEN MRESA_TAC DIVISION[`i + p MOD k`;`k:num`] ; MP_TAC SCS_J_PRIME_SUBSET_SCS_J THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist] THEN ASM_REWRITE_TAC[REAL_ARITH`&0<= A+B -C<=> C<= A+B`] ; MP_TAC(ARITH_RULE`3<k==> ~(k=0)`) THEN RESA_TAC THEN MRESA_TAC DIVISION[`i + q MOD k`;`k:num`] ; MRESA_TAC(GEN_ALL SCS_J_PRIME_SUBSET_SCS_J)[`d'':real`;`mkj:bool`;`p:num`;`s'':scs_v39`;`i:num`;`q:num`;`s:scs_v39`] THEN POP_ASSUM MATCH_MP_TAC THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist] THEN ASM_REWRITE_TAC[REAL_ARITH`&0<= A+B -C<=> C<= A+B`]; SUBGOAL_THEN`FINITE {i | i < k /\ scs_J_v39 s i (SUC i)}` ASSUME_TAC ; MATCH_MP_TAC FINITE_SUBSET THEN EXISTS_TAC`0..k` THEN REWRITE_TAC[FINITE_NUMSEG;SUBSET;IN_ELIM_THM;IN_NUMSEG] THEN ARITH_TAC; MRESA_TAC SUM_DIFF[`(\i. cstab - norm (vv i - (vv:num->real^3) (SUC i)))`;`{i | i < k /\ scs_J_v39 s i (SUC i)}`;`{(i + p MOD k) MOD k | i < scs_k_v39 s' - 1 /\ scs_J_v39 s' i (SUC i)} UNION {(i + q MOD k) MOD k | i < scs_k_v39 s'' - 1 /\ scs_J_v39 s'' i (SUC i)}`;] THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN MATCH_MP_TAC SUM_POS_LE THEN ASM_REWRITE_TAC[] THEN STRIP_TAC; MATCH_MP_TAC FINITE_SUBSET THEN EXISTS_TAC`0.. k` THEN REWRITE_TAC[FINITE_NUMSEG;SUBSET; DIFF;IN_ELIM_THM;IN_NUMSEG;ARITH_RULE`0<= a`] THEN ARITH_TAC; REWRITE_TAC[IN_ELIM_THM;DIFF] THEN REPEAT RESA_TAC THEN ASM_TAC THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist] THEN ASM_REWRITE_TAC[REAL_ARITH`&0<= A+B -C<=> C<= A+B`] THEN REPEAT RESA_TAC THEN REPLICATE_TAC (87-7)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESA_TAC th[`x:num`;`SUC (x)`]) THEN REPLICATE_TAC (88-78)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESA1_TAC th`x:num`) THEN POP_ASSUM MP_TAC THEN POP_ASSUM MP_TAC THEN REAL_ARITH_TAC; MATCH_MP_TAC(REAL_ARITH`-- &1 *a <=c* a /\ -- &1 *b<= d*b /\ &0<= a1-(a+b) ==> &0<= a1+ c*a+d*b`) THEN ASM_REWRITE_TAC[] ; MATCH_MP_TAC(REAL_ARITH`&0<=a ==> &0<= #0.1 *a`) THEN MP_TAC SCS_J_DIAG_EQ THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist;] THEN ASM_SIMP_TAC[REAL_ARITH`&0<= A+B -C<=> C<= A+B`] THEN REPLICATE_TAC (59-31)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN REPLICATE_TAC (1)(POP_ASSUM MP_TAC) THEN GEN_REWRITE_TAC(LAND_CONV o LAND_CONV o LAND_CONV o LAND_CONV o ONCE_DEPTH_CONV)[th] THEN ASSUME_TAC th) THEN REWRITE_TAC[] THEN REPLICATE_TAC (59-31)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN REPLICATE_TAC (1)(POP_ASSUM MP_TAC) THEN GEN_REWRITE_TAC(LAND_CONV o LAND_CONV o LAND_CONV o ONCE_DEPTH_CONV)[th] THEN ASSUME_TAC th) THEN RESA_TAC THEN SUBGOAL_THEN`scs_k_v39 s'=k'`ASSUME_TAC ; EXPAND_TAC"s'" THEN EXPAND_TAC"s''" THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist;scs_half_slice_v39] THEN ASM_REWRITE_TAC[REAL_ARITH`&0<= A+B -C<=> C<= A+B`] ; SUBGOAL_THEN`scs_k_v39 s''=k''`ASSUME_TAC ; EXPAND_TAC"s'" THEN EXPAND_TAC"s''" THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist;scs_half_slice_v39] THEN ASM_REWRITE_TAC[REAL_ARITH`&0<= A+B -C<=> C<= A+B`] ; MP_TAC(ARITH_RULE`3<=k'/\ 3<=k'' ==> SUC(k'-1)=k' /\ SUC (k''-1)=k''`) THEN RESA_TAC THEN MP_TAC(SET_RULE`scs_J_v39 s' (scs_k_v39 s' - 1) (SUC (scs_k_v39 s' - 1)) \/ ~(scs_J_v39 s' (scs_k_v39 s' - 1) (SUC (scs_k_v39 s' - 1)))`) THEN RESA_TAC; ASM_TAC THEN REWRITE_TAC[periodic2] THEN REPEAT STRIP_TAC THEN POP_ASSUM MP_TAC THEN MP_TAC SCS_HALF_SLICE_IS_A_SCS THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist;periodic2] THEN ASM_SIMP_TAC[REAL_ARITH`&0<= A+B -C<=> C<= A+B`] THEN REPLICATE_TAC (64-58)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN REPLICATE_TAC (2)(POP_ASSUM MP_TAC) THEN GEN_REWRITE_TAC(LAND_CONV o LAND_CONV o LAND_CONV o LAND_CONV o ONCE_DEPTH_CONV)[th] THEN ASSUME_TAC th THEN ASM_REWRITE_TAC[]) THEN REPLICATE_TAC (64-58)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN REPLICATE_TAC (2)(POP_ASSUM MP_TAC) THEN GEN_REWRITE_TAC( LAND_CONV o LAND_CONV o LAND_CONV o ONCE_DEPTH_CONV)[th] THEN ASSUME_TAC th) THEN RESA_TAC THEN REPLICATE_TAC (81-72)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESAL_TAC th[`0`;`k'-1`;][ARITH_RULE`0+A=A`]) THEN SUBGOAL_THEN`(!i. scs_b_v39 s i (SUC i) <= cstab)`ASSUME_TAC; REPLICATE_TAC (83-24)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MATCH_MP_TAC th) THEN ASM_REWRITE_TAC[]; MRESAL_TAC(GEN_ALL SCS_HALF_SLICE_IS_A_SCS)[`s:scs_v39`;`s':scs_v39`;`q:num`;`p:num`;`s'':scs_v39`] [MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist;periodic2] THEN REPLICATE_TAC (85-35)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[th] THEN ASSUME_TAC th THEN REPEAT RESA_TAC) THEN REPLICATE_TAC (85-36)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN POP_ASSUM MP_TAC THEN MP_TAC th THEN RESA_TAC) THEN ASM_REWRITE_TAC[SET_RULE`A\/B<=> B\/A`] THEN REPLICATE_TAC (84-63)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN REPLICATE_TAC (1)(POP_ASSUM MP_TAC) THEN GEN_REWRITE_TAC(LAND_CONV o LAND_CONV o LAND_CONV o LAND_CONV o LAND_CONV o ONCE_DEPTH_CONV)[th] THEN ASSUME_TAC th THEN ASM_REWRITE_TAC[]) THEN REPLICATE_TAC (84-62)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN REPLICATE_TAC (1)(POP_ASSUM MP_TAC) THEN GEN_REWRITE_TAC( LAND_CONV o LAND_CONV o LAND_CONV o LAND_CONV o ONCE_DEPTH_CONV)[th] THEN ASSUME_TAC th) THEN ASM_REWRITE_TAC[REAL_ARITH`a<=b+c<=> a<= c+b`] THEN STRIP_TAC THEN REPLICATE_TAC (101-92)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESAL_TAC th[`0`;`k''-1`;][ARITH_RULE`0+A=A`]) THEN REPLICATE_TAC (102-57)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th) THEN RESA_TAC THEN REWRITE_TAC[SET_RULE`{a|a=b}={b}`;SUM_SING] THEN MP_TAC(ARITH_RULE`3<=k'/\ 3<=k'' ==> (k'-1)<k' /\ (k''-1)<k''`) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`k'-1`;`k':num`] THEN MRESA_TAC MOD_LT[`k''-1`;`k'':num`] THEN MRESA_TAC (GEN_ALL W_EW_K_SCS_ADD_P)[ `d':real`;`mkj:bool`;`s':scs_v39`;`(vv:num->real^3)(p MOD k)`;`q:num`;`s:scs_v39`;`(vv:num->real^3)`;`k':num`;`p:num`;`k:num`;`(vv:num->real^3) (q MOD k)`] THEN MRESA_TAC (GEN_ALL W_EW_K_SCS_ADD_P)[ `d'':real`;`mkj:bool`;`s'':scs_v39`;`(vv:num->real^3)(q MOD k)`;`p:num`;`s:scs_v39`;`(vv:num->real^3)`;`k'':num`;`q:num`;`k:num`;`(vv:num->real^3) (p MOD k)`] THEN ASM_TAC THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist;periodic2] THEN REPEAT RESA_TAC THEN MP_TAC(ARITH_RULE`3<=k'/\ 3<=k'' ==> ~(k'=0) /\ ~(k''=0)`) THEN RESA_TAC THEN MRESAL_TAC MOD_MULT[`k':num`;`1:num`][ARITH_RULE`k'*1 =k'/\ 0+A=A`] THEN MRESAL_TAC MOD_MULT[`k'':num`;`1:num`][ARITH_RULE`k'*1 =k'/\ 0+A=A`] THEN SUBGOAL_THEN`norm ((vv:num->real^3) (q MOD k) - vv (p MOD k)) =norm (vv (p MOD k) - vv (q MOD k))`ASSUME_TAC ; MP_TAC(VECTOR_ARITH`vv (q MOD k) - vv (p MOD k) = --(vv (p MOD k) - (vv:num->real^3) (q MOD k))`) THEN STRIP_TAC THEN POP_ASSUM(fun th-> ONCE_REWRITE_TAC[th]) THEN REWRITE_TAC[NORM_NEG]; ASM_REWRITE_TAC[ARITH_RULE`a*b+c*b=(a+c)*b`] THEN MATCH_MP_TAC REAL_LE_MUL THEN STRIP_TAC; REPLICATE_TAC (124-92)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th THEN RESA_TAC) THEN REAL_ARITH_TAC ; REPLICATE_TAC (124-92)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th THEN RESA_TAC) ; POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[is_ear_v39] THEN STRIP_TAC THEN SUBGOAL_THEN`k'-1 IN {i | i < 3 /\ scs_J_v39 s' i (SUC i)}`ASSUME_TAC; ASM_REWRITE_TAC[IN_ELIM_THM;ARITH_RULE`3-1<3`] THEN REPLICATE_TAC (132-88)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th THEN ASM_REWRITE_TAC[]); POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[IN_SING;ARITH_RULE`3-1=2`] THEN STRIP_TAC THEN POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[SYM th]) THEN REPEAT STRIP_TAC THEN SUBGOAL_THEN`d' = scs_d_v39 s' `ASSUME_TAC ; EXPAND_TAC"s'" THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist;periodic2;scs_half_slice_v39] ; MP_TAC QKNVMLB1 THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist;periodic2;] THEN REPEAT RESA_TAC THEN POP_ASSUM MP_TAC THEN REWRITE_TAC[REAL_ARITH`#0.11 < #0.9`;ARITH_RULE`3<=3`] THEN STRIP_TAC THEN POP_ASSUM(fun th-> MRESA_TAC th[`2`;`SUC 2`]) THEN POP_ASSUM MP_TAC THEN REWRITE_TAC[ARITH_RULE`SUC 2 MOD 3=0/\ 0+A=A/\ 2 MOD 3=2`] THEN REPLICATE_TAC (136-117)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN POP_ASSUM MP_TAC THEN MP_TAC th THEN ASM_REWRITE_TAC[ARITH_RULE`3-1=2`]) THEN RESA_TAC THEN REAL_ARITH_TAC; POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[is_ear_v39] THEN STRIP_TAC THEN SUBGOAL_THEN`k''-1 IN {i | i < 3 /\ scs_J_v39 s'' i (SUC i)}`ASSUME_TAC; ASM_REWRITE_TAC[IN_ELIM_THM;ARITH_RULE`3-1<3`] THEN REPLICATE_TAC (132-110)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th THEN ASM_REWRITE_TAC[]); POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[IN_SING;ARITH_RULE`3-1=2`] THEN STRIP_TAC THEN POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[SYM th]) THEN REPEAT STRIP_TAC THEN SUBGOAL_THEN`d'' = scs_d_v39 s'' `ASSUME_TAC ; EXPAND_TAC"s''" THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist;periodic2;scs_half_slice_v39] ; MRESAL_TAC (GEN_ALL QKNVMLB1)[`vv:num->real^3`;`s:scs_v39`;`q:num`;`p:num`;`d'':real`;`mkj:bool`] [MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist;periodic2;] THEN REPLICATE_TAC (134-9)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN POP_ASSUM MP_TAC THEN MP_TAC th THEN RESA_TAC) THEN REWRITE_TAC[REAL_ARITH`#0.11 < #0.9`;ARITH_RULE`3<=3`] THEN STRIP_TAC THEN POP_ASSUM(fun th-> MRESA_TAC th[`2`;`SUC 2`]) THEN POP_ASSUM MP_TAC THEN REWRITE_TAC[ARITH_RULE`SUC 2 MOD 3=0/\ 0+A=A/\ 2 MOD 3=2`] THEN REPLICATE_TAC (136-117)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN POP_ASSUM MP_TAC THEN MP_TAC th THEN ASM_REWRITE_TAC[ARITH_RULE`3-1=2`]) THEN RESA_TAC THEN REAL_ARITH_TAC; MP_TAC(VECTOR_ARITH`vv (q MOD k) - vv (p MOD k) = --(vv (p MOD k) - (vv:num->real^3) (q MOD k))`) THEN STRIP_TAC THEN POP_ASSUM(fun th-> ONCE_REWRITE_TAC[th]) THEN REWRITE_TAC[NORM_NEG]; ASM_REWRITE_TAC[ARITH_RULE`a*b+c*b=(a+c)*b`] THEN MATCH_MP_TAC REAL_LE_MUL THEN STRIP_TAC; REPLICATE_TAC (124-92)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th THEN RESA_TAC) THEN REAL_ARITH_TAC ; REPLICATE_TAC (124-92)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th THEN RESA_TAC) ; POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[is_ear_v39] THEN STRIP_TAC THEN SUBGOAL_THEN`k'-1 IN {i | i < 3 /\ scs_J_v39 s' i (SUC i)}`ASSUME_TAC; ASM_REWRITE_TAC[IN_ELIM_THM;ARITH_RULE`3-1<3`] THEN REPLICATE_TAC (132-88)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th THEN ASM_REWRITE_TAC[]); POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[IN_SING;ARITH_RULE`3-1=2`] THEN STRIP_TAC THEN POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[SYM th]) THEN REPEAT STRIP_TAC THEN SUBGOAL_THEN`d' = scs_d_v39 s' `ASSUME_TAC ; EXPAND_TAC"s'" THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist;periodic2;scs_half_slice_v39] ; MP_TAC QKNVMLB1 THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist;periodic2;] THEN REPEAT RESA_TAC THEN POP_ASSUM MP_TAC THEN REWRITE_TAC[REAL_ARITH`#0.11 < #0.9`;ARITH_RULE`3<=3`] THEN STRIP_TAC THEN POP_ASSUM(fun th-> MRESA_TAC th[`2`;`SUC 2`]) THEN POP_ASSUM MP_TAC THEN REWRITE_TAC[ARITH_RULE`SUC 2 MOD 3=0/\ 0+A=A/\ 2 MOD 3=2`] THEN REPLICATE_TAC (136-117)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN POP_ASSUM MP_TAC THEN MP_TAC th THEN ASM_REWRITE_TAC[ARITH_RULE`3-1=2`]) THEN RESA_TAC THEN REAL_ARITH_TAC; POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[is_ear_v39] THEN STRIP_TAC THEN SUBGOAL_THEN`k''-1 IN {i | i < 3 /\ scs_J_v39 s'' i (SUC i)}`ASSUME_TAC; ASM_REWRITE_TAC[IN_ELIM_THM;ARITH_RULE`3-1<3`] THEN REPLICATE_TAC (132-110)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th THEN ASM_REWRITE_TAC[]); POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[IN_SING;ARITH_RULE`3-1=2`] THEN STRIP_TAC THEN POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[SYM th]) THEN REPEAT STRIP_TAC THEN SUBGOAL_THEN`d'' = scs_d_v39 s'' `ASSUME_TAC ; EXPAND_TAC"s''" THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist;periodic2;scs_half_slice_v39] ; MRESAL_TAC (GEN_ALL QKNVMLB1)[`vv:num->real^3`;`s:scs_v39`;`q:num`;`p:num`;`d'':real`;`mkj:bool`] [MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist;periodic2;] THEN REPLICATE_TAC (134-9)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN POP_ASSUM MP_TAC THEN MP_TAC th THEN RESA_TAC) THEN REWRITE_TAC[REAL_ARITH`#0.11 < #0.9`;ARITH_RULE`3<=3`] THEN STRIP_TAC THEN POP_ASSUM(fun th-> MRESA_TAC th[`2`;`SUC 2`]) THEN POP_ASSUM MP_TAC THEN REWRITE_TAC[ARITH_RULE`SUC 2 MOD 3=0/\ 0+A=A/\ 2 MOD 3=2`] THEN REPLICATE_TAC (136-117)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN POP_ASSUM MP_TAC THEN MP_TAC th THEN ASM_REWRITE_TAC[ARITH_RULE`3-1=2`]) THEN RESA_TAC THEN REAL_ARITH_TAC; ASM_TAC THEN REWRITE_TAC[periodic2] THEN REPEAT STRIP_TAC THEN POP_ASSUM MP_TAC THEN MP_TAC SCS_HALF_SLICE_IS_A_SCS THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist;periodic2] THEN ASM_SIMP_TAC[REAL_ARITH`&0<= A+B -C<=> C<= A+B`] THEN REPLICATE_TAC (64-58)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN REPLICATE_TAC (2)(POP_ASSUM MP_TAC) THEN GEN_REWRITE_TAC(LAND_CONV o LAND_CONV o LAND_CONV o LAND_CONV o ONCE_DEPTH_CONV)[th] THEN ASSUME_TAC th THEN ASM_REWRITE_TAC[]) THEN REPLICATE_TAC (64-58)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN REPLICATE_TAC (2)(POP_ASSUM MP_TAC) THEN GEN_REWRITE_TAC( LAND_CONV o LAND_CONV o LAND_CONV o ONCE_DEPTH_CONV)[th] THEN ASSUME_TAC th) THEN RESA_TAC THEN REPLICATE_TAC (81-72)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESAL_TAC th[`0`;`k'-1`;][ARITH_RULE`0+A=A`]) THEN SUBGOAL_THEN`(!i. scs_b_v39 s i (SUC i) <= cstab)`ASSUME_TAC; REPLICATE_TAC (83-24)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MATCH_MP_TAC th) THEN ASM_REWRITE_TAC[]; MRESAL_TAC(GEN_ALL SCS_HALF_SLICE_IS_A_SCS)[`s:scs_v39`;`s':scs_v39`;`q:num`;`p:num`;`s'':scs_v39`] [MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist;periodic2] THEN REPLICATE_TAC (85-35)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[th] THEN ASSUME_TAC th THEN REPEAT RESA_TAC) THEN REPLICATE_TAC (85-36)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN POP_ASSUM MP_TAC THEN MP_TAC th THEN RESA_TAC) THEN ASM_REWRITE_TAC[SET_RULE`A\/B<=> B\/A`] THEN REPLICATE_TAC (84-63)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN REPLICATE_TAC (1)(POP_ASSUM MP_TAC) THEN GEN_REWRITE_TAC(LAND_CONV o LAND_CONV o LAND_CONV o LAND_CONV o LAND_CONV o ONCE_DEPTH_CONV)[th] THEN ASSUME_TAC th THEN ASM_REWRITE_TAC[]) THEN REPLICATE_TAC (84-62)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN REPLICATE_TAC (1)(POP_ASSUM MP_TAC) THEN GEN_REWRITE_TAC( LAND_CONV o LAND_CONV o LAND_CONV o LAND_CONV o ONCE_DEPTH_CONV)[th] THEN ASSUME_TAC th) THEN ASM_REWRITE_TAC[REAL_ARITH`a<=b+c<=> a<= c+b`] THEN STRIP_TAC THEN REPLICATE_TAC (101-92)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESAL_TAC th[`0`;`k''-1`;][ARITH_RULE`0+A=A`]) THEN REPLICATE_TAC (102-57)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th) THEN RESA_TAC THEN REWRITE_TAC[SET_RULE`{a|F}={}`;SUM_SING;SUM_CLAUSES] THEN REAL_ARITH_TAC; ]);;
let DIST_DIAG_LE_CSTAB= 
prove_by_refinement( `~(scs_k_v39 s =4 /\ ~(scs_J_v39 s' 0 (scs_k_v39 s' - 1)))/\ scs_half_slice_v39 s p q d' mkj =s'/\ scs_half_slice_v39 s q p d'' mkj =s'' /\ MMs_v39 s vv /\ is_scs_v39 s /\ scs_diag (scs_k_v39 s) p q /\ is_scs_slice_v39 s s' s'' p q ==> norm(vv (p MOD (scs_k_v39 s)) - vv (q MOD (scs_k_v39 s)))<= cstab`,
[ STRIP_TAC THEN MP_TAC SCS_K_PRIME_CASE_3 THEN REWRITE_TAC[taustar_v39;LET_DEF;LET_END_DEF;] THEN RESA_TAC THEN ABBREV_TAC`k=scs_k_v39 s` THEN MP_TAC(ARITH_RULE`3<k==> ~(k<=3)`) THEN RESA_TAC THEN MP_TAC SCS_K_LE_6 THEN RESA_TAC THEN ASM_TAC THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ] THEN REPEAT RESA_TAC THEN REPLICATE_TAC (48-5)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th THEN ASM_REWRITE_TAC[]) THEN STRIP_TAC THEN ABBREV_TAC`k'=scs_k_v39 s'` THEN ABBREV_TAC`k''=scs_k_v39 s''` THEN MP_TAC(SET_RULE`scs_J_v39 s' 0 (scs_k_v39 s' - 1) \/ ~(scs_J_v39 s' 0 (scs_k_v39 s' - 1) )`) THEN RESA_TAC ; REPLICATE_TAC (52)(POP_ASSUM MP_TAC) THEN REMOVE_ASSUM_TAC THEN REPEAT STRIP_TAC THEN REPLICATE_TAC (51-43)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th THEN ASM_REWRITE_TAC[]) ; STRIP_TAC; POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[is_ear_v39;is_scs_v39;periodic2] THEN STRIP_TAC THEN SUBGOAL_THEN`k'-1 IN {i | i < 3 /\ scs_J_v39 s' i (SUC i)}`ASSUME_TAC; ASM_REWRITE_TAC[IN_ELIM_THM;ARITH_RULE`3-1<3`] THEN REPLICATE_TAC (77-60)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESAL_TAC th[`0`;`3-1`][ARITH_RULE`0+3=3`] THEN ASM_REWRITE_TAC[ARITH_RULE`SUC(3-1)=3`]) THEN REPLICATE_TAC (78-50)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th THEN ASM_REWRITE_TAC[ARITH_RULE`SUC(3-1)=3`]) ; POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[IN_SING;ARITH_RULE`3-1=2`] THEN STRIP_TAC THEN POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[SYM th]) THEN REPEAT STRIP_TAC THEN REPLICATE_TAC (77-5)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th THEN ASM_REWRITE_TAC[ARITH_RULE`SUC(3-1)=3`]) THEN STRIP_TAC THEN SUBGOAL_THEN`d' = scs_d_v39 s' `ASSUME_TAC ; EXPAND_TAC"s'" THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist;periodic2;scs_half_slice_v39] ; MP_TAC QKNVMLB1 THEN ASM_REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;REAL_ARITH`#0.11 < #0.9`;ARITH_RULE`3<=3`] THEN STRIP_TAC THEN POP_ASSUM(fun th-> MRESA_TAC th[`2`;`SUC 2`]) THEN POP_ASSUM MP_TAC THEN REWRITE_TAC[ARITH_RULE`SUC 2 MOD 3=0/\ 0+A=A/\ 2 MOD 3=2`;dist] THEN MRESAL_TAC (GEN_ALL W_EW_K_SCS_ADD_P)[ `d':real`;`mkj:bool`;`s':scs_v39`;`(vv:num->real^3)(p MOD k)`;`q:num`;`s:scs_v39`;`(vv:num->real^3)`;`k':num`;`p:num`;`k:num`;`(vv:num->real^3) (q MOD k)`][MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;ARITH_RULE`3-1=2`] THEN SUBGOAL_THEN`norm ((vv:num->real^3) (q MOD k) - vv (p MOD k)) =norm (vv (p MOD k) - vv (q MOD k))`ASSUME_TAC ; MP_TAC(VECTOR_ARITH`vv (q MOD k) - vv (p MOD k) = --(vv (p MOD k) - (vv:num->real^3) (q MOD k))`) THEN STRIP_TAC THEN POP_ASSUM(fun th-> ONCE_REWRITE_TAC[th]) THEN REWRITE_TAC[NORM_NEG]; RESA_TAC; MP_TAC SCS_J_DIAG_EQ THEN ASM_REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist;is_ear_v39] THEN REPLICATE_TAC (51-36)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN REPLICATE_TAC (1)(POP_ASSUM MP_TAC) THEN GEN_REWRITE_TAC(LAND_CONV o LAND_CONV o LAND_CONV o LAND_CONV o ONCE_DEPTH_CONV)[th] THEN ASM_REWRITE_TAC[] THEN ASSUME_TAC th) THEN REPLICATE_TAC (51-36)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN REPLICATE_TAC (1)(POP_ASSUM MP_TAC) THEN GEN_REWRITE_TAC( LAND_CONV o LAND_CONV o LAND_CONV o ONCE_DEPTH_CONV)[th] THEN ASM_REWRITE_TAC[] THEN ASSUME_TAC th) THEN STRIP_TAC THEN REPLICATE_TAC (51-48)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th THEN ASM_REWRITE_TAC[is_ear_v39;is_scs_v39;periodic2] THEN STRIP_TAC) THEN SUBGOAL_THEN`k''-1 IN {i | i < 3 /\ scs_J_v39 s'' i (SUC i)}`ASSUME_TAC; ASM_REWRITE_TAC[IN_ELIM_THM;ARITH_RULE`3-1<3`] THEN REPLICATE_TAC (78-61)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MRESAL_TAC th[`0`;`3-1`][ARITH_RULE`0+3=3`] THEN ASM_REWRITE_TAC[ARITH_RULE`SUC(3-1)=3`]) THEN REPLICATE_TAC (79-51)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th THEN ASM_REWRITE_TAC[ARITH_RULE`SUC(3-1)=3`]) ; POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[IN_SING;ARITH_RULE`3-1=2`] THEN STRIP_TAC THEN POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[SYM th]) THEN REPEAT STRIP_TAC THEN REPLICATE_TAC (78-5)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th THEN ASM_REWRITE_TAC[ARITH_RULE`SUC(3-1)=3`]) THEN STRIP_TAC THEN SUBGOAL_THEN`d'' = scs_d_v39 s'' `ASSUME_TAC ; EXPAND_TAC"s''" THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist;periodic2;scs_half_slice_v39] ; MRESAL_TAC (GEN_ALL QKNVMLB1)[`vv:num->real^3`;`s:scs_v39`;`q:num`;`p:num`;`d'':real`;`mkj:bool`] [MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;REAL_ARITH`#0.11 < #0.9`;ARITH_RULE`3<=3`] THEN REPLICATE_TAC (80-41)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> ASM_REWRITE_TAC[ARITH_RULE`SUC(3-1)=3`;SYM th] THEN REWRITE_TAC[th] THEN MP_TAC th) THEN REPEAT RESA_TAC THEN POP_ASSUM(fun th-> MRESA_TAC th[`2`;`SUC 2`]) THEN POP_ASSUM MP_TAC THEN REWRITE_TAC[ARITH_RULE`SUC 2 MOD 3=0/\ 0+A=A/\ 2 MOD 3=2`;dist] THEN MRESAL_TAC (GEN_ALL W_EW_K_SCS_ADD_P)[ `d'':real`;`mkj:bool`;`s'':scs_v39`;`(vv:num->real^3)(q MOD k)`;`p:num`;`s:scs_v39`;`(vv:num->real^3)`;`k'':num`;`q:num`;`k:num`;`(vv:num->real^3) (p MOD k)`][MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;ARITH_RULE`3-1=2`] ; REPLICATE_TAC (52)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th THEN ASM_REWRITE_TAC[]) ; REPLICATE_TAC (52-6)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th THEN ASM_REWRITE_TAC[ARITH_RULE`SUC(3-1)=3`]) THEN STRIP_TAC THEN SUBGOAL_THEN`d' = scs_d_v39 s' `ASSUME_TAC ; EXPAND_TAC"s'" THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist;periodic2;scs_half_slice_v39] ; SUBGOAL_THEN` (q+1+k -p MOD k)MOD k =scs_k_v39 s'` ASSUME_TAC ; EXPAND_TAC"s'" THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist;periodic2;scs_half_slice_v39] THEN ASM_REWRITE_TAC[] ; MRESA_TAC (GEN_ALL SCS_K_PRIME_LE_GE)[`s:scs_v39`;`p:num`;`q:num`;`d':real`;`scs_J_v39 s' p q`] THEN POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;scs_half_slice_v39;PAIR_EQ;REAL_ARITH`#0.11 < #0.9`;ARITH_RULE`3<=3`] THEN STRIP_TAC THEN MP_TAC(ARITH_RULE`3<= k' /\ k'<k ==> 0<k' /\ ~(k=0) /\ k'-1<k'`) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`0`;`k':num`] THEN MRESA_TAC MOD_LT[`k'-1`;`k':num`] THEN MRESAL_TAC (GEN_ALL W_EW_K_SCS_ADD_P)[ `d':real`;`mkj:bool`;`s':scs_v39`;`(vv:num->real^3)(p MOD k)`;`q:num`;`s:scs_v39`;`(vv:num->real^3)`;`k':num`;`p:num`;`k:num`;`(vv:num->real^3) (q MOD k)`][MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;ARITH_RULE`3-1=2`] THEN MP_TAC QKNVMLB1 THEN ASM_REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;REAL_ARITH`#0.11 < #0.9`;ARITH_RULE`3<=3`] THEN STRIP_TAC THEN REMOVE_ASSUM_TAC THEN POP_ASSUM(fun th-> MRESAL_TAC th[`0`;`k'-1`][ARITH_RULE`0+A=A`;dist]) THEN POP_ASSUM MP_TAC THEN EXPAND_TAC"s'" THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist;periodic2;scs_half_slice_v39] THEN ASM_REWRITE_TAC[] THEN REPLICATE_TAC (66-42)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN POP_ASSUM MP_TAC THEN MP_TAC th THEN ASM_REWRITE_TAC[cstab]) THEN REAL_ARITH_TAC; REPLICATE_TAC (52-6)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th THEN ASM_REWRITE_TAC[ARITH_RULE`SUC(3-1)=3`]) THEN STRIP_TAC THEN SUBGOAL_THEN`d' = scs_d_v39 s' `ASSUME_TAC ; EXPAND_TAC"s'" THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist;periodic2;scs_half_slice_v39] ; SUBGOAL_THEN` (q+1+k -p MOD k)MOD k =scs_k_v39 s'` ASSUME_TAC ; EXPAND_TAC"s'" THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist;periodic2;scs_half_slice_v39] THEN ASM_REWRITE_TAC[] ; MRESA_TAC (GEN_ALL SCS_K_PRIME_LE_GE)[`s:scs_v39`;`p:num`;`q:num`;`d':real`;`scs_J_v39 s' p q`] THEN POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;scs_half_slice_v39;PAIR_EQ;REAL_ARITH`#0.11 < #0.9`;ARITH_RULE`3<=3`] THEN STRIP_TAC THEN MP_TAC(ARITH_RULE`3<= k' /\ k'<k ==> 0<k' /\ ~(k=0) /\ k'-1<k'`) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`0`;`k':num`] THEN MRESA_TAC MOD_LT[`k'-1`;`k':num`] THEN MRESAL_TAC (GEN_ALL W_EW_K_SCS_ADD_P)[ `d':real`;`mkj:bool`;`s':scs_v39`;`(vv:num->real^3)(p MOD k)`;`q:num`;`s:scs_v39`;`(vv:num->real^3)`;`k':num`;`p:num`;`k:num`;`(vv:num->real^3) (q MOD k)`][MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;ARITH_RULE`3-1=2`] THEN MP_TAC QKNVMLB1 THEN ASM_REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;REAL_ARITH`#0.11 < #0.9`;ARITH_RULE`3<=3`] THEN STRIP_TAC THEN REMOVE_ASSUM_TAC THEN POP_ASSUM(fun th-> MRESAL_TAC th[`0`;`k'-1`][ARITH_RULE`0+A=A`;dist]) THEN POP_ASSUM MP_TAC THEN EXPAND_TAC"s'" THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist;periodic2;scs_half_slice_v39] THEN ASM_REWRITE_TAC[] THEN REPLICATE_TAC (66-42)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN POP_ASSUM MP_TAC THEN MP_TAC th THEN ASM_REWRITE_TAC[cstab]) THEN REAL_ARITH_TAC; ]);;
let VV_SUC_EQ_RHO_NODE_PRIME=
prove_by_refinement(`scs_k_v39 s =k /\ (vv:num->real^3) p1=u /\ IMAGE (vv:num->real^3) (:num)=V/\ IMAGE (\i. {vv i,(vv:num->real^3) (SUC i)}) (:num) =E/\ IMAGE (\i. (vv i,(vv:num->real^3) (SUC i))) (:num)=FF /\ is_scs_v39 s /\ ~(k<=3)/\ BBs_v39 s vv ==> (!m. ITER m (rho_node1 FF) u= vv (m+p1))`,
[ STRIP_TAC THEN INDUCT_TAC; ASM_REWRITE_TAC[ITER;ARITH_RULE`0+p=p`]; ASM_REWRITE_TAC[ITER] THEN SUBGOAL_THEN`(vv:num->real^3) (m+p1), (vv:num->real^3) (SUC m+p1) IN FF ` ASSUME_TAC; EXPAND_TAC"FF" THEN REWRITE_TAC[IMAGE;IN_ELIM_THM] THEN EXISTS_TAC`m+p1:num` THEN REWRITE_TAC[ARITH_RULE`SUC m+p= SUC(m+p)`;SET_RULE`(a:num)IN(:num)`]; MATCH_MP_TAC(GEN_ALL Local_lemmas.DETER_RHO_NODE) THEN EXISTS_TAC`V:real^3->bool` THEN EXISTS_TAC`E:(real^3->bool)->bool` THEN ASM_REWRITE_TAC[] THEN MP_TAC SCS_K_PRIME_CASE_3 THEN RESA_TAC THEN POP_ASSUM(fun th-> ASM_TAC THEN ASSUME_TAC th) THEN ASM_REWRITE_TAC[scs_diag;BBs_v39;LET_DEF;LET_END_DEF;convex_local_fan] THEN REPEAT RESA_TAC]);;
let SUM_AZIM_EQ_ANGLE_LE4=
prove_by_refinement( ` ~(scs_k_v39 s<=3)/\ BBs_v39 s vv /\ is_scs_v39 s /\ (vv:num->real^3) (p MOD (scs_k_v39 s))=u /\ IMAGE (vv:num->real^3) (:num)=V/\ IMAGE (\i. {vv i,(vv:num->real^3) (SUC i)}) (:num)=E/\ IMAGE (\i. (vv i,(vv:num->real^3) (SUC i))) (:num)=FF ==> sum {i | i < scs_k_v39 s} (\i. rho_fun (norm ((vv:num->real^3) (i+p MOD scs_k_v39 s))) * interior_angle1 (vec 0) FF (ITER i (rho_node1 FF) u)) =sum FF (\e. rho_fun (norm (FST e)) * azim_in_fan e E) `,
[ MRESA_TAC (GEN_ALL IN_IMAGE_VV)[`p MOD scs_k_v39 s`;`vv:num->real^3`] THEN ASM_TAC THEN ASM_REWRITE_TAC[MMs_v39;BBprime_v39;BBprime2_v39;is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist] THEN ABBREV_TAC`k= scs_k_v39 s` THEN REPEAT RESA_TAC; REPLICATE_TAC (30-2)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th) THEN ASM_REWRITE_TAC[]; MATCH_MP_TAC SUM_EQ_GENERAL THEN EXISTS_TAC`(\i. (vv:num->real^3) (i+ p MOD k), vv (SUC i + p MOD k))` THEN MP_TAC(ARITH_RULE`3<= k ==> ~(k=0) /\ 1<k`) THEN RESA_TAC THEN STRIP_TAC; EXPAND_TAC"FF" THEN REWRITE_TAC[IN_ELIM_THM; IMAGE;EXISTS_UNIQUE] THEN ASM_REWRITE_TAC[PAIR_EQ] THEN REPEAT RESA_TAC THEN EXISTS_TAC`(x MOD k + k -p MOD k) MOD k` THEN ASM_REWRITE_TAC[ARITH_RULE`A-0=A`;PAIR_EQ] THEN MRESA_TAC DIVISION[`x MOD k + k - p MOD k:num`;`k:num`] THEN MRESA_TAC DIVISION[`p:num`;`k:num`] THEN MRESA_TAC MOD_LT[`p MOD k`;`k:num`] THEN MRESA_TAC MOD_MOD_REFL[`x:num`;`k:num`] THEN MRESAL_TAC MOD_MULT_ADD[`1`;`k:num`;`x MOD k`][ARITH_RULE`1 * k + x MOD k = x MOD k +k`] THEN MRESA_TAC MOD_ADD_MOD[`x MOD k + k - p MOD k:num`;`p MOD k:num`;`k:num`] THEN MP_TAC(ARITH_RULE`1<k/\ p MOD k<k ==>(x MOD k+ k- p MOD k) + p MOD k = x MOD k+k /\ (x + p MOD k) + k- p MOD k= x+k`) THEN RESA_TAC THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`vv:num->real^3`][ARITH_RULE`~(4=0)`;] THEN POP_ASSUM(fun th-> MRESA1_TAC th `(x MOD k + k - p MOD k) MOD k + p MOD k:num` THEN MRESA1_TAC th ` x:num`) THEN MRESA_TAC MOD_ADD_MOD[`x:num`;`1`;`k:num`] THEN MRESA_TAC MOD_ADD_MOD[`(x MOD k + k - p MOD k) MOD k + p MOD k`;`1`;`k:num`] THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`vv:num->real^3`][ARITH_RULE`~(4=0)`;ARITH_RULE`SUC ((x MOD k + k - p MOD k) MOD k) + p MOD k = ((x MOD k + k - p MOD k) MOD k + p MOD k)+1`] THEN POP_ASSUM(fun th-> MRESA1_TAC th `((x MOD k + k - p MOD k) MOD k + p MOD k)+1:num` THEN MRESA1_TAC th ` x+1:num`) THEN REWRITE_TAC[ADD1] THEN REPEAT STRIP_TAC THEN MRESA_TAC DIVISION[`x:num`;`k:num`] THEN MRESA_TAC DIVISION[`y' + p MOD k:num`;`k:num`] THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`vv:num->real^3`][ARITH_RULE`~(4=0)`;] THEN POP_ASSUM(fun th-> MRESA1_TAC th `y' + p MOD k:num`) THEN MP_TAC VV_INJ THEN ASM_REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;scs_half_slice_v39;PAIR_EQ;REAL_ARITH`#0.11 < #0.9`;ARITH_RULE`3<=3`;dist] THEN STRIP_TAC THEN POP_ASSUM(fun th-> MRESA_TAC th[`(y'+ p MOD k) MOD k:num`;`(x MOD k + k)MOD k`]) THEN MRESA_TAC MOD_LT[`y':num`;`k:num`] THEN MRESAL_TAC(GEN_ALL Hdplygy.MOD_EQ_MOD)[`y':num`;`x MOD k + k- p MOD k`;`p MOD k`;`k:num`][] THEN POP_ASSUM MP_TAC THEN ONCE_REWRITE_TAC[ADD_SYM] THEN RESA_TAC; REWRITE_TAC[IN_ELIM_THM;] THEN REPEAT STRIP_TAC; EXPAND_TAC"FF" THEN REWRITE_TAC[IMAGE;IN_ELIM_THM] THEN EXISTS_TAC`x+ p MOD k` THEN REWRITE_TAC[SET_RULE`(a:num)IN (:num)`;ADD1;ARITH_RULE`(x + 1) + p MOD k= (x + p MOD k)+1`]; MRESAL_TAC(GEN_ALL VV_SUC_EQ_RHO_NODE_PRIME)[`V:real^3->bool`;`E:(real^3->bool)->bool`;`k:num`;`s:scs_v39`;`FF:real^3#real^3->bool`;`u:real^3`;`vv:num->real^3`;`p:num MOD k`] [is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist] THEN SUBGOAL_THEN`(vv:num->real^3) (x + p MOD k) IN V`ASSUME_TAC; EXPAND_TAC"V" THEN REWRITE_TAC[IN_ELIM_THM;IMAGE] THEN EXISTS_TAC`x+ p MOD k` THEN REWRITE_TAC[SET_RULE`(a:num)IN (:num)`]; REPLICATE_TAC (35-6)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th) THEN ASM_REWRITE_TAC[] THEN STRIP_TAC THEN MP_TAC Nkezbfc_local.CONVEX_LOFA_IMP_INANGLE_EQ_AZIM THEN RESA_TAC THEN POP_ASSUM(fun th-> MRESA_TAC th[`(vv:num->real^3) (x + p MOD k )`]) THEN REPLICATE_TAC (3) REMOVE_ASSUM_TAC THEN POP_ASSUM(fun th-> ASSUME_TAC th THEN MRESAL1_TAC th`SUC x`[ITER])]);;
let V_SLICE_EQ_NUMSEG=
prove_by_refinement( ` IMAGE (\i. (vv i,(vv:num->real^3) (SUC i))) (:num) = FF/\ scs_k_v39 s=k /\ scs_k_v39 s'=k' /\ vv (p MOD k) =u /\ scs_half_slice_v39 s p q d' mkj =s'/\ MMs_v39 s vv /\ is_scs_v39 s /\ scs_diag (scs_k_v39 s) p q /\ is_scs_slice_v39 s s' s'' p q ==> {i | i < k /\ ITER i (rho_node1 FF) u IN IMAGE (\i. vv (i MOD k' + p MOD k)) (:num)} ={i | i<k'}`,
[ REWRITE_TAC[MMs_v39;BBprime_v39;BBprime2_v39;is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist] THEN REPEAT STRIP_TAC THEN REWRITE_TAC[EXTENSION;IN_ELIM_THM;IMAGE] THEN MRESAL_TAC(GEN_ALL VV_SUC_EQ_RHO_NODE)[`scs_k_v39 s`;`IMAGE (vv:num->real^3) (:num)`;`IMAGE (\i. {(vv:num->real^3) i, vv (SUC i)}) (:num)`;`p:num`;`q:num`;`s:scs_v39`;`FF:real^3#real^3->bool`;`(vv:num->real^3) (p MOD k)`;`vv:num->real^3`;`p:num MOD k`] [is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist] THEN SUBGOAL_THEN` (q+1+k -p MOD k)MOD k =scs_k_v39 s'` ASSUME_TAC; EXPAND_TAC"s'" THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist;periodic2;scs_half_slice_v39] THEN ASM_REWRITE_TAC[]; MRESAL_TAC (GEN_ALL SCS_K_PRIME_LE_GE)[`s:scs_v39`;`p:num`;`q:num`;`d':real`;`scs_J_v39 s' p q`] [MMs_v39;BBprime_v39;BBprime2_v39;is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist;scs_half_slice_v39] THEN GEN_TAC THEN EQ_TAC; MP_TAC(ARITH_RULE`3 <= scs_k_v39 s ==> ~(scs_k_v39 s=0)`) THEN RESA_TAC THEN STRIP_TAC THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`vv:num->real^3`][ARITH_RULE`~(4=0)`;] THEN POP_ASSUM(fun th-> MRESA1_TAC th `x + p MOD k:num` THEN MRESA1_TAC th `x' MOD k'+ p MOD k:num`) THEN MRESA_TAC DIVISION[`x+ p MOD k`;`k:num`] THEN MRESA_TAC DIVISION[`x' MOD k'+ p MOD k`;`k:num`] THEN MP_TAC VV_INJ THEN ASM_REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;scs_half_slice_v39;PAIR_EQ;REAL_ARITH`#0.11 < #0.9`;ARITH_RULE`3<=3`;dist] THEN STRIP_TAC THEN POP_ASSUM(fun th-> MRESA_TAC th[`(x' MOD k'+ p MOD k) MOD k:num`;`(x + p MOD k)MOD k`]) THEN MRESAL_TAC(GEN_ALL Hdplygy.MOD_EQ_MOD)[`x' MOD k':num`;`x:num`;`p MOD k`;`k:num`][] THEN POP_ASSUM MP_TAC THEN ONCE_REWRITE_TAC[ADD_SYM] THEN MRESA_TAC MOD_LT[`x:num`;`k:num`] THEN MP_TAC(ARITH_RULE`3<=k' ==> ~(k'=0)`) THEN RESA_TAC THEN MRESA_TAC DIVISION[`x':num`;`k':num`] THEN MP_TAC(ARITH_RULE`3<=k'/\ k'<k /\ x' MOD k'< k' ==> x' MOD k'< k`) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`x' MOD k':num`;`k:num`] THEN STRIP_TAC THEN POP_ASSUM(fun th-> ASM_REWRITE_TAC[SYM th]); REPEAT STRIP_TAC; POP_ASSUM MP_TAC THEN POP_ASSUM MP_TAC THEN ARITH_TAC; EXISTS_TAC`x:num` THEN MRESA_TAC MOD_LT[`x:num`;`k':num`] THEN REWRITE_TAC[SET_RULE`(x:num)IN(:num)`]; EXPAND_TAC"s'" THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist;periodic2;scs_half_slice_v39] THEN ASM_REWRITE_TAC[]; MRESAL_TAC (GEN_ALL SCS_K_PRIME_LE_GE)[`s:scs_v39`;`p:num`;`q:num`;`d':real`;`scs_J_v39 s' p q`] [MMs_v39;BBprime_v39;BBprime2_v39;is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist;scs_half_slice_v39] THEN GEN_TAC THEN EQ_TAC; MP_TAC(ARITH_RULE`3 <= scs_k_v39 s ==> ~(scs_k_v39 s=0)`) THEN RESA_TAC THEN STRIP_TAC THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`vv:num->real^3`][ARITH_RULE`~(4=0)`;] THEN POP_ASSUM(fun th-> MRESA1_TAC th `x + p MOD k:num` THEN MRESA1_TAC th `x' MOD k'+ p MOD k:num`) THEN MRESA_TAC DIVISION[`x+ p MOD k`;`k:num`] THEN MRESA_TAC DIVISION[`x' MOD k'+ p MOD k`;`k:num`] THEN MP_TAC VV_INJ THEN ASM_REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;scs_half_slice_v39;PAIR_EQ;REAL_ARITH`#0.11 < #0.9`;ARITH_RULE`3<=3`;dist] THEN STRIP_TAC THEN POP_ASSUM(fun th-> MRESA_TAC th[`(x' MOD k'+ p MOD k) MOD k:num`;`(x + p MOD k)MOD k`]) THEN MRESAL_TAC(GEN_ALL Hdplygy.MOD_EQ_MOD)[`x' MOD k':num`;`x:num`;`p MOD k`;`k:num`][] THEN POP_ASSUM MP_TAC THEN ONCE_REWRITE_TAC[ADD_SYM] THEN MRESA_TAC MOD_LT[`x:num`;`k:num`] THEN MP_TAC(ARITH_RULE`3<=k' ==> ~(k'=0)`) THEN RESA_TAC THEN MRESA_TAC DIVISION[`x':num`;`k':num`] THEN MP_TAC(ARITH_RULE`3<=k'/\ k'<k /\ x' MOD k'< k' ==> x' MOD k'< k`) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`x' MOD k':num`;`k:num`] THEN STRIP_TAC THEN POP_ASSUM(fun th-> ASM_REWRITE_TAC[SYM th]); REPEAT STRIP_TAC; POP_ASSUM MP_TAC THEN POP_ASSUM MP_TAC THEN ARITH_TAC; EXISTS_TAC`x:num` THEN MRESA_TAC MOD_LT[`x:num`;`k':num`] THEN REWRITE_TAC[SET_RULE`(x:num)IN(:num)`]]);;
let SCS_SLICE_SYM= 
prove_by_refinement(` is_scs_v39 s /\ scs_diag (scs_k_v39 s) p q==> (is_scs_slice_v39 s s' s'' p q <=> is_scs_slice_v39 s s'' s' q p)`,
[ REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist; is_scs_slice_v39;scs_slice_v39;PAIR_EQ] THEN RESA_TAC THEN EQ_TAC; RESA_TAC THEN MRESAL_TAC(GEN_ALL SCS_J_DIAG_EQ)[`scs_d_v39 s'`;`scs_d_v39 s''`;`scs_J_v39 s' 0 (scs_k_v39 s' - 1):bool`;`s:scs_v39`;`p:num`;`q:num`;`s':scs_v39`;`s'':scs_v39`] [MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist; is_scs_slice_v39;scs_slice_v39;PAIR_EQ] THEN POP_ASSUM MP_TAC THEN REWRITE_TAC[SET_RULE`(A/\ B/\A /\B==>C)<=>(A/\B==>C) `] THEN REPLICATE_TAC (30-23)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT DISCH_TAC THEN REPLICATE_TAC (1)(POP_ASSUM MP_TAC) THEN GEN_REWRITE_TAC(LAND_CONV o LAND_CONV o LAND_CONV o LAND_CONV o ONCE_DEPTH_CONV)[th] THEN ASSUME_TAC th) THEN REWRITE_TAC[] THEN REPLICATE_TAC (30-23)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT DISCH_TAC THEN REPLICATE_TAC (1)(POP_ASSUM MP_TAC) THEN GEN_REWRITE_TAC(LAND_CONV o LAND_CONV o LAND_CONV o ONCE_DEPTH_CONV)[th] THEN ASSUME_TAC th) THEN RESA_TAC THEN POP_ASSUM(fun th-> ASM_REWRITE_TAC[SYM th;REAL_ARITH`a<=b+c <=> a<= c+b`; SET_RULE`(A==> B\/C)<=> (A==>C\/B)`]) THEN STRIP_TAC; POP_ASSUM(fun th-> GEN_REWRITE_TAC(LAND_CONV o ONCE_DEPTH_CONV)[th]) THEN REWRITE_TAC[]; REMOVE_ASSUM_TAC THEN POP_ASSUM(fun th-> GEN_REWRITE_TAC(LAND_CONV o ONCE_DEPTH_CONV)[th]) THEN REWRITE_TAC[]; POP_ASSUM(fun th-> GEN_REWRITE_TAC(LAND_CONV o ONCE_DEPTH_CONV)[th]) THEN REWRITE_TAC[]; REMOVE_ASSUM_TAC THEN POP_ASSUM(fun th-> GEN_REWRITE_TAC(LAND_CONV o ONCE_DEPTH_CONV)[th]) THEN REWRITE_TAC[]; RESA_TAC THEN MRESAL_TAC(GEN_ALL SCS_J_DIAG_EQ)[`scs_d_v39 s''`;`scs_d_v39 s'`;`scs_J_v39 s'' 0 (scs_k_v39 s'' - 1):bool`;`s:scs_v39`;`q:num`;`p:num`;`s'':scs_v39`;`s':scs_v39`] [MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist; is_scs_slice_v39;scs_slice_v39;PAIR_EQ] THEN POP_ASSUM MP_TAC THEN REWRITE_TAC[SET_RULE`(A/\ B/\A /\B==>C)<=>(A/\B==>C) `] THEN REPLICATE_TAC (30-23)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT DISCH_TAC THEN REPLICATE_TAC (1)(POP_ASSUM MP_TAC) THEN GEN_REWRITE_TAC(LAND_CONV o LAND_CONV o LAND_CONV o LAND_CONV o ONCE_DEPTH_CONV)[th] THEN ASSUME_TAC th) THEN REWRITE_TAC[] THEN REPLICATE_TAC (30-23)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT DISCH_TAC THEN REPLICATE_TAC (1)(POP_ASSUM MP_TAC) THEN GEN_REWRITE_TAC(LAND_CONV o LAND_CONV o LAND_CONV o ONCE_DEPTH_CONV)[th] THEN ASSUME_TAC th) THEN RESA_TAC THEN POP_ASSUM(fun th-> ASM_REWRITE_TAC[SYM th;]) THEN STRIP_TAC; STRIP_TAC; POP_ASSUM(fun th-> GEN_REWRITE_TAC(LAND_CONV o ONCE_DEPTH_CONV)[th]) THEN REWRITE_TAC[]; REMOVE_ASSUM_TAC THEN POP_ASSUM(fun th-> GEN_REWRITE_TAC(LAND_CONV o ONCE_DEPTH_CONV)[th]) THEN REWRITE_TAC[]; STRIP_TAC; ONCE_REWRITE_TAC[REAL_ARITH`a<=b+c <=> a<= c+b`] THEN ASM_REWRITE_TAC[]; ONCE_REWRITE_TAC[SET_RULE`(A==> B\/C)<=> (A==>C\/B)`] THEN ASM_REWRITE_TAC[]; STRIP_TAC; POP_ASSUM(fun th-> GEN_REWRITE_TAC(LAND_CONV o ONCE_DEPTH_CONV)[th]) THEN REWRITE_TAC[]; REMOVE_ASSUM_TAC THEN POP_ASSUM(fun th-> GEN_REWRITE_TAC(LAND_CONV o ONCE_DEPTH_CONV)[th]) THEN REWRITE_TAC[]; STRIP_TAC; ONCE_REWRITE_TAC[REAL_ARITH`a<=b+c <=> a<= c+b`] THEN ASM_REWRITE_TAC[]; ONCE_REWRITE_TAC[SET_RULE`(A==> B\/C)<=> (A==>C\/B)`] THEN ASM_REWRITE_TAC[]]);;
let SUM_NUMSEG2=
prove(`!t. sum(0..2) t = t(0) +t(1) + t(2)`,
REWRITE_TAC[num_CONV `1`;num_CONV `2`; SUM_CLAUSES_NUMSEG] THEN REWRITE_TAC[SUM_SING_NUMSEG; ARITH; REAL_ADD_ASSOC]);;
let NUMSEG_2=
prove(`{i| i<3}=0..2`,
REWRITE_TAC[EXTENSION;IN_NUMSEG;IN_ELIM_THM] THEN ARITH_TAC);;
let SUM_NUMSEG3=
prove(`!t. sum(0..3) t = t(0) +t(1) + t(2)+ t(3)`,
REWRITE_TAC[num_CONV `1`;num_CONV `2`;num_CONV `3`; SUM_CLAUSES_NUMSEG] THEN REWRITE_TAC[SUM_SING_NUMSEG; ARITH; REAL_ADD_ASSOC]);;
let NUMSEG_3=
prove(`{i| i<4}=0..3`,
REWRITE_TAC[EXTENSION;IN_NUMSEG;IN_ELIM_THM] THEN ARITH_TAC);;
let SUM_AZIM_EQ_ANGLE_EQ4=
prove_by_refinement( `(k'=3)/\ scs_half_slice_v39 s p q d' mkj =s'/\ scs_half_slice_v39 s q p d'' mkj =s'' /\ vv' = (\i. (vv:num->real^3) (i MOD (scs_k_v39 s')+p MOD (scs_k_v39 s))) /\ vv'' = (\i. (vv:num->real^3) (i MOD (scs_k_v39 s'')+q MOD (scs_k_v39 s))) /\ MMs_v39 s vv /\ is_scs_v39 s /\ scs_diag (scs_k_v39 s) p q /\ is_scs_slice_v39 s s' s'' p q /\ scs_k_v39 s' =k' /\ scs_k_v39 s =k /\(vv:num->real^3) (p MOD k)=u /\ (vv:num->real^3) (q MOD k)=w /\ IMAGE (vv:num->real^3) (:num)=V/\ IMAGE (\i. {vv i,(vv:num->real^3) (SUC i)}) (:num) =E/\ IMAGE (\i. (vv i,(vv:num->real^3) (SUC i))) (:num)=FF /\ norm (u - w) <= cstab /\ convex_local_fan (v_prime V (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u)), e_prime (E UNION {{u, w}}) (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u)), face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u)) ==> tau3 (vv (0 MOD k' + p MOD k)) (vv (1 MOD k' + p MOD k)) (vv (2 MOD k' + p MOD k)) = sum {i | i < k'} (\i. rho_fun (norm (vv (i + p MOD k))) * interior_angle1 (vec 0) (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u)) (ITER i (rho_node1 FF) u)) - (pi + sol0)`,
[ REWRITE_TAC[LET_DEF;LET_END_DEF;tau3;MMs_v39;BBprime2_v39;BBprime_v39;] THEN STRIP_TAC THEN MATCH_MP_TAC(REAL_ARITH`a1+a2+a3=b==> a1+a2+a3-c= b-c`) THEN ASM_REWRITE_TAC[NUMSEG_2;SUM_NUMSEG2;ARITH_RULE`0 MOD 3=0/\1 MOD 3=1/\ 2 MOD 3=2`;Appendix.rho_rho_fun] THEN MP_TAC V_PRIME_EQ_V_vv THEN RESA_TAC THEN MP_TAC E_PRIME_EQ_E_vv THEN RESA_TAC THEN MP_TAC F_PRIME_EQ_F_vv THEN RESA_TAC THEN MP_TAC SCS_HALF_SLICE_IS_A_SCS THEN RESA_TAC THEN SUBGOAL_THEN`BBs_v39 s' vv'`ASSUME_TAC; MP_TAC QKNVMLB1 THEN REWRITE_TAC[MMs_v39;BBprime2_v39;BBprime_v39;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;IN;mk_unadorned_v39;] THEN RESA_TAC THEN POP_ASSUM MATCH_MP_TAC THEN ASM_TAC THEN REWRITE_TAC[LET_DEF;LET_END_DEF;tau3;MMs_v39;BBprime2_v39;BBprime_v39;is_scs_slice_v39] THEN REPEAT RESA_TAC THEN SUBGOAL_THEN`d' = scs_d_v39 s'`ASSUME_TAC ; EXPAND_TAC"s'" THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist;periodic2;scs_half_slice_v39] THEN ASM_REWRITE_TAC[]; ASM_REWRITE_TAC[] ; EXPAND_TAC"s'" THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist;periodic2;scs_half_slice_v39] THEN ASM_REWRITE_TAC[]; ASM_REWRITE_TAC[] ; MRESAL_TAC (GEN_ALL(INST_TYPE [`:3`,`:M`]V_E_FF_IS_SCS_CASES_3))[`s':scs_v39`;`vv':num->real^3`] [DIMINDEX_3] THEN MRESA_TAC(GEN_ALL VV_SUC_EQ_RHO_NODE)[`scs_k_v39 s`;`V:real^3->bool`;`E:(real^3->bool)->bool`;`p:num`;`q:num`;`s:scs_v39`;`FF:real^3#real^3->bool`;`u:real^3`;`vv:num->real^3`;`p:num MOD k`] THEN MRESA_TAC (GEN_ALL Nkezbfc_local.CONVEX_LOFA_IMP_INANGLE_EQ_AZIM_IVS) [`e_prime (E UNION {{u, w}}) (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u))`; `v_prime V (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u))`; `face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u)`] THEN MATCH_MP_TAC(REAL_ARITH`a1= b1 /\ a2= b2 /\a3= b3 ==> a1+a2+a3= b1+b2+b3`) THEN REPEAT STRIP_TAC THEN REWRITE_TAC[REAL_EQ_MUL_LCANCEL] THEN MATCH_MP_TAC(SET_RULE`A==>B\/A`) ; POP_ASSUM MP_TAC THEN SUBGOAL_THEN`vv (0 + p MOD k) IN v_prime V (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u))` ASSUME_TAC; REPLICATE_TAC (33-26)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN REWRITE_TAC[SYM th;IN_ELIM_THM;IMAGE]) THEN EXISTS_TAC`0` THEN REWRITE_TAC[SET_RULE`(a:num)IN(:num)`;ARITH_RULE`0 MOD 3=0/\ 1 MOD 3=1/\ 2 MOD 3=2`]; SUBGOAL_THEN`vv (1 + p MOD k) IN v_prime V (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u))` ASSUME_TAC; REPLICATE_TAC (34-26)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN REWRITE_TAC[SYM th;IN_ELIM_THM;IMAGE]) THEN EXISTS_TAC`1` THEN REWRITE_TAC[SET_RULE`(a:num)IN(:num)`;ARITH_RULE`0 MOD 3=0/\ 1 MOD 3=1/\ 2 MOD 3=2`]; SUBGOAL_THEN`vv (2 + p MOD k) IN v_prime V (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u))` ASSUME_TAC; REPLICATE_TAC (35-26)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN REWRITE_TAC[SYM th;IN_ELIM_THM;IMAGE]) THEN EXISTS_TAC`2` THEN REWRITE_TAC[SET_RULE`(a:num)IN(:num)`;ARITH_RULE`0 MOD 3=0/\ 1 MOD 3=1/\ 2 MOD 3=2`]; REPLICATE_TAC (3)(POP_ASSUM MP_TAC) THEN REPLICATE_TAC (4) RESA_TAC THEN POP_ASSUM(fun th-> MRESA1_TAC th`(vv:num->real^3) (0 + p MOD k)`) THEN SUBGOAL_THEN`(rho_node1 {(vv (0 MOD 3 + p MOD k),vv (1 MOD 3 + p MOD k)), (vv (1 MOD 3 + p MOD k), vv (2 MOD 3 + p MOD k)), (vv (2 MOD 3 + p MOD k), vv (0 MOD 3 + p MOD k))} (vv (0 + p MOD k))) = (vv:num->real^3) (1 MOD 3 + p MOD k)`ASSUME_TAC ; MATCH_MP_TAC (GEN_ALL Local_lemmas.DETER_RHO_NODE) THEN EXISTS_TAC`v_prime V (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u))` THEN EXISTS_TAC`e_prime (E UNION {{u, w}}) (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u))` THEN ASM_REWRITE_TAC[] THEN REPLICATE_TAC (37-25)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT DISCH_TAC THEN MP_TAC th THEN ASM_REWRITE_TAC[convex_local_fan] THEN RESA_TAC) THEN REWRITE_TAC[SET_RULE`a IN {a1,b,c} <=> a=a1\/ a=b\/ a=c`;ARITH_RULE`0 MOD 3=0/\ 1 MOD 3=1/\ 2 MOD 3=2`] ; ASM_REWRITE_TAC[] THEN SUBGOAL_THEN`(ivs_rho_node1 {(vv (0 MOD 3 + p MOD k),vv (1 MOD 3 + p MOD k)), (vv (1 MOD 3 + p MOD k), vv (2 MOD 3 + p MOD k)), (vv (2 MOD 3 + p MOD k), vv (0 MOD 3 + p MOD k))} (vv (0 + p MOD k))) = (vv:num->real^3) (2 MOD 3 + p MOD k)`ASSUME_TAC ; MATCH_MP_TAC (GEN_ALL Local_lemmas.IVS_RHO_NODE1_DETE) THEN EXISTS_TAC`v_prime V (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u))` THEN EXISTS_TAC`e_prime (E UNION {{u, w}}) (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u))` THEN ASM_REWRITE_TAC[] THEN REPLICATE_TAC (38-25)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT DISCH_TAC THEN MP_TAC th THEN ASM_REWRITE_TAC[convex_local_fan] THEN RESA_TAC) THEN REWRITE_TAC[SET_RULE`a IN {a1,b,c} <=> a=a1\/ a=b\/ a=c`;ARITH_RULE`0 MOD 3=0/\ 1 MOD 3=1/\ 2 MOD 3=2`] ; SUBGOAL_THEN`(rho_node1 {(vv (0 MOD 3 + p MOD k),vv (1 MOD 3 + p MOD k)), (vv (1 MOD 3 + p MOD k), vv (2 MOD 3 + p MOD k)), (vv (2 MOD 3 + p MOD k), vv (0 MOD 3 + p MOD k))} (vv (2 + p MOD k))) = (vv:num->real^3) (0 MOD 3 + p MOD k)`ASSUME_TAC ; MATCH_MP_TAC (GEN_ALL Local_lemmas.DETER_RHO_NODE) THEN EXISTS_TAC`v_prime V (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u))` THEN EXISTS_TAC`e_prime (E UNION {{u, w}}) (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u))` THEN ASM_REWRITE_TAC[] THEN REPLICATE_TAC (39-25)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT DISCH_TAC THEN MP_TAC th THEN ASM_REWRITE_TAC[convex_local_fan] THEN RESA_TAC) THEN REWRITE_TAC[SET_RULE`a IN {a1,b,c} <=> a=a1\/ a=b\/ a=c`;ARITH_RULE`0 MOD 3=0/\ 1 MOD 3=1/\ 2 MOD 3=2`] ; ASM_REWRITE_TAC[ARITH_RULE`0 MOD 3=0/\ 1 MOD 3=1/\ 2 MOD 3=2`] THEN MRESA_TAC (GEN_ALL Local_lemmas.IN_V_IMP_AZIM_LESS_PI)[`e_prime (E UNION {{u, w}}) (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u))`; `v_prime V (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u))`; `face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u)`;`(vv:num->real^3) (0 + p MOD k)`] THEN POP_ASSUM(fun th-> MRESA1_TAC th`(vv:num->real^3) (2 + p MOD k)`) THEN POP_ASSUM MP_TAC THEN REWRITE_TAC[ARITH_RULE`0 MOD 3=0/\ 1 MOD 3=1/\ 2 MOD 3=2`] THEN STRIP_TAC THEN SUBGOAL_THEN` local_fan (v_prime V (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u)), e_prime (E UNION {{u, w}}) (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u)), face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u)) `ASSUME_TAC ; ASM_TAC THEN REWRITE_TAC[convex_local_fan] THEN REPEAT RESA_TAC ; MRESA_TAC (GEN_ALL Local_lemmas.LOCAL_FAN_CHARACTER_OF_RHO_NODE2) [`e_prime (E UNION {{u, w}}) (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u))`; `v_prime V (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u))`; `face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u)`;`(vv:num->real^3) (0 + p MOD k)`] THEN POP_ASSUM MP_TAC THEN REWRITE_TAC[ARITH_RULE`0 MOD 3=0/\ 1 MOD 3=1/\ 2 MOD 3=2`] THEN STRIP_TAC THEN MRESA_TAC (GEN_ALL Local_lemmas.LOCAL_FAN_CHARACTER_OF_RHO_NODE2) [`e_prime (E UNION {{u, w}}) (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u))`; `v_prime V (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u))`; `face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u)`;`(vv:num->real^3) (2 + p MOD k)`]THEN POP_ASSUM MP_TAC THEN REWRITE_TAC[ARITH_RULE`0 MOD 3=0/\ 1 MOD 3=1/\ 2 MOD 3=2`] THEN ONCE_REWRITE_TAC[SET_RULE`{A,B,C}={A,C,B}`] THEN STRIP_TAC THEN MRESA_TAC (GEN_ALL Local_lemmas.AZIM_LE_PI_EQ_DIHV)[`vec 0:real^3`;`(vv:num->real^3) (0 + p MOD k)`;`(vv:num->real^3) (1 + p MOD k)`;`(vv:num->real^3) (2 + p MOD k)`] ; (******************) POP_ASSUM MP_TAC THEN SUBGOAL_THEN`vv (0 + p MOD k) IN v_prime V (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u))` ASSUME_TAC; REPLICATE_TAC (33-26)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN REWRITE_TAC[SYM th;IN_ELIM_THM;IMAGE]) THEN EXISTS_TAC`0` THEN REWRITE_TAC[SET_RULE`(a:num)IN(:num)`;ARITH_RULE`0 MOD 3=0/\ 1 MOD 3=1/\ 2 MOD 3=2`]; SUBGOAL_THEN`vv (1 + p MOD k) IN v_prime V (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u))` ASSUME_TAC; REPLICATE_TAC (34-26)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN REWRITE_TAC[SYM th;IN_ELIM_THM;IMAGE]) THEN EXISTS_TAC`1` THEN REWRITE_TAC[SET_RULE`(a:num)IN(:num)`;ARITH_RULE`0 MOD 3=0/\ 1 MOD 3=1/\ 2 MOD 3=2`]; SUBGOAL_THEN`vv (2 + p MOD k) IN v_prime V (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u))` ASSUME_TAC; REPLICATE_TAC (35-26)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN REWRITE_TAC[SYM th;IN_ELIM_THM;IMAGE]) THEN EXISTS_TAC`2` THEN REWRITE_TAC[SET_RULE`(a:num)IN(:num)`;ARITH_RULE`0 MOD 3=0/\ 1 MOD 3=1/\ 2 MOD 3=2`]; REPLICATE_TAC (3)(POP_ASSUM MP_TAC) THEN REPLICATE_TAC (4) RESA_TAC THEN POP_ASSUM(fun th-> MRESA1_TAC th`(vv:num->real^3) (1 + p MOD k)`) THEN SUBGOAL_THEN`(rho_node1 {(vv (0 MOD 3 + p MOD k),vv (1 MOD 3 + p MOD k)), (vv (1 MOD 3 + p MOD k), vv (2 MOD 3 + p MOD k)), (vv (2 MOD 3 + p MOD k), vv (0 MOD 3 + p MOD k))} (vv (1 + p MOD k))) = (vv:num->real^3) (2 MOD 3 + p MOD k)`ASSUME_TAC ; MATCH_MP_TAC (GEN_ALL Local_lemmas.DETER_RHO_NODE) THEN EXISTS_TAC`v_prime V (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u))` THEN EXISTS_TAC`e_prime (E UNION {{u, w}}) (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u))` THEN ASM_REWRITE_TAC[] THEN REPLICATE_TAC (37-25)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT DISCH_TAC THEN MP_TAC th THEN ASM_REWRITE_TAC[convex_local_fan] THEN RESA_TAC) THEN REWRITE_TAC[SET_RULE`a IN {a1,b,c} <=> a=a1\/ a=b\/ a=c`;ARITH_RULE`0 MOD 3=0/\ 1 MOD 3=1/\ 2 MOD 3=2`] ; ASM_REWRITE_TAC[] THEN SUBGOAL_THEN`(ivs_rho_node1 {(vv (0 MOD 3 + p MOD k),vv (1 MOD 3 + p MOD k)), (vv (1 MOD 3 + p MOD k), vv (2 MOD 3 + p MOD k)), (vv (2 MOD 3 + p MOD k), vv (0 MOD 3 + p MOD k))} (vv (1 + p MOD k))) = (vv:num->real^3) (0 MOD 3 + p MOD k)`ASSUME_TAC ; MATCH_MP_TAC (GEN_ALL Local_lemmas.IVS_RHO_NODE1_DETE) THEN EXISTS_TAC`v_prime V (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u))` THEN EXISTS_TAC`e_prime (E UNION {{u, w}}) (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u))` THEN ASM_REWRITE_TAC[] THEN REPLICATE_TAC (38-25)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT DISCH_TAC THEN MP_TAC th THEN ASM_REWRITE_TAC[convex_local_fan] THEN RESA_TAC) THEN REWRITE_TAC[SET_RULE`a IN {a1,b,c} <=> a=a1\/ a=b\/ a=c`;ARITH_RULE`0 MOD 3=0/\ 1 MOD 3=1/\ 2 MOD 3=2`] ; SUBGOAL_THEN`(rho_node1 {(vv (0 MOD 3 + p MOD k),vv (1 MOD 3 + p MOD k)), (vv (1 MOD 3 + p MOD k), vv (2 MOD 3 + p MOD k)), (vv (2 MOD 3 + p MOD k), vv (0 MOD 3 + p MOD k))} (vv (0 + p MOD k))) = (vv:num->real^3) (1 MOD 3 + p MOD k)`ASSUME_TAC ; MATCH_MP_TAC (GEN_ALL Local_lemmas.DETER_RHO_NODE) THEN EXISTS_TAC`v_prime V (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u))` THEN EXISTS_TAC`e_prime (E UNION {{u, w}}) (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u))` THEN ASM_REWRITE_TAC[] THEN REPLICATE_TAC (39-25)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT DISCH_TAC THEN MP_TAC th THEN ASM_REWRITE_TAC[convex_local_fan] THEN RESA_TAC) THEN REWRITE_TAC[SET_RULE`a IN {a1,b,c} <=> a=a1\/ a=b\/ a=c`;ARITH_RULE`0 MOD 3=0/\ 1 MOD 3=1/\ 2 MOD 3=2`] ; ASM_REWRITE_TAC[ARITH_RULE`0 MOD 3=0/\ 1 MOD 3=1/\ 2 MOD 3=2`] THEN MRESA_TAC (GEN_ALL Local_lemmas.IN_V_IMP_AZIM_LESS_PI)[`e_prime (E UNION {{u, w}}) (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u))`; `v_prime V (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u))`; `face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u)`;`(vv:num->real^3) (1 + p MOD k)`] THEN POP_ASSUM(fun th-> MRESA1_TAC th`(vv:num->real^3) (0 + p MOD k)`) THEN POP_ASSUM MP_TAC THEN REWRITE_TAC[ARITH_RULE`0 MOD 3=0/\ 1 MOD 3=1/\ 2 MOD 3=2`] THEN STRIP_TAC THEN SUBGOAL_THEN` local_fan (v_prime V (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u)), e_prime (E UNION {{u, w}}) (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u)), face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u)) `ASSUME_TAC ; ASM_TAC THEN REWRITE_TAC[convex_local_fan] THEN REPEAT RESA_TAC ; MRESA_TAC (GEN_ALL Local_lemmas.LOCAL_FAN_CHARACTER_OF_RHO_NODE2) [`e_prime (E UNION {{u, w}}) (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u))`; `v_prime V (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u))`; `face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u)`;`(vv:num->real^3) (1 + p MOD k)`] THEN POP_ASSUM MP_TAC THEN REWRITE_TAC[ARITH_RULE`0 MOD 3=0/\ 1 MOD 3=1/\ 2 MOD 3=2`] THEN STRIP_TAC THEN MRESA_TAC (GEN_ALL Local_lemmas.LOCAL_FAN_CHARACTER_OF_RHO_NODE2) [`e_prime (E UNION {{u, w}}) (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u))`; `v_prime V (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u))`; `face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u)`;`(vv:num->real^3) (0 + p MOD k)`]THEN POP_ASSUM MP_TAC THEN REWRITE_TAC[ARITH_RULE`0 MOD 3=0/\ 1 MOD 3=1/\ 2 MOD 3=2`] THEN ONCE_REWRITE_TAC[SET_RULE`{A,B,C}={A,C,B}`] THEN STRIP_TAC THEN MRESA_TAC (GEN_ALL Local_lemmas.AZIM_LE_PI_EQ_DIHV)[`vec 0:real^3`;`(vv:num->real^3) (1 + p MOD k)`;`(vv:num->real^3) (2 + p MOD k)`;`(vv:num->real^3) (0 + p MOD k)`] ; (************) POP_ASSUM MP_TAC THEN SUBGOAL_THEN`vv (0 + p MOD k) IN v_prime V (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u))` ASSUME_TAC; REPLICATE_TAC (33-26)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN REWRITE_TAC[SYM th;IN_ELIM_THM;IMAGE]) THEN EXISTS_TAC`0` THEN REWRITE_TAC[SET_RULE`(a:num)IN(:num)`;ARITH_RULE`0 MOD 3=0/\ 1 MOD 3=1/\ 2 MOD 3=2`]; SUBGOAL_THEN`vv (1 + p MOD k) IN v_prime V (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u))` ASSUME_TAC; REPLICATE_TAC (34-26)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN REWRITE_TAC[SYM th;IN_ELIM_THM;IMAGE]) THEN EXISTS_TAC`1` THEN REWRITE_TAC[SET_RULE`(a:num)IN(:num)`;ARITH_RULE`0 MOD 3=0/\ 1 MOD 3=1/\ 2 MOD 3=2`]; SUBGOAL_THEN`vv (2 + p MOD k) IN v_prime V (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u))` ASSUME_TAC; REPLICATE_TAC (35-26)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN REWRITE_TAC[SYM th;IN_ELIM_THM;IMAGE]) THEN EXISTS_TAC`2` THEN REWRITE_TAC[SET_RULE`(a:num)IN(:num)`;ARITH_RULE`0 MOD 3=0/\ 1 MOD 3=1/\ 2 MOD 3=2`]; REPLICATE_TAC (3)(POP_ASSUM MP_TAC) THEN REPLICATE_TAC (4) RESA_TAC THEN POP_ASSUM(fun th-> MRESA1_TAC th`(vv:num->real^3) (2 + p MOD k)`) THEN SUBGOAL_THEN`(rho_node1 {(vv (0 MOD 3 + p MOD k),vv (1 MOD 3 + p MOD k)), (vv (1 MOD 3 + p MOD k), vv (2 MOD 3 + p MOD k)), (vv (2 MOD 3 + p MOD k), vv (0 MOD 3 + p MOD k))} (vv (2 + p MOD k))) = (vv:num->real^3) (0 MOD 3 + p MOD k)`ASSUME_TAC ; MATCH_MP_TAC (GEN_ALL Local_lemmas.DETER_RHO_NODE) THEN EXISTS_TAC`v_prime V (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u))` THEN EXISTS_TAC`e_prime (E UNION {{u, w}}) (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u))` THEN ASM_REWRITE_TAC[] THEN REPLICATE_TAC (37-25)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT DISCH_TAC THEN MP_TAC th THEN ASM_REWRITE_TAC[convex_local_fan] THEN RESA_TAC) THEN REWRITE_TAC[SET_RULE`a IN {a1,b,c} <=> a=a1\/ a=b\/ a=c`;ARITH_RULE`0 MOD 3=0/\ 1 MOD 3=1/\ 2 MOD 3=2`] ; ASM_REWRITE_TAC[] THEN SUBGOAL_THEN`(ivs_rho_node1 {(vv (0 MOD 3 + p MOD k),vv (1 MOD 3 + p MOD k)), (vv (1 MOD 3 + p MOD k), vv (2 MOD 3 + p MOD k)), (vv (2 MOD 3 + p MOD k), vv (0 MOD 3 + p MOD k))} (vv (2 + p MOD k))) = (vv:num->real^3) (1 MOD 3 + p MOD k)`ASSUME_TAC ; MATCH_MP_TAC (GEN_ALL Local_lemmas.IVS_RHO_NODE1_DETE) THEN EXISTS_TAC`v_prime V (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u))` THEN EXISTS_TAC`e_prime (E UNION {{u, w}}) (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u))` THEN ASM_REWRITE_TAC[] THEN REPLICATE_TAC (38-25)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT DISCH_TAC THEN MP_TAC th THEN ASM_REWRITE_TAC[convex_local_fan] THEN RESA_TAC) THEN REWRITE_TAC[SET_RULE`a IN {a1,b,c} <=> a=a1\/ a=b\/ a=c`;ARITH_RULE`0 MOD 3=0/\ 1 MOD 3=1/\ 2 MOD 3=2`] ; SUBGOAL_THEN`(rho_node1 {(vv (0 MOD 3 + p MOD k),vv (1 MOD 3 + p MOD k)), (vv (1 MOD 3 + p MOD k), vv (2 MOD 3 + p MOD k)), (vv (2 MOD 3 + p MOD k), vv (0 MOD 3 + p MOD k))} (vv (1 + p MOD k))) = (vv:num->real^3) (2 MOD 3 + p MOD k)`ASSUME_TAC ; MATCH_MP_TAC (GEN_ALL Local_lemmas.DETER_RHO_NODE) THEN EXISTS_TAC`v_prime V (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u))` THEN EXISTS_TAC`e_prime (E UNION {{u, w}}) (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u))` THEN ASM_REWRITE_TAC[] THEN REPLICATE_TAC (39-25)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT DISCH_TAC THEN MP_TAC th THEN ASM_REWRITE_TAC[convex_local_fan] THEN RESA_TAC) THEN REWRITE_TAC[SET_RULE`a IN {a1,b,c} <=> a=a1\/ a=b\/ a=c`;ARITH_RULE`0 MOD 3=0/\ 1 MOD 3=1/\ 2 MOD 3=2`] ; ASM_REWRITE_TAC[ARITH_RULE`0 MOD 3=0/\ 1 MOD 3=1/\ 2 MOD 3=2`] THEN MRESA_TAC (GEN_ALL Local_lemmas.IN_V_IMP_AZIM_LESS_PI)[`e_prime (E UNION {{u, w}}) (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u))`; `v_prime V (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u))`; `face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u)`;`(vv:num->real^3) (2 + p MOD k)`] THEN POP_ASSUM(fun th-> MRESA1_TAC th`(vv:num->real^3) (1 + p MOD k)`) THEN POP_ASSUM MP_TAC THEN REWRITE_TAC[ARITH_RULE`0 MOD 3=0/\ 1 MOD 3=1/\ 2 MOD 3=2`] THEN STRIP_TAC THEN SUBGOAL_THEN` local_fan (v_prime V (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u)), e_prime (E UNION {{u, w}}) (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u)), face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u)) `ASSUME_TAC ; ASM_TAC THEN REWRITE_TAC[convex_local_fan] THEN REPEAT RESA_TAC ; MRESA_TAC (GEN_ALL Local_lemmas.LOCAL_FAN_CHARACTER_OF_RHO_NODE2) [`e_prime (E UNION {{u, w}}) (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u))`; `v_prime V (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u))`; `face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u)`;`(vv:num->real^3) (2 + p MOD k)`] THEN POP_ASSUM MP_TAC THEN REWRITE_TAC[ARITH_RULE`0 MOD 3=0/\ 1 MOD 3=1/\ 2 MOD 3=2`] THEN STRIP_TAC THEN MRESA_TAC (GEN_ALL Local_lemmas.LOCAL_FAN_CHARACTER_OF_RHO_NODE2) [`e_prime (E UNION {{u, w}}) (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u))`; `v_prime V (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u))`; `face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u)`;`(vv:num->real^3) (1 + p MOD k)`]THEN POP_ASSUM MP_TAC THEN REWRITE_TAC[ARITH_RULE`0 MOD 3=0/\ 1 MOD 3=1/\ 2 MOD 3=2`] THEN ONCE_REWRITE_TAC[SET_RULE`{A,B,C}={A,C,B}`] THEN STRIP_TAC THEN MRESA_TAC (GEN_ALL Local_lemmas.AZIM_LE_PI_EQ_DIHV)[`vec 0:real^3`;`(vv:num->real^3) (2 + p MOD k)`;`(vv:num->real^3) (0 + p MOD k)`;`(vv:num->real^3) (1 + p MOD k)`] ;]);;
let CARD_FF_EQ_CARD_SLICE_FF= 
prove_by_refinement( `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) ==> CARD FF = CARD fv + CARD fw -2`,
[ STRIP_TAC THEN MP_TAC Local_lemmas1.PROVE_THE_SLICE_ASSUMPTION THEN RESA_TAC THEN POP_ASSUM(fun th-> MRESA_TAC th[`v:real^3`;`w:real^3`]) THEN POP_ASSUM MP_TAC THEN REWRITE_TAC[DIFF;IN_ELIM_THM;IN_SING] THEN ONCE_REWRITE_TAC[SET_RULE`~(a=b)<=> ~(b=a)`] THEN STRIP_TAC THEN MP_TAC Nkezbfc_local.COMPATIBLE_BW_TWO_LEMMAS THEN RESA_TAC THEN SUBGOAL_THEN`{{w, v}} = {{v,w:real^3}}` ASSUME_TAC; REWRITE_TAC[EXTENSION;IN_SING] THEN SET_TAC[]; MRESA_TAC (GEN_ALL Nkezbfc_local.COMPATIBLE_BW_TWO_LEMMAS) [`hypermap (HYP (vec 0,V,(E:(real^3->bool)->bool) UNION {{v, w}}))`;`V:real^3->bool`;`face (hypermap (HYP (vec 0,V,(E:(real^3->bool)->bool) UNION {{v, w}}))) (w,rho_node1 FF w)`;`(E:(real^3->bool)->bool)`;`FF:real^3#real^3->bool`;`w:real^3`;`v:real^3`;] THEN POP_ASSUM MP_TAC THEN ONCE_REWRITE_TAC[SET_RULE`~(a=b)<=> ~(b=a)`] THEN ONCE_REWRITE_TAC[SET_RULE`{a,b}={b,a}`] THEN ASM_REWRITE_TAC[] THEN ONCE_REWRITE_TAC[SET_RULE`{a,b}={b,a}`] THEN RESA_TAC THEN MRESA_TAC CARD_SLICE_EQ[`V:real^3->bool`;`(E:(real^3->bool)->bool)`;`FF:real^3#real^3->bool`;`v:real^3`;`w:real^3`;] THEN MP_TAC Local_lemmas1.EJRCFJD THEN RESA_TAC THEN MRESA_TAC (GEN_ALL Local_lemmas.LOFA_IMP_CARD_FF_V_EQ) [`E:(real^3->bool)->bool`;`FF:real^3#real^3->bool`;`V:real^3->bool`] THEN MRESA_TAC (GEN_ALL Local_lemmas.LOFA_IMP_CARD_FF_V_EQ) [`e_prime (E UNION {{v, w}}) (face (hypermap (HYP (vec 0,V,E UNION {{v, w}}))) (w,rho_node1 FF w))`;`face (hypermap (HYP (vec 0,V,E UNION {{v, w}}))) (w,rho_node1 FF w)`;`v_prime V (face (hypermap (HYP (vec 0,V,E UNION {{v, w}}))) (w,rho_node1 FF w))`] THEN MRESA_TAC (GEN_ALL Local_lemmas.LOFA_IMP_CARD_FF_V_EQ) [`e_prime (E UNION {{v, w}}) (face (hypermap (HYP (vec 0,V,E UNION {{v, w}}))) (v,rho_node1 FF v))`;`face (hypermap (HYP (vec 0,V,E UNION {{v, w}}))) (v,rho_node1 FF v)`;`v_prime V (face (hypermap (HYP (vec 0,V,E UNION {{v, w}}))) (v,rho_node1 FF v))`] THEN ASM_TAC THEN REWRITE_TAC[convex_local_fan] THEN REPEAT RESA_TAC THEN REPLICATE_TAC (25-16)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[th] THEN MP_TAC th THEN REPEAT RESA_TAC) THEN REPLICATE_TAC (25-13)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[th] THEN MP_TAC th THEN REPEAT RESA_TAC)]);;
let CARD_SLICE_FF_LE_3= 
prove_by_refinement( `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) ==> 3<= CARD fv /\ 3<= CARD fw`,
[ STRIP_TAC THEN MP_TAC Local_lemmas1.PROVE_THE_SLICE_ASSUMPTION THEN RESA_TAC THEN POP_ASSUM(fun th-> MRESA_TAC th[`v:real^3`;`w:real^3`]) THEN POP_ASSUM MP_TAC THEN REWRITE_TAC[DIFF;IN_ELIM_THM;IN_SING] THEN ONCE_REWRITE_TAC[SET_RULE`~(a=b)<=> ~(b=a)`] THEN STRIP_TAC THEN MP_TAC Nkezbfc_local.COMPATIBLE_BW_TWO_LEMMAS THEN RESA_TAC THEN SUBGOAL_THEN`{{w, v}} = {{v,w:real^3}}` ASSUME_TAC; REWRITE_TAC[EXTENSION;IN_SING] THEN SET_TAC[]; MRESA_TAC (GEN_ALL Nkezbfc_local.COMPATIBLE_BW_TWO_LEMMAS) [`hypermap (HYP (vec 0,V,(E:(real^3->bool)->bool) UNION {{v, w}}))`;`V:real^3->bool`;`face (hypermap (HYP (vec 0,V,(E:(real^3->bool)->bool) UNION {{v, w}}))) (w,rho_node1 FF w)`;`(E:(real^3->bool)->bool)`;`FF:real^3#real^3->bool`;`w:real^3`;`v:real^3`;] THEN POP_ASSUM MP_TAC THEN ONCE_REWRITE_TAC[SET_RULE`~(a=b)<=> ~(b=a)`] THEN ONCE_REWRITE_TAC[SET_RULE`{a,b}={b,a}`] THEN ASM_REWRITE_TAC[] THEN ONCE_REWRITE_TAC[SET_RULE`{a,b}={b,a}`] THEN RESA_TAC THEN MRESA_TAC CARD_SLICE_EQ[`V:real^3->bool`;`(E:(real^3->bool)->bool)`;`FF:real^3#real^3->bool`;`v:real^3`;`w:real^3`;] THEN MP_TAC Local_lemmas1.EJRCFJD THEN RESA_TAC THEN MRESA_TAC (GEN_ALL Local_lemmas.LOFA_IMP_CARD_FF_V_EQ) [`E:(real^3->bool)->bool`;`FF:real^3#real^3->bool`;`V:real^3->bool`] THEN MRESA_TAC (GEN_ALL Local_lemmas.LOFA_IMP_CARD_FF_V_EQ) [`e_prime (E UNION {{v, w}}) (face (hypermap (HYP (vec 0,V,E UNION {{v, w}}))) (w,rho_node1 FF w))`;`face (hypermap (HYP (vec 0,V,E UNION {{v, w}}))) (w,rho_node1 FF w)`;`v_prime V (face (hypermap (HYP (vec 0,V,E UNION {{v, w}}))) (w,rho_node1 FF w))`] THEN MRESA_TAC (GEN_ALL Local_lemmas.LOFA_IMP_CARD_FF_V_EQ) [`e_prime (E UNION {{v, w}}) (face (hypermap (HYP (vec 0,V,E UNION {{v, w}}))) (v,rho_node1 FF v))`;`face (hypermap (HYP (vec 0,V,E UNION {{v, w}}))) (v,rho_node1 FF v)`;`v_prime V (face (hypermap (HYP (vec 0,V,E UNION {{v, w}}))) (v,rho_node1 FF v))`] THEN ASM_TAC THEN REWRITE_TAC[convex_local_fan] THEN REPEAT RESA_TAC THEN REPLICATE_TAC (25-16)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[th] THEN MP_TAC th THEN REPEAT RESA_TAC) THEN REPLICATE_TAC (25-13)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> ASM_TAC THEN REWRITE_TAC[th] THEN MP_TAC th THEN REPEAT RESA_TAC) THEN MRESA_TAC (GEN_ALL Nkezbfc_local.CARD_VERTEX_GE_3_LOCAL_FAN) [`slicev (E:(real^3->bool)->bool) FF w v`;`slicee (E:(real^3->bool)->bool) FF w v`;`slicef (E:(real^3->bool)->bool) FF w v`] THEN POP_ASSUM MP_TAC THEN MRESA_TAC (GEN_ALL Nkezbfc_local.CARD_VERTEX_GE_3_LOCAL_FAN) [`slicev (E:(real^3->bool)->bool) FF v w`;`slicee (E:(real^3->bool)->bool) FF v w`;`slicef (E:(real^3->bool)->bool) FF v w`] THEN POP_ASSUM MP_TAC THEN REWRITE_TAC[convex_local_fan] THEN RESA_TAC;]);;
let CARD_FF_EQ_SCS_K_3=
prove( ` scs_k_v39 s =k /\ IMAGE (\i. vv i,vv (SUC i)) (:num)=FF/\ is_scs_v39 s /\ k=3 /\ BBs_v39 s vv ==> CARD FF=3`,
REPEAT STRIP_TAC THEN MRESAL_TAC (GEN_ALL(INST_TYPE [`:3`,`:M`]V_E_FF_IS_SCS_CASES_3))[`s:scs_v39`;`vv:num->real^3`] [DIMINDEX_3] THEN MP_TAC VV_INJ THEN RESA_TAC THEN POP_ASSUM(fun th-> MRESAL_TAC th[`1`;`2`][ARITH_RULE`~(1=2)/\ ~(1=0) /\ ~(1=3)/\ ~(2=3)/\ ~(2=0)/\ ~(3=0)/\ 0<3/\ 1<3/\ 2<3/\ 3<4`] THEN MRESAL_TAC th[`1`;`0`][ARITH_RULE`~(1=2)/\ ~(1=0) /\ ~(1=3)/\ ~(2=3)/\ ~(2=0)/\ ~(3=0)/\ 0<3/\ 1<3/\ 2<3/\ 3<4`] THEN MRESAL_TAC th[`2`;`0`][ARITH_RULE`~(1=2)/\ ~(1=0) /\ ~(1=3)/\ ~(2=3)/\ ~(2=0)/\ ~(3=0)/\ 0<3/\ 1<3/\ 2<3/\ 3<4`]) THEN SIMP_TAC[HAS_SIZE; CARD_CLAUSES; FINITE_INSERT; FINITE_EMPTY; IN_INSERT; NOT_IN_EMPTY;PAIR_EQ] THEN ASM_REWRITE_TAC[] THEN ARITH_TAC);;
let QKNVMLB3_LE4=
prove_by_refinement( `~(scs_k_v39 s =4 /\ ~(scs_J_v39 s' 0 (scs_k_v39 s' - 1)))/\ scs_half_slice_v39 s p q d' mkj =s'/\ scs_half_slice_v39 s q p d'' mkj =s'' /\ vv' = (\i. (vv:num->real^3) (i MOD (scs_k_v39 s')+p MOD (scs_k_v39 s))) /\ vv'' = (\i. (vv:num->real^3) (i MOD (scs_k_v39 s'')+q MOD (scs_k_v39 s))) /\ MMs_v39 s vv /\ is_scs_v39 s /\ scs_diag (scs_k_v39 s) p q /\ is_scs_slice_v39 s s' s'' p q /\ scs_d_v39 s <= d' + d'' ==> taustar_v39 s' vv' + taustar_v39 s'' vv'' <= taustar_v39 s vv`,
[REWRITE_TAC[taustar_v39;LET_DEF;LET_END_DEF;scs_diag] THEN STRIP_TAC THEN MP_TAC SCS_K_PRIME_CASE_3 THEN REWRITE_TAC[taustar_v39;LET_DEF;LET_END_DEF;scs_diag] THEN RESA_TAC THEN ABBREV_TAC`k=scs_k_v39 s` THEN ABBREV_TAC`k'=scs_k_v39 s'` THEN ABBREV_TAC`k''=scs_k_v39 s''` THEN MP_TAC(ARITH_RULE`3<k==> ~(k<=3)`) THEN RESA_TAC THEN MP_TAC SCS_K_LE_6 THEN RESA_TAC THEN ABBREV_TAC`u= (vv:num->real^3) (p MOD k)` THEN ABBREV_TAC `w= (vv:num->real^3) (q MOD k)` THEN ABBREV_TAC`V= IMAGE (vv:num->real^3) (:num)` THEN ABBREV_TAC`E= IMAGE (\i. {vv i,(vv:num->real^3) (SUC i)}) (:num)` THEN ABBREV_TAC`FF= IMAGE (\i. (vv i,(vv:num->real^3) (SUC i))) (:num)` THEN MRESA_TAC (GEN_ALL IN_IMAGE_VV)[`p MOD scs_k_v39 s`;`vv:num->real^3`] THEN MRESA_TAC (GEN_ALL IN_IMAGE_VV)[`q MOD scs_k_v39 s`;`vv:num->real^3`] THEN ASM_TAC THEN REPLICATE_TAC 2 STRIP_TAC THEN ASM_REWRITE_TAC[MMs_v39;BBprime_v39;BBprime2_v39;is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist] THEN REPEAT RESA_TAC ; REPLICATE_TAC (54-8)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th) THEN ASM_REWRITE_TAC[]; REPLICATE_TAC (54-8)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th) THEN ASM_REWRITE_TAC[] THEN STRIP_TAC THEN SUBGOAL_THEN`(!i. scs_b_v39 s i (SUC i) <= cstab)`ASSUME_TAC; REPLICATE_TAC (54-32)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MATCH_MP_TAC th) THEN ASM_REWRITE_TAC[]; REPLICATE_TAC (55-8)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th THEN ASM_REWRITE_TAC[ARITH_RULE`SUC(3-1)=3`]) THEN STRIP_TAC THEN MP_TAC NOT_EQ_DIAG THEN MP_TAC DIST_DIAG_LE_CSTAB THEN MP_TAC CARD_V_EQ_SCS_K THEN ASM_REWRITE_TAC[MMs_v39;BBprime_v39;BBprime2_v39;is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist] THEN STRIP_TAC THEN REPEAT RESA_TAC THEN MP_TAC TECOXBMv2 THEN ASM_REWRITE_TAC[is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist;tau_fun] THEN STRIP_TAC THEN MRESA_TAC(GEN_ALL Local_lemmas1.EJRCFJD)[`hypermap (HYP (vec 0,V,(E:(real^3->bool)->bool) UNION {{u, w}}))`;`(E:(real^3->bool)->bool)`;`w:real^3`;`face (hypermap (HYP (vec 0,V,(E:(real^3->bool)->bool) UNION {{u, w}}))) (u,rho_node1 FF u)`;`V:real^3->bool`;`face (hypermap (HYP (vec 0,V,(E:(real^3->bool)->bool) UNION {{u, w}}))) (w,rho_node1 FF w)`;`FF:real^3#real^3->bool`;`u:real^3`] THEN POP_ASSUM MP_TAC THEN MP_TAC V_PRIME_EQ_V_vv THEN ASM_REWRITE_TAC[is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist;scs_half_slice_v39] THEN STRIP_TAC THEN POP_ASSUM(fun th-> ASSUME_TAC(SYM th)) THEN MRESA_TAC (GEN_ALL V_PRIME_EQ_V_vv) [`d'':real`;`d':real`;`mkj:bool`;`s':scs_v39`;`s'':scs_v39`;`p:num`;`s:scs_v39`; `vv:num->real^3`;`k'':num`;`q:num`;`k:num`;`V:real^3->bool`;`E:(real^3->bool)->bool`;`u:real^3`;`FF:real^3#real^3->bool`;`w:real^3`] THEN POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist;scs_half_slice_v39;] THEN ONCE_REWRITE_TAC[VECTOR_ARITH`u-w= --(w-u):real^3`] THEN ASM_REWRITE_TAC[NORM_NEG] THEN SUBGOAL_THEN`{{w, u}} = {{u,w:real^3}}` ASSUME_TAC ; REWRITE_TAC[EXTENSION;IN_SING] THEN SET_TAC[]; RESA_TAC THEN POP_ASSUM(fun th-> ASSUME_TAC(SYM th)) THEN RESA_TAC THEN POP_ASSUM(fun th-> MRESA1_TAC th`(\i. rho_fun (norm ((vv:num->real^3) (i+ p MOD k))))`) THEN SUBGOAL_THEN` sum {i | i < k} (\i. rho_fun (norm ((vv:num->real^3) (i+p MOD k))) * interior_angle1 (vec 0) FF (ITER i (rho_node1 FF) u)) =sum FF (\e. rho_fun (norm (FST e)) * azim_in_fan e E) `ASSUME_TAC ; MATCH_MP_TAC SUM_EQ_GENERAL THEN EXISTS_TAC`(\i. (vv:num->real^3) (i+ p MOD k), vv (SUC i + p MOD k))` THEN SUBGOAL_THEN` (q+1+k -p MOD k)MOD k =scs_k_v39 s'` ASSUME_TAC; EXPAND_TAC"s'" THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist;periodic2;scs_half_slice_v39] THEN ASM_REWRITE_TAC[] ; MRESA_TAC (GEN_ALL SCS_K_PRIME_LE_GE)[`s:scs_v39`;`p:num`;`q:num`;`d':real`;`scs_J_v39 s' p q`] THEN POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;scs_half_slice_v39;PAIR_EQ;REAL_ARITH`#0.11 < #0.9`;ARITH_RULE`3<=3`] THEN STRIP_TAC THEN MP_TAC(ARITH_RULE`3<= k' /\ k'<k ==> 0<k' /\ ~(k=0) /\ k'-1<k'/\ 1<k`) THEN RESA_TAC THEN STRIP_TAC ; EXPAND_TAC"FF" THEN REWRITE_TAC[IN_ELIM_THM; IMAGE;EXISTS_UNIQUE] THEN ASM_REWRITE_TAC[PAIR_EQ] THEN REPEAT RESA_TAC THEN EXISTS_TAC`(x MOD k + k -p MOD k) MOD k` THEN ASM_REWRITE_TAC[ARITH_RULE`A-0=A`;PAIR_EQ] THEN MRESA_TAC DIVISION[`x MOD k + k - p MOD k:num`;`k:num`] THEN MRESA_TAC DIVISION[`p:num`;`k:num`] THEN MRESA_TAC MOD_LT[`p MOD k`;`k:num`] THEN MRESA_TAC MOD_MOD_REFL[`x:num`;`k:num`] THEN MRESAL_TAC MOD_MULT_ADD[`1`;`k:num`;`x MOD k`][ARITH_RULE`1 * k + x MOD k = x MOD k +k`] THEN MRESA_TAC MOD_ADD_MOD[`x MOD k + k - p MOD k:num`;`p MOD k:num`;`k:num`] THEN MP_TAC(ARITH_RULE`1<k/\ p MOD k<k ==>(x MOD k+ k- p MOD k) + p MOD k = x MOD k+k /\ (x + p MOD k) + k- p MOD k= x+k`) THEN RESA_TAC THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`vv:num->real^3`][ARITH_RULE`~(4=0)`;] THEN POP_ASSUM(fun th-> MRESA1_TAC th `(x MOD k + k - p MOD k) MOD k + p MOD k:num` THEN MRESA1_TAC th ` x:num`) THEN MRESA_TAC MOD_ADD_MOD[`x:num`;`1`;`k:num`] THEN MRESA_TAC MOD_ADD_MOD[`(x MOD k + k - p MOD k) MOD k + p MOD k`;`1`;`k:num`] THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`vv:num->real^3`][ARITH_RULE`~(4=0)`;ARITH_RULE`SUC ((x MOD k + k - p MOD k) MOD k) + p MOD k = ((x MOD k + k - p MOD k) MOD k + p MOD k)+1`] THEN POP_ASSUM(fun th-> MRESA1_TAC th `((x MOD k + k - p MOD k) MOD k + p MOD k)+1:num` THEN MRESA1_TAC th ` x+1:num`) THEN REWRITE_TAC[ADD1] THEN REPEAT STRIP_TAC THEN MRESA_TAC DIVISION[`x:num`;`k:num`] THEN MRESA_TAC DIVISION[`y' + p MOD k:num`;`k:num`] THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`vv:num->real^3`][ARITH_RULE`~(4=0)`;] THEN POP_ASSUM(fun th-> MRESA1_TAC th `y' + p MOD k:num`) THEN MP_TAC VV_INJ THEN ASM_REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;scs_half_slice_v39;PAIR_EQ;REAL_ARITH`#0.11 < #0.9`;ARITH_RULE`3<=3`;dist] THEN STRIP_TAC THEN POP_ASSUM(fun th-> MRESA_TAC th[`(y'+ p MOD k) MOD k:num`;`(x MOD k + k)MOD k`]) THEN MRESA_TAC MOD_LT[`y':num`;`k:num`] THEN MRESAL_TAC(GEN_ALL Hdplygy.MOD_EQ_MOD)[`y':num`;`x MOD k + k- p MOD k`;`p MOD k`;`k:num`][] THEN POP_ASSUM MP_TAC THEN ONCE_REWRITE_TAC[ADD_SYM] THEN RESA_TAC ; REWRITE_TAC[IN_ELIM_THM;] THEN REPEAT STRIP_TAC; EXPAND_TAC"FF" THEN REWRITE_TAC[IMAGE;IN_ELIM_THM] THEN EXISTS_TAC`x+ p MOD k` THEN REWRITE_TAC[SET_RULE`(a:num)IN (:num)`;ADD1;ARITH_RULE`(x + 1) + p MOD k= (x + p MOD k)+1`] ; MRESAL_TAC(GEN_ALL VV_SUC_EQ_RHO_NODE)[`scs_k_v39 s`;`V:real^3->bool`;`E:(real^3->bool)->bool`;`p:num`;`q:num`;`s:scs_v39`;`FF:real^3#real^3->bool`;`u:real^3`;`vv:num->real^3`;`p:num MOD k`] [is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist] THEN SUBGOAL_THEN`(vv:num->real^3) (x + p MOD k) IN V`ASSUME_TAC ; EXPAND_TAC"V" THEN REWRITE_TAC[IN_ELIM_THM;IMAGE] THEN EXISTS_TAC`x+ p MOD k` THEN REWRITE_TAC[SET_RULE`(a:num)IN (:num)`]; MP_TAC Nkezbfc_local.CONVEX_LOFA_IMP_INANGLE_EQ_AZIM THEN RESA_TAC THEN POP_ASSUM(fun th-> MRESA_TAC th[`(vv:num->real^3) (x + p MOD k )`]) THEN REMOVE_ASSUM_TAC THEN REMOVE_ASSUM_TAC THEN POP_ASSUM(fun th-> ASSUME_TAC th THEN MRESAL1_TAC th`SUC x`[ITER]) ; POP_ASSUM(fun th-> ASM_REWRITE_TAC[SYM th]) THEN MP_TAC F_PRIME_EQ_F_vv THEN ASM_REWRITE_TAC[is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist;scs_half_slice_v39] THEN STRIP_TAC THEN POP_ASSUM(fun th-> ASM_REWRITE_TAC[th]) THEN MRESAL_TAC (GEN_ALL F_PRIME_EQ_F_vv)[`d'':real`;`d':real`;`mkj:bool`;`s':scs_v39`;`s'':scs_v39`;`p:num`;`s:scs_v39`;`vv:num->real^3`;`k'':num`;`q:num`;`k:num`;`V:real^3->bool`;`E:(real^3->bool)->bool`;`u:real^3`;`FF:real^3#real^3->bool`;`w:real^3`] [is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist;scs_half_slice_v39] THEN POP_ASSUM MP_TAC THEN ONCE_REWRITE_TAC[VECTOR_ARITH`u-w= --(w-u):real^3`] THEN ASM_REWRITE_TAC[NORM_NEG] THEN STRIP_TAC THEN POP_ASSUM(fun th-> ASM_REWRITE_TAC[th]) THEN MP_TAC V_SLICE_EQ_NUMSEG THEN ASM_REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist;scs_half_slice_v39] THEN RESA_TAC THEN MP_TAC SCS_SLICE_SYM THEN ASM_REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist;scs_half_slice_v39;] THEN STRIP_TAC THEN MRESAL_TAC(GEN_ALL V_SLICE_EQ_NUMSEG)[ `d'':real`;`mkj:bool`;`s:scs_v39`;`s'':scs_v39`;`s':scs_v39`;`p:num`;`FF:real^3#real^3->bool`;`w:real^3`;`vv:num->real^3`;`q:num`;`k:num`;`k'':num`] [MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist;scs_half_slice_v39;] THEN SUBGOAL_THEN`sum {i | i < k /\ ITER i (rho_node1 FF) u IN IMAGE (\i. vv (i MOD k'' + q MOD k)) (:num)} (\i. rho_fun (norm ((vv:num->real^3) (i + p MOD k))) * interior_angle1 (vec 0) (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (w,rho_node1 FF w)) (ITER i (rho_node1 FF) u)) = sum {i | i < k /\ ITER i (rho_node1 FF) w IN IMAGE (\i. vv (i MOD k'' + q MOD k)) (:num)} (\i. rho_fun (norm (vv (i + q MOD k))) * interior_angle1 (vec 0) (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (w,rho_node1 FF w)) (ITER i (rho_node1 FF) w))` ASSUME_TAC ; MATCH_MP_TAC SUM_EQ_GENERAL THEN MRESAL_TAC(GEN_ALL VV_SUC_EQ_RHO_NODE)[`scs_k_v39 s`;`V:real^3->bool`;`E:(real^3->bool)->bool`;`p:num`;`q:num`;`s:scs_v39`;`FF:real^3#real^3->bool`;`u:real^3`;`vv:num->real^3`;`p:num MOD k`] [is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist] THEN MRESAL_TAC(GEN_ALL VV_SUC_EQ_RHO_NODE)[`scs_k_v39 s`;`V:real^3->bool`;`E:(real^3->bool)->bool`;`p:num`;`q:num`;`s:scs_v39`;`FF:real^3#real^3->bool`;`w:real^3`;`vv:num->real^3`;`q:num MOD k`] [is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist] THEN MP_TAC SCS_K_PRIME_LE_GE THEN ASM_REWRITE_TAC[is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist] THEN STRIP_TAC THEN SUBGOAL_THEN` (p+1+k -q MOD k)MOD k =scs_k_v39 s''` ASSUME_TAC; EXPAND_TAC"s''" THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist;periodic2;scs_half_slice_v39] THEN ASM_REWRITE_TAC[] ; MRESAL_TAC (GEN_ALL SCS_K_PRIME_LE_GE)[`s:scs_v39`;`q:num`;`p:num`;`d'':real`;`scs_J_v39 s' p q`] [is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist;scs_half_slice_v39;IN_ELIM_THM;IMAGE] THEN MP_TAC(ARITH_RULE`3<=k'/\ k'<k ==> ~(k=0)`) THEN RESA_TAC THEN MP_TAC(ARITH_RULE`p MOD k<= q MOD k \/ q MOD k<= p MOD k`) THEN RESA_TAC; EXISTS_TAC`(\i. (i+ p MOD k + k - q MOD k) MOD k)` THEN STRIP_TAC; REWRITE_TAC[IN_ELIM_THM; IMAGE;EXISTS_UNIQUE] THEN REPEAT STRIP_TAC THEN EXISTS_TAC`(y + q MOD k - p MOD k) MOD k ` THEN MRESA_TAC DIVISION[`q:num`;`k:num`] THEN MRESA_TAC DIVISION[`p:num`;`k:num`] THEN MRESA_TAC DIVISION[`y + q MOD k - p MOD k:num`;`k:num`] THEN MP_TAC(ARITH_RULE`y<k'' /\ k''<k/\ q MOD k<k /\ p MOD k<= q MOD k /\ ~(p MOD k = q MOD k) ==> y<k:num /\ p MOD k + k - q MOD k =k -(q MOD k - p MOD k) /\ k- (q MOD k - p MOD k)<k /\ (y + q MOD k - p MOD k) + k - (q MOD k - p MOD k) = y+ k/\ (y + q MOD k - p MOD k) + p MOD k= y + q MOD k `) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`y:num`;`k'':num`] THEN MRESA_TAC MOD_LT[`y:num`;`k:num`] THEN MRESA_TAC MOD_LT[`p MOD k:num`;`k:num`] THEN MRESA_TAC MOD_LT[`k-(q MOD k- p MOD k):num`;`k:num`] THEN MRESA_TAC MOD_ADD_MOD[`y + q MOD k- p MOD k`;`k -(q MOD k - p MOD k)`;`k:num`] THEN MRESA_TAC MOD_ADD_MOD[`y + q MOD k- p MOD k`;`(p MOD k)`;`k:num`] THEN MRESAL_TAC MOD_MULT_ADD[`1:num`;`k:num`;`y:num`][ARITH_RULE`1 * k' + i = (i+k')`] THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`vv:num->real^3`][ARITH_RULE`~(4=0)`;] THEN POP_ASSUM(fun th-> MRESA1_TAC th `(y + q MOD k - p MOD k) MOD k + p MOD k:num` THEN MRESA1_TAC th`y+ q MOD k`) THEN STRIP_TAC ; EXISTS_TAC`y:num` THEN ASM_REWRITE_TAC[SET_RULE`(a:num)IN(:num)`] ; REPEAT STRIP_TAC THEN POP_ASSUM (fun th-> ASM_REWRITE_TAC[SYM th]) THEN MP_TAC(ARITH_RULE`y<k'' /\ k''<k/\ q MOD k<k /\ p MOD k<= q MOD k /\ ~(p MOD k = q MOD k) ==> (y' + k - (q MOD k - p MOD k)) + q MOD k - p MOD k = y'+k /\ q MOD k - p MOD k < k`) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`q MOD k - p MOD k`;`k:num`] THEN MRESA_TAC MOD_ADD_MOD[`y' + k - (q MOD k - p MOD k)`;`q MOD k - p MOD k`;`k:num`] THEN MRESAL_TAC MOD_MULT_ADD[`1:num`;`k:num`;`y':num`][ARITH_RULE`1 * k' + i = (i+k')`] THEN MRESA_TAC MOD_LT[`y':num`;`k:num`] ; REPEAT RESA_TAC ; MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`vv:num->real^3`][ARITH_RULE`~(4=0)`;] THEN POP_ASSUM(fun th-> MRESA1_TAC th `(x + p MOD k):num` THEN MRESA1_TAC th`x' MOD k''+ q MOD k`) THEN MP_TAC(ARITH_RULE`3<= k'' ==> ~(k''=0)`) THEN RESA_TAC THEN MRESA_TAC DIVISION[`q:num`;`k:num`] THEN MRESA_TAC DIVISION[`x':num`;`k'':num`] THEN MRESA_TAC DIVISION[`x +p MOD k`;`k:num`] THEN MRESA_TAC DIVISION[`x' MOD k'' +q MOD k`;`k:num`] THEN MP_TAC(ARITH_RULE`p MOD k<= q MOD k /\ q MOD k < k/\ x' MOD k''<k'' /\ k''<k ==> p MOD k + x' MOD k''+ q MOD k - p MOD k = q MOD k +x' MOD k'' /\ (p MOD k + k - q MOD k) + q MOD k - p MOD k + x' MOD k'' = k + x' MOD k'' /\ x' MOD k'' < k`) THEN RESA_TAC THEN MP_TAC VV_INJ THEN ASM_REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;scs_half_slice_v39;PAIR_EQ;REAL_ARITH`#0.11 < #0.9`;ARITH_RULE`3<=3`;dist] THEN STRIP_TAC THEN POP_ASSUM(fun th-> MRESA_TAC th[`(x+ p MOD k) MOD k:num`;`(x' MOD k'' + q MOD k)MOD k`]) THEN MRESAL_TAC(GEN_ALL Hdplygy.MOD_EQ_MOD)[`x:num`;`x' MOD k'' + q MOD k - p MOD k`;`p MOD k`;`k:num`][] THEN POP_ASSUM MP_TAC THEN ONCE_REWRITE_TAC[ADD_SYM] THEN RESA_TAC THEN MRESA_TAC MOD_ADD_MOD[`(p MOD k + k - q MOD k)`;`x:num`;`k:num`] THEN POP_ASSUM (fun th-> REWRITE_TAC[SYM th]) THEN MRESA_TAC MOD_ADD_MOD[`(p MOD k + k - q MOD k)`;`q MOD k - p MOD k + x' MOD k'':num`;`k:num`] THEN MRESAL_TAC MOD_MULT_ADD[`1:num`;`k:num`;`x' MOD k'':num`][ARITH_RULE`1 * k' + i = (k' +i)`] THEN MRESA_TAC MOD_LT[`x' MOD k''`;`k:num`]; MRESA_TAC DIVISION[`q:num`;`k:num`] THEN MP_TAC(ARITH_RULE`q MOD k< k ==>(x + p MOD k + k - q MOD k) + q MOD k = ((x + p MOD k) + k) `) THEN RESA_TAC THEN MRESAL_TAC MOD_MULT_ADD[`1:num`;`k:num`;`x+ p MOD k:num`][ARITH_RULE`1 * k' + i = (i+ k')`] THEN MRESA_TAC MOD_LT[`q MOD k`;`k:num`] THEN MRESA_TAC MOD_ADD_MOD[`(x + p MOD k + k - q MOD k)`;`q MOD k:num`;`k:num`] THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`vv:num->real^3`][ARITH_RULE`~(4=0)`;] THEN POP_ASSUM(fun th-> MRESA1_TAC th`x+ p MOD k` THEN MRESA1_TAC th `(x + p MOD k + k - q MOD k) MOD k + q MOD k:num` ) THEN POP_ASSUM(fun th-> ASM_REWRITE_TAC[SYM th]) THEN POP_ASSUM(fun th-> ASM_REWRITE_TAC[SYM th]); EXISTS_TAC`(\i. (i+ p MOD k - q MOD k) MOD k)` THEN STRIP_TAC; REWRITE_TAC[IN_ELIM_THM; IMAGE;EXISTS_UNIQUE] THEN REPEAT STRIP_TAC THEN EXISTS_TAC`(y + q MOD k +k - p MOD k) MOD k ` THEN MRESA_TAC DIVISION[`p:num`;`k:num`] THEN MRESA_TAC DIVISION[`q:num`;`k:num`] THEN MRESA_TAC DIVISION[`y + q MOD k +k - p MOD k:num`;`k:num`] THEN MP_TAC(ARITH_RULE`y<k'' /\ k''<k/\ p MOD k<k /\ q MOD k<= p MOD k /\ ~(q MOD k = p MOD k) ==> y<k:num /\ (y + q MOD k + k - p MOD k) + p MOD k - q MOD k =y+k/\ p MOD k - q MOD k < k /\ (y + q MOD k + k - p MOD k) + p MOD k = (y + q MOD k) + k `) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`y:num`;`k'':num`] THEN MRESA_TAC MOD_LT[`y:num`;`k:num`] THEN MRESA_TAC MOD_LT[`p MOD k:num`;`k:num`] THEN MRESA_TAC MOD_LT[`(p MOD k- q MOD k):num`;`k:num`] THEN MRESA_TAC MOD_ADD_MOD[`y+q MOD k +k - p MOD k`;`(p MOD k - q MOD k)`;`k:num`] THEN MRESAL_TAC MOD_MULT_ADD[`1:num`;`k:num`;`y:num`][ARITH_RULE`1 * k' + i = (i+k')`] THEN MRESAL_TAC MOD_MULT_ADD[`1:num`;`k:num`;`y+ q MOD k:num`][ARITH_RULE`1 * k' + i = (i+k')`] THEN MRESA_TAC MOD_ADD_MOD[`y+q MOD k +k - p MOD k`;`p MOD k `;`k:num`] THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`vv:num->real^3`][ARITH_RULE`~(4=0)`;] THEN POP_ASSUM(fun th-> MRESA1_TAC th`y+ q MOD k` THEN MRESA1_TAC th `((y + q MOD k + k - p MOD k) MOD k + p MOD k):num` ) THEN STRIP_TAC ; EXISTS_TAC`y:num` THEN ASM_REWRITE_TAC[SET_RULE`(a:num)IN(:num)`] THEN POP_ASSUM(fun th-> ASM_REWRITE_TAC[SYM th]); REPEAT STRIP_TAC THEN POP_ASSUM (fun th-> ASM_REWRITE_TAC[SYM th]) THEN MP_TAC(ARITH_RULE`y<k'' /\ k''<k/\ p MOD k<k /\ q MOD k<= p MOD k /\ ~(q MOD k = p MOD k) ==> q MOD k + k - p MOD k< k/\ (y' + p MOD k - q MOD k) + q MOD k + k - p MOD k = y'+k`) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`q MOD k + k - p MOD k`;`k:num`] THEN MRESA_TAC MOD_ADD_MOD[`y' + p MOD k - q MOD k`;`q MOD k + k - p MOD k`;`k:num`] THEN MRESAL_TAC MOD_MULT_ADD[`1:num`;`k:num`;`y':num`][ARITH_RULE`1 * k' + i = (i+k')`] THEN MRESA_TAC MOD_LT[`y':num`;`k:num`] ; REPEAT RESA_TAC ; MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`vv:num->real^3`][ARITH_RULE`~(4=0)`;] THEN POP_ASSUM(fun th-> MRESA1_TAC th `(x + p MOD k):num` THEN MRESA1_TAC th`x' MOD k''+ q MOD k`) THEN MP_TAC(ARITH_RULE`3<= k'' ==> ~(k''=0)`) THEN RESA_TAC THEN MRESA_TAC DIVISION[`x +p MOD k`;`k:num`] THEN MRESA_TAC DIVISION[`x' MOD k'' +q MOD k`;`k:num`] THEN MRESA_TAC DIVISION[`x':num`;`k'':num`] THEN MP_TAC VV_INJ THEN ASM_REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;scs_half_slice_v39;PAIR_EQ;REAL_ARITH`#0.11 < #0.9`;ARITH_RULE`3<=3`;dist] THEN STRIP_TAC THEN POP_ASSUM(fun th-> MRESA_TAC th[`(x+ p MOD k) MOD k:num`;`(x' MOD k'' + q MOD k)MOD k`]) THEN MP_TAC(ARITH_RULE`q MOD k<= p MOD k /\ x' MOD k''< k'' /\ k''<k ==> (x + p MOD k - q MOD k) + q MOD k = x + p MOD k /\ x' MOD k''< k`) THEN RESA_TAC THEN MRESAL_TAC(GEN_ALL Hdplygy.MOD_EQ_MOD)[`x + p MOD k - q MOD k`;`x' MOD k'' `;`q MOD k`;`k:num`][] THEN POP_ASSUM MP_TAC THEN ONCE_REWRITE_TAC[ADD_SYM] THEN RESA_TAC THEN MRESA_TAC MOD_LT[`x' MOD k''`;`k:num`]; MRESA_TAC DIVISION[`q:num`;`k:num`] THEN MP_TAC(ARITH_RULE`q MOD k<= p MOD k ==> (x + p MOD k - q MOD k) + q MOD k = (x + p MOD k) `) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`q MOD k`;`k:num`] THEN MRESA_TAC MOD_ADD_MOD[`(x + p MOD k - q MOD k)`;`q MOD k:num`;`k:num`] THEN MRESAL_TAC(GEN_ALL PERIODIC_PROPERTY)[`scs_k_v39 s`;`vv:num->real^3`][ARITH_RULE`~(4=0)`;] THEN POP_ASSUM(fun th-> MRESA1_TAC th`x+ p MOD k` THEN MRESA1_TAC th `((x + p MOD k - q MOD k) MOD k + q MOD k):num` ) THEN POP_ASSUM(fun th-> ASM_REWRITE_TAC[SYM th]) THEN POP_ASSUM(fun th-> ASM_REWRITE_TAC[SYM th]); ASM_REWRITE_TAC[] THEN MP_TAC E_PRIME_EQ_E_vv THEN ASM_REWRITE_TAC[is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist;scs_half_slice_v39] THEN STRIP_TAC THEN MRESA_TAC (GEN_ALL E_PRIME_EQ_E_vv) [`d'':real`;`d':real`;`mkj:bool`;`s':scs_v39`;`s'':scs_v39`;`p:num`;`s:scs_v39`; `vv:num->real^3`;`k'':num`;`q:num`;`k:num`;`V:real^3->bool`;`E:(real^3->bool)->bool`;`u:real^3`;`FF:real^3#real^3->bool`;`w:real^3`] THEN POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist;scs_half_slice_v39;] THEN ONCE_REWRITE_TAC[VECTOR_ARITH`u-w= --(w-u):real^3`] THEN ASM_REWRITE_TAC[NORM_NEG] THEN STRIP_TAC THEN MP_TAC F_PRIME_EQ_F_vv THEN ASM_REWRITE_TAC[is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist;scs_half_slice_v39] THEN STRIP_TAC THEN MRESA_TAC (GEN_ALL F_PRIME_EQ_F_vv) [`d'':real`;`d':real`;`mkj:bool`;`s':scs_v39`;`s'':scs_v39`;`p:num`;`s:scs_v39`; `vv:num->real^3`;`k'':num`;`q:num`;`k:num`;`V:real^3->bool`;`E:(real^3->bool)->bool`;`u:real^3`;`FF:real^3#real^3->bool`;`w:real^3`] THEN POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist;scs_half_slice_v39;] THEN ONCE_REWRITE_TAC[VECTOR_ARITH`u-w= --(w-u):real^3`] THEN ASM_REWRITE_TAC[NORM_NEG] THEN STRIP_TAC THEN SUBGOAL_THEN`BBs_v39 s' vv'`ASSUME_TAC; MP_TAC QKNVMLB1 THEN ASM_REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist;] THEN RESA_TAC THEN POP_ASSUM MATCH_MP_TAC THEN ASM_TAC THEN REWRITE_TAC[LET_DEF;LET_END_DEF;tau3;MMs_v39;BBprime2_v39;BBprime_v39;is_scs_slice_v39] THEN REPEAT RESA_TAC THEN SUBGOAL_THEN`d' = scs_d_v39 s'`ASSUME_TAC ; EXPAND_TAC"s'" THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist;periodic2;scs_half_slice_v39] THEN ASM_REWRITE_TAC[]; ASM_REWRITE_TAC[] ; EXPAND_TAC"s'" THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist;periodic2;scs_half_slice_v39] THEN ASM_REWRITE_TAC[]; ASM_REWRITE_TAC[] ; SUBGOAL_THEN`BBs_v39 s'' vv''`ASSUME_TAC; MRESAL_TAC (GEN_ALL QKNVMLB1)[`vv:num->real^3`;`s:scs_v39`;`q:num`;`p:num`;`d'':real`;`mkj:bool`] [MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist;] THEN POP_ASSUM MATCH_MP_TAC THEN ASM_TAC THEN REWRITE_TAC[LET_DEF;LET_END_DEF;tau3;MMs_v39;BBprime2_v39;BBprime_v39;is_scs_slice_v39] THEN REPEAT RESA_TAC THEN SUBGOAL_THEN`d'' = scs_d_v39 s''`ASSUME_TAC ; EXPAND_TAC"s''" THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist;periodic2;scs_half_slice_v39] THEN ASM_REWRITE_TAC[]; ASM_REWRITE_TAC[] ; EXPAND_TAC"s''" THEN REWRITE_TAC[MMs_v39; BBprime2_v39;BBprime_v39;BBs_v39;LET_DEF;LET_END_DEF;is_scs_v39;scs_diag;scs_v39_explicit;is_scs_slice_v39;dsv_v39;scs_slice_v39;PAIR_EQ;dist;periodic2;scs_half_slice_v39] THEN ASM_REWRITE_TAC[]; ASM_REWRITE_TAC[] ; MP_TAC SCS_HALF_SLICE_IS_A_SCS THEN ASM_REWRITE_TAC[is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist;scs_half_slice_v39] THEN STRIP_TAC THEN MRESAL_TAC (GEN_ALL SCS_HALF_SLICE_IS_A_SCS)[`s:scs_v39`;`s':scs_v39`;`q:num`;`p:num`;`s'':scs_v39`] [is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist;scs_half_slice_v39] THEN MRESAL_TAC(GEN_ALL VV_SUC_EQ_RHO_NODE_PRIME)[`V:real^3->bool`;`E:(real^3->bool)->bool`;`k:num`;`s:scs_v39`;`FF:real^3#real^3->bool`;`u:real^3`;`vv:num->real^3`;`p:num MOD k`] [is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist] THEN MRESAL_TAC(GEN_ALL VV_SUC_EQ_RHO_NODE_PRIME)[`V:real^3->bool`;`E:(real^3->bool)->bool`;`k:num`;`s:scs_v39`;`FF:real^3#real^3->bool`;`w:real^3`;`vv:num->real^3`;`q:num MOD k`] [is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist] THEN MP_TAC(ARITH_RULE`~(k'<= 3)\/ k'<= 3 `) THEN RESA_TAC; MP_TAC(ARITH_RULE`~(k''<= 3)\/ k''<= 3 `) THEN RESA_TAC; MP_TAC(ARITH_RULE`3<=k'==> ~(k'=0)/\ 0<k'`) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`0`;`k':num`] THEN MRESAL_TAC(GEN_ALL VV_SUC_EQ_RHO_NODE_PRIME)[`v_prime V (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u))`;`e_prime (E UNION {{u, w}}) (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u))`;`k':num`;`s':scs_v39`;`face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u)`;`u:real^3`;`vv':num->real^3`;`0:num MOD k'`] [is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3/\ 0+A=A`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist] THEN MRESAL_TAC (GEN_ALL SUM_AZIM_EQ_ANGLE_LE4) [`v_prime V (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u))`; `vv':num->real^3`;`0`;`s':scs_v39`;`u:real^3`;`face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u)`;`e_prime (E UNION {{u, w}}) (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u))`;] [is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)/\ 0+A=A/\ A+0=A`;mk_unadorned_v39;scs_diag;dist;scs_half_slice_v39] THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN SUBGOAL_THEN`sum {i | i < k'} (\i. rho_fun (norm (vv (i MOD k' + p MOD k))) * interior_angle1 (vec 0) (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u)) (vv (i MOD k' + p MOD k))) =sum {i | i < k'} (\i. rho_fun (norm (vv (i + p MOD k))) * interior_angle1 (vec 0) (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u)) (vv (i + p MOD k)))` ASSUME_TAC ; MATCH_MP_TAC SUM_EQ THEN REWRITE_TAC[IN_ELIM_THM] THEN REPEAT RESA_TAC THEN MRESA_TAC MOD_LT[`x:num`;`k':num`]; MP_TAC(ARITH_RULE`3<=k''==> ~(k''=0)/\ 0<k''`) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`0`;`k'':num`] THEN MRESAL_TAC(GEN_ALL VV_SUC_EQ_RHO_NODE_PRIME)[`v_prime V (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (w,rho_node1 FF w))`;`e_prime (E UNION {{u, w}}) (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (w,rho_node1 FF w))`;`k'':num`;`s'':scs_v39`;`face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (w,rho_node1 FF w)`;`w:real^3`;`vv'':num->real^3`;`0:num MOD k'`] [is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3/\ 0+A=A`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist] THEN MRESAL_TAC (GEN_ALL SUM_AZIM_EQ_ANGLE_LE4) [`v_prime V (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (w,rho_node1 FF w))`; `vv'':num->real^3`;`0`;`s'':scs_v39`;`w:real^3`;`face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (w,rho_node1 FF w)`;`e_prime (E UNION {{u, w}}) (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (w,rho_node1 FF w))`;] [is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)/\ 0+A=A/\ A+0=A`;mk_unadorned_v39;scs_diag;dist;scs_half_slice_v39] THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN SUBGOAL_THEN`sum {i | i < k''} (\i. rho_fun (norm (vv (i MOD k'' + q MOD k))) * interior_angle1 (vec 0) (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (w,rho_node1 FF w)) (vv (i MOD k'' + q MOD k))) =sum {i | i < k''} (\i. rho_fun (norm (vv (i + q MOD k))) * interior_angle1 (vec 0) (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (w,rho_node1 FF w)) (vv (i + q MOD k)))` ASSUME_TAC ; MATCH_MP_TAC SUM_EQ THEN REWRITE_TAC[IN_ELIM_THM] THEN REPEAT RESA_TAC THEN MRESA_TAC MOD_LT[`x:num`;`k'':num`]; ASM_REWRITE_TAC[] ; MRESA_TAC (GEN_ALL CARD_FF_EQ_CARD_SLICE_FF) [`V:real^3->bool`;`(E:(real^3->bool)->bool)`;`u:real^3`;`hypermap (HYP (vec 0,V,(E:(real^3->bool)->bool) UNION {{u, w}}))`;`w:real^3`;`FF:real^3#real^3->bool`;`face (hypermap (HYP (vec 0,V,(E:(real^3->bool)->bool) UNION {{u, w}}))) (u,rho_node1 FF u)`;`face (hypermap (HYP (vec 0,V,(E:(real^3->bool)->bool) UNION {{u, w}}))) (w,rho_node1 FF w)`] THEN MRESA_TAC (GEN_ALL CARD_SLICE_FF_LE_3)[`V:real^3->bool`;`E:(real^3->bool)->bool`;`u:real^3`;`hypermap (HYP (vec 0,V,(E:(real^3->bool)->bool) UNION {{u, w}}))`;`FF:real^3#real^3->bool`;`w:real^3`;`face (hypermap (HYP (vec 0,V,(E:(real^3->bool)->bool) UNION {{u, w}}))) (u,rho_node1 FF u)`;`face (hypermap (HYP (vec 0,V,(E:(real^3->bool)->bool) UNION {{u, w}}))) (w,rho_node1 FF w)`] THEN MP_TAC(ARITH_RULE` 3<= CARD (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u)) /\ 3<= CARD (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (w,rho_node1 FF w)) ==> (CARD (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u)) + CARD (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (w,rho_node1 FF w)) - 2) - 2= (CARD (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u)) -2)+ (CARD (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (w,rho_node1 FF w)) - 2)`) THEN RESA_TAC THEN REWRITE_TAC[GSYM REAL_OF_NUM_ADD] THEN MP_TAC QKNVMLB2 THEN REWRITE_TAC[MMs_v39;BBprime2_v39;BBprime_v39;BBs_v39;is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3/\ 0+A=A`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist] THEN RESA_TAC THEN MATCH_MP_TAC(REAL_ARITH`d2<= d+d1 ==> a-c*b-d + a1-c*b1-d1<= (a+a1) - c*(b+b1)-d2`) THEN ASM_REWRITE_TAC[] ; (******3<k' /\ k''=3 ********) MP_TAC(ARITH_RULE`3<=k'==> ~(k'=0)/\ 0<k'`) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`0`;`k':num`] THEN MRESAL_TAC(GEN_ALL VV_SUC_EQ_RHO_NODE_PRIME)[`v_prime V (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u))`;`e_prime (E UNION {{u, w}}) (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u))`;`k':num`;`s':scs_v39`;`face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u)`;`u:real^3`;`vv':num->real^3`;`0:num MOD k'`] [is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3/\ 0+A=A`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist] THEN MRESAL_TAC (GEN_ALL SUM_AZIM_EQ_ANGLE_LE4) [`v_prime V (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u))`; `vv':num->real^3`;`0`;`s':scs_v39`;`u:real^3`;`face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u)`;`e_prime (E UNION {{u, w}}) (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u))`;] [is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)/\ 0+A=A/\ A+0=A`;mk_unadorned_v39;scs_diag;dist;scs_half_slice_v39] THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN SUBGOAL_THEN`sum {i | i < k'} (\i. rho_fun (norm (vv (i MOD k' + p MOD k))) * interior_angle1 (vec 0) (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u)) (vv (i MOD k' + p MOD k))) =sum {i | i < k'} (\i. rho_fun (norm (vv (i + p MOD k))) * interior_angle1 (vec 0) (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u)) (vv (i + p MOD k)))` ASSUME_TAC ; MATCH_MP_TAC SUM_EQ THEN REWRITE_TAC[IN_ELIM_THM] THEN REPEAT RESA_TAC THEN MRESA_TAC MOD_LT[`x:num`;`k':num`]; MP_TAC(ARITH_RULE`(k''<=3) /\ 3<= k'' ==> k''=3`) THEN RESA_TAC THEN REPLICATE_TAC (125-61)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th THEN ASM_REWRITE_TAC[] THEN STRIP_TAC) THEN MRESA_TAC (GEN_ALL SUM_AZIM_EQ_ANGLE_EQ4) [`d'':real`;`d':real`;`mkj:bool`;`vv'':num->real^3`;`vv':num->real^3`;`s':scs_v39`;`s'':scs_v39`;`s:scs_v39`;`p:num`;`k'':num`;`vv:num->real^3`;`q:num`;`k:num`;`V:real^3->bool`;`E:(real^3->bool)->bool`;`u:real^3`;`FF:real^3#real^3->bool`;`w:real^3`] THEN POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[MMs_v39;BBprime2_v39;BBprime_v39;BBs_v39;is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist;scs_half_slice_v39;] THEN ONCE_REWRITE_TAC[VECTOR_ARITH`u-w= --(w-u):real^3`] THEN ASM_REWRITE_TAC[NORM_NEG] THEN RESA_TAC ; MRESA_TAC (GEN_ALL CARD_FF_EQ_CARD_SLICE_FF) [`V:real^3->bool`;`(E:(real^3->bool)->bool)`;`u:real^3`;`hypermap (HYP (vec 0,V,(E:(real^3->bool)->bool) UNION {{u, w}}))`;`w:real^3`;`FF:real^3#real^3->bool`;`face (hypermap (HYP (vec 0,V,(E:(real^3->bool)->bool) UNION {{u, w}}))) (u,rho_node1 FF u)`;`face (hypermap (HYP (vec 0,V,(E:(real^3->bool)->bool) UNION {{u, w}}))) (w,rho_node1 FF w)`] THEN MRESA_TAC (GEN_ALL CARD_SLICE_FF_LE_3)[`V:real^3->bool`;`E:(real^3->bool)->bool`;`u:real^3`;`hypermap (HYP (vec 0,V,(E:(real^3->bool)->bool) UNION {{u, w}}))`;`FF:real^3#real^3->bool`;`w:real^3`;`face (hypermap (HYP (vec 0,V,(E:(real^3->bool)->bool) UNION {{u, w}}))) (u,rho_node1 FF u)`;`face (hypermap (HYP (vec 0,V,(E:(real^3->bool)->bool) UNION {{u, w}}))) (w,rho_node1 FF w)`] THEN MP_TAC(ARITH_RULE` 3<= CARD (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u)) /\ 3<= CARD (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (w,rho_node1 FF w)) ==> (CARD (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u)) + CARD (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (w,rho_node1 FF w)) - 2) - 2= (CARD (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u)) -2)+ (CARD (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (w,rho_node1 FF w)) - 2)`) THEN RESA_TAC THEN REWRITE_TAC[GSYM REAL_OF_NUM_ADD] THEN MP_TAC QKNVMLB2 THEN REWRITE_TAC[MMs_v39;BBprime2_v39;BBprime_v39;BBs_v39;is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3/\ 0+A=A`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist] THEN RESA_TAC THEN REPLICATE_TAC (131-124)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> ASM_TAC THEN ASM_REWRITE_TAC[th] THEN MP_TAC th THEN REPEAT STRIP_TAC) THEN MRESAL_TAC(GEN_ALL CARD_FF_EQ_SCS_K_3)[`k'':num`;`s'':scs_v39`;`vv'':num->real^3`;`face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (w,rho_node1 FF w)`][MMs_v39;BBprime2_v39;BBprime_v39;BBs_v39;is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3/\ 0+A=A`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3) /\ 3-2=1`;mk_unadorned_v39;scs_diag;dist] THEN MATCH_MP_TAC(REAL_ARITH`d2<= d+d1 ==> a-c*b-d + a1-c-d1<= (a+a1) - c*(b+ &1)-d2`) THEN ASM_REWRITE_TAC[] ; MP_TAC(ARITH_RULE`~(k''<= 3)\/ k''<= 3 `) THEN RESA_TAC; (********k'=3 /\ 3< k''***********) MP_TAC(ARITH_RULE`3<=k''==> ~(k''=0)/\ 0<k''`) THEN RESA_TAC THEN MRESA_TAC MOD_LT[`0`;`k'':num`] THEN MRESAL_TAC(GEN_ALL VV_SUC_EQ_RHO_NODE_PRIME)[`v_prime V (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (w,rho_node1 FF w))`;`e_prime (E UNION {{u, w}}) (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (w,rho_node1 FF w))`;`k'':num`;`s'':scs_v39`;`face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (w,rho_node1 FF w)`;`w:real^3`;`vv'':num->real^3`;`0:num MOD k''`] [is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3/\ 0+A=A`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist] THEN MRESAL_TAC (GEN_ALL SUM_AZIM_EQ_ANGLE_LE4) [`v_prime V (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (w,rho_node1 FF w))`; `vv'':num->real^3`;`0`;`s'':scs_v39`;`w:real^3`;`face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (w,rho_node1 FF w)`;`e_prime (E UNION {{u, w}}) (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (w,rho_node1 FF w))`;] [is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)/\ 0+A=A/\ A+0=A`;mk_unadorned_v39;scs_diag;dist;scs_half_slice_v39] THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN SUBGOAL_THEN`sum {i | i < k''} (\i. rho_fun (norm (vv (i MOD k'' + q MOD k))) * interior_angle1 (vec 0) (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (w,rho_node1 FF w)) (vv (i MOD k'' + q MOD k))) =sum {i | i < k''} (\i. rho_fun (norm (vv (i + q MOD k))) * interior_angle1 (vec 0) (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (w,rho_node1 FF w)) (vv (i + q MOD k)))` ASSUME_TAC ; MATCH_MP_TAC SUM_EQ THEN REWRITE_TAC[IN_ELIM_THM] THEN REPEAT RESA_TAC THEN MRESA_TAC MOD_LT[`x:num`;`k'':num`]; ASM_REWRITE_TAC[] ; MP_TAC(ARITH_RULE`(k'<=3) /\ 3<= k' ==> k'=3`) THEN RESA_TAC THEN REPLICATE_TAC (125-60)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th THEN ASM_REWRITE_TAC[] THEN STRIP_TAC) THEN MRESA_TAC (GEN_ALL SUM_AZIM_EQ_ANGLE_EQ4) [`d':real`;`d'':real`;`mkj:bool`;`vv':num->real^3`;`vv'':num->real^3`;`s'':scs_v39`;`s':scs_v39`;`s:scs_v39`;`q:num`;`k':num`;`vv:num->real^3`;`p:num`;`k:num`;`V:real^3->bool`;`E:(real^3->bool)->bool`;`w:real^3`;`FF:real^3#real^3->bool`;`u:real^3`] THEN POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[MMs_v39;BBprime2_v39;BBprime_v39;BBs_v39;is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist;scs_half_slice_v39;] THEN ONCE_REWRITE_TAC[VECTOR_ARITH`u-w= --(w-u):real^3`] THEN ASM_REWRITE_TAC[NORM_NEG] THEN RESA_TAC ; MRESA_TAC (GEN_ALL CARD_FF_EQ_CARD_SLICE_FF) [`V:real^3->bool`;`(E:(real^3->bool)->bool)`;`u:real^3`;`hypermap (HYP (vec 0,V,(E:(real^3->bool)->bool) UNION {{u, w}}))`;`w:real^3`;`FF:real^3#real^3->bool`;`face (hypermap (HYP (vec 0,V,(E:(real^3->bool)->bool) UNION {{u, w}}))) (u,rho_node1 FF u)`;`face (hypermap (HYP (vec 0,V,(E:(real^3->bool)->bool) UNION {{u, w}}))) (w,rho_node1 FF w)`] THEN MRESA_TAC (GEN_ALL CARD_SLICE_FF_LE_3)[`V:real^3->bool`;`E:(real^3->bool)->bool`;`u:real^3`;`hypermap (HYP (vec 0,V,(E:(real^3->bool)->bool) UNION {{u, w}}))`;`FF:real^3#real^3->bool`;`w:real^3`;`face (hypermap (HYP (vec 0,V,(E:(real^3->bool)->bool) UNION {{u, w}}))) (u,rho_node1 FF u)`;`face (hypermap (HYP (vec 0,V,(E:(real^3->bool)->bool) UNION {{u, w}}))) (w,rho_node1 FF w)`] THEN MP_TAC(ARITH_RULE` 3<= CARD (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u)) /\ 3<= CARD (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (w,rho_node1 FF w)) ==> (CARD (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u)) + CARD (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (w,rho_node1 FF w)) - 2) - 2= (CARD (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u)) -2)+ (CARD (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (w,rho_node1 FF w)) - 2)`) THEN RESA_TAC THEN REWRITE_TAC[GSYM REAL_OF_NUM_ADD] THEN MP_TAC QKNVMLB2 THEN REWRITE_TAC[MMs_v39;BBprime2_v39;BBprime_v39;BBs_v39;is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3/\ 0+A=A`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist] THEN RESA_TAC THEN REPLICATE_TAC (131-124)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> ASM_TAC THEN ASM_REWRITE_TAC[th] THEN MP_TAC th THEN REPEAT STRIP_TAC) THEN MRESAL_TAC(GEN_ALL CARD_FF_EQ_SCS_K_3)[`k':num`;`s':scs_v39`;`vv':num->real^3`;`face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u)`][MMs_v39;BBprime2_v39;BBprime_v39;BBs_v39;is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3/\ 0+A=A`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3) /\ 3-2=1`;mk_unadorned_v39;scs_diag;dist] THEN MATCH_MP_TAC(REAL_ARITH`d2<= d+d1 ==> a-c-d + a1-c*b-d1<= (a+a1) - c*(&1+b)-d2`) THEN ASM_REWRITE_TAC[] ; (*********k'=3 /\ k''=3********) MP_TAC(ARITH_RULE`(k'<=3) /\ 3<= k' ==> k'=3`) THEN RESA_TAC THEN REPLICATE_TAC (120-60)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th THEN ASM_REWRITE_TAC[] THEN STRIP_TAC) THEN MRESA_TAC (GEN_ALL SUM_AZIM_EQ_ANGLE_EQ4) [`d':real`;`d'':real`;`mkj:bool`;`vv':num->real^3`;`vv'':num->real^3`;`s'':scs_v39`;`s':scs_v39`;`s:scs_v39`;`q:num`;`k':num`;`vv:num->real^3`;`p:num`;`k:num`;`V:real^3->bool`;`E:(real^3->bool)->bool`;`w:real^3`;`FF:real^3#real^3->bool`;`u:real^3`] THEN POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[MMs_v39;BBprime2_v39;BBprime_v39;BBs_v39;is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist;scs_half_slice_v39;] THEN ONCE_REWRITE_TAC[VECTOR_ARITH`u-w= --(w-u):real^3`] THEN ASM_REWRITE_TAC[NORM_NEG] THEN RESA_TAC ; MP_TAC(ARITH_RULE`(k''<=3) /\ 3<= k'' ==> k''=3`) THEN RESA_TAC THEN REPLICATE_TAC (122-60)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th THEN ASM_REWRITE_TAC[] THEN STRIP_TAC) THEN MRESA_TAC (GEN_ALL SUM_AZIM_EQ_ANGLE_EQ4) [`d'':real`;`d':real`;`mkj:bool`;`vv'':num->real^3`;`vv':num->real^3`;`s':scs_v39`;`s'':scs_v39`;`s:scs_v39`;`p:num`;`k'':num`;`vv:num->real^3`;`q:num`;`k:num`;`V:real^3->bool`;`E:(real^3->bool)->bool`;`u:real^3`;`FF:real^3#real^3->bool`;`w:real^3`] THEN POP_ASSUM MP_TAC THEN ASM_REWRITE_TAC[MMs_v39;BBprime2_v39;BBprime_v39;BBs_v39;is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist;scs_half_slice_v39;] THEN ONCE_REWRITE_TAC[VECTOR_ARITH`u-w= --(w-u):real^3`] THEN ASM_REWRITE_TAC[NORM_NEG] THEN RESA_TAC ; MRESA_TAC (GEN_ALL CARD_FF_EQ_CARD_SLICE_FF) [`V:real^3->bool`;`(E:(real^3->bool)->bool)`;`u:real^3`;`hypermap (HYP (vec 0,V,(E:(real^3->bool)->bool) UNION {{u, w}}))`;`w:real^3`;`FF:real^3#real^3->bool`;`face (hypermap (HYP (vec 0,V,(E:(real^3->bool)->bool) UNION {{u, w}}))) (u,rho_node1 FF u)`;`face (hypermap (HYP (vec 0,V,(E:(real^3->bool)->bool) UNION {{u, w}}))) (w,rho_node1 FF w)`] THEN MRESA_TAC (GEN_ALL CARD_SLICE_FF_LE_3)[`V:real^3->bool`;`E:(real^3->bool)->bool`;`u:real^3`;`hypermap (HYP (vec 0,V,(E:(real^3->bool)->bool) UNION {{u, w}}))`;`FF:real^3#real^3->bool`;`w:real^3`;`face (hypermap (HYP (vec 0,V,(E:(real^3->bool)->bool) UNION {{u, w}}))) (u,rho_node1 FF u)`;`face (hypermap (HYP (vec 0,V,(E:(real^3->bool)->bool) UNION {{u, w}}))) (w,rho_node1 FF w)`] THEN MP_TAC(ARITH_RULE` 3<= CARD (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u)) /\ 3<= CARD (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (w,rho_node1 FF w)) ==> (CARD (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u)) + CARD (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (w,rho_node1 FF w)) - 2) - 2= (CARD (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u)) -2)+ (CARD (face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (w,rho_node1 FF w)) - 2)`) THEN RESA_TAC THEN REWRITE_TAC[GSYM REAL_OF_NUM_ADD] THEN MP_TAC QKNVMLB2 THEN REWRITE_TAC[MMs_v39;BBprime2_v39;BBprime_v39;BBs_v39;is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3/\ 0+A=A`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist] THEN RESA_TAC THEN REPLICATE_TAC (128-118)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> ASM_TAC THEN ASM_REWRITE_TAC[th] THEN MP_TAC th THEN REPEAT STRIP_TAC) THEN MRESAL_TAC(GEN_ALL CARD_FF_EQ_SCS_K_3)[`k':num`;`s':scs_v39`;`vv':num->real^3`;`face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (u,rho_node1 FF u)`][MMs_v39;BBprime2_v39;BBprime_v39;BBs_v39;is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3/\ 0+A=A`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3) /\ 3-2=1`;mk_unadorned_v39;scs_diag;dist] THEN REPLICATE_TAC (128-120)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> ASM_TAC THEN ASM_REWRITE_TAC[th] THEN MP_TAC th THEN REPEAT STRIP_TAC) THEN MRESAL_TAC(GEN_ALL CARD_FF_EQ_SCS_K_3)[`k'':num`;`s'':scs_v39`;`vv'':num->real^3`;`face (hypermap (HYP (vec 0,V,E UNION {{u, w}}))) (w,rho_node1 FF w)`][MMs_v39;BBprime2_v39;BBprime_v39;BBs_v39;is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3/\ 0+A=A`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3) /\ 3-2=1`;mk_unadorned_v39;scs_diag;dist] THEN MATCH_MP_TAC(REAL_ARITH`d2<= d+d1 ==> a-c-d + a1-c-d1<= (a+a1) - c*(&1+ &1)-d2`) THEN ASM_REWRITE_TAC[] ; ]);;
let DIAGE_VAL_P_Q=
prove(`~(p MOD 4 = q MOD 4)/\ ~(SUC p MOD 4 = q MOD 4)/\ ~(p MOD 4 = SUC q MOD 4) ==> q MOD 4=(p MOD 4 +2) MOD 4`,
MRESAL_TAC DIVISION[`p:num`;`4`][ARITH_RULE`~(4=0)`;ADD1] THEN MP_TAC(ARITH_RULE`p MOD 4<4==> p MOD 4=0 \/ p MOD 4=1 \/ p MOD 4=2 \/ p MOD 4=3`) THEN RESA_TAC THEN MRESAL_TAC DIVISION[`q:num`;`4`][ARITH_RULE`~(4=0)`;ADD1] THEN MP_TAC(ARITH_RULE`q MOD 4<4==> q MOD 4=0 \/ q MOD 4=1 \/ q MOD 4=2 \/ q MOD 4=3`) THEN RESA_TAC THEN MRESAL_TAC MOD_ADD_MOD[`p:num`;`1`;`4`][ARITH_RULE`~(4=0)`] THEN MRESAL_TAC MOD_ADD_MOD[`q:num`;`1`;`4`][ARITH_RULE`~(4=0)`] THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN POP_ASSUM(fun th-> REWRITE_TAC[SYM th]) THEN ARITH_TAC);;
let QKNVMLB3_Eq4=
prove_by_refinement( `(scs_k_v39 s =4 /\ ~(scs_J_v39 s' 0 (scs_k_v39 s' - 1)))/\ scs_half_slice_v39 s p q d' mkj =s'/\ scs_half_slice_v39 s q p d'' mkj =s'' /\ vv' = (\i. (vv:num->real^3) (i MOD (scs_k_v39 s')+p MOD (scs_k_v39 s))) /\ vv'' = (\i. (vv:num->real^3) (i MOD (scs_k_v39 s'')+q MOD (scs_k_v39 s))) /\ MMs_v39 s vv /\ is_scs_v39 s /\ scs_diag (scs_k_v39 s) p q /\ is_scs_slice_v39 s s' s'' p q /\ scs_d_v39 s <= d' + d'' ==> taustar_v39 s' vv' + taustar_v39 s'' vv'' <= taustar_v39 s vv`,
[ REWRITE_TAC[taustar_v39;LET_DEF;LET_END_DEF;scs_diag] THEN STRIP_TAC THEN MP_TAC SCS_K_PRIME_CASE_3 THEN REWRITE_TAC[taustar_v39;LET_DEF;LET_END_DEF;scs_diag] THEN RESA_TAC THEN ABBREV_TAC`k=scs_k_v39 s` THEN ABBREV_TAC`k'=scs_k_v39 s'` THEN ABBREV_TAC`k''=scs_k_v39 s''` THEN MP_TAC(ARITH_RULE`3<k==> ~(k<=3)`) THEN RESA_TAC THEN MP_TAC SCS_K_LE_6 THEN RESA_TAC THEN ABBREV_TAC`u= (vv:num->real^3) (p MOD k)` THEN ABBREV_TAC `w= (vv:num->real^3) (q MOD k)` THEN ABBREV_TAC`V= IMAGE (vv:num->real^3) (:num)` THEN ABBREV_TAC`E= IMAGE (\i. {vv i,(vv:num->real^3) (SUC i)}) (:num)` THEN ABBREV_TAC`FF= IMAGE (\i. (vv i,(vv:num->real^3) (SUC i))) (:num)` THEN MRESA_TAC (GEN_ALL IN_IMAGE_VV)[`p MOD scs_k_v39 s`;`vv:num->real^3`] THEN MRESA_TAC (GEN_ALL IN_IMAGE_VV)[`q MOD scs_k_v39 s`;`vv:num->real^3`] THEN ASM_TAC THEN REPLICATE_TAC 2 STRIP_TAC THEN ASM_REWRITE_TAC[MMs_v39;BBprime_v39;BBprime2_v39;is_scs_v39;scs_k_v39_explicit;scs_d_v39_explicit;scs_a_v39_explicit;scs_b_v39_explicit;BBs_v39;ARITH_RULE`3<=3`;LET_DEF;LET_END_DEF;ARITH_RULE`~(4<=3)`;mk_unadorned_v39;scs_diag;dist;] THEN REPEAT RESA_TAC ; REPLICATE_TAC (54-9)(POP_ASSUM MP_TAC) THEN POP_ASSUM(fun th-> REPEAT STRIP_TAC THEN MP_TAC th) THEN ASM_REWRITE_TAC[ARITH_RULE`~(4<=3)`] ; MP_TAC SCS_K_PRIME_CASE_4 THEN ASM_REWRITE_TAC[MMs_v39;BBprime_v39;BBprime2_v39;