Skip to content

feat(rocq): wire mathcomp into the toolchain — Coq-Interval is unusable without it - #43

Merged
avrabe merged 3 commits into
mainfrom
feat/mathcomp-for-coq-interval
Jul 22, 2026
Merged

feat(rocq): wire mathcomp into the toolchain — Coq-Interval is unusable without it#43
avrabe merged 3 commits into
mainfrom
feat/mathcomp-for-coq-interval

Conversation

@avrabe

@avrabe avrabe commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Coq-Interval (added in #41) is present but unusable: Require Import Interval.Tactic fails with Cannot load mathcomp.boot.seq: no physical path bound to mathcomp.boot. Interval depends on Mathematical Components, which the toolchain does not expose on the coqc load path. This blocks the FP approximation-layer proofs (relay MATHF32-P04/P05).

Mirrors the Interval/Coquelicot wiring for mathcomp (rocq_mathcomp nixpkgs_package + filegroup + toolchain attr + extra_libs -Q binding).

NOT YET VALIDATED end-to-end — on a consumer with a pinned lock the extension didn't re-evaluate (rocq_mathcomp not materialised, same error). Open: (1) is coqPackages.mathcomp the right attr (modern mathcomp splits into boot/ssreflect/algebra)? (2) do the path pattern + glob match the nix layout? (3) lock refresh needed. Filed as the prerequisite for the approximation-layer proof track.

🤖 Generated with Claude Code

Coq-Interval (added in #41) is present but UNUSABLE: `Require Import
Interval.Tactic` fails with "Cannot load mathcomp.boot.seq: no physical
path bound to mathcomp.boot" — Interval depends on Mathematical
Components, which the toolchain does not expose on the coqc load path.

This mirrors the Interval/Coquelicot wiring for mathcomp: a rocq_mathcomp
nixpkgs_package (coqPackages.mathcomp), a filegroup BUILD, the toolchain
`mathcomp` attr, and the extra_libs -Q binding (logical name `mathcomp`).

NOT YET VALIDATED end-to-end: on a consumer (relay) with a pinned
MODULE.bazel.lock, the module extension did not re-evaluate, so
rocq_mathcomp was not materialised and the smoke proof still failed with
the same error. Needs: (a) confirm `coqPackages.mathcomp` is the right nix
attribute (modern mathcomp is split into boot/ssreflect/algebra — a meta
vs component question), (b) confirm the `/mathcomp/` path pattern +
lib/coq glob match the nix output layout, (c) a lock refresh so the
extension re-runs. Filed so the approximation-layer FP proofs
(relay MATHF32-P04/P05) can proceed once green.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HvusAXYbHLyv3uTzfBcMbG
@avrabe

avrabe commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

Verified this empirically before merging (per the operating discipline: reproduce, don't trust a done-flag). Recommend not merging as-is — the diagnosis is right (Coq-Interval genuinely can't load without mathcomp), but this specific fix doesn't resolve it, and the gap is deeper than one missing package.

coqPackages.mathcomp is the wrong attribute. Built it and checked:

$ nix build --expr '(import nixpkgs {}).coqPackages.mathcomp'
→ only lib/coq/9.0/user-contrib/mathcomp/all/all.vo  (1 file — an umbrella re-export)

It does not contain mathcomp/boot/seq.vo — the exact module the original error names. mathcomp.boot.seq lives in the separate coqPackages.mathcomp-boot derivation; modern mathcomp splits into ~20 sub-packages (boot, ssreflect, fingroup, algebra, ...), and mathcomp alone is just a thin re-export shell. Wiring attribute_path = "coqPackages.mathcomp" as this PR does would still fail with the identical error post-merge.

The real dependency list, read directly off nixpkgs (not guessed):

$ nix eval '(import nixpkgs {}).coqPackages.interval.propagatedBuildInputs'
→ bignums, coquelicot, flocq, mathcomp-boot, mathcomp-fingroup, gnuplot

So this is also missing bignums entirely (not wired in #41 either — my miss, not just this PR's).

And it goes one level deeper still. mathcomp-boot itself needs hierarchy-builder (HB), and HB needs coq-elpi — which is a real OCaml plugin (findlib META + .cmxs), not a plain .v library. A smoke test (Require Import Interval.Tactic. Goal (1+1<=3)%R. Proof. interval. Qed.) compiled against every individual package I could enumerate manually still failed on Findlib error: ppx_deriving.runtime not found — the OCaml findlib closure for elpi keeps going, the same category of complexity this repo already had to solve once for Hammer.

What actually works, verified:

nix build --expr '(import nixpkgs {}).coq_9_0.withPackages (p: [p.flocq p.interval p.coquelicot])'

Using that environment's coqc directly on the smoke test above: exit 0, .vo produced, no manual -Q list, no findlib chasing — withPackages has nixpkgs resolve the entire transitive closure (mathcomp-boot/fingroup, bignums, hierarchy-builder, coq-elpi, and elpi's own OCaml deps) the way it's designed to. Confirmed the .vo load path is also reconstructible via a single -Q <that-tree>/lib/coq/9.0/user-contrib "" (the subdirs are already named Flocq/Interval/mathcomp/Bignums/HB/elpi etc., so the empty logical root just works) — but the OCaml plugin/findlib side only resolves through the withPackages-produced coqc binary itself (it has the OCaml env baked in at the binary level, not something I could reproduce by hand as an env var).

Recommendation: the real fix is architectural, not a quick patch — either (a) a second, withPackages-composed coqc scoped to the approximation-layer packages, since rocq_toolchain_info currently assumes one coqc for everything, or (b) unify the whole toolchain (coqutil/Hammer/smpl included) onto coq_9_0.withPackages(...), which would also simplify away the hand-rolled Hammer OCAMLPATH wiring — bigger, but more maintainable long-term. Also worth adding a CI target that actually exercises Interval.Tactic once this lands, since nothing currently does (this PR's own CI went green without proving anything about the bug it claims to fix). Happy to scope the real fix as a follow-up rather than block on it here.

🤖 Generated with Claude Code

avrabe and others added 2 commits July 22, 2026 19:29
… (DD-003)

Replaces the previous commit's coqPackages.mathcomp wiring, which doesn't
fix the bug: `nix build coqPackages.mathcomp` produces only a 1-file
umbrella re-export (lib/coq/9.0/user-contrib/mathcomp/all/all.vo), not
the mathcomp-boot package the original error names
("Cannot load mathcomp.boot.seq").

The real dependency closure, read off nixpkgs directly (not guessed):
`coqPackages.interval.propagatedBuildInputs` = bignums, coquelicot,
flocq, mathcomp-boot, mathcomp-fingroup. mathcomp-boot itself needs
hierarchy-builder, which needs the coq-elpi OCaml plugin, whose own
OCaml findlib deps (ppx_deriving.runtime, ...) go deeper still --
hand-wiring each as a separate nixpkgs_package + -Q flag doesn't scale
past this point.

- rocq/extensions.bzl: @rocq_interval_env is a single
  `coq_9_0.withPackages (p: [p.flocq p.interval p.coquelicot])`
  composition that resolves the entire transitive closure automatically
  (mathcomp-boot/fingroup, bignums, hierarchy-builder, coq-elpi and its
  OCaml deps) -- exactly the way nixpkgs is designed to solve this. Its
  own subdirs are already named Flocq/Interval/mathcomp/Bignums/HB/elpi,
  so exposing the tree needs no manual -Q reconstruction at all.
- rocq/private/rocq.bzl: new rocq_interval_proof rule compiles against
  this dedicated environment's own coqc (no -Q flags needed -- it has
  its own default load path baked in). The primary toolchain
  (coqutil/Hammer/smpl, rocq-of-rust) is untouched.
- examples/interval_proof/: a real smoke test -- Require Import
  Interval.Tactic, `interval` tactic discharges a goal. Verified:
  `bazel test //examples/interval_proof:smoke_test` -- PASSED. Nothing
  exercised this before (#41/#43 both went green on CI without proving
  the capability worked).
- artifacts/requirements.yaml: FEAT-001/REQ-002 back to implemented
  (genuinely this time); DD-003 records the verified decision and why
  hand-wiring the closure was rejected.
- README.md / claims.yaml: document the new capability and gate the
  claim the same way as the rest of this repo's doc claims.

Closes #43

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011MptgyfLZuHYCbfpq1zDey
@avrabe
avrabe merged commit ee900f0 into main Jul 22, 2026
9 checks passed
@avrabe
avrabe deleted the feat/mathcomp-for-coq-interval branch July 22, 2026 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant