Zulip Chat Archive

Stream: general

Topic: instance


Kenny Lau (Aug 13 2018 at 11:47):

algebra/module.lean:

instance range {f : β  γ} (hf : is_linear_map f) : is_submodule (set.range f) :=
by rw [ set.image_univ]; exact is_submodule.image hf

should this be an instance?

Mario Carneiro (Aug 13 2018 at 11:51):

no good, unless is_linear_map is a typeclass

Kenny Lau (Aug 13 2018 at 12:32):

what to do about it then

Mario Carneiro (Aug 13 2018 at 12:37):

fix it?

Guy Leroy (Aug 14 2018 at 16:31):

I'm struggling with instances, I have the error:
failed to synthesize type class instance for

a n : ,
_inst_1 : pos_nat n,
em : coprime a n
 decidable_eq (coprime a n  Π [_inst_1 : pos_nat n], units (zmod n))

How should I state the instance that would solve this?

Patrick Massot (Aug 14 2018 at 16:42):

You should give us more context, this goal is probably not what you actually want

Mario Carneiro (Aug 14 2018 at 16:46):

While I agree with patrick, I doubt that this is the right goal to solve, it is incidentally provable. Probably the missing piece is decidable (pos_nat n)

Guy Leroy (Aug 14 2018 at 16:47):

Thanks Patrick, you're right, I made a mistake when writing my goal and it's all fixed now.
I would still be curious as to what this instance actually means.
As for the context I wrote

have : (units_zmod_mk a n) ^ order_of (units_zmod_mk a n), from pow_order_of_eq_one (units_zmod_mk a n),

instead of

have  : (units_zmod_mk a n em) ^ order_of (units_zmod_mk a n em) = 1, from pow_order_of_eq_one (units_zmod_mk a n em),

and I have defined above

def units_zmod_mk (a n :  ) (h : nat.coprime a n) [pos_nat n] : units (zmod n) :=
{
    val := a,
    inv := a⁻¹,
    val_inv := by rw [mul_inv_eq_gcd n a, coprime.gcd_eq_one h];dsimp;rw zero_add,
    inv_val := by rw [mul_comm, mul_inv_eq_gcd n a, coprime.gcd_eq_one h];dsimp;rw zero_add,
}

Guy Leroy (Aug 14 2018 at 16:47):

Okay thanks Mario

Mario Carneiro (Aug 14 2018 at 16:49):

I assume the decidable_eq goal is coming from order_of

Guy Leroy (Aug 14 2018 at 16:55):

Very well thanks, I'm slowly trying to get a grasp of instances


Last updated: Dec 20 2023 at 11:08 UTC