Correctness and exact running time of unary halving
ProvedTensorUnaryHalf.halfProg_execcomplexity-theorycomputation
For every natural number , the fixed three-stack halving program consumes a unary counter of length , prepends unary symbols to the quotient stack, and prepends one marker to the parity stack exactly when is odd. Both original stack tails are preserved, and execution takes exactly steps. This is a building block for converting unary magnitudes to binary encodings.
Preamble
import Definitions.Def_TensorUnaryHalf open CookPvsNP ProjSchedTW.Complexity
Formal statement
theorem TensorUnaryHalf.halfProg_exec (n : ℕ) (quotientTail parityTail : List BSym) :
TensorUnaryHalf.halfProg.Exec
(TensorUnaryHalf.store (List.replicate n .one) quotientTail parityTail)
(TensorUnaryHalf.store [] (List.replicate (n/2) .one ++ quotientTail)
((if n % 2 = 0 then [] else [.one]) ++ parityTail))
(6*((n+1)/2)+1) := by
sorry