reserve x, y for set;

theorem Th16:
  for s, t being finite set st card s <= card t
  holds card (not-one-to-one (s, t)) =
       (card t |^ card s) - ((card t)! / ((card t -' card s)!))
  proof
    let s, t be finite set such that A1: card s <= card t;
    defpred P[Function] means $1 is one-to-one;
    set onetoone = {f where f is Function of s, t : f is one-to-one};
A2: t = {} implies s = {}
    by A1;
    onetoone c= Funcs(s, t)
    proof
      let x be object;
      assume x in onetoone;
      then ex f be Function of s, t st x = f & f is one-to-one;
      hence thesis by A2,FUNCT_2:8;
    end;
    then reconsider onetoone as Subset of Funcs(s, t);
    {f where f is Function of s, t : not P[f]} =
        Funcs(s, t) \ {f where f is Function of s, t : P[f]}
                                           from FraenkelDiff(A2);
    then
    card (not-one-to-one (s, t)) =
         card(Funcs(s, t)) - card(onetoone) by CARD_2:44
      .= card(Funcs(s, t)) -
         ((card t)! / ((card t -' card s)!)) by A1,CARD_FIN:7
      .= (card t) |^ (card s) -
         ((card t)! / ((card t -' card s)!)) by A2,CARD_FIN:4;
    hence thesis;
  end;
