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
Metadata
Release files for genesis-q4-core 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| genesis_q4_core-1.0.0.tar.gz | 98.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| genesis_q4_core-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 114.5 kB
Release files / genesis_q4_core-1.0.0.tar.gz
| Download URL | genesis_q4_core-1.0.0.tar.gz |
|---|---|
| Size | 98.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ae9b9af07e7c40aa19883c6ee8c06eab025e94455136a7d6dccef59ce8139d7a
|
|
BLAKE2b-256 checksum How to use checksums |
c795ad3b36d64f329d73066af3a86a516738172e3436e7c9c6f7ebf02dc9a4b2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|
Release files / genesis_q4_core-1.0.0-py3-none-any.whl
| Download URL | genesis_q4_core-1.0.0-py3-none-any.whl |
|---|---|
| Size | 15.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d3c271b6cc2af158566540fbbfcd9cd8cb2faa0f7f6d7908a54717049500528c
|
|
BLAKE2b-256 checksum How to use checksums |
8e09ace5460431a7d6302c5cf25664f03ad111c97d1e37bf977ef241fb324777
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|
Security for genesis-q4-core 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.