sage-check
Skill15 starsChanged 9 days agoMITView on GitHub
Numeric sanity check of every lemma, identity and parameter claim on small parameters, with exhaustive search where feasible. Use it before writing a proof, before Lean formalisation, and whenever a falsifier needs a counterexample search. Works with SageMath if installed and falls back to pure Python/sympy otherwise.
In this repository29 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- abstract-craftSkill
- anonymize-checkSkill
- artifact-packSkill
- baseline-pinSkill
- bench-protocolSkill
- bib-verifySkill
- camera-readySkill
- eprint-searchSkill
- experiments-writingSkill
- falsifySkill
- figure-harvestSkill
- idea-mining-loopSkill
- lean-bridgeSkill
- lit-matrixSkill
- log-to-evidenceSkill
- mock-reviewSkill
- paper-figuresSkill
- paper-playbookSkill
- param-estimationSkill
- phase-gateSkill
- polish-writingSkill
- reading-notesSkill
- rebuttalSkill
- related-work-writingSkill
- technique-overviewSkill
- textbook-indexSkill
- venue-calibrationSkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 2 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 23
Test the hypotheses too: Check that the hypotheses are satisfiable on the grid, because a vacuous theorem "passes" every check.
- Distinctive: line 28
Also test the converse: If a condition is claimed to be necessary *and* sufficient, test both directions separately.
- Very specific: line 37
If a check fails, give the minimal counterexample (smallest parameters) to falsifier and theorist.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
sage-check: test every lemma on small cases first
Why
Proving a false lemma wastes days, and formalising one in Lean wastes weeks. Most wrong statements fail on a toy instance: a small prime, a small ring dimension, a 2×2 case. Run a finite check before proving and before formalising.
Protocol
- Transcribe the statement exactly as in THEORY.md. Include every quantifier and side condition. Each checked statement gets an ID matching THEORY.md / CLAIMS.md.
- Choose a parameter grid.
- Include every smallest case (p ∈ {2, 3, 5, 7, 11, 13}, n ∈ {1, 2, 4, 8}).
- Cover both residue classes the statement distinguishes (for example p ≡ 1 and p ≡ 3 mod 4).
- Include the boundary of any inequality hypothesis, on both sides.
- Include at least one parameter as large as the experiments use, if it is feasible.
- Test the hypotheses too. Check that the hypotheses are satisfiable on the grid, because a vacuous theorem "passes" every check. Then check the conclusion.
- Search exhaustively wherever the space is finite and small (≤ 10⁷ cases). Otherwise use random sampling with a fixed seed, and report the seed and the sample size.
- Also test the converse. If a condition is claimed to be necessary and sufficient, test both directions separately.
- Use exact arithmetic:
ZMod/GF,Integer,QQ,sympy.Rational. Use no floats unless the statement is about floats. For asymptotic claims, check the exact finite formula on a range and fit the trend; do not trust a plotted curve. - Output one JSON line per check:
{"check": ID, "params": {...}, "cases": N, "passed": bool, "counterexample": {...} | null}. Save the script underchecks/and the output underresults/checks/, then add an EVIDENCE row if any number from it reaches the paper. - If a check fails, give the minimal counterexample (smallest parameters) to
falsifierandtheorist. Do not patch the statement silently.
Script template
scripts/sanity_check_template.py is a runnable skeleton with a guarded Sage import,
a check(...) helper that stops at the first counterexample, and a toy statement
about roots of unity mod p. Copy it, then replace the STATEMENTS list.
python3 skills/sage-check/scripts/sanity_check_template.py # pure Python
sage -python skills/sage-check/scripts/sanity_check_template.py # uses Sage if presentTypical checks by area
| area | what to check on toy parameters |
| algebra | existence and order of roots of unity mod p; factorisation of Φ_m mod p (number and degree of factors = ord_m(p)); injectivity of encodings; polynomial identities coefficient by coefficient |
| FHE | noise bound vs measured noise on a toy scheme (the bound must hold on every sample); correctness of the claimed decryption condition at its boundary; operation counts by instrumented toy evaluation |
| lattice | toy LWE instances solved by LLL/BKZ in small dimensions, compared with the estimator's predicted β |
| symmetric | S-box properties (DDT/LAT/differential uniformity) by exhaustive computation; small-round trail probabilities by exhaustive search on scaled-down versions |
| protocols | secret-sharing reconstruction thresholds; OT/PSI correctness on small sets; communication formulas vs counted messages |
Tooling notes
- In Sage,
GF(p),Zmod(n),CyclotomicField(m)andcyclotomic_polynomial(m)cover most checks. Run withsage -python script.pyso the same file stays importable as plain Python. - In pure Python,
sympy(cyclotomic_poly,factor_list(..., modulus=p),n_order,primitive_root) andpow(a, -1, p)are enough for most toy checks. - Mathematica, if connected, is useful for closed forms and series. Treat its output as a hint, then recheck with exact finite computation.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

