Skip to content

Commit f348e2d

Browse files
committed
ltac: any/simple APIs with sealed/unsealed goals
1 parent d453e00 commit f348e2d

File tree

12 files changed

+719
-144
lines changed

12 files changed

+719
-144
lines changed

apps/coercion/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ coercion _ X Ty {{ @sig lp:Ty lp:P }} Solution :- std.do! [
6161
Solution = {{ @exist lp:Ty lp:P lp:X1 _ }},
6262
% we call the solver
6363
coq.ltac.collect-goals Solution [G] [],
64-
coq.ltac.open (coq.ltac.call-ltac1 "my_solver") G [],
64+
coq.ltac.open (x\y\coq.ltac.call-any-ltac1 "my_solver" x y ok) G [],
6565
].
6666
6767
}}.

apps/coercion/tests/test_open.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ coercion _ X Ty {{ @sig lp:Ty lp:P }} Solution :- std.do! [
1212
Solution = {{ @exist lp:Ty lp:P lp:X1 _ }},
1313
% we call the solver
1414
coq.ltac.collect-goals Solution [G] [],
15-
coq.ltac.open (coq.ltac.call-ltac1 "my_solver") G [],
15+
coq.ltac.open (x\y\coq.ltac.call-any-ltac1 "my_solver" x y ok) G [],
1616
].
1717

1818
}}.

builtin-doc/coq-builtin.elpi

Lines changed: 58 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1634,7 +1634,7 @@ kind ltac1-tactic type.
16341634
% Level can be left unspecified and defaults to 0
16351635
external type coq.ltac.fail int -> variadic any (func).
16361636

1637-
% [coq.ltac.collect-goals T Goals ShelvedGoals]
1637+
% [coq.ltac.collect-any-goals T Goals ShelvedGoals]
16381638
% Turns the holes in T into Goals.
16391639
% Goals are closed with nablas.
16401640
% ShelvedGoals are goals which can be solved by side effect (they occur
@@ -1643,11 +1643,23 @@ external type coq.ltac.fail int -> variadic any (func).
16431643
% (a
16441644
% fold_left over the terms, letin body comes before the type).
16451645
%
1646-
external func coq.ltac.collect-goals term -> list sealed-goal,
1647-
list sealed-goal.
1646+
external func coq.ltac.collect-any-goals term -> list sealed-goal,
1647+
list sealed-goal.
16481648

1649-
% [coq.ltac.call-mltac PluginName BlockName BlockIndex G GL] Calls OCaml
1650-
% code bound via TACTIC EXTEND. For example the
1649+
1650+
func coq.ltac.collect-goals term -> list sealed-goal, list sealed-goal.
1651+
coq.ltac.collect-goals T GA GB :- coq.ltac.collect-any-goals T GA GB.
1652+
1653+
1654+
% [coq.ltac.collect-simple-goals T Goals ShelvedGoals] Like
1655+
% coq.ltac.collect-goals turns the holes in T into
1656+
% Goals but fails if the goals do not live in the current context.
1657+
%
1658+
external func coq.ltac.collect-simple-goals term -> list goal,
1659+
list sealed-goal.
1660+
1661+
% [coq.ltac.call-any-mltac PluginName BlockName BlockIndex G GL Diagnostic]
1662+
% Calls OCaml code bound via TACTIC EXTEND. For example the
16511663
% OCaml code for lia looks like:
16521664
%
16531665
% DECLARE PLUGIN "rocq-runtime.plugins.micromega"
@@ -1665,13 +1677,27 @@ external func coq.ltac.collect-goals term -> list sealed-goal,
16651677
% numbering
16661678
% starts from 0. Also, each block has a name, "Lia" in this case.
16671679
%
1680+
% When the diagnostic is (error Msg), then GL is not set.
1681+
%
1682+
% Supported attributes:
1683+
% - @no-tc! (default false, do not infer typeclasses)
1684+
external func coq.ltac.call-any-mltac string, string, int,
1685+
goal -> list sealed-goal, diagnostic.
1686+
1687+
% [coq.ltac.call-simple-mltac PluginName BlockName BlockIndex G GL
1688+
% Diagnostic] Like coq.ltac.call-any-mltac but Tac is not allowed to
1689+
% generate new goals GL in different contexts. For example "intro" does
1690+
% not
1691+
% obey this restriction.
1692+
%
16681693
% Supported attributes:
16691694
% - @no-tc! (default false, do not infer typeclasses)
1670-
external func coq.ltac.call-mltac string, string, int,
1671-
goal -> list sealed-goal.
1695+
external func coq.ltac.call-simple-mltac string, string, int,
1696+
goal -> list goal, diagnostic.
16721697

1673-
% [coq.ltac.call-ltac1 Tac G GL] Calls Ltac1 tactic Tac on goal G (passing
1674-
% the arguments of G, see coq.ltac.call for a handy wrapper).
1698+
% [coq.ltac.call-any-ltac1 Tac G GL Diagnostic] Calls Ltac1 tactic Tac on
1699+
% goal G (passing the arguments of G, see coq.ltac.call for a handy
1700+
% wrapper).
16751701
% Tac can either be a string (the tactic name), or a value
16761702
% of type ltac1-tactic, see the tac argument constructor
16771703
% and the ltac_tactic:(...) syntax to pass arguments to
@@ -1681,9 +1707,31 @@ external func coq.ltac.call-mltac string, string, int,
16811707
% "Ltac name := body", it cannot be a builtin one. For example
16821708
% "Ltac myapply x := apply x." lets one call apply by running
16831709
% coq.ltac.call-ltac1 "myapply" G GL.
1710+
%
1711+
% When the diagnostic is (error Msg), then GL is not set.
1712+
%
1713+
% Supported attributes:
1714+
% - @no-tc! (default false, do not infer typeclasses)
1715+
external func coq.ltac.call-any-ltac1 any, goal -> list sealed-goal,
1716+
diagnostic.
1717+
1718+
1719+
func coq.ltac.call-ltac1 any, goal -> list sealed-goal.
1720+
coq.ltac.call-ltac1 Tac G GL :-
1721+
coq.warning "elpi.deprecated" "elpi.ltac.call-ltac1" "use ltac.call-any-ltac1 with an extra diagnostic argument",
1722+
coq.ltac.call-any-ltac1 Tac G GL ok.
1723+
1724+
1725+
% [coq.ltac.call-simple-ltac1 Tac G GL Diagnostic] Like
1726+
% coq.ltac.call-any-ltac1 but Tac is not allowed to
1727+
% generate new goals GL in different contexts. For example "intro" does
1728+
% not
1729+
% obey this restriction.
1730+
%
16841731
% Supported attributes:
16851732
% - @no-tc! (default false, do not infer typeclasses)
1686-
external func coq.ltac.call-ltac1 any, goal -> list sealed-goal.
1733+
external func coq.ltac.call-simple-ltac1 any, goal -> list goal,
1734+
diagnostic.
16871735

16881736
% [coq.ltac.id-free? ID G]
16891737
% Fails if ID is already used in G. Note that ids which are taken are

0 commit comments

Comments
 (0)