let X be set ; :: thesis: for f being PartFunc of REAL,REAL st X c= dom f & f | X is monotone & ex p being Real st f .: X = left_open_halfline p holds
f | X is continuous

let f be PartFunc of REAL,REAL; :: thesis: ( X c= dom f & f | X is monotone & ex p being Real st f .: X = left_open_halfline p implies f | X is continuous )
assume that
A1: X c= dom f and
A2: f | X is monotone ; :: thesis: ( for p being Real holds not f .: X = left_open_halfline p or f | X is continuous )
given p being Real such that A3: f .: X = left_open_halfline p ; :: thesis: f | X is continuous
set L = left_open_halfline p;
now :: thesis: f | X is continuous
per cases ( f | X is non-decreasing or f | X is non-increasing ) by A2, RFUNCT_2:def 5;
suppose f | X is non-decreasing ; :: thesis: f | X is continuous
then A4: (f | X) | X is non-decreasing ;
for x0 being real number st x0 in dom (f | X) holds
f | X is_continuous_in x0
proof
let x0 be real number ; :: thesis: ( x0 in dom (f | X) implies f | X is_continuous_in x0 )
A5: x0 in REAL by XREAL_0:def 1;
A6: (f | X) .: X = f .: X by RELAT_1:129;
assume x0 in dom (f | X) ; :: thesis: f | X is_continuous_in x0
then x0 in X ;
then x0 in (dom f) /\ X by A1, XBOOLE_0:def 4;
then A7: x0 in dom (f | X) by RELAT_1:61;
then (f | X) . x0 in (f | X) .: X by FUNCT_1:def 6;
then A8: (f | X) . x0 in left_open_halfline p by A3, RELAT_1:129;
now :: thesis: for N1 being Neighbourhood of (f | X) . x0 ex N being Neighbourhood of x0 st
for x being real number st x in dom (f | X) & x in N holds
(f | X) . x in N1
let N1 be Neighbourhood of (f | X) . x0; :: thesis: ex N being Neighbourhood of x0 st
for x being real number st x in dom (f | X) & x in N holds
(f | X) . x in N1

