src/Sequents/Sequents.thy
author paulson
Fri, 05 Oct 2007 09:59:03 +0200
changeset 24854 0ebcd575d3c6
parent 24178 4ff1dc2aa18d
child 26956 1309a6a0a29f
permissions -rw-r--r--
filtering out some package theorems
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
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
     2
    ID:         $Id$
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
     4
    Copyright   1993  University of Cambridge
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
     5
*)
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
     6
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
     7
header {* Parsing and pretty-printing of sequences *}
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
     8
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
     9
theory Sequents
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    10
imports Pure
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    11
uses ("prover.ML")
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    12
begin
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    13
24178
4ff1dc2aa18d turned Unify flags into configuration options (global only);
wenzelm
parents: 18176
diff changeset
    14
declare [[unify_trace_bound = 20, unify_search_bound = 40]]
4ff1dc2aa18d turned Unify flags into configuration options (global only);
wenzelm
parents: 18176
diff changeset
    15
7098
86583034aacf installation of simplifier and classical reasoner, better rules etc
paulson
parents: 6819
diff changeset
    16
global
86583034aacf installation of simplifier and classical reasoner, better rules etc
paulson
parents: 6819
diff changeset
    17
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    18
typedecl o
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    19
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    20
(* Sequences *)
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
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    30
(* concrete syntax *)
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    31
14765
bafb24c150c1 proper use of 'syntax';
wenzelm
parents: 7166
diff changeset
    32
nonterminals
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    33
  seq seqobj seqcont
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    34
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    35
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    36
syntax
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    37
 SeqEmp         :: seq                                  ("")
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    38
 SeqApp         :: "[seqobj,seqcont] => seq"            ("__")
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    39
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    40
 SeqContEmp     :: seqcont                              ("")
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    41
 SeqContApp     :: "[seqobj,seqcont] => seqcont"        (",/ __")
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    42
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    43
 SeqO           :: "o => seqobj"                        ("_")
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    44
 SeqId          :: "'a => seqobj"                       ("$_")
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    45
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    46
types
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    47
 single_seqe = "[seq,seqobj] => prop"
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    48
 single_seqi = "[seq'=>seq',seq'=>seq'] => prop"
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    49
 two_seqi    = "[seq'=>seq', seq'=>seq'] => prop"
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    50
 two_seqe    = "[seq, seq] => prop"
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    51
 three_seqi  = "[seq'=>seq', seq'=>seq', seq'=>seq'] => prop"
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    52
 three_seqe  = "[seq, seq, seq] => prop"
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    53
 four_seqi   = "[seq'=>seq', seq'=>seq', seq'=>seq', seq'=>seq'] => prop"
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    54
 four_seqe   = "[seq, seq, seq, seq] => prop"
7166
a4a870ec2e67 Sara Kalvala: moving the <<...>> notation from LK to Sequents
paulson
parents: 7121
diff changeset
    55
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    56
 sequence_name = "seq'=>seq'"
7166
a4a870ec2e67 Sara Kalvala: moving the <<...>> notation from LK to Sequents
paulson
parents: 7121
diff changeset
    57
a4a870ec2e67 Sara Kalvala: moving the <<...>> notation from LK to Sequents
paulson
parents: 7121
diff changeset
    58
14765
bafb24c150c1 proper use of 'syntax';
wenzelm
parents: 7166
diff changeset
    59
