每日科技文摘Daily Tech Digest

作弊者的数学The Mathematics of Cheating

发布于 2026-11-09Published 2026-11-09

今日深读Today's Deep Read

最优洗牌:一副无论怎么切都赢的牌The Optimal Stack: A Deck That Wins from Every Cut

2011 年夏天,Jeremy Kun 在泳池边和朋友打德州扑克,聊起以前遇到的老千:有人从牌堆底部发牌,有人两人合伙做牌,还有人把牌事先排好。赌桌上有个默契:由庄家右边的玩家切牌,就能洗清庄家的嫌疑。于是问题冒出来:如果一副牌被排成某种顺序,使得无论从哪里切,某个玩家都赢——这种事可能吗?In the summer of 2011, Jeremy Kun was playing Texas Hold 'Em by a pool with old friends when the conversation turned to cheaters they had known: someone dealing from the bottom of the deck, two players colluding, a dealer stacking the cards in advance. Poker has a quiet convention for exactly this: the player to the dealer's right cuts the deck, which supposedly absolves the dealer. That convention produced a question. Could a deck be arranged so that, no matter where it is cut, one particular player always wins?

先从最简单的牌戏开始。Kuhn 扑克只有三张牌(K、Q、J),每人一张,比大小。六种排列逐一检查,每一种都能找到一个切点,让切牌的那一方拿到更大的那张牌。为什么不是巧合?作者给出一般论证:假设存在一副“万能牌堆”让先手在任何切点都赢,那么沿着牌堆,每张牌都必须严格赢过下一张,否则对手切到那一位就赢。由传递性,第一张牌赢最后一张;于是后手只要切在最后一张之前,先手就只能拿到整副牌里最小的那张。矛盾。Start with the simplest possible game. Kuhn poker has three cards (king, queen, jack), one each, high card wins. There are only six orderings, and each one has a cut that hands the cutter the better card. That is not a coincidence, and the general argument is short. Suppose a magical ordering existed that let the first player win from every cut. Then walking down the deck, each card must beat the next one, or the opponent would simply cut there. By transitivity the top card beats the bottom card, so the opponent can cut just before the last card and leave the first player holding the worst card in the deck. Contradiction.

这个论证的漂亮之处在于它几乎不用算:切牌只是把环换个起点,而“赢”是传递的,于是环上不可能处处上坡。它也说明为什么德州扑克不能照搬——公共牌、顺子、同花让小牌也能赢,传递性被打破了。What is lovely is how little arithmetic this needs. A cut is just a different starting point on a circle, and 'beats' is transitive, so the circle cannot slope upward everywhere. It also explains why Texas Hold 'Em cannot inherit the result: community cards, straights and flushes let a low card win, and transitivity breaks.

于是 Kun 反过来设计游戏:K Poker(K 既是匈牙利语 kicsi、“小”,也是他的姓),九张同花色连续牌(2 到 10),每人两张,四张公共牌,只可能出高牌或顺子。规则少到可以穷举,又复杂到允许小牌翻盘。9! = 362,880 种排列,按切牌等价压到 8! = 40,320 种,计算机几秒钟扫完。So Kun ran the question backwards and designed a game: K Poker (K for kicsi, Hungarian for 'small', and for Kun himself), nine consecutive cards of one suit (deuce through ten), two cards each, four community cards, only high card or straight possible. The rules are small enough to enumerate and rich enough to let low cards win. That is 9! = 362,880 arrangements, reduced by cut-equivalence to 8! = 40,320, which a computer finishes in seconds.

结果出人意料地不对称:先手有 9 种(计切牌 81 种)万能牌堆,后手只有 2 种(18 种)。其中后手的一种就是升序牌堆——后手总拿最后一张,接下来四张公共牌正好成顺;而先手永远拿不到顺子。The answer is strangely asymmetric. Player one has nine winning stacks (81 counting cuts). Player two has two (18). One of player two's is simply the deck in ascending order: player two always receives the last card, and the next four community cards complete a straight, while player one can never make one.

但故事的重点不是“作弊可行”。Kun 的结论是:能否排出一副万能牌堆,取决于游戏规则允许什么牌赢;规则越丰富,传递性越弱,可乘之机越多。反过来,一个公平的游戏,本质上是在设计上堵住“环上下坡”的可能性。But the point is not that cheating works. The point is that whether a stack exists depends on which hands the rules allow to win. The richer the rules, the weaker transitivity, and the more room for a rigged deck. A fair game, seen this way, is one whose design closes off the possibility of an upward-sloping circle.

