1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915
|
.. _tactics:
Tactics
========
Tactics specify how to transform the :term:`proof state` of an
incomplete proof to eventually generate a complete proof.
Proofs can be developed in two basic ways: In :gdef:`forward reasoning`,
the proof begins by proving simple statements that are then combined to prove the
theorem statement as the last step of the proof. With forward reasoning,
for example,
the proof of `A /\\ B` would begin with proofs of `A` and `B`, which are
then used to prove `A /\\ B`. Forward reasoning is probably the most common
approach in human-generated proofs.
In :gdef:`backward reasoning`, the proof begins with the theorem statement
as the goal, which is then gradually transformed until every subgoal generated
along the way has been proven. In this case, the proof of `A /\\ B` begins
with that formula as the goal. This can be transformed into two subgoals,
`A` and `B`, followed by the proofs of `A` and `B`. Coq and its tactics
primarily use backward reasoning.
A tactic may fully prove a goal, in which case the goal is removed
from the proof state.
More commonly, a tactic replaces a goal with one or more :term:`subgoals <subgoal>`.
(We say that a tactic reduces a goal to its subgoals.)
Most tactics require specific elements or preconditions to reduce a goal;
they display error messages if they can't be applied to the goal.
A few tactics, such as :tacn:`auto`, don't fail even if the proof state
is unchanged.
Goals are identified by number. The current goal is number
1. Tactics are applied to the current goal by default. (The
default can be changed with the :opt:`Default Goal Selector`
option.) They can
be applied to another goal or to multiple goals with a
:ref:`goal selector <goal-selectors>` such as :n:`2: @tactic`.
This chapter describes many of the most common built-in tactics.
Built-in tactics can be combined to form tactic expressions, which are
described in the :ref:`Ltac` chapter. Since tactic expressions can
be used anywhere that a built-in tactic can be used, "tactic" may
refer to both built-in tactics and tactic expressions.
Common elements of tactics
--------------------------
Reserved keywords
~~~~~~~~~~~~~~~~~
The tactics described in this chapter reserve the following keywords::
by using
Thus, these keywords cannot be used as identifiers. It also declares
the following character sequences as tokens::
** [= |-
.. _invocation-of-tactics:
Invocation of tactics
~~~~~~~~~~~~~~~~~~~~~
Tactics may be preceded by a
goal selector (see Section :ref:`goal-selectors`). If no selector is
specified, the default selector is used.
.. _tactic_invocation_grammar:
.. prodn::
tactic_invocation ::= {? @toplevel_selector : } @tactic.
.. todo: fully describe selectors. At the moment, ltac has a fairly complete description
.. todo: mention selectors can be applied to some commands, such as
Check, Search, SearchPattern, SearchRewrite.
.. opt:: Default Goal Selector "@toplevel_selector"
:name: Default Goal Selector
This :term:`option` controls the default selector, used when no selector is
specified when applying a tactic. The initial value is 1, hence the
tactics are, by default, applied to the first goal.
Using value ``all`` will make it so that tactics are, by default,
applied to every goal simultaneously. Then, to apply a tactic tac
to the first goal only, you can write ``1:tac``.
Using value ``!`` enforces that all tactics are used either on a
single focused goal or with a local selector (’’strict focusing
mode’’).
Although other selectors are available, only ``all``, ``!`` or a
single natural number are valid default goal selectors.
.. _bindings:
Bindings
~~~~~~~~
Tactics that take a term as an argument may also accept :token:`bindings` to
specify the values to assign unbound variables in a term.
Bindings can be given by position or name. Generally these appear in the form
:n:`@one_term_with_bindings` or :n:`with @bindings`, depending on the tactic.
.. insertprodn one_term_with_bindings bindings
.. prodn::
one_term_with_bindings ::= @one_term {? with @bindings }
bindings ::= {+ @one_term }
| {+ ( {| @ident | @natural } := @term ) }
* :n:`@one_term {? with @bindings }` — bindings for variables in :n:`@one_term`
are typically determined by unifying :n:`@one_term` with a tactic-dependent part
of the context, with any remaining unbound variables provided by the :n:`@bindings`.
* :n:`{+ @one_term }` — binds free variables in the left-to-right order of their first
appearance in the relevant term.
For some tactics, bindings for all free variables
must be provided, such as for :tacn:`induction`, :tacn:`destruct`, :tacn:`elim`
and :tacn:`case`. Other tactics automatically generate some or all
of the bindings from the conclusion or a hypothesis, such as :tacn:`apply` and
:tacn:`constructor` and its variants. In this case, only instances
for the :term:`dependent premises <dependent premise>` that are not bound in
the conclusion of the relevant term are required (and permitted).
* :n:`{+ ( {| @ident | @natural } := @term ) }` — binds variables by name (if :n:`@ident` is given), or
by unifying with the ``n``-th :term:`premise` of the relevant term
(if :n:`@natural` is given).
.. exn:: No such binder.
:n:`@natural` is 0 or more than the number of unbound variables.
.. exn:: No such bound variable @ident (no bound variables at all in the expression).
:undocumented:
.. exn:: No such bound variable @ident__1 (possible names are: @ident__2 ...).
The specified binder name :n:`@ident__1` is not used in the :n:`@one_term`.
:n:`@ident__2 ...` lists all the valid binder names.
.. exn:: Not the right number of missing arguments (expected @natural).
Generated when the first form of :n:`@bindings` doesn't have the
expected number of arguments.
.. _intropatterns:
Intro patterns
~~~~~~~~~~~~~~
Intro patterns let you specify the name to assign to variables and hypotheses
introduced by tactics. They also let you split an introduced hypothesis into
multiple hypotheses or subgoals. Common tactics that accept intro patterns
include :tacn:`assert`, :tacn:`intros` and :tacn:`destruct`.
.. insertprodn intropattern equality_intropattern
.. prodn::
intropattern ::= *
| **
| @simple_intropattern
simple_intropattern ::= @simple_intropattern_closed {* % @term0 }
simple_intropattern_closed ::= @naming_intropattern
| _
| @or_and_intropattern
| @equality_intropattern
naming_intropattern ::= @ident
| ?
| ?@ident
or_and_intropattern ::= [ {*| {* @intropattern } } ]
| ( {*, @simple_intropattern } )
| ( {*& @simple_intropattern } )
equality_intropattern ::= ->
| <-
| [= {* @intropattern } ]
Note that the intro pattern syntax varies between tactics.
Most tactics use :n:`@simple_intropattern` in the grammar.
:tacn:`destruct`, :tacn:`edestruct`, :tacn:`induction`,
:tacn:`einduction`, :tacn:`case`, :tacn:`ecase` and the various
:tacn:`inversion` tactics use :n:`@or_and_intropattern`, while
:tacn:`intros` and :tacn:`eintros` use :n:`{* @intropattern }`.
The :n:`eqn:` construct in various tactics uses :n:`@naming_intropattern`.
**Naming patterns**
Use these elementary patterns to specify a name:
* :n:`@ident` — use the specified name
* :n:`?` — let Coq generate a fresh name
* :n:`?@ident` — generate a name that begins with :n:`@ident`
* :n:`_` — discard the matched part (unless it is required for another
hypothesis)
* if a disjunction pattern omits a name, such as :g:`[|H2]`, Coq will choose a name
**Splitting patterns**
The most common splitting patterns are:
* split a hypothesis in the form :n:`A /\ B` into two
hypotheses :g:`H1: A` and :g:`H2: B` using the pattern :g:`(H1 & H2)` or
:g:`(H1, H2)` or :g:`[H1 H2]`.
:ref:`Example <intropattern_conj_ex>`. This also works on :n:`A <-> B`, which
is just a notation representing :n:`(A -> B) /\ (B -> A)`.
* split a hypothesis in the form :g:`A \/ B` into two
subgoals using the pattern :g:`[H1|H2]`. The first subgoal will have the hypothesis
:g:`H1: A` and the second subgoal will have the hypothesis :g:`H2: B`.
:ref:`Example <intropattern_disj_ex>`
* split a hypothesis in either of the forms :g:`A /\ B` or :g:`A \/ B` using the pattern :g:`[]`.
Patterns can be nested: :n:`[[Ha|Hb] H]` can be used to split :n:`(A \/ B) /\ C`.
Note that there is no equivalent to intro patterns for goals. For a goal :g:`A /\ B`,
use the :tacn:`split` tactic to replace the current goal with subgoals :g:`A` and :g:`B`.
For a goal :g:`A \/ B`, use :tacn:`left` to replace the current goal with :g:`A`, or
:tacn:`right` to replace the current goal with :g:`B`.
* :n:`( {+, @simple_intropattern}` ) — matches
a product over an inductive type with a
:ref:`single constructor <intropattern_cons_note>`.
If the number of patterns
equals the number of constructor arguments, then it applies the patterns only to
the arguments, and
:n:`( {+, @simple_intropattern} )` is equivalent to :n:`[{+ @simple_intropattern}]`.
If the number of patterns equals the number of constructor arguments plus the number
of :n:`let-ins`, the patterns are applied to the arguments and :n:`let-in` variables.
* :n:`( {+& @simple_intropattern} )` — matches a right-hand nested term that consists
of one or more nested binary inductive types such as :g:`a1 OP1 a2 OP2 …`
(where the :g:`OPn` are right-associative).
(If the :g:`OPn` are left-associative, additional parentheses will be needed to make the
term right-hand nested, such as :g:`a1 OP1 (a2 OP2 …)`.)
The splitting pattern can have more than 2 names, for example :g:`(H1 & H2 & H3)`
matches :g:`A /\ B /\ C`.
The inductive types must have a
:ref:`single constructor with two parameters <intropattern_cons_note>`.
:ref:`Example <intropattern_ampersand_ex>`
* :n:`[ {+| {* @intropattern } } ]` — splits an inductive type that has
:ref:`multiple constructors <intropattern_cons_note>`
such as :n:`A \/ B` into multiple subgoals. The number of :token:`intropattern`\s
must be the same as the number of constructors for the matched part.
* :n:`[ {+ @intropattern} ]` — splits an inductive type that has a
:ref:`single constructor with multiple parameters <intropattern_cons_note>`
such as :n:`A /\ B` into multiple hypotheses. Use :n:`[H1 [H2 H3]]` to match :g:`A /\ B /\ C`.
* :n:`[]` — splits an inductive type: If the inductive
type has multiple constructors, such as :n:`A \/ B`,
create one subgoal for each constructor. If the inductive type has a single constructor with
multiple parameters, such as :n:`A /\ B`, split it into multiple hypotheses.
**Equality patterns**
These patterns can be used when the hypothesis is an equality:
* :n:`->` — replaces the right-hand side of the hypothesis with the left-hand
side of the hypothesis in the conclusion of the goal; the hypothesis is
cleared; if the left-hand side of the hypothesis is a variable, it is
substituted everywhere in the context and the variable is removed.
:ref:`Example <intropattern_rarrow_ex>`
* :n:`<-` — similar to :n:`->`, but replaces the left-hand side of the hypothesis
with the right-hand side of the hypothesis.
* :n:`[= {*, @intropattern} ]` — If the product is over an equality type,
applies either :tacn:`injection` or :tacn:`discriminate`.
If :tacn:`injection` is applicable, the intropattern
is used on the hypotheses generated by :tacn:`injection`. If the
number of patterns is smaller than the number of hypotheses generated, the
pattern :n:`?` is used to complete the list.
:ref:`Example <intropattern_inj_discr_ex>`
**Other patterns**
* :n:`*` — introduces one or more :term:`dependent premises <dependent premise>`
from the result until there are no more.
:ref:`Example <intropattern_star_ex>`
* :n:`**` — introduces one or more :term:`dependent <dependent premise>`
or :term:`non-dependent premises <non-dependent premise>` from the result
until there are no more premises. :g:`intros **` is equivalent to :g:`intros`.
:ref:`Example <intropattern_2stars_ex>`
* :n:`@simple_intropattern_closed {* % @term}` — first applies each of the terms
with the :tacn:`apply` tactic on the hypothesis to be introduced, then it uses
:n:`@simple_intropattern_closed`.
:ref:`Example <intropattern_injection_ex>`
.. _intropattern_cons_note:
.. note::
:n:`A \/ B` and :n:`A /\ B` use infix notation to refer to the inductive
types :n:`or` and :n:`and`.
:n:`or` has multiple constructors (:n:`or_introl` and :n:`or_intror`),
while :n:`and` has a single constructor (:n:`conj`) with multiple parameters
(:n:`A` and :n:`B`).
These are defined in ``theories/Init/Logic.v``. The "where" clauses define the
infix notation for "or" and "and".
.. coqdoc::
Inductive or (A B:Prop) : Prop :=
| or_introl : A -> A \/ B
| or_intror : B -> A \/ B
where "A \/ B" := (or A B) : type_scope.
Inductive and (A B:Prop) : Prop :=
conj : A -> B -> A /\ B
where "A /\ B" := (and A B) : type_scope.
.. note::
:tacn:`intros` :n:`{+ p}` is not always equivalent to :n:`intros p; … ; intros p`
if some of the :n:`p` are :g:`_`. In the first form, all erasures are done
at once, while they're done sequentially for each tactic in the second form.
If the second matched term depends on the first matched term and the pattern
for both is :g:`_` (i.e., both will be erased), the first :n:`intros` in the second
form will fail because the second matched term still has the dependency on the first.
Examples:
.. _intropattern_conj_ex:
.. example:: intro pattern for /\\
.. coqtop:: reset none
Goal forall (A: Prop) (B: Prop), (A /\ B) -> True.
.. coqtop:: out
intros.
.. coqtop:: all
destruct H as (HA & HB).
.. _intropattern_disj_ex:
.. example:: intro pattern for \\/
.. coqtop:: reset none
Goal forall (A: Prop) (B: Prop), (A \/ B) -> True.
.. coqtop:: out
intros.
.. coqtop:: all
destruct H as [HA|HB]. all: swap 1 2.
.. _intropattern_rarrow_ex:
.. example:: -> intro pattern
.. coqtop:: reset none
Goal forall (x:nat) (y:nat) (z:nat), (x = y) -> (y = z) -> (x = z).
.. coqtop:: out
intros * H.
.. coqtop:: all
intros ->.
.. _intropattern_inj_discr_ex:
.. example:: [=] intro pattern
The first :tacn:`intros` :n:`[=]` uses :tacn:`injection` to strip :n:`(S …)` from
both sides of the matched equality. The second uses :tacn:`discriminate` on
the contradiction :n:`1 = 2` (internally represented as :n:`(S O) = (S (S O))`)
to complete the goal.
.. coqtop:: reset none
Goal forall (n m:nat), (S n) = (S m) -> (S O)=(S (S O)) -> False.
.. coqtop:: out
intros *.
.. coqtop:: all
intros [= H].
.. coqtop:: all
intros [=].
.. _intropattern_ampersand_ex:
.. example:: (A & B & …) intro pattern
.. coqtop:: reset none
Parameters (A : Prop) (B: nat -> Prop) (C: Prop).
.. coqtop:: out
Goal A /\ (exists x:nat, B x /\ C) -> True.
.. coqtop:: all
intros (a & x & b & c).
.. _intropattern_star_ex:
.. example:: * intro pattern
.. coqtop:: reset out
Goal forall (A: Prop) (B: Prop), A -> B.
.. coqtop:: all
intros *.
.. _intropattern_2stars_ex:
.. example:: ** pattern ("intros \**" is equivalent to "intros")
.. coqtop:: reset out
Goal forall (A: Prop) (B: Prop), A -> B.
.. coqtop:: all
intros **.
.. example:: compound intro pattern
.. coqtop:: reset out
Goal forall A B C:Prop, A \/ B /\ C -> (A -> C) -> C.
.. coqtop:: all
intros * [a | (_,c)] f.
all: swap 1 2.
.. _intropattern_injection_ex:
.. example:: combined intro pattern using [=] -> and %
.. coqtop:: reset none
Require Import Coq.Lists.List.
Section IntroPatterns.
Variables (A : Type) (xs ys : list A).
.. coqtop:: out
Example ThreeIntroPatternsCombined :
S (length ys) = 1 -> xs ++ ys = xs.
.. coqtop:: all
intros [=->%length_zero_iff_nil].
* `intros` would add :g:`H : S (length ys) = 1`
* `intros [=]` would additionally apply :tacn:`injection` to :g:`H` to yield :g:`H0 : length ys = 0`
* `intros [=->%length_zero_iff_nil]` applies the theorem, making H the equality :g:`l=nil`,
which is then applied as for :g:`->`.
.. coqdoc::
Theorem length_zero_iff_nil (l : list A):
length l = 0 <-> l=nil.
The example is based on `Tej Chajed's coq-tricks <https://github.com/tchajed/coq-tricks/blob/8e6efe4971ed828ac8bdb5512c1f615d7d62691e/src/IntroPatterns.v>`_
.. _occurrenceclauses:
Occurrence clauses
~~~~~~~~~~~~~~~~~~
An :gdef:`occurrence` is a subterm of a goal or hypothesis that
matches a pattern provided by a tactic. Occurrence clauses
select a subset of the ocurrences in a goal and/or in
one or more of its hypotheses.
.. insertprodn occurrences concl_occs
.. prodn::
occurrences ::= at @occs_nums
| in @goal_occurrences
simple_occurrences ::= @occurrences
occs_nums ::= {? - } {+ @nat_or_var }
nat_or_var ::= {| @natural | @ident }
goal_occurrences ::= {+, @hyp_occs } {? %|- {? @concl_occs } }
| * %|- {? @concl_occs }
| %|- {? @concl_occs }
| {? @concl_occs }
hyp_occs ::= @hypident {? at @occs_nums }
hypident ::= @ident
| ( type of @ident )
| ( value of @ident )
concl_occs ::= * {? at @occs_nums }
:n:`@occurrences`
The first form of :token:`occurrences` selects occurrences in
the conclusion of the goal. The second form can select occurrences
in the goal conclusion and in one or more hypotheses.
:n:`@simple_occurrences`
A semantically restricted form of :n:`@occurrences` that doesn't allow the
`at` clause anywhere within it.
:n:`{? - } {+ @nat_or_var }`
Selects the specified occurrences within a single goal or hypothesis.
Occurrences are numbered starting with 1 following a depth-first traversal
of the term's expression, including occurrences in
:ref:`implicit arguments <ImplicitArguments>`
and :ref:`coercions <Coercions>` that are not displayed by default.
(Set the :flag:`Printing All` flag to show those in the printed term.)
For example, when matching the pattern `_ + _` in the term `(a + b) + c`,
occurrence 1 is `(…) + c` and
occurrence 2 is `(a + b)`. When matching that pattern with term `a + (b + c)`,
occurrence 1 is `a + (…)` and occurrence 2 is `b + c`.
Specifying `-` includes all occurrences *except* the ones listed.
:n:`{*, @hyp_occs } {? %|- {? @concl_occs } }`
Selects occurrences in the specified hypotheses and the
specified occurrences in the conclusion.
:n:`* %|- {? @concl_occs }`
Selects all occurrences in all hypotheses and the
specified occurrences in the conclusion.
:n:`%|- {? @concl_occs }`
Selects the specified occurrences in the conclusion.
:n:`@goal_occurrences ::= {? @concl_occs }`
Selects all occurrences in all hypotheses and in the specified occurrences
in the conclusion.
:n:`@hypident {? at @occs_nums }`
Omiting :token:`occs_nums` selects all occurrences within the hypothesis.
:n:`@hypident ::= @ident`
Selects the hypothesis named :token:`ident`.
:n:`( type of @ident )`
Selects the type part of the named hypothesis (e.g. `: nat`).
:n:`( value of @ident )`
Selects the value part of the named hypothesis (e.g. `:= 1`).
:n:`@concl_occs ::= * {? at @occs_nums }`
Selects occurrences in the conclusion. '*' by itself selects all occurrences.
:n:`@occs_nums` selects the specified occurrences.
Use `in *` to select all occurrences in all hypotheses and the conclusion,
which is equivalent to `in * |- *`. Use `* |-` to select all occurrences
in all hypotheses.
When rewriting in multiple hypotheses, they must not appear in the
term to rewrite. For instance `rewrite H in H,H'` is an error. If
an hypothesis appears only through a hole, it will be removed from
that hole's context.
With `rewrite term in *`, hypotheses on which the dependency cannot
be avoided are skipped, for instance `rewrite H in *` skips
rewriting in `H`. This is the case even if only one hypothesis ends
up rewritten.
If multiple
occurrences are given, such as in :tacn:`rewrite` `H at 1 2 3`, the tactic
must match at least one occurrence in order to succeed. The tactic will fail
if no occurrences match. Occurrence numbers that are out of range (e.g.
`at 1 3` when there are only 2 occurrences in the hypothesis or conclusion)
are ignored.
.. todo: remove last sentence above and add "Invalid occurrence number @natural" exn for 8.14
per #13568.
Tactics that use occurrence clauses include :tacn:`set`,
:tacn:`remember`, :tacn:`induction` and :tacn:`destruct`.
.. exn:: No such hypothesis: @ident.
:undocumented:
.. seealso::
:ref:`Managingthelocalcontext`, :ref:`caseanalysisandinduction`,
:ref:`printing_constructions_full`.
.. _applyingtheorems:
Applying theorems
---------------------
.. tacn:: exact @one_term
Directly gives the exact proof term for the goal.
``exact p`` succeeds if and only if :n:`@one_term` and the type of ``p`` are
unifiable (see :ref:`Conversion-rules`).
.. exn:: Not an exact proof.
:undocumented:
.. tacn:: eexact @one_term
Behaves like :tacn:`exact` but can handle terms and
goals with existential variables.
.. tacn:: assumption
This tactic looks in the local context for a hypothesis whose type is
convertible to the goal. If it is the case, the subgoal is proved.
Otherwise, it fails.
.. exn:: No such assumption.
:undocumented:
.. tacn:: eassumption
Behaves like :tacn:`assumption` but is able to process
goals and hypotheses with existential variables. It can also
resolve existential variables, which :tacn:`assumption` will not.
.. tacn:: {? simple } {? notypeclasses } refine @one_term
:name: refine
Behaves like :tacn:`exact` but allows holes (denoted by ``_``
or :n:`(_ : @type)`) in :n:`@one_term`. :tacn:`refine` generates as many
subgoals as there are remaining holes in the elaborated term. Any subgoal
that occurs in other subgoals is automatically shelved, as if calling
:tacn:`shelve_unifiable`.
`simple`
If specified, don't shelve any subgoals or perform beta reduction.
`notypeclasses`
If specified, do checking without resolving typeclasses. The generated
subgoals (shelved or not) are *not* candidates for typeclass resolution,
even if they have a typeclass type as their conclusion.
.. example::
.. coqtop:: reset all
Inductive Option : Set :=
| Fail : Option
| Ok : bool -> Option.
Definition get : forall x:Option, x <> Fail -> bool.
refine
(fun x:Option =>
match x return x <> Fail -> bool with
| Fail => _
| Ok b => fun _ => b
end).
intros; absurd (Fail = Fail); trivial.
Defined.
.. exn:: Cannot infer a term for this placeholder.
:name: Cannot infer a term for this placeholder. (refine)
There is a hole in the term you gave whose type cannot be inferred. Put a
cast around it.
Setting :opt:`Debug` ``"unification"`` enables printing traces of
unification steps used during elaboration/typechecking and the
:tacn:`refine` tactic. ``"ho-unification"`` prints information
about higher order heuristics.
.. tacn:: apply {+, @one_term_with_bindings } {? @in_hyp_as }
.. insertprodn in_hyp_as as_ipat
.. prodn::
in_hyp_as ::= in {+, @ident {? @as_ipat } }
as_ipat ::= as @simple_intropattern
Uses unification to match the type of each :n:`@one_term`
(in :n:`@one_term_with_bindings`) with the goal
(to do :term:`backward reasoning`) or with a hypothesis (to do :term:`forward reasoning`).
Specifying multiple :n:`@one_term_with_bindings` is equivalent to
giving each one serially, left to right, as separate `apply` tactics.
The type of :n:`@one_term` contains zero or more :term:`premises <premise>`
followed by a :ref:`conclusion <conclusion_meaning_2>`,
i.e. it typically has the form :n:`{? forall @open_binders , } {* @term__premise -> } @term__conclusion`.
(The ``forall``\s may also be interleaved with the premises, but common usage is
to equivalently gather them at the beginning of the :n:`@one_term`.)
Backward reasoning with a :n:`@one_term` whose type is, for example, `A -> B`
replaces an as-yet unproven goal `B` with `A`. Forward reasoning with the same
:n:`@one_term` changes a hypothesis with type `A` to `B`. (Hypotheses are
considered proven propositions within the context that contains them.)
Unification creates a map from the variables in the type of :n:`@one_term`
to matching subterms of the goal or hypothesis.
The matching subterms are then substituted into the type of :n:`@one_term`
when generating the updated goal or hypothesis. Unmatched premises become
new subgoals with similar substitutions. If no match is found, the
tactic fails.
Setting :opt:`Debug` ``"tactic-unification"`` enables printing traces of
unification steps in tactic unification. Tactic unification is used in
tactics such as :tacn:`apply` and :tacn:`rewrite`.
The goal and hypothesis cases are described separately for clarity.
.. _unused1:
.. the dummy ref name is needed to get correct formatting of the next line and "Without..."
:n:`@one_term` (inside :n:`@one_term_with_bindings`)
If :n:`@one_term` is an :n:`@ident`, it is the name of
a theorem, lemma or hypothesis whose type is given in the
theorem statement or shown in the context. Otherwise it is a proof term whose
type can be displayed with :cmd:`Check` :n:`@one_term`.
Without :n:`@in_hyp_as` (the goal case)
If the goal matches all of the type of :n:`@one_term` (both premises and
the conclusion), the tactic proves the goal.
Otherwise, the tactic matches the goal against the conclusion of :n:`@one_term`
and, if possible, one or more premises (from right to left).
If the match succeeds, the tactic replaces the current goal with a subgoal for
each unmatched premise of the type of :n:`@one_term`. This
:ref:`example <apply_backward>` matches only the conclusion, while
this :ref:`one <apply_backward_w_premises>` also matches a premise.
If the conclusion of the type of :token:`one_term` does not match the goal
*and* the conclusion is an inductive type with a single constructor,
then each premise in the constructor is recursively matched to the goal in
right-to-left order and the first match is used. In this case, the tactic
will not match premises that would result in applying a lemma of the form
``forall A, … -> A``. See example :ref:`here <apply_with_iff>`.
.. _apply_with_second_order_unification:
The goal case uses first-order unification with dependent types unless the
conclusion of the type of :token:`term` is of the form
:n:`P t__1 … t__n` with :n:`P` to be instantiated. In the latter case,
the behavior depends on the form of the target. If the target is of the form
:n:`Q u__1 … u__n` and the :n:`t__i` and :n:`u__i` unify,
then :n:`P` is instantiated into :n:`Q`. Otherwise, :tacn:`apply`
tries to define :n:`P` by abstracting over :n:`t__1 … t__n` in the target.
You can use :tacn:`pattern` to transform the target so that it
gets the form :n:`(fun x__1 … x__n => Q) u__1 … u__n`. See the example
:ref:`here <example_apply_pattern>`.
:n:`@in_hyp_as` (the hypothesis case)
Proceeding from *right to left*, find the first premise of the type of
:n:`@one_term` that matches the specified hypothesis. If a match
is found, the hypothesis is replaced with the conclusion of the type of
:n:`@one_term` (substituting for the unified variables)
and the tactic creates a new subgoal for each unmatched premise.
See the example :ref:`here <apply_forward>`.
If specified, :n:`as @simple_intropattern` is applied to the conclusion
of the type of :n:`@one_term`. In this case, the selected hypothesis
is left unchanged if its name is not reused.
If the type of :n:`@one_term` is an inductive type with a single constructor,
then each premise in the constructor is recursively matched to the conclusion
of the hypothesis in right-to-left order and the first match is used.
See example :ref:`here <apply_with_iff>`.
For the hypothesis case, matching is done only with first-order unification.
:n:`with @bindings` (in :n:`@one_term_with_bindings`)
Gives explicit instantiations for variables used in the type of :n:`@one_term`.
There are 3 cases:
- Bindings for variables can be provided in a list of :n:`@one_term`\s
in the left-to-right order of their first appearance in the type of
:n:`@one_term`. For the goal case (:ref:`example <apply_with_binding_goal>`),
the list should give bindings only for variables that aren't bound by
unification. However, in the hypothesis case
(:ref:`example <apply_with_binding_hyp>`),
the list must include bindings for *all* variables.
- Bindings for unbound variables can be given by name with the
:n:`(@ident := @term)` form.
- The form :n:`(@natural := @term)` binds additional variables by
unifying the Nth premise of the type of :n:`@one_term` with :n:`@term`.
(Use `1` for the first premise.)
.. exn:: Unable to unify @one_term with @one_term.
The :tacn:`apply` tactic failed to match the conclusion of :token:`one_term`.
You can help :tacn:`apply` by
transforming your goal with the :tacn:`change` or :tacn:`pattern`
tactics.
.. exn:: Unable to apply lemma of type "..." on hypothesis of type "...".
This happens if the conclusion of :token:`ident` does not match any of
the premises of the type of :token:`one_term`.
.. exn:: Unable to find an instance for the variables {+ @ident}.
This occurs when some instantiations of the premises of :token:`one_term` are not deducible
from the unification. This is the case, for instance, when you want to apply a
transitivity property. To fix this, add bindings for the :n:`@ident`\s using
to :n:`with @bindings` or use :tacn:`eapply`.
.. todo: we should be listing things like "Debug tactic-unification" in
in the options index. Maybe we should add ":debug:" as a new tag.
.. _apply_backward:
.. example:: Backward reasoning in the goal with `apply`
.. coqtop:: reset none
Goal forall A B C: Prop, (A -> B -> C) -> C.
.. coqtop:: out
intros A B C H.
.. coqtop:: all
apply H. (* replace goal with new goals for unmatched premises of H *)
.. _apply_backward_w_premises:
.. example:: Backward reasoning in the goal with `apply` including a premise
.. coqtop:: reset none
Goal forall A B C: Prop, (A -> B -> C) -> (B -> C).
.. coqtop:: out
intros A B C H.
.. coqtop:: all
apply H. (* match on "B -> C", replace goal with "A" *)
.. _apply_forward:
.. example:: Forward reasoning in hypotheses with `apply`
.. coqtop:: reset none
Goal forall A B C: Prop, B -> (A -> B -> C) -> True.
.. coqtop:: out
intros A B C H0 H1.
.. coqtop:: all
apply H1 in H0. (* change H0, create new goals for unmatched premises of H1 *)
.. _apply_with_binding_goal:
.. example:: Apply a theorem with a binding in a goal
:tacn:`apply` unifies the conclusion `n <= p` of the theorem
`le_trans : forall n m p, n <= m -> m <= p -> n <= p`
with the goal, assigning `x * x` and `y * y` in the goal
to, repectively, `n` and `p` in theorem (backward reasoning).
The `with` clause provides the binding for `m`:
.. coqtop:: reset in
Require Import PeanoNat.
.. coqtop:: none
Goal forall (x y : nat), x <= y -> x * x <= y * y.
.. coqtop:: out
intros x y H0.
.. coqtop:: all
apply Nat.le_trans with (y * x).
.. _apply_with_binding_hyp:
.. example:: Apply a theorem with a binding in a hypothesis
When applying a theorem in a hypothesis,
:tacn:`apply` unifies the hypothesis with one of the premises
of the theorem `le_trans : forall n m p, n <= m -> m <= p -> n <= p`.
In this case, it unifies with the first premise
(`n <= m`) and assigns `x * x` and `y * y` to,
respectively, `n` and `m` in the theorem (forward reasoning).
The `with` clause provides the binding for `p`.
In addition, :tacn:`apply` in a hypothesis isn't as flexible as
:tacn:`apply` in the goal: for hypotheses, the unbound variable can be bound
by name (as shown) or values for all the variables can be given
positionally, i.e. `apply Nat.le_trans with (x * x) (y * y) (y * x) in H.`
.. coqtop:: reset in
Require Import PeanoNat.
.. coqtop:: none
Goal forall (x y : nat), x * x <= y * y -> x <= y.
.. coqtop:: out
intros x y H.
.. coqtop:: all
apply Nat.le_trans with (p := y * x) in H.
.. _apply_with_iff:
.. example:: Applying theorems with `<->`
.. Note: :n:`/\` and :n:`/\\` don't give the desired output. A bug.
:n:`A <-> B` is defined as :n:`(A -> B) /\ (B -> A)`.
`/\\` represents an inductive type with a single constructor:
:n:`Inductive and (C D:Prop) : Prop := conj : C -> D -> D /\ C`. The premises
of :n:`conj` are :n:`C` and :n:`D`. The tactic uses the first matching
constructor premise in right-to-left order.
Theorems that use :n:`<->` to state a logical equivalence behave consistently
when applied to goals and hypotheses.
.. coqtop:: reset none
Goal forall (A B: Prop) (H1: A <-> B) (H: A), A.
.. coqtop:: out
intros A B H1 H.
.. coqtop:: all
apply H1.
apply H1 in H.
.. _example_apply_pattern:
.. example:: Special case of second-order unification in apply
Shows the use of the special case second-order unification described
:ref:`here <apply_with_second_order_unification>` (after "unless").
Note that we usually use :tacn:`induction` rather than applying ``nat_ind`` directly.
.. coqtop:: reset none
Goal forall x y, x + y = y + x.
.. coqtop:: out
intros.
.. coqtop:: all
Check nat_ind.
apply nat_ind. (* Notice the goals are unprovable. *)
Show Proof. (* apply has instantiated P with (eq (x + y))
because the goal was (eq (x + y) (y + x))
and n could be unified with (y + x) *)
(* However, we can use the pattern tactic to get the instantiation we want: *)
Undo.
pattern x.
apply nat_ind.
Show Proof. (* apply has instantiated P with (fun n : nat => n + y = y + n)
and the goal can be proven *)
.. tacn:: eapply {+, @one_term_with_bindings } {? @in_hyp_as }
Behaves like :tacn:`apply`, but creates
:ref:`existential variables <Existential-Variables>`
when Coq is unable to deduce instantiations for variables, rather than failing.
.. tacn:: rapply @one_term
Behaves like :tacn:`eapply` but
uses the proof engine of :tacn:`refine` to handle
existential variables, holes and conversion problems. This may
result in slightly different behavior regarding which conversion
problems are solvable. However, :tacn:`rapply` fails if any holes remain
in :n:`@one_term` itself after typechecking and
typeclass resolution but before unification with the goal. Note
that :tacn:`rapply` tries to instantiate as many hypotheses of
:n:`@one_term` as possible. As a result, if it is possible to apply
:n:`@one_term` to arbitrarily many arguments without getting a type
error, :tacn:`rapply` will loop.
.. tacn:: simple apply {+, @one_term_with_bindings } {? @in_hyp_as }
Behaves like :tacn:`apply` but it reasons modulo conversion only on subterms
that contain no variables to instantiate and does not traverse tuples.
For instance, the following example fails because it would require converting
``id ?foo`` and :g:`O`.
.. _simple_apply_ex:
.. example::
.. coqtop:: reset all
Definition id (x : nat) := x.
Parameter H : forall x y, id x = y.
Goal O = O.
Fail simple apply H.
Because it reasons modulo a limited amount of conversion, :tacn:`simple apply` fails
faster than :tacn:`apply` and it is thus well-suited for use in user-defined
tactics that backtrack often.
.. tacn:: simple eapply {+, @one_term_with_bindings } {? @in_hyp_as }
:undocumented:
.. tacn:: lapply @one_term
Splits a :n:`@one_term` in the goal reducible to the form `A -> B`, replacing it
with two new subgoals `A` and `B -> G`.
``lapply H`` (where `H` is `A -> B` and `B` does not start with a product)
is equivalent to :tacn:`cut` ``B. 2:apply H.``.
.. exn:: lapply needs a non-dependent product.
:undocumented:
.. example::
Assume we have a transitive relation ``R`` on ``nat``:
.. coqtop:: reset in
Parameter R : nat -> nat -> Prop.
Axiom Rtrans : forall x y z:nat, R x y -> R y z -> R x z.
Parameters n m p : nat.
Axiom Rnm : R n m.
Axiom Rmp : R m p.
Consider the goal ``(R n p)`` provable using the transitivity of ``R``:
.. coqtop:: in
Goal R n p.
The direct application of ``Rtrans`` with ``apply`` fails because no value
for ``y`` in ``Rtrans`` is found by ``apply``:
.. coqtop:: all fail
apply Rtrans.
A solution is to ``apply (Rtrans n m p)`` or ``(Rtrans n m)``.
.. coqtop:: all
apply (Rtrans n m p).
Note that ``n`` can be inferred from the goal, so the following would work
too.
.. coqtop:: in restart
apply (Rtrans _ m).
More elegantly, ``apply Rtrans with (y:=m)`` allows only mentioning the
unknown m:
.. coqtop:: in restart
apply Rtrans with (y := m).
Another solution is to mention the proof of ``(R x y)`` in ``Rtrans``
.. coqtop:: all restart
apply Rtrans with (1 := Rnm).
… or the proof of ``(R y z)``.
.. coqtop:: all restart
apply Rtrans with (2 := Rmp).
On the opposite, one can use ``eapply`` which postpones the problem of
finding ``m``. Then one can apply the hypotheses ``Rnm`` and ``Rmp``. This
instantiates the existential variable and completes the proof.
.. coqtop:: all restart abort
eapply Rtrans.
apply Rnm.
apply Rmp.
.. todo the following title isn't the greatest. Perhaps more like "trivial tactics"
or "simple tactics"???
.. _managingthelocalcontext:
Managing the local context
------------------------------
.. tacn:: intro {? @ident } {? @where }
Applies the :tacn:`hnf` tactic until it finds an item that can be
introduced in the context by removing certain constructs in the goal.
If no item is found, the tactic fails. The name used is
:n:`@ident` (if specified) or from the construct, except that if the name from the
construct already exists in the :term:`local context`, Coq uses a fresh name
instead. The constructs have these forms:
(See examples :ref:`here <intro_examples>`.)
:n:`forall x : T, @term`
`x : T` is a :term:`dependent premise`. Removes `forall x : T,`
from the goal and adds `x : T` to the context.
:n:`A -> …`
`A` is a :term:`non-dependent premise`. Removes `A ->` from
the goal and adds `H : A` to the context.
:n:`let x := c, @term`
Removes `let x := c,` from the goal and adds `x := c : T` to the context.
.. _warn_should_give_name_in_intro:
We recommend always specifying :n:`@ident` so that the names of hypotheses don't
change as the proof is updated, making your proof easier to maintain. For example,
if H exists in the context, Coq will consider using `H0`, `H1`, ... until it finds an
unused name. Modifications to a proof can change automatically assigned names
that subsequent tactics likely refer to, making the proofs harder to maintain. The
:flag:`Mangle Names` flag gives some control over how fresh names are generated (see
:ref:`proof-maintenance`).
Note that :tacn:`intros` lets you introduce multiple items into
the context with a single tactic.
:n:`@ident`
The name to give to the introduced item. If not given, Coq uses the
variable name from the :n:`forall` or `H` for premises.
If a name such as `H` is already in use, Coq will consider using `H0`,
`H1`, ... until it finds a fresh name.
.. note::
If a hypothesis name hides the base name of a global constant then
the latter can still be referred to by a qualified name
(see :ref:`Qualified-names`).
:n:`@where`
Indicates where to place the introduced hypothesis: at the top or bottom
of the context or before or after another specified hypothesis. The default
is `at bottom`.
.. exn:: @ident is already used.
The provided :n:`@ident` is already used in the :term:`local context`.
.. exn:: No product even after head-reduction.
There is nothing to introduce even after :tacn:`hnf` has been completely applied.
.. _intro_examples:
.. example:: `intro` and `intros`
.. coqtop:: reset out
Goal forall m n, m < n -> (let x := 0 in True).
.. coqtop:: all
intro m.
intro n.
intro H.
intro x.
This single `intros` tactic is equivalent to the 4 preceding `intro` tactics:
.. coqtop:: reset out
Goal forall m n, m < n -> (let x := 0 in True).
.. coqtop:: all
intros m n H x.
.. tacn:: intros {* @intropattern }
intros until {| @ident | @natural }
The first form introduces zero or more items into the context from the
constructs listed in :tacn:`intro`. If :n:`@intropattern` is not specified,
the tactic introduces items until it reaches the :term:`head constant`;
it never fails and may leave the context unchanged.
If :n:`@intropattern` is specified, the :tacn:`hnf` tactic is applied until
it finds an item that can be introduced into the context.
The :n:`@intropattern` is
often just a list of :n:`@ident`\s, but other forms can also be specified
in order to, for example, introduce all :term:`dependent premises <dependent premise>` (`*`);
introduce all dependent and :term:`non-dependent premises <non-dependent premise>` (`**`);
split terms such as `A /\\ B` (`[]`) and pick a fresh name with a given prefix (`?X`).
See :ref:`intropatterns`.
The second form repeats :n:`intro` until it has introduced a :term:`dependent premise`
with the name :n:`@ident` or has introduced
:n:`@natural` :term:`premises <premise>` (like ``A`` in ``A -> B``).
We recommend explicitly naming items with :tacn:`intros` instead of using
:n:`intros until @natural`. See the explanation :ref:`here <warn_should_give_name_in_intro>`.
.. example:: intros until
.. coqtop:: reset out
Goal forall x y : nat, x = y -> y = x.
.. coqtop:: all
intros until y.
Or:
.. coqtop:: reset out
Goal forall x y : nat, x = y -> y = x.
.. coqtop:: all
intros until 1.
.. exn:: No quantified hypothesis named @ident in current goal even after head-reduction.
The :n:`@ident` in the ``until`` clause doesn't appear as a :term:`dependent premise`.
.. exn:: No @natural-th non dependent hypothesis in current goal even after head-reduction.
There are fewer than :n:`@natural` premises in the goal.
.. tacn:: eintros {* @intropattern }
Works just like :tacn:`intros` except that it creates existential variables
for any unresolved variables rather than failing. Typically this happens when
using a ``%`` intropattern (see :n:`@simple_intropattern`).
.. tacn:: clear {? {? - } {+ @ident } }
Erases *unneeded* hypotheses from the context of the current goal. "Unneeded"
means that the unselected hypotheses and the goal don't depend directly or
indirectly on the erased hypotheses. That means the hypotheses will no longer
appear in the context and therefore can't be used in subsequent proof steps.
Note that erasing an uneeded hypothesis may turn a goal that was provable
into an unprovable goal.
:n:`clear`
All unneeded hypotheses are erased. This may leave the context unchanged; this form
never fails.
:n:`clear {+ @ident }`
Erases the named hypotheses if they are unneeded and fails otherwise.
.. exn:: @ident is used in the conclusion.
:undocumented:
.. exn:: @ident is used in the hypothesis @ident.
:undocumented:
:n:`clear - {+ @ident }`
Selects all hypotheses that are not named by the :n:`@ident`\s, then
erases those that are unneeded.
This may leave the context unchanged; this form never fails as long as the
:n:`@ident`\s name hypotheses in the context.
.. tacn:: clearbody {+ @ident }
This tactic expects :n:`{+ @ident}` to be :term:`local definitions <context-local definition>`
and clears their respective bodies.
In other words, it turns the given definitions into assumptions.
.. exn:: @ident is not a local definition.
:undocumented:
.. tacn:: clear dependent @ident
Clears the hypothesis :token:`ident` and all the hypotheses that depend on it.
.. tacn:: revert {+ @ident }
Moves the specified hypotheses and :term:`local definitions <context-local definition>`
to the goal, if this respects dependencies. This is
the inverse of :tacn:`intro`.
.. tacn:: revert dependent @ident
.. deprecated:: 8.18
An alias for :tacn:`generalize dependent`.
.. tacn:: move @ident__from @where
.. insertprodn where where
.. prodn::
where ::= at top
| at bottom
| before @ident
| after @ident
Moves a hypothesis :n:`@ident__from` and hypotheses that directly or indirectly
refer to :n:`@ident__from` that appear between :n:`@ident__from` and :n:`@ident`.
`at top` and `at bottom` are
equivalent to giving the name of the first or last hypotheses in the context. The
dependent hypotheses will appear after :n:`@ident__from`, appearing in dependency order.
This lets users show and group hypotheses in the order they prefer. It doesn't
change the goal or the proof term.
.. todo: "at top and at bottom are equivalent to giving the name of the first or
last hypotheses in the context." Equivalent to "after first" and
"after last"??
.. note::
Perhaps confusingly, "before" and "after" are interpeted with respect to the direction
in which the hypotheses are moved rather than in the order of the resulting
list of hypotheses. If :n:`@ident__from` is before :n:`@ident` in the context, these
notions are the
same: for hypotheses `A B C`, `move A after B` gives `B A C`, whereas if :n:`@ident__from`
is after :n:`@ident` in the context, they are the opposite: `move C after A` gives
`C A B` because the direction of movement is reversed.
.. todo This is dreadful behavior
.. exn:: Cannot move @ident__from after @ident: it occurs in the type of @ident.
:undocumented:
.. exn:: Cannot move @ident__from after @ident: it depends on @ident.
:undocumented:
.. example:: move
.. coqtop:: reset none
Goal forall x :nat, x = 0 -> forall y z:nat, y=y-> 0=x.
.. coqtop:: out
intros x Hx y z Hy.
.. coqtop:: in
(* x Hx y z Hy *)
move y after z. (* x Hx z y Hy (z was left of y, intuitive case) *)
Undo.
move z after y. (* x Hx z y Hy (z was right of y, see Note above) *)
Undo.
move x after Hy. (* y z Hy x Hx (Hx depends on x, so moved) *)
Undo.
move x before Hy. (* y z x Hx Hy *)
Undo.
move Hy after Hx. (* x y Hy Hx z *)
Undo.
move Hy before Hx. (* x Hx y Hy z *)
.. tacn:: rename {+, @ident__1 into @ident__2 }
Renames hypothesis :n:`@ident__1` into :n:`@ident__2` for each pair of :n:`@ident`\s.
Renaming is done simultaneously, which permits swapping the names of 2 hypotheses.
(Note that the renaming is applied in the context and the existential
variables, but the proof term doesn't change.)
.. tacn:: set @alias_definition {? @occurrences }
set @one_term {? @as_name } {? @occurrences }
:name: set; _
.. insertprodn alias_definition as_name
.. prodn::
alias_definition ::= ( @ident {* @simple_binder } := @term )
simple_binder ::= @name
| ( {+ @name } : @term )
as_name ::= as @ident
The first form adds a new local definition :n:`@ident := …`. If
:n:`@simple_binder` is not specified, the definition body is :n:`@term` and
otherwise :n:`fun {* @simple_binder } => @term`. Then the tactic replaces
the body expression with the new variable :n:`@ident` in the goal or as
specified by :n:`@occurrences`. The tactic may succeed and add the local
definition even if no replacements are made.
The second form is equivalent to :n:`set (@ident := @one_term) {? @occurrences }`
using :n:`@ident`, if present, or an auto-generated name if not provided.
If :token:`term` or :token:`one_term` has holes (i.e. subexpressions with the
form “`_`”), the tactic first checks that all subterms matching the pattern
are compatible before doing the replacement using the leftmost subterm
matching the pattern.
.. exn:: The variable @ident is already declared.
:undocumented:
.. example:: set with a :n:`@simple_binder`
:n:`set` does a simple syntactic replacement in the goal:
.. coqtop:: reset none
Goal forall n, n = 0.
.. coqtop:: out
intros.
.. coqtop:: all
pattern n. (* without this, "set" won't replace anything in the goal *)
set (f x := x = 0).
.. tacn:: eset @alias_definition {? @occurrences }
eset @one_term {? @as_name } {? @occurrences }
:name: eset; _
Similar to :tacn:`set`, but instead of failing because of uninstantiated
variables, generates existential variables for them.
In practice, this is relevant only when :tacn:`eset` is
used as a synonym of :tacn:`epose`, i.e. when the :token:`term` does
not occur in the goal.
.. tacn:: remember @one_term {? @as_name } {? eqn : @naming_intropattern } {? in @goal_occurrences }
Similar to :n:`set (@ident := @one_term) in *` but creates a hypothesis using
:term:`Leibniz equality` to remember the relation between the introduced
variable and the term rather than creating a
:term:`local definition <context-local definition>`. If :n:`@as_name` is not
specified a fresh name is used.
Use :n:`@naming_intropattern` to name the new equation.
.. tacn:: eremember @one_term {? @as_name } {? eqn : @naming_intropattern } {? in @goal_occurrences }
Similar to :tacn:`remember`, but instead of failing because of uninstantiated
variables, generates existential variables for them.
.. tacn:: pose @alias_definition
pose @one_term {? @as_name }
:name: pose; _
Similar to :tacn:`set`. Adds a :term:`local definition <context-local definition>`
to the context but without doing any replacement.
.. tacn:: epose @alias_definition
epose @one_term {? @as_name }
:name: epose; _
Similar to :tacn:`pose`, but instead of failing because of uninstantiated
variables, generates existential variables for them.
.. todo: the following title seems inappropriate. How about something
more like "Introducing new hypotheses", as in adding arbitrary terms rather
than transformations of existing terms?? But then I think the tactics in the
previous section (set, remember, pose, maybe decompose) should be moved into
this section. But maybe hard to make the section seem like an crisp, intuitive grouping.
I can do the moving that after we've reviewed all the text. WDYT?
See https://github.com/coq/coq/pull/16498#discussion_r989928078
.. _controllingtheproofflow:
Controlling the proof flow
------------------------------
.. tacn:: assert ( @ident : @type ) {? by @ltac_expr3 }
assert ( @ident := @term )
assert @one_type {? @as_ipat } {? by @ltac_expr3 }
:name: assert; _; _
Adds a new hypothesis to the current subgoal and a new subgoal before
it to prove the hypothesis. Then, if :n:`@ltac_expr3`
is specified, it applies that tactic to fully prove the new subgoal (and
otherwise fails).
The first form adds a new hypothesis named :n:`@ident` of type :n:`@type`.
(This corresponds to the cut rule of sequent calculus.)
The second form is equivalent to :n:`assert (@ident : @type) by exact (@term)` where
:n:`@type` is the type of :n:`@term`. It is also equivalent to using
:tacn:`pose proof`. If the head of :n:`@term` is :n:`@ident`, the tactic
is equivalent to :tacn:`specialize`.
In the third form, if :n:`@as_ipat` isn't specified, the tactic adds the
hypothesis :n:`@one_type` with a fresh name. Otherwise, it transforms the
hypothesis as specified by :n:`@as_ipat` and adds the resulting new hypotheses
and goals. See :ref:`intropatterns`.
.. exn:: The term "@type" has type "@type__1" which should be Set, Prop or Type.
Occurs when the argument :n:`@type` (in the first form) or :n:`@one_type`
(in the third form) is not of type :g:`Prop`, :g:`Set` nor :g:`Type`.
.. exn:: Proof is not complete.
:name: Proof is not complete. (assert)
:n:`@ltac_expr3` was not able to prove the new hypothesis.
.. tacn:: eassert ( @ident : @type ) {? by @ltac_expr3 }
eassert ( @ident := @term )
eassert @one_type {? @as_ipat } {? by @ltac_expr3 }
:name: eassert; _; _
Unlike :tacn:`assert`, the :n:`@type`, :n:`@term` or :n:`@one_type` in
:tacn:`eassert` may contain :gdef:`holes <hole>`, denoted by :n:`_`,
for which the tactic will create existential variables. This lets you
avoid specifying the asserted statement completely before starting to
prove it.
.. tacn:: enough ( @ident : @type ) {? by @ltac_expr3 }
enough @one_type {? @as_ipat } {? by @ltac_expr3 }
:name: enough; _
Adds a new hypothesis to the current subgoal and a new subgoal after it
to prove the hypothesis.
The first form adds a new hypothesis :n:`@ident : @type`
and :n:`@type` as the new subgoal. Then, if :n:`@ltac_expr3` is
specified, it applies that tactic to prove the current subgoal
with the added hypothesis (and otherwise fails).
In the second form, if :n:`@as_ipat` isn't specified, the tactic adds a new
hypothesis :n:`@one_type` with a name chosen by Coq. Otherwise, it transforms
:n:`@one_type` as specified by :n:`@as_ipat` and adds the resulting new hypotheses.
The :n:`@as_ipat` may also expand the current subgoal into multiple subgoals.
Then, if :n:`@ltac_expr3` is specified, it is applied to and must succeed on all
of them.
.. tacn:: eenough ( @ident : @type ) {? by @ltac_expr3 }
eenough @one_type {? @as_ipat } {? by @ltac_expr3 }
:name: eenough; _
Unlike :tacn:`enough`, the :n:`@type` and :n:`@one_type` in
:tacn:`eenough` may contain :term:`holes <hole>`, denoted by :n:`_`,
for which the tactic will create existential variables. This lets you
avoid specifying the asserted statement completely until you start to use
the hypothesis or later start to prove the statement.
.. tacn:: cut @one_type
Implements the non-dependent case of the :ref:`App <app_rule>` typing rule,
the Modus Ponens inference rule. It is equivalent to
:n:`enough (@ident: @one_type). revert @ident.`
This tactic is generally considered obsolete but it is still widely
used in old scripts.
.. tacn:: pose proof @term {? @as_ipat }
pose proof ( @ident := @term )
:name: pose proof; _
The first form behaves like :n:`assert @one_type {? @as_ipat } by exact @term`
where :token:`one_type` is the type of :token:`term`.
.. Théo notes it's odd that the first form uses @term instead of @one_term
The second form is equivalent to :n:`assert (@ident := @term)`.
.. tacn:: epose proof @term {? @as_ipat }
epose proof ( @ident := @term )
:name: epose proof; _
While :tacn:`pose proof` expects that no existential variables are generated by
the tactic, :tacn:`epose proof` removes this constraint.
.. tacn:: specialize @one_term_with_bindings {? @as_ipat }
Specializes a term (typically a hypothesis or a lemma) by applying arguments to it.
*First*, the tactic generates a modified term:
If the :term:`head constant` of :n:`@one_term` (in :n:`@one_term_with_bindings`)
has the type `forall ...`, the tactic replaces one or more of the
quantified variables in the type with arguments provided by
:n:`@one_term_with_bindings`, either in the form of a
:ref:`function application <function_application>` (which may be partial),
such as `(H 1)`, or with named or numbered binders, such as `H with (n:=1)`.
If the :term:`head constant` has a :term:`non-dependent product` type such as
`A -> B -> C`, the tactic eliminates one or more of the premises
(doing :term:`forward reasoning`).
Uninstantiated arguments are inferred by unification, if possible, or otherwise
left quantified in the resulting term.
*Then*, If the :term:`head constant` is a hypothesis :n:`H`, the resulting
term replaces that hypothesis. Specifying :n:`@as_ipat` will leave the original
hypothesis unchanged and will introduce new hypotheses as specified by the
:token:`simple_intropattern`. If :n:`H` appears in the conclusion or another
hypothesis, you must use :n:`@as_ipat` to give a fresh hypothesis name.
If the head constant is a lemma or theorem, the resulting term
is added as a new premise of the goal so that the behavior is similar
to that of :tacn:`generalize`. In this case, you can use :n:`@as_ipat` to
immediately introduce the modified term as one or more hypotheses.
.. exn:: Cannot change @ident, it is used in hypothesis @ident.
:undocumented:
.. exn:: Cannot change @ident, it is used in conclusion.
:undocumented:
.. example:: partial application in :tacn:`specialize`
.. coqtop:: reset none
Goal (forall n m: nat, n + m = m + n) -> True.
.. coqtop:: out
intros.
.. coqtop:: all
specialize (H 1). (* equivalent to: specialize H with (n := 1) *)
.. example:: :tacn:`specialize` with a non-dependent product
Compare this to a similar :ref:`example <apply_forward>` that uses
:tacn:`apply`. :tacn:`specialize` won't introduce new goals as
:tacn:`apply` can.
.. coqtop:: reset none
Goal forall A B C: Prop, B -> (A -> B -> C) -> True.
Proof.
.. coqtop:: out
intros A B C H0 H1.
.. coqtop:: all
specialize H1 with (2:=H0).
.. tacn:: specialize_eqs @ident
:undocumented:
.. tacn:: generalize {+ @one_term }
generalize {+, @pattern_occs {? @as_name } }
:name: generalize; _
For each :n:`@one_term` (which may be in the :n:`@pattern_occs`), replaces the
goal `G` with `forall (x:T), G'`,
where :n:`@one_term` is a subterm of `G` of type `T` and `G'` is obtained
by replacing all occurrences of :n:`@one_term` with `x` within `G`. `x` is
a fresh variable chosen based on `T`. Specifying multiple :n:`@one_term`\s is
equivalent to :n:`generalize @one_term__n; … ; generalize @one_term__1`.
(Note they are processed *right to left*.)
:n:`@as_name`
The name to use for `x` instead of a fresh name.
.. example::
.. coqtop:: reset none
Goal forall x y:nat, 0 <= x + y + y.
Proof. intros *.
.. coqtop:: out
Show.
.. coqtop:: all abort
generalize (x + y + y). (* get a simpler goal that can be proven by induction *)
.. tacn:: generalize dependent @one_term
Generalizes :n:`@one_term` and all hypotheses that depend on :n:`@one_term`. It
clears the generalized hypotheses.
.. tacn:: dependent generalize_eqs @ident
:undocumented:
.. tacn:: dependent generalize_eqs_vars @ident
:undocumented:
.. tacn:: generalize_eqs @ident
:undocumented:
.. tacn:: generalize_eqs_vars @ident
:undocumented:
.. tacn:: evar ( @ident : @type )
evar @one_type
:name: evar; _
The :n:`evar` tactic creates a new :term:`local definition <context-local definition>`
named :n:`@ident` with type :n:`@type` or :n:`@one_type` in the context.
The body of this binding is a fresh existential variable. If the second
form is used, Coq chooses the name.
.. tacn:: instantiate ( @ident := @term )
instantiate ( @natural := @term ) {? @hloc }
:name: instantiate; _
.. insertprodn hloc hloc
.. prodn::
hloc ::= in %|- *
| in @ident
| in ( type of @ident )
| in ( value of @ident )
The first form refines (see :tacn:`refine`) an existential variable
:n:`@ident` with the term :n:`@term`. It is equivalent to
:n:`only [@ident]: refine @term`.
.. note:: To be able to refer to an existential variable by name, the user
must have given the name explicitly (see :ref:`Existential-Variables`).
.. note:: When you are referring to hypotheses which you did not name
explicitly, be aware that Coq may make a different decision on how to
name the variable in the current goal and in the context of the
existential variable. This can lead to surprising behaviors.
The second form refines an existential variable selected by its position. The
:n:`@natural` argument is the position of the existential variable
*from right to left* in the goal. (Use the :n:`@hloc` clause
to select an existential variable in a
hypothesis.) Counting starts at 1 and multiple occurrences of the
same existential variable are counted multiple times. Using this form
is discouraged because slight changes to the goal may change the needed index,
causing a maintenance issue.
Advanced users may want to define and use an Ltac tactic to get more consistent
behavior, such as:
.. coqdoc::
Ltac instantiate_ltac_variable ev term :=
let H := fresh in
pose ev as H;
instantiate (1 := term) in (value of H);
clear H.
:n:`in @ident`
Selects the hypothesis :n:`@ident`.
:n:`in %|- *`
Selects the goal. This is the default behavior.
:n:`in ( type of @ident )`
Selects existential variables in the type of the
:term:`local definition <context-local definition>` :n:`@ident`.
(The body is not included.)
:n:`in ( value of @ident )`
Selects existential variables in the body of the
:term:`local definition <context-local definition>` :n:`@ident`.
(The type is not included.)
.. tacn:: absurd @one_type
:n:`@one_type` is any proposition
:g:`P` of type :g:`Prop`. This tactic applies False elimination, that is it
deduces the current goal from False, and generates as subgoals :g:`∼P` and
:g:`P`. It is very useful in proofs by cases, where some cases are
impossible. In most cases, :g:`P` or :g:`∼P` is one of the hypotheses of the
local context.
.. tacn:: contradiction {? @one_term_with_bindings }
Tries to prove the current goal by finding a contradiction.
If :n:`@one_term_with_bindings` is not provided (the most common use case),
the tactic first does an :tacn:`intros`. The tactic then proves the goal if
- the updated context has a pair of hypotheses where one is the negation of
the other (e.g. :n:`P` and not :n:`~P`), or
- there is a hypothesis with an empty inductive type (e.g. :n:`False`), or
- there is a hypothesis :n:`~P` where `P` is a singleton inductive type
(e.g. :n:`True` or :n:`x=x`) provable by `Goal P. constructor.`
If :n:`@one_term_with_bindings` is provided, its type
must be a negation, such as :n:`~P`,
or an empty inductive type, such as :n:`False`.
If the type is a negation and :n:`P` is a hypothesis in the context,
the goal is proven. If the type is a negation and :n:`P` is not in
the context, the goal is replaced with :n:`P`. If the type is :n:`False`
or another empty inductive type, the goal is proven.
Otherwise the tactic fails. (If there is a hypothesis
`P` and you want to replace the goal with `~P`, use the :tacn:`contradict`
tactic. If there are hypotheses `H1 : P` and `H2 : ~P`, use `contradiction`
without arguments or `contradiction H2` since `contradiction H1` won't work.)
Use the :tacn:`discriminate` tactic to prove the current goal when there
is a hypothesis with an impossible structural equality such as
:n:`0 = 1`.
.. example:: :tacn:`contradiction` tactic
Simple examples. To see more detail, add `intros` after each `Goal`.
.. coqtop:: reset in
Inductive F :=. (* Another empty inductive type *)
Goal F -> False.
contradiction.
Qed.
Goal forall (A : Prop), A -> ~A -> False.
contradiction.
Qed.
Goal forall (A : Type) (x : A), ~(x = x) -> False.
contradiction.
Qed.
Apply a fact from the standard library:
.. coqtop:: in
Require Import Arith.
Goal forall (A : Prop), 0 < 0 -> A.
.. coqtop:: all
intros.
contradiction (Nat.lt_irrefl 0).
Qed.
.. tacn:: contradict @ident
Transforms the specified hypothesis :n:`@ident` and the goal in order to
prove that the hypothesis is false. For :n:`contradict H`, the
current goal and context are transformed as shown. (For brevity,
`⊢` is used to separate hypotheses from the goal; it is equivalent to the
dividing line shown in a context.):
+ `H: ~A ⊢ B` becomes `⊢ A`
+ `H: ~A ⊢ ~B` becomes `H: B ⊢ A`
+ `H: A ⊢ B` becomes `⊢ ~A`
+ `H: A ⊢ ~B` becomes `H: B ⊢ ~A`
.. tacn:: exfalso
Implements the “ex falso quodlibet” logical principle: an
elimination of False is performed on the current goal, and the user is
then required to prove that False is indeed provable in the current
context.
Classical tactics
-----------------
In order to ease the proving process, when the ``Classical`` module is
loaded, a few more tactics are available. Make sure to load the module
using the :cmd:`Require Import` command.
.. tacn:: classical_left
classical_right
These tactics are the analog of :tacn:`left` and :tacn:`right`
but using classical logic. They can only be used for
disjunctions. Use :tacn:`classical_left` to prove the left part of the
disjunction with the assumption that the negation of right part holds.
Use :tacn:`classical_right` to prove the right part of the disjunction with
the assumption that the negation of left part holds.
Performance-oriented tactic variants
------------------------------------
.. todo: move the following adjacent to the `exact` tactic?
.. tacn:: exact_no_check @one_term
For advanced usage. Similar to :tacn:`exact` :n:`@term`, but as an optimization,
it skips checking that :n:`@term` has the goal's type, relying on the kernel
check instead. See :tacn:`change_no_check` for more explanation.
.. example::
.. coqtop:: all abort
Goal False.
exact_no_check I.
Fail Qed.
.. tacn:: vm_cast_no_check @one_term
For advanced usage. Similar to :tacn:`exact_no_check` :n:`@term`, but additionally
instructs the kernel to use :tacn:`vm_compute` to compare the
goal's type with the :n:`@term`'s type.
.. example::
.. coqtop:: all abort
Goal False.
vm_cast_no_check I.
Fail Qed.
.. tacn:: native_cast_no_check @one_term
for advanced usage. similar to :tacn:`exact_no_check` :n:`@term`, but additionally
instructs the kernel to use :tacn:`native_compute` to compare the goal's
type with the :n:`@term`'s type.
.. example::
.. coqtop:: all abort
Goal False.
native_cast_no_check I.
Fail Qed.
|