{"id":50168197,"url":"https://github.com/alkahest-cas/alkahest","last_synced_at":"2026-05-28T23:01:42.031Z","repository":{"id":354750714,"uuid":"1216604986","full_name":"alkahest-cas/alkahest","owner":"alkahest-cas","description":"High-performance computer algebra system built for humans and AI","archived":false,"fork":false,"pushed_at":"2026-05-24T20:32:54.000Z","size":4513,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-24T22:26:32.068Z","etag":null,"topics":["agent-tools","computer-algebra","computer-algebra-system","python","rust"],"latest_commit_sha":null,"homepage":"https://alkahest-cas.github.io/","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alkahest-cas.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":"ROADMAP.md","authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2026-04-21T04:15:51.000Z","updated_at":"2026-05-24T20:32:56.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/alkahest-cas/alkahest","commit_stats":null,"previous_names":["areggevorgyan/alkahest","alkahest-cas/alkahest"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/alkahest-cas/alkahest","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alkahest-cas%2Falkahest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alkahest-cas%2Falkahest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alkahest-cas%2Falkahest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alkahest-cas%2Falkahest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alkahest-cas","download_url":"https://codeload.github.com/alkahest-cas/alkahest/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alkahest-cas%2Falkahest/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33629560,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-28T02:00:06.440Z","response_time":99,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["agent-tools","computer-algebra","computer-algebra-system","python","rust"],"created_at":"2026-05-24T22:02:52.101Z","updated_at":"2026-05-28T23:01:40.465Z","avatar_url":"https://github.com/alkahest-cas.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Alkahest\n\n[![CI](https://github.com/alkahest-cas/alkahest/actions/workflows/ci.yml/badge.svg)](https://github.com/alkahest-cas/alkahest/actions/workflows/ci.yml)\n[![cross-platform CI](https://github.com/alkahest-cas/alkahest/actions/workflows/ci-cross.yml/badge.svg)](https://github.com/alkahest-cas/alkahest/actions/workflows/ci-cross.yml)\n[![PyPI](https://img.shields.io/pypi/v/alkahest.svg)](https://pypi.org/project/alkahest/)\n[![Crates.io](https://img.shields.io/crates/v/alkahest-cas.svg)](https://crates.io/crates/alkahest-cas)\n[![Docs](https://img.shields.io/badge/docs-online-blue)](https://alkahest-cas.github.io/alkahest/)\n[![Ask DeepWiki](https://deepwiki.com/badge.svg?url=https%3A%2F%2Fdeepwiki.com%2Falkahest-cas%2Falkahest)](https://deepwiki.com/alkahest-cas/alkahest)\n[![License](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](LICENSE)\n\nA high-performance computer algebra system for Python built for both humans and agents. Symbolic operations run orders of magnitude faster than SymPy and can run on modern accelerated hardware. Every computation produces a derivation log; a meaningful subset can export Lean 4 proofs for independent verification.\n\n**Install:** the package is published on [PyPI](https://pypi.org/project/alkahest/); use `pip install alkahest` (**Python 3.9–3.13**). See [Install](#install) below for optional **`+jit`** / **`+full`** Linux wheels (GitHub Releases or a future extras index) and building from source.\n\n**Demo:** try the hosted **[playground](https://alkahest-cas.github.io/playground/)** (WASM in-browser, or bring your own server/Jupyter URL + token), or run [`demo-playground/`](demo-playground/) locally for the full agent and recording stack. See [`demo-playground/README.md`](demo-playground/README.md).\n\n**Stack:** Rust kernel → FLINT/Arb (polynomials, ball arithmetic) → egglog (e-graph simplification) → MLIR/LLVM (native and GPU codegen) → PyO3 → Python\n\n---\n\n## Install\n\n**Requirements:** Python **3.9–3.13** ([PyPI](https://pypi.org/project/alkahest/) `requires-python`).\n\n```bash\npip install alkahest\n```\n\nFor an isolated environment (recommended when juggling versions or building from source):\n\n```bash\npython3 -m venv .venv \u0026\u0026 source .venv/bin/activate   # Windows: .venv\\Scripts\\activate\npython -m pip install -U pip\npip install alkahest\n```\n\nWheels on PyPI are built **without** the LLVM JIT and **without** the optional `groebner` / `egraph` / `parallel` Rust features so installs stay small and avoid a runtime dependency on LLVM. Numeric APIs still work via the interpreter fallback; for native LLVM CPU JIT—or the full Gröbner/JIT stack—use a **PyTorch-style** opt-in wheel (separate artifact / index), not the default PyPI resolver path.\n\n### Opt-in Linux wheels: `+jit` and `+full` (PyTorch-style)\n\n**Why a separate index or direct wheel URL:** feature-heavy wheels use a PEP 440 **local version** (for example `2.0.3+jit` or `2.0.3+full`). Those builds **must not** be mixed into the main PyPI project’s simple API for the same reason PyTorch publishes CUDA wheels on `download.pytorch.org`: otherwise `pip install alkahest` could resolve a `+jit` / `+full` build as “newer” than `2.0.3` and pull LLVM (or a much larger binary) when you wanted the default wheel.\n\nThere is **no** `pip install alkahest[jit]` / `alkahest[full]` that swaps the native extension: **pip extras only add Python dependencies**, not alternate binaries for the same wheel slot.\n\n**Until a dedicated PEP 503 simple index is published**, tagged releases attach Linux **`linux_x86_64`** wheels on [GitHub Releases](https://github.com/alkahest-cas/alkahest/releases) (CI builds them on `ubuntu-22.04`, not the manylinux image used for default wheels). Pick the `.whl` whose tags match your Python (`cp311`, etc.) and **`linux_x86_64`**.\n\n| Local version | Cargo features | When to use |\n|---------------|----------------|-------------|\n| `+jit` | `jit` | Native LLVM CPU JIT only (smaller than `+full`). |\n| `+full` | `jit groebner parallel egraph` | JIT plus Gröbner-backed solvers, parallel F4, egglog e-graph backend (matches a typical maximal **from-source** dev build). |\n\nDirect-install examples (adjust tag and filename after checking the release assets):\n\n```bash\npip install \"https://github.com/alkahest-cas/alkahest/releases/download/v2.0.3/alkahest-2.0.3+full-cp311-cp311-linux_x86_64.whl\"\npip install \"https://github.com/alkahest-cas/alkahest/releases/download/v2.0.3/alkahest-2.0.3+jit-cp311-cp311-linux_x86_64.whl\"\n```\n\nThese wheels vendor LLVM (for JIT) and related `.so` files under `site-packages/alkahest.libs/`. If `import alkahest` fails with a missing `libffi-*.so` or `libLLVM-*.so`, prepend that directory to `LD_LIBRARY_PATH` (or install matching system packages). Release CI uses the same `LD_LIBRARY_PATH` step when smoke-testing wheels.\n\nIf your client chokes on `+` in the URL, use percent-encoding (`2.0.3%2Bfull` in the filename segment).\n\nAfter installing `+jit`, `alkahest.jit_is_available()` should be `True`. After `+full`, expect that **and** Gröbner-backed APIs such as `alkahest.solve`.\n\n*macOS and Windows `+jit` / `+full` wheels are not produced in CI yet (LLVM / MSYS2 constraints); use [building from source](#from-source) there.*\n\n**Target layout (roadmap):** a small **extra index** URL (PEP 503) hosting only `+jit` / `+full` wheels, mirroring PyTorch’s `--extra-index-url` workflow:\n\n```bash\npip install 'alkahest==2.0.3+full' --extra-index-url https://EXAMPLE/alkahest-extras/simple\n```\n\n### From source\n\nRequired to enable optional features (`jit`, `groebner`, `cuda`) or for development. Prerequisites:\n\n- **Rust** stable ≥ 1.76 and nightly:\n  ```bash\n  curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh\n  rustup toolchain install nightly\n  ```\n- **LLVM 15**: `apt install llvm-15 libllvm15 llvm-15-dev` / `brew install llvm@15`\n- **FLINT ≥ 2.9** (includes GMP and MPFR): `apt install libflint-dev` / `brew install flint`\n\n```bash\npip install maturin\nmaturin develop --manifest-path alkahest-py/Cargo.toml --release --features \"parallel egraph jit groebner\"\n```\n\nOptional Cargo features: `parallel` (sharded pool + parallel F4), `egraph` (egglog backend), `jit` (LLVM JIT), `groebner` (Gröbner solver + Diophantine + homotopy), `cuda` (NVPTX codegen).\n\n### Rust crate\n\n`alkahest-cas` is also published on [crates.io](https://crates.io/crates/alkahest-cas) ([docs.rs](https://docs.rs/alkahest-cas)) for use directly from Rust without a Python runtime:\n\n```toml\n[dependencies]\nalkahest-cas = \"2\"\n\n# With optional features:\n# alkahest-cas = { version = \"2\", features = [\"groebner\", \"parallel\", \"egraph\"] }\n```\n\n**System prerequisites** (same libraries as the Python build — must be present before `cargo build`):\n\n```bash\n# Debian / Ubuntu\nsudo apt-get install -y libflint-dev libgmp-dev libmpfr-dev\n\n# macOS\nbrew install flint\n```\n\nThe `jit` feature additionally requires LLVM 15 dev headers (`apt install llvm-15-dev` / `brew install llvm@15`). A self-contained runnable example is in [`examples/rust_quickstart/`](examples/rust_quickstart/).\n\n---\n\n## Quick start\n\n```python\nimport alkahest as ak\n\npool = ak.ExprPool()\nx = pool.symbol(\"x\")\n\n# Differentiation with derivation log\nresult = ak.diff(ak.sin(x ** 2), x)\nprint(result.value)   # 2*x*cos(x^2)\nprint(result.steps)   # list of rewrite steps\n\n# Integration\nr = ak.integrate(ak.exp(x), x)\nprint(r.value)        # exp(x)\n\n# Simplification\ns = ak.simplify(x + pool.integer(0))\nprint(s.value)        # x\n\n# JIT-compile to native code\nf = ak.compile_expr(x ** 2 + pool.integer(1), [x])\nprint(f([3.0]))       # 10.0\n```\n\n### Explicit polynomial representations\n\n```python\nimport alkahest as ak\n\npool = ak.ExprPool()\nx = pool.symbol(\"x\")\ny = pool.symbol(\"y\")\n\n# FLINT-backed univariate polynomial\np = ak.UniPoly.from_symbolic(x ** 3 + pool.integer(-2) * x + pool.integer(1), x)\nprint(p.degree())        # 3\nprint(p.coefficients())  # [1, -2, 0, 1]\n\n# GCD\na = ak.UniPoly.from_symbolic(x ** 2 + pool.integer(-1), x)\nb = ak.UniPoly.from_symbolic(x + pool.integer(-1), x)\nprint(a.gcd(b))          # x - 1\n\n# Factorization over ℤ (FLINT — Zassenhaus / van Hoeij)\nfac = a.factor_z()\nprint(int(fac.unit), fac.factor_list())  # unit and list of (UniPoly, exponent)\n\n# Dense univariate mod p (Berlekamp / Cantor–Zassenhaus via FLINT nmod)\nfp = ak.factor_univariate_mod_p([1, 0, 1], 2)  # x^2+1 over GF(2)\nprint(fp.factor_list())\n\n# Rational function with automatic GCD normalization\nrf = ak.RationalFunction.from_symbolic(x ** 2 + pool.integer(-1), x + pool.integer(-1), [x])\nprint(rf)                # x + 1\n\n# Sparse multivariate polynomial\nmp = ak.MultiPoly.from_symbolic(x ** 2 * y + x * y ** 2, [x, y])\nprint(mp.total_degree()) # 3\n```\n\n### Sparse multivariate interpolation (Ben-Or/Tiwari, Zippel)\n\nBlack-box recovery of sparse polynomials from evaluations, and sparse modular GCD as a substrate for faster exact GCD algorithms.\n\n```python\nimport alkahest as ak\n\npool = ak.ExprPool()\nx, y = pool.symbol(\"x\"), pool.symbol(\"y\")\n\n# Recover a sparse univariate f ∈ 𝔽ₚ[x] from 2T black-box evaluations\np = 32749  # prime\ntarget = lambda v: (v**5 + 3*v**3 + 7) % p  # hidden: x^5 + 3x^3 + 7\nf = ak.sparse_interp_univariate(target, T=3, prime=p)\nprint(f)   # recovered polynomial\n\n# Recover a sparse multivariate f ∈ 𝔽ₚ[x, y] via Zippel's algorithm\ntarget2 = lambda vals: (vals[0]**3 * vals[1]**2 + vals[0] * vals[1]**4) % p\ng = ak.sparse_interp(target2, vars=[x, y], T=2, D=5, prime=p)\nprint(g)   # recovered MultiPolyFp\n\n# Sparse modular GCD over ℤ[x₁,...,xₙ]\nf2 = ak.MultiPoly.from_symbolic((x + y) * (x - y), [x, y])\ng2 = ak.MultiPoly.from_symbolic((x + y) * (x + pool.integer(1)), [x, y])\nh = ak.gcd_sparse(f2, g2, term_bound=4, degree_bound=4)\nprint(h)   # x + y\n```\n\n### Symbolic summation (Gosper / recurrences)\n\nIndefinite and definite sums for terms whose shift ratio `F(k+1)/F(k)` is rational in `k`—typically polynomials multiplied by `gamma` of a **linear** expression in `k`. General multivariate Zeilberger automation is partial; use `verify_wz_pair(F, G, n, k)` to check a discrete telescoping certificate after simplification.\n\n```python\nimport alkahest as ak\n\npool = ak.ExprPool()\nk = pool.symbol(\"k\")\nn = pool.symbol(\"n\")\nterm = ak.simplify(k * ak.gamma(k + pool.integer(1))).value\nprint(ak.sum_indefinite(term, k).value)\nprint(ak.sum_definite(term, k, pool.integer(0), n).value)\n\nfib = ak.solve_linear_recurrence_homogeneous(\n    n, [(-1, 1), (-1, 1), (1, 1)], [pool.integer(0), pool.integer(1)]\n)\n```\n\n### Difference equations / `rsolve`\n\nLinear recurrences in one sequence with **constant coefficients** and a **polynomial** right-hand side (in the recurrence index `n`). Write shifts as `pool.func(\"f\", [n + integer])`, pass the equation as a single expression that simplifies to zero, and optional `initials` as `{n: value}` to fix the `C0`, `C1`, … symbols.\n\n```python\nimport alkahest as ak\n\npool = ak.ExprPool()\nn = pool.symbol(\"n\")\nf = lambda *a: pool.func(\"f\", list(a))\n# f(n) - f(n-1) - 1 == 0  →  general solution n + C0\neq = ak.simplify(f(n) - f(n + pool.integer(-1)) - pool.integer(1)).value\nprint(ak.rsolve(eq, n, \"f\", None))\n# Fibonacci with f(0)=0, f(1)=1\nfib_eq = ak.simplify(\n    f(n) - f(n + pool.integer(-1)) - f(n + pool.integer(-2))\n).value\nprint(ak.rsolve(fib_eq, n, \"f\", {0: pool.integer(0), 1: pool.integer(1)}))\n```\n\nNon-homogeneous **order \u003e 2** and sequences with **polynomial coefficients** in `n` are not implemented yet (see `RsolveError` / `E-RSOLVE-*`).\n\n### Symbolic products (`∏`)\n\n`product_definite(term, k, lo, hi)` closes $\\prod_{i=\\text{lo}}^{\\text{hi}} \\text{term}(i)$ (inclusive) when `term` simplifies to **ℚ(`k`)** whose numerator/denominator **factor into ℤ-linear** polynomials — the implementation expands each linear factor $\\alpha k+\\beta$ with $\\Gamma$ shifts $\\Gamma(\\text{hi}+\\beta/\\alpha+1)/\\Gamma(\\text{lo}+\\beta/\\alpha)$ and collects $\\alpha^{(\\text{hi}-\\text{lo}+1)\\cdot e}$. `product_indefinite` returns a `Γ`/power witness `Z(k)` with `simplify`-stable ratio `Z(k+1)/Z(k)=term`. `Product(term, (k, lo, hi)).doit()` matches SymPy ergonomics (`DerivedResult`; use `.value`). Irreducible quadratics in `k`, extra symbols besides `k`, and non-integer powers are rejected (`ProductError` / `E-PROD-*`).\n\n```python\nimport alkahest as ak\n\npool = ak.ExprPool()\nk, n = pool.symbol(\"k\"), pool.symbol(\"n\")\nP = ak.Product(k, (k, pool.integer(1), n))\nprint(ak.simplify(P.doit().value).value)\n\nkp2 = k ** 2\nterm = ak.simplify(\n    ((k + pool.integer(-1)) * (k + pool.integer(1))) / kp2\n).value  # (k²-1)/k²\n\nprint(ak.simplify(\n    ak.product_definite(term, k, pool.integer(2), n).value\n).value)\n```\n\n### Diophantine equations\n\nTwo integer unknowns, equation as a single polynomial `= 0`: **linear** families `a·x + b·y + c = 0`, **sum of two squares** `x² + y² = n` (finitely many tuples), and **unit Pell** `x² - D·y² = 1` (fundamental solution `(x₀, y₀)` via the continued-fraction period of `√D`). Requires the `groebner` feature in the native build. API: `diophantine(equation, [x, y])` → `DiophantineSolution` with `.kind` (`parametric_linear`, `finite`, `pell_fundamental`, `no_solution`) and typed fields.\n\n```python\nimport alkahest as ak\n\npool = ak.ExprPool()\nx, y = pool.symbol(\"x\"), pool.symbol(\"y\")\nsol = ak.diophantine(pool.integer(3) * x + pool.integer(5) * y - pool.integer(1), [x, y])\nassert sol.kind == \"parametric_linear\"\npell = ak.diophantine(x**2 - pool.integer(2) * y**2 - pool.integer(1), [x, y])\nassert pell.kind == \"pell_fundamental\" and int(str(pell.fundamental[0])) == 3\n```\n\nQuadratics with an **`x·y` cross-term**, unequal ellipse coefficients, or **generalized Pell** right-hand sides `≠ 1` are not implemented yet (`DiophantineError` / `E-DIOPH-*`).\n\n### Integer number theory\n\nSubmodule `alkahest.number_theory`: `isprime`, `factorint`, `nextprime`, `totient`, `jacobi_symbol`, `nthroot_mod` (prime modulus; `k=2` or `gcd(k,p−1)=1`), `discrete_log` (linear scan for moderate primes), plus quadratic `DirichletChi` on odd square-free conductors. Implemented via FLINT `fmpz` in the Rust kernel; raises `NumberTheoryError` (`E-NT-*`) on invalid input.\n\n```python\nimport alkahest as ak\nimport alkahest.number_theory as nt\n\nassert nt.isprime(2**127 - 1)\nassert nt.factorint(2**32 - 1)[65537] == 1\nassert nt.discrete_log(13, 3, 17) == 4\nassert pow(nt.nthroot_mod(144, 2, 401), 2, 401) == 144 % 401\n```\n\n### Noncommutative algebra\n\nSymbols can opt out of multiplicative commutativity: `pool.symbol(\"A\", \"real\", commutative=False)`. Then `A * B` and `B * A` are distinct expressions, and sorting of `Mul` factors is disabled. The egglog backend automatically falls back to the rule-based simplifier when such symbols appear.\n\nPauli matrices (names `sx`, `sy`, `sz`) and a minimal orthogonal Clifford pair (`cliff_e1`, `cliff_e2`) have built-in rewrite tables; combine default rules with `ak.simplify_pauli` or `ak.simplify_clifford_orthogonal`. See `examples/noncommutative.py`.\n\n### Truncated series / Laurent tail\n\n`series(expr, var, point, order)` builds a symbolic truncation about `(var − point)` and appends a `BigO(⋯)` remainder. Smooth functions use repeated differentiation; simple poles such as `1/x` at zero take the rational Laurent path. `Series.expr` is the pooled sum-plus-order expression; `ExprPool.big_o(inner)` constructs standalone order bounds.\n\n```python\nimport alkahest as ak\n\npool = ak.ExprPool()\nx = pool.symbol(\"x\")\ns_cos = ak.series(ak.cos(x), x, pool.integer(0), 6)\ns_inv = ak.series(x ** (-1), x, pool.integer(0), 4)\nprint(s_cos.expr)\n```\n\n### Rigorous interval arithmetic\n\n```python\nimport alkahest as ak\n\npool = ak.ExprPool()\nx = pool.symbol(\"x\")\nresult = ak.interval_eval(ak.sin(x), {x: ak.ArbBall(1.0, 1e-10)})\nprint(result)  # guaranteed enclosure of sin(1 ± 1e-10)\n```\n\n### String expressions\n\n```python\nimport alkahest as ak\n\npool = ak.ExprPool()\nx = pool.symbol(\"x\")\n\n# Parse a string into a symbolic expression\ne = ak.parse(\"x^2 + 2*x + 1\", pool, {\"x\": x})\nprint(e)                    # (x^2 + (x * 2)) + 1\n\n# Round-trip: parse then pretty-print\nexpr = ak.parse(\"sin(x)^2 + cos(x)^2\", pool, {\"x\": x})\nprint(ak.latex(expr))        # \\sin\\!\\left(x\\right)^2 + \\cos\\!\\left(x\\right)^2\nprint(ak.unicode_str(expr))  # sin(x)² + cos(x)²\n```\n\n### Lattice reduction and approximate integer relations\n\nExact LLL reduction on integer bases lives under `alkahest.lattice`; for floating constants (as `float` or decimal strings) `guess_relation` searches for small integer coefficient vectors whose dot product has tiny residual relative to the working precision:\n\n```python\nimport alkahest as ak\n\nbasis = ak.lattice.lll_reduce_rows([[2, 15], [1, 21]])\nrel = ak.guess_relation([\"1\", \"2\", \"3\"], precision_bits=256)\n```\n\nThe relation finder is an augmented-lattice + LLL heuristic, not Ferguson–Bailey PSLQ; treat results as exploratory unless verified independently.\n\n### Regular chains / triangular decomposition\n\nLex-order Gröbner bases yield triangular sets used by the polynomial solver. The `triangularize(equations, vars)` API returns one or more `RegularChain` objects (polynomials as `GbPoly` tiles), splitting along factored bottom univariates when applicable. The built-in `solve()` routine retries backsolving from an extracted chain when the full basis is not directly triangular enough.\n\n```python\nimport alkahest as ak\n\npool = ak.ExprPool()\nx = pool.symbol(\"x\")\ny = pool.symbol(\"y\")\neq1 = x**2 + y**2 - pool.integer(1)\neq2 = y - x\nchains = ak.triangularize([eq1, eq2], [x, y])\nassert len(chains) \u003e= 1\n```\n\n### Primary decomposition\n\nLex-order Gröbner data is used to split ideals via saturations (`I : x_i^∞` with `(I + (x_i))`) and, in the zero-dimensional case, factoring a univariate polynomial in the first Lex variable. `primary_decomposition(polys, vars)` returns `PrimaryComponent` objects with `.primary()` and `.associated_prime()` Gröbner bases; `radical(polys, vars)` returns a basis for √I.\n\n```python\nimport alkahest as ak\n\npool = ak.ExprPool()\nx, y, z = pool.symbol(\"x\"), pool.symbol(\"y\"), pool.symbol(\"z\")\ncomps = ak.primary_decomposition([x * y, x * z], [x, y, z])\nassert len(comps) == 2\nr = ak.radical([x**2, x * y], [x, y])\nassert r.contains(x)\n```\n\n### Differential algebra / Rosenfeld–Gröbner\n\nPolynomial DAEs in implicit form `g_i(t, y, y') = 0` can be analysed by **prolongation** (formal time derivatives of each equation, with the same derivative-state extension rule as Pantelides) and **ordinary Gröbner bases** over the jet variables. Inconsistent systems yield the unit ideal. Use `rosenfeld_groebner(dae, order=..., max_prolong_rounds=...)`; when Pantelides exhausts its index cap, `dae_index_reduce(dae)` falls back to this pass.\n\n```python\nimport alkahest as ak\n\npool = ak.ExprPool()\nt = pool.symbol(\"t\")\ny = pool.symbol(\"y\")\ndy = pool.symbol(\"dy/dt\")\ndae = ak.DAE.new([dy - y, dy - y - pool.integer(1)], [y], [dy], t)\nr = ak.rosenfeld_groebner(dae, max_prolong_rounds=2)\nassert r.consistent is False\n```\n\n### Numerical algebraic geometry / homotopy continuation\n\nSquare polynomial systems can be solved numerically with a **total-degree** homotopy in `ℂⁿ` (`(1-t)·γ·G + t·F`), Newton polish on real projections, a conservative **Smale-style** `α` heuristic, and **`ArbBall` enclosures** attached to each coordinate. Use `solve(eqs, vars, method=\"homotopy\")` for a list of `dict` solutions (`Expr` keys → `float`). For residuals, certification flags, and enclosures, call `solve_numerical(...)`, which returns `CertifiedSolution` objects (`.coordinates`, `.smale_certified`, `.to_dict()`, `.enclosures()`, …).\n\nIdeals whose finite root count in `ℂⁿ` is **strictly below** the Bézout bound (often called *deficient* — e.g. the Katsura family) typically need a **polyhedral / mixed-volume** start system; only the Bézout start (`∏ deg F_i` paths) is implemented here.\n\n```python\nimport alkahest as ak\n\npool = ak.ExprPool()\nx, y = pool.symbol(\"x\"), pool.symbol(\"y\")\nneg1 = pool.integer(-1)\nsols = ak.solve([x**2 + neg1, y**2 + neg1], [x, y], method=\"homotopy\")\ncs = ak.solve_numerical([x**2 + neg1], [x])[0]\nprint(cs.coordinates, cs.smale_certified, cs.enclosures())\n```\n\n### Composable transformations\n\n```python\nimport alkahest as ak\n\npool = ak.ExprPool()\n\n@ak.trace(pool)\ndef f(x):\n    return ak.sin(x ** 2)\n\ndf = ak.grad(f)          # symbolic gradient\ndf_fast = ak.jit(df)     # compiled gradient\n```\n\n---\n\n## Directory layout\n\n```\nalkahest/\n├── alkahest-core/         # Rust kernel (published as the alkahest-cas crate)\n│   ├── src/\n│   │   ├── kernel/        # hash-consed expression DAG, ExprPool\n│   │   ├── algebra/       # noncommutative Pauli / Clifford rules\n│   │   ├── parse.rs       # Pratt expression parser (parse / ParseError)\n│   │   ├── poly/          # UniPoly, MultiPoly, RationalFunction\n│   │   ├── simplify/      # e-graph simplification (egglog)\n│   │   ├── diff/          # symbolic differentiation\n│   │   ├── integrate/     # symbolic integration\n│   │   ├── calculus/      # series / limits\n│   │   ├── jit/           # LLVM JIT and interpreter\n│   │   ├── ball/          # Arb ball arithmetic\n│   │   ├── ode/           # ODE analysis\n│   │   ├── dae/           # DAE analysis and index reduction\n│   │   ├── diffalg/       # Rosenfeld–Gröbner / differential elimination (groebner)\n│   │   ├── solver/        # polynomial solving: Gröbner triangular, regular chains, homotopy\n│   │   ├── lean/          # Lean 4 proof certificate export\n│   │   └── primitive/     # primitive registration system\n│   └── benches/           # criterion benchmarks\n├── alkahest-mlir/         # MLIR dialect and lowering passes\n├── alkahest-py/           # PyO3 bindings (Rust side)\n├── python/alkahest/       # Python package\n│   ├── _transform.py      # trace, grad, jit decorators\n│   ├── _pytree.py         # JAX-style pytree flattening\n│   ├── _context.py        # context manager and defaults\n│   └── experimental/      # unstable API surface\n├── examples/              # runnable end-to-end examples\n│   └── rust_quickstart/   # self-contained Cargo project for alkahest-cas\n├── tests/                 # Python test suite (pytest + hypothesis)\n├── benchmarks/            # Python benchmarks and competitor comparisons\n├── fuzz/                  # AFL++ fuzz targets\n├── docs/                  # mdBook and Sphinx documentation\n├── website/               # landing page (alkahest-cas.github.io)\n│   └── src/               # index.html + styles.css source (deployed via CI)\n├── alkahest-skill/        # Skill for AI to use alkahest\n├── agent-benchmark/       # benchmark for comparing AI use of alkahest vs other CAS\n└── scripts/               # CI helpers (API freeze check, error codes)\n```\n\n---\n\n## Expression representations\n\n| Type | Description |\n|---|---|\n| `Expr` | Generic hash-consed symbolic expression |\n| `UniPoly` | Dense univariate polynomial (FLINT-backed) |\n| `MultiPoly` | Sparse multivariate polynomial over ℤ |\n| `MultiPolyFp` | Sparse multivariate polynomial over 𝔽ₚ (modular arithmetic) |\n| `RationalFunction` | Quotient of polynomials with GCD normalization |\n| `ArbBall` | Real interval with rigorous error bounds (Arb) |\n\nRepresentation types are explicit — no silent performance cliffs. Conversion between them is always an opt-in call (`UniPoly.from_symbolic(...)`, etc.).\n\n---\n\n## Result objects\n\nEvery top-level operation returns a `DerivedResult` with:\n\n- `.value` — the result expression\n- `.steps` — derivation log (list of rewrite rules applied)\n- `.certificate` — Lean 4 proof term, when available\n\n---\n\n## Documentation and further reading\n\n- [**Documentation site**](https://alkahest-cas.github.io/alkahest/) — full API reference and user guide\n- [`ROADMAP.md`](ROADMAP.md) — planned milestones\n- [`CONTRIBUTING.md`](CONTRIBUTING.md) — Rust vs Python layer guide\n- [`TESTING.md`](TESTING.md) — property-based testing, fuzzing, sanitizers, CI tiers\n- [`BENCHMARKS.md`](BENCHMARKS.md) — criterion and Python benchmark suites\n- [`examples/`](examples/) — runnable end-to-end examples\n- [`LICENSE`](LICENSE) — Apache 2.0 license\n\n---\n\n## Stability\n\nAlkahest follows semantic versioning from `1.0`. The stable surface is everything re-exported from `alkahest_cas::stable` (Rust) and `alkahest.__all__` (Python). Experimental APIs live under `alkahest_cas::experimental` and `alkahest.experimental` and may change in minor releases.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falkahest-cas%2Falkahest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falkahest-cas%2Falkahest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falkahest-cas%2Falkahest/lists"}