 reserve Omega for non empty set;
 reserve F for SigmaField of Omega;
 reserve phi for Real_Sequence;
 reserve jpi for pricefunction;
 reserve Prob for Probability of Special_SigmaField2;

theorem ThArbPrel:
  for r being Real st r>0 holds
  for jpi being pricefunction
  for d being Nat holds
    ex f being Real-Valued-Random-Variable of Special_SigmaField2 st
    f = {1,2,3,4} --> (jpi.d*(1+r)) &
    f is_integrable_on P2M(Prob) &
    f is_simple_func_in Special_SigmaField2
proof
 set F2=Special_SigmaField2;
 set Omega2={1,2,3,4};
 let r be Real;
 assume ASSJ: r>0;
 let jpi be pricefunction;
 let d be Nat;
 deffunc U(Element of Omega2)=In((jpi.d*(1+r)),REAL);
 consider f being Function of Omega2,REAL such that
  A1: for d being Element of Omega2 holds f.d=U(d) from FUNCT_2:sch 4;
 set g=(Omega2-->In((jpi.d*(1+r)),REAL));
b1: dom f=Omega2 & dom g=Omega2 by FUNCT_2:def 1;
AA: d in NAT by ORDINAL1:def 12;
   for x being object st x in dom f holds f.x=g.x
   proof
    let x be object; assume x in dom f; then
    reconsider x as Element of Omega2;
    f.x=In(jpi.d*(1+r),REAL) by A1;
    hence thesis;
   end; then
ff: f=g by b1; then
 reconsider f as Real-Valued-Random-Variable of F2 by FINANCE3:10,RANDOM_3:7;
zz:Omega2 in F2 & dom R_EAL f =Omega2 by PROB_1:5,FUNCT_2:def 1;
   for x be object st x in dom f holds (R_EAL f).x = In((jpi.d*(1+r)),REAL)
     by ff,FUNCOP_1:7; then
 Fin3: f is_simple_func_in F2 by MESFUNC6:2,zz,MESFUNC6:49;
    reconsider g = f as random_variable of F2,Borel_Sets
      by ff,FINANCE3:10;
    reconsider fREAL = R_EAL f as random_variable of F2,Borel_Sets
      by ff,FINANCE3:10;
   reconsider FOmega = {1,2,3,4} as Element of F2 by PROB_1:5;
Q1: FOmega = dom R_EAL f by FUNCT_2:def 1;
 f is_integrable_on P2M(Prob)
 proof
  R_EAL f is_integrable_on P2M(Prob)
  proof
   R_EAL f is FOmega-measurable &
   integral+ (P2M(Prob),(max+ (R_EAL f))) < +infty &
   integral+ (P2M(Prob),(max- (R_EAL f))) < +infty
   proof
    Q2: (R_EAL f) is FOmega-measurable
    proof
     for r being Real holds FOmega /\ (less_dom ((R_EAL f),r)) in F2
     proof
      let r be Real;
      set WX = {w where w is Element of Omega2: fREAL.w <r};
      W1: FOmega /\ (less_dom (fREAL,r)) = WX
      proof
        for x being object holds x in FOmega /\ (less_dom (fREAL,r)) iff
         x in WX
        proof
         let x be object;
         thus x in FOmega /\ (less_dom (fREAL,r)) implies x in WX
         proof
          assume x in FOmega /\ (less_dom (fREAL,r));
          then x in FOmega & x in less_dom(fREAL,r) by XBOOLE_0:def 4;
          then x in FOmega & (x in dom fREAL & fREAL.x < r) by MESFUNC1:def 11;
         hence thesis;
         end;
          assume x in WX;
          then x in less_dom(fREAL,r) by FINANCE1:9;
          then x in dom fREAL & fREAL.x<r by MESFUNC1:def 11;
          then x in FOmega & x in less_dom (fREAL,r) by MESFUNC1:def 11;
         hence thesis by XBOOLE_0:def 4;
        end;
       hence thesis by TARSKI:2;
      end;
      WX = g"].-infty,r.[ in F2
      proof
