$      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~  The series [1,0,0,0,0,...]4, which is the neutral element for the convolution. UConvolution of series. The result is always an infinite list. Warning: This is slow! (Convolution of many series. Still slow! Power series expansion of  1 1 / ( (1-x^k_1) * (1-x^k_2) * ... * (1-x^k_n) )  Example: (coinSeries [2,3,5])!!k is the number of ways  to pay k4 dollars with coins of two, three and five dollars. TODO: better name? CGeneralization of the above to include coefficients: expansion of > 1 / ( (1-a_1*x^k_1) * (1-a_2*x^k_2) * ... * (1-a_n*x^k_n) )  Convolution of many +, that is, the expansion of the reciprocal  of a product of polynomials The same, with coefficients. AThis is the most general function in this module; all the others " are special cases of this one. The power series expansion of / 1 / (1 - x^k_1 - x^k_2 - x^k_3 - ... - x^k_n) "Convolve with (the expansion of) / 1 / (1 - x^k_1 - x^k_2 - x^k_3 - ... - x^k_n) The expansion of ? 1 / (1 - a_1*x^k_1 - a_2*x^k_2 - a_3*x^k_3 - ... - a_n*x^k_n) "Convolve with (the expansion of) ? 1 / (1 - a_1*x^k_1 - a_2*x^k_2 - a_3*x^k_3 - ... - a_n*x^k_n) "Convolve with (the expansion of)  4 1 / (1 +- x^k_1 +- x^k_2 +- x^k_3 +- ... +- x^k_n) Should be faster than using .  Note:  corresponds to the coefficient -1 in  (since 1 there is a minus sign in the definition there)!     "Tuples"A fitting into a give shape. The order is lexicographic, that is,  ( sort ts == ts where ts = tuples' shape  Example:  tuples' [2,3] = M [[0,0],[0,1],[0,2],[0,3],[1,0],[1,1],[1,2],[1,3],[2,0],[2,1],[2,2],[2,3]]  positive "tuples" fitting into a give shape. # = \prod_i (m_i + 1) # = \ prod_i m_i length (width) maximum (height) length (width) maximum (height) # = (m+1) ^ len # = m ^ len      (-1)^k A000142.  A006882. ! A007318. "#Catalan numbers. OEIS:A000108. $Catalan's triangle. OEIS:A009766.  Note: " catalanTriangle n n == catalan n G catalanTriangle n k == countStandardYoungTableaux (toPartition [n,k]) %CRows of (signed) Stirling numbers of the first kind. OEIS:A008275.  Coefficients of the polinomial (x-1)*(x-2)*...*(x-n+1). + This function uses the recursion formula. &;(Signed) Stirling numbers of the first kind. OEIS:A008275.  This function uses %, so it shouldn' t be used  to compute many Stirling numbers. '3(Unsigned) Stirling numbers of the first kind. See &. (3Stirling numbers of the second kind. OEIS:A008277. ) This function uses an explicit formula. )Bernoulli numbers. bernoulli 1 == -1%2 and bernoulli k == 0 for  k>2 and odd<. This function uses the formula involving Stirling numbers A of the second kind. Numerators: A027641, denominators: A027642.  !"#$%&'()  !"#$%&'()  !"#$%&'()*All possible ways to choose k elements from a list, without  repetitions. "Antisymmetric power" for lists. Synonym for  kSublists. +All possible ways to choose k elements from a list, with repetitions.  "Symmetric power" for lists. See also Math.Combinat.Combinations.  TODO: better name? ," Tensor power" for lists. Special case of -:  4 tuplesFromList k xs == listTensor (replicate k xs)  See also Math.Combinat.Tuples.  TODO: better name? -"Tensor product" for lists. .4Sublists of a list having given number of elements. /# = binom { n } { k }. 0All sublists of a list. 1# = 2^n. *+,-./01*+,-.0/1*+,-./012CCombinations fitting into a given shape and having a given degree. ) The order is lexicographic, that is, 0 sort cs == cs where cs = combinations' shape k shape sum 34-All combinations fitting into a given shape. 5 Combinations of a given length. length sum 6# = \binom { len+d-1 } { len-1 } 7)Positive combinations of a given length. length sum 8234567823456782345678 9-Integer vectors. The indexing starts from 1. :;The additional invariant enforced here is that partitions ; are monotone decreasing sequences of positive integers. ;4Sorts the input, and cuts the nonpositive elements. <&Assumes that the input is decreasing. =9Checks whether the input is a partition. See the note at >! >9Note: we only check that the sequence is ordered, but we do not check for N negative elements. This can be useful when working with symmetric functions. % It may also change in the future... ?@#The first element of the sequence. AThe length of the sequence. BCThe weight of the partition 5 (that is, the sum of the corresponding sequence). D#The dual (or conjugate) partition. EF Example: # elements (toPartition [5,2,1]) == % [ (1,1), (1,2), (1,3), (1,4), (1,5)  , (2,1), (2,2), (2,3), (2,4)  , (3,1)  ] GHComputes the number of " automorphisms" of a given partition. IJ;Partitions of d, fitting into a given rectangle, as lists. (height,width) d KSPartitions of d, fitting into a given rectangle. The order is again lexicographic. (height,width) d LMPartitions of d, as lists NPartitions of d. OP/All partitions fitting into a given rectangle. (height,width) Q%All partitions up to a given degree. R# = \binom { h+w } { h } STPartitions of a multiset. U+Vector partitions. Basically a synonym for W. VW!Generates all vector partitions  (" algorithm M" in Knuth). , The order is decreasing lexicographic. 9:;<=>?@ABCDEFGHIJKLMNOPQRSTUVW:=<;>?@ABCDEFGHIKJLNMOPQRST9UVW9:;<=>?@ABCDEFGHIJKLMNOPQRSTUVW XAdds unique labels to a . YAdds unique labels to a  Z[\>Attaches the depth to each node. The depth of the root is 0. ]^_`:Computes the set of equivalence classes of trees (in the % sense that the leaves of a node are  unordered)  with  n = length ks% leaves where the set of heights of / the leaves matches the given set of numbers. ( The height is defined as the number of edges from the leaf to the root. TODO: better name? XYZ[\]^_` `XYZ[\]^_ XYZ[\]^_`%a;Disjoint cycle notation for permutations. Internally it is [[Int]]. bNStandard notation for permutations. Internally it is an array of the integers [1..n]. cde7Assumes that the input is a permutation of the numbers [1..n]. f9Checks whether the input is a permutation of the numbers [1..n]. gChecks the input. hReturns n2, where the input is a permutation of the numbers [1..n] ijklThis is compatible with Maple's  convert(perm,'disjcyc'). mnoPlus 1 or minus 1. pq9Action of a permutation on a set. If our permutation is  encoded with the sequence  [p1,p2,...,pn], then in the  two-line notation we have   ( 1 2 3 ... n )  ( p1 p2 p3 ... pn ) .We adopt the convention that permutations act  on the left 5 (as opposed to Knuth, where they act on the right).  Thus,  C permute pi1 (permute pi2 set) == permute (pi1 `multiply` pi2) set 3The second argument should be an array with bounds (1,n). ' The function checks the array bounds. rThe list should be of length n. s*Multiplies two permutations together. See q for our  conventions. tThe inverse permutation uA synonym for w vwPermutations of [1..n]* in lexicographic order, naive algorithm. xy# = n! zA synonym for ~. {|A synonym for . }~,Generates a uniformly random permutation of [1..n].  Durstenfeld's algorithm (see  *http://en.wikipedia.org/wiki/Knuth_shuffle). Generates a uniformly random cyclic permutation of [1..n].  Sattolo's algorithm (see  *http://en.wikipedia.org/wiki/Knuth_shuffle). ,Generates all permutations of a multiset. - The order is lexicographic. A synonym for  # = \frac { (sum_i n_i) ! } { \prod_i (n_i !) } *Generates all permutations of a multiset  (based on " algorithm L"& in Knuth; somewhat less efficient). ! The order is lexicographic. "abcdefghijklmnopqrstuvwxyz{|}~"bacdefghijlkmnopqrstuvwxyz{|}~"abcdefghijklmnopqrstuvwxyz{|}~  An element (i,j)2 of the resulting tableau (which has shape of the F given partition) means that the vertical part of the hook has length i,  and the horizontal part j. The  hook length is thus i+j-1.  Example: - > mapM_ print $ hooks $ toPartition [5,4,1] ! [(3,5),(2,4),(2,3),(2,2),(1,1)]  [(2,4),(1,3),(1,2),(1,1)]  [(1,1)] *Standard Young tableaux of a given shape. " Adapted from John Stembridge,   ?http://www.math.lsa.umich.edu/~jrs/software/SFexamples/tableaux. hook-length formula ,Semistandard Young tableaux of given shape, "naive" algorithm Stanley'$s hook formula (cf. Fulton page 55)  Set of (i,j) pairs with i>=j>=1. Triangular arrays Generates all tableaux of size k. Effective for k<=6.  "8A binary tree with leaves and internal nodes decorated  with types a and b, respectively. .A binary tree with leaves decorated with type a.  Synonym for .  Synonym for .  Synonym for . <Generates all sequences of nested parentheses of length 2n. > Order is lexigraphic (when right parentheses are considered  smaller then left ones).  Based on " Algorithm P") in Knuth, but less efficient because of  the " idiomatic" code. NGenerates a uniformly random sequence of nested parentheses of length 2n.  Based on " Algorithm W" in Knuth. 2Nth sequence of nested parentheses of length 2n.  The order is the same as in .  Based on " Algorithm U" in Knuth. n N; should satisfy 1 <= N <= C(n) *Generates all binary trees with n nodes. $ At the moment just a synonym for . # = Catalan(n) = \frac { 1 } { n+1 } \binom { 2n } { n }. GThis is also the counting function for forests and nested parentheses. >Generates all binary trees with n nodes. The naive algorithm. 1Generates an uniformly random binary tree, using . 'Grows a uniformly random binary tree.  " Algorithm R" (Remy's procudere) in Knuth. J Nodes are decorated with odd numbers, leaves with even numbers (from the  set [0..2n]#). Uses mutable arrays internally. &!!/XYZ[\]^_` Generates graphviz .dot6 file from a forest. The first argument tells whether Q to make the individual trees clustered subgraphs; the second is the name of the  graph. Generates graphviz .dot) file from a tree. The first argument is  the name of the graph.  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~               Jqr      combinat-0.2.4Math.Combinat.Numbers.SeriesMath.Combinat.TuplesMath.Combinat.NumbersMath.Combinat.SetsMath.Combinat.CombinationsMath.Combinat.PartitionsMath.Combinat.Trees.NaryMath.Combinat.PermutationsMath.Combinat.TableauxMath.Combinat.Tableaux.KostkaMath.Combinat.Trees.BinaryMath.Combinat.GraphvizMath.Combinat.HelperMath.Combinat.Trees Math.CombinatSignMinusPlus unitSeriesconvolve convolveMany coinSeries coinSeries'convolveWithCoinSeriesconvolveWithCoinSeries'productPSeriesproductPSeries'convolveWithProductPSeriesconvolveWithProductPSeries'pseriesconvolveWithPSeriespseries'convolveWithPSeries' signValue signedPSeriesconvolveWithSignedPSeriestuples'tuples1' countTuples' countTuples1'tuplestuples1 countTuples countTuples1 binaryTuples paritySign factorialdoubleFactorialbinomial multinomialcatalancatalanTrianglesignedStirling1stArraysignedStirling1stunsignedStirling1st stirling2nd bernoullichoosecombinetuplesFromList listTensor kSublistscountKSublistssublists countSublists combinations'countCombinations'allCombinations' combinationscountCombinations combinations1countCombinations1 IntVector Partition mkPartitiontoPartitionUnsafe toPartition isPartition fromPartitionheightwidth heightWidthweight dualPartition_dualPartitionelements _elementscountAutomorphisms_countAutomorphisms _partitions' partitions'countPartitions' _partitions partitionscountPartitionsallPartitions' allPartitionscountAllPartitions'countAllPartitionspartitionMultisetvectorPartitions_vectorPartitionsfasc3B_algorithm_MaddUniqueLabelsTreeaddUniqueLabelsForestaddUniqueLabelsTree_addUniqueLabelsForest_labelDepthTreelabelDepthForestlabelDepthTree_labelDepthForest_ derivTreesDisjointCycles PermutationfromPermutationpermutationArraytoPermutationUnsafe isPermutation toPermutationpermutationSizefromDisjointCyclesdisjointCyclesUnsafedisjointCyclesToPermutationpermutationToDisjointCyclesisEvenPermutationisOddPermutationsignOfPermutationisCyclicPermutationpermute permuteListmultiplyinverse permutations _permutationspermutationsNaive_permutationsNaivecountPermutationsrandomPermutation_randomPermutationrandomCyclicPermutation_randomCyclicPermutationrandomPermutationDurstenfeldrandomCyclicPermutationSattolopermuteMultisetcountPermuteMultisetfasc2B_algorithm_LTableau_shapeshape dualTableaucontenthooks hookLengthsrowWordrowWordToTableau columnWordcolumnWordToTableaustandardYoungTableauxcountStandardYoungTableauxsemiStandardYoungTableauxcountSemiStandardYoungTableauxTriunTriTriangularArraytriangularArrayUnsafefromTriangularArray kostkaContent_kostkaContentkostkaTableaux_kostkaTableauxcountKostkaTableauxParen RightParen LeftParenBinTree'Leaf'Branch'BinTreeLeafBranchleafforgetNodeDecorationsparenthesesToStringstringToParenthesesforestToNestedParenthesesforestToBinaryTreenestedParenthesesToForestnestedParenthesesToForestUnsafenestedParenthesesToBinaryTree#nestedParenthesesToBinaryTreeUnsafebinaryTreeToNestedParenthesesbinaryTreeToForestnestedParenthesesrandomNestedParenthesesnthNestedParenthesescountNestedParenthesesfasc4A_algorithm_Pfasc4A_algorithm_Wfasc4A_algorithm_U binaryTreescountBinaryTreesbinaryTreesNaiverandomBinaryTreefasc4A_algorithm_RDot binTreeDot binTree'Dot forestDottreeDotdebugswapequatingreverseOrderingreverseCompare groupSortBynubOrdcountfromJust intToBool boolToIntnestunfold1unfold unfoldEitherunfoldM mapAccumMcontainers-0.4.0.0 Data.TreeTreeForest derivTrees'#randomPermutationDurstenfeldSattoloReverseHoleTableauReverseTableauHolebinom2index'deIndex'toHolenextHolereverseTableau normalize normalize' startHole enumHoleshelper newLines'newLinessizes' parenToChar subForest rootLabelNodedigraphBracket binTreeDot' binTree'Dot'