2 <!-- ============ Tacticals ====================== -->
3 <chapter id="sec_tacticals">
4 <title>Tacticals</title>
6 <title>Interactive proofs and definitions</title>
8 An interactive definition is started by giving a
9 <link linkend="definition">definition</link> command omitting
11 An interactive proof is started by using one of the
12 <link linkend="proofs">proof commands</link> omitting
13 an explicit proof term.
15 <para>An interactive proof or definition can and must be terminated by
16 a <link linkend="command_qed">qed</link> command when no more sequents are
17 left to prove. Between the command that starts the interactive session and
18 the qed command the user must provide a procedural proof script made
19 of <link linkend="sec_tactics">tactics</link> structured by means of
20 <link linkend="tacticals">tacticals</link>.</para>
21 <para>In the tradition of the LCF system, tacticals can be considered
22 higher order tactics. Their syntax is structured and they are executed
23 atomically. On the contrary, in Matita the syntax of several tacticals is
24 destructured into a sequence of tokens and tactics in such a way that is
25 is possible to stop execution after every single token or tactic.
26 The original semantics is preserved: the execution of the whole sequence
27 yields the result expected by the original LCF-like tactical.</para>
29 <sect1 id="proofstatus">
30 <title>The proof status</title>
32 During an interactive proof, the proof status is made of
33 the set of sequents to prove and the partial proof built so far.
35 <para>The partial proof can be <link linkend="aboutproof">inspected</link>
36 on demand in the CIC browser. It will be shown in pseudo-natural language
37 produced on the fly from the proof term.</para>
38 <para>The set of sequents to prove is shown in the notebook of the
39 <link linkend="authoringinterface">authoring interface</link>, in the
40 top-right corner of the main window of Matita. Each tab shows a different
41 sequent, named with a question mark followed by a number. The current
42 role of the sequent, according to the following description, is also
46 <listitem id="selectedsequents">
48 <emphasis role="bold">Selected sequents</emphasis>
49 (name in boldface, e.g. <emphasis role="bold">?3</emphasis>).
50 The next tactic will be applied to every selected sequent, producing
51 new selected sequents. <link linkend="tacticals">Tacticals</link>
52 such as branching ("<emphasis role="bold">[</emphasis>")
53 or "<emphasis role="bold">focus</emphasis>" can be used
54 to change the set of selected sequents.
57 <listitem id="siblingsequents">
59 <emphasis role="bold">Sibling sequents</emphasis>
60 (name prefixed by a vertical bar and their position, e.g.
61 |<subscript>3</subscript>?2). When the set of selected sequents
62 has more than one element, the user can decide to focus in turn on each
63 of them. The branching <link linkend="tacticals">tactical</link>
64 ("<emphasis role="bold">[</emphasis>") selects the first
65 sequent only, marking every previously selected sequent as a sibling
66 sequent. Each sibling sequent is given a different position. The
67 tactical "<emphasis role="bold">2,3:</emphasis>" can be used to
68 select one or more sibling sequents, different from the one proposed,
69 according to their position. Once the user starts to work on the
70 selected sibling sequents it becomes impossible to select a new
71 set of siblings until the ("<emphasis role="bold">|</emphasis>")
72 tactical is used to end work on the current one.
75 <listitem id="solvedsequents">
77 <emphasis role="bold">Automatically solved sibling sequents</emphasis>
78 (name strokethrough, e.g. |<subscript>3</subscript><emphasis role="strikethrough">?2</emphasis>).
79 Sometimes a tactic can close by side effects a sibling sequent the
80 user has not selected yet. The sequent is left in the automatically
81 solved status in order for the user to explicitly accept
82 (using the "<emphasis role="bold">skip</emphasis>"
83 <link linkend="tacticals">tactical</link>) the automatic
84 instantiation in the proof script. This way the correspondence between
85 the number of branches in the proof script and the number of sequents
86 generated in the proof is preserved.
91 <sect1 id="tacticals">
92 <title>Tacticals</title>
93 <table frame="topbot" rowsep="0" colsep="0" role="grammar">
94 <title>proof script</title>
98 <entry id="grammar.proofscript">&proofscript;</entry>
100 <entry>&proofstep; [&proofstep;]…</entry>
105 <para>Every proof step can be immediately executed.</para>
106 <table frame="topbot" rowsep="0" colsep="0" role="grammar">
107 <title>proof steps</title>
111 <entry id="grammar.proofstep">&proofstep;</entry>
113 <entry>&LCFtactical;</entry>
114 <entry>The tactical is applied to each
115 <link linkend="selectedsequents">selected sequent</link>.
116 Each new sequent becomes a selected sequent.</entry>
121 <entry><emphasis role="bold">.</emphasis></entry>
123 <link linkend="selectedsequents">selected sequent</link> becomes
124 the only one selected. All the remaining previously selected sequents
125 are proposed to the user one at a time when the next
126 "<emphasis role="bold">.</emphasis>" is used.
132 <entry><emphasis role="bold">;</emphasis></entry>
133 <entry>Nothing changes. Use this proof step as a separator in
134 concrete syntax.</entry>
139 <entry><emphasis role="bold">[</emphasis></entry>
140 <entry>Every <link linkend="selectedsequents">selected sequent</link>
141 becomes a <link linkend="siblingsequents">sibling sequent</link>
142 that constitute a branch in the proof.
143 Moreover, the first sequent is also selected.
149 <entry><emphasis role="bold">|</emphasis></entry>
150 <entry>Stop working on the current branch of the innermost branching
152 The sibling branches become the <link linkend="siblingsequents">sibling
153 sequents</link> and the first one is also selected.
159 <entry>&nat;[<emphasis role="bold">,</emphasis>&nat;]…<emphasis role="bold">:</emphasis></entry>
160 <entry>The <link linkend="siblingsequents">sibling sequents</link>
161 specified by the user become the next
162 <link linkend="selectedsequents">selected sequents</link>.
168 <entry><emphasis role="bold">*:</emphasis></entry>
169 <entry>Every sibling branch not considered yet in the innermost
170 branching proof becomes a
171 <link linkend="selectedsequents">selected sequent</link>.
177 <entry><emphasis role="bold">skip</emphasis></entry>
178 <entry>Accept the automatically provided instantiation (not shown
179 to the user) for the currently selected
180 <link linkend="solvedsequents">automatically closed sibling sequent</link>.
186 <entry><emphasis role="bold">]</emphasis></entry>
187 <entry>Stop analyzing branches for the innermost branching proof.
188 Every sequent opened during the branching proof and not closed yet
189 becomes a <link linkend="selectedsequents">selected sequent</link>.
195 <entry><emphasis role="bold">focus</emphasis> &nat; [&nat;]…</entry>
197 Selects the sequents specified by the user. The selected sequents
198 must be completely closed (no new sequents left open) before doing an
199 "<emphasis role="bold">unfocus</emphasis> that restores
200 the current set of sibling branches.
206 <entry><emphasis role="bold">unfocus</emphasis></entry>
208 Used to match the innermost
209 "<emphasis role="bold">focus</emphasis>" tactical
210 when all the sequents selected by it have been closed.
211 Until "<emphasis role="bold">unfocus</emphasis>" is
212 performed, it is not possible to progress in the rest of the
219 <table frame="topbot" rowsep="0" colsep="0" role="grammar">
220 <title>tactics and LCF tacticals</title>
224 <entry id="grammar.LCFtactical">&LCFtactical;</entry>
226 <entry>&tactic;</entry>
227 <entry>Applies the specified tactic.</entry>
232 <entry>&LCFtactical; <emphasis role="bold">;</emphasis> &LCFtactical;</entry>
233 <entry>Applies the first tactical first and the second tactical
234 to each sequent opened by the first one.</entry>
240 <emphasis role="bold">[</emphasis>
242 [<emphasis role="bold">|</emphasis> &LCFtactical;]…
243 <emphasis role="bold">]</emphasis>
245 <entry>Applies the first tactical first and each tactical in the
246 list of tacticals to the corresponding sequent opened by the
247 first one. The number of tacticals provided in the list must be
248 equal to the number of sequents opened by the first tactical.</entry>
253 <entry><emphasis role="bold">do</emphasis> &nat;
256 <entry>&TODO;</entry>
261 <entry><emphasis role="bold">repeat</emphasis>
264 <entry>&TODO;</entry>
270 <emphasis role="bold">first [</emphasis>
272 [<emphasis role="bold">|</emphasis> &LCFtactical;]…
273 <emphasis role="bold">]</emphasis>
275 <entry>&TODO;</entry>
280 <entry><emphasis role="bold">try</emphasis> &LCFtactical;</entry>
281 <entry>&TODO;</entry>
287 <emphasis role="bold">solve [</emphasis>
289 [<emphasis role="bold">|</emphasis> &LCFtactical;]…
290 <emphasis role="bold">]</emphasis>
292 <entry>&TODO;</entry>
297 <entry><emphasis role="bold">(</emphasis>&LCFtactical;<emphasis role="bold">)</emphasis></entry>
298 <entry>Used for grouping during parsing.</entry>