Skip to content
PerAlexanderssonPublic

About

Exact univariate polynomial tools for real-rootedness, interlacing, and combinatorics

Resources

Stars

1 star

Watchers

1 watching

Forks

Repository files navigation

polytool

Dense univariate polynomial toolkit for combinatorial research. Provides real-rootedness testing by adaptive subresultant integer root counting, Bézout-matrix interlacing checks, exact Hurwitz stability, log-concavity, gamma-positivity, resultants, Ehrhart/h*-vector conversion, recurrence search for polynomial sequences, finite Athanasiadis--Wagner interlacing matrices, and standard sequences — all with exact arithmetic.

Features

  • Exact real-rootedness testing by adaptive subresultant integer root counting (the engine is the standalone exact-real-roots crate), Bézout-matrix and Sturm-chain interlacing tests, and exact Hurwitz stability.
  • Unimodality, log-concavity, ultra-log-concavity, palindromicity and gamma-positivity (with the gamma expansion), Bernstein-basis expansion, resultants and discriminants.
  • Ehrhart/h*-vector conversion, h*-inequalities, cyclic and bicyclic sieving checks, Stapledon decomposition.
  • Exact labelled-block exponential rows with sparse extraction and in-process root checks.
  • Recurrence search for polynomial sequences (with certified complete spaces, coordinate transformations and implicit differential relations), renewal recognition, and a bundled catalog of recurrence-backed OEIS families.
  • Planar-network certificates: TNN triangles, strip digraphs and Pólya frequency rows.
  • Finite Athanasiadis--Wagner interlacing matrices, standard sequences (Eulerian, Narayana, Chebyshev, Hermite, ...), and enumeration of real-rooted integer polynomials with a prescribed leading prefix.
  • A curated family overview with public proof links, exact generators and OEIS draft exports; see the family guide.
  • A command-line tool, an MCP server and a browser (WebAssembly) wrapper, all over the same exact-arithmetic library.

Installation

The command-line program is the package crates/polytool-cli (binary polytool). From the repository root, build it with

cargo build --locked --release --manifest-path crates/polytool-cli/Cargo.toml --target-dir target

The CLI binary is then at target/release/polytool. Run that binary directly, or install it on your Cargo binary path:

cargo install --locked --path crates/polytool-cli

Use polytool --version (or polytool -V) for a single deterministic line:

polytool 0.9.0 (git 0123456789ab)

The version comes from the CLI's manifest and the lowercase 12-hex-digit Git commit is captured at build time from the last commit affecting the Polytool subtree (the repository commit in a standalone checkout). If the source is built without trustworthy Git metadata, the suffix is (git unavailable) rather than a fabricated revision. Reproducible packaging environments may set POLYTOOL_GIT_COMMIT to a full or at least 12-digit hexadecimal revision; an empty or malformed value deliberately selects the unavailable form.

Using as a crate

The library crate is usable today from another Rust project by depending on this directory:

[dependencies]
polytool = { path = "../polytool" }

From GitHub, depend on the repository's standalone main branch:

[dependencies]
polytool = { git = "https://github.com/PerAlexandersson/polytool.git" }

Crates.io publication is currently held: the bundled exact-algebra package is not published, and path-only sibling dependency metadata must be prepared before publishing this package graph. Git and local builds include those crates. After publishing to crates.io, the dependency would be:

[dependencies]
polytool = "0.8"

The public API is re-exported from polytool, so a downstream crate can write:

use polytool::{check_weak_interlacing, is_real_rooted};

assert!(is_real_rooted(&[1, 11, 11, 1]));
assert_eq!(check_weak_interlacing(&[-1, 1], &[2, -3, 1]), Some(true));

Coefficient vectors are always in ascending degree order. Most convenience functions accept &[i64]; use the *_bigint_coeffs variants when coefficients may exceed i64. Interlacing functions return Option<bool>: None means the directed degree relation is not valid for that test, not that interlacing failed. For the undirected question "do f and g interlace in some order?", use interlaces_either_order, which returns a plain bool.

More library examples (real-rootedness and interlacing, Athanasiadis--Wagner interlacing matrices, planar networks, polynomial arithmetic, recurrence search, enumeration of real-rooted integer polynomials, ...) are in doc/library.md. Build searchable API documentation with cargo doc --no-deps --open. The crate has not yet been published on docs.rs. The documentation build guide combines the guides, generated CLI reference and rustdoc into a static site.

CLI quick start

Command Purpose
families Curated OEIS and submission-bound families, generation and OEIS drafts; guide
exp-rows Exact exponential-family rows from series expressions, in-process checks and symbolic routes; guide

Polynomials are read from standard input, one per line, as comma-separated integer coefficients in ascending degree order (1, 11, 11, 1 is 1 + 11t + 11t^2 + t^3):

echo "1, 11, 11, 1" | polytool real-rooted
polytool sequence eulerian 8 --format rows > polys.txt
polytool interlacing --json < polys.txt
polytool properties < polys.txt
polytool sequence eulerian 5
polytool oeis generate A008292 --count 8 --format triangle
polytool recurrence < polys.txt
echo "1, 0, -3, 1" | polytool discriminant

Many commands accept --json for machine-readable output, and large integer coefficients are serialized as strings. See doc/cli.md for the input format and the full command reference.

Start with the CLI workflows for generation, recurrence discovery, report reuse and shell pipelines. polytool --help groups commands by task; polytool help --json provides a machine-readable command index.

MCP server and web app

  • mcp/ contains a local Model Context Protocol server (polytool-mcp) that exposes the exact routines to MCP clients over stdio. Build, install and client configuration are described in mcp/README.md; the remaining notes on the tool set are in doc/mcp.md.
  • web/ contains a browser wrapper over the same Rust code (WebAssembly); see doc/web.md for the arbitrary-precision contract and the build.
  • The library itself is split into layered crates under crates/, which the polytool crate re-exports at the same paths: polytool-core (polynomials, real-rootedness, interlacing, linear algebra, sequences and the recurrence model), polytool-oeis (the bundled catalog), polytool-recurrence (the recurrence searches), polytool-theorems (the real-rootedness theorem checks and BKW), polytool-proofs (lifts, proof discovery, renewal) and polytool-combinatorics (network, sieving and h* certificates). The front ends share the JSON conversions of the reports through polytool-json. See doc/library.md.
  • crates/exact-real-roots is the standalone exact root-counting crate that polytool depends on; see crates/exact-real-roots/README.md.
  • crates/ore-algebra is the standalone exact Ore-algebra crate (shift and derivative operators, pseudo-division, common left multiples, image annihilators with identity certificates) behind polytool's recurrence transport and image recurrences; see crates/ore-algebra/README.md.

Documentation

Support

Report issues in the Git repository, or contact Per Alexandersson (@PerAlexandersson, per.w.alexandersson@gmail.com).

For general recurrence proofs, use polytool recurrence prove --recurrence recurrence.json. The proof-discovery guide explains the exact theorem checks, certificates and Lean correspondence. Rational generating functions also have effective dominant-pair certificates through polytool bkw effective, and polytool bkw dominance decides whether some nonreal parameter gives two or more dominant characteristic roots (nonreal dominance queries). For the degree law and the leading-coefficient signs of every row, use polytool recurrence degree --recurrence recurrence.json (see doc/cli-recurrence.md).

About

Exact univariate polynomial tools for real-rootedness, interlacing, and combinatorics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages