Require Import Omega.
Require Import mathcomp.ssreflect.ssreflect.
Require Import K_def demo.

Set Implicit Arguments.
Import Prenex Implicits.

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

Gentzen System for K

Definition of the Rules

Inductive gen : clause -> Prop :=
| gen_F C :
    gen (fF^+ |` C)
| gen_p p C :
    gen ([fset fV p^+ , fV p^- & C])
| gen_Ip s t C :
    gen (s^- |` C) -> gen (t^+ |` C) -> gen (fImp s t^+ |` C)
| gen_In s t C :
    gen ([fset s^+ , t^- & C]) -> gen (fImp s t^- |` C)
| gen_AXn s C :
    gen (s^- |` R C) -> gen (fAX s^- |` C)
.

Soundness

Theorem gen_hsound C : gen C -> prv ([af C] ---> Bot).

Lemma gen_ref_sound C : gen C -> ~ (exists M : cmodel, sat M C).

Refutation Completeness


Section RefPred.
  Variable (F : {fset sform}).
  Hypothesis (sfc_F : sf_closed F).


  Lemma lcons_gen C : ~~ lcons C -> gen C.

  Ltac Lsupp1 := by rewrite /= ?fsubUset !fsub1 !inE // !ssub_refl.
  Ltac Lsupp2 := rewrite /weight /= ?fsumU !fsum1 /= /sltype.f_weight /= -?(plusE,minusE); apply/leP; omega.
  Ltac Lsupp3 := move => L; rewrite /= ?suppCU !suppC1 /=; by bcase.

  Lemma ref_R0 C : C \in U -> (forall D, D \in base S0 C -> gen D) -> gen C.

  Lemma ref_coref S C : C \in U -> coref F gen S ->
    (forall D, D \in base S C -> gen D) -> gen C.

  Lemma ref_R1 S C : C \in U -> coref F gen S -> ~~ suppS S C -> gen C.

  Lemma ref_R2 C s : gen (s^- |` R C) -> gen (fAX s^- |` C).

  Lemma gen_of_ref C : ref F C -> gen C.

End RefPred.

Lemma ex_fc (P : cmodel -> Prop) : (exists M : fmodel, P M) -> (exists M : cmodel, P M).

Theorem gen_completeness C : gen C + (exists M : fmodel, sat M C).

Corollary gen_correctness C : gen C <-> ~ (exists M : cmodel, sat M C).

Corollary gen_dec C : decidable (gen C).