src/Sequents/Sequents.thy
author wenzelm
Tue Jun 01 12:33:50 2004 +0200 (2004-06-01)
changeset 14854 61bdf2ae4dc5
parent 14765 bafb24c150c1
child 17481 75166ebb619b
permissions -rw-r--r--
removed obsolete sort 'logic';
paulson@6819
     1
(*  Title: 	Sequents/Sequents.thy
paulson@2073
     2
    ID:         $Id$
paulson@2073
     3
    Author: 	Lawrence C Paulson, Cambridge University Computer Laboratory
paulson@2073
     4
    Copyright   1993  University of Cambridge
paulson@2073
     5
paulson@7166
     6
Basis theory for parsing and pretty-printing of sequences to be used in
paulson@7166
     7
Sequent Calculi. 
paulson@2073
     8
*)
paulson@2073
     9
paulson@2073
    10
Sequents = Pure +
paulson@2073
    11
paulson@7098
    12
global
paulson@7098
    13
paulson@2073
    14
types
paulson@2073
    15
  o 
paulson@2073
    16
paulson@2073
    17
paulson@2073
    18
(* Sequences *)
paulson@2073
    19
paulson@2073
    20
types
paulson@2073
    21
 seq'
paulson@2073
    22
paulson@2073
    23
consts
paulson@7166
    24
 SeqO'         :: [o,seq']=>seq'
paulson@7166
    25
 Seq1'         :: o=>seq'
paulson@2073
    26
    
paulson@2073
    27
paulson@2073
    28
(* concrete syntax *)
paulson@2073
    29
wenzelm@14765
    30
nonterminals
paulson@2073
    31
  seq seqobj seqcont
paulson@2073
    32
paulson@2073
    33
paulson@2073
    34
syntax
paulson@7166
    35
 SeqEmp         :: seq                                ("")
paulson@7166
    36
 SeqApp         :: [seqobj,seqcont] => seq            ("__")
paulson@2073
    37
paulson@7166
    38
 SeqContEmp     :: seqcont                            ("")
paulson@7166
    39
 SeqContApp     :: [seqobj,seqcont] => seqcont        (",/ __")
paulson@2073
    40
  
paulson@7166
    41
 SeqO           :: o => seqobj                        ("_")
paulson@7166
    42
 SeqId          :: 'a => seqobj                       ("$_")
paulson@2073
    43
paulson@2073
    44
types
paulson@2073
    45
    
paulson@7166
    46
 single_seqe = [seq,seqobj] => prop
paulson@7166
    47
 single_seqi = [seq'=>seq',seq'=>seq'] => prop
paulson@7166
    48
 two_seqi    = [seq'=>seq', seq'=>seq'] => prop
paulson@7166
    49
 two_seqe    = [seq, seq] => prop
paulson@7166
    50
 three_seqi  = [seq'=>seq', seq'=>seq', seq'=>seq'] => prop
paulson@7166
    51
 three_seqe  = [seq, seq, seq] => prop
paulson@7166
    52
 four_seqi   = [seq'=>seq', seq'=>seq', seq'=>seq', seq'=>seq'] => prop
paulson@7166
    53
 four_seqe   = [seq, seq, seq, seq] => prop
paulson@7166
    54
paulson@7166
    55
paulson@7166
    56
 sequence_name = seq'=>seq'
paulson@7166
    57
paulson@7166
    58
wenzelm@14765
    59
syntax
paulson@7166
    60
  (*Constant to allow definitions of SEQUENCES of formulas*)
paulson@7166
    61
  "@Side"        :: seq=>(seq'=>seq')     ("<<(_)>>")
paulson@2073
    62
paulson@2073
    63
end
paulson@2073
    64
paulson@2073
    65
ML
paulson@2073
    66
paulson@2073
    67
(* parse translation for sequences *)
paulson@2073
    68
paulson@2073
    69
fun abs_seq' t = Abs("s", Type("seq'",[]), t);
paulson@2073
    70
paulson@6819
    71
fun seqobj_tr(Const("SeqO",_) $ f) = Const("SeqO'",dummyT) $ f |
paulson@6819
    72
    seqobj_tr(_ $ i) = i;
paulson@2073
    73
    
paulson@2073
    74
fun seqcont_tr(Const("SeqContEmp",_)) = Bound 0 |
paulson@6819
    75
    seqcont_tr(Const("SeqContApp",_) $ so $ sc) = 
paulson@6819
    76
      (seqobj_tr so) $ (seqcont_tr sc);
paulson@2073
    77
paulson@2073
    78
fun seq_tr(Const("SeqEmp",_)) = abs_seq'(Bound 0) |
paulson@6819
    79
    seq_tr(Const("SeqApp",_) $ so $ sc) = 
paulson@6819
    80
      abs_seq'(seqobj_tr(so) $ seqcont_tr(sc));
paulson@2073
    81
paulson@2073
    82
paulson@6819
    83
