Exact stack execution of binary-adder normalization
ProvedTwoAgentSched.TotalTotal.BinaryAdder.Normalizer.normalizeOutput_execcomplexity-theorycomputation
For arbitrary output and carry-history stacks, the fixed normalizer removes the maximal leading zero prefix of the output, reverses the remaining symbols onto the first stack, clears the output and carry history, and resets the carry to zero. Its exact cost is three times the length of each of the discarded prefix, remaining output and carry history, plus seven structured-program steps.
Preamble
import Definitions.Def_TwoAgentSched_TotalTotal_BinaryAdderNormalizer open CookPvsNP ProjSchedTW.Complexity TwoAgentSched.TotalTotal.BinaryAdder
Formal statement
namespace TwoAgentSched.TotalTotal.BinaryAdder.Normalizer
theorem normalizeOutput_exec (output carries : List BSym) :
normalizeOutput.Exec (store [] [] output carries)
(store (output.dropWhile (fun x => x == BSym.zero)).reverse [] [] [.zero])
(3 * (output.takeWhile (fun x => x == BSym.zero)).length +
3 * (output.dropWhile (fun x => x == BSym.zero)).length + 3 * carries.length + 7) := by
sorry
end TwoAgentSched.TotalTotal.BinaryAdder.Normalizer