Verified SageMath computation for mathematical agents: reference lookup, executable Python code, and reproducible results.
中文说明 · Contributors · Skill package · Installation · Quick start · References · Security model
If this project helps your work, please consider giving the repository a Star ⭐
sagemath-skill helps mathematical agents use SageMath for verified computation. The agent searches the bundled SageMath reference first, writes SageMath code in ordinary Python form, executes the code locally, and reports results backed by real runtime output.
It is designed for exact computation in algebra, number theory, combinatorics, graph theory, polynomial rings, matrices, calculus, finite fields, elliptic curves, Galois groups, coding theory, cryptography, manifolds, modular forms, and related mathematical domains.
VeryMath / AI4Math project.
Contributions are welcome for examples, installation notes, reference indexing, and runner improvements.
OpenCode / Codex should install the repository's sagemath-skill/ directory as the complete skill package.
Core capabilities:
- Search the bundled SageMath reference before writing code.
- Write SageMath code in Python form and avoid Sage REPL preparser-only syntax.
- Verify computations on macOS / Linux with
scripts/sagemath_runner.py. - Verify computations on Windows from inside WSL with
scripts/sagemath_runner_wsl.py. - Guide Miniconda and SageMath 10.9 installation when SageMath is missing.
In OpenCode Desktop or Codex, ask:
Please install the VeryMath SageMath Skill from this GitHub repository:
https://github.com/VeryMath/AI4Math-Sagemath-skill
The skill directory is sagemath-skill/. Please download the repository and install that directory as the complete skill.
If GitHub access is slow, download the archive first and ask the agent to install sagemath-skill/ from the local path.
Windows users should install WSL first, then install and run SageMath inside WSL. Do not use Windows-native conda for SageMath.
After installation, try:
Use sagemath-skill to compute the factorization, discriminant, Galois group, Galois group order, and splitting field degree of x^4 - 2 over QQ. Provide SageMath code, the real runtime output, and a mathematical explanation.
Graph theory smoke test:
Use sagemath-skill to construct a small directed network, verify max-flow min-cut by both the maximum flow algorithm and exhaustive cut enumeration, and report the SageMath runtime output.
sagemath-skill/references/api/ contains the processed SageMath text reference. The agent uses scripts/sage_ref_search.py to locate relevant constructors, methods, and examples before writing code.
Useful entry points:
sagemath-skill/SKILL.mdsagemath-skill/references/domain_index.mdsagemath-skill/references/install_sagemath.mdsagemath-skill/scripts/sage_ref_search.py
This skill may guide the agent to execute local commands for reference search, SageMath code execution, or environment installation. Installation, downloads, and conda environment creation should be confirmed by the user first.
On Windows, the intended path uses Linux conda inside WSL. The WSL runner refuses Windows conda exposed under /mnt/c/.... Mathematical results should come from runner output, not from language-model guessing.