Design decisions

2. Index spaces

#DecisionStatusCurrent leanDepends onWhere
2.1Domains, [V]T, unchecked indexing by VSettled, revised 2026-11-20domain V = 1..=n is sugar for a sealed nominal struct over a range type with impl Index and impl Seq; its width follows the range (4 bytes at most for input-sized domains). Checks only where positions are created; the no-check guarantee is now derived from to_idx: 0..K, not a rule about domainsplan/19-index-and-lends.md §3.1
2.2Cuts (gaps between positions)Revised 2026-11-21 (v0.3)V.cuts (renamed from V.bounds). Position v: v.l / v.r are its cuts; cut c: c.l / c.r are the positions beside it (?V). .l/.r switch kind, .prev/.next keep it. v.after / v.before are the pieces v.r.. and ..v.l (186). Prefix sums answer pre.fold(r) (186)spec/core/04-indices.md R04.3
2.3Range<I>Revised 2026-11-20 (v2.2)One Range<I> type everywhere (Range1<I> deleted). Stored as two bounds (l..r, l..=r, ..i, ..=i, i.., i.r.., l.r..r.l); .l/.r (boundary cuts even if empty), .first -> ?I, .last -> ?I, .mid -> ?I, .len, .is_empty, .rev, .step(k), (lo..=hi).clamp(D). D.chunks, D[..k], r1 & r2, and .mirror deleted. ../..= bind looser than arithmetic, tighter than comparisons/in. Empty/inverted ranges are valid no-ops except SparseTable.fold -> T (asserts non-empty)§16, §18.5, §19.7
2.4SlicesSettled, revised 2026-11-20a[s] is a library projection that lends a slice. A slice is indexed by the positions of its array (V), with a window check unless proven; Sub<V> is removed. The window is a value, the slice is a lend: fns return ranges, callers apply them5.12plan/19-index-and-lends.md §4.2
2.5Product and fresh domainsSettled, revised 2026-11-20(A, B) is an Index everywhere (for p in Cell, [Cell]T, Dsu<Cell>, bfs, @memo), and a[i, j] is sugar for a[(i, j)]; domain D in a signature or binding introduces a fresh index type that can't leave its block (compress, scc, freeze)2.16plan/19-index-and-lends.md §3.2, §4.3
2.6Domains that depend on a valueOpene.g. "children of v" as a domain; deferred — tree.children(v) covers the common case without dependent domain syntax3.xdesign-v2 C2
2.7Growable arenas & freeze()Revised 2026-11-20 (v2)Pool<T>, Pool<Node<_>>, PoolMap, and Handle deleted. Use type Id = 0..=MAX (4-byte handle + 4-byte niche ?Id) with List<Node>, .push_id(x), ??=, and xs.freeze() -> (domain D, [D]T)1.2, 2.5§16, research/archive/audits/subtraction-audit-1.md Cut 6
2.8Conversions between related domainsSettled, revised 2026-11-20strict, no implicit conversion at all: every conversion is a named method (v.l, pre.vertex, V(x))2.4research/archive/RECOMMENDATIONS.md §3, plan/19-index-and-lends.md §4.2
2.9Stepping positionsRevised 2026-11-21 (v0.3)v.next / v.prev (?V) and v.next(k) / v.prev(k), the same on cuts. v + k is an Int; getting back is explicit (v.next, V(x), V.at(x)). V.wrap(x) for ringsspec/core/04-indices.md R04.3
2.10Self-reading tablesLeaningallowed only for cells provably filled alreadyplan/12-domains-and-sequences.md §4
2.11Escape hatch from domain checksSettledexplicit and greppable: a.raw[i] with an Int index; never implicit. a.raw is a library projection lending the same storage indexed by 0..K. With unchecked: (7.1) and raw intrinsics these are the contest escape hatches of G152.1research/archive/RECOMMENDATIONS.md §3
2.12Name< generics vs less-thanLeaningcapitalized name and a tentative type-argument parse closed by >; otherwise a comparison (INF < x)compiler/03-parsing.md, plan/17-syntax.md
2.13Generic type arguments & inferenceLocked v2 (2026-11-20)Bidirectional unification of non-closure args (from:, root:, g) before closures removes ~90% of explicit type args; f::<T>() is the unambiguous fallback (f<T>() stays an error). Generic fn definitions always write <D> explicitly (implicit single-letter generics deleted)2.12§16, research/archive/architecture/syntax-bakeoff-1.md Fork 2
2.14[domain]T packagesRevised 2026-11-20 (v2)an array stored with a fresh index type of its own; binding one opens it as [x.Idx]T. Serves opt-in [domain S]Char and jagged rows (List<[domain]Int>); default Str is 0..len-indexed ASCII bytes (1.6)1.6, 2.5§16, plan/19-index-and-lends.md §4.4
2.15Indexing is a traitSettled 2026-11-20a[i] is Indexed<I>.at, a projection; [I]T is sugar for the library struct Array<I, T>, and grids and permutations are library code over it3.5, 5.12plan/19-index-and-lends.md §3.3, §7
2.16Algebraic Index derivationLocked v2 (2026-11-20)5 strictly O(1), Copy finite shapes derive Index automatically: Bool, unit/payload enum (computed on demand, solving typed FlowGraph<Node>), ?T (T: Index), bounded ranges lo..hi/lo..=hi (structural equality for identical bounds in scope), and tuples/records (A, B), plus Subset<D>. [D]E: Index deleted2.1, 3.5§16, research/archive/audits/subtraction-audit-1.md Cut 5