How One Binary Distinction Underlies All Information: Encoding and Compression Principles

    This article explains how a single distinction—a binary choice between two stable states—forms the foundation of information theory and modern computing. Drawing on Shannon's 1948 model, it shows how information is quantified with base-2 logarithms and entropy, why uneven probability distributions make compression possible (with a runnable Huffman coding example), where binary representation breaks down under noise and correlation, and how to apply these ideas in real systems. It closes with a practical checklist and a comparison between "starting from distinction" and "starting from meaning" as engineering approaches.

    What Is a Distinction? From “Two Stable Positions” to the Origin of Information

    In 1948, Shannon proposed a simple model in A Mathematical Theory of Communication: a device with two stable positions—such as a relay or a bistable circuit—can store one bit of information. The key point is not “what does 1 mean, what does 0 mean,” but rather that the device must be in one of two states. In other words, distinction can exist before meaning.

    A “distinction” can be understood as a single binary choice: selecting one outcome from several possibilities. It does not begin with semantics but with form. The names 0 and 1 can be assigned by convention, and even the left-right polarity can be reversed; what matters is that the representation “must be split into two sides, and at any moment falls into only one of them.” That is the minimal structure of information representation.

    From an engineering perspective, distinction matters because it breaks complex content into computable, transmittable, and verifiable sequences of choices. Text, images, audio, video, programs, and interface states can all ultimately be expressed as a chain of distinctions:

    Physical signal → Quantization → Symbols → Messages → Message → Semantics

    The lower you go, the closer distinction is to pure form; the higher you go, the more convention and meaning accumulate. Understanding this helps us view encoding, compression, error correction, and semantic governance together.

    How Do You Calculate Information? Binary Positioning and the Base-2 Logarithm

    Imagine 8 equally probable messages. We ask the first question: “Is it among the first 4?” The answer is only yes or no, and the candidate set is halved. Then we ask: “Is it among the first 2 of the remaining 4?” The range halves again. After the third question, a single message is pinned down.

    In general, selecting one message from n equally probable possibilities requires log₂ n binary choices. For example:

    1. import math
    2. print(math.log2(8)) # 3.0
    3. print(math.log2(3)) # ~ 1.58

    Back in 1928, Hartley measured information as “the logarithm of the number of possible messages.” Shannon adopted this idea and named the unit the bit. The bit is therefore not merely a hardware state but also the fundamental unit of information.

    When message probabilities are uneven, the average number of choices needed decreases. Shannon gave the entropy formula:

    H = -Σ pᵢ log₂ pᵢ

    where pᵢ is the probability of the i-th symbol. Entropy represents average uncertainty and gives the lower bound on average length for noiseless coding. The noiseless coding theorem states that each symbol requires at least H bits on average, and can always be encoded to come arbitrarily close to H.

    Why Can Uneven Probabilities Be Compressed? Entropy and Runnable Huffman Coding

    Take four symbols A, B, C, and D with probabilities 1/2, 1/4, 1/8, and 1/8. Applying the entropy formula:

    H = 1/2×1 + 1/4×2 + 1/8×3 + 1/8×3 = 1.75

    With Huffman coding, high-probability symbols can be assigned shorter codewords, pushing the average close to the entropy lower bound. A common result is:

    Symbol Probability Codeword Length
    A 1/2 0 1
    B 1/4 10 2
    C 1/8 110 3
    D 1/8 111 3

    The following is a runnable Huffman coding example. The import math at the top lets it run directly and output the codewords above:

    1. import math
    2. import heapq
    3. def huffman(weights):
    4. """
    5. Input: {symbol: probability}
    6. Output: {symbol: codeword}
    7. """
    8. heap = [(w, i, sym) for i, (sym, w) in enumerate(weights.items())]
    9. heapq.heapify(heap)
    10. counter = len(heap)
    11. while len(heap) > 1:
    12. w1, _, left = heapq.heappop(heap)
    13. w2, _, right = heapq.heappop(heap)
    14. heapq.heappush(heap, (w1 + w2, counter, (left, right)))
    15. counter += 1
    16. _, _, root = heap[0]
    17. codes = {}
    18. def walk(node, prefix):
    19. if isinstance(node, tuple):
    20. walk(node[0], prefix + "0")
    21. walk(node[1], prefix + "1")
    22. else:
    23. codes[node] = prefix
    24. walk(root, "")
    25. return codes
    26. src = {"A": 1 / 2, "B": 1 / 4, "C": 1 / 8, "D": 1 / 8}
    27. codes = huffman(src)
    28. print(codes["A"], codes["B"], codes["C"], codes["D"]) # 0 10 110 111
    29. H = -sum(p * math.log2(p) for p in src.values())
    30. avg_len = sum(p * len(codes[sym]) for sym, p in src.items())
    31. print(H, avg_len) # 1.75 1.75

    A Huffman tree is essentially a binary decision tree: from root to leaf, each step chooses 0 or 1. The higher a symbol’s probability, the closer it sits to the root, the shorter its path, and the smaller the average code length. This is precisely the core mechanism of how distinction supports encoding and compression.

    Can Any Content Be Represented in Binary? Where Do the Boundaries Fail?

    The claim that “any content can be written as a string of binary answers” holds at the representation level, but engineering requires boundary conditions.

    First, continuous quantities are not naturally binary. Temperature, volume, and brightness have no inherent thresholds. Someone must first decide “how many degrees counts as hot” or “how loud counts as noise” before a distinction exists. So a real-world distinction chain usually does not start directly from two stable positions, but rather from:

    Sampling → Quantization → Encoding

    Sampling discretizes time, quantization discretizes values, and encoding assigns symbols. Choosing the thresholds is itself a business decision.

    Second, noise makes distinction fail. Two positions can flip into each other; once a 0 is misread as a 1, the distinction becomes unreliable. Shannon’s noisy-channel coding theorem gives the channel capacity as:

    C = B log₂(1 + S/N)

    where B is the bandwidth and S/N is the signal-to-noise ratio. Only when the transmission rate stays below C can an arbitrarily small error probability be achieved. Engineers typically respond to noise in three ways:

    Approach Mechanism Cost
    Verification Parity checks, CRC, retransmission Extra check bits and latency
    Forward error correction RS codes, convolutional codes, LDPC codes Redundancy grows with correction capability
    Physical enhancement Higher power, better antennas, less interference Limited by energy, cost, and spectrum

    Third, real sources are often correlated. Entropy assumes symbol-by-symbol independence, but language, logs, images, and video all carry strong structure. Letters, pixels, and requests may be highly correlated. As a result, practical compression has more than one route beyond entropy coding:

    • Dictionary compression exploits repeated fragments, as in the LZ family;
    • Predictive coding predicts first and then encodes the error;
    • Arithmetic coding and range coding break the whole-bit-per-symbol limit;
    • Context modeling lets probabilities vary with context, approaching the true entropy.

    So binary representation can always hold, but “where to split” and “how to split” depend on your understanding of the data’s structure.

    What Does Compression Actually Remove? Redundancy, Noise, and Observability

    In engineering contexts, “information” carries two meanings:

    1. Information in Shannon’s sense: the reduction of uncertainty;
    2. Information in the everyday sense: content with business value to the receiver.

    The outcome of a fair coin toss is 1 bit of Shannon information but may be useless, while a production safety alert may take only a few bytes yet be critically important. So deciding which distinctions to keep cannot rest on information content alone—it must also weigh business value.

    Compression does not delete content; it removes recoverable redundancy. If a distinction can be inferred from other parts, it is not something that must be transmitted. Lossless compression strips out this reconstructable redundancy; whatever distinctions cannot be inferred are the core information that truly needs to be kept.

    In engineering systems, noise is not something foreign—it is the manifestation of a distinction being misread. A protocol’s version bits, check bits, timeouts, retries, circuit breakers, and lease expirations are all, at heart, admissions that “the distinction at this moment may not be trustworthy.” Observability is likewise a set of distinctions: metrics compress state, logs retain context, and traces reconstruct call paths. Sampling decides which distinctions are worth keeping, and cost decides how fine a granularity to preserve them at.

    How Do You Apply This in Real Projects? A Checklist with Priorities

    Priority Check item Applicable scenario
    High Define the possibility set first: where does the data come from, and how many possibilities exist? Interface design, data modeling
    High Make interpretation conventions explicit: who interprets each byte, under what specification? Protocol design, serialization, file formats
    High Reserve redundancy for noise: are verification, retry, timeout, and circuit breakers all in place? Network communication, message queues, remote calls
    Medium Let the probability distribution guide optimization: are hot paths and cold paths treated differently? Encoding, storage, caching, compression
    Medium Align distinction granularity with business value: which distinctions must be preserved? Logging, monitoring, data governance
    Low Establish semantic and version contracts: are changes backward compatible? API evolution, configuration management, data pipelines

    When applying this, you can ask in the following order:

    1. What possibilities does this content correspond to?
    2. Which possibilities are more common, and which are rarer?
    3. How will the receiver interpret these distinctions?
    4. If a distinction is misread, can the system detect it?
    5. Which redundancies can be removed, and which must be kept?
    6. Is the cost of preserving these distinctions acceptable?

    How Should You Choose Compared to “Starting from Meaning”?

    Starting from distinction gives you measurability, compressibility, and error correctability; starting from meaning emphasizes business value and the interpreter. The two are not mutually exclusive.

    Dimension Starting from distinction Starting from meaning
    Basic unit A binary choice A meaningful symbol
    Requires an interpreter Not mandatory; names can be conventional Must rely on an interpreter
    Handles noise Can define bit error rate and capacity Misinterpretation is hard to quantify
    Explains compression Yes—compression is removing redundancy Harder to quantify directly
    Main risk Distinction without meaning Meaning that cannot be verified

    Good engineering practice is to first use distinction to build a computable, transmittable representation, then use meaning to constrain what goal those distinctions serve. Distinction gives us tools and measurements; meaning gives us direction and boundaries.

    Conclusion: Treat “Distinction” as a Governable Engineering Resource

    Shannon’s bistable device looks simple, yet it reveals the underlying approach of information technology: any content can first be represented as a set of choices, then turned into usable information through encoding, transmission, verification, and interpretation. Distinction is not an abstract philosophical concept but a resource that can be computed, compressed, protected, and governed.

    When we face interfaces, logs, images, audio, databases, and message queues, the real question is not “does it have meaning?” but:

    • What distinctions does it contain?
    • Which distinctions must be preserved?
    • Which distinctions can be compressed?
    • Which distinctions need error correction?
    • Which distinctions need semantic constraints?
    • Is the cost of preserving these distinctions worth it?

    Once these questions are answered clearly, encoding and compression are no longer isolated techniques but foundational methods of system design.