(***************************************************************************)
(* 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 construction_lemmas.
Definition weak_parallelogram (A B C D : Point) : Prop :=
A<>C /\ B<>D /\
exists O, mid_point O A C /\ mid_point O B D.
Proof with Geometry.
intros.
unfold weak_parallelogram in H0.
DecompAndAll.
DecompExAnd H4 X.
unfold parallelogram.
assert (parallel A B C D).
eapply diag_mid_point_parallel;eauto.
repeat split;try assumption.
cut (parallel C B A D).
Geometry.
eapply diag_mid_point_parallel.
2:apply H5.
unfold mid_point in *;DecompAndAll;Geometry.
Qed.
Proof with Geometry.
intros.
unfold weak_parallelogram in H.
DecompAndAll.
DecompExAnd H3 X.
unfold mid_point in *.
DecompAndAll.
assert (S A P Q + S C P Q = 2 * S X P Q).
apply mid_point_equation; Geometry.
assert (S B P Q + S D P Q = 2 * S X P Q).
apply mid_point_equation; Geometry.
congruence.
Qed.
Definition weak_2_parallelogram (A B C D : Point) : Prop :=
(A=C <-> B=D) /\
exists O, mid_point O A C /\ mid_point O B D.
(** We choose the most general notion such that l2_11 is still valid *)
Definition  weak_3_parallelogram (A B C D : Point) : Prop :=
exists O, mid_point O A C /\ mid_point O B D.
Hint Resolve weak_para_1 : Geom.
Proof with Geometry.
intros.
unfold weak_3_parallelogram in H0.
cases_equality P Q.
subst P.
basic_simpl...
subst C.
cases_col A P Q.
rewrite H.
ring_simplify.
DecompExAnd H0 X.
assert (X=A)...
subst X.
clear H3.
unfold mid_point in H4.
DecompAndAll.
cases_equality A D.
subst D.
basic_simpl.
assert (B=A)...
subst B.
rewrite H;ring.
cases_equality P D.
subst P.
basic_simpl.
assert (Col D B Q).
eapply col_trans_1 with (B:= A)...
assert (Col B D Q)...
cases_col D P Q.
rewrite H5.
ring_simplify.
assert (Col P A D).
eapply col_trans_1 with (B:=Q)...
assert (Col A B P).
eapply col_trans_1 with (B:=D)...
assert (Col D B P).
eapply col_trans_1 with (B:=A)...
assert (Col P B Q).
eapply col_trans_1 with (B:=D)...
assert (Col B P Q)...
assert (A<>B).
unfold not;intro.
subst A.
basic_simpl...
cases_equality P A.
subst P.
clear H H4.
assert (A ** B / A ** D = S Q A B / S Q A D).
apply A6...
rewrite <- H2 in H.
replace (A**B/B**A) with (- (1)) in H.
IsoleVar (S Q A B) H.
replace (S B A Q) with (- S Q A B).
rewrite H.
uniformize_signed_areas.
ring.
Geometry.
Geometry.
replace (A**B) with (- B**A).
field...
symmetry...
assert (B ** A / D ** A = S B P Q / S D P Q).
apply co_side...
rewrite H2 in H8.
replace (A**D/D**A) with (-(1)) in H8.
RewriteVar (S D P Q) H8.
field...
eapply nonzerodiv...
unfold not;intro.
assert (Col B P Q)...
assert (Col P A B).
eapply col_trans_1 with (B:=Q)...
assert (Col A P D).
eapply col_trans_1 with (B:=B)...
assert (Col P Q D).
eapply col_trans_1 with (B:=A)...
intuition.
replace (A**D) with (- D**A).
field...
symmetry;Geometry.
DecompExAnd H0 X.
assert (X=A)...
subst X.
clear H3.
unfold mid_point in H4.
DecompAndAll.
cases_equality B D.
subst D.
assert (A=B).
replace (A**B) with (- B**A) in H2.
assert (B**A=0)...
symmetry...
symmetry...
subst B.
auto.
assert (S B P Q + S D P Q = 2 * S A P Q).
apply mid_point_equation...
rewrite H4.
ring.
Qed.
Proof with Geometry.
intros.
cases_equality A C.
apply  l2_11a_strong_strong_strong_aux...
cases_equality B D.
symmetry.
apply  l2_11a_strong_strong_strong_aux...
unfold weak_3_parallelogram in *.
DecompExAnd H X.
exists X.
intuition.
apply l2_11a_strong.
unfold weak_parallelogram.
intuition.
Qed.
Proof with Geometry.
intros.
unfold S4 in |- *.
assert (S P A Q = - S A P Q)...
assert (S P Q B = S B P Q)...
assert (S P D Q = - S D P Q)...
assert (S P Q C = S C P Q)...
rewrite H0.
rewrite H1.
rewrite H2.
rewrite H3.
assert (T := l2_11a A B C D P Q H)...
RewriteVar (S A P Q) T...
ring...
Qed.
Proof with Geometry.
intros.
unfold S4 in |- *.
assert (S P A Q = - S A P Q)...
assert (S P Q B = S B P Q)...
assert (S P D Q = - S D P Q)...
assert (S P Q C = S C P Q)...
rewrite H0.
rewrite H1.
rewrite H2.
rewrite H3.
assert (T := l2_11a_strong_strong A B C D P Q H)...
RewriteVar (S A P Q) T...
ring...
Qed.
Proof with Geometry.
intros.
unfold S4 in |- *.
assert (S P A Q = - S A P Q)...
assert (S P Q B = S B P Q)...
assert (S P D Q = - S D P Q)...
assert (S P Q C = S C P Q)...
rewrite H0.
rewrite H1.
rewrite H2.
rewrite H3.
assert (T := l2_11a_strong_strong_strong A B C D P Q H)...
RewriteVar (S A P Q) T...
ring...
Qed.
Proof with Geometry.
intros.
assert (S B D C = S A D C).
assert (S A D C + S C D C = S B D C + S D D C).
apply l2_11a...
basic_simpl...
assert (S4 D B C P = S D B C + S D C P)...
assert (S4 D B C P = S P D C - S A D C).
rewrite H1.
uniformize_signed_areas.
rewrite H0.
ring.
assert (S P A B = S P D B - S P C B).
assert (S A B P + S C B P = S D B P + S B B P).
apply l2_11a...
basic_simpl.
uniformize_signed_areas.
rewrite <- H3.
ring.
rewrite H3.
assert (S4 D B C P = S D B P - S C B P)...
uniformize_signed_areas.
congruence.
Qed.
Proof with Geometry.
intros.
assert (S B D C = S A D C).
assert (S A D C + S C D C = S B D C + S D D C).
apply l2_11a_strong_strong_strong...
basic_simpl...
assert (S4 D B C P = S D B C + S D C P)...
assert (S4 D B C P = S P D C - S A D C).
rewrite H1.
uniformize_signed_areas.
rewrite H0.
ring.
assert (S P A B = S P D B - S P C B).
assert (S A B P + S C B P = S D B P + S B B P).
apply l2_11a_strong_strong_strong...
unfold weak_3_parallelogram in *.
DecompExAnd H Z.
exists Z;split...
basic_simpl.
uniformize_signed_areas.
rewrite <- H3.
ring.
rewrite H3.
assert (S4 D B C P = S D B P - S C B P)...
uniformize_signed_areas.
congruence.
Qed.
Proof with Geometry.
intros.
replace (S4 P D A C) with (S P D C - S A D C)...
apply l2_12a...
Qed.
Proof with Geometry.
intros.
replace (S4 P D A C) with (S P D C - S A D C)...
apply l2_12a_strong_3...
Qed.
Proof with Geometry.
unfold parallel,S4 in |- *.
intros.
assert (S R A P = S R A Q + S R Q P + S Q A P)...
assert (Col R Q P)...
rewrite H4 in H3.
NormalizeRing H3...
assert (S A R Q = - S R A Q)...
rewrite H5 in H1.
RewriteVar (S R A Q) H1...
assert (S4 B A P Q = S B A P + S B P Q)...
assert (S B P Q = - S B Q P)...
rewrite H7 in H6.
RewriteVar (S B Q P) H2...
NormalizeRing H6...
assert (S C A P = S C A B + S C B P + S B A P)...
assert (Col C A B)...
rewrite H9 in H8...
assert (S C B P = S B P C)...
rewrite <- H10 in H6...
assert (S4 B A P Q = S C A P)...
rewrite H8.
rewrite H6.
ring_simplify...
cut (S A Q B + S Q A P = S4 B A P Q).
intro.
rewrite H12 in H3.
rewrite H11 in H3.
assert (S A P C = S C A P)...
rewrite H13.
rewrite <- H3.
assert (S A R P = - S R A P)...
rewrite H14.
ring.
assert (S A Q B = S B A Q)...
rewrite H12.
assert (S4 B A P Q = S B A Q - S P A Q)...
rewrite H13.
assert (S Q A P = - S P A Q)...
rewrite H14.
ring.
Qed.
Proof with Geometry.
intros.
assert (S C B Y = S Z B Y).
unfold parallel, S4 in H4.
assert (S B C Y = - S C B Y)...
rewrite H7 in H4.
RewriteVar (S C B Y) H4...
assert (S A B Y = S X B Y)...
assert (parallel B Y A X)...
unfold parallel, S4 in H8.
assert (S B A Y = - S A B Y)...
assert (S B Y X = S X B Y)...
rewrite H9 in H8.
rewrite H10 in H8.
RewriteVar (S A B Y) H8...
assert (A ** B / C ** B = S A B Y / S C B Y)...
assert (X ** Y / Z ** Y = S X B Y / S Z B Y)...
congruence...
Qed.
Proof with Geometry.
intros.
assert (~ Col Z B Y).
unfold not in |- *; intro.
unfold parallel in H3.
unfold S4 in H3.
assert (Col B Y Z)...
rewrite H5 in H3.
NormalizeRing H3...
assert (C <> B); eauto with Geom...
assert (Z <> Y); eauto with Geom...
apply l1_25_aux...
Qed.
Proof with Geometry.
intros.
apply l1_25...
Qed.
Proof with Geometry.
intros.
cases_equality B' A'.
subst.
assert (S<>A').
intro.
subst.
intuition.
replace (S ** A' / S ** A') with 1.
2:field;auto with Geom.
cases_equality A B.
subst.
field.
intro.
assert (S=B).
auto with Geom.
subst.
intuition.
assert (Col A A' S).
apply  (col_trans_1 A B A' S).
assumption.
unfold parallel, S4 in *.
basic_simpl.
auto with Geom.
auto with Geom.
assert (Col S A A') by auto with Geom.
intuition.
assert (S<>A).
intro;subst.
intuition.
assert (S<>A').
intro;subst.
intuition.
cases_equality A B.
subst.
replace (S ** B / S ** B) with 1.
2:field.
2:auto with Geom.
clear H0.
assert (Col A' B' B).
unfold parallel, S4 in *.
basic_simpl.
auto with Geom.
assert (Col A' S B).
apply (col_trans_1 A' B' S B);auto with Geom.
assert (Col S B A');auto with Geom.
intuition.
assert (S ** A / B ** A = S ** A' / B' ** A').
apply (thales S A B B' A');auto with Geom.
intro.
assert (Col A A' S).
apply (col_trans_1 A B A' S);auto with Geom.
intuition.
assert (B**A/S**A= B'**A' / S**A').
assert (S ** A / B ** A * B**A =  S** A' / B' ** A' * B**A).
rewrite H7.
auto.
replace (S ** A / B ** A * B ** A) with (S**A) in H8.
2:field;auto with Geom.
field_simplify_eq.
rewrite H8.
field.
auto with Geom.
split;auto with Geom.
assert ( A**B / S ** A =  A'**B' / S ** A').
uniformize_dir_seg.
IsoleVar (A**B) H8.
rewrite H8.
field;split;auto with Geom.
auto with Geom.
assert (1+ A ** B / S ** A = 1+ A' ** B' / S ** A').
rewrite H9.
auto.
replace (1 + A ** B / S ** A) with ((S**A + A**B) / S**A) in H10.
2:field;auto with Geom.
replace (1 + A' ** B' / S ** A') with ((S**A' + A'**B') / S**A') in H10.
2:field;auto with Geom.
assert (S**A + A**B=S**B).
apply chasles;auto with Geom.
assert (S**A' + A'**B'=S**B').
apply chasles;auto with Geom.
rewrite H11 in H10.
rewrite H12 in H10.
assumption.
Qed.

Theorem on_line_dex_spec :
forall P Q C D : Point, P <> Q -> {Y : Point | Col Y P Q /\ P ** Y = C ** D}.