Require Import Recdef.
Require Import NArith.
Require Import GeoCoq.Utils.sets.

Module SSWP := WPropertiesOn SetOfSetsOfPositiveOrderedType SS.

Module SSWEqP := WEqPropertiesOn SetOfSetsOfPositiveOrderedType SS.

Module SPWEqP := WEqPropertiesOn SetOfPairsOfPositiveOrderedType SP.

Definition pick_line (s : SS.elt) (sp : SP.t) :=
  SP.exists_ (fun p => (S.mem (fstpp p) s) && (S.mem (sndpp p) s)) sp.

Lemma proper_00 : forall s,
  Proper
  ((fun t1 t2 : SetOfPairsOfPositiveOrderedType.t =>
    Pos.eq (fstpp t1) (fstpp t2) /\ Pos.eq (sndpp t1) (sndpp t2)) ==> eq)
  (fun p : SP.elt =>
   S.mem (fstpp p) s && S.mem (sndpp p) s).
Proof.
(* Goal: forall s : S.t, @Proper (forall _ : SetOfPairsOfPositiveOrderedType.t, bool) (@respectful SetOfPairsOfPositiveOrderedType.t bool (fun t1 t2 : SetOfPairsOfPositiveOrderedType.t => and (Pos.eq (fstpp t1) (fstpp t2)) (Pos.eq (sndpp t1) (sndpp t2))) (@eq bool)) (fun p : SP.elt => andb (S.mem (fstpp p) s) (S.mem (sndpp p) s)) *)
intros s x y Hxy.
(* Goal: @eq bool (andb (S.mem (fstpp x) s) (S.mem (sndpp x) s)) (andb (S.mem (fstpp y) s) (S.mem (sndpp y) s)) *)
destruct Hxy as [Hxyfst Hxysnd].
(* Goal: @eq bool (andb (S.mem (fstpp x) s) (S.mem (sndpp x) s)) (andb (S.mem (fstpp y) s) (S.mem (sndpp y) s)) *)
rewrite Hxyfst.
(* Goal: @eq bool (andb (S.mem (fstpp y) s) (S.mem (sndpp x) s)) (andb (S.mem (fstpp y) s) (S.mem (sndpp y) s)) *)
rewrite Hxysnd.
(* Goal: @eq bool (negb (Pos.eqb (fstpp y) p)) (negb (Pos.eqb (fstpp y) p)) *)
reflexivity.
Qed.

Lemma proper_0 :
  Proper (S.Equal ==> eq ==> eq) pick_line.
Proof.
(* Goal: @Proper (forall (_ : S.t) (_ : SS.t) (_ : SP.t), option (prod SS.elt SS.elt)) (@respectful S.t (forall (_ : SS.t) (_ : SP.t), option (prod SS.elt SS.elt)) S.Equal (@respectful SS.t (forall _ : SP.t, option (prod SS.elt SS.elt)) SS.Equal (@respectful SP.t (option (prod SS.elt SS.elt)) (@eq SP.t) eqopp))) pick_lines_aux *)
intros x1 y1 HXY1.
(* Goal: @respectful SS.t (forall _ : SP.t, option (prod SS.elt SS.elt)) SS.Equal (@respectful SP.t (option (prod SS.elt SS.elt)) (@eq SP.t) eqopp) (pick_lines_aux x1) (pick_lines_aux y1) *)
intros x2 y2 HXY2.
(* Goal: @eq bool (pick_line x1 x2) (pick_line y1 y2) *)
unfold pick_line; unfold SP.exists_; unfold SP.Raw.exists_.
(* Goal: @eq bool ((fix exists_ (f : forall _ : SP.Raw.elt, bool) (s : SP.Raw.t) {struct s} : bool := match s with | nil => false | cons x l => if f x then true else exists_ f l end) (fun p : SP.elt => andb (S.mem (fstpp p) x1) (S.mem (sndpp p) x1)) (SP.this x2)) ((fix exists_ (f : forall _ : SP.Raw.elt, bool) (s : SP.Raw.t) {struct s} : bool := match s with | nil => false | cons x l => if f x then true else exists_ f l end) (fun p : SP.elt => andb (S.mem (fstpp p) y1) (S.mem (sndpp p) y1)) (SP.this y2)) *)
rewrite HXY2.
(* Goal: @eq bool ((fix exists_ (f : forall _ : SP.Raw.elt, bool) (s : SP.Raw.t) {struct s} : bool := match s with | nil => false | cons x l => if f x then true else exists_ f l end) (fun p : SP.elt => andb (S.mem (fstpp p) x1) (S.mem (sndpp p) x1)) (SP.this y2)) ((fix exists_ (f : forall _ : SP.Raw.elt, bool) (s : SP.Raw.t) {struct s} : bool := match s with | nil => false | cons x l => if f x then true else exists_ f l end) (fun p : SP.elt => andb (S.mem (fstpp p) y1) (S.mem (sndpp p) y1)) (SP.this y2)) *)
induction (SP.this y2); try intuition.

  assert (HEqMem : forall e, S.mem e x1 = S.mem e y1)
    by (intro; apply SWP.Dec.F.mem_m; intuition).
  assert (HEqAI : (S.mem (fstpp a) x1 && S.mem (sndpp a) x1) =
                  (S.mem (fstpp a) y1 && S.mem (sndpp a) y1))
    by (rewrite HEqMem; rewrite HEqMem; intuition).
(* Goal: @eq bool (if andb (S.mem (fstpp a) x1) (S.mem (sndpp a) x1) then true else (fix exists_ (f : forall _ : SP.Raw.elt, bool) (s : SP.Raw.t) {struct s} : bool := match s with | nil => false | cons x l => if f x then true else exists_ f l end) (fun p : SP.elt => andb (S.mem (fstpp p) x1) (S.mem (sndpp p) x1)) t) (if andb (S.mem (fstpp a) y1) (S.mem (sndpp a) y1) then true else (fix exists_ (f : forall _ : SP.Raw.elt, bool) (s : SP.Raw.t) {struct s} : bool := match s with | nil => false | cons x l => if f x then true else exists_ f l end) (fun p : SP.elt => andb (S.mem (fstpp p) y1) (S.mem (sndpp p) y1)) t) *)
  rewrite HEqAI.
  induction (S.mem (fstpp a) y1 && S.mem (sndpp a) y1);
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    intuition.
Qed.

Lemma proper_1 : forall s1 sp,
  Proper (S.Equal ==> eq)
  (fun s2 : SS.elt => pick_line (S.inter s1 s2) sp).
Proof.
(* Goal: forall (s1 : S.t) (sp : SP.t), @Proper (forall _ : S.t, bool) (@respectful S.t bool S.Equal (@eq bool)) (fun s2 : SS.elt => pick_line (S.inter s1 s2) sp) *)
intros s1 sp.
(* Goal: @Proper (forall _ : S.t, bool) (@respectful S.t bool S.Equal (@eq bool)) (fun s2 : SS.elt => pick_line (S.inter s1 s2) sp) *)
(* Goal: @eq (option SS.elt) (exists_witness (fun s2 : SS.elt => pick_line (S.inter s1 s2) sp) (SS.remove s1 ss)) (@Some SS.elt s2) *)
(* Goal: forall _ : @eq (option SS.elt) (exists_witness (fun s2 : SS.elt => pick_line (S.inter e1 s2) sp) (SS.remove e1 ss)) (@None SS.elt), SS.In s2 (SS.remove s1 ss) *)
(* Goal: forall _ : @eq (option SS.elt) (exists_witness (fun s : SS.elt => match pick_lines_aux s (SS.remove s ss) sp with | Some p => true | None => false end) ss) (@None SS.elt), SS.In s2 (SS.remove s1 ss) *)
intros x y HXY.
assert (HEqI : S.Equal (S.inter s1 x) (S.inter s1 y))
  by (apply SWP.inter_equal_2; assumption).
(* Goal: @eq bool (pick_line (S.inter s1 x) sp) (pick_line (S.inter s1 y) sp) *)
apply proper_0; auto.
Qed.

Definition exists_witness (f : SS.elt -> bool) (s : SS.t) : option SS.elt :=
  SS.choose (SS.filter f s).

Lemma exists_witness_ok : forall e f s,
  Proper (S.Equal ==> eq) f ->
  exists_witness f s = Some e -> SS.In e s.
Proof.
(* Goal: forall (e : SS.elt) (f : forall _ : S.t, bool) (s : SS.t) (_ : @Proper (forall _ : S.t, bool) (@respectful S.t bool S.Equal (@eq bool)) f) (_ : @eq (option SS.elt) (exists_witness f s) (@Some SS.elt e)), SS.In e s *)
intros e f s HP H.
(* Goal: SS.In e s *)
unfold exists_witness in H.
(* Goal: SS.In e s *)
apply SSWEqP.MP.Dec.F.mem_2.
(* Goal: @eq bool (SS.mem e s) true *)
apply SSWEqP.choose_mem_1 in H.
(* Goal: @eq bool (SS.mem e s) true *)
rewrite SSWEqP.filter_mem in H; try assumption.
(* Goal: @eq bool (SS.mem e s) true *)
apply andb_true_iff in H.
(* Goal: @eq bool (SS.mem e s) true *)
induction H.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
assumption.
Qed.

Definition pick_lines_aux (s1 : SS.elt)
                          (ss : SS.t)
                          (sp : SP.t)
                          : (option (SS.elt * SS.elt)) :=
  match ((exists_witness (fun s2 => let i := S.inter s1 s2 in
                                    pick_line i sp)) ss) with
    | None => None
    | Some s2 => Some(s1,s2)
  end.

Definition pick_lines (ss : SS.t) (sp : SP.t)
                      : (option (SS.elt * SS.elt)) :=
  match (exists_witness (fun s =>
                           match (pick_lines_aux s (SS.remove s ss) sp) with
                             | None => false
                             | _ => true
                           end) ss) with
    | None => None
    | Some s1 => pick_lines_aux s1 (SS.remove s1 ss) sp
  end.

Definition eqop (p1 p2 : option SS.elt) :=
  match p1,p2 with
    | None, None => True
    | Some s1, Some s2 => True
    | _, _ => False
  end.

Lemma proper_2 : forall (f1 f2 : SS.elt -> bool) (s1 s2 : SS.t),
  Proper (S.Equal ==> eq) f1 ->
  Proper (S.Equal ==> eq) f2 ->
  (forall x, f1 x = f2 x) ->
  SS.Equal s1 s2 ->
  eqop (exists_witness f1 s1) (exists_witness f2 s2).
Proof.
intros f1 f2 s1 s2.
intros H1 H2 H3 H4.
unfold eqop.
unfold exists_witness in *.
assert (SS.Equal (SS.filter f1 s1) (SS.filter f2 s2)) by (apply SSWEqP.MP.Dec.F.filter_ext; assumption).
case_eq (SS.choose (SS.filter f1 s1)); case_eq (SS.choose (SS.filter f2 s2)).

(* Goal: @eq positive (sndpp x) pb *)
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
  intuition.

(* Goal: forall (_ : @eq (option SS.elt) (exists_witness (fun s2 : SS.elt => pick_line (S.inter x1 s2) y3) x2) (@None SS.elt)) (e : SS.elt) (_ : @eq (option SS.elt) (exists_witness (fun s2 : SS.elt => pick_line (S.inter y1 s2) y3) y2) (@Some SS.elt e)), eqopp (@None (prod SS.elt SS.elt)) (@Some (prod SS.elt SS.elt) (@pair SS.elt SS.elt y1 e)) *)
(* Goal: forall (e : SS.elt) (_ : @eq (option SS.elt) (exists_witness (fun s2 : SS.elt => pick_line (S.inter x1 s2) y3) x2) (@Some SS.elt e)) (_ : @eq (option SS.elt) (exists_witness (fun s2 : SS.elt => pick_line (S.inter y1 s2) y3) y2) (@None SS.elt)), eqopp (@Some (prod SS.elt SS.elt) (@pair SS.elt SS.elt x1 e)) (@None (prod SS.elt SS.elt)) *)
(* Goal: forall (_ : @eq (option SS.elt) (exists_witness (fun s2 : SS.elt => pick_line (S.inter x1 s2) y3) x2) (@None SS.elt)) (_ : @eq (option SS.elt) (exists_witness (fun s2 : SS.elt => pick_line (S.inter y1 s2) y3) y2) (@None SS.elt)), eqopp (@None (prod SS.elt SS.elt)) (@None (prod SS.elt SS.elt)) *)
  intros HCN e HCS.
  apply SS.choose_spec1 in HCS.
  apply SS.choose_spec2 in HCN.
  rewrite H in HCS.
  apply SSWEqP.MP.empty_is_empty_1 in HCN.
  rewrite HCN in HCS.
  rewrite <- SSWEqP.MP.Dec.F.empty_iff.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
  eassumption.

(* Goal: forall (e : SS.elt) (_ : @eq (option SS.elt) (exists_witness (fun s2 : SS.elt => pick_line (S.inter x1 s2) y3) x2) (@Some SS.elt e)) (_ : @eq (option SS.elt) (exists_witness (fun s2 : SS.elt => pick_line (S.inter y1 s2) y3) y2) (@None SS.elt)), eqopp (@Some (prod SS.elt SS.elt) (@pair SS.elt SS.elt x1 e)) (@None (prod SS.elt SS.elt)) *)
(* Goal: forall (_ : @eq (option SS.elt) (exists_witness (fun s2 : SS.elt => pick_line (S.inter x1 s2) y3) x2) (@None SS.elt)) (_ : @eq (option SS.elt) (exists_witness (fun s2 : SS.elt => pick_line (S.inter y1 s2) y3) y2) (@None SS.elt)), eqopp (@None (prod SS.elt SS.elt)) (@None (prod SS.elt SS.elt)) *)
  intros e HCS HCN.
  apply SS.choose_spec1 in HCS.
  apply SS.choose_spec2 in HCN.
  rewrite H in HCN.
  apply SSWEqP.MP.empty_is_empty_1 in HCN.
  rewrite HCN in HCS.
  rewrite <- SSWEqP.MP.Dec.F.empty_iff.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
  eassumption.

(* Goal: @eq positive (sndpp x) pb *)
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
  intuition.
Qed.

Definition eqopp (p1 p2 : option (SS.elt * SS.elt)) :=
  match p1,p2 with
    | None, None => True
    | Some s1, Some s2 => True
    | _, _ => False
  end.

Lemma proper_3 : Proper (S.Equal ==> SS.Equal ==> eq ==> eqopp) pick_lines_aux.
Proof.
(* Goal: @Proper (forall (_ : S.t) (_ : SS.t) (_ : SP.t), option (prod SS.elt SS.elt)) (@respectful S.t (forall (_ : SS.t) (_ : SP.t), option (prod SS.elt SS.elt)) S.Equal (@respectful SS.t (forall _ : SP.t, option (prod SS.elt SS.elt)) SS.Equal (@respectful SP.t (option (prod SS.elt SS.elt)) (@eq SP.t) eqopp))) pick_lines_aux *)
intros x1 y1 HXY1.
(* Goal: @respectful SS.t (forall _ : SP.t, option (prod SS.elt SS.elt)) SS.Equal (@respectful SP.t (option (prod SS.elt SS.elt)) (@eq SP.t) eqopp) (pick_lines_aux x1) (pick_lines_aux y1) *)
intros x2 y2 HXY2.
(* Goal: @respectful SP.t (option (prod SS.elt SS.elt)) (@eq SP.t) eqopp (pick_lines_aux x1 x2) (pick_lines_aux y1 y2) *)
intros x3 y3 HXY3.
(* Goal: eqopp (pick_lines_aux x1 x2 x3) (pick_lines_aux y1 y2 y3) *)
unfold pick_lines_aux.
(* Goal: eqopp match exists_witness (fun s2 : SS.elt => pick_line (S.inter x1 s2) x3) x2 with | Some s2 => @Some (prod SS.elt SS.elt) (@pair SS.elt SS.elt x1 s2) | None => @None (prod SS.elt SS.elt) end match exists_witness (fun s2 : SS.elt => pick_line (S.inter y1 s2) y3) y2 with | Some s2 => @Some (prod SS.elt SS.elt) (@pair SS.elt SS.elt y1 s2) | None => @None (prod SS.elt SS.elt) end *)
rewrite HXY3.
assert (eqop (exists_witness (fun s2 : SS.elt => pick_line (S.inter x1 s2) y3) x2)
             (exists_witness (fun s2 : SS.elt => pick_line (S.inter y1 s2) y3) y2)).

(* Goal: eqop (exists_witness (fun s2 : SS.elt => pick_line (S.inter x1 s2) y3) x2) (exists_witness (fun s2 : SS.elt => pick_line (S.inter y1 s2) y3) y2) *)
(* Goal: eqopp match exists_witness (fun s2 : SS.elt => pick_line (S.inter x1 s2) y3) x2 with | Some s2 => @Some (prod SS.elt SS.elt) (@pair SS.elt SS.elt x1 s2) | None => @None (prod SS.elt SS.elt) end match exists_witness (fun s2 : SS.elt => pick_line (S.inter y1 s2) y3) y2 with | Some s2 => @Some (prod SS.elt SS.elt) (@pair SS.elt SS.elt y1 s2) | None => @None (prod SS.elt SS.elt) end *)
  apply proper_2.

(* Goal: @Proper (forall _ : S.t, bool) (@respectful S.t bool S.Equal (@eq bool)) (fun s2 : SS.elt => pick_line (S.inter y1 s2) y3) *)
(* Goal: forall x : SS.elt, @eq bool (pick_line (S.inter x1 x) y3) (pick_line (S.inter y1 x) y3) *)
(* Goal: SS.Equal x2 y2 *)
(* Goal: eqopp match exists_witness (fun s2 : SS.elt => pick_line (S.inter x1 s2) y3) x2 with | Some s2 => @Some (prod SS.elt SS.elt) (@pair SS.elt SS.elt x1 s2) | None => @None (prod SS.elt SS.elt) end match exists_witness (fun s2 : SS.elt => pick_line (S.inter y1 s2) y3) y2 with | Some s2 => @Some (prod SS.elt SS.elt) (@pair SS.elt SS.elt y1 s2) | None => @None (prod SS.elt SS.elt) end *)
    apply proper_1.

(* Goal: @Proper (forall _ : S.t, bool) (@respectful S.t bool S.Equal (@eq bool)) (fun s2 : SS.elt => pick_line (S.inter y1 s2) y3) *)
(* Goal: forall x : SS.elt, @eq bool (pick_line (S.inter x1 x) y3) (pick_line (S.inter y1 x) y3) *)
(* Goal: SS.Equal x2 y2 *)
(* Goal: eqopp match exists_witness (fun s2 : SS.elt => pick_line (S.inter x1 s2) y3) x2 with | Some s2 => @Some (prod SS.elt SS.elt) (@pair SS.elt SS.elt x1 s2) | None => @None (prod SS.elt SS.elt) end match exists_witness (fun s2 : SS.elt => pick_line (S.inter y1 s2) y3) y2 with | Some s2 => @Some (prod SS.elt SS.elt) (@pair SS.elt SS.elt y1 s2) | None => @None (prod SS.elt SS.elt) end *)
    apply proper_1.

(* Goal: @eq bool (negb (Pos.eqb (fstpp y) p)) (negb (Pos.eqb (fstpp y) p)) *)
    intro; apply proper_0; try reflexivity.

