{
  "aliases": null,
  "backlinks": null,
  "body": "\n## Proof\n\nWe match the multisets with the solutions, and the solutions with subsets of positions of the bars. Let $X$ be the $n$-element set and put $N = n + k - 1$.\n\n1. Fix a [[bijection|0SNQEF7Z53]] $i \\mapsto e_i$ from $\\set{1, \\dots, n}$ to $X$.\n2. A [[multiset of size $k$|0YEQG3VBYC]] on $X$ is a function $\\mu : X \\to \\N$ with $\\sum_{x \\in X} \\mu(x) = k$. Send it to the tuple $(\\mu(e_1), \\dots, \\mu(e_n))$.\n3. This tuple solves $x_1 + \\dots + x_n = k$ in natural numbers, since the sum over $X$ is the sum over the $e_i$.\n4. Conversely, a solution $(x_1, \\dots, x_n)$ gives the multiset $e_i \\mapsto x_i$. The two maps are mutually inverse. So multisets and solutions are equinumerous.\n5. Let $S$ be the set of solutions. For $(x_1, \\dots, x_n) \\in S$, put $p_0 = 0$ and $p_j = x_1 + \\dots + x_j + j$ for $1 \\le j \\le n$.\n6. Then $p_j - p_{j-1} = x_j + 1 \\ge 1$ for $1 \\le j \\le n$, so $p_0 \u003c p_1 \u003c \\dots \u003c p_n$. Also $p_n = k + n = N + 1$.\n7. Hence $p_1, \\dots, p_{n-1}$ are $n - 1$ distinct elements of $\\set{1, \\dots, N}$. Let $\\beta(x_1, \\dots, x_n)$ be the set $\\set{p_1, \\dots, p_{n-1}}$.\n8. Conversely, let $T \\subseteq \\set{1, \\dots, N}$ have $n - 1$ elements. List them in increasing order as $q_1 \u003c \\dots \u003c q_{n-1}$, and put $q_0 = 0$ and $q_n = N + 1$.\n9. Put $x_j = q_j - q_{j-1} - 1$ for $1 \\le j \\le n$. Each $x_j \\ge 0$ because $q_{j-1} \u003c q_j$.\n10. The sum telescopes: $x_1 + \\dots + x_n = q_n - q_0 - n = N + 1 - n = k$. So $\\gamma(T) = (x_1, \\dots, x_n)$ lies in $S$.\n11. For this solution, $x_1 + \\dots + x_j + j = q_j - q_0 = q_j$ for every $j$. So $\\beta(\\gamma(T)) = T$.\n12. Starting from a solution, the list of step 6 is the increasing listing of $\\beta(x_1, \\dots, x_n)$. Step 9 then returns $x_j = p_j - p_{j-1} - 1$. So $\\gamma(\\beta(x_1, \\dots, x_n)) = (x_1, \\dots, x_n)$.\n13. By the [[inverse criterion|01VG2A0BHW]], $\\beta$ is a bijection from $S$ to the set of $(n-1)$-element subsets of $\\set{1, \\dots, N}$.\n14. By the [[number of $k$-element subsets|0BFMR2FQ8B]], there are $\\binom{N}{n-1}$ such subsets. Numbering them and composing with $\\gamma$ gives $|S| = \\binom{N}{n-1}$, as in the [[bijection principle|0GV2573FP4]].\n15. Since $n \\ge 1$ and $k \\ge 0$, we have $n - 1 \\le N$ and $N - (n - 1) = k$. By the [[symmetry of binomial coefficients|0R7JS3DP3W]], $\\binom{N}{n-1} = \\binom{N}{k}$.\n16. By step 4, the number of multisets of size $k$ on $X$ is also $\\binom{n + k - 1}{k}$.\n\n## Idea\n\nWrite a solution as a row of $k$ stars, split into $n$ groups by $n - 1$ bars.\nThe row has $n + k - 1$ places, and the solution is determined by which places hold bars.\nSo solutions match subsets of $n - 1$ places, and there are $\\binom{n+k-1}{n-1} = \\binom{n+k-1}{k}$ of them.\n",
  "commit": "4a3290d299c8b2cd6493fce2296920ba7f82d942",
  "front": {
    "kind": "proof",
    "msc": [
      "05A10"
    ],
    "name": "Proof of stars and bars by a bijection with subsets",
    "proves": "009TEMTQKH",
    "sources": [
      {
        "locator": "Theorem two",
        "url": "https://en.wikipedia.org/wiki/Stars_and_bars_(combinatorics)"
      }
    ],
    "tag": "KB70806JGH",
    "uses": [
      "0YEQG3VBYC",
      "0SNQEF7Z53",
      "0GV2573FP4",
      "0BFMR2FQ8B",
      "0R7JS3DP3W",
      "01VG2A0BHW"
    ]
  },
  "kind": "proof",
  "link": "https://math2.tamnd.com/node/KB70806JGH/",
  "links": [
    {
      "field": "proves",
      "target": "009TEMTQKH"
    },
    {
      "field": "uses",
      "target": "0YEQG3VBYC"
    },
    {
      "field": "uses",
      "target": "0SNQEF7Z53"
    },
    {
      "field": "uses",
      "target": "0GV2573FP4"
    },
    {
      "field": "uses",
      "target": "0BFMR2FQ8B"
    },
    {
      "field": "uses",
      "target": "0R7JS3DP3W"
    },
    {
      "field": "uses",
      "target": "01VG2A0BHW"
    }
  ],
  "markdown": "https://math2.tamnd.com/node/KB70806JGH.md",
  "msc": [
    "05A10"
  ],
  "name": "Proof of stars and bars by a bijection with subsets",
  "prov": null,
  "role": "",
  "source": "https://github.com/tamnd/math2/blob/main/nodes/KB7/KB70806JGH.md",
  "status": null,
  "tag": "KB70806JGH",
  "uri": "m2://KB70806JGH",
  "url": "https://math2.tamnd.com/wiki/proof-of-stars-and-bars-by-a-bijection-with-subsets/",
  "writing": {
    "tag": "KB70806JGH",
    "kind": "proof",
    "level": "W0",
    "next": [
      {
        "what": "an inventory row",
        "note": "the row of the inventory that the node accounts for",
        "have": 0,
        "want": 1
      }
    ]
  }
}
