Skip to content

Young diagrams

Partitions and Young diagrams.

A partition \(\lambda = (\lambda_1 \ge \lambda_2 \ge \cdots)\) of \(n\) is drawn as rows of boxes, \(\lambda_i\) boxes in row \(i\). Partitions are plain tuples in weakly decreasing order, and cells are 0-indexed \((i, j)\) pairs. Conjugation transposes the diagram.

The hook of a box is the box itself plus everything to its right and everything below it; its content is \(c(i, j) = j - i\). The two numbers give the dimension formulas of dimensions.

Examples:

>>> from schur_weyl import partitions, partition_conjugate, hook_lenght
>>> [*partitions(4)]
[(4,), (3, 1), (2, 2), (2, 1, 1), (1, 1, 1, 1)]
>>> [*partitions(5, max_part=2)]
[(2, 2, 1), (2, 1, 1, 1), (1, 1, 1, 1, 1)]
>>> partition_conjugate((4, 3, 1))
(3, 2, 2, 1)
>>> hook_lenght((4, 3, 1), 0, 0)
6

partitions

partitions(k: int, max_part: Optional[int] = None, max_height: Optional[int] = None, *, min_height: Optional[int] = None, height: Optional[int] = None) -> Generator[tuple[int, ...], None, None]

Generate the partitions of k. All the non-increasing vectors of positive integers summing to k.

The height of a partition is its number of rows, len(lam). Bounding it is the cheaper way to ask for partitions of a given height: the bounds prune the recursion instead of filtering its output.

Parameters:

Name Type Description Default
k int

The size of the Symmetric group

required
max_part Optional[int]

The maximum number of columns in any row of the Young tableau. Defaults to None.

None
max_height Optional[int]

The maximum number of rows. Defaults to None.

None
min_height Optional[int]

The minimum number of rows. Keyword only. Defaults to None.

None
height Optional[int]

The exact number of rows, i.e. both bounds at once. Keyword only, and mutually exclusive with min_height / max_height. Defaults to None.

None

Yields:

Type Description
Generator[tuple[int, ...], None, None]

The partitions.

Raises:

Type Description
ValueError

If height is combined with min_height or max_height.

Examples:

>>> list(partitions(4))
[(4,), (3, 1), (2, 2), (2, 1, 1), (1, 1, 1, 1)]
>>> list(partitions(5, 2))
[(2, 2, 1), (2, 1, 1, 1), (1, 1, 1, 1, 1)]
>>> list(partitions(5, 2, 4))
[(2, 2, 1), (2, 1, 1, 1)]
>>> list(partitions(5, height=2))
[(4, 1), (3, 2)]
>>> list(partitions(4, min_height=3))
[(2, 1, 1), (1, 1, 1, 1)]
Source code in src/schur_weyl/young_diagrams.py
def partitions(
    k: int,
    max_part: Optional[int] = None,
    max_height: Optional[int] = None,
    *,
    min_height: Optional[int] = None,
    height: Optional[int] = None,
) -> Generator[tuple[int, ...], None, None]:
    """Generate the partitions of k. All the non-increasing vectors of positive integers summing to k.

    The height of a partition is its number of rows, len(lam). Bounding it is the
    cheaper way to ask for partitions of a given height: the bounds prune the
    recursion instead of filtering its output.

    Args:
        k (int):  The size of the Symmetric group
        max_part (Optional[int], optional): The maximum number of columns in any row of the Young tableau. Defaults to None.
        max_height (Optional[int], optional): The maximum number of rows. Defaults to None.
        min_height (Optional[int], optional): The minimum number of rows. Keyword only. Defaults to None.
        height (Optional[int], optional): The exact number of rows, i.e. both bounds at once. Keyword
            only, and mutually exclusive with min_height / max_height. Defaults to None.

    Yields:
        Generator[tuple[int, ...], None, None]: The partitions.

    Raises:
        ValueError: If height is combined with min_height or max_height.

    Examples:
        >>> list(partitions(4))
        [(4,), (3, 1), (2, 2), (2, 1, 1), (1, 1, 1, 1)]

        >>> list(partitions(5, 2))
        [(2, 2, 1), (2, 1, 1, 1), (1, 1, 1, 1, 1)]

        >>> list(partitions(5, 2, 4))
        [(2, 2, 1), (2, 1, 1, 1)]

        >>> list(partitions(5, height=2))
        [(4, 1), (3, 2)]

        >>> list(partitions(4, min_height=3))
        [(2, 1, 1), (1, 1, 1, 1)]
    """
    if height is not None:
        if min_height is not None or max_height is not None:
            raise ValueError("height is exclusive with min_height / max_height")
        min_height = max_height = height
    if max_part is None:
        max_part = k
    if max_height is None:
        max_height = k
    if min_height is None:
        min_height = 0
    if k == 0:
        if min_height <= 0:
            yield ()
        return
    if max_height <= 0 or k < min_height:
        return

    for first in range(min(k, max_part), 0, -1):
        for rest in partitions(k - first, first, max_height - 1, min_height=min_height - 1):
            yield (first,) + rest

