Require Import mathcomp.ssreflect.ssreflect.
Require Import K_def.

Set Implicit Arguments.
Import Prenex Implicits.


Implicit Types (S cls X Y : {fset clause}) (C D : clause).

Demos

A demo consists of a finite set of clauses that satisfy the demo conditions. We do not enfoce that that the demo contains only literal clauses. However, non-literal clauses do not change the support of a clause and therefore also need not be satisfied by the construced model (See supp_eval).

Definition D0 cls := forall C, C \in cls -> lcons C.
Definition D1 cls := forall C, C \in cls -> forall s, fAX s^- \in C -> suppS cls (s^- |` R C).

Record demo := Demo
{
  cls :> {fset clause} ;
  demoD0 : D0 cls ;
  demoD1 : D1 cls
}.


Canonical demo_predType := mkPredType (fun (S : demo) (C : clause) => nosimpl C \in cls S).

Lemma LCF C : lcons C ->
  ((fF^+ \in C) = false) * (forall p, (fV p^+ \in C) && (fV p^- \in C) = false).

Model Existence


Definition rtrans C D := suppC D (R C).

Section ModelExistience.
  Variables (S : demo).

  Definition Mtype := seq_sub S.
  Definition Mtrans : rel Mtype := restrict S rtrans.
  Definition Mlabel (p:var) (C : Mtype) := fV p^+ \in val C.

  Definition model_of := FModel Mtrans Mlabel.

  Implicit Types (x y : model_of).

  Lemma supp_eval s x : val x |> s -> eval (interp s) x.

End ModelExistience.

Pruning


Section Pruning.
  Variables (F : clause).
  Hypothesis sfc_F : sf_closed F.

  Definition U := powerset F.
  Definition S0 := [fset C in U | literalC C && lcons C].

  Definition pcond C S :=
    ~~ [all u in C, if u is fAX s^- then suppS S (s^- |` R C) else true].

Pruning yields a demo

  Lemma prune_D0 : D0 (prune pcond S0).

  Lemma prune_D1 : D1 (prune pcond S0).

  Definition DD := Demo prune_D0 prune_D1.

Note: in contrast to the mathematical text the pruning function uses pcond C S as pruning rules rather than ~~ pcond C S

Refutation Predicates and corefutability of the pruning demo


  Definition coref (ref : clause -> Prop) S :=
    forall C, C \in S0 `\` S -> ref C.

  Inductive ref : clause -> Prop :=
  | R1 S C : C \in U -> coref ref S -> ~~ suppS S C -> ref C
  | R2 C s : ref (s^- |` R C) -> ref (fAX s^- |` C).

  Lemma corefD1 S C : ref C -> coref ref S -> coref ref (S `\` [fset C]).

  Lemma R1inU C s : C \in U -> fAX s^- \in C -> s^- |` R C \in U.

The pruning demo is corefutable

  Lemma coref_DD : coref ref DD.

  Lemma DD_refute C : C \in U -> ~~ suppS DD C -> ref C.

End Pruning.

Refutation Completeness


Theorem refutation_completeness F (sfc_F : sf_closed F) C :
  C \in U F -> ref F C + exists2 M:fmodel, sat M C & #|{: M}| <= 2 ^ size F.