alkahest

Symbolic math for agents and humans

Get an exact answer fast, with a derivation you can check

Python 3.10–3.14 · Linux x86_64, macOS arm64, Windows x86_64 · PyPI

Full symbolic and exact numerical capabilities

Mathematics

Infrastructure

Results you can verify

Lean 4 certificates certified

Supported results come with a Lean 4 proof that checks independently of alkahest. Integrals, definite ones included, and ODE/PDE solutions are proved by reflection through a verified checker, with a tactic fallback. certifiable() tells you in advance whether a result will get one

r = ak.integrate(1/x, x, 1, 2); r.certificate # tail of the Lean file
open Alkahest.Kernel in
theorem alkahest_definite_integral :
    ∫ x in ((1 : ℝ))..((2 : ℝ)), ((x : ℝ))⁻¹ = Real.log |(2 : ℝ)| - Real.log |(1 : ℝ)| :=
  defint_sound (P := [])
    (X := [(.ne (.var (nat_lit 0)))])
    (F := (.app .logabs (.var (nat_lit 0))))
    (f := (.inv (.var (nat_lit 0))))
    (A := .one) (B := (.lit (nat_lit 2)))
    (w := ⟨[⟨(.var (nat_lit 0)), .zero⟩,
      ⟨.inv, (.var (nat_lit 0))⟩],
      [],
      []⟩)
    (pts := [(Int.ofNat (nat_lit 1), nat_lit 1), (Int.ofNat (nat_lit 2), nat_lit 1)])
    (by decide +kernel) [] trivial

143 kinds of result certified, listed in the coverage ledger and checked against Mathlib in CI; all 240 certified integrals of the benchmark corpora, special functions such as erf, Si and Ei included, go through the reflective kernel

Refuses instead of guessing E-INT-004

When there is no answer, alkahest says so and says why. Every error has a stable code and a hint for what to do next

ak.integrate(ak.exp(x**3), x) # raises IntegrationError
[E-INT-004] integrate: no elementary antiderivative exists: ∫ e^(x³) dx …
Remediation: this integrand has no closed-form antiderivative in terms of elementary functions; use a numeric integrator or elliptic-integral library

Time, step and memory budgets raise E-BUDGET-* so a long call never hangs your program

Proven arithmetic kernels model-checked

The integer and modular arithmetic underneath everything is proven correct for every possible input with the Kani model checker

alkahest-core/src/modular/mod.rs
#[kani::proof]
fn mul_mod_in_range_full_width() {
    let a: u64 = kani::any();
    let b: u64 = kani::any();
    let m: u64 = kani::any_where(|m: &u64| *m > 0);
    assert!(mul_mod(a, b, m) < m);
}

50 proofs across 16 modules, checked on every pull request and nightly

Every step on record

Each result carries the list of rules that produced it and how it was verified, ready to log or compare

ak.integrate(x * ak.cos(x), x).to_dict(mode="compact")
{
  "kind": "alkahest.derived_result",
  "value": "(cos(x) + (x * sin(x)))",
  "verification": { "status": "exactly_verified" },
  "certificate_status": { "certifiable": true },
  "steps": [
    { "r": "int_poly_trig_ibp" },
    { "r": "const_fold" },
    { "r": "mul_one" }, …
  ]
}

crosscheck compares any answer against another computer algebra system

High performance on real workloads

Loading benchmarks…
Median time, log scale, shorter is faster