%% Equivalence of natural deduction, hilbert calculus, and sequent calculus
Specification "equiv".
%% Contexts
Define ctxs : olist -> olist -> olist -> prop by
ctxs nil nil nil ;
ctxs (nd G :: L) (hyp G :: J) (hil G :: K) := ctxs L J K.
Theorem ctxs_member1 : forall L J K E,
ctxs L J K -> member E L ->
exists F, E = nd F /\ member (hyp F) J /\ member (hil F) K.
IH : induction on 2. intros !L !J !K !E Hctxs Hmem. case Hmem.
- case Hctxs. search.
- HmemSub =>
HctxsSub : case Hctxs.
apply IH to HctxsSub HmemSub. search.
Theorem ctxs_member2 : forall L J K E,
ctxs L J K -> member E J ->
exists F, E = hyp F /\ member (nd F) L /\ member (hil F) K.
IH : induction on 2. intros !L !J !K !E Hctxs Hmem. case Hmem.
- case Hctxs. search.
- HmemSub =>
HctxsSub : case Hctxs.
apply IH to HctxsSub HmemSub. search.
Theorem ctxs_member3 : forall L J K E,
ctxs L J K -> member E K ->
exists F, E = hil F /\ member (nd F) L /\ member (hyp F) J.
IH : induction on 2. intros !L !J !K !E Hctxs Hmem. case Hmem.
- case Hctxs. search.
- HmemSub =>
HctxsSub : case Hctxs.
apply IH to HctxsSub HmemSub. search.
%% Natural deduction -> sequent calculus
Theorem nd_to_seq_ext : forall L J K G,
ctxs L J K -> {L |- nd G} -> {J |- conc G}.
IH : induction on 2. intros !L !J !K !G Hctxs Hnd. case Hnd.
- HndImp => apply IH to _ HndImp. search.
- HndImpA HndA =>
apply IH to Hctxs HndImpA. apply IH to Hctxs HndA. search.
- HndHyp HmemNd => apply ctxs_member1 to Hctxs HmemNd. case HndHyp.
search.
Theorem nd_to_seq : forall G,
{nd G} -> {conc G}.
intros !G Hnd. apply nd_to_seq_ext to _ Hnd. search.
%% Sequent calculus -> hilbert calculus
Set witnesses on.
Theorem hil_deduction : forall L J K A B,
ctxs L J K ->
{K, hil A |- hil B} -> {K |- hil (imp A B)}.
IH : induction on 2. intros !L !J !K !A !B Hctxs Hhil. case Hhil.
- search. % KK
- search. % KS
- HhilImp HhilA =>
apply IH to _ HhilImp. apply IH to _ HhilA. search. % S(HhilImp)(HhilA)
- HhilHyp HmemHil => case HmemHil.
+ case HhilHyp. search. % SKK
+ HmemHilK =>
apply ctxs_member3 to Hctxs HmemHilK. case HhilHyp. search.
Set witnesses off.
Theorem seq_to_hil_ext : forall L J K G,
ctxs L J K -> {J |- conc G} -> {K |- hil G}.
IH : induction on 2. intros !L !J !K !G Hctxs Hconc. case Hconc.
- HconcHyp => HconcHypF HmemHyp : case HconcHyp.
apply ctxs_member2 to Hctxs HmemHyp. case HconcHypF. search.
- HconcHypA HconcA => HhilHypA : apply IH to _ HconcHypA.
apply IH to Hctxs HconcA. apply hil_deduction to _ HhilHypA. search.
- HconcImp => HhilImpR : apply IH to _ HconcImp.
apply hil_deduction to _ HhilImpR. search.
- HconcImpL HconcA HconcHypR =>
HconcImpF HmemImp : case HconcImpL.
apply ctxs_member2 to Hctxs HmemImp. case HconcImpF.
apply IH to Hctxs HconcA. HhilHypB : apply IH to _ HconcHypR.
apply hil_deduction to _ HhilHypB. search.
- HconcBk HmemBk => apply ctxs_member2 to Hctxs HmemBk. case HconcBk.
Theorem seq_to_hil : forall G,
{conc G} -> {hil G}.
intros !G Hconc. apply seq_to_hil_ext to _ Hconc. search.
%% Hilbert calculus -> natural deduction
Theorem hil_to_nd_ext : forall L J K G,
ctxs L J K -> {K |- hil G} -> {L |- nd G}.
IH : induction on 2. intros !L !J !K !G Hctxs Hhil. case Hhil.
- search.
- !C !A !B =>
% This hint/assertion speeds up search considerably
assert {nd (imp A (imp B C)), nd (imp A B), nd A |- nd C}.
search.
- HhilImp HhilA =>
apply IH to Hctxs HhilImp. apply IH to Hctxs HhilA. search.
- HhilHyp HmemHil =>
apply ctxs_member3 to Hctxs HmemHil. case HhilHyp. search.
Theorem hil_to_nd : forall G,
{hil G} -> {nd G}.
intros !G Hhil. apply hil_to_nd_ext to _ Hhil. search.
%% The general form of the Hilbert deduction theorem:
%% if {hil A1, hil A2, ..., hil An |- hil B}
%% then {hil (imp A1 (imp A2 (imp ... (imp An B)...)))}
Define fold : olist -> form -> form -> prop by
fold nil B B ;
fold (hil A :: L) B B' := fold L (imp A B) B'.
Theorem hil_deduction_generalized : forall L J K B B',
ctxs L J K ->
fold K B B' -> {K |- hil B} -> {hil B'}.
IH : induction on 2. intros !L !J !K !B !B' Hctxs Hfold Hhil. case Hfold.
- search.
- HfoldSub => HctxsSub : case Hctxs.
HhilImp : apply hil_deduction to _ Hhil.
apply IH to _ HfoldSub HhilImp. search.