A probability-shaped prefix codeComplete codeword-pair check + exact rational average
The problem
Check binary prefix-freeness and compute exact mean codeword length.
The checked result
Prefix free: yes; Expected bits per symbol: 7/4.
The pairwise check reveals every possible prefix collision. Expected length is an exact fraction, avoiding rounding in the acceptance artifact.
Why the checker accepts it
- Require one binary codeword for every declared symbol.
- Check every ordered pair for the prefix relation.
- Verify symbol probabilities form an exact rational distribution.
- Compute the average code length using rational arithmetic.
Formal specification
{
"probabilities": {
"A": "1/2",
"B": "1/4",
"C": "1/8",
"D": "1/8"
}
}Claim and evidence
{
"claim": {
"prefix_free": true,
"expected_bits": "7/4"
},
"witness": {
"codes": {
"A": "0",
"B": "10",
"C": "110",
"D": "111"
}
}
}Dataset construction
Deterministic finite fixture; full enumeration or witness replay as stated. Structured JSON; field meanings are stated in the specification. Acceptance covers 12 checker units for this record; the unit type is stated in its verification scope.
Complexity and limits
With n symbols and maximum code length L, naive pairwise prefix checking is O(n²L).
No entropy estimate or code optimality claim is made. A rejected prefix code is retained as an instructive checked negative result.
A boundary to investigate
Short-looking codewords can be ambiguous; a prefix check does not establish minimum expected length. Add Huffman construction traces, lossless round trips, and exact small-tree optimality certificates.