Zulip Chat Archive

Stream: Is there code for X?

Topic: Additive coercions


Ashvni Narayanan (Nov 29 2021 at 20:26):

I want to define a coercion from to a ring R which is additive, that is , something to this effect :

example (n : ) [has_coe  R] (coe :  →+ R) {s : finset (zmod n)} {f : (zmod n)  } :
   a in s, ((f a) : R) = ( a in s, (f a)) :=

Here any space works in place of zmod n (I think). Is there something I am missing? I think using rat.cast_add should do it, but I am not sure.
Any help is appreciated, thank you!

Yakov Pechersky (Nov 29 2021 at 20:32):

Do you want to define a coercion, or given such a coercion which is an add_hom, prove that lemma?

Kevin Buzzard (Nov 29 2021 at 20:34):

guessing docs#finset.sum_coe or docs#finset.coe_sum ? Nope...

Kevin Buzzard (Nov 29 2021 at 20:36):

Hmm I guess I see why not -- how does one say that the coercion is a monoid hom? We do have docs#add_monoid_hom.finset_sum_apply though -- maybe that helps

Ashvni Narayanan (Nov 29 2021 at 20:39):

Yakov Pechersky said:

Do you want to define a coercion, or given such a coercion which is an add_hom, prove that lemma?

I think I would like to use the canonical rat.cast.

Yakov Pechersky (Nov 29 2021 at 20:44):

If I understand correctly, rat.cast casts a rat into a division_ring. Is that the case for R here?

Yakov Pechersky (Nov 29 2021 at 20:46):

import data.zmod.basic

variables {R : Type*} [ring R] [has_coe  R]

open_locale big_operators

example {n : } (s : finset (zmod n)) (f : (zmod n)  ) {coe' :  →+ R}
  (h :  q : , (q : R) = coe' q) :
   a in s, ((f a) : R) = ( a in s, (f a)) :=
by simpa [h] using (coe'.map_sum f s).symm

Yakov Pechersky (Nov 29 2021 at 20:47):

That's a #mwe, with more proper argument explicit/implicit style, and the crucial hypothesis you need to prove, which I called h.

Ashvni Narayanan (Nov 29 2021 at 22:22):

Yakov Pechersky said:

import data.zmod.basic

variables {R : Type*} [ring R] [has_coe  R]

open_locale big_operators

example {n : } (s : finset (zmod n)) (f : (zmod n)  ) {coe' :  →+ R}
  (h :  q : , (q : R) = coe' q) :
   a in s, ((f a) : R) = ( a in s, (f a)) :=
by simpa [h] using (coe'.map_sum f s).symm

This is helpful, thank you!


Last updated: Dec 20 2023 at 11:08 UTC