Require Import Relations.
Require Import mathcomp.ssreflect.ssreflect.
Require Import Kstar_def.
Set Implicit Arguments.
Import Prenex Implicits.
Implicit Types (S cls X Y : {fset clause}) (C D : clause).
Require Import mathcomp.ssreflect.ssreflect.
Require Import Kstar_def.
Set Implicit Arguments.
Import Prenex Implicits.
Implicit Types (S cls X Y : {fset clause}) (C D : clause).
Definition suppS S C := [some D in S, suppC D C].
Definition rtrans C D := suppC D (R C).
Inductive fulfillAG S s C : Prop :=
| fulfillAG1 D : D \in S -> rtrans C D -> D |> s^- -> fulfillAG S s C
| fulfillAGn D : D \in S -> rtrans C D -> fulfillAG S s D -> fulfillAG S s C.
Lemma fulfillAGEn s S C : ~ fulfillAG S s C ->
forall D, D \in S -> rtrans C D -> ~~ D |> s^- /\ ~ fulfillAG S s D.
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).
Definition D2 cls := forall C, C \in cls -> forall s, fAX (fAG s)^- \in C -> fulfillAG cls s C.
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).
Record demo := Demo
{
cls :> {fset clause} ;
demoD0 : D0 cls ;
demoD1 : D1 cls ;
demoD2 : D2 cls }.
Canonical demo_predType := mkPredType (fun (S : demo) (C : clause) => nosimpl C \in cls S).
Lemma LCF (S : demo) C : C \in S ->
((fF^+ \in C) = false) * (forall p, (fV p^+ \in C) && (fV p^- \in C) = false).
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.
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].
To construct the pruning demo, we need to decide the fulfillment
relations. For this we again use a fixpoint computation
Definition fulfillAG_fun s S X : {fset clause} :=
[fset C in S | [some D in S, rtrans C D && ((D |> s^-) || (D \in X))]].
Lemma fulfillAG_fun_mono s S : monotone (fulfillAG_fun s S).
Lemma fulfillAG_fun_bounded s S : bounded S (fulfillAG_fun s S).
Definition fulfillAGb s S := fset.lfp S (fulfillAG_fun s S).
Lemma fulfillAGE s S C :
(C \in fulfillAGb s S) = (C \in fulfillAG_fun s S (fulfillAGb s S)).
Lemma fulfillAGP s S C : reflect (C \in S /\ fulfillAG S s C) (C \in fulfillAGb s S).
Definition P1 C S := ~~ [all u in C, if u is fAX s^- then suppS S (s^- |` R C) else true].
Definition P2 C S := ~~ [all u in C, if u is fAX (fAG s)^- then C \in fulfillAGb s S else true].
Definition pcond C S := P1 C S || P2 C S.
Pruning yields a demo
Lemma prune_D0 : D0 (prune pcond S0).
Lemma prune_D1 : D1 (prune pcond S0).
Lemma prune_D2 : D2 (prune pcond S0).
Definition DD := Demo prune_D0 prune_D1 prune_D2.
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)
| R3 S C s : S `<=` S0 -> coref ref S ->
C \in S -> fAX (fAG s)^- \in C -> ~ fulfillAG S s C -> ref 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