 reserve a,b,r for Real;
 reserve A for non empty set;
 reserve X,x for set;
 reserve f,g,F,G for PartFunc of REAL,REAL;
 reserve n for Element of NAT;

theorem Th6:
  for a,b be Real,
      f be PartFunc of REAL,REAL
  st a <= b
   & [.a,b.] c= dom f & f | ['a,b'] is continuous
   & ( for t be Real st t in [.a,b.] holds 0 <= f.t )
   & ex t0 be Real st t0 in ].a,b.[ & 0 < f.t0
  holds
    ex d,c,e be Real
    st 0 < e & c < d & c in [.a,b.] & d in [.a,b.]
     & 0 < e*(d-c) <= integral(f,a,b)
proof
  let a,b be Real,
      f be PartFunc of REAL,REAL;

  assume
  A1: a <= b
    & [.a,b.] c= dom f & f | ['a,b'] is continuous
    & ( for t be Real st t in [.a,b.] holds 0 <= f.t )
    & ex t0 be Real st t0 in ].a,b.[ & 0 < f.t0;

  then consider t0 be Real such that
  A2: t0 in ].a,b.[ & 0 < f.t0;
  A3: ].a,b.[ c= [.a,b.] by Lm1;
  set e = f.t0 / 2;
  A4: ['a,b'] = [.a,b.] by A1,INTEGRA5:def 3; then
  consider s0 be Real such that
  A6: 0 < s0
    & for t be Real st t in ['a,b'] & |.t-t0.| < s0 holds |.f.t-f.t0.| < e
    by A1,A2,A3,FCONT_1:14;

  set s = s0/2;
  A7: 0 < s < s0 by A6,XREAL_1:216;

  reconsider s2 = min(t0-a,b-t0) as Real;

  A10: s2 <= t0-a & s2 <= b-t0 by XXREAL_0:17;
  A8: a < t0 < b by A2,XXREAL_1:4; then
  0 < t0 - a & 0 < b - t0 by XREAL_1:50; then
  A11: 0 < s2 by XXREAL_0:15;
  reconsider s3 = min(s,s2) as Real;
  A12: s3 <= s & s3 <= s2 by XXREAL_0:17;
  A13: 0 < s3 by A6,A11,XXREAL_0:15;
  set c = t0 - s3;
  set d = t0 + s3;
  set e0 = (f.t0)/2;
  take d,c,e0;
  thus 0 < e0 by A2;
  A15: t0 - s3 < t0 - 0 by XREAL_1:15,A13;
  thus
  A16: c < d by A13,XREAL_1:8;

  A18: t0 - s2 <= t0 - s3 by A12,XREAL_1:13;
  s2 + a <= t0 - a + a by A10,XREAL_1:7; then
  s2 + a - s2 <= t0 -s2 by XREAL_1:13; then
  A19: a <= c <= b by A8,A15,A18,XXREAL_0:2;
  hence
  A20: c in [.a,b.];

  A21: a + 0 < t0 + s3 by A8,A13,XREAL_1:8;
  A22: t0 + s3 <= t0 + s2 by A12,XREAL_1:7;
  s2 + t0 <= b - t0 + t0 by A10,XREAL_1:7; then
  A23: a <= d <= b by A21,A22,XXREAL_0:2;
  hence
  A24: d in [.a,b.];
  A25: [.c,d.] c= [.a,b.] by A19,A23,XXREAL_1:34;

  for t be Real st t in [.c,d.] holds e0 <= f.t
  proof
    let t be Real;
    assume
    A27: t in [.c,d.];
    then c <= t <= d by XXREAL_1:1;
    then t0 - s3 - t0 <= t - t0 <= t0 + s3 - t0 by XREAL_1:13;
    then |.t-t0.| <= s3 by ABSVALUE:5;
    then |.t-t0.| <= s by A12,XXREAL_0:2;
    then |.t-t0.| < s0 by A7,XXREAL_0:2;
    then |.f.t - f.t0.| < e by A4,A6,A25,A27;
    then -e <= f.t - f.t0 <= e by ABSVALUE:5;
    then -e + f.t0 <= f.t - f.t0 + f.t0 by XREAL_1:7;
    hence (f.t0)/2 <= f.t;
  end;

  hence 0 < e0*(d-c) <= integral(f,a,b) by A1,A2,A16,A20,A24,Th5;
end;
