author  wenzelm 
Thu, 07 Dec 2000 17:09:15 +0100  
changeset 10627  dc3eff1b7556 
parent 10548  e8c774c12105 
child 10741  e56ac1863f2c 
permissions  rwrr 
7135  1 

7167  2 
\chapter{Generic Tools and Packages}\label{ch:gentools} 
3 

8517  4 
\section{Axiomatic Type Classes}\label{sec:axclass} 
7167  5 

8904  6 
%FIXME 
7 
%  qualified names 

8 
%  class intro rules; 

9 
%  class axioms; 

10 

8517  11 
\indexisarcmd{axclass}\indexisarcmd{instance}\indexisarmeth{introclasses} 
7167  12 
\begin{matharray}{rcl} 
8517  13 
\isarcmd{axclass} & : & \isartrans{theory}{theory} \\ 
14 
\isarcmd{instance} & : & \isartrans{theory}{proof(prove)} \\ 

15 
intro_classes & : & \isarmeth \\ 

7167  16 
\end{matharray} 
17 

8517  18 
Axiomatic type classes are provided by Isabelle/Pure as a \emph{definitional} 
19 
interface to type classes (cf.~\S\ref{sec:classes}). Thus any object logic 

8547  20 
may make use of this lightweight mechanism of abstract theories 
8901  21 
\cite{Wenzel:1997:TPHOL}. There is also a tutorial on using axiomatic type 
22 
classes in isabelle \cite{isabelleaxclass} that is part of the standard 

23 
Isabelle documentation. 

8517  24 

7167  25 
\begin{rail} 
8517  26 
'axclass' classdecl (axmdecl prop comment? +) 
27 
; 

28 
'instance' (nameref '<' nameref  nameref '::' simplearity) comment? 

7167  29 
; 
30 
\end{rail} 

31 

32 
\begin{descr} 

10223  33 
\item [$\AXCLASS~c < \vec c~axms$] defines an axiomatic type class as the 
34 
intersection of existing classes, with additional axioms holding. Class 

35 
axioms may not contain more than one type variable. The class axioms (with 

36 
implicit sort constraints added) are bound to the given names. Furthermore 

37 
a class introduction rule is generated, which is employed by method 

38 
$intro_classes$ to support instantiation proofs of this class. 

39 

40 
\item [$\INSTANCE~c@1 < c@2$ and $\INSTANCE~t :: (\vec s)c$] setup a goal 

41 
stating a class relation or type arity. The proof would usually proceed by 

42 
$intro_classes$, and then establish the characteristic theorems of the type 

43 
classes involved. After finishing the proof, the theory will be augmented 

44 
by a type signature declaration corresponding to the resulting theorem. 

8517  45 
\item [$intro_classes$] repeatedly expands all class introduction rules of 
46 
this theory. 

7167  47 
\end{descr} 
48 

7315  49 

50 
\section{Calculational proof}\label{sec:calculation} 

51 

8619  52 
\indexisarcmd{also}\indexisarcmd{finally} 
53 
\indexisarcmd{moreover}\indexisarcmd{ultimately} 

9606  54 
\indexisarcmd{printtransrules}\indexisaratt{trans} 
7315  55 
\begin{matharray}{rcl} 
56 
\isarcmd{also} & : & \isartrans{proof(state)}{proof(state)} \\ 

57 
\isarcmd{finally} & : & \isartrans{proof(state)}{proof(chain)} \\ 

8619  58 
\isarcmd{moreover} & : & \isartrans{proof(state)}{proof(state)} \\ 
59 
\isarcmd{ultimately} & : & \isartrans{proof(state)}{proof(chain)} \\ 

10154  60 
\isarcmd{print_trans_rules}^* & : & \isarkeep{theory~~proof} \\ 
7315  61 
trans & : & \isaratt \\ 
62 
\end{matharray} 

63 

64 
Calculational proof is forward reasoning with implicit application of 

65 
transitivity rules (such those of $=$, $\le$, $<$). Isabelle/Isar maintains 

7391  66 
an auxiliary register $calculation$\indexisarthm{calculation} for accumulating 
7897  67 
results obtained by transitivity composed with the current result. Command 
68 
$\ALSO$ updates $calculation$ involving $this$, while $\FINALLY$ exhibits the 

69 
final $calculation$ by forward chaining towards the next goal statement. Both 

70 
commands require valid current facts, i.e.\ may occur only after commands that 

71 
produce theorems such as $\ASSUMENAME$, $\NOTENAME$, or some finished proof of 

8619  72 
$\HAVENAME$, $\SHOWNAME$ etc. The $\MOREOVER$ and $\ULTIMATELY$ commands are 
73 
similar to $\ALSO$ and $\FINALLY$, but only collect further results in 

74 
$calculation$ without applying any rules yet. 

7315  75 

76 
Also note that the automatic term abbreviation ``$\dots$'' has its canonical 

8619  77 
application with calculational proofs. It refers to the argument\footnote{The 
78 
argument of a curried infix expression is its righthand side.} of the 

79 
preceding statement. 

7315  80 

81 
Isabelle/Isar calculations are implicitly subject to block structure in the 

82 
sense that new threads of calculational reasoning are commenced for any new 

83 
block (as opened by a local goal, for example). This means that, apart from 

84 
being able to nest calculations, there is no separate \emph{begincalculation} 

85 
command required. 

86 

8619  87 
\medskip 
88 

89 
The Isar calculation proof commands may be defined as 

90 
follows:\footnote{Internal bookkeeping such as proper handling of 

91 
blockstructure has been suppressed.} 

92 
\begin{matharray}{rcl} 

93 
\ALSO@0 & \equiv & \NOTE{calculation}{this} \\ 

9606  94 
\ALSO@{n+1} & \equiv & \NOTE{calculation}{trans~[OF~calculation~this]} \\[0.5ex] 
8619  95 
\FINALLY & \equiv & \ALSO~\FROM{calculation} \\ 
96 
\MOREOVER & \equiv & \NOTE{calculation}{calculation~this} \\ 

