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 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016
# 11 "plugins/ltac/extratactics.mlg" open Pp open Constr open Context open Genarg open Stdarg open Tacarg open Extraargs open Pltac open Mod_subst open Names open Tacexpr open Glob_ops open CErrors open Util open Termops open Equality open Namegen open Tactypes open Tactics open Proofview.Notations open Attributes open Vernacextend let wit_hyp = wit_var let __coq_plugin_name = "ltac_plugin" let _ = Mltop.add_known_module __coq_plugin_name # 42 "plugins/ltac/extratactics.mlg" (**********************************************************************) (* replace, discriminate, injection, simplify_eq *) (* cutrewrite, dependent rewrite *) let with_delayed_uconstr ist c tac = let flags = { Pretyping.use_typeclasses = false; solve_unification_constraints = true; fail_evar = false; expand_evars = true; program_mode = false; polymorphic = false; } in let c = Tacinterp.type_uconstr ~flags ist c in Tacticals.New.tclDELAYEDWITHHOLES false c tac let replace_in_clause_maybe_by ist c1 c2 cl tac = with_delayed_uconstr ist c1 (fun c1 -> replace_in_clause_maybe_by c1 c2 cl (Option.map (Tacinterp.tactic_of_value ist) tac)) let replace_term ist dir_opt c cl = with_delayed_uconstr ist c (fun c -> replace_term dir_opt c cl) let () = Tacentries.tactic_extend __coq_plugin_name "replace" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("replace", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_uconstr), Tacentries.TyIdent ("with", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_constr), Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_clause), Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_by_arg_tac), Tacentries.TyNil)))))), (fun c1 c2 cl tac ist -> # 71 "plugins/ltac/extratactics.mlg" replace_in_clause_maybe_by ist c1 c2 cl tac )))] let () = Tacentries.tactic_extend __coq_plugin_name "replace_term_left" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("replace", Tacentries.TyIdent ("->", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_uconstr), Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_clause), Tacentries.TyNil)))), (fun c cl ist -> # 76 "plugins/ltac/extratactics.mlg" replace_term ist (Some true) c cl )))] let () = Tacentries.tactic_extend __coq_plugin_name "replace_term_right" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("replace", Tacentries.TyIdent ("<-", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_uconstr), Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_clause), Tacentries.TyNil)))), (fun c cl ist -> # 81 "plugins/ltac/extratactics.mlg" replace_term ist (Some false) c cl )))] let () = Tacentries.tactic_extend __coq_plugin_name "replace_term" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("replace", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_uconstr), Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_clause), Tacentries.TyNil))), (fun c cl ist -> # 86 "plugins/ltac/extratactics.mlg" replace_term ist None c cl )))] # 89 "plugins/ltac/extratactics.mlg" let induction_arg_of_quantified_hyp = function | AnonHyp n -> None,ElimOnAnonHyp n | NamedHyp id -> None,ElimOnIdent (CAst.make id) (* Versions *_main must come first!! so that "1" is interpreted as a ElimOnAnonHyp and not as a "constr", and "id" is interpreted as a ElimOnIdent and not as "constr" *) let mytclWithHoles tac with_evars c = Proofview.Goal.enter begin fun gl -> let env = Tacmach.New.pf_env gl in let sigma = Tacmach.New.project gl in let sigma',c = Tactics.force_destruction_arg with_evars env sigma c in Tacticals.New.tclWITHHOLES with_evars (tac with_evars (Some c)) sigma' end let elimOnConstrWithHoles tac with_evars c = Tacticals.New.tclDELAYEDWITHHOLES with_evars c (fun c -> tac with_evars (Some (None,ElimOnConstr c))) let () = Tacentries.tactic_extend __coq_plugin_name "simplify_eq" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("simplify_eq", Tacentries.TyNil), (fun ist -> # 114 "plugins/ltac/extratactics.mlg" dEq ~keep_proofs:None false None ))); (Tacentries.TyML (Tacentries.TyIdent ("simplify_eq", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_destruction_arg), Tacentries.TyNil)), (fun c ist -> # 115 "plugins/ltac/extratactics.mlg" mytclWithHoles (dEq ~keep_proofs:None) false c )))] let () = Tacentries.tactic_extend __coq_plugin_name "esimplify_eq" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("esimplify_eq", Tacentries.TyNil), (fun ist -> # 118 "plugins/ltac/extratactics.mlg" dEq ~keep_proofs:None true None ))); (Tacentries.TyML (Tacentries.TyIdent ("esimplify_eq", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_destruction_arg), Tacentries.TyNil)), (fun c ist -> # 119 "plugins/ltac/extratactics.mlg" mytclWithHoles (dEq ~keep_proofs:None) true c )))] # 122 "plugins/ltac/extratactics.mlg" let discr_main c = elimOnConstrWithHoles discr_tac false c let () = Tacentries.tactic_extend __coq_plugin_name "discriminate" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("discriminate", Tacentries.TyNil), (fun ist -> # 129 "plugins/ltac/extratactics.mlg" discr_tac false None ))); (Tacentries.TyML (Tacentries.TyIdent ("discriminate", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_destruction_arg), Tacentries.TyNil)), (fun c ist -> # 131 "plugins/ltac/extratactics.mlg" mytclWithHoles discr_tac false c )))] let () = Tacentries.tactic_extend __coq_plugin_name "ediscriminate" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("ediscriminate", Tacentries.TyNil), (fun ist -> # 134 "plugins/ltac/extratactics.mlg" discr_tac true None ))); (Tacentries.TyML (Tacentries.TyIdent ("ediscriminate", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_destruction_arg), Tacentries.TyNil)), (fun c ist -> # 136 "plugins/ltac/extratactics.mlg" mytclWithHoles discr_tac true c )))] # 139 "plugins/ltac/extratactics.mlg" let discrHyp id = Proofview.tclEVARMAP >>= fun sigma -> discr_main (fun env sigma -> (sigma, (EConstr.mkVar id, NoBindings))) let injection_main with_evars c = elimOnConstrWithHoles (injClause None None) with_evars c let isInjPat pat = match pat.CAst.v with IntroAction (IntroInjection _) -> Some pat.CAst.loc | _ -> None let decode_inj_ipat ?loc = function (* For the "as [= pat1 ... patn ]" syntax *) | [{ CAst.v = IntroAction (IntroInjection ipat) }] -> ipat (* For the "as pat1 ... patn" syntax *) | ([] | [_]) as ipat -> ipat | pat1::pat2::_ as ipat -> (* To be sure that there is no confusion of syntax, we check that no [= ...] occurs in the non-singleton list of patterns *) match isInjPat pat1 with | Some _ -> user_err ?loc:pat2.CAst.loc (str "Unexpected pattern.") | None -> match List.map_filter isInjPat ipat with | loc :: _ -> user_err ?loc (str "Unexpected injection pattern.") | [] -> ipat let () = Tacentries.tactic_extend __coq_plugin_name "injection" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("injection", Tacentries.TyNil), (fun ist -> # 168 "plugins/ltac/extratactics.mlg" injClause None None false None ))); (Tacentries.TyML (Tacentries.TyIdent ("injection", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_destruction_arg), Tacentries.TyNil)), (fun c ist -> # 169 "plugins/ltac/extratactics.mlg" mytclWithHoles (injClause None None) false c )))] let () = Tacentries.tactic_extend __coq_plugin_name "einjection" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("einjection", Tacentries.TyNil), (fun ist -> # 172 "plugins/ltac/extratactics.mlg" injClause None None true None ))); (Tacentries.TyML (Tacentries.TyIdent ("einjection", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_destruction_arg), Tacentries.TyNil)), (fun c ist -> # 173 "plugins/ltac/extratactics.mlg" mytclWithHoles (injClause None None) true c )))] let () = Tacentries.tactic_extend __coq_plugin_name "injection_as" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("injection", Tacentries.TyIdent ("as", Tacentries.TyArg ( Extend.TUlist0 ( Extend.TUentry (Genarg.get_arg_tag wit_simple_intropattern)), Tacentries.TyNil))), (fun ipat ist -> # 177 "plugins/ltac/extratactics.mlg" injClause None (Some (decode_inj_ipat ipat)) false None ))); (Tacentries.TyML (Tacentries.TyIdent ("injection", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_destruction_arg), Tacentries.TyIdent ("as", Tacentries.TyArg ( Extend.TUlist0 ( Extend.TUentry (Genarg.get_arg_tag wit_simple_intropattern)), Tacentries.TyNil)))), (fun c ipat ist -> # 179 "plugins/ltac/extratactics.mlg" mytclWithHoles (injClause None (Some (decode_inj_ipat ipat))) false c )))] let () = Tacentries.tactic_extend __coq_plugin_name "einjection_as" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("einjection", Tacentries.TyIdent ("as", Tacentries.TyArg ( Extend.TUlist0 ( Extend.TUentry (Genarg.get_arg_tag wit_simple_intropattern)), Tacentries.TyNil))), (fun ipat ist -> # 183 "plugins/ltac/extratactics.mlg" injClause None (Some (decode_inj_ipat ipat)) true None ))); (Tacentries.TyML (Tacentries.TyIdent ("einjection", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_destruction_arg), Tacentries.TyIdent ("as", Tacentries.TyArg ( Extend.TUlist0 ( Extend.TUentry (Genarg.get_arg_tag wit_simple_intropattern)), Tacentries.TyNil)))), (fun c ipat ist -> # 185 "plugins/ltac/extratactics.mlg" mytclWithHoles (injClause None (Some (decode_inj_ipat ipat))) true c )))] let () = Tacentries.tactic_extend __coq_plugin_name "simple_injection" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("simple", Tacentries.TyIdent ("injection", Tacentries.TyNil)), (fun ist -> # 188 "plugins/ltac/extratactics.mlg" simpleInjClause None false None ))); (Tacentries.TyML (Tacentries.TyIdent ("simple", Tacentries.TyIdent ("injection", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_destruction_arg), Tacentries.TyNil))), (fun c ist -> # 189 "plugins/ltac/extratactics.mlg" mytclWithHoles (simpleInjClause None) false c )))] # 192 "plugins/ltac/extratactics.mlg" let injHyp id = Proofview.tclEVARMAP >>= fun sigma -> injection_main false (fun env sigma -> (sigma, (EConstr.mkVar id, NoBindings))) let () = Tacentries.tactic_extend __coq_plugin_name "dependent_rewrite" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("dependent", Tacentries.TyIdent ("rewrite", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_orient), Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_constr), Tacentries.TyNil)))), (fun b c ist -> # 201 "plugins/ltac/extratactics.mlg" rewriteInConcl b c ))); (Tacentries.TyML (Tacentries.TyIdent ("dependent", Tacentries.TyIdent ("rewrite", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_orient), Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_constr), Tacentries.TyIdent ("in", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_hyp), Tacentries.TyNil)))))), (fun b c id ist -> # 203 "plugins/ltac/extratactics.mlg" rewriteInHyp b c id )))] let () = Tacentries.tactic_extend __coq_plugin_name "cut_rewrite" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("cutrewrite", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_orient), Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_constr), Tacentries.TyNil))), (fun b eqn ist -> # 211 "plugins/ltac/extratactics.mlg" cutRewriteInConcl b eqn ))); (Tacentries.TyML (Tacentries.TyIdent ("cutrewrite", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_orient), Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_constr), Tacentries.TyIdent ("in", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_hyp), Tacentries.TyNil))))), (fun b eqn id ist -> # 213 "plugins/ltac/extratactics.mlg" cutRewriteInHyp b eqn id )))] let () = Tacentries.tactic_extend __coq_plugin_name "decompose_sum" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("decompose", Tacentries.TyIdent ("sum", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_constr), Tacentries.TyNil))), (fun c ist -> # 220 "plugins/ltac/extratactics.mlg" Elim.h_decompose_or c )))] let () = Tacentries.tactic_extend __coq_plugin_name "decompose_record" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("decompose", Tacentries.TyIdent ("record", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_constr), Tacentries.TyNil))), (fun c ist -> # 224 "plugins/ltac/extratactics.mlg" Elim.h_decompose_and c )))] # 230 "plugins/ltac/extratactics.mlg" open Contradiction let () = Tacentries.tactic_extend __coq_plugin_name "absurd" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("absurd", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_constr), Tacentries.TyNil)), (fun c ist -> # 237 "plugins/ltac/extratactics.mlg" absurd c )))] # 240 "plugins/ltac/extratactics.mlg" let onSomeWithHoles tac = function | None -> tac None | Some c -> Tacticals.New.tclDELAYEDWITHHOLES false c (fun c -> tac (Some c)) let () = Tacentries.tactic_extend __coq_plugin_name "contradiction" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("contradiction", Tacentries.TyArg ( Extend.TUopt ( Extend.TUentry (Genarg.get_arg_tag wit_constr_with_bindings)), Tacentries.TyNil)), (fun c ist -> # 250 "plugins/ltac/extratactics.mlg" onSomeWithHoles contradiction c )))] # 256 "plugins/ltac/extratactics.mlg" open Autorewrite let () = Tacentries.tactic_extend __coq_plugin_name "autorewrite" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("autorewrite", Tacentries.TyIdent ("with", Tacentries.TyArg ( Extend.TUlist1 ( Extend.TUentry (Genarg.get_arg_tag wit_preident)), Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_clause), Tacentries.TyNil)))), (fun l cl ist -> # 264 "plugins/ltac/extratactics.mlg" auto_multi_rewrite l ( cl) ))); (Tacentries.TyML (Tacentries.TyIdent ("autorewrite", Tacentries.TyIdent ("with", Tacentries.TyArg ( Extend.TUlist1 ( Extend.TUentry (Genarg.get_arg_tag wit_preident)), Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_clause), Tacentries.TyIdent ("using", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_tactic), Tacentries.TyNil)))))), (fun l cl t ist -> # 266 "plugins/ltac/extratactics.mlg" auto_multi_rewrite_with (Tacinterp.tactic_of_value ist t) l cl )))] let () = Tacentries.tactic_extend __coq_plugin_name "autorewrite_star" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("autorewrite", Tacentries.TyIdent ("*", Tacentries.TyIdent ("with", Tacentries.TyArg ( Extend.TUlist1 ( Extend.TUentry (Genarg.get_arg_tag wit_preident)), Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_clause), Tacentries.TyNil))))), (fun l cl ist -> # 273 "plugins/ltac/extratactics.mlg" auto_multi_rewrite ~conds:AllMatches l cl ))); (Tacentries.TyML (Tacentries.TyIdent ("autorewrite", Tacentries.TyIdent ("*", Tacentries.TyIdent ("with", Tacentries.TyArg ( Extend.TUlist1 ( Extend.TUentry (Genarg.get_arg_tag wit_preident)), Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_clause), Tacentries.TyIdent ("using", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_tactic), Tacentries.TyNil))))))), (fun l cl t ist -> # 275 "plugins/ltac/extratactics.mlg" auto_multi_rewrite_with ~conds:AllMatches (Tacinterp.tactic_of_value ist t) l cl )))] # 281 "plugins/ltac/extratactics.mlg" let rewrite_star ist clause orient occs c (tac : Geninterp.Val.t option) = let tac' = Option.map (fun t -> Tacinterp.tactic_of_value ist t, FirstSolved) tac in with_delayed_uconstr ist c (fun c -> general_rewrite_ebindings_clause clause orient occs ?tac:tac' true true (c,NoBindings) true) let () = Tacentries.tactic_extend __coq_plugin_name "rewrite_star" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("rewrite", Tacentries.TyIdent ("*", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_orient), Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_uconstr), Tacentries.TyIdent ("in", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_hyp), Tacentries.TyIdent ("at", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_occurrences), Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_by_arg_tac), Tacentries.TyNil))))))))), (fun o c id occ tac ist -> # 292 "plugins/ltac/extratactics.mlg" rewrite_star ist (Some id) o (occurrences_of occ) c tac ))); (Tacentries.TyML (Tacentries.TyIdent ("rewrite", Tacentries.TyIdent ("*", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_orient), Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_uconstr), Tacentries.TyIdent ("at", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_occurrences), Tacentries.TyIdent ("in", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_hyp), Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_by_arg_tac), Tacentries.TyNil))))))))), (fun o c occ id tac ist -> # 294 "plugins/ltac/extratactics.mlg" rewrite_star ist (Some id) o (occurrences_of occ) c tac ))); (Tacentries.TyML (Tacentries.TyIdent ("rewrite", Tacentries.TyIdent ("*", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_orient), Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_uconstr), Tacentries.TyIdent ("in", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_hyp), Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_by_arg_tac), Tacentries.TyNil))))))), (fun o c id tac ist -> # 296 "plugins/ltac/extratactics.mlg" rewrite_star ist (Some id) o Locus.AllOccurrences c tac ))); (Tacentries.TyML (Tacentries.TyIdent ("rewrite", Tacentries.TyIdent ("*", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_orient), Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_uconstr), Tacentries.TyIdent ("at", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_occurrences), Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_by_arg_tac), Tacentries.TyNil))))))), (fun o c occ tac ist -> # 298 "plugins/ltac/extratactics.mlg" rewrite_star ist None o (occurrences_of occ) c tac ))); (Tacentries.TyML (Tacentries.TyIdent ("rewrite", Tacentries.TyIdent ("*", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_orient), Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_uconstr), Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_by_arg_tac), Tacentries.TyNil))))), (fun o c tac ist -> # 300 "plugins/ltac/extratactics.mlg" rewrite_star ist None o Locus.AllOccurrences c tac )))] # 306 "plugins/ltac/extratactics.mlg" let add_rewrite_hint ~poly bases ort t lcsr = let env = Global.env() in let sigma = Evd.from_env env in let f ce = let c, ctx = Constrintern.interp_constr env sigma ce in let c = EConstr.to_constr sigma c in let ctx = let ctx = UState.context_set ctx in if poly then ctx else (* This is a global universe context that shouldn't be refreshed at every use of the hint, declare it globally. *) (Declare.declare_universe_context ~poly:false ctx; Univ.ContextSet.empty) in CAst.make ?loc:(Constrexpr_ops.constr_loc ce) ((c, ctx), ort, Option.map (in_gen (rawwit wit_ltac)) t) in let eqs = List.map f lcsr in let add_hints base = add_rew_rules base eqs in List.iter add_hints bases let classify_hint _ = VtSideff ([], VtLater) let () = Vernacextend.vernac_extend ~command:"HintRewrite" ~classifier:( classify_hint ) ?entry:None [(Vernacextend.TyML (false, Vernacextend.TyTerminal ("Hint", Vernacextend.TyTerminal ("Rewrite", Vernacextend.TyNonTerminal (Extend.TUentry (Genarg.get_arg_tag wit_orient), Vernacextend.TyNonTerminal (Extend.TUlist1 ( Extend.TUentry (Genarg.get_arg_tag wit_constr)), Vernacextend.TyTerminal (":", Vernacextend.TyNonTerminal ( Extend.TUlist0 ( Extend.TUentry (Genarg.get_arg_tag wit_preident)), Vernacextend.TyNil)))))), (let coqpp_body o l bl polymorphic = Vernacextend.VtDefault (fun () -> # 333 "plugins/ltac/extratactics.mlg" add_rewrite_hint ~poly:polymorphic bl o None l ) in fun o l bl ~atts -> coqpp_body o l bl (Attributes.parse polymorphic atts)), None)); (Vernacextend.TyML (false, Vernacextend.TyTerminal ("Hint", Vernacextend.TyTerminal ("Rewrite", Vernacextend.TyNonTerminal (Extend.TUentry (Genarg.get_arg_tag wit_orient), Vernacextend.TyNonTerminal (Extend.TUlist1 ( Extend.TUentry (Genarg.get_arg_tag wit_constr)), Vernacextend.TyTerminal ("using", Vernacextend.TyNonTerminal (Extend.TUentry (Genarg.get_arg_tag wit_tactic), Vernacextend.TyTerminal (":", Vernacextend.TyNonTerminal ( Extend.TUlist0 ( Extend.TUentry (Genarg.get_arg_tag wit_preident)), Vernacextend.TyNil)))))))), (let coqpp_body o l t bl polymorphic = Vernacextend.VtDefault (fun () -> # 336 "plugins/ltac/extratactics.mlg" add_rewrite_hint ~poly:polymorphic bl o (Some t) l ) in fun o l t bl ~atts -> coqpp_body o l t bl (Attributes.parse polymorphic atts)), None)); (Vernacextend.TyML (false, Vernacextend.TyTerminal ("Hint", Vernacextend.TyTerminal ("Rewrite", Vernacextend.TyNonTerminal (Extend.TUentry (Genarg.get_arg_tag wit_orient), Vernacextend.TyNonTerminal (Extend.TUlist1 ( Extend.TUentry (Genarg.get_arg_tag wit_constr)), Vernacextend.TyNil)))), (let coqpp_body o l polymorphic = Vernacextend.VtDefault (fun () -> # 338 "plugins/ltac/extratactics.mlg" add_rewrite_hint ~poly:polymorphic ["core"] o None l ) in fun o l ~atts -> coqpp_body o l (Attributes.parse polymorphic atts)), None)); (Vernacextend.TyML (false, Vernacextend.TyTerminal ("Hint", Vernacextend.TyTerminal ("Rewrite", Vernacextend.TyNonTerminal (Extend.TUentry (Genarg.get_arg_tag wit_orient), Vernacextend.TyNonTerminal (Extend.TUlist1 ( Extend.TUentry (Genarg.get_arg_tag wit_constr)), Vernacextend.TyTerminal ("using", Vernacextend.TyNonTerminal (Extend.TUentry (Genarg.get_arg_tag wit_tactic), Vernacextend.TyNil)))))), (let coqpp_body o l t polymorphic = Vernacextend.VtDefault (fun () -> # 340 "plugins/ltac/extratactics.mlg" add_rewrite_hint ~poly:polymorphic ["core"] o (Some t) l ) in fun o l t ~atts -> coqpp_body o l t (Attributes.parse polymorphic atts)), None))] # 346 "plugins/ltac/extratactics.mlg" open EConstr open Vars let constr_flags () = { Pretyping.use_typeclasses = true; Pretyping.solve_unification_constraints = Pfedit.use_unification_heuristics (); Pretyping.fail_evar = false; Pretyping.expand_evars = true; Pretyping.program_mode = false; Pretyping.polymorphic = false; } let refine_tac ist simple with_classes c = Proofview.Goal.enter begin fun gl -> let concl = Proofview.Goal.concl gl in let env = Proofview.Goal.env gl in let flags = { (constr_flags ()) with Pretyping.use_typeclasses = with_classes } in let expected_type = Pretyping.OfType concl in let c = Tacinterp.type_uconstr ~flags ~expected_type ist c in let update = begin fun sigma -> c env sigma end in let refine = Refine.refine ~typecheck:false update in if simple then refine else refine <*> Tactics.New.reduce_after_refine <*> Proofview.shelve_unifiable end let () = Tacentries.tactic_extend __coq_plugin_name "refine" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("refine", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_uconstr), Tacentries.TyNil)), (fun c ist -> # 382 "plugins/ltac/extratactics.mlg" refine_tac ist false true c )))] let () = Tacentries.tactic_extend __coq_plugin_name "simple_refine" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("simple", Tacentries.TyIdent ("refine", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_uconstr), Tacentries.TyNil))), (fun c ist -> # 387 "plugins/ltac/extratactics.mlg" refine_tac ist true true c )))] let () = Tacentries.tactic_extend __coq_plugin_name "notcs_refine" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("notypeclasses", Tacentries.TyIdent ("refine", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_uconstr), Tacentries.TyNil))), (fun c ist -> # 392 "plugins/ltac/extratactics.mlg" refine_tac ist false false c )))] let () = Tacentries.tactic_extend __coq_plugin_name "notcs_simple_refine" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("simple", Tacentries.TyIdent ("notypeclasses", Tacentries.TyIdent ("refine", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_uconstr), Tacentries.TyNil)))), (fun c ist -> # 397 "plugins/ltac/extratactics.mlg" refine_tac ist true false c )))] let () = Tacentries.tactic_extend __coq_plugin_name "solve_constraints" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("solve_constraints", Tacentries.TyNil), (fun ist -> # 402 "plugins/ltac/extratactics.mlg" Refine.solve_constraints )))] # 408 "plugins/ltac/extratactics.mlg" open Inv open Leminv let seff id = VtSideff ([id], VtLater) let () = Vernacextend.vernac_extend ~command:"DeriveInversionClear" ?entry:None [(Vernacextend.TyML (false, Vernacextend.TyTerminal ("Derive", Vernacextend.TyTerminal ("Inversion_clear", Vernacextend.TyNonTerminal (Extend.TUentry (Genarg.get_arg_tag wit_ident), Vernacextend.TyTerminal ("with", Vernacextend.TyNonTerminal (Extend.TUentry (Genarg.get_arg_tag wit_constr), Vernacextend.TyTerminal ("Sort", Vernacextend.TyNonTerminal (Extend.TUentry (Genarg.get_arg_tag wit_sort_family), Vernacextend.TyNil))))))), (let coqpp_body na c s polymorphic = Vernacextend.VtDefault (fun () -> # 426 "plugins/ltac/extratactics.mlg" add_inversion_lemma_exn ~poly:polymorphic na c s false inv_clear_tac ) in fun na c s ~atts -> coqpp_body na c s (Attributes.parse polymorphic atts)), Some (fun na c s -> # 425 "plugins/ltac/extratactics.mlg" seff na ))); (Vernacextend.TyML (false, Vernacextend.TyTerminal ("Derive", Vernacextend.TyTerminal ("Inversion_clear", Vernacextend.TyNonTerminal (Extend.TUentry (Genarg.get_arg_tag wit_ident), Vernacextend.TyTerminal ("with", Vernacextend.TyNonTerminal (Extend.TUentry (Genarg.get_arg_tag wit_constr), Vernacextend.TyNil))))), (let coqpp_body na c polymorphic = Vernacextend.VtDefault (fun () -> # 430 "plugins/ltac/extratactics.mlg" add_inversion_lemma_exn ~poly:polymorphic na c Sorts.InProp false inv_clear_tac ) in fun na c ~atts -> coqpp_body na c (Attributes.parse polymorphic atts)), Some (fun na c -> # 429 "plugins/ltac/extratactics.mlg" seff na )))] let () = Vernacextend.vernac_extend ~command:"DeriveInversion" ?entry:None [(Vernacextend.TyML (false, Vernacextend.TyTerminal ("Derive", Vernacextend.TyTerminal ("Inversion", Vernacextend.TyNonTerminal (Extend.TUentry (Genarg.get_arg_tag wit_ident), Vernacextend.TyTerminal ("with", Vernacextend.TyNonTerminal (Extend.TUentry (Genarg.get_arg_tag wit_constr), Vernacextend.TyTerminal ("Sort", Vernacextend.TyNonTerminal (Extend.TUentry (Genarg.get_arg_tag wit_sort_family), Vernacextend.TyNil))))))), (let coqpp_body na c s polymorphic = Vernacextend.VtDefault (fun () -> # 437 "plugins/ltac/extratactics.mlg" add_inversion_lemma_exn ~poly:polymorphic na c s false inv_tac ) in fun na c s ~atts -> coqpp_body na c s (Attributes.parse polymorphic atts)), Some (fun na c s -> # 436 "plugins/ltac/extratactics.mlg" seff na ))); (Vernacextend.TyML (false, Vernacextend.TyTerminal ("Derive", Vernacextend.TyTerminal ("Inversion", Vernacextend.TyNonTerminal (Extend.TUentry (Genarg.get_arg_tag wit_ident), Vernacextend.TyTerminal ("with", Vernacextend.TyNonTerminal (Extend.TUentry (Genarg.get_arg_tag wit_constr), Vernacextend.TyNil))))), (let coqpp_body na c polymorphic = Vernacextend.VtDefault (fun () -> # 441 "plugins/ltac/extratactics.mlg" add_inversion_lemma_exn ~poly:polymorphic na c Sorts.InProp false inv_tac ) in fun na c ~atts -> coqpp_body na c (Attributes.parse polymorphic atts)), Some (fun na c -> # 440 "plugins/ltac/extratactics.mlg" seff na )))] let () = Vernacextend.vernac_extend ~command:"DeriveDependentInversion" ?entry:None [(Vernacextend.TyML (false, Vernacextend.TyTerminal ("Derive", Vernacextend.TyTerminal ("Dependent", Vernacextend.TyTerminal ("Inversion", Vernacextend.TyNonTerminal (Extend.TUentry (Genarg.get_arg_tag wit_ident), Vernacextend.TyTerminal ("with", Vernacextend.TyNonTerminal (Extend.TUentry (Genarg.get_arg_tag wit_constr), Vernacextend.TyTerminal ("Sort", Vernacextend.TyNonTerminal (Extend.TUentry (Genarg.get_arg_tag wit_sort_family), Vernacextend.TyNil)))))))), (let coqpp_body na c s polymorphic = Vernacextend.VtDefault (fun () -> # 448 "plugins/ltac/extratactics.mlg" add_inversion_lemma_exn ~poly:polymorphic na c s true dinv_tac ) in fun na c s ~atts -> coqpp_body na c s (Attributes.parse polymorphic atts)), Some (fun na c s -> # 447 "plugins/ltac/extratactics.mlg" seff na )))] let () = Vernacextend.vernac_extend ~command:"DeriveDependentInversionClear" ?entry:None [(Vernacextend.TyML (false, Vernacextend.TyTerminal ("Derive", Vernacextend.TyTerminal ("Dependent", Vernacextend.TyTerminal ("Inversion_clear", Vernacextend.TyNonTerminal (Extend.TUentry (Genarg.get_arg_tag wit_ident), Vernacextend.TyTerminal ("with", Vernacextend.TyNonTerminal (Extend.TUentry (Genarg.get_arg_tag wit_constr), Vernacextend.TyTerminal ("Sort", Vernacextend.TyNonTerminal (Extend.TUentry (Genarg.get_arg_tag wit_sort_family), Vernacextend.TyNil)))))))), (let coqpp_body na c s polymorphic = Vernacextend.VtDefault (fun () -> # 455 "plugins/ltac/extratactics.mlg" add_inversion_lemma_exn ~poly:polymorphic na c s true dinv_clear_tac ) in fun na c s ~atts -> coqpp_body na c s (Attributes.parse polymorphic atts)), Some (fun na c s -> # 454 "plugins/ltac/extratactics.mlg" seff na )))] let () = Tacentries.tactic_extend __coq_plugin_name "subst" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("subst", Tacentries.TyArg ( Extend.TUlist1 ( Extend.TUentry (Genarg.get_arg_tag wit_var)), Tacentries.TyNil)), (fun l ist -> # 463 "plugins/ltac/extratactics.mlg" subst l ))); (Tacentries.TyML (Tacentries.TyIdent ("subst", Tacentries.TyNil), (fun ist -> # 464 "plugins/ltac/extratactics.mlg" subst_all () )))] # 467 "plugins/ltac/extratactics.mlg" let simple_subst_tactic_flags = { only_leibniz = true; rewrite_dependent_proof = false } let () = Tacentries.tactic_extend __coq_plugin_name "simple_subst" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("simple", Tacentries.TyIdent ("subst", Tacentries.TyNil)), (fun ist -> # 475 "plugins/ltac/extratactics.mlg" subst_all ~flags:simple_subst_tactic_flags () )))] # 478 "plugins/ltac/extratactics.mlg" open Evar_tactics let () = Tacentries.tactic_extend __coq_plugin_name "evar" ~level:0 [( Tacentries.TyML ( Tacentries.TyIdent ("evar", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_test_lpar_id_colon), Tacentries.TyIdent ("(", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_ident), Tacentries.TyIdent (":", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_lconstr), Tacentries.TyIdent (")", Tacentries.TyNil))))))), (fun _ id typ ist -> # 490 "plugins/ltac/extratactics.mlg" let_evar (Name.Name id) typ ))); ( Tacentries.TyML ( Tacentries.TyIdent ("evar", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_constr), Tacentries.TyNil)), (fun typ ist -> # 491 "plugins/ltac/extratactics.mlg" let_evar Name.Anonymous typ )))] let () = Tacentries.tactic_extend __coq_plugin_name "instantiate" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("instantiate", Tacentries.TyIdent ("(", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_ident), Tacentries.TyIdent (":=", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_lglob), Tacentries.TyIdent (")", Tacentries.TyNil)))))), (fun id c ist -> # 496 "plugins/ltac/extratactics.mlg" Tacticals.New.tclTHEN (instantiate_tac_by_name id c) Proofview.V82.nf_evar_goals ))); (Tacentries.TyML (Tacentries.TyIdent ("instantiate", Tacentries.TyIdent ("(", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_integer), Tacentries.TyIdent (":=", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_lglob), Tacentries.TyIdent (")", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_hloc), Tacentries.TyNil))))))), (fun i c hl ist -> # 498 "plugins/ltac/extratactics.mlg" Tacticals.New.tclTHEN (instantiate_tac i c hl) Proofview.V82.nf_evar_goals ))); (Tacentries.TyML (Tacentries.TyIdent ("instantiate", Tacentries.TyNil), (fun ist -> # 499 "plugins/ltac/extratactics.mlg" Proofview.V82.nf_evar_goals )))] # 505 "plugins/ltac/extratactics.mlg" open Tactics open Glob_term open Libobject open Lib (* Registered lemmas are expected to be of the form x R y -> y == z -> x R z (in the right table) x R y -> x == z -> z R y (in the left table) *) let transitivity_right_table = Summary.ref [] ~name:"transitivity-steps-r" let transitivity_left_table = Summary.ref [] ~name:"transitivity-steps-l" (* [step] tries to apply a rewriting lemma; then apply [tac] intended to complete to proof of the last hypothesis (assumed to state an equality) *) let step left x tac = let l = List.map (fun lem -> let lem = EConstr.of_constr lem in Tacticals.New.tclTHENLAST (apply_with_bindings (lem, ImplicitBindings [x])) tac) !(if left then transitivity_left_table else transitivity_right_table) in Tacticals.New.tclFIRST l (* Main function to push lemmas in persistent environment *) let cache_transitivity_lemma (_,(left,lem)) = if left then transitivity_left_table := lem :: !transitivity_left_table else transitivity_right_table := lem :: !transitivity_right_table let subst_transitivity_lemma (subst,(b,ref)) = (b,subst_mps subst ref) let inTransitivity : bool * Constr.t -> obj = declare_object @@ global_object_nodischarge "TRANSITIVITY-STEPS" ~cache:cache_transitivity_lemma ~subst:(Some subst_transitivity_lemma) (* Main entry points *) let add_transitivity_lemma left lem = let env = Global.env () in let sigma = Evd.from_env env in let lem',ctx (*FIXME*) = Constrintern.interp_constr env sigma lem in let lem' = EConstr.to_constr sigma lem' in add_anonymous_leaf (inTransitivity (left,lem')) let () = Tacentries.tactic_extend __coq_plugin_name "stepl" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("stepl", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_constr), Tacentries.TyIdent ("by", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_tactic), Tacentries.TyNil)))), (fun c tac ist -> # 563 "plugins/ltac/extratactics.mlg" step true c (Tacinterp.tactic_of_value ist tac) ))); (Tacentries.TyML (Tacentries.TyIdent ("stepl", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_constr), Tacentries.TyNil)), (fun c ist -> # 564 "plugins/ltac/extratactics.mlg" step true c (Proofview.tclUNIT ()) )))] let () = Tacentries.tactic_extend __coq_plugin_name "stepr" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("stepr", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_constr), Tacentries.TyIdent ("by", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_tactic), Tacentries.TyNil)))), (fun c tac ist -> # 568 "plugins/ltac/extratactics.mlg" step false c (Tacinterp.tactic_of_value ist tac) ))); (Tacentries.TyML (Tacentries.TyIdent ("stepr", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_constr), Tacentries.TyNil)), (fun c ist -> # 569 "plugins/ltac/extratactics.mlg" step false c (Proofview.tclUNIT ()) )))] let () = Vernacextend.vernac_extend ~command:"AddStepl" ~classifier:(fun _ -> Vernacextend.classify_as_sideeff) ?entry:None [(Vernacextend.TyML (false, Vernacextend.TyTerminal ("Declare", Vernacextend.TyTerminal ("Left", Vernacextend.TyTerminal ("Step", Vernacextend.TyNonTerminal (Extend.TUentry (Genarg.get_arg_tag wit_constr), Vernacextend.TyNil)))), (let coqpp_body t () = Vernacextend.VtDefault (fun () -> # 574 "plugins/ltac/extratactics.mlg" add_transitivity_lemma true t ) in fun t ~atts -> coqpp_body t (Attributes.unsupported_attributes atts)), None))] let () = Vernacextend.vernac_extend ~command:"AddStepr" ~classifier:(fun _ -> Vernacextend.classify_as_sideeff) ?entry:None [(Vernacextend.TyML (false, Vernacextend.TyTerminal ("Declare", Vernacextend.TyTerminal ("Right", Vernacextend.TyTerminal ("Step", Vernacextend.TyNonTerminal (Extend.TUentry (Genarg.get_arg_tag wit_constr), Vernacextend.TyNil)))), (let coqpp_body t () = Vernacextend.VtDefault (fun () -> # 579 "plugins/ltac/extratactics.mlg" add_transitivity_lemma false t ) in fun t ~atts -> coqpp_body t (Attributes.unsupported_attributes atts)), None))] let () = Tacentries.tactic_extend __coq_plugin_name "generalize_eqs" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("generalize_eqs", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_hyp), Tacentries.TyNil)), (fun id ist -> # 586 "plugins/ltac/extratactics.mlg" abstract_generalize ~generalize_vars:false id )))] let () = Tacentries.tactic_extend __coq_plugin_name "dep_generalize_eqs" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("dependent", Tacentries.TyIdent ("generalize_eqs", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_hyp), Tacentries.TyNil))), (fun id ist -> # 589 "plugins/ltac/extratactics.mlg" abstract_generalize ~generalize_vars:false ~force_dep:true id )))] let () = Tacentries.tactic_extend __coq_plugin_name "generalize_eqs_vars" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("generalize_eqs_vars", Tacentries.TyArg (Extend.TUentry (Genarg.get_arg_tag wit_hyp), Tacentries.TyNil)), (fun id ist -> # 592 "plugins/ltac/extratactics.mlg" abstract_generalize ~generalize_vars:true id )))] let () = Tacentries.tactic_extend __coq_plugin_name "dep_generalize_eqs_vars" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("dependent", Tacentries.TyIdent ("generalize_eqs_vars", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_hyp), Tacentries.TyNil))), (fun id ist -> # 595 "plugins/ltac/extratactics.mlg" abstract_generalize ~force_dep:true ~generalize_vars:true id )))] let () = Tacentries.tactic_extend __coq_plugin_name "specialize_eqs" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("specialize_eqs", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_hyp), Tacentries.TyNil)), (fun id ist -> # 603 "plugins/ltac/extratactics.mlg" specialize_eqs id )))] # 614 "plugins/ltac/extratactics.mlg" let subst_var_with_hole occ tid t = let occref = if occ > 0 then ref occ else Find_subterm.error_invalid_occurrence [occ] in let locref = ref 0 in let rec substrec x = match DAst.get x with | GVar id -> if Id.equal id tid then (decr occref; if Int.equal !occref 0 then x else (incr locref; DAst.make ~loc:(Loc.make_loc (!locref,0)) @@ GHole (Evar_kinds.QuestionMark { Evar_kinds.qm_obligation=Evar_kinds.Define true; Evar_kinds.qm_name=Anonymous; Evar_kinds.qm_record_field=None; }, IntroAnonymous, None))) else x | _ -> map_glob_constr_left_to_right substrec x in let t' = substrec t in if !occref > 0 then Find_subterm.error_invalid_occurrence [occ] else t' let subst_hole_with_term occ tc t = let locref = ref 0 in let occref = ref occ in let rec substrec c = match DAst.get c with | GHole (Evar_kinds.QuestionMark { Evar_kinds.qm_obligation=Evar_kinds.Define true; Evar_kinds.qm_name=Anonymous; Evar_kinds.qm_record_field=None; }, IntroAnonymous, s) -> decr occref; if Int.equal !occref 0 then tc else (incr locref; DAst.make ~loc:(Loc.make_loc (!locref,0)) @@ GHole (Evar_kinds.QuestionMark { Evar_kinds.qm_obligation=Evar_kinds.Define true; Evar_kinds.qm_name=Anonymous; Evar_kinds.qm_record_field=None; },IntroAnonymous,s)) | _ -> map_glob_constr_left_to_right substrec c in substrec t open Tacmach let hResolve id c occ t = Proofview.Goal.enter begin fun gl -> let sigma = Proofview.Goal.sigma gl in let env = Termops.clear_named_body id (Proofview.Goal.env gl) in let concl = Proofview.Goal.concl gl in let env_ids = Termops.vars_of_env env in let c_raw = Detyping.detype Detyping.Now true env_ids env sigma c in let t_raw = Detyping.detype Detyping.Now true env_ids env sigma t in let rec resolve_hole t_hole = try Pretyping.understand env sigma t_hole with | Pretype_errors.PretypeError (_,_,Pretype_errors.UnsolvableImplicit _) as e -> let (e, info) = CErrors.push e in let loc_begin = Option.cata (fun l -> fst (Loc.unloc l)) 0 (Loc.get_loc info) in resolve_hole (subst_hole_with_term loc_begin c_raw t_hole) in let t_constr,ctx = resolve_hole (subst_var_with_hole occ id t_raw) in let sigma = Evd.merge_universe_context sigma ctx in let t_constr_type = Retyping.get_type_of env sigma t_constr in Proofview.tclTHEN (Proofview.Unsafe.tclEVARS sigma) (change_concl (mkLetIn (make_annot Name.Anonymous Sorts.Relevant,t_constr,t_constr_type,concl))) end let hResolve_auto id c t = let rec resolve_auto n = try hResolve id c n t with | UserError _ as e -> raise e | e when CErrors.noncritical e -> resolve_auto (n+1) in resolve_auto 1 let () = Tacentries.tactic_extend __coq_plugin_name "hresolve_core" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("hresolve_core", Tacentries.TyIdent ("(", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_ident), Tacentries.TyIdent (":=", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_constr), Tacentries.TyIdent (")", Tacentries.TyIdent ("at", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_int_or_var), Tacentries.TyIdent ("in", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_constr), Tacentries.TyNil)))))))))), (fun id c occ t ist -> # 701 "plugins/ltac/extratactics.mlg" hResolve id c occ t ))); (Tacentries.TyML (Tacentries.TyIdent ("hresolve_core", Tacentries.TyIdent ("(", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_ident), Tacentries.TyIdent (":=", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_constr), Tacentries.TyIdent (")", Tacentries.TyIdent ("in", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_constr), Tacentries.TyNil)))))))), (fun id c t ist -> # 702 "plugins/ltac/extratactics.mlg" hResolve_auto id c t )))] let () = Tacentries.tactic_extend __coq_plugin_name "hget_evar" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("hget_evar", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_int_or_var), Tacentries.TyNil)), (fun n ist -> # 710 "plugins/ltac/extratactics.mlg" Evar_tactics.hget_evar n )))] # 723 "plugins/ltac/extratactics.mlg" exception Found of unit Proofview.tactic let rewrite_except h = Proofview.Goal.enter begin fun gl -> let hyps = Tacmach.New.pf_ids_of_hyps gl in Tacticals.New.tclMAP (fun id -> if Id.equal id h then Proofview.tclUNIT () else Tacticals.New.tclTRY (Equality.general_rewrite_in true Locus.AllOccurrences true true id (mkVar h) false)) hyps end let refl_equal () = Coqlib.lib_ref "core.eq.type" (* This is simply an implementation of the case_eq tactic. this code should be replaced by a call to the tactic but I don't know how to call it before it is defined. *) let mkCaseEq a : unit Proofview.tactic = Proofview.Goal.enter begin fun gl -> let type_of_a = Tacmach.New.pf_unsafe_type_of gl a in Tacticals.New.pf_constr_of_global (delayed_force refl_equal) >>= fun req -> Tacticals.New.tclTHENLIST [Tactics.generalize [(mkApp(req, [| type_of_a; a|]))]; Proofview.Goal.enter begin fun gl -> let concl = Proofview.Goal.concl gl in let env = Proofview.Goal.env gl in (* FIXME: this looks really wrong. Does anybody really use this tactic? *) let (_, c) = Tacred.pattern_occs [Locus.OnlyOccurrences [1], a] env (Evd.from_env env) concl in change_concl c end; simplest_case a] end let case_eq_intros_rewrite x = Proofview.Goal.enter begin fun gl -> let n = nb_prod (Tacmach.New.project gl) (Proofview.Goal.concl gl) in (* Pp.msgnl (Printer.pr_lconstr x); *) Tacticals.New.tclTHENLIST [ mkCaseEq x; Proofview.Goal.enter begin fun gl -> let concl = Proofview.Goal.concl gl in let hyps = Tacmach.New.pf_ids_set_of_hyps gl in let n' = nb_prod (Tacmach.New.project gl) concl in let h = fresh_id_in_env hyps (Id.of_string "heq") (Proofview.Goal.env gl) in Tacticals.New.tclTHENLIST [ Tacticals.New.tclDO (n'-n-1) intro; introduction h; rewrite_except h] end ] end let rec find_a_destructable_match sigma t = let cl = induction_arg_of_quantified_hyp (NamedHyp (Id.of_string "x")) in let cl = [cl, (None, None), None], None in let dest = TacAtom (CAst.make @@ TacInductionDestruct(false, false, cl)) in match EConstr.kind sigma t with | Case (_,_,x,_) when closed0 sigma x -> if isVar sigma x then (* TODO check there is no rel n. *) raise (Found (Tacinterp.eval_tactic dest)) else (* let _ = Pp.msgnl (Printer.pr_lconstr x) in *) raise (Found (case_eq_intros_rewrite x)) | _ -> EConstr.iter sigma (fun c -> find_a_destructable_match sigma c) t let destauto t = Proofview.tclEVARMAP >>= fun sigma -> try find_a_destructable_match sigma t; Tacticals.New.tclZEROMSG (str "No destructable match found") with Found tac -> tac let destauto_in id = Proofview.Goal.enter begin fun gl -> let ctype = Tacmach.New.pf_unsafe_type_of gl (mkVar id) in (* Pp.msgnl (Printer.pr_lconstr (mkVar id)); *) (* Pp.msgnl (Printer.pr_lconstr (ctype)); *) destauto ctype end let () = Tacentries.tactic_extend __coq_plugin_name "destauto" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("destauto", Tacentries.TyNil), (fun ist -> # 810 "plugins/ltac/extratactics.mlg" Proofview.Goal.enter begin fun gl -> destauto (Proofview.Goal.concl gl) end ))); (Tacentries.TyML (Tacentries.TyIdent ("destauto", Tacentries.TyIdent ("in", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_hyp), Tacentries.TyNil))), (fun id ist -> # 811 "plugins/ltac/extratactics.mlg" destauto_in id )))] let () = Tacentries.tactic_extend __coq_plugin_name "transparent_abstract" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("transparent_abstract", Tacentries.TyArg (Extend.TUentryl (Genarg.get_arg_tag wit_tactic, 3), Tacentries.TyNil)), (fun t ist -> # 822 "plugins/ltac/extratactics.mlg" Proofview.Goal.enter begin fun gl -> Abstract.tclABSTRACT ~opaque:false None (Tacinterp.tactic_of_value ist t) end; ))); (Tacentries.TyML (Tacentries.TyIdent ("transparent_abstract", Tacentries.TyArg (Extend.TUentryl (Genarg.get_arg_tag wit_tactic, 3), Tacentries.TyIdent ("using", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_ident), Tacentries.TyNil)))), (fun t id ist -> # 824 "plugins/ltac/extratactics.mlg" Proofview.Goal.enter begin fun gl -> Abstract.tclABSTRACT ~opaque:false (Some id) (Tacinterp.tactic_of_value ist t) end; )))] let () = Tacentries.tactic_extend __coq_plugin_name "constr_eq" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("constr_eq", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_constr), Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_constr), Tacentries.TyNil))), (fun x y ist -> # 831 "plugins/ltac/extratactics.mlg" Tactics.constr_eq ~strict:false x y )))] let () = Tacentries.tactic_extend __coq_plugin_name "constr_eq_strict" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("constr_eq_strict", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_constr), Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_constr), Tacentries.TyNil))), (fun x y ist -> # 835 "plugins/ltac/extratactics.mlg" Tactics.constr_eq ~strict:true x y )))] let () = Tacentries.tactic_extend __coq_plugin_name "constr_eq_nounivs" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("constr_eq_nounivs", Tacentries.TyArg (Extend.TUentry (Genarg.get_arg_tag wit_constr), Tacentries.TyArg (Extend.TUentry (Genarg.get_arg_tag wit_constr), Tacentries.TyNil))), (fun x y ist -> # 839 "plugins/ltac/extratactics.mlg" Proofview.tclEVARMAP >>= fun sigma -> if eq_constr_nounivs sigma x y then Proofview.tclUNIT () else Tacticals.New.tclFAIL 0 (str "Not equal") )))] let () = Tacentries.tactic_extend __coq_plugin_name "is_evar" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("is_evar", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_constr), Tacentries.TyNil)), (fun x ist -> # 845 "plugins/ltac/extratactics.mlg" Proofview.tclEVARMAP >>= fun sigma -> match EConstr.kind sigma x with | Evar _ -> Proofview.tclUNIT () | _ -> Tacticals.New.tclFAIL 0 (str "Not an evar") )))] let () = Tacentries.tactic_extend __coq_plugin_name "has_evar" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("has_evar", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_constr), Tacentries.TyNil)), (fun x ist -> # 854 "plugins/ltac/extratactics.mlg" Proofview.tclEVARMAP >>= fun sigma -> if Evarutil.has_undefined_evars sigma x then Proofview.tclUNIT () else Tacticals.New.tclFAIL 0 (str "No evars") )))] let () = Tacentries.tactic_extend __coq_plugin_name "is_hyp" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("is_var", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_constr), Tacentries.TyNil)), (fun x ist -> # 863 "plugins/ltac/extratactics.mlg" Proofview.tclEVARMAP >>= fun sigma -> match EConstr.kind sigma x with | Var _ -> Proofview.tclUNIT () | _ -> Tacticals.New.tclFAIL 0 (str "Not a variable or hypothesis") )))] let () = Tacentries.tactic_extend __coq_plugin_name "is_fix" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("is_fix", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_constr), Tacentries.TyNil)), (fun x ist -> # 871 "plugins/ltac/extratactics.mlg" Proofview.tclEVARMAP >>= fun sigma -> match EConstr.kind sigma x with | Fix _ -> Proofview.tclUNIT () | _ -> Tacticals.New.tclFAIL 0 (Pp.str "not a fix definition") )))] let () = Tacentries.tactic_extend __coq_plugin_name "is_cofix" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("is_cofix", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_constr), Tacentries.TyNil)), (fun x ist -> # 879 "plugins/ltac/extratactics.mlg" Proofview.tclEVARMAP >>= fun sigma -> match EConstr.kind sigma x with | CoFix _ -> Proofview.tclUNIT () | _ -> Tacticals.New.tclFAIL 0 (Pp.str "not a cofix definition") )))] let () = Tacentries.tactic_extend __coq_plugin_name "is_ind" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("is_ind", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_constr), Tacentries.TyNil)), (fun x ist -> # 887 "plugins/ltac/extratactics.mlg" Proofview.tclEVARMAP >>= fun sigma -> match EConstr.kind sigma x with | Ind _ -> Proofview.tclUNIT () | _ -> Tacticals.New.tclFAIL 0 (Pp.str "not an (co)inductive datatype") )))] let () = Tacentries.tactic_extend __coq_plugin_name "is_constructor" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("is_constructor", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_constr), Tacentries.TyNil)), (fun x ist -> # 895 "plugins/ltac/extratactics.mlg" Proofview.tclEVARMAP >>= fun sigma -> match EConstr.kind sigma x with | Construct _ -> Proofview.tclUNIT () | _ -> Tacticals.New.tclFAIL 0 (Pp.str "not a constructor") )))] let () = Tacentries.tactic_extend __coq_plugin_name "is_proj" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("is_proj", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_constr), Tacentries.TyNil)), (fun x ist -> # 903 "plugins/ltac/extratactics.mlg" Proofview.tclEVARMAP >>= fun sigma -> match EConstr.kind sigma x with | Proj _ -> Proofview.tclUNIT () | _ -> Tacticals.New.tclFAIL 0 (Pp.str "not a primitive projection") )))] let () = Tacentries.tactic_extend __coq_plugin_name "is_const" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("is_const", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_constr), Tacentries.TyNil)), (fun x ist -> # 911 "plugins/ltac/extratactics.mlg" Proofview.tclEVARMAP >>= fun sigma -> match EConstr.kind sigma x with | Const _ -> Proofview.tclUNIT () | _ -> Tacticals.New.tclFAIL 0 (Pp.str "not a constant") )))] let () = Vernacextend.vernac_extend ~command:"GrabEvars" ?entry:None [(Vernacextend.TyML (false, Vernacextend.TyTerminal ("Grab", Vernacextend.TyTerminal ("Existential", Vernacextend.TyTerminal ("Variables", Vernacextend.TyNil))), (let coqpp_body () = Vernacextend.VtModifyProof ( # 925 "plugins/ltac/extratactics.mlg" fun ~pstate -> Proof_global.map_proof (fun p -> Proof.V82.grab_evars p) pstate ) in fun ~atts -> coqpp_body (Attributes.unsupported_attributes atts)), Some # 924 "plugins/ltac/extratactics.mlg" classify_as_proofstep ))] let () = Tacentries.tactic_extend __coq_plugin_name "shelve" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("shelve", Tacentries.TyNil), (fun ist -> # 931 "plugins/ltac/extratactics.mlg" Proofview.shelve )))] let () = Tacentries.tactic_extend __coq_plugin_name "shelve_unifiable" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("shelve_unifiable", Tacentries.TyNil), (fun ist -> # 939 "plugins/ltac/extratactics.mlg" Proofview.shelve_unifiable )))] let () = Tacentries.tactic_extend __coq_plugin_name "unshelve" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("unshelve", Tacentries.TyArg ( Extend.TUentryl (Genarg.get_arg_tag wit_tactic, 1), Tacentries.TyNil)), (fun t ist -> # 945 "plugins/ltac/extratactics.mlg" Proofview.with_shelf (Tacinterp.tactic_of_value ist t) >>= fun (gls, ()) -> let gls = List.map Proofview.with_empty_state gls in Proofview.Unsafe.tclGETGOALS >>= fun ogls -> Proofview.Unsafe.tclSETGOALS (gls @ ogls) )))] let () = Vernacextend.vernac_extend ~command:"Unshelve" ?entry:None [(Vernacextend.TyML (false, Vernacextend.TyTerminal ("Unshelve", Vernacextend.TyNil), (let coqpp_body () = Vernacextend.VtModifyProof ( # 957 "plugins/ltac/extratactics.mlg" fun ~pstate -> Proof_global.map_proof (fun p -> Proof.unshelve p) pstate ) in fun ~atts -> coqpp_body (Attributes.unsupported_attributes atts)), Some # 956 "plugins/ltac/extratactics.mlg" classify_as_proofstep ))] let () = Tacentries.tactic_extend __coq_plugin_name "give_up" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("give_up", Tacentries.TyNil), (fun ist -> # 965 "plugins/ltac/extratactics.mlg" Proofview.give_up )))] let () = Tacentries.tactic_extend __coq_plugin_name "cycle" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("cycle", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_int_or_var), Tacentries.TyNil)), (fun n ist -> # 970 "plugins/ltac/extratactics.mlg" Proofview.cycle n )))] let () = Tacentries.tactic_extend __coq_plugin_name "swap" ~level:0 [( Tacentries.TyML ( Tacentries.TyIdent ("swap", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_int_or_var), Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_int_or_var), Tacentries.TyNil))), (fun i j ist -> # 975 "plugins/ltac/extratactics.mlg" Proofview.swap i j )))] let () = Tacentries.tactic_extend __coq_plugin_name "revgoals" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("revgoals", Tacentries.TyNil), (fun ist -> # 980 "plugins/ltac/extratactics.mlg" Proofview.revgoals )))] # 983 "plugins/ltac/extratactics.mlg" type cmp = | Eq | Lt | Le | Gt | Ge type 'i test = | Test of cmp * 'i * 'i let pr_cmp = function | Eq -> Pp.str"=" | Lt -> Pp.str"<" | Le -> Pp.str"<=" | Gt -> Pp.str">" | Ge -> Pp.str">=" let pr_cmp' _prc _prlc _prt = pr_cmp let pr_test_gen f (Test(c,x,y)) = Pp.(f x ++ pr_cmp c ++ f y) let pr_test = pr_test_gen (Pputils.pr_or_var Pp.int) let pr_test' _prc _prlc _prt = pr_test let pr_itest = pr_test_gen Pp.int let pr_itest' _prc _prlc _prt = pr_itest let (wit_comparison, comparison) = Tacentries.argument_extend ~name:"comparison" { Tacentries.arg_parsing = Vernacextend.Arg_rules ( [(Extend.Rule (Extend.Next (Extend.Stop, (Extend.Atoken (CLexer.terminal ">="))), (fun _ loc -> # 1020 "plugins/ltac/extratactics.mlg" Ge ))); (Extend.Rule (Extend.Next (Extend.Stop, (Extend.Atoken (CLexer.terminal ">"))), (fun _ loc -> # 1019 "plugins/ltac/extratactics.mlg" Gt ))); (Extend.Rule (Extend.Next (Extend.Stop, (Extend.Atoken (CLexer.terminal "<="))), (fun _ loc -> # 1018 "plugins/ltac/extratactics.mlg" Le ))); (Extend.Rule (Extend.Next (Extend.Stop, (Extend.Atoken (CLexer.terminal "<"))), (fun _ loc -> # 1017 "plugins/ltac/extratactics.mlg" Lt ))); (Extend.Rule (Extend.Next (Extend.Stop, (Extend.Atoken (CLexer.terminal "="))), (fun _ loc -> # 1016 "plugins/ltac/extratactics.mlg" Eq )))]); Tacentries.arg_tag = None; Tacentries.arg_intern = Tacentries.ArgInternFun (fun ist v -> (ist, v)); Tacentries.arg_subst = Tacentries.ArgSubstFun (fun s v -> v); Tacentries.arg_interp = Tacentries.ArgInterpRet; Tacentries.arg_printer = ((fun env sigma -> # 1015 "plugins/ltac/extratactics.mlg" pr_cmp' ), (fun env sigma -> # 1015 "plugins/ltac/extratactics.mlg" pr_cmp' ), (fun env sigma -> # 1015 "plugins/ltac/extratactics.mlg" pr_cmp' )); } let _ = (wit_comparison, comparison) # 1023 "plugins/ltac/extratactics.mlg" let interp_test ist gls = function | Test (c,x,y) -> project gls , Test(c,Tacinterp.interp_int_or_var ist x,Tacinterp.interp_int_or_var ist y) let (wit_test, test) = Tacentries.argument_extend ~name:"test" { Tacentries.arg_parsing = Vernacextend.Arg_rules ( [(Extend.Rule (Extend.Next (Extend.Next (Extend.Next (Extend.Stop, (Extend.Aentry int_or_var)), (Extend.Aentry comparison)), (Extend.Aentry int_or_var)), (fun y c x loc -> # 1037 "plugins/ltac/extratactics.mlg" Test(c,x,y) )))]); Tacentries.arg_tag = None; Tacentries.arg_intern = Tacentries.ArgInternFun (fun ist v -> (ist, v)); Tacentries.arg_subst = Tacentries.ArgSubstFun (fun s v -> v); Tacentries.arg_interp = Tacentries.ArgInterpLegacy ( # 1034 "plugins/ltac/extratactics.mlg" interp_test ); Tacentries.arg_printer = ((fun env sigma -> # 1035 "plugins/ltac/extratactics.mlg" pr_test' ), (fun env sigma -> # 1036 "plugins/ltac/extratactics.mlg" pr_test' ), (fun env sigma -> # 1033 "plugins/ltac/extratactics.mlg" pr_itest' )); } let _ = (wit_test, test) # 1040 "plugins/ltac/extratactics.mlg" let interp_cmp = function | Eq -> Int.equal | Lt -> ((<):int->int->bool) | Le -> ((<=):int->int->bool) | Gt -> ((>):int->int->bool) | Ge -> ((>=):int->int->bool) let run_test = function | Test(c,x,y) -> interp_cmp c x y let guard tst = if run_test tst then Proofview.tclUNIT () else let msg = Pp.(str"Condition not satisfied:"++ws 1++(pr_itest tst)) in Tacticals.New.tclZEROMSG msg let () = Tacentries.tactic_extend __coq_plugin_name "guard" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("guard", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_test), Tacentries.TyNil)), (fun tst ist -> # 1062 "plugins/ltac/extratactics.mlg" guard tst )))] # 1065 "plugins/ltac/extratactics.mlg" let decompose l c = Proofview.Goal.enter begin fun gl -> let sigma = Tacmach.New.project gl in let to_ind c = if isInd sigma c then fst (destInd sigma c) else user_err Pp.(str "not an inductive type") in let l = List.map to_ind l in Elim.h_decompose l c end let () = Tacentries.tactic_extend __coq_plugin_name "decompose" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("decompose", Tacentries.TyIdent ("[", Tacentries.TyArg ( Extend.TUlist1 ( Extend.TUentry (Genarg.get_arg_tag wit_constr)), Tacentries.TyIdent ("]", Tacentries.TyArg ( Extend.TUentry (Genarg.get_arg_tag wit_constr), Tacentries.TyNil))))), (fun l c ist -> # 1081 "plugins/ltac/extratactics.mlg" decompose l c )))] let () = Vernacextend.vernac_extend ~command:"Declare_keys" ~classifier:(fun _ -> Vernacextend.classify_as_sideeff) ?entry:None [(Vernacextend.TyML (false, Vernacextend.TyTerminal ("Declare", Vernacextend.TyTerminal ("Equivalent", Vernacextend.TyTerminal ("Keys", Vernacextend.TyNonTerminal (Extend.TUentry (Genarg.get_arg_tag wit_constr), Vernacextend.TyNonTerminal (Extend.TUentry (Genarg.get_arg_tag wit_constr), Vernacextend.TyNil))))), (let coqpp_body c c' () = Vernacextend.VtDefault (fun () -> # 1087 "plugins/ltac/extratactics.mlg" let get_key c = let env = Global.env () in let evd = Evd.from_env env in let (evd, c) = Constrintern.interp_open_constr env evd c in let kind c = EConstr.kind evd c in Keys.constr_key kind c in let k1 = get_key c in let k2 = get_key c' in match k1, k2 with | Some k1, Some k2 -> Keys.declare_equiv_keys k1 k2 | _ -> () ) in fun c c' ~atts -> coqpp_body c c' (Attributes.unsupported_attributes atts)), None))] let () = Vernacextend.vernac_extend ~command:"Print_keys" ~classifier:(fun _ -> Vernacextend.classify_as_query) ?entry:None [(Vernacextend.TyML (false, Vernacextend.TyTerminal ("Print", Vernacextend.TyTerminal ("Equivalent", Vernacextend.TyTerminal ("Keys", Vernacextend.TyNil))), (let coqpp_body () = Vernacextend.VtDefault (fun () -> # 1103 "plugins/ltac/extratactics.mlg" Feedback.msg_notice (Keys.pr_keys Printer.pr_global) ) in fun ~atts -> coqpp_body (Attributes.unsupported_attributes atts)), None))] let () = Vernacextend.vernac_extend ~command:"OptimizeProof" ?entry:None [(Vernacextend.TyML (false, Vernacextend.TyTerminal ("Optimize", Vernacextend.TyTerminal ("Proof", Vernacextend.TyNil)), (let coqpp_body () = Vernacextend.VtModifyProof ( # 1109 "plugins/ltac/extratactics.mlg" fun ~pstate -> Proof_global.compact_the_proof pstate ) in fun ~atts -> coqpp_body (Attributes.unsupported_attributes atts)), Some # 1108 "plugins/ltac/extratactics.mlg" classify_as_proofstep )); (Vernacextend.TyML (false, Vernacextend.TyTerminal ("Optimize", Vernacextend.TyTerminal ("Heap", Vernacextend.TyNil)), (let coqpp_body () = Vernacextend.VtDefault (fun () -> # 1111 "plugins/ltac/extratactics.mlg" Gc.compact () ) in fun ~atts -> coqpp_body (Attributes.unsupported_attributes atts)), Some # 1110 "plugins/ltac/extratactics.mlg" classify_as_proofstep ))] # 1116 "plugins/ltac/extratactics.mlg" let tclOPTIMIZE_HEAP = Proofview.tclLIFT (Proofview.NonLogical.make (fun () -> Gc.compact ())) let () = Tacentries.tactic_extend __coq_plugin_name "optimize_heap" ~level:0 [(Tacentries.TyML (Tacentries.TyIdent ("optimize_heap", Tacentries.TyNil), (fun ist -> # 1124 "plugins/ltac/extratactics.mlg" tclOPTIMIZE_HEAP )))]