Require Export GeoCoq.Tarski_dev.Ch06_out_lines.
Require Export GeoCoq.Tarski_dev.Tactics.ColR.

Ltac not_exist_hyp_comm A B := not_exist_hyp (A<>B);not_exist_hyp (B<>A).

Ltac not_exist_hyp2 A B C D := first [not_exist_hyp_comm A B | not_exist_hyp_comm C D].
Ltac not_exist_hyp3 A B C D E F := first [not_exist_hyp_comm A B | not_exist_hyp_comm C D | not_exist_hyp_comm E F].

Ltac assert_diffs :=
repeat
 match goal with
      | H:(~Col ?X1 ?X2 ?X3) |- _ =>
      let h := fresh in
      not_exist_hyp3 X1 X2 X1 X3 X2 X3;
      assert (h := not_col_distincts X1 X2 X3 H);decompose [and] h;clear h;clean_reap_hyps

      | H:(~Bet ?X1 ?X2 ?X3) |- _ =>
      let h := fresh in
      not_exist_hyp2 X1 X2 X2 X3;
      assert (h := not_bet_distincts X1 X2 X3 H);decompose [and] h;clear h;clean_reap_hyps
      | H:Bet ?A ?B ?C, H2 : ?A <> ?B |-_ =>
      let T:= fresh in (not_exist_hyp_comm A C);
        assert (T:= bet_neq12__neq A B C H H2);clean_reap_hyps
      | H:Bet ?A ?B ?C, H2 : ?B <> ?A |-_ =>
      let T:= fresh in (not_exist_hyp_comm A C);
        assert (T:= bet_neq21__neq A B C H H2);clean_reap_hyps
      | H:Bet ?A ?B ?C, H2 : ?B <> ?C |-_ =>
      let T:= fresh in (not_exist_hyp_comm A C);
        assert (T:= bet_neq23__neq A B C H H2);clean_reap_hyps
      | H:Bet ?A ?B ?C, H2 : ?C <> ?B |-_ =>
      let T:= fresh in (not_exist_hyp_comm A C);
        assert (T:= bet_neq32__neq A B C H H2);clean_reap_hyps

      | H:Cong ?A ?B ?C ?D, H2 : ?A <> ?B |-_ =>
      let T:= fresh in (not_exist_hyp_comm C D);
        assert (T:= cong_diff A B C D H2 H);clean_reap_hyps
      | H:Cong ?A ?B ?C ?D, H2 : ?B <> ?A |-_ =>
      let T:= fresh in (not_exist_hyp_comm C D);
        assert (T:= cong_diff_2 A B C D H2 H);clean_reap_hyps
      | H:Cong ?A ?B ?C ?D, H2 : ?C <> ?D |-_ =>
      let T:= fresh in (not_exist_hyp_comm A B);
        assert (T:= cong_diff_3 A B C D H2 H);clean_reap_hyps
      | H:Cong ?A ?B ?C ?D, H2 : ?D <> ?C |-_ =>
      let T:= fresh in (not_exist_hyp_comm A B);
        assert (T:= cong_diff_4 A B C D H2 H);clean_reap_hyps

      | H:Le ?A ?B ?C ?D, H2 : ?A <> ?B |-_ =>
      let T:= fresh in (not_exist_hyp_comm C D);
        assert (T:= le_diff A B C D H2 H);clean_reap_hyps
      | H:Lt ?A ?B ?C ?D |-_ =>
      let T:= fresh in (not_exist_hyp_comm C D);
        assert (T:= lt_diff A B C D H);clean_reap_hyps

      | H:Out ?A ?B ?C |- _ =>
      let T:= fresh in (not_exist_hyp2 A B A C);
       assert (T:= out_distinct A B C H);
       decompose [and] T;clear T;clean_reap_hyps
 end.

Ltac ColR :=
 let tpoint := constr:(Tpoint) in
 let col := constr:(Col) in
   treat_equalities; assert_cols; assert_diffs; try (solve [Col]); Col_refl tpoint col.

Section T7_1.

