| 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}
 | 
| 325 |      7 | Chapter~\ref{sec:ref-defining-theories} explains the meanings of these
 | 
|  |      8 | constructs.  The syntax obeys the following conventions:
 | 
| 285 |      9 | \begin{itemize}
 | 
|  |     10 | \item {\tt Typewriter font} denotes terminal symbols.
 | 
|  |     11 | \item $id$, $tid$, $nat$, $string$ and $text$ are the lexical classes of
 | 
|  |     12 |   identifiers, type identifiers, natural numbers, \ML\ strings (with their
 | 
| 1148 |     13 |   quotation marks, but without the need for \verb$\$ at the end of a line and
 | 
|  |     14 |   the beginning of the next line) and arbitrary \ML\ text.  The first three
 | 
|  |     15 |   are fully defined in \iflabelundefined{Defining-Logics}%
 | 
| 325 |     16 |     {{\it The Isabelle Reference Manual}, chapter `Defining Logics'}%
 | 
|  |     17 |     {Chap.\ts\ref{Defining-Logics}}.
 | 
| 285 |     18 | \end{itemize}
 | 
| 325 |     19 | Comments in theories take the form {\tt (*} {\it text\/} {\tt*)}, where
 | 
|  |     20 | {\it text\/} should not contain the character sequence {\tt*)}.
 | 
| 285 |     21 | 
 | 
|  |     22 | \begin{rail}
 | 
|  |     23 | 
 | 
|  |     24 | theoryDef : id '=' (name + '+') ('+' extension | ());
 | 
|  |     25 | 
 | 
|  |     26 | name: id | string;
 | 
|  |     27 | 
 | 
| 1082 |     28 | extension : (section +) 'end' ( () | ml );
 | 
| 285 |     29 | 
 | 
| 1080 |     30 | section : classes
 | 
|  |     31 |         | default
 | 
|  |     32 |         | types
 | 
|  |     33 |         | arities
 | 
|  |     34 |         | consts
 | 
|  |     35 |         | trans
 | 
|  |     36 |         | defs
 | 
|  |     37 |         | rules
 | 
|  |     38 |         ;
 | 
|  |     39 | 
 | 
|  |     40 | classes : 'classes' ( ( id (  ()
 | 
| 285 |     41 |                             | '<' (id + ',')
 | 
|  |     42 |                            ) 
 | 
|  |     43 |                        ) + )
 | 
|  |     44 |         ;
 | 
|  |     45 | 
 | 
| 1080 |     46 | default : 'default' sort 
 | 
| 285 |     47 |         ;
 | 
|  |     48 | 
 | 
|  |     49 | sort :  id
 | 
|  |     50 |      | '\{' (id * ',') '\}'
 | 
|  |     51 |      ;
 | 
|  |     52 | 
 | 
| 1080 |     53 | types : 'types' ( ( typeDecl ( () | '(' infix ')' ) ) + )
 | 
| 285 |     54 |       ;
 | 
|  |     55 | 
 | 
| 325 |     56 | typeDecl : ( () | tid | '(' ( tid + ',' ) ')') name ( () | '='  string );
 | 
| 285 |     57 | 
 | 
|  |     58 | infix : ( 'infixr' | 'infixl' ) nat;
 | 
|  |     59 | 
 | 
|  |     60 | 
 | 
| 1080 |     61 | arities : 'arities' ((( name + ',' ) '::' arity ) + )
 | 
| 285 |     62 |         ;
 | 
|  |     63 | 
 | 
|  |     64 | arity   : ( () 
 | 
|  |     65 |           | '(' (sort + ',') ')' 
 | 
|  |     66 |           ) id
 | 
|  |     67 |         ;
 | 
|  |     68 | 
 | 
|  |     69 | 
 | 
| 1080 |     70 | consts : 'consts' ( ( constDecl ( () | ( '(' mixfix ')' ) ) ) + )
 | 
| 285 |     71 |        ;
 | 
|  |     72 | 
 | 
|  |     73 | constDecl : ( name + ',') '::' string ;
 | 
|  |     74 | 
 | 
|  |     75 | 
 | 
|  |     76 | mixfix :  string ( () | ( () | ('[' (nat + ',') ']')) nat )
 | 
|  |     77 |        | infix
 | 
|  |     78 |        | 'binder' string nat ;
 | 
|  |     79 | 
 | 
| 1080 |     80 | trans : 'translations' ( pat ( '==' | '=>' | '<=' ) pat + )
 | 
| 285 |     81 |       ;
 | 
|  |     82 | 
 | 
|  |     83 | pat : ( () | ( '(' id ')' ) ) string;
 | 
|  |     84 | 
 | 
| 1080 |     85 | rules : 'rules' (( id string ) + )
 | 
| 285 |     86 |       ;
 | 
|  |     87 | 
 | 
| 1080 |     88 | defs : 'defs' (( id string ) + )
 | 
|  |     89 |      ;
 | 
|  |     90 | 
 | 
| 1082 |     91 | ml : 'ML' text
 | 
| 285 |     92 |    ;
 | 
|  |     93 | 
 | 
|  |     94 | \end{rail}
 |