16-state Q4 space with Gray-Code encoding and Tesseract topology — the mathematical foundation of GenesisAeon
Project description
genesis-q4-core
16-State Q4 Space · Gray-Code Encoding · Tesseract Topology
The mathematical foundation of the GenesisAeon cognitive runtime: a fully tested, zero-dependency Python library for the 16-state Q4 state space.
Mathematical Foundations
| Concept | Value |
|---|---|
| State count | 16 |
| Bits required | 4 bit (H = log₂(16) = 4 bit — not 16 bit) |
| Gray-Code | g(n) = n XOR (n >> 1) |
| Hamming distance (consecutive Gray states) | always 1 |
| Tesseract vertices | 16 |
| Tesseract edges | 32 |
| Tesseract faces | 24 |
| Tesseract cells | 8 |
The Tesseract is a 4D hypercube with 16 vertices — a topological data structure, not a metaphysical statement.
Installation
pip install genesis-q4-core
# with YAML support:
pip install "genesis-q4-core[yaml]"
# with CLI:
pip install "genesis-q4-core[cli]"
Quick Start
from genesis_q4 import Q4State, GrayCode, Tesseract, Q4TransitionValidator
# Create a state
s = Q4State(C=1, R=0, E=1, P=1)
print(s.id) # 11
print(s.binary) # "1011"
print(s.gray_id) # 10
print(s.entropy_bits) # 4.0 (log₂(16) = 4 bit)
# Gray-Code
print(GrayCode.encode(5)) # 7
print(GrayCode.decode(7)) # 5
# Core invariant: consecutive Gray codes differ by exactly 1 bit
for n in range(15):
assert GrayCode.hamming_distance(GrayCode.encode(n), GrayCode.encode(n+1)) == 1
# Tesseract navigation
t = Tesseract()
print(t.neighbors(0)) # [1, 2, 4, 8]
print(t.shortest_gray_path(0, 15)) # [0, 1, 3, 7, 15]
# Transition validation (Gray-Code policy gate)
v = Q4TransitionValidator()
v.validate(0, 1) # OK — Hamming distance = 1
v.validate(0, 15) # raises InvalidTransitionError — Hamming = 4
path = v.suggest_path(0, 15) # [0, 1, 3, 7, 15]
CLI
genesis-q4 state --id 11 # Show state 1011
genesis-q4 path --from 0 --to 15 # Shortest Gray path
genesis-q4 validate --from 5 --to 7
genesis-q4 visualize --format mermaid
State Space
The 16 Q4 states encode binary flags for four CREP dimensions:
| Dimension | Bit | Default Threshold |
|---|---|---|
| C — Coherence | 3 (MSB) | 0.5 |
| R — Resonance | 2 | 0.6 |
| E — Emergence | 1 | 0.7 |
| P — Poetics | 0 (LSB) | 0.8 |
State ID = 8*C + 4*R + 2*E + P
Gray-Code Order (4×4 grid)
0 1 3 2
6 7 5 4
12 13 15 14
10 11 9 8
Adjacent cells differ by exactly 1 bit — the canonical layout for the unified-mandala GrayGrid component.
Tesseract Topology
Vertices: 16 (= Q4 states)
Edges: 32 (= valid 1-bit transitions)
Faces: 24 (= 2-bit similarity groups)
Cells: 8 (= 3-bit subspaces)
Each vertex has exactly 4 neighbors. All paths from shortest_gray_path()
are BFS-optimal.
TypeScript
import { makeQ4State, q4StateFromId, GRAY_ORDER } from "./Q4State";
import { gray, hammingDistance, isValidTransition } from "./grayCode";
import { Tesseract } from "./hypercube";
const s = q4StateFromId(11);
// { C:1, R:0, E:1, P:1, id:11, binary:"1011", grayId:10, entropyBits:4.0 }
const t = new Tesseract();
console.log(t.shortestGrayPath(0, 15)); // [0, 1, 3, 7, 15]
Benchmark Targets
| Metric | Target |
|---|---|
hamming_invariant |
All 15 consecutive pairs = 1 bit ✓ |
state_count |
Exactly 16 ✓ |
entropy_bits |
4.0 (log₂(16)) ✓ |
tesseract_edges |
Exactly 32 ✓ |
encode_decode_roundtrip |
Gray invertible for all 16 states ✓ |
path_optimality |
BFS-shortest for all 256 pairs ✓ |
Repository Structure
genesis-q4-core/
├── genesis_q4/
│ ├── __init__.py
│ ├── constants.py # PHI_APPROX, GRAY_ORDER, topology constants
│ ├── state.py # Q4State dataclass
│ ├── gray_code.py # Gray-Code encode/decode/validate
│ ├── tesseract.py # 4D hypercube graph topology
│ ├── transitions.py # Q4TransitionValidator + InvalidTransitionError
│ ├── navigator.py # Shortest Gray-path navigation
│ └── serializer.py # JSON/YAML export
├── typescript/src/
│ ├── Q4State.ts
│ ├── grayCode.ts
│ └── hypercube.ts
├── tests/
│ ├── test_state.py
│ ├── test_gray_code.py # Hamming=1 invariant (all 15 pairs)
│ ├── test_tesseract.py
│ ├── test_transitions.py
│ └── test_serializer.py
├── pyproject.toml
└── CITATION.cff
Notes on Constants
PHI_APPROX = 1.6— Engineering approximation of Φ = 1.6180339... Error < 0.2%. Not the exact golden ratio. Used for layout spacing in unified-mandala (1.6rem gap).
Roadmap
This repo is Phase 1 of the GenesisAeon Q4 integration roadmap. Subsequent phases integrate Q4 into:
genesis-os— Q4Mapper (CREP float → Q4State), NATSga.frame.*subjectssigillin— SHA256-anchored state snapshots with Q4 encodingunified-mandala— GrayGrid + Tesseract visualisationHexaAgent— Agent roles with Q4-aware memory and replay
Role in the GenesisAeon Ecosystem
genesis-q4-core is P-Q4 in the GenesisAeon ecosystem registry,
covering the domain of the Q4 16-state space, Gray-Code encoding, and
Tesseract topology. It is a Tier T0, zero-dependency foundational package
consumed by genesis-os, sigillin, unified-mandala, and HexaAgent.
Citation
DOI will be assigned automatically on first GitHub Release once Zenodo–GitHub integration is enabled for this repo.
@software{genesis_q4_core_2026,
author = {Römer, Johann and {MOR Research Collective}},
title = {genesis-q4-core: 16-State Q4 Space with Gray-Code and Tesseract Topology},
year = {2026},
doi = {10.5281/zenodo.XXXXXXX},
url = {https://github.com/GenesisAeon/genesis-q4-core},
}
License
MIT © Johann Römer, MOR Research Collective
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file genesis_q4_core-1.0.0.tar.gz.
File metadata
- Download URL: genesis_q4_core-1.0.0.tar.gz
- Upload date:
- Size: 98.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ae9b9af07e7c40aa19883c6ee8c06eab025e94455136a7d6dccef59ce8139d7a
|
|
| MD5 |
a1d08f43e1afa45acc9fd4af31d2f6bd
|
|
| BLAKE2b-256 |
c795ad3b36d64f329d73066af3a86a516738172e3436e7c9c6f7ebf02dc9a4b2
|
File details
Details for the file genesis_q4_core-1.0.0-py3-none-any.whl.
File metadata
- Download URL: genesis_q4_core-1.0.0-py3-none-any.whl
- Upload date:
- Size: 15.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d3c271b6cc2af158566540fbbfcd9cd8cb2faa0f7f6d7908a54717049500528c
|
|
| MD5 |
69eea14fde2ba3c020c5b7843b42ee3a
|
|
| BLAKE2b-256 |
8e09ace5460431a7d6302c5cf25664f03ad111c97d1e37bf977ef241fb324777
|