Skip to content

refactor(Computability/WordRAM): scope the word-RAM statement syntax and ram_eval - #1091

Merged
SamuelSchlesinger merged 2 commits into
cslib-community:mainfrom
orbitingflea:wordram-notation-scoped
Oct 27, 2026
Merged

SamuelSchlesinger merged 2 commits into
cslib-community:mainfrom
orbitingflea:wordram-notation-scoped

Conversation

@orbitingflea

@orbitingflea orbitingflea commented Oct 25, 2026 •

Copy link
Copy Markdown
Collaborator

Change

One file, Complexity/Computability/WordRAM/Notation.lean: one commit (7c68492), plus a merge of
upstream/main f86ebad (ae590c4). The entry
points ram[, ram_block% and ram_stmt% were already scoped to Cslib.WordRAM. This PR also
scopes the rest of the notation to Cslib.WordRAM: the statement forms of the category wramStmt,
the macro_rules that expand ram[, ram_block% and ram_stmt%, and the tactic ram_eval with
its macro_rules. The module doc says so. No definition, theorem or proof changes.

Why: a later PR (Dijkstra's algorithm on the word RAM) adds a formal abstract whose bridge imports
word-RAM programs written in this notation. The abstract's import closure should carry no active
global syntax. After this change, the notation stays inactive until open Cslib.WordRAM.

Two declarations stay global: the syntax category wramStmt (declare_syntax_cat) and the
syntax abbreviation wramBlock. Lean has no scoped form for either. Without the open,
wramStmt has no rules, so neither parses anything.

Upstream's new statement form d ← rand s (#1141) is scoped the same way; the merge keeps its
doc bullet and expansion unchanged and only adds scoped to its syntax line. Every current user
of the notation, including the newer ComplexityTests/WordRAMRandomized.lean,
ComplexityTests/WordRAMQuicksort.lean and Complexity/Algorithms/WordRAM/Quicksort.lean, is
inside a Cslib.WordRAM namespace or opens it, so no other file changes.

  • Existing notions considered: none; this PR adds no definition.

Validation and review

Tested revision: ae590c4 (7c68492 merged with upstream/main f86ebad).

  • Gate on ae590c4, run by the fork's lead agent, passed: lake build --wfail --iofail (12671
    jobs), scripts/check.sh (all six steps), python3 -B scripts/check_hygiene.py --check-simp,
    python3 -B scripts/check_tidy_surface.py (matches the baseline),
    python3 -B scripts/check_changed_files.py --base upstream/main, and
    lake build ComplexityTests.WordRAMRandomized.
  • git merge-tree --write-tree upstream/main ae590c40 against upstream/main 79b55bc merges
    cleanly (no conflict). In that merged tree, every file that uses ram[, ram_block%,
    ram_stmt%, ram_eval or wramStmt is inside a Cslib.WordRAM namespace or opens it.
  • CI: fork CI (Lean Action CI) on ae590c4 passed:
    https://github.com/orbitingflea/complexitylib2/actions/runs/40446239407
  • Review (all by AI agents): independent AI agent reviews of 7c68492 by Codex gpt-6.1-sol and
    Claude Opus 5.5, both "ready", and by Gemini 4 Argon (gemini-4-argon-high), "ready". The merge
    ae590c4 was re-checked by Codex gpt-6.1-sol and Claude Opus 5.5, both "ready". No human has
    reviewed this PR yet.

Headline abstracts

  • Affected abstracts/catalogue entries, or reason the selection is unaffected: none. The change
    touches only syntax attributes (scoped) and a module doc. No definition or theorem statement
    changes. No file under abstracts/ uses this notation.
  • Independent abstract review (reviewer, exact source revision, findings/resolutions): not
    needed; no abstract changes.
  • PDF artifact/run and source/PR-head revisions; rendered-page and declaration-link checks: not
    applicable; no abstract or catalogue entry changes.

AI assistance

Written with Claude Code (Claude Opus 5.5), under Renfei Zhou's direction. Claude Code wrote the
change and this text. All reviews listed are AI agent reviews; no human has reviewed this PR yet.

🤖 Generated with Claude Code

…and ram_eval

The statement forms of `wramStmt`, the `macro_rules` that expand `ram[`, `ram_block%` and
`ram_stmt%`, and the tactic `ram_eval` with its `macro_rules` are now `scoped` to
`Cslib.WordRAM`, like the entry points `ram[`, `ram_block%` and `ram_stmt%` already were. Only the
category `wramStmt` and the syntax abbreviation `wramBlock` stay global, since Lean cannot scope
them; without the open they parse nothing. Every current user is inside a `Cslib.WordRAM`
namespace or opens it before use, so no other file changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	Complexity/Computability/WordRAM/Notation.lean

SamuelSchlesinger commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

coordinator-reviewer-codex-20261023 (agent coordinator): I offered a mechanical current-main refresh of this small syntax-scoping PR, preserving your payload and credit, followed by #1098 review when you consider that draft ready. That assistance is now parked under Samuel's current priority. Your branches remain untouched. Please feel free to record whether you would welcome that help when review capacity returns.

@orbitingflea
orbitingflea marked this pull request as ready for review October 27, 2026 03:57
Copilot AI balanced review requested due to automatic review settings October 27, 2026 03:57

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@orbitingflea

Copy link
Copy Markdown
Collaborator Author

Thanks for the offer! The refresh is pushed, and #1098 is now ported to Code.rand / instrOf and ready for review as well.

@SamuelSchlesinger SamuelSchlesinger left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reviewer-jetski-5208-1091 for coordinator-jetski-5208b1c7 (agent review, not human approval): APPROVED at ae590c400732903bba45d1136847e74f3fc9a063

Thanks, Renfei, for this tidy cleanup and for keeping the PR description so clear.

This is a refactor with no change to semantics. It adds scoped to all 21 wramStmt statement forms (including the newer d ← rand s), to the two macro_rules blocks that expand ram[ / ram_block% / ram_stmt%, and to the ram_eval syntax and its macro_rules. It also updates the module docstring to match. No declaration is added, removed or renamed, and the expansions and tactic body are unchanged. After this change, every syntax rule, macro and elaboration hook in Notation.lean is scoped to Cslib.WordRAM. What stays global is the category wramStmt and the parser abbreviation Cslib.WordRAM.wramBlock, as the description says. Neither can be scoped, and neither parses anything until open Cslib.WordRAM adds rules to wramStmt. So no notation leaks globally.

Clients: the branch's merge base (f86ebad) is well behind current main, which has since added many notation users (FusionTree, van Emde Boas, prefix sums, multiword, RandomizedWordRAMBridge, …). Notation.lean itself has not changed on main, and git merge-tree with current main (b64bd2b) is clean. In that merged tree I checked all 44 files that use ram[, ram_block%, ram_stmt% or ram_eval. Every use is inside a Cslib.WordRAM.* namespace or after an unrestricted open Cslib.WordRAM. No open … (names) form appears, and that form would not activate scoped syntax. I also found no macro or tactic quotation outside Notation.lean that produces these nodes, so scoping the macro_rules cannot break expansion at another use site. For example, Complexity/Computability/WordRAM/Multiword/Workspace.lean relies only on its namespace Cslib.WordRAM.Multiword.Workspace, which activates the scope.

Abstract impact: none. No abstract statement changes. The only abstract-side file that mentions the notation is RandomizedWordRAMBridge.lean, and it mentions it only in a comment; that file also opens Cslib.WordRAM.

Limits of this review: ci-checks is green on this exact head, but that run tested the PR against its older base. I did not build the merged tree. The client check above is textual, and the merge queue / a rebase CI run should confirm it.

Non-blocking notes:

  • nit: the description links no issue. A one-line pointer to #1098 (the motivating Dijkstra abstract) or a small tracking issue would make the record easier to follow.
  • nit (inline): one docstring wording.

It is scoped: `open Cslib.WordRAM` enables it, with its statement forms, their expansions and the
tactic `ram_eval`. Only the category `wramStmt` and the syntax abbreviation `wramBlock` are
global, since Lean cannot scope them; without the open, `wramStmt` has no rules, so they parse
nothing. The statement forms follow the word-RAM notation of [Algolean][Algolean2026]. Its only

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: after the rewrite, "Its only new tokens" follows "The statement forms follow …", so "Its" now reads as if it refers to the statement forms. Consider "The notation's only new tokens are …".

@SamuelSchlesinger
SamuelSchlesinger added this pull request to the merge queue Oct 27, 2026
Merged via the queue into cslib-community:main with commit 63bb52f Oct 27, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants