Zulip Chat Archive
Stream: new members
Topic: Learning class declaration
Luiz Kazuo Takei (Nov 06 2025 at 19:54):
I am trying to learn about class declaration and tried to define an Abelian group like this:
class AbGroup (G : Type) extends HMul G G G, Inv G, One G where
mul_assoc : ∀ x y z, x * y * z = x * (y * z)
one_mul : ∀ x, 1 * x = x
mul_inv : ∀ x, x * x⁻¹ = 1
mul_comm : ∀ x y, x * y = y * x
In the mul_assoc type, I get an error message saying
typeclass instance problem is stuck, it is often due to metavariables
HMul ?m.31 (?m.39 x y z) (?m.35 x y z)
Could anyone help me understand why?
Ruben Van de Velde (Nov 06 2025 at 19:55):
Does it work with ∀ x y z : G, ...?
Luiz Kazuo Takei (Nov 06 2025 at 19:56):
Yes, it does! Thanks!
Luiz Kazuo Takei (Nov 06 2025 at 19:57):
By the way, I read somewhere that I should avoid using the class Mul and instead use HMul. Is this correct?
Ruben Van de Velde (Nov 06 2025 at 20:13):
I'm not sure I'd agree with that
Ruben Van de Velde (Nov 06 2025 at 20:13):
But perhaps it was in a context where this was relevant
Luiz Kazuo Takei (Nov 06 2025 at 20:16):
It must be an AI hallucination then... :P I believe it even said that Mul was deprecated and was there only to be compatible with Lean 3.
Thanks for clarifying it.
Kevin Buzzard (Nov 06 2025 at 23:05):
Kevin Buzzard (Nov 06 2025 at 23:06):
Kevin Buzzard (Nov 06 2025 at 23:07):
Yeah mathlib's Group extends Semigroup (via Monoid etc) and Semigroup uses Mul.
Last updated: Dec 20 2025 at 21:32 UTC