reserve n,m for Element of NAT;
reserve x, X,X1,Z,Z1 for set;
reserve s,g,r,t,p,x0,x1,x2 for Real;
reserve s1,s2,q1 for Real_Sequence;
reserve Y for Subset of REAL;
reserve f,f1,f2 for PartFunc of REAL,REAL;

theorem Th16:
  p<=g & [.p,g.] c= dom f & f|[.p,g.] is continuous implies for r
st r in [.(lower_bound (f.:[.p,g.])),(upper_bound (f.:[.p,g.])).] ex s st s in
  [.p,g.] & r = f.s
proof
  assume that
A1: p<=g and
A2: [.p,g.] c= dom f and
A3: f|[.p,g.] is continuous;
  [.p,g.] is compact by RCOMP_1:6;
  then
A4: f.:[.p,g.] is real-bounded by A2,A3,FCONT_1:29,RCOMP_1:10;
  set ub=upper_bound (f.:[.p,g.]);
  set lb=lower_bound (f.:[.p,g.]);
  [.p,g.] <> {} by A1,XXREAL_1:1;
  then consider x2,x1 be Real such that
A5: x2 in [.p,g.] and
A6: x1 in [.p,g.] and
A7: f.x2=ub and
A8: f.x1=lb by A2,A3,FCONT_1:31,RCOMP_1:6;
  reconsider x1,x2 as Real;
  let r such that
A9: r in [.lb,ub.];
  f.x1 in f.:[.p,g.] by A2,A6,FUNCT_1:def 6;
  then
A10: [.lb,ub.] = [.lb,ub.] \/ [.ub,lb.] by A4,SEQ_4:11,XXREAL_1:222;
  now
    per cases;
    suppose
A11:  x1 <= x2;
A12:  [.x1,x2.] c= [.p,g.] by A5,A6,XXREAL_2:def 12;
A13:  [.x1,x2.] c= [.p,g.] by A5,A6,XXREAL_2:def 12;
      then f|[.x1,x2.] is continuous by A3,FCONT_1:16;
      then consider s such that
A14:  s in [.x1,x2.] and
A15:  r=f.s by A2,A9,A7,A8,A10,A11,A12,Th15,XBOOLE_1:1;
      take s;
      thus s in [.p,g.] & r=f.s by A13,A14,A15;
    end;
    suppose
A16:  x2 <= x1;
A17:  [.x2,x1.] c= [.p,g.] by A5,A6,XXREAL_2:def 12;
A18:  [.x2,x1.] c= [.p,g.] by A5,A6,XXREAL_2:def 12;
      then f|[.x2,x1.] is continuous by A3,FCONT_1:16;
      then consider s such that
A19:  s in [.x2,x1.] and
A20:  r=f.s by A2,A9,A7,A8,A10,A16,A17,Th15,XBOOLE_1:1;
      take s;
      thus s in [.p,g.] & r=f.s by A18,A19,A20;
    end;
  end;
  hence thesis;
end;
