Skip to content

fix(phl): proc rewrite /= honors the proof-local simplify context - #1146

Merged
strub merged 1 commit into
mainfrom
fix/proc-rewrite-simpl-local-hint
Sep 22, 2026
Merged

strub merged 1 commit into
mainfrom
fix/proc-rewrite-simpl-local-hint

Conversation

@bgregoir

Copy link
Copy Markdown
Contributor

Fixes #1145.

process_rewrite_simpl reduced with a bare EcReduction.nodelta, whose
user_local is SimplifyContext.empty. Databases activated with
hint +db and lemmas added with hint {l} — whether by the standalone
command or by the scoped with hint ... (...) form — were therefore
invisible to proc rewrite /=, unlike every other reduction tactic
(t_cbv, t_cbn, simplify, cbv), which all thread
FApi.tc1_simplify_context.

-  let ri = EcReduction.nodelta in
+  let ri =
+    { EcReduction.nodelta with
+        EcReduction.user_local = FApi.tc1_simplify_context tc } in

The same ri is reused by the t_change discharging the side goal, so the
discharge stays consistent with the rewriting performed.

Tests

tests/procrewrite-simpl.ec gains five lemmas covering hint +db,
hint {l}, and both scoped forms. They keep the rule in a named database
so kernel conversion cannot fire it on its own, and drop the hint before
the closing apply — otherwise it is the apply's own conversion, which
does see the local context, that closes the goal, and the test passes even
with the bug present.

Checked in both directions by rebuilding: the four positive lemmas each
fail on unpatched main and pass with the patch. No regression on
procrewrite, procchange, match_codepos, local_hint_simplify,
hint_simplify_db, simplify_head_filter, simplify-delta-ops.
theories/crypto/assumptions/DHIES.ec uses the proc rewrite <pterm>
branch, which this patch does not touch.

Not included

The two related points listed at the end of the issue (ptenv_of_penv
without ~simpl:, and the absence of a use-site hint clause on
proc rewrite /=) are left out to keep this PR to the single fix.

`process_rewrite_simpl` reduced with a bare `EcReduction.nodelta`, whose
`user_local` is `SimplifyContext.empty`. The lemmas and databases added by
`hint ...` or by `with hint ... (...)` were therefore invisible to it, unlike
every other reduction tactic (`t_cbv`, `t_cbn`, `simplify`, `cbv`), which all
thread `FApi.tc1_simplify_context`.

The same `ri` is reused by the `t_change` that discharges the side goal, so
the discharge stays consistent with the rewriting performed.

The tests keep the rule in a named database and drop the hint before the
closing `apply`, so that only a rewriting of the program itself can close
the goal; each of them fails without the fix.
@strub strub self-assigned this Sep 22, 2026
@strub
strub added this pull request to the merge queue Sep 22, 2026
Merged via the queue into main with commit 1e2d06e Sep 22, 2026
19 checks passed
@strub
strub deleted the fix/proc-rewrite-simpl-local-hint branch September 22, 2026 06:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

proc rewrite /= ignores the proof-local simplify context (hint ..., with hint ... (...))

2 participants