Require Export GeoCoq.Tarski_dev.Ch08_orthogonality.
Require Export GeoCoq.Tarski_dev.Annexes.coplanar.

Ltac clean_reap_hyps :=
  clean_duplicated_hyps;
  repeat
  match goal with
   | H:(Midpoint ?A ?B ?C), H2 : Midpoint ?A ?C ?B |- _ => clear H2
   | H:(Col ?A ?B ?C), H2 : Col ?A ?C ?B |- _ => clear H2
   | H:(Col ?A ?B ?C), H2 : Col ?B ?A ?C |- _ => clear H2
   | H:(Col ?A ?B ?C), H2 : Col ?B ?C ?A |- _ => clear H2
   | H:(Col ?A ?B ?C), H2 : Col ?C ?B ?A |- _ => clear H2
   | H:(Col ?A ?B ?C), H2 : Col ?C ?A ?B |- _ => clear H2
   | H:(Bet ?A ?B ?C), H2 : Bet ?C ?B ?A |- _ => clear H2
   | H:(Cong ?A ?B ?C ?D), H2 : Cong ?A ?B ?D ?C |- _ => clear H2
   | H:(Cong ?A ?B ?C ?D), H2 : Cong ?C ?D ?A ?B |- _ => clear H2
   | H:(Cong ?A ?B ?C ?D), H2 : Cong ?C ?D ?B ?A |- _ => clear H2
   | H:(Cong ?A ?B ?C ?D), H2 : Cong ?D ?C ?B ?A |- _ => clear H2
   | H:(Cong ?A ?B ?C ?D), H2 : Cong ?D ?C ?A ?B |- _ => clear H2
   | H:(Cong ?A ?B ?C ?D), H2 : Cong ?B ?A ?C ?D |- _ => clear H2
   | H:(Cong ?A ?B ?C ?D), H2 : Cong ?B ?A ?D ?C |- _ => clear H2
   | H:(Perp ?A ?B ?C ?D), H2 : Perp ?A ?B ?D ?C |- _ => clear H2
   | H:(Perp ?A ?B ?C ?D), H2 : Perp ?C ?D ?A ?B |- _ => clear H2
   | H:(Perp ?A ?B ?C ?D), H2 : Perp ?C ?D ?B ?A |- _ => clear H2
   | H:(Perp ?A ?B ?C ?D), H2 : Perp ?D ?C ?B ?A |- _ => clear H2
   | H:(Perp ?A ?B ?C ?D), H2 : Perp ?D ?C ?A ?B |- _ => clear H2
   | H:(Perp ?A ?B ?C ?D), H2 : Perp ?B ?A ?C ?D |- _ => clear H2
   | H:(Perp ?A ?B ?C ?D), H2 : Perp ?B ?A ?D ?C |- _ => clear H2
   | H:(?A<>?B), H2 : (?B<>?A) |- _ => clear H2
   | H:(Per ?A ?D ?C), H2 : (Per ?C ?D ?A) |- _ => clear H2
   | H:(Perp_at ?X ?A ?B ?C ?D), H2 : Perp_at ?X ?A ?B ?D ?C |- _ => clear H2
   | H:(Perp_at ?X ?A ?B ?C ?D), H2 : Perp_at ?X ?C ?D ?A ?B |- _ => clear H2
   | H:(Perp_at ?X ?A ?B ?C ?D), H2 : Perp_at ?X ?C ?D ?B ?A |- _ => clear H2
   | H:(Perp_at ?X ?A ?B ?C ?D), H2 : Perp_at ?X ?D ?C ?B ?A |- _ => clear H2
   | H:(Perp_at ?X ?A ?B ?C ?D), H2 : Perp_at ?X ?D ?C ?A ?B |- _ => clear H2
   | H:(Perp_at ?X ?A ?B ?C ?D), H2 : Perp_at ?X ?B ?A ?C ?D |- _ => clear H2
   | H:(Perp_at ?X ?A ?B ?C ?D), H2 : Perp_at ?X ?B ?A ?D ?C |- _ => clear H2
