%%% Verifications and uses
%%% and sequent calculus
%%%
%%% Author: Frank Pfenning
%%% November 2009
%%%
%%% requires: prop.elf
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Verifications and uses
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
verif : prop -> type.
use : prop -> type.
u2v : use (? P)
-> verif (? P).
/\I : verif A
-> verif B
-> verif (A /\ B).
/\EL : use (A /\ B)
-> use A.
/\ER : use (A /\ B)
-> use B.
=>I : (use A -> verif B)
-> verif (A => B).
=>E : use (A => B)
-> verif A
-> use B.
% sample proofs
_ = =>I ([u:use (? a)] u2v u)
: verif (? a => ? a).
% derived rule of inference = notational definition
% at the level of proofs!
/\I3 : verif A -> verif B -> verif C -> verif (A /\ B /\ C)
= [va:verif A][vb:verif B][vc:verif C] /\I va (/\I vb vc).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Sequent calculus
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
left : prop -> type.
right : prop -> type.
init : left (? P) -> right (? P).
/\R : right A -> right B -> right (A /\ B).
/\L1 : (left A -> right C)
-> (left (A /\ B) -> right C).
/\L2 : (left B -> right C)
-> (left (A /\ B) -> right C).
=>R : (left A -> right B)
-> right (A => B).
=>L : right A
-> (left B -> right C)
-> (left (A => B) -> right C).
% sample deductions
_ : right (? a => ? b => ? a)
= =>R ([la] =>R [lb] init la).
_ : right ((? a => ? b) => ? a => ? b)
= =>R [la=>b] =>R [la] =>L (init la) ([lb] init lb) la=>b.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Translation from sequents to verifications
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
r2v : right A -> verif A -> type.
l2u : left A -> use A -> type.
%mode r2v +D -N.
%mode l2u +L -R.
% the code below is incomplete!
- : r2v (init L) (u2v R)
<- l2u L R.
- : r2v (/\R D E) (/\I N M)
<- r2v D N
<- r2v E M.
- : r2v (=>R [l:left A] D l) (=>I [u:use A] N u)
<- ({l:left A} {u:use A}
l2u l u -> r2v (D l) (N u)).
% missing: /\L1, /\L2, =>L
%query 1 1
r2v (=>R ([la] =>R [lb] init la)) N.