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 |
|
|
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:
|
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 |
|
3108
|
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
|
|
45 |
| consts
|
3108
|
46 |
| syntax
|
1080
|
47 |
| trans
|
|
48 |
| defs
|
3108
|
49 |
| constdefs
|
1080
|
50 |
| rules
|
3108
|
51 |
| axclass
|
|
52 |
| instance
|
1846
|
53 |
| oracle
|
1080
|
54 |
;
|
|
55 |
|
3108
|
56 |
classes : 'classes' ( classDecl + )
|
|
57 |
;
|
|
58 |
|
|
59 |
classDecl : (id (() | '<' (id + ',')))
|
285
|
60 |
;
|
|
61 |
|
1080
|
62 |
default : 'default' sort
|
285
|
63 |
;
|
|
64 |
|
|
65 |
sort : id
|
3098
|
66 |
| lbrace (id * ',') rbrace
|
285
|
67 |
;
|
|
68 |
|
1080
|
69 |
types : 'types' ( ( typeDecl ( () | '(' infix ')' ) ) + )
|
285
|
70 |
;
|
|
71 |
|
3215
|
72 |
infix : ( 'infixr' | 'infixl' ) (() | string) nat
|
3108
|
73 |
;
|
1488
|
74 |
|
|
75 |
typeDecl : typevarlist name
|
1385
|
76 |
( () | '=' ( string | type ) );
|
|
77 |
|
1488
|
78 |
typevarlist : () | tid | '(' ( tid + ',' ) ')';
|
|
79 |
|
1385
|
80 |
type : simpleType | '(' type ')' | type '=>' type |
|
|
81 |
'[' ( type + "," ) ']' '=>' type;
|
|
82 |
|
|
83 |
simpleType: id | ( tid ( () | '::' id ) ) |
|
3108
|
84 |
'(' ( type + "," ) ')' id | simpleType id
|
|
85 |
;
|
285
|
86 |
|
3108
|
87 |
arities : 'arities' ((name + ',') '::' arity +)
|
285
|
88 |
;
|
|
89 |
|
3108
|
90 |
arity : ( () | '(' (sort + ',') ')' ) sort
|
|
91 |
;
|
|
92 |
|
|
93 |
consts : 'consts' ( mixfixConstDecl + )
|
|
94 |
;
|
285
|
95 |
|
3108
|
96 |
syntax : 'syntax' (() | mode) ( mixfixConstDecl + );
|
285
|
97 |
|
3108
|
98 |
mode : '(' name (() | 'output') ')'
|
|
99 |
;
|
|
100 |
|
|
101 |
mixfixConstDecl : constDecl (() | ( '(' mixfix ')' ))
|
|
102 |
;
|
285
|
103 |
|
1382
|
104 |
constDecl : ( name + ',') '::' (string | type);
|
285
|
105 |
|
|
106 |
mixfix : string ( () | ( () | ('[' (nat + ',') ']')) nat )
|
3215
|
107 |
| infix
|
285
|
108 |
| 'binder' string nat ;
|
|
109 |
|
1080
|
110 |
trans : 'translations' ( pat ( '==' | '=>' | '<=' ) pat + )
|
285
|
111 |
;
|
|
112 |
|
|
113 |
pat : ( () | ( '(' id ')' ) ) string;
|
|
114 |
|
1080
|
115 |
rules : 'rules' (( id string ) + )
|
285
|
116 |
;
|
|
117 |
|
1080
|
118 |
defs : 'defs' (( id string ) + )
|
|
119 |
;
|
|
120 |
|
3108
|
121 |
constdefs : 'constdefs' (id '::' (string | type) string +)
|
|
122 |
;
|
|
123 |
|
|
124 |
axclass : 'axclass' classDecl (() | ( id string ) +)
|
|
125 |
;
|
|
126 |
|
|
127 |
instance : 'instance' ( name '<' name | name '::' arity) witness
|
|
128 |
;
|
|
129 |
|
3130
|
130 |
witness : (() | '(' ((string | longident) + ',') ')') (() | verbatim)
|
3108
|
131 |
;
|
|
132 |
|
1846
|
133 |
oracle : 'oracle' name
|
|
134 |
;
|
|
135 |
|
1082
|
136 |
ml : 'ML' text
|
285
|
137 |
;
|
|
138 |
|
|
139 |
\end{rail}
|