{
  "index": "2019-B-1",
  "type": "COMB",
  "tag": [
    "COMB",
    "NT",
    "GEO"
  ],
  "difficulty": "",
  "question": "Denote by $\\mathbb{Z}^2$ the set of all points $(x,y)$ in the plane with integer coordinates. For each integer $n \\geq 0$, let $P_n$ be the subset of $\\mathbb{Z}^2$ consisting of the point $(0,0)$ together with all points $(x,y)$ such that $x^2 + y^2 = 2^k$ for some integer $k \\leq n$. Determine, as a function of $n$, the number of four-point subsets of $P_n$ whose elements are the vertices of a square.",
  "solution": "The answer is $5n+1$.\n\nWe first determine the set $P_n$. Let $Q_n$ be the set of points in $\\mathbb{Z}^2$ of the form $(0, \\pm 2^k)$ or $(\\pm 2^k, 0)$ for some $k \\leq n$. Let $R_n$ be the set of points in $\\mathbb{Z}^2$ of the form $(\\pm 2^k, \\pm 2^k)$ for some $k \\leq n$ (the two signs being chosen independently). \nWe prove by induction on $n$ that\n\\[\nP_n = \\{(0,0)\\} \\cup Q_{\\lfloor n/2 \\rfloor} \\cup R_{\\lfloor (n-1)/2 \\rfloor}.\n\\]\nWe take as base cases the straightforward computations\n\\begin{align*}\nP_0 &= \\{(0,0), (\\pm 1, 0), (0, \\pm 1)\\} \\\\\nP_1 &= P_0 \\cup \\{(\\pm 1, \\pm 1)\\}.\n\\end{align*}\nFor $n \\geq 2$, it is clear that $\\{(0,0)\\} \\cup Q_{\\lfloor n/2 \\rfloor} \\cup R_{\\lfloor (n-1)/2 \\rfloor} \\subseteq P_n$, so it remains to prove the reverse inclusion. For $(x,y) \\in P_n$, note that $x^2 + y^2 \\equiv 0 \\pmod{4}$;\nsince every perfect square is congruent to either 0 or 1 modulo 4, $x$ and $y$ must both be even. Consequently,\n$(x/2, y/2) \\in P_{n-2}$, so we may appeal to the induction hypothesis to conclude.\n\nWe next identify all of the squares with vertices in $P_n$. In the following discussion, let $(a,b)$\nand $(c,d)$ be two opposite vertices of a square, so that the other two vertices are\n\\[\n\\left( \\frac{a-b+c+d}{2}, \\frac{a+b-c+d}{2} \\right)\n\\]\nand \n\\[\n\\left( \\frac{a+b+c-d}{2}, \\frac{-a+b+c+d}{2} \\right).\n\\]\n\\begin{itemize}\n\\item\nSuppose that $(a,b) = (0,0)$. Then $(c,d)$ may be any element of $P_n$ not contained in $P_0$.\nThe number of such squares is $4n$.\n\n\\item\nSuppose that $(a,b), (c,d) \\in Q_k$ for some $k$. \nThere is one such square with vertices \n\\[\n\\{(0, 2^k), (0, 2^{-k}), (2^k, 0), (2^{-k}, 0)\\}\n\\]\nfor $k = 0,\\dots,\\lfloor \\frac{n}{2} \\rfloor$, for a total of $\\lfloor \\frac{n}{2} \\rfloor + 1$.\nTo show that there are no others, by symmetry it suffices to rule out the existence of a square with\nopposite vertices $(a,0)$ and $(c,0)$ where $a > \\left| c \\right|$. \nThe other two vertices of this square would be $((a+c)/2, (a-c)/2)$ and $((a+c)/2, (-a+c)/2)$.\nThese cannot belong to any $Q_k$, or be equal to $(0,0)$,\nbecause $|a+c|, |a-c| \\geq a - |c| > 0$ by the triangle inequality.\nThese also cannot belong to any $R_k$ because $(a + |c|)/2 > (a - |c|)/2$. \n(One can also phrase this argument in geometric terms.)\n\n\\item\nSuppose that $(a,b), (c,d) \\in R_k$ for some $k$.\nThere is one such square with vertices\n\\[\n\\{(2^k, 2^k), (2^k, -2^k), (-2^k, 2^k), (-2^k, -2^k)\\}\n\\]\nfor $k=0,\\dots, \\lfloor \\frac{n-1}{2} \\rfloor$, for a total of $\\lfloor \\frac{n+1}{2} \\rfloor$.\nTo show that there are no others, we may reduce to the previous case: rotating by an angle of $\\frac{\\pi}{4}$ and then rescaling by a factor of $\\sqrt{2}$ would yield a square with two opposite vertices in some $Q_k$ not centered at $(0,0)$, which we have already ruled out.\n\n\\item\nIt remains to show that we cannot have $(a,b) \\in Q_k$ and $(c,d) \\in R_k$ for some $k$.\nBy symmetry, we may reduce to the case where $(a,b) = (0, 2^k)$ and $(c,d) = (2^\\ell, \\pm 2^\\ell)$.\nIf $d>0$, then the third vertex $(2^{k-1}, 2^{k-1} + 2^\\ell)$ is impossible.\nIf $d<0$, then the third vertex $(-2^{k-1}, 2^{k-1} - 2^\\ell)$ is impossible.\n\n\\end{itemize}\n\nSumming up, we obtain\n\\[\n4n + \\left\\lfloor \\frac{n}{2} \\right\\rfloor + 1 + \\left\\lfloor \\frac{n+1}{2} \\right\\rfloor = 5n+1\n\\]\nsquares, proving the claim.\n\n\\noindent\n\\textbf{Remark.}\nGiven the computation of $P_n$, we can alternatively show that the number of squares with vertices in $P_n$ is $5n+1$ as follows. Since this is clearly true for $n=1$, it suffices to show that for $n \\geq 2$, there are exactly $5$ squares with vertices in $P_n$, at least one of which is not in $P_{n-1}$. Note that the convex hull of $P_n$ is a square $S$ whose four vertices are the four points in $P_n \\setminus P_{n-1}$. If $v$ is one of these points, then a square with a vertex at $v$ can only lie in $S$ if its two sides containing $v$ are in line with the two sides of $S$ containing $v$. It follows that there are exactly two squares with a vertex at $v$ and all vertices in $P_n$: the square corresponding to $S$ itself, and a square whose vertex diagonally opposite to $v$ is the origin. Taking the union over the four points in $P_n \\setminus P_{n-1}$ gives a total of $5$ squares, as desired.",
  "vars": [
    "x",
    "y",
    "a",
    "b",
    "c",
    "d",
    "k",
    "\\\\ell",
    "P_n",
    "Q_n",
    "Q_k",
    "R_n",
    "R_k",
    "S"
  ],
  "params": [
    "n"
  ],
  "sci_consts": [],
  "variants": {
    "descriptive_long": {
      "map": {
        "x": "coordx",
        "y": "coordy",
        "a": "vertexa",
        "b": "vertexb",
        "c": "vertexc",
        "d": "vertexd",
        "k": "powerk",
        "\\ell": "powerell",
        "P_n": "mainset",
        "Q_n": "axisset",
        "Q_k": "axissetk",
        "R_n": "diagset",
        "R_k": "diagsetk",
        "S": "hullsqr",
        "n": "paramnn"
      },
      "question": "Denote by $\\mathbb{Z}^2$ the set of all points $(coordx,coordy)$ in the plane with integer coordinates. For each integer $paramnn \\geq 0$, let $mainset_{paramnn}$ be the subset of $\\mathbb{Z}^2$ consisting of the point $(0,0)$ together with all points $(coordx,coordy)$ such that $coordx^2 + coordy^2 = 2^{powerk}$ for some integer $powerk \\leq paramnn$. Determine, as a function of $paramnn$, the number of four-point subsets of $mainset_{paramnn}$ whose elements are the vertices of a square.",
      "solution": "The answer is $5\\mathrm{paramnn}+1$.\n\nWe first determine the set $mainset_{paramnn}$. Let $axisset_{paramnn}$ be the set of points in $\\mathbb{Z}^2$ of the form $(0, \\pm 2^{powerk})$ or $(\\pm 2^{powerk}, 0)$ for some $powerk \\leq paramnn$. Let $diagset_{paramnn}$ be the set of points in $\\mathbb{Z}^2$ of the form $(\\pm 2^{powerk}, \\pm 2^{powerk})$ for some $powerk \\leq paramnn$ (the two signs being chosen independently).\nWe prove by induction on $paramnn$ that\n\\[\nmainset_{paramnn} = \\{(0,0)\\} \\cup axisset_{\\lfloor paramnn/2 \\rfloor} \\cup diagset_{\\lfloor (paramnn-1)/2 \\rfloor} .\n\\]\nWe take as base cases the straightforward computations\n\\begin{align*}\nmainset_0 &= \\{(0,0), (\\pm 1, 0), (0, \\pm 1)\\} \\\\\nmainset_1 &= mainset_0 \\cup \\{(\\pm 1, \\pm 1)\\} .\n\\end{align*}\nFor $paramnn \\geq 2$, it is clear that $\\{(0,0)\\} \\cup axisset_{\\lfloor paramnn/2 \\rfloor} \\cup diagset_{\\lfloor (paramnn-1)/2 \\rfloor} \\subseteq mainset_{paramnn}$, so it remains to prove the reverse inclusion. For $(coordx,coordy) \\in mainset_{paramnn}$, note that $coordx^2 + coordy^2 \\equiv 0 \\pmod{4}$; since every perfect square is congruent to either $0$ or $1$ modulo $4$, $coordx$ and $coordy$ must both be even. Consequently,\n$(coordx/2, coordy/2) \\in mainset_{paramnn-2}$, so we may appeal to the induction hypothesis to conclude.\n\nWe next identify all of the squares with vertices in $mainset_{paramnn}$. In the following discussion, let $(vertexa,vertexb)$ and $(vertexc,vertexd)$ be two opposite vertices of a square, so that the other two vertices are\n\\[\n\\left( \\frac{vertexa-vertexb+vertexc+vertexd}{2}, \\frac{vertexa+vertexb-vertexc+vertexd}{2} \\right)\n\\]\nand\n\\[\n\\left( \\frac{vertexa+vertexb+vertexc-vertexd}{2}, \\frac{-vertexa+vertexb+vertexc+vertexd}{2} \\right).\n\\]\n\\begin{itemize}\n\\item\nSuppose that $(vertexa,vertexb) = (0,0)$. Then $(vertexc,vertexd)$ may be any element of $mainset_{paramnn}$ not contained in $mainset_0$.\nThe number of such squares is $4\\,paramnn$.\n\n\\item\nSuppose that $(vertexa,vertexb), (vertexc,vertexd) \\in axissetk$ for some $powerk$.\nThere is one such square with vertices\n\\[\n\\{(0, 2^{powerk}), (0, 2^{-powerk}), (2^{powerk}, 0), (2^{-powerk}, 0)\\}\n\\]\nfor $powerk = 0,\\dots,\\lfloor \\tfrac{paramnn}{2} \\rfloor$, for a total of $\\lfloor \\tfrac{paramnn}{2} \\rfloor + 1$.\nTo show that there are no others, by symmetry it suffices to rule out the existence of a square with\nopposite vertices $(vertexa,0)$ and $(vertexc,0)$ where $vertexa > \\lvert vertexc \\rvert$.\nThe other two vertices of this square would be $((vertexa+vertexc)/2, (vertexa-vertexc)/2)$ and $((vertexa+vertexc)/2, (-vertexa+vertexc)/2)$.\nThese cannot belong to any $axisset_{powerk}$, or be equal to $(0,0)$,\nbecause $|vertexa+vertexc|, |vertexa-vertexc| \\ge vertexa - |vertexc| > 0$ by the triangle inequality.\nThese also cannot belong to any $diagset_{powerk}$ because $(vertexa + |vertexc|)/2 > (vertexa - |vertexc|)/2$.\n\n\\item\nSuppose that $(vertexa,vertexb), (vertexc,vertexd) \\in diagsetk$ for some $powerk$.\nThere is one such square with vertices\n\\[\n\\{(2^{powerk}, 2^{powerk}), (2^{powerk}, -2^{powerk}), (-2^{powerk}, 2^{powerk}), (-2^{powerk}, -2^{powerk})\\}\n\\]\nfor $powerk = 0,\\dots, \\lfloor \\tfrac{paramnn-1}{2} \\rfloor$, for a total of $\\lfloor \\tfrac{paramnn+1}{2} \\rfloor$.\nTo show that there are no others, we may reduce to the previous case: rotating by an angle of $\\tfrac{\\pi}{4}$ and then rescaling by a factor of $\\sqrt{2}$ would yield a square with two opposite vertices in some $axisset_{powerk}$ not centered at $(0,0)$, which we have already ruled out.\n\n\\item\nIt remains to show that we cannot have $(vertexa,vertexb) \\in axissetk$ and $(vertexc,vertexd) \\in diagsetk$ for some $powerk$.\nBy symmetry, we may reduce to the case where $(vertexa,vertexb) = (0, 2^{powerk})$ and $(vertexc,vertexd) = (2^{powerell}, \\pm 2^{powerell})$.\nIf $vertexd>0$, then the third vertex $(2^{powerk-1}, 2^{powerk-1} + 2^{powerell})$ is impossible.\nIf $vertexd<0$, then the third vertex $(-2^{powerk-1}, 2^{powerk-1} - 2^{powerell})$ is impossible.\n\\end{itemize}\n\nSumming up, we obtain\n\\[\n4\\,paramnn + \\left\\lfloor \\frac{paramnn}{2} \\right\\rfloor + 1 + \\left\\lfloor \\frac{paramnn+1}{2} \\right\\rfloor = 5\\,paramnn+1\n\\]\nsquares, proving the claim.\n\n\\noindent\n\\textbf{Remark.}\nGiven the computation of $mainset_{paramnn}$, we can alternatively show that the number of squares with vertices in $mainset_{paramnn}$ is $5\\,paramnn+1$ as follows. Since this is clearly true for $paramnn=1$, it suffices to show that for $paramnn \\ge 2$, there are exactly $5$ squares with vertices in $mainset_{paramnn}$, at least one of which is not in $mainset_{paramnn-1}$. Note that the convex hull of $mainset_{paramnn}$ is a square $hullsqr$ whose four vertices are the four points in $mainset_{paramnn} \\setminus mainset_{paramnn-1}$. If $v$ is one of these points, then a square with a vertex at $v$ can only lie in $hullsqr$ if its two sides containing $v$ are in line with the two sides of $hullsqr$ containing $v$. It follows that there are exactly two squares with a vertex at $v$ and all vertices in $mainset_{paramnn}$: the square corresponding to $hullsqr$ itself, and a square whose vertex diagonally opposite to $v$ is the origin. Taking the union over the four points in $mainset_{paramnn} \\setminus mainset_{paramnn-1}$ gives a total of $5$ squares, as desired."
    },
    "descriptive_long_confusing": {
      "map": {
        "x": "lanternfish",
        "y": "honeybadger",
        "a": "sunflower",
        "b": "caterpillar",
        "c": "pinecone",
        "d": "horseshoe",
        "k": "marigold",
        "\\ell": "blueberry",
        "P_n": "rainshadow",
        "Q_n": "driftwood",
        "Q_k": "starflower",
        "R_n": "tumbleweed",
        "R_k": "dragonfruit",
        "S": "cloudberry",
        "n": "waterfall"
      },
      "question": "Denote by $\\mathbb{Z}^2$ the set of all points $(lanternfish,honeybadger)$ in the plane with integer coordinates. For each integer $waterfall \\geq 0$, let $rainshadow$ be the subset of $\\mathbb{Z}^2$ consisting of the point $(0,0)$ together with all points $(lanternfish,honeybadger)$ such that $lanternfish^2 + honeybadger^2 = 2^{marigold}$ for some integer $marigold \\leq waterfall$. Determine, as a function of $waterfall$, the number of four-point subsets of $rainshadow$ whose elements are the vertices of a square.",
      "solution": "The answer is $5waterfall+1$.\n\nWe first determine the set $rainshadow$. Let $driftwood$ be the set of points in $\\mathbb{Z}^2$ of the form $(0, \\pm 2^{marigold})$ or $(\\pm 2^{marigold}, 0)$ for some $marigold \\leq waterfall$. Let $tumbleweed$ be the set of points in $\\mathbb{Z}^2$ of the form $(\\pm 2^{marigold}, \\pm 2^{marigold})$ for some $marigold \\leq waterfall$ (the two signs being chosen independently).\nWe prove by induction on $waterfall$ that\n\\[\nrainshadow = \\{(0,0)\\} \\cup Q_{\\lfloor waterfall/2 \\rfloor} \\cup R_{\\lfloor (waterfall-1)/2 \\rfloor}.\n\\]\nWe take as base cases the straightforward computations\n\\begin{align*}\nP_0 &= \\{(0,0), (\\pm 1, 0), (0, \\pm 1)\\} \\\\\nP_1 &= P_0 \\cup \\{(\\pm 1, \\pm 1)\\}.\n\\end{align*}\nFor $waterfall \\geq 2$, it is clear that $\\{(0,0)\\} \\cup Q_{\\lfloor waterfall/2 \\rfloor} \\cup R_{\\lfloor (waterfall-1)/2 \\rfloor} \\subseteq rainshadow$, so it remains to prove the reverse inclusion. For $(lanternfish,honeybadger) \\in rainshadow$, note that $lanternfish^2 + honeybadger^2 \\equiv 0 \\pmod{4}$; since every perfect square is congruent to either 0 or 1 modulo 4, $lanternfish$ and $honeybadger$ must both be even. Consequently, $(lanternfish/2, honeybadger/2) \\in P_{waterfall-2}$, so we may appeal to the induction hypothesis to conclude.\n\nWe next identify all of the squares with vertices in $rainshadow$. In the following discussion, let $(sunflower,caterpillar)$ and $(pinecone,horseshoe)$ be two opposite vertices of a square, so that the other two vertices are\n\\[\n\\left( \\frac{sunflower-caterpillar+pinecone+horseshoe}{2}, \\frac{sunflower+caterpillar-pinecone+horseshoe}{2} \\right)\n\\]\nand\n\\[\n\\left( \\frac{sunflower+caterpillar+pinecone-horseshoe}{2}, \\frac{-sunflower+caterpillar+pinecone+horseshoe}{2} \\right).\n\\]\n\\begin{itemize}\n\\item\nSuppose that $(sunflower,caterpillar) = (0,0)$. Then $(pinecone,horseshoe)$ may be any element of $rainshadow$ not contained in $P_0$. The number of such squares is $4waterfall$.\n\n\\item\nSuppose that $(sunflower,caterpillar), (pinecone,horseshoe) \\in Q_{marigold}$ for some $marigold$. There is one such square with vertices\n\\[\n\\{(0, 2^{marigold}), (0, 2^{-marigold}), (2^{marigold}, 0), (2^{-marigold}, 0)\\}\n\\]\nfor $marigold = 0,\\dots,\\lfloor \\tfrac{waterfall}{2} \\rfloor$, for a total of $\\lfloor \\tfrac{waterfall}{2} \\rfloor + 1$. To show that there are no others, by symmetry it suffices to rule out the existence of a square with opposite vertices $(sunflower,0)$ and $(pinecone,0)$ where $sunflower > |pinecone|$. The other two vertices of this square would be $((sunflower+pinecone)/2, (sunflower-pinecone)/2)$ and $((sunflower+pinecone)/2, (-sunflower+pinecone)/2)$. These cannot belong to any $starflower$, or be equal to $(0,0)$, because $|sunflower+pinecone|, |sunflower-pinecone| \\geq sunflower - |pinecone| > 0$ by the triangle inequality. These also cannot belong to any $dragonfruit$ because $(sunflower + |pinecone|)/2 > (sunflower - |pinecone|)/2$.\n\n\\item\nSuppose that $(sunflower,caterpillar), (pinecone,horseshoe) \\in R_{marigold}$ for some $marigold$. There is one such square with vertices\n\\[\n\\{(2^{marigold}, 2^{marigold}), (2^{marigold}, -2^{marigold}), (-2^{marigold}, 2^{marigold}), (-2^{marigold}, -2^{marigold})\\}\n\\]\nfor $marigold=0,\\dots, \\lfloor \\tfrac{waterfall-1}{2} \\rfloor$, for a total of $\\lfloor \\tfrac{waterfall+1}{2} \\rfloor$. To show that there are no others, we may reduce to the previous case: rotating by an angle of $\\tfrac{\\pi}{4}$ and then rescaling by a factor of $\\sqrt{2}$ would yield a square with two opposite vertices in some $Q_{marigold}$ not centered at $(0,0)$, which we have already ruled out.\n\n\\item\nIt remains to show that we cannot have $(sunflower,caterpillar) \\in Q_{marigold}$ and $(pinecone,horseshoe) \\in R_{marigold}$ for some $marigold$. By symmetry, we may reduce to the case where $(sunflower,caterpillar) = (0, 2^{marigold})$ and $(pinecone,horseshoe) = (2^{blueberry}, \\pm 2^{blueberry})$. If $horseshoe>0$, then the third vertex $(2^{marigold-1}, 2^{marigold-1} + 2^{blueberry})$ is impossible. If $horseshoe<0$, then the third vertex $(-2^{marigold-1}, 2^{marigold-1} - 2^{blueberry})$ is impossible.\n\\end{itemize}\n\nSumming up, we obtain\n\\[\n4waterfall + \\left\\lfloor \\frac{waterfall}{2} \\right\\rfloor + 1 + \\left\\lfloor \\frac{waterfall+1}{2} \\right\\rfloor = 5waterfall+1\n\\]\nsquares, proving the claim.\n\n\\noindent\\textbf{Remark.} Given the computation of $rainshadow$, we can alternatively show that the number of squares with vertices in $rainshadow$ is $5waterfall+1$ as follows. Since this is clearly true for $waterfall=1$, it suffices to show that for $waterfall \\geq 2$, there are exactly $5$ squares with vertices in $rainshadow$, at least one of which is not in $P_{waterfall-1}$. Note that the convex hull of $rainshadow$ is a square $cloudberry$ whose four vertices are the four points in $rainshadow \\setminus P_{waterfall-1}$. If $v$ is one of these points, then a square with a vertex at $v$ can only lie in $cloudberry$ if its two sides containing $v$ are in line with the two sides of $cloudberry$ containing $v$. It follows that there are exactly two squares with a vertex at $v$ and all vertices in $rainshadow$: the square corresponding to $cloudberry$ itself, and a square whose vertex diagonally opposite to $v$ is the origin. Taking the union over the four points in $rainshadow \\setminus P_{waterfall-1}$ gives a total of $5$ squares, as desired."
    },
    "descriptive_long_misleading": {
      "map": {
        "x": "verticalcoord",
        "y": "horizontalcoord",
        "a": "constantvalue",
        "b": "steadfastvalue",
        "c": "tranquilvalue",
        "d": "stablemeasure",
        "k": "constantindex",
        "\\ell": "shortindex",
        "P_n": "emptinessfamily",
        "Q_n": "diagonalfamily",
        "Q_k": "diagonalsubset",
        "R_n": "axialfamily",
        "R_k": "axialsubset",
        "S": "roundshape",
        "n": "mutableindex"
      },
      "question": "Denote by $\\mathbb{Z}^2$ the set of all points $(verticalcoord,horizontalcoord)$ in the plane with integer coordinates. For each integer $mutableindex \\geq 0$, let $emptinessfamily$ be the subset of $\\mathbb{Z}^2$ consisting of the point $(0,0)$ together with all points $(verticalcoord,horizontalcoord)$ such that $verticalcoord^2 + horizontalcoord^2 = 2^{constantindex}$ for some integer $constantindex \\leq mutableindex$. Determine, as a function of $mutableindex$, the number of four-point subsets of $emptinessfamily$ whose elements are the vertices of a square.",
      "solution": "The answer is $5mutableindex+1$.\n\nWe first determine the set $emptinessfamily$. Let $diagonalfamily$ be the set of points in $\\mathbb{Z}^2$ of the form $(0, \\pm 2^{constantindex})$ or $(\\pm 2^{constantindex}, 0)$ for some $constantindex \\leq mutableindex$. Let $axialfamily$ be the set of points in $\\mathbb{Z}^2$ of the form $(\\pm 2^{constantindex}, \\pm 2^{constantindex})$ for some $constantindex \\leq mutableindex$ (the two signs being chosen independently). \nWe prove by induction on $mutableindex$ that\n\\[\nemptinessfamily = \\{(0,0)\\} \\cup diagonalfamily_{\\lfloor mutableindex/2 \\rfloor} \\cup axialfamily_{\\lfloor (mutableindex-1)/2 \\rfloor}.\n\\]\nWe take as base cases the straightforward computations\n\\begin{align*}\nemptinessfamily_{0} &= \\{(0,0), (\\pm 1, 0), (0, \\pm 1)\\} \\\\\nemptinessfamily_{1} &= emptinessfamily_{0} \\cup \\{(\\pm 1, \\pm 1)\\}.\n\\end{align*}\nFor $mutableindex \\geq 2$, it is clear that $\\{(0,0)\\} \\cup diagonalfamily_{\\lfloor mutableindex/2 \\rfloor} \\cup axialfamily_{\\lfloor (mutableindex-1)/2 \\rfloor} \\subseteq emptinessfamily$, so it remains to prove the reverse inclusion. For $(verticalcoord,horizontalcoord) \\in emptinessfamily$, note that $verticalcoord^2 + horizontalcoord^2 \\equiv 0 \\pmod{4}$;\nsince every perfect square is congruent to either 0 or 1 modulo 4, $verticalcoord$ and $horizontalcoord$ must both be even. Consequently,\n$(verticalcoord/2, horizontalcoord/2) \\in emptinessfamily_{mutableindex-2}$, so we may appeal to the induction hypothesis to conclude.\n\nWe next identify all of the squares with vertices in $emptinessfamily$. In the following discussion, let $(constantvalue,steadfastvalue)$\nand $(tranquilvalue,stablemeasure)$ be two opposite vertices of a square, so that the other two vertices are\n\\[\n\\left( \\frac{constantvalue-steadfastvalue+tranquilvalue+stablemeasure}{2}, \\frac{constantvalue+steadfastvalue-tranquilvalue+stablemeasure}{2} \\right)\n\\]\nand \n\\[\n\\left( \\frac{constantvalue+steadfastvalue+tranquilvalue-stablemeasure}{2}, \\frac{-constantvalue+steadfastvalue+tranquilvalue+stablemeasure}{2} \\right).\n\\]\n\\begin{itemize}\n\\item\nSuppose that $(constantvalue,steadfastvalue) = (0,0)$. Then $(tranquilvalue,stablemeasure)$ may be any element of $emptinessfamily$ not contained in $emptinessfamily_{0}$.\nThe number of such squares is $4mutableindex$.\n\n\\item\nSuppose that $(constantvalue,steadfastvalue), (tranquilvalue,stablemeasure) \\in diagonalsubset$ for some $constantindex$. \nThere is one such square with vertices \n\\[\n\\{(0, 2^{constantindex}), (0, 2^{-constantindex}), (2^{constantindex}, 0), (2^{-constantindex}, 0)\\}\n\\]\nfor $constantindex = 0,\\dots,\\lfloor \\frac{mutableindex}{2} \\rfloor$, for a total of $\\lfloor \\frac{mutableindex}{2} \\rfloor + 1$.\nTo show that there are no others, by symmetry it suffices to rule out the existence of a square with\nopposite vertices $(constantvalue,0)$ and $(tranquilvalue,0)$ where $constantvalue > \\left| tranquilvalue \\right|$. \nThe other two vertices of this square would be $((constantvalue+tranquilvalue)/2, (constantvalue-tranquilvalue)/2)$ and $((constantvalue+tranquilvalue)/2, (-constantvalue+tranquilvalue)/2)$.\nThese cannot belong to any diagonalsubset, or be equal to $(0,0)$,\nbecause $|constantvalue+tranquilvalue|, |constantvalue-tranquilvalue| \\geq constantvalue - |tranquilvalue| > 0$ by the triangle inequality.\nThese also cannot belong to any axialsubset because $(constantvalue + |tranquilvalue|)/2 > (constantvalue - |tranquilvalue|)/2$. \n(One can also phrase this argument in geometric terms.)\n\n\\item\nSuppose that $(constantvalue,steadfastvalue), (tranquilvalue,stablemeasure) \\in axialsubset$ for some $constantindex$.\nThere is one such square with vertices\n\\[\n\\{(2^{constantindex}, 2^{constantindex}), (2^{constantindex}, -2^{constantindex}), (-2^{constantindex}, 2^{constantindex}), (-2^{constantindex}, -2^{constantindex})\\}\n\\]\nfor $constantindex=0,\\dots, \\lfloor \\frac{mutableindex-1}{2} \\rfloor$, for a total of $\\lfloor \\frac{mutableindex+1}{2} \\rfloor$.\nTo show that there are no others, we may reduce to the previous case: rotating by an angle of $\\frac{\\pi}{4}$ and then rescaling by a factor of $\\sqrt{2}$ would yield a square with two opposite vertices in some diagonalsubset not centered at $(0,0)$, which we have already ruled out.\n\n\\item\nIt remains to show that we cannot have $(constantvalue,steadfastvalue) \\in diagonalsubset$ and $(tranquilvalue,stablemeasure) \\in axialsubset$ for some $constantindex$.\nBy symmetry, we may reduce to the case where $(constantvalue,steadfastvalue) = (0, 2^{constantindex})$ and $(tranquilvalue,stablemeasure) = (2^{shortindex}, \\pm 2^{shortindex})$.\nIf $stablemeasure>0$, then the third vertex $(2^{constantindex-1}, 2^{constantindex-1} + 2^{shortindex})$ is impossible.\nIf $stablemeasure<0$, then the third vertex $(-2^{constantindex-1}, 2^{constantindex-1} - 2^{shortindex})$ is impossible.\n\n\\end{itemize}\n\nSumming up, we obtain\n\\[\n4mutableindex + \\left\\lfloor \\frac{mutableindex}{2} \\right\\rfloor + 1 + \\left\\lfloor \\frac{mutableindex+1}{2} \\right\\rfloor = 5mutableindex+1\n\\]\nsquares, proving the claim.\n\n\\noindent\n\\textbf{Remark.}\nGiven the computation of $emptinessfamily$, we can alternatively show that the number of squares with vertices in $emptinessfamily$ is $5mutableindex+1$ as follows. Since this is clearly true for $mutableindex=1$, it suffices to show that for $mutableindex \\geq 2$, there are exactly $5$ squares with vertices in $emptinessfamily$, at least one of which is not in $emptinessfamily_{mutableindex-1}$. Note that the convex hull of $emptinessfamily$ is a square $roundshape$ whose four vertices are the four points in $emptinessfamily \\setminus emptinessfamily_{mutableindex-1}$. If $v$ is one of these points, then a square with a vertex at $v$ can only lie in $roundshape$ if its two sides containing $v$ are in line with the two sides of $roundshape$ containing $v$. It follows that there are exactly two squares with a vertex at $v$ and all vertices in $emptinessfamily$: the square corresponding to $roundshape$ itself, and a square whose vertex diagonally opposite to $v$ is the origin. Taking the union over the four points in $emptinessfamily \\setminus emptinessfamily_{mutableindex-1}$ gives a total of $5$ squares, as desired."
    },
    "garbled_string": {
      "map": {
        "x": "qzxwvtnp",
        "y": "hjgrksla",
        "a": "cidfuhsee",
        "b": "mratokewn",
        "c": "plodixcse",
        "d": "ravnuxpto",
        "k": "sjelmivqu",
        "\\ell": "zoryknuve",
        "P_n": "fugeravxi",
        "Q_n": "wcespqndr",
        "Q_k": "gthqipolr",
        "R_n": "dzxkvyhpl",
        "R_k": "umorhasdc",
        "S": "xbtpojnls",
        "n": "vnetqxwhp"
      },
      "question": "Denote by $\\mathbb{Z}^2$ the set of all points $(qzxwvtnp,hjgrksla)$ in the plane with integer coordinates. For each integer $vnetqxwhp \\geq 0$, let $fugeravxi$ be the subset of $\\mathbb{Z}^2$ consisting of the point $(0,0)$ together with all points $(qzxwvtnp,hjgrksla)$ such that $qzxwvtnp^2 + hjgrksla^2 = 2^{sjelmivqu}$ for some integer $sjelmivqu \\leq vnetqxwhp$. Determine, as a function of $vnetqxwhp$, the number of four-point subsets of $fugeravxi$ whose elements are the vertices of a square.",
      "solution": "The answer is $5vnetqxwhp+1$.\n\nWe first determine the set $fugeravxi$. Let $wcespqndr$ be the set of points in $\\mathbb{Z}^2$ of the form $(0, \\pm 2^{sjelmivqu})$ or $(\\pm 2^{sjelmivqu}, 0)$ for some $sjelmivqu \\leq vnetqxwhp$. Let $dzxkvyhpl$ be the set of points in $\\mathbb{Z}^2$ of the form $(\\pm 2^{sjelmivqu}, \\pm 2^{sjelmivqu})$ for some $sjelmivqu \\leq vnetqxwhp$ (the two signs being chosen independently). \nWe prove by induction on $vnetqxwhp$ that\n\\[\nfugeravxi = \\{(0,0)\\} \\cup wcespqndr_{\\lfloor vnetqxwhp/2 \\rfloor} \\cup dzxkvyhpl_{\\lfloor (vnetqxwhp-1)/2 \\rfloor}.\n\\]\nWe take as base cases the straightforward computations\n\\begin{align*}\nfugeravxi_0 &= \\{(0,0), (\\pm 1, 0), (0, \\pm 1)\\} \\\\ \nfugeravxi_1 &= fugeravxi_0 \\cup \\{(\\pm 1, \\pm 1)\\}.\n\\end{align*}\nFor $vnetqxwhp \\geq 2$, it is clear that $\\{(0,0)\\} \\cup wcespqndr_{\\lfloor vnetqxwhp/2 \\rfloor} \\cup dzxkvyhpl_{\\lfloor (vnetqxwhp-1)/2 \\rfloor} \\subseteq fugeravxi$, so it remains to prove the reverse inclusion. For $(qzxwvtnp,hjgrksla) \\in fugeravxi$, note that $qzxwvtnp^2 + hjgrksla^2 \\equiv 0 \\pmod{4}$; since every perfect square is congruent to either 0 or 1 modulo 4, $qzxwvtnp$ and $hjgrksla$ must both be even. Consequently, $(qzxwvtnp/2, hjgrksla/2) \\in fugeravxi_{vnetqxwhp-2}$, so we may appeal to the induction hypothesis to conclude.\n\nWe next identify all of the squares with vertices in $fugeravxi$. In the following discussion, let $(cidfuhsee,mratokewn)$ and $(plodixcse,ravnuxpto)$ be two opposite vertices of a square, so that the other two vertices are\n\\[\n\\left( \\frac{cidfuhsee-mratokewn+plodixcse+ravnuxpto}{2}, \\frac{cidfuhsee+mratokewn-plodixcse+ravnuxpto}{2} \\right)\n\\]\nand\n\\[\n\\left( \\frac{cidfuhsee+mratokewn+plodixcse-ravnuxpto}{2}, \\frac{-cidfuhsee+mratokewn+plodixcse+ravnuxpto}{2} \\right).\n\\]\n\\begin{itemize}\n\\item Suppose that $(cidfuhsee,mratokewn) = (0,0)$. Then $(plodixcse,ravnuxpto)$ may be any element of $fugeravxi$ not contained in $fugeravxi_0$. The number of such squares is $4vnetqxwhp$.\n\n\\item Suppose that $(cidfuhsee,mratokewn), (plodixcse,ravnuxpto) \\in gthqipolr_{sjelmivqu}$ for some $sjelmivqu$. There is one such square with vertices\n\\[\n\\{(0, 2^{sjelmivqu}), (0, 2^{-sjelmivqu}), (2^{sjelmivqu}, 0), (2^{-sjelmivqu}, 0)\\}\n\\]\nfor $sjelmivqu = 0,\\dots,\\lfloor \\tfrac{vnetqxwhp}{2} \\rfloor$, for a total of $\\lfloor \\tfrac{vnetqxwhp}{2} \\rfloor + 1$. To show that there are no others, by symmetry it suffices to rule out the existence of a square with opposite vertices $(cidfuhsee,0)$ and $(plodixcse,0)$ where $cidfuhsee > |plodixcse|$. The other two vertices of this square would be $((cidfuhsee+plodixcse)/2, (cidfuhsee-plodixcse)/2)$ and $((cidfuhsee+plodixcse)/2, (-cidfuhsee+plodixcse)/2)$. These cannot belong to any $gthqipolr_{sjelmivqu}$, or be equal to $(0,0)$, because $|cidfuhsee+plodixcse|, |cidfuhsee-plodixcse| \\ge cidfuhsee - |plodixcse| > 0$ by the triangle inequality. These also cannot belong to any $umorhasdc_{sjelmivqu}$ because $(cidfuhsee + |plodixcse|)/2 > (cidfuhsee - |plodixcse|)/2$.\n\n\\item Suppose that $(cidfuhsee,mratokewn), (plodixcse,ravnuxpto) \\in umorhasdc_{sjelmivqu}$ for some $sjelmivqu$. There is one such square with vertices\n\\[\n\\{(2^{sjelmivqu}, 2^{sjelmivqu}), (2^{sjelmivqu}, -2^{sjelmivqu}), (-2^{sjelmivqu}, 2^{sjelmivqu}), (-2^{sjelmivqu}, -2^{sjelmivqu})\\}\n\\]\nfor $sjelmivqu = 0,\\dots, \\lfloor \\tfrac{vnetqxwhp-1}{2} \\rfloor$, for a total of $\\lfloor \\tfrac{vnetqxwhp+1}{2} \\rfloor$. To show that there are no others, we may reduce to the previous case: rotating by an angle of $\\tfrac{\\pi}{4}$ and then rescaling by a factor of $\\sqrt{2}$ would yield a square with two opposite vertices in some $gthqipolr_{sjelmivqu}$ not centered at $(0,0)$, which we have already ruled out.\n\n\\item It remains to show that we cannot have $(cidfuhsee,mratokewn) \\in gthqipolr_{sjelmivqu}$ and $(plodixcse,ravnuxpto) \\in umorhasdc_{sjelmivqu}$ for some $sjelmivqu$. By symmetry, we may reduce to the case where $(cidfuhsee,mratokewn) = (0, 2^{sjelmivqu})$ and $(plodixcse,ravnuxpto) = (2^{zoryknuve}, \\pm 2^{zoryknuve})$. If $ravnuxpto>0$, then the third vertex $(2^{sjelmivqu-1}, 2^{sjelmivqu-1} + 2^{zoryknuve})$ is impossible. If $ravnuxpto<0$, then the third vertex $(-2^{sjelmivqu-1}, 2^{sjelmivqu-1} - 2^{zoryknuve})$ is impossible.\n\\end{itemize}\n\nSumming up, we obtain\n\\[\n4vnetqxwhp + \\left\\lfloor \\frac{vnetqxwhp}{2} \\right\\rfloor + 1 + \\left\\lfloor \\frac{vnetqxwhp+1}{2} \\right\\rfloor = 5vnetqxwhp+1\n\\]\nsquares, proving the claim.\n\n\\noindent\\textbf{Remark.} Given the computation of $fugeravxi$, we can alternatively show that the number of squares with vertices in $fugeravxi$ is $5vnetqxwhp+1$ as follows. Since this is clearly true for $vnetqxwhp=1$, it suffices to show that for $vnetqxwhp \\ge 2$, there are exactly $5$ squares with vertices in $fugeravxi$, at least one of which is not in $fugeravxi_{vnetqxwhp-1}$. Note that the convex hull of $fugeravxi$ is a square $xbtpojnls$ whose four vertices are the four points in $fugeravxi \\setminus fugeravxi_{vnetqxwhp-1}$. If $v$ is one of these points, then a square with a vertex at $v$ can only lie in $xbtpojnls$ if its two sides containing $v$ are in line with the two sides of $xbtpojnls$ containing $v$. It follows that there are exactly two squares with a vertex at $v$ and all vertices in $fugeravxi$: the square corresponding to $xbtpojnls$ itself, and a square whose vertex diagonally opposite to $v$ is the origin. Taking the union over the four points in $fugeravxi \\setminus fugeravxi_{vnetqxwhp-1}$ gives a total of $5$ squares, as desired."
    },
    "kernel_variant": {
      "question": "Let ℤ² be the usual square lattice in the plane.  For an integer n ≥ 2 put\n\n        Pₙ := { (x , y) ∈ ℤ²  |  x² + y² = 2ᵏ for some integer k with 2 ≤ k ≤ n } .\n\n(Thus the origin and the lattice points that lie on the circles of radius 1 and √2 are excluded.)\n\nHow many four-point subsets of Pₙ are the four vertices of a square?  Give the answer explicitly as a function of n.",
      "solution": "Notation.  For (x , y) ∈ ℤ² write ∥(x , y)∥² = x²+y² and let v₂(m) be the 2-adic valuation of an integer m (v₂(0)=∞).\n\n1.  The lattice points with norm 2ᵏ , k ≥ 2\n------------------------------------------\nFor t ≥ 1 set\n    Q_t := { (±2ᵗ , 0) , (0 , ±2ᵗ) } ,            (axis points)\n    R_t := { (±2ᵗ , ±2ᵗ) } .                       (diagonal points)\n\nA classical parametrisation of integer solutions of x²+y² = 2ᵏ together with a short divisibility argument yields\n\n    x²+y² = 2ᵏ  (k ≥ 2)  ⇔  { x , y } = { 0 , ±2ᵗ }   if k = 2t ,\n                           { ±2ᵗ , ±2ᵗ }             if k = 2t+1.\n\nHence\n    Pₙ = ( ⋃_{t=1}^{⌊n/2⌋} Q_t ) ⊔ ( ⋃_{t=1}^{⌊(n-1)/2⌋} R_t ).   (1)\nEach of the ‘rings’ Q_t and R_t consists of four points that themselves form a square with centre (0,0).\n\n2.  Squares cannot use two different rings\n-----------------------------------------\nLemma.  Every square whose four vertices lie in Pₙ is contained in a single ring Q_t or R_t.\n\nProof.  Let S be such a square.  We distinguish two possibilities for the distribution of its vertices over rings.\n\n(A)  Two opposite vertices come from different rings.\n\n      Suppose u ∈ Q_s and w ∈ Q_t with s < t are opposite vertices of S.  As in §2·1 of the original solution we place\n          u = (2ˢ , 0) ,   w = (2ᵗ , 0).\n      The other two vertices are\n          v₁ = ((2ˢ+2ᵗ)/2 ,  (2ᵗ−2ˢ)/2) ,  v₂ = ((2ˢ+2ᵗ)/2 , −(2ᵗ−2ˢ)/2).\n      The second coordinate (2ᵗ−2ˢ)/2 is 2^{s−1}(2^{t−s}−1) and therefore contains an odd factor; consequently v₁ and v₂ do not lie in any ring, contradicting S ⊂ Pₙ.  The same computation works verbatim for the combination ‘two different R–rings’ after carrying out the similarity (rotation through 45° followed by the homothety of factor √2) that sends every point (±2ᵗ,±2ᵗ) to (±2^{t+1},0) or (0,±2^{t+1}).  Because the images are still integer points, the case ‘two R–rings’ is reduced to the one just treated.  Finally, the mixed case ‘one Q–ring, one R–ring’ with the opposite vertices in different rings is ruled out exactly as in §2·3 of the original text.  Hence no square can have opposite vertices in different rings.\n\n(B)  The vertices alternate between two rings.\n\n      Assume the opposite vertices A,C lie in one ring and the opposite vertices B,D in another.  Denote their rings by 𝔄 and 𝔅, respectively.\n\n      •  If 𝔄 = Q_s and 𝔅 = Q_t with s ≠ t, then |AC| = 2^{s+1} and |BD| = 2^{t+1}.  Since the two diagonals of a square must have the same length, we must have 2^{s+1} = 2^{t+1}, whence s = t, contradicting s ≠ t.\n\n      •  If 𝔄 = R_s and 𝔅 = R_t with s ≠ t, then |AC| = 2^{s+1}√2 and |BD| = 2^{t+1}√2.  Equality of the diagonals forces s = t, again impossible.\n\n      •  If 𝔄 = Q_s and 𝔅 = R_t (or vice versa) we obtain |AC| = 2^{s+1} and |BD| = 2^{t+1}√2.  Equality gives 2^{s+1} = 2^{t+1}√2, or 2^{t−s} = √2, which is impossible because √2 is not an integral power of two.\n\n      Consequently the alternating configuration cannot occur.\n\nSince the two mutually exclusive possibilities (A) and (B) are impossible, every square contained in Pₙ must lie entirely inside one single ring. □\n\n3.  The only square in a ring is the ring itself\n-----------------------------------------------\nBecause every ring Q_t or R_t contains exactly the four vertices of one square, it obviously contains no other square.  Explicitly\n    Q_t  :  side-length  2ᵗ√2,   centre (0,0),\n    R_t  :  side-length  2^{t+1}, centre (0,0).\nThus each ring contributes precisely one square.\n\n4.  Counting the rings\n----------------------\nFrom (1) we read off that Pₙ contains\n      ⌊n/2⌋  rings of type Q   and   ⌊(n−1)/2⌋  rings of type R.\nTherefore the total number of squares equals\n      ⌊n/2⌋ + ⌊(n−1)/2⌋ = n − 1.   (n ≥ 2)\n\n5.  Small-n check\n-----------------\n n = 2 : Q₁ → 1 square.\n n = 3 : Q₁ , R₁ → 2 squares.\n n = 4 : Q₁ , Q₂ , R₁ → 3 squares.\nThese agree with the formula n − 1.\n\nAnswer.  The number of four-point subsets of Pₙ that form the vertices of a square is\n                       n − 1.",
      "_meta": {
        "core_steps": [
          "Parity-induction shows any lattice point with x²+y² = 2^k (k≥2) has even coordinates; halving lowers k by 2, giving a recursive description of P_n.",
          "From that recursion, decompose P_n into three disjoint sets: the origin, axial points Q_{⌊n/2⌋}, and diagonal points R_{⌊(n-1)/2⌋}.",
          "Classify all possible squares whose vertices lie in P_n into three mutually exclusive types: (i) those with the origin as a vertex, (ii) those whose opposite vertices are both in some Q_k, (iii) those whose opposite vertices are both in some R_k; show Q–R mixes are impossible.",
          "Count the squares in each class (4n, ⌊n/2⌋+1, ⌊(n+1)/2⌋ respectively) by symmetry/coordinate checks and sum the totals.",
          "Combine the counts to obtain 5n+1 squares."
        ],
        "mutable_slots": {
          "slot1": {
            "description": "Lowest exponent allowed in x²+y² = 2^k (currently k ≥ 0); shifting this lower bound by any fixed non-negative integer merely alters base cases while leaving the inductive step and subsequent classification intact.",
            "original": "k_min = 0"
          },
          "slot2": {
            "description": "Explicit inclusion of the centre point (0,0) in every P_n; removing or replacing it only subtracts/relocates the ‘origin-based’ family of squares, leaving the rest of the argument unchanged.",
            "original": "(0,0) ∈ P_n for all n"
          }
        }
      }
    }
  },
  "checked": true,
  "problem_type": "proof",
  "iteratively_fixed": true
}