Skip to content

formal(refinement): Tier-3 bridge — extracted Rust refines Authority.lean (Aeneas)#244

Open
hartsock wants to merge 1 commit into
mainfrom
formal/p0-refinement-aeneas
Open

formal(refinement): Tier-3 bridge — extracted Rust refines Authority.lean (Aeneas)#244
hartsock wants to merge 1 commit into
mainfrom
formal/p0-refinement-aeneas

Conversation

@hartsock

Copy link
Copy Markdown
Member

The Rust waist provably refines the Lean model

Stands up the Charon/Aeneas toolchain (roadmap Phase 0.6, now ✅ on gnuc) and proves, on the actual extracted Rust of agent-bridle-ceremony, the Authority.lean algebraic laws.

Pipeline (formal/refinement/): charon cargo --preset=aeneas → LLBC → aeneas -backend lean → generated Types/Funs/FunsExternal → hand-written Refinement.leanlake build ✅.

12 refinement theorems, all cases <;> rfl over the finite domain (the extracted monadic functions reduce cleanly):

  • axis + product meet commutativity and idempotence
  • attenuation (L4/PO-4) as absorption (a⊓c) ⊓ a = a⊓c — i.e. (a⊓c) ≤ a under the meet-order Authority.lean defines
  • attenuate = meet (the extracted definition)

The shipping implementation is no longer just tested against the frozen algebra — it's proven to refine it.

Design / plumbing

  • Separate HEAVY tier: generated code imports Aeneas + mathlib, so this is not in the mandatory pre-push/CI gate. Run via just check-refinement (skips gracefully without the toolchain). The fast formal/ gate now prunes refinement/ (Gate.lean).
  • Portable: aeneas-lean is a gitignored symlink from setup.sh (honours AENEAS_LEAN_LIB) — no absolute path / username committed.
  • regenerate.sh reproduces the extraction; aeneas-commit.txt pins provenance.

Known gap (tracked, ROADMAP 1c)

resolve uses a slice iterator (iter().fold), which Aeneas axiomatizes (opaque fold/split_first), so it doesn't reduce and its laws aren't provable yet. Fix = rewrite resolve as explicit recursion in the kernel.

Test plan

  • just check-refinementlake build in formal/refinement/, exit 0 (verified on gnuc).
  • just check-formal still green with refinement/ present (pruned from the scan).
  • Full pre-push gate passed on push.

Pairs with the boundary re-land

The generated Lean was extracted from a crate including boundary.rs, which landed on the #241 branch after #241 merged (authority-only). Merge the boundary PR first for regenerate.sh provenance parity.

Risk

Low — additive formal/refinement/ + a Gate.lean prune + one justfile recipe + ROADMAP notes. No mandatory-gate behavior change for existing code; nothing deleted.

…lean

Stands up the Charon/Aeneas refinement toolchain (roadmap Phase 0.6) and proves,
on the ACTUAL extracted Rust of agent-bridle-ceremony, the Authority.lean laws.

Pipeline (formal/refinement/): charon cargo --preset=aeneas → LLBC →
aeneas -backend lean → generated Types/Funs/FunsExternal → hand-written
Refinement.lean → lake build ✅.

12 refinement theorems, all by `cases <;> rfl` over the finite domain (the
extracted monadic functions reduce cleanly):
  - axis + product `meet` commutativity and idempotence
  - attenuation (L4/PO-4) as absorption `(a⊓c) ⊓ a = a⊓c`, i.e. `(a⊓c) ≤ a`
    under the meet-order Authority.lean defines
  - `attenuate = meet` (the extracted definition)

This is the concrete instance of the roadmap's central claim: the Rust waist
refines the Lean model. The frozen algebra is no longer just an abstract Lean
theorem set — the shipping implementation provably obeys it.

Design/plumbing:
  - Separate, HEAVY tier: the generated code imports Aeneas + mathlib, so this
    is NOT in the mandatory pre-push/CI gate (mathlib is too heavy per push).
    Run via `just check-refinement` (skips gracefully without the toolchain).
  - Portable: `aeneas-lean` is a gitignored symlink created by setup.sh
    (honours AENEAS_LEAN_LIB) — no absolute path / username committed.
  - regenerate.sh reproduces the extraction; aeneas-commit.txt pins provenance.
  - Toolchain gotcha handled: this harness overrides CARGO_TARGET_DIR, which
    breaks Charon's Makefile copy step; regenerate.sh unsets it.

KNOWN GAP: `resolve` uses a slice iterator (`iter().fold`), which Aeneas
axiomatizes (opaque `fold`/`split_first`), so it does not reduce and its laws
are not yet proven here. Fix = rewrite `resolve` as explicit recursion in the
kernel (ROADMAP 1c follow-up).

NOTE: the generated Lean was extracted from a crate including boundary.rs (the
enforcement-boundary module), which landed on the #241 branch AFTER #241 merged
(authority-only). Pairs with the boundary PR; merge that first for regenerate.sh
provenance parity.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant