(* Gabriel Braun April 2013 *)
Require Export GeoCoq.Tarski_dev.Ch12_parallel.
Section L13_1.
Context `{TnEQD:Tarski_neutral_dimensionless_with_decidable_point_equality}.
(** Pappus Desargues *)

(* Specifications: *)
Lemma per2_col_eq : forall A P P' B, A <> P -> A <> P' -> Per A P B -> Per A P' B -> Col P A P' -> P = P'.
Lemma per2_preserves_diff : forall O A B A' B', O <> A' -> O <> B' -> Col O A' B' -> Per O A' A -> Per O B' B -> A' <> B' -> A <> B.
Lemma per23_preserves_bet : forall A B C B' C', Bet A B C -> A <> B' -> A <> C' -> Col A B' C' -> Per A B' B -> Per A C' C -> Bet A B' C'.
Lemma per23_preserves_bet_inv : forall A B C B' C', Bet A B' C' -> A <> B' -> Col A B C -> Per A B' B -> Per A C' C -> Bet A B C.
Lemma per13_preserves_bet : forall A B C A' C', Bet A B C -> B <> A' -> B <> C' -> Col A' B C' -> Per B A' A -> Per B C' C -> Bet A' B C'.
Lemma per13_preserves_bet_inv : forall A B C A' C', Bet A' B C' -> B <> A' -> B <> C' ->  Col A B C  -> Per B A' A -> Per B C' C -> Bet A B C.
Lemma per3_preserves_bet1 : forall O A B C A' B' C', Col O A B -> Bet A B C -> O <> A' -> O <> B' -> O <> C'
-> Per O A' A -> Per O B' B -> Per O C' C
-> Col A' B' C' -> Col O A' B' -> Bet A' B' C'.
Lemma per3_preserves_bet2_aux : forall O A B C B' C', Col O A C -> A <> C' ->
Bet A B' C' -> O <> A -> O <> B' -> O <> C'
-> Per O B' B -> Per O C' C
-> Col A B C -> Col O A C' -> Bet A B C.
Lemma per3_preserves_bet2 : forall O A B C A' B' C', Col O A C -> A' <> C' ->
Bet A' B' C' -> O <> A' -> O <> B' -> O <> C'
-> Per O A' A -> Per O B' B -> Per O C' C
-> Col A B C -> Col O A' C' -> Bet A B C.
Lemma symmetry_preserves_per : forall A P B A' P', Per B P A -> Midpoint B A A' -> Midpoint B P P'
-> Per B P' A'.
Lemma l13_1_aux : forall A B C P Q R,
~ Col A B C -> Midpoint P B C -> Midpoint Q A C -> Midpoint R A B ->
exists X, exists Y, Perp_at R X Y A B /\ Perp X Y P Q /\ Coplanar A B C X /\ Coplanar A B C Y.
Lemma l13_1 : forall A B C P Q R,
~ Col A B C -> Midpoint P B C -> Midpoint Q A C -> Midpoint R A B ->
exists X, exists Y, Perp_at R X Y A B /\ Perp X Y P Q.
Lemma per_lt : forall A B C, A <> B ->  C <> B -> Per A B C -> Lt A B A C /\ Lt C B A C.
Lemma cong_perp_conga : forall A B C P,  Cong A B C B -> Perp A C B P -> CongA A B P C B P /\ TS B P A C.
Lemma perp_per_bet : forall A B C P, ~Col A B C -> Col A P C -> Per A B C -> Perp_at P P B A C -> Bet A P C.
Lemma ts_per_per_ts : forall A B C D, TS A B C D -> Per B C A -> Per B D A -> TS C D A B.
Lemma l13_2_1 : forall A B C D E, TS A B C D -> Per B C A -> Per B D A -> Col C D E
-> Perp A E C D -> CongA C A B D A B
-> CongA B A C D A E /\ CongA B A D C A E /\ Bet C E D.
Lemma triangle_mid_par : forall A B C P Q, ~Col A B C -> Midpoint P B C -> Midpoint Q A C -> Par_strict A B Q P.
Lemma cop4_perp_in2__col : forall A B A' B' X Y P,
Coplanar X Y A A' -> Coplanar X Y A B' ->
Coplanar X Y B A' -> Coplanar X Y B B' ->
Perp_at P A B X Y -> Perp_at P A' B' X Y  -> Col A B A'.
Lemma l13_2 : forall A B C D E, TS A B C D -> Per B C A -> Per B D A -> Col C D E -> Perp A E C D
-> CongA B A C D A E /\ CongA B A D C A E /\ Bet C E D.
Lemma perp2_refl : forall A B P, A <> B -> Perp2 A B A B P.
Lemma perp2_sym : forall A B C D P, Perp2 A B C D P -> Perp2 C D A B P.
Lemma perp2_left_comm : forall A B C D P, Perp2 A B C D P -> Perp2 B A C D P.
Lemma perp2_right_comm : forall A B C D P, Perp2 A B C D P -> Perp2 A B D C P.
Lemma perp2_comm : forall A B C D P, Perp2 A B C D P -> Perp2 B A D C P.
Lemma perp2_pseudo_trans : forall A B C D E F P, Perp2 A B C D P -> Perp2 C D E F P -> ~ Col C D P ->
Perp2 A B E F P.
Lemma perp2_preserves_bet23 : forall O A B A' B', Bet O A B -> Col O A' B' -> ~Col O A A' ->
Perp2 A A' B B' O -> Bet O A' B'.
Lemma perp2_preserves_bet13 : forall O B C B' C', Bet B O C -> Col O B' C' -> ~Col O B B' ->
Perp2 B C' C B' O -> Bet B' O C'.
Lemma is_image_perp_in : forall A A' X Y, A <> A' -> X <> Y -> Reflect A A' X Y ->
exists P, Perp_at P A A' X Y.
Lemma perp_inter_perp_in_n
: forall A B C D : Tpoint,
Perp A B C D ->
exists P : Tpoint, Col A B P /\ Col C D P /\ Perp_at P A B C D.
Lemma perp2_perp_in : forall A B C D O, Perp2 A B C D O -> ~Col O A B /\ ~Col O C D ->
exists P, exists Q, Col A B P /\ Col C D Q /\ Col O P Q /\ Perp_at P O P A B /\ Perp_at Q O Q C D.
Lemma l13_8 : forall O P Q U V, U <> O -> V <> O -> Col O P Q -> Col O U V
-> Per P U O -> Per Q V O -> (Out O P Q <-> Out O U V).
Lemma perp_in_rewrite : forall A B C D P, Perp_at P A B C D ->
Perp_at P A P P C \/
Perp_at P A P P D \/
Perp_at P B P P C \/
Perp_at P B P P D.
Lemma gta_to_lta : forall A B C D E F, GtA A B C D E F -> LtA D E F A B C.
Lemma lta_to_gta : forall A B C D E F, LtA A B C D E F -> GtA D E F A B C.
Lemma perp_out_acute : forall A B C C', Out B A C' -> Perp A B C C' -> Acute A B C.
Lemma flat_all_lea : forall A B C, A <> B -> C <> B -> Bet A B C -> forall P, P <> B -> LeA A B P A B C.
Lemma perp_bet_obtuse : forall A B C C', B <> C' -> Perp A B C C' -> Bet A B C' -> Obtuse A B C.
End L13_1.