Zulip Chat Archive
Stream: lean4
Topic: Can't inline lemma to rw
Bolton Bailey (Oct 19 2023 at 14:27):
MWE:
import Mathlib.RingTheory.IntegralDomain
import Mathlib.FieldTheory.Finite.Basic
open scoped Classical
theorem Polynomial.sum_eval_eq_iff' {F : Type} [Field F] [Fintype F] {G : Subgroup (Units (F))} (σ : F) :
σ = (Fintype.card G) * (σ / (Fintype.card G)) := by
-- rw [mul_div_cancel' (FiniteField.card_cast_subgroup_card_ne_zero G)]
-- -- did not find instance of the pattern in the target expression
rw [mul_div_cancel']
exact FiniteField.card_cast_subgroup_card_ne_zero G
-- works fine
Why can I not do the first one?
Matthew Ballard (Oct 19 2023 at 14:29):
rw [mul_div_cancel' _ (FiniteField.card_cast_subgroup_card_ne_zero G)]
Bolton Bailey (Oct 19 2023 at 14:30):
Thank you, I'm dumb.
Matthew Ballard (Oct 19 2023 at 14:30):
Just ambitious :)
Bolton Bailey (Oct 19 2023 at 14:30):
Wait I'm still confused
Bolton Bailey (Oct 19 2023 at 14:31):
Why is the first one not a type error then?
Matthew Ballard (Oct 19 2023 at 14:36):
It looks like Lean tries to make sense of that as (a : ?G0)
Bolton Bailey (Oct 19 2023 at 14:37):
If I do have := mul_div_cancel' (FiniteField.card_cast_subgroup_card_ne_zero G)
it gives
typeclass instance problem is stuck, it is often due to metavariables
CommGroupWithZero ?m.1195
Why isn't that the error I see in my example?
Matthew Ballard (Oct 19 2023 at 14:38):
It appears if you trace the output with trace.Meta.isDefEq
Bolton Bailey (Oct 19 2023 at 14:40):
It seems to me I shouldn't have to do a fancy trace to see that if this is the problem
Eric Wieser (Oct 19 2023 at 14:45):
I think in the context of rw
, stuck TC problems are allowed and resolved later
Eric Wieser (Oct 19 2023 at 14:45):
But it's still weird that that example gets that far, because it looks like there's a universe issue long before a typeclass issue
Last updated: Dec 20 2023 at 11:08 UTC