lean4-htt/src/Lean
Joachim Breitner 24cb133eb2
feat: explicit defeq attribute (#8419)
This PR introduces an explicit `defeq` attribute to mark theorems that
can be used by `dsimp`. The benefit of an explicit attribute over the
prior logic of looking at the proof body is that we can reliably omit
theorem bodies across module boundaries. It also helps with intra-file
parallelism.

If a theorem is syntactically defined by `:= rfl`, then the attribute is
assumed and need not given explicitly. This is a purely syntactic check
and can be fooled, e.g. if in the current namespace, `rfl` is not
actually “the” `rfl` of `Eq`. In that case, some other syntax has be
used, such as `:= (rfl)`. This is also the way to go if a theorem can be
proved by `defeq`, but one does not actually want `dsimp` to use this
fact.

The `defeq` attribute will look at the *type* of the declaration, not
the body, to check if it really holds definitionally. Because of
different reduction settings, this can sometimes go wrong. Then one
should also write `:= (rfl)`, if one does not want this to be a defeq
theorem. (If one does then this is currently not possible, but it’s
probably a bad idea anyways).

The `set_option debug.tactic.simp.checkDefEqAttr true`, `dsimp` will
warn if could not apply a lemma due to a missing `defeq` attribute.

With `set_option backward.dsimp.useDefEqAttr.get false` one can revert
to the old behavior of inferring rfl-ness based on the theorem body.

Both options will go away eventually (too bad we can’t mark them as
deprecated right away, see #7969)

Meta programs that generate theorems (e.g. equational theorems) can use
`inferDefEqAttr` to set the attribute based on the theorem body of the
just created declaration.

This builds on #8501 to update Init to `@[expose]` a fair amount of
definitions that, if not exposed, would prevent some existing `:= rfl`
theorems from being `defeq` theorems. In the interest of starting
backwards compatible, I exposed these function. Hopefully many can be
un-exposed later again.

A mathlib adaption branch exists that includes both the meta programming
fixes and changes to the theorems (e.g. changing `:= by rfl` to `:=
rfl`).

With the module system there is now no special handling for `defeq`
theorem bodies, because we don’t look at the body anymore. The previous
hack is removed. The `defeq`-ness of the theorem needs to be checked in
the context of the theorem’s *type*; the error message contains a hint
if the defeq check fails because of the exported context.
2025-06-06 18:40:06 +00:00
..
Compiler fix: improve precision of the new compiler's noncomputable check for proj (#8647) 2025-06-05 22:44:02 +00:00
Data feat: signature help (#8511) 2025-06-03 17:26:33 +00:00
DocString feat: move non-essential metadata into .olean.server (#8068) 2025-04-24 08:12:26 +00:00
Elab feat: explicit defeq attribute (#8419) 2025-06-06 18:40:06 +00:00
Language fix: SnapshotTree.waitAll (#8532) 2025-05-29 20:12:23 +00:00
Linter feat: := private instance syntax 2025-05-28 10:18:04 +02:00
Meta feat: explicit defeq attribute (#8419) 2025-06-06 18:40:06 +00:00
Parser feat: #print sig (#8641) 2025-06-05 09:02:19 +00:00
ParserCompiler
PrettyPrinter fix: let private names be unresolved in the pretty printer, fix shadowing bug when pp.universes is true (#8617) 2025-06-03 23:37:35 +00:00
Server fix: wrong signature help after map/filter/etc (#8655) 2025-06-06 13:07:01 +00:00
Util feat: meta syntax 2025-06-04 18:26:05 +02:00
Widget feat: reusable rpc refs (#8105) 2025-06-03 12:35:12 +00:00
AddDecl.lean feat: explicit defeq attribute (#8419) 2025-06-06 18:40:06 +00:00
Attributes.lean feat: explicit defeq attribute (#8419) 2025-06-06 18:40:06 +00:00
AuxRecursor.lean refactor: split Lean.EnvironmentExtension from Lean.Environment (#7794) 2025-04-02 16:19:12 +00:00
BuiltinDocAttr.lean
Class.lean
Compiler.lean
CoreM.lean feat: create private aux decls in private contexts 2025-06-03 15:53:05 +02:00
Data.lean chore: remove the old Lean.Data.HashMap implementation (#7519) 2025-03-20 23:49:55 +00:00
Declaration.lean feat: explicit defeq attribute (#8419) 2025-06-06 18:40:06 +00:00
DeclarationRange.lean feat: move non-essential metadata into .olean.server (#8068) 2025-04-24 08:12:26 +00:00
DefEqAttrib.lean feat: explicit defeq attribute (#8419) 2025-06-06 18:40:06 +00:00
DocString.lean feat: language reference links and examples in docstrings (#7240) 2025-03-12 09:17:27 +00:00
Elab.lean feat: #info_trees in command (#6964) 2025-02-06 03:11:53 +00:00
EnvExtension.lean feat: make equational theorems of non-exposed defs private (#8519) 2025-06-04 11:52:08 +00:00
Environment.lean chore: revise environment constant addition details (#8610) 2025-06-03 15:16:45 +00:00
Exception.lean fix: unknown identifier ranges (#8362) 2025-05-22 10:05:31 +00:00
Expr.lean fix: block potential adversarial exploit of non-aborting assert! (#8560) 2025-05-31 03:14:01 +00:00
HeadIndex.lean
Hygiene.lean
ImportingFlag.lean
InternalExceptionId.lean
KeyedDeclsAttribute.lean
LabelAttribute.lean
Level.lean fix: block adversarial exploit of non-aborting assert! (#8559) 2025-05-31 00:08:30 +00:00
Linter.lean feat: implement "linter sets" that can be turned on as a group (#8106) 2025-05-14 23:30:42 +00:00
LoadDynlib.lean feat: smarter plugin loading (#7090) 2025-02-18 23:03:52 +00:00
LocalContext.lean fix: replace bad simp lemmas for Id (#7352) 2025-05-22 22:45:35 +00:00
Log.lean feat: 'unsolved goals' & 'goals accomplished' diagnostics (#7366) 2025-03-07 13:50:56 +00:00
Message.lean fix: improve error-message hint rendering and API (#8486) 2025-06-01 01:22:09 +00:00
Meta.lean feat: add labeled subcomponents and helper functions for error messages (#8225) 2025-05-07 21:15:27 +00:00
MetavarContext.lean doc: fix typo in MetavarDecl docstring (#8069) 2025-04-23 22:00:13 +00:00
Modifiers.lean refactor: split Lean.EnvironmentExtension from Lean.Environment (#7794) 2025-04-02 16:19:12 +00:00
MonadEnv.lean feat: revamp aux decl name generation (#8363) 2025-05-16 14:57:18 +00:00
Namespace.lean refactor: split Lean.EnvironmentExtension from Lean.Environment (#7794) 2025-04-02 16:19:12 +00:00
Parser.lean
ParserCompiler.lean feat: rename List.enum(From) to List.zipIdx, and Array/Vector.zipWithIndex to zipIdx (#6800) 2025-01-28 23:34:30 +00:00
PremiseSelection.lean feat: premise selection API (#7061) 2025-02-14 04:08:18 +00:00
PrettyPrinter.lean fix: don't reset localInstances in delaboration (#8022) 2025-04-19 15:39:16 +00:00
PrivateName.lean chore: do not use the coercion α → Option α in Init and Std (#8085) 2025-04-24 13:35:01 +00:00
ProjFns.lean refactor: split Lean.EnvironmentExtension from Lean.Environment (#7794) 2025-04-02 16:19:12 +00:00
ReducibilityAttrs.lean feat: add async support to more extensions and constructions (#7363) 2025-03-06 14:27:45 +00:00
Replay.lean chore: Mathlib fixes (#7327) 2025-03-04 13:41:30 +00:00
ReservedNameAction.lean feat: make equational theorems of non-exposed defs private (#8519) 2025-06-04 11:52:08 +00:00
ResolveName.lean fix: let private names be unresolved in the pretty printer, fix shadowing bug when pp.universes is true (#8617) 2025-06-03 23:37:35 +00:00
Runtime.lean
ScopedEnvExtension.lean feat: make more constructions async-compatible (#7384) 2025-03-10 09:56:30 +00:00
Server.lean fix: do not cancel async elaboration tasks (#7175) 2025-02-21 17:24:36 +00:00
Setup.lean feat: meta syntax 2025-06-04 18:26:05 +02:00
Structure.lean refactor: factor out common code for structure default values (#7737) 2025-03-31 22:40:39 +00:00
SubExpr.lean fix: replace bad simp lemmas for Id (#7352) 2025-05-22 22:45:35 +00:00
Syntax.lean fix: replace bad simp lemmas for Id (#7352) 2025-05-22 22:45:35 +00:00
ToExpr.lean feat: ToExpr IntX (#7268) 2025-02-28 09:32:30 +00:00
ToLevel.lean feat: upstream ToLevel from mathlib (#6285) 2024-12-05 05:50:32 +00:00
Util.lean feat: simp +arith sorts linear atoms (#7040) 2025-02-11 23:37:30 +00:00
Widget.lean