(***************************************************************************)
(* 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 advanced_parallel_lemmas.
Require Export geometry_tools.
(*********************************************************************)
(*  Elimination Theorems                                               *)
(*********************************************************************)
(* Area elimination *)
unfold on_line in |- *.
Proof with Geometry.
unfold on_inter_parallel_parallel in |- *.
unfold parallel in |- *.
intros.
assert (S4 G C H D = - S4 C G D H)...
rewrite H1 in H0.
intuition.
Qed.
Proof with Geometry.
intros.
unfold on_line_d in *.
DecompAndAll.
RewriteVar lambda H3...
clear H3.
assert (1 - P ** Y / P ** Q = Y ** Q / P ** Q)...
assert (Y ** P + P ** Q = Y ** Q)...
rewrite <- H1...
assert (P ** Y = - Y ** P)...
rewrite H3; field...
rewrite H1...
replace (S A B Y) with (S Y A B)...
replace (S A B Q) with (S Q A B)...
replace (S A B P) with (S P A B)...
apply l2_9...
Qed.
Proof with Geometry.
intros.
assert (on_line_d Y P Q (P ** Y / P ** Q)).
apply on_line_to_on_line_d...
apply elim_area_on_line_d...
Qed.
Proof with Geometry.
intros.
unfold inter_ll in *.
DecompAndAll.
assert (P <> Q);eauto with Geom.
assert (S Y A B = P ** Y / P ** Q * S Q A B + Y ** Q / P ** Q * S P A B)...
apply l2_9...
unfold parallel in H3.
assert (P ** Y / P ** Q = S P U V / S4 P U Q V)...
assert (Q ** Y / P ** Q = S Q U V / S4 P U Q V)...
replace (Q**Y) with (- Y**Q) in H5.
2:symmetry;Geometry.
uniformize_signed_areas.
IsoleVar (Y ** Q) H5...
rewrite H1.
rewrite H4.
rewrite H5.
field...
Qed.
Proof with Geometry.
intros.
unfold on_parallel_d in H.
DecompAndAll.
cases_equality R Y.
subst R;basic_simpl.
IsoleVar lambda H3...
assert (lambda = 0).
rewrite H3.
field...
rewrite H1.
ring.
assert (parallel R Y P Q)...
assert (Th := on_line_dex_spec_strong_f R Y P Q H1 H)...
DecompExAnd Th T.
assert (R <> T).
unfold not;intro;subst R;basic_simpl...
assert (S A B Y = lambda * S A B T + (1 - lambda) * S A B R).
apply elim_area_on_line_d.
rewrite <- H7 in H3.
unfold on_line_d in *...
assert (S R A B + S Q A B = S T A B + S P A B).
apply l2_11a_strong_strong_strong...
IsoleVar (S T A B) H9.
uniformize_signed_areas.
rewrite H9 in H6.
replace (S4 A P B Q) with (S Q A B - S P A B).
rewrite H6;ring.
unfold S4 in |- *;uniformize_signed_areas;ring.
Qed.

Theorem elim_area_on_parallel :
forall A B P Q R Y : Point,
on_parallel Y R P Q ->
S A B Y = S A B R + R ** Y / P ** Q * S4 A P B Q.