├── DeepSeekMath_V2.pdf ├── figures ├── Competitions.png └── IMO-ProofBench.png ├── inference ├── README.md ├── run.sh ├── utils.py ├── generate.py ├── math_templates.py └── main.py ├── outputs ├── README.md └── CMO2024.jsonl ├── inputs ├── CMO2024.json ├── CMO2025.json ├── IMO2025.json └── Putnam2024.json ├── README.md └── LICENSE /DeepSeekMath_V2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deepseek-ai/DeepSeek-Math-V2/HEAD/DeepSeekMath_V2.pdf -------------------------------------------------------------------------------- /figures/Competitions.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deepseek-ai/DeepSeek-Math-V2/HEAD/figures/Competitions.png -------------------------------------------------------------------------------- /figures/IMO-ProofBench.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deepseek-ai/DeepSeek-Math-V2/HEAD/figures/IMO-ProofBench.png -------------------------------------------------------------------------------- /inference/README.md: -------------------------------------------------------------------------------- 1 | Here presents an example code for running proof-based evaluations. 2 | 3 | You should first specify your api key in the `generate.py` file and then run `run.sh` to start your job. -------------------------------------------------------------------------------- /outputs/README.md: -------------------------------------------------------------------------------- 1 | This work makes use of [IMO-ProofBench](https://github.com/google-deepmind/superhuman/tree/main/imobench), developed by Google DeepMind, which is licensed under the [Apache License, Version 2.0](https://github.com/google-deepmind/superhuman/blob/main/LICENSE). -------------------------------------------------------------------------------- /inference/run.sh: -------------------------------------------------------------------------------- 1 | set -f 2 | 3 | input_path=../IMO2025.json,../CMO2024.json,../CMO2025.json 4 | # directory to dump results 5 | output_dirname=xxx 6 | # directory to maintain a pool of generated proofs for each evaluated problem 7 | proof_pool_dirname=${output_dirname}/proof_pool 8 | 9 | python main.py \ 10 | --input_paths ${input_path} \ 11 | --output_dirname ${output_dirname} \ 12 | --proof_pool_dirname ${proof_pool_dirname} \ 13 | --n_best_proofs_to_sample 32 \ 14 | --n_proofs_to_refine 1 \ 15 | --n_agg_trials 32 \ 16 | --n_parallel_proof_gen 128 \ 17 | --n_verification_per_proof 64 \ 18 | --skip_meta_verification \ 19 | --start_round 1 \ 20 | --max_rounds 16 21 | 22 | set +f 23 | -------------------------------------------------------------------------------- /inference/utils.py: -------------------------------------------------------------------------------- 1 | import hashlib 2 | import json 3 | import regex 4 | 5 | def hash_problem_idx(question): 6 | return hashlib.sha256(question.encode()).hexdigest() 7 | 8 | def read_data(path): 9 | items = [] 10 | if path.endswith(".jsonl"): 11 | with open(path, "r") as file: 12 | for line in file: 13 | item = json.loads(line) 14 | items.append(item) 15 | else: 16 | items = json.load(open(path, "r")) 17 | return items 18 | 19 | def extract_boxed_answers(text): 20 | answers = [] 21 | for piece in text.split('boxed{')[1:]: 22 | n = 0 23 | for i in range(len(piece)): 24 | if piece[i] == '{': 25 | n += 1 26 | elif piece[i] == '}': 27 | n -= 1 28 | if n < 0: 29 | if i + 1 < len(piece) and piece[i + 1] == '%': 30 | answers.append(piece[: i + 1]) 31 | else: 32 | answers.append(piece[:i]) 33 | break 34 | return answers 35 | 36 | def _normalize_prover_output(text): 37 | text = text.strip() 38 | text = regex.sub(r"(^|\n)\s*\*+\s*Solution\s*\*+\s*\n", "\n## Solution\n", text) 39 | text = regex.sub(r"\n\s*\*+\s*Self Evaluation\s*\*+\s*\n", "\n## Self Evaluation\n", text) 40 | text = regex.sub(r"(^|\n)## Solution\s*\n", "\n## Solution\n", text) 41 | text = regex.sub(r"\n## Self Evaluation\s*\n", "\n## Self Evaluation\n", text) 42 | return text.strip() 43 | 44 | def extract_solution(student): 45 | student = _normalize_prover_output(student) 46 | return regex.split(r"## Solution\s*\n", regex.split(r"\n## Self Evaluation\s*\n", student)[0])[1].strip() 47 | 48 | def extract_self_eval(student): 49 | student = _normalize_prover_output(student) 50 | return regex.split(r"\n## Self Evaluation\s*\n", student)[1].strip() 51 | -------------------------------------------------------------------------------- /inputs/CMO2024.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": 1, 4 | "question": "Let $\\alpha > 1$ be an irrational number and $L$ be a integer such that $L > \\frac{\\alpha^2}{\\alpha - 1}$. A sequence $x_1, x_2, \\cdots$ satisfies that $x_1 > L$ and for all positive integers $n$,\\[ x_{n+1} = \\begin{cases} \\left \\lfloor \\alpha x_n \\right \\rfloor & \\textup{if} \\; x_n \\leqslant L \\\\left \\lfloor \\frac{x_n}{\\alpha} \\right \\rfloor & \\textup{if} \\; x_n > L \\end{cases}. \\]Prove that\n(i) $\\left\\{x_n\\right\\}$ is eventually periodic.\n(ii) The eventual fundamental period of $\\left\\{x_n\\right\\}$ is an odd integer which doesn't depend on the choice of $x_1$.", 5 | "answer": "null", 6 | "contest": "CMO2024", 7 | "problem_idx": "CMO2024-1" 8 | }, 9 | { 10 | "id": 2, 11 | "question": "Let $ABC$ be a triangle with incenter $I$. Denote the midpoints of $AI$, $AC$ and $CI$ by $L$, $M$ and $N$ respectively. Point $D$ lies on segment $AM$ such that $BC= BD$. Let the incircle of triangle $ABD$ be tangent to $AD$ and $BD$ at $E$ and $F$ respectively. Denote the circumcenter of triangle $AIC$ by $J$, and the circumcircle of triangle $JMD$ by $\\omega$. Lines $MN$ and $JL$ meet $\\omega$ again at $P$ and $Q$ respectively. Prove that $PQ$, $LN$ and $EF$ are concurrent.", 12 | "answer": "null", 13 | "contest": "CMO2024", 14 | "problem_idx": "CMO2024-2" 15 | }, 16 | { 17 | "id": 3, 18 | "question": "Let \\(a_1, a_2, \\ldots, a_n\\) be integers such that \\(a_1 > a_2 > \\cdots > a_n > 1\\). Let \\(M = \\operatorname{lcm} \\left( a_1, a_2, \\ldots, a_n \\right)\\). For any finite nonempty set $X$ of positive integers, define\\[ f(X) = \\min_{1 \\leqslant i \\leqslant n} \\sum_{x \\in X} \\left\\{ \\frac{x}{a_i} \\right\\}. \\]Such a set $X$ is called minimal if for every proper subset $Y$ of it, $f(Y) < f(X)$ always holds.\n\nSuppose $X$ is minimal and $f(X) \\geqslant \\frac{2}{a_n}$. Prove that\\[ |X| \\leqslant f(X) \\cdot M. \\]", 19 | "answer": "null", 20 | "contest": "CMO2024", 21 | "problem_idx": "CMO2024-3" 22 | }, 23 | { 24 | "id": 4, 25 | "question": "The fractional distance between two points $(x_1,y_1)$ and $(x_2,y_2)$ is defined as\\[ \\sqrt{ \\left\\| x_1 - x_2 \\right\\|^2 + \\left\\| y_1 - y_2 \\right\\|^2},\\]where $\\left\\| x \\right\\|$ denotes the distance between $x$ and its nearest integer. Find the largest real $r$ such that there exists four points on the plane whose pairwise fractional distance are all at least $r$.", 26 | "answer": "\\frac{\\sqrt{6} - \\sqrt{2}}{2}", 27 | "contest": "CMO2024", 28 | "problem_idx": "CMO2024-4" 29 | }, 30 | { 31 | "id": 5, 32 | "question": "Let $p$ be a prime number and $f$ be a bijection from $\\left\\{0,1,\\ldots,p-1\\right\\}$ to itself. Suppose that for integers $a,b \\in \\left\\{0,1,\\ldots,p-1\\right\\}$, $|f(a) - f(b)|\\leqslant 2024$ if $p \\mid a^2 - b$. Prove that there exists infinite many $p$ such that there exists such an $f$ and there also exists infinite many $p$ such that there doesn't exist such an $f$.", 33 | "answer": "null", 34 | "contest": "CMO2024", 35 | "problem_idx": "CMO2024-5" 36 | }, 37 | { 38 | "id": 6, 39 | "question": "Let $a_1, a_2, \\ldots, a_n$ be real numbers such that $\\sum_{i=1}^n a_i = n$, $\\sum_{i = 1}^n a_i^2 = 2n$, $\\sum_{i=1}^n a_i^3 = 3n$.\n(i) Find the largest constant $C$, such that for all $n \\geqslant 4$,\\[ \\max \\left\\{ a_1, a_2, \\ldots, a_n \\right\\} - \\min \\left\\{ a_1, a_2, \\ldots, a_n \\right\\} \\geqslant C. \\](ii) Prove that there exists a positive constant $C_2$, such that\\[ \\max \\left\\{ a_1, a_2, \\ldots, a_n \\right\\} - \\min \\left\\{ a_1, a_2, \\ldots, a_n \\right\\} \\geqslant C + C_2 n^{-\\frac 32}, \\]where $C$ is the constant determined in (i).", 40 | "answer": "\\sqrt{5}", 41 | "contest": "CMO2024", 42 | "problem_idx": "CMO2024-6" 43 | } 44 | ] -------------------------------------------------------------------------------- /inputs/CMO2025.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": 1, 4 | "question": "Define two subsets $A$, $B$ of the set of complex numbers $\\Bbb C$ as follows:\\[ \\begin{aligned} A &= \\left\\{ z \\in \\Bbb C \\, \\left| \\, z = r \\textup{e}^{\\textup{i}\\theta} , \\, r \\geqslant 0, \\, \\theta \\in \\left[ 0, \\frac{\\pi}{41}\\right]\\right.\\right\\}, \\ B &= \\left\\{ z \\in \\Bbb C \\, \\left| \\, z = x + \\textup{i}y, \\, x,y \\in \\Bbb R , \\, \\left| x - y \\right| < 2025 \\right. \\right\\} \\end{aligned}\\]where $\\textup{i}$ is the imaginary unit and $r \\textup{e}^{\\textup{i}\\theta} = r \\left( \\cos \\theta + \\textup{i} \\sin \\theta \\right)$.\nFind all univariate polynomials of complex coefficients $P(x)$, such that for all $z \\in A$, we have $P(z) \\in B$. (Note: A monomial is also considered a polynomial.)", 5 | "answer": "null", 6 | "contest": "CMO2025", 7 | "problem_idx": "CMO2025-1" 8 | }, 9 | { 10 | "id": 2, 11 | "question": "Let $ABCD$ be an convex quadrilateral inscribed in a circle with center $O$ and radius $1$, with vertices labeled consecutively around the circle (regardless of orientation), which satisfies $\\angle ABC < \\angle BCD < 90^\\circ$. Let lines $BA$ and $CD$ intersect at $P$, diagonals $AC$ and $BD$ intersect at $Q$. There is a point $K$ on segment $\\overline{BC}$, such that $P$, $A$, $K$, $D$ are concyclic and $KB \\cdot KC = \\frac 12 OP^2$. The perpendicular to $BC$ through $Q$ intersects line $OP$ at $T$.\n(1) Find all possible values of $\\overline{OP}$.\n(2) Find all possible values of $\\overline{TB} + \\overline{TC}$.", 12 | "answer": "null", 13 | "contest": "CMO2025", 14 | "problem_idx": "CMO2025-2" 15 | }, 16 | { 17 | "id": 3, 18 | "question": "Let $n$ be an positive integer. There are $n$ red cards and $n$ blue cards. Initially, there is a real number $0$ on each red card, and a real number $1$ on each blue card. One operation is: choose a red card and a blue card, such that the real number $x$ on the red card is smaller than the real number $y$ on the blue card, erase these two numbers and write down $\\frac{x + y}{2}$ instead on both cards.\nFind the smallest positive integer $n$, such that one can appropriately operate finite times to make the sum of real numbers on red cards be larger than $100$.", 19 | "answer": "null", 20 | "contest": "CMO2025", 21 | "problem_idx": "CMO2025-3" 22 | }, 23 | { 24 | "id": 4, 25 | "question": "There are 30 colors of cards, with 70 cards of each color. Initially, 70 cards are chosen arbitrarily and stacked from top to bottom to form a pile.\n\nOne operation is defined as follows:\nFrom the bottom 20 cards, choose a card $X$ whose color does *not* appear among the top 50 cards. Then, from the top 50 cards, choose a card $Y$ whose color appears at least twice among the top 50 cards. Remove $X$ and reinsert it immediately above $Y$. Repeat this operation until it is no longer possible to select such an $X$.\n\n(1) Prove that the operation can only be performed finitely many times.\n(2) Over all possible initial configurations and choices of operations, determine the maximum possible number of operations.", 26 | "answer": "null", 27 | "contest": "CMO2025", 28 | "problem_idx": "CMO2025-4" 29 | }, 30 | { 31 | "id": 5, 32 | "question": "Find all real numbers $\\lambda$ such that there exists a positive integer $N$ with the following property:\n for every integer $n \\ge N$ and for all non-negative real numbers\n $x_1, x_2, \\ldots, x_n$ whose sum is 1, the inequality\n\n$$\n\\left( \\sum_{1\\le i 1$. It is known that every prime divisor $p$ of $n$ satisfies $\\gcd(p - 1, n) = 1$. Determine the number of triples $(a, b, c)$ satisfying the following two conditions:\n\n(1) $a, b, c \\in {1, 2, \\dots, n}$, and $\\gcd(a, b, c, n) = 1$\n\n(2) There exists a permutation $x_1, x_2, \\dots, x_n$ of $1, 2, \\dots, n$ such that for every $1 \\le k \\le n$,\n\n$$\nn \\mid a x_{k+2} + b x_{k+1} + c x_k,\n$$\nwhere the indices are interpreted modulo $n$.", 40 | "answer": "null", 41 | "contest": "CMO2025", 42 | "problem_idx": "CMO2025-6" 43 | } 44 | ] -------------------------------------------------------------------------------- /inputs/IMO2025.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": 1, 4 | "question": "A line in the plane is called \\emph{sunny} if it is not parallel to any of the $x$-axis, the $y$-axis, or the line $x + y = 0$.\n\nLet $n \\geq 3$ be a given integer. Determine all nonnegative integers $k$ such that there exist $n$ distinct lines in the plane satisfying both of the following:\n\\begin{itemize}\n \\item for all positive integers $a$ and $b$ with $a + b \\leq n + 1$, the point $(a, b)$ lies on at least one of the lines; and\n \\item exactly $k$ of the $n$ lines are sunny.\n\\end{itemize}", 5 | "answer": "k = 0, 1, 3 for all n", 6 | "contest": "IMO2025", 7 | "problem_idx": "IMO2025-1" 8 | }, 9 | { 10 | "id": 2, 11 | "question": "Let \\( \\Omega \\) and \\( \\Gamma \\) be circles with centres \\( M \\) and \\( N \\), respectively, such that the radius of \\( \\Omega \\) is less than the radius of \\( \\Gamma \\). Suppose \\( \\Omega \\) and \\( \\Gamma \\) intersect at two distinct points \\( A \\) and \\( B \\). Line \\( MN \\) intersects \\( \\Omega \\) at \\( C \\) and \\( \\Gamma \\) at \\( D \\), so that \\( C, M, N, D \\) lie on \\( MN \\) in that order. Let \\( P \\) be the circumcentre of triangle \\( ACD \\). Line \\( AP \\) meets \\( \\Omega \\) again at \\( E \\ne A \\) and meets \\( \\Gamma \\) again at \\( F \\ne A \\). Let \\( H \\) be the orthocentre of triangle \\( PMN \\).\n\nProve that the line through \\( H \\) parallel to \\( AP \\) is tangent to the circumcircle of triangle \\( BEF \\).", 12 | "answer": "null", 13 | "contest": "IMO2025", 14 | "problem_idx": "IMO2025-2" 15 | }, 16 | { 17 | "id": 3, 18 | "question": "Let \\mathbb{N} denote the set of positive integers. A function \\( f : \\mathbb{N} \\rightarrow \\mathbb{N} \\) is said to be bonza if \n\\[\nf(a) \\text{ divides } b^a - f(b)^{f(a)}\n\\] \nfor all positive integers \\( a \\) and \\( b \\).\n\nDetermine the smallest real constant \\( c \\) such that \\( f(n) \\leq cn \\) for all bonza functions \\( f \\) and all positive integers \\( n \\).", 19 | "answer": "4", 20 | "contest": "IMO2025", 21 | "problem_idx": "IMO2025-3" 22 | }, 23 | { 24 | "id": 4, 25 | "question": "A proper divisor of a positive integer \\( N \\) is a positive divisor of \\( N \\) other than \\( N \\) itself. \nThe infinite sequence \\( a_1, a_2, \\cdots \\) consists of positive integers, each of which has at least three proper divisors. \nFor each \\( n \\geq 1 \\), the integer \\( a_{n+1} \\) is the sum of the three largest proper divisors of \\( a_n \\). \nDetermine all possible values of \\( a_1 \\).", 26 | "answer": "The set of all possible values for $a_1$ are integers $a$ of the form $a = 2^x 3^y m$, where:\n1. $x$ is a positive odd integer.\n2. $y$ is a positive integer satisfying $y \\ge \\frac{x+1}{2}$.\n3. $m$ is a positive integer whose prime factors are all greater than or equal to 7.", 27 | "contest": "IMO2025", 28 | "problem_idx": "IMO2025-4" 29 | }, 30 | { 31 | "id": 5, 32 | "question": "Alice and Bazza are playing the inekoalaty game, a two-player game whose rules depend on a positive real number \\(\\lambda\\) which is known to both players. On the \\(n\\)th turn of the game (starting with \\(n = 1\\)) the following happens:\n\n- If \\(n\\) is odd, Alice chooses a nonnegative real number \\(x_n\\) such that \n \\[\n x_1 + x_2 + \\cdots + x_n \\leq \\lambda n.\n \\]\n\n- If \\(n\\) is even, Bazza chooses a nonnegative real number \\(x_n\\) such that \n \\[\n x_1^2 + x_2^2 + \\cdots + x_n^2 \\leq n.\n \\]\n\nIf a player cannot choose a suitable \\(x_n\\), the game ends and the other player wins. If the game goes on forever, neither player wins. All chosen numbers are known to both players.\n\nDetermine all values of \\(\\lambda\\) for which Alice has a winning strategy and all those for which Bazza has a winning strategy.", 33 | "answer": "The outcome of the inekoalty game depends on the value of \\lambda as follows:\n\n- If \\lambda > \\frac{\\sqrt{2}}{2}, Alice has a winning strategy.\n- If \\lambda < \\frac{\\sqrt{2}}{2}, Bazza has a winning strategy.\n- If \\lambda = \\frac{\\sqrt{2}}{2}, neither player has a winning strategy, and the game can go on forever.", 34 | "contest": "IMO2025", 35 | "problem_idx": "IMO2025-5" 36 | }, 37 | { 38 | "id": 6, 39 | "question": "Consider a 2025 \\times 2025 grid of unit squares. Matilda wishes to place on the grid some rectangular tiles, possibly of different sizes, such that each side of every tile lies on a grid line and every unit square is covered by at most one tile. \nDetermine the minimum number of tiles Matilda needs to place so that each row and each column of the grid has exactly one unit square that is not covered by any tile.", 40 | "answer": "2112", 41 | "contest": "IMO2025", 42 | "problem_idx": "IMO2025-6" 43 | } 44 | ] -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
6 | DeepSeek-V3 7 |
8 |
9 |
10 | Homepage 12 | Chat 14 | Hugging Face 16 |
17 | Discord 19 | Wechat 21 | Twitter Follow 23 |
24 | 25 | License 26 | 27 |
28 |
29 | 30 | # DeepSeekMath-V2: Towards Self-Verifiable Mathematical Reasoning 31 | 32 | ## 1. Introduction 33 | 34 | Large language models have made significant progress in mathematical reasoning, which serves as an important testbed for AI and could impact scientific research if further advanced. 35 | By scaling reasoning with reinforcement learning that rewards correct final answers, LLMs have improved from poor performance to saturating quantitative reasoning competitions like AIME and HMMT in one year. 36 | However, this approach faces fundamental limitations. 37 | Pursuing higher final answer accuracy doesn't address a key issue: correct answers don't guarantee correct reasoning. 38 | Moreover, many mathematical tasks like theorem proving require rigorous step-by-step derivation rather than numerical answers, making final answer rewards inapplicable. 39 | To push the limits of deep reasoning, we believe it is necessary to verify the comprehensiveness and rigor of mathematical reasoning. 40 | Self-verification is particularly important for scaling test-time compute, especially for open problems without known solutions. 41 | Towards self-verifiable mathematical reasoning, we investigate how to train an accurate and faithful LLM-based verifier for theorem proving. 42 | We then train a proof generator using the verifier as the reward model, and incentivize the generator to identify and resolve as many issues as possible in their own proofs before finalizing them. 43 | To maintain the generation-verification gap as the generator becomes stronger, we propose to scale verification compute to automatically label new hard-to-verify proofs, creating training data to further improve the verifier. 44 | Our resulting model, DeepSeekMath-V2, demonstrates strong theorem-proving capabilities, achieving gold-level scores on IMO 2025 and CMO 2024 and a near-perfect 118/120 on Putnam 2024 with scaled test-time compute. 45 | While much work remains, these results suggest that self-verifiable mathematical reasoning is a feasible research direction that may help develop more capable mathematical AI systems. 46 | 47 | ## 2. Evaluation Results 48 | 49 | Below are evaluation results on [IMO-ProofBench](https://github.com/google-deepmind/superhuman/tree/main/imobench) (developed by the DeepMind team behind DeepThink IMO-Gold) and recent mathematics competitions including IMO 2025, CMO 2024, and Putnam 2024. 50 | Model predictions are available in the `outputs` folder. 51 | 52 | **IMO-ProofBench** 53 | 54 |

55 | 56 |

57 | 58 | 59 | --- 60 | 61 | **Mathematics Competitions** 62 | 63 |

64 | 65 |

66 | 67 | ## 4. Download & Quick Start 68 | 69 | DeepSeekMath-V2 is built on top of DeepSeek-V3.2-Exp-Base, which can be downloaded from [🤗 HuggingFace](https://huggingface.co/deepseek-ai/DeepSeek-Math-V2). 70 | For inference support, please refer to [the DeepSeek-V3.2-Exp github repository](https://github.com/deepseek-ai/DeepSeek-V3.2-Exp). 71 | 72 | ## 6. License 73 | The use of DeepSeekMath-V2 models is subject to [the Model License](LICENSE). 74 | 75 | ## 7. Citation 76 | 77 | ``` 78 | @misc{deepseek-math-v2, 79 | author = {Zhihong Shao, Yuxiang Luo, Chengda Lu, Z.Z. Ren, Jiewen Hu, Tian Ye, Zhibin Gou, Shirong Ma, Xiaokang Zhang}, 80 | title = {DeepSeekMath-V2: Towards Self-Verifiable Mathematical Reasoning}, 81 | year = {2025}, 82 | } 83 | ``` 84 | 85 | ## 8. Contact 86 | 87 | If you have any questions, please raise an issue or contact us at [service@deepseek.com](mailto:service@deepseek.com). 88 | -------------------------------------------------------------------------------- /inputs/Putnam2024.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": 1, 4 | "question": "Determine all positive integers $n$ for which there exist positive integers $a$, $b$, and $c$ satisfying\n\\[\n2a^n + 3b^n = 4c^n.\n\\]", 5 | "answer": "The answer is $n=1$. When $n=1$, $(a,b,c) = (1,2,2)$ is a solution to the given equation. We claim that there are no solutions when $n \\geq 2$.", 6 | "contest": "Putnam2024", 7 | "problem_idx": "Putnam2024-A1" 8 | }, 9 | { 10 | "id": 2, 11 | "question": "For which real polynomials $p$ is there a real polynomial $q$ such that\n\\[\np(p(x)) - x = (p(x) - x)^2 q(x)\n\\]\nfor all real $x$?", 12 | "answer": "The answer is $p(x) = \\pm x+c$ for any $c \\in \\mathbb{R}$", 13 | "contest": "Putnam2024", 14 | "problem_idx": "Putnam2024-A2" 15 | }, 16 | { 17 | "id": 3, 18 | "question": "Let $S$ be the set of bijections\n\\[\nT \\colon \\{1,2,3\\} \\times \\{1,2,\\dots,2024\\} \\to \\{1,2,\\dots,6072\\}\n\\]\nsuch that $T(1,j) < T(2,j) < T(3,j)$ for all $j \\in \\{1,2,\\dots,2024\\}$ and $T(i,j) < T(i,j+1)$ for all $i \\in \\{1,2,3\\}$ and $j \\in \\{1,2,\\dots,2023\\}$. Do there exist $a$ and $c$ in $\\{1,2,3\\}$ and $b$ and $d$ in $\\{1,2,\\dots,2024\\}$ such that the fraction of elements $T$ in $S$ for which $T(a,b) < T(c,d)$ is at least $1/3$ and at most $2/3$?", 19 | "answer": "yes", 20 | "contest": "Putnam2024", 21 | "problem_idx": "Putnam2024-A3" 22 | }, 23 | { 24 | "id": 4, 25 | "question": "Find all primes $p > 5$ for which there exists an integer $a$ and an integer $r$ satisfying $1 \\leq r \\leq p-1$ with the following property: the sequence $1,a,a^2,\\dots,a^{p-5}$ can be rearranged to form a sequence $b_0,b_1,b_2,\\dots,b_{p-5}$ such that $b_n-b_{n-1}-r$ is divisible by $p$ for $1 \\leq n \\leq p-5$.", 26 | "answer": "7", 27 | "contest": "Putnam2024", 28 | "problem_idx": "Putnam2024-A4" 29 | }, 30 | { 31 | "id": 5, 32 | "question": "Consider a circle $\\Omega$ with radius 9 and center at the origin $(0,0)$, and a disc $\\Delta$ with radius 1 and center at $(r,0)$, where $0 \\leq r \\leq 8$. Two points $P$ and $Q$ are chosen independently and uniformly at random on $\\Omega$. Which value(s) of $r$ minimize the probability that the chord $\\overline{PQ}$ intersects $\\Delta$?", 33 | "answer": "We will show that $r=0$ (and no other value of $r$) minimizes the stated probability.", 34 | "contest": "Putnam2024", 35 | "problem_idx": "Putnam2024-A5" 36 | }, 37 | { 38 | "id": 6, 39 | "question": "Let $c_0,c_1,c_2,\\dots$ be the sequence defined so that \n\\[\n\\frac{1-3x-\\sqrt{1-14x+9x^2}}{4} = \\sum_{k=0}^\\infty c_k x^k\n\\]\nfor sufficiently small $x$. For a positive integer $n$, let $A$ be the $n$-by-$n$ matrix with $i,j$-entry $c_{i+j-1}$ for $i$ and $j$ in $\\{1,\\dots,n\\}$. Find the determinant of $A$.", 40 | "answer": "The determinant equals $10^{n(n-1)/2}$.", 41 | "contest": "Putnam2024", 42 | "problem_idx": "Putnam2024-A6" 43 | }, 44 | { 45 | "id": 7, 46 | "question": "Let $n$ and $k$ be positive integers. The square in the $i$th row and $j$th column of an $n$-by-$n$ grid contains the number $i+j-k$. For which $n$ and $k$ is it possible to select $n$ squares from the grid, no two in the same row or column, such that the numbers contained in the selected squares are exactly $1,2,\\dots,n$?", 47 | "answer": "This is possible if and only if $n$ is odd and $k = (n+1)/2$.", 48 | "contest": "Putnam2024", 49 | "problem_idx": "Putnam2024-B1" 50 | }, 51 | { 52 | "id": 8, 53 | "question": "Two convex quadrilaterals are called \\emph{partners} if they have three vertices in common and they can be labeled $ABCD$ and $ABCE$ so that $E$ is the reflection of $D$ across the perpendicular bisector of the diagonal $\\overline{AC}$. Is there an infinite sequence of convex quadrilaterals such that each quadrilateral is a partner of its successor and no two elements of the sequence are congruent?\n[A diagram has been omitted.]", 54 | "answer": "no", 55 | "contest": "Putnam2024", 56 | "problem_idx": "Putnam2024-B2" 57 | }, 58 | { 59 | "id": 9, 60 | "question": "Let $r_n$ be the $n$th smallest positive solution to $\\tan x = x$, where the argument of tangent is in radians. Prove that\n\\[\n0 < r_{n+1} - r_n - \\pi < \\frac{1}{(n^2+n)\\pi}\n\\]\nfor $n \\geq 1$.", 61 | "answer": "null", 62 | "contest": "Putnam2024", 63 | "problem_idx": "Putnam2024-B3" 64 | }, 65 | { 66 | "id": 10, 67 | "question": "Let $n$ be a positive integer. Set $a_{n,0} = 1$. For $k \\geq 0$, choose an integer $m_{n,k}$ uniformly at random from the set $\\{1,\\dots,n\\}$, and let\n\\[\na_{n,k+1} = \\begin{cases} a_{n,k} + 1, & \\mbox{if $m_{n,k} > a_{n,k};$} \\\na_{n,k}, & \\mbox{if $m_{n,k} = a_{n,k}$;} \\\na_{n,k}-1, & \\mbox{if $m_{n,k} < a_{n,k}$.}\n\\end{cases}\n\\]\nLet $E(n)$ be the expected value of $a_{n,n}$. Determine $\\lim_{n\\to \\infty} E(n)/n$.", 68 | "answer": "The limit equals $\\frac{1-e^{-2}}{2}$.", 69 | "contest": "Putnam2024", 70 | "problem_idx": "Putnam2024-B4" 71 | }, 72 | { 73 | "id": 11, 74 | "question": "Let $k$ and $m$ be positive integers. For a positive integer $n$, let $f(n)$ be the number of integer sequences $x_1,\\dots,x_k,y_1,\\dots,y_m,z$ satisfying $1 \\leq x_1 \\leq \\cdots \\leq x_k \\leq z \\leq n$ and $1 \\leq y_1 \\leq \\cdots \\leq y_m \\leq z \\leq n$. Show that $f(n)$ can be expressed as a polynomial in $n$ with nonnegative coefficients.", 75 | "answer": "null", 76 | "contest": "Putnam2024", 77 | "problem_idx": "Putnam2024-B5" 78 | }, 79 | { 80 | "id": 12, 81 | "question": "For a real number $a$, let $F_a(x) = \\sum_{n \\geq 1} n^a e^{2n} x^{n^2}$ for $0 \\leq x < 1$.\nFind a real number $c$ such that\n\\begin{align*}\n& \\lim_{x \\to 1^-} F_a(x) e^{-1/(1-x)} = 0 \\qquad \\mbox{for all $a < c$, and} \\\n& \\lim_{x \\to 1^-} F_a(x) e^{-1/(1-x)} = \\infty \\qquad \\mbox{for all $a > c$.}\n\\end{align*}", 82 | "answer": "The claim holds with $c=-\\frac{1}{2}$.", 83 | "contest": "Putnam2024", 84 | "problem_idx": "Putnam2024-B6" 85 | } 86 | ] -------------------------------------------------------------------------------- /inference/generate.py: -------------------------------------------------------------------------------- 1 | import os 2 | import json 3 | import pickle 4 | import math 5 | import argparse 6 | import asyncio 7 | import aiohttp 8 | 9 | from tqdm import tqdm 10 | from multiprocessing import Queue, Process 11 | from time import time, sleep 12 | 13 | from openai import AsyncOpenAI 14 | 15 | class APIModel: 16 | def __init__(self): 17 | self.client = AsyncOpenAI( 18 | api_key="xxx", 19 | timeout=300000, 20 | base_url="yyy" 21 | ) 22 | 23 | async def generate_one(self, prompt, sampling_params): 24 | res = await self.client.chat.completions.create( 25 | messages=prompt, 26 | stream=False, 27 | **sampling_params 28 | ) 29 | reasoning_content = res.choices[0].message.reasoning_content.strip() 30 | content = res.choices[0].message.content.strip() 31 | output_string = f"\n{reasoning_content}" 32 | if content: 33 | output_string = reasoning_content + f"\n\n{content}" 34 | finish_reason = res.choices[0].finish_reason 35 | return output_string, finish_reason 36 | 37 | async def generate_all(self, data): 38 | tasks = [self.generate_one(task['prompt'], task['sampling_params']) for i, task in enumerate(data)] 39 | results = await asyncio.gather(*tasks) 40 | return results 41 | 42 | def generate(self, input_data, sampling_params): 43 | data = [] 44 | for item in input_data: 45 | if "messages" not in item: 46 | messages = [{ 47 | "role": "user", 48 | "content": item["prompt"], 49 | }] 50 | else: 51 | messages = item['messages'] 52 | data.append({ 53 | 'prompt': messages, 54 | 'sampling_params': sampling_params 55 | }) 56 | 57 | outputs = asyncio.run(self.generate_all(data)) 58 | output_data = [] 59 | assert len(input_data) == len(outputs) 60 | for item, (output_string, finish_reason) in zip(input_data, outputs): 61 | output_data.append({ 62 | **item, 63 | "output": output_string, 64 | "finish_reason": finish_reason.lower(), 65 | }) 66 | return output_data 67 | 68 | def mp_generate(self, input_queue: Queue, output_queue: Queue, sampling_params): 69 | while True: 70 | batch_idx, input_data = input_queue.get() 71 | if input_data is None: 72 | output_queue.put((batch_idx, None)) 73 | break 74 | output_data = self.generate(input_data, sampling_params) 75 | output_queue.put((batch_idx, output_data)) 76 | 77 | 78 | def mp_generate_loop(input_queue, output_queue, sampling_params): 79 | api_model = APIModel() 80 | sleep(5) 81 | api_model.mp_generate(input_queue, output_queue, sampling_params) 82 | 83 | if __name__ == "__main__": 84 | parser = argparse.ArgumentParser() 85 | parser.add_argument("--input_data_path", required=True) 86 | parser.add_argument("--output_data_path", required=True) 87 | parser.add_argument("--num_processes", default=16, type=int) 88 | parser.add_argument("--batch_size", default=16, type=int) 89 | parser.add_argument("--temperature", required=True, type=float) 90 | parser.add_argument("--top_p", required=True, type=float) 91 | parser.add_argument("--max_tokens", required=True, type=int) 92 | parser.add_argument("--n", required=True, type=int) 93 | args, _ = parser.parse_known_args() 94 | input_data_path, output_data_path = args.input_data_path, args.output_data_path 95 | os.makedirs(os.path.dirname(output_data_path), exist_ok=True) 96 | 97 | num_processes = args.num_processes 98 | batch_size = args.batch_size 99 | temperature = args.temperature 100 | top_p = args.top_p 101 | max_tokens = args.max_tokens 102 | n = args.n 103 | 104 | meta_data_path = f"{output_data_path}.meta" 105 | if not os.path.exists(meta_data_path): 106 | meta_data = {"n": n, "batch_size": batch_size, "complete_batches": []} 107 | with open(meta_data_path, "wb") as f: 108 | pickle.dump(meta_data, f) 109 | with open(meta_data_path, "rb") as f: 110 | meta_data = pickle.load(f) 111 | meta_data["complete_batches"] = set(meta_data["complete_batches"]) 112 | 113 | assert n == meta_data["n"] and batch_size == meta_data["batch_size"], \ 114 | f"params n or batch_size are different from previous running setting({n}, {batch_size}) != ({meta_data['n']}, {meta_data['batch_size']}), you need to delete {output_data_path} & {meta_data_path} to clear existing results" 115 | 116 | sampling_params = dict( 117 | temperature=temperature, 118 | top_p=top_p, 119 | max_tokens=max_tokens, 120 | max_total_tokens=max_tokens 121 | ) 122 | 123 | input_queue, output_queue = Queue(), Queue() 124 | fr = open(input_data_path, "r", encoding="utf-8") 125 | fw = open(output_data_path, "a+", encoding="utf-8") 126 | 127 | processes = [] 128 | 129 | for i in range(num_processes): 130 | process = Process(target=mp_generate_loop, args=(input_queue, output_queue, sampling_params)) 131 | process.start() 132 | processes.append(process) 133 | 134 | submit_batch = [] 135 | num_input = 0 136 | num_skip = 0 137 | batch_idx = 0 138 | 139 | for line in tqdm(fr, desc="Waiting Input"): 140 | item = json.loads(line) 141 | for i in range(n): 142 | submit_batch.append(item) 143 | if len(submit_batch) >= batch_size: 144 | if batch_idx not in meta_data["complete_batches"]: 145 | num_input += batch_size 146 | input_queue.put((batch_idx, submit_batch)) 147 | else: 148 | num_skip += batch_size 149 | batch_idx += 1 150 | submit_batch = [] 151 | if len(submit_batch) > 0: 152 | if batch_idx not in meta_data["complete_batches"]: 153 | input_queue.put((batch_idx, submit_batch)) 154 | num_input += len(submit_batch) 155 | else: 156 | num_skip += len(submit_batch) 157 | print(f"Total Input Samples: {num_input} (Skip {num_skip} Samples)") 158 | fr.close() 159 | 160 | for i in range(num_processes): 161 | input_queue.put((None, None)) 162 | 163 | remain_processes = num_processes 164 | num_output = 0 165 | with tqdm(desc="Waiting Output", total=num_input) as pbar: 166 | while remain_processes > 0: 167 | batch_idx, output_data = output_queue.get() 168 | if output_data is None: 169 | remain_processes -= 1 170 | continue 171 | for item in output_data: 172 | print(json.dumps(item, ensure_ascii=False), file=fw, flush=True) 173 | num_output += 1 174 | pbar.update(1) 175 | meta_data["complete_batches"].add(batch_idx) 176 | with open(meta_data_path, "wb") as f: 177 | pickle.dump(meta_data, f) 178 | fw.flush() 179 | print(f"Total Output Samples: {num_output}") 180 | fw.close() 181 | [process.join() for process in processes] 182 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright (c) 2023 DeepSeek 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. -------------------------------------------------------------------------------- /inference/math_templates.py: -------------------------------------------------------------------------------- 1 | math_templates = { 2 | "proof_verification": """ 3 | ## Instruction 4 | 5 | Your task is to evaluate the quality of a solution to a problem. The problem may ask for a proof of statement, or ask for an answer. If finding an answer is required, the solution should present the answer, and it should also be a rigorous proof of that answer being valid. 6 | 7 | Please evaluate the solution and score it according to the following criteria: 8 | - If the solution is completely correct, with all steps executed properly and clearly demonstrated, then the score is 1 9 | - If the solution is generally correct, but with some details omitted or minor errors, then the score is 0.5 10 | - If the solution does not actually address the required problem, contains fatal errors, or has severe omissions, then the score is 0 11 | - Additionally, referencing anything from any paper does not save the need to prove the reference. It's okay IF AND ONLY IF the solution also presents a valid proof of the reference argument(s); otherwise, if the solution omits the proof or if the proof provided is not completely correct, the solution should be scored according to the criteria above, and definitely not with a score of 1 12 | 13 | Please carefully reason out and analyze the quality of the solution below, and in your final response present a detailed evaluation of the solution's quality followed by your score. Therefore, your response should be in the following format: 14 | 15 | Here is my evaluation of the solution: 16 | ... // Your evaluation here. You are required to present in detail the key steps of the solution or the steps for which you had doubts regarding their correctness, and explicitly analyze whether each step is accurate: for correct steps, explain why you initially doubted their correctness and why they are indeed correct; for erroneous steps, explain the reason for the error and the impact of that error on the solution. 17 | 18 | Based on my evaluation, the final overal score should be: 19 | \\boxed{{...}} // where ... should be the final overall score (0, 0.5, or 1, and nothing else) based on the above criteria 20 | 21 | --- 22 | 23 | Here is your task input: 24 | 25 | ## Problem 26 | {statement} 27 | 28 | ## Solution 29 | {proof} 30 | """.strip(), 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | "meta_verification": """ 47 | You are given a "problem", "solution", and "solution evaluation", and you need to assess the whether this "solution evaluation" is reasonable. 48 | 49 | First, "solution evaluation" is generated to evaluate the quality of the "solution", by prompting a verifier with the rules below (these are not your rules): 50 | 51 | ``` 52 | Please evaluate the solution and score it according to the following criteria: 53 | - If the solution is completely correct, with all steps executed properly and clearly demonstrated, then the score is 1 54 | - If the solution is generally correct, but with some details omitted or minor errors, then the score is 0.5 55 | - If the solution does not actually address the required problem, contains fatal errors, or has severe omissions, then the score is 0 56 | 57 | Additionally, referencing anything from any paper does not save the need to prove the reference. It's okay IF AND ONLY IF the solution also presents a valid proof of the reference argument(s); otherwise, if the solution omits the proof or if the proof provided is not completely correct, the solution should be scored according to the criteria above, and definitely not with a score of 1 58 | ``` 59 | 60 | Next, I will introduce the rules for you to analyze the quality of the "solution evaluation": 61 | 62 | 1. Your task is to analyze the "solution evaluation". You do not need to solve the "problem", nor do you need to strictly assess whether the "solution" is accurate. Your only task is to strictly follow the rules below to evaluate whether the "solution evaluation" is reasonable. 63 | 64 | 2. You need to analyze the content of the "solution evaluation" from three aspects: 65 | 66 | Step Restatement: In the "solution evaluation", certain behaviors of the "solution" may be restated. You need to return to the original text of the "solution" and check whether the "solution" actually has these behaviors mentioned in the "solution evaluation". 67 | 68 | Defect Analysis: "solution evaluation" may point out errors or defects in the "solution". You need to carefully analyze whether the mentioned errors and defects are indeed valid. 69 | 70 | Expression Analysis: Whether the "solution evaluation"'s expressions are accurate. 71 | 72 | Score Analysis: Whether the final score given by the "solution evaluation" matches the defects it found. You need to analyze according to the scoring rules given above. 73 | 74 | 3. The most important part is **defect analysis**: In this part, your core task is to check whether the errors or defects of the "solution" pointed out in the "solution evaluation" are reasonable. In other words, any positive components about the "solution" in the "solution evaluation", regardless of whether they are reasonable, are not within your evaluation scope. 75 | 76 | - For example: If the "solution evaluation" says that a certain conclusion in the "solution" is correct, but actually this conclusion is incorrect, then you do not need to care about this point. All parts that the "solution evaluation" considers correct do not belong to your evaluation scope. 77 | - Specifically: If the "solution evaluation" believes that the "solution" is completely accurate and has not found any errors or defects, then regardless of whether the "solution" itself is actually accurate, even if there are obvious errors, you should still consider its analysis of errors to be reasonable. 78 | 79 | **Importantly**, for defects found by the "solution evaluation", you need to analyze two points simultaneously: 80 | 81 | - whether this defect actually exists 82 | - whether the "solution evaluation"'s analysis of this defect is accurate 83 | 84 | These two aspects constitute the analysis of defects. 85 | 86 | 4. About **expression analysis**, if there are certain expression errors in the "solution evaluation", even minor errors in details, you need to identify them. However, please note that identifying incorrect steps in the "solution" as correct steps does not constitute an **expression error**. 87 | 88 | In practice, expression errors include but are not limited to: 89 | 90 | - If the "solution evaluation" identifies some reasoning step(s) in the "solution" as incorrect, then it cannot further indicate that subsequent conclusion(s) depending on those reasoning step(s) are wrong, but can only indicate that subsequent conclusion(s) are "not rigorously demonstrated." 91 | - Typos and calculation errors made by "solution evaluation" 92 | - Inaccurate restatement of content from "solution" 93 | 94 | 5. Finally, you need to present your analysis of the "solution evaluation" in your output and also rate its quality based on the rules below: 95 | 96 | First, if there is at least one unreasonable defect among the defects found by the "solution evaluation", then you only need to do **defect analysis**: 97 | 98 | - If all defects found by the "solution evaluation" are unreasonable, then you should rate it with \(0\) 99 | - If some defects found by the "solution evaluation" are reasonable and some are unreasonable, then your rating should be \(0.5\) 100 | 101 | Next, if the "solution evaluation" points out no errors or defects, or all defects found by the evaluation are reasonable, then you should do the following things: 102 | 103 | - Analyze whether "expression errors" exist in the "solution evaluation" (**expression analysis**) or whether "solution evaluation" gives a wrong score according to the rules for "solution evaluation" (**score analysis**). If yes, you should rate the "solution evaluation" with \(0.5\); if no, your rating should be \(1\) 104 | 105 | Your output should follow the format below: 106 | 107 | Here is my analysis of the "solution evaluation": 108 | ... // Your analysis here. 109 | 110 | Based on my analysis, I will rate the "solution evaluation" as: 111 | \\boxed{{...}} // where ... should be a numerical rating of the "solution evaluation" (0, 0.5, or 1, and nothing else) based on the criteria above. 112 | 113 | --- 114 | 115 | Here is your task input: 116 | 117 | ## Problem 118 | {statement} 119 | 120 | ## Solution 121 | {proof} 122 | 123 | ## Solution Evaluation 124 | {rating} 125 | """.strip(), 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | "proof_generation": """ 143 | Your task is to solve a given problem. The problem may ask you to prove a statement, or ask for an answer. If finding an answer is required, you should come up with the answer, and your final solution should also be a rigorous proof of that answer being valid. 144 | 145 | Your final solution to the problem should be exceptionally comprehensive and easy-to-follow, which will be rated according to the following evaluation instruction: 146 | 147 | ```txt 148 | Here is the instruction to evaluate the quality of a solution to a problem. The problem may ask for a proof of statement, or ask for an answer. If finding an answer is required, the solution should present the answer, and it should also be a rigorous proof of that answer being valid. 149 | 150 | Please evaluate the solution and score it according to the following criteria: 151 | - If the solution is completely correct, with all steps executed properly and clearly demonstrated, then the score is 1 152 | - If the solution is generally correct, but with some details omitted or minor errors, then the score is 0.5 153 | - If the solution does not actually address the required problem, contains fatal errors, or has severe omissions, then the score is 0 154 | 155 | Additionally, referencing anything from any paper does not save the need to prove the reference. It's okay IF AND ONLY IF the solution also presents a valid proof of the reference argument(s); otherwise, if the solution omits the proof or if the proof provided is not completely correct, the solution should be scored according to the criteria above, and definitely not with a score of 1 156 | ``` 157 | 158 | In fact, you already have the ability to rate your solution yourself, so you are expected to reason carefully about how to solve a given problem, evaluate your method according to the instruction, and refine your solution by fixing issues identified until you can make no further progress. 159 | 160 | In your final response, you should present a detailed solution to the problem followed by your evaluation of that solution. 161 | - To give a good final response, you should try your best to locate potential issues in your own (partial) solution according to the evaluation instruction above, and fix them as many as you can. 162 | - A good final response should just faithfully present your progress, including the best solution you can give, as well as a faithful evaluation of that solution. 163 | - Only when you fail to locate any issues in your solution should you score it with 1. 164 | - If you do notice some issues in your solution but fail to resolve them with your best efforts, it's totally ok to faithfully present the issues in your final response. 165 | - The worst final response would provide a wrong solution but lie that it's correct or claim that it's correct without careful error checking. A better version should faithfully identify errors in the solution. Remember! You CAN'T cheat! If you cheat, we will know, and you will be penalized! 166 | 167 | Your final response should be in the following format: 168 | 169 | ## Solution // Your final solution should start with this exact same markdown title 170 | ... // Your final solution to the problem here. You should try your best to optimize the quality of your solution according to the evaluation instruction above before finalizing it here. 171 | 172 | ## Self Evaluation // Your evaluation of your own solution above should start with this exact same markdown title 173 | 174 | Here is my evaluation of the solution: // Your analysis should start with this exact same phrase 175 | ... // Your evaluation here. You are required to present in detail the key steps of the solution or the steps for which you had doubts regarding their correctness, and explicitly analyze whether each step is accurate: for correct steps, explain why you initially doubted their correctness and why they are indeed correct; for erroneous steps, explain the reason for the error and the impact of that error on the solution. You should analyze your solution faithfully. E.g., if there are issues in your final solution, you should point it out. 176 | 177 | Based on my evaluation, the final overal score should be: 178 | \\boxed{{...}} // where ... should be the final overall score (0, 0.5, or 1, and nothing else) based on the evaluation instruction above. You should reach this score ONLY AFTER careful RE-examination of your own solution above 179 | 180 | --- 181 | 182 | Here is your task input: 183 | 184 | ## Problem 185 | {question} 186 | """.strip(), 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | "proof_refinement": """ 204 | {instruction} 205 | 206 | ## Candidate Solution(s) to Refine 207 | Here are some solution sample(s) along with their correctness evaluation(s). You should provide a better solution by solving issues mentioned in the evaluation(s), or by re-using promising ideas mentioned in the solution sample(s), or by doing both. 208 | 209 | {proofs_to_refine} 210 | 211 | ## Final Instruction 212 | Your final response should follow the format above, including a `## Solution` section followed by a `## Self Evaluation` section 213 | """.strip() 214 | } -------------------------------------------------------------------------------- /inference/main.py: -------------------------------------------------------------------------------- 1 | import json 2 | import orjson 3 | import os 4 | 5 | from math_templates import math_templates 6 | from utils import hash_problem_idx, read_data, extract_boxed_answers, extract_solution, extract_self_eval 7 | 8 | import itertools 9 | from copy import deepcopy 10 | from glob import glob 11 | import numpy as np 12 | from functools import partial 13 | import math 14 | from tqdm import tqdm 15 | import multiprocessing 16 | 17 | import argparse 18 | 19 | parser = argparse.ArgumentParser() 20 | parser.add_argument("--input_paths", required=True) 21 | parser.add_argument("--output_dirname", required=True, help="directory to dump results") 22 | parser.add_argument("--proof_pool_dirname", required=True, help="directory to maintain a pool of generated proofs for each evaluated problem") 23 | 24 | parser.add_argument("--batch_size", type=int, default=160) 25 | 26 | parser.add_argument("--proof_gen_num_processes", type=int, default=40) 27 | parser.add_argument("--proof_gen_temp", type=float, default=1.0) 28 | parser.add_argument("--proof_gen_max_len", type=int, default=128 * 1024) 29 | parser.add_argument("--proof_gen_template", type=str, default="proof_generation") 30 | parser.add_argument("--proof_refine_template", type=str, default="proof_refinement") 31 | parser.add_argument("--n_best_proofs_to_sample", type=int, default=32, help="the number of best proofs to consider for refinements") 32 | parser.add_argument("--n_proofs_to_refine", type=int, default=1, help="the number of proofs used as the input for a refinement") 33 | parser.add_argument("--n_agg_trials", type=int, default=32, help="the number of different combinations of proofs used for refinements") 34 | parser.add_argument("--n_parallel_proof_gen", type=int, default=128) 35 | 36 | 37 | parser.add_argument("--proof_verification_num_processes", type=int, default=320) 38 | parser.add_argument("--proof_verification_temp", type=float, default=1.0) 39 | parser.add_argument("--proof_verification_max_len", type=int, default=64 * 1024) 40 | parser.add_argument("--proof_verification_template", type=str, default="proof_verification") 41 | parser.add_argument("--n_verification_per_proof", type=int, default=4) 42 | 43 | 44 | parser.add_argument("--skip_meta_verification", action='store_true') 45 | parser.add_argument("--meta_verification_num_processes", type=int, default=320) 46 | parser.add_argument("--meta_verification_temp", type=float, default=1.0) 47 | parser.add_argument("--meta_verification_max_len", type=int, default=64 * 1024) 48 | parser.add_argument("--meta_verification_template", type=str, default="meta_verification") 49 | parser.add_argument("--n_meta_verification_per_rating", type=int, default=1) 50 | 51 | 52 | parser.add_argument("--start_round", type=int, default=1) 53 | parser.add_argument("--max_rounds", type=int, default=20) 54 | 55 | args, _ = parser.parse_known_args() 56 | 57 | input_paths = args.input_paths 58 | output_dirname = args.output_dirname 59 | proof_pool_dirname = args.proof_pool_dirname 60 | 61 | proof_gen_url = args.proof_gen_url 62 | proof_rate_url = args.proof_rate_url 63 | 64 | args.proof_gen_with_self_eval = args.proof_gen_template in ['proof_generation'] 65 | 66 | def prepare_proof_verification(path, tar_path): 67 | print(f"Proof Verification >>>\ninput path = {path}\noutput_path = {tar_path}", flush=True) 68 | items = read_data(path) 69 | data = [] 70 | for item in items: 71 | item['proof_finish_reason'] = item.pop('finish_reason').lower() 72 | statement = item['question'].strip() 73 | prover_output = item['output'].strip() 74 | if item['proof_finish_reason'] == 'stop': 75 | assert '' in prover_output 76 | proof = prover_output.split("")[-1].strip() 77 | else: 78 | continue 79 | item['prover_output'] = prover_output 80 | 81 | self_eval = 'null' 82 | self_eval_score = 0 83 | if item['proof_finish_reason'] == 'stop' and args.proof_gen_with_self_eval: 84 | try: 85 | self_eval = extract_self_eval(proof).strip() 86 | proof = extract_solution(proof).strip() 87 | try: 88 | self_eval_score = float([s.strip() for s in extract_boxed_answers(self_eval) if s.strip()][-1]) 89 | except: 90 | self_eval_score = 0 91 | except: 92 | continue 93 | 94 | item['self_eval'] = self_eval 95 | item['self_eval_score'] = self_eval_score 96 | 97 | item['proof'] = proof 98 | 99 | question = math_templates[args.proof_verification_template].format( 100 | statement=statement.strip(), 101 | proof=proof.strip() 102 | ) 103 | item.update({ 104 | 'messages': [ 105 | {'role': 'user', 'content': question}, 106 | ] 107 | }) 108 | for key in ['finished', 'finish_reason', 'input', 'output']: 109 | if key in item: 110 | item.pop(key) 111 | data.append(item) 112 | os.makedirs(os.path.dirname(tar_path), exist_ok=True) 113 | with open(tar_path, "w") as file: 114 | for item in data: 115 | print(json.dumps(item), file=file, flush=True) 116 | return len(data) 117 | 118 | def prepare_meta_verification(path, tar_path, drop_thought=True): 119 | print(f"Meta Verification >>>\ninput path = {path}\noutput_path = {tar_path}", flush=True) 120 | items = read_data(path) 121 | data = [] 122 | for item in items: 123 | problem = item['question'].strip() 124 | if item['finish_reason'] == 'stop' and '' in item['output']: 125 | rating = item['output'].strip() 126 | if drop_thought and '' in rating: 127 | rating = rating.split("")[-1].strip() 128 | scores = [s.strip() for s in extract_boxed_answers(rating) if s.strip()] 129 | try: 130 | score = float(scores[-1]) 131 | except: 132 | continue 133 | if score > 0.75: 134 | continue 135 | inp = math_templates[args.meta_verification_template].format( 136 | statement=problem.strip(), 137 | proof=item['proof'].strip(), 138 | rating=rating.strip() 139 | ) 140 | item.update({ 141 | 'messages': [ 142 | {'role': 'user', 'content': inp} 143 | ], 144 | 'rating': rating 145 | }) 146 | for key in ['finished', 'finish_reason', 'input', 'output']: 147 | if key in item: 148 | item.pop(key) 149 | data.append(item) 150 | os.makedirs(os.path.dirname(tar_path), exist_ok=True) 151 | with open(tar_path, "w") as file: 152 | for item in data: 153 | print(json.dumps(item), file=file, flush=True) 154 | return len(data) 155 | 156 | def _split_jobs(jobs, nsplit): 157 | if len(jobs) < nsplit: 158 | return [jobs] 159 | res = [] 160 | sz = math.ceil(len(jobs) / nsplit) 161 | for i in range(0, len(jobs), sz): 162 | res.append(jobs[i: i + sz]) 163 | return res 164 | 165 | def _prepare_proof_agg_tasks(tasks, round_idx=None, proof_pool_dirname=None, use_old_proofs_for_refinement=False, num_trials=16, n_best_proofs_to_sample=6, n_proofs_to_refine=4, max_rating_per_score=4): 166 | data = [] 167 | trials = [] 168 | print(f"tasks = {len(tasks[0])}", flush=True) 169 | for (item, proof2ratings, proof2self_eval, proof2dep_proof_ids) in tasks: 170 | source_name = item.get('source_name', 'temp_source_name') 171 | if 'problem_idx' in item: 172 | problem_idx = str(item['problem_idx']) 173 | else: 174 | problem_idx = hash_problem_idx(item['question'].strip()) 175 | problem = item['question'] 176 | old_proof_pool = [] 177 | proof_dedup = set() 178 | proof_id_dedup = set() 179 | proof_pool_path = f"{proof_pool_dirname}/{source_name}/{problem_idx}.jsonl" 180 | if os.path.exists(proof_pool_path): 181 | with open(proof_pool_path, "r") as file: 182 | for line in file: 183 | record = json.loads(line) 184 | assert (problem_idx, record['proof']) not in proof_dedup 185 | assert record.get('proof_id', 'null') not in proof_id_dedup 186 | old_proof_pool.append( 187 | (record['proof'], record['meanscore'], record['score2ratings'], record['self_eval'], record.get('proof_id', 'null')) 188 | ) 189 | proof_dedup.add((problem_idx, record['proof'])) 190 | proof_id_dedup.add(record.get('proof_id', 'null')) 191 | if proof_id_dedup: 192 | nxt_proof_id = max(proof_id_dedup) + 1 193 | else: 194 | nxt_proof_id = 1 195 | proof_meanscore_ratings_tuples = [] 196 | for proof, ratings in proof2ratings.items(): 197 | if (problem_idx, proof) in proof_dedup: 198 | continue 199 | meanscore = float(np.mean([rating['score'] for rating in ratings])) 200 | score2ratings = {} 201 | for rating in ratings: 202 | score = rating['score'] 203 | if score not in score2ratings: 204 | score2ratings[score] = [] 205 | score2ratings[score].append(rating) 206 | proof_dedup.add((problem_idx, proof)) 207 | proof_id = nxt_proof_id 208 | nxt_proof_id += 1 209 | record = (proof, meanscore, score2ratings, proof2self_eval[proof], proof_id, proof2dep_proof_ids[proof]) 210 | proof_meanscore_ratings_tuples.append(record) 211 | os.makedirs(os.path.dirname(proof_pool_path), exist_ok=True) 212 | with open(proof_pool_path, "a") as file: 213 | for record in proof_meanscore_ratings_tuples: 214 | record = dict(zip(['proof', 'meanscore', 'score2ratings', 'self_eval', 'proof_id', 'dep_proof_ids'], record)) 215 | record['round_idx'] = round_idx 216 | for _id in record['dep_proof_ids']: 217 | assert _id in proof_id_dedup or float(_id) < 0, f"{_id} {len(proof_id_dedup)} {proof_pool_path}" 218 | print(json.dumps(record), file=file, flush=True) 219 | if use_old_proofs_for_refinement: 220 | proof_meanscore_ratings_tuples += old_proof_pool 221 | 222 | if any(record[1] > 0.99999 for record in proof_meanscore_ratings_tuples): 223 | continue 224 | 225 | for _ in range(10): 226 | np.random.shuffle(proof_meanscore_ratings_tuples) 227 | proof_meanscore_ratings_tuples = sorted(proof_meanscore_ratings_tuples, key=lambda x: (x[1], x[3]['self_eval_score']), reverse=True)[:n_best_proofs_to_sample] 228 | combinations = [list(range(min(n_proofs_to_refine, len(proof_meanscore_ratings_tuples))))] + \ 229 | list(itertools.combinations(list(range(min(n_best_proofs_to_sample, len(proof_meanscore_ratings_tuples)))), min(n_proofs_to_refine, len(proof_meanscore_ratings_tuples)))) 230 | if not proof_meanscore_ratings_tuples: 231 | combinations = [] 232 | dedup = set() 233 | for i, indices in enumerate(combinations): 234 | if len(dedup) == num_trials: 235 | break 236 | indices = list(indices) 237 | if i > 0: 238 | np.random.shuffle(indices) 239 | for num_proofs_to_include in range(n_proofs_to_refine, 0, -1): 240 | if tuple(sorted(indices[:num_proofs_to_include])) in dedup: 241 | break 242 | summary = [] 243 | dep_proof_ids = [] 244 | for idx in indices[:num_proofs_to_include]: 245 | proof, meanscore, score2ratings, self_eval, proof_id = proof_meanscore_ratings_tuples[idx][:5] 246 | dep_proof_ids.append(proof_id) 247 | score2ratings = {float(key): val for key, val in score2ratings.items()} 248 | scores = sorted(list(score2ratings.keys())) 249 | if len(scores) == 1: 250 | max_rating = 8 251 | else: 252 | max_rating = max_rating_per_score 253 | ratings = [] 254 | for score in scores: 255 | assert isinstance(score, float), score 256 | np.random.shuffle(score2ratings[score]) 257 | for rating in score2ratings[score][:max_rating]: 258 | rating = rating['rating'] 259 | ratings.append(f"=== Evaluation {len(ratings)} of Solution {len(summary)} ===\n{rating}") 260 | if len(ratings) == 8: 261 | break 262 | ratings = "\n\n".join(ratings) 263 | summary.append(f"--- Solution {len(summary)} ---\n{proof}\n\n{ratings}") 264 | summary = "\n\n\n".join(summary) 265 | msg = [ 266 | { 267 | 'role': 'user', 268 | 'content': math_templates[args.proof_refine_template].format( 269 | instruction=math_templates[args.proof_gen_template].format(question=problem.strip()).strip(), 270 | proofs_to_refine=summary.strip() 271 | ) 272 | } 273 | ] 274 | dedup.add(tuple(sorted(indices[:num_proofs_to_include]))) 275 | sample = deepcopy(item) 276 | sample.update({ 277 | 'messages': msg, 278 | 'dep_proof_ids': dep_proof_ids 279 | }) 280 | data.append(sample) 281 | break 282 | 283 | trials.append(len(dedup)) 284 | return data, trials 285 | 286 | def prepare_proof_refinement( 287 | path, meta_verification_path, tar_path, round_idx, 288 | proof_pool_dirname=None, use_old_proofs_for_refinement=False, num_trials=16, n_best_proofs_to_sample=6, n_proofs_to_refine=4, max_rating_per_score=4, drop_thought=True 289 | ): 290 | print(f"Proof refinement >>>\ninput path = {path}\noutput_path = {tar_path}\nproof_pool_dirname = {proof_pool_dirname}", flush=True) 291 | 292 | problem2item = {} 293 | problem2proof2ratings = {} 294 | problem2proof2self_eval = {} 295 | problem2proof2dep_proof_ids = {} 296 | 297 | rating2quality = {} 298 | if os.path.exists(meta_verification_path): 299 | with open(meta_verification_path, "r") as file: 300 | for line in tqdm(file, desc='reading meta verification outputs'): 301 | item = orjson.loads(line) 302 | rating = item['rating'].strip() 303 | if item['finish_reason'] == 'stop' and '' in item['output']: 304 | quality = item['output'].strip() 305 | if drop_thought and '' in quality: 306 | quality = quality.split("")[-1].strip() 307 | scores = [s.strip() for s in extract_boxed_answers(quality) if s.strip()] 308 | try: 309 | score = float(scores[-1]) 310 | except: 311 | continue 312 | if rating not in rating2quality: 313 | rating2quality[rating] = [] 314 | rating2quality[rating].append({ 315 | 'quality': quality, 316 | 'score': score 317 | }) 318 | 319 | with open(path, "r") as file: 320 | for line in tqdm(file, desc='reading proof verification outputs'): 321 | item = orjson.loads(line) 322 | problem = item['question'].strip() 323 | prover_output = item['proof'].strip() 324 | if drop_thought and '' in prover_output: 325 | prover_output = prover_output.split("")[-1].strip() 326 | if item['finish_reason'] == 'stop' and '' in item['output']: 327 | rating = item['output'].strip() 328 | if drop_thought and '' in rating: 329 | rating = rating.split("")[-1].strip() 330 | scores = [s.strip() for s in extract_boxed_answers(rating) if s.strip()] 331 | try: 332 | score = float(scores[-1]) 333 | except: 334 | continue 335 | if problem not in problem2proof2ratings: 336 | problem2proof2ratings[problem] = {} 337 | problem2proof2self_eval[problem] = {} 338 | problem2proof2dep_proof_ids[problem] = {} 339 | problem2item[problem] = {key: val for key, val in item.items() if key not in ['messages', 'output', 'input', 'finish_reason', 'meta', 'finished']} 340 | if prover_output not in problem2proof2ratings[problem]: 341 | problem2proof2ratings[problem][prover_output] = [] 342 | problem2proof2self_eval[problem][prover_output] = { 343 | 'self_eval': item.get('self_eval', 'null'), 344 | 'self_eval_score': item.get('self_eval_score', 0) 345 | } 346 | problem2proof2dep_proof_ids[problem][prover_output] = item.get('dep_proof_ids', []) 347 | problem2proof2ratings[problem][prover_output].append({ 348 | 'rating': rating, 349 | 'quality': rating2quality.get(rating, []), 350 | 'score': score 351 | }) 352 | 353 | print(f"Num statements loaded = {len(problem2proof2ratings)}", flush=True) 354 | 355 | problem_idx_dedup = set() 356 | tasks = [] 357 | for problem, proof2ratings in problem2proof2ratings.items(): 358 | item = problem2item[problem] 359 | if 'problem_idx' in item: 360 | problem_idx = str(item['problem_idx']) 361 | else: 362 | problem_idx = hash_problem_idx(item['question'].strip()) 363 | assert problem_idx not in problem_idx_dedup, problem_idx 364 | problem_idx_dedup.add(problem_idx) 365 | proof2self_eval = problem2proof2self_eval[problem] 366 | proof2dep_proof_ids = problem2proof2dep_proof_ids[problem] 367 | tasks.append( 368 | (item, proof2ratings, proof2self_eval, proof2dep_proof_ids) 369 | ) 370 | 371 | _args = dict( 372 | round_idx=round_idx, 373 | proof_pool_dirname=proof_pool_dirname, 374 | use_old_proofs_for_refinement=use_old_proofs_for_refinement, 375 | num_trials=num_trials, 376 | n_best_proofs_to_sample=n_best_proofs_to_sample, 377 | n_proofs_to_refine=n_proofs_to_refine, 378 | max_rating_per_score=max_rating_per_score, 379 | ) 380 | data = [] 381 | trials = [] 382 | cpu_count = multiprocessing.cpu_count() 383 | print(f"multiprocessing: {cpu_count} workers", flush=True) 384 | pool = multiprocessing.Pool(cpu_count) 385 | for (_data, _trials) in tqdm(pool.imap(partial(_prepare_proof_agg_tasks, **_args), _split_jobs(tasks, 50))): 386 | data.extend(_data) 387 | trials.extend(_trials) 388 | 389 | print(f"Avg trials per statement = {np.mean(trials)}", flush=True) 390 | 391 | os.makedirs(os.path.dirname(tar_path), exist_ok=True) 392 | with open(tar_path, "w") as file: 393 | for item in data: 394 | print(json.dumps(item), file=file, flush=True) 395 | return len(data) 396 | 397 | if __name__ == '__main__': 398 | for R in range(args.start_round, args.max_rounds + 2): 399 | proof_gen_input_path = f"{output_dirname}/proof_gen_R{R}/input.jsonl" 400 | proof_gen_output_path = f"{output_dirname}/proof_gen_R{R}/output.jsonl" 401 | if not os.path.exists(proof_gen_input_path): 402 | if R == 1: 403 | raw_data = [] 404 | for input_path in input_paths.split(","): 405 | source_name = input_path.split("/")[-1].split(".")[0] 406 | if input_path.endswith(".json"): 407 | _local_data = json.load(open(input_path, "r")) 408 | else: 409 | _local_data = [] 410 | with open(input_path, "r") as file: 411 | for line in file: 412 | _local_data.append(json.loads(line)) 413 | for item in _local_data: 414 | item['source_name'] = source_name 415 | raw_data.extend(_local_data) 416 | data = [] 417 | for item in raw_data: 418 | question = math_templates[args.proof_gen_template].format(question=item['question'].strip()) 419 | item.update({ 420 | 'messages': [ 421 | {'role': 'user', 'content': question} 422 | ] 423 | }) 424 | data.append(item) 425 | os.makedirs(os.path.dirname(proof_gen_input_path), exist_ok=True) 426 | with open(proof_gen_input_path, "w") as file: 427 | for item in data: 428 | print(json.dumps(item), file=file, flush=True) 429 | else: 430 | previous_proof_verification_output_path = f"{output_dirname}/proof_verification_R{R - 1}/output.jsonl" 431 | previous_meta_verification_output_path = f"{output_dirname}/meta_verification_R{R - 1}/output.jsonl" 432 | prepare_proof_refinement( 433 | path=previous_proof_verification_output_path, 434 | meta_verification_path=previous_meta_verification_output_path, 435 | tar_path=proof_gen_input_path, 436 | round_idx=R - 1, 437 | proof_pool_dirname=proof_pool_dirname, 438 | use_old_proofs_for_refinement=True, 439 | num_trials=args.n_agg_trials, 440 | n_best_proofs_to_sample=args.n_best_proofs_to_sample, 441 | n_proofs_to_refine=args.n_proofs_to_refine, 442 | max_rating_per_score=4, 443 | drop_thought=True 444 | ) 445 | if R == args.max_rounds + 1: 446 | break 447 | 448 | n_sample = args.n_parallel_proof_gen if R == 1 else args.n_parallel_proof_gen // args.n_agg_trials 449 | proof_gen_cmd = f""" 450 | python {args.infer_script}.py \ 451 | --input_data_path {proof_gen_input_path} \ 452 | --output_data_path {proof_gen_output_path} \ 453 | --api_url {proof_gen_url} \ 454 | --batch_size {args.batch_size} \ 455 | --num_processes {args.proof_gen_num_processes} \ 456 | --temperature {args.proof_gen_temp} \ 457 | --top_p 0.95 \ 458 | --max_tokens {args.proof_gen_max_len} \ 459 | --n {n_sample} 460 | """.strip() 461 | print(proof_gen_cmd, flush=True) 462 | os.system(proof_gen_cmd) 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | proof_verification_input_path = f"{output_dirname}/proof_verification_R{R}/input.jsonl" 473 | proof_verification_output_path = f"{output_dirname}/proof_verification_R{R}/output.jsonl" 474 | if not os.path.exists(proof_verification_input_path): 475 | prepare_proof_verification( 476 | path=proof_gen_output_path, 477 | tar_path=proof_verification_input_path 478 | ) 479 | 480 | proof_verification_cmd = f""" 481 | python generate.py \ 482 | --input_data_path {proof_verification_input_path} \ 483 | --output_data_path {proof_verification_output_path} \ 484 | --batch_size {args.batch_size} \ 485 | --num_processes {args.proof_verification_num_processes} \ 486 | --temperature {args.proof_verification_temp} \ 487 | --top_p 0.95 \ 488 | --max_tokens {args.proof_verification_max_len} \ 489 | --n {args.n_verification_per_proof} 490 | """.strip() 491 | print(proof_verification_cmd, flush=True) 492 | os.system(proof_verification_cmd) 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | meta_verification_input_path = f"{output_dirname}/meta_verification_R{R}/input.jsonl" 503 | meta_verification_output_path = f"{output_dirname}/meta_verification_R{R}/output.jsonl" 504 | if not args.skip_meta_verification: 505 | if not os.path.exists(meta_verification_input_path): 506 | prepare_meta_verification( 507 | path=proof_verification_output_path, 508 | tar_path=meta_verification_input_path 509 | ) 510 | 511 | meta_verification_cmd = f""" 512 | python generate.py \ 513 | --input_data_path {meta_verification_input_path} \ 514 | --output_data_path {meta_verification_output_path} \ 515 | --batch_size {args.batch_size} \ 516 | --num_processes {args.meta_verification_num_processes} \ 517 | --temperature {args.meta_verification_temp} \ 518 | --top_p 0.95 \ 519 | --max_tokens {args.meta_verification_max_len} \ 520 | --n {args.n_meta_verification_per_rating} 521 | """.strip() 522 | print(meta_verification_cmd, flush=True) 523 | os.system(meta_verification_cmd) 524 | -------------------------------------------------------------------------------- /outputs/CMO2024.jsonl: -------------------------------------------------------------------------------- 1 | {"question": "Let $\\alpha > 1$ be an irrational number and $L$ be a integer such that $L > \\frac{\\alpha^2}{\\alpha - 1}$. A sequence $x_1, x_2, \\cdots$ satisfies that $x_1 > L$ and for all positive integers $n$,\\[ x_{n+1} = \\begin{cases} \\left \\lfloor \\alpha x_n \\right \\rfloor & \\textup{if} \\; x_n \\leqslant L \\\\left \\lfloor \\frac{x_n}{\\alpha} \\right \\rfloor & \\textup{if} \\; x_n > L \\end{cases}. \\]Prove that\n(i) $\\left\\{x_n\\right\\}$ is eventually periodic.\n(ii) The eventual fundamental period of $\\left\\{x_n\\right\\}$ is an odd integer which doesn't depend on the choice of $x_1$.", "problem_idx": "CMO2024-1", "model_prediction": {"proof": "**Notation and basic facts** \n\nDefine \n\n\\[\nf(x)=\\begin{cases}\n\\displaystyle \\bigl\\lfloor \\alpha x\\bigr\\rfloor & (x\\le L),\\\\[4mm]\n\\displaystyle \\Bigl\\lfloor \\frac{x}{\\alpha}\\Bigr\\rfloor & (x>L).\n\\end{cases}\n\\]\n\nThe recurrence is \\(x_{n+1}=f(x_n)\\;(n\\ge1)\\) with \\(x_1>L\\). \nSince \\(x_2=\\bigl\\lfloor x_1/\\alpha\\bigr\\rfloor\\) is an integer, by induction every term from \\(x_2\\) onward is an integer.\n\n---\n\n### 1. Preliminary estimates \n\nFrom \\(L>\\dfrac{\\alpha^{2}}{\\alpha-1}\\) and \\(\\alpha>1\\),\n\n\\[\nL(\\alpha-1)>\\alpha^{2}\\;\\Longrightarrow\\; \\alpha L>L+\\alpha^{2}>L+1. \\tag{1}\n\\]\n\nSet \n\n\\[\nM=\\bigl\\lfloor\\alpha L\\bigr\\rfloor ,\\qquad a=\\Bigl\\lfloor\\frac{L+1}{\\alpha}\\Bigr\\rfloor .\n\\]\n\nBecause \\(\\alpha L>L+1\\), we have \\(M\\ge L+1\\). \nSince \\((L+1)/\\alphaL+1\\) \u21d2 \\((L+1)/\\alpha\\alpha\\) \u21d2 \\((L+1)/\\alpha>1\\) \u21d2 \\(a\\ge1\\). \nFrom \\(L>\\alpha^{2}/(\\alpha-1)\\) we also obtain \\(L>\\alpha\\). \nThe irrationality of \\(\\alpha\\) guarantees that \\(\\alpha L\\) and \\((L+1)/\\alpha\\) are not integers, so \n\n\\[\nM<\\alpha L,\\qquad a<\\frac{L+1}{\\alpha}. \\tag{2}\n\\]\n\n---\n\n### 2. Part (i) \u2013 eventual periodicity \n\nLet \n\n\\[\nS=\\{1,2,\\dots ,M\\}.\n\\]\n\n**Lemma\u202f2.1** \\(f(S)\\subseteq S\\).\n\n*Proof.* Take \\(k\\in S\\).\n\n*If \\(k\\le L\\):* \\(f(k)=\\lfloor\\alpha k\\rfloor\\). Because \\(k\\ge1\\), \\(\\alpha k\\ge\\alpha>1\\) \u21d2 \\(f(k)\\ge1\\). Also \\(\\alpha k\\le\\alpha L\\) \u21d2 \\(f(k)\\le\\lfloor\\alpha L\\rfloor=M\\).\n\n*If \\(k>L\\):* then \\(L\\alpha\\), \\(k/\\alpha>1\\) \u21d2 \\(f(k)=\\lfloor k/\\alpha\\rfloor\\ge1\\). Moreover \\(k\\le M\\) and \\(M<\\alpha L\\) \u21d2 \\(k/\\alpha\\le M/\\alphaL>\\alpha\\), \\(x_2\\ge1\\).\n\n*If \\(x_2\\le L\\):* then \\(1\\le x_2\\le L\\le M\\), so \\(x_2\\in S\\).\n\n*If \\(x_2>L\\):* while a term exceeds \\(L\\) we use the second branch: \\(x_{n+1}=\\lfloor x_n/\\alpha\\rfloor\\). For such \\(x_n\\) we have \\(x_{n+1}1\\)). Thus the values while \\(>L\\) form a strictly decreasing sequence of positive integers. Such a sequence cannot be infinite; therefore there exists a smallest index \\(N\\ge2\\) with \\(x_N\\le L\\). By minimality \\(x_{N-1}>L\\), hence \\(x_{N-1}\\ge L+1\\). Then \n\n\\[\nx_N=\\Bigl\\lfloor\\frac{x_{N-1}}{\\alpha}\\Bigr\\rfloor\\ge\\Bigl\\lfloor\\frac{L+1}{\\alpha}\\Bigr\\rfloor = a\\ge1,\n\\]\n\nand \\(x_N\\le L\\); consequently \\(x_N\\in S\\).\n\nThus in every case we find an index \\(N\\) with \\(x_N\\in S\\).\n\n**Conclusion of (i).** By Lemma\u202f2.1, once we are in \\(S\\) we stay there: if \\(x_n\\in S\\) then \\(x_{n+1}=f(x_n)\\in S\\). Hence \\(x_n\\in S\\) for all \\(n\\ge N\\). \nBecause \\(S\\) is finite, among the infinitely many terms \\(x_N,x_{N+1},\\dots\\) two must be equal: say \\(x_i=x_j\\) with \\(ia\\), then \\(f(y)\\in I\\) and \\(f^{2}(y)=y-1\\). \n2. If \\(k\\in I\\), then \\(f(k)\\in Y\\) and \\(f(k)\\ge a\\). \n3. \\(f(a)\\in Y\\) (and \\(f(a)\\ge a\\)).\n\n*Proof.* \n\n1. Because \\(y\\le L\\), \\(f(y)=\\lfloor\\alpha y\\rfloor\\). \n From \\(a=\\bigl\\lfloor\\frac{L+1}{\\alpha}\\bigr\\rfloor\\) we have \\(a<\\frac{L+1}{\\alpha}\\frac{L+1}{\\alpha}\\), hence \\(\\alpha y>L+1\\). \n Also \\(\\alpha y\\le\\alpha L\\); therefore \\(L+1\\le\\lfloor\\alpha y\\rfloor\\le M\\), i.e. \\(f(y)\\in I\\). \n\n \\(\\alpha\\) is irrational, so \\(\\alpha y\\) is not an integer; thus \\(\\alpha y-1<\\lfloor\\alpha y\\rfloor<\\alpha y\\). Dividing by \\(\\alpha\\) gives \n\n \\[\n y-\\frac1\\alpha<\\frac{f(y)}{\\alpha}1\\) implies \\(\\alpha a>a\\); therefore \\(f(a)\\ge a\\). Hence \\(f(a)\\in Y\\). \u220e \n\n**Corollary\u202f3.2** \\(f(T)\\subseteq T\\). (Immediate from Lemma\u202f3.1.)\n\n---\n\n#### 3.2 The sequence eventually stays in \\(T\\)\n\nWe analyse \\(x_2=\\lfloor x_1/\\alpha\\rfloor\\).\n\n* **Case\u202fA:** \\(x_2\\le L\\) **and** \\(x_2\\ge a\\). \n Then \\(x_2\\in Y\\subseteq T\\). By Corollary\u202f3.2 the whole tail from index\u202f2 stays in \\(T\\); we may take \\(N=2\\).\n\n* **Case\u202fB:** \\(x_2\\le L\\) **and** \\(x_2\\dfrac{\\alpha^{2}}{\\alpha-1}\\) we obtain \\(\\dfrac{L}{\\alpha}>\\dfrac{\\alpha}{\\alpha-1}\\); hence \n\n \\[\n \\frac{L}{\\alpha}-1>\\frac{1}{\\alpha-1}.\n \\]\n\n Since \\(t>\\dfrac{L}{\\alpha}-1\\) (property of the floor), we have \\(t>\\dfrac{1}{\\alpha-1}\\), i.e. \\(t(\\alpha-1)>1\\), which is equivalent to \\(\\alpha t>t+1\\). Therefore \\(\\lfloor\\alpha t\\rfloor\\ge t+1=a\\). \n\n Thus \\(a\\le x_3\\le L\\), so \\(x_3\\in Y\\subseteq T\\). From index\u202f3 onward the sequence remains in \\(T\\); take \\(N=3\\).\n\n* **Case\u202fC:** \\(x_2>L\\). \n\n As in part\u202f(i), there exists a smallest index \\(N\\ge2\\) with \\(x_N\\le L\\). Minimality gives \\(x_{N-1}>L\\), hence \\(x_{N-1}\\ge L+1\\). Then \n\n \\[\n x_N=\\Bigl\\lfloor\\frac{x_{N-1}}{\\alpha}\\Bigr\\rfloor\\ge\\Bigl\\lfloor\\frac{L+1}{\\alpha}\\Bigr\\rfloor = a,\n \\]\n\n and \\(x_N\\le L\\); therefore \\(x_N\\in Y\\subseteq T\\). By Corollary\u202f3.2, for all \\(n\\ge N\\) we have \\(x_n\\in T\\).\n\nIn every possible situation we have found an index \\(N\\) such that \\(x_N\\in T\\) and \\(x_n\\in T\\) for all \\(n\\ge N\\).\n\n---\n\n#### 3.3 All elements of \\(T\\) are attracted to \\(a\\)\n\n**Lemma\u202f3.3** For every \\(t\\in T\\) there exists a non\u2011negative integer \\(m\\) with \\(f^{\\,m}(t)=a\\).\n\n*Proof.* \n\n- If \\(t=a\\), take \\(m=0\\). \n- If \\(t\\in Y\\) and \\(t>a\\), Lemma\u202f3.1(1) gives \\(f^{2}(t)=t-1\\). Repeating this operation reduces the value by one every two steps; after \\(2(t-a)\\) applications we reach \\(a\\). \n- If \\(t\\in I\\), Lemma\u202f3.1(2) yields \\(f(t)\\in Y\\). Applying the previous case to \\(f(t)\\) provides an \\(m'\\) with \\(f^{\\,m'}(f(t))=a\\); then \\(m=m'+1\\) works. \u220e \n\nApply Lemma\u202f3.3 to \\(x_N\\) (which lies in \\(T\\)). There exists \\(m\\ge0\\) such that \\(x_{N+m}=a\\). Set \\(K=N+m\\). By the definition of the recurrence,\n\n\\[\nx_{K+n}=f^{\\,n}(a)\\qquad\\text{for all }n\\ge0. \\tag{1}\n\\]\n\n---\n\n#### 3.4 The orbit of \\(a\\) and its period \n\nLet \\(b=f(a)\\). From Lemma\u202f3.1(3) we have \\(b\\in Y\\) and \\(b\\ge a\\).\n\n* **Subcase\u202f1:** \\(b=a\\). Then \\(a\\) is a fixed point; its fundamental period is \\(p=1\\).\n\n* **Subcase\u202f2:** \\(b>a\\). Put \\(d=b-a\\;(d\\ge1)\\). \n\n **Claim:** For \\(k=0,1,\\dots ,d-1\\), \n\n \\[\n f^{\\,2k+1}(a)=b-k. \\tag{2}\n \\]\n\n *Proof by induction.* For \\(k=0\\), (2) is \\(f(a)=b\\). Assume (2) holds for some \\(ka\\) (because \\(b-k\\ge b-(d-2)=a+2\\)). By Lemma\u202f3.1(1), \\(f^{2}(y)=y-1=b-(k+1)\\). Hence \\(f^{\\,2(k+1)+1}(a)=f^{2}\\!\\bigl(f^{\\,2k+1}(a)\\bigr)=b-(k+1)\\), completing the induction. \u220e \n\n Taking \\(k=d-1\\) gives \\(f^{\\,2d-1}(a)=b-(d-1)=a+1\\). \n Applying Lemma\u202f3.1(1) to \\(y=a+1\\) yields \\(f^{2}(a+1)=a\\). Consequently \n\n \\[\n f^{\\,2d+1}(a)=a. \\tag{3}\n \\]\n\n We now verify that no smaller positive integer can be a period of \\(a\\). \n\n *Odd candidates:* If \\(q=2k+1\\) with \\(0\\le ka\\), so \\(f^{q}(a)\\neq a\\). \n\n *Even candidates:* If \\(q=2k\\) with \\(1\\le k\\le d\\), then \\(f^{\\,2k-1}(a)=b-(k-1)>a\\) (by (2) for \\(k-1\\le d-1\\)). Since \\(f^{\\,2k-1}(a)\\in Y\\) and \\(>a\\), Lemma\u202f3.1(1) tells us that \\(f^{\\,2k}(a)\\in I\\); but \\(a\\in Y\\) and \\(Y\\cap I=\\varnothing\\), hence \\(f^{\\,2k}(a)\\neq a\\).\n\n Therefore the smallest positive integer with \\(f^{p}(a)=a\\) is \\(p=2d+1\\).\n\nIn both subcases \\(p\\) is **odd** (1 is odd, and \\(2d+1\\) is odd).\n\n---\n\n#### 3.5 The eventual fundamental period of \\(\\{x_n\\}\\)\n\nFrom (1) and \\(f^{p}(a)=a\\) we obtain \\(x_{K+p}=f^{p}(a)=a=x_K\\), and by induction \n\n\\[\nx_{K+n+p}=x_{K+n}\\qquad\\text{for all }n\\ge0.\n\\]\n\nThus the tail \\(\\{x_n\\}_{n\\ge K}\\) is periodic with period \\(p\\); the whole sequence is eventually periodic with period \\(p\\).\n\nNow we prove that \\(p\\) is the *fundamental* eventual period. Suppose, for contradiction, that there existed a positive integer \\(qa\\)). Hence \\(p\\) does **not** depend on the choice of \\(x_1\\).\n\n\u220e \n\n---", "average_automatic_rating": 1.0, "human_rating": 21}} 2 | {"question": "Let $ABC$ be a triangle with incenter $I$. Denote the midpoints of $AI$, $AC$ and $CI$ by $L$, $M$ and $N$ respectively. Point $D$ lies on segment $AM$ such that $BC= BD$. Let the incircle of triangle $ABD$ be tangent to $AD$ and $BD$ at $E$ and $F$ respectively. Denote the circumcenter of triangle $AIC$ by $J$, and the circumcircle of triangle $JMD$ by $\\omega$. Lines $MN$ and $JL$ meet $\\omega$ again at $P$ and $Q$ respectively. Prove that $PQ$, $LN$ and $EF$ are concurrent.", "problem_idx": "CMO2024-2", "model_prediction": {"proof": "**1. Coordinate set\u2011up.** \nPlace the midpoint \\(M\\) of \\(AC\\) at the origin and let \\(AC\\) lie on the \\(x\\)-axis. \nWrite \n\n\\[\nA=(-t,0),\\qquad C=(t,0)\\quad(t>0),\\qquad B=(p,q)\\quad(q>0).\n\\]\n\nDenote the side lengths \n\n\\[\na = BC = \\sqrt{(p-t)^2+q^2},\\qquad \nc = AB = \\sqrt{(p+t)^2+q^2},\\qquad \nb = AC = 2t,\n\\]\nand let \n\n\\[\ns = a+b+c = a+2t+c.\n\\]\n\n**2. Point \\(D\\).** \n\\(D\\) lies on segment \\(AM\\) and satisfies \\(BD = BC = a\\). Points on \\(AM\\) have the form \\((x,0)\\) with \\(-t\\le x\\le 0\\). \nThe condition \\((p-x)^2+q^2 = (p-t)^2+q^2\\) gives \\((p-x)^2 = (p-t)^2\\); hence \n\n\\[\np-x = \\pm(p-t).\n\\]\n\nThe choice \\(p-x = p-t\\) yields \\(x=t\\) (point \\(C\\)), which is not on \\(AM\\). The other choice gives \n\n\\[\nx = 2p-t.\n\\]\n\nThus \\(D = (d,0)\\) with \n\n\\[\nd = 2p-t.\n\\]\n\nFor \\(D\\) to belong to the segment \\(AM\\) we need \\(-t\\le d\\le0\\), i.e. \\(0\\le p\\le t/2\\). \nA non\u2011degenerate configuration (the incircle of \\(\\triangle ABD\\) exists and \\(\\omega\\) is defined) requires \\(D\\) distinct from \\(A\\) and \\(M\\); therefore we take \n\n\\[\n00\\); also \\(U>q\\) since \\(c=\\sqrt{(p+t)^2+q^2}>q\\) and \\(U=p+t+c>q\\). Hence \\(\\Delta x\\neq0\\) and the slope is well defined.)\n\nThus the slope of \\(PQ\\) is \n\n\\[\nm = \\frac{\\Delta y}{\\Delta x} = \\frac{-2U q d/\\Delta}{d\\,(q^2-U^2)/\\Delta}\n = -\\frac{2U q}{q^2-U^2}.\n\\]\n\nNow the line through \\(P\\) with this slope has equation \n\n\\[\ny - \\lambda_P q = m\\,(x - \\lambda_P U).\n\\]\n\nSetting \\(y = L_y\\) and solving for \\(x\\) yields \n\n\\[\nx = \\lambda_P U + \\frac{L_y - \\lambda_P q}{m}.\n\\]\n\nBecause \\(1/m = -(q^2-U^2)/(2U q)\\),\n\n\\[\nx = \\lambda_P U - (L_y - \\lambda_P q)\\,\\frac{q^2-U^2}{2U q}.\n\\]\n\nExpand and collect the terms containing \\(\\lambda_P\\):\n\n\\[\n\\begin{aligned}\nx &= \\lambda_P U - \\frac{L_y(q^2-U^2)}{2U q} + \\lambda_P q\\,\\frac{q^2-U^2}{2U q}\\\\[4pt]\n &= \\lambda_P\\!\\left(U + \\frac{q^2-U^2}{2U}\\right) - \\frac{L_y(q^2-U^2)}{2U q}\\\\[4pt]\n &= \\lambda_P\\frac{U^2+q^2}{2U} - \\frac{L_y(q^2-U^2)}{2U q}.\n\\end{aligned}\n\\]\n\nUsing \\(\\lambda_P\\Delta = U d + q y_J\\) (from (4)) we obtain \n\n\\[\nx = \\frac{U d + q y_J}{2U} - \\frac{L_y(q^2-U^2)}{2U q}.\n\\]\n\nNow apply relation (2), \\(q y_J = L_x U + q L_y\\):\n\n\\[\n\\frac{U d + q y_J}{2U} = \\frac{d}{2} + \\frac{L_x}{2} + \\frac{q L_y}{2U}.\n\\]\n\nHence \n\n\\[\nx = \\frac{d}{2} + \\frac{L_x}{2} + \\frac{q L_y}{2U} - \\frac{L_y(q^2-U^2)}{2U q}.\n\\]\n\nCombine the \\(L_y\\)\u2011terms:\n\n\\[\n\\frac{q L_y}{2U} - \\frac{L_y(q^2-U^2)}{2U q}\n = \\frac{L_y}{2U}\\!\\left(q - \\frac{q^2-U^2}{q}\\right)\n = \\frac{L_y}{2U}\\!\\left(\\frac{U^2}{q}\\right)\n = \\frac{U L_y}{2q}.\n\\]\n\nTherefore \n\n\\[\nx = \\frac{d}{2} + \\frac{L_x}{2} + \\frac{U L_y}{2q}. \\tag{8}\n\\]\n\nFinally substitute the explicit coordinates:\n\n\\[\nd = 2p-t,\\qquad\nL_x = \\frac{t(p-a-t)}{s},\\qquad\nL_y = \\frac{tq}{s},\\qquad\nU = p+t+c.\n\\]\n\nThen \n\n\\[\n\\begin{aligned}\nx &= \\frac{2p-t}{2} + \\frac{1}{2}\\,\\frac{t(p-a-t)}{s} + \\frac{t(p+t+c)}{2s}\\\\[4pt]\n &= \\frac{2p-t}{2} + \\frac{t}{2s}\\bigl[(p-a-t)+(p+t+c)\\bigr]\\\\[4pt]\n &= \\frac{2p-t}{2} + \\frac{t(2p - a + c)}{2s}. \\tag{9}\n\\end{aligned}\n\\]\n\nThus \n\n\\[\nX = \\bigl(x,\\;L_y\\bigr) = \\Bigl(\\frac{2p-t}{2} + \\frac{t(2p - a + c)}{2s},\\; \\frac{tq}{s}\\Bigr). \\tag{10}\n\\]\n\n**9. Points \\(E\\) and \\(F\\) \u2013 tangency points of the incircle of \\(\\triangle ABD\\).** \nFor \\(\\triangle ABD\\) we have \n\n\\[\nAB = c,\\quad BD = a,\\quad AD = |d-(-t)| = 2p.\n\\]\n\nIts semiperimeter is \n\n\\[\ns_1 = \\frac{a+2p+c}{2}.\n\\]\n\nStandard incircle properties give \n\n\\[\nAE = s_1 - a = \\frac{2p + c - a}{2},\\qquad\nBF = s_1 - AD = \\frac{a + c - 2p}{2}.\n\\]\n\nSince \\(A=(-t,0)\\) and \\(D=(d,0)\\) lie on the \\(x\\)-axis, \\(E\\) is also on this axis:\n\n\\[\nE = (-t + AE,\\;0) = \\Bigl(\\frac{c + 2p - a - 2t}{2},\\;0\\Bigr). \\tag{11}\n\\]\n\nVector \\(\\overrightarrow{BD} = (d-p,\\,-q) = (p-t,\\,-q)\\). Hence \n\n\\[\nF = B + \\frac{BF}{BD}\\,\\overrightarrow{BD}\n = (p,q) + \\frac{a + c - 2p}{2a}\\,(p-t,\\,-q).\n\\]\n\nConsequently \n\n\\[\nx_F = p + \\frac{(a + c - 2p)(p-t)}{2a},\\qquad\ny_F = q\\Bigl(1 - \\frac{a + c - 2p}{2a}\\Bigr)\n = q\\,\\frac{a - c + 2p}{2a}. \\tag{12}\n\\]\n\n**10. Proving that \\(X\\) lies on \\(EF\\).** \nBecause \\(LN\\) is horizontal, \\(X\\) has ordinate \\(L_y\\). Points \\(E\\), \\(F\\), \\(X\\) are collinear iff \n\n\\[\n(x - x_E)\\,y_F = L_y\\,(x_F - x_E). \\tag{13}\n\\]\n\nSubstituting \\(y_F = q\\,\\dfrac{a-c+2p}{2a}\\) and \\(L_y = \\dfrac{tq}{s}\\) and cancelling the common factor \\(q>0\\) yields \n\n\\[\n(x - x_E)\\,\\frac{a-c+2p}{2a} = \\frac{t}{s}\\,(x_F - x_E).\n\\]\n\nMultiplying by \\(2a s\\) we obtain an equivalent equation \n\n\\[\ns\\,(a - c + 2p)\\,(x - x_E) = 2a t\\,(x_F - x_E). \\tag{14}\n\\]\n\nNow insert the expressions for \\(x\\), \\(x_E\\) and \\(x_F\\). From (9) and (11)\n\n\\[\nx - x_E = \\frac{a - c + t}{2} + \\frac{t(2p - a + c)}{2s}. \\tag{15}\n\\]\n\nHence \n\n\\[\n\\begin{aligned}\ns\\,(a - c + 2p)(x - x_E)\n&= s\\,(a - c + 2p)\\!\\left(\\frac{a - c + t}{2} + \\frac{t(2p - a + c)}{2s}\\right)\\\\[4pt]\n&= \\frac{a - c + 2p}{2}\\Bigl[\\,s\\,(a - c + t) + t(2p - a + c)\\Bigr].\n\\end{aligned}\n\\]\n\nExpand the bracket using \\(s = a+2t+c\\):\n\n\\[\n\\begin{aligned}\ns\\,(a - c + t) + t(2p - a + c)\n&= (a+2t+c)(a - c + t) + t(2p - a + c)\\\\\n&= a^2 + 2a t + 2t^2 - c^2 + 2p t.\n\\end{aligned}\n\\]\n\nFrom the coordinates we have the simple relation \n\n\\[\nc^2 - a^2 = (p+t)^2+q^2 - \\bigl[(p-t)^2+q^2\\bigr] = 4pt,\n\\]\nso \\(a^2 - c^2 = -4pt\\). Substituting this,\n\n\\[\ns\\,(a - c + t) + t(2p - a + c) = -4pt + 2a t + 2t^2 + 2p t\n = 2t\\,(a + t - p).\n\\]\n\nTherefore \n\n\\[\ns\\,(a - c + 2p)(x - x_E) = \\frac{a - c + 2p}{2}\\cdot 2t\\,(a + t - p)\n = t\\,(a - c + 2p)(a - p + t). \\tag{16}\n\\]\n\nNow compute the right\u2011hand side of (14). From (11) and (12),\n\n\\[\nx_F - x_E = p + \\frac{(a + c - 2p)(p-t)}{2a} - \\frac{c + 2p - a - 2t}{2}.\n\\]\n\nWriting everything over the common denominator \\(2a\\) gives \n\n\\[\nx_F - x_E = \\frac{N}{2a},\n\\]\n\nwhere \n\n\\[\nN = a^2 + a(p+t) + c(p-t) - a c - 2p^2 + 2p t. \\tag{17}\n\\]\n\nConsequently \n\n\\[\n2a t\\,(x_F - x_E) = 2a t\\cdot\\frac{N}{2a} = t N. \\tag{18}\n\\]\n\nIt remains to check that \n\n\\[\nN = (a - c + 2p)(a - p + t).\n\\]\n\nExpanding the right\u2011hand side:\n\n\\[\n\\begin{aligned}\n(a - c + 2p)(a - p + t)\n&= a(a-p+t) - c(a-p+t) + 2p(a-p+t)\\\\\n&= a^2 - a p + a t - a c + c p - c t + 2a p - 2p^2 + 2p t\\\\\n&= a^2 + a p + a t - a c + c p - c t - 2p^2 + 2p t,\n\\end{aligned}\n\\]\n\nwhich is exactly the expression (17). Hence \\(t N = t\\,(a - c + 2p)(a - p + t)\\).\n\nComparing (16) and (18) we see that (14) holds, and therefore (13) is satisfied. Thus \\(X\\) lies on line \\(EF\\).\n\n**11. Conclusion.** \nWe have shown that the point \\(X = PQ\\cap LN\\) also belongs to \\(EF\\). Hence the three lines \\(PQ,\\;LN,\\;EF\\) are concurrent (they intersect at \\(X\\)). \u220e", "average_automatic_rating": 1.0, "human_rating": 21}} 3 | {"question": "Let \\(a_1, a_2, \\ldots, a_n\\) be integers such that \\(a_1 > a_2 > \\cdots > a_n > 1\\). Let \\(M = \\operatorname{lcm} \\left( a_1, a_2, \\ldots, a_n \\right)\\). For any finite nonempty set $X$ of positive integers, define\\[ f(X) = \\min_{1 \\leqslant i \\leqslant n} \\sum_{x \\in X} \\left\\{ \\frac{x}{a_i} \\right\\}. \\]Such a set $X$ is called minimal if for every proper subset $Y$ of it, $f(Y) < f(X)$ always holds.\n\nSuppose $X$ is minimal and $f(X) \\geqslant \\frac{2}{a_n}$. Prove that\\[ |X| \\leqslant f(X) \\cdot M. \\]", "problem_idx": "CMO2024-3", "model_prediction": {"proof": "**Notation** \nFor a finite non\u2011empty set \\(X\\subset\\mathbb N\\) write \n\n\\[\nS_i(X)=\\sum_{x\\in X}\\Bigl\\{\\frac{x}{a_i}\\Bigr\\}\\qquad(1\\le i\\le n),\\qquad \nf(X)=\\min_{1\\le i\\le n}S_i(X).\n\\]\n\nThe integers \\(a_1>a_2>\\dots >a_n>1\\) are fixed and \n\n\\[\nM=\\operatorname{lcm}(a_1,a_2,\\dots ,a_n).\n\\]\n\n---\n\n### 1. No element of \\(X\\) is a multiple of \\(M\\)\n\nAssume that some \\(x\\in X\\) satisfies \\(M\\mid x\\). \n\n* If \\(|X|>1\\) then \\(Y=X\\setminus\\{x\\}\\) is a non\u2011empty proper subset and \n \\(S_i(Y)=S_i(X)\\) for every \\(i\\) (because \\(\\{x/a_i\\}=0\\)). Hence \\(f(Y)=f(X)\\), contradicting minimality. \n\n* If \\(X=\\{x\\}\\) then \\(f(X)=0\\), but the hypothesis says \\(f(X)\\ge 2/a_n>0\\), impossible. \n\nThus every \\(x\\in X\\) has a remainder \\(t_x:=x\\bmod M\\) belonging to \\(\\{1,2,\\dots ,M-1\\}\\) and \n\n\\[\n\\Bigl\\{\\frac{x}{a_i}\\Bigr\\}=\\Bigl\\{\\frac{t_x}{a_i}\\Bigr\\}\\qquad(\\forall i).\n\\]\n\n---\n\n### 2. A useful lemma \n\nFor \\(t\\in\\{1,\\dots ,M-1\\}\\) define \n\n\\[\ng(t)=\\sum_{i=1}^{n}\\Bigl\\{\\frac{t}{a_i}\\Bigr\\}.\n\\]\n\n**Lemma 1.** \\(g(t)\\ge \\dfrac{n}{M}\\) for every such \\(t\\).\n\n*Proof by induction on \\(n\\).* \n\n*Base \\(n=1\\).* Then \\(M=a_1\\) and \\(g(t)=\\{t/a_1\\}=t/a_1\\ge 1/a_1=1/M\\).\n\n*Inductive step.* Assume the statement true for any collection of \\(n-1\\) integers satisfying the same hypotheses. \nLet \\(a_1>a_2>\\dots >a_n>1\\) and put \n\n\\[\nM'=\\operatorname{lcm}(a_2,\\dots ,a_n),\\qquad g=\\gcd(a_1,M'),\\qquad a_1=gL,\\; M'=gL'\\;(\\gcd(L,L')=1).\n\\]\n\nThen \\(M=\\operatorname{lcm}(a_1,M')=L M'\\).\n\nTake \\(t\\) with \\(1\\le t\\le M-1\\) and write its division by \\(M'\\): \n\n\\[\nt=qM'+r,\\qquad 0\\le q\\le L-1,\\;0\\le r\\le M'-1 .\n\\]\n\n---\n\n**Case A: \\(r=0\\).** Then \\(t=qM'\\) with \\(1\\le q\\le L-1\\). \nFor \\(i\\ge 2\\) we have \\(\\{t/a_i\\}=0\\) because \\(M'\\) is a multiple of each \\(a_i\\). Hence \n\n\\[\ng(t)=\\Bigl\\{\\frac{qM'}{a_1}\\Bigr\\}\n =\\Bigl\\{\\frac{qL'}{L}\\Bigr\\}\\ge\\frac{1}{L},\n\\]\n\nthe last inequality holding because \\(\\gcd(L,L')=1\\) and \\(q\\) is not a multiple of \\(L\\). \n\nNow we need \\(\\frac{1}{L}\\ge\\frac{n}{M}= \\frac{n}{L M'}\\), i.e. \\(M'\\ge n\\). \nThe numbers \\(a_2,\\dots ,a_n\\) are \\(n-1\\) distinct integers \\(>1\\). Their largest element \\(a_2\\) must be at least \\(n\\); otherwise all of them would lie in \\(\\{2,3,\\dots ,n-1\\}\\), a set of only \\(n-2\\) elements, contradicting distinctness. Thus \\(M'\\ge a_2\\ge n\\) and the desired inequality follows.\n\n---\n\n**Case B: \\(r>0\\).** For \\(i\\ge 2\\) we have \\(\\{t/a_i\\}=\\{r/a_i\\}\\) (again because \\(M'\\) is a multiple of \\(a_i\\)). \nBy the induction hypothesis applied to \\((a_2,\\dots ,a_n)\\) and its lcm \\(M'\\),\n\n\\[\nh(r):=\\sum_{i=2}^{n}\\Bigl\\{\\frac{r}{a_i}\\Bigr\\}\\ge\\frac{n-1}{M'}.\n\\]\n\nThus \n\n\\[\ng(t)=\\Bigl\\{\\frac{qM'+r}{a_1}\\Bigr\\}+h(r)\\ge\n\\Bigl\\{\\frac{qM'+r}{a_1}\\Bigr\\}+\\frac{n-1}{M'}. \\tag{\u2217}\n\\]\n\nWe distinguish two sub\u2011cases.\n\n* **Sub\u2011case B1: \\(L\\ge 2\\).** \n Because \\((n-1)/M' = (n-1)L / M\\) and \\(L\\ge 2\\) implies \\((n-1)L \\ge n\\) (true for all \\(n\\ge 2\\)), we have \\((n-1)/M'\\ge n/M\\). \n Since the first term in (\u2217) is non\u2011negative, \\(g(t)\\ge n/M\\).\n\n* **Sub\u2011case B2: \\(L=1\\).** \n Then \\(a_1=g\\), \\(M=M'\\) and \\(k:=M/a_1\\) is an integer. Because \\(q\\le L-1=0\\), we have \\(q=0\\) and \\(t=r\\). \n\n *If \\(a_1\\nmid t\\)*, then \\(\\{t/a_1\\}\\ge 1/a_1 = k/M\\). Consequently \n\n \\[\n g(t)=\\{t/a_1\\}+h(t)\\ge \\frac{k}{M}+\\frac{n-1}{M}= \\frac{k+n-1}{M}\\ge\\frac{n}{M}\\quad(\\text{since }k\\ge1).\n \\]\n\n *If \\(a_1\\mid t\\)*, write \\(t=a_1u\\) with \\(1\\le u\\le k-1\\) (if \\(k=1\\) this case cannot occur). Then \\(\\{t/a_1\\}=0\\) and \n\n \\[\n g(t)=h(t)=\\sum_{i=2}^{n}\\Bigl\\{\\frac{a_1u}{a_i}\\Bigr\\}.\n \\]\n\n For \\(i\\ge2\\) set \\(b_i=M/a_i\\) (an integer). Using \n\n \\[\n \\Bigl\\{\\frac{a_1u}{a_i}\\Bigr\\}=\\frac{((a_1u)b_i)\\bmod M}{M},\n \\]\n and the fact that \\(M=a_1k\\), we obtain \n\n \\[\n ((a_1u)b_i)\\bmod M = a_1\\bigl((u b_i)\\bmod k\\bigr),\n \\qquad\\text{hence}\\qquad\n \\Bigl\\{\\frac{a_1u}{a_i}\\Bigr\\}=\\frac{(u b_i)\\bmod k}{k}.\n \\]\n\n Therefore \n\n \\[\n h(t)=\\frac1k\\sum_{i=2}^{n}\\bigl((u b_i)\\bmod k\\bigr).\n \\]\n\n **Claim:** \\(\\displaystyle\\sum_{i=2}^{n}\\bigl((u b_i)\\bmod k\\bigr)\\ge 1\\). \n\n *Proof of the claim.* Because \\(M=\\operatorname{lcm}(a_2,\\dots ,a_n)\\) and \\(a_1\\mid M\\), the integers \\(b_i=M/a_i\\) satisfy \\(\\gcd(b_2,\\dots ,b_n)=1\\). (If a common divisor \\(d>1\\) divided every \\(b_i\\), then \\(M/d\\) would be a common multiple of \\(a_2,\\dots ,a_n\\), contradicting the definition of \\(M\\) as the *least* common multiple.) \n\n By B\u00e9zout\u2019s identity there exist integers \\(\\lambda_i\\) with \\(\\sum_{i=2}^{n}\\lambda_i b_i =1\\). Multiplying by \\(u\\) gives \n\n \\[\n u = \\sum_{i=2}^{n}\\lambda_i (u b_i).\n \\]\n\n If every term \\((u b_i)\\) were divisible by \\(k\\), the right\u2011hand side would be divisible by \\(k\\), forcing \\(k\\mid u\\). But \\(1\\le u\\le k-1\\) \u2013 contradiction. Hence at least one \\((u b_i)\\bmod k\\) is non\u2011zero, and because all are non\u2011negative integers, the sum is at least \\(1\\). \u220e \n\n Consequently \\(h(t)\\ge 1/k\\). \n\n Now recall that \\(a_1>a_2\\) and, as shown in Case\u202fA, \\(a_2\\ge n\\); thus \\(a_1\\ge n+1\\ge n\\). Hence \n\n \\[\n h(t)\\ge\\frac1k=\\frac{a_1}{M}\\ge\\frac{n}{M}.\n \\]\n\nIn every sub\u2011case we have proved \\(g(t)\\ge n/M\\), completing the induction. \u220e\n\n\n\n---\n\n### 3. Applying the lemma \n\nFor each \\(x\\in X\\) let \\(t_x=x\\bmod M\\;(1\\le t_x\\le M-1)\\). Summing Lemma\u202f1 over the elements of \\(X\\) we obtain \n\n\\[\n\\sum_{i=1}^{n}S_i(X)=\\sum_{x\\in X}g(t_x)\\ge |X|\\cdot\\frac{n}{M}. \\tag{1}\n\\]\n\n---\n\n### 4. Integrality of \\(f\\cdot M\\)\n\nBecause each \\(a_i\\) divides \\(M\\), we can write \\(\\frac1{a_i}=\\frac{M/a_i}{M}\\). Hence \n\n\\[\n\\{x/a_i\\}=\\frac{x\\bmod a_i}{a_i}\n =\\frac{(x\\bmod a_i)\\,(M/a_i)}{M}\\in\\frac{1}{M}\\mathbb Z .\n\\]\n\nTherefore every \\(S_i(X)\\) is a sum of such numbers, so \\(S_i(X)\\in\\frac{1}{M}\\mathbb Z\\). \nThe minimum \\(f=f(X)\\) of finitely many numbers each in \\(\\frac{1}{M}\\mathbb Z\\) is itself of this form; write \n\n\\[\nf=\\frac{K}{M}\\qquad(K\\in\\mathbb N,\\;K\\ge 1)\n\\]\n\n(the positivity follows from \\(f\\ge 2/a_n>0\\)). From the hypothesis \\(f\\ge 2/a_n\\) we obtain \n\n\\[\nK = fM \\ge \\frac{2}{a_n}\\,M = 2\\,\\frac{M}{a_n}\\ge 2,\n\\]\n\nso \\(K\\ge 2\\).\n\n---\n\n### 5. Reduction to \\(|X|\\ge 2\\)\n\nIf \\(|X|=1\\) then the desired inequality \\(|X|\\le fM\\) becomes \\(1\\le K\\), which is true because \\(K\\ge2\\). Hence the statement holds trivially for singletons. \n**From now on we assume \\(|X|\\ge2\\).** Then for any \\(x\\in X\\) the set \\(Y=X\\setminus\\{x\\}\\) is a non\u2011empty proper subset, and minimality yields \\(f(Y)d_i\\,\\}.\n\\]\n\n**Why the \\(T_i\\) cover \\(X\\).** \nTake an arbitrary \\(x\\in X\\) and consider \\(Y=X\\setminus\\{x\\}\\). Since \\(f(Y)d_i\\). Both \\(\\{x/a_i\\}\\) and \\(d_i\\) are multiples of \\(1/M\\); therefore their difference is at least \\(1/M\\), i.e. \\(\\{x/a_i\\}\\ge d_i+1/M.\n\nThus \n\n\\[\n\\sum_{x\\in T_i}\\{x/a_i\\}\\ge |T_i|(d_i+1/M),\\qquad \n\\sum_{x\\notin T_i}\\{x/a_i\\}\\le (|X|-|T_i|)d_i .\n\\]\n\n**Adding these two inequalities** gives \n\n\\[\nf+d_i = S_i \\ge |T_i|(d_i+1/M)+( |X|-|T_i|)d_i = |X|d_i+\\frac{|T_i|}{M}.\n\\]\n\nRearranging we obtain \n\n\\[\nf \\ge (|X|-1)d_i+\\frac{|T_i|}{M}. \\tag{3}\n\\]\n\n---\n\n### 8. Summation over all indices \n\nSumming (3) for \\(i=1,\\dots ,n\\) yields \n\n\\[\nn f \\ge (|X|-1)\\sum_{i=1}^{n}d_i + \\frac1M\\sum_{i=1}^{n}|T_i|\n = (|X|-1)\\Delta + \\frac1M\\sum_{i=1}^{n}|T_i|. \\tag{4}\n\\]\n\nBecause the \\(T_i\\) cover \\(X\\) (relation (2)), every element of \\(X\\) is counted at least once in \\(\\sum_i|T_i|\\); hence \n\n\\[\n\\sum_{i=1}^{n}|T_i|\\ge |X|. \\tag{5}\n\\]\n\nInserting (5) into (4) we get \n\n\\[\nn f \\ge (|X|-1)\\Delta + \\frac{|X|}{M},\n\\qquad\\text{i.e.}\\qquad\n(|X|-1)\\Delta \\le n f - \\frac{|X|}{M}. \\tag{6}\n\\]\n\n---\n\n### 9. Lower bound for \\(\\Delta\\) from Lemma\u202f1 \n\nFrom (1) we have \n\n\\[\n\\sum_{i=1}^{n}S_i = n f + \\Delta \\ge |X|\\,\\frac{n}{M},\n\\]\n\nhence \n\n\\[\n\\Delta \\ge n\\!\\left(\\frac{|X|}{M}-f\\right). \\tag{7}\n\\]\n\n(If the right\u2011hand side is negative the inequality is trivially true because \\(\\Delta\\ge0\\).)\n\n---\n\n### 10. Deriving a numeric inequality \n\nMultiply (7) by the positive number \\(|X|-1\\) and combine with (6):\n\n\\[\nn\\,(|X|-1)\\!\\left(\\frac{|X|}{M}-f\\right)\n \\le (|X|-1)\\Delta \\le n f - \\frac{|X|}{M}.\n\\]\n\nNow multiply by \\(M\\) (which is positive) to clear denominators. Set \n\n\\[\nt:=|X|,\\qquad K:=fM\\ (\\text{an integer}).\n\\]\n\nThe inequality becomes \n\n\\[\nn\\,(t-1)(t-K) \\le nK - t. \\tag{8}\n\\]\n\n---\n\n### 11. The decisive contradiction \n\nAssume, for the sake of contradiction, that \\(t>K\\). Then \n\n\\[\nt-K\\ge 1,\\qquad t-1\\ge K\\ (\\text{since }t\\ge K+1).\n\\]\n\nConsequently \n\n\\[\n\\text{LHS of (8)} = n\\,(t-1)(t-K) \\ge n\\cdot K\\cdot 1 = nK.\n\\]\n\nOn the other hand, because \\(t\\ge K+1\\),\n\n\\[\n\\text{RHS of (8)} = nK - t \\le nK - (K+1).\n\\]\n\nThus (8) would imply \n\n\\[\nnK \\le nK - (K+1),\n\\]\n\ni.e. \\(0 \\le -(K+1)\\), which is impossible (the right\u2011hand side is negative). \nHence our assumption \\(t>K\\) cannot hold; we must have \\(t\\le K\\).\n\n---\n\n### 12. Conclusion \n\nWe have proved that for \\(|X|\\ge2\\) the inequality \\(|X|\\le fM\\) follows. For \\(|X|=1\\) the inequality is obvious because \\(fM\\ge2>1\\). Therefore **every** minimal set \\(X\\) with \\(f(X)\\ge 2/a_n\\) satisfies \n\n\\[\n|X|\\le f(X)\\cdot M .\n\\]\n\n\u220e", "average_automatic_rating": 0.9296875, "human_rating": 0}} 4 | {"question": "The fractional distance between two points $(x_1,y_1)$ and $(x_2,y_2)$ is defined as\\[ \\sqrt{ \\left\\| x_1 - x_2 \\right\\|^2 + \\left\\| y_1 - y_2 \\right\\|^2},\\]where $\\left\\| x \\right\\|$ denotes the distance between $x$ and its nearest integer. Find the largest real $r$ such that there exists four points on the plane whose pairwise fractional distance are all at least $r$.", "problem_idx": "CMO2024-4", "model_prediction": {"proof": "### 1. Reduction to the unit square \n\nFor a real number \\(x\\) let \\(\\|x\\|=\\min_{k\\in\\mathbb Z}|x-k|\\) be the distance to the nearest integer. \nThe *fractional distance* between two points \\(P=(x_1,y_1),\\;Q=(x_2,y_2)\\) is \n\n\\[\nd(P,Q)=\\sqrt{\\;\\|x_1-x_2\\|^{2}+\\|y_1-y_2\\|^{2}\\; } .\n\\]\n\nBecause \\(\\|t+n\\|=\\|t\\|\\) for every integer \\(n\\), adding an integer to a coordinate does **not** change any distance. \nHence we may replace each coordinate by its fractional part and assume that all points lie in the unit square \n\n\\[\n[0,1)^2 .\n\\]\n\nFor two numbers \\(u,v\\in[0,1)\\) we have \n\n\\[\n\\|u-v\\|=\\min\\{\\,|u-v|,\\;1-|u-v|\\,\\}.\n\\]\n\n---\n\n### 2. A configuration achieving a large mutual distance \n\nSet \n\n\\[\nt=\\frac{2-\\sqrt3}{2}\\approx0.133975 .\n\\]\n\nConsider the four points \n\n\\[\nA=(0,0),\\qquad B=\\Bigl(\\frac12,\\,t\\Bigr),\\qquad\nC=\\Bigl(t,\\,\\frac12\\Bigr),\\qquad D=\\Bigl(\\frac12+t,\\;\\frac12+t\\Bigr).\n\\]\n\nAll coordinates are in \\([0,1)\\) because \\(t<\\frac12\\). \nTheir pairwise fractional distances are \n\n\\[\n\\begin{aligned}\nd(A,B)&=d(A,C)=d(B,D)=d(C,D)=\\sqrt{\\frac14+t^{2}},\\\\[2mm]\nd(A,D)&=d(B,C)=\\sqrt2\\Bigl(\\frac12-t\\Bigr).\n\\end{aligned}\n\\]\n\nNow \n\n\\[\nt^{2}+\\frac14 =\\frac{(2-\\sqrt3)^{2}}{4}+\\frac14\n =\\frac{4-4\\sqrt3+3}{4}+\\frac14\n =\\frac{8-4\\sqrt3}{4}=2-\\sqrt3,\n\\]\n\n\\[\n\\sqrt2\\Bigl(\\frac12-t\\Bigr)=\\sqrt2\\Bigl(\\frac{\\sqrt3-1}{2}\\Bigr)\n =\\frac{\\sqrt6-\\sqrt2}{2},\n\\]\n\nand \n\n\\[\n\\sqrt{2-\\sqrt3}= \\frac{\\sqrt6-\\sqrt2}{2}.\n\\]\n\nThus **all six distances are equal** to \n\n\\[\nr_{0}= \\frac{\\sqrt6-\\sqrt2}{2}\\approx0.517638 .\n\\]\n\nConsequently \n\n\\[\nr_{\\max}\\ge r_{0}.\n\\]\n\n---\n\n### 3. Upper bound \u2013 no larger \\(r\\) is possible \n\nAssume that four points \\(P_1,\\dots,P_4\\) in the unit square have pairwise fractional distances \\(\\ge r\\). \nWe will prove that necessarily \\(r\\le r_{0}\\).\n\nIf \\(r\\le\\frac12\\) the inequality \\(r\\le r_{0}\\) is trivial because \\(r_{0}>\\frac12\\). \nHence we may **suppose \\(r>\\frac12\\)** and define \n\n\\[\n\\delta:=\\sqrt{r^{2}-\\frac14}\\;>\\;0 .\n\\]\n\n---\n\n#### Lemma\u202f1 (Coordinate\u2011wise lower bound) \nFor any two points \\(P_i,P_j\\) let \\(\\Delta x=\\|x_i-x_j\\|\\) and \\(\\Delta y=\\|y_i-y_j\\|\\). \nThen \\(\\Delta x\\ge\\delta\\) and \\(\\Delta y\\ge\\delta\\).\n\n*Proof.* Because \\(\\|t\\|\\le\\frac12\\) for every real \\(t\\), we have \\(\\Delta y\\le\\frac12\\). \nIf \\(\\Delta x<\\delta\\) then \\(\\Delta x^{2}0).\n\\]\n\nDefine the four *cyclic gaps* \n\n\\[\na=u_2-u_1,\\; b=u_3-u_2,\\; c=u_4-u_3,\\; d=1-(u_4-u_1).\n\\]\n\nThese numbers are non\u2011negative, satisfy \n\n\\[\na+b+c+d=1,\n\\]\n\nand represent the lengths of the arcs between consecutive points on the circle \\(\\mathbb R/\\mathbb Z\\).\n\n---\n\n#### 3.2 Consequences of Lemma\u202f1 for the gaps \n\nFor the pairs that are neighbours in this order we have \n\n\\[\n\\|u_2-u_1\\|=\\min(a,1-a),\\;\\|u_3-u_2\\|=\\min(b,1-b),\\;\n\\|u_4-u_3\\|=\\min(c,1-c),\\;\\|u_4-u_1\\|=\\min(1-d,d)=\\min(d,1-d).\n\\]\n\nApplying Lemma\u202f1 to each of these four pairs gives \n\n\\[\n\\min(a,1-a)\\ge\\delta,\\;\\min(b,1-b)\\ge\\delta,\\;\n\\min(c,1-c)\\ge\\delta,\\;\\min(d,1-d)\\ge\\delta .\n\\]\n\nBecause a number is always at least its own minimum, we obtain \n\n\\[\na\\ge\\delta,\\; b\\ge\\delta,\\; c\\ge\\delta,\\; d\\ge\\delta .\\tag{1}\n\\]\n\n(We also get \\(a\\le1-\\delta\\) etc., but only the lower bounds are needed later.)\n\n---\n\n#### 3.3 Sum of squared \\(x\\)-distances \n\nLet \n\n\\[\nf(t)=\\bigl(\\min\\{t,1-t\\}\\bigr)^{2}\\qquad(0\\le t\\le1).\n\\]\n\nWith the gaps the six unordered pairs contribute \n\n\\[\nS_x:= \\sum_{i\\frac12\\));\n* if \\(r>\\frac12\\) and a configuration with mutual distances \\(\\ge r\\) exists, the above proof forces \\(r\\le r_{0}\\).\n\nThus **no** four points can have all pairwise fractional distances larger than \\(r_{0}\\); i.e. \n\n\\[\nr_{\\max}\\le r_{0}.\n\\]\n\n---\n\n### 4. Conclusion \n\nThe construction in Section\u202f2 shows \\(r_{\\max}\\ge r_{0}\\); the rigorous upper bound in Section\u202f3 shows \\(r_{\\max}\\le r_{0}\\). \nTherefore the largest real \\(r\\) for which such four points exist is \n\n\\[\n\\boxed{\\displaystyle r_{\\max}= \\frac{\\sqrt6-\\sqrt2}{2}} .\n\\]\n\n---", "average_automatic_rating": 1.0, "human_rating": 21}} 5 | {"question": "Let $p$ be a prime number and $f$ be a bijection from $\\left\\{0,1,\\ldots,p-1\\right\\}$ to itself. Suppose that for integers $a,b \\in \\left\\{0,1,\\ldots,p-1\\right\\}$, $|f(a) - f(b)|\\leqslant 2024$ if $p \\mid a^2 - b$. Prove that there exists infinite many $p$ such that there exists such an $f$ and there also exists infinite many $p$ such that there doesn't exist such an $f$.", "problem_idx": "CMO2024-5", "model_prediction": {"proof": "### 1. Existence of infinitely many primes with a suitable bijection \n\n#### 1.1 Infinitely many primes \\(p\\equiv 3\\pmod 4\\)\n\nAssume there are only finitely many primes congruent to \\(3\\) modulo \\(4\\); list them as \\(p_1,p_2,\\dots ,p_k\\). \nConsider \n\n\\[\nN = 4p_1p_2\\cdots p_k - 1 .\n\\]\n\n\\(N\\) is odd and \\(N\\equiv -1\\equiv 3\\pmod 4\\). \nFor each \\(p_i\\) we have \\(p_i\\mid N+1\\) because \\(N+1 = 4\\prod p_i\\). \nIf some \\(p_i\\) divided \\(N\\), then \\(p_i\\) would divide both \\(N\\) and \\(N+1\\); hence \\(p_i\\mid (N+1)-N = 1\\), impossible. \nThus **no** \\(p_i\\) divides \\(N\\).\n\nLet \\(q\\) be any prime divisor of \\(N\\). \\(q\\) is odd because \\(N\\) is odd. \nIf every prime divisor of \\(N\\) were \\(\\equiv 1\\pmod 4\\), then \\(N\\) itself would be \\(\\equiv 1\\pmod 4\\) (product of numbers \\(\\equiv 1\\pmod 4\\) is \\(\\equiv 1\\pmod 4\\)). This contradicts \\(N\\equiv 3\\pmod 4\\). \nTherefore \\(N\\) possesses at least one prime divisor \\(q\\) with \\(q\\equiv 3\\pmod 4\\). Because none of the \\(p_i\\) divide \\(N\\), this \\(q\\) is a new prime congruent to \\(3\\) modulo \\(4\\) \u2013 a contradiction to the assumption that the list contained all such primes. \nHence there are infinitely many primes \\(p\\equiv 3\\pmod 4\\).\n\n#### 1.2 Construction of \\(f\\) for a prime \\(p\\equiv 3\\pmod 4\\)\n\nFix such a prime \\(p\\) and write \\(\\mathbb Z_p=\\{0,1,\\dots ,p-1\\}\\). \nDefine the set of quadratic residues \n\n\\[\nQ = \\{x^{2}\\bmod p\\mid x\\in\\mathbb Z_p\\},\\qquad \nR = Q\\setminus\\{0\\}\\;(\\text{non\u2011zero residues}),\\qquad \nN = \\mathbb Z_p\\setminus Q\\;(\\text{non\u2011residues}).\n\\]\n\nIt is well known that \\(|Q| = \\frac{p+1}{2}\\); consequently \\(|R| = |N| = \\frac{p-1}{2}\\).\n\n---\n\n**Lemma 1.** The map \\(\\varphi : N \\to R,\\ \\varphi(a)=a^{2}\\pmod p\\) is a bijection.\n\n*Proof.* For \\(a\\in N\\), \\(a^{2}\\) is a quadratic residue and non\u2011zero (because \\(p\\nmid a\\)), so \\(\\varphi\\) maps into \\(R\\). \nSuppose \\(a,b\\in N\\) satisfy \\(a^{2}\\equiv b^{2}\\pmod p\\). Then \\((ab^{-1})^{2}\\equiv 1\\pmod p\\); hence \\(a\\equiv \\pm b\\pmod p\\). \n\nIf \\(a\\equiv -b\\), then \\(b\\equiv -a\\). Since \\(p\\equiv 3\\pmod 4\\), the Legendre symbol \\(\\bigl(\\frac{-1}{p}\\bigr)=(-1)^{(p-1)/2}=-1\\). Using multiplicativity,\n\\[\n\\Bigl(\\frac{-a}{p}\\Bigr)=\\Bigl(\\frac{-1}{p}\\Bigr)\\Bigl(\\frac{a}{p}\\Bigr)=(-1)\\cdot(-1)=1,\n\\]\nso \\(-a\\) is a quadratic residue. But then \\(b\\equiv -a\\) would be a residue, contradicting \\(b\\in N\\). \nTherefore we must have \\(a\\equiv b\\), proving injectivity. Because \\(|N|=|R|\\), \\(\\varphi\\) is also surjective. \u220e\n\n---\n\n**Lemma 2.** The squaring map \\(\\psi : R \\to R,\\ \\psi(r)=r^{2}\\pmod p\\) is a permutation of \\(R\\).\n\n*Proof.* The multiplicative group \\((\\mathbb Z/p\\mathbb Z)^{\\times}\\) is cyclic; its subgroup of quadratic residues \\(R\\) is therefore cyclic of order \\(\\frac{p-1}{2}\\). \nFor \\(p\\equiv 3\\pmod 4\\), \\(\\frac{p-1}{2}\\) is odd. In a cyclic group of odd order the map \\(x\\mapsto x^{2}\\) is an automorphism (the exponent \\(2\\) is coprime to the group order). Hence \\(\\psi\\) is bijective. \u220e\n\n---\n\nDecompose \\(\\psi\\) into disjoint cycles. Denote the cycles by \\(C_1,\\dots ,C_k\\) and let \\(L_i = |C_i|\\); thus \n\n\\[\n\\sum_{i=1}^{k}L_i = |R| = \\frac{p-1}{2}.\n\\]\n\nSet \\(S_0 = 0\\) and for \\(i\\ge 1\\) define \\(S_i = L_1 + \\cdots + L_i\\).\n\nFor each cycle we will use the even numbers \n\n\\[\nE_i = \\{\\,2S_{i-1},\\;2S_{i-1}+2,\\;\\dots ,\\;2(S_{i-1}+L_i-1)\\,\\}.\n\\]\n\nThe sets \\(E_i\\) are pairwise disjoint, their union is \\(\\{0,2,4,\\dots ,p-3\\}\\) (all even numbers except \\(p-1\\)), and \\(|E_i| = L_i\\).\n\nNow fix a cycle \\(C_i\\) and choose a starting element \\(r_0\\in C_i\\). Define recursively \n\n\\[\nr_{j+1} = r_j^{\\,2}\\pmod p\\qquad(j=0,1,\\dots ,L_i-2);\n\\]\n\nbecause \\(\\psi\\) is a permutation we have \\(r_{L_i-1}^{\\,2}=r_0\\). Thus \\((r_0,r_1,\\dots ,r_{L_i-1})\\) lists the elements of the cycle in the order they are visited by repeated squaring.\n\nWe assign an auxiliary integer \\(g(r_j)\\in\\{0,1,\\dots ,L_i-1\\}\\) as follows.\n\n* **Even length** \\(L_i = 2k\\): \n\n \\[\n \\begin{aligned}\n g(r_j) &= 2j &&(j=0,1,\\dots ,k-1),\\\\[2mm]\n g(r_{k+j}) &= L_i-1-2j &&(j=0,1,\\dots ,k-1).\n \\end{aligned}\n \\]\n\n* **Odd length** \\(L_i = 2k+1\\): \n\n \\[\n \\begin{aligned}\n g(r_j) &= 2j &&(j=0,1,\\dots ,k),\\\\[2mm]\n g(r_{k+1+j}) &= L_i-2-2j &&(j=0,1,\\dots ,k-1).\n \\end{aligned}\n \\]\n\nFor a cycle of length \\(1\\) (i.e. \\(k=0\\) in the odd case) this simply gives \\(g(r_0)=0\\).\n\nA direct inspection shows that in each case the values \\(g(r_j)\\) are exactly the integers \\(0,1,\\dots ,L_i-1\\) (hence \\(g\\) is a bijection from the cycle onto that set) and that for every \\(j\\) (indices taken modulo \\(L_i\\))\n\n\\[\n|g(r_j)-g(r_{j+1})|\\le 2. \\tag{1}\n\\]\n\n(For even length the only differences of \\(1\\) occur between \\(r_{k-1}\\) and \\(r_k\\) and between \\(r_{2k-1}\\) and \\(r_0\\); all other consecutive indices differ by \\(2\\). For odd length the only differences of \\(1\\) occur between \\(r_k\\) and \\(r_{k+1}\\) and between \\(r_{2k}\\) and \\(r_0\\); again all other steps differ by \\(2\\).)\n\nNow define for every \\(r\\in R\\)\n\n\\[\nf(r) = 2\\bigl(S_{i-1}+g(r)\\bigr)\\qquad\\text{if } r\\in C_i.\n\\]\n\nBecause \\(g(r)\\) runs through \\(\\{0,\\dots ,L_i-1\\}\\) as \\(r\\) runs through \\(C_i\\), the values \\(f(r)\\) for \\(r\\in C_i\\) are exactly the even numbers in \\(E_i\\). Consequently \\(f\\) maps \\(R\\) bijectively onto the set \\(\\{0,2,4,\\dots ,p-3\\}\\).\n\nIf \\(r\\in R\\) and \\(s = r^{2}\\) (the successor of \\(r\\) in its cycle), then by (1)\n\n\\[\n|f(r)-f(s)| = 2\\,|g(r)-g(s)| \\le 2\\cdot 2 = 4 \\le 2024. \\tag{2}\n\\]\n\n---\n\n**The element \\(0\\).** Set \n\n\\[\nf(0) = p-1.\n\\]\n\n**Non\u2011residues.** For \\(a\\in N\\) define \n\n\\[\nf(a) = f(a^{2}) + 1,\n\\]\n\nwhere \\(a^{2}\\) denotes the element of \\(R\\) obtained by squaring modulo \\(p\\) (Lemma\u202f1 guarantees \\(a^{2}\\in R\\)). Because \\(f(a^{2})\\) is even, \\(f(a)\\) is odd.\n\n---\n\n**Bijectivity.** \n- \\(f|_{R}\\) is a bijection onto the evens \\(\\{0,2,\\dots ,p-3\\}\\). \n- Lemma\u202f1 gives a bijection \\(\\varphi : N\\to R\\). Composing with \\(f|_{R}\\) and adding \\(1\\) yields a bijection from \\(N\\) onto the odds \\(\\{1,3,\\dots ,p-2\\}\\). \n- Finally \\(f(0)=p-1\\) is the unique even number \\(p-1\\) not used for \\(R\\). \n\nThe three images \\(\\{p-1\\},\\{0,2,\\dots ,p-3\\},\\{1,3,\\dots ,p-2\\}\\) partition \\(\\{0,1,\\dots ,p-1\\}\\); therefore \\(f\\) is a permutation of this set.\n\n---\n\n**Verification of the required bound.** \nLet \\(a,b\\in\\mathbb Z_p\\) satisfy \\(p\\mid a^{2}-b\\). Because \\(b\\) is the unique element of \\(\\mathbb Z_p\\) congruent to \\(a^{2}\\) modulo \\(p\\), we have \\(b\\equiv a^{2}\\pmod p\\) and we distinguish three cases.\n\n* \\(a=0\\): then \\(b=0\\) and \\(|f(0)-f(0)|=0\\le2024\\). \n* \\(a\\in R\\): then \\(b=a^{2}\\in R\\) and (2) gives \\(|f(a)-f(b)|\\le4\\le2024\\). \n* \\(a\\in N\\): then \\(b=a^{2}\\in R\\) and \\(|f(a)-f(b)| = |(f(a^{2})+1)-f(a^{2})| = 1\\le2024\\).\n\nThus for every prime \\(p\\equiv 3\\pmod 4\\) we have constructed a bijection \\(f\\) satisfying the condition. Together with the infinitude of such primes proved in \u00a71.1 we conclude:\n\n\\[\n\\text{There are infinitely many primes }p\\text{ for which a suitable bijection }f\\text{ exists.}\n\\]\n\n---\n\n### 2. Non\u2011existence for infinitely many primes \n\n#### 2.1 A necessary condition \n\nLet \\(p\\) be an odd prime and write \n\n\\[\np-1 = 2^{s}\\,m\\qquad(s\\ge 1,\\;m\\text{ odd}).\n\\]\n\nThe multiplicative group \\((\\mathbb Z/p\\mathbb Z)^{\\times}\\) is cyclic of order \\(p-1\\). Consequently it contains a unique subgroup of order \\(2^{s}\\); call it \\(H\\). \\(H\\) is cyclic, and the set \n\n\\[\nA = \\{\\,x\\in (\\mathbb Z/p\\mathbb Z)^{\\times}\\mid \\operatorname{ord}(x)=2^{s}\\,\\}\n\\]\n\nis exactly the set of generators of \\(H\\). Hence \n\n\\[\n|A| = \\varphi(2^{s}) = 2^{s-1}.\n\\]\n\nAssume that a bijection \\(f:\\mathbb Z_p\\to\\{0,1,\\dots ,p-1\\}\\) satisfies \n\n\\[\np\\mid a^{2}-b\\;\\Longrightarrow\\;|f(a)-f(b)|\\le 2024. \\tag{\u2217}\n\\]\n\nTake any \\(a\\in A\\) and consider the chain obtained by repeated squaring:\n\n\\[\na_0 = a,\\quad a_1 = a^{2}\\pmod p,\\quad a_2 = a_1^{2}\\pmod p = a^{4}\\pmod p,\\;\\dots\\;,\\;a_s = a^{2^{s}}\\equiv 1\\pmod p.\n\\]\n\n(All \\(a_i\\) are taken as the representatives in \\(\\{0,\\dots ,p-1\\}\\).) \n\nFor each \\(i=0,\\dots ,s-1\\) we have \\(a_{i+1}\\equiv a_i^{2}\\pmod p\\); therefore (\u2217) yields \n\n\\[\n|f(a_i)-f(a_{i+1})|\\le 2024.\n\\]\n\nApplying the triangle inequality repeatedly gives \n\n\\[\n|f(a)-f(1)| = |f(a_0)-f(a_s)|\n \\le \\sum_{i=0}^{s-1}|f(a_i)-f(a_{i+1})|\n \\le s\\cdot 2024. \\tag{3}\n\\]\n\nDefine \n\n\\[\nJ = \\{\\,x\\in\\{0,1,\\dots ,p-1\\}\\mid |x-f(1)|\\le s\\cdot2024\\,\\}.\n\\]\n\nFrom (3) we have \\(f(a)\\in J\\) for every \\(a\\in A\\). Because \\(f\\) is injective, the values \\(f(a)\\;(a\\in A)\\) are pairwise distinct; hence \n\n\\[\n|J|\\ \\ge\\ |A| = 2^{s-1}. \\tag{4}\n\\]\n\nOn the other hand, \\(J\\) is a subset of the real interval \\(I = [f(1)-s\\cdot2024,\\ f(1)+s\\cdot2024]\\). An interval of length \\(L = 2s\\cdot2024\\) can contain at most \\(L+1 = 2s\\cdot2024+1\\) integers. Thus \n\n\\[\n|J|\\ \\le\\ 2s\\cdot2024+1. \\tag{5}\n\\]\n\nCombining (4) and (5) we obtain the **necessary condition**\n\n\\[\n2^{s-1}\\ \\le\\ 2s\\cdot2024+1. \\tag{6}\n\\]\n\n#### 2.2 When does (6) fail? \n\nCompute for \\(s=18\\):\n\n\\[\n2^{s-1}=2^{17}=131072,\\qquad 2s\\cdot2024+1 = 2\\cdot18\\cdot2024+1 = 72865.\n\\]\n\nThus \\(2^{17} > 72865\\); inequality (6) is false for \\(s=18\\).\n\nWe show that once (6) fails for some \\(s\\ge 3\\), it also fails for \\(s+1\\). \nAssume \\(2^{s-1} > 2s\\cdot2024+1\\). Multiplying by \\(2\\) gives \n\n\\[\n2^{s} > 4s\\cdot2024+2.\n\\]\n\nCompare the right\u2011hand side with the bound needed for \\(s+1\\):\n\n\\[\n4s\\cdot2024+2 - \\bigl(2(s+1)\\cdot2024+1\\bigr) = 2s\\cdot2024 - 4047.\n\\]\n\nFor \\(s\\ge 3\\), \\(2s\\cdot2024 \\ge 2\\cdot3\\cdot2024 = 12144\\), so the difference is positive. Hence \n\n\\[\n4s\\cdot2024+2 > 2(s+1)\\cdot2024+1,\n\\]\n\nand together with \\(2^{s} > 4s\\cdot2024+2\\) we obtain \n\n\\[\n2^{s} > 2(s+1)\\cdot2024+1,\n\\]\n\ni.e. \\(2^{(s+1)-1} > 2(s+1)\\cdot2024+1\\). So the failure propagates to \\(s+1\\).\n\nSince (6) fails for \\(s=18\\), by induction it fails for every integer \\(s\\ge 18\\). \n\nConsequently **no** bijection satisfying (\u2217) can exist for any prime \\(p\\) with \\(v_{2}(p-1)=s\\ge 18\\) (equivalently, \\(2^{18}\\mid p-1\\)).\n\n#### 2.3 Infinitely many primes with \\(v_{2}(p-1)\\ge 18\\)\n\nWe use the Fermat numbers \n\n\\[\nF_n = 2^{2^{n}} + 1\\qquad(n\\ge 0).\n\\]\n\n**Coprimality.** The numbers \\(F_n\\) are pairwise coprime. \nIndeed, one proves by induction that \n\n\\[\nF_n = \\prod_{i=0}^{n-1}F_i + 2\\qquad(n\\ge 1).\n\\]\n\n(For \\(n=1\\): \\(\\prod_{i=0}^{0}F_i = F_0 = 3\\) and \\(3+2=5 = F_1\\). Assuming the formula for \\(n\\), then \n\\[\n\\prod_{i=0}^{n}F_i = F_n\\prod_{i=0}^{n-1}F_i = F_n(F_n-2) = F_n^{2}-2F_n,\n\\]\nwhile \n\\[\nF_{n+1} = (2^{2^{n}})^{2}+1 = (F_n-1)^{2}+1 = F_n^{2}-2F_n+2 = \\prod_{i=0}^{n}F_i + 2,\n\\]\ncompleting the induction.) \n\nNow if a prime \\(p\\) divided both \\(F_k\\) and \\(F_n\\) with \\(k1\\) and is odd, it possesses at least one odd prime divisor \\(p\\). From \\(F_n\\equiv 0\\pmod p\\) we obtain \n\n\\[\n2^{2^{n}}\\equiv -1\\pmod p.\n\\]\n\nSquaring gives \\(2^{2^{n+1}}\\equiv 1\\pmod p\\). Thus the order \\(\\operatorname{ord}_p(2)\\) divides \\(2^{n+1}\\). It cannot divide \\(2^{n}\\); otherwise we would have \\(2^{2^{n}}\\equiv 1\\pmod p\\), contradicting the congruence above. Hence \\(\\operatorname{ord}_p(2)=2^{n+1}\\). \n\nBy Fermat\u2019s little theorem, \\(\\operatorname{ord}_p(2)\\mid p-1\\); therefore \\(2^{n+1}\\mid(p-1)\\). In particular \n\n\\[\nv_{2}(p-1)\\ \\ge\\ n+1\\ \\ge\\ 18.\n\\]\n\n**Infiniteness.** Because the Fermat numbers are pairwise coprime, the prime divisors of distinct \\(F_n\\) are distinct. For each \\(n\\ge 17\\) pick one prime divisor \\(p_n\\) of \\(F_n\\). Then \\(\\{p_n\\mid n\\ge 17\\}\\) is an infinite set of distinct primes, each satisfying \\(v_{2}(p_n-1)\\ge 18\\). \n\nThus there are infinitely many primes for which the necessary condition (6) is violated, and consequently no bijection \\(f\\) with the required property can exist for those primes.\n\n---\n\n### 3. Conclusion \n\nWe have proved: \n\n* There are infinitely many primes (all primes congruent to \\(3\\) modulo \\(4\\)) for which a bijection \\(f\\) satisfying \\(|f(a)-f(b)|\\le 2024\\) whenever \\(p\\mid a^{2}-b\\) exists. \n* There are infinitely many primes (e.g. the prime divisors of the Fermat numbers \\(F_n\\) with \\(n\\ge 17\\)) for which such a bijection cannot exist. \n\nHence the statement of the problem holds. \u220e", "average_automatic_rating": 1.0, "human_rating": 21}} 6 | {"question": "Let $a_1, a_2, \\ldots, a_n$ be real numbers such that $\\sum_{i=1}^n a_i = n$, $\\sum_{i = 1}^n a_i^2 = 2n$, $\\sum_{i=1}^n a_i^3 = 3n$.\n(i) Find the largest constant $C$, such that for all $n \\geqslant 4$,\\[ \\max \\left\\{ a_1, a_2, \\ldots, a_n \\right\\} - \\min \\left\\{ a_1, a_2, \\ldots, a_n \\right\\} \\geqslant C. \\](ii) Prove that there exists a positive constant $C_2$, such that\\[ \\max \\left\\{ a_1, a_2, \\ldots, a_n \\right\\} - \\min \\left\\{ a_1, a_2, \\ldots, a_n \\right\\} \\geqslant C + C_2 n^{-\\frac 32}, \\]where $C$ is the constant determined in (i).", "problem_idx": "CMO2024-6", "model_prediction": {"proof": "### Part\u202f(i) \n\nPut \n\n\\[\nd_i=a_i-1\\qquad(i=1,\\dots ,n).\n\\]\n\nThen \n\n\\[\n\\sum_{i=1}^{n}d_i =0,\\qquad \n\\sum_{i=1}^{n}d_i^{2}=n,\\qquad \n\\sum_{i=1}^{n}d_i^{3}=-n. \\tag{0}\n\\]\n\nDefine \n\n\\[\nu=\\max_i d_i,\\qquad v=-\\min_i d_i\\;(>0),\\qquad \nD=u+v=\\max_i a_i-\\min_i a_i .\n\\]\n\nAll \\(d_i\\) lie in \\([-v,u]\\); hence for every \\(i\\)\n\n\\[\nd_i+v\\ge 0,\\qquad u-d_i\\ge 0 .\n\\]\n\n---\n**Three non\u2011negative sums** \n\n\\[\n\\begin{aligned}\nS_1&:=\\sum_{i=1}^{n}(d_i+v)^{2}(u-d_i)\\ge 0,\\\\[2mm]\nS_2&:=\\sum_{i=1}^{n}(d_i+v)(u-d_i)^{2}\\ge 0,\\\\[2mm]\nT&:=\\sum_{i=1}^{n}(d_i+v)(u-d_i)\\ge 0 .\n\\end{aligned}\n\\]\n\nExpanding each sum and using (0) gives \n\n\\[\n\\begin{aligned}\nS_1&=\\sum_i\\bigl(d_i^{2}+2v d_i+v^{2}\\bigr)(u-d_i)\\\\\n &=u\\sum d_i^{2}+2vu\\sum d_i+u v^{2}n-\\sum d_i^{3}-2v\\sum d_i^{2}-v^{2}\\sum d_i\\\\\n &=un+0+u v^{2}n-(-n)-2vn-0\\\\\n &=n\\bigl(uv^{2}+u+1-2v\\bigr),\\\\[2mm]\nS_2&=\\sum_i(d_i+v)(u^{2}-2u d_i+d_i^{2})\\\\\n &=u^{2}\\sum d_i-2u\\sum d_i^{2}+\\sum d_i^{3}+v u^{2}n-2uv\\sum d_i+v\\sum d_i^{2}\\\\\n &=0-2un+(-n)+v u^{2}n-0+vn\\\\\n &=n\\bigl(v u^{2}+v-2u-1\\bigr),\\\\[2mm]\nT&=\\sum_i\\bigl((d_i+v)u-(d_i+v)d_i\\bigr)\n =u\\sum(d_i+v)-\\sum(d_i^{2}+v d_i)\\\\\n &=u\\bigl(\\sum d_i+n v\\bigr)-\\bigl(\\sum d_i^{2}+v\\sum d_i\\bigr)\n =u(0+n v)-(n+0)=n(uv-1).\n\\end{aligned}\n\\]\n\nBecause the three sums are non\u2011negative we obtain \n\n\\[\n\\boxed{uv^{2}+u+1\\ge 2v}\\tag{1}\n\\] \n\n\\[\n\\boxed{v u^{2}+v\\ge 2u+1}\\tag{2}\n\\] \n\n\\[\n\\boxed{uv\\ge 1}\\tag{3}\n\\]\n\n---\n**Consequences for \\(u,v\\)** \n\nFrom (2) \n\n\\[\nv\\ge\\frac{2u+1}{u^{2}+1}=:f(u). \\tag{4}\n\\]\n\nFrom (3) \n\n\\[\nv\\ge\\frac{1}{u}. \\tag{5}\n\\]\n\nThus \n\n\\[\nv\\ge\\max\\!\\Bigl(f(u),\\frac1u\\Bigr)\\quad\\Longrightarrow\\quad \nD=u+v\\ge u+\\max\\!\\Bigl(f(u),\\frac1u\\Bigr)=:\\varphi(u). \\tag{6}\n\\]\n\n---\n**Minimising \\(\\varphi(u)\\)** \n\nThe equation \\(f(u)=1/u\\) is \n\n\\[\n\\frac{2u+1}{u^{2}+1}=\\frac1u\\;\\Longleftrightarrow\\;u^{2}+u-1=0,\n\\]\n\nwhose positive root is \n\n\\[\nu_{0}=\\frac{\\sqrt5-1}{2}\\approx0.618,\\qquad \nv_{0}=u_{0}+1=\\frac{\\sqrt5+1}{2}\\approx1.618 .\n\\]\n\n*For \\(02(u^{2}+u-1)\\qquad(\\text{because }u^{4}-2u+3>0\\;\\forall u\\ge0),\n\\]\n\nso \\(\\varphi'(u)>0\\). Hence \\(\\varphi\\) is strictly increasing on \\([u_{0},\\infty)\\) and \n\n\\[\n\\varphi(u)\\ge\\varphi(u_{0})=\\sqrt5 .\n\\]\n\nIn **both** cases we have proved \n\n\\[\n\\boxed{\\;D\\ge\\sqrt5\\;}. \\tag{7}\n\\]\n\n---\n**Sharpness \u2013 the constant cannot be larger** \n\nLet \n\n\\[\nu_{0}=\\frac{\\sqrt5-1}{2},\\;v_{0}=u_{0}+1,\\;D_{0}=u_{0}+v_{0}=\\sqrt5 .\n\\]\n\nFor any \\(\\varepsilon>0\\) choose a **rational** number \\(u\\) with \n\n\\[\nu>u_{0},\\qquad |u-u_{0}|<\\frac{\\varepsilon}{4}.\n\\]\n\nSet \\(v=u+1\\) and \\(D=u+v=2u+1\\); then \\(|D-\\sqrt5|=2|u-u_{0}|<\\varepsilon/2\\).\n\nBecause \\(u\\) is rational, the numbers \n\n\\[\n\\alpha=\\frac{1}{uD},\\qquad \\beta=\\frac{1}{vD}\n\\]\n\nare rational. Write \\(\\alpha=\\frac{a_{1}}{b_{1}},\\;\\beta=\\frac{a_{2}}{b_{2}}\\) in lowest terms and let \\(L=\\operatorname{lcm}(b_{1},b_{2})\\). Choose an integer \\(N\\) that is a multiple of \\(L\\) and satisfies \\(N\\ge4\\) (e.g. \\(N=L\\) if \\(L\\ge4\\), otherwise \\(N=4L\\)). \nNow set \n\n\\[\nn:=N,\\qquad r:=N\\alpha,\\; s:=N\\beta,\\; t:=N-r-s .\n\\]\n\nSince \\(u>u_{0}\\) implies \\(uv>1\\) and therefore \\(\\alpha+\\beta=1/(uv)<1\\), we have \\(t>0\\). \nAll three numbers \\(r,s,t\\) are non\u2011negative integers and \\(r+s+t=n\\).\n\nConstruct the \\(a_i\\) as follows: \n\n* \\(r\\) copies of \\(1+u\\) (i.e. \\(d_i=u\\)), \n* \\(s\\) copies of \\(1-v\\) (i.e. \\(d_i=-v\\)), \n* \\(t\\) copies of \\(1\\) (i.e. \\(d_i=0\\)).\n\nThen \n\n\\[\n\\begin{aligned}\n\\sum a_i &= r(1+u)+s(1-v)+t\\cdot1 = n + (ru-sv) = n,\\\\[2mm]\n\\sum a_i^{2} &= r(1+u)^{2}+s(1-v)^{2}+t\\cdot1^{2} \n = n + 2(ru-sv) + (ru^{2}+sv^{2}) = n+0+n = 2n,\\\\[2mm]\n\\sum a_i^{3} &= r(1+u)^{3}+s(1-v)^{3}+t\\cdot1^{3} \\\\\n &= n + 3(ru-sv) + 3(ru^{2}+sv^{2}) + (ru^{3}-sv^{3}) \n = n+0+3n+(-n)=3n .\n\\end{aligned}\n\\]\n\n(The identities \\(ru=sv=n/D\\) and \\(v=u+1\\) guarantee the third\u2011moment condition.) \n\nThe range of this set is \n\n\\[\n\\max a_i-\\min a_i = (1+u)-(1-v)=u+v = D < \\sqrt5+\\varepsilon .\n\\]\n\nSince \\(\\varepsilon>0\\) was arbitrary, no constant larger than \\(\\sqrt5\\) can work for **all** admissible sequences. Together with (7) we obtain \n\n\\[\n\\boxed{C=\\sqrt5}.\n\\]\n\n---\n\n### Part\u202f(ii) \n\nFix an integer \\(n\\ge4\\) and consider \n\n\\[\n\\mathcal{F}_n=\\{(a_1,\\dots ,a_n)\\in\\mathbb R^{n}\\mid \n\\sum a_i=n,\\;\\sum a_i^{2}=2n,\\;\\sum a_i^{3}=3n\\}.\n\\]\n\nBecause \\(\\sum a_i^{2}=2n\\) implies \\(|a_i|\\le\\sqrt{2n}\\), \\(\\mathcal{F}_n\\) is a closed bounded subset of \\(\\mathbb R^{n}\\) and therefore **compact**. \nThe function \n\n\\[\nR(a)=\\max_i a_i-\\min_i a_i\n\\]\n\nis continuous; hence it attains its minimum on \\(\\mathcal{F}_n\\). \nLet \\(a\\) be a minimiser and denote \n\n\\[\nM=\\max_i a_i,\\qquad m=\\min_i a_i,\\qquad D=M-m .\n\\]\n\n---\n#### 1. Basic properties \n\n* **Location of\u202f1.** \n If all \\(a_i\\ge 1\\) then \\(a_i-1\\ge0\\) and \\(\\sum (a_i-1)=0\\) forces \\(a_i=1\\) for every \\(i\\), contradicting \\(\\sum a_i^{2}=2n\\). \n The same argument shows that not all \\(a_i\\le 1\\). Consequently there exist indices with \\(a_i>1\\) and with \\(a_i<1\\); therefore \n\n \\[\n m<10,\\;v=1-m>0\\).\n\n* **Two\u2011value configurations are impossible.** \n Assume, for contradiction, that a feasible vector consists only of the two values \\(M\\) and \\(m\\). \n Let \\(r=\\#\\{i:a_i=M\\},\\;s=\\#\\{i:a_i=m\\}\\) (\\(r,s\\ge1,\\;r+s=n\\)). \n Translating the moment conditions with \\(u,v\\) gives \n\n \\[\n \\begin{aligned}\n r u - s v &=0,\\\\\n r u^{2}+ s v^{2} &= n,\\\\\n r u^{3}- s v^{3} &= -n. \\tag{\u2020}\n \\end{aligned}\n \\]\n\n From the first two relations we obtain \\(r u = s v =:K\\) and \\(K(u+v)=n\\), i.e. \\(K=n/D\\). \n Substituting \\(r=K/u,\\;s=K/v\\) into \\(r+s=n\\) yields \n\n \\[\n \\frac{K}{u}+\\frac{K}{v}=n\\;\\Longrightarrow\\; \\frac{n}{D}\\Bigl(\\frac1u+\\frac1v\\Bigr)=n\n \\;\\Longrightarrow\\; \\frac{1}{u}+\\frac1v = D\n \\;\\Longrightarrow\\; \\frac{u+v}{uv}=D\n \\;\\Longrightarrow\\; \\frac{D}{uv}=D\\;\\Longrightarrow\\; uv=1 .\n \\]\n\n Using the third relation of (\u2020) we get \n\n \\[\n K(u^{2}-v^{2})=-n\\;\\Longrightarrow\\;\\frac{n}{D}(u^{2}-v^{2})=-n\n \\;\\Longrightarrow\\;u^{2}-v^{2}=-D .\n \\]\n\n Because \\(D=u+v\\), this simplifies to \\(u-v=-1\\), i.e. \\(v=u+1\\). \n Together with \\(uv=1\\) we obtain \\(u^{2}+u-1=0\\) and \n\n \\[\n u=u_{0}=\\frac{\\sqrt5-1}{2},\\qquad v=v_{0}=u_{0}+1=\\frac{\\sqrt5+1}{2},\\qquad D=\\sqrt5 .\n \\]\n\n Finally \\(r=K/u=n/(uD)=n/(u_{0}\\sqrt5)\\), which is **irrational** for any integer \\(n\\) \u2013 contradicting that \\(r\\) must be an integer. \n Hence **no feasible vector can consist of only two values**. \n Consequently every feasible vector (and in particular our minimiser) contains at least three distinct numbers, and therefore there exists an index with \n\n \\[\n m0\\).\n\nSince \\(\\lambda_0>0\\) we may divide the whole system by \\(\\lambda_0\\) and rename the scaled multipliers. Equivalently, we set \\(\\lambda_0=1\\) without loss of generality. Then \n\n\\[\n\\sum_{i=1}^n \\alpha_i = \\sum_{i=1}^n \\beta_i = 1, \\tag{2}\n\\]\n\nand (F1) becomes \n\n\\[\n\\lambda + 2\\mu a_i + 3\\nu a_i^2 + \\alpha_i - \\beta_i = 0\\qquad(i=1,\\dots,n), \\tag{4}\n\\]\n\nwhere \\(\\lambda=\\lambda_1/\\lambda_0,\\;\\mu=\\lambda_2/\\lambda_0,\\;\\nu=\\lambda_3/\\lambda_0\\).\n\nDefine \\(Q(x)=\\lambda + 2\\mu x + 3\\nu x^2\\). Then (4) reads \n\n\\[\nQ(a_i) = -\\alpha_i + \\beta_i. \\tag{5}\n\\]\n\n---\n#### 5. Consequences of complementary slackness \n\nLet \\(A=\\{i:a_i=M\\},\\;B=\\{i:a_i=m\\}\\) and set \\(r=|A|,\\;s=|B|\\) (both \\(\\ge1\\)). \nComplementary slackness gives \\(\\alpha_i=0\\) for \\(i\\notin A\\) and \\(\\beta_i=0\\) for \\(i\\notin B\\). Moreover, for \\(i\\in A\\) we have \\(\\beta_i=0\\), so (5) yields \\(Q(M)=-\\alpha_i\\le0\\); summing over \\(A\\) and using (2) gives \n\n\\[\nr\\,Q(M)+\\sum_{i\\in A}\\alpha_i =0 \\;\\Longrightarrow\\; r\\,Q(M)+1=0 \\;\\Longrightarrow\\; Q(M)=-\\frac1r<0. \\tag{6}\n\\]\n\nAnalogously, for \\(i\\in B\\) we have \\(\\alpha_i=0\\), \\(Q(m)=\\beta_i\\ge0\\) and \n\n\\[\ns\\,Q(m)-\\sum_{i\\in B}\\beta_i =0 \\;\\Longrightarrow\\; s\\,Q(m)-1=0 \\;\\Longrightarrow\\; Q(m)=\\frac1s>0. \\tag{7}\n\\]\n\nFor any index with \\(m0,\\;Q(M)<0\\) and \\(m<10\\).** From (16), \\(Q(m)=3\\nu\\,(m-1)(m-r)>0\\). Since \\(m-1<0\\), we must have \\(m-r<0\\Rightarrow r>m\\). \n Similarly \\(Q(M)=3\\nu\\,(M-1)(M-r)<0\\) and \\(M-1>0\\) give \\(M-r<0\\Rightarrow r>M\\). Hence \\(r>M\\).\n\n* **Case \\(\\nu<0\\).** Now \\(3\\nu<0\\). \\(Q(m)>0\\) implies \\((m-1)(m-r)<0\\); with \\(m-1<0\\) this yields \\(m-r>0\\Rightarrow r0\\); with \\(M-1>0\\) we obtain \\(M-r>0\\Rightarrow r0)\\) the moment conditions become \n\n\\[\n\\begin{aligned}\nr u - s v &=0, \\tag{E1}\\\\\nr u^{2}+ s v^{2} &= n, \\tag{E2}\\\\\nr u^{3}- s v^{3} &= -n. \\tag{E3}\n\\end{aligned}\n\\]\n\nSet \\(K = r u = s v\\). From (E2), \\(K(u+v)=n\\), i.e. \\(K = n/D\\) where \\(D=u+v\\). Hence \n\n\\[\nr = \\frac{K}{u}= \\frac{n}{u D},\\qquad s = \\frac{n}{v D}. \\tag{17}\n\\]\n\nSubstituting (17) into (E3) gives \n\n\\[\nK(u^{2}-v^{2}) = -n \\;\\Longrightarrow\\; \\frac{n}{D}(u^{2}-v^{2}) = -n\n\\;\\Longrightarrow\\; u^{2}-v^{2} = -D.\n\\]\n\nSince \\(u^{2}-v^{2}=(u-v)(u+v)=(u-v)D\\), we obtain \\(u-v=-1\\), i.e. \n\n\\[\nv = u+1,\\qquad D = 2u+1. \\tag{18}\n\\]\n\nThe number of entries different from \\(1\\) is \\(S = r+s\\). Using (17),\n\n\\[\nS = \\frac{n}{u D} + \\frac{n}{v D}\n = \\frac{n}{D}\\Bigl(\\frac1u+\\frac1v\\Bigr)\n = \\frac{n}{D}\\cdot\\frac{u+v}{uv}\n = \\frac{n}{uv}. \\tag{19}\n\\]\n\nThus \\(uv = n/S\\). Now compute \\(D^{2}\\):\n\n\\[\nD^{2} = (2u+1)^{2} = 4u^{2}+4u+1 = 4u(u+1)+1 = 4uv+1 = 1 + \\frac{4n}{S}. \\tag{20}\n\\]\n\n---\n#### 11. A lower bound involving \\(n\\) \n\nBecause \\(t\\ge1\\) we have \\(S = n-t \\le n-1\\). Therefore (20) yields \n\n\\[\nD^{2} \\ge 1 + \\frac{4n}{\\,n-1\\,}.\n\\]\n\nA simple algebraic manipulation shows \n\n\\[\n1 + \\frac{4n}{n-1} = 5 + \\frac{4}{n-1}.\n\\]\n\nSet \\(\\delta = \\frac{4}{n-1}>0\\). Then \\(D \\ge \\sqrt{5+\\delta}\\) and \n\n\\[\nD - \\sqrt5 \\ge \\sqrt{5+\\delta} - \\sqrt5 = \\frac{\\delta}{\\sqrt{5+\\delta} + \\sqrt5}. \\tag{21}\n\\]\n\n---\n#### 12. Extracting the required asymptotic estimate \n\nFor any \\(\\delta\\ge0\\) we have \n\n\\[\n\\sqrt{5+\\delta} + \\sqrt5 \\le 2\\sqrt5 + \\delta,\n\\]\n\nbecause \\((2\\sqrt5+\\delta)-(\\sqrt{5+\\delta}+\\sqrt5)=\\sqrt5+\\delta-\\sqrt{5+\\delta}\\) is an increasing function of \\(\\delta\\) vanishing at \\(\\delta=0\\). Hence \n\n\\[\nD - \\sqrt5 \\ge \\frac{\\delta}{2\\sqrt5 + \\delta}. \\tag{22}\n\\]\n\nSubstituting \\(\\delta = 4/(n-1)\\) gives \n\n\\[\nD - \\sqrt5 \\ge \\frac{4/(n-1)}{2\\sqrt5 + 4/(n-1)}\n = \\frac{4}{2\\sqrt5\\,(n-1) + 4}.\n\\]\n\nSince \\(2\\sqrt5\\,(n-1) + 4 < 2\\sqrt5\\,n\\) (because \\(2\\sqrt5 n - [2\\sqrt5\\,(n-1)+4] = 2\\sqrt5-4 >0\\)), we obtain \n\n\\[\n\\frac{4}{2\\sqrt5\\,(n-1) + 4} \\;>\\; \\frac{4}{2\\sqrt5\\,n}\n = \\frac{2}{\\sqrt5}\\,\\frac1n.\n\\]\n\nThus \\(D - \\sqrt5 > \\frac{2}{\\sqrt5}\\,\\frac1n\\), and consequently \n\n\\[\nD - \\sqrt5 \\ge \\frac{2}{\\sqrt5}\\,\\frac1n. \\tag{23}\n\\]\n\nFor every integer \\(n\\ge 1\\) we have \\(\\frac1n \\ge n^{-3/2}\\) (because \\(n^{1/2}\\ge1\\)). Applying this to (23) yields \n\n\\[\nD - \\sqrt5 \\ge \\frac{2}{\\sqrt5}\\,n^{-3/2}.\n\\]\n\nFinally,\n\n\\[\n\\boxed{\\;\\max_i a_i - \\min_i a_i \\ge \\sqrt5 + \\frac{2}{\\sqrt5}\\,n^{-3/2}\\; }.\n\\]\n\nThus we can take \\(C_2 = \\dfrac{2}{\\sqrt5}\\) (any smaller positive constant also works). This completes the proof of part\u202f(ii). \u220e", "average_automatic_rating": 0.7109375, "human_rating": 9}} 7 | --------------------------------------------------------------------------------