src/Sequents/Sequents.thy
author haftmann
Fri Jun 19 21:08:07 2009 +0200 (2009-06-19)
changeset 31726 ffd2dc631d88
parent 26956 1309a6a0a29f
child 35113 1a0c129bb2e0
permissions -rw-r--r--
merged
wenzelm@17481
     1
(*  Title:      Sequents/Sequents.thy
paulson@2073
     2
    ID:         $Id$
wenzelm@17481
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
paulson@2073
     4
    Copyright   1993  University of Cambridge
paulson@2073
     5
*)
paulson@2073
     6
wenzelm@17481
     7
header {* Parsing and pretty-printing of sequences *}
wenzelm@17481
     8
wenzelm@17481
     9
theory Sequents
wenzelm@17481
    10
imports Pure
wenzelm@17481
    11
uses ("prover.ML")
wenzelm@17481
    12
begin
paulson@2073
    13
wenzelm@26956
    14
setup PureThy.old_appl_syntax_setup
wenzelm@26956
    15
wenzelm@24178
    16
declare [[unify_trace_bound = 20, unify_search_bound = 40]]
wenzelm@24178
    17
paulson@7098
    18
global
paulson@7098
    19
wenzelm@17481
    20
typedecl o
paulson@2073
    21
paulson@2073
    22
(* Sequences *)
paulson@2073
    23
wenzelm@17481
    24
typedecl
paulson@2073
    25
 seq'
paulson@2073
    26
paulson@2073
    27
consts
wenzelm@17481
    28
 SeqO'         :: "[o,seq']=>seq'"
wenzelm@17481
    29
 Seq1'         :: "o=>seq'"
wenzelm@17481
    30
paulson@2073
    31
paulson@2073
    32
(* concrete syntax *)
paulson@2073
    33
wenzelm@14765
    34
nonterminals
paulson@2073
    35
  seq seqobj seqcont
paulson@2073
    36
paulson@2073
    37
paulson@2073
    38
syntax
wenzelm@17481
    39
 SeqEmp         :: seq                                  ("")
wenzelm@17481
    40
 SeqApp         :: "[seqobj,seqcont] => seq"            ("__")
paulson@2073
    41
wenzelm@17481
    42
 SeqContEmp     :: seqcont                              ("")
wenzelm@17481
    43
 SeqContApp     :: "[seqobj,seqcont] => seqcont"        (",/ __")
wenzelm@17481
    44
wenzelm@17481
    45
 SeqO           :: "o => seqobj"                        ("_")
wenzelm@17481
    46
 SeqId          :: "'a => seqobj"                       ("$_")
paulson@2073
    47
paulson@2073
    48
types
wenzelm@17481
    49
 single_seqe = "[seq,seqobj] => prop"
wenzelm@17481
    50
 single_seqi = "[seq'=>seq',seq'=>seq'] => prop"
wenzelm@17481
    51
 two_seqi    = "[seq'=>seq', seq'=>seq'] => prop"
wenzelm@17481
    52
 two_seqe    = "[seq, seq] => prop"
wenzelm@17481
    53
 three_seqi  = "[seq'=>seq', seq'=>seq', seq'=>seq'] => prop"
wenzelm@17481
    54
 three_seqe  = "[seq, seq, seq] => prop"
wenzelm@17481
    55
 four_seqi   = "[seq'=>seq', seq'=>seq', seq'=>seq', seq'=>seq'] => prop"
wenzelm@17481
    56
 four_seqe   = "[seq, seq, seq, seq] => prop"
paulson@7166
    57
wenzelm@17481
    58
 sequence_name = "seq'=>seq'"
paulson@7166
    59
paulson@7166
    60
wenzelm@14765
    61
syntax
paulson@7166
    62
  (*Constant to allow definitions of SEQUENCES of formulas*)
wenzelm@17481
    63
  "@Side"        :: "seq=>(seq'=>seq')"     ("<<(_)>>")
paulson@2073
    64
wenzelm@17481
    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;
wenzelm@17481
    73
paulson@2073
    74
fun seqcont_tr(Const("SeqContEmp",_)) = Bound 0 |
wenzelm@17481
    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) |
wenzelm@17481
    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);
wenzelm@17481
    85
paulson@2073
    86
wenzelm@17481
    87
paulson@2073
    88
(* print translation for sequences *)
paulson@2073
    89
wenzelm@17481
    90
fun seqcont_tr' (Bound 0) =
paulson@2073
    91
      Const("SeqContEmp",dummyT) |
paulson@6819
    92
    seqcont_tr' (Const("SeqO'",_) $ f $ s) =
wenzelm@17481
    93
      Const("SeqContApp",dummyT) $
wenzelm@17481
    94
      (Const("SeqO",dummyT) $ f) $
paulson@2073
    95
      (seqcont_tr' s) |
wenzelm@17481
    96
(*    seqcont_tr' ((a as Abs(_,_,_)) $ s)=
wenzelm@18176
    97
      seqcont_tr'(Term.betapply(a,s)) | *)
wenzelm@17481
    98
    seqcont_tr' (i $ s) =
wenzelm@17481
    99
      Const("SeqContApp",dummyT) $
wenzelm@17481
   100
      (Const("SeqId",dummyT) $ i) $
paulson@2073
   101
      (seqcont_tr' s);
paulson@2073
   102
paulson@2073
   103
fun seq_tr' s =
wenzelm@17481
   104
    let fun seq_itr' (Bound 0) =
paulson@2073
   105
              Const("SeqEmp",dummyT) |
paulson@6819
   106
            seq_itr' (Const("SeqO'",_) $ f $ s) =
wenzelm@17481
   107
              Const("SeqApp",dummyT) $
paulson@6819
   108
              (Const("SeqO",dummyT) $ f) $ (seqcont_tr' s) |
paulson@6819
   109
(*            seq_itr' ((a as Abs(_,_,_)) $ s) =
wenzelm@18176
   110
              seq_itr'(Term.betapply(a,s)) |    *)
paulson@6819
   111
            seq_itr' (i $ s) =
wenzelm@17481
   112
              Const("SeqApp",dummyT) $
wenzelm@17481
   113
              (Const("SeqId",dummyT) $ i) $
paulson@2073
   114
              (seqcont_tr' s)
wenzelm@17481
   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] =
wenzelm@17481
   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] =
wenzelm@17481
   145
  Const (c, dummyT) $ seq_tr' s1 $ seq_tr' s2;
paulson@2073
   146
paulson@2073
   147
fun three_seq_tr' c [s1, s2, s3] =
wenzelm@17481
   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] =
wenzelm@17481
   151
  Const (c, dummyT) $ seq_tr' s1 $ seq_tr' s2 $ seq_tr' s3 $ seq_tr' s4;
wenzelm@17481
   152
paulson@2073
   153
paulson@2073
   154
paulson@7166
   155
(** for the <<...>> notation **)
wenzelm@17481
   156
paulson@7166
   157
fun side_tr [s1] = seq_tr s1;
wenzelm@17481
   158
*}
paulson@7166
   159
wenzelm@17481
   160
parse_translation {* [("@Side", side_tr)] *}
wenzelm@17481
   161
wenzelm@17481
   162
use "prover.ML"
wenzelm@17481
   163
wenzelm@17481
   164
end
wenzelm@17481
   165