end.

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:Le ?A ?B ?C ?D, H2 : ?B <> ?A |-_ =>
      let T:= fresh in (not_exist_hyp_comm C D);
        assert (T:= le_diff A B C D (swap_diff B A 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:Midpoint ?I ?A ?B, H2 : ?A<>?B |- _ =>
      let T:= fresh in (not_exist_hyp2 I B I A);
       assert (T:= midpoint_distinct_1 I A B H2 H);
       decompose [and] T;clear T;clean_reap_hyps
      | H:Midpoint ?I ?A ?B, H2 : ?B<>?A |- _ =>
      let T:= fresh in (not_exist_hyp2 I B I A);
       assert (T:= midpoint_distinct_1 I A B (swap_diff B A H2) H);
       decompose [and] T;clear T;clean_reap_hyps

      | H:Midpoint ?I ?A ?B, H2 : ?I<>?A |- _ =>
      let T:= fresh in (not_exist_hyp2 I B A B);
       assert (T:= midpoint_distinct_2 I A B H2 H);
       decompose [and] T;clear T;clean_reap_hyps
      | H:Midpoint ?I ?A ?B, H2 : ?A<>?I |- _ =>
      let T:= fresh in (not_exist_hyp2 I B A B);
       assert (T:= midpoint_distinct_2 I A B (swap_diff A I H2) H);
       decompose [and] T;clear T;clean_reap_hyps

      | H:Midpoint ?I ?A ?B, H2 : ?I<>?B |- _ =>
      let T:= fresh in (not_exist_hyp2 I A A B);
       assert (T:= midpoint_distinct_3 I A B H2 H);
       decompose [and] T;clear T;clean_reap_hyps
      | H:Midpoint ?I ?A ?B, H2 : ?B<>?I |- _ =>
      let T:= fresh in (not_exist_hyp2 I A A B);
       assert (T:= midpoint_distinct_3 I A B (swap_diff B I H2) H);
       decompose [and] T;clear T;clean_reap_hyps

      | H:Per ?A ?B ?C, H2 : ?A<>?B |- _ =>
      let T:= fresh in (not_exist_hyp_comm A C);
        assert (T:= per_distinct A B C H H2); clean_reap_hyps
      | H:Per ?A ?B ?C, H2 : ?B<>?A |- _ =>
      let T:= fresh in (not_exist_hyp_comm A C);
        assert (T:= per_distinct A B C H (swap_diff B A H2)); clean_reap_hyps
      | H:Per ?A ?B ?C, H2 : ?B<>?C |- _ =>
      let T:= fresh in (not_exist_hyp_comm A C);
        assert (T:= per_distinct_1 A B C H H2); clean_reap_hyps
      | H:Per ?A ?B ?C, H2 : ?C<>?B |- _ =>
      let T:= fresh in (not_exist_hyp_comm A C);
        assert (T:= per_distinct_1 A B C H (swap_diff C B H2)); clean_reap_hyps

      | H:Perp ?A ?B ?C ?D |- _ =>
      let T:= fresh in (not_exist_hyp2 A B C D);
       assert (T:= perp_distinct A B C D H);
       decompose [and] T;clear T;clean_reap_hyps
      | H:Perp_at ?X ?A ?B ?C ?D |- _ =>
      let T:= fresh in (not_exist_hyp2 A B C D);
       assert (T:= perp_in_distinct X A B C D H);
       decompose [and] T;clear T;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 clean_trivial_hyps :=
  repeat
  match goal with
   | H:(Cong ?X1 ?X1 ?X2 ?X2) |- _ => clear H
   | H:(Cong ?X1 ?X2 ?X2 ?X1) |- _ => clear H
   | H:(Cong ?X1 ?X2 ?X1 ?X2) |- _ => clear H
   | H:(Bet ?X1 ?X1 ?X2) |- _ => clear H
   | H:(Bet ?X2 ?X1 ?X1) |- _ => clear H
   | H:(Col ?X1 ?X1 ?X2) |- _ => clear H
   | H:(Col ?X2 ?X1 ?X1) |- _ => clear H
   | H:(Col ?X1 ?X2 ?X1) |- _ => clear H
   | H:(Per ?X1 ?X2 ?X2)     |- _ => clear H
   | H:(Per ?X1 ?X1 ?X2)     |- _ => clear H
   | H:(Midpoint ?X1 ?X1 ?X1) |- _ => clear H
end.

Ltac clean := clean_trivial_hyps;clean_reap_hyps.

Section T9.

Context `{TnEQD:Tarski_neutral_dimensionless_with_decidable_point_equality}.

Lemma ts_distincts : forall A B P Q, TS A B P Q ->
  A <> B /\ A <> P /\ A <> Q /\ B <> P /\ B <> Q /\ P <> Q.
Proof.
(* Goal: forall (A B P Q : @Tpoint Tn) (_ : @TS Tn A B P Q), and (not (@eq (@Tpoint Tn) A B)) (and (not (@eq (@Tpoint Tn) A P)) (and (not (@eq (@Tpoint Tn) A Q)) (and (not (@eq (@Tpoint Tn) B P)) (and (not (@eq (@Tpoint Tn) B Q)) (not (@eq (@Tpoint Tn) P Q)))))) *)
  intros A B P Q HTS.
(* Goal: and (not (@eq (@Tpoint Tn) A B)) (and (not (@eq (@Tpoint Tn) A P)) (and (not (@eq (@Tpoint Tn) A Q)) (and (not (@eq (@Tpoint Tn) B P)) (and (not (@eq (@Tpoint Tn) B Q)) (not (@eq (@Tpoint Tn) P Q)))))) *)
  destruct HTS as [HNCol1 [HNCol2 [T [HCol HBet]]]].
(* Goal: or (@TS Tn A B C D) (not (@TS Tn A B C D)) *)
  assert_diffs.
(* Goal: and (not (@eq (@Tpoint Tn) A B)) (and (not (@eq (@Tpoint Tn) A C)) (and (not (@eq (@Tpoint Tn) B C)) (and (not (@eq (@Tpoint Tn) A P)) (and (not (@eq (@Tpoint Tn) B P)) (and (not (@eq (@Tpoint Tn) C P)) (and (not (@eq (@Tpoint Tn) A Q)) (and (not (@eq (@Tpoint Tn) B Q)) (and (not (@eq (@Tpoint Tn) C Q)) (not (@eq (@Tpoint Tn) P Q)))))))))) *)
  repeat split; auto.
(* Goal: not (@eq (@Tpoint Tn) X Y) *)
  intro; treat_equalities; auto.
Qed.

Lemma l9_2 : forall A B P Q, TS A B P Q -> TS A B Q P.
Proof.
(* Goal: @TS Tn A B C P *)
(* Goal: @ex (@Tpoint Tn) (fun P : @Tpoint Tn => and (@Cong Tn A P X Y) (and (@Perp Tn A B P A) (@TS Tn A B C P))) *)
    unfold TS.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Coplanar Tn A B C D) (_ : not (@Col Tn C A B)) (_ : not (@Col Tn D A B)) (_ : not (@OS Tn A B C D)), @TS Tn A B C D *)
    intros.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
    spliter.
(* Goal: and (not (@Col Tn Q A B)) (and (not (@Col Tn P A B)) (@ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn Q T P)))) *)
    repeat split; try Col.
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn Q T P)) *)
    destruct H1 as [T [HCol1 HCol2]].
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn Q T P)) *)
    exists T; Col; Between.
Qed.

Lemma invert_two_sides : forall A B P Q,
 TS A B P Q -> TS B A P Q.
Proof with finish.
(* Goal: @TS Tn A B C P *)
(* Goal: @ex (@Tpoint Tn) (fun P : @Tpoint Tn => and (@Cong Tn A P X Y) (and (@Perp Tn A B P A) (@TS Tn A B C P))) *)
    unfold TS.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Coplanar Tn A B C D) (_ : not (@Col Tn C A B)) (_ : not (@Col Tn D A B)) (_ : not (@OS Tn A B C D)), @TS Tn A B C D *)
    intros.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
    spliter.
    repeat split...
(* Goal: or (not (@Col Tn A X Y)) (not (@Col Tn B X Y)) *)
    ex_and H1 T.
    exists T;split...
Qed.


Lemma l9_3 : forall P Q A C M R B,
 TS P Q A C -> Col M P Q ->
 Midpoint M A C -> Col R P Q ->
 Out R A B -> TS P Q B C.
Proof with finish.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Coplanar Tn A B C D) (_ : not (@Col Tn C A B)) (_ : not (@Col Tn D A B)) (_ : not (@OS Tn A B C D)), @TS Tn A B C D *)
    intros.
(* Goal: and (not (@Col Tn X A B)) (and (not (@Col Tn Y A B)) (@ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn X T Y)))) *)
(* Goal: @Out Tn A X Y *)
    unfold TS in *.
(* Goal: not (@Bet Tn A X B) *)
    assert (~ Col A P Q).
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
      spliter.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
    spliter.
    clear H.
    assert (P <> Q).
(* Goal: not (@TS Tn D E X Y) *)
      intro.
      subst Q.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
      Col.
    ex_and H6 T.
    show_distinct A C.
(* Goal: and (@Col Tn X P Q) (@Bet Tn A X B) *)
      intuition.
    assert (T = M).
(* Goal: @eq (@Tpoint Tn) A B *)
      assert_bets.
(* Goal: @eq (@Tpoint Tn) T1 T *)
(* Goal: @OS Tn A C B D *)
      assert_cols.
      eapply l6_21 with P Q A C...
(* Goal: False *)
(* Goal: not (@eq (@Tpoint Tn) D C) *)
(* Goal: or (@Bet Tn C T D) (@Bet Tn C D T) *)
(* Goal: @OS Tn A C B D *)
    subst T.
    repeat split...
      induction(eq_dec_points C M).
        subst M.
(* Goal: and (@Col Tn X P Q) (@Bet Tn A X B) *)
        intuition.
(* Goal: not (@TS Tn D E X Y) *)
      intro.
      clear H0.
      assert (B <> R).
(* Goal: not (@TS Tn D E X Y) *)
        intro.
(* Goal: False *)
(* Goal: or (@Bet Tn A T B) (@Bet Tn A B T) *)
(* Goal: @OS Tn A C B D *)
        subst B.
(* Goal: @Col Tn X A B *)
(* Goal: not (@Col Tn V A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn U T V)) *)
        unfold Out in H3.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
        spliter.
        absurde.
      assert (Col P R B) by ColR.
      assert (Col P R A).
        induction (eq_dec_points P B).
(* Goal: False *)
(* Goal: or (@Bet Tn A T B) (@Bet Tn A B T) *)
(* Goal: @OS Tn A C B D *)
          subst B.
(* Goal: @eq (@Tpoint Tn) T1 T *)
(* Goal: @OS Tn A C B D *)
          assert_cols...
(* Goal: @Col Tn X A B *)
        apply col_permutation_2.
        eapply col_transitivity_2.
(* Goal: False *)
(* Goal: @Out Tn C T D *)
(* Goal: @OS Tn A C B D *)
          apply H0.
(* Goal: @eq (@Tpoint Tn) T1 T *)
(* Goal: @OS Tn A C B D *)
          assert_cols...
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
        Col.
      induction (eq_dec_points P R).
        subst R.
        apply H4.
(* Goal: @Col Tn X A B *)
        apply col_permutation_2.
        eapply (col_transitivity_1 _ B).
(* Goal: and (@Col Tn X P Q) (@Bet Tn A X B) *)
          assert_diffs;intuition.
(* Goal: @Col Tn P C Q *)
(* Goal: @Col Tn P C A *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T P Q) (@Bet Tn A T C)) *)
(* Goal: and (@TS Tn P Q A C) (@TS Tn P Q A C) *)
          apply col_permutation_4.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
          assumption.
(* Goal: @eq (@Tpoint Tn) T1 T *)
(* Goal: @OS Tn A C B D *)
        assert_cols...
      assert (Col P B A ).
        eapply col_transitivity_1.
          apply H13.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
          assumption.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
      induction (eq_dec_points P B).
(* Goal: False *)
(* Goal: or (@Bet Tn A T B) (@Bet Tn A B T) *)
(* Goal: @OS Tn A C B D *)
        subst B.
        apply H4.
(* Goal: @Col Tn X A B *)
        apply col_permutation_2.
        eapply (col_transitivity_1 _ R).
(* Goal: False *)
(* Goal: @Out Tn C T D *)
(* Goal: @OS Tn A C B D *)
          apply H0.
(* Goal: @Col Tn P C Q *)
(* Goal: @Col Tn P C A *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T P Q) (@Bet Tn A T C)) *)
(* Goal: and (@TS Tn P Q A C) (@TS Tn P Q A C) *)
          apply col_permutation_4.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
          assumption.
(* Goal: @Col Tn X A B *)
(* Goal: not (@Col Tn V A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn U T V)) *)
        unfold Out in H3.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
        spliter.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
        unfold Col.
        induction H16.
          right; left.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
          assumption.
(* Goal: or (@Bet Tn P C A) (or (@Bet Tn C A P) (@Bet Tn A P C)) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T P Q) (@Bet Tn A T C)) *)
(* Goal: and (@TS Tn P Q A C) (@TS Tn P Q A C) *)
        right;right.
        Between.
      apply H4.
(* Goal: @Col Tn X A B *)
      apply col_permutation_2.
      eapply col_transitivity_1.
        apply H15.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
        Col.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
    induction H3.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
    spliter.
(* Goal: @Col Tn Y A B *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn U T V)) *)
    induction H10.
      double B M B'.
      double R M R'.
      assert (Bet B' C R').
        eapply l7_15.
          apply H11.
(* Goal: @Col Tn A P Q *)
          apply H1.
          apply H12.
        Between.
      assert (exists X, Bet M X R' /\ Bet C X B).
        eapply inner_pasch.
(* Goal: @eq (@Tpoint Tn) A B *)
          (* assert_bets.
          Between.
          *)
(* Goal: @Bet Tn A P C *)
(* Goal: and (@TS Tn P Q A C) (@TS Tn P Q A C) *)
          apply midpoint_bet.
          apply H11.
(* Goal: @Bet Tn X A Y *)
(* Goal: @Out Tn A X Y *)
        apply between_symmetry.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
      ex_and H14 X.
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T P Q) (@Bet Tn A T B)) *)
      exists X.
(* Goal: @TSP Tn A B C Q R *)
      split.
        assert (Col P M R ).
          eapply col_transitivity_1.
(* Goal: False *)
            apply H.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
            Col.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
          Col.
        assert (Col Q M R).
          eapply (col_transitivity_1 _ P).
(* Goal: False *)
            auto.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
            Col.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
          Col.
        induction (eq_dec_points M X).
(* Goal: False *)
(* Goal: not (@eq (@Tpoint Tn) Y A) *)
(* Goal: @Out Tn A X Y *)
          subst X.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
          assumption.
        show_distinct M R'.
(* Goal: and (@Col Tn X P Q) (@Bet Tn A X B) *)
          intuition.
        assert (M <> R).
(* Goal: not (@TS Tn D E X Y) *)
          intro.
          subst R.
          eapply (symmetric_point_uniqueness) in H12.
            apply H19.
            apply H12.
          apply l7_3_2.
(* Goal: @Col Tn X A B *)
        apply col_permutation_2.
(* Goal: @Col Tn C0 D0 M' *)
(* Goal: @Bet Tn C M D' *)
        ColR.
      Between.
    assert (exists X, Bet B X C /\ Bet M X R).
      eapply inner_pasch.
        apply H10.
      Between.
    ex_and H11 X.
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T P Q) (@Bet Tn A T B)) *)
    exists X.
    induction (eq_dec_points M R).
      subst R.
      apply between_identity in H12.
(* Goal: False *)
(* Goal: not (@eq (@Tpoint Tn) Y A) *)
(* Goal: @Out Tn A X Y *)
      subst X.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      split; assumption.
    induction (eq_dec_points R X).
(* Goal: False *)
(* Goal: not (@eq (@Tpoint Tn) Y A) *)
(* Goal: @Out Tn A X Y *)
      subst X.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      split; assumption.
(* Goal: @TSP Tn A B C Q R *)
    split.
      induction (eq_dec_points X M).
(* Goal: False *)
(* Goal: not (@eq (@Tpoint Tn) Y A) *)
(* Goal: @Out Tn A X Y *)
        subst X.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
      assert (Col P M R ).
        eapply col_transitivity_1.
(* Goal: False *)
          apply H.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
          Col.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
        Col.
      assert (Col X P Q).
(* Goal: @Col Tn X A B *)
        apply col_permutation_2.
(* Goal: @Col Tn C0 D0 M' *)
(* Goal: @Bet Tn C M D' *)
        ColR.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
    assumption.
Qed.

(*
Lemma sym_sym : forall A C A', Midpoint C A A' -> ReflectP A' A C.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Coplanar Tn A B C D) (_ : not (@Col Tn C A B)) (_ : not (@Col Tn D A B)) (_ : not (@OS Tn A B C D)), @TS Tn A B C D *)
    intros.
    apply l7_2.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
    assumption.
Qed.
*)

Lemma mid_preserves_col : forall A B C M A' B' C',
  Col A B C ->
  Midpoint M A A' ->
  Midpoint M B B' ->
  Midpoint M C C' ->
  Col A' B' C'.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Coplanar Tn A B C D) (_ : not (@Col Tn C A B)) (_ : not (@Col Tn D A B)) (_ : not (@OS Tn A B C D)), @TS Tn A B C D *)
    intros.
(* Goal: @Out Tn A X Y *)
    induction H.
(* Goal: @Col Tn A' B' C' *)
(* Goal: @Col Tn A' B' C' *)
      assert (Bet A' B' C').
(* Goal: False *)
        eapply l7_15 with A B C M;auto.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
      assert_cols;Col.
(* Goal: @Out Tn A X Y *)
    induction H.
(* Goal: @Col Tn A' B' C' *)
(* Goal: @Col Tn A' B' C' *)
      assert (Bet B' C' A').
(* Goal: False *)
        eapply l7_15 with B C A M;auto.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
      assert_cols;Col.
(* Goal: @Col Tn A' B' C' *)
    assert (Bet C' A' B').
(* Goal: False *)
      eapply l7_15 with C A B M;auto.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
    assert_cols;Col.
Qed.

Lemma per_mid_per : forall A B X Y M,
   A <> B -> Per X A B ->
   Midpoint M A B -> Midpoint M X Y ->
   Cong A X B Y /\ Per Y B A.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Coplanar Tn A B C D) (_ : not (@Col Tn C A B)) (_ : not (@Col Tn D A B)) (_ : not (@OS Tn A B C D)), @TS Tn A B C D *)
    intros.
    assert (Cong A X B Y).
      eapply l7_13.
        apply l7_2.
(* Goal: @Col Tn A P Q *)
        apply H1.
      apply l7_2.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
(* Goal: @TSP Tn A B C Q R *)
    split.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
    unfold Per in H0.
    ex_and H0 B'.
    double A B A'.
    assert (Cong B X A Y).
      eapply l7_13.
(* Goal: @Col Tn A P Q *)
        apply H1.
      apply l7_2.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
    assert (OFSC B A B' X A B A' Y).
      unfold OFSC.
(* Goal: @TSP Tn A B C Q R *)
      repeat split.
(* Goal: @Bet Tn A P C *)
(* Goal: and (@TS Tn P Q A C) (@TS Tn P Q A C) *)
        apply midpoint_bet.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: @Bet Tn A P C *)
(* Goal: and (@TS Tn P Q A C) (@TS Tn P Q A C) *)
        apply midpoint_bet.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
        apply cong_pseudo_reflexivity.
        unfold Midpoint in *.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
        spliter.
        eapply cong_transitivity.
          apply cong_symmetry.
          apply H8.
        apply cong_left_commutativity.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
    unfold Per.
(* Goal: @ex (@Tpoint Tn) (fun C : @Tpoint Tn => @TS Tn P Q A C) *)
    exists A'.
(* Goal: @TSP Tn A B C Q R *)
    split.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
    assert (Cong B' X A' Y).
      eapply five_segment_with_def.
        apply H7.
(* Goal: not (@TS Tn D E X Y) *)
      intro.
(* Goal: False *)
      apply H.
(* Goal: False *)
(* Goal: or (@Bet Tn A T B) (@Bet Tn A B T) *)
(* Goal: @OS Tn A C B D *)
      subst B.
      reflexivity.
    eapply cong_transitivity.
      apply cong_commutativity.
      apply cong_symmetry.
(* Goal: False *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn U T V)) *)
      apply H6.
    eapply cong_transitivity.
      apply H4.
    apply cong_commutativity.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
    assumption.
Qed.


Lemma sym_preserve_diff : forall A B M A' B',
 A <> B -> Midpoint M A A' -> Midpoint M B B' -> A'<> B'.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Coplanar Tn A B C D) (_ : not (@Col Tn C A B)) (_ : not (@Col Tn D A B)) (_ : not (@OS Tn A B C D)), @TS Tn A B C D *)
    intros.
(* Goal: not (@TS Tn D E X Y) *)
    intro.
    subst B'.
    assert (A = B).
      eapply l7_9.
(* Goal: False *)
(* Goal: @Out Tn C T D *)
(* Goal: @OS Tn A C B D *)
        apply H0.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
(* Goal: @TS Tn A B C D *)
    contradiction.
Qed.


Lemma l9_4_1_aux : forall P Q A C R S M,
 Le S C R A ->
 TS P Q A C -> Col R P Q -> Perp P Q A R -> Col S P Q ->
 Perp P Q C S -> Midpoint M R S ->
 (forall U C',Midpoint M U C' -> (Out R U A <-> Out S C C')).
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Coplanar Tn A B C D) (_ : not (@Col Tn C A B)) (_ : not (@Col Tn D A B)) (_ : not (@OS Tn A B C D)), @TS Tn A B C D *)
    intros.
    induction (eq_dec_points R S).
      subst S.
      apply l7_3 in H5.
      subst R.
      unfold TS in H0.
(* Goal: not (@Bet Tn A X B) *)
      assert (~ Col A P Q).
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
        spliter.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
      spliter.
      clear H0.
      assert (P <> Q).
(* Goal: not (@TS Tn D E X Y) *)
        intro.
        subst Q.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
        Col.
      ex_and H8 T.
      induction (eq_dec_points M T).
(* Goal: False *)
(* Goal: not (@eq (@Tpoint Tn) D C) *)
(* Goal: or (@Bet Tn C T D) (@Bet Tn C D T) *)
(* Goal: @OS Tn A C B D *)
        subst T.
(* Goal: @TSP Tn A B C Q R *)
        split.
(* Goal: not (@TS Tn D E X Y) *)
          intro.
(* Goal: @Bet Tn U T V *)
          unfold Out in *.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
          spliter.
(* Goal: @TSP Tn A B C Q R *)
          repeat split.
(* Goal: not (@TS Tn D E X Y) *)
            intro.
(* Goal: False *)
(* Goal: @Col Tn P C Q *)
(* Goal: @Col Tn P C A *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T P Q) (@Bet Tn A T C)) *)
(* Goal: and (@TS Tn P Q A C) (@TS Tn P Q A C) *)
            subst C.
            apply perp_distinct in H4.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
            spliter.
            absurde.
(* Goal: not (@TS Tn D E X Y) *)
            intro.
            subst C'.
            apply l7_2 in H6.
            eapply (symmetric_point_uniqueness _ _ M) in H6.
              apply H10.
              apply sym_equal.
(* Goal: False *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn U T V)) *)
              apply H6.
            apply l7_3_2.
          induction H12.
            assert (Bet U M C).
              eapply between_exchange3.
(* Goal: @Bet Tn X A Y *)
(* Goal: @Out Tn A X Y *)
                apply between_symmetry.
                apply H12.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
              assumption.
            unfold Midpoint in H13.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
            spliter.
            eapply l5_2.
              apply H10.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
              assumption.
(* Goal: @Bet Tn A P C *)
(* Goal: and (@TS Tn P Q A C) (@TS Tn P Q A C) *)
            apply midpoint_bet.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
            assumption.
          assert (Bet U M C).
            eapply outer_transitivity_between2.
(* Goal: @Bet Tn X A Y *)
(* Goal: @Out Tn A X Y *)
              apply between_symmetry.
              apply H12.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
              assumption.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
            assumption.
          eapply l5_2.
            apply H10.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
            assumption.
          unfold Midpoint in H6.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
          spliter.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
          assumption.
(* Goal: not (@TS Tn D E X Y) *)
        intro.
(* Goal: @Bet Tn U T V *)
        unfold Out in *.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
        spliter.
(* Goal: @TSP Tn A B C Q R *)
        repeat split.
(* Goal: not (@TS Tn D E X Y) *)
          intro.
          subst U.
          eapply is_midpoint_id in H6.
          subst C'.
          apply H11.
          reflexivity.
(* Goal: not (@TS Tn D E X Y) *)
          intro.
(* Goal: False *)
(* Goal: and (@Bet Tn A P B) (and (not (@Col Tn X Y A)) (not (@Col Tn X Y B))) *)
(* Goal: forall _ : and (@Bet Tn A P B) (and (not (@Col Tn X Y A)) (not (@Col Tn X Y B))), @TS Tn X Y A B *)
          subst A.
(* Goal: not (@eq (@Tpoint Tn) P A) *)
(* Goal: @ex (@Tpoint Tn) (fun P : @Tpoint Tn => and (@Cong Tn A P X Y) (and (@Perp Tn A B P A) (@TS Tn A B C P))) *)
          apply perp_distinct in H2.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
          spliter.
          apply H13.
          reflexivity.
        unfold Midpoint in H6.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
        spliter.
        assert (Bet A M C').
          induction H12.
            eapply outer_transitivity_between.
(* Goal: False *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T P')) *)
              apply H9.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
              assumption.
(* Goal: not (@TS Tn D E X Y) *)
            intro.
            apply H10.
(* Goal: False *)
(* Goal: @Col Tn P C Q *)
(* Goal: @Col Tn P C A *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T P Q) (@Bet Tn A T C)) *)
(* Goal: and (@TS Tn P Q A C) (@TS Tn P Q A C) *)
            subst C.
            reflexivity.
          eapply between_inner_transitivity.
(* Goal: False *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T P')) *)
            apply H9.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
          assumption.
        eapply l5_2.
          apply H11.
(* Goal: @Bet Tn X A Y *)
(* Goal: @Out Tn A X Y *)
          apply between_symmetry.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
          assumption.
(* Goal: @Bet Tn X A Y *)
(* Goal: @Out Tn A X Y *)
        apply between_symmetry.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
      assert (Perp M T A M) by (eapply perp_col2  with P Q;Col).
      apply perp_perp_in in H11.
      apply perp_in_comm in H11.
      eapply perp_in_per in H11.
      assert (Perp M T C M) by (eapply perp_col2  with P Q;Col).
      apply perp_perp_in in H12.
      apply perp_in_comm in H12.
      eapply perp_in_per in H12.
      assert (M = T).
        apply (l8_6 C M T A).
          3:Between.
(* Goal: False *)
          apply l8_2;auto.
(* Goal: False *)
        apply l8_2;auto.
(* Goal: False *)
(* Goal: not (@eq (@Tpoint Tn) D C) *)
(* Goal: or (@Bet Tn C T D) (@Bet Tn C D T) *)
(* Goal: @OS Tn A C B D *)
      subst T.
(* Goal: @TSP Tn A B C Q R *)
      split.
(* Goal: not (@TS Tn D E X Y) *)
        intro.
(* Goal: @Bet Tn U T V *)
        unfold Out in *.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
        spliter.
(* Goal: @TSP Tn A B C Q R *)
        repeat split.
(* Goal: not (@TS Tn D E X Y) *)
          intro.
(* Goal: False *)
(* Goal: @Col Tn P C Q *)
(* Goal: @Col Tn P C A *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T P Q) (@Bet Tn A T C)) *)
(* Goal: and (@TS Tn P Q A C) (@TS Tn P Q A C) *)
          subst C.
          apply perp_distinct in H4.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
          spliter.
          absurde.
(* Goal: not (@TS Tn D E X Y) *)
          intro.
          subst C'.
(* Goal: and (@Col Tn X P Q) (@Bet Tn A X B) *)
          intuition.
(* Goal: and (@Col Tn X P Q) (@Bet Tn A X B) *)
        intuition.
(* Goal: and (@Col Tn X P Q) (@Bet Tn A X B) *)
      intuition.
    (*   R <> S  *)
    unfold Le in H.
    ex_and H D.
    assert (C <> S).
(* Goal: not (@TS Tn D E X Y) *)
      intro.
      subst S.
      apply perp_distinct in H4.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
      spliter.
      absurde.
    assert (R <> D).
(* Goal: not (@TS Tn D E X Y) *)
      intro.
(* Goal: False *)
(* Goal: or (@Bet Tn C T D) (@Bet Tn C D T) *)
(* Goal: @OS Tn A C B D *)
      subst D.
(* Goal: False *)
(* Goal: @Perp Tn A P A B *)
(* Goal: @Col Tn A P P' *)
(* Goal: and (@Cong Tn A P' X Y) (and (@Perp Tn A B P' A) (@TS Tn A B C P')) *)
      apply cong_identity in H8.
(* Goal: False *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T P')) *)
      apply H9.
      subst S.
      reflexivity.
    assert (Perp R S A R).
      eapply perp_col2.
(* Goal: False *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T P)) *)
(* Goal: @ex (@Tpoint Tn) (fun P : @Tpoint Tn => and (@Cong Tn A P X Y) (and (@Perp Tn A B P A) (@TS Tn A B C P))) *)
        apply H2.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: @Col Tn A B Y *)
(* Goal: @OS Tn A B X Y *)
        apply col_permutation_1.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: @Col Tn A B Y *)
(* Goal: @OS Tn A B X Y *)
        apply col_permutation_1.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
    assert(exists M, Midpoint M S R /\ Midpoint M C D).
      unfold TS in H0.
(* Goal: not (@Bet Tn A X B) *)
      assert (~ Col A P Q).
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
        spliter.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
      spliter.
      clear H0.
      assert (P <> Q).
(* Goal: not (@TS Tn D E X Y) *)
        intro.
        subst Q.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
        Col.
      ex_and H14 T.
      eapply (l8_24 S R C A D T).
(* Goal: @Perp Tn A B P' A *)
(* Goal: and (@Cong Tn A P' X Y) (and (@Perp Tn A B P' A) (@TS Tn A B C P')) *)
        apply perp_sym.
(* Goal: @Perp Tn P' A A B *)
(* Goal: and (@Cong Tn A P' X Y) (and (@Perp Tn A B P' A) (@TS Tn A B C P')) *)
        apply perp_left_comm.
        eapply perp_col2.
          apply H4.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
          assumption.
(* Goal: @Col Tn A B Y *)
(* Goal: @OS Tn A B X Y *)
          apply col_permutation_1.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
          assumption.
(* Goal: @Col Tn A B Y *)
(* Goal: @OS Tn A B X Y *)
          apply col_permutation_1.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
          assumption.
        apply perp_right_comm.
(* Goal: @Perp Tn A B P' A *)
(* Goal: and (@Cong Tn A P' X Y) (and (@Perp Tn A B P' A) (@TS Tn A B C P')) *)
        apply perp_sym.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
        eapply col3.
(* Goal: False *)
(* Goal: @Out Tn C T D *)
(* Goal: @OS Tn A C B D *)
          apply H0.
(* Goal: @Col Tn A B Y *)
(* Goal: @OS Tn A B X Y *)
          apply col_permutation_1.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
          assumption.
(* Goal: @Col Tn A B Y *)
(* Goal: @OS Tn A B X Y *)
          apply col_permutation_1.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
          assumption.
(* Goal: @Col Tn A B Y *)
(* Goal: @OS Tn A B X Y *)
        apply col_permutation_1.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: @Bet Tn X A Y *)
(* Goal: @Out Tn A X Y *)
        apply between_symmetry.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
    ex_and H12 M'.
    apply l7_2 in H12.
    assert (M = M').
      eapply l7_17.
(* Goal: False *)
(* Goal: not (@Col Tn V A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn U T V)) *)
        apply H5.
      apply H12.
    subst M'.
(* Goal: @TSP Tn A B C Q R *)
    split.
(* Goal: not (@TS Tn D E X Y) *)
      intro.
      unfold Out in H14.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
      spliter.
(* Goal: @Out Tn A X Y *)
(* Goal: @Out Tn A X Y *)
      unfold Out.
(* Goal: @TSP Tn A B C Q R *)
      repeat split.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
        eapply sym_preserve_diff.
(* Goal: False *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn U T V)) *)
          2:apply H6.
          apply H14.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
      induction H16.
        assert(Bet R U D \/ Bet R D U).
          eapply l5_3.
            apply H16.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
          assumption.
        induction H17.
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
          right.
          eapply l7_15.
(* Goal: False *)
(* Goal: not (@Col Tn V A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn U T V)) *)
            apply H5.
(* Goal: False *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn U T V)) *)
            apply H6.
            apply l7_2.
            apply H13.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
          assumption.
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
        left.
        eapply l7_15.
(* Goal: False *)
(* Goal: not (@Col Tn V A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn U T V)) *)
          apply H5.
          apply l7_2.
          apply H13.
(* Goal: False *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn U T V)) *)
          apply H6.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
      left.
      eapply l7_15.
(* Goal: False *)
(* Goal: not (@Col Tn V A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn U T V)) *)
        apply H5.
        apply l7_2.
        apply H13.
(* Goal: False *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn U T V)) *)
        apply H6.
      eapply between_exchange4.
(* Goal: False *)
        apply H.
      apply H16.
(* Goal: @Out Tn A X Y *)
(* Goal: @Out Tn A X Y *)
    unfold Out.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Coplanar Tn A B C D) (_ : not (@Col Tn C A B)) (_ : not (@Col Tn D A B)) (_ : not (@OS Tn A B C D)), @TS Tn A B C D *)
    intros.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
    spliter.
(* Goal: @TSP Tn A B C Q R *)
    repeat split.
      eapply sym_preserve_diff.
        apply H15.
        apply l7_2.
(* Goal: False *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn U T V)) *)
        apply H6.
      apply l7_2.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
(* Goal: not (@TS Tn D E X Y) *)
      intro.
      subst R.
      apply perp_distinct in H11.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
      spliter.
      absurde.
    induction H16.
      eapply l5_1.
        apply H10.
        eapply l7_15.
          apply l7_2.
          apply H12.
          apply H13.
          apply l7_2.
(* Goal: False *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn U T V)) *)
          apply H6.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
    left.
    eapply between_exchange4.
      eapply l7_15.
        apply l7_2.
        apply H12.
        apply l7_2.
(* Goal: False *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn U T V)) *)
        apply H6.
        apply H13.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
    assumption.
Qed.

Lemma per_col_eq : forall A B C, Per A B C -> Col A B C -> B <> C -> A = B.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Coplanar Tn A B C D) (_ : not (@Col Tn C A B)) (_ : not (@Col Tn D A B)) (_ : not (@OS Tn A B C D)), @TS Tn A B C D *)
    intros.
(* Goal: @eq (@Tpoint Tn) A B *)
    unfold Per in H.
(* Goal: @eq (@Tpoint Tn) A B *)
    ex_and H C'.
(* Goal: @eq (@Tpoint Tn) A B *)
    assert_bets.
(* Goal: @eq (@Tpoint Tn) T1 T *)
(* Goal: @OS Tn A C B D *)
    assert_cols.
(* Goal: @Col Tn C0 D0 M' *)
(* Goal: @Bet Tn C M D' *)
    assert (Col A C C') by ColR.
(* Goal: @eq (@Tpoint Tn) A B *)
    assert (C = C' \/ Midpoint A C C') by (eapply l7_20;Col).
(* Goal: @eq (@Tpoint Tn) A B *)
    induction H6.
(* Goal: @Col Tn A B C *)
(* Goal: @Col Tn A B C *)
      treat_equalities.
(* Goal: and (@Col Tn X P Q) (@Bet Tn A X B) *)
      intuition.
(* Goal: False *)
    eapply l7_17;eauto.
Qed.


Lemma l9_4_1 : forall P Q A C R S M,
 TS P Q A C -> Col R P Q ->
 Perp P Q A R -> Col S P Q ->
 Perp P Q C S -> Midpoint M R S ->
 (forall U C',Midpoint M U C' -> (Out R U A <-> Out S C C')).
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Coplanar Tn A B C D) (_ : not (@Col Tn C A B)) (_ : not (@Col Tn D A B)) (_ : not (@OS Tn A B C D)), @TS Tn A B C D *)
    intros.
    assert (Le S C R A \/ Le R A S C).
      apply le_cases.
(* Goal: @eq (@Tpoint Tn) A B *)
    induction H6.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      apply (l9_4_1_aux P Q A C R S M); assumption.
    assert((Out R A U <-> Out S C' C) -> (Out R U A <-> Out S C C')).
(* Goal: not (@TS Tn D E X Y) *)
      intro.
(* Goal: @Col Tn A P P' *)
(* Goal: and (@Cong Tn A P' X Y) (and (@Perp Tn A B P' A) (@TS Tn A B C P')) *)
      induction H7.
(* Goal: @TSP Tn A B C Q R *)
      split.
(* Goal: not (@TS Tn D E X Y) *)
        intro.
        eapply l6_6.
        apply H7.
(* Goal: @Out Tn A Y X *)
        apply l6_6.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: not (@TS Tn D E X Y) *)
      intro.
(* Goal: @Out Tn A Y X *)
      apply l6_6.
      apply H8.
(* Goal: @Out Tn A Y X *)
      apply l6_6.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
    apply H7.
    assert((Out S C' C <-> Out R A U) -> (Out R A U <-> Out S C' C)).
(* Goal: not (@TS Tn D E X Y) *)
      intro.
      induction H8.
(* Goal: @TSP Tn A B C Q R *)
      split.
(* Goal: not (@TS Tn D E X Y) *)
        intro.
(* Goal: False *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T P')) *)
        apply H9.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: not (@TS Tn D E X Y) *)
      intro.
      apply H8.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
    apply H8.
    eapply (l9_4_1_aux).
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
(* Goal: @TS Tn A B P C *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T P')) *)
      apply l9_2.
(* Goal: False *)
      apply H.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
      apply l7_2.
      apply H4.
    apply l7_2.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
    assumption.
Qed.

Lemma mid_two_sides : forall A B M X Y,
 Midpoint M A B -> ~ Col A B X -> Midpoint M X Y ->
 TS A B X Y.
Proof.
(* Goal: forall (A B M X Y : @Tpoint Tn) (_ : @Midpoint Tn M A B) (_ : not (@Col Tn A B X)) (_ : @Midpoint Tn M X Y), @TS Tn A B X Y *)
    intros A B M X Y HM1 HNCol HM2.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
    repeat split; Col.
(* Goal: or (@TS Tn A B C D) (not (@TS Tn A B C D)) *)
      assert_diffs.
(* Goal: not (@Col Tn Y A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn X T Y)) *)
      assert (X<>Y) by (intro; treat_equalities; assert_cols; Col).
(* Goal: @Col Tn C0 D0 M' *)
(* Goal: @Bet Tn C M D' *)
      intro Col; apply HNCol; ColR.
    exists M; split; Col; Between.
Qed.

Lemma col_preserves_two_sides : forall A B C D X Y,
 C <> D -> Col A B C -> Col A B D ->
 TS A B X Y ->
 TS C D X Y.
Proof.
    intros A B C D X Y.
    assert (H := A).
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Coplanar Tn A B C D) (_ : not (@Col Tn C A B)) (_ : not (@Col Tn D A B)) (_ : not (@OS Tn A B C D)), @TS Tn A B C D *)
    intros.
(* Goal: and (not (@Col Tn X A B)) (and (not (@Col Tn Y A B)) (@ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn X T Y)))) *)
(* Goal: @Out Tn A X Y *)
    unfold TS in *.
(* Goal: @OS Tn A B X Y *)
(* Goal: @OS Tn A B X Y *)
    assert (~ Col X A B).
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
      spliter.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
    clear H.
    assert (A <> B).
(* Goal: not (@TS Tn D E X Y) *)
      intro.
(* Goal: False *)
(* Goal: or (@Bet Tn A T B) (@Bet Tn A B T) *)
(* Goal: @OS Tn A C B D *)
      subst B.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
      Col.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
    spliter.
(* Goal: @TSP Tn A B C Q R *)
    repeat split.
(* Goal: not (@TS Tn D E X Y) *)
      intro.
      apply H4.
(* Goal: @Col Tn X A B *)
      apply col_permutation_2.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
      apply (colx C D); Col.
(* Goal: not (@TS Tn D E X Y) *)
      intro.
(* Goal: False *)
(* Goal: not (@Col Tn V A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn U T V)) *)
      apply H5.
(* Goal: @Col Tn X A B *)
      apply col_permutation_2.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
      apply (colx C D); Col.
    ex_and H6 T.
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T P)) *)
(* Goal: @ex (@Tpoint Tn) (fun P : @Tpoint Tn => and (@Cong Tn A P X Y) (and (@Perp Tn A B P A) (@TS Tn A B C P))) *)
    exists T.
(* Goal: @TSP Tn A B C Q R *)
    split.
      eapply col3.
(* Goal: False *)
        apply H.
(* Goal: @Col Tn A B Y *)
(* Goal: @OS Tn A B X Y *)
        apply col_permutation_1.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
    assumption.
Qed.


Lemma out_out_two_sides : forall A B X Y U V I,
  A <> B ->
  TS A B X Y ->
  Col I A B -> Col I X Y ->
  Out I X U -> Out I Y V ->
  TS A B U V.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Coplanar Tn A B C D) (_ : not (@Col Tn C A B)) (_ : not (@Col Tn D A B)) (_ : not (@OS Tn A B C D)), @TS Tn A B C D *)
    intros.
(* Goal: and (not (@Col Tn X A B)) (and (not (@Col Tn Y A B)) (@ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn X T Y)))) *)
(* Goal: @Out Tn A X Y *)
    unfold TS in *.
(* Goal: @OS Tn A B X Y *)
(* Goal: @OS Tn A B X Y *)
    assert (~ Col X A B).
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
      spliter.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
    spliter.
(* Goal: @TSP Tn A B C Q R *)
    repeat split.
(* Goal: not (@TS Tn D E X Y) *)
      intro.
(* Goal: False *)
(* Goal: not (@Col Tn V A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn U T V)) *)
      apply H5.
(* Goal: @Col Tn X A B *)
(* Goal: not (@Col Tn V A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn U T V)) *)
      unfold Out in H3.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
      spliter.
(* Goal: @Col Tn Y A B *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn U T V)) *)
      induction H10.
(* Goal: @Col Tn C0 D0 M' *)
(* Goal: @Bet Tn C M D' *)
      ColR.
(* Goal: @Col Tn C0 D0 M' *)
(* Goal: @Bet Tn C M D' *)
      ColR.
(* Goal: not (@TS Tn D E X Y) *)
      intro.
(* Goal: False *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn U T V)) *)
      apply H6.
(* Goal: @Col Tn Y A B *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn U T V)) *)
      unfold Out in H4.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
      spliter.
(* Goal: @Col Tn Y A B *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn U T V)) *)
      induction H10.
(* Goal: @Col Tn C0 D0 M' *)
(* Goal: @Bet Tn C M D' *)
      ColR.
(* Goal: @Col Tn C0 D0 M' *)
(* Goal: @Bet Tn C M D' *)
      ColR.
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn U T V)) *)
    ex_and H7 T.
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn U T V)) *)
    assert (I = T).
(* Goal: @TSP Tn A B C D E' *)
(* Goal: @ex (@Tpoint Tn) (fun Q : @Tpoint Tn => and (@Coplanar Tn A B C Q) (and (@Coplanar Tn D E P Q) (not (@eq (@Tpoint Tn) P Q)))) *)
     {
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
      apply l6_21 with A B X Y; Col.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
      intro; treat_equalities; Col.
      }
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn U T V)) *)
    subst I.
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T P)) *)
(* Goal: @ex (@Tpoint Tn) (fun P : @Tpoint Tn => and (@Cong Tn A P X Y) (and (@Perp Tn A B P A) (@TS Tn A B C P))) *)
    exists T.
(* Goal: @TSP Tn A B C Q R *)
    split.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
(* Goal: @Bet Tn U T V *)
    unfold Out in *.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
    spliter.
    induction H12; induction H10;
    eauto using outer_transitivity_between2, between_symmetry, between_inner_transitivity, between_exchange3, outer_transitivity_between.
Qed.

Lemma l9_4_2_aux : forall P Q A C R S U V, Le S C R A -> TS P Q A C -> Col R P Q -> Perp P Q A R -> Col S P Q ->
Perp P Q C S -> Out R U A -> Out S V C -> TS P Q U V.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Coplanar Tn A B C D) (_ : not (@Col Tn C A B)) (_ : not (@Col Tn D A B)) (_ : not (@OS Tn A B C D)), @TS Tn A B C D *)
    intros.
    induction (eq_dec_points R S).
      subst S.
      assert (TT:= H0).
      unfold TS in H0.
(* Goal: not (@Bet Tn A X B) *)
      assert (~ Col A P Q).
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
        spliter.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
      spliter.
      clear H0.
      assert (P <> Q).
(* Goal: not (@TS Tn D E X Y) *)
        intro.
        subst Q.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
        Col.
      ex_and H9 T.
      induction (eq_dec_points R T).
(* Goal: False *)
(* Goal: not (@eq (@Tpoint Tn) D C) *)
(* Goal: or (@Bet Tn C T D) (@Bet Tn C D T) *)
(* Goal: @OS Tn A C B D *)
        subst T.
        clear H9 H3.
        apply (out_out_two_sides P Q A C U V R); auto using l6_6, bet_col with col.
      assert (Perp R T A R) by (eapply perp_col2  with P Q;Col).
      apply perp_perp_in in H12.
      apply perp_in_comm in H12.
      eapply perp_in_per in H12.
      assert (Perp R T C R) by (eapply perp_col2  with P Q;Col).
      apply perp_perp_in in H13.
      apply perp_in_comm in H13.
      eapply perp_in_per in H13.
      assert (R = T).
        apply (l8_6 C R T A).
          3:Between.
(* Goal: False *)
          apply l8_2;auto.
(* Goal: False *)
        apply l8_2;auto.
      subst.
(* Goal: and (@Col Tn X P Q) (@Bet Tn A X B) *)
      intuition.
    (********* R <> S ***************)
    assert(P <> Q).
      apply perp_distinct in H4.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
      spliter.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
    assert (TS R S A C).
      eapply (col_preserves_two_sides P Q).
        apply H7.
(* Goal: @Col Tn A B Y *)
(* Goal: @OS Tn A B X Y *)
        apply col_permutation_1.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: @Col Tn A B Y *)
(* Goal: @OS Tn A B X Y *)
        apply col_permutation_1.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
    eapply (col_preserves_two_sides R S).
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
(* Goal: @Col Tn A B Y *)
(* Goal: @OS Tn A B X Y *)
      eapply col_permutation_1.
      eapply col_transitivity_1.
        apply H8.
(* Goal: @Col Tn A B Y *)
(* Goal: @OS Tn A B X Y *)
        apply col_permutation_1.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: @Col Tn A B Y *)
(* Goal: @OS Tn A B X Y *)
      apply col_permutation_1.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
(* Goal: @Col Tn A B Y *)
(* Goal: @OS Tn A B X Y *)
      apply col_permutation_1.
      eapply (col_transitivity_1 _ P).
(* Goal: False *)
        auto.
        apply col_permutation_3.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
      apply col_permutation_3.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
    assert (Perp R S A R).
      eapply perp_col2.
(* Goal: False *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T P)) *)
(* Goal: @ex (@Tpoint Tn) (fun P : @Tpoint Tn => and (@Cong Tn A P X Y) (and (@Perp Tn A B P A) (@TS Tn A B C P))) *)
        apply H2.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: @Col Tn A B Y *)
(* Goal: @OS Tn A B X Y *)
        apply col_permutation_1.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: @Col Tn A B Y *)
(* Goal: @OS Tn A B X Y *)
        apply col_permutation_1.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
    assert (Perp R S C S).
      eapply perp_col2.
        apply H4.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: @Col Tn A B Y *)
(* Goal: @OS Tn A B X Y *)
        apply col_permutation_1.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: @Col Tn A B Y *)
(* Goal: @OS Tn A B X Y *)
        apply col_permutation_1.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
    assert (HH9:=H9).
    unfold TS in HH9.
    assert (~ Col A R S).
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
      spliter.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
    spliter.
    ex_and H15 T.
    unfold Le in H.
(* Goal: @eq (@Tpoint Tn) A B *)
    ex_and H C'.
    assert (exists M, Midpoint M S R /\ Midpoint M C C').
      eapply (l8_24 S R C A C' T).
(* Goal: @Perp Tn A B P' A *)
(* Goal: and (@Cong Tn A P' X Y) (and (@Perp Tn A B P' A) (@TS Tn A B C P')) *)
        apply perp_sym.
(* Goal: @Perp Tn P' A A B *)
(* Goal: and (@Cong Tn A P' X Y) (and (@Perp Tn A B P' A) (@TS Tn A B C P')) *)
        apply perp_left_comm.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: @Perp Tn A B P' A *)
(* Goal: and (@Cong Tn A P' X Y) (and (@Perp Tn A B P' A) (@TS Tn A B C P')) *)
        apply perp_sym.
(* Goal: @Perp Tn P' A A B *)
(* Goal: and (@Cong Tn A P' X Y) (and (@Perp Tn A B P' A) (@TS Tn A B C P')) *)
        apply perp_left_comm.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
        apply col_permutation_3.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: @Bet Tn X A Y *)
(* Goal: @Out Tn A X Y *)
        apply between_symmetry.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
    ex_and H18 M.
    double U M U'.
    assert (R <> U).
(* Goal: not (@TS Tn D E X Y) *)
      intro.
      subst U.
      unfold Out in H5.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
      spliter.
      absurde.
    assert (TS R S U U').
      eapply mid_two_sides.
        apply l7_2.
        apply H18.
(* Goal: not (@TS Tn D E X Y) *)
        intro.
        apply H13.
(* Goal: @Col Tn X A B *)
        eapply col_permutation_2.
        eapply col_transitivity_1.
          apply H21.
          apply col_permutation_5.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
          assumption.
        induction H5.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
        spliter.
        induction H24.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
          unfold Col.
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
          left.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
          assumption.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
        unfold Col.
        right; left.
(* Goal: @Bet Tn X A Y *)
(* Goal: @Out Tn A X Y *)
        apply between_symmetry.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
(* Goal: @TS Tn A B P C *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T P')) *)
    apply l9_2.
    eapply l9_3.
(* Goal: @TS Tn A B P C *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T P')) *)
      apply l9_2.
      apply H22.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
      unfold Col.
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
      right; right.
(* Goal: @Bet Tn A P C *)
(* Goal: and (@TS Tn P Q A C) (@TS Tn P Q A C) *)
      apply midpoint_bet.
      apply H18.
      apply l7_2.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
      apply col_trivial_3.
    assert (forall X Y, Midpoint M X Y -> (Out R X A <-> Out S C Y)).
      eapply l9_4_1.
(* Goal: False *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T P')) *)
        apply H9.
(* Goal: @Col Tn A A B *)
(* Goal: @Bet Tn X A Y *)
(* Goal: @Out Tn A X Y *)
        apply col_trivial_1.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
        apply col_trivial_3.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
      apply l7_2.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
    assert (Out R U A <-> Out S C U').
      eapply H23.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
    destruct H24.
    eapply l6_7.
(* Goal: @Out Tn A Y X *)
      apply l6_6.
      apply H24.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
(* Goal: @Out Tn A Y X *)
    apply l6_6.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
    assumption.
Qed.


Lemma l9_4_2 : forall P Q A C R S U V,
TS P Q A C -> Col R P Q -> Perp P Q A R -> Col S P Q ->
Perp P Q C S -> Out R U A -> Out S V C -> TS P Q U V.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Coplanar Tn A B C D) (_ : not (@Col Tn C A B)) (_ : not (@Col Tn D A B)) (_ : not (@OS Tn A B C D)), @TS Tn A B C D *)
    intros.
    assert(Le S C R A \/ Le R A S C) by (apply le_cases).
(* Goal: @eq (@Tpoint Tn) A B *)
    induction H6.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      eapply l9_4_2_aux with A C R S;assumption.
(* Goal: @TS Tn A B P C *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T P')) *)
    apply l9_2.
    apply l9_2 in H.
(* Goal: False *)
    eapply l9_4_2_aux with C A S R;auto.
Qed.

Lemma l9_5 : forall P Q A C R B,
 TS P Q A C -> Col R P Q -> Out R A B -> TS P Q B C.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Coplanar Tn A B C D) (_ : not (@Col Tn C A B)) (_ : not (@Col Tn D A B)) (_ : not (@OS Tn A B C D)), @TS Tn A B C D *)
    intros.
    assert (P <> Q).
(* Goal: or (not (@Col Tn A X Y)) (not (@Col Tn B X Y)) *)
      unfold TS in H.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
      spliter.
(* Goal: not (@TS Tn D E X Y) *)
      intro.
      subst Q.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
      Col.
    assert(exists A0, Col P Q A0 /\ Perp P Q A A0).
      eapply l8_18_existence.
(* Goal: not (@TS Tn D E X Y) *)
      intro.
(* Goal: or (not (@Col Tn A X Y)) (not (@Col Tn B X Y)) *)
      unfold TS in H.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
      spliter.
(* Goal: False *)
      apply H.
(* Goal: @Col Tn X A B *)
      apply col_permutation_2.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
    assert(exists C0, Col P Q C0 /\ Perp P Q C C0).
      eapply l8_18_existence.
(* Goal: or (not (@Col Tn A X Y)) (not (@Col Tn B X Y)) *)
      unfold TS in H.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
      spliter.
(* Goal: not (@TS Tn D E X Y) *)
      intro.
      apply H4.
(* Goal: @Col Tn X A B *)
      apply col_permutation_2.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
    assert(exists B0, Col P Q B0 /\ Perp P Q B B0).
      eapply l8_18_existence.
      assert (HH1:=H1).
      unfold Out in HH1.
(* Goal: or (not (@Col Tn A X Y)) (not (@Col Tn B X Y)) *)
      unfold TS in H.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
      spliter.
(* Goal: not (@TS Tn D E X Y) *)
      intro.
      assert (Col P B R).
        eapply col_transitivity_1.
(* Goal: False *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T P)) *)
(* Goal: @ex (@Tpoint Tn) (fun P : @Tpoint Tn => and (@Cong Tn A P X Y) (and (@Perp Tn A B P A) (@TS Tn A B C P))) *)
          apply H2.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
          assumption.
(* Goal: @Col Tn A B Y *)
(* Goal: @OS Tn A B X Y *)
        apply col_permutation_1.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
      assert (R <> B).
(* Goal: not (@TS Tn D E X Y) *)
        intro.
(* Goal: False *)
(* Goal: or (@Bet Tn A T B) (@Bet Tn A B T) *)
(* Goal: @OS Tn A C B D *)
        subst B.
        absurde.
      assert(Col R P A ).
        eapply col_transitivity_1.
          apply H12.
          eapply col_permutation_3.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
          assumption.
        apply col_permutation_5.
        apply out_col.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: False *)
      apply H.
(* Goal: @Col Tn C0 D0 M' *)
(* Goal: @Bet Tn C M D' *)
      ColR.
    ex_and H3 A'.
    ex_and H4 C'.
    ex_and H5 B'.
    assert (exists M, Midpoint M A' C').
      apply midpoint_existence.
    ex_and H9 M.
    double A M D.
    assert (Out C' D C <-> Out A' A A).
      eapply l9_4_1.
(* Goal: @TS Tn A B P C *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T P')) *)
        apply l9_2.
(* Goal: False *)
        apply H.
(* Goal: @Col Tn X A B *)
        apply col_permutation_2.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: @Col Tn X A B *)
        apply col_permutation_2.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
        apply l7_2.
        apply H10.
      apply l7_2.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
    destruct H11.
    assert (Out C' D C).
      apply H12.
(* Goal: @Out Tn A X Y *)
(* Goal: @Out Tn A X Y *)
      unfold Out.
(* Goal: @TSP Tn A B C Q R *)
      repeat split.
(* Goal: not (@TS Tn D E X Y) *)
        intro.
(* Goal: False *)
(* Goal: @Col Tn P A' Q *)
(* Goal: @Col Tn P A' A *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T P Q) (@Bet Tn A T A')) *)
        subst A'.
        apply perp_distinct in H6.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
        spliter.
        absurde.
(* Goal: not (@TS Tn D E X Y) *)
        intro.
(* Goal: False *)
(* Goal: @Col Tn P A' Q *)
(* Goal: @Col Tn P A' A *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T P Q) (@Bet Tn A T A')) *)
        subst A'.
        apply perp_distinct in H6.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
        spliter.
        absurde.
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
      left.
      apply between_trivial.
    assert (TS P Q A D).
      eapply l9_4_2.
(* Goal: False *)
        apply H.
(* Goal: @Col Tn X A B *)
        apply col_permutation_2.
        apply H3.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: @Col Tn X A B *)
        apply col_permutation_2.
        apply H4.
        apply H7.
(* Goal: @Out Tn A X Y *)
(* Goal: @Out Tn A X Y *)
        unfold Out.
(* Goal: @TSP Tn A B C Q R *)
        repeat split.
(* Goal: not (@TS Tn D E X Y) *)
          intro.
(* Goal: False *)
(* Goal: @Col Tn P A' Q *)
(* Goal: @Col Tn P A' A *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T P Q) (@Bet Tn A T A')) *)
          subst A'.
          apply perp_distinct in H6.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
          spliter.
          absurde.
(* Goal: not (@TS Tn D E X Y) *)
          intro.
(* Goal: False *)
(* Goal: @Col Tn P A' Q *)
(* Goal: @Col Tn P A' A *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T P Q) (@Bet Tn A T A')) *)
          subst A'.
          apply perp_distinct in H6.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
          spliter.
          absurde.
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
        left.
        apply between_trivial.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
    assert (TS P Q B D).
      eapply l9_3.
        apply H14.
(* Goal: False *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T P')) *)
        2:apply H9.
(* Goal: False *)
(* Goal: @Out Tn C T D *)
(* Goal: @OS Tn A C B D *)
        2: apply H0.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        2:assumption.
      induction (eq_dec_points A' C').
        subst C'.
        apply l7_3 in H10.
(* Goal: False *)
(* Goal: @Col Tn P A' Q *)
(* Goal: @Col Tn P A' A *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T P Q) (@Bet Tn A T A')) *)
        subst A'.
(* Goal: @Col Tn X A B *)
        apply col_permutation_2.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: @Col Tn C0 D0 M' *)
(* Goal: @Bet Tn C M D' *)
      ColR.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
    try assumption.
    eapply l9_4_2.
      apply H15.
      2: apply H8.
(* Goal: @Col Tn X A B *)
      apply col_permutation_2.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
(* Goal: @Col Tn X A B *)
      apply col_permutation_2.
      apply H4.
(* Goal: @Perp Tn A B P' A *)
(* Goal: and (@Cong Tn A P' X Y) (and (@Perp Tn A B P' A) (@TS Tn A B C P')) *)
      apply perp_sym.
(* Goal: @Perp Tn P' A A B *)
(* Goal: and (@Cong Tn A P' X Y) (and (@Perp Tn A B P' A) (@TS Tn A B C P')) *)
      apply perp_left_comm.
      eapply perp_col.
(* Goal: not (@TS Tn D E X Y) *)
        intro.
(* Goal: False *)
(* Goal: or (@Bet Tn C T D) (@Bet Tn C D T) *)
(* Goal: @OS Tn A C B D *)
        subst D.
        unfold Out in H13.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
        spliter.
        absurde.
(* Goal: @Perp Tn A B P' A *)
(* Goal: and (@Cong Tn A P' X Y) (and (@Perp Tn A B P' A) (@TS Tn A B C P')) *)
        apply perp_sym.
        apply perp_right_comm.
        apply H7.
      apply col_permutation_5.
      apply out_col.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
      eapply out_trivial.
(* Goal: not (@TS Tn D E X Y) *)
      intro.
(* Goal: False *)
(* Goal: or (@Bet Tn A T B) (@Bet Tn A B T) *)
(* Goal: @OS Tn A C B D *)
      subst B.
      apply perp_distinct in H8.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
      spliter.
      absurde.
(* Goal: @Out Tn A Y X *)
    apply l6_6.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
    assumption.
Qed.

(** This lemma used to be an axiom in previous versions of Tarski's axiom system.
    It is a been shown to a theorem by Gupta in his Phd 1965. *)
(** This corresponds to l9_6 in Tarski's book. *)

Lemma outer_pasch : forall A B C P Q,
 Bet A C P -> Bet B Q C -> exists X, Bet A X B /\ Bet P Q X.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Coplanar Tn A B C D) (_ : not (@Col Tn C A B)) (_ : not (@Col Tn D A B)) (_ : not (@OS Tn A B C D)), @TS Tn A B C D *)
    intros.
    induction(col_dec P Q C).
      induction(bet_dec P Q C).
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn X T Y)) *)
(* Goal: @Out Tn A X Y *)
        exists A.
(* Goal: @TSP Tn A B C Q R *)
        split.
          Between.
        eapply between_exchange4 with C;Between.
      assert (Out Q P C) by (apply l6_4_2;auto).
      exists B.
(* Goal: @TSP Tn A B C Q R *)
      split.
        Between.
(* Goal: @Col Tn X A B *)
(* Goal: not (@Col Tn V A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn U T V)) *)
      unfold Out in H3.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
      spliter.
      induction H5.
        apply between_exchange3 with C;Between.
      apply outer_transitivity_between2 with C;Between.
    induction (eq_dec_points B Q).
      subst Q;exists B;Between.
    show_distinct A P.
(* Goal: and (@Col Tn X P Q) (@Bet Tn A X B) *)
      intuition.
    show_distinct P Q.
(* Goal: and (@Col Tn X P Q) (@Bet Tn A X B) *)
      intuition.
    show_distinct P B.
(* Goal: and (@Col Tn X P Q) (@Bet Tn A X B) *)
      intuition.
    assert(TS P Q C B).
(* Goal: @TS Tn A B C P *)
(* Goal: @ex (@Tpoint Tn) (fun P : @Tpoint Tn => and (@Cong Tn A P X Y) (and (@Perp Tn A B P A) (@TS Tn A B C P))) *)
      unfold TS.
(* Goal: @TSP Tn A B C Q R *)
      repeat split.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
        Col.
(* Goal: @eq (@Tpoint Tn) T1 T *)
(* Goal: @OS Tn A C B D *)
        assert_cols.
(* Goal: @Col Tn C0 D0 M' *)
(* Goal: @Bet Tn C M D' *)
        intro;apply H1; ColR.
      exists Q; split;Col;Between.
(* Goal: or (@TS Tn A B C D) (not (@TS Tn A B C D)) *)
    assert_diffs.
    assert (TS P Q A B) by (apply l9_5 with C P;unfold Out;intuition).
    unfold TS in H8.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
    spliter.
    ex_and H11 X.
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T P Q) (@Bet Tn A T B)) *)
    exists X.
(* Goal: @TSP Tn A B C Q R *)
    split.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
    assert (exists T, Bet X T P /\ Bet C T B) by (apply inner_pasch with A;Between).
    ex_and H14 T.
    show_distinct B C.
(* Goal: and (@Col Tn X P Q) (@Bet Tn A X B) *)
      intuition.
    assert (T = Q).
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
      apply l6_21 with X P B C; assert_cols;Col.
(* Goal: not (@TS Tn D E X Y) *)
      intro.
      apply H10.
(* Goal: @Col Tn X A B *)
      eapply col_permutation_2.
      eapply col_transitivity_1 with X.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
        2:Col.
(* Goal: not (@TS Tn D E X Y) *)
        intro.
(* Goal: @Col Tn A B C *)
(* Goal: @Col Tn A B C *)
        treat_equalities.
        apply H10.
(* Goal: @Col Tn C0 D0 M' *)
(* Goal: @Bet Tn C M D' *)
        ColR.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
      Col.
    subst T;Between.
Qed.

Lemma os_distincts : forall A B X Y, OS A B X Y ->
  A <> B /\ A <> X /\ A <> Y /\ B <> X /\ B <> Y.
Proof.
(* Goal: forall (A B X Y : @Tpoint Tn) (_ : @OS Tn A B X Y), and (not (@eq (@Tpoint Tn) A B)) (and (not (@eq (@Tpoint Tn) A X)) (and (not (@eq (@Tpoint Tn) A Y)) (and (not (@eq (@Tpoint Tn) B X)) (not (@eq (@Tpoint Tn) B Y))))) *)
  intros A B P Q HOS.
(* Goal: and (not (@eq (@Tpoint Tn) A B)) (and (not (@eq (@Tpoint Tn) A P)) (and (not (@eq (@Tpoint Tn) A Q)) (and (not (@eq (@Tpoint Tn) B P)) (not (@eq (@Tpoint Tn) B Q))))) *)
  destruct HOS as [Z [HTS1 HTS2]].
(* Goal: and (not (@eq (@Tpoint Tn) A B)) (and (not (@eq (@Tpoint Tn) A P)) (and (not (@eq (@Tpoint Tn) A Q)) (and (not (@eq (@Tpoint Tn) B P)) (not (@eq (@Tpoint Tn) B Q))))) *)
  apply ts_distincts in HTS1.
(* Goal: and (not (@eq (@Tpoint Tn) A B)) (and (not (@eq (@Tpoint Tn) A P)) (and (not (@eq (@Tpoint Tn) A Q)) (and (not (@eq (@Tpoint Tn) B P)) (not (@eq (@Tpoint Tn) B Q))))) *)
  apply ts_distincts in HTS2.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
  spliter.
(* Goal: and (not (@eq (@Tpoint Tn) A B)) (and (not (@eq (@Tpoint Tn) A C)) (and (not (@eq (@Tpoint Tn) B C)) (and (not (@eq (@Tpoint Tn) A P)) (and (not (@eq (@Tpoint Tn) B P)) (and (not (@eq (@Tpoint Tn) C P)) (and (not (@eq (@Tpoint Tn) A Q)) (and (not (@eq (@Tpoint Tn) B Q)) (and (not (@eq (@Tpoint Tn) C Q)) (not (@eq (@Tpoint Tn) P Q)))))))))) *)
  repeat split; auto.
Qed.

Lemma invert_one_side : forall A B P Q,
 OS A B P Q -> OS B A P Q.
Proof.
(* Goal: forall (A B C P Q : @Tpoint Tn) (_ : @Col Tn A B C) (_ : not (@eq (@Tpoint Tn) A C)) (_ : @OS Tn A B P Q), @OS Tn A C P Q *)
    unfold OS.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Coplanar Tn A B C D) (_ : not (@Col Tn C A B)) (_ : not (@Col Tn D A B)) (_ : not (@OS Tn A B C D)), @TS Tn A B C D *)
    intros.
    ex_and H T.
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T P)) *)
(* Goal: @ex (@Tpoint Tn) (fun P : @Tpoint Tn => and (@Cong Tn A P X Y) (and (@Perp Tn A B P A) (@TS Tn A B C P))) *)
    exists T.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
    split; apply invert_two_sides; assumption.
Qed.

Lemma l9_8_1 : forall P Q A B C, TS P Q A C -> TS P Q B C -> OS P Q A B.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Coplanar Tn A B C D) (_ : not (@Col Tn C A B)) (_ : not (@Col Tn D A B)) (_ : not (@OS Tn A B C D)), @TS Tn A B C D *)
    intros.
(* Goal: forall (A B C P Q : @Tpoint Tn) (_ : @Col Tn A B C) (_ : not (@eq (@Tpoint Tn) A C)) (_ : @OS Tn A B P Q), @OS Tn A C P Q *)
    unfold OS.
(* Goal: @ex (@Tpoint Tn) (fun R : @Tpoint Tn => and (@TS Tn P Q B R) (@TS Tn P Q A R)) *)
    exists C.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
    split; assumption.
Qed.

Lemma not_two_sides_id : forall A P Q, ~ TS P Q A A.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Coplanar Tn A B C D) (_ : not (@Col Tn C A B)) (_ : not (@Col Tn D A B)) (_ : not (@OS Tn A B C D)), @TS Tn A B C D *)
    intros.
(* Goal: not (@TS Tn D E X Y) *)
    intro.
(* Goal: or (not (@Col Tn A X Y)) (not (@Col Tn B X Y)) *)
    unfold TS in H.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
    spliter.
(* Goal: or (not (@Col Tn A X Y)) (not (@Col Tn B X Y)) *)
    ex_and H1 T.
(* Goal: False *)
    apply between_identity in H2.
(* Goal: False *)
(* Goal: not (@eq (@Tpoint Tn) D C) *)
(* Goal: or (@Bet Tn C T D) (@Bet Tn C D T) *)
(* Goal: @OS Tn A C B D *)
    subst T.
(* Goal: False *)
(* Goal: @Out Tn C T D *)
(* Goal: @OS Tn A C B D *)
    apply H0.
(* Goal: @Col Tn A P Q *)
    apply H1.
Qed.

Lemma l9_8_2 : forall P Q A B C,
 TS P Q A C ->
 OS P Q A B ->
 TS P Q B C.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Coplanar Tn A B C D) (_ : not (@Col Tn C A B)) (_ : not (@Col Tn D A B)) (_ : not (@OS Tn A B C D)), @TS Tn A B C D *)
    intros.
(* Goal: and (not (@Col Tn X A B)) (and (not (@Col Tn Y A B)) (@ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn X T Y)))) *)
(* Goal: @Out Tn A X Y *)
    unfold OS in H0.
    ex_and H0 D.
    assert (HH:= H).
(* Goal: and (not (@Col Tn X A B)) (and (not (@Col Tn Y A B)) (@ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn X T Y)))) *)
(* Goal: @Out Tn A X Y *)
    assert (HH0:=H0).
    assert (HH1:=H1).
    unfold TS in HH1.
    assert (P <> Q).
(* Goal: not (@TS Tn D E X Y) *)
      intro.
      subst Q.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
      spliter.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
      Col.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
    spliter.
    unfold TS in HH0.
    assert (P <> Q).
(* Goal: not (@TS Tn D E X Y) *)
      intro.
      subst Q.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
      spliter.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
      Col.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
    spliter.
    unfold TS in HH.
    assert (P <> Q).
(* Goal: not (@TS Tn D E X Y) *)
      intro.
      subst Q.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
      spliter.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
      Col.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
    spliter.
    ex_and H13 T.
    ex_and H9 X.
    ex_and H5 Y.
    assert (exists M , Bet Y M A /\ Bet X M B).
      eapply inner_pasch.
        apply H16.
      apply H15.
    ex_and H17 M.
    assert (A <> D).
(* Goal: not (@TS Tn D E X Y) *)
      intro.
(* Goal: False *)
(* Goal: or (@Bet Tn C T D) (@Bet Tn C D T) *)
(* Goal: @OS Tn A C B D *)
      subst D.
      apply not_two_sides_id in H0.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
    assert (B <> D).
(* Goal: not (@TS Tn D E X Y) *)
      intro.
(* Goal: False *)
(* Goal: or (@Bet Tn C T D) (@Bet Tn C D T) *)
(* Goal: @OS Tn A C B D *)
      subst D.
      apply not_two_sides_id in H1.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
    induction (col_dec A B D).
      induction (eq_dec_points M Y).
        subst M.
        assert (X = Y).
(* Goal: @Col Tn C0 D0 M' *)
(* Goal: @Bet Tn C M D' *)
          apply l6_21 with P Q A D; assert_cols; Col; ColR.
(* Goal: @Out Tn Y P Q *)
        subst Y.
        eapply l9_5.
(* Goal: False *)
          apply H.
(* Goal: False *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T P')) *)
          apply H9.
(* Goal: @Out Tn A X Y *)
(* Goal: @Out Tn A X Y *)
        unfold Out.
(* Goal: @TSP Tn A B C Q R *)
        repeat split.
(* Goal: not (@TS Tn D E X Y) *)
          intro.
(* Goal: False *)
(* Goal: not (@eq (@Tpoint Tn) Y A) *)
(* Goal: @Out Tn A X Y *)
          subst X.
          apply H11.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
          assumption.
(* Goal: not (@TS Tn D E X Y) *)
          intro.
(* Goal: False *)
(* Goal: not (@eq (@Tpoint Tn) Y A) *)
(* Goal: @Out Tn A X Y *)
          subst X.
          apply H3.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
          assumption.
        unfold Col in H21.
        induction H21.
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
          right.
          eapply between_exchange3.
(* Goal: @Bet Tn X A Y *)
(* Goal: @Out Tn A X Y *)
            apply between_symmetry.
            apply H16.
(* Goal: @Bet Tn X A Y *)
(* Goal: @Out Tn A X Y *)
          apply between_symmetry.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
          assumption.
        induction H21.
          assert (Bet D B A \/ Bet D A B).
            eapply (l5_1 _ X).
(* Goal: not (@TS Tn D E X Y) *)
              intro.
(* Goal: False *)
(* Goal: not (@eq (@Tpoint Tn) Y A) *)
(* Goal: @Out Tn A X Y *)
              subst X.
              apply H4.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
              assumption.
(* Goal: @Bet Tn X A Y *)
(* Goal: @Out Tn A X Y *)
              apply between_symmetry.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
              assumption.
(* Goal: @Bet Tn X A Y *)
(* Goal: @Out Tn A X Y *)
            apply between_symmetry.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
            assumption.
          induction H22.
            assert (D = B).
              eapply between_equality.
                apply H22.
              apply H21.
(* Goal: False *)
(* Goal: or (@Bet Tn C T D) (@Bet Tn C D T) *)
(* Goal: @OS Tn A C B D *)
            subst D.
            absurde.
          assert (D = A).
            eapply between_equality.
              apply H22.
(* Goal: @Bet Tn X A Y *)
(* Goal: @Out Tn A X Y *)
            apply between_symmetry.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
            assumption.
(* Goal: False *)
(* Goal: or (@Bet Tn C T D) (@Bet Tn C D T) *)
(* Goal: @OS Tn A C B D *)
          subst D.
          absurde.
        eapply (l5_2 D).
(* Goal: not (@TS Tn D E X Y) *)
          intro.
(* Goal: False *)
(* Goal: not (@eq (@Tpoint Tn) Y A) *)
(* Goal: @Out Tn A X Y *)
          subst X.
          apply H8.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
          assumption.
(* Goal: @Bet Tn X A Y *)
(* Goal: @Out Tn A X Y *)
          apply between_symmetry.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
          assumption.
(* Goal: @Bet Tn X A Y *)
(* Goal: @Out Tn A X Y *)
        apply between_symmetry.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
      induction (eq_dec_points M X).
        subst M.
        assert (X = Y).
(* Goal: @Col Tn C0 D0 M' *)
(* Goal: @Bet Tn C M D' *)
          apply l6_21 with P Q A D; assert_cols; Col; ColR.
(* Goal: @Out Tn Y P Q *)
        subst Y.
        absurde.
      eapply (l9_5 _ _ M _ X).
        eapply l9_5.
(* Goal: False *)
          apply H.
(* Goal: False *)
(* Goal: not (@Col Tn V A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn U T V)) *)
          apply H5.
(* Goal: @Out Tn A X Y *)
(* Goal: @Out Tn A X Y *)
        unfold Out.
(* Goal: @TSP Tn A B C Q R *)
        repeat split.
(* Goal: not (@TS Tn D E X Y) *)
          intro.
(* Goal: @Out Tn Y P Q *)
          subst Y.
          apply between_identity in H17.
          subst M.
          absurde.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
          assumption.
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
        right.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: @Out Tn A X Y *)
(* Goal: @Out Tn A X Y *)
      unfold Out.
      assert (Out Y M  A).
(* Goal: @Out Tn A X Y *)
(* Goal: @Out Tn A X Y *)
        unfold Out.
(* Goal: @TSP Tn A B C Q R *)
        repeat split.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
          assumption.
(* Goal: not (@TS Tn D E X Y) *)
          intro.
(* Goal: @Out Tn Y P Q *)
          subst Y.
          apply H11.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
          assumption.
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
        left.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: @TSP Tn A B C Q R *)
      repeat split.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: not (@TS Tn D E X Y) *)
        intro.
(* Goal: False *)
(* Goal: not (@eq (@Tpoint Tn) Y A) *)
(* Goal: @Out Tn A X Y *)
        subst X.
        apply between_identity in H18.
        subst M.
        absurde.
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
      left.
      apply H18.
    eapply (l9_5 _ _ M).
      eapply l9_5.
(* Goal: False *)
        apply H.
(* Goal: False *)
(* Goal: not (@Col Tn V A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn U T V)) *)
        apply H5.
(* Goal: @Out Tn A X Y *)
(* Goal: @Out Tn A X Y *)
      unfold Out.
(* Goal: @TSP Tn A B C Q R *)
      repeat split.
(* Goal: not (@TS Tn D E X Y) *)
        intro.
(* Goal: @Out Tn Y P Q *)
        subst Y.
        apply H7.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: not (@TS Tn D E X Y) *)
        intro.
(* Goal: @Out Tn Y P Q *)
        subst Y.
        assert(Col B D X).
          eapply (col_transitivity_1 _ M).
(* Goal: not (@TS Tn D E X Y) *)
            intro.
            subst M.
            apply H3.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
            assumption.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
            unfold Col.
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
            left.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
            assumption.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
          unfold Col.
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
          left.
(* Goal: @Bet Tn X A Y *)
(* Goal: @Out Tn A X Y *)
          apply between_symmetry.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
          assumption.
        apply H21.
(* Goal: @Col Tn A B Y *)
(* Goal: @OS Tn A B X Y *)
        apply col_permutation_1.
        eapply (col_transitivity_1 _ X).
(* Goal: not (@TS Tn D E X Y) *)
          intro.
(* Goal: False *)
(* Goal: not (@eq (@Tpoint Tn) Y A) *)
(* Goal: @Out Tn A X Y *)
          subst X.
          apply H4.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
          assumption.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
          unfold Col.
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
          left.
(* Goal: @Bet Tn X A Y *)
(* Goal: @Out Tn A X Y *)
          apply between_symmetry.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
          assumption.
(* Goal: @Col Tn A B Y *)
(* Goal: @OS Tn A B X Y *)
        apply col_permutation_1.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
      right.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
(* Goal: False *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T P')) *)
      apply H9.
(* Goal: @Out Tn A X Y *)
(* Goal: @Out Tn A X Y *)
    unfold Out.
(* Goal: @TSP Tn A B C Q R *)
    repeat split.
(* Goal: not (@TS Tn D E X Y) *)
      intro.
(* Goal: False *)
(* Goal: not (@eq (@Tpoint Tn) Y A) *)
(* Goal: @Out Tn A X Y *)
      subst X.
      assert (Col A D Y).
        eapply (col_transitivity_1 _ M).
(* Goal: not (@TS Tn D E X Y) *)
          intro.
          subst M.
          apply H7.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
          assumption.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
          unfold Col.
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
          left.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
          assumption.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
        unfold Col.
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
        left.
(* Goal: @Bet Tn X A Y *)
(* Goal: @Out Tn A X Y *)
        apply between_symmetry.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
      apply H21.
(* Goal: @Col Tn A B Y *)
(* Goal: @OS Tn A B X Y *)
      apply col_permutation_1.
      eapply (col_transitivity_1 _ Y).
(* Goal: not (@TS Tn D E X Y) *)
        intro.
(* Goal: @Out Tn Y P Q *)
        subst Y.
        apply H4.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: @Col Tn A B Y *)
(* Goal: @OS Tn A B X Y *)
        apply col_permutation_1.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
      unfold Col.
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
      left.
(* Goal: @Bet Tn X A Y *)
(* Goal: @Out Tn A X Y *)
      apply between_symmetry.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
(* Goal: not (@TS Tn D E X Y) *)
      intro.
(* Goal: False *)
(* Goal: not (@eq (@Tpoint Tn) Y A) *)
(* Goal: @Out Tn A X Y *)
      subst X.
      apply H3.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
    left.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
    assumption.
Qed.

Lemma l9_9 : forall P Q A B, TS P Q A B -> ~ OS P Q A B.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Coplanar Tn A B C D) (_ : not (@Col Tn C A B)) (_ : not (@Col Tn D A B)) (_ : not (@OS Tn A B C D)), @TS Tn A B C D *)
    intros.
(* Goal: not (@TS Tn D E X Y) *)
    intro.
(* Goal: False *)
    apply (l9_8_2 P Q A B B ) in H.
(* Goal: False *)
(* Goal: @OS Tn P Q A B *)
      apply not_two_sides_id in H.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
    assumption.
Qed.

Lemma l9_9_bis : forall P Q A B, OS P Q A B -> ~ TS P Q A B.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Coplanar Tn A B C D) (_ : not (@Col Tn C A B)) (_ : not (@Col Tn D A B)) (_ : not (@OS Tn A B C D)), @TS Tn A B C D *)
    intros.
(* Goal: not (@TS Tn D E X Y) *)
    intro.
(* Goal: not (@Col Tn A B X) *)
    unfold OS in H.
(* Goal: not (@Col Tn A B X) *)
    ex_and H C.
    assert (OS P Q A B).
      eapply l9_8_1.
(* Goal: False *)
        apply H.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
    assert (~ OS P Q A B).
      apply l9_9.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
(* Goal: @TS Tn A B C D *)
    contradiction.
Qed.

Lemma one_side_chara : forall P Q A B,
 OS P Q A B -> (forall X, Col X P Q -> ~ Bet A X B).
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Coplanar Tn A B C D) (_ : not (@Col Tn C A B)) (_ : not (@Col Tn D A B)) (_ : not (@OS Tn A B C D)), @TS Tn A B C D *)
    intros.
(* Goal: not (@Bet Tn A X B) *)
    assert(~ Col A P Q).
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      destruct H as [R [[] _]]; assumption.
(* Goal: not (@Bet Tn A X B) *)
    assert(~ Col B P Q).
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      destruct H as [R [_ []]]; assumption.
(* Goal: not (@Bet Tn A X B) *)
    apply l9_9_bis in H.
(* Goal: not (@TS Tn D E X Y) *)
    intro.
(* Goal: False *)
    apply H.
(* Goal: @TS Tn A B C P *)
(* Goal: @ex (@Tpoint Tn) (fun P : @Tpoint Tn => and (@Cong Tn A P X Y) (and (@Perp Tn A B P A) (@TS Tn A B C P))) *)
    unfold TS.
(* Goal: @TSP Tn A B C Q R *)
    repeat split.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T P Q) (@Bet Tn A T B)) *)
    exists X.
(* Goal: and (@Col Tn X P Q) (@Bet Tn A X B) *)
    intuition.
Qed.

Lemma l9_10 : forall P Q A,
 ~ Col A P Q -> exists C, TS P Q A C.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Coplanar Tn A B C D) (_ : not (@Col Tn C A B)) (_ : not (@Col Tn D A B)) (_ : not (@OS Tn A B C D)), @TS Tn A B C D *)
    intros.
(* Goal: @ex (@Tpoint Tn) (fun C : @Tpoint Tn => @TS Tn P Q A C) *)
    double A P A'.
(* Goal: @ex (@Tpoint Tn) (fun C : @Tpoint Tn => @TS Tn P Q A C) *)
    exists A'.
(* Goal: @TS Tn A B C P *)
(* Goal: @ex (@Tpoint Tn) (fun P : @Tpoint Tn => and (@Cong Tn A P X Y) (and (@Perp Tn A B P A) (@TS Tn A B C P))) *)
    unfold TS.
(* Goal: @TSP Tn A B C Q R *)
    repeat split.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
(* Goal: not (@TS Tn D E X Y) *)
      intro.
(* Goal: False *)
      apply H.
(* Goal: @Col Tn X A B *)
      eapply col_permutation_2.
(* Goal: @Col Tn P Q A *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T P Q) (@Bet Tn A T A')) *)
      eapply (col_transitivity_1 _ A').
(* Goal: not (@TS Tn D E X Y) *)
        intro.
(* Goal: False *)
(* Goal: @Col Tn P A' Q *)
(* Goal: @Col Tn P A' A *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T P Q) (@Bet Tn A T A')) *)
        subst A'.
(* Goal: False *)
(* Goal: @Col Tn P C Q *)
(* Goal: @Col Tn P C A *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T P Q) (@Bet Tn A T C)) *)
(* Goal: and (@TS Tn P Q A C) (@TS Tn P Q A C) *)
        apply l7_2 in H0.
(* Goal: False *)
(* Goal: @Col Tn P A' Q *)
(* Goal: @Col Tn P A' A *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T P Q) (@Bet Tn A T A')) *)
        eapply is_midpoint_id in H0.
(* Goal: False *)
(* Goal: and (@Bet Tn A P B) (and (not (@Col Tn X Y A)) (not (@Col Tn X Y B))) *)
(* Goal: forall _ : and (@Bet Tn A P B) (and (not (@Col Tn X Y A)) (not (@Col Tn X Y B))), @TS Tn X Y A B *)
        subst A.
(* Goal: False *)
        apply H.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: @Col Tn P C Q *)
(* Goal: @Col Tn P C A *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T P Q) (@Bet Tn A T C)) *)
(* Goal: and (@TS Tn P Q A C) (@TS Tn P Q A C) *)
        apply col_permutation_4.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
      unfold Col.
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
      right; right.
(* Goal: @Bet Tn A P C *)
(* Goal: and (@TS Tn P Q A C) (@TS Tn P Q A C) *)
      apply midpoint_bet.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T X Y) (@Bet Tn A T B)) *)
    exists P.
(* Goal: @TSP Tn A B C Q R *)
    split.
(* Goal: @Col Tn A A B *)
(* Goal: @Bet Tn X A Y *)
(* Goal: @Out Tn A X Y *)
      apply col_trivial_1.
(* Goal: @Bet Tn A P C *)
(* Goal: and (@TS Tn P Q A C) (@TS Tn P Q A C) *)
    apply midpoint_bet.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
    assumption.
Qed.



Lemma one_side_reflexivity : forall P Q A,
 ~ Col A P Q -> OS P Q A A.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Coplanar Tn A B C D) (_ : not (@Col Tn C A B)) (_ : not (@Col Tn D A B)) (_ : not (@OS Tn A B C D)), @TS Tn A B C D *)
    intros.
(* Goal: forall (A B C P Q : @Tpoint Tn) (_ : @Col Tn A B C) (_ : not (@eq (@Tpoint Tn) A C)) (_ : @OS Tn A B P Q), @OS Tn A C P Q *)
    unfold OS.
(* Goal: @ex (@Tpoint Tn) (fun R : @Tpoint Tn => and (@TS Tn P Q A R) (@TS Tn P Q A R)) *)
    double A P C.
(* Goal: @ex (@Tpoint Tn) (fun R : @Tpoint Tn => and (@TS Tn P Q B R) (@TS Tn P Q A R)) *)
    exists C.
(* Goal: and (@TS Tn P Q A C) (@TS Tn P Q A C) *)
    assert (TS P Q A C).
(* Goal: @TSP Tn A B C Q R *)
      repeat split.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: not (@TS Tn D E X Y) *)
        intro.
(* Goal: False *)
        apply H.
(* Goal: @Col Tn X A B *)
        apply col_permutation_2.
(* Goal: @Col Tn P Q A *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T P Q) (@Bet Tn A T C)) *)
(* Goal: and (@TS Tn P Q A C) (@TS Tn P Q A C) *)
        eapply (col_transitivity_1 _ C).
(* Goal: not (@TS Tn D E X Y) *)
          intro.
(* Goal: False *)
(* Goal: @Col Tn P C Q *)
(* Goal: @Col Tn P C A *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T P Q) (@Bet Tn A T C)) *)
(* Goal: and (@TS Tn P Q A C) (@TS Tn P Q A C) *)
          subst C.
(* Goal: False *)
(* Goal: @Col Tn P C Q *)
(* Goal: @Col Tn P C A *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T P Q) (@Bet Tn A T C)) *)
(* Goal: and (@TS Tn P Q A C) (@TS Tn P Q A C) *)
          apply l7_2 in H0.
(* Goal: False *)
(* Goal: @Col Tn P C Q *)
(* Goal: @Col Tn P C A *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T P Q) (@Bet Tn A T C)) *)
(* Goal: and (@TS Tn P Q A C) (@TS Tn P Q A C) *)
          apply is_midpoint_id in H0.
(* Goal: False *)
(* Goal: and (@Bet Tn A P B) (and (not (@Col Tn X Y A)) (not (@Col Tn X Y B))) *)
(* Goal: forall _ : and (@Bet Tn A P B) (and (not (@Col Tn X Y A)) (not (@Col Tn X Y B))), @TS Tn X Y A B *)
          subst A.
(* Goal: False *)
          apply H.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
          assumption.
(* Goal: @Col Tn P C Q *)
(* Goal: @Col Tn P C A *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T P Q) (@Bet Tn A T C)) *)
(* Goal: and (@TS Tn P Q A C) (@TS Tn P Q A C) *)
          apply col_permutation_4.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
          assumption.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
        unfold Col.
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
        right; right.
(* Goal: @Bet Tn A P C *)
(* Goal: and (@TS Tn P Q A C) (@TS Tn P Q A C) *)
        apply midpoint_bet.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T X Y) (@Bet Tn A T B)) *)
      exists P.
(* Goal: @TSP Tn A B C Q R *)
      split.
(* Goal: @Col Tn A A B *)
(* Goal: @Bet Tn X A Y *)
(* Goal: @Out Tn A X Y *)
        apply col_trivial_1.
(* Goal: @Bet Tn A P C *)
(* Goal: and (@TS Tn P Q A C) (@TS Tn P Q A C) *)
      apply midpoint_bet.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
    split; assumption.
Qed.


Lemma one_side_symmetry : forall P Q A B,
 OS P Q A B -> OS P Q B A.
Proof.
(* Goal: forall (A B C P Q : @Tpoint Tn) (_ : @Col Tn A B C) (_ : not (@eq (@Tpoint Tn) A C)) (_ : @OS Tn A B P Q), @OS Tn A C P Q *)
    unfold OS.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Coplanar Tn A B C D) (_ : not (@Col Tn C A B)) (_ : not (@Col Tn D A B)) (_ : not (@OS Tn A B C D)), @TS Tn A B C D *)
    intros.
(* Goal: not (@Col Tn A B X) *)
    ex_and H C.
(* Goal: @ex (@Tpoint Tn) (fun R : @Tpoint Tn => and (@TS Tn P Q B R) (@TS Tn P Q A R)) *)
    exists C.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
    split; assumption.
Qed.

Lemma one_side_transitivity : forall P Q A B C,
OS P Q A B -> OS P Q B C -> OS P Q A C.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Coplanar Tn A B C D) (_ : not (@Col Tn C A B)) (_ : not (@Col Tn D A B)) (_ : not (@OS Tn A B C D)), @TS Tn A B C D *)
    intros.
    unfold OS in *.
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
    ex_and H X.
    ex_and H0 Y.
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T P Q) (@Bet Tn A T B)) *)
    exists X.
(* Goal: @TSP Tn A B C Q R *)
    split.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
(* Goal: @TS Tn A B P C *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T P')) *)
    apply l9_2.
    eapply l9_8_2.
(* Goal: @TS Tn A B P C *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T P')) *)
      apply l9_2.
(* Goal: False *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T P)) *)
(* Goal: @ex (@Tpoint Tn) (fun P : @Tpoint Tn => and (@Cong Tn A P X Y) (and (@Perp Tn A B P A) (@TS Tn A B C P))) *)
      apply H2.
    eapply l9_8_1.
(* Goal: @TS Tn A B P C *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T P')) *)
      apply l9_2.
(* Goal: False *)
(* Goal: @Out Tn C T D *)
(* Goal: @OS Tn A C B D *)
      apply H0.
(* Goal: @TS Tn A B P C *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T P')) *)
    apply l9_2.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
    assumption.
Qed.

Lemma col_eq : forall A B X Y,
  A <> X -> Col A X Y -> Col B X Y ->
 ~ Col A X B ->
 X = Y.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Coplanar Tn A B C D) (_ : not (@Col Tn C A B)) (_ : not (@Col Tn D A B)) (_ : not (@OS Tn A B C D)), @TS Tn A B C D *)
    intros.
(* Goal: @eq (@Tpoint Tn) X Y *)
    apply eq_sym.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
    apply l6_21 with A X B X; assert_diffs; Col.
Qed.

Lemma l9_17 : forall A B C P Q, OS P Q A C -> Bet A B C -> OS P Q A B.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Coplanar Tn A B C D) (_ : not (@Col Tn C A B)) (_ : not (@Col Tn D A B)) (_ : not (@OS Tn A B C D)), @TS Tn A B C D *)
    intros.
    induction (eq_dec_points A C).
(* Goal: False *)
(* Goal: @Col Tn P C Q *)
(* Goal: @Col Tn P C A *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T P Q) (@Bet Tn A T C)) *)
(* Goal: and (@TS Tn P Q A C) (@TS Tn P Q A C) *)
      subst C.
      apply between_identity in H0.
(* Goal: False *)
(* Goal: or (@Bet Tn A T B) (@Bet Tn A B T) *)
(* Goal: @OS Tn A C B D *)
      subst B.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
    assert( HH:= H).
(* Goal: not (@Col Tn A B X) *)
    unfold OS in H.
    ex_and H D.
    assert(HH1:=H).
    unfold TS in H2.
    assert (P <> Q).
(* Goal: not (@TS Tn D E X Y) *)
      intro.
      subst Q.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
      spliter.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
      Col.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
    spliter.
(* Goal: or (not (@Col Tn A X Y)) (not (@Col Tn B X Y)) *)
    unfold TS in H.
    assert (P <> Q).
(* Goal: not (@TS Tn D E X Y) *)
      intro.
      subst Q.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
      spliter.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
      Col.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
    spliter.
    ex_and H8 X.
    ex_and H5 Y.
    assert (exists T,  Bet B T D /\ Bet X T Y).
      eapply l3_17.
(* Goal: False *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T P')) *)
        apply H9.
        apply H10.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
    ex_and H11 T.
(* Goal: forall (A B C P Q : @Tpoint Tn) (_ : @Col Tn A B C) (_ : not (@eq (@Tpoint Tn) A C)) (_ : @OS Tn A B P Q), @OS Tn A C P Q *)
    unfold OS.
    exists D.
(* Goal: @TSP Tn A B C Q R *)
    split.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
(* Goal: @TS Tn A B C P *)
(* Goal: @ex (@Tpoint Tn) (fun P : @Tpoint Tn => and (@Cong Tn A P X Y) (and (@Perp Tn A B P A) (@TS Tn A B C P))) *)
    unfold TS.
(* Goal: @TSP Tn A B C Q R *)
    repeat split.
      apply l9_9_bis in HH.
(* Goal: not (@TS Tn D E X Y) *)
      intro.
      apply HH.
(* Goal: @TS Tn A B C P *)
(* Goal: @ex (@Tpoint Tn) (fun P : @Tpoint Tn => and (@Cong Tn A P X Y) (and (@Perp Tn A B P A) (@TS Tn A B C P))) *)
      unfold TS.
(* Goal: @TSP Tn A B C Q R *)
      repeat split.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
      exists B.
(* Goal: @TSP Tn A B C Q R *)
      split.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
      unfold TS in HH1.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
      spliter.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T P)) *)
(* Goal: @ex (@Tpoint Tn) (fun P : @Tpoint Tn => and (@Cong Tn A P X Y) (and (@Perp Tn A B P A) (@TS Tn A B C P))) *)
    exists T.
    induction (col_dec A C D).
      assert (X = Y).
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
        apply l6_21 with P Q A D; Col.
(* Goal: not (@TS Tn D E X Y) *)
          intro.
(* Goal: False *)
(* Goal: or (@Bet Tn C T D) (@Bet Tn C D T) *)
(* Goal: @OS Tn A C B D *)
          subst D.
          assert (OS P Q A A).
            apply one_side_reflexivity.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
            assumption.
          apply l9_9_bis in H14.
(* Goal: @TS Tn A B C D *)
          contradiction.
(* Goal: @Col Tn X A B *)
          apply col_permutation_2.
(* Goal: @Col Tn P Q A *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T P Q) (@Bet Tn A T C)) *)
(* Goal: and (@TS Tn P Q A C) (@TS Tn P Q A C) *)
          eapply (col_transitivity_1 _ C).
(* Goal: not (@TS Tn D E X Y) *)
            intro.
(* Goal: False *)
(* Goal: or (@Bet Tn C T D) (@Bet Tn C D T) *)
(* Goal: @OS Tn A C B D *)
            subst D.
            apply between_identity in H10.
(* Goal: @Out Tn Y P Q *)
            subst Y.
            apply H4.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
            assumption.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
            assert_cols; Col.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
            Col.
(* Goal: @Out Tn Y P Q *)
      subst Y.
      apply between_identity in H12.
(* Goal: False *)
(* Goal: not (@eq (@Tpoint Tn) Y A) *)
(* Goal: @Out Tn A X Y *)
      subst X.
(* Goal: @TSP Tn A B C Q R *)
      split.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
(* Goal: @TSP Tn A B C Q R *)
    split.
(* Goal: or (not (@Col Tn A X Y)) (not (@Col Tn B X Y)) *)
      assert (X <> Y).
(* Goal: not (@TS Tn D E X Y) *)
        intro.
(* Goal: @Out Tn Y P Q *)
        subst Y.
        apply between_identity in H12.
(* Goal: False *)
(* Goal: not (@eq (@Tpoint Tn) Y A) *)
(* Goal: @Out Tn A X Y *)
        subst X.
        apply H13.
(* Goal: @Col Tn A B Y *)
(* Goal: @OS Tn A B X Y *)
        apply col_permutation_1.
        eapply (col_transitivity_1 _ T).
(* Goal: not (@TS Tn D E X Y) *)
          intro.
(* Goal: False *)
(* Goal: or (@Bet Tn C T D) (@Bet Tn C D T) *)
(* Goal: @OS Tn A C B D *)
          subst D.
(* Goal: @TS Tn A B C D *)
          contradiction.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
          unfold Col.
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
          left.
(* Goal: @Bet Tn X A Y *)
(* Goal: @Out Tn A X Y *)
          apply between_symmetry.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
          assumption.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
        unfold Col.
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
        left.
(* Goal: @Bet Tn X A Y *)
(* Goal: @Out Tn A X Y *)
        apply between_symmetry.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: @Col Tn X A B *)
      apply col_permutation_2.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
      apply (colx X Y); Col.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
    assumption.
Qed.

Lemma l9_18 : forall X Y A B P,
 Col X Y P -> Col A B P -> (TS X Y A B <-> (Bet A P B /\ ~Col X Y A /\ ~Col X Y B)).
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Coplanar Tn A B C D) (_ : not (@Col Tn C A B)) (_ : not (@Col Tn D A B)) (_ : not (@OS Tn A B C D)), @TS Tn A B C D *)
    intros.
(* Goal: @TSP Tn A B C Q R *)
    split.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Coplanar Tn A B C D) (_ : not (@Col Tn C A B)) (_ : not (@Col Tn D A B)) (_ : not (@OS Tn A B C D)), @TS Tn A B C D *)
      intros.
(* Goal: and (@Bet Tn A P B) (and (not (@Col Tn X Y A)) (not (@Col Tn X Y B))) *)
(* Goal: forall _ : and (@Bet Tn A P B) (and (not (@Col Tn X Y A)) (not (@Col Tn X Y B))), @TS Tn X Y A B *)
      unfold TS in H1.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
      spliter.
(* Goal: or (not (@Col Tn A X Y)) (not (@Col Tn B X Y)) *)
      assert (X <> Y).
(* Goal: not (@TS Tn D E X Y) *)
        intro.
(* Goal: @Out Tn Y P Q *)
        subst Y.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
        spliter.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
        Col.
(* Goal: and (@Bet Tn A P B) (and (not (@Col Tn X Y A)) (not (@Col Tn X Y B))) *)
(* Goal: forall _ : and (@Bet Tn A P B) (and (not (@Col Tn X Y A)) (not (@Col Tn X Y B))), @TS Tn X Y A B *)
      ex_and H3 T.
(* Goal: and (@Bet Tn A P B) (and (not (@Col Tn X Y A)) (not (@Col Tn X Y B))) *)
(* Goal: forall _ : and (@Bet Tn A P B) (and (not (@Col Tn X Y A)) (not (@Col Tn X Y B))), @TS Tn X Y A B *)
      assert (P=T).
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
        apply l6_21 with X Y A B; Col.
(* Goal: not (@TS Tn D E X Y) *)
        intro.
(* Goal: False *)
(* Goal: or (@Bet Tn A T B) (@Bet Tn A B T) *)
(* Goal: @OS Tn A C B D *)
        subst B.
(* Goal: False *)
(* Goal: and (@Bet Tn A P B) (and (not (@Col Tn X Y A)) (not (@Col Tn X Y B))) *)
(* Goal: forall _ : and (@Bet Tn A P B) (and (not (@Col Tn X Y A)) (not (@Col Tn X Y B))), @TS Tn X Y A B *)
        apply between_identity in H5.
(* Goal: False *)
(* Goal: and (@Bet Tn A P B) (and (not (@Col Tn X Y A)) (not (@Col Tn X Y B))) *)
(* Goal: forall _ : and (@Bet Tn A P B) (and (not (@Col Tn X Y A)) (not (@Col Tn X Y B))), @TS Tn X Y A B *)
        subst A.
(* Goal: @TS Tn A B C D *)
        contradiction.
(* Goal: False *)
(* Goal: not (@eq (@Tpoint Tn) D C) *)
(* Goal: or (@Bet Tn C T D) (@Bet Tn C D T) *)
(* Goal: @OS Tn A C B D *)
      subst T.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
      repeat split; Col.
(* Goal: not (@TS Tn D E X Y) *)
    intro.
(* Goal: @TS Tn A B C P *)
(* Goal: @ex (@Tpoint Tn) (fun P : @Tpoint Tn => and (@Cong Tn A P X Y) (and (@Perp Tn A B P A) (@TS Tn A B C P))) *)
    unfold TS.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
    spliter.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
    repeat split; Col.
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T X Y) (@Bet Tn A T B)) *)
    exists P.
(* Goal: @TSP Tn A B C Q R *)
    split.
(* Goal: @Col Tn X A B *)
      apply col_permutation_2.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
    assumption.
Qed.

Lemma l9_19 : forall X Y A B P ,
 Col X Y P -> Col A B P -> (OS X Y A B <-> (Out P A B /\ ~Col X Y A)).
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Coplanar Tn A B C D) (_ : not (@Col Tn C A B)) (_ : not (@Col Tn D A B)) (_ : not (@OS Tn A B C D)), @TS Tn A B C D *)
    intros.
(* Goal: @TSP Tn A B C Q R *)
    split.
(* Goal: not (@TS Tn D E X Y) *)
      intro.
      assert (HH2:=H1).
      unfold OS in H1.
      ex_and H1 D.
      unfold TS in H2.
      assert (~ Col B X Y).
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
        spliter.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
      spliter.
      clear H3.
(* Goal: or (not (@Col Tn A X Y)) (not (@Col Tn B X Y)) *)
      assert (X <> Y).
(* Goal: not (@TS Tn D E X Y) *)
        intro.
(* Goal: @Out Tn Y P Q *)
        subst Y.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
        spliter.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
        Col.
(* Goal: and (@Bet Tn A P B) (and (not (@Col Tn X Y A)) (not (@Col Tn X Y B))) *)
(* Goal: forall _ : and (@Bet Tn A P B) (and (not (@Col Tn X Y A)) (not (@Col Tn X Y B))), @TS Tn X Y A B *)
      unfold TS in H1.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
      spliter.
      ex_and H5 M.
      ex_and H7 N.
(* Goal: @TSP Tn A B C Q R *)
      split.
(* Goal: @Out Tn A X Y *)
(* Goal: @Out Tn A X Y *)
        unfold Out.
(* Goal: @TSP Tn A B C Q R *)
        repeat split.
(* Goal: not (@TS Tn D E X Y) *)
          intro.
          subst P.
(* Goal: @Col Tn A P Q *)
          apply H1.
(* Goal: @Col Tn X A B *)
          apply col_permutation_2.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
          assumption.
(* Goal: not (@TS Tn D E X Y) *)
          intro.
          subst P.
(* Goal: False *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T P)) *)
(* Goal: @ex (@Tpoint Tn) (fun P : @Tpoint Tn => and (@Cong Tn A P X Y) (and (@Perp Tn A B P A) (@TS Tn A B C P))) *)
          apply H2.
(* Goal: @Col Tn X A B *)
          apply col_permutation_2.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
          assumption.
        unfold Col in H0.
        induction H0.
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
          right.
(* Goal: @Bet Tn X A Y *)
(* Goal: @Out Tn A X Y *)
          apply between_symmetry.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
          assumption.
        induction H0.
          apply False_ind.
          assert (TS X Y A B).
(* Goal: @TS Tn A B C P *)
(* Goal: @ex (@Tpoint Tn) (fun P : @Tpoint Tn => and (@Cong Tn A P X Y) (and (@Perp Tn A B P A) (@TS Tn A B C P))) *)
            unfold TS.
(* Goal: @TSP Tn A B C Q R *)
            repeat split.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
              assumption.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
              assumption.
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T X Y) (@Bet Tn A T B)) *)
            exists P.
(* Goal: @TSP Tn A B C Q R *)
            split.
(* Goal: @Col Tn X A B *)
              apply col_permutation_2.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
              assumption.
(* Goal: @Bet Tn X A Y *)
(* Goal: @Out Tn A X Y *)
            apply between_symmetry.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
            assumption.
          apply l9_9_bis in HH2.
(* Goal: @TS Tn A B C D *)
          contradiction.
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
        left.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: not (@TS Tn D E X Y) *)
      intro.
(* Goal: @Col Tn A P Q *)
      apply H1.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
      Col.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Coplanar Tn A B C D) (_ : not (@Col Tn C A B)) (_ : not (@Col Tn D A B)) (_ : not (@OS Tn A B C D)), @TS Tn A B C D *)
    intros.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
    spliter.
    assert (exists D, TS X Y A D).
      apply l9_10.
(* Goal: not (@TS Tn D E X Y) *)
      intro.
(* Goal: False *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T P)) *)
(* Goal: @ex (@Tpoint Tn) (fun P : @Tpoint Tn => and (@Cong Tn A P X Y) (and (@Perp Tn A B P A) (@TS Tn A B C P))) *)
      apply H2.
(* Goal: @Col Tn A B Y *)
(* Goal: @OS Tn A B X Y *)
      apply col_permutation_1.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
    ex_elim H3 D.
(* Goal: forall (A B C P Q : @Tpoint Tn) (_ : @Col Tn A B C) (_ : not (@eq (@Tpoint Tn) A C)) (_ : @OS Tn A B P Q), @OS Tn A C P Q *)
    unfold OS.
    exists D.
(* Goal: @TSP Tn A B C Q R *)
    split.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
    eapply l9_5.
      apply H4.
(* Goal: @Col Tn X A B *)
      apply col_permutation_2.
(* Goal: False *)
      apply H.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
    assumption.
Qed.

Lemma one_side_not_col123 :
 forall A B X Y,
  OS A B X Y ->
  ~ Col A B X.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Coplanar Tn A B C D) (_ : not (@Col Tn C A B)) (_ : not (@Col Tn D A B)) (_ : not (@OS Tn A B C D)), @TS Tn A B C D *)
    intros.
(* Goal: not (@Col Tn A B X) *)
    unfold OS in H.
(* Goal: not (@Col Tn A B X) *)
    ex_and H C.
(* Goal: and (not (@Col Tn X A B)) (and (not (@Col Tn Y A B)) (@ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn X T Y)))) *)
(* Goal: @Out Tn A X Y *)
    unfold TS in *.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
    spliter.
(* Goal: not (@TS Tn D E X Y) *)
    intro.
(* Goal: False *)
    apply H.
(* Goal: @Col Tn X A B *)
    apply col_permutation_2.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
    assumption.
Qed.

Lemma one_side_not_col124 :
 forall A B X Y,
  OS A B X Y ->
  ~ Col A B Y.
Proof.
(* Goal: forall (A B X Y : @Tpoint Tn) (_ : @OS Tn A B X Y), not (@Col Tn A B Y) *)
  intros A B X Y HOS.
(* Goal: not (@Col Tn A B Y) *)
  apply one_side_not_col123 with X.
(* Goal: @OS Tn A B Y X *)
  apply one_side_symmetry, HOS.
Qed.

Lemma col_two_sides : forall A B C P Q,
 Col A B C -> A <> C -> TS A B P Q ->
 TS A C P Q.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Coplanar Tn A B C D) (_ : not (@Col Tn C A B)) (_ : not (@Col Tn D A B)) (_ : not (@OS Tn A B C D)), @TS Tn A B C D *)
    intros.
(* Goal: and (not (@Col Tn X A B)) (and (not (@Col Tn Y A B)) (@ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn X T Y)))) *)
(* Goal: @Out Tn A X Y *)
    unfold TS in *.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
    spliter.
(* Goal: and (@Bet Tn A P B) (and (not (@Col Tn X Y A)) (not (@Col Tn X Y B))) *)
(* Goal: forall _ : and (@Bet Tn A P B) (and (not (@Col Tn X Y A)) (not (@Col Tn X Y B))), @TS Tn X Y A B *)
    ex_and H3 T.
(* Goal: @TSP Tn A B C Q R *)
    repeat split.
(* Goal: not (@TS Tn D E X Y) *)
      intro.
(* Goal: @Col Tn A P Q *)
      apply H1.
(* Goal: @Col Tn X A B *)
      apply col_permutation_2.
      eapply col_transitivity_1.
(* Goal: False *)
(* Goal: @Out Tn C T D *)
(* Goal: @OS Tn A C B D *)
        apply H0.
        apply col_permutation_5.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: @Col Tn A B Y *)
(* Goal: @OS Tn A B X Y *)
      apply col_permutation_1.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
(* Goal: not (@TS Tn D E X Y) *)
      intro.
(* Goal: False *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T P)) *)
(* Goal: @ex (@Tpoint Tn) (fun P : @Tpoint Tn => and (@Cong Tn A P X Y) (and (@Perp Tn A B P A) (@TS Tn A B C P))) *)
      apply H2.
(* Goal: @Col Tn X A B *)
      apply col_permutation_2.
      eapply col_transitivity_1.
(* Goal: False *)
(* Goal: @Out Tn C T D *)
(* Goal: @OS Tn A C B D *)
        apply H0.
        apply col_permutation_5.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: @Col Tn A B Y *)
(* Goal: @OS Tn A B X Y *)
      apply col_permutation_1.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T P)) *)
(* Goal: @ex (@Tpoint Tn) (fun P : @Tpoint Tn => and (@Cong Tn A P X Y) (and (@Perp Tn A B P A) (@TS Tn A B C P))) *)
    exists T.
(* Goal: @TSP Tn A B C Q R *)
    split.
(* Goal: @Col Tn X A B *)
      apply col_permutation_2.
      apply col_transitivity_1 with B.
(* Goal: not (@TS Tn D E X Y) *)
        intro.
(* Goal: False *)
(* Goal: or (@Bet Tn A T B) (@Bet Tn A B T) *)
(* Goal: @OS Tn A C B D *)
        subst B.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
        Col.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: @Col Tn A B Y *)
(* Goal: @OS Tn A B X Y *)
      apply col_permutation_1.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
    assumption.
Qed.

Lemma col_one_side : forall A B C P Q,
  Col A B C -> A <> C -> OS A B P Q -> OS A C P Q.
Proof.
(* Goal: forall (A B C P Q : @Tpoint Tn) (_ : @Col Tn A B C) (_ : not (@eq (@Tpoint Tn) A C)) (_ : @OS Tn A B P Q), @OS Tn A C P Q *)
    unfold OS.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Coplanar Tn A B C D) (_ : not (@Col Tn C A B)) (_ : not (@Col Tn D A B)) (_ : not (@OS Tn A B C D)), @TS Tn A B C D *)
    intros.
(* Goal: or (not (@Col Tn A X Y)) (not (@Col Tn B X Y)) *)
    ex_and H1 T.
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T P)) *)
(* Goal: @ex (@Tpoint Tn) (fun P : @Tpoint Tn => and (@Cong Tn A P X Y) (and (@Perp Tn A B P A) (@TS Tn A B C P))) *)
    exists T.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
    split; eapply (col_two_sides _ B); assumption.
Qed.

Lemma out_out_one_side :
 forall A B X Y Z,
  OS A B X Y ->
  Out A Y Z ->
  OS A B X Z.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Coplanar Tn A B C D) (_ : not (@Col Tn C A B)) (_ : not (@Col Tn D A B)) (_ : not (@OS Tn A B C D)), @TS Tn A B C D *)
    intros.
    assert (A <> B).
(* Goal: not (@Col Tn A B X) *)
      unfold OS in H.
(* Goal: not (@Col Tn A B X) *)
      ex_and H C.
(* Goal: or (not (@Col Tn A X Y)) (not (@Col Tn B X Y)) *)
      unfold TS in H.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
      spliter.
(* Goal: not (@TS Tn D E X Y) *)
      intro.
(* Goal: False *)
(* Goal: or (@Bet Tn A T B) (@Bet Tn A B T) *)
(* Goal: @OS Tn A C B D *)
      subst B.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
      Col.
    prolong Y A Y' A Y.
    assert(OS A B Y Z).
(* Goal: forall (A B C P Q : @Tpoint Tn) (_ : @Col Tn A B C) (_ : not (@eq (@Tpoint Tn) A C)) (_ : @OS Tn A B P Q), @OS Tn A C P Q *)
      unfold OS.
      exists Y'.
(* Goal: @TSP Tn A B C Q R *)
      split.
(* Goal: @TS Tn A B C P *)
(* Goal: @ex (@Tpoint Tn) (fun P : @Tpoint Tn => and (@Cong Tn A P X Y) (and (@Perp Tn A B P A) (@TS Tn A B C P))) *)
        unfold TS.
(* Goal: @TSP Tn A B C Q R *)
        repeat split.
          apply one_side_symmetry in H.
          eapply one_side_not_col123 in H.
(* Goal: not (@TS Tn D E X Y) *)
          intro.
(* Goal: False *)
          apply H.
(* Goal: @Col Tn A B Y *)
(* Goal: @OS Tn A B X Y *)
          apply col_permutation_1.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
          assumption.
(* Goal: not (@TS Tn D E X Y) *)
          intro.
          apply one_side_symmetry in H.
          eapply one_side_not_col123 in H.
(* Goal: False *)
          apply H.
          assert(Col A B Y).
            eapply (col_transitivity_1 _ Y').
(* Goal: not (@TS Tn D E X Y) *)
              intro.
              subst Y'.
              apply cong_symmetry in H3.
              apply cong_identity in H3.
(* Goal: @Out Tn Y P Q *)
              subst Y.
              unfold Out in H0.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
              spliter.
              absurde.
(* Goal: @Col Tn P C Q *)
(* Goal: @Col Tn P C A *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T P Q) (@Bet Tn A T C)) *)
(* Goal: and (@TS Tn P Q A C) (@TS Tn P Q A C) *)
              apply col_permutation_4.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
              assumption.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
            unfold Col.
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
            right; right.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
            assumption.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
          assumption.
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn X T Y)) *)
(* Goal: @Out Tn A X Y *)
        exists A.
(* Goal: @TSP Tn A B C Q R *)
        split.
(* Goal: @Col Tn A A B *)
(* Goal: @Bet Tn X A Y *)
(* Goal: @Out Tn A X Y *)
          apply col_trivial_1.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: @TS Tn A B C P *)
(* Goal: @ex (@Tpoint Tn) (fun P : @Tpoint Tn => and (@Cong Tn A P X Y) (and (@Perp Tn A B P A) (@TS Tn A B C P))) *)
      unfold TS.
(* Goal: @TSP Tn A B C Q R *)
      repeat split.
(* Goal: not (@TS Tn D E X Y) *)
        intro.
        apply one_side_symmetry in H.
        eapply one_side_not_col123 in H.
(* Goal: False *)
        apply H.
        eapply (col_transitivity_1 _ Z).
(* Goal: not (@TS Tn D E X Y) *)
          intro.
          subst Z.
          unfold Out in H0.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
          spliter.
          absurde.
(* Goal: @Col Tn P C Q *)
(* Goal: @Col Tn P C A *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T P Q) (@Bet Tn A T C)) *)
(* Goal: and (@TS Tn P Q A C) (@TS Tn P Q A C) *)
          apply col_permutation_4.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
          assumption.
        apply out_col in H0.
        apply col_permutation_5.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
        apply one_side_symmetry in H.
        eapply one_side_not_col123 in H.
(* Goal: not (@TS Tn D E X Y) *)
        intro.
(* Goal: False *)
        apply H.
        eapply (col_transitivity_1 _ Y').
(* Goal: not (@TS Tn D E X Y) *)
          intro.
          subst Y'.
          apply cong_symmetry in H3.
          apply cong_identity in H3.
(* Goal: @Out Tn Y P Q *)
          subst Y.
(* Goal: False *)
          apply H.
          apply col_trivial_3.
(* Goal: @Col Tn P C Q *)
(* Goal: @Col Tn P C A *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T P Q) (@Bet Tn A T C)) *)
(* Goal: and (@TS Tn P Q A C) (@TS Tn P Q A C) *)
          apply col_permutation_4.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
          assumption.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
        unfold Col.
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
        right; right.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn X T Y)) *)
(* Goal: @Out Tn A X Y *)
      exists A.
(* Goal: @TSP Tn A B C Q R *)
      split.
(* Goal: @Col Tn A A B *)
(* Goal: @Bet Tn X A Y *)
(* Goal: @Out Tn A X Y *)
        apply col_trivial_1.
      unfold Out in H0.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
      spliter.
      induction H5.
(* Goal: @Bet Tn X A Y *)
(* Goal: @Out Tn A X Y *)
        apply between_symmetry.
        eapply outer_transitivity_between.
(* Goal: @Bet Tn X A Y *)
(* Goal: @Out Tn A X Y *)
          apply between_symmetry.
(* Goal: False *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T P)) *)
(* Goal: @ex (@Tpoint Tn) (fun P : @Tpoint Tn => and (@Cong Tn A P X Y) (and (@Perp Tn A B P A) (@TS Tn A B C P))) *)
          apply H2.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
          assumption.
(* Goal: False *)
        auto.
(* Goal: @Bet Tn X A Y *)
(* Goal: @Out Tn A X Y *)
      apply between_symmetry.
      eapply between_inner_transitivity.
(* Goal: @Bet Tn X A Y *)
(* Goal: @Out Tn A X Y *)
        apply between_symmetry.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
        apply H2; spliter.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
    eapply one_side_transitivity.
(* Goal: False *)
      apply H.
    apply H4.
Qed.

Lemma out_one_side : forall A B X Y, (~ Col A B X \/ ~ Col A B Y) -> Out A X Y -> OS A B X Y.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Coplanar Tn A B C D) (_ : not (@Col Tn C A B)) (_ : not (@Col Tn D A B)) (_ : not (@OS Tn A B C D)), @TS Tn A B C D *)
    intros.
(* Goal: @Out Tn A X Y *)
    induction H.
(* Goal: @OS Tn A B X Y *)
(* Goal: @OS Tn A B X Y *)
      assert(~ Col X A B).
(* Goal: not (@TS Tn D E X Y) *)
        intro.
(* Goal: False *)
        apply H.
(* Goal: @Col Tn A B Y *)
(* Goal: @OS Tn A B X Y *)
        apply col_permutation_1.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: @OS Tn A B X Y *)
(* Goal: @OS Tn A B X Y *)
      assert(HH:=one_side_reflexivity A B X H1).
(* Goal: @OS Tn A B X Y *)
(* Goal: @OS Tn A B X Y *)
      eapply (out_out_one_side _ _ _ _ _ HH H0).
(* Goal: @OS Tn A B X Y *)
    assert(~ Col Y A B).
(* Goal: not (@TS Tn D E X Y) *)
      intro.
(* Goal: False *)
      apply H.
(* Goal: @Col Tn A B Y *)
(* Goal: @OS Tn A B X Y *)
      apply col_permutation_1.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
(* Goal: @OS Tn A B X Y *)
    assert(HH:=one_side_reflexivity A B Y H1).
(* Goal: @OS Tn Z A X P *)
    apply one_side_symmetry.
(* Goal: @OS Tn A B Y X *)
    eapply (out_out_one_side _ _ _ _ _ HH).
(* Goal: @Out Tn A Y X *)
    apply l6_6.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
    assumption.
Qed.

Lemma bet_ts__ts : forall A B X Y Z, TS A B X Y -> Bet X Y Z -> TS A B X Z.
Proof.
(* Goal: forall (A B X Y Z : @Tpoint Tn) (_ : @TS Tn A B X Y) (_ : @Bet Tn X Y Z), @TS Tn A B X Z *)
  intros A B X Y Z [HNCol1 [HNCol2 [T [HT1 HT2]]]] HBet.
(* Goal: and (@Bet Tn X P Y) (and (not (@Coplanar Tn A B C X)) (not (@Coplanar Tn A B C Y))) *)
  repeat split; trivial.
(* Goal: False *)
    intro; assert (Z = T); [apply (l6_21 A B X Y); Col; intro|]; treat_equalities; auto.
  exists T; split; eBetween.
Qed.

Lemma bet_ts__os : forall A B X Y Z, TS A B X Y -> Bet X Y Z -> OS A B Y Z.
Proof.
(* Goal: forall (A B X Y Z : @Tpoint Tn) (_ : @TS Tn A B X Y) (_ : @Bet Tn X Y Z), @OS Tn A B Y Z *)
  intros A B X Y Z HTS HBet.
(* Goal: @OS Tn A B Y Z *)
  exists X; split; apply l9_2; trivial.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
  apply bet_ts__ts with Y; assumption.
Qed.

Lemma l9_31 :
 forall A X Y Z,
  OS A X Y Z ->
  OS A Z Y X ->
  TS A Y X Z.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Coplanar Tn A B C D) (_ : not (@Col Tn C A B)) (_ : not (@Col Tn D A B)) (_ : not (@OS Tn A B C D)), @TS Tn A B C D *)
    intros.
    assert(A <> X /\ A <> Z /\ ~ Col Y A X  /\ ~ Col Z A X /\ ~Col Y A Z).
      unfold OS in *.
(* Goal: not (@Col Tn A B X) *)
      ex_and H C.
      ex_and H0 D.
(* Goal: and (not (@Col Tn X A B)) (and (not (@Col Tn Y A B)) (@ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn X T Y)))) *)
(* Goal: @Out Tn A X Y *)
      unfold TS in *.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
      spliter.
(* Goal: @TSP Tn A B C Q R *)
      split.
(* Goal: not (@TS Tn D E X Y) *)
        intro.
(* Goal: False *)
(* Goal: not (@eq (@Tpoint Tn) Y A) *)
(* Goal: @Out Tn A X Y *)
        subst X.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
        Col.
(* Goal: @TSP Tn A B C Q R *)
      split.
(* Goal: not (@TS Tn D E X Y) *)
        intro.
        subst Z.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
        Col.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      repeat split; assumption.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
    spliter.
    prolong Z A Z' Z A.
    assert(Z' <> A).
(* Goal: not (@TS Tn D E X Y) *)
      intro.
      subst Z'.
      apply cong_symmetry in H7.
      apply cong_identity in H7.
      subst Z.
      absurde.
    assert(TS A X Y Z').
      eapply (l9_8_2 _ _ Z).
(* Goal: @TS Tn A B C P *)
(* Goal: @ex (@Tpoint Tn) (fun P : @Tpoint Tn => and (@Cong Tn A P X Y) (and (@Perp Tn A B P A) (@TS Tn A B C P))) *)
        unfold TS.
(* Goal: @TSP Tn A B C Q R *)
        repeat split.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
          assumption.
(* Goal: not (@TS Tn D E X Y) *)
          intro.
          apply H4.
(* Goal: @Col Tn X A B *)
          apply col_permutation_2.
          eapply (col_transitivity_1 _ Z').
(* Goal: False *)
            auto.
(* Goal: @Col Tn P C Q *)
(* Goal: @Col Tn P C A *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T P Q) (@Bet Tn A T C)) *)
(* Goal: and (@TS Tn P Q A C) (@TS Tn P Q A C) *)
            apply col_permutation_4.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
            assumption.
(* Goal: @Col Tn A B Y *)
(* Goal: @OS Tn A B X Y *)
          apply col_permutation_1.
          apply bet_col.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
          assumption.
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn X T Y)) *)
(* Goal: @Out Tn A X Y *)
        exists A.
(* Goal: @TSP Tn A B C Q R *)
        split.
(* Goal: @Col Tn A A B *)
(* Goal: @Bet Tn X A Y *)
(* Goal: @Out Tn A X Y *)
          apply col_trivial_1.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: @OS Tn Z A X P *)
      apply one_side_symmetry.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
    unfold TS in H9.
    assert (~ Col Y A X).
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
      spliter.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
    spliter.
    ex_and H12 T.
    assert(T <> A).
(* Goal: not (@TS Tn D E X Y) *)
      intro.
(* Goal: False *)
(* Goal: not (@eq (@Tpoint Tn) D C) *)
(* Goal: or (@Bet Tn C T D) (@Bet Tn C D T) *)
(* Goal: @OS Tn A C B D *)
      subst T.
(* Goal: False *)
(* Goal: not (@Col Tn V A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn U T V)) *)
      apply H5.
(* Goal: @Col Tn X A B *)
      apply col_permutation_2.
      eapply (col_transitivity_1 _ Z').
(* Goal: False *)
        auto.
(* Goal: @Col Tn A B Y *)
(* Goal: @OS Tn A B X Y *)
        apply col_permutation_1.
        apply bet_col.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: @Col Tn A B Y *)
(* Goal: @OS Tn A B X Y *)
      apply col_permutation_1.
      apply bet_col.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
    assert(OS Y A Z' T).
      eapply out_one_side.
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
        left.
(* Goal: not (@TS Tn D E X Y) *)
        intro.
(* Goal: False *)
(* Goal: not (@Col Tn V A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn U T V)) *)
        apply H5.
(* Goal: @Col Tn X A B *)
        apply col_permutation_2.
        eapply (col_transitivity_1 _ Z').
(* Goal: False *)
          auto.
          apply bet_col in H6.
(* Goal: @Col Tn A B Y *)
(* Goal: @OS Tn A B X Y *)
          apply col_permutation_1.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
          assumption.
(* Goal: @Col Tn A B Y *)
(* Goal: @OS Tn A B X Y *)
        apply col_permutation_1.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: @Out Tn A Y X *)
      apply l6_6.
      apply bet_out.
(* Goal: not (@TS Tn D E X Y) *)
        intro.
(* Goal: False *)
(* Goal: not (@eq (@Tpoint Tn) D C) *)
(* Goal: or (@Bet Tn C T D) (@Bet Tn C D T) *)
(* Goal: @OS Tn A C B D *)
        subst T.
(* Goal: @TS Tn A B C D *)
        contradiction.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
    unfold Col in H12.
    induction H12.
      assert(OS Z' Z Y T).
(* Goal: @OS Tn A B P P' *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T P')) *)
        apply out_one_side.
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
          left.
(* Goal: not (@TS Tn D E X Y) *)
          intro.
(* Goal: False *)
(* Goal: not (@Col Tn V A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn U T V)) *)
          apply H5.
(* Goal: @Col Tn A B Y *)
(* Goal: @OS Tn A B X Y *)
          eapply col_permutation_1.
          eapply (col_transitivity_1 _ Z').
(* Goal: not (@TS Tn D E X Y) *)
            intro.
            subst Z'.
            apply between_identity in H6.
            subst Z.
            apply H4.
(* Goal: @Col Tn A A B *)
(* Goal: @Bet Tn X A Y *)
(* Goal: @Out Tn A X Y *)
            apply col_trivial_1.
(* Goal: @Col Tn P C Q *)
(* Goal: @Col Tn P C A *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T P Q) (@Bet Tn A T C)) *)
(* Goal: and (@TS Tn P Q A C) (@TS Tn P Q A C) *)
            apply col_permutation_4.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
            assumption.
          apply bet_col in H6.
          apply col_permutation_5.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
          assumption.
(* Goal: @Out Tn A Y X *)
        apply l6_6.
        apply bet_out.
(* Goal: not (@TS Tn D E X Y) *)
          intro.
(* Goal: False *)
(* Goal: not (@eq (@Tpoint Tn) D C) *)
(* Goal: or (@Bet Tn C T D) (@Bet Tn C D T) *)
(* Goal: @OS Tn A C B D *)
          subst T.
          apply H11.
          apply bet_col.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
          assumption.
(* Goal: @Bet Tn X A Y *)
(* Goal: @Out Tn A X Y *)
        apply between_symmetry.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
      assert(OS A Z Y T).
(* Goal: @OS Tn A X P Z *)
        apply invert_one_side.
        eapply (col_one_side _ Z').
          apply bet_col in H6.
          apply col_permutation_5.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
          assumption.
(* Goal: False *)
          auto.
(* Goal: @OS Tn A X P Z *)
        apply invert_one_side.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
      assert(TS A Z X T).
(* Goal: @TSP Tn A B C Q R *)
        repeat split.
(* Goal: not (@TS Tn D E X Y) *)
          intro.
          apply H11.
(* Goal: @Col Tn X A B *)
          apply col_permutation_2.
          eapply (col_transitivity_1 _ Z).
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
            assumption.
(* Goal: @Col Tn A B Y *)
(* Goal: @OS Tn A B X Y *)
            apply col_permutation_1.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
            assumption.
          apply bet_col in H6.
(* Goal: @Col Tn P C Q *)
(* Goal: @Col Tn P C A *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T P Q) (@Bet Tn A T C)) *)
(* Goal: and (@TS Tn P Q A C) (@TS Tn P Q A C) *)
          apply col_permutation_4.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
          assumption.
          unfold OS in H17.
          ex_and H17 C.
          unfold TS in H18.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
          spliter.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
          assumption.
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn X T Y)) *)
(* Goal: @Out Tn A X Y *)
        exists A.
(* Goal: @TSP Tn A B C Q R *)
        split.
(* Goal: @Col Tn A A B *)
(* Goal: @Bet Tn X A Y *)
(* Goal: @Out Tn A X Y *)
          apply col_trivial_1.
(* Goal: @Bet Tn X A Y *)
(* Goal: @Out Tn A X Y *)
        apply between_symmetry.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
      assert(TS A Z Y X).
        eapply l9_8_2.
(* Goal: @TS Tn A B P C *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T P')) *)
          eapply l9_2.
          apply H18.
(* Goal: @OS Tn Z A X P *)
        apply one_side_symmetry.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
      apply l9_9 in H19.
(* Goal: @TS Tn A B C D *)
      contradiction.
    assert(OS A Z T X).
(* Goal: @OS Tn A B P P' *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T P')) *)
      apply out_one_side.
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
        right.
(* Goal: not (@TS Tn D E X Y) *)
        intro.
        apply H4.
(* Goal: @Col Tn P C Q *)
(* Goal: @Col Tn P C A *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T P Q) (@Bet Tn A T C)) *)
(* Goal: and (@TS Tn P Q A C) (@TS Tn P Q A C) *)
        apply col_permutation_4.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: @TSP Tn A B C Q R *)
      repeat split.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: False *)
        auto.
      induction H12.
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
        right.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
      left.
(* Goal: @Bet Tn X A Y *)
(* Goal: @Out Tn A X Y *)
      apply between_symmetry.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
    assert(TS A Y Z' Z).
(* Goal: @TSP Tn A B C Q R *)
      repeat split.
        unfold OS in H5.
        ex_and H15 C.
        unfold TS in H15.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
        spliter.
(* Goal: not (@TS Tn D E X Y) *)
        intro.
        apply H15.
        apply col_permutation_5.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: not (@TS Tn D E X Y) *)
        intro.
(* Goal: False *)
(* Goal: not (@Col Tn V A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn U T V)) *)
        apply H5.
        apply col_permutation_3.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn X T Y)) *)
(* Goal: @Out Tn A X Y *)
      exists A.
(* Goal: @TSP Tn A B C Q R *)
      split.
(* Goal: @Col Tn A A B *)
(* Goal: @Bet Tn X A Y *)
(* Goal: @Out Tn A X Y *)
        apply col_trivial_1.
(* Goal: @Bet Tn X A Y *)
(* Goal: @Out Tn A X Y *)
      apply between_symmetry.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
    assert(OS A Y T X).
(* Goal: @OS Tn A B P P' *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T P')) *)
      apply out_one_side.
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
        left.
        unfold OS in H15.
        ex_and H15 C.
        unfold TS in H18.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
        spliter.
(* Goal: not (@TS Tn D E X Y) *)
        intro.
        apply H18.
        apply col_permutation_3.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: @TSP Tn A B C Q R *)
      repeat split.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: False *)
        auto.
      induction H12.
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
        right.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
      left.
(* Goal: @Bet Tn X A Y *)
(* Goal: @Out Tn A X Y *)
      apply between_symmetry.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
    apply invert_one_side in H15.
    assert (OS A Y Z' X).
      eapply one_side_transitivity.
        apply H15.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
    eapply l9_8_2.
      apply H17.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
    assumption.
Qed.

Lemma col123__nos : forall A B P Q, Col P Q A -> ~ OS P Q A B.
Proof.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
  intros A B P Q HCol.
(* Goal: not (@OS Tn P Q A B) *)
  intro HOne.
(* Goal: False *)
  assert (~ Col P Q A) by (apply (one_side_not_col123 P Q A B); auto).
(* Goal: False *)
  auto.
Qed.

Lemma col124__nos : forall A B P Q, Col P Q B -> ~ OS P Q A B.
Proof.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
  intros A B P Q HCol.
(* Goal: not (@OS Tn P Q A B) *)
  intro HOne.
(* Goal: False *)
  assert (HN : ~ OS P Q B A) by (apply col123__nos; auto).
(* Goal: False *)
  apply HN; apply one_side_symmetry; auto.
Qed.

Lemma col2_os__os : forall A B C D X Y, C <> D -> Col A B C ->
   Col A B D -> OS A B X Y -> OS C D X Y.
Proof.
(* Goal: forall (A B C D X Y : @Tpoint Tn) (_ : not (@eq (@Tpoint Tn) C D)) (_ : @Col Tn A B C) (_ : @Col Tn A B D) (_ : @OS Tn A B X Y), @OS Tn C D X Y *)
  intros A B C D X Y HCD HColC HColD Hos.
(* Goal: @OS Tn C D X Y *)
  destruct Hos as [Z [Hts1 Hts2]].
(* Goal: @OS Tn C D X Y *)
  exists Z.
(* Goal: False *)
  split; apply (col_preserves_two_sides A B); auto.
Qed.

Lemma os_out_os : forall A B C D C' P , Col A B P -> OS A B C D -> Out P C C' -> OS A B C' D.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Coplanar Tn A B C D) (_ : not (@Col Tn C A B)) (_ : not (@Col Tn D A B)) (_ : not (@OS Tn A B C D)), @TS Tn A B C D *)
    intros.
    assert(A <> B /\ ~ Col C A B).
(* Goal: and (not (@Col Tn X A B)) (and (not (@Col Tn Y A B)) (@ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn X T Y)))) *)
(* Goal: @Out Tn A X Y *)
      unfold OS in H0.
      ex_and H0 T.
      unfold TS in H0.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
      spliter.
(* Goal: @TSP Tn A B C Q R *)
      split.
(* Goal: not (@TS Tn D E X Y) *)
        intro.
(* Goal: False *)
(* Goal: or (@Bet Tn A T B) (@Bet Tn A B T) *)
(* Goal: @OS Tn A C B D *)
        subst B.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
        Col.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
    spliter.
    prolong C P T C P.
    assert(P <> T).
(* Goal: not (@TS Tn D E X Y) *)
      intro.
(* Goal: False *)
(* Goal: not (@eq (@Tpoint Tn) D C) *)
(* Goal: or (@Bet Tn C T D) (@Bet Tn C D T) *)
(* Goal: @OS Tn A C B D *)
      subst T.
(* Goal: @Col Tn A B C *)
(* Goal: @Col Tn A B C *)
      treat_equalities.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
      Col.
    assert(TS A B C T).
(* Goal: @TS Tn A B C P *)
(* Goal: @ex (@Tpoint Tn) (fun P : @Tpoint Tn => and (@Cong Tn A P X Y) (and (@Perp Tn A B P A) (@TS Tn A B C P))) *)
      unfold TS.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
      repeat split; Col.
(* Goal: not (@TS Tn D E X Y) *)
        intro.
        apply H3.
(* Goal: @eq (@Tpoint Tn) T1 T *)
(* Goal: @OS Tn A C B D *)
        assert_cols. ColR.
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T X Y) (@Bet Tn A T B)) *)
      exists P.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
      split; Col.
    assert(TS A B T C').
      apply bet_col in H4.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
      eapply (out_out_two_sides _ _ T C _ _ P); Col.
(* Goal: @TS Tn A B P C *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T P')) *)
        apply l9_2.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
      apply out_trivial.
(* Goal: False *)
      auto.
    assert(OS A B C C').
      eapply l9_8_1.
        apply H7.
(* Goal: @TS Tn A B P C *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T P')) *)
      apply l9_2.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
    eauto using one_side_transitivity, one_side_symmetry.
Qed.

Lemma ts_ts_os : forall A B C D, TS A B C D -> TS C D A B -> OS A C B D.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Coplanar Tn A B C D) (_ : not (@Col Tn C A B)) (_ : not (@Col Tn D A B)) (_ : not (@OS Tn A B C D)), @TS Tn A B C D *)
    intros.
(* Goal: and (not (@Col Tn X A B)) (and (not (@Col Tn Y A B)) (@ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn X T Y)))) *)
(* Goal: @Out Tn A X Y *)
    unfold TS in *.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
    spliter.
(* Goal: @OS Tn A C B D *)
    ex_and H4 T1.
(* Goal: @ex (@Tpoint Tn) (fun P : @Tpoint Tn => and (@Cong Tn A P X Y) (and (@Perp Tn A B P A) (@TS Tn A B C P))) *)
    ex_and H2 T.
(* Goal: @OS Tn A C B D *)
    assert(T1 = T).
(* Goal: @eq (@Tpoint Tn) T1 T *)
(* Goal: @OS Tn A C B D *)
      assert_cols.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
      apply (l6_21 C D A B); Col.
(* Goal: not (@TS Tn D E X Y) *)
      intro.
(* Goal: False *)
(* Goal: or (@Bet Tn A T B) (@Bet Tn A B T) *)
(* Goal: @OS Tn A C B D *)
      subst B.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
      Col.
(* Goal: @OS Tn A C B D *)
    subst T1.

(* Goal: @OS Tn A C B D *)
assert(OS A C T B).
(* Goal: @OS Tn A C T B *)
(* Goal: @OS Tn A C B D *)
apply(out_one_side A C T B).
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
right.
(* Goal: not (@TS Tn D E X Y) *)
intro.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
Col.
(* Goal: @Out Tn A X Y *)
(* Goal: @Out Tn A X Y *)
unfold Out.
(* Goal: @TSP Tn A B C Q R *)
repeat split.
(* Goal: not (@TS Tn D E X Y) *)
intro.
(* Goal: False *)
(* Goal: not (@eq (@Tpoint Tn) D C) *)
(* Goal: or (@Bet Tn C T D) (@Bet Tn C D T) *)
(* Goal: @OS Tn A C B D *)
subst T.
(* Goal: @TS Tn A B C D *)
contradiction.
(* Goal: not (@TS Tn D E X Y) *)
intro.
(* Goal: False *)
(* Goal: or (@Bet Tn A T B) (@Bet Tn A B T) *)
(* Goal: @OS Tn A C B D *)
subst B.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
Col.
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
left.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
assumption.

(* Goal: @OS Tn A C B D *)
assert(OS C A T D).
(* Goal: @OS Tn C A T D *)
(* Goal: @OS Tn A C B D *)
apply(out_one_side C A T D).
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
right.
(* Goal: not (@TS Tn D E X Y) *)
intro.
(* Goal: False *)
(* Goal: @Out Tn C T D *)
(* Goal: @OS Tn A C B D *)
apply H0.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
Col.
(* Goal: @Out Tn A X Y *)
(* Goal: @Out Tn A X Y *)
unfold Out.
(* Goal: @TSP Tn A B C Q R *)
repeat split.
(* Goal: not (@TS Tn D E X Y) *)
intro.
(* Goal: False *)
(* Goal: not (@eq (@Tpoint Tn) D C) *)
(* Goal: or (@Bet Tn C T D) (@Bet Tn C D T) *)
(* Goal: @OS Tn A C B D *)
subst T.
(* Goal: @TS Tn A B C D *)
contradiction.
(* Goal: not (@TS Tn D E X Y) *)
intro.
(* Goal: False *)
(* Goal: or (@Bet Tn C T D) (@Bet Tn C D T) *)
(* Goal: @OS Tn A C B D *)
subst D.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
Col.
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
left.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
assumption.
(* Goal: @OS Tn A C B D *)
apply invert_one_side in H8.
(* Goal: @OS Tn A C B D *)
apply (one_side_transitivity A C B T).
(* Goal: @OS Tn Z A X P *)
apply one_side_symmetry.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
assumption.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
assumption.
Qed.

Lemma two_sides_not_col :
 forall A B X Y,
  TS A B X Y ->
  ~ Col A B X.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Coplanar Tn A B C D) (_ : not (@Col Tn C A B)) (_ : not (@Col Tn D A B)) (_ : not (@OS Tn A B C D)), @TS Tn A B C D *)
    intros.
(* Goal: or (not (@Col Tn A X Y)) (not (@Col Tn B X Y)) *)
    unfold TS in H.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
    spliter.
(* Goal: not (@TS Tn D E X Y) *)
    intro.
(* Goal: False *)
    apply H.
(* Goal: @Col Tn X A B *)
    apply col_permutation_2.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
    assumption.
Qed.

Lemma col_one_side_out : forall A B X Y,
 Col A X Y ->
 OS A B X Y ->
 Out A X Y.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Coplanar Tn A B C D) (_ : not (@Col Tn C A B)) (_ : not (@Col Tn D A B)) (_ : not (@OS Tn A B C D)), @TS Tn A B C D *)
    intros.
(* Goal: @Out Tn A X Y *)
    assert(X <> A /\ Y <> A).
(* Goal: and (not (@Col Tn X A B)) (and (not (@Col Tn Y A B)) (@ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn X T Y)))) *)
(* Goal: @Out Tn A X Y *)
      unfold OS in H0.
(* Goal: and (not (@Col Tn X A B)) (and (not (@Col Tn Y A B)) (@ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn X T Y)))) *)
(* Goal: @Out Tn A X Y *)
      ex_and H0 Z.
(* Goal: and (not (@Col Tn X A B)) (and (not (@Col Tn Y A B)) (@ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn X T Y)))) *)
(* Goal: @Out Tn A X Y *)
      unfold TS in *.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
      spliter.
(* Goal: and (not (@eq (@Tpoint Tn) X A)) (not (@eq (@Tpoint Tn) Y A)) *)
(* Goal: @Out Tn A X Y *)
      ex_and H5 T0.
(* Goal: and (not (@eq (@Tpoint Tn) X A)) (not (@eq (@Tpoint Tn) Y A)) *)
(* Goal: @Out Tn A X Y *)
      ex_and H3 T1.
(* Goal: @TSP Tn A B C Q R *)
      split.
(* Goal: not (@TS Tn D E X Y) *)
        intro.
(* Goal: False *)
(* Goal: not (@eq (@Tpoint Tn) Y A) *)
(* Goal: @Out Tn A X Y *)
        subst X.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
        Col.
(* Goal: not (@TS Tn D E X Y) *)
      intro.
(* Goal: @Out Tn Y P Q *)
      subst Y.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
      Col.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
    spliter.
(* Goal: @Out Tn A X Y *)
    unfold Col in H.
(* Goal: @Out Tn A X Y *)
    induction H.
(* Goal: @Out Tn A X Y *)
(* Goal: @Out Tn A X Y *)
      unfold Out.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      repeat split; try assumption.
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
      left.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
(* Goal: @Out Tn A X Y *)
    induction H.
(* Goal: @Out Tn A X Y *)
(* Goal: @Out Tn A X Y *)
      unfold Out.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      repeat split; try assumption.
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
      right.
(* Goal: @Bet Tn X A Y *)
(* Goal: @Out Tn A X Y *)
      apply between_symmetry.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
(* Goal: @Out Tn A X Y *)
    assert(TS A B X Y).
(* Goal: @TS Tn A B C P *)
(* Goal: @ex (@Tpoint Tn) (fun P : @Tpoint Tn => and (@Cong Tn A P X Y) (and (@Perp Tn A B P A) (@TS Tn A B C P))) *)
      unfold TS.
(* Goal: and (not (@Col Tn X A B)) (and (not (@Col Tn Y A B)) (@ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn X T Y)))) *)
(* Goal: @Out Tn A X Y *)
      assert(HH0 := H0).
(* Goal: and (not (@Col Tn X A B)) (and (not (@Col Tn Y A B)) (@ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn X T Y)))) *)
(* Goal: @Out Tn A X Y *)
      unfold OS in H0.
(* Goal: and (not (@Col Tn X A B)) (and (not (@Col Tn Y A B)) (@ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn X T Y)))) *)
(* Goal: @Out Tn A X Y *)
      ex_and H0 Z.
(* Goal: and (not (@Col Tn X A B)) (and (not (@Col Tn Y A B)) (@ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn X T Y)))) *)
(* Goal: @Out Tn A X Y *)
      unfold TS in *.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
      spliter.
(* Goal: @TSP Tn A B C Q R *)
      repeat split.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn X T Y)) *)
(* Goal: @Out Tn A X Y *)
      exists A.
(* Goal: @TSP Tn A B C Q R *)
      split.
(* Goal: @Col Tn A A B *)
(* Goal: @Bet Tn X A Y *)
(* Goal: @Out Tn A X Y *)
        apply col_trivial_1.
(* Goal: @Bet Tn X A Y *)
(* Goal: @Out Tn A X Y *)
      apply between_symmetry.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
(* Goal: @Out Tn A X Y *)
    eapply l9_9 in H3.
(* Goal: @TS Tn A B C D *)
    contradiction.
Qed.

Lemma col_two_sides_bet :
 forall A B X Y,
 Col A X Y ->
 TS A B X Y ->
 Bet X A Y.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Coplanar Tn A B C D) (_ : not (@Col Tn C A B)) (_ : not (@Col Tn D A B)) (_ : not (@OS Tn A B C D)), @TS Tn A B C D *)
    intros.
(* Goal: @Out Tn A X Y *)
    unfold Col in H.
(* Goal: @Out Tn A X Y *)
    induction H.
      unfold TS in H0.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
      spliter.
(* Goal: @ex (@Tpoint Tn) (fun P : @Tpoint Tn => and (@Cong Tn A P X Y) (and (@Perp Tn A B P A) (@TS Tn A B C P))) *)
      ex_and H2 T.
      apply False_ind.
(* Goal: @Col Tn A P Q *)
      apply H1.
(* Goal: @Col Tn X A B *)
      apply col_permutation_2.
      eapply (col_transitivity_1 _ T).
(* Goal: not (@TS Tn D E X Y) *)
        intro.
(* Goal: False *)
(* Goal: not (@eq (@Tpoint Tn) D C) *)
(* Goal: or (@Bet Tn C T D) (@Bet Tn C D T) *)
(* Goal: @OS Tn A C B D *)
        subst T.
        assert(A = X).
          eapply between_equality.
(* Goal: False *)
            apply H.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
          assumption.
(* Goal: False *)
(* Goal: not (@eq (@Tpoint Tn) Y A) *)
(* Goal: @Out Tn A X Y *)
        subst X.
(* Goal: False *)
(* Goal: @Out Tn C T D *)
(* Goal: @OS Tn A C B D *)
        apply H0.
(* Goal: @Col Tn A A B *)
(* Goal: @Bet Tn X A Y *)
(* Goal: @Out Tn A X Y *)
        apply col_trivial_1.
(* Goal: @Col Tn P C Q *)
(* Goal: @Col Tn P C A *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T P Q) (@Bet Tn A T C)) *)
(* Goal: and (@TS Tn P Q A C) (@TS Tn P Q A C) *)
        apply col_permutation_4.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: @Col Tn A B Y *)
(* Goal: @OS Tn A B X Y *)
      apply col_permutation_1.
      eapply (col_transitivity_1 _ X).
(* Goal: not (@TS Tn D E X Y) *)
        intro.
(* Goal: @Out Tn Y P Q *)
        subst Y.
        apply between_identity in H3.
(* Goal: False *)
(* Goal: not (@eq (@Tpoint Tn) Y A) *)
(* Goal: @Out Tn A X Y *)
        subst X.
(* Goal: @TS Tn A B C D *)
        contradiction.
        apply bet_col in H.
        apply col_permutation_3.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: @Col Tn X A B *)
      apply col_permutation_2.
      apply bet_col.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
(* Goal: @Out Tn A X Y *)
    induction H.
      unfold TS in H0.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
      spliter.
(* Goal: @ex (@Tpoint Tn) (fun P : @Tpoint Tn => and (@Cong Tn A P X Y) (and (@Perp Tn A B P A) (@TS Tn A B C P))) *)
      ex_and H2 T.
      assert(Col Y A T).
        eapply (col_transitivity_1 _ X).
(* Goal: not (@TS Tn D E X Y) *)
          intro.
(* Goal: @Out Tn Y P Q *)
          subst Y.
          apply between_identity in H3.
(* Goal: False *)
(* Goal: not (@eq (@Tpoint Tn) Y A) *)
(* Goal: @Out Tn A X Y *)
          subst X.
(* Goal: @TS Tn A B C D *)
          contradiction.
(* Goal: @Col Tn P C Q *)
(* Goal: @Col Tn P C A *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T P Q) (@Bet Tn A T C)) *)
(* Goal: and (@TS Tn P Q A C) (@TS Tn P Q A C) *)
          apply col_permutation_4.
          apply bet_col.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
          assumption.
(* Goal: @Col Tn X A B *)
        apply col_permutation_2.
        apply bet_col.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
      apply False_ind.
(* Goal: @Col Tn A P Q *)
      apply H1.
(* Goal: @Col Tn X A B *)
      apply col_permutation_2.
      eapply (col_transitivity_1 _ T).
(* Goal: not (@TS Tn D E X Y) *)
        intro.
(* Goal: False *)
(* Goal: not (@eq (@Tpoint Tn) D C) *)
(* Goal: or (@Bet Tn C T D) (@Bet Tn C D T) *)
(* Goal: @OS Tn A C B D *)
        subst T.
        assert(A = Y).
          eapply between_equality.
(* Goal: @Bet Tn X A Y *)
(* Goal: @Out Tn A X Y *)
            apply between_symmetry.
(* Goal: False *)
            apply H.
(* Goal: @Bet Tn X A Y *)
(* Goal: @Out Tn A X Y *)
          apply between_symmetry.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
          assumption.
(* Goal: @Out Tn Y P Q *)
        subst Y.
(* Goal: @Col Tn A P Q *)
        apply H1.
(* Goal: @Col Tn A A B *)
(* Goal: @Bet Tn X A Y *)
(* Goal: @Out Tn A X Y *)
        apply col_trivial_1.
(* Goal: @Col Tn P C Q *)
(* Goal: @Col Tn P C A *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T P Q) (@Bet Tn A T C)) *)
(* Goal: and (@TS Tn P Q A C) (@TS Tn P Q A C) *)
        apply col_permutation_4.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: @Col Tn A B Y *)
(* Goal: @OS Tn A B X Y *)
      apply col_permutation_1.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
(* Goal: @Bet Tn X A Y *)
(* Goal: @Out Tn A X Y *)
    apply between_symmetry.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
    assumption.
Qed.

Lemma os_ts1324__os : forall A X Y Z,
  OS A X Y Z ->
  TS A Y X Z ->
  OS A Z X Y.
Proof.
(* Goal: forall (A X Y Z : @Tpoint Tn) (_ : @OS Tn A X Y Z) (_ : @TS Tn A Y X Z), @OS Tn A Z X Y *)
  intros A X Y Z Hos Hts.
(* Goal: @OS Tn A Z X Y *)
  destruct Hts as [HNColXY [HNColYZ [P [HColP HPBet]]]].
(* Goal: @OS Tn A Z X Y *)
  apply (one_side_transitivity _ _ _ P).
(* Goal: @OS Tn A X P Z *)
  - apply invert_one_side.
(* Goal: @OS Tn Z A X P *)
    apply one_side_symmetry.
(* Goal: @OS Tn A X P Y *)
    apply one_side_symmetry in Hos.
(* Goal: @OS Tn X A P Z *)
    apply one_side_not_col123 in Hos.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
    apply out_one_side; Col.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
    apply bet_out; Between; intro; subst Z; Col.

(* Goal: @OS Tn A B P P' *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T P')) *)
  - apply out_one_side.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
    right; Col.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
    apply (col_one_side_out _ X); Col.
(* Goal: @OS Tn A X P Y *)
    apply one_side_symmetry in Hos.
(* Goal: False *)
    apply (one_side_transitivity _ _ _ Z); auto.
(* Goal: @OS Tn A X P Z *)
    apply invert_one_side.
(* Goal: @OS Tn X A P Z *)
    apply one_side_not_col123 in Hos.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
    apply out_one_side; Col.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
    apply bet_out; auto; intro; subst X; Col.
Qed.

Lemma ts2__ex_bet2 : forall A B C D, TS A C B D -> TS B D A C ->
  exists X, Bet A X C /\ Bet B X D.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @TS Tn A C B D) (_ : @TS Tn B D A C), @ex (@Tpoint Tn) (fun X : @Tpoint Tn => and (@Bet Tn A X C) (@Bet Tn B X D)) *)
  intros A B C D HTS HTS'.
(* Goal: @ex (@Tpoint Tn) (fun X : @Tpoint Tn => and (@Bet Tn A X C) (@Bet Tn B X D)) *)
  destruct HTS as [HNCol [HNCol1 [X [HCol HBet]]]].
(* Goal: @ex (@Tpoint Tn) (fun X : @Tpoint Tn => and (@Bet Tn A X C) (or (@eq (@Tpoint Tn) X B) (@Out Tn B X P))) *)
  exists X; split; trivial.
(* Goal: @Bet Tn A X C *)
  apply col_two_sides_bet with B; trivial.
(* Goal: or (@TS Tn A B C D) (not (@TS Tn A B C D)) *)
  assert_diffs.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
  apply invert_two_sides, col_two_sides with D; Col.
(* Goal: False *)
  intro; subst X; auto.
Qed.

Lemma ts2__inangle : forall A B C P, TS A C B P -> TS B P A C ->
  InAngle P A B C.
Proof.
(* Goal: forall (A B C P : @Tpoint Tn) (_ : @TS Tn A C B P) (_ : @TS Tn B P A C), @InAngle Tn P A B C *)
  intros A B C P HTS1 HTS2.
(* Goal: @InAngle Tn P A B C *)
  destruct (ts2__ex_bet2 A B C P) as [X [HBet1 HBet2]]; trivial.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
  apply ts_distincts in HTS2; spliter.
(* Goal: and (not (@eq (@Tpoint Tn) A B)) (and (not (@eq (@Tpoint Tn) A C)) (and (not (@eq (@Tpoint Tn) B C)) (and (not (@eq (@Tpoint Tn) A P)) (and (not (@eq (@Tpoint Tn) B P)) (and (not (@eq (@Tpoint Tn) C P)) (and (not (@eq (@Tpoint Tn) A Q)) (and (not (@eq (@Tpoint Tn) B Q)) (and (not (@eq (@Tpoint Tn) C Q)) (not (@eq (@Tpoint Tn) P Q)))))))))) *)
  repeat split; auto.
(* Goal: @ex (@Tpoint Tn) (fun X : @Tpoint Tn => and (@Bet Tn A X C) (or (@eq (@Tpoint Tn) X B) (@Out Tn B X P))) *)
  exists X; split; trivial.
(* Goal: False *)
  right; apply bet_out; auto.
(* Goal: False *)
(* Goal: not (@eq (@Tpoint Tn) Y A) *)
(* Goal: @Out Tn A X Y *)
  intro; subst X.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
  apply (two_sides_not_col A C B P HTS1); Col.
Qed.

Lemma out_one_side_1 :
 forall A B C D X,
 ~ Col A B C -> Col A B X -> Out X C D ->
 OS A B C D.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Coplanar Tn A B C D) (_ : not (@Col Tn C A B)) (_ : not (@Col Tn D A B)) (_ : not (@OS Tn A B C D)), @TS Tn A B C D *)
    intros.
    induction (eq_dec_points C D).
(* Goal: False *)
(* Goal: or (@Bet Tn C T D) (@Bet Tn C D T) *)
(* Goal: @OS Tn A C B D *)
      subst D.
      apply one_side_reflexivity.
(* Goal: not (@TS Tn D E X Y) *)
      intro.
(* Goal: False *)
      apply H.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
      Col.
    prolong C X C' C X.
    exists C'.
    assert(TS A B C C').
(* Goal: @TS Tn A B C P *)
(* Goal: @ex (@Tpoint Tn) (fun P : @Tpoint Tn => and (@Cong Tn A P X Y) (and (@Perp Tn A B P A) (@TS Tn A B C P))) *)
      unfold TS.
(* Goal: @TSP Tn A B C Q R *)
      repeat split.
(* Goal: not (@TS Tn D E X Y) *)
        intro.
(* Goal: False *)
        apply H.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
        Col.
(* Goal: not (@TS Tn D E X Y) *)
        intro.
        assert(C'=X).
          eapply (l6_21 A B C D).
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
            assumption.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
            assumption.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
            Col.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
            assumption.
            apply out_col in H1.
            eapply (col_transitivity_1 _ X).
(* Goal: not (@TS Tn D E X Y) *)
              intro.
(* Goal: @Col Tn A B C *)
(* Goal: @Col Tn A B C *)
              treat_equalities.
              Col5.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
              Col.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
            Col.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
            Col.
(* Goal: @Col Tn A B C *)
(* Goal: @Col Tn A B C *)
        treat_equalities.
        unfold Out in H1.
(* Goal: False *)
        tauto.
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T P Q) (@Bet Tn A T B)) *)
      exists X.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
      split; Col.
    assert(TS A B D C').
      eapply (l9_5 _ _ _ _ X).
(* Goal: False *)
(* Goal: not (@Col Tn V A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn U T V)) *)
        apply H5.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
        Col.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
    split; assumption.
Qed.

Lemma out_two_sides_two_sides :
 forall A B X Y P PX,
  A <> PX ->
  Col A B PX ->
  Out PX X P ->
  TS A B P Y ->
  TS A B X Y.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Coplanar Tn A B C D) (_ : not (@Col Tn C A B)) (_ : not (@Col Tn D A B)) (_ : not (@OS Tn A B C D)), @TS Tn A B C D *)
    intros.
    assert(OS A B P X).
      eapply (col_one_side _ PX).
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
        Col.
        unfold TS in H2.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
        spliter.
(* Goal: False *)
        auto.
(* Goal: not (@TS Tn D E X Y) *)
        intro.
(* Goal: False *)
(* Goal: or (@Bet Tn A T B) (@Bet Tn A B T) *)
(* Goal: @OS Tn A C B D *)
        subst B.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
        Col.
(* Goal: @OS Tn A X P Z *)
      apply invert_one_side.
(* Goal: @OS Tn A B P P' *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T P')) *)
      apply out_one_side.
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
        left.
(* Goal: not (@TS Tn D E X Y) *)
        intro.
        unfold TS in H2.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
        spliter.
(* Goal: False *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T P)) *)
(* Goal: @ex (@Tpoint Tn) (fun P : @Tpoint Tn => and (@Cong Tn A P X Y) (and (@Perp Tn A B P A) (@TS Tn A B C P))) *)
        apply H2.
(* Goal: @Col Tn C0 D0 M' *)
(* Goal: @Bet Tn C M D' *)
        ColR.
(* Goal: @Out Tn A Y X *)
      apply l6_6.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
    eapply l9_8_2.
(* Goal: False *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T P)) *)
(* Goal: @ex (@Tpoint Tn) (fun P : @Tpoint Tn => and (@Cong Tn A P X Y) (and (@Perp Tn A B P A) (@TS Tn A B C P))) *)
      apply H2.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
    assumption.
Qed.

Lemma l8_21_bis : forall A B C X Y, X <> Y -> ~ Col C A B -> exists P : Tpoint,
  Cong A P X Y /\ Perp A B P A /\ TS A B C P.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Coplanar Tn A B C D) (_ : not (@Col Tn C A B)) (_ : not (@Col Tn D A B)) (_ : not (@OS Tn A B C D)), @TS Tn A B C D *)
intros.
(* Goal: @ex (@Tpoint Tn) (fun P : @Tpoint Tn => and (@Cong Tn A P X Y) (and (@Perp Tn A B P A) (@TS Tn A B C P))) *)
assert (A <> B) by (intro; subst; Col).
(* Goal: @ex (@Tpoint Tn) (fun P : @Tpoint Tn => and (@Cong Tn A P X Y) (and (@Perp Tn A B P A) (@TS Tn A B C P))) *)
assert(HH:= l8_21 A B C H1).
(* Goal: @ex (@Tpoint Tn) (fun P : @Tpoint Tn => and (@Cong Tn A P X Y) (and (@Perp Tn A B P A) (@TS Tn A B C P))) *)
ex_and HH P.
(* Goal: @ex (@Tpoint Tn) (fun P : @Tpoint Tn => and (@Cong Tn A P X Y) (and (@Perp Tn A B P A) (@TS Tn A B C P))) *)
ex_and H2 T.

(* Goal: @ex (@Tpoint Tn) (fun P : @Tpoint Tn => and (@Cong Tn A P X Y) (and (@Perp Tn A B P A) (@TS Tn A B C P))) *)
assert(TS A B C P).
(* Goal: @TS Tn A B C P *)
(* Goal: @ex (@Tpoint Tn) (fun P : @Tpoint Tn => and (@Cong Tn A P X Y) (and (@Perp Tn A B P A) (@TS Tn A B C P))) *)
unfold TS.
(* Goal: and (not (@eq (@Tpoint Tn) A B)) (and (not (@eq (@Tpoint Tn) A C)) (and (not (@eq (@Tpoint Tn) B C)) (and (not (@eq (@Tpoint Tn) A P)) (and (not (@eq (@Tpoint Tn) B P)) (and (not (@eq (@Tpoint Tn) C P)) (and (not (@eq (@Tpoint Tn) A Q)) (and (not (@eq (@Tpoint Tn) B Q)) (and (not (@eq (@Tpoint Tn) C Q)) (not (@eq (@Tpoint Tn) P Q)))))))))) *)
repeat split; auto.
(* Goal: not (@TS Tn D E X Y) *)
intro.
(* Goal: not (@Col Tn A B P) *)
(* Goal: @Out Tn A P P' *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T P')) *)
apply perp_not_col in H2.
(* Goal: False *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T P)) *)
(* Goal: @ex (@Tpoint Tn) (fun P : @Tpoint Tn => and (@Cong Tn A P X Y) (and (@Perp Tn A B P A) (@TS Tn A B C P))) *)
apply H2.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
Col.
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T P)) *)
(* Goal: @ex (@Tpoint Tn) (fun P : @Tpoint Tn => and (@Cong Tn A P X Y) (and (@Perp Tn A B P A) (@TS Tn A B C P))) *)
exists T.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
split; Col.
(* Goal: @ex (@Tpoint Tn) (fun P : @Tpoint Tn => and (@Cong Tn A P X Y) (and (@Perp Tn A B P A) (@TS Tn A B C P))) *)
assert(P <> A).
(* Goal: not (@eq (@Tpoint Tn) P A) *)
(* Goal: @ex (@Tpoint Tn) (fun P : @Tpoint Tn => and (@Cong Tn A P X Y) (and (@Perp Tn A B P A) (@TS Tn A B C P))) *)
apply perp_distinct in H2.
(* Goal: False *)
tauto.

(* Goal: @ex (@Tpoint Tn) (fun P : @Tpoint Tn => and (@Cong Tn A P X Y) (and (@Perp Tn A B P A) (@TS Tn A B C P))) *)
assert(HH:= segment_construction_2 P A X Y H6).
(* Goal: @ex (@Tpoint Tn) (fun P : @Tpoint Tn => and (@Cong Tn A P X Y) (and (@Perp Tn A B P A) (@TS Tn A B C P))) *)
ex_and HH P'.
(* Goal: @ex (@Tpoint Tn) (fun P : @Tpoint Tn => and (@Cong Tn A P X Y) (and (@Perp Tn A B P A) (@TS Tn A B C P))) *)
exists P'.

(* Goal: and (@Cong Tn A P' X Y) (and (@Perp Tn A B P' A) (@TS Tn A B C P')) *)
assert(Perp A B P' A).
(* Goal: @Perp Tn A B P' A *)
(* Goal: and (@Cong Tn A P' X Y) (and (@Perp Tn A B P' A) (@TS Tn A B C P')) *)
apply perp_sym.
(* Goal: @Perp Tn P' A A B *)
(* Goal: and (@Cong Tn A P' X Y) (and (@Perp Tn A B P' A) (@TS Tn A B C P')) *)
apply perp_left_comm.
(* Goal: @Perp Tn A P' A B *)
(* Goal: and (@Cong Tn A P' X Y) (and (@Perp Tn A B P' A) (@TS Tn A B C P')) *)
apply (perp_col _ P).
(* Goal: not (@TS Tn D E X Y) *)
intro.
(* Goal: False *)
(* Goal: @Perp Tn A P A B *)
(* Goal: @Col Tn A P P' *)
(* Goal: and (@Cong Tn A P' X Y) (and (@Perp Tn A B P' A) (@TS Tn A B C P')) *)
subst P'.
(* Goal: False *)
(* Goal: @Perp Tn A P A B *)
(* Goal: @Col Tn A P P' *)
(* Goal: and (@Cong Tn A P' X Y) (and (@Perp Tn A B P' A) (@TS Tn A B C P')) *)
apply cong_symmetry in H8.
(* Goal: False *)
(* Goal: @Perp Tn A P A B *)
(* Goal: @Col Tn A P P' *)
(* Goal: and (@Cong Tn A P' X Y) (and (@Perp Tn A B P' A) (@TS Tn A B C P')) *)
apply cong_identity in H8.
(* Goal: @TS Tn A B C D *)
contradiction.
(* Goal: @Perp Tn A P A B *)
(* Goal: @Col Tn A P P' *)
(* Goal: and (@Cong Tn A P' X Y) (and (@Perp Tn A B P' A) (@TS Tn A B C P')) *)
Perp.
(* Goal: @Col Tn A P P' *)
(* Goal: and (@Cong Tn A P' X Y) (and (@Perp Tn A B P' A) (@TS Tn A B C P')) *)
induction H7.

(* Goal: @Col Tn A P P' *)
(* Goal: and (@Cong Tn A P' X Y) (and (@Perp Tn A B P' A) (@TS Tn A B C P')) *)
apply bet_col in H7.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
Col.
(* Goal: @Col Tn A P P' *)
(* Goal: and (@Cong Tn A P' X Y) (and (@Perp Tn A B P' A) (@TS Tn A B C P')) *)
apply bet_col in H7.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
Col.

(* Goal: False *)
repeat split;auto.
(* Goal: not (@Col Tn P' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T P')) *)
apply perp_not_col in H9.
(* Goal: not (@TS Tn D E X Y) *)
intro.
(* Goal: False *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T P')) *)
apply H9.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
Col.

(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T P')) *)
assert(OS A B P P').
(* Goal: @OS Tn A B P P' *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T P')) *)
apply out_one_side.
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
left.
(* Goal: not (@Col Tn A B P) *)
(* Goal: @Out Tn A P P' *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T P')) *)
apply perp_not_col in H2.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
assumption.
(* Goal: and (not (@eq (@Tpoint Tn) A B)) (and (not (@eq (@Tpoint Tn) A C)) (and (not (@eq (@Tpoint Tn) B C)) (and (not (@eq (@Tpoint Tn) A P)) (and (not (@eq (@Tpoint Tn) B P)) (and (not (@eq (@Tpoint Tn) C P)) (and (not (@eq (@Tpoint Tn) A Q)) (and (not (@eq (@Tpoint Tn) B Q)) (and (not (@eq (@Tpoint Tn) C Q)) (not (@eq (@Tpoint Tn) P Q)))))))))) *)
repeat split; auto.
(* Goal: not (@eq (@Tpoint Tn) P' A) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T P')) *)
apply perp_distinct in H9.
(* Goal: False *)
tauto.
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T P')) *)
assert(TS A B C P').
(* Goal: @TS Tn A B P C *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T P')) *)
apply l9_2.
(* Goal: False *)
apply(l9_8_2 A B P P' C); auto.
(* Goal: @TS Tn A B P C *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T P')) *)
apply l9_2.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
assumption.
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T P')) *)
unfold TS in H11.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
spliter.
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T P')) *)
ex_and H13 T'.
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T P')) *)
exists T'.
(* Goal: False *)
split; auto.
Qed.

Lemma ts__ncol : forall A B X Y, TS A B X Y -> ~Col A X Y \/ ~Col B X Y.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Coplanar Tn A B C D) (_ : not (@Col Tn C A B)) (_ : not (@Col Tn D A B)) (_ : not (@OS Tn A B C D)), @TS Tn A B C D *)
intros.
(* Goal: or (not (@Col Tn A X Y)) (not (@Col Tn B X Y)) *)
unfold TS in H.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
spliter.
(* Goal: or (not (@Col Tn A X Y)) (not (@Col Tn B X Y)) *)
ex_and H1 T.

(* Goal: or (not (@Col Tn A X Y)) (not (@Col Tn B X Y)) *)
assert(X <> Y).
(* Goal: not (@TS Tn D E X Y) *)
intro.
(* Goal: @Col Tn A B C *)
(* Goal: @Col Tn A B C *)
treat_equalities.
(* Goal: @TS Tn A B C D *)
contradiction.
(* Goal: or (not (@Col Tn A X Y)) (not (@Col Tn B X Y)) *)
induction(eq_dec_points A T).
(* Goal: @Col Tn A B C *)
(* Goal: @Col Tn A B C *)
treat_equalities.
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
right.
(* Goal: not (@TS Tn D E X Y) *)
intro.
(* Goal: False *)
apply H.
(* Goal: @Col Tn C0 D0 M' *)
(* Goal: @Bet Tn C M D' *)
ColR.
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
left.
(* Goal: not (@TS Tn D E X Y) *)
intro.
(* Goal: False *)
apply H.
(* Goal: @Col Tn C0 D0 M' *)
(* Goal: @Bet Tn C M D' *)
ColR.
Qed.

Lemma one_or_two_sides_aux : forall A B C D X,
 ~ Col C A B -> ~ Col D A B -> Col A C X -> Col B D X ->
 TS A B C D \/ OS A B C D.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Coplanar Tn A B C D) (_ : not (@Col Tn C A B)) (_ : not (@Col Tn D A B)) (_ : not (@OS Tn A B C D)), @TS Tn A B C D *)
    intros.
(* Goal: or (@TS Tn A B C D) (not (@TS Tn A B C D)) *)
    assert_diffs.
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
    assert (A <> X) by (intro; subst; Col).
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
    assert (B <> X) by (intro; subst; Col).
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
    assert (~ Col X A B) by (intro; apply H; ColR).
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
    destruct H1 as [|[|]]; destruct H2 as [|[|]].
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
    - right.
(* Goal: @OS Tn A B C D *)
      apply one_side_transitivity with X.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
        apply out_one_side; Col.
(* Goal: False *)
        apply bet_out; auto.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
      apply invert_one_side, out_one_side; Col.
(* Goal: False *)
      apply l6_6, bet_out; auto.
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
    - right.
(* Goal: @OS Tn A B C D *)
      apply one_side_transitivity with X.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
        apply out_one_side; Col.
(* Goal: False *)
        apply bet_out; auto.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
      apply invert_one_side, out_one_side; Col.
      apply bet_out; Between.
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
    - left.
(* Goal: @TS Tn A B C D *)
      apply l9_8_2 with X.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
        repeat split; Col.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
        exists B; split; Col.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
      apply out_one_side; Col.
(* Goal: False *)
      apply l6_6, bet_out; auto.
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
    - right.
(* Goal: @OS Tn A B C D *)
      apply one_side_transitivity with X.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
        apply out_one_side; Col.
        apply l6_6, bet_out; Between.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
      apply invert_one_side, out_one_side; Col.
(* Goal: False *)
      apply l6_6, bet_out; auto.
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
    - right.
(* Goal: @OS Tn A B C D *)
      apply one_side_transitivity with X.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
        apply out_one_side; Col.
        apply l6_6, bet_out; Between.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
      apply invert_one_side, out_one_side; Col.
      apply bet_out; Between.
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
    - left.
(* Goal: @TS Tn A B C D *)
      apply l9_8_2 with X.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
        repeat split; Col.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
        exists B; split; Col.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
      apply out_one_side; Col.
      apply bet_out; Between.
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
    - left.
(* Goal: @TS Tn A B C D *)
      apply l9_2, l9_8_2 with X.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
        repeat split; Col.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
        exists A; split; Col.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
      apply invert_one_side, out_one_side; Col.
(* Goal: False *)
      apply l6_6, bet_out; auto.
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
    - left.
(* Goal: @TS Tn A B C D *)
      apply l9_2, l9_8_2 with X.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
        repeat split; Col.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
        exists A; split; Col.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
      apply invert_one_side, out_one_side; Col.
      apply bet_out; Between.
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
    - right.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
      exists X; repeat split; Col.
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T X)) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn D T X)) *)
        exists A; split; finish.
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn D T X)) *)
      exists B; split; finish.
Qed.

Lemma cop__one_or_two_sides :
 forall A B C D, Coplanar A B C D ->
  ~ Col C A B ->
  ~ Col D A B ->
  TS A B C D \/ OS A B C D.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Coplanar Tn A B C D) (_ : not (@Col Tn C A B)) (_ : not (@Col Tn D A B)) (_ : not (@OS Tn A B C D)), @TS Tn A B C D *)
    intros.
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
    ex_and H X.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
    induction H2; spliter.
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
      destruct (or_bet_out C X D) as [|[|]].
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
        left; repeat split; auto; exists X; split; Col.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
        right; apply out_one_side_1 with X; Col.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
      exfalso; Col.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
    induction H; spliter.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      apply one_or_two_sides_aux with X; assumption.
(* Goal: or (@TS Tn A B C D) (@OS Tn A B C D) *)
    induction (one_or_two_sides_aux A B D C X H1 H0 H H2).
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      left; apply l9_2; assumption.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
    right; apply one_side_symmetry; assumption.
Qed.

Lemma os__coplanar : forall A B C D, OS A B C D -> Coplanar A B C D.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @OS Tn A B C D), @Coplanar Tn A B C D *)
  intros A B C D HOS.
(* Goal: @Coplanar Tn A B C D *)
  assert (HNCol : ~ Col A B C) by (apply one_side_not_col123 with D, HOS).
(* Goal: @Coplanar Tn A B C D *)
  destruct (segment_construction C B B C) as [C'[]].
(* Goal: @Coplanar Tn A B C D *)
  assert (HT : TS A B D C').
(* Goal: @TSP Tn A B C D E' *)
(* Goal: @ex (@Tpoint Tn) (fun Q : @Tpoint Tn => and (@Coplanar Tn A B C Q) (and (@Coplanar Tn D E P Q) (not (@eq (@Tpoint Tn) P Q)))) *)
  { apply l9_8_2 with C; [|assumption].
(* Goal: @TS Tn A B C C' *)
    split; [|split].
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
      Col.
(* Goal: @Col Tn C0 D0 M' *)
(* Goal: @Bet Tn C M D' *)
      intro; apply HNCol; ColR.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
      exists B; split; Col.
  }
(* Goal: @Coplanar Tn A B C D *)
  destruct HT as [HNCol1 [HNCol2 [T []]]].
(* Goal: @Coplanar Tn A B C D *)
  assert (C' <> T) by (intro; treat_equalities; auto).
(* Goal: @Coplanar Tn A B C D *)
  destruct (col_dec T B C) as [|HNCol3].
(* Goal: @Col Tn C0 D0 M' *)
(* Goal: @Bet Tn C M D' *)
    exists B; left; split; ColR.
(* Goal: @Coplanar Tn A B C D *)
  destruct (bet_dec T B A) as [|HOut].
  - apply coplanar_perm_18, ts__coplanar.
(* Goal: @TS Tn B C D A *)
    apply l9_8_2 with T.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
      repeat split; Col; exists B; split; Col.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
    apply out_one_side_1 with C'; Col.
    apply bet_out; Between.
  - apply coplanar_perm_19, ts__coplanar, l9_31; [|apply one_side_symmetry, invert_one_side, HOS].
(* Goal: @OS Tn B C D A *)
    apply one_side_transitivity with T.
(* Goal: @OS Tn B C D T *)
(* Goal: @OS Tn B C T A *)
      apply out_one_side_1 with C'; [intro; apply HNCol3; ColR|Col|apply l6_6, bet_out; Between].
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
      apply out_one_side; Col; apply not_bet_out; Col.
Qed.

Lemma coplanar_trans_1 : forall P Q R A B,
  ~ Col P Q R -> Coplanar P Q R A -> Coplanar P Q R B -> Coplanar Q R A B.
Proof.
(* Goal: forall (P Q R A B : @Tpoint Tn) (_ : not (@Col Tn P Q R)) (_ : @Coplanar Tn P Q R A) (_ : @Coplanar Tn P Q R B), @Coplanar Tn Q R A B *)
  intros P Q R A B HNCol HCop1 HCop2.
(* Goal: @Coplanar Tn Q R A B *)
  destruct (col_dec Q R A).
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
    exists A; left; split; Col.
(* Goal: @Coplanar Tn Q R A B *)
  destruct (col_dec Q R B).
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
    exists B; left; split; Col.
(* Goal: @Coplanar Tn Q R A B *)
  destruct (col_dec Q A B).
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
    exists Q; left; split; Col.
(* Goal: @Coplanar Tn Q R A B *)
  assert (HDij : TS Q R A B \/ OS Q R A B).
(* Goal: @TSP Tn A B C D E' *)
(* Goal: @ex (@Tpoint Tn) (fun Q : @Tpoint Tn => and (@Coplanar Tn A B C Q) (and (@Coplanar Tn D E P Q) (not (@eq (@Tpoint Tn) P Q)))) *)
  { assert (HA : TS Q R P A \/ OS Q R P A) by (apply cop__one_or_two_sides; Col; Cop).
(* Goal: or (@TS Tn Q R A B) (@OS Tn Q R A B) *)
    assert (HB : TS Q R P B \/ OS Q R P B) by (apply cop__one_or_two_sides; Col; Cop).
(* Goal: or (@TS Tn Q R A B) (@OS Tn Q R A B) *)
    destruct HA; destruct HB.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
    - right; apply l9_8_1 with P; apply l9_2; assumption.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
    - left; apply l9_2, l9_8_2 with P; assumption.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
    - left; apply l9_8_2 with P; assumption.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
    - right; apply one_side_transitivity with P; [apply one_side_symmetry|]; assumption.
  }
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
  destruct HDij; [apply ts__coplanar|apply os__coplanar]; assumption.
Qed.

Lemma coplanar_pseudo_trans : forall A B C D P Q R,
  ~ Col P Q R ->
  Coplanar P Q R A ->
  Coplanar P Q R B ->
  Coplanar P Q R C ->
  Coplanar P Q R D ->
  Coplanar A B C D.
Proof.
(* Goal: forall (A B C D P Q R : @Tpoint Tn) (_ : not (@Col Tn P Q R)) (_ : @Coplanar Tn P Q R A) (_ : @Coplanar Tn P Q R B) (_ : @Coplanar Tn P Q R C) (_ : @Coplanar Tn P Q R D), @Coplanar Tn A B C D *)
intros A B C D P Q R HNC HCop1 HCop2 HCop3 HCop4.
(* Goal: @Coplanar Tn A B C D *)
elim (col_dec R A B); intro HRAB.

(* Goal: @TSP Tn A B C D E' *)
(* Goal: @ex (@Tpoint Tn) (fun Q : @Tpoint Tn => and (@Coplanar Tn A B C Q) (and (@Coplanar Tn D E P Q) (not (@eq (@Tpoint Tn) P Q)))) *)
  {
(* Goal: @Coplanar Tn A B C D *)
  elim (col_dec R C D); intro HRCD.

(* Goal: @TSP Tn A B C D E' *)
(* Goal: @ex (@Tpoint Tn) (fun Q : @Tpoint Tn => and (@Coplanar Tn A B C Q) (and (@Coplanar Tn D E P Q) (not (@eq (@Tpoint Tn) P Q)))) *)
    {
    exists R; Col5.
    }

(* Goal: @TSP Tn A B C D E' *)
(* Goal: @ex (@Tpoint Tn) (fun Q : @Tpoint Tn => and (@Coplanar Tn A B C Q) (and (@Coplanar Tn D E P Q) (not (@eq (@Tpoint Tn) P Q)))) *)
    {
(* Goal: @Coplanar Tn A B C D *)
    elim (col_dec Q R C); intro HQRC.

(* Goal: @TSP Tn A B C D E' *)
(* Goal: @ex (@Tpoint Tn) (fun Q : @Tpoint Tn => and (@Coplanar Tn A B C Q) (and (@Coplanar Tn D E P Q) (not (@eq (@Tpoint Tn) P Q)))) *)
      {
(* Goal: @Coplanar Tn A B C D *)
      assert (HQRD : ~ Col Q R D) by (intro; assert_diffs; apply HRCD; ColR).
(* Goal: @Coplanar Tn A B C D *)
      assert (HCop5 := coplanar_trans_1 P Q R D A HNC HCop4 HCop1).
(* Goal: @Coplanar Tn A B C D *)
      assert (HCop6 := coplanar_trans_1 P Q R D B HNC HCop4 HCop2).
(* Goal: @Coplanar Tn A B C D *)
      assert (HCop7 := coplanar_trans_1 P Q R D C HNC HCop4 HCop3).
(* Goal: @Coplanar Tn A B C D *)
      assert (HCop8 := coplanar_trans_1 Q R D C A HQRD HCop7 HCop5).
(* Goal: @Coplanar Tn A B C D *)
      assert (HCop9 := coplanar_trans_1 Q R D C B HQRD HCop7 HCop6).
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
      assert (HRDC : ~ Col R D C) by Col.
(* Goal: @Coplanar Tn A B C D *)
      assert (HCop := coplanar_trans_1 R D C A B HRDC HCop8 HCop9).
(* Goal: @Coplanar Tn A B C D *)
      Cop.
      }

(* Goal: @TSP Tn A B C D E' *)
(* Goal: @ex (@Tpoint Tn) (fun Q : @Tpoint Tn => and (@Coplanar Tn A B C Q) (and (@Coplanar Tn D E P Q) (not (@eq (@Tpoint Tn) P Q)))) *)
      {
(* Goal: @Coplanar Tn A B C D *)
      assert (HCop5 := coplanar_trans_1 P Q R C A HNC HCop3 HCop1).
(* Goal: @Coplanar Tn A B C D *)
      assert (HCop6 := coplanar_trans_1 P Q R C B HNC HCop3 HCop2).
(* Goal: @Coplanar Tn A B C D *)
      assert (HCop7 := coplanar_trans_1 P Q R C D HNC HCop3 HCop4).
(* Goal: @Coplanar Tn A B C D *)
      assert (HCop8 := coplanar_trans_1 Q R C D A HQRC HCop7 HCop5).
(* Goal: @Coplanar Tn A B C D *)
      assert (HCop9 := coplanar_trans_1 Q R C D B HQRC HCop7 HCop6).
(* Goal: @Coplanar Tn A B C D *)
      assert (HCop := coplanar_trans_1 R C D A B HRCD HCop8 HCop9).
(* Goal: @Coplanar Tn A B C D *)
      Cop.
      }
    }
  }

(* Goal: @TSP Tn A B C D E' *)
(* Goal: @ex (@Tpoint Tn) (fun Q : @Tpoint Tn => and (@Coplanar Tn A B C Q) (and (@Coplanar Tn D E P Q) (not (@eq (@Tpoint Tn) P Q)))) *)
  {
(* Goal: @Coplanar Tn A B C D *)
  elim (col_dec Q R A); intro HQRA.

(* Goal: @TSP Tn A B C D E' *)
(* Goal: @ex (@Tpoint Tn) (fun Q : @Tpoint Tn => and (@Coplanar Tn A B C Q) (and (@Coplanar Tn D E P Q) (not (@eq (@Tpoint Tn) P Q)))) *)
    {
(* Goal: @Coplanar Tn A B C D *)
    assert (HQRB : ~ Col Q R B) by (intro; assert_diffs; apply HRAB; ColR).
(* Goal: @Coplanar Tn A B C D *)
    assert (HCop5 := coplanar_trans_1 P Q R B A HNC HCop2 HCop1).
(* Goal: @Coplanar Tn A B C D *)
    assert (HCop6 := coplanar_trans_1 P Q R B C HNC HCop2 HCop3).
(* Goal: @Coplanar Tn A B C D *)
    assert (HCop7 := coplanar_trans_1 P Q R B D HNC HCop2 HCop4).
(* Goal: @Coplanar Tn A B C D *)
    assert (HCop8 := coplanar_trans_1 Q R B A C HQRB HCop5 HCop6).
(* Goal: @Coplanar Tn A B C D *)
    assert (HCop9 := coplanar_trans_1 Q R B A D HQRB HCop5 HCop7).
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
    assert (HRBA : ~ Col R B A) by Col.
(* Goal: @Coplanar Tn A B C D *)
    assert (HCop := coplanar_trans_1 R B A C D HRBA HCop8 HCop9).
(* Goal: @Coplanar Tn A B C D *)
    Cop.
    }

(* Goal: @TSP Tn A B C D E' *)
(* Goal: @ex (@Tpoint Tn) (fun Q : @Tpoint Tn => and (@Coplanar Tn A B C Q) (and (@Coplanar Tn D E P Q) (not (@eq (@Tpoint Tn) P Q)))) *)
    {
(* Goal: @Coplanar Tn A B C D *)
    assert (HCop5 := coplanar_trans_1 P Q R A B HNC HCop1 HCop2).
(* Goal: @Coplanar Tn A B C D *)
    assert (HCop6 := coplanar_trans_1 P Q R A C HNC HCop1 HCop3).
(* Goal: @Coplanar Tn A B C D *)
    assert (HCop7 := coplanar_trans_1 P Q R A D HNC HCop1 HCop4).
(* Goal: @Coplanar Tn A B C D *)
    assert (HCop8 := coplanar_trans_1 Q R A B C HQRA HCop5 HCop6).
(* Goal: @Coplanar Tn A B C D *)
    assert (HCop9 := coplanar_trans_1 Q R A B D HQRA HCop5 HCop7).
(* Goal: @Coplanar Tn A B C D *)
    assert (HCop := coplanar_trans_1 R A B C D HRAB HCop8 HCop9).
(* Goal: @Coplanar Tn A B C D *)
    Cop.
    }
  }
Qed.

Lemma col_cop__cop : forall A B C D E, Coplanar A B C D -> C <> D -> Col C D E -> Coplanar A B C E.
Proof.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
  intros A B C D E HCop HCD HCol.
(* Goal: @Coplanar Tn A B C E *)
  destruct (col_dec D A C).
(* Goal: @Coplanar Tn A B C D *)
    assert (Col A C E) by (apply l6_16_1 with D; Col); Cop.
(* Goal: @Coplanar Tn A B C D *)
  apply coplanar_perm_2, coplanar_trans_1 with D; Cop.
Qed.

Lemma bet_cop__cop : forall A B C D E, Coplanar A B C E -> Bet C D E -> Coplanar A B C D.
Proof.
(* Goal: forall (A B C D E : @Tpoint Tn) (_ : @Coplanar Tn A B C E) (_ : @Bet Tn C D E), @Coplanar Tn A B C D *)
  intros A B C D E HCop HBet.
(* Goal: @Coplanar Tn A B C D *)
  destruct (eq_dec_points C E).
(* Goal: @Coplanar Tn A B C D *)
    treat_equalities; apply HCop.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
  apply col_cop__cop with E; Col.
Qed.

Lemma col2_cop__cop : forall A B C D E F, Coplanar A B C D -> C <> D -> Col C D E -> Col C D F ->
  Coplanar A B E F.
Proof.
(* Goal: forall (A B C D E F : @Tpoint Tn) (_ : @Coplanar Tn A B C D) (_ : not (@eq (@Tpoint Tn) C D)) (_ : @Col Tn C D E) (_ : @Col Tn C D F), @Coplanar Tn A B E F *)
  intros A B C D E F HCop HCD HE HF.
(* Goal: @Coplanar Tn A B E F *)
  destruct (col_dec C D A).
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
    exists A; left; split; Col; apply (col3 C D); assumption.
(* Goal: @Coplanar Tn A B C D *)
  apply coplanar_pseudo_trans with C D A; Cop.
Qed.

Lemma l9_30 : forall A B C D E F P X Y Z,
  ~ Coplanar A B C P -> ~ Col D E F -> Coplanar D E F P ->
  Coplanar A B C X -> Coplanar A B C Y -> Coplanar A B C Z ->
  Coplanar D E F X -> Coplanar D E F Y -> Coplanar D E F Z ->
  Col X Y Z.
Proof.
(* Goal: forall (A B C D E F P X Y Z : @Tpoint Tn) (_ : not (@Coplanar Tn A B C P)) (_ : not (@Col Tn D E F)) (_ : @Coplanar Tn D E F P) (_ : @Coplanar Tn A B C X) (_ : @Coplanar Tn A B C Y) (_ : @Coplanar Tn A B C Z) (_ : @Coplanar Tn D E F X) (_ : @Coplanar Tn D E F Y) (_ : @Coplanar Tn D E F Z), @Col Tn X Y Z *)
  intros A B C D E F P X Y Z HNCop HNCol HP HX1 HY1 HZ1 HX2 HY2 HZ2.
(* Goal: @Col Tn X Y Z *)
  destruct (col_dec X Y Z); [assumption|].
(* Goal: @Col Tn X Y Z *)
  assert (~ Col A B C) by (apply ncop__ncol with P, HNCop).
(* Goal: @eq (@Tpoint Tn) P Q *)
  exfalso.
(* Goal: @Coplanar Tn A B C D *)
  apply HNCop.
(* Goal: @Coplanar Tn A B C D *)
  apply coplanar_pseudo_trans with X Y Z; [assumption|apply coplanar_pseudo_trans with A B C; Cop..|].
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
  apply coplanar_pseudo_trans with D E F; assumption.
Qed.

Lemma cop_per2__col : forall A X Y Z,
  Coplanar A X Y Z ->  A <> Z -> Per X Z A -> Per Y Z A -> Col X Y Z.
Proof.
intros A X Y Z HC HAZ HPer1 HPer2.
(* Goal: @Col Tn A B C *)
(* Goal: @Col Tn A B C *)
destruct HPer1 as [B' [HMid1 HCong1]]; destruct HPer2 as [B [HMid2 HCong2]]; treat_equalities.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
elim (eq_dec_points X Y); intro HXY; treat_equalities; Col.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
elim (eq_dec_points X Z); intro HXZ; treat_equalities; Col.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
elim (eq_dec_points Y Z); intro HYZ; treat_equalities; Col.
destruct HC as [I HC].
elim HC; clear HC; intro HC; try (elim HC; clear HC);
try (intros HCol1 HCol2); try (intro H; destruct H as [HCol1 HCol2]).

(* Goal: @TSP Tn A B C D E' *)
(* Goal: @ex (@Tpoint Tn) (fun Q : @Tpoint Tn => and (@Coplanar Tn A B C Q) (and (@Coplanar Tn D E P Q) (not (@eq (@Tpoint Tn) P Q)))) *)
  {
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
  elim (eq_dec_points X I); intro HXI; treat_equalities; Col.
  assert (HCong3 : Cong I A I B) by (apply l4_17 with Y Z; unfold Midpoint in *; spliter; Cong).
  elim HCol1; clear HCol1; intro HCol1; try (elim HCol1; clear HCol1; intro HCol1).

(* Goal: @TSP Tn A B C D E' *)
(* Goal: @ex (@Tpoint Tn) (fun Q : @Tpoint Tn => and (@Coplanar Tn A B C Q) (and (@Coplanar Tn D E P Q) (not (@eq (@Tpoint Tn) P Q)))) *)
    {
    assert (HLe : Le A X B I).
(* Goal: @TSP Tn A B C D E' *)
(* Goal: @ex (@Tpoint Tn) (fun Q : @Tpoint Tn => and (@Coplanar Tn A B C Q) (and (@Coplanar Tn D E P Q) (not (@eq (@Tpoint Tn) P Q)))) *)
      {
      apply l5_6 with A X A I; Cong.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
      apply l6_13_2; Col.
      split; try (intro; treat_equalities; Col).
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
      split; try (intro; treat_equalities; Col); Col.
      }
    assert (H := le_bet B I A X HLe); destruct H as [X' [HBet HCong4]]; clear HLe.
    assert (HCong5 : Cong A X' B X).
(* Goal: @TSP Tn A B C D E' *)
(* Goal: @ex (@Tpoint Tn) (fun Q : @Tpoint Tn => and (@Coplanar Tn A B C Q) (and (@Coplanar Tn D E P Q) (not (@eq (@Tpoint Tn) P Q)))) *)
      {
      apply five_segment with I I X X'; Cong; Between.
      apply l4_3 with A B; Cong; Between.
      apply l4_3 with B A; Cong; Between.
      }
(* Goal: @Col Tn A B C *)
(* Goal: @Col Tn A B C *)
    assert (H : X = X'); treat_equalities.
(* Goal: @TSP Tn A B C D E' *)
(* Goal: @ex (@Tpoint Tn) (fun Q : @Tpoint Tn => and (@Coplanar Tn A B C Q) (and (@Coplanar Tn D E P Q) (not (@eq (@Tpoint Tn) P Q)))) *)
      {
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
      apply l4_18 with A I; try (intro; treat_equalities); Col.
        apply cong_transitivity with B X; Cong.
      apply l4_3 with A B; Cong; Between.
      }
    assert (H : A = B) by (apply construction_uniqueness with I X X A; Cong; Between);
(* Goal: and (@Col Tn X P Q) (@Bet Tn A X B) *)
    treat_equalities; intuition.
    }

(* Goal: @TSP Tn A B C D E' *)
(* Goal: @ex (@Tpoint Tn) (fun Q : @Tpoint Tn => and (@Coplanar Tn A B C Q) (and (@Coplanar Tn D E P Q) (not (@eq (@Tpoint Tn) P Q)))) *)
    {
    assert (H := segment_construction B I I X); destruct H as [X' [HBet HCong4]].
    assert (HCong5 : Cong A X' B X).
(* Goal: @TSP Tn A B C D E' *)
(* Goal: @ex (@Tpoint Tn) (fun Q : @Tpoint Tn => and (@Coplanar Tn A B C Q) (and (@Coplanar Tn D E P Q) (not (@eq (@Tpoint Tn) P Q)))) *)
      {
      apply five_segment with X X' I I; Cong; Between.
      }
(* Goal: @Col Tn A B C *)
(* Goal: @Col Tn A B C *)
    assert (H : X = X'); treat_equalities.
(* Goal: @TSP Tn A B C D E' *)
(* Goal: @ex (@Tpoint Tn) (fun Q : @Tpoint Tn => and (@Coplanar Tn A B C Q) (and (@Coplanar Tn D E P Q) (not (@eq (@Tpoint Tn) P Q)))) *)
      {
      apply l4_18 with A I; try (intro; treat_equalities); Col; Cong.
      apply cong_transitivity with B X; Cong.
      }
    assert (H : A = B) by (apply construction_uniqueness with X I I A; Cong; Between);
(* Goal: and (@Col Tn X P Q) (@Bet Tn A X B) *)
    treat_equalities; intuition.
    }

(* Goal: @TSP Tn A B C D E' *)
(* Goal: @ex (@Tpoint Tn) (fun Q : @Tpoint Tn => and (@Coplanar Tn A B C Q) (and (@Coplanar Tn D E P Q) (not (@eq (@Tpoint Tn) P Q)))) *)
    {
    assert (H := segment_construction I B A X); destruct H as [X' [HBet HCong4]].
    assert (HCong5 : Cong X B X' A).
(* Goal: @TSP Tn A B C D E' *)
(* Goal: @ex (@Tpoint Tn) (fun Q : @Tpoint Tn => and (@Coplanar Tn A B C Q) (and (@Coplanar Tn D E P Q) (not (@eq (@Tpoint Tn) P Q)))) *)
      {
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
      apply five_segment with I I A B; Cong; intro; treat_equalities; Col.
      }
(* Goal: @Col Tn A B C *)
(* Goal: @Col Tn A B C *)
    assert (H : X = X'); treat_equalities.
(* Goal: @TSP Tn A B C D E' *)
(* Goal: @ex (@Tpoint Tn) (fun Q : @Tpoint Tn => and (@Coplanar Tn A B C Q) (and (@Coplanar Tn D E P Q) (not (@eq (@Tpoint Tn) P Q)))) *)
      {
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
      apply l4_18 with A I; try (intro; treat_equalities); Col.
        apply cong_transitivity with B X; Cong.
      apply l2_11 with A B; Cong.
      }
    assert (H : A = B) by (apply between_cong_2 with I X; Col).
(* Goal: and (@Col Tn X P Q) (@Bet Tn A X B) *)
    treat_equalities; intuition.
    }
  }

(* Goal: @TSP Tn A B C D E' *)
(* Goal: @ex (@Tpoint Tn) (fun Q : @Tpoint Tn => and (@Coplanar Tn A B C Q) (and (@Coplanar Tn D E P Q) (not (@eq (@Tpoint Tn) P Q)))) *)
  {
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
  elim (eq_dec_points Y I); intro HYI; treat_equalities; Col.
  assert (HCong3 : Cong I A I B) by (apply l4_17 with X Z; unfold Midpoint in *; spliter; Cong).
  elim HCol1; clear HCol1; intro HCol1; try (elim HCol1; clear HCol1; intro HCol1).

(* Goal: @TSP Tn A B C D E' *)
(* Goal: @ex (@Tpoint Tn) (fun Q : @Tpoint Tn => and (@Coplanar Tn A B C Q) (and (@Coplanar Tn D E P Q) (not (@eq (@Tpoint Tn) P Q)))) *)
    {
    assert (HLe : Le A Y B I).
(* Goal: @TSP Tn A B C D E' *)
(* Goal: @ex (@Tpoint Tn) (fun Q : @Tpoint Tn => and (@Coplanar Tn A B C Q) (and (@Coplanar Tn D E P Q) (not (@eq (@Tpoint Tn) P Q)))) *)
      {
      apply l5_6 with A Y A I; Cong.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
      apply l6_13_2; Col.
      split; try (intro; treat_equalities; Col).
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
      split; try (intro; treat_equalities; Col); Col.
      }
    assert (H := le_bet B I A Y HLe); destruct H as [Y' [HBet HCong4]]; clear HLe.
    assert (HCong5 : Cong A Y' B Y).
(* Goal: @TSP Tn A B C D E' *)
(* Goal: @ex (@Tpoint Tn) (fun Q : @Tpoint Tn => and (@Coplanar Tn A B C Q) (and (@Coplanar Tn D E P Q) (not (@eq (@Tpoint Tn) P Q)))) *)
      {
      apply five_segment with I I Y Y'; Cong; Between.
      apply l4_3 with A B; Cong; Between.
      apply l4_3 with B A; Cong; Between.
      }
(* Goal: @Col Tn A B C *)
(* Goal: @Col Tn A B C *)
    assert (H : Y = Y'); treat_equalities.
(* Goal: @TSP Tn A B C D E' *)
(* Goal: @ex (@Tpoint Tn) (fun Q : @Tpoint Tn => and (@Coplanar Tn A B C Q) (and (@Coplanar Tn D E P Q) (not (@eq (@Tpoint Tn) P Q)))) *)
      {
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
      apply l4_18 with A I; try (intro; treat_equalities); Col.
        apply cong_transitivity with B Y; Cong.
      apply l4_3 with A B; Cong; Between.
      }
    assert (H : A = B) by (apply construction_uniqueness with I Y Y A; Cong; Between);
(* Goal: and (@Col Tn X P Q) (@Bet Tn A X B) *)
    treat_equalities; intuition.
    }

(* Goal: @TSP Tn A B C D E' *)
(* Goal: @ex (@Tpoint Tn) (fun Q : @Tpoint Tn => and (@Coplanar Tn A B C Q) (and (@Coplanar Tn D E P Q) (not (@eq (@Tpoint Tn) P Q)))) *)
    {
    assert (H := segment_construction B I I Y); destruct H as [Y' [HBet HCong4]].
    assert (HCong5 : Cong A Y' B Y).
(* Goal: @TSP Tn A B C D E' *)
(* Goal: @ex (@Tpoint Tn) (fun Q : @Tpoint Tn => and (@Coplanar Tn A B C Q) (and (@Coplanar Tn D E P Q) (not (@eq (@Tpoint Tn) P Q)))) *)
      {
      apply five_segment with Y Y' I I; Cong; Between.
      }
(* Goal: @Col Tn A B C *)
(* Goal: @Col Tn A B C *)
    assert (H : Y = Y'); treat_equalities.
(* Goal: @TSP Tn A B C D E' *)
(* Goal: @ex (@Tpoint Tn) (fun Q : @Tpoint Tn => and (@Coplanar Tn A B C Q) (and (@Coplanar Tn D E P Q) (not (@eq (@Tpoint Tn) P Q)))) *)
      {
      apply l4_18 with A I; try (intro; treat_equalities); Col; Cong.
      apply cong_transitivity with B Y; Cong.
      }
    assert (H : A = B) by (apply construction_uniqueness with Y I I A; Cong; Between);
(* Goal: and (@Col Tn X P Q) (@Bet Tn A X B) *)
    treat_equalities; intuition.
    }

(* Goal: @TSP Tn A B C D E' *)
(* Goal: @ex (@Tpoint Tn) (fun Q : @Tpoint Tn => and (@Coplanar Tn A B C Q) (and (@Coplanar Tn D E P Q) (not (@eq (@Tpoint Tn) P Q)))) *)
    {
    assert (H := segment_construction I B A Y); destruct H as [Y' [HBet HCong4]].
    assert (HCong5 : Cong Y B Y' A).
(* Goal: @TSP Tn A B C D E' *)
(* Goal: @ex (@Tpoint Tn) (fun Q : @Tpoint Tn => and (@Coplanar Tn A B C Q) (and (@Coplanar Tn D E P Q) (not (@eq (@Tpoint Tn) P Q)))) *)
      {
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
      apply five_segment with I I A B; Cong; intro; treat_equalities; Col.
      }
(* Goal: @Col Tn A B C *)
(* Goal: @Col Tn A B C *)
    assert (H : Y = Y'); treat_equalities.
(* Goal: @TSP Tn A B C D E' *)
(* Goal: @ex (@Tpoint Tn) (fun Q : @Tpoint Tn => and (@Coplanar Tn A B C Q) (and (@Coplanar Tn D E P Q) (not (@eq (@Tpoint Tn) P Q)))) *)
      {
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
      apply l4_18 with A I; try (intro; treat_equalities); Col.
        apply cong_transitivity with B Y; Cong.
      apply l2_11 with A B; Cong.
      }
    assert (H : A = B) by (apply between_cong_2 with I Y; Col).
(* Goal: and (@Col Tn X P Q) (@Bet Tn A X B) *)
    treat_equalities; intuition.
    }
  }

(* Goal: @TSP Tn A B C D E' *)
(* Goal: @ex (@Tpoint Tn) (fun Q : @Tpoint Tn => and (@Coplanar Tn A B C Q) (and (@Coplanar Tn D E P Q) (not (@eq (@Tpoint Tn) P Q)))) *)
  {
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
  elim (eq_dec_points Z I); intro HZI; treat_equalities; Col.
  assert (HCong3 : Cong I A I B) by (apply l4_17 with X Y; unfold Midpoint in *; spliter; Cong).
  assert (H := l7_20 I A B). elim H; clear H; try intro H;
(* Goal: and (@Col Tn X P Q) (@Bet Tn A X B) *)
  treat_equalities; assert_diffs; assert_cols; try ColR; Cong; intuition.
  }
Qed.

Lemma cop_perp2__col : forall X Y Z A B,
 Coplanar A B Y Z -> Perp X Y A B -> Perp X Z A B -> Col X Y Z.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Coplanar Tn A B C D) (_ : not (@Col Tn C A B)) (_ : not (@Col Tn D A B)) (_ : not (@OS Tn A B C D)), @TS Tn A B C D *)
    intros.
    induction(col_dec A B X).
      induction(eq_dec_points X A).
(* Goal: False *)
(* Goal: and (@Bet Tn A P B) (and (not (@Col Tn X Y A)) (not (@Col Tn X Y B))) *)
(* Goal: forall _ : and (@Bet Tn A P B) (and (not (@Col Tn X Y A)) (not (@Col Tn X Y B))), @TS Tn X Y A B *)
        subst A.
        assert(X <> B).
          apply perp_distinct in H0.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
          spliter.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
          assumption.
        apply perp_right_comm in H0.
        apply perp_perp_in in H0.
        apply perp_in_comm in H0.
        apply perp_in_per in H0.
        apply perp_right_comm in H1.
        apply perp_perp_in in H1.
        apply perp_in_comm in H1.
        apply perp_in_per in H1.
(* Goal: @Col Tn X A B *)
        apply col_permutation_2.
        apply cop_per2__col with B.
(* Goal: @Coplanar Tn A B C D *)
          Cop.
(* Goal: False *)
          auto.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
          assumption.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
          assumption.
      assert(Perp A X X Y ).
        eapply perp_col.
(* Goal: False *)
          auto.
(* Goal: @Perp Tn A B P' A *)
(* Goal: and (@Cong Tn A P' X Y) (and (@Perp Tn A B P' A) (@TS Tn A B C P')) *)
          apply perp_sym.
(* Goal: False *)
(* Goal: @Out Tn C T D *)
(* Goal: @OS Tn A C B D *)
          apply H0.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
      assert(Perp A X X Z).
        eapply perp_col.
(* Goal: False *)
          auto.
(* Goal: @Perp Tn A B P' A *)
(* Goal: and (@Cong Tn A P' X Y) (and (@Perp Tn A B P' A) (@TS Tn A B C P')) *)
          apply perp_sym.
(* Goal: @Col Tn A P Q *)
          apply H1.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: @Col Tn X A B *)
      apply col_permutation_2.
      apply cop_per2__col with A.
(* Goal: @Coplanar Tn A B C D *)
        assert_diffs; apply coplanar_perm_12, col_cop__cop with B; Cop.
(* Goal: False *)
        auto.
        apply perp_in_per.
        apply perp_in_comm.
        apply perp_perp_in.
(* Goal: @Perp Tn A B P' A *)
(* Goal: and (@Cong Tn A P' X Y) (and (@Perp Tn A B P' A) (@TS Tn A B C P')) *)
        apply perp_sym.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
      apply perp_in_per.
      apply perp_in_comm.
      apply perp_perp_in.
(* Goal: @Perp Tn A B P' A *)
(* Goal: and (@Cong Tn A P' X Y) (and (@Perp Tn A B P' A) (@TS Tn A B C P')) *)
      apply perp_sym.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
(* Goal: and (not (@Col Tn X A B)) (and (not (@Col Tn Y A B)) (@ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn X T Y)))) *)
(* Goal: @Out Tn A X Y *)
    assert(HH0:=H0).
    assert(HH1:=H1).
    unfold Perp in H0.
    unfold Perp in H1.
    ex_and H0 Y0.
    ex_and H1 Z0.
    assert(HH2:=H0).
    assert(HH3:=H3).
    apply perp_in_col in H0.
    apply perp_in_col in H3.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
    spliter.
    assert(Perp X Y0 A B).
      eapply perp_col.
(* Goal: not (@TS Tn D E X Y) *)
        intro.
        subst Y0.
(* Goal: @TS Tn A B C D *)
        contradiction.
        apply HH0.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
    assert(Perp X Z0 A B).
      eapply perp_col.
(* Goal: not (@TS Tn D E X Y) *)
        intro.
        subst Z0.
(* Goal: @TS Tn A B C D *)
        contradiction.
        apply HH1.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
    assert(Y0 = Z0).
      eapply l8_18_uniqueness.
(* Goal: False *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T P)) *)
(* Goal: @ex (@Tpoint Tn) (fun P : @Tpoint Tn => and (@Cong Tn A P X Y) (and (@Perp Tn A B P A) (@TS Tn A B C P))) *)
        apply H2.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: @Perp Tn A B P' A *)
(* Goal: and (@Cong Tn A P' X Y) (and (@Perp Tn A B P' A) (@TS Tn A B C P')) *)
        apply perp_sym.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
        assumption.
(* Goal: @Perp Tn A B P' A *)
(* Goal: and (@Cong Tn A P' X Y) (and (@Perp Tn A B P' A) (@TS Tn A B C P')) *)
      apply perp_sym.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      assumption.
    subst Z0.
    apply (col_transitivity_1 _ Y0).
(* Goal: not (@TS Tn D E X Y) *)
      intro.
      subst Y0.
(* Goal: @TS Tn A B C D *)
      contradiction.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
      Col.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
    Col.
Qed.

Lemma two_sides_dec : forall A B C D, TS A B C D \/ ~ TS A B C D.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Coplanar Tn A B C D) (_ : not (@Col Tn C A B)) (_ : not (@Col Tn D A B)) (_ : not (@OS Tn A B C D)), @TS Tn A B C D *)
    intros.
(* Goal: or (@Coplanar Tn A B C D) (not (@Coplanar Tn A B C D)) *)
    destruct (col_dec C A B).
(* Goal: @TS Tn A B C D *)
      right; intros []; contradiction.
(* Goal: or (@TS Tn A B C D) (not (@TS Tn A B C D)) *)
    destruct (col_dec D A B) as [|HNCol].
(* Goal: @TS Tn A B C D *)
      right; intros [HN []]; contradiction.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
    destruct (l8_18_existence A B C) as [C0 [HCol1 HPerp1]]; Col.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
    destruct (l8_18_existence A B D) as [D0 [HCol2 HPerp2]]; Col.
(* Goal: or (@TS Tn A B C D) (not (@TS Tn A B C D)) *)
    assert_diffs.
(* Goal: or (@TS Tn A B C D) (not (@TS Tn A B C D)) *)
    destruct (midpoint_existence C0 D0) as [M].
(* Goal: or (@TS Tn A B C D) (not (@TS Tn A B C D)) *)
    assert (Col M A B).
(* Goal: @Col Tn M A B *)
(* Goal: or (@TS Tn A B C D) (not (@TS Tn A B C D)) *)
      destruct (eq_dec_points C0 D0); [treat_equalities; Col|ColR].
(* Goal: False *)
    destruct (l6_11_existence D0 C0 C D) as [D' []]; auto.
(* Goal: or (@TS Tn A B C D) (not (@TS Tn A B C D)) *)
    destruct (bet_dec C M D') as [|HNBet].
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
    { left; apply l9_2, l9_5 with D' D0; Col.
(* Goal: and (not (@eq (@Tpoint Tn) A B)) (and (not (@eq (@Tpoint Tn) A C)) (and (not (@eq (@Tpoint Tn) B C)) (and (not (@eq (@Tpoint Tn) A P)) (and (not (@eq (@Tpoint Tn) B P)) (and (not (@eq (@Tpoint Tn) C P)) (and (not (@eq (@Tpoint Tn) A Q)) (and (not (@eq (@Tpoint Tn) B Q)) (and (not (@eq (@Tpoint Tn) C Q)) (not (@eq (@Tpoint Tn) P Q)))))))))) *)
      repeat split; auto.
(* Goal: @Col Tn C0 D0 M' *)
(* Goal: @Bet Tn C M D' *)
        intro; apply HNCol; ColR.
      exists M; split; Between.
    }
(* Goal: or (@TS Tn A B C D) (not (@TS Tn A B C D)) *)
    right; intro HTS.
(* Goal: False *)
    apply HNBet.
(* Goal: @Bet Tn C M D' *)
    assert (HTS1 : TS A B D' C).
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
      apply l9_5 with D D0; [apply l9_2|Col|apply l6_6]; assumption.
(* Goal: @Bet Tn C M D' *)
    destruct (eq_dec_points C0 D0).
(* Goal: @Col Tn A B C *)
(* Goal: @Col Tn A B C *)
    { treat_equalities.
(* Goal: @Bet Tn C M D' *)
      assert (Col M C D) by (apply cop_perp2__col with A B; Perp; Cop).
(* Goal: False *)
      destruct (distinct A B M); auto.
      - apply col_two_sides_bet with A.
(* Goal: @Col Tn C0 D0 M' *)
(* Goal: @Bet Tn C M D' *)
          ColR.
(* Goal: @TS Tn M A C D' *)
        apply invert_two_sides, col_two_sides with B; Col; apply l9_2, HTS1.
      - apply col_two_sides_bet with B.
(* Goal: @Col Tn C0 D0 M' *)
(* Goal: @Bet Tn C M D' *)
          ColR.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
        apply invert_two_sides, col_two_sides with A; Col.
(* Goal: @TS Tn B A C D' *)
        apply l9_2, invert_two_sides, HTS1.
    }
(* Goal: @Bet Tn C M D' *)
    destruct HTS1 as [HNCol' [_ [M' []]]].
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
    destruct (l8_22 C0 D0 C D' M') as [_ []]; Between; Cong; Col.
(* Goal: False *)
      apply perp_per_1, perp_col2 with A B; auto.
(* Goal: False *)
      assert_diffs; apply per_col with D; Col; apply perp_per_1, perp_col2 with A B; auto.
(* Goal: @Col Tn C0 D0 M' *)
(* Goal: @Bet Tn C M D' *)
      ColR.
    replace M with M'; Between.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
    apply (l7_17 C0 D0); assumption.
Qed.

Lemma cop__not_two_sides_one_side :
 forall A B C D,
  Coplanar A B C D ->
  ~ Col C A B ->
  ~ Col D A B ->
  ~ TS A B C D ->
  OS A B C D.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Coplanar Tn A B C D) (_ : not (@Col Tn C A B)) (_ : not (@Col Tn D A B)) (_ : not (@OS Tn A B C D)), @TS Tn A B C D *)
    intros.
(* Goal: False *)
    induction (cop__one_or_two_sides A B C D); auto.
(* Goal: @TS Tn A B C D *)
    contradiction.
Qed.

Lemma cop__not_one_side_two_sides :
 forall A B C D,
  Coplanar A B C D ->
  ~ Col C A B ->
  ~ Col D A B ->
  ~ OS A B C D ->
  TS A B C D.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Coplanar Tn A B C D) (_ : not (@Col Tn C A B)) (_ : not (@Col Tn D A B)) (_ : not (@OS Tn A B C D)), @TS Tn A B C D *)
    intros.
(* Goal: False *)
    induction (cop__one_or_two_sides A B C D); auto.
(* Goal: @TS Tn A B C D *)
    contradiction.
Qed.

Lemma one_side_dec : forall A B C D,
 OS A B C D \/ ~ OS A B C D.
Proof.
(* Goal: forall A B C D : @Tpoint Tn, @ex (@Tpoint Tn) (fun E : @Tpoint Tn => @ex (@Tpoint Tn) (fun F : @Tpoint Tn => and (@Coplanar Tn A B C E) (and (@Coplanar Tn A B C F) (not (@Col Tn D E F))))) *)
  intros A B C D.
(* Goal: or (@OS Tn A B C D) (not (@OS Tn A B C D)) *)
  destruct (col_dec A B D).
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
    right; intro Habs; apply (one_side_not_col124 A B C D); assumption.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
  destruct (l9_10 A B D) as [D']; Col.
(* Goal: or (@OS Tn A B C D) (not (@OS Tn A B C D)) *)
  destruct (two_sides_dec A B C D') as [|HNTS].
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
    left; apply l9_8_1 with D'; assumption.
(* Goal: not (@TS Tn D E X Y) *)
  right; intro.
(* Goal: False *)
  apply HNTS, l9_8_2 with D.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
    assumption.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
  apply one_side_symmetry; assumption.
Qed.

Lemma cop_dec : forall A B C D,
 Coplanar A B C D \/ ~ Coplanar A B C D.
Proof.
(* Goal: forall A B C D : @Tpoint Tn, @ex (@Tpoint Tn) (fun E : @Tpoint Tn => @ex (@Tpoint Tn) (fun F : @Tpoint Tn => and (@Coplanar Tn A B C E) (and (@Coplanar Tn A B C F) (not (@Col Tn D E F))))) *)
  intros A B C D.
(* Goal: or (@Coplanar Tn A B C D) (not (@Coplanar Tn A B C D)) *)
  destruct (col_dec C A B).
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
    left; exists C; left; split; Col.
(* Goal: or (@Coplanar Tn A B C D) (not (@Coplanar Tn A B C D)) *)
  destruct (col_dec D A B).
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
    left; exists D; left; split; Col.
(* Goal: or (@Coplanar Tn A B C D) (not (@Coplanar Tn A B C D)) *)
  destruct (two_sides_dec A B C D).
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
    left; apply ts__coplanar; assumption.
(* Goal: or (@Coplanar Tn A B C D) (not (@Coplanar Tn A B C D)) *)
  destruct (one_side_dec A B C D).
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
    left; apply os__coplanar; assumption.
(* Goal: False *)
  right; intro; destruct (cop__one_or_two_sides A B C D); auto.
Qed.

Lemma ex_diff_cop : forall A B C D, exists E,
  Coplanar A B C E /\ D <> E.
Proof.
(* Goal: forall A B C D : @Tpoint Tn, @ex (@Tpoint Tn) (fun E : @Tpoint Tn => @ex (@Tpoint Tn) (fun F : @Tpoint Tn => and (@Coplanar Tn A B C E) (and (@Coplanar Tn A B C F) (not (@Col Tn D E F))))) *)
  intros A B C D.
(* Goal: @ex (@Tpoint Tn) (fun E : @Tpoint Tn => and (@Coplanar Tn A B C E) (not (@eq (@Tpoint Tn) D E))) *)
  destruct (eq_dec_points A D); [destruct (eq_dec_points B D); subst|].
  - destruct (another_point D) as [E]; exists E; split; Cop.
  - exists B; split; Cop.
  - exists A; split; Cop.
Qed.

Lemma ex_ncol_cop : forall A B C D E, D <> E ->
  exists F, Coplanar A B C F /\ ~ Col D E F.
Proof.
(* Goal: forall (A B C D E : @Tpoint Tn) (_ : not (@eq (@Tpoint Tn) D E)), @ex (@Tpoint Tn) (fun F : @Tpoint Tn => and (@Coplanar Tn A B C F) (not (@Col Tn D E F))) *)
  intros A B C D E HDE.
(* Goal: @ex (@Tpoint Tn) (fun F : @Tpoint Tn => and (@Coplanar Tn A B C F) (not (@Col Tn D E F))) *)
  destruct (col_dec A B C) as [|HNCol].
(* Goal: @Coplanar Tn A B C D *)
    destruct (not_col_exists D E HDE) as [F]; exists F; split; Cop.
(* Goal: @ex (@Tpoint Tn) (fun F : @Tpoint Tn => and (@Coplanar Tn A B C F) (not (@Col Tn D E F))) *)
  destruct (col_dec D E A); [destruct (col_dec D E B)|].
  - exists C; split; Cop.
(* Goal: @Col Tn C0 D0 M' *)
(* Goal: @Bet Tn C M D' *)
    intro; apply HNCol; ColR.
  - exists B; split; Cop.
  - exists A; split; Cop.
Qed.

Lemma ex_ncol_cop2 : forall A B C D, exists E F,
  Coplanar A B C E /\ Coplanar A B C F /\ ~ Col D E F.
Proof.
(* Goal: forall A B C D : @Tpoint Tn, @ex (@Tpoint Tn) (fun E : @Tpoint Tn => @ex (@Tpoint Tn) (fun F : @Tpoint Tn => and (@Coplanar Tn A B C E) (and (@Coplanar Tn A B C F) (not (@Col Tn D E F))))) *)
  intros A B C D.
(* Goal: @ex (@Tpoint Tn) (fun E : @Tpoint Tn => @ex (@Tpoint Tn) (fun F : @Tpoint Tn => and (@Coplanar Tn A B C E) (and (@Coplanar Tn A B C F) (not (@Col Tn D E F))))) *)
  destruct (ex_diff_cop A B C D) as [E [HE HDE]].
(* Goal: @ex (@Tpoint Tn) (fun E : @Tpoint Tn => @ex (@Tpoint Tn) (fun F : @Tpoint Tn => and (@Coplanar Tn A B C E) (and (@Coplanar Tn A B C F) (not (@Col Tn D E F))))) *)
  destruct (ex_ncol_cop A B C D E HDE) as [F []].
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
  exists E, F; repeat split; assumption.
Qed.

Lemma cop4__col : forall A1 A2 A3 B1 B2 B3 P Q R, ~ Coplanar A1 A2 A3 B1 -> ~ Col B1 B2 B3 ->
  Coplanar A1 A2 A3 P -> Coplanar B1 B2 B3 P ->
  Coplanar A1 A2 A3 Q -> Coplanar B1 B2 B3 Q ->
  Coplanar A1 A2 A3 R -> Coplanar B1 B2 B3 R ->
  Col P Q R.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Coplanar Tn A B C D) (_ : not (@Col Tn C A B)) (_ : not (@Col Tn D A B)) (_ : not (@OS Tn A B C D)), @TS Tn A B C D *)
  intros A1 A2 A3 B1 B2 B3 P Q R HNCop HNCol; intros.
(* Goal: @Col Tn P Q R *)
  assert (~ Col A1 A2 A3) by (apply ncop__ncol with B1, HNCop).
(* Goal: @Col Tn P Q R *)
  destruct (col_dec P Q R); trivial.
(* Goal: @Coplanar Tn A B C D *)
  exfalso; apply HNCop.
  apply coplanar_pseudo_trans with P Q R;
(* Goal: @Coplanar Tn A B C D *)
  [assumption|apply coplanar_pseudo_trans with A1 A2 A3; Cop..|].
(* Goal: @Coplanar Tn A B C D *)
  apply coplanar_pseudo_trans with B1 B2 B3; Cop.
Qed.

Lemma col_cop2__cop : forall A B C U V P, U <> V ->
  Coplanar A B C U -> Coplanar A B C V -> Col U V P ->
  Coplanar A B C P.
Proof.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
  intros A B C U V P HUV HU HV HCol.
(* Goal: @Coplanar Tn A B C P *)
  destruct (col_dec A B C) as [HCol1|HNCol].
(* Goal: @Coplanar Tn A B C P *)
(* Goal: @Coplanar Tn A B C P *)
    apply col__coplanar, HCol1.
(* Goal: @Coplanar Tn A B C P *)
  revert dependent C.
(* Goal: forall (C : @Tpoint Tn) (_ : @Coplanar Tn A B C U) (_ : @Coplanar Tn A B C V) (_ : not (@Col Tn A B C)), @Coplanar Tn A B C P *)
  revert A B.
  assert (Haux : forall A B C, ~ Col A B C -> ~ Col U A B ->
  Coplanar A B C U -> Coplanar A B C V -> Coplanar A B C P).
(* Goal: @TSP Tn A B C D E' *)
(* Goal: @ex (@Tpoint Tn) (fun Q : @Tpoint Tn => and (@Coplanar Tn A B C Q) (and (@Coplanar Tn D E P Q) (not (@eq (@Tpoint Tn) P Q)))) *)
  { intros A B C HNCol HNCol' HU HV.
(* Goal: @Coplanar Tn A B C D *)
    apply coplanar_trans_1 with U; [Cop..|].
(* Goal: False *)
    apply coplanar_perm_12, col_cop__cop with V; auto.
(* Goal: @Coplanar Tn A B C D *)
    apply coplanar_pseudo_trans with A B C; Cop.
  }
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
  intros A B C HU HV HNCol.
(* Goal: @Coplanar Tn A B C P *)
  destruct (col_dec U A B); [destruct (col_dec U A C)|].
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
  - apply coplanar_perm_12, Haux; Cop; Col.
(* Goal: @Col Tn C0 D0 M' *)
(* Goal: @Bet Tn C M D' *)
    intro; apply HNCol; destruct (eq_dec_points U A); [subst|]; ColR.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
  - apply coplanar_perm_2, Haux; Cop; Col.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
  - apply Haux; assumption.
Qed.

Lemma bet_cop2__cop : forall A B C U V W,
  Coplanar A B C U -> Coplanar A B C W -> Bet U V W -> Coplanar A B C V.
Proof.
(* Goal: forall (A B C U V W : @Tpoint Tn) (_ : @Coplanar Tn A B C U) (_ : @Coplanar Tn A B C W) (_ : @Bet Tn U V W), @Coplanar Tn A B C V *)
  intros A B C U V W HU HW HBet.
(* Goal: @Coplanar Tn A B C V *)
  destruct (eq_dec_points U W).
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
    treat_equalities; assumption.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
    apply col_cop2__cop with U W; Col.
Qed.

Lemma col2_cop2__eq : forall A B C U V P Q, ~ Coplanar A B C U -> U <> V ->
  Coplanar A B C P -> Coplanar A B C Q -> Col U V P -> Col U V Q ->
  P = Q.
Proof.
(* Goal: forall (A B C D : @Tpoint Tn) (_ : @Coplanar Tn A B C D) (_ : not (@Col Tn C A B)) (_ : not (@Col Tn D A B)) (_ : not (@OS Tn A B C D)), @TS Tn A B C D *)
  intros A B C U V P Q HNCop; intros.
(* Goal: @eq (@Tpoint Tn) P Q *)
  destruct (eq_dec_points P Q); [assumption|].
(* Goal: @eq (@Tpoint Tn) P Q *)
  exfalso.
(* Goal: @Col Tn C0 D0 M' *)
(* Goal: @Bet Tn C M D' *)
  apply HNCop, col_cop2__cop with P Q; ColR.
Qed.

Lemma cong3_cop2__col : forall A B C P Q,
  Coplanar A B C P -> Coplanar A B C Q ->
  P <> Q -> Cong A P A Q -> Cong B P B Q -> Cong C P C Q ->
  Col A B C.
Proof.
(* Goal: forall (A B C P Q : @Tpoint Tn) (_ : @Coplanar Tn A B C P) (_ : @Coplanar Tn A B C Q) (_ : not (@eq (@Tpoint Tn) P Q)) (_ : @Cong Tn A P A Q) (_ : @Cong Tn B P B Q) (_ : @Cong Tn C P C Q), @Col Tn A B C *)
  intros A B C P Q HP HQ HPQ HA HB HC.
(* Goal: @Col Tn A B C *)
  destruct (col_dec A B C); [assumption|].
(* Goal: @Col Tn A B C *)
  destruct (midpoint_existence P Q) as [M HMid].
(* Goal: @Col Tn A B C *)
  assert (Per A M P) by (exists Q; Cong).
(* Goal: @Col Tn A B C *)
  assert (Per B M P) by (exists Q; Cong).
(* Goal: @Col Tn A B C *)
  assert (Per C M P) by (exists Q; Cong).
(* Goal: @Col Tn A B C *)
  elim (eq_dec_points A M); intro HAM.
(* Goal: @Col Tn A B C *)
(* Goal: @Col Tn A B C *)
    treat_equalities.
(* Goal: @Coplanar Tn A B C D *)
    assert_diffs; apply col_permutation_2, cop_per2__col with P; Cop.
(* Goal: @Col Tn A B C *)
  assert (Col A B M).
(* Goal: False *)
    apply cop_per2__col with P; try apply HUD; assert_diffs; auto.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
    apply coplanar_perm_12, col_cop__cop with Q; Col.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
    apply coplanar_trans_1 with C; Cop; Col.
(* Goal: @Col Tn A B C *)
  assert (Col A C M).
(* Goal: False *)
    apply cop_per2__col with P; try apply HUD; assert_diffs; auto.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
    apply coplanar_perm_12, col_cop__cop with Q; Col.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
    apply coplanar_trans_1 with B; Cop; Col.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
  apply col_transitivity_1 with M; Col.
Qed.

Lemma l9_38 : forall A B C P Q, TSP A B C P Q -> TSP A B C Q P.
Proof.
(* Goal: forall (A B C P Q : @Tpoint Tn) (_ : @TSP Tn A B C P Q), @TSP Tn A B C Q P *)
  intros A B C P Q [HP [HQ [T [HT HBet]]]].
(* Goal: and (@Bet Tn X P Y) (and (not (@Coplanar Tn A B C X)) (not (@Coplanar Tn A B C Y))) *)
  repeat split; trivial.
  exists T; split; Between.
Qed.

Lemma l9_39 : forall A B C D P Q R, TSP A B C P R -> Coplanar A B C D -> Out D P Q ->
  TSP A B C Q R.
Proof.
(* Goal: forall (A B C D P Q R : @Tpoint Tn) (_ : @TSP Tn A B C P R) (_ : @Coplanar Tn A B C D) (_ : @Out Tn D P Q), @TSP Tn A B C Q R *)
  intros A B C D P Q R [HP [HR [T [HT HBet]]]] HCop HOut.
(* Goal: @TSP Tn A B C Q R *)
  assert (HNCol : ~ Col A B C) by (apply ncop__ncol with P, HP).
(* Goal: @TSP Tn A B C Q R *)
  split.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
    intro; assert_diffs; apply HP, col_cop2__cop with D Q; Col.
(* Goal: and (@TSP Tn A B C P S) (@TSP Tn A B C Q S) *)
  split; [assumption|].
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Coplanar Tn A B C T) (@Bet Tn Q T R)) *)
  destruct (eq_dec_points D T).
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
    subst T; exists D; split; [|apply (bet_out__bet P)]; assumption.
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Coplanar Tn A B C T) (@Bet Tn Q T R)) *)
  assert (HTS : TS D T Q R).
(* Goal: @TSP Tn A B C D E' *)
(* Goal: @ex (@Tpoint Tn) (fun Q : @Tpoint Tn => and (@Coplanar Tn A B C Q) (and (@Coplanar Tn D E P Q) (not (@eq (@Tpoint Tn) P Q)))) *)
  { assert (~ Col P D T) by (intro; apply HP, col_cop2__cop with D T; Col).
(* Goal: @TS Tn D T Q R *)
    apply l9_8_2 with P.
(* Goal: and (not (@eq (@Tpoint Tn) A B)) (and (not (@eq (@Tpoint Tn) A C)) (and (not (@eq (@Tpoint Tn) B C)) (and (not (@eq (@Tpoint Tn) A P)) (and (not (@eq (@Tpoint Tn) B P)) (and (not (@eq (@Tpoint Tn) C P)) (and (not (@eq (@Tpoint Tn) A Q)) (and (not (@eq (@Tpoint Tn) B Q)) (and (not (@eq (@Tpoint Tn) C Q)) (not (@eq (@Tpoint Tn) P Q)))))))))) *)
    - repeat split; auto.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
        intro; apply HR, col_cop2__cop with D T; Col.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
        exists T; split; Col.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
    - apply out_one_side; Col.
  }
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Coplanar Tn A B C T) (@Bet Tn Q T R)) *)
  destruct HTS as [HNCol1 [HNCol2 [T' []]]].
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Coplanar Tn A B C T) (@Bet Tn Q T R)) *)
  exists T'; split; [|assumption].
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
  apply col_cop2__cop with D T; Col.
Qed.

Lemma l9_41_1 : forall A B C P Q R, TSP A B C P R -> TSP A B C Q R -> OSP A B C P Q.
Proof.
(* Goal: forall (A B C P Q R : @Tpoint Tn) (_ : @TSP Tn A B C P R) (_ : @TSP Tn A B C Q R), @OSP Tn A B C P Q *)
  intros A B C P Q R H1 H2.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
  exists R; split; assumption.
Qed.

Lemma l9_41_2 : forall A B C P Q R, TSP A B C P R -> OSP A B C P Q -> TSP A B C Q R.
Proof.
(* Goal: forall (A B C P Q R : @Tpoint Tn) (_ : @TSP Tn A B C P R) (_ : @OSP Tn A B C P Q), @TSP Tn A B C Q R *)
  intros A B C P Q R HPR [S [[HP [_ [X []]]] [HQ [HS [Y []]]]]].
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
  assert (P <> X /\ S <> X /\ Q <> Y /\ S <> Y) by (repeat split; intro; subst; auto); spliter.
(* Goal: @TSP Tn A B C Q R *)
  destruct (col_dec P Q S) as [|HNCol].
(* Goal: @TSP Tn A B C D E' *)
(* Goal: @ex (@Tpoint Tn) (fun Q : @Tpoint Tn => and (@Coplanar Tn A B C Q) (and (@Coplanar Tn D E P Q) (not (@eq (@Tpoint Tn) P Q)))) *)
  { assert (X = Y) by (apply (col2_cop2__eq A B C Q S); ColR).
(* Goal: @Out Tn Y P Q *)
    subst Y.
(* Goal: @TSP Tn A B C Q R *)
    apply l9_39 with X P; trivial.
(* Goal: False *)
    apply l6_2 with S; auto.
  }
(* Goal: @TSP Tn A B C Q R *)
  destruct (inner_pasch P Q S X Y) as [Z []]; trivial.
(* Goal: @TSP Tn A B C Q R *)
  assert (X <> Z) by (intro; subst; apply HNCol; ColR).
(* Goal: @TSP Tn A B C Q R *)
  apply l9_39 with X Z; [|assumption|apply bet_out; auto].
(* Goal: @TSP Tn A B C Z R *)
  assert (Y <> Z) by (intro; subst; apply HNCol; ColR).
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
  apply l9_39 with Y P; [assumption..|apply l6_6, bet_out; auto].
Qed.

Lemma tsp_exists : forall A B C P, ~ Coplanar A B C P -> exists Q, TSP A B C P Q.
Proof.
(* Goal: forall (A B C P : @Tpoint Tn) (_ : not (@Coplanar Tn A B C P)), @OSP Tn A B C P P *)
  intros A B C P HP.
(* Goal: @ex (@Tpoint Tn) (fun Q : @Tpoint Tn => @TSP Tn A B C P Q) *)
  destruct (segment_construction P A A P) as [Q []].
(* Goal: @Coplanar Tn A B C D *)
  assert (HA : Coplanar A B C A) by Cop.
(* Goal: @TSP Tn A B C Q R *)
  exists Q; repeat split.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
  - assumption.
(* Goal: or (@TS Tn A B C D) (not (@TS Tn A B C D)) *)
  - assert (A <> P) by (intro; subst; apply HP, HA); assert_diffs.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
    intro; apply HP, col_cop2__cop with A Q; Col.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
  - exists A; split; assumption.
Qed.

Lemma osp_reflexivity : forall A B C P, ~ Coplanar A B C P -> OSP A B C P P.
Proof.
(* Goal: forall (A B C P : @Tpoint Tn) (_ : not (@Coplanar Tn A B C P)), @OSP Tn A B C P P *)
  intros A B C P HP.
(* Goal: @OSP Tn A B C P P *)
  destruct (tsp_exists A B C P HP) as [Q].
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
  exists Q; split; assumption.
Qed.

Lemma osp_symmetry : forall A B C P Q, OSP A B C P Q -> OSP A B C Q P.
Proof.
(* Goal: forall (A B C P Q : @Tpoint Tn) (_ : @OSP Tn A B C P Q), @OSP Tn A B C Q P *)
  intros A B C P Q [R []].
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
  exists R; split; assumption.
Qed.

Lemma osp_transitivity : forall A B C P Q R, OSP A B C P Q -> OSP A B C Q R -> OSP A B C P R.
Proof.
(* Goal: forall (A B C P Q R : @Tpoint Tn) (_ : @OSP Tn A B C P Q) (_ : @OSP Tn A B C Q R), @OSP Tn A B C P R *)
  intros A B C P Q R [S [HPS HQS]] HQR.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
  exists S; split; [|apply l9_41_2 with Q]; assumption.
Qed.

Lemma cop3_tsp__tsp : forall A B C D E F P Q, ~ Col D E F ->
  Coplanar A B C D -> Coplanar A B C E -> Coplanar A B C F ->
  TSP A B C P Q -> TSP D E F P Q.
Proof.
(* Goal: forall (A B C D E F P Q : @Tpoint Tn) (_ : not (@Col Tn D E F)) (_ : @Coplanar Tn A B C D) (_ : @Coplanar Tn A B C E) (_ : @Coplanar Tn A B C F) (_ : @TSP Tn A B C P Q), @TSP Tn D E F P Q *)
  intros A B C D E F P Q HNCol HD HE HF [HP [HQ [T [HT HBet]]]].
(* Goal: @TSP Tn D E F P Q *)
  assert (~ Col A B C) by (apply ncop__ncol with P, HP).
(* Goal: @TSP Tn D E F P Q *)
  assert (Coplanar D E F A /\ Coplanar D E F B /\ Coplanar D E F C /\ Coplanar D E F T).
(* Goal: @Coplanar Tn A B C D *)
    repeat split; apply coplanar_pseudo_trans with A B C; Cop.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
  spliter.
(* Goal: @TSP Tn A B C Q R *)
  repeat split.
(* Goal: @Coplanar Tn A B C D *)
    intro; apply HP; apply coplanar_pseudo_trans with D E F; Cop.
(* Goal: @Coplanar Tn A B C D *)
    intro; apply HQ; apply coplanar_pseudo_trans with D E F; Cop.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
    exists T; split; assumption.
Qed.

Lemma cop3_osp__osp : forall A B C D E F P Q, ~ Col D E F ->
  Coplanar A B C D -> Coplanar A B C E -> Coplanar A B C F ->
  OSP A B C P Q -> OSP D E F P Q.
Proof.
(* Goal: forall (A B C D E F P Q : @Tpoint Tn) (_ : not (@Col Tn D E F)) (_ : @Coplanar Tn A B C D) (_ : @Coplanar Tn A B C E) (_ : @Coplanar Tn A B C F) (_ : @OSP Tn A B C P Q), @OSP Tn D E F P Q *)
  intros A B C D E F P Q HNCol HD HE HF [R []].
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
  exists R; split; apply (cop3_tsp__tsp A B C); assumption.
Qed.

Lemma ncop_distincts : forall A B C D, ~ Coplanar A B C D ->
  A <> B /\ A <> C /\ A <> D /\ B <> C /\ B <> D /\ C <> D.
Proof.
(* Goal: @Coplanar Tn A B C D *)
  intros A B C D H; repeat split; intro; subst; apply H; Cop.
Qed.

Lemma tsp_distincts : forall A B C P Q, TSP A B C P Q ->
  A <> B /\ A <> C /\ B <> C /\ A <> P /\ B <> P /\ C <> P /\ A <> Q /\ B <> Q /\ C <> Q /\ P <> Q.
Proof.
(* Goal: forall (A B C P Q : @Tpoint Tn) (_ : @TSP Tn A B C P Q), and (not (@eq (@Tpoint Tn) A B)) (and (not (@eq (@Tpoint Tn) A C)) (and (not (@eq (@Tpoint Tn) B C)) (and (not (@eq (@Tpoint Tn) A P)) (and (not (@eq (@Tpoint Tn) B P)) (and (not (@eq (@Tpoint Tn) C P)) (and (not (@eq (@Tpoint Tn) A Q)) (and (not (@eq (@Tpoint Tn) B Q)) (and (not (@eq (@Tpoint Tn) C Q)) (not (@eq (@Tpoint Tn) P Q)))))))))) *)
  intros A B C P Q [HP [HQ HT]].
(* Goal: and (not (@eq (@Tpoint Tn) A B)) (and (not (@eq (@Tpoint Tn) A C)) (and (not (@eq (@Tpoint Tn) B C)) (and (not (@eq (@Tpoint Tn) A P)) (and (not (@eq (@Tpoint Tn) B P)) (and (not (@eq (@Tpoint Tn) C P)) (and (not (@eq (@Tpoint Tn) A Q)) (and (not (@eq (@Tpoint Tn) B Q)) (and (not (@eq (@Tpoint Tn) C Q)) (not (@eq (@Tpoint Tn) P Q)))))))))) *)
  assert (HP' := ncop_distincts A B C P HP).
(* Goal: and (not (@eq (@Tpoint Tn) A B)) (and (not (@eq (@Tpoint Tn) A C)) (and (not (@eq (@Tpoint Tn) B C)) (and (not (@eq (@Tpoint Tn) A P)) (and (not (@eq (@Tpoint Tn) B P)) (and (not (@eq (@Tpoint Tn) C P)) (and (not (@eq (@Tpoint Tn) A Q)) (and (not (@eq (@Tpoint Tn) B Q)) (and (not (@eq (@Tpoint Tn) C Q)) (not (@eq (@Tpoint Tn) P Q)))))))))) *)
  assert (HQ' := ncop_distincts A B C Q HQ).
(* Goal: and (not (@eq (@Tpoint Tn) A B)) (and (not (@eq (@Tpoint Tn) A C)) (and (not (@eq (@Tpoint Tn) B C)) (and (not (@eq (@Tpoint Tn) A P)) (and (not (@eq (@Tpoint Tn) B P)) (and (not (@eq (@Tpoint Tn) C P)) (and (not (@eq (@Tpoint Tn) A Q)) (and (not (@eq (@Tpoint Tn) B Q)) (and (not (@eq (@Tpoint Tn) C Q)) (not (@eq (@Tpoint Tn) P Q)))))))))) *)
  spliter; clean.
(* Goal: and (not (@eq (@Tpoint Tn) A B)) (and (not (@eq (@Tpoint Tn) A C)) (and (not (@eq (@Tpoint Tn) B C)) (and (not (@eq (@Tpoint Tn) A P)) (and (not (@eq (@Tpoint Tn) B P)) (and (not (@eq (@Tpoint Tn) C P)) (and (not (@eq (@Tpoint Tn) A Q)) (and (not (@eq (@Tpoint Tn) B Q)) (and (not (@eq (@Tpoint Tn) C Q)) (not (@eq (@Tpoint Tn) P Q)))))))))) *)
  repeat split; auto.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
  destruct HT; spliter.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
  intro; apply HP; treat_equalities; assumption.
Qed.

Lemma osp_distincts : forall A B C P Q, OSP A B C P Q ->
  A <> B /\ A <> C /\ B <> C /\ A <> P /\ B <> P /\ C <> P /\ A <> Q /\ B <> Q /\ C <> Q.
Proof.
(* Goal: forall (A B C P Q : @Tpoint Tn) (_ : @OSP Tn A B C P Q), and (not (@eq (@Tpoint Tn) A B)) (and (not (@eq (@Tpoint Tn) A C)) (and (not (@eq (@Tpoint Tn) B C)) (and (not (@eq (@Tpoint Tn) A P)) (and (not (@eq (@Tpoint Tn) B P)) (and (not (@eq (@Tpoint Tn) C P)) (and (not (@eq (@Tpoint Tn) A Q)) (and (not (@eq (@Tpoint Tn) B Q)) (not (@eq (@Tpoint Tn) C Q))))))))) *)
  intros A B C P Q [R [HPR HQR]].
(* Goal: and (not (@eq (@Tpoint Tn) A B)) (and (not (@eq (@Tpoint Tn) A C)) (and (not (@eq (@Tpoint Tn) B C)) (and (not (@eq (@Tpoint Tn) A P)) (and (not (@eq (@Tpoint Tn) B P)) (and (not (@eq (@Tpoint Tn) C P)) (and (not (@eq (@Tpoint Tn) A Q)) (and (not (@eq (@Tpoint Tn) B Q)) (not (@eq (@Tpoint Tn) C Q))))))))) *)
  apply tsp_distincts in HPR.
(* Goal: and (not (@eq (@Tpoint Tn) A B)) (and (not (@eq (@Tpoint Tn) A C)) (and (not (@eq (@Tpoint Tn) B C)) (and (not (@eq (@Tpoint Tn) A P)) (and (not (@eq (@Tpoint Tn) B P)) (and (not (@eq (@Tpoint Tn) C P)) (and (not (@eq (@Tpoint Tn) A Q)) (and (not (@eq (@Tpoint Tn) B Q)) (not (@eq (@Tpoint Tn) C Q))))))))) *)
  apply tsp_distincts in HQR.
(* Goal: and (not (@eq (@Tpoint Tn) A B)) (and (not (@eq (@Tpoint Tn) A C)) (and (not (@eq (@Tpoint Tn) B C)) (and (not (@eq (@Tpoint Tn) A P)) (and (not (@eq (@Tpoint Tn) B P)) (and (not (@eq (@Tpoint Tn) C P)) (and (not (@eq (@Tpoint Tn) A Q)) (and (not (@eq (@Tpoint Tn) B Q)) (and (not (@eq (@Tpoint Tn) C Q)) (not (@eq (@Tpoint Tn) P Q)))))))))) *)
  spliter; clean; repeat split; auto.
Qed.

Lemma tsp__ncop1 : forall A B C P Q, TSP A B C P Q -> ~ Coplanar A B C P.
Proof.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
  unfold TSP; intros; spliter; assumption.
Qed.

Lemma tsp__ncop2 : forall A B C P Q, TSP A B C P Q -> ~ Coplanar A B C Q.
Proof.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
  unfold TSP; intros; spliter; assumption.
Qed.

Lemma osp__ncop1 : forall A B C P Q, OSP A B C P Q -> ~ Coplanar A B C P.
Proof.
(* Goal: forall (A B C P Q : @Tpoint Tn) (_ : @OSP Tn A B C P Q), not (@Coplanar Tn A B C Q) *)
  intros A B C P Q [R [H1 H2]].
(* Goal: not (@Coplanar Tn A B C P) *)
  apply tsp__ncop1 with R, H1.
Qed.

Lemma osp__ncop2 : forall A B C P Q, OSP A B C P Q -> ~ Coplanar A B C Q.
Proof.
(* Goal: forall (A B C P Q : @Tpoint Tn) (_ : @OSP Tn A B C P Q), not (@Coplanar Tn A B C Q) *)
  intros A B C P Q [R [H1 H2]].
(* Goal: not (@Coplanar Tn A B C Q) *)
  apply tsp__ncop1 with R, H2.
Qed.

Lemma tsp__nosp : forall A B C P Q, TSP A B C P Q -> ~ OSP A B C P Q.
Proof.
(* Goal: forall (A B C P Q : @Tpoint Tn) (_ : @TSP Tn A B C P Q), not (@OSP Tn A B C P Q) *)
  intros A B C P Q HTS HOS.
(* Goal: False *)
  absurd (TSP A B C P P).
(* Goal: False *)
    intro Habs; apply tsp_distincts in Habs; spliter; auto.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
    apply l9_41_2 with Q; [apply l9_38 | apply osp_symmetry]; assumption.
Qed.

Lemma osp__ntsp : forall A B C P Q, OSP A B C P Q -> ~ TSP A B C P Q.
Proof.
(* Goal: forall (A B C P Q : @Tpoint Tn) (_ : @OSP Tn A B C P Q), not (@TSP Tn A B C P Q) *)
  intros A B C P Q HOS HTS.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
  apply (tsp__nosp A B C P Q); assumption.
Qed.

Lemma osp_bet__osp : forall A B C P Q R, OSP A B C P R -> Bet P Q R -> OSP A B C P Q.
Proof.
(* Goal: forall (A B C P Q R : @Tpoint Tn) (_ : @OSP Tn A B C P R) (_ : @Bet Tn P Q R), @OSP Tn A B C P Q *)
  intros A B C P Q R [S [HPS [HR [_ [Y []]]]]] HBet.
(* Goal: @OSP Tn A B C P Q *)
  destruct (col_dec P R S) as [|HNCol].
(* Goal: @TSP Tn A B C D E' *)
(* Goal: @ex (@Tpoint Tn) (fun Q : @Tpoint Tn => and (@Coplanar Tn A B C Q) (and (@Coplanar Tn D E P Q) (not (@eq (@Tpoint Tn) P Q)))) *)
  { exists S.
(* Goal: and (@TSP Tn A B C P S) (@TSP Tn A B C Q S) *)
    split; [assumption|].
(* Goal: @TSP Tn A B C Q S *)
    apply l9_39 with Y P; trivial.
(* Goal: @OSP Tn A B C P Q *)
    destruct HPS as [HP [HS [X []]]].
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
    assert (P <> X /\ S <> X /\ R <> Y) by (repeat split; intro; subst; auto); spliter.
(* Goal: @Out Tn Y P Q *)
    assert (X = Y) by (assert_diffs; apply (col2_cop2__eq A B C R S); ColR).
(* Goal: @Out Tn Y P Q *)
    subst Y.
(* Goal: @Out Tn X P Q *)
    apply out_bet_out_1 with R; [|assumption].
(* Goal: False *)
    apply l6_2 with S; auto.
  }
(* Goal: @OSP Tn A B C P Q *)
  destruct HPS as [HP [HS [X []]]].
(* Goal: @OSP Tn A B C P Q *)
  assert (HOS : OS X Y P Q).
(* Goal: @TSP Tn A B C D E' *)
(* Goal: @ex (@Tpoint Tn) (fun Q : @Tpoint Tn => and (@Coplanar Tn A B C Q) (and (@Coplanar Tn D E P Q) (not (@eq (@Tpoint Tn) P Q)))) *)
  { apply l9_17 with R; [|assumption].
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
    assert (P <> X /\ S <> X /\ R <> Y /\ S <> Y) by (repeat split; intro; subst; auto); spliter.
(* Goal: @OS Tn X Y P R *)
    assert (~ Col S X Y) by (intro; apply HNCol; ColR).
(* Goal: @OS Tn X Y P R *)
    exists S; repeat split; trivial; try (intro; apply HNCol; ColR).
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
      exists X; split; Col.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
      exists Y; split; Col.
  }
(* Goal: @OSP Tn A B C P Q *)
  destruct HOS as [S' [[HNCol1 [HNCol2 [X' []]]] [HNCol3 [_ [Y' []]]]]].
(* Goal: @OSP Tn A B C P Q *)
  assert (Coplanar A B C X') by (assert_diffs; apply col_cop2__cop with X Y; Col).
(* Goal: @OSP Tn A B C P Q *)
  assert (Coplanar A B C Y') by (assert_diffs; apply col_cop2__cop with X Y; Col).
(* Goal: @OSP Tn A B C P Q *)
  assert (HS' : ~ Coplanar A B C S').
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
    intro; apply HP, col_cop2__cop with X' S'; Col; intro; subst; Col.
(* Goal: and (@Bet Tn X P Y) (and (not (@Coplanar Tn A B C X)) (not (@Coplanar Tn A B C Y))) *)
  exists S'; repeat split; trivial.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
    exists X'; split; assumption.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
    intro; apply HS', col_cop2__cop with Q Y'; Col; intro; subst; Col.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
    exists Y'; split; assumption.
Qed.

Lemma l9_18_3 : forall A B C X Y P, Coplanar A B C P -> Col X Y P ->
  TSP A B C X Y <-> Bet X P Y /\ ~ Coplanar A B C X /\ ~ Coplanar A B C Y.
Proof.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
  intros A B C X Y P HP HCol.
(* Goal: iff (@TSP Tn A B C X Y) (and (@Bet Tn X P Y) (and (not (@Coplanar Tn A B C X)) (not (@Coplanar Tn A B C Y)))) *)
  split; [|intros [HBet [HX HY]]; repeat split; trivial; exists P; split; assumption].
(* Goal: forall _ : @TSP Tn A B C X Y, and (@Bet Tn X P Y) (and (not (@Coplanar Tn A B C X)) (not (@Coplanar Tn A B C Y))) *)
  intros [HX [HY [T [HT HBet]]]].
(* Goal: and (@Bet Tn X P Y) (and (not (@Coplanar Tn A B C X)) (not (@Coplanar Tn A B C Y))) *)
  repeat split; trivial.
(* Goal: @Bet Tn X P Y *)
  replace P with T; trivial.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
  apply (col2_cop2__eq A B C X Y); Col.
(* Goal: not (@eq (@Tpoint Tn) X Y) *)
  intro; treat_equalities; auto.
Qed.

Lemma bet_cop__tsp : forall A B C X Y P,
  ~ Coplanar A B C X -> P <> Y -> Coplanar A B C P -> Bet X P Y ->
  TSP A B C X Y.
Proof.
(* Goal: forall (A B C X Y P : @Tpoint Tn) (_ : not (@Coplanar Tn A B C X)) (_ : not (@eq (@Tpoint Tn) P Y)) (_ : @Coplanar Tn A B C P) (_ : @Bet Tn X P Y), @TSP Tn A B C X Y *)
  intros A B C X Y P HX HPY HP HBet.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
  apply (l9_18_3 A B C X Y P); Col.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
  repeat split; [assumption..|].
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
  intro; apply HX, col_cop2__cop with P Y; Col.
Qed.

Lemma cop_out__osp : forall A B C X Y P,
  ~ Coplanar A B C X -> Coplanar A B C P -> Out P X Y -> OSP A B C X Y.
Proof.
(* Goal: forall (A B C X Y P : @Tpoint Tn) (_ : not (@Coplanar Tn A B C X)) (_ : @Coplanar Tn A B C P) (_ : @Out Tn P X Y), @OSP Tn A B C X Y *)
  intros A B C X Y P HX HP HOut.
(* Goal: @OSP Tn A B C X Y *)
  assert (~ Coplanar A B C Y).
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
    assert_diffs; intro; apply HX, col_cop2__cop with P Y; Col.
(* Goal: @OSP Tn A B C X Y *)
  destruct (segment_construction X P P X) as [X' []].
(* Goal: @OSP Tn A B C X Y *)
  assert (~ Coplanar A B C X').
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
    assert_diffs; intro; apply HX, col_cop2__cop with P X'; Col.
(* Goal: @OSP Tn A B C X Y *)
  exists X'; repeat split; trivial; exists P; split; trivial.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
  apply bet_out__bet with X; assumption.
Qed.

Lemma l9_19_3 : forall A B C X Y P, Coplanar A B C P -> Col X Y P ->
  OSP A B C X Y <-> Out P X Y /\ ~ Coplanar A B C X.
Proof.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
  intros A B C X Y P HP HCol.
(* Goal: iff (@OSP Tn A B C X Y) (and (@Out Tn P X Y) (not (@Coplanar Tn A B C X))) *)
  split; [|intros []; apply cop_out__osp with P; assumption].
(* Goal: forall _ : @OSP Tn A B C X Y, and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
  intro HOS.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
  assert (~ Coplanar A B C X /\ ~ Coplanar A B C Y).
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
    unfold OSP, TSP in HOS; destruct HOS as [Z []]; spliter; split; assumption.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
  spliter.
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
  split; [|assumption].
(* Goal: @Out Tn P X Y *)
  apply not_bet_out; [Col|].
(* Goal: not (@Bet Tn X P Y) *)
  intro HBet.
(* Goal: False *)
  apply osp__ntsp in HOS.
(* Goal: False *)
  apply HOS.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
  repeat split; trivial; exists P; split; assumption.
Qed.

Lemma cop2_ts__tsp : forall A B C D E X Y, ~ Coplanar A B C X ->
  Coplanar A B C D -> Coplanar A B C E -> TS D E X Y ->
  TSP A B C X Y.
Proof.
(* Goal: forall (A B C D E X Y : @Tpoint Tn) (_ : not (@Coplanar Tn A B C X)) (_ : @Coplanar Tn A B C D) (_ : @Coplanar Tn A B C E) (_ : @TS Tn D E X Y), @TSP Tn A B C X Y *)
  intros A B C D E X Y HX HD HE [HNCol [HNCol' [T []]]].
(* Goal: @TSP Tn A B C X Y *)
  assert (Coplanar A B C T) by (assert_diffs; apply col_cop2__cop with D E; Col).
(* Goal: @TSP Tn A B C Q R *)
  repeat split.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
    assumption.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
    intro; apply HX, col_cop2__cop with T Y; Col; intro; subst; apply HNCol'; Col.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
  exists T; split; assumption.
Qed.

Lemma cop2_os__osp : forall A B C D E X Y, ~ Coplanar A B C X ->
  Coplanar A B C D -> Coplanar A B C E -> OS D E X Y ->
  OSP A B C X Y.
Proof.
(* Goal: forall (A B C D E X Y : @Tpoint Tn) (_ : not (@Coplanar Tn A B C X)) (_ : @Coplanar Tn A B C D) (_ : @Coplanar Tn A B C E) (_ : @OS Tn D E X Y), @OSP Tn A B C X Y *)
  intros A B C D E X Y HX HD HE [Z [HXZ HYZ]].
(* Goal: @OSP Tn A B C X Y *)
  assert (HTS : TSP A B C X Z) by (apply cop2_ts__tsp with D E; assumption).
(* Goal: and (@TSP Tn A B C P S) (@TSP Tn A B C Q S) *)
  exists Z; split; [assumption|].
(* Goal: @TSP Tn A B C Y Z *)
  destruct HTS as [_ []].
(* Goal: @TSP Tn A B C Y Z *)
  apply l9_2 in HYZ.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
  apply l9_38, cop2_ts__tsp with D E; assumption.
Qed.

Lemma cop3_tsp__ts : forall A B C D E X Y, D <> E ->
  Coplanar A B C D -> Coplanar A B C E -> Coplanar D E X Y ->
  TSP A B C X Y -> TS D E X Y.
Proof.
(* Goal: forall (A B C D E X Y : @Tpoint Tn) (_ : not (@eq (@Tpoint Tn) D E)) (_ : @Coplanar Tn A B C D) (_ : @Coplanar Tn A B C E) (_ : @Coplanar Tn D E X Y) (_ : @TSP Tn A B C X Y), @TS Tn D E X Y *)
  intros A B C D E X Y HDE HD HE HCop HTSP.
(* Goal: @TS Tn D E X Y *)
  assert (HX : ~ Coplanar A B C X) by (apply tsp__ncop1 with Y, HTSP).
(* Goal: @TS Tn D E X Y *)
  assert (HY : ~ Coplanar A B C Y) by (apply tsp__ncop2 with X, HTSP).
(* Goal: @TS Tn D E X Y *)
  apply cop__not_one_side_two_sides.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
    assumption.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
    intro; apply HX, col_cop2__cop with D E; Col.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
    intro; apply HY, col_cop2__cop with D E; Col.
(* Goal: not (@TS Tn D E X Y) *)
  intro.
(* Goal: False *)
  apply tsp__nosp in HTSP.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
  apply HTSP, cop2_os__osp with D E; assumption.
Qed.

Lemma cop3_osp__os : forall A B C D E X Y, D <> E ->
  Coplanar A B C D -> Coplanar A B C E -> Coplanar D E X Y ->
  OSP A B C X Y -> OS D E X Y.
Proof.
(* Goal: forall (A B C D E X Y : @Tpoint Tn) (_ : not (@eq (@Tpoint Tn) D E)) (_ : @Coplanar Tn A B C D) (_ : @Coplanar Tn A B C E) (_ : @Coplanar Tn D E X Y) (_ : @OSP Tn A B C X Y), @OS Tn D E X Y *)
  intros A B C D E X Y HDE HD HE HCop HOSP.
(* Goal: @OS Tn D E X Y *)
  assert (HX : ~ Coplanar A B C X) by (apply osp__ncop1 with Y, HOSP).
(* Goal: @OS Tn D E X Y *)
  assert (HY : ~ Coplanar A B C Y) by (apply osp__ncop2 with X, HOSP).
(* Goal: @OS Tn D E X Y *)
  apply cop__not_two_sides_one_side.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
    assumption.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
    intro; apply HX, col_cop2__cop with D E; Col.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
    intro; apply HY, col_cop2__cop with D E; Col.
(* Goal: not (@TS Tn D E X Y) *)
  intro.
(* Goal: False *)
  apply osp__ntsp in HOSP.
(* Goal: @Coplanar Tn D E X Y *)
(* Goal: not (@Col Tn X D E) *)
(* Goal: not (@Col Tn Y D E) *)
(* Goal: not (@TS Tn D E X Y) *)
  apply HOSP, cop2_ts__tsp with D E; assumption.
Qed.

Lemma cop_tsp__ex_cop2 : forall A B C D E P,
  Coplanar A B C P -> TSP A B C D E ->
  exists Q, Coplanar A B C Q /\ Coplanar D E P Q /\ P <> Q.
Proof.
(* Goal: forall (A B C D E P : @Tpoint Tn) (_ : @Coplanar Tn A B C P) (_ : @TSP Tn A B C D E), @ex (@Tpoint Tn) (fun Q : @Tpoint Tn => and (@Coplanar Tn A B C Q) (and (@Coplanar Tn D E P Q) (not (@eq (@Tpoint Tn) P Q)))) *)
  intros A B C D E P HCop HTSP.
(* Goal: @ex (@Tpoint Tn) (fun Q : @Tpoint Tn => and (@Coplanar Tn A B C Q) (and (@Coplanar Tn D E P Q) (not (@eq (@Tpoint Tn) P Q)))) *)
  destruct (col_dec D E P) as [|HNCol].
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
  { apply tsp_distincts in HTSP; spliter.
(* Goal: @ex (@Tpoint Tn) (fun Q : @Tpoint Tn => and (@Coplanar Tn A B C Q) (and (@Coplanar Tn D E P Q) (not (@eq (@Tpoint Tn) P Q)))) *)
    destruct (eq_dec_points P A).
(* Goal: @Coplanar Tn A B C D *)
      subst; exists B; repeat split; Cop.
(* Goal: @Coplanar Tn A B C D *)
      exists A; repeat split; Cop.
  }
(* Goal: @ex (@Tpoint Tn) (fun Q : @Tpoint Tn => and (@Coplanar Tn A B C Q) (and (@Coplanar Tn D E P Q) (not (@eq (@Tpoint Tn) P Q)))) *)
  destruct HTSP as [_ [_ [Q []]]].
(* Goal: @Coplanar Tn A B C D *)
  exists Q; repeat split; Cop.
(* Goal: not (@Col Tn C A B) *)
(* Goal: not (@Col Tn C' A B) *)
(* Goal: @ex (@Tpoint Tn) (fun T : @Tpoint Tn => and (@Col Tn T A B) (@Bet Tn C T C')) *)
  intro; subst; apply HNCol; Col.
Qed.

Lemma cop_osp__ex_cop2 : forall A B C D E P,
  Coplanar A B C P -> OSP A B C D E ->
  exists Q, Coplanar A B C Q /\ Coplanar D E P Q /\ P <> Q.
Proof.
(* Goal: forall (A B C D E P : @Tpoint Tn) (_ : @Coplanar Tn A B C P) (_ : @OSP Tn A B C D E), @ex (@Tpoint Tn) (fun Q : @Tpoint Tn => and (@Coplanar Tn A B C Q) (and (@Coplanar Tn D E P Q) (not (@eq (@Tpoint Tn) P Q)))) *)
  intros A B C D E P HCop HOSP.
(* Goal: @ex (@Tpoint Tn) (fun Q : @Tpoint Tn => and (@Coplanar Tn A B C Q) (and (@Coplanar Tn D E P Q) (not (@eq (@Tpoint Tn) P Q)))) *)
  destruct (col_dec D E P) as [|HNCol].
(* Goal: and (@Out Tn P X Y) (not (@Coplanar Tn A B C X)) *)
  { apply osp_distincts in HOSP; spliter.
(* Goal: @ex (@Tpoint Tn) (fun Q : @Tpoint Tn => and (@Coplanar Tn A B C Q) (and (@Coplanar Tn D E P Q) (not (@eq (@Tpoint Tn) P Q)))) *)
    destruct (eq_dec_points P A).
(* Goal: @Coplanar Tn A B C D *)
      subst; exists B; repeat split; Cop.
(* Goal: @Coplanar Tn A B C D *)
      exists A; repeat split; Cop.
  }
  
(* Goal: @ex (@Tpoint Tn) (fun Q : @Tpoint Tn => and (@Coplanar Tn A B C Q) (and (@Coplanar Tn D E P Q) (not (@eq (@Tpoint Tn) P Q)))) *)
    destruct (segment_construction E P P E) as [E' []].
(* Goal: @ex (@Tpoint Tn) (fun Q : @Tpoint Tn => and (@Coplanar Tn A B C Q) (and (@Coplanar Tn D E P Q) (not (@eq (@Tpoint Tn) P Q)))) *)
    assert (~ Col D E' P) by (intro; apply HNCol; ColR).
(* Goal: @ex (@Tpoint Tn) (fun Q : @Tpoint Tn => and (@Coplanar Tn A B C Q) (and (@Coplanar Tn D E P Q) (not (@eq (@Tpoint Tn) P Q)))) *)
    destruct (cop_tsp__ex_cop2 A B C D E' P) as [Q [HQ1 [HQ2 HPQ]]]; [assumption|..].
(* Goal: @TSP Tn A B C D E' *)
(* Goal: @ex (@Tpoint Tn) (fun Q : @Tpoint Tn => and (@Coplanar Tn A B C Q) (and (@Coplanar Tn D E P Q) (not (@eq (@Tpoint Tn) P Q)))) *)
    { apply l9_41_2 with E.
(* Goal: @Coplanar Tn A B C D *)
        assert_diffs; destruct HOSP as [F [_ [HE]]]; apply bet_cop__tsp with P; Cop.
(* Goal: @OSP Tn A B C E D *)
        apply osp_symmetry, HOSP.
    }
(* Goal: and (not (@eq (@Tpoint Tn) A B)) (and (not (@eq (@Tpoint Tn) A C)) (and (not (@eq (@Tpoint Tn) B C)) (and (not (@eq (@Tpoint Tn) A P)) (and (not (@eq (@Tpoint Tn) B P)) (and (not (@eq (@Tpoint Tn) C P)) (and (not (@eq (@Tpoint Tn) A Q)) (and (not (@eq (@Tpoint Tn) B Q)) (and (not (@eq (@Tpoint Tn) C Q)) (not (@eq (@Tpoint Tn) P Q)))))))))) *)
    exists Q; repeat split; auto.
(* Goal: @Coplanar Tn A B C D *)
    apply coplanar_perm_2, coplanar_trans_1 with E'; Col; Cop.
Qed.

End T9.

Hint Resolve l9_2 invert_two_sides invert_one_side one_side_symmetry l9_9 l9_9_bis
             l9_38 osp_symmetry osp__ntsp tsp__nosp : side.
Hint Resolve os__coplanar : cop.

Ltac Side := eauto with side.

Ltac not_exist_hyp_perm4 A B C D := first [not_exist_hyp_perm_ncol A B C|not_exist_hyp_perm_ncol A B D|not_exist_hyp_perm_ncol A C D|not_exist_hyp_perm_ncol B C D].

Ltac assert_ncols :=
repeat
  match goal with
      | H:OS ?A ?B ?X ?Y |- _ =>
     not_exist_hyp_perm_ncol A B X;assert (~ Col A B X) by (apply(one_side_not_col123 A B X Y);finish)

      | H:OS ?A ?B ?X ?Y |- _ =>
     not_exist_hyp_perm_ncol A B Y;assert (~ Col A B Y) by (apply(one_side_not_col124 A B X Y);finish)

      | H:TS ?A ?B ?X ?Y |- _ =>
     not_exist_hyp_perm_ncol A B X;assert (~ Col A B X) by (apply(two_sides_not_col A B X Y);finish)

      | H:TS ?A ?B ?X ?Y |- _ =>
     not_exist_hyp_perm_ncol A B Y;assert (~ Col A B Y) by (apply(two_sides_not_col A B Y X);finish)

      | H:~ Coplanar ?A ?B ?C ?D |- _ =>
      let h := fresh in
      not_exist_hyp_perm4 A B C D;
      assert (h := ncop__ncols A B C D H);decompose [and] h;clear h;clean_reap_hyps
  end.
