reserve x,y for set;
reserve s,s1,s2,s4,r,r1,r2 for Real;
reserve n,m,i,j for Element of NAT;
reserve p for Element of NAT;

theorem
  for e being Real,
      g being Function of I[01],TOP-REAL n, p1,p2 being
  Element of TOP-REAL n st e>0 & g is continuous ex h being FinSequence of REAL
  st h.1=0 & h.len h=1 & 5<=len h & rng h c=the carrier of I[01] & h is
increasing & for i being Nat,Q being Subset of I[01], W being Subset
of Euclid n st 1<=i & i<len h & Q=[.h/.i,h/.(i+1).] & W=g.:(Q) holds diameter(W
  )<e
proof
  1 in {r where r is Real:0<=r & r<=1};
  then
A1: 1 in [.0,1.] by RCOMP_1:def 1;
  {1} c= [.0,1.]
  by A1,TARSKI:def 1;
  then
A2: [.0,1.] \/ {1} =[.0,1.] by XBOOLE_1:12;
  Closed-Interval-TSpace(0,1) =TopSpaceMetr(Closed-Interval-MSpace(0,1))
  by TOPMETR:def 7;
  then
A3: the carrier of I[01] =the carrier of Closed-Interval-MSpace(0,1) by
TOPMETR:12,20
    .= [.0,1.] by TOPMETR:10;
  let e be Real,g be Function of I[01],TOP-REAL n, p1,p2 be Element of
  TOP-REAL n;
  assume that
A4: e>0 and
A5: g is continuous;
A6: e/2>0 by A4,XREAL_1:215;
A7: the TopStruct of TOP-REAL n = TopSpaceMetr Euclid n by EUCLID:def 8;
  then reconsider h=g as Function of I[01], TopSpaceMetr Euclid n;
  reconsider f=h as Function of Closed-Interval-MSpace(0,1),Euclid n by Lm3,
EUCLID:67;
A8: dom g=the carrier of I[01] by FUNCT_2:def 1;
  h is continuous by A5,A7,PRE_TOPC:33;
  then f is uniformly_continuous by Lm1,Th7,TOPMETR:20;
  then consider s1 being Real such that
A9: 0<s1 and
A10: for u1,u2 being Element of (Closed-Interval-MSpace(0,1)) st dist(u1
  ,u2) < s1 holds dist((f/.u1),(f/.u2)) < e/2 by A6;
  set s=min(s1,1/2);
  defpred P[Nat,object] means $2=s/2*($1-1);
A11: 0<=s by A9,XXREAL_0:20;
  then reconsider j= [/ (2/s) \] as Element of NAT by INT_1:53;
A12: 2/s<=j by INT_1:def 7;
A13: s<=s1 by XXREAL_0:17;
A14: for u1,u2 being Element of (Closed-Interval-MSpace(0,1)) st dist(u1,u2)
  < s holds dist((f/.u1),(f/.u2)) < e/2
  proof
    let u1,u2 be Element of (Closed-Interval-MSpace(0,1));
    assume dist(u1,u2) < s;
    then dist(u1,u2) < s1 by A13,XXREAL_0:2;
    hence thesis by A10;
  end;
A15: 2/s<=[/ (2/s) \] by INT_1:def 7;
  then 2/s-j<=0 by XREAL_1:47;
  then 1+(2/s-j)<=1+0 by XREAL_1:6;
  then
A16: s/2*(1+(2/s-j))<=s/2*1 by A11,XREAL_1:64;
A17: for k being Nat st k in Seg j ex x being object st P[k,x];
  consider p being FinSequence such that
A18: dom p = Seg j & for k being Nat st k in Seg j holds P[k,p.k] from
  FINSEQ_1:sch 1(A17);
A19: Seg len p=Seg j by A18,FINSEQ_1:def 3;
  rng (p^<*1*>) c= REAL
  proof
    let y be object;
A20: len (p^<*1*>)=len p + len <*1*> by FINSEQ_1:22
      .=len p+1 by FINSEQ_1:40;
    assume y in rng (p^<*1*>);
    then consider x being object such that
A21: x in dom (p^<*1*>) and
A22: y=(p^<*1*>).x by FUNCT_1:def 3;
    reconsider nx=x as Element of NAT by A21;
A23: dom (p^<*1*>)=Seg len (p^<*1*>) by FINSEQ_1:def 3;
    then
A24: nx<=len (p^<*1*>) by A21,FINSEQ_1:1;
A25: 1<=nx by A21,A23,FINSEQ_1:1;
A26: 1<=nx by A21,A23,FINSEQ_1:1;
      per cases;
      suppose
        nx<len p+1;
        then
A27:    nx<=len p by NAT_1:13;
        then nx in Seg j by A19,A25,FINSEQ_1:1;
        then
