
theorem Th38:
  for S be non empty finite set,
  X be non empty Subset of S,
  D be EqSampleSpaces of S,
  s1,s2 be Element of D,
  t1,t2 be FinSequence of S,
  SD1 be Subset of dom s1,
  SD2 be Subset of dom s2 st
  SD1 = s1"X &t1 = extract(s1,SD1) &
  SD2 = s2"X &t2 = extract(s2,SD2) holds
  t1,t2 -are_prob_equivalent
  proof
    let S be non empty finite set,
    X be non empty Subset of S,
    D be EqSampleSpaces of S,
    s1,s2 be Element of D,
    t1,t2 be FinSequence of S,
    SD1 be Subset of dom s1,
    SD2 be Subset of dom s2;
    assume A1:
    SD1 = s1"X &t1 = extract(s1,SD1) &
    SD2 = s2"X &t2 = extract(s2,SD2);
    then SD1=trueEVENT((MembershipDecision(X))*s1) by Th37;
    then A2:Prob( MembershipDecision(X),s1)
    =(len t1)/(len s1) by Th11,A1;
    SD2=trueEVENT((MembershipDecision(X))*s2) by A1,Th37;
    then A3:Prob( MembershipDecision(X),s2)
    =(len t2)/(len s2) by Th11,A1;
    A4: t1={} implies t2={} by A3,A2,Th17;
    A5: for n,x be set st n in SD1 & not x in X holds
    not s1.n in {x}
    proof
      let n,x be set;
      assume A6: n in SD1 & not x in X;
      assume s1.n in {x};
      then not s1.n in X by A6,TARSKI:def 1;
      hence contradiction by A1,A6,FUNCT_1:def 7;
    end;
    A7:for n,x be set st n in SD2 & not x in X holds not s2.n in {x}
    proof
      let n,x be set;
      assume A8: n in SD2 & not x in X;
      assume s2.n in {x};then
      not s2.n in X by A8,TARSKI:def 1;
      hence contradiction by A1,A8,FUNCT_1:def 7;
    end;
    set c = (len t1)/(len s1);
    A9: c = (len t2)/(len s2) by A3,A2,Th17;
    for x be set holds FDprobability (x,t1)=FDprobability (x,t2)
    proof
      let x be set;
      per cases;
        suppose A10: t1 <> {};
          per cases;
            suppose A11:x in X;
              FDprobability (x,s1)=FDprobability (x,s2) by DIST_1:def 4,Th4
              .= frequency(x,s2) / (len s2);then
              frequency(x,t1) / (len s1)
              = frequency(x,s2) / (len s2) by Th35,A1,A11;then
              frequency(x,t1) / (len s1)
              = frequency(x,t2) / (len s2) by Th35,A1,A11;then
              (len t1)* FDprobability (x,t1)/(len s1)
              =frequency(x,t2) / (len s2) by DIST_1:4;then
              (len t1)* FDprobability (x,t1)/(len s1)
              =(len t2)* FDprobability (x,t2)/(len s2) by DIST_1:4;then
              FDprobability (x,t1)*((len t1)/(len s1))
              =FDprobability (x,t2)*(len t2)/(len s2) by XCMPLX_1:74;
              then
              FDprobability (x,t1)*c
              =FDprobability (x,t2)*c by A9,XCMPLX_1:74;
              hence thesis by A10,XCMPLX_1:5;
            end;
            suppose A12: not x in X;
              not ex i be object st i in t1"{x}
              proof
                let i be object;
                assume A13:i in t1"{x};then
                A14:i in dom t1 & t1.i in {x} by FUNCT_1:def 7;
                len t1 = card SD1 by A1,Th11;then
                A15:dom t1 = Seg (card SD1) by FINSEQ_1:def 3;
                reconsider i as Nat by A13;
                A16:rng canFS(SD1) c= SD1 by FINSEQ_1:def 4;
                set NE = (canFS(SD1)).i;
                len canFS(SD1) = card SD1 by FINSEQ_1:93;
                then i in dom canFS(SD1) by A14,A15,FINSEQ_1:def 3;then
                A17:NE in rng canFS(SD1) by FUNCT_1:3;
                t1.i= s1.NE by A1,A14,Th11;
                hence contradiction by A14,A17,A16,A5,A12;
              end;
              then Coim(t1,x) is empty by XBOOLE_0:def 1;
              then A18: FDprobability (x,t1) = 0;
              not ex i be object st i in t2"{x}
              proof
                let i be object;
                assume A19:i in t2"{x};then
                A20:i in dom t2 & t2.i in {x} by FUNCT_1:def 7;
                len t2 = card SD2 by A1,Th11;then
                A21:dom t2 = Seg (card SD2) by FINSEQ_1:def 3;
                reconsider i as Nat by A19;
                A22:rng canFS(SD2) c= SD2 by FINSEQ_1:def 4;
                set NE = (canFS(SD2)).i;
                len canFS(SD2) = card SD2 by FINSEQ_1:93;
                then i in dom canFS(SD2) by A20,A21,FINSEQ_1:def 3;then
                A23:NE in rng canFS(SD2) by FUNCT_1:3;
                t2.i= s2.NE by A1,A20,Th11;
                hence contradiction by A20,A23,A22,A7,A12;
              end;
              then Coim(t2,x) is empty by XBOOLE_0:def 1;
              hence thesis by A18;
            end;
        end;
        suppose t1 ={};
          hence thesis by A4;
        end;
    end;
    hence thesis;
  end;