partition_conjugate

partition_conjugate(lam: tuple[int, ...]) -> tuple[int, ...]

Take the conjugate of a partition. Flip/Transpose a Young tableau accross its main diagonal

Parameters:

Name Type Description Default
lam tuple[int, ...]

The partition

required

Returns:

Type Description
tuple[int, ...]

Its conjugate

Examples:

>>> partition_conjugate((4, 3, 1))
(3, 2, 2, 1)
>>> partition_conjugate(())
()
Source code in src/schur_weyl/young_diagrams.py
def partition_conjugate(lam: tuple[int, ...]) -> tuple[int, ...]:
    """Take the conjugate of a partition. Flip/Transpose a Young tableau accross its main diagonal

    Args:
        lam (tuple[int, ...]): The partition

    Returns:
        tuple[int, ...]: Its conjugate

    Examples:
        >>> partition_conjugate((4, 3, 1))
        (3, 2, 2, 1)
        >>> partition_conjugate(())
        ()
    """
    if not lam:
        return ()
    result: list[int] = [0] * lam[0]
    for p in lam:
        for j in range(p):
            result[j] += 1
    return tuple(result)

hook_lenght

hook_lenght(lam: tuple[int, ...], i: int, j: int) -> int

The hook lenght at index ()

Parameters:

Name Type Description Default
lam tuple[int, ...]

The partition

required
i int

the row index (0-indexed)

required
j int

the column index (0-indexed)

required

Returns: int: The hook lenght

Examples:

>>> hook_lenght((4, 3, 1), 0, 0)
6
>>> hook_lenght((4, 3, 3, 2), 2, 1)
3
Source code in src/schur_weyl/young_diagrams.py
def hook_lenght(lam: tuple[int, ...], i: int, j: int) -> int:
    """The hook lenght at index ()

    Args:
        lam (tuple[int, ...]): The partition
        i (int): the row index (0-indexed)
        j (int): the column index (0-indexed)
    Returns:
        int: The hook lenght

    Examples:
        >>> hook_lenght((4, 3, 1), 0, 0)
        6
        >>> hook_lenght((4, 3, 3, 2), 2, 1)
        3
    """
    return (lam[i] - j) + sum(1 for l in range(i + 1, len(lam)) if lam[l] > j)  # (arm + 1) + leg

cells

cells(lam: tuple[int, ...]) -> Generator[tuple[int, int], None, None]

All the cells index of a partition

Parameters:

Name Type Description Default
lam tuple[int, ...]

The partition

required

Yields:

Type Description
Generator[tuple[int, int], None, None]

the indexes (0-indexed)

Examples:

