reserve a,b,p,r,r1,r2,s,s1,s2,x0,x for Real;
reserve f,g for PartFunc of REAL,REAL;
reserve X,Y for set;

theorem
  for f being PartFunc of REAL,REAL, I being Interval, a being Real st (
ex x1,x2 being Real st x1 in I & x2 in I & x1 < a & a < x2) & f is_convex_on I
  holds f is_continuous_in a
proof
  let f be PartFunc of REAL,REAL, I be Interval, a be Real such that
A1: ex x1,x2 being Real st x1 in I & x2 in I & x1<a & a<x2 and
A2: f is_convex_on I;
  consider x1,x2 being Real such that
A3: x1 in I and
A4: x2 in I and
A5: x1 < a and
A6: a < x2 by A1;
  set M = max(|.(f.x1-f.a)/(x1-a).|,|.(f.x2-f.a)/(x2-a).|);
A7: a in I by A3,A4,A5,A6,XXREAL_2:80;
A8: for x being Real st x1<=x & x<=x2 & x<>a holds (f.x1-f.a)/(x1-a) <= (f.x
  -f.a)/(x-a) & (f.x-f.a)/(x-a) <= (f.x2-f.a)/(x2-a)
  proof
    let x be Real such that
A9: x1 <= x and
A10: x <= x2 and
A11: x<>a;
A12: x in I by A3,A4,A9,A10,XXREAL_2:80;
    (f.x1-f.a)/(x1-a) <= (f.x-f.a)/(x-a) & (f.x-f.a)/(x-a) <= (f.x2-f.a)/
    (x2-a)
    proof
      now
        per cases by A11,XXREAL_0:1;
        suppose
A13:      x < a;
A14:      now
            per cases by A9,XXREAL_0:1;
            suppose
              x1=x;
              hence (f.x1-f.a)/(x1-a) <= (f.x-f.a)/(x-a);
            end;
            suppose
A15:          x1 < x;
A16:          (f.a-f.x1)/(a-x1) = (-(f.a-f.x1))/(-(a-x1)) by XCMPLX_1:191
                .=(f.x1-f.a)/(x1-a);
              (f.a-f.x)/(a-x) = (-(f.a-f.x))/(-(a-x)) by XCMPLX_1:191
                .=(f.x-f.a)/(x-a);
              hence
              (f.x1-f.a)/(x1-a)<=(f.x-f.a)/(x-a) by A2,A3,A7,A12,A13,A15,A16
,Th16;
            end;
          end;
          (f.a-f.x)/(a-x)<=(f.x2-f.x)/(x2-x) & (f.x2-f.x)/(x2-x)<=(f.x2-f
          .a)/(x2-a) by A2,A4,A6,A7,A12,A13,Th16;
          then (f.a-f.x)/(a-x)<=(f.x2-f.a)/(x2-a) by XXREAL_0:2;
          then (-(f.a-f.x))/(-(a-x)) <= (f.x2-f.a)/(x2-a) by XCMPLX_1:191;
          hence thesis by A14;
        end;
        suppose
A17:      x > a;
A18:      (f.a-f.x1)/(a-x1) = (-(f.a-f.x1))/(-(a-x1)) by XCMPLX_1:191
            .=(f.x1-f.a)/(x1-a);
          (f.a-f.x1)/(a-x1)<=(f.x-f.x1)/(x-x1) & (f.x-f.x1)/(x-x1)<=(f.x-
          f.a)/(x-a) by A2,A3,A5,A7,A12,A17,Th16;
          hence (f.x1-f.a)/(x1-a) <= (f.x-f.a)/(x-a) by A18,XXREAL_0:2;
          now
            per cases by A10,XXREAL_0:1;
            suppose
              x=x2;
              hence (f.x-f.a)/(x-a) <= (f.x2-f.a)/(x2-a);
            end;
            suppose
              x<x2;
              hence (f.x-f.a)/(x-a)<=(f.x2-f.a)/(x2-a) by A2,A4,A7,A12,A17,Th16
;
            end;
          end;
          hence (f.x-f.a)/(x-a) <= (f.x2-f.a)/(x2-a);
        end;
      end;
      hence thesis;
    end;
    hence thesis;
  end;
A19: for x being Real st x1<=x & x<=x2 & x<>a holds |.f.x-f.a.|<=M*
  |.x-a.|
  proof
