src/Sequents/Sequents.thy
author wenzelm
Thu, 23 Jul 2015 14:25:05 +0200
changeset 60770 240563fbf41d
parent 58889 5b7a9633cfa8
child 61385 538100cc4399
permissions -rw-r--r--
isabelle update_cartouches;
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
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 58889
diff changeset
     6
section \<open>Parsing and pretty-printing of sequences\<close>
17481
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
55228
901a6696cdd8 misc tuning and modernization;
wenzelm
parents: 52143
diff changeset
    10
keywords "print_pack" :: diag
17481
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
55228
901a6696cdd8 misc tuning and modernization;
wenzelm
parents: 52143
diff changeset
    19
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 58889
diff changeset
    20
subsection \<open>Sequences\<close>
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    21
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    22
typedecl
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    23
 seq'
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    24
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    25
consts
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    26
 SeqO'         :: "[o,seq']=>seq'"
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    27
 Seq1'         :: "o=>seq'"
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    28
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    29
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 58889
diff changeset
    30
subsection \<open>Concrete syntax\<close>
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    31
41229
d797baa3d57c replaced command 'nonterminals' by slightly modernized version 'nonterminal';
wenzelm
parents: 39557
diff changeset
    32
nonterminal seq and seqobj and seqcont
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    33
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    34
syntax
35113
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    35
 "_SeqEmp"         :: seq                                  ("")
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    36
 "_SeqApp"         :: "[seqobj,seqcont] => seq"            ("__")
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    37
35113
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    38
 "_SeqContEmp"     :: seqcont                              ("")
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    39
 "_SeqContApp"     :: "[seqobj,seqcont] => seqcont"        (",/ __")
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    40
35113
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    41
 "_SeqO"           :: "o => seqobj"                        ("_")
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    42
 "_SeqId"          :: "'a => seqobj"                       ("$_")
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    43
42463
f270e3e18be5 modernized specifications;
wenzelm
parents: 41229
diff changeset
    44
type_synonym single_seqe = "[seq,seqobj] => prop"
f270e3e18be5 modernized specifications;
wenzelm
parents: 41229
diff changeset
    45
type_synonym single_seqi = "[seq'=>seq',seq'=>seq'] => prop"
f270e3e18be5 modernized specifications;
wenzelm
parents: 41229
diff changeset
    46
type_synonym two_seqi = "[seq'=>seq', seq'=>seq'] => prop"
f270e3e18be5 modernized specifications;
wenzelm
parents: 41229
diff changeset
    47
type_synonym two_seqe = "[seq, seq] => prop"
f270e3e18be5 modernized specifications;
wenzelm
parents: 41229
diff changeset
    48
type_synonym three_seqi = "[seq'=>seq', seq'=>seq', seq'=>seq'] => prop"
f270e3e18be5 modernized specifications;
wenzelm
parents: 41229
diff changeset
    49
type_synonym three_seqe = "[seq, seq, seq] => prop"
f270e3e18be5 modernized specifications;
wenzelm
parents: 41229
diff changeset
    50
type_synonym four_seqi = "[seq'=>seq', seq'=>seq', seq'=>seq', seq'=>seq'] => prop"
f270e3e18be5 modernized specifications;
wenzelm
parents: 41229
diff changeset
    51
type_synonym four_seqe = "[seq, seq, seq, seq] => prop"
f270e3e18be5 modernized specifications;
wenzelm
parents: 41229
diff changeset
    52
type_synonym sequence_name = "seq'=>seq'"
7166
a4a870ec2e67 Sara Kalvala: moving the <<...>> notation from LK to Sequents
paulson
parents: 7121
diff changeset
    53
a4a870ec2e67 Sara Kalvala: moving the <<...>> notation from LK to Sequents
paulson
parents: 7121
diff changeset
    54
14765
bafb24c150c1 proper use of 'syntax';
wenzelm
parents: 7166
diff changeset
    55
syntax
7166
a4a870ec2e67 Sara Kalvala: moving the <<...>> notation from LK to Sequents
paulson
parents: 7121
diff changeset
    56
  (*Constant to allow definitions of SEQUENCES of formulas*)
35113
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    57
  "_Side"        :: "seq=>(seq'=>seq')"     ("<<(_)>>")
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    58
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 58889
diff changeset
    59
ML \<open>
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    60
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    61
(* parse translation for sequences *)
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    62
35430
df2862dc23a8 adapted to authentic syntax -- actual types are verbatim;
wenzelm
parents: 35363
diff changeset
    63
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
    64
