reserve n,m,k for Element of NAT;
reserve x, X,X1,Z,Z1 for set;
reserve s,g,r,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
  for f,Y st Y<>{} & Y c= dom f & Y is compact & f|Y is continuous ex x1
,x2 st x1 in Y & x2 in Y & f.x1 = upper_bound (f.:Y) & f.x2 = lower_bound (f.:Y
  )
proof
  let f,Y such that
A1: Y <> {} and
A2: Y c= dom f and
A3: Y is compact and
A4: f|Y is continuous;
A5: dom (f|Y) = dom f /\ Y by RELAT_1:61
    .= Y by A2,XBOOLE_1:28;
  f|Y|Y is continuous by A4;
  then consider x1,x2 such that
A6: x1 in dom (f|Y) & x2 in dom (f|Y) and
A7: (f|Y).x1 = upper_bound (rng (f|Y)) & (f|Y).x2 = lower_bound (rng (f|
  Y)) by A1,A3,A5,Th30;
  take x1,x2;
  thus x1 in Y & x2 in Y by A6;
  f.x1=upper_bound(rng (f|Y)) & f.x2=lower_bound(rng (f|Y)) by A6,A7,FUNCT_1:47
;
  hence thesis by RELAT_1:115;
end;