fun singlobj_tr(Const("SeqO",_) $ f) =
paulson@6819
    84
    abs_seq' ((Const("SeqO'",dummyT) $ f) $ Bound 0);
paulson@2073
    85
    
paulson@2073
    86
paulson@2073
    87
    
paulson@2073
    88
(* print translation for sequences *)
paulson@2073
    89
paulson@2073
    90
fun seqcont_tr' (Bound 0) = 
paulson@2073
    91
      Const("SeqContEmp",dummyT) |
paulson@6819
    92
    seqcont_tr' (Const("SeqO'",_) $ f $ s) =
paulson@6819
    93
      Const("SeqContApp",dummyT) $ 
paulson@6819
    94
      (Const("SeqO",dummyT) $ f) $ 
paulson@2073
    95
      (seqcont_tr' s) |
paulson@6819
    96
(*    seqcont_tr' ((a as Abs(_,_,_)) $ s)= 
paulson@2073
    97
      seqcont_tr'(betapply(a,s)) | *)
paulson@6819
    98
    seqcont_tr' (i $ s) = 
paulson@6819
    99
      Const("SeqContApp",dummyT) $ 
paulson@6819
   100
      (Const("SeqId",dummyT) $ i) $ 
paulson@2073
   101
      (seqcont_tr' s);
paulson@2073
   102
paulson@2073
   103
fun seq_tr' s =
paulson@2073
   104
    let fun seq_itr' (Bound 0) = 
paulson@2073
   105
              Const("SeqEmp",dummyT) |
paulson@6819
   106
            seq_itr' (Const("SeqO'",_) $ f $ s) =
paulson@6819
   107
              Const("SeqApp",dummyT) $ 
paulson@6819
   108
              (Const("SeqO",dummyT) $ f) $ (seqcont_tr' s) |
paulson@6819
   109
(*            seq_itr' ((a as Abs(_,_,_)) $ s) =
paulson@2073
   110
              seq_itr'(betapply(a,s)) |    *)
paulson@6819
   111
            seq_itr' (i $ s) =
paulson@6819
   112
              Const("SeqApp",dummyT) $ 
paulson@6819
   113
              (Const("SeqId",dummyT) $ i) $ 
paulson@2073
   114
              (seqcont_tr' s)
paulson@2073
   115
    in case s of 
paulson@2073
   116
         Abs(_,_,t) => seq_itr' t |
paulson@6819
   117
         _ => s $ (Bound 0)
paulson@2073
   118
    end;
paulson@2073
   119
paulson@2073
   120
paulson@2073
   121
paulson@2073
   122
paulson@2073
   123
fun single_tr c [s1,s2] =
paulson@6819
   124
    Const(c,dummyT) $ seq_tr s1 $ singlobj_tr s2;
paulson@2073
   125
paulson@2073
   126
fun two_seq_tr c [s1,s2] =
paulson@6819
   127
    Const(c,dummyT) $ seq_tr s1 $ seq_tr s2;
paulson@2073
   128
paulson@2073
   129
fun three_seq_tr c [s1,s2,s3] =
paulson@6819
   130
    Const(c,dummyT) $ seq_tr s1 $ seq_tr s2 $ seq_tr s3;
paulson@2073
   131
paulson@2073
   132
fun four_seq_tr c [s1,s2,s3,s4] =
paulson@6819
   133
    Const(c,dummyT) $ seq_tr s1 $ seq_tr s2 $ seq_tr s3 $ seq_tr s4;
paulson@2073
   134
paulson@2073
   135
paulson@6819
   136
fun singlobj_tr'(Const("SeqO'",_) $ fm) = fm |
paulson@6819
   137
    singlobj_tr'(id) = Const("@SeqId",dummyT) $ id;
paulson@2073
   138
paulson@2073
   139
paulson@2073
   140
fun single_tr' c [s1, s2] =
paulson@6819
   141
(Const (c, dummyT) $ seq_tr' s1 $ seq_tr' s2 ); 
paulson@2073
   142
paulson@2073
   143
paulson@2073
   144
fun two_seq_tr' c [s1, s2] =
paulson@6819
   145
  Const (c, dummyT) $ seq_tr' s1 $ seq_tr' s2; 
paulson@2073
   146
paulson@2073
   147
fun three_seq_tr' c [s1, s2, s3] =
paulson@6819
   148
  Const (c, dummyT) $ seq_tr' s1 $ seq_tr' s2 $ seq_tr' s3; 
paulson@2073
   149
paulson@2073
   150
fun four_seq_tr' c [s1, s2, s3, s4] =
paulson@6819
   151
  Const (c, dummyT) $ seq_tr' s1 $ seq_tr' s2 $ seq_tr' s3 $ seq_tr' s4; 
paulson@2073
   152
paulson@2073
   153
paulson@2073
   154
			 
paulson@7166
   155
(** for the <<...>> notation **)
paulson@7166
   156
  
paulson@7166
   157
fun side_tr [s1] = seq_tr s1;
paulson@7166
   158
paulson@7166
   159
val parse_translation = [("@Side", side_tr)];