Documentation

Complexitylib.Models.TuringMachine.Subroutines.BinaryAddConst

Addition of a fixed natural to a canonical binary tape #

This module exposes the literal-frame and resource contracts for a finite sequence of binary successors compiled from a hardwired natural constant.

Main results #

theorem Complexity.TM.binaryAddConstTM_reachesIn_frame {n : } (idx : Fin n) (constant dstValue : ) (inp₀ : Tape) (work₀ : Fin nTape) (out₀ : Tape) (hdst : (work₀ idx).HasBinaryNat dstValue) (hinp : Parked inp₀) (hother : ∀ (i : Fin n), i idxParked (work₀ i)) (hout : Parked out₀) :
(binaryAddConstTM idx constant).reachesIn (binaryAddConstTime constant dstValue) { state := (binaryAddConstTM idx constant).qstart, input := inp₀, work := work₀, output := out₀ } { state := (binaryAddConstTM idx constant).qhalt, input := inp₀, work := Function.update work₀ idx ((Tape.init (List.map Γ.ofBool (dstValue + constant).bits)).move Dir3.right), output := out₀ }

Fixed-constant addition has the advertised exact runtime and changes only the destination tape.

theorem Complexity.TM.binaryAddConstTM_hoareTime_frame {n : } (idx : Fin n) (constant dstValue : ) (inp₀ : Tape) (work₀ : Fin nTape) (out₀ : Tape) (hdst : (work₀ idx).HasBinaryNat dstValue) (hinp : Parked inp₀) (hother : ∀ (i : Fin n), i idxParked (work₀ i)) (hout : Parked out₀) :
(binaryAddConstTM idx constant).HoareTime (fun (inp : Tape) (work : Fin nTape) (out : Tape) => inp = inp₀ work = work₀ out = out₀) (fun (inp : Tape) (work : Fin nTape) (out : Tape) => inp = inp₀ work = Function.update work₀ idx ((Tape.init (List.map Γ.ofBool (dstValue + constant).bits)).move Dir3.right) out = out₀) (binaryAddConstTime constant dstValue)

Time-bounded literal-frame contract for fixed-constant addition.

theorem Complexity.TM.binaryAddConstTM_hoareTimeSpace_frame {n : } (idx : Fin n) (constant dstValue inputLength initialSpace : ) (inp₀ : Tape) (work₀ : Fin nTape) (out₀ : Tape) (hdst : (work₀ idx).HasBinaryNat dstValue) (hinp : Parked inp₀) (hother : ∀ (i : Fin n), i idxParked (work₀ i)) (hout : Parked out₀) (hworkSpace : ∀ (i : Fin n), (work₀ i).head initialSpace) (hinputSpace : inp₀.head inputLength + initialSpace + 1) :
(binaryAddConstTM idx constant).HoareTimeSpace (fun (inp : Tape) (work : Fin nTape) (out : Tape) => inp = inp₀ work = work₀ out = out₀) (fun (inp : Tape) (work : Fin nTape) (out : Tape) => inp = inp₀ work = Function.update work₀ idx ((Tape.init (List.map Γ.ofBool (dstValue + constant).bits)).move Dir3.right) out = out₀) (binaryAddConstTime constant dstValue) inputLength (binaryAddConstSpace initialSpace constant dstValue)

Every prefix of fixed-constant addition respects a bound controlled by the final destination width.

theorem Complexity.TM.binaryAddConstTM_isTransducer {n : } (idx : Fin n) (constant : ) :

Fixed-constant addition never moves its output head left.