Atomic Kernel — Pure Algorithms

Atomic Kernel — Pure Algorithms

Version 1.0 | Authority: verified outputs only

All 11 algorithms in one notation. No prose between them.

Source of truth: kernel.py, tests/golden_parity.json, tests/admitted_invariants.json

─────────────────────────────────────────────────────────────

TYPES

─────────────────────────────────────────────────────────────

n : positive integer (bit width)

C : integer in [1, 2^n - 1] (constant, must be nonzero)

x : integer in [0, 2^n - 1] (state)

v : nonneg integer (value to encode)

R : list of integers ≥ 2 (radix list)

coords : list of nonneg integers (coordinate list)

plane : one of {FS, GS, RS, US}

b : basis_spec

stream : bytes

pkg : artifact_package

frame : {tick, plane, basis_spec, triplet}

─────────────────────────────────────────────────────────────

A1. delta

─────────────────────────────────────────────────────────────


Input: x (state), C (constant), n (width)

Output: next state in [0, 2^n - 1]

mask(n) = 2^n - 1 rotl(x, k, n) = ((x << k) | (x >> (n - k))) & mask(n) rotr(x, k, n) = ((x >> k) | (x << (n - k))) & mask(n)

delta(x, C, n) = (rotl(x,1,n) XOR rotl(x,3,n) XOR rotr(x,2,n) XOR C) & mask(n)

Verified:

delta(0x0001, 0x1D1D, 16) = 0x5D17

delta(0xFFFF, 0x1D1D, 16) = 0xE2E2


C_n = 0x1D repeated for each byte of width n

n=16: C = 0x1D1D

n=32: C = 0x1D1D1D1D

n=64: C = 0x1D1D1D1D1D1D1D1D

n=128: C = 0x1D1D...1D (16 bytes)

n=256: C = 0x1D1D...1D (32 bytes)

─────────────────────────────────────────────────────────────

A2. replay

─────────────────────────────────────────────────────────────


Input: x0 (seed), steps (count), C, n

Output: list of steps states beginning at x0

replay(x0, steps, C, n): x := x0 & mask(n) result := [] repeat steps times: result.append(x) x := delta(x, C, n) return result

Invariants:

len(replay(x0, steps, C, n)) = steps

replay(x0, steps, C, n)[0] = x0 & mask(n)


Golden (n=16, seed=0x0001, steps=8):

[0x0001, 0x5D17, 0x98CC, 0xCCD3, 0x1110, 0xB3F9, 0x89DD, 0x223D]

─────────────────────────────────────────────────────────────

A3. mixed_encode

─────────────────────────────────────────────────────────────


Input: v (nonneg integer), R (radix list, each r ≥ 2)

Output: coords of length len(R) + 1

mixed_encode(v, R): coords := [] for r in R: coords.append(v mod r) v := floor(v / r) coords.append(v) # most-significant remainder return coords

Examples:

mixed_encode(36, [36]) = [0, 1] (orbit=1, offset=0)

mixed_encode(100, [36]) = [28, 2] (orbit=2, offset=28)

mixed_encode(65536, [65536])= [0, 1] (plane=1, offset=0)

mixed_encode(63, [16, 4]) = [15, 3, 0]

─────────────────────────────────────────────────────────────

A4. mixed_decode

─────────────────────────────────────────────────────────────


Input: coords (list), R (radix list)

Output: nonneg integer

mixed_decode(coords, R): v := coords[len(R)] # start from most-significant for i from len(R)-1 down to 0: v := coords[i] + R[i] * v return v

Invariant (Theorem 4):

mixed_decode(mixed_encode(v, R), R) = v for all v ≥ 0, valid R

Canonical instances:

R = [W] where W = 36 → orbit/offset decomposition of crystal position

R = [16] → channel/lane address decomposition

R = [65536] → Unicode plane/offset decomposition

─────────────────────────────────────────────────────────────

A5. project_value

─────────────────────────────────────────────────────────────


Input: v (integer), p (plane), b (basis_spec)

Output: representation

project_value(v, p, b): if b.kind = "2" return ("2", v) if b.kind = "8" return ("8", v) if b.kind = "10" return ("10", v) if b.kind = "16" return ("16", v) if b.kind = "36" return ("36", v) if b.kind = "codepoint" return ("codepoint",[v mod 65536, floor(v / 65536)]) if b.kind = "mixed" return ("mixed", mixed_encode(v, b.radices))

