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'').

(*main lemma 2' (redund_sub): if c \in s, c is not redundant in s and s -->* s', then either: (1) c \in s', or (2) c \notin s' and there exists a clauseset t such that t is a subset of s' but not a subset of the first set s  as a corollary, we have that when c is added in some step s --> s'' and s'' -->* s', then s != s'.  proof sketch: since c is added in s --> s'', c is not redundant in s''. also, we know that c \notin s and c \in s'' (since c was just added).  by lemma 2', either c \in s' (in which case s != s' since c \notin s), or there exists a clauseset t such that t is a subset of s' but not of s''. since s'' = s \cup {c}, t is not a subset of s either, so s != s'. *)
Lemma redund_sub (c: clause) (s s': clauseset) :
c \in s -> ~redund s c -> deriv s s' ->
(c \in s') \/
(c \notin s' /\ exists t: clauseset, t \subset s' /\ ~t \subset s).