35113
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    65
fun seqobj_tr (Const (@{syntax_const "_SeqO"}, _) $ f) =
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    66
      Const (@{const_syntax SeqO'}, dummyT) $ f
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    67
  | seqobj_tr (_ $ i) = i;
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    68
35113
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    69
fun seqcont_tr (Const (@{syntax_const "_SeqContEmp"}, _)) = Bound 0
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    70
  | seqcont_tr (Const (@{syntax_const "_SeqContApp"}, _) $ so $ sc) =
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    71
      seqobj_tr so $ seqcont_tr sc;
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    72
35113
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    73
fun seq_tr (Const (@{syntax_const "_SeqEmp"}, _)) = abs_seq' (Bound 0)
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    74
  | seq_tr (Const (@{syntax_const "_SeqApp"}, _) $ so $ sc) =
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    75
      abs_seq'(seqobj_tr so $ seqcont_tr sc);
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    76
35113
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    77
fun singlobj_tr (Const (@{syntax_const "_SeqO"},_) $ f) =
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    78
  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
    79
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    80
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    81
(* print translation for sequences *)
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    82
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    83
fun seqcont_tr' (Bound 0) =
35113
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    84
      Const (@{syntax_const "_SeqContEmp"}, dummyT)
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    85
  | seqcont_tr' (Const (@{const_syntax SeqO'}, _) $ f $ s) =
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    86
      Const (@{syntax_const "_SeqContApp"}, dummyT) $
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    87
        (Const (@{syntax_const "_SeqO"}, dummyT) $ f) $ seqcont_tr' s
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    88
  | seqcont_tr' (i $ s) =
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    89
      Const (@{syntax_const "_SeqContApp"}, dummyT) $
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    90
        (Const (@{syntax_const "_SeqId"}, dummyT) $ i) $ seqcont_tr' s;
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    91
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    92
fun seq_tr' s =
35113
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    93
  let
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    94
    fun seq_itr' (Bound 0) = Const (@{syntax_const "_SeqEmp"}, dummyT)
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    95
      | seq_itr' (Const (@{const_syntax SeqO'}, _) $ f $ s) =
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    96
          Const (@{syntax_const "_SeqApp"}, dummyT) $
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    97
            (Const (@{syntax_const "_SeqO"}, dummyT) $ f) $ seqcont_tr' s
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    98
      | seq_itr' (i $ s) =
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
    99
          Const (@{syntax_const "_SeqApp"}, dummyT) $
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
   100
            (Const (@{syntax_const "_SeqId"}, dummyT) $ i) $ seqcont_tr' s
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
   101
  in
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
   102
    case s of
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
   103
      Abs (_, _, t) => seq_itr' t
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
   104
    | _ => s $ Bound 0
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
   105
  end;
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
   106
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
   107
35113
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
   108
fun single_tr c [s1, s2] =
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
   109
  Const (c, dummyT) $ seq_tr s1 $ singlobj_tr s2;
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
   110
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
   111
fun two_seq_tr c [s1, s2] =
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
   112
  Const (c, dummyT) $ seq_tr s1 $ seq_tr s2;
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
   113
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
   114
fun three_seq_tr c [s1, s2, s3] =
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
   115
  Const (c, dummyT) $ seq_tr s1 $ seq_tr s2 $ seq_tr s3;
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
   116
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
   117
fun four_seq_tr c [s1, s2, s3, s4] =
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
   118
  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
   119
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
   120
35113
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
   121
fun singlobj_tr' (Const (@{const_syntax SeqO'},_) $ fm) = fm
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
   122
  | singlobj_tr' id = Const (@{syntax_const "_SeqId"}, dummyT) $ id;
2073
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
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
   125
fun single_tr' c [s1, s2] =
35113
1a0c129bb2e0 modernized translations;
wenzelm
parents: 26956
diff changeset
   126
  Const (c, dummyT) $ seq_tr' s1 $ seq_tr' s2;
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
   127
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
   128
fun two_seq_tr' c [s1, s2] =
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   129
  Const (c, dummyT) $ seq_tr' s1 $ seq_tr' s2;
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
   130
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
   131
fun three_seq_tr' c [s1, s2, s3] =
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   132
  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
   133
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
   134
fun four_seq_tr' c [s1, s2, s3, s4] =
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   135
  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
   136
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
   137
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
   138
7166
a4a870ec2e67 Sara Kalvala: moving the <<...>> notation from LK to Sequents
paulson
parents: 7121
diff changeset
   139
(** for the <<...>> notation **)
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   140
7166
a4a870ec2e67 Sara Kalvala: moving the <<...>> notation from LK to Sequents
paulson
parents: 7121
diff changeset
   141
fun side_tr [s1] = seq_tr s1;
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 58889
diff changeset
   142
\<close>
7166
a4a870ec2e67 Sara Kalvala: moving the <<...>> notation from LK to Sequents
paulson
parents: 7121
diff changeset
   143
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 58889
diff changeset
   144
parse_translation \<open>[(@{syntax_const "_Side"}, K side_tr)]\<close>
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   145
55228
901a6696cdd8 misc tuning and modernization;
wenzelm
parents: 52143
diff changeset
   146
60770
240563fbf41d isabelle update_cartouches;
wenzelm
parents: 58889
diff changeset
   147
subsection \<open>Proof tools\<close>
55228
901a6696cdd8 misc tuning and modernization;
wenzelm
parents: 52143
diff changeset
   148
48891
c0eafbd55de3 prefer ML_file over old uses;
wenzelm
parents: 42463
diff changeset
   149
ML_file "prover.ML"
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   150
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   151
end
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   152