feat: an interpreter for HeapLang - #580
Draft
kdvkrs wants to merge 1 commit into
Draft
Conversation
Port of Iris's `iris_unstable/heap_lang/interpreter.v` (tracking issue iris/iris#405). `exec fuel e` runs a closed expression and returns either its value or a structured error. Like the Rocq original the interpreter is sequential and deterministic: forks are collected but never run, and allocation always takes the next fresh location. `exec_spec` is ported in full, split into `exec_sound` and `exec_stuck` and recombined into Rocq's three-way shape. Divergences from Rocq are documented at their definitions. Stuck reasons are structured (`StuckReason`) and rendered separately rather than being built as strings inside the interpreter. One supporting change outside the new files: `solve_subredex_values` in `HeapLang/Instances.lean` is no longer `local`. Anyone proving a concrete expression stuck needs it, and the interpreter would otherwise have to duplicate it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Description
I needed an interpreter for HeapLang and ended up porting the one from
iris_unstable/heap_lang/interpreter.v. Putting it here in case it's useful to anyone else and since it might be worth discussing whether this should be part of Iris Lean eventually. The implementation is mostly vibe-coded with a couple of cross-provider review rounds against the Rocq implementation and repo guidelines.exec fuel eruns a closed expression and returns either its value or a structured error. Like the Rocq one, the interpreter is sequential and deterministic, with forks being collected but never run, and allocation always takes the next fresh location.Divergences from Rocq are documented at their definitions. Stuck reasons are structured (
StuckReason) and rendered separately.The only change outside new files is removing
localfromsolve_subredex_valuesinHeapLang/Instances.leanso it can be used in the interpreter.Checking parity turned up two divergences in the semantics that are likely worth raising as separate issues:
UnOp.evalrejects integers for.neg; Rocq'sNegOponLitIntisZ.lnot.BinOp.evalhas no≤/<on two locations; Rocq'sbin_op_eval_locdoes.Checklist
authorssection of any appropriate filesGenerative AI Guidelines
AI assistance is permitted when making contributions to Iris-Lean, however, generative AI systems tend to produce code which takes a long time to review.
Please carefully review your code to ensure it meets the following standards.
havestatements that do not aid readability or code reuse should be inlined.In our experience, a good place to begin refactoring is by re-arranging and combining independent tactic invocations.
We also find that pointing generative AI systems to the Mathlib code style guidelines can help them perform some of this refactoring work.