Module Terminate. Section Terminate.
Variable (clause: finType)
(entails: {set clause} -> clause -> bool)
(redund: {set clause} -> clause -> bool)
(Trans: TRANS.Sig entails redund).
Notation redundU := (TRANS.redundU Trans).
Notation redundU2 := (TRANS.redundU2 Trans).
Notation redundD := (TRANS.redundD Trans).
(*Notation clauseset := ({set clause}).*)
Definition clauseset := set_finType clause.
(* set of clauses addable to s *)
Definition add (s: clauseset) : clauseset :=
[set c | [&& ~~redund s c &
[exists s0: clauseset, [&& s0 \subset s & entails s0 c]]]].
(* set of clauses removable from s *)
Definition rem (s: clauseset) : clauseset := [set c | redund s c].
(* the transition relation, expressed as a function to bool *)
Definition trans (s s': clauseset) :=
[exists c: clause,
if [&& c \in add s & c \notin s] then s' == c |: s
else if [&& c \in rem s & c \in s] then s' == s :\ c
else false].
(* a derivation is the graph induced by the refl. transitive closure of trans *)
Notation deriv := (connect trans).
(* predicate a is closed under "edge" relation e *)
Definition closed {T: finType} (e: rel T) (a: pred T) :=
forall x y : T, e x y -> a x -> a y.
Definition removed (c: clause) {s s'': clauseset} (step: trans s s'') :=
(c \in s) && (c \notin s'').
Definition added (c: clause) {s s'': clauseset} (step: trans s s'') :=
(c \notin s) && (c \in s'').
Definition adds (c: clause) (s s': clauseset) (trace: deriv s s') :=
[&& c \notin s & c \in s'].

Lemma deriv_plus_eq_removed
(c: clause) (s1 s2: clauseset) (step1: trans s1 s2) (trace: deriv s2 s1) :
removed c step1 -> adds c trace.