(***************************************************************************)
(* Formalization of the Chou, Gao and Zhang's decision procedure.          *)
(* Julien Narboux (Julien@narboux.fr)                                      *)
(* LIX/INRIA FUTURS 2004-2006                                              *)
(* University of Strasbourg 2008                                           *)
(***************************************************************************)
Require Export geometry_tools.
Proof with try solve [ ring | congruence ].
intros.
assert (- -a=-0).
rewrite H...
assert (- -a=a)...
assert (-0=0)...
Qed.
Hint Resolve field_prop1 : Geom.
(** Some propositions about Col *)
Proof with uniformize_signed_areas;Geometry.
unfold Col in |- *.
intros...
Qed.
Proof with uniformize_signed_areas;Geometry.
unfold Col in |- *.
intros...
Qed.
Proof with uniformize_signed_areas;Geometry.
unfold Col in |- *.
intros...
Qed.
Proof with uniformize_signed_areas;Geometry.
unfold Col in |- *.
intros...
Qed.
Proof with uniformize_signed_areas;Geometry.
unfold Col in |- *.
intros...
Qed.
Hint Resolve col_1 col_2 col_3 col_4 col_5: Geom.
(** Proposition about equality and nullity of geometric quantities *)
intros.
assert (A ** B = 0 <-> A = B).
apply A1b.
intuition.
Qed.
Hint Resolve noteqnotzero: Geom.
Proof with try solve [ Geometry | congruence ].
intros.
unfold Col.
rewrite H...
Qed.
unfold Col in |- *.
intros.
intuition.
assert (T := egalcol A B C H0).
auto.
Qed.
intros.
assert (~ Col A B C -> ~ Col B C A).
intuition.
assert (~ Col B C A).
auto.
eapply notcolnotegal_1.
apply H1.
Qed.
intros.
assert (~ Col A B C -> ~ Col A C B).
intuition.
assert (~ Col A C B).
auto.
eapply notcolnotegal_1.
apply H1.
Qed.
Hint Resolve notcolnotegal_1 notcolnotegal_2 notcolnotegal_3: Geom.
Hint Resolve notparallelnotegal_1 notparallelnotegal_2 : Geom.
(** Some usefull lemmas about ratios of signed distances *)
Proof with Geometry.
intros.
uniformize_dir_seg.
field...
Qed.
Hint Resolve dirseg_1: Geom.
Proof with Geometry.
intros.
uniformize_dir_seg.
rewrite H.
auto.
Qed.
Hint Resolve dirseg_2: Geom.
(* Theorem dirseg_1 : (A,B,C,D:Point) C<>D -> -(A**B/C**D) = B**A /C**D. Proof with Geometry. Intros. Replace A**B with -B**A. Field. Symmetry. Qed.  Theorem dirseg_2 : (A,B,C,D:Point) C<>D -> -(A**B/C**D) = A**B /D**C. Proof with Geometry. Intros. Replace C**D with -D**C. Field. Symmetry. Qed.   Hints Resolve dirseg_1 dirseg_2 : Geom. *)
Proof with Geometry.
intros.
uniformize_dir_seg.
field...
Qed.
Proof with Geometry.
intros...
uniformize_dir_seg.
field...
Qed.
Hint Resolve dirseg_3 dirseg_4: Geom.
Proof with Geometry.
intros.
uniformize_signed_areas.
field...
Qed.
Hint Resolve dirsur_1: Geom.
Proof with Geometry.
intros.
assert (S A B C = S A B D + S A D C + S D B C)...
rewrite H0 in H2.
rewrite H1 in H2.
cases_col A D C...
cases_equality C A...
apply egalcol...
NormalizeRing H2...
assert (C ** B / C ** A = S D C B / S D C A)...
assert (C ** A + A ** B = C ** B)...
rewrite <- H6 in H5...
assert ((C ** A + A ** B) / C ** A = 1 + A ** B / C ** A)...
field...
rewrite H7 in H5.
clear H7 H6.
assert (S D B C = - S D C B)...
rewrite H6 in H2...
assert (S A D C = S D C A)...
rewrite H7 in H2...
IsoleVarRing (S D C B) H2...
rewrite H2 in H5...
assert (S D C A / S D C A = 1)...
field...
rewrite H8 in H5.
clear H6 H7 H8.
IsoleVarRing (A ** B) H5...
assert (A = B)...
intuition...
Qed.
Hint Resolve col_trans_1 : Geom.
Proof with Geometry.
assert ({A : Point &  {B : Point &  {C : Point | ~ Col A B C}}}).
apply A4.
intros.
elim H;intro X;intros.
elim p;intro Y;intros.
elim p0;intro Z;intros.
cases_col A B X.
cases_col A B Y.
cases_col A B Z.
cases_equality Y A.
subst Y.
assert (Col A X Z).
eapply col_trans_1 with (B:=B)...
assert (Col X A Z)...
intuition.
assert (Col A Y Z).
eapply col_trans_1 with (B:=B)...
assert (Col A Y X).
eapply col_trans_1 with (B:=B)...
assert (Col Y X Z).
eapply col_trans_1 with (B:=A)...
assert (Col X Y Z)...
intuition.
exists Z...
exists Y...
exists X...
Qed.
Proof with Geometry.
intros.
assert ({A : Point &  {B : Point &  {C : Point | ~ Col A B C}}}).
apply A4.
DecompEx H A1.
DecompEx p B.
DecompEx p0 C.
cases_equality A B.
subst A.
exists A1.
exists C...
assert  (T:=build_point_not_collinear_1 A B H).
DecompEx T C1.
exists B.
exists C1...
Qed.
Proof with Geometry.
intros.
unfold not in |- *; intro.
assert (Col A O P)...
assert (Col A O B)...
assert (Col A P B)...
eauto with Geom...
Qed.
Hint Resolve col_not_col_1 : Geom.
Proof with try solve [ Geometry | congruence ].
intros...
assert (P ** M / Q ** M = M ** P / M ** Q)...
assert (M ** P / M ** Q = S A M P / S A M Q)...
assert (S A M P = S P A M)...
assert (S A M Q = S Q A M)...
Qed.
Hint Resolve A6_1: Geom.
Proof with try solve [ Geometry | congruence ].
intros...
assert (P ** R / P ** Q = S A P R / S A P Q)...
assert (S A P R = S R A P)...
assert (S A P Q = S Q A P)...
Qed.
Hint Resolve A6_2: Geom.
Proof with Geometry.
intros...
assert (C ** A = - A ** C)...
assert (S P C A = - S P A C)...
assert (C ** B / C ** A = S P C B / S P C A)...
rewrite H3 in H4...
rewrite H2 in H4...
RewriteVar (C ** B) H4...
field...
Qed.
Hint Resolve A6_3: Geom.
Proof with Geometry.
intros...
assert (A ** C / B ** A = S P A C / S P B A)...
assert (A ** C / B ** A = C ** A / A ** B)...
assert (S P C A / S P A B = S P A C / S P B A)...
congruence...
Qed.
Hint Resolve A6_4: Geom.
Proof with Geometry.
intros...
assert (P ** A / O ** A = S P B A / S O B A)...
assert (S P A B = - S P B A)...
assert (S O A B = - S O B A)...
rewrite H3...
rewrite H4...
rewrite H2...
assert (S O B A <> 0)...
field...
Qed.
Hint Resolve A6_5: Geom.
Proof with Geometry.
intros...
assert (S R A B / S Q A B = S R B A / S Q B A)...
rewrite H2...
Qed.
Hint Resolve A6_6: Geom.
Proof with try solve [ Geometry | congruence | field; Geometry ].
intros...
cases_equality C A...
assert (Col A B D)...
rewrite H4...
symmetry  in |- *...
assert (S P C D / S P A B = S P C D / S P C A * (S P C A / S P A B))...
assert (A <> C)...
assert (Col C D A)...
eauto with Geom...
assert (C ** D / C ** A = S P C D / S P C A)...
assert (A ** C / A ** B = S P A C / S P A B)...
assert (C ** A / A ** B = S P C A / S P A B)...
assert (C ** D / C ** A * (C ** A / A ** B) = C ** D / A ** B)...
Qed.
Proof with Geometry.
intros...
unfold parallel in H...
unfold S4 in H...
unfold not in |- *; intro...
assert (S P U Q = 0)...
rewrite H0...
assert (S P Q V = 0)...
rewrite H0...
rewrite H1 in H...
rewrite H2 in H...
Qed.
intros.
cases_col P U Q.
unfold parallel in H.
unfold S4 in H.
rewrite H0 in H.
assert (0 + S P Q V = S P Q V).
ring.
rewrite H1 in H.
right.
unfold Col in |- *.
trivial.
left.
trivial.
Qed.
Proof with try solve [ Geometry | congruence | field; Geometry ].
intros...
assert
(S P A B / S Q A B =
S P A B / S P A M * (S P A M / S Q A M * (S Q A M / S Q A B)))...
assert (A <> B); eauto with Geom...
assert (A <> M); eauto with Geom...
assert (A ** B / A ** M * (P ** M / Q ** M * (A ** M / A ** B)) = P ** M / Q ** M)...
assert (A ** B / A ** M = S P A B / S P A M)...
assert (P ** M / Q ** M = S P A M / S Q A M)...
assert (A ** M / A ** B = S Q A M / S Q A B)...
Qed.

Theorem co_side :
forall A B P Q M : Point,
~ Col Q A B ->
Q <> M -> Col A B M -> Col P Q M -> P ** M / Q ** M = S P A B / S Q A B.