7046

1 

7315

2 
\chapter{Basic Isar elements}\label{ch:puresyntax}

7167

3 

7315

4 
Subsequently, we introduce the main part of the basic Isar theory and proof


5 
commands as provided by Isabelle/Pure. Chapter~\ref{ch:gentools} describes


6 
further Isar elements as provided by generic tools and packages that are


7 
either part of Pure Isabelle, or preloaded by most object logics (such as the


8 
Simplifier). See chapter~\ref{ch:holtools} for actual objectlogic specific


9 
elements (for Isabelle/HOL).

7046

10 

7167

11 
\medskip


12 


13 
Isar commands may be either \emph{proper} document constructors, or

7175

14 
\emph{improper commands} (indicated by $^*$). Some proof methods and


15 
attributes introduced later may be classified as improper as well. Improper


16 
Isar language elements might be helpful when developing proof documents, while


17 
their use is strongly discouraged for the final version. Typical examples are


18 
diagnostic commands that print terms or theorems according to the current


19 
context; other commands even emulate oldstyle tactical theorem proving, which


20 
facilitates porting of legacy proof scripts.

7167

21 

7134

22 


23 
\section{Theory commands}


24 

7167

25 
\subsection{Defining theories}\label{sec:beginthy}

7134

26 


27 
\indexisarcmd{theory}\indexisarcmd{end}\indexisarcmd{context}


28 
\begin{matharray}{rcl}


29 
\isarcmd{theory} & : & \isartrans{\cdot}{theory} \\


30 
\isarcmd{context}^* & : & \isartrans{\cdot}{theory} \\


31 
\isarcmd{end} & : & \isartrans{theory}{\cdot} \\


32 
\end{matharray}


33 


34 
Isabelle/Isar ``newstyle'' theories are either defined via theory files or

7167

35 
interactively. Both actual theory specifications and proofs are handled

7175

36 
uniformly  occasionally definitional mechanisms even require some manual


37 
proof. In contrast, ``oldstyle'' Isabelle theories support batch processing


38 
only, with the proof scripts collected in separate ML files.

7134

39 


40 
The first command of any theory has to be $\THEORY$, starting a new theory

7175

41 
based on the merge of existing ones. The theory context may be also changed


42 
by $\CONTEXT$ without creating a new theory. In both cases, $\END$ concludes


43 
the theory development; it has to be the very last command of any proper


44 
theory file.

7134

45 


46 
\begin{rail}


47 
'theory' name '=' (name + '+') filespecs? ':'


48 
;


49 
'context' name


50 
;


51 
'end'


52 
;;


53 

7167

54 
filespecs: 'files' ((name  parname) +);

7134

55 
\end{rail}


56 

7167

57 
\begin{descr}

7134

58 
\item [$\THEORY~A = B@1 + \cdots + B@n$] commences a new theory $A$ based on

7175

59 
existing ones $B@1 + \cdots + B@n$. Isabelle's theory loader system ensures


60 
that any of the base theories are properly loaded (and fully uptodate when


61 
$\THEORY$ is executed interactively). The optional $\isarkeyword{files}$


62 
specification declares additional dependencies on ML files. Unless put in


63 
parentheses, any file will be loaded immediately via $\isarcmd{use}$ (see


64 
also \S\ref{sec:ML}).

7134

65 

7167

66 
\item [$\CONTEXT~B$] enters an existing theory context $B$, basically in

7134

67 
readonly mode, so only a limited set of commands may be performed. Just as


68 
for $\THEORY$, the theory loader ensures that $B$ is loaded and uptodate.

7175

69 

7167

70 
\item [$\END$] concludes the current theory definition or context switch.

7175

71 
Note that this command cannot be undone, instead the theory definition


72 
itself has to be retracted.

7167

73 
\end{descr}

7134

74 


75 

7167

76 
\subsection{Formal comments}\label{sec:formalcmtthy}

7134

77 

7167

78 
\indexisarcmd{title}\indexisarcmd{chapter}\indexisarcmd{section}\indexisarcmd{subsection}


79 
\indexisarcmd{subsubsection}\indexisarcmd{text}

7134

80 
\begin{matharray}{rcl}


81 
\isarcmd{title} & : & \isartrans{theory}{theory} \\


82 
\isarcmd{chapter} & : & \isartrans{theory}{theory} \\

7167

83 
\isarcmd{section} & : & \isartrans{theory}{theory} \\

7134

84 
\isarcmd{subsection} & : & \isartrans{theory}{theory} \\


85 
\isarcmd{subsubsection} & : & \isartrans{theory}{theory} \\


86 
\isarcmd{text} & : & \isartrans{theory}{theory} \\


87 
\end{matharray}


88 

7167

89 
There are several commands to include \emph{formal comments} in theory


90 
specification (a few more are available for proofs, see


91 
\S\ref{sec:formalcmtprf}). In contrast to sourcelevel comments

7134

92 
\verb(*\dots\verb*), which are stripped at the lexical level, any text


93 
given as formal comment is meant to be part of the actual document.


94 
Consequently, it would be included in the final printed version.


95 


96 
Apart from plain prose, formal comments may also refer to logical entities of

7175

97 
the theory context (types, terms, theorems etc.). Proper processing of the


98 
text would then include some further consistency checks with the items


99 
declared in the current theory, e.g.\ typechecking of included


100 
terms.\footnote{The current version of Isabelle/Isar does not process formal

7134

101 
comments in any such way. This will be available as part of the automatic

7175

102 
theory and proof document preparation system (using (PDF){\LaTeX}) that is

7134

103 
planned for the near future.}


104 


105 
\begin{rail}


106 
'title' text text? text?


107 
;

7167

108 
('chapter'  'section'  'subsection'  'subsubsection'  'text') text