A28:    p.nx=s/2*(nx-1) by A18;
        y=p.nx by A22,A26,A27,FINSEQ_1:64;
        hence thesis by A28,XREAL_0:def 1;
      end;
      suppose
        nx>=len p+1;
        then nx=len p+1 by A24,A20,XXREAL_0:1;
        then
A29:      y=1 by A22,Lm4;
         1 in REAL by XREAL_0:def 1;
        hence thesis by A29;
      end;
  end;
  then reconsider h1=p^<*1*> as FinSequence of REAL by FINSEQ_1:def 4;
A30: len h1=len p+len <*1*> by FINSEQ_1:22
    .=len p+1 by FINSEQ_1:40;
A31: len p=j by A18,FINSEQ_1:def 3;
A32: s<>0 by A9,XXREAL_0:15;
  then 2/s>=2/(1/2) by A11,XREAL_1:118,XXREAL_0:17;
  then 4<=j by A12,XXREAL_0:2;
  then
A33: 4+1<=len p+1 by A31,XREAL_1:6;
A34: s/2>0 by A11,A32,XREAL_1:215;
A35: for i being Nat,r1,r2 st 1<=i & i<len p & r1=p.i & r2=p.(i+1
  ) holds r1<r2 & r2-r1=s/2
  proof
    let i be Nat,r1,r2;
    assume that
A36: 1<=i & i<len p and
A37: r1=p.i and
A38: r2=p.(i+1);
    1<i+1 & i+1<=len p by A36,NAT_1:13;
    then (i+1) in Seg j by A19,FINSEQ_1:1;
    then
A39: r2=s/2*(i+1-1) by A18,A38;
    i<i+1 by NAT_1:13;
    then
A40: i-1<i+1-1 by XREAL_1:9;
A41: i in Seg j by A19,A36,FINSEQ_1:1;
    then r1=s/2*(i-1) by A18,A37;
    hence r1<r2 by A34,A39,A40,XREAL_1:68;
    r2-r1=s/2*(i)-s/2*(i-1) by A18,A37,A41,A39
      .=s/2;
    hence thesis;
  end;
  0<s by A9,XXREAL_0:15;
  then 0<j by A15,XREAL_1:139;
  then
A42: 0+1<=j by NAT_1:13;
  then 1 in Seg j by FINSEQ_1:1;
  then p.1=s/2*(1-1) by A18
    .=0;
  then
A43: h1.1=0 by A42,A31,Lm5;
  2*s<>0 by A9,XXREAL_0:15;
  then
A44: s/2*(2/s)=(2*s)/(2*s) & (2*s)/(2*s)=1 by XCMPLX_1:60,76;
  then
A45: 1-s/2*(j-1)=s/2*(1+(2/s-[/ (2/s) \]));
A46: for r1 st r1=p.len p holds 1-r1<=s/2
  by A42,A31,FINSEQ_1:1,A16,A18,A45;
A47: for i being Nat st 1<=i & i<len h1 holds h1/.(i+1)-h1/.i<=s /2
  proof
    let i be Nat;
    assume that
A48: 1<=i and
A49: i<len h1;
A50: i+1<=len h1 by A49,NAT_1:13;
A51: 1<i+1 by A48,NAT_1:13;
A52: i<=len p by A30,A49,NAT_1:13;
    now
      per cases;
      case
A53:    i<len p;
        then i+1<=len p by NAT_1:13;
        then
A54:    h1.(i+1)=p.(i+1) by A51,FINSEQ_1:64;
A55:    h1.i=p.i by A48,A53,FINSEQ_1:64;
        h1.i=h1/.i & h1.(i+1)=h1/.(i+1) by A48,A49,A50,A51,FINSEQ_4:15;
        hence thesis by A35,A48,A53,A55,A54;
      end;
      case
        i>=len p;
        then
A56:    i=len p by A52,XXREAL_0:1;
A57:    h1/.i=h1.i by A48,A49,FINSEQ_4:15
          .=p.i by A48,A52,FINSEQ_1:64;
        h1/.(i+1)=h1.(i+1) by A50,A51,FINSEQ_4:15
          .=1 by A56,Lm4;
        hence thesis by A46,A56,A57;
      end;
    end;
    hence thesis;
  end;
  [/ (2/s) \]<2/s+1 by INT_1:def 7;
  then [/ (2/s) \]-1<2/s+1-1 by XREAL_1:9;
  then
A58: s/2*(j-1)<s/2*(2/s) by A34,XREAL_1:68;
A59: for i being Nat,r1 st 1<=i & i<=len p & r1=p.i holds r1<1
  proof
    let i be Nat,r1;
    assume that
A60: 1<=i and
A61: i<=len p and
A62: r1=p.i;
    i-1<=j-1 by A31,A61,XREAL_1:9;
    then
A63: (s/2)*(i-1)<=(s/2)*(j-1) by A11,XREAL_1:64;
    i in Seg j by A19,A60,A61,FINSEQ_1:1;
    then r1=s/2*(i-1) by A18,A62;
    hence thesis by A58,A44,A63,XXREAL_0:2;
  end;
