reserve a,a1,b,b1,x,y for Real,
  F,G,H for FinSequence of REAL,
  i,j,k,n,m for Element of NAT,
  I for Subset of REAL,
  X for non empty set,
  x1,R,s for set;
reserve A for non empty closed_interval Subset of REAL;
reserve A, B for non empty closed_interval Subset of REAL;
reserve r for Real;
reserve D, D1, D2 for Division of A;
reserve f, g for Function of A,REAL;

theorem Th26:
  f|A is bounded implies lower_sum(f,D) <= upper_sum(f,D)
proof
  deffunc F(Nat)=
   In((lower_bound rng (f|divset(D,$1)))*vol(divset(D,$1)),REAL);
  consider p being FinSequence of REAL such that
A1: len p = len D & for i be Nat st i in dom p holds p.i=F(i) from
  FINSEQ_2:sch 1;
A2: for i be Nat st i in dom p holds p.i=
     (lower_bound rng (f|divset(D,i)))*vol(divset(D,i))
    proof let i be Nat;
     assume i in dom p;
      then p.i= F(i) by A1;
     hence thesis;
    end;
  assume
A3: f|A is bounded;
  then
A4: rng f is bounded_above by Th11;
A5: dom p = dom D by A1,FINSEQ_3:29;
  reconsider p as Element of (len D)-tuples_on REAL by A1,FINSEQ_2:92;
  deffunc G(Nat)=
    In((upper_bound rng (f|divset(D,$1)))*vol(divset(D,$1)),REAL);
  consider q being FinSequence of REAL such that
A6: len q = len D & for i be Nat st i in dom q holds q.i=G(i) from
  FINSEQ_2:sch 1;
A7: for i be Nat st i in dom q holds q.i=
   (upper_bound rng (f|divset(D,i)))*vol(divset(D,i))
   proof let i be Nat;
    assume i in dom q;
     then q.i=G(i) by A6;
    hence thesis;
   end;
A8: dom q = dom D by A6,FINSEQ_3:29;
   then len q = len D by FINSEQ_3:29;
  then
A9: q=upper_volume(f,D) by A7,Def5,A8;
  reconsider q as Element of (len D)-tuples_on REAL by A6,FINSEQ_2:92;
A10: rng f is bounded_below by A3,Th9;
  for i be Nat st i in Seg(len D) holds p.i <= q.i
  proof
    let i be Nat;
A11: dom f = A by FUNCT_2:def 1;
    assume
A12: i in Seg(len D);
    then
A13: i in dom D by FINSEQ_1:def 3;
    i in dom D by A12,FINSEQ_1:def 3;
    then dom (f|divset(D,i)) = divset(D,i) by A11,Th6,RELAT_1:62;
    then
A14: rng(f|divset(D,i)) is non empty Subset of REAL by RELAT_1:42;
A15: 0 <= vol(divset(D,i)) by SEQ_4:11,XREAL_1:48;
A16: rng (f|divset(D,i)) is bounded_above by A4,RELAT_1:70,XXREAL_2:43;
    rng (f|divset(D,i)) is bounded_below by A10,RELAT_1:70,XXREAL_2:44;
    then
    lower_bound (rng(f|divset(D,i)))*vol(divset(D,i)) <= upper_bound (rng
    (f|divset(D,i)))*vol(divset(D,i)) by A16,A14,A15,SEQ_4:11,XREAL_1:64;
    then
    p.i <= upper_bound (rng(f|divset(D,i)))*vol(divset(D,i))
       by A5,A13,A2;
    hence thesis by A8,A13,A7;
  end;
  then Sum p <= Sum q by RVSUM_1:82;
  hence thesis by A1,A5,A9,Def6,A2;
end;
