#
# zeta(P,X,z) returns the zeta polynomial of a poset P with vertex
#  set X in the variable z.
# zeta(P,n,z) does the same, using X={1,...,n}.
# zeta(P,z) does the same, assuming there are no isolated points.
#
`posets/zeta`:=proc() local n,f,g,z,q;
  z:=args[nargs]; n:=nargs-1;
  if n>2 then ERROR(`invalid arguments`) fi;
  g:=posets['chains'](args[1..n],q);
  n:=degree(g,q); f:=coeff(g,q,max(n,1));
  while n>1 do f:=(z-n)*f; n:=n-1; f:=coeff(g,q,n)+expand(f)/n od; f
end:
#
save `posets/zeta`, cat(HomeLib,`/posets/zeta.m`);
read cat(HomeLib,`/help/posets/zeta`);
quit; 

