Zulip Chat Archive
Stream: general
Topic: automated bugs
Damiano Testa (Apr 10 2024 at 20:50):
I wrote a small testing suite for finding common meta-programming bugs. It is quite rudimentary, but it found bugs in abel
and in cancel_denoms
. I have not used it extensively, but here is the PR, in case someone is curious!
Any comments are very welcome!
Damiano Testa (Apr 10 2024 at 20:50):
Here are the two auto-bugs:
import Mathlib.Tactic.CancelDenoms
import Mathlib.Tactic.Ring
import Mathlib.Tactic.Abel
universe u
section cancel_denoms
variable {α : Type u} [LinearOrderedField α] (a b : α)
-- found by automated testing
example (h : a > 0) : a / 5 > 0 := by
have := 0 -- works if you comment
cancel_denoms
exact h
end cancel_denoms
section abel
-- found by automated testing
example [AddCommGroup α] (a b s : α) : -b + (s - a) = s - b - a := by
have := 0 -- works if you comment
abel_nf
end abel
Alex J. Best (Apr 10 2024 at 22:59):
Wow this is very very cool!
Kim Morrison (Apr 12 2024 at 08:56):
Can we separate out the fixes to tactics in a separate PR?
Damiano Testa (Apr 12 2024 at 09:22):
Separated:
Kim Morrison (Apr 12 2024 at 09:50):
Eric just left comments on #12083, and I've :peace_sign:'d #12084.
Eric Wieser (Apr 12 2024 at 09:52):
I think my comments apply to both; I think we're solving the symptom not the problem here
Eric Wieser (Apr 12 2024 at 09:52):
The problem is that we're performing syntactic matching when we should almost certainly be performing reducible defeq matching
Eric Wieser (Apr 12 2024 at 09:53):
In both cases, I think a whnfR
, immediately before doing expression matching, is the right approach
Eric Wieser (Apr 12 2024 at 09:54):
(or switching to use ~q()
, but that's a more involved change with more downsides)
Damiano Testa (Apr 12 2024 at 09:54):
Ok, so at least in one case, this means making a "pure" def into a "monadic" one: is that correct?
Damiano Testa (Apr 12 2024 at 09:55):
Oh, I see that this is what you wrote in the PR!
Damiano Testa (Apr 12 2024 at 18:07):
I'm going to wait for #12084 to build and then will merge: if you have anything against it, let me know!
With the fix, abel
should work at reducible transparency, which seems to be what everyone wants and there is a test checking this.
Last updated: May 02 2025 at 03:31 UTC