math-skill 2.0.1 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en-US.md +40 -7
- package/README.md +40 -7
- package/agents/math-critic.en.md +235 -0
- package/agents/math-critic.md +2 -0
- package/commands/abstraction.md +1 -3
- package/commands/algorithmic-thinking.md +1 -3
- package/commands/ask.md +1 -3
- package/commands/axiomatization.md +1 -3
- package/commands/causal-inference.md +1 -3
- package/commands/discrete-combinatorial.md +1 -3
- package/commands/game-theory.md +1 -3
- package/commands/induction-analogy.md +1 -3
- package/commands/information-theory.md +1 -3
- package/commands/logic-deduction.md +1 -3
- package/commands/modeling.md +1 -3
- package/commands/optimization.md +1 -3
- package/commands/probability-statistics.md +1 -3
- package/commands/symmetry-invariance.md +1 -3
- package/commands/topological-thinking.md +1 -3
- package/commands/transformation.md +1 -3
- package/knowledge-base/overview.en.md +228 -0
- package/knowledge-base/overview.md +2 -0
- package/package.json +4 -2
- package/references/agentic-workflow.en.md +53 -0
- package/references/agentic-workflow.md +2 -0
- package/references/books/abstract-algebra.md +4 -0
- package/references/books/algebraic-geometry-rising-sea.md +4 -0
- package/references/books/differential-geometry.md +4 -0
- package/references/books/matrix-analysis.md +4 -0
- package/references/books/micro-lie-theory.md +4 -0
- package/references/books/optimization-ml.md +4 -0
- package/references/books/smooth-manifolds.md +4 -0
- package/references/gpu-friendly-math.en.md +65 -0
- package/references/gpu-friendly-math.md +2 -0
- package/references/inspiration.en.md +113 -0
- package/references/inspiration.md +2 -0
- package/skills/abstraction/SKILL.en.md +117 -0
- package/skills/abstraction/SKILL.md +2 -0
- package/skills/abstraction/original-texts.en.md +163 -0
- package/skills/algorithmic-thinking/SKILL.en.md +132 -0
- package/skills/algorithmic-thinking/SKILL.md +2 -0
- package/skills/algorithmic-thinking/original-texts.en.md +253 -0
- package/skills/axiomatization/SKILL.en.md +144 -0
- package/skills/axiomatization/SKILL.md +2 -0
- package/skills/axiomatization/original-texts.en.md +154 -0
- package/skills/causal-inference/SKILL.en.md +147 -0
- package/skills/causal-inference/SKILL.md +2 -0
- package/skills/causal-inference/original-texts.en.md +136 -0
- package/skills/discrete-combinatorial/SKILL.en.md +124 -0
- package/skills/discrete-combinatorial/SKILL.md +2 -0
- package/skills/discrete-combinatorial/original-texts.en.md +184 -0
- package/skills/game-theory/SKILL.en.md +117 -0
- package/skills/game-theory/SKILL.md +2 -0
- package/skills/game-theory/original-texts.en.md +131 -0
- package/skills/induction-analogy/SKILL.en.md +145 -0
- package/skills/induction-analogy/SKILL.md +2 -0
- package/skills/induction-analogy/original-texts.en.md +140 -0
- package/skills/information-theory/SKILL.en.md +134 -0
- package/skills/information-theory/SKILL.md +2 -0
- package/skills/information-theory/original-texts.en.md +127 -0
- package/skills/logic-deduction/SKILL.en.md +130 -0
- package/skills/logic-deduction/SKILL.md +2 -0
- package/skills/logic-deduction/original-texts.en.md +160 -0
- package/skills/math-research-activator/SKILL.en.md +132 -0
- package/skills/math-research-activator/SKILL.md +2 -0
- package/skills/math-research-activator/original-texts.en.md +105 -0
- package/skills/modeling/SKILL.en.md +135 -0
- package/skills/modeling/SKILL.md +2 -0
- package/skills/modeling/original-texts.en.md +162 -0
- package/skills/optimization/SKILL.en.md +129 -0
- package/skills/optimization/SKILL.md +2 -0
- package/skills/optimization/original-texts.en.md +167 -0
- package/skills/probability-statistics/SKILL.en.md +146 -0
- package/skills/probability-statistics/SKILL.md +2 -0
- package/skills/probability-statistics/original-texts.en.md +191 -0
- package/skills/symmetry-invariance/SKILL.en.md +135 -0
- package/skills/symmetry-invariance/SKILL.md +2 -0
- package/skills/symmetry-invariance/original-texts.en.md +206 -0
- package/skills/topological-thinking/SKILL.en.md +124 -0
- package/skills/topological-thinking/SKILL.md +2 -0
- package/skills/topological-thinking/original-texts.en.md +134 -0
- package/skills/transformation/SKILL.en.md +120 -0
- package/skills/transformation/SKILL.md +2 -0
- package/skills/transformation/original-texts.en.md +204 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: abstraction
|
|
3
|
+
description: |
|
|
4
|
+
Trigger when extracting mathematical structures from complex problems, discovering cross-domain commonalities, building general theories; or finding transferable abstract structures (category/algebra/topology) for algorithm/operator design.
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# 🧩 Abstraction
|
|
8
|
+
|
|
9
|
+
> "The power of mathematics lies in abstraction: ignoring contingent details to reveal necessary structures."
|
|
10
|
+
>
|
|
11
|
+
> — Algebra, Topology, Category Theory
|
|
12
|
+
|
|
13
|
+
## Core Principle
|
|
14
|
+
|
|
15
|
+
**Abstraction is not distancing from reality but penetrating into it — by stripping away superficial, contingent details, one reveals deep, essential structures. Problems from different domains often share the same abstract structure.** In the context of this skill pack, abstraction is the core operation of "cross-domain activation": transferring structures from algebraic geometry / topology to algorithm design relies on identifying the abstract structures shared by both.
|
|
16
|
+
|
|
17
|
+
Three progressive levels of abstraction: **Distillation** (identifying common structure across multiple instances) → **Generalization** (extending theorems from special to general cases) → **Structurization** (reconstructing the entire problem domain in the language of structure).
|
|
18
|
+
|
|
19
|
+
> **Mathematical Formalization**
|
|
20
|
+
>
|
|
21
|
+
> Category-theoretic perspective: Objects and morphisms form a category **C**; functors **F, G : C → D** preserve structure; natural transformations **η : F ⇒ G** relate functors; **Yoneda Lemma**: Hom(Hom(−, A), F) ≅ F(A), i.e., an object is completely determined by all morphisms pointing to it.
|
|
22
|
+
>
|
|
23
|
+
> Algebraic perspective: Groups (closure, associativity, identity, inverse); rings (additive group + multiplicative semigroup + distributivity); fields (ring + multiplicative inverses); modules (vector spaces over a ring); lattices (partially ordered set + meet and join).
|
|
24
|
+
|
|
25
|
+
## GPU-Friendliness (Cross-Cutting Check)
|
|
26
|
+
|
|
27
|
+
Whether an abstract structure can be deployed on GPU depends on the computational form it takes once "concretized" — pass the eight dimensions of `../../references/gpu-friendly-math.md`:
|
|
28
|
+
|
|
29
|
+
- **Category / algebraic structure → GEMM**: If the abstract structure can be concretized as linear maps (e.g., restriction maps, group representations), it naturally maps to Tensor Core GEMM (friendly).
|
|
30
|
+
- **Universal constructions (products / coproducts / limits)**: If materialized as large intermediate tensors, memory explodes (unfriendly) → refactor into chunked / streaming or low-rank approximations.
|
|
31
|
+
- **Yoneda perspective**: Replace internal structure with Hom-behavior — if the Hom-sets themselves are huge, the construction is non-computable; friendly only when Hom can be batch-tensorized.
|
|
32
|
+
- **Anti-pattern**: Forcing an essentially discrete/symbolic abstraction (e.g., exact computation of general cohomology) into training is often "beautiful but not computable."
|
|
33
|
+
|
|
34
|
+
Eight-dimension minimum assessment (formal terminology): **Tensorization** — whether abstract objects can be concretized as batched tensors; **GEMM-Mappability** — whether morphisms / representations / restriction maps can reduce to linear maps; **Complexity** — whether the abstraction layer introduces super-linear global constructions; **Memory & KV-Cache** — whether products / limits / Hom tables are materialized; **Low-Precision Stability** — whether concretization depends on ill-conditioned inversion or exact symbolic equalities; **Parallelism & Communication** — whether the construction is locally block-decomposable; **Sparsity Structure** — whether it yields block/banded structure rather than random access; **Operator Fusion** — whether abstract interfaces can converge into a small number of fused kernels.
|
|
35
|
+
|
|
36
|
+
> In conjunction with `../../references/books/algebraic-geometry-rising-sea.md`, `abstract-algebra.md`, `smooth-manifolds.md`.
|
|
37
|
+
|
|
38
|
+
## When NOT to Use
|
|
39
|
+
|
|
40
|
+
- **Every detail is critical** (e.g., debugging a specific bug) — abstraction would discard key information.
|
|
41
|
+
- **A specific numerical answer is needed** (e.g., "what is this integral equal to") — abstraction does not provide concrete calculations.
|
|
42
|
+
- **The problem is already in its simplest form** — no further abstraction is needed.
|
|
43
|
+
|
|
44
|
+
## When to Use
|
|
45
|
+
|
|
46
|
+
- When facing a complex problem and not knowing where to start — first abstract out the core structure.
|
|
47
|
+
- When two seemingly different problems share similarities — seek a common abstract framework.
|
|
48
|
+
- When generalizing specific experience into general rules, or building cross-domain general models/theories.
|
|
49
|
+
- **Transferring modern math structures to algorithm/operator design** — identifying the abstract structure the problem shares with algebraic geometry / topology / Lie theory.
|
|
50
|
+
|
|
51
|
+
## Method
|
|
52
|
+
|
|
53
|
+
### Step 1: Describe the Concrete Problem
|
|
54
|
+
Precisely describe all elements of the problem in mathematical language — objects, relations, constraints, objectives. Abstraction begins with the concrete: before abstracting, one must fully understand the concrete objects.
|
|
55
|
+
|
|
56
|
+
### Step 2: Distinguish Essential from Non-Essential Features
|
|
57
|
+
Examine each feature one by one: if this feature is changed, does the core structure of the problem change? **Essential features** (those whose change fundamentally alters the nature of the problem) must be retained; **non-essential features** (those whose change leaves the structure invariant) can be ignored. Example: when studying matrix invertibility, the specific entries are non-essential (invariant under similarity transformations), while rank is essential.
|
|
58
|
+
|
|
59
|
+
### Step 3: Extract the Abstract Structure
|
|
60
|
+
Choose the best-matching perspective from four mathematical viewpoints and execute its operations:
|
|
61
|
+
|
|
62
|
+
- **Category-theoretic perspective** (focus on relations between objects): Identify "objects" and "morphisms/relations"; check that morphisms compose and have identities → forming a category; further check for functors to known categories, natural transformations relating different functors.
|
|
63
|
+
- **Algebraic perspective** (focus on operations and axioms): Identify "operations" and their properties (closure / associativity / commutativity / distributivity); match axioms against group / ring / field / module / lattice; determine the best-matching structure.
|
|
64
|
+
- **Topological perspective** (focus on continuity and connectedness): Identify "continuous change / proximity / connected-separated"; construct open-set structure and verify topological axioms; identify topological invariants (connectedness, compactness, fundamental group).
|
|
65
|
+
- **Analytic perspective** (focus on metrics and norms): Identify "distance / size / convergence"; verify metric/norm axioms; determine properties such as completeness/boundedness, and invoke the corresponding theorems (e.g., Banach space theory).
|
|
66
|
+
|
|
67
|
+
### Step 4: Solve at the Abstract Level
|
|
68
|
+
Leverage existing theory of the abstract structure. Key tools:
|
|
69
|
+
- **Universal constructions**: Products (unified projections), coproducts (unified embeddings), limits/colimits (merging and gluing under compatibility conditions).
|
|
70
|
+
- **Yoneda Lemma insight**: An object is completely determined by all morphisms pointing to it; to understand X, examine Hom(A,X) / Hom(X,A); to prove two objects are isomorphic, it suffices to show their morphism behavior is identical.
|
|
71
|
+
|
|
72
|
+
### Step 5: Concretize Back
|
|
73
|
+
Precisely translate each element of the abstract solution back into the mathematical language of the original problem, ensuring every step has a correspondence. After abstraction, one must return to the concrete; otherwise abstraction loses its meaning.
|
|
74
|
+
|
|
75
|
+
### Step 6: Verify
|
|
76
|
+
Is key information fully preserved through the round trip? Does the answer to the original problem have a clear counterpart in the abstract solution? After translating back to the concrete, does it indeed solve the original problem? Has any essential feature been accidentally overlooked?
|
|
77
|
+
|
|
78
|
+
### Step 7: Level Progression
|
|
79
|
+
- **Distillation → Generalization**: When the distilled concept has been verified across multiple instances, and the theorem's natural extension appears to hold under broader conditions → generalize.
|
|
80
|
+
- **Generalization → Structurization**: When generalized theorems have accumulated enough to support a self-consistent system, and different generalizations are systematically related → structurize.
|
|
81
|
+
- **No premature leaps**: If distilled concepts have not been verified across enough instances, do not rashly generalize; if generalized theorems are scattered and unsystematic, do not rashly structurize.
|
|
82
|
+
|
|
83
|
+
## Common Errors
|
|
84
|
+
|
|
85
|
+
| Error | Critique | Correct Approach |
|
|
86
|
+
|---|---|---|
|
|
87
|
+
| Over-abstraction | Abstracting away essential details, distorting the problem (e.g., dropping group inverses and retaining only a semigroup) | After each abstraction, check whether key information is preserved |
|
|
88
|
+
| Under-abstraction | Retaining too many non-essential details, failing to achieve simplification | Repeatedly ask: is this detail truly necessary? |
|
|
89
|
+
| Abstracting to the wrong level | Using category theory for a problem that only needs group theory; or using only set theory for a problem with group structure | Choose the level matching the problem's complexity |
|
|
90
|
+
| Forgetting the functorial perspective | Looking only at internal object structure while ignoring morphisms, losing half the information | Simultaneously examine Hom(A,X) and Hom(X,A) |
|
|
91
|
+
| Forgetting to return to the concrete | Staying at the abstract level without translating back to the original problem | After abstraction is complete, concretization is mandatory |
|
|
92
|
+
| Abstract structure is non-computable | Forcing an essentially discrete/symbolic abstraction into GPU training | After concretization, pass the GPU eight-dimension gate; if non-computable, adapt or abandon |
|
|
93
|
+
|
|
94
|
+
## Operating Procedure
|
|
95
|
+
|
|
96
|
+
When this skill is triggered, the output must contain:
|
|
97
|
+
|
|
98
|
+
1. **[Problem Description]:[Concrete]** — Precisely describe all elements of the problem in mathematical language
|
|
99
|
+
2. **[Essential / Non-Essential]:[Distinction]** — List essential and non-essential features, annotating for each whether changing it affects the core structure
|
|
100
|
+
3. **[Perspective Choice]:[One of Four]** — Select the best match from category-theoretic / algebraic / topological / analytic, and execute its operational steps
|
|
101
|
+
4. **[Abstract Solution]:[Construction]** — Using universal constructions or the Yoneda perspective, provide a solution direction at the abstract level
|
|
102
|
+
5. **[Concretization]:[Translation]** — Precisely translate the abstract solution back into the mathematical language of the original problem
|
|
103
|
+
6. **[Verification]:[Check]** — Is key information fully preserved through the round trip?
|
|
104
|
+
7. **[Level Assessment]:[Progression]** — Indicate which level (distillation / generalization / structurization) is current, and assess whether a leap is warranted
|
|
105
|
+
8. **[GPU Feasibility]** (if used for algorithm/operator design) — After concretizing the abstract structure, pass the eight-dimension gate, rating friendly / retrofittable / unfriendly
|
|
106
|
+
|
|
107
|
+
**Output must never provide analysis alone without a conclusion.**
|
|
108
|
+
|
|
109
|
+
## Relations to Other Skills
|
|
110
|
+
|
|
111
|
+
- **Axiomatization**: Abstraction is the precursor to axiomatization — first abstract the essentials, then choose the axioms.
|
|
112
|
+
- **Modeling**: Modeling is the concrete application of abstraction — abstracting real-world problems into mathematical ones.
|
|
113
|
+
- **Transformation**: A transformation can be seen as a form of abstraction — finding simple structure in a new representation.
|
|
114
|
+
- **Induction and Analogy**: Analogy is essentially identifying the shared abstract structure between two different domains.
|
|
115
|
+
- **Topological Thinking**: Topological abstraction focuses on continuity and connectedness; it is the concrete form of abstraction in spatial problems.
|
|
116
|
+
- **Algorithmic Thinking**: Algorithmic abstraction focuses on the structure of computational processes, abstracting concrete implementations into algorithmic patterns and complexity classes.
|
|
117
|
+
- **Modern Math Activation**: `../../references/books/algebraic-geometry-rising-sea.md` (sheaves/categories → attention), `abstract-algebra.md` (groups/semirings → equivariance and routing), `smooth-manifolds.md` (manifold structure → latent-space geometry).
|
|
@@ -5,6 +5,8 @@ description: |
|
|
|
5
5
|
English: Trigger when extracting mathematical structures from complex problems, discovering cross-domain commonalities, building general theories; or finding transferable abstract structures (category/algebra/topology) for algorithm/operator design.
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
+
> **语言路由**:若用户消息为英文,请读取并遵循同目录下的 `SKILL.en.md`,按其操作规程以英文输出;中文消息则继续使用本文件。
|
|
9
|
+
|
|
8
10
|
# 🧩 抽象化思想 / Abstraction
|
|
9
11
|
|
|
10
12
|
> "数学的力量在于抽象:忽略偶然细节,揭示必然结构。"
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
# Mathematical Sources and Classic Texts
|
|
2
|
+
|
|
3
|
+
## Galois Theory (1830s)
|
|
4
|
+
|
|
5
|
+
> "The profundity of Galois theory: it transforms the question 'can an equation be solved by radicals?' into the structural question 'is the permutation group solvable?'"
|
|
6
|
+
|
|
7
|
+
**Abstract paradigm**: Galois theory represents the earliest systematic abstraction in the history of mathematics — rising from concrete equation-solving to the symmetry structure of groups.
|
|
8
|
+
- The permutation group of roots determines the solvability of an equation
|
|
9
|
+
- The Galois correspondence: subgroups ↔ subfields, directly linking algebra to structure
|
|
10
|
+
- Far-reaching influence: inaugurated the mode of thinking "replace calculation with structure," laying the foundation for abstract algebra
|
|
11
|
+
|
|
12
|
+
**History**: Évariste Galois (1811–1832), unrecognized during his lifetime; his manuscripts were published by Liouville in 1846.
|
|
13
|
+
|
|
14
|
+
## Dedekind & Noether — From Numbers to Structures
|
|
15
|
+
|
|
16
|
+
> "Dedekind abstracted integers from 'counting tools' into 'ideals of rings'; Noether systematized this, making ideals the central objects of algebra."
|
|
17
|
+
|
|
18
|
+
**Key contributions**:
|
|
19
|
+
- **Dedekind (1831–1916)**: Founder of ideal theory — abstracted "divisibility" into "containment relations," elevating number theory to a structural level
|
|
20
|
+
- **Emmy Noether (1882–1935)**:
|
|
21
|
+
- Noetherian rings: the ascending chain condition abstracts "finiteness" from concrete objects to a structural property
|
|
22
|
+
- Noether's theorem (1918): symmetries ↔ conservation laws in physics — a paradigm of abstract structure in physics
|
|
23
|
+
- Transformed abstract algebra from a "computational" to a "structural" discipline
|
|
24
|
+
|
|
25
|
+
> "Noether's teaching mode: 'Es steht schon bei Dedekind' (Dedekind already wrote it) — she always traced ideas back to their structural origins."
|
|
26
|
+
|
|
27
|
+
## Category Theory (Eilenberg & Mac Lane, 1945)
|
|
28
|
+
|
|
29
|
+
> "The key idea of category theory: studying the morphisms (maps) between objects is more important than studying the objects themselves."
|
|
30
|
+
|
|
31
|
+
**Core concepts**:
|
|
32
|
+
- **Objects** and **Morphisms**
|
|
33
|
+
- **Functors**: Maps between categories
|
|
34
|
+
- **Natural Transformations**: Maps between functors
|
|
35
|
+
- **Universal Properties**: Defining objects through their relations
|
|
36
|
+
|
|
37
|
+
**The significance of abstraction**: Category theory is "the mathematics of mathematics" — it is abstract enough to describe the structure of mathematics itself.
|
|
38
|
+
|
|
39
|
+
## Yoneda Lemma (1954)
|
|
40
|
+
|
|
41
|
+
> "An object is completely determined by its relationships to all other objects — this is the fundamental theorem of category theory."
|
|
42
|
+
|
|
43
|
+
**Mathematical meaning**:
|
|
44
|
+
- Formal statement: Hom(Hom(A, —), F) ≅ F(A) — there is a one-to-one correspondence between natural transformations of a functor and the functor's evaluation at A
|
|
45
|
+
- Philosophical significance: To understand a thing, one need only observe its interactions with everything else — "you are defined by your relationships"
|
|
46
|
+
- The Yoneda embedding: every object A ↦ Hom(—, A); an object can be fully embedded into its "relational world"
|
|
47
|
+
- Called the "first theorem" of category theory, its status is analogous to the axiom of extensionality in set theory
|
|
48
|
+
|
|
49
|
+
**History**: First appeared in Nobuo Yoneda's unpublished notes, later formally expounded by Mac Lane in 1954.
|
|
50
|
+
|
|
51
|
+
## Bourbaki (1935–)
|
|
52
|
+
|
|
53
|
+
> "Bourbaki rewrote 20th-century mathematics with 'structures' as a unifying language — from mother structures (algebra, order, topology), everything is structure."
|
|
54
|
+
|
|
55
|
+
**Core ideas**:
|
|
56
|
+
- Three mother structures: algebraic, order, and topological
|
|
57
|
+
- Multiple structures: formed by combining mother structures — topological groups, ordered fields, etc.
|
|
58
|
+
- *Éléments de mathématique*: a systematic rewrite spanning over 40 volumes
|
|
59
|
+
- Far-reaching influence: defined the organizational structure and abstract style of modern mathematics textbooks
|
|
60
|
+
|
|
61
|
+
**Controversy**: Bourbaki's structuralist bias was excessively abstract, neglecting probability theory and computational mathematics — yet it was precisely this drive toward abstraction that catalyzed the birth of category theory.
|
|
62
|
+
|
|
63
|
+
## Algebraic Structures
|
|
64
|
+
|
|
65
|
+
Abstract algebra reveals deep commonalities among diverse mathematical objects:
|
|
66
|
+
|
|
67
|
+
| Structure | Operational Requirements | Examples |
|
|
68
|
+
|-----------|-------------------------|----------|
|
|
69
|
+
| Semigroup | Closure, associativity | Function composition, string concatenation |
|
|
70
|
+
| Monoid | Semigroup + identity element | Natural number addition, list concatenation (including the empty list) |
|
|
71
|
+
| Group | Monoid + inverses | Symmetric groups, the additive group of integers |
|
|
72
|
+
| Ring | Group (addition) + semigroup (multiplication) + distributivity | The ring of integers, polynomial rings |
|
|
73
|
+
| Field | Ring + multiplicative inverses (for nonzero elements) | The field of rationals, the field of reals |
|
|
74
|
+
| Vector Space | Additive group over a field + scalar multiplication | ℝⁿ, function spaces |
|
|
75
|
+
|
|
76
|
+
**The significance of intermediate structures**: Semigroups and monoids are not "incomplete groups" — in automata theory, formal languages, and string processing, they are themselves the central objects. Abstraction does not seek the "most complete" structure but extracts precisely the properties that are needed.
|
|
77
|
+
|
|
78
|
+
**The power of abstraction**: Once a theorem is proved at the abstract level, it automatically applies to all instances satisfying that structure.
|
|
79
|
+
|
|
80
|
+
## Universal Algebra (Birkhoff, 1935)
|
|
81
|
+
|
|
82
|
+
> "The central question of universal algebra: which equational classes can be defined by a set of equational axioms?"
|
|
83
|
+
|
|
84
|
+
**Key contributions**:
|
|
85
|
+
- **Birkhoff's Theorem**: A class of algebras is a variety if and only if it is closed under homomorphic images, subalgebras, and direct products (the HSP Theorem)
|
|
86
|
+
- Systematic study of "algebraic structures as such" — not a particular group or ring, but "the common properties of all structures satisfying given axioms"
|
|
87
|
+
- Universal algebra as a precursor to category theory: concepts such as universal properties and free objects already had their prototypes here
|
|
88
|
+
- Relationship to category theory: equational classes = universal objects in the category generated by free algebras
|
|
89
|
+
|
|
90
|
+
## Representation Theory (Frobenius, 1896–)
|
|
91
|
+
|
|
92
|
+
> "Representation theory 'realizes' abstract groups as concrete linear transformations — making invisible symmetries visible."
|
|
93
|
+
|
|
94
|
+
**Core ideas**:
|
|
95
|
+
- Group representation: a group G → GL(V), mapping abstract group elements to matrices
|
|
96
|
+
- Frobenius (1849–1917): Pioneered character theory of groups, using trace functions to capture irreducible representations
|
|
97
|
+
- Irreducible representations: the "atoms" of a group — all representations are built from them
|
|
98
|
+
- Schur's Lemma, Maschke's Theorem, and related results form the complete theory of semisimple algebras
|
|
99
|
+
|
|
100
|
+
**The dual significance of abstraction**: On one hand, representation theory makes abstract objects computable; on the other hand, the classification of representations is itself a higher-level abstract problem.
|
|
101
|
+
|
|
102
|
+
## Free Objects and Universal Constructions
|
|
103
|
+
|
|
104
|
+
> "A free object is the most general object with 'no extra relations' — determined only by relations forced by axioms."
|
|
105
|
+
|
|
106
|
+
**Core concepts**:
|
|
107
|
+
- **Free group**: Generated by an alphabet, with no extra relations beyond the group axioms
|
|
108
|
+
- **Free monoid**: Simply the set of strings — string concatenation is the "freest" associative operation
|
|
109
|
+
- **Universal property formulation**: A free object F(A) satisfies the property that any map A → X (where X is an object in the target structure) extends uniquely to a morphism F(A) → X
|
|
110
|
+
- **Left adjoint**: The left adjoint of the forgetful functor is precisely the free object — the "most general solution" of abstraction
|
|
111
|
+
|
|
112
|
+
**Significance**: Free objects exemplify the paradigm of universal constructions — defining the "most general solution" with "the fewest constraints," then obtaining more specific objects by imposing additional relations.
|
|
113
|
+
|
|
114
|
+
## Grothendieck & Schemes (1950s–60s)
|
|
115
|
+
|
|
116
|
+
> "Grothendieck completely reconstructed algebraic geometry: no longer studying specific curves, but schemes — the most general notion of 'space'."
|
|
117
|
+
|
|
118
|
+
**Revolutionary abstraction**:
|
|
119
|
+
- **Schemes**: Generalized algebraic varieties to allow zero divisors and arbitrary base changes — "space" is no longer a point set but the spectrum of a ring
|
|
120
|
+
- **Topoi**: A notion of "space" more general than topological spaces — a topos is a category rich enough to support an internal logic
|
|
121
|
+
- **Motives**: The conjectural "universal cohomology theory" — the common root of different cohomology theories
|
|
122
|
+
- **Universal construction philosophy**: Grothendieck always sought the "most general" framework first, then solved specific problems within it
|
|
123
|
+
|
|
124
|
+
**Impact**: The EGA/SGA rewrite, spanning over four thousand pages, made algebraic geometry one of the most abstract yet most powerful branches of mathematics. The proof of the Weil conjectures was a direct fruit of this abstract framework.
|
|
125
|
+
|
|
126
|
+
## Topology
|
|
127
|
+
|
|
128
|
+
> "Topology studies properties that remain unchanged under continuous deformations."
|
|
129
|
+
|
|
130
|
+
**Levels of abstraction**:
|
|
131
|
+
- Metric space → topological space: discard distance, retain only the notion of "open sets"
|
|
132
|
+
- Continuous functions → morphisms: discard ε-δ, retain only "the preimage of an open set is open"
|
|
133
|
+
- Homeomorphism → equivalence: spaces that are "the same" in the topological sense
|
|
134
|
+
|
|
135
|
+
**Classic example**: A coffee cup and a donut are homeomorphic in the topological sense — they both have exactly one hole.
|
|
136
|
+
|
|
137
|
+
## Homotopy Type Theory (Voevodsky, 2009–)
|
|
138
|
+
|
|
139
|
+
> "The univalence axiom of homotopy type theory asserts: isomorphic structures are identical — the ultimate form of abstraction."
|
|
140
|
+
|
|
141
|
+
**Core ideas**:
|
|
142
|
+
- **Univalence Axiom**: (A ≃ B) ≃ (A = B) — isomorphism and equality are equivalent
|
|
143
|
+
- Philosophical impact: if two structures agree on all observable properties, they "are" the same — there is no "unobservable" identity
|
|
144
|
+
- **Homotopy levels (h-levels)**: Propositions (h-level 1), sets (h-level 2), group objects (h-level 3), ... — unifying classical logic with topological intuition
|
|
145
|
+
- Voevodsky (1966–2017): Fields Medalist who devoted his later career to establishing mathematics on a new foundation with greater computational reliability
|
|
146
|
+
|
|
147
|
+
**Relationship to category theory**: Homotopy type theory can be viewed as the "internal language" of category theory — in the context of (∞,1)-categories, the univalence axiom arises naturally.
|
|
148
|
+
|
|
149
|
+
## The Nature of Abstraction
|
|
150
|
+
|
|
151
|
+
> "Abstraction means ignoring specific, contingent features and extracting general, essential structures."
|
|
152
|
+
|
|
153
|
+
Abstraction is not a retreat from reality but a deeper engagement with it — by identifying the common structure underlying different phenomena, we can treat them within a unified framework.
|
|
154
|
+
|
|
155
|
+
**The genealogy of abstraction**:
|
|
156
|
+
- Galois (1830s): equations → group structure
|
|
157
|
+
- Dedekind (1870s): numbers → ideals
|
|
158
|
+
- Birkhoff (1935): concrete algebras → equational classes
|
|
159
|
+
- Eilenberg–Mac Lane (1945): concrete mathematics → categories
|
|
160
|
+
- Grothendieck (1960s): concrete spaces → schemes and topoi
|
|
161
|
+
- Voevodsky (2010s): isomorphism → identity
|
|
162
|
+
|
|
163
|
+
Each step of abstraction reveals deeper structure and enables us to address a broader class of problems.
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: algorithmic-thinking
|
|
3
|
+
description: |
|
|
4
|
+
Trigger when a problem needs finite-step solving, algorithm design, complexity analysis (time/space), tractability & parallelism assessment (P/NP-hard/undecidable); or termination/correctness proofs; or designing executable algorithms/operators for GPU (assessing complexity order, parallelism, memory access & fusion).
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# 🖥️ Algorithmic Thinking
|
|
8
|
+
|
|
9
|
+
> "An algorithm is the automation of thought — turning insight into precisely repeatable steps."
|
|
10
|
+
>
|
|
11
|
+
> — Computability Theory, Algorithm Analysis, Complexity Theory
|
|
12
|
+
|
|
13
|
+
## Core Principle
|
|
14
|
+
|
|
15
|
+
**Break problems into executable steps, assess cost, judge feasibility. The first principle is not "how to solve" but "whether it is solvable and at what cost" — some problems are inherently hard (NP-complete), some inherently unsolvable (undecidable); knowing these limits is as important as finding solutions.**
|
|
16
|
+
|
|
17
|
+
> **Mathematical Formalization**
|
|
18
|
+
>
|
|
19
|
+
> A Turing machine M: Σ* → Σ* halts within a finite number of steps. Time complexity T(n) = the maximum number of execution steps for an input of length n; space complexity S(n) = the maximum number of cells used. Church–Turing thesis: anything computable is computable by a Turing machine.
|
|
20
|
+
>
|
|
21
|
+
> Three-tier hierarchy: computable (an algorithm exists) → tractable (a polynomial-time algorithm exists) → intractable (only exponential-time or no algorithm). Computable but intractable is practically equivalent to uncomputable — brute force 2^n is worthless for n=100. P vs NP is precisely the boundary between tractable and intractable.
|
|
22
|
+
>
|
|
23
|
+
> Complexity notation: O(f(n)) upper bound, Ω(f(n)) lower bound, Θ(f(n)) tight bound. Common recurrences: T(n)=2T(n/2)+O(n) → O(n log n); T(n)=T(n-1)+O(n) → O(n²); T(n)=T(n/2)+O(1) → O(log n). Complexity classes: O(1) ⊂ O(log n) ⊂ O(n) ⊂ O(n log n) ⊂ O(n^k) ⊂ O(2^n) ⊂ O(n!).
|
|
24
|
+
>
|
|
25
|
+
> Complexity class definitions: P = polynomial-time decidable; NP-hard = at least as hard as every problem in NP; undecidable = no algorithm can decide it. NP-hard response: approximation (with error bounds) or heuristics (with probabilistic guarantees); undecidable response: find a decidable restricted version.
|
|
26
|
+
>
|
|
27
|
+
> Loop invariant: a property that holds before and after every iteration, which together with the termination condition implies output correctness. Hoare logic: {P} S {Q} — precondition P, after statement S, yields postcondition Q.
|
|
28
|
+
|
|
29
|
+
## GPU-Friendliness (Cross-Cutting Check)
|
|
30
|
+
|
|
31
|
+
Algorithmic thinking is the weapon most directly relevant to GPU — complexity order, parallelism, memory access/communication, and operator fusion directly determine whether an algorithm can run efficiently on GPU. Every algorithm must pass the `../../references/gpu-friendly-math.md` eight-dimension gate:
|
|
32
|
+
|
|
33
|
+
- **Complexity order**: Sub-quadratic O(n log n)/O(n) is friendly (fully utilizes parallel cores); O(n²) is borderline (GEMM is an exception, salvageable by Tensor Cores); O(2^n)/O(n!) is an anti-pattern.
|
|
34
|
+
- **Parallelism and communication**: Divide-and-conquer / data parallelism is friendly (sub-problems are independent, batchable); dependency chains in dynamic programming and serial search in backtracking require adaptation (chunking / skew scanning).
|
|
35
|
+
- **Memory and KV-Cache / Parallelism and communication**: Coalesced access is friendly; butterfly reductions and prefix scans have dependency patterns that require attention to bandwidth; random scatter/gather is unfriendly.
|
|
36
|
+
- **Operator fusion**: Multiple elementwise steps can be fused into a single kernel; algorithms that repeatedly read/write to memory — "beautiful but intractable" — should be rearranged into a single pass.
|
|
37
|
+
|
|
38
|
+
Eight-dimension minimum criteria (formal terms): **Tensorization** requires the main loop to be batchable; **GEMM-mappability** prioritizes expressing the core computation as GEMM/conv/scan; **complexity** must specify both time and space order; **memory and KV-cache** checks whether intermediate tables, state, and cache can be chunked; **low-precision stability** checks reduction, sorting, and iteration errors; **parallelism and communication** checks dependency graphs and cross-device synchronization; **sparse structure** accepts only structured sparsity; **operator fusion** requires reducing small kernels and memory round-trips.
|
|
39
|
+
|
|
40
|
+
| Algorithm characteristic | GPU classification | Notes |
|
|
41
|
+
|---|---|---|
|
|
42
|
+
| Divide-and-conquer / Merge / FFT | Friendly | Sub-quadratic, batchable, regular structure |
|
|
43
|
+
| Dynamic programming (dependency chains) | Adaptable | Chunking / skew scanning breaks serial dependencies |
|
|
44
|
+
| Backtracking / DFS serial search | Anti-pattern | Unpredictable branching, cannot fill SIMD lanes |
|
|
45
|
+
| Brute force O(2^n) | Anti-pattern | Complexity order itself is intractable |
|
|
46
|
+
|
|
47
|
+
> Used together with `../../references/books/matrix-analysis.md` (GEMM / low-rank decomposition for order reduction), `../../references/books/optimization-ml.md` (first-order / second-order method feasibility), `../../references/books/abstract-algebra.md` (parallel algorithms over semirings / finite fields).
|
|
48
|
+
|
|
49
|
+
## When NOT to Use
|
|
50
|
+
|
|
51
|
+
- **The problem has a closed-form solution and does not require step-by-step computation** — e.g., the quadratic formula directly gives the answer; algorithmic treatment only adds complexity.
|
|
52
|
+
- **The problem is qualitative rather than procedural** — e.g., "Is this structure elegant?" or "Is this proof insightful?" cannot be reduced to finite steps.
|
|
53
|
+
- **The input is unstructured and cannot be discretized** — e.g., a continuous perceptual data stream cannot directly serve as algorithm input; when preprocessing is more complex than the core problem, algorithmic treatment may not be optimal.
|
|
54
|
+
|
|
55
|
+
## When to Use
|
|
56
|
+
|
|
57
|
+
- Automating a repetitive process — the same operation must be performed on large volumes of data; manual execution does not scale.
|
|
58
|
+
- Verifying program termination — proving the algorithm halts in a finite number of steps is the cornerstone of reliability.
|
|
59
|
+
- Estimating computational cost — evaluating time/space consumption before large-scale runs to avoid resource exhaustion.
|
|
60
|
+
- Facing combinatorial explosion — the search space grows exponentially with input size, requiring pruning strategies.
|
|
61
|
+
- Judging problem feasibility — determining P / NP-hard / undecidable to decide on a solution strategy.
|
|
62
|
+
- Designing efficient solution procedures — from brute force to elegant algorithms, efficiency differences can span several orders of magnitude.
|
|
63
|
+
- **Designing executable algorithms/operators for GPU** — assessing complexity order, parallelism, memory access, and fusion so the algorithm is truly tractable on hardware.
|
|
64
|
+
|
|
65
|
+
## Method
|
|
66
|
+
|
|
67
|
+
### Step 1: Formalize I/O Spec
|
|
68
|
+
Define the input domain, output domain, and constraints. The input specification states data types (integer/floating-point/string/graph), scale range n∈[1,10^6], and validity conditions (preconditions); the output specification states the return type, precision, and boundary handling; constraints cover time/space limits and correctness guarantees (postconditions). Test: if you cannot write down the precondition/postcondition predicates, the specification is not yet formal enough.
|
|
69
|
+
|
|
70
|
+
### Step 2: Decompose into Sub-problems
|
|
71
|
+
Break the large problem into independently solvable pieces with clear boundaries and well-defined interfaces. Decomposition strategies: by data (processing different subsets), by function (completing different subtasks), by level (coarse-to-fine refinement). Good decomposition makes each sub-problem independently verifiable and the whole recursively verifiable; dependencies between sub-problems must be explicitly annotated to avoid implicit coupling.
|
|
72
|
+
|
|
73
|
+
### Step 3: Design the Procedure
|
|
74
|
+
Choose an algorithmic paradigm — this is the core decision; choosing wrong wastes all subsequent effort:
|
|
75
|
+
|
|
76
|
+
- **Divide-and-Conquer**: Partition, solve sub-parts, merge. Sub-problems are independent; merge cost is lower than solving the whole. Classics: merge sort, quicksort, Strassen matrix multiplication. Recurrence T(n)=aT(n/b)+f(n), solved by the Master Theorem.
|
|
77
|
+
- **Dynamic Programming (DP)**: Overlapping sub-problems, memoization to avoid repetition. Optimal substructure holds. Classics: shortest paths, knapsack, sequence alignment.
|
|
78
|
+
- **Greedy**: Locally optimal at each step, hoping for global optimality. Greedy-choice property holds. Classics: Dijkstra, Huffman, MST.
|
|
79
|
+
- **Backtracking**: Systematic search, pruning and retreating upon hitting dead ends. Search space has structure. Classics: N-queens, exact TSP, CSP.
|
|
80
|
+
- **Randomized**: Probabilistic shortcuts, trading randomness for efficiency. Deterministic cost is too high. Classics: randomized quicksort, Monte Carlo, Las Vegas.
|
|
81
|
+
|
|
82
|
+
Selection principle: independent → divide-and-conquer; overlapping → DP; greedy property → greedy; structured search → backtracking; deterministic cost too high → randomized. Practical problems often mix multiple paradigms.
|
|
83
|
+
|
|
84
|
+
### Step 4: Analyze Complexity
|
|
85
|
+
Time O(f(n)), space O(g(n)), distinguishing worst case from average case. Identify basic operation counts, solve recurrences (Master Theorem), and attend to how input distributions affect average-case complexity; beyond O (upper bound), attend to Ω (lower bound) and Θ (tight bound). Complexity analysis is an ongoing assessment during design, not post-hoc verification. Practical significance: for n=10^6, O(n) ≈ 10^6 steps (seconds), O(n²) ≈ 10^12 steps (infeasible), O(2^n) far exceeds the age of the universe.
|
|
86
|
+
|
|
87
|
+
### Step 5: Prove Correctness
|
|
88
|
+
Use loop invariants, structural induction, termination proofs, and pre/postconditions. An unverified algorithm is a guess. Loop invariant: initialization (holds before the loop), maintenance (preserved by each iteration), termination (invariant plus termination condition yields the postcondition); structural induction: assume correctness of sub-calls and prove the current call; termination: construct a decreasing measure and prove it strictly decreases; Hoare logic: {P} S {Q}.
|
|
89
|
+
|
|
90
|
+
### Step 6: Check Tractability
|
|
91
|
+
Is the problem in P? NP-hard? Undecidable? P → pursue the optimal exact algorithm; NP-hard → approximation/heuristics with explicit error bounds or probabilistic guarantees; undecidable → find a decidable restricted version. Common NP-hard problems: TSP, graph coloring, subset sum, SAT; common undecidable problems: the halting problem, Hilbert's tenth problem.
|
|
92
|
+
|
|
93
|
+
### Step 7: Optimize and Improve
|
|
94
|
+
Reduce constant factors, leverage data structures, parallelize — based on bottleneck analysis, not blind tuning. Optimization levels: (1) Algorithm level — switch to a superior paradigm (O(n²) → O(n log n) yields the largest gain); (2) Data structure level — switch to better storage/query structures; (3) Implementation level — caching, parallelism, SIMD, operator fusion; (4) Problem level — reformulate for easier solving (may yield qualitative leaps). Priority: algorithm level > data structure level > implementation level; problem level may enable leaps. Re-verify correctness after every optimization.
|
|
95
|
+
|
|
96
|
+
## Common Errors
|
|
97
|
+
|
|
98
|
+
| Error | Critique | Correct Approach |
|
|
99
|
+
|-------|----------|-----------------|
|
|
100
|
+
| Assuming exponential algorithms are acceptable | NP-hard problems require heuristics for large n, not exact solutions; 2^50 steps at 1ns each takes 35 years | Use approximation/heuristics for large n with explicit error bounds |
|
|
101
|
+
| Failing to prove termination | Infinite loops are a real risk; hanging is far more dangerous than slow results | Prove termination via a decreasing measure; construct a decreasing function on a well-ordered set |
|
|
102
|
+
| Confusing worst case with average case | Quicksort is worst-case O(n²) but average O(n log n); the worst case can occur in practice | Clearly state the analysis scenario and note assumptions |
|
|
103
|
+
| Confusing existence with constructibility | A solution may exist but be uncomputable; existence ≠ constructibility | Distinguish existence proofs from algorithmic constructions |
|
|
104
|
+
| Underestimating constant factors | O(n log n) with a huge constant may be slower than O(n²) with a small constant | Benchmark empirically; attend to constants and cache effects |
|
|
105
|
+
| Ignoring space complexity | A time-efficient algorithm may exhaust memory; DFS needs O(n) but BFS needs O(2^n) | Analyze both time and space |
|
|
106
|
+
| Premature optimization | Optimizing before proving correctness; the direction may be entirely wrong | Prove correctness first → analyze complexity → then optimize |
|
|
107
|
+
| Ignoring input distribution | Average-case complexity depends on distributional assumptions; random input ≠ real input | State distributional assumptions explicitly; analyze real-world scenarios |
|
|
108
|
+
| Serial / unfusable algorithms on GPU | Unpredictable branching, serial dependency chains, repeated memory reads/writes — "beautiful but intractable" | Adapt to parallel / fusible / sub-quadratic form; pass the GPU eight-dimension gate |
|
|
109
|
+
|
|
110
|
+
## Operating Procedure
|
|
111
|
+
|
|
112
|
+
When this skill is triggered, the output must include:
|
|
113
|
+
|
|
114
|
+
1. **Input specification**: `[Input]: [description]` — e.g., `[Input]: unsorted integer array A[1..n], n∈[1,10^6]`
|
|
115
|
+
2. **Output specification**: `[Output]: [description]` — e.g., `[Output]: A sorted in ascending order`
|
|
116
|
+
3. **Algorithm paradigm**: `[Paradigm]: [divide-and-conquer/DP/greedy/backtracking/randomized] because [reason]`
|
|
117
|
+
4. **Complexity**: `[Time]: O([f(n)]) [Space]: O([g(n)]) [Scenario]: [worst/average]`
|
|
118
|
+
5. **Correctness**: `[Loop invariant/induction strategy]: [content] ✅ proved / ❌ not proved`
|
|
119
|
+
6. **Tractability**: `[Class]: [P/NP-hard/undecidable] [Response]: [exact/approximate/heuristic/reformulate]`
|
|
120
|
+
7. **Improvement suggestions**: `[Optimization direction]: [specific suggestions]`
|
|
121
|
+
8. **[GPU feasibility]** (if used for algorithm/operator design) — complexity order / parallelism / memory access / fusion assessment, annotate as friendly / retrofittable / anti-pattern + adaptation suggestions
|
|
122
|
+
|
|
123
|
+
**The output must not present analysis alone without a conclusion.**
|
|
124
|
+
|
|
125
|
+
## Relations to Other Skills
|
|
126
|
+
|
|
127
|
+
- **Optimization thinking**: Gradient descent, branch-and-bound, and other optimization algorithms are instances of algorithmic thinking — optimization focuses on the optimal value, while algorithms focus on the steps and cost to reach it.
|
|
128
|
+
- **Transformation thinking**: FFT is a paradigmatic application of algorithmic thinking to transformations — O(n²) → O(n log n); transformations map problems to easily solvable spaces, and algorithms solve them efficiently in the transformed space.
|
|
129
|
+
- **Logical deduction**: Correctness proofs use deductive reasoning (loop invariants, induction) — an algorithm correctness proof is essentially a chain of deductive steps.
|
|
130
|
+
- **Induction and analogy**: Divide-and-conquer uses structural analogy — sub-problems are isomorphic to the original problem — which is precisely the algorithmic embodiment of inductive thinking.
|
|
131
|
+
- **Discrete / Combinatorial thinking**: Algorithms process discrete objects, and combinatorial counting underpins complexity analysis — combinatorial explosion is the core obstacle algorithmic thinking must overcome.
|
|
132
|
+
- **Modern mathematics activation**: `../../references/books/matrix-analysis.md` (GEMM / low-rank decomposition for order reduction), `../../references/books/optimization-ml.md` (GPU feasibility of first-order / second-order methods), `../../references/books/abstract-algebra.md` (parallel algorithms over semirings / finite fields).
|
|
@@ -5,6 +5,8 @@ description: |
|
|
|
5
5
|
English: Trigger when a problem needs finite-step solving, algorithm design, complexity analysis (time/space), tractability & parallelism assessment (P/NP-hard/undecidable); or termination/correctness proofs; or designing executable algorithms/operators for GPU (assessing complexity order, parallelism, memory access & fusion).
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
+
> **语言路由**:若用户消息为英文,请读取并遵循同目录下的 `SKILL.en.md`,按其操作规程以英文输出;中文消息则继续使用本文件。
|
|
9
|
+
|
|
8
10
|
# 🖥️ 算法与计算思想 / Algorithmic Thinking
|
|
9
11
|
|
|
10
12
|
> "算法是思想的自动化——将洞察转化为可重复执行的精确步骤。"
|