97 
\ULTIMATELY & \equiv & \MOREOVER~\FROM{calculation} \\ 

98 
\end{matharray} 

99 

7315  100 
\begin{rail} 
101 
('also'  'finally') transrules? comment? 

102 
; 

8619  103 
('moreover'  'ultimately') comment? 
104 
; 

8507  105 
'trans' (()  'add'  'del') 
7315  106 
; 
107 

108 
transrules: '(' thmrefs ')' interest? 

109 
; 

110 
\end{rail} 

111 

112 
\begin{descr} 

8547  113 
\item [$\ALSO~(\vec a)$] maintains the auxiliary $calculation$ register as 
7315  114 
follows. The first occurrence of $\ALSO$ in some calculational thread 
7905  115 
initializes $calculation$ by $this$. Any subsequent $\ALSO$ on the same 
7335  116 
level of blockstructure updates $calculation$ by some transitivity rule 
7458  117 
applied to $calculation$ and $this$ (in that order). Transitivity rules are 
8547  118 
picked from the current context plus those given as explicit arguments (the 
119 
latter have precedence). 

9614  120 

8547  121 
\item [$\FINALLY~(\vec a)$] maintaining $calculation$ in the same way as 
7315  122 
$\ALSO$, and concludes the current calculational thread. The final result 
123 
is exhibited as fact for forward chaining towards the next goal. Basically, 

7987  124 
$\FINALLY$ just abbreviates $\ALSO~\FROM{calculation}$. Note that 
125 
``$\FINALLY~\SHOW{}{\Var{thesis}}~\DOT$'' and 

126 
``$\FINALLY~\HAVE{}{\phi}~\DOT$'' are typical idioms for concluding 

127 
calculational proofs. 

9614  128 

8619  129 
\item [$\MOREOVER$ and $\ULTIMATELY$] are analogous to $\ALSO$ and $\FINALLY$, 
130 
but collect results only, without applying rules. 

9614  131 

9606  132 
\item [$\isarkeyword{print_trans_rules}$] prints the list of transitivity 
133 
rules declared in the current context. 

9614  134 

8547  135 
\item [$trans$] declares theorems as transitivity rules. 
9614  136 

7315  137 
\end{descr} 
138 

139 

8483  140 
\section{Named local contexts (cases)}\label{sec:cases} 
141 

142 
\indexisarcmd{case}\indexisarcmd{printcases} 

10548  143 
\indexisaratt{casenames}\indexisaratt{params}\indexisaratt{consumes} 
8483  144 
\begin{matharray}{rcl} 
145 
\isarcmd{case} & : & \isartrans{proof(state)}{proof(state)} \\ 

8517  146 
\isarcmd{print_cases}^* & : & \isarkeep{proof} \\ 
8483  147 
case_names & : & \isaratt \\ 
148 
params & : & \isaratt \\ 

10548  149 
consumes & : & \isaratt \\ 
8483  150 
\end{matharray} 
151 

152 
Basically, Isar proof contexts are built up explicitly using commands like 

153 
$\FIXNAME$, $\ASSUMENAME$ etc.\ (see \S\ref{sec:proofcontext}). In typical 

154 
verification tasks this can become hard to manage, though. In particular, a 

155 
large number of local contexts may emerge from case analysis or induction over 

156 
inductive sets and types. 

157 

158 
\medskip 

159 

160 
The $\CASENAME$ command provides a shorthand to refer to certain parts of 

161 
logical context symbolically. Proof methods may provide an environment of 

8507  162 
named ``cases'' of the form $c\colon \vec x, \vec \phi$. Then the effect of 
163 
$\CASE{c}$ is exactly the same as $\FIX{\vec x}~\ASSUME{c}{\vec\phi}$. 

8483  164 

165 
It is important to note that $\CASENAME$ does \emph{not} provide any means to 

166 
peek at the current goal state, which is treated as strictly nonobservable in 

167 
Isar! Instead, the cases considered here usually emerge in a canonical way 

168 
from certain pieces of specification that appear in the theory somewhere else 

169 
(e.g.\ in an inductive definition, or recursive function). See also 

170 
\S\ref{sec:inductmethod} for more details of how this works in HOL. 

171 

172 
\medskip 

173 

174 
Named cases may be exhibited in the current proof context only if both the 

8547  175 
proof method and the rules involved support this. Case names and parameters 
176 
of basic rules may be declared by hand as well, by using appropriate 

177 
attributes. Thus variant versions of rules that have been derived manually 

178 
may be used in advanced case analysis later. 

8483  179 

180 
\railalias{casenames}{case\_names} 

181 
\railterm{casenames} 

182 

183 
\begin{rail} 

184 
'case' nameref attributes? 

185 
; 

186 
casenames (name + ) 

187 
; 

188 
'params' ((name * ) + 'and') 

189 
; 

10548  190 
'consumes' nat? 
191 
; 

8483  192 
\end{rail} 
8547  193 
%FIXME bug in rail 
8483  194 

195 
\begin{descr} 

8507  196 
\item [$\CASE{c}$] invokes a named local context $c\colon \vec x, \vec \phi$, 
8547  197 
as provided by an appropriate proof method (such as $cases$ and $induct$ in 
198 
Isabelle/HOL, see \S\ref{sec:inductmethod}). The command $\CASE{c}$ 

199 
abbreviates $\FIX{\vec x}~\ASSUME{c}{\vec\phi}$. 

8483  200 
\item [$\isarkeyword{print_cases}$] prints all local contexts of the current 
8547  201 
state, using Isar proof language notation. This is a diagnostic command; 
202 
$undo$ does not apply. 

8483  203 
\item [$case_names~\vec c$] declares names for the local contexts of premises 
10627  204 
of some theorem; $\vec c$ refers to the \emph{suffix} of the list of 
205 
premises. 

