{
  "aliases": null,
  "backlinks": null,
  "body": "\n## Proof\n\nWe give a bijection between [[compositions|0J8ANSYKAC]] of $n$ and subsets of $\\set{1, \\dots, n-1}$.\n\n1. Let $n \\ge 1$. Let $\\mathcal{C}$ be the set of compositions of $n$, and let $\\mathcal{S}$ be the set of subsets of $\\set{1, \\dots, n - 1}$.\n2. Let $(a_1, \\dots, a_k) \\in \\mathcal{C}$. Then $k \\ge 1$, because the empty sequence has sum $0 \\ne n$.\n3. Put $s_i = a_1 + \\dots + a_i$ for $0 \\le i \\le k$. Then $s_0 = 0$ and $s_k = n$.\n4. Since each $a_i \\ge 1$, we have $s_0 \u003c s_1 \u003c \\dots \u003c s_k$. Hence $\\set{s_1, \\dots, s_{k-1}}$ is a subset of $\\set{1, \\dots, n-1}$.\n5. Define $\\Phi(a_1, \\dots, a_k) = \\set{s_1, \\dots, s_{k-1}} \\in \\mathcal{S}$.\n6. Let $S \\in \\mathcal{S}$ have elements $t_1 \u003c \\dots \u003c t_j$. Put $t_0 = 0$ and $t_{j+1} = n$, so $t_0 \u003c t_1 \u003c \\dots \u003c t_{j+1}$.\n7. Define $\\Psi(S) = (t_1 - t_0, t_2 - t_1, \\dots, t_{j+1} - t_j)$. Its entries are positive integers, and they sum to $t_{j+1} - t_0 = n$. So $\\Psi(S) \\in \\mathcal{C}$.\n8. Let $(a_1, \\dots, a_k) \\in \\mathcal{C}$. The elements of $\\Phi(a_1, \\dots, a_k)$ in increasing order are $s_1 \u003c \\dots \u003c s_{k-1}$, by step 4.\n9. So $\\Psi(\\Phi(a_1, \\dots, a_k)) = (s_1 - s_0, \\dots, s_k - s_{k-1}) = (a_1, \\dots, a_k)$.\n10. Let $S = \\set{t_1 \u003c \\dots \u003c t_j} \\in \\mathcal{S}$. The partial sums of $\\Psi(S)$ are $t_1, \\dots, t_{j+1}$, because the differences telescope.\n11. So $\\Phi(\\Psi(S)) = \\set{t_1, \\dots, t_j} = S$.\n12. Thus $\\Phi$ and $\\Psi$ are inverse maps, and $\\Phi$ is a [[bijection|01VG2A0BHW]] from $\\mathcal{C}$ to $\\mathcal{S}$.\n13. The set $\\set{1, \\dots, n-1}$ has $n - 1$ elements. By the [[number of subsets of a finite set|0C5RDJE73X]], $\\abs{\\mathcal{S}} = 2^{n-1}$.\n14. By the [[bijection principle|0GV2573FP4]], $\\abs{\\mathcal{C}} = 2^{n-1}$.\n\n## Idea\n\nWrite $n$ as a row of $n$ ones. A composition is the same as a choice of the places where we cut the row.\nThere are $n - 1$ gaps between the ones, and each gap is cut or not. The cut positions are exactly the partial sums $a_1 + \\dots + a_i$ with $i \u003c k$.\n",
  "commit": "4a3290d299c8b2cd6493fce2296920ba7f82d942",
  "front": {
    "kind": "proof",
    "msc": [
      "05A17"
    ],
    "name": "Proof of the number of compositions by partial sums",
    "proves": "057H72B2MB",
    "sources": [
      {
        "locator": "Number of compositions",
        "url": "https://en.wikipedia.org/wiki/Composition_(combinatorics)"
      }
    ],
    "tag": "C9H2SC7D3T",
    "uses": [
      "0J8ANSYKAC",
      "01VG2A0BHW",
      "0GV2573FP4",
      "0C5RDJE73X"
    ]
  },
  "kind": "proof",
  "link": "https://math2.tamnd.com/node/C9H2SC7D3T/",
  "links": [
    {
      "field": "proves",
      "target": "057H72B2MB"
    },
    {
      "field": "uses",
      "target": "0J8ANSYKAC"
    },
    {
      "field": "uses",
      "target": "01VG2A0BHW"
    },
    {
      "field": "uses",
      "target": "0GV2573FP4"
    },
    {
      "field": "uses",
      "target": "0C5RDJE73X"
    }
  ],
  "markdown": "https://math2.tamnd.com/node/C9H2SC7D3T.md",
  "msc": [
    "05A17"
  ],
  "name": "Proof of the number of compositions by partial sums",
  "prov": null,
  "role": "",
  "source": "https://github.com/tamnd/math2/blob/main/nodes/C9H/C9H2SC7D3T.md",
  "status": null,
  "tag": "C9H2SC7D3T",
  "uri": "m2://C9H2SC7D3T",
  "url": "https://math2.tamnd.com/wiki/proof-of-the-number-of-compositions-by-partial-sums/",
  "writing": {
    "tag": "C9H2SC7D3T",
    "kind": "proof",
    "level": "W0",
    "next": [
      {
        "what": "an inventory row",
        "note": "the row of the inventory that the node accounts for",
        "have": 0,
        "want": 1
      }
    ]
  }
}
