Generation
# Error-Correcting Codes
**Definition:** Error-correcting codes are methods of encoding data by adding redundant information so that errors introduced during transmission or storage can be detected and corrected without retransmission.
The key idea is to map messages to codewords in such a way that valid codewords are sufficiently "far apart" (in terms of differing bits/symbols), allowing corrupted data to be recovered.
## Worked Example: (7,4) Hamming Code
**Setup:** Encode 4 data bits into 7 bits by adding 3 parity bits. This code can correct any single-bit error.
**Encoding:**
Let's encode the message **1011**
The 7 bits are positioned as: p₁ p₂ d₁ p₃ d₂ d₃ d₄
- Data bits: d₁=1, d₂=0, d₃=1, d₄=1
- Parity bits calculated as:
- p₁ checks positions 1,3,5,7: p₁ ⊕ 1 ⊕ 0 ⊕ 1 = 0, so **p₁=0**
- p₂ checks positions 2,3,6,7: p₂ ⊕ 1 ⊕ 1 ⊕ 1 = 0, so **p₂=1**
- p₃ checks positions 4,5,6,7: p₃ ⊕ 0 ⊕ 1 ⊕ 1 = 0, so **p₃=0**
**Codeword:** 0110011
**Error correction:** Suppose we receive **0**1**1**0011 (error in position 5)
- Check p₁: positions 1,3,5,7 → 0⊕1⊕1⊕1 = 1 ✗
- Check p₂: positions 2,3,6,7 → 1⊕1⊕1⊕1 = 0 ✓
- Check p₃: positions 4,5,6,7 → 0⊕1⊕1⊕1 = 1 ✗
Error position = 1 + 4 = **5** → flip bit 5 to recover correct codeword!
20 tokens in · 595 tokens out · 10961 ms · $0.009
Trail
03:43:44 received prompt_chars=64 verifiers=['scripture_anchors', 'theology_doctrine']
03:43:44 red_gate decision=pass reason=no disqualifying input patterns detected
03:43:55 base_llm_call model=anthropic/claude-sonnet-4-5 tokens_in=20 tokens_out=595 latency_ms=10961.2 cost_usd=0.009
03:43:55 verifier:scripture_anchors verdict=NOT_APPLICABLE summary=0 Scripture citation(s) extracted
03:43:55 verifier:theology_doctrine verdict=NOT_APPLICABLE summary=no doctrine keyword patterns detected
03:43:55 floor_gate decision=pass reason=output above protective minimum; no mismatches
03:43:55 way_gate decision=pass reason=no declared way_path (Way check NA); no coercion language
03:43:55 execution_gate decision=deferred reason=no witnesses available (Witness Roll not yet constituted)
03:43:55 signed hash_algo=sha256 hash=sha256:20fac5afa18019fe0611bce1b71906babe11c5ad6a5a4c9f92e2e9d66bd5960a