Zulip Chat Archive

Stream: Is there code for X?

Topic: Nat -> ZMod n -> ZMod m


Michael Stoll (Aug 29 2023 at 15:44):

This should be in mathlib, but I can't find it:

lemma foo {m n : } (h : m  n) (a : ) : ((a : ZMod n) : ZMod m) = (a : ZMod m)

or equivalently,

lemma bar {m n : } (h : m  n) : (ZMod.cast : ZMod n  ZMod m)  (Nat.cast :   ZMod n) = Nat.cast

Any ideas where it is hiding?

Ruben Van de Velde (Aug 29 2023 at 15:50):

ZMod.cast_nat_cast h

Michael Stoll (Aug 29 2023 at 15:51):

Found it:

lemma foo {m n : } (h : m  n) (a : ) : ((a : ZMod n) : ZMod m) = (a : ZMod m) :=
  ZMod.cast_nat_cast h a

(by apply? returned, among others, refine ZMod.cast_nat_cast ?h a, which, however, does not work when pasted in. Replacing ?h by h does it. Why does apply? not do that, too?)

Michael Stoll (Aug 29 2023 at 15:52):

BTW, ZMod.cast_nat_cast h does not work as a proof of bar.

Ruben Van de Velde (Aug 29 2023 at 15:53):

lemma bar {m n : } (h : m  n) : (ZMod.cast : ZMod n  ZMod m)  (Nat.cast :   ZMod n) = Nat.cast :=
  funext <| ZMod.cast_nat_cast h

Last updated: Dec 20 2023 at 11:08 UTC