Zulip Chat Archive

Stream: Is there code for X?

Topic: Fin.mulNat etc.


Wrenna Robson (Dec 13 2023 at 19:42):

We seem to be missing these from the library - am I just failing to find them?

import Mathlib.Data.Fin.Basic

namespace Fin

def mulNat {n : } (i : Fin n) (m : ) (h : 0 < m) : Fin (n * m) :=
  i * m, Nat.mul_lt_mul_of_pos_right i.prop h

lemma coe_mulNat {n : } (i : Fin n) (m : ) (h : 0 < m) : (i.mulNat m h : ) = i * m := rfl

lemma mulNat_mk {n i m : } (hi : i < n) (h : 0 < m) : mulNat i, hi m h = i * m := rfl

def natMul {m : } (n : ) (i : Fin m) (h : 0 < n) : Fin (n * m) :=
  n * i, Nat.mul_lt_mul_of_pos_left i.prop h

lemma natMul_mk {m n i : } (hi : i < m) (h : 0 < n) : natMul n i, hi h = n * i := rfl

lemma coe_natMul {m : } (n : ) (i : Fin m) (h : 0 < n) : (i.natMul n h : ) = n * i := rfl

lemma divNat_mk {n m i : } (hi : i < m * n) : divNat i, hi = i / n := rfl

lemma modNat_mk {n m i : } (hi : i < m * n) : modNat i, hi = i % n := rfl

end Fin

Yaël Dillies (Dec 13 2023 at 19:43):

This should probably be about ZMod instead since you could drop the 0 < m assumption.

Wrenna Robson (Dec 13 2023 at 19:48):

Possibly! But we already have e.g. Fin.subNat and so forth.


Last updated: Dec 20 2023 at 11:08 UTC