1 |
1 |
2 \chapter{Isabelle/Isar Conversion Guide}\label{ap:conv} |
2 \chapter{Isabelle/Isar conversion guide}\label{ap:conv} |
3 |
3 |
4 Subsequently, we give a few practical hints on working in a mixed environment |
4 Subsequently, we give a few practical hints on working in a mixed environment |
5 of old Isabelle ML proof scripts and new Isabelle/Isar theories. There are |
5 of old Isabelle ML proof scripts and new Isabelle/Isar theories. There are |
6 basically three ways to cope with this issue. |
6 basically three ways to cope with this issue. |
7 \begin{enumerate} |
7 \begin{enumerate} |
37 this is no longer done in new-style Isabelle/Isar theories. |
37 this is no longer done in new-style Isabelle/Isar theories. |
38 |
38 |
39 \begin{descr} |
39 \begin{descr} |
40 \item [$\mathtt{thm}~name$ and $\mathtt{thms}~name$] retrieve theorems stored |
40 \item [$\mathtt{thm}~name$ and $\mathtt{thms}~name$] retrieve theorems stored |
41 in the current theory context, including any ancestor node. |
41 in the current theory context, including any ancestor node. |
42 |
42 |
43 The convention of old-style theories was to bind any theorem as an ML value |
43 The convention of old-style theories was to bind any theorem as an ML value |
44 as well. New-style theories no longer do this, so ML code may require |
44 as well. New-style theories no longer do this, so ML code may require |
45 \texttt{thm~"foo"} rather than just \texttt{foo}. |
45 \texttt{thm~"foo"} rather than just \texttt{foo}. |
46 |
46 |
47 \item [$\mathtt{the_context()}$] refers to the current theory context. |
47 \item [$\mathtt{the_context()}$] refers to the current theory context. |
48 |
48 |
49 Old-style theories often use the ML binding \texttt{thy}, which is |
49 Old-style theories often use the ML binding \texttt{thy}, which is |
50 dynamically created by the ML code generated from old theory source. This |
50 dynamically created by the ML code generated from old theory source. This |
51 is no longer the recommended way in any case! Function \texttt{the_context} |
51 is no longer the recommended way in any case! Function \texttt{the_context} |
52 should be used for old scripts as well. |
52 should be used for old scripts as well. |
53 |
53 |
54 \item [$\mathtt{theory}~name$] retrieves the named theory from the global |
54 \item [$\mathtt{theory}~name$] retrieves the named theory from the global |
55 theory-loader database. |
55 theory-loader database. |
56 |
56 |
57 The ML code generated from old-style theories would include an ML binding |
57 The ML code generated from old-style theories would include an ML binding |
58 $name\mathtt{.thy}$ as part of an ML structure. |
58 $name\mathtt{.thy}$ as part of an ML structure. |
59 \end{descr} |
59 \end{descr} |
60 |
60 |
61 |
61 |
70 ML proof scripts have to be well-behaved by storing theorems properly within |
70 ML proof scripts have to be well-behaved by storing theorems properly within |
71 the current theory context, in order to enable new-style theories to retrieve |
71 the current theory context, in order to enable new-style theories to retrieve |
72 these later. |
72 these later. |
73 |
73 |
74 \begin{descr} |
74 \begin{descr} |
75 |
75 |
76 \item [$\mathtt{qed}~name$] is the canonical way to conclude a proof script in |
76 \item [$\mathtt{qed}~name$] is the canonical way to conclude a proof script in |
77 ML. This already manages entry in the theorem database of the current |
77 ML. This already manages entry in the theorem database of the current |
78 theory context. |
78 theory context. |
79 |
79 |
80 \item [$\mathtt{bind_thm}~(name, thm)$ and $\mathtt{bind_thms}~(name, thms)$] |
80 \item [$\mathtt{bind_thm}~(name, thm)$ and $\mathtt{bind_thms}~(name, thms)$] |
81 store theorems that have been produced in ML in an ad-hoc manner. |
81 store theorems that have been produced in ML in an ad-hoc manner. |
82 |
82 |
83 \end{descr} |
83 \end{descr} |
84 |
84 |
131 |
131 |
132 \begin{itemize} |
132 \begin{itemize} |
133 \item Quoted strings may contain arbitrary white space, and span several lines |
133 \item Quoted strings may contain arbitrary white space, and span several lines |
134 without requiring \verb,\,\,\dots\verb,\, escapes. |
134 without requiring \verb,\,\,\dots\verb,\, escapes. |
135 \item Names may always be quoted. |
135 \item Names may always be quoted. |
136 |
136 |
137 The old syntax would occasionally demand plain identifiers vs.\ quoted |
137 The old syntax would occasionally demand plain identifiers vs.\ quoted |
138 strings to accommodate certain syntactic features. |
138 strings to accommodate certain syntactic features. |
139 \item Types and terms have to be \emph{atomic} as far as the theory syntax is |
139 \item Types and terms have to be \emph{atomic} as far as the theory syntax is |
140 concerned; this typically requires quoting of input strings, e.g.\ ``$x + |
140 concerned; this typically requires quoting of input strings, e.g.\ ``$x + |
141 y$''. |
141 y$''. |
142 |
142 |
143 The old theory syntax used to fake part of the syntax of types in order to |
143 The old theory syntax used to fake part of the syntax of types in order to |
144 require less quoting in common cases; this was hard to predict, though. On |
144 require less quoting in common cases; this was hard to predict, though. On |
145 the other hand, Isar does not require quotes for simple terms, such as plain |
145 the other hand, Isar does not require quotes for simple terms, such as plain |
146 identifiers $x$, numerals $1$, or symbols $\forall$ (input as |
146 identifiers $x$, numerals $1$, or symbols $\forall$ (input as |
147 \verb,\<forall>,). |
147 \verb,\<forall>,). |
298 |
298 |
299 Classic Isabelle provides several variant forms of tactics for single-step |
299 Classic Isabelle provides several variant forms of tactics for single-step |
300 rule applications (based on higher-order resolution). The space of resolution |
300 rule applications (based on higher-order resolution). The space of resolution |
301 tactics has the following main dimensions. |
301 tactics has the following main dimensions. |
302 \begin{enumerate} |
302 \begin{enumerate} |
303 \item The ``mode'' of resolution: intro, elim, destruct, or forward (e.g.\ |
303 \item The ``mode'' of resolution: intro, elim, destruct, or forward (e.g.\ |
304 \texttt{resolve_tac}, \texttt{eresolve_tac}, \texttt{dresolve_tac}, |
304 \texttt{resolve_tac}, \texttt{eresolve_tac}, \texttt{dresolve_tac}, |
305 \texttt{forward_tac}). |
305 \texttt{forward_tac}). |
306 \item Optional explicit instantiation (e.g.\ \texttt{resolve_tac} vs.\ |
306 \item Optional explicit instantiation (e.g.\ \texttt{resolve_tac} vs.\ |
307 \texttt{res_inst_tac}). |
307 \texttt{res_inst_tac}). |
308 \item Abbreviations for singleton arguments (e.g.\ \texttt{resolve_tac} vs.\ |
308 \item Abbreviations for singleton arguments (e.g.\ \texttt{resolve_tac} vs.\ |
309 \texttt{rtac}). |
309 \texttt{rtac}). |
310 \end{enumerate} |
310 \end{enumerate} |
311 |
311 |
312 Basically, the set of Isar tactic emulations $rule_tac$, $erule_tac$, |
312 Basically, the set of Isar tactic emulations $rule_tac$, $erule_tac$, |
313 $drule_tac$, $frule_tac$ (see \S\ref{sec:tactics}) would be sufficient to |
313 $drule_tac$, $frule_tac$ (see \S\ref{sec:tactics}) would be sufficient to |
346 |
346 |
347 \subsubsection{Simplifier tactics} |
347 \subsubsection{Simplifier tactics} |
348 |
348 |
349 The main Simplifier tactics \texttt{Simp_tac}, \texttt{simp_tac} and variants |
349 The main Simplifier tactics \texttt{Simp_tac}, \texttt{simp_tac} and variants |
350 (cf.\ \cite{isabelle-ref}) are all covered by the $simp$ and $simp_all$ |
350 (cf.\ \cite{isabelle-ref}) are all covered by the $simp$ and $simp_all$ |
351 methods (see \S\ref{sec:simp}). Note that there is no individual goal |
351 methods (see \S\ref{sec:simplifier}). Note that there is no individual goal |
352 addressing available, simplification acts either on the first goal ($simp$) |
352 addressing available, simplification acts either on the first goal ($simp$) or |
353 or all goals ($simp_all$). |
353 all goals ($simp_all$). |
354 |
354 |
355 \begin{matharray}{lll} |
355 \begin{matharray}{lll} |
356 \texttt{Asm_full_simp_tac 1} & & simp \\ |
356 \texttt{Asm_full_simp_tac 1} & & simp \\ |
357 \texttt{ALLGOALS Asm_full_simp_tac} & & simp_all \\[0.5ex] |
357 \texttt{ALLGOALS Asm_full_simp_tac} & & simp_all \\[0.5ex] |
358 \texttt{Simp_tac 1} & & simp~(no_asm) \\ |
358 \texttt{Simp_tac 1} & & simp~(no_asm) \\ |
359 \texttt{Asm_simp_tac 1} & & simp~(no_asm_simp) \\ |
359 \texttt{Asm_simp_tac 1} & & simp~(no_asm_simp) \\ |
360 \texttt{Full_simp_tac 1} & & simp~(no_asm_use) \\ |
360 \texttt{Full_simp_tac 1} & & simp~(no_asm_use) \\ |
361 \end{matharray} |
361 \end{matharray} |
362 |
362 |
363 Isar also provides separate method modifier syntax for augmenting the |
363 Isar also provides separate method modifier syntax for augmenting the |
364 Simplifier context (see \S\ref{sec:simp}), which is known as the ``simpset'' |
364 Simplifier context (see \S\ref{sec:simplifier}), which is known as the |
365 in ML. A typical ML expression with simpset changes looks like this: |
365 ``simpset'' in ML. A typical ML expression with simpset changes looks like |
|
366 this: |
366 \begin{ttbox} |
367 \begin{ttbox} |
367 asm_full_simp_tac (simpset () addsimps [\(a@1\), \(\dots\)] delsimps [\(b@1\), \(\dots\)]) 1 |
368 asm_full_simp_tac (simpset () addsimps [\(a@1\), \(\dots\)] delsimps [\(b@1\), \(\dots\)]) 1 |
368 \end{ttbox} |
369 \end{ttbox} |
369 The corresponding Isar text is as follows: |
370 The corresponding Isar text is as follows: |
370 \[ |
371 \[ |
378 |
379 |
379 The Classical Reasoner provides a rather large number of variations of |
380 The Classical Reasoner provides a rather large number of variations of |
380 automated tactics, such as \texttt{Blast_tac}, \texttt{Fast_tac}, |
381 automated tactics, such as \texttt{Blast_tac}, \texttt{Fast_tac}, |
381 \texttt{Clarify_tac} etc.\ (see \cite{isabelle-ref}). The corresponding Isar |
382 \texttt{Clarify_tac} etc.\ (see \cite{isabelle-ref}). The corresponding Isar |
382 methods usually share the same base name, such as $blast$, $fast$, $clarify$ |
383 methods usually share the same base name, such as $blast$, $fast$, $clarify$ |
383 etc.\ (see \S\ref{sec:classical-auto}). |
384 etc.\ (see \S\ref{sec:classical}). |
384 |
385 |
385 Similar to the Simplifier, there is separate method modifier syntax for |
386 Similar to the Simplifier, there is separate method modifier syntax for |
386 augmenting the Classical Reasoner context, which is known as the ``claset'' in |
387 augmenting the Classical Reasoner context, which is known as the ``claset'' in |
387 ML. A typical ML expression with claset changes looks like this: |
388 ML. A typical ML expression with claset changes looks like this: |
388 \begin{ttbox} |
389 \begin{ttbox} |
440 \emph{unchanged} results as well. |
441 \emph{unchanged} results as well. |
441 |
442 |
442 \medskip \texttt{ALLGOALS}, \texttt{SOMEGOAL} etc.\ (see \cite{isabelle-ref}) |
443 \medskip \texttt{ALLGOALS}, \texttt{SOMEGOAL} etc.\ (see \cite{isabelle-ref}) |
443 are not available in Isar, since there is no direct goal addressing. |
444 are not available in Isar, since there is no direct goal addressing. |
444 Nevertheless, some basic methods address all goals internally, notably |
445 Nevertheless, some basic methods address all goals internally, notably |
445 $simp_all$ (see \S\ref{sec:simp}). Also note that \texttt{ALLGOALS} may be |
446 $simp_all$ (see \S\ref{sec:simplifier}). Also note that \texttt{ALLGOALS} may |
446 often replaced by ``$+$'' (repeat at least once), although this usually has a |
447 be often replaced by ``$+$'' (repeat at least once), although this usually has |
447 different operational behavior, such as solving goals in a different order. |
448 a different operational behavior, such as solving goals in a different order. |
448 |
449 |
449 \medskip Iterated resolution, such as |
450 \medskip Iterated resolution, such as |
450 \texttt{REPEAT~(FIRSTGOAL~(resolve_tac~$\dots$))}, is usually better expressed |
451 \texttt{REPEAT~(FIRSTGOAL~(resolve_tac~$\dots$))}, is usually better expressed |
451 using the $intro$ and $elim$ methods of Isar (see |
452 using the $intro$ and $elim$ methods of Isar (see \S\ref{sec:classical}). |
452 \S\ref{sec:classical-basic}). |
|
453 |
453 |
454 |
454 |
455 \subsection{Declarations and ad-hoc operations}\label{sec:conv-decls} |
455 \subsection{Declarations and ad-hoc operations}\label{sec:conv-decls} |
456 |
456 |
457 Apart from proof commands and tactic expressions, almost all of the remaining |
457 Apart from proof commands and tactic expressions, almost all of the remaining |
557 Certainly, rewriting formal reasoning in Isar requires some additional effort. |
557 Certainly, rewriting formal reasoning in Isar requires some additional effort. |
558 On the other hand, one gains a human-readable representation of |
558 On the other hand, one gains a human-readable representation of |
559 machine-checked formal proof. Depending on the context of application, this |
559 machine-checked formal proof. Depending on the context of application, this |
560 might be even indispensable to start with! |
560 might be even indispensable to start with! |
561 |
561 |
562 |
562 %%% Local Variables: |
563 %%% Local Variables: |
|
564 %%% mode: latex |
563 %%% mode: latex |
565 %%% TeX-master: "isar-ref" |
564 %%% TeX-master: "isar-ref" |
566 %%% End: |
565 %%% End: |