5 chapter {* ML tactic expressions *}
8 Isar Proof methods closely resemble traditional tactics, when used
9 in unstructured sequences of @{command "apply"} commands.
10 Isabelle/Isar provides emulations for all major ML tactics of
11 classic Isabelle --- mostly for the sake of easy porting of existing
12 developments, as actual Isar proof texts would demand much less
13 diversity of proof methods.
15 Unlike tactic expressions in ML, Isar proof methods provide proper
16 concrete syntax for additional arguments, options, modifiers etc.
17 Thus a typical method text is usually more concise than the
18 corresponding ML tactic. Furthermore, the Isar versions of classic
19 Isabelle tactics often cover several variant forms by a single
20 method with separate options to tune the behavior. For example,
21 method @{method simp} replaces all of @{ML simp_tac}~/ @{ML
22 asm_simp_tac}~/ @{ML full_simp_tac}~/ @{ML asm_full_simp_tac}, there
23 is also concrete syntax for augmenting the Simplifier context (the
24 current ``simpset'') in a convenient way.
28 section {* Resolution tactics *}
31 Classic Isabelle provides several variant forms of tactics for
32 single-step rule applications (based on higher-order resolution).
33 The space of resolution tactics has the following main dimensions.
37 \item The ``mode'' of resolution: intro, elim, destruct, or forward
38 (e.g.\ @{ML resolve_tac}, @{ML eresolve_tac}, @{ML dresolve_tac},
41 \item Optional explicit instantiation (e.g.\ @{ML resolve_tac} vs.\
44 \item Abbreviations for singleton arguments (e.g.\ @{ML resolve_tac}
49 Basically, the set of Isar tactic emulations @{method rule_tac},
50 @{method erule_tac}, @{method drule_tac}, @{method frule_tac} (see
51 \secref{sec:tactics}) would be sufficient to cover the four modes,
52 either with or without instantiation, and either with single or
53 multiple arguments. Although it is more convenient in most cases to
54 use the plain @{method rule} method (see
55 \secref{sec:pure-meth-att}), or any of its ``improper'' variants
56 @{method erule}, @{method drule}, @{method frule} (see
57 \secref{sec:misc-meth-att}). Note that explicit goal addressing is
58 only supported by the actual @{method rule_tac} version.
60 With this in mind, plain resolution tactics correspond to Isar
65 @{ML rtac}~@{text "a 1"} & & @{text "rule a"} \\
66 @{ML resolve_tac}~@{text "[a\<^sub>1, \<dots>] 1"} & & @{text "rule a\<^sub>1 \<dots>"} \\
67 @{ML res_inst_tac}~@{text "ctxt [(x\<^sub>1, t\<^sub>1), \<dots>] a 1"} & &
68 @{text "rule_tac x\<^sub>1 = t\<^sub>1 \<AND> \<dots> \<IN> a"} \\[0.5ex]
69 @{ML rtac}~@{text "a i"} & & @{text "rule_tac [i] a"} \\
70 @{ML resolve_tac}~@{text "[a\<^sub>1, \<dots>] i"} & & @{text "rule_tac [i] a\<^sub>1 \<dots>"} \\
71 @{ML res_inst_tac}~@{text "ctxt [(x\<^sub>1, t\<^sub>1), \<dots>] a i"} & &
72 @{text "rule_tac [i] x\<^sub>1 = t\<^sub>1 \<AND> \<dots> \<IN> a"} \\
76 Note that explicit goal addressing may be usually avoided by
77 changing the order of subgoals with @{command "defer"} or @{command
78 "prefer"} (see \secref{sec:tactic-commands}).
82 section {* Simplifier tactics *}
85 The main Simplifier tactics @{ML simp_tac} and variants (cf.\
86 \cite{isabelle-ref}) are all covered by the @{method simp} and
87 @{method simp_all} methods (see \secref{sec:simplifier}). Note that
88 there is no individual goal addressing available, simplification
89 acts either on the first goal (@{method simp}) or all goals
94 @{ML asm_full_simp_tac}~@{text "@{simpset} 1"} & & @{method simp} \\
95 @{ML ALLGOALS}~(@{ML asm_full_simp_tac}~@{text "@{simpset}"}) & & @{method simp_all} \\[0.5ex]
96 @{ML simp_tac}~@{text "@{simpset} 1"} & & @{method simp}~@{text "(no_asm)"} \\
97 @{ML asm_simp_tac}~@{text "@{simpset} 1"} & & @{method simp}~@{text "(no_asm_simp)"} \\
98 @{ML full_simp_tac}~@{text "@{simpset} 1"} & & @{method simp}~@{text "(no_asm_use)"} \\
99 @{ML asm_lr_simp_tac}~@{text "@{simpset} 1"} & & @{method simp}~@{text "(asm_lr)"} \\
105 section {* Classical Reasoner tactics *}
108 The Classical Reasoner provides a rather large number of variations
109 of automated tactics, such as @{ML blast_tac}, @{ML fast_tac}, @{ML
110 clarify_tac} etc.\ (see \cite{isabelle-ref}). The corresponding
111 Isar methods usually share the same base name, such as @{method
112 blast}, @{method fast}, @{method clarify} etc.\ (see
113 \secref{sec:classical}).
117 section {* Miscellaneous tactics *}
120 There are a few additional tactics defined in various theories of
121 Isabelle/HOL, some of these also in Isabelle/FOL or Isabelle/ZF.
122 The most common ones of these may be ported to Isar as follows.
126 @{ML stac}~@{text "a 1"} & & @{text "subst a"} \\
127 @{ML hyp_subst_tac}~@{text 1} & & @{text hypsubst} \\
128 @{ML strip_tac}~@{text 1} & @{text "\<approx>"} & @{text "intro strip"} \\
129 @{ML split_all_tac}~@{text 1} & & @{text "simp (no_asm_simp) only: split_tupled_all"} \\
130 & @{text "\<approx>"} & @{text "simp only: split_tupled_all"} \\
131 & @{text "\<lless>"} & @{text "clarify"} \\
136 section {* Tacticals *}
139 Classic Isabelle provides a huge amount of tacticals for combination
140 and modification of existing tactics. This has been greatly reduced
141 in Isar, providing the bare minimum of combinators only: ``@{text
142 ","}'' (sequential composition), ``@{text "|"}'' (alternative
143 choices), ``@{text "?"}'' (try), ``@{text "+"}'' (repeat at least
144 once). These are usually sufficient in practice; if all fails,
145 arbitrary ML tactic code may be invoked via the @{method tactic}
146 method (see \secref{sec:tactics}).
148 \medskip Common ML tacticals may be expressed directly in Isar as
153 @{text "tac\<^sub>1"}~@{ML_text THEN}~@{text "tac\<^sub>2"} & & @{text "meth\<^sub>1, meth\<^sub>2"} \\
154 @{text "tac\<^sub>1"}~@{ML_text ORELSE}~@{text "tac\<^sub>2"} & & @{text "meth\<^sub>1 | meth\<^sub>2"} \\
155 @{ML TRY}~@{text tac} & & @{text "meth?"} \\
156 @{ML REPEAT1}~@{text tac} & & @{text "meth+"} \\
157 @{ML REPEAT}~@{text tac} & & @{text "(meth+)?"} \\
158 @{ML EVERY}~@{text "[tac\<^sub>1, \<dots>]"} & & @{text "meth\<^sub>1, \<dots>"} \\
159 @{ML FIRST}~@{text "[tac\<^sub>1, \<dots>]"} & & @{text "meth\<^sub>1 | \<dots>"} \\
163 \medskip @{ML CHANGED} (see \cite{isabelle-ref}) is usually not
164 required in Isar, since most basic proof methods already fail unless
165 there is an actual change in the goal state. Nevertheless, ``@{text
166 "?"}'' (try) may be used to accept \emph{unchanged} results as
169 \medskip @{ML ALLGOALS}, @{ML SOMEGOAL} etc.\ (see
170 \cite{isabelle-ref}) are not available in Isar, since there is no
171 direct goal addressing. Nevertheless, some basic methods address
172 all goals internally, notably @{method simp_all} (see
173 \secref{sec:simplifier}). Also note that @{ML ALLGOALS} can be
174 often replaced by ``@{text "+"}'' (repeat at least once), although
175 this usually has a different operational behavior, such as solving
176 goals in a different order.
178 \medskip Iterated resolution, such as @{ML_text "REPEAT (FIRSTGOAL
179 (resolve_tac \<dots>))"}, is usually better expressed using the @{method
180 intro} and @{method elim} methods of Isar (see
181 \secref{sec:classical}).