A20: -|.(f.x1-f.a)/(x1-a).| <= (f.x1-f.a)/(x1-a) by ABSVALUE:4;
A21: (f.x2-f.a)/(x2-a) <= |.(f.x2-f.a)/(x2-a).| by ABSVALUE:4;
    let x be Real such that
A22: x1<=x & x<=x2 and
A23: x<>a;
    reconsider x as Real;
    (f.x-f.a)/(x-a) <= (f.x2-f.a)/(x2-a) by A8,A22,A23;
    then
A24: (f.x-f.a)/(x-a) <= |.(f.x2-f.a)/(x2-a).| by A21,XXREAL_0:2;
    x-a <> 0 by A23;
    then
A25: |.x-a.| > 0 by COMPLEX1:47;
    (f.x1-f.a)/(x1-a) <= (f.x-f.a)/(x-a) by A8,A22,A23;
    then
A26: -|.(f.x1-f.a)/(x1-a).| <= (f.x-f.a)/(x-a) by A20,XXREAL_0:2;
    now
      per cases;
      suppose
        |.(f.x1-f.a)/(x1-a).| <= |.(f.x2-f.a)/(x2-a).|;
        then -|.(f.x1-f.a)/(x1-a).| >= -|.(f.x2-f.a)/(x2-a).| by XREAL_1:24;
        then -|.(f.x2-f.a)/(x2-a).| <= (f.x-f.a)/(x-a) by A26,XXREAL_0:2;
        then |.(f.x-f.a)/(x-a).| <= |.(f.x2-f.a)/(x2-a).| by A24,ABSVALUE:5;
        then
A27:    |.(f.x-f.a).|/|.(x-a).| <= |.(f.x2-f.a)/(x2-a).| by COMPLEX1:67;
        |.(f.x2-f.a)/(x2-a).| <= M by XXREAL_0:25;
        then |.(f.x-f.a).|/|.(x-a).| <= M by A27,XXREAL_0:2;
        hence thesis by A25,XREAL_1:81;
      end;
      suppose
        |.(f.x1-f.a)/(x1-a).| >= |.(f.x2-f.a)/(x2-a).|;
        then (f.x-f.a)/(x-a) <= |.(f.x1-f.a)/(x1-a).| by A24,XXREAL_0:2;
        then |.(f.x-f.a)/(x-a).| <= |.(f.x1-f.a)/(x1-a).| by A26,ABSVALUE:5;
        then
A28:    |.(f.x-f.a).|/|.(x-a).| <= |.(f.x1-f.a)/(x1-a).| by COMPLEX1:67;
        |.(f.x1-f.a)/(x1-a).| <= M by XXREAL_0:25;
        then |.(f.x-f.a).|/|.(x-a).| <= M by A28,XXREAL_0:2;
        hence thesis by A25,XREAL_1:81;
      end;
    end;
    hence thesis;
  end;
A29: max(|.(f.x1-f.a)/(x1-a).|,|.(f.x2-f.a)/(x2-a).|) >= min(|.(f.x1-f.a
  )/(x1-a).|,|.(f.x2-f.a)/(x2-a).|) by Th1;
A30: |.(f.x1-f.a)/(x1-a).| >= 0 & |.(f.x2-f.a)/(x2-a).| >= 0 by COMPLEX1:46;
  then
A31: min(|.(f.x1-f.a)/(x1-a).|,|.(f.x2-f.a)/(x2-a).|) >= 0 by XXREAL_0:20;
  then
A32: M >= 0 by Th1;
  for r being Real st 0<r ex s being Real st 0<s & for x
  being Real st x in dom f & |.x-a.|<s holds |.f.x-f.a.|<r
  proof
    let r be Real such that
A33: 0<r;
    reconsider r as Real;
    ex s being Real st 0<s & for x being Real st x in dom f
    & |.x-a.|<s holds |.f.x-f.a.|<r
    proof
      now
        per cases by A30,A29,XXREAL_0:20;
        suppose
A34:      M>0;
          set s = min(r/M,min(a-x1,x2-a));
A35:      for x being Real st x in dom f & |.x-a.|<s holds |.f.
          x-f.a.|<r
          proof
A36:        s<=min(a-x1,x2-a) by XXREAL_0:17;
            let x be Real such that
            x in dom f and
