Skip to content

Commit 61005df

Browse files
levineuwirthclaude
andcommitted
Rocq Alethe walker R-1: foundation module (parse wrapper)
Begins the Rocq-side Alethe walker port (mirror of the Lean arc PRs #41-#52). Goal: end-to-end "cert IS the proof" reconstruction for cvc5 alethe-2024 traces on Rocq, with UF + LIA mixed-theory closure as the primary capability gain. Currently Rocq's LIA arm is bare `lia` and its UF arm is a congruence chain; neither composes for mixed-theory goals cvc5 handles natively. The walker shifts Rocq from "can solve LIA, can solve UF, struggles on mixed" to "can replay anything cvc5 closed". R-1 establishes the module file and a Result-typed wrapper over the SDK's already-shared `Proof_broker.Alethe.parse`. Walker elaborators arrive starting R-2 (clausal layer). The SDK's ADT (Sexp.t, step, proof) and parser are shared by both bridges, so the Rocq side reuses them directly — no mirror-in-OCaml work like Lean PR #41 needed (Lean had to build its own Sexp ADT and FFI envelope; Rocq just uses the OCaml SDK directly). Audit H1 contract (same as Lean): walker failure surfaces as a tactic failure, with the existing lia fallback re-running. Wired into close_or_fail in R-9; no closer integration yet. Subsequent PRs follow the Lean cluster decomposition: R-2 clausal, R-3 arithmetic, R-4 multi-literal resolution, R-5 equality, R-6 trust-tagged leaves, R-7 boolean cleanup, R-8 equiv_simplify, R-9 wire into closer, R-10 equiv_pos1/equiv_pos2, R-11 cong over operators (visible payoff PR), R-12 snapshot test against the real cvc5 trace pinned in Lean #52. Validation: local Rocq env is broken (missing zarith, rocq-runtime per project memory); rely on CI for the full build. The OCaml file itself is 15 lines of `Result`-typed exception wrapping — confident in syntax. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 22b9cec commit 61005df

2 files changed

Lines changed: 69 additions & 0 deletions

File tree

rocq-bridge/src/alethe_walker.ml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
(** Rocq-side Alethe walker. R-1: foundation only — the parse
2+
wrapper that surfaces the SDK's already-shared
3+
[Proof_broker.Alethe.parse] in a [Result] form for the Rocq
4+
plugin. Walker elaborators arrive starting R-2.
5+
6+
See [.mli] for the multi-PR plan and audit-H1 contract. *)
7+
8+
module Alethe = Proof_broker.Alethe
9+
10+
type proof = Alethe.proof
11+
12+
let parse_trace (s : string) : (proof, string) result =
13+
try Ok (Alethe.parse s)
14+
with
15+
| Alethe.Parse_error msg ->
16+
Error ("alethe parse: " ^ msg)
17+
| exn ->
18+
(* Defensive: any other exception (e.g. an unexpected stack
19+
overflow not caught by [parse]'s own backstop) becomes an
20+
Error so the caller falls through to [lia] cleanly,
21+
rather than propagating and crashing the tactic. *)
22+
Error ("alethe parse: unexpected exception: " ^ Printexc.to_string exn)

rocq-bridge/src/alethe_walker.mli

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
(** Rocq-side Alethe walker — R-1 foundation.
2+
3+
Mirror of [lean-bridge/ProofBroker/Alethe.lean]'s walker module
4+
(PR #41-#52 on the Lean side). This module elaborates cvc5's
5+
alethe-2024 trace into a Coq kernel proof term — the "cert IS
6+
the proof" architectural play, parallel to the Tier-1 Farkas
7+
[Term_mode] closer for Tier-1 certs but for Tier-3 alethe-2024.
8+
9+
Audit H1: walker failure surfaces as a tactic failure, with
10+
the existing [lia] fallback re-running (closer chain in
11+
[Pb_rocq_main.close_or_fail]). No axioms are introduced by the
12+
walker itself — proof-term construction goes through the
13+
kernel like every other tactic, and the cert never widens the
14+
trust footprint.
15+
16+
R-1 scope (this PR): module file scaffolding + the parse
17+
wrapper exposing the SDK's [Proof_broker.Alethe.parse] in a
18+
Result-typed form. No walking yet; the per-rule elaborators
19+
arrive in R-2 (clausal layer) and onward. The SDK's ADT
20+
([Sexp.t], [step], [proof]) and parser are shared across both
21+
bridges, so the Rocq side reuses them directly via
22+
[Proof_broker.Alethe] rather than mirroring in OCaml the way
23+
Lean had to mirror them in Lean.
24+
25+
Subsequent PRs follow the same cluster decomposition as the
26+
Lean arc: R-2 clausal, R-3 arithmetic, R-4 multi-literal
27+
resolution, R-5 equality, R-6 trust-tagged leaves, R-7
28+
boolean cleanup, R-8 [equiv_simplify], R-9 wire into closer,
29+
R-10 [equiv_pos1]/[equiv_pos2], R-11 [cong] over operators,
30+
R-12 snapshot test. See plan in [.claude/]. *)
31+
32+
(** Re-export of the SDK's [proof] type as the canonical Alethe
33+
proof representation used by the walker. The SDK is shared by
34+
both bridges and already includes named-reference expansion,
35+
so the walker consumes a fully-resolved proof from the start. *)
36+
type proof = Proof_broker.Alethe.proof
37+
38+
(** Parse an alethe-2024 trace string into a [proof].
39+
40+
Failure modes:
41+
- parser error (malformed trace, unterminated S-expression,
42+
depth exceeded) → [Error msg];
43+
- stack overflow (deeply-nested untrusted solver output) →
44+
[Error msg];
45+
- any other unexpected exception is converted to [Error msg]
46+
so the caller can fall through to [lia] cleanly. *)
47+
val parse_trace : string -> (proof, string) result

0 commit comments

Comments
 (0)