lean4-htt/src/Lean/Meta/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
..
AC fix: grind.debug true when using grind +ring (#8134) 2025-04-27 20:28:08 +00:00
Grind feat: improve grind diagnostics for successful case (#8625) 2025-06-04 09:34:48 +00:00
Simp feat: create private aux decls in private contexts 2025-06-03 15:53:05 +02:00
Try feat: ematch generalized patterns (#8569) 2025-05-31 19:08:33 -07:00
AC.lean
Acyclic.lean
Apply.lean fix: Make split work with metavariables in the target (#8437) 2025-05-23 12:46:27 +00:00
Assert.lean
Assumption.lean
AuxLemma.lean feat: revamp aux decl name generation (#8363) 2025-05-16 14:57:18 +00:00
Backtrack.lean
Cases.lean feat: induction: allow complex arguments to motive in conclusion of eliminator (#8096) 2025-04-30 08:56:17 +00:00
Cleanup.lean
Clear.lean
Congr.lean
Constructor.lean
Contradiction.lean
Delta.lean
ElimInfo.lean fix: cases tactic to handle non-atomic eliminator well (#8361) 2025-05-15 16:59:11 +00:00
ExposeNames.lean
Ext.lean feat: add [grind ext] attribute (#7949) 2025-04-13 22:08:36 +00:00
FunInd.lean feat: make equational theorems of non-exposed defs private (#8519) 2025-06-04 11:52:08 +00:00
FunIndCollect.lean feat: fun_induction to unfold function application in the goal (#8104) 2025-05-13 09:37:39 +00:00
FunIndInfo.lean feat: fun_induction to unfold function application in the goal (#8104) 2025-05-13 09:37:39 +00:00
FVarSubst.lean
Generalize.lean
Grind.lean feat: improve E-matching pattern inference in grind (#8196) 2025-05-01 23:48:32 +00:00
IndependentOf.lean
Induction.lean
Injection.lean
Intro.lean doc: add docstrings to mkFreshUserName etc (#7947) 2025-04-14 04:17:45 +00:00
Lets.lean feat: extract_lets and lift_lets tactics (#6432) 2025-04-21 08:57:01 +00:00
LibrarySearch.lean
NormCast.lean
Refl.lean
Rename.lean
Repeat.lean
Replace.lean feat: clear_value tactic (#8449) 2025-05-27 01:52:08 +00:00
Revert.lean
Rewrite.lean
Rewrites.lean feat: validate, expose names, and add hovers for all suggestion tactics (#7474) 2025-04-07 01:11:39 +00:00
Rfl.lean feat: improve 'apply' unification error message (#8261) 2025-05-08 16:00:42 +00:00
Simp.lean
SolveByElim.lean
Split.lean fix: Make split work with metavariables in the target (#8437) 2025-05-23 12:46:27 +00:00
SplitIf.lean
Subst.lean
Symm.lean
Try.lean
TryThis.lean feat: add labeled subcomponents and helper functions for error messages (#8225) 2025-05-07 21:15:27 +00:00
Unfold.lean chore: revert "feat: make isRfl lazy" 2025-03-27 11:55:14 +01:00
UnifyEq.lean
Util.lean feat: add debug.terminalTacticsAsSorry (#8012) 2025-04-18 00:10:59 +00:00