Zulip Chat Archive

Stream: Is there code for X?

Topic: Zero det of rank lt


Martin Dvořák (Dec 04 2024 at 14:57):

When a square matrix has nonmaximal rank, its determinant is 0.

Direct lemma does not exist.
Should I search for it through a notion of a singular matrix?
What is the definition I need?
I know IsUnit exists.

Jireh Loreaux (Dec 04 2024 at 15:09):

Together docs#Matrix.rank_of_isUnit, docs#Matrix.isUnit_iff_isUnit_det will show that if a matrix has nonmaximal rank, then the determinant is not a unit. If you want to get that the determinant is zero, you'll need to consider matrices over a field to use something like docs#isUnit_iff_ne_zero.

Jireh Loreaux (Dec 04 2024 at 15:13):

import Mathlib

variable {n 𝕜 : Type*} [Fintype n] [DecidableEq n] [Field 𝕜]

example (A : Matrix n n 𝕜) (hA: A.rank < Fintype.card n) : A.det = 0 := by
  contrapose hA
  rw [ ne_eq,  isUnit_iff_ne_zero,  Matrix.isUnit_iff_isUnit_det] at hA
  exact A.rank_of_isUnit hA |>.not_lt

Jireh Loreaux (Dec 04 2024 at 15:18):

As for how to find this. Note that you already had the first bit: docs#IsUnit, and you can use Loogle to find the rest for you.

First we link the rank to IsUnit: @loogle Matrix.rank, IsUnit

loogle (Dec 04 2024 at 15:18):

:search: Matrix.rank_of_isUnit, Matrix.rank_mul_eq_left_of_isUnit_det, and 1 more

Jireh Loreaux (Dec 04 2024 at 15:18):

Then we link the determinant to IsUnit: @loogle Matrix.det, IsUnit

loogle (Dec 04 2024 at 15:18):

:search: Matrix.isUnit_det_transpose, Matrix.nonsingInvUnit, and 59 more

Jireh Loreaux (Dec 04 2024 at 15:18):

Then we link the determinant being a unit to the nonzero condition: @loogle IsUnit, ?a ≠ 0

loogle (Dec 04 2024 at 15:18):

:search: IsUnit.ne_zero, IsUnit.mk0, and 75 more

Martin Dvořák (Dec 04 2024 at 15:24):

Should I PR your lemma so that future users don't have to go through the search?

Junyan Xu (Dec 04 2024 at 15:41):

variable {n 𝕜 : Type*} [Fintype n] [DecidableEq n] [Field 𝕜]
example (A : Matrix n n 𝕜) (hA: A.rank < Fintype.card n) : A.det = 0

This should still be true if 𝕜 is a domain because e.g. we can map the matrix into the FractionRing. The map is injective so if you get zero det over the field it's also zero over the domain. To see that this preserves the rank I see no easier way than to 1) consider the associated linear map, whose range has the same rank as the matrix; 2) use the existing results that the base change of the range is the range of the base-changed linear map (LinearMap.range_localizedMap_eq_localized₀_range), and that rank is preserved under (IsLocalizedModule.lift_rank_eq).

Martin Dvořák (Dec 04 2024 at 16:19):

Indeed, I will have to look into the generalization; ideally, I want to have the lemma for matrices over integers.

Martin Dvořák (Dec 04 2024 at 16:20):

Let's postpone the potential PR until we have the most general version.

Floris van Doorn (Dec 04 2024 at 21:25):

Can docs#Matrix.rank_of_isUnit (and the new lemma) be upgraded to an iff?

Junyan Xu (Dec 04 2024 at 21:39):

docs#Matrix.rank_of_isUnit cannot; consider the 1x1 matrix with the single entry 2 : ℤ. Its rank is 1 because the range of the associated linear map is 2ℤ which is isomorphic to and of rank 1, but its determinant is 2, which isn't a unit.

Riccardo Brasca (Dec 04 2024 at 21:51):

I have the impression that if the rank is not maximal then the determinant must be nilpotent, but I may be wrong.

Riccardo Brasca (Dec 04 2024 at 21:57):

There are criteria for surjectivity involving the ideal generated by all the minors iirc

Eric Wieser (Dec 04 2024 at 22:54):

Is it sufficient for the determinant to satisfy docs#IsRegular ?

Kevin Buzzard (Dec 05 2024 at 07:57):

I don't even know what "rank" means if you're not over a field.

Junyan Xu (Dec 05 2024 at 09:47):

It's defined to be the Module.rank of the range of the associated linear map. It especially makes sense over a PID, where every submodule of a finite free module is also free.

Kevin Buzzard (Dec 05 2024 at 10:15):

This is just the sort of daft thing we end up with in mathlib because people write definitions in the max generality for which it compiles. So the open questions in this thread (assuming the base is a commutative ring, my sanity won't let me go any lower) are: does det regular (ie not a zero divisor) imply full rank and does not-full rank imply nilpotent det? These can't both be right because in K[X,Y]/(XY) the element X is neither regular nor nilpotent but I'm about to get on a plane so can't think about this online any more. Is the 1*1 matrix (X) "full rank" or not? :-/

Kevin Buzzard (Dec 05 2024 at 10:17):

The geometric answer (ie the sensible answer) is "yes on one component of the scheme, no on the other"

Antoine Chambert-Loir (Dec 05 2024 at 12:18):

There is a determinantal criterion for injectivity— a square matrix is injective iff its determinant is regular. Is it in mathlib?
That will imply full rank.
But it is not a necessary assumption, in a product ring A x B, multiplication by (1, 0) has rank one (for A nonzero) but is neither injective nor surjective.

Antoine Chambert-Loir (Dec 05 2024 at 12:19):

The absolute rank of a module is not a good invariant, what makes more sense is the function on the spectrum, ranks of the tensor products with the various residual fields

Junyan Xu (Dec 05 2024 at 14:43):

Antoine Chambert-Loir said:

There is a determinantal criterion for injectivity— a square matrix is injective iff its determinant is regular. Is it in mathlib?
That will imply full rank.

To formalize this proof it looks like we will need #18771.

in a product ring A x B, multiplication by (1, 0) has rank one (for A nonzero) but is neither injective nor surjective.

I don't think it has rank one (according to Mathlib definition)? The only (A x B)-linearly independent subset contained in the range A x 0 is the empty set.

Martin Dvořák (Dec 05 2024 at 16:49):

I am a computer scientist, hence I naturally think about rank in terms of the Gaussian elimination.
It prevents me from seeing the more general things that could be there.

Kevin Buzzard (Dec 05 2024 at 22:55):

What's going on is that the Gaussian elimination algorithm involves division and all the discussion above is trying to make it work for rings, where division isn't in general defined.

Eric Wieser (Dec 05 2024 at 23:45):

Kevin Buzzard said:

assuming the base is a commutative ring, my sanity won't let me go any lower

Avery your eyes from #19581 then!


Last updated: May 02 2025 at 03:31 UTC