lean4-htt/src
Joachim Breitner ac9a1cb415
feat: add @[backward_defeq] attribute and local useBackward simp option (#13492)
This PR introduces stricter inference for the `@[defeq]` attribute and a
companion `@[backward_defeq]` attribute that preserves the pre-PR
behavior
as an opt-in.

### What changed

* `@[defeq]` is now inferred only when the equation holds at
  `.instances` transparency (the transparency `dsimp` operates at).
* `@[backward_defeq]` is the old set: every theorem whose `rfl` proof
the legacy inference would have accepted is tagged `@[backward_defeq]`,
  so `defeq ⊆ backward_defeq` holds by construction.
* The option `backward.defeqAttrib.useBackward` (default `false`) makes
  `dsimp` also use `@[backward_defeq]` theorems, restoring the pre-PR
  behavior for a specific proof or file.
* The option is eqn-affecting: its value at the point of a function's
  definition is recorded so that the equation lemmas later generated for
  that function use the same value, regardless of the ambient option at
  the use site.

### Mathlib adaption

A companion adaption branch (`lean-pr-testing-backward-defeq-attrib` on
mathlib4) builds cleanly against this PR and passes `lake test` without
warnings. Most adaption changes are scoped
`set_option backward.defeqAttrib.useBackward true in` additions on the
failing declarations; a small number of files needed proof-level edits
where the stored form of a `dsimp%`/`@[reassoc]`/`@[elementwise]`
/`@[simps]`/`@[to_app]`-generated lemma had drifted under the stricter
regime.

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-27 10:07:59 +00:00
..
bin perf: separate meta and non-meta initializers (#12016) 2026-02-26 08:05:19 +00:00
cmake fix: use commondir to resolve git directory in worktrees (#13045) 2026-04-11 06:45:02 +00:00
include/lean fix: file read buffer overflow (#13392) 2026-04-13 17:56:27 +00:00
Init feat: add @[backward_defeq] attribute and local useBackward simp option (#13492) 2026-04-27 10:07:59 +00:00
initialize
kernel chore: fix spelling errors (#13274) 2026-04-04 07:34:34 +00:00
lake fix: lake: namespace in Lake.Util.Opaque (reapplied) (#13526) 2026-04-24 22:25:24 +00:00
Lean feat: add @[backward_defeq] attribute and local useBackward simp option (#13492) 2026-04-27 10:07:59 +00:00
library fix: potential Array.get!Internal leaks part 2 (#13148) 2026-03-27 02:51:39 +00:00
runtime fix: two bugs in io.cpp (#13427) 2026-04-16 12:38:17 +00:00
shell chore: move test suite setup to tests/CMakeLists.txt (#12278) 2026-02-03 13:22:20 +00:00
Std feat: add @[backward_defeq] attribute and local useBackward simp option (#13492) 2026-04-27 10:07:59 +00:00
util feat: allow deprecating options (#13195) 2026-04-02 14:44:11 +00:00
cadical.mk
CMakeLists.txt fix: pass CMake Lake args to the Lake make build (#13410) 2026-04-14 22:07:29 +00:00
config.h.in
githash.h.in
Init.lean feat: lake: add support for running environment linters (#13431) 2026-04-22 18:17:41 +00:00
lakefile.toml.in chore: use weakLeanArgs for Lake plugin (#13335) 2026-04-09 00:02:39 +00:00
lean-toolchain chore: relative lean-toolchains (#12652) 2026-02-25 10:23:35 +00:00
Lean.lean refactor: move getOriginalConstKind? into its own module to avoid future import cycle (#12265) 2026-02-01 16:18:51 +00:00
lean.mk.in
Leanc.lean
LeanChecker.lean refactor: remove Lean.Environment.replay from core (#12972) 2026-03-18 22:11:42 +00:00
LeanIR.lean chore: fixes from #13103 "enable separate codegen" (#13241) 2026-04-02 11:13:22 +00:00
out
Std.lean
stdlib.make.in fix: pass CMake Lake args to the Lake make build (#13410) 2026-04-14 22:07:29 +00:00
stdlib_flags.h chore: consistent build flags between USE_LAKE ON and OFF (#12941) 2026-03-17 11:02:55 +00:00
version.h.in