这也是一则关于问题本身的寓言。最初的问题是“德州扑克能被做牌吗”,太难;他换成“什么样的牌戏能被做牌”,于是既得到定理,也得到可运行的搜索。很多时候,把问题改写成自己能回答的形状,比硬啃原题更接近答案。而 81 比 9、18 比 2 的差别还提醒我们:即使在同一套规则下,谁能作弊也不是对称的——先手天然拥有更多藏身之处。It is also a fable about questions. 'Can Texas Hold 'Em be stacked?' is too hard. 'What kind of card game can be stacked?' is answerable, and it yields both a theorem and a working search. Rewriting a problem into a shape you can actually answer is often closer to progress than grinding on the original. And the 81-versus-18 asymmetry adds a parting thought: even under one rule set, who gets to cheat is not symmetric. The first player simply has more places to hide.

AI 思考AI Thoughts

数学之美The Beauty of Mathematics

每日 Lean 谜题 · 周一Daily Lean Puzzle · Monday ★☆☆☆☆☆☆

五个连续自然数,为什么总和是中间数的五倍Why Five Consecutive Numbers Sum to Five Times the Middle One

任取一个自然数 $n$,写出紧跟它的五个连续自然数:$n,\ n+1,\ n+2,\ n+3,\ n+4$。要证明的事情很朴素:这五个数的和,恰好等于中间那个数 $n+2$ 的五倍,即Take any natural number $n$ and write down the five consecutive numbers starting at it: $n,\ n+1,\ n+2,\ n+3,\ n+4$. The claim is simple: their sum is exactly five times the middle number $n+2$, that is,

$n + (n+1) + (n+2) + (n+3) + (n+4) = 5\,(n+2)$。$n + (n+1) + (n+2) + (n+3) + (n+4) = 5\,(n+2)$.

在 Lean 里,它就是定理 five_consecutive_sum,对任意自然数 $n$ 成立。In Lean this is the theorem five_consecutive_sum, stated for every natural number $n$.

Lean 形式化陈述(把 sorry 换成你的证明):The statement in Lean (replace sorry with your proof):

-- level: 1
import Mathlib.Tactic.Ring
/-! Prove that the sum of five consecutive natural numbers starting at $n$
equals five times the middle one, $n+2$. -/
theorem five_consecutive_sum (n : ℕ) :
    n + (n + 1) + (n + 2) + (n + 3) + (n + 4) = 5 * (n + 2) := by
  sorry

在浏览器中挑战 ▶Try it in your browser ▶ 下载题目 .leanDownload puzzle .lean

提示Hint

把五个数写成以中间数 $m=n+2$ 为中心:$m-2,\ m-1,\ m,\ m+1,\ m+2$。两端的偏移会成对抵消,只剩五个 $m$。Rewrite the five numbers around the middle one $m=n+2$: $m-2,\ m-1,\ m,\ m+1,\ m+2$. The offsets cancel in pairs, leaving five copies of $m$.

答案与讲解Solution & walkthrough
  1. 先把五个数按中间数 $m=n+2$ 重写:$m-2,\ m-1,\ m,\ m+1,\ m+2$。这一步只是换记号,却把“五个连续数”的对称性摆到了明面上。Rewrite the five numbers around the middle one $m=n+2$: $m-2,\ m-1,\ m,\ m+1,\ m+2$. This is only a change of notation, but it puts the symmetry of “five consecutive numbers” in plain sight.
  2. 相加时按对称配对:$(m-2)+(m+2)=2m$,$(m-1)+(m+1)=2m$,中间还剩一个 $m$。于是总和是 $2m+2m+m=5m$。这就是小学里说的“移多补少”。Add them in symmetric pairs: $(m-2)+(m+2)=2m$ and $(m-1)+(m+1)=2m$, with the middle $m$ left over. The total is $2m+2m+m=5m$ — the same “move the excess to fill the deficit” idea taught in primary school.
  3. 换回原来的记号:$m=n+2$,所以和就是 $5(n+2)$,正是要证的等式。全程只用了加法的交换律、结合律和乘法分配律,没有借用任何减法技巧。Translate back: $m=n+2$, so the sum is $5(n+2)$, exactly the identity to be proved. Only commutativity, associativity, and distributivity are used; no clever subtraction is needed.
  4. Lean 中的 ring 策略做的正是同一件事:把等式两边都展开成“若干项相加”的标准形,合并同类项、约掉相同的项,最后确认两边恒等。它不负责解释思路,只负责保证在交换半环 $\mathbb{N}$ 上每一步都合法——这也是为什么用自然数不会出问题:整个证明里根本没有出现 $n-2$ 这种可能为负的项。Lean's ring tactic performs the same computation: it expands both sides into a canonical sum of terms, collects like terms, cancels what matches, and confirms the two sides are identical. It does not explain the idea, it only guarantees each step is valid in the commutative semiring $\mathbb{N}$ — which is why natural numbers are safe here: no term such as $n-2$ that could go negative ever appears.
  5. 把结论放大:任意奇数个连续整数之和,都等于“项数 × 中间项”;偶数个则等于“项数 × 中间两项的平均数”。这个观察在数论里会反复用到,例如判断一个数能否写成连续整数之和,本质上是在数它的奇因子。Generalize: the sum of any odd number of consecutive integers equals “the count times the middle term”; for an even count it is “the count times the average of the two middle terms”. This observation recurs in number theory — deciding whether a number is a sum of consecutive integers amounts to counting its odd divisors.
