Skip to content

Proof: model IR internal helper composition for the generic Layer 2 theorem #1638

@Th0rgal

Description

@Th0rgal

Summary

SupportedSpec and the Layer 2 theorem surface are now helper-proof-ready on the source side, but the compiled-side IR semantics still cannot execute internal helper calls. execIRFunction only runs the compiled external function body and ignores IRContract.internalFunctions, so any generic helper-summary composition proof remains blocked even after the source-side summary/rank interfaces exist.

This issue tracks the compiled-side theorem target and proof architecture needed to make internal helper composition a real generic Layer 2 capability instead of a fail-closed exclusion.

Why this is the next structural blocker

PR #1633 split the body witness into feature-local interfaces and added:

  • positive direct-callee helper-summary inventory (SupportedBodyHelperInterface.summaryOf)
  • a decreasing helper-rank interface (calleeRanksDecrease)
  • helper-aware source semantics (evalExprWithHelpers, execStmtListWithHelpers, interpretInternalFunctionFuel)
  • theorem-level proof wrappers (SupportedSpecHelperProofs)

What still blocks end-to-end generic helper reuse:

  1. SupportedStmtList still excludes helper-call syntax, so generic body proofs do not yet admit helper forms.
  2. GenericInduction.supported_function_body_correct_from_exact_state_generic_with_helpers still collapses helper-aware source semantics back to helper-free semantics through calls.helperCompatibility.
  3. Compiler.Proofs.IRGeneration.IRInterpreter.execIRFunction does not model internal helper call composition at all.

The third point is the compiled-side blocker. Without an IR semantics that can execute helper calls, consuming source-side helper summaries alone would not strengthen compile_preserves_semantics for helper-using contracts.

Scope

  • define the exact IR semantics target for internal helper composition
  • make the target compatible with the existing generic theorem surface, ideally via helper-aware/contract-aware IR execution plus compatibility lemmas on the current helper-free fragment
  • preserve proof genericity: no contract-specific helper assumptions, no demo-only shortcuts
  • keep the trusted boundary explicit if any temporary compatibility reduction remains

Candidate implementation shape

  • add contract-aware IR execution that can resolve calls against IRContract.internalFunctions
  • introduce explicit fuel / rank discipline for internal helper execution on the IR side, aligned with the source-side decreasing helper-rank interface
  • retarget the generic theorem stack to the richer IR semantics family while proving equivalence to the current execIRFunction / interpretIR on the existing supported fragment
  • only then thread helper-summary soundness/rank evidence through the body proof to remove SupportedBodyCallInterface.helperCompatibility

Acceptance criteria

  • the remaining helper blocker is no longer "IR semantics has no internal helper composition"
  • the exact compiled-side theorem target for helper-using contracts is encoded in code/docs, not only in prose
  • the public Layer 2 theorem surface does not need another theorem-shape rewrite when helper composition is proved
  • docs and artifacts/layer2_boundary_catalog.json link to this issue as the compiled-side helper blocker

Part of #1630.
Related: #1510, #1633.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions