doc-src/Ref/theory-syntax.tex
author wenzelm
Thu, 27 Nov 1997 19:39:02 +0100
changeset 4317 7264fa2ff2ec
parent 3215 9e097d5cc246
child 4543 82a45bdd0e80
permissions -rw-r--r--
several minor updates;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
285
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
     1
%% $Id$
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
     2
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
     3
\appendix
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
     4
\newlinechar=-1  %mathsing.sty sets \newlinechar=`\|, which would cause mayhem
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
     5
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
     6
\chapter{Syntax of Isabelle Theories}\label{app:TheorySyntax}
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3098
diff changeset
     7
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3098
diff changeset
     8
Below we present the full syntax of theory definition files as
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3098
diff changeset
     9
provided by {\Pure} Isabelle --- object-logics may add their own
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3098
diff changeset
    10
sections.  \S\ref{sec:ref-defining-theories} explains the meanings of
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3098
diff changeset
    11
these constructs.  The syntax obeys the following conventions:
285
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    12
\begin{itemize}
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    13
\item {\tt Typewriter font} denotes terminal symbols.
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3098
diff changeset
    14
  
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3098
diff changeset
    15
\item $id$, $tid$, $nat$, $string$ and $longident$ are the lexical
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3098
diff changeset
    16
  classes of identifiers, type identifiers, natural numbers, quoted
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3098
diff changeset
    17
  strings (without the need for \verb$\$\dots\verb$\$ between lines)
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3098
diff changeset
    18
  and long qualified \ML{} identifiers.
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3098
diff changeset
    19
  The categories $id$, $tid$, $nat$ are fully defined in \iflabelundefined{Defining-Logics}%
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3098
diff changeset
    20
  {{\it The Isabelle Reference Manual}, chapter `Defining Logics'}%
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3098
diff changeset
    21
  {\S\ref{Defining-Logics}}.
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3098
diff changeset
    22
  
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3098
diff changeset
    23
\item $text$ is all text from the current position to the end of file,
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3098
diff changeset
    24
  $verbatim$ is any text enclosed in \verb.{|.\dots\verb.|}.
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3098
diff changeset
    25
  
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3098
diff changeset
    26
\item Comments in theories take the form {\tt (*}\dots{\tt*)} and may
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3098
diff changeset
    27
  be nested, just as in \ML.
285
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    28
\end{itemize}
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    29
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    30
\begin{rail}
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    31
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3098
diff changeset
    32
theoryDef : id '=' (name + '+') ('+' extension | ())
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3098
diff changeset
    33
          ;
285
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    34
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3098
diff changeset
    35
name: id | string
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3098
diff changeset
    36
    ;
285
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    37
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3098
diff changeset
    38
extension : (section +) 'end' ( () | ml )
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3098
diff changeset
    39
          ;
285
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    40
1080
13c35eb5169b Sections can now be given in any order.
nipkow
parents: 325
diff changeset
    41
section : classes
13c35eb5169b Sections can now be given in any order.
nipkow
parents: 325
diff changeset
    42
        | default
13c35eb5169b Sections can now be given in any order.
nipkow
parents: 325
diff changeset
    43
        | types
13c35eb5169b Sections can now be given in any order.
nipkow
parents: 325
diff changeset
    44
        | arities
13c35eb5169b Sections can now be given in any order.
nipkow
parents: 325
diff changeset
    45
        | consts
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3098
diff changeset
    46
        | syntax
1080
13c35eb5169b Sections can now be given in any order.
nipkow
parents: 325
diff changeset
    47
        | trans
13c35eb5169b Sections can now be given in any order.
nipkow
parents: 325
diff changeset
    48
        | defs
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3098
diff changeset
    49
        | constdefs
1080
13c35eb5169b Sections can now be given in any order.
nipkow
parents: 325
diff changeset
    50
        | rules
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3098
diff changeset
    51
        | axclass
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3098
diff changeset
    52
        | instance
1846
763f08fb194f Documentation of oracles and their syntax
paulson
parents: 1650
diff changeset
    53
        | oracle
1080
13c35eb5169b Sections can now be given in any order.
nipkow
parents: 325
diff changeset
    54
        ;
13c35eb5169b Sections can now be given in any order.
nipkow
parents: 325
diff changeset
    55
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3098
diff changeset
    56
classes : 'classes' ( classDecl + )
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3098
diff changeset
    57
        ;
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3098
diff changeset
    58
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3098
diff changeset
    59
classDecl : (id (() | '<' (id + ',')))
285
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    60
        ;
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    61
1080
13c35eb5169b Sections can now be given in any order.
nipkow
parents: 325
diff changeset
    62
default : 'default' sort 
285
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    63
        ;
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    64
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    65
sort :  id
3098
a31170b67367 Updated to LaTeX 2e
berghofe
parents: 1846
diff changeset
    66
     | lbrace (id * ',') rbrace
285
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    67
     ;
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    68
1080
13c35eb5169b Sections can now be given in any order.
nipkow
parents: 325
diff changeset
    69
types : 'types' ( ( typeDecl ( () | '(' infix ')' ) ) + )
285
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    70
      ;
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    71
3215
9e097d5cc246 fixed infix syntax;
wenzelm
parents: 3130
diff changeset
    72
