reserve x,y for object,X,Y for set,
  D for non empty set,
  i,j,k,l,m,n,m9,n9 for Nat,
  i0,j0,n0,m0 for non zero Nat,
  K for Field,
  a,b for Element of K,
  p for FinSequence of K,
  M for Matrix of n,K;
reserve A for (Matrix of D),
  A9 for Matrix of n9,m9,D,
  M9 for Matrix of n9, m9,K,
  nt,nt1,nt2 for Element of n-tuples_on NAT,
  mt,mt1 for Element of m -tuples_on NAT,
  M for Matrix of K;

theorem Th39:
  i in rng nt & [:rng nt,rng mt:] c= Indices A9 implies ex nt1 st
rng nt1 = rng nt\{i} \/ {j} & Segm(RLine(A9,i,Line(A9,j)),nt,mt) = Segm(A9,nt1,
  mt)
proof
  assume that
A1: i in rng nt and
A2: [:rng nt,rng mt:] c= Indices A9;
  defpred P[set,set] means for k st k=$1 holds (nt.k=i implies $2=j) & (nt.k<>
  i implies $2=nt.k);
A3: for k st k in Seg n ex x be Element of NAT st P[k,x]
  proof
    let k such that
    k in Seg n;
    per cases;
    suppose
A4:   nt.k=i;
      reconsider J=j as Element of NAT by ORDINAL1:def 12;
      take J;
      thus thesis by A4;
    end;
    suppose
A5:   nt.k<>i;
      reconsider ntk=nt.k as Element of NAT by ORDINAL1:def 12;
      take ntk;
      thus thesis by A5;
    end;
  end;
  consider p be FinSequence of NAT such that
A6: dom p = Seg n and
A7: for k being Nat st k in Seg n holds P[k,p.k] from FINSEQ_1:sch 5(A3);
  n in NAT by ORDINAL1:def 12;
  then len p = n by A6,FINSEQ_1:def 3;
  then reconsider p9=p as Element of n-tuples_on NAT by FINSEQ_2:92;
A8: rng p9 c= (rng nt\{i}) \/ {j}
  proof
    let y be object;
A9: dom nt=Seg n by FINSEQ_2:124;
    assume y in rng p9;
    then consider x be object such that
A10: x in dom p and
A11: p.x=y by FUNCT_1:def 3;
    consider k be Nat such that
A12: x=k and
    1<=k and
    k<=n by A6,A10;
    p.k=j & nt.k=i or p.k=nt.k& nt.k<>i & nt.k in rng nt by A6,A7,A10,A12,A9,
FUNCT_1:def 3;
    then p.k in {j} or p.k in rng nt & not p.k in {i} by TARSKI:def 1;
    then p.k in {j} or p.k in rng nt\{i} by XBOOLE_0:def 5;
    hence thesis by A11,A12,XBOOLE_0:def 3;
  end;
  take p9;
  (rng nt\{i}) \/ {j} c= rng p9
  proof
    let y be object such that
A13: y in (rng nt\{i}) \/ {j};
    per cases by A13,XBOOLE_0:def 3;
    suppose
A14:  y in rng nt\{i};
      then consider x be object such that
A15:  x in dom nt and
A16:  nt.x=y by FUNCT_1:def 3;
A17:  dom nt=Seg n by FINSEQ_2:124;
      then consider k be Nat such that
A18:  x=k and
      1<=k and
      k<=n by A15;
      not y in {i} by A14,XBOOLE_0:def 5;
      then y<>i by TARSKI:def 1;
      then p.k=y by A7,A15,A16,A17,A18;
      hence thesis by A6,A15,A17,A18,FUNCT_1:def 3;
    end;
    suppose
      y in {j};
      then
A19:  y=j by TARSKI:def 1;
      consider x be object such that
A20:  x in dom nt and
A21:  nt.x=i by A1,FUNCT_1:def 3;
A22:  dom nt=Seg n by FINSEQ_2:124;
      then consider k be Nat such that
A23:  x=k and
      1<=k and
      k<=n by A20;
      p.k=j by A7,A20,A21,A22,A23;
      hence thesis by A6,A20,A22,A23,A19,FUNCT_1:def 3;
    end;
  end;
  hence rng p9 =(rng nt\{i}) \/ {j} by A8,XBOOLE_0:def 10;
  set S=Segm(A9,p9,mt);
  set LA=Line(A9,j);
  set R=RLine(A9,i,LA);
  set SR=Segm(R,nt,mt);
A24: Indices A9=Indices R by MATRIX_0:26;
A25: len LA=width A9 by MATRIX_0:def 7;
A26: Indices S=Indices SR by MATRIX_0:26;
  now
    let k,l such that
A27: [k,l] in Indices SR;
    reconsider K=k,L=l as Element of NAT by ORDINAL1:def 12;
A28: SR*(K,L)=R*(nt.K,mt.L) by A27,Def1;
    Indices SR=[:Seg n,Seg width SR:] by MATRIX_0:25;
    then
A29: K in Seg n by A27,ZFMISC_1:87;
A30: nt.K=i or nt.K<>i;
A31: [nt.K,mt.L] in Indices A9 by A2,A24,A27,Th17;
    then mt.L in Seg width A9 by ZFMISC_1:87;
    then SR*(K,L)=LA.(mt.L) & p9.K=j & LA.(mt.L)=A9*(j,mt.L) or SR*(K,L)=A9*(
    nt.K,mt.L) & p9.K=nt.K by A7,A25,A31,A28,A30,A29,MATRIX11:def 3
,MATRIX_0:def 7;
    hence SR*(k,l)=S*(k,l) by A26,A27,Def1;
  end;
  hence thesis by MATRIX_0:27;
end;
