Skip to content

Implement more functions in SimpleAPI#652

Merged
shigoel merged 11 commits intomainfrom
atomb/more-simple-api
Mar 26, 2026
Merged

Implement more functions in SimpleAPI#652
shigoel merged 11 commits intomainfrom
atomb/more-simple-api

Conversation

@atomb
Copy link
Copy Markdown
Contributor

@atomb atomb commented Mar 24, 2026

This PR implements several previously-opaque functions in the Strata/SimpleAPI.lean and consolidates the verification entry point.

Changes

Implemented Simple API functions:

  • genericToCore — translates a generic Strata.Program to Core.Program using
    Core.getProgram
  • genericToLaurel — translates a generic Strata.Program to Laurel.Program using
    Laurel.parseProgram
  • laurelToCore — translates a Laurel.Program to Core.Program using the existing
    Laurel translator
  • Core.inlineProcedures — inlines procedure calls with a configurable predicate
    controlling which calls to inline
  • Core.loopElimUsingContract — eliminates loops by replacing them with invariant-
    based assertions/assumptions
  • Core.callElimUsingContract — eliminates procedure calls by replacing them with
    contract-based assertions/assumptions
  • Core.verifyProgram — runs deductive verification on a Core program (replaces
    the standalone verifyCore)

Structural changes:

  • Core.InlineTransformOptions is now a concrete structure with an optional
    doInline predicate, rather than an opaque type
  • Removed the standalone verifyCore function; its logic is now in
    Core.verifyProgram under the Core namespace
  • Renamed Core.loopElimWithContractCore.loopElimUsingContract and
    Core.callElimWithContractCore.callElimUsingContract
  • Trimmed unnecessary imports from SimpleAPI.lean and StrataMain.lean
  • Fixed a docstring typo (Core dialect → Laurel dialect for genericToLaurel)

Transform module workarounds:

  • Added top-level aliases coreCallElimCmd and coreInlineCallCmd in CallElim.lean
    and ProcedureInlining.lean to work around the Core module/dialect name collision

Dogfooding in StrataMain:

  • Updated pyAnalyzeCommand to use Core.inlineProcedures instead of calling the
    transform directly
  • Updated pyAnalyzeLaurelCommand to use Core.verifyProgram instead of
    Strata.verifyCore

Motivation

The Simple API was originally sketched with opaque declarations to define the
intended surface. This PR makes the majority of those functions concrete, moving
the API closer to being usable by external clients. The remaining
noncomputable opaque functions depend on DDM functionality that is not yet
available.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@atomb atomb marked this pull request as ready for review March 24, 2026 22:38
@atomb atomb requested a review from a team March 24, 2026 22:38
shigoel
shigoel previously approved these changes Mar 25, 2026
Don't depend on a specific counterexample
@shigoel shigoel enabled auto-merge March 26, 2026 18:53
@shigoel shigoel added this pull request to the merge queue Mar 26, 2026
Merged via the queue into main with commit 5267cb0 Mar 26, 2026
15 checks passed
@shigoel shigoel deleted the atomb/more-simple-api branch March 26, 2026 19:04
olivier-aws pushed a commit that referenced this pull request Mar 30, 2026
This PR implements several previously-opaque functions in the
`Strata/SimpleAPI.lean` and consolidates the verification entry point.

### Changes

Implemented Simple API functions:
- `genericToCore` — translates a generic `Strata.Program` to`
Core.Program` using
`Core.getProgram`
- `genericToLaurel` — translates a generic `Strata.Program` to
`Laurel.Program` using
`Laurel.parseProgram`
- `laurelToCore` — translates a `Laurel.Program` to `Core.Program` using
the existing
Laurel translator
- `Core.inlineProcedures` — inlines procedure calls with a configurable
predicate
controlling which calls to inline
- `Core.loopElimUsingContract` — eliminates loops by replacing them with
invariant-
based assertions/assumptions
- `Core.callElimUsingContract` — eliminates procedure calls by replacing
them with
contract-based assertions/assumptions
- `Core.verifyProgram` — runs deductive verification on a Core program
(replaces
the standalone `verifyCore`)

Structural changes:
- `Core.InlineTransformOptions` is now a concrete structure with an
optional
`doInline` predicate, rather than an opaque type
- Removed the standalone `verifyCore` function; its logic is now in
`Core.verifyProgram` under the `Core` namespace
- Renamed `Core.loopElimWithContract` → `Core.loopElimUsingContract` and
`Core.callElimWithContract` → `Core.callElimUsingContract`
- Trimmed unnecessary imports from `SimpleAPI.lean` and
`StrataMain.lean`
- Fixed a docstring typo (Core dialect → Laurel dialect for
`genericToLaurel`)

Transform module workarounds:
- Added top-level aliases `coreCallElimCmd` and `coreInlineCallCmd` in
`CallElim.lean`
and `ProcedureInlining.lean` to work around the Core module/dialect name
collision

Dogfooding in `StrataMain`:
- Updated `pyAnalyzeCommand` to use `Core.inlineProcedures` instead of
calling the
transform directly
- Updated `pyAnalyzeLaurelCommand` to use `Core.verifyProgram` instead
of
`Strata.verifyCore`

### Motivation

The Simple API was originally sketched with opaque declarations to
define the
intended surface. This PR makes the majority of those functions
concrete, moving
the API closer to being usable by external clients. The remaining
`noncomputable opaque` functions depend on DDM functionality that is not
yet
available.

By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.

---------

Co-authored-by: Josh Cohen <36058610+joscoh@users.noreply.github.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.

3 participants