let K be Field; :: thesis: for M being diagonal Matrix of K
for NonZero1 being set st NonZero1 = { i where i is Element of NAT : ( [i,i] in Indices M & M * (i,i) <> 0. K ) } holds
the_rank_of M = card NonZero1

let M be diagonal Matrix of K; :: thesis: for NonZero1 being set st NonZero1 = { i where i is Element of NAT : ( [i,i] in Indices M & M * (i,i) <> 0. K ) } holds
the_rank_of M = card NonZero1

consider P, Q being finite without_zero Subset of NAT such that
A1: [:P,Q:] c= Indices M and
A2: card P = card Q and
A3: card P = the_rank_of M and
A4: Det (EqSegm (M,P,Q)) <> 0. K by Def4;
let NZ be set ; :: thesis: ( NZ = { i where i is Element of NAT : ( [i,i] in Indices M & M * (i,i) <> 0. K ) } implies the_rank_of M = card NZ )
assume A5: NZ = { i where i is Element of NAT : ( [i,i] in Indices M & M * (i,i) <> 0. K ) } ; :: thesis: the_rank_of M = card NZ
A6: NZ c= Seg (width M)
proof
let x be object ; :: according to TARSKI:def 3 :: thesis: ( not x in NZ or x in Seg (width M) )
assume x in NZ ; :: thesis: x in Seg (width M)
then ex i being Element of NAT st
( x = i & [i,i] in Indices M & M * (i,i) <> 0. K ) by A5;
hence x in Seg (width M) by ZFMISC_1:87; :: thesis: verum
end;
then not 0 in NZ ;
then reconsider nz = NZ as finite without_zero Subset of NAT by A6, MEASURE6:def 2, XBOOLE_1:1;
set S = Segm (M,nz,nz);
NZ c= dom M
proof
let x be object ; :: according to TARSKI:def 3 :: thesis: ( not x in NZ or x in dom M )
assume x in NZ ; :: thesis: x in dom M
then ex i being Element of NAT st
( x = i & [i,i] in Indices M & M * (i,i) <> 0. K ) by A5;
hence x in dom M by ZFMISC_1:87; :: thesis: verum
end;
then A7: [:nz,nz:] c= Indices M by A6, ZFMISC_1:96;
then reconsider S = Segm (M,nz,nz) as diagonal Matrix of card nz,K by Th100;
set d = diagonal_of_Matrix S;
now :: thesis: Det S <> 0. Kend;
then Det (EqSegm (M,nz,nz)) <> 0. K by Def3;
then A16: the_rank_of M >= card nz by A7, Def4;
P c= nz by A5, A1, A2, A4, Th99;
then card P <= card nz by NAT_1:43;
hence the_rank_of M = card NZ by A16, A3, XXREAL_0:1; :: thesis: verum