agentleFS
acprkacprk/crypto-research-agents/skills/sage-check/SKILL.md

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.

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
  1. Distinctive:

    Test the hypotheses too: Check that the hypotheses are satisfiable on the grid, because a vacuous theorem "passes" every check.

    line 23
  2. Distinctive:

    Also test the converse: If a condition is claimed to be necessary *and* sufficient, test both directions separately.

    line 28
  3. Very specific:

    If a check fails, give the minimal counterexample (smallest parameters) to falsifier and theorist.

    line 37

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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

  1. 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.
  2. 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.
  3. Test the hypotheses too. Check that the hypotheses are satisfiable on the grid, because a vacuous theorem "passes" every check. Then check the conclusion.
  4. 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.
  5. Also test the converse. If a condition is claimed to be necessary and sufficient, test both directions separately.
  6. 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.
  7. Output one JSON line per check: {"check": ID, "params": {...}, "cases": N, "passed": bool, "counterexample": {...} | null}. Save the script under checks/ and the output under results/checks/, then add an EVIDENCE row if any number from it reaches the paper.
  8. If a check fails, give the minimal counterexample (smallest parameters) to falsifier and theorist. 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 present

Typical checks by area

areawhat to check on toy parameters
algebraexistence 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
FHEnoise 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
latticetoy LWE instances solved by LLL/BKZ in small dimensions, compared with the estimator's predicted β
symmetricS-box properties (DDT/LAT/differential uniformity) by exhaustive computation; small-round trail probabilities by exhaustive search on scaled-down versions
protocolssecret-sharing reconstruction thresholds; OT/PSI correctness on small sets; communication formulas vs counted messages

Tooling notes

  • In Sage, GF(p), Zmod(n), CyclotomicField(m) and cyclotomic_polynomial(m) cover most checks. Run with sage -python script.py so the same file stays importable as plain Python.
  • In pure Python, sympy (cyclotomic_poly, factor_list(..., modulus=p), n_order, primitive_root) and pow(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.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.