Design decisions

19. Locked CP Lang v2.2 Architecture (Wave 4 — Ultra-Lean 34-Keyword Spec, 2026-11-20)

Wave 4 synthesizes Subtraction Audit #2 (research/archive/audits/subtraction-audit-2-v21.md, d6b3c4c, 642 canonical .cp ports), Syntax Bakeoff #2 (research/archive/architecture/syntax-bakeoff-2-v21.md, a9ca4f8, 20 hard multi-topic ports + 611-port incidence census), Blind Critic #4 (research/archive/blind-evals/blind-critic-4-v21-audit.md, 02f6137, 8 blind 2 AM Olympiad/ICPC drafts + 3 pivot/WA drills), and Batches 47–51 (50 hard CCC/CCO, IOI, NOI/NOIP, APIO, and EGOI ports) into CP Lang v2.2 (research/archive/architecture/language-architecture-v2.2.md, docs/one-page-cheat-sheet.md). (This edit also removes a stray merge-conflict trailer left at the end of §18.)

  • 19.1 Six keywords cut: 40 -> 34 reserved keywords (3.11, 5.4, 5.7, 5.12, 5.13, 7.1, 7.6, 7.9; Subtraction Audit #2 §§2.1–2.2, Syntax Bakeoff #2 Tension 5). The locked keyword budget drops to 30 contestant keywords (including 3 literals true, false, none) plus 4 library-author keywords (trait, impl, lends, yield):
    • defer deleted: 1/642 ports (noi22p4.cp, where pure mask.with(e) shrinks 8 lines to 4), active WA trap in search-and-keep backtracking (noip04p4.cp), and Batch 51's ccc96s3 only reached for defer cur.pop() because prev_permutation was missing. Explicit dsu.undo_to(snap) and cur.pop() are 1 unmistakable line.
    • assume deleted: 6/611 ports (1.0%), saves 0 LOC and 0 keystrokes over assert while causing real misuse (cco24p4.cp wrote assume on a postcondition self-check). assert is the sole predicate keyword (always checked; feeds flow proofs); input constraints live in typed read() bounds, read(gen:), and @checker; local-only tracing uses debug(...).
    • where, inline, and lend deleted: 0/642 ports for where and inline (inline generic bounds <T: Ord> and implicit inline semantics on lends/yield/closures handle 100% of cases); lend appeared in 1 library file (matrix.cp) and is replaced by the tail expression (or return mut place) inside lends / lends mut bodies.
    • law demoted from hard keyword to @law: 0/642 contestant ports and 3 stdlib/ files. @law disjoint(i, j) = i != j keeps full SMT/property-test support, frees law as an identifier, and auto-derives disjointness for trivial single-index forwarding (mut self.data[i.to_idx]).
  • 19.2 Core traits 8 -> 7 & library traits 4 -> 2 (3.5; Subtraction Audit #2 §2.12). Copy is internalized into compiler value semantics (0 uses as a user trait bound across 642 ports and stdlib/; small <= 16 B non-heap values copy implicitly, heap values move on last use and clone via .copy()). The 7 auto-derived core traits are Index, Seq, Eq, Ord, Hash, Show, and Read; the 2 library-author traits are Indexed (unified with IndexedMut) and Iterable (Gen dropped since choice-stream shrinking works on any @gen function).
  • 19.3 Decorator parameter grammars & grader edge cases cut (3.11, 5.9, 6.3, 6.8; Subtraction Audit #2 §2.5, Syntax Bakeoff #2 Tension 2). Delete @memo(flat) (0/611) and @memo(hash) (3/611, redundant with runtime auto-dispatch at <= 2^24 / 2^26 for tri-state ?Bool); bare @memo stays and explicit custom hash caches use plain HashMap. Delete @multitest(count:) (1/611; lost to for _ in 0..tests: + block-scoped @memo by +1 LOC / +23 keystrokes on noi22p4); keep bare @multitest, @multitest(until_eof), and bare @multitest fn solve():. Delete @grader const (1/642) and uninitialized file-scope grader domains (1/642); keep bodyless @grader fn, exported @grader fn, sibling-parameter array bounds, and stateful top-level var / @grader struct.
  • 19.4 List.absorb and for mut x in xs: deleted (5.3, 7.19; Subtraction Audit #2 §§2.4 & 2.9, Syntax Bakeoff #2 Tension 3). Both hit 0/642 canonical ports. .absorb() fails same-container aliasing (cco22p5, noi22p1), hides an O(|other|) vs O(min) complexity trap across containers, and rarely applies when small-to-large updates companion arrays; .take() + swap(mut dst, mut src) stays locked as the uniform 2-line idiom. for mut removes an entire second iterator borrow mode and lured illegal [mut a, mut b] arrays (noip22p2); indexed for i in 0..xs.len: xs[i].f() is uniform and pairs index with mutation directly.
  • 19.5 Tropical Optional trims & min=-skips-none guardrail (1.3; Subtraction Audit #2 §2.3, Syntax Bakeoff #2 Tension 1, Blind Critic #4 §2). Keep Tropical Optionals (min/max/min=/max= skip none; binary +/- and unary - on ?Int/?F64 absorb none; removing them costs +945 keystrokes and +221 punctuation chars across 7/20 hard problems). Delete sum(?T) absorption (0/642; conflicted with min skipping none) and ?T +=/-= lifting (0/642; silent no-ops hide uninitialized DP). Pin mixed min(T, ?T) -> T (3+ args via min([a, b, c])). Document and guard against the etsr23r1p3 poison-failure pitfall: when none means impossible/failure inside a min= loop, check and break explicitly instead of bare best min= cand.
  • 19.6 Marks<D> demoted from core & shrunk to 32-bit (I32) stamps (7.4, 7.19; Subtraction Audit #2 §2.6, Syntax Bakeoff #2 Tension 4). 0/642 ports, and 8-byte [D]Int backing caused an 80 MB vs 10 MB RAM cliff on ucrpc21g's 10^7-state table. Demote Marks<D> off the cheat sheet and core prelude; teach [D]Bool + .fill(false) / touched-list reset as primary. Keep Marks<D> opt-in under std.marks backed by [D]0..=2_000_000_000 (lowering to 4-byte int32_t / I32 storage in C++17, with wraparound reset).
  • 19.7 Low-usage domain, range, grid, search, sequence & stdlib trims (2.3, 4.3, 7.19; Subtraction Audit #2 §§2.7–2.11, Batch 49 §4). Delete D.chunks(k), D[..k], r1 & r2, .mirror, .flipped_rows/.flipped_cols/.flipped (keep .transposed and Range.l/Range.r), bsearch_first_some, slide_until, rotate_right (unified into signed Euclidean rotate_left), prod(gen), sliding_min/sliding_max, topo_prefix, topo::<V> turbofish docs (handled by bidirectional inference), Dsu.count (use .components), and floor_div (redundant with Euclidean /; keep ceil_div). Revert SparseTable.fold(r) from ?T back to T (asserting non-empty; fixes ioi99p6). Demote 11 0–1-use specialized structures (MonoDeque, Steps, TwoSat, Matrix, MinCostFlow, Dir8, palindromes, shortest, walk_back, mst, convex_hull) from core std and the cheat sheet to examples/local-lib/.
  • 19.8 Index-before-place-borrow evaluation & interactive I/O hardening (5.3, 6.6; Syntax Bakeoff #2 Tensions 3 & 5, Batch 47 §4, Batch 50 NP1). Extend RHS-before-LHS so a[idx].f = rhs, a[idx].f ??= rhs, and compound assignments evaluate all index expressions and rhs before borrowing the mutable place in a — making trie[step(o)].ends = true and trie[o].next[s] ??= trie.push_id(Node()) borrow-safe and reallocation-safe in C++17. In interactive programs, any use of ask(...) automatically flushes all ordinary print(...) calls, and @interactor fn judge(sol: Interactor): replaces overloaded read_output()/print() with explicit sol.recv() / sol.send(...) (read() reads the hidden judge test case).
  • 19.9 All five Blind Critic #4 contest-pressure ambiguities pinned on the cheat sheet (4.3, 5.9, 6.8, 7.19; Blind Critic #4 §§3 & 7, Batches 47–49).
    1. Action(id, (new_f, old_f) => ..., (f, val, span) => ..., over: op) argument order pinned (compose takes new tag first, old tag second; LazySegTree<D, T>(act, a) infers tag type F; .all is O(1) whole-domain fold; .update(i, f) does single-leaf push-modify-pull; max_right/min_left take/return D.bounds; empty/inverted ranges are valid no-ops).
    2. first_ge/last_le return types stated side by side: sequences return index (?Int/?D), Set/SortedBag return key (?K), Map returns pair (?(K, V)).
    3. Map entry semantics pinned: m[k] traps if missing, m[k] = v inserts or overwrites, m[k] f= x auto-inserts from op identity (0 for +=/-=, none for min=/max=), m[k] ??= init lazily inserts + lends mutably, m.remove(k) -> ?V returns the removed value.
    4. Subset<D> constructors and all three iterations pinned (Subset<D>.empty, .full, for mask in Subset<D>, for v in mask, for sub in mask.subsets, plus uniform x not in s).
    5. Stateful @grader uses top-level var (e.g. var state: ?State = none) or @grader struct without uninitialized global domains; @memo explicitly permits ask(...) and deterministic extern @grader fn oracles (guaranteeing at most one call per distinct argument tuple) while still rejecting mutated captured local vars and read()/print().
  • 19.10 Batch 51 zero-keyword wins & contest-ergonomics polish (1.3, 3.10, 4.3, 7.6; Batch 51 F1/F3/F5, Blind Critic #4 §§3.4–3.7, Batch 48 §48.2, Batch 50 NP6). Allow diverging RHS (return ..., break, continue) on ?? (let u = o ?? return (none, none)); add prev_permutation(mut a) beside next_permutation(mut a) (fixing ccc96s3 from 19 -> 8 lines); give Comb<P>() interior mutability so let comb = Comb<MOD>() stays immutable and freely capturable; add List.insert(i, x) and List.remove(i) -> T; surface Rng(seed), rand(lo..hi), shuffle(mut xs), and sort(mut a, by: desc) on the cheat sheet; lock declaration-order Ord on derived enums and the else if -> elif parser diagnostic.