Skip to content

CompositionsIntoKParts ​

A name from the enumeratio catalogue with no kernel of its own yet; this page carries its crosswalk only.

Catalogued in the enumeratio database, with crosswalk rows in mathlib4, oeis, sage; not yet written up here.

✓ checked against that system · ! checked, with disagreements (hover a chip)OEISA097805✓SageMathCompositions(n, length=k)mathlib4Composition n
CompositionsIntoKParts(...)Catalogued in the enumeratio database, with crosswalk rows in mathlib4, oeis, sage; not yet written up here.
Typed signatures
TypePackageApplies
(integer<0..>, integer<0..>) -> indexed_collection<composition>combinatoricsalways

Domain: Combinatorics

Definition

Epsil, as the implementation runs it.

count(_n, _k)

(1 if _k == 0 else 0) if _n == 0 else Binomial(_n - 1, _k - 1)

unrank(_n, _k, _r)

Apply(
       (cd_digits: list<integer>) => Map(Function((0 if pos == 0 else _n if pos ==
                                                                            _k else cd_digits[pos + 1] +
                                                                                  1) -
                                                  (0 if pos - 1 == 0 else _n if pos - 1 ==
                                                                                _k else cd_digits[pos - 1 +
                                                                                                1] +
                                                                                      1) + 0, pos), Range(1, _k, 1)),
       Apply((cd_st_init: list<integer>) => Fold(
                                                  (cd_st: list<integer>, cd_i) => Apply(
                                                                                         (cd_st_next: list<integer>) => cd_st_next,
                                                                                         Apply((cd_left: integer) => Apply(
                                                                                                                            (cd_found: integer) => ReplaceAt(ReplaceAt(cd_st, 1, cd_left -
                                                                                                                                                                                 _tables[cd_found *
                                                                                                                                                                                         (Max(_k - 1, 0) +
                                                                                                                                                                                          1) + cd_i + 1]), cd_i + 1, cd_found),
                                                                                                                            Fold(
                                                                                                                                  Function(cd_c if _tables[cd_c *
                                                                                                                                                           (Max(_k - 1, 0) +
                                                                                                                                                            1) + cd_i + 1] <=
                                                                                                                                                   cd_left else cd_best, cd_best, cd_c),
                                                                                                                                  cd_i - 1,
                                                                                                                                  Range(
                                                                                                                                         cd_i - 1,
                                                                                                                                         (_n - 1 if cd_i ==
                                                                                                                                                    _k - 1 else cd_st[cd_i + 2]) -
                                                                                                                                         1,
                                                                                                                                         1,
                                                                                                                                       ),
                                                                                                                                ),
                                                                                                                          ), cd_st[1]),
                                                                                       ),
                                                  cd_st_init,
                                                  Range(_k - 1, 1, -1),
                                                ), Join(
                                                        [_r],
                                                        Map(
                                                             Function(0, cd_z),
                                                             Range(1, _k - 1, 1),
                                                           ),
                                                      )),
     )

rank(_n, _k, _x)

Fold(Function(
               acc3 + _tables[(Fold(
                                     Function(acc2 + (_x[t] - 0), acc2, t),
                                     0,
                                     Range(1, i, 1),
                                   ) - 1) * (Max(_k - 1, 0) + 1) + i + 1],
               acc3,
               i,
             ), 0, Range(1, _k - 1, 1))

valid(_n, _k, _x)

Length(_x) == _k && Fold(
                          Function(acc2 + (_x[t] - 0), acc2, t),
                          0,
                          Range(1, Length(_x), 1),
                        ) == _n && Fold(
                                        Function(okv && _x[jv] >= 1, okv, jv),
                                        True,
                                        Range(1, Length(_x), 1),
                                      )

tables(_n, _k)

Fold(Function(Join(
                    pc_t,
                    Fold(Function(ReplaceAt(
                                             pc_row,
                                             pc_c + 1,
                                             1 if pc_c == 0 else pc_t[(pc_s - 1) *
                                                                      (Max(_k -
                                                                           1, 0) +
                                                                       1) + (pc_c -
                                                                          1) + 1] +
                                                                 pc_t[(pc_s - 1) *
                                                                      (Max(_k -
                                                                           1, 0) +
                                                                       1) + pc_c +
                                                                      1],
                                           ), pc_row, pc_c), Map(
                                                                 Function(
                                                                           0,
                                                                           pc_z,
                                                                         ),
                                                                 Range(
                                                                        0,
                                                                        Max(_k -
                                                                            1, 0) +
                                                                        1 - 1,
                                                                        1,
                                                                      ),
                                                               ), Range(
                                                                        0,
                                                                        Max(_k -
                                                                            1, 0) +
                                                                        1 - 1,
                                                                        1,
                                                                      )),
                  ), pc_t, pc_s), Fold(
                                       Function(ReplaceAt(
                                                           pc_row,
                                                           pc_c + 1,
                                                           1 if pc_c == 0 else 0,
                                                         ), pc_row, pc_c),
                                       Map(
                                            Function(0, pc_z),
                                            Range(0, Max(_k - 1, 0) + 1 - 1, 1),
                                          ),
                                       Range(0, Max(_k - 1, 0) + 1 - 1, 1),
                                     ), Range(1, Max(_n, 1) - 1, 1))

Statistics

On IntegerComposition, called as CombinatorialStat(x, "Name").

Maps

Into and out of IntegerComposition, called as CombinatorialMap(x, "Name"). Properties are the laws we state and what FindStat records.

