reserve

  k,n,m,i,j for Element of NAT,
  K for Field;
reserve L for non empty addLoopStr;
reserve G for non empty multLoopStr;

theorem Th49:
  for i0 being Element of NAT st 1<=i0 & i0<=n holds SwapDiagonal(
  K,n,i0) is invertible & (SwapDiagonal(K,n,i0))~ =SwapDiagonal(K,n,i0)
proof
  let i0 be Element of NAT;
  assume that
A1: 1<=i0 and
A2: i0<=n;
A3: 1<=n by A1,A2,XXREAL_0:2;
  set R=(SwapDiagonal(K,n,i0))*(SwapDiagonal(K,n,i0));
A4: Indices R=[: Seg n,Seg n :] by MATRIX_0:24;
A5: width R=n by MATRIX_0:24;
A6: for i4,j4 being Nat st [i4,j4] in Indices R holds R*(i4,j4) = (1.(K,n))
  *(i4,j4)
  proof
    let i4,j4 be Nat;
    reconsider i=i4,j=j4 as Element of NAT by ORDINAL1:def 12;
    assume
A7: [i4,j4] in Indices R;
    then
A8: [i,j] in Indices (1.(K,n)) by A4,MATRIX_0:24;
    j in Seg n by A5,A7,ZFMISC_1:87;
    then
A9: 1<=j & j<=n by FINSEQ_1:1;
A10: i in Seg n by A4,A7,ZFMISC_1:87;
    then
A11: 1<=i by FINSEQ_1:1;
A12: i<=n by A10,FINSEQ_1:1;
    per cases by A11,XXREAL_0:1;
    suppose
A13:  1<i;
      now
        per cases;
        suppose
A14:      i<>i0;
          now
            per cases;
            suppose
A15:          i=j;
A16:          now
                per cases;
                suppose
                  i0<>1;
                  hence (SwapDiagonal(K,n,i0))*(i,j)=1.K by A1,A2,A12,A13,A14
,A15,Th43;
                end;
                suppose
                  i0=1;
                  hence (SwapDiagonal(K,n,i0))*(i,j)=1.K by A11,A12,A15,Th44;
                end;
              end;
              (1.(K,n))*(i,j)= 1.K by A8,A15,MATRIX_1:def 3;
              hence R*(i,j) = (1.(K,n))*(i,j) by A1,A2,A12,A9,A13,A14,A16,Th48;
            end;
            suppose
A17:          i<>j;
A18:          now
                per cases;
                suppose
                  i0=1;
                  hence (SwapDiagonal(K,n,i0))*(i,j)=0.K by A11,A12,A9,A17,Th45
;
                end;
                suppose
                  i0<>1;
                  hence (SwapDiagonal(K,n,i0))*(i,j)=0.K by A1,A2,A12,A9,A13
,A14,A17,Th43;
                end;
              end;
              (1.(K,n))*(i,j)=0.K by A8,A17,MATRIX_1:def 3;
              hence R*(i,j) = (1.(K,n))*(i,j) by A1,A2,A12,A9,A13,A14,A18,Th48;
            end;
          end;
          hence R*(i,j) = (1.(K,n))*(i,j);
        end;
        suppose
A19:      i=i0;
          now
            per cases;
            suppose
A20:          i=j;
A21:          now
                per cases;
                suppose
                  i0=1;
                  hence (SwapDiagonal(K,n,i0))*(1,i0)=1.K by A13,A19;
                end;
                suppose
                  i0<>1;
                  hence (SwapDiagonal(K,n,i0))*(1,i0)=1.K by A1,A2,A3,Th43;
                end;
              end;
              (1.(K,n))*(i,j)=1.K by A8,A20,MATRIX_1:def 3;
              hence R*(i,j) = (1.(K,n))*(i,j) by A1,A2,A19,A20,A21,Th48;
            end;
            suppose
A22:          i<>j;
A23:          now
                  now
                    per cases;
                    suppose
                      j=1;
                      hence (SwapDiagonal(K,n,i0))*(1,j)=0.K by A2,A3,A13,A19
,Th43;
                    end;
                    suppose
                      j<>1;
                      hence
                      (SwapDiagonal(K,n,i0))*(1,j)=0.K by A3,A12,A9,A13,A19,A22
,Th43;
                    end;
                  end;
                  hence (SwapDiagonal(K,n,i0))*(1,j)=0.K;
              end;
              (1.(K,n))*(i,j)=0.K by A8,A22,MATRIX_1:def 3;
              hence R*(i,j) = (1.(K,n))*(i,j) by A11,A12,A9,A19,A23,Th48;
            end;
          end;
          hence R*(i,j) = (1.(K,n))*(i,j);
        end;
      end;
      hence thesis;
    end;
    suppose
A24:  1=i;
      now
        per cases;
        suppose
A25:      i0<>1;
          per cases;
          suppose
A26:        j<>1;
A27:        now
              per cases;
              suppose
                j=i0;
                hence (SwapDiagonal(K,n,i0))*(i0,j)=0.K by A9,A26,Th43;
              end;
              suppose
                j<>i0;
                hence (SwapDiagonal(K,n,i0))*(i0,j)=0.K by A1,A2,A9,A25,A26
,Th43;
              end;
            end;
            (1.(K,n))*(i,j)=0.K by A8,A24,A26,MATRIX_1:def 3;
            hence R*(i,j) = (1.(K,n))*(i,j) by A1,A2,A9,A24,A27,Th48;
          end;
          suppose
            j=1;
            then (1.(K,n))*(i,j)= 1.K & (SwapDiagonal(K,n,i0))*(i0,j)=1.K by A1
,A2,A3,A8,A24,A25,Th43,MATRIX_1:def 3;
            hence R*(i,j) = (1.(K,n))*(i,j) by A1,A2,A9,A24,Th48;
          end;
        end;
        suppose
A28:      i0=1;
          now
            per cases;
            suppose
              i<>j;
              then (1.(K,n))*(i,j)=0.K & (SwapDiagonal(K,n,1))*(1,j)=0.K by A12
,A9,A8,A24,Th45,MATRIX_1:def 3;
              hence R*(i,j) = (1.(K,n))*(i,j) by A12,A9,A24,A28,Th48;
            end;
            suppose
A29:          i=j;
              then
A30:          (1.(K,n))*(j,j)= 1.K by A8,MATRIX_1:def 3;
              ((SwapDiagonal(K,n,i0))*(SwapDiagonal(K,n,i0)))*(1,j) =(
              SwapDiagonal(K,n,i0))*(i0,j) by A1,A2,A9,Th48;
              hence R*(i,j) = (1.(K,n))*(i,j) by A2,A24,A28,A29,A30,Th44;
            end;
          end;
          hence R*(i,j) = (1.(K,n))*(i,j);
        end;
      end;
      hence thesis;
    end;
  end;
  width (1.(K,n))=n by MATRIX_0:24;
  then
A31: width R = width (1.(K,n)) by MATRIX_0:24;
  len (1.(K,n))=n by MATRIX_0:24;
  then len R = len (1.(K,n)) by MATRIX_0:24;
  then
A32: (SwapDiagonal(K,n,i0))*(SwapDiagonal(K,n,i0))=1.(K,n) by A31,A6,
MATRIX_0:21;
  hence SwapDiagonal(K,n,i0) is invertible by Th19;
  thus thesis by A32,Th18;
end;
