Linear-time canonical binary addition -- definitions #
This module defines a finite-state ripple-carry scan over two preserved little-endian binary work tapes. Each scan step appends one sum bit to a fresh result tape. A composed wrapper then rewinds all three owned tapes.
The output bit of a one-column binary addition with incoming carry.
Equations
- Complexity.BinaryRippleAdd.sumBit carry lhs rhs = (lhs ^^ rhs ^^ carry)
Instances For
Ripple-carry addition on little-endian bit strings, padding a missing side with zero and emitting a final high bit exactly when the carry remains set.
Equations
Instances For
Carry-bearing scan states followed by the unique halt state.
- scan (carry : Bool) : BinaryRippleAddPhase
- done : BinaryRippleAddPhase
Instances For
Equations
- Complexity.TM.instDecidableEqBinaryRippleAddPhase.decEq (Complexity.TM.BinaryRippleAddPhase.scan a) (Complexity.TM.BinaryRippleAddPhase.scan b) = if h : a = b then h ▸ isTrue ⋯ else isFalse ⋯
- Complexity.TM.instDecidableEqBinaryRippleAddPhase.decEq (Complexity.TM.BinaryRippleAddPhase.scan carry) Complexity.TM.BinaryRippleAddPhase.done = isFalse ⋯
- Complexity.TM.instDecidableEqBinaryRippleAddPhase.decEq Complexity.TM.BinaryRippleAddPhase.done (Complexity.TM.BinaryRippleAddPhase.scan carry) = isFalse ⋯
- Complexity.TM.instDecidableEqBinaryRippleAddPhase.decEq Complexity.TM.BinaryRippleAddPhase.done Complexity.TM.BinaryRippleAddPhase.done = isTrue ⋯
Instances For
BinaryRippleAddPhase is finite, as required by the concrete machine model.
Equations
- One or more equations did not get rendered due to their size.
Scan two canonical little-endian operands and append their sum to a fresh result tape. Operand cells are written back unchanged. An exhausted operand stays on its first blank while the longer operand continues to advance.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Scan the operands into a fresh result and then rewind both operands and the result to cell one.
Equations
- One or more equations did not get rendered due to their size.