math-skill 2.1.0 → 3.0.1

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 (244) hide show
  1. package/README.en-US.md +165 -198
  2. package/README.md +165 -198
  3. package/agents/math-critic.en.md +28 -26
  4. package/agents/math-critic.md +33 -33
  5. package/commands/ask.en.md +10 -0
  6. package/commands/ask.md +3 -10
  7. package/design-patterns/attention/equivariant-attention.en.md +72 -0
  8. package/design-patterns/attention/equivariant-attention.md +72 -0
  9. package/design-patterns/attention/geometry-aware-attention.en.md +73 -0
  10. package/design-patterns/attention/geometry-aware-attention.md +72 -0
  11. package/design-patterns/attention/information-bottleneck-attention.en.md +72 -0
  12. package/design-patterns/attention/information-bottleneck-attention.md +72 -0
  13. package/design-patterns/attention/projection-attention.en.md +68 -0
  14. package/design-patterns/attention/projection-attention.md +68 -0
  15. package/design-patterns/attention/spectral-attention.en.md +71 -0
  16. package/design-patterns/attention/spectral-attention.md +71 -0
  17. package/design-patterns/compression/leverage-score-selection.en.md +71 -0
  18. package/design-patterns/compression/leverage-score-selection.md +71 -0
  19. package/design-patterns/compression/low-rank-kv-cache.en.md +60 -0
  20. package/design-patterns/compression/low-rank-kv-cache.md +60 -0
  21. package/design-patterns/compression/spectral-token-pruning.en.md +61 -0
  22. package/design-patterns/compression/spectral-token-pruning.md +61 -0
  23. package/design-patterns/compression/topology-preserving-compression.en.md +64 -0
  24. package/design-patterns/compression/topology-preserving-compression.md +64 -0
  25. package/design-patterns/loss/constraint-penalty.en.md +67 -0
  26. package/design-patterns/loss/constraint-penalty.md +78 -0
  27. package/design-patterns/loss/contrastive-loss.en.md +59 -0
  28. package/design-patterns/loss/contrastive-loss.md +68 -0
  29. package/design-patterns/loss/information-bottleneck-loss.en.md +69 -0
  30. package/design-patterns/loss/information-bottleneck-loss.md +74 -0
  31. package/design-patterns/loss/orthogonality-loss.en.md +56 -0
  32. package/design-patterns/loss/orthogonality-loss.md +60 -0
  33. package/design-patterns/loss/variational-loss.en.md +61 -0
  34. package/design-patterns/loss/variational-loss.md +71 -0
  35. package/design-patterns/representation/equivariant-split.en.md +87 -0
  36. package/design-patterns/representation/equivariant-split.md +89 -0
  37. package/design-patterns/representation/manifold-representation.en.md +85 -0
  38. package/design-patterns/representation/manifold-representation.md +87 -0
  39. package/design-patterns/representation/shared-private-decomposition.en.md +84 -0
  40. package/design-patterns/representation/shared-private-decomposition.md +86 -0
  41. package/design-patterns/representation/subspace-alignment.en.md +90 -0
  42. package/design-patterns/representation/subspace-alignment.md +92 -0
  43. package/design-patterns/routing/graph-routing.en.md +79 -0
  44. package/design-patterns/routing/graph-routing.md +81 -0
  45. package/design-patterns/routing/moe-routing.en.md +85 -0
  46. package/design-patterns/routing/moe-routing.md +87 -0
  47. package/design-patterns/routing/optimal-transport-routing.en.md +68 -0
  48. package/design-patterns/routing/optimal-transport-routing.md +72 -0
  49. package/design-patterns/routing/spectral-clustering-routing.en.md +88 -0
  50. package/design-patterns/routing/spectral-clustering-routing.md +90 -0
  51. package/knowledge-base/differential-geometry/connection.en.md +51 -0
  52. package/knowledge-base/differential-geometry/connection.md +51 -0
  53. package/knowledge-base/differential-geometry/curvature.en.md +49 -0
  54. package/knowledge-base/differential-geometry/curvature.md +49 -0
  55. package/knowledge-base/differential-geometry/geodesic.en.md +51 -0
  56. package/knowledge-base/differential-geometry/geodesic.md +51 -0
  57. package/knowledge-base/differential-geometry/manifold.en.md +47 -0
  58. package/knowledge-base/differential-geometry/manifold.md +47 -0
  59. package/knowledge-base/differential-geometry/metric-tensor.en.md +50 -0
  60. package/knowledge-base/differential-geometry/metric-tensor.md +50 -0
  61. package/knowledge-base/differential-geometry/tangent-space.en.md +48 -0
  62. package/knowledge-base/differential-geometry/tangent-space.md +48 -0
  63. package/knowledge-base/information-geometry/fisher-metric.en.md +56 -0
  64. package/knowledge-base/information-geometry/fisher-metric.md +56 -0
  65. package/knowledge-base/information-geometry/natural-gradient.en.md +54 -0
  66. package/knowledge-base/information-geometry/natural-gradient.md +54 -0
  67. package/knowledge-base/lie-theory/equivariance.en.md +54 -0
  68. package/knowledge-base/lie-theory/equivariance.md +54 -0
  69. package/knowledge-base/lie-theory/group-action.en.md +51 -0
  70. package/knowledge-base/lie-theory/group-action.md +51 -0
  71. package/knowledge-base/lie-theory/lie-algebra.en.md +51 -0
  72. package/knowledge-base/lie-theory/lie-algebra.md +51 -0
  73. package/knowledge-base/lie-theory/lie-group.en.md +51 -0
  74. package/knowledge-base/lie-theory/lie-group.md +51 -0
  75. package/knowledge-base/lie-theory/representation.en.md +52 -0
  76. package/knowledge-base/lie-theory/representation.md +52 -0
  77. package/knowledge-base/matrix-analysis/low-rank-approximation.en.md +49 -0
  78. package/knowledge-base/matrix-analysis/low-rank-approximation.md +49 -0
  79. package/knowledge-base/matrix-analysis/matrix-perturbation.en.md +49 -0
  80. package/knowledge-base/matrix-analysis/matrix-perturbation.md +49 -0
  81. package/knowledge-base/matrix-analysis/positive-semidefinite.en.md +50 -0
  82. package/knowledge-base/matrix-analysis/positive-semidefinite.md +50 -0
  83. package/knowledge-base/matrix-analysis/projection.en.md +47 -0
  84. package/knowledge-base/matrix-analysis/projection.md +47 -0
  85. package/knowledge-base/matrix-analysis/spectral-decomposition.en.md +48 -0
  86. package/knowledge-base/matrix-analysis/spectral-decomposition.md +48 -0
  87. package/knowledge-base/optimization/constrained-optimization.en.md +53 -0
  88. package/knowledge-base/optimization/constrained-optimization.md +53 -0
  89. package/knowledge-base/optimization/convex-optimization.en.md +50 -0
  90. package/knowledge-base/optimization/convex-optimization.md +50 -0
  91. package/knowledge-base/optimization/lagrangian-duality.en.md +50 -0
  92. package/knowledge-base/optimization/lagrangian-duality.md +50 -0
  93. package/knowledge-base/optimization/proximal-method.en.md +52 -0
  94. package/knowledge-base/optimization/proximal-method.md +52 -0
  95. package/knowledge-base/optimization/riemannian-optimization.en.md +51 -0
  96. package/knowledge-base/optimization/riemannian-optimization.md +51 -0
  97. package/knowledge-base/overview.en.md +29 -218
  98. package/knowledge-base/overview.md +29 -220
  99. package/knowledge-base/probability/concentration-inequality.en.md +45 -0
  100. package/knowledge-base/probability/concentration-inequality.md +45 -0
  101. package/knowledge-base/probability/entropy.en.md +47 -0
  102. package/knowledge-base/probability/entropy.md +47 -0
  103. package/knowledge-base/probability/fisher-information.en.md +48 -0
  104. package/knowledge-base/probability/fisher-information.md +48 -0
  105. package/knowledge-base/probability/information-bottleneck.en.md +49 -0
  106. package/knowledge-base/probability/information-bottleneck.md +49 -0
  107. package/knowledge-base/probability/kl-divergence.en.md +51 -0
  108. package/knowledge-base/probability/kl-divergence.md +51 -0
  109. package/knowledge-base/topology/euler-characteristic.en.md +54 -0
  110. package/knowledge-base/topology/euler-characteristic.md +54 -0
  111. package/knowledge-base/topology/fundamental-group.en.md +52 -0
  112. package/knowledge-base/topology/fundamental-group.md +52 -0
  113. package/knowledge-base/topology/persistent-homology.en.md +54 -0
  114. package/knowledge-base/topology/persistent-homology.md +54 -0
  115. package/lenses/algorithmic.en.md +49 -0
  116. package/lenses/algorithmic.md +49 -0
  117. package/lenses/axiomatization.en.md +48 -0
  118. package/lenses/axiomatization.md +48 -0
  119. package/lenses/categorical.en.md +48 -0
  120. package/lenses/categorical.md +48 -0
  121. package/lenses/causal.en.md +49 -0
  122. package/lenses/causal.md +49 -0
  123. package/lenses/duality.en.md +47 -0
  124. package/lenses/duality.md +47 -0
  125. package/lenses/game.en.md +50 -0
  126. package/lenses/game.md +50 -0
  127. package/lenses/geometric.en.md +53 -0
  128. package/lenses/geometric.md +53 -0
  129. package/lenses/local-to-global.en.md +52 -0
  130. package/lenses/local-to-global.md +52 -0
  131. package/lenses/perturbation.en.md +51 -0
  132. package/lenses/perturbation.md +51 -0
  133. package/lenses/probabilistic.en.md +48 -0
  134. package/lenses/probabilistic.md +48 -0
  135. package/lenses/projection.en.md +50 -0
  136. package/lenses/projection.md +50 -0
  137. package/lenses/spectral.en.md +52 -0
  138. package/lenses/spectral.md +52 -0
  139. package/lenses/symmetry.en.md +49 -0
  140. package/lenses/symmetry.md +49 -0
  141. package/lenses/topological.en.md +48 -0
  142. package/lenses/topological.md +48 -0
  143. package/lenses/variational.en.md +48 -0
  144. package/lenses/variational.md +48 -0
  145. package/package.json +9 -3
  146. package/references/agentic-workflow.en.md +1 -1
  147. package/references/agentic-workflow.md +1 -1
  148. package/references/books/abstract-algebra.en.md +124 -0
  149. package/references/books/abstract-algebra.md +22 -22
  150. package/references/books/algebraic-geometry-rising-sea.en.md +171 -0
  151. package/references/books/algebraic-geometry-rising-sea.md +11 -11
  152. package/references/books/differential-geometry.en.md +140 -0
  153. package/references/books/differential-geometry.md +19 -19
  154. package/references/books/matrix-analysis.en.md +146 -0
  155. package/references/books/matrix-analysis.md +10 -10
  156. package/references/books/micro-lie-theory.en.md +116 -0
  157. package/references/books/micro-lie-theory.md +17 -17
  158. package/references/books/optimization-ml.en.md +163 -0
  159. package/references/books/optimization-ml.md +7 -8
  160. package/references/books/smooth-manifolds.en.md +105 -0
  161. package/references/books/smooth-manifolds.md +14 -14
  162. package/references/gpu-friendly-math.en.md +23 -10
  163. package/references/gpu-friendly-math.md +17 -4
  164. package/references/inspiration.en.md +1 -1
  165. package/references/inspiration.md +2 -2
  166. package/skills/math-research-activator/SKILL.en.md +195 -114
  167. package/skills/math-research-activator/SKILL.md +194 -119
  168. package/skills/math-research-activator/original-texts.en.md +9 -9
  169. package/skills/math-research-activator/original-texts.md +11 -11
  170. package/commands/abstraction.md +0 -11
  171. package/commands/algorithmic-thinking.md +0 -11
  172. package/commands/axiomatization.md +0 -11
  173. package/commands/causal-inference.md +0 -11
  174. package/commands/discrete-combinatorial.md +0 -11
  175. package/commands/game-theory.md +0 -11
  176. package/commands/induction-analogy.md +0 -11
  177. package/commands/information-theory.md +0 -11
  178. package/commands/logic-deduction.md +0 -11
  179. package/commands/modeling.md +0 -11
  180. package/commands/optimization.md +0 -11
  181. package/commands/probability-statistics.md +0 -11
  182. package/commands/symmetry-invariance.md +0 -11
  183. package/commands/topological-thinking.md +0 -11
  184. package/commands/transformation.md +0 -11
  185. package/skills/abstraction/SKILL.en.md +0 -117
  186. package/skills/abstraction/SKILL.md +0 -121
  187. package/skills/abstraction/original-texts.en.md +0 -163
  188. package/skills/abstraction/original-texts.md +0 -175
  189. package/skills/algorithmic-thinking/SKILL.en.md +0 -132
  190. package/skills/algorithmic-thinking/SKILL.md +0 -138
  191. package/skills/algorithmic-thinking/original-texts.en.md +0 -253
  192. package/skills/algorithmic-thinking/original-texts.md +0 -256
  193. package/skills/axiomatization/SKILL.en.md +0 -144
  194. package/skills/axiomatization/SKILL.md +0 -151
  195. package/skills/axiomatization/original-texts.en.md +0 -154
  196. package/skills/axiomatization/original-texts.md +0 -160
  197. package/skills/causal-inference/SKILL.en.md +0 -147
  198. package/skills/causal-inference/SKILL.md +0 -151
  199. package/skills/causal-inference/original-texts.en.md +0 -136
  200. package/skills/causal-inference/original-texts.md +0 -167
  201. package/skills/discrete-combinatorial/SKILL.en.md +0 -124
  202. package/skills/discrete-combinatorial/SKILL.md +0 -131
  203. package/skills/discrete-combinatorial/original-texts.en.md +0 -184
  204. package/skills/discrete-combinatorial/original-texts.md +0 -185
  205. package/skills/game-theory/SKILL.en.md +0 -117
  206. package/skills/game-theory/SKILL.md +0 -123
  207. package/skills/game-theory/original-texts.en.md +0 -131
  208. package/skills/game-theory/original-texts.md +0 -131
  209. package/skills/induction-analogy/SKILL.en.md +0 -145
  210. package/skills/induction-analogy/SKILL.md +0 -152
  211. package/skills/induction-analogy/original-texts.en.md +0 -140
  212. package/skills/induction-analogy/original-texts.md +0 -154
  213. package/skills/information-theory/SKILL.en.md +0 -134
  214. package/skills/information-theory/SKILL.md +0 -140
  215. package/skills/information-theory/original-texts.en.md +0 -127
  216. package/skills/information-theory/original-texts.md +0 -127
  217. package/skills/logic-deduction/SKILL.en.md +0 -130
  218. package/skills/logic-deduction/SKILL.md +0 -135
  219. package/skills/logic-deduction/original-texts.en.md +0 -160
  220. package/skills/logic-deduction/original-texts.md +0 -173
  221. package/skills/modeling/SKILL.en.md +0 -135
  222. package/skills/modeling/SKILL.md +0 -139
  223. package/skills/modeling/original-texts.en.md +0 -162
  224. package/skills/modeling/original-texts.md +0 -165
  225. package/skills/optimization/SKILL.en.md +0 -129
  226. package/skills/optimization/SKILL.md +0 -135
  227. package/skills/optimization/original-texts.en.md +0 -167
  228. package/skills/optimization/original-texts.md +0 -168
  229. package/skills/probability-statistics/SKILL.en.md +0 -146
  230. package/skills/probability-statistics/SKILL.md +0 -151
  231. package/skills/probability-statistics/original-texts.en.md +0 -191
  232. package/skills/probability-statistics/original-texts.md +0 -193
  233. package/skills/symmetry-invariance/SKILL.en.md +0 -135
  234. package/skills/symmetry-invariance/SKILL.md +0 -139
  235. package/skills/symmetry-invariance/original-texts.en.md +0 -206
  236. package/skills/symmetry-invariance/original-texts.md +0 -221
  237. package/skills/topological-thinking/SKILL.en.md +0 -124
  238. package/skills/topological-thinking/SKILL.md +0 -128
  239. package/skills/topological-thinking/original-texts.en.md +0 -134
  240. package/skills/topological-thinking/original-texts.md +0 -164
  241. package/skills/transformation/SKILL.en.md +0 -120
  242. package/skills/transformation/SKILL.md +0 -124
  243. package/skills/transformation/original-texts.en.md +0 -204
  244. package/skills/transformation/original-texts.md +0 -216
