Exact fixed-width shift-and-add word multiplication, including leading zeros
ProvedIntMul.BinarySchoolbook.product_word_correctalgorithmsfixed-tape-routinginteger-multiplicationturing-machines
For any equal-length binary words x and y, the explicit fixed-width Horner shift-and-add word algorithm returns exactly bin(2|x|,val(x)*val(y)). The accumulator has width 2|x| throughout; intermediate shifts and additions discard high carries and are analyzed modulo 2^(2|x|). The final exact product is below this capacity, so the output retains every required leading zero. Empty words are included. This theorem supplies the arithmetic interface for the actual schoolbook tape machine; it does not by itself prove any Turing-machine time bound.
Preamble
import Definitions.Def_IntMul_BinarySchoolbook import Definitions.Def_IntMul_MultitapeModel import Mathlib.Data.Nat.Bits import Mathlib.Tactic open IntMul.BinarySchoolbook
Formal statement
theorem IntMul.BinarySchoolbook.product_word_correct (x y : List Bool) (h : x.length = y.length) :
productWord x y = IntMul.bin (2 * x.length) (IntMul.val x * IntMul.val y) := by sorrySource
Classical shift-and-add algorithm used in the existing IntMul.TM.schoolbook milestone (86109c88-e1e4-410a-a312-0a5f005a04cf). Original fixed-width word and machine interface formalization, Written by Codex.