
theorem
  for X being RealLinearSpace, f being Function of the carrier of X,
ExtREAL st (for x being VECTOR of X holds f.x <> -infty) holds f is convex iff
for x1, x2 being VECTOR of X,
   p being Real st 0<=p & p<=1 holds f.(p*x1+(1-p)*
  x2) <= (p)*f.x1+(1-p)*f.x2
proof
  let X be RealLinearSpace, f be Function of the carrier of X,ExtREAL;
  assume
A1: for x being VECTOR of X holds f.x <> -infty;
  thus f is convex implies for x1, x2 being VECTOR of X,
    p being Real st 0<=p
  & p<=1 holds f.(p*x1+(1-p)*x2) <= (p)*f.x1+(1-p)*f.x2
  proof
    assume
A2: f is convex;
    let x1, x2 be VECTOR of X, p be Real;
    assume that
A3: 0<=p and
A4: p<=1;
    per cases;
    suppose
A5:   p=0;
      then
A6:   (1-p)*x2=x2 by RLVECT_1:def 8;
      p*x1 = 0.X by A5,RLVECT_1:10;
      then
A7:   p*x1+(1-p)*x2=x2 by A6;
A8:   (1-p)*f.x2=f.x2 by A5,XXREAL_3:81;
      (p)*f.x1=0. by A5;
      hence thesis by A7,A8,XXREAL_3:4;
    end;
    suppose
A9:   p=1;
      then
A10:  (1-p)*x2=0.X by RLVECT_1:10;
      p*x1 = x1 by A9,RLVECT_1:def 8;
      then
A11:  p*x1+(1-p)*x2=x1 by A10;
A12:  (p)*f.x1=f.x1 by A9,XXREAL_3:81;
      (1-p)*f.x2=0. by A9;
      hence thesis by A11,A12,XXREAL_3:4;
    end;
    suppose
A13:  p<>0 & p<>1;
      then p<1 by A4,XXREAL_0:1;
      hence thesis by A1,A2,A3,A13,Th4;
    end;
  end;
  assume for x1, x2 being VECTOR of X,
    p being Real st 0<=p & p<=1 holds f.(
  p*x1+(1-p)*x2) <= (p)*f.x1+(1-p)*f.x2;
  then
  for x1, x2 being VECTOR of X,
    p being Real st 0<p & p<1 holds f.(p*x1+(
  1-p)*x2) <= (p)*f.x1+(1-p)*f.x2;
  hence thesis by A1,Th4;
end;
