Require Export GeoCoq.Tarski_dev.Ch14_order.
Section T15.
Context `{T2D:Tarski_2D}.
Context `{TE:@Tarski_euclidean Tn TnEQD}.
(** Lemma 15.2 *)
(** Cong corresponds to length equality.*)
(** Le corresponds to length inequality.*)

(* Specifications: *)
Lemma length_pos : forall O E E' A B L,
Length O E E' A B L -> LeP O E E' O L.
Lemma length_id_1 : forall O E E' A B,
Length O E E' A B O -> A=B.
Lemma length_id_2 : forall O E E' A,
O<>E -> Length O E E' A A O.
Lemma length_id : forall O E E' A B,
Length O E E' A B O <-> (A=B /\ O<>E).
Lemma length_eq_cong_1 : forall O E E' A B C D AB,
Length O E E' A B AB -> Length O E E' C D AB -> Cong A B C D.
Lemma length_eq_cong_2 : forall O E E' A B C D AB,
Length O E E' A B AB -> Cong A B C D -> Length O E E' C D AB.
Lemma ltP_pos : forall O E E' A, LtP O E E' O A  -> Ps O E A.
Lemma bet_leP : forall O E E' AB CD,
Bet O AB CD -> LeP O E E' O AB -> LeP O E E' O CD -> LeP O E E' AB CD.
Lemma leP_bet : forall O E E' AB CD,
LeP O E E' AB CD -> LeP O E E' O AB -> LeP O E E' O CD -> Bet O AB CD.
Lemma length_Ar2 : forall O E E' A B AB,
Length O E E' A B AB -> (Col O E AB /\ ~Col O E E') \/ AB = O.
Lemma length_leP_le_1 : forall O E E' A B C D AB CD,
Length O E E' A B AB -> Length O E E' C D CD -> LeP O E E' AB CD -> Le A B C D.
Lemma length_leP_le_2 : forall O E E' A B C D AB CD,
Length O E E' A B AB -> Length O E E' C D CD -> Le A B C D -> LeP O E E' AB CD.
Lemma l15_3 : forall O E E' A B C, Sum O E E' A B C -> Cong O B A C.
(** Lemma 15.4. *)
(** Triangular equality. *)
Lemma length_uniqueness : forall O E E' A B AB AB',
Length O E E' A B AB -> Length O E E' A B AB' -> AB = AB'.
Lemma length_cong : forall O E E' A B AB, Length O E E' A B AB -> Cong A B O AB.
Lemma length_Ps : forall O E E' A B AB,
AB <> O -> Length O E E' A B AB -> Ps O E AB.
Lemma length_not_col_null : forall O E E' A B AB,
Col O E E' -> Length O E E' A B AB -> AB=O.
Lemma triangular_equality_equiv :
(forall O E A , O<>E -> (forall E' B C AB BC AC,
Bet A B C ->
Length O E E' A B AB -> Length O E E' B C BC -> Length O E E' A C AC ->
Sum O E E' AB BC AC)) <->
(forall O E E' A B C AB BC AC,
O<>E -> Bet A B C ->
Length O E E' A B AB -> Length O E E' B C BC -> Length O E E' A C AC ->
Sum O E E' AB BC AC).
Lemma not_triangular_equality1 : forall O E A ,
O<>E ->
~ (forall E' B C AB BC AC,
Bet A B C ->
Length O E E' A B AB -> Length O E E' B C BC -> Length O E E' A C AC ->
Sum O E E' AB BC AC).
Lemma triangular_equality : forall O E E' A B C AB BC AC,
O<>E -> Bet A B C ->
Is_length O E E' A B AB -> Is_length O E E' B C BC ->
Is_length O E E' A C AC ->
Sumg O E E' AB BC AC.
Lemma length_O : forall O E E', O <> E -> Length O E E' O O O.
Lemma triangular_equality_bis : forall O E E' A B C AB BC AC,
A <> B \/ A <> C \/ B <> C -> O<>E -> Bet A B C ->
Length O E E' A B AB -> Length O E E' B C BC -> Length O E E' A C AC ->
Sum O E E' AB BC AC.
(** Lemma 15.5. *)
(** Known as Thales theorem or intercept theorem. *)
Lemma length_out : forall O E E' A B C D AB CD,
A <> B -> C <> D -> Length O E E' A B AB -> Length O E E' C D CD ->
Out O AB CD.
Lemma image_preserves_bet1 : forall X Y A B C A' B' C',
Bet A B C -> Reflect A A' X Y -> Reflect B B' X Y -> Reflect C C' X Y ->
Bet A' B' C'.
Lemma image_preserves_col : forall X Y A B C A' B' C',
Col A B C -> Reflect A A' X Y -> Reflect B B' X Y -> Reflect C C' X Y ->
Col A' B' C'.
Lemma image_preserves_out : forall X Y A B C A' B' C',
Out A B C -> Reflect A A' X Y -> Reflect B B' X Y -> Reflect C C' X Y ->
Out A' B' C'.
Lemma project_preserves_out : forall A B C A' B' C' P Q X Y,
Out A B C -> ~Par A B X Y ->
Proj A A' P Q X Y -> Proj B B' P Q X Y -> Proj C C' P Q X Y ->
Out A' B' C'.
Lemma conga_bet_conga : forall A B C D E F A' C' D' F',
CongA A B C D E F -> A' <> B -> C' <> B -> D' <> E -> F' <> E ->
Bet A B A' -> Bet C B C' -> Bet D E D' -> Bet F E F' ->
CongA A' B C' D' E F'.
Lemma thales : forall O E E' P A B C D A1 B1 C1 D1 AD,
O <> E -> Col P A B -> Col P C D -> ~ Col P A C -> Pj A C B D ->
Length O E E' P A A1 -> Length O E E' P B B1 ->
Length O E E' P C C1 -> Length O E E' P D D1 ->
Prodg O E E' A1 D1 AD ->
Prodg O E E' C1 B1 AD.
Lemma length_existence : forall O E E' A B,
~ Col O E E' -> exists AB, Length O E E' A B AB.
(** Known as Euklid *)
Lemma l15_7 : forall O E E' A B C H AB AC AH AC2,
O<>E -> Per A C B -> Perp_at H C H A B ->
Length O E E' A B AB -> Length O E E' A C AC -> Length O E E' A H AH ->
(Prod O E E' AC AC AC2 <-> Prod O E E' AB AH AC2).
Lemma l15_7_1 : forall O E E' A B C H AB AC AH AC2,
O<>E -> Per A C B -> Perp_at H C H A B ->
Length O E E' A B AB -> Length O E E' A C AC -> Length O E E' A H AH ->
Prod O E E' AC AC AC2 ->
Prod O E E' AB AH AC2.
Lemma l15_7_2 : forall O E E' A B C H AB AC AH AC2,
O<>E -> Per A C B -> Perp_at H C H A B ->
Length O E E' A B AB -> Length O E E' A C AC -> Length O E E' A H AH ->
Prod O E E' AB AH AC2 ->
Prod O E E' AC AC AC2.
Lemma length_sym : forall O E E' A B AB,
Length O E E' A B AB -> Length O E E' B A AB.
Lemma pythagoras : forall O E E' A B C AC BC AB AC2 BC2 AB2,
O <> E -> Per A C B ->
Length O E E' A B AB ->
Length O E E' A C AC ->
Length O E E' B C BC ->
Prod O E E' AC AC AC2 ->
Prod O E E' BC BC BC2 ->
Prod O E E' AB AB AB2 ->
Sum  O E E' AC2 BC2 AB2.
Lemma is_length_exists : forall O E E' X Y,
~ Col O E E' -> exists XY, Is_length O E E' X Y XY.