reserve a, b, n for Nat,
  r for Real,
  f for FinSequence of REAL;
reserve p for Prime;
reserve n, m for non zero Nat;

theorem
  Product ppf n = n
proof
  defpred P[Nat] means for n being non zero Nat st
  support ppf n c= Seg $1 holds Product ppf n = n;
A1: support ppf n = support pfexp n by Def9;
A2: P[ 0 ]
  proof
    let n be non zero Nat;
A3: {} c= support ppf n;
    assume support ppf n c= Seg 0;
    then
A4: support ppf n = {} by A3;
A5: now
      reconsider k = n as Nat;
      assume n <> 1;
      then k > 1 by NAT_1:53;
      then k >=1+1 by NAT_1:13;
      then ex p being Element of NAT st p is prime & p divides k by INT_2:31;
      then support pfexp n is non empty by Th37;
      hence contradiction by A4,Def9;
    end;
    ppf n = EmptyBag SetPrimes by A4,PRE_POLY:81;
    hence thesis by A5,Th20;
  end;
A6: for k being Nat st P[k] holds P[k+1]
  proof
    let k be Nat;
    assume
A7: P[k];
    let n be non zero Nat such that
A8: support ppf n c= Seg (k+1);
A9: support ppf n = support pfexp n by Def9;
    per cases;
    suppose
A10:  not support ppf n c= Seg k;
      set p = k+1;
      set e = p |-count n;
      set s = p |^ e;
A11:  now
        assume
A12:    not k+1 in support ppf n;
        support ppf n c= Seg k
        proof
          let x be object;
          assume
A13:      x in support ppf n;
          then reconsider m = x as Nat;
          m <= k+1 by A8,A13,FINSEQ_1:1;
          then m < k+1 by A12,A13,XXREAL_0:1;
          then
A14:      m <= k by NAT_1:13;
          x is Prime by A9,A13,Th34;
          then 1 <= m by INT_2:def 4;
          hence thesis by A14;
        end;
        hence contradiction by A10;
      end;
      then
A15:  p is Prime by A9,Th34;
      then
A16:  p > 1 by INT_2:def 4;
      then s divides n by Def7;
      then consider t being Nat such that
A17:  n = s * t;
      reconsider s, t as non zero Nat by A17;
A18:  dom ppf s = SetPrimes by PARTFUN1:def 2;
      (pfexp n).p = e by A15,Def8;
      then
A19:  e <> 0 by A9,A11,PRE_POLY:def 7;
      reconsider s1 = s, t1 = t as non zero Nat;
A20:  support ppf t = support pfexp t by Def9;
A21:  support ppf t c= Seg k
      proof
        set f = p |-count t;
        let x be object;
        assume
A22:    x in support ppf t;
        then reconsider m = x as Nat;
A23:    x in support pfexp t by A22,Def9;
A24:    now
          assume
A25:      m = p;
          (pfexp t).p = f by A15,Def8;
          then f <> 0 by A23,A25,PRE_POLY:def 7;
          then f >= 0+1 by NAT_1:13;
          then consider g being Nat such that
A26:      f = 1+g by NAT_1:10;
          p |^ f divides t by A16,Def7;
          then consider u being Nat such that
A27:      t = (p |^ f)*u;
          n = s * (((p |^ g)*p)*u) by A17,A26,A27,NEWTON:6
            .= s*p *((p |^ g)*u)
            .= (p |^ (e+1))*((p |^ g)*u) by NEWTON:6;
          then p |^ (e+1) divides n;
          hence contradiction by A16,Def7;
        end;
        support ppf t c= support ppf n by A9,A17,A20,Th45;
        then m in support ppf n by A22;
        then m <= k+1 by A8,FINSEQ_1:1;
        then m < p by A24,XXREAL_0:1;
        then
A28:    m <= k by NAT_1:13;
        x is Prime by A23,Th34;
        then 1 <= m by INT_2:def 4;
        hence thesis by A28;
      end;
      s1,t1 are_coprime
      proof
        set u = s1 gcd t1;
A29:    u divides t1 by NAT_D:def 5;
        u <> 0 by INT_2:5;
        then
A30:    0+1 <= u by NAT_1:13;
        assume s1 gcd t1 <> 1;
        then u > 1 by A30,XXREAL_0:1;
        then u >= 1+1 by NAT_1:13;
        then consider r being Element of NAT such that
A31:    r is prime and
A32:    r divides u by INT_2:31;
        u divides s1 by NAT_D:def 5;
        then r divides s1 by A32,NAT_D:4;
        then r divides p by A31,Th5;
        then r = 1 or r = p by A15,INT_2:def 4;
        then p divides t1 by A31,A32,A29,NAT_D:4;
        then p in support pfexp t by A15,Th37;
        then k+1 <= k by A20,A21,FINSEQ_1:1;
        hence contradiction by NAT_1:13;
      end;
      then
A33:  ppf n = ppf s + ppf t by A17,Th58;
      consider f being FinSequence of COMPLEX such that
A34:  Product ppf s = Product f and
A35:  f = (ppf s)*canFS(support ppf s) by Def5;
      support ppf s = support pfexp s by Def9;
      then
A36:  support ppf s = {p} by A15,A19,Th42;
      then f = (ppf s)*<*p*> by A35,FINSEQ_1:94
        .= <* (ppf s).p *> by A11,A18,FINSEQ_2:34;
      then
A37:  Product ppf s = (ppf s).p by A34
        .= s by A15,A19,Th59;
      now
        assume (support ppf s) /\ (support ppf t) <> {};
        then consider x being object such that
A38:    x in (support ppf s) /\ support ppf t by XBOOLE_0:def 1;
        x in support ppf s by A38,XBOOLE_0:def 4;
        then
A39:    x = p by A36,TARSKI:def 1;
        x in support ppf t by A38,XBOOLE_0:def 4;
        then p <= k by A21,A39,FINSEQ_1:1;
        hence contradiction by NAT_1:13;
      end;
      then
A40:  support ppf s misses support ppf t;
      Product ppf t = t by A7,A21;
      hence thesis by A17,A40,A33,A37,Th19;
    end;
    suppose
      support ppf n c= Seg k;
      hence thesis by A7;
    end;
  end;
A41: for k being Nat holds P[k] from NAT_1:sch 2(A2,A6);
  per cases;
  suppose
    support ppf n is empty;
    hence thesis by A2;
  end;
  suppose
    support ppf n is non empty;
    then reconsider S = support ppf n as finite non empty Subset of NAT
    by XBOOLE_1:1;
A42: max S is Nat by TARSKI:1;
    support ppf n c= Seg max S
    proof
      let x be object;
      assume
A43:  x in support ppf n;
      then reconsider m = x as Nat;
      x is Prime by A1,A43,Th34;
      then
A44:  1 <= m by INT_2:def 4;
      m <= max S by A43,XXREAL_2:def 8;
      hence thesis by A44;
    end;
    hence thesis by A42,A41;
  end;
end;
