math-skill 2.1.0 → 3.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 (234) hide show
  1. package/README.en-US.md +159 -200
  2. package/README.md +159 -200
  3. package/agents/math-critic.en.md +2 -2
  4. package/agents/math-critic.md +8 -8
  5. package/commands/ask.md +3 -10
  6. package/design-patterns/attention/equivariant-attention.en.md +72 -0
  7. package/design-patterns/attention/equivariant-attention.md +72 -0
  8. package/design-patterns/attention/geometry-aware-attention.en.md +73 -0
  9. package/design-patterns/attention/geometry-aware-attention.md +72 -0
  10. package/design-patterns/attention/information-bottleneck-attention.en.md +72 -0
  11. package/design-patterns/attention/information-bottleneck-attention.md +72 -0
  12. package/design-patterns/attention/projection-attention.en.md +68 -0
  13. package/design-patterns/attention/projection-attention.md +68 -0
  14. package/design-patterns/attention/spectral-attention.en.md +71 -0
  15. package/design-patterns/attention/spectral-attention.md +71 -0
  16. package/design-patterns/compression/leverage-score-selection.en.md +71 -0
  17. package/design-patterns/compression/leverage-score-selection.md +71 -0
  18. package/design-patterns/compression/low-rank-kv-cache.en.md +60 -0
  19. package/design-patterns/compression/low-rank-kv-cache.md +60 -0
  20. package/design-patterns/compression/spectral-token-pruning.en.md +61 -0
  21. package/design-patterns/compression/spectral-token-pruning.md +61 -0
  22. package/design-patterns/compression/topology-preserving-compression.en.md +64 -0
  23. package/design-patterns/compression/topology-preserving-compression.md +64 -0
  24. package/design-patterns/loss/constraint-penalty.en.md +67 -0
  25. package/design-patterns/loss/constraint-penalty.md +78 -0
  26. package/design-patterns/loss/contrastive-loss.en.md +59 -0
  27. package/design-patterns/loss/contrastive-loss.md +68 -0
  28. package/design-patterns/loss/information-bottleneck-loss.en.md +69 -0
  29. package/design-patterns/loss/information-bottleneck-loss.md +74 -0
  30. package/design-patterns/loss/orthogonality-loss.en.md +56 -0
  31. package/design-patterns/loss/orthogonality-loss.md +60 -0
  32. package/design-patterns/loss/variational-loss.en.md +61 -0
  33. package/design-patterns/loss/variational-loss.md +71 -0
  34. package/design-patterns/representation/equivariant-split.en.md +87 -0
  35. package/design-patterns/representation/equivariant-split.md +89 -0
  36. package/design-patterns/representation/manifold-representation.en.md +85 -0
  37. package/design-patterns/representation/manifold-representation.md +87 -0
  38. package/design-patterns/representation/shared-private-decomposition.en.md +84 -0
  39. package/design-patterns/representation/shared-private-decomposition.md +86 -0
  40. package/design-patterns/representation/subspace-alignment.en.md +90 -0
  41. package/design-patterns/representation/subspace-alignment.md +92 -0
  42. package/design-patterns/routing/graph-routing.en.md +79 -0
  43. package/design-patterns/routing/graph-routing.md +81 -0
  44. package/design-patterns/routing/moe-routing.en.md +85 -0
  45. package/design-patterns/routing/moe-routing.md +87 -0
  46. package/design-patterns/routing/optimal-transport-routing.en.md +68 -0
  47. package/design-patterns/routing/optimal-transport-routing.md +72 -0
  48. package/design-patterns/routing/spectral-clustering-routing.en.md +88 -0
  49. package/design-patterns/routing/spectral-clustering-routing.md +90 -0
  50. package/knowledge-base/differential-geometry/connection.en.md +51 -0
  51. package/knowledge-base/differential-geometry/connection.md +51 -0
  52. package/knowledge-base/differential-geometry/curvature.en.md +49 -0
  53. package/knowledge-base/differential-geometry/curvature.md +49 -0
  54. package/knowledge-base/differential-geometry/geodesic.en.md +51 -0
  55. package/knowledge-base/differential-geometry/geodesic.md +51 -0
  56. package/knowledge-base/differential-geometry/manifold.en.md +47 -0
  57. package/knowledge-base/differential-geometry/manifold.md +47 -0
  58. package/knowledge-base/differential-geometry/metric-tensor.en.md +50 -0
  59. package/knowledge-base/differential-geometry/metric-tensor.md +50 -0
  60. package/knowledge-base/differential-geometry/tangent-space.en.md +48 -0
  61. package/knowledge-base/differential-geometry/tangent-space.md +48 -0
  62. package/knowledge-base/information-geometry/fisher-metric.en.md +56 -0
  63. package/knowledge-base/information-geometry/fisher-metric.md +56 -0
  64. package/knowledge-base/information-geometry/natural-gradient.en.md +54 -0
  65. package/knowledge-base/information-geometry/natural-gradient.md +54 -0
  66. package/knowledge-base/lie-theory/equivariance.en.md +54 -0
  67. package/knowledge-base/lie-theory/equivariance.md +54 -0
  68. package/knowledge-base/lie-theory/group-action.en.md +51 -0
  69. package/knowledge-base/lie-theory/group-action.md +51 -0
  70. package/knowledge-base/lie-theory/lie-algebra.en.md +51 -0
  71. package/knowledge-base/lie-theory/lie-algebra.md +51 -0
  72. package/knowledge-base/lie-theory/lie-group.en.md +51 -0
  73. package/knowledge-base/lie-theory/lie-group.md +51 -0
  74. package/knowledge-base/lie-theory/representation.en.md +52 -0
  75. package/knowledge-base/lie-theory/representation.md +52 -0
  76. package/knowledge-base/matrix-analysis/low-rank-approximation.en.md +49 -0
  77. package/knowledge-base/matrix-analysis/low-rank-approximation.md +49 -0
  78. package/knowledge-base/matrix-analysis/matrix-perturbation.en.md +49 -0
  79. package/knowledge-base/matrix-analysis/matrix-perturbation.md +49 -0
  80. package/knowledge-base/matrix-analysis/positive-semidefinite.en.md +50 -0
  81. package/knowledge-base/matrix-analysis/positive-semidefinite.md +50 -0
  82. package/knowledge-base/matrix-analysis/projection.en.md +47 -0
  83. package/knowledge-base/matrix-analysis/projection.md +47 -0
  84. package/knowledge-base/matrix-analysis/spectral-decomposition.en.md +48 -0
  85. package/knowledge-base/matrix-analysis/spectral-decomposition.md +48 -0
  86. package/knowledge-base/optimization/constrained-optimization.en.md +53 -0
  87. package/knowledge-base/optimization/constrained-optimization.md +53 -0
  88. package/knowledge-base/optimization/convex-optimization.en.md +50 -0
  89. package/knowledge-base/optimization/convex-optimization.md +50 -0
  90. package/knowledge-base/optimization/lagrangian-duality.en.md +50 -0
  91. package/knowledge-base/optimization/lagrangian-duality.md +50 -0
  92. package/knowledge-base/optimization/proximal-method.en.md +52 -0
  93. package/knowledge-base/optimization/proximal-method.md +52 -0
  94. package/knowledge-base/optimization/riemannian-optimization.en.md +51 -0
  95. package/knowledge-base/optimization/riemannian-optimization.md +51 -0
  96. package/knowledge-base/overview.en.md +29 -218
  97. package/knowledge-base/overview.md +29 -220
  98. package/knowledge-base/probability/concentration-inequality.en.md +45 -0
  99. package/knowledge-base/probability/concentration-inequality.md +45 -0
  100. package/knowledge-base/probability/entropy.en.md +47 -0
  101. package/knowledge-base/probability/entropy.md +47 -0
  102. package/knowledge-base/probability/fisher-information.en.md +48 -0
  103. package/knowledge-base/probability/fisher-information.md +48 -0
  104. package/knowledge-base/probability/information-bottleneck.en.md +49 -0
  105. package/knowledge-base/probability/information-bottleneck.md +49 -0
  106. package/knowledge-base/probability/kl-divergence.en.md +51 -0
  107. package/knowledge-base/probability/kl-divergence.md +51 -0
  108. package/knowledge-base/topology/euler-characteristic.en.md +54 -0
  109. package/knowledge-base/topology/euler-characteristic.md +54 -0
  110. package/knowledge-base/topology/fundamental-group.en.md +52 -0
  111. package/knowledge-base/topology/fundamental-group.md +52 -0
  112. package/knowledge-base/topology/persistent-homology.en.md +54 -0
  113. package/knowledge-base/topology/persistent-homology.md +54 -0
  114. package/lenses/algorithmic.en.md +49 -0
  115. package/lenses/algorithmic.md +49 -0
  116. package/lenses/axiomatization.en.md +48 -0
  117. package/lenses/axiomatization.md +48 -0
  118. package/lenses/categorical.en.md +48 -0
  119. package/lenses/categorical.md +48 -0
  120. package/lenses/causal.en.md +49 -0
  121. package/lenses/causal.md +49 -0
  122. package/lenses/duality.en.md +47 -0
  123. package/lenses/duality.md +47 -0
  124. package/lenses/game.en.md +50 -0
  125. package/lenses/game.md +50 -0
  126. package/lenses/geometric.en.md +53 -0
  127. package/lenses/geometric.md +53 -0
  128. package/lenses/local-to-global.en.md +52 -0
  129. package/lenses/local-to-global.md +52 -0
  130. package/lenses/perturbation.en.md +51 -0
  131. package/lenses/perturbation.md +51 -0
  132. package/lenses/probabilistic.en.md +48 -0
  133. package/lenses/probabilistic.md +48 -0
  134. package/lenses/projection.en.md +50 -0
  135. package/lenses/projection.md +50 -0
  136. package/lenses/spectral.en.md +52 -0
  137. package/lenses/spectral.md +52 -0
  138. package/lenses/symmetry.en.md +49 -0
  139. package/lenses/symmetry.md +49 -0
  140. package/lenses/topological.en.md +48 -0
  141. package/lenses/topological.md +48 -0
  142. package/lenses/variational.en.md +48 -0
  143. package/lenses/variational.md +48 -0
  144. package/package.json +9 -3
  145. package/references/books/abstract-algebra.md +5 -5
  146. package/references/books/algebraic-geometry-rising-sea.md +5 -5
  147. package/references/books/differential-geometry.md +3 -3
  148. package/references/books/matrix-analysis.md +4 -4
  149. package/references/books/micro-lie-theory.md +3 -3
  150. package/references/books/optimization-ml.md +1 -1
  151. package/references/books/smooth-manifolds.md +3 -3
  152. package/references/gpu-friendly-math.en.md +8 -8
  153. package/references/gpu-friendly-math.md +2 -2
  154. package/references/inspiration.en.md +1 -1
  155. package/references/inspiration.md +2 -2
  156. package/skills/math-research-activator/SKILL.en.md +161 -106
  157. package/skills/math-research-activator/SKILL.md +162 -110
  158. package/skills/math-research-activator/original-texts.en.md +9 -9
  159. package/skills/math-research-activator/original-texts.md +11 -11
  160. package/commands/abstraction.md +0 -11
  161. package/commands/algorithmic-thinking.md +0 -11
  162. package/commands/axiomatization.md +0 -11
  163. package/commands/causal-inference.md +0 -11
  164. package/commands/discrete-combinatorial.md +0 -11
  165. package/commands/game-theory.md +0 -11
  166. package/commands/induction-analogy.md +0 -11
  167. package/commands/information-theory.md +0 -11
  168. package/commands/logic-deduction.md +0 -11
  169. package/commands/modeling.md +0 -11
  170. package/commands/optimization.md +0 -11
  171. package/commands/probability-statistics.md +0 -11
  172. package/commands/symmetry-invariance.md +0 -11
  173. package/commands/topological-thinking.md +0 -11
  174. package/commands/transformation.md +0 -11
  175. package/skills/abstraction/SKILL.en.md +0 -117
  176. package/skills/abstraction/SKILL.md +0 -121
  177. package/skills/abstraction/original-texts.en.md +0 -163
  178. package/skills/abstraction/original-texts.md +0 -175
  179. package/skills/algorithmic-thinking/SKILL.en.md +0 -132
  180. package/skills/algorithmic-thinking/SKILL.md +0 -138
  181. package/skills/algorithmic-thinking/original-texts.en.md +0 -253
  182. package/skills/algorithmic-thinking/original-texts.md +0 -256
  183. package/skills/axiomatization/SKILL.en.md +0 -144
  184. package/skills/axiomatization/SKILL.md +0 -151
  185. package/skills/axiomatization/original-texts.en.md +0 -154
  186. package/skills/axiomatization/original-texts.md +0 -160
  187. package/skills/causal-inference/SKILL.en.md +0 -147
  188. package/skills/causal-inference/SKILL.md +0 -151
  189. package/skills/causal-inference/original-texts.en.md +0 -136
  190. package/skills/causal-inference/original-texts.md +0 -167
  191. package/skills/discrete-combinatorial/SKILL.en.md +0 -124
  192. package/skills/discrete-combinatorial/SKILL.md +0 -131
  193. package/skills/discrete-combinatorial/original-texts.en.md +0 -184
  194. package/skills/discrete-combinatorial/original-texts.md +0 -185
  195. package/skills/game-theory/SKILL.en.md +0 -117
  196. package/skills/game-theory/SKILL.md +0 -123
  197. package/skills/game-theory/original-texts.en.md +0 -131
  198. package/skills/game-theory/original-texts.md +0 -131
  199. package/skills/induction-analogy/SKILL.en.md +0 -145
  200. package/skills/induction-analogy/SKILL.md +0 -152
  201. package/skills/induction-analogy/original-texts.en.md +0 -140
  202. package/skills/induction-analogy/original-texts.md +0 -154
  203. package/skills/information-theory/SKILL.en.md +0 -134
  204. package/skills/information-theory/SKILL.md +0 -140
  205. package/skills/information-theory/original-texts.en.md +0 -127
  206. package/skills/information-theory/original-texts.md +0 -127
  207. package/skills/logic-deduction/SKILL.en.md +0 -130
  208. package/skills/logic-deduction/SKILL.md +0 -135
  209. package/skills/logic-deduction/original-texts.en.md +0 -160
  210. package/skills/logic-deduction/original-texts.md +0 -173
  211. package/skills/modeling/SKILL.en.md +0 -135
  212. package/skills/modeling/SKILL.md +0 -139
  213. package/skills/modeling/original-texts.en.md +0 -162
  214. package/skills/modeling/original-texts.md +0 -165
  215. package/skills/optimization/SKILL.en.md +0 -129
  216. package/skills/optimization/SKILL.md +0 -135
  217. package/skills/optimization/original-texts.en.md +0 -167
  218. package/skills/optimization/original-texts.md +0 -168
  219. package/skills/probability-statistics/SKILL.en.md +0 -146
  220. package/skills/probability-statistics/SKILL.md +0 -151
  221. package/skills/probability-statistics/original-texts.en.md +0 -191
  222. package/skills/probability-statistics/original-texts.md +0 -193
  223. package/skills/symmetry-invariance/SKILL.en.md +0 -135
  224. package/skills/symmetry-invariance/SKILL.md +0 -139
  225. package/skills/symmetry-invariance/original-texts.en.md +0 -206
  226. package/skills/symmetry-invariance/original-texts.md +0 -221
  227. package/skills/topological-thinking/SKILL.en.md +0 -124
  228. package/skills/topological-thinking/SKILL.md +0 -128
  229. package/skills/topological-thinking/original-texts.en.md +0 -134
  230. package/skills/topological-thinking/original-texts.md +0 -164
  231. package/skills/transformation/SKILL.en.md +0 -120
  232. package/skills/transformation/SKILL.md +0 -124
  233. package/skills/transformation/original-texts.en.md +0 -204
  234. package/skills/transformation/original-texts.md +0 -216
