# Generating semistandard Young tableaux in Mathematica?

The Combinatorica package is able to generate standard Young tableau via the command Tableaux. But is there any functionality for generating semistandard Young tableaux (i.e., tableaux in which the entries strictly increase down the columns, but may weakly increase along the rows)? Ideally a command in which one would input a shape (i.e., an integer partition) and a maximum allowed entry, and the output would be a list of semistandard Young tableaux?

Right now my only method is to generate the tableaux in Sage, then find and replace all the square brackets with curly braces, then just paste into Mathematica. But this is silly and case-by-case, since one must repeat the process for each new shape one is interested in; I suspect someone has already figured out a clever way to do this all within Mathematica.

I have a package for this on my GitHub pages. The package is called NewTableaux. The algorithm used for generation is rather fast: it relies on Mathematicas ability to find all paths between two nodes in a directed graph.

The package also has some other classical features (convert to LaTeX, Crystal operators, promotion, RSK).

majorsweak[left_List, right_List] := Block[{le1 = Length[left],
le2 = Length[right]}, If[le2 > le1 || Min[Sign[left - PadRight[right, le1]]] < 0,
False, True]];

right_List] :=  ! (First[right] > First[left] ||
Min[Sign[PadRight[left, Length[right]] - right]] < 1);

solspace[par_List, v_Integer] :=
Block[{tra = TransposePartition[par], it},
it = MapIndexed[Function[{q, i}, Union[(PadRight[#1, q] & ) /@
Partitions[q*(v + 1 - Tr[i]),
v + 1 - Tr[i]]]], par]; MapIndexed[
Cases[#1, q_List /; majorsweak[q, (1 - Tr[#2]) +
Take[tra, par[[Tr[#2]]]]]] & , it]];

SSYT[par_List, v_Integer] :=
Block[{sspace}, sspace = solspace[par, v]; v + 1 -
If[Length[par] === 1, List /@ Flatten[sspace, 1],
Backtrack[sspace,
If[Length[#1] < 2, True, majorsstrong[#1[[-2]], #1[[-1]]]] & ,
True & , All]]];

tableauxForm[yt_List] := (TableForm[#1, TableSpacing -> {1, 1}] & ) /@
yt (* /.  q:{__Integer} :> StringJoin @@ ToString /@ q *);

hooklength[(\[Lambda]_)?Partition1Q] :=
Table[Count[\[Lambda], q_ /; q >= j] + 1 - i + \[Lambda][[i]] - j,
{i, Length[\[Lambda]]}, {j, \[Lambda][[i]]}];

content[(par_)?Partition1Q] :=
Table[j - i, {i, Length[par]}, {j, par[[i]]}];

stanley[(p_)?Partition1Q, t_] := Times @@ ((t + Flatten[content[p]])/
Flatten[hooklength[p]]);


example :

stanley[{3, 2, 1}, 3]
8
SSYT[{3, 2, 1}, 3]
{{{1, 2, 3}, {2, 3}, {3}}, {{1, 2, 2}, {2, 3}, {3}}, {{1, 1, 3}, {2, 3}, {3}}, {{1, 1, 3}, {2, 2}, {3}}, {{1, 1, 2}, {2, 3}, {3}}, {{1, 1, 2}, {2, 2}, {3}}, {{1, 1, 1}, {2, 3}, {3}}, {{1, 1, 1}, {2, 2}, {3}}}