src/Sequents/Sequents.thy
author bulwahn
Thu, 07 Jul 2011 23:33:14 +0200
changeset 43704 47b0be18ccbe
parent 42463 f270e3e18be5
child 48891 c0eafbd55de3
permissions -rw-r--r--
floor and ceiling definitions are not code equations -- this enables trivial evaluation of floor and ceiling
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
     1
(*  Title:      Sequents/Sequents.thy
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
     2
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
     3
    Copyright   1993  University of Cambridge
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
     4
*)
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
     5
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
     6
header {* Parsing and pretty-printing of sequences *}
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
     7
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
     8
theory Sequents
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
     9
imports Pure
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    10
uses ("prover.ML")
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    11
begin
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    12
39557
fe5722fce758 renamed structure PureThy to Pure_Thy and moved most content to Global_Theory, to emphasize that this is global-only;
wenzelm
parents: 38499
diff changeset
    13
setup Pure_Thy.old_appl_syntax_setup
26956
1309a6a0a29f setup PureThy.old_appl_syntax_setup -- theory Pure provides regular application syntax by default;
wenzelm
parents: 24178
diff changeset
    14
24178
4ff1dc2aa18d turned Unify flags into configuration options (global only);
wenzelm
parents: 18176
diff changeset
    15
declare [[unify_trace_bound = 20, unify_search_bound = 40]]
4ff1dc2aa18d turned Unify flags into configuration options (global only);
wenzelm
parents: 18176
diff changeset
    16
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    17
typedecl o
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    18
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    19
(* Sequences *)
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    20
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    21
typedecl
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    22
 seq'
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    23
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    24
consts
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    25
 SeqO'         :: "[o,seq']=>seq'"
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    26
 Seq1'         :: "o=>seq'"
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    27
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    28
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    29
(* concrete syntax *)
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    30
41229
d797baa3d57c replaced command 'nonterminals' by slightly modernized version 'nonterminal';
wenzelm
parents: 39557
diff changeset
    31
nonterminal seq and seqobj and seqcont
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    32
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    33
syntax
35113
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    34
 "_SeqEmp"         :: seq                                  ("")
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    35
 "_SeqApp"         :: "[seqobj,seqcont] => seq"            ("__")
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    36
35113
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    37
 "_SeqContEmp"     :: seqcont                              ("")
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    38
 "_SeqContApp"     :: "[seqobj,seqcont] => seqcont"        (",/ __")
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    39
35113
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    40
 "_SeqO"           :: "o => seqobj"                        ("_")
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    41
 "_SeqId"          :: "'a => seqobj"                       ("$_")
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    42
42463
f270e3e18be5 modernized specifications;
wenzelm
parents: 41229
diff changeset
    43
type_synonym single_seqe = "[seq,seqobj] => prop"
f270e3e18be5 modernized specifications;
wenzelm
parents: 41229
diff changeset
    44
type_synonym single_seqi = "[seq'=>seq',seq'=>seq'] => prop"
f270e3e18be5 modernized specifications;
wenzelm
parents: 41229
diff changeset
    45
type_synonym two_seqi = "[seq'=>seq', seq'=>seq'] => prop"
f270e3e18be5 modernized specifications;
wenzelm
parents: 41229
diff changeset
    46
type_synonym two_seqe = "[seq, seq] => prop"
f270e3e18be5 modernized specifications;
wenzelm
parents: 41229
diff changeset
    47
type_synonym three_seqi = "[seq'=>seq', seq'=>seq', seq'=>seq'] => prop"
f270e3e18be5 modernized specifications;
wenzelm
parents: 41229
diff changeset
    48
type_synonym three_seqe = "[seq, seq, seq] => prop"
f270e3e18be5 modernized specifications;
wenzelm
parents: 41229
diff changeset
    49
type_synonym four_seqi = "[seq'=>seq', seq'=>seq', seq'=>seq', seq'=>seq'] => prop"
f270e3e18be5 modernized specifications;
wenzelm
parents: 41229
diff changeset
    50
type_synonym four_seqe = "[seq, seq, seq, seq] => prop"
f270e3e18be5 modernized specifications;
wenzelm
parents: 41229
diff changeset
    51
type_synonym sequence_name = "seq'=>seq'"
7166
a4a870ec2e67 Sara Kalvala: moving the <<...>> notation from LK to Sequents
paulson
parents: 7121
diff changeset
    52
a4a870ec2e67 Sara Kalvala: moving the <<...>> notation from LK to Sequents
paulson
parents: 7121
diff changeset
    53
14765
bafb24c150c1 proper use of 'syntax';
wenzelm
parents: 7166
diff changeset
    54
syntax
7166
a4a870ec2e67 Sara Kalvala: moving the <<...>> notation from LK to Sequents
paulson
parents: 7121
diff changeset
    55
  (*Constant to allow definitions of SEQUENCES of formulas*)