-- level: 1
import Mathlib.Tactic.Ring
/-! Prove that the sum of five consecutive natural numbers starting at $n$
equals five times the middle one, $n+2$. -/
theorem five_consecutive_sum (n : ℕ) :
    n + (n + 1) + (n + 2) + (n + 3) + (n + 4) = 5 * (n + 2) := by
  ring

运行答案 ▶Run the solution ▶ 下载答案 .leanDownload solution .lean

人的思考A human's take

Three Neighbours — NRICH (student solutions by Nikhil, Roger, Aadit and others)

NRICH 的这道题先问三个连续整数之和为什么总是 3 的倍数,再让读者把它推广到五个、七个。NRICH's problem first asks why three consecutive integers always add up to a multiple of 3, then invites readers to extend the pattern to five and seven numbers.

学生 Nikhil 的解释是:以中间数为基准,后面两个数分别是“中间数减 1、减 2”,前面两个数是“加 1、加 2”,正负抵消后,整列数就相当于五个中间数相加。Student Nikhil explains it by centring on the middle number: the two numbers after it are “middle minus 1, minus 2”, the two before it are “plus 1, plus 2”, and after cancellation the list is just five copies of the middle number.

另一位学生 Roger 用代数写:五个数是 $n$ 到 $n+4$,和为 $5n+10$,提出 5 得到 $5(n+2)$;Aadit 则把它推广到任意奇数个连续整数。Another student, Roger, writes the five numbers as $n$ through $n+4$, sums them to $5n+10$, and factors out 5 to get $5(n+2)$; Aadit generalizes the argument to any odd number of consecutive integers.

AI 随想An AI's reflection

以下由 AI 撰写。Written by AI.

这是一道“看一眼就懂”的题,却值得认真写一遍。因为真正让人确信的,不是记住 $5(n+2)$ 这个结果,而是看见五个数如何围绕中点对称、偏移如何两两抵消。数学里大量“显然”的结论,一旦要求把每一步说出来,就会暴露我们其实只是在复述记忆。This is a problem you understand at a glance, yet it is worth writing out. What convinces you is not the result $5(n+2)$ but the sight of five numbers arranged around their middle, with the offsets cancelling in pairs. Many “obvious” facts expose, once every step must be spoken aloud, that we were only repeating a memory.

这种“找到中心,再看两边如何抵消”的眼光,比公式本身有用得多。它不仅解释了五个连续数,也解释了任意奇数个连续数;换到别的题目里,它会变成“先找对称轴”“先找不变量”这类更一般的策略。That habit of finding the centre and watching the two sides cancel is more useful than the formula. It explains five consecutive numbers, any odd number of them, and turns into general strategies elsewhere: look for the axis of symmetry, look for the invariant.

Lean 在这里扮演的角色很有意思:ring 一行就结束了证明,但它给出的不是洞察,而是保证——保证在自然数这个半环里,展开、合并、约去都合法。人类负责选择“以中点为心”的看法,机器负责确认这个看法没有漏洞。这大概是人与证明助手最舒服的分工。顺带一提,这也解释了题目为什么放心地取自然数:整个论证里根本没有出现 $n-2$ 这种可能为负的式子,自然数没有减法封闭性的麻烦,证明才这么干净。Lean's role is interesting: ring ends the proof in one line, but what it supplies is not insight — it is a guarantee that expanding, collecting and cancelling are legal in the semiring of naturals. The human chooses the view; the machine checks it has no holes. That is also why the problem can safely use natural numbers: nothing in the argument ever writes down $n-2$, so there is no subtraction to worry about, and the proof stays clean.

✓ 已通过 Lean 编译验证(无 sorry,无额外公理)✓ Verified by Lean (no sorry, no extra axioms) · 题目与证明由 AI 编写Problem and proof written by AI · Lean v4.36.0-rc2 · Mathlib fafbe4e

程序员随想Programmer Reflections

哲学与生活Philosophy & Life

工具角Tools Corner