Binary addition in logarithmic space 2026-10-31
For canonical positive binary numeral system inputs, a logspace transducer can emit the canonical representation of their sum most significant digit first. Count the operand lengths, compute the final arithmetic carry to determine output length, and then compute each requested result digit by restarting the least-significant-first column recurrence. Each pass uses only a fixed number of -bit indices and one arithmetic carry. The binary-addition carry invariant proves correctness. Logspace composition by recomputation consequently permits any L property of the resulting digit string, including being a binary palindrome, to be tested without storing the sum.
Logspace-computable function 2026-10-31
A total function computed by a halting logspace transducer. Its output may be much longer than its work tapes. Logspace-computable functions compose using logspace composition by recomputation.
A logspace transducer is a deterministic Turing machine with a read-only input tape, read-write work space, and a write-only output tape. It emits symbols successively and cannot reread the output; that output is not charged as working memory. For a total function it must halt on every input. A logspace-computable function is a total function whose output is produced by such a logspace transducer on input .
A logspace many-one reduction is a logspace-computable function such thatfor every string . The logarithmic space bound permits a polynomial-length output, even when that output does not fit in work space. Indeed, a halting logspace transducer cannot repeat its state, input-head position and work-tape contents and head positions: the unreadable output cannot affect its subsequent behaviour. There are only a polynomial number of such internal Turing machine configurations, hence a polynomial bound on the number of steps and output symbols.
To prove a formal language is NL-complete, first give an NL acceptance procedure for . Then show every has a logspace many-one reduction to . Alternatively, reduce one already NL-complete formal language to , using transitivity of logspace many-one reductions.
Transitivity requires logspace composition by recomputation, rather than storing the intermediate output. To compose with , simulate the logspace transducer for with a virtual input . Retain its virtual input-head position in bits. Whenever it asks for a symbol, rerun the logspace transducer for from the beginning and count its output symbols until that position is reached. Since is polynomial in , the simulated work space and all output-position counters are . Repeated runs reuse their storage. This proves closure under composition and explains why the hardness argument works.
The binary numeral system representation is taken to be canonical, with no leading zeroes, for each positive integer. Delimiters separate the components of a pair or triple. Syntax, positivity and this representation convention can all be checked in logarithmic space. The useful principle is that a large integer need not be stored in order to compute its digits one at a time.
First consider Add. Let denote the binary digits in position , counting from the least significant position and taking out-of-range digits to be zero. Count the component lengths, and let be their maximum. Start with arithmetic carry . For , computeReject if at any position. After the last position, reject if ; otherwise accept. The final arithmetic carry check prevents accepting a result with an omitted high digit, such as the false equality obtained by retaining only two binary digits.
The binary-addition carry invariant isIt holds initially and is preserved by the displayed one-column equations. At the end, it proves that the comparisons and the final arithmetic carry check succeed exactly when . Each requested binary digit is recovered by scanning the corresponding input field and counting to its position. The length counters, position and scan counters require bits, while and require constant space. ThusFor Pal-Add, construct a logspace transducer producing the canonical binary numeral system representation of . Put . One least-to-most-significant pass using the same recurrence determines the final arithmetic carry . Positivity and canonical representations imply that the sum's digit length isIndeed, one summand is at least and both are less than . For each output position, from down to , recompute the required sum digit from scratch: reset the arithmetic carry to zero and run the column recurrence from position up to the requested position, reading input digits by scans. Positions beyond the summands use zero digits, so position correctly emits the possible final arithmetic carry. Emit only the requested digit, then reuse the work space for the next position.
This produces most-significant-first output with digits. It uses work space because it retains only a fixed number of digit indices, lengths, scan counters and one arithmetic carry; it never stores the whole sum. A direct implementation with repeated whole-input scans uses at most time complexity, which is sufficient here. Hence is a logspace-computable function.
Finally simulate the assumed L decider for binary palindrome on this virtual output, using logspace composition by recomputation from part (b). Whenever the simulated input head asks for a digit, rerun the addition logspace transducer until it emits that digit. The virtual input length is , so both its work space and the addition work space are . The simulation accepts exactly when the canonical representation of is a binary palindrome. ThereforeEquivalently, one could directly compare the sum digits in positions and , recomputing each digit by the same recurrence. This gives the same logarithmic space conclusion without ever writing the full sum on a work tape.