reserve n for Nat,
        p,p1,p2 for Point of TOP-REAL n,
        x for Real;
reserve n,m for non zero Nat;
reserve i,j for Nat;
reserve f for PartFunc of REAL-NS m,REAL-NS n;
reserve g for PartFunc of REAL m,REAL n;
reserve h for PartFunc of REAL m,REAL;
reserve x for Point of REAL-NS m;
reserve y for Element of REAL m;
reserve X for set;

theorem Th44:
for m be non zero Nat, x,y,z,w be Element of REAL m,
    i be Nat,
    d,p,q,r be Real
 st 1 <= i & i <= m & |. y-x .| < d & |. z-x .| < d
  & p= proj(i,m).y & z=reproj(i,y).q
  & r in [. p,q .] & w= reproj(i,y).r
holds |. w-x .| < d
proof
   let m be non zero Nat,
       x,y,z,w be Element of REAL m,
       i be Nat,
       d,p,q,r be Real;
   assume that
A1: 1 <= i & i <= m and
A2: |. y-x .| < d  & |. z-x .| < d and
A3: p= proj(i,m).y & z=reproj(i,y).q and
A4: r in [. p,q .] and
A5: w= reproj(i,y).r;
   set wx = w-x;
   set yx = y-x;
   set zx = z-x;
A6:
Sum sqr yx = |. yx .|^2 & Sum sqr wx = |. wx .|^2 & Sum sqr zx = |. zx .|^2
      by TOPREAL9:5;
A7:proj(i,m).z = q & proj(i,m).w = r by A1,A3,A5,Th39;
A8:p <= r & r <= q by A4,XXREAL_1:1;
   i in Seg m by A1;
then A9:i in dom yx & i in dom wx & i in dom zx by FINSEQ_1:89;
   set x1 = x;
     reconsider r as Element of REAL by XREAL_0:def 1;
A10:
   for l be Nat st l in Seg m & l <> i holds (sqr yx).l = (sqr wx).l
   proof
    let l be Nat;
    assume A11: l in Seg m & l <> i;
then A12: l in dom yx & l in dom wx & l in dom y by FINSEQ_1:89;
    then A13: l in Seg len y by FINSEQ_1:def 3;
then A14: 1 <= l & l <= len y by FINSEQ_1:1;
     l in Seg len y & l in Seg len Replace(y,i,r) by A13,FINSEQ_7:5;
then A15: l in dom y & l in dom Replace(y,i,r) by FINSEQ_1:def 3;
     sqr yx = sqrreal*yx & sqr wx = sqrreal*wx by RVSUM_1:def 8;
    then (sqr yx).l = sqrreal.(yx.l) &
    (sqr wx).l = sqrreal.(wx.l) by A12,FUNCT_1:13;
    then (sqr yx).l = (yx.l)^2 & (sqr wx).l = (wx.l)^2 by RVSUM_1:def 2;
then A16: (sqr yx).l = (y.l - x1.l)^2 & (sqr wx).l = (w.l - x1.l)^2
       by A12,VALUED_1:13;
     w.l = Replace(y,i,r).l by A5,PDIFF_1:def 5;
    then w.l = Replace(y,i,r)/.l by A15,PARTFUN1:def 6;
    then w.l = y/.l by A11,A14,FINSEQ_7:10;
    hence thesis by A15,A16,PARTFUN1:def 6;
   end;
A17:
   for l be Nat st l in Seg m & l <> i holds (sqr zx).l = (sqr wx).l
   proof
    let l be Nat;
    assume A18: l in Seg m & l <> i;
then A19: l in dom zx & l in dom wx & l in dom z by FINSEQ_1:89;
    then A20: l in Seg len z by FINSEQ_1:def 3;
then A21: 1 <= l & l <= len z by FINSEQ_1:1;
     l in Seg len z & l in Seg len Replace(z,i,r) by A20,FINSEQ_7:5;
then A22: l in dom z & l in dom Replace(z,i,r) by FINSEQ_1:def 3;
     sqr zx = sqrreal*zx & sqr wx = sqrreal*wx by RVSUM_1:def 8;
    then (sqr zx).l = sqrreal.(zx.l) &
    (sqr wx).l = sqrreal.(wx.l) by A19,FUNCT_1:13;
    then (sqr zx).l = (zx.l)^2 & (sqr wx).l = (wx.l)^2 by RVSUM_1:def 2;
then A23: (sqr zx).l = (z.l - x1.l)^2 & (sqr wx).l = (w.l - x1.l)^2
       by A19,VALUED_1:13;
     w.l = (reproj(i,z).r).l by A1,A3,Th40,A5;
    then w.l = Replace(z,i,r).l by PDIFF_1:def 5;
    then w.l = Replace(z,i,r)/.l by A22,PARTFUN1:def 6;
    then w.l = z/.l by A18,A21,FINSEQ_7:10;
    hence thesis by A22,A23,PARTFUN1:def 6;
   end;
