Zulip Chat Archive

Stream: Is there code for X?

Topic: Rank of a vector space


Yakov Pechersky (May 11 2021 at 03:07):

After the basis refactor, what is the right way to say that the dimension of the vector space of n x n matrices over \R is n x n? Before, I had the following:

variables {n m : }

-- An n × n matrix has some finite basis of cardinality n ^ 2
example :  (b : finset (matrix (fin n) (fin n) )),
            (is_basis  (subtype.val : (b : set (MnR n))  (MnR n)) 
            (finset.card b = n ^ 2)) :=
begin
  obtain s, s_basis := finite_dimensional.exists_is_basis_finset  (MnR n),
  refine s, s_basis, _⟩,
  rw [finite_dimensional.finrank_eq_card_finset_basis s_basis,
      matrix.finrank_matrix, fintype.card, finset.card_fin, pow_two]
end

-- An m × n matrix has some finite basis of cardinality m * n
example :  (b : finset (matrix (fin m) (fin n) )),
            (is_basis 
              (subtype.val : (b : set (matrix (fin m) (fin n) ))  (matrix (fin m) (fin n) )) 
            (finset.card b = m * n)) :=
begin
  obtain s, s_basis := finite_dimensional.exists_is_basis_finset  (matrix (fin m) (fin n) ),
  refine s, s_basis, _⟩,
  rw [finite_dimensional.finrank_eq_card_finset_basis s_basis,
      matrix.finrank_matrix],
  repeat { rw [fintype.card, finset.card_fin] }
end

Yakov Pechersky (May 11 2021 at 03:11):

@Anne Baanen

Johan Commelin (May 11 2021 at 04:00):

@Yakov Pechersky Can't you write findim (matrix (fin m) (fin n) ℝ) = m * n?

Yakov Pechersky (May 11 2021 at 04:02):

Yes, but that doesn't state that there is some finset with finset.card or fintype with fintype.card that could form a basis.

Johan Commelin (May 11 2021 at 04:08):

Hmm, but that's not specific to matrices. So we should prove that as a general lemma.

Johan Commelin (May 11 2021 at 04:10):

If you are finite dimensional:

  • Then there exists a finset that is a basis
  • Any two bases have the same fintype.card
  • Any basis has cardinality findim

Johan Commelin (May 11 2021 at 04:10):

I hope that some of those are already in mathlib, but I haven't used this part much...

Yakov Pechersky (May 11 2021 at 04:10):

Yes, is there such a lemma? My examples above are from an offshoot repo that showcases mathlib with simple undergrad examples

Kevin Buzzard (May 11 2021 at 07:48):

While we're here, what's the right way to say that an add_comm_group Λ\Lambda is finite and free as a Z\Z-module, i.e. isomorphic to Zn\Z^n for some n0n\geq0?

Johan Commelin (May 11 2021 at 07:58):

We need to turn finite_free from LTE into a typeclass predicate on R-modules, and build some API around it.

Anne Baanen (May 11 2021 at 08:29):

Yakov Pechersky said:

Yes, but that doesn't state that there is some finset with finset.card or fintype with fintype.card that could form a basis.

These kinds of results can (still) be found in finite_dimensional.lean. I did have to rename/adapt them slightly, but there should be nothing missing.

So exists_is_basis_finset is now docs#finite_dimensional.finset_basis and docs#finite_dimensional.finrank_eq_card_finset_basis is still the same.

Anne Baanen (May 11 2021 at 08:32):

Johan Commelin said:

If you are finite dimensional:

  • Then there exists a finset that is a basis
  • Any two bases have the same fintype.card
  • Any basis has cardinality findim

Anne Baanen (May 11 2021 at 08:34):

Kevin Buzzard said:

While we're here, what's the right way to say that an add_comm_group Λ\Lambda is finite and free as a Z\Z-module, i.e. isomorphic to Zn\Z^n for some n0n\geq0?

At the moment you can say something like Σ (n : ℕ), basis (fin n) ℤ Λ like the conclusion for docs#submodule.basis_of_pid.

The finite_free typeclass sounds like a very good idea though!

Anne Baanen (May 11 2021 at 08:41):

Updated examples:

import data.real.basic
import linear_algebra.matrix

variables {n m : }

abbreviation MnR (n : ) := matrix (fin n) (fin n) 

-- An n × n matrix has some finite basis of cardinality n ^ 2
example :  (s : finset (matrix (fin n) (fin n) ))
            (b : basis ((s : set (MnR n)) : Type*)  (MnR n)), -- Why isn't there a nice coe_to_sort on finset?
            (finset.card s = n ^ 2) :=
begin
  let s_basis := finite_dimensional.finset_basis  (MnR n),
  refine _, s_basis, _⟩,
  rw [finite_dimensional.finrank_eq_card_finset_basis s_basis,
      matrix.finrank_matrix, fintype.card, finset.card_fin, pow_two]
end

-- An m × n matrix has some finite basis of cardinality m * n
example :  (s : finset (matrix (fin m) (fin n) ))
            (b : basis ((s : set (matrix (fin m) (fin n) )) : Type*)  (matrix (fin m) (fin n) )),
            (finset.card s = m * n) :=
begin
  let s_basis := finite_dimensional.finset_basis  (matrix (fin m) (fin n) ),
  refine _, s_basis, _⟩,
  rw [finite_dimensional.finrank_eq_card_finset_basis s_basis,
      matrix.finrank_matrix],
  repeat { rw [fintype.card, finset.card_fin] }
end

Johan Commelin (May 11 2021 at 08:42):

-- Why isn't there a nice coe_to_sort on finset?

:this:

Anne Baanen (May 11 2021 at 08:50):

#7575

Eric Wieser (May 11 2021 at 09:02):

Should finset be set_like?

Eric Wieser (May 11 2021 at 09:03):

It wasn't originally what I was trying to do when I created set_like, but is maybe still appropriate


Last updated: Dec 20 2023 at 11:08 UTC