Skip to content

Retarget public correctness toward native EVMYulLean#1822

Merged
Th0rgal merged 446 commits intomainfrom
native-evmyullean-public-correctness
May 11, 2026
Merged

Retarget public correctness toward native EVMYulLean#1822
Th0rgal merged 446 commits intomainfrom
native-evmyullean-public-correctness

Conversation

@Th0rgal
Copy link
Copy Markdown
Member

@Th0rgal Th0rgal commented May 3, 2026

Summary

Retargets Verity's public EVMYulLean correctness surface away from backend-parameterized oracle spellings and toward native EVMYulLean-named entry points, and lands the first wave of leaf ExecOnlyBridgeAtFuelRevived constructors so the Revived family covers every observational-no-op fn.body shape.

Public-surface retarget

  • Added interpretYulRuntimeEvmYulLean and interpretYulRuntimeEvmYulLeanFuel wrappers.
  • Retargeted the public Layer 3 and SimpleStorage EndToEnd theorem names to EVMYulLean conclusions.
  • Kept legacy/reference-oracle paths available under explicit ..._via_reference_oracle names; renamed the lower legacy Layer 3 theorem to yulCodegen_preserves_semantics_via_reference_oracle and guarded against restoring the bare oracle name.
  • Renamed native agreement seams from ...Interpreter to ...EvmYulLean.
  • Changed defaultBuiltinBackend to .evmYulLean; added legacyBuiltinBackend := .verity, legacyEvalBuiltinCallWithContext, and legacyExecYulFuel so old reference-oracle / bridge-comparison paths opt into legacy semantics explicitly.

Native EndToEnd surface

  • nativeResultsMatchOn, sourceResultMatchesNativeOn, source/native composition theorem over the result surface.
  • compile_preserves_native_evmYulLean_callDispatcher_of_generated_callDispatcher_match, plus helper-free and mapping-helper lowering wrappers.
  • Concrete SimpleStorage native theorem; case freshness dispatcher adapters; mapping switch freshness wrappers.

Leaf Revived constructors (G1 increments S1–S4)

On NativeGeneratedSelectedUserBodyExecOnlyBridgeAtFuelRevived:

  • .of_block_emptyfn.body = [.block []]
  • .of_block_leavefn.body = [.block [.leave]]
  • .of_singleton_commentfn.body = [.comment text]

Together with the pre-existing .of_empty_body and .of_leave_body, the Revived family now covers every body of shape [], [.leave], [.block []], [.block [.leave]], [.comment text] — the full observational-no-op family. Concrete contracts whose user body is a label-only stub now have a direct Revived bridge without going through the halt path.

.of_comment_cons is intentionally deferred to the success-bridge wiring layer (per-leaf _with_label_prefix adapters); see docs/NATIVE_EVMYULLEAN_TRANSITION.md for the structural rationale.

Supporting infrastructure

  • New harness lemmas: exec_block_block_nil_ok_add_ten, exec_block_block_leave_ok_add_ten, exec_block_noop_block_head_eq, lowerStmtsNativeWithSwitchIds_comment_head_eq.
  • Source-side helpers: nativeResultsMatchOn_execIRFunction_block_empty_body_markedPrefix, ..._block_leave_body_markedPrefix, ..._singleton_comment_body_markedPrefix.
  • Updated native-transition guards/docs to enforce the new public surface and terminology.

Invariants

  • Zero sorry, zero new axioms.
  • lake build Compiler.Proofs.EndToEnd green.
  • make check validators (axioms, capability boundary, builtin boundary, doc check) pass.

Verification

  • lake build Compiler.Proofs.EndToEnd
  • lake build Compiler.Proofs.YulGeneration.Backends.EvmYulLeanBridgeTest
  • python3 scripts/check_proof_length.py
  • python3 scripts/generate_print_axioms.py --check
  • python3 scripts/check_native_transition_doc.py
  • python3 scripts/test_check_native_transition_doc.py
  • python3 -m unittest scripts.test_evmyullean_capability
  • make check

Deferred to a follow-up PR

