51 |
51 |
52 \section{Calculational proof}\label{sec:calculation} |
52 \section{Calculational proof}\label{sec:calculation} |
53 |
53 |
54 \indexisarcmd{also}\indexisarcmd{finally} |
54 \indexisarcmd{also}\indexisarcmd{finally} |
55 \indexisarcmd{moreover}\indexisarcmd{ultimately} |
55 \indexisarcmd{moreover}\indexisarcmd{ultimately} |
56 \indexisaratt{trans} |
56 \indexisarcmd{print-trans-rules}\indexisaratt{trans} |
57 \begin{matharray}{rcl} |
57 \begin{matharray}{rcl} |
58 \isarcmd{also} & : & \isartrans{proof(state)}{proof(state)} \\ |
58 \isarcmd{also} & : & \isartrans{proof(state)}{proof(state)} \\ |
59 \isarcmd{finally} & : & \isartrans{proof(state)}{proof(chain)} \\ |
59 \isarcmd{finally} & : & \isartrans{proof(state)}{proof(chain)} \\ |
60 \isarcmd{moreover} & : & \isartrans{proof(state)}{proof(state)} \\ |
60 \isarcmd{moreover} & : & \isartrans{proof(state)}{proof(state)} \\ |
61 \isarcmd{ultimately} & : & \isartrans{proof(state)}{proof(chain)} \\ |
61 \isarcmd{ultimately} & : & \isartrans{proof(state)}{proof(chain)} \\ |
|
62 \isarcmd{print_trans_rules} & : & \isarkeep{theory~|~proof} \\ |
62 trans & : & \isaratt \\ |
63 trans & : & \isaratt \\ |
63 \end{matharray} |
64 \end{matharray} |
64 |
65 |
65 Calculational proof is forward reasoning with implicit application of |
66 Calculational proof is forward reasoning with implicit application of |
66 transitivity rules (such those of $=$, $\le$, $<$). Isabelle/Isar maintains |
67 transitivity rules (such those of $=$, $\le$, $<$). Isabelle/Isar maintains |
90 The Isar calculation proof commands may be defined as |
91 The Isar calculation proof commands may be defined as |
91 follows:\footnote{Internal bookkeeping such as proper handling of |
92 follows:\footnote{Internal bookkeeping such as proper handling of |
92 block-structure has been suppressed.} |
93 block-structure has been suppressed.} |
93 \begin{matharray}{rcl} |
94 \begin{matharray}{rcl} |
94 \ALSO@0 & \equiv & \NOTE{calculation}{this} \\ |
95 \ALSO@0 & \equiv & \NOTE{calculation}{this} \\ |
95 \ALSO@{n+1} & \equiv & \NOTE{calculation}{trans~[OF~calculation~this]} \\ |
96 \ALSO@{n+1} & \equiv & \NOTE{calculation}{trans~[OF~calculation~this]} \\[0.5ex] |
96 \FINALLY & \equiv & \ALSO~\FROM{calculation} \\ |
97 \FINALLY & \equiv & \ALSO~\FROM{calculation} \\ |
97 \MOREOVER & \equiv & \NOTE{calculation}{calculation~this} \\ |
98 \MOREOVER & \equiv & \NOTE{calculation}{calculation~this} \\ |
98 \ULTIMATELY & \equiv & \MOREOVER~\FROM{calculation} \\ |
99 \ULTIMATELY & \equiv & \MOREOVER~\FROM{calculation} \\ |
99 \end{matharray} |
100 \end{matharray} |
100 |
101 |
231 \quad \BG \\ |
236 \quad \BG \\ |
232 \qquad \FIX{thesis} \\ |
237 \qquad \FIX{thesis} \\ |
233 \qquad \ASSUME{that [simp, intro]}{\All{\vec x} \vec\phi \Imp thesis} \\ |
238 \qquad \ASSUME{that [simp, intro]}{\All{\vec x} \vec\phi \Imp thesis} \\ |
234 \qquad \FROM{\vec b}~\HAVE{}{thesis}~~\langle proof\rangle \\ |
239 \qquad \FROM{\vec b}~\HAVE{}{thesis}~~\langle proof\rangle \\ |
235 \quad \EN \\ |
240 \quad \EN \\ |
236 \quad \FIX{\vec x}~\ASSUMENAME^{obtained}~{a}~{\vec\phi} \\ |
241 \quad \FIX{\vec x}~\ASSUMENAME^{\ast}~{a}~{\vec\phi} \\ |
237 \end{matharray} |
242 \end{matharray} |
238 |
243 |
239 Typically, the soundness proof is relatively straight-forward, often just by |
244 Typically, the soundness proof is relatively straight-forward, often just by |
240 canonical automated tools such as $\BY{simp}$ (see \S\ref{sec:simp}) or |
245 canonical automated tools such as $\BY{simp}$ (see \S\ref{sec:simp}) or |
241 $\BY{blast}$ (see \S\ref{sec:classical-auto}). Accordingly, the ``$that$'' |
246 $\BY{blast}$ (see \S\ref{sec:classical-auto}). Accordingly, the ``$that$'' |
252 where the result is treated as an assumption. |
257 where the result is treated as an assumption. |
253 |
258 |
254 |
259 |
255 \section{Miscellaneous methods and attributes} |
260 \section{Miscellaneous methods and attributes} |
256 |
261 |
257 \indexisarmeth{unfold}\indexisarmeth{fold} |
262 \indexisarmeth{unfold}\indexisarmeth{fold}\indexisarmeth{insert} |
258 \indexisarmeth{erule}\indexisarmeth{drule}\indexisarmeth{frule} |
263 \indexisarmeth{erule}\indexisarmeth{drule}\indexisarmeth{frule} |
259 \indexisarmeth{fail}\indexisarmeth{succeed} |
264 \indexisarmeth{fail}\indexisarmeth{succeed} |
260 \begin{matharray}{rcl} |
265 \begin{matharray}{rcl} |
261 unfold & : & \isarmeth \\ |
266 unfold & : & \isarmeth \\ |
262 fold & : & \isarmeth \\[0.5ex] |
267 fold & : & \isarmeth \\[0.5ex] |
|
268 insert^* & : & \isarmeth \\[0.5ex] |
263 erule^* & : & \isarmeth \\ |
269 erule^* & : & \isarmeth \\ |
264 drule^* & : & \isarmeth \\ |
270 drule^* & : & \isarmeth \\ |
265 frule^* & : & \isarmeth \\[0.5ex] |
271 frule^* & : & \isarmeth \\[0.5ex] |
266 succeed & : & \isarmeth \\ |
272 succeed & : & \isarmeth \\ |
267 fail & : & \isarmeth \\ |
273 fail & : & \isarmeth \\ |
268 \end{matharray} |
274 \end{matharray} |
269 |
275 |
270 \begin{rail} |
276 \begin{rail} |
271 ('fold' | 'unfold' | 'erule' | 'drule' | 'frule') thmrefs |
277 ('fold' | 'unfold' | 'insert' | 'erule' | 'drule' | 'frule') thmrefs |
272 ; |
278 ; |
273 \end{rail} |
279 \end{rail} |
274 |
280 |
275 \begin{descr} |
281 \begin{descr} |
276 \item [$unfold~\vec a$ and $fold~\vec a$] expand and fold back again the given |
282 \item [$unfold~\vec a$ and $fold~\vec a$] expand and fold back again the given |
284 |
290 |
285 Different modes of basic rule application are usually expressed in Isar at |
291 Different modes of basic rule application are usually expressed in Isar at |
286 the proof language level, rather than via implicit proof state |
292 the proof language level, rather than via implicit proof state |
287 manipulations. For example, a proper single-step elimination would be done |
293 manipulations. For example, a proper single-step elimination would be done |
288 using the basic $rule$ method, with forward chaining of current facts. |
294 using the basic $rule$ method, with forward chaining of current facts. |
|
295 \item [$insert~\vec a$] inserts theorems as facts into all goals of the proof |
|
296 state. Note that current facts indicated for forward chaining are ignored. |
289 \item [$succeed$] yields a single (unchanged) result; it is the identity of |
297 \item [$succeed$] yields a single (unchanged) result; it is the identity of |
290 the ``\texttt{,}'' method combinator (cf.\ \S\ref{sec:syn-meth}). |
298 the ``\texttt{,}'' method combinator (cf.\ \S\ref{sec:syn-meth}). |
291 \item [$fail$] yields an empty result sequence; it is the identity of the |
299 \item [$fail$] yields an empty result sequence; it is the identity of the |
292 ``\texttt{|}'' method combinator (cf.\ \S\ref{sec:syn-meth}). |
300 ``\texttt{|}'' method combinator (cf.\ \S\ref{sec:syn-meth}). |
293 \end{descr} |
301 \end{descr} |
338 \item [$RS~n~a$ and $COMP~n~a$] compose rules. $RS$ resolves with the $n$-th |
346 \item [$RS~n~a$ and $COMP~n~a$] compose rules. $RS$ resolves with the $n$-th |
339 premise of $a$; $COMP$ is a version of $RS$ that skips the automatic lifting |
347 premise of $a$; $COMP$ is a version of $RS$ that skips the automatic lifting |
340 process that is normally intended (cf.\ \texttt{RS} and \texttt{COMP} in |
348 process that is normally intended (cf.\ \texttt{RS} and \texttt{COMP} in |
341 \cite[\S5]{isabelle-ref}). |
349 \cite[\S5]{isabelle-ref}). |
342 \item [$where~\vec x = \vec t$] perform named instantiation of schematic |
350 \item [$where~\vec x = \vec t$] perform named instantiation of schematic |
343 variables occurring in a theorem. Unlike instantiation tactics (such as |
351 variables occurring in a theorem. Unlike instantiation tactics such as |
344 \texttt{res_inst_tac}, see \cite{isabelle-ref}), actual schematic variables |
352 $rule_tac$ (see \S\ref{sec:tactic-commands}), actual schematic variables |
345 have to be specified (e.g.\ $\Var{x@3}$). |
353 have to be specified (e.g.\ $\Var{x@3}$). |
346 |
354 |
347 \item [$unfold~\vec a$ and $fold~\vec a$] expand and fold back again the given |
355 \item [$unfold~\vec a$ and $fold~\vec a$] expand and fold back again the given |
348 meta-level definitions throughout a rule. |
356 meta-level definitions throughout a rule. |
349 |
357 |
359 \item [$export$] lifts a local result out of the current proof context, |
367 \item [$export$] lifts a local result out of the current proof context, |
360 generalizing all fixed variables and discharging all assumptions. Note that |
368 generalizing all fixed variables and discharging all assumptions. Note that |
361 proper incremental export is already done as part of the basic Isar |
369 proper incremental export is already done as part of the basic Isar |
362 machinery. This attribute is mainly for experimentation. |
370 machinery. This attribute is mainly for experimentation. |
363 |
371 |
|
372 \end{descr} |
|
373 |
|
374 |
|
375 \section{Tactic emulations}\label{sec:tactics} |
|
376 |
|
377 The following improper proof methods emulate traditional tactics. These admit |
|
378 direct access to the goal state, which is normally considered harmful! In |
|
379 particular, this may involve both numbered goal addressing (default 1), and |
|
380 dynamic instantiation within the scope of some subgoal. |
|
381 |
|
382 \begin{warn} |
|
383 Dynamic instantiations are read and type-checked according to a subgoal of |
|
384 the current dynamic goal state, rather than the static proof context! In |
|
385 particular, locally fixed variables and term abbreviations may not be |
|
386 included in the term specifications. Thus schematic variables are left to |
|
387 be solved by unification with certain parts of the subgoal involved. |
|
388 \end{warn} |
|
389 |
|
390 Note that the tactic emulation proof methods in Isabelle/Isar are consistently |
|
391 named $foo_tac$. |
|
392 |
|
393 \indexisarmeth{rule-tac}\indexisarmeth{erule-tac} |
|
394 \indexisarmeth{drule-tac}\indexisarmeth{frule-tac} |
|
395 \indexisarmeth{cut-tac}\indexisarmeth{thin-tac} |
|
396 \indexisarmeth{subgoal-tac}\indexisarmeth{tactic} |
|
397 \begin{matharray}{rcl} |
|
398 rule_tac^* & : & \isarmeth \\ |
|
399 erule_tac^* & : & \isarmeth \\ |
|
400 drule_tac^* & : & \isarmeth \\ |
|
401 frule_tac^* & : & \isarmeth \\ |
|
402 cut_tac^* & : & \isarmeth \\ |
|
403 thin_tac^* & : & \isarmeth \\ |
|
404 subgoal_tac^* & : & \isarmeth \\ |
|
405 tactic^* & : & \isarmeth \\ |
|
406 \end{matharray} |
|
407 |
|
408 \railalias{ruletac}{rule\_tac} |
|
409 \railterm{ruletac} |
|
410 |
|
411 \railalias{eruletac}{erule\_tac} |
|
412 \railterm{eruletac} |
|
413 |
|
414 \railalias{druletac}{drule\_tac} |
|
415 \railterm{druletac} |
|
416 |
|
417 \railalias{fruletac}{frule\_tac} |
|
418 \railterm{fruletac} |
|
419 |
|
420 \railalias{cuttac}{cut\_tac} |
|
421 \railterm{cuttac} |
|
422 |
|
423 \railalias{thintac}{thin\_tac} |
|
424 \railterm{thintac} |
|
425 |
|
426 \railalias{subgoaltac}{subgoal\_tac} |
|
427 \railterm{subgoaltac} |
|
428 |
|
429 \begin{rail} |
|
430 ( ruletac | eruletac | druletac | fruletac | cuttac | thintac ) goalspec? |
|
431 ( insts thmref | thmrefs ) |
|
432 ; |
|
433 subgoaltac goalspec? (prop +) |
|
434 ; |
|
435 'tactic' text |
|
436 ; |
|
437 |
|
438 insts: ((name '=' term) + 'and') 'in' |
|
439 ; |
|
440 \end{rail} |
|
441 |
|
442 \begin{descr} |
|
443 \item [$rule_tac$ etc.] do resolution of rules with explicit instantiation. |
|
444 This works the same way as the ML tactics \texttt{res_inst_tac} etc. (see |
|
445 \cite[\S3]{isabelle-ref}). |
|
446 |
|
447 Note that multiple rules may be only given there is no instantiation. Then |
|
448 $rule_tac$ is the same as \texttt{resolve_tac} in ML (see |
|
449 \cite[\S3]{isabelle-ref}). |
|
450 \item [$cut_tac$] inserts facts into the proof state as assumption of a |
|
451 subgoal, see also \texttt{cut_facts_tac} in \cite[\S3]{isabelle-ref}. Note |
|
452 that the scope of schmatic variables is spread over the main goal statement. |
|
453 Instantiations may be given as well, see also ML tactic |
|
454 \texttt{cut_inst_tac} in \cite[\S3]{isabelle-ref}. |
|
455 \item [$thin_tac~\phi$] deletes the specified assumption from a subgoal; note |
|
456 that $\phi$ may contain schematic variables. See also \texttt{thin_tac} in |
|
457 \cite[\S3]{isabelle-ref}. |
|
458 \item [$subgoal_tac~\phi$] adds $\phi$ as an assumption to a subgoal. See |
|
459 also \texttt{subgoal_tac} and \texttt{subgoals_tac} in |
|
460 \cite[\S3]{isabelle-ref}. |
|
461 \item [$tactic~text$] produces a proof method from any ML text of type |
|
462 \texttt{tactic}. Apart from the usual ML environment and the current |
|
463 implicit theory context, the ML code may refer to the following locally |
|
464 bound values: |
|
465 |
|
466 %%FIXME ttbox produces too much trailing space (why?) |
|
467 {\footnotesize\begin{verbatim} |
|
468 val ctxt : Proof.context |
|
469 val facts : thm list |
|
470 val thm : string -> thm |
|
471 val thms : string -> thm list |
|
472 \end{verbatim}} |
|
473 Here \texttt{ctxt} refers to the current proof context, \texttt{facts} |
|
474 indicates any current facts for forward-chaining, and |
|
475 \texttt{thm}~/~\texttt{thms} retrieve named facts (including global |
|
476 theorems) from the context. |
364 \end{descr} |
477 \end{descr} |
365 |
478 |
366 |
479 |
367 \section{The Simplifier} |
480 \section{The Simplifier} |
368 |
481 |
545 \end{rail} |
658 \end{rail} |
546 |
659 |
547 \begin{descr} |
660 \begin{descr} |
548 \item [$blast$] refers to the classical tableau prover (see \texttt{blast_tac} |
661 \item [$blast$] refers to the classical tableau prover (see \texttt{blast_tac} |
549 in \cite[\S11]{isabelle-ref}). The optional argument specifies a |
662 in \cite[\S11]{isabelle-ref}). The optional argument specifies a |
550 user-supplied search bound (default 20). |
663 user-supplied search bound (default 20). Note that $blast$ is the only |
|
664 classical proof procedure in Isabelle that can handle actual object-logic |
|
665 rules as local assumptions ($fast$ etc.\ would just ignore non-atomic |
|
666 facts). |
551 \item [$fast$, $best$, and $clarify$] refer to the generic classical reasoner. |
667 \item [$fast$, $best$, and $clarify$] refer to the generic classical reasoner. |
552 See \texttt{fast_tac}, \texttt{best_tac}, and \texttt{clarify_tac} in |
668 See \texttt{fast_tac}, \texttt{best_tac}, and \texttt{clarify_tac} in |
553 \cite[\S11]{isabelle-ref} for more information. |
669 \cite[\S11]{isabelle-ref} for more information. |
554 \end{descr} |
670 \end{descr} |
555 |
671 |
563 \S\ref{sec:simp}). |
679 \S\ref{sec:simp}). |
564 |
680 |
565 |
681 |
566 \subsection{Combined automated methods} |
682 \subsection{Combined automated methods} |
567 |
683 |
568 \indexisarmeth{force}\indexisarmeth{auto}\indexisarmeth{clarsimp} |
684 \indexisarmeth{auto}\indexisarmeth{force} |
569 \begin{matharray}{rcl} |
685 \indexisarmeth{clarsimp}\indexisarmeth{fastsimp} |
|
686 \begin{matharray}{rcl} |
|
687 auto & : & \isarmeth \\ |
570 force & : & \isarmeth \\ |
688 force & : & \isarmeth \\ |
571 auto & : & \isarmeth \\ |
|
572 clarsimp & : & \isarmeth \\ |
689 clarsimp & : & \isarmeth \\ |
573 \end{matharray} |
690 fastsimp & : & \isarmeth \\ |
574 |
691 \end{matharray} |
575 \begin{rail} |
692 |
576 ('force' | 'auto' | 'clarsimp') ('!' ?) (clasimpmod * ) |
693 \begin{rail} |
|
694 ('auto' | 'force' | 'clarsimp' | 'fastsimp') ('!' ?) (clasimpmod * ) |
577 ; |
695 ; |
578 |
696 |
579 clasimpmod: ('simp' (() | 'add' | 'del' | 'only') | 'other' | |
697 clasimpmod: ('simp' (() | 'add' | 'del' | 'only') | 'other' | |
580 ('split' (() | 'add' | 'del')) | |
698 ('split' (() | 'add' | 'del')) | |
581 (('intro' | 'elim' | 'dest') ('!' | () | '?') | 'del')) ':' thmrefs |
699 (('intro' | 'elim' | 'dest') ('!' | () | '?') | 'del')) ':' thmrefs |
582 \end{rail} |
700 \end{rail} |
583 |
701 |
584 \begin{descr} |
702 \begin{descr} |
585 \item [$force$, $auto$, and $clarsimp$] provide access to Isabelle's combined |
703 \item [$auto$, $force$, $clarsimp$, $fastsimp$] provide access to Isabelle's |
586 simplification and classical reasoning tactics. See \texttt{force_tac}, |
704 combined simplification and classical reasoning tactics. These correspond |
587 \texttt{auto_tac}, and \texttt{clarsimp_tac} in \cite[\S11]{isabelle-ref} |
705 to \texttt{auto_tac}, \texttt{force_tac}, \texttt{clarsimp_tac}, and |
588 for more information. The modifier arguments correspond to those given in |
706 \texttt{fast_tac} (with the Simplifier added as wrapper), see |
589 \S\ref{sec:simp} and \S\ref{sec:classical-auto}. Just note that the ones |
707 \cite[\S11]{isabelle-ref} for more information. The modifier arguments |
590 related to the Simplifier are prefixed by \railtterm{simp} here. |
708 correspond to those given in \S\ref{sec:simp} and |
|
709 \S\ref{sec:classical-auto}. Just note that the ones related to the |
|
710 Simplifier are prefixed by \railtterm{simp} here. |
591 |
711 |
592 Facts provided by forward chaining are inserted into the goal before doing |
712 Facts provided by forward chaining are inserted into the goal before doing |
593 the search. The ``!''~argument causes the full context of assumptions to be |
713 the search. The ``!''~argument causes the full context of assumptions to be |
594 included as well. |
714 included as well. |
595 \end{descr} |
715 \end{descr} |