p /\
~coplanar {v1, v2, v3, w}
==> (?n n'. norm(n - n') = &1 /\
(!x. x
aff_ge {v1, v2, v3} {w} <=>
(?xx h.
xx
affine hull {v1, v2, v3} /\
&0 <= h /\
x - xx = h % (n - n'))) /\
(!x y.
{x, y}
GEOM_HORIZONTAL_PLANE_TAC `p:real^3->bool` THEN
REPEAT GEN_TAC THEN DISCH_THEN(CONJUNCTS_THEN2 ASSUME_TAC MP_TAC) THEN
REWRITE_TAC[
INSERT_SUBSET;
EMPTY_SUBSET;
IN_ELIM_THM] THEN
MAP_EVERY (fun t ->
ASM_CASES_TAC t THENL [ASM_REWRITE_TAC[
INSERT_AC;
COPLANAR_3]; ALL_TAC])
[`v1:real^3 = v2`; `v1:real^3 = v3`; `v2:real^3 = v3`;
`v1:real^3 = w`; `v2:real^3 = w`; `v3:real^3 = w`] THEN
STRIP_TAC THEN
ONCE_REWRITE_TAC[
SWAP_EXISTS_THM] THEN
EXISTS_TAC `vec 0:real^3` THEN REWRITE_TAC[
VECTOR_SUB_RZERO] THEN
SUBGOAL_THEN `~((w:real^3)$3 = &0)` ASSUME_TAC THENL
[DISCH_TAC THEN UNDISCH_TAC `~coplanar{v1:real^3,v2,v3,w}` THEN
REWRITE_TAC[coplanar] THEN
FIRST_X_ASSUM(MP_TAC o GEN_REWRITE_RULE I [plane]) THEN
REPEAT(MATCH_MP_TAC
MONO_EXISTS THEN GEN_TAC) THEN
DISCH_THEN(SUBST1_TAC o SYM o CONJUNCT2) THEN
ASM_REWRITE_TAC[
INSERT_SUBSET;
EMPTY_SUBSET;
IN_ELIM_THM];
ALL_TAC] THEN
SUBGOAL_THEN `(vec 0:real^3)
IN affine hull {v1,v2,v3}` ASSUME_TAC THENL
[MP_TAC(ISPEC `{v1:real^3,v2,v3}`
DEPENDENT_BIGGERSET_GENERAL) THEN
ANTS_TAC THENL
[DISCH_THEN(K ALL_TAC) THEN REWRITE_TAC[
GT] THEN
MATCH_MP_TAC
LET_TRANS THEN EXISTS_TAC `dim {z:real^3 | z$3 = &0}` THEN
CONJ_TAC THENL [MATCH_MP_TAC
DIM_SUBSET THEN ASM SET_TAC[]; ALL_TAC] THEN
SIMP_TAC[
DIM_SPECIAL_HYPERPLANE; DIMINDEX_3; ARITH] THEN
REWRITE_TAC[GSYM
NOT_LE] THEN DISCH_TAC THEN
FIRST_ASSUM(MP_TAC o MATCH_MP
NOT_COPLANAR_NOT_COLLINEAR) THEN
REWRITE_TAC[] THEN MATCH_MP_TAC
COLLINEAR_SMALL THEN
ASM_REWRITE_TAC[
FINITE_INSERT;
FINITE_RULES];
ALL_TAC] THEN
REWRITE_TAC[
DEPENDENT_AFFINE_DEPENDENT_CASES] THEN
ASM_MESON_TAC[
AFFINE_DEPENDENT_IMP_COLLINEAR_3;
NOT_COPLANAR_NOT_COLLINEAR];
ALL_TAC] THEN
SUBGOAL_THEN `affine hull {v1,v2,v3} = {z:real^3 | z$3 = &0}`
ASSUME_TAC THENL
[ASM_SIMP_TAC[
AFFINE_HULL_EQ_SPAN] THEN
MATCH_MP_TAC(SET_RULE
`!s. t
SUBSET u /\ s
SUBSET t /\ u
SUBSET s ==> t = u`) THEN
EXISTS_TAC `span {x - v1:real^3 | x
IN {v2,v3}}` THEN CONJ_TAC THENL
[REWRITE_TAC[
SUBSET] THEN MATCH_MP_TAC
SPAN_INDUCT THEN
REWRITE_TAC[SET_RULE `(\x. x
IN s) = s`] THEN
SIMP_TAC[
SUBSPACE_SPECIAL_HYPERPLANE; DIMINDEX_3; ARITH] THEN
ASM_SIMP_TAC[
FORALL_IN_INSERT;
NOT_IN_EMPTY;
IN_ELIM_THM];
ALL_TAC] THEN
CONJ_TAC THENL
[GEN_REWRITE_TAC RAND_CONV [GSYM
SPAN_SPAN] THEN
MATCH_MP_TAC
SPAN_MONO THEN
REWRITE_TAC[
SUBSET;
FORALL_IN_GSPEC;
FORALL_IN_INSERT;
NOT_IN_EMPTY] THEN
MESON_TAC[
SPAN_SUB;
SPAN_INC;
IN_INSERT;
SUBSET];
ALL_TAC] THEN
MATCH_MP_TAC
CARD_GE_DIM_INDEPENDENT THEN REPEAT CONJ_TAC THENL
[REWRITE_TAC[
SUBSET;
FORALL_IN_GSPEC;
IN_ELIM_THM;
FORALL_IN_INSERT;
NOT_IN_EMPTY] THEN
ASM_SIMP_TAC[
VECTOR_SUB_COMPONENT; DIMINDEX_3; ARITH;
REAL_SUB_REFL];
REWRITE_TAC[independent] THEN
DISCH_THEN(MP_TAC o MATCH_MP (REWRITE_RULE[
IMP_CONJ]
DEPENDENT_IMP_AFFINE_DEPENDENT)) THEN
ASM_REWRITE_TAC[
IN_INSERT;
NOT_IN_EMPTY] THEN
ASM_MESON_TAC[
AFFINE_DEPENDENT_IMP_COLLINEAR_3;
NOT_COPLANAR_NOT_COLLINEAR];
SIMP_TAC[
DIM_SPECIAL_HYPERPLANE; DIMINDEX_3; ARITH] THEN
ONCE_REWRITE_TAC[
SIMPLE_IMAGE] THEN
SIMP_TAC[
CARD_IMAGE_INJ;
FINITE_INSERT;
FINITE_RULES;
VECTOR_ARITH `x - a:real^N = y - a <=> x = y`] THEN
ASM_SIMP_TAC[
CARD_CLAUSES;
FINITE_INSERT;
FINITE_RULES;
IN_INSERT;
NOT_IN_EMPTY; ARITH]];
ALL_TAC] THEN
FIRST_ASSUM(DISJ_CASES_TAC o MATCH_MP (REAL_ARITH
`~(x = &0) ==> &0 < x \/ &0 < --x`))
THENL
[EXISTS_TAC `basis 3:real^3`; EXISTS_TAC `--(basis 3):real^3`] THEN
ASM_SIMP_TAC[
NORM_BASIS; DIMINDEX_3; ARITH;
IN_ELIM_THM;
DOT_BASIS;
NORM_NEG;
DOT_LNEG; DIMINDEX_3; ARITH;
VECTOR_SUB_COMPONENT;
REAL_SUB_REFL;
REAL_NEG_0] THEN
X_GEN_TAC `x:real^3` THEN
REWRITE_TAC[
aff_ge_def;
IN_AFFSIGN;
sgn_ge] THEN
REWRITE_TAC[SET_RULE `{a,b,c}
UNION {d} = {a,b,c,d}`] THEN
REWRITE_TAC[SET_RULE `x
IN {a} <=> a = x`] THEN
SIMP_TAC[
AFFINE_HULL_FINITE_STEP_GEN;
REAL_LE_ADD;
FINITE_INSERT;
CONJUNCT1
FINITE_RULES; REAL_ARITH `&0 <= x / &2 <=> &0 <= x`;
RIGHT_EXISTS_AND_THM] THEN
ASM_REWRITE_TAC[
RIGHT_AND_EXISTS_THM] THEN
REWRITE_TAC[REAL_ARITH `x - y:real = z <=> x = y + z`] THEN
REWRITE_TAC[VECTOR_ARITH `x - y:real^3 = z <=> x = y + z`] THEN
REWRITE_TAC[
VECTOR_ADD_RID;
REAL_ADD_RID] THEN
REWRITE_TAC[REAL_ARITH `&1 = x + y <=> x + y = &1`] THEN
EQ_TAC THEN REWRITE_TAC[
LEFT_IMP_EXISTS_THM] THENL
[MAP_EVERY X_GEN_TAC [`a:real`; `b:real`; `c:real`; `h:real`] THEN
STRIP_TAC THEN
EXISTS_TAC `a % v1 + b % v2 + c % v3 +
h % ((w:real^3)$1 % basis 1 + w$2 % basis 2):real^3` THEN
EXISTS_TAC `h * (w:real^3)$3` THEN
ASM_SIMP_TAC[
REAL_LE_MUL;
REAL_LT_IMP_LE] THEN
ASM_SIMP_TAC[
VECTOR_ADD_COMPONENT;
VECTOR_MUL_COMPONENT;
BASIS_COMPONENT;
DIMINDEX_3; ARITH;
REAL_MUL_RZERO;
REAL_ADD_RID] THEN
REWRITE_TAC[GSYM
VECTOR_MUL_ASSOC; GSYM
VECTOR_ADD_LDISTRIB;
GSYM
VECTOR_ADD_ASSOC] THEN
REPLICATE_TAC 4 AP_TERM_TAC THEN
GEN_REWRITE_TAC LAND_CONV [GSYM
BASIS_EXPANSION] THEN
REWRITE_TAC[DIMINDEX_3] THEN CONV_TAC(ONCE_DEPTH_CONV NUMSEG_CONV) THEN
SIMP_TAC[
VSUM_CLAUSES;
FINITE_INSERT; CONJUNCT1
FINITE_RULES] THEN
REWRITE_TAC[
IN_INSERT;
NOT_IN_EMPTY;
ARITH_EQ;
VECTOR_ADD_RID];
MAP_EVERY X_GEN_TAC [`y:real^3`; `h:real`] THEN STRIP_TAC THEN
UNDISCH_TAC `(vec 0:real^3)
IN affine hull {v1,v2,v3}` THEN
SUBGOAL_THEN `(y - h / (w:real^3)$3 % (w$1 % basis 1 + w$2 % basis 2))
IN affine hull {v1:real^3,v2,v3}` MP_TAC THENL
[ASM_SIMP_TAC[
IN_ELIM_THM;
VECTOR_ADD_COMPONENT;
VECTOR_MUL_COMPONENT;
VECTOR_SUB_COMPONENT;
BASIS_COMPONENT; ARITH; DIMINDEX_3] THEN
REAL_ARITH_TAC;
ALL_TAC] THEN
SIMP_TAC[
AFFINE_HULL_FINITE;
FINITE_INSERT; CONJUNCT1
FINITE_RULES;
AFFINE_HULL_FINITE_STEP;
IN_ELIM_THM] THEN
REWRITE_TAC[REAL_ARITH `x - y:real = z <=> x = y + z`] THEN
REWRITE_TAC[VECTOR_ARITH `x - y:real^3 = z <=> x = y + z`] THEN
REWRITE_TAC[
VECTOR_ADD_RID;
REAL_ADD_RID;
LEFT_IMP_EXISTS_THM] THEN
REWRITE_TAC[REAL_ARITH `&1 = x + y <=> x + y = &1`] THEN
MAP_EVERY X_GEN_TAC [`a:real`; `b:real`; `c:real`] THEN STRIP_TAC THEN
MAP_EVERY X_GEN_TAC [`a':real`; `b':real`; `c':real`] THEN
DISCH_THEN(CONJUNCTS_THEN2 ASSUME_TAC (ASSUME_TAC o SYM)) THEN
MAP_EVERY EXISTS_TAC
[`a + (&1 - (a + b + c + h / (w:real^3)$3)) * a'`;
`b + (&1 - (a + b + c + h / (w:real^3)$3)) * b'`;
`c + (&1 - (a + b + c + h / (w:real^3)$3)) * c'`; `h / (w:real^3)$3`] THEN
ASM_REWRITE_TAC[REAL_ARITH
`(a + x * a') + (b + x * b') + (c + x * c') + h:real =
(a + b + c + h) + x * (a' + b' + c')`] THEN
ASM_SIMP_TAC[
REAL_LE_DIV;
REAL_LT_IMP_LE] THEN
CONJ_TAC THENL [REAL_ARITH_TAC; ALL_TAC] THEN
REWRITE_TAC[VECTOR_ARITH
`(a + x * a') % v1 + (b + x * b') % v2 + (c + x * c') % v3 + h:real^N =
(a % v1 + b % v2 + c % v3) + x % (a' % v1 + b' % v2 + c' % v3) + h`] THEN
ASM_REWRITE_TAC[
VECTOR_MUL_RZERO;
VECTOR_ADD_LID] THEN
REWRITE_TAC[VECTOR_ARITH `(x + a) + y:real^3 = a + z <=> x + y = z`] THEN
GEN_REWRITE_TAC (RAND_CONV o RAND_CONV) [GSYM
BASIS_EXPANSION] THEN
REWRITE_TAC[DIMINDEX_3] THEN CONV_TAC(ONCE_DEPTH_CONV NUMSEG_CONV) THEN
SIMP_TAC[
VSUM_CLAUSES;
FINITE_INSERT; CONJUNCT1
FINITE_RULES] THEN
REWRITE_TAC[
IN_INSERT;
NOT_IN_EMPTY;
ARITH_EQ;
VECTOR_ADD_RID] THEN
REWRITE_TAC[
VECTOR_ADD_LDISTRIB; GSYM
VECTOR_ADD_ASSOC] THEN
ASM_SIMP_TAC[
VECTOR_MUL_ASSOC;
REAL_DIV_RMUL;
REAL_LT_IMP_NZ];
MAP_EVERY X_GEN_TAC [`a:real`; `b:real`; `c:real`; `h:real`] THEN
STRIP_TAC THEN
EXISTS_TAC `a % v1 + b % v2 + c % v3 +
h % ((w:real^3)$1 % basis 1 + w$2 % basis 2):real^3` THEN
EXISTS_TAC `h * --((w:real^3)$3)` THEN
ASM_SIMP_TAC[
REAL_LE_MUL;
REAL_LT_IMP_LE] THEN
REWRITE_TAC[VECTOR_ARITH `(x * --y) % --z:real^N = (x * y) % z`] THEN
ASM_SIMP_TAC[
VECTOR_ADD_COMPONENT;
VECTOR_MUL_COMPONENT;
BASIS_COMPONENT;
DIMINDEX_3; ARITH;
REAL_MUL_RZERO;
REAL_ADD_RID] THEN
REWRITE_TAC[GSYM
VECTOR_MUL_ASSOC; GSYM
VECTOR_ADD_LDISTRIB;
GSYM
VECTOR_ADD_ASSOC] THEN
REPLICATE_TAC 4 AP_TERM_TAC THEN
GEN_REWRITE_TAC LAND_CONV [GSYM
BASIS_EXPANSION] THEN
REWRITE_TAC[DIMINDEX_3] THEN CONV_TAC(ONCE_DEPTH_CONV NUMSEG_CONV) THEN
SIMP_TAC[
VSUM_CLAUSES;
FINITE_INSERT; CONJUNCT1
FINITE_RULES] THEN
REWRITE_TAC[
IN_INSERT;
NOT_IN_EMPTY;
ARITH_EQ;
VECTOR_ADD_RID];
MAP_EVERY X_GEN_TAC [`y:real^3`; `h:real`] THEN STRIP_TAC THEN
UNDISCH_TAC `(vec 0:real^3)
IN affine hull {v1,v2,v3}` THEN
SUBGOAL_THEN `(y - h / --((w:real^3)$3) % (w$1 % basis 1 + w$2 % basis 2))
IN affine hull {v1:real^3,v2,v3}` MP_TAC THENL
[ASM_SIMP_TAC[
IN_ELIM_THM;
VECTOR_ADD_COMPONENT;
VECTOR_MUL_COMPONENT;
VECTOR_SUB_COMPONENT;
BASIS_COMPONENT; ARITH; DIMINDEX_3] THEN
REAL_ARITH_TAC;
ALL_TAC] THEN
SIMP_TAC[
AFFINE_HULL_FINITE;
FINITE_INSERT; CONJUNCT1
FINITE_RULES;
AFFINE_HULL_FINITE_STEP;
IN_ELIM_THM] THEN
REWRITE_TAC[REAL_ARITH `x - y:real = z <=> x = y + z`] THEN
REWRITE_TAC[VECTOR_ARITH `x - y:real^3 = z <=> x = y + z`] THEN
REWRITE_TAC[
VECTOR_ADD_RID;
REAL_ADD_RID;
LEFT_IMP_EXISTS_THM] THEN
REWRITE_TAC[REAL_ARITH `&1 = x + y <=> x + y = &1`] THEN
MAP_EVERY X_GEN_TAC [`a:real`; `b:real`; `c:real`] THEN STRIP_TAC THEN
MAP_EVERY X_GEN_TAC [`a':real`; `b':real`; `c':real`] THEN
DISCH_THEN(CONJUNCTS_THEN2 ASSUME_TAC (ASSUME_TAC o SYM)) THEN
MAP_EVERY EXISTS_TAC
[`a + (&1 - (a + b + c + h / --((w:real^3)$3))) * a'`;
`b + (&1 - (a + b + c + h / --((w:real^3)$3))) * b'`;
`c + (&1 - (a + b + c + h / --((w:real^3)$3))) * c'`;
`h / --((w:real^3)$3)`] THEN
ASM_REWRITE_TAC[REAL_ARITH
`(a + x * a') + (b + x * b') + (c + x * c') + h:real =
(a + b + c + h) + x * (a' + b' + c')`] THEN
ASM_SIMP_TAC[
REAL_LE_DIV;
REAL_LT_IMP_LE] THEN
CONJ_TAC THENL [REAL_ARITH_TAC; ALL_TAC] THEN
REWRITE_TAC[VECTOR_ARITH
`(a + x * a') % v1 + (b + x * b') % v2 + (c + x * c') % v3 + h:real^N =
(a % v1 + b % v2 + c % v3) + x % (a' % v1 + b' % v2 + c' % v3) + h`] THEN
ASM_REWRITE_TAC[
VECTOR_MUL_RZERO;
VECTOR_ADD_LID] THEN
REWRITE_TAC[VECTOR_ARITH `(x + a) + y:real^3 = a + z <=> x + y = z`] THEN
GEN_REWRITE_TAC (RAND_CONV o RAND_CONV) [GSYM
BASIS_EXPANSION] THEN
REWRITE_TAC[DIMINDEX_3] THEN CONV_TAC(ONCE_DEPTH_CONV NUMSEG_CONV) THEN
SIMP_TAC[
VSUM_CLAUSES;
FINITE_INSERT; CONJUNCT1
FINITE_RULES] THEN
REWRITE_TAC[
IN_INSERT;
NOT_IN_EMPTY;
ARITH_EQ;
VECTOR_ADD_RID] THEN
REWRITE_TAC[
VECTOR_ADD_LDISTRIB; GSYM
VECTOR_ADD_ASSOC] THEN
REWRITE_TAC[
real_div;
REAL_INV_NEG;
REAL_MUL_RNEG] THEN
REWRITE_TAC[
VECTOR_MUL_RNEG;
VECTOR_MUL_LNEG; GSYM
real_div] THEN
ASM_SIMP_TAC[
VECTOR_MUL_ASSOC;
REAL_DIV_RMUL;
REAL_LT_IMP_NZ]]);;