# 斑马谜题（Zebra Puzzle）

斑马谜题是一种逻辑谜题：一排五座房子必须逐座与若干属性类别中的各一个值对应起来，这些类别包括颜色、国籍、饮料、香烟品牌和宠物；解题依据一份固定线索清单，仅凭演绎推理完成。它的两个标准问题是：谁喝水，谁养斑马。这个谜题最早于1962年在一本杂志上刊出，此后被反复重印、改写，并被错误地归到他人名下；它是约束满足问题（constraint satisfaction problem）的经典范例：一个人用铅笔和纸就能解出。报摊上任何一本谜题杂志里的逻辑网格谜题，都是它的后裔。<sup>[1](https://puzzlemakers.net/articles/logic/logic-grid-puzzles-and-the-zebra-problem)</sup>

| 关键事实 | 详情 |
|---|---|
| 结构 | 一排五座房子，每座颜色、国籍、饮料、香烟品牌和宠物各不相同；十五条线索；两个问题：谁喝水，谁养斑马<sup>[1](https://puzzlemakers.net/articles/logic/logic-grid-puzzles-and-the-zebra-problem)</sup> |
| 原始答案 | 日本人养斑马，挪威人喝水<sup>[3](https://www.thepuzzlelabs.com/grid-puzzles/einsteins-riddle)</sup> |
| 鱼版本 | 在广泛重印的“爱因斯坦之谜”（Einstein's Riddle）版本中，最后的问题问谁养鱼，答案是德国人<sup>[4](https://www.riddlesparade.com/einsteins-riddle/)</sup> |
| 归属 | 民间常将其归到阿尔伯特·爱因斯坦（Albert Einstein）名下，并声称只有2%的人能解出；没有证据表明他写过这个谜题，而且谜题中提到的香烟品牌在他年轻时并不存在<sup>[5](https://unanswered.io/guide/who-owns-the-zebra-who-drinks-the-water)</sup> |
| 解的数量 | 经典谜题恰好有一个解；约束不足的变体有许多解，约束过度的变体则无解<sup>[6](https://github.com/aidtopia/zebra)</sup> |
| 作为基准 | ZebraLogic 是由艾伦人工智能研究所（Allen Institute for AI）和华盛顿大学（University of Washington）研究人员构建的包含1000道谜题的基准，用生成的逻辑网格谜题测试大语言模型<sup>[7](https://benchgen.com/benchmarks/bill-yuchen-lin-et-al-allen-institute-for-ai-university-of-washington/zebralogic)</sup> |

## 结构与解法

所有逻辑网格谜题都有共同结构：一组位置、若干属性类别，并且每个位置都从每一类别中恰好取一个值。<sup>[1](https://puzzlemakers.net/articles/logic/logic-grid-puzzles-and-the-zebra-problem)</sup> 经典版本中，位置是从左到右编号的五座房子，类别是颜色、国籍、饮料、香烟品牌和宠物。一份线索清单描述各项之间如何关联，且恰好有一种排列满足所有线索。解谜靠演绎而非猜测，因此它也被称为逻辑网格谜题或排除谜题。<sup>[8](https://www.zebrapuzzles.com/?trk=public_post_main-feed-card-text)</sup>

实用方法从能直接确定某项的线索入手，例如“中间房子里的人喝牛奶”或“挪威人住在第一座房子里”，先把这些放好。位置线索说明两项相邻，或一项位于另一项左侧某处，据此排除位置。每一次排除都会收窄剩余线索，演绎链条最终只留下一种可能排列。<sup>[8](https://www.zebrapuzzles.com/?trk=public_post_main-feed-card-text)</sup> 解题者通常用一张五乘五的排除网格记录进展，把房子与类别交叉排列。<sup>[1](https://puzzlemakers.net/articles/logic/logic-grid-puzzles-and-the-zebra-problem)</sup>

## 1962年的谜题及其答案

1962年《生活》杂志（Life Magazine）国际版刊登的版本使用国籍（英国人、西班牙人、乌克兰人、挪威人、日本人）、五种房子颜色、五种宠物（包括斑马）、五种饮料和五种职业，列出十四条线索，随后是两个问题。<sup>[2](https://www.mathsisfun.com/puzzles/who-owns-the-zebra--solution.html)</sup> 其解为：挪威人住在黄房子里，喝水，养狐狸；日本人住在绿房子里，喝咖啡，养斑马。<sup>[2](https://www.mathsisfun.com/puzzles/who-owns-the-zebra--solution.html)</sup>

更广为人知的重印版用香烟品牌取代职业，并问谁养鱼。在该版本中，各座房子对应为：黄房子，挪威人，水，猫，登喜路（Dunhill）；蓝房子，丹麦人，茶，马，Blends；红房子，英国人，牛奶，鸟，波迈（Pall Mall）；绿房子，德国人，咖啡，鱼，王子（Prince）；白房子，瑞典人，啤酒，狗，蓝大师（Bluemasters）。<sup>[3](https://www.thepuzzlelabs.com/grid-puzzles/einsteins-riddle)</sup> 两个版本共享相同的底层约束结构，而且在两个版本中都是挪威人喝水。<sup>[2](https://www.mathsisfun.com/puzzles/who-owns-the-zebra--solution.html)</sup><sup> • </sup><sup>[3](https://www.thepuzzlelabs.com/grid-puzzles/einsteins-riddle)</sup>

## 爱因斯坦归属

民间常把这个谜题归到[阿尔伯特·爱因斯坦](https://www.edgepedia.org/zh/albert-einstein)名下，并称他少年时创作了它，还估计只有2%的人能解出。没有证据表明他写过它，但“爱因斯坦之谜”这个名字流传了下来；爱因斯坦之谜、爱因斯坦谜题（Einstein puzzle）和斑马谜题描述的是同一种格式。<sup>[8](https://www.zebrapuzzles.com/?trk=public_post_main-feed-card-text)</sup> 这一归属在内部也自相矛盾：谜题中提到的香烟品牌在爱因斯坦年轻时并不存在。<sup>[5](https://unanswered.io/guide/who-owns-the-zebra-who-drinks-the-water)</sup> 这个故事通常被视为围绕那次重印生长出来的民间传说。<sup>[5](https://unanswered.io/guide/who-owns-the-zebra-who-drinks-the-water)</sup>

## 作为约束满足问题的谜题

形式上，斑马谜题是一个约束满足问题（CSP）：为各位置找到一组取值，使其同时满足一组约束。<sup>[9](https://sifnos.iwm-tuebingen.de/dm/01/winter/684.01/etc/ale-manual/html/node29.html)</sup> 在人工智能研究使用的逻辑网格表述中，谜题由一组自然语言线索构成，这些线索涉及被划分成若干大小相等的组的实体；目标是找出各组之间的关系，使每条线索都得到满足，一种类型的每个实体都恰好与另一种类型的一个实体匹配（双射性），并且这些关系在逻辑上相互关联（传递性）。<sup>[10](https://www.bartbogaerts.eu/articles/2021/004-AIJ-Expl/Zebra-Journal.pdf)</sup>

由于谜题规模小且定义明确，它天然适合自动求解，主要逻辑编程传统中都有实现：Prolog 与约束逻辑编程、Go 中的 miniKanren，以及 Python 中的 SAT 求解器——在后者中，线索被转换为合取范式，交给 pycosat 之类的求解器。<sup>[11](https://www.eclipseclp.org/examples/index.html)</sup><sup> • </sup><sup>[12](https://pkg.go.dev/github.com/gitrdm/gokanlogic/examples)</sup><sup> • </sup><sup>[13](https://github.com/tuchandra/zebra)</sup> 同一个谜题也被用作基于约束的编程教学的标准示例。<sup>[14](https://www.jite.org/documents/Vol14/JITEv14IIPp171-189Crabtree1771.pdf)</sup>

**求解器会如何表现。** 一个对谜题一无所知的通用约束求解器，仅靠施加约束就能确定一半以上的解，然后大约需要三次猜测才能找到第一个解；继续搜索很快会表明没有其他解。<sup>[6](https://github.com/aidtopia/zebra)</sup> 对经典谜题及其近亲的分析发现，斑马谜题、爱因斯坦谜题和献血谜题（Blood Donation puzzle）各自都有唯一解，但允许多种求解顺序变体：斑马谜题有144种，献血谜题有972种；后者维度更多，搜索空间更大。<sup>[15](https://blogs.sas.com/content/sgf/2022/04/06/zebra-puzzle-terminator/)</sup>

**解释解。** 由于这个谜题本意是让人来解，研究者把它用作逐步解释约束求解的测试案例。布鲁塞尔自由大学（Vrije Universiteit Brussel）的巴特·博加茨（Bart Bogaerts）、埃米利奥·甘巴（Emilio Gamba）和蒂亚斯·贡斯（Tias Guns）开发了一个框架，能生成一系列小型推理步骤，每一步都由先前推出的事实和约束的一个子集来证明；其代价函数偏好让人容易验证的解释；困难的步骤可以通过反证推理进一步拆解。<sup>[10](https://www.bartbogaerts.eu/articles/2021/004-AIJ-Expl/Zebra-Journal.pdf)</sup> 同一领域的早期工作发现，与单独使用一种方法相比，组合冗余推理方法可将生成的解释长度大约缩短一半。<sup>[16](https://aaai.org/Papers/AAAI/1996/AAAI96-048.pdf)</sup>

## 在人工智能评估中的使用

这个谜题把自然语言线索与严格演绎结合起来，使其成为机器推理中反复使用的基准。为自然语言推理构建的 PuzzTE 数据集包含斑马谜题，标注为蕴含、矛盾或未知；其16,745个配对中有4,467个蕴含标签、8,530个矛盾标签和3,748个未知标签，而信息不完整的歧义谜题可能有多个解。<sup>[17](https://www.researchgate.net/publication/356986354_A_Puzzle-Based_Dataset_for_Natural_Language_Inference)</sup>

ZebraLogic 由[艾伦人工智能研究所](https://www.edgepedia.org/zh/allen-institute-for-ai)和华盛顿大学的研究人员创建，并在 ICML 2025 上展示；它以程序化方式生成1000道逻辑网格谜题，每道题设定为 N 座房子、M 个属性以及一份自然语言线索清单，用来测试大语言模型在非单调推理上的扩展表现。其核心发现是“复杂性诅咒”：模型准确率随谜题规模增大而下降，而且即使模型更大、推理时计算增加，这一局限依然存在。<sup>[7](https://benchgen.com/benchmarks/bill-yuchen-lin-et-al-allen-institute-for-ai-university-of-washington/zebralogic)</sup><sup> • </sup><sup>[18](https://arxiv.org/abs/2502.01100)</sup> 多语言后续工作 MultiZebraLogic 生成多种语言、主题和规模的谜题，包含14种线索类型和8种干扰线索类型（无信息线索），并发现2×3和4×5的谜题规模分别足以挑战非推理模型 GPT-4o mini 和推理模型 o3-mini。<sup>[19](https://arxiv.org/abs/2511.03553)</sup> 在另一条研究路线上，一个被训练在数独上搜索的因果语言模型被扩展到斑马谜题，并完全正确地解出了其中92.04%。<sup>[20](https://arxiv.org/abs/2409.10502)</sup> 将线索转换为定理证明器所用 SMT 代码的约束引导多智能体系统代表了另一种方法，其自动评分器已在用户研究中得到验证。<sup>[21](https://arxiv.org/abs/2407.03956)</sup>

适定性是这些基准中计分的前提：每道谜题都经过验证，恰好有一个解。这一区分很重要，因为带有剩余自由度的谜题可能允许多种有效排列，而求解器若对一个欠定谜题只报告一个答案，就没有注意到其非唯一性。<sup>[22](https://www.rabdos.ai/research/process-of-elimination)</sup>

## References

1. [Logic Grid Puzzles and the Zebra Problem, PuzzleMakers](https://puzzlemakers.net/articles/logic/logic-grid-puzzles-and-the-zebra-problem)
2. [Who Owns the Zebra? Puzzle - Solution, Math is Fun](https://www.mathsisfun.com/puzzles/who-owns-the-zebra--solution.html)
3. [Einstein's Riddle (The Zebra Puzzle), ThePuzzleLabs](https://www.thepuzzlelabs.com/grid-puzzles/einsteins-riddle)
4. [Einstein's Riddle: Who Owns the Fish?, Riddles Parade](https://www.riddlesparade.com/einsteins-riddle/)
5. [Who Owns the Zebra and Who Drinks the Water?, Unanswered](https://unanswered.io/guide/who-owns-the-zebra-who-drinks-the-water)
6. [aidtopia/zebra: Solving the Zebra puzzle from its constraints, GitHub](https://github.com/aidtopia/zebra)
7. [ZebraLogic, Benchgen](https://benchgen.com/benchmarks/bill-yuchen-lin-et-al-allen-institute-for-ai-university-of-washington/zebralogic)
8. [Zebra Puzzles - Free Daily Logic Puzzles](https://www.zebrapuzzles.com/?trk=public_post_main-feed-card-text)
9. [Example: The Zebra Puzzle, ALE manual, University of Tübingen](https://sifnos.iwm-tuebingen.de/dm/01/winter/684.01/etc/ale-manual/html/node29.html)
10. [Bogaerts, Gamba, Guns. A framework for step-wise explaining how to solve constraint satisfaction problems, Artificial Intelligence](https://www.bartbogaerts.eu/articles/2021/004-AIJ-Expl/Zebra-Journal.pdf)
11. [ECLiPSe Code Samples](https://www.eclipseclp.org/examples/index.html)
12. [gokanlogic examples: Zebra Puzzle, pkg.go.dev](https://pkg.go.dev/github.com/gitrdm/gokanlogic/examples)
13. [tuchandra/zebra: Logic grid puzzle generator and solver, GitHub](https://github.com/tuchandra/zebra)
14. [Teaching Advanced Programming Concepts and Techniques Using the Zebra Puzzle, JITE](https://www.jite.org/documents/Vol14/JITEv14IIPp171-189Crabtree1771.pdf)
15. [Zebra Puzzle Terminator, SAS Users](https://blogs.sas.com/content/sgf/2022/04/06/zebra-puzzle-terminator/)
16. [AAAI-96 Proceedings: explanation methods for the zebra puzzle](https://aaai.org/Papers/AAAI/1996/AAAI96-048.pdf)
17. [A Puzzle-Based Dataset for Natural Language Inference, ResearchGate](https://www.researchgate.net/publication/356986354_A_Puzzle-Based_Dataset_for_Natural_Language_Inference)
18. [ZebraLogic: On the Scaling Limits of LLMs for Logical Reasoning, arXiv](https://arxiv.org/abs/2502.01100)
19. [MultiZebraLogic: A Multilingual Logical Reasoning Benchmark, arXiv](https://arxiv.org/abs/2511.03553)
20. [Causal Language Modeling Can Elicit Search and Reasoning Capabilities on Logic Puzzles, arXiv](https://arxiv.org/abs/2409.10502)
21. [Solving Zebra Puzzles Using Constraint-Guided Multi-Agent Systems, arXiv](https://arxiv.org/abs/2407.03956)
22. [Process of Elimination, Rabdos AI](https://www.rabdos.ai/research/process-of-elimination)

---
*Initially written Sep 17, 2026 · Reviewed: Oct 21, 2026 · Edited: Oct 15, 2026; Oct 21, 2026 · Last review: Oct 21, 2026*

Topic: 体育、游戏与休闲 › 棋牌与益智游戏 › 益智游戏 › Physical, logic, and word puzzles › Classical mathematical puzzles

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/zebra-puzzle

English original: https://www.edgepedia.org/zebra-puzzle
