h$c       !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~                                                                                                              !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!""""""""""""""""""""""""############################################$$$$$$$$$$$                                    %%%%%%%%%%%%%%%%%&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&'''''''''''''''''''''''' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( (, Safe-Inferredcombinat Number of cycles (of partitions) combinatNumber of leaves (of trees) combinatNumber of nodes (of trees)combinat"Shape (of tableaux, skew tableaux)combinat&Duality (of partitions, tableaux, etc)combinat%Weight (of partitions, tableaux, etc)combinatNumber of partscombinat Emptyness   None. combinatThe Rand monad transformercombinat,A simple random monad to make life suck less(combinatProduct of list of integers, but in interleaved order (for a list of big numbers, it should be faster than the linear order))combinatFaster implementation of product [ i | i <- [a+1..b] ]*combinat!Faster implementation of product [ i | i <- [a+1,a+3,..b] ]6combinatThe boolean argument will True only for the last element9combinat8extend lines with spaces so that they have the same lineMcombinatThis may be occasionally usefulNcombinat9Puts a standard-conforming random function into the monad5 !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQ5 !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQNone-q-UcombinatOrder of elements in a matrixXcombinatVertical separatorYcombinatempty separatorZcombinatn spaces[combinat$some custom list of characters, eg. " - "5 (the characters are interpreted as below each other)\combinatHorizontal separator]combinatempty separator^combinatn spaces_combinatsome custom string, eg. " | "bcombinatVertical alignmentfcombinatHorizontal alignmentjcombinat1A type class to have a simple way to draw things lcombinatThe type of a (rectangular) ASCII figure. Internally it is a list of lines of the same length plus the size.Note: The Show instance is pretty-printing, so that it's convenient in ghci.pcombinatAn empty (0x0) rectangle{combinat4Horizontal append, centrally aligned, no separation.|combinat2Vertical append, centrally aligned, no separation.}combinat4Horizontal concatenation, top-aligned, no separation~combinat7Horizontal concatenation, bottom-aligned, no separationcombinat3Vertical concatenation, left-aligned, no separationcombinat4Vertical concatenation, right-aligned, no separationcombinat General horizontal concatenationcombinatGeneral vertical concatenationcombinatHorizontally pads with the given number of spaces, on both sidescombinatVertically pads with the given number of empty lines, on both sidescombinatPads by single empty lines vertically and two spaces horizontallycombinatExtends an ASCII figure with spaces horizontally to the given width. Note: the alignment is the alignment of the original picture in the new bigger picture!combinatExtends an ASCII figure with spaces vertically to the given height. Note: the alignment is the alignment of the original picture in the new bigger picture!combinat4Extend horizontally with the given number of spaces.combinat7Extend vertically with the given number of empty lines.combinatHorizontal indentationcombinatVertical indentationcombinatCuts the given number of columns from the picture. The alignment is the alignment of the picture, not the cuts.%This should be the (left) inverse of .combinatCuts the given number of rows from the picture. The alignment is the alignment of the picture, not the cuts.%This should be the (left) inverse of .combinatPastes the first ASCII graphics onto the second, keeping the second one's dimension (that is, overlapping parts of the first one are ignored). The offset is relative to the top-left corner of the second picture. Spaces at treated as transparent.Example: tabulate (HCenter,VCenter) (HSepSpaces 2, VSepSpaces 1) [ [ caption (show (x,y)) $ pasteOnto (x,y) (filledBox '@' (4,3)) (asciiBox (7,5)) | x <- [-4..7] ] | y <- [-3..5] ]combinatPastes the first ASCII graphics onto the second, keeping the second one's dimension. The first argument specifies the transparency condition (on the first picture). The offset is relative to the top-left corner of the second picture.combinat A version of  where we can specify the corner of the second picture to which the offset is relative: &pasteOntoRel (HLeft,VTop) == pasteOntocombinat0Tabulates the given matrix of pictures. Example: tabulate (HCenter, VCenter) (HSepSpaces 2, VSepSpaces 1) [ [ asciiFromLines [ "x=" ++ show x , "y=" ++ show y ] | x<-[7..13] ] | y<-[98..102] ]combinat)Automatically tabulates ASCII rectangles.combinat4Adds a caption to the bottom, with default settings.combinat"Adds a caption to the bottom. The Bool flag specifies whether to add an empty between the caption and the figurecombinat&An ASCII border box of the given size combinat/An "rounded" ASCII border box of the given sizecombinat,A box simply filled with the given charactercombinatA box of spacescombinat An integercombinattransparency conditioncombinat=0 : signedBinomial n k == binomial n k for any n,k : signedBinomial n k == signedBinomial n (n-k) for k >= 0 : signedBinomial (-n) k == (-1)^k * signedBinomial (n+k-1) k,Note: This is compatible with Mathematica's Binomial function.combinatA given row of the Pascal triangle; equivalent to a sequence of binomial numbers, but much more efficient. You can also left-fold over it. +pascalRow n == [ binomial n k | k<-[0..n] ]combinatCatalan numbers. OEIS:A000108.combinat(Catalan's triangle. OEIS:A009766. Note: catalanTriangle n n == catalan n catalanTriangle n k == countStandardYoungTableaux (toPartition [n,k])combinatRows 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.combinat(Signed) Stirling numbers of the first kind. OEIS:A008275. This function uses &, so it shouldn't be used to compute many Stirling numbers.Argument order: signedStirling1st n kcombinat3(Unsigned) Stirling numbers of the first kind. See .combinatStirling numbers of the second kind. OEIS:A008277. This function uses an explicit formula.Argument order: stirling2nd n kcombinatBernoulli numbers. bernoulli 1 == -1%2 and bernoulli k == 0 for k>2 and odd. This function uses the formula involving Stirling numbers of the second kind. Numerators: A027641, denominators: A027642.combinatBell numbers (Sloane's A000110) from B(0) up to B(n). B(0)=B(1)=1, B(2)=2, etc. %The Bell numbers count the number of set partitions of a set of size nSee (http://en.wikipedia.org/wiki/Bell_numbercombinatThe n-th Bell number B(n), using the Stirling numbers of the second kind. This may be slower than using .+NoneM6None>VcombinatA binary tree with leaves and internal nodes decorated with types a and b, respectively.combinat.A binary tree with leaves decorated with type a.combinat*The monadic join operation of binary treescombinatEnumerates the leaves a tree, starting from 0, ignoring old labelscombinatEnumerates the leaves a tree, starting from zero, and also returns the number of leavescombinat0Enumerates the leaves a tree, starting from zerocombinat+Convert a binary tree to a rose tree (from  Data.Tree)combinat8Generates all sequences of nested parentheses of length 2n in lexigraphic order. Synonym for .combinat Synonym for .combinat Synonym for .combinatGenerates all sequences of nested parentheses of length 2n. Order is lexicographical (when right parentheses are considered smaller then left ones). Based on "Algorithm P" in Knuth, but less efficient because of the "idiomatic" code.combinatGenerates a uniformly random sequence of nested parentheses of length 2n. Based on "Algorithm W" in Knuth.combinatNth sequence of nested parentheses of length 2n. The order is the same as in #. Based on "Algorithm U" in Knuth.combinat Generates all binary trees with n- nodes. At the moment just a synonym for .combinat9# = Catalan(n) = \frac { 1 } { n+1 } \binom { 2n } { n }.This is also the counting function for forests and nested parentheses.combinat=Generates all binary trees with n nodes. The naive algorithm.combinat1Generates an uniformly random binary tree, using .combinatGrows a uniformly random binary tree. "Algorithm R" (Remy's procudere) in Knuth. Nodes are decorated with odd numbers, leaves with even numbers (from the set [0..2n]"). Uses mutable arrays internally.combinat3Draws a binary tree in ASCII, ignoring node labels.Example: autoTabulate RowMajor (Right 5) $ map asciiBinaryTree_ $ binaryTrees 4combinatncombinat!N; should satisfy 1 <= N <= C(n) 4 4 None5>d.%combinat#A completely unlabelled binary treecombinatA (strict) binary tree with labelled leaves (but unlabelled nodes)combinatA tree diagram, consisting of two binary trees with the same number of leaves, representing an element of the group F.combinat (map fst xs, map snd ys)) . choose' kcombinatAnother variation on  which tags the elements based on whether they are part of the selected subset (  ) or not ( ): &choose k = map rights . chooseTagged kcombinatAll possible ways to choose k elements from a list, with repetitions*. "Symmetric power" for lists. See also Math.Combinat.Compositions. TODO: better name?combinatA synonym for .combinat*"Tensor power" for lists. Special case of : 2tuplesFromList k xs == listTensor (replicate k xs) See also Math.Combinat.Tuples. TODO: better name?combinat"Tensor product" for lists.combinatSublists of a list having given number of elements. Synonym for .combinat# = binom { n } { k }.combinatAll sublists of a list.combinat# = 2^n.combinatrandomChoice k n& returns a uniformly random choice of k elements from the set [1..n]Example: do cs <- replicateM 10000 (getStdRandom (randomChoice 3 7)) mapM_ print $ histogram csNone>?p> combinatThe type of half-integers (internally represented by their double)'TODO: refactor this into its own modulecombinatThe ambient dimension of (our representation of the) system (length of the vector)combinatFinds a vector, which is hopefully not orthognal to any root (generated by the given simple roots), and has positive dot product with each of them.combinatbracket b a = (a,b)/(a,a) combinat"mirror b a = b - 2*(a,b)/(a,a) * acombinat)Cartan matrix of a list of (simple) rootscombinatWe mirror stuff until there is no more things happening (very naive algorithm, but seems to work)combinatThis is a basis of E6 as the subset of the even E8 root system where the first three coordinates agree (they are consolidated into the first coordinate here)combinatThis is a basis of E8 as the subset of the even E8 root system where the first two coordinates agree (they are consolidated into the first coordinate here)combinatThis is a basis of E7 as the subset of the even E8 root system for which the sum of coordinates sum to zero''None?B8combinat;Disjoint cycle notation for permutations. Internally it is [[Int]].4The cycles are to be understood as follows: a cycle [c1,c2,...,ck] means the permutation '( c1 c2 c3 ... ck ) ( c2 c3 c4 ... c1 )combinatA permutation. Internally it is an (compact) vector of the integers [1..n].If this array of integers is [p1,p2,...,pn]?, then in two-line notations, that represents the permutation '( 1 2 3 ... n ) ( p1 p2 p3 ... pn )That is, it is the permutation sigma! whose (right) action on the set [1..n] is  sigma(1) = p1 sigma(2) = p2 ...((NOTE: this changed at version 0.2.8.0!)combinat7Assumes that the input is a permutation of the numbers [1..n].combinatThis is faster than , but you need to supply n.combinatNote: Indexing starts from 1.combinat9Checks whether the input is a permutation of the numbers [1..n].combinat9Checks whether the input is a permutation of the numbers [1..n].combinatChecks the input.combinatReturns n2, where the input is a permutation of the numbers [1..n]combinatReturns the image sigma(k) of k under the permutation sigma.Note: we don't check the bounds! It may even crash if you index out of bounds!combinatInfix version of combinat:Checks whether the permutation is the identity permutationcombinatGiven a permutation of n and a permutation of m, we return a permutation of n+m resulting by putting them next to each other. This should satisfy permuteList p1 xs ++ permuteList p2 ys == permuteList (concatPermutations p1 p2) (xs++ys)combinat Synonym for combinatThe standard two-line notation, moving the element indexed by the top row into the place indexed by the corresponding element in the bottom row.combinatThe inverse two-line notation, where the it's the bottom line which is in standard order. The columns of this are a permutation of the columns .Remark: the top row of inverseTwoLineNotation perm$ is the same as the bottom row of )twoLineNotation (inversePermutation perm).combinat(Two-line notation for any set of numberscombinat#Convert to disjoint cycle notation. This is compatible with Maple's convert(perm,'disjcyc') and also with Mathematica's PermutationCycles[perm]6Note however, that for example Mathematica uses the top row/ to represent a permutation, while we use the  bottom row8 - thus even though this function looks identical, the meaning, of both the input and output is different!combinatPlus 1 or minus 1.combinatAn  inversion of a permutation sigma is a pair (i,j) such that i sigma(j).6This functions returns the inversion of a permutation.combinat!Returns the number of inversions: 2numberOfInversions perm = length (inversions perm) Synonym for combinatReturns the number of inversions, using the merge-sort algorithm. This should be  O(n*log(n))combinatReturns the number of inversions, using the definition, thus it's O(n^2).combinatBubble sorts breaks a permutation into the product of adjacent transpositions: multiplyMany' n (map (transposition n) $ bubbleSort2 perm) == permNote that while this is not unique, the number of transpositions equals the number of inversions.combinat)Another version of bubble sort. An entry i1 in the return sequence means the transposition (i,i+1): multiplyMany' n (map (adjacentTransposition n) $ bubbleSort perm) == permcombinatThe permutation [n,n-1,n-2,...,2,1](. Note that it is the inverse of itself.combinatChecks whether the permutation is the reverse permutation @[n,n-1,n-2,...,2,1].combinat)A transposition (swapping two elements). transposition n (i,j) is the permutation of size n which swaps i'th and j 'th elements.combinatProduct of transpositions. transpositions n list == multiplyMany [ transposition n pair | pair <- list ]combinatadjacentTransposition n k swaps the elements k and (k+1).combinat#Product of adjacent transpositions. adjacentTranspositions n list == multiplyMany [ adjacentTransposition n idx | idx <- list ]combinat5The permutation which cycles a list left by one step: ,permuteList (cycleLeft 5) "abcde" == "bcdea"Or in two-line notation: ( 1 2 3 4 5 ) ( 2 3 4 5 1 )combinat6The permutation which cycles a list right by one step: -permuteList (cycleRight 5) "abcde" == "eabcd"Or in two-line notation: ( 1 2 3 4 5 ) ( 5 1 2 3 4 )combinat&Multiplies two permutations together: p  q, means the permutation when we first apply p , and then q& (that is, the natural action is the right action) See also  for our conventions. combinatThe inverse permutation.combinat&The identity (or trivial) permutation.combinatMultiply together a  non-empty list of permutations (the reason for requiring the list to be non-empty is that we don't know the size of the result). See also  multiplyMany'.combinatMultiply together a (possibly empty) list of permutations, all of which has size ncombinatRight action 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 right (as in Knuth): permuteArray pi2 (permuteArray pi1 set) == permuteArray (pi1 `multiplyPermutation` pi2) set Synonym to combinat"Right action on lists. Synonym to combinat5The right (standard) action of permutations on sets.  permuteArrayRight pi2 (permuteArrayRight pi1 set) == permuteArrayRight (pi1 `multiplyPermutation` pi2) set3The second argument should be an array with bounds (1,n)(. The function checks the array bounds.combinatThe right (standard) action on a list. The list should be of length n. 4fromPermutation perm == permuteListRight perm [1..n]combinat4The left (opposite) action of the permutation group. permuteArrayLeft pi2 (permuteArrayLeft pi1 set) == permuteArrayLeft (pi2 `multiplyPermutation` pi1) setIt is related to permuteLeftArray via: permuteArrayLeft pi arr == permuteArrayRight (inversePermutation pi) arr permuteArrayRight pi arr == permuteArrayLeft (inversePermutation pi) arrcombinatThe left (opposite) action on a list. The list should be of length n. permuteListLeft perm set == permuteList (inversePermutation perm) set fromPermutation (inversePermutation perm) == permuteListLeft perm [1..n]combinatGiven a list of things, we return a permutation which sorts them into ascending order, that is: 4permuteList (sortingPermutationAsc xs) xs == sort xsNote: if the things are not unique, then the sorting permutations is not unique either; we just return one of them.combinatGiven a list of things, we return a permutation which sorts them into descending order, that is: ?permuteList (sortingPermutationDesc xs) xs == reverse (sort xs)Note: if the things are not unique, then the sorting permutations is not unique either; we just return one of them.combinatA synonym for combinatAll permutations of [1..n]) in lexicographic order, naive algorithm.combinat# = n!combinatA synonym for .combinatA synonym for .combinat,Generates a uniformly random permutation of [1..n] . Durstenfeld's algorithm (see  *http://en.wikipedia.org/wiki/Knuth_shuffle).combinatGenerates a uniformly random cyclic permutation of [1..n]. Sattolo's algorithm (see  *http://en.wikipedia.org/wiki/Knuth_shuffle).combinatGenerates all permutations of a multiset. The order is lexicographic. A synonym for combinat3# = \frac { (sum_i n_i) ! } { \prod_i (n_i !) } combinatGenerates all permutations of a multiset (based on "algorithm L" in Knuth; somewhat less efficient). The order is lexicographic.  7None combinat:A data structure which is essentially an infinite list of Integer2-s, but fast lookup (for reasonable small inputs)combinatNumber of partitions of n3 (looking up a table built using Euler's algorithm)combinatThis uses the power series expansion of the infinite product. It is slower than the above.combinat This uses , and is (very) slowcombinat+This uses Euler's algorithm to compute p(n)See eg.: NEIL CALKIN, JIMENA DAVIS, KEVIN JAMES, ELIZABETH PEREZ, AND CHARLES SWANNACK COMPUTING THE INTEGER PARTITION FUNCTION http://www.math.clemson.edu/~kevja/PAPERS/ComputingPartitions-MathComp.pdfcombinat An infinite list containing all p(n), starting from p(0).combinat)Infinite list of number of partitions of  0,1,2,...This uses the infinite product formula the generating function of partitions, recursively expanding it; it is reasonably fast for small numbers. >partitionCountListInfiniteProduct == map countPartitions [0..]combinat/Naive infinite list of number of partitions of  0,1,2,... 9partitionCountListNaive == map countPartitionsNaive [0..]This is very slow.combinatCount all partitions fitting into a rectangle. # = \binom { h+w } { h }combinatNumber of of d, fitting into a given rectangle. Naive recursive algorithm.combinatCount partitions of n into k parts.Naive recursive algorithm.combinatk = number of partscombinatn = the integer we partitionNonecombinat3Sorts the input, and cuts the nonpositive elements.combinat This returns True. if the input is non-increasing sequence of positive integers (possibly empty); False otherwise.combinatA simpler, but bit slower (about twice?) implementation of dual partitioncombinatFrom a sequence  [a1,a2,..,an]' computes the sequence of differences [a1-a2,a2-a3,...,an-0]combinatExample: _elements [5,4,1] == [ (1,1), (1,2), (1,3), (1,4), (1,5) , (2,1), (2,2), (2,3), (2,4) , (3,1) ]combinat-We convert a partition to exponential form. (i,e) mean (i^e); for example  [(1,4),(2,3)] corresponds to (1^4)(2^3) = [2,2,2,1,1,1,1]. Another example: toExponentialForm (Partition [5,5,3,2,2,2,2,1,1]) == [(1,2),(2,4),(3,1),(5,2)]combinatPartitions of d , as listscombinatAll integer partitions up to a given degree (that is, all integer partitions whose sum is less or equal to d)combinatAll integer partitions up to a given degree (that is, all integer partitions whose sum is less or equal to d), grouped by weightcombinatInteger partitions of d+, fitting into a given rectangle, as lists.combinat0Uniformly random partition of the given weight. ,NOTE: This algorithm is effective for small n-s (say n up to a few hundred / one thousand it should work nicely), and the first time it is executed may be slower (as it needs to build the table partitionCountList first)+Algorithm of Nijenhuis and Wilf (1975); see+Knuth Vol 4A, pre-fascicle 3B, exercise 47;Nijenhuis and Wilf: Combinatorial Algorithms for Computers and Calculators, chapter 10combinat1Generates several uniformly random partitions of n at the same time. Should be a little bit faster then generating them individually.combinatq `dominates` p returns True if q >= p in the dominance order of partitions (this is partial ordering on the set of partitions of n).See ,http://en.wikipedia.org/wiki/Dominance_ordercombinat+Lists all partitions of the same weight as lambda and also dominated by lambda0 (that is, all partial sums are less or equal): dominatedPartitions lam == [ mu | mu <- partitions (weight lam), lam `dominates` mu ]combinat+Lists all partitions of the sime weight as mu and also dominating mu3 (that is, all partial sums are greater or equal): dominatingPartitions mu == [ lam | lam <- partitions (weight mu), lam `dominates` mu ]combinatLists partitions of n into k parts. sort (partitionsWithKParts k n) == sort [ p | p <- partitions n , numberOfParts p == k ]Naive recursive algorithm.combinatPartitions of n with only odd partscombinatPartitions of n with distinct parts.Note: length (partitionsWithDistinctParts d) == length (partitionsWithOddParts d)combinatReturns True of the first partition is a subpartition (that is, fit inside) of the second. This includes equalitycombinat7This is provided for convenience/completeness only, as: .isSuperPartitionOf q p == isSubPartitionOf p qcombinat:Sub-partitions of a given partition with the given weight: sort (subPartitions d q) == sort [ p | p <- partitions d, isSubPartitionOf p q ]combinat'All sub-partitions of a given partitioncombinat= p in the dominance order of partitions (this is partial ordering on the set of partitions of n).See ,http://en.wikipedia.org/wiki/Dominance_ordercombinatReturns True of the first partition is a subpartition (that is, fit inside) of the second. This includes equalitycombinat7This is provided for convenience/completeness only, as: .isSuperPartitionOf q p == isSubPartitionOf p qcombinatThe Pieri rule computes s[lambda]*h[n] as a sum of s[mu]-s (each with coefficient 1).See for example ,http://en.wikipedia.org/wiki/Pieri's_formulacombinatThe dual Pieri rule computes s[lambda]*e[n] as a sum of s[mu]-s (each with coefficient 1)NonecombinatWhich orientation to draw the Ferrers diagrams. For example, the partition [5,4,1] corrsponds to:In standard English notation:  @@@@@ @@@@ @"combinat3A tableau is simply represented as a list of lists.combinatASCII diagram of a tableaucombinatThe shape of a tableaucombinatNumber of entriescombinatThe dual of the tableau is the mirror image to the main diagonal.combinatThe content of a tableau is the list of its entries. The ordering is from the left to the right and then from the top to the bottomcombinat An element (i,j) of the resulting tableau (which has shape of the 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)]combinatThe row word of a tableau is the list of its entry read from the right to the left and then from the top to the bottom.combinat Semistandard3 tableaux can be reconstructed from their row wordscombinatThe  column word of a tableau is the list of its entry read from the bottom to the top and then from the left to the rightcombinatStandard tableaux can be reconstructed from either their column or row wordscombinat4Checks whether a sequence of positive integers is a  lattice word, which means that in every initial part of the sequence any number i) occurs at least as often as the number i+1combinat A tableau is  semistandard if its entries are weekly increasing horizontally and strictly increasing verticallycombinatSemistandard Young tableaux of given shape, "naive" algorithm combinat+Stanley's hook formula (cf. Fulton page 55)combinat A tableau is standard2 if it is semistandard and its content is exactly [1..n] , where n is the weight.combinatStandard Young tableaux of a given shape. Adapted from John Stembridge,  ?http://www.math.lsa.umich.edu/~jrs/software/SFexamples/tableaux.combinathook-length formulaNone>АcombinatSet of (i,j) pairs with i>=j>=1.combinatTriangular arrayscombinatGenerates all tableaux of size k. Effective for k<=6.combinat;Note: This is slow (it actually generates all the tableaux)combinat 0 ] == dominatedPartitions lamcombinatVery naive (and slow) implementation of Kostka numbers, for reference.combinat$Lists all (positive) Kostka numbers  K(lambda,mu) with the given lambda: kostkaNumbersWithGivenLambda lambda == Map.fromList [ (mu , kostkaNumber lambda mu) | mu <- dominatedPartitions lambda ]It's much faster than computing the individual Kostka numbers, but not as fast as it could be.combinat$Lists all (positive) Kostka numbers  K(lambda,mu) with the given mu: kostkaNumbersWithGivenMu mu == Map.fromList [ (lambda , kostkaNumber lambda mu) | lambda <- dominatingPartitions mu ]This function uses the iterated Pieri rule, and is relatively fast.combinatGenerates all Kostka-Gelfand-Tsetlin tableau, that is, triangular arrays like /[ 3 ] [ 3 , 2 ] [ 3 , 1 , 0 ] [ 2 , 0 , 0 , 0 ]with both rows and column non-increasing such that the top diagonal read lambda (in this case  lambda=[3,2]>) and the diagonal sums are partial sums of mu (in this case  mu=[2,1,1,1])The number of such GT tableaux is the Kostka number K(lambda,mu).combinat-This returns the corresponding Kostka number: countKostkaGelfandTsetlinPatterns lambda mu == length (kostkaGelfandTsetlinPatterns lambda mu)combinat Computes the Schur expansion of h[n1]*h[n2]*h[n3]*...*h[nk] via iterating the Pieri rule. Note: the coefficients are actually the Kostka numbers; the following is true: Map.toList (iteratedPieriRule (fromPartition mu)) == [ (lam, kostkaNumber lam mu) | lam <- dominatingPartitions mu ]This should be faster than individually computing all these Kostka numbers.combinatIterating the Pieri rule, we can compute the Schur expansion of %h[lambda]*h[n1]*h[n2]*h[n3]*...*h[nk]combinat Computes the Schur expansion of e[n1]*e[n2]*e[n3]*...*e[nk] via iterating the Pieri rule. Note: the coefficients are actually the Kostka numbers; the following is true: Map.toList (iteratedDualPieriRule (fromPartition mu)) == [ (dualPartition lam, kostkaNumber lam mu) | lam <- dominatingPartitions mu ]This should be faster than individually computing all these Kostka numbers. It is a tiny bit slower than .combinatIterating the Pieri rule, we can compute the Schur expansion of %e[lambda]*e[n1]*e[n2]*e[n3]*...*e[nk]None combinatA skew partition  lambda/mu' is internally represented by the list &[ (mu_i , lambda_i-mu_i) | i<-[1..n] ]combinatmkSkewPartition (lambda,mu) creates the skew partition  lambda/mu. Throws an error if mu is not a sub-partition of lambda.combinatReturns   if mu is not a sub-partition of lambda.combinatThe weight of a skew partition is the weight of the outer partition minus the the weight of the inner partition (that is, the number of boxes present).combinatThis function "cuts off" the "uninteresting parts" of a skew partitioncombinatReturns the outer and inner partition of a skew partition, respectively: )mkSkewPartition . fromSkewPartition == idcombinatThe lambda part of  lambda/mucombinatThe mu part of  lambda/mucombinatThe dual skew partition (that is, the mirror image to the main diagonal)combinatSee "partitionElements"combinatLists all skew partitions with the given outer shape and given (skew) weightcombinatLists all skew partitions with the given outer shape and any (skew) weightcombinatLists all skew partitions with the given inner shape and given (skew) weightNone combinat>A skew tableau is represented by a list of offsets and entriescombinatThe shape of a skew tableau combinatThe weight of a tableau is the weight of its shape, or the number of entriescombinatThe dual of a skew tableau, that is, its mirror image to the main diagonalcombinat A tableau is  semistandard if its entries are weekly increasing horizontally and strictly increasing verticallycombinat A tableau is standard2 if it is semistandard and its content is exactly [1..n] , where n is the weight.combinat8All semi-standard skew tableaux filled with the numbers [1..n]combinathttp://www.math.lsa.umich.edu/~jrs/software/SFexamples/LR_rule lrRule (mkSkewPartition (lambda,nu)) == Map.fromList list where muw = weight lambda - weight nu list = [ (mu, coeff) | mu <- partitions muw , let coeff = lrCoeff lambda (mu,nu) , coeff /= 0 ] combinat_lrRule lambda mu4 computes the expansion of the skew Schur function  s[lambda/mu]$ via the Littlewood-Richardson rule.combinatlrCoeff lam (mu,nu) computes the coressponding Littlewood-Richardson coefficients. This is also the coefficient of  s[lambda] in the product  s[mu]*s[nu]%Note: This is much slower than using  or 3 to compute several coefficients at the same time!combinatlrCoeff (lam/nu) mu computes the coressponding Littlewood-Richardson coefficients. This is also the coefficient of s[mu] in the product  s[lam/nu]%Note: This is much slower than using  or 3 to compute several coefficients at the same time!combinat!lrScalar (lambda/mu) (alpha/beta)> computes the scalar product of the two skew Schur functions  s[lambda/mu] and  s[alpha/beta]$ via the Littlewood-Richardson rule.+Adapted from John Stembridge Maple code: >http://www.math.lsa.umich.edu/~jrs/software/SFexamples/LR_rulecombinat;Computes the expansion of the product of Schur polynomials  s[mu]*s[nu] using the Littlewood-Richardson rule. Note: this is symmetric in the two arguments.Based on the wikipedia article 8https://en.wikipedia.org/wiki/Littlewood-Richardson_rule lrMult mu nu == Map.fromList list where lamw = weight nu + weight mu list = [ (lambda, coeff) | lambda <- partitions lamw , let coeff = lrCoeff lambda (mu,nu) , coeff /= 0 ] Nonedcombinat"A box on the border of a partitioncombinatBorder strips (or ribbons) are defined to be skew partitions which are connected and do not contain 2x2 blocks.The length of a border strip is the number of boxes it contains, and its height is defined to be one less than the number of rows (in English notation) it occupies. The width is defined symmetrically to be one less than the number of columns it occupies.combinat%The coordinates of the outer corners combinatThe coordinates of the inner corners, including the two on the two coordinate axes. For the partition [5,4,1] the result should be [(0,5),(1,4),(2,1),(3,0)]combinat&Sequence of all the (extended) cornerscombinatThe inner corner boxes; of the partition. Coordinates are counted from 1 (cf.the  function), and the first coordinate is the row, the second the column (in English notation).For the partition [5,4,1] the result should be  [(1,4),(2,1)] innerCornerBoxes lambda == (tail $ init $ extendedInnerCorners lambda)combinatThe outer corner boxes; of the partition. Coordinates are counted from 1 (cf.the  function), and the first coordinate is the row, the second the column (in English notation).For the partition [5,4,1] the result should be [(1,5),(2,4),(3,1)]combinatThe outer and inner corner boxes interleaved, so together they form the turning points of the full border stripcombinat(Naive (and very slow) implementation of innerCornerBoxes, for testing purposescombinat(Naive (and very slow) implementation of outerCornerBoxes, for testing purposescombinatA skew partition is a a ribbon (or border strip) if and only if projected to the diagonals the result is an interval.combinatRibbons (or border strips) are defined to be skew partitions which are connected and do not contain 2x2 blocks. This function returns the border strips whose outer partition is the given one.combinat4Inner border strips (or ribbons) of the given lengthcombinatHooks of length n% (TODO: move to the partition module)combinat4Outer border strips (or ribbons) of the given lengthcombinat?Naive (and slow) implementation listing all inner border stripscombinatNaive (and slow) implementation listing all inner border strips of the given lengthcombinatNaive (and slow) implementation listing all outer border strips of the given lengthcombinatThe boxes of the full inner border strip, annotated with whether a border strip can start or end there.combinatThe boxes of the full outer border strip, annotated with whether a border strip can start or end there.NonecombinatA partition of the set [1..n] (in standard order)combinatThe "shape" of a set partition is the partition we get when we forget the set structure, keeping only the cardinalities.combinat Synonym for combinat Synonym for  sort (setPartitionsWithKParts k n) == sort [ p | p <- setPartitions n , numberOfParts p == k ]combinatList all set partitions of [1..n], naive algorithmcombinatSet partitions of the set [1..n] into k partscombinat.Set partitions are counted by the Bell numberscombinatSet partitions of size k3 are counted by the Stirling numbers of second kindcombinatk = number of partscombinatn = size of the setcombinatk = number of partscombinatn = size of the setcombinatk = number of partscombinatn = size of the set,NoneNonecombinatA plane partition encoded as a tablaeu (the "Z" heights are the numbers)combinat9Throws an exception if the input is not a plane partitioncombinatThe XY projected shape of a plane partition, as an integer partitioncombinat!The Z height of a plane partitioncombinatStacks layers of partitions into a plane partition. Throws an exception if they do not form a plane partition.combinatStacks layers of partitions into a plane partition. This is unsafe in the sense that we don't check that the partitions fit on the top of each other.combinat0The "layers" of a plane partition (in direction Z). We should have ,unsafeStackLayers (planePartLayers pp) == ppcombinat"Plane partitions of a given weight   Nonex'combinatThe series [1,0,0,0,0,...], which is the neutral element for the convolution.combinatConstant zero seriescombinat-Power series representing a constant functioncombinat9The power series representation of the identity function xcombinat#The power series representation of x^ncombinat'A different implementation, taken from:0M. Douglas McIlroy: Power Series, Power Serious combinatMultiplication of power series. This implementation is a synonym for combinatConvolution of series (that is, multiplication of power series). The result is always an infinite list. Warning: This is slow!combinat3Convolution (= product) of many series. Still slow!combinatDivision of series.+(!combinatA lattice path is a path using only the allowed steps, never going below the zero level line y=0. Note that if you rotate such a path by 45 degrees counterclockwise, you get a path which uses only the steps (1,0) and (0,1), and stays above the main diagonal (hence the name, we just use a different convention).combinatA step in a lattice pathcombinat the step (1,1)combinat the step (1,-1)combinat5Draws the path into a list of lines. For example try: =autotabulate RowMajor (Right 5) (map asciiPath $ dyckPaths 4)combinat=A lattice path is called "valid", if it never goes below the y=0 line.combinat;A Dyck path is a lattice path whose last point lies on the y=0 linecombinat Maximal height of a lattice pathcombinat.Endpoint of a lattice path, which starts from (0,0).combinatReturns the coordinates of the path (excluding the starting point (0,0), but including the endpoint)combinatCounts the up-stepscombinatCounts the down-stepscombinat'Counts both the up-steps and down-stepscombinat2Number of peaks of a path (excluding the endpoint)combinat-Number of points on the path which touch the y=00 zero level line (excluding the starting point (0,0), but including the endpoint; that is, for Dyck paths it this is always positive!).combinatNumber of points on the path which touch the level line at height h (excluding the starting point (0,0), but including the endpoint).combinat dyckPaths m lists all Dyck paths from (0,0) to (2m,0). Remark: Dyck paths are obviously in bijection with nested parentheses, and thus also with binary trees.!Order is reverse lexicographical: +sort (dyckPaths m) == reverse (dyckPaths m)combinat dyckPaths m lists all Dyck paths from (0,0) to (2m,0).  .sort (dyckPathsNaive m) == sort (dyckPaths m) *Naive recursive algorithm, order is ad-hoccombinatThe number of Dyck paths from (0,0) to (2m,0)# is simply the m'th Catalan number.combinatThe trivial bijectioncombinat,The trivial bijection in the other directioncombinatboundedDyckPaths h m lists all Dyck paths from (0,0) to (2m,0) whose height is at most h. Synonym for .combinatboundedDyckPathsNaive h m lists all Dyck paths from (0,0) to (2m,0) whose height is at most h. sort (boundedDyckPaths h m) == sort [ p | p <- dyckPaths m , pathHeight p <= h ] sort (boundedDyckPaths m m) == sort (dyckPaths m) ]Acombinat8Adds unique labels to the nodes (including leaves) of a combinat8Adds unique labels to the nodes (including leaves) of a .combinatregularNaryTrees d n' returns the list of (rooted) trees on n$ nodes where each node has exactly d0 children. Note that the leaves do not count in n. Naive algorithm.combinatTernary trees on n nodes (synonym for regularNaryTrees 3)combinatWe have length (regularNaryTrees d n) == countRegularNaryTrees d n == \frac {1} {(d-1)n+1} \binom {dn} {n} combinat %# = \frac {1} {(2n+1} \binom {3n} {n}combinat All trees on n nodes where the number of children of all nodes is in element of the given set. Example: autoTabulate RowMajor (Right 5) $ map asciiTreeVertical $ map labelNChildrenTree_ $ semiRegularTrees [2,3] 2 [ length $ semiRegularTrees [2,3] n | n<-[0..] ] == [1,2,10,66,498,4066,34970,312066,2862562,26824386,...](The latter sequence is A027307 in OEIS: https://oeis.org/A027307Remark: clearly, we have .semiRegularTrees [d] n == regularNaryTrees d ncombinat:Vertical ASCII drawing of a tree, without labels. Example: autoTabulate RowMajor (Right 5) $ map asciiTreeVertical_ $ regularNaryTrees 2 4 Nodes are denoted by @ , leaves by *.combinatPrints all labels. Example: asciiTreeVertical $ addUniqueLabelsTree_ $ (regularNaryTrees 3 9) !! 666Nodes are denoted by (label) , leaves by label.combinat9Prints the labels for the leaves, but not for the nodes.combinatThe leftmost spine (the second element of the pair is the leaf node)combinat(The leftmost spine without the leaf nodecombinat/The length (number of edges) on the left spine 0leftSpineLength tree == length (leftSpine_ tree)combinat  is leaf,   is nodecombinat=Attaches the depth to each node. The depth of the root is 0. combinat.Attaches the number of children to each node. combinatComputes the set of equivalence classes of rooted 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?combinat(degree = number of children of each nodecombinatnumber of nodescombinat!set of allowed number of childrencombinatnumber of nodes8 ,-None^  %NonedcombinatVenn diagrams of n= sets. Each possible zone is annotated with a value of type a. A typical use case is to annotate with the cardinality of the given zone./Internally this is representated by a map from [Bool], where True means element of the set, False means not.TODO: write a more efficient implementation (for example an array of size 2^n)combinat%How many sets are in the Venn diagramcombinat&How many zones are in the Venn diagram =vennDiagramNumberOfZones v == 2 ^ (vennDiagramNumberOfSets v)combinat How many nonempty zones are in the Venn diagramcombinatWe call venn diagram trivial if all the intersection zones has zero cardinality (that is, the original sets are all disjoint)combinatGiven a Venn diagram of cardinalities, we compute the cardinalities of the original sets (note: this is slow!)combinatGiven the cardinalities of some finite sets, we list all possible Venn diagrams.Note: we don't include the empty zone in the tables, because it's always empty.Remark: if each sets is a singleton set, we get back set partitions: > [ length $ enumerateVennDiagrams $ replicate k 1 | k<-[1..8] ] [1,2,5,15,52,203,877,4140] > [ countSetPartitions k | k<-[1..8] ] [1,2,5,15,52,203,877,4140]/Maybe this could be called multiset-partitions?Example: autoTabulate RowMajor (Right 6) $ map ascii $ enumerateVennDiagrams [2,3,3]  &None&j combinatSimulated newtype constructor combinatPattern sysnonyms allows us to use existing code with minimal modificationscombinatThe lexicographic orderingcombinat !partitionTail p == snd (uncons p)combinatWe assume that x >= partitionHeight p!combinat?We assume that the element is not bigger than the last element!combinatWidth, or the number of partscombinat3Height, or the first (that is, the largest) elementcombinatWidth and height combinatFrom a non-increasing sequence  [a1,a2,..,an], this computes the sequence of differences [a1-a2,a2-a3,...,an-0]combinatFrom a non-increasing sequence  [a1,a2,..,an]5 this computes the reversed sequence of differences 7[ a[n]-0 , a[n-1]-a[n] , ... , a[2]-a[3] , a[1]-a[2] ] combinat*returns a descending (non-increasing) listcombinat3Returns a reversed (ascending; non-decreasing) listcombinat5We assume that the input is a non-increasing list of positive integers!combinat q  pcombinatExpands to product s[lambda]*h[k] as a sum of s[mu]-s. See -https://en.wikipedia.org/wiki/Pieri's_formulacombinatlengthcombinatthe list''.Nonej  UVWX[YZ\_]^`abecdfighjklmnopqrstuvwxyz{|}~None ./pUcombinat/Hide the type parameter of a functor. Example:  Some BraidcombinatUses the value inside a combinatMonadic version of combinatGiven a polymorphic value, we select at run time the one specified by the second argumentcombinatMonadic version of combinatCombination of  and : we make a temporary structure of the given size, but we immediately consume it.combinat(Half-)monadic version of 'None /23combinat3Sometimes we want to hide the type-level parameter n, for example when dynamically creating braids whose size is known only at runtime.combinatThe braid group B_n on n strands. The number n: is encoded as a type level natural in the type parameter.Braids are represented as words in the standard generators and their inverses.combinat'A standard Artin generator of a braid: Sigma i- represents twisting the neighbour strands i and (i+1), such that strand i goes under strand (i+1).Note: The strands are numbered 1..n.combinati goes under (i+1)combinati goes above (i+1)combinatThe strand (more precisely, the first of the two strands) the generator twistescombinat The inverse of a braid generatorcombinat"The number of strands in the braidcombinat:Embeds a smaller braid group into a bigger braid group combinatApply "free reduction" to the word, that is, iteratively remove sigma_i sigma_i^-1 pairs. The resulting braid is clearly equivalent to the original.combinatThe braid generator sigma_i as a braidcombinatThe braid generator  sigma_i^(-1) as a braidcombinatdoubleSigma s t (for s > (None// combinat,A unique normal form for braids, called the left-greedy normal form. It looks like  Delta^i*P, where Delta is the positive half-twist, i is an integer, and P> is a positive word, which can be further decomposed into non-Delta permutation words; these words themselves are not unique, but the permutations they realize are unique.This will solve the word problem relatively fast, though it is not the fastest known algorithm. combinatthe exponent of Delta combinatthe permutations combinat/A braid word representing the given normal form combinatComputes the normal form of a braid. We apply free reduction first, it should be faster that way. combinatThis function does not apply free reduction before computing the normal form combinatThis one uses the naive inverse replacement method. Probably somewhat slower than  . combinatThe  starting set( of a positive braid P is the subset of [1..n-1] defined by S(P) = [ i | P = sigma_i * Q , Q is positive ] = [ i | (sigma_i^-1 * P) is positive ] This function returns the starting set a positive word, assuming it is a permutation braid (see Lemma 2.4 in [2]) combinatThe  finishing set( of a positive braid P is the subset of [1..n-1] defined by F(P) = [ i | P = Q * sigma_i , Q is positive ] = [ i | (P * sigma_i^-1) is positive ] This function returns the finishing set, assuming the input is a permutation braid combinatThis satisfies permutationStartingSet p == permWordStartingSet n (_permutationBraid p) combinatThis satisfies permutationFinishingSet p == permWordFinishingSet n (_permutationBraid p) /01/02/02345346347348349:;<=>?@ABCDEFGHIJKLMNOOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~                                                           8                                                   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!""""""""""""""""""""""""############################################$$$$$$$$$$$                                    %%%%%%%%%%%%%%%%%&&&&&&&&&&&N&M&&&&&&&&I&G&&&&&&&&&&&&&&&U&&&&&&''''''''''''''''''''''''''''''''''' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( /  /  /  34 34 34 34 34 34 34 34 34 34 34   (combinat-0.2.10.0-8zxIzTLqomRBUoKOhCxncMMath.Combinat.TypeLevelMath.Combinat.Trees.BinaryMath.Combinat.ClassesMath.Combinat.HelperMath.Combinat.ASCIIMath.Combinat.Numbers.IntegersMath.Combinat.Partitions.Vector!Math.Combinat.Partitions.MultisetMath.Combinat.SignMath.Combinat.Trees.NaryMath.Combinat.Trees.GraphvizMath.Combinat.TuplesMath.Combinat.Numbers.PrimesMath.Combinat.Numbers.SequencesMath.Combinat.Groups.Thompson.FMath.Combinat.SetsMath.Combinat.RootSystemsMath.Combinat.Permutations&Math.Combinat.Partitions.Integer.Count(Math.Combinat.Partitions.Integer.IntList&Math.Combinat.Partitions.Integer.Naive Math.Combinat.Partitions.IntegerMath.Combinat.Tableaux*Math.Combinat.Tableaux.GelfandTsetlin.Cone%Math.Combinat.Tableaux.GelfandTsetlinMath.Combinat.Partitions.SkewMath.Combinat.Tableaux.Skew+Math.Combinat.Tableaux.LittlewoodRichardson$Math.Combinat.Partitions.Skew.RibbonMath.Combinat.Partitions.SetMath.Combinat.Partitions.PlaneMath.Combinat.Numbers.SeriesMath.Combinat.LatticePaths$Math.Combinat.Partitions.NonCrossingMath.Combinat.Groups.FreeMath.Combinat.CompositionsMath.Combinat.Sets.VennDiagrams(Math.Combinat.Partitions.Integer.CompactMath.Combinat.Groups.BraidMath.Combinat.Groups.Braid.NFSystemRandomMath.Combinat.NumbersMath.Combinat.PartitionsMath.Combinat.Trees Math.Combinatbase Data.Proxy asProxyTypeOfProxycontainers-0.6.2.1 Data.Tree subForest rootLabelNodeTreeForestHasNumberOfCyclesnumberOfCyclesHasNumberOfLeavesnumberOfLeavesHasNumberOfNodes numberOfNodesHasShapeshape HasDualitydual HasWeightweight HasHeightheightHasWidthwidthHasNumberOfParts numberOfParts CanBeEmptyisEmptyemptyRandTRanddebugswappairs pairsWithsum' interleaveevensoddsproductInterleaved productFromToproductFromToStride2equatingreverseOrderingreverseComparingreverseCompare reverseSort groupSortBynubOrdisWeaklyIncreasingisStrictlyIncreasingisWeaklyDecreasingisStrictlyDecreasing mapWithLast mapWithFirstmapWithFirstLastmkLinesUniformWidthmkBlocksUniformHeightmkUniformBlocks hConcatLines vConcatLinescount histogramfromJust intToBool boolToIntnestunfold1unfold unfoldEitherunfoldM mapAccumM longZipWithrunRand flipRunRandrunRandT flipRunRandTrandrandRoll randChoose randProxy1$fFunctorRandT$fApplicativeRandT $fMonadRandT MatrixOrderRowMajorColMajorVSep VSepEmpty VSepSpaces VSepStringHSep HSepEmpty HSepSpaces HSepString AlignmentAlignVAlignVTopVCenterVBottomHAlignHLeftHCenterHRight DrawASCIIasciiASCII asciiSize asciiLines emptyRect asciiXSize asciiYSize asciiString printASCIIasciiFromLinesasciiFromStringhSepSize hSepStringvSepSize vSepString|||===hCatTophCatBotvCatLeft vCatRighthCatWithvCatWithhPadvPadpad hExtendTo vExtendTo hExtendWith vExtendWithhIndentvIndenthCutvCut pasteOnto pasteOnto' pasteOntoRel pasteOntoRel'tabulate autoTabulatecaptioncaption'asciiBoxroundedAsciiBox filledBoxtransparentBox asciiNumber asciiShow $fShowASCII$fEqMatrixOrder$fOrdMatrixOrder$fShowMatrixOrder$fReadMatrixOrder $fShowVSep $fShowHSep $fEqVAlign $fShowVAlign $fEqHAlign $fShowHAlign integerLog2 ceilingLog2isSquareintegerSquareRootceilingSquareRootintegerSquareRoot'integerSquareRootNewton' IntVectorvectorPartitions_vectorPartitionsfasc3B_algorithm_MpartitionMultisetSignPlusMinusisPlusisMinus signValuesigned paritySignparitySignValue negateIfOdd oppositeSignmulSignproductOfSigns $fRandomSign $fMonoidSign$fSemigroupSign$fEqSign $fOrdSign $fShowSign $fReadSignBinTree'Branch'Leaf'BinTreeBranchLeafaddUniqueLabelsForest_addUniqueLabelsTree_addUniqueLabelsForestaddUniqueLabelsTreeDotgraphvizDotBinTreegraphvizDotBinTree'graphvizDotForestgraphvizDotTreetuples'tuples1' countTuples' countTuples1'tuplestuples1 countTuples countTuples1 binaryTuplesdivides moebiusMuliouvilleLambda divisorSum divisorSum' eulerTotientdivisorssquareFreeDivisorssquareFreeDivisors_primes primesSimple primesTMWE factorizefactorizeNaiveproductOfFactorsgroupIntegerFactorsintegerFactorsTrialDivisionpowerModmillerRabinPrimalityTestisProbablyPrimeisVeryProbablyPrime factorialfactorialSplitfactorialNaivefactorialSwingfactorialPrimeExponentsfactorialPrimeExponentsNaivefactorialPrimeExponents_swingFactorialExponents_doubleFactorialdoubleFactorialSplitdoubleFactorialNaivebinomial binomialSplit binomialNaivesignedBinomial pascalRow multinomialcatalancatalanTrianglesignedStirling1stArraysignedStirling1stunsignedStirling1st stirling2nd bernoullibellNumbersArray bellNumberParen LeftParen RightParenleafgraftforgetNodeDecorationsenumerateLeaves_enumerateLeaves'enumerateLeaves toRoseTree toRoseTree'parenthesesToStringstringToParenthesesforestToNestedParenthesesforestToBinaryTreenestedParenthesesToForestnestedParenthesesToForestUnsafenestedParenthesesToBinaryTree#nestedParenthesesToBinaryTreeUnsafebinaryTreeToNestedParenthesesbinaryTreeToForestnestedParenthesesrandomNestedParenthesesnthNestedParenthesescountNestedParenthesesfasc4A_algorithm_Pfasc4A_algorithm_Wfasc4A_algorithm_U binaryTreescountBinaryTreesbinaryTreesNaiverandomBinaryTreefasc4A_algorithm_RasciiBinaryTree_$fDrawASCIIBinTree$fMonadBinTree$fApplicativeBinTree$fTraversableBinTree$fFoldableBinTree$fFunctorBinTree$fHasNumberOfLeavesBinTree$fHasNumberOfNodesBinTree$fHasNumberOfLeavesBinTree'$fHasNumberOfNodesBinTree' $fEqParen $fOrdParen $fShowParen $fReadParen $fEqBinTree' $fOrdBinTree'$fShowBinTree'$fReadBinTree' $fEqBinTree $fOrdBinTree $fShowBinTree $fReadBinTreeTTDiag_width_domain_rangeX1X0CtBrLfmkTDiagmkTDiagDontReduce isValidTDiag isPositive isReducedx0x1xkidentitypositiveinverse equivalentreduce treeCaretList removeCaretscomposecomposeDontReduceextensionToCommonTree subdivision1 subdivision2 listGraftbranchcarettreeNumberOfLeaves treeWidth enumerate_ enumerate rightVineleftVineflipTree toBinTree fromBinTreeasciiTasciiT' asciiTLabels asciiTLabels' asciiTDiag$fHasWidthTree$fHasNumberOfLeavesTree$fDrawASCIITree$fHasWidthTDiag$fDrawASCIITDiag $fEqTDiag $fOrdTDiag $fShowTDiag$fEqTree $fOrdTree $fShowTree $fFunctorTreechoose_choosechoose'choose'' chooseTaggedcombinetuplesFromList listTensor kSublistscountKSublistssublists countSublists randomChoiceDynkinABCDE6E7E8F4G2HalfVecHalfInthalfdivByTwomulByTwoscaleByscaleVec negateVecsafeZip ambientDim simpleRootsOfpositiveRootsOfnegativeRootsOf allRootsOffindPositiveHyperplane positiveRootsbasisOfPositivesbracketmirror cartanMatrix printMatrix mirrorClosure mirrorStepsimpleRootsE6_123simpleRootsE7_12simpleRootsE7_diagsimpleRootsE8_evensimpleRootsE8_odd $fNumHalfInt $fShowHalfInt$fNum[] $fEqDynkin $fShowDynkin $fEqHalfInt $fOrdHalfIntDisjointCycles PermutationfromPermutationpermutationUArraypermutationArraytoPermutationUnsafetoPermutationUnsafeNuarrayToPermutationUnsafe isPermutationmaybePermutation toPermutationpermutationSizelookupPermutation!!!isIdentityPermutationconcatPermutationsasciiPermutationasciiDisjointCyclestwoLineNotationinverseTwoLineNotationgenericTwoLineNotationfromDisjointCyclesdisjointCyclesUnsafedisjointCyclesToPermutationpermutationToDisjointCyclesisEvenPermutationisOddPermutationsignOfPermutationsignValueOfPermutationisCyclicPermutation inversionsnumberOfInversionsnumberOfInversionsMergenumberOfInversionsNaive bubbleSort2 bubbleSortreversePermutationisReversePermutation transpositiontranspositionsadjacentTranspositionadjacentTranspositions cycleLeft cycleRightmultiplyPermutationinversePermutationidentityPermutationproductOfPermutationsproductOfPermutations' permuteArray permuteListpermuteArrayRightpermuteListRightpermuteArrayLeftpermuteListLeftsortingPermutationAscsortingPermutationDesc permutations _permutationspermutationsNaive_permutationsNaivecountPermutationsrandomPermutation_randomPermutationrandomCyclicPermutation_randomCyclicPermutationrandomPermutationDurstenfeldrandomCyclicPermutationSattolopermuteMultisetcountPermuteMultisetfasc2B_algorithm_L$fHasNumberOfCyclesPermutation$fHasWidthPermutation$fDrawASCIIPermutation$fReadPermutation$fShowPermutation!$fHasNumberOfCyclesDisjointCycles$fDrawASCIIDisjointCycles$fEqDisjointCycles$fOrdDisjointCycles$fShowDisjointCycles$fReadDisjointCycles$fEqPermutation$fOrdPermutationTableOfIntegers lookupIntegermakeTableOfIntegerscountPartitionscountPartitionsInfiniteProductcountPartitionsNaivepartitionCountTablepartitionCountList!partitionCountListInfiniteProductpartitionCountListNaivecountAllPartitionscountAllPartitions'countPartitions'countPartitionsWithKParts _mkPartition _isPartition_dualPartition_dualPartitionNaive _diffSequence _elements_toExponentialForm_fromExponentialForm _partitions_allPartitions_allPartitionsGrouped _partitions'_randomPartition_randomPartitions _dominates_dominatedPartitions_dominatingPartitions_partitionsWithKParts_partitionsWithOddParts_partitionsWithDistinctParts_isSubPartitionOf_isSuperPartitionOf_subPartitions_allSubPartitions_superPartitions _pieriRule_dualPieriRule PartitionLengthTailHead Partition_ConsNiltoListfromListfromListUnsafeisEmptyPartitionemptyPartitionpartitionHeightpartitionWidth heightWidthpartitionWeight dualPartitionelementstoExponentialFormfromExponentialForm diffSequenceunconsPartition toDescList dominatesisSubPartitionOfisSuperPartitionOf pieriRule dualPieriRule$fHasDualityPartition$fHasWeightPartition$fHasWidthPartition$fHasHeightPartition$fCanBeEmptyPartition$fHasNumberOfPartsPartition $fEqPartition$fOrdPartition$fShowPartition$fReadPartitionPartitionConventionEnglishNotationEnglishNotationCCWFrenchNotationConjLex fromPartition mkPartition toPartitiontoPartitionUnsafe isPartitiontoExponentVectorfromExponentVectordropTailingZerosunionOfPartitionssumOfPartitions partitions partitions' allPartitionsallPartitionsGroupedallPartitions'allPartitionsGrouped'randomPartitionrandomPartitionsdominanceComparedominatedPartitionsdominatingPartitionsconjugateLexicographicCompare fromConjLexpartitionsWithKPartspartitionsWithOddPartspartitionsWithDistinctParts subPartitionsallSubPartitionssuperPartitionsasciiFerrersDiagramasciiFerrersDiagram'$fDrawASCIIPartition $fOrdConjLex$fEqPartitionConvention$fShowPartitionConvention $fEqConjLex $fShowConjLexTableau asciiTableau _tableauShape tableauShape tableauWeight dualTableautableauContenthooks hookLengthsrowWordrowWordToTableau columnWordcolumnWordToTableau isLatticeWordisSemiStandardTableausemiStandardYoungTableauxcountSemiStandardYoungTableauxisStandardTableaustandardYoungTableauxcountStandardYoungTableaux$fHasDuality[] $fHasWeight[]$fHasShape[]Partition $fDrawASCII[]$fCanBeEmpty[]TriunTriTriangularArraytriangularArrayUnsafefromTriangularArrayasciiTriangularArraygtSimplexContent_gtSimplexContentgtSimplexTableaux_gtSimplexTableauxcountGTSimplexTableauxinvertGTSimplexTableau_invertGTSimplexTableau$fIxTri$fDrawASCIIArray$fEqHole $fOrdHole $fShowHole$fEqTri$fOrdTri $fShowTriGT kostkaNumberkostkaNumberReferenceNaivekostkaNumbersWithGivenLambdakostkaNumbersWithGivenMuasciiGTkostkaGelfandTsetlinPatternskostkaGelfandTsetlinPatterns'!countKostkaGelfandTsetlinPatternsiteratedPieriRuleiteratedPieriRule'iteratedPieriRule''iteratedDualPieriRuleiteratedDualPieriRule'iteratedDualPieriRule'' SkewPartitionmkSkewPartitionsafeSkewPartitionskewPartitionWeightnormalizeSkewPartitionfromSkewPartitionouterPartitioninnerPartitiondualSkewPartitionskewPartitionElementsskewPartitionsWithOuterShapeallSkewPartitionsWithOuterShapeskewPartitionsWithInnerShapeasciiSkewFerrersDiagramasciiSkewFerrersDiagram'$fDrawASCIISkewPartition$fHasDualitySkewPartition$fHasWeightSkewPartition$fEqSkewPartition$fOrdSkewPartition$fShowSkewPartition SkewTableauskewTableauShapeskewTableauWeightdualSkewTableauisSemiStandardSkewTableauisStandardSkewTableausemiStandardSkewTableauxasciiSkewTableauasciiSkewTableau'skewTableauRowWordskewTableauColumnWordfillSkewPartitionWithRowWordfillSkewPartitionWithColumnWordskewTableauRowContent$fDrawASCIISkewTableau$fHasDualitySkewTableau$fHasWeightSkewTableau"$fHasShapeSkewTableauSkewPartition$fFunctorSkewTableau$fEqSkewTableau$fOrdSkewTableau$fShowSkewTableau lrRuleNaivelrRule_lrRulelrCoefflrCoeff'lrScalar _lrScalarlrMult BorderBox_canStartStrip _canEndStrip_yCoord_xCoordRibbonrbShaperbLengthrbHeightrbWidth outerCornersextendedInnerCornersextendedCornerSequenceinnerCornerBoxesouterCornerBoxescornerBoxSequenceinnerCornerBoxesNaiveouterCornerBoxesNaiveisRibbontoRibbon innerRibbonsinnerRibbonsOfLength listHooksouterRibbonsOfLengthinnerRibbonsNaiveinnerRibbonsOfLengthNaiveouterRibbonsOfLengthNaiveannotatedInnerBorderStripannotatedOuterBorderStrip$fShowBorderBox $fEqRibbon $fOrdRibbon $fShowRibbon SetPartition_standardizeSetPartitionfromSetPartitiontoSetPartitionUnsafetoSetPartition_isSetPartitionsetPartitionShape setPartitionssetPartitionsWithKPartssetPartitionsNaivesetPartitionsWithKPartsNaivecountSetPartitionscountSetPartitionsWithKParts$fHasNumberOfPartsSetPartition$fEqSetPartition$fOrdSetPartition$fShowSetPartition$fReadSetPartition PlanePart fromPlanePartisValidPlanePart toPlanePartplanePartShapeplanePartZHeightplanePartWeight singleLayer stackLayersunsafeStackLayersplanePartLayersplanePartitions$fHasWeightPlanePart$fCanBeEmptyPlanePart $fEqPlanePart$fOrdPlanePart$fShowPlanePart unitSeries zeroSeries constSeriesidSeries powerTerm addSeries sumSeries subSeries negateSeries scaleSeries mulSeriesmulSeriesNaiveproductOfSeriesconvolve convolveMany divSeriesreciprocalSeriesintegralReciprocalSeries composeSeries substitutecomposeSeriesNaivesubstituteNaivelagrangeInversion lagrangeCoeffintegralLagrangeInversionNaivelagrangeInversionNaivedifferentiateSeriesintegrateSeries expSeries cosSeries sinSeries cosSeries2 sinSeries2 coshSeries sinhSeries log1Series dyckSeries coinSeries coinSeries'convolveWithCoinSeriesconvolveWithCoinSeries'productPSeriesproductPSeries'convolveWithProductPSeriesconvolveWithProductPSeries'pseriesconvolveWithPSeriespseries'convolveWithPSeries' signedPSeriesconvolveWithSignedPSeries LatticePathStepUpStepDownStep asciiPath isValidPath isDyckPath pathHeight pathEndpointpathCoordinatespathNumberOfUpStepspathNumberOfDownStepspathNumberOfUpDownStepspathNumberOfPeakspathNumberOfZeroTouchespathNumberOfTouches' dyckPathsdyckPathsNaivecountDyckPathsnestedParensToDyckPathdyckPathToNestedParensboundedDyckPathsboundedDyckPathsNaive latticePathslatticePathsNaivecountLatticePathstouchingDyckPathstouchingDyckPathsNaivecountTouchingDyckPathspeakingDyckPathspeakingDyckPathsNaivecountPeakingDyckPathsrandomDyckPath $fHasWidth[] $fHasHeight[]$fEqStep $fOrdStep $fShowStep NonCrossing_isNonCrossing_isNonCrossingUnsafe_standardizeNonCrossingfromNonCrossingtoNonCrossingUnsafe toNonCrossingtoNonCrossingMaybesetPartitionToNonCrossingdyckPathToNonCrossingPartition#dyckPathToNonCrossingPartitionMaybenonCrossingPartitionToDyckPath$_nonCrossingPartitionToDyckPathMaybenonCrossingPartitionsnonCrossingPartitionsWithKPartscountNonCrossingPartitions$countNonCrossingPartitionsWithKPartsrandomNonCrossingPartition$fHasNumberOfPartsNonCrossing$fEqNonCrossing$fOrdNonCrossing$fShowNonCrossing$fReadNonCrossingWord GeneratorGenInvgenIdxgenSign genSignValueabsGenshowGenshowWord inverseGen inverseWordallWords allWordsNoInvrandomGeneratorrandomGeneratorNoInv randomWordrandomWordNoInv multiplyFreeequivalentFreereduceWordFreereduceWordFreeNaivecountIdentityWordsFreecountWordReductionsFree multiplyZ2 multiplyZ3 multiplyZm equivalentZ2 equivalentZ3 equivalentZm reduceWordZ2 reduceWordZ3 reduceWordZmreduceWordZ2NaivereduceWordZ3NaivereduceWordZmNaivecountIdentityWordsZ2countWordReductionsZ2countIdentityWordsZ3NoInv$fFunctorGenerator $fEqGenerator$fOrdGenerator$fShowGenerator$fReadGenerator Composition compositions'countCompositions'allCompositions1allCompositions' compositionscountCompositions compositions1countCompositions1randomCompositionrandomComposition1regularNaryTrees ternaryTreescountRegularNaryTreescountTernaryTreessemiRegularTreesasciiTreeVertical_asciiTreeVerticalasciiTreeVerticalLeavesOnly leftSpine rightSpine leftSpine_ rightSpine_leftSpineLengthrightSpineLengthclassifyTreeNode isTreeLeaf isTreeNode isTreeLeaf_ isTreeNode_treeNodeNumberOfChildrencountTreeNodescountTreeLeavescountTreeLabelsWithcountTreeNodesWithlabelDepthTreelabelDepthForestlabelDepthTree_labelDepthForest_labelNChildrenTreelabelNChildrenForestlabelNChildrenTree_labelNChildrenForest_ derivTrees$fHasNumberOfNodesTree VennDiagram vennTablevennDiagramNumberOfSetsvennDiagramNumberOfZones vennDiagramNumberOfNonemptyZonesunsafeMakeVennDiagramisTrivialVennDiagramprintVennDiagramprettyVennDiagramasciiVennDiagramvennDiagramSetCardinalitiesenumerateVennDiagrams$fDrawASCIIVennDiagram$fEqVennDiagram$fOrdVennDiagram$fShowVennDiagramshowsPrecPartition cmpLexico singletonuncons partitionTailconssnoc widthHeightreverseDiffSequence toAscList fromDescList fromDescList'i2ww2isafeTail descendToZero descendToOneSome proxyUndefproxyOfproxyOf1proxyOf2asProxyTypeOf1typeArgiTypeArgwithSome withSomeM selectSome selectSomeM withSelected withSelectedM SomeBraidBraidBrGenSigmaSigmaInvbrGenIdx brGenSign brGenSignIdxinvBrGennumberOfStrands someBraid withSomeBraidmkBraid withBraid braidWordbraidWordLengthextendfreeReduceBraidWordsigmasigmaInv doubleSigma positiveWord halfTwist _halfTwisttheGarsideBraidtautauPerm composeMany isPureBraidbraidPermutation_braidPermutationisPositiveBraidWordisPermutationBraid_isPermutationBraidpermutationBraid_permutationBraid_permutationBraid' linkingMatrix_linkingMatrix strandLinking bronfmanHbronfmanHsListexpandBronfmanHhorizBraidASCIIhorizBraidASCII'allPositiveBraidWords allBraidWords_allPositiveBraidWords_allBraidWordsrandomBraidWordrandomPositiveBraidWordrandomPerturbBraidWordwithRandomBraidWordwithRandomPositiveBraidWord_randomBraidWord_randomPositiveBraidWord$fDrawASCIIBraid $fShowBraid $fEqBrGen $fOrdBrGen $fShowBrGenBraidNF _nfDeltaExp_nfPerms nfReprWordbraidNormalFormbraidNormalForm'braidNormalFormNaive'permWordStartingSetpermWordFinishingSetpermutationStartingSetpermutationFinishingSet$fEqXGen $fShowXGen $fEqBraidNF $fOrdBraidNF $fShowBraidNF Data.EitherRightLeft GHC.MaybeNothingunfoldForestM_BFunfoldTreeM_BF unfoldForestM unfoldTreeM unfoldForest unfoldTreefoldTreelevelsflatten drawForestdrawTreeghc-prim GHC.TypesTrueFalse