reserve a,b,r,x,y for Real,
  i,j,k,n for Nat,
  x1 for set;
reserve A, B for non empty closed_interval Subset of REAL;
reserve f, g for Function of A,REAL;
reserve D, D1, D2 for Division of A;

theorem Th32:
  f|A is bounded & (for x st x in A holds f.x >= 0) implies
  integral(f) >= 0
proof
  assume that
A1: f|A is bounded and
A2: for x st x in A holds f.x >= 0;
A3: for a be Real st a in rng upper_sum_set(f) holds a >= 0
  proof
    let a be Real;
    assume a in rng upper_sum_set(f);
    then consider D being Element of divs A such that
A4: D in dom upper_sum_set(f) & a=(upper_sum_set(f)).D by PARTFUN1:3;
    reconsider D as Division of A by INTEGRA1:def 3;
A5: for i be Nat st i in dom upper_volume(f,D) holds 0 <= upper_volume(f,D
    ). i
    proof
      let i be Nat;
      set r = upper_volume(f,D).i;
      assume
A6:   i in dom upper_volume(f,D);
      len D = len upper_volume(f,D) by INTEGRA1:def 6;
      then
A7:   i in dom D by A6,FINSEQ_3:29;
A8:   upper_bound (rng(f|divset(D,i))) >= 0
      proof
        rng f is bounded_above by A1,INTEGRA1:13;
        then
A9:     rng(f|divset(D,i)) is bounded_above by RELAT_1:70,XXREAL_2:43;
        dom(f|divset(D,i)) = dom f /\ divset(D,i) & dom f = A by FUNCT_2:def 1
,RELAT_1:61;
        then dom(f|divset(D,i)) is non empty Subset of REAL by A7,INTEGRA1:8
,XBOOLE_1:28;
        then consider x being Element of REAL such that
A10:    x in dom(f|divset(D,i)) by SUBSET_1:4;
        f.x >= 0 by A2,A10;
        then
A11:    (f|divset(D,i)).x >= 0 by A10,FUNCT_1:47;
        (f|divset(D,i)).x in rng(f|divset(D,i)) by A10,FUNCT_1:def 3;
        hence thesis by A9,A11,SEQ_4:def 1;
      end;
A12:  vol(divset(D,i)) >= 0 by INTEGRA1:9;
      r = (upper_bound (rng (f|divset(D,i))))*vol(divset(D,i)) by A7,
INTEGRA1:def 6;
      hence thesis by A12,A8;
    end;
    a = upper_sum(f,D) by A4,INTEGRA1:def 10
      .= Sum(upper_volume(f,D)) by INTEGRA1:def 8;
    hence thesis by A5,RVSUM_1:84;
  end;
  upper_integral(f) = lower_bound rng upper_sum_set(f) & rng upper_sum_set
  (f) is non empty by INTEGRA1:def 14;
  then upper_integral(f) >= 0 by A3,SEQ_4:43;
  hence thesis by INTEGRA1:def 17;
end;