8483  206 
\item [$params~\vec p@1 \dots \vec p@n$] renames the innermost parameters of 
8547  207 
premises $1, \dots, n$ of some theorem. An empty list of names may be given 
208 
to skip positions, leaving the present parameters unchanged. 

9614  209 

210 
Note that the default usage of case rules does \emph{not} directly expose 

211 
parameters to the proof context (see also \S\ref{sec:inductmethodproper}). 

10548  212 
\item [$consumes~n$] declares the number of ``major premises'' of a rule, 
213 
i.e.\ the number of facts to be consumed when it is applied by an 

214 
appropriate proof method (cf.\ \S\ref{sec:inductmethod}). The default 

215 
value of $consumes$ is $n = 1$, which is appropriate for the usual kind of 

216 
cases and induction rules for inductive sets (cf.\ \S\ref{sec:inductive}). 

217 
Rules without any $consumes$ declaration given are treated as if 

218 
$consumes~0$ had been specified. 

219 

220 
Note that explicit $consumes$ declarations are only rarely needed; this is 

221 
already taken care of automatically by the higherlevel $cases$ and $induct$ 

222 
declarations, see also \S\ref{sec:inductatt}. 

8483  223 
\end{descr} 
224 

225 

9614  226 
\section{Generalized existence}\label{sec:obtain} 
7135  227 

8517  228 
\indexisarcmd{obtain} 
7135  229 
\begin{matharray}{rcl} 
9480  230 
\isarcmd{obtain} & : & \isartrans{proof(state)}{proof(prove)} \\ 
8517  231 
\end{matharray} 
232 

9480  233 
Generalized existence means that additional elements with certain properties 
234 
may introduced in the current context. Technically, the $\OBTAINNAME$ 

235 
language element is like a declaration of $\FIXNAME$ and $\ASSUMENAME$ (see 

236 
also see \S\ref{sec:proofcontext}), together with a soundness proof of its 

237 
additional claim. According to the nature of existential reasoning, 

238 
assumptions get eliminated from any result exported from the context later, 

239 
provided that the corresponding parameters do \emph{not} occur in the 

240 
conclusion. 

8517  241 

242 
\begin{rail} 

243 
'obtain' (vars + 'and') comment? \\ 'where' (assm comment? + 'and') 

244 
; 

245 
\end{rail} 

246 

9480  247 
$\OBTAINNAME$ is defined as a derived Isar command as follows, where $\vec b$ 
248 
shall refer to (optional) facts indicated for forward chaining. 

8517  249 
\begin{matharray}{l} 
9480  250 
\langle facts~\vec b\rangle \\ 
251 
\OBTAIN{\vec x}{a}{\vec \phi}~~\langle proof\rangle \equiv {} \\[1ex] 

252 
\quad \BG \\ 

253 
\qquad \FIX{thesis} \\ 

10160  254 
\qquad \ASSUME{that~[simp, intro]}{\All{\vec x} \vec\phi \Imp thesis} \\ 
9480  255 
\qquad \FROM{\vec b}~\HAVE{}{thesis}~~\langle proof\rangle \\ 
256 
\quad \EN \\ 

10154  257 
\quad \FIX{\vec x}~\ASSUMENAME^\ast~a\colon~\vec\phi \\ 
7135  258 
\end{matharray} 
259 

8517  260 
Typically, the soundness proof is relatively straightforward, often just by 
261 
canonical automated tools such as $\BY{simp}$ (see \S\ref{sec:simp}) or 

9480  262 
$\BY{blast}$ (see \S\ref{sec:classicalauto}). Accordingly, the ``$that$'' 
263 
reduction above is declared as simplification and introduction rule. 

8517  264 

265 
\medskip 

266 

267 
In a sense, $\OBTAINNAME$ represents at the level of Isar proofs what would be 

268 
metalogical existential quantifiers and conjunctions. This concept has a 

269 
broad range of useful applications, ranging from plain elimination (or even 

270 
introduction) of objectlevel existentials and conjunctions, to elimination 

271 
over results of symbolic evaluation of recursive definitions, for example. 

9480  272 
Also note that $\OBTAINNAME$ without parameters acts much like $\HAVENAME$, 
273 
where the result is treated as an assumption. 

8517  274 

275 

10031  276 
\section{Miscellaneous methods and attributes}\label{sec:miscmethods} 
8517  277 

9606  278 
\indexisarmeth{unfold}\indexisarmeth{fold}\indexisarmeth{insert} 
8517  279 
\indexisarmeth{erule}\indexisarmeth{drule}\indexisarmeth{frule} 
280 
\indexisarmeth{fail}\indexisarmeth{succeed} 

281 
\begin{matharray}{rcl} 

282 
unfold & : & \isarmeth \\ 

283 
fold & : & \isarmeth \\[0.5ex] 

9606  284 
insert^* & : & \isarmeth \\[0.5ex] 
8517  285 
erule^* & : & \isarmeth \\ 
286 
drule^* & : & \isarmeth \\ 

287 
frule^* & : & \isarmeth \\[0.5ex] 

288 
succeed & : & \isarmeth \\ 

289 
fail & : & \isarmeth \\ 

290 
\end{matharray} 

7135  291 

292 
\begin{rail} 

9606  293 
('fold'  'unfold'  'insert'  'erule'  'drule'  'frule') thmrefs 
7135  294 
; 
295 
\end{rail} 

296 

7167  297 
\begin{descr} 
8547  298 
\item [$unfold~\vec a$ and $fold~\vec a$] expand and fold back again the given 
8517  299 
metalevel definitions throughout all goals; any facts provided are inserted 
300 
into the goal and subject to rewriting as well. 

8547  301 
\item [$erule~\vec a$, $drule~\vec a$, and $frule~\vec a$] are similar to the 
302 
basic $rule$ method (see \S\ref{sec:puremethatt}), but apply rules by 