7134

109 
;


110 
\end{rail}


111 

7167

112 
\begin{descr}

7134

113 
\item [$\isarkeyword{title}~title~author~date$] specifies the document title

7175

114 
just as in typical {\LaTeX} documents.

7167

115 
\item [$\isarkeyword{chapter}~text$, $\isarkeyword{section}~text$,

7175

116 
$\isarkeyword{subsection}~text$, and $\isarkeyword{subsubsection}~text$]

7315

117 
mark chapter and section headings.

7134

118 
\item [$\TEXT~text$] specifies an actual body of prose text, including

7315

119 
references to formal entities.\footnote{The latter feature is not yet


120 
exploited. Nevertheless, any text of the form \texttt{\at\{\dots\}}


121 
should be considered as reserved for future use.}

7167

122 
\end{descr}

7134

123 


124 

7135

125 
\subsection{Type classes and sorts}\label{sec:classes}

7134

126 


127 
\indexisarcmd{classes}\indexisarcmd{classrel}\indexisarcmd{defaultsort}


128 
\begin{matharray}{rcl}


129 
\isarcmd{classes} & : & \isartrans{theory}{theory} \\


130 
\isarcmd{classrel} & : & \isartrans{theory}{theory} \\


131 
\isarcmd{defaultsort} & : & \isartrans{theory}{theory} \\


132 
\end{matharray}


133 


134 
\begin{rail}

7167

135 
'classes' (classdecl comment? +)

7134

136 
;


137 
'classrel' nameref '<' nameref comment?


138 
;


139 
'defaultsort' sort comment?


140 
;


141 
\end{rail}


142 

7167

143 
\begin{descr}

7175

144 
\item [$\isarkeyword{classes}~c<\vec c ~\dots$] declares class $c$ to be a


145 
subclass of existing classes $\vec c$. Cyclic class structures are ruled


146 
out.

7134

147 
\item [$\isarkeyword{classrel}~c@1<c@2$] states a subclass relation between


148 
existing classes $c@1$ and $c@2$. This is done axiomatically! The

7175

149 
$\isarkeyword{instance}$ command (see \S\ref{sec:axclass}) provides a way


150 
introduce proven class relations.

7134

151 
\item [$\isarkeyword{defaultsort}~s$] makes sort $s$ the new default sort for

7175

152 
any type variables input without sort constraints. Usually, the default

7134

153 
sort would be only changed when defining new logics.

7167

154 
\end{descr}

7134

155 


156 

7315

157 
\subsection{Primitive types and type abbreviations}\label{sec:typespure}

7134

158 


159 
\indexisarcmd{typedecl}\indexisarcmd{types}\indexisarcmd{nonterminals}\indexisarcmd{arities}


160 
\begin{matharray}{rcl}


161 
\isarcmd{types} & : & \isartrans{theory}{theory} \\


162 
\isarcmd{typedecl} & : & \isartrans{theory}{theory} \\


163 
\isarcmd{nonterminals} & : & \isartrans{theory}{theory} \\


164 
\isarcmd{arities} & : & \isartrans{theory}{theory} \\


165 
\end{matharray}


166 


167 
\begin{rail}


168 
'types' (typespec '=' type infix? comment? +)


169 
;


170 
'typedecl' typespec infix? comment?


171 
;


172 
'nonterminals' (name +) comment?


173 
;


174 
'arities' (nameref '::' arity comment? +)


175 
;


176 
\end{rail}


177 

7167

178 
\begin{descr}

7134

179 
\item [$\TYPES~(\vec\alpha)t = \tau~\dots$] introduces \emph{type synonym}


180 
$(\vec\alpha)t$ for existing type $\tau$. Unlike actual type definitions,


181 
as are available in Isabelle/HOL for example, type synonyms are just purely


182 
syntactic abbreviations, without any logical significance. Internally, type


183 
synonyms are fully expanded, as may be observed when printing terms or


184 
theorems.


185 
\item [$\isarkeyword{typedecl}~(\vec\alpha)t$] declares a new type constructor


186 
$t$, intended as an actual logical type. Note that some logics such as


187 
Isabelle/HOL provide their own version of $\isarkeyword{typedecl}$.

7175

188 
\item [$\isarkeyword{nonterminals}~\vec c$] declares $0$ary type constructors


189 
$\vec c$ to act as purely syntactic types, i.e.\ nonterminal symbols of


190 
Isabelle's inner syntax of terms or types.

7134

191 
\item [$\isarkeyword{arities}~t::(\vec s)s~\dots$] augments Isabelle's


192 
ordersorted signature of types by new type constructor arities. This is

7175

193 
done axiomatically! The $\isarkeyword{instance}$ command (see


194 
\S\ref{sec:axclass}) provides a way introduce proven type arities.

7167

195 
\end{descr}

7134

196 


197 


198 
\subsection{Constants and simple definitions}


199 

7175

200 
\indexisarcmd{consts}\indexisarcmd{defs}\indexisarcmd{constdefs}\indexoutertoken{constdecl}

7134

201 
\begin{matharray}{rcl}


202 
\isarcmd{consts} & : & \isartrans{theory}{theory} \\


203 
\isarcmd{defs} & : & \isartrans{theory}{theory} \\


204 
\isarcmd{constdefs} & : & \isartrans{theory}{theory} \\


205 
\end{matharray}


206 


207 
\begin{rail}


208 
'consts' (constdecl +)


209 
;


210 
'defs' (thmdecl? prop comment? +)


211 
;


212 
'constdefs' (constdecl prop comment? +)


213 
;


214 


215 
constdecl: name '::' type mixfix? comment?


216 
;


217 
\end{rail}


218 

7167

219 
\begin{descr}

7175

