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):deferdeleted: 1/642 ports (noi22p4.cp, where puremask.with(e)shrinks 8 lines to 4), active WA trap in search-and-keep backtracking (noip04p4.cp), and Batch 51'sccc96s3only reached fordefer cur.pop()becauseprev_permutationwas missing. Explicitdsu.undo_to(snap)andcur.pop()are 1 unmistakable line.assumedeleted: 6/611 ports (1.0%), saves 0 LOC and 0 keystrokes overassertwhile causing real misuse (cco24p4.cpwroteassumeon a postcondition self-check).assertis the sole predicate keyword (always checked; feeds flow proofs); input constraints live in typedread()bounds,read(gen:), and@checker; local-only tracing usesdebug(...).where,inline, andlenddeleted: 0/642 ports forwhereandinline(inline generic bounds<T: Ord>and implicit inline semantics onlends/yield/closures handle 100% of cases);lendappeared in 1 library file (matrix.cp) and is replaced by the tail expression (orreturn mut place) insidelends/lends mutbodies.lawdemoted from hard keyword to@law: 0/642 contestant ports and 3stdlib/files.@law disjoint(i, j) = i != jkeeps full SMT/property-test support, freeslawas 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).
Copyis internalized into compiler value semantics (0 uses as a user trait bound across 642 ports andstdlib/; small<= 16 Bnon-heap values copy implicitly, heap values move on last use and clone via.copy()). The 7 auto-derived core traits areIndex,Seq,Eq,Ord,Hash,Show, andRead; the 2 library-author traits areIndexed(unified withIndexedMut) andIterable(Gendropped since choice-stream shrinking works on any@genfunction).
- 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^26for tri-state?Bool); bare@memostays and explicit custom hash caches use plainHashMap. Delete@multitest(count:)(1/611; lost tofor _ in 0..tests:+ block-scoped@memoby +1 LOC / +23 keystrokes onnoi22p4); 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-levelvar/@grader struct.
- 19.4
List.absorbandfor 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 mutremoves an entire second iterator borrow mode and lured illegal[mut a, mut b]arrays (noip22p2); indexedfor i in 0..xs.len: xs[i].f()is uniform and pairs index with mutation directly.
- 19.5 Tropical Optional trims &
min=-skips-noneguardrail (1.3; Subtraction Audit #2 §2.3, Syntax Bakeoff #2 Tension 1, Blind Critic #4 §2). Keep Tropical Optionals (min/max/min=/max=skipnone; binary+/-and unary-on?Int/?F64absorbnone; removing them costs +945 keystrokes and +221 punctuation chars across 7/20 hard problems). Deletesum(?T)absorption (0/642; conflicted withminskippingnone) and?T +=/-=lifting (0/642; silent no-ops hide uninitialized DP). Pin mixedmin(T, ?T) -> T(3+ args viamin([a, b, c])). Document and guard against theetsr23r1p3poison-failure pitfall: whennonemeans impossible/failure inside amin=loop, check and break explicitly instead of barebest 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]Intbacking caused an 80 MB vs 10 MB RAM cliff onucrpc21g's10^7-state table. DemoteMarks<D>off the cheat sheet and core prelude; teach[D]Bool+.fill(false)/ touched-list reset as primary. KeepMarks<D>opt-in understd.marksbacked by[D]0..=2_000_000_000(lowering to 4-byteint32_t/I32storage 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.transposedandRange.l/Range.r),bsearch_first_some,slide_until,rotate_right(unified into signed Euclideanrotate_left),prod(gen),sliding_min/sliding_max,topo_prefix,topo::<V>turbofish docs (handled by bidirectional inference),Dsu.count(use.components), andfloor_div(redundant with Euclidean/; keepceil_div). RevertSparseTable.fold(r)from?Tback toT(asserting non-empty; fixesioi99p6). Demote 11 0–1-use specialized structures (MonoDeque,Steps,TwoSat,Matrix,MinCostFlow,Dir8,palindromes,shortest,walk_back,mst,convex_hull) from corestdand the cheat sheet toexamples/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 soa[idx].f = rhs,a[idx].f ??= rhs, and compound assignments evaluate all index expressions andrhsbefore borrowing the mutable place ina— makingtrie[step(o)].ends = trueandtrie[o].next[s] ??= trie.push_id(Node())borrow-safe and reallocation-safe in C++17. In interactive programs, any use ofask(...)automatically flushes all ordinaryprint(...)calls, and@interactor fn judge(sol: Interactor):replaces overloadedread_output()/print()with explicitsol.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).
Action(id, (new_f, old_f) => ..., (f, val, span) => ..., over: op)argument order pinned (composetakes new tag first, old tag second;LazySegTree<D, T>(act, a)infers tag typeF;.allis O(1) whole-domain fold;.update(i, f)does single-leaf push-modify-pull;max_right/min_lefttake/returnD.bounds; empty/inverted ranges are valid no-ops).first_ge/last_lereturn types stated side by side: sequences return index (?Int/?D),Set/SortedBagreturn key (?K),Mapreturns pair (?(K, V)).Mapentry semantics pinned:m[k]traps if missing,m[k] = vinserts or overwrites,m[k] f= xauto-inserts from op identity (0for+=/-=,noneformin=/max=),m[k] ??= initlazily inserts + lends mutably,m.remove(k) -> ?Vreturns the removed value.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 uniformx not in s).- Stateful
@graderuses top-levelvar(e.g.var state: ?State = none) or@grader structwithout uninitialized global domains;@memoexplicitly permitsask(...)and deterministic extern@grader fnoracles (guaranteeing at most one call per distinct argument tuple) while still rejecting mutated captured localvars andread()/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 50NP6). Allow diverging RHS (return ...,break,continue) on??(let u = o ?? return (none, none)); addprev_permutation(mut a)besidenext_permutation(mut a)(fixingccc96s3from 19 -> 8 lines); giveComb<P>()interior mutability solet comb = Comb<MOD>()stays immutable and freely capturable; addList.insert(i, x)andList.remove(i) -> T; surfaceRng(seed),rand(lo..hi),shuffle(mut xs), andsort(mut a, by: desc)on the cheat sheet; lock declaration-orderOrdon derivedenums and theelse if->elifparser diagnostic.