reserve A for non empty closed_interval Subset of REAL;

theorem Th18Z:
for a,b,c being Real, f,g,h be Function of REAL,REAL st
a <= b & b <= c &
f is_integrable_on ['a,c'] & f | ['a,c'] is bounded &
g is_integrable_on ['a,c'] & g | ['a,c'] is bounded &
h | [.a,c.] = (f| [.a,b.]) +* (g | [.b,c.]) &
h is_integrable_on ['a,c'] & f.b = g.b
holds
integral(h,['a,c']) = integral(f,['a,b']) + integral(g,['b,c'])
proof
 let a,b,c be Real, f,g,h be Function of REAL,REAL;
 assume that
 A1: a <= b & b <= c and
 A2: f is_integrable_on ['a,c'] & f | ['a,c'] is bounded  and
 A3: g is_integrable_on ['a,c'] & g | ['a,c'] is bounded  and
 A4: h  | [.a,c.] = (f| [.a,b.]) +* (g | [.b,c.]) and
 A0: h is_integrable_on ['a,c'] and
 A5: f.b = g.b;
 B10: (f| [.a,b.]) tolerates (g | [.b,c.])
 proof
 for x being object st x in (dom (f| [.a,b.])) /\ (dom (g | [.b,c.])) holds
 (f| [.a,b.]) . x = (g | [.b,c.]) . x
 proof
  let  x being object;
  assume T1: x in (dom (f| [.a,b.])) /\ (dom (g | [.b,c.]));
  T2: (dom (f| [.a,b.])) /\ (dom (g | [.b,c.]))
   = [.a,b.] /\ (dom (g | [.b,c.])) by FUNCT_2:def 1
  .= [.a,b.] /\ [.b,c.] by FUNCT_2:def 1
  .= {b} by XXREAL_1:418,A1;
  (f| [.a,b.]) . x
   = (f| [.a,b.]) . b by TARSKI:def 1,T1,T2
  .= f.b by FUNCT_1:49,XXREAL_1:1,A1
  .= (g | [.b,c.]) . b by FUNCT_1:49,XXREAL_1:1,A1,A5;
  hence thesis by TARSKI:def 1,T1,T2;
 end;
 hence thesis by PARTFUN1:def 4;
 end;
 reconsider h1  = (h | ['a,b']) as PartFunc of ['a,b'],REAL;
 reconsider f1 = (f | ['a,b']) as PartFunc of ['a,b'],REAL;
 reconsider H = upper_sum_set h1 as Function of (divs ['a,b']),REAL;
 reconsider F = upper_sum_set f1 as Function of (divs ['a,b']),REAL;
 A6: H = F
 proof
 for D being object st D in (divs ['a,b']) holds
 H . D = F . D
 proof
  let D be object;
  assume D in  (divs ['a,b']);then
  reconsider D as Division of  ['a,b'] by INTEGRA1:def 3;
  set uvh1 = upper_volume (h1,D);
  set uvf1 = upper_volume (f1,D);
  len D = len uvh1 & len D = len uvf1 by INTEGRA1:def 6;then
  A8: dom uvh1 = dom uvf1 by FINSEQ_3:29;
  B4: uvh1  = uvf1
  proof
  for i being Element of NAT st i in dom uvh1 holds uvh1 . i = uvf1 . i
  proof
   let i be Element of NAT;
   assume B1: i in dom (upper_volume (h1,D));
   len D = len uvh1 by INTEGRA1:def 6;then
   B2: i in dom D by FINSEQ_3:29,B1;
   B5: (divset (D,i)) c= ['a,b'] by INTEGRA1:8,B2;
   B7: h | (divset (D,i)) = f | (divset (D,i))
   proof
    for x being object st x in divset (D,i) holds
     (h | (divset (D,i))) . x = (f | (divset (D,i))) . x
    proof
     let x be object;
     assume
     B8: x in divset (D,i); then
     B9X: x in ['a,b'] by B5; then
     B9: x in [.a,b.] by INTEGRA5:def 3,A1;
     reconsider x as Real by B8;
     a <= x & x <= b by XXREAL_1:1,B9; then
     B9c: a <= x & x <= c by XXREAL_0:2,A1;
     dom (f| [.a,b.]) = [.a,b.] by FUNCT_2:def 1; then
     B11: x in dom (f| [.a,b.]) by B9X,INTEGRA5:def 3,A1;
     (h | (divset (D,i))).x = h . x by B8,FUNCT_1:49
     .= (h | [.a,c.]).x by FUNCT_1:49,B9c,XXREAL_1:1
     .= (f| [.a,b.]) .x by B10,FUNCT_4:15,B11,A4
     .= f.x by B9,FUNCT_1:49;
     hence thesis by B8,FUNCT_1:49;
    end;
    hence thesis by FUNCT_2:12;
   end;
   B3: h1 | (divset (D,i)):: = (h | ['a,b']) | (divset (D,i))
   = h | (divset (D,i)) by B5,FUNCT_1:51
   .= f1 | (divset (D,i)) by B5,FUNCT_1:51,B7;
   uvh1 . i
   = (upper_bound (rng (f1 | (divset (D,i))))) * (vol (divset (D,i)))
      by B3,INTEGRA1:def 6,B2;
   hence thesis by INTEGRA1:def 6,B2;
  end;
  hence thesis by PARTFUN1:5,A8;
  end;
  H . D = upper_sum (h1,D) by INTEGRA1:def 10
   .= Sum (upper_volume (f1,D)) by B4,INTEGRA1:def 8
   .= upper_sum (f1,D) by INTEGRA1:def 8
  .= F . D  by INTEGRA1:def 10;
  hence thesis;
 end;
 hence thesis by FUNCT_2:12;
 end;
 B6: integral (h,['a,b']) = integral h1 by INTEGRA5:def 2
 .= upper_integral h1 by INTEGRA1:def 17
 .= lower_bound (rng (upper_sum_set f1)) by A6,INTEGRA1:def 14
 .= upper_integral f1 by INTEGRA1:def 14
 .= integral f1 by INTEGRA1:def 17
 .= integral (f,['a,b']) by INTEGRA5:def 2;
 reconsider h2  = (h | ['b,c']) as PartFunc of ['b,c'],REAL;
 reconsider g1 = (g | ['b,c']) as PartFunc of ['b,c'],REAL;
 reconsider H1 = upper_sum_set h2 as Function of (divs ['b,c']),REAL;
 reconsider G = upper_sum_set g1 as Function of (divs ['b,c']),REAL;
 A66: H1 = G
 proof
  for D being object st D in (divs ['b,c']) holds
  H1 . D = G . D
  proof
   let D be object;
   assume D in  (divs ['b,c']);then
   reconsider D as Division of  ['b,c'] by INTEGRA1:def 3;
   set uvh2 = upper_volume (h2,D);
   set uvg1 = upper_volume (g1,D);
   len D = len uvh2 & len D = len uvg1 by INTEGRA1:def 6;then
   A8: dom uvh2 = dom uvg1 by FINSEQ_3:29;
   B4: uvh2  = uvg1
   proof
    for i being Element of NAT st i in dom uvh2 holds uvh2 . i = uvg1 . i
    proof
     let i be Element of NAT;
     assume B1: i in dom (upper_volume (h2,D));
     reconsider i as Nat;
     len D = len uvh2 by INTEGRA1:def 6;then
     B2: i in dom D by FINSEQ_3:29,B1;
     B5: (divset (D,i)) c= ['b,c'] by INTEGRA1:8,B2;
     B7: h | (divset (D,i))  = g | (divset (D,i))
     proof
      for x being object st x in divset (D,i) holds
      (h | (divset (D,i))) . x = (g | (divset (D,i))) . x
      proof
       let x be object;
       assume
       B8: x in divset (D,i); then
       B9X: x in ['b,c'] by B5; then
       B9: x in [.b,c.] by INTEGRA5:def 3,A1;
       reconsider x as Real by B8;
       b <= x & x <= c by XXREAL_1:1,B9; then
       B9c: a <= x & x <= c by XXREAL_0:2,A1;
       dom (g| [.b,c.]) = [.b,c.] by FUNCT_2:def 1; then
       B11: x in dom (g| [.b,c.]) by B9X,INTEGRA5:def 3,A1;
       (h | (divset (D,i))).x = h . x by B8,FUNCT_1:49
       .= ((f| [.a,b.]) +* (g| [.b,c.])).x
            by A4,FUNCT_1:49,B9c,XXREAL_1:1
       .= (g| [.b,c.]) .x by FUNCT_4:13,B11
       .= g.x by B9,FUNCT_1:49;
       hence thesis by B8,FUNCT_1:49;
      end;
      hence thesis by FUNCT_2:12;
     end;
     B3: h2 | (divset (D,i))
     = g | (divset (D,i)) by B7,B5,FUNCT_1:51
     .= g1 | (divset (D,i)) by B5,FUNCT_1:51;
     uvh2 . i
     = (upper_bound (rng (g1 | (divset (D,i))))) * (vol (divset (D,i)))
         by B3,INTEGRA1:def 6,B2;
     hence thesis by INTEGRA1:def 6,B2;
    end;
    hence thesis by PARTFUN1:5,A8;
   end;
   H1 . D = upper_sum (h2,D) by INTEGRA1:def 10
   .= Sum (upper_volume (g1,D)) by B4,INTEGRA1:def 8
   .= upper_sum (g1,D) by INTEGRA1:def 8
   .= G . D  by INTEGRA1:def 10;
   hence thesis;
  end;
  hence thesis by FUNCT_2:12;
 end;
 C1: integral (h,['b,c'])
  = integral h2 by INTEGRA5:def 2
 .= upper_integral h2 by INTEGRA1:def 17
 .= lower_bound (rng (upper_sum_set g1)) by A66,INTEGRA1:def 14
 .= upper_integral g1 by INTEGRA1:def 14
 .= integral g1 by INTEGRA1:def 17
 .= integral (g,['b,c']) by INTEGRA5:def 2;
 reconsider h,f,g as PartFunc of REAL,REAL;
 A04: a <= c by A1,XXREAL_0:2;
 A01: h | ['a,c'] is bounded by A1,A2,A3,A4,A5,Th18B;
 A02: dom h = REAL by FUNCT_2:def 1;
 b in [.a,c.] by A1; then
 A03: b in ['a,c'] by INTEGRA5:def 3,A1,XXREAL_0:2;
 integral (h,['a,c'])
  = integral (h,a,c) by INTEGRA5:def 4,A1,XXREAL_0:2
 .= integral (h,a,b) + integral (h,b,c)
       by INTEGRA6:17,A04,A0,A01,A03,A02
 .= integral (f,['a,b']) + integral (h,b,c) by B6,INTEGRA5:def 4,A1
 .= integral (f,['a,b']) + integral (h,['b,c']) by INTEGRA5:def 4,A1;
 hence thesis by C1;
end;
