(***************************************************************************)
(* 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.

Theorem l2_11a_strong_strong_strong :
forall A B C D P Q : Point,
weak_3_parallelogram A B C D -> S A P Q + S C P Q = S B P Q + S D P Q.