Repository navigation
refactor(Computability/WordRAM): scope the word-RAM statement syntax and ram_eval - #1091
Conversation
…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
|
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. |
There was a problem hiding this comment.
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.
|
Thanks for the offer! The refresh is pushed, and #1098 is now ported to |
SamuelSchlesinger
left a comment
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 …".
Change
One file,
Complexity/Computability/WordRAM/Notation.lean: one commit (7c68492), plus a merge ofupstream/main f86ebad (ae590c4). The entry
points
ram[,ram_block%andram_stmt%were alreadyscopedtoCslib.WordRAM. This PR alsoscopes the rest of the notation to
Cslib.WordRAM: the statement forms of the categorywramStmt,the
macro_rulesthat expandram[,ram_block%andram_stmt%, and the tacticram_evalwithits
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 thesyntax abbreviation
wramBlock. Lean has noscopedform for either. Without the open,wramStmthas no rules, so neither parses anything.Upstream's new statement form
d ← rand s(#1141) is scoped the same way; the merge keeps itsdoc bullet and expansion unchanged and only adds
scopedto itssyntaxline. Every current userof the notation, including the newer
ComplexityTests/WordRAMRandomized.lean,ComplexityTests/WordRAMQuicksort.leanandComplexity/Algorithms/WordRAM/Quicksort.lean, isinside a
Cslib.WordRAMnamespace or opens it, so no other file changes.Validation and review
Tested revision: ae590c4 (7c68492 merged with upstream/main f86ebad).
lake build --wfail --iofail(12671jobs),
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, andlake build ComplexityTests.WordRAMRandomized.git merge-tree --write-tree upstream/main ae590c40against upstream/main 79b55bc mergescleanly (no conflict). In that merged tree, every file that uses
ram[,ram_block%,ram_stmt%,ram_evalorwramStmtis inside aCslib.WordRAMnamespace or opens it.https://github.com/orbitingflea/complexitylib2/actions/runs/40446239407
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
touches only syntax attributes (
scoped) and a module doc. No definition or theorem statementchanges. No file under
abstracts/uses this notation.needed; no abstract changes.
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