Commit cbd9449
feat(coprocessor): Phase 2a — FLINT FFI CAS backend
Adds `CoprocessorKind::FlintMath` and the full `FlintMathBackend` wired
via Rust FFI to the FLINT C library (LGPL-3). FLINT is the only CAS
backend in ECHIDNA that links in-process rather than shelling out —
earning trust tier LibraryWrapped (Tier 3), same as `MathBackend`.
## What lands
**New `CoprocessorOp` variants** (polynomial algebra + enhanced integer ops):
- `FlintPolyGcd` — primitive GCD of two polynomials over Z
- `FlintPolyMul` — product of two polynomials over Z
- `FlintPolyRem` — pseudo-remainder (lc(g)^d · f = q·g + r)
- `FlintPolyContent` — GCD of all coefficients of a polynomial
- `FlintNthRoot` — exact integer k-th root (Empty if not exact)
- `FlintBinomial` — binomial coefficient C(n, k)
**New `CoprocessorOutcome::Polynomial`** — wire format: space-separated
decimal coefficients in degree-ascending order; "0" for zero polynomial.
**`src/rust/coprocessor/flint.rs`** — RAII wrappers (`Fmpz`, `FmpzPoly`)
over `fmpz_t` / `fmpz_poly_t`; `extern "C"` declarations for 15 FLINT
functions; `FlintMathBackend` implementing `Coprocessor`; 8 unit tests.
**`--features flint`** — build.rs discovers system FLINT via pkg-config
or bare `-lflint`. Without the feature, `CoprocessorFactory::native`
returns `None` for `FlintMath` — callers fall through gracefully.
**`julia_bridge.rs`** — exhaustive `kind_name` match extended for `FlintMath`.
## Tests
33 coprocessor tests pass. New `flint_math_unavailable_without_feature`
confirms factory returns `None` without `--features flint`. The 8
flint-specific tests (poly GCD, mul, rem, content, nth-root, binomial)
run only when `--features flint` is active and FLINT is installed.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent 9af87ba commit cbd9449
19 files changed
Lines changed: 3055 additions & 6 deletions
File tree
- .machine_readable/6a2
- src/rust
- coprocessor
- ffi
- provers
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
| 45 | + | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
48 | 49 | | |
49 | 50 | | |
50 | 51 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
| 113 | + | |
113 | 114 | | |
114 | 115 | | |
115 | 116 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
53 | 93 | | |
54 | 94 | | |
55 | 95 | | |
| |||
0 commit comments