Chapter 10 - Propositional Entailment


Require Import Base.

10.1 Propositional Formulas


Definition var := nat.
Inductive form : Type :=
| Var : var form
| Imp : form form form
| Fal : form.

Definition Not s := Imp s Fal.

Definition assn := var bool.

Fixpoint satis (f : assn) (s : form) : Prop :=
match s with
| Var xf x = true
| Imp s1 s2satis f s1 satis f s2
| FalFalse
end.

(* Exercise 10.1.1 *)

Goal f: assn, satis f (Not (Imp (Var 0) (Var 1))).
Proof.
Abort.

(* Exercise 10.1.2 *)

Goal f: assn, s:form, satis f (Imp (Not (Not s)) s).
Proof.
Abort.

(* Exercise 10.1.3 *)

Goal f: assn, s t:form, satis f (Imp (Imp (Imp s t) s) s).
Proof.
Abort.

10.2 Structural Properties of Entailment Relations


(* Generic Entailment Relations *)
Section F.

  Variable F:Type.
  (* E is an entailment relation *)
  Variable E:list F F Prop.

  (* Structural Properties *)
  Definition Monotonicity : Prop :=
     A A' s, A <<= A' E A s E A' s.

  Definition Reflexivity : Prop :=
     A s, s el A E A s.

  Definition Cut : Prop :=
     A s t, E A s E (s::A) t E A t.

  Definition Consistency : Prop :=
     s:F, ¬E nil s.

End F.

Fixpoint andlist (A:list Prop) : Prop :=
match A with
| P::A'P andlist A'
| nilTrue
end.

Lemma andlistEq (A:list Prop) : andlist A s, s el A s.
Proof.
Abort.

(* Exercise 10.2.1 *)

Goal
  let E : list bool bool Prop := fun A sif s then True else false el A in
  Reflexivity E Monotonicity E Cut E Consistency E.
Abort.

(* Exercise 10.2.2 *)

Goal X:Type, inhabited X
  let E : list (X Prop) (X Prop) Prop
     := fun A s x:X, ( P, P el A P x) s x in
  Reflexivity E Monotonicity E Cut E Consistency E.
Abort.

(* Exercise 10.2.3 *)

Goal
  let E : list nat nat Prop := fun A s n, n el A s n in
  Reflexivity E Monotonicity E Cut E Consistency E.
Abort.

(* Exercise 10.2.4 *)

Section Ex1024.
  Variable F: Type.
  Definition E := (fun (A: list F) xIn x A).

  (* ... *)

End Ex1024.

10.3 Logical Properties of Entailment Relations


Definition context := list form.

Definition CharImp (E:context form Prop) : Prop :=
A s t, E A (Imp s t) E (s::A) t.

Definition CharFal (E:context form Prop) : Prop :=
A, E A Fal s, E A s.

Definition bsc A s : Prop := f, ( u, u el A satis f u) satis f s.

(* Exercise 10.3.1 *)

Goal
  Reflexivity bsc Monotonicity bsc Cut bsc Consistency bsc
CharImp bsc CharFal bsc.
Abort.

(* Exercise 10.3.2 *)

Goal E, CharImp E CharFal E A s, E A (Not s) t, E (s :: A) t.
Abort.

(* Exercise 10.3.3 *)

Goal E, Cut E CharImp E A s t, E A (Imp s t) E A s E A t.
Abort.

(* Exercise 10.3.4 *)

Lemma Reflexivity_CharImp_nonempty E :
  Reflexivity E CharImp E s, E nil s.
Abort.


(* Exercise 10.3.5 *)

Inductive closed : form Prop :=
| closedFal : closed Fal
| closedImp s t : closed s closed t closed (Imp s t).

Lemma ReflexivityCutChar_closed_or E s :
  Reflexivity E Cut E CharImp E CharFal E
  closed s ( A, E A s) ( A, E A (Not s)).
Abort.

10.4 Variables and Substitutions


Fixpoint subst (sigma : var form) (s : form) : form :=
match s with
| Var xsigma x
| Imp s tImp (subst sigma s) (subst sigma t)
| FalFal
end.

Definition Substitution (E:context form Prop) :=
A s sigma, E A s E (map (subst sigma) A) (subst sigma s).

(* Exercise 10.4.1 *)

