Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

le_rank and le_eq_of_rank for nested idempotents

Definition
IntMul_Kappa_R8_Data_BitOppbankMoveFactsLe

by Ethan Cheung Wang · Oct 28, 2026 · Mathlib 0df444a (Lean v4.33.1)

complexity-theoryinteger-multiplicationround-eight

For nested idempotent matrices (Le A B\mathrm{Le}\,A\,BLeAB), one has rank A≤rank B\mathrm{rank}\,A\le\mathrm{rank}\,BrankA≤rankB and rank(B−A)=rank B−rank A\mathrm{rank}(B-A)=\mathrm{rank}\,B-\mathrm{rank}\,Arank(B−A)=rankB−rankA. Equal rank forces A=BA=BA=B.

Definition code
-- MoveFactsLe: le_rank / le_eq_of_rank for nested idempotents (pure matrix).

import Mathlib
import Definitions.Def_IntMul_Kappa_R6_Defs4
import Definitions.Def_IntMul_Kappa_R6_Defs20
import Definitions.Def_IntMul_Kappa_R8_Data_BitOppbankMoveFacts2

set_option autoImplicit false
set_option relaxedAutoImplicit false
set_option maxHeartbeats 4000000

open Matrix
open NetLabels
open IntMul.Kappa.R8.Bit.Oppbank.MoveFacts2

namespace IntMul.Kappa.R8.Bit.Oppbank.MoveFactsLe

theorem rank_idem {n : ℕ} {P : Matrix (Fin n) (Fin n) ℚ} (h : P * P = P) :
    (P.rank : ℚ) = P.trace :=
  NetLabels.rank_eq_trace_of_idem P h

theorem le_rank {n : ℕ} {A B : Matrix (Fin n) (Fin n) ℚ}
    (hA : A * A = A) (hB : B * B = B) (h : Le A B) :
    A.rank ≤ B.rank ∧ (B - A).rank = B.rank - A.rank := by
  have hD := le_sub_idem hA hB h
  have e := rank_idem hD
  rw [Matrix.trace_sub, ← rank_idem hA, ← rank_idem hB] at e
  have hle : A.rank ≤ B.rank := by
    have : (0 : ℚ) ≤ (B.rank : ℚ) - A.rank := by rw [← e]; positivity
    exact_mod_cast (sub_nonneg.1 this)
  refine ⟨hle, ?_⟩
  have : ((B - A).rank : ℚ) = ((B.rank - A.rank : ℕ) : ℚ) := by rw [e, Nat.cast_sub hle]
  exact_mod_cast this

theorem le_eq_of_rank {n : ℕ} {A B : Matrix (Fin n) (Fin n) ℚ}
    (hA : A * A = A) (hB : B * B = B) (h : Le A B) (hr : B.rank ≤ A.rank) : B = A := by
  have h0 : (B - A).rank = 0 := by rw [(le_rank hA hB h).2]; omega
  have h1 : LinearMap.range (B - A).mulVecLin = ⊥ := Submodule.finrank_eq_zero.1 h0
  have h2 : (B - A).mulVecLin = 0 := LinearMap.range_eq_bot.1 h1
  have : B - A = 0 := by
    ext i j
    have := congrArg (fun f => f (Pi.single j 1) i) h2
    simpa [Matrix.mulVec_single] using this
  exact sub_eq_zero.1 this

end IntMul.Kappa.R8.Bit.Oppbank.MoveFactsLe
Source
R6 le_rank; NetLabels.rank_eq_trace_of_idem in Defs20

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me