Use this theorem
Create a project
lake +leanprover/lean4:v4.35.0 new myproject std.toml cd myprojectStandard template, not
math: themathtemplate adds its own Mathlib requirement pinned to the Lean release tag, not to the Mathlib commit this package is built and tested with, so you would get a second, different Mathlib. Mathlib comes in through this package. Skip this step in an existing project with the same Lean and Mathlib.Add the dependency to
lakefile.toml[[require]] name = "formalizations" git = "https://github.com/karlesmarin/formalizations" rev = "v0.15.0"Import the minimal module
import Formalizations.Reusable.LinearAlgebraIn a file of the project, e.g.
Example.lean.Paste the example
open Formalizations.Reusable Matrix open scoped Kronecker open PowerSeries in open scoped PowerSeries in /-- A block upper-triangular matrix with identity diagonal blocks is invertible, whatever its corner `B`: its rank is at least `2 + 2`. -/ example (B : Matrix (Fin 2) (Fin 2) β) : 4 β€ (fromBlocks (1 : Matrix (Fin 2) (Fin 2) β) B 0 (1 : Matrix (Fin 2) (Fin 2) β)).rank := by have h := matrix_rank_add_rank_le_rank_fromBlocks (1 : Matrix (Fin 2) (Fin 2) β) B (1 : Matrix (Fin 2) (Fin 2) β) simpa only [rank_one, Fintype.card_fin] using hSteps 3 and 4 together are a complete Lean file:
FormalizationsTest/ReusableLinearAlgebraExample.leanat v0.15.0, compiled by the CI.Fetch and check
lake update lake lean Example.leanlake updatefetches this package and Mathlib, and Mathlib's update hook downloads the compiled Mathlib (lake exe cache get).lake lean Example.leanbuilds the imports of the file (steps 3 and 4) and checks it. If the file belongs to alean_libof your project,lake build <lib>does the same. Avoid a barelake buildin a project from the standard template: its default target is the executable, whose link compiles every imported Mathlib module to native code. Same versions required: Leanv4.35.0, Mathlibf0b4c81.
Alternative: import Formalizations.Reusable imports the whole layer (all areas).
Over a field, rank A + rank D β€ rank of the block upper-triangular matrix fromBlocks A B 0 D.
Lean statement
theorem matrix_rank_add_rank_le_rank_fromBlocks {l n o p K : Type*} [Field K] [Fintype n]
[Fintype o] (A : Matrix l n K) (B : Matrix l o K) (D : Matrix p o K) :
A.rank + D.rank β€ (fromBlocks A B 0 D).rankLinks
Lean docstring
Lower bound for the rank of a block upper-triangular matrix. Over a field K, for blocks A : l Γ n, B : l Γ o and D : p Γ o, rank A + rank D β€ rank !![A, B; 0, D]. Together with rank_fromBlocks_zeroββ_le_card_add_rank it pins the rank of a block-triangular certificate between rank A + rank D and |l| + rank D; with A invertible both bounds agree.
- Archive:
Matrix.rank_add_rank_le_rank_fromBlocks_zeroββ(Formalizations.LinearAlgebra.Matrix.Rank, used by the free-locus certificates of the same archive); proved through the nullity bound for block triangular matrices. - Classical reference: textbook (e.g. G. Marsaglia, G. P. H. Styan, Equalities and inequalities for ranks of matrices, Linear and Multilinear Algebra 2 (1974) 269β292).
- Example: with
A = D = 1 : Matrix (Fin 2) (Fin 2) β, anyBgives4 β€ rank !![1, B; 0, 1], so the4 Γ 4block matrix is invertible.
Upstream
the lower-bound companion of R0009 and R0017; Mathlib has no rank bound for fromBlocks
Depends on, in this repository
Formalizations.LinearAlgebra.Matrix.BlockRank