Zulip Chat Archive
Stream: general
Topic: by_contra performance
Bolton Bailey (Jun 14 2021 at 19:55):
Here is a performance issue that is causing me problems.
import data.finsupp.basic
section
universe u
parameter {F : Type u}
parameter [field F]
lemma test2 (A_β B_β A_α B_α : F) (h3 : B_β * A_β = 0)
(h4: B_α = 0)
(h2: A_α * B_β = 1)
(h5: B_β = 0 ∨ A_β = 0)
: A_β = 0 :=
begin
by_contra,
end
end
Working in VSCode on my laptop, it takes a full 50 seconds for the by_contra
tactic to finish processing. What is going on here?
Bolton Bailey (Jun 14 2021 at 20:11):
To explain what I mean more
begin
apply by_contra,
intro,
-- by_contra,
end
Runs in less than a second. It feels like this should be equivalent to the tactic form, but something must be going on.
Patrick Massot (Jun 14 2021 at 20:11):
This is clearly a decidability issue.
Patrick Massot (Jun 14 2021 at 20:11):
Try adding open_locale classical
before the lemma
Patrick Massot (Jun 14 2021 at 20:11):
Or maybe classical
as the first proof line
Bolton Bailey (Jun 14 2021 at 20:12):
open locale classical makes it much faster yes
Yaël Dillies (Jun 14 2021 at 20:14):
The thing is that by_contra
requires decidability of the proposition you're proving, so it first tries to prove that decidability by typeclass inference. But that takes an awful while because it doesn't find anything, and it eventually falls onto excluded middle.
Bolton Bailey (Jun 14 2021 at 20:20):
It doesn't seem like it requires decidability to me. https://leanprover-community.github.io/mathlib_docs/logic/basic.html#by_contra doesn't say anything about requiring decidability.
Bryan Gin-ge Chen (Jun 14 2021 at 20:21):
That's the theorem by_contra
, but you're using a tactic: https://leanprover-community.github.io/mathlib_docs/tactics.html#by_contra%20/%20by_contradiction
Bolton Bailey (Jun 14 2021 at 20:21):
The docs do say, though, that the tactic version requires decidability. Why should this be the case?
Bolton Bailey (Jun 14 2021 at 20:22):
In other words, why isn't the by_contra
tactic equivalent to apply by_contra, intro,
?
Patrick Massot (Jun 14 2021 at 20:24):
Who can pretend to understand constructivists?
Patrick Massot (Jun 14 2021 at 20:25):
Bolton Bailey (Jun 14 2021 at 20:31):
Probably my import I guess
Kevin Buzzard (Jun 14 2021 at 21:00):
@Ashvni Narayanan this is the issue you discovered about two weeks ago, which is still on my job list to ask about here -- looks like I no longer need to.
Mario Carneiro (Jun 15 2021 at 01:16):
50 seconds to fail to prove decidable_eq F
where field F
sounds pretty extreme though. Using open_locale classical
is probably the best workaround for this, but no typeclass search should be that bad
Last updated: Dec 20 2023 at 11:08 UTC