8517  303 
elimresolution, destructresolution, and forwardresolution, respectively 
304 
\cite{isabelleref}. These are improper method, mainly for experimentation 

305 
and emulating tactic scripts. 

9614  306 

8517  307 
Different modes of basic rule application are usually expressed in Isar at 
308 
the proof language level, rather than via implicit proof state 

8547  309 
manipulations. For example, a proper singlestep elimination would be done 
8517  310 
using the basic $rule$ method, with forward chaining of current facts. 
9606  311 
\item [$insert~\vec a$] inserts theorems as facts into all goals of the proof 
312 
state. Note that current facts indicated for forward chaining are ignored. 

8517  313 
\item [$succeed$] yields a single (unchanged) result; it is the identity of 
314 
the ``\texttt{,}'' method combinator (cf.\ \S\ref{sec:synmeth}). 

315 
\item [$fail$] yields an empty result sequence; it is the identity of the 

316 
``\texttt{}'' method combinator (cf.\ \S\ref{sec:synmeth}). 

7167  317 
\end{descr} 
7135  318 

10318  319 
\indexisaratt{tagged}\indexisaratt{untagged} 
9614  320 
\indexisaratt{THEN}\indexisaratt{COMP} 
10318  321 
\indexisaratt{where}\indexisaratt{unfolded}\indexisaratt{folded} 
322 
\indexisaratt{standard}\indexisaratt{elimformat} 

323 
\indexisaratt{novars}\indexisaratt{exported} 

8517  324 
\begin{matharray}{rcl} 
9905  325 
tagged & : & \isaratt \\ 
326 
untagged & : & \isaratt \\[0.5ex] 

9614  327 
THEN & : & \isaratt \\ 
8517  328 
COMP & : & \isaratt \\[0.5ex] 
329 
where & : & \isaratt \\[0.5ex] 

9905  330 
unfolded & : & \isaratt \\ 
331 
folded & : & \isaratt \\[0.5ex] 

8517  332 
standard & : & \isaratt \\ 
9941
fe05af7ec816
renamed atts: rulify to rule_format, elimify to elim_format;
wenzelm
parents:
9936
diff
changeset

333 
elim_format & : & \isaratt \\ 
9936  334 
no_vars^* & : & \isaratt \\ 
9905  335 
exported^* & : & \isaratt \\ 
8517  336 
\end{matharray} 
337 

338 
\begin{rail} 

9905  339 
'tagged' (nameref+) 
8517  340 
; 
9905  341 
'untagged' name 
8517  342 
; 
10154  343 
('THEN'  'COMP') ('[' nat ']')? thmref 
8517  344 
; 
345 
'where' (name '=' term * 'and') 

346 
; 

9905  347 
('unfolded'  'folded') thmrefs 
8517  348 
; 
349 
\end{rail} 

350 

351 
\begin{descr} 

9905  352 
\item [$tagged~name~args$ and $untagged~name$] add and remove $tags$ of some 
8517  353 
theorem. Tags may be any list of strings that serve as comment for some 
354 
tools (e.g.\ $\LEMMANAME$ causes the tag ``$lemma$'' to be added to the 

355 
result). The first string is considered the tag name, the rest its 

356 
arguments. Note that untag removes any tags of the same name. 

9614  357 
\item [$THEN~n~a$ and $COMP~n~a$] compose rules. $THEN$ resolves with the 
358 
$n$th premise of $a$; the $COMP$ version skips the automatic lifting 

8547  359 
process that is normally intended (cf.\ \texttt{RS} and \texttt{COMP} in 
360 
\cite[\S5]{isabelleref}). 

8517  361 
\item [$where~\vec x = \vec t$] perform named instantiation of schematic 
9606  362 
variables occurring in a theorem. Unlike instantiation tactics such as 
363 
$rule_tac$ (see \S\ref{sec:tacticcommands}), actual schematic variables 

8517  364 
have to be specified (e.g.\ $\Var{x@3}$). 
9905  365 
\item [$unfolded~\vec a$ and $folded~\vec a$] expand and fold back again the 
366 
given metalevel definitions throughout a rule. 

8517  367 
\item [$standard$] puts a theorem into the standard form of objectrules, just 
368 
as the ML function \texttt{standard} (see \cite[\S5]{isabelleref}). 

9941
fe05af7ec816
renamed atts: rulify to rule_format, elimify to elim_format;
wenzelm
parents:
9936
diff
changeset

369 
\item [$elim_format$] turns a destruction rule into elimination rule format; 
fe05af7ec816
renamed atts: rulify to rule_format, elimify to elim_format;
wenzelm
parents:
9936
diff
changeset

370 
see also the ML function \texttt{make\_elim} (see \cite{isabelleref}). 
9232  371 
\item [$no_vars$] replaces schematic variables by free ones; this is mainly 
372 
for tuning output of pretty printed theorems. 

9905  373 
\item [$exported$] lifts a local result out of the current proof context, 
8517  374 
generalizing all fixed variables and discharging all assumptions. Note that 
8547  375 
proper incremental export is already done as part of the basic Isar 
376 
machinery. This attribute is mainly for experimentation. 

8517  377 
\end{descr} 
7135  378 

379 

9606  380 
\section{Tactic emulations}\label{sec:tactics} 
381 

382 
The following improper proof methods emulate traditional tactics. These admit 

383 
direct access to the goal state, which is normally considered harmful! In 

384 
particular, this may involve both numbered goal addressing (default 1), and 

385 
dynamic instantiation within the scope of some subgoal. 

386 

387 
\begin{warn} 

388 
Dynamic instantiations are read and typechecked according to a subgoal of 

389 
the current dynamic goal state, rather than the static proof context! In 

390 
particular, locally fixed variables and term abbreviations may not be 

391 
included in the term specifications. Thus schematic variables are left to 

392 
be solved by unification with certain parts of the subgoal involved. 

393 
\end{warn} 

394 