220 
\item [$\CONSTS~c::\sigma~\dots$] declares constant $c$ to have any instance


221 
of type scheme $\sigma$. The optional mixfix annotations may attach


222 
concrete syntax constants.

7134

223 
\item [$\DEFS~name: eqn~\dots$] introduces $eqn$ as a definitional axiom for


224 
some existing constant. See \cite[\S6]{isabelleref} for more details on


225 
the form of equations admitted as constant definitions.

7175

226 
\item [$\isarkeyword{constdefs}~c::\sigma~eqn~\dots$] combines constant

7134

227 
declarations and definitions, using canonical name $c_def$ for the


228 
definitional axiom.

7167

229 
\end{descr}

7134

230 


231 

7167

232 
\subsection{Syntax and translations}

7134

233 


234 
\indexisarcmd{syntax}\indexisarcmd{translations}


235 
\begin{matharray}{rcl}


236 
\isarcmd{syntax} & : & \isartrans{theory}{theory} \\


237 
\isarcmd{translations} & : & \isartrans{theory}{theory} \\


238 
\end{matharray}


239 


240 
\begin{rail}


241 
'syntax' ('(' name 'output'? ')')? (constdecl +)


242 
;


243 
'translations' (transpat ('=='  '=>'  '<=') transpat comment? +)


244 
;


245 
transpat: ('(' nameref ')')? string


246 
;


247 
\end{rail}


248 

7167

249 
\begin{descr}

7175

250 
\item [$\isarkeyword{syntax}~(mode)~decls$] is similar to $\CONSTS~decls$,


251 
except that the actual logical signature extension is omitted. Thus the


252 
context free grammar of Isabelle's inner syntax may be augmented in


253 
arbitrary ways. The $mode$ argument refers to the print mode that the


254 
grammar rules belong; unless there is the \texttt{output} flag given, all


255 
productions are added both to the input and output grammar.


256 
\item [$\isarkeyword{translations}~rules$] specifies syntactic translation


257 
rules (also known as \emph{macros}): parse/print rules (\texttt{==}), parse


258 
rules (\texttt{=>}), print rules (\texttt{<=}). Translation patterns may be

7134

259 
prefixed by the syntactic category to be used for parsing; the default is


260 
\texttt{logic}.

7167

261 
\end{descr}

7134

262 


263 


264 
\subsection{Axioms and theorems}


265 


266 
\indexisarcmd{axioms}\indexisarcmd{theorems}\indexisarcmd{lemmas}


267 
\begin{matharray}{rcl}


268 
\isarcmd{axioms} & : & \isartrans{theory}{theory} \\


269 
\isarcmd{theorems} & : & \isartrans{theory}{theory} \\


270 
\isarcmd{lemmas} & : & \isartrans{theory}{theory} \\


271 
\end{matharray}


272 


273 
\begin{rail}

7135

274 
'axioms' (axmdecl prop comment? +)

7134

275 
;


276 
('theorems'  'lemmas') thmdef? thmrefs


277 
;


278 
\end{rail}


279 

7167

280 
\begin{descr}

7134

281 
\item [$\isarkeyword{axioms}~name: \phi~\dots$] introduces arbitrary


282 
statements as logical axioms. In fact, axioms are ``axiomatic theorems'',

7175

283 
and may be referred just as any other theorem later.

7134

284 


285 
Axioms are usually only introduced when declaring new logical systems.

7175

286 
Everyday work is typically done the hard way, with proper definitions and

7134

287 
actual theorems.


288 
\item [$\isarkeyword{theorems}~name = thms$] stores lists of existing theorems

7175

289 
as $name$. Typical applications would also involve attributes (to augment


290 
the default simpset, for example).

7134

291 
\item [$\isarkeyword{lemmas}$] is similar to $\isarkeyword{theorems}$, but


292 
tags the results as ``lemma''.

7167

293 
\end{descr}

7134

294 


295 

7167

296 
\subsection{Name spaces}

7134

297 

7167

298 
\indexisarcmd{global}\indexisarcmd{local}

7134

299 
\begin{matharray}{rcl}


300 
\isarcmd{global} & : & \isartrans{theory}{theory} \\


301 
\isarcmd{local} & : & \isartrans{theory}{theory} \\


302 
\end{matharray}


303 

7315

304 
Isabelle organises any kind of names (of types, constants, theorems etc.) by

7175

305 
hierarchically structured name spaces. Normally the user never has to control

7315

306 
the behaviour of name space entry by hand, yet the following commands provide

7175

307 
some way to do so.


308 

7167

309 
\begin{descr}


310 
\item [$\isarkeyword{global}$ and $\isarkeyword{local}$] change the current


311 
name declaration mode. Initially, theories start in $\isarkeyword{local}$


312 
mode, causing all names to be automatically qualified by the theory name.


313 
Changing this to $\isarkeyword{global}$ causes all names to be declared as

7175

314 
base names only, until $\isarkeyword{local}$ is declared again.

7167

315 
\end{descr}

7134

316 


317 

7167

318 
\subsection{Incorporating ML code}\label{sec:ML}

7134

319 


320 
\indexisarcmd{use}\indexisarcmd{ML}\indexisarcmd{setup}


321 
\begin{matharray}{rcl}


322 
\isarcmd{use} & : & \isartrans{\cdot}{\cdot} \\


323 
\isarcmd{ML} & : & \isartrans{\cdot}{\cdot} \\

7175

324 
\isarcmd{setup} & : & \isartrans{theory}{theory} \\

7134

325 
\end{matharray}


326 


327 
\begin{rail}


328 
'use' name


329 
;


330 
'ML' text


331 
;


332 
'setup' text


333 
;


334 
\end{rail}


335 

7167

336 
\begin{descr}

7175