35113
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    56
  "_Side"        :: "seq=>(seq'=>seq')"     ("<<(_)>>")
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    57
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    58
ML {*
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    59
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    60
(* parse translation for sequences *)
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    61
35430
df2862dc23a8 adapted to authentic syntax -- actual types are verbatim;
wenzelm
parents: 35363
diff changeset
    62
fun abs_seq' t = Abs ("s", Type (@{type_name seq'}, []), t);
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    63
35113
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    64
fun seqobj_tr (Const (@{syntax_const "_SeqO"}, _) $ f) =
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    65
      Const (@{const_syntax SeqO'}, dummyT) $ f
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    66
  | seqobj_tr (_ $ i) = i;
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    67
35113
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    68
fun seqcont_tr (Const (@{syntax_const "_SeqContEmp"}, _)) = Bound 0
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    69
  | seqcont_tr (Const (@{syntax_const "_SeqContApp"}, _) $ so $ sc) =
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    70
      seqobj_tr so $ seqcont_tr sc;
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    71
35113
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    72
fun seq_tr (Const (@{syntax_const "_SeqEmp"}, _)) = abs_seq' (Bound 0)
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    73
  | seq_tr (Const (@{syntax_const "_SeqApp"}, _) $ so $ sc) =
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    74
      abs_seq'(seqobj_tr so $ seqcont_tr sc);
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    75
35113
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    76
fun singlobj_tr (Const (@{syntax_const "_SeqO"},_) $ f) =
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    77
  abs_seq' ((Const (@{const_syntax SeqO'}, dummyT) $ f) $ Bound 0);
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    78
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    79
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    80
(* print translation for sequences *)
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    81
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    82
fun seqcont_tr' (Bound 0) =
35113
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    83
      Const (@{syntax_const "_SeqContEmp"}, dummyT)
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    84
  | seqcont_tr' (Const (@{const_syntax SeqO'}, _) $ f $ s) =
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    85
      Const (@{syntax_const "_SeqContApp"}, dummyT) $
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    86
        (Const (@{syntax_const "_SeqO"}, dummyT) $ f) $ seqcont_tr' s
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    87
  | seqcont_tr' (i $ s) =
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    88
      Const (@{syntax_const "_SeqContApp"}, dummyT) $
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    89
        (Const (@{syntax_const "_SeqId"}, dummyT) $ i) $ seqcont_tr' s;
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    90
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    91
fun seq_tr' s =
35113
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    92
  let
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    93
    fun seq_itr' (Bound 0) = Const (@{syntax_const "_SeqEmp"}, dummyT)
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    94
      | seq_itr' (Const (@{const_syntax SeqO'}, _) $ f $ s) =
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    95
          Const (@{syntax_const "_SeqApp"}, dummyT) $
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    96
            (Const (@{syntax_const "_SeqO"}, dummyT) $ f) $ seqcont_tr' s
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    97
      | seq_itr' (i $ s) =
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    98
          Const (@{syntax_const "_SeqApp"}, dummyT) $
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    99
            (Const (@{syntax_const "_SeqId"}, dummyT) $ i) $ seqcont_tr' s
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
   100
  in
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
   101
    case s of
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
   102
      Abs (_, _, t) => seq_itr' t
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
   103
    | _ => s $ Bound 0
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
   104
  end;
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
   105
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
   106
35113
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
   107
fun single_tr c [s1, s2] =
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
   108
  Const (c, dummyT) $ seq_tr s1 $ singlobj_tr s2;
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
   109
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
   110
fun two_seq_tr c [s1, s2] =
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
   111
  Const (c, dummyT) $ seq_tr s1 $ seq_tr s2;
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
   112
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
   113
fun three_seq_tr c [s1, s2, s3] =
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
   114
  Const (c, dummyT) $ seq_tr s1 $ seq_tr s2 $ seq_tr s3;
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
   115
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
   116
fun four_seq_tr c [s1, s2, s3, s4] =
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
   117
  Const (c, dummyT) $ seq_tr s1 $ seq_tr s2 $ seq_tr s3 $ seq_tr s4;
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
   118
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
   119
35113
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
   120
fun singlobj_tr' (Const (@{const_syntax SeqO'},_) $ fm) = fm
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
   121
  | singlobj_tr' id = Const (@{syntax_const "_SeqId"}, dummyT) $ id;
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
   122
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
   123
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
   124
fun single_tr' c [s1, s2] =
35113
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
   125
  Const (c, dummyT) $ seq_tr' s1 $ seq_tr' s2;
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
   126
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
   127
fun two_seq_tr' c [s1, s2] =
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   128
  Const (c, dummyT) $ seq_tr' s1 $ seq_tr' s2;
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
   129
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
   130
fun three_seq_tr' c [s1, s2, s3] =
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   131
  Const (c, dummyT) $ seq_tr' s1 $ seq_tr' s2 $ seq_tr' s3;
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
   132
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
   133
fun four_seq_tr' c [s1, s2, s3, s4] =
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   134
  Const (c, dummyT) $ seq_tr' s1 $ seq_tr' s2 $ seq_tr' s3 $ seq_tr' s4;
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   135
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
   136
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
   137
7166
a4a870ec2e67 Sara Kalvala: moving the <<...>> notation from LK to Sequents
paulson
parents: 7121
diff changeset
   138
(** for the <<...>> notation **)
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   139
7166
a4a870ec2e67 Sara Kalvala: moving the <<...>> notation from LK to Sequents
paulson
parents: 7121
diff changeset
   140
fun side_tr [s1] = seq_tr s1;
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   141
*}
7166
a4a870ec2e67 Sara Kalvala: moving the <<...>> notation from LK to Sequents
paulson
parents: 7121
diff changeset
   142
35113
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
   143
parse_translation {* [(@{syntax_const "_Side"}, side_tr)] *}
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   144
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   145
use "prover.ML"
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   146
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   147
end
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   148