395 
Note that the tactic emulation proof methods in Isabelle/Isar are consistently 

396 
named $foo_tac$. 

397 

398 
\indexisarmeth{ruletac}\indexisarmeth{eruletac} 

399 
\indexisarmeth{druletac}\indexisarmeth{fruletac} 

400 
\indexisarmeth{cuttac}\indexisarmeth{thintac} 

9642  401 
\indexisarmeth{subgoaltac}\indexisarmeth{renametac} 
9614  402 
\indexisarmeth{rotatetac}\indexisarmeth{tactic} 
9606  403 
\begin{matharray}{rcl} 
404 
rule_tac^* & : & \isarmeth \\ 

405 
erule_tac^* & : & \isarmeth \\ 

406 
drule_tac^* & : & \isarmeth \\ 

407 
frule_tac^* & : & \isarmeth \\ 

408 
cut_tac^* & : & \isarmeth \\ 

409 
thin_tac^* & : & \isarmeth \\ 

410 
subgoal_tac^* & : & \isarmeth \\ 

9614  411 
rename_tac^* & : & \isarmeth \\ 
412 
rotate_tac^* & : & \isarmeth \\ 

9606  413 
tactic^* & : & \isarmeth \\ 
414 
\end{matharray} 

415 

416 
\railalias{ruletac}{rule\_tac} 

417 
\railterm{ruletac} 

418 

419 
\railalias{eruletac}{erule\_tac} 

420 
\railterm{eruletac} 

421 

422 
\railalias{druletac}{drule\_tac} 

423 
\railterm{druletac} 

424 

425 
\railalias{fruletac}{frule\_tac} 

426 
\railterm{fruletac} 

427 

428 
\railalias{cuttac}{cut\_tac} 

429 
\railterm{cuttac} 

430 

431 
\railalias{thintac}{thin\_tac} 

432 
\railterm{thintac} 

433 

434 
\railalias{subgoaltac}{subgoal\_tac} 

435 
\railterm{subgoaltac} 

436 

9614  437 
\railalias{renametac}{rename\_tac} 
438 
\railterm{renametac} 

439 

440 
\railalias{rotatetac}{rotate\_tac} 

441 
\railterm{rotatetac} 

442 

9606  443 
\begin{rail} 
444 
( ruletac  eruletac  druletac  fruletac  cuttac  thintac ) goalspec? 

445 
( insts thmref  thmrefs ) 

446 
; 

447 
subgoaltac goalspec? (prop +) 

448 
; 

9614  449 
renametac goalspec? (name +) 
450 
; 

451 
rotatetac goalspec? int? 

452 
; 

9606  453 
'tactic' text 
454 
; 

455 

456 
insts: ((name '=' term) + 'and') 'in' 

457 
; 

458 
\end{rail} 

459 

460 
\begin{descr} 

461 
\item [$rule_tac$ etc.] do resolution of rules with explicit instantiation. 

462 
This works the same way as the ML tactics \texttt{res_inst_tac} etc. (see 

463 
\cite[\S3]{isabelleref}). 

9614  464 

9606  465 
Note that multiple rules may be only given there is no instantiation. Then 
466 
$rule_tac$ is the same as \texttt{resolve_tac} in ML (see 

467 
\cite[\S3]{isabelleref}). 

468 
\item [$cut_tac$] inserts facts into the proof state as assumption of a 

469 
subgoal, see also \texttt{cut_facts_tac} in \cite[\S3]{isabelleref}. Note 

470 
that the scope of schmatic variables is spread over the main goal statement. 

471 
Instantiations may be given as well, see also ML tactic 

472 
\texttt{cut_inst_tac} in \cite[\S3]{isabelleref}. 

473 
\item [$thin_tac~\phi$] deletes the specified assumption from a subgoal; note 

474 
that $\phi$ may contain schematic variables. See also \texttt{thin_tac} in 

475 
\cite[\S3]{isabelleref}. 

476 
\item [$subgoal_tac~\phi$] adds $\phi$ as an assumption to a subgoal. See 

477 
also \texttt{subgoal_tac} and \texttt{subgoals_tac} in 

478 
\cite[\S3]{isabelleref}. 

9614  479 
\item [$rename_tac~\vec x$] renames parameters of a goal according to the list 
480 
$\vec x$, which refers to the \emph{suffix} of variables. 

481 
\item [$rotate_tac~n$] rotates the assumptions of a goal by $n$ positions: 

482 
from right to left if $n$ is positive, and from left to right if $n$ is 

483 
negative; the default value is $1$. See also \texttt{rotate_tac} in 

484 
\cite[\S3]{isabelleref}. 

9606  485 
\item [$tactic~text$] produces a proof method from any ML text of type 
486 
\texttt{tactic}. Apart from the usual ML environment and the current 

487 
implicit theory context, the ML code may refer to the following locally 

488 
bound values: 

489 

490 
%%FIXME ttbox produces too much trailing space (why?) 

491 
{\footnotesize\begin{verbatim} 

492 
val ctxt : Proof.context 

493 
val facts : thm list 

494 
val thm : string > thm 

495 
val thms : string > thm list 

496 
\end{verbatim}} 

497 
Here \texttt{ctxt} refers to the current proof context, \texttt{facts} 

498 
indicates any current facts for forwardchaining, and 

499 
\texttt{thm}~/~\texttt{thms} retrieve named facts (including global 

500 
theorems) from the context. 

501 
\end{descr} 

502 

503 

9614  504 
\section{The Simplifier}\label{sec:simplifier} 
7135  505 

7321  506 
\subsection{Simplification methods}\label{sec:simp} 
7315  507 

8483  508 
\indexisarmeth{simp}\indexisarmeth{simpall} 
7315  509 
\begin{matharray}{rcl} 
510 
simp & : & \isarmeth \\ 

8483  511 
simp_all & : & \isarmeth \\ 
7315  512 
\end{matharray} 
513 

