doc-src/Ref/theory-syntax.tex
author clasohm
Fri, 01 Dec 1995 12:26:42 +0100
changeset 1379 8f693d2ffb59
parent 1375 d04af07266e8
child 1382 7e97232c1159
permissions -rw-r--r--
modified simpleType
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}
325
49baeba86546 penultimate Springer draft
lcp
parents: 295
diff changeset
     7
Chapter~\ref{sec:ref-defining-theories} explains the meanings of these
49baeba86546 penultimate Springer draft
lcp
parents: 295
diff changeset
     8
constructs.  The syntax obeys the following conventions:
285
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
     9
\begin{itemize}
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    10
\item {\tt Typewriter font} denotes terminal symbols.
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    11
\item $id$, $tid$, $nat$, $string$ and $text$ are the lexical classes of
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    12
  identifiers, type identifiers, natural numbers, \ML\ strings (with their
1148
e125fc7a1183 Added remark that \...\ in strings is unnecessary.
nipkow
parents: 1082
diff changeset
    13
  quotation marks, but without the need for \verb$\$ at the end of a line and
e125fc7a1183 Added remark that \...\ in strings is unnecessary.
nipkow
parents: 1082
diff changeset
    14
  the beginning of the next line) and arbitrary \ML\ text.  The first three
e125fc7a1183 Added remark that \...\ in strings is unnecessary.
nipkow
parents: 1082
diff changeset
    15
  are fully defined in \iflabelundefined{Defining-Logics}%
325
49baeba86546 penultimate Springer draft
lcp
parents: 295
diff changeset
    16
    {{\it The Isabelle Reference Manual}, chapter `Defining Logics'}%
49baeba86546 penultimate Springer draft
lcp
parents: 295
diff changeset
    17
    {Chap.\ts\ref{Defining-Logics}}.
285
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    18
\end{itemize}
325
49baeba86546 penultimate Springer draft
lcp
parents: 295
diff changeset
    19
Comments in theories take the form {\tt (*} {\it text\/} {\tt*)}, where
49baeba86546 penultimate Springer draft
lcp
parents: 295
diff changeset
    20
{\it text\/} should not contain the character sequence {\tt*)}.
285
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    21
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    22
\begin{rail}
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    23
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    24
theoryDef : id '=' (name + '+') ('+' extension | ());
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    25
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    26
name: id | string;
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    27
1082
1b30e27aca82 Simplified layout a little.
nipkow
parents: 1080
diff changeset
    28
extension : (section +) 'end' ( () | ml );
285
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    29
1080
13c35eb5169b Sections can now be given in any order.
nipkow
parents: 325
diff changeset
    30
section : classes
13c35eb5169b Sections can now be given in any order.
nipkow
parents: 325
diff changeset
    31
        | default
13c35eb5169b Sections can now be given in any order.
nipkow
parents: 325
diff changeset
    32
        | types
13c35eb5169b Sections can now be given in any order.
nipkow
parents: 325
diff changeset
    33
        | arities
13c35eb5169b Sections can now be given in any order.
nipkow
parents: 325
diff changeset
    34
        | consts
13c35eb5169b Sections can now be given in any order.
nipkow
parents: 325
diff changeset
    35
        | trans
13c35eb5169b Sections can now be given in any order.
nipkow
parents: 325
diff changeset
    36
        | defs
13c35eb5169b Sections can now be given in any order.
nipkow
parents: 325
diff changeset
    37
        | rules
13c35eb5169b Sections can now be given in any order.
nipkow
parents: 325
diff changeset
    38
        ;
13c35eb5169b Sections can now be given in any order.
nipkow
parents: 325
diff changeset
    39
13c35eb5169b Sections can now be given in any order.
nipkow
parents: 325
diff changeset
    40
classes : 'classes' ( ( id (  ()
285
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    41
                            | '<' (id + ',')
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    42
                           ) 
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    43
                       ) + )
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    44
        ;
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    45
1080
13c35eb5169b Sections can now be given in any order.
nipkow
parents: 325
diff changeset
    46
default : 'default' sort 
285
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    47
        ;
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    48
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    49
sort :  id
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    50
     | '\{' (id * ',') '\}'
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    51
     ;
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    52
1080
13c35eb5169b Sections can now be given in any order.
nipkow
parents: 325
diff changeset
    53
types : 'types' ( ( typeDecl ( () | '(' infix ')' ) ) + )
285
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    54
      ;
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    55
325
49baeba86546 penultimate Springer draft
lcp
parents: 295
diff changeset
    56
typeDecl : ( () | tid | '(' ( tid + ',' ) ')') name ( () | '='  string );
285
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    57
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    58
infix : ( 'infixr' | 'infixl' ) nat;
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    59
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    60
1080
13c35eb5169b Sections can now be given in any order.
nipkow
parents: 325
diff changeset
    61
arities : 'arities' ((( name + ',' ) '::' arity ) + )
285
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    62
        ;
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    63
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    64
arity   : ( () 
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    65
          | '(' (sort + ',') ')' 
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    66
          ) id
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    67
        ;
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    68
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    69
1080
13c35eb5169b Sections can now be given in any order.
nipkow
parents: 325
diff changeset
    70
consts : 'consts' ( ( constDecl ( () | ( '(' mixfix ')' ) ) ) + )
285
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    71
       ;
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    72
1375
d04af07266e8 removed spaghetti diagrams for constType
clasohm
parents: 1373
diff changeset
    73
constDecl : ( name + ',') '::' (string | constType);
285
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    74
1375
d04af07266e8 removed spaghetti diagrams for constType
clasohm
parents: 1373
diff changeset
    75
constType : simpleType | '(' constType ')' | '[' ( constType + "," ) ']'
d04af07266e8 removed spaghetti diagrams for constType
clasohm
parents: 1373
diff changeset
    76
            '=>' constType | constType '=>' constType;
1373
f061d2435d63 changed syntax diagrams according to quote-less consts and syntax section
clasohm
parents: 1148
diff changeset
    77
1375
d04af07266e8 removed spaghetti diagrams for constType
clasohm
parents: 1373
diff changeset
    78
simpleType: id | ( tid ( () | '::' id ) ) |
1379
8f693d2ffb59 modified simpleType
clasohm
parents: 1375
diff changeset
    79
            '(' ( constType + "," ) ')' ( id + ',' ) | simpleType ( id + ',' );
285
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    80
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    81
mixfix :  string ( () | ( () | ('[' (nat + ',') ']')) nat )
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    82
       | infix
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    83
       | 'binder' string nat ;
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    84
1080
13c35eb5169b Sections can now be given in any order.
nipkow
parents: 325
diff changeset
    85
trans : 'translations' ( pat ( '==' | '=>' | '<=' ) pat + )
285
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    86
      ;
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    87
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    88
pat : ( () | ( '(' id ')' ) ) string;
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    89
1080
13c35eb5169b Sections can now be given in any order.
nipkow
parents: 325
diff changeset
    90
rules : 'rules' (( id string ) + )
285
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    91
      ;
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    92
1080
13c35eb5169b Sections can now be given in any order.
nipkow
parents: 325
diff changeset
    93
defs : 'defs' (( id string ) + )
13c35eb5169b Sections can now be given in any order.
nipkow
parents: 325
diff changeset
    94
     ;
13c35eb5169b Sections can now be given in any order.
nipkow
parents: 325
diff changeset
    95
1082
1b30e27aca82 Simplified layout a little.
nipkow
parents: 1080
diff changeset
    96
ml : 'ML' text
285
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    97
   ;
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    98
fd4a6585e5bf first draft of Springer book
lcp
parents:
diff changeset
    99
\end{rail}