
theorem Th43:
  for a being Element of NAT, X being included_in_Seg set,
  F being FinSequence of SetPrimes, p being Prime st
  X c= SetPrimes & F = Sgm X &
  a = Product F holds
  (p in rng F implies p |-count a = 1) &
  (not p in rng F implies p |-count a = 0)
proof
  let a be Element of NAT, X be included_in_Seg set,
  F be FinSequence of SetPrimes,
  p be Prime;
  defpred P[Nat] means for a being Element of NAT, X being included_in_Seg set,
  F being FinSequence of SetPrimes, p being Prime st X c= SetPrimes &
F = Sgm X & a = Product F & len F = $1 holds (p in rng F implies p |-count a =
  1) & (not( p in rng F) implies p |-count a = 0);
  now
    let F be FinSequence of SetPrimes;
    rng F c= REAL;
    hence F is FinSequence of REAL by FINSEQ_1:def 4;
  end;
  then reconsider F as FinSequence of REAL;
A1: ex n being Element of NAT st n = len F;
A2: for n being Nat st P[n] holds P[n+1]
  proof
    let n be Nat;
    assume
A3: P[n];
    for a being Element of NAT, X being included_in_Seg set,
    F being FinSequence of
    SetPrimes, p being Prime st X c= SetPrimes & F = Sgm X & a =
Product F & len F = n+1 holds (p in rng F implies p |-count a = 1) & (not p in
    rng F implies p |-count a = 0)
    proof
      let a be Element of NAT, X be included_in_Seg set,
      F be FinSequence of SetPrimes, p be Prime;
      assume that
A4:   X c= SetPrimes and
A6:   F = Sgm X and
A7:   a = Product F;
      set x = F.(n+1);
      assume
A8:   len F = n+1;
      then
A9:   Seg (n+1) = dom F by FINSEQ_1:def 3;
      then n+1 in dom F by FINSEQ_1:3;
      then
A10:  x in rng F by FUNCT_1:def 3;
      rng F c= SetPrimes by FINSEQ_1:def 4;
      then reconsider x as Prime by A10,NEWTON:def 6;
      set X1 = X \ {x};
A11:  X1 c= X by XBOOLE_1:36;
A13:  rng F = X by A6,FINSEQ_1:def 14;
A15:  for m1,n1 being Nat st m1 in X1 & n1 in {x} holds m1 < n1
      proof
        set n9=n+1;
        let m1,n1 be Nat;
        assume that
A16:    m1 in X1 and
A17:    n1 in {x};
        set l=(F").m1;
A18:    F is one-to-one by A6,FINSEQ_3:92;
        m1 in rng F by A11,A13,A16;
        then m1 in dom (F") by A18,FUNCT_1:33;
        then l in rng (F") by FUNCT_1:def 3;
        then
A19:    l in Seg (n+1) by A9,A18,FUNCT_1:33;
        then reconsider l as Element of NAT;
A20:    l <= n+1 by A19,FINSEQ_1:1;
A21:    m1=F.l by A11,A13,A16,A18,FUNCT_1:35;
        then not n9=l by A16,ZFMISC_1:56;
        then
A22:    l < n9 by A20,XXREAL_0:1;
A23:    n1=F.n9 by A17,TARSKI:def 1;
        1<= l by A19,FINSEQ_1:1;
        hence thesis by A6,A8,A21,A23,A22,FINSEQ_1:def 14;
      end;
      set F2 = Sgm {x};
      set F1 = Sgm X1;
      reconsider F1 as FinSequence of NAT;
      set a1 = Product F1;
A24:  F2 = <*x*> by FINSEQ_3:44;
      then
A25:  rng F2 = {x} by FINSEQ_1:39;
A26:  X1 \/ {x} = X \/ {x} by XBOOLE_1:39
        .= X by A10,A13,ZFMISC_1:40;
      then
A27:  F = F1 ^ F2 by A6,A15,FINSEQ_3:42;
      then rng F c= SetPrimes & rng F1 c= rng F by FINSEQ_1:29,def 4;
      then
A28:  rng F1 c= SetPrimes;
      len F = len F1 + len F2 by A27,FINSEQ_1:22;
      then
A29:  n+1=len F1 + 1 by A8,A24,FINSEQ_1:39;
      reconsider F1 as FinSequence of SetPrimes by A28,FINSEQ_1:def 4;
A30:   F1 is FinSequence of REAL by FINSEQ_2:24,NUMBERS:19;
      now
        let k be Element of NAT;
        assume k in dom F1;
        then F1.k in rng F1 by FUNCT_1:def 3;
        then F1.k is Prime by A28,NEWTON:def 6;
        hence F1.k>0;
      end;
      then
A31:  a1<>0 by Th41,A30;
      Product F = Product (F1^F2) by A6,A15,A26,FINSEQ_3:42
        .= Product (F1^<*x*>) by FINSEQ_3:44
        .= Product F1 * x by RVSUM_1:96;
      then
A32:  p |-count a = (p |-count a1) + (p |-count x) by A7,A31,NAT_3:28;
A33:  X1 c= SetPrimes by A4,A11;
A34:  rng F1 = X \ {x} by FINSEQ_1:def 14;
A35:  now
        assume p in rng F;
        then p in (rng F1 \/ rng F2) by A27,FINSEQ_1:31;
        then
A36:    p in rng F1 or p in {x} by A25,XBOOLE_0:def 3;
A37:    p>1 by INT_2:def 4;
        per cases by A36,TARSKI:def 1;
        suppose
A38:      p in rng F1;
          then not p in {x} by A34,XBOOLE_0:def 5;
          then p<>x by TARSKI:def 1;
          then p |-count x = 0 by A37,NAT_3:24;
          hence p |-count a=1 by A3,A33,A29,A32,A38;
        end;
        suppose
A39:      p=x;
          then p in {x} by TARSKI:def 1;
          then not p in rng F1 by A34,XBOOLE_0:def 5;
          then p |-count a1 = 0 by A3,A33,A29;
          hence p |-count a=1 by A32,A37,A39,NAT_3:22;
        end;
      end;
      now
        assume not p in rng F;
        then
A40:    not p in (rng F1 \/ rng F2) by A27,FINSEQ_1:31;
        then not p in {x} by A25,XBOOLE_0:def 3;
        then
A41:    p<>x by TARSKI:def 1;
        not p in rng F1 by A40,XBOOLE_0:def 3;
        then
A42:    p |-count a1 = 0 by A3,A33,A29;
        p<>1 by INT_2:def 4;
        hence p |-count a=0 by A32,A42,A41,NAT_3:24;
      end;
      hence thesis by A35;
    end;
    hence thesis;
  end;
A43: P[0]
  proof
    let a be Element of NAT, X be included_in_Seg set,
    F be FinSequence of SetPrimes, p be Prime;
    assume that
    X c= SetPrimes and
    F = Sgm X and
A44: a = Product F and
A45: len F = 0;
A46: F=<*>REAL by A45;
    assume
A47: not(p in rng F implies p |-count a = 1) or not(not p in rng F
    implies p |-count a = 0);
    per cases by A47;
    suppose
      not(p in rng F implies p |-count a = 1);
      hence contradiction by A46;
    end;
    suppose
A48:  not(not p in rng F implies p |-count a = 0);
      F = <*>SetPrimes by A45;
      then a=1 & p<>1 by A44,INT_2:def 4,RVSUM_1:94;
      hence contradiction by A48,NAT_3:21;
    end;
  end;
  for n being Nat holds P[n] from NAT_1:sch 2(A43,A2);
  hence thesis by A1;
end;
