Archive HACHIMOJI_DNA_ENCODING.md

This commit is contained in:
Allaun Silverfox 2026-07-02 03:36:19 +02:00
parent 573455bf05
commit 17980b6603

View file

@ -0,0 +1,104 @@
# Hachimoji DNA Encoding Specification
**Version:** 0.1
**Status:** Draft
**Purpose:** Computational substrate, not compression format.
## 1. Alphabet
Eight bases, ASCII-ordered for monotone lexicographic sorting:
| Index | Base | Phase | Bits |
|-------|------|-------|------|
| 0 | A | 0° | 000 |
| 1 | B | 45° | 001 |
| 2 | C | 90° | 010 |
| 3 | G | 135° | 011 |
| 4 | P | 180° | 100 |
| 5 | S | 225° | 101 |
| 6 | T | 270° | 110 |
| 7 | Z | 315° | 111 |
**Key property:** ASCII sort order = index order = lexicographic rank.
This means `sorted(sequences)` produces the same order as `sorted(sequences, key=dna_to_int)`.
## 2. Symbol Encoding
Each symbol (byte, word, or chunk) maps to a fixed-length DNA sequence.
- **1-byte chunks:** 256 symbols → 3 bases/symbol (8³ = 512 ≥ 256)
- **2-byte chunks:** 65,536 symbols → 6 bases/symbol (8⁶ = 262,144 ≥ 65,536)
- **n unique symbols:** `ceil(log₈(n))` bases/symbol
The LUT assigns sequences by rank:
- Rank 0 → "AAA...A" (lowest)
- Rank 1 → "AAA...B"
- Rank n → highest sequence
## 3. Monotone Property
If symbols are ranked by frequency (most frequent = rank 0), then:
- Most frequent symbol → shortest/lowest DNA sequence
- Lexicographic sort of DNA = frequency sort of symbols
- This is NOT compression — it's structured representation
## 4. LUT Format
```json
{
"format": "hachimoji_lut_v1",
"bases": "ABCGPSTZ",
"chunk_size": 1,
"bases_per_symbol": 3,
"entries": {
"AAA": "20",
"AAB": "65",
"AAC": "74"
}
}
```
- Keys: DNA sequences (base-8 encoded ranks)
- Values: hex-encoded byte chunks
- Portable: JSON, human-readable, self-describing
## 5. File Format
```
.dna file: raw DNA sequence (text, A-Z only)
.lut file: JSON LUT (see above)
.meta file: encoding metadata (optional JSON)
```
## 6. Roundtrip Guarantee
```
decode(encode(data)) == data
```
Verified at encode time. No lossy steps. No approximation.
## 7. Computational Properties
The DNA sequence is not just encoded data — it's a computational address:
- **Sequence index** (base-8 integer) = symbolic rank
- **Lexicographic order** = rank order (monotone)
- **LUT lookup** = O(1) per symbol
- **Sortable** by standard string sort (= rank sort)
- **Portable** across systems (plain text + JSON)
## 8. Integration with SilverSight
- `HachimojiCodec.lean` — formal encode/decode specification
- `HachimojiLUT.lean` — LUT hierarchy (k=2, k=6, k=50)
- `PhaseCircle`/360 address space
- `dna_lut.py` — Python LUT implementation
- `dna_encode_file.py` — file encoder/decoder
## 9. Not This
- ❌ Not a compression format (bits/byte not the goal)
- ❌ Not a DNA storage format (no synthesis/sequencing constraints)
- ❌ Not a cryptographic scheme (no security claims)
- ✅ A computational substrate for manifold/QUBO/eigenvalue work