reserve a,b,c,d,e for Real;
reserve X,Y for set,
          Z for non empty set,
          r for Real,
          s for ExtReal,
          A for Subset of REAL,
          f for real-valued Function;
reserve I for non empty closed_interval Subset of REAL,
       TD for tagged_division of I,
        D for Division of I,
        T for Element of set_of_tagged_Division(D),
        f for PartFunc of I,REAL;
reserve f for Function of I,REAL;
reserve f,g for HK-integrable Function of I,REAL,
          r for Real;
reserve f for bounded integrable Function of I,REAL;

theorem Th39:
  for i being Nat st i in dom TD holds
  (lower_volume(f,division_of TD)).i <= (tagged_volume(f,TD)).i
    <= (upper_volume(f,division_of TD)).i
  proof
    let i be Nat;
    assume
A1: i in dom TD;
    set a = (lower_volume(f,division_of TD)).i,
        b = (tagged_volume(f,TD)).i,
        c = (upper_volume(f,division_of TD)).i;
    reconsider D = division_of TD as Division of I;
    set x = (tagged_of TD).i;
    consider D9 be Division of I,
             T9 be Element of set_of_tagged_Division(D9) such that
A2: tagged_of TD = T9 & TD = [D9,T9] by Def2;
A3: D = D9 & x = T9.i by A2,Th20;
    consider s be non empty non-decreasing FinSequence of REAL such that
A4: T9 = s & dom s = dom D9 &
    for i be Nat st i in dom s holds s.i in divset(D9,i) by COUSIN:def 2;
    divset(D,i) c= I by A1,INTEGRA1:8;
    then x in I by A1,A3,A4;
    then
A5: x in dom f by FUNCT_2:def 1;
    then reconsider y = f.x as Element of REAL by PARTFUN1:4;
    f/.x in rng (f|divset(D,i)) by A1,A3,A4,A5,PARTFUN2:18; then
W1: f.x in rng (f|divset(D,i)) by A5,PARTFUN1:def 6;
    rng f is bounded_below by INTEGRA1:11; then
    rng (f|divset(D,i)) is bounded_below by RELAT_1:70,XXREAL_2:44; then
W3: (lower_bound rng (f|divset(D,i))) <= f.((tagged_of TD).i)
        by SEQ_4:def 2,W1;
    0 <= vol divset(D,i) by INTEGRA1:9;
    then (lower_bound rng (f|divset(D,i)))*vol divset(D,i)
      <= f.((tagged_of TD).i) * vol(divset(division_of TD,i))
        by XREAL_1:64,W3;
    then (lower_volume(f,D)).i
      <= f.((tagged_of TD).i) * vol(divset(division_of TD,i))
        by A1,INTEGRA1:def 7;
    hence a <= b by A1,Def4;
    f/.x in rng (f|divset(D,i)) by A1,A3,A4,A5,PARTFUN2:18; then
T2: f.x in rng (f|divset(D,i)) by A5,PARTFUN1:def 6;
    rng f is bounded_above by INTEGRA1:13; then
    rng (f|divset(D,i)) is bounded_above by RELAT_1:70,XXREAL_2:43; then
W1: f.((tagged_of TD).i) <= (upper_bound rng (f|divset(D,i)))
        by SEQ_4:def 1,T2;
    0 <= vol divset(D,i) by INTEGRA1:9;
    then f.((tagged_of TD).i) * vol(divset(division_of TD,i))
      <= (upper_bound rng (f|divset(D,i))) * vol divset(D,i) by W1,XREAL_1:64;
    then f.((tagged_of TD).i) * vol(divset(division_of TD,i))
      <= (upper_volume(f,D)).i by A1,INTEGRA1:def 6;
    hence b <= c by A1,Def4;
  end;
