reserve k, l, m, n, i, j for Nat,
  K, N for non empty Subset of NAT,
  Ke, Ne, Me for Subset of NAT,
  X,Y for set;
reserve f for Function of Segm n,Segm k;
reserve x,y for set;

theorem Th45:
k * (n block k)= card{f where f is
  Function of Segm(n+1),Segm k: f is onto "increasing & f"{f.n}<>{n}}
proof
  now
    per cases;
    suppose
A1:   k=0;
      reconsider F1={f where f is Function of Segm(n+1),Segm k:
                 f is onto "increasing} as set;
      reconsider F={f where f is Function of Segm(n+1),Segm k:
f is onto "increasing & f"{f.n}<> {n}} as set;
A2:   F c= F1
      proof
        let x be object;
        assume x in F;
        then
        ex f be Function of Segm(n+1),Segm k
st x=f & f is onto "increasing & f"{f.n}
        <>{n};
        hence thesis;
      end;
       card F1= (n+1) block k;
      then F1 is empty by A1,Th31;
      hence thesis by A1,A2;
    end;
    suppose k>0;
      then
A3:   Segm k is non empty;
      set G1={g where g is Function of Segm(n+1),Segm k:
g is onto "increasing & g"{g.n}
      <>{n}};
      defpred P[set] means ex f be Function of Segm(n+1),Segm k
         st f=$1& f is onto "increasing&f"{f.n}<>{n};
      n<n+1 by NAT_1:13;
      then
A4:   n in Segm(n+1) by NAT_1:44;
      consider f be Function such that
A5:   f is one-to-one and
A6:   dom f = card k and
A7:   rng f = k by WELLORD2:def 4;
      reconsider f as Function of card Segm k,Segm k by A6,A7,FUNCT_2:1;
A8:   f is onto one-to-one by A5,A7,FUNCT_2:def 3;
      consider F be XFinSequence of NAT such that
A9:  dom F = card Segm k and
A10:  card{g where g is Function of Segm(n+1),Segm k:P[g]} = Sum(F) and
A11:  for i st i in dom F holds F.i =
        card{g where g is Function of Segm(n+1),Segm k:P[g] & g.n=f.i}
              from Sch8(A8,A3,A4);
A12:  for i be Nat st i in dom F holds F.i = n block k
      proof
        set F2={g where g is Function of Segm n,Segm k:
              g is onto "increasing};
        let i be Nat such that
A13:    i in dom F;
A14:    f.i in rng f by A6,A9,A13,FUNCT_1:def 3;
        reconsider fi=f.i as Element of NAT by A7,A14;
A15:    fi<k by A14,NAT_1:44;
        set F1={g where g is Function of Segm(n+1),Segm k:P[g] & g.n=fi};
        set F={g where g is Function of Segm(n+1),Segm k:
g is onto "increasing & g"{g.n}
        <>{n} & g.n=fi};
A16:    F1 c= F
        proof
          let x be object;
          assume x in F1;
          then ex g be Function of Segm(n+1),Segm k st x=g & P[g] & g.n=fi;
          hence thesis;
        end;
        F c= F1
        proof
          let x be object;
          assume x in F;
          then
          ex g be Function of Segm(n+1),Segm k
              st x=g &g is onto "increasing & g"{g.
          n}<>{n} & g.n=fi;
          hence thesis;
        end;
        then F=F1 by A16;
        then card F1=card F2 by A15,Th43;
        hence thesis by A11,A13;
      end;
      then for i be Nat st i in dom F holds F.i <= n block k;
      then
A17:  Sum F <= len F * (n block k) by AFINSQ_2:59;
      set G={g where g is Function of Segm(n+1),Segm k:P[g]};
A18:  G1 c= G
      proof
        let x be object;
        assume x in G1;
        then
        ex g be Function of Segm(n+1),Segm k
         st x=g &g is onto "increasing & g"{g.n} <>{n};
        hence thesis;
      end;
A19:  G c= G1
      proof
        let x be object;
        assume x in G;
        then ex g be Function of Segm(n+1),Segm k st x=g & P[g];
        hence thesis;
      end;
      for i be Nat st i in dom F holds F.i >= n block k by A12;
      then
A20:  Sum F >= len F * (n block k) by AFINSQ_2:60;
      Sum F= k*(n block k) by A9,A17,A20,XXREAL_0:1;
      hence thesis by A10,A18,A19,XBOOLE_0:def 10;
    end;
  end;
  hence thesis;
end;
