Skip to content

Commit 46f23b6

Browse files
authored
Merge pull request #581 from LPCIC/fix-evar-loss
fix sigma pruning when calling ltac, reachability is not correct
2 parents 1ed6c4e + 849a95d commit 46f23b6

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed

coq-builtin-synterp.elpi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,10 +306,12 @@ external pred coq.env.current-section-path o:list string.
306306
kind clause type.
307307
type clause id -> grafting -> prop -> clause.
308308

309-
% Specify if the clause has to be grafted before or after a named clause
309+
% Specify if the clause has to be grafted before, grafted after or replace
310+
% a named clause
310311
kind grafting type.
311312
type before id -> grafting.
312313
type after id -> grafting.
314+
type replace id -> grafting.
313315

314316
% Specify to which module the clause should be attached to
315317
kind scope type.

coq-builtin.elpi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1711,10 +1711,12 @@ external pred coq.extra-dep i:id, o:option id.
17111711
kind clause type.
17121712
type clause id -> grafting -> prop -> clause.
17131713

1714-
% Specify if the clause has to be grafted before or after a named clause
1714+
% Specify if the clause has to be grafted before, grafted after or replace
1715+
% a named clause
17151716
kind grafting type.
17161717
type before id -> grafting.
17171718
type after id -> grafting.
1719+
type replace id -> grafting.
17181720

17191721
% Specify to which module the clause should be attached to
17201722
kind scope type.

examples/example_abs_evars.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ solve (goal _ _ _ _ [trm T] as G) GL :-
8888
solve (goal _ _ T _ [] as G) GL :-
8989
std.assert! (abs-evars T ClosedT N) "closure fails",
9090
coq.mk-app {{ (fun x : lp:ClosedT => x) _ }} {coq.mk-n-holes N} R,
91-
refine R G GL.
91+
refine R G GL.
9292

9393
}}.
9494
Elpi Typecheck.

src/coq_elpi_HOAS.ml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2414,7 +2414,10 @@ let get_declared_goals all_goals constraints state assignments pp_ctx =
24142414

24152415
let rec reachable1 sigma root acc =
24162416
let EvarInfo info = Evd.find sigma root in
2417-
let res = match Evd.evar_body info with Evd.Evar_empty -> Evar.Set.add root acc | Evd.Evar_defined _ -> acc in
2417+
let res =
2418+
match Evd.evar_body info with
2419+
| Evd.Evar_empty -> Evar.Set.add root acc
2420+
| Evd.Evar_defined d -> acc in
24182421
let res = Evar.Set.union res @@ Evarutil.filtered_undefined_evars_of_evar_info sigma info in
24192422
if Evar.Set.equal res acc then acc else reachable sigma res res
24202423
and reachable sigma roots acc =
@@ -2432,13 +2435,14 @@ let reachable sigma roots acc =
24322435
let solution2evd sigma0 { API.Data.constraints; assignments; state; pp_ctx } roots =
24332436
let state, solved_goals, _, _gls = elpi_solution_to_coq_solution ~calldepth:0 constraints state in
24342437
let sigma = get_sigma state in
2435-
let all_goals = reachable sigma roots Evar.Set.empty in
2438+
let roots = Evd.fold_undefined (fun k _ acc -> Evar.Set.add k acc) sigma0 roots in
2439+
let reachable_undefined_evars = reachable sigma roots Evar.Set.empty in
24362440
let declared_goals, shelved_goals =
2437-
get_declared_goals (Evar.Set.diff all_goals solved_goals) constraints state assignments pp_ctx in
2441+
get_declared_goals (Evar.Set.diff reachable_undefined_evars solved_goals) constraints state assignments pp_ctx in
24382442
debug Pp.(fun () -> str "Goals: " ++ prlist_with_sep spc Evar.print declared_goals);
24392443
debug Pp.(fun () -> str "Shelved Goals: " ++ prlist_with_sep spc Evar.print shelved_goals);
24402444
Evd.fold_undefined (fun k _ sigma ->
2441-
if Evar.Set.mem k all_goals || Evd.mem sigma0 k then sigma
2445+
if Evar.Set.mem k reachable_undefined_evars then sigma
24422446
else Evd.remove sigma k
24432447
) sigma sigma,
24442448
declared_goals,

0 commit comments

Comments
 (0)