consider N2 being Neighbourhood of (f | X) . x0 such that
A9: N2 c= left_open_halfline p by A8, RCOMP_1:18;
consider N3 being Neighbourhood of (f | X) . x0 such that
A10: N3 c= N1 and
A11: N3 c= N2 by RCOMP_1:17;
consider r being real number such that
A12: r > 0 and
A13: N3 = ].(((f | X) . x0) - r),(((f | X) . x0) + r).[ by RCOMP_1:def 6;
reconsider r = r as Real by XREAL_0:def 1;
A14: ((f | X) . x0) + (r / 2) < (((f | X) . x0) + (r / 2)) + (r / 2) by A12, XREAL_1:29, XREAL_1:215;
set M2 = ((f | X) . x0) + (r / 2);
A15: (f | X) . x0 < ((f | X) . x0) + (r / 2) by A12, XREAL_1:29, XREAL_1:215;
A16: (f | X) . x0 < ((f | X) . x0) + r by A12, XREAL_1:29;
then ((f | X) . x0) - r < (((f | X) . x0) + r) - r by XREAL_1:9;
then ((f | X) . x0) - r < ((f | X) . x0) + (r / 2) by A15, XXREAL_0:2;
then A17: ((f | X) . x0) + (r / 2) in ].(((f | X) . x0) - r),(((f | X) . x0) + r).[ by A14;
then ((f | X) . x0) + (r / 2) in N2 by A11, A13;
then consider r2 being Real such that
A18: ( r2 in dom (f | X) & r2 in X ) and
A19: ((f | X) . x0) + (r / 2) = (f | X) . r2 by A3, A6, A9, PARTFUN2:59;
A20: ((f | X) . x0) + (r / 2) > (f | X) . x0 by A12, XREAL_1:29, XREAL_1:215;
A21: now :: thesis: not r2 < x0
assume A22: r2 < x0 ; :: thesis: contradiction
( x0 in X /\ (dom (f | X)) & r2 in X /\ (dom (f | X)) ) by A7, A18, XBOOLE_0:def 4;
hence contradiction by A4, A19, A20, A22, RFUNCT_2:22, A5; :: thesis: verum
end;
set M1 = ((f | X) . x0) - (r / 2);
A23: ((f | X) . x0) - r < (((f | X) . x0) - r) + (r / 2) by A12, XREAL_1:29, XREAL_1:215;
((f | X) . x0) - (r / 2) < (f | X) . x0 by A15, XREAL_1:19;
then ((f | X) . x0) - (r / 2) < ((f | X) . x0) + r by A16, XXREAL_0:2;
then A24: ((f | X) . x0) - (r / 2) in ].(((f | X) . x0) - r),(((f | X) . x0) + r).[ by A23;
then ((f | X) . x0) - (r / 2) in N2 by A11, A13;
then consider r1 being Real such that
A25: ( r1 in dom (f | X) & r1 in X ) and
A26: ((f | X) . x0) - (r / 2) = (f | X) . r1 by A3, A6, A9, PARTFUN2:59;
A27: (f | X) . x0 < ((f | X) . x0) + (r / 2) by A12, XREAL_1:29, XREAL_1:215;
then A28: ((f | X) . x0) - (r / 2) < (f | X) . x0 by XREAL_1:19;
A29: now :: thesis: not x0 < r1
assume A30: x0 < r1 ; :: thesis: contradiction
( x0 in X /\ (dom (f | X)) & r1 in X /\ (dom (f | X)) ) by A7, A25, XBOOLE_0:def 4;
hence contradiction by A4, A26, A28, A30, RFUNCT_2:22, A5; :: thesis: verum
end;
x0 <> r2 by A12, A19, XREAL_1:29, XREAL_1:215;
then x0 < r2 by A21, XXREAL_0:1;
then A31: r2 - x0 > 0 by XREAL_1:50;
set R = min ((x0 - r1),(r2 - x0));
A32: min ((x0 - r1),(r2 - x0)) <= r2 - x0 by XXREAL_0:17;
r1 <> x0 by A26, A27, XREAL_1:19;
then r1 < x0 by A29, XXREAL_0:1;
then x0 - r1 > 0 by XREAL_1:50;
then min ((x0 - r1),(r2 - x0)) > 0 by A31, XXREAL_0:15;
then reconsider N = ].(x0 - (min ((x0 - r1),(r2 - x0)))),(x0 + (min ((x0 - r1),(r2 - x0)))).[ as Neighbourhood of x0 by RCOMP_1:def 6;
take N = N; :: thesis: for x being real number st x in dom (f | X) & x in N holds
(f | X) . x in N1

let x be real number ; :: thesis: ( x in dom (f | X) & x in N implies (f | X) . x in N1 )
A33: x in REAL by XREAL_0:def 1;
assume that
A34: x in dom (f | X) and
A35: x in N ; :: thesis: (f | X) . x in N1
A36: x in X /\ (dom (f | X)) by A34, XBOOLE_1:28;
A37: ex s being Real st
( s = x & x0 - (min ((x0 - r1),(r2 - x0))) < s & s < x0 + (min ((x0 - r1),(r2 - x0))) ) by A35;
then x0 < (min ((x0 - r1),(r2 - x0))) + x by XREAL_1:19;
then A38: x0 - x < ((min ((x0 - r1),(r2 - x0))) + x) - x by XREAL_1:9;
min ((x0 - r1),(r2 - x0)) <= x0 - r1 by XXREAL_0:17;
then x0 - x < x0 - r1 by A38, XXREAL_0:2;
then - (x0 - x) > - (x0 - r1) by XREAL_1:24;
then A39: (x - x0) + x0 > (r1 - x0) + x0 by XREAL_1:6;
r1 in X /\ (dom (f | X)) by A25, XBOOLE_0:def 4;
then A40: (f | X) . r1 <= (f | X) . x by A4, A39, A36, RFUNCT_2:22, A33;
x - x0 < min ((x0 - r1),(r2 - x0)) by A37, XREAL_1:19;
then x - x0 < r2 - x0 by A32, XXREAL_0:2;
then A41: (x - x0) + x0 < (r2 - x0) + x0 by XREAL_1:6;
r2 in X /\ (dom (f | X)) by A18, XBOOLE_0:def 4;
then (f | X) . x <= (f | X) . r2 by A4, A41, A36, RFUNCT_2:22, A33;
then A42: (f | X) . x in [.(((f | X) . x0) - (r / 2)),(((f | X) . x0) + (r / 2)).] by A26, A19, A40;
[.(((f | X) . x0) - (r / 2)),(((f | X) . x0) + (r / 2)).] c= ].(((f | X) . x0) - r),(((f | X) . x0) + r).[ by A24, A17, XXREAL_2:def 12;
then (f | X) . x in N3 by A13, A42;
hence (f | X) . x in N1 by A10; :: thesis: verum
end;
hence f | X is_continuous_in x0 by FCONT_1:4; :: thesis: verum
end;
hence f | X is continuous by FCONT_1:def 2; :: thesis: verum
end;
suppose f | X is non-increasing ; :: thesis: f | X is continuous
then A43: (f | X) | X is non-increasing ;
for x0 being real number st x0 in dom (f | X) holds
f | X is_continuous_in x0
proof
let x0 be real number ; :: thesis: ( x0 in dom (f | X) implies f | X is_continuous_in x0 )
A44: x0 in REAL by XREAL_0:def 1;
A45: (f | X) .: X = f .: X by RELAT_1:129;
assume x0 in dom (f | X) ; :: thesis: f | X is_continuous_in x0
then x0 in X ;
then x0 in (dom f) /\ X by A1, XBOOLE_0:def 4;
then A46: x0 in dom (f | X) by RELAT_1:61;
then (f | X) . x0 in (f | X) .: X by FUNCT_1:def 6;
then A47: (f | X) . x0 in left_open_halfline p by A3, RELAT_1:129;
now :: thesis: for N1 being Neighbourhood of (f | X) . x0 ex N being Neighbourhood of x0 st
for x being real number st x in dom (f | X) & x in N holds
(f | X) . x in N1
let N1 be Neighbourhood of (f | X) . x0; :: thesis: ex N being Neighbourhood of x0 st
for x being real number st x in dom (f | X) & x in N holds
(f | X) . x in N1

consider N2 being Neighbourhood of (f | X) . x0 such that
A48: N2 c= left_open_halfline p by A47, RCOMP_1:18;
consider N3 being Neighbourhood of (f | X) . x0 such that
A49: N3 c= N1 and
A50: N3 c= N2 by RCOMP_1:17;
consider r being real number such that
A51: r > 0 and
A52: N3 = ].(((f | X) . x0) - r),(((f | X) . x0) + r).[ by RCOMP_1:def 6;
reconsider r = r as Real by XREAL_0:def 1;
A53: ((f | X) . x0) + (r / 2) < (((f | X) . x0) + (r / 2)) + (r / 2) by A51, XREAL_1:29, XREAL_1:215;
set M2 = ((f | X) . x0) + (r / 2);
A54: (f | X) . x0 < ((f | X) . x0) + (r / 2) by A51, XREAL_1:29, XREAL_1:215;
A55: (f | X) . x0 < ((f | X) . x0) + r by A51, XREAL_1:29;
then ((f | X) . x0) - r < (((f | X) . x0) + r) - r by XREAL_1:9;
then ((f | X) . x0) - r < ((f | X) . x0) + (r / 2) by A54, XXREAL_0:2;
then A56: ((f | X) . x0) + (r / 2) in ].(((f | X) . x0) - r),(((f | X) . x0) + r).[ by A53;
then ((f | X) . x0) + (r / 2) in N2 by A50, A52;
then consider r2 being Real such that
A57: ( r2 in dom (f | X) & r2 in X ) and
A58: ((f | X) . x0) + (r / 2) = (f | X) . r2 by A3, A45, A48, PARTFUN2:59;
A59: ((f | X) . x0) + (r / 2) > (f | X) . x0 by A51, XREAL_1:29, XREAL_1:215;
A60: now :: thesis: not r2 > x0
assume A61: r2 > x0 ; :: thesis: contradiction
( x0 in X /\ (dom (f | X)) & r2 in X /\ (dom (f | X)) ) by A46, A57, XBOOLE_0:def 4;
hence contradiction by A43, A58, A59, A61, RFUNCT_2:23, A44; :: thesis: verum
end;
set M1 = ((f | X) . x0) - (r / 2);
A62: ((f | X) . x0) - r < (((f | X) . x0) - r) + (r / 2) by A51, XREAL_1:29, XREAL_1:215;
((f | X) . x0) - (r / 2) < (f | X) . x0 by A54, XREAL_1:19;
then ((f | X) . x0) - (r / 2) < ((f | X) . x0) + r by A55, XXREAL_0:2;
then A63: ((f | X) . x0) - (r / 2) in ].(((f | X) . x0) - r),(((f | X) . x0) + r).[ by A62;
then ((f | X) . x0) - (r / 2) in N2 by A50, A52;
then consider r1 being Real such that
A64: ( r1 in dom (f | X) & r1 in X ) and
A65: ((f | X) . x0) - (r / 2) = (f | X) . r1 by A3, A45, A48, PARTFUN2:59;
A66: (f | X) . x0 < ((f | X) . x0) + (r / 2) by A51, XREAL_1:29, XREAL_1:215;
then A67: ((f | X) . x0) - (r / 2) < (f | X) . x0 by XREAL_1:19;
A68: now :: thesis: not x0 > r1
assume A69: x0 > r1 ; :: thesis: contradiction
( x0 in X /\ (dom (f | X)) & r1 in X /\ (dom (f | X)) ) by A46, A64, XBOOLE_0:def 4;
hence contradiction by A43, A65, A67, A69, RFUNCT_2:23, A44; :: thesis: verum
end;
x0 <> r2 by A51, A58, XREAL_1:29, XREAL_1:215;
then x0 > r2 by A60, XXREAL_0:1;
then A70: x0 - r2 > 0 by XREAL_1:50;
set R = min ((r1 - x0),(x0 - r2));
A71: min ((r1 - x0),(x0 - r2)) <= r1 - x0 by XXREAL_0:17;
r1 <> x0 by A65, A66, XREAL_1:19;
then r1 > x0 by A68, XXREAL_0:1;
then r1 - x0 > 0 by XREAL_1:50;
then min ((r1 - x0),(x0 - r2)) > 0 by A70, XXREAL_0:15;
then reconsider N = ].(x0 - (min ((r1 - x0),(x0 - r2)))),(x0 + (min ((r1 - x0),(x0 - r2)))).[ as Neighbourhood of x0 by RCOMP_1:def 6;
take N = N; :: thesis: for x being real number st x in dom (f | X) & x in N holds
(f | X) . x in N1

let x be real number ; :: thesis: ( x in dom (f | X) & x in N implies (f | X) . x in N1 )
A72: x in REAL by XREAL_0:def 1;
assume that
A73: x in dom (f | X) and
A74: x in N ; :: thesis: (f | X) . x in N1
A75: x in X /\ (dom (f | X)) by A73, XBOOLE_1:28;
A76: ex s being Real st
( s = x & x0 - (min ((r1 - x0),(x0 - r2))) < s & s < x0 + (min ((r1 - x0),(x0 - r2))) ) by A74;
then x0 < (min ((r1 - x0),(x0 - r2))) + x by XREAL_1:19;
then A77: x0 - x < ((min ((r1 - x0),(x0 - r2))) + x) - x by XREAL_1:9;
x - x0 < min ((r1 - x0),(x0 - r2)) by A76, XREAL_1:19;
then x - x0 < r1 - x0 by A71, XXREAL_0:2;
then A78: (x - x0) + x0 < (r1 - x0) + x0 by XREAL_1:6;
r1 in X /\ (dom (f | X)) by A64, XBOOLE_0:def 4;
then A79: (f | X) . r1 <= (f | X) . x by A43, A78, A75, RFUNCT_2:23, A72;
min ((r1 - x0),(x0 - r2)) <= x0 - r2 by XXREAL_0:17;
then x0 - x < x0 - r2 by A77, XXREAL_0:2;
then - (x0 - x) > - (x0 - r2) by XREAL_1:24;
then A80: (x - x0) + x0 > (r2 - x0) + x0 by XREAL_1:6;
r2 in X /\ (dom (f | X)) by A57, XBOOLE_0:def 4;
then (f | X) . x <= (f | X) . r2 by A43, A80, A75, RFUNCT_2:23, A72;
then A81: (f | X) . x in [.(((f | X) . x0) - (r / 2)),(((f | X) . x0) + (r / 2)).] by A65, A58, A79;
[.(((f | X) . x0) - (r / 2)),(((f | X) . x0) + (r / 2)).] c= ].(((f | X) . x0) - r),(((f | X) . x0) + r).[ by A63, A56, XXREAL_2:def 12;
then (f | X) . x in N3 by A52, A81;
hence (f | X) . x in N1 by A49; :: thesis: verum
end;
hence f | X is_continuous_in x0 by FCONT_1:4; :: thesis: verum
end;
hence f | X is continuous by FCONT_1:def 2; :: thesis: verum
end;
end;
end;
hence f | X is continuous ; :: thesis: verum