| 285 |      1 | %% $Id$
 | 
|  |      2 | 
 | 
|  |      3 | \appendix
 | 
|  |      4 | \newlinechar=-1  %mathsing.sty sets \newlinechar=`\|, which would cause mayhem
 | 
|  |      5 | 
 | 
|  |      6 | \chapter{Syntax of Isabelle Theories}\label{app:TheorySyntax}
 | 
| 3108 |      7 | 
 | 
| 9695 |      8 | Below we present the full syntax of theory definition files as provided by
 | 
|  |      9 | Pure Isabelle --- object-logics may add their own sections.
 | 
|  |     10 | \S\ref{sec:ref-defining-theories} explains the meanings of these constructs.
 | 
|  |     11 | The syntax obeys the following conventions:
 | 
| 285 |     12 | \begin{itemize}
 | 
|  |     13 | \item {\tt Typewriter font} denotes terminal symbols.
 | 
| 3108 |     14 |   
 | 
|  |     15 | \item $id$, $tid$, $nat$, $string$ and $longident$ are the lexical
 | 
|  |     16 |   classes of identifiers, type identifiers, natural numbers, quoted
 | 
|  |     17 |   strings (without the need for \verb$\$\dots\verb$\$ between lines)
 | 
|  |     18 |   and long qualified \ML{} identifiers.
 | 
|  |     19 |   The categories $id$, $tid$, $nat$ are fully defined in \iflabelundefined{Defining-Logics}%
 | 
|  |     20 |   {{\it The Isabelle Reference Manual}, chapter `Defining Logics'}%
 | 
|  |     21 |   {\S\ref{Defining-Logics}}.
 | 
|  |     22 |   
 | 
|  |     23 | \item $text$ is all text from the current position to the end of file,
 | 
|  |     24 |   $verbatim$ is any text enclosed in \verb.{|.\dots\verb.|}.
 | 
|  |     25 |   
 | 
|  |     26 | \item Comments in theories take the form {\tt (*}\dots{\tt*)} and may
 | 
|  |     27 |   be nested, just as in \ML.
 | 
| 285 |     28 | \end{itemize}
 | 
|  |     29 | 
 | 
|  |     30 | \begin{rail}
 | 
|  |     31 | 
 | 
| 3108 |     32 | theoryDef : id '=' (name + '+') ('+' extension | ())
 | 
|  |     33 |           ;
 | 
| 285 |     34 | 
 | 
| 5369 |     35 | name : id | string
 | 
|  |     36 |      ;
 | 
| 285 |     37 | 
 | 
| 3108 |     38 | extension : (section +) 'end' ( () | ml )
 | 
|  |     39 |           ;
 | 
| 285 |     40 | 
 | 
| 1080 |     41 | section : classes
 | 
|  |     42 |         | default
 | 
|  |     43 |         | types
 | 
|  |     44 |         | arities
 | 
| 5369 |     45 |         | nonterminals
 | 
| 1080 |     46 |         | consts
 | 
| 3108 |     47 |         | syntax
 | 
| 1080 |     48 |         | trans
 | 
|  |     49 |         | defs
 | 
| 3108 |     50 |         | constdefs
 | 
| 1080 |     51 |         | rules
 | 
| 3108 |     52 |         | axclass
 | 
|  |     53 |         | instance
 | 
| 1846 |     54 |         | oracle
 | 
| 6669 |     55 |         | locale
 | 
| 4543 |     56 |         | local
 | 
|  |     57 |         | global
 | 
| 5369 |     58 |         | setup
 | 
| 1080 |     59 |         ;
 | 
|  |     60 | 
 | 
| 3108 |     61 | classes : 'classes' ( classDecl + )
 | 
|  |     62 |         ;
 | 
|  |     63 | 
 | 
|  |     64 | classDecl : (id (() | '<' (id + ',')))
 | 
| 5369 |     65 |           ;
 | 
| 285 |     66 | 
 | 
| 1080 |     67 | default : 'default' sort 
 | 
| 285 |     68 |         ;
 | 
|  |     69 | 
 | 
|  |     70 | sort :  id
 | 
| 3098 |     71 |      | lbrace (id * ',') rbrace
 | 
| 285 |     72 |      ;
 | 
|  |     73 | 
 | 
| 1080 |     74 | types : 'types' ( ( typeDecl ( () | '(' infix ')' ) ) + )
 | 
| 285 |     75 |       ;
 | 
|  |     76 | 
 | 
| 3215 |     77 | infix : ( 'infixr' | 'infixl' ) (() | string) nat
 | 
| 3108 |     78 |       ;
 | 
| 1488 |     79 | 
 | 
|  |     80 | typeDecl : typevarlist name
 | 
| 1385 |     81 |            ( () | '=' ( string | type ) );
 | 
|  |     82 | 
 | 
| 1488 |     83 | typevarlist : () | tid | '(' ( tid + ',' ) ')';
 | 
|  |     84 | 
 | 
| 1385 |     85 | type : simpleType | '(' type ')' | type '=>' type |
 | 
|  |     86 |        '[' ( type + "," ) ']' '=>' type;
 | 
