Zulip Chat Archive

Stream: general

Topic: gpow on `matrix n n K`


Yakov Pechersky (Jul 15 2021 at 01:46):

Thanks to linear_algebra.matrix.nonsingular_inverse, we have a has_inv (matrix n n K). However, that does not provide a has_pow (matrix n n K) int. What is the right way to provide that? Directly? What's the correct algebraic structure to give here?

Eric Wieser (Jul 15 2021 at 02:02):

I think that instance requires a group

Eric Wieser (Jul 15 2021 at 02:02):

There's also fpow instead of gpow which requires a group_with_zero

Yakov Pechersky (Jul 15 2021 at 02:05):

You can define it by casing on the int, and for things that are truly invertible, (units.coe_hom _).map_pow will work on the two cases. But it monoid_hom.map_gpow won't work, of course, due to the restriction to groups...

Yakov Pechersky (Jul 15 2021 at 02:06):

Can one give matrix n n K group_with_zero then?

Eric Wieser (Jul 15 2021 at 02:08):

Only when n=unit

Eric Wieser (Jul 15 2021 at 02:09):

There are non-invertible non-zero matrices

Yakov Pechersky (Jul 15 2021 at 02:27):

I see -- the issue is evident below

import linear_algebra.matrix.nonsingular_inverse

open_locale matrix
open matrix

variables {n α : Type*} [fintype n] [decidable_eq n] [comm_ring α]

noncomputable instance : div_inv_monoid (matrix n n α) :=
{ ..matrix.has_inv,
  ..(show monoid (matrix n n α), by apply_instance) }

lemma matrix.inv_def (M : matrix n n α) : M⁻¹ = nonsing_inv M := rfl

lemma matrix.nonsing_inv_of_not_is_unit {M : matrix n n α} (h : ¬ is_unit M) :
  M⁻¹ = 0 :=
begin
  rw is_unit_iff_is_unit_det at h,
  simp [matrix.inv_def, nonsing_inv, h]
end

lemma matrix.inv_zero [nontrivial n] [nontrivial α] : (0 : matrix n n α)⁻¹ = 0 :=
matrix.nonsing_inv_of_not_is_unit (by simp)

noncomputable instance [nontrivial n] [nontrivial α] : group_with_zero (matrix n n α) :=
{ zero_mul := λ _, matrix.zero_mul _,
  mul_zero := λ _, matrix.mul_zero _,
  inv_zero := matrix.inv_zero,
  mul_inv_cancel := λ M hM, sorry, -- if `¬ is_unit M` then `0 = 1`
  ..(show has_zero (matrix n n α), by apply_instance),
  ..(show nontrivial (matrix n n α), by apply_instance),
  ..(show div_inv_monoid (matrix n n α), by apply_instance) }

Kevin Buzzard (Jul 15 2021 at 05:53):

Square matrices over a semiring are a monoid with zero

Yury G. Kudryashov (Jul 15 2021 at 06:45):

You can try to generalize the gpow instance to a monoid+has_inv but it won't have many nice properties.

Yury G. Kudryashov (Jul 15 2021 at 06:46):

So, it might be better to copy definition from fpow or gpow, then prove lemmas that are true for matrices (or operators).

Kevin Buzzard (Jul 15 2021 at 06:50):

Square matrices over a field shouldn't really have an inv, because of matrices like (0100)\begin{pmatrix}01\\00\end{pmatrix}.

Anne Baanen (Jul 15 2021 at 07:00):

My proposal was to define has_inv as (some choice of) pseudoinverse, which would give sensible results for a few more matrices. But that might actually have less nice properties than the nonsingular inverse.

Yakov Pechersky (Jul 15 2021 at 12:48):

Are there any lemmas about monoid_with_zero that are worth having for matrices? I can do the specialized fpow approach for matrices.

Eric Wieser (Jul 15 2021 at 12:49):

I assume you mean group_with_zero, monoid_with_zero is already true for matrices

Yakov Pechersky (Jul 15 2021 at 12:50):

Sorry, I was trying to parse Kevin's statement

Kevin Buzzard (Jul 15 2021 at 14:19):

"Monoids with zero shouldn't have an inv"


Last updated: Dec 20 2023 at 11:08 UTC