math-skill 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +278 -0
  3. package/agents/math-critic.md +203 -0
  4. package/commands/abstraction.md +34 -0
  5. package/commands/algorithmic-thinking.md +34 -0
  6. package/commands/ask.md +21 -0
  7. package/commands/axiomatization.md +34 -0
  8. package/commands/causal-inference.md +34 -0
  9. package/commands/discrete-combinatorial.md +34 -0
  10. package/commands/game-theory.md +34 -0
  11. package/commands/induction-analogy.md +34 -0
  12. package/commands/information-theory.md +34 -0
  13. package/commands/logic-deduction.md +34 -0
  14. package/commands/modeling.md +37 -0
  15. package/commands/optimization.md +33 -0
  16. package/commands/probability-statistics.md +36 -0
  17. package/commands/symmetry-invariance.md +34 -0
  18. package/commands/topological-thinking.md +33 -0
  19. package/commands/transformation.md +33 -0
  20. package/docs/CLAUDE.md +187 -0
  21. package/docs/inspiration.md +113 -0
  22. package/knowledge-base/overview.md +230 -0
  23. package/package.json +60 -0
  24. package/skills/abstraction/SKILL.md +264 -0
  25. package/skills/abstraction/original-texts.md +175 -0
  26. package/skills/algorithmic-thinking/SKILL.md +371 -0
  27. package/skills/algorithmic-thinking/original-texts.md +256 -0
  28. package/skills/axiomatization/SKILL.md +213 -0
  29. package/skills/axiomatization/original-texts.md +160 -0
  30. package/skills/causal-inference/SKILL.md +374 -0
  31. package/skills/causal-inference/original-texts.md +167 -0
  32. package/skills/discrete-combinatorial/SKILL.md +286 -0
  33. package/skills/discrete-combinatorial/original-texts.md +185 -0
  34. package/skills/game-theory/SKILL.md +318 -0
  35. package/skills/game-theory/original-texts.md +131 -0
  36. package/skills/induction-analogy/SKILL.md +310 -0
  37. package/skills/induction-analogy/original-texts.md +154 -0
  38. package/skills/information-theory/SKILL.md +242 -0
  39. package/skills/information-theory/original-texts.md +127 -0
  40. package/skills/logic-deduction/SKILL.md +280 -0
  41. package/skills/logic-deduction/original-texts.md +173 -0
  42. package/skills/meta-selector/SKILL.md +188 -0
  43. package/skills/meta-selector/original-texts.md +105 -0
  44. package/skills/modeling/SKILL.md +318 -0
  45. package/skills/modeling/original-texts.md +165 -0
  46. package/skills/optimization/SKILL.md +292 -0
  47. package/skills/optimization/original-texts.md +168 -0
  48. package/skills/probability-statistics/SKILL.md +312 -0
  49. package/skills/probability-statistics/original-texts.md +193 -0
  50. package/skills/symmetry-invariance/SKILL.md +358 -0
  51. package/skills/symmetry-invariance/original-texts.md +221 -0
  52. package/skills/topological-thinking/SKILL.md +273 -0
  53. package/skills/topological-thinking/original-texts.md +164 -0
  54. package/skills/transformation/SKILL.md +264 -0
  55. package/skills/transformation/original-texts.md +216 -0
