Math Prompt Engineering
Relevant source files
The following files were used as context for generating this wiki page:
Math Prompt Engineering within the WHK project defines a specialized framework for transforming Large Language Models (LLMs) into "Expert Math Mentors." Unlike simple equation solvers, this system focuses on "Cognitive Revelation," guiding users through high-school and competition-level mathematics (CMO-grade) by emphasizing structural analysis, multi-path problem solving, and meta-cognitive reflection. Sources: scripts/skills/math/SKILL.md:1-15
The system architecture is built upon a modular prompt structure that integrates identity definition, behavioral constraints, a specialized function exploration skill library, and a rigorous logical workflow. This ensures that the AI provides not only correct answers but also deep insights into mathematical logic and "fingerprint" structures. Sources: scripts/skills/math/prompt/main.md:1-16, scripts/skills/math/SKILL.md:18-35
System Persona and Core Capabilities
The "Expert Solver v3.0" persona is engineered to act as a senior mentor rather than a calculator. It is equipped with specific cognitive frameworks to handle high-level tasks such as identifying isomorphism in derivatives or performing precise algebraic control. Sources: scripts/skills/math/SKILL.md:18-35
Core Capabilities
| Capability | Description |
|---|---|
| Feature Extraction | Identifies "fingerprint" structures (e.g., symmetric offsets, logarithmic isomorphisms). |
| Cross-Method Analysis | Compares "brute force" solutions with "elegant intuitive" paths. |
| Precision Control | Uses thinking chains to ensure zero error in complex calculus/algebra. |
| Schema Transfer | Connects problems to broader mathematical branches like probability or geometry. |
Sources: scripts/skills/math/SKILL.md:27-40
Problem-Solving Workflow
The engineering of the math prompt follows a strict 5-step sequence designed to ensure accuracy and educational value. Sources: scripts/skills/math/prompt/workflow.md:3-23
The diagram above illustrates the logical flow from initial query to final structured response, highlighting the internal thinking processes.
Sources: scripts/skills/math/prompt/workflow.md:3-23
Workflow Phases
- Feature Mining: Identification of structural components (e.g., $e^x$ presence, dual roots) and retrieval of strategies from
SKILLS.md. - Ground Solution: Establishment of standard steps based on basic theorems (Lagrange, Zero-point existence).
- High-Level Strategy: Exploration of "mathematical beauty" through dualities, convexity scaling, or operator methods.
- Verification: Backtracking algebraic transformations and using numerical approximation if necessary.
- Cognitive Reflection: Distilling the process into a "solution model" and identifying potential pitfalls.
Sources: scripts/skills/math/prompt/workflow.md:3-23, scripts/skills/math/SKILL.md:104-124
Functional Exploration Skill Library
A critical component of the math prompt is the library of specific mathematical techniques, particularly for function analysis and variable manipulation. Sources: scripts/skills/math/SKILL.md:126-200
Isomorphism and Transformation
The system is programmed to recognize specific "fingerprints" for transformation:
- Logarithmic/Exponential Isomorphism: Identifying $xe^x$ or $\frac{\ln x}{x}$ to reduce dimensions via monotonicity.
- Complex Isomorphism: Using $e^{\ln x} = x$ to align structures like $ae^x \ge \ln x + b$.
Sources: scripts/skills/math/SKILL.md:154-165
Specialized Inequalities and Methods
- Logarithmic Mean Inequality: A tool for handling logarithmic offsets.
- Homogenization: Reducing multi-variable relations to single-variable models using ratios ($k$) or sum-product relations.
- Operator Theory: Using "derivative fingerprints" (e.g., $xf' \pm f$) to construct auxiliary functions like $[xf]'$ or $[f/x]'$.
Sources: scripts/skills/math/SKILL.md:175-195
Operational Constraints and Output Standards
To maintain high technical accuracy and readability, the prompt enforces strict formatting and behavioral rules. Sources: scripts/skills/math/prompt/constraints.md:3-25, scripts/skills/math/prompt/output_format.md:3-10
Technical Constraints
- Deep Chain of Thought (CoT): Mandatory internal "lossless rehearsal" before outputting any solution.
- Absolute Rigor: Numerical calculation errors or theorem misuse are strictly prohibited.
- Aesthetic Formatting: Middle-spaces between Chinese and English (e.g., "对于 $x > 0$"), and isolation of formulas from text with empty lines. Sources: scripts/skills/math/prompt/constraints.md:3-15
Structured Output Format
Responses must follow a three-part hierarchy:
- 【常规解法】 (Standard Solution): Exam-ready, standard steps.
- 【进阶解法/技巧】 (Advanced Solution): Higher-level insights and "shortcuts."
- 【总结与反思】 (Summary & Reflection): Meta-cognitive review and pitfall warnings.
Sources: scripts/skills/math/prompt/output_format.md:3-10
Conclusion
Math Prompt Engineering in the WHK repository creates a robust, expert-level pedagogical tool. By combining a sophisticated persona with a rigorous 5-step workflow and a deep library of specialized mathematical "skills," it ensures that LLM responses are technically precise, logically transparent, and educationally impactful for advanced learners. Sources: scripts/skills/math/SKILL.md:214-225