Skip to content

Make type of Assign more specific with Variable inductive#36

Draft
keyboardDrummer-bot wants to merge 3 commits intomainfrom
issue-21-variable-type-refactor
Draft

Make type of Assign more specific with Variable inductive#36
keyboardDrummer-bot wants to merge 3 commits intomainfrom
issue-21-variable-type-refactor

Conversation

@keyboardDrummer-bot
Copy link
Copy Markdown
Collaborator

Summary

Implements the refactoring requested in #21: makes the type of Assign targets more specific by introducing a Variable inductive type.

Changes

Core type change (Laurel.lean)

  • Introduced Variable inductive inside the mutual block:
    inductive Variable where
      | Local (name : Identifier)
      | Field (target : AstNode StmtExpr) (fieldName : Identifier)
  • Changed Assign from List (AstNode StmtExpr) to List (AstNode Variable)
  • Replaced StmtExpr.Identifier with StmtExpr.Variable (.Local name)
  • Removed StmtExpr.FieldSelect, replaced with StmtExpr.Variable (.Field target fieldName)
  • Added VariableMd abbreviation

Grammar (LaurelGrammar.st)

  • Added multiAssign operator for multi-target assignment syntax

Updated passes

  • MapStmtExpr.lean — updated traversal for new constructors
  • Resolution.lean — added resolveVariable in mutual block with resolveStmtExpr
  • HeapParameterization.lean — updated field detection and heap variable references
  • LaurelToCoreTranslator.lean — updated pattern matching on targets
  • LiftImperativeExpressions.lean — updated assign target handling
  • FilterPrelude.lean, CoreGroupingAndOrdering.lean, InferHoleTypes.lean, ConstrainedTypeElim.lean, EliminateHoles.lean, EliminateValueReturns.lean, ModifiesClauses.lean, TypeHierarchy.lean, LaurelTypes.lean
  • Grammar translators (both directions)
  • Python-to-Laurel translator and specs

Notes

  • Multi-target assignment in the grammar uses identifier targets only (as specified in the issue)
  • The assign comment documents that multiple targets only work with identifier targets and a call as RHS

Closes #21

- Introduce Variable inductive with Local and Field constructors
- Change Assign targets from List (AstNode StmtExpr) to List (AstNode Variable)
- Replace StmtExpr.Identifier with StmtExpr.Variable (.Local name)
- Replace StmtExpr.FieldSelect with StmtExpr.Variable (.Field target fieldName)
- Add multi-target assignment (multiAssign) to Laurel grammar
- Update all Laurel passes and Python-to-Laurel translator

Closes #21
…ion proofs

- Rename 'variable' field to 'ref' in StmtExpr.Variable (Lean keyword conflict)
- Rename 'variable' local in ConcreteToAbstractTreeTranslator (same)
- Fix multiAssign grammar: use CommaSepBy Ident with parenthesized syntax
  to avoid leading-symbol recursion and parsing ambiguity
- Add Variable.sizeOf_field_target lemma for termination proofs
- Fix termination in MapStmtExpr, CoreGroupingAndOrdering, Resolution,
  HeapParameterization, TypeHierarchy by adding 'have' annotations
- Inline resolveVariable into resolveStmtExpr to avoid mutual recursion
- Inline recurseVariable in HeapParameterization
- Fix PythonToLaurel: use freeVarTarget for Assign targets, fix missing
  newline and parenthesis
- Fix TypeHierarchy diamond field check for Assign targets
- Fix test references to removed StmtExpr.Identifier constructor
The docs build uses --wfail which treats warnings as errors.
The unused variable linter flagged h1 and h2 in HeapParameterization.lean.
@keyboardDrummer-bot
Copy link
Copy Markdown
Collaborator Author

I investigated the CI failure. The only failing check is "Run internal benchmarks of Strata" which requires AWS credentials (secrets.AWS_BENCHMARK_ACCOUNT) to trigger a CodeBuild job. The job failed in ~1 minute (started 10:30:15, completed 10:31:23), which is consistent with a credential/permissions failure at the "Configure AWS credentials" step rather than an actual code issue.

All other 13 checks passed (Lean build+test, Python tests on 3.11–3.14, CBMC tests, lint, documentation, etc.).

Locally, lake build, lake test, and lake lint all pass successfully. This failure is not caused by the code changes in this PR — it's an infrastructure issue with the benchmark job's AWS access in this repository.

@github-actions github-actions Bot added the Git conflicts PR has merge conflicts with the base branch label May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Git conflicts PR has merge conflicts with the base branch Laurel Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make type of Assign more specific

1 participant