sir: certified lowering from Vars to Stack - #27
Open
Eduardogbg wants to merge 13 commits into
Open
Conversation
Eduardogbg
force-pushed
the
sir/machine-languages
branch
from
August 13, 2026 04:42
d37a264 to
1275cc5
Compare
Eduardogbg
force-pushed
the
sir/lowering
branch
from
August 13, 2026 04:42
c9e8537 to
f931c20
Compare
Eduardogbg
force-pushed
the
sir/machine-languages
branch
from
August 13, 2026 07:25
1275cc5 to
014009d
Compare
Eduardogbg
force-pushed
the
sir/lowering
branch
2 times, most recently
from
August 13, 2026 08:37
7dbe434 to
48dc4a7
Compare
Eduardogbg
force-pushed
the
sir/machine-languages
branch
from
August 13, 2026 08:37
014009d to
e759e2f
Compare
Eduardogbg
force-pushed
the
sir/lowering
branch
4 times, most recently
from
August 18, 2026 06:48
1e1cddd to
4e7c326
Compare
Eduardogbg
force-pushed
the
sir/lowering
branch
from
August 18, 2026 08:27
4e7c326 to
4cfba46
Compare
Eduardogbg
marked this pull request as ready for review
August 18, 2026 20:28
StackSchedule stays the per-function certificate; ProgramSchedule pairs an init certificate with an optional main and lifts the equivalence to whole programs by relocating each certified function's evaluations. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Convert nested match/if expressions in StackSchedule checker functions to use do-notation with throw, pure, and pattern matching syntax. This reduces verbosity and makes the code more readable. Functions updated: - StackSchedule.Block.checkFinalStack - StackSchedule.Block.check - StackSchedule.checkBlocks - StackSchedule.checkEdge - StackSchedule.checkBlockEdges - StackSchedule.checkEdges - StackSchedule.check - ProgramSchedule.check The proofs should still work as the do-notation desugars to the same structure that split can operate on. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
Eduardogbg
force-pushed
the
sir/lowering
branch
from
August 22, 2026 02:45
8d39f86 to
ed61cba
Compare
Convert functions in Stack.Spec to use do-notation for cleaner, less verbose code: - sourceFetch: use pattern matching with | syntax for list destructuring - decode: extract instruction decoding to do block, match on instruction - control: add outer do block for consistency - resume: use | syntax for Except matching Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
Restructure decode function to use nested match on instruction type, which is more maintainable and easier to extend with new instruction types. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
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.
this PR defines and verifies the lowering from
VarstoStack. this lowering requires an additional external witness (from plank's rust compiler), namely the stack schedule. it lifts the knowledge of a valid stack schedule into a proven lowering between the languages.we check a stack schedule is correct by symbolically executing both a Vars and a Stack program against opaque variable names. as long as both executions match, meaning that they fire the same ops against their respective operands, the schedule checks.
StackSchedule.checkvalidates a whole function's schedule;StackSchedule.Block.checkchecks one block.exchange/flippedOp, leftover stack at a halting block, loops. we don't yet accept effectful ops such asicallinitschedule with an optionalmain; the lowering theorem isschedule.check = .ok () → Equiv schedule.vars schedule.stack(ProgramSchedule.equiv;StackSchedule.equivis the one-function corollary)useBeforeDefinition,boundaryArityMismatch, ...)SchedulerisAcceptedwhen every schedule it emits checks and schedules exactly its input (Scheduler.Accepted.equiv,Scheduler.Accepted.schedules_input)spillAllscheduler, which loads every operand from its memory slot and stores every result back so nothing stays on the stack between statements, and proved the checker accepts everything it emits (spillAll_accepted)Examples/Corpus.leanto see the equivalence discharged for real scheduler output (straight-line, diamond, loop) and for a two-function program withmainExamples/Lowering.leanhas accepted and rejected schedules, each rejection proving its specific error