The composite body shapes and the final premise drop share heavy proof infrastructure (whole-block per-slot preservation, IR execIRStmts falling-through induction) that does not fit a single landable increment in this branch's budget. See docs/NATIVE_EVMYULLEAN_TRANSITION.md — the "G1 Incremental Plan" section has full constructor signatures, harness-lemma signatures, and proof sketches.

  • G1-S5 .of_nativePreservableStraightStmts_leave — bodies <straight-stmts>; leave. Companion lemma: execIRStmts_continue_of_nativePreservableStraightStmts_pre_leave (purely IR-side; recommended starting point for a follow-up worker).
  • G1-S6 .of_bridgedStraightStmts_falling_through — bodies <straight-stmts> (no terminator). Deepest case; requires aligning execIRFunction's fall-through extraction with the dispatcher's outer block exit.
  • G1-S7 Wire the five shipped leaves plus the two new constructors through NativeGeneratedSelectorHitSuccessBridge adapters, including per-leaf _with_label_prefix variants that strip a leading .comment "label" head via exec_block_noop_block_head_eq. Subsumes the deferred .of_comment_cons shape.
  • G1-S8 Drop hUserBodyHalt from compile_preserves_native_evmYulLean_of_compile_ok_supported_generated_callDispatcher once S5–S7 land.

Long-standing items (orthogonal to this PR)

  • legacyExecYulFuel remains in ReferenceOracle/Semantics.lean for legacy/reference-oracle comparisons.
  • EvmYulLeanRetarget.lean still proves the EVMYulLean retarget by composing through yulCodegen_preserves_semantics_via_reference_oracle and backend comparison machinery.
  • The final native execution theorem path still has explicit bridge obligations and is not fully discharged for all compiler-generated contracts — the G1-S5..S8 follow-up is the path to discharging them.

Note

Medium Risk
Touches the public proof surface (arithmetic correctness lemmas) and CI caching/install logic; while semantics should be equivalent, regressions could break downstream proofs or CI reliability.

Overview
Retargets the public arithmetic proof surface to state wrapping/bitwise/shift facts directly in terms of the native evalPureBuiltinViaEvmYulLean evaluator, removing reliance on legacy oracle/bridge comparison lemmas while keeping historical theorem names.

Exposes compileMappingSlotRead and compileMappingSlotChain from ExpressionCompile.lean so proof modules can reference the exact lowering shapes, and trims top-level Compiler.lean imports to drop unused proof modules.

CI updates: adds a sticky-disk pruning step for stale Lake packages, increases verify.yml job timeout, and hardens setup-solc by caching per-version in-repo with PATH injection plus install/repair retries and version verification (instead of writing to /usr/local/bin).

Reviewed by Cursor Bugbot for commit 06d2aea. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 3, 2026

\n### CI Failure Hints\n\nFailed jobs: `checks`\n\nCopy-paste local triage:\n```bash\nmake check\nlake build\nFOUNDRY_PROFILE=difftest forge test -vv\n```

Th0rgal and others added 26 commits May 9, 2026 08:35
Lays out an 8-step constructor pyramid for
NativeGeneratedSelectedUserBodyExecOnlyBridgeAtFuelRevived in the
remaining-work tracker. Each step is intended to land as a separately
green-buildable commit so that partial progress is durable even if the
deep generic BridgedStraightStmts step is not reached in one pass.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Implements G1 plan step 2: a generic constructor for
NativeGeneratedSelectedUserBodyExecOnlyBridgeAtFuelRevived covering selected
user bodies of the shape [.block [.leave]]. The native lowering produces
[.Block [.Leave]] which the outer dispatcher block wraps as
.Block [.Block [.Leave]] — closed by the new exec_block_block_leave_ok_add_ten
helper. The source side execIRFunction reduces the inner .block to its body
and a single .leave to .continue, observationally matching the native
post-reviveJump state.

This widens the success-side revived bridge surface by one shape without
modifying any existing constructor. lake build Compiler.Proofs.EndToEnd
remains green.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Implements G1 plan step 3: a generic constructor for
NativeGeneratedSelectedUserBodyExecOnlyBridgeAtFuelRevived covering selected
user bodies of the shape [.block []]. The native lowering produces
[.Block []] which the outer dispatcher block wraps as .Block [.Block []] —
closed by the new exec_block_block_nil_ok_add_ten helper. The source side
execIRFunction reduces the inner .block to its empty body returning
.continue stateWithParams, observationally matching the native post state
(no setLeave needed, so reviveJump is identity).

Mirrors .of_empty_body shape with one extra nested-block layer. No existing
constructor is modified. lake build Compiler.Proofs.EndToEnd remains green.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Implements G1 plan step 4: a generic constructor for
NativeGeneratedSelectedUserBodyExecOnlyBridgeAtFuelRevived covering selected
user bodies of the shape [.comment text]. The native lowering of .comment is
.Block [] (via lowerStmtGroupNativeWithSwitchIds_comment), so the
dispatcher-wrapped body becomes .Block [.Block []] — the same native shape
as .of_block_empty, closed by the existing exec_block_block_nil_ok_add_ten.
The source side execIRStmt of .comment is a no-op (.continue state), so the
observable projection matches the empty-body path. The text is existentially
extracted from the hypothesis so the constructor works for any concrete label.

