{
  "aliases": null,
  "backlinks": null,
  "body": "\n## Proof\n\nWe count the bad counting orders with André's reflection argument.\n\n1. Let $p \u003e q \\ge 0$ be integers and $N = p + q$. A counting order gives a word $w = w_1 \\cdots w_N$ with $p$ letters $A$ and $q$ letters $B$. Let $\\Omega$ be the set of such words.\n2. Each word arises from exactly $p!\\, q!$ orders of the individual ballots. So a uniformly random order gives each word of $\\Omega$ the same probability, and we may use the [[classical definition of probability|0AKNPYQ04R]] on $\\Omega$.\n3. A word is fixed by the positions of its $q$ letters $B$. By the [[number of $k$-element subsets|0BFMR2FQ8B]], $|\\Omega|$ is the [[binomial coefficient|092GEF38YD]] $\\binom{N}{q}$.\n4. For $0 \\le k \\le N$, let $d_k$ be the number of letters $A$ minus the number of letters $B$ among $w_1, \\dots, w_k$. Then $d_0 = 0$, $d_N = p - q \u003e 0$, and $|d_{k+1} - d_k| = 1$.\n5. The word is good if $d_k \u003e 0$ for all $1 \\le k \\le N$, and bad otherwise.\n6. If $q = 0$, the only word is $A \\cdots A$, with $d_k = k \u003e 0$. So the probability is $1 = \\frac{p - 0}{p + 0}$. From now on let $q \\ge 1$.\n7. We claim that $w$ is bad exactly when $d_k = 0$ for some $k \\ge 1$. If $d_k = 0$ with $k \\ge 1$, then $w$ is bad by step 5.\n8. Conversely, let $w$ be bad. If $w_1 = B$, then $d_1 = -1 \u003c 0 \u003c d_N$. Let $k$ be the least index with $d_k \u003e 0$. Then $k \\ge 2$ and $d_{k-1} \\le 0$. Also $d_{k-1} \\ge d_k - 1 \\ge 0$, so $d_{k-1} = 0$ with $k - 1 \\ge 1$.\n9. If $w_1 = A$, then $d_1 = 1$, and some $j \\ge 1$ has $d_j \\le 0$. Let $k$ be the least such $j$. Then $d_{k-1} \\ge 1$ and $d_k \\ge d_{k-1} - 1 \\ge 0$, so $d_k = 0$.\n10. For a bad word $w$, let $k \\ge 1$ be the least index with $d_k = 0$. Let $\\rho(w)$ be the word obtained by exchanging $A$ and $B$ in $w_1, \\dots, w_k$.\n11. Since $d_k = 0$, the first $k$ letters have as many $A$ as $B$. So $\\rho(w) \\in \\Omega$. Its differences are $-d_j$ for $j \\le k$ and $d_j$ for $j \\ge k$.\n12. So $\\rho(w)$ is bad, and $k$ is again its least index $\\ge 1$ with difference $0$. Hence $\\rho(\\rho(w)) = w$, and $\\rho$ is a bijection of the set of bad words to itself.\n13. Since $k \\ge 1$, $\\rho$ changes the first letter. So $\\rho$ maps the bad words that start with $A$ bijectively onto the bad words that start with $B$.\n14. Every word that starts with $B$ is bad, because $d_1 = -1$. Such a word is fixed by the positions of its other $q - 1$ letters $B$ among $N - 1$ places. So there are $\\binom{N-1}{q-1}$ of them.\n15. By the [[bijection principle|0GV2573FP4]] and the [[rule of sum|0EE2V3CHFK]], there are $2 \\binom{N-1}{q-1}$ bad words.\n16. By the [[factorial formula|033KTKKRV6]] and $N! = N \\cdot (N - 1)!$, $q! = q \\cdot (q-1)!$ from the definition of the [[factorial|0WFCGVMRRC]],\n$$\\binom{N-1}{q-1} = \\frac{(N-1)!}{(q-1)!\\, p!} = \\frac{q}{N} \\cdot \\frac{N!}{q!\\, p!} = \\frac{q}{N} \\binom{N}{q}.$$\n17. By the [[complement principle|03QC59M99B]], the number of good words is $\\binom{N}{q} - \\frac{2q}{N} \\binom{N}{q} = \\frac{p - q}{p + q} \\binom{N}{q}$.\n18. Dividing by $|\\Omega| = \\binom{N}{q}$, the probability that $A$ stays strictly ahead throughout the count is $\\frac{p - q}{p + q}$.\n\n## Idea\n\nA bad count must reach a tie at some moment. Swapping the votes up to the first tie turns a bad count that starts with $A$ into one that starts with $B$, and back. Every count that starts with $B$ is bad, so the bad counts are twice those starting with $B$, a fraction $\\frac{2q}{p+q}$.\n",
  "commit": "4a3290d299c8b2cd6493fce2296920ba7f82d942",
  "front": {
    "kind": "proof",
    "msc": [
      "05A15"
    ],
    "name": "Proof of Bertrand's ballot theorem by reflection",
    "proves": "0FS972T0ZH",
    "sources": [
      {
        "locator": "Proof by reflection",
        "url": "https://en.wikipedia.org/wiki/Bertrand's_ballot_theorem"
      }
    ],
    "tag": "FYQY3KVC7D",
    "uses": [
      "0AKNPYQ04R",
      "092GEF38YD",
      "0BFMR2FQ8B",
      "033KTKKRV6",
      "03QC59M99B",
      "0EE2V3CHFK",
      "0GV2573FP4",
      "0WFCGVMRRC"
    ]
  },
  "kind": "proof",
  "link": "https://math2.tamnd.com/node/FYQY3KVC7D/",
  "links": [
    {
      "field": "proves",
      "target": "0FS972T0ZH"
    },
    {
      "field": "uses",
      "target": "0AKNPYQ04R"
    },
    {
      "field": "uses",
      "target": "092GEF38YD"
    },
    {
      "field": "uses",
      "target": "0BFMR2FQ8B"
    },
    {
      "field": "uses",
      "target": "033KTKKRV6"
    },
    {
      "field": "uses",
      "target": "03QC59M99B"
    },
    {
      "field": "uses",
      "target": "0EE2V3CHFK"
    },
    {
      "field": "uses",
      "target": "0GV2573FP4"
    },
    {
      "field": "uses",
      "target": "0WFCGVMRRC"
    }
  ],
  "markdown": "https://math2.tamnd.com/node/FYQY3KVC7D.md",
  "msc": [
    "05A15"
  ],
  "name": "Proof of Bertrand's ballot theorem by reflection",
  "prov": null,
  "role": "",
  "source": "https://github.com/tamnd/math2/blob/main/nodes/FYQ/FYQY3KVC7D.md",
  "status": null,
  "tag": "FYQY3KVC7D",
  "uri": "m2://FYQY3KVC7D",
  "url": "https://math2.tamnd.com/wiki/proof-of-bertrands-ballot-theorem-by-reflection/",
  "writing": {
    "tag": "FYQY3KVC7D",
    "kind": "proof",
    "level": "W0",
    "next": [
      {
        "what": "an inventory row",
        "note": "the row of the inventory that the node accounts for",
        "have": 0,
        "want": 1
      }
    ]
  }
}
