Function identify_varieties (ss : SS.t) (st : STt) {measure SS.cardinal ss}
: SS.t :=
let varieties := pick_varieties ss st in
match varieties 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_varieties newss st
end.

Lemma memCPAuxProperOK : forall m, Proper (eq ==> S.Equal==> eq) (memCPAux m).