{
  "aliases": null,
  "backlinks": null,
  "body": "\n## Definition\n\nLet $N$ and $X$ be finite sets with $\\abs{N} = n$ and $\\abs{X} = x$.\nConsider the [[functions|0XHDTE5YMZ]] $f \\colon N \\to X$ in one of three classes: all functions, [[injective functions|0PVG1CRAJN]], or [[surjective functions|0XKH881BZ7]].\nCount them in one of four ways:\n\n1. as functions;\n2. up to permutations of $N$, so $f$ and $f \\circ \\sigma$ count as the same for every permutation $\\sigma$ of $N$;\n3. up to permutations of $X$, so $f$ and $\\tau \\circ f$ count as the same for every permutation $\\tau$ of $X$;\n4. up to permutations of both, so $f$ and $\\tau \\circ f \\circ \\sigma$ count as the same for all such $\\sigma$ and $\\tau$.\n\nThe *twelvefold way* is the list of these $3 \\cdot 4 = 12$ counting problems with their answers.\n\n## Remarks\n\nWrite $x^{\\underline{n}}$ for the [[falling factorial|0N5M924N3P]], $S(n, k)$ for the [[Stirling numbers of the second kind|0JCQGPY8Z4]], and $p_k(m)$ for the number of [[partitions|0JV30XN73Z]] of $m$ into exactly $k$ parts.\nWrite $[n \\le x]$ for $1$ if $n \\le x$ and $0$ otherwise.\nThe answers, with $n$ balls $N$ and $x$ boxes $X$, are as follows.\n\n| count | all functions | injective | surjective |\n|---|---|---|---|\n| as functions | $x^n$ | $x^{\\underline{n}}$ | $x!\\, S(n, x)$ |\n| up to permutations of $N$ | $\\binom{x + n - 1}{n}$ | $\\binom{x}{n}$ | $\\binom{n - 1}{x - 1}$ |\n| up to permutations of $X$ | $\\sum_{k=0}^{x} S(n, k)$ | $[n \\le x]$ | $S(n, x)$ |\n| up to both | $\\sum_{k=0}^{x} p_k(n)$ | $[n \\le x]$ | $p_x(n)$ |\n\nThe entry $\\binom{n-1}{x-1}$ needs $n \\ge 1$; for $n = x = 0$ there is exactly one surjection, the empty map.\n\nExample: take $n = 3$ and $x = 2$, counted up to permutations of $N$.\nA class of functions is then fixed by how many balls go into each box, so the classes are $(3, 0)$, $(2, 1)$, $(1, 2)$ and $(0, 3)$.\nThis gives $4 = \\binom{4}{3}$, as in the table.\n\nNon-example: counting functions up to a permutation of $N$ that is not arbitrary, for instance only up to cyclic rotations of $N$, is not one of the twelve problems.\nIt leads to necklace counting, which is handled by the [[Pólya enumeration theorem|MPYQ39P01F]].\n\nThe second row is the theory of [[combinations with repetition|0VQQCVG8WA]].\nThe first entry of the first row is the [[number of functions between finite sets|08QQH9F7G0]], and the second is the [[number of injections|0X0N833FF8]].\n",
  "commit": "efe85cee8dbc57d85bedbacfb97b99d1b7bee843",
  "front": {
    "defines": "1J16RVRHYS",
    "kind": "definition",
    "msc": [
      "05A15",
      "05A18",
      "05A17"
    ],
    "name": "Twelvefold way",
    "sources": [
      {
        "url": "https://en.wikipedia.org/wiki/Twelvefold_way"
      }
    ],
    "tag": "3BBE4XY4E9",
    "uses": [
      "0XHDTE5YMZ",
      "0PVG1CRAJN",
      "0XKH881BZ7",
      "0515A6D2Y1",
      "0JCQGPY8Z4",
      "0JV30XN73Z",
      "0N5M924N3P"
    ]
  },
  "kind": "definition",
  "link": "https://math2.tamnd.com/node/3BBE4XY4E9/",
  "links": [
    {
      "field": "defines",
      "target": "1J16RVRHYS"
    },
    {
      "field": "uses",
      "target": "0XHDTE5YMZ"
    },
    {
      "field": "uses",
      "target": "0PVG1CRAJN"
    },
    {
      "field": "uses",
      "target": "0XKH881BZ7"
    },
    {
      "field": "uses",
      "target": "0515A6D2Y1"
    },
    {
      "field": "uses",
      "target": "0JCQGPY8Z4"
    },
    {
      "field": "uses",
      "target": "0JV30XN73Z"
    },
    {
      "field": "uses",
      "target": "0N5M924N3P"
    }
  ],
  "markdown": "https://math2.tamnd.com/node/3BBE4XY4E9.md",
  "msc": [
    "05A15",
    "05A18",
    "05A17"
  ],
  "name": "Twelvefold way",
  "prov": null,
  "role": "",
  "source": "https://github.com/tamnd/math2/blob/main/nodes/3BB/3BBE4XY4E9.md",
  "status": null,
  "tag": "3BBE4XY4E9",
  "uri": "m2://3BBE4XY4E9",
  "url": "https://math2.tamnd.com/wiki/twelvefold-way-definition/",
  "writing": {
    "tag": "3BBE4XY4E9",
    "kind": "definition",
    "level": "W0",
    "next": [
      {
        "what": "an inventory row",
        "note": "the row of the inventory that the node accounts for",
        "have": 0,
        "want": 1
      },
      {
        "what": "a source with a locator",
        "have": 0,
        "want": 1
      }
    ]
  }
}
