
theorem Th36:
for A being Element of Family_of_Intervals st A is open_interval holds
 ex F being Open_Interval_Covering of A st F.0 = A &
  (for n being Nat st n <> 0 holds F.n = {}) & union rng F = A
  & SUM(F vol) = diameter A
proof
    let A be Element of Family_of_Intervals;
    assume A1: A is open_interval;
    defpred P[Nat,set] means
     ($1 = 0 implies $2 = A) & ($1 <> 0 implies $2 = {}REAL);

A2: for n being Element of NAT ex E being Element of bool REAL st P[n,E]
    proof
     let n be Element of NAT;
     per cases;
     suppose A3: n = 0;
      take E = A;
      thus P[n,E] by A3;
     end;
     suppose A4: n <> 0;
      take E = {}REAL;
      thus P[n,E] by A4;
     end;
    end;
    consider F be Function of NAT,(bool REAL) such that
A5:  for n being Element of NAT holds P[n,F.n] from FUNCT_2:sch 3(A2);
    reconsider F as sequence of (bool REAL);
    0 in NAT; then
    0 in dom F & F.0 = A by A5,FUNCT_2:def 1; then
    A in rng F by FUNCT_1:def 3; then
A6: A c= union rng F by ZFMISC_1:74;

    now let z be object;
     assume z in union rng F; then
     consider Y be set such that
A7:   z in Y & Y in rng F by TARSKI:def 4;
     ex n be object st n in dom F & Y = F.n by A7,FUNCT_1:def 3;
     hence z in A by A7,A5;
    end; then
A8:union rng F c= A;
A9: for n be Element of NAT holds F.n is open_interval by A1,A5;
    reconsider F as Open_Interval_Covering of A by A6,A9,Th32;
    take F;
    thus F.0 = A by A5;
    thus for n being Nat st n <> 0 holds F.n = {}
    proof
     let n be Nat;
     assume A10: n <> 0;
     n is Element of NAT by ORDINAL1:def 12;
     hence F.n = {} by A5,A10;
    end;
    thus union rng F = A by A8,A6,XBOOLE_0:def 10;

    for n being object holds 0 <= (F vol).n
    proof
     let n be object;
     per cases;
     suppose n in NAT; then
      reconsider n1 = n as Element of NAT;
      (F vol).n = diameter(F.n1) by MEASURE7:def 4;
      hence 0 <= (F vol).n by MEASURE5:13;
     end;
     suppose not n in NAT; then
      not n in dom(F vol);
      hence 0 <= (F vol).n by FUNCT_1:def 2;
     end;
    end; then
A11: F vol is nonnegative by SUPINF_2:51;
    defpred P[Nat] means (Partial_Sums(F vol)).$1 = diameter A;
    (Partial_Sums(F vol)).0 = (F vol).0 by MESFUNC9:def 1; then
    (Partial_Sums(F vol)).0 = diameter(F.0) by MEASURE7:def 4; then
A12:P[0] by A5;
A13:for n be Nat st P[n] holds P[n+1]
    proof
     let n be Nat;
     assume A14: P[n];
A15: (Partial_Sums(F vol)).(n+1) = (Partial_Sums(F vol)).n + (F vol).(n+1)
       by MESFUNC9:def 1;
     (F vol).(n+1) = diameter(F.(n+1)) by MEASURE7:def 4;then
     (F vol).(n+1) = diameter {} by A5;
     hence P[n+1] by A14,A15,XXREAL_3:4,MEASURE5:10;
    end;

A16: for n be Nat holds P[n] from NAT_1:sch 2(A12,A13);

    thus SUM(F vol) = diameter A
    proof
     SUM(F vol) = Sum(F vol) by A11,MEASURE8:2; then
A17:  SUM(F vol) = lim Partial_Sums(F vol) by MESFUNC9:def 3;

     per cases;
     suppose A18: diameter A = +infty; then
   for n be Element of NAT holds +infty <= (Partial_Sums(F vol)).n
        by A16; then
      Partial_Sums(F vol) is convergent_to_+infty by RINFSUP2:32;
      hence SUM(F vol) = diameter A by A17,A18,MESFUNC5:def 12;
     end;
     suppose A19: diameter A <> +infty;
      0 <= diameter A by A1,MEASURE5:13; then
      diameter A in REAL by A19,XXREAL_0:14;
      hence SUM(F vol) = diameter A by A16,A17,MESFUNC5:52;
     end;
    end;
end;