337 
\item [$\isarkeyword{use}~file$] reads and executes ML commands from $file$.


338 
The current theory context (if present) is passed down to the ML session.


339 
Furthermore, the file name is checked with the $\isarkeyword{files}$


340 
dependency declaration given in the theory header (see also


341 
\S\ref{sec:beginthy}).


342 
\item [$\isarkeyword{ML}~text$] reads and executes ML commands from $text$.


343 
The theory context is passed just as for $\isarkeyword{use}$.

7167

344 
\item [$\isarkeyword{setup}~text$] changes the current theory context by

7175

345 
applying setup functions $text$, which has to be an ML expression of type


346 
$(theory \to theory)~list$. The $\isarkeyword{setup}$ command is the usual

7315

347 
way to initialise objectlogic specific tools and packages written in ML.

7167

348 
\end{descr}

7134

349 


350 

7167

351 
\subsection{Syntax translation functions}

7134

352 

7167

353 
\indexisarcmd{parseasttranslation}\indexisarcmd{parsetranslation}


354 
\indexisarcmd{printtranslation}\indexisarcmd{typedprinttranslation}


355 
\indexisarcmd{printasttranslation}\indexisarcmd{tokentranslation}

7134

356 
\begin{matharray}{rcl}


357 
\isarcmd{parse_ast_translation} & : & \isartrans{theory}{theory} \\


358 
\isarcmd{parse_translation} & : & \isartrans{theory}{theory} \\


359 
\isarcmd{print_translation} & : & \isartrans{theory}{theory} \\


360 
\isarcmd{typed_print_translation} & : & \isartrans{theory}{theory} \\


361 
\isarcmd{print_ast_translation} & : & \isartrans{theory}{theory} \\


362 
\isarcmd{token_translation} & : & \isartrans{theory}{theory} \\


363 
\end{matharray}


364 


365 
Syntax translation functions written in ML admit almost arbitrary


366 
manipulations of Isabelle's inner syntax. Any of the above commands have a


367 
single \railqtoken{text} argument that refers to an ML expression of


368 
appropriate type. See \cite[\S8]{isabelleref} for more information on syntax


369 
transformations.


370 


371 


372 
\subsection{Oracles}


373 


374 
\indexisarcmd{oracle}


375 
\begin{matharray}{rcl}


376 
\isarcmd{oracle} & : & \isartrans{theory}{theory} \\


377 
\end{matharray}


378 

7175

379 
Oracles provide an interface to external reasoning systems, without giving up


380 
control completely  each theorem carries a derivation object recording any


381 
oracle invocation. See \cite[\S6]{isabelleref} for more information.


382 

7134

383 
\begin{rail}


384 
'oracle' name '=' text comment?


385 
;


386 
\end{rail}


387 

7167

388 
\begin{descr}

7175

389 
\item [$\isarkeyword{oracle}~name=text$] declares oracle $name$ to be ML

7315

390 
function $text$, which has to be of type $Sign\mathord.sg \times


391 
Object\mathord.T \to term)$.

7167

392 
\end{descr}

7134

393 


394 


395 
\section{Proof commands}


396 

7315

397 
Proof commands provide transitions of Isar/VM machine configurations, which


398 
are blockstructured, consisting of a stack of nodes with three main


399 
components: logical \emph{proof context}, local \emph{facts}, and open


400 
\emph{goals}. Isar/VM transitions are \emph{typed} according to the following


401 
three three different modes of operation:

7167

402 
\begin{descr}


403 
\item [$proof(prove)$] means that a new goal has just been stated that is now


404 
to be \emph{proven}; the next command may refine it by some proof method

7175

405 
($\approx$ tactic), and enter a subproof to establish the final result.

7167

406 
\item [$proof(state)$] is like an internal theory mode: the context may be

7175

407 
augmented by \emph{stating} additional assumptions, intermediate result etc.


408 
\item [$proof(chain)$] is an intermediate mode between $proof(state)$ and

7315

409 
$proof(prove)$: existing facts have been just picked up in order to use them


410 
when refining the goal to be claimed next.

7167

411 
\end{descr}

7134

412 

7167

413 


414 
\subsection{Formal comments}\label{sec:formalcmtprf}


415 


416 
\indexisarcmd{sect}\indexisarcmd{subsect}\indexisarcmd{subsect}\indexisarcmd{txt}

7134

417 
\begin{matharray}{rcl}

7167

418 
\isarcmd{sect} & : & \isartrans{proof(state)}{proof(state)} \\


419 
\isarcmd{subsect} & : & \isartrans{proof(state)}{proof(state)} \\


420 
\isarcmd{subsubsect} & : & \isartrans{proof(state)}{proof(state)} \\


421 
\isarcmd{txt} & : & \isartrans{proof(state)}{proof(state)} \\

7134

422 
\end{matharray}


423 

7175

424 
These formal comments in proof mode closely correspond to the ones of theory


425 
mode (see \S\ref{sec:formalcmtthy}).


426 

7134

427 
\begin{rail}

7167

428 
('sect'  'subsect'  'subsubsect'  'txt') text

7134

429 
;


430 
\end{rail}


431 


432 

7315

433 
\subsection{Proof context}\label{sec:proofcontext}

7134

434 

7315

435 
\indexisarcmd{fix}\indexisarcmd{assume}\indexisarcmd{presume}\indexisarcmd{def}

7134

436 
\begin{matharray}{rcl}


437 
\isarcmd{fix} & : & \isartrans{proof(state)}{proof(state)} \\


438 
\isarcmd{assume} & : & \isartrans{proof(state)}{proof(state)} \\


439 
\isarcmd{presume} & : & \isartrans{proof(state)}{proof(state)} \\


440 
\isarcmd{def} & : & \isartrans{proof(state)}{proof(state)} \\


