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