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.*)
(********************************************************)
intros.
unfold Obtuse in H0.
ex_and H0 A'.
ex_and H8 B'.
ex_and H0 C'.
assert(A' <> B' /\ C' <> B' /\ C <> A /\ C' <> B' /\ C <> B).
{
unfold LtA in H8.
spliter.
unfold LeA in H8.
ex_and H8 P.
unfold CongA in H10.
unfold InAngle in H8.
repeat split;
try tauto.
spliter.
auto.
spliter.
auto.
}
spliter.
assert(HH:=l6_11_existence B' C A A' H9 H11).
ex_and HH AA.
assert(HH:=l6_11_existence B' C B C' H12 H13).
ex_and HH CC.
assert(Lt AA CC A B).
{
apply(t18_18 C A B B' AA CC);Cong.
apply lta_comm.
apply(lta_out_lta A' B' C' A C B);
try(apply l6_6; auto).
apply out_trivial; auto.
apply out_trivial; auto.
auto.
}
assert(~Col O E E').
{
unfold Prod in H5.
unfold Ar2 in H5; tauto.
}
assert(exists S1 : Tpoint, Length O E E' AA CC S1).
{
apply(length_existence O E E' AA CC);auto.
}
destruct H20 as [S1 H21].
(* ex_and H20 S1. *)
assert(exists SS : Tpoint, Prod O E E' S1 S1 SS).
{
apply(prod_exists O E E' H19 S1 S1);
unfold Length in H21;tauto.
}
ex_and H20 SS.
apply (per_col _ _ _ CC) in H0;auto.
apply l8_2 in H0.
apply (per_col _ _ _ AA) in H0;auto.
assert(Sum O E E' AC2 BC2 SS).
{
apply(pythagoras O E E' AA CC B' AC BC S1 AC2 BC2 SS H); auto.
apply l8_2; auto.
apply(length_eq_cong_2  O E E' A C AA B'); Cong.
apply(length_eq_cong_2  O E E' B C CC B'); Cong.
}
assert(S2=SS).
{
apply (sum_uniqueness O E E' AC2 BC2);auto.
}
treat_equalities.
assert(HH:= lt_to_ltp O E E' AA CC S1 A B AB H21 H1 H18).
assert(Ps O E S1).
{
assert(AA <> B').
{
intro.
treat_equalities.
unfold Out in H14.
contradiction.
}
assert(CC <> B').
{
intro.
treat_equalities.
unfold Out in H16.
contradiction.
}
assert(AA <> CC).
intro.
treat_equalities.
apply l8_8 in H0.
treat_equalities.
tauto.
apply length_Ps in H21; auto.
intro.
apply sym_equal in H24.
treat_equalities.
apply length_cong in H21.
treat_equalities.
tauto.
}
apply(square_increase_strict O E E' S1 AB S2 AB2); auto.
unfold Length in H1.
unfold Length in H21.
spliter.
repeat split; Col.
apply (length_Ps O E E' A B); auto.
intro.
apply sym_equal in H20.
treat_equalities.
apply ltP_neg in HH.
apply pos_not_neg in H12.
contradiction.
apply out_col in H14; Col.
apply out_col in H16; Col.
Qed.
intros.
induction H0.
{
apply ltp_to_lep.
apply (pythagoras_obtuse O E E' A B C AC BC AB AC2 BC2 AB2 S2); auto.
}
{
assert(HH:= pythagoras O E E' A B C AC BC AB AC2 BC2 AB2 H H0 H1 H2 H3 H4 H5 H6).
assert(S2 = AB2).
{
apply (sum_uniqueness O E E' AC2 BC2); auto.
}
subst S2.
apply leP_refl.
}
Qed.
intros.
unfold Acute in H0.
ex_and H0 A'.
ex_and H8 B'.
ex_and H0 C'.
assert(A <> C /\ B <> C).
{
split;
intro;
treat_equalities;
unfold LtA in H8;
spliter;
unfold LeA in H8;
ex_and H8 P;
unfold CongA in *;
tauto.
}
spliter.
assert(~Col O E E').
{
unfold Prod in H5.
unfold Ar2 in H5; tauto.
}
induction(eq_dec_points A B).
{
treat_equalities.
assert(Length O E E' A A O).
{
apply length_id_2; auto.
}
assert(AB = O).
{
apply (length_uniqueness O E E' A A); auto.
}
apply sym_equal in H12.
treat_equalities.
apply(prod_O_l_eq) in H6.
subst AB2.
apply length_Ps in H2.
apply length_Ps in H3.
assert(Ps O E AC2).
{
apply (signeq__prod_pos O E E' AC AC); auto.
unfold SignEq.
left.
split; auto.
}
assert(Ps O E BC2).
{
apply (signeq__prod_pos O E E' BC BC); auto.
unfold SignEq.
left.
split; auto.
}
apply sum_pos_pos in H7; auto.
unfold LtP.
exists S2.
split; auto.
apply(diff_A_O O E E'  S2 ); auto.
unfold Ps in H2.
apply out_col in H2; Col.
intro.
subst BC.
apply length_cong in H3.
treat_equalities; tauto;
apply sym_equal in H6.
intro.
subst AC.
apply length_cong in H2.
treat_equalities; tauto.
}
{
assert(A' <> B' /\ C' <> B'  /\ C' <> B').
{
unfold LtA in H8.
spliter.
unfold LeA in H8.
ex_and H8 P.
unfold CongA in H10.
unfold InAngle in H8.
repeat split;
tauto.
}
spliter.
assert(exists X : Tpoint, Out B' X A' /\ Cong B' X C A).
{
apply(l6_11_existence B' C A A' H13); auto.
}
ex_and H16 AA.
assert(exists X : Tpoint, Out B' X C' /\ Cong B' X C B).
{
apply(l6_11_existence B' C B C'); auto.
}
ex_and H18 CC.
assert(Lt A B AA CC).
{
apply(t18_18 B' AA CC C A B );Cong.
apply lta_comm.
apply(lta_out_lta  A C B A' B' C');
try(apply l6_6; auto).
apply out_trivial; auto.
apply out_trivial; auto.
auto.
}
assert(exists S1 : Tpoint, Length O E E' AA CC S1).
{
apply(length_existence O E E' AA CC);auto.
}
destruct H21 as [S1 H22].
assert(exists SS : Tpoint, Prod O E E' S1 S1 SS).
{
apply(prod_exists O E E' H11 S1 S1);
unfold Length in H22;tauto.
}
ex_and H21 SS.
apply (per_col _ _ _ CC) in H0;auto.
apply l8_2 in H0.
apply (per_col _ _ _ AA) in H0;auto.
assert(Sum O E E' AC2 BC2 SS).
{
apply(pythagoras O E E' AA CC B' AC BC S1 AC2 BC2 SS H); auto.
apply l8_2; auto.
apply(length_eq_cong_2  O E E' A C AA B'); Cong.
apply(length_eq_cong_2  O E E' B C CC B'); Cong.
}
assert(S2=SS).
{
apply (sum_uniqueness O E E' AC2 BC2);auto.
}
treat_equalities.
assert(HH:= lt_to_ltp O E E' A B AB AA CC S1 H1 H22 H20).
apply(square_increase_strict O E E' AB S1 AB2 S2); auto.
unfold Length in H1.
unfold Length in H22.
spliter.
repeat split; Col.
apply (length_Ps O E E' A B) in H1.
auto.
intro.
apply sym_equal in H15.
treat_equalities.
apply (length_cong O E E') in H1.
treat_equalities.
tauto.
assert(AA <> B').
{
intro.
treat_equalities.
unfold Out in H14.
contradiction.
}
assert(CC <> B').
{
intro.
treat_equalities.
unfold Out in H16.
contradiction.
}
assert(AA <> CC).
intro.
treat_equalities.
apply l8_8 in H0.
treat_equalities.
tauto.
apply length_Ps in H22; auto.
intro.
apply sym_equal in H25.
treat_equalities.
apply length_cong in H22.
treat_equalities.
tauto.
apply out_col in H16; Col.
apply out_col in H18; Col.
}
Qed.

Lemma square_not_neg : forall O E E' A A2, Prod O E E' A A A2 -> ~Ng O E A2.