spike(vcr-isa-001): Sail/ASL-derived semantics bridge — AArch32 ADD/ADDS/CMP proven ≡ ArmSemantics.v (#242) - #660
Merged
Merged
Conversation
…rch32 ADD/ADDS/CMP (#242) Bounded spike answering the 2026-06-10 deep-research gate on VCR-ISA-001 (re-base ARM semantics on Sail-generated Rocq). Survey verdict: the Sail tool's Rocq backend is alive (Sail 0.20 via nixpkgs, --coq target, coq-sail maintained), and sail-arm arm-v9.4-a covers all of T32/A32 — but IMPORTING its generated Coq is a no-go (single 42 MB armv9.v pinned to stdpp-unstable + git-pinned coq-sail-stdpp; the 2019 v8.5 snapshot needed ~40 GB RAM on Coq 8.9.1). Incompatible with the hermetic Rocq 9 Bazel toolchain. Working alternative landed end-to-end: per-instruction transcribe-and-bridge. coq/Synth/ARM/SailArmBridge.v (23 Qed / 0 Admitted, wired into //coq:verify_proofs) transcribes AddWithCarry (v8_base.sail:13337) and the AArch32 ADD/CMP register-form execute clauses (instrs32.sail:457) from sail-arm @ 1bf2e5574ba9 with file:line provenance, and proves ArmSemantics.v's ADD, ADDS and CMP equal the transcription on the destination register AND all four NZCV flags — the six hand-written compute_*_flag definitions are now proven equal to ASL's AddWithCarry outputs (the foundation under every CMP-based comparison lowering in Compilation.v / VcrSelRules.v). Abstraction gaps documented in-file: shift_n=0, d<>15 (the PC-executor gap stays this item's core prerequisite), no IT blocks, bits(32) as Z mod 2^32. Report: docs/design/vcr-isa-001-spike.md (go/no-go + per-instruction cost). Roadmap: VCR-ISA-001 stays proposed; spike evidence + revised criterion. Refs #242 (VCR-ISA-001) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
VCR-ISA-001 feasibility spike (epic #242, Track B)
Bounded research spike: can we anchor
ArmSemantics.von an independently-derived ISA semantics (Sail, generated from Arm's own ASL) so a modeling bug can't hide? Deliverable is a decision-quality report + minimal working code — not a migration.Survey (verified against the repos, not from memory)
ocamlPackages.sail, installs in seconds) ships the--coqtarget (bbv|stdpp styles);rems-project/coq-sailis maintained.sail-armarm-v9.4-a (derived from Arm's 2023-03 ASL via asl_to_sail) contains every AArch32 instruction incl. all four ADD (register) encodings (instrs32.sail, 1.9 MB).armv9.v+ 1 MB types, pinned to stdpp-unstable (not in opam) and git-pinnedcoq-sail-stdpp; the 2019 v8.5 snapshot README says the build needs ~40 GB RAM and was checked against Coq 8.9.1. That cannot join our hermetic Rocq 9 /Stdlib-prefix Bazel toolchain or CI.The bridge (the spike's crown) — landed, all Qed
coq/Synth/ARM/SailArmBridge.v(23 Qed / 0 Admitted, in//coq:verify_proofs, green): hand-transcribesAddWithCarry(v8_base.sail:13337) and the AArch32 ADD/CMP register-form execute clauses (instrs32.sail:457) fromsail-arm @ 1bf2e5574ba9with file:line provenance comments, then proves:sail_bridge_add_reg— ourADD≡R[d] := AddWithCarry(R[n], R[m], '0').resultsail_bridge_adds_reg— ourADDS≡ same, plus all four NZCV flagssail_bridge_cmp_reg— ourCMPflags ≡AddWithCarry(R[n], NOT(R[m]), '1')nzcvThe six hand-written flag definitions (
compute_{n,z}_flag,compute_{c,v}_flag_{add,sub}) are proven equal to ASL's formulations — genuinely different formulas (ASL's V isSInt(result) != signed_sum; ours is the sign-pattern test), so the lemmas are non-vacuous. These definitions are the foundation under every CMP-based comparison lowering inCompilation.vandVcrSelRules.v.Documented abstraction gaps (file header):
shift_n = 0,d ≠ 15(the PC-executor gap is NOT closed by this and remains the item's core prerequisite for the div/rem admits), no IT blocks,bits(32)as Z mod 2^32.Cost per instruction (measured, not estimated)
~40 lines transcription + ~230 lines proof for the whole ADD family, with the flag machinery (the hard 60%) now reusable: SUB/SUBS/CMN/RSB near-free, ~0.5–1 day per remaining straight-line op class, memory ops widest gap. Full analysis in
docs/design/vcr-isa-001-spike.md.Recommendation
GO on VCR-ISA-001 via per-instruction transcribe-and-bridge (priority: AddWithCarry family → flag-free ALU → PC-executor refactor → memory). NO-GO on importing
gen_coqoutput. RISC-V half unmeasured — sail-riscv's maintained Coq export may admit the import path there; evaluate separately.Roadmap: VCR-ISA-001 stays
proposed; the 2026-06-10 deep-research gate ("bounded feasibility spike must precede release commitment") is now answered with in-tree evidence.bazel test //coq:verify_proofsgreen (rocq_proofs + vcr_sel_rules_coverage)rivet validate— 0 non-xref errors (same as main baseline)Refs #242 (VCR-ISA-001)
🤖 Generated with Claude Code