8483  514 
\railalias{simpall}{simp\_all} 
515 
\railterm{simpall} 

516 

8704  517 
\railalias{noasm}{no\_asm} 
518 
\railterm{noasm} 

519 

520 
\railalias{noasmsimp}{no\_asm\_simp} 

521 
\railterm{noasmsimp} 

522 

523 
\railalias{noasmuse}{no\_asm\_use} 

524 
\railterm{noasmuse} 

525 

7315  526 
\begin{rail} 
8706  527 
('simp'  simpall) ('!' ?) opt? (simpmod * ) 
7315  528 
; 
529 

8811  530 
opt: '(' (noasm  noasmsimp  noasmuse) ')' 
8704  531 
; 
9711  532 
simpmod: ('add'  'del'  'only'  'cong' (()  'add'  'del')  
9847  533 
'split' (()  'add'  'del')) ':' thmrefs 
7315  534 
; 
535 
\end{rail} 

536 

7321  537 
\begin{descr} 
8547  538 
\item [$simp$] invokes Isabelle's simplifier, after declaring additional rules 
8594  539 
according to the arguments given. Note that the \railtterm{only} modifier 
8547  540 
first removes all other rewrite rules, congruences, and looper tactics 
8594  541 
(including splits), and then behaves like \railtterm{add}. 
9711  542 

543 
\medskip The \railtterm{cong} modifiers add or delete Simplifier congruence 

544 
rules (see also \cite{isabelleref}), the default is to add. 

545 

546 
\medskip The \railtterm{split} modifiers add or delete rules for the 

547 
Splitter (see also \cite{isabelleref}), the default is to add. This works 

548 
only if the Simplifier method has been properly setup to include the 

549 
Splitter (all major object logics such HOL, HOLCF, FOL, ZF do this already). 

8483  550 
\item [$simp_all$] is similar to $simp$, but acts on all goals. 
7321  551 
\end{descr} 
552 

8704  553 
By default, the Simplifier methods are based on \texttt{asm_full_simp_tac} 
8706  554 
internally \cite[\S10]{isabelleref}, which means that assumptions are both 
555 
simplified as well as used in simplifying the conclusion. In structured 

556 
proofs this is usually quite well behaved in practice: just the local premises 

557 
of the actual goal are involved, additional facts may inserted via explicit 

558 
forwardchaining (using $\THEN$, $\FROMNAME$ etc.). The full context of 

559 
assumptions is only included if the ``$!$'' (bang) argument is given, which 

560 
should be used with some care, though. 

7321  561 

8704  562 
Additional Simplifier options may be specified to tune the behavior even 
9614  563 
further: $(no_asm)$ means assumptions are ignored completely (cf.\ 
8811  564 
\texttt{simp_tac}), $(no_asm_simp)$ means assumptions are used in the 
9614  565 
simplification of the conclusion but are not themselves simplified (cf.\ 
8811  566 
\texttt{asm_simp_tac}), and $(no_asm_use)$ means assumptions are simplified 
567 
but are not used in the simplification of each other or the conclusion (cf. 

8704  568 
\texttt{full_simp_tac}). 
569 

570 
\medskip 

571 

572 
The Splitter package is usually configured to work as part of the Simplifier. 

9711  573 
The effect of repeatedly applying \texttt{split_tac} can be simulated by 
574 
$(simp~only\colon~split\colon~\vec a)$. There is also a separate $split$ 

575 
method available for singlestep case splitting, see \S\ref{sec:basiceq}. 

8483  576 

577 

578 
\subsection{Declaring rules} 

579 

8667  580 
\indexisarcmd{printsimpset} 
8638  581 
\indexisaratt{simp}\indexisaratt{split}\indexisaratt{cong} 
7321  582 
\begin{matharray}{rcl} 
10154  583 
print_simpset^* & : & \isarkeep{theory~~proof} \\ 
7321  584 
simp & : & \isaratt \\ 
9711  585 
cong & : & \isaratt \\ 
8483  586 
split & : & \isaratt \\ 
7321  587 
\end{matharray} 
588 

589 
\begin{rail} 

9711  590 
('simp'  'cong'  'split') (()  'add'  'del') 
7321  591 
; 
592 
\end{rail} 

593 

594 
\begin{descr} 

8667  595 
\item [$print_simpset$] prints the collection of rules declared to the 
596 
Simplifier, which is also known as ``simpset'' internally 

597 
\cite{isabelleref}. This is a diagnostic command; $undo$ does not apply. 

8547  598 
\item [$simp$] declares simplification rules. 
8638  599 
\item [$cong$] declares congruence rules. 
9711  600 
\item [$split$] declares case split rules. 
7321  601 
\end{descr} 
7319  602 

7315  603 

604 
\subsection{Forward simplification} 

605 

9905  606 
\indexisaratt{simplified} 
7315  607 
\begin{matharray}{rcl} 
9905  608 
simplified & : & \isaratt \\ 
7315  609 
\end{matharray} 
610 

9905  611 
\begin{rail} 
612 
'simplified' opt? 

613 
; 

614 

615 
opt: '(' (noasm  noasmsimp  noasmuse) ')' 

616 
; 

617 
\end{rail} 

7905  618 

9905  619 
\begin{descr} 
620 
\item [$simplified$] causes a theorem to be simplified according to the 

621 
current Simplifier context (there are no separate arguments for declaring 

622 
additional rules). By default the result is fully simplified, including 

623 
assumptions and conclusion. The options $no_asm$ etc.\ restrict the 

624 
Simplifier in the same way as the for the $simp$ method (see 

625 
\S\ref{sec:simp}). 

626 

627 
The $simplified$ operation should be used only very rarely, usually for 

628 
experimentation only. 

629 
\end{descr} 

7315  630 

631 

9711  632 
\section{Basic equational reasoning}\label{sec:basiceq} 
9614  633 

