Proof with simpl; auto.
unfold one_inference_step; intros A B C.
(*DEBUGGING*)
autounfold with DEBUG_UNFOLD in *.
(*DEBUGGING*)
remember (M.delete_min unselected) as b. destruct b as [[c unselected'']| ].
2: inversion C; subst; split; auto.
symmetry in Heqb.
apply M.delete_min_spec1 in Heqb.
destruct Heqb as [Heqb ?]. subst unselected''.
remember (mem_add (simplify (M.elements given) c) given) as q.
destruct q as [new_given|].
if_tac in C. inversion C; subst. split. clear C.
symmetry in Heqq; eapply setd_mem_add with (cls := given); eauto.
apply simplify_sound; auto. eapply pick_sound; eauto.
apply setd_fold_left...
clear C. intros until s0. intros H1 H2. if_tac... solve[apply setd_add; auto].
apply infer_list_sound... apply simplify_sound... eapply pick_sound; eauto.
apply setd_remove; auto.
inversion C; subst; split; auto. apply setd_remove; auto.
if_tac in C; inversion C; subst. split; auto. apply setd_remove; auto.
split; auto. apply setd_remove; auto.
Qed.

(* Specifications: *)
Lemma simple_loop_induction (P : M.t*M.t -> Prop)
given unselected r given' unselected' :
(forall g u g' u',
P (g, u) ->
one_inference_step (g, u) = (g', u') -> P (g', u')) ->
P (given, unselected) ->
loop (given, unselected) = (r, given', unselected') -> P (given', unselected').
Lemma loop_sound given unselected given' unselected' r s :
setd clause_denote inter TT given s ->
setd clause_denote inter TT unselected s ->
loop (given, unselected) = (r, given', unselected') ->
setd clause_denote inter TT given' s /\
setd clause_denote inter TT unselected' s.
Lemma loop_Valid_empty_clause g u g' u' :
loop (g, u) = (Valid, g', u') -> M.In empty_clause g' \/ M.In empty_clause u'.
Lemma clauses_gen_sound1 R R' cs cs' s :
listd clause_denote inter TT cs s -> clauses_generate R cs = (R', cs') ->
setd clause_denote inter TT cs' s.