@@ -0,0 +1,286 @@
1
+ ---
2
+ name: discrete-combinatorial
3
+ description: |
4
+ 触发:当需要计数、枚举、发现有限结构中的规律、或处理离散对象时调用。
5
+ 科研模式:组合计数、图论分析、生成函数计算。
6
+ 生活模式:系统性枚举、鸽巢推理、组织有限选项。
7
+ English: Trigger when you need to count, enumerate, find patterns in finite structures, or handle discrete objects.
8
+ Research mode: combinatorial counting, graph theory analysis, generating function computation.
9
+ Life mode: systematic enumeration, pigeonhole reasoning, organizing finite options.
10
+ ---
11
+
12
+ # 🧮 离散与组合思想
13
+
14
+ > "计数是最古老的数学活动——有限对象蕴含无限规律。"
15
+ > "Counting is the oldest mathematical activity — finite objects harbor infinite patterns."
16
+ >
17
+ > —— 组合数学、图论、生成函数
18
+ > —— Combinatorics, Graph Theory, Generating Functions
19
+
20
+ ## 核心原则 / Core Principle
21
+
22
+ 组合思维的核心:(1) 对有限结构进行系统计数,(2) 发现支配枚举的规律,(3) 使用代数方法(生成函数)将计数问题变换为代数问题。这三项构成了组合思想的基石——没有系统计数就没有可靠结论,没有规律发现就没有预测能力,没有代数变换就没有高效求解。
23
+
24
+ Combinatorial thinking means: (1) counting finite structures systematically, (2) finding patterns that govern enumeration, (3) using algebraic methods (generating functions) to transform counting problems into algebraic ones. These three pillars form the foundation — without systematic counting there is no reliable conclusion, without pattern discovery there is no predictive power, without algebraic transformation there is no efficient solution.
25
+
26
+ > **数学形式化**(科研模式参考)
27
+ >
28
+ > **鸽巢原理 (Pigeonhole Principle)**:若 n 个物品放入 m < n 个盒子,则必有某个盒子含至少 2 个物品。推广:将 kn+1 个物品放入 n 个盒子,则某盒子至少含 k+1 个物品。看似简单,却是存在性证明的利器——不构造具体对象,仅证明其必然存在。
29
+ >
30
+ > **容斥原理 (Inclusion-Exclusion)**:|A∪B| = |A| + |B| − |A∩B|。推广到 n 个集合:|A₁∪A₂∪...∪A_n| = Σ|A_i| − Σ|A_i∩A_j| + ... ± |A₁∩...∩A_n|。直接计数困难时,计数补集:"不具有性质 P 的数量" = 全部 − "具有性质 P 的数量"。
31
+ >
32
+ > **生成函数 (Generating Functions)**:
33
+ > - 常生成函数 (OGF):A(x) = Σa_n x^n。适用于无序选择、组合计数。乘法:A(x)·C(x) 的系数 = Σa_i·c_{n−i}(组合两个独立的计数)。
34
+ > - 指数生成函数 (EGF):B(x) = Σb_n x^n/n!。适用于有序选择、排列计数、有标号对象。乘法:B(x)·D(x) 的系数/n! = Σ(b_i/i!)·(d_{n−i}/(n−i)!)(排列两个有标号集合)。
35
+ >
36
+ > Euler 的洞察:将 1+2+3+... 的"发散级数"重新诠释为分拆计数的生成函数。
37
+
38
+ 关键洞察:许多无限结构受有限组合规则支配。分拆函数 p(n) 由五角数定理这一有限公式完全刻画;Catalan 数 C_n 由递推 C_n = ΣC_i·C_{n−1−i} 这一有限规则生成。组合思想揭示:无限的复杂可以由有限的简单来掌控。
39
+
40
+ Key insight: many infinite structures are governed by finite combinatorial rules. The partition function p(n) is completely characterized by the pentagonal number theorem — a finite formula; Catalan numbers C_n are generated by the recurrence C_n = ΣC_i·C_{n−1−i} — a finite rule. Combinatorial thinking reveals: infinite complexity can be governed by finite simplicity.
41
+
42
+ > 详细数学依据见 `original-texts.md`
43
+
44
+ ## 不适用场景 / When NOT to Use
45
+
46
+ 1. **连续/分析性问题,无离散结构** `[科研]` ——当问题涉及连续变量的极限、微分、积分而非有限对象的计数时,组合工具不适用。例如求连续函数的最优值或证明实数的稠密性,这些是分析而非组合的领域。
47
+
48
+ Continuous/analytical problems with no discrete structure — when the problem involves limits, derivatives, integrals of continuous variables rather than counting finite objects, combinatorial tools are inappropriate. Finding the optimum of a continuous function or proving density of real numbers belongs to analysis, not combinatorics.
49
+
50
+ 2. **精确计算可行,无需计数** `[通用]` ——当问题有闭式公式直接给出答案时,组合枚举是多余的开销。例如求 n·(n−1) 直接用代数运算,无需枚举所有排列。
51
+
52
+ Exact computation is possible without counting — when a closed-form formula gives the answer directly, combinatorial enumeration is unnecessary overhead. Computing n·(n−1) directly via algebra is preferable to enumerating all permutations.
53
+
54
+ 3. **纯粹概率问题,无组合结构** `[科研]` ——当问题仅涉及连续分布的参数估计或贝叶斯更新,不涉及有限集合的计数时,组合方法不是核心工具。概率密度函数的积分不是组合问题。
55
+
56
+ Purely probabilistic with no combinatorial structure — when the problem involves parameter estimation for continuous distributions or Bayesian updating without counting finite sets, combinatorial methods are not the central tool. Integrating a probability density function is not a combinatorial problem.
57
+
58
+ 4. **情绪化决策,无结构化选择** `[生活]` ——当选择基于直觉、偏好或情感而非可枚举的有限选项时,组合枚举无法提供有效指导。"我喜欢哪个"不是计数问题。
59
+
60
+ Emotional decisions with no structured choices — when choices are based on intuition, preference, or emotion rather than enumerable finite options, combinatorial enumeration cannot provide effective guidance. "Which one do I like" is not a counting problem.
61
+
62
+ ## 何时使用 / When to Use
63
+
64
+ ### 科研触发条件 / Research Triggers
65
+
66
+ 1. **需要计数配置数量**——"有多少种排列/选择/分配方式?"是组合思想的原问题。当答案不是 1 或"无穷",而是一个具体的有限数时,组合计数是核心方法。
67
+
68
+ Need to count configurations — "How many arrangements/selections/assignments are there?" is the original question of combinatorial thinking. When the answer is not 1 or "infinite" but a specific finite number, combinatorial counting is the central method.
69
+
70
+ 2. **需要通过鸽巢原理证明存在性**——当需要证明"必存在某对象具有某性质"而不需要构造具体实例时,鸽巢原理是最有力的工具。例如:任意 5 个整数中必有 2 个差为 4 的倍数。
71
+
72
+ Need to prove existence via pigeonhole — when proving "some object with some property must exist" without constructing a specific instance, the pigeonhole principle is the most powerful tool. For example: among any 5 integers, two must differ by a multiple of 4.
73
+
74
+ 3. **需要发现组合规律**——当观察到枚举数列 {a_n} 且需要发现其递推关系或封闭公式时,组合分析是核心方法。发现 C_n = (2n)!/(n!(n+1)!) 是组合洞察的典范。
75
+
76
+ Need to find combinatorial patterns — when observing an enumeration sequence {a_n} and needing to discover its recurrence relation or closed-form formula, combinatorial analysis is the central method. Discovering C_n = (2n)!/(n!(n+1)!) is a paradigm of combinatorial insight.
77
+
78
+ 4. **需要枚举可能性**——当需要列举所有满足约束的配置时,组合枚举提供系统性方法。枚举不是随机罗列,而是按结构分类、按规则生成。
79
+
80
+ Need to enumerate possibilities — when listing all configurations satisfying constraints, combinatorial enumeration provides systematic methods. Enumeration is not random listing, but classification by structure and generation by rules.
81
+
82
+ 5. **需要图/网络分析**——当问题涉及连接、路径、匹配、着色、覆盖等关系结构时,图论是组合思想的核心分支。社交网络、交通规划、任务调度都可化为图问题。
83
+
84
+ Need graph/network analysis — when the problem involves relational structures such as connections, paths, matching, coloring, covering, graph theory is the core branch of combinatorial thinking. Social networks, traffic planning, task scheduling all reduce to graph problems.
85
+
86
+ 6. **需要求解递推关系**——当问题的答案由递推定义(如 C_n = ΣC_i·C_{n−1−i})且需要封闭公式或渐近行为时,生成函数是标准工具。递推 → 生成函数 → 代数求解 → 提取系数。
87
+
88
+ Need to solve recurrence relations — when the answer is defined by a recurrence (e.g., C_n = ΣC_i·C_{n−1−i}) and a closed formula or asymptotic behavior is needed, generating functions are the standard tool. Recurrence → generating function → algebraic solution → extract coefficients.
89
+
90
+ ### 生活触发条件 / Life Triggers
91
+
92
+ 1. **需要在有限选项中做选择**——面对有限的选项(餐厅、路线、日程安排),系统性枚举比随机尝试更有效。
93
+
94
+ Need to choose among finite options — when facing limited options (restaurants, routes, schedules), systematic enumeration is more effective than random attempts.
95
+
96
+ 2. **直觉感到"选项比需求多,必然有重复"**——鸽巢原理的生活版:如果 5 个人抢 3 个车位,必然有人抢不到或有人共享。
97
+
98
+ Intuition that "more demands than slots means collision" — pigeonhole principle in life: if 5 people compete for 3 parking spots, someone must miss out or share.
99
+
100
+ 3. **需要组织或安排有限资源**——将任务分配给时间段、将物品归入类别——这些都是排列和分配问题的日常版。
101
+
102
+ Need to organize or arrange finite resources — assigning tasks to time slots, categorizing items — these are everyday versions of arrangement and allocation problems.
103
+
104
+ 4. **需要发现日常规律**——"每周总是有两天最忙"——这是有限结构中的规律发现,组合思维帮助确认规律而非错觉。
105
+
106
+ Need to discover everyday patterns — "there are always two busiest days each week" — this is pattern discovery in finite structures; combinatorial thinking helps confirm patterns rather than illusions.
107
+
108
+ 5. **需要分析人际关系或依赖结构**——谁和谁是朋友、谁依赖谁——这是图结构的生活版:社交网络就是图。
109
+
110
+ Need to analyze interpersonal relations or dependency structures — who is friends with whom, who depends on whom — this is graph structure in life: social networks are graphs.
111
+
112
+ ## 方法流程 / Method
113
+
114
+ ### 第一步:识别离散结构与计数问题 / Identify Discrete Structure and Counting Problem
115
+
116
+ **科研模式**:明确:
117
+ - **要计数的对象**是什么?(排列、组合、分拆、安排)
118
+ - **计数的目标**是什么?(总数、带约束的子集、概率)
119
+ - **约束条件**是什么?(互不相交、有序/无序、有标号/无标号)
120
+
121
+ 分类计数类型:
122
+ - **排列 (Permutations)**:有序选择,n 个物品选 k 个排列 = P(n,k) = n!/(n−k)!
123
+ - **组合 (Combinations)**:无序选择,n 个物品选 k 个组合 = C(n,k) = n!/(k!(n−k)!)
124
+ - **分拆 (Partitions)**:将 n 分为若干组(整数分拆 p(n),集合分拆 B(n))
125
+ - **安排 (Arrangements)**:将物品放入位置(盒子、格子、座位)
126
+
127
+ **生活模式**:你面对的是什么类型的有限选择/排列/分配问题?——搞清楚问题类型是第一步。是"选几个"的问题,还是"排顺序"的问题,还是"分到不同组"的问题?
128
+
129
+ **共通要点**:识别问题的结构是所有后续步骤的基础——不同类型需要不同方法。
130
+
131
+ ---
132
+
133
+ ### 第二步:应用基本计数原理 / Apply Basic Counting Principles
134
+
135
+ **科研模式**:
136
+ - **乘法原理 (Multiplication Principle)**:k 个独立选择 → k₁ × k₂ × ... × k_n 种结果。每步独立,总数相乘。
137
+ - **加法原理 (Addition Principle)**:互斥选项 → 总数相加。|A∪B| = |A| + |B|(当 A∩B = ∅)。
138
+ - **鸽巢原理 (Pigeonhole Principle)**:n > m 时碰撞不可避免。将 n 个物品放入 m 个盒子(n > m),则某盒子至少含 ⌈n/m⌉ 个物品。推广:将 kn+1 个物品放入 n 个盒子,则某盒子至少含 k+1 个物品。
139
+
140
+ 应用要点:先判断选择是否独立(乘法)还是互斥(加法),再判断是否需要存在性结论(鸽巢)。
141
+
142
+ **生活模式**:粗略估计有多少种可能——"很多"还是"只有几种"?如果选项比需要分配的数量多,必然有选项被重复选择(鸽巢原理的生活版)。
143
+
144
+ **共通要点**:无论正式计算还是粗略估计,判断数量规模是决策的关键输入。
145
+
146
+ ---
147
+
148
+ ### 第三步:使用容斥原理 / Apply Inclusion-Exclusion
149
+
150
+ **科研模式**:
151
+
152
+ |A₁∪A₂∪...∪A_n| = Σ|A_i| − Σ|A_i∩A_j| + Σ|A_i∩A_j∩A_k| − ... ± |A₁∩...∩A_n|
153
+
154
+ 容斥原理处理交集重叠的计数——直接相加会重复计算交集,容斥逐层修正。
155
+
156
+ **补集计数 (Complement counting)**:当直接计数困难时,计数补集。"不具有性质 P 的数量" = 全部 − "具有性质 P 的数量"。经典实例:错排数 D(n) = n! − C(n,1)(n−1)! + C(n,2)(n−2)! − ... ± C(n,n)·0!,即"所有元素都不在原位" = 全排列 − "至少一个在原位"。
157
+
158
+ **符号规则**:奇数个集合的交集取正号,偶数个集合的交集取负号。第 k 层贡献 = (−1)^{k+1} Σ|A_{i₁}∩...∩A_{i_k}|。
159
+
160
+ **生活模式**:有重叠的情况怎么算?——不是简单地相加,重叠部分要扣除。A或B的情况 = A的情况 + B的情况 − 同时是A和B的情况。
161
+
162
+ **共通要点**:重叠修正是一般性原则——不修正重叠就是错误估计。
163
+
164
+ ---
165
+
166
+ ### 第四步:构造生成函数 / Construct Generating Functions
167
+
168
+ **科研模式**:
169
+ - **常生成函数 (OGF)**:A(x) = Σa_n x^n。适用于无序选择、组合计数。系数 a_n 是第 n 项的计数。乘法:A(x)·C(x) 的系数 = Σa_i·c_{n−i}(组合两个独立的计数)。
170
+ - **指数生成函数 (EGF)**:B(x) = Σb_n x^n/n!。适用于有序选择、排列计数、有标号对象。乘法:B(x)·D(x) 的系数/n! = Σ(b_i/i!)·(d_{n−i}/(n−i)!)(排列两个有标号集合)。
171
+
172
+ 经典实例:
173
+ - 分拆函数生成函数:P(x) = Σp(n)x^n = 1/((1−x)(1−x²)(1−x³)...),分拆 = 无限制地选择1、2、3、...的组合。
174
+ - Catalan 数生成函数:C(x) = ΣC_n x^n = (1−√(1−4x))/(2x),由递推 C_n = ΣC_i·C_{n−1−i} 得 C(x) = 1 + x·C(x)²。
175
+
176
+ **生活模式**:有没有一个系统的方法来追踪所有可能性?——用结构化的方式列出所有选项,而不是逐个枚举。
177
+
178
+ **共通要点**:结构化追踪优于随机枚举——这是组合效率的核心。
179
+
180
+ ---
181
+
182
+ ### 第五步:分析图结构 / Analyze Graph Structure
183
+
184
+ **科研模式**:
185
+
186
+ 图 G = (V, E):顶点集 V,边集 E。
187
+
188
+ 核心属性与分析:
189
+ - **顶点与边**:|V| 个顶点,|E| 条边;度数 deg(v);邻接矩阵、关联矩阵
190
+ - **路径与连通**:路径、回路、连通分量;最短路径(Dijkstra, Floyd-Warshall)
191
+ - **树与森林**:n 顶点的树恰有 n−1 条边;生成树(Kruskal, Prim 最小生成树);二叉树计数 C_n
192
+ - **平面图**:Euler 公式 V − E + F = 2(连通平面图);平面图必满足 E ≤ 3V − 6
193
+ - **着色**:色数 χ(G) = 最少颜色数使相邻顶点不同色;四色定理 χ(平面图) ≤ 4
194
+ - **匹配**:二分图匹配(Hall 婚姻定理);最大匹配、完美匹配;König 定理:二分图中最大匹配 = 最小顶点覆盖
195
+ - **环与割**:Euler 环(每边恰好一次 iff 连通且所有度数为偶);Hamilton 环(每顶点恰好一次,NP-complete)
196
+
197
+ **生活模式**:事物之间的关系是什么?——谁和谁连接,连接的方式是什么,整体的结构是什么样的?
198
+
199
+ **共通要点**:关系结构决定可行方案——理解连接方式是理解系统的前提。
200
+
201
+ ---
202
+
203
+ ### 第六步:发现递推与封闭公式 / Discover Recurrence and Closed Formula
204
+
205
+ **科研模式**:
206
+ - **递推关系 (Recurrence)**:Catalan 数 C_n = ΣC_i·C_{n−1−i},Fibonacci F_n = F_{n−1} + F_{n−2},错排 D_n = (n−1)(D_{n−1} + D_{n−2})
207
+ - **通过生成函数求解**:将递推乘以 x^n,对 n 求和,解出 A(x),再提取 a_n 的封闭公式。例如 Fibonacci:F(x) = x/(1−x−x²),部分分式分解得 F_n = (φ^n − ψ^n)/√5(φ = (1+√5)/2)。
208
+ - **直接公式**:当组合结构有清晰解释时可直接推导。C(n,k) = n!/(k!(n−k)!) 来自"n 选 k 无序"的计数;Catalan C_n = C(2n,n)/(n+1) 来自"合法括号序列"的组合论证。
209
+
210
+ **生活模式**:找到规律——如果知道前几步的结果,能否推导下一步?规律一旦找到就不需要逐个计算。
211
+
212
+ **共通要点**:规律发现是效率的来源——从已知推导未知优于逐个计算。
213
+
214
+ ---
215
+
216
+ ### 第七步:验证与推广 / Verify and Generalize
217
+
218
+ **科研模式**:
219
+ - **检查小案例**:n=0, 1, 2, 3 时公式是否给出正确计数?手动枚举验证。
220
+ - **验证公式计数正确**:公式的值是否等于实际枚举数?递推是否自洽?边界条件是否正确?
221
+ - **推广规律**:公式是否对所有 n 成立?是否可推广到更一般的参数?是否有更深的组合解释?
222
+
223
+ > **验证不是可选的——未经验证的计数公式是不可信的。** n=3 的手动枚举与公式的对比是最低验证要求。
224
+
225
+ **生活模式**:验证你的枚举是否完整——有没有遗漏的选项?结论能否推广到类似情况?
226
+
227
+ **共通要点**:验证是必须的——遗漏一个选项或一个规律反例就足以推翻整个推理。
228
+
229
+ ## 常见错误 / Common Errors
230
+
231
+ | 错误 / Error | 数学批评 / Mathematical Critique | 正确做法 / Correct Approach | 标签 |
232
+ |---|---|---|---|
233
+ | 漏计与重计 (Under/Overcounting) | 漏计:遗漏约束的交互导致少计;重计:同一配置被多次计算 | 明确约束交互,用容斥修正重计,用补集计数修正漏计 | `[科研]` |
234
+ | 忽略约束条件的交互作用 | 约束不是独立的,交集的影响必须用容斥处理 | 用容斥原理:|A₁∪A₂| = |A₁| + |A₂| − |A₁∩A₂| | `[科研]` |
235
+ | 混淆排列与组合 | 排列计序 P(n,k) = n!/(n−k)!,组合不计序 C(n,k) = n!/(k!(n−k)!) | 先判断有序/无序,再选择公式 | `[通用]` |
236
+ | 错误使用容斥原理的符号 | 奇数层取正、偶数层取负,符号错误导致结果偏差 | 严格按 (−1)^{k+1} 规定符号:第 k 层交集取 (−1)^{k+1} | `[科研]` |
237
+ | 忽略生成函数的收敛域 | 生成函数作为形式幂级数可忽略收敛,但提取封闭公式需收敛域内操作 | 区分形式幂级数操作与解析操作;封闭公式提取需 x 在收敛域内 | `[科研]` |
238
+ | 混淆有标号与无标号计数 | 有标号用指数生成函数 Σb_n x^n/n!,无标号用常生成函数 Σa_n x^n | 有标号(排列/分布)→ EGF;无标号(组合/分拆)→ OGF | `[科研]` |
239
+ | 鸽巢原理使用不当 | 仅证明存在性,不构造具体实例;且需 n > m 条件才成立 | 确认 n > m 条件满足,结论为"至少一个"而非"恰好一个" | `[通用]` |
240
+ | 递推边界条件错误 | C₀ = 1(空结构计数为 1)而非 C₀ = 0;F₀ = 0, F₁ = 1 | 空结构 = 1(空排列、空组合各一种),检查 n=0,1 边界 | `[科研]` |
241
+ | 枚举遗漏 (Enumeration omission) | 列出选项时遗漏某些可能性,导致决策基础不完整 | 系统性枚举:按类别分组,检查每组是否完整 | `[生活]` |
242
+ | 忽略重叠情况 (Ignoring overlap) | 多个选项同时满足时简单相加,导致过度估计 | A或B的情况 = A的情况 + B的情况 − 重叠部分 | `[生活]` |
243
+ | 逐个尝试而非找规律 (Trial-by-trial instead of pattern) | 逐个检查所有选项而不是发现规律,效率低且易遗漏 | 先看前几步能否推导规律,有规律就不需要逐个计算 | `[生活]` |
244
+
245
+ ## 操作规程 / Operating Procedure
246
+
247
+ 当本 skill 被触发时,执行以下具体步骤:
248
+
249
+ **模式选择 / Mode Selector**:
250
+ - 若问题涉及正式计数、公式推导、存在性证明、生成函数 → **科研模式**
251
+ - 若问题涉及日常选择、有限选项枚举、规律发现、关系分析 → **生活模式**
252
+
253
+ ---
254
+
255
+ ### 科研模式输出格式 / Research Mode Output Format
256
+
257
+ 1. **结构识别**:[结构]: [离散对象描述] — 明确计数对象、约束、分类
258
+ 2. **计数类型**:[计数类型]: [排列/组合/分割/安排] — 判断有序/无序、有标号/无标号
259
+ 3. **原理选择**:[原理]: [乘法/加法/鸽巢/容斥] — 说明选择理由
260
+ 4. **生成函数**:[生成函数]: [公式] — 列出 GF 及其代数性质
261
+ 5. **图结构**:[图结构]: [属性] — 顶点、边、连通性、着色等(如涉及)
262
+ 6. **递推/公式**:[递推/公式]: [具体内容] — 递推关系及封闭公式
263
+ 7. **验证**:[验证]: [小案例检查] — 至少 n=0,1,2,3 的手动枚举与公式对比
264
+
265
+ **输出必须包含以上 7 项,不得只输出分析性文字而不给出结论。**
266
+
267
+ ---
268
+
269
+ ### 生活模式输出格式 / Life Mode Output Format
270
+
271
+ 1. **[问题类型]:[分类]** — 有限选择/排列/分配/关系
272
+ 2. **[可能数量]:[粗略估计]** — 选项很多还是只有几种
273
+ 3. **[系统性枚举]:[方法]** — 有没有遗漏
274
+ 4. **[关系结构]:[分析]** — 事物之间的连接方式
275
+ 5. **[规律发现]:[模式]** — 能否从已知推导未知
276
+ 6. **[行动建议]:[步骤]** — 基于枚举和规律的结论
277
+
278
+ **输出必须包含以上 6 项,不得只输出分析性文字而不给出结论。**
279
+
280
+ ## 与其他 skill 的关系 / Relations to Other Skills
281
+
282
+ - **归纳与类比**:组合规律由归纳发现——从枚举 {a_n} 的前几项归纳出递推,再类比到更一般结构
283
+ - **算法思想**:组合计数支撑复杂度分析——n! 排列、C(n,k) 组合是算法代价的估计基础
284
+ - **概率与统计**:组合是概率的计算基础——古典概率 P(A) = |A|/|Ω|,分母 |Ω| 和分子 |A| 都是组合计数
285
+ - **变换思想**:生成函数将计数变换为代数——序列 → 幂级数,递推 → 方程,计数 → 系数提取
286
+ - **公理化思想**:组合恒等式的严格证明——C(n,k) = C(n,n−k) 需代数证明或组合论证,不可仅凭直觉
@@ -0,0 +1,185 @@
1
+ # 离散与组合思想 — 原始文献与历史语境 / Discrete & Combinatorial Thinking — Original Texts & Historical Context
2
+
3
+ ---
4
+
5
+ ## 1. Pigeonhole Principle — Dirichlet (1834) / 鸽巢原理 — Dirichlet (1834)
6
+
7
+ Peter Gustav Lejeune Dirichlet 在 1834 年以"Schubfachprinzip"(抽屉原理)阐述鸽巢原理,用于数论存在性证明。
8
+
9
+ > "Wenn man n + 1 Objecte in n Facher distribuiert, so ist mindestens ein Fach mit zwei Objecten besetzt."
10
+ > — Dirichlet, 1834
11
+
12
+ **核心陈述 / Core statement:**
13
+ - 基本形式:若 n 物品放入 m 个盒子且 n > m,则某盒子含至少 ⌈n/m⌉ 个物品
14
+ - 推广形式:kn+1 物品入 n 盒子 → 某盒至少含 k+1 个物品
15
+ - 数论应用:对任意实数 α 和整数 N,存在 q ≤ N 使得 |qα − p| < 1/(N+1)(即 qα 逼近整数)
16
+
17
+ **Diophantine 逼近 / Diophantine approximation:** 将 [0,1) 分为 N+1 个等长区间("盒子"),考虑 N+2 个数 {0, {α}, {2α}, ..., {(N+1)α}}("物品"),鸽巢保证必有两个落入同一区间,得 |(q₁−q₂)α − ⌊(q₁−q₂)α⌋| < 1/(N+1)。这是 Dirichlet 逼近定理的标准鸽巢证明。
18
+
19
+ ---
20
+
21
+ ## 2. Euler's Generating Functions (1748) / Euler 的生成函数 (1748)
22
+
23
+ Leonhard Euler 在 **Introductio in analysin infinitorum** (1748) 中开创生成函数方法——序列变换为幂级数,计数变换为代数运算。
24
+
25
+ > "If we ask how many ways a given number can be partitioned, we are led to a study of the generating function." — Euler, 1748
26
+
27
+ **分拆函数生成函数 / Partition GF:**
28
+ $$P(x) = \sum_{n=0}^{\infty} p(n) x^n = \prod_{k=1}^{\infty} \frac{1}{1-x^k}$$
29
+ - p(n) = 将 n 分为正整数之和的分拆数。p(5) = 7:{5, 4+1, 3+2, 3+1+1, 2+2+1, 2+1+1+1, 1+1+1+1+1}
30
+ - 乘积形式:1/(1−x^k) = 1+x^k+x^{2k}+... 表示"取 k 的 0,1,2,... 次",各 k 独立故乘积编码组合
31
+
32
+ **五角数定理 / Pentagonal number theorem (Euler 1750):**
33
+ $$\prod_{k=1}^{\infty}(1-x^k) = \sum_{m=-\infty}^{\infty} (-1)^m x^{m(3m-1)/2}$$
34
+ - 广义五角数 e_m = m(3m−1)/2:0, 1, 2, 5, 7, 12, 15, 22, ...
35
+ - 由 P(x)·∏(1−x^k) = Σ(−1)^m x^{e_m},得递推 p(n) = p(n−1)+p(n−2)−p(n−5)−p(n−7)+...
36
+ - 这是有限递推控制无限序列的经典实例——组合思想的精髓
37
+
38
+ **Hardy-Ramanujan 渐近公式 (1918):**
39
+ $$p(n) \sim \frac{1}{4n\sqrt{3}} \exp\left(\pi\sqrt{\frac{2n}{3}}\right)$$
40
+
41
+ ---
42
+
43
+ ## 3. Catalan Numbers / Catalan 数
44
+
45
+ **历史 / History:** Eugène Catalan (1838) 研究括号嵌套的计数问题,Catalan 数由此得名。但 Euler 早在 1751 年就研究过类似问题(多边形三角剖分)。
46
+
47
+ **定义与公式 / Definition and formula:**
48
+ $$C_n = \frac{1}{n+1}\binom{2n}{n} = \frac{(2n)!}{n!(n+1)!}$$
49
+ - 递推:C₀ = 1, C_n = ΣC_i·C_{n−1−i}
50
+ - 生成函数:C(x) = ΣC_n x^n = (1−√(1−4x))/(2x),由 C(x) = 1 + x·C(x)² 解得
51
+
52
+ **组合解释(60+种) / Combinatorial interpretations (60+):**
53
+ - **二叉树**:n 个节点的有序二叉树数 = C_n
54
+ - **Dyck 路径**:从 (0,0) 到 (2n,0) 的格点路径,每步 (+1,+1) 或 (+1,−1),不越 y=0
55
+ - **括号序列**:n 对括号的合法嵌套方式数 = C_n
56
+ - **投票问题 (Ballot problem)**:A 得 n+1 票、B 得 n 票,A 全程领先 B 的序列数 = C_n(Bertrand 1887)
57
+ - **多边形三角剖分**:n+2 边形的不同三角剖分数 = C_n
58
+
59
+ 前几项:C₀=1, C₁=1, C₂=2, C₃=5, C₄=14, C₅=42, C₆=132
60
+
61
+ ---
62
+
63
+ ## 4. Ramsey Theory — Ramsey (1930) / Ramsey 理论 — Ramsey (1930)
64
+
65
+ Frank P. Ramsey 在 **"On a Problem of Formal Logic"** (1930) 中证明:足够大的系统必存在某种结构——鸽巢原理的深刻推广。
66
+
67
+ > "In any sufficiently large system, complete disorder is impossible." — Cohen
68
+
69
+ **Ramsey 数 / Ramsey numbers:**
70
+ $$R(s,t) = \min\{n : \text{任意 } n \text{ 阶 2-色完全图中必有红 } K_s \text{ 或蓝 } K_t\}$$
71
+
72
+ **已知值:** R(3,3)=6(6人聚会必有3人互识或互不识;证明:固定一人,5人中至少3人同色关系(鸽巢),此3人中若2人同色则3人组,否则此3人构成另一色3人组), R(4,4)=18, R(3,4)=9, R(3,5)=14.
73
+
74
+ **一般界:** Erdős 1947 概率方法: R(k,k) > 2^{k/2}; 上界 R(k,k) ≤ 4^k. R(5,5)未知(43≤R(5,5)≤48). Erdős:"外星人要R(5,5)就动员所有计算机;要R(6,6)就准备战斗。"
75
+
76
+ ---
77
+
78
+ ## 5. Graph Theory — Euler (1736) / 图论 — Euler (1736)
79
+
80
+ **Königsberg 七桥问题 / Seven Bridges of Königsberg (1736):**
81
+
82
+ Leonhard Euler 在 **"Solutio problematis ad geometriam situs pertinentis"** (1736) 解决柯尼斯堡七桥问题,开创图论。
83
+
84
+ > "The problem... is to find whether one can cross each of the seven bridges exactly once and return to the starting point." — Euler, 1736
85
+
86
+ **Euler 环定理 / Euler circuit theorem:**
87
+ - 连通图存在 Euler 环(经过每边恰好一次的闭路径)iff 所有顶点度数为偶数
88
+ - 柯尼斯堡图:4 个顶点度数为 3, 3, 3, 5(均为奇数),故 Euler 环不存在——问题无解
89
+
90
+ **Euler 平面图公式 / Euler's planar formula (1750):**
91
+ $$V - E + F = 2$$
92
+ - 对任意连通平面图:顶点数 V、边数 E、面数 F 满足此公式
93
+ - 推论:简单连通平面图 E ≤ 3V − 6;不含 K₃ 的平面图 E ≤ 2V − 4
94
+
95
+ **匹配理论 / Matching theory:**
96
+ - König (1931):二分图中最大匹配数 = 最小顶点覆盖数(König 定理)
97
+ - Hall 婚姻定理 (1935):二分图 G(X,Y) 有 X 到 Y 的完美匹配 iff 对任意 S ⊆ X,|N(S)| ≥ |S|
98
+
99
+ ---
100
+
101
+ ## 6. Pólya Enumeration Theorem (1937) / Pólya 计数定理 (1937)
102
+
103
+ George Pólya 在 1937 年的论文中给出对称性下的计数方法——轨道计数定理,组合计数与群论的交汇点。
104
+
105
+ > "The number of distinct colorings is obtained by averaging over the group action." — Pólya, 1937
106
+
107
+ **定理陈述 / Theorem statement:**
108
+ 设群 G 作用于集合 X,k-着色等价类数(轨道数):
109
+ $$N = \frac{1}{|G|} \sum_{g \in G} k^{c(g)}$$
110
+ c(g) = 置换 g 的循环数。应用: 化学异构体、珠串图案。Burnside 引理 (1897): N = (1/|G|)Σ|Fix(g)|,是 Pólya 特例。Pólya 推广为带权版本: GF × 循环指数 = 对称计数。
111
+
112
+ ---
113
+
114
+ ## 7. Inclusion-Exclusion Principle / 容斥原理
115
+
116
+ **历史:** da Vinci 用容斥思想计算面积;Sylvester (1882) 形式化。容斥处理交集重叠——直接相加重计交集,需逐层修正。
117
+
118
+ 基本形式: |A₁∪...∪A_n| = Σ|A_i| − Σ|A_i∩A_j| + ... ± |A₁∩...∩A_n|. 补集计数: "不具有P" = 全部 − "具有P".
119
+
120
+ **错排数:** D(n) = n! − C(n,1)(n−1)! + C(n,2)(n−2)! − ... = n!Σ(−1)^k/k! ≈ n!/e (n→∞). 概率形式: P(A₁∪...∪A_n) = ΣP(A_i) − ΣP(A_i∩A_j) + ...
121
+
122
+ ---
123
+
124
+ ## 8. Recurrence Relations / 递推关系
125
+
126
+ **Fibonacci 数列 / Fibonacci sequence:**
127
+ $$F_0 = 0, F_1 = 1, F_n = F_{n-1} + F_{n-2}$$
128
+ - 生成函数:F(x) = ΣF_n x^n = x/(1−x−x²)
129
+ - Binet 公式:F_n = (φ^n − ψ^n)/√5,φ = (1+√5)/2 ≈ 1.618(黄金比)
130
+
131
+ **汉诺塔 / Tower of Hanoi:**
132
+ $$T_1 = 1, T_n = 2T_{n-1} + 1$$
133
+ - 解:T_n = 2^n − 1。64 层需 2^{64} − 1 ≈ 1.8×10^{19} 步
134
+
135
+ **GF 求解递推 / Solving recurrences via GF:**
136
+ 1. 递推乘以 x^n,对 n 求和 → A(x) 的方程
137
+ 2. 利用初始条件,解出 A(x)(代数/微分方程)
138
+ 3. 提取 a_n:部分分式、Taylor 展开、幂级数对照
139
+
140
+ **Catalan GF 推导:** C(x) = 1 + x·C(x)² → 解 x·C² − C + 1 = 0 → C(x) = (1−√(1−4x))/(2x) → C_n = (1/(n+1))C(2n,n)
141
+
142
+ ---
143
+
144
+ ## 9. Combinatorial Optimization / 组合优化
145
+
146
+ **最小生成树 / Minimum spanning tree:**
147
+ - Kruskal (1956):按边权升序贪心选取不成环的边,O(E log E)
148
+ - Prim (1957):从单点扩展,每次选最小权连接边,O(E log V)(优先队列)
149
+
150
+ **最大流最小割 / Max-flow min-cut:**
151
+ - Ford-Fulkerson (1956):增广路径法,流量逐步增加直至无增广路径
152
+ - 最大流最小割定理:最大流值 = 最小割容量(LP 对偶性的组合表现)
153
+ - Edmonds-Karp (1972):BFS 选最短增广路径,保证 O(VE²)
154
+
155
+ **匹配理论 / Matching theory:**
156
+ - Hungarian 算法 (Kuhn 1955):O(V³) 最大加权二分匹配
157
+ - Edmonds 带花树算法 (1965):一般图最大匹配,O(V³)
158
+
159
+ ---
160
+
161
+ ## 10. The Twelvefold Way / 十二重道
162
+
163
+ Richard P. Stanley 在 **Enumerative Combinatorics Vol. 1** 中统一分类 n球入k盒的12种基本计数(2×2×3: 球有标号/无标号 × 盒有标号/无标号 × 任意/至多1/至少1):
164
+
165
+ | 球 / Balls | 盒子 / Boxes | 条件 / Condition | 公式 / Formula |
166
+ |---|---|---|---|
167
+ | 有标号 distinct | 有标号 distinct | 任意 any | k^n |
168
+ | 无标号 identical | 有标号 distinct | 任意 any | C(n+k−1, k−1) |
169
+ | 有标号 distinct | 无标号 identical | 任意 any | Σ S₂(n,i), i=1..k |
170
+ | 无标号 identical | 无标号 identical | 任意 any | p_k(n)(受限分拆) |
171
+ | 有标号 distinct | 有标号 distinct | 至多一个 ≤1 | P(k,n) = k!/(k−n)! |
172
+ | 无标号 identical | 有标号 distinct | 至多一个 ≤1 | C(k,n) |
173
+ | 有标号 distinct | 无标号 identical | 至多一个 ≤1 | 1 if n≤k, 0 else |
174
+ | 无标号 identical | 无标号 identical | 至多一个 ≤1 | 1 if n≤k, 0 else |
175
+ | 有标号 distinct | 有标号 distinct | 至少一个 ≥1 | k!·S₂(n,k) |
176
+ | 无标号 identical | 有标号 distinct | 至至少一个 ≥1 | C(n−1, k−1) |
177
+ | 有标号 distinct | 无标号 identical | 至少一个 ≥1 | S₂(n,k) − S₂(n,k−1) |
178
+ | 无标号 identical | 无标号 identical | 至少一个 ≥1 | p_k(n) − p_{k−1}(n) |
179
+
180
+ **关键洞察:** 2×2×3=12种基本计数覆盖组合数学核心场景。有标号用EGF,无标号用OGF。**Stirling数:** S₁(n,k)=n元素k循环排列数; S₂(n,k)=n元素k非空子集数。
181
+
182
+ ---
183
+
184
+ *本文件为离散与组合思想技能的数学参考与历史语境,涵盖从 Euler 到现代组合数学的核心成果。*
185
+ *This file provides mathematical references and historical context for the discrete-combinatorial skill, covering core results from Euler to modern combinatorics.*