src/Sequents/Sequents.thy
author bulwahn
Tue Aug 31 08:00:53 2010 +0200 (2010-08-31)
changeset 38950 62578950e748
parent 38499 8f0cd11238a7
child 39557 fe5722fce758
permissions -rw-r--r--
storing options for prolog code generation in the theory
wenzelm@17481
     1
(*  Title:      Sequents/Sequents.thy
wenzelm@17481
     2
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
paulson@2073
     3
    Copyright   1993  University of Cambridge
paulson@2073
     4
*)
paulson@2073
     5
wenzelm@17481
     6
header {* Parsing and pretty-printing of sequences *}
wenzelm@17481
     7
wenzelm@17481
     8
theory Sequents
wenzelm@17481
     9
imports Pure
wenzelm@17481
    10
uses ("prover.ML")
wenzelm@17481
    11
begin
paulson@2073
    12
wenzelm@26956
    13
setup PureThy.old_appl_syntax_setup
wenzelm@26956
    14
wenzelm@24178
    15
declare [[unify_trace_bound = 20, unify_search_bound = 40]]
wenzelm@24178
    16
wenzelm@17481
    17
typedecl o
paulson@2073
    18
paulson@2073
    19
(* Sequences *)
paulson@2073
    20
wenzelm@17481
    21
typedecl
paulson@2073
    22
 seq'
paulson@2073
    23
paulson@2073
    24
consts
wenzelm@17481
    25
 SeqO'         :: "[o,seq']=>seq'"
wenzelm@17481
    26
 Seq1'         :: "o=>seq'"
wenzelm@17481
    27
paulson@2073
    28
paulson@2073
    29
(* concrete syntax *)
paulson@2073
    30
wenzelm@14765
    31
nonterminals
paulson@2073
    32
  seq seqobj seqcont
paulson@2073
    33
paulson@2073
    34
paulson@2073
    35
syntax
wenzelm@35113
    36
 "_SeqEmp"         :: seq                                  ("")
wenzelm@35113
    37
 "_SeqApp"         :: "[seqobj,seqcont] => seq"            ("__")
paulson@2073
    38
wenzelm@35113
    39
 "_SeqContEmp"     :: seqcont                              ("")
wenzelm@35113
    40
 "_SeqContApp"     :: "[seqobj,seqcont] => seqcont"        (",/ __")
wenzelm@17481
    41
wenzelm@35113
    42
 "_SeqO"           :: "o => seqobj"                        ("_")
wenzelm@35113
    43
 "_SeqId"          :: "'a => seqobj"                       ("$_")
paulson@2073
    44
paulson@2073
    45
types
wenzelm@17481
    46
 single_seqe = "[seq,seqobj] => prop"
wenzelm@17481
    47
 single_seqi = "[seq'=>seq',seq'=>seq'] => prop"
wenzelm@17481
    48
 two_seqi    = "[seq'=>seq', seq'=>seq'] => prop"
wenzelm@17481
    49
 two_seqe    = "[seq, seq] => prop"
wenzelm@17481
    50
 three_seqi  = "[seq'=>seq', seq'=>seq', seq'=>seq'] => prop"
wenzelm@17481
    51
 three_seqe  = "[seq, seq, seq] => prop"
wenzelm@17481
    52
 four_seqi   = "[seq'=>seq', seq'=>seq', seq'=>seq', seq'=>seq'] => prop"
wenzelm@17481
    53
 four_seqe   = "[seq, seq, seq, seq] => prop"
paulson@7166
    54
wenzelm@17481
    55
 sequence_name = "seq'=>seq'"
paulson@7166
    56
paulson@7166
    57
wenzelm@14765
    58
syntax
paulson@7166
    59
  (*Constant to allow definitions of SEQUENCES of formulas*)
wenzelm@35113
    60
  "_Side"        :: "seq=>(seq'=>seq')"     ("<<(_)>>")
paulson@2073
    61
wenzelm@17481
    62
ML {*
paulson@2073
    63
paulson@2073
    64
(* parse translation for sequences *)
paulson@2073
    65
wenzelm@35430
    66
fun abs_seq' t = Abs ("s", Type (@{type_name seq'}, []), t);
paulson@2073
    67
wenzelm@35113
    68
fun seqobj_tr (Const (@{syntax_const "_SeqO"}, _) $ f) =
wenzelm@35113
    69
      Const (@{const_syntax SeqO'}, dummyT) $ f
wenzelm@35113
    70
  | seqobj_tr (_ $ i) = i;
paulson@2073
    71
wenzelm@35113
    72
fun seqcont_tr (Const (@{syntax_const "_SeqContEmp"}, _)) = Bound 0
wenzelm@35113
    73
  | seqcont_tr (Const (@{syntax_const "_SeqContApp"}, _) $ so $ sc) =
wenzelm@35113
    74
      seqobj_tr so $ seqcont_tr sc;
paulson@2073
    75
wenzelm@35113
    76
fun seq_tr (Const (@{syntax_const "_SeqEmp"}, _)) = abs_seq' (Bound 0)
wenzelm@35113
    77
  | seq_tr (Const (@{syntax_const "_SeqApp"}, _) $ so $ sc) =
wenzelm@35113
    78
      abs_seq'(seqobj_tr so $ seqcont_tr sc);
paulson@2073
    79
wenzelm@35113
    80
fun singlobj_tr (Const (@{syntax_const "_SeqO"},_) $ f) =
wenzelm@35113
    81
  abs_seq' ((Const (@{const_syntax SeqO'}, dummyT) $ f) $ Bound 0);
