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.
- package/README.en-US.md +165 -198
- package/README.md +165 -198
- package/agents/math-critic.en.md +28 -26
- package/agents/math-critic.md +33 -33
- package/commands/ask.en.md +10 -0
- package/commands/ask.md +3 -10
- package/design-patterns/attention/equivariant-attention.en.md +72 -0
- package/design-patterns/attention/equivariant-attention.md +72 -0
- package/design-patterns/attention/geometry-aware-attention.en.md +73 -0
- package/design-patterns/attention/geometry-aware-attention.md +72 -0
- package/design-patterns/attention/information-bottleneck-attention.en.md +72 -0
- package/design-patterns/attention/information-bottleneck-attention.md +72 -0
- package/design-patterns/attention/projection-attention.en.md +68 -0
- package/design-patterns/attention/projection-attention.md +68 -0
- package/design-patterns/attention/spectral-attention.en.md +71 -0
- package/design-patterns/attention/spectral-attention.md +71 -0
- package/design-patterns/compression/leverage-score-selection.en.md +71 -0
- package/design-patterns/compression/leverage-score-selection.md +71 -0
- package/design-patterns/compression/low-rank-kv-cache.en.md +60 -0
- package/design-patterns/compression/low-rank-kv-cache.md +60 -0
- package/design-patterns/compression/spectral-token-pruning.en.md +61 -0
- package/design-patterns/compression/spectral-token-pruning.md +61 -0
- package/design-patterns/compression/topology-preserving-compression.en.md +64 -0
- package/design-patterns/compression/topology-preserving-compression.md +64 -0
- package/design-patterns/loss/constraint-penalty.en.md +67 -0
- package/design-patterns/loss/constraint-penalty.md +78 -0
- package/design-patterns/loss/contrastive-loss.en.md +59 -0
- package/design-patterns/loss/contrastive-loss.md +68 -0
- package/design-patterns/loss/information-bottleneck-loss.en.md +69 -0
- package/design-patterns/loss/information-bottleneck-loss.md +74 -0
- package/design-patterns/loss/orthogonality-loss.en.md +56 -0
- package/design-patterns/loss/orthogonality-loss.md +60 -0
- package/design-patterns/loss/variational-loss.en.md +61 -0
- package/design-patterns/loss/variational-loss.md +71 -0
- package/design-patterns/representation/equivariant-split.en.md +87 -0
- package/design-patterns/representation/equivariant-split.md +89 -0
- package/design-patterns/representation/manifold-representation.en.md +85 -0
- package/design-patterns/representation/manifold-representation.md +87 -0
- package/design-patterns/representation/shared-private-decomposition.en.md +84 -0
- package/design-patterns/representation/shared-private-decomposition.md +86 -0
- package/design-patterns/representation/subspace-alignment.en.md +90 -0
- package/design-patterns/representation/subspace-alignment.md +92 -0
- package/design-patterns/routing/graph-routing.en.md +79 -0
- package/design-patterns/routing/graph-routing.md +81 -0
- package/design-patterns/routing/moe-routing.en.md +85 -0
- package/design-patterns/routing/moe-routing.md +87 -0
- package/design-patterns/routing/optimal-transport-routing.en.md +68 -0
- package/design-patterns/routing/optimal-transport-routing.md +72 -0
- package/design-patterns/routing/spectral-clustering-routing.en.md +88 -0
- package/design-patterns/routing/spectral-clustering-routing.md +90 -0
- package/knowledge-base/differential-geometry/connection.en.md +51 -0
- package/knowledge-base/differential-geometry/connection.md +51 -0
- package/knowledge-base/differential-geometry/curvature.en.md +49 -0
- package/knowledge-base/differential-geometry/curvature.md +49 -0
- package/knowledge-base/differential-geometry/geodesic.en.md +51 -0
- package/knowledge-base/differential-geometry/geodesic.md +51 -0
- package/knowledge-base/differential-geometry/manifold.en.md +47 -0
- package/knowledge-base/differential-geometry/manifold.md +47 -0
- package/knowledge-base/differential-geometry/metric-tensor.en.md +50 -0
- package/knowledge-base/differential-geometry/metric-tensor.md +50 -0
- package/knowledge-base/differential-geometry/tangent-space.en.md +48 -0
- package/knowledge-base/differential-geometry/tangent-space.md +48 -0
- package/knowledge-base/information-geometry/fisher-metric.en.md +56 -0
- package/knowledge-base/information-geometry/fisher-metric.md +56 -0
- package/knowledge-base/information-geometry/natural-gradient.en.md +54 -0
- package/knowledge-base/information-geometry/natural-gradient.md +54 -0
- package/knowledge-base/lie-theory/equivariance.en.md +54 -0
- package/knowledge-base/lie-theory/equivariance.md +54 -0
- package/knowledge-base/lie-theory/group-action.en.md +51 -0
- package/knowledge-base/lie-theory/group-action.md +51 -0
- package/knowledge-base/lie-theory/lie-algebra.en.md +51 -0
- package/knowledge-base/lie-theory/lie-algebra.md +51 -0
- package/knowledge-base/lie-theory/lie-group.en.md +51 -0
- package/knowledge-base/lie-theory/lie-group.md +51 -0
- package/knowledge-base/lie-theory/representation.en.md +52 -0
- package/knowledge-base/lie-theory/representation.md +52 -0
- package/knowledge-base/matrix-analysis/low-rank-approximation.en.md +49 -0
- package/knowledge-base/matrix-analysis/low-rank-approximation.md +49 -0
- package/knowledge-base/matrix-analysis/matrix-perturbation.en.md +49 -0
- package/knowledge-base/matrix-analysis/matrix-perturbation.md +49 -0
- package/knowledge-base/matrix-analysis/positive-semidefinite.en.md +50 -0
- package/knowledge-base/matrix-analysis/positive-semidefinite.md +50 -0
- package/knowledge-base/matrix-analysis/projection.en.md +47 -0
- package/knowledge-base/matrix-analysis/projection.md +47 -0
- package/knowledge-base/matrix-analysis/spectral-decomposition.en.md +48 -0
- package/knowledge-base/matrix-analysis/spectral-decomposition.md +48 -0
- package/knowledge-base/optimization/constrained-optimization.en.md +53 -0
- package/knowledge-base/optimization/constrained-optimization.md +53 -0
- package/knowledge-base/optimization/convex-optimization.en.md +50 -0
- package/knowledge-base/optimization/convex-optimization.md +50 -0
- package/knowledge-base/optimization/lagrangian-duality.en.md +50 -0
- package/knowledge-base/optimization/lagrangian-duality.md +50 -0
- package/knowledge-base/optimization/proximal-method.en.md +52 -0
- package/knowledge-base/optimization/proximal-method.md +52 -0
- package/knowledge-base/optimization/riemannian-optimization.en.md +51 -0
- package/knowledge-base/optimization/riemannian-optimization.md +51 -0
- package/knowledge-base/overview.en.md +29 -218
- package/knowledge-base/overview.md +29 -220
- package/knowledge-base/probability/concentration-inequality.en.md +45 -0
- package/knowledge-base/probability/concentration-inequality.md +45 -0
- package/knowledge-base/probability/entropy.en.md +47 -0
- package/knowledge-base/probability/entropy.md +47 -0
- package/knowledge-base/probability/fisher-information.en.md +48 -0
- package/knowledge-base/probability/fisher-information.md +48 -0
- package/knowledge-base/probability/information-bottleneck.en.md +49 -0
- package/knowledge-base/probability/information-bottleneck.md +49 -0
- package/knowledge-base/probability/kl-divergence.en.md +51 -0
- package/knowledge-base/probability/kl-divergence.md +51 -0
- package/knowledge-base/topology/euler-characteristic.en.md +54 -0
- package/knowledge-base/topology/euler-characteristic.md +54 -0
- package/knowledge-base/topology/fundamental-group.en.md +52 -0
- package/knowledge-base/topology/fundamental-group.md +52 -0
- package/knowledge-base/topology/persistent-homology.en.md +54 -0
- package/knowledge-base/topology/persistent-homology.md +54 -0
- package/lenses/algorithmic.en.md +49 -0
- package/lenses/algorithmic.md +49 -0
- package/lenses/axiomatization.en.md +48 -0
- package/lenses/axiomatization.md +48 -0
- package/lenses/categorical.en.md +48 -0
- package/lenses/categorical.md +48 -0
- package/lenses/causal.en.md +49 -0
- package/lenses/causal.md +49 -0
- package/lenses/duality.en.md +47 -0
- package/lenses/duality.md +47 -0
- package/lenses/game.en.md +50 -0
- package/lenses/game.md +50 -0
- package/lenses/geometric.en.md +53 -0
- package/lenses/geometric.md +53 -0
- package/lenses/local-to-global.en.md +52 -0
- package/lenses/local-to-global.md +52 -0
- package/lenses/perturbation.en.md +51 -0
- package/lenses/perturbation.md +51 -0
- package/lenses/probabilistic.en.md +48 -0
- package/lenses/probabilistic.md +48 -0
- package/lenses/projection.en.md +50 -0
- package/lenses/projection.md +50 -0
- package/lenses/spectral.en.md +52 -0
- package/lenses/spectral.md +52 -0
- package/lenses/symmetry.en.md +49 -0
- package/lenses/symmetry.md +49 -0
- package/lenses/topological.en.md +48 -0
- package/lenses/topological.md +48 -0
- package/lenses/variational.en.md +48 -0
- package/lenses/variational.md +48 -0
- package/package.json +9 -3
- package/references/agentic-workflow.en.md +1 -1
- package/references/agentic-workflow.md +1 -1
- package/references/books/abstract-algebra.en.md +124 -0
- package/references/books/abstract-algebra.md +22 -22
- package/references/books/algebraic-geometry-rising-sea.en.md +171 -0
- package/references/books/algebraic-geometry-rising-sea.md +11 -11
- package/references/books/differential-geometry.en.md +140 -0
- package/references/books/differential-geometry.md +19 -19
- package/references/books/matrix-analysis.en.md +146 -0
- package/references/books/matrix-analysis.md +10 -10
- package/references/books/micro-lie-theory.en.md +116 -0
- package/references/books/micro-lie-theory.md +17 -17
- package/references/books/optimization-ml.en.md +163 -0
- package/references/books/optimization-ml.md +7 -8
- package/references/books/smooth-manifolds.en.md +105 -0
- package/references/books/smooth-manifolds.md +14 -14
- package/references/gpu-friendly-math.en.md +23 -10
- package/references/gpu-friendly-math.md +17 -4
- package/references/inspiration.en.md +1 -1
- package/references/inspiration.md +2 -2
- package/skills/math-research-activator/SKILL.en.md +195 -114
- package/skills/math-research-activator/SKILL.md +194 -119
- package/skills/math-research-activator/original-texts.en.md +9 -9
- package/skills/math-research-activator/original-texts.md +11 -11
- package/commands/abstraction.md +0 -11
- package/commands/algorithmic-thinking.md +0 -11
- package/commands/axiomatization.md +0 -11
- package/commands/causal-inference.md +0 -11
- package/commands/discrete-combinatorial.md +0 -11
- package/commands/game-theory.md +0 -11
- package/commands/induction-analogy.md +0 -11
- package/commands/information-theory.md +0 -11
- package/commands/logic-deduction.md +0 -11
- package/commands/modeling.md +0 -11
- package/commands/optimization.md +0 -11
- package/commands/probability-statistics.md +0 -11
- package/commands/symmetry-invariance.md +0 -11
- package/commands/topological-thinking.md +0 -11
- package/commands/transformation.md +0 -11
- package/skills/abstraction/SKILL.en.md +0 -117
- package/skills/abstraction/SKILL.md +0 -121
- package/skills/abstraction/original-texts.en.md +0 -163
- package/skills/abstraction/original-texts.md +0 -175
- package/skills/algorithmic-thinking/SKILL.en.md +0 -132
- package/skills/algorithmic-thinking/SKILL.md +0 -138
- package/skills/algorithmic-thinking/original-texts.en.md +0 -253
- package/skills/algorithmic-thinking/original-texts.md +0 -256
- package/skills/axiomatization/SKILL.en.md +0 -144
- package/skills/axiomatization/SKILL.md +0 -151
- package/skills/axiomatization/original-texts.en.md +0 -154
- package/skills/axiomatization/original-texts.md +0 -160
- package/skills/causal-inference/SKILL.en.md +0 -147
- package/skills/causal-inference/SKILL.md +0 -151
- package/skills/causal-inference/original-texts.en.md +0 -136
- package/skills/causal-inference/original-texts.md +0 -167
- package/skills/discrete-combinatorial/SKILL.en.md +0 -124
- package/skills/discrete-combinatorial/SKILL.md +0 -131
- package/skills/discrete-combinatorial/original-texts.en.md +0 -184
- package/skills/discrete-combinatorial/original-texts.md +0 -185
- package/skills/game-theory/SKILL.en.md +0 -117
- package/skills/game-theory/SKILL.md +0 -123
- package/skills/game-theory/original-texts.en.md +0 -131
- package/skills/game-theory/original-texts.md +0 -131
- package/skills/induction-analogy/SKILL.en.md +0 -145
- package/skills/induction-analogy/SKILL.md +0 -152
- package/skills/induction-analogy/original-texts.en.md +0 -140
- package/skills/induction-analogy/original-texts.md +0 -154
- package/skills/information-theory/SKILL.en.md +0 -134
- package/skills/information-theory/SKILL.md +0 -140
- package/skills/information-theory/original-texts.en.md +0 -127
- package/skills/information-theory/original-texts.md +0 -127
- package/skills/logic-deduction/SKILL.en.md +0 -130
- package/skills/logic-deduction/SKILL.md +0 -135
- package/skills/logic-deduction/original-texts.en.md +0 -160
- package/skills/logic-deduction/original-texts.md +0 -173
- package/skills/modeling/SKILL.en.md +0 -135
- package/skills/modeling/SKILL.md +0 -139
- package/skills/modeling/original-texts.en.md +0 -162
- package/skills/modeling/original-texts.md +0 -165
- package/skills/optimization/SKILL.en.md +0 -129
- package/skills/optimization/SKILL.md +0 -135
- package/skills/optimization/original-texts.en.md +0 -167
- package/skills/optimization/original-texts.md +0 -168
- package/skills/probability-statistics/SKILL.en.md +0 -146
- package/skills/probability-statistics/SKILL.md +0 -151
- package/skills/probability-statistics/original-texts.en.md +0 -191
- package/skills/probability-statistics/original-texts.md +0 -193
- package/skills/symmetry-invariance/SKILL.en.md +0 -135
- package/skills/symmetry-invariance/SKILL.md +0 -139
- package/skills/symmetry-invariance/original-texts.en.md +0 -206
- package/skills/symmetry-invariance/original-texts.md +0 -221
- package/skills/topological-thinking/SKILL.en.md +0 -124
- package/skills/topological-thinking/SKILL.md +0 -128
- package/skills/topological-thinking/original-texts.en.md +0 -134
- package/skills/topological-thinking/original-texts.md +0 -164
- package/skills/transformation/SKILL.en.md +0 -120
- package/skills/transformation/SKILL.md +0 -124
- package/skills/transformation/original-texts.en.md +0 -204
- package/skills/transformation/original-texts.md +0 -216
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# 信息瓶颈 / Information Bottleneck
|
|
2
|
+
|
|
3
|
+
## 最小定义
|
|
4
|
+
信息瓶颈(IB)是一种表示学习理论框架:给定输入 $X$ 和目标 $Y$,寻找压缩表示 $Z$,使其**尽可能丢弃 $X$ 中与 $Y$ 无关的信息,同时保留对预测 $Y$ 有用的信息**。它将学习问题重新表述为信息论约束优化。
|
|
5
|
+
|
|
6
|
+
## 核心公式
|
|
7
|
+
|
|
8
|
+
**IB 目标函数**:
|
|
9
|
+
$$\min_{p(z|x)} \; I(X; Z) - \beta \cdot I(Z; Y)$$
|
|
10
|
+
|
|
11
|
+
其中 $\beta > 0$ 为拉格朗日乘子,控制**压缩-预测**的权衡:
|
|
12
|
+
- $I(X; Z)$:表示 $Z$ 中保留的关于输入 $X$ 的信息量(越小 = 压缩越强)
|
|
13
|
+
- $I(Z; Y)$:表示 $Z$ 中关于目标 $Y$ 的信息量(越大 = 预测越好)
|
|
14
|
+
|
|
15
|
+
**变分下界**(实际可计算版本):
|
|
16
|
+
$$\mathcal{L}_{VIB} = \mathbb{E}_{p(x,y)}[-\log q_\phi(y|z)] + D_{KL}(p_\theta(z|x) \| r(z))$$
|
|
17
|
+
|
|
18
|
+
其中 $q_\phi(y|z)$ 为分类器/解码器,$r(z)$ 为先验分布(通常为 $\mathcal{N}(0,I)$),$p_\theta(z|x)$ 为编码器。
|
|
19
|
+
|
|
20
|
+
**IB 曲线**:在 $(I(X;Z), I(Z;Y))$ 平面上,帕累托最优解构成一条凹曲线,拐点处对应最优压缩率。
|
|
21
|
+
|
|
22
|
+
## 适用问题
|
|
23
|
+
- **理解深度网络的学习动态**:信息平面(Information Plane)分析——每层的 $(I(X;Z_l), I(Z_l;Y))$ 随训练的变化轨迹
|
|
24
|
+
- **表示学习的理论指导**:为什么正则化(dropout、weight decay)有效——它们在隐式压缩冗余信息
|
|
25
|
+
- **特征选择与降维**:在压缩率和预测性能之间寻找帕累托最优点
|
|
26
|
+
|
|
27
|
+
## AI 设计翻译
|
|
28
|
+
- **VIB 层 Variational Information Bottleneck**:编码器 $p_\theta(z|x)$ + KL 正则 + 解码器 $q_\phi(y|z)$,本质与 VAE 结构相同但目标语义不同(VAE 重构 $X$,VIB 预测 $Y$)
|
|
29
|
+
- **$\beta$-VAE 的统一视角**:$\beta$-VAE 的目标函数与 VIB 形式一致,$\beta$ 即为 IB 拉格朗日乘子
|
|
30
|
+
- **注意力稀疏化 / 路由的信息论解释**:Sparse Attention 和 MoE 路由可理解为隐式信息瓶颈——选择性地让"有用" token 通过,丢弃噪声
|
|
31
|
+
|
|
32
|
+
## 工程可行性
|
|
33
|
+
- **D1[v]**:VIB 的编码器/解码器均为标准网络,$D_{KL}$ 为逐元素计算
|
|
34
|
+
- **D2[v]**:主体计算为标准前向网络 + GEMM
|
|
35
|
+
- **D3[v]**:相比原始网络仅增加 KL 项的 $O(d)$ 计算
|
|
36
|
+
- **D4[~]**:需要额外维护先验分布 $r(z)$ 的参数和 KL 计算中间量
|
|
37
|
+
- **D5[v]**:重参数化技巧 + KL 解析解在 bf16 下稳定
|
|
38
|
+
- **D8[v]**:与标准训练流程无冲突,可正常融合
|
|
39
|
+
|
|
40
|
+
## 风险与失效条件
|
|
41
|
+
- **$I(X;Z)$ 的精确估计困难**:高维连续变量间的互信息估计本身是开放问题(MINE、NWJ 等估计器方差大),实际用 VIB 变分下界绕过,但下界可能很松。
|
|
42
|
+
- **$\beta$ 调参敏感**:$\beta$ 过大会过度压缩(欠拟合),过小则退化为标准 ERM(无压缩效果)。需要信息平面分析或自适应 $\beta$ 调度。
|
|
43
|
+
|
|
44
|
+
## 深入参考
|
|
45
|
+
- 蒸馏稿:`references/books/` 暂无专用 IB 蒸馏稿
|
|
46
|
+
- Tishby, Pereira, Bialek. "The Information Bottleneck Method." *arXiv:physics/0004057*, 2000
|
|
47
|
+
- Alemi, Poole, Fischer, Dillon, Suresh, Murphy. "Deep Variational Information Bottleneck." *ICLR*, 2017
|
|
48
|
+
- Shwartz-Ziv, Tishby. "Opening the Black Box of Deep Neural Networks via Information." *arXiv:1703.00810*, 2017
|
|
49
|
+
- 关联知识卡:`probability/entropy.md`、`probability/kl-divergence.md`
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# KL Divergence
|
|
2
|
+
|
|
3
|
+
## Minimal Definition
|
|
4
|
+
Kullback-Leibler divergence measures the **information loss** when a probability distribution $q$ is used to approximate the true distribution $p$ — that is, the average number of extra bits spent when encoding $p$ using $q$. It is not a metric (it is asymmetric and does not satisfy the triangle inequality), but it defines a natural "directional distance" on the probability simplex.
|
|
5
|
+
|
|
6
|
+
## Core Formulas
|
|
7
|
+
|
|
8
|
+
**Definition**:
|
|
9
|
+
$$D_{KL}(p \| q) = \sum_x p(x) \log \frac{p(x)}{q(x)} = \mathbb{E}_{p}\left[\log \frac{p(X)}{q(X)}\right]$$
|
|
10
|
+
|
|
11
|
+
**Continuous version**:
|
|
12
|
+
$$D_{KL}(p \| q) = \int p(x) \log \frac{p(x)}{q(x)}\, dx$$
|
|
13
|
+
|
|
14
|
+
**Fundamental properties**:
|
|
15
|
+
- $D_{KL}(p \| q) \geq 0$ (Gibbs' inequality), with equality if and only if $p = q$
|
|
16
|
+
- **Asymmetric**: $D_{KL}(p \| q) \neq D_{KL}(q \| p)$, hence it is not a metric
|
|
17
|
+
|
|
18
|
+
**Relationship to cross-entropy and entropy**:
|
|
19
|
+
$$D_{KL}(p \| q) = H(p, q) - H(p)$$
|
|
20
|
+
|
|
21
|
+
**Semantic difference between the two directions**:
|
|
22
|
+
- **Forward KL** $D_{KL}(p \| q)$: $q$ tends to cover all modes of $p$ (mean-seeking)
|
|
23
|
+
- **Reverse KL** $D_{KL}(q \| p)$: $q$ tends to lock onto a single mode of $p$ (mode-seeking)
|
|
24
|
+
|
|
25
|
+
## Applicable Problems
|
|
26
|
+
- **Variational inference**: Minimize the reverse KL $D_{KL}(q \| p)$ to find an approximate posterior distribution
|
|
27
|
+
- **Knowledge distillation**: Minimize the information loss from the teacher distribution $p$ to the student distribution $q$
|
|
28
|
+
- **Regularization**: Constrain the model distribution to remain close to a prior (e.g., the KL regularization term in VAEs)
|
|
29
|
+
|
|
30
|
+
## AI Design Translation
|
|
31
|
+
- **Knowledge Distillation Loss**: $\mathcal{L} = (1-\alpha) \cdot CE(y, q_s) + \alpha \cdot T^2 \cdot D_{KL}(p_t \| q_s)$, where $T$ is the temperature parameter
|
|
32
|
+
- **VAE Regularization Term**: $D_{KL}(q_\phi(z|x) \| p(z))$, typically with $p(z) = \mathcal{N}(0, I)$, which admits an analytical solution
|
|
33
|
+
- **PPO / RLHF**: $D_{KL}(\pi_\theta \| \pi_{\text{ref}})$ serves as a penalty term for the policy deviating from the reference policy
|
|
34
|
+
|
|
35
|
+
## Engineering Feasibility
|
|
36
|
+
- **D1[v]**: Element-wise $p \log(p/q)$ is fully vectorizable
|
|
37
|
+
- **D2[~]**: KL itself is not a GEMM, but its inputs (logits) come from GEMM layers
|
|
38
|
+
- **D3[v]**: $O(|\mathcal{X}|)$ linear
|
|
39
|
+
- **D4[~]**: For large vocabularies, both $p$ and $q$ probability vectors must be held simultaneously; chunked computation is possible
|
|
40
|
+
- **D5[v]**: Log-softmax differences are stable in bf16; note that $\log q$ diverges as $q \to 0$, requiring clamping
|
|
41
|
+
- **D8[v]**: Can be fused with softmax into FusedKLDivLoss
|
|
42
|
+
|
|
43
|
+
## Risks and Failure Conditions
|
|
44
|
+
- **KL diverges to infinity when $q(x)=0$ but $p(x)>0$**: In practice, label smoothing or temperature scaling must be applied to $q$ to avoid zero probabilities. The mode-seeking behavior of reverse KL can exacerbate this issue — the student model "drops" low-probability regions of the teacher distribution.
|
|
45
|
+
- **High gradient variance**: In RL (PPO/RLHF), KL estimation relies on sampling; high variance can lead to training instability. A clipped + linear approximation $\mathbb{E}[\log p - \log q]$ is commonly used in place of the exact KL.
|
|
46
|
+
|
|
47
|
+
## Further References
|
|
48
|
+
- Distillation draft: `references/books/` — no dedicated information theory distillation draft at present
|
|
49
|
+
- Cover & Thomas. *Elements of Information Theory*, Ch. 2-3. Wiley, 2006
|
|
50
|
+
- Murphy. *Probabilistic Machine Learning: Advanced Topics*, Ch. 6. MIT Press, 2023
|
|
51
|
+
- Related knowledge cards: `probability/entropy.md`, `probability/information-bottleneck.md`, `probability/fisher-information.md`
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# KL 散度 / KL Divergence
|
|
2
|
+
|
|
3
|
+
## 最小定义
|
|
4
|
+
Kullback-Leibler 散度度量一个概率分布 $q$ 相对于真实分布 $p$ 的**信息损失**——即用 $q$ 编码 $p$ 时多花的平均比特数。它不是度量(不对称、不满足三角不等式),但在概率单纯形上定义了自然的"方向性距离"。
|
|
5
|
+
|
|
6
|
+
## 核心公式
|
|
7
|
+
|
|
8
|
+
**定义**:
|
|
9
|
+
$$D_{KL}(p \| q) = \sum_x p(x) \log \frac{p(x)}{q(x)} = \mathbb{E}_{p}\left[\log \frac{p(X)}{q(X)}\right]$$
|
|
10
|
+
|
|
11
|
+
**连续版本**:
|
|
12
|
+
$$D_{KL}(p \| q) = \int p(x) \log \frac{p(x)}{q(x)}\, dx$$
|
|
13
|
+
|
|
14
|
+
**基本性质**:
|
|
15
|
+
- $D_{KL}(p \| q) \geq 0$(Gibbs 不等式),等号当且仅当 $p = q$
|
|
16
|
+
- **不对称**:$D_{KL}(p \| q) \neq D_{KL}(q \| p)$,因此不是度量
|
|
17
|
+
|
|
18
|
+
**与交叉熵/熵的关系**:
|
|
19
|
+
$$D_{KL}(p \| q) = H(p, q) - H(p)$$
|
|
20
|
+
|
|
21
|
+
**两种方向的语义差异**:
|
|
22
|
+
- **前向 KL** $D_{KL}(p \| q)$:$q$ 倾向于覆盖 $p$ 的所有模式(mean-seeking)
|
|
23
|
+
- **反向 KL** $D_{KL}(q \| p)$:$q$ 倾向于锁定 $p$ 的某一个模式(mode-seeking)
|
|
24
|
+
|
|
25
|
+
## 适用问题
|
|
26
|
+
- **变分推断**:最小化反向 KL $D_{KL}(q \| p)$ 以寻找近似后验分布
|
|
27
|
+
- **知识蒸馏**:教师分布 $p$ 到学生分布 $q$ 的信息损失最小化
|
|
28
|
+
- **正则化**:约束模型分布不偏离先验太远(VAE 中的 KL 正则项)
|
|
29
|
+
|
|
30
|
+
## AI 设计翻译
|
|
31
|
+
- **知识蒸馏 Loss**:$\mathcal{L} = (1-\alpha) \cdot CE(y, q_s) + \alpha \cdot T^2 \cdot D_{KL}(p_t \| q_s)$,其中 $T$ 为温度参数
|
|
32
|
+
- **VAE 正则项**:$D_{KL}(q_\phi(z|x) \| p(z))$,通常取 $p(z) = \mathcal{N}(0, I)$,解析可算
|
|
33
|
+
- **PPO / RLHF**:$D_{KL}(\pi_\theta \| \pi_{\text{ref}})$ 作为策略偏离参考策略的惩罚项
|
|
34
|
+
|
|
35
|
+
## 工程可行性
|
|
36
|
+
- **D1[v]**:逐元素 $p \log(p/q)$ 完全向量化
|
|
37
|
+
- **D2[~]**:KL 本身不是 GEMM,但输入(logits)来自 GEMM 层
|
|
38
|
+
- **D3[v]**:$O(|\mathcal{X}|)$ 线性
|
|
39
|
+
- **D4[~]**:大 vocab 下需同时保留 $p$ 和 $q$ 的完整概率向量,可 chunk 计算
|
|
40
|
+
- **D5[v]**:log-softmax 差值在 bf16 下稳定;注意 $q \to 0$ 时 $\log q$ 发散,需 clamp
|
|
41
|
+
- **D8[v]**:可与 softmax 融合为 FusedKLDivLoss
|
|
42
|
+
|
|
43
|
+
## 风险与失效条件
|
|
44
|
+
- **$q(x)=0$ 但 $p(x)>0$ 时 KL 发散为无穷**:实践中必须对 $q$ 做 label smoothing 或温度缩放,避免零概率。反向 KL 的 mode-seeking 行为可加剧此问题——学生模型"丢弃"教师分布的低概率区域。
|
|
45
|
+
- **梯度方差大**:在 RL(PPO/RLHF)中,KL 估计依赖采样,高方差可导致训练不稳定。常用 clip + 线性近似 $\mathbb{E}[\log p - \log q]$ 替代精确 KL。
|
|
46
|
+
|
|
47
|
+
## 深入参考
|
|
48
|
+
- 蒸馏稿:`references/books/` 暂无专用信息论蒸馏稿
|
|
49
|
+
- Cover & Thomas. *Elements of Information Theory*, Ch. 2-3. Wiley, 2006
|
|
50
|
+
- Murphy. *Probabilistic Machine Learning: Advanced Topics*, Ch. 6. MIT Press, 2023
|
|
51
|
+
- 关联知识卡:`probability/entropy.md`、`probability/information-bottleneck.md`、`probability/fisher-information.md`
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Euler Characteristic
|
|
2
|
+
|
|
3
|
+
## Minimal Definition
|
|
4
|
+
|
|
5
|
+
The Euler characteristic $\chi$ is the most fundamental integer invariant of a topological space, defined as the alternating sum of the number of cells (or simplices) of each dimension: $\chi = \sum_{k=0}^d (-1)^k c_k$. It is invariant under continuous deformation and equals the alternating sum of Betti numbers $\chi = \sum_k (-1)^k \beta_k$.
|
|
6
|
+
|
|
7
|
+
## Core Formulas
|
|
8
|
+
|
|
9
|
+
- Cell formula: $\chi = c_0 - c_1 + c_2 - c_3 + \cdots = \sum_{k=0}^d (-1)^k c_k$
|
|
10
|
+
- Betti number formula: $\chi = \beta_0 - \beta_1 + \beta_2 - \cdots = \sum_{k=0}^d (-1)^k \beta_k$
|
|
11
|
+
- Gauss-Bonnet theorem: $\chi(M) = \frac{1}{2\pi} \int_M K \, dA$ (for 2-dimensional surfaces), connecting topology and curvature
|
|
12
|
+
- Higher-dimensional Gauss-Bonnet-Chern theorem: $\chi(M^{2n}) = \int_M \text{Pf}(\Omega / 2\pi)$
|
|
13
|
+
- Product formula: $\chi(X \times Y) = \chi(X) \cdot \chi(Y)$
|
|
14
|
+
- Common values: $\chi(S^2) = 2$, $\chi(T^2) = 0$, $\chi(\text{genus-}g) = 2 - 2g$
|
|
15
|
+
|
|
16
|
+
## Applicable Problems
|
|
17
|
+
|
|
18
|
+
- Rapid topological diagnostics: a single integer distinguishes spheres from tori from high-genus surfaces
|
|
19
|
+
- Mesh/graph quality inspection: the $\chi$ of a triangle mesh should be 2 (sphere-homeomorphic); anomalous values indicate topological errors
|
|
20
|
+
- Loss landscape analysis: in Morse theory of critical points, $\chi$ constrains the number and type of critical points
|
|
21
|
+
- Quick summary of persistent homology: $\chi = \sum (-1)^k \beta_k$ can be quickly computed from the persistence diagram
|
|
22
|
+
|
|
23
|
+
## AI Design Translation
|
|
24
|
+
|
|
25
|
+
- **Topological diagnostic metric**: Monitor the $\chi$ of the latent/feature space during training; sudden changes in $\chi$ indicate topological phase transitions (e.g., mode collapse)
|
|
26
|
+
- **Gauss-Bonnet regularization**: $\int K \, dA$ can be approximated by the trace of the Hessian, using curvature integrals as a regularization term to constrain loss landscape topology
|
|
27
|
+
- **Mesh quality loss**: For 3D generative models, penalize $\chi \neq \chi_{\text{target}}$ to ensure topological correctness of generated meshes
|
|
28
|
+
- **Morse-theoretic critical point analysis**: $\chi = \sum (-1)^{\text{index}} (\text{number of critical points})$, using critical point indices to diagnose optimization landscape
|
|
29
|
+
- **Euler characteristic curve**: $\chi(\epsilon) = \chi(VR_\epsilon)$ as a function of scale $\epsilon$, providing richer information than a single $\chi$ value
|
|
30
|
+
|
|
31
|
+
## Engineering Feasibility
|
|
32
|
+
|
|
33
|
+
High GPU friendliness. Computing the Euler characteristic is extremely cheap:
|
|
34
|
+
- **Cell counting**: $c_k$ is an integer count, $O(n)$ summation, perfectly GPU-friendly
|
|
35
|
+
- **From Betti numbers**: $\chi = \sum (-1)^k \beta_k$; if Betti numbers are already available, $O(d)$ summation
|
|
36
|
+
- **From persistence diagram**: $\beta_k(\epsilon) = |\{(b,d) \in D_k \mid b \leq \epsilon < d\}|$, a counting operation, $O(|D_k|)$
|
|
37
|
+
- **Gauss-Bonnet integral**: For 2D surfaces $\int K \, dA \approx \sum K_i A_i$, per-face summation, parallelizable
|
|
38
|
+
- **Euler characteristic curve**: Scanning $\chi(\epsilon)$ along $\epsilon$, implementable with sorting + cumulative sum, $O(n \log n)$
|
|
39
|
+
- Overall complexity: linear or sub-quadratic, fully computable in real time during the training loop
|
|
40
|
+
|
|
41
|
+
## Risks and Failure Conditions
|
|
42
|
+
|
|
43
|
+
- **Extreme information compression**: $\chi$ is a single integer; many distinct topological spaces share the same $\chi$ value ($\chi = 0$ can correspond to a torus, Klein bottle, etc.)
|
|
44
|
+
- **Sensitivity to noise**: Small perturbations of a point cloud can add/remove simplices, changing $c_k$ and hence $\chi$; should be combined with scale analysis from persistent homology
|
|
45
|
+
- **Discrete approximation error in Gauss-Bonnet**: Discrete curvature definitions are not unique; different discretizations yield different $\chi$ estimates
|
|
46
|
+
- **Degeneracy in high dimensions**: The Euler characteristic of odd-dimensional closed manifolds is $\chi = 0$, losing discriminative power; high-dimensional Betti numbers are expensive to compute
|
|
47
|
+
- **Captures only the global, not the local**: $\chi$ is a global invariant; local topological changes may cancel out
|
|
48
|
+
|
|
49
|
+
## Further References
|
|
50
|
+
|
|
51
|
+
- Distillation notes: references/books/smooth-manifolds.md (Ch 17--18 De Rham Cohomology, Betti numbers and cohomology)
|
|
52
|
+
- Distillation notes: references/books/differential-geometry.md (Ch 4 Curves and Hypersurfaces, intuition source for Gauss curvature)
|
|
53
|
+
- Original text: John M. Lee, *Introduction to Smooth Manifolds*, Ch 17--18 (de Rham cohomology and topological invariants)
|
|
54
|
+
- Extended reading: Hatcher, *Algebraic Topology*, Ch 2 (standard treatment of simplicial homology and the Euler characteristic)
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# 欧拉示性数 (Euler Characteristic)
|
|
2
|
+
|
|
3
|
+
## 最小定义
|
|
4
|
+
|
|
5
|
+
欧拉示性数 $\chi$ 是拓扑空间最基本的整数不变量,定义为各维胞腔(或单纯形)数的交错和:$\chi = \sum_{k=0}^d (-1)^k c_k$。它在连续变形下不变,等于各阶 Betti 数的交错和 $\chi = \sum_k (-1)^k \beta_k$。
|
|
6
|
+
|
|
7
|
+
## 核心公式
|
|
8
|
+
|
|
9
|
+
- 胞腔公式:$\chi = c_0 - c_1 + c_2 - c_3 + \cdots = \sum_{k=0}^d (-1)^k c_k$
|
|
10
|
+
- Betti 数公式:$\chi = \beta_0 - \beta_1 + \beta_2 - \cdots = \sum_{k=0}^d (-1)^k \beta_k$
|
|
11
|
+
- Gauss-Bonnet 定理:$\chi(M) = \frac{1}{2\pi} \int_M K \, dA$(2 维曲面),连接拓扑与曲率
|
|
12
|
+
- 高维 Gauss-Bonnet-Chern:$\chi(M^{2n}) = \int_M \text{Pf}(\Omega / 2\pi)$
|
|
13
|
+
- 乘积公式:$\chi(X \times Y) = \chi(X) \cdot \chi(Y)$
|
|
14
|
+
- 常见值:$\chi(S^2) = 2$,$\chi(T^2) = 0$,$\chi(\text{genus-}g) = 2 - 2g$
|
|
15
|
+
|
|
16
|
+
## 适用问题
|
|
17
|
+
|
|
18
|
+
- 快速拓扑诊断:一个整数即可区分球面 vs 环面 vs 高亏格曲面
|
|
19
|
+
- 网格/图的质量检验:三角形网格的 $\chi$ 应为 2(球面同胚),异常值指示拓扑错误
|
|
20
|
+
- 损失地形分析:临界点的 Morse 理论中 $\chi$ 约束临界点的数量和类型
|
|
21
|
+
- 持续同调的快速摘要:$\chi = \sum (-1)^k \beta_k$ 可从持续图快速算出
|
|
22
|
+
|
|
23
|
+
## AI 设计翻译
|
|
24
|
+
|
|
25
|
+
- **拓扑诊断指标**:训练过程中监控隐空间/特征空间的 $\chi$,$\chi$ 突变指示拓扑相变(如模式坍塌)
|
|
26
|
+
- **Gauss-Bonnet 正则化**:$\int K \, dA$ 可用 Hessian 的迹近似,将曲率积分作为正则项约束 loss landscape 拓扑
|
|
27
|
+
- **网格质量损失**:对 3D 生成模型,惩罚 $\chi \neq \chi_{\text{target}}$ 确保生成网格的拓扑正确
|
|
28
|
+
- **Morse 理论的临界点分析**:$\chi = \sum (-1)^{\text{index}} (\text{临界点数})$,用临界点指标诊断优化地形
|
|
29
|
+
- **Euler characteristic curve**:$\chi(\epsilon) = \chi(VR_\epsilon)$ 作为尺度 $\epsilon$ 的函数,比单一 $\chi$ 信息更丰富
|
|
30
|
+
|
|
31
|
+
## 工程可行性
|
|
32
|
+
|
|
33
|
+
GPU 友好度高。欧拉示性数的计算极其廉价:
|
|
34
|
+
- **胞腔计数**:$c_k$ 是整数计数,$O(n)$ 求和,完美 GPU 友好
|
|
35
|
+
- **从 Betti 数计算**:$\chi = \sum (-1)^k \beta_k$,若已有 Betti 数则 $O(d)$ 求和
|
|
36
|
+
- **从持续图计算**:$\beta_k(\epsilon) = |\{(b,d) \in D_k \mid b \leq \epsilon < d\}|$,计数操作,$O(|D_k|)$
|
|
37
|
+
- **Gauss-Bonnet 积分**:2 维曲面 $\int K \, dA \approx \sum K_i A_i$,逐面片求和,可并行
|
|
38
|
+
- **Euler characteristic curve**:沿 $\epsilon$ 扫描计算 $\chi(\epsilon)$,可用排序 + 累积和实现,$O(n \log n)$
|
|
39
|
+
- 整体复杂度:线性或亚二次,完全可在训练循环中实时计算
|
|
40
|
+
|
|
41
|
+
## 风险与失效条件
|
|
42
|
+
|
|
43
|
+
- **信息极度压缩**:$\chi$ 是单一整数,大量不同拓扑空间共享同一 $\chi$ 值($\chi = 0$ 可以是环面、Klein 瓶等)
|
|
44
|
+
- **对噪声敏感**:点云的小扰动可能添加/删除单纯形,改变 $c_k$ 从而改变 $\chi$;需配合持续同调的尺度分析
|
|
45
|
+
- **Gauss-Bonnet 的离散近似误差**:离散曲率的定义不唯一,不同离散化给出不同的 $\chi$ 估计
|
|
46
|
+
- **高维退化**:奇数维闭流形的 $\chi = 0$,失去区分能力;高维 Betti 数计算昂贵
|
|
47
|
+
- **只捕捉"整体"不捕捉"局部"**:$\chi$ 是全局不变量,局部拓扑变化可能被抵消
|
|
48
|
+
|
|
49
|
+
## 深入参考
|
|
50
|
+
|
|
51
|
+
- 蒸馏稿:references/books/smooth-manifolds.md(Ch 17-18 De Rham Cohomology,Betti 数与上同调)
|
|
52
|
+
- 蒸馏稿:references/books/differential-geometry.md(Ch 4 Curves and Hypersurfaces, Gauss curvature 直觉来源)
|
|
53
|
+
- 原书:John M. Lee, *Introduction to Smooth Manifolds*, Ch 17-18(de Rham 上同调与拓扑不变量)
|
|
54
|
+
- 延伸:Hatcher, *Algebraic Topology*, Ch 2(单纯同调与欧拉示性数的标准处理)
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Fundamental Group
|
|
2
|
+
|
|
3
|
+
## Minimal Definition
|
|
4
|
+
|
|
5
|
+
The fundamental group $\pi_1(X, x_0)$ is the group of equivalence classes of loops in a topological space $X$ based at a point $x_0$, under homotopy equivalence. The group operation is loop concatenation (first traverse $\alpha$, then $\beta$). It is the first homotopy group, detecting "non-contractible holes" in the space -- whether loops can be continuously shrunk to a point.
|
|
6
|
+
|
|
7
|
+
## Core Formulas
|
|
8
|
+
|
|
9
|
+
- Fundamental group: $\pi_1(X, x_0) = \{[\gamma] \mid \gamma: [0,1] \to X, \gamma(0)=\gamma(1)=x_0\}$
|
|
10
|
+
- Group operation: $[\alpha] \cdot [\beta] = [\alpha * \beta]$, $(\alpha * \beta)(t) = \begin{cases} \alpha(2t) & t \leq 1/2 \\ \beta(2t-1) & t \geq 1/2 \end{cases}$
|
|
11
|
+
- Simply connected: $\pi_1(X) = \{e\}$ (all loops can be contracted to a point)
|
|
12
|
+
- Common fundamental groups: $\pi_1(S^1) = \mathbb{Z}$, $\pi_1(T^2) = \mathbb{Z}^2$, $\pi_1(S^n) = 0 \, (n \geq 2)$
|
|
13
|
+
- Covering space correspondence: subgroups of $\pi_1$ $\leftrightarrow$ covering spaces (Galois correspondence)
|
|
14
|
+
- Seifert-van Kampen theorem: $\pi_1(X) = \pi_1(U) *_{\pi_1(U \cap V)} \pi_1(V)$ (computation via cover decomposition)
|
|
15
|
+
|
|
16
|
+
## Applicable Problems
|
|
17
|
+
|
|
18
|
+
- Detecting "holes" in a space: $\pi_1 \neq 0$ implies the existence of non-contractible loops
|
|
19
|
+
- Covering spaces and multi-valued functions: subgroups of $\pi_1$ determine the Riemann surface structure of multi-valued functions
|
|
20
|
+
- Robotic path planning: $\pi_1$ of the configuration space determines the number of topological equivalence classes of paths
|
|
21
|
+
- Molecular configuration analysis: the topology of the configuration space of cyclic molecules affects conformational sampling
|
|
22
|
+
|
|
23
|
+
## AI Design Translation
|
|
24
|
+
|
|
25
|
+
- **Topological regularization (non-contractible loop penalty)**: In the latent space, if the data has a loop-like structure (e.g., periodic signals), penalize the collapse of $\pi_1$ to maintain loop connectivity in the latent space
|
|
26
|
+
- **Covering-space-inspired multi-hypothesis tracking**: Non-trivial subgroups of $\pi_1$ correspond to multiple "covers," which can be used for parallel multi-hypothesis tracking in multi-modal prediction
|
|
27
|
+
- **Path equivalence class classifier**: In robotics/motion planning, label paths of different topological classes using elements of $\pi_1$, training a classifier to distinguish path topology types
|
|
28
|
+
- **Simply-connected regularization**: Enforce simple connectivity of the latent space ($\pi_1 = 0$), ensuring that interpolation paths between any two points can be continuously deformed, preventing "tearing" in the latent space
|
|
29
|
+
|
|
30
|
+
## Engineering Feasibility
|
|
31
|
+
|
|
32
|
+
Low GPU friendliness. Computation of the fundamental group is inherently combinatorial/algebraic rather than numerically linear:
|
|
33
|
+
- **Computing the fundamental group itself**: For a simplicial complex, $\pi_1$ is isomorphic to the edge group modulo face relations (Wirtinger presentation); requires a group presentation, **not tensorizable**
|
|
34
|
+
- **Loop detection**: Finding non-contractible loops on a graph/mesh is equivalent to finding non-trivial cycles, solvable via BFS/DFS, $O(V+E)$, but unsuitable for GPU parallelism (data-dependent graph traversal)
|
|
35
|
+
- **Differentiable alternatives**: Convert "loop contractibility" into a differentiable proxy -- such as loop integrals $\oint \omega$ (de Rham cohomology); a non-zero closed-form integral implies non-contractibility, which is differentiable
|
|
36
|
+
- **Numerical implementation of covering spaces**: For known group structures (e.g., $\mathbb{Z}^n$), covering spaces can be explicitly parameterized as periodic identifications, which is tensorizable
|
|
37
|
+
- Overall assessment: exact computation of $\pi_1$ belongs to the "beautiful but incomputable" category; differentiable proxies (loop integrals/cohomology) are required
|
|
38
|
+
|
|
39
|
+
## Risks and Failure Conditions
|
|
40
|
+
|
|
41
|
+
- **Not tensorizable**: The group presentation of $\pi_1$ is symbolic computation with no GEMM representation; it cannot be directly inserted into a training forward pass
|
|
42
|
+
- **Base-point dependence**: $\pi_1(X, x_0)$ is independent of the base point (up to isomorphism) in path-connected spaces, but different components of disconnected spaces have different $\pi_1$
|
|
43
|
+
- **Non-Abelianness**: $\pi_1$ is generally a non-Abelian group (e.g., free groups); the group operation is non-commutative, increasing computational and representational complexity
|
|
44
|
+
- **High-dimensional blind spot**: $\pi_1$ only detects 1-dimensional holes (non-contractible loops); higher-dimensional holes (e.g., "voids" in $S^2$) require higher homotopy groups $\pi_k$ ($k \geq 2$)
|
|
45
|
+
- **Robustness of numerical loop detection**: The definition of a "loop" in discretized/sampled point clouds is ambiguous and requires scale analysis from persistent homology
|
|
46
|
+
|
|
47
|
+
## Further References
|
|
48
|
+
|
|
49
|
+
- Distillation notes: references/books/smooth-manifolds.md (Ch 17--18 De Rham Cohomology, cohomology and topological invariants)
|
|
50
|
+
- Distillation notes: references/books/algebraic-geometry-rising-sea.md (Section 18 Cech Cohomology, local gluing and global obstructions)
|
|
51
|
+
- Original text: John M. Lee, *Introduction to Smooth Manifolds*, Ch 17 (de Rham cohomology, the loop integral perspective)
|
|
52
|
+
- Extended reading: Hatcher, *Algebraic Topology*, Ch 1 (standard textbook treatment of the fundamental group, including the Seifert-van Kampen theorem)
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# 基本群 (Fundamental Group)
|
|
2
|
+
|
|
3
|
+
## 最小定义
|
|
4
|
+
|
|
5
|
+
基本群 $\pi_1(X, x_0)$ 是拓扑空间 $X$ 中以基点 $x_0$ 为起终点的环路(loop)在同伦等价下的等价类构成的群。群运算是环路的拼接(先走 $\alpha$ 再走 $\beta$)。它是第一个同伦群,检测空间中"不可收缩的洞"——环路能否连续缩为一点。
|
|
6
|
+
|
|
7
|
+
## 核心公式
|
|
8
|
+
|
|
9
|
+
- 基本群:$\pi_1(X, x_0) = \{[\gamma] \mid \gamma: [0,1] \to X, \gamma(0)=\gamma(1)=x_0\}$
|
|
10
|
+
- 群运算:$[\alpha] \cdot [\beta] = [\alpha * \beta]$,$(\alpha * \beta)(t) = \begin{cases} \alpha(2t) & t \leq 1/2 \\ \beta(2t-1) & t \geq 1/2 \end{cases}$
|
|
11
|
+
- 单连通:$\pi_1(X) = \{e\}$(所有环路可缩为一点)
|
|
12
|
+
- 常见基本群:$\pi_1(S^1) = \mathbb{Z}$,$\pi_1(T^2) = \mathbb{Z}^2$,$\pi_1(S^n) = 0 \, (n \geq 2)$
|
|
13
|
+
- 覆盖空间对应:$\pi_1$ 的子群 $\leftrightarrow$ 覆盖空间(Galois 对应)
|
|
14
|
+
- Seifert-van Kampen 定理:$\pi_1(X) = \pi_1(U) *_{\pi_1(U \cap V)} \pi_1(V)$(由覆盖拼接计算)
|
|
15
|
+
|
|
16
|
+
## 适用问题
|
|
17
|
+
|
|
18
|
+
- 检测空间中的"洞":$\pi_1 \neq 0$ 意味着存在不可收缩的环路
|
|
19
|
+
- 覆盖空间与多值函数:$\pi_1$ 的子群决定多值函数的黎曼面结构
|
|
20
|
+
- 机器人路径规划:构型空间的 $\pi_1$ 决定路径的拓扑等价类数
|
|
21
|
+
- 分子构型分析:环状分子的构型空间拓扑影响构象采样
|
|
22
|
+
|
|
23
|
+
## AI 设计翻译
|
|
24
|
+
|
|
25
|
+
- **拓扑正则化(环路不可缩惩罚)**:在隐空间中,如果数据有环状结构(如周期信号),惩罚 $\pi_1$ 的坍塌,保持隐空间的环路连通性
|
|
26
|
+
- **覆盖空间启发的多假设跟踪**:$\pi_1$ 的非平凡子群对应多个"覆盖",可用于多模态预测中的多假设并行跟踪
|
|
27
|
+
- **路径等价类的分类器**:在机器人/运动规划中,用 $\pi_1$ 的元素标记不同拓扑类的路径,训练分类器区分路径的拓扑类型
|
|
28
|
+
- **单连通正则化**:强制隐空间为单连通($\pi_1 = 0$),确保任意两点间的插值路径可连续变形,避免隐空间"撕裂"
|
|
29
|
+
|
|
30
|
+
## 工程可行性
|
|
31
|
+
|
|
32
|
+
GPU 友好度低。基本群的计算本质上是组合/代数的,而非数值线性的:
|
|
33
|
+
- **基本群本身的计算**:对于单纯复形,$\pi_1$ 同构于边的群模去面的关系(Wirtinger 表示),需要群的展示(presentation),**不可张量化**
|
|
34
|
+
- **环路检测**:在图/网格上找不可缩环路等价于找非平凡循环,可用 BFS/DFS,$O(V+E)$,但不适合 GPU 并行(数据依赖的图遍历)
|
|
35
|
+
- **可微替代**:将"环路可缩性"转化为可微代理——如环路积分 $\oint \omega$(de Rham 上同调),闭形式积分非零即不可缩,这是可微的
|
|
36
|
+
- **覆盖空间的数值实现**:对于已知群结构(如 $\mathbb{Z}^n$),覆盖空间可以显式参数化为周期性拼接,可张量化
|
|
37
|
+
- 整体评估:精确计算 $\pi_1$ 属于"美但不可算"类别,需要可微代理(环路积分/上同调)替代
|
|
38
|
+
|
|
39
|
+
## 风险与失效条件
|
|
40
|
+
|
|
41
|
+
- **不可张量化**:$\pi_1$ 的群展示是符号计算,无 GEMM 表达,不能直接塞进训练 forward
|
|
42
|
+
- **基点依赖**:$\pi_1(X, x_0)$ 在路径连通空间中不依赖基点选择(同构),但不连通空间中不同分量有不同的 $\pi_1$
|
|
43
|
+
- **非阿贝尔性**:$\pi_1$ 一般是非阿贝尔群(如自由群),群运算不可交换,增加了计算和表示的复杂度
|
|
44
|
+
- **高维盲区**:$\pi_1$ 只检测 1 维洞(不可缩环路),高维洞(如 $S^2$ 的"空腔")需要高阶同伦群 $\pi_k (k \geq 2)$
|
|
45
|
+
- **数值环路检测的鲁棒性**:离散化/采样的点云中"环路"的定义模糊,需要配合持续同调的尺度分析
|
|
46
|
+
|
|
47
|
+
## 深入参考
|
|
48
|
+
|
|
49
|
+
- 蒸馏稿:references/books/smooth-manifolds.md(Ch 17-18 De Rham Cohomology,上同调与拓扑不变量)
|
|
50
|
+
- 蒸馏稿:references/books/algebraic-geometry-rising-sea.md(§18 Cech Cohomology,局部黏合与全局障碍)
|
|
51
|
+
- 原书:John M. Lee, *Introduction to Smooth Manifolds*, Ch 17(de Rham 上同调,环路积分的视角)
|
|
52
|
+
- 延伸:Hatcher, *Algebraic Topology*, Ch 1(基本群的标准教材处理,含 Seifert-van Kampen 定理)
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Persistent Homology
|
|
2
|
+
|
|
3
|
+
## Minimal Definition
|
|
4
|
+
|
|
5
|
+
Persistent homology tracks how the homology groups $H_k$ of a topological space change across different scales $\epsilon$: as $\epsilon$ increases from 0, topological features (connected components, holes, voids) are "born" at some scale and "die" at a larger scale. Features with long persistence are intrinsic topological structure; short-lived ones are noise. The output is a barcode or persistence diagram.
|
|
6
|
+
|
|
7
|
+
## Core Formulas
|
|
8
|
+
|
|
9
|
+
- Filtration: $\emptyset = K_0 \subseteq K_1 \subseteq \cdots \subseteq K_n = K$ (e.g., Vietoris-Rips complex $VR_\epsilon$)
|
|
10
|
+
- Vietoris-Rips complex: $VR_\epsilon = \{\sigma \subseteq X \mid d(x_i, x_j) \leq \epsilon, \forall x_i, x_j \in \sigma\}$
|
|
11
|
+
- Persistent homology groups: $H_k^{i,j} = \text{im}(H_k(K_i) \to H_k(K_j))$
|
|
12
|
+
- Persistence diagram: $D_k = \{(b_l, d_l)\}$, where $b_l$ is the birth scale and $d_l$ is the death scale
|
|
13
|
+
- Bottleneck distance: $d_B(D, D') = \inf_\gamma \sup_x \|x - \gamma(x)\|_\infty$
|
|
14
|
+
- Persistence landscape: $\lambda_k(t) = \sup\{m \mid \text{rank } H_k^{t-m, t+m} \geq k\}$
|
|
15
|
+
|
|
16
|
+
## Applicable Problems
|
|
17
|
+
|
|
18
|
+
- Topological feature extraction from point clouds: detecting the number of clusters, loops, voids, and other global structures
|
|
19
|
+
- Latent space quality assessment: whether the latent space generated by a VAE/GAN preserves the topological structure of the data
|
|
20
|
+
- Time series analysis: persistent homology after Takens embedding reveals dynamical topology
|
|
21
|
+
- Graph/network analysis: detecting community structure, bottlenecks, and higher-order correlations
|
|
22
|
+
|
|
23
|
+
## AI Design Translation
|
|
24
|
+
|
|
25
|
+
- **Topological regularization loss**: $L_{\text{topo}} = d_B(D_{\text{latent}}, D_{\text{data}})$, forcing the persistence diagram of the latent space to match that of the data, preserving topology
|
|
26
|
+
- **Persistence diagram featurization layer**: Convert the persistence diagram into a fixed-dimension vector (persistence image/landscape/silhouette) as input for downstream classification/regression
|
|
27
|
+
- **Topology-aware clustering**: Use the persistence intervals of $H_0$ to automatically determine the number of clusters; long-lived connected components correspond to true clusters
|
|
28
|
+
- **Latent space topology monitoring**: Compute $H_1$ (holes) of the latent space during training in real time to detect topological collapse (all holes disappear = posterior collapse)
|
|
29
|
+
|
|
30
|
+
## Engineering Feasibility
|
|
31
|
+
|
|
32
|
+
Limited GPU friendliness, which is the main bottleneck for deploying persistent homology:
|
|
33
|
+
- **Distance matrix computation**: $O(n^2)$, batched pairwise distances, GPU-friendly
|
|
34
|
+
- **Vietoris-Rips construction**: Combinatorial explosion; the VR complex on $n$ points has up to $2^n$ simplices; in practice, truncated to 2-skeleton, $O(n^3)$ worst case
|
|
35
|
+
- **Boundary matrix reduction (core algorithm)**: Column reduction analogous to Gaussian elimination, **highly serial**, standard algorithm cannot be parallelized
|
|
36
|
+
- **GPU-accelerated reduction algorithms**: e.g., Ripser's clearing optimization + GPU-based reduction (Emerald, etc.) can achieve 10--100x speedup, but still far from GEMM-level parallelism
|
|
37
|
+
- **Differentiable alternatives**: Persistence images are differentiable (gradients with respect to point positions can be computed), but the barcode itself is non-differentiable at birth/death events
|
|
38
|
+
- Complexity: exact computation is worst-case $O(n^3)$ (2-skeleton VR); large point clouds ($n > 10^4$) require subsampling
|
|
39
|
+
|
|
40
|
+
## Risks and Failure Conditions
|
|
41
|
+
|
|
42
|
+
- **Seriality of boundary matrix reduction**: The core algorithm is inherently serial, with GPU parallelism far below that of GEMM, making it infeasible for large-scale data
|
|
43
|
+
- **Combinatorial explosion**: The number of simplices in the VR complex grows exponentially with dimension; truncation to 2--3 dimensions is mandatory
|
|
44
|
+
- **Non-differentiability**: The discrete combinatorial structure of the barcode is non-differentiable with respect to input point positions (at birth/death events); differentiable proxies such as landscapes/images are required
|
|
45
|
+
- **Subjectivity of scale selection**: The scale range and truncation threshold for the filtration must be chosen manually
|
|
46
|
+
- **Topology is not geometry**: Persistent homology captures only topological invariants, losing metric information (distances, angles), which may be insufficient to distinguish different datasets
|
|
47
|
+
- **Subsampling bias**: Large datasets must be subsampled, and persistence diagrams from different subsamples may differ significantly
|
|
48
|
+
|
|
49
|
+
## Further References
|
|
50
|
+
|
|
51
|
+
- Distillation notes: references/books/smooth-manifolds.md (Ch 17--18 De Rham Cohomology, conceptual origin of topological invariants)
|
|
52
|
+
- Distillation notes: references/books/algebraic-geometry-rising-sea.md (Section 18 Cech Cohomology, Section 23 Derived Functors, cohomology computations)
|
|
53
|
+
- Original text: John M. Lee, *Introduction to Smooth Manifolds*, Ch 17--18 (de Rham cohomology)
|
|
54
|
+
- Extended reading: Edelsbrunner & Harer, *Computational Topology: An Introduction* (standard textbook on persistent homology)
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# 持续同调 (Persistent Homology)
|
|
2
|
+
|
|
3
|
+
## 最小定义
|
|
4
|
+
|
|
5
|
+
持续同调追踪拓扑空间在不同尺度 $\epsilon$ 下的同调群 $H_k$ 变化:当 $\epsilon$ 从 0 增大时,拓扑特征(连通分量、洞、空腔)在某个尺度"诞生",在更大尺度"消亡"。存活时间长的特征是数据的本质拓扑结构,短命的视为噪声。输出是 barcode/persistence diagram。
|
|
6
|
+
|
|
7
|
+
## 核心公式
|
|
8
|
+
|
|
9
|
+
- 滤过(filtration):$\emptyset = K_0 \subseteq K_1 \subseteq \cdots \subseteq K_n = K$(如 Vietoris-Rips 复形 $VR_\epsilon$)
|
|
10
|
+
- Vietoris-Rips 复形:$VR_\epsilon = \{\sigma \subseteq X \mid d(x_i, x_j) \leq \epsilon, \forall x_i, x_j \in \sigma\}$
|
|
11
|
+
- 持续同调群:$H_k^{i,j} = \text{im}(H_k(K_i) \to H_k(K_j))$
|
|
12
|
+
- 持续图(persistence diagram):$D_k = \{(b_l, d_l)\}$,$b_l$ 为诞生尺度,$d_l$ 为消亡尺度
|
|
13
|
+
- Bottleneck 距离:$d_B(D, D') = \inf_\gamma \sup_x \|x - \gamma(x)\|_\infty$
|
|
14
|
+
- 持续性景观(persistence landscape):$\lambda_k(t) = \sup\{m \mid \text{rank } H_k^{t-m, t+m} \geq k\}$
|
|
15
|
+
|
|
16
|
+
## 适用问题
|
|
17
|
+
|
|
18
|
+
- 点云数据的拓扑特征提取:检测聚类数、环、空腔等全局结构
|
|
19
|
+
- 隐空间质量评估:VAE/GAN 生成的隐空间是否保留了数据的拓扑结构
|
|
20
|
+
- 时间序列分析:Takens 嵌入后的持续同调揭示动力学拓扑
|
|
21
|
+
- 图/网络分析:检测社区结构、瓶颈、高阶关联
|
|
22
|
+
|
|
23
|
+
## AI 设计翻译
|
|
24
|
+
|
|
25
|
+
- **拓扑正则化损失**:$L_{\text{topo}} = d_B(D_{\text{latent}}, D_{\text{data}})$,强制隐空间的持续图匹配数据的持续图,保持拓扑
|
|
26
|
+
- **持续图特征化层**:将 persistence diagram 转为固定维向量(persistence image/landscape/silhouette),作为下游分类/回归的输入
|
|
27
|
+
- **拓扑感知的聚类**:用 $H_0$ 的持续区间自动确定聚类数,长存活连通分量 = 真实簇
|
|
28
|
+
- **隐空间拓扑监控**:训练中实时计算 latent space 的 $H_1$(洞),检测拓扑坍塌(所有洞消失 = 后验坍塌)
|
|
29
|
+
|
|
30
|
+
## 工程可行性
|
|
31
|
+
|
|
32
|
+
GPU 友好度有限,是持续同调落地的主要瓶颈:
|
|
33
|
+
- **距离矩阵计算**:$O(n^2)$,batched 成对距离,GPU 友好
|
|
34
|
+
- **Vietoris-Rips 构建**:组合爆炸,$n$ 个点的 VR 复形最多 $2^n$ 个单纯形;实践中截断到 2-维,$O(n^3)$ 最坏
|
|
35
|
+
- **边界矩阵约化(核心算法)**:类似高斯消元的列约化,**高度串行**,标准算法不可并行化
|
|
36
|
+
- **GPU 加速的约化算法**:如 Ripser 的 clearing 优化 + GPU 版约化(Emerald 等),可加速 10-100x,但仍不及 GEMM 的并行度
|
|
37
|
+
- **可微替代**:persistence image 是可微的(对点位置的梯度可算),但 barcode 本身在诞生/消亡点不可微
|
|
38
|
+
- 复杂度:精确计算最坏 $O(n^3)$(2 维 VR),大规模点云($n > 10^4$)需要子采样
|
|
39
|
+
|
|
40
|
+
## 风险与失效条件
|
|
41
|
+
|
|
42
|
+
- **边界矩阵约化的串行性**:核心算法本质串行,GPU 并行度远低于 GEMM,大规模数据不可行
|
|
43
|
+
- **组合爆炸**:VR 复形的单纯形数随维数指数增长,必须截断到 2-3 维
|
|
44
|
+
- **不可微性**:barcode 的离散组合结构对输入点位置不可微(在诞生/消亡事件处),需要 landscape/image 等可微代理
|
|
45
|
+
- **尺度选择的主观性**:滤过的尺度范围和截断阈值需要手动选择
|
|
46
|
+
- **拓扑 ≠ 几何**:持续同调只捕捉拓扑不变量,丢失度量信息(距离、角度),可能不够区分不同数据集
|
|
47
|
+
- **子采样偏差**:大规模数据必须子采样,不同子采样的持续图可能有显著差异
|
|
48
|
+
|
|
49
|
+
## 深入参考
|
|
50
|
+
|
|
51
|
+
- 蒸馏稿:references/books/smooth-manifolds.md(Ch 17-18 De Rham Cohomology,拓扑不变量概念来源)
|
|
52
|
+
- 蒸馏稿:references/books/algebraic-geometry-rising-sea.md(§18 Cech Cohomology, §23 Derived Functors,上同调计算)
|
|
53
|
+
- 原书:John M. Lee, *Introduction to Smooth Manifolds*, Ch 17-18(de Rham 上同调)
|
|
54
|
+
- 延伸:Edelsbrunner & Harer, *Computational Topology: An Introduction*(持续同调标准教材)
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Algorithmic Lens
|
|
2
|
+
|
|
3
|
+
> Algorithms are the automation of thought — converting insights into precise, repeatable steps.
|
|
4
|
+
|
|
5
|
+
## What Perspective It Offers
|
|
6
|
+
|
|
7
|
+
This is an "engineer's" perspective — decomposing problems into finitely executable steps, evaluating costs, and judging feasibility. Its first principle is not "how to solve it," but rather "whether it is solvable and at what cost." Some problems are inherently difficult (NP-complete), and some are inherently unsolvable (undecidable); understanding these limits is as important as finding solutions. Every problem should first be asked: to which complexity class does it belong?
|
|
8
|
+
|
|
9
|
+
## What Problems It Is Suited to Diagnose
|
|
10
|
+
|
|
11
|
+
- Automating processes — applying the same operation repeatedly to large volumes of data
|
|
12
|
+
- Estimating computational cost — evaluating time / space consumption before large-scale execution
|
|
13
|
+
- Judging feasibility — determining whether a problem is in P / NP-hard / undecidable to decide on a solution strategy
|
|
14
|
+
- Confronting combinatorial explosion — search spaces that grow exponentially with input size, requiring pruning or approximation
|
|
15
|
+
|
|
16
|
+
## What Problems It Is Not Suited For
|
|
17
|
+
|
|
18
|
+
- Problems with closed-form solutions that yield answers directly — algorithmization only adds complexity
|
|
19
|
+
- Problems that are inherently qualitative rather than procedural — they cannot be reduced to finite steps
|
|
20
|
+
- Unstructured inputs that cannot be discretized — when preprocessing is more complex than the core problem itself
|
|
21
|
+
|
|
22
|
+
## Which Knowledge Domains It Routes To
|
|
23
|
+
|
|
24
|
+
- Complexity theory (P / NP / undecidability): the fundamental framework for judging problem feasibility
|
|
25
|
+
- Algorithmic paradigms (divide-and-conquer / dynamic programming / greedy / backtracking / randomized): core design decisions that determine the subsequent path
|
|
26
|
+
- Data structures: storage and query efficiency directly affects algorithmic performance
|
|
27
|
+
- Computation theory (Turing machines / the halting problem): understanding the absolute boundaries of computability
|
|
28
|
+
|
|
29
|
+
## What AI Designs It May Inspire
|
|
30
|
+
|
|
31
|
+
- Complexity classifier: input → automatic determination of P / NP-hard / undecidable, with recommended response strategies
|
|
32
|
+
- Algorithmic paradigm selector: automatic paradigm selection based on subproblem independence / overlap / greedy properties
|
|
33
|
+
- Correctness verification pipeline: automated checking of loop invariants + structural induction + termination proofs
|
|
34
|
+
|
|
35
|
+
## Reasoning Protocol
|
|
36
|
+
|
|
37
|
+
1. **Formalize the specification**: Define the input domain, output domain, and constraints; write pre-condition and post-condition predicates
|
|
38
|
+
2. **Judge feasibility**: To which complexity class does the problem belong? P → exact algorithm; NP-hard → approximation / heuristics; undecidable → restricted version
|
|
39
|
+
3. **Select a paradigm**: Independent → divide-and-conquer; overlapping → dynamic programming; greedy property → greedy; structured search → backtracking; high deterministic cost → randomized
|
|
40
|
+
4. **Analyze complexity**: Provide time O(f(n)) and space O(g(n)); distinguish worst-case from average-case; attend to constant factors
|
|
41
|
+
5. **Prove correctness**: Use loop invariants / structural induction / termination proofs to ensure algorithmic reliability
|
|
42
|
+
|
|
43
|
+
## Acceptance Criteria
|
|
44
|
+
|
|
45
|
+
- Input / output specifications have been formalized; pre- and post-conditions can be expressed as predicates
|
|
46
|
+
- Complexity is given in terms of time order and space order, annotated with worst-case / average-case scenarios
|
|
47
|
+
- Feasibility class has been determined (P / NP-hard / undecidable), with a corresponding response strategy stated
|
|
48
|
+
- A correctness proof has been provided (loop invariant or inductive strategy), annotated as proved / unproved
|
|
49
|
+
- Optimization recommendations are based on bottleneck analysis rather than blind parameter tuning
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# 算法透镜 / Algorithmic Lens
|
|
2
|
+
|
|
3
|
+
> 算法是思想的自动化——将洞察转化为可重复执行的精确步骤。
|
|
4
|
+
|
|
5
|
+
## 它是什么视角
|
|
6
|
+
|
|
7
|
+
这是一种"工程师"的视角——把问题拆解为有限可执行步骤,评估代价,判断可行性。它的第一原则不是"如何求解",而是"是否可解、代价几何"。某些问题本质困难(NP 完全),某些本质不可解(不可判定),了解这些极限与找到解同样重要。每一个问题都应先问:它属于哪个复杂度类?
|
|
8
|
+
|
|
9
|
+
## 适合诊断什么问题
|
|
10
|
+
|
|
11
|
+
- 需要将过程自动化——同一操作对大量数据反复执行
|
|
12
|
+
- 需要估算计算代价——大规模运行前评估时间/空间消耗
|
|
13
|
+
- 需要判断可行性——确定 P / NP-hard / 不可判定,决定求解策略
|
|
14
|
+
- 面对组合爆炸——搜索空间随输入指数增长,需剪枝或近似
|
|
15
|
+
|
|
16
|
+
## 不适合什么问题
|
|
17
|
+
|
|
18
|
+
- 问题有闭式解可直接给出答案——算法化反增复杂度
|
|
19
|
+
- 问题本质是定性的而非程序性的——无法化为有限步骤
|
|
20
|
+
- 输入无结构且无法离散化——预处理比核心问题更复杂时
|
|
21
|
+
|
|
22
|
+
## 会路由到哪些知识域
|
|
23
|
+
|
|
24
|
+
- 复杂度理论(P/NP/不可判定):判断问题可行性的根本框架
|
|
25
|
+
- 算法范式(分治/动规/贪心/回溯/随机化):核心设计决策决定后续路径
|
|
26
|
+
- 数据结构:存储与查询的效率直接影响算法性能
|
|
27
|
+
- 计算理论(图灵机/停机问题):理解可计算性的绝对边界
|
|
28
|
+
|
|
29
|
+
## 可能产生哪些 AI 设计
|
|
30
|
+
|
|
31
|
+
- 复杂度分类器:输入→自动判断 P/NP-hard/不可判定,推荐应对策略
|
|
32
|
+
- 算法范式选择器:根据子问题独立性/重叠性/贪心性质自动选范式
|
|
33
|
+
- 正确性验证管线:循环不变量 + 结构归纳 + 终止证明的自动化检查
|
|
34
|
+
|
|
35
|
+
## 推理协议
|
|
36
|
+
|
|
37
|
+
1. **形式化规格**:定义输入域、输出域、约束条件,写出前置/后置条件谓词
|
|
38
|
+
2. **判断可行性**:问题属于哪个复杂度类?P → 精确算法;NP-hard → 近似/启发式;不可判定 → 受限版本
|
|
39
|
+
3. **选择范式**:独立→分治、重叠→动规、贪心性质→贪心、结构化搜索→回溯、确定性代价高→随机化
|
|
40
|
+
4. **分析复杂度**:给出时间 O(f(n)) 和空间 O(g(n)),区分最坏与平均,关注常数因子
|
|
41
|
+
5. **证明正确性**:用循环不变量/结构归纳/终止证明确保算法可靠
|
|
42
|
+
|
|
43
|
+
## 验收标准
|
|
44
|
+
|
|
45
|
+
- 输入/输出规格已形式化,前置/后置条件可写成谓词
|
|
46
|
+
- 复杂度已给出时间阶和空间阶,标注最坏/平均场景
|
|
47
|
+
- 可行性类别已判定(P/NP-hard/不可判定),应对策略已说明
|
|
48
|
+
- 正确性证明已给出(循环不变量或归纳策略),标注已证/未证
|
|
49
|
+
- 优化建议基于瓶颈分析而非盲目调参
|