lean4-htt/src/Lean/Elab/Tactic
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
..
BVDecide feat: make equational theorems of non-exposed defs private (#8519) 2025-06-04 11:52:08 +00:00
Conv feat: extract_lets and lift_lets tactics (#6432) 2025-04-21 08:57:01 +00:00
Omega feat: revamp aux decl name generation (#8363) 2025-05-16 14:57:18 +00:00
AsAuxLemma.lean feat: revamp aux decl name generation (#8363) 2025-05-16 14:57:18 +00:00
Basic.lean fix: apply? produces a non-synthetic sorry (#8231) 2025-05-05 12:31:08 +00:00
BoolToPropSimps.lean chore: rename simp sets (#7018) 2025-02-10 10:56:20 +00:00
BuiltinTactic.lean feat: different syntax for new clear_value tactic (#8516) 2025-05-28 22:33:35 +00:00
BVDecide.lean doc: review Int docstrings (#7568) 2025-03-20 14:04:56 +00:00
Calc.lean chore: fix spelling mistakes (#7328) 2025-04-07 01:15:48 +00:00
Change.lean fix: improvements to change tactic (#6022) 2024-11-16 07:08:29 +00:00
Classical.lean feat: make classical tactic incremental (#6575) 2025-01-08 13:04:31 +00:00
Config.lean chore: prepare for bootstrap 2024-11-19 09:26:58 +01:00
Congr.lean
Conv.lean feat: extract_lets and lift_lets tactics (#6432) 2025-04-21 08:57:01 +00:00
Delta.lean
DiscrTreeKey.lean fix: #discr_tree_simp_key shouldn't look into lhs of (#6936) 2025-02-04 08:43:12 +00:00
Doc.lean
ElabTerm.lean feat: improve 'apply' unification error message (#8261) 2025-05-08 16:00:42 +00:00
ExposeNames.lean feat: expose_names tactic (#6935) 2025-02-04 00:53:31 +00:00
Ext.lean feat: deprecate Array.mkArray in favour of Array.replicate 2025-03-24 08:25:00 +01:00
FalseOrByContra.lean
Generalize.lean
Grind.lean feat: ematch generalized patterns (#8569) 2025-05-31 19:08:33 -07:00
Guard.lean
Induction.lean fix: record fvar alias info for generalized variables in induction/cases (#8002) 2025-05-31 22:27:44 +00:00
Injection.lean fix: nontermination while generating equation lemmas for match-expressions (#6180) 2024-11-23 00:06:34 +00:00
Lets.lean feat: extract_lets and lift_lets tactics (#6432) 2025-04-21 08:57:01 +00:00
LibrarySearch.lean fix: apply? produces a non-synthetic sorry (#8231) 2025-05-05 12:31:08 +00:00
Location.lean feat: allow turnstiles anywhere in location sequences (#7431) 2025-03-11 15:34:40 +00:00
Match.lean
Meta.lean
Monotonicity.lean fix: mapError to store message data context (#8375) 2025-05-16 14:46:23 +00:00
NormCast.lean fix: ignore no_index around OfNat.ofNat in norm_cast (#6438) 2025-01-02 09:10:27 +00:00
Omega.lean
RCases.lean feat: add generalization hypotheses to induction tactic (#7103) 2025-02-18 03:46:23 +00:00
Repeat.lean
Rewrite.lean fix: deduplicate elaboration of constant argument to rw (#8232) 2025-05-15 11:33:10 +00:00
Rewrites.lean feat: validate, expose names, and add hovers for all suggestion tactics (#7474) 2025-04-07 01:11:39 +00:00
Rfl.lean
ShowTerm.lean feat: validate, expose names, and add hovers for all suggestion tactics (#7474) 2025-04-07 01:11:39 +00:00
Simp.lean fix: unknown identifier ranges (#8362) 2025-05-22 10:05:31 +00:00
Simpa.lean feat: implement "linter sets" that can be turned on as a group (#8106) 2025-05-14 23:30:42 +00:00
SimpArith.lean chore: simp_arith has been deprecated (#7043) 2025-02-12 03:55:45 +00:00
Simproc.lean fix: isDefEq, whnf, simp caching and configuration (#6053) 2024-11-18 01:17:26 +00:00
SimpTrace.lean fix: simp_all? and simp_all?! (#8491) 2025-05-27 07:07:12 +00:00
SolveByElim.lean
Split.lean
Symm.lean
TreeTacAttr.lean feat: builtin as_aux_lemma tactic and tree_tac simp attribute (#6823) 2025-02-03 08:34:29 +00:00
Try.lean feat: ematch generalized patterns (#8569) 2025-05-31 19:08:33 -07:00
Unfold.lean