src/LK/lk.thy
changeset 0 a5a9c433f639
child 283 76caebd18756
equal deleted inserted replaced
-1:000000000000 0:a5a9c433f639
       
     1 (*  Title: 	LK/lk.thy
       
     2     ID:         $Id$
       
     3     Author: 	Lawrence C Paulson, Cambridge University Computer Laboratory
       
     4     Copyright   1993  University of Cambridge
       
     5 
       
     6 Classical First-Order Sequent Calculus
       
     7 *)
       
     8 
       
     9 LK = Pure +
       
    10 classes term < logic
       
    11 default term
       
    12 types o 0
       
    13       sequence,seqobj,seqcont,sequ,sobj 0
       
    14 arities o :: logic
       
    15 consts
       
    16  True,False	:: "o"
       
    17  "="		:: "['a,'a] => o"	(infixl 50)
       
    18  "Not"		:: "o => o"		("~ _" [40] 40)
       
    19  "&"		:: "[o,o] => o"		(infixr 35)
       
    20  "|"		:: "[o,o] => o"		(infixr 30)
       
    21  "-->","<->"	:: "[o,o] => o"		(infixr 25)
       
    22  The		:: "('a => o) => 'a"	(binder "THE " 10)
       
    23  All		:: "('a => o) => o"	(binder "ALL " 10)
       
    24  Ex		:: "('a => o) => o"	(binder "EX " 10)
       
    25 
       
    26  (*Representation of sequents*)
       
    27  Trueprop	:: "[sobj=>sobj,sobj=>sobj] => prop"
       
    28  Seqof		:: "o => sobj=>sobj"
       
    29  "@Trueprop"	:: "[sequence,sequence] => prop" ("((_)/ |- (_))" [6,6] 5)
       
    30  "@MtSeq"	:: "sequence"				("" [] 1000)
       
    31  "@NmtSeq"	:: "[seqobj,seqcont] => sequence"	("__" [] 1000)
       
    32  "@MtSeqCont"	:: "seqcont"				("" [] 1000)
       
    33  "@SeqCont"	:: "[seqobj,seqcont] => seqcont"	(",/ __" [] 1000)
       
    34  ""		:: "o => seqobj"			("_" [] 1000)
       
    35  "@SeqId"	:: "id => seqobj"			("$_" [] 1000)
       
    36  "@SeqVar"	:: "var => seqobj"			("$_")
       
    37 
       
    38 rules
       
    39   (*Structural rules*)
       
    40 
       
    41   basic	"$H, P, $G |- $E, P, $F"
       
    42 
       
    43   thinR	"$H |- $E, $F ==> $H |- $E, P, $F"
       
    44   thinL	"$H, $G |- $E ==> $H, P, $G |- $E"
       
    45 
       
    46   cut	"[| $H |- $E, P;  $H, P |- $E |] ==> $H |- $E"
       
    47 
       
    48   (*Propositional rules*)
       
    49 
       
    50   conjR	"[| $H|- $E, P, $F;  $H|- $E, Q, $F |] ==> $H|- $E, P&Q, $F"
       
    51   conjL	"$H, P, Q, $G |- $E ==> $H, P & Q, $G |- $E"
       
    52 
       
    53   disjR	"$H |- $E, P, Q, $F ==> $H |- $E, P|Q, $F"
       
    54   disjL	"[| $H, P, $G |- $E;  $H, Q, $G |- $E |] ==> $H, P|Q, $G |- $E"
       
    55 
       
    56   impR	"$H, P |- $E, Q, $F ==> $H |- $E, P-->Q, $F"
       
    57   impL	"[| $H,$G |- $E,P;  $H, Q, $G |- $E |] ==> $H, P-->Q, $G |- $E"
       
    58 
       
    59   notR	"$H, P |- $E, $F ==> $H |- $E, ~P, $F"
       
    60   notL	"$H, $G |- $E, P ==> $H, ~P, $G |- $E"
       
    61 
       
    62   FalseL "$H, False, $G |- $E"
       
    63 
       
    64   True_def "True == False-->False"
       
    65   iff_def  "P<->Q == (P-->Q) & (Q-->P)"
       
    66 
       
    67   (*Quantifiers*)
       
    68 
       
    69   allR	"(!!x.$H |- $E, P(x), $F) ==> $H |- $E, ALL x.P(x), $F"
       
    70   allL	"$H, P(x), $G, ALL x.P(x) |- $E ==> $H, ALL x.P(x), $G |- $E"
       
    71 
       
    72   exR	"$H |- $E, P(x), $F, EX x.P(x) ==> $H |- $E, EX x.P(x), $F"
       
    73   exL	"(!!x.$H, P(x), $G |- $E) ==> $H, EX x.P(x), $G |- $E"
       
    74 
       
    75   (*Equality*)
       
    76 
       
    77   refl	"$H |- $E, a=a, $F"
       
    78   sym   "$H |- $E, a=b, $F ==> $H |- $E, b=a, $F"
       
    79   trans "[| $H|- $E, a=b, $F;  $H|- $E, b=c, $F |] ==> $H|- $E, a=c, $F"
       
    80 
       
    81 
       
    82   (*Descriptions*)
       
    83 
       
    84   The "[| $H |- $E, P(a), $F;  !!x.$H, P(x) |- $E, x=a, $F |] ==> \
       
    85 \          $H |- $E, P(THE x.P(x)), $F"
       
    86 end
       
    87 
       
    88 ML
       
    89 
       
    90 (*Abstract over "sobj" -- representation of a sequence of formulae *)
       
    91 fun abs_sobj t = Abs("sobj", Type("sobj",[]), t);
       
    92 
       
    93 (*Representation of empty sequence*)
       
    94 val Sempty =  abs_sobj (Bound 0);
       
    95 
       
    96 fun seq_obj_tr(Const("@SeqId",_)$id) = id |
       
    97     seq_obj_tr(Const("@SeqVar",_)$id) = id |
       
    98     seq_obj_tr(fm) = Const("Seqof",dummyT)$fm;
       
    99 
       
   100 fun seq_tr(_$obj$seq) = seq_obj_tr(obj)$seq_tr(seq) |
       
   101     seq_tr(_) = Bound 0;
       
   102 
       
   103 fun seq_tr1(Const("@MtSeq",_)) = Sempty |
       
   104     seq_tr1(seq) = abs_sobj(seq_tr seq);
       
   105 
       
   106 fun true_tr[s1,s2] = Const("Trueprop",dummyT)$seq_tr1 s1$seq_tr1 s2;
       
   107 
       
   108 fun seq_obj_tr'(Const("Seqof",_)$fm) = fm |
       
   109     seq_obj_tr'(id) = Const("@SeqId",dummyT)$id;
       
   110 
       
   111 fun seq_tr'(obj$sq,C) =
       
   112       let val sq' = case sq of
       
   113             Bound 0 => Const("@MtSeqCont",dummyT) |
       
   114             _ => seq_tr'(sq,Const("@SeqCont",dummyT))
       
   115       in C $ seq_obj_tr' obj $ sq' end;
       
   116 
       
   117 fun seq_tr1'(Bound 0) = Const("@MtSeq",dummyT) |
       
   118     seq_tr1' s = seq_tr'(s,Const("@NmtSeq",dummyT));
       
   119 
       
   120 fun true_tr'[Abs(_,_,s1),Abs(_,_,s2)] =
       
   121       Const("@Trueprop",dummyT)$seq_tr1' s1$seq_tr1' s2;
       
   122 
       
   123 val parse_translation = [("@Trueprop",true_tr)];
       
   124 val print_translation = [("Trueprop",true_tr')];