|  |     87 | 
 | 
|  |     88 | simpleType: id | ( tid ( () | '::' id ) ) |
 | 
| 3108 |     89 |             '(' ( type + "," ) ')' id | simpleType id
 | 
|  |     90 |           ;
 | 
| 285 |     91 | 
 | 
| 3108 |     92 | arities : 'arities' ((name + ',') '::' arity +)
 | 
| 285 |     93 |         ;
 | 
|  |     94 | 
 | 
| 3108 |     95 | arity : ( () | '(' (sort + ',') ')' ) sort
 | 
|  |     96 |       ;
 | 
|  |     97 | 
 | 
| 5369 |     98 | nonterminals : 'nonterminals' (name+)
 | 
|  |     99 |              ;
 | 
|  |    100 | 
 | 
| 3108 |    101 | consts : 'consts' ( mixfixConstDecl + )
 | 
|  |    102 |        ;
 | 
| 285 |    103 | 
 | 
| 3108 |    104 | syntax : 'syntax' (() | mode) ( mixfixConstDecl + );
 | 
| 285 |    105 | 
 | 
| 3108 |    106 | mode : '(' name (() | 'output') ')'
 | 
|  |    107 |      ;
 | 
|  |    108 | 
 | 
|  |    109 | mixfixConstDecl : constDecl (() | ( '(' mixfix ')' ))
 | 
|  |    110 |                 ;
 | 
| 285 |    111 | 
 | 
| 1382 |    112 | constDecl : ( name + ',') '::' (string | type);
 | 
| 285 |    113 | 
 | 
|  |    114 | mixfix :  string ( () | ( () | ('[' (nat + ',') ']')) nat )
 | 
| 3215 |    115 |        |  infix
 | 
| 285 |    116 |        | 'binder' string nat ;
 | 
|  |    117 | 
 | 
| 1080 |    118 | trans : 'translations' ( pat ( '==' | '=>' | '<=' ) pat + )
 | 
| 285 |    119 |       ;
 | 
|  |    120 | 
 | 
|  |    121 | pat : ( () | ( '(' id ')' ) ) string;
 | 
|  |    122 | 
 | 
| 1080 |    123 | rules : 'rules' (( id string ) + )
 | 
| 285 |    124 |       ;
 | 
|  |    125 | 
 | 
| 1080 |    126 | defs : 'defs' (( id string ) + )
 | 
|  |    127 |      ;
 | 
|  |    128 | 
 | 
| 4891 |    129 | constdefs : 'constdefs' (name '::' (string | type) (() | mixfix) string +)
 | 
| 3108 |    130 |           ;
 | 
|  |    131 | 
 | 
|  |    132 | axclass : 'axclass' classDecl (() | ( id string ) +)
 | 
|  |    133 |         ;
 | 
|  |    134 | 
 | 
|  |    135 | instance : 'instance' ( name '<' name | name '::' arity) witness
 | 
|  |    136 |          ;
 | 
|  |    137 | 
 | 
| 5369 |    138 | witness : (() | '(' ((string | id | longident) + ',') ')') (() | verbatim)
 | 
| 3108 |    139 |         ;
 | 
|  |    140 | 
 | 
| 6669 |    141 | locale : 'locale' name '=' ( () | name '+' ) localeBody
 | 
|  |    142 |        ;
 | 
|  |    143 | 
 | 
|  |    144 | localeBody : localeConsts ( () | localeAsms ) ( () | localeDefs )
 | 
|  |    145 |        ;
 | 
|  |    146 | 
 | 
|  |    147 | localeConsts: ( 'fixes' ( ( (name '::' ( string | type )) ( () | '(' mixfix ')' ) ) + ) )
 | 
|  |    148 |        ;
 | 
|  |    149 | 
 | 
|  |    150 | 
 | 
|  |    151 | localeAsms:    ( 'assumes' ( ( id string ) + ) )
 | 
|  |    152 |        ;
 | 
|  |    153 | 
 | 
|  |    154 | localeDefs:   ( 'defines' ( ( id string ) +) )
 | 
|  |    155 |        ;
 | 
|  |    156 | 
 | 
| 4317 |    157 | oracle : 'oracle' name '=' name
 | 
| 1846 |    158 |        ;
 | 
|  |    159 | 
 | 
| 4543 |    160 | local : 'local'
 | 
| 5369 |    161 |       ;
 | 
| 4543 |    162 | 
 | 
|  |    163 | global : 'global'
 | 
|  |    164 |        ;
 | 
|  |    165 | 
 | 
| 5369 |    166 | setup : 'setup' (id | longident)
 | 
|  |    167 |       ;
 | 
|  |    168 | 
 | 
| 1082 |    169 | ml : 'ML' text
 | 
| 285 |    170 |    ;
 | 
|  |    171 | 
 | 
|  |    172 | \end{rail}
 | 
| 5369 |    173 | 
 | 
|  |    174 | 
 | 
|  |    175 | %%% Local Variables: 
 | 
|  |    176 | %%% mode: latex
 | 
|  |    177 | %%% TeX-master: "ref"
 | 
|  |    178 | %%% End: 
 |