reserve Z for set;

theorem Th3:
  for A be non empty closed_interval Subset of REAL, f be Function of A,REAL,
  D be Division of A, e be Real st f|A is bounded_below & 0 < e holds ex F be
  middle_volume of f,D st middle_sum(f,F) <= lower_sum (f,D) + e
proof
  let A be non empty closed_interval Subset of REAL,
  f be Function of A,REAL, D be
  Division of A, e be Real;
  len lower_volume (f,D) = len D by INTEGRA1:def 7;
  then reconsider
  p = lower_volume (f,D) as Element of (len D)-tuples_on REAL by FINSEQ_2:92;
  reconsider e1= e/(len D) as Element of REAL by XREAL_0:def 1;
  assume f|A is bounded_below & 0 < e;
  then consider F be middle_volume of f,D such that
A1: for i be Nat st i in dom D holds (lower_volume (f,D)).i <=F.i & F.i
  < (lower_volume (f,D)).i + e1 by Lm2,XREAL_1:139;
  set s= (len D) |-> e1;
  reconsider t =p + s as Element of (len D)-tuples_on REAL;
  take F;
  len F = len D by Def1;
  then reconsider q =F as Element of (len D)-tuples_on REAL by FINSEQ_2:92;
  now
    let i be Nat;
    assume
A2: i in Seg (len D);
    then i in dom D by FINSEQ_1:def 3;
    then q.i <= p.i + e1 by A1;
    then q.i <= p.i + s.i by A2,FINSEQ_2:57;
    hence q.i <= t.i by RVSUM_1:11;
  end;
  then Sum(q) <= Sum(t) by RVSUM_1:82;
  then Sum(q) <= Sum(p)+Sum(s) by RVSUM_1:89;
  then Sum(q) <= Sum(p)+ (len D)*e1 by RVSUM_1:80;
  hence thesis by XCMPLX_1:87;
end;