A64: for i being Nat st 1<=i & i<len h1 holds h1/.i<h1/.(i+1)
  proof
    let i be Nat;
    assume that
A65: 1<=i and
A66: i<len h1;
A67: 1<i+1 by A65,NAT_1:13;
A68: i<=len p by A30,A66,NAT_1:13;
A69: i+1<=len h1 by A66,NAT_1:13;
      per cases;
      suppose
A70:    i<len p;
        then i+1<=len p by NAT_1:13;
        then
A71:    h1.(i+1)=p.(i+1) by A67,FINSEQ_1:64;
A72:    h1.i=p.i by A65,A70,FINSEQ_1:64;
        h1.i=h1/.i & h1.(i+1)=h1/.(i+1) by A65,A66,A69,A67,FINSEQ_4:15;
        hence thesis by A35,A65,A70,A72,A71;
      end;
      suppose
        i>=len p;
        then
A73:    i=len p by A68,XXREAL_0:1;
A74:    h1/.i=h1.i by A65,A66,FINSEQ_4:15
          .=p.i by A65,A68,FINSEQ_1:64;
        h1/.(i+1)=h1.(i+1) by A69,A67,FINSEQ_4:15
          .=1 by A73,Lm4;
        hence thesis by A59,A65,A68,A74;
      end;
  end;
A75: e/2<e by A4,XREAL_1:216;
A76: for i being Nat,Q being Subset of I[01], W being Subset of
Euclid n st 1<=i & i<len h1 & Q=[.h1/.i,h1/.(i+1).] & W=g.:(Q) holds diameter(W
  )<e
  proof
    let i be Nat,Q be Subset of I[01], W be Subset of Euclid n;
    assume that
A77: 1<=i & i<len h1 and
A78: Q=[.h1/.i,h1/.(i+1).] and
A79: W=g.:(Q);
    h1/.i<h1/.(i+1) by A64,A77;
    then
A80: Q<>{} by A78,XXREAL_1:1;
A81: for x,y being Point of Euclid n st x in W & y in W holds dist(x,y)<= e/2
    proof
      let x,y be Point of Euclid n;
      assume that
A82:  x in W and
A83:  y in W;
      consider x3 being object such that
A84:  x3 in dom g and
A85:  x3 in Q and
A86:  x=g.x3 by A79,A82,FUNCT_1:def 6;
      reconsider x3 as Element of Closed-Interval-MSpace(0,1) by A84,Lm2,
TOPMETR:12;
      reconsider r3=x3 as Real by A78,A85;
A87:  h1/.(i+1)-h1/.i<=s/2 by A47,A77;
      consider y3 being object such that
A88:  y3 in dom g and
A89:  y3 in Q and
A90:  y=g.y3 by A79,A83,FUNCT_1:def 6;
      reconsider y3 as Element of Closed-Interval-MSpace(0,1) by A88,Lm2,
TOPMETR:12;
      reconsider s3=y3 as Real by A78,A89;
A91:  f.x3=(f/.x3) & f.y3=(f/.y3);
      |.r3-s3.|<=h1/.(i+1)-h1/.i by A78,A85,A89,Th12;
      then |.r3-s3.|<=s/2 by A87,XXREAL_0:2;
      then
A92:  dist(x3,y3)<=s/2 by HEINE:1;
      s/2<s by A11,A32,XREAL_1:216;
      then dist(x3,y3)<s by A92,XXREAL_0:2;
      hence thesis by A14,A86,A90,A91;
    end;
    then W is bounded by A6,TBSP_1:def 7;
    then diameter(W)<=e/2 by A8,A79,A80,A81,TBSP_1:def 8;
    hence thesis by A75,XXREAL_0:2;

  end;
A93: rng p c=[.0,1.]
  proof
    let y be object;
    assume y in rng p;
    then consider x being object such that
A94: x in dom p and
A95: y=p.x by FUNCT_1:def 3;
    reconsider nx=x as Element of NAT by A94;
A96: p.nx=s/2*(nx-1) by A18,A94;
    then reconsider ry=p.nx as Real;
A97: x in Seg len p by A94,FINSEQ_1:def 3;
    then
A98: 1<=nx by FINSEQ_1:1;
    then
A99: nx-1>=1-1 by XREAL_1:9;
    nx<=len p by A97,FINSEQ_1:1;
    then ry<1 by A59,A98;
    then y in {rs where rs is Real:0<=rs & rs<=1} by A11,A95,A96,A99;
    hence thesis by RCOMP_1:def 1;
  end;
  rng <*1*> ={1} by FINSEQ_1:38;
  then rng h1 =rng p \/ {1} by FINSEQ_1:31;
  then
A100: rng h1 c=[.0,1.] \/ {1} by A93,XBOOLE_1:13;
  h1.len h1=1 by A30,Lm4;
  hence thesis by A30,A33,A43,A2,A100,A3,A64,A76,Lm7;
end;
