2 <!-- ============ Tactics ====================== -->
3 <chapter id="sec_tactics">
6 <sect1 id="tac_absurd">
7 <title>absurd <term></title>
8 <titleabbrev>absurd</titleabbrev>
9 <para><userinput>absurd P</userinput></para>
13 <term>Pre-conditions:</term>
15 <para><command>P</command> must have type <command>Prop</command>.</para>
21 <para>It closes the current sequent by eliminating an
26 <term>New sequents to prove:</term>
28 <para>It opens two new sequents of conclusion <command>P</command>
29 and <command>¬P</command>.</para>
35 <sect1 id="tac_apply">
36 <title>apply <term></title>
37 <titleabbrev>apply</titleabbrev>
38 <para><userinput>apply t</userinput></para>
42 <term>Pre-conditions:</term>
44 <para><command>t</command> must have type
45 <command>T<subscript>1</subscript> → ... →
46 T<subscript>n</subscript> → G</command>
47 where <command>G</command> can be unified with the conclusion
48 of the current sequent.</para>
54 <para>It closes the current sequent by applying <command>t</command> to <command>n</command> implicit arguments (that become new sequents).</para>
58 <term>New sequents to prove:</term>
60 <para>It opens a new sequent for each premise
61 <command>T<subscript>i</subscript></command> that is not
62 instantiated by unification. <command>T<subscript>i</subscript></command> is
63 the conclusion of the <command>i</command>-th new sequent to
70 <sect1 id="tac_assumption">
71 <title>assumption</title>
72 <titleabbrev>assumption</titleabbrev>
73 <para><userinput>assumption </userinput></para>
77 <term>Pre-conditions:</term>
79 <para>There must exist an hypothesis whose type can be unified with
80 the conclusion of the current sequent.</para>
86 <para>It closes the current sequent exploiting an hypothesis.</para>
90 <term>New sequents to prove:</term>
99 <title>auto [depth=<int>] [width=<int>] [paramodulation] [full]</title>
100 <titleabbrev>auto</titleabbrev>
101 <para><userinput>auto depth=d width=w paramodulation full</userinput></para>
105 <term>Pre-conditions:</term>
107 <para>None, but the tactic may fail finding a proof if every
108 proof is in the search space that is pruned away. Pruning is
109 controlled by <command>d</command> and <command>w</command>.
110 Moreover, only lemmas whose type signature is a subset of the
111 signature of the current sequent are considered. The signature of
112 a sequent is ...TODO</para>
118 <para>It closes the current sequent by repeated application of
119 rewriting steps (unless <command>paramodulation</command> is
120 omitted), hypothesis and lemmas in the library.</para>
124 <term>New sequents to prove:</term>
132 <sect1 id="tac_clear">
133 <title>clear <id></title>
134 <titleabbrev>clear</titleabbrev>
135 <para><userinput>clear H</userinput></para>
139 <term>Pre-conditions:</term>
141 <para><command>H</command> must be an hypothesis of the
142 current sequent to prove.</para>
148 <para>It hides the hypothesis <command>H</command> from the
149 current sequent.</para>
153 <term>New sequents to prove:</term>
161 <sect1 id="tac_clearbody">
162 <title>clearbody <id></title>
163 <titleabbrev>clearbody</titleabbrev>
164 <para><userinput>clearbody H</userinput></para>
168 <term>Pre-conditions:</term>
170 <para><command>H</command> must be an hypothesis of the
171 current sequent to prove.</para>
177 <para>It hides the definiens of a definition in the current
178 sequent context. Thus the definition becomes an hypothesis.</para>
182 <term>New sequents to prove:</term>
190 <sect1 id="tac_change">
191 <title>change <pattern> with <term></title>
192 <titleabbrev>change</titleabbrev>
193 <para><userinput>change patt with t</userinput></para>
197 <term>Pre-conditions:</term>
199 <para>Each subterm matched by the pattern must be convertible
200 with the term <command>t</command> disambiguated in the context
201 of the matched subterm.</para>
207 <para>It replaces the subterms of the current sequent matched by
208 <command>patt</command> with the new term <command>t</command>.
209 For each subterm matched by the pattern, <command>t</command> is
210 disambiguated in the context of the subterm.</para>
214 <term>New sequents to prove:</term>
222 <sect1 id="tac_constructor">
223 <title>constructor <int></title>
224 <titleabbrev>constructor</titleabbrev>
225 <para><userinput>constructor n</userinput></para>
229 <term>Pre-conditions:</term>
231 <para>The conclusion of the current sequent must be
232 an inductive type or the application of an inductive type with
233 at least <command>n</command> constructors.</para>
239 <para>It applies the <command>n</command>-th constructor of the
240 inductive type of the conclusion of the current sequent.</para>
244 <term>New sequents to prove:</term>
246 <para>It opens a new sequent for each premise of the constructor
247 that can not be inferred by unification. For more details,
248 see the <command>apply</command> tactic.</para>
254 <sect1 id="tac_contradiction">
255 <title>contradiction</title>
256 <titleabbrev>contradiction</titleabbrev>
257 <para><userinput>contradiction </userinput></para>
261 <term>Pre-conditions:</term>
263 <para>There must be in the current context an hypothesis of type
264 <command>False</command>.</para>
270 <para>It closes the current sequent by applying an hypothesis of
271 type <command>False</command>.</para>
275 <term>New sequents to prove:</term>
284 <title>cut <term> [as <id>]</title>
285 <titleabbrev>cut</titleabbrev>
286 <para><userinput>cut P as H</userinput></para>
290 <term>Pre-conditions:</term>
292 <para><command>P</command> must have type <command>Prop</command>.</para>
298 <para>It closes the current sequent.</para>
302 <term>New sequents to prove:</term>
304 <para>It opens two new sequents. The first one has an extra
305 hypothesis <command>H:P</command>. If <command>H</command> is
306 omitted, the name of the hypothesis is automatically generated.
307 The second sequent has conclusion <command>P</command> and
308 hypotheses the hypotheses of the current sequent to prove.</para>
314 <sect1 id="tac_decompose">
315 <title>decompose [<ident list>] <ident> [<intros_spec>]</title>
316 <titleabbrev>decompose</titleabbrev>
317 <para><userinput>decompose ???</userinput></para>
321 <term>Pre-conditions:</term>
333 <term>New sequents to prove:</term>
341 <sect1 id="tac_discriminate">
342 <title>discriminate <term></title>
343 <titleabbrev>discriminate</titleabbrev>
344 <para><userinput>discriminate p</userinput></para>
348 <term>Pre-conditions:</term>
350 <para><command>p</command> must have type <command>K t<subscript>1</subscript> ... t<subscript>n</subscript> = K' t'<subscript>1</subscript> ... t'<subscript>m</subscript></command> where <command>K</command> and <command>K'</command> must be different constructors of the same inductive type and each argument list can be empty if
351 its constructor takes no arguments.</para>
357 <para>It closes the current sequent by proving the absurdity of
358 <command>p</command>.</para>
362 <term>New sequents to prove:</term>
370 <sect1 id="tac_elim">
371 <title>elim <term> [using <term>] [<intros_spec>]</title>
372 <titleabbrev>elim</titleabbrev>
373 <para><userinput>elim t using th hyps</userinput></para>
377 <term>Pre-conditions:</term>
379 <para><command>t</command> must inhabit an inductive type and
380 <command>th</command> must be an elimination principle for that
381 inductive type. If <command>th</command> is omitted the appropriate
382 standard elimination principle is chosen.</para>
388 <para>It proceeds by cases on the values of <command>t</command>,
389 according to the elimination principle <command>th</command>.
394 <term>New sequents to prove:</term>
396 <para>It opens one new sequent for each case. The names of
397 the new hypotheses are picked by <command>hyps</command>, if
398 provided. If hyps specifies also a number of hypotheses that
399 is less than the number of new hypotheses for a new sequent,
400 then the exceeding hypothesis will be kept as implications in
401 the conclusion of the sequent.</para>
407 <sect1 id="tac_elimType">
408 <title>elimType <term> [using <term>] [<intros_spec>]</title>
409 <titleabbrev>elimType</titleabbrev>
410 <para><userinput>elimType T using th hyps</userinput></para>
414 <term>Pre-conditions:</term>
416 <para><command>T</command> must be an inductive type.</para>
422 <para>TODO (severely bugged now).</para>
426 <term>New sequents to prove:</term>
434 <sect1 id="tac_exact">
435 <title>exact <term></title>
436 <titleabbrev>exact</titleabbrev>
437 <para><userinput>exact p</userinput></para>
441 <term>Pre-conditions:</term>
443 <para>The type of <command>p</command> must be convertible
444 with the conclusion of the current sequent.</para>
450 <para>It closes the current sequent using <command>p</command>.</para>
454 <term>New sequents to prove:</term>
462 <sect1 id="tac_exists">
463 <title>exists</title>
464 <titleabbrev>exists</titleabbrev>
465 <para><userinput>exists </userinput></para>
469 <term>Pre-conditions:</term>
471 <para>The conclusion of the current sequent must be
472 an inductive type or the application of an inductive type
473 with at least one constructor.</para>
479 <para>Equivalent to <command>constructor 1</command>.</para>
483 <term>New sequents to prove:</term>
485 <para>It opens a new sequent for each premise of the first
486 constructor of the inductive type that is the conclusion of the
487 current sequent. For more details, see the <command>constructor</command> tactic.</para>
493 <sect1 id="tac_fail">
495 <titleabbrev>failt</titleabbrev>
496 <para><userinput>fail</userinput></para>
500 <term>Pre-conditions:</term>
508 <para>This tactic always fail.</para>
512 <term>New sequents to prove:</term>
520 <sect1 id="tac_fold">
521 <title>fold <reduction_kind> <term> <pattern></title>
522 <titleabbrev>fold</titleabbrev>
523 <para><userinput>fold red t patt</userinput></para>
527 <term>Pre-conditions:</term>
529 <para>The pattern must not specify the wanted term.</para>
535 <para>First of all it locates all the subterms matched by
536 <command>patt</command>. In the context of each matched subterm
537 it disambiguates the term <command>t</command> and reduces it
538 to its <command>red</command> normal form; then it replaces with
539 <command>t</command> every occurrence of the normal form in the
540 matched subterm.</para>
544 <term>New sequents to prove:</term>
552 <sect1 id="tac_fourier">
553 <title>fourier</title>
554 <titleabbrev>fourier</titleabbrev>
555 <para><userinput>fourier </userinput></para>
559 <term>Pre-conditions:</term>
561 <para>The conclusion of the current sequent must be a linear
562 inequation over real numbers taken from standard library of
563 Coq. Moreover the inequations in the hypotheses must imply the
564 inequation in the conclusion of the current sequent.</para>
570 <para>It closes the current sequent by applying the Fourier method.</para>
574 <term>New sequents to prove:</term>
583 <title>fwd <ident> [<ident list>]</title>
584 <titleabbrev>fwd</titleabbrev>
585 <para><userinput>fwd ...TODO</userinput></para>
589 <term>Pre-conditions:</term>
601 <term>New sequents to prove:</term>
609 <sect1 id="tac_generalize">
610 <title>generalize <pattern> [as <id>]</title>
611 <titleabbrev>generalize</titleabbrev>
612 <para><userinput>generalize patt as H</userinput></para>
616 <term>Pre-conditions:</term>
618 <para>All the terms matched by <command>patt</command> must be
619 convertible and close in the context of the current sequent.</para>
625 <para>It closes the current sequent by applying a stronger
626 lemma that is proved using the new generated sequent.</para>
630 <term>New sequents to prove:</term>
632 <para>It opens a new sequent where the current sequent conclusion
633 <command>G</command> is generalized to
634 <command>∀x.G{x/t}</command> where <command>{x/t}</command>
635 is a notation for the replacement with <command>x</command> of all
636 the occurrences of the term <command>t</command> matched by
637 <command>patt</command>. If <command>patt</command> matches no
638 subterm then <command>t</command> is defined as the
639 <command>wanted</command> part of the pattern.</para>
647 <titleabbrev>id</titleabbrev>
648 <para><userinput>id </userinput></para>
652 <term>Pre-conditions:</term>
660 <para>This identity tactic does nothing without failing.</para>
664 <term>New sequents to prove:</term>
672 <sect1 id="tac_injection">
673 <title>injection <term></title>
674 <titleabbrev>injection</titleabbrev>
675 <para><userinput>injection p</userinput></para>
679 <term>Pre-conditions:</term>
681 <para><command>p</command> must have type <command>K t<subscript>1</subscript> ... t<subscript>n</subscript> = K t'<subscript>1</subscript> ... t'<subscript>n</subscript></command> where both argument lists are empty if
682 <command>K</command> takes no arguments.</para>
688 <para>It derives new hypotheses by injectivity of
689 <command>K</command>.</para>
693 <term>New sequents to prove:</term>
695 <para>The new sequent to prove is equal to the current sequent
696 with the additional hypotheses
697 <command>t<subscript>1</subscript>=t'<subscript>1</subscript></command> ... <command>t<subscript>n</subscript>=t'<subscript>n</subscript></command>.</para>
703 <sect1 id="tac_intro">
704 <title>intro [<ident>]</title>
705 <titleabbrev>intro</titleabbrev>
706 <para><userinput>intro H</userinput></para>
710 <term>Pre-conditions:</term>
712 <para>The conclusion of the sequent to prove must be an implication
713 or a universal quantification.</para>
719 <para>It applies the right introduction rule for implication,
720 closing the current sequent.</para>
724 <term>New sequents to prove:</term>
726 <para>It opens a new sequent to prove adding to the hypothesis
727 the antecedent of the implication and setting the conclusion
728 to the consequent of the implicaiton. The name of the new
729 hypothesis is <command>H</command> if provided; otherwise it
730 is automatically generated.</para>
736 <sect1 id="tac_intros">
737 <title>intros <intros_spec></title>
738 <titleabbrev>intros</titleabbrev>
739 <para><userinput>intros hyps</userinput></para>
743 <term>Pre-conditions:</term>
745 <para>If <command>hyps</command> specifies a number of hypotheses
746 to introduce, then the conclusion of the current sequent must
747 be formed by at least that number of imbricated implications
748 or universal quantifications.</para>
754 <para>It applies several times the right introduction rule for
755 implication, closing the current sequent.</para>
759 <term>New sequents to prove:</term>
761 <para>It opens a new sequent to prove adding a number of new
762 hypotheses equal to the number of new hypotheses requested.
763 If the user does not request a precise number of new hypotheses,
764 it adds as many hypotheses as possible.
765 The name of each new hypothesis is either popped from the
766 user provided list of names, or it is automatically generated when
767 the list is (or becomes) empty.</para>
773 <sect1 id="tac_inversion">
774 <title>inversion <term></title>
775 <titleabbrev>inversion</titleabbrev>
776 <para><userinput>inversion t</userinput></para>
780 <term>Pre-conditions:</term>
782 <para>The type of the term <command>t</command> must be an inductive
783 type or the application of an inductive type.</para>
789 <para>It proceeds by cases on <command>t</command> paying attention
790 to the constraints imposed by the actual "right arguments"
791 of the inductive type.</para>
795 <term>New sequents to prove:</term>
797 <para>It opens one new sequent to prove for each case in the
798 definition of the type of <command>t</command>. With respect to
799 a simple elimination, each new sequent has additional hypotheses
800 that states the equalities of the "right parameters"
801 of the inductive type with terms originally present in the
802 sequent to prove.</para>
808 <sect1 id="tac_lapply">
809 <title>lapply [depth=<int>] <term> [to <term list] [using <ident>]</title>
810 <titleabbrev>lapply</titleabbrev>
811 <para><userinput>lapply ???</userinput></para>
815 <term>Pre-conditions:</term>
827 <term>New sequents to prove:</term>
835 <sect1 id="tac_left">
837 <titleabbrev>left</titleabbrev>
838 <para><userinput>left </userinput></para>
842 <term>Pre-conditions:</term>
844 <para>The conclusion of the current sequent must be
845 an inductive type or the application of an inductive type
846 with at least one constructor.</para>
852 <para>Equivalent to <command>constructor 1</command>.</para>
856 <term>New sequents to prove:</term>
858 <para>It opens a new sequent for each premise of the first
859 constructor of the inductive type that is the conclusion of the
860 current sequent. For more details, see the <command>constructor</command> tactic.</para>
866 <sect1 id="tac_letin">
867 <title>letin <ident> ≝ <term></title>
868 <titleabbrev>letin</titleabbrev>
869 <para><userinput>letin x ≝ t</userinput></para>
873 <term>Pre-conditions:</term>
881 <para>It adds to the context of the current sequent to prove a new
882 definition <command>x ≝ t</command>.</para>
886 <term>New sequents to prove:</term>
894 <sect1 id="tac_normalize">
895 <title>normalize <pattern></title>
896 <titleabbrev>normalize</titleabbrev>
897 <para><userinput>normalize patt</userinput></para>
901 <term>Pre-conditions:</term>
909 <para>It replaces all the terms matched by <command>patt</command>
910 with their βδιζ-normal form.</para>
914 <term>New sequents to prove:</term>
922 <sect1 id="tac_paramodulation">
923 <title>paramodulation <pattern></title>
924 <titleabbrev>paramodulation</titleabbrev>
925 <para><userinput>paramodulation patt</userinput></para>
929 <term>Pre-conditions:</term>
941 <term>New sequents to prove:</term>
949 <sect1 id="tac_reduce">
950 <title>reduce <pattern></title>
951 <titleabbrev>reduce</titleabbrev>
952 <para><userinput>reduce patt</userinput></para>
956 <term>Pre-conditions:</term>
964 <para>It replaces all the terms matched by <command>patt</command>
965 with their βδιζ-normal form.</para>
969 <term>New sequents to prove:</term>
977 <sect1 id="tac_reflexivity">
978 <title>reflexivity</title>
979 <titleabbrev>reflexivity</titleabbrev>
980 <para><userinput>reflexivity </userinput></para>
984 <term>Pre-conditions:</term>
986 <para>The conclusion of the current sequent must be
987 <command>t=t</command> for some term <command>t</command></para>
993 <para>It closes the current sequent by reflexivity
998 <term>New sequents to prove:</term>
1006 <sect1 id="tac_replace">
1007 <title>replace <pattern> with <term></title>
1008 <titleabbrev>change</titleabbrev>
1009 <para><userinput>change patt with t</userinput></para>
1013 <term>Pre-conditions:</term>
1019 <term>Action:</term>
1021 <para>It replaces the subterms of the current sequent matched by
1022 <command>patt</command> with the new term <command>t</command>.
1023 For each subterm matched by the pattern, <command>t</command> is
1024 disambiguated in the context of the subterm.</para>
1028 <term>New sequents to prove:</term>
1030 <para>For each matched term <command>t'</command> it opens
1031 a new sequent to prove whose conclusion is
1032 <command>t'=t</command>.</para>
1038 <sect1 id="tac_rewrite">
1039 <title>rewrite {<|>} <term> <pattern></title>
1040 <titleabbrev>rewrite</titleabbrev>
1041 <para><userinput>rewrite dir p patt</userinput></para>
1045 <term>Pre-conditions:</term>
1047 <para><command>p</command> must be the proof of an equality,
1048 possibly under some hypotheses.</para>
1052 <term>Action:</term>
1054 <para>It looks in every term matched by <command>patt</command>
1055 for all the occurrences of the
1056 left hand side of the equality that <command>p</command> proves
1057 (resp. the right hand side if <command>dir</command> is
1058 <command><</command>). Every occurence found is replaced with
1059 the opposite side of the equality.</para>
1063 <term>New sequents to prove:</term>
1065 <para>It opens one new sequent for each hypothesis of the
1066 equality proved by <command>p</command> that is not closed
1067 by unification.</para>
1073 <sect1 id="tac_right">
1074 <title>right</title>
1075 <titleabbrev>right</titleabbrev>
1076 <para><userinput>right </userinput></para>
1080 <term>Pre-conditions:</term>
1082 <para>The conclusion of the current sequent must be
1083 an inductive type or the application of an inductive type with
1084 at least two constructors.</para>
1088 <term>Action:</term>
1090 <para>Equivalent to <command>constructor 2</command>.</para>
1094 <term>New sequents to prove:</term>
1096 <para>It opens a new sequent for each premise of the second
1097 constructor of the inductive type that is the conclusion of the
1098 current sequent. For more details, see the <command>constructor</command> tactic.</para>
1104 <sect1 id="tac_ring">
1106 <titleabbrev>ring</titleabbrev>
1107 <para><userinput>ring </userinput></para>
1111 <term>Pre-conditions:</term>
1113 <para>The conclusion of the current sequent must be an
1114 equality over Coq's real numbers that can be proved using
1115 the ring properties of the real numbers only.</para>
1119 <term>Action:</term>
1121 <para>It closes the current sequent veryfying the equality by
1122 means of computation (i.e. this is a reflexive tactic, implemented
1123 exploiting the "two level reasoning" technique).</para>
1127 <term>New sequents to prove:</term>
1135 <sect1 id="tac_simplify">
1136 <title>simplify <pattern></title>
1137 <titleabbrev>simplify</titleabbrev>
1138 <para><userinput>simplify patt</userinput></para>
1142 <term>Pre-conditions:</term>
1148 <term>Action:</term>
1150 <para>It replaces all the terms matched by <command>patt</command>
1151 with other convertible terms that are supposed to be simpler.</para>
1155 <term>New sequents to prove:</term>
1163 <sect1 id="tac_split">
1164 <title>split</title>
1165 <titleabbrev>split</titleabbrev>
1166 <para><userinput>split </userinput></para>
1170 <term>Pre-conditions:</term>
1172 <para>The conclusion of the current sequent must be
1173 an inductive type or the application of an inductive type with
1174 at least one constructor.</para>
1178 <term>Action:</term>
1180 <para>Equivalent to <command>constructor 1</command>.</para>
1184 <term>New sequents to prove:</term>
1186 <para>It opens a new sequent for each premise of the first
1187 constructor of the inductive type that is the conclusion of the
1188 current sequent. For more details, see the <command>constructor</command> tactic.</para>
1194 <sect1 id="tac_symmetry">
1195 <title>symmetry</title>
1196 <titleabbrev>symmetry</titleabbrev>
1197 <para>The tactic <command>symmetry</command> </para>
1198 <para><userinput>symmetry </userinput></para>
1202 <term>Pre-conditions:</term>
1204 <para>The conclusion of the current proof must be an equality.</para>
1208 <term>Action:</term>
1210 <para>It swaps the two sides of the equalityusing the symmetric
1215 <term>New sequents to prove:</term>
1223 <sect1 id="tac_transitivity">
1224 <title>transitivity <term></title>
1225 <titleabbrev>transitivity</titleabbrev>
1226 <para><userinput>transitivity t</userinput></para>
1230 <term>Pre-conditions:</term>
1232 <para>The conclusion of the current proof must be an equality.</para>
1236 <term>Action:</term>
1238 <para>It closes the current sequent by transitivity of the equality.</para>
1242 <term>New sequents to prove:</term>
1244 <para>It opens two new sequents <command>l=t</command> and
1245 <command>t=r</command> where <command>l</command> and <command>r</command> are the left and right hand side of the equality in the conclusion of
1246 the current sequent to prove.</para>
1252 <sect1 id="tac_unfold">
1253 <title>unfold [<term>] <pattern></title>
1254 <titleabbrev>unfold</titleabbrev>
1255 <para><userinput>unfold t patt</userinput></para>
1259 <term>Pre-conditions:</term>
1265 <term>Action:</term>
1267 <para>It finds all the occurrences of <command>t</command>
1268 (possibly applied to arguments) in the subterms matched by
1269 <command>patt</command>. Then it δ-expands each occurrence,
1270 also performing β-reduction of the obtained term. If
1271 <command>t</command> is omitted it defaults to each
1272 subterm matched by <command>patt</command>.</para>
1276 <term>New sequents to prove:</term>
1284 <sect1 id="tac_whd">
1285 <title>whd <pattern></title>
1286 <titleabbrev>whd</titleabbrev>
1287 <para><userinput>whd patt</userinput></para>
1291 <term>Pre-conditions:</term>
1297 <term>Action:</term>
1299 <para>It replaces all the terms matched by <command>patt</command>
1300 with their βδιζ-weak-head normal form.</para>
1304 <term>New sequents to prove:</term>