Mirrors .of_block_empty native shape; no existing constructor is modified.
lake build Compiler.Proofs.EndToEnd remains green.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
A direct Revived-level .of_comment_cons recursive adapter is structurally
awkward: the Revived predicate's nativeGeneratedSelectorHitUserBodyFuel
depends on the full contract's fn.body size, so recursing into a stripped
tail body would require either a predicate refactor parameterizing over the
explicit body shape or duplicating the entire predicate logic inline.

Instead, the runtime dispatcher's `.comment "label" :: <real body>` shape
is handled at the NativeGeneratedSelectorHitSuccessBridge wiring (step 7):
each leaf Revived constructor pairs with a one-shot comment-prefix adapter
that strips the no-op label head, leaving <real body> to match an existing
leaf constructor.

Documentation-only change. lake build remains green.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Documents the shipped Revived constructor family (.of_block_empty,
.of_block_leave, .of_singleton_comment, .of_leave_body, .of_empty_body) and
the technical sketches for the three deeper remaining steps:

- Step 5 (.of_nativePreservableStraightStmts_leave): cites the
  NativeBlockPreservesWord_lowerStmtsNativeWithSwitchIds_of_nativePreservableStraightStmts
  glue and proposes the execIRStmts_continue_of_nativePreservableStraightStmts_pre_leave
  companion lemma signature.
- Step 6 (.of_bridgedStraightStmts_falling_through): notes the
  function-end fall-through convention alignment between execIRFunction's
  post-execIRStmts extraction and the dispatcher outer block exit.
- Step 7 (success-bridge wiring + comment-prefix collapse).
- Step 8 (hUserBodyHalt premise drop).

Also regenerates PrintAxioms.lean to track the three new private theorems
added by .of_block_empty (commit fa980235), .of_singleton_comment (commit
f69044a1), and their source-side helpers.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds a top-level "PR 1822 — Achievement Summary" block to the native
EVMYulLean transition doc that calls out exactly what landed on
`native-evmyullean-public-correctness` (public-surface retarget, native
EndToEnd surface, leaf Revived constructors S1–S4 covering the full
observational-no-op body family, supporting harness lemmas, zero-sorry /
zero-axiom invariants) versus what is deferred to a follow-up PR (G1
steps S5–S8: the `<straight-stmts>; leave` and `<straight-stmts>`
falling-through constructors, success-bridge wiring with per-leaf
`_with_label_prefix` variants, and the final `hUserBodyHalt` premise
drop). Per-step status lines now read "shipped in PR 1822" or
"deferred to follow-up PR" so the document is self-contained as a
hand-off without consulting commit history.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The test asserted that removing the canonical public-theorem mention from
the native transition doc makes `check_doc` report an error. It used
`replace(..., ..., 1)` (count=1), which only rewrote the first
occurrence. Once the doc grew a second backticked mention (introduced by
the G1 plan in `5535376f`, and again by the PR-1822 achievement summary),
the post-replace text still contained the canonical name elsewhere, so
`check_doc` found nothing missing and the assertion fired with an empty
error list.

Switch the test to a count-less `replace`, so every occurrence is
rewritten before invoking `check_doc`. The test now matches its intent —
"if no mention of the public theorem survives, the check must complain"
— and stays robust against future natural mentions in the same doc.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Th0rgal Th0rgal marked this pull request as ready for review May 11, 2026 08:22
@Th0rgal Th0rgal merged commit d694305 into main May 11, 2026
22 checks passed
Th0rgal added a commit that referenced this pull request May 11, 2026
Captures concrete code-level facts gathered while reviewing the post-#1822
tree for the S5-S8 follow-up:

- Verified line numbers for every shipped Revived leaf constructor and
  the one shipped chain (`of_empty_body`).
- Corrected the original plan: the `of_leave_body` success-bridge chain
  is NOT pre-existing - it must be authored alongside E3, E4, E5.
- Documented the per-body-shape preservation status: `empty_block` and
  `comment` preservation lemmas already ship; `Leave` and
  `NativePreservableStraightStmts` preservation are net-new work.
- Pointed F1 readers at the redundancy with E5: F1 and E5 describe the
  same body shape `[.comment text]`, so F1 can be dropped once E5 lands.
- Listed concrete file insertion points for Layers A, B, D, and the
  call-site sweep required for Layer G.
- Revised the effort estimate to 5-9 senior-engineer days and noted
  why this scope is not compatible with a single autonomous coding
  session (prior worker attempts repeatedly stalled or fabricated
  phantom pushes).

No code changes; planning document only.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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