qq1:   for x being object holds x in WX iff x in g"].-infty,r.[
       proof
        let x be object;
        thus x in WX implies x in g"].-infty,r.[
        proof
         assume x in WX;
         then consider w being Element of Omega2 such that
          YA1: w=x & fREAL.w<r;
         reconsider x as Element of Omega2 by YA1;
         -infty<fREAL.x & fREAL.x<r by XXREAL_0:12,YA1;
         then g.x in ].-infty,r.[ & dom g=Omega2 by FUNCT_2:def 1,XXREAL_1:4;
        hence thesis by FUNCT_1:def 7;
        end;
         assume c0: x in g"].-infty,r.[;
         then C0: x in dom g & g.x in ].-infty,r.[ by FUNCT_1:def 7;
         reconsider x as Element of Omega2 by c0;
         -infty<g.x & g.x<r & g.x=fREAL.x by C0,XXREAL_1:4;
        hence thesis;
       end;
ZZ:    ].-infty,r.[ is Element of Borel_Sets &
        g is random_variable of F2,Borel_Sets by FINANCE1:3;
        g is (F2,Borel_Sets)-random_variable-like;
      hence thesis by qq1,TARSKI:2,ZZ;
      end;
     hence thesis by W1;
     end;
    hence thesis by MESFUNC1:def 16;
    end;
     set fREAL=R_EAL f;
     set maxfREAL=max+ fREAL;
U0:   dom maxfREAL = dom fREAL & dom fREAL=Omega2
       by MESFUNC2:def 2,FUNCT_2:def 1;
Fin30: maxfREAL is nonnegative
     proof
      for x being ExtReal holds x in rng maxfREAL implies 0. <= x
      proof
       let x be ExtReal;
       assume CASS0: x in rng maxfREAL;
       consider w being object such that
   W1: w in dom maxfREAL & maxfREAL.w=x by CASS0,FUNCT_1:def 3;
       thus thesis by W1,MESFUNC2:12;
       end;
      hence thesis by SUPINF_2:def 12,SUPINF_2:def 9;
     end;
    integral+ (P2M(Prob),(max+ (R_EAL f))) < +infty &
     integral+ (P2M(Prob),(max- (R_EAL f))) < +infty
    proof
    maxfREAL is_simple_func_in F2
    proof
      for x be object st x in dom maxfREAL holds
        maxfREAL.x = In((jpi.d*(1+r)),REAL)
      proof
       let x be object;
       assume x in dom maxfREAL;
       then reconsider x as Element of Omega2;
       per cases;
       suppose 0<=fREAL.x;
        then S2: max(fREAL.x,0)=fREAL.x by XXREAL_0:def 10;
        fREAL.x=In((jpi.d*(1+r)),REAL) by ff;
        hence thesis by U0,MESFUNC2:def 2,S2;
       end;
       suppose S1: 0>fREAL.x;
        0<1+r & 0<=jpi.d by AA,FINANCE1:def 2,ASSJ;
        hence thesis by S1,ff;
       end;
     end;
    hence thesis by MESFUNC6:2,U0;
    end;
    then Schritt1: integral+ (P2M(Prob),(max+ (fREAL)))=
     integral' (P2M(Prob),(max+ (fREAL))) by MESFUNC5:77,Fin30;
    reconsider myr = jpi.d*(1+r) as Element of REAL by XREAL_0:def 1;
     dom(max+ fREAL)=dom fREAL by MESFUNC2:def 2;
     then y1: dom(max+ fREAL)=[#]Special_SigmaField2 by FUNCT_2:def 1;
y2:  0<1+r & 0<=jpi.d by AA,FINANCE1:def 2,ASSJ;
zz1: for x be object st x in dom (max+ fREAL) holds (max+ fREAL).x = myr
     proof
      let x be object;
      assume S: x in dom(max+ fREAL);
      then reconsider x as Element of Omega2;
 YY1: (max+ fREAL).x= max(fREAL.x,0) by MESFUNC2:def 2,S;
      per cases;
      suppose fREAL.x>=0;
        then (max+ fREAL).x=fREAL.x by YY1,XXREAL_0:def 10;
        hence thesis by A1;
      end;
      suppose fREAL.x<0;
        hence thesis by A1,y2;
      end;
     end;
    (P2M(Prob)).(dom max+ fREAL)=1
    proof
     dom (max+ fREAL)= dom fREAL by MESFUNC2:def 2;
     then dom(max+ fREAL)=([#]Special_SigmaField2) by FUNCT_2:def 1;
     hence thesis by PROB_1:30;
    end; then
fin1: integral+ (P2M(Prob),(max+ fREAL))= myr*1
      by zz1,Schritt1,MESFUNC5:104,y2,y1;
     set maxmfREAL=max- fREAL;
YY:  dom maxmfREAL = dom fREAL & dom fREAL=Omega2
       by MESFUNC2:def 3,FUNCT_2:def 1;
JFin1: maxmfREAL is nonnegative
      proof
       for x being ExtReal holds x in rng maxmfREAL implies 0. <= x
       proof
         let x be ExtReal;
         assume x in rng maxmfREAL; then
         ex w being object st
          w in dom maxmfREAL & maxmfREAL.w=x by FUNCT_1:def 3;
         hence thesis by MESFUNC2:13;
         end;
        hence thesis by SUPINF_2:def 12,SUPINF_2:def 9;
      end;
U1:  dom maxmfREAL in F2 by YY;
    integral+ (P2M(Prob),(max- fREAL)) < +infty
    proof
FFF: for x be object st x in dom maxmfREAL holds maxmfREAL.x = 0
     proof
     let x be object;
     assume x in dom maxmfREAL;
     then reconsider x as Element of Omega2;
QQQ1: -fREAL.x=-jpi.d*(1+r) by A1;
     set mfREAL = -fREAL.x;
     0<(1+r) & 0<=jpi.d by AA,FINANCE1:def 2,ASSJ; then
QQQ3: max(-(fREAL.x),0)=0 by XXREAL_0:def 10,QQQ1;
      dom (max- fREAL)=dom fREAL & dom fREAL=Omega2
        by MESFUNC2:def 3,FUNCT_2:def 1;
      hence thesis by QQQ3,MESFUNC2:def 3;
     end; then
     Schritt1: integral+ (P2M(Prob),(max- (fREAL)))=
     integral' (P2M(Prob),(max- (fREAL))) by MESFUNC5:77,JFin1,MESFUNC6:2,U1;
aq2: dom maxmfREAL = dom fREAL & dom fREAL=Omega2
       by MESFUNC2:def 3,FUNCT_2:def 1;
     integral+ (P2M(Prob),(max- fREAL))=
     0 * (P2M(Prob)). (dom (max- fREAL))
       by Schritt1,MESFUNC5:104,aq2,FFF;
    hence thesis;
    end;
    hence thesis by fin1,XXREAL_0:9;
    end;
   hence thesis by Q2;
   end;
  hence thesis by Q1;
  end;
 hence thesis;
 end;
hence thesis by ff,Fin3;
end;