(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
      apply SWP.inter_equal_1; assumption.

(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
      assumption.

case_eq (exists_witness (fun s2 : SS.elt => pick_line (S.inter y1 s2) y3) y2);
case_eq (exists_witness (fun s2 : SS.elt => pick_line (S.inter x1 s2) y3) x2).

(* Goal: @eq positive (sndpp x) pb *)
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
  simpl; intuition.

(* Goal: forall (_ : @eq (option SS.elt) (exists_witness (fun s2 : SS.elt => pick_line (S.inter x1 s2) y3) x2) (@None SS.elt)) (e : SS.elt) (_ : @eq (option SS.elt) (exists_witness (fun s2 : SS.elt => pick_line (S.inter y1 s2) y3) y2) (@Some SS.elt e)), eqopp (@None (prod SS.elt SS.elt)) (@Some (prod SS.elt SS.elt) (@pair SS.elt SS.elt y1 e)) *)
(* Goal: forall (e : SS.elt) (_ : @eq (option SS.elt) (exists_witness (fun s2 : SS.elt => pick_line (S.inter x1 s2) y3) x2) (@Some SS.elt e)) (_ : @eq (option SS.elt) (exists_witness (fun s2 : SS.elt => pick_line (S.inter y1 s2) y3) y2) (@None SS.elt)), eqopp (@Some (prod SS.elt SS.elt) (@pair SS.elt SS.elt x1 e)) (@None (prod SS.elt SS.elt)) *)
(* Goal: forall (_ : @eq (option SS.elt) (exists_witness (fun s2 : SS.elt => pick_line (S.inter x1 s2) y3) x2) (@None SS.elt)) (_ : @eq (option SS.elt) (exists_witness (fun s2 : SS.elt => pick_line (S.inter y1 s2) y3) y2) (@None SS.elt)), eqopp (@None (prod SS.elt SS.elt)) (@None (prod SS.elt SS.elt)) *)
  intros HCN e HCS.
(* Goal: not (@eq COLTpoint (interp (fstpp (@pair positive positive fstp sndp))) (interp (sndpp (@pair positive positive fstp sndp)))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
  simpl in *.
(* Goal: False *)
(* Goal: forall (_ : @eq (option SS.elt) (exists_witness (fun s2 : SS.elt => pick_line (S.inter x1 s2) y3) x2) (@None SS.elt)) (_ : @eq (option SS.elt) (exists_witness (fun s2 : SS.elt => pick_line (S.inter y1 s2) y3) y2) (@None SS.elt)), eqopp (@None (prod SS.elt SS.elt)) (@None (prod SS.elt SS.elt)) *)
  rewrite HCS in H; rewrite HCN in H.
(* Goal: not (@eq COLTpoint (interp (fstpp (@pair positive positive fstp sndp))) (interp (sndpp (@pair positive positive fstp sndp)))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
  simpl in *.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
  intuition.

(* Goal: forall (e : SS.elt) (_ : @eq (option SS.elt) (exists_witness (fun s2 : SS.elt => pick_line (S.inter x1 s2) y3) x2) (@Some SS.elt e)) (_ : @eq (option SS.elt) (exists_witness (fun s2 : SS.elt => pick_line (S.inter y1 s2) y3) y2) (@None SS.elt)), eqopp (@Some (prod SS.elt SS.elt) (@pair SS.elt SS.elt x1 e)) (@None (prod SS.elt SS.elt)) *)
(* Goal: forall (_ : @eq (option SS.elt) (exists_witness (fun s2 : SS.elt => pick_line (S.inter x1 s2) y3) x2) (@None SS.elt)) (_ : @eq (option SS.elt) (exists_witness (fun s2 : SS.elt => pick_line (S.inter y1 s2) y3) y2) (@None SS.elt)), eqopp (@None (prod SS.elt SS.elt)) (@None (prod SS.elt SS.elt)) *)
  intros e HCS HCN.
(* Goal: not (@eq COLTpoint (interp (fstpp (@pair positive positive fstp sndp))) (interp (sndpp (@pair positive positive fstp sndp)))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
  simpl in *.
(* Goal: False *)
(* Goal: forall (_ : @eq (option SS.elt) (exists_witness (fun s2 : SS.elt => pick_line (S.inter x1 s2) y3) x2) (@None SS.elt)) (_ : @eq (option SS.elt) (exists_witness (fun s2 : SS.elt => pick_line (S.inter y1 s2) y3) y2) (@None SS.elt)), eqopp (@None (prod SS.elt SS.elt)) (@None (prod SS.elt SS.elt)) *)
  rewrite HCS in H; rewrite HCN in H.
(* Goal: not (@eq COLTpoint (interp (fstpp (@pair positive positive fstp sndp))) (interp (sndpp (@pair positive positive fstp sndp)))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
  simpl in *.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
  intuition.

(* Goal: @eq positive (sndpp x) pb *)
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
  intuition.
Qed.

Lemma pick_lines_ok_1 : forall s1 s2 ss sp,
  pick_lines ss sp = Some(s1,s2) ->
  SS.In s1 ss.
Proof.
(* Goal: forall (s1 s2 : SS.elt) (ss : SS.t) (sp : SP.t) (_ : @eq (option (prod SS.elt SS.elt)) (pick_lines ss sp) (@Some (prod SS.elt SS.elt) (@pair SS.elt SS.elt s1 s2))), SS.In s2 (SS.remove s1 ss) *)
intros s1 s2 ss sp H.
(* Goal: SS.In s2 (SS.remove s1 ss) *)
unfold pick_lines in H.
case_eq (exists_witness (fun s : SS.elt => match pick_lines_aux s
                          (SS.remove s ss) sp with | Some _ => true | None => false end) ss).

(* Goal: forall (e : SS.elt) (_ : @eq (option SS.elt) (exists_witness (fun s : SS.elt => match pick_lines_aux s (SS.remove s ss) sp with | Some p => true | None => false end) ss) (@Some SS.elt e)), SS.In s2 (SS.remove s1 ss) *)
(* Goal: forall _ : @eq (option SS.elt) (exists_witness (fun s : SS.elt => match pick_lines_aux s (SS.remove s ss) sp with | Some p => true | None => false end) ss) (@None SS.elt), SS.In s2 (SS.remove s1 ss) *)
  intros e1 HEW1.
(* Goal: SS.In s2 (SS.remove s1 ss) *)
(* Goal: forall _ : @eq (option SS.elt) (exists_witness (fun s : SS.elt => match pick_lines_aux s (SS.remove s ss) sp with | Some p => true | None => false end) ss) (@None SS.elt), SS.In s2 (SS.remove s1 ss) *)
  rewrite HEW1 in H.
(* Goal: SS.In s2 (SS.remove s1 ss) *)
(* Goal: forall _ : @eq (option SS.elt) (exists_witness (fun s : SS.elt => match pick_lines_aux s (SS.remove s ss) sp with | Some p => true | None => false end) ss) (@None SS.elt), SS.In s2 (SS.remove s1 ss) *)
  unfold pick_lines_aux in H.
(* Goal: SS.In s2 (SS.remove s1 ss) *)
(* Goal: forall _ : @eq (option SS.elt) (exists_witness (fun s : SS.elt => match pick_lines_aux s (SS.remove s ss) sp with | Some p => true | None => false end) ss) (@None SS.elt), SS.In s2 (SS.remove s1 ss) *)
  case_eq (exists_witness (fun s2 : SS.elt => pick_line (S.inter e1 s2) sp) (SS.remove e1 ss)).

(* Goal: forall (e : SS.elt) (_ : @eq (option SS.elt) (exists_witness (fun s2 : SS.elt => pick_line (S.inter e1 s2) sp) (SS.remove e1 ss)) (@Some SS.elt e)), SS.In s2 (SS.remove s1 ss) *)
(* Goal: forall _ : @eq (option SS.elt) (exists_witness (fun s2 : SS.elt => pick_line (S.inter e1 s2) sp) (SS.remove e1 ss)) (@None SS.elt), SS.In s2 (SS.remove s1 ss) *)
(* Goal: forall _ : @eq (option SS.elt) (exists_witness (fun s : SS.elt => match pick_lines_aux s (SS.remove s ss) sp with | Some p => true | None => false end) ss) (@None SS.elt), SS.In s2 (SS.remove s1 ss) *)
    intros e2 HEW2.
(* Goal: SS.In s2 (SS.remove s1 ss) *)
(* Goal: forall _ : @eq (option SS.elt) (exists_witness (fun s : SS.elt => match pick_lines_aux s (SS.remove s ss) sp with | Some p => true | None => false end) ss) (@None SS.elt), SS.In s2 (SS.remove s1 ss) *)
    rewrite HEW2 in H.
(* Goal: SS.In s2 (SS.remove s1 ss) *)
(* Goal: forall _ : @eq (option SS.elt) (exists_witness (fun s2 : SS.elt => pick_line (S.inter e1 s2) sp) (SS.remove e1 ss)) (@None SS.elt), SS.In s2 (SS.remove s1 ss) *)
(* Goal: forall _ : @eq (option SS.elt) (exists_witness (fun s : SS.elt => match pick_lines_aux s (SS.remove s ss) sp with | Some p => true | None => false end) ss) (@None SS.elt), SS.In s2 (SS.remove s1 ss) *)
    assert (HEq1 : e1 = s1) by (injection H; intros; assumption).
(* Goal: SS.In s2 (SS.remove s1 ss) *)
(* Goal: forall _ : @eq (option SS.elt) (exists_witness (fun s2 : SS.elt => pick_line (S.inter e1 s2) sp) (SS.remove e1 ss)) (@None SS.elt), SS.In s2 (SS.remove s1 ss) *)
(* Goal: forall _ : @eq (option SS.elt) (exists_witness (fun s : SS.elt => match pick_lines_aux s (SS.remove s ss) sp with | Some p => true | None => false end) ss) (@None SS.elt), SS.In s2 (SS.remove s1 ss) *)
    rewrite HEq1 in *.
(* Goal: SS.In s2 (SS.remove s1 ss) *)
(* Goal: forall _ : @eq (option SS.elt) (exists_witness (fun s2 : SS.elt => pick_line (S.inter e1 s2) sp) (SS.remove e1 ss)) (@None SS.elt), SS.In s2 (SS.remove s1 ss) *)
(* Goal: forall _ : @eq (option SS.elt) (exists_witness (fun s : SS.elt => match pick_lines_aux s (SS.remove s ss) sp with | Some p => true | None => false end) ss) (@None SS.elt), SS.In s2 (SS.remove s1 ss) *)
    assert (HEq2 : e2 = s2) by (injection H; intros; assumption).
(* Goal: SS.In s2 (SS.remove s1 ss) *)
(* Goal: forall _ : @eq (option SS.elt) (exists_witness (fun s2 : SS.elt => pick_line (S.inter e1 s2) sp) (SS.remove e1 ss)) (@None SS.elt), SS.In s2 (SS.remove s1 ss) *)
(* Goal: forall _ : @eq (option SS.elt) (exists_witness (fun s : SS.elt => match pick_lines_aux s (SS.remove s ss) sp with | Some p => true | None => false end) ss) (@None SS.elt), SS.In s2 (SS.remove s1 ss) *)
    rewrite HEq2 in *.
    apply exists_witness_ok with (fun s : SS.elt =>
      match pick_lines_aux s (SS.remove s ss) sp with | Some _ => true | None => false end).
(* Goal: @Proper (forall _ : S.t, bool) (@respectful S.t bool S.Equal (@eq bool)) (fun s2 : SS.elt => pick_line (S.inter s1 s2) sp) *)
(* Goal: @eq (option SS.elt) (exists_witness (fun s2 : SS.elt => pick_line (S.inter s1 s2) sp) (SS.remove s1 ss)) (@Some SS.elt s2) *)
(* Goal: forall _ : @eq (option SS.elt) (exists_witness (fun s2 : SS.elt => pick_line (S.inter e1 s2) sp) (SS.remove e1 ss)) (@None SS.elt), SS.In s2 (SS.remove s1 ss) *)
(* Goal: forall _ : @eq (option SS.elt) (exists_witness (fun s : SS.elt => match pick_lines_aux s (SS.remove s ss) sp with | Some p => true | None => false end) ss) (@None SS.elt), SS.In s2 (SS.remove s1 ss) *)
    intros x y HXY.
    assert (SS.Equal (SS.remove x ss) (SS.remove y ss))
      by (apply SSWP.Dec.F.remove_m; try assumption; reflexivity).
(* Goal: @eq bool match pick_lines_aux x (SS.remove x ss) sp with | Some p => true | None => false end match pick_lines_aux y (SS.remove y ss) sp with | Some p => true | None => false end *)
(* Goal: @eq (option SS.elt) (exists_witness (fun s : SS.elt => match pick_lines_aux s (SS.remove s ss) sp with | Some p => true | None => false end) ss) (@Some SS.elt s1) *)
(* Goal: forall _ : @eq (option SS.elt) (exists_witness (fun s2 : SS.elt => pick_line (S.inter e1 s2) sp) (SS.remove e1 ss)) (@None SS.elt), SS.In s1 ss *)
(* Goal: forall _ : @eq (option SS.elt) (exists_witness (fun s : SS.elt => match pick_lines_aux s (SS.remove s ss) sp with | Some p => true | None => false end) ss) (@None SS.elt), SS.In s1 ss *)
    assert (eqopp (pick_lines_aux x (SS.remove x ss) sp) (pick_lines_aux y (SS.remove y ss) sp)).
(* Goal: eqopp (pick_lines_aux x (SS.remove x ss) sp) (pick_lines_aux y (SS.remove y ss) sp) *)
(* Goal: @eq bool match pick_lines_aux x (SS.remove x ss) sp with | Some p => true | None => false end match pick_lines_aux y (SS.remove y ss) sp with | Some p => true | None => false end *)
(* Goal: @eq (option SS.elt) (exists_witness (fun s : SS.elt => match pick_lines_aux s (SS.remove s ss) sp with | Some p => true | None => false end) ss) (@Some SS.elt s1) *)
(* Goal: forall _ : @eq (option SS.elt) (exists_witness (fun s2 : SS.elt => pick_line (S.inter e1 s2) sp) (SS.remove e1 ss)) (@None SS.elt), SS.In s1 ss *)
(* Goal: forall _ : @eq (option SS.elt) (exists_witness (fun s : SS.elt => match pick_lines_aux s (SS.remove s ss) sp with | Some p => true | None => false end) ss) (@None SS.elt), SS.In s1 ss *)
    apply proper_3; auto.
    case_eq (pick_lines_aux x (SS.remove x ss) sp);
      intros;
      case_eq (pick_lines_aux y (SS.remove y ss) sp);
(* Goal: forall (p1 p2 p3 : S.elt) (_ : @eq bool (andb (andb (S.mem p1 s') (S.mem p2 s')) (S.mem p3 s')) true), CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
      intros.
(* Goal: @eq bool (negb (Pos.eqb (fstpp y) p)) (negb (Pos.eqb (fstpp y) p)) *)
      reflexivity.

(* Goal: @eq bool false true *)
(* Goal: @eq bool false false *)
(* Goal: @eq (option SS.elt) (exists_witness (fun s : SS.elt => match pick_lines_aux s (SS.remove s ss) sp with | Some p => true | None => false end) ss) (@Some SS.elt s1) *)
(* Goal: forall _ : @eq (option SS.elt) (exists_witness (fun s2 : SS.elt => pick_line (S.inter e1 s2) sp) (SS.remove e1 ss)) (@None SS.elt), SS.In s1 ss *)
(* Goal: forall _ : @eq (option SS.elt) (exists_witness (fun s : SS.elt => match pick_lines_aux s (SS.remove s ss) sp with | Some p => true | None => false end) ss) (@None SS.elt), SS.In s1 ss *)
      rewrite H2 in H1; rewrite H3 in H1.
(* Goal: @eq bool false true *)
(* Goal: @eq bool false false *)
(* Goal: @eq (option SS.elt) (exists_witness (fun s : SS.elt => match pick_lines_aux s (SS.remove s ss) sp with | Some p => true | None => false end) ss) (@Some SS.elt s1) *)
(* Goal: forall _ : @eq (option SS.elt) (exists_witness (fun s2 : SS.elt => pick_line (S.inter e1 s2) sp) (SS.remove e1 ss)) (@None SS.elt), SS.In s1 ss *)
(* Goal: forall _ : @eq (option SS.elt) (exists_witness (fun s : SS.elt => match pick_lines_aux s (SS.remove s ss) sp with | Some p => true | None => false end) ss) (@None SS.elt), SS.In s1 ss *)
      unfold eqop in H1; simpl in H1.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
      intuition.
(* Goal: @eq bool false true *)
(* Goal: @eq bool false false *)
(* Goal: @eq (option SS.elt) (exists_witness (fun s : SS.elt => match pick_lines_aux s (SS.remove s ss) sp with | Some p => true | None => false end) ss) (@Some SS.elt s1) *)
(* Goal: forall _ : @eq (option SS.elt) (exists_witness (fun s2 : SS.elt => pick_line (S.inter e1 s2) sp) (SS.remove e1 ss)) (@None SS.elt), SS.In s1 ss *)
(* Goal: forall _ : @eq (option SS.elt) (exists_witness (fun s : SS.elt => match pick_lines_aux s (SS.remove s ss) sp with | Some p => true | None => false end) ss) (@None SS.elt), SS.In s1 ss *)
      rewrite H2 in H1; rewrite H3 in H1.
(* Goal: @eq bool false true *)
(* Goal: @eq bool false false *)
(* Goal: @eq (option SS.elt) (exists_witness (fun s : SS.elt => match pick_lines_aux s (SS.remove s ss) sp with | Some p => true | None => false end) ss) (@Some SS.elt s1) *)
(* Goal: forall _ : @eq (option SS.elt) (exists_witness (fun s2 : SS.elt => pick_line (S.inter e1 s2) sp) (SS.remove e1 ss)) (@None SS.elt), SS.In s1 ss *)
(* Goal: forall _ : @eq (option SS.elt) (exists_witness (fun s : SS.elt => match pick_lines_aux s (SS.remove s ss) sp with | Some p => true | None => false end) ss) (@None SS.elt), SS.In s1 ss *)
      unfold eqop in H1; simpl in H1.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
      intuition.
(* Goal: @eq bool (negb (Pos.eqb (fstpp y) p)) (negb (Pos.eqb (fstpp y) p)) *)
      reflexivity.

(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    assumption.

(* Goal: forall _ : @eq (option SS.elt) (exists_witness (fun s2 : SS.elt => pick_line (S.inter e1 s2) sp) (SS.remove e1 ss)) (@None SS.elt), SS.In s2 (SS.remove s1 ss) *)
(* Goal: forall _ : @eq (option SS.elt) (exists_witness (fun s : SS.elt => match pick_lines_aux s (SS.remove s ss) sp with | Some p => true | None => false end) ss) (@None SS.elt), SS.In s2 (SS.remove s1 ss) *)
    intro HEW2.
(* Goal: SS.In s2 (SS.remove s1 ss) *)
(* Goal: forall _ : @eq (option SS.elt) (exists_witness (fun s : SS.elt => match pick_lines_aux s (SS.remove s ss) sp with | Some p => true | None => false end) ss) (@None SS.elt), SS.In s2 (SS.remove s1 ss) *)
    rewrite HEW2 in H.
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    discriminate.

(* Goal: forall _ : @eq (option SS.elt) (exists_witness (fun s : SS.elt => match pick_lines_aux s (SS.remove s ss) sp with | Some p => true | None => false end) ss) (@None SS.elt), SS.In s2 (SS.remove s1 ss) *)
  intro HEW.
(* Goal: SS.In s2 (SS.remove s1 ss) *)
  rewrite HEW in H.
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
  discriminate.
Qed.

Lemma pick_lines_ok_2 : forall s1 s2 ss sp,
  pick_lines ss sp = Some(s1,s2) ->
  SS.In s2 (SS.remove s1 ss).
Proof.
(* Goal: forall (s1 s2 : SS.elt) (ss : SS.t) (sp : SP.t) (_ : @eq (option (prod SS.elt SS.elt)) (pick_lines ss sp) (@Some (prod SS.elt SS.elt) (@pair SS.elt SS.elt s1 s2))), SS.In s2 (SS.remove s1 ss) *)
intros s1 s2 ss sp H.
(* Goal: SS.In s2 (SS.remove s1 ss) *)
unfold pick_lines in H.
case_eq (exists_witness (fun s : SS.elt => match pick_lines_aux s
                          (SS.remove s ss) sp with | Some _ => true | None => false end) ss).

(* Goal: forall (e : SS.elt) (_ : @eq (option SS.elt) (exists_witness (fun s : SS.elt => match pick_lines_aux s (SS.remove s ss) sp with | Some p => true | None => false end) ss) (@Some SS.elt e)), SS.In s2 (SS.remove s1 ss) *)
(* Goal: forall _ : @eq (option SS.elt) (exists_witness (fun s : SS.elt => match pick_lines_aux s (SS.remove s ss) sp with | Some p => true | None => false end) ss) (@None SS.elt), SS.In s2 (SS.remove s1 ss) *)
  intros e1 HEW1.
(* Goal: SS.In s2 (SS.remove s1 ss) *)
(* Goal: forall _ : @eq (option SS.elt) (exists_witness (fun s : SS.elt => match pick_lines_aux s (SS.remove s ss) sp with | Some p => true | None => false end) ss) (@None SS.elt), SS.In s2 (SS.remove s1 ss) *)
  rewrite HEW1 in H.
(* Goal: SS.In s2 (SS.remove s1 ss) *)
(* Goal: forall _ : @eq (option SS.elt) (exists_witness (fun s : SS.elt => match pick_lines_aux s (SS.remove s ss) sp with | Some p => true | None => false end) ss) (@None SS.elt), SS.In s2 (SS.remove s1 ss) *)
  unfold pick_lines_aux in H.
(* Goal: SS.In s2 (SS.remove s1 ss) *)
(* Goal: forall _ : @eq (option SS.elt) (exists_witness (fun s : SS.elt => match pick_lines_aux s (SS.remove s ss) sp with | Some p => true | None => false end) ss) (@None SS.elt), SS.In s2 (SS.remove s1 ss) *)
  case_eq (exists_witness (fun s2 : SS.elt => pick_line (S.inter e1 s2) sp) (SS.remove e1 ss)).

(* Goal: forall (e : SS.elt) (_ : @eq (option SS.elt) (exists_witness (fun s2 : SS.elt => pick_line (S.inter e1 s2) sp) (SS.remove e1 ss)) (@Some SS.elt e)), SS.In s2 (SS.remove s1 ss) *)
(* Goal: forall _ : @eq (option SS.elt) (exists_witness (fun s2 : SS.elt => pick_line (S.inter e1 s2) sp) (SS.remove e1 ss)) (@None SS.elt), SS.In s2 (SS.remove s1 ss) *)
(* Goal: forall _ : @eq (option SS.elt) (exists_witness (fun s : SS.elt => match pick_lines_aux s (SS.remove s ss) sp with | Some p => true | None => false end) ss) (@None SS.elt), SS.In s2 (SS.remove s1 ss) *)
    intros e2 HEW2.
(* Goal: SS.In s2 (SS.remove s1 ss) *)
(* Goal: forall _ : @eq (option SS.elt) (exists_witness (fun s : SS.elt => match pick_lines_aux s (SS.remove s ss) sp with | Some p => true | None => false end) ss) (@None SS.elt), SS.In s2 (SS.remove s1 ss) *)
    rewrite HEW2 in H.
(* Goal: SS.In s2 (SS.remove s1 ss) *)
(* Goal: forall _ : @eq (option SS.elt) (exists_witness (fun s2 : SS.elt => pick_line (S.inter e1 s2) sp) (SS.remove e1 ss)) (@None SS.elt), SS.In s2 (SS.remove s1 ss) *)
(* Goal: forall _ : @eq (option SS.elt) (exists_witness (fun s : SS.elt => match pick_lines_aux s (SS.remove s ss) sp with | Some p => true | None => false end) ss) (@None SS.elt), SS.In s2 (SS.remove s1 ss) *)
    assert (HEq1 : e1 = s1) by (injection H; intros; assumption).
(* Goal: SS.In s2 (SS.remove s1 ss) *)
(* Goal: forall _ : @eq (option SS.elt) (exists_witness (fun s2 : SS.elt => pick_line (S.inter e1 s2) sp) (SS.remove e1 ss)) (@None SS.elt), SS.In s2 (SS.remove s1 ss) *)
(* Goal: forall _ : @eq (option SS.elt) (exists_witness (fun s : SS.elt => match pick_lines_aux s (SS.remove s ss) sp with | Some p => true | None => false end) ss) (@None SS.elt), SS.In s2 (SS.remove s1 ss) *)
    rewrite HEq1 in *.
(* Goal: SS.In s2 (SS.remove s1 ss) *)
(* Goal: forall _ : @eq (option SS.elt) (exists_witness (fun s2 : SS.elt => pick_line (S.inter e1 s2) sp) (SS.remove e1 ss)) (@None SS.elt), SS.In s2 (SS.remove s1 ss) *)
(* Goal: forall _ : @eq (option SS.elt) (exists_witness (fun s : SS.elt => match pick_lines_aux s (SS.remove s ss) sp with | Some p => true | None => false end) ss) (@None SS.elt), SS.In s2 (SS.remove s1 ss) *)
    assert (HEq2 : e2 = s2) by (injection H; intros; assumption).
(* Goal: SS.In s2 (SS.remove s1 ss) *)
(* Goal: forall _ : @eq (option SS.elt) (exists_witness (fun s2 : SS.elt => pick_line (S.inter e1 s2) sp) (SS.remove e1 ss)) (@None SS.elt), SS.In s2 (SS.remove s1 ss) *)
(* Goal: forall _ : @eq (option SS.elt) (exists_witness (fun s : SS.elt => match pick_lines_aux s (SS.remove s ss) sp with | Some p => true | None => false end) ss) (@None SS.elt), SS.In s2 (SS.remove s1 ss) *)
    rewrite HEq2 in *.
(* Goal: SS.In s2 (SS.remove s1 ss) *)
(* Goal: forall _ : @eq (option SS.elt) (exists_witness (fun s2 : SS.elt => pick_line (S.inter e1 s2) sp) (SS.remove e1 ss)) (@None SS.elt), SS.In s2 (SS.remove s1 ss) *)
(* Goal: forall _ : @eq (option SS.elt) (exists_witness (fun s : SS.elt => match pick_lines_aux s (SS.remove s ss) sp with | Some p => true | None => false end) ss) (@None SS.elt), SS.In s2 (SS.remove s1 ss) *)
    apply exists_witness_ok with (fun s2 : SS.elt => pick_line (S.inter s1 s2) sp).
(* Goal: @Proper (forall _ : S.t, bool) (@respectful S.t bool S.Equal (@eq bool)) (fun s2 : SS.elt => pick_line (S.inter s1 s2) sp) *)
(* Goal: @eq (option SS.elt) (exists_witness (fun s2 : SS.elt => pick_line (S.inter s1 s2) sp) (SS.remove s1 ss)) (@Some SS.elt s2) *)
(* Goal: forall _ : @eq (option SS.elt) (exists_witness (fun s2 : SS.elt => pick_line (S.inter e1 s2) sp) (SS.remove e1 ss)) (@None SS.elt), SS.In s2 (SS.remove s1 ss) *)
(* Goal: forall _ : @eq (option SS.elt) (exists_witness (fun s : SS.elt => match pick_lines_aux s (SS.remove s ss) sp with | Some p => true | None => false end) ss) (@None SS.elt), SS.In s2 (SS.remove s1 ss) *)
    intros x y HXY.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    apply proper_1; assumption.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    assumption.

(* Goal: forall _ : @eq (option SS.elt) (exists_witness (fun s2 : SS.elt => pick_line (S.inter e1 s2) sp) (SS.remove e1 ss)) (@None SS.elt), SS.In s2 (SS.remove s1 ss) *)
(* Goal: forall _ : @eq (option SS.elt) (exists_witness (fun s : SS.elt => match pick_lines_aux s (SS.remove s ss) sp with | Some p => true | None => false end) ss) (@None SS.elt), SS.In s2 (SS.remove s1 ss) *)
    intro HEW2.
(* Goal: SS.In s2 (SS.remove s1 ss) *)
(* Goal: forall _ : @eq (option SS.elt) (exists_witness (fun s : SS.elt => match pick_lines_aux s (SS.remove s ss) sp with | Some p => true | None => false end) ss) (@None SS.elt), SS.In s2 (SS.remove s1 ss) *)
    rewrite HEW2 in H.
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    discriminate.

(* Goal: forall _ : @eq (option SS.elt) (exists_witness (fun s : SS.elt => match pick_lines_aux s (SS.remove s ss) sp with | Some p => true | None => false end) ss) (@None SS.elt), SS.In s2 (SS.remove s1 ss) *)
  intro HEW.
(* Goal: SS.In s2 (SS.remove s1 ss) *)
  rewrite HEW in H.
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
  discriminate.
Qed.

Function identify_lines (ss : SS.t) (sp : SP.t) {measure SS.cardinal ss}
                        : SS.t :=
  let lines := pick_lines ss sp in
    match lines with
      |None => ss
      |Some (s1,s2) => let auxsetofsets := SS.remove s2 (SS.remove s1 ss) in
                       let auxset := S.union s1 s2 in
                       let newss := SS.add auxset auxsetofsets in
                         identify_lines newss sp
    end.
Proof.
(* Goal: forall (p1 p2 p3 : S.elt) (_ : @eq bool (andb (andb (S.mem p1 s') (S.mem p2 s')) (S.mem p3 s')) true), CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
intros.
(* Goal: lt (SS.cardinal (SS.add (S.union s1 s2) (SS.remove s2 (SS.remove s1 ss)))) (SS.cardinal ss) *)
assert (S(SS.cardinal (SS.remove s1 ss)) = SS.cardinal ss).
(* Goal: @eq nat (S (SS.cardinal (SS.remove s2 (SS.remove s1 ss)))) (SS.cardinal (SS.remove s1 ss)) *)
(* Goal: lt (SS.cardinal (SS.add (S.union s1 s2) (SS.remove s2 (SS.remove s1 ss)))) (SS.cardinal ss) *)
apply SSWP.remove_cardinal_1.
(* Goal: SS.In s1 ss *)
(* Goal: lt (SS.cardinal (SS.add (S.union s1 s2) (SS.remove s2 (SS.remove s1 ss)))) (SS.cardinal ss) *)
apply pick_lines_ok_1 with s2 sp.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
assumption.
(* Goal: lt (SS.cardinal (SS.add (S.union s1 s2) (SS.remove s2 (SS.remove s1 ss)))) (SS.cardinal ss) *)
assert (S(S(SS.cardinal (SS.remove s2 (SS.remove s1 ss)))) = S(SS.cardinal (SS.remove s1 ss))).
(* Goal: @eq nat (S (S (SS.cardinal (SS.remove s2 (SS.remove s1 ss))))) (S (SS.cardinal (SS.remove s1 ss))) *)
(* Goal: lt (SS.cardinal (SS.add (S.union s1 s2) (SS.remove s2 (SS.remove s1 ss)))) (SS.cardinal ss) *)
apply eq_S.
(* Goal: @eq nat (S (SS.cardinal (SS.remove s2 (SS.remove s1 ss)))) (SS.cardinal (SS.remove s1 ss)) *)
(* Goal: lt (SS.cardinal (SS.add (S.union s1 s2) (SS.remove s2 (SS.remove s1 ss)))) (SS.cardinal ss) *)
apply SSWP.remove_cardinal_1.
(* Goal: SS.In s2 (SS.remove s1 ss) *)
(* Goal: lt (SS.cardinal (SS.add (S.union s1 s2) (SS.remove s2 (SS.remove s1 ss)))) (SS.cardinal ss) *)
apply pick_lines_ok_2 with sp.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
assumption.
(* Goal: lt (SS.cardinal (SS.add (S.union s1 s2) (SS.remove s2 (SS.remove s1 ss)))) (SS.cardinal ss) *)
assert (HR1 : S(S(SS.cardinal (SS.remove s2 (SS.remove s1 ss)))) = SS.cardinal ss).
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
transitivity (S(SS.cardinal (SS.remove s1 ss))); assumption.
(* Goal: lt (SS.cardinal (SS.add (S.union s1 s2) (SS.remove s2 (SS.remove s1 ss)))) (SS.cardinal ss) *)
elim (SSWP.In_dec (S.union s1 s2) (SS.remove s2 (SS.remove s1 ss))); intro HDec.

(* Goal: lt (SS.cardinal (SS.add (S.union s1 s2) (SS.remove s2 (SS.remove s1 ss)))) (SS.cardinal ss) *)
(* Goal: lt (SS.cardinal (SS.add (S.union s1 s2) (SS.remove s2 (SS.remove s1 ss)))) (SS.cardinal ss) *)
  assert (HR2 : SS.cardinal (SS.add (S.union s1 s2) (SS.remove s2 (SS.remove s1 ss))) = SS.cardinal (SS.remove s2 (SS.remove s1 ss))).
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
  apply SSWP.add_cardinal_1; assumption.
(* Goal: lt (SS.cardinal (SS.add (S.union s1 s2) (SS.remove s2 (SS.remove s1 ss)))) (SS.cardinal ss) *)
  rewrite HR2.
(* Goal: lt (S (SS.cardinal (SS.remove s2 (SS.remove s1 ss)))) (SS.cardinal ss) *)
  rewrite <- HR1.
(* Goal: lt (SS.cardinal (SS.remove s2 (SS.remove s1 ss))) (S (S (SS.cardinal (SS.remove s2 (SS.remove s1 ss))))) *)
(* Goal: lt (SS.cardinal (SS.add (S.union s1 s2) (SS.remove s2 (SS.remove s1 ss)))) (SS.cardinal ss) *)
  apply le_S;apply le_n.

(* Goal: lt (SS.cardinal (SS.add (S.union s1 s2) (SS.remove s2 (SS.remove s1 ss)))) (SS.cardinal ss) *)
  assert (HR2 : SS.cardinal (SS.add (S.union s1 s2) (SS.remove s2 (SS.remove s1 ss))) = S( SS.cardinal (SS.remove s2 (SS.remove s1 ss)))).
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
  apply SSWP.add_cardinal_2; assumption.
(* Goal: lt (SS.cardinal (SS.add (S.union s1 s2) (SS.remove s2 (SS.remove s1 ss)))) (SS.cardinal ss) *)
  rewrite HR2.
(* Goal: lt (S (SS.cardinal (SS.remove s2 (SS.remove s1 ss)))) (SS.cardinal ss) *)
  rewrite <- HR1.
(* Goal: lt (S (SS.cardinal (SS.remove s2 (SS.remove s1 ss)))) (S (S (SS.cardinal (SS.remove s2 (SS.remove s1 ss))))) *)
  apply le_n.
Defined.

Definition test_col (ss : SS.t) (sp : SP.t) p1 p2 p3 : bool :=
  let newss := identify_lines ss sp  in
    SS.exists_ (fun s => S.mem p1 s && S.mem p2 s && S.mem p3 s) newss.

Section Col_refl.

Context `{CT:Col_theory}.

Lemma CTcol_permutation_5 : forall A B C : COLTpoint, CTCol A B C -> CTCol A C B.
Proof.
(* Goal: CTCol A B B *)
apply CTcol_permutation_2.
Qed.

Lemma CTcol_permutation_2 : forall A B C : COLTpoint, CTCol A B C -> CTCol C A B.
Proof.
(* Goal: forall (p1 p2 p3 : S.elt) (_ : @eq bool (andb (andb (S.mem p1 s') (S.mem p2 s')) (S.mem p3 s')) true), CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
intros.
(* Goal: CTCol B C A *)
apply CTcol_permutation_1.
(* Goal: CTCol B C A *)
apply CTcol_permutation_1.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
assumption.
Qed.

Lemma CTcol_permutation_3 : forall A B C : COLTpoint, CTCol A B C -> CTCol C B A.
Proof.
(* Goal: forall (p1 p2 p3 : S.elt) (_ : @eq bool (andb (andb (S.mem p1 s') (S.mem p2 s')) (S.mem p3 s')) true), CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
intros.
(* Goal: CTCol B A C *)
apply CTcol_permutation_5.
(* Goal: CTCol A B B *)
apply CTcol_permutation_2.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
assumption.
Qed.

Lemma CTcol_permutation_4 : forall A B C : COLTpoint, CTCol A B C -> CTCol B A C.
Proof.
(* Goal: forall (p1 p2 p3 : S.elt) (_ : @eq bool (andb (andb (S.mem p1 s') (S.mem p2 s')) (S.mem p3 s')) true), CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
intros.
(* Goal: CTCol B A C *)
apply CTcol_permutation_5.
(* Goal: CTCol B C A *)
apply CTcol_permutation_1.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
assumption.
Qed.

Lemma CTcol_trivial_1 : forall A B : COLTpoint, CTCol A A B.
Proof.
(* Goal: forall A B : COLTpoint, CTCol A A B *)
apply CTcol_trivial.
Qed.

Lemma CTcol_trivial_2 : forall A B : COLTpoint, CTCol A B B.
Proof.
(* Goal: forall (p1 p2 p3 : S.elt) (_ : @eq bool (andb (andb (S.mem p1 s') (S.mem p2 s')) (S.mem p3 s')) true), CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
intros.
(* Goal: CTCol A B B *)
apply CTcol_permutation_2.
(* Goal: CTCol (interp p2) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
apply CTcol_trivial_1.
Qed.

Definition ss_ok (ss : SS.t) (interp: positive -> COLTpoint) :=
  forall s, SS.mem s ss = true ->
  forall p1 p2 p3, S.mem p1 s && S.mem p2 s && S.mem p3 s = true ->
    CTCol (interp p1) (interp p2) (interp p3).

Definition sp_ok (sp : SP.t) (interp: positive -> COLTpoint) :=
  forall p, SP.mem p sp = true -> interp (fstpp p) <> interp (sndpp p).

Lemma identify_lines_ok : forall ss sp interp,
  ss_ok ss interp -> sp_ok sp interp ->
  ss_ok (identify_lines ss sp) interp.
Proof.
(* Goal: forall (ss : SS.t) (sp : SP.t) (interp : forall _ : positive, COLTpoint) (_ : ss_ok ss interp) (_ : sp_ok sp interp), ss_ok (identify_lines ss sp) interp *)
intros ss sp interp HSS HSP.
apply (let P interp ss sp newss :=
       ss_ok ss interp -> sp_ok sp interp -> ss_ok newss interp in
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
         identify_lines_ind (P interp)); try assumption.

(* Goal: forall (p1 p2 p3 : S.elt) (_ : @eq bool (andb (andb (S.mem p1 s') (S.mem p2 s')) (S.mem p3 s')) true), CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
  intros.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
  assumption.

(* Goal: forall (ss : SS.t) (sp : SP.t), let lines := pick_lines ss sp in forall (s1 s2 : SS.elt) (_ : @eq (option (prod SS.elt SS.elt)) lines (@Some (prod SS.elt SS.elt) (@pair SS.elt SS.elt s1 s2))), let auxsetofsets := SS.remove s2 (SS.remove s1 ss) in let auxset := S.union s1 s2 in let newss := SS.add auxset auxsetofsets in forall (_ : forall (_ : ss_ok newss interp) (_ : sp_ok sp interp), ss_ok (identify_lines newss sp) interp) (_ : ss_ok ss interp) (_ : sp_ok sp interp), ss_ok (identify_lines newss sp) interp *)
  clear HSS; clear HSP; clear ss; clear sp.
(* Goal: forall (ss : SS.t) (sp : SP.t), let lines := pick_lines ss sp in forall (s1 s2 : SS.elt) (_ : @eq (option (prod SS.elt SS.elt)) lines (@Some (prod SS.elt SS.elt) (@pair SS.elt SS.elt s1 s2))), let auxsetofsets := SS.remove s2 (SS.remove s1 ss) in let auxset := S.union s1 s2 in let newss := SS.add auxset auxsetofsets in forall (_ : forall (_ : ss_ok newss interp) (_ : sp_ok sp interp), ss_ok (identify_lines newss sp) interp) (_ : ss_ok ss interp) (_ : sp_ok sp interp), ss_ok (identify_lines newss sp) interp *)
  intros ss sp suitablepairofsets s1 s2 Hs1s2 auxsetofsets auxset newss H HSS HSP.
(* Goal: ss_ok (identify_lines newss sp) interp *)
  assert (Hs1 := Hs1s2).
(* Goal: ss_ok (identify_lines newss sp) interp *)
  assert (Hs2 := Hs1s2).
(* Goal: ss_ok (identify_lines newss sp) interp *)
  apply pick_lines_ok_1 in Hs1.
(* Goal: ss_ok (identify_lines newss sp) interp *)
  apply pick_lines_ok_2 in Hs2.
(* Goal: ss_ok (identify_lines newss sp) interp *)
  apply SSWEqP.MP.Dec.F.remove_3 in Hs2.
(* Goal: ss_ok (identify_lines newss sp) interp *)
  apply H; try assumption; clear H.
(* Goal: ss_ok newss interp *)
  intros s Hmem p1 p2 p3 Hmemp.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
  do 2 (rewrite andb_true_iff in Hmemp).
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
  destruct Hmemp as [[Hmemp1 Hmemp2] Hmemp3].
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
  unfold newss in Hmem; clear newss.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
  elim (SS.E.eq_dec auxset s); intro HEq.

(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
    rewrite <- HEq in *; clear HEq; clear s.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
    unfold suitablepairofsets in Hs1s2; clear suitablepairofsets.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
    unfold pick_lines in Hs1s2.
    case_eq (exists_witness
            (fun s : SS.elt =>
             match pick_lines_aux s (SS.remove s ss) sp with
             | Some _ => true
             | None => false
             end) ss); try (intro HEW; rewrite HEW in *; discriminate).
(* Goal: forall (e : SS.elt) (_ : @eq (option SS.elt) (exists_witness (fun s : SS.elt => match pick_lines_aux s (SS.remove s ss) sp with | Some p => true | None => false end) ss) (@Some SS.elt e)), CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
    intros e1 HEW; rewrite HEW in *; clear HEW.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
    unfold pick_lines_aux in *.
    case_eq (exists_witness
            (fun s2 : SS.elt => pick_line (S.inter e1 s2) sp)
            (SS.remove e1 ss)); try (intro HEW; rewrite HEW in *; discriminate).
(* Goal: forall (e : SS.elt) (_ : @eq (option SS.elt) (exists_witness (fun s2 : SS.elt => pick_line (S.inter e1 s2) sp) (SS.remove e1 ss)) (@Some SS.elt e)), CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
    intros e2 HEW; rewrite HEW in *.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
    injection Hs1s2; intros He2s2 He1s1.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
    rewrite He2s2 in *; rewrite He1s1 in *; clear He2s2; clear He1s1; clear Hs1s2; clear e2; clear e1.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
    case_eq (pick_line (S.inter s1 s2) sp).

(* Goal: forall _ : @eq (option SS.elt) (exists_witness (fun s : SS.elt => match pick_lines_aux s (SS.remove s ss) sp with | Some p => true | None => false end) ss) (@None SS.elt), SS.In s2 (SS.remove s1 ss) *)
      clear HEW; intro HEW.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: forall _ : @eq bool (pick_line (S.inter s1 s2) sp) false, CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
      unfold pick_line in HEW.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: forall _ : @eq bool (pick_line (S.inter s1 s2) sp) false, CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
      apply SPWEqP.exists_mem_4 in HEW; try (apply proper_00).
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: forall _ : @eq bool (pick_line (S.inter s1 s2) sp) false, CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
      destruct HEW as [x [HmemSP HmemS]].
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: forall _ : @eq bool (pick_line (S.inter s1 s2) sp) false, CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
      rewrite andb_true_iff in HmemS; destruct HmemS as [Hmemfsts Hmemsnds].
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: forall _ : @eq bool (pick_line (S.inter s1 s2) sp) false, CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
      apply HSP in HmemSP.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: forall _ : @eq bool (pick_line (S.inter s1 s2) sp) false, CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
      apply SWP.Dec.F.mem_2 in Hmemfsts.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: forall _ : @eq bool (pick_line (S.inter s1 s2) sp) false, CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
      apply S.inter_spec in Hmemfsts.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: forall _ : @eq bool (pick_line (S.inter s1 s2) sp) false, CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
      destruct Hmemfsts as [Hfss1 Hfss2].
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: forall _ : @eq bool (pick_line (S.inter s1 s2) sp) false, CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
      apply SWP.Dec.F.mem_2 in Hmemsnds.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: forall _ : @eq bool (pick_line (S.inter s1 s2) sp) false, CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
      apply S.inter_spec in Hmemsnds.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: forall _ : @eq bool (pick_line (S.inter s1 s2) sp) false, CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
      destruct Hmemsnds as [Hsss1 Hsss2].
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: forall _ : @eq bool (pick_line (S.inter s1 s2) sp) false, CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
      unfold auxset in *.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
      apply CTcol3 with (interp (fstpp(x))) (interp (sndpp(x))); try assumption.

(* Goal: CTCol (interp (fstpp x)) (interp (sndpp x)) (interp p1) *)
(* Goal: CTCol (interp (fstpp x)) (interp (sndpp x)) (interp p2) *)
(* Goal: CTCol (interp (fstpp x)) (interp (sndpp x)) (interp p3) *)
(* Goal: forall _ : @eq bool (pick_line (S.inter s1 s2) sp) false, CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
        apply SWP.Dec.F.mem_2 in Hmemp1.
(* Goal: CTCol (interp (fstpp x)) (interp (sndpp x)) (interp p1) *)
(* Goal: CTCol (interp (fstpp x)) (interp (sndpp x)) (interp p2) *)
(* Goal: CTCol (interp (fstpp x)) (interp (sndpp x)) (interp p3) *)
(* Goal: forall _ : @eq bool (pick_line (S.inter s1 s2) sp) false, CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
        apply SWP.Dec.F.union_1 in Hmemp1.
(* Goal: CTCol (interp (fstpp x)) (interp (sndpp x)) (interp p1) *)
(* Goal: CTCol (interp (fstpp x)) (interp (sndpp x)) (interp p2) *)
(* Goal: CTCol (interp (fstpp x)) (interp (sndpp x)) (interp p3) *)
(* Goal: forall _ : @eq bool (pick_line (S.inter s1 s2) sp) false, CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
        elim (Hmemp1); intro HInp1.

(* Goal: CTCol (interp (fstpp x)) (interp (sndpp x)) (interp p3) *)
(* Goal: CTCol (interp (fstpp x)) (interp (sndpp x)) (interp p3) *)
(* Goal: forall _ : @eq bool (pick_line (S.inter s1 s2) sp) false, CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          apply HSS with s1.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
          apply SSWP.Dec.F.mem_1; assumption.
(* Goal: @eq bool (andb (andb (S.mem p1 s) (S.mem p2 s)) (S.mem p3 s)) true *)
          do 2 (rewrite andb_true_iff).
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
          repeat split; apply SWP.Dec.F.mem_1; assumption.

(* Goal: CTCol (interp (fstpp x)) (interp (sndpp x)) (interp p3) *)
(* Goal: forall _ : @eq bool (pick_line (S.inter s1 s2) sp) false, CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          apply HSS with s2.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
          apply SSWP.Dec.F.mem_1; assumption.
(* Goal: @eq bool (andb (andb (S.mem p1 s) (S.mem p2 s)) (S.mem p3 s)) true *)
          do 2 (rewrite andb_true_iff).
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
          repeat split; apply SWP.Dec.F.mem_1; assumption.

(* Goal: CTCol (interp (fstpp x)) (interp (sndpp x)) (interp p2) *)
(* Goal: CTCol (interp (fstpp x)) (interp (sndpp x)) (interp p3) *)
(* Goal: forall _ : @eq bool (pick_line (S.inter s1 s2) sp) false, CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
        apply SWP.Dec.F.mem_2 in Hmemp2.
(* Goal: CTCol (interp (fstpp x)) (interp (sndpp x)) (interp p2) *)
(* Goal: CTCol (interp (fstpp x)) (interp (sndpp x)) (interp p3) *)
(* Goal: forall _ : @eq bool (pick_line (S.inter s1 s2) sp) false, CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
        apply SWP.Dec.F.union_1 in Hmemp2.
(* Goal: CTCol (interp (fstpp x)) (interp (sndpp x)) (interp p2) *)
(* Goal: CTCol (interp (fstpp x)) (interp (sndpp x)) (interp p3) *)
(* Goal: forall _ : @eq bool (pick_line (S.inter s1 s2) sp) false, CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
        elim (Hmemp2); intro HInp2.

(* Goal: CTCol (interp (fstpp x)) (interp (sndpp x)) (interp p3) *)
(* Goal: CTCol (interp (fstpp x)) (interp (sndpp x)) (interp p3) *)
(* Goal: forall _ : @eq bool (pick_line (S.inter s1 s2) sp) false, CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          apply HSS with s1.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
          apply SSWP.Dec.F.mem_1; assumption.
(* Goal: @eq bool (andb (andb (S.mem p1 s) (S.mem p2 s)) (S.mem p3 s)) true *)
          do 2 (rewrite andb_true_iff).
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
          repeat split; apply SWP.Dec.F.mem_1; assumption.

(* Goal: CTCol (interp (fstpp x)) (interp (sndpp x)) (interp p3) *)
(* Goal: forall _ : @eq bool (pick_line (S.inter s1 s2) sp) false, CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          apply HSS with s2.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
          apply SSWP.Dec.F.mem_1; assumption.
(* Goal: @eq bool (andb (andb (S.mem p1 s) (S.mem p2 s)) (S.mem p3 s)) true *)
          do 2 (rewrite andb_true_iff).
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
          repeat split; apply SWP.Dec.F.mem_1; assumption.

(* Goal: CTCol (interp (fstpp x)) (interp (sndpp x)) (interp p3) *)
(* Goal: forall _ : @eq bool (pick_line (S.inter s1 s2) sp) false, CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
        apply SWP.Dec.F.mem_2 in Hmemp3.
(* Goal: CTCol (interp (fstpp x)) (interp (sndpp x)) (interp p3) *)
(* Goal: forall _ : @eq bool (pick_line (S.inter s1 s2) sp) false, CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
        apply SWP.Dec.F.union_1 in Hmemp3.
(* Goal: CTCol (interp (fstpp x)) (interp (sndpp x)) (interp p3) *)
(* Goal: forall _ : @eq bool (pick_line (S.inter s1 s2) sp) false, CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
        elim (Hmemp3); intro HInp3.

(* Goal: CTCol (interp (fstpp x)) (interp (sndpp x)) (interp p3) *)
(* Goal: CTCol (interp (fstpp x)) (interp (sndpp x)) (interp p3) *)
(* Goal: forall _ : @eq bool (pick_line (S.inter s1 s2) sp) false, CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          apply HSS with s1.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
          apply SSWP.Dec.F.mem_1; assumption.
(* Goal: @eq bool (andb (andb (S.mem p1 s) (S.mem p2 s)) (S.mem p3 s)) true *)
          do 2 (rewrite andb_true_iff).
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
          repeat split; apply SWP.Dec.F.mem_1; assumption.

(* Goal: CTCol (interp (fstpp x)) (interp (sndpp x)) (interp p3) *)
(* Goal: forall _ : @eq bool (pick_line (S.inter s1 s2) sp) false, CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          apply HSS with s2.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
          apply SSWP.Dec.F.mem_1; assumption.
(* Goal: @eq bool (andb (andb (S.mem p1 s) (S.mem p2 s)) (S.mem p3 s)) true *)
          do 2 (rewrite andb_true_iff).
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
          repeat split; apply SWP.Dec.F.mem_1; assumption.

(* Goal: forall _ : @eq bool (pick_line (S.inter s1 s2) sp) false, CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
      intro HEW2; unfold exists_witness in *; apply SS.choose_spec1 in HEW.
(* Goal: @Proper (forall _ : S.t, bool) (@respectful S.t bool S.Equal (@eq bool)) (fun s2 : SS.elt => pick_line (S.inter y1 s2) y3) *)
(* Goal: forall x : SS.elt, @eq bool (pick_line (S.inter x1 x) y3) (pick_line (S.inter y1 x) y3) *)
(* Goal: SS.Equal x2 y2 *)
(* Goal: eqopp match exists_witness (fun s2 : SS.elt => pick_line (S.inter x1 s2) y3) x2 with | Some s2 => @Some (prod SS.elt SS.elt) (@pair SS.elt SS.elt x1 s2) | None => @None (prod SS.elt SS.elt) end match exists_witness (fun s2 : SS.elt => pick_line (S.inter y1 s2) y3) y2 with | Some s2 => @Some (prod SS.elt SS.elt) (@pair SS.elt SS.elt y1 s2) | None => @None (prod SS.elt SS.elt) end *)
      apply SSWEqP.MP.Dec.F.filter_2 in HEW; try apply proper_1.
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
      rewrite HEW2 in *; discriminate.

(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    rewrite SSWP.Dec.F.add_neq_b in Hmem; try assumption.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
    apply HSS with s.
(* Goal: @eq bool (SS.mem s ss) true *)
(* Goal: @eq bool (andb (andb (S.mem p1 s) (S.mem p2 s)) (S.mem p3 s)) true *)
    unfold auxsetofsets in *.
(* Goal: @eq bool (SS.mem s ss) true *)
(* Goal: @eq bool (andb (andb (S.mem p1 s) (S.mem p2 s)) (S.mem p3 s)) true *)
    apply SSWEqP.MP.Dec.F.mem_2 in Hmem.
(* Goal: @eq bool (SS.mem s ss) true *)
(* Goal: @eq bool (andb (andb (S.mem p1 s) (S.mem p2 s)) (S.mem p3 s)) true *)
    do 2 (apply SSWEqP.MP.Dec.F.remove_3 in Hmem).
(* Goal: @eq bool (SS.mem s ss) true *)
(* Goal: @eq bool (andb (andb (S.mem p1 s) (S.mem p2 s)) (S.mem p3 s)) true *)
    apply SSWEqP.MP.Dec.F.mem_1.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    assumption.
(* Goal: @eq bool (andb (andb (S.mem p1 s) (S.mem p2 s)) (S.mem p3 s)) true *)
    do 2 (rewrite andb_true_iff).
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    repeat split; assumption.
Qed.

Lemma test_col_ok : forall ss sp interp p1 p2 p3,
  ss_ok ss interp -> sp_ok sp interp ->
  test_col ss sp p1 p2 p3 = true ->
  CTCol (interp p1) (interp p2) (interp p3).
Proof.
(* Goal: forall (ss : SS.t) (sp : SP.t) (interp : forall _ : positive, COLTpoint) (p1 p2 p3 : S.elt) (_ : ss_ok ss interp) (_ : sp_ok sp interp) (_ : @eq bool (test_col ss sp p1 p2 p3) true), CTCol (interp p1) (interp p2) (interp p3) *)
intros ss sp interp p1 p2 p3 HSS HSP HTC.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
unfold test_col in *.
assert (HSS2 : ss_ok (identify_lines ss sp) interp)
  by (apply identify_lines_ok; assumption).

(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
unfold ss_ok in HSS2.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
apply SSWEqP.MP.Dec.F.exists_2 in HTC.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: @Proper (forall _ : S.t, bool) (@respectful S.t bool S.Equal (@eq bool)) (fun s : SS.elt => andb (andb (S.mem p1 s) (S.mem p2 s)) (S.mem p3 s)) *)
unfold SS.Exists in HTC.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: @Proper (forall _ : S.t, bool) (@respectful S.t bool S.Equal (@eq bool)) (fun s : SS.elt => andb (andb (S.mem p1 s) (S.mem p2 s)) (S.mem p3 s)) *)
destruct HTC as [s [HIn Hmem]].
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: @Proper (forall _ : S.t, bool) (@respectful S.t bool S.Equal (@eq bool)) (fun s : SS.elt => andb (andb (S.mem p1 s) (S.mem p2 s)) (S.mem p3 s)) *)
apply HSS2 with s.
(* Goal: @eq bool (SS.mem s ss) true *)
(* Goal: @eq bool (andb (andb (S.mem p1 s) (S.mem p2 s)) (S.mem p3 s)) true *)
apply SSWEqP.MP.Dec.F.mem_1.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
assumption.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
assumption.

(* Goal: @Proper (forall _ : S.t, bool) (@respectful S.t bool S.Equal (@eq bool)) (fun s : SS.elt => andb (andb (S.mem p1 s) (S.mem p2 s)) (S.mem p3 s)) *)
intros x y Hxy.
assert (HmemEq : forall p, S.mem p x = S.mem p y)
  by (intro; apply SWP.Dec.F.mem_m; auto).
(* Goal: @eq bool (negb (Pos.eqb (fstpp y) p)) (negb (Pos.eqb (fstpp y) p)) *)
do 3 (rewrite HmemEq); reflexivity.
Qed.

Lemma ss_ok_empty : forall interp,
  ss_ok SS.empty interp.
Proof.
(* Goal: forall interp : forall _ : positive, COLTpoint, ss_ok SS.empty interp *)
intros interp ss Hmem1 p1 p2 p3 Hmem2.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
rewrite SSWEqP.MP.Dec.F.empty_b in Hmem1.
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
discriminate.
Qed.

Lemma sp_ok_empty : forall interp,
  sp_ok SP.empty interp.
Proof.
(* Goal: forall (p1 p2 p3 : S.elt) (_ : @eq bool (andb (andb (S.mem p1 s') (S.mem p2 s')) (S.mem p3 s')) true), CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
intros.
(* Goal: sp_ok (SP.union (SP.union (@SP.fold SP.t (subst_in_sp_aux_1 pa) (fst_sp (partition_sp_2 pb (fst_sp (partition_sp_1 pb sp)))) SP.empty) (@SP.fold SP.t (subst_in_sp_aux_2 pa) (snd_sp (partition_sp_2 pb (fst_sp (partition_sp_1 pb sp)))) SP.empty)) (snd_sp (partition_sp_1 pb sp))) interp *)
unfold sp_ok.
(* Goal: forall (p : SP.elt) (_ : @eq bool (SP.mem p (SP.union (SP.union (@SP.fold SP.t (subst_in_sp_aux_1 pa) (fst_sp (partition_sp_2 pb (fst_sp (partition_sp_1 pb sp)))) SP.empty) (@SP.fold SP.t (subst_in_sp_aux_2 pa) (snd_sp (partition_sp_2 pb (fst_sp (partition_sp_1 pb sp)))) SP.empty)) (snd_sp (partition_sp_1 pb sp)))) true), not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
intros p Hp.
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
rewrite SPWEqP.MP.Dec.F.empty_b in Hp.
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
discriminate.
Qed.

Lemma collect_cols :
  forall (A B C : COLTpoint) (HCol : CTCol A B C) pa pb pc ss (interp :  positive -> COLTpoint),
  interp pa = A ->
  interp pb = B ->
  interp pc = C ->
  ss_ok ss interp -> ss_ok (SS.add (S.add pa (S.add pb (S.add pc S.empty))) ss) interp.
Proof.
(* Goal: forall (A B C : COLTpoint) (_ : CTCol A B C) (pa pb pc : positive) (ss : SS.t) (interp : forall _ : positive, COLTpoint) (_ : @eq COLTpoint (interp pa) A) (_ : @eq COLTpoint (interp pb) B) (_ : @eq COLTpoint (interp pc) C) (_ : ss_ok ss interp), ss_ok (SS.add (S.add pa (S.add pb (S.add pc S.empty))) ss) interp *)
intros A B C HCol pa pb pc ss interp HA HB HC HSS.
(* Goal: ss_ok (SS.union (@SS.fold SS.t (subst_in_ss_aux pa pb) (fst_ss (partition_ss pb ss)) SS.empty) (snd_ss (partition_ss pb ss))) interp *)
unfold ss_ok.
(* Goal: forall (s : SS.elt) (_ : @eq bool (SS.mem s (SS.union (@SS.fold SS.t (subst_in_ss_aux pa pb) (fst_ss (partition_ss pb ss)) SS.empty) (snd_ss (partition_ss pb ss)))) true) (p1 p2 p3 : S.elt) (_ : @eq bool (andb (andb (S.mem p1 s) (S.mem p2 s)) (S.mem p3 s)) true), CTCol (interp p1) (interp p2) (interp p3) *)
intros s Hs.
(* Goal: forall (p1 p2 p3 : S.elt) (_ : @eq bool (andb (andb (S.mem p1 s') (S.mem p2 s')) (S.mem p3 s')) true), CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
intros p1 p2 p3 Hmem.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
apply SSWEqP.MP.Dec.F.mem_2 in Hs.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
apply SSWEqP.MP.Dec.F.add_iff in Hs.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
do 2 (rewrite andb_true_iff in Hmem).
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
destruct Hmem as [[Hmem1 Hmem2] Hmem3].
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
elim Hs; intro HsE.

  assert (HmemR : forall p, S.mem p (S.add pa (S.add pb (S.add pc S.empty))) = S.mem p s)
    by (intros; apply SWP.Dec.F.mem_m; auto).
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
  rewrite <- HmemR in Hmem1.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
  rewrite <- HmemR in Hmem2.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
  rewrite <- HmemR in Hmem3.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
  clear HmemR.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
  elim (Pos.eq_dec pa p1); intro Hpap1.

(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
    rewrite Hpap1 in *; rewrite HA.
(* Goal: CTCol A (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
    elim (Pos.eq_dec p1 p2); intro Hp1p2.

(* Goal: CTCol A (interp p2) (interp p3) *)
(* Goal: CTCol A (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
      rewrite Hp1p2 in *; rewrite HA.
(* Goal: CTCol (interp p2) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
      apply CTcol_trivial_1.

(* Goal: CTCol C (interp p2) (interp p3) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: not (@eq positive pb p1) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
      rewrite SWP.Dec.F.add_neq_b in Hmem2.
(* Goal: CTCol A (interp p2) (interp p3) *)
(* Goal: not (@eq positive p1 p2) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
      elim (Pos.eq_dec pb p2); intro Hpbp2.

(* Goal: CTCol A (interp p2) (interp p3) *)
(* Goal: CTCol A (interp p2) (interp p3) *)
(* Goal: not (@eq positive p1 p2) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
        rewrite Hpbp2 in *; rewrite HB.
(* Goal: CTCol B C (interp p3) *)
(* Goal: not (@eq positive pb p2) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
        elim (Pos.eq_dec p3 p1); intro Hp3p1; elim (Pos.eq_dec p3 p2); intro Hp3p2.

(* Goal: CTCol A B (interp p3) *)
(* Goal: CTCol A B (interp p3) *)
(* Goal: CTCol A (interp p2) (interp p3) *)
(* Goal: not (@eq positive p1 p2) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          rewrite Hp3p2; rewrite HB; apply CTcol_trivial_2.

(* Goal: CTCol (interp p2) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          rewrite Hp3p1; rewrite HA; apply CTcol_permutation_1; apply CTcol_trivial_1.

(* Goal: CTCol A B (interp p3) *)
(* Goal: CTCol A B (interp p3) *)
(* Goal: CTCol A (interp p2) (interp p3) *)
(* Goal: not (@eq positive p1 p2) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          rewrite Hp3p2; rewrite HB; apply CTcol_trivial_2.

(* Goal: CTCol C B (interp p3) *)
(* Goal: CTCol C (interp p2) (interp p3) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: not (@eq positive pb p1) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          do 2 (rewrite SWP.Dec.F.add_neq_b in Hmem3).
(* Goal: CTCol C B (interp p3) *)
(* Goal: not (@eq positive pb p3) *)
(* Goal: not (@eq positive pa p3) *)
(* Goal: not (@eq positive pa p3) *)
(* Goal: CTCol C (interp p2) (interp p3) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: not (@eq positive pb p1) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          rewrite <- SWP.singleton_equal_add in Hmem3.
(* Goal: CTCol C B (interp p3) *)
(* Goal: not (@eq positive pb p3) *)
(* Goal: not (@eq positive pa p3) *)
(* Goal: not (@eq positive pa p3) *)
(* Goal: CTCol C (interp p2) (interp p3) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: not (@eq positive pb p1) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          apply SWP.Dec.F.mem_iff in Hmem3.
(* Goal: CTCol C B (interp p3) *)
(* Goal: not (@eq positive pb p3) *)
(* Goal: not (@eq positive pa p3) *)
(* Goal: not (@eq positive pa p3) *)
(* Goal: CTCol C (interp p2) (interp p3) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: not (@eq positive pb p1) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          apply SWP.Dec.F.singleton_1 in Hmem3.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
          rewrite <- Hmem3; rewrite HC; assumption.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
          intuition.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
          intuition.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
          intuition.

(* Goal: CTCol C (interp p2) (interp p3) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: not (@eq positive pb p1) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
        rewrite SWP.Dec.F.add_neq_b in Hmem2.
(* Goal: CTCol C (interp p2) (interp p3) *)
(* Goal: not (@eq positive pb p2) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: not (@eq positive pb p1) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
        rewrite <- SWP.singleton_equal_add in Hmem2.
(* Goal: CTCol C (interp p2) (interp p3) *)
(* Goal: not (@eq positive pb p2) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: not (@eq positive pb p1) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
        apply SWP.Dec.F.mem_iff in Hmem2.
(* Goal: CTCol C (interp p2) (interp p3) *)
(* Goal: not (@eq positive pb p2) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: not (@eq positive pb p1) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
        apply SWP.Dec.F.singleton_1 in Hmem2.
(* Goal: CTCol B (interp p2) (interp p3) *)
(* Goal: not (@eq positive pb p2) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
        rewrite <- Hmem2 in *; rewrite HC.
(* Goal: CTCol B C (interp p3) *)
(* Goal: not (@eq positive pb p2) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
        elim (Pos.eq_dec p3 p1); intro Hp3p1; elim (Pos.eq_dec p3 p2); intro Hp3p2.

(* Goal: CTCol B C (interp p3) *)
(* Goal: CTCol B C (interp p3) *)
(* Goal: not (@eq positive pb p2) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          rewrite Hp3p2 in *; rewrite Hmem2 in *; rewrite HC; apply CTcol_trivial_2.

(* Goal: CTCol (interp p2) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          rewrite Hp3p1 in *; rewrite HA; apply CTcol_permutation_1; apply CTcol_trivial_1.

(* Goal: CTCol B C (interp p3) *)
(* Goal: CTCol B C (interp p3) *)
(* Goal: not (@eq positive pb p2) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          rewrite Hp3p2 in *; rewrite Hmem2 in *; rewrite HC; apply CTcol_trivial_2.

(* Goal: CTCol B C (interp p3) *)
(* Goal: not (@eq positive pa p3) *)
(* Goal: not (@eq positive pb p2) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          rewrite SWP.Dec.F.add_neq_b in Hmem3.
(* Goal: CTCol B C (interp p3) *)
(* Goal: not (@eq positive pa p3) *)
(* Goal: not (@eq positive pb p2) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          elim (Pos.eq_dec p3 pb); intro Hp3pb.

(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
            rewrite Hp3pb in *; rewrite HB; apply CTcol_permutation_5; assumption.

(* Goal: CTCol B C (interp p3) *)
(* Goal: not (@eq positive pa p3) *)
(* Goal: not (@eq positive pb p2) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
            rewrite SWP.Dec.F.add_neq_b in Hmem3.
(* Goal: CTCol C B (interp p3) *)
(* Goal: not (@eq positive pb p3) *)
(* Goal: not (@eq positive pa p3) *)
(* Goal: not (@eq positive pa p3) *)
(* Goal: CTCol C (interp p2) (interp p3) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: not (@eq positive pb p1) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
            rewrite <- SWP.singleton_equal_add in Hmem3.
(* Goal: CTCol C B (interp p3) *)
(* Goal: not (@eq positive pb p3) *)
(* Goal: not (@eq positive pa p3) *)
(* Goal: not (@eq positive pa p3) *)
(* Goal: CTCol C (interp p2) (interp p3) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: not (@eq positive pb p1) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
            apply SWP.Dec.F.mem_iff in Hmem3.
(* Goal: CTCol C B (interp p3) *)
(* Goal: not (@eq positive pb p3) *)
(* Goal: not (@eq positive pa p3) *)
(* Goal: not (@eq positive pa p3) *)
(* Goal: CTCol C (interp p2) (interp p3) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: not (@eq positive pb p1) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
            apply SWP.Dec.F.singleton_1 in Hmem3.
(* Goal: CTCol B C (interp p3) *)
(* Goal: not (@eq positive pb p3) *)
(* Goal: not (@eq positive pa p3) *)
(* Goal: not (@eq positive pb p2) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
            rewrite Hmem3 in *; contradiction.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
            intuition.

(* Goal: @eq positive (sndpp x) pb *)
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
          intuition.

(* Goal: @eq positive (sndpp x) pb *)
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
        intuition.

(* Goal: @eq positive (sndpp x) pb *)
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
      intuition.

(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
    rewrite SWP.Dec.F.add_neq_b in Hmem1.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
    elim (Pos.eq_dec p1 pb); intro Hp1pb.

(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
      rewrite Hp1pb in *; rewrite HB.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
      elim (Pos.eq_dec pa p2); intro Hpap2.

(* Goal: CTCol C (interp p2) (interp p3) *)
(* Goal: CTCol C (interp p2) (interp p3) *)
(* Goal: not (@eq positive pb p1) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
        rewrite Hpap2 in *; rewrite HA.
(* Goal: CTCol B C (interp p3) *)
(* Goal: not (@eq positive pa p3) *)
(* Goal: not (@eq positive pb p2) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
        elim (Pos.eq_dec p3 p2); intro Hp3p2; elim (Pos.eq_dec p3 pb); intro Hp3pb.

(* Goal: CTCol (interp p2) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          rewrite Hp3pb; rewrite HB; apply CTcol_permutation_1; apply CTcol_trivial_1.

(* Goal: CTCol C A (interp p3) *)
(* Goal: CTCol C A (interp p3) *)
(* Goal: CTCol C A (interp p3) *)
(* Goal: CTCol C (interp p2) (interp p3) *)
(* Goal: not (@eq positive pb p1) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          rewrite Hp3p2; rewrite HA; apply CTcol_trivial_2.

(* Goal: CTCol (interp p2) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          rewrite Hp3pb; rewrite HB; apply CTcol_permutation_1; apply CTcol_trivial_1.

(* Goal: CTCol C B (interp p3) *)
(* Goal: CTCol C (interp p2) (interp p3) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: not (@eq positive pb p1) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          do 2 (rewrite SWP.Dec.F.add_neq_b in Hmem3).
(* Goal: CTCol C B (interp p3) *)
(* Goal: not (@eq positive pb p3) *)
(* Goal: not (@eq positive pa p3) *)
(* Goal: not (@eq positive pa p3) *)
(* Goal: CTCol C (interp p2) (interp p3) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: not (@eq positive pb p1) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          rewrite <- SWP.singleton_equal_add in Hmem3.
(* Goal: CTCol C B (interp p3) *)
(* Goal: not (@eq positive pb p3) *)
(* Goal: not (@eq positive pa p3) *)
(* Goal: not (@eq positive pa p3) *)
(* Goal: CTCol C (interp p2) (interp p3) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: not (@eq positive pb p1) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          apply SWP.Dec.F.mem_iff in Hmem3.
(* Goal: CTCol C B (interp p3) *)
(* Goal: not (@eq positive pb p3) *)
(* Goal: not (@eq positive pa p3) *)
(* Goal: not (@eq positive pa p3) *)
(* Goal: CTCol C (interp p2) (interp p3) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: not (@eq positive pb p1) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          apply SWP.Dec.F.singleton_1 in Hmem3.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
          rewrite <- Hmem3; rewrite HC; apply CTcol_permutation_4; assumption.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
          intuition.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
          intuition.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
          intuition.

(* Goal: CTCol C (interp p2) (interp p3) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: not (@eq positive pb p1) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
        rewrite SWP.Dec.F.add_neq_b in Hmem2.
(* Goal: CTCol C (interp p2) (interp p3) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: not (@eq positive pb p1) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
        elim (Pos.eq_dec p2 pb); intro Hp2pb.

(* Goal: CTCol (interp p2) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          rewrite Hp2pb; rewrite HB; apply CTcol_trivial_1.

(* Goal: CTCol C (interp p2) (interp p3) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: not (@eq positive pb p1) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          rewrite SWP.Dec.F.add_neq_b in Hmem2.
(* Goal: CTCol C (interp p2) (interp p3) *)
(* Goal: not (@eq positive pb p2) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: not (@eq positive pb p1) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          rewrite <- SWP.singleton_equal_add in Hmem2.
(* Goal: CTCol C (interp p2) (interp p3) *)
(* Goal: not (@eq positive pb p2) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: not (@eq positive pb p1) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          apply SWP.Dec.F.mem_iff in Hmem2.
(* Goal: CTCol C (interp p2) (interp p3) *)
(* Goal: not (@eq positive pb p2) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: not (@eq positive pb p1) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          apply SWP.Dec.F.singleton_1 in Hmem2.
(* Goal: CTCol B (interp p2) (interp p3) *)
(* Goal: not (@eq positive pb p2) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          rewrite <- Hmem2 in *; rewrite HC.
(* Goal: CTCol B C (interp p3) *)
(* Goal: not (@eq positive pb p2) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          elim (Pos.eq_dec p3 p1); intro Hp3p1; elim (Pos.eq_dec p3 p2); intro Hp3p2.

(* Goal: CTCol B C (interp p3) *)
(* Goal: CTCol B C (interp p3) *)
(* Goal: not (@eq positive pb p2) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
            rewrite Hp3p2 in *; rewrite Hmem2 in *; rewrite HC; apply CTcol_trivial_2.

(* Goal: CTCol (interp p2) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
            rewrite Hp3p1 in *; rewrite Hp1pb; rewrite HB; apply CTcol_permutation_1; apply CTcol_trivial_1.

(* Goal: CTCol B C (interp p3) *)
(* Goal: CTCol B C (interp p3) *)
(* Goal: not (@eq positive pb p2) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
            rewrite Hp3p2 in *; rewrite Hmem2 in *; rewrite HC; apply CTcol_trivial_2.

(* Goal: CTCol B C (interp p3) *)
(* Goal: not (@eq positive pb p2) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
            elim (Pos.eq_dec p3 pa); intro Hp3pa.

(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
              rewrite Hp3pa; rewrite HA; apply CTcol_permutation_1; assumption.

(* Goal: CTCol B C (interp p3) *)
(* Goal: not (@eq positive pa p3) *)
(* Goal: not (@eq positive pb p2) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
              rewrite SWP.Dec.F.add_neq_b in Hmem3.
(* Goal: CTCol B C (interp p3) *)
(* Goal: not (@eq positive pa p3) *)
(* Goal: not (@eq positive pb p2) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
              elim (Pos.eq_dec p3 pb); intro Hp3pb.

(* Goal: CTCol (interp p2) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
                rewrite Hp3pb in *; rewrite HB; apply CTcol_permutation_5; apply CTcol_trivial_1.

(* Goal: CTCol B C (interp p3) *)
(* Goal: not (@eq positive pa p3) *)
(* Goal: not (@eq positive pb p2) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
                rewrite SWP.Dec.F.add_neq_b in Hmem3.
(* Goal: CTCol C B (interp p3) *)
(* Goal: not (@eq positive pb p3) *)
(* Goal: not (@eq positive pa p3) *)
(* Goal: not (@eq positive pa p3) *)
(* Goal: CTCol C (interp p2) (interp p3) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: not (@eq positive pb p1) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
                rewrite <- SWP.singleton_equal_add in Hmem3.
(* Goal: CTCol C B (interp p3) *)
(* Goal: not (@eq positive pb p3) *)
(* Goal: not (@eq positive pa p3) *)
(* Goal: not (@eq positive pa p3) *)
(* Goal: CTCol C (interp p2) (interp p3) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: not (@eq positive pb p1) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
                apply SWP.Dec.F.mem_iff in Hmem3.
(* Goal: CTCol C B (interp p3) *)
(* Goal: not (@eq positive pb p3) *)
(* Goal: not (@eq positive pa p3) *)
(* Goal: not (@eq positive pa p3) *)
(* Goal: CTCol C (interp p2) (interp p3) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: not (@eq positive pb p1) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
                apply SWP.Dec.F.singleton_1 in Hmem3.
(* Goal: CTCol B C (interp p3) *)
(* Goal: not (@eq positive pb p3) *)
(* Goal: not (@eq positive pa p3) *)
(* Goal: not (@eq positive pb p2) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
                rewrite Hmem3 in *; contradiction.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
                intuition.

(* Goal: @eq positive (sndpp x) pb *)
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
              intuition.

(* Goal: @eq positive (sndpp x) pb *)
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
          intuition.

(* Goal: @eq positive (sndpp x) pb *)
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
        intuition.

(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
      rewrite SWP.Dec.F.add_neq_b in Hmem1.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: not (@eq positive pb p1) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
      rewrite <- SWP.singleton_equal_add in Hmem1.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: not (@eq positive pb p1) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
      apply SWP.Dec.F.mem_iff in Hmem1.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: not (@eq positive pb p1) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
      apply SWP.Dec.F.singleton_1 in Hmem1.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: not (@eq positive pb p1) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
      rewrite <- Hmem1 in *; rewrite HC.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
      elim (Pos.eq_dec pa p2); intro Hpap2.

(* Goal: CTCol C (interp p2) (interp p3) *)
(* Goal: CTCol C (interp p2) (interp p3) *)
(* Goal: not (@eq positive pb p1) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
        rewrite Hpap2 in *; rewrite HA.
(* Goal: CTCol B C (interp p3) *)
(* Goal: not (@eq positive pa p3) *)
(* Goal: not (@eq positive pb p2) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
        elim (Pos.eq_dec p3 p2); intro Hp3p2; elim (Pos.eq_dec p3 pb); intro Hp3pb.

(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
          rewrite Hp3pb; rewrite HB; apply CTcol_permutation_2; assumption.

(* Goal: CTCol C A (interp p3) *)
(* Goal: CTCol C A (interp p3) *)
(* Goal: CTCol C A (interp p3) *)
(* Goal: CTCol C (interp p2) (interp p3) *)
(* Goal: not (@eq positive pb p1) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          rewrite Hp3p2; rewrite HA; apply CTcol_trivial_2.

(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
          rewrite Hp3pb; rewrite HB; apply CTcol_permutation_2; assumption.

(* Goal: CTCol C B (interp p3) *)
(* Goal: CTCol C (interp p2) (interp p3) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: not (@eq positive pb p1) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          do 2 (rewrite SWP.Dec.F.add_neq_b in Hmem3).
(* Goal: CTCol C B (interp p3) *)
(* Goal: not (@eq positive pb p3) *)
(* Goal: not (@eq positive pa p3) *)
(* Goal: not (@eq positive pa p3) *)
(* Goal: CTCol C (interp p2) (interp p3) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: not (@eq positive pb p1) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          rewrite <- SWP.singleton_equal_add in Hmem3.
(* Goal: CTCol C B (interp p3) *)
(* Goal: not (@eq positive pb p3) *)
(* Goal: not (@eq positive pa p3) *)
(* Goal: not (@eq positive pa p3) *)
(* Goal: CTCol C (interp p2) (interp p3) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: not (@eq positive pb p1) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          apply SWP.Dec.F.mem_iff in Hmem3.
(* Goal: CTCol C B (interp p3) *)
(* Goal: not (@eq positive pb p3) *)
(* Goal: not (@eq positive pa p3) *)
(* Goal: not (@eq positive pa p3) *)
(* Goal: CTCol C (interp p2) (interp p3) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: not (@eq positive pb p1) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          apply SWP.Dec.F.singleton_1 in Hmem3.
(* Goal: CTCol (interp p2) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          rewrite <- Hmem3; rewrite HC; apply CTcol_permutation_1; apply CTcol_trivial_1.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
          intuition.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
          intuition.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
          intuition.

(* Goal: CTCol C (interp p2) (interp p3) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: not (@eq positive pb p1) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
        rewrite SWP.Dec.F.add_neq_b in Hmem2.
(* Goal: CTCol C (interp p2) (interp p3) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: not (@eq positive pb p1) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
        elim (Pos.eq_dec p2 pb); intro Hp2pb.

(* Goal: CTCol C (interp p2) (interp p3) *)
(* Goal: CTCol C (interp p2) (interp p3) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: not (@eq positive pb p1) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          rewrite Hp2pb; rewrite HB.
(* Goal: CTCol B C (interp p3) *)
(* Goal: not (@eq positive pa p3) *)
(* Goal: not (@eq positive pb p2) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          elim (Pos.eq_dec p3 pa); intro Hp3pa; elim (Pos.eq_dec p3 pb); intro Hp3pb.

(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
            rewrite Hp3pa; rewrite HA; apply CTcol_permutation_3; assumption.

(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
            rewrite Hp3pa; rewrite HA; apply CTcol_permutation_3; assumption.

(* Goal: CTCol C B (interp p3) *)
(* Goal: CTCol C B (interp p3) *)
(* Goal: CTCol C (interp p2) (interp p3) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: not (@eq positive pb p1) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
            rewrite Hp3pb; rewrite HB; apply CTcol_trivial_2.

(* Goal: CTCol C B (interp p3) *)
(* Goal: CTCol C (interp p2) (interp p3) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: not (@eq positive pb p1) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
            do 2 (rewrite SWP.Dec.F.add_neq_b in Hmem3).
(* Goal: CTCol C B (interp p3) *)
(* Goal: not (@eq positive pb p3) *)
(* Goal: not (@eq positive pa p3) *)
(* Goal: not (@eq positive pa p3) *)
(* Goal: CTCol C (interp p2) (interp p3) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: not (@eq positive pb p1) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
            rewrite <- SWP.singleton_equal_add in Hmem3.
(* Goal: CTCol C B (interp p3) *)
(* Goal: not (@eq positive pb p3) *)
(* Goal: not (@eq positive pa p3) *)
(* Goal: not (@eq positive pa p3) *)
(* Goal: CTCol C (interp p2) (interp p3) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: not (@eq positive pb p1) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
            apply SWP.Dec.F.mem_iff in Hmem3.
(* Goal: CTCol C B (interp p3) *)
(* Goal: not (@eq positive pb p3) *)
(* Goal: not (@eq positive pa p3) *)
(* Goal: not (@eq positive pa p3) *)
(* Goal: CTCol C (interp p2) (interp p3) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: not (@eq positive pb p1) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
            apply SWP.Dec.F.singleton_1 in Hmem3.
(* Goal: CTCol (interp p2) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
            rewrite <- Hmem3 in *; rewrite HC; apply CTcol_permutation_1; apply CTcol_trivial_1.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
            intuition.

(* Goal: @eq positive (sndpp x) pb *)
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
          intuition.

(* Goal: @eq positive (sndpp x) pb *)
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
        intuition.

(* Goal: CTCol C (interp p2) (interp p3) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: not (@eq positive pb p1) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
        rewrite SWP.Dec.F.add_neq_b in Hmem2.
(* Goal: CTCol C (interp p2) (interp p3) *)
(* Goal: not (@eq positive pb p2) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: not (@eq positive pb p1) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
        rewrite <- SWP.singleton_equal_add in Hmem2.
(* Goal: CTCol C (interp p2) (interp p3) *)
(* Goal: not (@eq positive pb p2) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: not (@eq positive pb p1) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
        apply SWP.Dec.F.mem_iff in Hmem2.
(* Goal: CTCol C (interp p2) (interp p3) *)
(* Goal: not (@eq positive pb p2) *)
(* Goal: not (@eq positive pa p2) *)
(* Goal: not (@eq positive pb p1) *)
(* Goal: not (@eq positive pa p1) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
        apply SWP.Dec.F.singleton_1 in Hmem2.
(* Goal: CTCol (interp p2) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
        rewrite <- Hmem2 in *; rewrite HC; apply CTcol_trivial_1.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
        intuition.

(* Goal: @eq positive (sndpp x) pb *)
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
        intuition.

(* Goal: @eq positive (sndpp x) pb *)
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
      intuition.

(* Goal: @eq positive (sndpp x) pb *)
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    intuition.

(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
  unfold ss_ok in *.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
  apply HSS with s.
(* Goal: @eq bool (SS.mem s ss) true *)
(* Goal: @eq bool (andb (andb (S.mem p1 s) (S.mem p2 s)) (S.mem p3 s)) true *)
  apply SSWEqP.MP.Dec.F.mem_1.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
  assumption.
(* Goal: @eq bool (negb (Pos.eqb (fstpp y) p)) (negb (Pos.eqb (fstpp y) p)) *)
  rewrite Hmem1; rewrite Hmem2; rewrite Hmem3; reflexivity.
Qed.

Lemma collect_diffs :
  forall (A B : COLTpoint) (H : A <> B) pa pb sp (interp :  positive -> COLTpoint),
  interp pa = A ->
  interp pb = B ->
  sp_ok sp interp -> sp_ok (SP.add (pa, pb) sp) interp.
Proof.
(* Goal: forall (A B : COLTpoint) (_ : not (@eq COLTpoint A B)) (pa pb : positive) (sp : SP.t) (interp : forall _ : positive, COLTpoint) (_ : @eq COLTpoint (interp pa) A) (_ : @eq COLTpoint (interp pb) B) (_ : sp_ok sp interp), sp_ok (SP.add (@pair positive positive pa pb) sp) interp *)
intros A B HDiff pa pb sp interp HA HB HSP.
(* Goal: sp_ok (SP.union (SP.union (@SP.fold SP.t (subst_in_sp_aux_1 pa) (fst_sp (partition_sp_2 pb (fst_sp (partition_sp_1 pb sp)))) SP.empty) (@SP.fold SP.t (subst_in_sp_aux_2 pa) (snd_sp (partition_sp_2 pb (fst_sp (partition_sp_1 pb sp)))) SP.empty)) (snd_sp (partition_sp_1 pb sp))) interp *)
unfold sp_ok.
(* Goal: forall (p : SP.elt) (_ : @eq bool (SP.mem p (SP.union (SP.union (@SP.fold SP.t (subst_in_sp_aux_1 pa) (fst_sp (partition_sp_2 pb (fst_sp (partition_sp_1 pb sp)))) SP.empty) (@SP.fold SP.t (subst_in_sp_aux_2 pa) (snd_sp (partition_sp_2 pb (fst_sp (partition_sp_1 pb sp)))) SP.empty)) (snd_sp (partition_sp_1 pb sp)))) true), not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
intros p Hp.
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
apply SPWEqP.MP.Dec.F.mem_2 in Hp.
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
apply SPWEqP.MP.Dec.F.add_iff in Hp.
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
elim Hp; intro HpE.

(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
  destruct HpE as [HEq1 HEq2].
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
  destruct p as [fstp sndp].
(* Goal: not (@eq COLTpoint (interp (fstpp (@pair positive positive fstp sndp))) (interp (sndpp (@pair positive positive fstp sndp)))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
  simpl in *.
  elim (Pos.min_spec pa pb); intro Hmin1; elim (Pos.min_spec fstp sndp); intro Hmin2;
  destruct Hmin1 as [Hpapb1 Hmin1]; destruct Hmin2 as [Hfpsp1 Hmin2];
  elim (Pos.max_spec pa pb); intro Hmax1; elim (Pos.max_spec fstp sndp); intro Hmax2;
  destruct Hmax1 as [Hpapb2 Hmax1]; destruct Hmax2 as [Hfpsp2 Hmax2].

(* Goal: not (@eq COLTpoint (interp (Pos.min fstp sndp)) (interp (Pos.max fstp sndp))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    rewrite Hmin1 in *; rewrite Hmin2 in *; rewrite Hmax1 in *;rewrite Hmax2 in *.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    rewrite <- HEq1; rewrite <- HEq2; rewrite HA in *; rewrite HB in *; assumption.

    rewrite <- Pos.ltb_lt in Hfpsp1; rewrite Pos.ltb_antisym in Hfpsp1;
    rewrite negb_true_iff in Hfpsp1; rewrite Pos.leb_nle in Hfpsp1; contradiction.

    rewrite <- Pos.ltb_lt in Hpapb1; rewrite Pos.ltb_antisym in Hpapb1;
    rewrite negb_true_iff in Hpapb1; rewrite Pos.leb_nle in Hpapb1; contradiction.

    rewrite <- Pos.ltb_lt in Hfpsp1; rewrite Pos.ltb_antisym in Hfpsp1;
    rewrite negb_true_iff in Hfpsp1; rewrite Pos.leb_nle in Hfpsp1; contradiction.

    rewrite <- Pos.ltb_lt in Hfpsp2; rewrite Pos.ltb_antisym in Hfpsp2;
    rewrite negb_true_iff in Hfpsp2; rewrite Pos.leb_nle in Hfpsp2; contradiction.

(* Goal: not (@eq COLTpoint (interp (Pos.min fstp sndp)) (interp (Pos.max fstp sndp))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    rewrite Hmin1 in *; rewrite Hmin2 in *; rewrite Hmax1 in *;rewrite Hmax2 in *.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    rewrite <- HEq1; rewrite <- HEq2; rewrite HA in *; rewrite HB in *; assumption.

    rewrite <- Pos.ltb_lt in Hfpsp2; rewrite Pos.ltb_antisym in Hfpsp2;
    rewrite negb_true_iff in Hfpsp2; rewrite Pos.leb_nle in Hfpsp2; contradiction.

    rewrite <- Pos.ltb_lt in Hpapb1; rewrite Pos.ltb_antisym in Hpapb1;
    rewrite negb_true_iff in Hpapb1; rewrite Pos.leb_nle in Hpapb1; contradiction.

    rewrite <- Pos.ltb_lt in Hpapb2; rewrite Pos.ltb_antisym in Hpapb2;
    rewrite negb_true_iff in Hpapb2; rewrite Pos.leb_nle in Hpapb2; contradiction.

    rewrite <- Pos.ltb_lt in Hpapb2; rewrite Pos.ltb_antisym in Hpapb2;
    rewrite negb_true_iff in Hpapb2; rewrite Pos.leb_nle in Hpapb2; contradiction.

(* Goal: not (@eq COLTpoint (interp (Pos.min fstp sndp)) (interp (Pos.max fstp sndp))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    rewrite Hmin1 in *; rewrite Hmin2 in *; rewrite Hmax1 in *;rewrite Hmax2 in *.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    rewrite <- HEq1; rewrite <- HEq2; rewrite HA in *; rewrite HB in *; intuition.

    rewrite <- Pos.ltb_lt in Hfpsp1; rewrite Pos.ltb_antisym in Hfpsp1;
    rewrite negb_true_iff in Hfpsp1; rewrite Pos.leb_nle in Hfpsp1; contradiction.

    rewrite <- Pos.ltb_lt in Hpapb2; rewrite Pos.ltb_antisym in Hpapb2;
    rewrite negb_true_iff in Hpapb2; rewrite Pos.leb_nle in Hpapb2; contradiction.

    rewrite <- Pos.ltb_lt in Hpapb2; rewrite Pos.ltb_antisym in Hpapb2;
    rewrite negb_true_iff in Hpapb2; rewrite Pos.leb_nle in Hpapb2; contradiction.

    rewrite <- Pos.ltb_lt in Hfpsp2; rewrite Pos.ltb_antisym in Hfpsp2;
    rewrite negb_true_iff in Hfpsp2; rewrite Pos.leb_nle in Hfpsp2; contradiction.

(* Goal: not (@eq COLTpoint (interp (Pos.min fstp sndp)) (interp (Pos.max fstp sndp))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    rewrite Hmin1 in *; rewrite Hmin2 in *; rewrite Hmax1 in *;rewrite Hmax2 in *.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    rewrite <- HEq1; rewrite <- HEq2; rewrite HA in *; rewrite HB in *; intuition.

(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
  unfold sp_ok in *.
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
  apply HSP.
(* Goal: @eq bool (SP.mem p sp) true *)
  apply SPWEqP.MP.Dec.F.mem_1.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
  assumption.
Qed.

Definition list_assoc_inv :=
  (fix list_assoc_inv_rec (A:Type) (B:Set)
                          (eq_dec:forall e1 e2:B, {e1 = e2} + {e1 <> e2})
                          (lst : list (prodT A B)) {struct lst} : B -> A -> A :=
  fun (key:B) (default:A) =>
    match lst with
      | nil => default
      | cons (pairT v e) l =>
        match eq_dec e key with
          | left _ => v
          | right _ => list_assoc_inv_rec A B eq_dec l key default
        end
    end).

Lemma positive_dec : forall (p1 p2:positive), {p1=p2}+{~p1=p2}.
Proof.
(* Goal: forall p1 p2 : positive, sumbool (@eq positive p1 p2) (not (@eq positive p1 p2)) *)
decide equality.
Defined.

Definition interp (lvar : list (COLTpoint * positive)) (Default : COLTpoint) : positive -> COLTpoint := 
  fun p => list_assoc_inv COLTpoint positive positive_dec lvar p Default.

Definition eq_tagged (lvar : list (COLTpoint * positive)) := lvar = lvar.

Lemma eq_eq_tagged : forall lvar, lvar = lvar -> eq_tagged lvar.
Proof.
(* Goal: forall (lvar : list (prod COLTpoint positive)) (_ : @eq (list (prod COLTpoint positive)) lvar lvar), eq_tagged lvar *)
trivial.
Qed.

Definition partition_ss e ss :=
  SS.partition (fun s => S.mem e s) ss.

Definition fst_ss (pair : SS.t * SS.t) :=
 match pair with
    |(a,b) => a
  end.

Definition snd_ss (pair : SS.t * SS.t) :=
 match pair with
    |(a,b) => b
  end.

Definition subst_in_set p1 p2 s := S.add p1 (S.remove p2 s).

Definition subst_in_ss_aux p1 p2 := (fun s ss => SS.add (subst_in_set p1 p2 s) ss).

Definition subst_in_ss p1 p2 ss :=
  let pair := partition_ss p2 ss in
  let fss := fst_ss(pair) in
  let sss := snd_ss(pair) in
  let newfss := SS.fold (subst_in_ss_aux p1 p2) fss SS.empty in
  SS.union newfss sss.

Lemma proper_4 : forall p, Proper (S.Equal ==> eq) (fun s : SS.elt => S.mem p s).
Proof.
(* Goal: forall p : positive, @Proper (forall _ : SetOfPairsOfPositiveOrderedType.t, bool) (@respectful SetOfPairsOfPositiveOrderedType.t bool (fun t1 t2 : SetOfPairsOfPositiveOrderedType.t => and (Pos.eq (fstpp t1) (fstpp t2)) (Pos.eq (sndpp t1) (sndpp t2))) (@eq bool)) (fun x : SP.elt => negb (Pos.eqb (fstpp x) p)) *)
intros p x y Hxy.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
apply SWP.Dec.F.mem_m; intuition.
Qed.

Lemma proper_5 : forall p, Proper (S.Equal ==> eq) (fun s : SS.elt => negb (S.mem p s)).
Proof.
(* Goal: forall p : positive, @Proper (forall _ : SetOfPairsOfPositiveOrderedType.t, bool) (@respectful SetOfPairsOfPositiveOrderedType.t bool (fun t1 t2 : SetOfPairsOfPositiveOrderedType.t => and (Pos.eq (fstpp t1) (fstpp t2)) (Pos.eq (sndpp t1) (sndpp t2))) (@eq bool)) (fun x : SP.elt => negb (Pos.eqb (fstpp x) p)) *)
intros p x y Hxy.
(* Goal: @eq bool (negb (S.mem p x)) (negb (S.mem p y)) *)
apply negb_sym.
(* Goal: @eq bool (S.mem p y) (negb (negb (S.mem p x))) *)
rewrite negb_involutive.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
apply SWP.Dec.F.mem_m; intuition.
Qed.

Lemma subst_ss_ok :
  forall (A B : COLTpoint) (H : A = B) pa pb ss (interp :  positive -> COLTpoint),
  interp pa = A ->
  interp pb = B ->
  ss_ok ss interp -> ss_ok (subst_in_ss pa pb ss) interp.
Proof.
(* Goal: forall (A B : COLTpoint) (_ : @eq COLTpoint A B) (pa pb : positive) (ss : SS.t) (interp : forall _ : positive, COLTpoint) (_ : @eq COLTpoint (interp pa) A) (_ : @eq COLTpoint (interp pb) B) (_ : ss_ok ss interp), ss_ok (subst_in_ss pa pb ss) interp *)
intros A B H pa pb ss interp HA HB HSS.
(* Goal: ss_ok (subst_in_ss pa pb ss) interp *)
unfold subst_in_ss.
(* Goal: ss_ok (SS.union (@SS.fold SS.t (subst_in_ss_aux pa pb) (fst_ss (partition_ss pb ss)) SS.empty) (snd_ss (partition_ss pb ss))) interp *)
unfold ss_ok.
(* Goal: forall (s : SS.elt) (_ : @eq bool (SS.mem s (SS.union (@SS.fold SS.t (subst_in_ss_aux pa pb) (fst_ss (partition_ss pb ss)) SS.empty) (snd_ss (partition_ss pb ss)))) true) (p1 p2 p3 : S.elt) (_ : @eq bool (andb (andb (S.mem p1 s) (S.mem p2 s)) (S.mem p3 s)) true), CTCol (interp p1) (interp p2) (interp p3) *)
intros s Hs.
(* Goal: forall (p1 p2 p3 : S.elt) (_ : @eq bool (andb (andb (S.mem p1 s') (S.mem p2 s')) (S.mem p3 s')) true), CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
intros p1 p2 p3 Hmem.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
apply SSWEqP.MP.Dec.F.mem_2 in Hs.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
rewrite SSWEqP.MP.Dec.F.union_iff in Hs.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
elim Hs; intro HIn; clear Hs.

(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
  assert (HSSF : ss_ok (fst_ss (partition_ss pb ss)) interp).

(* Goal: ss_ok (snd_ss (partition_ss pb ss)) interp *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
    clear Hmem; clear p1; clear p2; clear p3.
(* Goal: ss_ok (snd_ss (partition_ss pb ss)) interp *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
    intros s' Hs'.
(* Goal: forall (p1 p2 p3 : S.elt) (_ : @eq bool (andb (andb (S.mem p1 s') (S.mem p2 s')) (S.mem p3 s')) true), CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
    intros.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
    apply SSWEqP.MP.Dec.F.mem_2 in Hs'.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
    unfold partition in Hs'.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
    apply SS.partition_spec1 in Hs'; try apply proper_4.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
    apply SSWEqP.MP.Dec.F.filter_1 in Hs'; try apply proper_4.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
    unfold ss_ok in HSS.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    apply HSS with s'; try assumption.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    apply SSWEqP.MP.Dec.F.mem_1; assumption.

(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
  assert (HSSF' : ss_ok (SS.fold (subst_in_ss_aux pa pb) (fst_ss (partition_ss pb ss)) SS.empty) interp).

(* Goal: ss_ok (@SS.fold SS.t (subst_in_ss_aux pa pb) (fst_ss (partition_ss pb ss)) SS.empty) interp *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
    apply SSWEqP.MP.fold_rec_nodep; try apply ss_ok_empty.
(* Goal: forall (x : SS.elt) (a : SS.t) (_ : SS.In x (fst_ss (partition_ss pb ss))) (_ : ss_ok a interp), ss_ok (subst_in_ss_aux pa pb x a) interp *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
    intros x a HIn1 HSSa.
(* Goal: ss_ok (snd_ss (partition_ss pb ss)) interp *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
    clear Hmem; clear p1; clear p2; clear p3.
(* Goal: ss_ok (snd_ss (partition_ss pb ss)) interp *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
    intros s' Hs'.
(* Goal: forall (p1 p2 p3 : S.elt) (_ : @eq bool (andb (andb (S.mem p1 s') (S.mem p2 s')) (S.mem p3 s')) true), CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
    intros p1 p2 p3 Hmem.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
    unfold subst_in_ss_aux in *.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
    apply SSWEqP.MP.Dec.F.mem_2 in Hs'.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
    rewrite SSWEqP.MP.Dec.F.add_iff in Hs'.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
    elim Hs'; intro HIn2; clear Hs'.

(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
      unfold subst_in_set in HIn2.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
      clear HIn; clear s; assert (HEq := HIn2); clear HIn2; assert (HIn := HIn1); clear HIn1.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
      elim (Pos.eq_dec pb p1); intro Hp1; elim (Pos.eq_dec pb p2); intro Hp2; elim (Pos.eq_dec pb p3); intro Hp3.

(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
        do 2 subst.
(* Goal: CTCol (interp p2) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
        apply CTcol_trivial_1.

(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
        do 2 subst.
(* Goal: CTCol (interp p2) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
        apply CTcol_trivial_1.

(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
        do 2 subst.
(* Goal: CTCol (interp p3) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
        apply CTcol_permutation_4; apply CTcol_trivial_2.

(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
        subst.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
        do 2 (rewrite andb_true_iff in Hmem).
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
        destruct Hmem as [[Hmem1' Hmem2'] Hmem3'].
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
        assert (Hmem1 : S.mem p1 x = true).

(* Goal: @eq bool (S.mem pb x) true *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          unfold partition in HIn.
(* Goal: @eq bool (S.mem pb x) true *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          apply SS.partition_spec1 in HIn; try apply proper_4.
(* Goal: @eq bool (S.mem pb x) true *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          apply SSWEqP.MP.Dec.F.filter_2 in HIn; try assumption; apply proper_4.

(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
        elim (Pos.eq_dec pa p2); intro Hpap2.

(* Goal: CTCol (interp p2) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          subst; rewrite HB; apply CTcol_trivial_1.

(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          assert (Hmem2 : S.mem p2 x = true).

(* Goal: @eq bool (S.mem p2 x) true *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
            rewrite <- HEq in Hmem2'.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
            rewrite SWP.Dec.F.add_neq_b in Hmem2'; try assumption.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
            rewrite SWP.Dec.F.remove_neq_b in Hmem2'; assumption.

(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          elim (Pos.eq_dec pa p3); intro Hpap3.

(* Goal: CTCol (interp p3) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
            subst; rewrite HB; apply CTcol_permutation_4; apply CTcol_trivial_2.

(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
            assert (Hmem3 : S.mem p3 x = true).

(* Goal: @eq bool (S.mem p3 x) true *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
              rewrite <- HEq in Hmem3'.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
              rewrite SWP.Dec.F.add_neq_b in Hmem3'; try assumption.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
              rewrite SWP.Dec.F.remove_neq_b in Hmem3'; assumption.

(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
            unfold ss_ok in HSSF.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
            apply HSSF with x.

(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
              apply SSWEqP.MP.Dec.F.mem_1; assumption.

(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
              do 2 (rewrite andb_true_iff); repeat split; assumption.

(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
        do 2 subst.
(* Goal: CTCol (interp p1) (interp p3) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
        apply CTcol_trivial_2.

(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
        subst.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
        do 2 (rewrite andb_true_iff in Hmem).
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
        destruct Hmem as [[Hmem1' Hmem2'] Hmem3'].
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
        assert (Hmem2 : S.mem p2 x = true).

(* Goal: @eq bool (S.mem pb x) true *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          unfold partition in HIn.
(* Goal: @eq bool (S.mem pb x) true *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          apply SS.partition_spec1 in HIn; try apply proper_4.
(* Goal: @eq bool (S.mem pb x) true *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          apply SSWEqP.MP.Dec.F.filter_2 in HIn; try assumption; apply proper_4.

(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
        elim (Pos.eq_dec pa p1); intro Hpap1.

(* Goal: CTCol (interp p2) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          subst; rewrite HB; apply CTcol_trivial_1.

(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          assert (Hmem1 : S.mem p1 x = true).

(* Goal: @eq bool (S.mem p1 x) true *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
            rewrite <- HEq in Hmem1'.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
            rewrite SWP.Dec.F.add_neq_b in Hmem1'; try assumption.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
            rewrite SWP.Dec.F.remove_neq_b in Hmem1'; assumption.

(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          elim (Pos.eq_dec pa p3); intro Hpap3.

(* Goal: CTCol (interp p1) (interp p3) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
            subst; rewrite HB; apply CTcol_trivial_2.

(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
            assert (Hmem3 : S.mem p3 x = true).

(* Goal: @eq bool (S.mem p3 x) true *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
              rewrite <- HEq in Hmem3'.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
              rewrite SWP.Dec.F.add_neq_b in Hmem3'; try assumption.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
              rewrite SWP.Dec.F.remove_neq_b in Hmem3'; assumption.

(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
            unfold ss_ok in HSSF.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
            apply HSSF with x.

(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
              apply SSWEqP.MP.Dec.F.mem_1; assumption.

(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
              do 2 (rewrite andb_true_iff); repeat split; assumption.

(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
        subst.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
        do 2 (rewrite andb_true_iff in Hmem).
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
        destruct Hmem as [[Hmem1' Hmem2'] Hmem3'].
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
        assert (Hmem3 : S.mem p3 x = true).

(* Goal: @eq bool (S.mem pb x) true *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          unfold partition in HIn.
(* Goal: @eq bool (S.mem pb x) true *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          apply SS.partition_spec1 in HIn; try apply proper_4.
(* Goal: @eq bool (S.mem pb x) true *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          apply SSWEqP.MP.Dec.F.filter_2 in HIn; try assumption; apply proper_4.

(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
        elim (Pos.eq_dec pa p1); intro Hpap1.

(* Goal: CTCol (interp p3) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          subst; rewrite HB; apply CTcol_permutation_4; apply CTcol_trivial_2.

(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          assert (Hmem1 : S.mem p1 x = true).

(* Goal: @eq bool (S.mem p1 x) true *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
            rewrite <- HEq in Hmem1'.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
            rewrite SWP.Dec.F.add_neq_b in Hmem1'; try assumption.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
            rewrite SWP.Dec.F.remove_neq_b in Hmem1'; assumption.

(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          elim (Pos.eq_dec pa p2); intro Hpap2.

(* Goal: CTCol (interp p1) (interp p3) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
            subst; rewrite HB; apply CTcol_trivial_2.

(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
            assert (Hmem2 : S.mem p2 x = true).

(* Goal: @eq bool (S.mem p2 x) true *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
              rewrite <- HEq in Hmem2'.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
              rewrite SWP.Dec.F.add_neq_b in Hmem2'; try assumption.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
              rewrite SWP.Dec.F.remove_neq_b in Hmem2'; assumption.

(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
            unfold ss_ok in HSSF.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
            apply HSSF with x.

(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
              apply SSWEqP.MP.Dec.F.mem_1; assumption.

(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
              do 2 (rewrite andb_true_iff); repeat split; assumption.

(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
        do 2 (rewrite andb_true_iff in Hmem).
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
        destruct Hmem as [[Hmem1' Hmem2'] Hmem3'].

        elim (Pos.eq_dec pa p1); intro Hpap1;
        elim (Pos.eq_dec pa p2); intro Hpap2;
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
        elim (Pos.eq_dec pa p3); intro Hpap3.

(* Goal: CTCol (interp p2) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          do 2 subst; apply CTcol_trivial_1.

(* Goal: CTCol (interp p2) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          do 2 subst; apply CTcol_trivial_1.

(* Goal: CTCol (interp p3) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          do 2 subst; apply CTcol_permutation_4; apply CTcol_trivial_2.

(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          subst.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          assert (Hmem1 : S.mem pb x = true).

(* Goal: @eq bool (S.mem pb x) true *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
            unfold partition in HIn.
(* Goal: @eq bool (S.mem pb x) true *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
            apply SS.partition_spec1 in HIn; try apply proper_4.
(* Goal: @eq bool (S.mem pb x) true *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
            apply SSWEqP.MP.Dec.F.filter_2 in HIn; try assumption; apply proper_4.

(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          assert (Hmem2 : S.mem p2 x = true).

(* Goal: @eq bool (S.mem p2 x) true *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
            rewrite <- HEq in Hmem2'.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
            rewrite SWP.Dec.F.add_neq_b in Hmem2'; try assumption.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
            rewrite SWP.Dec.F.remove_neq_b in Hmem2'; assumption.

(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          assert (Hmem3 : S.mem p3 x = true).

(* Goal: @eq bool (S.mem p3 x) true *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
            rewrite <- HEq in Hmem3'.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
            rewrite SWP.Dec.F.add_neq_b in Hmem3'; try assumption.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
            rewrite SWP.Dec.F.remove_neq_b in Hmem3'; assumption.

(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          rewrite <- HB.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          unfold ss_ok in HSSF.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          apply HSSF with x.

(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
            apply SSWEqP.MP.Dec.F.mem_1; assumption.

(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
            do 2 (rewrite andb_true_iff); repeat split; assumption.

(* Goal: CTCol (interp p1) (interp p3) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          do 2 subst; apply CTcol_trivial_2.

(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          subst.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          assert (Hmem2 : S.mem pb x = true).

(* Goal: @eq bool (S.mem pb x) true *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
            unfold partition in HIn.
(* Goal: @eq bool (S.mem pb x) true *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
            apply SS.partition_spec1 in HIn; try apply proper_4.
(* Goal: @eq bool (S.mem pb x) true *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
            apply SSWEqP.MP.Dec.F.filter_2 in HIn; try assumption; apply proper_4.

(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          assert (Hmem1 : S.mem p1 x = true).

(* Goal: @eq bool (S.mem p1 x) true *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
            rewrite <- HEq in Hmem1'.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
            rewrite SWP.Dec.F.add_neq_b in Hmem1'; try assumption.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
            rewrite SWP.Dec.F.remove_neq_b in Hmem1'; assumption.

(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          assert (Hmem3 : S.mem p3 x = true).

(* Goal: @eq bool (S.mem p3 x) true *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
            rewrite <- HEq in Hmem3'.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
            rewrite SWP.Dec.F.add_neq_b in Hmem3'; try assumption.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
            rewrite SWP.Dec.F.remove_neq_b in Hmem3'; assumption.

(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          rewrite <- HB.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          unfold ss_ok in HSSF.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          apply HSSF with x.

(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
            apply SSWEqP.MP.Dec.F.mem_1; assumption.

(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
            do 2 (rewrite andb_true_iff); repeat split; assumption.

(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          subst.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          assert (Hmem3 : S.mem pb x = true).

(* Goal: @eq bool (S.mem pb x) true *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
            unfold partition in HIn.
(* Goal: @eq bool (S.mem pb x) true *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
            apply SS.partition_spec1 in HIn; try apply proper_4.
(* Goal: @eq bool (S.mem pb x) true *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
            apply SSWEqP.MP.Dec.F.filter_2 in HIn; try assumption; apply proper_4.

(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          assert (Hmem1 : S.mem p1 x = true).

(* Goal: @eq bool (S.mem p1 x) true *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
            rewrite <- HEq in Hmem1'.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
            rewrite SWP.Dec.F.add_neq_b in Hmem1'; try assumption.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
            rewrite SWP.Dec.F.remove_neq_b in Hmem1'; assumption.

(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          assert (Hmem2 : S.mem p2 x = true).

(* Goal: @eq bool (S.mem p2 x) true *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
            rewrite <- HEq in Hmem2'.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
            rewrite SWP.Dec.F.add_neq_b in Hmem2'; try assumption.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
            rewrite SWP.Dec.F.remove_neq_b in Hmem2'; assumption.

(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          rewrite <- HB.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          unfold ss_ok in HSSF.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          apply HSSF with x.

(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
            apply SSWEqP.MP.Dec.F.mem_1; assumption.

(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
            do 2 (rewrite andb_true_iff); repeat split; assumption.

(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
         assert (Hmem1 : S.mem p1 x = true).

(* Goal: @eq bool (S.mem p1 x) true *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
            rewrite <- HEq in Hmem1'.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
            rewrite SWP.Dec.F.add_neq_b in Hmem1'; try assumption.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
            rewrite SWP.Dec.F.remove_neq_b in Hmem1'; assumption.

(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          assert (Hmem2 : S.mem p2 x = true).

(* Goal: @eq bool (S.mem p2 x) true *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
            rewrite <- HEq in Hmem2'.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
            rewrite SWP.Dec.F.add_neq_b in Hmem2'; try assumption.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
            rewrite SWP.Dec.F.remove_neq_b in Hmem2'; assumption.

(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          assert (Hmem3 : S.mem p3 x = true).

(* Goal: @eq bool (S.mem p3 x) true *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
            rewrite <- HEq in Hmem3'.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
            rewrite SWP.Dec.F.add_neq_b in Hmem3'; try assumption.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
            rewrite SWP.Dec.F.remove_neq_b in Hmem3'; assumption.

(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          unfold ss_ok in HSSF.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
          apply HSSF with x.

(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
            apply SSWEqP.MP.Dec.F.mem_1; assumption.

(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
            do 2 (rewrite andb_true_iff); repeat split; assumption.

(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
      unfold ss_ok in HSSa.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
      apply HSSa with s'; try assumption.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
      apply SSWEqP.MP.Dec.F.mem_1; assumption.

(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
  clear HSSF; assert (HSSF := HSSF'); clear HSSF'.

(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
  unfold ss_ok in HSSF.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
  apply HSSF with s; try assumption.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
  apply SSWEqP.MP.Dec.F.mem_1; assumption.

(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
  assert (HSSS : ss_ok (snd_ss (partition_ss pb ss)) interp).

(* Goal: ss_ok (snd_ss (partition_ss pb ss)) interp *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
    clear Hmem; clear p1; clear p2; clear p3.
(* Goal: ss_ok (snd_ss (partition_ss pb ss)) interp *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
    intros s' Hs'.
(* Goal: forall (p1 p2 p3 : S.elt) (_ : @eq bool (andb (andb (S.mem p1 s') (S.mem p2 s')) (S.mem p3 s')) true), CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
    intros.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
    apply SSWEqP.MP.Dec.F.mem_2 in Hs'.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
    unfold partition in Hs'.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
    apply SS.partition_spec2 in Hs'; try apply proper_4.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
    apply SSWEqP.MP.Dec.F.filter_1 in Hs'; try apply proper_5.
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
    unfold ss_ok in HSS.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    apply HSS with s'; try assumption.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    apply SSWEqP.MP.Dec.F.mem_1; assumption.

(* Goal: CTCol (interp p1) (interp p2) (interp p3) *)
  unfold ss_ok in HSSS.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
  apply HSSS with s; try assumption.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
  apply SSWEqP.MP.Dec.F.mem_1; assumption.
Qed.

Definition partition_sp_1 p sp :=
  SP.partition (fun e => Pos.eqb (fstpp e) p || Pos.eqb (sndpp e) p) sp.

Definition partition_sp_2 p sp :=
  SP.partition (fun e => Pos.eqb (fstpp e) p) sp.

Definition fst_sp (pair : SP.t * SP.t) :=
 match pair with
    |(a,b) => a
  end.

Definition snd_sp (pair : SP.t * SP.t) :=
 match pair with
    |(a,b) => b
  end.

Definition new_pair_1 pair (pos : positive) := (pos, sndpp(pair)).

Definition new_pair_2 pair (pos : positive) := (fstpp(pair), pos).

Definition subst_in_sp_aux_1 := (fun pos pair sp => SP.add (new_pair_1 pair pos) sp).

Definition subst_in_sp_aux_2 := (fun pos pair sp => SP.add (new_pair_2 pair pos) sp).

Definition subst_in_sp p1 p2 sp :=
  let pair_1 := partition_sp_1 p2 sp in
  let sp_to_modify := fst_sp(pair_1) in
  let sp_to_keep := snd_sp(pair_1) in
  let pair_2 := partition_sp_2 p2 sp_to_modify in
  let sp_to_modify_f := fst_sp(pair_2) in
  let sp_to_modify_s := snd_sp(pair_2) in
  let newsp_to_modify_f := SP.fold (subst_in_sp_aux_1 p1) sp_to_modify_f SP.empty in
  let newsp_to_modify_s := SP.fold (subst_in_sp_aux_2 p1) sp_to_modify_s SP.empty in
  SP.union (SP.union newsp_to_modify_f newsp_to_modify_s) sp_to_keep.

Lemma proper_6 : forall p, Proper ((fun t1 t2 : SetOfPairsOfPositiveOrderedType.t =>
                                  Pos.eq (fstpp t1) (fstpp t2) /\ Pos.eq (sndpp t1) (sndpp t2)) ==> eq)
                                  (fun e : SP.elt => (fstpp e =? p)%positive || (sndpp e =? p)%positive).
Proof.
(* Goal: forall p : positive, @Proper (forall _ : SetOfPairsOfPositiveOrderedType.t, bool) (@respectful SetOfPairsOfPositiveOrderedType.t bool (fun t1 t2 : SetOfPairsOfPositiveOrderedType.t => and (Pos.eq (fstpp t1) (fstpp t2)) (Pos.eq (sndpp t1) (sndpp t2))) (@eq bool)) (fun x : SP.elt => negb (Pos.eqb (fstpp x) p)) *)
intros p x y Hxy.
(* Goal: @eq bool (negb (Pos.eqb (fstpp x) p)) (negb (Pos.eqb (fstpp y) p)) *)
destruct Hxy as [Hxyf Hxys].
(* Goal: @eq bool (negb (orb (Pos.eqb (fstpp x) p) (Pos.eqb (sndpp x) p))) (negb (orb (Pos.eqb (fstpp y) p) (Pos.eqb (sndpp y) p))) *)
rewrite Hxyf; rewrite Hxys.
(* Goal: @eq bool (negb (Pos.eqb (fstpp y) p)) (negb (Pos.eqb (fstpp y) p)) *)
reflexivity.
Qed.

Lemma proper_7 : forall p, Proper ((fun t1 t2 : SetOfPairsOfPositiveOrderedType.t =>
                                  Pos.eq (fstpp t1) (fstpp t2) /\ Pos.eq (sndpp t1) (sndpp t2)) ==> eq)
                                  (fun x : SP.elt => negb ((fstpp x =? p)%positive || (sndpp x =? p)%positive)).
Proof.
(* Goal: forall p : positive, @Proper (forall _ : SetOfPairsOfPositiveOrderedType.t, bool) (@respectful SetOfPairsOfPositiveOrderedType.t bool (fun t1 t2 : SetOfPairsOfPositiveOrderedType.t => and (Pos.eq (fstpp t1) (fstpp t2)) (Pos.eq (sndpp t1) (sndpp t2))) (@eq bool)) (fun x : SP.elt => negb (Pos.eqb (fstpp x) p)) *)
intros p x y Hxy.
(* Goal: @eq bool (negb (Pos.eqb (fstpp x) p)) (negb (Pos.eqb (fstpp y) p)) *)
destruct Hxy as [Hxyf Hxys].
(* Goal: @eq bool (negb (orb (Pos.eqb (fstpp x) p) (Pos.eqb (sndpp x) p))) (negb (orb (Pos.eqb (fstpp y) p) (Pos.eqb (sndpp y) p))) *)
rewrite Hxyf; rewrite Hxys.
(* Goal: @eq bool (negb (Pos.eqb (fstpp y) p)) (negb (Pos.eqb (fstpp y) p)) *)
reflexivity.
Qed.

Lemma proper_8 : forall p, Proper ((fun t1 t2 : SetOfPairsOfPositiveOrderedType.t =>
                                  Pos.eq (fstpp t1) (fstpp t2) /\ Pos.eq (sndpp t1) (sndpp t2)) ==> eq)
                                  (fun e : SP.elt => (fstpp e =? p)%positive).
Proof.
(* Goal: forall p : positive, @Proper (forall _ : SetOfPairsOfPositiveOrderedType.t, bool) (@respectful SetOfPairsOfPositiveOrderedType.t bool (fun t1 t2 : SetOfPairsOfPositiveOrderedType.t => and (Pos.eq (fstpp t1) (fstpp t2)) (Pos.eq (sndpp t1) (sndpp t2))) (@eq bool)) (fun x : SP.elt => negb (Pos.eqb (fstpp x) p)) *)
intros p x y Hxy.
(* Goal: @eq bool (negb (Pos.eqb (fstpp x) p)) (negb (Pos.eqb (fstpp y) p)) *)
destruct Hxy as [Hxyf Hxys].
(* Goal: @eq bool (negb (Pos.eqb (fstpp x) p)) (negb (Pos.eqb (fstpp y) p)) *)
rewrite Hxyf.
(* Goal: @eq bool (negb (Pos.eqb (fstpp y) p)) (negb (Pos.eqb (fstpp y) p)) *)
reflexivity.
Qed.

Lemma proper_9 : forall p, Proper ((fun t1 t2 : SetOfPairsOfPositiveOrderedType.t =>
                                  Pos.eq (fstpp t1) (fstpp t2) /\ Pos.eq (sndpp t1) (sndpp t2)) ==> eq)
                                  (fun x : SP.elt => negb (fstpp x =? p)%positive).
Proof.
(* Goal: forall p : positive, @Proper (forall _ : SetOfPairsOfPositiveOrderedType.t, bool) (@respectful SetOfPairsOfPositiveOrderedType.t bool (fun t1 t2 : SetOfPairsOfPositiveOrderedType.t => and (Pos.eq (fstpp t1) (fstpp t2)) (Pos.eq (sndpp t1) (sndpp t2))) (@eq bool)) (fun x : SP.elt => negb (Pos.eqb (fstpp x) p)) *)
intros p x y Hxy.
(* Goal: @eq bool (negb (Pos.eqb (fstpp x) p)) (negb (Pos.eqb (fstpp y) p)) *)
destruct Hxy as [Hxyf Hxys].
(* Goal: @eq bool (negb (Pos.eqb (fstpp x) p)) (negb (Pos.eqb (fstpp y) p)) *)
rewrite Hxyf.
(* Goal: @eq bool (negb (Pos.eqb (fstpp y) p)) (negb (Pos.eqb (fstpp y) p)) *)
reflexivity.
Qed.

Lemma subst_sp_ok :
  forall (A B : COLTpoint) (H : A = B) pa pb sp (interp :  positive -> COLTpoint),
  interp pa = A ->
  interp pb = B ->
  sp_ok sp interp -> sp_ok (subst_in_sp pa pb sp) interp.
Proof.
(* Goal: forall (A B : COLTpoint) (_ : @eq COLTpoint A B) (pa pb : positive) (sp : SP.t) (interp : forall _ : positive, COLTpoint) (_ : @eq COLTpoint (interp pa) A) (_ : @eq COLTpoint (interp pb) B) (_ : sp_ok sp interp), sp_ok (subst_in_sp pa pb sp) interp *)
intros A B H pa pb sp interp HA HB HSP.
(* Goal: sp_ok (subst_in_sp pa pb sp) interp *)
unfold subst_in_sp.
(* Goal: sp_ok (SP.union (SP.union (@SP.fold SP.t (subst_in_sp_aux_1 pa) (fst_sp (partition_sp_2 pb (fst_sp (partition_sp_1 pb sp)))) SP.empty) (@SP.fold SP.t (subst_in_sp_aux_2 pa) (snd_sp (partition_sp_2 pb (fst_sp (partition_sp_1 pb sp)))) SP.empty)) (snd_sp (partition_sp_1 pb sp))) interp *)
unfold sp_ok.
(* Goal: forall (p : SP.elt) (_ : @eq bool (SP.mem p (SP.union (SP.union (@SP.fold SP.t (subst_in_sp_aux_1 pa) (fst_sp (partition_sp_2 pb (fst_sp (partition_sp_1 pb sp)))) SP.empty) (@SP.fold SP.t (subst_in_sp_aux_2 pa) (snd_sp (partition_sp_2 pb (fst_sp (partition_sp_1 pb sp)))) SP.empty)) (snd_sp (partition_sp_1 pb sp)))) true), not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
intros p Hp.
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
apply SPWEqP.MP.Dec.F.mem_2 in Hp.
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
do 2 rewrite SPWEqP.MP.Dec.F.union_iff in Hp.
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
elim Hp; intro HInAux; clear Hp.

(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
  assert (HSPM : sp_ok (fst_sp (partition_sp_1 pb sp)) interp).

(* Goal: sp_ok (snd_sp (partition_sp_1 pb sp)) interp *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    intros p' Hp'.
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    apply SPWEqP.MP.Dec.F.mem_2 in Hp'.
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    unfold partition_sp_1 in Hp'.
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    apply SP.partition_spec1 in Hp'; try apply proper_6.
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    apply SPWEqP.MP.Dec.F.filter_1 in Hp'; try apply proper_6.
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    unfold sp_ok in HSP.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    apply HSP; try assumption.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    apply SPWEqP.MP.Dec.F.mem_1; assumption.

(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
  clear HSP.
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
  elim HInAux; intro HIn; clear HInAux.

(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    assert (HSPF : sp_ok (fst_sp (partition_sp_2 pb (fst_sp (partition_sp_1 pb sp)))) interp).

(* Goal: sp_ok (snd_sp (partition_sp_1 pb sp)) interp *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
      intros p' Hp'.
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
      apply SPWEqP.MP.Dec.F.mem_2 in Hp'.
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
      unfold partition_sp_1 in Hp'.
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
      apply SP.partition_spec1 in Hp'; try apply proper_8.
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
      apply SPWEqP.MP.Dec.F.filter_1 in Hp'; try apply proper_8.
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
      unfold sp_ok in HSPM.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
      apply HSPM; try assumption.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
      apply SPWEqP.MP.Dec.F.mem_1; assumption.

(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    clear HSPM.

    assert (HSPF' : sp_ok (SP.fold (subst_in_sp_aux_1 pa)
                         (fst_sp (partition_sp_2 pb (fst_sp (partition_sp_1 pb sp))))
                         SP.empty) interp).
(* Goal: sp_ok (@SP.fold SP.t (subst_in_sp_aux_2 pa) (snd_sp (partition_sp_2 pb (fst_sp (partition_sp_1 pb sp)))) SP.empty) interp *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    apply SPWEqP.MP.fold_rec_nodep; try apply sp_ok_empty.
(* Goal: forall (x : SP.elt) (a : SP.t) (_ : SP.In x (snd_sp (partition_sp_2 pb (fst_sp (partition_sp_1 pb sp))))) (_ : sp_ok a interp), sp_ok (subst_in_sp_aux_2 pa x a) interp *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    clear HIn.
(* Goal: forall (x : SP.elt) (a : SP.t) (_ : SP.In x (snd_sp (partition_sp_2 pb (fst_sp (partition_sp_1 pb sp))))) (_ : sp_ok a interp), sp_ok (subst_in_sp_aux_2 pa x a) interp *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    intros x a HInRec HSPRec.
(* Goal: sp_ok (snd_sp (partition_sp_1 pb sp)) interp *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    intros p' Hp'.
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    unfold subst_in_sp_aux_1 in *.
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    apply SPWEqP.MP.Dec.F.mem_2 in Hp'.
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    rewrite SPWEqP.MP.Dec.F.add_iff in Hp'.
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    elim Hp'; intro HIn; clear Hp'.

(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
      destruct HIn as [HEq1 HEq2].
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
      rewrite <- HEq1; rewrite <- HEq2.
(* Goal: not (@eq COLTpoint (interp (fstpp (new_pair_1 x pa))) (interp (sndpp (new_pair_1 x pa)))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
      unfold new_pair_1.
(* Goal: not (@eq COLTpoint (interp (fstpp (@pair positive positive (fstpp x) pa))) (interp (sndpp (@pair positive positive (fstpp x) pa)))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
      clear HSPRec; clear a.
(* Goal: not (@eq COLTpoint (interp (fstpp (@pair positive positive pa (sndpp x)))) (interp (sndpp (@pair positive positive pa (sndpp x))))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
      elim (Pos.min_spec pa (sndpp(x))); intro Hmin.

(* Goal: not (@eq COLTpoint (interp (fstpp (@pair positive positive (fstpp x) pa))) (interp (sndpp (@pair positive positive (fstpp x) pa)))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp (@pair positive positive (fstpp x) pa))) (interp (sndpp (@pair positive positive (fstpp x) pa)))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
        destruct Hmin as [HLt Hmin].
(* Goal: not (@eq COLTpoint (interp (fstpp (@pair positive positive pa (sndpp x)))) (interp (sndpp (@pair positive positive pa (sndpp x))))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp (@pair positive positive pa (sndpp x)))) (interp (sndpp (@pair positive positive pa (sndpp x))))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
        assert (Hmax : Pos.max pa (sndpp(x)) = (sndpp(x))) by (apply Pos.max_r; apply Pos.lt_le_incl; assumption).
(* Goal: not (@eq COLTpoint (interp (fstpp (@pair positive positive pa (sndpp x)))) (interp (sndpp (@pair positive positive pa (sndpp x))))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp (@pair positive positive pa (sndpp x)))) (interp (sndpp (@pair positive positive pa (sndpp x))))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
        assert (HF : fstpp(pa, sndpp(x)) = pa) by (unfold fstpp; assumption).
(* Goal: not (@eq COLTpoint (interp (fstpp (@pair positive positive pa (sndpp x)))) (interp (sndpp (@pair positive positive pa (sndpp x))))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp (@pair positive positive pa (sndpp x)))) (interp (sndpp (@pair positive positive pa (sndpp x))))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
        assert (HS : sndpp(pa, sndpp(x)) = sndpp(x)) by (unfold sndpp; assumption).
(* Goal: not (@eq COLTpoint (interp (fstpp (@pair positive positive (fstpp x) pa))) (interp (sndpp (@pair positive positive (fstpp x) pa)))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
        rewrite HF; rewrite HS.

(* Goal: not (@eq COLTpoint (interp (sndpp x)) (interp pa)) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
        assert (Hpb : fstpp(x) = pb).

(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
          unfold partition_sp_2 in HInRec.
(* Goal: @eq positive (fstpp x) pb *)
(* Goal: not (@eq COLTpoint (interp (sndpp x)) (interp pa)) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
          apply SP.partition_spec1 in HInRec; try apply proper_8.
(* Goal: @eq positive (fstpp x) pb *)
(* Goal: not (@eq COLTpoint (interp (sndpp x)) (interp pa)) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
          apply SPWEqP.MP.Dec.F.filter_2 in HInRec; try apply proper_8.
(* Goal: @eq positive (fstpp x) pb *)
(* Goal: not (@eq COLTpoint (interp (sndpp x)) (interp pa)) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
          apply Ndec.Peqb_complete.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
          assumption.

(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
        intro HEq4.
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
        unfold sp_ok in HSPF.
(* Goal: False *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
        apply SPWEqP.MP.Dec.F.mem_1 in HInRec.
(* Goal: False *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
        apply (HSPF x) in HInRec.
(* Goal: False *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
        apply HInRec.
(* Goal: @eq bool (negb (Pos.eqb (fstpp y) p)) (negb (Pos.eqb (fstpp y) p)) *)
        rewrite Hpb; rewrite <- HEq4; rewrite HA; rewrite HB; rewrite H; reflexivity.

(* Goal: not (@eq COLTpoint (interp (fstpp (@pair positive positive (fstpp x) pa))) (interp (sndpp (@pair positive positive (fstpp x) pa)))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
        destruct Hmin as [HLe Hmin].
(* Goal: not (@eq COLTpoint (interp (fstpp (@pair positive positive pa (sndpp x)))) (interp (sndpp (@pair positive positive pa (sndpp x))))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
        assert (Hmax : Pos.max pa (sndpp(x)) = pa) by (apply Pos.max_l; assumption).
(* Goal: not (@eq COLTpoint (interp (fstpp (@pair positive positive pa (sndpp x)))) (interp (sndpp (@pair positive positive pa (sndpp x))))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
        assert (HF : fstpp(pa, sndpp(x)) = sndpp(x)) by (unfold fstpp; assumption).
(* Goal: not (@eq COLTpoint (interp (fstpp (@pair positive positive pa (sndpp x)))) (interp (sndpp (@pair positive positive pa (sndpp x))))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
        assert (HS : sndpp(pa, sndpp(x)) = pa) by (unfold sndpp; assumption).
(* Goal: not (@eq COLTpoint (interp (fstpp (@pair positive positive (fstpp x) pa))) (interp (sndpp (@pair positive positive (fstpp x) pa)))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
        rewrite HF; rewrite HS.

(* Goal: not (@eq COLTpoint (interp (sndpp x)) (interp pa)) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
        assert (Hpb : fstpp(x) = pb).

(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
          unfold partition_sp_2 in HInRec.
(* Goal: @eq positive (fstpp x) pb *)
(* Goal: not (@eq COLTpoint (interp (sndpp x)) (interp pa)) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
          apply SP.partition_spec1 in HInRec; try apply proper_8.
(* Goal: @eq positive (fstpp x) pb *)
(* Goal: not (@eq COLTpoint (interp (sndpp x)) (interp pa)) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
          apply SPWEqP.MP.Dec.F.filter_2 in HInRec; try apply proper_8.
(* Goal: @eq positive (fstpp x) pb *)
(* Goal: not (@eq COLTpoint (interp (sndpp x)) (interp pa)) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
          apply Ndec.Peqb_complete.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
          assumption.

(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
        intro HEq4.
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
        unfold sp_ok in HSPF.
(* Goal: False *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
        apply SPWEqP.MP.Dec.F.mem_1 in HInRec.
(* Goal: False *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
        apply (HSPF x) in HInRec.
(* Goal: False *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
        apply HInRec.
(* Goal: @eq bool (negb (Pos.eqb (fstpp y) p)) (negb (Pos.eqb (fstpp y) p)) *)
        rewrite Hpb; rewrite HEq4; rewrite HA; rewrite HB; rewrite H; reflexivity.

(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
      unfold sp_ok in HSPRec.
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
      apply HSPRec.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
      apply SPWEqP.MP.Dec.F.mem_1; assumption.

(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    clear HSPF; assert (HSPF := HSPF'); clear HSPF'.
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    unfold sp_ok in HSPF.
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    apply HSPF.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    apply SPWEqP.MP.Dec.F.mem_1; assumption.

(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    assert (HSPS : sp_ok (snd_sp (partition_sp_2 pb (fst_sp (partition_sp_1 pb sp)))) interp).

(* Goal: sp_ok (snd_sp (partition_sp_1 pb sp)) interp *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
      intros p' Hp'.
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
      apply SPWEqP.MP.Dec.F.mem_2 in Hp'.
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
      unfold partition_sp_1 in Hp'.
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
      apply SP.partition_spec2 in Hp'; try apply proper_8.
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
      apply SPWEqP.MP.Dec.F.filter_1 in Hp'; try apply proper_9.
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
      unfold sp_ok in HSPM.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
      apply HSPM; try assumption.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
      apply SPWEqP.MP.Dec.F.mem_1; assumption.

(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    clear HSPM.

    assert (HSPS' : sp_ok (SP.fold (subst_in_sp_aux_2 pa)
                         (snd_sp (partition_sp_2 pb (fst_sp (partition_sp_1 pb sp))))
                         SP.empty) interp).
(* Goal: sp_ok (@SP.fold SP.t (subst_in_sp_aux_2 pa) (snd_sp (partition_sp_2 pb (fst_sp (partition_sp_1 pb sp)))) SP.empty) interp *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    apply SPWEqP.MP.fold_rec_nodep; try apply sp_ok_empty.
(* Goal: forall (x : SP.elt) (a : SP.t) (_ : SP.In x (snd_sp (partition_sp_2 pb (fst_sp (partition_sp_1 pb sp))))) (_ : sp_ok a interp), sp_ok (subst_in_sp_aux_2 pa x a) interp *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    clear HIn.
(* Goal: forall (x : SP.elt) (a : SP.t) (_ : SP.In x (snd_sp (partition_sp_2 pb (fst_sp (partition_sp_1 pb sp))))) (_ : sp_ok a interp), sp_ok (subst_in_sp_aux_2 pa x a) interp *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    intros x a HInRec HSPRec.
(* Goal: sp_ok (snd_sp (partition_sp_1 pb sp)) interp *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    intros p' Hp'.
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    unfold subst_in_sp_aux_2 in *.
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    apply SPWEqP.MP.Dec.F.mem_2 in Hp'.
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    rewrite SPWEqP.MP.Dec.F.add_iff in Hp'.
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    elim Hp'; intro HIn; clear Hp'.

(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
      destruct HIn as [HEq1 HEq2].
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
      rewrite <- HEq1; rewrite <- HEq2.
(* Goal: not (@eq COLTpoint (interp (fstpp (new_pair_2 x pa))) (interp (sndpp (new_pair_2 x pa)))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
      unfold new_pair_2.
(* Goal: not (@eq COLTpoint (interp (fstpp (@pair positive positive (fstpp x) pa))) (interp (sndpp (@pair positive positive (fstpp x) pa)))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
      clear HSPRec; clear a.
(* Goal: not (@eq COLTpoint (interp (fstpp (@pair positive positive (fstpp x) pa))) (interp (sndpp (@pair positive positive (fstpp x) pa)))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
      elim (Pos.min_spec (fstpp(x)) pa); intro Hmin.

(* Goal: not (@eq COLTpoint (interp (fstpp (@pair positive positive (fstpp x) pa))) (interp (sndpp (@pair positive positive (fstpp x) pa)))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp (@pair positive positive (fstpp x) pa))) (interp (sndpp (@pair positive positive (fstpp x) pa)))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
        destruct Hmin as [HLt Hmin].
(* Goal: not (@eq COLTpoint (interp (fstpp (@pair positive positive (fstpp x) pa))) (interp (sndpp (@pair positive positive (fstpp x) pa)))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp (@pair positive positive (fstpp x) pa))) (interp (sndpp (@pair positive positive (fstpp x) pa)))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
        assert (Hmax : Pos.max (fstpp(x)) pa = pa) by (apply Pos.max_r; apply Pos.lt_le_incl; assumption).
(* Goal: not (@eq COLTpoint (interp (fstpp (@pair positive positive (fstpp x) pa))) (interp (sndpp (@pair positive positive (fstpp x) pa)))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp (@pair positive positive (fstpp x) pa))) (interp (sndpp (@pair positive positive (fstpp x) pa)))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
        assert (HF : fstpp(fstpp(x), pa) = fstpp(x)) by (unfold fstpp; assumption).
(* Goal: not (@eq COLTpoint (interp (fstpp (@pair positive positive (fstpp x) pa))) (interp (sndpp (@pair positive positive (fstpp x) pa)))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp (@pair positive positive (fstpp x) pa))) (interp (sndpp (@pair positive positive (fstpp x) pa)))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
        assert (HS : sndpp(fstpp(x), pa) = pa) by (unfold sndpp; assumption).
(* Goal: not (@eq COLTpoint (interp (fstpp (@pair positive positive (fstpp x) pa))) (interp (sndpp (@pair positive positive (fstpp x) pa)))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
        rewrite HF; rewrite HS.

(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
        assert (Hpb : sndpp(x) = pb).

(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
          assert (HIn : SP.In x (fst_sp (partition_sp_1 pb sp))).

(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
            unfold partition_sp_2 in HInRec.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
            apply SP.partition_spec2 in HInRec; try apply proper_8.
(* Goal: SP.In x (fst_sp (partition_sp_1 pb sp)) *)
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
            apply SPWEqP.MP.Dec.F.filter_1 in HInRec; try apply proper_9.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
            assumption.

(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
          unfold partition_sp_2 in HInRec.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
          apply SP.partition_spec2 in HInRec; try apply proper_8.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
          apply SPWEqP.MP.Dec.F.filter_2 in HInRec; try apply proper_9.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
          unfold partition_sp_1 in HIn.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
          apply SP.partition_spec1 in HIn; try apply proper_6.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
          apply SPWEqP.MP.Dec.F.filter_2 in HIn; try apply proper_6.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
          apply orb_true_iff in HIn.
(* Goal: forall (x : SP.elt) (a : SP.t) (_ : SP.In x (snd_sp (partition_sp_2 pb (fst_sp (partition_sp_1 pb sp))))) (_ : sp_ok a interp), sp_ok (subst_in_sp_aux_2 pa x a) interp *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
          elim HIn; intro HEqb; clear HIn.

(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
            apply Peqb_true_eq in HEqb.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
            apply negb_true_iff in HInRec.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
            apply Pos.eqb_neq in HInRec.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
            rewrite HEqb in HInRec.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
            intuition.

(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
            apply Peqb_true_eq in HEqb.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
            assumption.

(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
        intro HEq4.
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
        unfold sp_ok in HSPS.
(* Goal: False *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
        apply SPWEqP.MP.Dec.F.mem_1 in HInRec.
(* Goal: False *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
        apply (HSPS x) in HInRec.
(* Goal: False *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
        apply HInRec.
(* Goal: @eq bool (negb (Pos.eqb (fstpp y) p)) (negb (Pos.eqb (fstpp y) p)) *)
        rewrite Hpb; rewrite HEq4; rewrite HA; rewrite HB; rewrite H; reflexivity.

(* Goal: not (@eq COLTpoint (interp (fstpp (@pair positive positive (fstpp x) pa))) (interp (sndpp (@pair positive positive (fstpp x) pa)))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
        destruct Hmin as [HLe Hmin].
(* Goal: not (@eq COLTpoint (interp (fstpp (@pair positive positive (fstpp x) pa))) (interp (sndpp (@pair positive positive (fstpp x) pa)))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
        assert (Hmax : Pos.max (fstpp(x)) pa = fstpp(x)) by (apply Pos.max_l; assumption).
(* Goal: not (@eq COLTpoint (interp (fstpp (@pair positive positive (fstpp x) pa))) (interp (sndpp (@pair positive positive (fstpp x) pa)))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
        assert (HF : fstpp(fstpp(x), pa) = pa) by (unfold fstpp; assumption).
(* Goal: not (@eq COLTpoint (interp (fstpp (@pair positive positive (fstpp x) pa))) (interp (sndpp (@pair positive positive (fstpp x) pa)))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
        assert (HS : sndpp(fstpp(x), pa) = fstpp(x)) by (unfold sndpp; assumption).
(* Goal: not (@eq COLTpoint (interp (fstpp (@pair positive positive (fstpp x) pa))) (interp (sndpp (@pair positive positive (fstpp x) pa)))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
        rewrite HF; rewrite HS.

(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
        assert (Hpb : sndpp(x) = pb).

(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
          assert (HIn : SP.In x (fst_sp (partition_sp_1 pb sp))).

(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
            unfold partition_sp_2 in HInRec.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
            apply SP.partition_spec2 in HInRec; try apply proper_8.
(* Goal: SP.In x (fst_sp (partition_sp_1 pb sp)) *)
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
            apply SPWEqP.MP.Dec.F.filter_1 in HInRec; try apply proper_9.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
            assumption.

(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
          unfold partition_sp_2 in HInRec.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
          apply SP.partition_spec2 in HInRec; try apply proper_8.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
          apply SPWEqP.MP.Dec.F.filter_2 in HInRec; try apply proper_9.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
          unfold partition_sp_1 in HIn.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
          apply SP.partition_spec1 in HIn; try apply proper_6.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
          apply SPWEqP.MP.Dec.F.filter_2 in HIn; try apply proper_6.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
          apply orb_true_iff in HIn.
(* Goal: forall (x : SP.elt) (a : SP.t) (_ : SP.In x (snd_sp (partition_sp_2 pb (fst_sp (partition_sp_1 pb sp))))) (_ : sp_ok a interp), sp_ok (subst_in_sp_aux_2 pa x a) interp *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
          elim HIn; intro HEqb; clear HIn.

(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
            apply Peqb_true_eq in HEqb.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
            apply negb_true_iff in HInRec.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
            apply Pos.eqb_neq in HInRec.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
            rewrite HEqb in HInRec.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
            intuition.

(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
            apply Peqb_true_eq in HEqb.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
            assumption.

(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
        intro HEq4.
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
        unfold sp_ok in HSPS.
(* Goal: False *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
        apply SPWEqP.MP.Dec.F.mem_1 in HInRec.
(* Goal: False *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
        apply (HSPS x) in HInRec.
(* Goal: False *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
        apply HInRec.
(* Goal: @eq bool (negb (Pos.eqb (fstpp y) p)) (negb (Pos.eqb (fstpp y) p)) *)
        rewrite Hpb; rewrite <- HEq4; rewrite HA; rewrite HB; rewrite H; reflexivity.

(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
      unfold sp_ok in HSPRec.
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
      apply HSPRec.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
      apply SPWEqP.MP.Dec.F.mem_1; assumption.

(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    clear HSPS; assert (HSPS := HSPS'); clear HSPS'.
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    unfold sp_ok in HSPS.
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    apply HSPS.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    apply SPWEqP.MP.Dec.F.mem_1; assumption.

(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
  assert (HIn := HInAux); clear HInAux.
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
  assert (HSPK : sp_ok (snd_sp (partition_sp_1 pb sp)) interp).

(* Goal: sp_ok (snd_sp (partition_sp_1 pb sp)) interp *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    intros p' Hp'.
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    apply SPWEqP.MP.Dec.F.mem_2 in Hp'.
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    unfold partition_sp_1 in Hp'.
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    apply SP.partition_spec2 in Hp'; try apply proper_6.
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    apply SPWEqP.MP.Dec.F.filter_1 in Hp'; try apply proper_7.
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    unfold sp_ok in HSP.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    apply HSP; try assumption.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
    apply SPWEqP.MP.Dec.F.mem_1; assumption.

(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
  unfold sp_ok in HSPK.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
  apply HSPK; try assumption.
(* Goal: @eq positive (sndpp x) pb *)
(* Goal: not (@eq COLTpoint (interp pa) (interp (fstpp x))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p')) (interp (sndpp p'))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
(* Goal: not (@eq COLTpoint (interp (fstpp p)) (interp (sndpp p))) *)
  apply SPWEqP.MP.Dec.F.mem_1; assumption.
Qed.

End Col_refl.