reserve n   for Nat,
        r,s for Real,
        x,y for Element of REAL n,
        p,q for Point of TOP-REAL n,
        e   for Point of Euclid n;
reserve n for non zero Nat;
reserve n for non zero Nat;
reserve n for Nat,
        X for set,
        S for Subset-Family of X;
reserve n for Nat,
        S for Subset-Family of REAL;
reserve n       for Nat,
        a,b,c,d for Element of REAL n;
reserve n for non zero Nat;
reserve n     for non zero Nat,
        x,y,z for Element of REAL n;
reserve p for Element of EMINFTY n;

theorem Th68:
  Ball(p,r) = product Intervals(@p,r)
  proof
    consider x be Element of REAL n such that
A1: @p = x;
    per cases;
    suppose r <= 0;
      then Ball(p,r) = {} & product Intervals(x,r) = {} by Th67,TBSP_1:12;
      hence thesis by A1;
    end;
    suppose
A2:   r > 0;
A3:   {q where q is Element of EMINFTY n : dist(p,q) < r} c=
        product Intervals(x,r)
      proof
        let t be object;
        assume t in {q where q is Element of EMINFTY n : dist(p,q) < r};
        then consider q be Element of EMINFTY n such that
A4:     t = q and
A5:     dist(p,q) < r;
        reconsider pr = p, qr = q as Element of REAL n;
        consider S being
        ext-real-membered set such that
A6:     S = the set of all |. pr.i - qr.i .| where i is Element of Seg n and
A7:     (Infty_dist n).(pr,qr) = sup S by Th57;
        (Infty_dist n).(p,q) in REAL by BINOP_1:17;
        then reconsider s = (Infty_dist n).(p,q) as Real;
        reconsider f = Intervals(x,r) as Function;
        now
A8:       dom f = dom x by EUCLID_9:def 3
               .= Seg n by FINSEQ_1:89;
          hence dom qr = dom f by FINSEQ_1:89;
          thus for y being object st y in dom f holds qr.y in f.y
          proof
            let y be object;
            assume
A9:         y in dom f; then
A10:        y in dom x by A8,FINSEQ_1:89;
            reconsider y1 = y as Element of Seg n by A9,A8;
            |. pr.y1 - qr.y1 .| in S by A6;
            then |. pr.y1 - qr.y1 .| <= sup S & sup S < r by A7,A5,XXREAL_2:4;
            then
A11:        |.x.y - qr.y.| < r by A1,XXREAL_0:2;
            x.y -r < qr.y & qr.y < x.y + r
            proof
              per cases;
              suppose
A12:            x.y - qr.y >= 0;
                then x.y - qr.y < r by A11,COMPLEX1:43;
                then x.y - qr.y +qr.y < qr.y + r by XREAL_1:8;
                then x.y - r < qr.y + r - r by XREAL_1:8;
                hence x.y - r < qr.y;
                0 + qr.y <= x.y -qr.y +qr.y by A12,XREAL_1:7;
                hence thesis by A2,XREAL_1:8;
              end;
              suppose
A13:            x.y - qr.y < 0;
                then x.y - qr.y + qr.y < 0 + qr.y by XREAL_1:8;
                then x.y - r < qr.y - 0 by A2,XREAL_1:15;
                hence x.y - r < qr.y;
                |.x.y - qr.y.| = -(x.y - qr.y) by A13,COMPLEX1:70
                              .= qr.y - x.y;
                then qr.y - x.y + x.y < r + x.y by A11,XREAL_1:8;
                hence qr.y < x.y + r;
              end;
            end;
            then qr.y in ]. x.y - r , x.y + r .[ by XXREAL_1:4;
            hence qr.y in f.y by A10,EUCLID_9:def 3;
          end;
        end;
        hence thesis by A4,CARD_3:9;
      end;
      product Intervals(x,r) c=
      {q where q is Element of EMINFTY n : dist(p,q) < r}
      proof
        let t be object;
        assume t in product Intervals(x,r);
        then consider g be Function such that
A14:    t = g and
A15:    dom g = dom Intervals(x,r) and
A16:    for y be object st y in dom Intervals(x,r) holds
          g.y in (Intervals(x,r)).y by CARD_3:def 5;
A17:    dom Intervals(x,r) = dom x by EUCLID_9:def 3
                          .= Seg n by FINSEQ_1:89;
        rng g c= REAL
        proof
          let u be object;
          assume u in rng g;
          then consider t be object such that
A18:      t in dom g and
A19:      u = g.t by FUNCT_1:def 3;
A20:      u in (Intervals(x,r)).t by A18,A19,A15,A16;
          t in dom x by A18,A17,A15,FINSEQ_1:89;
          then u in ].x.t-r,x.t+r.[ by A20,EUCLID_9:def 3;
          hence thesis;
        end;
        then g in Funcs(Seg n,REAL) by A17,A15,FUNCT_2:def 2;
        then reconsider g0 = g as Element of EMINFTY n by FINSEQ_2:93;
        dist(p,g0) < r
        proof
          reconsider p1 = p, g1 = g0 as Element of REAL n;
          consider S being
          ext-real-membered set such that
          S = the set of all |. p1.i - g1.i .| where
          i is Element of Seg n and
A21:      (Infty_dist n).(p1,g1) = sup S by Th57;
          sup S < r
          proof
            assume
A22:        r <= sup S;
            set md = max_diff_index(p1,g1);
A23:        r <= abs (p1-g1).md by A22,A21,Th58;
A24:        md in dom x by A1,EUCLID_9:4;
            then md in dom Intervals(x,r) by EUCLID_9:def 3;
            then g1.md in (Intervals(x,r)).md by A16; then
A25:        g1.md in ].p1.md-r,p1.md+r.[ by A24,A1,EUCLID_9:def 3;
A26:        p1.md - r < g1.md & g1.md < p1.md + r by A25,XXREAL_1:4;
            p1.md - r + r < g1.md + r by A26,XREAL_1:8; then
A27:        p1.md - g1.md < g1.md + r - g1.md by XREAL_1:14;
            g1.md - p1.md < p1.md + r - p1.md by A26,XREAL_1:14; then
A28:        p1.md - g1.md < r & -(p1.md - g1.md) < r by A27; then
A29:        (p1 - g1).md < r & -(p1 - g1).md < r by RVSUM_1:27;
            set pg = (p1 - g1).md;
            |.pg.| < r
            proof
              per cases;
              suppose pg < 0;
                then |.pg.| = -pg by COMPLEX1:70;
                hence thesis by A28,RVSUM_1:27;
              end;
              suppose 0 <= pg;
                hence thesis by A29,COMPLEX1:43;
              end;
            end;
            hence contradiction by A23,VALUED_1:18;
          end;
          hence thesis by A21;
        end;
        hence t in {q where q is Element of EMINFTY n : dist(p,q) < r} by A14;
      end;
      hence Ball(p,r) = product Intervals(@p,r) by A1,A3,METRIC_1:def 14;
    end;
  end;
