mathlib4 icon indicating copy to clipboard operation
mathlib4 copied to clipboard

fix(Tactic/Simps): skip @[defeq] inference for non-exposed definitions

Open kim-em opened this issue 2 months ago • 1 comments

This PR makes @[simps] check whether the source definition's body is exposed before calling inferDefEqAttr. When the body is not exposed, we skip the @[defeq] inference to avoid validation errors.

Without this fix, using @[simps] on a definition that is not @[expose]d produces an error like:

Theorem Foo_bar has a `rfl`-proof and was thus inferred to be `@[defeq]`, but validating that attribute failed:
 Not a definitional equality: the left-hand side ... is not definitionally equal to the right-hand side ...
 Note: This theorem is exported from the current module. This requires that all definitions that need to be unfolded to prove this theorem must be exposed.

The fix checks (← getEnv).setExporting true |>.find? cfg.srcDeclName |>.any (·.hasValue) to determine if the definition body is visible in the public scope, and only calls inferDefEqAttr if it is.

🤖 Prepared with Claude Code

kim-em avatar Dec 17 '25 03:12 kim-em

PR summary 87b2aabda3

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff

+ MyStruct + helperVal + myDef

You can run this locally as follows
## summary with just the declaration names:
./scripts/declarations_diff.sh <optional_commit>

## more verbose report:
./scripts/declarations_diff.sh long <optional_commit>

The doc-module for script/declarations_diff.sh contains some details about this script.


No changes to technical debt.

You can run this locally as

./scripts/technical-debt-metrics.sh pr_summary
  • The relative value is the weighted sum of the differences with weight given by the inverse of the current value of the statistic.
  • The absolute value is the relative value divided by the total sum of the inverses of the current values (i.e. the weighted average of the differences).

github-actions[bot] avatar Dec 17 '25 03:12 github-actions[bot]

Now you don't need the srcDeclName field anymore right?

JovanGerb avatar Dec 19 '25 09:12 JovanGerb

The test file is not currently a module. So I don't see how it is testing what it says it is testing.

JovanGerb avatar Dec 20 '25 00:12 JovanGerb

The test file is not currently a module. So I don't see how it is testing what it says it is testing.

Indeed, thanks. Fixed now.

kim-em avatar Dec 20 '25 00:12 kim-em

I copy-pasted the test file into the web editor, and it successfully build. Maybe you meant to add public section to the test file?

JovanGerb avatar Dec 20 '25 01:12 JovanGerb