reserve n,m for Nat,
  r,r1,r2,s,t for Real,
  x,y for set;

theorem
  for a,b be Real, F be PartFunc of REAL,REAL holds F is_convex_on
  [.a,b.] iff [.a,b.] c= dom F &
   for p be Real st 0<=p & p<=1
  for r,s be Real st r in [.a,b.] & s in [.a,b.]
   holds F.(p*r + (1-p)*s) <= p*F.r + (1-p)*F.s
proof
  let a,b be Real, f be PartFunc of REAL,REAL;
  set ab = {r: a<=r & r<=b};
A1: [.a,b.]= ab by RCOMP_1:def 1;
  thus f is_convex_on [.a,b.] implies [.a,b.] c= dom f &
  for p be Real st 0<=p
& p<=1 holds
 for x,y be Real st x in [.a,b.] & y in [.a,b.] holds f.(p*x + (1-p
  )*y) <= p* f.x + (1-p)*f.y
  proof
    assume
A2: f is_convex_on [.a,b.];
    hence [.a,b.] c= dom f;
    let p be Real;
    assume that
A3: 0<=p and
A4: p<=1;
A5: 0<=1-p by A4,XREAL_1:48;
A6: p*b+(1-p)*b=b;
A7: p*a+(1-p)*a=a;
    let x,y be Real;
    assume that
A8: x in [.a,b.] and
A9: y in [.a,b.];
A10: ex r2 st r2=y & a<=r2 & r2<=b by A1,A9;
    then
A11: (1-p)*y<=(1-p)*b by A5,XREAL_1:64;
A12: ex r1 st r1=x & a<=r1 & r1<=b by A1,A8;
    then p*x<=p*b by A3,XREAL_1:64;
    then
A13: p*x+(1-p)*y<=b by A11,A6,XREAL_1:7;
A14: (1-p)*a<=(1-p)*y by A5,A10,XREAL_1:64;
    p*a<=p*x by A3,A12,XREAL_1:64;
    then a<=p*x+(1-p)*y by A14,A7,XREAL_1:7;
    then p*x+(1-p)*y in ab by A13;
    hence thesis by A1,A2,A3,A4,A8,A9;
  end;
  assume that
A15: [.a,b.] c= dom f and
A16: for p be Real
    st 0<=p & p<=1 holds for x,y be Real st x in [.a,b.]
  & y in [.a,b.] holds f.(p*x + (1-p)*y) <= p* f.x + (1-p)*f.y;
  thus [.a,b.] c= dom f by A15;
  let p be Real;
  assume
A17: 0<=p & p<=1;
  let x,y be Real;
  assume that
A18: x in [.a,b.] & y in [.a,b.] and
  p*x + (1-p)*y in [.a,b.];
  thus thesis by A16,A17,A18;
end;
