reserve x,y for object,
        i,j,k,m,n for Nat;

theorem Th7:
  for D be finite set
   for f be Function of D,NAT
     ex h be FinSequence of D st
       for d be Element of D holds
         card Coim(h,d) = f.d
proof
  defpred P[Nat] means
    for D be finite set st card D=$1
     for f be Function of D,NAT
       ex h be FinSequence of D st
         for d be Element of D holds
           card Coim(h,d) = f.d;
  A1:P[0]
  proof
    let D be finite set such that A2:card D=0;
    let f be Function of D,NAT;
    take h=<*>D;
    let d be Element of D;
    A3: Coim(h,d)=h"{d} by RELAT_1:def 17;
    not d in dom f by A2;
    hence thesis by FUNCT_1:def 2,A3;
  end;
  A4:P[i] implies P[i+1]
  proof
    assume A5:P[i];
    set i1=i+1;
    let D be finite set such that A6:card D=i1;
    let f be Function of D,NAT;
    D is non empty by A6;
    then consider d be object such that
    A7:d in D;
    set Dd=D\{d};
    A8:card Dd = i by A6,A7,STIRL2_1:55;
    reconsider fd=f|Dd as Function of Dd,NAT;
    consider h be FinSequence of Dd such that
    A9:for x be Element of Dd holds
    card Coim(h,x) = fd.x by A5,A8;
    A10:rng h c= Dd;
    Dd c= D;
    then rng h c= D;
    then reconsider h as FinSequence of D by FINSEQ_1:def 4;
    reconsider g=f.d |-> d as FinSequence of D by A7,FINSEQ_2:63;
    take hg=h^g;
    let x be Element of D;
    Coim(hg,x) = hg"{x} & Coim(h,x) = h"{x} & Coim(g,x) = g"{x}
    by RELAT_1:def 17;
    then A11:card Coim(hg,x) = card (h"{x})+ card (g"{x}) by FINSEQ_3:57;
    per cases;
    suppose A12:x<>d;
      then x in Dd by A7,ZFMISC_1:56;
      then A13: card Coim(h,x) = fd.x & fd.x = f.x by A9,FUNCT_1:49;
      not d in {x} by A12,TARSKI:def 1;
      then g"{x}={} by FUNCOP_1:16;
      hence thesis by RELAT_1:def 17,A11,A13;
    end;
    suppose A14:x=d;
      then not x in rng h by ZFMISC_1:56,A10;
      then A15:h"{x} = {} by FUNCT_1:72;
      d in {x} by A14,TARSKI:def 1;
      then g"{x}=Seg (f.d) by FUNCOP_1:14;
      hence thesis by FINSEQ_1:57,A15,A11,A14;
    end;
  end;
  let D be finite set;
  P[i] from NAT_1:sch 2(A1,A4);
  then P[card D];
  hence thesis;
end;