9703  634 
\indexisarmeth{subst}\indexisarmeth{hypsubst}\indexisarmeth{split}\indexisaratt{symmetric} 
9614  635 
\begin{matharray}{rcl} 
636 
subst & : & \isarmeth \\ 

637 
hypsubst^* & : & \isarmeth \\ 

9703  638 
split & : & \isarmeth \\ 
9614  639 
symmetric & : & \isaratt \\ 
640 
\end{matharray} 

641 

642 
\begin{rail} 

643 
'subst' thmref 

644 
; 

9799  645 
'split' ('(' 'asm' ')')? thmrefs 
9703  646 
; 
9614  647 
\end{rail} 
648 

649 
These methods and attributes provide basic facilities for equational reasoning 

650 
that are intended for specialized applications only. Normally, single step 

651 
reasoning would be performed by calculation (see \S\ref{sec:calculation}), 

652 
while the Simplifier is the canonical tool for automated normalization (see 

653 
\S\ref{sec:simplifier}). 

654 

655 
\begin{descr} 

656 
\item [$subst~thm$] performs a single substitution step using rule $thm$, 

657 
which may be either a meta or object equality. 

658 
\item [$hypsubst$] performs substitution using some assumption. 

9703  659 
\item [$split~thms$] performs singlestep case splitting using rules $thms$. 
9799  660 
By default, splitting is performed in the conclusion of a goal; the $asm$ 
661 
option indicates to operate on assumptions instead. 

662 

9703  663 
Note that the $simp$ method already involves repeated application of split 
664 
rules as declared in the current context (see \S\ref{sec:simp}). 

9614  665 
\item [$symmetric$] applies the symmetry rule of meta or object equality. 
666 
\end{descr} 

667 

668 

9847  669 
\section{The Classical Reasoner}\label{sec:classical} 
7135  670 

7335  671 
\subsection{Basic methods}\label{sec:classicalbasic} 
7321  672 

7974  673 
\indexisarmeth{rule}\indexisarmeth{intro} 
674 
\indexisarmeth{elim}\indexisarmeth{default}\indexisarmeth{contradiction} 

7321  675 
\begin{matharray}{rcl} 
676 
rule & : & \isarmeth \\ 

677 
intro & : & \isarmeth \\ 

678 
elim & : & \isarmeth \\ 

679 
contradiction & : & \isarmeth \\ 

680 
\end{matharray} 

681 

682 
\begin{rail} 

8547  683 
('rule'  'intro'  'elim') thmrefs? 
7321  684 
; 
685 
\end{rail} 

686 

687 
\begin{descr} 

7466  688 
\item [$rule$] as offered by the classical reasoner is a refinement over the 
8517  689 
primitive one (see \S\ref{sec:puremethatt}). In case that no rules are 
7466  690 
provided as arguments, it automatically determines elimination and 
7321  691 
introduction rules from the context (see also \S\ref{sec:classicalmod}). 
8517  692 
This is made the default method for basic proof steps, such as $\PROOFNAME$ 
693 
and ``$\DDOT$'' (two dots), see also \S\ref{sec:proofsteps} and 

694 
\S\ref{sec:puremethatt}. 

9614  695 

7466  696 
\item [$intro$ and $elim$] repeatedly refine some goal by intro or 
7905  697 
elimresolution, after having inserted any facts. Omitting the arguments 
8547  698 
refers to any suitable rules declared in the context, otherwise only the 
699 
explicitly given ones may be applied. The latter form admits better control 

700 
of what actually happens, thus it is very appropriate as an initial method 

701 
for $\PROOFNAME$ that splits up certain connectives of the goal, before 

702 
entering the actual subproof. 

9614  703 

7466  704 
\item [$contradiction$] solves some goal by contradiction, deriving any result 
705 
from both $\neg A$ and $A$. Facts, which are guaranteed to participate, may 

706 
appear in either order. 

7321  707 
\end{descr} 
708 

709 

7981  710 
\subsection{Automated methods}\label{sec:classicalauto} 
7315  711 

9799  712 
\indexisarmeth{blast}\indexisarmeth{fast}\indexisarmeth{slow} 
713 
\indexisarmeth{best}\indexisarmeth{safe}\indexisarmeth{clarify} 

7321  714 
\begin{matharray}{rcl} 
9780  715 
blast & : & \isarmeth \\ 
716 
fast & : & \isarmeth \\ 

9799  717 
slow & : & \isarmeth \\ 
9780  718 
best & : & \isarmeth \\ 
719 
safe & : & \isarmeth \\ 

720 
clarify & : & \isarmeth \\ 

7321  721 
\end{matharray} 
722 

723 
\begin{rail} 

7905  724 
'blast' ('!' ?) nat? (clamod * ) 
7321  725 
; 
9799  726 
('fast'  'slow'  'best'  'safe'  'clarify') ('!' ?) (clamod * ) 
7321  727 
; 
728 

9408  729 
clamod: (('intro'  'elim'  'dest') ('!'  ()  '?')  'del') ':' thmrefs 
7321  730 
; 
731 
\end{rail} 

732 

733 
\begin{descr} 

734 
\item [$blast$] refers to the classical tableau prover (see \texttt{blast_tac} 

7335  735 
in \cite[\S11]{isabelleref}). The optional argument specifies a 
9606  736 
usersupplied search bound (default 20). Note that $blast$ is the only 
737 
classical proof procedure in Isabelle that can handle actual objectlogic 

738 
rules as local assumptions ($fast$ etc.\ would just ignore nonatomic 

739 
facts). 

9799  740 
\item [$fast$, $slow$, $best$, $safe$, and $clarify$] refer to the generic 
741 
classical reasoner. See \texttt{fast_tac}, \texttt{slow_tac}, 

742 
\texttt{best_tac}, \texttt{safe_tac}, and \texttt{clarify_tac} in 

743 
\cite[\S11]{isabelleref} for more information. 

7321  744 
\end{descr} 
745 

746 
Any of above methods support additional modifiers of the context of classical 