From IntegerComposition

  • CodeWordIntegerComposition → BinaryWordInjectionGraded mapMp00094The word that writes each part i as a one followed by i - 1 zeros.
  • ComplementIntegerComposition → IntegerCompositioninvolutionBijectionGraded mapInvolutionMp00039The composition cut exactly where this one is not: its cut set complemented.
  • CompositionBouncePathIntegerComposition → DyckPathInjectionGraded mapMp00231The Dyck path that bounces off the diagonal once for each part: a run of that many ups, then as many downs.
  • CutWordIntegerComposition → BinaryWordinverseA composition of n as the binary word of length n - 1 marking where it is cut.
  • CyclicShiftIntegerComposition → IntegerCompositioninverseBijectionGraded mapMp00173Rotate the parts one place to the left: the first part moves to the end.
  • DeltaMorphismIntegerComposition → IntegerCompositionSurjectionMp00133The lengths of the maximal runs of equal parts, left to right.
  • FoataInversionsToMajorIntegerComposition → IntegerCompositionbijectioninverseBijectionGraded mapMp00315The inverse of Foata's bijection on compositions: peel off the last part, rotate the blocks of the rest back.
  • FoataMajorToInversionsIntegerComposition → IntegerCompositionbijectioninverseBijectionGraded mapMp00314Foata's bijection on the word of parts: each part is put on the end of the image so far, which is cut into blocks, and every block is rotated one place right.
  • InverseCyclicShiftIntegerComposition → IntegerCompositioninverseBijectionGraded mapMp00172Rotate the parts one place to the right: the last part moves to the front.
  • ReverseIntegerComposition → IntegerCompositioninvolutionBijectionGraded mapInvolutionMp00038The parts read backwards.
  • SortedPartitionIntegerComposition → IntegerPartitionsurjectionSurjectionGraded mapMp00040The partition a composition's parts form, sorted largest first.
  • TransposeCompositionIntegerComposition → IntegerCompositioninvolutionBijectionGraded mapInvolutionMp00041The conjugate composition: its ribbon shape transposed, the complement of the reverse.

To IntegerComposition

  • BlockSizeCompositionSetPartition → IntegerCompositionsurjectionSurjectionGraded mapMp00128The block sizes of a set partition, its blocks taken in order of their least elements.
  • BlockSizeCompositionSetComposition → IntegerCompositionsurjectionSurjectionGraded mapMp00287The block sizes of a set composition, its blocks taken in order.
  • CodeCompositionBinaryWord → IntegerCompositionInjectionGraded mapMp00178The composition whose code is the word with a 1 put in front: each 1 opens a part, of 1 plus the zeros after it.
  • DescentCompositionPermutation → IntegerCompositionsurjectionSurjectionGraded mapMp00071The composition of n cut at the descent positions.
  • IntegerCompositionBinaryWord → IntegerCompositioninverseThe composition of m + 1 a binary word of length m cuts out.
  • PeakCompositionStandardTableau → IntegerCompositionGraded mapMp00294The composition cut at the peaks: entries i that are descents after an ascent.
  • RiseCompositionDyckPath → IntegerCompositionsurjectionSurjectionGraded mapMp00102The lengths of the maximal runs of up steps, left to right.
  • RunCompositionBinaryWord → IntegerCompositionsurjectionSurjectionGraded mapMp00097The lengths of the maximal runs of equal letters, left to right.
  • TouchCompositionDyckPath → IntegerCompositionsurjectionSurjectionGraded mapMp00100The semilengths of the primitive pieces between a path's returns to the diagonal.
  • ValleyCompositionStandardTableau → IntegerCompositionGraded mapMp00295The composition cut at the valleys: entries i that are ascents after a descent.
10 more in FindStat, not implemented here
  • Mp00054ParkingFunction → IntegerCompositionSurjectionGraded mapto inverse des composition
  • Mp00057ParkingFunction → IntegerCompositionSurjectionGraded mapto touch composition
  • Mp00152LabeledGraph → IntegerCompositionSurjectionGraded mapLaplacian multiplicities
  • Mp00180IntegerComposition → SkewPartitionInjectionGraded mapto ribbon
  • Mp00181SkewPartition → IntegerCompositionSurjectionGraded maprow lengths
  • Mp00184IntegerComposition → LabeledGraphInjectionGraded mapto threshold graph
  • Mp00207StandardTableau → IntegerCompositionSurjectionGraded maphorizontal strip sizes
  • Mp00248Permutation → IntegerCompositionGraded mapDEX composition
  • Mp00319ParkingFunction → IntegerCompositionInjectionto composition
  • Mp00324LabeledGraph → IntegerCompositionGraded mapchromatic difference sequence

Enumeration

Examples

Basic #

(52)=10\binom{5}{2} = 10 compositions of 6 into 3 positive parts

live ↗
InCount(CompositionsIntoKParts(6,3))\mathrm{Count}(\mathrm{CompositionsIntoKParts}(6, 3))Out1010

Every composition of 4 into 2 parts, in enumeration order

live ↗
InTake(CompositionsIntoKParts(4,2),3)\mathrm{Take}(\mathrm{CompositionsIntoKParts}(4, 2), 3)Out[IntegerComposition⁡([1,3]),IntegerComposition⁡([2,2]),IntegerComposition⁡([3,1])]\bigl\lbrack{\operatorname{IntegerComposition}}([1, 3]), {\operatorname{IntegerComposition}}([2, 2]), {\operatorname{IntegerComposition}}([3, 1])\bigr\rbrack
Properties #

The first of the compositions of 5 into 3 parts

live ↗
InCompositionsIntoKParts(5,3)[1]\mathrm{CompositionsIntoKParts}(5, 3)[1]OutIntegerComposition⁡([1,1,3]){\operatorname{IntegerComposition}}([1, 1, 3])
About
Examples3
Checked againstmathlib4 2 agree1 error
CrosswalkOEISSageMathmathlib4

Implementation

mappedmathlib4packages/oracle/src/mappings.ts

Composition n enumerated, those with exactly k blocks, in lexicographic order