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.

(* Specifications: *)
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).