Linear-time canonical binary subtraction -- definitions #
This module defines a full-borrow scan over two preserved little-endian binary work tapes. The scan writes a fixed-width difference to a fresh result tape. A single backward pass then erases the complete result on underflow or removes only its redundant high zeros, while returning the result head to cell one.
The low output bit of one binary-subtraction column.
Equations
- Complexity.BinaryRippleSub.diffBit borrow lhs rhs = (lhs ^^ rhs ^^ borrow)
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Scan two little-endian bit strings with an incoming borrow. A missing side is padded by zero; the final borrow is retained separately from the raw bits.
Equations
Instances For
Forward-borrow states, backward cleanup states, and the unique halt state.
- scan (borrow : Bool) : BinaryRippleSubPhase
- erase : BinaryRippleSubPhase
- trim (seenOne : Bool) : BinaryRippleSubPhase
- done : BinaryRippleSubPhase
Instances For
Equations
- One or more equations did not get rendered due to their size.
- Complexity.TM.instDecidableEqBinaryRippleSubPhase.decEq (Complexity.TM.BinaryRippleSubPhase.scan a) (Complexity.TM.BinaryRippleSubPhase.scan b) = if h : a = b then h ▸ isTrue ⋯ else isFalse ⋯
- Complexity.TM.instDecidableEqBinaryRippleSubPhase.decEq (Complexity.TM.BinaryRippleSubPhase.scan borrow) Complexity.TM.BinaryRippleSubPhase.erase = isFalse ⋯
- Complexity.TM.instDecidableEqBinaryRippleSubPhase.decEq (Complexity.TM.BinaryRippleSubPhase.scan borrow) (Complexity.TM.BinaryRippleSubPhase.trim seenOne) = isFalse ⋯
- Complexity.TM.instDecidableEqBinaryRippleSubPhase.decEq (Complexity.TM.BinaryRippleSubPhase.scan borrow) Complexity.TM.BinaryRippleSubPhase.done = isFalse ⋯
- Complexity.TM.instDecidableEqBinaryRippleSubPhase.decEq Complexity.TM.BinaryRippleSubPhase.erase (Complexity.TM.BinaryRippleSubPhase.scan borrow) = isFalse ⋯
- Complexity.TM.instDecidableEqBinaryRippleSubPhase.decEq Complexity.TM.BinaryRippleSubPhase.erase Complexity.TM.BinaryRippleSubPhase.erase = isTrue ⋯
- Complexity.TM.instDecidableEqBinaryRippleSubPhase.decEq Complexity.TM.BinaryRippleSubPhase.erase (Complexity.TM.BinaryRippleSubPhase.trim seenOne) = isFalse ⋯
- Complexity.TM.instDecidableEqBinaryRippleSubPhase.decEq (Complexity.TM.BinaryRippleSubPhase.trim seenOne) (Complexity.TM.BinaryRippleSubPhase.scan borrow) = isFalse ⋯
- Complexity.TM.instDecidableEqBinaryRippleSubPhase.decEq (Complexity.TM.BinaryRippleSubPhase.trim seenOne) Complexity.TM.BinaryRippleSubPhase.erase = isFalse ⋯
- Complexity.TM.instDecidableEqBinaryRippleSubPhase.decEq (Complexity.TM.BinaryRippleSubPhase.trim a) (Complexity.TM.BinaryRippleSubPhase.trim b) = if h : a = b then h ▸ isTrue ⋯ else isFalse ⋯
- Complexity.TM.instDecidableEqBinaryRippleSubPhase.decEq (Complexity.TM.BinaryRippleSubPhase.trim seenOne) Complexity.TM.BinaryRippleSubPhase.done = isFalse ⋯
- Complexity.TM.instDecidableEqBinaryRippleSubPhase.decEq Complexity.TM.BinaryRippleSubPhase.done (Complexity.TM.BinaryRippleSubPhase.scan borrow) = isFalse ⋯
- Complexity.TM.instDecidableEqBinaryRippleSubPhase.decEq Complexity.TM.BinaryRippleSubPhase.done (Complexity.TM.BinaryRippleSubPhase.trim seenOne) = isFalse ⋯
- Complexity.TM.instDecidableEqBinaryRippleSubPhase.decEq Complexity.TM.BinaryRippleSubPhase.done Complexity.TM.BinaryRippleSubPhase.done = isTrue ⋯
Instances For
BinaryRippleSubPhase is finite, as required by the concrete TM model.
Equations
- One or more equations did not get rendered due to their size.
Scan two canonical operands, write their fixed-width raw difference, and canonicalize the result while moving backward. A final borrow erases the whole result; otherwise high zeros are erased until the first high one is seen.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Canonical subtraction followed by rewinds of the two preserved operands.
Equations
- One or more equations did not get rendered due to their size.