A24:now assume A25: |. w - x .| > |. y - x .| & |. w - x .| > |. z - x .|;
    A26: now assume A27: (sqr wx).i <= (sqr yx).i;
A28:  len sqr wx = m by CARD_1:def 7 .= len sqr yx by CARD_1:def 7;
   for l be Element of NAT st l in dom sqr wx holds (sqr wx).l <= (sqr yx).l
     proof
      let l be Element of NAT;
      assume l in dom sqr wx;
then A29: l in Seg m by FINSEQ_1:89;
      per cases;
      suppose l = i;
       hence (sqr wx).l <= (sqr yx).l by A27;
      end;
      suppose l <> i;
       hence (sqr wx).l <= (sqr yx).l by A29,A10;
      end;
     end;
     hence contradiction by A28,A6,A25,INTEGRA5:3,SQUARE_1:16;
    end;
    A30: now assume A31: (sqr wx).i <= (sqr zx).i;
A32:  len sqr wx = m by CARD_1:def 7 .= len sqr zx by CARD_1:def 7;
for l be Element of NAT st l in dom sqr wx holds (sqr wx).l <= (sqr zx).l
     proof
      let l be Element of NAT;
      assume l in dom sqr wx;
then A33:   l in Seg m by FINSEQ_1:89;
      per cases;
      suppose l = i;
       hence (sqr wx).l <= (sqr zx).l by A31;
      end;
      suppose l <> i;
       hence (sqr wx).l <= (sqr zx).l by A33,A17;
      end;
     end;
     hence contradiction by A32,A6,A25,INTEGRA5:3,SQUARE_1:16;
    end;
     sqr yx = sqrreal*yx & sqr wx = sqrreal*wx &
    sqr zx = sqrreal*zx by RVSUM_1:def 8;
    then (sqr yx).i = sqrreal.(yx.i) & (sqr wx).i = sqrreal.(wx.i) &
    (sqr zx).i = sqrreal.(zx.i) by A9,FUNCT_1:13;
    then A34: (sqr yx).i = (yx.i)^2 & (sqr wx).i = (wx.i)^2 &
    (sqr zx).i = (zx.i)^2 by RVSUM_1:def 2;
     y.i = p & w.i = r & z.i = q by A3,A7,PDIFF_1:def 1;
    then A35: (sqr yx).i = (p - x1.i)^2 & (sqr wx).i = (r - x1.i)^2 &
    (sqr zx).i = (q - x1.i)^2 by A34,A9,VALUED_1:13;
A36: p <= q by A8,XXREAL_0:2;
    per cases;
    suppose x1.i < p;
     then x1.i < r & x1.i < q by A8,A36,XXREAL_0:2;
     then q - x1.i > 0 & r - x1.i > 0 by XREAL_1:50;
     then q - x1.i < r - x1.i by A35,A30,SQUARE_1:15;
     hence contradiction by A8,XREAL_1:13;
    end;
    suppose A37: p <= x1.i & x1.i <= r;
     then x1.i <= q by A8,XXREAL_0:2;
     then r - x1.i >= 0 & q - x1.i >= 0 by A37,XREAL_1:48;
     then q - x1.i < r - x1.i by A35,A30,SQUARE_1:15;
     hence contradiction by A8,XREAL_1:13;
    end;
    suppose A38: r < x1.i & x1.i <= q;
     then p < x1.i by A8,XXREAL_0:2;
then A39:  x1.i - p >= 0 & x1.i - r >= 0 by A38,XREAL_1:48;
      (p-x1.i)^2 = (x1.i-p)^2 & (r-x1.i)^2 = (x1.i-r)^2;
     then x1.i - p < x1.i - r by A35,A26,A39,SQUARE_1:15;
     hence contradiction by A8,XREAL_1:13;
    end;
    suppose q < x1.i;
     then r < x1.i by A8,XXREAL_0:2;
     then p < x1.i & r < x1.i by A8,XXREAL_0:2;
then A40:  x1.i - r >= 0 & x1.i - p >= 0 by XREAL_1:48;
      (p-x1.i)^2 = (x1.i-p)^2 & (r-x1.i)^2 = (x1.i-r)^2;
     then x1.i - p < x1.i - r by A35,A26,A40,SQUARE_1:15;
     hence contradiction by A8,XREAL_1:13;
    end;
   end;
   per cases by A24;
   suppose |. w - x .| <= |. y - x .|;
    hence |. w-x .| < d by A2,XXREAL_0:2;
   end;
   suppose |. w - x .| <= |. z - x .|;
    hence |. w-x .| < d by A2,XXREAL_0:2;
   end;
end;
