interpreter: prove env-independence of run for import-free modules - #159
Merged
mfornet merged 1 commit intoJul 18, 2026
Merged
Conversation
…ee modules When a module declares no imported functions (`imports = []`), the host environment is never consulted: `run`'s host arm is dead and `env` is otherwise only threaded, never inspected. `env_indep_aux` proves this as a joint statement over `execOne`/`exec`/`run` by the same fuel induction as `fuel_mono_aux`, exposed as `execOne_env_indep` / `exec_env_indep` / `run_env_indep`. This lets fuel-free specs and iris-style adequacy results quantify over an arbitrary `env` yet discharge at the canonical empty one, rather than assuming it (e.g. the `run_env_indep` axiom carried in the sep-logic merge-sort work). Axiom-clean (`propext`, `Classical.choice`, `Quot.sound`); full interpreter build green. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
mfornet
approved these changes
Jul 18, 2026
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.
What
Proves that when a module declares no imported functions (
imports = []),run— henceexec/execOne— does not depend on the host environment:envis only ever inspected inrun's host arm (env.funcs[id]?); with no imports that arm is dead, and everywhere elseenvis merely threaded. So env-independence falls out of the same joint fuel induction as the existingfuel_mono_aux—env_indep_aux(overexecOne/exec/run), withexecOne_env_indep/exec_env_indep/run_env_indepas the projections.Why
Fuel-free specs and iris-style adequacy results naturally quantify over an arbitrary
envbut want to discharge at the canonical empty one. This lets them do that by proof instead of assumption — e.g. therun_env_indepaxiom currently carried in the iris merge-sort work (SepLogic/AllocSpec.lean, #157) becomes a one-line consequence of this lemma (this statement is the general-αform of thatUnit-specialised axiom). Flagged in #157.How it's proved
Mirrors
fuel_mono_auxin the same file: joint statement over the three functions, strong induction on fuel, per-instruction case analysis viaexecOne.eq_def(reusing the existingexecOne_loop_succ/execOne_memOp_succunfolding helpers). It is simpler per case than fuel-monotonicity — env-independence is unconditional, so there is no≠ .OutOfFuelbookkeeping. The one structural difference:run's host arm is genuinely env-dependent, so it is discharged byimports = [](m.imports[id]? = none) rather than closed by reflexivity.Single-file, additive: no change to any existing definition or lemma statement.
Verification
lake buildgreen ininterpreter/.#print axiomson all three lemmas:[propext, Classical.choice, Quot.sound]— nosorryAx.Disclosure per CONTRIBUTING: AI tooling (Claude Code) was used to write and check these changes.