`posets/text/chains` := TEXT(
`   `,
`FUNCTION:  chains - list/count chains in a partially ordered set`,
`   `,
`CALLING SEQUENCE:  chains(P,<option>);`,
`                   chains(P,n,<option>);`,
`                   chains(P,X,<option>);`,
`   `,
`PARAMETERS:  P    = a poset`,
`             X    = a set (the vertex set); or, a linear extension of P`,
`             n    = a positive integer (the number of vertices)`,
`         <option> = at most one of the following:`,
`            (1) a range, such as 2..7`,
`            (2) the name 'max'`,
`            (3) a variable name, such as q`,
`   `,
`SYNOPSIS:`,
`  A chain in a poset P with vertex set X is a list [x_1,x_2,...,x_k] of`,
`  vertices such that x_1 < x_2 < ... < x_k in P.`,
`   `,
`  chains(P,X) returns a list of all chains in the poset P.`,
`  chains(P,n) does the same, if the vertex set of P is {1,2,...,n}.`,
`  chains(P) does the same, assuming that P has no isolated vertices.`,
`   `,
`  The chains are listed in a lexicographic order so that chain C precedes`,
`  chain D if D contains the "last" vertex of the symmetric difference of C`,
`  and D. Here, "last" is determined by some linear extension of P; i.e.,`,
`  a linear ordering of X such that if x < y in P, then x precedes y in the`,
`  linear ordering. So for example, all chains that include the last vertex`,
`  of the linear extension appear after all chains that do not.`,
`   `,
`  In order to force the use of the lexordering induced by a particular`,
`  linear extension of P, the vertex set X may be specified as a list in`,
`  the desired order, rather than as a set.`,
`   `,
`  Optionally, if the last argument is a range a..b, then only those chains`,
`  whose sizes fit within this range are listed.`,
`   `,
`  Optionally, if the last argument is the name 'max', then only maximal`,
`  chains are listed.`,
`   `,
`  Optionally, if the last argument is a variable name, such as q, then`,
`  the result is the generating series for chain sizes (not lengths); i.e.,`,
`  the sum of q^nops(C) over all chains C in P. Note that the f-polynomial`,
`  of the poset obtained by adjoining maximum and minimum elements to P`,
`  is q*chains(P,X,q) (see 'f_poly').`,
`   `,
`EXAMPLES:`,
`  chains({[a,b],[b,c]},{a,b,c});    yields`,
`                                [[],[a],[b],[a,b],[c],[a,c],[b,c],[a,b,c]]`,
`  P:={[1,2],[3,4]};`,
`  chains(P,[1,3,2,4]);          yields    [[],[1],[3],[2],[1,2],[4],[3,4]]`,
`  chains(P,[1,2,3,4]);          yields    [[],[1],[2],[1,2],[3],[4],[3,4]]`,
`  P:=({},1) &+ ({[1,2]},3) &+ ({},1);`,
`  chains(P,'max');              yields          [[1,4,5],[1,2,3,5]]`,
`  chains(P,6,q);                yields         1+6*q+8*q^2+5*q^3+q^4`,
`  chains(P,[1,2,3,4,5],3..3);   yields`,
`                                 [[1,2,3],[1,2,5],[1,3,5],[2,3,5],[1,4,5]]`,
`   `,
`SEE ALSO:  antichains, extensions, f_poly, ideals, zeta`,
NULL):

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