(***************************************************************************)
(* 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.
Definition Py A B C := A**B * A**B + B**C * B**C - A**C * A**C.
Definition Py4 A B C D := Py A B D - Py C B D.
Definition per A B C := Py A B C = 0.
Definition perp A B C D := Py4 A C B D = 0.
Definition on_foot (Y P U V : Point) := perp Y P U V /\ Col Y U V /\ U<>V.
(* We introduce three additionnal axioms *)
(* We use the square to get rid of sign issues *)
Hint Rewrite pyth_simpl_1  pyth_simpl_2 : seg_simplifications.
Hint Resolve pyth_simpl_1 pyth_simpl_2 : Geom.
Hint Resolve pyth_sym : Geom.
Hint Immediate pyth_simpl_4 : Geom.
Ltac uniformize_pys :=
repeat (rewrite pyth_simpl_1);
repeat (rewrite pyth_simpl_2);
repeat
match goal with
|  |- context [(Py ?A ?B ?C)] =>
(match goal with
|  |- context [(Py C B A)] => rewrite (pyth_sym A B C) in *
end)
|  |- context [(Py ?A ?B ?A)] =>
(match goal with
|  |- context [(Py B A B)] => rewrite (pyth_simpl_4 A B) in *
end)
end.
Hint Resolve py4_1 py4_2 py4_3 py4_4 py4_5 py4_6 py4_7 : Geom.
Hint Resolve
py4_simpl_1
py4_simpl_2
py4_simpl_3
py4_simpl_4
py4_simpl_5
py4_simpl_6 : Geom.
Hint Rewrite
pyth_simpl_1
pyth_simpl_2
py4_simpl_1
py4_simpl_2
py4_simpl_3
py4_simpl_4
py4_simpl_5
py4_simpl_6 : py_simplifications.
Ltac py_simpl := autorewrite with py_simplifications in *.
intros.
py_simpl.
ring.
Qed.

Lemma perp_4 : forall A B C D,
perp A B C D -> perp C D A B.