(***************************************************************************)
(* Formalization of the Chou, Gao and Zhang's decision procedure.          *)
(* Julien Narboux (Julien@narboux.fr)                                      *)
(* LIX/INRIA FUTURS 2004-2006                                              *)
(* University of Strasbourg 2008                                           *)
(***************************************************************************)

(* Specifications: *)
Lemma perp_bissect_perp : forall A B M C,
is_midpoint M A B ->
on_perp C M B ->
perp C M A B.
Lemma perp_bissect_eq_distance : forall A B M C,
is_midpoint M A B ->
on_perp C M B ->
eq_distance C A C B.
Lemma perp_bissect_eq_angle : forall A B M C,
is_midpoint M A B ->
on_perp C M B ->
eq_angle C A B A B C.
Lemma rectangle_1 : forall A B C D,
on_perp C B A ->
on_parallel_d D C A B (0-1) ->
perp A D  A B.
Lemma rectangle_2 : forall A B C D,
on_perp C B A ->
on_parallel_d D C A B (0-1) ->
parallel A D B C.
Lemma rectangle_3 : forall A B C D I,
on_perp C B A ->
on_parallel_d D C A B (0-1) ->
inter_ll I A C B D ->
parallel A I A C ->
A<> C ->
A <> I ->
A ** I / A ** C = 1 / 2.
Lemma square_1 : forall A B C D,
on_perp_d C B A 1 ->
on_parallel_d D C A B (0-1) ->
eq_distance A B B C.
Lemma square_2 : forall A B C D,
on_perp_d C B A 1 ->
on_parallel_d D C A B (0-1) ->
eq_distance A B C D.
Lemma circle_square_triangle : forall A B C M,
is_midpoint M B C ->
on_perp C A B ->
eq_distance M B M A.
Lemma l_6_264 : forall A B C F H,
on_perp_d F A B 1 ->
on_perp_d H A C (0-1) ->
S A B C = S A H F.
Lemma l_6_266 : forall A B C F H N,
on_perp_d F A B 1 ->
on_perp_d H A C (0-1) ->
is_midpoint N F H ->
perp N A B C.
Lemma l_6_267 : forall A B C F H,
on_perp_d F A B 1 ->
on_perp_d H A C (0-1) ->
eq_distance F C B H.
Lemma l_6_268 : forall A B C F H,
on_perp_d F A B 1 ->
on_perp_d H A C (0-1) ->
perp F C B H.
Lemma l_6_269 : forall A B C D F E G,
on_perp_d D B A 1 ->
on_foot F D B C ->
on_perp_d E C A (0-1) ->
on_foot G E B C ->
S A B C = S B D F + S C G E.
Lemma l_6_270 : forall A B C E G P,
on_perp_d E B A 1 ->
on_perp_d G C A (0-1) ->
is_midpoint P E G ->
eq_distance B P C P.
Lemma l_6_271 : forall B C D G E r,
on_perp_d B C D 1 ->
on_line_d G C D r ->
on_line_d E C B (0-r) ->
perp D E B G.
Lemma l6_222 : forall A B C D P Q R S,
is_midpoint P A B ->
is_midpoint Q B C ->
is_midpoint S D A ->
is_midpoint R C D ->
Py A C A + Py B D B = 2* (Py Q S Q + Py P R P).
Lemma l_3_40 : forall A B C E G,
on_perp_d E A B 1 ->
on_perp_d G A C (0 - 1) ->
perp E C G B.
Lemma l_3_41 : forall A B C D F M,
on_perp_d D C A 1 ->
on_perp_d F C B (0-1) ->
is_midpoint M A B ->
perp D F C M.
Lemma test_elim : forall A B C D Q,
is_midpoint Q B C ->
Py A Q A + Py A Q D = Py Q A Q + Py A Q D.
Lemma l3_43 : forall O A B X Y C D P Q R T r,
mratio C A B r ->
mratio D A B (0-r) ->
inter_ll P O A X Y ->
inter_ll Q O B X Y ->
inter_ll R O C X Y ->
inter_ll T O D X Y ->
parallel P R R Q ->
R<>Q ->
parallel T P T Q ->
T<>Q ->
P<>T ->
P<>R ->
~ Col P X Y ->
harmonic P Q R T.
Theorem Ceva :
forall A B C D E F G P : Point,
inter_ll D B C A P ->
inter_ll E A C B P ->
inter_ll F A B C P ->
F <> B ->
D <> C ->
E <> A ->
parallel A F F B ->
parallel B D D C ->
parallel C E E A ->
(A ** F / F ** B) *  (B ** D / D ** C) *  (C ** E / E ** A) = 1.
Lemma l6_217 : forall A B C D E F G H,
is_midpoint E A B  ->
is_midpoint F B C ->
is_midpoint G C D ->
is_midpoint H D A ->
parallel H E G F ->
G<>F ->
E<>H ->
~ Col E D A ->
H**E / G**F = 1.
Theorem Menelaus :
forall A B C X Y D E F : Point,
inter_ll D B C X Y ->
inter_ll E A C X Y ->
inter_ll F A B X Y ->
F <> B ->
D <> C ->
E <> A ->
parallel A F F B ->
parallel B D D C ->
parallel C E E A ->
(A ** F / F ** B) * (B ** D / D ** C) * (C ** E / E ** A) = - (1).
Theorem Pascal :
forall A B C A' B' C' : Point, A<>C' ->
on_line C A B ->
on_parallel B' A B A' ->
on_inter_line_parallel C' A A' B' C A' ->
parallel B C' B' C.
Theorem Desargues :
forall A B C X A' B' C' : Point, A' <>C' -> A' <> B' ->
on_line A' X A ->
on_inter_line_parallel B' A' X B A B ->
on_inter_line_parallel C' A' X C A C ->
parallel B C B' C'.
Theorem ex1_6auto :
forall A B C D E F G P : Point,
inter_ll D B C A P ->
inter_ll E A C B P ->
inter_ll F A B C P ->
A <> D ->
B <> E ->
C <> F ->
parallel P D A D ->
parallel P E B E ->
parallel P F C F ->
P ** D / A ** D + P ** E / B ** E + P ** F / C ** F = 1.
Theorem th2_41 :
forall A B C D P Q M : Point,
on_line C A P ->
on_inter_line_parallel D C B P A B ->
inter_ll Q A D B C ->
inter_ll M A B P Q ->
B <> M ->
parallel A M B M ->
C<>D ->
A ** M / B ** M = - (1).
Lemma essai : forall A B C,
let x := S A B C + 2 in
let y := S B C A + 2 in
x = y.
Lemma l6_17 : forall A B R P Q S C F,
on_line P B R ->
on_line Q A R ->
inter_ll S A P B Q ->
inter_ll C R S A B ->
inter_ll F P Q A B ->
parallel A C B C ->
parallel A F B F ->
B<>C -> B<>F ->
A**C / B**C = - A**F / B**F.
Lemma l6_52 : forall A B C D E F,
is_midpoint E A C ->
is_midpoint F A B ->
is_midpoint D B C ->
2*(Py A D A)+2*(Py F C F) +2*Py B E B =
(2+1)/2 * (Py A C A + Py A B A + Py B C B).
Lemma l6_55 : forall A B C E G,
is_midpoint E A C ->
on_line_d G B E (2/(2+1)) ->
1+2 <> 0 ->
(2+1) * (Py A G A + Py G C G + Py B G B) =
Py A C A + Py A B A + Py B C B.
Lemma l6_56 : forall A B C E G M,
is_midpoint E A C ->
on_line_d G B E (2/(2+1)) ->
1+2 <> 0 ->
(2+1) * Py M G M + Py A G A + Py G C G + Py B G B =
Py A M A + Py B M B + Py C M C.
Lemma l6_67 : forall A B C F E,
on_foot F C A B ->
on_foot E B A C ->
Py B A F = Py C A E.
Lemma l6_69 : forall A B C D E F,
on_foot F C A B ->
on_foot E B A C ->
on_foot D A B C ->
eq_angle E D C B D F.
Lemma l6_197 : forall A B C E F G,
on_foot E A B C ->
on_foot F B A C ->
on_foot G C A B ->
2 * Py A B C * Py B A C * Py A C B * S A B C =
Py A B A * Py B C B * Py A C A * S E F G.
Lemma l6_218 : forall A B C D E F G H,
is_midpoint E A B  ->
is_midpoint F B C ->
is_midpoint G C D ->
is_midpoint H D A ->
2* S4 E F G H = S4 A B C D.
Lemma l6_224 : forall A B C D N M P r,
is_midpoint N A C ->
is_midpoint M B D ->
on_line_d P N M r ->
S P A B + S P C D = S P D A + S P B C.
Lemma l6_223 : forall A B C D X Y W,
is_midpoint X C A ->
is_midpoint Y B D ->
inter_ll W B C D A ->
S4 B C D A = (2+2)* S X Y W.
Lemma midpoint_elim : forall O A B,
on_line_d O A B (1 / 2) ->
O<>A ->
B ** O / O ** A =1.
Lemma l6_15 : forall A B O C D r,
is_midpoint O A B ->
on_line_d C O A r ->
on_line_d D O A (1/r) ->
r <> 0 ->
parallel A C C B ->
parallel D A D B ->
C<>B ->
D<>B ->
A<>D ->
A<>C ->
r+1 <> 0 ->
harmonic A B C D.
Lemma l_6_295 : forall A B C D F P Q R S,
on_foot F B A C ->
on_line D B F ->
is_midpoint P A B ->
is_midpoint Q B C ->
is_midpoint R C D ->
is_midpoint S D A ->
eq_distance S Q P R.
Lemma l6_63 : forall A B C D E H,
on_foot D C A B ->
on_foot E B A C ->
inter_ll H C D B E ->
Py C H D = Py B H E.
Lemma l_6_273 : forall B C X A A1 C1,
on_perp_d A B C 1 ->
on_foot A1 A B X ->
on_foot C1 C B X ->
eq_distance A A1 B C1.
Lemma l6_144 : forall A B I A1 A2 B1 B2 C,
on_foot A1 B I A ->
on_line_d A2 A1 B (0-1) ->
on_foot B1 A I B ->
on_line_d B2 B1 A (0-1) ->
inter_ll C A A2 B B2 ->
eq_angle A C I I C B.
Lemma l3_44: forall O A X P Q U R G r N,
on_line_d P O A r ->
inversion Q P O A ->
is_midpoint U P O ->
inter_lc R O X U N ->
inversion G R O A ->
perp G Q O A.
Theorem example6_9 : forall L M N A B C SS:Point,
parallel A M M C ->
parallel A N N B ->
parallel A SS SS L ->
M<>C ->
N<>B ->
SS<>L ->
inter_ll L B C A SS ->
inter_ll N B A C SS ->
inter_ll M A C B SS ->
A**M/M**C+A**N/N**B = A**SS/SS**L.
Theorem th6_41_b : forall A B C M N L P K X1 X2:Point,
is_midpoint M A B ->
is_midpoint N A C ->
is_midpoint K B C ->
on_parallel X1 A C M ->
on_parallel X2 K B N ->
inter_ll P X1 A X2 K ->
is_midpoint L A K ->
B<>C ->
parallel L P B C ->
2+2<>0 ->
L<>P ->
L**P / B**C = (1+2)/(2+2).
Lemma th6_232 : forall A B C D P Q,
on_parallel_d D A B C 1 ->
is_midpoint P B D ->
is_midpoint Q A C ->
parallel P Q A B.
Lemma th6_234_1 : forall A B C D O E F,
on_parallel D A B C ->
inter_ll O A C B D ->
on_inter_line_parallel E O B C A B ->
on_inter_line_parallel F O A D A B ->
Col O E F.
Lemma th6_239 : forall A B C D P Q R A1 D1 J,
is_midpoint Q B C ->
is_midpoint P B A ->
is_midpoint R C D ->
inter_ll A1 D Q B R ->
inter_ll D1 A Q C P ->
inter_ll J A A1 D D1 ->
parallel A J A1 J ->
A<>J ->
A1<>J ->
A**J/A1**J=- (2+1).
Theorem th6_258 : forall A B C D E F M N P Q:Point,
on_parallel_d D B E A 1 ->
on_line C A E ->
on_line F B D ->
inter_ll M D C A F ->
inter_ll N E F B C ->
inter_ll P M N A D ->
inter_ll Q M N E B ->
D<>P -> E<>Q ->
parallel A P D P ->
parallel B Q E Q ->
A**P/D**P=B**Q/E**Q.
Lemma exercice2_38_3 : forall Y P Q U V A B,
inter_ll Y P Q U V ->
on_line A U V ->
S4 U P V Q <>0 ->
~Col U V Q ->
S A B Y = (S U B V) * (S A P Q) / S4 U P V Q.
Theorem th6_41 : forall A B C M N L P K:Point,
is_midpoint M A B ->
is_midpoint N A C ->
is_midpoint K B C ->
is_midpoint L A K ->
on_inter_parallel_parallel P A C M K B N ->
B<>C ->
P<>L ->
P<>A ->
P<>K ->
parallel L P B C ->
S A B C <> 0 ->
2+2 <> 0 ->
L**P / B**C = (1+2)/(2+2).