MESFUN15

index · ← FIELD_10 · CLASSES4 →
:: Absolutely Integrable Functions
::  by Noboru Endou
::
:: Received April 30, 2022
:: Copyright (c) 2022-2026 Association of Mizar Users
::           (Stowarzyszenie Uzytkownikow Mizara, Bialystok, Poland).
:: This code can be distributed under the GNU General Public Licence
:: version 3.0 or later, or the Creative Commons Attribution-ShareAlike
:: License version 3.0 or later, subject to the binding interpretation
:: detailed in file COPYING.interpretation.
:: See COPYING.GPL and COPYING.CC-BY-SA for the full text of these
:: licenses, or see http://www.gnu.org/licenses/gpl.html and
:: http://creativecommons.org/licenses/by-sa/3.0/.

environ

 vocabularies FUNCT_1, NUMBERS, SUBSET_1, SUPINF_2, ARYTM_3, CARD_1, RELAT_1,
      TARSKI, ORDINAL2, XXREAL_0, NAT_1, XXREAL_2, XBOOLE_0, MEASURE5,
      SUPINF_1, REAL_1, PROB_1, MEASURE1, XXREAL_1, ARYTM_1, CARD_3, VALUED_0,
      MESFUNC5, SEQ_2, COMPLEX1, MEASURE3, MEASUR12, PARTFUN1, INTEGRA1,
      MESFUNC8, INTEGRA5, REALSET1, MESFUNC1, MEASURE6, SEQFUNC, RFUNCT_3,
      PBOOLE, FUNCT_3, VALUED_1, ZFMISC_1, LIMFUNC1, LIMFUNC2, INTEGR10,
      FUNCT_7, PROB_2, SERIES_1, MSSUBFAM, PROB_3, INTEGR24, INTEGR25;
 notations TARSKI, XBOOLE_0, SUBSET_1, ORDINAL1, FUNCT_1, ZFMISC_1, RELAT_1,
      RELSET_1, PARTFUN1, SEQ_2, KURATO_0, VALUED_0, FUNCT_2,
      XXREAL_0, MEASURE3, XXREAL_3, XCMPLX_0, EXTREAL1, COMPLEX1, XREAL_0,
      NUMBERS, SUPINF_1, RFUNCT_3, SUPINF_2, NAT_1, RCOMP_1, MEASURE1,
      MEASURE5, MESFUNC1, VALUED_1, MESFUNC2, MESFUNC6, MESFUNC5, MESFUNC8,
      MESFUNC9,
      MEASUR11, PROB_1, PROB_3, MEASUR12, INTEGRA1, RFUNCT_1, INTEGRA5,
      SEQFUNC, DBLSEQ_3, SETLIM_1, LIMFUNC1, LIMFUNC2, INTEGR10, INTEGR24,
      INTEGR25, MESFUN7C;
 constructors SUPINF_1, MEASURE6, EXTREAL1, PROB_3, MEASUR11, MEASURE3, SEQ_4,
      NEWTON, COMSEQ_2, MEASUR12, INTEGRA2, INTEGRA5, MESFUNC6, MESFUNC2,
      SEQFUNC, MESFUNC9, LIMFUNC1, LIMFUNC2, INTEGR10, KURATO_0, DBLSEQ_3,
      INTEGR24, INTEGR25, MESFUN7C;
 registrations XBOOLE_0, SUBSET_1, ORDINAL1, NUMBERS, XREAL_0, MEMBERED,
      MEASURE1, VALUED_0, XXREAL_2, RELSET_1, MEASURE5, NAT_1, XXREAL_0,
      XXREAL_3, PARTFUN1, DBLSEQ_3, PROB_3, FINSEQ_9, LPSPACC1, RELAT_1,
      XCMPLX_0, VALUED_1;
 requirements NUMERALS, BOOLE, SUBSET, ARITHM, REAL;
 expansions TARSKI;
 theorems TARSKI, SUPINF_2, MEASURE1, FUNCT_1, MEASURE5, ZFMISC_1, FUNCT_2,
      NAT_1, XBOOLE_0, XBOOLE_1, XXREAL_0, ORDINAL1, XXREAL_3, XXREAL_1,
      MESFUNC5, MESFUNC9, XREAL_1, MEASUR10, XREAL_0, VALUED_0, PARTFUN1,
      EXTREAL1, RELAT_1, PROB_2, NUMBERS, MEASURE3, MEASUR12, MESFUNC6,
      MESFUNC1, INTEGRA5, INTEGRA4, RFUNCT_1, SEQ_4, MESFUNC2, MESFUN11,
      VALUED_1, MESFUNC8, SEQ_2, ABSVALUE, RELSET_1, MESFUN13, INTEGRA2,
      FINSUB_1, FUNCT_3, RFUNCT_3, PROB_1, LIMFUNC2, INTEGR10, PROB_4,
      SETLIM_1, CARD_3, COMPLEX1, INTEGRA6, LIMFUNC1, DBLSEQ_3, PROB_3,
      MESFUN14, INTEGR24, INTEGR25, MESFUN6C, RFUNCT_2, MESFUN7C, LPSPACE2;
 schemes FUNCT_2, NAT_1, FUNCT_1;

begin :: Preliminaries

Th1:
for seq be without-infty ExtREAL_sequence holds
  Partial_Sums seq is without-infty ExtREAL_sequence
proof
    let seq be without-infty ExtREAL_sequence;
    defpred P[Nat] means (Partial_Sums seq).$1 <> -infty;

    (Partial_Sums seq).0 = seq.0 by MESFUNC9:def 1; then
    (Partial_Sums seq).0 > -infty by MESFUNC5:def 5; then
A1: P[0];
A2: for n be Nat st P[n] holds P[n+1]
    proof
     let n be Nat;
     assume A3: P[n];
A4:  seq.(n+1) > -infty by MESFUNC5:def 5;
     (Partial_Sums seq).(n+1) = (Partial_Sums seq).n + seq.(n+1)
       by MESFUNC9:def 1;
     hence P[n+1] by A3,A4,XXREAL_3:17;
    end;
A5: for n be Nat holds P[n] from NAT_1:sch 2(A1,A2);
    hereby assume
     not Partial_Sums seq is without-infty ExtREAL_sequence; then
     -infty in rng(Partial_Sums seq) by MESFUNC5:def 3; then
     ex n be Element of NAT st -infty = (Partial_Sums seq).n by FUNCT_2:113;
     hence contradiction by A5;
    end;
end;

Th2:
for seq be without+infty ExtREAL_sequence holds
  Partial_Sums seq is without+infty ExtREAL_sequence
proof
    let seq be without+infty ExtREAL_sequence;
    defpred P[Nat] means (Partial_Sums seq).$1 <> +infty;

    (Partial_Sums seq).0 = seq.0 by MESFUNC9:def 1; then
A1: P[0] by MESFUNC5:def 6;
A2: for n be Nat st P[n] holds P[n+1]
    proof
     let n be Nat;
     assume A3: P[n];
A4:  seq.(n+1) < +infty by MESFUNC5:def 6;
     (Partial_Sums seq).(n+1) = (Partial_Sums seq).n + seq.(n+1)
       by MESFUNC9:def 1;
     hence P[n+1] by A3,A4,XXREAL_3:16;
    end;
A5: for n be Nat holds P[n] from NAT_1:sch 2(A1,A2);
    hereby assume not Partial_Sums seq is without+infty ExtREAL_sequence; then
     +infty in rng(Partial_Sums seq) by MESFUNC5:def 4; then
     ex n be Element of NAT st
      +infty = (Partial_Sums seq).n by FUNCT_2:113;
     hence contradiction by A5;
    end;
end;

registration
  let seq be without-infty ExtREAL_sequence;
  cluster Partial_Sums seq -> without-infty;
  correctness by Th1;
end;

registration
  let seq be without+infty ExtREAL_sequence;
  cluster Partial_Sums seq -> without+infty;
  correctness by Th2;
end;

theorem Th3:
for f1 be without-infty ExtREAL_sequence, f2 be without+infty ExtREAL_sequence
 holds Partial_Sums(f1-f2) = Partial_Sums f1 - Partial_Sums f2
     & Partial_Sums(f2-f1) = Partial_Sums f2 - Partial_Sums f1
proof
    let f1 be without-infty ExtREAL_sequence,
        f2 be without+infty ExtREAL_sequence;
    set P1 = Partial_Sums f1;
    set P2 = Partial_Sums f2;
    set P12 = Partial_Sums(f1-f2);
    set P21 = Partial_Sums(f2-f1);

    defpred C[Nat] means P12.$1 = P1.$1 - P2.$1;
    P12.0 = (f1-f2).0 by MESFUNC9:def 1; then
    P12.0 = f1.0 - f2.0 by DBLSEQ_3:7; then
    P12.0 = P1.0 - f2.0 by MESFUNC9:def 1; then
A1: C[0] by MESFUNC9:def 1;

A2: for k be Nat st C[k] holds C[k+1]
    proof
     let k be Nat;
     assume A3: C[k];
A4:  P1.k <> -infty & P2.k <> +infty & f1.(k+1) <> -infty
   & f2.(k+1) <> +infty & (f1-f2).(k+1) <> -infty & P2.(k+1) <> +infty
       by MESFUNC5:def 5,def 6; then
A5:  P2.k + f2.(k+1) <> +infty & -f1.(k+1) <> +infty
   & -P2.(k+1) <> -infty by XXREAL_3:16,23;
     P12.(k+1) = P12.k + (f1-f2).(k+1) by MESFUNC9:def 1
      .= P1.k - ( P2.k - (f1-f2).(k+1) ) by A3,A4,XXREAL_3:32
      .= P1.k - ( P2.k - (f1.(k+1) - f2.(k+1)) ) by DBLSEQ_3:7
      .= P1.k - ( P2.k - f1.(k+1) + f2.(k+1) ) by A4,XXREAL_3:32
      .= P1.k - ( - f1.(k+1) + P2.k  + f2.(k+1) ) by XXREAL_3:def 4
      .= P1.k - ( - f1.(k+1) + (P2.k + f2.(k+1)) ) by A4,A5,XXREAL_3:29
      .= P1.k - ( - f1.(k+1) + P2.(k+1) ) by MESFUNC9:def 1
      .= P1.k - ( P2.(k+1) - f1.(k+1) ) by XXREAL_3:def 4
      .= P1.k - P2.(k+1) + f1.(k+1) by A4,XXREAL_3:32
      .= P1.k + (- P2.(k+1)) + f1.(k+1) by XXREAL_3:def 4
      .= P1.k + f1.(k+1) + (- P2.(k+1)) by A4,A5,XXREAL_3:29
      .= P1.(k+1) + (- P2.(k+1)) by MESFUNC9:def 1;
     hence C[k+1] by XXREAL_3:def 4;
    end;
A6: for k be Nat holds C[k] from NAT_1:sch 2(A1,A2);
    for k be Element of NAT holds P12.k = (P1-P2).k
    proof
     let k be Element of NAT;
     P12.k = P1.k - P2.k by A6;
     hence P12.k = (P1-P2).k by DBLSEQ_3:7;
    end;
    hence P12 = P1-P2 by FUNCT_2:63;

    defpred C[Nat] means P21.$1 = P2.$1 - P1.$1;
    P21.0 = (f2-f1).0 by MESFUNC9:def 1
     .= f2.0 - f1.0 by DBLSEQ_3:7
     .= P2.0 - f1.0 by MESFUNC9:def 1; then
A7: C[0] by MESFUNC9:def 1;
A8: for k be Nat st C[k] holds C[k+1]
    proof
     let k be Nat;
     assume A9: C[k];
A10:  P2.k <> +infty & P1.k <> -infty & f2.(k+1) <> +infty
   & f1.(k+1) <> -infty & (f2-f1).(k+1) <> +infty & P1.(k+1) <> -infty
         by MESFUNC5:def 5,def 6; then
A11:  P1.k + f1.(k+1) <> -infty & -f2.(k+1) <> -infty
   & -P1.(k+1) <> +infty by XXREAL_3:17,23;
     P21.(k+1) = P21.k + (f2-f1).(k+1) by MESFUNC9:def 1
      .= P2.k - ( P1.k - (f2-f1).(k+1) ) by A9,A10,XXREAL_3:32
      .= P2.k - ( P1.k - (f2.(k+1) - f1.(k+1)) ) by DBLSEQ_3:7
      .= P2.k - ( P1.k - f2.(k+1) + f1.(k+1) ) by A10,XXREAL_3:32
      .= P2.k - ( - f2.(k+1) + P1.k  + f1.(k+1) ) by XXREAL_3:def 4
      .= P2.k - ( - f2.(k+1) + (P1.k + f1.(k+1)) ) by A10,A11,XXREAL_3:29
      .= P2.k - ( - f2.(k+1) + P1.(k+1) ) by MESFUNC9:def 1
      .= P2.k - ( P1.(k+1) - f2.(k+1) ) by XXREAL_3:def 4
      .= P2.k - P1.(k+1) + f2.(k+1) by A10,XXREAL_3:32
      .= P2.k + (- P1.(k+1)) + f2.(k+1) by XXREAL_3:def 4
      .= P2.k + f2.(k+1) + (- P1.(k+1)) by A10,A11,XXREAL_3:29
      .= P2.(k+1) + (- P1.(k+1)) by MESFUNC9:def 1;
     hence C[k+1] by XXREAL_3:def 4;
    end;
A12: for k be Nat holds C[k] from NAT_1:sch 2(A7,A8);
    for k be Element of NAT holds P21.k = (P2-P1).k
    proof
     let k be Element of NAT;
     P21.k = P2.k - P1.k by A12;
     hence P21.k = (P2-P1).k by DBLSEQ_3:7;
    end;
    hence P21 = P2-P1 by FUNCT_2:63;
end;

theorem Th4:
for X,A be set, f be PartFunc of X,REAL st f is nonpositive holds
  f|A is nonpositive
proof
    let X,A be set, f be PartFunc of X,REAL;
    assume A1: f is nonpositive;

    now let r be R_eal;
     assume r in rng(f|A); then
     consider x be object such that
A2:   x in dom(f|A) & r = (f|A).x by FUNCT_1:def 3;
     f.x <= 0 by A1,A2,MESFUNC6:53;
     hence r <= 0 by A2,FUNCT_1:47;
    end;
    hence f|A is nonpositive by MESFUNC5:def 1,def 2;
end;

theorem Th5:
for X be set, f be PartFunc of X,REAL st f is nonpositive holds
  -f is nonnegative
proof
    let X be set, f be PartFunc of X,REAL;
    assume A1: f is nonpositive;

    now let x be object;
     assume x in dom(-f); then
     f.x <= 0 by A1,MESFUNC6:53; then
     -(f.x) >= 0;
     hence 0 <= (-f).x by VALUED_1:8;
    end;
    hence -f is nonnegative by MESFUNC6:52;
end;

theorem Th6:
for f be PartFunc of REAL,REAL, a be Real st
 f is_left_convergent_in a & f is non-decreasing holds
  for x be Real st x in dom f & x < a holds f.x <= lim_left(f,a)
proof
    let f be PartFunc of REAL,REAL, a be Real;
    assume that
A1:  f is_left_convergent_in a and
A2:  f is non-decreasing;
    let x be Real;
    assume that
A3:  x in dom f and
A4:  x < a;

    hereby assume
A5:  f.x > lim_left(f,a); then
A6:  f.x - lim_left(f,a) > 0 by XREAL_1:50;
     set g1 = f.x - lim_left(f,a);
     consider r be Real such that
A7:   r < a and
A8:   for r1 be Real st r < r1 & r1 < a & r1 in dom f
        holds |.f.r1-lim_left(f,a).| < g1 by A6,A1,LIMFUNC2:41;

     consider R be Real such that
A9:   max(x,r) < R & R < a & R in dom f by A1,A4,A7,XXREAL_0:29,LIMFUNC2:def 1;
A10: x <= max(x,r) & r <= max(x,r) by XXREAL_0:25; then
     r < R by A9,XXREAL_0:2; then
A11: |.f.R - lim_left(f,a).| < g1 by A8,A9;

     x < R by A9,A10,XXREAL_0:2; then
A12: f.x <= f.R by A2,A3,A9,RFUNCT_2:def 3; then
     lim_left(f,a) < f.R by A5,XXREAL_0:2; then
     f.R - lim_left(f,a) > 0 by XREAL_1:50; then
     f.R - lim_left(f,a) < g1 by A11,ABSVALUE:def 1;
     hence contradiction by A12,XREAL_1:9;
    end;
end;

theorem
for f be PartFunc of REAL,REAL, a be Real st
 f is_left_convergent_in a & f is non-increasing holds
  for x be Real st x in dom f & x < a holds f.x >= lim_left(f,a)
proof
    let f be PartFunc of REAL,REAL, a be Real;
    assume that
A1:  f is_left_convergent_in a and
A2:  f is non-increasing;
    let x be Real;
    assume that
A3:  x in dom f and
A4:  x < a;

    hereby assume
A5:  f.x < lim_left(f,a); then
A6:  lim_left(f,a) - f.x > 0 by XREAL_1:50;
     set g1 = lim_left(f,a) - f.x;
     consider r be Real such that
A7:   r < a and
A8:   for r1 be Real st r < r1 & r1 < a & r1 in dom f
        holds |.f.r1-lim_left(f,a).| < g1 by A6,A1,LIMFUNC2:41;

     consider R be Real such that
A9:   max(x,r) < R & R < a & R in dom f by A1,A4,A7,XXREAL_0:29,LIMFUNC2:def 1;
A10: x <= max(x,r) & r <= max(x,r) by XXREAL_0:25; then
A11: r < R by A9,XXREAL_0:2;

     x < R by A9,A10,XXREAL_0:2; then
A12: f.x >= f.R by A2,A3,A9,RFUNCT_2:def 4; then
     lim_left(f,a) > f.R by A5,XXREAL_0:2; then
     |.f.R - lim_left(f,a).| = -(f.R - lim_left(f,a))
       by ABSVALUE:def 1,XREAL_1:49; then
     lim_left(f,a) - f.R < lim_left(f,a) - f.x by A8,A9,A11;
     hence contradiction by A12,XREAL_1:10;
    end;
end;

theorem
for f be PartFunc of REAL,REAL, a be Real st
 f is_right_convergent_in a & f is non-decreasing holds
  for x be Real st x in dom f & a < x holds f.x >= lim_right(f,a)
proof
    let f be PartFunc of REAL,REAL, a be Real;
    assume that
A1:  f is_right_convergent_in a and
A2:  f is non-decreasing;
    let x be Real;
    assume that
A3:  x in dom f and
A4:  a < x;

    hereby assume
A5:  f.x < lim_right(f,a); then
A6:  lim_right(f,a) - f.x > 0 by XREAL_1:50;
     set g1 = lim_right(f,a) - f.x;
     consider r be Real such that
A7:   a < r and
A8:   for r1 be Real st r1 < r & a < r1 & r1 in dom f
        holds |.f.r1-lim_right(f,a).| < g1 by A6,A1,LIMFUNC2:42;

     consider R be Real such that
A9:   min(x,r) > R & R > a & R in dom f by A1,A4,A7,XXREAL_0:21,LIMFUNC2:def 4;
A10: x >= min(x,r) & r >= min(x,r) by XXREAL_0:17; then
A11: r > R by A9,XXREAL_0:2;

     x > R by A9,A10,XXREAL_0:2; then
A12: f.x >= f.R by A2,A3,A9,RFUNCT_2:def 3; then
     lim_right(f,a) > f.R by A5,XXREAL_0:2; then
     |.f.R - lim_right(f,a) .| = -(f.R - lim_right(f,a))
       by ABSVALUE:def 1,XREAL_1:49; then
     lim_right(f,a) - f.R < lim_right(f,a) - f.x by A8,A9,A11;
     hence contradiction by A12,XREAL_1:10;
    end;
end;

theorem Th9:
for f be PartFunc of REAL,REAL, a be Real st
 f is_right_convergent_in a & f is non-increasing holds
  for x be Real st x in dom f & a < x holds f.x <= lim_right(f,a)
proof
    let f be PartFunc of REAL,REAL, a be Real;
    assume that
A1:  f is_right_convergent_in a and
A2:  f is non-increasing;
    let x be Real;
    assume that
A3:  x in dom f and
A4:  a < x;

    hereby assume
A5:  f.x > lim_right(f,a); then
A6:  f.x - lim_right(f,a) > 0 by XREAL_1:50;
     set g1 = f.x - lim_right(f,a);
     consider r be Real such that
A7:   a < r and
A8:   for r1 be Real st r1 < r & a < r1 & r1 in dom f
        holds |.f.r1-lim_right(f,a).| < g1 by A6,A1,LIMFUNC2:42;

     consider R be Real such that
A9:   min(x,r) > R & R > a & R in dom f by A1,A4,A7,XXREAL_0:21,LIMFUNC2:def 4;
A10: x >= min(x,r) & r >= min(x,r) by XXREAL_0:17; then
     r > R by A9,XXREAL_0:2; then
A11: |.f.R - lim_right(f,a).| < g1 by A8,A9;

     x > R by A9,A10,XXREAL_0:2; then
A12: f.x <= f.R by A2,A3,A9,RFUNCT_2:def 4; then
     lim_right(f,a) < f.R by A5,XXREAL_0:2; then
     f.R - lim_right(f,a) > 0 by XREAL_1:50; then
     |.f.R - lim_right(f,a) .| = f.R - lim_right(f,a) by ABSVALUE:def 1;
     hence contradiction by A11,A12,XREAL_1:9;
    end;
end;

theorem Th10:
for f be PartFunc of REAL,REAL, a be Real st
 f is convergent_in-infty & f is non-increasing holds
  for x be Real st x in dom f holds f.x <= lim_in-infty f
proof
    let f be PartFunc of REAL,REAL, a be Real;
    assume that
A1:  f is convergent_in-infty and
A2:  f is non-increasing;

    let x be Real;
    assume
A3:  x in dom f;

    hereby assume
A4:  f.x > lim_in-infty f; then
A5:  f.x - lim_in-infty f > 0 by XREAL_1:50;
     set g1 = f.x - lim_in-infty f;
     consider r be Real such that
A6:   for r1 be Real st r1 < r & r1 in dom f holds
       |. f.r1 - lim_in-infty f .| < g1 by A5,A1,LIMFUNC1:78;

     consider R be Real such that
A7:   R < min(x,r) & R in dom f by A1,LIMFUNC1:45;
A8: x >= min(x,r) & r >= min(x,r) by XXREAL_0:17; then
     R < r by A7,XXREAL_0:2; then
A9: |. f.R - lim_in-infty f .| < g1 by A6,A7;

     x > R by A8,A7,XXREAL_0:2; then
A10:  f.x <= f.R by A2,A3,A7,RFUNCT_2:def 4; then
     lim_in-infty f < f.R by A4,XXREAL_0:2; then
     f.R - lim_in-infty f > 0 by XREAL_1:50; then
     f.R - lim_in-infty f < g1 by A9,ABSVALUE:def 1;
     hence contradiction by A10,XREAL_1:9;
    end;
end;

theorem Th11:
for f be PartFunc of REAL,REAL, a be Real st
 f is convergent_in+infty & f is non-decreasing holds
  for x be Real st x in dom f holds f.x <= lim_in+infty f
proof
    let f be PartFunc of REAL,REAL, a be Real;
    assume that
A1:  f is convergent_in+infty and
A2:  f is non-decreasing;

    let x be Real;
    assume
A3:  x in dom f;

    hereby assume
A4:  f.x > lim_in+infty f; then
A5:  f.x - lim_in+infty f > 0 by XREAL_1:50;
     set g1 = f.x - lim_in+infty f;
     consider r be Real such that
A6:   for r1 be Real st r < r1 & r1 in dom f holds
       |. f.r1 - lim_in+infty f .| < g1 by A5,A1,LIMFUNC1:79;

     consider R be Real such that
A7:   max(x,r) < R & R in dom f by A1,LIMFUNC1:44;
A8: x <= max(x,r) & r <= max(x,r) by XXREAL_0:25; then
     r < R by A7,XXREAL_0:2; then
A9: |. f.R - lim_in+infty f .| < g1 by A6,A7;

     x < R by A8,A7,XXREAL_0:2; then
A10:  f.x <= f.R by A2,A3,A7,RFUNCT_2:def 3; then
     lim_in+infty f < f.R by A4,XXREAL_0:2; then
     f.R - lim_in+infty f > 0 by XREAL_1:50; then
     f.R - lim_in+infty f < g1 by A9,ABSVALUE:def 1;
     hence contradiction by A10,XREAL_1:9;
    end;
end;

theorem Th12:
for a,b be Real, f be PartFunc of REAL,REAL st a <= b & [.a,b.] c= dom f &
 f|[.a,b.] is bounded & f|[.a,b.] is nonnegative holds
  integral(f,a,b) >= 0
proof
    let a,b be Real, f be PartFunc of REAL,REAL;
    assume that
A1:  a <= b and
A2:  [.a,b.] c= dom f and
A3:  f|[.a,b.] is bounded and
A4:  f|[.a,b.] is nonnegative;

    reconsider A = [.a,b.] as non empty closed_interval Subset of REAL
      by A1,XXREAL_1:30,MEASURE5:def 3;
    dom(f|A) = A by A2,RELAT_1:62; then
    reconsider f1 = f|A as Function of A,REAL by FUNCT_2:def 1,RELSET_1:5;
A5: for x be Real st x in A holds f1.x >= 0 by A4,MESFUNC6:51;
A6: A = ['a,b'] by A1,INTEGRA5:def 3;
    f1|A is bounded by A3; then
    integral(f1) >= 0 by A5,INTEGRA2:32; then
    integral(f,A) >= 0 by INTEGRA5:def 2;
    hence integral(f,a,b) >= 0 by A1,A6,INTEGRA5:def 4;
end;

theorem Th13:
for a,b be Real, f be PartFunc of REAL,REAL st a <= b & [.a,b.] c= dom f &
 f|[.a,b.] is bounded & f is_integrable_on ['a,b'] &
 f|[.a,b.] is nonpositive holds integral(f,a,b) <= 0
proof
    let a,b be Real, f be PartFunc of REAL,REAL;
    assume that
A1:  a <= b and
A2:  [.a,b.] c= dom f and
A3:  f|[.a,b.] is bounded and
A4:  f is_integrable_on ['a,b'] and
A5:  f|[.a,b.] is nonpositive;

A6: f||['a,b'] is integrable by A4,INTEGRA5:def 1;
    reconsider A = [.a,b.] as non empty closed_interval Subset of REAL
      by A1,XXREAL_1:30,MEASURE5:def 3;

A7: [.a,b.] c= dom(-f) by A2,VALUED_1:8;
A8: (-f)|[.a,b.] is bounded by A3,RFUNCT_1:82;
A9: A = ['a,b'] by A1,INTEGRA5:def 3;

    -(f|[.a,b.]) is nonnegative by A5,Th5; then
    (-f)|A is nonnegative by RFUNCT_1:46; then
    integral(-f,a,b) >= 0 by A1,A7,A8,Th12; then
A10: integral(-f,A) >= 0 by A1,A9,INTEGRA5:def 4;

    dom(f|A) = A by A2,RELAT_1:62; then
    reconsider f0 = f|A as Function of A,REAL by FUNCT_2:def 1,RELSET_1:5;

    dom((-f)|A) = A by A7,RELAT_1:62; then
    reconsider f1 = (-f)|A as Function of A,REAL by FUNCT_2:def 1,RELSET_1:5;
A11: integral(f1) >= 0 by A10,INTEGRA5:def 2;

    f0 = ((-1)(#)(-f))|A; then
A12: f0 = (-1)(#)f1 by MESFUN6C:41;

A13: (-1)(#)f = -f by VALUED_1:def 6;

A14: f1|A is bounded by A3,RFUNCT_1:82;

    f0|A is bounded by A3; then
    (-1)(#)(f0) is integrable by A6,A9,INTEGRA2:31; then
    f1 is integrable by A13,MESFUN6C:41; then
    integral((-1)(#)f1) = (-1)*integral(f1) by A14,INTEGRA2:31; then
    integral(f,A) <= 0 by A12,A11,INTEGRA5:def 2;
    hence integral(f,a,b) <= 0 by A1,A9,INTEGRA5:def 4;
end;

theorem Th14:
for a,b,c,d be Real, f be PartFunc of REAL,REAL st c <= d &
 [.c,d.] c= [.a,b.] & [.a,b.] c= dom f &
 f|[.a,b.] is bounded & f is_integrable_on ['a,b'] &
 f|[.a,b.] is nonnegative holds
  integral(f,c,d) <= integral(f,a,b)
proof
    let a,b,c,d be Real, f be PartFunc of REAL,REAL;
    assume that
A1:  c <= d and
A2:  [.c,d.] c= [.a,b.] and
A3:  [.a,b.] c= dom f and
A4:  f|[.a,b.] is bounded and
A5:  f is_integrable_on ['a,b'] and
A6:  f|[.a,b.] is nonnegative;

A7:a <= c & d <= b by A1,A2,XXREAL_1:50; then
A8: a <= d by A1,XXREAL_0:2; then
A9: a <= b by A7,XXREAL_0:2;

A10:[.a,b.] = ['a,b'] by A8,A7,XXREAL_0:2,INTEGRA5:def 3; then
    c in ['a,b'] by A1,A2,XXREAL_1:1; then
A11:integral(f,a,b) = integral(f,a,c)+integral(f,c,b)
      by A9,A3,A4,A5,A10,INTEGRA6:17;

A12:c <= b by A1,A7,XXREAL_0:2; then
    [.a,c.] c= [.a,b.] by XXREAL_1:34; then
A13:[.a,c.] c= dom f by A3;

A14:f|[.a,c.] is bounded by A4,A12,XXREAL_1:34,RFUNCT_1:74;
    (f|[.a,b.])|[.a,c.] is nonnegative by A6,MESFUNC6:55; then
    f|[.a,c.] is nonnegative by A12,XXREAL_1:34,RELAT_1:74; then
    0 <= integral(f,a,c) by A7,A13,A14,Th12; then
A15:integral(f,c,b) <= integral(f,a,b) by A11,XREAL_1:31;

A16:f is_integrable_on ['c,b'] & f|['c,b'] is bounded
      by A3,A4,A5,A10,A7,A12,INTEGRA6:18;

A17:[.c,b.] = ['c,b'] by A1,A7,XXREAL_0:2,INTEGRA5:def 3;
    [.c,b.] c= [.a,b.] by A7,XXREAL_1:34; then
A18:['c,b'] c= dom f by A3,A17;
    d in ['c,b'] by A1,A7,A17,XXREAL_1:1; then
A19:integral(f,c,b) = integral(f,c,d)+integral(f,d,b)
      by A12,A16,A18,INTEGRA6:17;

    [.d,b.] c= [.a,b.] by A8,XXREAL_1:34; then
A20:[.d,b.] c= dom f by A3;

A21:f|[.d,b.] is bounded by A4,A8,XXREAL_1:34,RFUNCT_1:74;
    (f|[.a,b.])|[.d,b.] is nonnegative by A6,MESFUNC6:55; then
    f|[.d,b.] is nonnegative by A8,XXREAL_1:34,RELAT_1:74; then
    0 <= integral(f,d,b) by A7,A20,A21,Th12; then
    integral(f,c,d) <= integral(f,c,b) by A19,XREAL_1:31;
    hence integral(f,c,d) <= integral(f,a,b) by A15,XXREAL_0:2;
end;

theorem
for a,b,c,d be Real, f be PartFunc of REAL,REAL st c <= d &
 [.c,d.] c= [.a,b.] & [.a,b.] c= dom f &
 f|[.a,b.] is bounded & f is_integrable_on ['a,b'] &
 f|[.a,b.] is nonpositive holds
  integral(f,c,d) >= integral(f,a,b)
proof
    let a,b,c,d be Real, f be PartFunc of REAL,REAL;
    assume that
A1:  c <= d and
A2:  [.c,d.] c= [.a,b.] and
A3:  [.a,b.] c= dom f and
A4:  f|[.a,b.] is bounded and
A5:  f is_integrable_on ['a,b'] and
A6:  f|[.a,b.] is nonpositive;

A7:a <= c & d <= b by A2,A1,XXREAL_1:50; then
A8:a <= d & c <= b by A1,XXREAL_0:2; then
A9: a <= b by A7,XXREAL_0:2;

A10:[.a,b.] = ['a,b'] & [.a,c.] = ['a,c'] & [.d,b.] = ['d,b']
      by A8,A7,XXREAL_0:2,INTEGRA5:def 3; then
    c in ['a,b'] by A2,A1,XXREAL_1:1; then
A11:integral(f,a,b) = integral(f,a,c)+integral(f,c,b)
      by A9,A3,A4,A5,A10,INTEGRA6:17;

    [.a,c.] c= [.a,b.] & [.d,b.] c= [.a,b.] by A8,XXREAL_1:34; then
A12:[.a,c.] c= dom f & [.d,b.] c= dom f by A3;

A13: f is_integrable_on ['a,c'] & f|['a,c'] is bounded &
    f is_integrable_on ['c,b'] & f|['c,b'] is bounded &
    f is_integrable_on ['d,b'] & f|['d,b'] is bounded
      by A7,A8,A4,A5,A10,A3,INTEGRA6:18;

    (f|[.a,b.])|[.a,c.] is nonpositive by A6,Th4; then
    f|[.a,c.] is nonpositive by A8,XXREAL_1:34,RELAT_1:74; then
    0 >= integral(f,a,c) by A7,A12,A13,A10,Th13; then
A14:integral(f,c,b) >= integral(f,a,b) by A11,XREAL_1:32;

A15:[.c,b.] = ['c,b'] by A1,A7,XXREAL_0:2,INTEGRA5:def 3;
    [.c,b.] c= [.a,b.] by A7,XXREAL_1:34; then
A16:['c,b'] c= dom f by A3,A15;
    d in ['c,b'] by A1,A7,A15,XXREAL_1:1; then
A17:integral(f,c,b) = integral(f,c,d)+integral(f,d,b)
      by A8,A13,A16,INTEGRA6:17;

    (f|[.a,b.])|[.d,b.] is nonpositive by A6,Th4; then
    f|[.d,b.] is nonpositive by A8,XXREAL_1:34,RELAT_1:74; then
    0 >= integral(f,d,b) by A7,A12,A13,A10,Th13; then
    integral(f,c,d) >= integral(f,c,b) by A17,XREAL_1:32;
    hence integral(f,c,d) >= integral(f,a,b) by A14,XXREAL_0:2;
end;

begin :: Fundamental Properties of Measure and Integral

theorem Th16:
for X be non empty set, f be PartFunc of X,REAL, E be set holds
 (R_EAL f)|E = R_EAL f|E
proof
    let X be non empty set, f be PartFunc of X,REAL, E be set;
    dom(R_EAL f|E) = dom(f|E) by MESFUNC5:def 7; then
A1: dom((R_EAL f)|E) = dom(R_EAL f|E) by MESFUNC5:def 7;
    now let x be Element of X;
     assume x in dom((R_EAL f)|E);
     (R_EAL f|E).x = (f|E).x by MESFUNC5:def 7;
     hence ((R_EAL f)|E).x = (R_EAL f|E).x by MESFUNC5:def 7;
    end;
    hence thesis by A1,PARTFUN1:5;
end;

Lm1:
for X be non empty set, S be SigmaField of X, M be sigma_Measure of S,
 f be PartFunc of X,ExtREAL, A be Element of S, E be SetSequence of S
 st f is nonnegative
  & f is A-measurable & A = dom f & E is disjoint_valued & A = Union E
holds
 ex I be nonnegative ExtREAL_sequence st
   (for n be Nat holds I.n = Integral(M,f|(E.n)))
  & I is summable & Integral(M,f) = Sum I
proof
    let X be non empty set, S be SigmaField of X, M be sigma_Measure of S,
        f be PartFunc of X,ExtREAL, A be Element of S, E be SetSequence of S;
    assume that
A1:  f is nonnegative and
A2:  f is A-measurable and
A3:  A = dom f and
A4:  E is disjoint_valued and
A5:  A = Union E;

A6:dom E = NAT by FUNCT_2:def 1;
A7:rng E c= S;

    defpred P[Element of NAT,PartFunc of X,ExtREAL] means
     dom $2 = dom f & (for x be Element of X st x in E.$1 holds $2.x = f.x)
     & (for x be Element of X st not x in E.$1 holds $2.x = 0);

A8: for n be Element of NAT holds E.n c= dom f
    proof
     let n be Element of NAT;
     E.n c= union rng E by A6,ZFMISC_1:74,FUNCT_1:3;
     hence E.n c= dom f by A3,A5,CARD_3:def 4;
    end;

A9: for n be Element of NAT ex g be Element of PFuncs(X,ExtREAL) st P[n,g]
    proof
     let n be Element of NAT;

     defpred Q[object,object] means
      ($1 in E.n implies $2 = f.$1) & (not $1 in E.n implies $2 = 0);

A10:  for x,y1,y2 be object st x in dom f & Q[x,y1] & Q[x,y2] holds y1=y2;
A11:  for x be object st x in dom f ex y be object st Q[x,y]
     proof
      let x be object;
      assume x in dom f;
      x in E.n or not x in E.n;
      hence ex y be object st Q[x,y];
     end;

     consider g be Function such that
A12:  dom g = dom f & for x be object st x in dom f holds Q[x,g.x]
         from FUNCT_1:sch 2(A10,A11);

     now let y be object;
      assume y in rng g; then
      consider x be object such that
A13:   x in dom g & g.x = y by FUNCT_1:def 3;
      per cases;
      suppose x in E.n; then
A14:   g.x = f.x by A12,A13;

       f.x in rng f by A12,A13,FUNCT_1:3;
       hence y in ExtREAL by A13,A14;
      end;
      suppose not x in E.n; then
       g.x = 0 by A12,A13; then
       g.x in REAL by XREAL_0:def 1;
       hence y in ExtREAL by A13,XBOOLE_0:def 3,XXREAL_0:def 4;
      end;
     end; then
     rng g c= ExtREAL; then
     reconsider g as Element of PFuncs(X,ExtREAL) by A12,PARTFUN1:def 3;
     take g;

A15: for x be Element of X st x in E.n holds g.x = f.x
     proof
      let x be Element of X;
A16:   E.n c= dom f by A8;
      assume x in E.n;
      hence g.x = f.x by A12,A16;
     end;

     for x be Element of X st not x in E.n holds g.x = 0
     proof
      let x be Element of X;
      assume A17: not x in E.n;
      x in dom f or not x in dom f;
      hence g.x = 0 by A12,A17,FUNCT_1:def 2;
     end;
     hence P[n,g] by A12,A15;
    end;

    consider F be sequence of PFuncs(X,ExtREAL) such that
A18: for n be Element of NAT holds P[n,F.n] from FUNCT_2:sch 3(A9);

    for n be Nat, x be Element of X holds (F.n).x >= 0
    proof
     let n be Nat, x be Element of X;
A19: n is Element of NAT by ORDINAL1:def 12;

     per cases;
     suppose x in E.n; then
      (F.n).x = f.x by A18,A19;
      hence (F.n).x >= 0 by A1,SUPINF_2:51;
     end;
     suppose not x in E.n;
      hence (F.n).x >= 0 by A18,A19;
     end;
    end; then
A20:for n,m be Nat st n <> m holds
     for x be set st x in dom(F.n) /\ dom(F.m) holds
      (F.n).x <> +infty or (F.m).x <> -infty;

    now let n,m be Nat;
     n is Element of NAT & m is Element of NAT by ORDINAL1:def 12; then
     dom(F.n) = dom f & dom(F.m) = dom f by A18;
     hence dom(F.n) = dom(F.m);
    end; then
A21:F is with_the_same_dom by MESFUNC8:def 2;

A22:for n be Nat holds F.n is nonnegative & F.n is A-measurable
    proof
     let n be Nat;
A23:  n is Element of NAT by ORDINAL1:def 12; then
     reconsider En = E.n as Element of S by A6,A7,FUNCT_1:3;

     now let x be object;
      assume x in dom(F.n); then
      (x in E.n implies (F.n).x = f.x) &
      (not x in E.n implies (F.n).x = 0) by A23,A18;
      hence (F.n).x >= 0 by A1,SUPINF_2:51;
     end;
     hence F.n is nonnegative by SUPINF_2:52;

A24:  E.n c= A by A3,A8,A23;

     for r be Real holds A /\ less_dom(F.n,r) in S
     proof
      let r be Real;
      per cases;
      suppose A25: r <= 0;
       for x be object holds not x in A /\ less_dom(F.n,r)
       proof
        let x be object;
        hereby assume
A26:     x in A /\ less_dom(F.n,r); then
A27:      x in A & x in less_dom(F.n,r) by XBOOLE_0:def 4;

         (x in E.n implies (F.n).x = f.x) &
         (not x in E.n implies (F.n).x = 0) by A23,A18,A26; then
         (F.n).x >= r by A25,A1,SUPINF_2:51;
         hence contradiction by A27,MESFUNC1:def 11;
        end;
       end; then
       A /\ less_dom(F.n,r) = {} by XBOOLE_0:def 1;
       hence thesis by MEASURE1:7;
      end;
      suppose A28: r > 0;
       now let x be object;
        assume x in A /\ less_dom(F.n,r); then
A29:     x in A & x in less_dom(F.n,r) by XBOOLE_0:def 4; then
A30:     x in dom(F.n) & (F.n).x < r by MESFUNC1:def 11;

        thus x in (A \ En) \/ (En /\ less_dom(f,r))
        proof
         per cases;
         suppose not x in En; then
          x in A \ En by A29,XBOOLE_0:def 5;
          hence thesis by XBOOLE_0:def 3;
         end;
         suppose A31: x in En; then
          (F.n).x = f.x by A23,A18; then
          x in less_dom(f,r) by A3,A29,A30,MESFUNC1:def 11; then
          x in En /\ less_dom(f,r) by A31,XBOOLE_0:def 4;
          hence thesis by XBOOLE_0:def 3;
         end;
        end;
       end; then
A32:    A /\ less_dom(F.n,r) c= (A \ En) \/ (En /\ less_dom(f,r));

       now let x be object;
        assume A33: x in (A \ En) \/ (En /\ less_dom(f,r));
        per cases by A33,XBOOLE_0:def 3;
        suppose x in A \ En; then
A34:     x in A & not x in En by XBOOLE_0:def 5; then
A35:     x in dom(F.n) by A23,A18,A3;
         (F.n).x = 0 by A23,A18,A34; then
         x in less_dom(F.n,r) by A28,A35,MESFUNC1:def 11;
         hence x in A /\ less_dom(F.n,r) by A34,XBOOLE_0:def 4;
        end;
        suppose x in En /\ less_dom(f,r); then
A36:     x in En & x in less_dom(f,r) by XBOOLE_0:def 4; then
         f.x < r by MESFUNC1:def 11; then
A37:     (F.n).x < r by A36,A23,A18;
         x in A by A36,A24; then
         x in dom(F.n) by A3,A23,A18; then
         x in less_dom(F.n,r) by A37,MESFUNC1:def 11;
         hence x in A /\ less_dom(F.n,r) by A36,A24,XBOOLE_0:def 4;
        end;
       end; then
       (A \ En) \/ (En /\ less_dom(f,r)) c= A /\ less_dom(F.n,r); then
A38:   A /\ less_dom(F.n,r) = (A \ En) \/ (En /\ less_dom(f,r))
         by A32,XBOOLE_0:def 10;

       f is En-measurable by A2,A3,A8,A23,MESFUNC1:30; then
       A \ En in S & En /\ less_dom(f,r) in S by MESFUNC1:def 16;
       hence thesis by A38,FINSUB_1:def 1;
      end;
     end;
     hence F.n is A-measurable by MESFUNC1:def 16;
    end;

A39: for n be Nat, x be Element of X st x in E.n holds
     for m be Nat st m < n or m > n holds (F#x).m = 0
    proof
     let n be Nat, x be Element of X;
     assume A40: x in E.n;
     hereby let m be Nat;
A41:   m is Element of NAT by ORDINAL1:def 12;
      assume m < n or m > n; then
A42:   not x in E.m by A40,A4,PROB_2:def 2,XBOOLE_0:3;
      (F#x).m = (F.m).x by MESFUNC5:def 13;
      hence (F#x).m = 0 by A41,A18,A42;
     end;
    end;

A43: for n be Nat, x be Element of X st x in E.n holds
     for m be Nat st m < n holds (Partial_Sums(F#x)).m = 0
    proof
     let n be Nat, x be Element of X;
     assume A44: x in E.n;
     defpred P[Nat] means $1<n implies (Partial_Sums(F#x)).$1 = 0;

     now assume 0 < n; then
      (F#x).0 = 0 by A44,A39;
      hence (Partial_Sums(F#x)).0 = 0 by MESFUNC9:def 1;
     end; then
A45:  P[0];
A46:  for k be Nat st P[k] holds P[k+1]
     proof
      let k be Nat;
      assume A47: P[k];
      assume A48: k+1 < n;
A49:  k <= k+1 by NAT_1:11;
A50:   (F#x).(k+1) = 0 by A48,A39,A44;
      (Partial_Sums(F#x)).(k+1) = (Partial_Sums(F#x)).k + (F#x).(k+1)
        by MESFUNC9:def 1;
      hence (Partial_Sums(F#x)).(k+1) = 0 by A49,A50,A47,A48,XXREAL_0:2;
     end;
     for k be Nat holds P[k] from NAT_1:sch 2(A45,A46);
     hence thesis;
    end;

A51: for n be Nat, x be Element of X st x in E.n holds
     for m be Nat st m >= n holds (Partial_Sums(F#x)).m = f.x
    proof
     let n be Nat, x be Element of X;
A52: n is Element of NAT by ORDINAL1:def 12;
     assume A53: x in E.n;
     defpred P[Nat] means $1>=n implies (Partial_Sums(F#x)).$1 = f.x;
     now assume 0>=n; then
A54:  n=0;
      (Partial_Sums(F#x)).0 = (F#x).0 by MESFUNC9:def 1; then
      (Partial_Sums(F#x)).0 = (F.0).x by MESFUNC5:def 13;
      hence (Partial_Sums(F#x)).0 = f.x by A18,A54,A53;
     end; then
A55: P[0];
A56: for k be Nat st P[k] holds P[k+1]
     proof
      let k be Nat;
      assume A57: P[k];
      assume A58: k+1>=n;
A59:   (Partial_Sums(F#x)).(k+1)
        = (Partial_Sums(F#x)).k + (F#x).(k+1) by MESFUNC9:def 1;
      per cases by A58,XXREAL_0:1;
      suppose A60: k+1=n; then
       k < n by NAT_1:13; then
A61:   (Partial_Sums(F#x)).k = 0 by A43,A53;
       (F#x).(k+1) = (F.n).x by A60,MESFUNC5:def 13; then
       (F#x).(k+1) = f.x by A18,A53,A52;
       hence (Partial_Sums(F#x)).(k+1) = f.x by A61,A59,XXREAL_3:4;
      end;
      suppose A62: k+1>n; then
       (F#x).(k+1) = 0 by A39,A53;
       hence (Partial_Sums(F#x)).(k+1) = f.x by A62,A59,A57
,NAT_1:13,XXREAL_3:4;
      end;
     end;
     for k be Nat holds P[k] from NAT_1:sch 2(A55,A56);
     hence thesis;
    end;

A63:for x be Element of X st x in A & f.x in REAL holds
     (for p be Real st 0<p ex n be Nat st for m be Nat st n<=m holds
       |. Partial_Sums(F#x).m - f.x .| < p)
    proof
     let x be Element of X;
     assume that
A64: x in A and
A65: f.x in REAL;
     reconsider g = f.x as Real by A65;
     x in union rng E by A5,A64,CARD_3:def 4; then
     consider En be set such that
A66:   x in En & En in rng E by TARSKI:def 4;
     consider n be object such that
A67:   n in dom E & En = E.n by A66,FUNCT_1:def 3;
     reconsider n as Nat by A67;
     hereby let p be Real;
      assume A68: 0 < p;
      take n;
      hereby let m be Nat;
       assume n <= m; then
       (Partial_Sums(F#x)).m - g = f.x - g by A66,A67,A51; then
       (Partial_Sums(F#x)).m - g = f.x + (-f.x) by XXREAL_3:def 4; then
       (Partial_Sums(F#x)).m - g = 0 by XXREAL_3:7;
       hence |. (Partial_Sums(F#x)).m - f.x .| < p by A68,EXTREAL1:def 1;
      end;
     end;
    end;

A69:for x be Element of X st x in A & f.x in REAL holds
     Partial_Sums(F#x) is convergent_to_finite_number
    proof
     let x be Element of X;
     assume that
A70:   x in A and
A71:  f.x in REAL;
     reconsider g = f.x as Real by A71;

     for p be Real st 0<p ex n be Nat st for m be Nat st n<=m holds
       |. Partial_Sums(F#x).m - g qua ExtReal .| < p by A70,A71,A63;
     hence Partial_Sums(F#x) is convergent_to_finite_number by MESFUNC5:def 8;
    end;

A72:for x be Element of X st x in A & f.x =+infty holds
     Partial_Sums(F#x) is convergent_to_+infty
    proof
     let x be Element of X;
     assume that
A73:   x in A and
A74:  f.x =+infty;
     x in union rng E by A5,A73,CARD_3:def 4; then
     consider En be set such that
A75:   x in En & En in rng E by TARSKI:def 4;
     consider n be object such that
A76:   n in dom E & En = E.n by A75,FUNCT_1:def 3;
     reconsider n as Nat by A76;
     now let g be Real;
      assume 0 < g;
      take n;
      hereby let m be Nat;
       assume n<=m; then
       (Partial_Sums(F#x)).m = +infty by A51,A75,A76,A74;
       hence g <= (Partial_Sums(F#x)).m by XXREAL_0:3;
      end;
     end;
     hence Partial_Sums(F#x) is convergent_to_+infty by MESFUNC5:def 9;
    end;

A77:for x be Element of X st x in A holds F#x is summable
    proof
     let x be Element of X;
     assume A78: x in A;
     f.x >= 0 by A1,SUPINF_2:51; then
     f.x in REAL or f.x = +infty by XXREAL_0:14; then
     Partial_Sums(F#x) is convergent_to_finite_number
  or Partial_Sums(F#x) is convergent_to_+infty by A78,A69,A72;
     hence F#x is summable by MESFUNC9:def 2;
    end;

    A c= dom(F.0) by A18,A3; then
    consider I be ExtREAL_sequence such that
A79: for n be Nat holds I.n = Integral(M,(F.n)|A) and
A80: I is summable and
A81: Integral(M,(lim(Partial_Sums F))|A) = Sum I
       by A20,A21,A22,A77,MESFUNC9:def 5,51;

A82:for n be Nat holds Integral(M,(F.n)|A) = Integral(M,f|(E.n))
    proof
     let n be Nat;
A83: n is Element of NAT by ORDINAL1:def 12; then
A84:  dom(F.n) = A by A3,A18;

     reconsider En = E.n as Element of S by A83,A6,A7,FUNCT_1:3;
     set E1 = A\En;

A85:  F.n is nonnegative & F.n is A-measurable by A22; then
A86:  F.n is E1-measurable by MESFUNC1:30,XBOOLE_1:36;

     E1 \/ En = A \/ En by XBOOLE_1:39; then
A87:  E1 \/ En = A by A8,A83,A3,XBOOLE_1:12;

A88: dom((F.n)|E1) = dom(F.n) /\ E1 by RELAT_1:61; then
A89: dom((F.n)|E1) = (A /\ A) \ En by A84,XBOOLE_1:49;

A90: dom(F.n) /\ E1 = (A /\ A) \ En by A84,XBOOLE_1:49;

     for x be Element of X st x in dom((F.n)|E1) holds ((F.n)|E1).x = 0
     proof
      let x be Element of X;
      assume A91: x in dom((F.n)|E1); then
A92:  not x in En by A89,XBOOLE_0:def 5;
      ((F.n)|E1).x = (F.n).x by A91,FUNCT_1:47;
      hence ((F.n)|E1).x = 0 by A18,A83,A92;
     end; then
A93: integral+(M,(F.n)|E1) = 0 by A88,A90,A86,MESFUNC5:42,87;

A94:  dom(f|En) = dom f /\ En by RELAT_1:61;
A95:  dom((F.n)|En) = En by A8,A83,A84,A3,RELAT_1:62;
A96: dom(f|En) = En by A8,A83,RELAT_1:62;

     now let x be Element of X;
      assume A97: x in dom((F.n)|En); then
      ((F.n)|En).x = (F.n).x by A95,FUNCT_1:49; then
      ((F.n)|En).x = f.x by A83,A18,A97,A95;
      hence ((F.n)|En).x = (f|En).x by A97,A95,FUNCT_1:49;
     end; then
A98:  (F.n)|En = f|En by A95,A96,PARTFUN1:5;

     f is En-measurable by A2,A8,A83,A3,MESFUNC1:30; then
A99:  f|En is En-measurable by A94,A96,MESFUNC5:42;

     integral+(M,(F.n)|(E1\/En)) = integral+(M,(F.n)|E1)
      + integral+(M,(F.n)|En) by A84,A85,MESFUNC5:81,XBOOLE_1:79; then
     integral+(M,(F.n)|A) = integral+(M,(F.n)|En) by A87,A93,XXREAL_3:4; then
     Integral(M,(F.n)|A) = integral+(M,f|En) by A98,A84,A85,MESFUNC5:88;
     hence Integral(M,(F.n)|A) = Integral(M,f|(E.n))
       by A96,A99,A1,MESFUNC5:15,88;
    end;

    for n be object st n in dom I holds 0 <= I.n
    proof
     let n be object;
     assume A100: n in dom I; then
A101:  E.n is Element of S by A6,A7,FUNCT_1:3;
     I.n = Integral(M,(F.n)|A) by A79,A100; then
     I.n = Integral(M,f|(E.n)) by A82,A100;
     hence I.n >= 0 by A1,A2,A3,A101,MESFUNC5:92;
    end; then

    reconsider I as nonnegative ExtREAL_sequence by SUPINF_2:52;

    take I;

    thus for n be Nat holds I.n = Integral(M,f|(E.n))
    proof
     let n be Nat;
     I.n = Integral(M,(F.n)|A) by A79;
     hence I.n = Integral(M,f|(E.n)) by A82;
    end;

    thus I is summable by A80;

    for n,m be Nat st n <> m holds
     for x be set holds (not x in dom(F.n) /\ dom(F.m)) or
      (F.n).x <> +infty or (F.m).x <> -infty
    proof
     let n,m be Nat;
     assume A102: n <> m;
A103:  n is Element of NAT & m is Element of NAT by ORDINAL1:def 12;
     hereby let x be set;
      x in E.n or x in E.m implies
       not x in E.m or not x in E.n by A102,A4,PROB_2:def 2,XBOOLE_0:3;
      hence (not x in dom(F.n) /\ dom(F.m)) or
       (F.n).x <> +infty or (F.m).x <> -infty by A18,A103;
     end;
    end; then
A104: F is additive by MESFUNC9:def 5;

    for n,m be Nat holds dom(F.n) = dom(F.m)
    proof
     let n,m be Nat;
     n is Element of NAT & m is Element of NAT by ORDINAL1:def 12; then
     dom(F.n) = dom f & dom(F.m) = dom f by A18;
     hence thesis;
    end; then
A105: F is with_the_same_dom by MESFUNC8:def 2;

A106: dom f = dom(F.0) by A18;

    dom(lim(Partial_Sums F)) = dom((Partial_Sums F).0) by MESFUNC8:def 9; then
A107: dom(lim(Partial_Sums F)) = dom(F.0) by MESFUNC9:def 4;
    for x be Element of X st x in dom f holds
     f.x = ((lim(Partial_Sums F))|A).x
    proof
     let x be Element of X;
     assume A108: x in dom f;

A109: f.x >= 0 by A1,SUPINF_2:51;
     now per cases by A109,XXREAL_0:14;
      suppose A110: f.x in REAL; then
       reconsider g = f.x as Real;
A111:   for p be Real st 0<p ex n be Nat st for m be Nat st n<=m holds
         |. Partial_Sums(F#x).m - g .| < p by A108,A3,A63,A110;
       Partial_Sums(F#x) is convergent_to_finite_number by A108,A3,A69,A110;
       hence f.x = lim(Partial_Sums(F#x)) by A111,MESFUNC5:def 12;
      end;
      suppose A112: f.x = +infty; then
       Partial_Sums(F#x) is convergent_to_+infty by A108,A3,A72;
       hence f.x = lim(Partial_Sums(F#x)) by A112,MESFUNC5:def 12;
      end;
     end; then
     f.x = Sum(F#x) by MESFUNC9:def 3; then
     f.x = lim((Partial_Sums F)#x) by A3,A77,A104,A105,A106,A108,MESFUNC9:34;
     hence thesis by A3,A108,A106,A107,MESFUNC8:def 9;
    end;
    hence Integral(M,f) = Sum I by A3,A81,A106,A107,PARTFUN1:5;
end;

theorem Th17:
  for X be non empty set, S be SigmaField of X, M be sigma_Measure
of S, f be PartFunc of X,ExtREAL, A be Element of S, E be SetSequence of S
 st f is A-measurable & A = dom f & E is disjoint_valued & A = Union E
  & (integral+(M,max+ f) < +infty or integral+(M,max- f) < +infty)
holds
 ex I be ExtREAL_sequence st (for n be Nat holds I.n = Integral(M,f|(E.n)))
  & I is summable & Integral(M,f) = Sum I
proof
    let X be non empty set, S be SigmaField of X, M be sigma_Measure of S,
    f be PartFunc of X,ExtREAL, A be Element of S, E be SetSequence of S;
    assume that
A1:  f is A-measurable and
A2:  A = dom f and
A3:  E is disjoint_valued and
A4:  A = Union E and
A5:  integral+(M,max+ f) < +infty or integral+(M,max- f) < +infty;

A6: max+ f is nonnegative & max-f is nonnegative by MESFUN11:5;
A7: max+ f is A-measurable & max- f is A-measurable by A1,A2,MESFUNC2:25,26;
A8: A = dom(max+ f) & A = dom(max- f) by A2,MESFUNC2:def 2,def 3;

    consider I1 be nonnegative ExtREAL_sequence such that
A9:  for n be Nat holds I1.n = Integral(M,(max+ f)|(E.n)) and
A10: I1 is summable & Integral(M,max+f) = Sum I1 by A7,A8,A3,A4,Lm1,MESFUN11:5;

    consider I2 be nonnegative ExtREAL_sequence such that
A11: for n be Nat holds I2.n = Integral(M,(max- f)|(E.n)) and
A12: I2 is summable & Integral(M,max-f) = Sum I2 by A7,A8,A3,A4,Lm1,MESFUN11:5;

A13: for n be Nat holds E.n is Element of S & E.n c= dom f
    proof
     let n be Nat;
     dom E = NAT by FUNCT_2:def 1; then
A14:  E.n in rng E by FUNCT_1:3,ORDINAL1:def 12;
     hence E.n is Element of S;
     E.n c= union rng E by A14,ZFMISC_1:74;
     hence E.n c= dom f by A2,A4,CARD_3:def 4;
    end;

A15: for n be Nat holds I1.n = integral+(M,max+f|(E.n))
    proof
     let n be Nat;
     reconsider En = E.n as Element of S by A13;
A16:  max+f is En-measurable by A7,A2,A13,MESFUNC1:30;
A17:  dom((max+f)|(E.n)) = En by A2,A8,A13,RELAT_1:62; then
     dom(max+f) /\ En = En by RELAT_1:61; then
A18:  (max+f)|(E.n) is En-measurable by A16,MESFUNC5:42;
     I1.n = Integral(M,(max+f)|(E.n)) by A9;
     hence thesis by A17,A18,A6,MESFUNC5:15,88;
    end;

A19: for n be Nat holds I2.n = integral+(M,max-f|(E.n))
    proof
     let n be Nat;
     reconsider En = E.n as Element of S by A13;
A20:  max-f is En-measurable by A7,A2,A13,MESFUNC1:30;
A21:  dom((max-f)|(E.n)) = En by A2,A8,A13,RELAT_1:62; then
     dom(max-f) /\ En = En by RELAT_1:61; then
A22:  (max-f)|(E.n) is En-measurable by A20,MESFUNC5:42;
     I2.n = Integral(M,(max-f)|(E.n)) by A11;
     hence thesis by A21,A22,A6,MESFUNC5:15,88;
    end;

    per cases by A5;
    suppose integral+(M,max+f) < +infty; then
A23: Integral(M,max+f) < +infty by A7,A8,MESFUNC5:88,MESFUN11:5; then
A24:  lim Partial_Sums I1 < +infty by A10,MESFUNC9:def 3;

     for n be set st n in dom I1 holds I1.n < +infty
     proof
      let n be set;
      assume A25: n in dom I1; then
      E.n is Element of S & E.n c= dom(max+f) by A2,A8,A13; then
      Integral(M,(max+f)|(E.n)) <= Integral(M,(max+f)|A)
        by A8,A7,MESFUNC5:93,MESFUN11:5; then
      Integral(M,(max+f)|(E.n)) < +infty by A8,A23,XXREAL_0:2;
      hence I1.n < +infty by A9,A25;
     end; then
     reconsider I1 as without+infty ExtREAL_sequence by MESFUNC5:11;
     take I = I1-I2;
     thus for n be Nat holds I.n = Integral(M,f|(E.n))
     proof
      let n be Nat;
A26:  n is Element of NAT by ORDINAL1:def 12;
      Integral(M,f|(E.n))
       = integral+(M,max+(f|(E.n))) - integral+(M,max-(f|(E.n)))
         by MESFUNC5:def 16
      .= integral+(M,max+f|(E.n)) - integral+(M,max-(f|(E.n)))
         by MESFUNC5:28
      .= integral+(M,max+f|(E.n)) - integral+(M,max-f|(E.n))
         by MESFUNC5:28
      .= I1.n - integral+(M,max-f|(E.n)) by A15
      .= I1.n - I2.n by A19;
      hence thesis by A26,DBLSEQ_3:7;
     end;

     Partial_Sums I1 is nonnegative & Partial_Sums I1 is non-decreasing
       by MESFUNC9:16; then
A27:  Partial_Sums I1 is convergent_to_+infty or
     Partial_Sums I1 is convergent_to_finite_number by DBLSEQ_3:62; then
     consider LI1 be Real such that
A28:  lim Partial_Sums I1 = LI1 and
      (for p be Real st 0<p ex n be Nat st for m be Nat st n<=m holds
       |. (Partial_Sums I1).m - lim Partial_Sums I1 .| < p) by A24,MESFUNC9:7;

A29: Partial_Sums I2 is nonnegative & Partial_Sums I2 is non-decreasing
       by MESFUNC9:16; then
A30:  Partial_Sums I2 is convergent_to_+infty or
     Partial_Sums I2 is convergent_to_finite_number by DBLSEQ_3:62;
A31:  Partial_Sums I = Partial_Sums I1 - Partial_Sums I2 by Th3;
     Partial_Sums I is convergent by A30,A31,A24,A27
,MESFUNC5:def 12,DBLSEQ_3:25;
     hence I is summable by MESFUNC9:def 2;

A32:  Integral(M,f) = integral+(M,max+f)-integral+(M,max-f) by MESFUNC5:def 16
      .= Integral(M,max+f)-integral+(M,max-f) by A7,A8,MESFUNC5:88,MESFUN11:5
      .= Integral(M,max+f)-Integral(M,max-f) by A7,A8,MESFUNC5:88,MESFUN11:5
      .= lim Partial_Sums I1 - Integral(M,max-f) by A10,MESFUNC9:def 3
      .= lim Partial_Sums I1 - lim Partial_Sums I2 by A12,MESFUNC9:def 3;

     thus Integral(M,f) = Sum I
     proof
      per cases by A29,DBLSEQ_3:62;
      suppose A33: Partial_Sums I2 is convergent_to_+infty; then
       lim Partial_Sums I2 = +infty by MESFUNC5:def 12; then
A34:    Integral(M,f) = -infty by A28,A32,XXREAL_3:13;

       lim (Partial_Sums I1 - Partial_Sums I2) = -infty
         by A33,A24,A27,MESFUNC5:def 12,DBLSEQ_3:25; then
       lim Partial_Sums I = -infty by Th3;
       hence Integral(M,f) = Sum I by A34,MESFUNC9:def 3;
      end;
      suppose A35: Partial_Sums I2 is convergent_to_finite_number;
       lim (Partial_Sums I)
        = lim (Partial_Sums I1 - Partial_Sums I2) by Th3
       .= lim Partial_Sums I1 - lim Partial_Sums I2
         by A35,A24,A27,MESFUNC5:def 12,DBLSEQ_3:25;
       hence Integral(M,f) = Sum I by A32,MESFUNC9:def 3;
      end;
     end;
    end;
    suppose integral+(M,max-f) < +infty; then
A36: Integral(M,max-f) < +infty by A7,A8,MESFUNC5:88,MESFUN11:5; then
A37:  lim Partial_Sums I2 < +infty by A12,MESFUNC9:def 3;

     for n be set st n in dom I2 holds I2.n < +infty
     proof
      let n be set;
      assume A38: n in dom I2; then
      E.n is Element of S & E.n c= dom(max-f) by A2,A8,A13; then
      Integral(M,(max-f)|(E.n)) <= Integral(M,(max-f)|A)
        by A8,A7,MESFUNC5:93,MESFUN11:5; then
      Integral(M,(max-f)|(E.n)) < +infty by A8,A36,XXREAL_0:2;
      hence I2.n < +infty by A11,A38;
     end; then
     reconsider I2 as without+infty ExtREAL_sequence by MESFUNC5:11;

     take I = I1-I2;
     thus for n be Nat holds I.n = Integral(M,f|(E.n))
     proof
      let n be Nat;
A39:  n is Element of NAT by ORDINAL1:def 12;
      Integral(M,f|(E.n))
       = integral+(M,max+(f|(E.n))) - integral+(M,max-(f|(E.n)))
         by MESFUNC5:def 16
      .= integral+(M,max+f|(E.n)) - integral+(M,max-(f|(E.n)))
         by MESFUNC5:28
      .= integral+(M,max+f|(E.n)) - integral+(M,max-f|(E.n))
         by MESFUNC5:28
      .= I1.n - integral+(M,max-f|(E.n)) by A15
      .= I1.n - I2.n by A19;
      hence thesis by A39,DBLSEQ_3:7;
     end;

     Partial_Sums I2 is nonnegative & Partial_Sums I2 is non-decreasing
       by MESFUNC9:16; then
A40:  Partial_Sums I2 is convergent_to_+infty or
     Partial_Sums I2 is convergent_to_finite_number by DBLSEQ_3:62; then
     consider LI2 be Real such that
A41:  lim Partial_Sums I2 = LI2 and
      (for p be Real st 0<p ex n be Nat st for m be Nat st n<=m holds
       |. (Partial_Sums I2).m - lim Partial_Sums I2 .| < p) by A37,MESFUNC9:7;

A42: Partial_Sums I1 is nonnegative & Partial_Sums I1 is non-decreasing
       by MESFUNC9:16; then
A43:  Partial_Sums I1 is convergent_to_+infty or
     Partial_Sums I1 is convergent_to_finite_number by DBLSEQ_3:62;
     Partial_Sums I = Partial_Sums I1 - Partial_Sums I2 by Th3; then
     Partial_Sums I is convergent by A43,A40,A37,MESFUNC5:def 12,DBLSEQ_3:25;
     hence I is summable by MESFUNC9:def 2;

A44:  Integral(M,f) = integral+(M,max+f)-integral+(M,max-f) by MESFUNC5:def 16
      .= Integral(M,max+f)-integral+(M,max-f) by A7,A8,MESFUNC5:88,MESFUN11:5
      .= Integral(M,max+f)-Integral(M,max-f) by A7,A8,MESFUNC5:88,MESFUN11:5
      .= lim Partial_Sums I1 - Integral(M,max-f) by A10,MESFUNC9:def 3
      .= lim Partial_Sums I1 - lim Partial_Sums I2 by A12,MESFUNC9:def 3;

     thus Integral(M,f) = Sum I
     proof
      per cases by A42,DBLSEQ_3:62;
      suppose A45: Partial_Sums I1 is convergent_to_+infty; then
       lim Partial_Sums I1 = +infty by MESFUNC5:def 12; then
A46:    Integral(M,f) = +infty by A41,A44,XXREAL_3:13;

       lim (Partial_Sums I1 - Partial_Sums I2) = +infty
         by A45,A40,A37,MESFUNC5:def 12,DBLSEQ_3:25; then
       lim Partial_Sums I = +infty by Th3;
       hence Integral(M,f) = Sum I by A46,MESFUNC9:def 3;
      end;
      suppose A47: Partial_Sums I1 is convergent_to_finite_number;
       lim (Partial_Sums I)
        = lim (Partial_Sums I1 - Partial_Sums I2) by Th3
       .= lim Partial_Sums I1 - lim Partial_Sums I2
         by A47,A40,A37,MESFUNC5:def 12,DBLSEQ_3:25;
       hence Integral(M,f) = Sum I by A44,MESFUNC9:def 3;
      end;
     end;
    end;
end;

Lm2:
for X be non empty set, S be SigmaField of X, M be sigma_Measure of S,
 f be PartFunc of X,ExtREAL, A,B be Element of S
 st dom f = A \/ B & f is (A\/B)-measurable & A misses B
  & (integral+(M,max+ f) < +infty or integral+(M,max- f) < +infty)
 holds Integral(M,f) = Integral(M,f|A)+Integral(M,f|B)
proof
    let X be non empty set, S be SigmaField of X, M be sigma_Measure of S,
     f be PartFunc of X,ExtREAL, A,B be Element of S;
    assume that
A1:  dom f = A \/ B and
A2: f is (A\/B)-measurable and
A3:  A misses B and
A4:  integral+(M,max+ f) < +infty or integral+(M,max- f) < +infty;

A5: Integral(M,f) = integral+(M,max+f) - integral+(M,max-f)
      by MESFUNC5:def 16;

A6: max+f is (A\/B)-measurable & max-f is (A\/B)-measurable
      by A1,A2,MESFUNC2:25,26;

A7: A\/B = dom(max+ f) & A\/B = dom(max- f) by A1,MESFUNC2:def 2,def 3; then
A8:integral+(M,max+f) >= 0 & integral+(M,max-f) >= 0
      by A6,MESFUNC5:79,MESFUN11:5;

A9: max+f|A is nonnegative & max+f|B is nonnegative
  & max-f|A is nonnegative & max-f|B is nonnegative by MESFUNC5:15,MESFUN11:5;

A10: dom(max+f|A) = dom(max+f) /\ A & dom(max+f|B) = dom(max+f) /\ B &
    dom(max-f|A) = dom(max-f) /\ A & dom(max-f|B) = dom(max-f) /\ B
      by RELAT_1:61;

A11: max+f is A-measurable & max+f is B-measurable
  & max-f is A-measurable & max-f is B-measurable by A6,XBOOLE_1:7,MESFUNC1:30;

    A = (A \/ B) /\ A & B = (A \/ B) /\ B by XBOOLE_1:21; then
A12: integral+(M,max+f|A) >= 0 & integral+(M,max+f|B) >= 0
  & integral+(M,max-f|A) >= 0 & integral+(M,max-f|B) >= 0
      by A9,A10,A7,A11,MESFUNC5:42,79;

A13: integral+(M,max+f|(A\/B)) = integral+(M,max+f|A) + integral+(M,max+f|B)
  & integral+(M,max-f|(A\/B)) = integral+(M,max-f|A) + integral+(M,max-f|B)
      by A3,A6,A7,MESFUNC5:81,MESFUN11:5;

A14: Integral(M,f|A) = integral+(M,max+(f|A)) - integral+(M,max-(f|A))
       by MESFUNC5:def 16
     .= integral+(M,max+f|A) - integral+(M,max-(f|A)) by MESFUNC5:28
     .= integral+(M,max+f|A) - integral+(M,max-f|A) by MESFUNC5:28;

A15: Integral(M,f|B) = integral+(M,max+(f|B)) - integral+(M,max-(f|B))
       by MESFUNC5:def 16
     .= integral+(M,max+f|B) - integral+(M,max-(f|B)) by MESFUNC5:28
     .= integral+(M,max+f|B) - integral+(M,max-f|B) by MESFUNC5:28;

A16: integral+(M,max+f) < +infty implies
      integral+(M,max+f|A) in REAL & integral+(M,max+f|B) in REAL
    proof
     assume integral+(M,max+ f) < +infty; then
A17:  integral+(M,max+f) in REAL by A8,XXREAL_0:14;

     now assume A18: integral+(M,max+f|A) = +infty;
      integral+(M,max+f|B) in REAL or integral+(M,max+f|B) = +infty
        by A12,XXREAL_0:14;
      hence contradiction by A13,A17,A18,A7;
     end;
     hence integral+(M,max+f|A) in REAL by A12,XXREAL_0:14;
     now assume A19: integral+(M,max+f|B) = +infty;
      integral+(M,max+f|A) in REAL or integral+(M,max+f|A) = +infty
        by A12,XXREAL_0:14;
      hence contradiction by A13,A17,A19,A7;
     end;
     hence integral+(M,max+f|B) in REAL by A12,XXREAL_0:14;
    end;

A20: integral+(M,max-f) < +infty implies
      integral+(M,max-f|A) in REAL & integral+(M,max-f|B) in REAL
    proof
     assume integral+(M,max-f) < +infty; then
A21:  integral+(M,max-f) in REAL by A8,XXREAL_0:14;

     now assume A22: integral+(M,max-f|A) = +infty;
      integral+(M,max-f|B) in REAL or integral+(M,max-f|B) = +infty
        by A12,XXREAL_0:14;
      hence contradiction by A13,A21,A22,A7;
     end;
     hence integral+(M,max-f|A) in REAL by A12,XXREAL_0:14;

     now assume A23: integral+(M,max-f|B) = +infty;
      integral+(M,max-f|A) in REAL or integral+(M,max-f|A) = +infty
        by A12,XXREAL_0:14;
      hence contradiction by A13,A21,A23,A7;
     end;
     hence integral+(M,max-f|B) in REAL by A12,XXREAL_0:14;
    end;

    per cases by A4;
    suppose A24: integral+(M,max+ f) < +infty; then
     integral+(M,max+f) in REAL by A8,XXREAL_0:14; then
     reconsider IP = integral+(M,max+f) as Real;
     reconsider IPA = integral+(M,max+f|A), IPB = integral+(M,max+f|B)
       as Real by A24,A16;

     per cases by A8,XXREAL_0:14;
     suppose A25: integral+(M,max-f) = +infty; then
A26:  Integral(M,f) = -infty by A24,A5,XXREAL_3:13;

      integral+(M,max-f|A) = +infty or integral+(M,max-f|B) = +infty
        by A13,A7,A25,XXREAL_3:16; then
A27:  Integral(M,f|A) = -infty or Integral(M,f|B) = -infty
        by A14,A15,A24,A16,XXREAL_3:13;

      Integral(M,f|A) <> +infty & Integral(M,f|B) <> +infty
        by A24,A16,A12,A14,A15,XXREAL_3:18;
      hence Integral(M,f) = Integral(M,f|A)+Integral(M,f|B)
        by A26,A27,XXREAL_3:def 2;
     end;

     suppose A28: integral+(M,max-f) in REAL; then
      reconsider IM = integral+(M,max-f) as Real;
A29:   -integral+(M,max-f) = -IM by XXREAL_3:def 3;
A30:  Integral(M,f) = integral+(M,max+f) - integral+(M,max-f)
        by MESFUNC5:def 16
       .= integral+(M,max+f) + (-integral+(M,max-f)) by XXREAL_3:def 4
       .= IP + - IM by A29,XXREAL_3:def 2;

      integral+(M,max-f|A) <> +infty by A28,A13,A7,A12,XXREAL_3:def 2; then
      integral+(M,max-f|A) in REAL by A12,XXREAL_0:14; then
      reconsider IMA = integral+(M,max-f|A) as Real;

      integral+(M,max-f|B) <> +infty by A28,A13,A7,A12,XXREAL_3:def 2; then
      integral+(M,max-f|B) in REAL by A12,XXREAL_0:14; then
      reconsider IMB = integral+(M,max-f|B) as Real;

A31:   IP = IPA + IPB & IM = IMA + IMB by A13,A7,XXREAL_3:def 2;
A32:   -integral+(M,max-f|A) = -IMA & -integral+(M,max-f|B) = -IMB
        by XXREAL_3:def 3;
A33:   Integral(M,f|A) = integral+(M,max+f|A) + (-integral+(M,max-f|A))
         by A14,XXREAL_3:def 4
       .= IPA + -IMA by A32,XXREAL_3:def 2;

      Integral(M,f|B) = integral+(M,max+f|B) + (-integral+(M,max-f|B))
         by A15,XXREAL_3:def 4
       .= IPB + -IMB by A32,XXREAL_3:def 2; then
      Integral(M,f|A) + Integral(M,f|B) = (IPA - IMA) + (IPB - IMB)
        by A33,XXREAL_3:def 2;
      hence Integral(M,f) = Integral(M,f|A)+Integral(M,f|B) by A30,A31;
     end;
    end;
    suppose A34: integral+(M,max- f) < +infty; then
     integral+(M,max-f) in REAL by A8,XXREAL_0:14; then
     reconsider IP = integral+(M,max-f) as Real;
     reconsider IPA = integral+(M,max-f|A), IPB = integral+(M,max-f|B)
       as Real by A34,A20;

     per cases by A8,XXREAL_0:14;
     suppose A35: integral+(M,max+f) = +infty; then
A36:  Integral(M,f) = +infty by A5,A34,XXREAL_3:13;

      integral+(M,max+f|A) = +infty or integral+(M,max+f|B) = +infty
        by A13,A7,A35,XXREAL_3:16; then
A37:  Integral(M,f|A) = +infty or Integral(M,f|B) = +infty
        by A14,A15,A34,A20,XXREAL_3:13;

      Integral(M,f|A) <> -infty & Integral(M,f|B) <> -infty
        by A34,A20,A12,A14,A15,XXREAL_3:19;
      hence Integral(M,f) = Integral(M,f|A)+Integral(M,f|B)
         by A36,A37,XXREAL_3:def 2;
     end;

     suppose A38: integral+(M,max+f) in REAL; then
      reconsider IM = integral+(M,max+f) as Real;
A39:   -integral+(M,max-f) = -IP by XXREAL_3:def 3;
A40:  Integral(M,f) = integral+(M,max+f) - integral+(M,max-f)
        by MESFUNC5:def 16
       .= integral+(M,max+f) + (-integral+(M,max-f)) by XXREAL_3:def 4
       .= IM + - IP by A39,XXREAL_3:def 2;

      integral+(M,max+f|A) <> +infty by A38,A13,A7,A12,XXREAL_3:def 2; then
      integral+(M,max+f|A) in REAL by A12,XXREAL_0:14; then
      reconsider IMA = integral+(M,max+f|A) as Real;

      integral+(M,max+f|B) <> +infty by A38,A13,A7,A12,XXREAL_3:def 2; then
      integral+(M,max+f|B) in REAL by A12,XXREAL_0:14; then
      reconsider IMB = integral+(M,max+f|B) as Real;

A41:   IP = IPA + IPB & IM = IMA + IMB by A13,A7,XXREAL_3:def 2;
A42:   -integral+(M,max-f|A) = -IPA & -integral+(M,max-f|B) = -IPB
        by XXREAL_3:def 3;
A43:   Integral(M,f|A) = integral+(M,max+f|A) + (-integral+(M,max-f|A))
         by A14,XXREAL_3:def 4
      .= IMA + -IPA by A42,XXREAL_3:def 2;
      Integral(M,f|B) = integral+(M,max+f|B) + (-integral+(M,max-f|B))
         by A15,XXREAL_3:def 4
      .= IMB + -IPB by A42,XXREAL_3:def 2; then
      Integral(M,f|A) + Integral(M,f|B) = (IMA - IPA) + (IMB - IPB)
        by A43,XXREAL_3:def 2;
      hence Integral(M,f) = Integral(M,f|A)+Integral(M,f|B) by A40,A41;
     end;
    end;
end;

theorem Th18:
for X be non empty set, S be SigmaField of X, M be sigma_Measure of S,
 f be PartFunc of X,ExtREAL, A,B be Element of S
 st A \/ B c= dom f & f is (A\/B)-measurable & A misses B
  & (integral+(M,max+(f|(A\/B))) < +infty
   or integral+(M,max-(f|(A\/B))) < +infty)
 holds Integral(M,f|(A\/B)) = Integral(M,f|A)+Integral(M,f|B)
proof
    let X be non empty set, S be SigmaField of X, M be sigma_Measure of S,
     f be PartFunc of X,ExtREAL, A,B be Element of S;
    assume that
A1:  A \/ B c= dom f and
A2:  f is (A\/B)-measurable and
A3:  A misses B and
A4:  integral+(M,max+(f|(A\/B))) < +infty
     or integral+(M,max-(f|(A\/B))) < +infty;

    set g=f|(A\/B);
A5: dom g = A \/ B by A1,RELAT_1:62;

    A \/ B = dom f /\ (A \/ B) by A1,XBOOLE_1:28; then
A6: g is (A\/B)-measurable by A2,MESFUNC5:42;

    g|A = f|A & g|B = f|B by RELAT_1:74,XBOOLE_1:7;
    hence Integral(M,f|(A\/B)) = Integral(M,f|A)+Integral(M,f|B)
      by A6,A5,A3,A4,Lm2;
end;

theorem Th19:
for X be non empty set, S be SigmaField of X, M be sigma_Measure of S,
  f be PartFunc of X,ExtREAL, A be Element of S, E be SetSequence of S
 st f is A-measurable & A = dom f & E is non-descending & lim E c= A
 & M.(A \ lim E) = 0
  & (integral+(M,max+ f) < +infty or integral+(M,max- f) < +infty)
holds
 ex I be ExtREAL_sequence st
 (for n be Nat holds I.n = Integral(M,f|((Partial_Union E).n)))
 & I is convergent & Integral(M,f) = lim I
proof
    let X be non empty set, S be SigmaField of X, M be sigma_Measure of S,
     f be PartFunc of X,ExtREAL, A be Element of S, E be SetSequence of S;
    assume that
A1:  f is A-measurable and
A2:  A = dom f and
A3:  E is non-descending and
A4:  lim E c= A and
A5:  M.(A \ lim E) = 0 and
A6:  (integral+(M,max+ f) < +infty or integral+(M,max- f) < +infty);

    Union E is Element of S by PROB_1:17; then
    reconsider LE = lim E as Element of S by A3,SETLIM_1:80;

    A \ (A \ LE) = A /\ LE by XBOOLE_1:48 .= LE by A4,XBOOLE_1:28; then
A7:Integral(M,f) = Integral(M,f|LE) by A1,A2,A5,MESFUNC5:95;

    reconsider F = Partial_Diff_Union E as SetSequence of S;

    set g = f|LE;
A8:LE = dom f /\ LE by A2,A4,XBOOLE_1:28;
    f is LE-measurable by A1,A4,MESFUNC1:30; then
A9: g is LE-measurable by A8,MESFUNC5:42;

A10:lim E = Union E by A3,SETLIM_1:80; then
A11: LE = Union F by PROB_3:20;

A12: max+f is nonnegative & max-f is nonnegative by MESFUN11:5;

A13: max+f|A = max+(f|A) & max-f|A = max-(f|A) &
    max+f|LE = max+g & max-f|LE = max-g by MESFUNC5:28;

    dom(max+f) = dom f & dom(max-f) = dom f by MESFUNC2:def 2,def 3; then
    integral+(M,max+f|LE) <= integral+(M,max+f|A)
  & integral+(M,max-f|LE) <= integral+(M,max-f|A)
    by A2,A4,A12,A1,MESFUNC2:25,26,MESFUNC5:83; then
A14: integral+(M,max+g) < +infty or integral+(M,max-g) <+infty
      by A2,A6,A13,XXREAL_0:2;

A15: LE = dom g by A8,RELAT_1:61; then
    consider J be ExtREAL_sequence such that
A16:  for n be Nat holds J.n = Integral(M,g|(F.n)) and
A17:  J is summable & Integral(M,g) = Sum J by A9,A11,A14,Th17;
    reconsider I = Partial_Sums J as ExtREAL_sequence;
    take I;
A18: for n be Nat holds g|((Partial_Union F).n) = f|((Partial_Union E).n)
    proof
     let n be Nat;
A19:  (Partial_Union F).n = (Partial_Union E).n by PROB_3:19;

     now let x be object;
      assume x in (Partial_Union E).n; then
      consider k be Nat such that
A20:    k <= n & x in E.k by PROB_3:13;
      k in NAT by ORDINAL1:def 12; then
      k in dom E by FUNCT_2:def 1; then
      E.k c= union rng E by FUNCT_1:3,ZFMISC_1:74; then
      E.k c= Union E by CARD_3:def 4;
      hence x in Union E by A20;
     end; then
     (Partial_Union E).n c= LE by A10;
     hence thesis by A19,RELAT_1:74;
    end;

A21: for n be Nat holds (Partial_Union E).n c= Union E
    proof
     let n be Nat;
     now let x be object;
      assume x in (Partial_Union E).n; then
      consider k be Nat such that
A22:    k <= n & x in E.k by PROB_3:13;
      k in NAT by ORDINAL1:def 12; then
      k in dom E by FUNCT_2:def 1; then
      E.k in rng E by FUNCT_1:3; then
      x in union rng E by A22,TARSKI:def 4;
      hence x in Union E by CARD_3:def 4;
     end;
     hence thesis;
    end;

    defpred P[Nat] means I.$1 = Integral(M,g|((Partial_Union F).$1));

    I.0 = J.0 by MESFUNC9:def 1 .= Integral(M,g|(F.0)) by A16; then
A23: P[0] by PROB_3:def 2;
A24: for n be Nat st P[n] holds P[n+1]
    proof
     let n be Nat;
     assume A25: P[n];
     reconsider PFn = (Partial_Union F).n as Element of S by PROB_1:25;
     reconsider Fn1 = F.(n+1) as Element of S by PROB_1:25;

     n < n+1 by NAT_1:13; then
A26:  PFn misses Fn1 by PROB_3:42;

     PFn \/ Fn1 = (Partial_Union F).(n+1) by PROB_3:def 2; then
A27: PFn \/ Fn1 = (Partial_Union E).(n+1) by PROB_3:19; then
A28:  PFn \/ Fn1 c= dom g by A21,A15,A10;

A29:  g is (PFn \/ Fn1)-measurable by A9,A21,A10,A27,MESFUNC1:30;

A30:  max+g is nonnegative & max-g is nonnegative by MESFUN11:5;
A31: max+g is LE-measurable & max-g is LE-measurable by A9,A15,MESFUNC2:25,26;
A32: max+g|LE = max+(g|LE) & max-g|LE = max-(g|LE) by MESFUNC5:28;

     dom(max+g) = dom g & dom(max-g) = dom g by MESFUNC2:def 2,def 3; then
     integral+(M,max+g|(PFn \/ Fn1)) <= integral+(M,max+g|LE)
   & integral+(M,max-g|(PFn \/ Fn1)) <= integral+(M,max-g|LE)
       by A30,A31,A15,A27,A21,A10,MESFUNC5:83; then
     integral+(M,max+g|(PFn \/ Fn1)) < +infty
  or integral+(M,max-g|(PFn \/ Fn1)) < +infty by A14,A32,XXREAL_0:2; then
A33: integral+(M,max+(g|(PFn \/ Fn1))) < +infty
  or integral+(M,max-(g|(PFn \/ Fn1))) < +infty by MESFUNC5:28;

     I.(n+1) = (Partial_Sums J).n + J.(n+1) by MESFUNC9:def 1
      .= Integral(M,g|PFn) + Integral(M,g|Fn1) by A16,A25
      .= Integral(M,g|(PFn \/ Fn1)) by A28,A29,A26,A33,Th18;
     hence I.(n+1) = Integral(M,g|((Partial_Union F).(n+1))) by PROB_3:def 2;
    end;
A34: for n be Nat holds P[n] from NAT_1:sch 2(A23,A24);
    thus for n be Nat holds I.n = Integral(M,f|((Partial_Union E).n))
    proof
     let n be Nat;
     I.n = Integral(M,g|((Partial_Union F).n)) by A34;
     hence thesis by A18;
    end;
    thus I is convergent by A17,MESFUNC9:def 2;
    thus Integral(M,f) = lim I by A7,A17,MESFUNC9:def 3;
end;

theorem Th20:  ::: see MEASURE4:1
for X,Y be non empty set, A be set,
  F being sequence of X, G be sequence of Y
   st for n being Element of NAT holds G.n = A /\ F.n
  holds union rng G = A /\ union rng F
proof
   let X,Y be non empty set, A be set;
   let F being sequence of X, G be sequence of Y;
   assume
A1: for n being Element of NAT holds G.n = A /\ F.n;

   now let r be object;
    assume r in union rng G; then
    consider E being set such that
A2:  r in E and
A3:  E in rng G by TARSKI:def 4;
    consider s being object such that
A4:  s in dom G and
A5:  E = G.s by A3,FUNCT_1:def 3;
    reconsider s as Element of NAT by A4;
A6: r in A /\ F.s by A1,A2,A5; then
A7: r in A by XBOOLE_0:def 4;
A8: F.s in rng F by FUNCT_2:4;
    r in F.s by A6,XBOOLE_0:def 4; then
    r in union rng F by A8,TARSKI:def 4;
    hence r in A /\ union rng F by A7,XBOOLE_0:def 4;
   end; then
A9:union rng G c= A /\ union rng F;

   now let r be object;
    assume
A10:  r in A /\ union rng F; then
A11:r in A by XBOOLE_0:def 4;
    r in union rng F by A10,XBOOLE_0:def 4; then
    consider E being set such that
A12: r in E and
A13: E in rng F by TARSKI:def 4;
    consider s being object such that
A14: s in dom F and
A15: E = F.s by A13,FUNCT_1:def 3;
    reconsider s as Element of NAT by A14;
A16:G.s in rng G by FUNCT_2:4;
    A /\ E = G.s by A1,A15; then
    r in G.s by A11,A12,XBOOLE_0:def 4;
    hence r in union rng G by A16,TARSKI:def 4;
   end; then
   A /\ union rng F c= union rng G;
   hence thesis by A9,XBOOLE_0:def 10;
end;

theorem Th21:
for X be non empty set, S be SigmaField of X, E be sequence of S,
 f be PartFunc of X,ExtREAL st
  for n be Nat holds f is (E.n)-measurable holds
 f is (Union E)-measurable
proof
    let X be non empty set, S be SigmaField of X, E be sequence of S,
     f be PartFunc of X,ExtREAL;
    assume A1: for n be Nat holds f is (E.n)-measurable;

    for r be Real holds (Union E) /\ less_dom(f,r) in S
    proof
     let r be Real;
     deffunc F(Element of NAT) = E.$1 /\ less_dom(f,r);
     consider E1 be sequence of bool X such that
A2:   for n be Element of NAT holds E1.n = F(n) from FUNCT_2:sch 4;

     for n be Element of NAT holds E1.n = less_dom(f,r) /\ E.n by A2; then
     (union rng E1) = less_dom(f,r) /\ (union rng E) by Th20; then
A3:  Union E1 = less_dom(f,r) /\ (union rng E) by CARD_3:def 4;

     reconsider E1 as SetSequence of X;
     for n be Element of NAT holds E1.n in S
     proof
      let n be Element of NAT;
A4:   f is (E.n)-measurable by A1;
      E1.n = E.n /\ less_dom(f,r) by A2;
      hence thesis by A4,MESFUNC1:def 16;
     end; then
     rng E1 c= S by FUNCT_2:114; then
     reconsider E1 as SetSequence of S by RELAT_1:def 19;

     Union E1 = Union E /\ less_dom(f,r) by A3,CARD_3:def 4;
     hence thesis by PROB_1:17;
    end;
    hence f is (Union E)-measurable by MESFUNC1:def 16;
end;

Lm3:
for a,b be Real, E be sequence of bool REAL st
 a < b & (for n be Nat holds E.n = [. a, b-(b-a)/(n+1) .]) holds
 E is non-descending & E is convergent & Union E = [. a,b .[
proof
    let a,b be Real, E be sequence of bool REAL;
    assume that
A1:  a < b and
A2:  for n be Nat holds E.n = [. a, b-(b-a)/(n+1) .];

A3: b-a > 0 by A1,XREAL_1:50;

    for n,m be Nat st n <= m holds E.n c= E.m
    proof
     let n,m be Nat;
     assume n <= m; then
     0 < n+1 & n+1 <= m+1 by XREAL_1:6; then
     (b-a)/(m+1) <= (b-a)/(n+1) by A3,XREAL_1:118; then
     b-(b-a)/(n+1) <= b-(b-a)/(m+1) by XREAL_1:10; then
     [.a,b-(b-a)/(n+1).] c= [.a,b-(b-a)/(m+1).] by XXREAL_1:34; then
     E.n c= [.a,b-(b-a)/(m+1).] by A2;
     hence thesis by A2;
    end;
    hence E is non-descending by PROB_1:def 5;
    hence E is convergent by SETLIM_1:63;

    now let x be Real;
     assume x in Union E; then
     x in union rng E by CARD_3:def 4; then
     consider A be set such that
A4:   x in A & A in rng E by TARSKI:def 4;
     consider n be Element of NAT such that
A5:   A = E.n by A4,FUNCT_2:113;
     x in [. a, b-(b-a)/(n+1) .] by A2,A4,A5; then
A6:  a <= x & x <= b-(b-a)/(n+1) by XXREAL_1:1;

     b-(b-a)/(n+1) < b by A3,XREAL_1:44; then
     x < b by A6,XXREAL_0:2;
     hence x in [.a,b.[ by A6,XXREAL_1:3;
    end; then
A7: Union E c= [.a,b.[;

    now let x be Real;
     assume x in [.a,b.[; then
A8:  a <= x & x < b by XXREAL_1:3; then
A9: x-a >= 0 & b-x > 0 by XREAL_1:48,50;

     consider n be Nat such that
A10:  (x-a)/(b-x) < n by SEQ_4:3;
     x-a < (b-x)*n by A9,A10,XREAL_1:77; then
     b-x + (x-a) < b-x+(b-x)*n by XREAL_1:8; then
     b-a < (b-x)*(n+1); then
     (b-a)/(n+1) < b-x by XREAL_1:83; then
     x < b-(b-a)/(n+1) by XREAL_1:12; then
     x in [.a,b-(b-a)/(n+1).] by A8,XXREAL_1:1; then
A11: x in E.n by A2;
     dom E = NAT by FUNCT_2:def 1; then
     E.n in rng E by FUNCT_1:3,ORDINAL1:def 12; then
     x in union rng E by A11,TARSKI:def 4;
     hence x in Union E by CARD_3:def 4;
    end; then
    [.a,b.[ c= Union E;
    hence Union E = [. a,b .[ by A7,XBOOLE_0:def 10;
end;

theorem Th22:
for a,b be Real, n be Nat st a < b holds
  a <= b-(b-a)/(n+1) < b & a < a+(b-a)/(n+1) <= b
proof
    let a,b be Real, n be Nat;
    assume a < b; then
A1: 0 < b-a & 0 < n+1 by XREAL_1:50; then
A2: (b-a)/(n+1) <= (b-a)/1 by NAT_1:11,XREAL_1:118; then
    a+(b-a)/(n+1) <= b by XREAL_1:19;
    hence a <= b-(b-a)/(n+1) < b by A1,XREAL_1:19,44;
    thus a < a+(b-a)/(n+1) <= b by A1,A2,XREAL_1:19,29;
end;

theorem Th23:
for a,b be Real st a < b holds
 ex E be SetSequence of L-Field st
  (for n be Nat holds E.n = [. a, b-(b-a)/(n+1) .] & E.n c= [.a,b.[ &
    E.n is non empty closed_interval Subset of REAL) &
  E is non-descending & E is convergent & Union E = [. a,b .[
proof
    let a,b be Real;
    assume A1: a < b;

    deffunc F(Element of NAT) = [. a, b-(b-a)/($1+1) .];
    consider E be Function of NAT, bool REAL such that
A2:  for n be Element of NAT holds E.n = F(n) from FUNCT_2:sch 4;

    now let x be object;
     assume x in rng E; then
     consider n be object such that
A3:   n in dom E & E.n = x by FUNCT_1:def 3;

     reconsider n as Element of NAT by A3;
     E.n = [.a,b-(b-a)/(n+1).] by A2;
     hence x in L-Field by A3,MEASUR10:5,MEASUR12:75;
    end; then
    rng E c= L-Field; then
    reconsider E as SetSequence of L-Field by RELAT_1:def 19;
    take E;

A4: for n be Nat holds E.n = [.a,b-(b-a)/(n+1).]
    proof
     let n be Nat;
     n is Element of NAT by ORDINAL1:def 12;
     hence thesis by A2;
    end;

    thus for n be Nat holds
     E.n = [.a,b-(b-a)/(n+1).] & E.n c= [.a,b.[
     & E.n is non empty closed_interval Subset of REAL
    proof
     let n be Nat;
     thus E.n = [.a,b-(b-a)/(n+1).] by A4;
A5:  E.n = [.a, b-(b-a)/(n+1).] by A4;
A6:  b-(b-a)/(n+1) < b by A1,Th22;
     a <= b-(b-a)/(n+1) by A1,Th22;
     hence thesis by A5,A6,MEASURE5:def 3,XXREAL_1:30,43;
    end;
    thus E is non-descending & E is convergent & Union E = [.a,b.[
     by A1,A4,Lm3;
end;

Lm4:
for a,b be Real, E be sequence of bool REAL st
 a < b & (for n be Nat holds E.n = [. a+(b-a)/(n+1), b .]) holds
 E is non-descending & E is convergent & Union E = ]. a,b .]
proof
    let a,b be Real, E be sequence of bool REAL;
    assume that
A1:  a < b and
A2:  for n be Nat holds E.n = [. a+(b-a)/(n+1), b .];

A3: b-a > 0 by A1,XREAL_1:50;

    for n,m be Nat st n <= m holds E.n c= E.m
    proof
     let n,m be Nat;
     assume n <= m; then
     0 < n+1 & n+1 <= m+1 by XREAL_1:6; then
     (b-a)/(m+1) <= (b-a)/(n+1) by A3,XREAL_1:118; then
     a+(b-a)/(n+1) >= a+(b-a)/(m+1) by XREAL_1:6; then
     [.a+(b-a)/(n+1),b.] c= [.a+(b-a)/(m+1),b.] by XXREAL_1:34; then

     E.n c= [.a+(b-a)/(m+1),b.] by A2;
     hence thesis by A2;
    end;
    hence E is non-descending by PROB_1:def 5;
    hence E is convergent by SETLIM_1:63;

    now let x be Real;
     assume x in Union E; then
     x in union rng E by CARD_3:def 4; then
     consider A be set such that
A4:   x in A & A in rng E by TARSKI:def 4;
     consider n be Element of NAT such that
A5:   A = E.n by A4,FUNCT_2:113;
     x in [. a+(b-a)/(n+1), b .] by A2,A4,A5; then
A6:  a+(b-a)/(n+1) <= x & x <= b by XXREAL_1:1;

     a+(b-a)/(n+1) > a by A3,XREAL_1:29; then
     x > a by A6,XXREAL_0:2;
     hence x in ].a,b.] by A6,XXREAL_1:2;
    end; then
A7: Union E c= ].a,b.];

    now let x be Real;
     assume x in ].a,b.]; then
A8:  a < x & x <= b by XXREAL_1:2; then
A9: x-a > 0 & b-x >= 0 by XREAL_1:48,50;

     consider n be Nat such that
A10:  (b-x)/(x-a) < n by SEQ_4:3;
     b-x < (x-a)*n by A9,A10,XREAL_1:77; then
     x-a + (b-x) < x-a+(x-a)*n by XREAL_1:8; then
     b-a < (x-a)*(n+1); then
     (b-a)/(n+1) < x-a by XREAL_1:83; then
     x > a+(b-a)/(n+1) by XREAL_1:20; then
     x in [.a+(b-a)/(n+1),b.] by A8,XXREAL_1:1; then
A11: x in E.n by A2;
     dom E = NAT by FUNCT_2:def 1; then
     E.n in rng E by FUNCT_1:3,ORDINAL1:def 12; then
     x in union rng E by A11,TARSKI:def 4;
     hence x in Union E by CARD_3:def 4;
    end; then
    ].a,b.] c= Union E;
    hence Union E = ]. a,b .] by A7,XBOOLE_0:def 10;
end;

theorem Th24:
for a,b be Real st a < b holds
 ex E be SetSequence of L-Field st
  (for n be Nat holds E.n = [. a+(b-a)/(n+1), b .] & E.n c= ].a,b.] &
    E.n is non empty closed_interval Subset of REAL) &
  E is non-descending & E is convergent & Union E = ]. a,b .]
proof
    let a,b be Real;
    assume A1: a < b;

    deffunc F(Element of NAT) = [. a+(b-a)/($1+1), b .];
    consider E be Function of NAT, bool REAL such that
A2:  for n be Element of NAT holds E.n = F(n) from FUNCT_2:sch 4;

    now let x be object;
     assume x in rng E; then
     consider n be object such that
A3:   n in dom E & E.n = x by FUNCT_1:def 3;
     reconsider n as Element of NAT by A3;
     E.n = [.a+(b-a)/(n+1), b.] by A2;
     hence x in L-Field by A3,MEASUR10:5,MEASUR12:75;
    end; then
    rng E c= L-Field; then
    reconsider E as SetSequence of L-Field by RELAT_1:def 19;
    take E;
    thus
    for n be Nat holds E.n = [.a+(b-a)/(n+1), b.] & E.n c= ].a,b.] &
     E.n is non empty closed_interval Subset of REAL
    proof
     let n be Nat;
     n is Element of NAT by ORDINAL1:def 12;
     hence
A4:   E.n = [.a+(b-a)/(n+1), b.] by A2;
A5:  a < a+(b-a)/(n+1) <= b by A1,Th22;
     hence E.n c= ].a,b.] by A4,XXREAL_1:39;
     thus E.n is non empty closed_interval Subset of REAL
       by A4,A5,XXREAL_1:30,MEASURE5:def 3;
    end;
    hence E is non-descending & E is convergent & Union E = ].a,b.] by A1,Lm4;
end;

Lm5:
for a be Real, E be sequence of bool REAL st
 (for n be Nat holds E.n = [.a,a+n.]) holds
 E is non-descending & E is convergent & Union E = [. a,+infty .[
proof
    let a be Real, E be sequence of bool REAL;
    assume A1: for n be Nat holds E.n = [.a,a+n.];

    for n,m be Nat st n <= m holds E.n c= E.m
    proof
     let n,m be Nat;
     assume n <= m; then
     a+n <= a+m by XREAL_1:6; then
     [.a,a+n.] c= [.a,a+m.] by XXREAL_1:34; then
     E.n c= [.a,a+m.] by A1;
     hence thesis by A1;
    end;
    hence E is non-descending by PROB_1:def 5;
    hence E is convergent by SETLIM_1:63;

    now let x be Real;
     assume x in Union E; then
     x in union rng E by CARD_3:def 4; then
     consider A be set such that
A2:   x in A & A in rng E by TARSKI:def 4;
     consider n be Element of NAT such that
A3:   A = E.n by A2,FUNCT_2:113;
     x in [. a, a+n .] by A1,A2,A3; then
A4:  a <= x & x <= a+n by XXREAL_1:1;

     x in REAL by XREAL_0:def 1;
     hence x in [.a,+infty.[ by A4,XXREAL_0:9,XXREAL_1:3;
    end; then
A5: Union E c= [.a,+infty.[;

    now let x be Real;
     assume x in [.a,+infty.[; then
A6:  a <= x & x < +infty by XXREAL_1:3;

     consider n be Nat such that
A7:  x-a < n by SEQ_4:3;
     x < a+n by A7,XREAL_1:19; then
     x in [.a,a+n.] by A6,XXREAL_1:1; then
A8: x in E.n by A1;
     dom E = NAT by FUNCT_2:def 1; then
     E.n in rng E by FUNCT_1:3,ORDINAL1:def 12; then
     x in union rng E by A8,TARSKI:def 4;
     hence x in Union E by CARD_3:def 4;
    end; then
    [.a,+infty.[ c= Union E;
    hence Union E = [. a,+infty .[ by A5,XBOOLE_0:def 10;
end;

theorem Th25:
for a be Real holds
 ex E be SetSequence of L-Field st
  (for n be Nat holds E.n = [.a,a+n.]) &
  E is non-descending & E is convergent & Union E = [. a,+infty .[
proof
    let a be Real;
    deffunc F(Element of NAT) = [.a,a+$1 .];
    consider E be Function of NAT, bool REAL such that
A1:  for n be Element of NAT holds E.n = F(n) from FUNCT_2:sch 4;

    now let x be object;
     assume x in rng E; then
     consider n be object such that
A2:   n in dom E & E.n = x by FUNCT_1:def 3;
     reconsider n as Element of NAT by A2;
     E.n = [.a,a+n.] by A1;
     hence x in L-Field by A2,MEASUR10:5,MEASUR12:75;
    end; then
    rng E c= L-Field; then
    reconsider E as SetSequence of L-Field by RELAT_1:def 19;
    take E;
    thus for n be Nat holds E.n = [.a,a+n.]
    proof
     let n be Nat;
     n is Element of NAT by ORDINAL1:def 12;
     hence thesis by A1;
    end;
    hence E is non-descending & E is convergent & Union E = [.a,+infty.[
     by Lm5;
end;

Lm6:
for a be Real, E be sequence of bool REAL st
 (for n be Nat holds E.n = [.a-n,a.]) holds
 E is non-descending & E is convergent & Union E = ].-infty,a.]
proof
    let a be Real, E be sequence of bool REAL;
    assume A1: for n be Nat holds E.n = [.a-n,a.];

    for n,m be Nat st n <= m holds E.n c= E.m
    proof
     let n,m be Nat;
     assume n <= m; then
     a-m <= a-n by XREAL_1:10; then
     [.a-n,a.] c= [.a-m,a.] by XXREAL_1:34; then
     E.n c= [.a-m,a.] by A1;
     hence thesis by A1;
    end;
    hence E is non-descending by PROB_1:def 5;
    hence E is convergent by SETLIM_1:63;

    now let x be Real;
     assume x in Union E; then
     x in union rng E by CARD_3:def 4; then
     consider A be set such that
A2:   x in A & A in rng E by TARSKI:def 4;
     consider n be Element of NAT such that
A3:   A = E.n by A2,FUNCT_2:113;
     x in [. a-n, a .] by A1,A2,A3; then
A4:  a-n <= x <= a by XXREAL_1:1;

     x in REAL by XREAL_0:def 1;
     hence x in ].-infty,a.] by A4,XXREAL_0:12,XXREAL_1:2;
    end; then
A5: Union E c= ].-infty,a.];

    now let x be Real;
     assume x in ].-infty,a.]; then
A6:  -infty < x <= a by XXREAL_1:2;

     consider n be Nat such that
A7:  a-x < n by SEQ_4:3;
     a-n < x by A7,XREAL_1:11; then
     x in [.a-n,a.] by A6,XXREAL_1:1; then
A8: x in E.n by A1;
     dom E = NAT by FUNCT_2:def 1; then
     E.n in rng E by FUNCT_1:3,ORDINAL1:def 12; then
     x in union rng E by A8,TARSKI:def 4;
     hence x in Union E by CARD_3:def 4;
    end; then
    ].-infty,a.] c= Union E;
    hence Union E = ].-infty,a.] by A5,XBOOLE_0:def 10;
end;

theorem Th26:
for a be Real holds
 ex E be SetSequence of L-Field st
  (for n be Nat holds E.n = [.a-n,a.]) &
  E is non-descending & E is convergent & Union E = ].-infty,a.]
proof
    let a be Real;
    deffunc F(Element of NAT) = [.a-$1,a.];
    consider E be Function of NAT, bool REAL such that
A1:  for n be Element of NAT holds E.n = F(n) from FUNCT_2:sch 4;

    now let x be object;
     assume x in rng E; then
     consider n be object such that
A2:   n in dom E & E.n = x by FUNCT_1:def 3;
     reconsider n as Element of NAT by A2;
     E.n = [.a-n,a.] by A1;
     hence x in L-Field by A2,MEASUR10:5,MEASUR12:75;
    end; then
    rng E c= L-Field; then
    reconsider E as SetSequence of L-Field by RELAT_1:def 19;
    take E;
    thus for n be Nat holds E.n = [.a-n,a.]
    proof
     let n be Nat;
     n is Element of NAT by ORDINAL1:def 12;
     hence thesis by A1;
    end;
    hence E is non-descending & E is convergent & Union E = ].-infty,a.]
     by Lm6;
end;

theorem Th27:
for X be set, S be SigmaField of X, M be sigma_Measure of S,
 A be thin of M holds A in COM(S,M)
proof
    let X be set, S be SigmaField of X, M be sigma_Measure of S,
    A be thin of M;
    reconsider B = {} as Element of S by MEASURE1:7;
    B \/ A in COM(S,M) by MEASURE3:def 3;
    hence A in COM(S,M);
end;

theorem Th28:
for r be Real holds {r} in L-Field
proof
    let r be Real;
    {r} is thin of B-Meas by MEASUR12:74;
    hence thesis by Th27,MEASUR12:def 11;
end;

theorem Th29:
for X be non empty set, S be SigmaField of X, E be Element of S,
 f be PartFunc of X,ExtREAL st E = {} holds f is E-measurable
proof
    let X be non empty set, S be SigmaField of X, E be Element of S,
    f be PartFunc of X,ExtREAL;
    assume E = {}; then
    for r be Real holds E /\ less_dom(f,r) in S;
    hence f is E-measurable by MESFUNC1:def 16;
end;

theorem Th30:
for X be non empty set, S be SigmaField of X, E be Element of S,
 f be PartFunc of X,REAL st E = {} holds f is E-measurable
proof
    let X be non empty set, S be SigmaField of X, E be Element of S,
    f be PartFunc of X,REAL;
    assume E = {}; then
    R_EAL f is E-measurable by Th29;
    hence f is E-measurable by MESFUNC6:def 1;
end;

theorem Th31:
for r be Real, E be Element of L-Field, f be PartFunc of REAL,ExtREAL
 st E = {r} holds f is E-measurable
proof
    let r be Real, E be Element of L-Field, f be PartFunc of REAL,ExtREAL;
    assume A1: E = {r};
    for a be Real holds E /\ less_dom(f,a) in L-Field
    proof
     let a be Real;
     E /\ less_dom(f,a) = {} or E /\ less_dom(f,a) = {r}
       by A1,XBOOLE_1:17,ZFMISC_1:33;
     hence thesis by A1,MEASURE1:7;
    end;
    hence f is E-measurable by MESFUNC1:def 16;
end;

theorem
for r be Real, E be Element of L-Field, f be PartFunc of REAL,REAL
 st E = {r} holds f is E-measurable
proof
    let r be Real, E be Element of L-Field, f be PartFunc of REAL,REAL;
    assume E = {r}; then
    R_EAL f is E-measurable by Th31;
    hence f is E-measurable by MESFUNC6:def 1;
end;

theorem Th33:
for a,b be Real, f be PartFunc of REAL,REAL st [.a,b.[ c= dom f
 & f is_right_improper_integrable_on a,b
 holds for E be Element of L-Field st E c= [.a,b.[ holds f is E-measurable
proof
    let a,b be Real, f be PartFunc of REAL,REAL;
    assume that
A1: [.a,b.[ c= dom f and
A2:  f is_right_improper_integrable_on a,b;

    per cases;
    suppose A3: a < b;
     reconsider A = [.a,b.[ as Element of L-Field by MEASUR12:72,75;
     set dif = b-a;

     consider K be SetSequence of L-Field such that
A4:   (for n be Nat holds K.n = [.a,b-(b-a)/(n+1).] & K.n c= [.a,b.[ &
       K.n is non empty closed_interval Subset of REAL) &
      K is non-descending &
      K is convergent &
      Union K = A by A3,Th23;
     rng K c= L-Field; then
     reconsider K1 = K as sequence of L-Field by FUNCT_2:6;

     for n be Nat holds (R_EAL f) is (K1.n)-measurable
     proof
      let n be Nat;
      K.n is non empty by A4; then
      [.a,b-(b-a)/(n+1).] <> {} by A4; then
A5:   a <= b-(b-a)/(n+1) by XXREAL_1:29;
      K.n c= [.a,b.[ by A4; then
      [.a,b-(b-a)/(n+1).] c= [.a,b.[ by A4; then
A6:   a<= b-dif/(n+1) < b by A5,XXREAL_1:54;

      reconsider Kn = K.n as non empty closed_interval Subset of REAL by A4;

      Kn = [.a,b-dif/(n+1).] by A4; then
      Kn = [' a,b-dif/(n+1) '] by XXREAL_1:29,INTEGRA5:def 3; then
A7:   f is_integrable_on Kn & f||Kn is bounded by A6,A2,INTEGR24:def 2;

      Kn c= [.a,b.[ by A4; then
      Kn c= dom f by A1;
      hence (R_EAL f) is (K1.n)-measurable by A7,MESFUN14:49,MESFUNC6:def 1;
     end; then
     f is (Union K1)-measurable by Th21,MESFUNC6:def 1;
     hence for E be Element of L-Field st E c= [.a,b.[ holds
      f is E-measurable by A4,MESFUNC6:16;
    end;
    suppose a >= b; then
A8:  [.a,b.[ = {} by XXREAL_1:27;
     hereby let E be Element of L-Field;
      assume E c= [.a,b.[; then
      E = {} by A8;
      hence f is E-measurable by Th30;
     end;
    end;
end;

theorem Th34:
for a,b be Real, f be PartFunc of REAL,REAL st
].a,b.] c= dom f &
 f is_left_improper_integrable_on a,b
 holds for E be Element of L-Field st E c= ].a,b.] holds f is E-measurable
proof
    let a,b be Real, f be PartFunc of REAL,REAL;
    assume that
A1: ].a,b.] c= dom f and
A2:  f is_left_improper_integrable_on a,b;

    per cases;
    suppose A3: a < b; then
    reconsider A = ].a,b.] as non empty Subset of REAL by XXREAL_1:32;
    reconsider A as Element of L-Field by MEASUR12:72,75;

    set dif = b-a;

    consider K be SetSequence of L-Field such that
A4:  (for n be Nat holds K.n = [. a+(b-a)/(n+1), b .] & K.n c= ].a,b.] &
       K.n is non empty closed_interval Subset of REAL) &
     K is non-descending & K is convergent & Union K = ]. a,b .] by A3,Th24;
    rng K c= L-Field; then
    reconsider K1 = K as sequence of L-Field by FUNCT_2:6;

    for n be Nat holds (R_EAL f) is (K1.n)-measurable
    proof
     let n be Nat;

A5:  a< a+dif/(n+1) <= b by A3,Th22;
     reconsider Kn = K.n as non empty closed_interval Subset of REAL by A4;
     Kn = [.a+dif/(n+1),b.] by A4; then
     Kn = [' a+dif/(n+1),b '] by A5,INTEGRA5:def 3; then
A6:  f is_integrable_on (Kn) & f||Kn is bounded by A5,A2,INTEGR24:def 1;

     Kn c= A by A4; then
     Kn c= dom f by A1;
     hence (R_EAL f) is (K1.n)-measurable by A6,MESFUN14:49,MESFUNC6:def 1;
    end; then
    f is (Union K1)-measurable by Th21,MESFUNC6:def 1;
    hence thesis by A4,MESFUNC6:16;
    end;
    suppose a >= b; then
A7:  ].a,b.] = {} by XXREAL_1:26;
     hereby let E be Element of L-Field;
      assume E c= ].a,b.]; then
      E = {} by A7;
      hence f is E-measurable by Th30;
     end;
    end;
end;

theorem Th35:
for a,b be Real, f be PartFunc of REAL,REAL st ].a,b.[ c= dom f &
 f is_improper_integrable_on a,b holds
  for E be Element of L-Field st E c= ].a,b.[ holds f is E-measurable
proof
    let a,b be Real, f be PartFunc of REAL,REAL;
    assume that
A1:  ].a,b.[ c= dom f and
A2:  f is_improper_integrable_on a,b;

    consider c be Real such that
A3:  a < c < b and
A4:  f is_left_improper_integrable_on a,c and
A5:  f is_right_improper_integrable_on c,b and
     not (left_improper_integral(f,a,c) = -infty
        & right_improper_integral(f,c,b) = +infty)
   & not (left_improper_integral(f,a,c) = +infty
        & right_improper_integral(f,c,b) = -infty) by A2,INTEGR24:def 5;

    hereby let E be Element of L-Field;
     assume A6: E c= ].a,b.[;
     ].a,c.] c= ].a,b.[ by A3,XXREAL_1:49; then
A7:  ].a,c.] c= dom f by A1;
     [.c,b.[ c= ].a,b.[ by A3,XXREAL_1:48; then
A8:  [.c,b.[ c= dom f by A1;

     reconsider L = ].a,c.] as Element of L-Field by MEASUR10:5,MEASUR12:75;
A9:  f is (E/\L)-measurable by A7,A4,Th34,XBOOLE_1:17;
     reconsider R = [.c,b.[ as Element of L-Field by MEASUR10:5,MEASUR12:75;
A10:  L\/R = ].a,b.[ by A3,XXREAL_1:172;
A11:  E/\L \/ E/\R = E/\(L\/R) by XBOOLE_1:23
      .= E by A6,A10,XBOOLE_1:28;

     f is (E/\R)-measurable by A8,A5,Th33,XBOOLE_1:17;
     hence f is E-measurable by A11,A9,MESFUNC6:17;
    end;
end;

theorem Th36:
for a be Real, f be PartFunc of REAL,REAL
 st [.a,+infty.[ c= dom f & f is_+infty_improper_integrable_on a holds
 for E be Element of L-Field st E c= [.a,+infty.[ holds f is E-measurable
proof
    let a be Real, f be PartFunc of REAL,REAL;
    assume that
A1:  [.a,+infty.[ c= dom f and
A2:  f is_+infty_improper_integrable_on a;

    set A = [.a,+infty.[;
    reconsider A as Element of L-Field by MEASUR12:72,75;

    consider K be SetSequence of L-Field such that
A3:  (for n be Nat holds K.n = [.a,a+n.]) &
     K is non-descending & K is convergent & Union K = [.a,+infty.[ by Th25;

    rng K c= L-Field; then
    reconsider K1 = K as sequence of L-Field by FUNCT_2:6;

    for n be Nat holds (R_EAL f) is (K1.n)-measurable
    proof
     let n be Nat;
A4:  a<= a+n by XREAL_1:31;

A5:  K.n = [.a,a+n.] by A3; then
     reconsider Kn = K.n as non empty closed_interval Subset of REAL
       by XREAL_1:31,XXREAL_1:30,MEASURE5:def 3;
     Kn = [' a,a+n '] by A5,XREAL_1:31,INTEGRA5:def 3; then
A6:  f is_integrable_on Kn & f||Kn is bounded by A4,A2,INTEGR25:def 2;

     Kn c= A by A5,XXREAL_1:251; then
     Kn c= dom f by A1;
     hence (R_EAL f) is (K1.n)-measurable by A6,MESFUN14:49,MESFUNC6:def 1;
    end; then
    (R_EAL f) is A-measurable by A3,Th21;
    hence thesis by MESFUNC6:def 1,16;
end;

theorem Th37:
for a be Real, f be PartFunc of REAL,REAL
 st ].-infty,a.] c= dom f & f is_-infty_improper_integrable_on a holds
 for E be Element of L-Field st E c= ].-infty,a.] holds f is E-measurable
proof
    let a be Real, f be PartFunc of REAL,REAL;
    assume that
A1:   ].-infty,a.] c= dom f and
A2:  f is_-infty_improper_integrable_on a;

    set A = ].-infty,a.];
    reconsider A as Element of L-Field by MEASUR12:72,75;

    consider K be SetSequence of L-Field such that
A3:  (for n be Nat holds K.n = [.a-n,a.]) &
     K is non-descending & K is convergent & Union K = ].-infty,a.] by Th26;

A4: for n be Element of NAT holds
      K.n is non empty closed_interval Subset of REAL
    proof
     let n be Element of NAT;
     K.n = [.a-n, a.] by A3;
     hence thesis by XREAL_1:43,XXREAL_1:30,MEASURE5:def 3;
    end;

    rng K c= L-Field; then
    reconsider K1 = K as sequence of L-Field by FUNCT_2:6;

    for n be Nat holds (R_EAL f) is (K1.n)-measurable
    proof
     let n be Nat;
A5:  a-n<= a by XREAL_1:43;

     n is Element of NAT by ORDINAL1:def 12; then
     reconsider Kn = K.n as non empty closed_interval Subset of REAL by A4;
A6:  Kn = [.a-n,a.] by A3; then
     Kn = [' a-n,a '] by XREAL_1:43,INTEGRA5:def 3; then
A7:  f is_integrable_on (Kn) & f||Kn is bounded by A5,A2,INTEGR25:def 1;

     Kn c= A by A6,XXREAL_1:265; then
     Kn c= dom f by A1;
     hence (R_EAL f) is (K1.n)-measurable by A7,MESFUN14:49,MESFUNC6:def 1;
    end; then
    (R_EAL f) is (Union K1)-measurable by Th21;
    hence thesis by A3,MESFUNC6:def 1,16;
end;

theorem Th38:
for f be PartFunc of REAL,REAL st dom f = REAL
 & f is_improper_integrable_on_REAL holds
 for E be Element of L-Field holds f is E-measurable
proof
    let f be PartFunc of REAL,REAL;
    assume that
A1:  dom f = REAL and
A2:  f is_improper_integrable_on_REAL;

    reconsider A = [.0,+infty.[, B = ].-infty,0 .] as Element of L-Field
      by MEASUR10:5,MEASUR12:75;
A3: A \/ B = REAL by XXREAL_1:172,224;

    f is_-infty_improper_integrable_on 0
  & f is_+infty_improper_integrable_on 0 by A1,A2,INTEGR25:36; then
    (R_EAL f) is A-measurable & (R_EAL f) is B-measurable
      by A1,Th36,Th37,MESFUNC6:def 1; then
    (R_EAL f) is (A \/ B)-measurable by MESFUNC1:31;
    hence thesis by A3,MESFUNC6:def 1,16;
end;

begin :: Relation between Improper Integral and Lebesgue Integral

theorem Th39:
for X be non empty set, S be SigmaField of X, M be sigma_Measure of S,
 f be PartFunc of X,REAL, A be Element of S
   st A = dom f & f is A-measurable holds Integral(M,-f) = - Integral(M,f)
proof
    let X be non empty set, S be SigmaField of X, M be sigma_Measure of S,
    f be PartFunc of X,REAL, A be Element of S;
    assume that
A1:  A = dom f and
A2:  f is A-measurable;
    dom(R_EAL f) = dom f by MESFUNC5:def 7; then
    Integral(M,-(R_EAL f)) = -Integral(M,R_EAL f)
      by A1,A2,MESFUNC6:def 1,MESFUN11:52; then
    Integral(M,R_EAL(-f)) = - Integral(M,R_EAL f) by MESFUNC6:28; then
    Integral(M,-f) = - Integral(M,R_EAL f) by MESFUNC6:def 3;
    hence Integral(M,-f) = - Integral(M,f) by MESFUNC6:def 3;
end;

theorem Th40:
for X be non empty set, S be SigmaField of X, M be sigma_Measure of S,
f be PartFunc of X,REAL, A,B,E be Element of S
  st E = dom f & f is E-measurable & f is nonpositive & A c= B
  holds Integral(M,f|A) >= Integral(M,f|B)
proof
    let X be non empty set, S be SigmaField of X, M be sigma_Measure of S,
    f be PartFunc of X,REAL, A,B,E be Element of S;
    assume that
A1:  E = dom f and
A2:  f is E-measurable and
A3:  f is nonpositive and
A4:  A c= B;

A5:  E = dom(R_EAL f) by A1,MESFUNC5:def 7;
A6:  R_EAL f is E-measurable by A2,MESFUNC6:def 1;

     for x be set st x in dom (R_EAL f) holds (R_EAL f).x <= 0
     proof
      let x be set;
      assume x in dom(R_EAL f);
      f.x <= 0 by A3,MESFUNC6:53;
      hence (R_EAL f).x <= 0 by MESFUNC5:def 7;
     end; then
     Integral(M,(R_EAL f)|A) >= Integral(M,(R_EAL f)|B)
       by A5,A6,A4,MESFUNC5:9,MESFUN11:64; then
     Integral(M,R_EAL (f|A)) >= Integral(M,(R_EAL f)|B) by Th16; then
     Integral(M,R_EAL (f|A)) >= Integral(M,R_EAL(f|B)) by Th16; then
     Integral(M,f|A) >= Integral(M,R_EAL(f|B)) by MESFUNC6:def 3;
     hence Integral(M,f|A) >= Integral(M,f|B) by MESFUNC6:def 3;
end;

Lm7:
for f be PartFunc of REAL,REAL, a,b be Real, A be non empty Subset of REAL
 st ].a,b.] c= dom f & A = ].a,b.] & f is_left_improper_integrable_on a,b
 & f|A is nonnegative & not f is_left_ext_Riemann_integrable_on a,b
 holds left_improper_integral(f,a,b) = Integral(L-Meas,f|A)
     & Integral(L-Meas,f|A) = +infty
proof
    let f be PartFunc of REAL,REAL, a,b be Real, A be non empty Subset of REAL;
    assume that
A1:  ].a,b.] c= dom f and
A2:  A = ].a,b.] and
A3:  f is_left_improper_integrable_on a,b and
A4:  f|A is nonnegative and
A5:  not f is_left_ext_Riemann_integrable_on a,b;

A6: for d be Real st a < d & d <= b holds
     f is_integrable_on [' d,b '] & f|[' d,b '] is bounded
      by A3,INTEGR24:def 1;

    reconsider A1 = A as Element of L-Field by A2,MEASUR10:5,MEASUR12:75;

A7: a < b by A2,XXREAL_1:26;
A8: R_EAL f is A1-measurable by A1,A2,A3,Th34,MESFUNC6:def 1;
A9:A1 = dom(f|A1) by A1,A2,RELAT_1:62; then
    A1 = dom f /\ A1 by RELAT_1:61; then
    A1 = dom(R_EAL f) /\ A1 by MESFUNC5:def 7; then
    (R_EAL f)|A1 is A1-measurable by A8,MESFUNC5:42; then
A10: (R_EAL f|A1) is A1-measurable by Th16;

A11: R_EAL(f|A1) is nonnegative by A4,MESFUNC5:def 7;

    A1 = dom(R_EAL(f|A1)) by A9,MESFUNC5:def 7; then
A12: integral+(L-Meas,max-(R_EAL f|A1)) < +infty by A10,A11,MESFUN11:53;

A13: A1 = dom(R_EAL f|A1) by A9,MESFUNC5:def 7;

    consider E be SetSequence of L-Field such that
A14:  (for n be Nat holds E.n = [. a+(b-a)/(n+1), b .] & E.n c= ].a,b.] &
     E.n is non empty closed_interval Subset of REAL) &
     E is non-descending & E is convergent & Union E = ]. a,b .]
       by A2,Th24,XXREAL_1:26;

A15: lim E c= A1 by A14,A2,SETLIM_1:80;

    lim E = Union E by A14,SETLIM_1:80; then
    A1 \ lim E = {} by A14,A2,XBOOLE_1:37; then
    L-Meas.(A1 \ lim E) = 0 by VALUED_0:def 19; then
    consider I be ExtREAL_sequence such that
A16:  for n be Nat holds
      I.n = Integral(L-Meas,(R_EAL f|A)|((Partial_Union E).n)) and
     I is convergent and
A17:  Integral(L-Meas,(R_EAL f|A)) = lim I
       by A10,A13,A12,A14,A15,Th19;

    consider Intf be PartFunc of REAL,REAL such that
A18:  dom Intf = ].a,b.] and
A19:  for x be Real st x in dom Intf holds Intf.x = integral(f,x,b) and
A20:  Intf is_right_convergent_in a or Intf is_right_divergent_to+infty_in a
  or Intf is_right_divergent_to-infty_in a by A3,INTEGR24:def 1;

A21: for x be Real st x in dom Intf holds Intf.x >= 0
    proof
     let x be Real;
     assume A22: x in dom Intf; then
A23:  a < x & x <= b by A18,XXREAL_1:2; then
     reconsider AX = [.x,b.] as non empty closed_interval Subset of REAL
       by XXREAL_1:30,MEASURE5:def 3;
A24:  AX c= ].a,b.] by A23,XXREAL_1:39; then
     AX c= dom f by A1; then
     dom(f|AX) = AX by RELAT_1:62; then
     reconsider f1 = f|AX as Function of AX,REAL by FUNCT_2:def 1,RELSET_1:5;

A25:  AX = ['x,b'] by A23,INTEGRA5:def 3; then
A26:  f1|AX is bounded by A23,A3,INTEGR24:def 1;
     for r be Real st r in AX holds f1.r >= 0
     proof
      let r be Real;
      assume A27: r in AX;
      (f|A).r >= 0 by A4,MESFUNC6:51; then
      f.r >= 0 by A27,A24,A2,FUNCT_1:49;
      hence f1.r >= 0 by A27,FUNCT_1:49;
     end; then
     integral(f1) >= 0 by A26,INTEGRA2:32; then
     integral(f,AX) >= 0 by INTEGRA5:def 2; then
     integral(f,x,b) >= 0 by A23,A25,INTEGRA5:def 4;
     hence Intf.x >= 0 by A19,A22;
    end;

A28:now assume
A29: Intf is_right_divergent_to-infty_in a; then
     consider r be Real such that
A30:  a < r and
A31:  for r1 be Real st r1 < r & a < r1 & r1 in dom Intf holds Intf.r1 < 0
        by LIMFUNC2:12;

     consider r1 be Real such that
A32:  r1< r & a < r1 & r1 in dom Intf by A29,A30,LIMFUNC2:12;

     Intf.r1 < 0 by A31,A32;
     hence contradiction by A21,A32;
    end; then
A33:left_improper_integral(f,a,b) = +infty
      by A3,A18,A19,A5,A6,A20,INTEGR10:def 2,INTEGR24:def 3;

    for g be Real st 0 < g
     ex n be Nat st for m be Nat st n<=m holds g <= I.m
    proof
     let g be Real;
     assume 0 < g;

     consider r be Real such that
A34:   a < r and
A35:   for r1 be Real st r1<r & a<r1 & r1 in dom Intf holds g<Intf.r1
       by A28,A18,A19,A5,A6,A20,INTEGR10:def 2,LIMFUNC2:11;
     consider r1 be Real such that
A36:   r1 < r & a < r1 & r1 in dom Intf
        by A28,A34,A18,A19,A5,A6,A20,INTEGR10:def 2,LIMFUNC2:11;
     g < Intf.r1 by A35,A36; then
A37: g < integral(f,r1,b) by A36,A19;

A38:  a < r1 & r1 <= b by A36,A18,XXREAL_1:2;
A39:  0 < r1 - a & 0 < b-a by A36,A2,XXREAL_1:26,XREAL_1:50;

     consider n be Nat such that
A40:   (b-a)/(r1-a) < n by SEQ_4:3;
     take n;
     thus for m be Nat st n <= m holds g <= I.m
     proof
      let m be Nat;
      assume n <= m; then
      n <= m+1 by NAT_1:13; then
A41:   (b-a)/(r1-a) < 1*(m+1) by A40,XXREAL_0:2;
      (b-a)/(m+1) < 1*(r1-a) by A39,A41,XREAL_1:113; then
A42:  a+(b-a)/(m+1) < r1 by XREAL_1:20;
A43:  a+(b-a)/(m+1) <= b by A7,Th22;

A44:   a < a+(b-a)/(m+1) by A7,Th22; then
A45:   f is_integrable_on ['a+(b-a)/(m+1),b']
    & f|['a+(b-a)/(m+1),b'] is bounded by A43,A3,INTEGR24:def 1;

A46:   ['a+(b-a)/(m+1),b'] = [.a+(b-a)/(m+1),b.] by A43,INTEGRA5:def 3; then
      ['a+(b-a)/(m+1),b'] c= ].a,b.] by A44,XXREAL_1:39; then
A47:   ['a+(b-a)/(m+1),b'] c= dom f by A1;

      r1 in ['a+(b-a)/(m+1),b'] by A38,A42,A46,XXREAL_1:1; then
A48:   integral(f,a+(b-a)/(m+1),b)
       = integral(f,a+(b-a)/(m+1),r1)+integral(f,r1,b)
         by A43,A45,A47,INTEGRA6:17;

      [.a+(b-a)/(m+1),r1.] c= ].a,b.] by A38,A44,XXREAL_1:39; then
A49:  [.a+(b-a)/(m+1),r1.] c= dom f by A1;

A50:  f|[.a+(b-a)/(m+1),r1.] is bounded by A45,A46,A38,XXREAL_1:34,RFUNCT_1:74;

      (f|A)|[.a+(b-a)/(m+1),r1.] is nonnegative by A4,MESFUNC6:55; then
      f|[.a+(b-a)/(m+1),r1.] is nonnegative
        by A2,A38,A44,XXREAL_1:39,RELAT_1:74; then
      integral(f,a+(b-a)/(m+1),r1) >= 0 by A42,A49,A50,Th12; then
A51:   integral(f,r1,b) <= integral(f,a+(b-a)/(m+1),b) by A48,XREAL_1:31;

      (R_EAL f|A)|(E.m) = (f|A)|(E.m) by MESFUNC5:def 7; then
A52:  (R_EAL f|A)|(E.m) = f|(E.m) by A2,A14,RELAT_1:74;

A53:   f||['a+(b-a)/(m+1),b'] is bounded by A44,A43,A3,INTEGR24:def 1;

      I.m = Integral(L-Meas,(R_EAL f|A)|((Partial_Union E).m)) by A16
       .= Integral(L-Meas,(R_EAL f|A)|(E.m)) by A14,PROB_4:15
       .= Integral(L-Meas,(R_EAL f|(E.m))) by A52,MESFUNC5:def 7
       .= Integral(L-Meas,f|(E.m)) by MESFUNC6:def 3
       .= Integral(L-Meas,f|[.a+(b-a)/(m+1),b.]) by A14
       .= integral(f,a+(b-a)/(m+1),b) by A53,A43,A45,A46,A47,MESFUN14:50;
      hence g <= I.m by A51,A37,XXREAL_0:2;
     end;
    end; then
    I is convergent_to_+infty by MESFUNC5:def 9; then
A54:Integral(L-Meas,R_EAL f|A) = +infty by A17,MESFUNC5:def 12;
    hence left_improper_integral(f,a,b) = Integral(L-Meas,f|A)
      by A33,MESFUNC6:def 3;
    thus Integral(L-Meas,f|A) = +infty by A54,MESFUNC6:def 3;
end;

Lm8:
for f be PartFunc of REAL,REAL, a,b be Real, A be non empty Subset of REAL
 st [.a,b.[ c= dom f & A = [.a,b.[ & f is_right_improper_integrable_on a,b
 & f|A is nonnegative & not f is_right_ext_Riemann_integrable_on a,b
 holds right_improper_integral(f,a,b) = Integral(L-Meas,f|A)
     & Integral(L-Meas,f|A) = +infty
proof
    let f be PartFunc of REAL,REAL, a,b be Real, A be non empty Subset of REAL;
    assume that
A1:  [.a,b.[ c= dom f and
A2:  A = [.a,b.[ and
A3:  f is_right_improper_integrable_on a,b and
A4:  f|A is nonnegative and
A5:  not f is_right_ext_Riemann_integrable_on a,b;

A6: for d be Real st a <= d & d < b holds
     f is_integrable_on [' a,d '] & f|[' a,d '] is bounded
      by A3,INTEGR24:def 2;

    reconsider A1 = A as Element of L-Field by A2,MEASUR10:5,MEASUR12:75;

A7: a < b by A2,XXREAL_1:27;

A8: R_EAL f is A1-measurable by A1,A2,A3,Th33,MESFUNC6:def 1;
A9:A1 = dom(f|A1) by A1,A2,RELAT_1:62; then
    A1 = dom f /\ A1 by RELAT_1:61; then
    A1 = dom(R_EAL f) /\ A1 by MESFUNC5:def 7; then
    (R_EAL f)|A1 is A1-measurable by A8,MESFUNC5:42; then
A10: (R_EAL f|A1) is A1-measurable by Th16;

A11: R_EAL(f|A1) is nonnegative by A4,MESFUNC5:def 7;

    A1 = dom(R_EAL(f|A1)) by A9,MESFUNC5:def 7; then
A12: integral+(L-Meas,max-(R_EAL f|A1)) < +infty by A10,A11,MESFUN11:53;

A13: A1 = dom(R_EAL f|A1) by A9,MESFUNC5:def 7;

    consider E be SetSequence of L-Field such that
A14: (for n be Nat holds E.n = [. a, b-(b-a)/(n+1) .] & E.n c= [.a,b.[ &
      E.n is non empty closed_interval Subset of REAL) &
     E is non-descending &
     E is convergent &
     Union E = [. a,b .[ by A2,XXREAL_1:27,Th23;

A15: lim E = Union E by A14,SETLIM_1:80; then
    A1 \ lim E = {} by A14,A2,XBOOLE_1:37; then
    L-Meas.(A1 \ lim E) = 0 by VALUED_0:def 19; then
    consider I be ExtREAL_sequence such that
A16:  for n be Nat holds
      I.n = Integral(L-Meas,(R_EAL f|A)|((Partial_Union E).n)) and
     I is convergent and
A17:  Integral(L-Meas,(R_EAL f|A)) = lim I by A10,A13,A12,A14,A15,A2,Th19;

    consider Intf be PartFunc of REAL,REAL such that
A18:  dom Intf = [.a,b.[ and
A19:  for x be Real st x in dom Intf holds Intf.x = integral(f,a,x) and
A20:  Intf is_left_convergent_in b or Intf is_left_divergent_to+infty_in b
  or Intf is_left_divergent_to-infty_in b by A3,INTEGR24:def 2;

A21: for x be Real st x in dom Intf holds Intf.x >= 0
    proof
     let x be Real;
     assume A22: x in dom Intf; then
A23:  a <= x & x < b by A18,XXREAL_1:3; then
     reconsider AX = [.a,x.] as non empty closed_interval Subset of REAL
       by XXREAL_1:30,MEASURE5:def 3;
A24:  AX c= [.a,b.[ by A23,XXREAL_1:43; then
     AX c= dom f by A1; then
     dom(f|AX) = AX by RELAT_1:62; then
     reconsider f1 = f|AX as Function of AX,REAL by FUNCT_2:def 1,RELSET_1:5;

A25:  AX = ['a,x'] by A23,INTEGRA5:def 3; then
A26:  f1|AX is bounded by A23,A3,INTEGR24:def 2;
     for r be Real st r in AX holds f1.r >= 0
     proof
      let r be Real;
      assume A27: r in AX;
      (f|A).r >= 0 by A4,MESFUNC6:51; then
      f.r >= 0 by A27,A24,A2,FUNCT_1:49;
      hence f1.r >= 0 by A27,FUNCT_1:49;
     end; then
     integral(f1) >= 0 by A26,INTEGRA2:32; then
     integral(f,AX) >= 0 by INTEGRA5:def 2; then
     integral(f,a,x) >= 0 by A23,A25,INTEGRA5:def 4;
     hence Intf.x >= 0 by A19,A22;
    end;

A28:now assume A29: Intf is_left_divergent_to-infty_in b; then
     consider r be Real such that
A30:  r < b and
A31:  for r1 be Real st r < r1 & r1 < b & r1 in dom Intf holds Intf.r1 < 0
        by LIMFUNC2:9;

     consider r1 be Real such that
A32:  r < r1 & r1 < b & r1 in dom Intf by A29,A30,LIMFUNC2:9;

     Intf.r1 < 0 by A31,A32;
     hence contradiction by A21,A32;
    end; then
A33:right_improper_integral(f,a,b) = +infty
      by A3,A18,A19,A20,A5,A6,INTEGR10:def 1,INTEGR24:def 4;

    for g be Real st 0 < g
     ex n be Nat st for m be Nat st n<=m holds g <= I.m
    proof
     let g be Real;
     assume 0 < g;

     consider r be Real such that
A34:   r < b and
A35:   for r1 be Real st r<r1 & r1<b & r1 in dom Intf holds g<Intf.r1
       by A28,A18,A19,A20,A5,A6,INTEGR10:def 1,LIMFUNC2:8;
     consider r1 be Real such that
A36:   r < r1 & r1 < b & r1 in dom Intf
       by A28,A34,A18,A19,A20,A5,A6,INTEGR10:def 1,LIMFUNC2:8;
     g < Intf.r1 by A35,A36; then
A37: g < integral(f,a,r1) by A36,A19;

A38:  a <= r1 & r1 < b by A36,A18,XXREAL_1:3;
A39:  0 < b - r1 & 0 < b-a by A36,A2,XXREAL_1:27,XREAL_1:50;

     consider n be Nat such that
A40:   (b-a)/(b-r1) < n by SEQ_4:3;
     take n;
     thus for m be Nat st n <= m holds g <= I.m
     proof
      let m be Nat;
      assume n <= m; then
      n <= m+1 by NAT_1:13; then
      (b-a)/(b-r1) < 1*(m+1) by A40,XXREAL_0:2; then
      (b-a)/(m+1) < 1*(b-r1) by A39,XREAL_1:113; then
      r1+(b-a)/(m+1) < b by XREAL_1:20; then
A41:   r1 < b-(b-a)/(m+1) by XREAL_1:20;
A42:  a <= b-(b-a)/(m+1) by A7,Th22;

A43:   b-(b-a)/(m+1) < b by A7,Th22; then
A44:   f is_integrable_on ['a,b-(b-a)/(m+1)']
    & f|['a,b-(b-a)/(m+1)'] is bounded by A42,A3,INTEGR24:def 2;

A45:   ['a,b-(b-a)/(m+1)'] = [.a,b-(b-a)/(m+1).] by A42,INTEGRA5:def 3; then
      ['a,b-(b-a)/(m+1)'] c= [.a,b.[ by A43,XXREAL_1:43; then
A46:   ['a,b-(b-a)/(m+1)'] c= dom f by A1;

      r1 in ['a,b-(b-a)/(m+1)'] by A38,A41,A45,XXREAL_1:1; then
A47:   integral(f,a,b-(b-a)/(m+1))
       = integral(f,a,r1)+integral(f,r1,b-(b-a)/(m+1))
         by A42,A44,A46,INTEGRA6:17;

      [.r1,b-(b-a)/(m+1).] c= [.a,b.[ by A38,A43,XXREAL_1:43; then
A48:  [.r1,b-(b-a)/(m+1).] c= dom f by A1;

A49:  f|[.r1,b-(b-a)/(m+1).] is bounded by A44,A45,A38,XXREAL_1:34,RFUNCT_1:74;

      (f|A)|[.r1,b-(b-a)/(m+1).] is nonnegative by A4,MESFUNC6:55; then
      f|[.r1,b-(b-a)/(m+1).] is nonnegative
        by A2,A38,A43,XXREAL_1:43,RELAT_1:74; then
      integral(f,r1,b-(b-a)/(m+1)) >= 0 by A41,A48,A49,Th12; then
A50:   integral(f,a,r1) <= integral(f,a,b-(b-a)/(m+1)) by A47,XREAL_1:31;

      (R_EAL f|A)|(E.m) = (f|A)|(E.m) by MESFUNC5:def 7; then
A51:   (R_EAL f|A)|(E.m) = f|(E.m) by A2,A14,RELAT_1:74;

A52:   f||['a,b-(b-a)/(m+1)'] is bounded by A43,A42,A3,INTEGR24:def 2;

      I.m = Integral(L-Meas,(R_EAL f|A)|((Partial_Union E).m)) by A16
       .= Integral(L-Meas,(R_EAL f|A)|(E.m)) by A14,PROB_4:15
       .= Integral(L-Meas,(R_EAL f|(E.m))) by A51,MESFUNC5:def 7
       .= Integral(L-Meas,f|(E.m)) by MESFUNC6:def 3
       .= Integral(L-Meas,f|[.a,b-(b-a)/(m+1).]) by A14
       .= integral(f,a,b-(b-a)/(m+1)) by A52,A42,A44,A45,A46,MESFUN14:50;
      hence g <= I.m by A37,A50,XXREAL_0:2;
     end;
    end; then
    I is convergent_to_+infty by MESFUNC5:def 9; then
A53:lim I = +infty by MESFUNC5:def 12;
    hence right_improper_integral(f,a,b) = Integral(L-Meas,f|A)
      by A33,A17,MESFUNC6:def 3;
    thus Integral(L-Meas,f|A) = +infty by A17,A53,MESFUNC6:def 3;
end;

theorem Th41:
for f be PartFunc of REAL,REAL, a,b be Real, A be non empty Subset of REAL
 st [.a,b.[ c= dom f & A = [.a,b.[ & f is_right_improper_integrable_on a,b
 & f|A is nonnegative
 holds right_improper_integral(f,a,b) = Integral(L-Meas,f|A)
  & (f is_right_ext_Riemann_integrable_on a,b
      implies f|A is_integrable_on L-Meas)
  & (not f is_right_ext_Riemann_integrable_on a,b
      implies Integral(L-Meas,f|A) = +infty)
proof
    let f be PartFunc of REAL,REAL, a,b be Real, A be non empty Subset of REAL;
    assume that
A1:  [.a,b.[ c= dom f and
A2:  A = [.a,b.[ and
A3:  f is_right_improper_integrable_on a,b and
A4:  f|A is nonnegative;

    reconsider A1 = A as Element of L-Field by A2,MEASUR10:5,MEASUR12:75;

A5: a < b by A2,XXREAL_1:27;

    per cases;
    suppose
A6:  f is_right_ext_Riemann_integrable_on a,b; then
A7:  right_improper_integral(f,a,b) = ext_right_integral(f,a,b)
       by A3,INTEGR24:39;

     consider Intf be PartFunc of REAL,REAL such that
A8:   dom Intf = [.a,b.[ and
A9:   for x be Real st x in dom Intf holds Intf.x = integral(f,a,x) and
A10:   Intf is_left_convergent_in b and
A11:   ext_right_integral(f,a,b) = lim_left(Intf,b)
        by A6,INTEGR10:def 3;

A12:  for p,q be Real st p in dom Intf & q in dom Intf & p < q holds
      Intf.p <= Intf.q
     proof
      let p,q be Real;
      assume that
A13:    p in dom Intf and
A14:    q in dom Intf and
A15:    p < q;

A16:   a <= q < b by A8,A14,XXREAL_1:3; then
      [.a,q.] c= [.a,b.[ by XXREAL_1:43; then
A17:   [.a,q.] c= dom f by A1;
A18:  [.a,q.] = ['a,q'] by A16,INTEGRA5:def 3;
A19:   a <= p by A8,A13,XXREAL_1:3;
A20:   f is_integrable_on ['a,q'] & f|['a,q'] is bounded
        by A6,A16,INTEGR10:def 1;
      (f|A)|[.a,q.] is nonnegative by A4,MESFUNC6:55; then
A21:   f|[.a,q.] is nonnegative by A16,A2,XXREAL_1:43,RELAT_1:74;
A22:   [.a,p.] c= [.a,q.] by A15,XXREAL_1:34;
      Intf.p = integral(f,a,p) & Intf.q = integral(f,a,q) by A13,A14,A9;
      hence Intf.p <= Intf.q by A17,A20,A21,A22,A19,A18,Th14;
     end; then
A23: Intf is non-decreasing by RFUNCT_2:def 3;

     consider E be SetSequence of L-Field such that
A24:   (for n be Nat holds E.n = [. a, b-(b-a)/(n+1) .] & E.n c= [.a,b.[ &
        E.n is non empty closed_interval Subset of REAL) &
      E is non-descending & E is convergent & Union E = [. a,b .[
        by A2,Th23,XXREAL_1:27;

A25: A1 = dom(f|A1) by A1,A2,RELAT_1:62; then
A26:  A1 = dom(R_EAL(f|A)) by MESFUNC5:def 7;

A27: lim E = Union E by A24,SETLIM_1:80;
A28:  lim E c= A1 by A24,A2,SETLIM_1:80;

     A1 \ lim E = {} by A24,A2,A27,XBOOLE_1:37; then
A29:  L-Meas.(A1 \ lim E) = 0 by VALUED_0:def 19;

A30:  R_EAL f is A1-measurable by A1,A2,A3,Th33,MESFUNC6:def 1;

     A1 = dom f /\ A1 by A25,RELAT_1:61; then
     A1 = dom(R_EAL f) /\ A1 by MESFUNC5:def 7; then
     (R_EAL f)|A is A1-measurable by A30,MESFUNC5:42; then
A31:  R_EAL(f|A) is A1-measurable by Th16;
A32: R_EAL (f|A) is nonnegative by A4,MESFUNC5:def 7; then
A33: integral+(L-Meas,max-(R_EAL(f|A))) < +infty by A31,A26,MESFUN11:53;

     consider I be ExtREAL_sequence such that
A34:  for n be Nat holds
       I.n = Integral(L-Meas,(R_EAL(f|A))|((Partial_Union E).n)) and
      I is convergent and
A35:   Integral(L-Meas,R_EAL(f|A)) = lim I by A24,A31,A26,A28,A29,A33,Th19;

A36: for x be Real st x in dom Intf holds Intf.x = Integral(L-Meas,f|[.a,x.])
     proof
      let x be Real;
      assume A37: x in dom Intf; then
A38:   a <= x < b by A8,XXREAL_1:3; then
A39:   f is_integrable_on ['a,x'] & f|['a,x'] is bounded by A3,INTEGR24:def 2;
      reconsider AX = [.a,x.] as non empty closed_interval Subset of REAL
        by A38,XXREAL_1:30,MEASURE5:def 3;
A40:  AX = ['a,x'] by A38,INTEGRA5:def 3;
      AX c= [.a,b.[ by A38,XXREAL_1:43; then
A41:  AX c= dom f by A1;

      reconsider AX1 = AX as Element of L-Field by MEASUR10:5,MEASUR12:75;
      AX = AX1; then
      integral(f||AX) = Integral(L-Meas,f|[.a,x.])
        by A39,A40,A41,MESFUN14:49; then
      integral(f,AX) = Integral(L-Meas,f|[.a,x.]) by INTEGRA5:def 2; then
      integral(f,a,x) = Integral(L-Meas,f|[.a,x.]) by A38,A40,INTEGRA5:def 4;
      hence Intf.x = Integral(L-Meas,f|[.a,x.]) by A9,A37;
     end;

A42: Partial_Union E = E by A24,PROB_4:15;

A43: for m be Nat holds I.m = integral(f,a,b-(b-a)/(m+1))
     proof
      let m be Nat;
A44:  a <= b-(b-a)/(m+1) < b by A5,Th22; then
A45:  f||['a,b-(b-a)/(m+1)'] is bounded by A6,INTEGR10:def 1;

A46:   ['a,b-(b-a)/(m+1)'] = [.a,b-(b-a)/(m+1).] by A44,INTEGRA5:def 3; then
      ['a,b-(b-a)/(m+1)'] c= [.a,b.[ by A44,XXREAL_1:43; then
A47:   ['a,b-(b-a)/(m+1)'] c= dom f by A1;

A48:  E.m = [.a,b-(b-a)/(m+1).] by A24;

      (R_EAL f|A)|(E.m) = (f|A)|(E.m) by MESFUNC5:def 7; then
      (R_EAL f|A)|(E.m) = f|(E.m) by A2,A24,RELAT_1:74; then
A49:   (R_EAL f|A)|(E.m) = R_EAL f|(E.m) by MESFUNC5:def 7;

      I.m = Integral(L-Meas,(R_EAL(f|A))|((Partial_Union E).m)) by A34; then
A50:   I.m = Integral(L-Meas,f|[.a,b-(b-a)/(m+1).])
        by A49,A42,A48,MESFUNC6:def 3;
      f is_integrable_on ['a,b-(b-a)/(m+1)'] by A44,A6,INTEGR10:def 1;
      hence I.m = integral(f,a,b-(b-a)/(m+1)) by A50,A44,A46,A47,A45
,MESFUN14:50;
     end;

     for p be Real st 0<p ex n be Nat st for m be Nat st n<=m
      holds |.I.m-ext_right_integral(f,a,b) qua ExtReal.|<p
     proof
      let p be Real;
      assume 0<p; then
      consider r be Real such that
A51:    r < b and
A52:    for r1 be Real st r<r1 & r1<b & r1 in dom Intf holds
        |.Intf.r1-lim_left(Intf,b).| < p by A10,LIMFUNC2:41;
      set rr = max(a,r);
A53:  a <= rr & r<= rr by XXREAL_0:25;
      rr < b by A5,A51,XXREAL_0:29; then
A54:   0 < b-rr by XREAL_1:50;

      consider n be Nat such that
A55:    (b-a)/(b-rr) < n by SEQ_4:3;
      n <= n+1 by NAT_1:13; then
      (b-a)/(b-rr) < 1*(n+1) by A55,XXREAL_0:2; then
      (b-a)/(n+1) < 1*(b-rr) by A54,XREAL_1:113; then
      rr+(b-a)/(n+1) < b by XREAL_1:20; then
      rr < b-(b-a)/(n+1) by XREAL_1:20; then
A56:   r < b-(b-a)/(n+1) by A53,XXREAL_0:2;

A57:  0 < b-a by A2,XXREAL_1:27,XREAL_1:50;

A58:  a <= b-(b-a)/(n+1) < b by A5,Th22; then
A59:  b-(b-a)/(n+1) in dom Intf by A8,XXREAL_1:3;
      set r1=b-(b-a)/(n+1);
A60:  |.Intf.r1-lim_left(Intf,b).| < p by A52,A56,A59,A58;

      take n;
      thus for m be Nat st n<=m holds
       |.I.m - ext_right_integral(f,a,b) qua ExtReal.|<p
      proof
       let m be Nat;
       set rm = b-(b-a)/(m+1);
       assume n<=m; then
       n+1 <= m+1 by XREAL_1:6; then
       (b-a)/(n+1) >= (b-a)/(m+1) by A57,XREAL_1:118; then
A61:   b-(b-a)/(n+1) <= b-(b-a)/(m+1) by XREAL_1:10;
A62:    a <= rm by A5,Th22;

A63:   rm < b by A57,XREAL_1:44; then
       [.a,rm.] c= [.a,b.[ by XXREAL_1:43; then
A64:    [.a,rm.] c= dom f by A1;

       f|['a,rm'] is bounded by A62,A63,A3,INTEGR24:def 2; then
A65:    f|[.a,rm.] is bounded by A61,A58,XXREAL_0:2,INTEGRA5:def 3;

A66:    f is_integrable_on ['a,rm'] by A62,A63,A3,INTEGR24:def 2;
       (f|A)|[.a,rm.] is nonnegative by A4,MESFUNC6:55; then
A67:    f|[.a,rm.] is nonnegative by A63,A2,XXREAL_1:43,RELAT_1:74;
       [.a,r1.] c= [.a,rm.] by A61,XXREAL_1:34; then
       integral(f,a,r1) <= integral(f,a,rm) by A58,A64,A65,A66,A67,Th14; then
       Intf.r1 <= integral(f,a,rm) by A9,A58,A8,XXREAL_1:3; then
A68:   Intf.r1 <= I.m by A43;

A69:   rm in dom Intf by A8,A62,A63,XXREAL_1:3;

       Intf.rm = integral(f,a,b-(b-a)/(m+1)) by A9,A8,A62,A63,XXREAL_1:3; then
       I.m = Intf.rm by A43; then
       I.m <= lim_left(Intf,b) by A10,A23,A69,Th6,A57,XREAL_1:44; then
A70:   lim_left(Intf,b) - I.m >= 0 by XXREAL_3:40; then
       -(lim_left(Intf,b) - I.m) <= 0; then
       I.m - ext_right_integral(f,a,b) <= 0 by A11,XXREAL_3:26; then
A71:   |.I.m-ext_right_integral(f,a,b).|
        = -(I.m - ext_right_integral(f,a,b)) by EXTREAL1:18
       .= ext_right_integral(f,a,b)-I.m by XXREAL_3:26;

       reconsider EX = ext_right_integral(f,a,b) as ExtReal;
A72:   EX - Intf.r1
        = EX + -((Intf.r1) qua ExtReal) by XXREAL_3:def 4
       .= ext_right_integral(f,a,b) + (-Intf.r1) by XXREAL_3:def 2
       .= ext_right_integral(f,a,b) - Intf.r1;

A73:   EX - I.m <= EX - Intf.r1 by A68,XXREAL_3:37; then
       -(ext_right_integral(f,a,b)-Intf.r1) <= 0 by A72,A70,A11; then
       |.Intf.r1 - ext_right_integral(f,a,b).|
        = -(Intf.r1 - ext_right_integral(f,a,b)) by ABSVALUE:30
       .= ext_right_integral(f,a,b) - Intf.r1;
       hence |.I.m - ext_right_integral(f,a,b) qua ExtReal.| < p
         by A60,A11,A72,A73,A71,XXREAL_0:2;
      end;
     end; then
     consider RI be Real such that
A74:   lim I = RI &
      for p be Real st 0<p ex n be Nat st for m be Nat st n<=m holds
       |.I.m-lim I.|< p by MESFUNC5:def 8,MESFUNC9:7;
A75:  RI = Integral(L-Meas,f|A) by A35,A74,MESFUNC6:def 3;

     for g1 be Real st 0 < g1 ex R be Real st R<b & for r1 be Real st R<r1 &
     r1<b & r1 in dom Intf holds |.Intf.r1-RI.|<g1
     proof
      let g1 be Real;
      assume A76: 0 < g1;
      set g2 = g1/2;

      consider N be Nat such that
A77:    for m be Nat st N <= m holds |.I.m - lim I.| < g1 by A76,A74;
      take R = b-(b-a)/(N+1);
A78:  a <= R < b by A5,Th22; then
A79:   R in dom Intf by A8,XXREAL_1:3;

      thus R < b by A5,Th22;
      thus for r1 be Real st R<r1 & r1<b & r1 in dom Intf holds
            |. Intf.r1 - RI .| < g1
      proof
       let r1 be Real;
       assume that
A80:     R < r1 and
A81:     r1 < b and
A82:     r1 in dom Intf;

       I.N = integral(f,a,b-(b-a)/(N+1)) by A43; then
       Intf.R = I.N by A78,A9,A8,XXREAL_1:3; then
A83:    I.N <= Intf.r1 by A80,A79,A82,A12;
       RI - I.N = RI qua ExtReal - I.N &
       RI - Intf.r1 = RI qua ExtReal - Intf.r1; then
A84:  RI - Intf.r1 <= RI - I.N by A83,XXREAL_3:37;

A85:  |. I.N - RI .| < g1 by A77,A74;

       reconsider A2 = [.a,r1.] as Element of L-Field
         by MEASUR10:5,MEASUR12:75;

       A2 c= A1 by A2,A81,XXREAL_1:43; then
       Integral(L-Meas,(f|A)|A2) <= Integral(L-Meas,(f|A)|A1)
         by A4,A25,A31,MESFUNC6:def 1,87; then
       Integral(L-Meas,f|A2) <= RI by A75,A2,A81,XXREAL_1:43,RELAT_1:74; then
A86:  Intf.r1 <= RI by A82,A36; then
A87:  |.Intf.r1 - RI.| = -(Intf.r1 - RI) by ABSVALUE:30,XREAL_1:47;

       I.N <= RI by A83,A86,XXREAL_0:2; then
       |.RI - I.N.| = RI - I.N by XXREAL_3:40,EXTREAL1:def 1; then
       |.-(RI - I.N).| = RI - I.N by EXTREAL1:29; then
       |.I.N - RI.| = RI - I.N by XXREAL_3:26;
       hence |.Intf.r1 - RI.| < g1 by A84,A87,A85,XXREAL_0:2;
      end;
     end;
     hence right_improper_integral(f,a,b) = Integral(L-Meas,f|A)
        by A11,A7,A75,A10,LIMFUNC2:41;

     max+(R_EAL(f|A)) = R_EAL(f|A) by A32,MESFUN11:31; then
     Integral(L-Meas,f|A) = integral+(L-Meas,max+(R_EAL(f|A)))
       by A4,A31,A25,MESFUNC6:def 1,82; then
     integral+(L-Meas,max+(R_EAL(f|A))) < +infty
       by A75,XREAL_0:def 1,XXREAL_0:9;
     hence f is_right_ext_Riemann_integrable_on a,b
      implies f|A is_integrable_on L-Meas
        by A31,A26,A33,MESFUNC5:def 17,MESFUNC6:def 4;

     thus not f is_right_ext_Riemann_integrable_on a,b
      implies Integral(L-Meas,f|A) = +infty by A6;
    end;
    suppose
A88:  not f is_right_ext_Riemann_integrable_on a,b;
     hence right_improper_integral(f,a,b) = Integral(L-Meas,f|A)
       by A1,A2,A3,A4,Lm8;
     thus f is_right_ext_Riemann_integrable_on a,b
      implies f|A is_integrable_on L-Meas by A88;
     thus not f is_right_ext_Riemann_integrable_on a,b
      implies Integral(L-Meas,f|A) = +infty by A1,A2,A3,A4,Lm8;
    end;
end;

theorem
for f be PartFunc of REAL,REAL, a,b be Real, A be non empty Subset of REAL
 st [.a,b.[ c= dom f & A = [.a,b.[ & f is_right_improper_integrable_on a,b
 & f|A is nonpositive
 holds right_improper_integral(f,a,b) = Integral(L-Meas,f|A)
  & (f is_right_ext_Riemann_integrable_on a,b
      implies f|A is_integrable_on L-Meas)
  & (not f is_right_ext_Riemann_integrable_on a,b
      implies Integral(L-Meas,f|A) = -infty)
proof
    let f be PartFunc of REAL,REAL, a,b be Real, A be non empty Subset of REAL;
    assume that
A1:  [.a,b.[ c= dom f and
A2:  A = [.a,b.[ and
A3:  f is_right_improper_integrable_on a,b and
A4:  f|A is nonpositive;

    -(f|A) is nonnegative by A4,Th5; then
A5: (-f)|A is nonnegative by RFUNCT_1:46;

A6: dom(-f) = dom f by VALUED_1:8;

A7: a < b by A2,XXREAL_1:27; then
A8: -f is_right_improper_integrable_on a,b by A3,A1,INTEGR24:56; then
    right_improper_integral(-f,a,b) = Integral(L-Meas,(-f)|A)
      by A1,A6,A2,A5,Th41; then
    -right_improper_integral(f,a,b) = Integral(L-Meas,(-f)|A)
      by A3,A7,A1,INTEGR24:56; then
A9: right_improper_integral(f,a,b) = -Integral(L-Meas,(-f)|A);

    reconsider A1 = A as Element of L-Field by A2,MEASUR10:5,MEASUR12:75;

A10: A1 = dom(f|A) by A1,A2,RELAT_1:62; then
A11: A1 = dom f /\ A1 by RELAT_1:61;

A12: dom(R_EAL(f|A)) = A1 by A10,MESFUNC5:def 7;
    f is A1-measurable by A1,A2,A3,Th33; then
A13: R_EAL(f|A) is A1-measurable by A11,MESFUNC6:def 1,76;

A14: R_EAL((-f)|A) = R_EAL -(f|A) by RFUNCT_1:46
     .= -R_EAL(f|A) by MESFUNC6:28;

A15: Integral(L-Meas,(-f)|A)
      = Integral(L-Meas,-R_EAL(f|A)) by A14,MESFUNC6:def 3
     .= -Integral(L-Meas,R_EAL(f|A)) by A12,A13,MESFUN11:52
     .= -Integral(L-Meas,f|A) by MESFUNC6:def 3;
    hence right_improper_integral(f,a,b) = Integral(L-Meas,f|A) by A9;
    hereby assume f is_right_ext_Riemann_integrable_on a,b; then
     (-1)(#)f is_right_ext_Riemann_integrable_on a,b by A1,INTEGR24:31; then
     -f is_right_ext_Riemann_integrable_on a,b by VALUED_1:def 6; then
     (-f)|A is_integrable_on L-Meas by A6,A1,A2,A8,A5,Th41; then
     -(f|A) is_integrable_on L-Meas by RFUNCT_1:46; then
     (-1)(#)(-(f|A)) is_integrable_on L-Meas by MESFUNC6:102;
     hence f|A is_integrable_on L-Meas;
    end;
    hereby assume not f is_right_ext_Riemann_integrable_on a,b; then
A16:  Integral(L-Meas,f|A) = +infty or Integral(L-Meas,f|A) = -infty
       by A9,A15,A3,INTEGR24:39;

     R_EAL(f|A) is nonpositive by A4,MESFUNC5:def 7; then
     Integral(L-Meas,R_EAL(f|A)) <= 0 by A13,A12,MESFUN11:61;
     hence Integral(L-Meas,f|A) = -infty by A16,MESFUNC6:def 3;
    end;
end;

theorem Th43:
for f be PartFunc of REAL,REAL, a,b be Real, A be non empty Subset of REAL
 st ].a,b.] c= dom f & A = ].a,b.] & f is_left_improper_integrable_on a,b
 & f|A is nonnegative
 holds left_improper_integral(f,a,b) = Integral(L-Meas,f|A)
  & (f is_left_ext_Riemann_integrable_on a,b
      implies f|A is_integrable_on L-Meas)
  & (not f is_left_ext_Riemann_integrable_on a,b
      implies Integral(L-Meas,f|A) = +infty)
proof
    let f be PartFunc of REAL,REAL, a,b be Real, A be non empty Subset of REAL;
    assume that
A1:  ].a,b.] c= dom f and
A2:  A = ].a,b.] and
A3:  f is_left_improper_integrable_on a,b and
A4:  f|A is nonnegative;

    reconsider A1 = A as Element of L-Field by A2,MEASUR10:5,MEASUR12:75;

A5: a < b by A2,XXREAL_1:26;

    per cases;
    suppose
A6:  f is_left_ext_Riemann_integrable_on a,b; then
A7:  left_improper_integral(f,a,b) = ext_left_integral(f,a,b)
       by A3,INTEGR24:34;

     consider Intf be PartFunc of REAL,REAL such that
A8:   dom Intf = ].a,b.] and
A9:   for x be Real st x in dom Intf holds Intf.x = integral(f,x,b) and
A10:   Intf is_right_convergent_in a and
A11:   ext_left_integral(f,a,b) = lim_right(Intf,a)
        by A6,INTEGR10:def 4;

A12:  for p,q be Real st p in dom Intf & q in dom Intf & p < q holds
      Intf.q <= Intf.p
     proof
      let p,q be Real;
      assume that
A13:    p in dom Intf and
A14:    q in dom Intf and
A15:    p < q;

A16:   a < p <= b by A8,A13,XXREAL_1:2; then
      [.p,b.] c= ].a,b.] by XXREAL_1:39; then
A17:   [.p,b.] c= dom f by A1;
A18:  [.p,b.] = ['p,b'] by A16,INTEGRA5:def 3;
A19:   q <= b by A8,A14,XXREAL_1:2;
A20:   f is_integrable_on ['p,b'] & f|['p,b'] is bounded
        by A6,A16,INTEGR10:def 2;
      (f|A)|[.p,b.] is nonnegative by A4,MESFUNC6:55; then
A21:   f|[.p,b.] is nonnegative by A2,A16,XXREAL_1:39,RELAT_1:74;
A22:   [.q,b.] c= [.p,b.] by A15,XXREAL_1:34;
      Intf.p = integral(f,p,b) & Intf.q = integral(f,q,b) by A13,A14,A9;
      hence Intf.q <= Intf.p by A17,A20,A21,A22,A19,A18,Th14;
     end; then
A23: Intf is non-increasing by RFUNCT_2:def 4;

     consider E be SetSequence of L-Field such that
A24:   (for n be Nat holds E.n = [. a+(b-a)/(n+1), b .] & E.n c= ].a,b.] &
      E.n is non empty closed_interval Subset of REAL) &
      E is non-descending & E is convergent & Union E = ]. a,b .]
        by A2,Th24,XXREAL_1:26;

A25: A1 = dom(f|A1) by A1,A2,RELAT_1:62; then
A26:  A1 = dom(R_EAL(f|A)) by MESFUNC5:def 7;

A27: lim E = Union E by A24,SETLIM_1:80;
A28:  lim E c= A1 by A24,A2,SETLIM_1:80;

     A1 \ lim E = {} by A24,A2,A27,XBOOLE_1:37; then
A29:  L-Meas.(A1 \ lim E) = 0 by VALUED_0:def 19;

A30:  R_EAL f is A1-measurable by A1,A2,A3,Th34,MESFUNC6:def 1;

     A1 = dom f /\ A1 by A25,RELAT_1:61; then
     A1 = dom(R_EAL f) /\ A1 by MESFUNC5:def 7; then
     (R_EAL f)|A is A1-measurable by A30,MESFUNC5:42; then
A31:  R_EAL(f|A) is A1-measurable by Th16;

A32: R_EAL (f|A) is nonnegative by A4,MESFUNC5:def 7; then
A33: integral+(L-Meas,max-(R_EAL(f|A))) < +infty by A31,A26,MESFUN11:53;

     consider I be ExtREAL_sequence such that
A34:  for n be Nat holds
       I.n = Integral(L-Meas,(R_EAL(f|A))|((Partial_Union E).n)) and
      I is convergent and
A35:   Integral(L-Meas,R_EAL(f|A)) = lim I by A24,A31,A26,A28,A29,A33,Th19;

A36: for x be Real st x in dom Intf holds Intf.x = Integral(L-Meas,f|[.x,b.])
     proof
      let x be Real;
      assume A37: x in dom Intf; then
A38:   a < x <= b by A8,XXREAL_1:2; then
A39:   f is_integrable_on ['x,b'] & f|['x,b'] is bounded by A3,INTEGR24:def 1;
      reconsider AX = [.x,b.] as non empty closed_interval Subset of REAL
        by A38,XXREAL_1:30,MEASURE5:def 3;
A40:  AX = ['x,b'] by A38,INTEGRA5:def 3;
      AX c= ].a,b.] by A38,XXREAL_1:39; then
A41:  AX c= dom f by A1;

      reconsider AX1 = AX as Element of L-Field by MEASUR10:5,MEASUR12:75;
      AX = AX1; then
      integral(f||AX) = Integral(L-Meas,f|[.x,b.])
        by A41,A39,A40,MESFUN14:49; then
      integral(f,AX) = Integral(L-Meas,f|[.x,b.]) by INTEGRA5:def 2; then
      integral(f,x,b) = Integral(L-Meas,f|[.x,b.]) by A38,A40,INTEGRA5:def 4;
      hence Intf.x = Integral(L-Meas,f|[.x,b.]) by A9,A37;
     end;

A42: Partial_Union E = E by A24,PROB_4:15;

A43: for m be Nat holds I.m = integral(f,a+(b-a)/(m+1),b)
     proof
      let m be Nat;
A44:  a < a+(b-a)/(m+1) <= b by A5,Th22; then
A45:  f||['a+(b-a)/(m+1),b'] is bounded by A6,INTEGR10:def 2;

A46:   ['a+(b-a)/(m+1),b'] = [.a+(b-a)/(m+1),b.] by A44,INTEGRA5:def 3; then
      ['a+(b-a)/(m+1),b'] c= ].a,b.] by A44,XXREAL_1:39; then
A47:   ['a+(b-a)/(m+1),b'] c= dom f by A1;

A48:  E.m = [.a+(b-a)/(m+1),b.] by A24;

      (R_EAL f|A)|(E.m) = (f|A)|(E.m) by MESFUNC5:def 7; then
      (R_EAL f|A)|(E.m) = f|(E.m) by A24,A2,RELAT_1:74; then
A49:   (R_EAL f|A)|(E.m) = R_EAL f|(E.m) by MESFUNC5:def 7;

      I.m = Integral(L-Meas,(R_EAL(f|A))|((Partial_Union E).m)) by A34; then
A50:   I.m = Integral(L-Meas,f|[.a+(b-a)/(m+1),b.])
        by A42,A49,A48,MESFUNC6:def 3;

      f is_integrable_on ['a+(b-a)/(m+1),b'] by A44,A6,INTEGR10:def 2;
      hence I.m = integral(f,a+(b-a)/(m+1),b) by A50,A44,A46,A47,A45
,MESFUN14:50;
     end;

     for p be Real st 0<p ex n be Nat st for m be Nat st n<=m
      holds |.I.m-ext_left_integral(f,a,b) qua ExtReal.|<p
     proof
      let p be Real;
      assume 0<p; then
      consider r be Real such that
A51:    a < r and
A52:    for r1 be Real st r1<r & a<r1 & r1 in dom Intf holds
        |.Intf.r1-lim_right(Intf,a).| < p by A10,LIMFUNC2:42;

      set rr = min(b,r);
A53:  rr <= b & rr <= r by XXREAL_0:17;
      a < rr by A5,A51,XXREAL_0:21; then
A54:   0 < rr-a by XREAL_1:50;

      consider n be Nat such that
A55:    (b-a)/(rr-a) < n by SEQ_4:3;
      n <= n+1 by NAT_1:13; then
      (b-a)/(rr-a) < 1*(n+1) by A55,XXREAL_0:2; then
      (b-a)/(n+1) < 1*(rr-a) by A54,XREAL_1:113; then
      a+(b-a)/(n+1) < rr by XREAL_1:20; then
A56:   a+(b-a)/(n+1) < r by A53,XXREAL_0:2;

A57:  0 < b-a by A2,XXREAL_1:26,XREAL_1:50;

A58:  a < a+(b-a)/(n+1) <= b by A5,Th22; then
A59:  a+(b-a)/(n+1) in dom Intf by A8,XXREAL_1:2;
      set r1=a+(b-a)/(n+1);
A60:  |.Intf.r1-lim_right(Intf,a).| < p by A52,A56,A59,A58;

      take n;
      thus for m be Nat st n<=m holds
       |.I.m - ext_left_integral(f,a,b) qua ExtReal.|<p
      proof
       let m be Nat;
       set rm = a+(b-a)/(m+1);
       assume n<=m; then
       n+1 <= m+1 by XREAL_1:6; then
       (b-a)/(n+1) >= (b-a)/(m+1) by A57,XREAL_1:118; then
A61:   a+(b-a)/(n+1) >= a+(b-a)/(m+1) by XREAL_1:6;
A62:    rm <= b by A5,Th22;

A63:   a < rm by A57,XREAL_1:29; then
       [.rm,b.] c= ].a,b.] by XXREAL_1:39; then
A64:    [.rm,b.] c= dom f by A1;

       f|['rm,b'] is bounded by A62,A63,A3,INTEGR24:def 1; then
A65:    f|[.rm,b.] is bounded by A61,A58,XXREAL_0:2,INTEGRA5:def 3;

A66:    f is_integrable_on ['rm,b'] by A62,A63,A3,INTEGR24:def 1;

       (f|A)|[.rm,b.] is nonnegative by A4,MESFUNC6:55; then
A67:    f|[.rm,b.] is nonnegative by A2,A63,XXREAL_1:39,RELAT_1:74;
       [.r1,b.] c= [.rm,b.] by A61,XXREAL_1:34; then
       integral(f,r1,b) <= integral(f,rm,b) by A58,A64,A65,A66,A67,Th14; then
       Intf.r1 <= integral(f,rm,b) by A9,A58,A8,XXREAL_1:2; then
A68:   Intf.r1 <= I.m by A43;

A69:   rm in dom Intf by A8,A62,A63,XXREAL_1:2;
       Intf.rm = integral(f,a+(b-a)/(m+1),b) by A9,A8,A62,A63,XXREAL_1:2; then
       I.m = Intf.rm by A43; then
       I.m <= lim_right(Intf,a) by A10,A23,A69,Th9,A57,XREAL_1:29; then
A70:   lim_right(Intf,a) - I.m >= 0 by XXREAL_3:40; then
       -(lim_right(Intf,a) - I.m) <= 0; then
       I.m - ext_left_integral(f,a,b) <= 0 by A11,XXREAL_3:26; then
A71:   |.I.m-ext_left_integral(f,a,b).|
        = -(I.m - ext_left_integral(f,a,b)) by EXTREAL1:18
       .= ext_left_integral(f,a,b)-I.m by XXREAL_3:26;

       reconsider EX = ext_left_integral(f,a,b) as ExtReal;
A72:   EX - Intf.r1
        = EX + -((Intf.r1) qua ExtReal) by XXREAL_3:def 4
       .= ext_left_integral(f,a,b) + (-Intf.r1) by XXREAL_3:def 2
       .= ext_left_integral(f,a,b) - Intf.r1;

A73:   EX - I.m <= EX - Intf.r1 by A68,XXREAL_3:37; then
       -(ext_left_integral(f,a,b)-Intf.r1) <= 0 by A72,A70,A11; then
       |.Intf.r1 - ext_left_integral(f,a,b).|
        = -(Intf.r1 - ext_left_integral(f,a,b)) by ABSVALUE:30;
       hence |.I.m - ext_left_integral(f,a,b) qua ExtReal.| < p
         by A60,A11,A72,A73,A71,XXREAL_0:2;
      end;
     end; then
     consider RI be Real such that
A74:   lim I = RI &
      for p be Real st 0<p ex n be Nat st for m be Nat st n<=m holds
       |.I.m-lim I.|< p by MESFUNC5:def 8,MESFUNC9:7;
A75:  RI = Integral(L-Meas,f|A) by A35,A74,MESFUNC6:def 3;

     for g1 be Real st 0 < g1 ex R be Real st a<R & for r1 be Real st r1<R &
     a<r1 & r1 in dom Intf holds |.Intf.r1-RI.|<g1
     proof
      let g1 be Real;
      assume A76: 0 < g1;
      set g2 = g1/2;

      consider N be Nat such that
A77:    for m be Nat st N <= m holds |.I.m - lim I.| < g1 by A76,A74;
      take R = a+(b-a)/(N+1);
A78:  a < R <= b by A5,Th22; then
A79:   R in dom Intf by A8,XXREAL_1:2;

      thus a < R by A5,Th22;
      thus for r1 be Real st r1<R & a<r1 & r1 in dom Intf holds
            |. Intf.r1 - RI .| < g1
      proof
       let r1 be Real;
       assume that
A80:     r1 < R and
A81:     a < r1 and
A82:     r1 in dom Intf;

       I.N = integral(f,a+(b-a)/(N+1),b) by A43; then
A83:    Intf.R = I.N by A78,A9,A8,XXREAL_1:2;

A84:    I.N <= Intf.r1 by A80,A79,A82,A12,A83;
       RI - I.N = RI qua ExtReal - I.N &
       RI - Intf.r1 = RI qua ExtReal - Intf.r1; then
A85:  RI - Intf.r1 <= RI - I.N by A84,XXREAL_3:37;

A86:  |. I.N - RI .| < g1 by A77,A74;

       reconsider A2 = [.r1,b.] as Element of L-Field
         by MEASUR10:5,MEASUR12:75;

       A2 c= A1 by A2,A81,XXREAL_1:39; then
       Integral(L-Meas,(f|A)|A2) <= Integral(L-Meas,(f|A)|A1)
         by A25,A31,A4,MESFUNC6:def 1,87; then
       Integral(L-Meas,f|A2) <= RI by A75,A2,A81,XXREAL_1:39,RELAT_1:74; then
A87:  Intf.r1 <= RI by A82,A36; then
A88:  |.Intf.r1 - RI.| = -(Intf.r1 - RI) by ABSVALUE:30,XREAL_1:47;

       I.N <= RI by A84,A87,XXREAL_0:2; then
       |.RI - I.N.| = RI - I.N by EXTREAL1:def 1,XXREAL_3:40; then
       |.-(RI - I.N).| = RI - I.N by EXTREAL1:29; then
       |.I.N - RI.| = RI - I.N by XXREAL_3:26;
       hence |.Intf.r1 - RI.| < g1 by A85,A88,A86,XXREAL_0:2;
      end;
     end;
     hence left_improper_integral(f,a,b) = Integral(L-Meas,f|A)
        by A11,A7,A75,A10,LIMFUNC2:42;

     max+(R_EAL(f|A)) = R_EAL(f|A) by A32,MESFUN11:31; then
     Integral(L-Meas,f|A) = integral+(L-Meas,max+(R_EAL(f|A)))
       by A31,A25,A4,MESFUNC6:def 1,82; then
     integral+(L-Meas,max+(R_EAL(f|A))) < +infty
       by A75,XREAL_0:def 1,XXREAL_0:9;
     hence f is_left_ext_Riemann_integrable_on a,b
      implies f|A is_integrable_on L-Meas
        by A31,A26,A33,MESFUNC5:def 17,MESFUNC6:def 4;

     thus not f is_left_ext_Riemann_integrable_on a,b
      implies Integral(L-Meas,f|A) = +infty by A6;
    end;
    suppose
A89:  not f is_left_ext_Riemann_integrable_on a,b;
     hence left_improper_integral(f,a,b) = Integral(L-Meas,f|A)
       by A1,A2,A3,A4,Lm7;
     thus f is_left_ext_Riemann_integrable_on a,b
      implies f|A is_integrable_on L-Meas by A89;
     thus not f is_left_ext_Riemann_integrable_on a,b
      implies Integral(L-Meas,f|A) = +infty by A1,A2,A3,A4,Lm7;
    end;
end;

theorem
for f be PartFunc of REAL,REAL, a,b be Real, A be non empty Subset of REAL
 st ].a,b.] c= dom f & A = ].a,b.] & f is_left_improper_integrable_on a,b
 & f|A is nonpositive
 holds left_improper_integral(f,a,b) = Integral(L-Meas,f|A)
  & (f is_left_ext_Riemann_integrable_on a,b
      implies f|A is_integrable_on L-Meas)
  & (not f is_left_ext_Riemann_integrable_on a,b
      implies Integral(L-Meas,f|A) = -infty)
proof
    let f be PartFunc of REAL,REAL, a,b be Real, A be non empty Subset of REAL;
    assume that
A1:  ].a,b.] c= dom f and
A2:  A = ].a,b.] and
A3:  f is_left_improper_integrable_on a,b and
A4:  f|A is nonpositive;

A5: a < b by A2,XXREAL_1:26;

    -(f|A) is nonnegative by A4,Th5; then
A6: (-f)|A is nonnegative by RFUNCT_1:46;

A7: dom(-f) = dom f by VALUED_1:8;
A8: -f is_left_improper_integrable_on a,b by A3,A5,A1,INTEGR24:55; then
    left_improper_integral(-f,a,b) = Integral(L-Meas,(-f)|A)
      by A1,A7,A2,A6,Th43; then
    -left_improper_integral(f,a,b) = Integral(L-Meas,(-f)|A)
      by A3,A5,A1,INTEGR24:55; then
A9: left_improper_integral(f,a,b) = -Integral(L-Meas,(-f)|A);

    reconsider A1 = A as Element of L-Field by A2,MEASUR10:5,MEASUR12:75;

A10: A1 = dom(f|A) by A1,A2,RELAT_1:62; then
A11: A1 = dom f /\ A1 by RELAT_1:61;

A12: dom(R_EAL(f|A)) = A1 by A10,MESFUNC5:def 7;
    f is A1-measurable by A1,A2,A3,Th34; then
A13: R_EAL(f|A) is A1-measurable by A11,MESFUNC6:def 1,76;

A14: R_EAL((-f)|A) = R_EAL -(f|A) by RFUNCT_1:46
     .= -R_EAL(f|A) by MESFUNC6:28;

A15: Integral(L-Meas,(-f)|A)
      = Integral(L-Meas,-R_EAL(f|A)) by A14,MESFUNC6:def 3
     .= -Integral(L-Meas,R_EAL(f|A)) by A12,A13,MESFUN11:52
     .= -Integral(L-Meas,f|A) by MESFUNC6:def 3;
    hence left_improper_integral(f,a,b) = Integral(L-Meas,f|A) by A9;
    hereby assume f is_left_ext_Riemann_integrable_on a,b; then
     (-1)(#)f is_left_ext_Riemann_integrable_on a,b by A1,INTEGR24:30; then
     -f is_left_ext_Riemann_integrable_on a,b by VALUED_1:def 6; then
     (-f)|A is_integrable_on L-Meas by A7,A1,A2,A8,A6,Th43; then
     -(f|A) is_integrable_on L-Meas by RFUNCT_1:46; then
     (-1)(#)(-(f|A)) is_integrable_on L-Meas by MESFUNC6:102;
     hence f|A is_integrable_on L-Meas;
    end;
    hereby assume not f is_left_ext_Riemann_integrable_on a,b; then
A16:  Integral(L-Meas,f|A) = +infty or Integral(L-Meas,f|A) = -infty
       by A15,A9,A3,INTEGR24:34;

     R_EAL (f|A) is nonpositive by A4,MESFUNC5:def 7; then
     Integral(L-Meas,R_EAL(f|A)) <= 0 by A13,A12,MESFUN11:61;
     hence Integral(L-Meas,f|A) = -infty by A16,MESFUNC6:def 3;
    end;
end;

theorem Th45:
for f be PartFunc of REAL,REAL, a,b be Real, A be non empty Subset of REAL
 st ].a,b.[ c= dom f & A = ].a,b.[ & f is_improper_integrable_on a,b
 & f|A is nonnegative
 holds improper_integral(f,a,b) = Integral(L-Meas,f|A)
  & ((ex c be Real st a < c < b & f is_left_ext_Riemann_integrable_on a,c
       & f is_right_ext_Riemann_integrable_on c,b) implies
     f|A is_integrable_on L-Meas)
  & ((for c be Real st a < c < b holds
       not f is_left_ext_Riemann_integrable_on a,c or
       not f is_right_ext_Riemann_integrable_on c,b) implies
     Integral(L-Meas,f|A) = +infty)
proof
    let f be PartFunc of REAL,REAL, a,b be Real, A be non empty Subset of REAL;
    assume that
A1:  ].a,b.[ c= dom f and
A2:  A = ].a,b.[ and
A3:  f is_improper_integrable_on a,b and
A4:  f|A is nonnegative;

    consider c be Real such that
A5:  a < c < b and
A6:  f is_left_improper_integrable_on a,c and
A7:  f is_right_improper_integrable_on c,b and
A8:  not(left_improper_integral(f,a,c) = -infty
       & right_improper_integral(f,c,b) = +infty) and
A9:  not(left_improper_integral(f,a,c) = +infty
       & right_improper_integral(f,c,b) = -infty) by A3,INTEGR24:def 5;

    reconsider L = ].a,c.] as non empty Subset of REAL by A5,XXREAL_1:32;
    reconsider L1 = L as Element of L-Field by MEASUR10:5,MEASUR12:75;
    reconsider R = [.c,b.[ as non empty Subset of REAL by A5,XXREAL_1:31;
    reconsider R1 = R as Element of L-Field by MEASUR10:5,MEASUR12:75;

    L c= ].a,b.[ & R c= ].a,b.[ by A5,XXREAL_1:48,49; then
A10: L c= dom f & R c= dom f by A1; then
A11:f is L1-measurable & f is R1-measurable by A6,A7,Th33,Th34; then
A12:f is (L1\/R1)-measurable by MESFUNC6:17;

    (f|A)|L is nonnegative by A4,MESFUNC6:55; then
A13:f|L is nonnegative by A2,A5,XXREAL_1:49,RELAT_1:74; then
A14:left_improper_integral(f,a,c) = Integral(L-Meas,f|L) by A6,A10,Th43;

    (f|A)|R is nonnegative by A4,MESFUNC6:55; then
A15:f|R is nonnegative by A2,A5,XXREAL_1:48,RELAT_1:74; then
A16:right_improper_integral(f,c,b) = Integral(L-Meas,f|R) by A7,A10,Th41;

    reconsider R2 = ].c,b.[ as Element of L-Field by MEASUR10:5,MEASUR12:75;
    reconsider C = {c} as Element of L-Field by Th28;
    C = [.c,c.] by XXREAL_1:17; then
A17:L-Meas.C = c-c by MESFUN14:5;

    set fLR = f|(L1\/R1);

A18:L1 \/ R1 = ].a,b.[ & L1 \/ R2 = ].a,b.[ by A5,XXREAL_1:172,171; then
A19:L1\/R1 = dom fLR by A1,RELAT_1:62; then
    L1\/R1 = dom f /\ (L1\/R1) by RELAT_1:61; then
A20:fLR is (L1\/R1)-measurable by A12,MESFUNC6:76;

A21:L1 c= L1 \/ R1 & R1 c= L1 \/ R1 by XBOOLE_1:7;
    R2 c= R1 by XXREAL_1:45; then
A22:R2 c= L1 \/ R1 by A21;

A23:fLR is nonnegative by A2,A4,A5,XXREAL_1:172;

    R2 = R1 \ C by A5,XXREAL_1:136; then
A24:(f|R1)|(R1\C) = f|R2 by XXREAL_1:45,RELAT_1:74;

A25:R1 = dom(f|R1) by A10,RELAT_1:62; then
    R1 = dom f /\ R1 by RELAT_1:61; then
A26:Integral(L-Meas,f|R2) = Integral(L-Meas,f|R1)
      by A24,A17,A25,A11,MESFUNC6:76,89;

    Integral(L-Meas,fLR|(L1\/R2))
     = Integral(L-Meas,fLR|L1) + Integral(L-Meas,fLR|R2)
       by A19,A20,A23,XXREAL_1:91,MESFUNC6:85; then
A27:Integral(L-Meas,fLR)
     = Integral(L-Meas,f|L1) + Integral(L-Meas,fLR|R2)
       by A18,XBOOLE_1:7,RELAT_1:74
    .= Integral(L-Meas,f|L1) + Integral(L-Meas,f|R2) by A22,RELAT_1:74;
    hence improper_integral(f,a,b) = Integral(L-Meas,f|A)
      by A1,A3,A5,A14,A16,A26,A18,A2,INTEGR24:48;

    hereby assume
     ex c be Real st a < c < b & f is_left_ext_Riemann_integrable_on a,c
       & f is_right_ext_Riemann_integrable_on c,b; then
     consider c be Real such that
A28:  a < c < b and
A29:  f is_left_ext_Riemann_integrable_on a,c and
A30:  f is_right_ext_Riemann_integrable_on c,b;

A31: f is_left_improper_integrable_on a,c by A29,INTEGR24:32;
A32: f is_right_improper_integrable_on c,b by A30,INTEGR24:33;

     reconsider L1 = ].a,c.] as Element of L-Field by MEASUR10:5,MEASUR12:75;
     reconsider R1 = [.c,b.[ as Element of L-Field by MEASUR10:5,MEASUR12:75;

A33:  L1\/R1 = A by A2,A28,XXREAL_1:172;

A34:  dom(f|A) = A by A1,A2,RELAT_1:62; then
A35:  dom(R_EAL(f|A)) = L1\/R1 by A33,MESFUNC5:def 7;
A36:  L1\/R1 = dom f /\ (L1\/R1) by A33,A34,RELAT_1:61;

A37: f|A is (L1\/R1)-measurable by A1,A3,A33,A2,Th35,A36,MESFUNC6:76; then
A38:  (R_EAL(f|A)) is (L1\/R1)-measurable by MESFUNC6:def 1;

A39:  L1 is non empty by A28,XXREAL_1:32;
      L1 c= ].a,b.[ by A28,XXREAL_1:49; then
A40:  L1 c= dom f by A1; then
A41:  L1 = dom(f|L1) by RELAT_1:62; then
A42:  L1 = dom f /\ L1 by RELAT_1:61;
A43: dom(R_EAL(f|L1)) = L1 by A41,MESFUNC5:def 7;
     f is L1-measurable by A40,Th34,A29,INTEGR24:32; then
A44: R_EAL(f|L1) is L1-measurable by A42,MESFUNC6:def 1,76;

     (f|A)|L1 is nonnegative by A4,MESFUNC6:55; then
     f|L1 is nonnegative by A2,A28,XXREAL_1:49,RELAT_1:74; then
     f|L1 is_integrable_on L-Meas by A39,A40,A29,A31,Th43; then
     R_EAL(f|L1) is_integrable_on L-Meas by MESFUNC6:def 4; then
A45: integral+(L-Meas,max+(R_EAL(f|L1))) < +infty &
     integral+(L-Meas,max-(R_EAL(f|L1))) < +infty by MESFUNC5:def 17;

A46:  R1 is non empty by A28,XXREAL_1:31;
      R1 c= ].a,b.[ by A28,XXREAL_1:48; then
A47:  R1 c= dom f by A1; then
A48:  R1 = dom(f|R1) by RELAT_1:62; then
A49:  R1 = dom f /\ R1 by RELAT_1:61;
A50: dom(R_EAL(f|R1)) = R1 by A48,MESFUNC5:def 7;
     f is R1-measurable by A47,Th33,A30,INTEGR24:33; then
A51: R_EAL(f|R1) is R1-measurable by A49,MESFUNC6:def 1,76;

     (f|A)|R1 is nonnegative by A4,MESFUNC6:55; then
     f|R1 is nonnegative by A2,A28,XXREAL_1:48,RELAT_1:74; then
     f|R1 is_integrable_on L-Meas by A46,A47,A30,A32,Th41; then
A52: R_EAL(f|R1) is_integrable_on L-Meas by MESFUNC6:def 4; then
A53: integral+(L-Meas,max+(R_EAL(f|R1))) < +infty &
     integral+(L-Meas,max-(R_EAL(f|R1))) < +infty by MESFUNC5:def 17;

     set R2 = ].c,b.[;
     reconsider R2 as Element of L-Field by MEASUR10:5,MEASUR12:75;
     set C = {c};
A54: C = [.c,c.] by XXREAL_1:17;
     reconsider C = {c} as Element of L-Field by Th28;
A55: L-Meas.C = c-c by A54,MESFUN14:5 .= 0;

A56: dom(f|R1) = R1 by A47,RELAT_1:62; then
A57: dom(R_EAL(f|R1)) = R1 by MESFUNC5:def 7;
     ex E be Element of L-Field st
      E = dom(R_EAL(f|R1)) & R_EAL(f|R1) is E-measurable
        by A52,MESFUNC5:def 17; then
A58: max+(f|R1) is R1-measurable & max-(f|R1) is R1-measurable
       by A56,A57,MESFUNC6:def 1,46,47;
A59: dom(max+(f|R1)) = R1 & dom(max-(f|R1)) = R1 by A56,RFUNCT_3:def 10,def 11;

A60: R2 = R1 \ C by A28,XXREAL_1:136;
     (f|R1)|(R1\C) = f|R2 by A60,XBOOLE_1:36,RELAT_1:74; then
A61: (max+(f|R1))|(R1\C) = max+(f|R2) & (max-(f|R1))|(R1\C) = max-(f|R2)
       by RFUNCT_3:44,45;

A62: max+(R_EAL(f|A)) = max+(f|A) & max-(R_EAL(f|A)) = max-(f|A) &
     max+(R_EAL(f|L1)) = max+(f|L1) & max-(R_EAL(f|L1)) = max-(f|L1) &
     max+(R_EAL(f|R1)) = max+(f|R1) & max-(R_EAL(f|R1)) = max-(f|R1)
       by MESFUNC6:30;

A63: dom(max+(R_EAL(f|A))) = L1 \/ R1 &
     dom(max-(R_EAL(f|A))) = L1 \/ R1 by A35,MESFUNC2:def 2,def 3;
A64: max+(R_EAL(f|A)) is (L1\/R1)-measurable &
     max-(R_EAL(f|A)) is (L1\/R1)-measurable
       by A35,A37,MESFUNC2:25,26,MESFUNC6:def 1;

A65:  integral+(L-Meas,max+(R_EAL(f|A)))
      = Integral(L-Meas,max+(R_EAL(f|A))) by A63,A64,MESFUNC5:88,MESFUN11:5
     .= Integral(L-Meas,R_EAL(max+(f|A))) by A62,MESFUNC5:def 7
     .= Integral(L-Meas,max+(f|A)) by MESFUNC6:def 3;

A66:  integral+(L-Meas,max-(R_EAL(f|A)))
      = Integral(L-Meas,max-(R_EAL(f|A))) by A63,A64,MESFUNC5:88,MESFUN11:5
     .= Integral(L-Meas,R_EAL(max-(f|A))) by A62,MESFUNC5:def 7
     .= Integral(L-Meas,max-(f|A)) by MESFUNC6:def 3;

A67: dom(max+(R_EAL(f|L1))) = L1 & dom(max-(R_EAL(f|L1))) = L1
       by A43,MESFUNC2:def 2,def 3;
A68: max+(R_EAL(f|L1)) is L1-measurable &
     max-(R_EAL(f|L1)) is L1-measurable by A43,A44,MESFUNC2:25,26;

A69: integral+(L-Meas,max+(R_EAL(f|L1)))
      = Integral(L-Meas,max+(R_EAL(f|L1))) by A67,A68,MESFUNC5:88,MESFUN11:5
     .= Integral(L-Meas,R_EAL(max+(f|L1))) by A62,MESFUNC5:def 7
     .= Integral(L-Meas,max+(f|L1)) by MESFUNC6:def 3;

A70: integral+(L-Meas,max-(R_EAL(f|L1)))
      = Integral(L-Meas,max-(R_EAL(f|L1))) by A67,A68,MESFUNC5:88,MESFUN11:5
     .= Integral(L-Meas,R_EAL(max-(f|L1))) by A62,MESFUNC5:def 7
     .= Integral(L-Meas,max-(f|L1)) by MESFUNC6:def 3;

A71: dom(max+(R_EAL(f|R1))) = R1 & dom(max-(R_EAL(f|R1))) = R1
       by A50,MESFUNC2:def 2,def 3;
A72: max+(R_EAL(f|R1)) is R1-measurable &
     max-(R_EAL(f|R1)) is R1-measurable by A50,A51,MESFUNC2:25,26;

A73: integral+(L-Meas,max+(R_EAL(f|R1)))
      = Integral(L-Meas,max+(R_EAL(f|R1))) by A71,A72,MESFUNC5:88,MESFUN11:5
     .= Integral(L-Meas,R_EAL(max+(f|R1))) by A62,MESFUNC5:def 7
     .= Integral(L-Meas,max+(f|R1)) by MESFUNC6:def 3;

A74: integral+(L-Meas,max-(R_EAL(f|R1)))
      = Integral(L-Meas,max-(R_EAL(f|R1))) by A71,A72,MESFUNC5:88,MESFUN11:5
     .= Integral(L-Meas,R_EAL(max-(f|R1))) by A62,MESFUNC5:def 7
     .= Integral(L-Meas,max-(f|R1)) by MESFUNC6:def 3;

A75:  dom(max+(f|A)) = A & dom(max-(f|A)) = A by A34,RFUNCT_3:def 10,def 11;
A76:  max+(f|A) is (L1\/R1)-measurable &
      max-(f|A) is (L1\/R1)-measurable by A33,A34,A37,MESFUNC6:46,47;
A77:  max+(f|A) is nonnegative & max-(f|A) is nonnegative by MESFUNC6:61;
A78:  A = L1 \/ R1 & A = L1 \/ R2 by A2,A28,XXREAL_1:172,171;

A79:  (max+(f|A))|L1 = max+((f|A)|L1) by RFUNCT_3:44 .= max+(f|L1)
       by A78,XBOOLE_1:7,RELAT_1:74;
A80:  (max-(f|A))|L1 = max-((f|A)|L1) by RFUNCT_3:45 .= max-(f|L1)
       by A78,XBOOLE_1:7,RELAT_1:74;
A81:  (max+(f|A))|R2 = max+((f|A)|R2) by RFUNCT_3:44 .= max+(f|R2)
       by A78,XBOOLE_1:7,RELAT_1:74;
A82:  (max-(f|A))|R2 = max-((f|A)|R2) by RFUNCT_3:45 .= max-(f|R2)
       by A78,XBOOLE_1:7,RELAT_1:74;

     Integral(L-Meas,max+(f|A)) = Integral(L-Meas,(max+(f|A))|A) by A75
     .= Integral(L-Meas,(max+(f|A))|L1)+Integral(L-Meas,(max+(f|A))|R2)
        by A75,A76,A77,A78,XXREAL_1:91,MESFUNC6:85
     .= Integral(L-Meas,max+(f|L1)) + Integral(L-Meas,max+(f|R1))
         by A79,A81,A61,A58,A59,A55,MESFUNC6:89; then
A83: integral+(L-Meas,max+(R_EAL(f|A))) < +infty
       by A45,A53,A65,A69,A73,XXREAL_3:16,XXREAL_0:4;

     Integral(L-Meas,max-(f|A)) = Integral(L-Meas,(max-(f|A))|A) by A75
     .= Integral(L-Meas,(max-(f|A))|L1)+Integral(L-Meas,(max-(f|A))|R2)
        by A75,A76,A77,A78,XXREAL_1:91,MESFUNC6:85
     .= Integral(L-Meas,max-(f|L1)) + Integral(L-Meas,max-(f|R1))
       by A80,A82,A61,A58,A59,A55,MESFUNC6:89; then
     integral+(L-Meas,max-(R_EAL(f|A))) < +infty
       by A45,A53,A66,A70,A74,XXREAL_3:16,XXREAL_0:4;
     hence f|A is_integrable_on L-Meas
       by A35,A38,A83,MESFUNC5:def 17,MESFUNC6:def 4;
    end;

    hereby assume
A84:  for c be Real st a < c < b holds
       not f is_left_ext_Riemann_integrable_on a,c or
       not f is_right_ext_Riemann_integrable_on c,b;
     per cases by A84,A5;
     suppose not f is_left_ext_Riemann_integrable_on a,c; then
      Integral(L-Meas,f|L) = +infty by A10,A6,A13,Th43;
      hence Integral(L-Meas,f|A) = +infty
        by A9,A13,A6,A10,Th43,A16,A26,A27,A18,A2,XXREAL_3:def 2;
     end;
     suppose not f is_right_ext_Riemann_integrable_on c,b; then
      Integral(L-Meas,f|R) = +infty by A10,A7,A15,Th41;
      hence Integral(L-Meas,f|A) = +infty
        by A8,A15,A7,A10,Th41,A14,A26,A27,A18,A2,XXREAL_3:def 2;
     end;
    end;
end;

theorem
for f be PartFunc of REAL,REAL, a,b be Real, A be non empty Subset of REAL
 st ].a,b.[ c= dom f & A = ].a,b.[ & f is_improper_integrable_on a,b
 & f|A is nonpositive
 holds improper_integral(f,a,b) = Integral(L-Meas,f|A)
   & ((ex c be Real st a < c < b & f is_left_ext_Riemann_integrable_on a,c
        & f is_right_ext_Riemann_integrable_on c,b) implies
      f|A is_integrable_on L-Meas)
   & ((for c be Real st a < c < b holds
        not f is_left_ext_Riemann_integrable_on a,c or
        not f is_right_ext_Riemann_integrable_on c,b) implies
      Integral(L-Meas,f|A) = -infty)
proof
    let f be PartFunc of REAL,REAL, a,b be Real, A be non empty Subset of REAL;
    assume that
A1:  ].a,b.[ c= dom f and
A2:  A = ].a,b.[ and
A3:  f is_improper_integrable_on a,b and
A4:  f|A is nonpositive;

    reconsider A1 = A as Element of L-Field by A2,MEASUR10:5,MEASUR12:75;

A5: -f is_improper_integrable_on a,b by A1,A3,INTEGR24:62;
A6: improper_integral(-f,a,b) = - improper_integral(f,a,b)
      by A1,A3,INTEGR24:62;

    -(f|A) is nonnegative by A4,Th5; then
A7: (-f)|A is nonnegative by RFUNCT_1:46;
A8:dom(-f) = dom f by VALUED_1:8; then
A9:improper_integral(-f,a,b) = Integral(L-Meas,(-f)|A) by A1,A2,A5,A7,Th45
      .= Integral(L-Meas,-(f|A)) by RFUNCT_1:46;

A10:dom(f|A) = A by A1,A2,RELAT_1:62; then
    A1 = dom f /\ A1 by RELAT_1:61; then
A11:f|A is A1-measurable by A1,A2,A3,Th35,MESFUNC6:76;

    Integral(L-Meas,-(f|A)) = - Integral(L-Meas,f|A) by A10,A11,Th39;
    hence improper_integral(f,a,b) = Integral(L-Meas,f|A)
      by A6,A9,XXREAL_3:10;

    hereby assume
     (ex c be Real st a < c < b & f is_left_ext_Riemann_integrable_on a,c
        & f is_right_ext_Riemann_integrable_on c,b); then
     consider c be Real such that
A12:   a < c < b and
A13:   f is_left_ext_Riemann_integrable_on a,c and
A14:   f is_right_ext_Riemann_integrable_on c,b;

     ].a,c.] c= ].a,b.[ & [.c,b.[ c= ].a,b.[ by A12,XXREAL_1:49,48; then
A15:  ].a,c.] c= dom f & [.c,b.[ c= dom f by A1; then
     (-1)(#)f is_left_ext_Riemann_integrable_on a,c by A13,INTEGR24:30; then
A16:  -f is_left_ext_Riemann_integrable_on a,c by VALUED_1:def 6;
     (-1)(#)f is_right_ext_Riemann_integrable_on c,b by A14,A15
,INTEGR24:31; then
     -f is_right_ext_Riemann_integrable_on c,b by VALUED_1:def 6; then
     (-f)|A is_integrable_on L-Meas by A1,A2,A8,A5,A7,A12,A16,Th45; then
     -(f|A) is_integrable_on L-Meas by RFUNCT_1:46; then
     (-1)(#)(-(f|A)) is_integrable_on L-Meas by MESFUNC6:102;
     hence f|A is_integrable_on L-Meas;
    end;
    hereby assume
A17:  (for c be Real st a < c < b holds
        not f is_left_ext_Riemann_integrable_on a,c or
        not f is_right_ext_Riemann_integrable_on c,b);
     for c be Real st a < c < b holds
      not -f is_left_ext_Riemann_integrable_on a,c or
      not -f is_right_ext_Riemann_integrable_on c,b
     proof
      let c be Real;
      assume A18: a < c < b;
      per cases by A17,A18;
      suppose A19: not f is_left_ext_Riemann_integrable_on a,c;
       ].a,c.] c= ].a,b.[ by A18,XXREAL_1:49; then
A20:    ].a,c.] c= dom (-f) by A1,A8;

       now assume -f is_left_ext_Riemann_integrable_on a,c; then
        (-1)(#)(-f) is_left_ext_Riemann_integrable_on a,c by A20,INTEGR24:30;
        hence contradiction by A19;
       end;
       hence thesis;
      end;
      suppose A21: not f is_right_ext_Riemann_integrable_on c,b;
       [.c,b.[ c= ].a,b.[ by A18,XXREAL_1:48; then
A22:    [.c,b.[ c= dom(-f) by A1,A8;
       now assume -f is_right_ext_Riemann_integrable_on c,b; then
        (-1)(#)(-f) is_right_ext_Riemann_integrable_on c,b by A22,INTEGR24:31;
        hence contradiction by A21;
       end;
       hence thesis;
      end;
     end; then
     Integral(L-Meas,(-f)|A) = +infty by A1,A8,A2,A5,A7,Th45; then
     Integral(L-Meas,-(f|A)) = +infty by RFUNCT_1:46; then
     -Integral(L-Meas,f|A) = +infty by A10,A11,Th39;
     hence Integral(L-Meas,f|A) = -infty by XXREAL_3:23;
    end;
end;

Lm9:
for f be PartFunc of REAL,REAL, b be Real, A be non empty Subset of REAL
 st left_closed_halfline b c= dom f & A = left_closed_halfline b
 & f is_-infty_improper_integrable_on b & f is nonnegative
 & not f is_-infty_ext_Riemann_integrable_on b
 holds improper_integral_-infty(f,b) = Integral(L-Meas,f|A)
  & Integral(L-Meas,f|A) = +infty
proof
    let f be PartFunc of REAL,REAL, b be Real, A be non empty Subset of REAL;
    assume that
A1:  left_closed_halfline b c= dom f and
A2:  A = left_closed_halfline b and
A3:  f is_-infty_improper_integrable_on b and
A4:  f is nonnegative and
A5:  not f is_-infty_ext_Riemann_integrable_on b;

A6: for a be Real st a <= b holds
     f is_integrable_on ['a,b'] & f|['a,b'] is bounded by A3,INTEGR25:def 1;

A7: A = ].-infty,b.] by A2,LIMFUNC1:def 1; then
    reconsider A1 = A as Element of L-Field by MEASUR10:5,MEASUR12:75;

A8: R_EAL f is A1-measurable by A1,A2,A7,A3,Th37,MESFUNC6:def 1;

A9:A1 = dom(f|A1) by A1,A2,RELAT_1:62; then
    A1 = dom f /\ A1 by RELAT_1:61; then
    A1 = dom(R_EAL f) /\ A1 by MESFUNC5:def 7; then
    (R_EAL f)|A1 is A1-measurable by A8,MESFUNC5:42; then
A10: (R_EAL f|A1) is A1-measurable by Th16;

    f|A1 is nonnegative by A4,MESFUNC6:55; then
A11: R_EAL(f|A1) is nonnegative by MESFUNC5:def 7;

    A1 = dom(R_EAL(f|A1)) by A9,MESFUNC5:def 7; then
A12: integral+(L-Meas,max-(R_EAL f|A1)) < +infty by A10,A11,MESFUN11:53;

A13: A1 = dom(R_EAL f|A1) by A9,MESFUNC5:def 7;

    consider E be SetSequence of L-Field such that
A14:  (for n be Nat holds E.n = [.b-n,b.]) &
     E is non-descending & E is convergent & Union E = ].-infty,b.] by Th26;

A15: lim E = Union E by A14,SETLIM_1:80; then
    A1 \ lim E = {} by A14,A7,XBOOLE_1:37; then
    L-Meas.(A1 \ lim E) = 0 by VALUED_0:def 19; then
    consider I be ExtREAL_sequence such that
A16:  for n be Nat holds
      I.n = Integral(L-Meas,(R_EAL f|A)|((Partial_Union E).n)) and
     I is convergent and
A17:  Integral(L-Meas,(R_EAL f|A)) = lim I by A10,A13,A12,A14,A15,A7,Th19;

    consider Intf be PartFunc of REAL,REAL such that
A18:  dom Intf = left_closed_halfline b and
A19:  for x be Real st x in dom Intf holds Intf.x = integral(f,x,b) and
A20:  Intf is convergent_in-infty or Intf is divergent_in-infty_to+infty
  or Intf is divergent_in-infty_to-infty by A3,INTEGR25:def 1;

A21: for x be Real st x in dom Intf holds Intf.x >= 0
    proof
     let x be Real;
     assume A22: x in dom Intf; then
A23:  -infty < x <= b by A18,A2,A7,XXREAL_1:2; then
     reconsider AX = [.x,b.] as non empty closed_interval Subset of REAL
       by XXREAL_1:30,MEASURE5:def 3;
     AX c= ].-infty,b.] by A23,XXREAL_1:39; then
     AX c= dom f by A1,A2,A7; then
     dom(f|AX) = AX by RELAT_1:62; then
     reconsider f1 = f|AX as Function of AX,REAL by FUNCT_2:def 1,RELSET_1:5;

A24:  AX = ['x,b'] by A23,INTEGRA5:def 3; then
A25:  f1|AX is bounded by A23,A3,INTEGR25:def 1;
     for r be Real st r in AX holds f1.r >= 0
     proof
      let r be Real;
      assume A26: r in AX;
      f.r >= 0 by A4,MESFUNC6:51;
      hence f1.r >= 0 by A26,FUNCT_1:49;
     end; then
     integral(f1) >= 0 by A25,INTEGRA2:32; then
     integral(f,AX) >= 0 by INTEGRA5:def 2; then
     integral(f,x,b) >= 0 by A23,A24,INTEGRA5:def 4;
     hence Intf.x >= 0 by A19,A22;
    end;

A27:now assume
A28: Intf is divergent_in-infty_to-infty;

     consider r be Real such that
A29:  for r1 be Real st r1 < r & r1 in dom Intf holds Intf.r1 < 0
        by A28,LIMFUNC1:49;

     consider r1 be Real such that
A30:  r1 < r & r1 in dom Intf by A28,LIMFUNC1:49;

     Intf.r1 < 0 by A29,A30;
     hence contradiction by A21,A30;
    end; then
A31:improper_integral_-infty(f,b) = +infty
      by A3,A18,A19,A20,A5,A6,INTEGR10:def 6,INTEGR25:def 3;

    for g be Real st 0 < g
     ex n be Nat st for m be Nat st n<=m holds g <= I.m
    proof
     let g be Real;
     assume 0 < g;

     consider r be Real such that
A32:   for r1 be Real st r1<r & r1 in dom Intf holds g<Intf.r1
       by A27,A18,A19,A20,A5,A6,INTEGR10:def 6,LIMFUNC1:48;
     consider r1 be Real such that
A33:   r1 < r & r1 in dom Intf
        by A27,A18,A19,A20,A5,A6,INTEGR10:def 6,LIMFUNC1:48;
     g < Intf.r1 by A32,A33; then
A34: g < integral(f,r1,b) by A33,A19;

A35:  -infty < r1 & r1 <= b by A33,A18,A2,A7,XXREAL_1:2;

     consider n be Nat such that
A36:   b-r1 < n by SEQ_4:3;
     b < r1 + n by A36,XREAL_1:19; then
A37:  b-n < r1 by XREAL_1:19;

     take n;
     thus for m be Nat st n <= m holds g <= I.m
     proof
      let m be Nat;
      assume n <= m; then
      b-m <= b-n by XREAL_1:10; then
A38:  b-m < r1 by A37,XXREAL_0:2;

A39:   -infty < b-m by XREAL_0:def 1,XXREAL_0:12;

A40:  b-m <= b by XREAL_1:43; then
A41:   f is_integrable_on ['b-m,b'] & f|['b-m,b'] is bounded
        by A3,INTEGR25:def 1;

A42:   ['b-m,b'] = [.b-m,b.] by XREAL_1:43,INTEGRA5:def 3; then
      ['b-m,b'] c= ].-infty,b.] by A39,XXREAL_1:39; then
A43:   ['b-m,b'] c= dom f by A1,A7,A2;

      r1 in ['b-m,b'] by A38,A35,A42,XXREAL_1:1; then
A44:   integral(f,b-m,b) = integral(f,b-m,r1) + integral(f,r1,b)
        by A40,A41,A43,INTEGRA6:17;

      [.b-m,r1.] c= ].-infty,b.] by A35,A39,XXREAL_1:39; then
A45:  [.b-m,r1.] c= dom f by A1,A7,A2;

      f|[.b-m,r1.] is bounded by A41,A42,A35,XXREAL_1:34,RFUNCT_1:74; then
      integral(f,b-m,r1) >= 0 by A38,A45,Th12,A4,MESFUNC6:55; then
A46:   integral(f,r1,b) <= integral(f,b-m,b) by A44,XREAL_1:31;

A47:  E.m = [.b-m,b.] by A14;

      (R_EAL f|A)|(E.m) = (f|A)|(E.m) by MESFUNC5:def 7; then
A48:  (R_EAL f|A)|(E.m) = f|(E.m) by A47,A39,A7,XXREAL_1:39,RELAT_1:74;

A49:   f||['b-m,b'] is bounded by A40,A3,INTEGR25:def 1;

      I.m = Integral(L-Meas,(R_EAL f|A)|((Partial_Union E).m)) by A16
       .= Integral(L-Meas,(R_EAL f|A)|(E.m)) by A14,PROB_4:15
       .= Integral(L-Meas,(R_EAL f|(E.m))) by A48,MESFUNC5:def 7
       .= Integral(L-Meas,f|(E.m)) by MESFUNC6:def 3
       .= Integral(L-Meas,f|[.b-m,b.]) by A14
       .= integral(f,b-m,b) by A49,A40,A42,A43,A3,INTEGR25:def 1,MESFUN14:50;
      hence g <= I.m by A46,A34,XXREAL_0:2;
     end;
    end; then
    I is convergent_to_+infty by MESFUNC5:def 9; then
A50:lim I = +infty by MESFUNC5:def 12;
    hence improper_integral_-infty(f,b) = Integral(L-Meas,f|A)
      by A17,A31,MESFUNC6:def 3;
    thus Integral(L-Meas,f|A) = +infty by A17,A50,MESFUNC6:def 3;
end;

theorem Th47:
for f be PartFunc of REAL,REAL, b be Real, A be non empty Subset of REAL
 st left_closed_halfline b c= dom f & A = left_closed_halfline b
 & f is_-infty_improper_integrable_on b & f is nonnegative
 holds improper_integral_-infty(f,b) = Integral(L-Meas,f|A)
  & (f is_-infty_ext_Riemann_integrable_on b
      implies f|A is_integrable_on L-Meas)
  & (not f is_-infty_ext_Riemann_integrable_on b
      implies Integral(L-Meas,f|A) = +infty)
proof
    let f be PartFunc of REAL,REAL, b be Real, A be non empty Subset of REAL;
    assume that
A1:  left_closed_halfline b c= dom f and
A2:  A = left_closed_halfline b and
A3:  f is_-infty_improper_integrable_on b and
A4:  f is nonnegative;

A5: A = ].-infty,b.] by A2,LIMFUNC1:def 1; then
    reconsider A1 = A as Element of L-Field by MEASUR10:5,MEASUR12:75;

    per cases;
    suppose
A6:  f is_-infty_ext_Riemann_integrable_on b; then
A7:  improper_integral_-infty(f,b) = infty_ext_left_integral(f,b)
       by A3,INTEGR25:22;

     consider Intf be PartFunc of REAL,REAL such that
A8:   dom Intf = left_closed_halfline b and
A9:   for x be Real st x in dom Intf holds Intf.x = integral(f,x,b) and
A10:   Intf is convergent_in-infty and
A11:   infty_ext_left_integral(f,b) = lim_in-infty Intf by A6,INTEGR10:def 8;

A12:  for p,q be Real st p in dom Intf & q in dom Intf & p < q holds
      Intf.q <= Intf.p
     proof
      let p,q be Real;
      assume that
A13:    p in dom Intf and
A14:    q in dom Intf and
A15:    p < q;

A16:   -infty < p <= b by A8,A13,A5,A2,XXREAL_1:2; then
      [.p,b.] c= ].-infty,b.] by XXREAL_1:39; then
A17:   [.p,b.] c= dom f by A1,A5,A2;
A18:  [.p,b.] = ['p,b'] by A16,INTEGRA5:def 3;
A19:   q <= b by A8,A14,A5,A2,XXREAL_1:2;
A20:   f is_integrable_on ['p,b'] & f|['p,b'] is bounded
        by A6,A16,INTEGR10:def 6;
A21:   [.q,b.] c= [.p,b.] by A15,XXREAL_1:34;
      Intf.p = integral(f,p,b) & Intf.q = integral(f,q,b) by A13,A14,A9;
      hence Intf.q <= Intf.p by A17,A20,A21,A19,A18,Th14,A4,MESFUNC6:55;
     end; then
A22: Intf is non-increasing by RFUNCT_2:def 4;

     consider E be SetSequence of L-Field such that
A23:   (for n be Nat holds E.n = [.b-n,b.]) &
      E is non-descending & E is convergent & Union E = ].-infty,b.] by Th26;

A24: A1 = dom(f|A1) by A1,A2,RELAT_1:62; then
A25:  A1 = dom(R_EAL(f|A)) by MESFUNC5:def 7;

A26:  lim E c= A1 by A23,A5,SETLIM_1:80;

     lim E = Union E by A23,SETLIM_1:80; then
     A1 \ lim E = {} by A23,A5,XBOOLE_1:37; then
A27:  L-Meas.(A1 \ lim E) = 0 by VALUED_0:def 19;

A28:  R_EAL f is A1-measurable by A1,A2,A3,A5,Th37,MESFUNC6:def 1;

     A1 = dom f /\ A1 by A24,RELAT_1:61; then
     A1 = dom(R_EAL f) /\ A1 by MESFUNC5:def 7; then
     (R_EAL f)|A is A1-measurable by A28,MESFUNC5:42; then
A29:  R_EAL(f|A) is A1-measurable by Th16; then
A30: f|A is A1-measurable by MESFUNC6:def 1;

     f|A is nonnegative by A4,MESFUNC6:55; then
A31: R_EAL (f|A) is nonnegative by MESFUNC5:def 7; then
A32: integral+(L-Meas,max-(R_EAL(f|A))) < +infty by A29,A25,MESFUN11:53;

     consider I be ExtREAL_sequence such that
A33:  for n be Nat holds
       I.n = Integral(L-Meas,(R_EAL(f|A))|((Partial_Union E).n)) and
      I is convergent and
A34:   Integral(L-Meas,R_EAL(f|A)) = lim I by A23,A29,A25,A26,A27,A32,Th19;

A35: for x be Real st x in dom Intf holds Intf.x = Integral(L-Meas,f|[.x,b.])
     proof
      let x be Real;
      assume A36: x in dom Intf; then
A37:   -infty < x <= b by A8,A2,A5,XXREAL_1:2; then
A38:   f is_integrable_on ['x,b'] & f|['x,b'] is bounded by A3,INTEGR25:def 1;
      reconsider AX = [.x,b.] as non empty closed_interval Subset of REAL
        by A37,XXREAL_1:30,MEASURE5:def 3;
A39:  AX = ['x,b'] by A37,INTEGRA5:def 3;
      AX c= ].-infty,b.] by A37,XXREAL_1:39; then
A40:  AX c= dom f by A1,A2,A5;

      reconsider AX1 = AX as Element of L-Field by MEASUR10:5,MEASUR12:75;
      AX = AX1; then
      integral(f||AX) = Integral(L-Meas,f|[.x,b.])
        by A38,A39,A40,MESFUN14:49; then
      integral(f,AX) = Integral(L-Meas,f|[.x,b.]) by INTEGRA5:def 2; then
      integral(f,x,b) = Integral(L-Meas,f|[.x,b.]) by A37,A39,INTEGRA5:def 4;
      hence Intf.x = Integral(L-Meas,f|[.x,b.]) by A9,A36;
     end;

A41: for m be Nat holds I.m = integral(f,b-m,b)
     proof
      let m be Nat;
A42:  -infty < b-m <= b by XREAL_0:def 1,XXREAL_0:12,XREAL_1:43; then
A43:  f||['b-m,b'] is bounded by A6,INTEGR10:def 6;

A44:   ['b-m,b'] = [.b-m,b.] by XREAL_1:43,INTEGRA5:def 3; then
      ['b-m,b'] c= ].-infty,b.] by A42,XXREAL_1:39; then
A45:   ['b-m,b'] c= dom f by A1,A2,A5;

A46:  E.m = [.b-m,b.] by A23;

      (R_EAL f|A)|(E.m) = (f|A)|(E.m) by MESFUNC5:def 7; then
A47:  (R_EAL f|A)|(E.m) = f|(E.m) by A46,A42,A5,XXREAL_1:39,RELAT_1:74;

      Partial_Union E = E by A23,PROB_4:15; then
      I.m = Integral(L-Meas,(R_EAL f|A)|(E.m)) by A33; then
      I.m = Integral(L-Meas,(R_EAL f|(E.m))) by A47,MESFUNC5:def 7; then
      I.m = Integral(L-Meas,f|(E.m)) by MESFUNC6:def 3;
      hence I.m = integral(f,b-m,b)
        by A6,A42,A46,A44,A45,A43,INTEGR10:def 6,MESFUN14:50;
     end;

     for p be Real st 0<p ex n be Nat st for m be Nat st n<=m
      holds |.I.m - infty_ext_left_integral(f,b) qua ExtReal.|<p
     proof
      let p be Real;
      assume 0<p; then
      consider r be Real such that
A48:    for r1 be Real st r1<r & r1 in dom Intf holds
        |.Intf.r1 - lim_in-infty Intf .| < p by A10,LIMFUNC1:78;

      set rr = min(b,r);

      consider n be Nat such that
A49:    b-r < n by SEQ_4:3;
      set r1=b-n;

A50:   b < r + n by A49,XREAL_1:19;

A51:  -infty < r1 <= b by XREAL_0:def 1,XXREAL_0:12,XREAL_1:43; then
      r1 in dom Intf by A2,A5,A8,XXREAL_1:2; then
A52:  |.Intf.r1- lim_in-infty Intf .| < p by A48,A50,XREAL_1:19;

      take n;
      thus for m be Nat st n<=m holds
       |.I.m - infty_ext_left_integral(f,b) qua ExtReal.|<p
      proof
       let m be Nat;
       set rm = b-m;
       assume n<=m; then
       rm <= r1 by XREAL_1:10; then
A53:   [.r1,b.] c= [.rm,b.] by XXREAL_1:34;

A54:   -infty < rm by XREAL_0:def 1,XXREAL_0:12; then
       [.rm,b.] c= ].-infty,b.] by XXREAL_1:39; then
A55:    [.rm,b.] c= dom f by A1,A2,A5;

A56:    rm <= b by XREAL_1:43; then
       f|['rm,b'] is bounded by A3,INTEGR25:def 1; then
A57:    f|[.rm,b.] is bounded by XREAL_1:43,INTEGRA5:def 3;

       f is_integrable_on ['rm,b'] by A56,A3,INTEGR25:def 1; then
       integral(f,r1,b) <= integral(f,rm,b)
         by A4,A51,A53,A55,A57,Th14,MESFUNC6:55; then
       Intf.r1 <= integral(f,rm,b) by A9,A51,A2,A5,A8,XXREAL_1:2; then
A58:   Intf.r1 <= I.m by A41;

A59:   rm in dom Intf by A8,A2,A5,A56,A54,XXREAL_1:2;

       Intf.rm = integral(f,b-m,b) by A9,A8,A2,A5,A56,A54,XXREAL_1:2; then
       I.m = Intf.rm by A41; then
A60:   lim_in-infty Intf - I.m >= 0 by A10,A22,A59,Th10,XXREAL_3:40; then
       -(lim_in-infty Intf - I.m) <= 0; then
       I.m - lim_in-infty Intf <= 0 by XXREAL_3:26; then
A61:   |.I.m- lim_in-infty Intf.|
        = -(I.m - lim_in-infty Intf) by EXTREAL1:18
       .= lim_in-infty Intf-I.m by XXREAL_3:26;

       reconsider EX = lim_in-infty Intf as ExtReal;
       EX - Intf.r1
        = EX + -((Intf.r1) qua ExtReal) by XXREAL_3:def 4
       .= lim_in-infty Intf + (-Intf.r1) by XXREAL_3:def 2
       .= lim_in-infty Intf - Intf.r1; then
A62:   lim_in-infty Intf - I.m
        <= lim_in-infty Intf - Intf.r1 by A58,XXREAL_3:37; then
       -(lim_in-infty Intf - Intf.r1) <= 0 by A60; then
       |.Intf.r1 - lim_in-infty Intf.|
        = -(Intf.r1 - lim_in-infty Intf) by ABSVALUE:30
       .= lim_in-infty Intf - Intf.r1;
       hence |.I.m - infty_ext_left_integral(f,b) qua ExtReal.| < p
         by A11,A52,A62,A61,XXREAL_0:2;
      end;
     end; then
     consider RI be Real such that
A63:   lim I = RI &
      for p be Real st 0<p ex n be Nat st for m be Nat st n<=m holds
       |.I.m-lim I.|< p by MESFUNC5:def 8,MESFUNC9:7;
A64:  RI = Integral(L-Meas,f|A) by A34,A63,MESFUNC6:def 3;

     for g1 be Real st 0 < g1 ex R be Real st for r1 be Real st r1<R &
      r1 in dom Intf holds |.Intf.r1-RI.|<g1
     proof
      let g1 be Real;
      assume A65: 0 < g1;
      set g2 = g1/2;

      consider N be Nat such that
A66:    for m be Nat st N <= m holds |.I.m - lim I.| < g1 by A65,A63;
      take R = b-N;
A67:  -infty < R <= b by XREAL_0:def 1,XXREAL_0:12,XREAL_1:43; then
A68:   R in dom Intf by A8,A5,A2,XXREAL_1:2;

      thus for r1 be Real st r1<R & r1 in dom Intf holds
            |. Intf.r1 - RI .| < g1
      proof
       let r1 be Real;
       assume that
A69:     r1 < R and
A70:     r1 in dom Intf;

       I.N = integral(f,b-N,b) by A41; then
A71:    Intf.R = I.N by A67,A9,A8,A5,A2,XXREAL_1:2;

A72:    I.N <= Intf.r1 by A71,A69,A68,A70,A12;
       RI - I.N = RI qua ExtReal - I.N &
       RI - Intf.r1 = RI qua ExtReal - Intf.r1; then
A73:  RI - Intf.r1 <= RI - I.N by A72,XXREAL_3:37;

A74:  |. I.N - RI .| < g1 by A66,A63;
       reconsider A2 = [.r1,b.] as Element of L-Field
         by MEASUR10:5,MEASUR12:75;

       r1 in REAL by XREAL_0:def 1; then
A75:    A2 c= A1 by A5,XXREAL_0:12,XXREAL_1:39; then
       Integral(L-Meas,(f|A)|A2) <= Integral(L-Meas,(f|A)|A1)
         by A24,A30,A4,MESFUNC6:55,87; then
       Integral(L-Meas,f|A2) <= RI by A64,A75,RELAT_1:74; then
A76:  Intf.r1 <= RI by A70,A35; then
A77:  |.Intf.r1 - RI.| = -(Intf.r1 - RI) by ABSVALUE:30,XREAL_1:47
        .= RI - Intf.r1;

       I.N <= RI by A72,A76,XXREAL_0:2; then
       |.RI - I.N.| = RI - I.N by EXTREAL1:def 1,XXREAL_3:40; then
       |.-(RI - I.N).| = RI - I.N by EXTREAL1:29; then
       |.I.N - RI.| = RI - I.N by XXREAL_3:26;
       hence |.Intf.r1 - RI.| < g1 by A73,A77,A74,XXREAL_0:2;
      end;
     end;
     hence improper_integral_-infty(f,b) = Integral(L-Meas,f|A)
        by A10,A11,A7,A64,LIMFUNC1:78;

     max+(R_EAL(f|A)) = R_EAL(f|A) by A31,MESFUN11:31; then
     Integral(L-Meas,f|A) = integral+(L-Meas,max+(R_EAL(f|A)))
       by A30,A24,A4,MESFUNC6:55,82; then
     integral+(L-Meas,max+(R_EAL(f|A))) < +infty
       by A64,XREAL_0:def 1,XXREAL_0:9;
     hence (f is_-infty_ext_Riemann_integrable_on b
       implies f|A is_integrable_on L-Meas)
         by A29,A25,A32,MESFUNC5:def 17,MESFUNC6:def 4;
     thus (not f is_-infty_ext_Riemann_integrable_on b
       implies Integral(L-Meas,f|A) = +infty) by A6;
    end;
    suppose
A78:  not f is_-infty_ext_Riemann_integrable_on b;
     hence improper_integral_-infty(f,b) = Integral(L-Meas,f|A)
       by A1,A2,A3,A4,Lm9;
     thus (f is_-infty_ext_Riemann_integrable_on b
       implies f|A is_integrable_on L-Meas) by A78;
     thus (not f is_-infty_ext_Riemann_integrable_on b
       implies Integral(L-Meas,f|A) = +infty) by A1,A2,A3,A4,Lm9;
    end;
end;

theorem Th48:
for f be PartFunc of REAL,REAL, b be Real, A be non empty Subset of REAL
 st left_closed_halfline b c= dom f & A = left_closed_halfline b
 & f is_-infty_improper_integrable_on b & f is nonpositive
 holds improper_integral_-infty(f,b) = Integral(L-Meas,f|A)
    & (f is_-infty_ext_Riemann_integrable_on b
        implies f|A is_integrable_on L-Meas)
    & (not f is_-infty_ext_Riemann_integrable_on b
        implies Integral(L-Meas,f|A) = -infty)
proof
    let f be PartFunc of REAL,REAL, b be Real, A be non empty Subset of REAL;
    assume that
A1:  left_closed_halfline b c= dom f and
A2:  A = left_closed_halfline b and
A3:  f is_-infty_improper_integrable_on b and
A4:  f is nonpositive;

A5: A = ].-infty,b.] by A2,LIMFUNC1:def 1; then
    reconsider A1 = A as Element of L-Field by MEASUR10:5,MEASUR12:75;

A6: -f is_-infty_improper_integrable_on b by A1,A3,INTEGR25:43;
A7: improper_integral_-infty(-f,b) = - improper_integral_-infty(f,b)
      by A1,A3,INTEGR25:43;

    for x be object st x in dom (-f) holds 0 <= (-f).x
    proof
     let x be object;
     assume x in dom (-f); then
A8:  f.x <= 0 by A4,MESFUNC6:53;
     (-f).x = -(f.x) by VALUED_1:8;
     hence 0 <= (-f).x by A8;
    end; then
A9: -f is nonnegative by MESFUNC6:52;

A10:dom(-f) = dom f by VALUED_1:8; then
A11:improper_integral_-infty(-f,b)
      = Integral(L-Meas,(-f)|A) by A1,A2,A6,A9,Th47
     .= Integral(L-Meas,-(f|A)) by RFUNCT_1:46;

A12:dom(f|A) = A by A1,A2,RELAT_1:62; then
A13:A1 = dom f /\ A1 by RELAT_1:61;

A14:f|A is A1-measurable by A13,A1,A2,A3,A5,Th37,MESFUNC6:76; then
    Integral(L-Meas,-(f|A)) = - Integral(L-Meas,f|A) by A12,Th39;
    hence improper_integral_-infty(f,b) = Integral(L-Meas,f|A)
      by A7,A11,XXREAL_3:10;

    hereby assume f is_-infty_ext_Riemann_integrable_on b; then
     (-1)(#)f is_-infty_ext_Riemann_integrable_on b by A1,INTEGR10:11; then
     -f is_-infty_ext_Riemann_integrable_on b by VALUED_1:def 6; then
     (-f)|A is_integrable_on L-Meas by A1,A2,A6,A10,A9,Th47; then
     -(f|A) is_integrable_on L-Meas by RFUNCT_1:46; then
     (-1)(#)(-(f|A)) is_integrable_on L-Meas by MESFUNC6:102;
     hence f|A is_integrable_on L-Meas;
    end;
    hereby assume
A15:  not f is_-infty_ext_Riemann_integrable_on b;
     now assume -f is_-infty_ext_Riemann_integrable_on b; then
      (-1)(#)(-f) is_-infty_ext_Riemann_integrable_on b by A1,A10,INTEGR10:11;
      hence contradiction by A15;
     end; then
     Integral(L-Meas,(-f)|A) = +infty by A1,A2,A6,A10,A9,Th47; then
     Integral(L-Meas,-(f|A)) = +infty by RFUNCT_1:46; then
     -Integral(L-Meas,f|A) = +infty by A12,A14,Th39;
     hence Integral(L-Meas,f|A) = -infty by XXREAL_3:23;
    end;
end;

Lm10:
for f be PartFunc of REAL,REAL, a be Real, A be non empty Subset of REAL
 st right_closed_halfline a c= dom f & A = right_closed_halfline a
 & f is_+infty_improper_integrable_on a & f is nonnegative
 & not f is_+infty_ext_Riemann_integrable_on a
 holds improper_integral_+infty(f,a) = Integral(L-Meas,f|A)
  & Integral(L-Meas,f|A) = +infty
proof
    let f be PartFunc of REAL,REAL, a be Real, A be non empty Subset of REAL;
    assume that
A1:  right_closed_halfline a c= dom f and
A2:  A = right_closed_halfline a and
A3:  f is_+infty_improper_integrable_on a and
A4:  f is nonnegative and
A5:  not f is_+infty_ext_Riemann_integrable_on a;

A6: for b be Real st a <= b holds
     f is_integrable_on ['a,b'] & f|['a,b'] is bounded by A3,INTEGR25:def 2;

A7: A = [.a,+infty.[ by A2,LIMFUNC1:def 2; then
    reconsider A1 = A as Element of L-Field by MEASUR10:5,MEASUR12:75;

A8: R_EAL f is A1-measurable by A1,A2,A7,A3,Th36,MESFUNC6:def 1;

A9:A1 = dom(f|A1) by A1,A2,RELAT_1:62; then
    A1 = dom f /\ A1 by RELAT_1:61; then
    A1 = dom(R_EAL f) /\ A1 by MESFUNC5:def 7; then
    (R_EAL f)|A1 is A1-measurable by A8,MESFUNC5:42; then
A10: (R_EAL f|A1) is A1-measurable by Th16;

    f|A1 is nonnegative by A4,MESFUNC6:55; then
A11: R_EAL(f|A1) is nonnegative by MESFUNC5:def 7;

    A1 = dom(R_EAL(f|A1)) by A9,MESFUNC5:def 7; then
A12: integral+(L-Meas,max-(R_EAL f|A1)) < +infty by A10,A11,MESFUN11:53;

A13: A1 = dom(R_EAL f|A1) by A9,MESFUNC5:def 7;

    consider E be SetSequence of L-Field such that
A14:  (for n be Nat holds E.n = [.a,a+n.]) &
     E is non-descending & E is convergent & Union E = [. a,+infty .[ by Th25;

A15: lim E = Union E by A14,SETLIM_1:80; then
    A1 \ lim E = {} by A14,A7,XBOOLE_1:37; then
    L-Meas.(A1 \ lim E) = 0 by VALUED_0:def 19; then
    consider I be ExtREAL_sequence such that
A16:  for n be Nat holds
      I.n = Integral(L-Meas,(R_EAL f|A)|((Partial_Union E).n)) and
      I is convergent and
A17:   Integral(L-Meas,(R_EAL f|A)) = lim I by A10,A13,A12,A14,A7,A15,Th19;

    consider Intf be PartFunc of REAL,REAL such that
A18:  dom Intf = right_closed_halfline a and
A19:  for x be Real st x in dom Intf holds Intf.x = integral(f,a,x) and
A20:  Intf is convergent_in+infty or Intf is divergent_in+infty_to+infty
  or Intf is divergent_in+infty_to-infty by A3,INTEGR25:def 2;

A21: for x be Real st x in dom Intf holds Intf.x >= 0
    proof
     let x be Real;
     assume A22: x in dom Intf; then
A23:  a <= x < +infty by A18,A2,A7,XXREAL_1:3; then
     reconsider AX = [.a,x.] as non empty closed_interval Subset of REAL
       by XXREAL_1:30,MEASURE5:def 3;
     AX c= [.a,+infty.[ by A23,XXREAL_1:43; then
     AX c= dom f by A1,A2,A7; then
     dom(f|AX) = AX by RELAT_1:62; then
     reconsider f1 = f|AX as Function of AX,REAL by FUNCT_2:def 1,RELSET_1:5;

A24:  AX = ['a,x'] by A23,INTEGRA5:def 3; then
A25:  f1|AX is bounded by A23,A3,INTEGR25:def 2;
     for r be Real st r in AX holds f1.r >= 0
     proof
      let r be Real;
      assume A26: r in AX;
      f.r >= 0 by A4,MESFUNC6:51;
      hence f1.r >= 0 by A26,FUNCT_1:49;
     end; then
     integral(f1) >= 0 by A25,INTEGRA2:32; then
     integral(f,AX) >= 0 by INTEGRA5:def 2; then
     integral(f,a,x) >= 0 by A23,A24,INTEGRA5:def 4;
     hence Intf.x >= 0 by A19,A22;
    end;

A27:now assume
A28:  Intf is divergent_in+infty_to-infty; then
     consider r be Real such that
A29:  for r1 be Real st r < r1 & r1 in dom Intf holds Intf.r1 < 0
        by LIMFUNC1:47;

     consider r1 be Real such that
A30:  r < r1 & r1 in dom Intf by A28,LIMFUNC1:47;

     Intf.r1 < 0 by A29,A30;
     hence contradiction by A21,A30;
    end; then
A31:improper_integral_+infty(f,a) = +infty
      by A3,A18,A19,A20,A5,A6,INTEGR10:def 5,INTEGR25:def 4;

    for g be Real st 0 < g
     ex n be Nat st for m be Nat st n<=m holds g <= I.m
    proof
     let g be Real;
     assume 0 < g;
     consider r be Real such that
A32:   for r1 be Real st r<r1 & r1 in dom Intf holds g<Intf.r1
       by A27,A18,A19,A20,A5,A6,INTEGR10:def 5,LIMFUNC1:46;
     consider r1 be Real such that
A33:   r < r1 & r1 in dom Intf by A27,A18,A19,A20,A5,A6
,INTEGR10:def 5,LIMFUNC1:46;
     g < Intf.r1 by A32,A33; then
A34: g < integral(f,a,r1) by A33,A19;

     consider n be Nat such that
A35:   r1-a < n by SEQ_4:3;
A36:  r1 < a + n by A35,XREAL_1:19;

     take n;
     thus for m be Nat st n <= m holds g <= I.m
     proof
      let m be Nat;
      assume n <= m; then
      a+n <= a+m by XREAL_1:6; then
A37:  r1 < a+m by A36,XXREAL_0:2;

A38:   a+m < +infty by XREAL_0:def 1,XXREAL_0:9;

A39:  a <= a+m by XREAL_1:31; then
A40:   f is_integrable_on ['a,a+m'] & f|['a,a+m'] is bounded
        by A3,INTEGR25:def 2;

A41:   ['a,a+m'] = [.a,a+m.] by XREAL_1:31,INTEGRA5:def 3; then
      ['a,a+m'] c= [.a,+infty.[ by A38,XXREAL_1:43; then
A42:   ['a,a+m'] c= dom f by A1,A7,A2;

A43:   a<= r1 & r1 < +infty by A33,A18,A2,A7,XXREAL_1:3; then
      r1 in ['a,a+m'] by A37,A41,XXREAL_1:1; then
A44:   integral(f,a,a+m) = integral(f,a,r1) + integral(f,r1,a+m)
        by A39,A40,A42,INTEGRA6:17;

      [.r1,a+m.] c= [.a,+infty.[ by A43,A38,XXREAL_1:43; then
A45:  [.r1,a+m.] c= dom f by A1,A7,A2;

      f|[.r1,a+m.] is bounded by A40,A41,A43,XXREAL_1:34,RFUNCT_1:74; then
      integral(f,r1,a+m) >= 0 by A4,A37,A45,Th12,MESFUNC6:55; then
A46:   integral(f,a,r1) <= integral(f,a,a+m) by A44,XREAL_1:31;

A47:   E.m = [.a,a+m.] by A14;

      (R_EAL f|A)|(E.m) = (f|A)|(E.m) by MESFUNC5:def 7; then
A48:   (R_EAL f|A)|(E.m) = f|(E.m) by A47,A38,A7,XXREAL_1:43,RELAT_1:74;

A49:   f||['a,a+m'] is bounded by A39,A3,INTEGR25:def 2;

      I.m = Integral(L-Meas,(R_EAL f|A)|((Partial_Union E).m)) by A16
       .= Integral(L-Meas,(R_EAL f|A)|(E.m)) by A14,PROB_4:15
       .= Integral(L-Meas,(R_EAL f|(E.m))) by A48,MESFUNC5:def 7
       .= Integral(L-Meas,f|(E.m)) by MESFUNC6:def 3
       .= Integral(L-Meas,f|[.a,a+m.]) by A14
       .= integral(f,a,a+m) by A49,A39,A41,A42,A3,INTEGR25:def 2,MESFUN14:50;
      hence g <= I.m by A46,A34,XXREAL_0:2;
     end;
    end; then
    I is convergent_to_+infty by MESFUNC5:def 9; then
A50:Integral(L-Meas,R_EAL f|A) = +infty by A17,MESFUNC5:def 12;
    hence improper_integral_+infty(f,a) = Integral(L-Meas,f|A)
      by A31,MESFUNC6:def 3;
    thus Integral(L-Meas,f|A) = +infty by A50,MESFUNC6:def 3;
end;

theorem Th49:
for f be PartFunc of REAL,REAL, a be Real, A be non empty Subset of REAL
 st right_closed_halfline a c= dom f & A = right_closed_halfline a
 & f is_+infty_improper_integrable_on a & f is nonnegative
 holds improper_integral_+infty(f,a) = Integral(L-Meas,f|A)
  & (f is_+infty_ext_Riemann_integrable_on a
      implies f|A is_integrable_on L-Meas)
  & (not f is_+infty_ext_Riemann_integrable_on a
      implies Integral(L-Meas,f|A) = +infty)
proof
    let f be PartFunc of REAL,REAL, a be Real, A be non empty Subset of REAL;
    assume that
A1:  right_closed_halfline a c= dom f and
A2:  A = right_closed_halfline a and
A3:  f is_+infty_improper_integrable_on a and
A4:  f is nonnegative;

A5: A = [.a,+infty.[ by A2,LIMFUNC1:def 2; then
    reconsider A1 = A as Element of L-Field by MEASUR10:5,MEASUR12:75;

    per cases;
    suppose
A6:  f is_+infty_ext_Riemann_integrable_on a; then
A7:  improper_integral_+infty(f,a) = infty_ext_right_integral(f,a)
       by A3,INTEGR25:27;

     consider Intf be PartFunc of REAL,REAL such that
A8:   dom Intf = right_closed_halfline a and
A9:   for x be Real st x in dom Intf holds Intf.x = integral(f,a,x) and
A10:   Intf is convergent_in+infty and
A11:   infty_ext_right_integral(f,a) = lim_in+infty Intf by A6,INTEGR10:def 7;

A12:  for p,q be Real st p in dom Intf & q in dom Intf & p < q holds
      Intf.p <= Intf.q
     proof
      let p,q be Real;
      assume that
A13:    p in dom Intf and
A14:    q in dom Intf and
A15:    p < q;

A16:   a <= q < +infty by A8,A14,A5,A2,XXREAL_1:3; then
      [.a,q.] c= [.a,+infty.[ by XXREAL_1:43; then
A17:   [.a,q.] c= dom f by A1,A5,A2;

A18:  [.a,q.] = ['a,q'] by A16,INTEGRA5:def 3;

A19:   a <= p by A8,A13,A5,A2,XXREAL_1:3;

A20:   f is_integrable_on ['a,q'] & f|['a,q'] is bounded
        by A6,A16,INTEGR10:def 5;

A21:   [.a,p.] c= [.a,q.] by A15,XXREAL_1:34;

      Intf.p = integral(f,a,p) & Intf.q = integral(f,a,q) by A13,A14,A9;
      hence Intf.p <= Intf.q by A17,A20,A4,A21,A19,A18,Th14,MESFUNC6:55;
     end; then
A22: Intf is non-decreasing by RFUNCT_2:def 3;

     consider E be SetSequence of L-Field such that
A23:   (for n be Nat holds E.n = [.a,a+n.]) &
      E is non-descending & E is convergent & Union E = [.a,+infty.[ by Th25;

A24: A1 = dom(f|A1) by A1,A2,RELAT_1:62; then
A25:  A1 = dom(R_EAL(f|A)) by MESFUNC5:def 7;

A26: lim E = Union E by A23,SETLIM_1:80; then
A27:  lim E c= A1 by A23,A2,LIMFUNC1:def 2;

     A1 \ lim E = {} by A23,A26,A5,XBOOLE_1:37; then
A28:  L-Meas.(A1 \ lim E) = 0 by VALUED_0:def 19;

A29:  R_EAL f is A1-measurable by A1,A2,A3,A5,Th36,MESFUNC6:def 1;

     A1 = dom f /\ A1 by A24,RELAT_1:61; then
     A1 = dom(R_EAL f) /\ A1 by MESFUNC5:def 7; then
     (R_EAL f)|A is A1-measurable by A29,MESFUNC5:42; then
A30:  R_EAL(f|A) is A1-measurable by Th16; then
A31: f|A is A1-measurable by MESFUNC6:def 1;

     f|A is nonnegative by A4,MESFUNC6:55; then
A32: R_EAL (f|A) is nonnegative by MESFUNC5:def 7; then
A33: integral+(L-Meas,max-(R_EAL(f|A))) < +infty by A30,A25,MESFUN11:53; then
     consider I be ExtREAL_sequence such that
A34:  for n be Nat holds
       I.n = Integral(L-Meas,(R_EAL(f|A))|((Partial_Union E).n)) and
      I is convergent and
A35:  Integral(L-Meas,R_EAL(f|A)) = lim I by A23,A30,A25,A27,A28,Th19;

A36: for x be Real st x in dom Intf holds Intf.x = Integral(L-Meas,f|[.a,x.])
     proof
      let x be Real;
      assume A37: x in dom Intf; then
A38:   a <= x < +infty by A8,A2,A5,XXREAL_1:3; then
A39:   f is_integrable_on ['a,x'] & f|['a,x'] is bounded by A3,INTEGR25:def 2;
      reconsider AX = [.a,x.] as non empty closed_interval Subset of REAL
        by A38,XXREAL_1:30,MEASURE5:def 3;
A40:  AX = ['a,x'] by A38,INTEGRA5:def 3;
      AX c= [.a,+infty.[ by A38,XXREAL_1:43; then
A41:  AX c= dom f by A1,A2,A5;

      reconsider AX1 = AX as Element of L-Field by MEASUR10:5,MEASUR12:75;
      AX = AX1; then
      integral(f||AX) = Integral(L-Meas,f|[.a,x.])
        by A41,A39,A40,MESFUN14:49; then
      integral(f,AX) = Integral(L-Meas,f|[.a,x.]) by INTEGRA5:def 2; then
      integral(f,a,x) = Integral(L-Meas,f|[.a,x.]) by A38,A40,INTEGRA5:def 4;
      hence Intf.x = Integral(L-Meas,f|[.a,x.]) by A9,A37;
     end;

A42: Partial_Union E = E by A23,PROB_4:15;

A43: for m be Nat holds I.m = integral(f,a,a+m)
     proof
      let m be Nat;
A44:  a <= a+m < +infty by XREAL_0:def 1,XXREAL_0:9,XREAL_1:31; then
A45:  f||['a,a+m'] is bounded by A6,INTEGR10:def 5;

A46:   ['a,a+m'] = [.a,a+m.] by XREAL_1:31,INTEGRA5:def 3; then
      ['a,a+m'] c= [.a,+infty.[ by A44,XXREAL_1:43; then
A47:   ['a,a+m'] c= dom f by A1,A2,A5;

A48:  E.m = [.a,a+m.] by A23;

      (R_EAL f|A)|(E.m) = (f|A)|(E.m) by MESFUNC5:def 7; then
      (R_EAL f|A)|(E.m) = f|(E.m) by A48,A44,A5,XXREAL_1:43,RELAT_1:74; then
      (R_EAL f|A)|(E.m) = R_EAL f|(E.m) by MESFUNC5:def 7; then
      I.m = Integral(L-Meas,(R_EAL f|(E.m))) by A34,A42; then
      I.m = Integral(L-Meas,f|[.a,a+m.]) by A48,MESFUNC6:def 3;
      hence I.m = integral(f,a,a+m)
       by A46,A47,A45,A44,A6,INTEGR10:def 5,MESFUN14:50;
     end;

     for p be Real st 0<p ex n be Nat st for m be Nat st n<=m
      holds |.I.m - infty_ext_right_integral(f,a) qua ExtReal.|<p
     proof
      let p be Real;
      assume 0<p; then
      consider r be Real such that
A49:    for r1 be Real st r<r1 & r1 in dom Intf holds
        |.Intf.r1 - lim_in+infty Intf .| < p by A10,LIMFUNC1:79;

      set rr = max(a,r);
      consider n be Nat such that
A50:    r-a < n by SEQ_4:3;

A51:  a <= a+n < +infty by XREAL_0:def 1,XXREAL_0:9,XREAL_1:31; then
A52:  a+n in dom Intf by A2,A5,A8,XXREAL_1:3;
      set r1=a+n;
A53:  |.Intf.r1- lim_in+infty Intf .| < p by A49,A52,A50,XREAL_1:19;

      take n;
      thus for m be Nat st n<=m holds
       |.I.m - infty_ext_right_integral(f,a) qua ExtReal.|<p
      proof
       let m be Nat;
       assume
A54:     n<=m;

       set rm = a+m;

A55:   a+n <= a+m by A54,XREAL_1:6;


A56:   rm < +infty by XREAL_0:def 1,XXREAL_0:9; then
       [.a,rm.] c= [.a,+infty.[ by XXREAL_1:43; then
A57:    [.a,rm.] c= dom f by A1,A2,A5;

A58:    a <= rm by XREAL_1:31; then
       f|['a,rm'] is bounded by A3,INTEGR25:def 2; then
A59:    f|[.a,rm.] is bounded by XREAL_1:31,INTEGRA5:def 3;

A60:    f is_integrable_on ['a,rm'] by A58,A3,INTEGR25:def 2;

       [.a,r1.] c= [.a,rm.] by A55,XXREAL_1:34; then
       integral(f,a,r1) <= integral(f,a,rm)
         by A4,A51,A57,A59,A60,Th14,MESFUNC6:55; then
       Intf.r1 <= integral(f,a,rm) by A9,A51,A2,A5,A8,XXREAL_1:3; then
A61:   Intf.r1 <= I.m by A43;

A62:   rm in dom Intf by A8,A2,A5,A58,A56,XXREAL_1:3;

       Intf.rm = integral(f,a,a+m) by A9,A8,A2,A5,A58,A56,XXREAL_1:3; then
       I.m = Intf.rm by A43; then
A63:   lim_in+infty Intf - I.m >= 0 by A10,A22,A62,Th11,XXREAL_3:40; then
       -(lim_in+infty Intf - I.m) <= 0; then
       I.m - lim_in+infty Intf <= 0 by XXREAL_3:26; then
A64:   |.I.m- lim_in+infty Intf.|
        = -(I.m - lim_in+infty Intf) by EXTREAL1:18
       .= lim_in+infty Intf-I.m by XXREAL_3:26;

       reconsider EX = lim_in+infty Intf as ExtReal;
A65:   EX - Intf.r1
        = EX + -((Intf.r1) qua ExtReal) by XXREAL_3:def 4
       .= lim_in+infty Intf + (-Intf.r1) by XXREAL_3:def 2
       .= lim_in+infty Intf - Intf.r1;

A66:   EX - I.m <= EX - Intf.r1 by A61,XXREAL_3:37; then
       -(lim_in+infty Intf - Intf.r1) <= 0 by A65,A63; then
       |.Intf.r1 - lim_in+infty Intf.|
        = -(Intf.r1 - lim_in+infty Intf) by ABSVALUE:30
       .= lim_in+infty Intf - Intf.r1;
       hence |.I.m - infty_ext_right_integral(f,a) qua ExtReal.| < p
         by A11,A53,A65,A66,A64,XXREAL_0:2;
      end;
     end; then
     consider RI be Real such that
A67:   lim I = RI &
      for p be Real st 0<p ex n be Nat st for m be Nat st n<=m holds
       |.I.m-lim I.|< p by MESFUNC5:def 8,MESFUNC9:7;
A68:  RI = Integral(L-Meas,f|A) by A35,A67,MESFUNC6:def 3;

     for g1 be Real st 0 < g1 ex R be Real st for r1 be Real st R<r1 &
     r1 in dom Intf holds |.Intf.r1-RI.|<g1
     proof
      let g1 be Real;
      assume A69: 0 < g1;
      set g2 = g1/2;

      consider N be Nat such that
A70:    for m be Nat st N <= m holds |.I.m - lim I.| < g1 by A69,A67;
      take R = a+N;
A71:  a <= R < +infty by XREAL_0:def 1,XXREAL_0:9,XREAL_1:31; then
A72:   R in dom Intf by A8,A5,A2,XXREAL_1:3;

      thus
       for r1 be Real st R<r1 & r1 in dom Intf holds |. Intf.r1 - RI .| < g1
      proof
       let r1 be Real;
       assume that
A73:     R < r1 and
A74:     r1 in dom Intf;

       I.N = integral(f,a,a+N) by A43; then
       Intf.R = I.N by A71,A9,A8,A5,A2,XXREAL_1:3; then
A75:    I.N <= Intf.r1 by A73,A72,A74,A12;
       RI - I.N = RI qua ExtReal - I.N &
       RI - Intf.r1 = RI qua ExtReal - Intf.r1; then
A76:  RI - Intf.r1 <= RI - I.N by A75,XXREAL_3:37;

A77:  |. I.N - RI .| < g1 by A70,A67;
       reconsider A2 = [.a,r1.] as Element of L-Field
         by MEASUR10:5,MEASUR12:75;

       r1 in REAL by XREAL_0:def 1; then
A78:    A2 c= A1 by A5,XXREAL_0:9,XXREAL_1:43; then
       Integral(L-Meas,(f|A)|A2) <= Integral(L-Meas,(f|A)|A1)
         by A24,A31,A4,MESFUNC6:55,87; then
       Integral(L-Meas,f|A2) <= RI by A78,A68,RELAT_1:74; then
A79:  Intf.r1 <= RI by A74,A36; then
A80:  |.Intf.r1 - RI.| = -(Intf.r1 - RI) by ABSVALUE:30,XREAL_1:47
        .= RI - Intf.r1;

       I.N <= RI by A75,A79,XXREAL_0:2; then
       |.RI - I.N.| = RI - I.N by EXTREAL1:def 1,XXREAL_3:40; then
       |.-(RI - I.N).| = RI - I.N by EXTREAL1:29; then
       |.I.N - RI.| = RI - I.N by XXREAL_3:26;
       hence |.Intf.r1 - RI.| < g1 by A76,A80,A77,XXREAL_0:2;
      end;
     end;
     hence improper_integral_+infty(f,a) = Integral(L-Meas,f|A)
        by A11,A7,A68,A10,LIMFUNC1:79;

     max+(R_EAL(f|A)) = R_EAL(f|A) by A32,MESFUN11:31; then
     Integral(L-Meas,f|A) = integral+(L-Meas,max+(R_EAL(f|A)))
       by A31,A24,A4,MESFUNC6:55,82; then
     integral+(L-Meas,max+(R_EAL(f|A))) < +infty
       by A68,XREAL_0:def 1,XXREAL_0:9;
     hence (f is_+infty_ext_Riemann_integrable_on a
       implies f|A is_integrable_on L-Meas)
         by A30,A25,A33,MESFUNC5:def 17,MESFUNC6:def 4;
     thus (not f is_+infty_ext_Riemann_integrable_on a
       implies Integral(L-Meas,f|A) = +infty) by A6;
    end;
    suppose
A81:  not f is_+infty_ext_Riemann_integrable_on a;
     hence improper_integral_+infty(f,a) = Integral(L-Meas,f|A)
       by A1,A2,A3,A4,Lm10;
     thus (f is_+infty_ext_Riemann_integrable_on a
       implies f|A is_integrable_on L-Meas) by A81;
     thus (not f is_+infty_ext_Riemann_integrable_on a
       implies Integral(L-Meas,f|A) = +infty) by A1,A2,A3,A4,Lm10;
    end;
end;

theorem Th50:
for f be PartFunc of REAL,REAL, a be Real, A be non empty Subset of REAL
 st right_closed_halfline a c= dom f & A = right_closed_halfline a
 & f is_+infty_improper_integrable_on a & f is nonpositive
 holds improper_integral_+infty(f,a) = Integral(L-Meas,f|A)
    & (f is_+infty_ext_Riemann_integrable_on a
        implies f|A is_integrable_on L-Meas)
    & (not f is_+infty_ext_Riemann_integrable_on a
        implies Integral(L-Meas,f|A) = -infty)
proof
    let f be PartFunc of REAL,REAL, a be Real, A be non empty Subset of REAL;
    assume that
A1:  right_closed_halfline a c= dom f and
A2:  A = right_closed_halfline a and
A3:  f is_+infty_improper_integrable_on a and
A4:  f is nonpositive;

A5: A = [.a,+infty.[ by A2,LIMFUNC1:def 2; then
    reconsider A1 = A as Element of L-Field by MEASUR10:5,MEASUR12:75;

A6: -f is_+infty_improper_integrable_on a by A1,A3,INTEGR25:44;
A7: improper_integral_+infty(-f,a) = - improper_integral_+infty(f,a)
      by A1,A3,INTEGR25:44;

    for x be object st x in dom (-f) holds 0 <= (-f).x
    proof
     let x be object;
     assume x in dom (-f); then
A8:  f.x <= 0 by A4,MESFUNC6:53;
     (-f).x = -(f.x) by VALUED_1:8;
     hence 0 <= (-f).x by A8;
    end; then
A9: -f is nonnegative by MESFUNC6:52;

A10:dom(-f) = dom f by VALUED_1:8; then
A11:improper_integral_+infty(-f,a)
      = Integral(L-Meas,(-f)|A) by A1,A2,A6,A9,Th49
     .= Integral(L-Meas,-(f|A)) by RFUNCT_1:46;

A12:dom(f|A) = A by A1,A2,RELAT_1:62; then
    A1 = dom f /\ A1 by RELAT_1:61; then
A13:f|A is A1-measurable by A1,A2,A3,A5,Th36,MESFUNC6:76; then
    Integral(L-Meas,-(f|A)) = - Integral(L-Meas,f|A) by A12,Th39;
    hence improper_integral_+infty(f,a) = Integral(L-Meas,f|A)
      by A7,A11,XXREAL_3:10;

    hereby assume f is_+infty_ext_Riemann_integrable_on a; then
     (-1)(#)f is_+infty_ext_Riemann_integrable_on a by A1,INTEGR10:9; then
     -f is_+infty_ext_Riemann_integrable_on a by VALUED_1:def 6; then
     (-f)|A is_integrable_on L-Meas by A1,A2,A6,A10,A9,Th49; then
     -(f|A) is_integrable_on L-Meas by RFUNCT_1:46; then
     (-1)(#)(-(f|A)) is_integrable_on L-Meas by MESFUNC6:102;
     hence f|A is_integrable_on L-Meas;
    end;
    hereby assume
A14:  not f is_+infty_ext_Riemann_integrable_on a;
     now assume -f is_+infty_ext_Riemann_integrable_on a; then
      (-1)(#)(-f) is_+infty_ext_Riemann_integrable_on a by A1,A10,INTEGR10:9;
      hence contradiction by A14;
     end; then
     Integral(L-Meas,(-f)|A) = +infty by A1,A2,A6,A10,A9,Th49; then
     Integral(L-Meas,-(f|A)) = +infty by RFUNCT_1:46; then
     -Integral(L-Meas,f|A) = +infty by A12,A13,Th39;
     hence Integral(L-Meas,f|A) = -infty by XXREAL_3:23;
    end;
end;

theorem Th51:
for X be non empty set, S be SigmaField of X, M be sigma_Measure of S,
 f be PartFunc of X,ExtREAL, A,B be Element of S st (ex E be Element of S
  st E = dom f & f is E-measurable) & f is nonnegative holds
  integral+(M,f|(A\/B)) <= integral+(M,f|A) + integral+(M,f|B)
proof
    let X be non empty set, S be SigmaField of X, M be sigma_Measure of S,
    f be PartFunc of X,ExtREAL, A,B be Element of S;
    assume that
A1:  ex E be Element of S st E = dom f & f is E-measurable and
A2:  f is nonnegative;

    set A1 = A \ B;
A3: integral+(M,f|A1) <= integral+(M,f|A) by A1,A2,XBOOLE_1:36,MESFUNC5:83;
A4: A1\/B = A\/B by XBOOLE_1:39;
    integral+(M,f|(A1\/B)) = integral+(M,f|A1) + integral+(M,f|B)
      by A1,A2,MESFUNC5:81,XBOOLE_1:79;
    hence integral+(M,f|(A\/B)) <= integral+(M,f|A) + integral+(M,f|B)
      by A3,A4,XXREAL_3:35;
end;

theorem Th52:
for X be non empty set, S be SigmaField of X, M be sigma_Measure of S,
 f be PartFunc of X,ExtREAL, A,B be set st
  A c= dom f & B c= dom f & f|A is_integrable_on M & f|B is_integrable_on M
  holds f|(A\/B) is_integrable_on M
proof
    let X be non empty set, S be SigmaField of X, M be sigma_Measure of S,
    f be PartFunc of X,ExtREAL, A,B be set;
    assume that
A1:  A c= dom f & B c= dom f and
A2:  f|A is_integrable_on M and
A3:  f|B is_integrable_on M;

    set f1 = f|(A\/B);

A4: A = dom(f|A) & B = dom(f|B) by A1,RELAT_1:62;
A5: ex E be Element of S st E = dom(f|A) & f|A is E-measurable
      by A2,MESFUNC5:def 17; then
    reconsider A1=A as Element of S by A1,RELAT_1:62;

A6: ex E be Element of S st E = dom(f|B) & f|B is E-measurable
      by A3,MESFUNC5:def 17; then
    reconsider B1=B as Element of S by A1,RELAT_1:62;

A7: integral+(M,max+(f|A)) < +infty & integral+(M,max-(f|A)) < +infty
      by A2,MESFUNC5:def 17;

A8: integral+(M,max+(f|B)) < +infty & integral+(M,max-(f|B)) < +infty
      by A3,MESFUNC5:def 17;

A9: dom f1 = dom f /\ (A\/B) by RELAT_1:61
     .= (dom f /\ A) \/ (dom f /\ B) by XBOOLE_1:23;
A10: dom(f|A) = dom f /\ A & dom(f|B) = dom f /\ B by RELAT_1:61;

A11:f1|A = f|A & f1|B = f|B by XBOOLE_1:7,RELAT_1:74; then
    f1 is A1-measurable & f1 is B1-measurable by A4,A5,A6,MESFUN13:19; then
A12:f1 is (A1\/B1)-measurable by MESFUNC1:31;

A13:dom(max+f1) = dom f1 & dom(max-f1) = dom f1 by MESFUNC2:def 2,def 3;

A14:max+f1 is nonnegative & max-f1 is nonnegative by MESFUN11:5;

A15:(max+f1)|A = max+(f|A) & (max+f1)|B = max+(f|B) &
    (max-f1)|A = max-(f|A) & (max-f1)|B = max-(f|B) by A11,MESFUNC5:28;

A16:(max+f1)|(A\/B) = max+( (f|(A\/B))|(A\/B) ) by MESFUNC5:28
     .= max+(f|(A\/B));
A17:(max-f1)|(A\/B) = max-( (f|(A\/B))|(A\/B) ) by MESFUNC5:28
     .= max-(f|(A\/B));

A18:integral+(M,(max+f1)|(A\/B))
     <= integral+(M,(max+f1)|A) + integral+(M,(max+f1)|B)
       by A13,A4,A9,A10,A14,Th51,A12,MESFUNC2:25;
    integral+(M,(max+f1)|A) + integral+(M,(max+f1)|B) <> +infty
      by A7,A8,A15,XXREAL_3:16; then
A19:integral+(M,max+(f|(A\/B))) < +infty by A16,A18,XXREAL_0:2,4;

A20:integral+(M,(max-f1)|(A\/B))
     <= integral+(M,(max-f1)|A) + integral+(M,(max-f1)|B)
       by A13,A4,A9,A10,A14,Th51,A12,MESFUNC2:26;
    integral+(M,(max-f1)|A) + integral+(M,(max-f1)|B) <> +infty
      by A7,A8,A15,XXREAL_3:16; then
    integral+(M,max-(f|(A\/B))) < +infty by A17,A20,XXREAL_0:2,4;
    hence f|(A\/B) is_integrable_on M by A4,A9,A10,A12,A19,MESFUNC5:def 17;
end;

theorem Th53:
for X be non empty set, S be SigmaField of X, M be sigma_Measure of S,
 f be PartFunc of X,REAL, A,B be set st
  A c= dom f & B c= dom f & f|A is_integrable_on M & f|B is_integrable_on M
  holds f|(A\/B) is_integrable_on M
proof
    let X be non empty set, S be SigmaField of X, M be sigma_Measure of S,
    f be PartFunc of X,REAL, A,B be set;
    assume that
A1:  A c= dom f and
A2:  B c= dom f and
A3:  f|A is_integrable_on M and
A4:  f|B is_integrable_on M;

A5: A c= dom(R_EAL f) & B c= dom(R_EAL f) by A1,A2,MESFUNC5:def 7;
    (R_EAL(f|A)) is_integrable_on M & (R_EAL(f|B)) is_integrable_on M
      by A3,A4,MESFUNC6:def 4; then
    (R_EAL f)|A is_integrable_on M & (R_EAL f)|B is_integrable_on M
      by Th16; then
    (R_EAL f)|(A\/B) is_integrable_on M by A5,Th52; then
    R_EAL(f|(A\/B)) is_integrable_on M by Th16;
    hence f|(A\/B) is_integrable_on M by MESFUNC6:def 4;
end;

theorem Th54:
for f be PartFunc of REAL,REAL, a be Real, A be non empty Subset of REAL
 st dom f = REAL & f is_improper_integrable_on_REAL & f is nonnegative
 holds improper_integral_on_REAL f = Integral(L-Meas,f)
  & (f is infty_ext_Riemann_integrable implies f is_integrable_on L-Meas)
  & (not f is infty_ext_Riemann_integrable implies
       Integral(L-Meas,f) = +infty)
proof
    let f be PartFunc of REAL,REAL, a be Real, A be non empty Subset of REAL;
    assume that
A1:  dom f = REAL and
A2:  f is_improper_integrable_on_REAL and
A3:  f is nonnegative;

    consider c be Real such that
A4:  f is_-infty_improper_integrable_on c and
A5:  f is_+infty_improper_integrable_on c and
A6:  improper_integral_on_REAL f
      = improper_integral_-infty(f,c) + improper_integral_+infty(f,c)
        by A1,A2,INTEGR25:def 6;

A7: -infty < c & c < +infty by XREAL_0:def 1,XXREAL_0:9,12; then
    reconsider A = ].-infty,c.] as non empty Subset of REAL by XXREAL_1:32;
    reconsider B = [.c,+infty.[ as non empty Subset of REAL by A7,XXREAL_1:31;

A8: A = left_closed_halfline c by LIMFUNC1:def 1; then
A9: improper_integral_-infty(f,c) = Integral(L-Meas,f|A) by A4,A1,A3,Th47;

A10:B = right_closed_halfline c by LIMFUNC1:def 2;

    REAL = ].-infty,+infty.[ by XXREAL_1:224; then
    reconsider E = REAL as Element of L-Field by MEASUR10:5,MEASUR12:75;
A11:f is E-measurable by A1,A2,Th38;

    reconsider A1=A as Element of L-Field by MEASUR10:5,MEASUR12:75;
    reconsider B1=B as Element of L-Field by MEASUR10:5,MEASUR12:75;
A12:f is A1-measurable by A1,A2,Th38;

    set C = {c};
A13: C = [.c,c.] by XXREAL_1:17;

    reconsider C = {c} as Element of L-Field by Th28;
A14: L-Meas.C = c-c by A13,MESFUN14:5 .= 0;

A15: dom(f|A) = A by A1,RELAT_1:62; then
    A1 = dom f /\ A1 by RELAT_1:61; then
A16: Integral(L-Meas,f|A)
     = Integral(L-Meas,(f|A)|(A\C)) by A12,A14,A15,MESFUNC6:76,89
    .= Integral(L-Meas,f|(A\C)) by XBOOLE_1:36,RELAT_1:74;

A17: -infty < c < +infty by XREAL_0:def 1,XXREAL_0:12,9; then
A18: A1\C = ].-infty,c.[ by XXREAL_1:137;

    A \/ B = ].-infty,+infty.[ by A17,XXREAL_1:172; then
A19: f|(A\/B) = f by XXREAL_1:224;

    A1\C \/ B1 = ].-infty,+infty.[ by A17,A18,XXREAL_1:173; then
    f = f|(A1\C \/ B1) by XXREAL_1:224; then
    Integral(L-Meas,f)
     = Integral(L-Meas,f|A1) + Integral(L-Meas,f|B1)
       by A16,A1,A11,A3,A18,XXREAL_1:94,MESFUNC6:85;
    hence improper_integral_on_REAL f = Integral(L-Meas,f)
      by A10,A6,A9,A5,A1,A3,Th49;
    hereby assume f is infty_ext_Riemann_integrable; then
     f is_+infty_ext_Riemann_integrable_on c &
     f is_-infty_ext_Riemann_integrable_on c by A1,INTEGR25:19; then
     f|A1 is_integrable_on L-Meas & f|B1 is_integrable_on L-Meas
       by A1,A3,A4,A5,A8,A10,Th47,Th49;
     hence f is_integrable_on L-Meas by A19,A1,Th53;
    end;
    hereby assume not f is infty_ext_Riemann_integrable; then
     consider d be Real such that
A20:   not f is_+infty_ext_Riemann_integrable_on d or
      not f is_-infty_ext_Riemann_integrable_on d by A1,INTEGR25:19;

A21:  f is_-infty_improper_integrable_on d &
     f is_+infty_improper_integrable_on d &
     improper_integral_on_REAL f
      = improper_integral_-infty(f,d) + improper_integral_+infty(f,d)
        by A1,A2,INTEGR25:36;

A22:  d in REAL by XREAL_0:def 1; then
     ].-infty,d.] is non empty by XXREAL_0:12,XXREAL_1:32; then
     reconsider A1 = left_closed_halfline d as non empty Subset of REAL
       by LIMFUNC1:def 1;
     [.d,+infty.[ is non empty by A22,XXREAL_0:9,XXREAL_1:31; then
     reconsider B1 = right_closed_halfline d as non empty Subset of REAL
       by LIMFUNC1:def 2;

     A1 = ].-infty,d.] by LIMFUNC1:def 1; then
     reconsider A1 as Element of L-Field by MEASUR10:5,MEASUR12:75;
     B1 = [.d,+infty.[ by LIMFUNC1:def 2; then
     reconsider B1 as Element of L-Field by MEASUR10:5,MEASUR12:75;

     per cases by A20;
     suppose not f is_+infty_ext_Riemann_integrable_on d; then
A23:   Integral(L-Meas,f|B1) = +infty by A21,A3,A1,Th49;
      Integral(L-Meas,f|B1) <= Integral(L-Meas,f|E)
        by A1,A3,A2,Th38,MESFUNC6:87;
      hence Integral(L-Meas,f) = +infty by A23,XXREAL_0:4;
     end;
     suppose not f is_-infty_ext_Riemann_integrable_on d; then
A24:   Integral(L-Meas,f|A1) = +infty by A21,A3,A1,Th47;
      Integral(L-Meas,f|A1) <= Integral(L-Meas,f|E)
        by A1,A3,A2,Th38,MESFUNC6:87;
      hence Integral(L-Meas,f) = +infty by A24,XXREAL_0:4;
     end;
    end;
end;

theorem
for f be PartFunc of REAL,REAL, a be Real, A be non empty Subset of REAL
 st dom f = REAL & f is_improper_integrable_on_REAL & f is nonpositive
 holds improper_integral_on_REAL f = Integral(L-Meas,f)
  & (f is infty_ext_Riemann_integrable implies f is_integrable_on L-Meas)
  & (not f is infty_ext_Riemann_integrable implies
       Integral(L-Meas,f) = -infty)
proof
    let f be PartFunc of REAL,REAL, a be Real, A be non empty Subset of REAL;
    assume that
A1:  dom f = REAL and
A2:  f is_improper_integrable_on_REAL and
A3:  f is nonpositive;

A4: -f is_improper_integrable_on_REAL by A1,A2,INTEGR25:50;

A5: improper_integral_on_REAL -f = - improper_integral_on_REAL f
      by A1,A2,INTEGR25:50;

    for x be object st x in dom (-f) holds 0 <= (-f).x
    proof
     let x be object;
     assume x in dom (-f); then
A6:  f.x <= 0 by A3,MESFUNC6:53;
     (-f).x = -(f.x) by VALUED_1:8;
     hence 0 <= (-f).x by A6;
    end; then
A7: -f is nonnegative by MESFUNC6:52;

    REAL = ].-infty,+infty.[ by XXREAL_1:224; then
    reconsider E = REAL as Element of L-Field by MEASUR10:5,MEASUR12:75;
A8:f is E-measurable by A1,A2,Th38;

A9:dom(-f) = dom f by VALUED_1:8; then
    -improper_integral_on_REAL f = Integral(L-Meas,-f)
      by A1,A4,A5,A7,Th54; then
    -improper_integral_on_REAL f = - Integral(L-Meas,f) by A1,A8,Th39;
    hence improper_integral_on_REAL f = Integral(L-Meas,f) by XXREAL_3:10;

A10: right_closed_halfline 0 c= dom f &
    left_closed_halfline 0 c= dom f by A1;

    hereby assume f is infty_ext_Riemann_integrable; then
     f is_+infty_ext_Riemann_integrable_on 0 &
     f is_-infty_ext_Riemann_integrable_on 0 by INTEGR10:def 9; then
     (-1)(#)f is_+infty_ext_Riemann_integrable_on 0 &
     (-1)(#)f is_-infty_ext_Riemann_integrable_on 0 by A10,INTEGR10:9,11; then
     -f is_+infty_ext_Riemann_integrable_on 0 &
     -f is_-infty_ext_Riemann_integrable_on 0 by VALUED_1:def 6; then
     -f is infty_ext_Riemann_integrable by INTEGR10:def 9; then
     -f is_integrable_on L-Meas by A1,A4,A7,A9,Th54; then
     (-1)(#)(-f) is_integrable_on L-Meas by MESFUNC6:102;
     hence f is_integrable_on L-Meas;
    end;
    hereby assume A11: not f is infty_ext_Riemann_integrable;

A12:  f is_-infty_improper_integrable_on 0 &
     f is_+infty_improper_integrable_on 0 by A1,A2,INTEGR25:36;

     ].-infty,0 .] is non empty by XXREAL_1:32; then
     reconsider A1 = left_closed_halfline 0 as non empty Subset of REAL
       by LIMFUNC1:def 1;
     [.0,+infty.[ is non empty by XXREAL_1:31; then
     reconsider B1 = right_closed_halfline 0 as non empty Subset of REAL
       by LIMFUNC1:def 2;

     A1 = ].-infty,0 .] by LIMFUNC1:def 1; then
     reconsider A1 as Element of L-Field by MEASUR10:5,MEASUR12:75;
     B1 = [.0,+infty.[ by LIMFUNC1:def 2; then
     reconsider B1 as Element of L-Field by MEASUR10:5,MEASUR12:75;

     per cases by A11,INTEGR10:def 9;
     suppose not f is_+infty_ext_Riemann_integrable_on 0; then
A13:   Integral(L-Meas,f|B1) = -infty by A12,A3,A1,Th50;
      Integral(L-Meas,f|B1) >= Integral(L-Meas,f|E)
        by A1,A3,A2,Th38,Th40;
      hence Integral(L-Meas,f) = -infty by A13,XXREAL_0:6;
     end;
     suppose not f is_-infty_ext_Riemann_integrable_on 0; then
A14:   Integral(L-Meas,f|A1) = -infty by A12,A3,A1,Th48;
      Integral(L-Meas,f|A1) >= Integral(L-Meas,f|E)
        by A1,A3,A2,Th38,Th40;
      hence Integral(L-Meas,f) = -infty by A14,XXREAL_0:6;
     end;
    end;
end;

begin :: Absolutely Integrable Function

theorem
for f be PartFunc of REAL,REAL, a,b be Real st [.a,b.[ = dom f holds
 ex F be Functional_Sequence of REAL,REAL st
  (for n be Nat holds dom(F.n) = dom f
   & (for x be Real st x in [.a,b-1/(n+1).] holds (F.n).x = f.x)
   & (for x be Real st not x in [.a,b-1/(n+1).] holds (F.n).x = 0))
& lim(R_EAL F) = f
proof
    let f be PartFunc of REAL,REAL, a,b be Real;
    assume that
A1:  [.a,b.[ = dom f;

A2: for n be Element of NAT holds [.a,b-1/(n+1).] c= dom f
    proof
     let n be Element of NAT;
     b-1/(n+1) < b by XREAL_1:44;
     hence [.a,b-1/(n+1).] c= dom f by A1,XXREAL_1:43;
    end;

    defpred P1[Element of NAT,object] means $2 = chi([.a,b-1/($1+1).],dom f);

A3: for n be Element of NAT ex ch be Element of PFuncs(REAL,REAL) st P1[n,ch]
    proof
     let n be Element of NAT;
     dom chi([.a,b-1/(n+1).],dom f) = dom f by FUNCT_3:def 3; then
     reconsider ch = chi([.a,b-1/(n+1).],dom f) as PartFunc of REAL,REAL
       by RELSET_1:5;
     reconsider ch as Element of PFuncs(REAL,REAL) by PARTFUN1:45;
     take ch;
     thus thesis;
    end;

    consider CH be sequence of PFuncs(REAL,REAL) such that
A4:  for n be Element of NAT holds P1[n,CH.n] from FUNCT_2:sch 3(A3);

    defpred P2[Element of NAT, object] means $2 = f(#)(CH.$1);

A5: for n be Element of NAT ex F be Element of PFuncs(REAL,REAL) st P2[n,F]
    proof
     let n be Element of NAT;
     reconsider F = f(#)(CH.n) as Element of PFuncs(REAL,REAL) by PARTFUN1:45;
     take F;
     thus thesis;
    end;

    consider F be sequence of PFuncs(REAL,REAL) such that
A6:  for n be Element of NAT holds P2[n,F.n] from FUNCT_2:sch 3(A5);
    take F;

    thus
A7: for n be Nat holds dom(F.n) = dom f
     & (for x be Real st x in [.a,b-1/(n+1).] holds (F.n).x = f.x)
     & (for x be Real st not x in [.a,b-1/(n+1).] holds (F.n).x = 0)
    proof
     let n be Nat;
A8:  n is Element of NAT by ORDINAL1:def 12; then
A9:  CH.n = chi([.a,b-1/(n+1).],dom f) by A4; then
A10:  dom(CH.n) = dom f by FUNCT_3:def 3;
A11: F.n = f(#)(CH.n) by A6,A8; then
A12: dom(F.n) = dom f /\ dom(CH.n) by VALUED_1:def 4;
     hence dom(F.n) = dom f by A10;
     thus for x be Real st x in [.a,b-1/(n+1).] holds (F.n).x = f.x
     proof
      let x be Real;
      assume A13: x in [.a,b-1/(n+1).];
A14:  [.a,b-1/(n+1).] c= dom f by A8,A2; then
      (CH.n).x = 1 by A9,A13,FUNCT_3:def 3; then
      (F.n).x = (f.x) * 1 by A11,A12,A10,A13,A14,VALUED_1:def 4;
      hence thesis;
     end;
     thus for x be Real st not x in [.a,b-1/(n+1).] holds (F.n).x = 0
     proof
      let x be Real;
      assume A15: not x in [.a,b-1/(n+1).];
      per cases;
      suppose A16: x in dom f; then
       (CH.n).x = 0 by A9,A15,FUNCT_3:def 3; then
       (F.n).x = (f.x) * 0 by A11,A12,A10,A16,VALUED_1:def 4;
       hence (F.n).x = 0;
      end;
      suppose not x in dom f;
       hence (F.n).x = 0 by A12,A10,FUNCT_1:def 2;
      end;
     end;
    end;

    dom(lim(R_EAL F)) = dom((R_EAL F).0) by MESFUNC8:def 9; then
    dom(lim(R_EAL F)) = dom(F.0) by MESFUN7C:def 1; then
A17: dom(lim(R_EAL F)) = dom f by A7; then
A18: dom(lim (R_EAL F)) = dom(R_EAL f) by MESFUNC5:def 7;
A19: for x be Element of REAL st x in dom (lim (R_EAL F)) holds
     (lim (R_EAL F)).x = (R_EAL f).x
    proof
     let x be Element of REAL;
     assume
A20:   x in dom(lim(R_EAL F)); then
A21:  a <= x < b by A1,A17,XXREAL_1:3; then
A22:  0 < b-x by XREAL_1:50;

A23:  (lim(R_EAL F)).x = lim((R_EAL F)#x) by A20,MESFUNC8:def 9;

A24:  for p be Real st 0<p ex n be Nat st for m be Nat st n<=m holds
      |. ((R_EAL F)#x).m - f.x qua ExtReal .| < p
     proof
      let p be Real;
      assume A25: 0<p;
      consider n be Nat such that
A26:    1/(b-x) < n by SEQ_4:3;
      n <= n+1 by NAT_1:13; then
      1/(b-x) < 1*(n+1) by A26,XXREAL_0:2; then
      1/(n+1) < 1*(b-x) by A22,XREAL_1:113; then
      x+1/(n+1) < b by XREAL_1:20; then
A27:  x < b-1/(n+1) by XREAL_1:20;

      take n;
      hereby let m be Nat;
       assume n<=m; then
       n+1 <= m+1 by XREAL_1:6; then
       1/(m+1) <= 1/(n+1) by XREAL_1:118; then
       b-1/(n+1) <= b-1/(m+1) by XREAL_1:10; then
       x < b-1/(m+1) by A27,XXREAL_0:2; then
       x in [.a,b-1/(m+1).] by A21,XXREAL_1:1; then
       (F.m).x = f.x by A7; then
       ((R_EAL F).m).x = f.x by MESFUN7C:def 1; then
       ((R_EAL F)#x).m = f.x by MESFUNC5:def 13; then
       ((R_EAL F)#x).m - f.x qua ExtReal
        = ((R_EAL F)#x).m + (- ((R_EAL F)#x).m) by XXREAL_3:def 4;
       hence |. ((R_EAL F)#x).m - f.x qua ExtReal .| < p
         by A25,EXTREAL1:16,XXREAL_3:7;
      end;
     end; then
     (R_EAL F)#x is convergent_to_finite_number by MESFUNC5:def 8; then
     lim((R_EAL F)#x) = f.x by A24,MESFUNC5:def 12;
     hence (lim(R_EAL F)).x = (R_EAL f).x by A23,MESFUNC5:def 7;
    end;
    lim (R_EAL F) = (R_EAL f) by A18,A19,PARTFUN1:5;
    hence lim(R_EAL F) = f by MESFUNC5:def 7;
end;

theorem Th57:
for f be PartFunc of REAL,REAL, a,b be Real st a < b & [.a,b.[ c= dom f
 & f is_right_improper_integrable_on a,b
 & abs f is_right_ext_Riemann_integrable_on a,b
holds f is_right_ext_Riemann_integrable_on a,b &
 right_improper_integral(f,a,b) <= right_improper_integral(abs f,a,b)
        < +infty
proof
    let f be PartFunc of REAL,REAL, a,b be Real;
    assume that
A1:  a < b and
A2:  [.a,b.[ c= dom f and
A3:  f is_right_improper_integrable_on a,b and
A4:  abs f is_right_ext_Riemann_integrable_on a,b;

    abs f is_right_improper_integrable_on a,b by A4,INTEGR24:33; then
A5: right_improper_integral(abs f,a,b) = ext_right_integral(abs f,a,b)
      by A4,INTEGR24:39;

A6: for d be Real st a <= d & d < b holds
     f is_integrable_on [' a,d '] & f|[' a,d '] is bounded
      by A3,INTEGR24:def 2;
    consider I be PartFunc of REAL,REAL such that
A7:  dom I = [.a,b.[ and
A8:  for x be Real st x in dom I holds I.x = integral(f,a,x) and
A9:  I is_left_convergent_in b or I is_left_divergent_to+infty_in b
  or I is_left_divergent_to-infty_in b by A3,INTEGR24:def 2;

    consider AI be PartFunc of REAL,REAL such that
A10: dom AI = [.a,b.[ and
A11: for x be Real st x in dom AI holds AI.x = integral(abs f,a,x) and
A12: AI is_left_convergent_in b by A4,INTEGR10:def 1;

A13:for r1,r2 be Real st r1 in dom AI & r2 in dom AI & r1 < r2
     holds AI.r1 <= AI.r2
    proof
     let r1,r2 be Real;
     assume that
A14:  r1 in dom AI and
A15:  r2 in dom AI and
A16:  r1 < r2;

A17: a <= r1 by A14,A10,XXREAL_1:3;
A18: a <= r2 < b by A15,A10,XXREAL_1:3; then
     [.a,r2.] c= [.a,b.[ by XXREAL_1:43; then
     [.a,r2.] c= dom f by A2; then
A19: [.a,r2.] c= dom (abs f) by VALUED_1:def 11;

     [.a,r2.] = ['a,r2'] by A18,INTEGRA5:def 3; then
A20: abs f is_integrable_on ['a,r2'] & (abs f)|[.a,r2.] is bounded
       by A18,A4,INTEGR10:def 1;
A21: [.a,r1.] c= [.a,r2.] by A16,XXREAL_1:34;

     f is Relation of REAL,COMPLEX by RELSET_1:7,NUMBERS:11; then
     integral(abs f,a,r1) <= integral(abs f,a,r2)
       by A19,A20,A21,A17,Th14,MESFUNC6:55; then
     AI.r1 <= integral(abs f,a,r2) by A11,A14;
     hence AI.r1 <= AI.r2 by A11,A15;
    end;

A22:now assume
A23: I is_left_divergent_to+infty_in b; then
     consider R be Real such that
A24:   R < b & for r1 be Real st R < r1 & r1 < b & r1 in dom I holds
       lim_left(AI,b) < I.r1 by LIMFUNC2:8;
     consider R1 be Real such that
A25:   R < R1 & R1 < b & R1 in dom I by A24,A23,LIMFUNC2:8;

A26: a <= R1 & R1 < b by A7,A25,XXREAL_1:3; then
     [.a,R1.] = ['a,R1'] by INTEGRA5:def 3; then
     ['a,R1'] c= [.a,b.[ by A25,XXREAL_1:43; then
A27: ['a,R1'] c= dom f by A2;

     f is_integrable_on ['a,R1'] & f|['a,R1'] is bounded
       by A26,A3,INTEGR24:def 2; then
     |. integral(f,a,R1) .| <= integral(abs f,a,R1) by A26,A27,INTEGRA6:8; then
     |. I.R1 .| <= integral(abs f,a,R1) by A25,A8; then
A28: |. I.R1 .| <= AI.R1 by A25,A7,A10,A11;
     AI.R1 <= lim_left(AI,b) by A13,A25,A10,A7,A12,Th6,RFUNCT_2:def 3; then
A29: |. I.R1 .| <= lim_left(AI,b) by A28,XXREAL_0:2;

A30: lim_left(AI,b) < I.R1 by A24,A25;
     I.R1 <= |. I.R1 .| by COMPLEX1:76;
     hence contradiction by A29,A30,XXREAL_0:2;
    end;

A31:now assume
A32: I is_left_divergent_to-infty_in b; then
     consider R be Real such that
A33:   R < b & for r1 be Real st R < r1 & r1 < b & r1 in dom I holds
       I.r1 < -lim_left(AI,b) by LIMFUNC2:9;
     consider R1 be Real such that
A34:   R < R1 & R1 < b & R1 in dom I by A33,A32,LIMFUNC2:9;

A35: a <= R1 & R1 < b by A7,A34,XXREAL_1:3; then
     [.a,R1.] = ['a,R1'] by INTEGRA5:def 3; then
     ['a,R1'] c= [.a,b.[ by A34,XXREAL_1:43; then
A36: ['a,R1'] c= dom f by A2;

     f is_integrable_on ['a,R1'] & f|['a,R1'] is bounded
       by A35,A3,INTEGR24:def 2; then
     |. integral(f,a,R1) .| <= integral(abs f,a,R1) by A35,A36,INTEGRA6:8; then
     |. I.R1 .| <= integral(abs f,a,R1) by A34,A8; then
A37: |. I.R1 .| <= AI.R1 by A34,A7,A10,A11;

     AI.R1 <= lim_left(AI,b) by A13,A34,A10,A7,A12,Th6,RFUNCT_2:def 3; then
A38: |. I.R1 .| <= lim_left(AI,b) by A37,XXREAL_0:2;

A39: I.R1 < -lim_left(AI,b) by A33,A34;
     -|. I.R1 .| <= I.R1 by COMPLEX1:76; then
     -|. I.R1 .| < -lim_left(AI,b) by A39,XXREAL_0:2;
     hence contradiction by A38,XREAL_1:24;
    end;
    hence f is_right_ext_Riemann_integrable_on a,b
      by A6,A7,A8,A9,A22,INTEGR10:def 1;

    consider r be Real such that
A40:  0 < r & r < b-a by A1,XREAL_1:5,50;

    for g be Real st g in dom I /\ ].b-r,b.[ holds I.g <= AI.g
    proof
     let g be Real;
     assume g in dom I /\ ].b-r,b.[; then
A41: g in dom I by XBOOLE_0:def 4; then
     I.g = integral(f,a,g) by A8; then
A42: I.g <= |. integral(f,a,g) .| by COMPLEX1:76;

A43: a <= g & g < b by A41,A7,XXREAL_1:3; then
     [.a,g.] = ['a,g'] by INTEGRA5:def 3; then
     ['a,g'] c= [.a,b.[ by A43,XXREAL_1:43; then
A44: ['a,g'] c= dom f by A2;

     f is_integrable_on ['a,g'] & f|['a,g'] is bounded
       by A43,A3,INTEGR24:def 2; then
     |. integral(f,a,g) .| <= integral(abs f,a,g) by A43,A44,INTEGRA6:8; then
     |. integral(f,a,g) .| <= AI.g by A41,A7,A10,A11;
     hence I.g <= AI.g by A42,XXREAL_0:2;
    end; then
    lim_left(I,b) <= lim_left(AI,b)
      by A9,A22,A31,A7,A10,A12,A40,LIMFUNC2:67; then
    right_improper_integral(f,a,b) <= lim_left(AI,b)
      by A3,A7,A8,A9,A22,A31,INTEGR24:41;
    hence right_improper_integral(f,a,b) <= right_improper_integral(abs f,a,b)
      by A5,A4,A10,A11,A12,INTEGR10:def 3;
    thus right_improper_integral(abs f,a,b) < +infty
      by A5,XREAL_0:def 1,XXREAL_0:9;
end;

theorem Th58:
for f be PartFunc of REAL,REAL, a,b be Real st a < b & ].a,b.] c= dom f
 & f is_left_improper_integrable_on a,b
 & abs f is_left_ext_Riemann_integrable_on a,b
holds f is_left_ext_Riemann_integrable_on a,b &
 left_improper_integral(f,a,b) <= left_improper_integral(abs f,a,b)
        < +infty
proof
    let f be PartFunc of REAL,REAL, a,b be Real;
    assume that
A1:  a < b and
A2:  ].a,b.] c= dom f and
A3:  f is_left_improper_integrable_on a,b and
A4:  abs f is_left_ext_Riemann_integrable_on a,b;

    abs f is_left_improper_integrable_on a,b by A4,INTEGR24:32; then
A5: left_improper_integral(abs f,a,b) = ext_left_integral(abs f,a,b)
      by A4,INTEGR24:34;

A6: for d be Real st a < d & d <= b holds
     f is_integrable_on [' d,b '] & f|[' d,b '] is bounded
      by A3,INTEGR24:def 1;
    consider I be PartFunc of REAL,REAL such that
A7:  dom I = ].a,b.] and
A8:  for x be Real st x in dom I holds I.x = integral(f,x,b) and
A9:  I is_right_convergent_in a or I is_right_divergent_to+infty_in a
  or I is_right_divergent_to-infty_in a by A3,INTEGR24:def 1;

    consider AI be PartFunc of REAL,REAL such that
A10: dom AI = ].a,b.] and
A11: for x be Real st x in dom AI holds AI.x = integral(abs f,x,b) and
A12: AI is_right_convergent_in a by A4,INTEGR10:def 2;

A13:for r1,r2 be Real st r1 in dom AI & r2 in dom AI & r1 < r2
     holds AI.r1 >= AI.r2
    proof
     let r1,r2 be Real;
     assume that
A14:  r1 in dom AI and
A15:  r2 in dom AI and
A16:  r1 < r2;

A17: a < r1 <= b by A14,A10,XXREAL_1:2; then
     [.r1,b.] c= ].a,b.] by XXREAL_1:39; then
     [.r1,b.] c= dom f by A2; then
A18: [.r1,b.] c= dom (abs f) by VALUED_1:def 11;

A19: a < r2 <= b by A15,A10,XXREAL_1:2;

     [.r1,b.] = ['r1,b'] by A17,INTEGRA5:def 3; then
A20: abs f is_integrable_on ['r1,b'] & (abs f)|[.r1,b.] is bounded
       by A4,A17,INTEGR10:def 2;
A21: [.r2,b.] c= [.r1,b.] by A16,XXREAL_1:34;

     f is Relation of REAL,COMPLEX by RELSET_1:7,NUMBERS:11; then
     integral(abs f,r1,b) >= integral(abs f,r2,b)
       by A19,A18,A20,A21,Th14,MESFUNC6:55; then
     AI.r1 >= integral(abs f,r2,b) by A11,A14;
     hence AI.r1 >= AI.r2 by A11,A15;
    end;

A22:now assume
A23: I is_right_divergent_to+infty_in a; then
     consider R be Real such that
A24:  a < R & for r1 be Real st r1 < R & a < r1 & r1 in dom I holds
      lim_right(AI,a) < I.r1 by LIMFUNC2:11;
     consider R1 be Real such that
A25:  R1 < R & a < R1 & R1 in dom I by A24,A23,LIMFUNC2:11;

A26: a < R1 & R1 <= b by A7,A25,XXREAL_1:2; then
     [.R1,b.] = ['R1,b'] by INTEGRA5:def 3; then
     ['R1,b'] c= ].a,b.] by A25,XXREAL_1:39; then
A27: ['R1,b'] c= dom f by A2;
     f is_integrable_on ['R1,b'] & f|['R1,b'] is bounded
       by A26,A3,INTEGR24:def 1; then
     |. integral(f,R1,b) .| <= integral(abs f,R1,b) by A26,A27,INTEGRA6:8; then
     |. I.R1 .| <= integral(abs f,R1,b) by A25,A8; then
A28: |. I.R1 .| <= AI.R1 by A25,A7,A10,A11;
     AI.R1 <= lim_right(AI,a) by A13,A25,A10,A7,A12,Th9,RFUNCT_2:def 4; then
A29: |. I.R1 .| <= lim_right(AI,a) by A28,XXREAL_0:2;

A30: lim_right(AI,a) < I.R1 by A24,A25;
     I.R1 <= |. I.R1 .| by COMPLEX1:76;
     hence contradiction by A29,A30,XXREAL_0:2;
    end;

A31:now assume
A32: I is_right_divergent_to-infty_in a; then
     consider R be Real such that
A33:  a < R & for r1 be Real st r1 < R & a < r1 & r1 in dom I holds
       I.r1 < -lim_right(AI,a) by LIMFUNC2:12;
     consider R1 be Real such that
A34:  R1 < R & a < R1 & R1 in dom I by A33,A32,LIMFUNC2:12;

A35: a < R1 & R1 <= b by A7,A34,XXREAL_1:2; then
     [.R1,b.] = ['R1,b'] by INTEGRA5:def 3; then
     ['R1,b'] c= ].a,b.] by A34,XXREAL_1:39; then
A36: ['R1,b'] c= dom f by A2;
     f is_integrable_on ['R1,b'] & f|['R1,b'] is bounded
       by A35,A3,INTEGR24:def 1; then
     |. integral(f,R1,b) .| <= integral(abs f,R1,b) by A35,A36,INTEGRA6:8; then
     |. I.R1 .| <= integral(abs f,R1,b) by A34,A8; then
A37: |. I.R1 .| <= AI.R1 by A34,A7,A10,A11;
     AI.R1 <= lim_right(AI,a) by A13,A34,A10,A7,A12,Th9,RFUNCT_2:def 4; then
A38: |. I.R1 .| <= lim_right(AI,a) by A37,XXREAL_0:2;

A39: I.R1 < -lim_right(AI,a) by A33,A34;
     -|. I.R1 .| <= I.R1 by COMPLEX1:76; then
     -|. I.R1 .| < -lim_right(AI,a) by A39,XXREAL_0:2;
     hence contradiction by A38,XREAL_1:24;
    end;
    hence f is_left_ext_Riemann_integrable_on a,b
      by A6,A7,A8,A9,A22,INTEGR10:def 2;

    consider r be Real such that
A40:  0 < r & r < b-a by A1,XREAL_1:5,50;
    for g be Real st g in dom I /\ ].a,a+r.[ holds I.g <= AI.g
    proof
     let g be Real;
     assume g in dom I /\ ].a,a+r.[; then
A41: g in dom I by XBOOLE_0:def 4; then
     I.g = integral(f,g,b) by A8; then
A42: I.g <= |. integral(f,g,b) .| by COMPLEX1:76;

A43: a < g & g <= b by A41,A7,XXREAL_1:2; then
     [.g,b.] = ['g,b'] by INTEGRA5:def 3; then
     ['g,b'] c= ].a,b.] by A43,XXREAL_1:39; then
A44: ['g,b'] c= dom f by A2;
     f is_integrable_on ['g,b'] & f|['g,b'] is bounded
       by A43,A3,INTEGR24:def 1; then
     |. integral(f,g,b) .| <= integral(abs f,g,b) by A43,A44,INTEGRA6:8; then
     |. integral(f,g,b) .| <= AI.g by A41,A7,A10,A11;
     hence I.g <= AI.g by A42,XXREAL_0:2;
    end; then
    lim_right(I,a) <= lim_right(AI,a)
      by A7,A9,A22,A31,A10,A12,A40,LIMFUNC2:68; then
    left_improper_integral(f,a,b) <= lim_right(AI,a)
      by A3,A7,A8,A9,A22,A31,INTEGR24:36;
    hence left_improper_integral(f,a,b) <= left_improper_integral(abs f,a,b)
      by A5,A4,A10,A11,A12,INTEGR10:def 4;
    thus left_improper_integral(abs f,a,b) < +infty
      by A5,XREAL_0:def 1,XXREAL_0:9;
end;

theorem Th59:
for f be PartFunc of REAL,REAL, A be non empty closed_interval Subset of REAL
 st A c= dom f holds max+(f||A) = max+(f|A) & max-(f||A) = max-(f|A)
proof
    let f be PartFunc of REAL,REAL,
     A be non empty closed_interval Subset of REAL;
     assume A c= dom f;
A1:  dom(max+(f||A)) = dom(f|A) & dom(f|A) = dom(max+(f|A))
       by RFUNCT_3:def 10;
     for x be object st x in dom(max+(f||A)) holds
      (max+(f||A)).x = (max+(f|A)).x
     proof
      let x be object;
      assume
A2:    x in dom(max+(f||A)); then
      (max+(f||A)).x = max+((f|A).x) by RFUNCT_3:def 10;
      hence (max+(f||A)).x = (max+(f|A)).x by A2,A1,RFUNCT_3:def 10;
     end;
     hence max+(f||A) = max+(f|A) by A1,FUNCT_1:2;

A3:  dom(max-(f||A)) = dom(f|A) & dom(f|A) = dom(max-(f|A))
       by RFUNCT_3:def 11;
     for x be object st x in dom(max-(f||A)) holds
      (max-(f||A)).x = (max-(f|A)).x
     proof
      let x be object;
      assume
A4:    x in dom(max-(f||A)); then
      (max-(f||A)).x = max-((f|A).x) by RFUNCT_3:def 11;
      hence (max-(f||A)).x = (max-(f|A)).x by A4,A3,RFUNCT_3:def 11;
     end;
     hence max-(f||A) = max-(f|A) by A3,FUNCT_1:2;
end;

theorem Th60:
for f be PartFunc of REAL,REAL, b be Real
 st left_closed_halfline b c= dom f
  & f is_-infty_improper_integrable_on b
  & abs f is_-infty_ext_Riemann_integrable_on b
holds f is_-infty_ext_Riemann_integrable_on b &
 improper_integral_-infty(f,b) <= improper_integral_-infty(abs f,b)
        < +infty
proof
    let f be PartFunc of REAL,REAL, b be Real;
    assume that
A1:  left_closed_halfline b c= dom f and
A2:  f is_-infty_improper_integrable_on b and
A3:  abs f is_-infty_ext_Riemann_integrable_on b;

    abs f is_-infty_improper_integrable_on b by A3,INTEGR25:20; then
A4: improper_integral_-infty(abs f,b) = infty_ext_left_integral(abs f,b)
      by A3,INTEGR25:22;

A5: for a be Real st a <=b holds f is_integrable_on [' a,b ']
     & f|[' a,b '] is bounded by A2,INTEGR25:def 1;

    consider I be PartFunc of REAL,REAL such that
A6:  dom I = left_closed_halfline b and
A7:  for x be Real st x in dom I holds I.x = integral(f,x,b) and
A8: I is convergent_in-infty or I is divergent_in-infty_to+infty
  or I is divergent_in-infty_to-infty by A2,INTEGR25:def 1;

    consider AI be PartFunc of REAL,REAL such that
A9: dom AI = left_closed_halfline b and
A10: for x be Real st x in dom AI holds AI.x = integral(abs f,x,b) and
A11: AI is convergent_in-infty by A3,INTEGR10:def 6;

A12: left_closed_halfline b = ].-infty,b.] by LIMFUNC1:def 1;

A13:for r1,r2 be Real st r1 in dom AI & r2 in dom AI & r1 < r2
     holds AI.r1 >= AI.r2
    proof
     let r1,r2 be Real;
     assume that
A14:  r1 in dom AI and
A15:  r2 in dom AI and
A16:  r1 < r2;

A17: -infty < r2 <= b by A12,A15,A9,XXREAL_1:2;
A18: -infty < r1 <= b by A12,A14,A9,XXREAL_1:2; then
     [.r1,b.] c= ].-infty,b.] by XXREAL_1:39; then
     [.r1,b.] c= dom f by A12,A1; then
A19: [.r1,b.] c= dom (abs f) by VALUED_1:def 11;

     [.r1,b.] = ['r1,b'] by A18,INTEGRA5:def 3; then
A20: abs f is_integrable_on ['r1,b'] & (abs f)|[.r1,b.] is bounded
       by A18,A3,INTEGR10:def 6;
A21: [.r2,b.] c= [.r1,b.] by A16,XXREAL_1:34;

     f is Relation of REAL,COMPLEX by RELSET_1:7,NUMBERS:11; then
     integral(abs f,r1,b) >= integral(abs f,r2,b)
       by A17,A19,A20,A21,Th14,MESFUNC6:55; then
     AI.r1 >= integral(abs f,r2,b) by A10,A14;
     hence AI.r1 >= AI.r2 by A10,A15;
    end;

A22:now assume
A23: I is divergent_in-infty_to+infty; then
     consider R be Real such that
A24:  for r1 be Real st r1 < R & r1 in dom I holds
       lim_in-infty AI < I.r1 by LIMFUNC1:48;
     consider R1 be Real such that
A25:  R1 < R & R1 in dom I by A23,LIMFUNC1:48;

A26: -infty < R1 & R1 <= b by A12,A6,A25,XXREAL_1:2; then
     [.R1,b.] = ['R1,b'] by INTEGRA5:def 3; then
     ['R1,b'] c= ].-infty,b.] by A26,XXREAL_1:39; then
A27: ['R1,b'] c= dom f by A1,A12;
     f is_integrable_on ['R1,b'] & f|['R1,b'] is bounded
       by A26,A2,INTEGR25:def 1; then
     |. integral(f,R1,b) .| <= integral(abs f,R1,b) by A26,A27,INTEGRA6:8; then
     |. I.R1 .| <= integral(abs f,R1,b) by A25,A7; then
A28: |. I.R1 .| <= AI.R1 by A25,A6,A9,A10;
     AI.R1 <= lim_in-infty AI by A13,A25,A9,A6,A11,Th10,RFUNCT_2:def 4; then
A29: |. I.R1 .| <= lim_in-infty AI by A28,XXREAL_0:2;

A30: lim_in-infty AI < I.R1 by A24,A25;
     I.R1 <= |. I.R1 .| by COMPLEX1:76;
     hence contradiction by A29,A30,XXREAL_0:2;
    end;

A31:now assume
A32: I is divergent_in-infty_to-infty; then
     consider R be Real such that
A33:  for r1 be Real st r1 < R & r1 in dom I holds I.r1 < -(lim_in-infty AI)
        by LIMFUNC1:49;
     consider R1 be Real such that
A34:  R1 < R & R1 in dom I by A32,LIMFUNC1:49;

A35: -infty < R1 & R1 <= b by A12,A6,A34,XXREAL_1:2; then
     [.R1,b.] = ['R1,b'] by INTEGRA5:def 3; then
     ['R1,b'] c= ].-infty,b.] by A35,XXREAL_1:39; then
A36: ['R1,b'] c= dom f by A1,A12;
     f is_integrable_on ['R1,b'] & f|['R1,b'] is bounded
       by A35,A2,INTEGR25:def 1; then
     |. integral(f,R1,b) .| <= integral(abs f,R1,b) by A35,A36,INTEGRA6:8; then
     |. I.R1 .| <= integral(abs f,R1,b) by A34,A7; then
A37: |. I.R1 .| <= AI.R1 by A34,A6,A9,A10;
     AI.R1 <= lim_in-infty AI by A13,A34,A9,A6,A11,Th10,RFUNCT_2:def 4; then
A38: |. I.R1 .| <= lim_in-infty AI by A37,XXREAL_0:2;

A39: I.R1 < -(lim_in-infty AI) by A33,A34;
     -|. I.R1 .| <= I.R1 by COMPLEX1:76; then
     -|. I.R1 .| < -(lim_in-infty AI) by A39,XXREAL_0:2;
     hence contradiction by A38,XREAL_1:24;
    end;
    hence f is_-infty_ext_Riemann_integrable_on b
      by A5,A6,A7,A8,A22,INTEGR10:def 6;

    for g be Real st g in dom I /\ left_open_halfline 1 holds I.g <= AI.g
    proof
     let g be Real;
     assume g in dom I /\ left_open_halfline 1; then
A40: g in dom I by XBOOLE_0:def 4; then
     I.g = integral(f,g,b) by A7; then
A41: I.g <= |. integral(f,g,b) .| by COMPLEX1:76;

A42: -infty < g & g <= b by A12,A40,A6,XXREAL_1:2; then
     [.g,b.] = ['g,b'] by INTEGRA5:def 3; then
     ['g,b'] c= ].-infty,b.] by A42,XXREAL_1:39; then
A43: ['g,b'] c= dom f by A1,A12;
     f is_integrable_on ['g,b'] & f|['g,b'] is bounded
       by A42,A2,INTEGR25:def 1; then
     |. integral(f,g,b) .| <= integral(abs f,g,b) by A42,A43,INTEGRA6:8; then
     |. integral(f,g,b) .| <= AI.g by A40,A6,A9,A10;
     hence I.g <= AI.g by A41,XXREAL_0:2;
    end; then
    lim_in-infty I <= lim_in-infty AI
      by A11,A8,A22,A31,A6,A9,LIMFUNC1:105; then
    improper_integral_-infty(f,b) <= lim_in-infty AI
      by A2,A6,A7,A8,A22,A31,INTEGR25:24;
    hence improper_integral_-infty(f,b) <= improper_integral_-infty(abs f,b)
      by A4,A3,A9,A10,A11,INTEGR10:def 8;
    thus improper_integral_-infty(abs f,b) < +infty
      by A4,XREAL_0:def 1,XXREAL_0:9;
end;

theorem Th61:
for f be PartFunc of REAL,REAL, a be Real
 st right_closed_halfline a c= dom f
  & f is_+infty_improper_integrable_on a
  & abs f is_+infty_ext_Riemann_integrable_on a
holds f is_+infty_ext_Riemann_integrable_on a &
 improper_integral_+infty(f,a) <= improper_integral_+infty(abs f,a)
        < +infty
proof
    let f be PartFunc of REAL,REAL, a be Real;
    assume that
A1:  right_closed_halfline a c= dom f and
A2:  f is_+infty_improper_integrable_on a and
A3:  abs f is_+infty_ext_Riemann_integrable_on a;

    abs f is_+infty_improper_integrable_on a by A3,INTEGR25:21; then
A4: improper_integral_+infty(abs f,a) = infty_ext_right_integral(abs f,a)
      by A3,INTEGR25:27;

A5: for d be Real st a <= d holds
     f is_integrable_on [' a,d '] & f|[' a,d '] is bounded
      by A2,INTEGR25:def 2;

    consider I be PartFunc of REAL,REAL such that
A6:  dom I = right_closed_halfline a and
A7:  for x be Real st x in dom I holds I.x = integral(f,a,x) and
A8:  I is convergent_in+infty or I is divergent_in+infty_to+infty
  or I is divergent_in+infty_to-infty by A2,INTEGR25:def 2;

    consider AI be PartFunc of REAL,REAL such that
A9: dom AI = right_closed_halfline a and
A10: for x be Real st x in dom AI holds AI.x = integral(abs f,a,x) and
A11: AI is convergent_in+infty by A3,INTEGR10:def 5;

A12: right_closed_halfline a = [.a,+infty.[ by LIMFUNC1:def 2;

A13:for r1,r2 be Real st r1 in dom AI & r2 in dom AI & r1 < r2
     holds AI.r1 <= AI.r2
    proof
     let r1,r2 be Real;
     assume that
A14:  r1 in dom AI and
A15:  r2 in dom AI and
A16:  r1 < r2;

A17: a <= r1 < +infty by A12,A14,A9,XXREAL_1:3;
A18: a <= r2 < +infty by A12,A15,A9,XXREAL_1:3; then
     [.a,r2.] c= [.a,+infty.[ by XXREAL_1:43; then
     [.a,r2.] c= dom f by A12,A1; then
A19: [.a,r2.] c= dom (abs f) by VALUED_1:def 11;

     [.a,r2.] = ['a,r2'] by A18,INTEGRA5:def 3; then
A20: abs f is_integrable_on ['a,r2'] & (abs f)|[.a,r2.] is bounded
       by A18,A3,INTEGR10:def 5;
A21: [.a,r1.] c= [.a,r2.] by A16,XXREAL_1:34;

     f is Relation of REAL,COMPLEX by RELSET_1:7,NUMBERS:11; then
     integral(abs f,a,r2) >= integral(abs f,a,r1)
       by A19,A20,A21,A17,Th14,MESFUNC6:55; then
     AI.r2 >= integral(abs f,a,r1) by A10,A15;
     hence AI.r2 >= AI.r1 by A14,A10;
    end;

A22:now assume
A23: I is divergent_in+infty_to+infty; then
     consider R be Real such that
A24:  for r1 be Real st R < r1 & r1 in dom I holds
       lim_in+infty AI < I.r1 by LIMFUNC1:46;
     consider R1 be Real such that
A25:  R < R1 & R1 in dom I by A23,LIMFUNC1:46;
A26: a <= R1 & R1 < +infty by A12,A6,A25,XXREAL_1:3; then
     [.a,R1.] = ['a,R1'] by INTEGRA5:def 3; then
     ['a,R1'] c= [.a,+infty.[ by A26,XXREAL_1:43; then
A27: ['a,R1'] c= dom f by A1,A12;
     f is_integrable_on ['a,R1'] & f|['a,R1'] is bounded
       by A26,A2,INTEGR25:def 2; then
     |. integral(f,a,R1) .| <= integral(abs f,a,R1) by A26,A27,INTEGRA6:8; then
     |. I.R1 .| <= integral(abs f,a,R1) by A25,A7; then
A28: |. I.R1 .| <= AI.R1 by A25,A6,A9,A10;
     AI.R1 <= lim_in+infty AI by A13,A25,A9,A6,A11,Th11,RFUNCT_2:def 3; then
A29: |. I.R1 .| <= lim_in+infty AI by A28,XXREAL_0:2;

A30: lim_in+infty AI < I.R1 by A24,A25;
     I.R1 <= |. I.R1 .| by COMPLEX1:76;
     hence contradiction by A29,A30,XXREAL_0:2;
    end;

A31:now assume
A32: I is divergent_in+infty_to-infty; then
     consider R be Real such that
A33:  for r1 be Real st R < r1 & r1 in dom I holds
       I.r1 < -(lim_in+infty AI) by LIMFUNC1:47;
     consider R1 be Real such that
A34:  R < R1 & R1 in dom I by A32,LIMFUNC1:47;
A35: a <= R1 & R1 < +infty by A12,A6,A34,XXREAL_1:3; then
     [.a,R1.] = ['a,R1'] by INTEGRA5:def 3; then
     ['a,R1'] c= [.a,+infty.[ by A35,XXREAL_1:43; then
A36: ['a,R1'] c= dom f by A1,A12;
     f is_integrable_on ['a,R1'] & f|['a,R1'] is bounded
       by A35,A2,INTEGR25:def 2; then
     |. integral(f,a,R1) .| <= integral(abs f,a,R1) by A35,A36,INTEGRA6:8; then
     |. I.R1 .| <= integral(abs f,a,R1) by A34,A7; then
A37: |. I.R1 .| <= AI.R1 by A34,A6,A9,A10;
     AI.R1 <= lim_in+infty AI by A13,A34,A9,A6,A11,Th11,RFUNCT_2:def 3; then
A38: |. I.R1 .| <= lim_in+infty AI by A37,XXREAL_0:2;

A39: I.R1 < -(lim_in+infty AI) by A33,A34;
     -|. I.R1 .| <= I.R1 by COMPLEX1:76; then
     -|. I.R1 .| < -(lim_in+infty AI) by A39,XXREAL_0:2;
     hence contradiction by A38,XREAL_1:24;
    end;
    hence f is_+infty_ext_Riemann_integrable_on a
      by A5,A6,A7,A8,A22,INTEGR10:def 5;

    for g be Real st g in dom I /\ right_open_halfline 1 holds I.g <= AI.g
    proof
     let g be Real;
     assume g in dom I /\ right_open_halfline 1; then
A40: g in dom I by XBOOLE_0:def 4; then
     I.g = integral(f,a,g) by A7; then
A41:  I.g <= |. integral(f,a,g) .| by COMPLEX1:76;

A42: a <= g & g < +infty by A12,A40,A6,XXREAL_1:3; then
     [.a,g.] = ['a,g'] by INTEGRA5:def 3; then
     ['a,g'] c= [.a,+infty.[ by A42,XXREAL_1:43; then
A43: ['a,g'] c= dom f by A1,A12;
     f is_integrable_on ['a,g'] & f|['a,g'] is bounded
       by A42,A2,INTEGR25:def 2; then
     |. integral(f,a,g) .| <= integral(abs f,a,g) by A42,A43,INTEGRA6:8; then
     |. integral(f,a,g) .| <= AI.g by A40,A6,A9,A10;
     hence I.g <= AI.g by A41,XXREAL_0:2;
    end; then
    lim_in+infty I <= lim_in+infty AI
      by A11,A8,A22,A31,A6,A9,LIMFUNC1:104; then
    improper_integral_+infty(f,a) <= lim_in+infty AI
      by A2,A6,A7,A8,A22,A31,INTEGR25:29;
    hence improper_integral_+infty(f,a) <= improper_integral_+infty(abs f,a)
      by A4,A3,A9,A10,A11,INTEGR10:def 7;
    thus improper_integral_+infty(abs f,a) < +infty
      by A4,XREAL_0:def 1,XXREAL_0:9;
end;

theorem Th62:
for f be PartFunc of REAL,REAL, a,b be Real st a <= b & [.a,b.] c= dom f &
 f is_integrable_on ['a,b'] & f|['a,b'] is bounded
 holds max+f is_integrable_on ['a,b'] & max-f is_integrable_on ['a,b'] &
  2*integral(max+f,a,b) = integral(f,a,b) + integral(abs f,a,b) &
  2*integral(max-f,a,b) = -integral(f,a,b) + integral(abs f,a,b) &
  integral(f,a,b) = integral(max+f,a,b) - integral(max-f,a,b)
proof
    let f be PartFunc of REAL,REAL, a,b be Real;
    assume that
A1:  a <= b and
A2:  [.a,b.] c= dom f and
A3:  f is_integrable_on ['a,b'] and
A4:  f|['a,b'] is bounded;

A5: ['a,b'] = [.a,b.] by A1,INTEGRA5:def 3; then
    a in ['a,b'] & b in ['a,b'] by A1,XXREAL_1:1; then
A6: abs f is_integrable_on ['a,b'] & (abs f)|['a,b'] is bounded
      by A1,A2,A3,A4,A5,INTEGRA6:22;
A7: dom abs f = dom f by VALUED_1:def 11;
    set MF1 = 2(#)max+f;

A8: MF1 = f + abs f by RFUNCT_3:34; then
A9: MF1 is_integrable_on ['a,b'] & MF1|['a,b'] is bounded
      by A1,A2,A3,A4,A5,A6,A7,INTEGRA6:19;

A10: dom max+f = dom f by RFUNCT_3:def 10; then
A11: dom MF1 = dom f by VALUED_1:def 5;

    (1/2)(#)MF1 = (1/2 * 2)(#)max+f by RFUNCT_1:17;
    hence
A12: max+f is_integrable_on ['a,b'] by A2,A5,A9,A11,INTEGRA6:9;

    f|['a,b'] is bounded_above & f|['a,b'] is bounded_below
      by A4,SEQ_2:def 8; then
    max+f|['a,b'] is bounded_above & max+f|['a,b'] is bounded_below
      by INTEGRA4:14,15; then
A13: max+f|['a,b'] is bounded by SEQ_2:def 8;

A14:-f = (-1)(#)f by VALUED_1:def 6; then
A15: (-f) is_integrable_on ['a,b'] by A2,A3,A4,A5,INTEGRA6:9;
A16: (-f)|['a,b'] is bounded by A4,A14,RFUNCT_1:80;

A17:abs(-f) = |. -1 .| (#)abs f by A14,RFUNCT_1:25
     .= (--1)(#)abs f by COMPLEX1:70 .= abs f;

A18:dom(-f) = dom f by A14,VALUED_1:def 5;

    set MF2 = 2(#)max-f;

A19: max-f = max+(-f) by INTEGRA4:21; then
A20: 2(#)max-f = (-f) + abs f by A17,RFUNCT_3:34; then
A21:MF2 is_integrable_on ['a,b'] & MF2|['a,b'] is bounded
      by A1,A2,A5,A7,A15,A16,A6,A18,INTEGRA6:19;

A22: dom max-f = dom f by RFUNCT_3:def 11; then
A23:['a,b'] c= dom MF2 by A2,A5,VALUED_1:def 5;

    (1/2)(#)MF2 = (1/2 * 2)(#)max-f by RFUNCT_1:17;
    hence
A24: max-f is_integrable_on ['a,b'] by A21,A23,INTEGRA6:9;

    (-f)|['a,b'] is bounded_above & (-f)|['a,b'] is bounded_below
      by A16,SEQ_2:def 8; then
    max+(-f)|['a,b'] is bounded_above & max+(-f)|['a,b'] is bounded_below
      by INTEGRA4:14,15; then
A25: max-f|['a,b'] is bounded by A19,SEQ_2:def 8;

    integral(MF1,a,b) = integral(f,a,b) + integral(abs f,a,b)
      by A1,A2,A3,A4,A5,A6,A7,A8,INTEGRA6:12;
    hence
A26:  2*integral(max+f,a,b) = integral(f,a,b) + integral(abs f,a,b)
      by A1,A2,A5,A12,A10,A13,INTEGRA6:10;

A27: integral(-f,a,b) = (-1)*integral(f,a,b) by A1,A2,A3,A4,A5,A14,INTEGRA6:10;

    integral(MF2,a,b) = integral(-f,a,b) + integral(abs f,a,b)
      by A1,A2,A5,A15,A16,A18,A6,A7,A20,INTEGRA6:12;
    hence 2*integral(max-f,a,b) = -integral(f,a,b) + integral(abs f,a,b)
      by A27,A1,A2,A5,A24,A22,A25,INTEGRA6:10;
    hence integral(f,a,b) = integral(max+f,a,b) - integral(max-f,a,b) by A26;
end;

theorem Th63:
for f be PartFunc of REAL,REAL, a,b be Real st a < b & ].a,b.] c= dom f
 & f is_left_ext_Riemann_integrable_on a,b
 & abs f is_left_ext_Riemann_integrable_on a,b
holds max+f is_left_ext_Riemann_integrable_on a,b
proof
    let f be PartFunc of REAL,REAL, a,b be Real;
    assume that
A1:  a < b and
A2:  ].a,b.] c= dom f and
A3:  f is_left_ext_Riemann_integrable_on a,b and
A4: abs f is_left_ext_Riemann_integrable_on a,b;

    set G = ext_left_integral(f,a,b);
    set AG = ext_left_integral(abs f,a,b);

A5: for d be Real st a < d & d <= b holds
     f is_integrable_on [' d,b '] & f|[' d,b '] is bounded
      by A3,INTEGR10:def 2;
    consider I be PartFunc of REAL,REAL such that
A6:  dom I = ].a,b.] and
A7:  for x be Real st x in dom I holds I.x = integral(f,x,b) and
A8:  I is_right_convergent_in a and
A9: G = lim_right(I,a) by A3,INTEGR10:def 4;

    consider AI be PartFunc of REAL,REAL such that
A10:  dom AI = ].a,b.] and
A11:  for x be Real st x in dom AI holds AI.x = integral(abs f,x,b) and
A12:  AI is_right_convergent_in a and
A13: AG = lim_right(AI,a) by A4,INTEGR10:def 4;

A14:for d be Real st a < d & d <= b holds
     max+f is_integrable_on ['d,b'] & (max+f)|['d,b'] is bounded
    proof
     let d be Real;
     assume
A15:  a < d & d <= b; then
A16: f is_integrable_on ['d,b'] & f|['d,b'] is bounded by A3,INTEGR10:def 2;

A17: (f||['d,b'])|['d,b'] is bounded by A15,A3,INTEGR10:def 2;

     ['d,b'] = [.d,b.] by A15,INTEGRA5:def 3; then
     ['d,b'] c= ].a,b.] by A15,XXREAL_1:39; then
A18: ['d,b'] c= dom f by A2; then
     dom(f||['d,b']) = ['d,b'] by RELAT_1:62; then
A19: f||['d,b'] is Function of ['d,b'],REAL by FUNCT_2:67;

A20: max+(f||['d,b']) = max+(f|['d,b']) by A18,Th59
      .= (max+f)||['d,b'] by MESFUNC6:66;

     f||['d,b'] is integrable by A5,A15,INTEGRA5:def 1;
     hence max+f is_integrable_on ['d,b']
       by A20,A17,A19,INTEGRA4:20,INTEGRA5:def 1;
     f|['d,b'] is bounded_above by A16,SEQ_2:def 8; then
     (max+f)|['d,b'] is bounded_above & (max+f)|['d,b'] is bounded_below
       by INTEGRA4:14,15;
     hence (max+f)|['d,b'] is bounded by SEQ_2:def 8;
    end;

    ex Intf be PartFunc of REAL,REAL st
     dom Intf = ].a,b.] &
     (for x be Real st x in dom Intf holds Intf.x = integral(max+f,x,b)) &
     Intf is_right_convergent_in a
    proof
     reconsider A = ].a,b.] as non empty Subset of REAL by A1,XXREAL_1:32;
     deffunc F(Element of A) = In(integral(max+f,$1,b),REAL);
     consider Intf be Function of A, REAL such that
A21:  for x being Element of A holds Intf.x = F(x) from FUNCT_2:sch 4;
A22: dom Intf = A by FUNCT_2:def 1; then
     reconsider Intf as PartFunc of REAL, REAL by RELSET_1:5;
     take Intf;
A23: for x be Real st x in dom Intf holds Intf.x = integral(max+f,x,b)
     proof
      let x be Real;
      assume x in dom Intf; then
      x is Element of A by FUNCT_2:def 1; then
      Intf.x = In(integral(max+f,x,b),REAL) by A21;
      hence Intf.x = integral(max+f,x,b);
     end;

A24: for r be Real st a<r ex g be Real st g<r & a<g & g in dom Intf
     proof
      let r be Real;
      assume a<r; then
      consider g be Real such that
A25:    g < r & a < g & g in dom I by A8,LIMFUNC2:10;
      take g;
      thus g < r & a < g & g in dom Intf by A6,A25,FUNCT_2:def 1;
     end;

     for g1 be Real st 0 < g1
      ex r be Real st a < r
       & for r1 be Real st r1 < r & a < r1 & r1 in dom Intf
        holds |. Intf.r1- (G+AG)/2.| < g1
     proof
      let g1 be Real;
      assume
A26:   0 < g1; then
      consider R1 be Real such that
A27:   a<R1 &
       for r1 be Real st r1<R1 & a<r1 & r1 in dom I holds |.I.r1-G.|<g1
        by A8,A9,LIMFUNC2:42;
      consider R2 be Real such that
A28:   a<R2 &
       for r1 be Real st r1<R2 & a<r1 & r1 in dom AI holds |.AI.r1-AG.|<g1
        by A12,A13,A26,LIMFUNC2:42;

      set RR1 = min(b,R1);
      set RR2 = min(b,R2);
      take R = min(RR1,RR2);
      a < RR1 & a < RR2 by A1,A27,A28,XXREAL_0:21;
      hence a < R by XXREAL_0:21;
      hereby let r1 be Real;
       assume
A29:    r1 < R & a < r1 & r1 in dom Intf;

       b >= RR1 & R1 >= RR1 & R2 >= RR2 & RR1 >= R & RR2 >= R
        by XXREAL_0:17; then
       b >= R & R1 >= R & R2 >= R by XXREAL_0:2; then
A30:   b > r1 & R1 > r1 & R2 > r1 by A29,XXREAL_0:2;
       [.r1,b.] c= ].a,b.] by A29,XXREAL_1:39; then
A31:   [.r1,b.] c= dom f by A2;

       f is_integrable_on ['r1,b'] & f|['r1,b'] is bounded
         by A30,A29,A3,INTEGR10:def 2; then
       2*integral(max+f,r1,b) = integral(f,r1,b) + integral(abs f,r1,b)
         by A30,A31,Th62; then
       2*Intf.r1 = integral(f,r1,b) + integral(abs f,r1,b) by A23,A29; then
       2*Intf.r1 = I.r1 + integral(abs f,r1,b) by A29,A22,A6,A7; then
       2*Intf.r1 = I.r1 + AI.r1 by A29,A22,A10,A11; then
       Intf.r1 - (G+AG)/2 = ( (I.r1 - G) + (AI.r1 - AG) ) /2; then
A32:   |. Intf.r1 - (G+AG)/2 .|
         = |.(I.r1-G) + (AI.r1-AG).|/|.2.| by COMPLEX1:67
        .= |.(I.r1-G) + (AI.r1-AG).| / 2 by ABSVALUE:def 1;

A33:   |.(I.r1-G) + (AI.r1-AG).|
        <= |. I.r1-G .| + |. AI.r1-AG .| by COMPLEX1:56;

       |. I.r1 - G .| < g1 & |. AI.r1-AG .| < g1 by A6,A10,A22,A27,A28,A30,A29
; then
       |. I.r1-G .| + |. AI.r1-AG .| < g1 + g1 by XREAL_1:8; then
       |.(I.r1-G) + (AI.r1-AG).| < 2*g1 by A33,XXREAL_0:2; then
       |. Intf.r1 - (G+AG)/2 .| < 2*g1/2 by A32,XREAL_1:74;
       hence |. Intf.r1- (G+AG)/2.| < g1;
      end;
     end;
     hence thesis by A23,A24,FUNCT_2:def 1,LIMFUNC2:10;
    end;
    hence max+f is_left_ext_Riemann_integrable_on a,b by A14,INTEGR10:def 2;
end;

theorem Th64:
for f be PartFunc of REAL,REAL, a,b be Real st a < b & [.a,b.[ c= dom f
 & f is_right_ext_Riemann_integrable_on a,b
 & abs f is_right_ext_Riemann_integrable_on a,b
holds max+f is_right_ext_Riemann_integrable_on a,b
proof
    let f be PartFunc of REAL,REAL, a,b be Real;
    assume that
A1:  a < b and
A2:  [.a,b.[ c= dom f and
A3:  f is_right_ext_Riemann_integrable_on a,b and
A4: abs f is_right_ext_Riemann_integrable_on a,b;

    set G = ext_right_integral(f,a,b);
    set AG = ext_right_integral(abs f,a,b);

A5: for d be Real st a <= d & d < b holds
     f is_integrable_on [' a,d '] & f|[' a,d '] is bounded
      by A3,INTEGR10:def 1;
    consider I be PartFunc of REAL,REAL such that
A6:  dom I = [.a,b.[ and
A7:  for x be Real st x in dom I holds I.x = integral(f,a,x) and
A8:  I is_left_convergent_in b and
A9: G = lim_left(I,b) by A3,INTEGR10:def 3;

    consider AI be PartFunc of REAL,REAL such that
A10:  dom AI = [.a,b.[ and
A11:  for x be Real st x in dom AI holds AI.x = integral(abs f,a,x) and
A12:  AI is_left_convergent_in b and
A13: AG = lim_left(AI,b) by A4,INTEGR10:def 3;

A14: for d be Real st a <= d & d < b holds
     max+f is_integrable_on ['a,d'] & (max+f)|['a,d'] is bounded
    proof
     let d be Real;
     assume
A15:   a <= d & d < b; then
A16: f is_integrable_on ['a,d'] & f|['a,d'] is bounded by A3,INTEGR10:def 1;
A17: (f||['a,d'])|['a,d'] is bounded by A3,A15,INTEGR10:def 1;

     ['a,d'] = [.a,d.] by A15,INTEGRA5:def 3; then
     ['a,d'] c= [.a,b.[ by A15,XXREAL_1:43; then
A18: ['a,d'] c= dom f by A2; then
A19: dom(f||['a,d']) = ['a,d'] by RELAT_1:62;

A20: max+(f||['a,d']) = max+(f|['a,d']) by A18,Th59
      .= (max+f)||['a,d'] by MESFUNC6:66;

A21: f||['a,d'] is Function of ['a,d'],REAL by A19,FUNCT_2:67;
     f||['a,d'] is integrable by A5,A15,INTEGRA5:def 1;
     hence max+f is_integrable_on ['a,d']
       by A20,A17,A21,INTEGRA4:20,INTEGRA5:def 1;
     f|['a,d'] is bounded_above by A16,SEQ_2:def 8; then
     (max+f)|['a,d'] is bounded_above & (max+f)|['a,d'] is bounded_below
       by INTEGRA4:14,15;
     hence (max+f)|['a,d'] is bounded by SEQ_2:def 8;
    end;

    ex Intf be PartFunc of REAL,REAL st
     dom Intf = [.a,b.[ &
     (for x be Real st x in dom Intf holds Intf.x = integral(max+f,a,x)) &
     Intf is_left_convergent_in b
    proof
     reconsider A = [.a,b.[ as non empty Subset of REAL by A1,XXREAL_1:31;
     deffunc F(Element of A) = In(integral(max+f,a,$1),REAL);
     consider Intf be Function of A, REAL such that
A22:  for x being Element of A holds Intf.x = F(x) from FUNCT_2:sch 4;
A23: dom Intf = A by FUNCT_2:def 1; then
     reconsider Intf as PartFunc of REAL, REAL by RELSET_1:5;
     take Intf;
A24: for x be Real st x in dom Intf holds Intf.x = integral(max+f,a,x)
     proof
      let x be Real;
      assume x in dom Intf; then
      x is Element of A by FUNCT_2:def 1; then
      Intf.x = In(integral(max+f,a,x),REAL) by A22;
      hence Intf.x = integral(max+f,a,x);
     end;

A25: for r be Real st r<b ex g be Real st r<g & g<b & g in dom Intf
       by A6,A23,A8,LIMFUNC2:7;

     for g1 be Real st 0 < g1
      ex r be Real st r < b
       & for r1 be Real st r < r1 & r1 < b & r1 in dom Intf
        holds |. Intf.r1- (G+AG)/2.| < g1
     proof
      let g1 be Real;
      assume
A26:    0 < g1; then
      consider R1 be Real such that
A27:    R1<b &
       for r1 be Real st R1<r1 & r1<b & r1 in dom I holds |.I.r1-G.|<g1
        by A8,A9,LIMFUNC2:41;
      consider R2 be Real such that
A28:    R2<b &
       for r1 be Real st R2<r1 & r1<b & r1 in dom AI holds |.AI.r1-AG.|<g1
        by A12,A13,A26,LIMFUNC2:41;

      set RR1 = max(a,R1);
      set RR2 = max(a,R2);
      take R = max(RR1,RR2);
      RR1 < b & RR2 < b by A1,A27,A28,XXREAL_0:29;
      hence R < b by XXREAL_0:29;
      hereby let r1 be Real;
       assume
A29:     R < r1 & r1 < b & r1 in dom Intf;

       a <= RR1 & R1 <= RR1 & R2 <= RR2 & RR1 <= R & RR2 <= R
         by XXREAL_0:25; then
       a <= R & R1 <= R & R2 <= R by XXREAL_0:2; then
A30:    a < r1 & R1 < r1 & R2 < r1 by A29,XXREAL_0:2;
       [.a,r1.] c= [.a,b.[ by A29,XXREAL_1:43; then
A31:    [.a,r1.] c= dom f by A2;
       f is_integrable_on ['a,r1'] & f|['a,r1'] is bounded
         by A30,A29,A3,INTEGR10:def 1; then
       2*integral(max+f,a,r1) = integral(f,a,r1) + integral(abs f,a,r1)
         by A30,A31,Th62; then
       2*Intf.r1 = integral(f,a,r1) + integral(abs f,a,r1) by A24,A29; then
       2*Intf.r1 = I.r1 + integral(abs f,a,r1) by A29,A23,A6,A7; then
       2*Intf.r1 = I.r1 + AI.r1 by A29,A23,A10,A11; then
       Intf.r1 - (G+AG)/2 = ( (I.r1 - G) + (AI.r1 - AG) ) /2; then
A32:    |. Intf.r1 - (G+AG)/2 .|
         = |.(I.r1-G) + (AI.r1-AG).|/|.2.| by COMPLEX1:67
        .= |.(I.r1-G) + (AI.r1-AG).| / 2 by ABSVALUE:def 1;

A33:   |.(I.r1-G) + (AI.r1-AG).|
        <= |. I.r1-G .| + |. AI.r1-AG .| by COMPLEX1:56;

       |. I.r1 - G .| < g1 & |. AI.r1-AG .| < g1 by A6,A10,A23,A27,A28,A30,A29
; then
       |. I.r1-G .| + |. AI.r1-AG .| < g1 + g1 by XREAL_1:8; then
       |.(I.r1-G) + (AI.r1-AG).| < 2*g1 by A33,XXREAL_0:2; then
       |. Intf.r1 - (G+AG)/2 .| < 2*g1/2 by A32,XREAL_1:74;
       hence |. Intf.r1- (G+AG)/2.| < g1;
      end;
     end;
     hence thesis by A24,A25,LIMFUNC2:7,FUNCT_2:def 1;
    end;
    hence max+f is_right_ext_Riemann_integrable_on a,b by A14,INTEGR10:def 1;
end;

theorem Th65:
for f be PartFunc of REAL,REAL, b be Real st left_closed_halfline b c= dom f
 & f is_-infty_ext_Riemann_integrable_on b
 & abs f is_-infty_ext_Riemann_integrable_on b
holds max+f is_-infty_ext_Riemann_integrable_on b
proof
    let f be PartFunc of REAL,REAL, b be Real;
    assume that
A1:  left_closed_halfline b c= dom f and
A2:  f is_-infty_ext_Riemann_integrable_on b and
A3: abs f is_-infty_ext_Riemann_integrable_on b;

A4: b in REAL by XREAL_0:def 1;

A5: left_closed_halfline b = ].-infty,b.] by LIMFUNC1:def 1;

    set G = infty_ext_left_integral(f,b);
    set AG = infty_ext_left_integral(abs f,b);

    consider I be PartFunc of REAL,REAL such that
A6:  dom I = left_closed_halfline b and
A7:  for x be Real st x in dom I holds I.x = integral(f,x,b) and
A8:  I is convergent_in-infty and
A9:  G = lim_in-infty I by A2,INTEGR10:def 8;
    consider AI be PartFunc of REAL,REAL such that
A10:  dom AI = left_closed_halfline b and
A11:  for x be Real st x in dom AI holds AI.x = integral(abs f,x,b) and
A12:  AI is convergent_in-infty and
A13: AG = lim_in-infty AI by A3,INTEGR10:def 8;

A14:for d be Real st d <= b holds
     max+f is_integrable_on ['d,b'] & (max+f)|['d,b'] is bounded
    proof
     let d be Real;
     assume
A15:  d <= b; then
A16: f is_integrable_on ['d,b'] & f|['d,b'] is bounded
       by A2,INTEGR10:def 6;
A17: (f||['d,b'])|['d,b'] is bounded by A15,A2,INTEGR10:def 6;

A18:  d in REAL by XREAL_0:def 1;
     ['d,b'] = [.d,b.] by A15,INTEGRA5:def 3; then
     ['d,b'] c= ].-infty,b.] by A18,XXREAL_0:12,XXREAL_1:39; then
A19: ['d,b'] c= dom f by A1,A5; then
A20: dom(f||['d,b']) = ['d,b'] by RELAT_1:62;
A21: max+(f||['d,b']) = max+(f|['d,b']) by A19,Th59
      .= (max+f)||['d,b'] by MESFUNC6:66;
A22: f||['d,b'] is Function of ['d,b'],REAL by A20,FUNCT_2:67;
     f||['d,b'] is integrable by A15,A2,INTEGR10:def 6,INTEGRA5:def 1;
     hence max+f is_integrable_on ['d,b']
       by A21,A17,A22,INTEGRA4:20,INTEGRA5:def 1;
     f|['d,b'] is bounded_above by A16,SEQ_2:def 8; then
     (max+f)|['d,b'] is bounded_above & (max+f)|['d,b'] is bounded_below
       by INTEGRA4:14,15;
     hence (max+f)|['d,b'] is bounded by SEQ_2:def 8;
    end;

    ex Intf be PartFunc of REAL,REAL st
     dom Intf = left_closed_halfline b &
     (for x be Real st x in dom Intf holds Intf.x = integral(max+f,x,b)) &
     Intf is convergent_in-infty
    proof
     reconsider A = ].-infty,b.] as non empty Subset of REAL
       by A4,XXREAL_0:12,XXREAL_1:32;
     deffunc F(Element of A) = In(integral(max+f,$1,b),REAL);
     consider Intf be Function of A, REAL such that
A23:  for x being Element of A holds Intf.x = F(x) from FUNCT_2:sch 4;
A24: dom Intf = A by FUNCT_2:def 1; then
     reconsider Intf as PartFunc of REAL, REAL by RELSET_1:5;
     take Intf;
A25: for x be Real st x in dom Intf holds Intf.x = integral(max+f,x,b)
     proof
      let x be Real;
      assume x in dom Intf; then
      x is Element of A by FUNCT_2:def 1; then
      Intf.x = In(integral(max+f,x,b),REAL) by A23;
      hence Intf.x = integral(max+f,x,b);
     end;

A26: for r be Real ex g be Real st g<r & g in dom Intf
       by A5,A6,A8,A24,LIMFUNC1:45;

     for g1 be Real st 0 < g1
      ex r be Real st for r1 be Real st r1 < r & r1 in dom Intf
        holds |. Intf.r1- (G+AG)/2.| < g1
     proof
      let g1 be Real;
      assume
A27:    0 < g1; then
      consider R1 be Real such that
A28:   for r1 be Real st r1<R1 & r1 in dom I holds |.I.r1-G.|<g1
        by A8,A9,LIMFUNC1:78;
      consider R2 be Real such that
A29:   for r1 be Real st r1<R2 & r1 in dom AI holds |.AI.r1-AG.|<g1
        by A12,A13,A27,LIMFUNC1:78;

      set RR1 = min(b,R1);
      set RR2 = min(b,R2);
      take R = min(RR1,RR2);
      hereby let r1 be Real;
       assume
A30:    r1 < R & r1 in dom Intf;

A31:    r1 in REAL by XREAL_0:def 1;

       b >= RR1 & R1 >= RR1 & R2 >= RR2 & RR1 >= R & RR2 >= R
         by XXREAL_0:17; then
       b >= R & R1 >= R & R2 >= R by XXREAL_0:2; then
A32:   b > r1 & R1 > r1 & R2 > r1 by A30,XXREAL_0:2;
       [.r1,b.] c= ].-infty,b.] by A31,XXREAL_0:12,XXREAL_1:39; then
A33:   [.r1,b.] c= dom f by A1,A5;
       f is_integrable_on ['r1,b'] & f|['r1,b'] is bounded
         by A32,A2,INTEGR10:def 6; then
       2*integral(max+f,r1,b) = integral(f,r1,b) + integral(abs f,r1,b)
         by A32,A33,Th62; then
       2*Intf.r1 = integral(f,r1,b) + integral(abs f,r1,b) by A25,A30; then
       2*Intf.r1 = I.r1 + integral(abs f,r1,b) by A5,A30,A24,A6,A7; then
       2*Intf.r1 = I.r1 + AI.r1 by A5,A30,A24,A10,A11; then
       Intf.r1 - (G+AG)/2 = ( (I.r1 - G) + (AI.r1 - AG) ) /2; then
A34:    |. Intf.r1 - (G+AG)/2 .|
         = |.(I.r1-G) + (AI.r1-AG).|/|.2.| by COMPLEX1:67
        .= |.(I.r1-G) + (AI.r1-AG).| / 2 by ABSVALUE:def 1;

A35:   |.(I.r1-G) + (AI.r1-AG).|
        <= |. I.r1-G .| + |. AI.r1-AG .| by COMPLEX1:56;

       |. I.r1 - G .| < g1 & |. AI.r1-AG .| < g1
         by A5,A6,A10,A24,A28,A29,A32,A30; then
       |. I.r1-G .| + |. AI.r1-AG .| < g1 + g1 by XREAL_1:8; then
       |.(I.r1-G) + (AI.r1-AG).| < 2*g1 by A35,XXREAL_0:2; then
       |. Intf.r1 - (G+AG)/2 .| < 2*g1/2 by A34,XREAL_1:74;
       hence |. Intf.r1- (G+AG)/2.| < g1;
      end;
     end;
     hence thesis by A5,A25,A26,LIMFUNC1:45,FUNCT_2:def 1;
    end;
    hence max+f is_-infty_ext_Riemann_integrable_on b by A14,INTEGR10:def 6;
end;

theorem Th66:
for f be PartFunc of REAL,REAL, a be Real st right_closed_halfline a c= dom f
 & f is_+infty_ext_Riemann_integrable_on a
 & abs f is_+infty_ext_Riemann_integrable_on a
holds max+f is_+infty_ext_Riemann_integrable_on a
proof
    let f be PartFunc of REAL,REAL, a be Real;
    assume that
A1:  right_closed_halfline a c= dom f and
A2:  f is_+infty_ext_Riemann_integrable_on a and
A3: abs f is_+infty_ext_Riemann_integrable_on a;

A4: a in REAL by XREAL_0:def 1;
A5: right_closed_halfline a = [.a,+infty.[ by LIMFUNC1:def 2;

    set G = infty_ext_right_integral(f,a);
    set AG = infty_ext_right_integral(abs f,a);

    consider I be PartFunc of REAL,REAL such that
A6:  dom I = right_closed_halfline a and
A7:  for x be Real st x in dom I holds I.x = integral(f,a,x) and
A8:  I is convergent_in+infty and
A9:  G = lim_in+infty I by A2,INTEGR10:def 7;
    consider AI be PartFunc of REAL,REAL such that
A10:  dom AI = right_closed_halfline a and
A11:  for x be Real st x in dom AI holds AI.x = integral(abs f,a,x) and
A12:  AI is convergent_in+infty and
A13: AG = lim_in+infty AI by A3,INTEGR10:def 7;

A14:for d be Real st a <= d holds
     max+f is_integrable_on ['a,d'] & (max+f)|['a,d'] is bounded
    proof
     let d be Real;
     assume
A15:  a <= d; then
A16: f is_integrable_on ['a,d'] & f|['a,d'] is bounded by A2,INTEGR10:def 5;
A17: (f||['a,d'])|['a,d'] is bounded by A15,A2,INTEGR10:def 5;

A18:  d in REAL by XREAL_0:def 1;
     ['a,d'] = [.a,d.] by A15,INTEGRA5:def 3; then
     ['a,d'] c= [.a,+infty.[ by A18,XXREAL_0:9,XXREAL_1:43; then
A19: ['a,d'] c= dom f by A1,A5; then
A20: dom(f||['a,d']) = ['a,d'] by RELAT_1:62;
A21: max+(f||['a,d']) = max+(f|['a,d']) by A19,Th59
      .= (max+f)||['a,d'] by MESFUNC6:66;
A22: f||['a,d'] is Function of ['a,d'],REAL by A20,FUNCT_2:67;
     f||['a,d'] is integrable by A15,A2,INTEGR10:def 5,INTEGRA5:def 1;
     hence max+f is_integrable_on ['a,d']
       by A21,A17,A22,INTEGRA4:20,INTEGRA5:def 1;
     f|['a,d'] is bounded_above by A16,SEQ_2:def 8; then
     (max+f)|['a,d'] is bounded_above & (max+f)|['a,d'] is bounded_below
       by INTEGRA4:14,15;
     hence (max+f)|['a,d'] is bounded by SEQ_2:def 8;
    end;

    ex Intf be PartFunc of REAL,REAL st
     dom Intf = right_closed_halfline a &
     (for x be Real st x in dom Intf holds Intf.x = integral(max+f,a,x)) &
     Intf is convergent_in+infty
    proof
     reconsider A = [.a,+infty.[ as non empty Subset of REAL
       by A4,XXREAL_0:9,XXREAL_1:31;
     deffunc F(Element of A) = In(integral(max+f,a,$1),REAL);
     consider Intf be Function of A, REAL such that
A23:  for x being Element of A holds Intf.x = F(x) from FUNCT_2:sch 4;
A24: dom Intf = A by FUNCT_2:def 1; then
     reconsider Intf as PartFunc of REAL, REAL by RELSET_1:5;
     take Intf;
A25: for x be Real st x in dom Intf holds Intf.x = integral(max+f,a,x)
     proof
      let x be Real;
      assume x in dom Intf; then
      x is Element of A by FUNCT_2:def 1; then
      Intf.x = In(integral(max+f,a,x),REAL) by A23;
      hence Intf.x = integral(max+f,a,x);
     end;

A26: for r be Real ex g be Real st r<g & g in dom Intf
       by A5,A6,A8,A24,LIMFUNC1:44;

     for g1 be Real st 0 < g1
      ex r be Real st for r1 be Real st r < r1 & r1 in dom Intf
        holds |. Intf.r1- (G+AG)/2.| < g1
     proof
      let g1 be Real;
      assume
A27:    0 < g1; then
      consider R1 be Real such that
A28:   for r1 be Real st R1 < r1 & r1 in dom I holds |.I.r1-G.|<g1
        by A8,A9,LIMFUNC1:79;
      consider R2 be Real such that
A29:   for r1 be Real st R2 < r1 & r1 in dom AI holds |.AI.r1-AG.|<g1
        by A12,A13,A27,LIMFUNC1:79;

      set RR1 = max(a,R1);
      set RR2 = max(a,R2);
      take R = max(RR1,RR2);
      hereby let r1 be Real;
       assume
A30:     R < r1 & r1 in dom Intf;

A31:    r1 in REAL by XREAL_0:def 1;

       a <= RR1 & R1 <= RR1 & R2 <= RR2 & RR1 <= R & RR2 <= R
         by XXREAL_0:25; then
       a <= R & R1 <= R & R2 <= R by XXREAL_0:2; then
A32:   a < r1 & R1 < r1 & R2 < r1 by A30,XXREAL_0:2;
       [.a,r1.] c= [.a,+infty.[ by A31,XXREAL_0:9,XXREAL_1:43; then
A33:   [.a,r1.] c= dom f by A1,A5;
       f is_integrable_on ['a,r1'] & f|['a,r1'] is bounded
          by A32,A2,INTEGR10:def 5; then
       2*integral(max+f,a,r1) = integral(f,a,r1) + integral(abs f,a,r1)
         by A32,A33,Th62; then
       2*Intf.r1 = integral(f,a,r1) + integral(abs f,a,r1) by A25,A30; then
       2*Intf.r1 = I.r1 + integral(abs f,a,r1) by A5,A30,A24,A6,A7; then
       2*Intf.r1 = I.r1 + AI.r1 by A5,A30,A24,A10,A11; then
       Intf.r1 - (G+AG)/2 = ( (I.r1 - G) + (AI.r1 - AG) ) /2; then
A34:    |. Intf.r1 - (G+AG)/2 .|
         = |.(I.r1-G) + (AI.r1-AG).|/|.2.| by COMPLEX1:67
        .= |.(I.r1-G) + (AI.r1-AG).| / 2 by ABSVALUE:def 1;

A35:   |.(I.r1-G) + (AI.r1-AG).|
        <= |. I.r1-G .| + |. AI.r1-AG .| by COMPLEX1:56;

       |. I.r1 - G .| < g1 & |. AI.r1-AG .| < g1
         by A5,A6,A10,A24,A28,A29,A32,A30; then
       |. I.r1-G .| + |. AI.r1-AG .| < g1 + g1 by XREAL_1:8; then
       |.(I.r1-G) + (AI.r1-AG).| < 2*g1 by A35,XXREAL_0:2; then
       |. Intf.r1 - (G+AG)/2 .| < 2*g1/2 by A34,XREAL_1:74;
       hence |. Intf.r1- (G+AG)/2.| < g1;
      end;
     end;
     hence thesis by A5,A25,A26,LIMFUNC1:44,FUNCT_2:def 1;
    end;
    hence max+f is_+infty_ext_Riemann_integrable_on a by A14,INTEGR10:def 5;
end;

theorem Th67:
for f be PartFunc of REAL,REAL, a,b be Real st a < b & ].a,b.] c= dom f
 & f is_left_ext_Riemann_integrable_on a,b
 & abs f is_left_ext_Riemann_integrable_on a,b
holds max-f is_left_ext_Riemann_integrable_on a,b
proof
    let f be PartFunc of REAL,REAL, a,b be Real;
    assume that
A1:  a < b and
A2:  ].a,b.] c= dom f and
A3:  f is_left_ext_Riemann_integrable_on a,b and
A4: abs f is_left_ext_Riemann_integrable_on a,b;

A5:-f = (-1)(#)f by VALUED_1:def 6; then
A6: dom(-f) = dom f by VALUED_1:def 5;
A7: -f is_left_ext_Riemann_integrable_on a,b by A2,A3,A5,INTEGR24:30;

    abs(-f) = |. -1 .| (#)abs f by A5,RFUNCT_1:25
     .= (--1)(#)abs f by COMPLEX1:70 .= abs f; then
    max+(-f) is_left_ext_Riemann_integrable_on a,b by A1,A2,A4,A6,A7,Th63;
    hence max-f is_left_ext_Riemann_integrable_on a,b by INTEGRA4:21;
end;

theorem Th68:
for f be PartFunc of REAL,REAL, a,b be Real st a < b & [.a,b.[ c= dom f
 & f is_right_ext_Riemann_integrable_on a,b
 & abs f is_right_ext_Riemann_integrable_on a,b
holds max-f is_right_ext_Riemann_integrable_on a,b
proof
    let f be PartFunc of REAL,REAL, a,b be Real;
    assume that
A1:  a < b and
A2:  [.a,b.[ c= dom f and
A3:  f is_right_ext_Riemann_integrable_on a,b and
A4: abs f is_right_ext_Riemann_integrable_on a,b;

A5:-f = (-1)(#)f by VALUED_1:def 6; then
A6: dom(-f) = dom f by VALUED_1:def 5;
A7: -f is_right_ext_Riemann_integrable_on a,b by A2,A3,A5,INTEGR24:31;

    abs(-f) = |. -1 .| (#)abs f by A5,RFUNCT_1:25
     .= (--1)(#)abs f by COMPLEX1:70 .= abs f; then
    max+(-f) is_right_ext_Riemann_integrable_on a,b by A1,A2,A4,A6,A7,Th64;
    hence max-f is_right_ext_Riemann_integrable_on a,b by INTEGRA4:21;
end;

theorem Th69:
for f be PartFunc of REAL,REAL, b be Real st left_closed_halfline b c= dom f
 & f is_-infty_ext_Riemann_integrable_on b
 & abs f is_-infty_ext_Riemann_integrable_on b
holds max-f is_-infty_ext_Riemann_integrable_on b
proof
    let f be PartFunc of REAL,REAL, b be Real;
    assume that
A1:  left_closed_halfline b c= dom f and
A2:  f is_-infty_ext_Riemann_integrable_on b and
A3: abs f is_-infty_ext_Riemann_integrable_on b;

A4:-f = (-1)(#)f by VALUED_1:def 6; then
A5: dom(-f) = dom f by VALUED_1:def 5;
   (-1)(#)f is_-infty_ext_Riemann_integrable_on b by A1,A2,INTEGR10:11; then
A6:-f is_-infty_ext_Riemann_integrable_on b by VALUED_1:def 6;
    abs(-f) = |. -1 .| (#)abs f by A4,RFUNCT_1:25
     .= (--1)(#)abs f by COMPLEX1:70 .= abs f; then
    max+(-f) is_-infty_ext_Riemann_integrable_on b by A1,A3,A5,A6,Th65;
    hence max-f is_-infty_ext_Riemann_integrable_on b by INTEGRA4:21;
end;

theorem Th70:
for f be PartFunc of REAL,REAL, a be Real st right_closed_halfline a c= dom f
 & f is_+infty_ext_Riemann_integrable_on a
 & abs f is_+infty_ext_Riemann_integrable_on a
holds max-f is_+infty_ext_Riemann_integrable_on a
proof
    let f be PartFunc of REAL,REAL, a be Real;
    assume that
A1:  right_closed_halfline a c= dom f and
A2:  f is_+infty_ext_Riemann_integrable_on a and
A3: abs f is_+infty_ext_Riemann_integrable_on a;

A4:-f = (-1)(#)f by VALUED_1:def 6; then
A5: dom(-f) = dom f by VALUED_1:def 5;
   (-1)(#)f is_+infty_ext_Riemann_integrable_on a by A1,A2,INTEGR10:9; then
A6:-f is_+infty_ext_Riemann_integrable_on a by VALUED_1:def 6;
    abs(-f) = |. -1 .| (#)abs f by A4,RFUNCT_1:25
     .= (--1)(#)abs f by COMPLEX1:70 .= abs f; then
    max+(-f) is_+infty_ext_Riemann_integrable_on a by A1,A3,A5,A6,Th66;
    hence max-f is_+infty_ext_Riemann_integrable_on a by INTEGRA4:21;
end;

theorem Th71:
for f be PartFunc of REAL,REAL, a,b be Real st ].a,b.] c= dom f &
 max+f is_left_ext_Riemann_integrable_on a,b &
 max-f is_left_ext_Riemann_integrable_on a,b
 holds f is_left_ext_Riemann_integrable_on a,b &
     left_improper_integral(f,a,b)
    = left_improper_integral(max+f,a,b) - left_improper_integral(max-f,a,b)
proof
    let f be PartFunc of REAL,REAL, a,b be Real;
    assume that
A1:  ].a,b.] c= dom f and
A2:  max+f is_left_ext_Riemann_integrable_on a,b and
A3:  max-f is_left_ext_Riemann_integrable_on a,b;

A4: max+f is_left_improper_integrable_on a,b by A2,INTEGR24:32;
A5: max-f is_left_improper_integrable_on a,b by A3,INTEGR24:32;

    consider I1 be PartFunc of REAL,REAL such that
A6:  dom I1 = ].a,b.] and
A7:  for x be Real st x in dom I1 holds I1.x = integral(max+f,x,b) and
A8:  I1 is_right_convergent_in a by A2,INTEGR10:def 2;

    consider I2 be PartFunc of REAL,REAL such that
A9:  dom I2 = ].a,b.] and
A10:  for x be Real st x in dom I2 holds I2.x = integral(max-f,x,b) and
A11:  I2 is_right_convergent_in a by A3,INTEGR10:def 2;

A12:f = max+f - max-f by RFUNCT_3:34;

A13:for d be Real st a < d & d <= b holds
     f is_integrable_on ['d,b'] & f|['d,b'] is bounded
    proof
     let d be Real;
     assume A14: a < d & d <= b; then
A15: max+f is_integrable_on ['d,b'] & max+f|['d,b'] is bounded
       by A2,INTEGR10:def 2;
A16: max-f is_integrable_on ['d,b'] & max-f|['d,b'] is bounded
       by A14,A3,INTEGR10:def 2;
     ['d,b'] = [.d,b.] by A14,INTEGRA5:def 3; then
     ['d,b'] c= ].a,b.] by A14,XXREAL_1:39; then
     ['d,b'] c= dom f by A1; then
     ['d,b'] c= dom(max+f) & ['d,b'] c= dom(max-f) by RFUNCT_3:def 10,def 11;
     hence f is_integrable_on ['d,b'] by A12,A15,A16,INTEGRA6:11;
     f|(['d,b'] /\ ['d,b']) is bounded by A12,A15,A16,RFUNCT_1:84;
     hence f|['d,b'] is bounded;
    end;

A17:dom(I1-I2) = ].a,b.] /\ ].a,b.] by A6,A9,VALUED_1:12;
A18:for x be Real st x in dom(I1-I2) holds (I1-I2).x = integral(f,x,b)
    proof
     let x be Real;
     assume
A19:  x in dom(I1-I2); then
     (I1-I2).x = I1.x - I2.x by VALUED_1:13; then
     (I1-I2).x = integral(max+f,x,b) - I2.x by A19,A6,A7,A17; then
A20: (I1-I2).x = integral(max+f,x,b) - integral(max-f,x,b) by A19,A9,A10,A17;

A21: a < x & x <= b by A19,A17,XXREAL_1:2; then
     ['x,b'] = [.x,b.] by INTEGRA5:def 3; then
     ['x,b'] c= ].a,b.] by A21,XXREAL_1:39; then
     ['x,b'] c= dom f by A1; then
A22: ['x,b'] c= dom(max+f) & ['x,b'] c= dom(max-f) by RFUNCT_3:def 10,def 11;
     max+f is_integrable_on ['x,b'] & max+f|['x,b'] is bounded &
     max-f is_integrable_on ['x,b'] & max-f|['x,b'] is bounded
       by A21,A2,A3,INTEGR10:def 2;
     hence (I1-I2).x = integral(f,x,b) by A20,A21,A22,A12,INTEGRA6:12;
    end;

A23:for r be Real st a<r ex g be Real st g<r & a<g & g in dom(I1-I2)
      by A17,A6,A8,LIMFUNC2:10;
    hence f is_left_ext_Riemann_integrable_on a,b
      by A13,A17,A18,A8,A11,LIMFUNC2:55,INTEGR10:def 2;

A24:I1-I2 is_right_convergent_in a
  & lim_right(I1-I2,a) = lim_right(I1,a) - lim_right(I2,a)
      by A8,A23,A11,LIMFUNC2:55; then
A25:f is_left_improper_integrable_on a,b
      by A13,A17,A18,INTEGR10:def 2,INTEGR24:32;

A26:lim_right(I1,a) = left_improper_integral(max+f,a,b) &
    lim_right(I2,a) = left_improper_integral(max-f,a,b)
      by A4,A5,A6,A7,A8,A9,A10,A11,INTEGR24:def 3; then
A27: -lim_right(I2,a) = -left_improper_integral(max-f,a,b)
      by XXREAL_3:def 3;

    left_improper_integral(max+f,a,b) - left_improper_integral(max-f,a,b)
      = left_improper_integral(max+f,a,b) + - left_improper_integral(max-f,a,b)
        by XXREAL_3:def 4
     .= lim_right(I1,a) + -lim_right(I2,a) by A26,A27,XXREAL_3:def 2;
    hence left_improper_integral(f,a,b)
      = left_improper_integral(max+f,a,b) - left_improper_integral(max-f,a,b)
       by A25,A17,A18,A24,INTEGR24:def 3;
end;

theorem Th72:
for f be PartFunc of REAL,REAL, a,b be Real st [.a,b.[ c= dom f &
 max+f is_right_ext_Riemann_integrable_on a,b &
 max-f is_right_ext_Riemann_integrable_on a,b
 holds f is_right_ext_Riemann_integrable_on a,b &
     right_improper_integral(f,a,b)
    = right_improper_integral(max+f,a,b) - right_improper_integral(max-f,a,b)
proof
    let f be PartFunc of REAL,REAL, a,b be Real;
    assume that
A1:  [.a,b.[ c= dom f and
A2:  max+f is_right_ext_Riemann_integrable_on a,b and
A3:  max-f is_right_ext_Riemann_integrable_on a,b;

A4: max+f is_right_improper_integrable_on a,b by A2,INTEGR24:33;
A5: max-f is_right_improper_integrable_on a,b by A3,INTEGR24:33;

    consider I1 be PartFunc of REAL,REAL such that
A6:  dom I1 = [.a,b.[ and
A7:  for x be Real st x in dom I1 holds I1.x = integral(max+f,a,x) and
A8:  I1 is_left_convergent_in b by A2,INTEGR10:def 1;

    consider I2 be PartFunc of REAL,REAL such that
A9:  dom I2 = [.a,b.[ and
A10:  for x be Real st x in dom I2 holds I2.x = integral(max-f,a,x) and
A11:  I2 is_left_convergent_in b by A3,INTEGR10:def 1;

A12:f = max+f - max-f by RFUNCT_3:34;

A13:for d be Real st a <= d & d < b holds
     f is_integrable_on ['a,d'] & f|['a,d'] is bounded
    proof
     let d be Real;
     assume A14: a <= d & d < b; then
A15: max+f is_integrable_on ['a,d'] & max+f|['a,d'] is bounded &
     max-f is_integrable_on ['a,d'] & max-f|['a,d'] is bounded
       by A2,A3,INTEGR10:def 1;
     ['a,d'] = [.a,d.] by A14,INTEGRA5:def 3; then
     ['a,d'] c= [.a,b.[ by A14,XXREAL_1:43; then
     ['a,d'] c= dom f by A1; then
     ['a,d'] c= dom(max+f) & ['a,d'] c= dom(max-f) by RFUNCT_3:def 10,def 11;
     hence f is_integrable_on ['a,d'] by A12,A15,INTEGRA6:11;
     f|(['a,d'] /\ ['a,d']) is bounded by A12,A15,RFUNCT_1:84;
     hence f|['a,d'] is bounded;
    end;

A16:dom(I1-I2) = [.a,b.[ /\ [.a,b.[ by A6,A9,VALUED_1:12;

A17:for x be Real st x in dom(I1-I2) holds (I1-I2).x = integral(f,a,x)
    proof
     let x be Real;
     assume
A18:  x in dom(I1-I2); then
     (I1-I2).x = I1.x - I2.x by VALUED_1:13; then
     (I1-I2).x = integral(max+f,a,x) - I2.x by A18,A6,A7,A16; then
A19: (I1-I2).x = integral(max+f,a,x) - integral(max-f,a,x) by A18,A9,A10,A16;

A20: a <= x & x < b by A18,A16,XXREAL_1:3; then
     ['a,x'] = [.a,x.] by INTEGRA5:def 3; then
     ['a,x'] c= [.a,b.[ by A20,XXREAL_1:43; then
     ['a,x'] c= dom f by A1; then
A21: ['a,x'] c= dom(max+f) & ['a,x'] c= dom(max-f) by RFUNCT_3:def 10,def 11;
     max+f is_integrable_on ['a,x'] & max+f|['a,x'] is bounded &
     max-f is_integrable_on ['a,x'] & max-f|['a,x'] is bounded
       by A20,A2,A3,INTEGR10:def 1;
     hence (I1-I2).x = integral(f,a,x) by A19,A20,A21,A12,INTEGRA6:12;
    end;

A22:for r be Real st r<b ex g be Real st r<g & g<b & g in dom(I1-I2)
      by A16,A6,A8,LIMFUNC2:7;
    hence f is_right_ext_Riemann_integrable_on a,b
      by A13,A16,A17,A8,A11,LIMFUNC2:46,INTEGR10:def 1;

A23:I1-I2 is_left_convergent_in b
  & lim_left(I1-I2,b) = lim_left(I1,b) - lim_left(I2,b)
      by A8,A11,A22,LIMFUNC2:46; then
A24:f is_right_improper_integrable_on a,b
      by A13,A16,A17,INTEGR10:def 1,INTEGR24:33;
A25:lim_left(I1,b) = right_improper_integral(max+f,a,b)
  & lim_left(I2,b) = right_improper_integral(max-f,a,b)
      by A4,A5,A6,A7,A8,A9,A10,A11,INTEGR24:def 4; then
A26: -lim_left(I2,b) = -right_improper_integral(max-f,a,b) by XXREAL_3:def 3;

    right_improper_integral(max+f,a,b) - right_improper_integral(max-f,a,b)
     = right_improper_integral(max+f,a,b) + -right_improper_integral(max-f,a,b)
      by XXREAL_3:def 4
    .= lim_left(I1,b) + -lim_left(I2,b) by A25,A26,XXREAL_3:def 2;
    hence right_improper_integral(f,a,b)
      = right_improper_integral(max+f,a,b) - right_improper_integral(max-f,a,b)
       by A24,A16,A17,A23,INTEGR24:def 4;
end;

theorem Th73:
for f be PartFunc of REAL,REAL, b be Real st left_closed_halfline b c= dom f &
 max+f is_-infty_ext_Riemann_integrable_on b &
 max-f is_-infty_ext_Riemann_integrable_on b
 holds f is_-infty_ext_Riemann_integrable_on b &
     improper_integral_-infty(f,b)
    = improper_integral_-infty(max+f,b) - improper_integral_-infty(max-f,b)
proof
    let f be PartFunc of REAL,REAL, b be Real;
    assume that
A1:  left_closed_halfline b c= dom f and
A2:  max+f is_-infty_ext_Riemann_integrable_on b and
A3:  max-f is_-infty_ext_Riemann_integrable_on b;

A4: max+f is_-infty_improper_integrable_on b by A2,INTEGR25:20;
A5: max-f is_-infty_improper_integrable_on b by A3,INTEGR25:20;

A6: left_closed_halfline b = ].-infty,b.] by LIMFUNC1:def 1;

    consider I1 be PartFunc of REAL,REAL such that
A7:  dom I1 = left_closed_halfline b and
A8:  for x be Real st x in dom I1 holds I1.x = integral(max+f,x,b) and
A9:  I1 is convergent_in-infty by A2,INTEGR10:def 6;

    consider I2 be PartFunc of REAL,REAL such that
A10:  dom I2 = left_closed_halfline b and
A11:  for x be Real st x in dom I2 holds I2.x = integral(max-f,x,b) and
A12:  I2 is convergent_in-infty by A3,INTEGR10:def 6;

A13:f = max+f - max-f by RFUNCT_3:34;

A14:for d be Real st d <= b holds
     f is_integrable_on ['d,b'] & f|['d,b'] is bounded
    proof
     let d be Real;
     assume A15: d <= b; then
A16: max+f is_integrable_on ['d,b'] & max+f|['d,b'] is bounded
   & max-f is_integrable_on ['d,b'] & max-f|['d,b'] is bounded
       by A2,A3,INTEGR10:def 6;
A17:  d in REAL by XREAL_0:def 1;

     ['d,b'] = [.d,b.] by A15,INTEGRA5:def 3; then
     ['d,b'] c= ].-infty,b.] by A17,XXREAL_0:12,XXREAL_1:39; then
     ['d,b'] c= dom f by A1,A6; then
     ['d,b'] c= dom(max+f) & ['d,b'] c= dom(max-f) by RFUNCT_3:def 10,def 11;
     hence f is_integrable_on ['d,b'] by A13,A16,INTEGRA6:11;
     f|(['d,b'] /\ ['d,b']) is bounded by A13,A16,RFUNCT_1:84;
     hence f|['d,b'] is bounded;
    end;

A18:dom(I1-I2) = ].-infty,b.] /\ ].-infty,b.] by A6,A7,A10,VALUED_1:12;
A19:for x be Real st x in dom(I1-I2) holds (I1-I2).x = integral(f,x,b)
    proof
     let x be Real;
     assume
A20:  x in dom(I1-I2); then
     (I1-I2).x = I1.x - I2.x by VALUED_1:13; then
     (I1-I2).x = integral(max+f,x,b) - I2.x by A6,A20,A7,A8,A18; then
A21: (I1-I2).x = integral(max+f,x,b) - integral(max-f,x,b)
       by A6,A20,A10,A11,A18;

A22:  -infty < x & x <= b by A20,A18,XXREAL_1:2; then
     ['x,b'] = [.x,b.] by INTEGRA5:def 3; then
     ['x,b'] c= ].-infty,b.] by A22,XXREAL_1:39; then
     ['x,b'] c= dom f by A1,A6; then
A23: ['x,b'] c= dom(max+f) & ['x,b'] c= dom(max-f) by RFUNCT_3:def 10,def 11;
     max+f is_integrable_on ['x,b'] & max+f|['x,b'] is bounded
   & max-f is_integrable_on ['x,b'] & max-f|['x,b'] is bounded
       by A22,A2,A3,INTEGR10:def 6;
     hence (I1-I2).x = integral(f,x,b) by A21,A22,A23,A13,INTEGRA6:12;
    end;

A24:for r be Real ex g be Real st g<r & g in dom(I1-I2)
      by A18,A6,A7,A9,LIMFUNC1:45;
    hence f is_-infty_ext_Riemann_integrable_on b
      by A6,A14,A18,A19,A9,A12,LIMFUNC1:92,INTEGR10:def 6;

A25:I1-I2 is convergent_in-infty
  & lim_in-infty(I1-I2) = lim_in-infty I1 - lim_in-infty I2
      by A9,A12,A24,LIMFUNC1:92; then
A26:f is_-infty_improper_integrable_on b
      by A6,A14,A18,A19,INTEGR10:def 6,INTEGR25:20;

A27:lim_in-infty I1 = improper_integral_-infty(max+f,b) &
    lim_in-infty I2 = improper_integral_-infty(max-f,b)
      by A4,A5,A7,A8,A9,A10,A11,A12,INTEGR25:def 3; then
A28: -lim_in-infty I2 = -improper_integral_-infty(max-f,b)
      by XXREAL_3:def 3;

    improper_integral_-infty(max+f,b)
     - improper_integral_-infty(max-f,b)
     = improper_integral_-infty(max+f,b)
     + - improper_integral_-infty(max-f,b) by XXREAL_3:def 4
     .= lim_in-infty I1 + -lim_in-infty I2 by A27,A28,XXREAL_3:def 2;
    hence improper_integral_-infty(f,b)
      = improper_integral_-infty(max+f,b)
      - improper_integral_-infty(max-f,b) by A26,A6,A18,A19,A25,INTEGR25:def 3;
end;

theorem Th74:
for f be PartFunc of REAL,REAL, a be Real st right_closed_halfline a c= dom f &
 max+f is_+infty_ext_Riemann_integrable_on a &
 max-f is_+infty_ext_Riemann_integrable_on a
 holds f is_+infty_ext_Riemann_integrable_on a &
     improper_integral_+infty(f,a)
    = improper_integral_+infty(max+f,a) - improper_integral_+infty(max-f,a)
proof
    let f be PartFunc of REAL,REAL, a be Real;
    assume that
A1:  right_closed_halfline a c= dom f and
A2:  max+f is_+infty_ext_Riemann_integrable_on a and
A3:  max-f is_+infty_ext_Riemann_integrable_on a;

A4: max+f is_+infty_improper_integrable_on a by A2,INTEGR25:21;
A5: max-f is_+infty_improper_integrable_on a by A3,INTEGR25:21;

A6: right_closed_halfline a = [.a,+infty.[ by LIMFUNC1:def 2;

    consider I1 be PartFunc of REAL,REAL such that
A7:  dom I1 = right_closed_halfline a and
A8:  for x be Real st x in dom I1 holds I1.x = integral(max+f,a,x) and
A9:  I1 is convergent_in+infty by A2,INTEGR10:def 5;

    consider I2 be PartFunc of REAL,REAL such that
A10:  dom I2 = right_closed_halfline a and
A11:  for x be Real st x in dom I2 holds I2.x = integral(max-f,a,x) and
A12:  I2 is convergent_in+infty by A3,INTEGR10:def 5;

A13:f = max+f - max-f by RFUNCT_3:34;

A14:for d be Real st a <= d holds
     f is_integrable_on ['a,d'] & f|['a,d'] is bounded
    proof
     let d be Real;
     assume A15: a <= d; then
A16:  max+f is_integrable_on ['a,d'] & max+f|['a,d'] is bounded
   & max-f is_integrable_on ['a,d'] & max-f|['a,d'] is bounded
       by A2,A3,INTEGR10:def 5;
A17:  d in REAL by XREAL_0:def 1;
     ['a,d'] = [.a,d.] by A15,INTEGRA5:def 3; then
     ['a,d'] c= [.a,+infty.[ by A17,XXREAL_0:9,XXREAL_1:43; then
     ['a,d'] c= dom f by A1,A6; then
     ['a,d'] c= dom(max+f) & ['a,d'] c= dom(max-f) by RFUNCT_3:def 10,def 11;
     hence f is_integrable_on ['a,d'] by A13,A16,INTEGRA6:11;
     f|(['a,d'] /\ ['a,d']) is bounded by A13,A16,RFUNCT_1:84;
     hence f|['a,d'] is bounded;
    end;

A18:dom(I1-I2) = [.a,+infty.[ /\ [.a,+infty.[ by A6,A7,A10,VALUED_1:12;
A19:for x be Real st x in dom(I1-I2) holds (I1-I2).x = integral(f,a,x)
    proof
     let x be Real;
     assume
A20:  x in dom(I1-I2); then
     (I1-I2).x = I1.x - I2.x by VALUED_1:13; then
     (I1-I2).x = integral(max+f,a,x) - I2.x by A6,A20,A7,A8,A18; then
A21: (I1-I2).x = integral(max+f,a,x) - integral(max-f,a,x)
       by A6,A20,A10,A11,A18;

A22: a <= x & x < +infty by A20,A18,XXREAL_1:3; then
     ['a,x'] = [.a,x.] by INTEGRA5:def 3; then
     ['a,x'] c= [.a,+infty.[ by A22,XXREAL_1:43; then
     ['a,x'] c= dom f by A1,A6; then
A23: ['a,x'] c= dom(max+f) & ['a,x'] c= dom(max-f) by RFUNCT_3:def 10,def 11;
     max+f is_integrable_on ['a,x'] & max+f|['a,x'] is bounded
   & max-f is_integrable_on ['a,x'] & max-f|['a,x'] is bounded
       by A22,A2,A3,INTEGR10:def 5;
     hence (I1-I2).x = integral(f,a,x) by A21,A22,A23,A13,INTEGRA6:12;
    end;

A24:for r be Real ex g be Real st r<g & g in dom(I1-I2)
      by A18,A6,A7,A9,LIMFUNC1:44;
    hence f is_+infty_ext_Riemann_integrable_on a
      by A6,A14,A18,A19,A9,A12,LIMFUNC1:83,INTEGR10:def 5;

A25:I1-I2 is convergent_in+infty
  & lim_in+infty(I1-I2) = lim_in+infty I1 - lim_in+infty I2
      by A24,A9,A12,LIMFUNC1:83; then
A26:f is_+infty_improper_integrable_on a
      by A6,A14,A18,A19,INTEGR10:def 5,INTEGR25:21;

A27:lim_in+infty I1 = improper_integral_+infty(max+f,a) &
    lim_in+infty I2 = improper_integral_+infty(max-f,a)
      by A4,A5,A7,A8,A9,A10,A11,A12,INTEGR25:def 4; then
A28: -lim_in+infty I2 = -improper_integral_+infty(max-f,a)
      by XXREAL_3:def 3;

    improper_integral_+infty(max+f,a)
     - improper_integral_+infty(max-f,a)
     = improper_integral_+infty(max+f,a)
     + - improper_integral_+infty(max-f,a) by XXREAL_3:def 4
     .= lim_in+infty I1 + -lim_in+infty I2 by A27,A28,XXREAL_3:def 2;
    hence improper_integral_+infty(f,a)
      = improper_integral_+infty(max+f,a)
      - improper_integral_+infty(max-f,a) by A26,A6,A18,A19,A25,INTEGR25:def 4;
end;

begin :: Improper Integral of Absolutely Integrable Functions

theorem Th75:
for f be PartFunc of REAL,REAL, a,b be Real, A be non empty Subset of REAL
 st ].a,b.] c= dom f & A = ].a,b.] & f is_left_improper_integrable_on a,b
 & abs f is_left_ext_Riemann_integrable_on a,b & f|A is nonnegative
 holds f|A is_integrable_on L-Meas
     & left_improper_integral(f,a,b) = Integral(L-Meas,f|A)
proof
    let f be PartFunc of REAL,REAL, a,b be Real, A be non empty Subset of REAL;
    assume that
A1:  ].a,b.] c= dom f and
A2:  A = ].a,b.] and
A3:  f is_left_improper_integrable_on a,b and
A4:  abs f is_left_ext_Riemann_integrable_on a,b and
A5:  f|A is nonnegative;
    a < b by A2,XXREAL_1:26; then
    f is_left_ext_Riemann_integrable_on a,b by A1,A3,A4,Th58;
    hence f|A is_integrable_on L-Meas &
    left_improper_integral(f,a,b) = Integral(L-Meas,f|A) by A1,A2,A3,A5,Th43;
end;

theorem Th76:
for f be PartFunc of REAL,REAL, a,b be Real, A be non empty Subset of REAL
 st [.a,b.[ c= dom f & A = [.a,b.[ & f is_right_improper_integrable_on a,b
 & abs f is_right_ext_Riemann_integrable_on a,b & f|A is nonnegative
 holds f|A is_integrable_on L-Meas
     & right_improper_integral(f,a,b) = Integral(L-Meas,f|A)
proof
    let f be PartFunc of REAL,REAL, a,b be Real, A be non empty Subset of REAL;
    assume that
A1:  [.a,b.[ c= dom f and
A2:  A = [.a,b.[ and
A3:  f is_right_improper_integrable_on a,b and
A4:  abs f is_right_ext_Riemann_integrable_on a,b and
A5:  f|A is nonnegative;
    a < b by A2,XXREAL_1:27; then
    f is_right_ext_Riemann_integrable_on a,b by A1,A3,A4,Th57;
    hence f|A is_integrable_on L-Meas &
    right_improper_integral(f,a,b) = Integral(L-Meas,f|A) by A1,A2,A3,A5,Th41;
end;

theorem Th77:
for f be PartFunc of REAL,REAL, b be Real, A be non empty Subset of REAL
 st left_closed_halfline b c= dom f & A = left_closed_halfline b
  & f is_-infty_improper_integrable_on b
  & abs f is_-infty_ext_Riemann_integrable_on b & f is nonnegative
 holds f|A is_integrable_on L-Meas
     & improper_integral_-infty(f,b) = Integral(L-Meas,f|A)
proof
    let f be PartFunc of REAL,REAL, b be Real, A be non empty Subset of REAL;
    assume that
A1:  left_closed_halfline b c= dom f and
A2:  A = left_closed_halfline b and
A3:  f is_-infty_improper_integrable_on b and
A4:  abs f is_-infty_ext_Riemann_integrable_on b and
A5:  f is nonnegative;

    f is_-infty_ext_Riemann_integrable_on b by A1,A3,A4,Th60;
    hence f|A is_integrable_on L-Meas &
    improper_integral_-infty(f,b) = Integral(L-Meas,f|A) by A1,A2,A3,A5,Th47;
end;

theorem Th78:
for f be PartFunc of REAL,REAL, a be Real, A be non empty Subset of REAL
 st right_closed_halfline a c= dom f & A = right_closed_halfline a
  & f is_+infty_improper_integrable_on a
  & abs f is_+infty_ext_Riemann_integrable_on a & f is nonnegative
 holds f|A is_integrable_on L-Meas
     & improper_integral_+infty(f,a) = Integral(L-Meas,f|A)
proof
    let f be PartFunc of REAL,REAL, a be Real, A be non empty Subset of REAL;
    assume that
A1:  right_closed_halfline a c= dom f and
A2:  A = right_closed_halfline a and
A3:  f is_+infty_improper_integrable_on a and
A4:  abs f is_+infty_ext_Riemann_integrable_on a and
A5:  f is nonnegative;

    f is_+infty_ext_Riemann_integrable_on a by A1,A3,A4,Th61;
    hence f|A is_integrable_on L-Meas &
    improper_integral_+infty(f,a) = Integral(L-Meas,f|A) by A1,A2,A3,A5,Th49;
end;

theorem
for f be PartFunc of REAL,REAL, a,b be Real st a < b & [.a,b.[ c= dom f &
 f is_right_improper_integrable_on a,b &
 abs f is_right_ext_Riemann_integrable_on a,b holds
 max+f is_right_ext_Riemann_integrable_on a,b
proof
    let f be PartFunc of REAL,REAL, a,b be Real;
    assume that
A1:  a < b and
A2:  [.a,b.[ c= dom f and
A3:  f is_right_improper_integrable_on a,b and
A4:  abs f is_right_ext_Riemann_integrable_on a,b;
    f is_right_ext_Riemann_integrable_on a,b by A1,A2,A3,A4,Th57;
    hence thesis by A1,A2,A4,Th64;
end;

theorem Th80:
for f be PartFunc of REAL,REAL, a,b be Real, A be non empty Subset of REAL
 st [.a,b.[ c= dom f & A = [.a,b.[ & f is_right_improper_integrable_on a,b
 & abs f is_right_ext_Riemann_integrable_on a,b
 holds f|A is_integrable_on L-Meas
     & right_improper_integral(f,a,b) = Integral(L-Meas,f|A)
proof
    let f be PartFunc of REAL,REAL, a,b be Real, A be non empty Subset of REAL;
    assume that
A1:  [.a,b.[ c= dom f and
A2:  A = [.a,b.[ and
A3:  f is_right_improper_integrable_on a,b and
A4:  abs f is_right_ext_Riemann_integrable_on a,b;

A5: dom max+f = dom f by RFUNCT_3:def 10;

    a < b by A2,XXREAL_1:27; then
A6: f is_right_ext_Riemann_integrable_on a,b by A1,A3,A4,Th57; then
A7: max+f is_right_ext_Riemann_integrable_on a,b
      by A1,A2,A4,Th64,XXREAL_1:27; then
A8: max+f is_right_improper_integrable_on a,b by INTEGR24:33;

A9:abs(max+f) is_right_ext_Riemann_integrable_on a,b
      by A7,LPSPACE2:14,MESFUNC6:61;

A10:(max+f)|A is nonnegative by MESFUNC6:61,55; then
    (max+f)|A is_integrable_on L-Meas by A1,A5,A2,A8,A9,Th76; then
A11:max+(f|A) is_integrable_on L-Meas by MESFUNC6:66;

    max+(R_EAL(f|A)) = max+(f|A) by MESFUNC6:30; then
A12:max+(R_EAL(f|A)) = R_EAL(max+(f|A)) by MESFUNC5:def 7; then
A13:max+(R_EAL(f|A)) is_integrable_on L-Meas by A11,MESFUNC6:def 4;

A14:dom max-f = dom f by RFUNCT_3:def 11;

A15:max-f is_right_ext_Riemann_integrable_on a,b
      by A1,A2,A4,A6,Th68,XXREAL_1:27; then
A16:max-f is_right_improper_integrable_on a,b by INTEGR24:33;

A17:abs(max-f) is_right_ext_Riemann_integrable_on a,b
      by A15,LPSPACE2:14,MESFUNC6:61;

A18:(max-f)|A is nonnegative by MESFUNC6:61,55; then
    (max-f)|A is_integrable_on L-Meas by A1,A14,A2,A16,A17,Th76; then
A19:max-(f|A) is_integrable_on L-Meas by MESFUNC6:66;

    max-(R_EAL(f|A)) = max-(f|A) by MESFUNC6:30; then
A20:max-(R_EAL(f|A)) = R_EAL(max-(f|A)) by MESFUNC5:def 7; then
    max-(R_EAL(f|A)) is_integrable_on L-Meas by A19,MESFUNC6:def 4;
    hence f|A is_integrable_on L-Meas by A13,MESFUN13:18,MESFUNC6:def 4;

    reconsider A1=A as Element of L-Field by A2,MEASUR12:72,75;

    R_EAL(f|A) is_integrable_on L-Meas
       by A20,A13,A19,MESFUNC6:def 4,MESFUN13:18; then
    consider E be Element of L-Field such that
A21: E = dom(R_EAL(f|A)) & R_EAL(f|A) is E-measurable by MESFUNC5:def 17;

A22:right_improper_integral(f,a,b)
      = right_improper_integral(max+f,a,b) - right_improper_integral(max-f,a,b)
       by A1,A7,A15,Th72;
A23:right_improper_integral(max+f,a,b)
      = Integral(L-Meas,(max+f)|A) by A1,A5,A2,A8,A9,A10,Th76
     .= Integral(L-Meas,max+(f|A)) by MESFUNC6:66
     .= Integral(L-Meas,max+(R_EAL(f|A))) by A12,MESFUNC6:def 3;

    right_improper_integral(max-f,a,b)
      = Integral(L-Meas,(max-f)|A) by A1,A14,A2,A16,A17,A18,Th76
     .= Integral(L-Meas,max-(f|A)) by MESFUNC6:66
     .= Integral(L-Meas,max-(R_EAL(f|A))) by A20,MESFUNC6:def 3; then
    right_improper_integral(f,a,b) = Integral(L-Meas,R_EAL(f|A))
       by A21,A22,A23,MESFUN11:54;
    hence right_improper_integral(f,a,b) = Integral(L-Meas,f|A)
       by MESFUNC6:def 3;
end;

theorem Th81:
for f be PartFunc of REAL,REAL, a,b be Real, A be non empty Subset of REAL
 st ].a,b.] c= dom f & A = ].a,b.] & f is_left_improper_integrable_on a,b
 & abs f is_left_ext_Riemann_integrable_on a,b
 holds f|A is_integrable_on L-Meas
     & left_improper_integral(f,a,b) = Integral(L-Meas,f|A)
proof
    let f be PartFunc of REAL,REAL, a,b be Real, A be non empty Subset of REAL;
    assume that
A1:  ].a,b.] c= dom f and
A2:  A = ].a,b.] and
A3:  f is_left_improper_integrable_on a,b and
A4:  abs f is_left_ext_Riemann_integrable_on a,b;

A5:  dom max+f = dom f by RFUNCT_3:def 10;

A6:  a < b by A2,XXREAL_1:26; then
A7:  f is_left_ext_Riemann_integrable_on a,b by A1,A3,A4,Th58; then
A8:  max+f is_left_improper_integrable_on a,b
       by A1,A4,A6,Th63,INTEGR24:32;

A9:  max+f is_left_ext_Riemann_integrable_on a,b
       by A1,A4,A2,A7,Th63,XXREAL_1:26; then
A10: abs(max+f) is_left_ext_Riemann_integrable_on a,b
       by MESFUNC6:61,LPSPACE2:14;

A11: (max+f)|A is nonnegative by MESFUNC6:61,55; then
     (max+f)|A is_integrable_on L-Meas by A1,A5,A2,A8,A10,Th75; then
A12: max+(f|A) is_integrable_on L-Meas by MESFUNC6:66;

     max+(R_EAL(f|A)) = max+(f|A) by MESFUNC6:30; then
A13: max+(R_EAL(f|A)) = R_EAL(max+(f|A)) by MESFUNC5:def 7; then
A14: max+(R_EAL(f|A)) is_integrable_on L-Meas by A12,MESFUNC6:def 4;

A15: dom max-f = dom f by RFUNCT_3:def 11;

A16: max-f is_left_improper_integrable_on a,b
       by A1,A4,A6,A7,Th67,INTEGR24:32;

A17: max-f is_left_ext_Riemann_integrable_on a,b
      by A1,A4,A2,A7,Th67,XXREAL_1:26; then
A18: abs(max-f) is_left_ext_Riemann_integrable_on a,b
       by LPSPACE2:14,MESFUNC6:61;

A19: (max-f)|A is nonnegative by MESFUNC6:61,55; then
     (max-f)|A is_integrable_on L-Meas by A1,A15,A2,A16,A18,Th75; then
A20: max-(f|A) is_integrable_on L-Meas by MESFUNC6:66;

     max-(R_EAL(f|A)) = max-(f|A) by MESFUNC6:30; then
A21: max-(R_EAL(f|A)) = R_EAL(max-(f|A)) by MESFUNC5:def 7; then
     max-(R_EAL(f|A)) is_integrable_on L-Meas by A20,MESFUNC6:def 4;
     hence f|A is_integrable_on L-Meas by A14,MESFUN13:18,MESFUNC6:def 4;

     reconsider A1=A as Element of L-Field by A2,MEASUR12:72,MEASUR12:75;

     R_EAL(f|A) is_integrable_on L-Meas
       by A21,A14,A20,MESFUNC6:def 4,MESFUN13:18; then
     consider E be Element of L-Field such that
A22:   E = dom(R_EAL(f|A)) & R_EAL(f|A) is E-measurable by MESFUNC5:def 17;

A23:  left_improper_integral(f,a,b)
      = left_improper_integral(max+f,a,b) - left_improper_integral(max-f,a,b)
       by A1,A9,A17,Th71;
A24:  left_improper_integral(max+f,a,b)
      = Integral(L-Meas,(max+f)|A) by A1,A5,A2,A8,A10,A11,Th75
     .= Integral(L-Meas,max+(f|A)) by MESFUNC6:66
     .= Integral(L-Meas,max+(R_EAL(f|A))) by A13,MESFUNC6:def 3;

     left_improper_integral(max-f,a,b)
      = Integral(L-Meas,(max-f)|A) by A1,A15,A2,A16,A18,A19,Th75
     .= Integral(L-Meas,max-(f|A)) by MESFUNC6:66
     .= Integral(L-Meas,max-(R_EAL(f|A))) by A21,MESFUNC6:def 3; then
     left_improper_integral(f,a,b) = Integral(L-Meas,R_EAL(f|A))
       by A22,A23,A24,MESFUN11:54;
     hence left_improper_integral(f,a,b) = Integral(L-Meas,f|A)
       by MESFUNC6:def 3;
end;

theorem
for f be PartFunc of REAL,REAL, a,b be Real, A be non empty Subset of REAL
 st ].a,b.[ c= dom f & A = ].a,b.[ & f is_improper_integrable_on a,b
 & (ex c be Real st a < c < b & abs f is_left_ext_Riemann_integrable_on a,c
    & abs f is_right_ext_Riemann_integrable_on c,b)
 holds f|A is_integrable_on L-Meas
     & improper_integral(f,a,b) = Integral(L-Meas,f|A)
proof
    let f be PartFunc of REAL,REAL, a,b be Real, A be non empty Subset of REAL;
    assume that
A1:  ].a,b.[ c= dom f and
A2:  A = ].a,b.[ and
A3:  f is_improper_integrable_on a,b and
A4:  ex c be Real st a < c < b & abs f is_left_ext_Riemann_integrable_on a,c
      & abs f is_right_ext_Riemann_integrable_on c,b;

    consider c be Real such that
A5:  a < c < b and
A6:  abs f is_left_ext_Riemann_integrable_on a,c and
A7:  abs f is_right_ext_Riemann_integrable_on c,b by A4;

    reconsider AC = ].a,c.] as non empty Subset of REAL by A5,XXREAL_1:32;
    reconsider CB = [.c,b.[ as non empty Subset of REAL by A5,XXREAL_1:31;
    reconsider AC,CB as Element of L-Field by MEASUR10:5,MEASUR12:75;

A8: f is_left_improper_integrable_on a,c &
    f is_right_improper_integrable_on c,b &
    improper_integral(f,a,b)
     = left_improper_integral(f,a,c) + right_improper_integral(f,c,b)
       by A1,A3,A5,INTEGR24:48;

A9:AC \/ CB = A by A2,A5,XXREAL_1:172;

A10: AC c= ].a,b.[ & CB c= ].a,b.[ by A5,XXREAL_1:48,49; then
A11: AC c= dom f & CB c= dom f by A1; then
A12:f|AC is_integrable_on L-Meas
     & left_improper_integral(f,a,c) = Integral(L-Meas,f|AC) by A6,A8,Th81;

    f|CB is_integrable_on L-Meas
     & right_improper_integral(f,c,b) = Integral(L-Meas,f|CB)
       by A7,A8,A11,Th80; then
A13: f|(AC \/ CB) is_integrable_on L-Meas by A11,A12,Th53;
    hence f|A is_integrable_on L-Meas by A2,A5,XXREAL_1:172;

    set C = {c};
A14: C = [.c,c.] by XXREAL_1:17;

    reconsider C = {c} as Element of L-Field by Th28;
A15:L-Meas.C = c-c by A14,MESFUN14:5 .= 0;

A16:dom(f|AC) = AC by A11,RELAT_1:62; then
A17:dom(R_EAL(f|AC)) = AC by MESFUNC5:def 7;

    R_EAL(f|AC) is_integrable_on L-Meas by A11,A6,A8,Th81,MESFUNC6:def 4; then
    consider E be Element of L-Field such that
A18: E = dom(R_EAL(f|AC)) & R_EAL(f|AC) is E-measurable
      by MESFUNC5:def 17;

A19:AC\C = ].a,c.[ by A5,XXREAL_1:137;

    AC\C c= AC by XBOOLE_1:36; then
    AC\C c= A by A10,A2; then
A20:(f|A)|(AC\C) = f|(AC\C) & (f|AC)|(AC\C) = f|(AC\C) &
    (f|A)|CB = f|CB by A2,A5,XXREAL_1:48,XBOOLE_1:36,RELAT_1:74;

    Integral(L-Meas,(f|A)|A)
     = Integral(L-Meas,(f|A)|(AC\C \/ CB)) by A2,A5,A19,XXREAL_1:173
    .= Integral(L-Meas,(f|A)|(AC\C)) + Integral(L-Meas,(f|A)|CB)
       by A13,A9,A19,XXREAL_1:94,MESFUNC6:92
    .= Integral(L-Meas,f|AC) + Integral(L-Meas,f|CB)
       by A20,A18,A16,A15,A17,MESFUNC6:def 1,89;
    hence improper_integral(f,a,b) = Integral(L-Meas,f|A) by A8,A12,A7,A11,Th80
;
end;

theorem Th83:
for f be PartFunc of REAL,REAL, b be Real, A be non empty Subset of REAL
 st left_closed_halfline b c= dom f & A = left_closed_halfline b
  & f is_-infty_improper_integrable_on b
  & abs f is_-infty_ext_Riemann_integrable_on b
 holds f|A is_integrable_on L-Meas
     & improper_integral_-infty(f,b) = Integral(L-Meas,f|A)
proof
    let f be PartFunc of REAL,REAL, b be Real, A be non empty Subset of REAL;
    assume that
A1:  left_closed_halfline b c= dom f and
A2:  A = left_closed_halfline b and
A3:  f is_-infty_improper_integrable_on b and
A4:  abs f is_-infty_ext_Riemann_integrable_on b;

A5:  dom max+f = dom f by RFUNCT_3:def 10;

A6:  f is_-infty_ext_Riemann_integrable_on b by A1,A3,A4,Th60; then
A7:  max+f is_-infty_improper_integrable_on b by A1,A4,Th65,INTEGR25:20;

A8:  max+f is_-infty_ext_Riemann_integrable_on b by A6,A1,A4,Th65; then
A9: abs(max+f) is_-infty_ext_Riemann_integrable_on b
       by MESFUNC6:61,LPSPACE2:14;

A10: max+f is nonnegative by MESFUNC6:61; then
     (max+f)|A is_integrable_on L-Meas by A1,A5,A2,A7,A9,Th77; then
A11: max+(f|A) is_integrable_on L-Meas by MESFUNC6:66;

     max+(R_EAL(f|A)) = max+(f|A) by MESFUNC6:30; then
A12: max+(R_EAL(f|A)) = R_EAL(max+(f|A)) by MESFUNC5:def 7; then
A13: max+(R_EAL(f|A)) is_integrable_on L-Meas by A11,MESFUNC6:def 4;

A14: dom max-f = dom f by RFUNCT_3:def 11;

A15: max-f is_-infty_improper_integrable_on b by A1,A4,A6,Th69,INTEGR25:20;

A16: max-f is_-infty_ext_Riemann_integrable_on b by A1,A4,A6,Th69; then
A17: abs(max-f) is_-infty_ext_Riemann_integrable_on b
       by MESFUNC6:61,LPSPACE2:14;

A18: max-f is nonnegative by MESFUNC6:61; then
     (max-f)|A is_integrable_on L-Meas by A1,A14,A2,A15,A17,Th77; then
A19: max-(f|A) is_integrable_on L-Meas by MESFUNC6:66;

     max-(R_EAL(f|A)) = max-(f|A) by MESFUNC6:30; then
A20: max-(R_EAL(f|A)) = R_EAL(max-(f|A)) by MESFUNC5:def 7; then
A21: max-(R_EAL(f|A)) is_integrable_on L-Meas by A19,MESFUNC6:def 4;
     hence f|A is_integrable_on L-Meas by A13,MESFUN13:18,MESFUNC6:def 4;

     A = ].-infty,b.] by A2,LIMFUNC1:def 1; then
     reconsider A1=A as Element of L-Field by MEASUR12:72,75;

     R_EAL(f|A) is_integrable_on L-Meas
       by A21,A12,A11,MESFUNC6:def 4,MESFUN13:18; then
     consider E be Element of L-Field such that
A22:   E = dom(R_EAL(f|A)) & R_EAL(f|A) is E-measurable by MESFUNC5:def 17;

A23:  improper_integral_-infty(f,b)
      = improper_integral_-infty(max+f,b) - improper_integral_-infty(max-f,b)
       by A1,A8,A16,Th73;
A24:  improper_integral_-infty(max+f,b)
      = Integral(L-Meas,(max+f)|A) by A1,A5,A2,A7,A9,A10,Th77
     .= Integral(L-Meas,max+(f|A)) by MESFUNC6:66
     .= Integral(L-Meas,max+(R_EAL(f|A))) by A12,MESFUNC6:def 3;

     improper_integral_-infty(max-f,b)
      = Integral(L-Meas,(max-f)|A) by A1,A14,A2,A15,A17,A18,Th77
     .= Integral(L-Meas,max-(f|A)) by MESFUNC6:66
     .= Integral(L-Meas,max-(R_EAL(f|A))) by A20,MESFUNC6:def 3; then
     improper_integral_-infty(f,b) = Integral(L-Meas,R_EAL(f|A))
       by A22,A23,A24,MESFUN11:54;
     hence improper_integral_-infty(f,b) = Integral(L-Meas,f|A)
       by MESFUNC6:def 3;
end;

theorem Th84:
for f be PartFunc of REAL,REAL, a be Real, A be non empty Subset of REAL
 st right_closed_halfline a c= dom f & A = right_closed_halfline a
  & f is_+infty_improper_integrable_on a
  & abs f is_+infty_ext_Riemann_integrable_on a
 holds f|A is_integrable_on L-Meas
     & improper_integral_+infty(f,a) = Integral(L-Meas,f|A)
proof
    let f be PartFunc of REAL,REAL, a be Real, A be non empty Subset of REAL;
    assume that
A1:  right_closed_halfline a c= dom f and
A2:  A = right_closed_halfline a and
A3:  f is_+infty_improper_integrable_on a and
A4:  abs f is_+infty_ext_Riemann_integrable_on a;

A5:  dom max+f = dom f by RFUNCT_3:def 10;

A6:  f is_+infty_ext_Riemann_integrable_on a by A1,A3,A4,Th61; then
A7:  max+f is_+infty_ext_Riemann_integrable_on a by A1,A4,Th66;

A8:  max+f is_+infty_improper_integrable_on a by A1,A4,A6,Th66,INTEGR25:21;

A9: max+f is nonnegative by MESFUNC6:61;
A10: abs(max+f) is_+infty_ext_Riemann_integrable_on a
       by A7,MESFUNC6:61,LPSPACE2:14; then

     (max+f)|A is_integrable_on L-Meas by A1,A5,A2,A8,A9,Th78; then
A11: max+(f|A) is_integrable_on L-Meas by MESFUNC6:66;

     max+(R_EAL(f|A)) = max+(f|A) by MESFUNC6:30; then
A12: max+(R_EAL(f|A)) = R_EAL(max+(f|A)) by MESFUNC5:def 7; then
A13: max+(R_EAL(f|A)) is_integrable_on L-Meas by A11,MESFUNC6:def 4;

A14: dom max-f = dom f by RFUNCT_3:def 11;

A15: max-f is_+infty_ext_Riemann_integrable_on a by A1,A4,A6,Th70;

A16: max-f is_+infty_improper_integrable_on a by A1,A4,A6,Th70,INTEGR25:21;

A17: max-f is nonnegative by MESFUNC6:61;
A18: abs(max-f) is_+infty_ext_Riemann_integrable_on a
       by A15,MESFUNC6:61,LPSPACE2:14; then
     (max-f)|A is_integrable_on L-Meas by A1,A14,A2,A16,A17,Th78; then
A19: max-(f|A) is_integrable_on L-Meas by MESFUNC6:66;

     max-(R_EAL(f|A)) = max-(f|A) by MESFUNC6:30; then
A20: max-(R_EAL(f|A)) = R_EAL(max-(f|A)) by MESFUNC5:def 7; then
     max-(R_EAL(f|A)) is_integrable_on L-Meas by A19,MESFUNC6:def 4;
     hence f|A is_integrable_on L-Meas by A13,MESFUN13:18,MESFUNC6:def 4;

     A = [.a,+infty.[ by A2,LIMFUNC1:def 2; then
     reconsider A1=A as Element of L-Field by MEASUR12:72,75;

     R_EAL(f|A) is_integrable_on L-Meas
       by A20,A13,A19,MESFUNC6:def 4,MESFUN13:18; then
     consider E be Element of L-Field such that
A21:   E = dom(R_EAL(f|A)) & R_EAL(f|A) is E-measurable by MESFUNC5:def 17;

A22:  improper_integral_+infty(f,a)
      = improper_integral_+infty(max+f,a) - improper_integral_+infty(max-f,a)
       by A1,A7,A15,Th74;
A23:  improper_integral_+infty(max+f,a)
      = Integral(L-Meas,(max+f)|A) by A1,A5,A2,A8,A10,A9,Th78
     .= Integral(L-Meas,max+(f|A)) by MESFUNC6:66
     .= Integral(L-Meas,max+(R_EAL(f|A))) by A12,MESFUNC6:def 3;

     improper_integral_+infty(max-f,a)
      = Integral(L-Meas,(max-f)|A) by A1,A14,A2,A16,A18,A17,Th78
     .= Integral(L-Meas,max-(f|A)) by MESFUNC6:66
     .= Integral(L-Meas,max-(R_EAL(f|A))) by A20,MESFUNC6:def 3; then
     improper_integral_+infty(f,a) = Integral(L-Meas,R_EAL(f|A))
       by A21,A22,A23,MESFUN11:54;
     hence improper_integral_+infty(f,a) = Integral(L-Meas,f|A)
       by MESFUNC6:def 3;
end;

theorem
for f be PartFunc of REAL,REAL st dom f = REAL
  & f is_improper_integrable_on_REAL
  & abs f is infty_ext_Riemann_integrable
 holds f is_integrable_on L-Meas
     & improper_integral_on_REAL f = Integral(L-Meas,f)
proof
    let f be PartFunc of REAL,REAL;
    assume that
A1:  dom f = REAL and
A2:  f is_improper_integrable_on_REAL and
A3:  abs f is infty_ext_Riemann_integrable;

A4: abs f is_+infty_ext_Riemann_integrable_on 0 &
    abs f is_-infty_ext_Riemann_integrable_on 0 by A3,INTEGR10:def 9;

A5: f is_-infty_improper_integrable_on 0 &
    f is_+infty_improper_integrable_on 0 &
    improper_integral_on_REAL f
     = improper_integral_-infty(f,0) + improper_integral_+infty(f,0)
       by A1,A2,INTEGR25:36;

    ].-infty,0 .] is non empty & [. 0,+infty.[ is non empty
      by XXREAL_1:31,32; then
    reconsider L = left_closed_halfline 0,R = right_closed_halfline 0
      as non empty Subset of REAL by LIMFUNC1:def 1,def 2;

A6: L = ].-infty,0 .] & R = [.0,+infty.[ by LIMFUNC1:def 1,def 2; then
    L \/ R = REAL by XXREAL_1:224,415; then
A7: f|(L\/R) = f;

    f|L is_integrable_on L-Meas & f|R is_integrable_on L-Meas
      by A1,A4,A5,Th83,Th84;
    hence
A8:  f is_integrable_on L-Meas by A7,A1,Th53;

A9: improper_integral_-infty(f,0) = Integral(L-Meas,f|L) &
    improper_integral_+infty(f,0) = Integral(L-Meas,f|R)
     by A4,A5,A1,Th83,Th84;

    REAL = ].-infty,+infty.[ by XXREAL_1:224; then
    reconsider E = REAL as Element of L-Field by MEASUR10:5,MEASUR12:75;
    reconsider A1=L as Element of L-Field by A6,MEASUR10:5,MEASUR12:75;
    reconsider B1=R as Element of L-Field by A6,MEASUR10:5,MEASUR12:75;

A10:f is A1-measurable by A1,A2,Th38;

    set C = {0};
A11: C = [. 0,0 .] by XXREAL_1:17; then
    reconsider C = {0} as Element of L-Field by MEASUR10:5,MEASUR12:75;
A12: L-Meas.C = 0-0 by A11,MESFUN14:5 .= 0;

A13: dom(f|L) = L by A1,RELAT_1:62; then
    A1 = dom f /\ A1 by RELAT_1:61; then
A14: Integral(L-Meas,f|L)
     = Integral(L-Meas,(f|L)|(L\C)) by A12,A13,A10,MESFUNC6:76,89
    .= Integral(L-Meas,f|(L\C)) by XBOOLE_1:36,RELAT_1:74;

A15: A1\C = ].-infty,0 .[ by A6,XXREAL_1:137; then
    A1\C \/ B1 = ].-infty,+infty.[ by A6,XXREAL_1:173; then
    f = f|(A1\C \/ B1) by XXREAL_1:224; then
    Integral(L-Meas,f)
     = Integral(L-Meas,f|L) + Integral(L-Meas,f|R)
      by A14,A15,A8,A6,XXREAL_1:94,MESFUNC6:92;
    hence improper_integral_on_REAL f = Integral(L-Meas,f)
      by A9,A1,A2,INTEGR25:36;
end;