reserve a,b,d,n,k,i,j,x,s for Nat;

theorem Th22:
  for n being non zero Nat holds
    rng pfexp n c= {0,1} & card support (pfexp n) = 1
  iff n is prime
proof
  let n be non zero Nat;
  hereby assume
A1:   rng pfexp n c= {0,1} & card support (pfexp n) = 1;
    then consider p be object such that
A2:   support (pfexp n) = {p} by CARD_2:42;
    p in {p} by TARSKI:def 1;
    then reconsider p as Prime by A2,NAT_3:34;
A3:   p in support (pfexp n) c= dom pfexp n by A2,TARSKI:def 1,PRE_POLY:37;
    then A4:(pfexp n).p in rng pfexp n by FUNCT_1:def 3;
    (pfexp n).p<>0 by A3,PRE_POLY:def 7;
    then
A5:   (pfexp n).p=1 by A1,A4,TARSKI:def 2;
    n = p |^ 1 by A5,A2,Th21;
    hence n is prime;
  end;
  assume
A6:  n is prime;
  n=n|^1;
  then
A7:  support pfexp (n) = {n} by A6,NAT_3:42;
  thus rng pfexp n c= {0,1}
  proof
    let y be object such that
A8:   y in rng pfexp n & not y in {0,1};
    consider x be object such that
A9:   x in dom pfexp n & (pfexp n).x=y by A8,FUNCT_1:def 3;
    y<>0 & y<>1 by A8,TARSKI:def 2;
    then x in support pfexp n by A9,PRE_POLY:def 7;
    then x=n by A7,TARSKI:def 1;
    then (pfexp n).x = 1 by A6,NAT_3:41;
    hence thesis by A8,A9,TARSKI:def 2;
  end;
  thus card support (pfexp n) = 1 by A7,CARD_1:30;
end;
