Repository navigation
Conversation
Fixes #1246. `NormMp.norm_mpath`, `norm_xfun` and `norm_xpv` memoise their results in `env.env_norm`, which is a `ref` in the otherwise persistent `env`. An environment derived from another one shared this `ref` unless the operation that derived it copied it, which only `Mod.bind` and `Mod.bind_local` did. What was cached in the new environment, about paths that it binds, then also reached the environment it came from. When that environment is used again, a module defined later at the same path is normalised as the old one. In the example of the issue, the procedure `M.q` of the new `M` is normalised to `N1.f`, the target of the old `M.q`, which is enough to prove `false`. This happens: - after a command that fails once the body of a module has been typed, or at the end of a section that defines a local module: the body is typed in an environment made by `enter`; - after `pragma reset` or an undo, which go back to an environment that shares the cache with the one after `end T` or `require T`. Entering a scope, and binding a theory, a module or a theory alias, now give the new environment its own copy of the cache (`fork_norm`), and so does `EcEnv.copy`. The other bindings (operators, lemmas, ...) do not bring module paths and still share it, so that the entries computed in proofs are kept.
strub
force-pushed
the
fix-norm-cache
branch
from
November 29, 2026 09:37
89ccf59 to
8118d6c
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 #1246.
NormMp.norm_mpath,norm_xfunandnorm_xpvmemoise their resultsin
env.env_norm, which is arefin the otherwise persistentenv.An environment derived from another one shared this
refunless theoperation that derived it copied it, which only
Mod.bindandMod.bind_localdid. What was cached in the new environment, aboutpaths that it binds, then also reached the environment it came from.
When that environment is used again, a module defined later at the
same path is normalised as the old one. In the example of the issue,
the procedure
M.qof the newMis normalised toN1.f, thetarget of the old
M.q, which is enough to provefalse. Thishappens:
typed, or at the end of a section that defines a local module: the
body is typed in an environment made by
enter;pragma resetor an undo, which go back to an environmentthat shares the cache with the one after
end Torrequire T.Entering a scope, and binding a theory, a module or a theory alias,
now give the new environment its own copy of the cache
(
fork_norm), and so doesEcEnv.copy. The other bindings(operators, lemmas, ...) do not bring module paths and still share
it, so that the entries computed in proofs are kept.