@@ -1,253 +0,0 @@
1
- # Algorithmic Thinking -- Original Texts & Historical Context
2
-
3
- ---
4
-
5
- ## 1. Turing Machine (1936)
6
-
7
- Alan Turing's paper **"On Computable Numbers, with an Application to the Entscheidungsproblem"** (1936) defined a precise mathematical model of "computability" -- the Turing machine.
8
-
9
- > "The 'computable' numbers may be described briefly as the real numbers whose expressions as a decimal are calculable by finite means."
10
- > -- Alan Turing, 1936
11
-
12
- **Core definition:**
13
- - A Turing machine $M = (Q, \Sigma, \Gamma, \delta, q_0, q_{\text{accept}}, q_{\text{reject}})$, where $\delta: Q \times \Gamma \to Q \times \Gamma \times \{L, R\}$ is the transition function.
14
- - Universal Turing machine: can simulate the execution of any Turing machine $M$ on input $w$, i.e., $U(\langle M \rangle, w) = M(w)$.
15
-
16
- **Halting problem:**
17
- - The halting problem $H = \{\langle M, w \rangle : M \text{ halts on } w\}$ is undecidable.
18
- - Proof: Suppose $H$ is decidable. Construct $D(\langle M \rangle) = \text{run } H(\langle M, \langle M \rangle \rangle)$; if $M$ halts on $\langle M \rangle$ then $D$ loops forever, otherwise $D$ halts. Applying $D(\langle D \rangle)$ produces a contradiction.
19
-
20
- **Entscheidungsproblem (Decision Problem):**
21
- - Proposed by Hilbert in 1928: Does there exist an algorithm to decide the validity of first-order logic statements?
22
- - Turing and Church independently proved: No such algorithm exists. The validity of first-order logic is undecidable.
23
-
24
- ---
25
-
26
- ## 2. Church-Turing Thesis
27
-
28
- **Thesis (not a theorem):**
29
- > Every "effectively calculable" function is Turing-computable.
30
-
31
- **Equivalent formulations:**
32
- - Church: $\lambda$-definable functions (lambda calculus, 1936)
33
- - Godel-Herbrand-Kleene: general recursive functions
34
- - Post: Post canonical systems
35
- - The sets of functions computable by all these models are identical, supporting the plausibility of the thesis.
36
-
37
- **Strong Church-Turing thesis:**
38
- - Any problem solvable on a physical device in time $T$ can be solved on a Turing machine in time $O(T^k)$ ($k$ a constant).
39
- - That is: all reasonable computational models are equivalent up to polynomial time.
40
- - Quantum computing challenges this -- does there exist a polynomial speedup with $k > 1$?
41
-
42
- ---
43
-
44
- ## 3. Euclid's Algorithm (~300 BC)
45
-
46
- **The oldest algorithm still in use.**
47
-
48
- **GCD computation:**
49
- $$\gcd(a, b) = \gcd(b, a \bmod b), \quad a \bmod b \neq 0$$
50
- $$\gcd(a, 0) = a$$
51
-
52
- **Termination proof:**
53
- - At each step $b' = a \bmod b < b$, so the sequence $b_0 > b_1 > b_2 > \cdots \geq 0$ is strictly decreasing.
54
- - Within finitely many steps $b_k = 0$ and the algorithm terminates.
55
-
56
- **Extended Euclidean algorithm:**
57
- - Computes $\gcd(a, b)$ while simultaneously finding $x, y$ such that $ax + by = \gcd(a, b)$.
58
- - Application: modular inverse $a^{-1} \bmod m$ -- when $\gcd(a, m) = 1$, $ax \equiv 1 \pmod{m}$ and $x = a^{-1}$.
59
-
60
- **Time complexity:**
61
- - Lame's theorem (1844): The number of steps in Euclid's algorithm is at most $5 \times$ the number of decimal digits of the smaller number, i.e., $O(\log \min(a, b))$.
62
-
63
- ---
64
-
65
- ## 4. Knuth -- The Art of Computer Programming (1968-)
66
-
67
- Donald Knuth's multi-volume magnum opus **TAOCP** systematized the field of algorithm analysis.
68
-
69
- > "The process of preparing programs for a digital computer is especially attractive, not only because it can be economically and scientifically rewarding, but also because it can be an aesthetic experience much like composing poetry or music."
70
- > -- Donald Knuth, TAOCP Vol. 1, Preface
71
-
72
- **Contributions:**
73
- - Introduced and popularized big-O notation from number theory into computer science. $O(f(n))$: there exist constants $c, n_0$ such that $T(n) \leq c \cdot f(n)$ for all $n \geq n_0$.
74
- - A systematic taxonomy of algorithms (sorting, searching, arithmetic, combinatorial, etc.).
75
- - MMIX/MIX mixed pseudo-machines for precise models of algorithm analysis.
76
- - Volumes: Vol. 1 (Fundamental Algorithms, 1968), Vol. 2 (Seminumerical Algorithms, 1969), Vol. 3 (Sorting and Searching, 1973), Vol. 4A (Combinatorial Algorithms, 2011).
77
-
78
- ---
79
-
80
- ## 5. Cook-Levin Theorem (1971)
81
-
82
- **NP-completeness:**
83
-
84
- > "The question 'is P = NP?' is one of the most important open questions in theoretical computer science."
85
- > -- Stephen Cook, 1971
86
-
87
- **The Cook-Levin theorem:**
88
- - SAT (the Boolean satisfiability problem) is NP-complete.
89
- - Proof: The accepting computation of a nondeterministic Turing machine $M$ for any NP language $L$ on input $w$ can be encoded as a SAT formula $\varphi_{M,w}$; $w \in L \iff \varphi_{M,w}$ is satisfiable.
90
- - Reduction: $L \leq_p \text{SAT}$ holds for all $L \in \text{NP}$.
91
-
92
- **Karp's 21 NP-complete problems (1972):**
93
- - Richard Karp, in "Reducibility among Combinatorial Problems," proved 21 classic problems to be NP-complete, including:
94
- - 3SAT, CLIQUE, VERTEX-COVER, HAM-CYCLE, TSP, SUBSET-SUM, PARTITION, etc.
95
-
96
- **P vs NP:**
97
- - $\text{P} = \text{NP}$? If true, all NP problems would have polynomial-time algorithms. The prevailing conjecture is $\text{P} \neq \text{NP}$. One of the Clay Mathematics Institute Millennium Prize Problems.
98
-
99
- ---
100
-
101
- ## 6. Divide-and-Conquer
102
-
103
- **Key idea:** Decompose the problem into subproblems, solve recursively, and combine results.
104
-
105
- **Canonical examples:**
106
- - **Merge sort:** $T(n) = 2T(n/2) + O(n) \Rightarrow T(n) = O(n \log n)$. A stable sort.
107
- - **Quicksort:** Average $O(n \log n)$, worst case $O(n^2)$. Hoare (1962).
108
- - **Binary search:** $T(n) = T(n/2) + O(1) \Rightarrow T(n) = O(\log n)$. Requires a sorted array.
109
-
110
- **Master theorem:**
111
- $$T(n) = a\,T(n/b) + f(n)$$
112
- - Case 1: If $f(n) = O(n^{\log_b a - \varepsilon})$, then $T(n) = \Theta(n^{\log_b a})$.
113
- - Case 2: If $f(n) = \Theta(n^{\log_b a} \log^k n)$, then $T(n) = \Theta(n^{\log_b a} \log^{k+1} n)$.
114
- - Case 3: If $f(n) = \Omega(n^{\log_b a + \varepsilon})$ and $af(n/b) \leq cf(n)$, then $T(n) = \Theta(f(n))$.
115
-
116
- ---
117
-
118
- ## 7. Dynamic Programming
119
-
120
- > "I decided to use the word 'dynamic' ... it was something not even a Congressman could object to."
121
- > -- Richard Bellman, on naming "dynamic programming" (1957)
122
-
123
- **Core principles:**
124
- 1. **Optimal substructure:** An optimal solution contains optimal solutions to subproblems.
125
- 2. **Overlapping subproblems:** Different subproblems share smaller sub-subproblems, so naive recursion redundantly recomputes them.
126
-
127
- **Classic algorithms:**
128
- - **Shortest paths:** Dijkstra (1959) -- single-source shortest paths, $O((V+E)\log V)$.
129
- - **Floyd-Warshall (1962):** All-pairs shortest paths, $O(V^3)$. Recurrence: $d_{ij}^{(k)} = \min(d_{ij}^{(k-1)}, d_{ik}^{(k-1)} + d_{kj}^{(k-1)})$.
130
- - **Knapsack problem:** $O(nW)$ pseudo-polynomial time.
131
-
132
- **Bottom-up vs Top-down (memoization):**
133
- - Bottom-up: Fill in a table from the smallest subproblems to the largest.
134
- - Top-down + memoization: Recurse but cache the results of already-solved subproblems.
135
-
136
- ---
137
-
138
- ## 8. Greedy Algorithms
139
-
140
- **Key idea:** At each step, choose the locally optimal option, hoping to reach a globally optimal solution.
141
-
142
- **Classic algorithms:**
143
- - **Kruskal's minimum spanning tree (1956):** Add edges in ascending order of weight, skipping those that form a cycle. $O(E \log E)$. Greedy is optimal for MST problems.
144
- - **Huffman coding (1952):** Repeatedly merge the two nodes with the lowest frequencies. Produces an optimal prefix code.
145
-
146
- **When greedy works:**
147
- - **Matroid structure:** If the set of feasible solutions forms a matroid $(E, \mathcal{I})$ -- satisfying the hereditary property and the exchange property -- then the greedy algorithm yields an optimal solution for any weight function.
148
- - Exchange property: If $A, B \in \mathcal{I}$ and $|A| < |B|$, then there exists $e \in B \setminus A$ such that $A \cup \{e\} \in \mathcal{I}$.
149
-
150
- ---
151
-
152
- ## 9. Backtracking and Search
153
-
154
- **Depth-First Search (DFS) / Breadth-First Search (BFS):**
155
- - DFS: Uses a stack (or recursion), explores as deep as possible first; used for topological sorting and connected components.
156
- - BFS: Uses a queue, expands level by level; used for shortest paths in unweighted graphs.
157
-
158
- **Backtracking:**
159
- - Systematically enumerates candidate solutions, retreating as soon as a constraint is violated.
160
- - Examples: N-Queens problem, subset enumeration, permutation enumeration.
161
-
162
- **Pruning and branch-and-bound:**
163
- - Pruning: Uses constraints to eliminate impossible branches early, reducing the search space.
164
- - Branch-and-bound: For optimization problems, maintains a bound on the current best solution and prunes branches that cannot improve it. Commonly used for TSP and integer programming.
165
-
166
- **Constraint Satisfaction Problems (CSP):**
167
- - A set of variables + domains + constraints. Backtracking search + constraint propagation (AC-3, etc.).
168
-
169
- ---
170
-
171
- ## 10. Randomized Algorithms
172
-
173
- **Two types:**
174
- - **Las Vegas algorithms:** Always produce correct results; running time is random. Example: randomized quicksort.
175
- - **Monte Carlo algorithms:** Running time is deterministic; result may be incorrect (but error probability can be made arbitrarily small). Example: Miller-Rabin primality test.
176
-
177
- **Miller-Rabin primality test (1976/1980):**
178
- - For an odd number $n$, choose a random $a \in \{2, \ldots, n-1\}$ and check whether the sequence $a^{d} \bmod n$ satisfies the strengthened conditions of Fermat's little theorem.
179
- - Error probability per test $\leq 1/4$; after $k$ independent tests, error probability $\leq 4^{-k}$.
180
- - Time complexity $O(k \log^3 n)$.
181
-
182
- **Randomized quicksort:**
183
- - Randomly select a pivot; expected number of comparisons $2n \ln n \approx 1.39 n \log_2 n$; expected running time $O(n \log n)$.
184
- - The probability of the worst case $O(n^2)$ can be shown to be extremely low.
185
-
186
- ---
187
-
188
- ## 11. Decidability and Undecidability
189
-
190
- **The halting problem is undecidable (see Section 1).**
191
-
192
- **Rice's theorem (1953):**
193
- > Every non-trivial semantic property of Turing machines is undecidable.
194
-
195
- - "Semantic property": depends only on the function computed by $M$, not on the structure of $M$.
196
- - "Non-trivial": holds for some Turing machines but not for others.
197
- - Examples: "Does $M$ compute a constant function?", "Does $M$ halt on some input?", "Does $M$ compute a decidable language?" -- all undecidable.
198
-
199
- **Post Correspondence Problem (PCP, 1946):**
200
- - Given a set of dominos $\{(t_1, b_1), \ldots, (t_k, b_k)\}$ (where $t_i, b_i$ are strings), does there exist a sequence $i_1, i_2, \ldots, i_m$ such that $t_{i_1} t_{i_2} \cdots t_{i_m} = b_{i_1} b_{i_2} \cdots b_{i_m}$?
201
- - PCP is undecidable. Commonly used to prove the undecidability of other problems.
202
-
203
- ---
204
-
205
- ## 12. Complexity Classes
206
-
207
- | Class | Definition | Description |
208
- |-------|-----------|-------------|
209
- | **P** | $\{L : L \text{ is decidable in } O(n^k) \text{ time}\}$ | Decidable in polynomial time |
210
- | **NP** | $\{L : L \text{ has a polynomial-length certificate}\}$ | Decidable in nondeterministic polynomial time |
211
- | **co-NP** | $\{L : \bar{L} \in \text{NP}\}$ | Complement of NP |
212
- | **EXP** | $\{L : L \text{ is decidable in } O(2^{n^k}) \text{ time}\}$ | Decidable in exponential time |
213
- | **R** | $\{L : L \text{ is decidable}\}$ | Recursive / decidable languages |
214
- | **RE** | $\{L : L \text{ is recognizable by a Turing machine}\}$ | Recursively enumerable languages |
215
-
216
- **Hierarchies:**
217
- $$\text{P} \subseteq \text{NP} \subseteq \text{PSPACE} \subseteq \text{EXP} \subseteq \text{R} \subseteq \text{RE}$$
218
- $$\text{P} \neq \text{EXP} \quad (\text{time hierarchy theorem, Hartmanis-Stearns 1965})$$
219
- $$\text{R} \neq \text{RE} \quad (\text{halting problem} \in \text{RE} \setminus \text{R})$$
220
-
221
- ---
222
-
223
- ## 13. Sorting Lower Bound
224
-
225
- **Lower bound for comparison-based sorting:**
226
-
227
- $$T(n) \geq \Omega(n \log n)$$
228
-
229
- **Information-theoretic argument:**
230
- - The number of permutations of $n$ elements $= n!$; each comparison halves the search space at most.
231
- - The decision tree height $h$ must satisfy $2^h \geq n!$, so $h \geq \log_2(n!) = \Omega(n \log n)$.
232
- - By Stirling's formula: $\log_2(n!) \approx n \log_2 n - n \log_2 e + O(\log n)$.
233
-
234
- **Breaking the bound:**
235
- - Non-comparison sorts can surpass $\Omega(n \log n)$: counting sort $O(n+k)$, radix sort $O(d(n+k))$ -- but require special structure in the input.
236
-
237
- ---
238
-
239
- ## 14. Algorithm Design Paradigms -- Summary Table
240
-
241
- | Paradigm | Key Idea | When to Use | Canonical Example |
242
- |----------|---------|-------------|-------------------|
243
- | Divide-and-Conquer | Decompose -> recurse -> combine | Problem naturally decomposes into independent subproblems | Merge sort, Binary search |
244
- | Dynamic Programming | Overlapping subproblems + optimal substructure; fill a table to avoid recomputation | Severe subproblem overlap with optimal substructure | Floyd-Warshall, Knapsack |
245
- | Greedy | Choose locally optimal at each step | Matroid structure or provable greedy correctness | Kruskal MST, Huffman coding |
246
- | Backtracking | Systematic search + pruning | Search space is finite but large | N-Queens, CSP |
247
- | Branch-and-Bound | Search + maintain upper/lower bounds for pruning | Optimization problems where bounds on solutions can be computed | TSP (exact), Integer programming |
248
- | Randomized | Introduce randomness to reduce expected cost or error probability | Probabilistic guarantees or expected efficiency needed | Miller-Rabin, Randomized quicksort |
249
- | Reduction | Transform a problem into a known problem | An efficient algorithm already exists for the target problem | SAT -> 3SAT (Cook-Levin) |
250
-
251
- ---
252
-
253
- *This file provides mathematical references and historical context for the algorithmic-thinking skill, covering core results from ancient Greece to modern computational theory.*
@@ -1,256 +0,0 @@
1
- # 算法思维 — 原始文献与历史语境 / Algorithmic Thinking — Original Texts & Historical Context
2
-
3
- ---
4
-
5
- ## 1. Turing Machine (1936) / 图灵机 (1936)
6
-
7
- Alan Turing 的论文 **"On Computable Numbers, with an Application to the Entscheidungsproblem"** (1936) 定义了"可计算性"的精确数学模型——图灵机 (Turing machine)。
8
-
9
- > "The 'computable' numbers may be described briefly as the real numbers whose expressions as a decimal are calculable by finite means."
10
- > — Alan Turing, 1936
11
-
12
- **核心定义 / Core definition:**
13
- - 图灵机 $M = (Q, \Sigma, \Gamma, \delta, q_0, q_{\text{accept}}, q_{\text{reject}})$,其中 $\delta: Q \times \Gamma \to Q \times \Gamma \times \{L, R\}$ 为转移函数。
14
- - 通用图灵机 (universal Turing machine): 可模拟任意图灵机 $M$ 在输入 $w$ 上的执行,即 $U(\langle M \rangle, w) = M(w)$。
15
-
16
- **停机问题 / Halting problem:**
17
- - 停机问题 $H = \{\langle M, w \rangle : M \text{ halts on } w\}$ 是不可判定的 (undecidable)。
18
- - 证明:假设 $H$ 可判定,则构造 $D(\langle M \rangle) = \text{run } H(\langle M, \langle M \rangle \rangle)$;若 $M$ 在 $\langle M \rangle$ 上停机则 $D$ 永不停机,反之 $D$ 停机。令 $D(\langle D \rangle)$ 产生矛盾。
19
-
20
- **Entscheidungsproblem (判定问题):**
21
- - Hilbert 1928 年提出:是否存在算法判定一阶逻辑语句的有效性?
22
- - Turing 与 Church 分别独立证明:不存在。一阶逻辑的有效性是不可判定的。
23
-
24
- ---
25
-
26
- ## 2. Church-Turing Thesis / Church-Turing 论题
27
-
28
- **论题 (thesis, not theorem):**
29
- > 任何"可有效计算"的函数都是图灵可计算的。
30
- > Every "effectively calculable" function is Turing-computable.
31
-
32
- **等价表述 / Equivalent formulations:**
33
- - Church: $\lambda$-可定义函数 (lambda calculus, 1936)
34
- - Gödel–Herbrand–Kleene: 一般递归函数 (general recursive functions)
35
- - Post: Post 系统 (Post canonical systems)
36
- - 以上模型计算的函数集完全相同,佐证论题的合理性。
37
-
38
- **强 Church-Turing 论题 / Strong Church-Turing thesis:**
39
- - 任何可在物理设备上于时间 $T$ 内求解的问题,均可在图灵机上于时间 $O(T^k)$($k$ 为常数)内求解。
40
- - 即:所有合理的计算模型在多项式时间内等价。
41
- - 量子计算对此提出挑战——是否存在 $k > 1$ 的多项式加速?
42
-
43
- ---
44
-
45
- ## 3. Euclid's Algorithm (~300 BC) / 欧几里得算法 (约公元前300年)
46
-
47
- **最古老且仍在使用的算法 / The oldest algorithm still in use.**
48
-
49
- **GCD 计算 / GCD computation:**
50
- $$\gcd(a, b) = \gcd(b, a \bmod b), \quad a \bmod b \neq 0$$
51
- $$\gcd(a, 0) = a$$
52
-
53
- **终止性证明 / Termination proof:**
54
- - 每一步 $b' = a \bmod b < b$,故序列 $b_0 > b_1 > b_2 > \cdots \geq 0$ 严格递减。
55
- - 有限步内必有 $b_k = 0$,算法终止。
56
-
57
- **扩展欧几里得算法 / Extended Euclidean algorithm:**
58
- - 计算 $\gcd(a, b)$ 同时求出 $x, y$ 使得 $ax + by = \gcd(a, b)$。
59
- - 应用:模逆元 $a^{-1} \bmod m$——当 $\gcd(a, m) = 1$ 时,$ax \equiv 1 \pmod{m}$,$x = a^{-1}$。
60
-
61
- **时间复杂度:**
62
- - Lamé 定理 (1844): 欧几里得算法的步数 $\leq 5 \times$ 较小数的十进制位数,即 $O(\log \min(a, b))$。
63
-
64
- ---
65
-
66
- ## 4. Knuth — The Art of Computer Programming (1968–) / Knuth — 计算机程序设计艺术 (1968–)
67
-
68
- Donald Knuth 的多卷巨著 **TAOCP** 系统化了算法分析学科。
69
-
70
- > "The process of preparing programs for a digital computer is especially attractive, not only because it can be economically and scientifically rewarding, but also because it can be an aesthetic experience much like composing poetry or music."
71
- > — Donald Knuth, TAOCP Vol. 1, Preface
72
-
73
- **贡献 / Contributions:**
74
- - 将 big-O 记号从数论引入计算机科学并普及。$O(f(n))$: 存在常数 $c, n_0$ 使得 $T(n) \leq c \cdot f(n)$ 对所有 $n \geq n_0$。
75
- - 系统化的算法分类体系 (sorting, searching, arithmetic, combinatorial 等)。
76
- - MMIX / MIX 混合伪机器用于算法分析的精确模型。
77
- - 卷目: Vol. 1 (Fundamental Algorithms, 1968), Vol. 2 (Seminumerical Algorithms, 1969), Vol. 3 (Sorting and Searching, 1973), Vol. 4A (Combinatorial Algorithms, 2011).
78
-
79
- ---
80
-
81
- ## 5. Cook-Levin Theorem (1971) / Cook-Levin 定理 (1971)
82
-
83
- **NP-完全性 / NP-completeness:**
84
-
85
- > "The question 'is P = NP?' is one of the most important open questions in theoretical computer science."
86
- > — Stephen Cook, 1971
87
-
88
- **Cook-Levin 定理:**
89
- - SAT (布尔可满足性问题) 是 NP-完全的 (NP-complete)。
90
- - 证明:任意 NP 语言 $L$ 的非确定图灵机 $M$ 在 $w$ 上的接受计算可编码为 SAT 公式 $\varphi_{M,w}$;$w \in L \iff \varphi_{M,w}$ 可满足。
91
- - 规约: $L \leq_p \text{SAT}$ 对所有 $L \in \text{NP}$ 成立。
92
-
93
- **Karp 的 21 个 NP-完全问题 (1972):**
94
- - Richard Karp 在 "Reducibility among Combinatorial Problems" 中证明 21 个经典问题均为 NP-完全,包括:
95
- - 3SAT, CLIQUE, VERTEX-COVER, HAM-CYCLE, TSP, SUBSET-SUM, PARTITION 等。
96
-
97
- **P vs NP:**
98
- - $\text{P} = \text{NP}$?若成立,则所有 NP 问题均有多项式时间算法。普遍猜测 $\text{P} \neq \text{NP}$。Clay 数学研究所千禧年大奖问题之一。
99
-
100
- ---
101
-
102
- ## 6. Divide-and-Conquer / 分治法
103
-
104
- **思想 / Key idea:** 将问题分解为若干子问题,递归求解,合并结果。
105
-
106
- **经典算法 / Canonical examples:**
107
- - **合并排序 (Merge sort):** $T(n) = 2T(n/2) + O(n) \Rightarrow T(n) = O(n \log n)$。稳定排序。
108
- - **快速排序 (Quicksort):** 平均 $O(n \log n)$,最坏 $O(n^2)$。Hoare (1962)。
109
- - **二分查找 (Binary search):** $T(n) = T(n/2) + O(1) \Rightarrow T(n) = O(\log n)$。有序数组前提。
110
-
111
- **主定理 / Master theorem:**
112
- $$T(n) = a\,T(n/b) + f(n)$$
113
- - 情形1: 若 $f(n) = O(n^{\log_b a - \varepsilon})$,则 $T(n) = \Theta(n^{\log_b a})$。
114
- - 情形2: 若 $f(n) = \Theta(n^{\log_b a} \log^k n)$,则 $T(n) = \Theta(n^{\log_b a} \log^{k+1} n)$。
115
- - 情形3: 若 $f(n) = \Omega(n^{\log_b a + \varepsilon})$ 且 $af(n/b) \leq cf(n)$,则 $T(n) = \Theta(f(n))$。
116
-
117
- ---
118
-
119
- ## 7. Dynamic Programming / 动态规划
120
-
121
- > "I decided to use the word 'dynamic' … it was something not even a Congressman could object to."
122
- > — Richard Bellman, on naming "dynamic programming" (1957)
123
-
124
- **核心要素 / Core principles:**
125
- 1. **最优子结构 (optimal substructure):** 最优解包含子问题的最优解。
126
- 2. **重叠子问题 (overlapping subproblems):** 不同子问题共享更小的子问题,递归会重复计算。
127
-
128
- **经典算法:**
129
- - **最短路径:** Dijkstra (1959)——单源最短路径,$O((V+E)\log V)$。
130
- - **Floyd-Warshall (1962):** 所有顶点对最短路径,$O(V^3)$。递推 $d_{ij}^{(k)} = \min(d_{ij}^{(k-1)}, d_{ik}^{(k-1)} + d_{kj}^{(k-1)})$。
131
- - **背包问题 (knapsack):** $O(nW)$ 伪多项式时间。
132
-
133
- **自底向上 vs 自顶向下 / Bottom-up vs Top-down (memoization):**
134
- - 自底向上:按子问题规模从小到大填表。
135
- - 自顶向下 + 记忆化 (memoization):递归但缓存已解子问题的结果。
136
-
137
- ---
138
-
139
- ## 8. Greedy Algorithms / 贪心算法
140
-
141
- **思想 / Key idea:** 每一步选择局部最优,期望达到全局最优。
142
-
143
- **经典算法:**
144
- - **Kruskal 最小生成树 (1956):** 按边权升序加入不形成环的边。$O(E \log E)$。贪心在 MST 问题中有效。
145
- - **Huffman 编码 (1952):** 每次合并频率最低的两个节点。最优前缀编码。
146
-
147
- **贪心何时有效 / When greedy works:**
148
- - **拟阵 (matroid) 结构:** 若问题的可行解集构成拟阵 $(E, \mathcal{I})$——即满足遗传性 (hereditary) 与交换性 (exchange property)——则贪心算法对任何权函数均给出最优解。
149
- - 交换性: 若 $A, B \in \mathcal{I}$,$|A| < |B|$,则存在 $e \in B \setminus A$ 使得 $A \cup \{e\} \in \mathcal{I}$。
150
-
151
- ---
152
-
153
- ## 9. Backtracking and Search / 回溯与搜索
154
-
155
- **深度优先搜索 (DFS) / 广度优先搜索 (BFS):**
156
- - DFS: 用栈(或递归),优先深入;用于拓扑排序、连通分量。
157
- - BFS: 用队列,优先扩展;用于最短路径(无权图)。
158
-
159
- **回溯 (backtracking):**
160
- - 系统地枚举候选解,发现不满足约束即回退。
161
- - 例: N-皇后问题、子集枚举、排列枚举。
162
-
163
- **剪枝与分支限界 / Pruning and branch-and-bound:**
164
- - 剪枝 (pruning): 利用约束提前排除不可能的分支,减少搜索空间。
165
- - 分支限界 (branch-and-bound): 对优化问题,维护当前最优解的界,剪去不可能更优的分支。常用于 TSP、整数规划。
166
-
167
- **约束满足问题 (CSP) / Constraint satisfaction:**
168
- - 变量集 + 值域 + 约束集。回溯搜索 + 约束传播 (AC-3 等)。
169
-
170
- ---
171
-
172
- ## 10. Randomized Algorithms / 随机化算法
173
-
174
- **两类 / Two types:**
175
- - **Las Vegas 算法:** 结果始终正确,运行时间随机。例:随机化 quicksort。
176
- - **Monte Carlo 算法:** 运行时间确定,结果可能错误(但错误概率可控制在任意小)。例:Miller-Rabin 素性测试。
177
-
178
- **Miller-Rabin 素性测试 (1976/1980):**
179
- - 对奇数 $n$,选取随机 $a \in \{2, \ldots, n-1\}$,检验 $a^{d} \bmod n$ 的序列是否满足 Fermat 小定理的强化条件。
180
- - 单次测试的错误概率 $\leq 1/4$;$k$ 次独立测试后错误概率 $\leq 4^{-k}$。
181
- - 时间 $O(k \log^3 n)$。
182
-
183
- **随机化快速排序 / Randomized quicksort:**
184
- - 随机选取 pivot,期望比较次数 $2n \ln n \approx 1.39 n \log_2 n$,期望运行时间 $O(n \log n)$。
185
- - 最坏 $O(n^2)$ 的概率可证明极低。
186
-
187
- ---
188
-
189
- ## 11. Decidability and Undecidability / 可判定性与不可判定性
190
-
191
- **停机问题不可判定 / Halting problem is undecidable (see §1).**
192
-
193
- **Rice 定理 (1953):**
194
- > 关于图灵机的任何非平凡语义性质都是不可判定的。
195
- > Every non-trivial semantic property of Turing machines is undecidable.
196
-
197
- - "语义性质": 仅取决于 $M$ 计算的函数,不取决于 $M$ 的结构。
198
- - "非平凡": 对某些图灵机成立,对某些不成立。
199
- - 例:"M 是否计算常数函数""M 是否在某输入上停机""M 是否计算可判定语言"——均不可判定。
200
-
201
- **Post 对应问题 / Post correspondence problem (PCP, 1946):**
202
- - 给定 domino 集合 $\{(t_1, b_1), \ldots, (t_k, b_k)\}$($t_i, b_i$ 为字符串),是否存在序列 $i_1, i_2, \ldots, i_m$ 使得 $t_{i_1} t_{i_2} \cdots t_{i_m} = b_{i_1} b_{i_2} \cdots b_{i_m}$?
203
- - PCP 是不可判定的。常用于证明其他问题的不可判定性。
204
-
205
- ---
206
-
207
- ## 12. Complexity Classes / 复杂度类
208
-
209
- | 类 / Class | 定义 / Definition | 中文说明 |
210
- |---|---|---|
211
- | **P** | $\{L : L \text{ 可在 } O(n^k) \text{ 时间内判定}\}$ | 多项式时间可判定 |
212
- | **NP** | $\{L : L \text{ 有多项式长度的验证证书}\}$ | 非确定多项式时间可判定 |
213
- | **co-NP** | $\{L : \bar{L} \in \text{NP}\}$ | NP 的补类 |
214
- | **EXP** | $\{L : L \text{ 可在 } O(2^{n^k}) \text{ 时间内判定}\}$ | 指数时间可判定 |
215
- | **R** | $\{L : L \text{ 是可判定的}\}$ | 递归语言 / 可判定语言 |
216
- | **RE** | $\{L : L \text{ 可被图灵机识别}\}$ | 递归可枚举语言 |
217
-
218
- **层次关系 / Hierarchies:**
219
- $$\text{P} \subseteq \text{NP} \subseteq \text{PSPACE} \subseteq \text{EXP} \subseteq \text{R} \subseteq \text{RE}$$
220
- $$\text{P} \neq \text{EXP} \quad (\text{time hierarchy theorem, Hartmanis–Stearns 1965})$$
221
- $$\text{R} \neq \text{RE} \quad (\text{halting problem} \in \text{RE} \setminus \text{R})$$
222
-
223
- ---
224
-
225
- ## 13. Sorting Lower Bound / 排序下界
226
-
227
- **比较排序的下界 / Lower bound for comparison-based sorting:**
228
-
229
- $$T(n) \geq \Omega(n \log n)$$
230
-
231
- **信息论论证 / Information-theoretic argument:**
232
- - $n$ 个元素的排列数 $= n!$,每次比较至多将搜索空间减半。
233
- - 决策树高度 $h$ 须满足 $2^h \geq n!$,故 $h \geq \log_2(n!) = \Omega(n \log n)$。
234
- - 由 Stirling 公式: $\log_2(n!) \approx n \log_2 n - n \log_2 e + O(\log n)$。
235
-
236
- **突破下界的方法 / Breaking the bound:**
237
- - 非比较排序可超越 $\Omega(n \log n)$:计数排序 $O(n+k)$,基数排序 $O(d(n+k))$——但要求输入有特殊结构。
238
-
239
- ---
240
-
241
- ## 14. Algorithm Design Paradigms — Summary Table / 算法设计范式总结表
242
-
243
- | 范式 / Paradigm | 核心思想 / Key Idea | 适用条件 / When to Use | 典型例子 / Canonical Example |
244
- |---|---|---|---|
245
- | 分治 / Divide-and-Conquer | 分解→递归→合并 | 问题可自然分为独立子问题 | Merge sort, Binary search |
246
- | 动态规划 / Dynamic Programming | 子问题重叠+最优子结构,填表避免重复 | 子问题重叠严重,有最优子结构 | Floyd-Warshall, Knapsack |
247
- | 贪心 / Greedy | 每步取局部最优 | 拟阵结构或可证贪心正确性 | Kruskal MST, Huffman coding |
248
- | 回溯 / Backtracking | 系统搜索+剪枝 | 搜索空间有限但巨大 | N-Queens, CSP |
249
- | 分支限界 / Branch-and-Bound | 搜索+维护上下界剪枝 | 优化问题,可计算解的界 | TSP (exact), Integer programming |
250
- | 随机化 / Randomized | 引入随机性降低期望代价或错误概率 | 需要概率保证或期望高效 | Miller-Rabin, Randomized quicksort |
251
- | 归约/规约 / Reduction | 将问题变换为已知问题 | 已有高效算法求解目标问题 | SAT → 3SAT (Cook-Levin) |
252
-
253
- ---
254
-
255
- *本文件为算法思维技能的数学参考与历史语境,涵盖从古希腊到现代计算理论的核心成果。*
256
- *This file provides mathematical references and historical context for the algorithmic-thinking skill, covering core results from ancient Greece to modern computational theory.*
@@ -1,144 +0,0 @@
1
- ---
2
- name: axiomatization
3
- description: |
4
- Trigger when examining the reasonableness of a theory's assumptions, constructing an axiom system, discovering internal contradictions, verifying consistency/independence/completeness; or defining axioms and invariants for an algorithm/operator/structure and checking their computability.
5
- ---
6
-
7
- # 📐 Axiomatization
8
-
9
- > "Starting from minimal assumptions, building through rigorous logic — examining premises matters more than checking conclusions"
10
- >
11
- > — Euclid's *Elements*, Hilbert's *Foundations of Geometry*, Axiomatic Set Theory
12
-
13
- ## Core Principle
14
-
15
- **Any theoretical system can (and should) be reduced to a set of fundamental axioms, from which all theorems in that domain can be derived through rigorous logical inference. Examining premises matters more than checking conclusions — if premises are wrong, no amount of elegant reasoning can save the conclusion.**
16
-
17
- > **Mathematical Formalization**
18
- >
19
- > The quality of an axiom system is judged by the following core criteria:
20
- >
21
- > - **Consistency**: The axioms must not contradict one another. If the axiom set is contradictory, then by the principle of explosion (*ex falso quodlibet*) any proposition can be derived, and the system collapses.
22
- > - **Independence**: No axiom should be derivable from the others.
23
- > - **Completeness**: All true propositions in the domain should be provable from the axioms (note: completeness varies with the order of the logical system; see Method).
24
- >
25
- > **Categoricity**: An axiom system is categorical if all its models are isomorphic to one another. A categorical system uniquely determines the structure of its subject — for example, the second-order Peano axioms are categorical (the unique model is the natural number structure ℕ), whereas the first-order Peano axioms are not (non-standard models exist).
26
- >
27
- > **Relative Consistency**: If all axioms of system A can be embedded as true propositions in system B, and system B is known to be consistent, then system A is consistent. This is the standard method for proving consistency — for example, the consistency of PA can be proved within ZFC (the axioms of PA are all true in ZFC), but the consistency of ZFC itself can only be relatively proved in a stronger system (e.g., ZFC + the existence of an inaccessible cardinal).
28
- >
29
- > See `original-texts.md` for detailed mathematical foundations.
30
-
31
- ## GPU-Friendliness (Cross-Cutting Check)
32
-
33
- When axiomatization is used to **define axioms and invariants for an algorithm/operator/structure**, the defined structures must pass the eight-dimension gate of `../../references/gpu-friendly-math.md` — "axiomatically self-consistent" does not mean "computable":
34
-
35
- - **Friendly**: The axiom system naturally reduces to linear algebra — group action axioms → equivariant layers = GEMM (weight sharing along orbits); ring axioms relaxed to semirings → generalized GEMM (min-plus / tropical). Passes dimensions 1/2/3.
36
- - **Adaptable**: Essentially discrete/symbolic axioms (hard Top-K, exact finite-field arithmetic, symbolic proof search) block gradients → relax the axioms: tropical semiring piecewise-linear gating, Gumbel-softmax, differentiable surrogates.
37
- - **Anti-pattern**: Invariants requiring global symbolic reasoning or exact discrete satisfaction (e.g., exact Čech cohomology, exact orbit-equality testing) → "beautiful but not computable"; switch to local/continuous approximations.
38
-
39
- Eight-dimension minimum assessment (formal terminology): **Tensorization** — whether axiom instances can be batch-checked; **GEMM-Mappability** — whether operational axioms can reduce to linear/semiring matrix multiplication; **Complexity** — whether consistency/independence checking degenerates to undecidable or exponential search; **Memory & KV-Cache** — whether invariants require a global state table; **Low-Precision Stability** — whether axioms tolerate approximate equalities; **Parallelism & Communication** — whether local axioms can be verified in blocks; **Sparsity Structure** — whether the constraint graph is structured; **Operator Fusion** — whether axiom checks can be compiled into lightweight loss/guard kernels.
40
-
41
- > In conjunction with `../../references/books/abstract-algebra.md` (group/ring/field axioms, ring→semiring relaxation) and `../../references/books/algebraic-geometry-rising-sea.md` (sheaf/category/cohomology axioms).
42
-
43
- ## When NOT to Use
44
-
45
- - **Pure factual queries** (e.g., "what is this formula") — no theoretical system needs examination.
46
- - **The user has already accepted a theoretical framework and only needs to apply it** — the axioms are already chosen.
47
- - **Empirical questions** (requiring experimental data rather than logical reasoning) — axiomatization cannot substitute for empirical evidence.
48
- - **Defaulting to classical tools in a constructive context** — if the user requires constructive proofs, the law of excluded middle or the axiom of choice should not be assumed by default.
49
-
50
- ## When to Use
51
-
52
- - When reading a paper, examining whether its theoretical assumptions are reasonable and self-consistent.
53
- - When building a theoretical framework, starting from the minimal axiom set.
54
- - When discovering contradictions or inconsistencies within a theoretical system.
55
- - When determining whether a formal system is decidable or complete.
56
- - When comparing the consequences of different axiom choices (constructive vs. classical, first-order vs. second-order).
57
- - **Defining axioms and invariants for an operator/structure** and checking their computability on GPU.
58
-
59
- ## Method
60
-
61
- ### Step 1: Identify the Axioms
62
- Find all fundamental assumptions (axioms) of the theoretical system, distinguishing: **explicit axioms** (clearly stated by the author), **implicit axioms** (unstated but actually used in the argument), **background axioms** (default assumptions of the larger framework, e.g., defaulting to ZFC).
63
-
64
- > "Every science truly matures only after it has been axiomatized." — Hilbert
65
-
66
- ### Step 2: Specify the Formal Language
67
- The expressive power of an axiom system depends on the chosen formal language; before axiomatizing, one must specify:
68
-
69
- - **First-order Logic**: Quantifiers range only over individual elements. Expressive power is limited, but it admits a complete proof theory (Gödel's Completeness Theorem: the provable coincides with the valid). Models of a first-order theory are not unique (non-categoricity), but the proof system is sound and complete.
70
- - **Second-order Logic**: Quantifiers may range over subsets and functions. Greater expressive power (can express categoricity, e.g., second-order Peano uniquely characterizes ℕ), but no complete proof system exists — its semantics cannot be fully captured by any recursive axiom set.
71
- - **Constructive / Intuitionistic Logic**: Rejects the law of excluded middle (∀P, P∨¬P). Existential proofs must provide an explicit witness: proving ∃x.φ(x) requires constructing a specific x₀ such that φ(x₀) holds. Inference rules are stricter, but all proofs are guaranteed to be computable.
72
-
73
- > Choosing a language is not merely a technical detail but a fundamental philosophical decision: first-order logic commits to an exhaustible proof system, second-order logic commits to structural uniqueness, constructive logic commits to computability.
74
-
75
- ### Step 3: Check Consistency
76
- Check whether the axioms contradict one another. If the axiom set is contradictory, then by the principle of explosion any proposition can be derived, and the system collapses. Methods:
77
-
78
- - Look for two axioms P and ¬P that hold simultaneously.
79
- - Attempt to construct a model in which all axioms are simultaneously true (model existence ⇒ consistency).
80
- - **Relative consistency proof**: Embed the axioms of system A as true propositions in system B; if B is known consistent, then A is consistent. For example, PA is consistent (the PA axioms are all true in the von Neumann natural number model within ZFC).
81
- - **Finite model method**: For weaker formal systems (propositional logic, certain finitely axiomatized weak arithmetics), construct a finite model to directly verify consistency.
82
-
83
- ### Step 4: Check Independence
84
- Check whether any axiom can be derived from the others. If so, it is not a true axiom but a theorem. Methods:
85
-
86
- - For each axiom A, construct a model in which A fails but all other axioms hold.
87
- - If such a model exists, then A is independent of the other axioms.
88
- - Classical examples: the parallel postulate is independent of the remaining axioms of Euclidean geometry (non-Euclidean geometry models); the Axiom of Choice is independent of ZF (Cohen's forcing method).
89
-
90
- ### Step 5: Assess Completeness
91
- Check whether the axiom system is strong enough to derive all important results in the domain. Completeness properties vary with the logical order and the content of the theory:
92
-
93
- - **First-order theories can be complete**: Dense Linear Order (DLO), Algebraically Closed Fields of fixed characteristic (ACF_p), and other first-order theories are complete and decidable. Completeness ≠ absence of open problems; completeness means that for every sentence φ, either φ or ¬φ is provable from the axioms.
94
- - **Scope of Gödel's Incompleteness Theorems**: Incompleteness specifically applies to first-order recursively enumerable theories containing sufficient arithmetic (PA, ZFC, etc.), in which there necessarily exist undecidable propositions (e.g., the Gödel sentence in PA, CH in ZFC).
95
- - **Decidability is an independent question**: A complete first-order theory is typically decidable (there exists an algorithm to determine whether any formula is a theorem), but an incomplete theory is not necessarily undecidable — decidability depends on whether an algorithm for deciding theorems exists, not on whether all propositions have proofs.
96
-
97
- ### Step 6: Analyze the Impact of Axiom Choice
98
- What happens to the theory if an axiom is changed or relaxed? Many branches of mathematics developed precisely through altering axioms:
99
-
100
- - Changing the parallel postulate → non-Euclidean geometries (hyperbolic geometry, elliptic geometry).
101
- - **Constructive vs. Classical**: Removing the law of excluded middle → constructive mathematics (Brouwer, Heyting), where existence proofs must provide explicit constructions; adding the Axiom of Choice → stronger classical mathematics, but yielding non-constructive proofs (e.g., the Banach-Tarski paradox).
102
- - **Zorn's Lemma, the Well-Ordering Theorem, and the Axiom of Choice**: These three are equivalent within ZF — accepting any one means accepting all; this equivalence itself is non-constructive.
103
- - Changing the induction axiom → non-standard analysis.
104
-
105
- ### Step 7: Apply and Conclude
106
- Synthesize the above analysis and give an overall assessment of the axiom system: Is it suitable for its intended domain of application? Are there axioms that need to be supplemented or revised? What are the limitations of the system (undecidable propositions, non-categoricity, lack of constructivity, etc.)?
107
-
108
- ## Common Errors
109
-
110
- | Error | Critique | Correct Approach |
111
- |---|---|---|
112
- | Confusing axioms with theorems | Treating a proposition that needs proof as a self-evident axiom | Clearly distinguish: axioms are the starting point, theorems are the endpoint |
113
- | Overlooking implicit assumptions | Using unstated assumptions in the argument, making the reasoning imprecise | Scrutinize every step of reasoning, exposing all hidden assumptions |
114
- | Accepting a contradictory axiom set | From contradictory axioms, any conclusion can be derived (principle of explosion) | Verify the consistency of the axiom set |
115
- | Treating axioms as truths | Axioms are merely conventions about starting points, not absolute truths | The value of axioms lies in the usefulness of their consequences |
116
- | Ignoring the possibility of axiom change | Assuming axioms are the only possible choice | Consider what new theories arise from changing axioms |
117
- | Confusing first-order and second-order completeness | First-order logic has a complete proof system (Gödel completeness); second-order does not; "completeness" has different meanings in each | Distinguish proof-theoretic completeness from model-theoretic completeness; specify the logical order |
118
- | Neglecting constructive obligations | Using the law of excluded middle in a constructive context, or proving only ¬¬∃x.φ(x) without providing a witness | Constructive proofs of ∃x.φ(x) must provide an explicit witness x₀; the law of excluded middle is prohibited in constructive contexts |
119
- | Assuming all incomplete theories are equally incomplete | Different incomplete theories vary enormously in the number and nature of their undecidable propositions | Analyze the specific theory: which propositions are undecidable, and what are their structural properties |
120
- | Forcing discrete/symbolic axioms into training | Essentially discrete/symbolic axiom systems are non-differentiable and non-computable | Pass the eight-dimension gate; relax to differentiable/approximate forms when necessary (tropical semiring, Gumbel-softmax) |
121
-
122
- ## Operating Procedure
123
-
124
- When this skill is triggered, the output must contain:
125
-
126
- 1. **Axiom Inventory**: `[Axiom N]: [content] (source: explicit / implicit / background)`
127
- 2. **Formal Language Specification**: `[Language type]: [first-order / second-order / constructive] (rationale: ...)`
128
- 3. **Consistency Check**: `✅ Consistent` or `❌ Contradiction found: [specific contradiction]`; if using relative consistency, note the target system of the embedding
129
- 4. **Independence Analysis**: Flag any redundant axioms `⚠️ [Axiom N] may be derivable from [Axiom M]`
130
- 5. **Completeness Assessment**: `✅ Complete` / `⚠️ Incomplete: missing [X]`; note whether Gödel's incompleteness theorems apply, and indicate decidability
131
- 6. **Axiom Change Analysis**: If a particular axiom is changed (removing excluded middle, adding/removing the Axiom of Choice), how does the theory change?
132
- 7. **Conclusion**: Overall assessment of the system's consistency, independence, completeness, categoricity, and decidability
133
- 8. **[GPU Feasibility]** (if used for algorithm/operator/structure design) — structures derived from the defined axioms and invariants pass the eight-dimension gate of `../../references/gpu-friendly-math.md`, rated friendly / retrofittable / unfriendly + adaptation recommendations
134
-
135
- **Output must never provide analysis alone without a conclusion. Every item must receive a definitive verdict — no hedging.**
136
-
137
- ## Relations to Other Skills
138
-
139
- - **Logic Deduction**: Axiomatization requires logical deduction as its inference tool; formal inference rules are the proof mechanism of the axiom system.
140
- - **Abstraction**: Axiomatization is abstraction at the highest level — reducing everything to minimal assumptions.
141
- - **Modeling**: An axiom system is itself a kind of model, whose applicability to reality must be verified; model theory directly serves consistency and independence checks.
142
- - **Induction and Analogy**: The choice of axioms is often inspired through induction and analogy.
143
- - **Algorithmic Thinking**: Formal systems and decidability are directly linked — decidable theories admit algorithmic theorem-decision procedures; undecidable theories do not.
144
- - **Modern Math Activation**: `../../references/books/abstract-algebra.md` (axiom systems / groups, rings, fields; ring→semiring relaxation), `../../references/books/algebraic-geometry-rising-sea.md` (sheaf/category/cohomology foundations).