(* Lemma l8_14_1 : forall A B C D, Perp A B C D -> DistLn A B C D.  Lemma l8_14_2_1b : forall X A B C D Y, Perp_in X A B C D -> Col Y A B -> Col Y C D -> X=Y. Proof with Perp. intros. unfold Perp_in in H. decompose [and] H;clear H. assert (Per Y X Y). apply H7... symmetry. eapply l8_8... Qed.  Lemma l8_14_2_1b_bis : forall A B C D X, Perp A B C D -> Col X A B -> Col X C D -> Perp_in X A B C D. Proof with Perp. intros. unfold Perp in H. DecompEx H Y. assert (X=Y). symmetry. eapply l8_14_2_1b;eauto. subst. auto. Qed.  Hint Resolve  l8_14_2_1b_bis : Perp.  Lemma l8_14_2_2 : forall X A B C D, Perp A B C D -> (forall Y, Col Y A B -> Col Y C D -> X=Y) -> Perp_in X A B C D. Proof with Perp. intros. unfold Perp in H. DecompEx H X0. assert (X=X0). apply H0;unfold Perp_in in H1;intuition. subst... Qed.  Lemma l8_14_3 : forall A B C D X Y, Perp_in X A B C D -> Perp_in Y A B C D -> X=Y. Proof with Perp. intros. unfold Perp_in in *. decompose [and] H;clear H. decompose [and] H0;clear H0. eapply l8_8. eapply H10;auto. Qed.  Lemma l8_15_1 : forall A B C X, A<>B -> Col A B X -> Perp A B C X -> Perp_in X A B C X. Proof with Perp. intros. unfold Perp in H1. DecompEx H1 X0. unfold Perp_in in *. intuition. assert (Per X X0 X). apply H6;Col;Tarski... assert (X =X0)... subst X0. apply H6... Qed.  Lemma l8_15_2 : forall A B C X, A<>B -> Col A B X -> Perp_in X A B C X -> Perp A B C X. Proof with Perp. intros. unfold Perp. exists X. auto. Qed.  Lemma l8_16_1 : forall A B C U X, A<>B -> Col A B X -> Col A B U -> U<>X -> Perp A B C X -> ~ Col A B C /\ Per C X U. Proof with Perp. intros. assert (Perp_in X  A B C X). eapply l8_15_1... assert (Per C X U). unfold Perp, Perp_in in *. DecompEx H3 X0. intuition. split;auto. assert (C<>X). unfold not;intro. subst X. unfold Perp_in in H4;intuition. assert (~ Col U C X). unfold not;intro. assert (C=X \/ U=X). eapply l8_9... Col. intuition. unfold not;intro. assert (Col A X C). eapply col_transitivity_1;Col. assert (Col A C U). eapply col_transitivity_1;Col. assert (A<>C). unfold not;intro. unfold Perp_in in *;intuition. smart_subst C. assert (A<>B);auto. assert (Col A X U). eapply col_transitivity_1;Col. intuition. assert (Col C U X). eapply col_transitivity_2;Col. intuition. Qed.  Lemma l8_16_2 : forall A B C U X, A<>B -> Col A B X -> Col A B U -> U<>X -> ~ Col A B C -> Per C X U ->Perp A B C X. Proof with Perp. intros. assert (C<>X). unfold not;intro. smart_subst X;auto. assert (Perp_in X A B C X). eapply l8_13_2... Col. Tarski. exists U. exists C. intuition. exists X... Qed.  Lemma l8_18_unicity : forall A B C X Y, ~ Col A B C -> Col A B X -> Perp A B C X -> Col A B Y -> Perp A B C Y -> X=Y. Proof with Perp. intros. assert (Perp_in X A B C X). eapply l8_15_1. unfold not;intro;subst B;auto. intuition. Col. assumption. assert (Perp_in Y A B C Y). eapply l8_15_1. unfold not;intro;subst B;auto. intuition. Col. assumption. unfold Perp_in in *. decompose [and] H4;clear H4. decompose [and] H5;clear H5. eapply l8_7 with (A:=C). apply l8_2. apply H11. Col. Tarski. apply l8_2. apply H15. assumption. Tarski. Qed.  Ltac show_distinct X Y := assert (X<>Y);[unfold not;intro;treat_equalities|idtac].  Lemma l8_18_existence : forall A B C, ~ Col A B C -> exists X, Col A B X /\ Perp A B C X. Proof with Tarski. intros. assert (exists Y, Bet B A Y /\ Cong A Y A C)... DecompExAnd H0 Y. assert (exists P : Point, is_midpoint P C Y). eapply l7_25. apply cong_symmetry;eauto. DecompEx H0 P. assert (Per A P Y). unfold Per. exists C;intuition;Tarski. assert (exists Z, Bet A Y Z /\ Cong Y Z Y P)... DecompExAnd H4 Z. assert (exists Q, Bet P Y Q /\ Cong Y Q Y A)... DecompExAnd H4 Q. let_symmetric Q' Z Q. assert (exists C', Bet Q' Y C' /\ Cong Y C' Y C)... DecompExAnd H4 C'. assert (OFSC A Y Z Q Q Y P A). unfold OFSC;intuition. show_distinct A Y... assert (Cong Z Q P A). eapply five_segments_with_def;eauto. assert (Cong_3 A P Y Q Z Y). unfold Cong_3;intuition. assert (Per Q Z Y). eapply l8_10. 2:apply H14. auto. assert (Cong Y Q Y Q'). assert (Per Y Z Q);Perp. unfold Per in H16;intuition. elim H16;intro Q'';intros. decompose [and] H17. assert (Q''=Q'). eapply symmetric_point_unicity. apply H18. auto. subst Q''. auto. assert (exists X : Point, is_midpoint X C C'). eapply l7_25. apply cong_symmetry;eauto. DecompEx H17 X. assert (Per Y X C). unfold Per. exists C';intuition. show_distinct Q Y... cases_equality C C'. unfold OFSC,Cong_3,is_midpoint in *;DecompAndAll. treat_equalities. show_distinct P Y... assert (Col A B C)... intuition. show_distinct A B... show_distinct A C... show_distinct B C... show_distinct Y C... assert (Col P Y Q)... assert (Col P Y C)... assert (Col P Q C). eapply col_transitivity_1;try apply H1;auto. assert (Col Y Q C). eapply col_transitivity_2;try apply H1;auto. assert (Col Y Q' P). eapply col_transitivity_1;try apply H21;auto. assert (Col C Q' P). eapply col_transitivity_2;try apply H21;auto. assert (Col A Y B)... assert (Col A Y Z)... assert (Col A B Z). eapply col_transitivity_1;try apply H10;auto. assert (Col Y B Z). eapply col_transitivity_2;try apply H10;auto. assert (Col Q Y P)... assert (Col Q' Y P). Col. assert (Col P Q Q'). eapply col_transitivity_1;try apply H1;auto. Col. assert (Col Y Q Q'). eapply col_transitivity_2;try apply H1;auto. Col. assert (Col Z Q Q')... Col. show_distinct Q' Q... assert (Col P B C). eapply col_transitivity_1;try apply H1;auto. intuition. assert (Col Q' P Y). eapply col_transitivity_1;try apply H42;Col. assert (Col Q' Z Y). eapply col_transitivity_1;try apply H42;Col. show_distinct Z Y... assert (Col Z A Q'). eapply col_transitivity_1;try apply H45;Col. assert (Col Y A Q'). eapply col_transitivity_2;try apply H45;Col. show_distinct Z A... assert (Col Z B Q'). eapply col_transitivity_1;try apply H48;Col. assert (Col A B Q'). eapply col_transitivity_2;try apply H48;Col. assert (Col B Y Q'). eapply col_transitivity_2;try apply H12;Col. show_distinct Y Q'... assert (Col Y Q B). eapply col_transitivity_1;try apply H52;Col. show_distinct Y B... assert (Col Y B C). eapply col_transitivity_1;try apply H52;Col. assert (B<>Y)... assert (Col B A C). eapply col_transitivity_1;try apply H56;Col. assert (Col A B C)... Col. intuition. (* Now we know that C<> C' ! *)
suppose (OFSC Q Y C Z Q' Y C' Z).
assert (Cong C Z C' Z).
eapply five_segments_with_def;eauto.
assert (Col Z Y X).
eapply upper_dim.
apply H20.
apply cong_commutativity.
assumption.
sTarski.
unfold is_midpoint in H18;intuition.
show_distinct Y Z.
unfold OFSC,Cong_3,is_midpoint in *;DecompAndAll.
treat_equalities.
auto.
show_distinct C X.
unfold OFSC,Cong_3,is_midpoint in *;DecompAndAll.
treat_equalities.
auto.
show_distinct Y X.
unfold OFSC,Cong_3,is_midpoint in *;DecompAndAll.
treat_equalities.
auto.
clean_trivial_hyps.
clean_duplicated_hyps.
Focus 2.
assert (Perp_in X Y Z C X).
eapply l8_13_2...
Col.
exists Y.
exists C.
repeat split...
assert (Col A B X).
unfold OFSC,Cong_3,is_midpoint in *;DecompAndAll.
clean_trivial_hyps.
clean_duplicated_hyps.
assert (Col A Y B)...
assert (Col A Y Z)...
assert (Col Y B Z).
eapply col_transitivity_2.
apply H10.
auto.
auto.
assert (Col Y Z X)...
Col.
assert (Col Y B X).
eapply col_transitivity_1.
apply H24.
Col.
Col.
assert (X<>Y)...
assert (Col X A B).
eapply col_transitivity_1.
apply H39.
assert (Col Y Z X)...
assert (Col Y Z A)...
assert (Col Y X A).
eapply col_transitivity_1;try apply H24;auto.
Col.
Col.
Col.
exists X.
split...
unfold Perp.
exists X.
unfold Perp_in.
repeat split.
unfold not;intro;subst B;intuition.
assumption.
Col.
Tarski.
unfold Perp_in in H27.
decompose [and] H27;clear H27.
intros.
apply H34.
2:assumption.
unfold OFSC,Cong_3,is_midpoint in *;DecompAndAll.
assert (Col A Y Z)...
assert (Col A B U)...
Col.
assert (Col A B Y).
Col.
assert (Col A Y Z).
assert (Col A U Y).
assert (A<>B).
unfold not;intro.
subst B;intuition.
eapply col_transitivity_1.
apply H53.
auto.
auto.
auto.
assert (Col Y U Z).
assert (Y<>A)...
eapply col_transitivity_1.
apply H54.
2:Col.
assert (Col A Y U).
eapply col_transitivity_1.
assert (A<>B)...
unfold not;intro;subst B;intuition.
apply H55.
Col.
Col.
Col.
Col.
Focus 2.
unfold OFSC;repeat split;sTarski...
2:unfold OFSC ,is_midpoint, Cong_3 in *;DecompAndAll.
2:apply cong_right_commutativity.
2:assumption.
unfold is_midpoint in H1.
DecompAndAll.
show_distinct P Y...
clear  H6 H2 H3 H7 H9 H5 H12 H13 H14 H15 H16 H18 H17 H22 H0 H.
Between.
(* retour de focus *)
show_distinct A B...
show_distinct A C...
show_distinct B C...
show_distinct Y C...
show_distinct P Y...
show_distinct A Y...
show_distinct A Z...
show_distinct Y B...
show_distinct Y Z...
show_distinct C' Y...
show_distinct Q Q'...
assert (Col P B C).
eapply col_transitivity_1;try apply H32;Col.
intuition.
show_distinct Y Q...
clear H17 H0 H3 H7 H9 H12 H13 H15 H16 H22 H26 H27 H29 H30 H21 H33 H34 H38 H40.
assert (Col B A Y)...
assert (Col A Y Z)...
assert (Col P Y Q)...
assert (Col P Y C)...
assert (Col P Q C).
eapply col_transitivity_1;try apply H32;auto.
assert (Col Y Q C).
eapply col_transitivity_2;try apply H32;auto.
assert (Col Q' Y  C')...
assert (Col Q Z Q')...
assert (Col C Y C')...
clear H18 H23 H35 H4 H5 H11 H8 H2 H6.
assert (Col A Z B).
eapply col_transitivity_1;try apply H36;Col.
assert (Col Y Z B).
eapply col_transitivity_2;try apply H36;Col.
assert (Col C' C Q').
eapply col_transitivity_1;try apply H42;Col.
assert (Col Y C Q').
eapply col_transitivity_2;try apply H42;Col.
assert (Col C P Q').
eapply col_transitivity_1;try apply H25;Col.
assert (Col Y P Q').
eapply col_transitivity_2;try apply H25;Col.
assert (Col Y Q Q').
eapply col_transitivity_2;try apply H32;Col.
assert (Col P Q Q').
eapply col_transitivity_2;try apply H32;Col.
assert (Col Q Z P).
eapply col_transitivity_1;try apply H43;Col.
assert (Col Q Z Y).
eapply col_transitivity_1;try apply H43;Col.
assert (Col Q' Z P).
eapply col_transitivity_2;try apply H43;Col.
assert (Col Q' Z Y).
eapply col_transitivity_2;try apply H43;Col.
assert (Col Q' P Y).
eapply col_transitivity_2;try apply H43;Col.
assert (Col Y Z C).
eapply col_transitivity_1;try apply H43;Col.
assert (Col Y A C).
eapply col_transitivity_1;try apply H41;Col.
assert (Col A B C).
eapply col_transitivity_1;try apply H10;Col.
intuition.
Qed.

(* Specifications: *)
Lemma l8_20_1 : forall A B C C' D P,
Per A B C -> is_midpoint P C' D ->
is_midpoint A C' C -> is_midpoint B D C ->
Per B A P.
Lemma l8_20_2 : forall A B C C' D P,
Per A B C -> is_midpoint P C' D ->
is_midpoint A C' C -> is_midpoint B D C ->
B<>C -> A<>P.
Lemma l8_21_aux : forall A B C,
A<> B -> ~ Col A B C -> exists P, exists T, Perp A B P A /\ Col A B T /\ Bet C T P.