Zulip Chat Archive
Stream: mathlib4
Topic: apply? giving output which then fails
Bolton Bailey (Jan 25 2024 at 20:22):
import Mathlib
theorem MvPolynomial.degreeOf_C_mul_le {R σ : Type} [CommSemiring R] [DecidableEq σ] (j : σ)
(c : R) (f : MvPolynomial σ R) :
MvPolynomial.degreeOf j (MvPolynomial.C c * f) ≤ MvPolynomial.degreeOf j f := by
unfold degreeOf
have := degrees_mul (C c) f
simp [MvPolynomial.degrees_C] at this
-- exact? -- exact Multiset.count_le_of_le j this
exact Multiset.count_le_of_le j this -- type mismatch
Ruben Van de Velde (Jan 25 2024 at 20:28):
Looks like the difference is in the decidability instance; convert
instead of exact
works
Kim Morrison (Jan 30 2024 at 01:21):
What's going on under the hood here?
import Mathlib
theorem MvPolynomial.degreeOf_C_mul_le {R σ : Type} [CommSemiring R] [DecidableEq σ] (j : σ)
(c : R) (f : MvPolynomial σ R) :
MvPolynomial.degreeOf j (MvPolynomial.C c * f) ≤ MvPolynomial.degreeOf j f := by
unfold degreeOf
have := degrees_mul (C c) f
simp [MvPolynomial.degrees_C] at this
-- what `exact?` is actually doing is:
apply (config := {allowSynthFailures := true}) Multiset.count_le_of_le
solve_by_elim*
Kim Morrison (Jan 30 2024 at 01:22):
Curiously even though apply Multiset.count_le_of_le
by itself fails with a typeclass synthesis error, with (config := {allowSynthFailures := true})
it doesn't actually return any additional goals!
Kim Morrison (Jan 30 2024 at 01:22):
That seems a bit mysterious.
Kim Morrison (Jan 30 2024 at 01:23):
One approach here would be to have exact?
verify that its suggestion really works, and if it doesn't, try again with convert
, and then report that if it works.
Kim Morrison (Jan 30 2024 at 01:23):
This could be done without touching the internals of exact?
, but instead as a wrapper around Std.Tactic.TryThis.addExactSuggestion
.
Kim Morrison (Jan 30 2024 at 01:23):
Anyone interested?
Last updated: May 02 2025 at 03:31 UTC