lean4-htt/tests/pkg
Joachim Breitner b9243e19be
feat: make equational theorems of non-exposed defs private (#8519)
This PR makes the equational theorems of non-exposed defs private. If
the author of a module chose not to expose the body of their function,
then they likely don't want that implementation to leak through
equational theorems. Helps with #8419.

There is some amount of incidential complexity due to how `private`
works in lean, by mangling the name: lots of code paths that need now do
the right thing™ about private and non-private names, including the
whole reserved name machinery.

So this includes a number of refactorings:

* The logic for calculating an equational theorem name (or similar) is
now done by a single function, `mkEqLikeNameFor`, rather than all over
the place.

* Since the name of the equational theorem now depends on the current
context (in particular whether it’s a proper module, or a non-module
file), the forward map from declaration to equational theorem doesn’t
quite work anymore. This map is deleted; the list of equational theorems
are now always found by looking for declaration of the expected names
(`alreadyGenerated). If users define such theorems themselves (and make
it past the “do not allow reserved names to be declared”) they get to
keep both pieces.

* Because this map was deleted, mathlib’s `eqns` command can no longer
easily warn if equational lemmas have already been generated too early
(adaption branch exists). But in general I think lean could provide a
more principled way of supporting custom unfold lemmas, and ideally the
whole equational theorem machinery is just using that.

* The ReservedNamePredicate is used by `resolveExact`, so we need to
make sure that it returns the right name, including privateness. It is
not ok to just reserve both the private and non-private name but then
later in the ReservedNameAction produce just one of the two.
 
* We create `foo.def_eq` eagerly for well-founded recursion. This is
needed because we need feed in the proof of the rewriting done by
`wf_preprocess`. But if `foo.def_eq` is private in a module, then a
non-module importing it will still expect a non-private `foo.def_eq` to
exist. To patch that, we install a `copyPrivateUnfoldTheorem :
GetUnfoldEqnFn` that declares a theorem aliasing the private one. Seems
to work.
2025-06-04 11:52:08 +00:00
..
builtin_attr fix: make sure monad lift coercion elaborator has no side effects (#6024) 2024-11-13 16:22:31 +00:00
debug feat: debug_assert! (#7256) 2025-03-03 16:34:44 +00:00
deriving chore: update tests to account for .lake 2023-11-13 20:31:24 -05:00
frontend feat: lake: support plugins (#7001) 2025-02-14 04:57:31 +00:00
initialize fix: missing unboxing in interpreter when loading initialized value (#4512) 2024-06-20 10:06:24 +00:00
linter_set feat: implement "linter sets" that can be turned on as a group (#8106) 2025-05-14 23:30:42 +00:00
misc feat: allow duplicate theorems to be imported 2024-03-13 12:57:41 -07:00
module feat: make equational theorems of non-exposed defs private (#8519) 2025-06-04 11:52:08 +00:00
path with spaces fix: calling programs with spaces on Windows (#4515) 2024-07-26 17:35:05 +00:00
prv feat: structure instance notation elaboration improvements (#7717) 2025-03-30 17:40:36 +00:00
setup feat: lean --setup (#8024) 2025-05-03 23:57:37 +00:00
test_extern test: disable flaky test 2025-04-29 17:34:10 +02:00
user_attr chore: upstream Nat material from mathlib (#7971) 2025-04-16 06:55:32 +00:00
user_attr_app feat: importModules without loading environment extensions (#6325) 2025-04-02 08:37:11 +00:00
user_ext chore: disable nondeterministic test 2025-04-24 11:30:26 +02:00
user_opt feat: accept user-defined options on the cmdline (#4741) 2024-08-02 12:24:56 +00:00
user_plugin feat: smarter plugin loading (#7090) 2025-02-18 23:03:52 +00:00
.gitignore chore: ignore forgotten Lake test artifacts 2023-11-17 21:25:41 -05:00