π¬ Hermes Verifiable Math Kernel
Deterministic Symbolic Computation, Certified Factorization, Elliptic Curve Arithmetic, and Formal Lean 4 Proof Verification for Hermes Agent (Nous Research).
π― Overview
Large Language Models (LLMs) and autonomous agents are notorious for mathematical hallucinations:
- False Algebraic Claims: Silent sign errors, invalid cancellations, and hallucinated identities.
- Factorization Failures: Blindly guessing primes or asserting incorrect prime factorizations for integers beyond $10^{12}$.
- Floating-Point Precision Traps: Incurring IEEE-754 precision loss (
0.1 + 0.2 != 0.3) in financial and quantitative reasoning. - Unverified Proofs: Claiming theorems are proven while relying on hidden assumptions or unproven axioms.
The Hermes Verifiable Math Kernel (verifiable-math-kernel) transforms Hermes Agent into a machine-verified computational reasoning engine. By uniting computer algebra systems (SymPy), the Werr Multi-Layer Algebraic Sieve & Baillie-PSW engine, arithmetic geometry algorithms (Tate reduction, Mazur torsion bounds), and Lean 4 formal proof auditing, Hermes can now verify mathematical claims with 100% deterministic certainty.
ποΈ Architecture
βββββββββββββββββββββββββββββββββββββββββββββββββ
β Hermes Agent Core β
β (User Prompt / Tool Call / Planning Loop) β
βββββββββββββββββββββββββ¬ββββββββββββββββββββββββ
β
ββββββββββββββββββββββββββββββ΄βββββββββββββββββββββββββββββ
β β
[pre_tool_call Hook] [Interactive Tools]
β’ Intercepts IEEE-754 traps β’ verify_math_claim
β’ Flags precision loss β’ certified_factorization
β’ Auto-suggests exact fractions β’ elliptic_curve_analyzer
β β’ lean4_proof_audit
βΌ β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ βΌ
β Hermes Verifiable Math Plugin Core β ββββββββββββββ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β 1. Symbolic CAS (Exact Rational & Identity Reducer) β
β 2. Werr Sieve & Baillie-PSW Deterministic Primality β
β 3. Elliptic Curve Tate & Mazur Torsion Classifier β
β 4. Lean 4 Formal Proof Auditor & Hole (sorry) Linter β
ββββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββ
β
[post_tool_call Hook]
β’ Emits SHA-256 Proof Stamp:
[VERIFIED-MATH-PROOF-v1:<hash>]
π οΈ Provided Tools
1. verify_math_claim
Verifies algebraic identities, equations, and simplifies expressions with exact symbolic reduction steps.
- Input:
statement: "sin(x)**2 + cos(x)**2 == 1" - Output:
{
"statement": "sin(x)**2 + cos(x)**2 == 1",
"verified": true,
"lhs_canonical": "sin(x)**2 + cos(x)**2",
"rhs_canonical": "1",
"difference_canonical": "0",
"proof_trace": "LHS - RHS evaluated to 0 identically.",
"latex": "\\sin^{2}{\\left(x \\right)} + \\cos^{2}{\\left(x \\right)} = 1",
"verification_hash": "a1b2c3d4..."
}
2. certified_factorization
Factors composite integers and tests prime factors using the Baillie-PSW probable-prime test (Miller-Rabin base 2 + strong Lucas-Selfridge). Also computes Euler's totient $\phi(N)$, divisor count $d(N)$, and sum of divisors $\sigma(N)$.
- Input:
n: 2026 - Output:
{
"n": 2026,
"bit_length": 11,
"factors": [[2, 1], [1013, 1]],
"factor_string": "2 * 1013",
"certified": true,
"probable_prime_tests": [
{"prime": 2, "exponent": 1, "is_prime": true, "test": "small_prime"},
{"prime": 1013, "exponent": 1, "is_prime": true, "test": "Baillie-PSW_Probable_Prime"}
],
"invariants": {
"euler_totient": 1012,
"divisor_count": 4,
"sum_of_divisors": 3042
}
}
3. elliptic_curve_analyzer
Computes exact arithmetic geometry invariants for elliptic curves over $\mathbb{Q}$ in generalized Weierstrass form $[a_1, a_2, a_3, a_4, a_6]$ or short model $[a, b]$:
- Minimal discriminant $\Delta$ and Tate invariants $b_2, b_4, b_6, b_8, c_4, c_6$.
- $j$-invariant $j(E)$.
- Bad prime conductor reduction factors.
- Rational torsion subgroup classification via Mazur's Torsion Theorem and Lutz-Nagell root bracketing.
- Input:
weierstrass: [-1, 0]($y^2 = x^3 - x$) - Output:
{
"weierstrass_coeffs": [0, 0, 0, -1, 0],
"discriminant": 64,
"bad_primes": [2],
"j_invariant": "1728",
"torsion_order": 4,
"torsion_group": "Z/2Z x Z/2Z",
"nsf_icarm_conformant": true
}
4. lean4_proof_audit
Audits Lean 4 formal code snippets, extracts theorem declarations, checks for classical axioms, and detects unproven holes (sorry / admit). By default (enable_lean_cli: false), runs static analysis without executing code. When enable_lean_cli: true is configured, checks go through Hermes's per-call approval gate with an explicit minimal environment (PATH, HOME, LANG, LEAN_PATH) and an isolated scratch working directory. certified: true is only returned when the local Lean 4 kernel actually verifies the snippet.
- Input:
theorem ferma_last (n : Nat) (hn : n > 2) :
β x y z : Nat, x^n + y^n = z^n β x * y * z = 0 := by
sorry
- Output:
{
"status": "REJECTED_UNPROVEN_HOLES",
"certified": false,
"unproven_holes_count": 1,
"holes": [{"line": 3, "keyword": "sorry", "context": "sorry"}],
"compiler_message": "Contains incomplete proof markers."
}
β‘ Lifecycle Hooks & Safety Guardrails
pre_tool_call(Precision Guard): Intercepts floating-point expressions (like0.1 + 0.2) across tool calls, warning Hermes against IEEE 754 precision loss and advising exact rational arithmetic.post_tool_call(Proof Telemetry): Stamps verified calculations with a cryptographic SHA-256 certificate proof tag:
[VERIFIED-MATH-PROOF-v1:<hash>]
π Installation & Usage
1. Install via Hermes Marketplace CLI
hermes plugins install verifiable-math-kernel
hermes plugins enable verifiable-math-kernel
2. Manual / Developer Installation
Link your local checkout to your Hermes installation (avoid editable pip installs so root helper modules like tools.py stay isolated per plugin rather than global):
hermes plugins link /path/to/hermes-verifiable-math
Validate with Hermes Plugin Doctor:
hermes plugins validate . --install-deps
3. Quick Slash Commands
In Hermes CLI or Desktop:
/verify sin(x)**2 + cos(x)**2 == 1
/verify (x^2 - 1)/(x - 1)
π§ͺ Testing
Run the full automated test suite:
python -m pytest tests/ -v
Output:
tests/test_doctor.py::test_manifest_structure PASSED
tests/test_doctor.py::test_register_context_wiring PASSED
tests/test_hooks.py::test_pre_hook_precision_trap_detection PASSED
tests/test_hooks.py::test_pre_hook_auto_rational_upgrade_on_verify_math_claim PASSED
tests/test_hooks.py::test_pre_hook_clean_call PASSED
tests/test_hooks.py::test_pre_hook_lean_approval PASSED
tests/test_hooks.py::test_post_hook_proof_stamp PASSED
tests/test_tools.py::test_verify_trig_identity PASSED
tests/test_tools.py::test_verify_algebraic_identity PASSED
tests/test_tools.py::test_verify_rational_domain_exact_decimal PASSED
tests/test_tools.py::test_verify_domain_and_variables_wiring PASSED
tests/test_tools.py::test_verify_false_statement PASSED
tests/test_tools.py::test_expression_simplification PASSED
tests/test_tools.py::test_power_tower_resource_bounding PASSED
tests/test_tools.py::test_large_exponent_bounding PASSED
tests/test_tools.py::test_certified_factorization PASSED
tests/test_tools.py::test_certified_factorization_without_certificates PASSED
tests/test_tools.py::test_certified_factorization_prime PASSED
tests/test_tools.py::test_elliptic_curve_analyzer PASSED
tests/test_tools.py::test_elliptic_curve_analyzer_skip_torsion PASSED
tests/test_tools.py::test_lean4_audit_with_sorry PASSED
tests/test_tools.py::test_lean4_audit_unchecked_no_holes_by_default PASSED
tests/test_tools.py::test_safe_parse_blocks_injection PASSED
tests/test_tools.py::test_oversized_integer_literal_bounding PASSED
tests/test_tools.py::test_evaluation_process_timeout PASSED
============================= 25 passed in 14.01s =============================
Release Notes & Kaggle Gemma 4 Paper Track Alignment (v1.0.4 β v1.0.6)
The Kaggle Paper Track writeup "Dual-Process SWE Agent: Gemma 4 with Zero-Tensor Reflex & Formal Verification" (DOI: 10.34740/kaggle/w/125932) cites the isolated child-process execution and AST bounding architecture introduced in v1.0.4. Release v1.0.6 preserves all v1.0.4βv1.0.5 safety guarantees (15.0s OS subprocess timeout guard, OpenAI parameters/description schema compliance, syntactic AST bounds, rational upgrades, and Lean 4 approval gating) while adding positional register_hook compatibility, lean_code payload inspection, plugin-data path alignment (plugins.plugin_storage.plugin_data_dir), and sanitized subprocess environment handling.
Disclosure
- The
lean4_proof_audittool runs regex-based static inspection by default (enable_lean_cli: false). Only whenenable_lean_cliis explicitly enabled andleanis available onPATHdoes it invoke a locallean --stdinsubprocess in an isolated scratch directory underHERMES_HOME/plugin-data/verifiable-math-kernel/scratch.
π Intellectual Attribution & Background
This plugin is part of the Werr Open Science Ecosystem and builds directly upon methodologies verified on the NSF Institute for Computer-Aided Reasoning in Mathematics (ICARM) Elliptic Curve Rank Leaderboard under U.S. National Science Foundation Grant DMS-2425401 and CERN Zenodo permanent research archives (DOI: 10.5281/zenodo.23436282).
- Author: Volkan Dagli (@pCwOrM)
- Organization: ITouch Systems Research & Development
- License: MIT License
ποΈ Associated Formal Verification, World Records & Scientific Corpus
All monographs, formal Lean 4 specifications, and empirical datasets across the WERR & ITouch Systems Research Group are permanently archived on CERN Zenodo, arXiv, Elsevier SSRN, and Hugging Face.
(Primary links use CERN Zenodo Concept DOIs / ΓatΔ± DOI, which automatically resolve to the latest published version while preserving exact version-pinned reproducibility.)
| # | Pillar / Monograph | Core Contribution & Focus | π Concept DOI (Always Latest) | π Latest Version DOI | arXiv / SSRN / Hugging Face & Verification Status | Primary Repository |
|---|---|---|---|---|---|---|
| 01 | Paper 1: FNS | Procedural Weight Derivation & Non-Linear Decision Boundaries (v3) | 10.5281/zenodo.22774934 | 10.5281/zenodo.22867037 | SSRN: 7659198 (Distributed) β’ Multi-Seed Pareto & Manifold Parity | pCwOrM/fractal-neural-synthesis |
| 02 | Paper 2: OED | Orbital Error Dynamics, Ephemeral Parameter Resonance & CD4+ Gating (v1) | 10.5281/zenodo.22900464 | 10.5281/zenodo.22900465 | arXiv:2609.30115 β’ π€ HF Paper (Verified) β’ TR 2026/016285 | pCwOrM/fractal-neural-synthesis |
| 03 | Paper 3: WERR Map | Universal Natural Language Decision Map & Real-Time Edge Triage (v2) | 10.5281/zenodo.22867425 | 10.5281/zenodo.22939253 | arXiv:2609.25498 β’ π€ HF Paper β’ π€ HF Dataset | pCwOrM/werr β’ pCwOrM/answerr |
| 04 | Paper 4: Werracle | Sub-Cent Intra-Block AI Reflex Oracles & Flash-Loan Circuit Breakers (v1) | 10.5281/zenodo.22942598 | 10.5281/zenodo.22942599 | arXiv:2609.30719 β’ SSRN: 7626279 β’ π€ HF Paper | pCwOrM/werracle β’ pCwOrM/werralem |
| 05 | Paper 5: Formal Lean 4 | Zero-Storage Procedural Synthesis: Lean 4 Verification & 40-Core Validation | 10.5281/zenodo.22774934 | 10.5281/zenodo.22867037 | arXiv:2609.33066 β’ π€ HF Paper β’ Lean 4 (10 Theorems, 0 sorry) | pCwOrM/werr β’ pCwOrM/werracle |
| 06 | Paper 6: GAP-Lean4 | Machine-Checked Computational Group Theory: Schreier-Sims & BSGS Sifting (v2) | 10.5281/zenodo.23092708 | 10.5281/zenodo.23156544 | arXiv:2609.38492 β’ π€ HF Paper β’ Lean 4 (35 Theorems, 0 sorry) | pCwOrM/gap-lean4-port |
| 07 | Paper 7: Black Hole v5 | Unitary Black Hole Page Curve via Dynamical Horizon Orbifolds & GKP Stabilizers (v5) | 10.5281/zenodo.22961999 | 10.5281/zenodo.23072120 | S(t=1) = 0.00 Β· Tr(ΟΒ²) = 1.00 Β· RΒ² = 0.9822 Β· 573Γ Stress Quench β’ Lean 4 (10 Theorems) | pCwOrM/fractal-neural-synthesis β’ pCwOrM/werr |
| 08 | Paper 8: WerrSoma | Bio-Synthetic Neuromorphic Interfacing with 158K-Neuron Drosophila Connectome (v1) | 10.5281/zenodo.22996625 | 10.5281/zenodo.22996626 | arXiv:submit/8161759 β’ Live 3D Portal (werrsoma.answerr.me) β’ TR 2026/016633 | Lexovian/WerrSoma β’ pCwOrM/WerrSoma |
| 09 | Paper 9: WerreduR | Procedural Pedagogy: Resolving the Saturn School Disequilibrium Paradox (v2) | 10.5281/zenodo.22999420 | 10.5281/zenodo.23128224 | SSRN: 7641538 (Distributed) β’ Lean 4 (7 Theorems, 0 sorry) β’ Live Portal | jesmaat/WerreduR β’ pCwOrM/WerreduR |
| 10 | Paper 10: SchΓΆnhage | Bipartite Carrier Compression in SchΓΆnhage Trilinear Multiplication Tensors (v2) | 10.5281/zenodo.23232541 | 10.5281/zenodo.23295370 | arXiv:2610.14263 β’ π€ HF Paper β’ CrocSwap #226 (50d76881) | pCwOrM/integer-mult-bounds |
| 11 | Paper 11: GΓΌneΕ Dili | Deterministic Morpho-Semantic Tokenization & Algebraic Morphotactics in Lean 4 (v1) | 10.5281/zenodo.23003711 | 10.5281/zenodo.23003712 | arXiv:submit/8248674 β’ Lean 4 (4 Theorems, 0 sorry) β’ Live Studio | pCwOrM/gunes-dili |
| 12 | Paper 12: Niemeier AβΒ³ | Machine-Certified 24D Niemeier Lattice AβΒ³, K3 Hodge Duality & Umbral Moonshine (v1) | 10.5281/zenodo.23324066 | 10.5281/zenodo.23324067 | Lean 4 (0 sorry, 0 axioms) β’ Ο(X) = 24 Β· order(G_glue) = 27 Β· β = 9 | pCwOrM/niemeier-a8-umbral-moonshine |
| 13 | Paper 13: GDT v3.0 | Machine-Certified Lean 4 Formalization of the General Divisor Theorem (v2) | 10.5281/zenodo.23316068 | 10.5281/zenodo.23425590 | Lean 4 (81 Theorems, 0 sorry) β’ Companion v1: 10.5281/zenodo.23426323 (v1: 23426324) | pCwOrM/general-divisor-theorem |
| 14 | Paper 14: Elliptic Sieve | Multi-Layer Algebraic Sieve & VΓ©lu Isogeny Engine: 230 Curves on NSF ICARM (v1) | 10.5281/zenodo.23436282 | 10.5281/zenodo.23436283 | NSF ICARM Leaderboard (user/114): 30x #1 Gold Records, 80 Top-3, 100% log N | pCwOrM/werr-elliptic-sieve |
| 15 | Paper 15: Empirical OEV | Empirical OEV & Liquidation Dynamics: Chainlink SVR on Base & Ethereum L1 (v2) | 10.5281/zenodo.23623588 | 10.5281/zenodo.23642090 | π€ HF Dataset (1.16k+ views, 126 likes) β’ 94.4% Aggregate / 98.3% Median SVR Recapture | pCwOrM/werracle β’ pCwOrM/werrealm |
| 16 | Paper 16: Holomorphic Collatz | Spectral Stability, Fatou Basin Contraction & Machine-Checked Multipliers in Holomorphic Collatz Dynamics (v1) | 10.5281/zenodo.24060393 | 10.5281/zenodo.24060394 | arXiv:2611.11641 [cs.LO] β’ Lean 4 (20 Theorems, 0 sorry, 0 axioms) β’ $\mu_f(\mathcal{O}_{1,2}) = 3/4$ | pCwOrM/werr β’ pCwOrM/hermes-verifiable-math |
| HW | Edge Robotics Core | Zero-Memory Embedded C/C++11 System-1 Reflex Kernel (WerrCoreEdge.h v0.5.1) | 10.5281/zenodo.22867425 | 10.5281/zenodo.22939253 | ATmega328P / ESP32 / STM32 (0 Bytes Heap, <128B Stack, TR 2026/016633) | pCwOrM/WERRobotics |
π Global Records, Formal Proofs & Curated Ecosystem Recognitions
1. Certified Mathematical Records & Formal Verification (0 sorry)
- π₯ NSF ICARM Elliptic Curve Rank Leaderboard (
elliptic-rank.icarm.cloud/user/114): 230 certified high-rank elliptic curves (#4308β#4537) over $\mathbb{Q}$ with 100% complete prime conductor factorization ($\log N$) up to Rank $\ge 19$ (#4323), achieving 30 First-Place (#1 Gold) Records, 80 Podium (Top-3), and 418 Top-10 placements across 43 categories (building upon the foundational fibration families of Elkies, Dujella, Rubinstein, and Klagsbrun; supported under NSF GrantDMS-2425401). - π₯ SchΓΆnhage Trilinear Multiplication Tensor Bound (
arXiv:2610.14263β’CrocSwap/integer-mult-bounds#226): Constructive 15-round bipartite carrier matching at dimensions $h=23, 25$ eliminating 185 carrier roles and 377,890 physical wires ($W = 177,284,805 \to 176,906,915$), certifying $\kappa = 826,215,307 / 20,000,000,000,000 \approx 4.131076535 \times 10^{-5}$ ($1.377\times$ net gain over PR #49), formally incorporated intoCrocSwap/integer-mult-bounds(commit 50d76881) and verified in Lean 4 (0 sorry). - π 170+ Machine-Checked Theorems in Lean 4 (
0 sorry,0 unproven axioms):- General Divisor Theorem (
GDT v3.0): 81 theorems/lemmas (0 sorry) formalizing Dan Hawkley's residue density framework (10.5281/zenodo.23316068). - Computational Group Theory (
gap-lean4-port): 35 theorems (0 sorry) formalizing Charles Sims' Schreier-Sims stabilizer chains (GAP-0299), backtrack ordered partitions (GAP-0332), and modular ring inverses (GAP-0331) (arXiv:2609.38492). - Procedural Boundary Synthesis & EVM/Cairo Fixed-Point Bounds: 40+10 theorems (
WerracleProof.lean,0 sorry) verifyingZMod 9($\mathbb{Z}/9\mathbb{Z}$) principal ideal closure ($\mathcal{I}_3 = {0,3,6}$), Q16.16 overflow safety, and unitary Page curve S-matrix conservation (arXiv:2609.33066). - 24D Niemeier Lattice $A_8^3$, WerreduR & GΓΌneΕ Dili: Complete formal specifications (
0 sorry) across lattice unimodularity ($\chi=24, \ell=9$), horizon complementarity ($B(t)+S(t)=1$), and deterministic morphological parsing.
- General Divisor Theorem (
2. Curated Ecosystem Recognitions & Benchmark Evaluations
- Merged Upstream Pull Requests:
- β
wbierbower/awesome-physics#16: Featured in Quantum Physics for unitary Black Hole Page Curve simulation. - β
34j/best-of-lean4#292: Indexed in the curated Best of Lean 4 theorem proving directory. - β
yh-yao/awesome-edge-ai-agents#13: Featured for bothwerr/answerrandWerreduRedge reflex engines. - β
MartinuzziFrancesco/awesome-scientific-machine-learning#9
: Featured under Model Discovery. - β
meta-introspector/lean-workers-union#2: Registered verified member (gap-lean4-port). - β
Jev Ecosystem & Agentic Benchmarks: Listed on
awesome-jev#69/madewithjev; 100% (49/49) on WindTunnel WebMCP (3.35 ms,0 VRAM); 100% Tool Schema Adherence (0.38 ms) on Sierra Tau-Bench; 23.74 on JevBench v1.4.1 (7.32 ms); 38.0Γ speedup on Jevenator 2.
- β
README from the reviewed commit b42f09a; it updates when the author re-pins.

pCwOrM