@@ -1,184 +0,0 @@
1
- # Discrete & Combinatorial Thinking — Original Texts & Historical Context
2
-
3
- ---
4
-
5
- ## 1. Pigeonhole Principle — Dirichlet (1834)
6
-
7
- Peter Gustav Lejeune Dirichlet stated the pigeonhole principle in 1834 as the "Schubfachprinzip" (drawer principle), using it for existential proofs in number theory.
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
- - Basic form: if n items are placed into m boxes and n > m, then some box contains at least ⌈n/m⌉ items
14
- - Generalized form: kn+1 items into n boxes → some box contains at least k+1 items
15
- - Number theory application: for any real number α and integer N, there exists q ≤ N such that |qα − p| < 1/(N+1) (i.e., qα approximates an integer)
16
-
17
- **Diophantine approximation:** Partition [0,1) into N+1 equal-length intervals ("boxes"), and consider the N+2 numbers {0, {α}, {2α}, ..., {(N+1)α}} ("items"). The pigeonhole principle guarantees that two must fall into the same interval, yielding |(q₁−q₂)α − ⌊(q₁−q₂)α⌋| < 1/(N+1). This is the standard pigeonhole proof of Dirichlet's approximation theorem.
18
-
19
- ---
20
-
21
- ## 2. Euler's Generating Functions (1748)
22
-
23
- Leonhard Euler pioneered the generating function method in **Introductio in analysin infinitorum** (1748) — transforming sequences into power series, and counting into algebraic operations.
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 generating function:**
28
- $$P(x) = \sum_{n=0}^{\infty} p(n) x^n = \prod_{k=1}^{\infty} \frac{1}{1-x^k}$$
29
- - p(n) = the number of partitions of n into positive integers. p(5) = 7: {5, 4+1, 3+2, 3+1+1, 2+2+1, 2+1+1+1, 1+1+1+1+1}
30
- - Product form: 1/(1−x^k) = 1+x^k+x^{2k}+... represents "taking 0, 1, 2, ... copies of k"; since each k is independent, the product encodes all combinations
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
- - Generalized pentagonal numbers e_m = m(3m−1)/2: 0, 1, 2, 5, 7, 12, 15, 22, ...
35
- - From P(x)·∏(1−x^k) = Σ(−1)^m x^{e_m}, one obtains the recurrence p(n) = p(n−1)+p(n−2)−p(n−5)−p(n−7)+...
36
- - This is a classic example of a finite recurrence controlling an infinite sequence — the essence of combinatorial thinking
37
-
38
- **Hardy-Ramanujan asymptotic formula (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
44
-
45
- **History:** Eugène Catalan (1838) studied the counting problem of nested parentheses, from which the Catalan numbers derive their name. However, Euler had already studied a related problem (polygon triangulation) in 1751.
46
-
47
- **Definition and formula:**
48
- $$C_n = \frac{1}{n+1}\binom{2n}{n} = \frac{(2n)!}{n!(n+1)!}$$
49
- - Recurrence: C₀ = 1, C_n = ΣC_i·C_{n−1−i}
50
- - Generating function: C(x) = ΣC_n x^n = (1−√(1−4x))/(2x), obtained by solving C(x) = 1 + x·C(x)²
51
-
52
- **Combinatorial interpretations (60+):**
53
- - **Binary trees**: the number of ordered binary trees with n nodes = C_n
54
- - **Dyck paths**: lattice paths from (0,0) to (2n,0), with steps (+1,+1) or (+1,−1), never crossing above y=0
55
- - **Parenthesizations**: the number of valid nestings of n pairs of parentheses = C_n
56
- - **Ballot problem**: A receives n+1 votes, B receives n votes; the number of sequences in which A is always ahead of B = C_n (Bertrand 1887)
57
- - **Polygon triangulation**: the number of distinct triangulations of an (n+2)-gon = C_n
58
-
59
- First few terms: C₀=1, C₁=1, C₂=2, C₃=5, C₄=14, C₅=42, C₆=132
60
-
61
- ---
62
-
63
- ## 4. Ramsey Theory — Ramsey (1930)
64
-
65
- Frank P. Ramsey proved in **"On a Problem of Formal Logic"** (1930) that sufficiently large systems necessarily contain some structure — a profound generalization of the pigeonhole principle.
66
-
67
- > "In any sufficiently large system, complete disorder is impossible." — Cohen
68
-
69
- **Ramsey numbers:**
70
- $$R(s,t) = \min\{n : \text{every 2-coloring of the complete graph on } n \text{ vertices contains a red } K_s \text{ or a blue } K_t\}$$
71
-
72
- **Known values:** R(3,3)=6 (at a party of 6 people, there must be 3 mutual acquaintances or 3 mutual strangers; proof: fix one person, among the remaining 5 at least 3 share the same relationship color by the pigeonhole principle; if any 2 of those 3 share that color they form a monochromatic triangle, otherwise those 3 form a triangle of the other color), R(4,4)=18, R(3,4)=9, R(3,5)=14.
73
-
74
- **General bounds:** Erdős 1947 probabilistic method: R(k,k) > 2^{k/2}; upper bound R(k,k) ≤ 4^k. R(5,5) is unknown (43 ≤ R(5,5) ≤ 48). Erdős: "If aliens demanded R(5,5), we should marshal all our computers; if they demanded R(6,6), we should prepare for battle."
75
-
76
- ---
77
-
78
- ## 5. Graph Theory — Euler (1736)
79
-
80
- **Seven Bridges of Königsberg (1736):**
81
-
82
- Leonhard Euler, in **"Solutio problematis ad geometriam situs pertinentis"** (1736), solved the Königsberg bridge problem, founding graph theory.
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 circuit theorem:**
87
- - A connected graph has an Euler circuit (a closed walk traversing every edge exactly once) if and only if all vertices have even degree
88
- - The Königsberg graph: the 4 vertices have degrees 3, 3, 3, 5 (all odd), so no Euler circuit exists — the problem has no solution
89
-
90
- **Euler's planar formula (1750):**
91
- $$V - E + F = 2$$
92
- - For any connected planar graph: the number of vertices V, edges E, and faces F satisfy this formula
93
- - Corollaries: for a simple connected planar graph E ≤ 3V − 6; for a planar graph containing no K₃, E ≤ 2V − 4
94
-
95
- **Matching theory:**
96
- - König (1931): in a bipartite graph, the maximum matching size = the minimum vertex cover size (König's theorem)
97
- - Hall's marriage theorem (1935): a bipartite graph G(X,Y) has a perfect matching from X to Y if and only if for every S ⊆ X, |N(S)| ≥ |S|
98
-
99
- ---
100
-
101
- ## 6. Pólya Enumeration Theorem (1937)
102
-
103
- George Pólya, in his 1937 paper, provided a counting method under symmetry — the orbit counting theorem, the meeting point of combinatorial enumeration and group theory.
104
-
105
- > "The number of distinct colorings is obtained by averaging over the group action." — Pólya, 1937
106
-
107
- **Theorem statement:**
108
- Let group G act on set X. The number of equivalence classes of k-colorings (number of orbits):
109
- $$N = \frac{1}{|G|} \sum_{g \in G} k^{c(g)}$$
110
- where c(g) = the number of cycles of the permutation g. Applications: chemical isomers, bead necklace patterns. Burnside's lemma (1897): N = (1/|G|)Σ|Fix(g)| is a special case of Pólya's theorem. Pólya generalized this to a weighted version: GF × cycle index = symmetric counting.
111
-
112
- ---
113
-
114
- ## 7. Inclusion-Exclusion Principle
115
-
116
- **History:** da Vinci used inclusion-exclusion ideas to compute areas; Sylvester (1882) formalized the principle. Inclusion-exclusion handles overlapping intersections — direct addition double-counts intersections, requiring successive corrections.
117
-
118
- Basic form: |A₁∪...∪A_n| = Σ|A_i| − Σ|A_i∩A_j| + ... ± |A₁∩...∩A_n|. Complement counting: "not having property P" = total − "having property P."
119
-
120
- **Derangements:** D(n) = n! − C(n,1)(n−1)! + C(n,2)(n−2)! − ... = n!Σ(−1)^k/k! ≈ n!/e as n→∞. Probability form: P(A₁∪...∪A_n) = ΣP(A_i) − ΣP(A_i∩A_j) + ...
121
-
122
- ---
123
-
124
- ## 8. Recurrence Relations
125
-
126
- **Fibonacci sequence:**
127
- $$F_0 = 0, F_1 = 1, F_n = F_{n-1} + F_{n-2}$$
128
- - Generating function: F(x) = ΣF_n x^n = x/(1−x−x²)
129
- - Binet's formula: F_n = (φ^n − ψ^n)/√5, where φ = (1+√5)/2 ≈ 1.618 (the golden ratio)
130
-
131
- **Tower of Hanoi:**
132
- $$T_1 = 1, T_n = 2T_{n-1} + 1$$
133
- - Solution: T_n = 2^n − 1. A tower of 64 disks requires 2^{64} − 1 ≈ 1.8×10^{19} moves
134
-
135
- **Solving recurrences via generating functions:**
136
- 1. Multiply the recurrence by x^n, sum over n → obtain an equation for A(x)
137
- 2. Use initial conditions to solve for A(x) (algebraic or differential equation)
138
- 3. Extract a_n: partial fractions, Taylor expansion, or matching against known power series
139
-
140
- **Catalan GF derivation:** C(x) = 1 + x·C(x)² → solve 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): greedily select edges in ascending order of weight, skipping those that form cycles, O(E log E)
148
- - Prim (1957): expand from a single vertex, each time selecting the minimum-weight connecting edge, O(E log V) (with a priority queue)
149
-
150
- **Max-flow min-cut:**
151
- - Ford-Fulkerson (1956): augmenting path method, incrementally increasing flow until no augmenting path exists
152
- - Max-flow min-cut theorem: the maximum flow value = the minimum cut capacity (the combinatorial manifestation of LP duality)
153
- - Edmonds-Karp (1972): BFS selects the shortest augmenting path, guaranteeing O(VE²)
154
-
155
- **Matching theory:**
156
- - Hungarian algorithm (Kuhn 1955): O(V³) maximum weighted bipartite matching
157
- - Edmonds' blossom algorithm (1965): maximum matching in general graphs, O(V³)
158
-
159
- ---
160
-
161
- ## 10. The Twelvefold Way
162
-
163
- Richard P. Stanley, in **Enumerative Combinatorics Vol. 1**, unified and classified the 12 fundamental counting problems of placing n balls into k boxes (2×2×3: balls labeled/unlabeled × boxes labeled/unlabeled × any/at most one/at least one):
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) (restricted partitions) |
171
- | distinct | distinct | at most one ≤1 | P(k,n) = k!/(k−n)! |
172
- | identical | distinct | at most one ≤1 | C(k,n) |
173
- | distinct | identical | at most one ≤1 | 1 if n≤k, 0 otherwise |
174
- | identical | identical | at most one ≤1 | 1 if n≤k, 0 otherwise |
175
- | distinct | distinct | at least one ≥1 | k!·S₂(n,k) |
176
- | identical | distinct | at least one ≥1 | C(n−1, k−1) |
177
- | distinct | identical | at least one ≥1 | S₂(n,k) − S₂(n,k−1) |
178
- | identical | identical | at least one ≥1 | p_k(n) − p_{k−1}(n) |
179
-
180
- **Key insight:** The 2×2×3=12 fundamental counting problems cover the core scenarios in combinatorics. Use EGF for labeled objects, OGF for unlabeled objects. **Stirling numbers:** S₁(n,k) = the number of permutations of n elements with k cycles; S₂(n,k) = the number of ways to partition n elements into k non-empty subsets.
181
-
182
- ---
183
-
184
- *This file provides mathematical references and historical context for the discrete-combinatorial skill, covering core results from Euler to modern combinatorics.*
@@ -1,185 +0,0 @@
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.*
@@ -1,117 +0,0 @@
1
- ---
2
- name: game-theory
3
- description: |
4
- Trigger when optimal strategy depends on others' choices, needing Nash equilibrium computation, zero-sum/non-zero-sum analysis, mechanism design; or designing strategies for multi-agent systems, adversarial training, routing games.
5
- ---
6
-
7
- # 🎯 Game Theory
8
-
9
- > "Your optimal choice depends on others' choices — thinking must be interactive, not just deep."
10
- >
11
- > — Game Theory, Decision Theory, Mechanism Design
12
-
13
- ## Core Principle
14
-
15
- **Strategic interaction — your best action depends on what others do, and theirs depend on what you do. Nash equilibrium: strategy profile where no player benefits from unilateral deviation.**
16
-
17
- Key concepts: **Payoff Matrix**, **Dominant Strategy**, **Mixed Strategy**, **Pareto Optimality**. Classification dimensions: cooperative vs. non-cooperative, zero-sum vs. general-sum, simultaneous vs. sequential.
18
-
19
- > **Mathematical Formalization**
20
- >
21
- > Formal definition: $n$ players, each with strategy set $S_i$ and payoff function $u_i: S_1 \times \cdots \times S_n \to \mathbb{R}$.
22
- >
23
- > Nash equilibrium: strategy profile $s^* = (s_1^*, \ldots, s_n^*)$ satisfying $u_i(s^*) \geq u_i(s_i, s^*_{-i})$ for all $s_i \in S_i$ and all $i$, where $s^*_{-i}$ denotes the strategies of all players except $i$. Mixed-strategy Nash equilibrium: probability distribution $\sigma^*$ such that $u_i(\sigma^*) \geq u_i(s_i, \sigma^*_{-i})$.
24
- >
25
- > Dominant strategy: strict $u_i(s_i^*, s_{-i}) > u_i(s_i, s_{-i})$; weak dominance $\geq$ with at least one strict inequality.
26
- >
27
- > Zero-sum minimax: $\max_x \min_y f(x,y) = \min_y \max_x f(x,y)$.
28
-
29
- ## GPU-Friendliness (Cross-Cutting Check)
30
-
31
- Game-solving maps to GPU with widely varying capability; pass through the eight-dimensional gate in `../../references/gpu-friendly-math.md`:
32
-
33
- - **Matrix games / two-player zero-sum (minimax)**: Equivalent to linear programming (LP); payoff matrix operations are GEMM-compatible and batch-parallelizable — **friendly**.
34
- - **Mixed-strategy equilibrium computation**: Linear systems / indifference equations on the support; small-scale problems are batch-solvable; watch for sparsity and condition number at scale.
35
- - **Exact large-scale multi-agent equilibrium**: $n$-player Nash equilibrium is PPAD-complete; general case is **intractable** → **anti-pattern**; switch to approximate / learning-based methods (fictitious play, self-play, multi-agent RL, NFSP).
36
- - **Evolutionary / repeated game simulation**: Population and strategy batch updates are parallelizable; watch for inter-agent communication and synchronization overhead.
37
-
38
- Eight-dimensional minimum assessment (formal terms): **Tensorization** — whether players / strategies / rounds admit batched unfolding; **GEMM-mappability** — whether payoff matrices, minimax, LP / linear systems fall into matrix operations; **Complexity** — flag PPAD / combinatorial explosion risks for Nash / mechanism solving; **Memory and KV-Cache** — whether the strategy-state Cartesian product is compressible; **Low-precision stability** — whether equilibrium solving, LP, soft best-response have controlled condition numbers; **Parallelism and communication** — synchronization cost of multi-agent rollouts; **Sparse structure** — whether the interaction graph is structured; **Operator fusion** — whether payoff, mask, and best-response updates can be fused.
39
-
40
- > Use in conjunction with `../../references/books/optimization-ml.md` (duality / minimax, game learning algorithms) and `../../references/books/matrix-analysis.md` (matrix games, linear systems).
41
-
42
- ## When NOT to Use
43
-
44
- - **Single-agent decision problems with no interaction** — optimization thinking is more appropriate; no need to model others' strategic responses.
45
- - **Purely cooperative problems with no conflict of interest** — players' objectives are fully aligned; strategic analysis is unnecessary.
46
- - **Deterministic problems with no strategic uncertainty** — outcomes are uniquely determined by one's own actions; no reaction from others is involved.
47
- - **Outcomes determined purely by chance with no strategic choice** — no strategy sets to analyze; game theory does not apply.
48
-
49
- ## When to Use
50
-
51
- - Multiple decision-makers interact; each player's strategy affects others' payoffs; the optimal strategy depends on predicting others' responses.
52
- - Need to design incentive mechanisms so that self-interested behavior leads to socially optimal outcomes; predict equilibrium states under given rules.
53
- - Analyze pricing, entry, and exit in competitive markets; benefit allocation and threat points in negotiation / bargaining.
54
- - **Design strategies and equilibrium objectives for multi-agent systems, adversarial training (GAN / robust learning), and routing games.**
55
-
56
- ## Method
57
-
58
- ### Step 1: Identify Players and Strategies
59
- Define the fundamental elements of the game: players $N=\{1,\ldots,n\}$; strategy sets $S_i$; payoff functions $u_i: S_1\times\cdots\times S_n\to\mathbb{R}$; information structure (symmetric or not? incomplete information? sequential actions? communication possible?). The core task is identifying the "interaction structure" — whose choices affect whose outcomes. Missing a key player is the most common error.
60
-
61
- ### Step 2: Analyze the Game Type
62
- First classify: zero-sum / general-sum, simultaneous / sequential, cooperative / non-cooperative, complete / incomplete information. The type determines the method: zero-sum uses minimax / LP; sequential games use backward induction and subgame-perfect equilibrium; cooperative games use the Shapley value to allocate by marginal contribution:
63
- $$\phi_i(v)=\sum_{S\subseteq N\setminus\{i\}}\frac{|S|!(n-|S|-1)!}{n!}[v(S\cup\{i\})-v(S)]$$
64
- Misclassifying the type leads directly to applying the wrong equilibrium concept and solution method.
65
-
66
- ### Step 3: Construct the Payoff Matrix / Function
67
- For two-player games, use a payoff matrix with cells $(u_1,u_2)$; for $n$-player games, use $u_i(s_1,\ldots,s_n)$. Verify completeness: are any players or strategies missing? Do payoffs accurately reflect preferences? Are there externalities? Payoffs are the foundation of all analysis; inaccurate assessment biases everything downstream.
68
-
69
- ### Step 4: Search for Dominant Strategies
70
- Strict dominance: $u_i(s_i^*,s_{-i}) > u_i(s_i,s_{-i})$ for all $s_i\neq s_i^*$ and all $s_{-i}$; weak dominance: $\geq$ with at least one strict inequality. **Iterated elimination of dominated strategies** successively removes inferior strategies to shrink the strategy space. A dominant-strategy equilibrium is the strongest possible conclusion — no player has any incentive to deviate. If none exists, proceed to equilibrium analysis.
71
-
72
- ### Step 5: Compute Equilibria
73
- Select the method based on the game type from Step 2. Pure-strategy Nash: for each $s_{-i}$, find the best response $BR_i(s_{-i})$; intersections are equilibria. Mixed strategies: find probability distributions that make others indifferent, $u_j(s_j,\sigma^*_{-j})=u_j(s_j',\sigma^*_{-j})$ for all $s_j,s_j'\in S_j$. Zero-sum matrix games use minimax $\max_x\min_y f=\min_y\max_x f$; sequential games use backward induction; cooperative games output allocation schemes rather than standard Nash. For multiple equilibria, perform Pareto ranking and label optimal vs. inferior equilibria.
74
-
75
- ### Step 6: Check Equilibrium Stability
76
- Trembling-hand perfection (stable under small perturbations, excluding equilibria that rely on "opponents never make mistakes"); evolutionarily stable strategy ESS (resists invasion in repeated interactions); off-equilibrium-path incentives (in sequential games, whether there is motivation to honor commitments). Ask: is the equilibrium unique or multiple? Is it robust to small perturbations? Only stable equilibria constitute credible predictions.
77
-
78
- ### Step 7: Mechanism Design and Improvement
79
- If no good equilibrium exists, redesign the game: modify the payoff structure (incentives and penalties), add enforceable rules, introduce communication and reputation mechanisms, Vickrey auctions (truthful valuation reporting is a dominant strategy). Mechanism design formalization:
80
- $$\max\ \text{social welfare}\quad\text{s.t.}\quad\text{incentive compatibility + individual rationality}$$
81
- The revelation principle: any Bayesian game equilibrium can be implemented by a direct mechanism — truthful type reporting is an equilibrium. Mechanism design is the most practical branch — rather than lamenting non-cooperation, change the rules so that cooperation becomes the self-interested choice.
82
-
83
- ## Common Errors
84
-
85
- | Error | Critique | Correct Approach |
86
- |---|---|---|
87
- | Assuming others think the same way you do | Others have different payoff functions / rationality levels; $u_i\neq u_j$ | Explicitly specify each player's payoff function and beliefs |
88
- | Ignoring mixed strategies | Pure-strategy equilibria may not exist; mixed equilibria always exist (Nash, 1950) | Check whether mixed-strategy analysis is needed |
89
- | Confusing Nash equilibrium with Pareto optimality | Nash equilibrium can be Pareto-dominated (Prisoner's Dilemma); the two are independent | Separately annotate equilibrium properties and efficiency properties |
90
- | Ignoring information asymmetry | Incomplete-information equilibria differ fundamentally from complete-information ones | Distinguish Bayesian games from complete-information games |
91
- | Oversimplifying payoff structure | Omitting key payoff dimensions distorts the equilibrium | Systematically check complete payoffs for all players |
92
- | Ignoring repeated interaction dynamics | One-shot equilibria may change in repeated games (folk theorem) | Analyze subgame-perfect equilibria |
93
- | Intractable exact large-scale equilibrium | $n$-player Nash equilibrium is PPAD-complete; exact solutions are infeasible | Pass through the GPU eight-dimensional gate; switch to approximate / learning methods (self-play, MARL) |
94
-
95
- ## Operating Procedure
96
-
97
- When this skill is triggered, the output must include:
98
-
99
- 1. **[Players]**: All decision-makers and their types (rational / boundedly rational / unknown).
100
- 2. **[Strategy Sets]**: Available strategies for each player; label finite / infinite.
101
- 3. **[Payoff Matrix]**: Payoff values $(u_1,u_2,\ldots)$ for core strategy profiles, or payoff function form.
102
- 4. **[Game Type]**: Zero-sum / non-zero-sum / sequential / cooperative, with corresponding analytical method.
103
- 5. **[Equilibria]**: All applicable equilibria (pure strategy, mixed strategy, subgame-perfect, cooperative allocation, etc.); label multiple equilibria.
104
- 6. **[Stability]**: Trembling-hand perfection, evolutionary stability, off-equilibrium-path incentives.
105
- 7. **[Mechanism Recommendations]**: If equilibria are undesirable, propose mechanism design suggestions (modify payoffs, add rules, introduce reputation, etc.).
106
- 8. **[GPU Feasibility]**: Matrix games / minimax → LP is GEMM-compatible; large-scale multi-agent equilibria may be intractable → approximate / learning methods; pass through the eight-dimensional gate.
107
-
108
- **Output must not consist of analysis alone without conclusions.**
109
-
110
- ## Relations to Other Skills
111
-
112
- - **Optimization Thinking**: Nash equilibrium is mutual optimization — each player optimizes their own payoff subject to others' strategies; the equilibrium is the common solution to all optimization problems.
113
- - **Probability and Statistics**: Mixed strategies select actions via probability distributions; Bayesian games handle type uncertainty probabilistically; equilibria depend on expected payoffs.
114
- - **Information Theory Thinking**: Information asymmetry and signaling — in Spence signaling games, the information structure directly affects equilibrium existence and properties.
115
- - **Causal Inference Thinking**: Strategic choices causally affect others' payoffs; causal chains in strategic interaction are bidirectional.
116
- - **Algorithmic Thinking**: Nash equilibrium computation complexity (PPAD-complete), Lemke-Howson algorithm, evolutionary game simulation.
117
- - **Modern Mathematics Activation**: `../../references/books/optimization-ml.md` (duality / minimax, game learning algorithms), `../../references/books/matrix-analysis.md` (matrix games, linear algebraic structure of payoff matrices).
@@ -1,123 +0,0 @@
1
- ---
2
- name: game-theory
3
- description: |
4
- 触发:当策略取决于他人选择、需计算纳什均衡、分析零和/非零和博弈、做机制设计;或为多智能体系统、对抗训练、路由博弈设计策略时调用。
5
- English: Trigger when optimal strategy depends on others' choices, needing Nash equilibrium computation, zero-sum/non-zero-sum analysis, mechanism design; or designing strategies for multi-agent systems, adversarial training, routing games.
6
- ---
7
-
8
- > **语言路由**:若用户消息为英文,请读取并遵循同目录下的 `SKILL.en.md`,按其操作规程以英文输出;中文消息则继续使用本文件。
9
-
10
- # 🎯 博弈论思想 / Game Theory
11
-
12
- > "你的最优选择取决于他人的选择——思考不仅要深入,还要互动。"
13
- > "Your optimal choice depends on others' choices — thinking must be interactive, not just deep."
14
- >
15
- > —— 博弈论、决策论、机制设计 / Game Theory, Decision Theory, Mechanism Design
16
-
17
- ## 核心原则 / Core Principle
18
-
19
- **战略互动——你的最优行动取决于他人做什么,而他人的最优行动取决于你做什么。纳什均衡:无人能从单方面偏离中获益的策略组合。**
20
-
21
- **Strategic interaction — your best action depends on what others do, and theirs depend on what you do. Nash equilibrium: strategy profile where no player benefits from unilateral deviation.**
22
-
23
- 关键概念:**支付矩阵(Payoff Matrix)**、**占优策略(Dominant Strategy)**、**混合策略(Mixed Strategy)**、**帕累托最优性(Pareto Optimality)**。分类维度:合作 vs 非合作、零和 vs 一般和、同时 vs 序列。
24
-
25
- > **数学形式化 / Mathematical Formalization**
26
- >
27
- > 形式化定义:n 个参与者,每人有策略集 $S_i$ 和支付函数 $u_i: S_1 \times \cdots \times S_n \to \mathbb{R}$。
28
- >
29
- > 纳什均衡:策略组合 $s^* = (s_1^*, \ldots, s_n^*)$ 满足 $u_i(s^*) \geq u_i(s_i, s^*_{-i})$ 对所有 $s_i \in S_i$、所有 $i$ 成立,其中 $s^*_{-i}$ 为除 $i$ 外所有人的策略。混合策略纳什均衡:概率分布 $\sigma^*$ 使 $u_i(\sigma^*) \geq u_i(s_i, \sigma^*_{-i})$。
30
- >
31
- > 占优策略:严格 $u_i(s_i^*, s_{-i}) > u_i(s_i, s_{-i})$;弱占优 $\geq$ 且至少一处严格。
32
- >
33
- > 零和 minimax:$\max_x \min_y f(x,y) = \min_y \max_x f(x,y)$。
34
-
35
- ## GPU 友好性 / GPU-Friendliness(横切检查)
36
-
37
- 博弈求解映射 GPU 的能力差异极大,过 `../../references/gpu-friendly-math.md` 八维门:
38
-
39
- - **矩阵博弈 / 双人零和(minimax)**:等价于线性规划(LP),支付矩阵运算可 GEMM 化、可批量并行——**友好**。
40
- - **混合策略均衡求解**:支撑集上的线性方程组/无差异方程,小规模可批量解;规模大时注意稀疏性与条件数。
41
- - **大规模多智能体均衡精确求解**:n 人纳什均衡 PPAD-complete,一般情形**不可算**→ **反模式**,改用近似/学习方法(fictitious play、虚拟自博、多智能体 RL、NFSP)。
42
- - **演化/重复博弈模拟**:群体与策略批量更新可并行;注意 agent 间通信与同步开销。
43
-
44
- 八维最低判定(正式术语):**张量化**看玩家/策略/回合是否能批量展开;**GEMM 可映射**看支付矩阵、minimax、LP/线性方程是否落矩阵运算;**复杂度**标注 Nash/机制求解的 PPAD/组合爆炸风险;**显存与 KV-Cache**看策略-状态笛卡尔积是否可压缩;**低精度稳定**看均衡求解、LP、soft best-response 是否条件数可控;**并行与通信**看多智能体 rollout 的同步成本;**稀疏结构**看交互图是否结构化;**算子融合**看收益、mask、best-response 更新能否融合。
45
-
46
- > 配合 `../../references/books/optimization-ml.md`(对偶/minimax、博弈学习算法)与 `../../references/books/matrix-analysis.md`(矩阵博弈、线性方程组)。
47
-
48
- ## 不适用场景 / When NOT to Use
49
-
50
- - **单人决策问题,与他人无互动**——优化思想更适用,无需考虑他人策略响应。
51
- - **纯合作问题,无利益冲突**——参与者目标完全一致,无需战略分析。
52
- - **确定性问题,无战略不确定性**——结果由自身行动唯一决定,不涉及他人反应。
53
- - **纯粹运气决定的结果,各方无策略选择**——无策略集可分析,博弈论不适用。
54
-
55
- ## 何时使用 / When to Use
56
-
57
- - 多个决策者相互影响,各自策略影响他人收益;最佳策略取决于他人响应,需预判他人行动。
58
- - 需设计激励机制,使自利行为导向社会最优结果;预测给定规则下的均衡稳定状态。
59
- - 分析竞争市场中的定价、进入、退出;谈判/讨价还价中的利益分配与威胁点。
60
- - **为多智能体系统、对抗训练(GAN/鲁棒学习)、路由博弈设计策略与均衡目标**。
61
-
62
- ## 方法流程 / Method
63
-
64
- ### 第一步:识别参与者与策略
65
- 定义博弈基本要素:参与者 $N=\{1,\ldots,n\}$;策略集 $S_i$;支付函数 $u_i: S_1\times\cdots\times S_n\to\mathbb{R}$;信息结构(是否对称?是否不完全信息?行动是否序列?能否通信?)。核心是识别"互动结构"——谁的选择影响谁的结果,遗漏关键参与者是最常见错误。
66
-
67
- ### 第二步:分析博弈类型
68
- 先判定零和/一般和、同时/序列、合作/非合作、完全信息/不完全信息。类型决定方法:零和用 minimax/LP;序列博弈用逆向归纳与子博弈完美均衡;合作博弈用 Shapley 值按边际贡献分配:
69
- $$\phi_i(v)=\sum_{S\subseteq N\setminus\{i\}}\frac{|S|!(n-|S|-1)!}{n!}[v(S\cup\{i\})-v(S)]$$
70
- 误判类型会直接导致均衡概念和求解方法错用。
71
-
72
- ### 第三步:构建支付矩阵/函数
73
- 2 人博弈用支付矩阵,单元格 $(u_1,u_2)$;n 人博弈用 $u_i(s_1,\ldots,s_n)$。验证完备性:是否遗漏参与者或策略?支付是否准确反映偏好?是否存在外部性?支付是分析根基,评估不准则后续全偏。
74
-
75
- ### 第四步:寻找占优策略
76
- 严格占优 $u_i(s_i^*,s_{-i}) > u_i(s_i,s_{-i})$ 对所有 $s_i\neq s_i^*$、所有 $s_{-i}$;弱占优 $\geq$ 且至少一处严格;**迭代消去劣策略**依次删去劣策略缩小空间。存在占优策略均衡是最强结论——无人有任何偏离动机;否则进入均衡分析。
77
-
78
- ### 第五步:计算均衡
79
- 按第二步的博弈类型选方法。纯策略纳什:对每个 $s_{-i}$ 找最优响应 $BR_i(s_{-i})$,交叉点即均衡。混合策略:求使他人无差异的概率分布 $u_j(s_j,\sigma^*_{-j})=u_j(s_j',\sigma^*_{-j})$ 对所有 $s_j,s_j'\in S_j$。零和矩阵博弈可走 minimax $\max_x\min_y f=\min_y\max_x f$;序列博弈用逆向归纳;合作博弈输出分配方案而非普通纳什。多重均衡做帕累托排序,标注最优与劣均衡。
80
-
81
- ### 第六步:检查均衡稳定性
82
- 颤抖手完美(微小失误下仍稳定,排除依赖"对手绝不犯错"的均衡);演化稳定策略 ESS(重复互动中抵御入侵);偏离均衡路径激励(序列博弈中是否有动机遵守承诺)。追问:均衡唯一还是多重?对微小扰动是否鲁棒?稳定均衡才是可信预测。
83
-
84
- ### 第七步:设计机制与改进
85
- 若不存在好的均衡,重新设计博弈:改变支付结构(奖惩)、增加可执行规则、引入通信与声誉、Vickrey 拍卖(报真实估值为占优策略)。机制设计形式化:
86
- $$\max\ \text{social welfare}\quad\text{s.t.}\quad\text{incentive compatibility + individual rationality}$$
87
- 显示原理:任何贝叶斯博弈均衡都可由直接机制实现——如实报告类型即均衡。机制设计是最实用分支——与其抱怨人不合作,不如改变规则让合作成为自利选择。
88
-
89
- ## 常见错误 / Common Errors
90
-
91
- | 错误 / Error | 批评 / Critique | 正确做法 / Correct Approach |
92
- |---|---|---|
93
- | 假设他人像自己一样思考 | 他人支付函数/理性水平不同,$u_i\neq u_j$ | 明确各参与者支付函数与信念 |
94
- | 忽略混合策略 | 纯策略均衡可能不存在,混合均衡总存在(Nash, 1950) | 检查是否需混合策略分析 |
95
- | 混淆纳什均衡与帕累托最优 | 纳什均衡可帕累托劣(囚徒困境),两者独立 | 分别标注均衡性与效率性 |
96
- | 忽略信息不对称 | 不完全信息均衡与完全信息截然不同 | 区分贝叶斯博弈与完全信息博弈 |
97
- | 过度简化支付结构 | 遗漏关键支付维度使均衡失真 | 系统检查所有参与者完整支付 |
98
- | 忽略重复互动动态 | 单次均衡在重复博弈中可能改变(folk theorem) | 分析子博弈完美均衡 |
99
- | 大规模均衡精确求解不可算 | n 人纳什均衡 PPAD-complete,精确解不可行 | 过 GPU 八维门,改用近似/学习(虚拟自博、MARL) |
100
-
101
- ## 操作规程 / Operating Procedure
102
-
103
- 当本 skill 被触发时,输出必须包含:
104
-
105
- 1. **[参与者]**:所有决策者及其类型(理性/有限理性/未知)。
106
- 2. **[策略集]**:每个参与者的可选策略,标注有限/无限。
107
- 3. **[支付矩阵]**:核心策略组合的支付值 $(u_1,u_2,\ldots)$ 或支付函数形式。
108
- 4. **[博弈类型]**:零和/非零和/序列/合作,对应分析方法。
109
- 5. **[均衡]**:所有适用均衡(纯策略、混合策略、子博弈完美、合作分配等),标注多重均衡。
110
- 6. **[稳定性]**:颤抖手完美性、演化稳定性、偏离均衡路径激励。
111
- 7. **[机制建议]**:若均衡不理想,提出机制设计建议(改变支付、增加规则、引入声誉等)。
112
- 8. **[GPU 可行性]**:矩阵博弈/minimax→LP 可 GEMM;大规模多智能体均衡是否不可算→近似/学习方法,过八维门。
113
-
114
- **输出不得只给分析而无结论。**
115
-
116
- ## 与其他 skill 的关系 / Relations to Other Skills
117
-
118
- - **优化思想**:纳什均衡是互相优化——每人在他人策略约束下优化自己支付,均衡是所有优化问题的共同解。
119
- - **概率与统计**:混合策略以概率分布选行动,贝叶斯博弈用概率处理类型不确定性,均衡依赖期望支付。
120
- - **信息论思想**:信息不对称与信号传递——Spence 信号博弈中信息结构直接影响均衡存在与性质。
121
- - **因果推断思想**:策略选择因果影响他人收益,战略互动中的因果链是双向的。
122
- - **算法思想**:纳什均衡计算复杂度(PPAD-complete)、Lemke-Howson 算法、演化博弈模拟。
123
- - **现代数学激活**:`../../references/books/optimization-ml.md`(对偶/minimax、博弈学习算法)、`../../references/books/matrix-analysis.md`(矩阵博弈、支付矩阵的线性代数结构)。