{
  "index": "2013-B-5",
  "type": "COMB",
  "tag": [
    "COMB",
    "NT",
    "ALG"
  ],
  "difficulty": "",
  "question": "Let $X = \\{1, 2, \\dots, n\\}$, and let $k \\in X$. Show that there are exactly $k \\cdot n^{n-1}$ functions $f: X \\to X$ such that for every $x \\in X$ there is a $j \\geq 0$ such that $f^{(j)}(x) \\leq k$.\n[Here $f^{(j)}$ denotes the $j$\\textsuperscript{th} iterate of $f$, so that $f^{(0)}(x) = x$ and $f^{(j+1)}(x) = f(f^{(j)}(x))$.]",
  "solution": "\\setcounter{lemma}{0}\n\\textbf{First solution:}\nWe assume $n \\geq 1$ unless otherwise specified.\nFor $T$ a set and $S_1, S_2$ two subsets of $T$, we say that a function $f: T \\to T$ \\emph{iterates $S_1$ into $S_2$} if for each $x \\in S_1$, there is a $j \\geq 0$ such that $f^{(j)}(x) \\in S_2$.\n\n\\begin{lemma}\nFix $k \\in X$. Let $f,g: X \\to X$ be two functions such that $f$ iterates $X$ into $\\{1,\\dots,k\\}$ and $f(x) = g(x)$ for $x \\in \\{k+1,\\dots,n\\}$. Then $g$ also iterates $X$ into $\\{1,\\dots,k\\}$.\n\\end{lemma}\n\\begin{proof}\nFor $x \\in X$, by hypothesis there exists a nonnegative integer $j$ such that $f^{(j)}(x) \\in \\{1,\\dots,k\\}$. Choose the integer $j$ as small as possible; then $f^{(i)}(x) \\in \\{k+1,\\dots,n\\}$ for $0 \\leq i<j$. By induction on $i$, we have $f^{(i)}(x) = g^{(i)}(x)$ for $i=0,\\dots,j$, so in particular $g^{(j)}(x) \\in \\{1,\\dots,k\\}$. This proves the claim.\n\\end{proof}\n\nWe proceed by induction on $n-k$, the case $n-k=0$ being trivial.\nFor the induction step, we need only confirm that the number $x$ of functions $f: X \\to X$ which iterate $X$ into $\\{1,\\dots,k+1\\}$ but not into $\\{1,\\dots,k\\}$ is equal to $n^{n-1}$. These are precisely the functions for which there is a unique cycle $C$ containing only numbers in $\\{k+1,\\dots,n\\}$ and said cycle contains $k+1$. Suppose $C$ has length $\\ell \\in \\{1,\\dots,n-k\\}$. For a fixed choice of $\\ell$, we may choose the underlying set of $C$ in\n$\\binom{n-k-1}{\\ell-1}$ ways and the cycle structure in $(\\ell-1)!$ ways. Given $C$, the functions $f$ we want are the ones that act on $C$ as specified and iterate $X$ into\n$\\{1,\\dots,k\\} \\cup C$.\nBy Lemma~1, the number of such functions is\n$n^{-\\ell}$ times the total number of functions that iterate $X$ into\n$\\{1,\\dots,k\\} \\cup C$.\nBy the induction hypothesis,\nwe compute the number of functions  which iterate $X$ into $\\{1,\\dots,k+1\\}$ but not into $\\{1,\\dots,k\\}$ to be\n\\[\n\\sum_{\\ell=1}^{n-k} (n-k-1)\\cdots(n-k-\\ell+1)\n(k+\\ell) n^{n-\\ell-1}\n\\]\nBy rewriting this as a telescoping sum, we get\n\\begin{align*}\n&\\sum_{\\ell=1}^{n-k} (n-k-1)\\cdots(n-k-\\ell+1)\n(n) n^{n-\\ell-1} \\\\\n&- \\sum_{\\ell=1}^{n-k} (n-k-1)\\cdots(n-k-\\ell+1)\n(n-k-\\ell) n^{n-\\ell-1} \\\\\n&=\\sum_{\\ell=0}^{n-k-1} (n-k-1)\\cdots(n-k-\\ell) n^{n-\\ell-1} \\\\\n&- \\sum_{\\ell=1}^{n-k} (n-k-1)\\cdots\n(n-k-\\ell) n^{n-\\ell-1} \\\\\n&= n^{n-1}.\n\\end{align*}\nas desired.\n\n\\textbf{Second solution:}\nFor $T$ a set, $f: T \\to T$ a function, and $S$ a subset of $T$,\nwe define the \\emph{contraction} of $f$ at $S$ as the function $g: \\{* \\} \\cup (T-S) \\to \\{*\\}  \\cup (T-S)$\ngiven by\n\\[\ng(x) = \\begin{cases} * & x = *  \\\\\n* & x \\neq *, f(x) \\in S \\\\\nf(x) & x \\neq *, f(x) \\notin S.\n\\end{cases}\n\\]\n\\begin{lemma}\nFor $S \\subseteq X$ of cardinality $\\ell \\geq 0$,\nthere are $\\ell n^{n-\\ell-1}$ functions $f: \\{*\\} \\cup X \\to \\{*\\} \\cup X$ with $f^{-1}(*) = \\{*\\} \\cup S$\nwhich iterate $X$ into $\\{*\\}$.\n\\end{lemma}\n\\begin{proof}\nWe induct on $n$. If $\\ell = n$ then there is nothing to check.\nOtherwise, put $T = f^{-1}(S)$, which must be nonempty.\nThe contraction $g$ of $f$ at $\\{*\\} \\cup S$ is then a function on $\\{*\\} \\cup (X-S)$ with $f^{-1}(*) = \\{*\\} \\cup T$ which iterates $X-S$ into $\\{*\\}$. Moreover, for given $T$, each such $g$ arises from\n$\\ell^{\\# T}$ functions of the desired form.\nSumming over $T$ and invoking the induction hypothesis, we see that the number of functions $f$ is \n\\begin{align*}\n&\\sum_{k=1}^{n-\\ell} \\binom{n-\\ell}{k} \\ell^k \\cdot k (n-\\ell)^{n-\\ell-k-1} \\\\\n&=\\sum_{k=1}^{n-\\ell} \\binom{n-\\ell-1}{k-1} \\ell^k (n-\\ell)^{n-\\ell-k} \n= \\ell n^{n-\\ell-1}\n\\end{align*}\nas claimed.\n\\end{proof}\n\nWe now count functions $f: X \\to X$ which iterate $X$ into $\\{1,\\dots,k\\}$ as follows. By Lemma~1 of the first solution, this count equals $n^k$ times the number of functions with $f(1) = \\cdots = f(k) = 1$  which iterate $X$ into $\\{1,\\dots,k\\}$. For such a function $f$, put $S = \\{k+1,\\dots,n\\} \\cap f^{-1}(\\{1,\\dots,k\\})$ and let $g$ be the contraction of $f$\nat $\\{1,\\dots,k\\}$; then $g^{-1}(*) = * \\cup \\{S\\}$ and $g$ iterates \nits domain into $*$. By Lemma~2, for $\\ell = \\#S$, there are\n$\\ell (n-k)^{n-k-\\ell-1}$ such functions $g$.\nFor given $S$, each such $g$ gives rise to $k^{\\ell}$ functions $f$ with $f(1) = \\cdots = f(k) = 1$  which iterate $X$ into $\\{1,\\dots,k\\}$.\nThus the number of such functions $f$ is\n\\begin{align*}\n&\\sum_{\\ell=0}^{n-k} \\binom{n-k}{\\ell} k^{\\ell} \\ell (n-k)^{n-k-\\ell-1} \\\\\n&= \\sum_{\\ell=0}^{n-k} \\binom{n-k-1}{\\ell-1} k^{\\ell} (n-k)^{n-k-\\ell}\\\\\n&= k n^{n-k-1}.\n\\end{align*}\nThe desired count is this times $n^k$, or $k n^{n-1}$ as desired.\n\n\\textbf{Remark:}\nFunctions of the sort counted in Lemma~2 can be identified with rooted trees on the vertex set $\\{*\\} \\cup X$ with root $*$. Such trees can be counted using \\emph{Cayley's formula}, a special case of \\emph{Kirchoff's matrix tree theorem}. The matrix tree theorem can also be used to show directly that the number of rooted forests on $n$ vertices with $k$ fixed roots is $k n^{n-k-1}$; the desired count follows immediately from this formula plus Lemma~1. (One can also use Pr\\\"ufer sequences for a more combinatorial interpretation.)",
  "vars": [
    "X",
    "x",
    "j",
    "f",
    "T",
    "S",
    "S_1",
    "S_2",
    "g",
    "C",
    "i",
    "\\\\ell"
  ],
  "params": [
    "n",
    "k"
  ],
  "sci_consts": [],
  "variants": {
    "descriptive_long": {
      "map": {
        "X": "fullset",
        "x": "element",
        "j": "stepindex",
        "f": "mapfunction",
        "T": "domainset",
        "S": "subset",
        "S_1": "subsetone",
        "S_2": "subsettwo",
        "g": "contractmap",
        "C": "cyclelist",
        "i": "indexvar",
        "\\ell": "lengthvar",
        "n": "totalnum",
        "k": "boundnum"
      },
      "question": "Let $fullset = \\{1, 2, \\dots, totalnum\\}$, and let $boundnum \\in fullset$. Show that there are exactly $boundnum \\cdot totalnum^{totalnum-1}$ functions $mapfunction: fullset \\to fullset$ such that for every $element \\in fullset$ there is a $stepindex \\geq 0$ such that $mapfunction^{(stepindex)}(element) \\leq boundnum$.\n[Here $mapfunction^{(stepindex)}$ denotes the $stepindex$\\textsuperscript{th} iterate of $mapfunction$, so that $mapfunction^{(0)}(element) = element$ and $mapfunction^{(stepindex+1)}(element) = mapfunction(mapfunction^{(stepindex)}(element))$.]",
      "solution": "\\setcounter{lemma}{0}\n\\textbf{First solution:}\nWe assume $totalnum \\geq 1$ unless otherwise specified.\nFor $domainset$ a set and $subsetone, subsettwo$ two subsets of $domainset$, we say that a function $mapfunction: domainset \\to domainset$ \\emph{iterates $subsetone$ into $subsettwo$} if for each $element \\in subsetone$, there is a $stepindex \\geq 0$ such that $mapfunction^{(stepindex)}(element) \\in subsettwo$.\n\n\\begin{lemma}\nFix $boundnum \\in fullset$. Let $mapfunction,contractmap: fullset \\to fullset$ be two functions such that $mapfunction$ iterates $fullset$ into $\\{1,\\dots,boundnum\\}$ and $mapfunction(element) = contractmap(element)$ for $element \\in \\{boundnum+1,\\dots,totalnum\\}$. Then $contractmap$ also iterates $fullset$ into $\\{1,\\dots,boundnum\\}$.\n\\end{lemma}\n\\begin{proof}\nFor $element \\in fullset$, by hypothesis there exists a nonnegative integer $stepindex$ such that $mapfunction^{(stepindex)}(element) \\in \\{1,\\dots,boundnum\\}$. Choose the integer $stepindex$ as small as possible; then $mapfunction^{(indexvar)}(element) \\in \\{boundnum+1,\\dots,totalnum\\}$ for $0 \\leq indexvar<stepindex$. By induction on $indexvar$, we have $mapfunction^{(indexvar)}(element) = contractmap^{(indexvar)}(element)$ for $indexvar=0,\\dots,stepindex$, so in particular $contractmap^{(stepindex)}(element) \\in \\{1,\\dots,boundnum\\}$. This proves the claim.\n\\end{proof}\n\nWe proceed by induction on $totalnum-boundnum$, the case $totalnum-boundnum=0$ being trivial.\nFor the induction step, we need only confirm that the number $element$ of functions $mapfunction: fullset \\to fullset$ which iterate $fullset$ into $\\{1,\\dots,boundnum+1\\}$ but not into $\\{1,\\dots,boundnum\\}$ is equal to $totalnum^{totalnum-1}$. These are precisely the functions for which there is a unique cycle $cyclelist$ containing only numbers in $\\{boundnum+1,\\dots,totalnum\\}$ and said cycle contains $boundnum+1$.\nSuppose $cyclelist$ has length $lengthvar \\in \\{1,\\dots,totalnum-boundnum\\}$. For a fixed choice of $lengthvar$, we may choose the underlying set of $cyclelist$ in\n$\\binom{totalnum-boundnum-1}{lengthvar-1}$ ways and the cycle structure in $(lengthvar-1)!$ ways. Given $cyclelist$, the functions $mapfunction$ we want are the ones that act on $cyclelist$ as specified and iterate $fullset$ into\n$\\{1,\\dots,boundnum\\} \\cup cyclelist$.\nBy Lemma~1, the number of such functions is\n$totalnum^{-lengthvar}$ times the total number of functions that iterate $fullset$ into\n$\\{1,\\dots,boundnum\\} \\cup cyclelist$.\nBy the induction hypothesis,\nwe compute the number of functions which iterate $fullset$ into $\\{1,\\dots,boundnum+1\\}$ but not into $\\{1,\\dots,boundnum\\}$ to be\n\\[\n\\sum_{lengthvar=1}^{totalnum-boundnum} (totalnum-boundnum-1)\\cdots(totalnum-boundnum-lengthvar+1)\n(boundnum+lengthvar) totalnum^{totalnum-lengthvar-1}\n\\]\nBy rewriting this as a telescoping sum, we get\n\\begin{align*}\n&\\sum_{lengthvar=1}^{totalnum-boundnum} (totalnum-boundnum-1)\\cdots(totalnum-boundnum-lengthvar+1)\n(totalnum) totalnum^{totalnum-lengthvar-1} \\\\\n&- \\sum_{lengthvar=1}^{totalnum-boundnum} (totalnum-boundnum-1)\\cdots(totalnum-boundnum-lengthvar+1)\n(totalnum-boundnum-lengthvar) totalnum^{totalnum-lengthvar-1} \\\\\n&=\\sum_{lengthvar=0}^{totalnum-boundnum-1} (totalnum-boundnum-1)\\cdots(totalnum-boundnum-lengthvar) totalnum^{totalnum-lengthvar-1} \\\\\n&- \\sum_{lengthvar=1}^{totalnum-boundnum} (totalnum-boundnum-1)\\cdots\n(totalnum-boundnum-lengthvar) totalnum^{totalnum-lengthvar-1} \\\\\n&= totalnum^{totalnum-1}.\n\\end{align*}\nas desired.\n\n\\textbf{Second solution:}\nFor $domainset$ a set, $mapfunction: domainset \\to domainset$ a function, and $subset$ a subset of $domainset$,\nwe define the \\emph{contraction} of $mapfunction$ at $subset$ as the function $contractmap: \\{* \\} \\cup (domainset-subset) \\to \\{*\\}  \\cup (domainset-subset)$\ngiven by\n\\[\ncontractmap(element) = \\begin{cases} * & element = *  \\\\\n* & element \\neq *, mapfunction(element) \\in subset \\\\\nmapfunction(element) & element \\neq *, mapfunction(element) \\notin subset.\n\\end{cases}\n\\]\n\\begin{lemma}\nFor $subset \\subseteq fullset$ of cardinality $lengthvar \\geq 0$,\nthere are $lengthvar\\, totalnum^{totalnum-lengthvar-1}$ functions $mapfunction: \\{*\\} \\cup fullset \\to \\{*\\} \\cup fullset$ with $mapfunction^{-1}(*) = \\{*\\} \\cup subset$\nwhich iterate $fullset$ into $\\{*\\}$.\n\\end{lemma}\n\\begin{proof}\nWe induct on $totalnum$. If $lengthvar = totalnum$ then there is nothing to check.\nOtherwise, put $domainset = mapfunction^{-1}(subset)$, which must be nonempty.\nThe contraction $contractmap$ of $mapfunction$ at $\\{*\\} \\cup subset$ is then a function on $\\{*\\} \\cup (fullset-subset)$ with $mapfunction^{-1}(*) = \\{*\\} \\cup domainset$ which iterates $fullset-subset$ into $\\{*\\}$. Moreover, for given $domainset$, each such $contractmap$ arises from\n$lengthvar^{\\# domainset}$ functions of the desired form.\nSumming over $domainset$ and invoking the induction hypothesis, we see that the number of functions $mapfunction$ is \n\\begin{align*}\n&\\sum_{boundnum=1}^{totalnum-lengthvar} \\binom{totalnum-lengthvar}{boundnum} lengthvar^{boundnum} \\cdot boundnum (totalnum-lengthvar)^{totalnum-lengthvar-boundnum-1} \\\\\n&=\\sum_{boundnum=1}^{totalnum-lengthvar} \\binom{totalnum-lengthvar-1}{boundnum-1} lengthvar^{boundnum} (totalnum-lengthvar)^{totalnum-lengthvar-boundnum} \n= lengthvar\\, totalnum^{totalnum-lengthvar-1}\n\\end{align*}\nas claimed.\n\\end{proof}\n\nWe now count functions $mapfunction: fullset \\to fullset$ which iterate $fullset$ into $\\{1,\\dots,boundnum\\}$ as follows. By Lemma~1 of the first solution, this count equals $totalnum^{boundnum}$ times the number of functions with $mapfunction(1) = \\cdots = mapfunction(boundnum) = 1$  which iterate $fullset$ into $\\{1,\\dots,boundnum\\}$. For such a function $mapfunction$, put $subset = \\{boundnum+1,\\dots,totalnum\\} \\cap mapfunction^{-1}(\\{1,\\dots,boundnum\\})$ and let $contractmap$ be the contraction of $mapfunction$\nat $\\{1,\\dots,boundnum\\}$; then $contractmap^{-1}(*) = * \\cup \\{subset\\}$ and $contractmap$ iterates \nits domain into $*$. By Lemma~2, for $lengthvar = \\# subset$, there are\n$lengthvar (totalnum-boundnum)^{totalnum-boundnum-lengthvar-1}$ such functions $contractmap$.\nFor given $subset$, each such $contractmap$ gives rise to $boundnum^{lengthvar}$ functions $mapfunction$ with $mapfunction(1) = \\cdots = mapfunction(boundnum) = 1$  which iterate $fullset$ into $\\{1,\\dots,boundnum\\}$.\nThus the number of such functions $mapfunction$ is\n\\begin{align*}\n&\\sum_{lengthvar=0}^{totalnum-boundnum} \\binom{totalnum-boundnum}{lengthvar} boundnum^{lengthvar} lengthvar (totalnum-boundnum)^{totalnum-boundnum-lengthvar-1} \\\\\n&= \\sum_{lengthvar=0}^{totalnum-boundnum} \\binom{totalnum-boundnum-1}{lengthvar-1} boundnum^{lengthvar} (totalnum-boundnum)^{totalnum-boundnum-lengthvar}\\\\\n&= boundnum\\, totalnum^{totalnum-boundnum-1}.\n\\end{align*}\nThe desired count is this times $totalnum^{boundnum}$, or $boundnum\\, totalnum^{totalnum-1}$ as desired.\n\n\\textbf{Remark:}\nFunctions of the sort counted in Lemma~2 can be identified with rooted trees on the vertex set $\\{*\\} \\cup fullset$ with root $*$. Such trees can be counted using \\emph{Cayley's formula}, a special case of \\emph{Kirchoff's matrix tree theorem}. The matrix tree theorem can also be used to show directly that the number of rooted forests on $totalnum$ vertices with $boundnum$ fixed roots is $boundnum\\, totalnum^{totalnum-boundnum-1}$; the desired count follows immediately from this formula plus Lemma~1. (One can also use Pr\"ufer sequences for a more combinatorial interpretation.)"
    },
    "descriptive_long_confusing": {
      "map": {
        "X": "sandcastle",
        "x": "lighthouse",
        "j": "paintbrush",
        "f": "pinecone",
        "T": "seashells",
        "S": "driftwood",
        "S_1": "driftwoodone",
        "S_2": "driftwoodtwo",
        "g": "arrowroot",
        "C": "moonstone",
        "i": "jellyfish",
        "\\\\ell": "starfruit",
        "n": "bookshelf",
        "k": "newspaper"
      },
      "question": "Let $sandcastle = \\{1, 2, \\dots, bookshelf\\}$, and let $newspaper \\in sandcastle$. Show that there are exactly $newspaper \\cdot bookshelf^{bookshelf-1}$ functions $pinecone: sandcastle \\to sandcastle$ such that for every $lighthouse \\in sandcastle$ there is a $paintbrush \\geq 0$ such that $pinecone^{(paintbrush)}(lighthouse) \\leq newspaper$.\n[Here $pinecone^{(paintbrush)}$ denotes the $paintbrush$\\textsuperscript{th} iterate of $pinecone$, so that $pinecone^{(0)}(lighthouse) = lighthouse$ and $pinecone^{(paintbrush+1)}(lighthouse) = pinecone(pinecone^{(paintbrush)}(lighthouse))$.]",
      "solution": "\\setcounter{lemma}{0}\n\\textbf{First solution:}\nWe assume $bookshelf \\geq 1$ unless otherwise specified.\nFor $seashells$ a set and $driftwoodone, driftwoodtwo$ two subsets of $seashells$, we say that a function $pinecone: seashells \\to seashells$ \\emph{iterates $driftwoodone$ into $driftwoodtwo$} if for each $lighthouse \\in driftwoodone$, there is a $paintbrush \\geq 0$ such that $pinecone^{(paintbrush)}(lighthouse) \\in driftwoodtwo$.\n\n\\begin{lemma}\nFix $newspaper \\in sandcastle$. Let $pinecone,arrowroot: sandcastle \\to sandcastle$ be two functions such that $pinecone$ iterates $sandcastle$ into $\\{1,\\dots,newspaper\\}$ and $pinecone(lighthouse) = arrowroot(lighthouse)$ for $lighthouse \\in \\{newspaper+1,\\dots,bookshelf\\}$. Then $arrowroot$ also iterates $sandcastle$ into $\\{1,\\dots,newspaper\\}$.\n\\end{lemma}\n\\begin{proof}\nFor $lighthouse \\in sandcastle$, by hypothesis there exists a nonnegative integer $paintbrush$ such that $pinecone^{(paintbrush)}(lighthouse) \\in \\{1,\\dots,newspaper\\}$. Choose the integer $paintbrush$ as small as possible; then $pinecone^{(jellyfish)}(lighthouse) \\in \\{newspaper+1,\\dots,bookshelf\\}$ for $0 \\leq jellyfish<paintbrush$. By induction on $jellyfish$, we have $pinecone^{(jellyfish)}(lighthouse) = arrowroot^{(jellyfish)}(lighthouse)$ for $jellyfish=0,\\dots,paintbrush$, so in particular $arrowroot^{(paintbrush)}(lighthouse) \\in \\{1,\\dots,newspaper\\}$. This proves the claim.\n\\end{proof}\n\nWe proceed by induction on $bookshelf-newspaper$, the case $bookshelf-newspaper=0$ being trivial.\nFor the induction step, we need only confirm that the number $lighthouse$ of functions $pinecone: sandcastle \\to sandcastle$ which iterate $sandcastle$ into $\\{1,\\dots,newspaper+1\\}$ but not into $\\{1,\\dots,newspaper\\}$ is equal to $bookshelf^{bookshelf-1}$. These are precisely the functions for which there is a unique cycle $moonstone$ containing only numbers in $\\{newspaper+1,\\dots,bookshelf\\}$ and said cycle contains $newspaper+1$. Suppose $moonstone$ has length $starfruit \\in \\{1,\\dots,bookshelf-newspaper\\}$. For a fixed choice of $starfruit$, we may choose the underlying set of $moonstone$ in\n$\\binom{bookshelf-newspaper-1}{starfruit-1}$ ways and the cycle structure in $(starfruit-1)!$ ways. Given $moonstone$, the functions $pinecone$ we want are the ones that act on $moonstone$ as specified and iterate $sandcastle$ into\n$\\{1,\\dots,newspaper\\} \\cup moonstone$.\nBy Lemma~1, the number of such functions is\n$bookshelf^{-starfruit}$ times the total number of functions that iterate $sandcastle$ into\n$\\{1,\\dots,newspaper\\} \\cup moonstone$.\nBy the induction hypothesis,\nwe compute the number of functions  which iterate $sandcastle$ into $\\{1,\\dots,newspaper+1\\}$ but not into $\\{1,\\dots,newspaper\\}$ to be\n\\[\n\\sum_{starfruit=1}^{bookshelf-newspaper} (bookshelf-newspaper-1)\\cdots(bookshelf-newspaper-starfruit+1)\n(newspaper+starfruit) bookshelf^{bookshelf-starfruit-1}\n\\]\nBy rewriting this as a telescoping sum, we get\n\\begin{align*}\n&\\sum_{starfruit=1}^{bookshelf-newspaper} (bookshelf-newspaper-1)\\cdots(bookshelf-newspaper-starfruit+1)\n(bookshelf) bookshelf^{bookshelf-starfruit-1} \\\\\n&- \\sum_{starfruit=1}^{bookshelf-newspaper} (bookshelf-newspaper-1)\\cdots(bookshelf-newspaper-starfruit+1)\n(bookshelf-newspaper-starfruit) bookshelf^{bookshelf-starfruit-1} \\\\\n&=\\sum_{starfruit=0}^{bookshelf-newspaper-1} (bookshelf-newspaper-1)\\cdots(bookshelf-newspaper-starfruit) bookshelf^{bookshelf-starfruit-1} \\\\\n&- \\sum_{starfruit=1}^{bookshelf-newspaper} (bookshelf-newspaper-1)\\cdots\n(bookshelf-newspaper-starfruit) bookshelf^{bookshelf-starfruit-1} \\\\\n&= bookshelf^{bookshelf-1}.\n\\end{align*}\nas desired.\n\n\\textbf{Second solution:}\nFor $seashells$ a set, $pinecone: seashells \\to seashells$ a function, and $driftwood$ a subset of $seashells$,\nwe define the \\emph{contraction} of $pinecone$ at $driftwood$ as the function $arrowroot: \\{* \\} \\cup (seashells-driftwood) \\to \\{*\\}  \\cup (seashells-driftwood)$\ngiven by\n\\[\narrowroot(lighthouse) = \\begin{cases} * & lighthouse = *  \\\\\n* & lighthouse \\neq *, pinecone(lighthouse) \\in driftwood \\\\\npinecone(lighthouse) & lighthouse \\neq *, pinecone(lighthouse) \\notin driftwood.\n\\end{cases}\n\\]\n\\begin{lemma}\nFor $driftwood \\subseteq sandcastle$ of cardinality $starfruit \\geq 0$,\nthere are $starfruit bookshelf^{bookshelf-starfruit-1}$ functions $pinecone: \\{*\\} \\cup sandcastle \\to \\{*\\} \\cup sandcastle$ with $pinecone^{-1}(*) = \\{*\\} \\cup driftwood$\nwhich iterate $sandcastle$ into $\\{*\\}$.\n\\end{lemma}\n\\begin{proof}\nWe induct on $bookshelf$. If $starfruit = bookshelf$ then there is nothing to check.\nOtherwise, put $seashells = pinecone^{-1}(driftwood)$, which must be nonempty.\nThe contraction $arrowroot$ of $pinecone$ at $\\{*\\} \\cup driftwood$ is then a function on $\\{*\\} \\cup (sandcastle-driftwood)$ with $pinecone^{-1}(*) = \\{*\\} \\cup seashells$ which iterates $sandcastle-driftwood$ into $\\{*\\}$. Moreover, for given $seashells$, each such $arrowroot$ arises from\n$starfruit^{\\# seashells}$ functions of the desired form.\nSumming over $seashells$ and invoking the induction hypothesis, we see that the number of functions $pinecone$ is \n\\begin{align*}\n&\\sum_{paintbrush=1}^{bookshelf-starfruit} \\binom{bookshelf-starfruit}{paintbrush} starfruit^{paintbrush} \\cdot paintbrush (bookshelf-starfruit)^{bookshelf-starfruit-paintbrush-1} \\\\\n&=\\sum_{paintbrush=1}^{bookshelf-starfruit} \\binom{bookshelf-starfruit-1}{paintbrush-1} starfruit^{paintbrush} (bookshelf-starfruit)^{bookshelf-starfruit-paintbrush} \n= starfruit bookshelf^{bookshelf-starfruit-1}\n\\end{align*}\nas claimed.\n\\end{proof}\n\nWe now count functions $pinecone: sandcastle \\to sandcastle$ which iterate $sandcastle$ into $\\{1,\\dots,newspaper\\}$ as follows. By Lemma~1 of the first solution, this count equals $bookshelf^{newspaper}$ times the number of functions with $pinecone(1) = \\cdots = pinecone(newspaper) = 1$  which iterate $sandcastle$ into $\\{1,\\dots,newspaper\\}$. For such a function $pinecone$, put $driftwood = \\{newspaper+1,\\dots,bookshelf\\} \\cap pinecone^{-1}(\\{1,\\dots,newspaper\\})$ and let $arrowroot$ be the contraction of $pinecone$\nat $\\{1,\\dots,newspaper\\}$; then $arrowroot^{-1}(*) = * \\cup \\{driftwood\\}$ and $arrowroot$ iterates \nits domain into $*$. By Lemma~2, for $starfruit = \\#driftwood$, there are\n$starfruit (bookshelf-newspaper)^{bookshelf-newspaper-starfruit-1}$ such functions $arrowroot$.\nFor given $driftwood$, each such $arrowroot$ gives rise to $newspaper^{starfruit}$ functions $pinecone$ with $pinecone(1) = \\cdots = pinecone(newspaper) = 1$  which iterate $sandcastle$ into $\\{1,\\dots,newspaper\\}$.\nThus the number of such functions $pinecone$ is\n\\begin{align*}\n&\\sum_{starfruit=0}^{bookshelf-newspaper} \\binom{bookshelf-newspaper}{starfruit} newspaper^{starfruit} starfruit (bookshelf-newspaper)^{bookshelf-newspaper-starfruit-1} \\\\\n&= \\sum_{starfruit=0}^{bookshelf-newspaper} \\binom{bookshelf-newspaper-1}{starfruit-1} newspaper^{starfruit} (bookshelf-newspaper)^{bookshelf-newspaper-starfruit}\\\\\n&= newspaper bookshelf^{bookshelf-newspaper-1}.\n\\end{align*}\nThe desired count is this times $bookshelf^{newspaper}$, or $newspaper bookshelf^{bookshelf-1}$ as desired.\n\n\\textbf{Remark:}\nFunctions of the sort counted in Lemma~2 can be identified with rooted trees on the vertex set $\\{*\\} \\cup sandcastle$ with root $*$. Such trees can be counted using \\emph{Cayley's formula}, a special case of \\emph{Kirchoff's matrix tree theorem}. The matrix tree theorem can also be used to show directly that the number of rooted forests on $bookshelf$ vertices with $newspaper$ fixed roots is $newspaper bookshelf^{bookshelf-newspaper-1}$; the desired count follows immediately from this formula plus Lemma~1. (One can also use Pr\"ufer sequences for a more combinatorial interpretation.)"
    },
    "descriptive_long_misleading": {
      "map": {
        "X": "emptiness",
        "x": "gigantic",
        "j": "stillness",
        "f": "malfunction",
        "T": "voidness",
        "S": "superset",
        "S_1": "supersetone",
        "S_2": "supersettwo",
        "g": "defective",
        "C": "acyclicset",
        "i": "stagnant",
        "\\ell": "tininess",
        "n": "minimums",
        "k": "supermax"
      },
      "question": "Let $emptiness = \\{1, 2, \\dots, minimums\\}$, and let $supermax \\in emptiness$. Show that there are exactly $supermax \\cdot minimums^{minimums-1}$ functions $malfunction: emptiness \\to emptiness$ such that for every $gigantic \\in emptiness$ there is a $stillness \\geq 0$ such that $malfunction^{(stillness)}(gigantic) \\leq supermax$.\n[Here $malfunction^{(stillness)}$ denotes the $stillness$\\textsuperscript{th} iterate of $malfunction$, so that $malfunction^{(0)}(gigantic) = gigantic$ and $malfunction^{(stillness+1)}(gigantic) = malfunction(malfunction^{(stillness)}(gigantic))$.]",
      "solution": "\\setcounter{lemma}{0}\n\\textbf{First solution:}\nWe assume $minimums \\geq 1$ unless otherwise specified.\nFor $voidness$ a set and $supersetone, supersettwo$ two subsets of $voidness$, we say that a function $malfunction: voidness \\to voidness$ \\emph{iterates $supersetone$ into $supersettwo$} if for each $gigantic \\in supersetone$, there is a $stillness \\geq 0$ such that $malfunction^{(stillness)}(gigantic) \\in supersettwo$.\n\n\\begin{lemma}\nFix $supermax \\in emptiness$. Let $malfunction,defective: emptiness \\to emptiness$ be two functions such that $malfunction$ iterates $emptiness$ into $\\{1,\\dots,supermax\\}$ and $malfunction(gigantic) = defective(gigantic)$ for $gigantic \\in \\{supermax+1,\\dots,minimums\\}$. Then $defective$ also iterates $emptiness$ into $\\{1,\\dots,supermax\\}$.\n\\end{lemma}\n\\begin{proof}\nFor $gigantic \\in emptiness$, by hypothesis there exists a nonnegative integer $stillness$ such that $malfunction^{(stillness)}(gigantic) \\in \\{1,\\dots,supermax\\}$. Choose the integer $stillness$ as small as possible; then $malfunction^{(stagnant)}(gigantic) \\in \\{supermax+1,\\dots,minimums\\}$ for $0 \\leq stagnant<stillness$. By induction on $stagnant$, we have $malfunction^{(stagnant)}(gigantic) = defective^{(stagnant)}(gigantic)$ for $stagnant=0,\\dots,stillness$, so in particular $defective^{(stillness)}(gigantic) \\in \\{1,\\dots,supermax\\}$. This proves the claim.\n\\end{proof}\n\nWe proceed by induction on $minimums-supermax$, the case $minimums-supermax=0$ being trivial.\nFor the induction step, we need only confirm that the number $gigantic$ of functions $malfunction: emptiness \\to emptiness$ which iterate emptiness into $\\{1,\\dots,supermax+1\\}$ but not into $\\{1,\\dots,supermax\\}$ is equal to $minimums^{minimums-1}$. These are precisely the functions for which there is a unique cycle $acyclicset$ containing only numbers in $\\{supermax+1,\\dots,minimums\\}$ and said cycle contains $supermax+1$. Suppose $acyclicset$ has length $tininess \\in \\{1,\\dots,minimums-supermax\\}$. For a fixed choice of $tininess$, we may choose the underlying set of $acyclicset$ in\n$\\binom{minimums-supermax-1}{tininess-1}$ ways and the cycle structure in $(tininess-1)!$ ways. Given $acyclicset$, the functions $malfunction$ we want are the ones that act on $acyclicset$ as specified and iterate emptiness into\n$\\{1,\\dots,supermax\\} \\cup acyclicset$.\nBy Lemma~1, the number of such functions is\n$minimums^{-tininess}$ times the total number of functions that iterate emptiness into\n$\\{1,\\dots,supermax\\} \\cup acyclicset$.\nBy the induction hypothesis,\nwe compute the number of functions  which iterate emptiness into $\\{1,\\dots,supermax+1\\}$ but not into $\\{1,\\dots,supermax\\}$ to be\n\\[\n\\sum_{tininess=1}^{minimums-supermax} (minimums-supermax-1)\\cdots(minimums-supermax-tininess+1)\n(supermax+tininess) minimums^{minimums-tininess-1}\n\\]\nBy rewriting this as a telescoping sum, we get\n\\begin{align*}\n&\\sum_{tininess=1}^{minimums-supermax} (minimums-supermax-1)\\cdots(minimums-supermax-tininess+1)\n(minimums) minimums^{minimums-tininess-1} \\\\\n&- \\sum_{tininess=1}^{minimums-supermax} (minimums-supermax-1)\\cdots(minimums-supermax-tininess+1)\n(minimums-supermax-tininess) minimums^{minimums-tininess-1} \\\\\n&=\\sum_{tininess=0}^{minimums-supermax-1} (minimums-supermax-1)\\cdots(minimums-supermax-tininess) minimums^{minimums-tininess-1} \\\\\n&- \\sum_{tininess=1}^{minimums-supermax} (minimums-supermax-1)\\cdots\n(minimums-supermax-tininess) minimums^{minimums-tininess-1} \\\\\n&= minimums^{minimums-1}.\n\\end{align*}\nas desired.\n\n\\textbf{Second solution:}\nFor $voidness$ a set, $malfunction: voidness \\to voidness$ a function, and $superset$ a subset of $voidness$,\nwe define the \\emph{contraction} of $malfunction$ at $superset$ as the function $defective: \\{* \\} \\cup (voidness-superset) \\to \\{*\\}  \\cup (voidness-superset)$\ngiven by\n\\[\ndefective(gigantic) = \\begin{cases} * & gigantic = *  \\\\\n* & gigantic \\neq *, malfunction(gigantic) \\in superset \\\\\nmalfunction(gigantic) & gigantic \\neq *, malfunction(gigantic) \\notin superset.\n\\end{cases}\n\\]\n\\begin{lemma}\nFor $superset \\subseteq emptiness$ of cardinality $tininess \\geq 0$,\nthere are $tininess minimums^{minimums-tininess-1}$ functions $malfunction: \\{*\\} \\cup emptiness \\to \\{*\\} \\cup emptiness$ with $malfunction^{-1}(*) = \\{*\\} \\cup superset$\nwhich iterate emptiness into $\\{*\\}$.\n\\end{lemma}\n\\begin{proof}\nWe induct on $minimums$. If $tininess = minimums$ then there is nothing to check.\nOtherwise, put $voidness = malfunction^{-1}(superset)$, which must be nonempty.\nThe contraction $defective$ of $malfunction$ at $\\{*\\} \\cup superset$ is then a function on $\\{*\\} \\cup (emptiness-superset)$ with $malfunction^{-1}(*) = \\{*\\} \\cup voidness$ which iterates $emptiness-superset$ into $\\{*\\}$. Moreover, for given $voidness$, each such $defective$ arises from\n$tininess^{\\# voidness}$ functions of the desired form.\nSumming over $voidness$ and invoking the induction hypothesis, we see that the number of functions $malfunction$ is \n\\begin{align*}\n&\\sum_{supermax=1}^{minimums-tininess} \\binom{minimums-tininess}{supermax} tininess^{supermax} \\cdot supermax (minimums-tininess)^{minimums-tininess-supermax-1} \\\\\n&=\\sum_{supermax=1}^{minimums-tininess} \\binom{minimums-tininess-1}{supermax-1} tininess^{supermax} (minimums-tininess)^{minimums-tininess-supermax} \n= tininess minimums^{minimums-tininess-1}\n\\end{align*}\nas claimed.\n\\end{proof}\n\nWe now count functions $malfunction: emptiness \\to emptiness$ which iterate emptiness into $\\{1,\\dots,supermax\\}$ as follows. By Lemma~1 of the first solution, this count equals $minimums^{supermax}$ times the number of functions with $malfunction(1) = \\cdots = malfunction(supermax) = 1$  which iterate emptiness into $\\{1,\\dots,supermax\\}$. For such a function $malfunction$, put $superset = \\{supermax+1,\\dots,minimums\\} \\cap malfunction^{-1}(\\{1,\\dots,supermax\\})$ and let $defective$ be the contraction of $malfunction$\nat $\\{1,\\dots,supermax\\}$; then $defective^{-1}(*) = * \\cup \\{superset\\}$ and $defective$ iterates \nits domain into $*$. By Lemma~2, for $tininess = \\#superset$, there are\n$tininess (minimums-supermax)^{minimums-supermax-tininess-1}$ such functions $defective$.\nFor given $superset$, each such $defective$ gives rise to $supermax^{tininess}$ functions $malfunction$ with $malfunction(1) = \\cdots = malfunction(supermax) = 1$  which iterate emptiness into $\\{1,\\dots,supermax\\}$.\nThus the number of such functions $malfunction$ is\n\\begin{align*}\n&\\sum_{tininess=0}^{minimums-supermax} \\binom{minimums-supermax}{tininess} supermax^{tininess} tininess (minimums-supermax)^{minimums-supermax-tininess-1} \\\\\n&= \\sum_{tininess=0}^{minimums-supermax} \\binom{minimums-supermax-1}{tininess-1} supermax^{tininess} (minimums-supermax)^{minimums-supermax-tininess}\\\\\n&= supermax minimums^{minimums-supermax-1}.\n\\end{align*}\nThe desired count is this times $minimums^{supermax}$, or $supermax minimums^{minimums-1}$ as desired.\n\n\\textbf{Remark:}\nFunctions of the sort counted in Lemma~2 can be identified with rooted trees on the vertex set $\\{*\\} \\cup emptiness$ with root $*$. Such trees can be counted using \\emph{Cayley's formula}, a special case of \\emph{Kirchoff's matrix tree theorem}. The matrix tree theorem can also be used to show directly that the number of rooted forests on $minimums$ vertices with $supermax$ fixed roots is $supermax minimums^{minimums-supermax-1}$; the desired count follows immediately from this formula plus Lemma~1. (One can also use Pr\"ufer sequences for a more combinatorial interpretation.)"
    },
    "garbled_string": {
      "map": {
        "X": "mgsdnqpl",
        "x": "tvkrouse",
        "j": "fzqlymna",
        "f": "hbrcpqvo",
        "T": "asljkebu",
        "S": "cihoptzx",
        "S_1": "bqyxmner",
        "S_2": "odfplwrt",
        "g": "uzseqnma",
        "C": "rlpqvzke",
        "i": "mcultrqn",
        "\\ell": "scbvoadr",
        "n": "qpzshfli",
        "k": "aldmrcvu"
      },
      "question": "Let $mgsdnqpl = \\{1, 2, \\dots, qpzshfli\\}$, and let $aldmrcvu \\in mgsdnqpl$. Show that there are exactly $aldmrcvu \\cdot qpzshfli^{qpzshfli-1}$ functions $hbrcpqvo: mgsdnqpl \\to mgsdnqpl$ such that for every $tvkrouse \\in mgsdnqpl$ there is a $fzqlymna \\geq 0$ such that $hbrcpqvo^{(fzqlymna)}(tvkrouse) \\leq aldmrcvu$.\n[Here $hbrcpqvo^{(fzqlymna)}$ denotes the $fzqlymna$\\textsuperscript{th} iterate of $hbrcpqvo$, so that $hbrcpqvo^{(0)}(tvkrouse) = tvkrouse$ and $hbrcpqvo^{(fzqlymna+1)}(tvkrouse) = hbrcpqvo(hbrcpqvo^{(fzqlymna)}(tvkrouse))$.]",
      "solution": "\\setcounter{lemma}{0}\n\\textbf{First solution:}\nWe assume $qpzshfli \\geq 1$ unless otherwise specified.\nFor $asljkebu$ a set and $bqyxmner, odfplwrt$ two subsets of $asljkebu$, we say that a function $hbrcpqvo: asljkebu \\to asljkebu$ \\emph{iterates $bqyxmner$ into $odfplwrt$} if for each $tvkrouse \\in bqyxmner$, there is a $fzqlymna \\geq 0$ such that $hbrcpqvo^{(fzqlymna)}(tvkrouse) \\in odfplwrt$.\n\n\\begin{lemma}\nFix $aldmrcvu \\in mgsdnqpl$. Let $hbrcpqvo,uzseqnma: mgsdnqpl \\to mgsdnqpl$ be two functions such that $hbrcpqvo$ iterates $mgsdnqpl$ into $\\{1,\\dots,aldmrcvu\\}$ and $hbrcpqvo(tvkrouse) = uzseqnma(tvkrouse)$ for $tvkrouse \\in \\{aldmrcvu+1,\\dots,qpzshfli\\}$. Then $uzseqnma$ also iterates $mgsdnqpl$ into $\\{1,\\dots,aldmrcvu\\}$.\n\\end{lemma}\n\\begin{proof}\nFor $tvkrouse \\in mgsdnqpl$, by hypothesis there exists a nonnegative integer $fzqlymna$ such that $hbrcpqvo^{(fzqlymna)}(tvkrouse) \\in \\{1,\\dots,aldmrcvu\\}$. Choose the integer $fzqlymna$ as small as possible; then $hbrcpqvo^{(mcultrqn)}(tvkrouse) \\in \\{aldmrcvu+1,\\dots,qpzshfli\\}$ for $0 \\leq mcultrqn<fzqlymna$. By induction on $mcultrqn$, we have $hbrcpqvo^{(mcultrqn)}(tvkrouse) = uzseqnma^{(mcultrqn)}(tvkrouse)$ for $mcultrqn=0,\\dots,fzqlymna$, so in particular $uzseqnma^{(fzqlymna)}(tvkrouse) \\in \\{1,\\dots,aldmrcvu\\}$. This proves the claim.\n\\end{proof}\n\nWe proceed by induction on $qpzshfli-aldmrcvu$, the case $qpzshfli-aldmrcvu=0$ being trivial.\nFor the induction step, we need only confirm that the number $tvkrouse$ of functions $hbrcpqvo: mgsdnqpl \\to mgsdnqpl$ which iterate $mgsdnqpl$ into $\\{1,\\dots,aldmrcvu+1\\}$ but not into $\\{1,\\dots,aldmrcvu\\}$ is equal to $qpzshfli^{qpzshfli-1}$. These are precisely the functions for which there is a unique cycle $rlpqvzke$ containing only numbers in $\\{aldmrcvu+1,\\dots,qpzshfli\\}$ and said cycle contains $aldmrcvu+1$. Suppose $rlpqvzke$ has length $scbvoadr \\in \\{1,\\dots,qpzshfli-aldmrcvu\\}$. For a fixed choice of $scbvoadr$, we may choose the underlying set of $rlpqvzke$ in\n$\\binom{qpzshfli-aldmrcvu-1}{scbvoadr-1}$ ways and the cycle structure in $(scbvoadr-1)!$ ways. Given $rlpqvzke$, the functions $hbrcpqvo$ we want are the ones that act on $rlpqvzke$ as specified and iterate $mgsdnqpl$ into\n$\\{1,\\dots,aldmrcvu\\} \\cup rlpqvzke$.\nBy Lemma~1, the number of such functions is\n$qpzshfli^{-scbvoadr}$ times the total number of functions that iterate $mgsdnqpl$ into\n$\\{1,\\dots,aldmrcvu\\} \\cup rlpqvzke$.\nBy the induction hypothesis,\nwe compute the number of functions  which iterate $mgsdnqpl$ into $\\{1,\\dots,aldmrcvu+1\\}$ but not into $\\{1,\\dots,aldmrcvu\\}$ to be\n\\[\n\\sum_{scbvoadr=1}^{qpzshfli-aldmrcvu} (qpzshfli-aldmrcvu-1)\\cdots(qpzshfli-aldmrcvu-scbvoadr+1)\n(aldmrcvu+scbvoadr) qpzshfli^{qpzshfli-scbvoadr-1}\n\\]\nBy rewriting this as a telescoping sum, we get\n\\begin{align*}\n&\\sum_{scbvoadr=1}^{qpzshfli-aldmrcvu} (qpzshfli-aldmrcvu-1)\\cdots(qpzshfli-aldmrcvu-scbvoadr+1)\n(qpzshfli) qpzshfli^{qpzshfli-scbvoadr-1} \\\\\n&- \\sum_{scbvoadr=1}^{qpzshfli-aldmrcvu} (qpzshfli-aldmrcvu-1)\\cdots(qpzshfli-aldmrcvu-scbvoadr+1)\n(qpzshfli-aldmrcvu-scbvoadr) qpzshfli^{qpzshfli-scbvoadr-1} \\\\\n&=\\sum_{scbvoadr=0}^{qpzshfli-aldmrcvu-1} (qpzshfli-aldmrcvu-1)\\cdots(qpzshfli-aldmrcvu-scbvoadr) qpzshfli^{qpzshfli-scbvoadr-1} \\\\\n&- \\sum_{scbvoadr=1}^{qpzshfli-aldmrcvu} (qpzshfli-aldmrcvu-1)\\cdots\n(qpzshfli-aldmrcvu-scbvoadr) qpzshfli^{qpzshfli-scbvoadr-1} \\\\\n&= qpzshfli^{qpzshfli-1}.\n\\end{align*}\nas desired.\n\n\\textbf{Second solution:}\nFor $asljkebu$ a set, $hbrcpqvo: asljkebu \\to asljkebu$ a function, and $cihoptzx$ a subset of $asljkebu$,\nwe define the \\emph{contraction} of $hbrcpqvo$ at $cihoptzx$ as the function $uzseqnma: \\{* \\} \\cup (asljkebu-cihoptzx) \\to \\{*\\}  \\cup (asljkebu-cihoptzx)$\ngiven by\n\\[\nuzseqnma(tvkrouse) = \\begin{cases} * & tvkrouse = *  \\\\\n* & tvkrouse \\neq *, hbrcpqvo(tvkrouse) \\in cihoptzx \\\\\nhbrcpqvo(tvkrouse) & tvkrouse \\neq *, hbrcpqvo(tvkrouse) \\notin cihoptzx.\n\\end{cases}\n\\]\n\\begin{lemma}\nFor $cihoptzx \\subseteq mgsdnqpl$ of cardinality $scbvoadr \\geq 0$,\nthere are $scbvoadr qpzshfli^{qpzshfli-scbvoadr-1}$ functions $hbrcpqvo: \\{*\\} \\cup mgsdnqpl \\to \\{*\\} \\cup mgsdnqpl$ with $hbrcpqvo^{-1}(*) = \\{*\\} \\cup cihoptzx$\nwhich iterate $mgsdnqpl$ into $\\{*\\}$.\n\\end{lemma}\n\\begin{proof}\nWe induct on $qpzshfli$. If $scbvoadr = qpzshfli$ then there is nothing to check.\nOtherwise, put $asljkebu = hbrcpqvo^{-1}(cihoptzx)$, which must be nonempty.\nThe contraction $uzseqnma$ of $hbrcpqvo$ at $\\{*\\} \\cup cihoptzx$ is then a function on $\\{*\\} \\cup (mgsdnqpl-cihoptzx)$ with $hbrcpqvo^{-1}(*) = \\{*\\} \\cup asljkebu$ which iterates $mgsdnqpl-cihoptzx$ into $\\{*\\}$. Moreover, for given $asljkebu$, each such $uzseqnma$ arises from\n$scbvoadr^{\\# asljkebu}$ functions of the desired form.\nSumming over $asljkebu$ and invoking the induction hypothesis, we see that the number of functions $hbrcpqvo$ is \n\\begin{align*}\n&\\sum_{aldmrcvu=1}^{qpzshfli-scbvoadr} \\binom{qpzshfli-scbvoadr}{aldmrcvu} scbvoadr^{aldmrcvu} \\cdot aldmrcvu (qpzshfli-scbvoadr)^{qpzshfli-scbvoadr-aldmrcvu-1} \\\\\n&=\\sum_{aldmrcvu=1}^{qpzshfli-scbvoadr} \\binom{qpzshfli-scbvoadr-1}{aldmrcvu-1} scbvoadr^{aldmrcvu} (qpzshfli-scbvoadr)^{qpzshfli-scbvoadr-aldmrcvu} \n= scbvoadr qpzshfli^{qpzshfli-scbvoadr-1}\n\\end{align*}\nas claimed.\n\\end{proof}\n\nWe now count functions $hbrcpqvo: mgsdnqpl \\to mgsdnqpl$ which iterate $mgsdnqpl$ into $\\{1,\\dots,aldmrcvu\\}$ as follows. By Lemma~1 of the first solution, this count equals $qpzshfli^{aldmrcvu}$ times the number of functions with $hbrcpqvo(1) = \\cdots = hbrcpqvo(aldmrcvu) = 1$  which iterate $mgsdnqpl$ into $\\{1,\\dots,aldmrcvu\\}$. For such a function $hbrcpqvo$, put $cihoptzx = \\{aldmrcvu+1,\\dots,qpzshfli\\} \\cap hbrcpqvo^{-1}(\\{1,\\dots,aldmrcvu\\})$ and let $uzseqnma$ be the contraction of $hbrcpqvo$\nat $\\{1,\\dots,aldmrcvu\\}$; then $uzseqnma^{-1}(*) = * \\cup \\{cihoptzx\\}$ and $uzseqnma$ iterates \nits domain into $*$. By Lemma~2, for $scbvoadr = \\#cihoptzx$, there are\n$scbvoadr (qpzshfli-aldmrcvu)^{qpzshfli-aldmrcvu-scbvoadr-1}$ such functions $uzseqnma$.\nFor given $cihoptzx$, each such $uzseqnma$ gives rise to $aldmrcvu^{scbvoadr}$ functions $hbrcpqvo$ with $hbrcpqvo(1) = \\cdots = hbrcpqvo(aldmrcvu) = 1$  which iterate $mgsdnqpl$ into $\\{1,\\dots,aldmrcvu\\}$.\nThus the number of such functions $hbrcpqvo$ is\n\\begin{align*}\n&\\sum_{scbvoadr=0}^{qpzshfli-aldmrcvu} \\binom{qpzshfli-aldmrcvu}{scbvoadr} aldmrcvu^{scbvoadr} scbvoadr (qpzshfli-aldmrcvu)^{qpzshfli-aldmrcvu-scbvoadr-1} \\\\\n&= \\sum_{scbvoadr=0}^{qpzshfli-aldmrcvu} \\binom{qpzshfli-aldmrcvu-1}{scbvoadr-1} aldmrcvu^{scbvoadr} (qpzshfli-aldmrcvu)^{qpzshfli-aldmrcvu-scbvoadr}\\\\\n&= aldmrcvu qpzshfli^{qpzshfli-aldmrcvu-1}.\n\\end{align*}\nThe desired count is this times $qpzshfli^{aldmrcvu}$, or $aldmrcvu qpzshfli^{qpzshfli-1}$ as desired.\n\n\\textbf{Remark:}\nFunctions of the sort counted in Lemma~2 can be identified with rooted trees on the vertex set $\\{*\\} \\cup mgsdnqpl$ with root $*$. Such trees can be counted using \\emph{Cayley's formula}, a special case of \\emph{Kirchoff's matrix tree theorem}. The matrix tree theorem can also be used to show directly that the number of rooted forests on $qpzshfli$ vertices with $aldmrcvu$ fixed roots is $aldmrcvu qpzshfli^{qpzshfli-aldmrcvu-1}$; the desired count follows immediately from this formula plus Lemma~1. (One can also use Pr\"ufer sequences for a more combinatorial interpretation.)"
    },
    "kernel_variant": {
      "question": "Let\n$$\n\\Omega = \\{\\alpha_0,\\alpha_1,\\dots ,\\alpha_{M-1}\\}\\quad(M\\ge 1),\n\\qquad \\Gamma = \\{\\alpha_0,\\alpha_1,\\dots ,\\alpha_{R-1}\\}\\;(1\\le R\\le M)\n$$\nbe fixed finite sets.  Determine, with proof, the number of functions\n$$\n\\Phi : \\Omega \\longrightarrow \\Omega\n$$\nthat satisfy\n\n(\\*)\\; for every \\(x\\in\\Omega\\) there exists an integer \\(t\\ge 0\\) such that\n\\(\\Phi^{(t)}(x)\\in\\Gamma.\\)\n\n(Here \\(\\Phi^{(0)}\\) is the identity on \\(\\Omega\\) and \\(\\Phi^{(t+1)}=\\Phi\\circ\\Phi^{(t)}\\).)",
      "solution": "Corrected Solution.  Let |Ω|=M and |Γ|=R.\n\n1. (Agreement Lemma)  If f and g:Ω→Ω agree on Ω\\Γ and if every orbit of f meets Γ, then every orbit of g also meets Γ.  Indeed, for any x take the least t with f^{(t)}(x)∈Γ; then for i<t we have f^{(i)}(x)∉Γ so f^{(i)}(x)=g^{(i)}(x), and hence g^{(t)}(x)=f^{(t)}(x)∈Γ.\n\n2. By the Agreement Lemma, to count all admissible f it suffices to:\n   (a) fix any convention for f on Γ (there are M^R choices),\n   (b) count only those f with that fixed convention on Γ whose orbits meet Γ.\n\n3.  We choose the convention f(i)=i for each i∈Γ.  Then \"every orbit meets Γ\" is equivalent to \"f has no cycles except the R fixed points in Γ.\"  Equivalently, the functional digraph of f is a forest on Ω with the R vertices of Γ as roots.\n\n4.  By the Matrix–Tree theorem (or a Prüfer‐code argument), the number of labelled forests on M vertices with a prescribed set Γ of R roots is\n     R·M^{M−R−1}.\n\n5.  Finally we multiply by the M^R choices of how f might have acted on Γ in the first place.  Therefore the total number of functions f:Ω→Ω satisfying (*) is\n     M^R · [R·M^{M−R−1}] = R·M^{M−1}.\n\nThis completes the proof that there are exactly R·M^{M−1} such functions.",
      "_meta": {
        "core_steps": [
          "Agreement lemma: if two maps coincide outside the target subset, the property of every orbit meeting that subset is preserved.",
          "Normalize by fixing the images of the k ‘target’ points, reducing the count by a factor n^k.",
          "Induct on the size of the complement (n−k): split each map into (i) one cycle lying completely in the complement and (ii) rooted trees feeding into that cycle.",
          "Count cycles by ordinary permutations and count the rooted trees with Cayley/Prufer (yielding n^{n-1}).",
          "Combine the counts and restore the normalization factor to obtain k·n^{n-1}."
        ],
        "mutable_slots": {
          "slot1": {
            "description": "Concrete labels of the ground set; any n-element set works.",
            "original": "{1,2,…,n}"
          },
          "slot2": {
            "description": "Chosen ‘absorbing’ subset of size k that every orbit must reach.",
            "original": "{1,…,k}"
          },
          "slot3": {
            "description": "Particular element of the complement singled out to lie on the unique cycle in the inductive count.",
            "original": "k+1"
          },
          "slot4": {
            "description": "Adjoined symbol used as the root in the contraction/rooted-tree viewpoint.",
            "original": "*"
          },
          "slot5": {
            "description": "Names of the size parameters; any letters could replace them.",
            "original": "n, k"
          }
        }
      }
    }
  },
  "checked": true,
  "problem_type": "proof"
}