A37:        |.x-a.|<s;
            min(a-x1,x2-a)<=a-x1 by XXREAL_0:17;
            then s <= a-x1 by A36,XXREAL_0:2;
            then |.x-a.|<a-x1 by A37,XXREAL_0:2;
            then -(a-x1) <= x-a by ABSVALUE:5;
            then x1-a <= x-a;
            then
A38:        x1 <= x by XREAL_1:9;
            min(a-x1,x2-a)<=x2-a by XXREAL_0:17;
            then s <= x2-a by A36,XXREAL_0:2;
            then |.x-a.|<x2-a by A37,XXREAL_0:2;
            then x-a <=x2-a by ABSVALUE:5;
            then
A39:        x <= x2 by XREAL_1:9;
            now
              per cases;
              suppose
                x<>a;
                then
A40:            |.f.x-f.a.|<=M*|.x-a.| by A19,A38,A39;
                now
                  per cases;
                  suppose
A41:                M<>0;
A42:                M*s <= M*(r/M) by A31,A29,XREAL_1:64,XXREAL_0:17;
                    M*|.x-a.| < M*s by A32,A37,A41,XREAL_1:68;
                    then M*|.x-a.| < M*(r/M) by A42,XXREAL_0:2;
                    then M*|.x-a.| < (r*M)/M by XCMPLX_1:74;
                    then M*|.x-a.| < r*(M/M) by XCMPLX_1:74;
                    then M*|.x-a.| < r*1 by A41,XCMPLX_1:60;
                    hence thesis by A40,XXREAL_0:2;
                  end;
                  suppose
                    M=0;
                    hence thesis by A33,A40;
                  end;
                end;
                hence thesis;
              end;
              suppose
                x=a;
                hence thesis by A33,ABSVALUE:2;
              end;
            end;
            hence thesis;
          end;
          s>0
          proof
A43:        min(a-x1,x2-a) > 0
            proof
              now
                per cases by XXREAL_0:15;
                suppose
                  min(a-x1,x2-a)=a-x1;
                  hence thesis by A5,XREAL_1:50;
                end;
                suppose
                  min(a-x1,x2-a)=x2-a;
                  hence thesis by A6,XREAL_1:50;
                end;
              end;
              hence thesis;
            end;
            now
              per cases by XXREAL_0:15;
              suppose
                s = r/M;
                hence thesis by A33,A34,XREAL_1:139;
              end;
              suppose
                s = min(a-x1,x2-a);
                hence thesis by A43;
              end;
            end;
            hence thesis;
          end;
          hence thesis by A35;
        end;
        suppose
A44:      M=0;
          set s = min(a-x1,x2-a);
A45:      for x being Real st x1<=x & x<=x2 & x<>a holds |.f.x- f.a.|=0
          proof
            let x be Real;
            assume x1<=x & x<=x2 & x<>a;
            then |.f.x-f.a.|<=M*|.x-a.| by A19;
            hence thesis by A44,COMPLEX1:46;
          end;
A46:      for x being Real st x in dom f & |.x-a.|<s holds |.f
          .x-f.a.|<r
          proof
            let x be Real such that
            x in dom f and
A47:        |.x-a.|<s;
            s<=a-x1 by XXREAL_0:17;
            then |.x-a.|<a-x1 by A47,XXREAL_0:2;
            then -(a-x1) <= x-a by ABSVALUE:5;
            then x1-a <= x-a;
            then
A48:        x1 <= x by XREAL_1:9;
            s<=x2-a by XXREAL_0:17;
            then |.x-a.|<x2-a by A47,XXREAL_0:2;
            then x-a <=x2-a by ABSVALUE:5;
            then
A49:        x <= x2 by XREAL_1:9;
            now
              per cases;
              suppose
                x<>a;
                hence thesis by A33,A45,A48,A49;
              end;
              suppose
                x=a;
                hence thesis by A33,ABSVALUE:2;
              end;
            end;
            hence thesis;
          end;
          s > 0
          proof
            now
              per cases by XXREAL_0:15;
              suppose
                s=a-x1;
                hence thesis by A5,XREAL_1:50;
              end;
              suppose
                s=x2-a;
                hence thesis by A6,XREAL_1:50;
              end;
            end;
            hence thesis;
          end;
          hence thesis by A46;
        end;
      end;
      hence thesis;
    end;
    hence thesis;
  end;
  hence thesis by FCONT_1:3;
end;