infix : ( 'infixr' | 'infixl' ) (() | string) nat
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3098
diff changeset
    73
      ;
1488
b25a747876a4 Added typevarlist
nipkow
parents: 1385
diff changeset
    74
b25a747876a4 Added typevarlist
nipkow
parents: 1385
diff changeset
    75
typeDecl : typevarlist name
1385
63c3d78df538 changed typeDecl
clasohm
parents: 1382
diff changeset
    76
           ( () | '=' ( string | type ) );
63c3d78df538 changed typeDecl
clasohm
parents: 1382
diff changeset
    77
1488
b25a747876a4 Added typevarlist
nipkow
parents: 1385
diff changeset
    78
typevarlist : () | tid | '(' ( tid + ',' ) ')';
b25a747876a4 Added typevarlist
nipkow
parents: 1385
diff changeset
    79
1385
63c3d78df538 changed typeDecl
clasohm
parents: 1382
diff changeset
    80
type : simpleType | '(' type ')' | type '=>' type |
63c3d78df538 changed typeDecl
clasohm
parents: 1382
diff changeset
    81
       '[' ( type + "," ) ']' '=>' type;
63c3d78df538 changed typeDecl
clasohm
parents: 1382
diff changeset
    82
63c3d78df538 changed typeDecl
clasohm
parents: 1382
diff changeset
    83
simpleType: id | ( tid ( () | '::' id ) ) |
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3098
diff changeset
    84
            '(' ( type + "," ) ')' id | simpleType id
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3098
diff changeset
    85
          ;
285
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    86
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3098
diff changeset
    87
arities : 'arities' ((name + ',') '::' arity +)
285
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    88
        ;
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    89
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3098
diff changeset
    90
arity : ( () | '(' (sort + ',') ')' ) sort
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3098
diff changeset
    91
      ;
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3098
diff changeset
    92
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3098
diff changeset
    93
consts : 'consts' ( mixfixConstDecl + )
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3098
diff changeset
    94
       ;
285
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    95
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3098
diff changeset
    96
syntax : 'syntax' (() | mode) ( mixfixConstDecl + );
285
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    97
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3098
diff changeset
    98
mode : '(' name (() | 'output') ')'
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3098
diff changeset
    99
     ;
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3098
diff changeset
   100
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3098
diff changeset
   101
mixfixConstDecl : constDecl (() | ( '(' mixfix ')' ))
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3098
diff changeset
   102
                ;
285
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
   103
1382
7e97232c1159 corrected diagrams for type and simpleType
clasohm
parents: 1379
diff changeset
   104
constDecl : ( name + ',') '::' (string | type);
285
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
   105
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
   106
mixfix :  string ( () | ( () | ('[' (nat + ',') ']')) nat )
3215
9e097d5cc246 fixed infix syntax;
wenzelm
parents: 3130
diff changeset
   107
       |  infix
285
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
   108
       | 'binder' string nat ;
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
   109
1080
13c35eb5169b Sections can now be given in any order.
nipkow
parents: 325
diff changeset
   110
trans : 'translations' ( pat ( '==' | '=>' | '<=' ) pat + )
285
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
   111
      ;
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
   112
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
   113
pat : ( () | ( '(' id ')' ) ) string;
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
   114
1080
13c35eb5169b Sections can now be given in any order.
nipkow
parents: 325
diff changeset
   115
rules : 'rules' (( id string ) + )
285
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
   116
      ;
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
   117
1080
13c35eb5169b Sections can now be given in any order.
nipkow
parents: 325
diff changeset
   118
defs : 'defs' (( id string ) + )
13c35eb5169b Sections can now be given in any order.
nipkow
parents: 325
diff changeset
   119
     ;
13c35eb5169b Sections can now be given in any order.
nipkow
parents: 325
diff changeset
   120
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3098
diff changeset
   121
constdefs : 'constdefs' (id '::' (string | type) string +)
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3098
diff changeset
   122
          ;
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3098
diff changeset
   123
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3098
diff changeset
   124
axclass : 'axclass' classDecl (() | ( id string ) +)
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3098
diff changeset
   125
        ;
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3098
diff changeset
   126
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3098
diff changeset
   127
instance : 'instance' ( name '<' name | name '::' arity) witness
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3098
diff changeset
   128
         ;
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3098
diff changeset
   129
3130
1ffe03f4c700 fixed witness syntax;
wenzelm
parents: 3108
diff changeset
   130
witness : (() | '(' ((string | longident) + ',') ')') (() | verbatim)
3108
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3098
diff changeset
   131
        ;
335efc3f5632 misc updates, tuning, cleanup;
wenzelm
parents: 3098
diff changeset
   132
4317
7264fa2ff2ec several minor updates;
wenzelm
parents: 3215
diff changeset
   133
oracle : 'oracle' name '=' name
1846
763f08fb194f Documentation of oracles and their syntax
paulson
parents: 1650
diff changeset
   134
       ;
763f08fb194f Documentation of oracles and their syntax
paulson
parents: 1650
diff changeset
   135
1082
1b30e27aca82 Simplified layout a little.
nipkow
parents: 1080
diff changeset
   136
ml : 'ML' text
285
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
   137
   ;
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
   138
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
   139
\end{rail}