Goal sigma1 sigma2 s,
       ( x, sigma1 x = sigma2 x) subst sigma1 s = subst sigma2 s.
Abort.

(* Exercise 10.4.2 *)

Fixpoint emb (s : form) : Prop :=
  match s with
    | Var xFalse
    | Imp s1 s2emb s1 emb s2
    | FalFalse
  end.

Goal
  let E : list form form Prop := fun A s( t, t el A emb t) emb s in
  Reflexivity E Monotonicity E Cut E Consistency E
     CharImp E CharFal E
     ¬ Substitution E.
Abort.

(* Exercise 10.4.3 *)

Definition EntailRelAllProps (E:context form Prop) :=
Reflexivity E Monotonicity E Cut E Consistency E
CharImp E CharFal E Substitution E.

Lemma Reflexivity_CharImp_nonempty E :
  Reflexivity E CharImp E s, E nil s.
Abort.

Lemma EntailRelAllProps_ext E E' :
  EntailRelAllProps E ( A s, E A s E' A s) EntailRelAllProps E'.
Abort.

10.5 Natural Deduction System


Inductive nd : context form Prop :=
| ndA A s : s el A nd A s
| ndII A s t : nd (s::A) t nd A (Imp s t)
| ndIE A s t : nd A (Imp s t) nd A s nd A t
| ndE A s : nd A Fal nd A s.

Goal A s t, nd A (Imp s (Imp (Not s) t)).
Proof.
  intros A s t. apply ndII, ndII. apply ndE. apply ndIE with (s := s).
  - apply ndA. left. reflexivity.
  - apply ndA. right. left. reflexivity.
Qed.

Check (nd_ind :
   p : context form Prop,
  ( (A : context) (s : form), s el A p A s)
  ( (A : context) (s t : form), nd (s :: A) t p (s :: A) t p A (Imp s t))
  ( (A : context) (s t : form), nd A (Imp s t) p A (Imp s t) nd A s p A s p A t)
  ( (A : context) (s : form), nd A Fal p A Fal p A s)
   (A : context) (s : form), nd A s p A s).

Lemma app A s u:
  nd A s (Imp s u) el A nd A u.
Abort.

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

Lemma W A A' s:
  nd A s A <<= A' nd A' s.
Abort.

Lemma IEweak A B s t:
  nd B (Imp s t) B <<= A nd A s nd A t.
Abort.

Lemma DN A s:
  nd A s nd A (Imp (Imp s Fal) Fal).
Abort.

(* Exercise 10.5.2 *)

Goal A s, nd A (Imp s s).
Abort.

Goal A s, nd A (Imp Fal s).
Abort.

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

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

(* Exercise 10.5.3 *)

Lemma nd_subst A s sigma : nd A s nd (map (subst sigma) A) (subst sigma s).
Abort.

(* Exercise 10.5.4 *)

Lemma nd_bsc A s:
  nd A s bsc A s.
Abort.

Goal Consistency nd.
Abort.

(* Exercise 10.5.5 *)

Lemma nd_EntailRelAllProps : EntailRelAllProps nd.
Abort.

(* Exercise 10.5.6 *)

Lemma nd_least_EntailRelAllProps (E : context form Prop) :
  Reflexivity E Cut E CharImp E CharFal E A s, nd A s E A s.
Abort.

(* Exercise 10.5.8*)

Lemma ndassert (A : context) (s u : form) :
 nd A s nd (s::A) u nd A u.
Abort.

Lemma ndappbin (A : context) (s t u : form) :
 Imp s (Imp t u) el A nd A s nd A t nd A u.
Abort.

10.6 Classical Natural Deduction


Inductive ndc : context form Prop :=
| ndcA A s : s el A ndc A s
| ndcII A s t : ndc (s::A) t ndc A (Imp s t)
| ndcIE A s t : ndc A (Imp s t) ndc A s ndc A t
| ndcC A s : ndc (Not s :: A) Fal ndc A s.

Lemma ndc_app A s u:
  ndc A s (Imp s u) el A ndc A u.
Proof.
  intros H H'. apply ndcIE with (s := s).
  - now apply ndcA.
  - assumption.
Qed.

Lemma ndc_weak A A' s :
  A <<= A' ndc A s ndc A' s.
Proof.
  intros H B. revert A' H. induction B.
  - intros A' B. now apply ndcA, B.
  - intros A' C. apply ndcII.
    apply IHB. auto.
  - intros A' H. apply ndcIE with (s := s). now apply IHB1. now apply IHB2.
  - intros A' H. apply ndcC. apply IHB. auto.
Qed.

Lemma ndc_W A s t:
  ndc A s ndc (t:: A) s.
Proof.
  intros H. apply ndc_weak with (A := A).
  auto. assumption.
Qed.

Lemma ndc_IEweak A B s t:
  ndc B (Imp s t) B <<= A ndc A s ndc A t.
Proof.
  intros C D E.
  apply ndcIE with (s := s).
  - apply ndc_weak with (A := B); assumption.
  - assumption.
Qed.

Lemma ndc_DN A s:
  ndc A s ndc A (Imp (Imp s Fal) Fal).
Proof.
  intros H. apply ndcII. apply ndcIE with (s := s).
  - apply ndcA. auto.
  - apply ndc_W. assumption.
Qed.

Lemma ndc_explosion A s:
  ndc A Fal ndc A s.
Admitted.

Lemma nd_ndc A s:
       nd A s ndc A s.
Abort.

Goal A s,
       ndc A s nd ((Not s) :: A) (Not s).
Abort.

(* Exercise 10.6.3 *)

Lemma ndc_contradiction_eq A s:
       ndc A s ndc ((Not s) :: A) Fal.
Abort.

(* Exercise 10.6.4 *)

Lemma ndcA2 A s t :
 ndc (t :: s :: A) s.
Abort.

Lemma ndcapp A s u :
  Imp s u el A ndc A s ndc A u.
Abort.

Lemma ndcapp1 A s u :
  ndc (Imp s u :: A) s ndc (Imp s u :: A) u.
Abort.

Lemma ndcapp2 A s t u :
  ndc (t :: Imp s u :: A) s ndc (t :: Imp s u :: A) u.
Abort.

Lemma ndcapp3 A s t u v :
  ndc (t :: v :: Imp s u :: A) s ndc (t :: v :: Imp s u :: A) u.
Abort.

Goal A s t, ndc A (Imp (Imp (Imp s t) s) s).
Abort.

(* Exercise 10.6.5 *)

Lemma ndc_subst A s sigma : ndc A s ndc (map (subst sigma) A) (subst sigma s).
Abort.

(* Exercise 10.6.6 *)

Definition XM := X : Prop, X ¬X.

Lemma ndc_eval_xm_sound A s (e:form Prop) :
 XM
 ¬e Fal ( t u, e (Imp t u) e t e u)
 ndc A s ( t, t el A e t) e s.
Abort.

10.7 Glivenko's Theorem


Lemma Glivenko A s:
  ndc A s nd A (Not (Not s)).
Abort.

Goal A,
       nd A Fal ndc A Fal.
Abort.

Goal A s,
       ndc A s nd ((Not s) :: A) Fal.
Abort.

(* Exercise 10.7.4 *)

Lemma Glivenko_converse A s :
  nd A (Not (Not s)) ndc A s.
Abort.

(* Exercise 10.7.5 *)

Goal A, ¬ s, ndc A (Not s) ¬ nd A (Not s).
Abort.

(* Exercise 10.7.6 *)

Lemma ndc_con : ¬ ndc nil Fal.
Abort.

(* Exercise 10.7.7 *)

Lemma ndc_EntailRelAllProps : EntailRelAllProps ndc.
Abort.

10.8 Hilbert System


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) : form Prop :=
| hilA s : s el A hil 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 s hil A t.

Lemma hil_nd A s:
       hil A s nd A s.
Abort.

Lemma ded A s t:
       nd (s :: A) t nd A (Imp s t).
Abort.

Lemma nd_hil A s:
       nd A s nd A s.
Abort.

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

(* Exercise 10.8.4 *)

Lemma hilW A s t :
  hil A t hil (s::A) t.
Abort.

(* Exercise 10.8.5 *)

Lemma hilassert A s u :
  hil A s hil (s::A) u hil A u.
Abort.

(* Exercise 10.8.6 *)

Lemma hil_con : ¬ hil nil Fal.
Abort.

(* Exercise 10.8.7 *)

Lemma hil_EntailRelAllProps : EntailRelAllProps hil.
Abort.