441 
\end{matharray}


442 

7315

443 
The logical proof context consists of fixed variables and assumptions. The


444 
former closely correspond to Skolem constants, or metalevel universal


445 
quantification as provided by the Isabelle/Pure logical framework.


446 
Introducing some \emph{arbitrary, but fixed} variable via $\FIX x$ results in


447 
a local entity that may be used in the subsequent proof as any other variable


448 
or constant. Furthermore, any result $\phi[x]$ exported from the current


449 
context will be universally closed wrt.\ $x$ at the outermost level (this is


450 
expressed using Isabelle's metavariables).


451 


452 
Similarly, introducing some assumption $\chi$ has two effects. On the one


453 
hand, a local theorem is created that may be used as a fact in subsequent


454 
proof steps. On the other hand, any result $\phi$ exported from the context


455 
becomes conditional wrt.\ the assumption. Thus, solving an enclosing goal


456 
using this result would basically introduce a new subgoal stemming from the


457 
assumption. How this situation is handled depends on the actual version of


458 
assumption command used: while $\ASSUMENAME$ solves the subgoal by unifying


459 
with some premise of the goal, $\PRESUMENAME$ leaves the subgoal unchanged to


460 
be proved later by the user.


461 


462 
Local definitions, introduced by $\DEF{a}{x \equiv t}$, are achieved by


463 
combining $\FIX x$ with another version of assumption that causes any


464 
hypothetical equation $x = t$ to be eliminated by reflexivity. Thus,


465 
exporting some result $\phi[x]$ simply yields $\phi[t]$.

7175

466 

7134

467 
\begin{rail}


468 
'fix' (var +) comment?


469 
;

7315

470 
('assume'  'presume') (assm comment? + 'and')

7134

471 
;

7175

472 
'def' thmdecl? \\ var '==' term termpat? comment?

7134

473 
;


474 


475 
var: name ('::' type)?


476 
;

7315

477 
assm: thmdecl? (prop proppat? +)


478 
;

7134

479 
\end{rail}


480 

7167

481 
\begin{descr}

7315

482 
\item [$\FIX{x}$] introduces a local \emph{arbitrary, but fixed} variable $x$.


483 
\item [$\ASSUME{a}{\Phi}$ and $\PRESUME{a}{\Phi}$] introduce local theorems


484 
$\Phi$. Subsequent results used to solve some enclosing goal (e.g.\ via


485 
$\SHOWNAME$) are handled as follows: $\ASSUMENAME$ expects to be able to


486 
unify with existing premises in the goal, while $\PRESUMENAME$ leaves $\Phi$


487 
as new subgoals. Note that several lists of assumptions may be given


488 
(separated by \railterm{and}); the resulting list of current facts consists


489 
of all of these.


490 
\item [$\DEF{a}{x \equiv t}$] introduces a local (nonpolymorphic) definition.


491 
In results exported from the context, $x$ is replaced by $t$. Basically,


492 
$\DEF{}{x \equiv t}$ abbreviates $\FIX{x}~\PRESUME{}{x \equiv t}$ (the


493 
resulting hypothetical equation is solved by reflexivity, though).

7167

494 
\end{descr}


495 

7315

496 
The internal register $prems$\indexisarreg{prems} refers to all current


497 
assumptions as a list of theorems.


498 

7167

499 


500 
\subsection{Facts and forward chaining}


501 


502 
\indexisarcmd{note}\indexisarcmd{then}\indexisarcmd{from}\indexisarcmd{with}


503 
\begin{matharray}{rcl}


504 
\isarcmd{note} & : & \isartrans{proof(state)}{proof(state)} \\


505 
\isarcmd{then} & : & \isartrans{proof(state)}{proof(chain)} \\


506 
\isarcmd{from} & : & \isartrans{proof(state)}{proof(chain)} \\


507 
\isarcmd{with} & : & \isartrans{proof(state)}{proof(chain)} \\


508 
\end{matharray}


509 

7315

510 
New facts are established either by assumption or proof of local statements


511 
(via $\HAVENAME$ or $\SHOWNAME$). Any facts will usually be involved in


512 
proofs of further results: either as explicit arguments of proof methods or


513 
when forward chaining towards the next goal via $\THEN$ (and variants).

7175

514 

7167

515 
\begin{rail}


516 
'note' thmdef? thmrefs comment?


517 
;


518 
'then' comment?


519 
;


520 
('from'  'with') thmrefs comment?


521 
;


522 
\end{rail}


523 


524 
\begin{descr}

7175

525 
\item [$\NOTE{a}{\vec b}$] recalls existing facts $\vec b$, binding the result


526 
as $a$. Note that attributes may be involved as well, both on the left and


527 
right hand sides.

7167

528 
\item [$\THEN$] indicates forward chaining by the current facts in order to

7175

529 
establish the goal to be claimed next. The initial proof method invoked to


530 
solve that will be offered these facts to do ``anything appropriate'' (see


531 
also \S\ref{sec:proofsteps}). For example, method $rule$ (see

7167

532 
\S\ref{sec:puremeth}) would do an elimination rather than an introduction.

7175

533 
\item [$\FROM{\vec b}$] abbreviates $\NOTE{}{\vec b}~\THEN$; also note that

7167

534 
$\THEN$ is equivalent to $\FROM{facts}$.

7175

535 
\item [$\WITH{\vec b}$] abbreviates $\FROM{\vec b~facts}$; thus the forward


536 
chaining is from earlier facts together with the current ones.

7167

537 
\end{descr}


538 

7315

539 
Note that the internal register of \emph{current facts} may be referred as


540 
theorem list $facts$.\indexisarreg{facts}


541 

7167

542 


543 
\subsection{Goal statements}


544 


545 
\indexisarcmd{theorem}\indexisarcmd{lemma}


546 
\indexisarcmd{have}\indexisarcmd{show}\indexisarcmd{hence}\indexisarcmd{thus}


547 
\begin{matharray}{rcl}


548 
\isarcmd{theorem} & : & \isartrans{theory}{proof(prove)} \\


549 
\isarcmd{lemma} & : & \isartrans{theory}{proof(prove)} \\


550 
\isarcmd{have} & : & \isartrans{proof(state)}{proof(prove)} \\


551 
\isarcmd{show} & : & \isartrans{proof(state)}{proof(prove)} \\


552 
\isarcmd{hence} & : & \isartrans{proof(state)}{proof(prove)} \\


553 
\isarcmd{thus} & : & \isartrans{proof(state)}{proof(prove)} \\


554 
\end{matharray}


555 

7175

556 
Proof mode is entered from theory mode by initial goal commands $\THEOREMNAME$


557 
and $\LEMMANAME$. New local goals may be claimed within proof mode: four


558 
variants are available, indicating whether the result is meant to solve some


559 
pending goal and whether forward chaining is employed.


560 

7167

561 
\begin{rail}


562 
('theorem'  'lemma') goal


563 
;


564 
('have'  'show'  'hence'  'thus') goal


565 
;


566 


567 
goal: thmdecl? proppat comment?


568 
;


569 
\end{rail}


570 


571 
\begin{descr}


572 
\item [$\THEOREM{name}{\phi}$] enters proof mode with $\phi$ as main goal,

7175

573 
eventually resulting in some theorem $\turn \phi$, which will be stored in


574 
the theory.

7167

575 
\item [$\LEMMANAME$] is similar to $\THEOREMNAME$, but tags the result as


576 
``lemma''.


577 
\item [$\HAVE{name}{\phi}$] claims a local goal, eventually resulting in a


578 
theorem with the current assumption context as hypotheses.

7175

579 
\item [$\SHOW{name}{\phi}$] is similar to $\HAVE{name}{\phi}$, but solves some


580 
pending goal with the result \emph{exported} into the corresponding context.

7167

581 
\item [$\HENCE{name}{\phi}$] abbreviates $\THEN~\HAVE{name}{\phi}$, i.e.\


582 
claims a local goal to be proven by forward chaining the current facts.


583 
\item [$\THUS{name}{\phi}$] abbreviates $\THEN~\SHOW{name}{\phi}$.


584 
\end{descr}


585 


586 


587 
\subsection{Initial and terminal proof steps}\label{sec:proofsteps}


588 

7175

589 
\indexisarcmd{proof}\indexisarcmd{qed}\indexisarcmd{by}


590 
\indexisarcmd{.}\indexisarcmd{..}\indexisarcmd{sorry}


591 
\begin{matharray}{rcl}


592 
\isarcmd{proof} & : & \isartrans{proof(prove)}{proof(state)} \\


593 
\isarcmd{qed} & : & \isartrans{proof(state)}{proof(state) ~~ theory} \\


594 
\isarcmd{by} & : & \isartrans{proof(prove)}{proof(state) ~~ theory} \\


595 
\isarcmd{.\,.} & : & \isartrans{proof(prove)}{proof(state) ~~ theory} \\


596 
\isarcmd{.} & : & \isartrans{proof(prove)}{proof(state) ~~ theory} \\


597 
\isarcmd{sorry} & : & \isartrans{proof(prove)}{proof(state) ~~ theory} \\


598 
\end{matharray}


599 

7167

600 
Arbitrary goal refinements via tactics is considered harmful. Consequently


601 
the Isar framework admits proof methods to be invoked in two places only.


602 
\begin{enumerate}

7175

603 
\item An \emph{initial} refinement step $\PROOF{m@1}$ reduces a newly stated


604 
intermediate goal to a number of subgoals that are to be solved later.


605 
Facts are passed to $m@1$ for forward chaining if so indicated by


606 
$proof(chain)$ mode.

7167

607 

7175

608 
\item A \emph{terminal} conclusion step $\QED{m@2}$ solves any remaining

7167

609 
pending goals completely. No facts are passed to $m@2$.


610 
\end{enumerate}


611 


612 
The only other proper way to affect pending goals is by $\SHOWNAME$, which


613 
involves an explicit statement of what is solved.


614 

7175

615 
\medskip


616 

7167

617 
Also note that initial proof methods should either solve the goal completely,


618 
or constitute some wellunderstood deterministic reduction to new subgoals.


619 
Arbitrary automatic proof tools that are prone leave a large number of badly


620 
structured subgoals are no help in continuing the proof document in any

7175

621 
intelligible way. A much better technique would be to $\SHOWNAME$ some


622 
nontrivial reduction as an explicit rule, which is solved completely by some


623 
automated method, and then applied to some pending goal.

7167

624 

7175

625 
\medskip


626 


627 
Unless given explicitly by the user, the default initial method is


628 
``$default$'', which is usually set up to apply a single standard elimination


629 
or introduction rule according to the topmost symbol involved. The default


630 
terminal method is ``$finish$''; it solves all goals by assumption.

7167

631 


632 
\begin{rail}


633 
'proof' interest? meth? comment?


634 
;


635 
'qed' meth? comment?


636 
;


637 
'by' meth meth? comment?


638 
;


639 
('.'  '..'  'sorry') comment?


640 
;


641 


642 
meth: method interest?


643 
;


644 
\end{rail}


645 


646 
\begin{descr}

7175

647 
\item [$\PROOF{m@1}$] refines the pending goal by proof method $m@1$; facts


648 
for forward chaining are passed if so indicated by $proof(chain)$.


649 
\item [$\QED{m@2}$] refines any remaining goals by proof method $m@1$ and

7167

650 
concludes the subproof. If the goal had been $\SHOWNAME$, some pending


651 
subgoal is solved as well by the rule resulting from the result exported to

7175

652 
the enclosing goal context. Thus $\QEDNAME$ may fail for two reasons:


653 
either $m@2$ fails to solve all remaining goals completely, or the resulting


654 
rule does not resolve with any enclosing goal. Debugging such a situation


655 
might involve temporarily changing $\SHOWNAME$ into $\HAVENAME$, or


656 
weakening the local context by replacing $\ASSUMENAME$ by $\PRESUMENAME$.


657 
\item [$\BYY{m@1}{m@2}$] is a \emph{terminal proof}; it abbreviates


658 
$\PROOF{m@1}~\QED{m@2}$, with automatic backtracking across both methods.


659 
Debugging an unsuccessful $\BYY{m@1}{m@2}$ commands might be done by simply


660 
expanding the abbreviation by hand; note that $\PROOF{m@1}$ is usually


661 
sufficient to see what is going wrong.


662 
\item [$\DDOT$] is a \emph{default proof}; it abbreviates $\BY{default}$.


663 
\item [$\DOT$] is a \emph{trivial proof}, it abbreviates $\BY{}$, where


664 
method ``$$'' does nothing except inserting any facts into the proof state.

7167

665 
\item [$\isarkeyword{sorry}$] is a \emph{fake proof}; provided that


666 
\texttt{quick_and_dirty} is enabled, $\isarkeyword{sorry}$ pretends to solve


667 
the goal without much ado. Of course, the result is a fake theorem only,

7175

668 
involving some oracle in its internal derivation object (this is indicated


669 
as $[!]$ in the printed result. The main application of

7167

670 
$\isarkeyword{sorry}$ is to support topdown proof development.


671 
\end{descr}

7134

672 


673 

7315

674 
\subsection{Improper proof steps}


675 


676 
The following commands emulate unstructured tactic scripts to some extent.


677 
While these are anathema for writing proper Isar proof documents, they might


678 
come in handy for exploring and debugging.


679 


680 
\indexisarcmd{apply}\indexisarcmd{thenapply}\indexisarcmd{back}


681 
\begin{matharray}{rcl}


682 
\isarcmd{apply}^* & : & \isartrans{proof}{proof} \\


683 
\isarcmd{then_apply}^* & : & \isartrans{proof}{proof} \\


684 
\isarcmd{back}^* & : & \isartrans{proof}{proof} \\


685 
\end{matharray}


686 


687 
\railalias{thenapply}{then\_apply}


688 
\railterm{thenapply}


689 


690 
\begin{rail}


691 
'apply' method


692 
;


693 
thenapply method


694 
;


695 
'back'


696 
;


697 
\end{rail}


698 


699 
\begin{descr}


700 
\item [$\isarkeyword{apply}~m$] applies proof method $m$ in the


701 
plainoldtactic sense. Facts for forward chaining are ignored.


702 
\item [$\isarkeyword{then_apply}~m$] is similar to $\isarkeyword{apply}$, but


703 
observes the goal's facts.


704 
\item [$\isarkeyword{back}$] does backtracking over the result sequence of


705 
the last proof command. Basically, any proof command may return multiple


706 
results.


707 
\end{descr}


708 


709 


710 
\subsection{Term abbreviations}\label{sec:termabbrev}


711 


712 
\indexisarcmd{let}


713 
\begin{matharray}{rcl}


714 
\isarcmd{let} & : & \isartrans{proof(state)}{proof(state)} \\


715 
\isarkeyword{is} & : & syntax \\


716 
\end{matharray}


717 


718 
Abbreviations may be either bound by explicit $\LET{p \equiv t}$ statements,


719 
or by annotating assumptions or goal statements ($\ASSUMENAME$, $\SHOWNAME$


720 
etc.) with a list of patterns $\IS{p@1 \dots p@n}$. In both cases,


721 
higherorder matching is applied to bind extralogical text


722 
variables\index{text variables}, which may be either of the form $\VVar{x}$


723 
(token class \railtoken{textvar}, see \S\ref{sec:lexsyntax}) or nameless


724 
dummies ``\verb,_,'' (underscore).\index{dummy variables} Note that in the


725 
$\LETNAME$ form the patterns occur on the lefthand side, while the $\ISNAME$


726 
patterns are in postfix position.


727 


728 
Note that term abbreviations are quite different from actual local definitions


729 
as introduced via $\DEFNAME$ (see \S\ref{sec:proofcontext}). The latter are


730 
visible within the logic as actual equations, while abbreviations disappear


731 
during the input process just after type checking.


732 


733 
\begin{rail}


734 
'let' ((term + 'as') '=' term comment? + 'and')


735 
;


736 
\end{rail}


737 


738 
The syntax of $\ISNAME$ patterns follows \railnonterm{termpat} or


739 
\railnonterm{proppat} (see \S\ref{sec:termpats}).


740 


741 
\begin{descr}


742 
\item [$\LET{\vec p = \vec t}$] binds any text variables in patters $\vec p$


743 
by simultaneous higherorder matching against terms $\vec t$.


744 
\item [$\IS{\vec p}$] resembles $\LETNAME$, but matches $\vec p$ against the


745 
preceding statement. Also note that $\ISNAME$ is not a separate command,


746 
but part of others (such as $\ASSUMENAME$, $\HAVENAME$ etc.).


747 
\end{descr}


748 


749 
Furthermore, a few automatic term abbreviations\index{automatic abbreviation}


750 
for goals and facts are available. For any open goal, $\VVar{thesis}$ refers


751 
to its objectlogic statement, $\VVar{thesis_prop}$ to the full proposition


752 
(which may be a rule), and $\VVar{thesis_concl}$ to its (atomic) conclusion.


753 


754 
Facts (i.e.\ assumptions and finished goals) that have an application $f(x)$


755 
as objectlogic statement get $x$ bound to the special text variable


756 
``$\dots$'' (three dots). The canonical application of this feature are


757 
calculational proofs, see \S\ref{sec:calculation}.


758 


759 

7134

760 
\subsection{Block structure}


761 

7167

762 
While Isar is inherently blockstructured, opening and closing blocks is


763 
mostly handled rather casually, with little explicit userintervention. Any


764 
local goal statement automatically opens \emph{two} blocks, which are closed


765 
again when concluding the subproof (by $\QEDNAME$ etc.). Sections of


766 
different context within a subproof are typically switched via


767 
$\isarkeyword{next}$, which is just a single blockclose followed by


768 
blockopen again. Thus the effect of $\isarkeyword{next}$ is to reset the


769 
proof context to that of the head of the subproof. Note that there is no

7175

770 
goal focus involved here!

7167

771 

7175

772 
For slightly more advanced applications, there are explicit block parentheses


773 
as well. These typically achieve a strong forward style of reasoning.

7167

774 

7134

775 
\indexisarcmd{next}\indexisarcmd{\{\{}\indexisarcmd{\}\}}


776 
\begin{matharray}{rcl}


777 
\isarcmd{next} & : & \isartrans{proof(state)}{proof(state)} \\


778 
\isarcmd{\{\{} & : & \isartrans{proof(state)}{proof(state)} \\


779 
\isarcmd{\}\}} & : & \isartrans{proof(state)}{proof(state)} \\


780 
\end{matharray}


781 

7167

782 
\begin{descr}


783 
\item [$\isarkeyword{next}$] switches to a fresh block within a subproof,


784 
resetting the context to the initial one.


785 
\item [$\isarkeyword{\{\{}$ and $\isarkeyword{\}\}}$] explicitly open and


786 
close blocks. Any current facts pass through $\isarkeyword{\{\{}$


787 
unchanged, while $\isarkeyword{\}\}}$ causes them to be \emph{exported} into

7315

788 
the enclosing context. Thus fixed variables are generalised, assumptions

7167

789 
discharged, and local definitions eliminated.


790 
\end{descr}

7134

791 


792 


793 
\section{Other commands}


794 

7315

795 
The following commands are not part of the actual proper or improper


796 
Isabelle/Isar syntax, but assist interactive development, for example. Also


797 
note that $undo$ does not apply here, since the theory or proof configuration


798 
is not changed.


799 

7134

800 
\subsection{Diagnostics}


801 


802 
\indexisarcmd{typ}\indexisarcmd{term}\indexisarcmd{prop}\indexisarcmd{thm}


803 
\begin{matharray}{rcl}


804 
\isarcmd{typ} & : & \isarkeep{theory~~proof} \\


805 
\isarcmd{term} & : & \isarkeep{theory~~proof} \\


806 
\isarcmd{prop} & : & \isarkeep{theory~~proof} \\


807 
\isarcmd{thm} & : & \isarkeep{theory~~proof} \\


808 
\end{matharray}


809 


810 
\begin{rail}


811 
'typ' type


812 
;


813 
'term' term


814 
;


815 
'prop' prop


816 
;


817 
'thm' thmrefs


818 
;


819 
\end{rail}


820 

7167

821 
\begin{descr}

7134

822 
\item [$\isarkeyword{typ}~\tau$, $\isarkeyword{term}~t$,


823 
$\isarkeyword{prop}~\phi$] read and print types / terms / propositions


824 
according to the current theory or proof context.


825 
\item [$\isarkeyword{thm}~thms$] retrieves lists of theorems from the current


826 
theory or proof context. Note that any attributes included in the theorem

7175

827 
specifications are applied to a temporary context derived from the current


828 
theory or proof; the result is discarded.

7167

829 
\end{descr}

7134

830 


831 


832 
\subsection{System operations}


833 

7167

834 
\indexisarcmd{cd}\indexisarcmd{pwd}\indexisarcmd{usethy}\indexisarcmd{usethyonly}


835 
\indexisarcmd{updatethy}\indexisarcmd{updatethyonly}

7134

836 
\begin{matharray}{rcl}


837 
\isarcmd{cd} & : & \isarkeep{\cdot} \\


838 
\isarcmd{pwd} & : & \isarkeep{\cdot} \\


839 
\isarcmd{use_thy} & : & \isarkeep{\cdot} \\


840 
\isarcmd{use_thy_only} & : & \isarkeep{\cdot} \\


841 
\isarcmd{update_thy} & : & \isarkeep{\cdot} \\


842 
\isarcmd{update_thy_only} & : & \isarkeep{\cdot} \\


843 
\end{matharray}


844 

7167

845 
\begin{descr}

7134

846 
\item [$\isarkeyword{cd}~name$] changes the current directory of the Isabelle


847 
process.


848 
\item [$\isarkeyword{pwd}~$] prints the current working directory.

7175

849 
\item [$\isarkeyword{use_thy}$, $\isarkeyword{use_thy_only}$,


850 
$\isarkeyword{update_thy}$, and $\isarkeyword{update_thy_only}$] load some


851 
theory given as $name$ argument. These commands are exactly the same as the


852 
corresponding ML functions (see also \cite[\S1 and \S6]{isabelleref}).


853 
Note that both the ML and Isar versions of these commands may load new and


854 
oldstyle theories alike.

7167

855 
\end{descr}

7134

856 


857 

7046

858 
%%% Local Variables:


859 
%%% mode: latex


860 
%%% TeXmaster: "isarref"


861 
%%% End:
