|
| 1 | +/- |
| 2 | +Copyright (c) 2021 Riccardo Brasca. All rights reserved. |
| 3 | +Released under Apache 2.0 license as described in the file LICENSE. |
| 4 | +Authors: Riccardo Brasca |
| 5 | +
|
| 6 | +! This file was ported from Lean 3 source module linear_algebra.free_module.finite.matrix |
| 7 | +! leanprover-community/mathlib commit b1c23399f01266afe392a0d8f71f599a0dad4f7b |
| 8 | +! Please do not edit these lines, except to modify the commit id |
| 9 | +! if you have ported upstream changes. |
| 10 | +-/ |
| 11 | +import Mathlib.LinearAlgebra.Finrank |
| 12 | +import Mathlib.LinearAlgebra.FreeModule.Finite.Rank |
| 13 | +import Mathlib.LinearAlgebra.Matrix.ToLin |
| 14 | + |
| 15 | +/-! |
| 16 | +# Finite and free modules using matrices |
| 17 | +
|
| 18 | +We provide some instances for finite and free modules involving matrices. |
| 19 | +
|
| 20 | +## Main results |
| 21 | +
|
| 22 | +* `Module.Free.linearMap` : if `M` and `N` are finite and free, then `M →ₗ[R] N` is free. |
| 23 | +* `Module.Finite.ofBasis` : A free module with a basis indexed by a `Fintype` is finite. |
| 24 | +* `Module.Finite.linearMap` : if `M` and `N` are finite and free, then `M →ₗ[R] N` |
| 25 | + is finite. |
| 26 | +-/ |
| 27 | + |
| 28 | + |
| 29 | +universe u v w |
| 30 | + |
| 31 | +variable (R : Type u) (M : Type v) (N : Type w) |
| 32 | + |
| 33 | +open Module.Free (chooseBasis) |
| 34 | + |
| 35 | +open FiniteDimensional (finrank) |
| 36 | + |
| 37 | +section CommRing |
| 38 | + |
| 39 | +variable [CommRing R] [AddCommGroup M] [Module R M] [Module.Free R M] |
| 40 | + |
| 41 | +variable [AddCommGroup N] [Module R N] [Module.Free R N] |
| 42 | + |
| 43 | +set_option synthInstance.etaExperiment true in -- Porting note: gets around lean4#2074 |
| 44 | +instance Module.Free.linearMap [Module.Finite R M] [Module.Finite R N] : |
| 45 | + Module.Free R (M →ₗ[R] N) := by |
| 46 | + cases subsingleton_or_nontrivial R |
| 47 | + · apply Module.Free.of_subsingleton' |
| 48 | + classical exact |
| 49 | + Module.Free.of_equiv (LinearMap.toMatrix (chooseBasis R M) (chooseBasis R N)).symm |
| 50 | +#align module.free.linear_map Module.Free.linearMap |
| 51 | + |
| 52 | +variable {R} |
| 53 | + |
| 54 | +set_option synthInstance.etaExperiment true in -- Porting note: gets around lean4#2074 |
| 55 | +instance Module.Finite.linearMap [Module.Finite R M] [Module.Finite R N] : |
| 56 | + Module.Finite R (M →ₗ[R] N) := by |
| 57 | + cases subsingleton_or_nontrivial R |
| 58 | + · infer_instance |
| 59 | + classical |
| 60 | + have f := (LinearMap.toMatrix (chooseBasis R M) (chooseBasis R N)).symm |
| 61 | + exact Module.Finite.of_surjective f.toLinearMap (LinearEquiv.surjective f) |
| 62 | +#align module.finite.linear_map Module.Finite.linearMap |
| 63 | + |
| 64 | +end CommRing |
| 65 | + |
| 66 | +section Integer |
| 67 | + |
| 68 | +variable [AddCommGroup M] [Module.Finite ℤ M] [Module.Free ℤ M] |
| 69 | + |
| 70 | +variable [AddCommGroup N] [Module.Finite ℤ N] [Module.Free ℤ N] |
| 71 | + |
| 72 | +instance Module.Finite.addMonoidHom : Module.Finite ℤ (M →+ N) := |
| 73 | + Module.Finite.equiv (addMonoidHomLequivInt ℤ).symm |
| 74 | +#align module.finite.add_monoid_hom Module.Finite.addMonoidHom |
| 75 | + |
| 76 | +instance Module.Free.addMonoidHom : Module.Free ℤ (M →+ N) := |
| 77 | + letI : Module.Free ℤ (M →ₗ[ℤ] N) := Module.Free.linearMap _ _ _ |
| 78 | + Module.Free.of_equiv (addMonoidHomLequivInt ℤ).symm |
| 79 | +#align module.free.add_monoid_hom Module.Free.addMonoidHom |
| 80 | + |
| 81 | +end Integer |
| 82 | + |
| 83 | +section CommRing |
| 84 | + |
| 85 | +variable [CommRing R] [StrongRankCondition R] |
| 86 | + |
| 87 | +variable [AddCommGroup M] [Module R M] [Module.Free R M] [Module.Finite R M] |
| 88 | + |
| 89 | +variable [AddCommGroup N] [Module R N] [Module.Free R N] [Module.Finite R N] |
| 90 | + |
| 91 | +set_option synthInstance.etaExperiment true in -- Porting note: gets around lean4#2074 |
| 92 | +/-- The finrank of `M →ₗ[R] N` is `(finrank R M) * (finrank R N)`. -/ |
| 93 | +theorem FiniteDimensional.finrank_linearMap : finrank R (M →ₗ[R] N) = finrank R M * finrank R N := |
| 94 | + by |
| 95 | + classical |
| 96 | + letI := nontrivial_of_invariantBasisNumber R |
| 97 | + have h := LinearMap.toMatrix (chooseBasis R M) (chooseBasis R N) |
| 98 | + simp_rw [h.finrank_eq, FiniteDimensional.finrank_matrix, |
| 99 | + FiniteDimensional.finrank_eq_card_chooseBasisIndex, mul_comm] |
| 100 | +#align finite_dimensional.finrank_linear_map FiniteDimensional.finrank_linearMap |
| 101 | + |
| 102 | +end CommRing |
| 103 | + |
| 104 | +theorem Matrix.rank_vecMulVec {K m n : Type u} [CommRing K] [StrongRankCondition K] [Fintype n] |
| 105 | + [DecidableEq n] (w : m → K) (v : n → K) : (Matrix.vecMulVec w v).toLin'.rank ≤ 1 := by |
| 106 | + rw [Matrix.vecMulVec_eq, Matrix.toLin'_mul] |
| 107 | + refine' le_trans (LinearMap.rank_comp_le_left _ _) _ |
| 108 | + refine' (LinearMap.rank_le_domain _).trans_eq _ |
| 109 | + rw [rank_fun', Fintype.card_unit, Nat.cast_one] |
| 110 | +#align matrix.rank_vec_mul_vec Matrix.rank_vecMulVec |
0 commit comments