For base-N kinds (2, 8, 10, 16, 36): representation is the value itself.

For codepoint: [offset, plane_index].

For mixed: coordinate list under b.radices.

─────────────────────────────────────────────────────────────

A6. interpret_value

─────────────────────────────────────────────────────────────


Input: repr (representation), p (plane), b (basis_spec)

Output: integer

interpret_value(repr, p, b): (kind, val) := repr if kind = "2" return val if kind = "8" return val if kind = "10" return val if kind = "16" return val if kind = "36" return val if kind = "codepoint" return val[0] + 65536 * val[1] if kind = "mixed" return mixed_decode(val, b.radices)

Invariant (Theorem 5):

interpret_value(project_value(v, p, b), p, b) = v

─────────────────────────────────────────────────────────────

A7. fano_triplet

─────────────────────────────────────────────────────────────


Input: tick (integer)

Output: triplet of three point indices from {0..6}

FANO_LINES = [ (0, 1, 3), # tick mod 7 = 0 (0, 2, 5), # tick mod 7 = 1 (0, 4, 6), # tick mod 7 = 2 (1, 2, 4), # tick mod 7 = 3 (1, 5, 6), # tick mod 7 = 4 (2, 3, 6), # tick mod 7 = 5 (3, 4, 5), # tick mod 7 = 6 ]

fano_triplet(tick): return FANO_LINES[tick mod 7]

Properties (verified):

7 points, 7 lines, 3 points per line, 3 lines per point

fano_triplet(t + 7) = fano_triplet(t) for all t

─────────────────────────────────────────────────────────────

A8. frame_at_tick

─────────────────────────────────────────────────────────────


Input: tick, basis_spec, plane

Output: frame record

frame_at_tick(tick, basis_spec, plane): return { tick: tick, plane: plane, basis_spec: basis_spec, triplet: fano_triplet(tick), }

─────────────────────────────────────────────────────────────

A9. projection_vector

─────────────────────────────────────────────────────────────


Input: entity_stream (bytes), frame

Output: list of four byte sequences [pFS, pGS, pRS, pUS]


project_entity(stream, plane):

returns the bytes of stream enclosed within matching TYPE=0

control words of the given channel.

FLAG=1 bytes (0x80-0xFF) with CH matching plane and TYPE=0 are boundaries.

FLAG=0 bytes (0x01-0x7F) between matching boundaries are content.

PLANE_OPEN = { FS: 0x80, GS: 0xA0, RS: 0xC0, US: 0xE0 }

project_entity(stream, plane): boundary := PLANE_OPEN[plane] inside := false content := [] for b in stream: is_ctrl := (b & 0x80) != 0 is_bdry := is_ctrl AND (b & 0xE0) = (boundary & 0xE0) AND (b & 0x01) = 0 if is_bdry: inside := NOT inside elif NOT is_ctrl AND inside: content.append(b) return bytes(content)

projection_vector(entity_stream, frame): return [ project_entity(entity_stream, FS), project_entity(entity_stream, GS), project_entity(entity_stream, RS), project_entity(entity_stream, US), ]

Examples:

stream = [0x42, 0x43, 0x44] (pure payload, no markers)

projection_vector → [b'BCD', b'BCD', b'BCD', b'BCD'] (collapsed)


stream = [0xA0, 0x42, 0x43, 0xA0, 0xE0, 0x44, 0xE0]

^GS open ^GS close ^US open ^US close

projection_vector → [b'', b'BC', b'', b'D'] (divergent)

─────────────────────────────────────────────────────────────

A10. is_collapsed / continuation_surface

─────────────────────────────────────────────────────────────


Input: V (list of four byte sequences)

Output: boolean / list

is_collapsed(V): return all elements of V are equal

is_divergent(V): return NOT is_collapsed(V)

continuation_surface(V): seen := [] for x in V: if x NOT in seen: seen.append(x) return seen # deduplicated, order preserved

step_projection(entity_stream, tick, basis_spec): frame := frame_at_tick(tick, basis_spec, RS) V := projection_vector(entity_stream, frame) if is_collapsed(V): return ("collapsed", V[0]) else: return ("divergent", continuation_surface(V))

A stream with no structural markers is always collapsed.

A stream with plane-differentiating markers is divergent.

The collapsed/divergent status is a property of the stream content,

not a label or annotation.

─────────────────────────────────────────────────────────────

A11. verify_package

─────────────────────────────────────────────────────────────


Input: pkg (artifact_package)

Output: boolean

pkg = { type: string, # "artifact_package" version: integer, # 1 artifact_kind: string, payload_bytes: bytes, fingerprint_algo: string, # "sha3_256" fingerprint: string, # "sha3_256:<64 hex chars>" }

verify_package(pkg): computed := hash(pkg.payload_bytes, pkg.fingerprint_algo) return computed = pkg.fingerprint

apply_package(pkg): if NOT verify_package(pkg): reject # do not apply parse payload validate kind and schema apply

Invariant: if verify_package(pkg) = false, payload is not applied.

─────────────────────────────────────────────────────────────

PURE INVARIANTS

─────────────────────────────────────────────────────────────

I1. delta(x, C, n) is deterministic delta(x, C, n) = delta(x, C, n) for all x, C, n

I2. replay is deterministic replay(x0, s, C, n) = replay(x0, s, C, n) for all x0, s, C, n

I3. mixed_decode(mixed_encode(v, R), R) = v for all v ≥ 0 and R with each r ≥ 2

I4. interpret_value(project_value(v, p, b), p, b) = v for all valid (v, p, b)

I5. fano_triplet(t + 7) = fano_triplet(t) for all t

I6. projection_vector is deterministic given same (stream, frame), same result

I7. continuation_surface is deterministic given same V, same result

I8. invalid package verification rejects verify_package(pkg) = false ⟹ apply does not execute

─────────────────────────────────────────────────────────────

SMALLEST COMPLETE FORM

─────────────────────────────────────────────────────────────

A1. delta A2. replay A3. mixed_encode A4. mixed_decode A5. project_value A6. interpret_value A7. fano_triplet A8. frame_at_tick A9. projection_vector (uses project_entity) A10. is_collapsed / continuation_surface / step_projection A11. verify_package / apply_package

─────────────────────────────────────────────────────────────

MINIMAL COMPOSITION

─────────────────────────────────────────────────────────────

x(t+1) = delta(x(t), C, n)

frame(t) = frame_at_tick(t, basis_spec, plane)

repr = project_value(v, p, b) v = interpret_value(repr, p, b)

V = projection_vector(entity_stream, frame(t))

if is_collapsed(V): output = (collapsed, V[0]) else: output = (divergent, continuation_surface(V))

valid = verify_package(pkg)

─────────────────────────────────────────────────────────────

CANONICAL INSTANCES OF A3/A4

─────────────────────────────────────────────────────────────

orbit/offset (crystal timing, W = 36)

orbit, offset = mixed_encode(position, [36])[1], mixed_encode(position, [36])[0] position = mixed_decode([offset, orbit], [36])

channel/lane (control-plane address)

lane, channel = mixed_encode(address, [16])[0], mixed_encode(address, [16])[1] address = mixed_decode([lane, channel], [16])

Unicode codepoint (plane/offset)

offset, plane = mixed_encode(codepoint, [65536])[0], mixed_encode(codepoint, [65536])[1] codepoint = mixed_decode([offset, plane], [65536])

These are the same algorithm. The radix list is the only parameter.

─────────────────────────────────────────────────────────────

DERIVATION NOTE (non-normative)

─────────────────────────────────────────────────────────────


The following values are derived from A1/A2, not chosen:


period = 8 property of delta(16) from seed 0x0001

prime 73 smallest p with ord_p(10) = 8

B = [0,1,3,6,9,8,6,3] digits of 1/73

W = 36 sum(B)


Frozen in tests/admitted_invariants.json.

73 is a witness, not a parameter.


Genesis Frame is the first public frame of the Atomic Kernel: a playable narrative world, artifact toolkit, and deterministic substrate packaged as a starting environment people can open, explore, test, and build on. Mission: We build a navigable artifact map so collaborators can co-create worlds that evolve independently yet interoperate at any shared replay step in time. This repository is a framed distribution built from my atomic-kernel work and expanded into a usable entrypoint for others. It combines: a deterministic replay/kernel layer a control-plane and artifact model a Three.js world interface a narrative chapter system compiled from markdown into NDJSON local save slots, editor mode, and story mode in one page https://github.com/bthornemail/genesis-frame

To view or add a comment, sign in

More articles by Brian Thorne

Others also viewed

Explore content categories