`posets/text/W` := TEXT(
` `,
`FUNCTION:  W - W-polynomial of a poset`,
` `,
`CALLING SEQUENCE:  W(P,q,t,<options>);`,
`                   W(P,X,q,t,<options>);`,
`                   W(P,n,q,t,<options>);`,
` `,
`PARAMETERS:  P     = a poset`,
`             X     = a set (the vertex set)`,
`             n     = a positive integer (the number of vertices)`,
`            q,t    = variable names or expressions`,
`         <options> = any of the following, in any order:`,
`            (1) 'ideals' or 'linear' (specifying an algorithm)`,
`            (2) a subset of P (specifying descent positions)`,
`   `,
`SYNOPSIS:`,
`  Let P be a poset with a vertex set X of size n. A labeling L of P may`,
`  be viewed as an assignment of distinct integers to the vertices in P.`,
`  The labeling is "natural" if x < y in P implies L[x] < L[y].`,
`  For each linear extension w of P (see 'extensions'), define`,
`   `,
`    D(L,w) = { 1 <= i <= n : L[w[i]] > L[w[i+1]] },`,
`   `,
`  using the convention that L[w[n+1]] = -infinity.`,
`  It follows that D(L,w) always includes n (assuming n>0).`,
`  The W-polynomial of (P,L) may be defined as the generating series`,
`   `,
`    W(q,t) = SUM  q^Sum(D(L,w)) * t^|D(L,w)|,`,
`   `,
`  where w ranges over all linear extensions of P.`,
`   `,
`  The W-polynomial depends only on P and the "descent set" of L; i.e.,`,
`  the set of all covering pairs x < y in P such that L[x] > L[y].`,
`  In other words, two labelings of P with the same descent set yield the`,
`  same W-polynomial. In particular, all natural labelings of P (the case`,
`  of an empty descent set) yield the same W-polynomial.`,
`   `,
`  W(P,X,q,t) returns the W-polynomial of P evaluated at q,t, relative`,
`  to a natural labeling of P.`,
`  W(P,n,q,t) does the same, if the vertex set of P is {1,...,n}.`,
`  W(P,q,t) does the same, assuming that P has no isolated vertices.`,
`   `,
`  To compute the W-polynomial of P relative to an arbitrary labeling L,`,
`  the descent set S of the labeling may be optionally provided as an`,
`  additional argument. This set must be a subset of P (i.e., a subset of`,
`  the covering relation of the poset). If there is no labeling of P`,
`  corresponding to the given descent set S, an error is signaled.`,
`   `,
`  Two algorithms are provided for computing W-polynomials: 'linear' and`,
`  'ideals'. The 'linear' algorithm has minimal space requirements and a`,
`  running time that is linear in the number of linear extensions of P.`,
`  The 'ideals' algorithm is more appropriate for larger posets, and has`,
`  worst-case running times that are quadratic in the number of order`,
`  ideals of P. If neither algorithm is specified, the default is to use`,
`  the 'linear' option for posets with <= 6 vertices, and the 'ideals'`,
`  option otherwise. `,
`   `,
`  Note that when the W-polynomial is evaluated at (q,t)=(1,1), the result`,
`  is the number of linear extensions of P. In this case (i.e., when the`,
`  supplied values for q and t are both 1), the procedure ignores any`,
`  optional arguments and calls a special subroutine for fast counting of`,
`  linear extensions.`,
`   `,
`  It can be shown that`,
`                             2         n                    s  m`,
`    W(q,t) = (1-t)(1-q t)(1-q t)...(1-q t) * SUM  N[s,m] * q  t,`,
`  `,
`  where N[s,m] is the number of order-reversing maps f from P to the`,
`  m-element chain 1 < 2 < ... < m such that`,
`   `,
`    (1) the sum of f(x) over all x in X is s,`,
`    (2) f(x) > f(y) whenever L[x] > L[y].`,
`   `,
`  In particular, specializing to the case q=1, one obtains`,
`   `,
`    W(1,t) = (1-t)^(n+1) * SUM Ord(m) * t^m,`,
`   `,
`  where Ord(m) is the order polynomial of P relative to L (see 'omega'). `,
`   `,
`  Relative to a natural labeling, the W-polynomial of P is the flag`,
`  h-polynomial of J(P,X) in the variables z[i]=q^i*t (see 'flag_h'),`,
`  and W(1,t) is the ordinary h-polynomial of J(P,X) (see 'h_poly').`,
`   `,
`EXAMPLES:`,
`  f:=W({},4,q,1);`,
`  factor(f);                  yields        q^4*(q^2+q+1)*(q^2+1)*(q+1)^2`,
`  P:=chain(2) &* chain(3);`,
`  W(P,q,t,{[1,2],[5,6]});     yields`,
`                               q^9*t^2 + q^11*t^3 + 2*q^12*t^3 + q^13*t^3`,
`  W({[a,b],[a,c]},{a,b,c,d},1,t,'ideals'); `,
`                              yields                t + 5*t^2 + 2*t^3`,
`  W(chain(9),q,t,'linear',{[1,2],[3,4],[5,6]});`,
`                              yields                    q^18*t^4`,
`  P:=chain(7) &* chain(7);`,
`  W(P,1,1);                   yields           475073684264389879228560`,
` `,
`SEE ALSO:  extensions, flag_h, h_poly, ideals, J, omega`,
NULL):

if `+`(0)=0 then # Maple V.4 or later
  print(INTERFACE_HELP(insert, topic=`posets/W`,
  helpfile=HomeLib, text=`posets/text/W`))
elif ceil(0)=0 then # Maple V.2 or V.3
  `help/posets/text/W`:=`posets/text/W`:
  save `help/posets/text/W`, cat(HomeLib,`/help/posets/text/W.m`)
fi:
