Require Export LFS.

Natural deduction for propositional logic

Formulas and contexts


Definition var := nat.

Inductive form : Type :=
| Var : varform
| Imp : formformform
| Fal : form.

Definition Not s := Imp s Fal.

Definition context := list form.

(*** This could be an exercise without decide equality. ***)
Instance form_eq_dec : s t:form, dec (s = t).


Intuitionistic system


Inductive nd (A : context) : formProp :=
| ndA s : s el And A s
| ndII s t : nd (s::A) tnd A (Imp s t)
| ndIE s t : nd A (Imp s t) → nd A snd A t
| ndE s : nd A Falnd A s.

Goal A s t, nd A (Imp (Not s) (Imp s t)).

Lemma ndA1 A s :
 nd (s :: A) s.

Lemma ndA2 A s t :
 nd (t :: s :: A) s.

Lemma ndA3 A s t u :
 nd (u :: t :: s :: A) s.

Check (nd_ind :
   p : contextformProp,
    ( (A : context) (s : form), s el Ap A s) →
    ( (A : context) (s t : form), nd (s :: A) tp (s :: A) tp A (Imp s t)) →
    ( (A : context) (s t : form), nd A (Imp s t) → p A (Imp s t) → nd A sp A sp A t) →
    ( (A : context) (s : form), nd A Falp A Falp A s) →
     (A : context) (s : form), nd A sp A s).

Lemma nd_weak A A' s :
  A <<= A'nd A snd A' s.

Lemma ndW A s t :
 nd A snd (t::A) s.

Lemma ndIE_weak A B s t :
  nd B (Imp s t) → B <<= And A snd A t.

Lemma ndapp A s u :
  Imp s u el And A snd A u.

Lemma ndapp1 A s u :
  nd (Imp s u :: A) snd (Imp s u :: A) u.

Lemma ndapp2 A s t u :
  nd (t :: Imp s u :: A) snd (t :: Imp s u :: A) u.

Lemma ndapp3 A s t u v :
  nd (t :: v :: Imp s u :: A) snd (t :: v :: Imp s u :: A) u.

Lemma ndDN A s :
  nd A snd A (Not (Not s)).

Classic system


Inductive ndc (A : context) : formProp :=
| ndcA s : s el Andc A s
| ndcII s t : ndc (s::A) tndc A (Imp s t)
| ndcIE s t : ndc A (Imp s t) → ndc A sndc A t
| ndcC s : ndc (Not s :: A) Falndc A s.

Lemma ndcA1 A s :
 ndc (s :: A) s.

Lemma ndc_weak A A' s :
  A <<= A'ndc A sndc A' s.

Lemma ndcW A s t :
 ndc A sndc (t::A) s.

Lemma ndcE A s :
  ndc A Falndc A s.

Lemma nd_ndc A s :
  nd A sndc A s.

Lemma ndc_refute A s :
  ndc A s ndc (Not s :: A) Fal.

Glivenko's theorem

says that from a classical proof of a formula one can obtain an intuitionistic proof of the double negation of the formula. It follows that intuitionistic and classical refutation coincide. The proof is by induction on ndc. For each case one has to show an intuitionistic tautology. Proving the tautologies first in Coq is very helpful. The two more involved tautologies are:
  • (s ~~ t) ~~ (s t)
  • ~~ (s t) ~~ s ~~ t

Lemma Glivenko A s :
  ndc A snd A (Not (Not s)).

Corollary Glivenko_refute A :
  nd A Fal ndc A Fal.

Corollary nd_embeds_ndc A s :
  ndc A s nd (Not s :: A) Fal.

Intuitionistic Hilbert system

The Hilbert system consists of Modus Ponens and the axioms
  • K : s t s
  • S : (s t u) (s t) s u
  • E : Fal s
We show that Hilbert derivability agrees with ND derivability. The easy direction is from Hilbert to ND. For the other direction we use the deduction theorem hilD.

Definition FK (s t : form) : form :=
  Imp s (Imp t s).

Definition FS (s t u : form) : form :=
  (Imp (Imp s (Imp t u))
       (Imp (Imp s t)
            (Imp s u))).

Inductive hil (A : context) : formProp :=
| hilA s : s el Ahil A s
| hilK s t : hil A (FK s t)
| hilS s t u : hil A (FS s t u)
| hilE s : hil A (Imp Fal s)
| hilMP s t : hil A (Imp s t) → hil A shil A t.

Check hil_ind.

Lemma hil_nd A s :
  hil A snd A s.

Lemma hilAK A s t :
  hil A shil A (Imp t s).

Lemma hilAS A s t u :
  hil A (Imp s (Imp t u)) → hil A (Imp s t) → hil A (Imp s u).

Lemma hilI A s :
  hil A (Imp s s).

Lemma hilD s A t :
  hil (s::A) thil A (Imp s t).

Lemma nd_hil A s :
  nd A shil A s.

Theorem hil_iff_nd A s :
  hil A s nd A s.

Fixpoint valb (s:form) (p:varbool) : bool :=
match s with
| Var xp x
| Falfalse
| Imp s timplb (valb s p) (valb t p)
end.

Lemma ndc_valb_sound A s p :
 ndc A s → ( t, t el Avalb t p = true) → valb s p = true.

Lemma ndc_con : ¬ ndc nil Fal.

Lemma nd_con : ¬ nd nil Fal.

Fixpoint subst (theta : varform) (s : form) : form :=
match s with
| Var xtheta x
| Imp s tImp (subst theta s) (subst theta t)
| FalFal
end.

(*** Properties of Proof Systems. ***)
Definition Assumption (p:contextformProp) :=
A s, s el Ap A s.

Definition ModusPonens (p:contextformProp) :=
A s t, p A (Imp s t) → p A sp A t.

Definition Deductivity (p:contextformProp) :=
A s t, p (s::A) tp A (Imp s t).

Definition Explosivity (p:contextformProp) :=
A s, p A Falp A s.

Definition Weakening (p:contextformProp) :=
A A' s, A <<= A'p A sp A' s.

Definition Substitutivity (p:contextformProp) :=
A s theta, p A sp (map (subst theta) A) (subst theta s).

Definition Consistency (p:contextformProp) :=
¬p nil Fal.

Definition ProvPred (p:contextformProp) :=
Assumption p ModusPonens p Deductivity p Explosivity p
  Weakening p Substitutivity p Consistency p.