Constant-weight code¶
A binary codebook whose equal-length words all contain the same fixed number of 1s, with error behavior depending on the selected words.
Core Idea¶
A binary constant-weight code is a selected set of equal-length binary words in which every word has the same number of 1 positions. For words of length n and weight m, there are n choose m eligible patterns, but the codebook C may select all of them or only a subset. That common-weight rule, together with the chosen set of valid words, identifies the code; a barcode or electronic circuit is one way to use it.[^ref-de576e1c83eb]
A one-coordinate bit flip changes the weight, so a correct weight check can reject it. Exchanging one active and one inactive position preserves weight; whether the result is another valid word depends on membership in C. A weight check alone therefore does not guarantee detection of every corruption, and the abstract codebook does not specify which checks a receiver performs.[^ref-de576e1c83eb]
Scope of Application¶
The rule applies when a carrier can be mapped to ordered binary positions and the selected valid words all have one length and weight. Matrix 2 of 5 uses five ordered bar-and-space elements per digit character, with two wide elements. Its quiet zones, start and stop characters, and optional check digit belong to the whole barcode, outside the digit word.[^ref-47a29de6fc4f]
In asynchronous interconnect, selected m-of-n patterns can use asserted rails as 1 positions. The Manchester study analyzes full and incomplete selected rail codebooks and their completion circuits. POSTNET has another digit-level realization with two tall and three short bars per digit.[ref-d80d3583a9c3][ref-c9c101af52bb]
Clarity¶
Separate eligible patterns from selected codewords. The binomial number n choose m counts every length-n, weight-m word; |C| counts the valid words actually chosen. These quantities coincide only for a complete codebook. Before making an error claim, ask whether a receiver checks weight, checks membership in C, or applies an additional format-level checksum.[^ref-de576e1c83eb]
“Two of five” can name the formal count or a particular barcode format. The formal type fixes a word boundary, binary mapping, common weight, and selected codebook. It does not fix printing, scanning, framing, or a self-timed rail handshake.[ref-47a29de6fc4f][ref-d80d3583a9c3]
Manages Complexity¶
Three questions let unlike implementations be compared: where does one codeword begin and end, what physical states map to ordered bits, and which eligible words are actually selected? These questions describe both width-coded barcode digits and asserted-rail groups without importing one system's apparatus into the other.[ref-47a29de6fc4f][ref-d80d3583a9c3]
After that shared test, inspect use-specific details separately: codebook size and distance for code design, barcode framing and check digits, or rail completion and acknowledgment circuitry. Those details determine practical performance but do not redefine the common-weight codebook.[ref-de576e1c83eb][ref-47a29de6fc4f][^ref-d80d3583a9c3]
Abstract Reasoning¶
For specified n and m, check that every member of C has weight m, then compare |C| with the ceiling n choose m. When C has at least two words, pairwise Hamming distances help show which corruptions can change one valid word into another. A singleton still meets the fixed-weight rule, although its pairwise minimum distance is undefined under this convention.[^ref-de576e1c83eb]
For example, 1100 and 1010 are both length-four, weight-two words. A one-for-one exchange can turn one into the other if both are selected. In the restricted codebook {1100, 0011}, the same exchange from 1100 to 1010 leaves the selected set even though weight remains two. The contrast follows from word weight and membership, not from a promise that every receiver checks both.[^ref-de576e1c83eb]
Knowledge Transfer¶
The fixed-weight membership test transfers among barcode digit widths, postal bar heights, and asserted-wire groups when each carrier has an explicit binary mapping. A single fixed-length bit flip leaves the eligible weight class, but application behavior also depends on the selected set and receiver checks.[ref-47a29de6fc4f][ref-c9c101af52bb][^ref-d80d3583a9c3]
The codebook is a specialized Set and Membership object: it is a selected collection of distinct words with bivalent membership. Its hard weight equality is an internal Constraint. Encoding and Decoding becomes relevant when a use adds a source-symbol assignment and paired encoder and decoder; that process is not part of a bare codebook.
Example¶
Matrix 2 of 5 digit character: one decimal digit has five ordered width-coded elements; mapping wide to 1 gives weight two. The chosen digit patterns are the codebook. The barcode's start, stop, quiet zones, and optional check digit surround these digit words and should not be counted as positions in one digit.[^ref-47a29de6fc4f]
Asynchronous m-of-n rail group: the ordered positions are rails, asserted rails map to 1, and valid groups have weight m. Full and incomplete chosen codebooks appear in the Manchester study. A completion detector belongs to the surrounding communication protocol, not to the mathematical codebook's identity.[^ref-d80d3583a9c3]
Relationships to Other Abstractions¶
Current abstraction Constant-weight code Domain-specific
Parents (2) — more general patterns this builds on
-
Constant-weight code is a kind of Set and Membership Prime
A constant-weight codebook is a set of selected binary words with bivalent membership, specialized by equal length and one common Hamming weight.
-
Constant-weight code is part of Constraint Prime
The hard equality wt(x)=m and its eligible word space are an internal, identity-bearing admissibility constituent of a constant-weight codebook.
Hierarchy paths (2) — routes to 2 parentless roots
- Constant-weight code → Set and Membership
- Constant-weight code → Constraint
Neighborhood in Abstraction Space¶
Constant-weight code sits in a sparse region of the domain-specific corpus (88th percentile for distinctiveness): few abstractions share its structure, so a faithful description tends to retrieve it precisely.
Family — Unclustered & Miscellaneous (2721 abstractions)
Nearest neighbors
- Even code — 0.82
- Locally catenative sequence — 0.81
- Gray Code — 0.80
- Repetition Code — 0.80
- Hypercube Graph — 0.79
Computed from structural-signature embeddings · 2026-10-17
Not to Be Confused With¶
- Matrix 2 of 5 as a whole symbol: its digit characters instantiate the rule, while framing and an optional check digit add format-specific structure.[^ref-47a29de6fc4f]
- The full m-of-n set: this is one special case; a proper selected subset can have different size and error behavior.[ref-de576e1c83eb][ref-d80d3583a9c3]
- Any error-correcting code: correction requires further error-model and decoding claims; its words need not all share one weight.
- Any delay-insensitive code: inspect its valid words before claiming a common weight, and keep completion behavior at the protocol level.[^ref-d80d3583a9c3]
References¶
[^ref-de576e1c83eb]: Smith, Derek H., and Roberto Montemanni. “Some constant weight codes from primitive permutation groups”. The Electronic Journal of Combinatorics 19(4), P4 (2012), doi:10.37236/2702. Full paper consulted; §1 defines binary constant-weight codes, Hamming weight and distance, and maximum-size notation. [^ref-47a29de6fc4f]: Seagull Software, LLC. “Matrix 2 of 5”. Barcode Guide. Lines 37-63 identify five ordered elements per digit, two wide, framing, supported digits, and optional check digit. [^ref-d80d3583a9c3]: Bainbridge, W. J., W. B. Toms, D. A. Edwards, and S. B. Furber. “Delay-insensitive, point-to-point interconnect using m-of-n codes”. Proceedings of the Ninth International Symposium on Asynchronous Circuits and Systems (2003), printed pp. 230-238. Full paper consulted; §§2-8 cover self-timed grouping, full and incomplete m-of-n codes, completion detection, and implementation trade-offs. [^ref-c9c101af52bb]: United States Postal Service. “Confirm Service, Product Technology, Barcoding”. Postal Bulletin 22083 (2002), lines 203-213. Documents two tall and three short bars per POSTNET digit.