Remove global variables and modifies clauses from Core, replace returns with out/inout parameters#759
Merged
shigoel merged 39 commits intoApr 22, 2026
Conversation
Contributor
Author
Implementation NotesWhat this PR does
Assumptions made
Current state
|
MikaelMayer
commented
Apr 6, 2026
MikaelMayer
commented
Apr 6, 2026
MikaelMayer
commented
Apr 6, 2026
MikaelMayer
commented
Apr 6, 2026
MikaelMayer
commented
Apr 6, 2026
MikaelMayer
commented
Apr 6, 2026
MikaelMayer
commented
Apr 7, 2026
This comment was marked as resolved.
This comment was marked as resolved.
MikaelMayer
commented
Apr 9, 2026
MikaelMayer
commented
Apr 9, 2026
This comment was marked as resolved.
This comment was marked as resolved.
Contributor
Author
|
We discussed together and we decided we also want to REMOVE the modifies clauses from the concrete syntax as well as the global variables. This is a bigger change, but a welcome improvement that will reduce the scope of Core while retaining full generality. |
Contributor
Author
|
🤖 Implemented the removal of What changed:
All existing tests pass. |
ce4dfdc to
3d0248a
Compare
bf3e310 to
92ef993
Compare
Contributor
|
Addressed comments, thank you all |
…ke-modifies-clauses-be-only-concrete-s
…github.com:strata-org/Strata into issue-757-make-modifies-clauses-be-only-concrete-s
…ke-modifies-clauses-be-only-concrete-s
…ifyCorrect.lean to Strata/Languages/Core/ProcedureWF.lean
aqjune-aws
approved these changes
Apr 22, 2026
shigoel
approved these changes
Apr 22, 2026
MikaelMayer
added a commit
that referenced
this pull request
Apr 22, 2026
PR #759 removed global variables and modifies clauses from Core. Without global variables, fvar expressions from one procedure's parameters no longer persist in shared state across procedure boundaries. The forced @n suffix on parameter fvars (which prevented cross-procedure name collisions) is no longer needed. Parameters now get bare names (e.g. x, n, cap) when they are the first use of that name, and @n suffixes only when disambiguation is needed.
5 tasks
This was referenced Apr 28, 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.
This changes
(1) the Core procedure declaration syntax from separate
input/output parameter lists (
procedure P(x: int) returns (y: int))to a unified parameter list with
out/inoutmodifiers(
procedure P(x: int, out y: int)),(2) removes the
modifiesclause from procedure specification,(3) removes global variables from Core, and
(4) changes the syntax of call
call lhs := f(args)tocall f(x, out lhs, inout ...).AST changes (summary: Procedure Header -> none, Decl -> global var removal, Call -> has list of in/inout/out args)
Procedure.Header.inputsandProcedure.Header.outputsare still there.modifiers (
inoutappears in both inputs and outputs lists)inoutby comparing input/output name overlap,emit
out/inoutprefixes instead ofreturnsclauseTwo new functions on
Procedure.Header(inProcedure.lean)classify parameters by their role:
Procedure.Header.getInoutParams: returns parameters that appearin both
inputsandoutputs(the intersection). These are theparameters for which
old xsnapshots are meaningful.Procedure.Header.getOutputOnlyParams: returns output parametersthat do NOT appear in
inputs. These are output-only parametersthat have no pre-state.
ioDisjointfromWFProcedureProp(inputs and outputs maynow overlap for inout parameters).
Removal of Decl.var (global variables)
Decl.varfromCore.DeclandDeclKind.varfromCore.DeclKind. Global variables no longer exist in the Core AST.Program.getVar?,Program.getVarTy?,Program.getVarInit?,Decl.getVar?,Decl.getVar, and related accessors.WFVarPropfrom well-formedness definitions and drop the.varcase fromWFDeclProp.ProcedureType.typeCheck: old-variable bindings for postconditionsare now added only for inout parameters (
getInoutParams), not forall program-level globals.
StatementType.typeCheckCmd: addareInoutArgsValidcheck ensuringthat inout call arguments are simple variable references with the
same name as the formal parameter.
CollectSymbols.lean: removecollectGlobalSymbols(always empty).ProcedureEval.lean: old-substitution now only covers inputparameters that also appear as outputs (inout), not program globals.
ProgramEval.lean,Core.lean: remove.varevaluation case andstatistics counting.
Old-expression rules
old(expr)now applies only to inout parameters (those appearing inboth inputs and outputs). For input-only parameters,
old x = xsothe
oldprefix is not emitted.Boole dialect updates (
Verify.lean)The new syntax of Core (
procedure/callwithout/inoutparams) is rejected,to unchange the Core syntax. A new
procedure_signatures.leantest coversaccepted and rejected procedure declaration and call statement forms.
Global variables in Boole are translated into
inoutparameters of procedures(constant globals to plain parameters).
modifies g) become inout parameters (in bothallInputsandallOutputs) viatranslateProcedureDecl.TranslateState.globalVarTypesand per-procedure modifies info intoTranslateState.modifiesMapviacollectModifiesFromSpec.modifies) becomeinput-only parameters so they remain in scope.
oldifyExprtakescurrentInoutNamesand only appliesoldprefixto inout variables. For read-only globals,
old gsimplifies tog.Pass updates
ProcBodyVerify.lean: prefix is nowinputInits ++ outputOnlyInits ++ oldInoutInits ++ assumes.ProcBodyVerifyCorrect.lean: full proof rewrite for the new prefixstructure. Added helper lemmas about
getInoutParams/getOutputOnlyParams(subset, disjointness, nodup). All proofscomplete with zero sorries.
CallElim.lean: old-variable type lookup no longer falls back toprogram-level globals.
Other changes
CoreIdent.mkOld_injectivelemma (Identifiers.lean)ioNotOldtoWFProcedureProp(no IO var is old-prefixed)out/inoutkeywords