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 = right_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 = right_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 = right_open_halfline p or f | X is continuous )
given p being Real such that A3: f .: X = right_open_halfline p ; :: thesis: f | X is continuous
set L = right_open_halfline p;
now
per cases ( f | X is non-decreasing or f | X is non-increasing ) by A2, RFUNCT_2:def 6;
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: (f | X) .: X = f .: X by RELAT_1:162;
assume x0 in dom (f | X) ; :: thesis: f | X is_continuous_in x0
then A6: x0 in X by RELAT_1:86;
then x0 in (dom f) /\ X by A1, XBOOLE_0:def 4;
then A7: x0 in dom (f | X) by RELAT_1:90;
then (f | X) . x0 in (f | X) .: X by A6, FUNCT_1:def 12;
then A8: (f | X) . x0 in right_open_halfline p by A3, RELAT_1:162;
now
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= right_open_halfline p by A8, RCOMP_1:39;
consider N3 being Neighbourhood of (f | X) . x0 such that
A10: N3 c= N1 and
A11: N3 c= N2 by RCOMP_1:38;
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 7;
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:31, XREAL_1:217;
set M2 = ((f | X) . x0) + (r / 2);
A15: (f | X) . x0 < ((f | X) . x0) + (r / 2) by A12, XREAL_1:31, XREAL_1:217;
A16: (f | X) . x0 < ((f | X) . x0) + r by A12, XREAL_1:31;
then ((f | X) . x0) - r < (((f | X) . x0) + r) - r by XREAL_1:11;
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, A5, A9, PARTFUN2:78;
A20: ((f | X) . x0) + (r / 2) > (f | X) . x0 by A12, XREAL_1:31, XREAL_1:217;
A21: now
assume A22: r2 < x0 ; :: thesis: contradiction
( x0 in X /\ (dom (f | X)) & r2 in X /\ (dom (f | X)) ) by A6, A7, A18, XBOOLE_0:def 4;
hence contradiction by A4, A19, A20, A22, RFUNCT_2:45; :: 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:31, XREAL_1:217;
((f | X) . x0) - (r / 2) < (f | X) . x0 by A15, XREAL_1:21;
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, A5, A9, PARTFUN2:78;
A27: (f | X) . x0 < ((f | X) . x0) + (r / 2) by A12, XREAL_1:31, XREAL_1:217;
then A28: ((f | X) . x0) - (r / 2) < (f | X) . x0 by XREAL_1:21;
A29: now
assume A30: x0 < r1 ; :: thesis: contradiction
( x0 in X /\ (dom (f | X)) & r1 in X /\ (dom (f | X)) ) by A6, A7, A25, XBOOLE_0:def 4;
hence contradiction by A4, A26, A28, A30, RFUNCT_2:45; :: thesis: verum
end;
x0 <> r2 by A12, A19, XREAL_1:31, XREAL_1:217;
then x0 < r2 by A21, XXREAL_0:1;
then A31: r2 - x0 > 0 by XREAL_1:52;
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:21;
then r1 < x0 by A29, XXREAL_0:1;
then x0 - r1 > 0 by XREAL_1:52;
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 7;
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 )
assume that
A33: x in dom (f | X) and
A34: x in N ; :: thesis: (f | X) . x in N1
A35: x in X /\ (dom (f | X)) by A33, RELAT_1:87, XBOOLE_1:28;
A36: ex s being Real st
( s = x & x0 - (min (x0 - r1),(r2 - x0)) < s & s < x0 + (min (x0 - r1),(r2 - x0)) ) by A34;
then x0 < (min (x0 - r1),(r2 - x0)) + x by XREAL_1:21;
then A37: x0 - x < ((min (x0 - r1),(r2 - x0)) + x) - x by XREAL_1:11;
min (x0 - r1),(r2 - x0) <= x0 - r1 by XXREAL_0:17;
then x0 - x < x0 - r1 by A37, XXREAL_0:2;
then - (x0 - x) > - (x0 - r1) by XREAL_1:26;
then A38: (x - x0) + x0 > (r1 - x0) + x0 by XREAL_1:8;
r1 in X /\ (dom (f | X)) by A25, XBOOLE_0:def 4;
then A39: (f | X) . r1 <= (f | X) . x by A4, A38, A35, RFUNCT_2:45;
x - x0 < min (x0 - r1),(r2 - x0) by A36, XREAL_1:21;
then x - x0 < r2 - x0 by A32, XXREAL_0:2;
then A40: (x - x0) + x0 < (r2 - x0) + x0 by XREAL_1:8;
r2 in X /\ (dom (f | X)) by A18, XBOOLE_0:def 4;
then (f | X) . x <= (f | X) . r2 by A4, A40, A35, RFUNCT_2:45;
then A41: (f | X) . x in [.(((f | X) . x0) - (r / 2)),(((f | X) . x0) + (r / 2)).] by A26, A19, A39;
[.(((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, A41;
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 A42: (f | X) | X is non-increasing by RELAT_1:101;
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 )
A43: (f | X) .: X = f .: X by RELAT_1:162;
assume x0 in dom (f | X) ; :: thesis: f | X is_continuous_in x0
then A44: x0 in X by RELAT_1:86;
then x0 in (dom f) /\ X by A1, XBOOLE_0:def 4;
then A45: x0 in dom (f | X) by RELAT_1:90;
then (f | X) . x0 in (f | X) .: X by A44, FUNCT_1:def 12;
then A46: (f | X) . x0 in right_open_halfline p by A3, RELAT_1:162;
now
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
A47: N2 c= right_open_halfline p by A46, RCOMP_1:39;
consider N3 being Neighbourhood of (f | X) . x0 such that
A48: N3 c= N1 and
A49: N3 c= N2 by RCOMP_1:38;
consider r being real number such that
A50: r > 0 and
A51: N3 = ].(((f | X) . x0) - r),(((f | X) . x0) + r).[ by RCOMP_1:def 7;
reconsider r = r as Real by XREAL_0:def 1;
A52: ((f | X) . x0) + (r / 2) < (((f | X) . x0) + (r / 2)) + (r / 2) by A50, XREAL_1:31, XREAL_1:217;
set M2 = ((f | X) . x0) + (r / 2);
A53: (f | X) . x0 < ((f | X) . x0) + (r / 2) by A50, XREAL_1:31, XREAL_1:217;
A54: (f | X) . x0 < ((f | X) . x0) + r by A50, XREAL_1:31;
then ((f | X) . x0) - r < (((f | X) . x0) + r) - r by XREAL_1:11;
then ((f | X) . x0) - r < ((f | X) . x0) + (r / 2) by A53, XXREAL_0:2;
then A55: ((f | X) . x0) + (r / 2) in ].(((f | X) . x0) - r),(((f | X) . x0) + r).[ by A52;
then ((f | X) . x0) + (r / 2) in N2 by A49, A51;
then consider r2 being Real such that
A56: ( r2 in dom (f | X) & r2 in X ) and
A57: ((f | X) . x0) + (r / 2) = (f | X) . r2 by A3, A43, A47, PARTFUN2:78;
A58: ((f | X) . x0) + (r / 2) > (f | X) . x0 by A50, XREAL_1:31, XREAL_1:217;
A59: now
assume A60: r2 > x0 ; :: thesis: contradiction
( x0 in X /\ (dom (f | X)) & r2 in X /\ (dom (f | X)) ) by A44, A45, A56, XBOOLE_0:def 4;
hence contradiction by A42, A57, A58, A60, RFUNCT_2:46; :: thesis: verum
end;
set M1 = ((f | X) . x0) - (r / 2);
A61: ((f | X) . x0) - r < (((f | X) . x0) - r) + (r / 2) by A50, XREAL_1:31, XREAL_1:217;
((f | X) . x0) - (r / 2) < (f | X) . x0 by A53, XREAL_1:21;
then ((f | X) . x0) - (r / 2) < ((f | X) . x0) + r by A54, XXREAL_0:2;
then A62: ((f | X) . x0) - (r / 2) in ].(((f | X) . x0) - r),(((f | X) . x0) + r).[ by A61;
then ((f | X) . x0) - (r / 2) in N2 by A49, A51;
then consider r1 being Real such that
A63: ( r1 in dom (f | X) & r1 in X ) and
A64: ((f | X) . x0) - (r / 2) = (f | X) . r1 by A3, A43, A47, PARTFUN2:78;
A65: (f | X) . x0 < ((f | X) . x0) + (r / 2) by A50, XREAL_1:31, XREAL_1:217;
then A66: ((f | X) . x0) - (r / 2) < (f | X) . x0 by XREAL_1:21;
A67: now
assume A68: x0 > r1 ; :: thesis: contradiction
( x0 in X /\ (dom (f | X)) & r1 in X /\ (dom (f | X)) ) by A44, A45, A63, XBOOLE_0:def 4;
hence contradiction by A42, A64, A66, A68, RFUNCT_2:46; :: thesis: verum
end;
x0 <> r2 by A50, A57, XREAL_1:31, XREAL_1:217;
then x0 > r2 by A59, XXREAL_0:1;
then A69: x0 - r2 > 0 by XREAL_1:52;
set R = min (r1 - x0),(x0 - r2);
A70: min (r1 - x0),(x0 - r2) <= r1 - x0 by XXREAL_0:17;
r1 <> x0 by A64, A65, XREAL_1:21;
then r1 > x0 by A67, XXREAL_0:1;
then r1 - x0 > 0 by XREAL_1:52;
then min (r1 - x0),(x0 - r2) > 0 by A69, 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 7;
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 )
assume that
A71: x in dom (f | X) and
A72: x in N ; :: thesis: (f | X) . x in N1
A73: x in X /\ (dom (f | X)) by A71, RELAT_1:87, XBOOLE_1:28;
A74: ex s being Real st
( s = x & x0 - (min (r1 - x0),(x0 - r2)) < s & s < x0 + (min (r1 - x0),(x0 - r2)) ) by A72;
then x0 < (min (r1 - x0),(x0 - r2)) + x by XREAL_1:21;
then A75: x0 - x < ((min (r1 - x0),(x0 - r2)) + x) - x by XREAL_1:11;
x - x0 < min (r1 - x0),(x0 - r2) by A74, XREAL_1:21;
then x - x0 < r1 - x0 by A70, XXREAL_0:2;
then A76: (x - x0) + x0 < (r1 - x0) + x0 by XREAL_1:8;
r1 in X /\ (dom (f | X)) by A63, XBOOLE_0:def 4;
then A77: (f | X) . r1 <= (f | X) . x by A42, A76, A73, RFUNCT_2:46;
min (r1 - x0),(x0 - r2) <= x0 - r2 by XXREAL_0:17;
then x0 - x < x0 - r2 by A75, XXREAL_0:2;
then - (x0 - x) > - (x0 - r2) by XREAL_1:26;
then A78: (x - x0) + x0 > (r2 - x0) + x0 by XREAL_1:8;
r2 in X /\ (dom (f | X)) by A56, XBOOLE_0:def 4;
then (f | X) . x <= (f | X) . r2 by A42, A78, A73, RFUNCT_2:46;
then A79: (f | X) . x in [.(((f | X) . x0) - (r / 2)),(((f | X) . x0) + (r / 2)).] by A64, A57, A77;
[.(((f | X) . x0) - (r / 2)),(((f | X) . x0) + (r / 2)).] c= ].(((f | X) . x0) - r),(((f | X) . x0) + r).[ by A62, A55, XXREAL_2:def 12;
then (f | X) . x in N3 by A51, A79;
hence (f | X) . x in N1 by A48; :: 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