LIMIT: H(X) ≤ L_avg
ALGORITHM: HUFFMAN_OPTIMAL
ARCHITECTURE: COMPRESSOR
REDUNDANCY: PURGED
ASKiIMAN™ DOOR 07 / THE VOICE / REALM 11
--:-- · -- --- ----
AAAAA
BBBCD
00000
1010110111

Ontological Layer: Information Density

Source Coding

The Coder Becomes A Thief: Stealing Empty Space

Stripping the Redundancy

Before we transmit data across our shared multiplexed channels, we must ask: Are we sending empty space? Raw information is inherently redundant—patterns repeat, letters occur predictably, and data contains waste. Realm 11 introduces Source Coding, where we mathematically measure "Information" (Entropy) and forcefully compress the source down to its absolute theoretical limit. Common symbols get short codes; rare symbols get long codes. Redundancy goes OUT.

RAW SOURCE → PROBABILITY MODEL → ENTROPY H(X) → HUFFMAN / LZ CODING → COMPRESSED BITS

The 16 Coding Nodes

Ontological Mapping: From Probability to Compression Limits

CHAMBER 01

Source vs Channel

  • Source Coding: REMOVE redundancy (Compress)
  • Channel Coding: ADD controlled redundancy (Protect)
  • Fundamental dichotomy of information theory
  • Compression saves bandwidth and storage
CHAMBER 02

Self-Information

  • I(x) = -log₂ P(x)
  • Information = "Unexpectedness" or Surprise
  • Rare event (low P) → High information
  • Common event (high P) → Low information
CHAMBER 03

Shannon Entropy

  • H(X) = -Σ p(x) log₂ p(x)
  • Average information content per source symbol
  • Measured in bits/symbol
  • Binary source hits maximum entropy at P = 0.5
CHAMBER 04

Redundancy

  • Maximum possible entropy: H_max = log₂ M
  • If H < log₂ M, the source is redundant
  • Redundancy (R) = 1 - H/log₂ M
  • Goal: Remove redundancy to lower average code length
CHAMBER 05

Variable-Length Coding

  • Fixed-length codes waste space on rare symbols
  • Variable-length: Common symbols get shorter codes
  • Exploits statistical structure for compression
  • Requires unambiguous decoding rules
CHAMBER 06

Prefix Codes & Kraft

  • Prefix Code: No codeword is a prefix of another
  • Guarantees "Instantaneous Decodability"
  • Kraft Inequality dictates if a prefix code can exist
  • Σ 2^(-l_i) ≤ 1 for binary codes
CHAMBER 07

Huffman Algorithm

  • Bottom-up construction of an optimal prefix tree
  • Repeatedly combine the two least-probable nodes
  • Leaves are symbols; paths are 0/1 codewords
  • Optimal average length under standard assumptions
CHAMBER 08

Shannon-Fano Coding

  • Top-down partitioning algorithm
  • Sort symbols by probability, split into equal halves
  • Assign 0 to one group, 1 to the other
  • Not strictly guaranteed to be as optimal as Huffman
CHAMBER 09

Arithmetic Coding

  • Represents entire message as an interval [0, 1)
  • Each symbol dynamically subdivides the interval
  • Final floating-point number identifies the sequence
  • Can achieve fractional bit lengths (closer to H)
CHAMBER 10

Dictionary Coding (LZ)

  • Lempel-Ziv family (LZ77, LZ78, LZW)
  • Builds a dictionary of repeated patterns
  • Replaces repeated sequences with backward references
  • Universal source coding (adapts without prior model)
CHAMBER 11

Run-Length Encoding

  • Represent repeated consecutive symbols simply
  • "AAAAAAABBB" becomes "7A 3B"
  • Excellent for files with long identical sequences
  • Can expand file size if data is highly alternating
CHAMBER 12

Predictive Coding

  • Predict next value based on previous context
  • Encode only the ERROR (Actual - Predicted)
  • Residual errors have much lower variance/entropy
  • Foundation of Delta/Differential coding and Video
CHAMBER 13

Entropy Rate & Memory

  • Conditional Entropy H(X|Y): Remaining uncertainty
  • Mutual Information I(X;Y): Shared knowledge
  • Predictability = Lower Conditional Uncertainty
  • Memory reduces the asymptotic Entropy Rate
CHAMBER 14

Lossless vs Lossy

  • Lossless: Exact original recovered (Text, Software)
  • Lossy: Approximation, discarding perceptual redundancy
  • Rate-Distortion Theory: Lower Rate ↔ More Distortion
  • Lossy achieves vastly higher compression (Audio, Video)
CHAMBER 15

Source Coding Theorem

  • Asymptotic Equipartition Property (AEP)
  • Most probability mass lies in "Typical Sequences"
  • Average code length cannot drop below source entropy
  • H(X) ≤ L_avg < H(X)+1 (for optimal binary codes)
FINAL PROTOCOL

16 — The Compression Laboratory

1. SOURCE H(X) = 1.9 BITS/SYMBOL.
2. KRAFT INEQUALITY VERIFIED: Σ 2^(-L) ≤ 1.
3. LZ77 DICTIONARY BUILT (REPEATS COMPRESSED).
4. L_avg = 1.95. EFFICIENCY η = 97.4%.
[1] CALCULATE ENTROPY [2] BUILD HUFFMAN TREE [3] CHECK KRAFT BOUND [4] REMOVE REDUNDANCY [5] ENCODE BITSTREAM

By understanding the statistical predictability of the source, we have stripped away all wasted space. The data is now a highly dense, hyper-efficient stream of pure information. But this creates a new, terrifying problem: Because every bit now carries maximum meaning, a single error caused by channel noise will destroy the message. We must now selectively put redundancy back in. You are prepared for Realm 12: Channel Coding.

HUFFMAN COMPRESSION RUNNING