The Impossible Compressor
Why no lossless algorithm can make every file smaller, and what that reveals about the nature of information itself.

Imagine someone develops a compression algorithm that guarantees every file will be at least one byte smaller after compression.
It doesn’t sound particularly ambitious. Modern compression algorithms regularly reduce files to a fraction of their original size. Surely guaranteeing a single byte of savings isn’t an unreasonable expectation.
But what happens if we compress the resulting file again?
We save another byte.
And again?
Another byte.
Eventually, we could reduce an entire operating system, a collection of photographs, or every document ever written to a single byte. We could continue until there was nothing left at all.
As long as the algorithm is lossless, we could reconstruct everything.
Obviously, something is wrong with this proposition. What’s interesting is that the problem has nothing to do with processing power, memory, implementation quality, or the sophistication of our compression algorithm.
Even with unlimited computational resources, such an algorithm cannot exist.
The reason begins with a rather simple mathematical observation.
There aren’t enough smaller files
Let’s forget about gigabytes of information for a moment and consider a file containing exactly three bits.
There are eight possible arrangements:
000
001
010
011
100
101
110
111
Suppose we want to develop an algorithm that compresses every one of these arrangements into fewer than three bits.
What representations are available?
| Length | Possible representations | Count |
|---|---|---|
| 0 bits | Empty string | 1 |
| 1 bit | 0, 1 | 2 |
| 2 bits | 00, 01, 10, 11 | 4 |
| Total | 7 |
We have eight possible inputs and only seven possible shorter outputs.
Even if we allow an empty file as a valid compressed representation, we’re still one representation short.
We could assign two inputs to the same output, but then our decoder would encounter a problem.
Which original input should it reconstruct?
If both 110 and 111 compress to 01, the decoder has no way of determining which sequence was originally supplied.
Unless it receives additional information, something has been lost.
That additional information is itself part of the compressed representation, whether we store it in a file, communicate it separately, or embed it into a specialized decoder.
We haven’t escaped the limitation. We’ve moved information somewhere else.
The pigeonhole principle
This is an application of the pigeonhole principle: if we place more objects into containers than there are containers available, at least one container must hold multiple objects.
In lossless compression, we cannot allow two distinct inputs to produce an indistinguishable output under the same decoding conditions.
The encoder must be injective. Every valid compressed representation must correspond unambiguously to its original input.
For an input containing bits, there are
possible arrangements.
The total number of binary strings shorter than bits is:
There is always at least one fewer shorter representation than there are original inputs.
It doesn’t matter whether we’re working with three bits or three terabytes. The relationship remains the same.
A lossless compressor cannot make every possible input smaller.
This isn’t an engineering limitation waiting to be solved by a better algorithm. It’s a consequence of the number of representations available.
More computational power cannot create additional distinguishable states within a fixed number of bits (Figure 1).
Fig. 01 / Interactive
Find a place for every input.
Original representations
Shorter representations
It gets considerably worse
The previous example only requires our algorithm to save one bit.
What if we wanted to guarantee that every file could be compressed to half its original size?
For a 16-bit input, we have
possible inputs.
There are only 511 binary strings containing eight bits or fewer, including the empty string.
Even under these generous assumptions, fewer than 0.78 percent of all possible 16-bit inputs could receive a unique representation of eight bits or less.
For larger inputs, that fraction becomes extraordinarily small.
More generally, the fraction of -bit strings that can be shortened by at least bits under a fixed lossless encoding is bounded above by:
This is slightly less than:
The bound doesn’t tell us which files can be compressed. It tells us how many can possibly receive representations of a given length.
| Minimum reduction | Maximum possible fraction of inputs |
|---|---|
| 8 bits | Less than 1 in 128 |
| 16 bits | Less than 1 in 32,768 |
| 32 bits | Less than 1 in 2.15 billion |
| 64 bits | Less than 1 in 9.22 quintillion |
These bounds assume that every original input has the same length and that the decoder can distinguish the complete encoded representations. They are deliberately generous; practical format constraints can reduce the available representations further (Figure 2).
Fig. 02 / Interactive
The shrinking fraction.
Strict upper bound on the eligible fraction:
The implication is fairly remarkable.
Among all possible arrangements of bits in a sufficiently large file, almost none can be substantially compressed by a given lossless compressor.
And yet we compress files successfully every day.
Why?
Most of the information we create isn’t random
Consider these two sequences:
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
Q7M2X9K4P8R1T6W3N5J0V2H7L9C4F8Z1
Both contain 32 characters.
The first sequence can be described relatively easily: the character A, repeated 32 times.
The second sequence doesn’t exhibit an immediately obvious pattern. Describing it may require reproducing the sequence itself.
The important distinction isn’t their length. It’s their structure.
A photograph contains relationships between neighboring pixels. A document contains recurring words, grammatical structures, and predictable combinations of characters. Source code contains repeated identifiers, keywords, indentation patterns, and syntactic conventions.
Even executable binaries contain structure resulting from instruction sets, compiler behavior, data alignment, and repeated operations.
The files we produce occupy a highly nonuniform subset of the possible arrangements of bits.
Compression algorithms exploit that fact.
When we compress a document to a fraction of its original size, we haven’t circumvented the pigeonhole principle. We’ve assigned relatively short representations to inputs that our compression algorithm is designed to recognize as likely or structured.
Other possible inputs receive longer representations.
The trade-off is unavoidable.
The problem with measuring entropy in a file
Consider this sequence:
01010101010101010101010101010101
Half of the bits are zero. Half are one.
If we calculate the entropy using only the frequency of individual symbols, we obtain one bit per symbol.
That is the maximum entropy of a binary alphabet.
Yet the sequence is extremely predictable.
Once we’ve observed a few bits, we can recognize that each zero is followed by a one and each one is followed by a zero.
We could describe the sequence as:
Repeat "01" sixteen times.
A frequency-based entropy calculation misses that relationship entirely.
Now consider an independent fair-coin sequence of the same length. It could also contain 16 zeros and 16 ones and therefore have exactly the same measured symbol frequencies.
The two sequences would receive identical zero-order empirical entropy values despite having very different apparent structures.
The difference is context.
In the alternating sequence, the preceding symbol determines the next symbol under an appropriate model. In an independent random sequence, it doesn’t.
A compressor that only examines the relative frequencies of individual symbols cannot exploit relationships it hasn’t been designed to model (Figure 4).
Fig. 04 / Interactive
Entropy depends on the model.
This is why looking at a file’s byte histogram and declaring that it has reached its theoretical compression limit can be misleading.
It may have reached the limit of a particular model.
That is a very different claim.
What compression algorithms actually do
Compression algorithms differ considerably in their implementations, but many can be understood as different ways of identifying and representing structure.
Run-length encoding identifies repeated values.
Instead of storing:
AAAAAABBBBCCCCCC
we can represent the same structure conceptually as:
6A4B6C
Dictionary-based compression looks for previously encountered sequences and replaces them with references.
For example, repeated phrases within a document may be represented by instructions to reproduce information that has already been decoded.
LZ77, introduced by Abraham Lempel and Jacob Ziv in 1977, established a particularly influential approach to this problem. Its descendants participate in many familiar compression formats and algorithms.
Huffman coding assigns shorter codes to more probable symbols and longer codes to less probable symbols.
Arithmetic coding and related entropy coding techniques represent sequences according to modeled probabilities, allowing encoding efficiency to approach the information-theoretic limits of those models under suitable conditions.
Modern compressors often combine several of these ideas.
A compressor might first identify recurring sequences, transform them into a more convenient representation, model the resulting symbols, and then encode those symbols efficiently.
The details vary, but the underlying problem is consistent.
We want to describe the original information using a representation that costs less than storing it directly.
That representation might contain references, dictionaries, probability tables, instructions, or some combination of them.
The decoder needs enough information to reverse the process.
How small can a particular file become?
The pigeonhole principle establishes that not every file can become smaller. Shannon’s work helps us reason about information produced by a probabilistic source.
Neither directly answers another particularly interesting question.
What is the shortest possible description of this specific file?
Algorithmic information theory provides a framework for considering that question through Kolmogorov complexity.
Informally, the Kolmogorov complexity of an object is the length of the shortest program that produces it when executed on a specified universal computational system.
We can write this as:
Here, is our chosen computational system, is a program, and is the output we’re attempting to reproduce.
Consider a file containing one million zeros.
Rather than storing a million zero bits, we could write a program that outputs a zero one million times.
In Python, a related byte-oriented example would be:
with open("output.bin", "wb") as file:
file.write(b"\x00" * 1_000_000)This program generates one million zero bytes from a relatively short description.
Of course, the program requires a Python interpreter and an environment in which it can execute. We need to specify whether those are already available or whether their size belongs in our accounting.
That’s why the computational system matters.
Now suppose we have a file containing a million bytes that were independently and uniformly sampled from all possible byte values.
A particular realization could contain an exploitable pattern, but most possible files of that length cannot have dramatically shorter descriptions under a fixed decoding system.
The shortest description of a file is a compelling theoretical ideal.
Unfortunately, there is another limitation.
Kolmogorov complexity is uncomputable in general.
We cannot build a universal algorithm that always determines the shortest possible program capable of reconstructing an arbitrary input.
We can discover better descriptions. We can develop improved models, optimize encoders, and find previously unrecognized structure.
But we cannot generally determine that we’ve reached the absolute minimum.
There is no universal progress bar telling us that a file is now 97 percent of the way to its ultimate compression limit.
What if we hide the information somewhere else?
Suppose I develop an extraordinarily effective compression algorithm.
It accepts any file from a predefined collection of one million files and reduces it to a single integer.
I only need approximately 20 bits to identify one of a million possibilities.
The decoder takes that integer, searches the collection, and reconstructs the original file.
Depending on the original file sizes, this could produce impressive compression ratios.
But where did the information actually go?
The decoder already possesses the original collection.
The compressed representation isn’t reconstructing the file independently. It’s identifying information that exists somewhere else.
This isn’t necessarily cheating.
Shared dictionaries, deduplication, content-addressable storage, and delta compression all exploit related concepts to achieve practical savings.
If two systems already possess the same information, there’s little reason to transmit it again.
The problem arises when we compare those results against an algorithm that doesn’t have access to the same information.
Consider two hypothetical systems:
| Component | Conventional compressor | Dictionary-based compressor |
|---|---|---|
| Original input | 100 MB | 100 MB |
| Compressed payload | 40 MB | 10 MB |
| Additional required dictionary | 0 MB | 50 MB |
| Self-contained size | 40 MB | 60 MB |
If we only report payload size, the dictionary-based compressor appears dramatically superior.
If the recipient doesn’t already possess the dictionary, the conventional compressor produces a smaller self-contained representation.
If the recipient does possess it, the dictionary-based compressor may be the more efficient choice.
Both conclusions can be correct.
We simply need to establish what the decoder already knows and which costs are included in the comparison (Figure 5).
Fig. 05 / Interactive
Accounting for shared knowledge.
This becomes especially relevant when evaluating compression systems built around machine learning models.
A model containing gigabytes of parameters could potentially encode certain information into remarkably small representations. But the model, the tokenizer, the decoding implementation, and their compatibility requirements are all part of the system.
Whether their costs should be included or amortized depends on the deployment scenario.
The information didn’t disappear. Some of it was already available.
Why compressed files sometimes become larger
If you’ve ever tried to compress a JPEG photograph, an MP4 video, or another archive, you’ve probably encountered this behavior.
The resulting file is barely smaller than the original.
Sometimes it’s larger.
JPEG and modern video formats already incorporate compression techniques. Their encoded representations often contain less of the particular redundancy a general-purpose archive compressor is designed to exploit.
That doesn’t make every JPEG or video stream mathematically incompressible. There may still be metadata, inefficient encodings, recurring structures, or other opportunities for optimization.
But applying another general-purpose compression algorithm frequently produces diminishing returns.
Encrypted data presents a related problem.
Modern encryption systems are designed so that ciphertext is computationally difficult to distinguish from random-looking data under their security assumptions. A general-purpose compressor usually cannot exploit much useful structure in properly encrypted payloads.
This is one reason compression is commonly performed before encryption.
There is also an unavoidable practical cost associated with the compressed representation itself.
A format may need to include headers, checksums, version information, compression method identifiers, lengths, and other metadata.
For example, a conventional gzip member contains a fixed 10-byte header and an eight-byte trailer, in addition to the compressed DEFLATE stream. Optional fields can introduce additional overhead.
Even if the original file is only one byte long, those structural requirements still exist.
A compression algorithm may represent the actual payload efficiently while producing a larger complete file.
This isn’t necessarily evidence of poor engineering.
Sometimes storing the original information directly is simply the more efficient choice.
An experiment in predictability
We can investigate these behaviors without developing a new compression engine.
The following Python program generates four different kinds of data at several input sizes, compresses each using gzip, and verifies that every compressed representation can be decoded back into its original bytes.
import gzip
import hashlib
import random
SIZES = [
16,
64,
256,
1024,
4096,
16384,
65536,
262144,
1048576,
]
rng = random.Random(1948)
pattern = b"ABCD1234"
text = (
b"Compression exploits structure "
b"in the information we create.\n"
)
def repeat_to_size(value, size):
count = (size + len(value) - 1) // len(value)
return (value * count)[:size]
def samples(size):
return {
"Repeated bytes": b"A" * size,
"Alternating pattern": repeat_to_size(
pattern, size
),
"Repeated text": repeat_to_size(
text, size
),
"Pseudorandom bytes": rng.randbytes(size),
}
print(
"type,input_bytes,compressed_bytes,"
"ratio,savings_percent,sha256"
)
for size in SIZES:
for name, data in samples(size).items():
compressed = gzip.compress(
data,
compresslevel=6,
mtime=0,
)
assert gzip.decompress(compressed) == data
ratio = len(data) / len(compressed)
savings = (
1 - len(compressed) / len(data)
) * 100
digest = hashlib.sha256(data).hexdigest()
print(
f"{name},{len(data)},"
f"{len(compressed)},{ratio:.6f},"
f"{savings:.6f},{digest}"
)The experiment is intentionally simple.
The repeated-byte sample contains very obvious redundancy. The repeating pattern and repeated text provide different structures for the compressor to recognize. The pseudorandom sample provides a contrasting workload.
We can plot complete compressed size against original input size.
For smaller inputs, format overhead may dominate the result. For larger structured inputs, we would expect the benefits of compression to become more apparent.
The pseudorandom sample should generally provide little opportunity for savings through gzip, although that is an expectation to test rather than a result we’re assuming.
There’s also an interesting subtlety in the pseudorandom sample.
Because we generated it using a deterministic algorithm and a known seed, it has a relatively short generative description.
A decoder equipped with that generator could reproduce the data from the seed, generation procedure, and requested length.
Gzip doesn’t know that.
From gzip’s perspective, the data may offer very little exploitable structure. From the perspective of a specialized decoder that understands how it was generated, it could be represented quite compactly.
This brings us back to the distinction between the information itself and the capabilities of the model attempting to describe it.
Failure to compress something doesn’t prove that it has no structure.
It proves that this particular compressor, with its particular representation and available information, didn’t find a sufficiently economical description.
The program above defines a reproducible experiment. Its output has not been presented here as measured benchmark data. Python and zlib versions should be recorded when publishing results. The repeated-text fixture is synthetic and should not be treated as representative of natural-language documents.
Can artificial intelligence change the equation?
Language models have introduced some particularly interesting possibilities for compression.
At a fundamental level, a language model predicts subsequent tokens based on preceding context.
If it can accurately predict what comes next, an entropy coder can potentially represent the actual observations more efficiently.
Suppose a model predicts that a particular symbol has a probability of 90 percent.
The ideal information cost associated with observing that symbol is
bits.
An unexpected symbol would require a larger representation.
The cost across a sequence depends on how accurately the model assigns probabilities to the observations that actually occur.
This relationship between prediction and compression is one reason researchers have investigated neural compression and the connection between intelligence and information theory.
The Hutter Prize, for example, encourages research into increasingly efficient compression of a large text dataset and explicitly connects compression with the development of intelligent systems.
But even an extraordinarily capable language model cannot evade the pigeonhole principle.
It can learn more sophisticated relationships.
It can recognize structures that traditional compressors don’t recognize.
It can use context extending far beyond a conventional dictionary window.
What it cannot do is give every possible input a unique representation smaller than the original.
Improving the model changes which inputs we can encode efficiently.
It doesn’t change the number of representations available.
Artificial intelligence may substantially improve our ability to discover structure, but it doesn’t repeal the mathematics that governs how information is represented.
What this means for compression benchmarks
When we’re evaluating compression algorithms, the input matters as much as the implementation.
An algorithm designed for natural-language text may perform exceptionally well on documents and relatively poorly on executable binaries.
An algorithm optimized for repetitive structured records might produce excellent results on database exports while achieving little improvement on photographic images.
A neural predictor might benefit from information represented in its trained parameters that a traditional dictionary-based compressor doesn’t possess.
Without understanding the distribution and structure of the input, a compression ratio tells us remarkably little about an algorithm’s broader capabilities.
This is particularly relevant to the development of Rind and Peel.
An archive engine encounters a substantially wider variety of information than a compressor evaluated against one carefully selected dataset.
It might process source code, photographs, application bundles, firmware images, compressed media, documents, and encrypted archives within the same workload.
We need to understand which structures an algorithm exploits, where its advantages disappear, how it behaves when compression is ineffective, and what resources it consumes in the process.
That requires more than a single ratio reported against a single corpus.
A useful benchmarking framework should include highly structured data, realistic mixed workloads, previously compressed files, high-entropy inputs, very small files, and larger datasets.
It should account for the complete encoded representation and any additional information required by the decoder.
It should also verify that the original information survives the process.
Otherwise, we’re measuring how effectively information disappears rather than how effectively it’s represented.
The impossible compressor
The original proposition was an algorithm that could guarantee every file would become at least one byte smaller.
We’ve established why that cannot exist.
There aren’t enough shorter representations to uniquely encode every possible input.
What makes compression interesting is everything that happens within that limitation.
We can discover patterns.
We can develop better probability models.
We can exploit relationships between distant pieces of information.
We can take advantage of shared knowledge between an encoder and a decoder.
We can construct descriptions that are substantially smaller than the information they generate.
And we can continue improving those descriptions without generally knowing whether we’ve reached the shortest possible one.
Compression isn’t the process of making information disappear.
It’s the process of finding a more economical way to describe it.
That’s a considerably more interesting engineering problem.
It also explains why the future of compression isn’t necessarily about inventing increasingly elaborate ways to manipulate bits.
It may be about developing increasingly sophisticated ways to understand what those bits represent.
References and further reading
- Claude E. Shannon. A Mathematical Theory of Communication. Bell System Technical Journal, 1948.
- Abraham Lempel and Jacob Ziv. A Universal Algorithm for Sequential Data Compression. IEEE Transactions on Information Theory, 1977.
- David A. Huffman. A Method for the Construction of Minimum-Redundancy Codes. Proceedings of the IRE, 1952.
- Ming Li and Paul Vitányi. An Introduction to Kolmogorov Complexity and Its Applications. Springer.
- RFC 1951 — DEFLATE Compressed Data Format Specification.
- RFC 1952 — GZIP File Format Specification.
- The Hutter Prize — Compression of Human Knowledge.
- Python gzip documentation.
Research disclosure: Mathematical examples are calculated from the stated assumptions. Dictionary comparisons are hypothetical. The included compression experiment is reproducible but has not been executed as part of this article. No empirical performance claims are made about Peel, Rind, or competing compression engines.
