{
  "index": "2008-A-3",
  "type": "NT",
  "tag": [
    "NT",
    "ALG",
    "COMB"
  ],
  "difficulty": "",
  "question": "Start with a finite sequence $a_1, a_2, \\dots, a_n$ of positive integers.\nIf possible, choose two indices $j < k$ such that $a_j$ does not divide\n$a_k$, and replace $a_j$ and $a_k$ by $\\mathrm{gcd}(a_j, a_k)$\nand $\\mathrm{lcm}(a_j, a_k)$, respectively. Prove that if this process is\nrepeated, it must eventually stop and the final sequence does not depend\non the choices made. (Note: gcd means greatest common divisor and lcm\nmeans least common multiple.)",
  "solution": "We first prove that the process stops. Note first that the product\n$a_1 \\cdots a_n$ remains constant, because\n$a_j a_k = \\gcd(a_j, a_k) \\lcm(a_j, a_k)$. Moreover,\nthe last number in the sequence can never decrease, because it is always\nreplaced by its least common multiple with another number.\nSince it is bounded above (by the product\nof all of the numbers), the last number must eventually reach its\nmaximum value, after which it remains constant throughout. After this\nhappens, the next-to-last number will never decrease, so it eventually\nbecomes constant, and so on. After finitely many steps, all of the numbers\nwill achieve their final values, so\nno more steps will be possible. This only happens when\n$a_j$ divides $a_k$ for all pairs $j < k$.\n\nWe next check that there is only one possible final sequence.\nFor $p$ a prime and $m$ a nonnegative integer, we claim that the number\nof integers in the list divisible by $p^m$ never changes. To see this,\nsuppose we replace $a_j, a_k$ by $\\gcd(a_j, a_k),\\lcm(a_j,a_k)$.\nIf neither of $a_j, a_k$ is divisible by $p^m$, then neither of\n$\\gcd(a_j, a_k),\\lcm(a_j,a_k)$ is either.\nIf exactly one $a_j, a_k$ is divisible by $p^m$, then\n$\\lcm(a_j,a_k)$ is divisible by $p^m$ but $\\gcd(a_j, a_k)$ is not.\n\n$\\gcd(a_j, a_k),\\lcm(a_j,a_k)$ are as well.\n\nIf we started out with exactly $h$ numbers not divisible by $p^m$,\nthen in the final sequence $a'_1, \\dots, a'_n$, the numbers\n$a'_{h+1}, \\dots, a'_n$ are divisible by $p^m$ while the numbers\n$a'_1, \\dots, a'_h$ are not. Repeating this argument for each\npair $(p,m)$ such that $p^m$ divides the initial product\n$a_1,\\dots,a_n$, we can determine the exact prime factorization\nof each of $a'_1,\\dots,a'_n$. This proves that the final sequence\nis unique.\n\n\\textbf{Remark:}\n(by David Savitt and Noam Elkies)\nHere are two other ways to prove the termination.\nOne is to observe that $\\prod_j a_j^j$\nis \\emph{strictly} increasing at each step, and bounded above by\n$(a_1\\cdots a_n)^n$. The other is to notice that $a_1$ is nonincreasing\nbut always positive, so eventually becomes constant; then\n$a_2$ is nonincreasing but always positive, and so on.\n\n\\textbf{Reinterpretation:}\nFor each $p$, consider the sequence consisting of the\nexponents of $p$ in the prime factorizations of $a_1,\\dots,a_n$.\nAt each step, we pick two positions $i$ and $j$ such that the exponents\nof some prime $p$ are in the wrong order at positions $i$ and $j$.\nWe then sort these two position into the correct order for every prime $p$\nsimultaneously.\n\nIt is clear that this can only terminate with all sequences being sorted\ninto the correct order. We must still check that the process terminates;\nhowever, since all but finitely many of the exponent\nsequences consist of all zeroes,\nand each step makes a nontrivial switch in at least one of the other exponent\nsequences, it is enough to check the case of a single exponent sequence.\nThis can be done as in the first solution.\n\n\\textbf{Remark:}\nAbhinav Kumar suggests the following proof that the process always terminates\nin at most  $\\binom{n}{2}$ steps.\n(This is a variant of the worst-case analysis of the \\emph{bubble sort}\nalgorithm.)\n\nConsider the number of pairs $(k,l)$\nwith $1 \\leq k < l \\leq n$ such that $a_k$ does not divide $a_l$\n(call these \\emph{bad pairs}).\nAt each step, we find one bad pair $(i,j)$ and eliminate it, and we do not\ntouch any pairs that do not involve either $i$ or $j$.\nIf $i < k < j$, then neither of the pairs $(i,k)$ and $(k,j)$ can become\nbad,\nbecause $a_i$ is replaced by a divisor of itself, while $a_j$ is replaced by\na multiple of itself. If $k < i$, then $(k,i)$ can only become a bad pair if\n$a_k$ divided $a_i$ but not $a_j$, in which case $(k,j)$ stops being bad.\nSimilarly, if $k > j$, then $(i,k)$ and $(j,k)$\neither stay the same or switch status. Hence the number of bad pairs\ngoes down by at least 1 each time; since it is at most $\\binom{n}{2}$\nto begin with, this is an upper bound for the number of steps.\n\n\\textbf{Remark:}\nThis problem is closely related to the classification theorem for\nfinite abelian groups. Namely, if $a_1,\\dots,a_n$\nand $a'_1,\\dots,a'_n$ are the sequences obtained at two different\nsteps in the process, then the abelian groups\n$\\ZZ/a_1 \\ZZ \\times \\cdots \\times \\ZZ/a_n \\ZZ$\nand\n$\\ZZ/a'_1 \\ZZ \\times \\cdots \\times \\ZZ/a'_n \\ZZ$\nare isomorphic. The final sequence gives a canonical\npresentation of this group; the terms of this sequence are called the\n\\emph{elementary divisors} or \\emph{invariant factors} of the group.\n\n\\textbf{Remark:} (by Tom Belulovich)\nA \\emph{lattice} is a partially ordered set $L$ in which for\nany two $x,y \\in L$, there is a unique minimal element $z$ with $z \\geq\nx$ and $z \\geq y$, called the \\emph{join} and denoted $x \\wedge y$,\nand there is a unique maximal element $z$ with $z \\leq x$ and $z \\leq y$,\ncalled the \\emph{meet} and denoted $x \\vee y$. In terms of a lattice $L$,\none can pose the following generalization of the given problem.\nStart with $a_1,\\dots,a_n \\in L$. If $i < j$ but $a_i \\not\\leq a_j$,\nit is permitted to replace $a_i, a_j$ by $a_i \\vee a_j, a_i \\wedge a_j$,\nrespectively. The same argument as above shows that this always terminates\nin at most $\\binom{n}{2}$ steps. The question is, under what conditions on\nthe lattice $L$ is the final sequence uniquely determined by the initial\nsequence?\n\nIt turns out that this holds if and only if $L$ is \\emph{distributive},\ni.e., for any $x,y,z \\in L$,\n\\[\nx \\wedge (y \\vee z)\n= (x \\wedge y) \\vee (x \\wedge z).\n\\]\n(This is equivalent to the same axiom with the operations interchanged.)\nFor example, if $L$ is a \\emph{Boolean algebra}, i.e., the set of subsets\nof a given set $S$ under inclusion, then $\\wedge$ is union, $\\vee$\nis intersection, and the distributive law holds.\nConversely, any finite\ndistributive lattice is contained in a Boolean algebra by a theorem of\nBirkhoff. The correspondence takes each  $x \\in L$ to the set of\n$y \\in L$ such that $x \\geq y$ and $y$ cannot be written as a join\nof two elements of $L \\setminus \\{y\\}$. (See for instance\nBirkhoff, \\textit{Lattice Theory}, Amer. Math. Soc., 1967.)\n\nOn one hand, if $L$ is distributive, it can be shown that the $j$-th term\nof the final sequence is equal to the meet of $a_{i_1} \\wedge \\cdots\n\\wedge a_{i_j}$ over all sequences $1 \\leq i_1 < \\cdots < i_j \\leq n$.\nFor instance, this can be checked by forming the smallest subset $L'$\nof $L$ containing $a_1,\\dots,a_n$ and closed under meet and join,\nthen embedding $L'$ into a Boolean algebra using\nBirkhoff's theorem, then checking the claim for all Boolean algebras.\nIt can also be checked directly (as suggested by Nghi Nguyen)\nby showing that for $j=1,\\dots,n$,\nthe meet of all joins of $j$-element subsets of $a_1,\\dots,a_n$ is\ninvariant at each step.\n\nOn the other hand,\na lattice fails to be distributive if and only if\nit contains five elements $a,b,c,0,1$ such that either the only relations\namong them are implied by\n\\[\n1 \\geq a,b,c \\geq 0\n\\]\n(this lattice is sometimes called the \\emph{diamond}),\nor the only relations among them  are implied by\n\\[\n1 \\geq a \\geq b \\geq 0, \\qquad 1 \\geq c \\geq 0\n\\]\n(this lattice is sometimes called the \\emph{pentagon}).\n(For a proof, see the Birkhoff reference given above.) For each of these\nexamples, the initial sequence $a,b,c$ fails to determine the final\nsequence; for the diamond, we can end up with $0, *, 1$ for\nany of $* = a,b,c$, whereas for the pentagon we can end up with\n$0, *, 1$ for any of $* = a, b$.\n\nConsequently, the final sequence is determined by the initial sequence\nif and only if $L$ is distributive.",
  "vars": [
    "a",
    "a_1",
    "a_2",
    "a_i",
    "a_j",
    "a_k",
    "a_n",
    "b",
    "c",
    "h",
    "i",
    "j",
    "k",
    "l",
    "x",
    "y",
    "z"
  ],
  "params": [
    "L",
    "S",
    "m",
    "n",
    "p"
  ],
  "sci_consts": [],
  "variants": {
    "descriptive_long": {
      "map": {
        "a": "baseseq",
        "a_1": "elementone",
        "a_2": "elementtwo",
        "a_i": "elementi",
        "a_j": "elementj",
        "a_k": "elementk",
        "a_n": "elementn",
        "b": "latticeb",
        "c": "latticec",
        "h": "counth",
        "i": "indexi",
        "j": "indexj",
        "k": "indexk",
        "l": "indexl",
        "x": "latticex",
        "y": "latticey",
        "z": "latticez",
        "L": "latticecap",
        "S": "setcapital",
        "m": "indexm",
        "n": "indexn",
        "p": "primep"
      },
      "question": "Start with a finite sequence $elementone, elementtwo, \\dots, elementn$ of positive integers.\nIf possible, choose two indices $indexj < indexk$ such that $elementj$ does not divide\n$elementk$, and replace $elementj$ and $elementk$ by $\\mathrm{gcd}(elementj, elementk)$\nand $\\mathrm{lcm}(elementj, elementk)$, respectively. Prove that if this process is\nrepeated, it must eventually stop and the final sequence does not depend\non the choices made. (Note: gcd means greatest common divisor and lcm\nmeans least common multiple.)",
      "solution": "We first prove that the process stops. Note first that the product\n$elementone \\cdots elementn$ remains constant, because\n$elementj\\,elementk = \\gcd(elementj, elementk) \\lcm(elementj, elementk)$. Moreover,\nthe last number in the sequence can never decrease, because it is always\nreplaced by its least common multiple with another number.\nSince it is bounded above (by the product\nof all of the numbers), the last number must eventually reach its\nmaximum value, after which it remains constant throughout. After this\nhappens, the next-to-last number will never decrease, so it eventually\nbecomes constant, and so on. After finitely many steps, all of the numbers\nwill achieve their final values, so\nno more steps will be possible. This only happens when\n$elementj$ divides $elementk$ for all pairs $indexj < indexk$.\n\nWe next check that there is only one possible final sequence.\nFor $primep$ a prime and $indexm$ a nonnegative integer, we claim that the number\nof integers in the list divisible by $primep^{indexm}$ never changes. To see this,\nsuppose we replace $elementj, elementk$ by $\\gcd(elementj, elementk),\\lcm(elementj,elementk)$.\nIf neither of $elementj, elementk$ is divisible by $primep^{indexm}$, then neither of\n$\\gcd(elementj, elementk),\\lcm(elementj,elementk)$ is either.\nIf exactly one $elementj, elementk$ is divisible by $primep^{indexm}$, then\n$\\lcm(elementj,elementk)$ is divisible by $primep^{indexm}$ but $\\gcd(elementj, elementk)$ is not.\n\n$\\gcd(elementj, elementk),\\lcm(elementj,elementk)$ are as well.\n\nIf we started out with exactly $counth$ numbers not divisible by $primep^{indexm}$,\nthen in the final sequence $baseseq'_1, \\dots, baseseq'_{indexn}$, the numbers\n$baseseq'_{counth+1}, \\dots, baseseq'_{indexn}$ are divisible by $primep^{indexm}$ while the numbers\n$baseseq'_1, \\dots, baseseq'_{counth}$ are not. Repeating this argument for each\npair $(primep,indexm)$ such that $primep^{indexm}$ divides the initial product\n$elementone,\\dots,elementn$, we can determine the exact prime factorization\nof each of $baseseq'_1,\\dots,baseseq'_{indexn}$. This proves that the final sequence\nis unique.\n\n\\textbf{Remark:}\n(by David Savitt and Noam Elkies)\nHere are two other ways to prove the termination.\nOne is to observe that $\\prod_{indexj} elementj^{indexj}$\nis \\emph{strictly} increasing at each step, and bounded above by\n$(elementone\\cdots elementn)^{indexn}$. The other is to notice that $elementone$ is nonincreasing\nbut always positive, so eventually becomes constant; then\n$elementtwo$ is nonincreasing but always positive, and so on.\n\n\\textbf{Reinterpretation:}\nFor each $primep$, consider the sequence consisting of the\nexponents of $primep$ in the prime factorizations of $elementone,\\dots,elementn$.\nAt each step, we pick two positions $indexi$ and $indexj$ such that the exponents\nof some prime $primep$ are in the wrong order at positions $indexi$ and $indexj$.\nWe then sort these two positions into the correct order for every prime $primep$\nsimultaneously.\n\nIt is clear that this can only terminate with all sequences being sorted\ninto the correct order. We must still check that the process terminates;\nhowever, since all but finitely many of the exponent\nsequences consist of all zeroes,\nand each step makes a nontrivial switch in at least one of the other exponent\nsequences, it is enough to check the case of a single exponent sequence.\nThis can be done as in the first solution.\n\n\\textbf{Remark:}\nAbhinav Kumar suggests the following proof that the process always terminates\nin at most  $\\binom{indexn}{2}$ steps.\n(This is a variant of the worst-case analysis of the \\emph{bubble sort}\nalgorithm.)\n\nConsider the number of pairs $(indexk,indexl)$\nwith $1 \\leq indexk < indexl \\leq indexn$ such that $elementk$ does not divide $baseseq_{indexl}$\n(call these \\emph{bad pairs}).\nAt each step, we find one bad pair $(indexi,indexj)$ and eliminate it, and we do not\ntouch any pairs that do not involve either $indexi$ or $indexj$.\nIf $indexi < indexk < indexj$, then neither of the pairs $(indexi,indexk)$ and $(indexk,indexj)$ can become\nbad,\nbecause $elementi$ is replaced by a divisor of itself, while $elementj$ is replaced by\na multiple of itself. If $indexk < indexi$, then $(indexk,indexi)$ can only become a bad pair if\n$elementk$ divided $elementi$ but not $elementj$, in which case $(indexk,indexj)$ stops being bad.\nSimilarly, if $indexk > indexj$, then $(indexi,indexk)$ and $(indexj,indexk)$\neither stay the same or switch status. Hence the number of bad pairs\ngoes down by at least 1 each time; since it is at most $\\binom{indexn}{2}$\nto begin with, this is an upper bound for the number of steps.\n\n\\textbf{Remark:}\nThis problem is closely related to the classification theorem for\nfinite abelian groups. Namely, if $elementone,\\dots,elementn$\nand $baseseq'_1,\\dots,baseseq'_{indexn}$ are the sequences obtained at two different\nsteps in the process, then the abelian groups\n$\\ZZ/elementone \\ZZ \\times \\cdots \\times \\ZZ/elementn \\ZZ$\nand\n$\\ZZ/baseseq'_1 \\ZZ \\times \\cdots \\times \\ZZ/baseseq'_{indexn} \\ZZ$\nare isomorphic. The final sequence gives a canonical\npresentation of this group; the terms of this sequence are called the\n\\emph{elementary divisors} or \\emph{invariant factors} of the group.\n\n\\textbf{Remark:} (by Tom Belulovich)\nA \\emph{lattice} is a partially ordered set $latticecap$ in which for\nany two $latticex,latticey \\in latticecap$, there is a unique minimal element $latticez$ with $latticez \\geq\nlatticex$ and $latticez \\geq latticey$, called the \\emph{join} and denoted $latticex \\wedge latticey$,\nand there is a unique maximal element $latticez$ with $latticez \\leq latticex$ and $latticez \\leq latticey$,\ncalled the \\emph{meet} and denoted $latticex \\vee latticey$. In terms of a lattice $latticecap$,\none can pose the following generalization of the given problem.\nStart with $elementone,\\dots,elementn \\in latticecap$. If $indexi < indexj$ but $elementi \\not\\leq elementj$,\nit is permitted to replace $elementi, elementj$ by $elementi \\vee elementj, elementi \\wedge elementj$,\nrespectively. The same argument as above shows that this always terminates\nin at most $\\binom{indexn}{2}$ steps. The question is, under what conditions on\nthe lattice $latticecap$ is the final sequence uniquely determined by the initial\nsequence?\n\nIt turns out that this holds if and only if $latticecap$ is \\emph{distributive},\ni.e., for any $latticex,latticey,latticez \\in latticecap$,\n\\[\nlatticex \\wedge (latticey \\vee latticez)\n= (latticex \\wedge latticey) \\vee (latticex \\wedge latticez).\n\\]\n(This is equivalent to the same axiom with the operations interchanged.)\nFor example, if $latticecap$ is a \\emph{Boolean algebra}, i.e., the set of subsets\nof a given set $setcapital$ under inclusion, then $\\wedge$ is union, $\\vee$\nis intersection, and the distributive law holds.\nConversely, any finite\ndistributive lattice is contained in a Boolean algebra by a theorem of\nBirkhoff. The correspondence takes each  $latticex \\in latticecap$ to the set of\n$latticey \\in latticecap$ such that $latticex \\geq latticey$ and $latticey$ cannot be written as a join\nof two elements of $latticecap \\setminus \\{latticey\\}$. (See for instance\nBirkhoff, \\textit{Lattice Theory}, Amer. Math. Soc., 1967.)\n\nOn one hand, if $latticecap$ is distributive, it can be shown that the $indexj$-th term\nof the final sequence is equal to the meet of $baseseq_{i_1} \\wedge \\cdots\n\\wedge baseseq_{i_{indexj}}$ over all sequences $1 \\leq i_1 < \\cdots < i_{indexj} \\leq indexn$.\nFor instance, this can be checked by forming the smallest subset $latticecap'$\nof $latticecap$ containing $elementone,\\dots,elementn$ and closed under meet and join,\nthen embedding $latticecap'$ into a Boolean algebra using\nBirkhoff's theorem, then checking the claim for all Boolean algebras.\nIt can also be checked directly (as suggested by Nghi Nguyen)\nby showing that for $indexj=1,\\dots,indexn$,\nthe meet of all joins of $indexj$-element subsets of $elementone,\\dots,elementn$ is\ninvariant at each step.\n\nOn the other hand,\na lattice fails to be distributive if and only if\nit contains five elements $baseseq,latticeb,latticec,0,1$ such that either the only relations\namong them are implied by\n\\[\n1 \\geq baseseq,latticeb,latticec \\geq 0\n\\]\n(this lattice is sometimes called the \\emph{diamond}),\nor the only relations among them  are implied by\n\\[\n1 \\geq baseseq \\geq latticeb \\geq 0, \\qquad 1 \\geq latticec \\geq 0\n\\]\n(this lattice is sometimes called the \\emph{pentagon}).\n(For a proof, see the Birkhoff reference given above.) For each of these\nexamples, the initial sequence $baseseq,latticeb,latticec$ fails to determine the final\nsequence; for the diamond, we can end up with $0, *, 1$ for\nany of $* = baseseq,latticeb,latticec$, whereas for the pentagon we can end up with\n$0, *, 1$ for any of $* = baseseq, latticeb$.\n\nConsequently, the final sequence is determined by the initial sequence\nif and only if $latticecap$ is distributive."
    },
    "descriptive_long_confusing": {
      "map": {
        "a": "blueberries",
        "a_1": "pineapple",
        "a_2": "blackcurrant",
        "a_i": "pomegranate",
        "a_j": "tangerine",
        "a_k": "watermelon",
        "a_n": "butternut",
        "b": "horsewhip",
        "c": "toothbrush",
        "h": "chandelier",
        "i": "i",
        "j": "shoelaces",
        "k": "marshmallow",
        "l": "screwdriver",
        "x": "paperclips",
        "y": "raincloud",
        "z": "fingernail",
        "L": "hummingbird",
        "S": "sailboats",
        "m": "caterpillar",
        "n": "jellybeans",
        "p": "gingerroot"
      },
      "question": "Start with a finite sequence $pineapple, blackcurrant, \\dots, butternut$ of positive integers.\nIf possible, choose two indices $shoelaces < marshmallow$ such that $tangerine$ does not divide\n$watermelon$, and replace $tangerine$ and $watermelon$ by $\\mathrm{gcd}(tangerine, watermelon)$\nand $\\mathrm{lcm}(tangerine, watermelon)$, respectively. Prove that if this process is\nrepeated, it must eventually stop and the final sequence does not depend\non the choices made. (Note: gcd means greatest common divisor and lcm\nmeans least common multiple.)",
      "solution": "We first prove that the process stops. Note first that the product\n$pineapple \\cdots butternut$ remains constant, because\n$tangerine \\, watermelon = \\gcd(tangerine, watermelon) \\, \\lcm(tangerine, watermelon)$. Moreover,\nthe last number in the sequence can never decrease, because it is always\nreplaced by its least common multiple with another number.\nSince it is bounded above (by the product\nof all of the numbers), the last number must eventually reach its\nmaximum value, after which it remains constant throughout. After this\nhappens, the next-to-last number will never decrease, so it eventually\nbecomes constant, and so on. After finitely many steps, all of the numbers\nwill achieve their final values, so\nno more steps will be possible. This only happens when\n$tangerine$ divides $watermelon$ for all pairs $shoelaces < marshmallow$.\n\nWe next check that there is only one possible final sequence.\nFor $gingerroot$ a prime and $caterpillar$ a nonnegative integer, we claim that the number\nof integers in the list divisible by $gingerroot^{caterpillar}$ never changes. To see this,\nsuppose we replace $tangerine, watermelon$ by $\\gcd(tangerine, watermelon),\\lcm(tangerine,watermelon)$.\nIf neither of $tangerine, watermelon$ is divisible by $gingerroot^{caterpillar}$, then neither of\n$\\gcd(tangerine, watermelon),\\lcm(tangerine,watermelon)$ is either.\nIf exactly one $tangerine, watermelon$ is divisible by $gingerroot^{caterpillar}$, then\n$\\lcm(tangerine,watermelon)$ is divisible by $gingerroot^{caterpillar}$ but $\\gcd(tangerine, watermelon)$ is not.\n\n$\\gcd(tangerine, watermelon),\\lcm(tangerine,watermelon)$ are as well.\n\nIf we started out with exactly $chandelier$ numbers not divisible by $gingerroot^{caterpillar}$,\nthen in the final sequence $a'_1, \\dots, a'_{jellybeans}$, the numbers\n$a'_{chandelier+1}, \\dots, a'_{jellybeans}$ are divisible by $gingerroot^{caterpillar}$ while the numbers\n$a'_1, \\dots, a'_{chandelier}$ are not. Repeating this argument for each\npair $(gingerroot,caterpillar)$ such that $gingerroot^{caterpillar}$ divides the initial product\n$pineapple,\\dots,butternut$, we can determine the exact prime factorization\nof each of $a'_1,\\dots,a'_{jellybeans}$. This proves that the final sequence\nis unique.\n\n\\textbf{Remark:}\n(by David Savitt and Noam Elkies)\nHere are two other ways to prove the termination.\nOne is to observe that $\\prod_{shoelaces} tangerine^{\\shoelaces}$\nis \\emph{strictly} increasing at each step, and bounded above by\n$(pineapple\\cdots butternut)^{jellybeans}$. The other is to notice that $pineapple$ is nonincreasing\nbut always positive, so eventually becomes constant; then\n$blackcurrant$ is nonincreasing but always positive, and so on.\n\n\\textbf{Reinterpretation:}\nFor each $gingerroot$, consider the sequence consisting of the\nexponents of $gingerroot$ in the prime factorizations of $pineapple,\\dots,butternut$.\nAt each step, we pick two positions $i$ and $shoelaces$ such that the exponents\nof some prime $gingerroot$ are in the wrong order at positions $i$ and $shoelaces$.\nWe then sort these two position into the correct order for every prime $gingerroot$\nsimultaneously.\n\nIt is clear that this can only terminate with all sequences being sorted\ninto the correct order. We must still check that the process terminates;\nhowever, since all but finitely many of the exponent\nsequences consist of all zeroes,\nand each step makes a nontrivial switch in at least one of the other exponent\nsequences, it is enough to check the case of a single exponent sequence.\nThis can be done as in the first solution.\n\n\\textbf{Remark:}\nAbhinav Kumar suggests the following proof that the process always terminates\nin at most  $\\binom{jellybeans}{2}$ steps.\n(This is a variant of the worst-case analysis of the \\emph{bubble sort}\nalgorithm.)\n\nConsider the number of pairs $(marshmallow,screwdriver)$\nwith $1 \\leq marshmallow < screwdriver \\leq jellybeans$ such that $watermelon$ does not divide $a_l$\n(call these \\emph{bad pairs}).\nAt each step, we find one bad pair $(i,shoelaces)$ and eliminate it, and we do not\ntouch any pairs that do not involve either $i$ or $shoelaces$.\nIf $i < marshmallow < shoelaces$, then neither of the pairs $(i,marshmallow)$ and $(marshmallow,shoelaces)$ can become\nbad,\nbecause $pomegranate$ is replaced by a divisor of itself, while $tangerine$ is replaced by\na multiple of itself. If $marshmallow < i$, then $(marshmallow,i)$ can only become a bad pair if\n$pomegranate$ divided $pomegranate$ but not $tangerine$, in which case $(marshmallow,shoelaces)$ stops being bad.\nSimilarly, if $marshmallow > shoelaces$, then $(i,marshmallow)$ and $(shoelaces,marshmallow)$\neither stay the same or switch status. Hence the number of bad pairs\ngoes down by at least 1 each time; since it is at most $\\binom{jellybeans}{2}$\nto begin with, this is an upper bound for the number of steps.\n\n\\textbf{Remark:}\nThis problem is closely related to the classification theorem for\nfinite abelian groups. Namely, if $pineapple,\\dots,butternut$\nand $a'_1,\\dots,a'_{jellybeans}$ are the sequences obtained at two different\nsteps in the process, then the abelian groups\n$\\ZZ/pineapple \\ZZ \\times \\cdots \\times \\ZZ/butternut \\ZZ$\nand\n$\\ZZ/a'_1 \\ZZ \\times \\cdots \\times \\ZZ/a'_{jellybeans} \\ZZ$\nare isomorphic. The final sequence gives a canonical\npresentation of this group; the terms of this sequence are called the\n\\emph{elementary divisors} or \\emph{invariant factors} of the group.\n\n\\textbf{Remark:} (by Tom Belulovich)\nA \\emph{lattice} is a partially ordered set $hummingbird$ in which for\nany two $paperclips,raincloud \\in hummingbird$, there is a unique minimal element $fingernail$ with $fingernail \\geq\npaperclips$ and $fingernail \\geq raincloud$, called the \\emph{join} and denoted $paperclips \\wedge raincloud$,\nand there is a unique maximal element $fingernail$ with $fingernail \\leq paperclips$ and $fingernail \\leq raincloud$,\ncalled the \\emph{meet} and denoted $paperclips \\vee raincloud$. In terms of a lattice $hummingbird$,\none can pose the following generalization of the given problem.\nStart with $pineapple,\\dots,butternut \\in hummingbird$. If $i < shoelaces$ but $pomegranate \\not\\leq tangerine$,\nit is permitted to replace $pomegranate, tangerine$ by $pomegranate \\vee tangerine, pomegranate \\wedge tangerine$,\nrespectively. The same argument as above shows that this always terminates\nin at most $\\binom{jellybeans}{2}$ steps. The question is, under what conditions on\nthe lattice $hummingbird$ is the final sequence uniquely determined by the initial\nsequence?\n\nIt turns out that this holds if and only if $hummingbird$ is \\emph{distributive},\ni.e., for any $paperclips,raincloud,fingernail \\in hummingbird$,\n\\[\npaperclips \\wedge (raincloud \\vee fingernail)\n= (paperclips \\wedge raincloud) \\vee (paperclips \\wedge fingernail).\n\\]\n(This is equivalent to the same axiom with the operations interchanged.)\nFor example, if $hummingbird$ is a \\emph{Boolean algebra}, i.e., the set of subsets\nof a given set $sailboats$ under inclusion, then $\\wedge$ is union, $\\vee$\nis intersection, and the distributive law holds.\nConversely, any finite\ndistributive lattice is contained in a Boolean algebra by a theorem of\nBirkhoff. The correspondence takes each  $fingernail \\in hummingbird$ to the set of\n$raincloud \\in hummingbird$ such that $fingernail \\geq raincloud$ and $raincloud$ cannot be written as a join\nof two elements of $hummingbird \\setminus \\{raincloud\\}$. (See for instance\nBirkhoff, \\textit{Lattice Theory}, Amer. Math. Soc., 1967.)\n\nOn one hand, if $hummingbird$ is distributive, it can be shown that the $shoelaces$-th term\nof the final sequence is equal to the meet of $a_{i_1} \\wedge \\cdots\n\\wedge a_{i_{shoelaces}}$ over all sequences $1 \\leq i_1 < \\cdots < i_{shoelaces} \\leq jellybeans$.\nFor instance, this can be checked by forming the smallest subset $hummingbird'$\nof $hummingbird$ containing $pineapple,\\dots,butternut$ and closed under meet and join,\nthen embedding $hummingbird'$ into a Boolean algebra using\nBirkhoff's theorem, then checking the claim for all Boolean algebras.\nIt can also be checked directly (as suggested by Nghi Nguyen)\nby showing that for $shoelaces=1,\\dots,jellybeans$,\nthe meet of all joins of $shoelaces$-element subsets of $pineapple,\\dots,butternut$ is\ninvariant at each step.\n\nOn the other hand,\na lattice fails to be distributive if and only if\nit contains five elements $blueberries,horsewhip,toothbrush,0,1$ such that either the only relations\namong them are implied by\n\\[\n1 \\geq blueberries,horsewhip,toothbrush \\geq 0\n\\]\n(this lattice is sometimes called the \\emph{diamond}),\nor the only relations among them  are implied by\n\\[\n1 \\geq blueberries \\geq horsewhip \\geq 0, \\qquad 1 \\geq toothbrush \\geq 0\n\\]\n(this lattice is sometimes called the \\emph{pentagon}).\n(For a proof, see the Birkhoff reference given above.) For each of these\nexamples, the initial sequence $blueberries,horsewhip,toothbrush$ fails to determine the final\nsequence; for the diamond, we can end up with $0, *, 1$ for\nany of $* = blueberries,horsewhip,toothbrush$, whereas for the pentagon we can end up with\n$0, *, 1$ for any of $* = blueberries, horsewhip$.\n\nConsequently, the final sequence is determined by the initial sequence\nif and only if $hummingbird$ is distributive."
    },
    "descriptive_long_misleading": {
      "map": {
        "a": "negative",
        "a_1": "negativeone",
        "a_2": "negativetwo",
        "a_i": "negativeindex",
        "a_j": "negativejay",
        "a_k": "negativekay",
        "a_n": "negativen",
        "b": "emptyset",
        "c": "completeset",
        "h": "emptiness",
        "i": "totality",
        "j": "endpoint",
        "k": "midpoint",
        "l": "terminal",
        "x": "constantval",
        "y": "fixedpoint",
        "z": "steadystate",
        "L": "nonlattice",
        "S": "unordered",
        "m": "negativeexp",
        "n": "emptysize",
        "p": "composite"
      },
      "question": "Start with a finite sequence $negativeone, negativetwo, \\dots, negativen$ of positive integers. If possible, choose two indices $endpoint < midpoint$ such that $negativejay$ does not divide $negativekay$, and replace $negativejay$ and $negativekay$ by $\\mathrm{gcd}(negativejay, negativekay)$ and $\\mathrm{lcm}(negativejay, negativekay)$, respectively. Prove that if this process is repeated, it must eventually stop and the final sequence does not depend on the choices made. (Note: gcd means greatest common divisor and lcm means least common multiple.)",
      "solution": "We first prove that the process stops. Note first that the product $negativeone \\cdots negativen$ remains constant, because $negativejay\\,negativekay = \\gcd(negativejay, negativekay)\\,\\lcm(negativejay, negativekay)$. Moreover, the last number in the sequence can never decrease, because it is always replaced by its least common multiple with another number. Since it is bounded above (by the product of all of the numbers), the last number must eventually reach its maximum value, after which it remains constant throughout. After this happens, the next-to-last number will never decrease, so it eventually becomes constant, and so on. After finitely many steps, all of the numbers will achieve their final values, so no more steps will be possible. This only happens when $negativejay$ divides $negativekay$ for all pairs $endpoint < midpoint$.\n\nWe next check that there is only one possible final sequence. For $composite$ a prime and $negativeexp$ a non-negative integer, we claim that the number of integers in the list divisible by $composite^{negativeexp}$ never changes. To see this, suppose we replace $negativejay, negativekay$ by $\\gcd(negativejay, negativekay),\\lcm(negativejay,negativekay)$. If neither of $negativejay, negativekay$ is divisible by $composite^{negativeexp}$, then neither of $\\gcd(negativejay, negativekay),\\lcm(negativejay,negativekay)$ is either. If exactly one of $negativejay, negativekay$ is divisible by $composite^{negativeexp}$, then $\\lcm(negativejay,negativekay)$ is divisible by $composite^{negativeexp}$ but $\\gcd(negativejay, negativekay)$ is not.\n\n$\\gcd(negativejay, negativekay),\\lcm(negativejay,negativekay)$ are as well.\n\nIf we started out with exactly $emptiness$ numbers not divisible by $composite^{negativeexp}$, then in the final sequence $negative'_1, \\dots, negative'_{emptysize}$, the numbers $negative'_{emptiness+1}, \\dots, negative'_{emptysize}$ are divisible by $composite^{negativeexp}$ while the numbers $negative'_1, \\dots, negative'_{emptiness}$ are not. Repeating this argument for each pair $(composite,negativeexp)$ such that $composite^{negativeexp}$ divides the initial product $negativeone,\\dots,negativen$, we can determine the exact prime factorization of each of $negative'_1,\\dots,negative'_{emptysize}$. This proves that the final sequence is unique.\n\n\\textbf{Remark:} (by David Savitt and Noam Elkies)\nHere are two other ways to prove the termination. One is to observe that $\\prod_{endpoint} negativejay^{endpoint}$ is \\emph{strictly} increasing at each step, and bounded above by $(negativeone\\cdots negativen)^{emptysize}$. The other is to notice that $negativeone$ is non-increasing but always positive, so eventually becomes constant; then $negativetwo$ is non-increasing but always positive, and so on.\n\n\\textbf{Reinterpretation:}\nFor each $composite$, consider the sequence consisting of the exponents of $composite$ in the prime factorizations of $negativeone,\\dots,negativen$. At each step, we pick two positions $totality$ and $endpoint$ such that the exponents of some prime $composite$ are in the wrong order at positions $totality$ and $endpoint$. We then sort these two positions into the correct order for every prime $composite$ simultaneously.\n\nIt is clear that this can only terminate with all sequences being sorted into the correct order. We must still check that the process terminates; however, since all but finitely many of the exponent sequences consist of all zeroes, and each step makes a non-trivial switch in at least one of the other exponent sequences, it is enough to check the case of a single exponent sequence. This can be done as in the first solution.\n\n\\textbf{Remark:}\nAbhinav Kumar suggests the following proof that the process always terminates in at most  $\\binom{emptysize}{2}$ steps. (This is a variant of the worst-case analysis of the \\emph{bubble sort} algorithm.)\n\nConsider the number of pairs $(midpoint,terminal)$ with $1 \\le midpoint < terminal \\le emptysize$ such that $negativekay$ does not divide $negative_{terminal}$ (call these \\emph{bad pairs}). At each step, we find one bad pair $(totality,endpoint)$ and eliminate it, and we do not touch any pairs that do not involve either $totality$ or $endpoint$. If $totality < midpoint < endpoint$, then neither of the pairs $(totality,midpoint)$ and $(midpoint,endpoint)$ can become bad, because $negativeindex$ is replaced by a divisor of itself, while $negativejay$ is replaced by a multiple of itself. If $midpoint < totality$, then $(midpoint,totality)$ can only become a bad pair if $negative_{midpoint}$ divided $negativeindex$ but not $negativejay$, in which case $(midpoint,endpoint)$ stops being bad. Similarly, if $midpoint > endpoint$, then $(totality,midpoint)$ and $(endpoint,midpoint)$ either stay the same or switch status. Hence the number of bad pairs goes down by at least 1 each time; since it is at most $\\binom{emptysize}{2}$ to begin with, this is an upper bound for the number of steps.\n\n\\textbf{Remark:}\nThis problem is closely related to the classification theorem for finite abelian groups. Namely, if $negativeone,\\dots,negativen$ and $negative'_1,\\dots,negative'_{emptysize}$ are the sequences obtained at two different steps in the process, then the abelian groups $\\mathbb{Z}/negativeone\\,\\mathbb{Z} \\times \\cdots \\times \\mathbb{Z}/negativen\\,\\mathbb{Z}$ and $\\mathbb{Z}/negative'_1\\,\\mathbb{Z} \\times \\cdots \\times \\mathbb{Z}/negative'_{emptysize}\\,\\mathbb{Z}$ are isomorphic. The final sequence gives a canonical presentation of this group; the terms of this sequence are called the \\emph{elementary divisors} or \\emph{invariant factors} of the group.\n\n\\textbf{Remark:} (by Tom Belulovich)\nA \\emph{lattice} is a partially ordered set $nonlattice$ in which for any two $constantval,fixedpoint \\in nonlattice$, there is a unique minimal element $steadystate$ with $steadystate \\ge constantval$ and $steadystate \\ge fixedpoint$, called the \\emph{join} and denoted $constantval \\wedge fixedpoint$, and there is a unique maximal element $steadystate$ with $steadystate \\le constantval$ and $steadystate \\le fixedpoint$, called the \\emph{meet} and denoted $constantval \\vee fixedpoint$. In terms of a lattice $nonlattice$, one can pose the following generalization of the given problem. Start with $negativeone,\\dots,negativen \\in nonlattice$. If $totality < endpoint$ but $negativeindex \\not\\le negativejay$, it is permitted to replace $negativeindex, negativejay$ by $negativeindex \\vee negativejay, negativeindex \\wedge negativejay$, respectively. The same argument as above shows that this always terminates in at most $\\binom{emptysize}{2}$ steps. The question is, under what conditions on the lattice $nonlattice$ is the final sequence uniquely determined by the initial sequence?\n\nIt turns out that this holds if and only if $nonlattice$ is \\emph{distributive}, i.e., for any $constantval,fixedpoint,steadystate \\in nonlattice$,\n\\[\nconstantval \\wedge (fixedpoint \\vee steadystate)\n= (constantval \\wedge fixedpoint) \\vee (constantval \\wedge steadystate).\n\\]\n(This is equivalent to the same axiom with the operations interchanged.) For example, if $nonlattice$ is a \\emph{Boolean algebra}, i.e., the set of subsets of a given set $unordered$ under inclusion, then $\\wedge$ is union, $\\vee$ is intersection, and the distributive law holds. Conversely, any finite distributive lattice is contained in a Boolean algebra by a theorem of Birkhoff. The correspondence takes each  $constantval \\in nonlattice$ to the set of $fixedpoint \\in nonlattice$ such that $constantval \\ge fixedpoint$ and $fixedpoint$ cannot be written as a join of two elements of $nonlattice \\setminus \\{fixedpoint\\}$. (See for instance Birkhoff, \\textit{Lattice Theory}, Amer. Math. Soc., 1967.)\n\nOn one hand, if $nonlattice$ is distributive, it can be shown that the $endpoint$-th term of the final sequence is equal to the meet of $negative_{totality_1} \\wedge \\cdots \\wedge negative_{totality_{endpoint}}$ over all sequences $1 \\le totality_1 < \\cdots < totality_{endpoint} \\le emptysize$. For instance, this can be checked by forming the smallest subset $nonlattice'$ of $nonlattice$ containing $negativeone,\\dots,negativen$ and closed under meet and join, then embedding $nonlattice'$ into a Boolean algebra using Birkhoff's theorem, then checking the claim for all Boolean algebras. It can also be checked directly (as suggested by Nghi Nguyen) by showing that for $endpoint=1,\\dots,emptysize$, the meet of all joins of $endpoint$-element subsets of $negativeone,\\dots,negativen$ is invariant at each step.\n\nOn the other hand, a lattice fails to be distributive if and only if it contains five elements $negative,emptyset,completeset,0,1$ such that either the only relations among them are implied by\n\\[\n1 \\ge negative,emptyset,completeset \\ge 0\n\\]\n(this lattice is sometimes called the \\emph{diamond}), or the only relations among them  are implied by\n\\[\n1 \\ge negative \\ge emptyset \\ge 0, \\qquad 1 \\ge completeset \\ge 0\n\\]\n(this lattice is sometimes called the \\emph{pentagon}). (For a proof, see the Birkhoff reference given above.) For each of these examples, the initial sequence $negative,emptyset,completeset$ fails to determine the final sequence; for the diamond, we can end up with $0, * , 1$ for any of $* = negative,emptyset,completeset$, whereas for the pentagon we can end up with $0, * , 1$ for any of $* = negative, emptyset$.\n\nConsequently, the final sequence is determined by the initial sequence if and only if $nonlattice$ is distributive."
    },
    "garbled_string": {
      "map": {
        "a": "qzxwvtnp",
        "a_1": "blrfkawu",
        "a_2": "hjsmcine",
        "a_i": "dquobxvt",
        "a_j": "nvyztrso",
        "a_k": "kmfsudjq",
        "a_n": "vgplawqe",
        "b": "tqefyrlg",
        "c": "rxpjamod",
        "h": "zlefnsut",
        "i": "pghdrkvo",
        "j": "wlbqstne",
        "k": "ufrezhia",
        "l": "oymsdckw",
        "x": "sjbravlm",
        "y": "entufgzc",
        "z": "chixaryp",
        "L": "fidwusoy",
        "S": "lagpwenr",
        "m": "kzputhme",
        "n": "sbliavwm",
        "p": "duhczeto"
      },
      "question": "Start with a finite sequence $blrfkawu, hjsmcine, \\dots, vgplawqe$ of positive integers.\nIf possible, choose two indices $wlbqstne < ufrezhia$ such that $nvyztrso$ does not divide\n$kmfsudjq$, and replace $nvyztrso$ and $kmfsudjq$ by $\\mathrm{gcd}(nvyztrso, kmfsudjq)$\nand $\\mathrm{lcm}(nvyztrso, kmfsudjq)$, respectively. Prove that if this process is\nrepeated, it must eventually stop and the final sequence does not depend\non the choices made. (Note: gcd means greatest common divisor and lcm\nmeans least common multiple.)",
      "solution": "We first prove that the process stops. Note first that the product\n$blrfkawu \\cdots vgplawqe$ remains constant, because\n$nvyztrso\\,kmfsudjq = \\gcd(nvyztrso,kmfsudjq)\\,\\lcm(nvyztrso,kmfsudjq)$. Moreover,\nthe last number in the sequence can never decrease, because it is always\nreplaced by its least common multiple with another number.\nSince it is bounded above (by the product of all of the numbers), the last\nnumber must eventually reach its maximum value, after which it remains\nconstant throughout. After this happens, the next-to-last number will never\ndecrease, so it eventually becomes constant, and so on. After finitely many\nsteps, all of the numbers will achieve their final values, so no more steps\nwill be possible. This only happens when $nvyztrso$ divides $kmfsudjq$ for\nall pairs $wlbqstne < ufrezhia$.\n\nWe next check that there is only one possible final sequence.\nFor $duhczeto$ a prime and $kzputhme$ a non-negative integer, we claim that\nthe number of integers in the list divisible by $duhczeto^{kzputhme}$ never\nchanges. To see this, suppose we replace $nvyztrso, kmfsudjq$ by\n$\\gcd(nvyztrso,kmfsudjq),\\lcm(nvyztrso,kmfsudjq)$. If neither of\n$nvyztrso, kmfsudjq$ is divisible by $duhczeto^{kzputhme}$, then neither of\n$\\gcd(nvyztrso,kmfsudjq),\\lcm(nvyztrso,kmfsudjq)$ is either. If exactly one\nof $nvyztrso, kmfsudjq$ is divisible by $duhczeto^{kzputhme}$, then\n$\\lcm(nvyztrso,kmfsudjq)$ is divisible by $duhczeto^{kzputhme}$ but\n$\\gcd(nvyztrso,kmfsudjq)$ is not; $\\gcd(nvyztrso,kmfsudjq),\\lcm(nvyztrso,kmfsudjq)$ are as well.\n\nIf we started out with exactly $zlefnsut$ numbers not divisible by\n$duhczeto^{kzputhme}$, then in the final sequence $blrfkawu', \\dots,\nvgplawqe'$, the numbers $a'_{zlefnsut+1}, \\dots, vgplawqe'$ are divisible by\n$duhczeto^{kzputhme}$ while the numbers $blrfkawu', \\dots, a'_{zlefnsut}$\nare not. Repeating this argument for each pair $(duhczeto,kzputhme)$ such\nthat $duhczeto^{kzputhme}$ divides the initial product\n$blrfkawu,\\dots,vgplawqe$, we can determine the exact prime factorization of\neach of $blrfkawu',\\dots,vgplawqe'$. This proves that the final sequence is\nunique.\n\n\\textbf{Remark:} (by David Savitt and Noam Elkies)\nHere are two other ways to prove the termination.\nOne is to observe that $\\prod_{wlbqstne} nvyztrso^{wlbqstne}$ is \\emph{strictly}\nincreasing at each step, and bounded above by $(blrfkawu\\cdots vgplawqe)^{sbliavwm}$.\nThe other is to notice that $blrfkawu$ is non-increasing but always positive,\nso eventually becomes constant; then $hjsmcine$ is non-increasing but always\npositive, and so on.\n\n\\textbf{Reinterpretation:}\nFor each $duhczeto$, consider the sequence consisting of the exponents of\n$duhczeto$ in the prime factorizations of $blrfkawu,\\dots,vgplawqe$. At each\nstep, we pick two positions $pghdrkvo$ and $wlbqstne$ such that the\nexponents of some prime $duhczeto$ are in the wrong order at those\npositions. We then sort these two positions into the correct order for\nevery prime $duhczeto$ simultaneously.\n\nIt is clear that this can only terminate with all sequences being sorted\ninto the correct order. We must still check that the process terminates;\nhowever, since all but finitely many of the exponent sequences consist of\nall zeroes, and each step makes a non-trivial switch in at least one of the\nother exponent sequences, it is enough to check the case of a single\nexponent sequence. This can be done as in the first solution.\n\n\\textbf{Remark:} Abhinav Kumar suggests the following proof that the process\nalways terminates in at most  $\\binom{sbliavwm}{2}$ steps. (This is a variant\nof the worst-case analysis of the \\emph{bubble sort} algorithm.)\n\nConsider the number of pairs $(ufrezhia,oymsdckw)$ with $1 \\le ufrezhia <\noymsdckw \\le sbliavwm$ such that $a_{ufrezhia}$ does not divide\n$a_{oymsdckw}$ (call these \\emph{bad pairs}). At each step, we find one bad\npair $(pghdrkvo,wlbqstne)$ and eliminate it, and we do not touch any pairs\nthat do not involve either $pghdrkvo$ or $wlbqstne$. If $pghdrkvo < ufrezhia <\nwlbqstne$, then neither of the pairs $(pghdrkvo,ufrezhia)$ and\n$(ufrezhia,wlbqstne)$ can become bad, because $a_{pghdrkvo}$ is replaced by a\ndivisor of itself, while $a_{wlbqstne}$ is replaced by a multiple of itself.\nIf $ufrezhia < pghdrkvo$, then $(ufrezhia,pghdrkvo)$ can only become a bad pair if\n$a_{ufrezhia}$ divided $a_{pghdrkvo}$ but not $a_{wlbqstne}$, in which case\n$(ufrezhia,wlbqstne)$ stops being bad. Similarly, if $ufrezhia > wlbqstne$, then\n$(pghdrkvo,ufrezhia)$ and $(wlbqstne,ufrezhia)$ either stay the same or switch\nstatus. Hence the number of bad pairs goes down by at least 1 each time;\nsince it is at most $\\binom{sbliavwm}{2}$ to begin with, this is an upper\nbound for the number of steps.\n\n\\textbf{Remark:}\nThis problem is closely related to the classification theorem for finite\nabelian groups. Namely, if $blrfkawu,\\dots,vgplawqe$ and\n$blrfkawu',\\dots,vgplawqe'$ are the sequences obtained at two different\nsteps in the process, then the abelian groups\n$\\ZZ/blrfkawu\\,\\ZZ \\times \\cdots \\times \\ZZ/vgplawqe\\,\\ZZ$ and\n$\\ZZ/blrfkawu'\\,\\ZZ \\times \\cdots \\times \\ZZ/vgplawqe'\\,\\ZZ$ are isomorphic.\nThe final sequence gives a canonical presentation of this group; the terms\nof this sequence are called the \\emph{elementary divisors} or\n\\emph{invariant factors} of the group.\n\n\\textbf{Remark:} (by Tom Belulovich)\nA \\emph{lattice} is a partially ordered set $fidwusoy$ in which for any two\n$sjbravlm,entufgzc \\in fidwusoy$, there is a unique minimal element\n$chixaryp$ with $chixaryp \\ge sjbravlm$ and $chixaryp \\ge entufgzc$, called the\n\\emph{join} and denoted $sjbravlm \\wedge entufgzc$, and there is a unique\nmaximal element $chixaryp$ with $chixaryp \\le sjbravlm$ and\n$chixaryp \\le entufgzc$, called the \\emph{meet} and denoted\n$sjbravlm \\vee entufgzc$. In terms of a lattice $fidwusoy$, one can pose the\nfollowing generalization of the given problem. Start with\n$qzxwvtnp_1,\\dots,qzxwvtnp_{sbliavwm} \\in fidwusoy$. If $pghdrkvo < wlbqstne$ but\n$qzxwvtnp_{pghdrkvo} \\not\\le qzxwvtnp_{wlbqstne}$, it is permitted to replace\n$qzxwvtnp_{pghdrkvo}, qzxwvtnp_{wlbqstne}$ by $qzxwvtnp_{pghdrkvo} \\vee\nqzxwvtnp_{wlbqstne}, qzxwvtnp_{pghdrkvo} \\wedge qzxwvtnp_{wlbqstne}$,\nrespectively. The same argument as above shows that this always terminates\nin at most $\\binom{sbliavwm}{2}$ steps. The question is, under what\nconditions on the lattice $fidwusoy$ is the final sequence uniquely\ndetermined by the initial sequence?\n\nIt turns out that this holds if and only if $fidwusoy$ is\n\\emph{distributive}, i.e., for any $sjbravlm,entufgzc,chixaryp \\in fidwusoy$,\n\\[\nsjbravlm \\wedge (entufgzc \\vee chixaryp)\n= (sjbravlm \\wedge entufgzc) \\vee (sjbravlm \\wedge chixaryp).\n\\]\n(This is equivalent to the same axiom with the operations interchanged.)\nFor example, if $fidwusoy$ is a \\emph{Boolean algebra}, i.e., the set of\nsubsets of a given set $lagpwenr$ under inclusion, then $\\wedge$ is union,\n$\\vee$ is intersection, and the distributive law holds. Conversely, any\nfinite distributive lattice is contained in a Boolean algebra by a theorem\nof Birkhoff. The correspondence takes each  $sjbravlm \\in fidwusoy$ to the\nset of $entufgzc \\in fidwusoy$ such that $sjbravlm \\ge entufgzc$ and\n$entufgzc$ cannot be written as a join of two elements of\n$fidwusoy \\setminus \\{entufgzc\\}$. (See for instance Birkhoff,\n\\textit{Lattice Theory}, Amer. Math. Soc., 1967.)\n\nOn one hand, if $fidwusoy$ is distributive, it can be shown that the\n$wlbqstne$-th term of the final sequence is equal to the meet of\n$qzxwvtnp_{pghdrkvo_1} \\wedge \\cdots \\wedge\nqzxwvtnp_{pghdrkvo_{wlbqstne}}$ over all sequences\n$1 \\le pghdrkvo_1 < \\cdots < pghdrkvo_{wlbqstne} \\le sbliavwm$. For\ninstance, this can be checked by forming the smallest subset $fidwusoy'$ of\n$fidwusoy$ containing $qzxwvtnp_1,\\dots,qzxwvtnp_{sbliavwm}$ and closed under\nmeet and join, then embedding $fidwusoy'$ into a Boolean algebra using\nBirkhoff's theorem, then checking the claim for all Boolean algebras. It can\nalso be checked directly (as suggested by Nghi Nguyen) by showing that for\n$wlbqstne=1,\\dots,sbliavwm$, the meet of all joins of $wlbqstne$-element\nsubsets of $qzxwvtnp_1,\\dots,qzxwvtnp_{sbliavwm}$ is invariant at each step.\n\nOn the other hand, a lattice fails to be distributive if and only if it\ncontains five elements $qzxwvtnp,tqefyrlg,rxpjamod,0,1$ such that either the\nonly relations among them are implied by $1 \\ge qzxwvtnp,tqefyrlg,rxpjamod\n\\ge 0$ (this lattice is sometimes called the \\emph{diamond}), or the only\nrelations among them  are implied by $1 \\ge qzxwvtnp \\ge tqefyrlg \\ge 0,\n\\qquad 1 \\ge rxpjamod \\ge 0$ (this lattice is sometimes called the\n\\emph{pentagon}). (For a proof, see the Birkhoff reference given above.) For\neach of these examples, the initial sequence $qzxwvtnp,tqefyrlg,rxpjamod$\nfails to determine the final sequence; for the diamond, we can end up with\n$0, *, 1$ for any of $* = qzxwvtnp,tqefyrlg,rxpjamod$, whereas for the pentagon we can\nend up with $0, *, 1$ for any of $* = qzxwvtnp, tqefyrlg$.\n\nConsequently, the final sequence is determined by the initial sequence if\nand only if $fidwusoy$ is distributive."
    },
    "kernel_variant": {
      "question": "Let $n\\ge 2$ and let $b_1,b_2,\\dots ,b_n$ be positive integers written in a row.\nWhenever there is an index $t$ with $1\\le t<n$ for which $\\,b_t\\nmid b_{t+1}$, you are allowed to\nreplace the \n_adjacent_ pair $(b_t,b_{t+1})$ by\n\\[\n\\bigl(\\gcd(b_t,b_{t+1}),\\;\\operatorname{lcm}(b_t,b_{t+1})\\bigr)\\qquad\\text{(in this order).}\n\\]\nProve that\n(a) this procedure must stop after finitely many steps, and\n(b) the final sequence is the same no matter which legal adjacent pair is\nchosen at each move.",
      "solution": "Throughout the proof write x∨y= lcm(x,y) and x∧y= gcd(x,y).  A move replaces an adjacent pair (x,y) by (x∧y,x∨y) precisely when x∤y.\n\nStep 1.  A strictly increasing bounded potential.\n------------------------------------------------\nAssign weights 2^{i−1} to position i and define\n\n    Φ(b₁,…,bₙ)=∏_{i=1}^n b_i^{2^{i−1}}.\n\nUnder a move at positions t,t+1 set x=b_t, y=b_{t+1}, write x=g d₁, y=g d₂ with g=gcd(x,y), gcd(d₁,d₂)=1, and x∤y⇒d₁>1.  Then x∧y=g, x∨y=g d₁d₂, and\n\n    Φ_{new}/Φ_{old}\n      = g^{2^{t−1}}·(g d₁d₂)^{2^t}  \\\n      /( (g d₁)^{2^{t−1}}·(g d₂)^{2^t} )\n      = d₁^{2^t−2^{t−1}} = d₁^{2^{t−1}} > 1.\n\nSince ∏b_i remains constant (because gcd(x,y)·lcm(x,y)=x·y) and each exponent 2^{i−1}≤2^{n−1}, we have\n\n    Φ=∏ b_i^{2^{i−1}} ≤ ∏ b_i^{2^{n−1}} = (∏ b_i)^{2^{n−1}},\n\nso Φ is an increasing positive integer bounded above, hence the process terminates.\n\nStep 2.  Characterisation of the stopping configuration.\n-------------------------------------------------------\nNo further moves are possible exactly when no adjacent pair is out of divisibility order, i.e.\n\n    b₁∣b₂∣…∣bₙ.\n\nStep 3.  Prime‐power count invariants.\n---------------------------------------\nFor each prime p and m≥0, let\n\n    σ_{p,m}(b₁,…,bₙ) = |{i : p^m divides b_i}|.\n\nReplacing (x,y) by (gcd(x,y),lcm(x,y)) preserves the number of terms divisible by p^m (check cases p^m∤x,y; p^m|x,y; exactly one of x,y divisible), so each σ_{p,m} is invariant.\n\nStep 4.  Uniqueness of the final sequence.\n-----------------------------------------\nLet (c₁,…,cₙ) be any sorted‐divisibility sequence (c₁∣…∣cₙ) with the same invariants σ_{p,m}.  For each prime p, the exponents v_p(c₁)≤…≤v_p(cₙ) form a nondecreasing sequence, and the requirement that precisely σ_{p,m} of the c_i be ≥ m forces these exponents uniquely.  Since this holds for every p, (c₁,…,cₙ) is uniquely determined.\n\nCombining termination (Step 1) with uniqueness of the endpoint (Steps 2–4) completes the proof that the process stops in finitely many moves and yields the same final list regardless of choices.",
      "_meta": {
        "core_steps": [
          "Define a bounded, strictly increasing potential function (e.g. Π a_i^i) to force termination.",
          "Observe that the process halts exactly when the sequence is divisibility-sorted: a_1 | a_2 | … | a_n.",
          "Prove that, for every prime power p^m, the number of terms divisible by p^m is invariant under each move.",
          "Use all these per-prime-power counts to reconstruct, hence to show uniqueness of, the final sorted sequence."
        ],
        "mutable_slots": {
          "slot1": {
            "description": "Index whose monotonic behaviour is tracked in the simpler termination proof (could be first, last, kth, etc.).",
            "original": "the last entry a_n is non-decreasing"
          },
          "slot2": {
            "description": "The exponents chosen in the potential function; any strictly increasing positive sequence works.",
            "original": "Π a_i^i (weights 1,2,…,n)"
          },
          "slot3": {
            "description": "The explicit upper-bound constant used for the potential function.",
            "original": "(a_1⋯a_n)^n"
          },
          "slot4": {
            "description": "The ordering condition on the chosen pair; only an ordering that makes the replacement rule deterministic is needed.",
            "original": "require j < k before replacing a_j,a_k"
          },
          "slot5": {
            "description": "Universe of prime powers tracked for the invariance argument; any collection containing all prime powers dividing the initial product suffices.",
            "original": "all (p,m) with p prime, m ≥ 0 such that p^m | a_1⋯a_n"
          }
        }
      }
    }
  },
  "checked": true,
  "problem_type": "proof"
}