syntax
7166
a4a870ec2e67 Sara Kalvala: moving the <<...>> notation from LK to Sequents
paulson
parents: 7121
diff changeset
    60
  (*Constant to allow definitions of SEQUENCES of formulas*)
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    61
  "@Side"        :: "seq=>(seq'=>seq')"     ("<<(_)>>")
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    62
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    63
ML {*
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    64
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    65
(* parse translation for sequences *)
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    66
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    67
fun abs_seq' t = Abs("s", Type("seq'",[]), t);
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    68
6819
433a980103b4 fixed title line; added spacing
paulson
parents: 2073
diff changeset
    69
fun seqobj_tr(Const("SeqO",_) $ f) = Const("SeqO'",dummyT) $ f |
433a980103b4 fixed title line; added spacing
paulson
parents: 2073
diff changeset
    70
    seqobj_tr(_ $ i) = i;
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    71
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    72
fun seqcont_tr(Const("SeqContEmp",_)) = Bound 0 |
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    73
    seqcont_tr(Const("SeqContApp",_) $ so $ sc) =
6819
433a980103b4 fixed title line; added spacing
paulson
parents: 2073
diff changeset
    74
      (seqobj_tr so) $ (seqcont_tr sc);
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    75
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    76
fun seq_tr(Const("SeqEmp",_)) = abs_seq'(Bound 0) |
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    77
    seq_tr(Const("SeqApp",_) $ so $ sc) =
6819
433a980103b4 fixed title line; added spacing
paulson
parents: 2073
diff changeset
    78
      abs_seq'(seqobj_tr(so) $ seqcont_tr(sc));
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    79
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    80
6819
433a980103b4 fixed title line; added spacing
paulson
parents: 2073
diff changeset
    81
fun singlobj_tr(Const("SeqO",_) $ f) =
433a980103b4 fixed title line; added spacing
paulson
parents: 2073
diff changeset
    82
    abs_seq' ((Const("SeqO'",dummyT) $ f) $ Bound 0);
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    83
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    84
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    85
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    86
(* print translation for sequences *)
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    87
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    88
fun seqcont_tr' (Bound 0) =
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    89
      Const("SeqContEmp",dummyT) |
6819
433a980103b4 fixed title line; added spacing
paulson
parents: 2073
diff changeset
    90
    seqcont_tr' (Const("SeqO'",_) $ f $ s) =
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    91
      Const("SeqContApp",dummyT) $
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    92
      (Const("SeqO",dummyT) $ f) $
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    93
      (seqcont_tr' s) |
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    94
(*    seqcont_tr' ((a as Abs(_,_,_)) $ s)=
18176
ae9bd644d106 Term.betapply;
wenzelm
parents: 17481
diff changeset
    95
      seqcont_tr'(Term.betapply(a,s)) | *)
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    96
    seqcont_tr' (i $ s) =
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    97
      Const("SeqContApp",dummyT) $
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
    98
      (Const("SeqId",dummyT) $ i) $
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
    99
      (seqcont_tr' s);
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
   100
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
   101
fun seq_tr' s =
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   102
    let fun seq_itr' (Bound 0) =
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
   103
              Const("SeqEmp",dummyT) |
6819
433a980103b4 fixed title line; added spacing
paulson
parents: 2073
diff changeset
   104
            seq_itr' (Const("SeqO'",_) $ f $ s) =
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   105
              Const("SeqApp",dummyT) $
6819
433a980103b4 fixed title line; added spacing
paulson
parents: 2073
diff changeset
   106
              (Const("SeqO",dummyT) $ f) $ (seqcont_tr' s) |
433a980103b4 fixed title line; added spacing
paulson
parents: 2073
diff changeset
   107
(*            seq_itr' ((a as Abs(_,_,_)) $ s) =
18176
ae9bd644d106 Term.betapply;
wenzelm
parents: 17481
diff changeset
   108
              seq_itr'(Term.betapply(a,s)) |    *)
6819
433a980103b4 fixed title line; added spacing
paulson
parents: 2073
diff changeset
   109
            seq_itr' (i $ s) =
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   110
              Const("SeqApp",dummyT) $
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   111
              (Const("SeqId",dummyT) $ i) $
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
   112
              (seqcont_tr' s)
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   113
    in case s of
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
   114
         Abs(_,_,t) => seq_itr' t |
6819
433a980103b4 fixed title line; added spacing
paulson
parents: 2073
diff changeset
   115
         _ => s $ (Bound 0)
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
   116
    end;
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
   117
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
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
   120
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
   121
fun single_tr c [s1,s2] =
6819
433a980103b4 fixed title line; added spacing
paulson
parents: 2073
diff changeset
   122
    Const(c,dummyT) $ seq_tr s1 $ singlobj_tr s2;
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
fun two_seq_tr c [s1,s2] =
6819
433a980103b4 fixed title line; added spacing
paulson
parents: 2073
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 three_seq_tr c [s1,s2,s3] =
6819
433a980103b4 fixed title line; added spacing
paulson
parents: 2073
diff changeset
   128
    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
   129
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
   130
fun four_seq_tr c [s1,s2,s3,s4] =
6819
433a980103b4 fixed title line; added spacing
paulson
parents: 2073
diff changeset
   131
    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
   132
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
   133
6819
433a980103b4 fixed title line; added spacing
paulson
parents: 2073
diff changeset
   134
fun singlobj_tr'(Const("SeqO'",_) $ fm) = fm |
433a980103b4 fixed title line; added spacing
paulson
parents: 2073
diff changeset
   135
    singlobj_tr'(id) = Const("@SeqId",dummyT) $ id;
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
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
   138
fun single_tr' c [s1, s2] =
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   139
(Const (c, dummyT) $ seq_tr' s1 $ seq_tr' s2 );
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
   140
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
   141
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
   142
fun two_seq_tr' c [s1, s2] =
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   143
  Const (c, dummyT) $ seq_tr' s1 $ seq_tr' s2;
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
   144
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
   145
fun three_seq_tr' c [s1, s2, s3] =
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   146
  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
   147
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
   148
fun four_seq_tr' c [s1, s2, s3, s4] =
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   149
  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
   150
2073
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
   151
fb0655539d05 New unified treatment of sequent calculi by Sara Kalvala
paulson
parents:
diff changeset
   152
7166
a4a870ec2e67 Sara Kalvala: moving the <<...>> notation from LK to Sequents
paulson
parents: 7121
diff changeset
   153
(** for the <<...>> notation **)
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   154
7166
a4a870ec2e67 Sara Kalvala: moving the <<...>> notation from LK to Sequents
paulson
parents: 7121
diff changeset
   155
fun side_tr [s1] = seq_tr s1;
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   156
*}
7166
a4a870ec2e67 Sara Kalvala: moving the <<...>> notation from LK to Sequents
paulson
parents: 7121
diff changeset
   157
17481
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   158
parse_translation {* [("@Side", side_tr)] *}
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   159
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   160
use "prover.ML"
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   161
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   162
end
75166ebb619b converted to Isar theory format;
wenzelm
parents: 14854
diff changeset
   163