4 \newlinechar=-1 %mathsing.sty sets \newlinechar=`\|, which would cause mayhem
6 \chapter{Syntax of Isabelle Theories}\label{app:TheorySyntax}
8 Below we present the full syntax of theory definition files as
9 provided by {\Pure} Isabelle --- object-logics may add their own
10 sections. \S\ref{sec:ref-defining-theories} explains the meanings of
11 these constructs. The syntax obeys the following conventions:
13 \item {\tt Typewriter font} denotes terminal symbols.
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}}.
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.|}.
26 \item Comments in theories take the form {\tt (*}\dots{\tt*)} and may
27 be nested, just as in \ML.
32 theoryDef : id '=' (name + '+') ('+' extension | ())
38 extension : (section +) 'end' ( () | ml )
56 classes : 'classes' ( classDecl + )
59 classDecl : (id (() | '<' (id + ',')))
62 default : 'default' sort
66 | lbrace (id * ',') rbrace
69 types : 'types' ( ( typeDecl ( () | '(' infix ')' ) ) + )
72 infix : ( 'infixr' | 'infixl' ) nat
75 typeDecl : typevarlist name
76 ( () | '=' ( string | type ) );
78 typevarlist : () | tid | '(' ( tid + ',' ) ')';
80 type : simpleType | '(' type ')' | type '=>' type |
81 '[' ( type + "," ) ']' '=>' type;
83 simpleType: id | ( tid ( () | '::' id ) ) |
84 '(' ( type + "," ) ')' id | simpleType id
87 arities : 'arities' ((name + ',') '::' arity +)
90 arity : ( () | '(' (sort + ',') ')' ) sort
93 consts : 'consts' ( mixfixConstDecl + )
96 syntax : 'syntax' (() | mode) ( mixfixConstDecl + );
98 mode : '(' name (() | 'output') ')'
101 mixfixConstDecl : constDecl (() | ( '(' mixfix ')' ))
104 constDecl : ( name + ',') '::' (string | type);
106 mixfix : string ( () | ( () | ('[' (nat + ',') ']')) nat )
107 | ( 'infixr' | 'infixl' ) (() | string) nat
108 | 'binder' string nat ;
110 trans : 'translations' ( pat ( '==' | '=>' | '<=' ) pat + )
113 pat : ( () | ( '(' id ')' ) ) string;
115 rules : 'rules' (( id string ) + )
118 defs : 'defs' (( id string ) + )
121 constdefs : 'constdefs' (id '::' (string | type) string +)
124 axclass : 'axclass' classDecl (() | ( id string ) +)
127 instance : 'instance' ( name '<' name | name '::' arity) witness
130 witness : (() | ((string | longident) + ',')) (() | verbatim)
133 oracle : 'oracle' name