Context `{TnEQD:Tarski_neutral_dimensionless_with_decidable_point_equality}.

Lemma midpoint_dec :
 forall I A B, Midpoint I A B \/ ~ Midpoint I A B.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Col Tn A B D) (_ : @Bet Tn A C B) (_ : @Cong Tn A B C D) (_ : @Bet Tn C A D), @Cong Tn D A B C *)
    intros.
(* Goal: forall (A B C : @Tpoint Tn) (_ : @Midpoint Tn B A C), @Cong Tn A B B C *)
    unfold Midpoint.
(* Goal: or (and (@Bet Tn A I B) (@Cong Tn A I I B)) (not (and (@Bet Tn A I B) (@Cong Tn A I I B))) *)
    elim (bet_dec A I B);intro; elim (cong_dec A I I B);intro; tauto.
Qed.

Lemma is_midpoint_id : forall A B, Midpoint A A B -> A = B.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Col Tn A B D) (_ : @Bet Tn A C B) (_ : @Cong Tn A B C D) (_ : @Bet Tn C A D), @Cong Tn D A B C *)
    intros.
(* Goal: @eq (@Tpoint Tn) A B *)
    unfold Midpoint in H.
(* Goal: @Bet Tn C A D *)
    spliter.
(* Goal: @eq (@Tpoint Tn) P Q *)
(* Goal: @eq (@Tpoint Tn) P Q *)
    treat_equalities;reflexivity.
Qed.

Lemma is_midpoint_id_2 : forall A B, Midpoint A B A -> A=B.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Col Tn A B D) (_ : @Bet Tn A C B) (_ : @Cong Tn A B C D) (_ : @Bet Tn C A D), @Cong Tn D A B C *)
    intros.
(* Goal: False *)
    unfold Midpoint in *.
(* Goal: @Bet Tn C A D *)
    spliter.
(* Goal: @eq (@Tpoint Tn) A B *)
    apply cong_identity in H0.
(* Goal: @eq (@Tpoint Tn) A B *)
    auto.
Qed.

Lemma l7_2 : forall M A B, Midpoint M A B -> Midpoint M B A.
Proof.
(* Goal: forall (A B C : @Tpoint Tn) (_ : @Midpoint Tn B A C), @Cong Tn A B B C *)
    unfold Midpoint.
(* Goal: forall (A B : @Tpoint Tn) (_ : not (@eq (@Tpoint Tn) A B)), not (@eq (@Tpoint Tn) B A) *)
    intuition.
Qed.

Lemma l7_3 : forall M A, Midpoint M A A -> M=A.
Proof.
(* Goal: forall (A B C : @Tpoint Tn) (_ : @Midpoint Tn B A C), @Cong Tn A B B C *)
    unfold Midpoint.
(* Goal: forall (M A : @Tpoint Tn) (_ : and (@Bet Tn A M A) (@Cong Tn A M M A)), @eq (@Tpoint Tn) M A *)
    intros;spliter;repeat split;Between;Cong.
Qed.


Lemma l7_3_2 : forall A, Midpoint A A A.
Proof.
(* Goal: forall (A B C : @Tpoint Tn) (_ : @Midpoint Tn B A C), @Cong Tn A B B C *)
    unfold Midpoint.
(* Goal: forall A : @Tpoint Tn, and (@Bet Tn A A A) (@Cong Tn A A A A) *)
    intros;repeat split;Between;Cong.
Qed.

(** This corresponds to l7_8 in Tarski's book. *)

Lemma symmetric_point_construction : forall P A, exists P', Midpoint A P P'.
Proof.
(* Goal: forall (A B C : @Tpoint Tn) (_ : @Midpoint Tn B A C), @Cong Tn A B B C *)
    unfold Midpoint.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Col Tn A B D) (_ : @Bet Tn A C B) (_ : @Cong Tn A B C D) (_ : @Bet Tn C A D), @Cong Tn D A B C *)
    intros.
(* Goal: @ex (@Tpoint Tn) (fun P' : @Tpoint Tn => and (@Bet Tn P A P') (@Cong Tn P A A P')) *)
    prolong P A E P A.
(* Goal: @ex (@Tpoint Tn) (fun P' : @Tpoint Tn => and (@Bet Tn P A P') (@Cong Tn P A A P')) *)
    exists E.
(* Goal: and (@Bet Tn P A E) (@Cong Tn P A A E) *)
    split;Cong;Between.
Qed.

Lemma symmetric_point_uniqueness : forall A P P1 P2, Midpoint P A P1 -> Midpoint P A P2 -> P1=P2.
Proof.
(* Goal: forall (A B C : @Tpoint Tn) (_ : @Midpoint Tn B A C), @Cong Tn A B B C *)
    unfold Midpoint.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Col Tn A B D) (_ : @Bet Tn A C B) (_ : @Cong Tn A B C D) (_ : @Bet Tn C A D), @Cong Tn D A B C *)
    intros.
(* Goal: @Bet Tn C A D *)
    spliter.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Col Tn A B D) (_ : @Bet Tn A C B) (_ : @Cong Tn A B C D) (_ : @Bet Tn C A D), @Cong Tn D A B C *)
    elim (eq_dec_points A P); intros.
(* Goal: @eq (@Tpoint Tn) A B *)
      treat_equalities;auto.
(* Goal: @eq (@Tpoint Tn) P1 P2 *)
    apply (construction_uniqueness A P A P);Cong.
Qed.

Lemma l7_9 : forall P Q A X, Midpoint A P X -> Midpoint A Q X -> P=Q.
Proof.
(* Goal: forall (A B C : @Tpoint Tn) (_ : @Midpoint Tn B A C), @Cong Tn A B B C *)
    unfold Midpoint.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Col Tn A B D) (_ : @Bet Tn A C B) (_ : @Cong Tn A B C D) (_ : @Bet Tn C A D), @Cong Tn D A B C *)
    intros.
(* Goal: @Bet Tn C A D *)
    spliter.
(* Goal: @eq (@Tpoint Tn) P Q *)
    induction (eq_dec_points A X).
(* Goal: @eq (@Tpoint Tn) P Q *)
(* Goal: @eq (@Tpoint Tn) P Q *)
      treat_equalities;reflexivity.
(* Goal: @eq (@Tpoint Tn) P Q *)
    apply (construction_uniqueness X A X A);Cong;Between.
Qed.

Lemma l7_9_bis : forall P Q A X, Midpoint A P X -> Midpoint A X Q -> P=Q.
Proof.
(* Goal: forall (P Q A X : @Tpoint Tn) (_ : @Midpoint Tn A P X) (_ : @Midpoint Tn A X Q), @eq (@Tpoint Tn) P Q *)
intros; apply l7_9 with A X; unfold Midpoint in *; split; spliter; Cong; Between.
Qed.

Lemma l7_13 : forall A P Q P' Q',  Midpoint A P' P -> Midpoint A Q' Q -> Cong P Q P' Q'.
Proof.
(* Goal: forall (A B C : @Tpoint Tn) (_ : @Midpoint Tn B A C), @Cong Tn A B B C *)
    unfold Midpoint.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Col Tn A B D) (_ : @Bet Tn A C B) (_ : @Cong Tn A B C D) (_ : @Bet Tn C A D), @Cong Tn D A B C *)
    intros.
(* Goal: @Bet Tn C A D *)
    spliter.
    induction (eq_dec_points P A).
      treat_equalities;Cong.
    prolong P' P X Q A.
    prolong X P' X' Q A.
    prolong Q' Q Y P A.
    prolong Y Q' Y' P A.
    assert (Bet Y A Q') by eBetween.
    assert (Bet P' A X) by eBetween.
    assert (Bet A P X) by eBetween.
    assert(Bet Y Q A) by eBetween.
    assert (Bet A Q' Y') by eBetween.
    assert (Bet X' P' A) by eBetween.
    assert(Bet X A X') by eBetween.
    assert(Bet Y A Y') by eBetween.
    assert (Cong A X Y A) by (eapply l2_11;eCong).
    assert (Cong A Y' X' A).
      apply l2_11 with Q' P'; Between.
        apply cong_transitivity with A Q; Cong.
      apply cong_transitivity with A P; Cong.
    assert (Cong A Y A Y').
      apply (l2_11 A Q Y _ Q' Y'); Between; Cong.
      apply cong_transitivity with A P; Cong.
    assert (Cong X A Y' A) by (apply cong_transitivity with A Y; Cong).
    assert (Cong A X' A Y) by (apply cong_transitivity with A Y'; Cong).
    assert (FSC X A X' Y' Y' A Y X).
      unfold FSC;repeat split; Cong.
(* Goal: @eq (@Tpoint Tn) A B *)
        apply bet_col;auto.
      eapply (l2_11 X A X' Y' A Y);Between.
    assert (A <> X).
      eapply bet_neq12__neq.
        apply H14.
(* Goal: @eq (@Tpoint Tn) A B *)
      auto.
    assert (Cong X' Y' Y X) by eauto using l4_16.
    assert (Cong A X A X') by (apply cong_transitivity with A Y; Cong).
    assert (IFSC Y Q A X Y' Q' A X') by (unfold IFSC, FSC in *;spliter;repeat split;Between; Cong).
    assert (Cong Q X Q' X') by eauto using l4_2.
    assert (IFSC X P A Q X' P' A Q') by (unfold IFSC;repeat split;Between;Cong).
    eauto using l4_2.
Qed.

Lemma l7_15 : forall P Q R P' Q' R' A,
 Midpoint A P P' -> Midpoint A Q Q' -> Midpoint A R R' -> Bet P Q R -> Bet P' Q' R'.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Col Tn A B D) (_ : @Bet Tn A C B) (_ : @Cong Tn A B C D) (_ : @Bet Tn C A D), @Cong Tn D A B C *)
    intros.
(* Goal: @Bet Tn C A D *)
    spliter.
    eapply l4_6.
      apply H2.
    unfold Cong_3.
    repeat split.
      eapply l7_13.
(* Goal: @Midpoint Tn M B A *)
        apply l7_2.
        apply H.
(* Goal: @Midpoint Tn M B A *)
      apply l7_2.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
      assumption.
      eapply l7_13.
(* Goal: @Midpoint Tn M B A *)
        apply l7_2.
        apply H.
(* Goal: @Midpoint Tn M B A *)
      apply l7_2.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
      assumption.
    eapply l7_13.
(* Goal: @Midpoint Tn M B A *)
      apply l7_2.
      apply H0.
(* Goal: @Midpoint Tn M B A *)
    apply l7_2.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
    assumption.
Qed.


Lemma l7_16 : forall P Q R S P' Q' R' S' A,
  Midpoint A P P' -> Midpoint A Q Q' ->
  Midpoint A R R' -> Midpoint A S S' ->
  Cong P Q R S -> Cong P' Q' R' S'.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Col Tn A B D) (_ : @Bet Tn A C B) (_ : @Cong Tn A B C D) (_ : @Bet Tn C A D), @Cong Tn D A B C *)
    intros.
    assert (Cong P Q P' Q').
      eapply l7_13.
(* Goal: @Midpoint Tn M B A *)
        apply l7_2.
        apply H.
(* Goal: @Midpoint Tn M B A *)
      apply l7_2.
      apply H0.
    assert (Cong R S R' S').
      eapply l7_13.
(* Goal: @Midpoint Tn M B A *)
        apply l7_2.
        apply H1.
(* Goal: @Midpoint Tn M B A *)
      apply l7_2.
      apply H2.
    apply cong_transitivity with P Q; Cong.
    apply cong_transitivity with R S; Cong.
Qed.


Lemma symmetry_preserves_midpoint :
   forall A B C D E F Z,
 Midpoint Z A D -> Midpoint Z B E ->
 Midpoint Z C F -> Midpoint B A C -> Midpoint E D F.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Col Tn A B D) (_ : @Bet Tn A C B) (_ : @Cong Tn A B C D) (_ : @Bet Tn C A D), @Cong Tn D A B C *)
    intros.
(* Goal: forall (A B C : @Tpoint Tn) (_ : @Midpoint Tn B A C), @Cong Tn A B B C *)
    unfold Midpoint.
(* Goal: and (@Bet Tn D E F) (@Cong Tn D E E F) *)
    unfold Midpoint in H2.
(* Goal: @Bet Tn C A D *)
    spliter.
(* Goal: @Lt Tn A M A' M' *)
    split.
(* Goal: @eq (@Tpoint Tn) A B *)
      eapply l7_15;eauto.
(* Goal: @eq (@Tpoint Tn) A B *)
    eapply l7_16;eauto.
Qed.

End T7_1.

Hint Resolve l7_13 : cong.
Hint Resolve l7_2 l7_3_2 : midpoint.

Ltac Midpoint := auto with midpoint.

Section T7_2.

Context {Tn:Tarski_neutral_dimensionless}.
Context {TnEQD:Tarski_neutral_dimensionless_with_decidable_point_equality Tn}.

Lemma Mid_cases :
  forall A B C,
  Midpoint A B C \/ Midpoint A C B ->
  Midpoint A B C.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Col Tn A B D) (_ : @Bet Tn A C B) (_ : @Cong Tn A B C D) (_ : @Bet Tn C A D), @Cong Tn D A B C *)
    intros.
(* Goal: @Midpoint Tn A B C *)
    decompose [or] H; Midpoint.
Qed.

Lemma Mid_perm :
  forall A B C,
  Midpoint A B C ->
  Midpoint A B C /\ Midpoint A C B.
Proof.
(* Goal: forall (A B C : @Tpoint Tn) (_ : @Midpoint Tn B A C), @Cong Tn A B B C *)
    unfold Midpoint.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Col Tn A B D) (_ : @Bet Tn A C B) (_ : @Cong Tn A B C D) (_ : @Bet Tn C A D), @Cong Tn D A B C *)
    intros.
(* Goal: @Bet Tn C A D *)
    spliter.
(* Goal: and (and (@Bet Tn B A C) (@Cong Tn B A A C)) (and (@Bet Tn C A B) (@Cong Tn C A A B)) *)
    repeat split; Between; Cong.
Qed.

Lemma l7_17 : forall P P' A B, Midpoint A P P' -> Midpoint B P P' -> A=B.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Col Tn A B D) (_ : @Bet Tn A C B) (_ : @Cong Tn A B C D) (_ : @Bet Tn C A D), @Cong Tn D A B C *)
    intros.
(* Goal: @eq (@Tpoint Tn) A B *)
    assert (Cong P B P' B).
(* Goal: False *)
      unfold Midpoint in *.
(* Goal: @Bet Tn C A D *)
      spliter.
(* Goal: @Cong Tn A B D C *)
      Cong.
(* Goal: @eq (@Tpoint Tn) A B *)
    assert (exists B', Midpoint A B B') by (apply symmetric_point_construction).
(* Goal: @eq (@Tpoint Tn) A B *)
    induction H2.
(* Goal: @eq (@Tpoint Tn) A B *)
    assert (Cong P' B P x) by eauto with midpoint cong.
(* Goal: @eq (@Tpoint Tn) A B *)
    assert (Cong P B P x) by (apply cong_transitivity with P' B; Cong).
(* Goal: @eq (@Tpoint Tn) A B *)
    assert (Cong P B P' x) by eauto with midpoint cong.
(* Goal: @eq (@Tpoint Tn) A B *)
    assert (Cong P' B P' x) by (apply cong_transitivity with P x; Cong; apply cong_transitivity with P B; Cong).
(* Goal: @eq (@Tpoint Tn) A B *)
    assert (Bet P B P') by (unfold Midpoint in *;spliter;assumption).
(* Goal: @eq (@Tpoint Tn) A B *)
    assert (B=x) by (apply (l4_19 P P' B x);Between).
(* Goal: and (@Midpoint Tn P A C) (@Midpoint Tn P B D) *)
    subst x.
(* Goal: @eq (@Tpoint Tn) A B *)
    apply l7_3.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
    assumption.
Qed.

Lemma l7_17_bis : forall P P' A B, Midpoint A P P' -> Midpoint B P' P -> A=B.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Col Tn A B D) (_ : @Bet Tn A C B) (_ : @Cong Tn A B C D) (_ : @Bet Tn C A D), @Cong Tn D A B C *)
    intros.
(* Goal: @eq (@Tpoint Tn) A B *)
    apply l7_17 with P P'; Midpoint.
Qed.

Lemma l7_20 : forall M A B,
  Col A M B -> Cong M A M B -> A=B \/ Midpoint M A B.
Proof.
(* Goal: @Col Tn M A B *)
    unfold Col.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Col Tn A B D) (_ : @Bet Tn A C B) (_ : @Cong Tn A B C D) (_ : @Bet Tn C A D), @Cong Tn D A B C *)
    intros.
(* Goal: or (@eq (@Tpoint Tn) A B) (@Midpoint Tn M A B) *)
    induction H.
(* Goal: or (@eq (@Tpoint Tn) A B) (@Midpoint Tn M A B) *)
(* Goal: or (@eq (@Tpoint Tn) A B) (@Midpoint Tn M A B) *)
      right.
(* Goal: forall (A B C : @Tpoint Tn) (_ : @Midpoint Tn B A C), @Cong Tn A B B C *)
      unfold Midpoint.
(* Goal: @Lt Tn A M A' M' *)
      split.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
        assumption.
(* Goal: @Cong Tn A B D C *)
      Cong.
(* Goal: or (@eq (@Tpoint Tn) A B) (@Midpoint Tn M A B) *)
    induction H.
(* Goal: or (@eq (@Tpoint Tn) A B) (@Midpoint Tn M A B) *)
(* Goal: or (@eq (@Tpoint Tn) A B) (@Midpoint Tn M A B) *)
      assert (Cong A B B B) by (apply (l4_3 A B M B B M);Between;Cong).
(* Goal: @eq (@Tpoint Tn) A B *)
      treat_equalities;auto.
(* Goal: or (@eq (@Tpoint Tn) A B) (@Midpoint Tn M A B) *)
    assert (Cong B A A A) by (apply (l4_3 B A M A A M);Cong;Between).
(* Goal: @eq (@Tpoint Tn) A B *)
    treat_equalities;auto.
Qed.

Lemma l7_20_bis : forall M A B, A<>B ->
  Col A M B -> Cong M A M B -> Midpoint M A B.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Col Tn A B D) (_ : @Bet Tn A C B) (_ : @Cong Tn A B C D) (_ : @Bet Tn C A D), @Cong Tn D A B C *)
   intros.
(* Goal: forall (A B : @Tpoint Tn) (_ : not (@eq (@Tpoint Tn) A B)), not (@eq (@Tpoint Tn) B A) *)
   induction (l7_20 M A B H0 H1);intuition.
Qed.

Lemma cong_col_mid : forall A B C,
 A <> C -> Col A B C -> Cong A B B C ->
 Midpoint B A C.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Col Tn A B D) (_ : @Bet Tn A C B) (_ : @Cong Tn A B C D) (_ : @Bet Tn C A D), @Cong Tn D A B C *)
    intros.
(* Goal: @Midpoint Tn B A C *)
    apply l7_20 in H0.
(* Goal: @Midpoint Tn B A C *)
(* Goal: @Cong Tn B A B C *)
      intuition subst.
(* Goal: @Cong Tn A B D C *)
    Cong.
Qed.

Lemma l7_21 : forall A B C D P,
  ~ Col A B C -> B<>D ->
  Cong A B C D -> Cong B C D A ->
  Col A P C -> Col B P D ->
  Midpoint P A C /\ Midpoint P B D.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Col Tn A B D) (_ : @Bet Tn A C B) (_ : @Cong Tn A B C D) (_ : @Bet Tn C A D), @Cong Tn D A B C *)
    intros.
(* Goal: and (@Midpoint Tn P A C) (@Midpoint Tn P B D) *)
    assert_diffs.
(* Goal: and (@Midpoint Tn P A C) (@Midpoint Tn P B D) *)
    assert (exists P', Cong_3 B D P D B P').
(* Goal: @ex (@Tpoint Tn) (fun P' : @Tpoint Tn => @Cong_3 Tn B D P D B P') *)
(* Goal: and (@Midpoint Tn P A C) (@Midpoint Tn P B D) *)
      eapply l4_14.
(* Goal: @Col Tn B D P *)
(* Goal: @Cong Tn B D D B *)
(* Goal: and (@Midpoint Tn P A C) (@Midpoint Tn P B D) *)
        Col.
(* Goal: @Cong Tn A B D C *)
      Cong.
(* Goal: and (@Midpoint Tn P A C) (@Midpoint Tn P B D) *)
    induction H9.
    assert (Col D B x) by
      (apply l4_13 with B D P;Col).
(* Goal: and (@Midpoint Tn P A C) (@Midpoint Tn P B D) *)
    assert (FSC B D P A D B x C).
(* Goal: @FSC Tn B D P C D B x A *)
(* Goal: and (@Midpoint Tn P A C) (@Midpoint Tn P B D) *)
      unfold FSC.
(* Goal: and (@Col Tn B D P) (and (@Cong_3 Tn B D P D B x) (and (@Cong Tn B C D A) (@Cong Tn D C B A))) *)
(* Goal: and (@Midpoint Tn P A C) (@Midpoint Tn P B D) *)
      unfold Cong_3 in *.
(* Goal: @Bet Tn C A D *)
      spliter.
(* Goal: @Col Tn B D P *)
(* Goal: @Cong Tn B D D B *)
(* Goal: and (@Midpoint Tn P A C) (@Midpoint Tn P B D) *)
      repeat split; Cong; Col.
(* Goal: and (@Midpoint Tn P A C) (@Midpoint Tn P B D) *)
    assert (FSC B D P C D B x A).
(* Goal: @FSC Tn B D P C D B x A *)
(* Goal: and (@Midpoint Tn P A C) (@Midpoint Tn P B D) *)
      unfold FSC.
(* Goal: and (@Col Tn B D P) (and (@Cong_3 Tn B D P D B x) (and (@Cong Tn B C D A) (@Cong Tn D C B A))) *)
(* Goal: and (@Midpoint Tn P A C) (@Midpoint Tn P B D) *)
      unfold Cong_3 in *.
(* Goal: @Bet Tn C A D *)
      spliter.
(* Goal: @Cong Tn A B D C *)
      repeat split; Col; Cong.
(* Goal: and (@Midpoint Tn P A C) (@Midpoint Tn P B D) *)
    assert (Cong P A x C) by (eauto using l4_16).
(* Goal: and (@Midpoint Tn P A C) (@Midpoint Tn P B D) *)
    assert (Cong P C x A) by (eauto using l4_16).
(* Goal: and (@Midpoint Tn P A C) (@Midpoint Tn P B D) *)
    assert (Cong_3 A P C C x A) by (unfold Cong_3;repeat split; Cong).
(* Goal: and (@Midpoint Tn P A C) (@Midpoint Tn P B D) *)
    assert (Col C x A) by (eauto using l4_13).
(* Goal: and (@Midpoint Tn P A C) (@Midpoint Tn P B D) *)
    assert (P=x).
(* Goal: @eq (@Tpoint Tn) P x *)
(* Goal: and (@Midpoint Tn P A C) (@Midpoint Tn P B D) *)
      unfold FSC in *.
(* Goal: @Bet Tn C A D *)
      spliter.
(* Goal: @Col Tn B D P *)
(* Goal: @Cong Tn B D D B *)
(* Goal: and (@Midpoint Tn P A C) (@Midpoint Tn P B D) *)
      apply (l6_21 A C B D); Col.
(* Goal: and (@Midpoint Tn P A C) (@Midpoint Tn P B D) *)
    subst x.
(* Goal: @Bet Tn C A D *)
    unfold Cong_3 in *;spliter.
(* Goal: @Cong Tn A B D C *)
    split;apply l7_20_bis;Col;Cong.
Qed.

Lemma l7_22_aux : forall A1 A2 B1 B2 C M1 M2,
   Bet A1 C A2 -> Bet B1 C B2 ->
   Cong C A1 C B1 -> Cong C A2 C B2 ->
   Midpoint M1 A1 B1 -> Midpoint M2 A2 B2 ->
   Le C A1 C A2 ->
   Bet M1 C M2.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Col Tn A B D) (_ : @Bet Tn A C B) (_ : @Cong Tn A B C D) (_ : @Bet Tn C A D), @Cong Tn D A B C *)
    intros.
    induction (eq_dec_points A2 C).
(* Goal: @Bet Tn C A B *)
      subst C.
      apply le_zero in H5.
      subst A2.
      apply cong_reverse_identity in H1.
      subst B1.
      apply cong_reverse_identity in H2.
      subst B2.
      apply l7_3 in H4.
      subst A1.
      apply between_trivial.
    assert (exists A, Midpoint C A2 A).
      apply symmetric_point_construction.
    induction H7.
    assert (exists B, Midpoint C B2 B).
      apply symmetric_point_construction.
    induction H8.
    assert (exists M, Midpoint C M2 M).
      apply symmetric_point_construction.
(* Goal: and (@Midpoint Tn P A C) (@Midpoint Tn P B D) *)
    induction H9.
    assert(Midpoint x1 x x0).
(* Goal: forall (A B C : @Tpoint Tn) (_ : @Midpoint Tn B A C), @Cong Tn A B B C *)
      unfold Midpoint.
(* Goal: @Lt Tn A M A' M' *)
      split.
        eapply l7_15.
          apply H7.
          apply H9.
          apply H8.
        unfold Midpoint in H4.
(* Goal: @Bet Tn C A D *)
        spliter.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
        assumption.
      eapply l7_16.
        apply H7.
        apply H9.
        apply H9.
        apply H8.
      unfold Midpoint in H4.
(* Goal: @Bet Tn C A D *)
      spliter.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
      assumption.
    assert (Le C A1 C x).
      eapply l5_6.
      repeat split.
        apply H5.
        apply cong_reflexivity.
      unfold Midpoint in H7.
(* Goal: @Bet Tn C A D *)
      spliter.
      apply cong_left_commutativity.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
      assumption.
    assert (Bet C A1 x).
      induction (eq_dec_points A1 C).
        subst A1.
        apply between_trivial2.
      eapply l6_13_1.
        unfold Out.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
        2:assumption.
      repeat split.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
        assumption.
(* Goal: not (@Cong Tn A M A' M') *)
        intro.
(* Goal: and (@Midpoint Tn P A C) (@Midpoint Tn P B D) *)
        subst x.
        apply le_zero in H11.
        apply H12.
        subst A1.
        reflexivity.
      eapply l5_2.
        apply H6.
        apply between_symmetry.
(* Goal: not (@Cong Tn A M A' M') *)
        assumption; intro.
      unfold Midpoint in H7.
(* Goal: @Bet Tn C A D *)
      spliter.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
      assumption.
    (* assert (M1=x).
(* Goal: @Midpoint Tn M' B' A' *)
(* Goal: @Cong Tn B A B' A' *)
    eauto with Midpoint.
    *)
    assert (Le C B1 C x0).
      eapply l5_6.
        apply H11.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
        assumption.
(* Goal: False *)
      unfold Midpoint in *.
(* Goal: @Bet Tn C A D *)
      spliter.
      eapply cong_transitivity.
        apply cong_symmetry.
        apply H16.
      eapply cong_transitivity.
        2:apply H15.
      apply cong_commutativity.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
      assumption.
    assert (Bet C B1 x0).
      induction (eq_dec_points B1 C).
        subst B1.
(* Goal: @Bet Tn A D C *)
(* Goal: @Bet Tn B D C *)
        apply cong_symmetry in H1.
        apply cong_reverse_identity in H1.
        subst A1.
        apply between_trivial2.
      induction (eq_dec_points x0 C).
        subst x0.
        apply le_zero in H13.
        subst B1.
        apply between_trivial.
      induction (eq_dec_points B2 C).
        subst B2.
(* Goal: @Bet Tn A B D *)
(* Goal: @Bet Tn C B D *)
        apply cong_symmetry in H2.
        eapply cong_reverse_identity in H2.
        subst A2.
        apply le_zero in H5.
        subst A1.
        apply cong_reverse_identity in H1.
        subst B1.
        apply False_ind.
        apply H14.
        reflexivity.
      eapply l6_13_1.
        unfold Out.
        repeat split.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
          assumption.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
          assumption.
        eapply l5_2.
          2:apply between_symmetry.
          2:apply H0.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
          assumption.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
        2:assumption.
      unfold Midpoint in H8.
(* Goal: @Bet Tn C A D *)
      spliter.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
      assumption.
    assert (exists Q, Bet x1 Q C /\ Bet A1 Q B1).
      eapply l3_17.
        apply between_symmetry.
        apply H12.
        apply between_symmetry.
        apply H14.
      unfold Midpoint in H10.
(* Goal: @Bet Tn C A D *)
      spliter.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
      assumption.
    ex_and H15 Q.
    assert (IFSC x A1 C x1 x0 B1 C x1).
      unfold IFSC.
(* Goal: False *)
      unfold Midpoint in *.
(* Goal: @Bet Tn C A D *)
      spliter.
      repeat split.
        apply between_symmetry.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
        assumption.
        apply between_symmetry.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
        assumption.
        eapply cong_transitivity.
          apply cong_commutativity.
          apply cong_symmetry.
          apply H20.
        eapply cong_transitivity.
          apply H2.
        apply cong_commutativity.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
        assumption.
        apply cong_commutativity.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
        assumption.
        apply cong_right_commutativity.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
        assumption.
      apply cong_reflexivity.
    assert (Cong A1 x1 B1 x1).
      eapply l4_2.
      apply H17.
    assert (Cong Q A1 Q B1).
      induction(eq_dec_points C x1).
        subst x1.
        apply between_identity in H15.
        subst Q.
        apply cong_commutativity.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
        assumption.
      eapply l4_17.
        apply H19.
(* Goal: @Col Tn M A B *)
        unfold Col.
        right; left.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
        assumption.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
        assumption.
      apply cong_commutativity.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
      assumption.
    assert (Midpoint Q A1 B1).
(* Goal: forall (A B C : @Tpoint Tn) (_ : @Midpoint Tn B A C), @Cong Tn A B B C *)
      unfold Midpoint.
(* Goal: @Lt Tn A M A' M' *)
      split.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
        assumption.
      apply cong_left_commutativity.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
      assumption.
    assert (Q=M1).
      eapply l7_17.
        apply H20.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
      assumption.
    subst Q.
    eapply between_exchange3.
      apply H15.
    unfold Midpoint in H9.
(* Goal: @Bet Tn C A D *)
    spliter.
    apply between_symmetry.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
    assumption.
Qed.

(** This is Krippen lemma , proved by Gupta in its PhD in 1965 as Theorem 3.45 *)

Lemma l7_22 : forall A1 A2 B1 B2 C M1 M2,
   Bet A1 C A2 -> Bet B1 C B2 ->
   Cong C A1 C B1 -> Cong C A2 C B2 ->
   Midpoint M1 A1 B1 -> Midpoint M2 A2 B2 ->
   Bet M1 C M2.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Col Tn A B D) (_ : @Bet Tn A C B) (_ : @Cong Tn A B C D) (_ : @Bet Tn C A D), @Cong Tn D A B C *)
    intros.
    assert (Le C A1 C A2 \/ Le C A2 C A1).
      eapply le_cases.
    induction H5.
      eapply l7_22_aux.
        apply H.
        apply H0.
        apply H1.
        apply H2.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
        assumption.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
        assumption.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
      assumption.
    apply between_symmetry.
    eapply l7_22_aux.
      7:apply H5.
      apply between_symmetry.
      apply H.
      5:apply H3.
      4:apply H4.
      apply between_symmetry.
      apply H0.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
      assumption.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
    assumption.
Qed.

Lemma bet_col1 : forall A B C D, Bet A B D -> Bet A C D -> Col A B C.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Col Tn A B D) (_ : @Bet Tn A C B) (_ : @Cong Tn A B C D) (_ : @Bet Tn C A D), @Cong Tn D A B C *)
    intros.
    assert(Bet A B C \/ Bet A C B).
      eapply l5_3.
        apply H.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
      assumption.
(* Goal: @Col Tn M A B *)
    unfold Col.
    induction H1.
      left.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
      assumption.
    right; left.
    apply between_symmetry.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
    assumption.
Qed.

Lemma l7_25 : forall A B C,
  Cong C A C B ->
  exists X, Midpoint X A B.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Col Tn A B D) (_ : @Bet Tn A C B) (_ : @Cong Tn A B C D) (_ : @Bet Tn C A D), @Cong Tn D A B C *)
    intros.
    induction(col_dec A B C).
      assert(A = B \/ Midpoint C A B).
        apply l7_20.
          unfold Col in *.
(* Goal: forall (A B : @Tpoint Tn) (_ : not (@eq (@Tpoint Tn) A B)), not (@eq (@Tpoint Tn) B A) *)
          intuition.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
        assumption.
      induction H1.
(* Goal: @Bet Tn B D C *)
(* Goal: @Bet Tn B D C *)
        subst B.
        exists A.
        apply l7_3_2.
      exists C.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
      assumption.
    assert (exists P, Bet C A P /\ A<>P).
      apply point_construction_different.
    ex_and H1 P.
    prolong C B Q A P.
    assert (exists R, Bet A R Q /\ Bet B R P).
      eapply inner_pasch.
        apply between_symmetry.
        apply H1.
      apply between_symmetry.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
      assumption.
    ex_and H5 R.
    assert (exists X, Bet A X B /\ Bet R X C).
      eapply inner_pasch.
        apply H1.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
      assumption.
    ex_and H7 X.
    exists X.
(* Goal: forall (A B C : @Tpoint Tn) (_ : @Midpoint Tn B A C), @Cong Tn A B B C *)
    unfold Midpoint.
(* Goal: @Lt Tn A M A' M' *)
    split.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
      assumption.
    apply cong_left_commutativity.
    cut(Cong R A R B).
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Col Tn A B D) (_ : @Bet Tn A C B) (_ : @Cong Tn A B C D) (_ : @Bet Tn C A D), @Cong Tn D A B C *)
      intros.
      induction(eq_dec_points R C).
        subst R.
        assert (C = X).
          apply between_identity.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
          assumption.
        subst X.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
        assumption.
      eapply l4_17.
        apply H10.
(* Goal: @Col Tn M A B *)
        unfold Col.
        right; left.
        apply between_symmetry.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
        assumption.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
        assumption.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
      assumption.
    assert (OFSC C A P B C B Q A).
      unfold OFSC.
      repeat split.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
        assumption.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
        assumption.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
        assumption.
        apply cong_symmetry.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
        assumption.
        apply cong_symmetry.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
        assumption.
      apply cong_pseudo_reflexivity.
    assert (Cong P B Q A).
      eapply five_segment_with_def.
        eapply H9.
      unfold Col in H0.
(* Goal: forall (A B : @Tpoint Tn) (_ : not (@eq (@Tpoint Tn) A B)), not (@eq (@Tpoint Tn) B A) *)
      intuition.
      apply H0.
      subst A.
      apply between_trivial.
    assert (exists R', Bet A R' Q /\ Cong_3 B R P A R' Q).
      eapply l4_5.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
        assumption.
      apply cong_commutativity.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
      assumption.
    ex_and H11 R'.
    assert (IFSC B R P A A R' Q B).
      unfold IFSC.
      repeat split.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
        assumption.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
        assumption.
        apply cong_commutativity.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
        assumption.
        unfold Cong_3 in H12.
(* Goal: @Bet Tn C A D *)
        spliter.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
        assumption.
        apply cong_pseudo_reflexivity.
      apply cong_commutativity.
      apply cong_symmetry.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
      assumption.
    assert (IFSC B R P Q A R' Q P).
      unfold IFSC.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
      repeat split;try assumption.
        apply cong_commutativity.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
        assumption.
        unfold Cong_3 in H12.
(* Goal: @Bet Tn C A D *)
        spliter.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
        assumption.
      apply cong_pseudo_reflexivity.
    assert (Cong R A R' B).
      eapply l4_2.
      apply H13.
    assert (Cong R Q R' P).
      eapply l4_2.
      apply H14.
    assert (Cong_3 A R Q B R' P).
      unfold Cong_3.
      repeat split.
        apply cong_commutativity.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
        assumption.
        apply cong_commutativity.
        apply cong_symmetry.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
        assumption.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
      assumption.
    assert (Col B R' P).
      eapply l4_13.
        2:apply H17.
(* Goal: @Col Tn M A B *)
      unfold Col.
      left.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
      assumption.
    cut(R=R').
(* Goal: not (@Cong Tn A M A' M') *)
      intro.
      subst R'.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
      assumption.
    assert (B <> P).
      unfold IFSC, OFSC, Cong_3 in *.
(* Goal: @Bet Tn C A D *)
      spliter.
(* Goal: not (@Cong Tn A M A' M') *)
      intro.
      subst P.
      apply between_identity in H14.
      subst R.
      apply cong_reverse_identity in H12.
      subst R'.
      apply cong_reverse_identity in H32.
      subst Q.
      apply between_identity in H5.
      apply H2.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
      assumption.
    assert (A <> Q).
      unfold IFSC, OFSC, Cong_3 in *.
(* Goal: @Bet Tn C A D *)
      spliter.
(* Goal: not (@Cong Tn A M A' M') *)
      intro.
      subst Q.
      apply cong_reverse_identity in H20.
      subst P.
      apply H19.
      reflexivity.
    assert(B <> Q).
(* Goal: not (@Cong Tn A M A' M') *)
      intro.
      subst Q.
      apply cong_symmetry in H4.
      apply cong_identity in H4.
      subst P.
      apply H2.
      reflexivity.
    assert (B <> R).
(* Goal: not (@Cong Tn A M A' M') *)
      intro.
      unfold Cong_3, IFSC, OFSC in *.
(* Goal: @Bet Tn C A D *)
      spliter.
      subst R.
      clean_duplicated_hyps.
      assert (Col B A C).
(* Goal: @Col Tn B D P *)
(* Goal: @Cong Tn B D D B *)
(* Goal: and (@Midpoint Tn P A C) (@Midpoint Tn P B D) *)
        apply col_transitivity_1 with X; Col.
(* Goal: not (@Cong Tn A M A' M') *)
        intro.
        apply cong_symmetry in H12.
        apply cong_identity in H12.
        subst R'.
        subst X.
        clean_duplicated_hyps.
        assert (Bet B A C \/ Bet B C A).
          eapply l5_2.
            2:apply between_symmetry.
            2:apply H5.
(* Goal: not (@Cong Tn A M A' M') *)
            intro.
            apply H21.
            rewrite H9.
            reflexivity.
          apply between_symmetry.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
          assumption.
        apply H0.
(* Goal: @Col Tn M A B *)
        unfold Col.
(* Goal: and (@Midpoint Tn P A C) (@Midpoint Tn P B D) *)
        induction H9.
(* Goal: or (@eq (@Tpoint Tn) A B) (@Midpoint Tn M A B) *)
(* Goal: or (@eq (@Tpoint Tn) A B) (@Midpoint Tn M A B) *)
          right;right.
          apply between_symmetry.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
          assumption.
        right; left.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
        assumption.
      apply H0.
      apply col_permutation_4.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
      assumption.
    eapply (l6_21 A Q B P R R' ).
(* Goal: not (@Cong Tn A M A' M') *)
      intro.
      unfold Col in H23.
      induction H23.
        assert(Bet A B C).
          eapply outer_transitivity_between2.
            apply H23.
            apply between_symmetry.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
            assumption.
(* Goal: not (@Cong Tn A M A' M') *)
          intro.
          apply H21.
          rewrite H24.
          reflexivity.
        apply H0.
(* Goal: @Col Tn M A B *)
        unfold Col.
        left.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
        assumption.
      induction H23.
        assert(Bet B A C \/ Bet B C A).
          eapply l5_2.
            2:apply H23.
(* Goal: not (@Cong Tn A M A' M') *)
            intro.
            apply H21.
            rewrite H24.
            reflexivity.
          apply between_symmetry.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
          assumption.
        apply H0.
(* Goal: @Col Tn M A B *)
        unfold Col.
        induction H24.
(* Goal: or (@eq (@Tpoint Tn) A B) (@Midpoint Tn M A B) *)
(* Goal: or (@eq (@Tpoint Tn) A B) (@Midpoint Tn M A B) *)
          right;right.
          apply between_symmetry.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
          assumption.
        right; left.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
        assumption.
      assert(Bet A B C).
        eapply between_exchange3.
          apply between_symmetry.
          apply H23.
        apply between_symmetry.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
        assumption.
      apply H0.
(* Goal: @Col Tn M A B *)
      unfold Col.
      left.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
      assumption.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
      assumption.
(* Goal: @Col Tn M A B *)
      unfold Col.
      right; left.
      apply between_symmetry.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
      assumption.
(* Goal: @Col Tn M A B *)
      unfold Col.
      right; left.
      apply between_symmetry.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
      assumption.
(* Goal: @Col Tn M A B *)
      unfold Col.
      right; left.
      apply between_symmetry.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
      assumption.
(* Goal: @Col Tn M A B *)
    unfold Col.
    unfold Col in H18.
    induction H18.
      right; left.
      apply between_symmetry.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
      assumption.
    induction H18.
      left.
      apply between_symmetry.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
      assumption.
(* Goal: or (@eq (@Tpoint Tn) A B) (@Midpoint Tn M A B) *)
(* Goal: or (@eq (@Tpoint Tn) A B) (@Midpoint Tn M A B) *)
    right;right.
    apply between_symmetry.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
    assumption.
Qed.

Lemma midpoint_distinct_1 : forall I A B,
 A<>B ->
 Midpoint I A B ->
 I<>A /\ I<>B.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Col Tn A B D) (_ : @Bet Tn A C B) (_ : @Cong Tn A B C D) (_ : @Bet Tn C A D), @Cong Tn D A B C *)
    intros.
(* Goal: @Lt Tn A M A' M' *)
    split.
(* Goal: not (@Cong Tn A M A' M') *)
      intro.
(* Goal: False *)
(* Goal: not (@eq (@Tpoint Tn) I B) *)
      subst.
(* Goal: False *)
      unfold Midpoint in *.
(* Goal: False *)
      decompose [and] H0.
(* Goal: False *)
(* Goal: and (not (@eq (@Tpoint Tn) A B)) (not (@eq (@Tpoint Tn) I A)) *)
      treat_equalities.
(* Goal: forall (A B : @Tpoint Tn) (_ : not (@eq (@Tpoint Tn) A B)), not (@eq (@Tpoint Tn) B A) *)
      intuition.
(* Goal: False *)
(* Goal: not (@eq (@Tpoint Tn) I B) *)
    intro;subst.
(* Goal: False *)
    unfold Midpoint in *.
(* Goal: False *)
    decompose [and] H0.
(* Goal: False *)
(* Goal: and (not (@eq (@Tpoint Tn) A B)) (not (@eq (@Tpoint Tn) I A)) *)
    treat_equalities.
(* Goal: forall (A B : @Tpoint Tn) (_ : not (@eq (@Tpoint Tn) A B)), not (@eq (@Tpoint Tn) B A) *)
    intuition.
Qed.

Lemma midpoint_distinct_2 : forall I A B,
 I<>A ->
 Midpoint I A B ->
 A<>B /\ I<>B.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Col Tn A B D) (_ : @Bet Tn A C B) (_ : @Cong Tn A B C D) (_ : @Bet Tn C A D), @Cong Tn D A B C *)
    intros.
(* Goal: and (not (@eq (@Tpoint Tn) A B)) (not (@eq (@Tpoint Tn) I A)) *)
    assert (A<>B).
(* Goal: not (@Cong Tn A M A' M') *)
      intro.
(* Goal: @Bet Tn C A D *)
      unfold Midpoint in *;spliter.
(* Goal: False *)
(* Goal: and (not (@eq (@Tpoint Tn) A B)) (not (@eq (@Tpoint Tn) I A)) *)
      treat_equalities.
(* Goal: forall (A B : @Tpoint Tn) (_ : not (@eq (@Tpoint Tn) A B)), not (@eq (@Tpoint Tn) B A) *)
      intuition.
(* Goal: @Lt Tn A M A' M' *)
    split.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
      assumption.
(* Goal: not (@eq (@Tpoint Tn) I A) *)
    apply midpoint_distinct_1 in H0.
(* Goal: forall (A B : @Tpoint Tn) (_ : not (@eq (@Tpoint Tn) A B)), not (@eq (@Tpoint Tn) B A) *)
      intuition.
(* Goal: forall (A B : @Tpoint Tn) (_ : not (@eq (@Tpoint Tn) A B)), not (@eq (@Tpoint Tn) B A) *)
    intuition.
Qed.


Lemma midpoint_distinct_3 : forall I A B,
 I<>B ->
 Midpoint I A B ->
 A<>B /\ I<>A.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Col Tn A B D) (_ : @Bet Tn A C B) (_ : @Cong Tn A B C D) (_ : @Bet Tn C A D), @Cong Tn D A B C *)
    intros.
(* Goal: and (not (@eq (@Tpoint Tn) A B)) (not (@eq (@Tpoint Tn) I A)) *)
    assert (A<>B).
(* Goal: not (@Cong Tn A M A' M') *)
      intro.
(* Goal: @Bet Tn C A D *)
      unfold Midpoint in *;spliter.
(* Goal: False *)
(* Goal: and (not (@eq (@Tpoint Tn) A B)) (not (@eq (@Tpoint Tn) I A)) *)
      treat_equalities.
(* Goal: forall (A B : @Tpoint Tn) (_ : not (@eq (@Tpoint Tn) A B)), not (@eq (@Tpoint Tn) B A) *)
      intuition.
(* Goal: @Lt Tn A M A' M' *)
    split.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
      assumption.
(* Goal: not (@eq (@Tpoint Tn) I A) *)
    apply midpoint_distinct_1 in H0.
(* Goal: forall (A B : @Tpoint Tn) (_ : not (@eq (@Tpoint Tn) A B)), not (@eq (@Tpoint Tn) B A) *)
      intuition.
(* Goal: forall (A B : @Tpoint Tn) (_ : not (@eq (@Tpoint Tn) A B)), not (@eq (@Tpoint Tn) B A) *)
    intuition.
Qed.


Lemma midpoint_def : forall A B C, Bet A B C -> Cong A B B C -> Midpoint B A C.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Col Tn A B D) (_ : @Bet Tn A C B) (_ : @Cong Tn A B C D) (_ : @Bet Tn C A D), @Cong Tn D A B C *)
    intros.
(* Goal: forall (A B C : @Tpoint Tn) (_ : @Midpoint Tn B A C), @Cong Tn A B B C *)
    unfold Midpoint.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
    split;assumption.
Qed.

Lemma midpoint_bet : forall A B C, Midpoint B A C -> Bet A B C.
Proof.
(* Goal: forall (A B C : @Tpoint Tn) (_ : @Midpoint Tn B A C), @Cong Tn A B B C *)
    unfold Midpoint.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Col Tn A B D) (_ : @Bet Tn A C B) (_ : @Cong Tn A B C D) (_ : @Bet Tn C A D), @Cong Tn D A B C *)
    intros.
(* Goal: @Cong Tn A B B C *)
    elim H.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Col Tn A B D) (_ : @Bet Tn A C B) (_ : @Cong Tn A B C D) (_ : @Bet Tn C A D), @Cong Tn D A B C *)
    intros.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
    assumption.
Qed.

Lemma midpoint_col : forall A M B, Midpoint M A B -> Col M A B.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Col Tn A B D) (_ : @Bet Tn A C B) (_ : @Cong Tn A B C D) (_ : @Bet Tn C A D), @Cong Tn D A B C *)
    intros.
(* Goal: @Col Tn M A B *)
    unfold Col.
(* Goal: or (@eq (@Tpoint Tn) A B) (@Midpoint Tn M A B) *)
(* Goal: or (@eq (@Tpoint Tn) A B) (@Midpoint Tn M A B) *)
    right;right.
(* Goal: @Bet Tn B M A *)
    apply midpoint_bet.
(* Goal: @Midpoint Tn M B A *)
    apply l7_2.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
    assumption.
Qed.

Lemma midpoint_cong : forall A B C, Midpoint B A C -> Cong A B B C.
Proof.
(* Goal: forall (A B C : @Tpoint Tn) (_ : @Midpoint Tn B A C), @Cong Tn A B B C *)
    unfold Midpoint.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Col Tn A B D) (_ : @Bet Tn A C B) (_ : @Cong Tn A B C D) (_ : @Bet Tn C A D), @Cong Tn D A B C *)
    intros.
(* Goal: @Cong Tn A B B C *)
    elim H.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Col Tn A B D) (_ : @Bet Tn A C B) (_ : @Cong Tn A B C D) (_ : @Bet Tn C A D), @Cong Tn D A B C *)
    intros.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
    assumption.
Qed.

Lemma midpoint_not_midpoint : forall I A B,
  A<>B ->
  Midpoint I A B ->
~ Midpoint B A I.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Col Tn A B D) (_ : @Bet Tn A C B) (_ : @Cong Tn A B C D) (_ : @Bet Tn C A D), @Cong Tn D A B C *)
    intros.
    assert (I<>B).
(* Goal: not (@eq (@Tpoint Tn) I A) *)
      apply midpoint_distinct_1 in H0.
(* Goal: @eq (@Tpoint Tn) A B *)
        tauto.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
      assumption.
    apply midpoint_bet in H0.
(* Goal: not (@Cong Tn A M A' M') *)
    intro.
    apply midpoint_bet in H2.
    assert (I=B).
      apply between_symmetry in H0.
      apply between_symmetry in H2.
      eapply between_equality.
        apply H2.
      apply H0.
(* Goal: forall (A B : @Tpoint Tn) (_ : not (@eq (@Tpoint Tn) A B)), not (@eq (@Tpoint Tn) B A) *)
    intuition.
Qed.

Lemma swap_diff : forall (A B : Tpoint), A<>B -> B<>A.
Proof.
(* Goal: forall (A B : @Tpoint Tn) (_ : not (@eq (@Tpoint Tn) A B)), not (@eq (@Tpoint Tn) B A) *)
    intuition.
Qed.

Lemma cong_cong_half_1 : forall A M B A' M' B',
 Midpoint M A B -> Midpoint M' A' B' ->
 Cong A B A' B' -> Cong A M A' M'.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Col Tn A B D) (_ : @Bet Tn A C B) (_ : @Cong Tn A B C D) (_ : @Bet Tn C A D), @Cong Tn D A B C *)
    intros.
(* Goal: False *)
    unfold Midpoint in *.
(* Goal: @Bet Tn C A D *)
    spliter.
    assert(exists M'', Bet A' M'' B' /\ Cong_3 A M B A' M'' B').
      eapply l4_5.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
        assumption.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
      assumption.
    ex_and H4 M''.
    assert (Midpoint M'' A' B').
(* Goal: forall (A B C : @Tpoint Tn) (_ : @Midpoint Tn B A C), @Cong Tn A B B C *)
      unfold Midpoint.
(* Goal: @Lt Tn A M A' M' *)
      split.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
        assumption.
      unfold Cong_3 in H5.
(* Goal: @Bet Tn C A D *)
      spliter.
      eapply cong_transitivity.
        apply cong_symmetry.
        apply H5.
      eapply cong_transitivity.
        apply H3.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
      assumption.
    assert(M'=M'').
(* Goal: @Lt Tn A M A' M' *)
      eapply l7_17; unfold Midpoint; split.
        apply H0.
        apply H2.
        apply H4.
      unfold Midpoint in H6.
(* Goal: @Bet Tn C A D *)
      spliter.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
      assumption.
    subst M''.
    unfold Cong_3 in H5.
(* Goal: @Bet Tn C A D *)
    spliter.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
    assumption.
Qed.

Lemma cong_cong_half_2 : forall A M B A' M' B',
 Midpoint M A B -> Midpoint M' A' B' ->
 Cong A B A' B' -> Cong B M B' M'.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Col Tn A B D) (_ : @Bet Tn A C B) (_ : @Cong Tn A B C D) (_ : @Bet Tn C A D), @Cong Tn D A B C *)
    intros.
(* Goal: @Cong Tn B M B' M' *)
    apply cong_cong_half_1 with A A'.
(* Goal: @Midpoint Tn M' B' A' *)
(* Goal: @Cong Tn B A B' A' *)
      Midpoint.
(* Goal: @Midpoint Tn M' B' A' *)
(* Goal: @Cong Tn B A B' A' *)
      Midpoint.
(* Goal: @Cong Tn A B D C *)
    Cong.
Qed.

Lemma cong_mid2__cong : forall A M B A' M' B',
 Midpoint M A B -> Midpoint M' A' B' ->
 Cong A M A' M' -> Cong A B A' B'.
Proof.
(* Goal: @Cong Tn A B D C *)
    intros A M B A' M' B' HM HM' HCong.
(* Goal: @Le Tn A B A' B' *)
    destruct HM.
(* Goal: @Le Tn A B A' B' *)
    destruct HM'.
(* Goal: @eq (@Tpoint Tn) A B *)
    apply (l2_11 _ M _ _ M'); auto.
(* Goal: @eq (@Tpoint Tn) A B *)
    apply (cong_transitivity _ _ A' M'); auto.
(* Goal: @Cong Tn A B D C *)
    apply (cong_transitivity _ _ A M); Cong.
Qed.

Lemma mid__lt : forall A M B,
 A <> B -> Midpoint M A B ->
 Lt A M A B.
Proof.
(* Goal: forall (A M B : @Tpoint Tn) (_ : not (@eq (@Tpoint Tn) A B)) (_ : @Midpoint Tn M A B), @Lt Tn A M A B *)
    intros A M B HAB HM.
(* Goal: @Lt Tn A M A B *)
    destruct (midpoint_distinct_1 M A B HAB HM) as [HMA HMB].
(* Goal: @Le Tn A B A' B' *)
    destruct HM.
(* Goal: @Lt Tn A M A' M' *)
    split.
(* Goal: @Cong Tn A B D C *)
      exists M; Cong.
(* Goal: not (@Cong Tn A M A' M') *)
    intro.
(* Goal: @eq (@Tpoint Tn) A B *)
    apply HMB, between_cong with A; auto.
Qed.

Lemma le_mid2__le13 : forall A M B A' M' B',
 Midpoint M A B -> Midpoint M' A' B' ->
 Le A M A' M' -> Le A B A' B'.
Proof.
(* Goal: forall (A M B A' M' B' : @Tpoint Tn) (_ : @Midpoint Tn M A B) (_ : @Midpoint Tn M' A' B') (_ : @Le Tn A B A' B'), @Le Tn A M A' M' *)
    intros A M B A' M' B' HM HM' Hle.
(* Goal: @Le Tn A B A' B' *)
    destruct HM.
(* Goal: @Le Tn A B A' B' *)
    destruct HM'.
(* Goal: @eq (@Tpoint Tn) A B *)
    apply (bet2_le2__le1346 _ M _ _ M'); auto.
(* Goal: @eq (@Tpoint Tn) A B *)
    apply (l5_6 A M A' M'); auto.
Qed.

Lemma le_mid2__le12 : forall A M B A' M' B',
 Midpoint M A B -> Midpoint M' A' B' ->
 Le A B A' B' -> Le A M A' M'.
Proof.
(* Goal: forall (A M B A' M' B' : @Tpoint Tn) (_ : @Midpoint Tn M A B) (_ : @Midpoint Tn M' A' B') (_ : @Le Tn A B A' B'), @Le Tn A M A' M' *)
    intros A M B A' M' B' HM HM' Hle.
(* Goal: @eq (@Tpoint Tn) A B *)
    elim(le_cases A M A' M'); auto.
(* Goal: not (@Cong Tn A M A' M') *)
    intro.
(* Goal: @Le Tn A M A' M' *)
    assert(Le A' B' A B) by (apply (le_mid2__le13 _ M' _ _ M); auto).
(* Goal: @Le Tn A M A' M' *)
    apply cong__le.
(* Goal: @eq (@Tpoint Tn) A B *)
    apply (cong_cong_half_1 _ _ B _ _ B'); auto.
(* Goal: @eq (@Tpoint Tn) A B *)
    apply le_anti_symmetry; auto.
Qed.

Lemma lt_mid2__lt13 : forall A M B A' M' B',
 Midpoint M A B -> Midpoint M' A' B' ->
 Lt A M A' M' -> Lt A B A' B'.
Proof.
(* Goal: forall (A M B A' M' B' : @Tpoint Tn) (_ : @Midpoint Tn M A B) (_ : @Midpoint Tn M' A' B') (_ : @Lt Tn A B A' B'), @Lt Tn A M A' M' *)
    intros A M B A' M' B' HM HM' [HLe HNcong].
(* Goal: @Lt Tn A M A' M' *)
    split.
(* Goal: @Le Tn A B A' B' *)
(* Goal: not (@Cong Tn A B A' B') *)
      apply le_mid2__le13 with M M'; trivial.
(* Goal: not (@Cong Tn A M A' M') *)
    intro.
(* Goal: False *)
    apply HNcong, cong_cong_half_1 with B B'; trivial.
Qed.

Lemma lt_mid2__lt12 : forall A M B A' M' B',
 Midpoint M A B -> Midpoint M' A' B' ->
 Lt A B A' B' -> Lt A M A' M'.
Proof.
(* Goal: forall (A M B A' M' B' : @Tpoint Tn) (_ : @Midpoint Tn M A B) (_ : @Midpoint Tn M' A' B') (_ : @Lt Tn A B A' B'), @Lt Tn A M A' M' *)
    intros A M B A' M' B' HM HM' [HLe HNcong].
(* Goal: @Lt Tn A M A' M' *)
    split.
(* Goal: @Le Tn A M A' M' *)
(* Goal: not (@Cong Tn A M A' M') *)
      apply le_mid2__le12 with B B'; trivial.
(* Goal: not (@Cong Tn A M A' M') *)
    intro.
(* Goal: False *)
    apply HNcong, cong_mid2__cong with M M'; trivial.
Qed.

Lemma midpoint_preserves_out :
 forall A B C A' B' C' M,
  Out A B C ->
  Midpoint M A A' ->
  Midpoint M B B' ->
  Midpoint M C C' ->
 Out A' B' C'.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Col Tn A B D) (_ : @Bet Tn A C B) (_ : @Cong Tn A B C D) (_ : @Bet Tn C A D), @Cong Tn D A B C *)
    intros.
    unfold Out in H.
(* Goal: @Bet Tn C A D *)
    spliter.
    unfold Out.
    repeat split.
(* Goal: not (@Cong Tn A M A' M') *)
      intro.
      subst B'.
      assert (A = B).
        eapply symmetric_point_uniqueness.
(* Goal: @Midpoint Tn M B A *)
          apply l7_2.
          apply H0.
(* Goal: @Midpoint Tn M B A *)
        apply l7_2.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
        assumption.
(* Goal: @eq (@Tpoint Tn) A B *)
      auto.
(* Goal: not (@Cong Tn A M A' M') *)
      intro.
      subst C'.
      assert (A = C).
        eapply symmetric_point_uniqueness.
(* Goal: @Midpoint Tn M B A *)
          apply l7_2.
          apply H0.
(* Goal: @Midpoint Tn M B A *)
        apply l7_2.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
        assumption.
(* Goal: @eq (@Tpoint Tn) A B *)
      auto.
    induction H4.
      left.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
      apply (l7_15 A B C A' B' C' M); assumption.
(* Goal: or (@eq (@Tpoint Tn) A B) (@Midpoint Tn M A B) *)
(* Goal: or (@eq (@Tpoint Tn) A B) (@Midpoint Tn M A B) *)
    right.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
    eapply (l7_15 A C B A' C' B' M); assumption.
Qed.

Lemma col_cong_bet : forall A B C D, Col A B D -> Cong A B C D -> Bet A C B -> Bet  C A D \/ Bet C B D.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Col Tn A B D) (_ : @Bet Tn A C B) (_ : @Cong Tn A B C D) (_ : @Bet Tn C A D), @Cong Tn D A B C *)
intros.

prolong B A D1 B C.
prolong A B D2 A C.

assert(Cong A B C D1).
eapply (l2_11 A C B C A D1).
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
assumption.
eapply between_exchange3.
apply between_symmetry.
apply H1.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
assumption.
apply cong_pseudo_reflexivity.
(* Goal: @Cong Tn A B D C *)
Cong.
assert(D = D1 \/ Midpoint C D D1).
eapply l7_20.
apply bet_col in H1.
apply bet_col in H2.

(* Goal: @Bet Tn B D C *)
induction (eq_dec_points A B).
(* Goal: @Bet Tn B D C *)
(* Goal: @Bet Tn B D C *)
subst B.
apply cong_symmetry in H0.
(* Goal: @eq (@Tpoint Tn) A B *)
apply cong_identity in H0.
(* Goal: @Bet Tn A D C *)
(* Goal: @Bet Tn B D C *)
subst D.
(* Goal: @Col Tn B D P *)
(* Goal: @Cong Tn B D D B *)
(* Goal: and (@Midpoint Tn P A C) (@Midpoint Tn P B D) *)
Col.
(* Goal: @Col Tn B D P *)
(* Goal: @Cong Tn B D D B *)
(* Goal: and (@Midpoint Tn P A C) (@Midpoint Tn P B D) *)
eapply (col3 A B); Col.

(* Goal: @Cong Tn A B D C *)
eCong.

induction H7.
subst D1.
left.
eapply between_exchange3.
apply between_symmetry.
apply H1.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
assumption.

assert(Cong B A C D2).
eapply (l2_11 B C A C B D2).
(* Goal: @Bet Tn A C C *)
(* Goal: @Bet Tn B D C *)
Between.
eapply between_exchange3.
apply H1.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
assumption.
apply cong_pseudo_reflexivity.
(* Goal: @Cong Tn A B D C *)
Cong.

assert(Midpoint C D2 D1).
(* Goal: forall (A B C : @Tpoint Tn) (_ : @Midpoint Tn B A C), @Cong Tn A B B C *)
unfold Midpoint.
(* Goal: @Lt Tn A M A' M' *)
split.

(* Goal: @Bet Tn B D C *)
induction(eq_dec_points A B).
(* Goal: @Bet Tn B D C *)
(* Goal: @Bet Tn B D C *)
subst B.
apply cong_symmetry in H0.
(* Goal: @eq (@Tpoint Tn) A B *)
apply cong_identity in H0.
(* Goal: @Bet Tn A D C *)
(* Goal: @Bet Tn B D C *)
subst D.
apply is_midpoint_id in H7.
subst D1.
(* Goal: @Bet Tn A C C *)
(* Goal: @Bet Tn B D C *)
Between.
apply between_symmetry.

(* Goal: @Bet Tn C A D *)
induction(eq_dec_points B C).
(* Goal: @Bet Tn C A B *)
subst C.
apply between_symmetry.
apply cong_identity in H3.
subst D1.
(* Goal: @Bet Tn A C C *)
(* Goal: @Bet Tn B D C *)
Between.

assert(Bet D1 C B).
(* Goal: @Bet Tn A C C *)
(* Goal: @Bet Tn B D C *)
eBetween.
assert(Bet C B D2).
(* Goal: @Bet Tn A C C *)
(* Goal: @Bet Tn B D C *)
eBetween.
eapply (outer_transitivity_between).
apply H11.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
assumption.
(* Goal: @eq (@Tpoint Tn) A B *)
auto.
unfold Midpoint in H7.
(* Goal: @Bet Tn C A D *)
spliter.
eapply cong_transitivity.
apply cong_symmetry.
apply cong_commutativity.
apply H8.
eapply cong_transitivity.
apply H0.
(* Goal: @Cong Tn A B D C *)
Cong.
assert(D = D2).
eapply symmetric_point_uniqueness.
(* Goal: @Midpoint Tn M B A *)
apply l7_2.
apply H7.
(* Goal: @Midpoint Tn M B A *)
apply l7_2.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
assumption.
subst D2.
(* Goal: or (@eq (@Tpoint Tn) A B) (@Midpoint Tn M A B) *)
(* Goal: or (@eq (@Tpoint Tn) A B) (@Midpoint Tn M A B) *)
right.
eapply between_exchange3.
apply H1.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
assumption.
Qed.

Lemma col_cong2_bet1 : forall A B C D, Col A B D -> Bet A C B -> Cong A B C D -> Cong A C B D -> Bet C B D.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Col Tn A B D) (_ : @Bet Tn A C B) (_ : @Cong Tn A B C D) (_ : @Bet Tn C A D), @Cong Tn D A B C *)
intros.
(* Goal: @Bet Tn C B D *)
induction(eq_dec_points A C).
(* Goal: @Bet Tn C A B *)
subst C.
(* Goal: @Bet Tn A B D *)
(* Goal: @Bet Tn C B D *)
apply cong_symmetry in H2.
(* Goal: @Bet Tn B A D *)
(* Goal: @Bet Tn C A D *)
apply cong_identity in H2.
(* Goal: @Bet Tn A D C *)
(* Goal: @Bet Tn B D C *)
subst D.
(* Goal: @Bet Tn A C C *)
(* Goal: @Bet Tn B D C *)
Between.

(* Goal: @Bet Tn C A D *)
assert(HH:=col_cong_bet A B C D H H1 H0).
(* Goal: @Bet Tn C A D *)
induction HH.
(* Goal: @Bet Tn C B D *)
(* Goal: @Bet Tn C B D *)
assert(A = D /\ B = C).
(* Goal: and (@eq (@Tpoint Tn) C A) (@eq (@Tpoint Tn) D B) *)
(* Goal: @Bet Tn C A D *)
eapply bet_cong_eq.
(* Goal: @Bet Tn A C C *)
(* Goal: @Bet Tn B D C *)
Between.
(* Goal: @Bet Tn A C C *)
(* Goal: @Bet Tn B D C *)
eBetween.
(* Goal: @Cong Tn A B D C *)
Cong.
(* Goal: @Bet Tn C A D *)
spliter.
(* Goal: @Bet Tn A D C *)
(* Goal: @Bet Tn B D C *)
subst D.
(* Goal: @Bet Tn C A B *)
subst C.
(* Goal: @Bet Tn A C C *)
(* Goal: @Bet Tn B D C *)
Between.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
assumption.
Qed.

Lemma col_cong2_bet2 : forall A B C D, Col A B D -> Bet A C B -> Cong A B C D -> Cong A D B C -> Bet C A D.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Col Tn A B D) (_ : @Bet Tn A C B) (_ : @Cong Tn A B C D) (_ : @Bet Tn C A D), @Cong Tn D A B C *)
intros.

(* Goal: @Bet Tn C A D *)
induction(eq_dec_points B C).
(* Goal: @Bet Tn C A B *)
subst C.
(* Goal: @Bet Tn B A D *)
(* Goal: @Bet Tn C A D *)
apply cong_identity in H2.
(* Goal: @Bet Tn A D C *)
(* Goal: @Bet Tn B D C *)
subst D.
(* Goal: @Bet Tn A C C *)
(* Goal: @Bet Tn B D C *)
Between.

(* Goal: @Bet Tn C A D *)
assert(HH:=col_cong_bet A B C D H H1 H0).
(* Goal: @Bet Tn C A D *)
induction HH.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
assumption.

(* Goal: @Bet Tn C A D *)
assert(C = A /\ D = B).
(* Goal: and (@eq (@Tpoint Tn) C A) (@eq (@Tpoint Tn) D B) *)
(* Goal: @Bet Tn C A D *)
eapply bet_cong_eq.
(* Goal: @Bet Tn A C C *)
(* Goal: @Bet Tn B D C *)
Between.
(* Goal: @Bet Tn A C C *)
(* Goal: @Bet Tn B D C *)
eBetween.
(* Goal: @Cong Tn A B D C *)
Cong.
(* Goal: @Bet Tn C A D *)
spliter.
(* Goal: @Bet Tn A D C *)
(* Goal: @Bet Tn B D C *)
subst D.
(* Goal: @Bet Tn C A B *)
subst C.
(* Goal: @Bet Tn A C C *)
(* Goal: @Bet Tn B D C *)
Between.
Qed.

Lemma col_cong2_bet3 : forall A B C D, Col A B D -> Bet A B C -> Cong A B C D -> Cong A C B D -> Bet B C D.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Col Tn A B D) (_ : @Bet Tn A C B) (_ : @Cong Tn A B C D) (_ : @Bet Tn C A D), @Cong Tn D A B C *)
intros.

(* Goal: @Bet Tn B D C *)
induction(eq_dec_points A B).
(* Goal: @Bet Tn B D C *)
(* Goal: @Bet Tn B D C *)
subst B.
(* Goal: @Bet Tn A D C *)
(* Goal: @Bet Tn B D C *)
apply cong_symmetry in H1.
(* Goal: @Bet Tn A D C *)
(* Goal: @Bet Tn B D C *)
apply cong_identity in H1.
(* Goal: @Bet Tn A D C *)
(* Goal: @Bet Tn B D C *)
subst D.
(* Goal: @Bet Tn A C C *)
(* Goal: @Bet Tn B D C *)
Between.


(* Goal: @Bet Tn B C D *)
eapply (col_cong2_bet2 _ A).
(* Goal: @Col Tn A D C *)
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
apply bet_col in H0.
(* Goal: @Col Tn A D C *)
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
ColR.
(* Goal: @Bet Tn A C C *)
(* Goal: @Bet Tn B D C *)
Between.
(* Goal: @Cong Tn A B D C *)
Cong.
(* Goal: @Cong Tn A B D C *)
Cong.
Qed.

Lemma col_cong2_bet4 : forall A B C D, Col A B C -> Bet A B D -> Cong A B C D -> Cong A D B C -> Bet B D C.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Col Tn A B D) (_ : @Bet Tn A C B) (_ : @Cong Tn A B C D) (_ : @Bet Tn C A D), @Cong Tn D A B C *)
intros.
(* Goal: @Bet Tn B D C *)
induction(eq_dec_points A B).
(* Goal: @Bet Tn B D C *)
(* Goal: @Bet Tn B D C *)
subst B.
(* Goal: @Bet Tn A D C *)
(* Goal: @Bet Tn B D C *)
apply cong_symmetry in H1.
(* Goal: @Bet Tn A D C *)
(* Goal: @Bet Tn B D C *)
apply cong_identity in H1.
(* Goal: @Bet Tn A D C *)
(* Goal: @Bet Tn B D C *)
subst D.
(* Goal: @Bet Tn A C C *)
(* Goal: @Bet Tn B D C *)
Between.
(* Goal: @Bet Tn B D C *)
apply (col_cong2_bet1 A D B C).
(* Goal: @Col Tn A D C *)
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
apply bet_col in H0.
(* Goal: @Col Tn A D C *)
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
ColR.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
assumption.
(* Goal: @Cong Tn A B D C *)
Cong.
(* Goal: @Cong Tn A B D C *)
Cong.
Qed.

Lemma col_bet2_cong1 : forall A B C D, Col A B D -> Bet A C B -> Cong A B C D -> Bet C B D -> Cong A C D B.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Col Tn A B D) (_ : @Bet Tn A C B) (_ : @Cong Tn A B C D) (_ : @Bet Tn C A D), @Cong Tn D A B C *)
intros.
(* Goal: @Cong Tn A B D C *)
apply (l4_3 A C B D B C); Between; Cong.
Qed.

Lemma col_bet2_cong2 : forall A B C D, Col A B D -> Bet A C B -> Cong A B C D -> Bet C A D -> Cong D A B C.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Col Tn A B D) (_ : @Bet Tn A C B) (_ : @Cong Tn A B C D) (_ : @Bet Tn C A D), @Cong Tn D A B C *)
intros.
(* Goal: @Cong Tn A B D C *)
apply (l4_3 D A C B C A); Between; Cong.
Qed.


Lemma bet2_lt2__lt : forall O o A B a b : Tpoint,
       Bet a o b -> Bet A O B -> Lt o a O A -> Lt o b O B -> Lt a b A B.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Col Tn A B D) (_ : @Bet Tn A C B) (_ : @Cong Tn A B C D) (_ : @Bet Tn C A D), @Cong Tn D A B C *)
intros.
unfold Lt.
(* Goal: @Lt Tn A M A' M' *)
split.
unfold Lt in *.
(* Goal: @Bet Tn C A D *)
spliter.
(* Goal: @eq (@Tpoint Tn) A B *)
apply(bet2_le2__le O o A B a b); auto.
(* Goal: not (@Cong Tn A M A' M') *)
intro.

induction(eq_dec_points O A).
(* Goal: False *)
(* Goal: and (not (@eq (@Tpoint Tn) A B)) (not (@eq (@Tpoint Tn) I A)) *)
treat_equalities.
unfold Lt in H1.
(* Goal: @Bet Tn C A D *)
spliter.
apply le_zero in H0.
(* Goal: False *)
(* Goal: and (not (@eq (@Tpoint Tn) A B)) (not (@eq (@Tpoint Tn) I A)) *)
treat_equalities.
apply H1.
apply cong_trivial_identity.

induction(eq_dec_points O B).
(* Goal: False *)
(* Goal: and (not (@eq (@Tpoint Tn) A B)) (not (@eq (@Tpoint Tn) I A)) *)
treat_equalities.
unfold Lt in H2.
(* Goal: @Bet Tn C A D *)
spliter.
apply le_zero in H0.
(* Goal: False *)
(* Goal: and (not (@eq (@Tpoint Tn) A B)) (not (@eq (@Tpoint Tn) I A)) *)
treat_equalities.
apply H2.
apply cong_trivial_identity.

unfold Lt in *.
(* Goal: @Bet Tn C A D *)
spliter.

unfold Le in H1.
ex_and H1 a'.
unfold Le in H2.
ex_and H2 b'.

assert(Bet a' O b').
  apply between_inner_transitivity with B.
    apply between_exchange3 with A.
(* Goal: @Bet Tn A C C *)
(* Goal: @Bet Tn B D C *)
      Between.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
    assumption.
(* Goal: @Bet Tn A C C *)
(* Goal: @Bet Tn B D C *)
  Between.
assert(Cong a b a' b').
{
(* Goal: @Cong Tn A B D C *)
  apply (l2_11 a o b a' O b'); Cong.
}
assert(Cong a' b' A B) by (apply cong_transitivity with a b; Cong).
(* Goal: @Bet Tn A C C *)
(* Goal: @Bet Tn B D C *)
assert(Bet A b' B) by eBetween.

induction(eq_dec_points A a').
(* Goal: False *)
(* Goal: and (not (@eq (@Tpoint Tn) A B)) (not (@eq (@Tpoint Tn) I A)) *)
treat_equalities.
assert(b'=B \/ Midpoint A b' B).
{
  apply l7_20.
(* Goal: @Col Tn B D P *)
(* Goal: @Cong Tn B D D B *)
(* Goal: and (@Midpoint Tn P A C) (@Midpoint Tn P B D) *)
  Col.
(* Goal: @Cong Tn A B D C *)
  Cong.
}
induction H1.
(* Goal: False *)
(* Goal: and (not (@eq (@Tpoint Tn) A B)) (not (@eq (@Tpoint Tn) I A)) *)
treat_equalities.
contradiction.
(* Goal: False *)
unfold Midpoint in *.
(* Goal: @Bet Tn C A D *)
spliter.
assert(b' = B).
{
  apply (between_cong A).
(* Goal: @Bet Tn A C C *)
(* Goal: @Bet Tn B D C *)
  Between.
(* Goal: @Cong Tn A B D C *)
  Cong.
}
(* Goal: @eq (@Tpoint Tn) A B *)
treat_equalities; tauto.

(* Goal: @Bet Tn A C C *)
(* Goal: @Bet Tn B D C *)
assert(Bet B a' A) by eBetween.
induction(eq_dec_points B b').
(* Goal: False *)
(* Goal: and (not (@eq (@Tpoint Tn) A B)) (not (@eq (@Tpoint Tn) I A)) *)
treat_equalities.
assert(a'=A \/ Midpoint B a' A).
{
  apply l7_20.
(* Goal: @Col Tn B D P *)
(* Goal: @Cong Tn B D D B *)
(* Goal: and (@Midpoint Tn P A C) (@Midpoint Tn P B D) *)
  Col.
(* Goal: @Cong Tn A B D C *)
  Cong.
}
(* Goal: @eq (@Tpoint Tn) A B *)
induction H2.
(* Goal: False *)
(* Goal: and (not (@eq (@Tpoint Tn) A B)) (not (@eq (@Tpoint Tn) I A)) *)
treat_equalities.
contradiction.
(* Goal: False *)
unfold Midpoint in *.
(* Goal: @Bet Tn C A D *)
spliter.
assert(a' = A).
{
  apply (between_cong B).
(* Goal: @Bet Tn A C C *)
(* Goal: @Bet Tn B D C *)
  Between.
(* Goal: @Cong Tn A B D C *)
  Cong.
}
(* Goal: @eq (@Tpoint Tn) A B *)
treat_equalities; tauto.

assert(Bet a' A b' \/ Bet a' B b').
{
  apply(col_cong_bet A B a' b').
(* Goal: @Col Tn B D P *)
(* Goal: @Cong Tn B D D B *)
(* Goal: and (@Midpoint Tn P A C) (@Midpoint Tn P B D) *)
  Col.
(* Goal: @Cong Tn A B D C *)
  Cong.
(* Goal: @Bet Tn A C C *)
(* Goal: @Bet Tn B D C *)
  eBetween.
}
induction H17.
assert(A = a').
{
  apply(between_equality _ _ b').
    apply between_exchange4 with O.
(* Goal: @Bet Tn A C C *)
(* Goal: @Bet Tn B D C *)
      Between.
      apply between_inner_transitivity with B.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
        assumption.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
      assumption.
(* Goal: @Bet Tn A B D *)
(* Goal: @Cong Tn A D B C *)
(* Goal: @Cong Tn A B D C *)
  assumption.
}
(* Goal: @eq (@Tpoint Tn) A B *)
treat_equalities; tauto.
assert(b' = B).
{
  apply(between_equality _ _ a').
(* Goal: @Bet Tn A C C *)
(* Goal: @Bet Tn B D C *)
  Between.
  apply between_exchange4 with O.
(* Goal: @Bet Tn A C C *)
(* Goal: @Bet Tn B D C *)
    Between.
  apply between_inner_transitivity with A.
(* Goal: @Bet Tn A C C *)
(* Goal: @Bet Tn B D C *)
    Between.
(* Goal: @Bet Tn A C C *)
(* Goal: @Bet Tn B D C *)
  Between.
}
(* Goal: @eq (@Tpoint Tn) A B *)
treat_equalities; tauto.
Qed.

Lemma bet2_lt_le__lt : forall O o A B a b : Tpoint,
       Bet a o b -> Bet A O B -> Cong o a O A -> Lt o b O B -> Lt a b A B.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Col Tn A B D) (_ : @Bet Tn A C B) (_ : @Cong Tn A B C D) (_ : @Bet Tn C A D), @Cong Tn D A B C *)
intros.
unfold Lt.
(* Goal: @Lt Tn A M A' M' *)
split.
unfold Lt in *.
(* Goal: @Bet Tn C A D *)
spliter.
assert(Le o a O A).
{
  unfold Le.
  exists A.
(* Goal: @Bet Tn A C C *)
(* Goal: @Bet Tn B D C *)
  split; Between.
}
(* Goal: @eq (@Tpoint Tn) A B *)
apply(bet2_le2__le O o A B a b); auto.
(* Goal: not (@Cong Tn A M A' M') *)
intro.

assert(HH:=segment_construction A O o b).
ex_and HH b'.

unfold Lt in H2.
(* Goal: @Bet Tn C A D *)
spliter.
apply H6.

(* Goal: @Cong Tn A B D C *)
apply(l4_3_1 a o b A O B H H0 ); Cong.
Qed.

End T7_2.

Hint Resolve midpoint_bet : between.
Hint Resolve midpoint_col : col.
Hint Resolve midpoint_cong : cong.