paulson@2073
    82
wenzelm@17481
    83
paulson@2073
    84
(* print translation for sequences *)
paulson@2073
    85
wenzelm@17481
    86
fun seqcont_tr' (Bound 0) =
wenzelm@35113
    87
      Const (@{syntax_const "_SeqContEmp"}, dummyT)
wenzelm@35113
    88
  | seqcont_tr' (Const (@{const_syntax SeqO'}, _) $ f $ s) =
wenzelm@35113
    89
      Const (@{syntax_const "_SeqContApp"}, dummyT) $
wenzelm@35113
    90
        (Const (@{syntax_const "_SeqO"}, dummyT) $ f) $ seqcont_tr' s
wenzelm@35113
    91
  | seqcont_tr' (i $ s) =
wenzelm@35113
    92
      Const (@{syntax_const "_SeqContApp"}, dummyT) $
wenzelm@35113
    93
        (Const (@{syntax_const "_SeqId"}, dummyT) $ i) $ seqcont_tr' s;
paulson@2073
    94
paulson@2073
    95
fun seq_tr' s =
wenzelm@35113
    96
  let
wenzelm@35113
    97
    fun seq_itr' (Bound 0) = Const (@{syntax_const "_SeqEmp"}, dummyT)
wenzelm@35113
    98
      | seq_itr' (Const (@{const_syntax SeqO'}, _) $ f $ s) =
wenzelm@35113
    99
          Const (@{syntax_const "_SeqApp"}, dummyT) $
wenzelm@35113
   100
            (Const (@{syntax_const "_SeqO"}, dummyT) $ f) $ seqcont_tr' s
wenzelm@35113
   101
      | seq_itr' (i $ s) =
wenzelm@35113
   102
          Const (@{syntax_const "_SeqApp"}, dummyT) $
wenzelm@35113
   103
            (Const (@{syntax_const "_SeqId"}, dummyT) $ i) $ seqcont_tr' s
wenzelm@35113
   104
  in
wenzelm@35113
   105
    case s of
wenzelm@35113
   106
      Abs (_, _, t) => seq_itr' t
wenzelm@35113
   107
    | _ => s $ Bound 0
wenzelm@35113
   108
  end;
paulson@2073
   109
paulson@2073
   110
wenzelm@35113
   111
fun single_tr c [s1, s2] =
wenzelm@35113
   112
  Const (c, dummyT) $ seq_tr s1 $ singlobj_tr s2;
wenzelm@35113
   113
wenzelm@35113
   114
fun two_seq_tr c [s1, s2] =
wenzelm@35113
   115
  Const (c, dummyT) $ seq_tr s1 $ seq_tr s2;
wenzelm@35113
   116
wenzelm@35113
   117
fun three_seq_tr c [s1, s2, s3] =
wenzelm@35113
   118
  Const (c, dummyT) $ seq_tr s1 $ seq_tr s2 $ seq_tr s3;
wenzelm@35113
   119
wenzelm@35113
   120
fun four_seq_tr c [s1, s2, s3, s4] =
wenzelm@35113
   121
  Const (c, dummyT) $ seq_tr s1 $ seq_tr s2 $ seq_tr s3 $ seq_tr s4;
paulson@2073
   122
paulson@2073
   123
wenzelm@35113
   124
fun singlobj_tr' (Const (@{const_syntax SeqO'},_) $ fm) = fm
wenzelm@35113
   125
  | singlobj_tr' id = Const (@{syntax_const "_SeqId"}, dummyT) $ id;
paulson@2073
   126
paulson@2073
   127
paulson@2073
   128
fun single_tr' c [s1, s2] =
wenzelm@35113
   129
  Const (c, dummyT) $ seq_tr' s1 $ seq_tr' s2;
paulson@2073
   130
paulson@2073
   131
fun two_seq_tr' c [s1, s2] =
wenzelm@17481
   132
  Const (c, dummyT) $ seq_tr' s1 $ seq_tr' s2;
paulson@2073
   133
paulson@2073
   134
fun three_seq_tr' c [s1, s2, s3] =
wenzelm@17481
   135
  Const (c, dummyT) $ seq_tr' s1 $ seq_tr' s2 $ seq_tr' s3;
paulson@2073
   136
paulson@2073
   137
fun four_seq_tr' c [s1, s2, s3, s4] =
wenzelm@17481
   138
  Const (c, dummyT) $ seq_tr' s1 $ seq_tr' s2 $ seq_tr' s3 $ seq_tr' s4;
wenzelm@17481
   139
paulson@2073
   140
paulson@2073
   141
paulson@7166
   142
(** for the <<...>> notation **)
wenzelm@17481
   143
paulson@7166
   144
fun side_tr [s1] = seq_tr s1;
wenzelm@17481
   145
*}
paulson@7166
   146
wenzelm@35113
   147
parse_translation {* [(@{syntax_const "_Side"}, side_tr)] *}
wenzelm@17481
   148
wenzelm@17481
   149
use "prover.ML"
wenzelm@17481
   150
wenzelm@17481
   151
end
wenzelm@17481
   152