8517  747 
rules. Their semantics is analogous to the attributes given in 
8547  748 
\S\ref{sec:classicalmod}. Facts provided by forward chaining are 
749 
inserted\footnote{These methods usually cannot make proper use of actual rules 

750 
inserted that way, though.} into the goal before doing the search. The 

751 
``!''~argument causes the full context of assumptions to be included as well. 

752 
This is slightly less hazardous than for the Simplifier (see 

753 
\S\ref{sec:simp}). 

7321  754 

7315  755 

9847  756 
\subsection{Combined automated methods}\label{sec:clasimp} 
7315  757 

9799  758 
\indexisarmeth{auto}\indexisarmeth{force}\indexisarmeth{clarsimp} 
759 
\indexisarmeth{fastsimp}\indexisarmeth{slowsimp}\indexisarmeth{bestsimp} 

7321  760 
\begin{matharray}{rcl} 
9606  761 
auto & : & \isarmeth \\ 
7321  762 
force & : & \isarmeth \\ 
9438  763 
clarsimp & : & \isarmeth \\ 
9606  764 
fastsimp & : & \isarmeth \\ 
9799  765 
slowsimp & : & \isarmeth \\ 
766 
bestsimp & : & \isarmeth \\ 

7321  767 
\end{matharray} 
768 

769 
\begin{rail} 

9780  770 
'auto' '!'? (nat nat)? (clasimpmod * ) 
771 
; 

9799  772 
('force'  'clarsimp'  'fastsimp'  'slowsimp'  'bestsimp') '!'? (clasimpmod * ) 
7321  773 
; 
7315  774 

9711  775 
clasimpmod: ('simp' (()  'add'  'del'  'only')  
10031  776 
('cong'  'split') (()  'add'  'del')  
777 
'iff' (((()  'add') '?'?)  'del')  

9408  778 
(('intro'  'elim'  'dest') ('!'  ()  '?')  'del')) ':' thmrefs 
7321  779 
\end{rail} 
7315  780 

7321  781 
\begin{descr} 
9799  782 
\item [$auto$, $force$, $clarsimp$, $fastsimp$, $slowsimp$, and $bestsimp$] 
783 
provide access to Isabelle's combined simplification and classical reasoning 

784 
tactics. These correspond to \texttt{auto_tac}, \texttt{force_tac}, 

785 
\texttt{clarsimp_tac}, and Classical Reasoner tactics with the Simplifier 

786 
added as wrapper, see \cite[\S11]{isabelleref} for more information. The 

787 
modifier arguments correspond to those given in \S\ref{sec:simp} and 

9606  788 
\S\ref{sec:classicalauto}. Just note that the ones related to the 
789 
Simplifier are prefixed by \railtterm{simp} here. 

9614  790 

7987  791 
Facts provided by forward chaining are inserted into the goal before doing 
792 
the search. The ``!''~argument causes the full context of assumptions to be 

793 
included as well. 

7321  794 
\end{descr} 
795 

7987  796 

8483  797 
\subsection{Declaring rules}\label{sec:classicalmod} 
7135  798 

8667  799 
\indexisarcmd{printclaset} 
7391  800 
\indexisaratt{intro}\indexisaratt{elim}\indexisaratt{dest} 
9936  801 
\indexisaratt{iff}\indexisaratt{rule} 
7321  802 
\begin{matharray}{rcl} 
10154  803 
print_claset^* & : & \isarkeep{theory~~proof} \\ 
7321  804 
intro & : & \isaratt \\ 
805 
elim & : & \isaratt \\ 

806 
dest & : & \isaratt \\ 

9936  807 
rule & : & \isaratt \\ 
7391  808 
iff & : & \isaratt \\ 
7321  809 
\end{matharray} 
7135  810 

7321  811 
\begin{rail} 
9408  812 
('intro'  'elim'  'dest') ('!'  ()  '?') 
7321  813 
; 
9936  814 
'rule' 'del' 
815 
; 

10031  816 
'iff' (((()  'add') '?'?)  'del') 
9936  817 
; 
7321  818 
\end{rail} 
7135  819 

7321  820 
\begin{descr} 
8667  821 
\item [$print_claset$] prints the collection of rules declared to the 
822 
Classical Reasoner, which is also known as ``simpset'' internally 

823 
\cite{isabelleref}. This is a diagnostic command; $undo$ does not apply. 

8517  824 
\item [$intro$, $elim$, and $dest$] declare introduction, elimination, and 
825 
destruct rules, respectively. By default, rules are considered as 

9408  826 
\emph{unsafe} (i.e.\ not applied blindly without backtracking), while a 
827 
single ``!'' classifies as \emph{safe}, and ``?'' as \emph{extra} (i.e.\ not 

828 
applied in the searchoriented automated methods, but only in singlestep 

829 
methods such as $rule$). 

9936  830 
\item [$rule~del$] deletes introduction, elimination, or destruct rules from 
831 
the context. 

10031  832 
\item [$iff$] declares equivalence rules to the context. The default behavior 
833 
is to declare a rewrite rule to the Simplifier, and the two corresponding 

834 
implications to the Classical Reasoner (as ``safe'' rules that are used 

835 
aggressively, which would normally be indicated by ``!''). 

836 

837 
The ``?'' version of $iff$ declares ``extra'' Classical Reasoner rules only, 

838 
and omits the Simplifier declaration. Thus the declaration does not have 

839 
any effect on automated proof tools, but only on simple methods such as 

840 
$rule$ (see \S\ref{sec:miscmethods}). 

7321  841 
\end{descr} 
7135  842 

8203
2fcc6017cb72
intro/elim/dest attributes: changed ! / !! flags to ? / ??;
wenzelm
parents:
8195
diff
changeset

843 

9614  844 
%%% Local Variables: 
7135  845 
%%% mode: latex 
846 
%%% TeXmaster: "isarref" 

9614  847 
%%% End: 