
theorem Th29:
for f,g be PartFunc of REAL,REAL, a,b be Real st a < b & [.a,b.[ c=
  dom f & [.a,b.[ c= dom g & f is_right_ext_Riemann_integrable_on a,b & g
  is_right_ext_Riemann_integrable_on a,b holds f + g
  is_right_ext_Riemann_integrable_on a,b & ext_right_integral(f + g,a,b) =
  ext_right_integral(f,a,b) + ext_right_integral(g,a,b)
proof
  let f,g be PartFunc of REAL,REAL, a,b be Real such that
A1: a < b and
A2: [.a,b.[ c= dom f & [.a,b.[ c= dom g and
A3: f is_right_ext_Riemann_integrable_on a,b and
A4: g is_right_ext_Riemann_integrable_on a,b;
  consider Intg be PartFunc of REAL,REAL such that
A5: dom Intg = [.a,b.[ and
A6: for x be Real st x in dom Intg holds Intg.x = integral(g,a,x) and
A7: Intg is_left_convergent_in b and
A8: ext_right_integral(g,a,b) = lim_left(Intg,b) by A4,INTEGR10:def 3;
  consider Intf be PartFunc of REAL,REAL such that
A9: dom Intf = [.a,b.[ and
A10: for x be Real st x in dom Intf holds Intf.x = integral(f,a,x) and
A11: Intf is_left_convergent_in b and
A12: ext_right_integral(f,a,b) = lim_left(Intf,b) by A3,INTEGR10:def 3;
  set Intfg = Intf + Intg;
A13: dom Intfg = [.a,b.[ &
  for x be Real st x in dom Intfg holds Intfg.x =
  integral(f + g,a,x)
  proof
    thus
A14: dom Intfg = dom Intf /\ dom Intg by VALUED_1:def 1
      .= [.a,b.[ by A9,A5;
    let x be Real;
    assume
A15: x in dom Intfg;
    then
A16: x < b by A14,XXREAL_1:3;
    then
A17: [.a,x.] c= [.a,b.[ by XXREAL_1:43;
A18: a <= x by A14,A15,XXREAL_1:3;
    then
A19: f is_integrable_on [' a,x '] & f|[' a,x '] is bounded
    by A3,A16,INTEGR10:def 1;
    [' a,x '] = [.a,x.] by A18,INTEGRA5:def 3;
    then
A20: [' a,x '] c= dom f & [' a,x '] c= dom g by A2,A17;
A21: g is_integrable_on [' a,x '] & g|[' a,x '] is bounded
   by A4,A18,A16,INTEGR10:def 1;
    thus Intfg.x = Intf.x + Intg.x by A15,VALUED_1:def 1
      .= integral(f,a,x) + Intg.x by A9,A10,A14,A15
      .= integral(f,a,x) + integral(g,a,x) by A5,A6,A14,A15
      .= integral(f + g,a,x) by A18,A20,A19,A21,INTEGRA6:12;
  end;
A22: for r be Real st r < b
      ex g be Real st r < g & g < b & g in dom(Intf + Intg)
  proof
    let r be Real such that
A23: r < b;
    per cases;
    suppose
A24:  r < a;
      take g = a;
      thus thesis by A1,A13,A24,XXREAL_1:3;
    end;
    suppose
      not r < a;
      then
A25:  a - a <= r - a by XREAL_1:9;
      take g = r + (b - r)/2;
A26:  0 < b - r by A23,XREAL_1:50;
      then (b - r)/2 < b - r by XREAL_1:216;
      then
A27:  (b - r)/2 + r < b - r + r by XREAL_1:8;
      r < g by A26,XREAL_1:29,215;
      then
A28:  r - (r - a) < g - 0 by A25,XREAL_1:14;
      0 < (b - r)/2 by A26,XREAL_1:215;
      hence thesis by A13,A28,A27,XREAL_1:8,XXREAL_1:3;
    end;
  end;
  then
A29: Intfg is_left_convergent_in b by A11,A7,LIMFUNC2:45;
  for d be Real st a <= d & d < b
holds f + g is_integrable_on [' a,d '] &
  (f+g)|[' a,d '] is bounded
  proof
    let d be Real;
    assume
A30: a <= d & d < b;
    then [' a,d '] = [.a,d.] & [.a,d.] c= [.a,b.[
     by INTEGRA5:def 3,XXREAL_1:43; then
A31: [' a,d '] c= dom f & [' a,d '] c= dom g by A2;
A32: f is_integrable_on [' a,d '] & g is_integrable_on [' a,d ']
   by A3,A4,A30,INTEGR10:def 1;
A33: f|[' a,d '] is bounded & g|[' a,d '] is bounded
  by A3,A4,A30,INTEGR10:def 1;
    then (f + g)|([' a,d '] /\ [' a,d ']) is bounded by RFUNCT_1:83;
    hence thesis by A31,A32,A33,INTEGRA6:11;
  end;
  hence
A34: f + g is_right_ext_Riemann_integrable_on a,b
   by A13,A22,A11,A7,LIMFUNC2:45,INTEGR10:def 1;
  lim_left(Intfg,b) = ext_right_integral(f,a,b) + ext_right_integral(g,a
  ,b) by A11,A12,A7,A8,A22,LIMFUNC2:45;
  hence thesis by A13,A29,A34,INTEGR10:def 3;
end;