>>> list(cells((3, 2, 1)))
[(0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (2, 0)]
Source code in src/schur_weyl/young_diagrams.py
def cells(lam: tuple[int, ...]) -> Generator[tuple[int, int], None, None]:
    """All the cells index of a partition

    Args:
        lam (tuple[int, ...]): The partition

    Yields:
        Generator[tuple[int, int], None, None]: the indexes (0-indexed)

    Examples:
        >>> list(cells((3, 2, 1)))
        [(0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (2, 0)]
    """
    for i in range(len(lam)):
        for j in range(lam[i]):
            yield (i, j)

majorizes

majorizes(lam: tuple[int, ...], nu: tuple[int, ...]) -> bool

Check if lam majorizes nu

Parameters:

Name Type Description Default
lam tuple[int, ...]

a partition

required
nu tuple[int, ...]

a partition of the same size as lambda. Otherwise the result is undefined

required

Returns:

Type Description
bool

True if lam majorizes nu

Examples:

>>> majorizes((3, 3), (4, 1, 1))
False
>>> majorizes((4, 1, 1), (3, 3))
False
>>> majorizes((3, 1, 1, 1), (2, 2, 1, 1))
True
>>> majorizes((2, 1), (2, 1))
True
Source code in src/schur_weyl/young_diagrams.py
def majorizes(lam: tuple[int, ...], nu: tuple[int, ...]) -> bool:
    """Check if lam majorizes nu

    Args:
        lam (tuple[int, ...]): a partition
        nu (tuple[int, ...]): a partition of the same size as lambda. Otherwise the result is undefined

    Returns:
        bool: True if lam majorizes nu

    Examples:
        >>> majorizes((3, 3), (4, 1, 1))
        False
        >>> majorizes((4, 1, 1), (3, 3))
        False
        >>> majorizes((3, 1, 1, 1), (2, 2, 1, 1))
        True
        >>> majorizes((2, 1), (2, 1))
        True
    """
    if len(nu) < len(lam):
        return False
    c_lam, c_nu = 0, 0
    for i in range(len(lam)):
        c_lam += lam[i]
        c_nu += nu[i]
        if not c_lam >= c_nu:
            return False
    return True

addable_corners

addable_corners(lam: tuple[int, ...]) -> Generator[tuple[int, int], None, None]

The cells that can be added to still obtain a valid partition

Parameters:

Name Type Description Default
lam tuple[int, ...]

The partition

required

Yields:

Type Description
Generator[tuple[int, int], None, None]

The indexes of the cells

Examples:

>>> list(addable_corners((2, 2, 1)))
[(0, 2), (2, 1), (3, 0)]
Source code in src/schur_weyl/young_diagrams.py
def addable_corners(lam: tuple[int, ...]) -> Generator[tuple[int, int], None, None]:
    """The cells that can be added to still obtain a valid partition

    Args:
        lam (tuple[int, ...]): The partition

    Yields:
        Generator[tuple[int, int], None, None]: The indexes of the cells

    Examples:
        >>> list(addable_corners((2, 2, 1)))
        [(0, 2), (2, 1), (3, 0)]

    """
    if not lam:
        yield (0, 0)
        return
    yield 0, lam[0]
    for i in range(1, len(lam)):
        if lam[i] != lam[i - 1]:
            yield i, lam[i]
    yield len(lam), 0

removable_corners

removable_corners(lam: tuple[int, ...]) -> Generator[tuple[int, int], None, None]

The cells that can be removed to still obtain a valid partition

Parameters:

Name Type Description Default
lam tuple[int, ...]

The partition

required

Yields:

Type Description
Generator[tuple[int, int], None, None]

The indexes of the cells

Examples:

>>> list(removable_corners((2, 2, 1)))
[(2, 0), (1, 1)]
Source code in src/schur_weyl/young_diagrams.py
def removable_corners(lam: tuple[int, ...]) -> Generator[tuple[int, int], None, None]:
    """The cells that can be removed to still obtain a valid partition

    Args:
        lam (tuple[int, ...]): The partition

    Yields:
        Generator[tuple[int, int], None, None]: The indexes of the cells

    Examples:
        >>> list(removable_corners((2, 2, 1)))
        [(2, 0), (1, 1)]
    """
    if not lam:
        return
    yield len(lam) - 1, lam[-1] - 1
    for i in range(len(lam) - 2, -1, -1):
        if lam[i] != lam[i + 1]:
            yield i, lam[i] - 1

is_in_partition

is_in_partition(lam: tuple[int, ...], i: int, j: int) -> bool

Returns true if a cell is in the partition lam

Parameters:

Name Type Description Default
lam tuple[int, ...]

the partition

required
i int

the row index (0-indexed)

required
j int

the column index (0-indexed)

required

Returns:

Type Description
bool

true if (i, j) in lam

Examples:

>>> is_in_partition((2, 1), 1, 1)
False
>>> is_in_partition((2, 1), 1, 0)
True
Source code in src/schur_weyl/young_diagrams.py
def is_in_partition(lam: tuple[int, ...], i: int, j: int) -> bool:
    """Returns true if a cell is in the partition lam

    Args:
        lam (tuple[int, ...]): the partition
        i (int): the row index (0-indexed)
        j (int): the column index (0-indexed)

    Returns:
        bool: true if (i, j) in lam

    Examples:
        >>> is_in_partition((2, 1), 1, 1)
        False
        >>> is_in_partition((2, 1), 1, 0)
        True
    """
    return len(lam) > i and lam[i] > j