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,154 +0,0 @@
1
- # Mathematical Sources and Classic Texts
2
-
3
- ## Euclid's *Elements* (~300 BC)
4
-
5
- **The Axiomatic System (Five Postulates)**:
6
-
7
- > 1. A straight line segment can be drawn joining any two points.
8
- > 2. Any straight line segment can be extended indefinitely in a straight line.
9
- > 3. Given any straight line segment, a circle can be drawn having the segment as radius and one endpoint as center.
10
- > 4. All right angles are congruent.
11
- > 5. (Parallel Postulate) If two lines are drawn which intersect a third in such a way that the sum of the inner angles on one side is less than two right angles, then the two lines inevitably must intersect on that side if extended far enough.
12
-
13
- 1. A straight line segment can be drawn joining any two points.
14
- 2. Any straight line segment can be extended indefinitely in a straight line.
15
- 3. Given any straight line segment, a circle can be drawn having the segment as radius and one endpoint as center.
16
- 4. All right angles are congruent.
17
- 5. (Parallel Postulate) If two lines are drawn which intersect a third in such a way that the sum of the inner angles on one side is less than two right angles, then the two lines inevitably must intersect on that side if extended far enough.
18
-
19
- **Significance**: The first axiomatic system in human history, demonstrating that 465 propositions can be rigorously derived from 5 postulates and 5 common notions through strict logical deduction.
20
-
21
- ## The Parallel Postulate Controversy (~300 BC – 1820s)
22
-
23
- Euclid's fifth postulate was disquieting from the very beginning: its formulation is far more complex than the first four, resembling a theorem rather than an axiom. For two millennia, countless mathematicians attempted to derive it from the first four postulates, all to no avail.
24
-
25
- Key figures and developments:
26
- - **Saccheri** (1733): Attempted to derive a contradiction by assuming the parallel postulate false; though unsuccessful, he was the first to systematically explore the properties of non-Euclidean geometry.
27
- - **Lambert** (1766): Pursued a similar approach, investigating more deeply the geometric consequences under the hypothesis of the obtuse angle and the hypothesis of the acute angle.
28
- - **Gauss** (~1820): Privately recognized the logical consistency of non-Euclidean geometry but refrained from publishing for fear of controversy.
29
- - **Bolyai** (1832) & **Lobachevsky** (1829): Independently published hyperbolic geometry — a geometry in which the parallel postulate is false yet the system is entirely self-consistent.
30
-
31
- > "I have created a new universe from nothing." — Bolyai
32
-
33
- **Significance**: The parallel postulate is independent of the other four — it can neither be proved nor refuted from them. This is the earliest instance of axiom independence, revealing the profound fact that "axioms cannot be forced to be true" a full century before Gödel's incompleteness theorems. The birth of non-Euclidean geometry directly gave rise to Riemannian geometry, which later became the mathematical foundation of general relativity.
34
-
35
- ## Hilbert's *Foundations of Geometry* (1899)
36
-
37
- > "We must be able to replace 'points, lines, planes' with 'tables, chairs, beer mugs' — as long as they satisfy the relations between the axioms."
38
-
39
- Hilbert proposed more rigorous requirements for axiomatic systems:
40
- - **Consistency**: The axioms must not contradict one another
41
- - **Independence**: No axiom can be derived from the others
42
- - **Completeness**: All geometric propositions must be decidable within the system
43
-
44
- ## Peano Axioms for Arithmetic (1889)
45
-
46
- Peano formulated five axioms for the natural numbers, constituting the most classical form of the axiomatization of arithmetic:
47
-
48
- > P1. 0 is a natural number.
49
- > P2. Every natural number n has a unique successor S(n).
50
- > P3. 0 is not the successor of any natural number.
51
- > P4. Different natural numbers have different successors.
52
- > P5. (Induction) If P(0) and P(n) → P(S(n)), then P holds for all natural numbers.
53
-
54
- **Significance**: First-order Peano Arithmetic (PA) is the standard object of study in Gödel's incompleteness theorems — PA is consistent but incomplete. Second-order Peano Arithmetic is categorical (see below), uniquely characterizing the structure of the natural numbers.
55
-
56
- ## Zermelo-Fraenkel Set Theory with Choice (ZFC, 1908–1922)
57
-
58
- ZFC is the standard axiomatic foundation of contemporary mathematics, consisting of 9 axioms:
59
-
60
- > Z1. Extensionality: Sets with the same elements are equal.
61
- > Z2. Empty Set: ∅ exists.
62
- > Z3. Pairing: {a, b} exists.
63
- > Z4. Union: The union of any family of sets exists.
64
- > Z5. Power Set: P(A) exists.
65
- > Z6. Infinity: An infinite set exists.
66
- > Z7. Replacement (Fraenkel's addition): Images of functions on sets are sets.
67
- > Z8. Foundation: Every nonempty set has a minimal element; no set contains itself.
68
- > Z9. Axiom of Choice (AC): For any family of nonempty sets, a choice function exists.
69
-
70
- **The Axiom of Choice Controversy**: AC seems intuitive yet leads to counterintuitive conclusions — most famously the **Banach-Tarski Paradox** (1924): a ball can be cut into five pieces which, after rotation and reassembly, form two balls each identical in size to the original. Zermelo used AC to prove that every set can be well-ordered (1904), a result that is itself deeply puzzling.
71
-
72
- > "The Axiom of Choice is obviously true, the Well-Ordering Theorem obviously false, and who can tell the difference?" — Jerry Bona
73
-
74
- **Significance**: ZFC's 9 axioms suffice to derive virtually all of modern mathematics. Yet ZFC itself is subject to Gödel's incompleteness theorems — ZFC is consistent but cannot prove its own consistency from within.
75
-
76
- ## Continuum Hypothesis (Cantor 1878, Gödel 1940, Cohen 1963)
77
-
78
- Cantor proposed in 1878 that the cardinality of the real numbers (the continuum) is exactly ℵ₁ — that is, there exists no infinite cardinal strictly between the cardinality of the natural numbers ℵ₀ and the cardinality of the reals.
79
-
80
- > CH: 2^ℵ₀ = ℵ₁. There is no cardinal between ℵ₀ and 2^ℵ₀.
81
-
82
- - **Gödel** (1940): Proved that CH is consistent with ZFC — CH cannot be refuted within ZFC. He constructed the constructible universe L, in which CH holds.
83
- - **Cohen** (1963): Using the forcing method, proved that ¬CH is also consistent with ZFC — CH cannot be proved within ZFC. This marked the birth of forcing.
84
-
85
- **Significance**: CH is the most concrete instance of Gödel's incompleteness theorems — a natural proposition about the size of infinity that is neither provable nor refutable within the standard axiomatic system of mathematics. This profoundly reveals the limitations of axiomatic systems: even the most fundamental mathematical questions may exceed the power of the axioms.
86
-
87
- ## Gödel's Incompleteness Theorems (1931)
88
-
89
- > **First Incompleteness Theorem**: In any consistent axiomatic system that includes arithmetic, there exist propositions that can neither be proved nor refuted.
90
- > **Second Incompleteness Theorem**: A consistent axiomatic system cannot prove its own consistency from within.
91
-
92
- **Implications for the axiomatic program**: A perfect axiomatization is impossible. But this does not mean axiomatization is without value — it helps us understand the boundaries of a theory.
93
-
94
- ## Whitehead & Russell, *Principia Mathematica* (1910–1913)
95
-
96
- An attempt to reduce all of mathematics to logic and set-theoretic axioms — the pinnacle of the axiomatization program. Although Gödel later proved the impossibility of such a complete reduction, *Principia* demonstrated the enormous power of the axiomatic method.
97
-
98
- ## Categoricity (Veblen 1904)
99
-
100
- Veblen introduced the concept of categoricity in 1904: an axiomatic system is called *categorical* if all of its models are isomorphic — that is, the axioms uniquely characterize the object of study.
101
-
102
- > Categoricity = all models of the axiom system are isomorphic.
103
-
104
- **Key examples**:
105
- - **Second-order Peano Arithmetic** is categorical — all models satisfying second-order PA are the standard natural number structure ℕ, unique up to isomorphism.
106
- - **First-order Peano Arithmetic** is not categorical — there exist non-standard models containing "infinitely large" natural numbers (Skolem 1934).
107
- - **First-order theory of real closed fields** is categorical (Tarski) — it uniquely characterizes ℝ.
108
-
109
- **Significance**: Categoricity is the ideal property of an axiomatic system — the axioms truly "pin down" a unique mathematical object. However, the Löwenheim-Skolem theorem shows that any first-order axiomatic system with an infinite model also has infinite models of arbitrary cardinality, and therefore a first-order system can never be categorical (unless it has only finite models). Second-order systems can be categorical, but second-order logic lacks a complete proof system. This is the fundamental tension between first-order and second-order approaches in the axiomatic method.
110
-
111
- ## Tarski's Axiomatization of Geometry (1926–1959)
112
-
113
- Tarski axiomatized Euclidean plane geometry in first-order logic, using only points together with two primitive relations: betweenness and equidistance.
114
-
115
- > Tarski's geometry = first-order logic + points + betweenness + equidistance, ~10 axioms (7 in the short version).
116
-
117
- **Decidability and Completeness**: Tarski proved in 1959 that this axiomatic system is **complete and decidable** — every geometric proposition can be decided within the system, and an algorithm exists to perform this decision automatically.
118
-
119
- **Contrast with Gödel**: This may seem to contradict Gödel's incompleteness theorems. The crucial point is that Tarski's geometry does not contain arithmetic — it cannot encode the natural numbers, so the condition "includes arithmetic" required by Gödel's theorem is not satisfied. This profoundly illustrates that the completeness or incompleteness of an axiomatic system depends on whether it can express sufficient arithmetic.
120
-
121
- **Significance**: Tarski's result is a marvel of axiomatic methodology — there exist first-order axiomatic systems that are both complete and decidable. The price is that one must sacrifice the ability to express arithmetic.
122
-
123
- ## Bourbaki (1935–)
124
-
125
- Bourbaki is the collective pseudonym of a group of French mathematicians dedicated to systematically reconstructing all of mathematics using the axiomatic method. Their monumental work, *Éléments de mathématique*, is grounded in set theory and builds up, layer by layer, the branches of algebra, analysis, topology, differential geometry, and more.
126
-
127
- > "Mathematics is not about numbers, but about structures." — The Bourbaki spirit
128
-
129
- **Three Mother Structures**:
130
- - **Algebraic Structures**: Groups, rings, fields — characterizing the laws of operation and composition.
131
- - **Order Structures**: Partial orders, total orders, lattices — characterizing the laws of comparison and ordering.
132
- - **Topological Structures**: Topological spaces, metric spaces — characterizing the laws of continuity and proximity.
133
-
134
- Bourbaki held that all mathematical structures can be generated through the combination of these three mother structures. This program profoundly influenced the classification and pedagogy of modern mathematics.
135
-
136
- **Significance**: Bourbaki elevated axiomatization from "laying foundations for a single discipline" to "building a unified architecture for all of mathematics." Although category theory later provided a more flexible perspective, Bourbaki's structuralism remains one of the core legacies of mathematical axiomatic thought.
137
-
138
- ## Constructive Mathematics (Brouwer 1908, Heyting 1930, Bishop 1967)
139
-
140
- Constructive mathematics rejects the Law of Excluded Middle and the Axiom of Choice in classical logic, requiring that every existence proof must provide a concrete construction method — that is, "there exists x" must be accompanied by "how to find x."
141
-
142
- > "To exist is to construct." — Core credo of constructive mathematics
143
-
144
- **Key figures and systems**:
145
- - **Brouwer** (1908–): Founder of intuitionism, held that mathematics is a free creation of the mind, and opposed treating the Law of Excluded Middle as universally valid.
146
- - **Heyting** (1930): Established a formal axiomatic system for intuitionistic logic — intuitionistic logic (Heyting arithmetic).
147
- - **Bishop** (1967): In *Foundations of Constructive Analysis*, demonstrated that constructive methods can reconstruct much of classical analysis without the Law of Excluded Middle and without the Axiom of Choice.
148
-
149
- **Key differences between constructive logic and classical logic**:
150
- - Excluded middle ¬¬P → P is not valid in constructive logic.
151
- - AC is nearly unacceptable in constructive frameworks.
152
- - Proving ¬P means constructing a function from P to contradiction; proving P ∨ Q means providing a proof of P or a proof of Q.
153
-
154
- **Significance**: Constructive mathematics is not merely a philosophical stance but a practical necessity — computer-executable proofs must provide algorithms (i.e., constructions). This also has profound connections to Gödel's incompleteness theorems: if the Law of Excluded Middle is rejected, many classical "proofs" no longer hold, and the "incompleteness" profile of an axiomatic system changes accordingly.
@@ -1,160 +0,0 @@
1
- # 数学出处与经典文献 / Mathematical Sources and Classic Texts
2
-
3
- ## 欧几里得《几何原本》/ Euclid's *Elements* (~300 BC)
4
-
5
- **公理体系(五大公设)**:
6
-
7
- > 1. 任意两点之间可以作一条直线。
8
- > 2. 一条有限直线可以不断延长。
9
- > 3. 以任意中心和半径可以画一个圆。
10
- > 4. 所有直角都相等。
11
- > 5. (平行公设)若一条直线与两条直线相交,在同一侧的内角之和小于两直角,则这两条直线无限延长后在该侧相交。
12
-
13
- 1. A straight line segment can be drawn joining any two points.
14
- 2. Any straight line segment can be extended indefinitely in a straight line.
15
- 3. Given any straight line segment, a circle can be drawn having the segment as radius and one endpoint as center.
16
- 4. All right angles are congruent.
17
- 5. (Parallel Postulate) If two lines are drawn which intersect a third in such a way that the sum of the inner angles on one side is less than two right angles, then the two lines inevitably must intersect on that side if extended far enough.
18
-
19
- **意义**:人类历史上第一个公理化体系,展示了从 5 条公设和 5 条公理出发,通过严格逻辑推理可以推导出 465 个命题。
20
-
21
- ## 平行公设之争 / The Parallel Postulate Controversy (~300 BC – 1820s)
22
-
23
- 欧几里得第五公设从一开始就令人不安:它的表述远比前四条复杂,更像是一条定理而非公理。两千年来,无数数学家试图从前四条公设推导出它,均告失败。
24
-
25
- 关键人物与进展:
26
- - **Saccheri** (1733):试图通过假设平行公设为假来推导矛盾,虽未成功,但首次系统探索了非欧几何的性质。
27
- - **Lambert** (1766):类似思路,更深入地研究了钝角假设与锐角假设下的几何结论。
28
- - **Gauss** (~1820):私下已认识到非欧几何的逻辑自洽性,但因怕引起争议而未发表。
29
- - **Bolyai** (1832) & **Lobachevsky** (1829):各自独立发表双曲几何——一种平行公设为假但完全自洽的几何体系。
30
-
31
- > "我已从虚无中创造了另一个全新的世界。" — Bolyai
32
- > "I have created a new universe from nothing." — Bolyai
33
-
34
- **意义**:平行公设独立于其余四条——它既不能被证明也不能被证伪。这是公理独立性最早的实例,比哥德尔不完备定理早一百年就揭示了"公理不可被迫为真"的深刻事实。非欧几何的诞生直接催生了黎曼几何,后者成为广义相对论的数学基础。
35
-
36
- ## 希尔伯特《几何基础》/ Hilbert's *Foundations of Geometry* (1899)
37
-
38
- > "我们可以用'桌子、椅子、啤酒杯'代替'点、线、面'——只要它们满足公理之间的关系。"
39
- > "We must be able to replace 'points, lines, planes' with 'tables, chairs, beer mugs'—as long as they satisfy the relations between the axioms."
40
-
41
- 希尔伯特提出了更严格的公理体系要求:
42
- - **相容性**:公理不能互相矛盾
43
- - **独立性**:每条公理不能由其他公数推出
44
- - **完备性**:所有几何命题都能在体系内判定
45
-
46
- ## 皮亚诺算术公理 / Peano Axioms for Arithmetic (1889)
47
-
48
- 皮亚诺给出自然数的五条公理,是算术公理化最经典的形式:
49
-
50
- > P1. 0 是自然数。 / 0 is a natural number.
51
- > P2. 每个自然数 n 都有唯一后继 S(n)。 / Every natural number n has a unique successor S(n).
52
- > P3. 0 不是任何自然数的后继。 / 0 is not the successor of any natural number.
53
- > P4. 不同自然数有不同的后继。 / Different natural numbers have different successors.
54
- > P5. (归纳公理)若性质 P 对 0 成立,且对 n 成立则对 S(n) 成立,则 P 对所有自然数成立。 / (Induction) If P(0) and P(n) → P(S(n)), then P holds for all natural numbers.
55
-
56
- **意义**:一阶皮亚诺公理(PA)是哥德尔不完备定理的标准研究对象——PA 相容但不完备。二阶皮亚诺公理是范畴性的(见下文),唯一刻画自然数结构。
57
-
58
- ## ZFC 公理 / Zermelo-Fraenkel Set Theory with Choice (1908–1922)
59
-
60
- ZFC 是当代数学的标准公理基础,由 9 条公理组成:
61
-
62
- > Z1. 外延公理:两个集合相等当且仅当它们有相同的元素。 / Extensionality: sets with the same elements are equal.
63
- > Z2. 空集公理:存在不含任何元素的集合。 / Empty set: ∅ exists.
64
- > Z3. 配对公理:对任意 a, b,存在集合 {a, b}。 / Pairing: {a, b} exists.
65
- > Z4. 并集公理:任意集合族的并集存在。 / Union: the union of any family of sets exists.
66
- > Z5. 幂集公理:任意集合的所有子集构成一个集合。 / Power set: P(A) exists.
67
- > Z6. 无穷公理:存在含 0 且对后继封闭的集合。 / Infinity: an infinite set exists.
68
- > Z7. 替换公理(Fraenkel 补充):函数像在集合范围内。 / Replacement (Fraenkel's addition): images of functions on sets are sets.
69
- > Z8. 基础公理:每个非空集合有最小元,禁止集合包含自身。 / Foundation: every nonempty set has a minimal element; no set contains itself.
70
- > Z9. 选择公理(AC):对任意非空集合族,存在选择函数从每个集合中选取一个元素。 / Axiom of Choice: for any family of nonempty sets, a choice function exists.
71
-
72
- **选择公理争议**:AC 看似直观,却导致反直觉结论——最著名的是 **Banach-Tarski 悖论** (1924):一个球可以被切成五块,经旋转重组后变成两个与原球同样大小的球。Zermelo 用 AC 证明了每个集合都可良序化 (1904),这本身也令人困惑。
73
-
74
- > "选择公理显然为真,良序定理显然为假,而谁又能分辨?" — Jerry Bona
75
- > "The Axiom of Choice is obviously true, the Well-Ordering Theorem obviously false, and who can tell the difference?" — Jerry Bona
76
-
77
- **意义**:ZFC 的 9 条公理足以推导几乎所有现代数学。但 ZFC 本身也是哥德尔不完备定理的适用对象——ZFC 相容但无法在内部证明其相容性。
78
-
79
- ## 连续统假设 / Continuum Hypothesis (Cantor 1878, Gödel 1940, Cohen 1963)
80
-
81
- 康托尔在 1878 年提出:实数集(连续统)的势恰好是 ℵ₁——即不存在介于自然数势 ℵ₀ 与实数势之间的无穷基数。
82
-
83
- > CH: 2^ℵ₀ = ℵ₁。不存在"中等大小"的无穷集。 / There is no cardinal between ℵ₀ and 2^ℵ₀.
84
-
85
- - **Gödel** (1940):证明了 CH 与 ZFC 相容——在 ZFC 中无法反驳 CH。构造了可构造集 L,在其中 CH 成立。
86
- - **Cohen** (1963):用力迫法(forcing)证明了 ¬CH 也与 ZFC 相容——在 ZFC 中无法证明 CH。这是力迫法的诞生。
87
-
88
- **意义**:CH 是哥德尔不完备定理最具体的实例——一条关于无穷大小的自然命题,在数学的标准公理体系中既不可证也不可驳。这深刻揭示了公理体系的局限:即使是最基本的数学问题,也可能超出公理的力量。
89
-
90
- ## 哥德尔不完备定理 / Gödel's Incompleteness Theorems (1931)
91
-
92
- > **第一不完备定理**:任何一个包含算术的相容公理体系,都存在既不能证明也不能证伪的命题。
93
- > **第二不完备定理**:一个相容的公理体系不能在体系内部证明自身的相容性。
94
-
95
- **对公理化思想的启示**:完美的公理化是不可能的。但这不意味着公理化没有价值——它帮助我们理解理论的边界。
96
-
97
- ## Whitehead & Russell《数学原理》/ *Principia Mathematica* (1910–1913)
98
-
99
- 尝试将所有数学还原为逻辑和集合论公理,是公理化思想的巅峰尝试。虽然哥德尔后来证明了这种完全还原的不可能性,但《原理》展示了公理化方法的巨大力量。
100
-
101
- ## 范畴性 / Categoricity (Veblen 1904)
102
-
103
- Veblen 在 1904 年引入范畴性概念:一个公理体系称为范畴性的(categorical),如果它的所有模型都同构——即公理唯一地刻画了研究对象。
104
-
105
- > 范畴性 = 公理体系的所有模型彼此同构。/ Categoricity = all models of the axiom system are isomorphic.
106
-
107
- **关键例子**:
108
- - **二阶皮亚诺公理**是范畴性的——所有满足二阶 PA 的模型都是标准自然数结构 ℕ,唯一的。
109
- - **一阶皮亚诺公理**不是范畴性的——存在非标准模型,其中有"无穷大"的自然数(Skolem 1934)。
110
- - **一阶实闭域公理**是范畴性的(Tarski)——唯一刻画 ℝ。
111
-
112
- **意义**:范畴性是公理体系的理想性质——公理真正"钉住"了唯一的数学对象。但 L\"owenheim-Skolem 定理表明,任何一阶公理体系如果有无穷模型,就有任意大小的无穷模型,因此一阶体系永远不可能范畴性(除非只有有限模型)。二阶体系可以范畴性,但二阶逻辑没有完备的证明系统。这是公理化方法中一阶与二阶的根本张力。
113
-
114
- ## 塔斯基几何公理化 / Tarski's Axiomatization of Geometry (1926–1959)
115
-
116
- 塔斯基用一阶逻辑公理化欧几里得平面几何,只使用点(point)与介于(betweenness)、等距(equidistance)两个基本关系。
117
-
118
- > 塔斯基几何 = 一阶逻辑 + 点 + 介于 + 等距,共约 10 条公理(短版本仅需 7 条)。
119
- > Tarski's geometry = first-order logic + points + betweenness + equidistance, ~10 axioms (7 in the short version).
120
-
121
- **决定性与完备性**:塔斯基在 1959 年证明了这个公理体系是**完备且可判定的**——每条几何命题都可在体系内判定真伪,且存在算法自动判定。
122
-
123
- **对比哥德尔**:这似乎与哥德尔不完备定理矛盾。关键在于:塔斯基几何不含算术——它无法编码自然数,因此哥德尔定理的条件"包含算术"不满足。这深刻说明了:公理体系的完备与否取决于它能否表达足够的算术。
124
-
125
- **意义**:塔斯基的成果是公理化方法论上的奇迹——存在既完备又可判定的一阶公理体系。代价是必须牺牲对算术的表达能力。
126
-
127
- ## 布尔巴基 / Bourbaki (1935–)
128
-
129
- 布尔巴基是一群法国数学家的集体笔名,致力于以公理化方法系统重构全部数学。其巨著《数学原理》(*Éléments de mathématique*)以集合论为根基,逐层构建代数、分析、拓扑、微分等分支。
130
-
131
- > "数学不是关于数的,而是关于结构的。" — 布尔巴基的精神
132
- > "Mathematics is not about numbers, but about structures." — The Bourbaki spirit
133
-
134
- **三大母结构**:
135
- - **代数结构**:群、环、域——刻画运算与组合规律。
136
- - **序结构**:偏序、全序、格——刻画比较与排序规律。
137
- - **拓扑结构**:拓扑空间、度量空间——刻画连续与邻近规律。
138
-
139
- 布尔巴基认为一切数学结构都可从这三种母结构复合生成。这个纲领深刻影响了现代数学的分类方式与教学方式。
140
-
141
- **意义**:布尔巴基将公理化从"为单一学科建基础"提升到"为全部数学建统一架构"的宏大尺度。尽管后来范畴论提供了更灵活的视角,布尔巴aki的结构主义仍是数学公理化思想的核心遗产之一。
142
-
143
- ## 构造性数学 / Constructive Mathematics (Brouwer 1908, Heyting 1930, Bishop 1967)
144
-
145
- 构造性数学拒绝经典逻辑中的排中律(Law of Excluded Middle)和选择公理,要求每个存在性证明必须提供具体的构造方法——即"存在 x"必须伴随"如何找到 x"。
146
-
147
- > "存在即构造。" — 构造性数学的核心信条
148
- > "To exist is to construct." — Core credo of constructive mathematics
149
-
150
- **关键人物与体系**:
151
- - **Brouwer** (1908–):直觉主义创始人,认为数学是心智的自由创造,反对将排中律视为普遍有效。
152
- - **Heyting** (1930):为直觉主义逻辑建立了形式化公理体系——直觉主义逻辑(Heyting 算术)。
153
- - **Bishop** (1967):在《构造性分析》中展示了构造性方法可以重建经典分析的大部分内容,无需排中律也无需选择公理。
154
-
155
- **构造性逻辑与经典逻辑的关键差异**:
156
- - 排中律 ¬¬P → P 在构造性逻辑中不成立。/ Excluded middle ¬¬P → P is not valid in constructive logic.
157
- - 选择公理在构造性框架中几乎不可接受。/ AC is nearly unacceptable in constructive frameworks.
158
- - 证明 ¬P = 构造一个从 P 到矛盾的函数;证明 P ∨ Q = 给出 P 的证明或 Q 的证明。/ Proving ¬P means constructing a function from P to contradiction; proving P ∨ Q means providing a proof of P or a proof of Q.
159
-
160
- **意义**:构造性数学不仅是哲学立场,更是实际需要——计算机可执行证明必须提供算法(即构造)。这与哥德尔不完备定理也有深刻关联:如果拒绝排中律,许多经典逻辑下的"证明"不再成立,公理体系的"不完备"面目也随之改变。
@@ -1,147 +0,0 @@
1
- ---
2
- name: causal-inference
3
- description: |
4
- Trigger when a problem concerns correlation vs. causation, intervention/counterfactual reasoning, do-calculus, causal DAG modeling, confounder identification, policy/treatment effect estimation; or needs explicit causal assumptions for model interpretability, out-of-distribution generalization, or data-generating process modeling.
5
- ---
6
-
7
- # 🔗 Causal Inference
8
-
9
- > "Correlation is not causation — but causation can be sorted out. Key distinction: 'how is Y when we see X' is not the same as 'what if we did X.'"
10
- >
11
- > — Causal Inference, Structural Causal Models, Counterfactual Reasoning
12
-
13
- ## Core Principle
14
-
15
- **Causal inference answers questions beyond probability's expressive power: probability answers "how is Y when we see X," not "what if we did X." Pearl's causal hierarchy has three levels, each requiring stronger modeling assumptions.**
16
-
17
- > **Mathematical Formalization**
18
- >
19
- > Pearl's Causal Hierarchy:
20
- > - **Level 1 — Association**: $P(y|x)$ — Seeing
21
- > - **Level 2 — Intervention**: $P(y|do(x))$ — Doing
22
- > - **Level 3 — Counterfactual**: $P(y_x|x',y')$ — Imagining
23
- >
24
- > **$do(x) \neq$ conditioning on $x$**: $do(x)$ severs all arrows pointing into $X$ (graph surgery), while conditioning on $x$ severs no arrows. Back-door adjustment: $P(y|do(x)) = \sum_z P(y|x,z)P(z)$
25
- >
26
- > **Potential Outcomes (Neyman-Rubin)**: $Y(x)$ denotes "the value $Y$ would take under intervention $X=x$"; individual treatment effect $\tau_i = Y_i(1)-Y_i(0)$; average treatment effect ATE $= E[Y(1)]-E[Y(0)] = E[Y|do(X=1)] - E[Y|do(X=0)]$.
27
- >
28
- > **Structural Causal Model (SCM)**: $Y := f(X, Z, U)$, where $U$ is exogenous; the DAG together with structural equations determines the counterfactual $Y_x = f(x, Z, U)$.
29
- >
30
- > **d-Separation**: A path is blocked by $Z$ $\iff$ a chain/fork middle node $\in Z$, or a collider $X\to C\leftarrow Y$ has $C$ and its descendants $\notin Z$. d-separation $X\perp_G Y|Z$ implies conditional independence; it is the tool for reading off causal assumptions from the graph.
31
- >
32
- > **Do-Calculus — Three Rules** (applied on modified graphs using d-separation):
33
- > - Rule 1 (Insertion/deletion of observations): If $Y \perp Z \mid X$ in the graph with all arrows into $X$ removed, then $P(y|do(x),z) = P(y|do(x))$
34
- > - Rule 2 (Exchange of intervention and observation): If $Y \perp Z \mid X$ in the graph with all arrows into $X$ removed and all arrows out of $Z$ removed, then $P(y|do(x),do(z)) = P(y|do(x),z)$
35
- > - Rule 3 (Insertion/deletion of interventions): If $Y \perp Z \mid X$ in the graph with all arrows into $X$ removed and all arrows from $Z$ to $X$ along paths from $Z$ to $X$ removed, then $P(y|do(x),do(z)) = P(y|do(x))$
36
- >
37
- > **Causal reasoning requires an explicit causal model; it cannot be derived from data alone. The DAG encodes causal assumptions, and do-calculus transforms interventional expressions into observable quantities.**
38
- >
39
- > See `original-texts.md` for detailed mathematical foundations.
40
-
41
- ## GPU-Friendliness (Cross-Cutting Check)
42
-
43
- When causal inference is used for **model interpretability / out-of-distribution generalization / data-generating process modeling** at scale, the methods themselves must pass through the eight-dimensional gate in `../../references/gpu-friendly-math.md`:
44
-
45
- - **Effect estimation / adjustment regression**: Back-door adjustment, IPW, doubly-robust ML — conditional expectations and regression are all batch GEMM, tensorizable, fusible, low-precision viable — **friendly** (see `../../references/books/optimization-ml.md`).
46
- - **Conditional independence testing**: High-dimensional conditional independence tests involve precision matrix (covariance inverse) inversion $O(p^3)$; can be reformed via **low-rank / diagonal approximation** or iterative solvers — **retrofittable** (see `../../references/books/matrix-analysis.md`).
47
- - **Exact causal discovery (DAG search)**: DAG space grows super-exponentially with node count; exact score-based search is NP-hard, non-differentiable, serial — a classic "beautiful but intractable" anti-pattern.
48
- - **Reform approach**: NOTEARS-style **continuous relaxation** (acyclicity constraint $h(W)=\text{tr}(e^{W\circ W})-p=0$) transforms discrete graph search into differentiable optimization; alternatively, MCMC / greedy + scoring as heuristic approximation.
49
- - **Counterfactual / SCM simulation**: Forward simulation of structural equations is batch-parallelizable; however, individual counterfactuals depend on identifying exogenous $U$ — watch for serial dependencies.
50
-
51
- Eight-dimensional minimum assessment (formal terms): **Tensorization** — whether samples / interventions / candidate graphs admit batched processing; **GEMM-mappability** — whether adjustment regression and representation learning fall into matrix multiplication; **Complexity** — whether causal discovery avoids super-exponential DAG search; **Memory and KV-Cache** — whether precision matrices, candidate graphs, and intermediate counterfactuals are compressible; **Low-precision stability** — whether IPW weights, covariance inverses, and logits are numerically robust; **Parallelism and communication** — whether multi-environment / multi-intervention estimation is parallelizable; **Sparse structure** — whether the DAG / SCM is structurally sparse; **Operator fusion** — whether scoring, masking, and loss can be fused.
52
-
53
- > Use in conjunction with `../../references/books/optimization-ml.md` (intervention estimation / regression) and `../../references/books/matrix-analysis.md` (conditional independence / low-rank precision matrices).
54
-
55
- ## When NOT to Use
56
-
57
- - **Pure prediction tasks with no causal question** (only $P(y|x)$ is needed, no interest in "why") — association is sufficient; causation is superfluous.
58
- - **No encodable causal assumptions** (cannot draw a reasonable DAG; causal directions are uncertain) — without explicit assumptions, no causal conclusions can be drawn.
59
- - **Deterministic systems with no variation** (inputs map strictly uniquely to outputs) — causation is fully described by the mechanism; the probabilistic causal framework is unnecessary.
60
-
61
- ## When to Use
62
-
63
- - Need to know the effect of an intervention ("If we do X, what happens to Y?") — requires $P(y|do(x))$, not $P(y|x)$.
64
- - Need to distinguish causes from confounders (Does X cause Y, or does Z cause both X and Y?) — DAGs identify confounding paths.
65
- - Need counterfactual reasoning ("What would have happened if we had not done A?") — Level 3 requires structural equations.
66
- - Need policy / treatment effect evaluation (back-door adjustment, IV, difference-in-differences when RCTs are infeasible).
67
- - Need mediation analysis (decomposing direct and indirect effects along $X\to M\to Y$).
68
- - Need to model the data-generating process (DGP) for **model interpretability / out-of-distribution generalization**, transforming predictor associations into actionable causal mechanisms.
69
-
70
- ## Method
71
-
72
- ### Step 1: Construct the Causal DAG
73
- Identify all variables explicitly; draw causal arrows encoding direct-cause assumptions; verify acyclicity. Identify the cause variable $X$ (intervention target), outcome $Y$ (effect), confounders $Z$ (common causes of $X$ and $Y$), and mediators $M$ ($X\to M\to Y$). An arrow $X\to Y$ means "$X$ is a direct cause of $Y$"; the direction encodes a causal assumption. The DAG must be directed and acyclic — cycles indicate uncertain causal direction and require re-modeling. **Key question**: Is there sufficient domain knowledge to encode causal directions? Conclusions depend entirely on DAG correctness.
74
-
75
- ### Step 2: Identify Confounders
76
- Confounders simultaneously affect $X$ and $Y$, creating spurious association — without adjustment, effect estimates are biased. **Definition**: $Z$ is a confounder $\iff$ $Z$ is a common cause of $X$ and $Y$ ($Z\to X$ and $Z\to Y$). **DAG identification**: find all common ancestors of $X$ and $Y$. **Back-door paths** $X\leftarrow Z\to Y$ create non-causal associations that must be blocked. **Key question**: Are all confounders observable? If unobserved confounders exist, back-door adjustment is unavailable and front-door criterion or instrumental variables are needed.
77
-
78
- ### Step 3: Choose Identification Strategy
79
- Based on confounder observability, select a strategy for computing $P(y|do(x))$ from observational data:
80
- - **Back-door criterion**: If $\exists S$ blocking all back-door paths from $X$ to $Y$ and $S$ contains no descendants of $X$, then $P(y|do(x)) = \sum_s P(y|x,S=s)\cdot P(S=s)$.
81
- - **Front-door criterion**: Confounders are unobservable but mediator $M$ is observable, $X\to M$ has no back-door paths, and $M$ blocks all back-door paths from $X$ to $Y$; then $P(y|do(x)) = \sum_m P(m|x)\cdot\sum_z P(y|m,z)P(z)$.
82
- - **Do-calculus**: Three rules transform do-expressions among observable quantities (see the Mathematical Formalization block in Core Principle).
83
-
84
- ### Step 4: Compute Intervention Effects
85
- Use the adjustment formula to compute $P(y|do(x))$ and compare with the observational $P(y|x)$ to quantify confounding bias:
86
- - Back-door adjustment: $P(y|do(x)) = \sum_z P(y|x,z)\cdot P(z)$ — weighted average over all values of $Z$.
87
- - Confounding bias: $|P(y|do(x)) - P(y|x)|$ — larger bias indicates more severe confounding.
88
- - Average treatment effect: ATE $= E[Y|do(X=1)] - E[Y|do(X=0)] = E[Y(1)] - E[Y(0)]$.
89
-
90
- **Key question**: Are $P(y|do(x))$ and $P(y|x)$ significantly different? If so, observational analysis suffers from confounding bias.
91
-
92
- ### Step 5: Counterfactual Analysis
93
- Individual-level retrospective reasoning: If $X$ had been $x_1$ instead of $x_0$, what would $Y$ have been?
94
- - **SCM**: $Y = f(X, Z, U)$, where $U$ is exogenous.
95
- - **Counterfactual computation**: Given observation $(x_0,y_0,z_0)$, the counterfactual $Y_{x_1} = f(x_1, z_0, u_0)$.
96
- - **Individual causal effect**: $Y_{x_1} - Y_{x_0}$ — requires structural equations.
97
-
98
- **Key point**: Counterfactuals depend on the specific form of the structural equations and are highly sensitive to model assumptions.
99
-
100
- ### Step 6: Experimental Design
101
- - **RCT (gold standard)**: Randomization severs all arrows into $X$; treatment and control groups are equal in expectation on all variables; ATE $= E[Y|do(X=1)] - E[Y|do(X=0)]$.
102
- - **Natural experiments**: Exploit naturally occurring quasi-random events (earthquakes, policy changes).
103
- - **Instrumental variables (IV)**: $V\to X$ with no direct path from $V$ to $Y$ and no common cause of $V$ and $Y$ — use the variation in $X$ created by $V$ to estimate the causal effect.
104
- - **Difference-in-differences (DD)**: $(Y_1^{\text{post}}-Y_1^{\text{pre}}) - (Y_0^{\text{post}}-Y_0^{\text{pre}})$.
105
-
106
- ### Step 7: Sensitivity Analysis
107
- Quantify the vulnerability of conclusions to unobserved confounding:
108
- - **Rosenbaum $\Gamma$**: For confounding strength $\Gamma$, compute the maximum $p$-value at which the conclusion could be overturned — larger $\Gamma$ means more vulnerable.
109
- - **E-value**: The minimum confounding strength required to nullify the effect estimate — larger values indicate greater robustness.
110
-
111
- **Key question**: How strong must an unobserved confounder $U$ be to overturn the conclusion?
112
-
113
- ## Common Errors
114
-
115
- | Error | Critique | Correct Approach |
116
- |---|---|---|
117
- | Inferring causation directly from correlation | $P(y\|x)\neq P(y\|do(x))$; correlation may be created by confounding | Draw a DAG to identify confounders; use back-door adjustment to compute $P(y\|do(x))$ |
118
- | Ignoring confounders | Without adjustment, $\|P(y\|do(x))-P(y\|x)\|$ equals confounding bias | Find all common ancestors of $X$ and $Y$; adjust for observable confounders |
119
- | Confusing $do(x)$ with conditioning $P(y\|x)$ | $do(x)$ severs arrows into $X$; conditioning does not | Clearly distinguish intervention (forced setting) from observation (passive seeing) |
120
- | Ignoring mediation effects | $X\to M\to Y$: total effect = direct + indirect | Perform mediation analysis to decompose direct / indirect effects; front-door criterion may apply |
121
- | Over-reliance on a single DAG | If the DAG is wrong, all conclusions are wrong; different DAGs can yield opposite conclusions | Validate DAG plausibility; compare multiple candidate DAGs |
122
- | Skipping sensitivity analysis | Unobserved confounders may overturn conclusions | Quantify vulnerability using Rosenbaum $\Gamma$ or E-value |
123
- | Intractable exact causal graph search | DAG space is super-exponential, NP-hard, non-differentiable | Use continuous relaxation (NOTEARS) / heuristic approximation; pass through the GPU eight-dimensional gate |
124
-
125
- ## Operating Procedure
126
-
127
- When this skill is triggered, the output must include:
128
-
129
- 1. **[DAG]**: Directed acyclic graph of all variables, with justification for each arrow's causal assumption.
130
- 2. **[Confounders]**: List all common ancestors of $X$ and $Y$; label each as observable / unobservable.
131
- 3. **[Identification Strategy]**: Back-door / front-door / do-calculus, with justification for the choice.
132
- 4. **[Intervention Effect]**: $P(y|do(x))$ = [value], computed via the adjustment formula and compared with $P(y|x)$.
133
- 5. **[Counterfactuals]**: Counterfactual reasoning for key individuals / subgroups, specifying the required structural equations.
134
- 6. **[Validation Method]**: RCT / natural experiment / IV / DD — how to validate causal conclusions.
135
- 7. **[Sensitivity]**: Rosenbaum $\Gamma$ or E-value, quantifying vulnerability to unobserved confounding.
136
- 8. **[GPU Feasibility]** (if used for large-scale estimation in interpretability / OOD / DGP modeling): Causal discovery / estimation method passes through the eight-dimensional gate; label friendly / retrofittable / unfriendly with reform suggestions.
137
-
138
- **Output must not consist of analysis alone without conclusions.**
139
-
140
- ## Relations to Other Skills
141
-
142
- - **Probability and Statistics**: Statistics is the foundation of causation but is insufficient — $P(y|x)$ is association, $P(y|do(x))$ is causal effect; causation requires additional assumptions.
143
- - **Modeling Thinking**: Causal DAGs are structural models — they encode hypotheses about causal mechanisms among variables; causal modeling is the causal version of modeling.
144
- - **Logical Deduction**: Starting from DAG assumptions, causal conclusions are deduced through the three rules of do-calculus.
145
- - **Information Theory Thinking**: Confounders create spurious signals; causal inference extracts true causal signals from noise.
146
- - **Game Theory Thinking**: Players' choices in strategic interaction constitute causal interventions; equilibrium analysis requires causal reasoning.
147
- - **Modern Mathematics Activation**: `../../references/books/optimization-ml.md` (intervention estimation / regression, double ML), `../../references/books/matrix-analysis.md` (conditional independence testing, low-rank precision matrix approximation).
@@ -1,151 +0,0 @@
1
- ---
2
- name: causal-inference
3
- description: |
4
- 触发:相关≠因果、干预/反事实推理、do-演算、因果图(DAG)建模、混淆变量识别、政策/处理效应评估;或为模型可解释性、分布外泛化、数据生成过程(DGP)建模而需显式因果假设时调用。
5
- English: Trigger when a problem concerns correlation≠causation, intervention/counterfactual reasoning, do-calculus, causal DAG modeling, confounder identification, policy/treatment effect estimation; or needs explicit causal assumptions for model interpretability, out-of-distribution generalization, or data-generating process modeling.
6
- ---
7
-
8
- > **语言路由**:若用户消息为英文,请读取并遵循同目录下的 `SKILL.en.md`,按其操作规程以英文输出;中文消息则继续使用本文件。
9
-
10
- # 🔗 因果推断思想 / Causal Inference
11
-
12
- > "相关不等于因果——但因果可以理清。关键区别:'看到X时Y如何'≠'如果做了X会怎样'"
13
- > "Correlation is not causation — but causation can be sorted out. Key distinction: 'how is Y when we see X' ≠ 'what if we did X'"
14
- >
15
- > —— 因果推断、结构因果模型、反事实推理
16
- > —— Causal Inference, Structural Causal Models, Counterfactual Reasoning
17
-
18
- ## 核心原则 / Core Principle
19
-
20
- **因果推断回答的问题超出概率论的表达能力:概率论能回答"看到 X 时 Y 如何",但不能回答"如果做了 X 会怎样"。Pearl 因果层级将推理分为三层,每层需要更强的建模假设。**
21
-
22
- **Causal inference answers questions beyond probability's expressive power: probability answers "how is Y when we see X," not "what if we did X." Pearl's causal hierarchy has three levels, each requiring stronger modeling assumptions.**
23
-
24
- > **数学形式化 / Mathematical Formalization**
25
- >
26
- > Pearl 因果层级 / Causal Hierarchy:
27
- > - **Level 1 关联 / Association**:P(y|x) —— 看到/观察 / Seeing
28
- > - **Level 2 干预 / Intervention**:P(y|do(x)) —— 做/干预 / Doing
29
- > - **Level 3 反事实 / Counterfactual**:P(y_x|x',y') —— 想/回顾 / Imagining
30
- >
31
- > **do(x) ≠ 条件化 x**:do(x) 切断所有指向 X 的箭头(图手术),条件化 x 不切断任何箭头。后门调整 / back-door adjustment:P(y|do(x)) = Σ_z P(y|x,z)P(z)
32
- >
33
- > **潜在结果 / Potential Outcomes (Neyman-Rubin)**:Y(x) 为"若施干预 X=x 时 Y 的取值";个体效应 τ_i = Y_i(1)-Y_i(0),平均处理效应 ATE = E[Y(1)]-E[Y(0)] = E[Y|do(X=1)] - E[Y|do(X=0)]。
34
- >
35
- > **结构因果模型 / SCM**:Y := f(X, Z, U),U 为外生变量;DAG + 结构方程共同确定反事实 Y_x = f(x, Z, U)。
36
- >
37
- > **d-分离 / d-Separation**:路径被 Z 阻断 ⟺ 链/叉中点 ∈ Z,或 collider X→C←Y 且 C 及其后代 ∉ Z。d-分离 X⊥_G Y|Z 蕴含条件独立,是图上读出因果假设的工具。
38
- >
39
- > **do-演算三规则 / Do-calculus**(在修正图上用 d-分离判断):
40
- > - 规则 1(插入/删除观察):若 Y ⊥ Z | X 在删去所有指向 X 的箭头后的图中成立,则 P(y|do(x),z) = P(y|do(x))
41
- > - 规则 2(干预与观察互换):若 Y ⊥ Z | X 在删去所有指向 X 的箭头并删去所有从 Z 出发的箭头后的图中成立,则 P(y|do(x),do(z)) = P(y|do(x),z)
42
- > - 规则 3(插入/删除干预):若 Y ⊥ Z | X 在删去所有指向 X 的箭头并删去所有从 Z 到 X 的路径上的箭头后的图中成立,则 P(y|do(x),do(z)) = P(y|do(x))
43
- >
44
- > **因果推理需显式因果模型,不能仅靠数据推导。DAG 编码因果假设,do-演算将干预表达式转化为可观测量。**
45
- >
46
- > 详细数学依据见 `original-texts.md`
47
-
48
- ## GPU 友好性 / GPU-Friendliness(横切检查)
49
-
50
- 当因果推断用于**模型可解释性 / 分布外泛化 / 数据生成过程建模**并需大规模估计时,方法本身要过 `../../references/gpu-friendly-math.md` 八维门:
51
-
52
- - **效应估计 / 调整回归**:后门调整、IPW、双重机器学习的条件期望/regression 全是批量 GEMM,张量化、可融合、低精度可行——**友好**(见 `../../references/books/optimization-ml.md`)。
53
- - **条件独立检验**:高维条件独立检验含精度阵(协方差逆)求逆 $O(p^3)$,可改 **低秩/对角近似**或迭代求解器——**可改造**(见 `../../references/books/matrix-analysis.md`)。
54
- - **精确因果发现(DAG 搜索)**:DAG 空间随节点数超指数增长,精确打分搜索 NP-hard、不可微、串行——典型"美但不可算"反模式。
55
- - **改造手法**:NOTEARS 式**连续松弛**(无环性 $h(W)=\text{tr}(e^{W\circ W})-p=0$)把离散图搜索变成可微优化;或 MCMC/贪心+打分作启发式近似。
56
- - **反事实/SCM 仿真**:结构方程前向模拟可批量并行;但个体反事实依赖外生 U 的识别,警惕串行依赖。
57
-
58
- 八维最低判定(正式术语):**张量化**看样本/干预/候选图能否批量处理;**GEMM 可映射**看调整回归与表示学习是否落矩阵乘;**复杂度**看因果发现是否避开超指数 DAG 搜索;**显存与 KV-Cache**看精度阵、候选图和中间反事实是否可压缩;**低精度稳定**看 IPW 权重、协方差逆和 logit 是否稳健;**并行与通信**看多环境/多干预估计能否并行;**稀疏结构**看 DAG/SCM 是否结构化稀疏;**算子融合**看打分、mask、loss 能否融合。
59
-
60
- > 配合 `../../references/books/optimization-ml.md`(干预估计/regression)与 `../../references/books/matrix-analysis.md`(条件独立/低秩精度阵)。
61
-
62
- ## 不适用场景 / When NOT to Use
63
-
64
- - **纯预测任务且无因果问题**(只需 P(y|x),不关心"为什么")——关联足够,因果多余。
65
- - **无可编码的因果假设**(画不出合理 DAG,因果方向不确定)——没有显式假设就没有因果结论。
66
- - **确定性系统且无变异**(输入严格唯一映射输出)——因果已被机制完全描述,无需概率因果框架。
67
-
68
- ## 何时使用 / When to Use
69
-
70
- - 需要知道干预的效果("做了 X,Y 会怎样?")——需 P(y|do(x)) 而非 P(y|x)。
71
- - 需要区分原因与混淆变量(X 导致 Y,还是 Z 同时导致 X 和 Y?)——DAG 识别混淆路径。
72
- - 需要反事实推理("若当时没做 A 结果会怎样?")——Level 3 需结构方程。
73
- - 需要政策/处理效应评估(RCT 不可行时的后门调整、IV、双重差分)。
74
- - 需要中介分析(拆分 X→M→Y 的直接与间接效应)。
75
- - 需要为**模型可解释性 / 分布外泛化**建模数据生成过程(DGP),把预测器的关联变成可干预的因果机制。
76
-
77
- ## 方法流程 / Method
78
-
79
- ### 第一步:构建因果 DAG / Construct the Causal DAG
80
- 明确所有变量,画因果箭头编码直接原因假设,检查无环性。识别原因变量 X(干预对象)、结果 Y(效应)、混淆 Z(X、Y 共同原因)、中介 M(X→M→Y)。箭头 X→Y 表示"X 是 Y 的直接原因",方向编码因果假设。DAG 必须有向无环——存在环路则因果方向不确定,需重新建模。**关键**:是否有足够领域知识编码因果方向?结论完全依赖 DAG 正确性。
81
-
82
- ### 第二步:识别混淆变量 / Identify Confounders
83
- 混淆变量同时影响 X 和 Y,创造虚假关联——不调整则效应估计有偏。**定义**:Z 是混淆 ⟺ Z 是 X、Y 的共同原因(Z→X 且 Z→Y)。**DAG 识别法**:找 X、Y 的所有共同祖先。**后门路径** X←Z→Y 创造非因果关联需阻断。**关键**:所有混淆是否可观测?存在未观测混淆则后门调整不可用,需前门准则或工具变量。
84
-
85
- ### 第三步:选择识别策略 / Choose Identification Strategy
86
- 据混淆可观测性,选择从观测数据计算 P(y|do(x)) 的策略:
87
- - **后门准则 / Back-door**:若 ∃ S 阻断 X→Y 所有后门路径且 S 不含 X 的后代,则 P(y|do(x)) = Σ_s P(y|x,S=s)·P(S=s)。
88
- - **前门准则 / Front-door**:混淆不可观测但中介 M 可观测,且 X→M 无后门、M 阻断 X→Y 所有后门路径,则 P(y|do(x)) = Σ_m P(m|x)·Σ_z P(y|m,z)P(z)。
89
- - **do-演算**:三规则在可观测量间转换 do-表达式(见核心原则数学形式化块)。
90
-
91
- ### 第四步:计算干预效果 / Compute Intervention Effects
92
- 用调整公式算 P(y|do(x)),与观察性 P(y|x) 对比衡量混淆偏差:
93
- - 后门调整:P(y|do(x)) = Σ_z P(y|x,z)·P(z)——对 Z 所有取值加权平均。
94
- - 混淆偏差:|P(y|do(x)) - P(y|x)|——偏差越大混淆越严重。
95
- - 平均处理效应:ATE = E[Y|do(X=1)] - E[Y|do(X=0)] = E[Y(1)] - E[Y(0)]。
96
- **关键**:P(y|do(x)) 与 P(y|x) 是否显著不同?不同则观察性分析有混淆偏差。
97
-
98
- ### 第五步:反事实分析 / Counterfactual Analysis
99
- 个体层面回顾性推理:若 X 是 x₁ 而非 x₀,Y 会怎样?
100
- - **SCM**:Y = f(X, Z, U),U 为外生变量。
101
- - **反事实计算**:给定观测 (x₀,y₀,z₀),反事实 Y_{x₁} = f(x₁, z₀, u₀)。
102
- - **个体因果效应**:Y_{x₁} - Y_{x₀}——需结构方程。
103
- **关键**:反事实依赖结构方程具体形式,对模型假设极敏感。
104
-
105
- ### 第六步:实验设计验证 / Experimental Design
106
- - **RCT(黄金标准)**:随机化切断所有指向 X 的箭头,处理组与对照组在所有变量上期望相等;ATE = E[Y|do(X=1)] - E[Y|do(X=0)]。
107
- - **自然实验**:利用自然发生的准随机事件(地震、政策变更)。
108
- - **工具变量 IV**:V→X 且 V 到 Y 无直接路径、V 与 Y 无共同原因——用 V 创造的 X 变异估计因果效应。
109
- - **双重差分 DD**:(Y₁^后-Y₁^前) - (Y₀^后-Y₀^前)。
110
-
111
- ### 第七步:敏感性分析 / Sensitivity Analysis
112
- 量化结论对未观测混淆的脆弱性:
113
- - **Rosenbaum Γ**:对混淆强度 Γ,算结论可能翻转的最大 p-value——Γ 越大越脆弱。
114
- - **E-value**:使效应估计归零所需的最小混淆强度——越大越稳健。
115
- **关键**:未观测混淆 U 必须多强才能推翻结论?
116
-
117
- ## 常见错误 / Common Errors
118
-
119
- | 错误 / Error | 批评 / Critique | 正确做法 / Correct Approach |
120
- |---|---|---|
121
- | 从相关直接推断因果 | P(y\|x)≠P(y\|do(x));相关可能由混淆创造 | 画 DAG 识别混淆,用后门调整算 P(y\|do(x)) |
122
- | 忽略混淆变量 | 不调整时 \|P(y\|do(x))-P(y\|x)\|=混淆偏差 | 找 X、Y 所有共同祖先,调整可观测混淆 |
123
- | 混淆 do(x) 与条件化 P(y\|x) | do(x) 切断指向 X 的箭头,条件化不切断 | 明确区分干预(强制设定)与观察(看到时) |
124
- | 忽略中介效应 | X→M→Y 总效应=直接+间接 | 中介分析拆分直接/间接效应,前门准则可用 |
125
- | 过度依赖单一 DAG | DAG 错则结论全错,不同 DAG 可能给相反结论 | 检验 DAG 合理性,比较多个备选 DAG |
126
- | 忽略敏感性分析 | 未观测混淆可能推翻结论 | 用 Rosenbaum Γ 或 E-value 量化脆弱性 |
127
- | 精确因果图搜索不可算 | DAG 空间超指数、NP-hard、不可微 | 连续松弛(NOTEARS)/启发式近似,过 GPU 八维门 |
128
-
129
- ## 操作规程 / Operating Procedure
130
-
131
- 当本 skill 被触发时,输出必须包含:
132
-
133
- 1. **[DAG]**:所有变量的有向无环图,标注每条箭头的假设依据。
134
- 2. **[混淆变量]**:列出 X、Y 的所有共同祖先,标注可观测/不可观测。
135
- 3. **[识别策略]**:后门/前门/do-演算,说明选择理由。
136
- 4. **[干预效果]**:P(y|do(x))=[值],用调整公式计算并与 P(y|x) 对比。
137
- 5. **[反事实]**:对关键个体/子群反事实推理,说明所需结构方程。
138
- 6. **[验证方法]**:RCT/自然实验/IV/DD,如何验证因果结论。
139
- 7. **[敏感性]**:Rosenbaum Γ 或 E-value,量化对未观测混淆的脆弱性。
140
- 8. **[GPU 可行性]**(若用于可解释性/OOD/DGP 建模的大规模估计):因果发现/估计方法过八维门,标注友好/可改造/不友好 + 改造建议。
141
-
142
- **输出不得只给分析而无结论。**
143
-
144
- ## 与其他 skill 的关系 / Relations to Other Skills
145
-
146
- - **概率与统计**:统计是因果的基础但不充分——P(y|x) 是关联,P(y|do(x)) 是因果效应;因果需额外假设。
147
- - **建模思想**:因果 DAG 是结构模型——编码变量间因果机制假设,是建模的因果版本。
148
- - **逻辑演绎**:从 DAG 假设出发,通过 do-演算三规则演绎因果结论。
149
- - **信息论思想**:混淆变量制造虚假信号,因果推断从噪声中提取真实因果信号。
150
- - **博弈思想**:策略互动中参与者的选择构成因果干预,均衡分析需因果推理。
151
- - **现代数学激活**:`../../references/books/optimization-ml.md`(干预估计/regression、双重 ML)、`../../references/books/matrix-analysis.md`(条件独立检验、精度阵低秩近似)。