Repository navigation
Make dependent elimination compatible with Set Mangle Names - #734
Merged
Merged
Conversation
Member
|
@thomas-lamiaux can you rebase this now? Hopefully this will run a reverse-deps CI on metarocq checking this does not break it. |
thomas-lamiaux
force-pushed
the
fix-mangle-names-733
branch
from
October 25, 2026 20:42
5660eed to
af9908f
Compare
Member
|
@thomas-lamiaux as I expected, this does break metarocq |
thomas-lamiaux
force-pushed
the
fix-mangle-names-733
branch
from
October 26, 2026 16:47
af9908f to
a5bf107
Compare
…ver#733) Preserve explicit elimination pattern names and names of existing hypotheses under Mangle Names. Restore covering binder names after refining dependent elimination, preserve surrounding patterns implicitly, and reintroduce reverted hypotheses with their binder names in the depelim/noconf pipeline. Restrict these naming and shadowing changes to mangled mode. Reserving implicit names also changes ordinary collision freshening: a temporary na0 can push a generated constructor argument to na1 and break existing proofs, as in MetaRocq's PCUICSpine.v. Keep the previous patterns, covering rules, and intro behavior when mangling is off. Read Mangle Names at tactic execution so Set/Unset changes take effect in the same session. Cover default names, numeric collisions, shadowing, option toggling, explicit pattern names, and light mangling with a custom prefix in the regression suite. Fixes rocq-prover#733. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
mattam82
force-pushed
the
fix-mangle-names-733
branch
from
November 2, 2026 18:13
a5bf107 to
90bb746
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #733.
Under
Set Mangle Names,dependent elimination ... as [pat]did not bind the pattern names, and both it anddepelim/noconfmangled the names of the pre-existing hypotheses they revert and reintroduce, making proofs using them impossible to write in a mangle-robust way (unlikeinversion ... as).Root cause
The covering contexts already carry the intended binder names: user-given names are installed verbatim by
Covering.rename_domain, and generated names are freshened (and mangled, when the option is set) by the covering engine itself. The names are lost at the very last step: when the subgoal evars are created,Evarutil.push_rel_context_to_named_contextregenerates every hypothesis name throughNamegen.next_ident_away, which appliesmangle_idindiscriminately — binder names carry no user/generated provenance, so Rocq cannot tell them apart. By contrast,inversion/destructintroduce their hypotheses in the existing named context withNamingMustBe-style intros, which bypass name generation.Fix
depelim.ml: after refining with the covering term, rename the hypotheses of each subgoal back to the binder names of the corresponding covering context. The mapping is collected from theComputeleaves of the splitting tree: each leaf's evar instance aligns its (mangled) named context with the covering rel context positionally. In the default mode this is a no-op, since the evar naming reuses the binder names. The surrounding-context patterns of the generated clauses are also markedImplicitrather thanGeneratedso their names are preserved byrename_domain.covering.ml: name priorityUser > Implicit > Generated: an explicit pattern name takes priority over an implicitly named variable (e.g. a preexisting hypothesis name) both when binding pattern variables and in the shadowing check, andrename_domaindropsImplicitbindings whose name is already taken instead of producing duplicate hypothesis names. (Without this, e.g.HoTT_light.v'sdependent elimination b as [(a, 1)]witha := xin the context would fail.)context_map.ml:context_map_to_lhs ~keep_namesreuses context binder names verbatim for variable patterns, used by pattern-lessdependent eliminationso that the unrelated hypotheses keep their names while the fresh constructor arguments still get mangled ones.extra_tactics.ml/CoreTactics.v: newintro_binder_nametactic that introduces the next hypothesis reusing its binder name verbatim (subscript-freshened, never mangled);intros_until_blocknow uses it, which fixes the Ltac-baseddepelim/noconf/dependent inductionpipeline that reverts the telescope behind ablockand reintroduced it with plainintro.Generated names remain mangled as the option intends; only names the user wrote (as-patterns or existing hypothesis names) survive.
Testing
test-suite/issue733.vcovering all the issue's scenarios plusnoconf.HoTT_light.v) and test-suite pass.🤖 Generated with Claude Code