Off-by-One Addition: Variants & Applications
- Off-by-one addition is a counterfactual arithmetic phenomenon characterized by a one-unit or one-position deviation from standard addition, impacting rule induction and generalization.
- It manifests in diverse contexts such as transformer interpretability through function induction, index shifts in image processing, and modular increment in quantum arithmetic with concrete performance implications.
- Methodological insights reveal that small perturbations in carry propagation, alignment, or normalization can lead to significant changes in computational outcomes and error characteristics in both classical and quantum systems.
Off-by-one addition denotes a family of addition-like phenomena in which the operative rule differs from ordinary addition by a one-unit or one-position discrepancy. In the most explicit recent usage, it is a counterfactual task in which examples instantiate ordinary addition followed by an extra , as in $1+1=3$ and $2+2=5$, and it is used to probe task-level generalization in LLMs (Ye et al., 14 Jul 2025). In adjacent literatures, closely related constructions appear as a index displacement in an implementation, a right-shifted addition used to model floating-point alignment, or modular increment-by-one in quantum arithmetic (Lorch, 2023, Kleinekathöfer et al., 2022, Ferraz, 2022). More indirectly, work on digit-vector addition, blockwise carry handling, and aggregation-versus-counting shows that small changes in carry propagation, indexing, or coarse-graining can alter the effective addition rule without altering arithmetic as a formal system (Hellekalek, 2012, Ghosh, 12 Aug 2025).
1. Terminological scope
The expression does not designate a single standardized object across mathematics, computer science, and physics. Instead, the literature uses it either directly for a counterfactual arithmetic rule, or indirectly for structurally similar one-step deviations in indexing, alignment, or representation.
| Sense | Formal object | Representative source |
|---|---|---|
| Counterfactual arithmetic rule | addition followed by | (Ye et al., 14 Jul 2025) |
| Implementation-level index shift | a displacement in extracted indices | (Lorch, 2023) |
| Alignment-sensitive addition | (Kleinekathöfer et al., 2022) | |
| Modular increment | (Ferraz, 2022) |
This multiplicity is important because several nearby papers are highly relevant without using the term itself. The study of digit vectors in fixed base , for example, classifies abelian-group additions on and proves that there are only two types of addition that may be employed—addition with carry and addition without carry—even though there are at least $1+1=3$0 distinct additions arising from compositions of $1+1=3$1 (Hellekalek, 2012). A plausible implication is that off-by-one addition is best understood not as a unique doctrine, but as a recurrent boundary phenomenon at the interface of rule induction, carry propagation, indexing, and representation.
2. Counterfactual arithmetic in transformer interpretability
In mechanistic interpretability, off-by-one addition is a deliberately counterfactual task: the model is shown examples in which the latent rule is not ordinary addition alone, but addition followed by $1+1=3$2. Canonical examples include $1+1=3$3, $1+1=3$4, $1+1=3$5, $1+1=3$6, and the diagnostic pattern $1+1=3$7, $1+1=3$8, $1+1=3$9, for which the intended answer is $2+2=5$0 rather than the arithmetic default $2+2=5$1. The task is therefore two-step and counterfactual: it preserves the familiar syntax of arithmetic while altering the semantic rule applied at the output (Ye et al., 14 Jul 2025).
Empirically, six recent LLMs were tested, and all showed nontrivial performance on off-by-one addition, with accuracy improving as more in-context examples were provided. The interpretability analysis used path patching with a base prompt $2+2=5$2 for standard addition and a contrast prompt $2+2=5$3 for off-by-one addition. Using Gemma-2 (9B) as the main case study, the paper identified three groups of attention heads: consolidation heads in later layers that aggregate the final answer, function induction (FI) heads that write the $2+2=5$4 function into the residual stream, and previous token (PT) heads that store a discrepancy signal by attending from the answer token back to the preceding “=” token in earlier examples. The reported Gemma-2 groups were consolidation heads H41.4, H41.5, H40.11, H40.12; FI heads H39.7, H39.12, H36.7, H32.1, H32.6, H25.13; and PT heads H38.6, H38.7, H38.9, H35.14, H35.9, H31.4, H31.5, H29.5 (Ye et al., 14 Jul 2025).
The central mechanistic claim is that the model implements a reusable function induction mechanism that generalizes the classic induction-head story from token continuation to abstract task transformation. In the proposed account, early layers first draft the ordinary answer inside an example such as $2+2=5$5; the actual observed output then creates a local discrepancy; PT heads register that discrepancy; FI heads retrieve and write the induced $2+2=5$6 transformation into the test context; and consolidation heads synthesize the result into the final output distribution. Ablation evidence is strong: when the six FI heads were replaced with their outputs from the standard-addition prompt, off-by-one accuracy collapsed to $2+2=5$7 while standard addition accuracy rose to $2+2=5$8. The same mechanism was then probed in off-by-$2+2=5$9 addition, shifted multiple-choice QA, Caesar cipher, and base-0 addition, where FI-head ablation pushed performance back toward the base-task behavior. The paper also reports that the function is not localized in a single head: distinct heads promote 1, suppress 2, promote numbers greater than 3, or suppress 4 itself, so the induced transformation is distributed across multiple heads in parallel (Ye et al., 14 Jul 2025).
A common misconception is that this line of work claims that transformers have learned arithmetic incorrectly. The paper does not make that claim. Rather, it shows that models can infer and apply a counterfactual rule supplied in context, and that the same reusable circuitry that enables useful task induction can also propagate false or unusual premises (Ye et al., 14 Jul 2025).
3. Off-by-one as an implementation-level index shift
A distinct usage appears in implementation analysis, where the off-by-one phenomenon is not a modified arithmetic law but a 5 displacement in array indexing. In J-UNIWARD steganography, the cost of changing one JPEG DCT coefficient is computed from a 6 neighborhood in the wavelet residual. The size 7 arises because an 8 affected spatial block is combined with a 9 wavelet kernel, giving 0. The implementation precomputes the numerator contribution for each coefficient position and extracts a 1 denominator window from the precomputed wavelet residual (Lorch, 2023).
The identified bug is exact: the correct denominator window for the paper’s 0-based example is 2, but the original Matlab and C++ implementations extracted 3. The window was therefore shifted one pixel to the bottom right. The corrected Matlab pattern changes
$1+1=3$43
to
$1+1=3$44
and the corresponding C++ code changes -6 to -7 in both starting indices (Lorch, 2023).
The consequence is a localized mispricing of coefficients. Some blocks are under-priced and others over-priced; the effect is strongest near transitions between smooth and textured regions, with smooth 4 textured transitions tending to be under-priced and textured 5 smooth transitions tending to be over-priced. For a sample cover image, block costs range roughly from 6 to 7, while the difference between original and fixed costmaps is less than 8. In a learning-based steganalysis experiment, an EfficientNet-B0 trained at JPEG quality 9 and 0 bpnzAC achieved test accuracy 1 on stego images generated with the original implementation and 2 on the fixed implementation; similar behavior was reported at JPEG qualities 3 and 4 (Lorch, 2023).
This suggests a useful distinction: off-by-one addition in practice often means that a one-step indexing displacement has entered an addition-adjacent computational pipeline, not that the arithmetic operation itself has been redefined.
4. Shifted addition and alignment-sensitive carry structure
In formal verification and decision-diagram complexity, the relevant object is shifted addition,
5
where 6 and 7 are 8-bit operands, 9 is an 0-bit shift amount, and 1 denotes right shift by 2 bit positions. The notation 3 denotes the 4-th output bit of the 5-bit shifted addition. The construction is motivated by floating-point addition, where one compares exponents, shifts the smaller significand right by the exponent difference, and then adds the aligned significands (Kleinekathöfer et al., 2022).
The essential off-by-one feature here is alignment sensitivity. A small change in exponent difference causes a one-bit change in which bits of 6 interact with which bits of 7. Because carries propagate through those aligned positions, the Boolean structure of the output is highly sensitive to the shift amount. The paper formalizes this via reduced ordered binary decision diagrams and proves an exponential lower bound for representing the most significant output bit 8 (Kleinekathöfer et al., 2022).
The proof uses fooling sets over balanced variable partitions. For each partition 9, the authors define aligned bit pairs under a fixed shift 0,
1
and the subset split by the partition,
2
A counting argument shows that some shift 3 satisfies 4. Fixing all nonessential bits then yields a fooling set of size at least 5 for 6. By the paper’s general lemma, every BDD representing the function therefore has exponential size in 7 (Kleinekathöfer et al., 2022).
The practical interpretation is that shifted addition is not merely addition plus a trivial alignment pre-processing step. The alignment itself induces a combinatorial dependency pattern that is difficult to compress. This explains why verification of floating-point adders often requires special handling such as case splitting, and why the one-position shift is not a negligible perturbation of ordinary addition (Kleinekathöfer et al., 2022).
5. Increment-by-one and one-bit addition in quantum computing
In quantum arithmetic, off-by-one addition appears most naturally as increment-by-one, the special case 8 of register-by-constant modular addition. A QFT-based constant adder applies the quantum Fourier transform to a target register, multiplies Fourier components by phases encoding the constant, and then applies the inverse QFT. For an 9-qubit register, the Fourier-basis constant-adder is
0
and the full adder is
1
For 2, this yields
3
Operationally, the circuit consists of 4 on the target register, one 5 gate per qubit with angles determined by 6, and 7 on the same register. The practical gain over Draper’s register-by-register adder is that constant addition uses only the target register, no second operand register, no carry ancilla, and exactly 8 single-qubit 9 rotations in the middle layer. Counting QFT and IQFT as 0 each, the total is 1 (Ferraz, 2022).
A different quantum use of addition appears in fault-tolerant one-bit addition. On the Quantinuum H1-1 quantum computer, one-bit addition was implemented with the 2 colour code via the reversible map
3
where 4 is stored in binary on the last two wires. The logical circuit uses a Hadamard-conjugated 5,
6
together with optimized encoded-state preparation, a logical CNOT by permutation, and tailored destructive measurements. By removing unnecessary error-correction circuits, the implementation reduced the number of error-prone two-qubit gates and measurements to 7. The observed arithmetic error rates were 8 for the fault-tolerant device and 9 for the unencoded device, with a post-selection acceptance overhead of about $1+1=3$00 (Wang et al., 2023).
These results indicate that increment-by-one and small-width addition are not trivial subroutines. Even the apparently minimal $1+1=3$01 case exposes deep issues in phase encoding, modular wraparound, reversibility, and fault tolerance.
6. Carry structure, block structure, and nonstandard numeration
A mathematically adjacent literature studies how many addition laws are possible once addition is regarded as structure on digit strings rather than as a fixed schoolbook algorithm. For digit vectors of length $1+1=3$02, the set
$1+1=3$03
admits abelian-group additions of two basic types only: addition without carry and addition with carry. In the binary case, addition without carry is coordinatewise XOR,
$1+1=3$04
while addition with carry is ordinary integer addition modulo $1+1=3$05,
$1+1=3$06
Despite there being only these two types, compositions $1+1=3$07 generate at least $1+1=3$08 different additions, because the number of compositions is $1+1=3$09. With automorphisms of residue groups allowed, the count becomes $1+1=3$10 for prime base $1+1=3$11, which gives $1+1=3$12 for $1+1=3$13 (Hellekalek, 2012).
The paper on digit vectors does not use the term off-by-one addition, and that omission matters. Its relevance is conceptual rather than terminological: carry propagation introduces interaction between neighboring digit positions, whereas no-carry addition is strictly local. A plausible implication is that many off-by-one effects can be seen as boundary cases in how local digit rules are extended across positions (Hellekalek, 2012).
An analogous theme appears in parallel addition for non-standard numeration systems. A map is $1+1=3$14-local if each output digit depends only on a fixed window of nearby input digits, so carries do not propagate indefinitely. In this framework, 1-block parallel addition is the classical single-digit setting, while $1+1=3$15-block parallel addition groups digits into fixed-length blocks. For $1+1=3$16-bonacci bases, if 1-block parallel addition is possible on an alphabet $1+1=3$17, then $1+1=3$18; however, there exists a $1+1=3$19 such that $1+1=3$20-block parallel addition is possible on $1+1=3$21, and in particular addition in the Tribonacci base is $1+1=3$22-block parallel on alphabet $1+1=3$23 (Frougny et al., 2013).
A further representation-theoretic example is the Fibonacci analogue of two’s complement numeration. For a binary word $1+1=3$24, the value map is
$1+1=3$25
with $1+1=3$26, $1+1=3$27, and $1+1=3$28. The system has neutral prefixes,
$1+1=3$29
and addition is performed by padding, digitwise ternary summation, and normalization via a deterministic finite-state transducer $1+1=3$30 derived from the Berstel adder (Labbé et al., 2022). This shows that what appears to be a one-step anomaly in signed representation can sometimes be absorbed into a regular local normalization rule.
7. Aggregation, counting, and conceptual boundaries
A final, more conceptual strand concerns the relation between addition, identity, and counting. In the multiset formalism $1+1=3$31, aggregation of individuals is represented by pointwise addition of multiplicities,
$1+1=3$32
so for distinct $1+1=3$33, the aggregate $1+1=3$34 literally encodes two ones with individuality preserved. Ordinary counting is then expressed not simply by the size map $1+1=3$35, but by the composition
$1+1=3$36
where $1+1=3$37 is a classification map and
$1+1=3$38
Because $1+1=3$39 may be non-injective, different individual-level aggregates can collapse to the same typed bag (Ghosh, 12 Aug 2025).
The paper states that this non-injectivity is the exact locus of information loss and identifies it as the mathematical place where a potential off-by-one-like mistake can enter. The count may be correct relative to the chosen classification while misdescribing what is being counted at the identity-preserving level. This is sharpened by the Non-Identity Addition Theorem,
$1+1=3$40
which says that a composite of two distinct physical objects cannot be physically identical to a doubled copy unless the originals were already physically identical to that same object. The numeral $1+1=3$41 therefore appears only as the readout of a typed count observable after explicit classification, not as a statement of physical identity (Ghosh, 12 Aug 2025).
This resolves a common confusion around off-by-one language. The issue is usually not that arithmetic in $1+1=3$42 has failed. Rather, the rule, index origin, shift amount, carry convention, or equivalence relation has changed. Off-by-one addition is therefore best regarded as a boundary concept: it marks the point at which a one-step perturbation in representation or interpretation becomes mathematically or computationally substantive.