# Kalika Integer Arithmetic Benchmarks

This suite benchmarks Kalika integer multiplication, GCD, and semismooth
factor-extraction workloads at 64-bit, 128-bit, 1024-bit, 10000-bit, and
1000000-bit scales. The target comparison gates are:

- native Kalika: within 2x of FLINT
- WASM Kalika: within 5x of FLINT

Run the Kalika-only Criterion suite:

```sh
cargo bench -p kalika-cas-core --bench integer_arithmetic_flint
```

The 1000000-bit cases are intentionally opt-in for local workstation runs:

```sh
KALIKA_INTEGER_BENCH_INCLUDE_1M=1 \
  cargo bench -p kalika-cas-core --bench integer_arithmetic_flint
```

To include FLINT timings, build the helper against a system FLINT install and
point the benchmark at it:

```sh
cc benches/flint_integer_bench.c \
  $(pkg-config --cflags --libs flint) \
  -O3 -o /tmp/flint_integer_bench

KALIKA_FLINT_INTEGER_BENCH_HELPER=/tmp/flint_integer_bench \
  cargo bench -p kalika-cas-core --bench integer_arithmetic_flint
```

Criterion reports Kalika and FLINT samples under matching operation/bit-size
benchmark IDs, so ratio gates can be computed from the generated estimates.

## Differential Equation Solver Suite

The differential equation suite covers 230 symbolic solve cases: Kamke-style
first-order quadrature and linear ODE families, Kamke-style second-order
constant-coefficient ODE families, and standard transport, heat, wave, and
Laplace PDE templates. The summary benchmark records Kalika solvability and
correctness against stored Maple and SymPy baseline expectations.

Run the Kalika-only Criterion suite:

```sh
cargo bench -p kalika-cas-core --bench differential_equation_solvers
```

For a quick local smoke run, sample three cases from each source family:

```sh
KALIKA_DE_BENCH_SMOKE=1 \
  cargo bench -p kalika-cas-core --bench differential_equation_solvers
```

Optional Maple and SymPy wall-clock samples can be supplied with external
helpers. Each helper receives:

```text
iterations case-id-1 case-id-2 ...
```

and must print elapsed nanoseconds to stdout:

```sh
KALIKA_MAPLE_DE_BENCH_HELPER=/path/to/maple_de_helper \
KALIKA_SYMPY_DE_BENCH_HELPER=/path/to/sympy_de_helper \
  cargo bench -p kalika-cas-core --bench differential_equation_solvers
```

## Polynomial FLINT/SINGULAR Suite

The polynomial suite covers dense integer polynomial GCD and factorization
against FLINT-compatible helpers, sparse multivariate GCD fixtures, plus sparse
Groebner basis fixtures against SINGULAR- and Magma-compatible helpers:

- dense GCD degrees: 50, 100, 500
- sparse multivariate GCD variable counts: 3, 5, 8
- dense split factorization degrees over Z: 50, 100, 500
- cyclic-n Groebner fixtures: n=4,5,6,7,8
- Katsura-n Groebner fixtures: n=5,6,7,8,9,10,11,12

Run Kalika-only compile and benchmark checks:

```sh
cargo bench -p kalika-cas-core --bench polynomial_flint_singular --no-run
cargo bench -p kalika-cas-core --bench polynomial_flint_singular
```

The full target Groebner range runs by default. For quick local smoke runs,
restrict Groebner fixtures to n <= 5:

```sh
KALIKA_POLY_BENCH_SMOKE=1 \
  cargo bench -p kalika-cas-core --bench polynomial_flint_singular
```

External helpers can be wired in without adding hard FLINT/SINGULAR build
dependencies to the Rust crate. Each helper receives:

```text
operation size iterations
```

and must print elapsed nanoseconds to stdout. Use these environment variables:

```sh
KALIKA_POLY_FLINT_BENCH_HELPER=/path/to/flint_poly_bench \
KALIKA_POLY_SINGULAR_BENCH_HELPER=/path/to/singular_groebner_bench \
KALIKA_POLY_MAGMA_BENCH_HELPER=/path/to/magma_groebner_bench \
  cargo bench -p kalika-cas-core --bench polynomial_flint_singular
```

## Simplification FullSimplify Suite

The simplification suite covers 330 expressions across trigonometric,
exponential/logarithmic, radical, polynomial, and mixed simplification families.
Each case stores a Mathematica FullSimplify-compatible target form and
node-count target; Criterion records both whole-catalog complexity scans and
per-category time-per-expression samples.

Run the Kalika-only Criterion suite:

```sh
cargo bench -p kalika-cas-core --bench simplification_fullsimplify
```

For a quick local smoke run, sample five cases per category:

```sh
KALIKA_SIMPLIFICATION_BENCH_SMOKE=1 \
  cargo bench -p kalika-cas-core --bench simplification_fullsimplify
```

Optional Mathematica wall-clock samples can be supplied without making
Mathematica a build dependency. A helper receives:

```text
iterations case-id-1 case-id-2 ...
```

and must print elapsed nanoseconds to stdout:

```sh
KALIKA_MATHEMATICA_FULLSIMPLIFY_HELPER=/path/to/fullsimplify_helper \
  cargo bench -p kalika-cas-core --bench simplification_fullsimplify
```

## Symbolic Integration CAS Suite

The symbolic integration suite covers 528 indefinite integration cases with
provenance from the Bondarenko, Charlwood, Timofeev, and Rubi integration test
families. Each case stores the integrand, optimal antiderivative, source
reference, Rubi step metadata, and published-style Mathematica, SymPy, and
FriCAS baseline buckets.

Run the Kalika-only Criterion suite:

```sh
cargo bench -p kalika-cas-core --bench symbolic_integration_cas
```

CI can compile the full benchmark without spending workstation benchmark time:

```sh
cargo bench -p kalika-cas-core --bench symbolic_integration_cas --no-run
```

Optional external helpers can be supplied for live Mathematica, SymPy, or FriCAS
timings. A helper receives:

```text
iterations case-id-1 case-id-2 ...
```

and must print elapsed nanoseconds to stdout. Use these environment variables:

```sh
KALIKA_MATHEMATICA_INTEGRATION_HELPER=/path/to/mathematica_helper \
KALIKA_SYMPY_INTEGRATION_HELPER=/path/to/sympy_helper \
KALIKA_FRICAS_INTEGRATION_HELPER=/path/to/fricas_helper \
  cargo bench -p kalika-cas-core --bench symbolic_integration_cas
```
