Prove2Me
Navigate
DiscoverCollectionsFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Multitape Turing machines and exact integer multiplication in time O(g(n))O(g(n))O(g(n))

Definition
IntMul_MultitapeModel

by avi · Oct 8, 2026 · Mathlib 0df444a (Lean v4.33.1)

complexity-theoryinteger-multiplicationturing-machines

This file fixes the machine model and the multiplication task shared by the integer-multiplication missions. The machine conventions are those of Montanaro's Computational Complexity lecture notes (§3, §3.4). The task is the one stated in Harvey–van der Hoeven and in the OpenAI preprint.

A kkk-tape Turing machine M=(Σ,K,δ)M=(\Sigma,K,\delta)M=(Σ,K,δ) consists of the following:

  1. A finite alphabet Σ\SigmaΣ containing the blank □\square□, the start symbol ▹\triangleright▹, and symbols 0,1,#\mathtt 0,\mathtt 1,\#0,1,#. These five symbols are pairwise distinct.
  2. A finite set of states KKK with a start state START\mathrm{START}START and a halting state HALT≠START\mathrm{HALT}\ne\mathrm{START}HALT=START.
  3. k≥2k\ge2k≥2 tapes: tape 000 is the input tape, tape 111 is the output tape, and the other k−2k-2k−2 tapes are work tapes. Each tape is infinite in one direction, with cells 0,1,2,…0,1,2,\dots0,1,2,… and ▹\triangleright▹ in cell 000.
  4. A transition function
δ:K×Σk→K×(Σ×{←,−,→})k.\delta:K\times\Sigma^k\to K\times(\Sigma\times\{\leftarrow,-,\rightarrow\})^k .δ:K×Σk→K×(Σ×{←,−,→})k.

In one step, the machine reads the kkk scanned symbols, overwrites each scanned cell, moves each head by at most one cell, and changes state.

The transition function satisfies four conditions:

  1. On a cell holding ▹\triangleright▹, the machine writes ▹\triangleright▹ back and does not move left.
  2. The machine never writes ▹\triangleright▹ on a cell that does not hold it, so ▹\triangleright▹ occurs only in cell 000 of each tape.
  3. δ(HALT,σ)=(HALT,σ,−)\delta(\mathrm{HALT},\sigma)=(\mathrm{HALT},\sigma,-)δ(HALT,σ)=(HALT,σ,−), so a halted machine never changes again.
  4. The input tape is read-only.

For x∈{0,1}nx\in\{0,1\}^nx∈{0,1}n, written most significant bit first, val⁡(x)\operatorname{val}(x)val(x) is the integer that xxx represents, and bin⁡k(z)\operatorname{bin}_k(z)bink​(z) is the binary representation of zzz padded on the left with zeros to length kkk. Put lg⁡n=max⁡(⌈log⁡2n⌉,1)\lg n=\max(\lceil\log_2 n\rceil,1)lgn=max(⌈log2​n⌉,1).

The machine is started in START\mathrm{START}START with the input tape holding ▹ x # y □□⋯\triangleright\,x\,\#\,y\,\square\square\cdots▹x#y□□⋯, every other tape holding ▹ □□⋯\triangleright\,\square\square\cdots▹□□⋯, and every head on cell 000. It multiplies nnn-bit integers within TTT steps if, for all x,y∈{0,1}nx,y\in\{0,1\}^nx,y∈{0,1}n, it reaches HALT\mathrm{HALT}HALT within TTT steps and the output tape then holds exactly

▹ bin⁡2n(val⁡(x)val⁡(y)) □□⋯ .\triangleright\ \operatorname{bin}_{2n}\big(\operatorname{val}(x)\operatorname{val}(y)\big)\ \square\square\cdots.▹ bin2n​(val(x)val(y)) □□⋯.

Multiplication is possible in time O(g)O(g)O(g), written MulTimeBound(g)\mathrm{MulTimeBound}(g)MulTimeBound(g), if there is one machine MMM that halts with the correct output on input x#yx\#yx#y for every n≥1n\ge1n≥1 and all x,y∈{0,1}nx,y\in\{0,1\}^nx,y∈{0,1}n, and whose worst-case running time T(n)T(n)T(n) satisfies T(n)≤c g(n)T(n)\le c\,g(n)T(n)≤cg(n) for all n≥n0n\ge n_0n≥n0​, for some constants c>0c>0c>0 and n0n_0n0​. Finally,

KappaBound(κ):  ⟺  MulTimeBound(n↦n(lg⁡n)1−κ).\mathrm{KappaBound}(\kappa):\iff\mathrm{MulTimeBound}\big(n\mapsto n(\lg n)^{1-\kappa}\big).KappaBound(κ):⟺MulTimeBound(n↦n(lgn)1−κ).

These definitions express the main theorems of Harvey–van der Hoeven (κ=0\kappa=0κ=0) and of the OpenAI preprint and its follow-ups (κ>0\kappa>0κ>0) as statements about one common object.

Formalization Note Following the papers, the size parameter nnn is the length of each operand, not the input length 2n+12n+12n+1, and only well-formed inputs x#yx\#yx#y with ∣x∣=∣y∣=n≥1|x|=|y|=n\ge1∣x∣=∣y∣=n≥1 are constrained. The two inputs are separated by #\##, as in the papers; the notes use a comma for the same purpose. A left move from cell 000 cannot occur, because cell 000 always holds ▹\triangleright▹. Since HALT\mathrm{HALT}HALT freezes the configuration, "in state HALT\mathrm{HALT}HALT after some t≤Tt\le Tt≤T steps" is the same as "halts using at most TTT steps".

Definition code
import Mathlib

/-!
# Exact integer multiplication on deterministic multitape Turing machines

Shared model for the integer-multiplication complexity missions.

Machine conventions follow A. Montanaro, *Computational Complexity* lecture notes
(Cambridge, 2012), §3 (Turing machines), §3.4 (multiple-tape machines), §3.3 (big-O),
§4 (time-bounded computation).  The multiplication task follows Harvey–van der Hoeven 2021, §1,
and OpenAI, *Integer multiplication below n log n*, §1.
-/

namespace IntMul

/-- Head movements `←`, `−`, `→`. -/
inductive Move
  | left
  | stay
  | right
  deriving DecidableEq

/-- A deterministic `k`-tape Turing machine (Montanaro §3, §3.4).

* `Σ` is a finite alphabet containing the blank `□`, the start symbol `▷`, and the symbols
  `0`, `1`, `#` used for the input and output; these five symbols are pairwise distinct.
* `K` is a finite set of states with a start state `START` and a halting state `HALT ≠ START`.
* There are `k ≥ 2` tapes: tape `0` is the input tape, tape `1` is the output tape, and the
  remaining `k - 2` tapes are work tapes.  Every tape is infinite in one direction (cells
  `0, 1, 2, …`), with cell `0` holding `▷`.
* `δ : K × Σᵏ → K × (Σ × {←, −, →})ᵏ` is the transition function.

The conditions are those of the notes: on a cell holding `▷` the machine rewrites `▷` and does
not move left; `▷` is never written anywhere else, so it occurs only in cell `0` of each tape;
in state `HALT` the configuration no longer changes; and the input tape is read-only. -/
structure MultitapeTM where
  /-- the alphabet `Σ` -/
  Sym : Type
  [instFintypeSym : Fintype Sym]
  /-- the blank symbol `□` -/
  blank : Sym
  /-- the start symbol `▷` -/
  startSym : Sym
  /-- the symbol for the bit `0` -/
  zero : Sym
  /-- the symbol for the bit `1` -/
  one : Sym
  /-- the separator `#` between the two inputs -/
  sep : Sym
  syms_distinct : [blank, startSym, zero, one, sep].Nodup
  /-- the set of states `K` -/
  K : Type
  [instFintypeK : Fintype K]
  /-- the start state `START` -/
  qStart : K
  /-- the halting state `HALT` -/
  qHalt : K
  start_ne_halt : qStart ≠ qHalt
  /-- the number of tapes -/
  k : ℕ
  two_le_k : 2 ≤ k
  /-- the transition function `δ : K × Σᵏ → K × (Σ × {←, −, →})ᵏ` -/
  δ : K → (Fin k → Sym) → K × (Fin k → Sym × Move)
  /-- the head never erases `▷` and never moves left from it -/
  start_preserved : ∀ q a i, a i = startSym →
    ((δ q a).2 i).1 = startSym ∧ ((δ q a).2 i).2 ≠ Move.left
  /-- `▷` is never written on a cell that does not already hold it, so `▷` stays at the start
  of each tape only -/
  start_only_at_start : ∀ q a i, a i ≠ startSym → ((δ q a).2 i).1 ≠ startSym
  /-- `δ(HALT, σ) = (HALT, σ, −)`: once halted, the machine no longer changes its configuration -/
  halt_fixed : ∀ a, δ qHalt a = (qHalt, fun i => (a i, Move.stay))
  /-- the input tape is read-only -/
  input_readonly : ∀ q a, ((δ q a).2 ⟨0, by omega⟩).1 = a ⟨0, by omega⟩

attribute [instance] MultitapeTM.instFintypeSym MultitapeTM.instFintypeK

namespace MultitapeTM

variable (M : MultitapeTM)

/-- The input tape (tape `0`). -/
def inTape : Fin M.k := ⟨0, by have := M.two_le_k; omega⟩

/-- The output tape (tape `1`). -/
def outTape : Fin M.k := ⟨1, by have := M.two_le_k; omega⟩

/-- A configuration: the current state, the contents of every tape (cell `p` of tape `i` is
`cells i p`), and the position of every head. -/
structure Cfg where
  state : M.K
  cells : Fin M.k → ℕ → M.Sym
  head : Fin M.k → ℕ

/-- One step: with state `q` and scanned symbols `a`, if `δ(q, a) = (q', (σᵢ, dᵢ)ᵢ)` then each
tape `i` has the scanned cell overwritten by `σᵢ`, its head moves according to `dᵢ`, and the
state becomes `q'`. -/
def step (c : M.Cfg) : M.Cfg :=
  let r := M.δ c.state (fun i => c.cells i (c.head i))
  { state := r.1
    cells := fun i => Function.update (c.cells i) (c.head i) (r.2 i).1
    head := fun i =>
      match (r.2 i).2 with
      | Move.left => c.head i - 1
      | Move.stay => c.head i
      | Move.right => c.head i + 1 }

/-- Encoding of a bit as a symbol. -/
def bitSym (b : Bool) : M.Sym := if b then M.one else M.zero

/-- Tape contents `▷ w □ □ …`: `▷` in cell `0`, the symbols of `w` in cells `1, …, |w|`, and
blanks everywhere after. -/
def tapeOf (w : List M.Sym) : ℕ → M.Sym
  | 0 => M.startSym
  | p + 1 => w.getD p M.blank

/-- The initial configuration on input `x#y`: state `START`; the input tape holds
`▷ x # y □ □ …`; every other tape holds `▷ □ □ …`; every head is on cell `0`. -/
def initCfg (x y : List Bool) : M.Cfg where
  state := M.qStart
  cells := fun i =>
    if i = M.inTape then M.tapeOf (x.map M.bitSym ++ M.sep :: y.map M.bitSym)
    else M.tapeOf []
  head := fun _ => 0

/-- On input `x#y`, after `t` steps the machine is in state `HALT` and the output tape holds
exactly `▷ w □ □ …` (output `w`). Since `HALT` freezes the configuration, this holds for some
`t ≤ T` iff the machine halts with output `w` using at most `T` steps. -/
def HaltsWithOutput (x y : List Bool) (t : ℕ) (w : List Bool) : Prop :=
  (M.step^[t] (M.initCfg x y)).state = M.qHalt ∧
    (M.step^[t] (M.initCfg x y)).cells M.outTape = M.tapeOf (w.map M.bitSym)

end MultitapeTM

/-- `val x`: the nonnegative integer whose binary representation is `x`,
leftmost bit most significant (`val [] = 0`). -/
def val (x : List Bool) : ℕ :=
  x.foldl (fun a b => 2 * a + b.toNat) 0

/-- `bin k z`: the binary representation of `z` padded on the left to length `k`
(most significant bit first). Meaningful for `z < 2 ^ k`. -/
def bin (k z : ℕ) : List Bool :=
  List.ofFn fun i : Fin k => z.testBit (k - 1 - i)

/-- `lg n = max (⌈log₂ n⌉, 1)`. -/
def lg (n : ℕ) : ℕ := max (Nat.clog 2 n) 1

/-- `M` multiplies `n`-bit integers within `T(n)` steps: for all `x, y ∈ {0,1}ⁿ`, on input
`x#y` the machine halts with output `bin_{2n}(val x · val y)` using at most `T(n)` steps. -/
def MultipliesAt (M : MultitapeTM) (n : ℕ) (T : ℝ) : Prop :=
  ∀ x y : List Bool, x.length = n → y.length = n →
    ∃ t : ℕ, (t : ℝ) ≤ T ∧ M.HaltsWithOutput x y t (bin (2 * n) (val x * val y))

/-- Exact integer multiplication is possible in time `O(g(n))` (Montanaro §3.3, §4): there is a
single machine `M` that, for every `n ≥ 1` and all `x, y ∈ {0,1}ⁿ`, halts on input `x#y` with
output `bin_{2n}(val x · val y)`, and whose worst-case running time `T(n)` satisfies
`T(n) ≤ c · g(n)` for all `n ≥ n₀`, for some constant `c > 0` and some `n₀`. -/
def MulTimeBound (g : ℕ → ℝ) : Prop :=
  ∃ M : MultitapeTM,
    (∀ n : ℕ, 1 ≤ n → ∃ T : ℝ, MultipliesAt M n T) ∧
    ∃ c : ℝ, 0 < c ∧ ∃ n₀ : ℕ, ∀ n : ℕ, n₀ ≤ n → 1 ≤ n → MultipliesAt M n (c * g n)

/-- Multiplication in time `O(n (lg n)^{1-κ})`. -/
def KappaBound (κ : ℝ) : Prop :=
  MulTimeBound fun n => (n : ℝ) * ((lg n : ℝ) ^ (1 - κ))

end IntMul
Source
A. Montanaro, Computational Complexity, lecture notes (Cambridge Part III, 2012), https://people.maths.bris.ac.uk/~csxam/teaching/cc-lecturenotes.pdf, §3 (Turing machine (Σ,K,δ), start symbol, HALT state, output), §3.3 (big-O), §3.4 (k-tape machines: input, output and work tapes; read-only input tape), §4 (computing f in time T); D. Harvey, J. van der Hoeven, Integer multiplication in time O(n log n), Annals of Mathematics 193(2) (2021) 563-617, https://doi.org/10.4007/annals.2021.193.2.4 (preprint https://hal.science/hal-02070778v2), §1 (multitape Turing model, M(n)); OpenAI, Integer multiplication below n log n, preprint, 23 September 2026, https://github.com/openai/math/blob/main/preprints/Integer-multiplication-below-n-log-n-September-23-2026/paper.pdf, §1 (exact multiplication on input x#y, output bin_{2n}(val(x)val(y)), lg n = max(ceil(log2 n),1), Theorem 1)
Read-back

What the Lean code literally says, in plain math · claude-opus-5-5

Read-back: Def_IntMul_MultitapeModel (namespace IntMul)

The file depends only on Mathlib. It defines a model of deterministic multitape Turing machines, together with what it means for one of them to multiply nnn-bit integers within a step budget. The declarations are described below in source order.


1. Move

There are three possible head movements: left, stay and right. Equality between them is decidable.


2. MultitapeTM: a deterministic kkk-tape machine

A machine MMM consists of the following data and conditions.

  • Alphabet. A type Σ\SigmaΣ, assumed finite (a Fintype instance), with five named symbols: the blank □\square□, the start symbol ▹\triangleright▹, the bit symbols 0\mathtt{0}0 and 1\mathtt{1}1, and the separator #\##. The only condition is that these five are pairwise distinct. Σ\SigmaΣ may contain any finite number of further symbols, which can serve as work symbols.
  • States. A finite type KKK with a start state qstartq_{\mathrm{start}}qstart​ and a halting state qhaltq_{\mathrm{halt}}qhalt​, where qstart≠qhaltq_{\mathrm{start}} \ne q_{\mathrm{halt}}qstart​=qhalt​. No other states are named, and nothing else is required of KKK.
  • Tapes. A natural number kkk with k≥2k \ge 2k≥2. Each machine has its own fixed kkk. Tapes are indexed by {0,…,k−1}\{0,\dots,k-1\}{0,…,k−1}.
  • Transition function. A total function
δ:K×Σk→K×(Σ×{left,stay,right})k.\delta : K \times \Sigma^{k} \to K \times (\Sigma \times \{\mathrm{left},\mathrm{stay},\mathrm{right}\})^{k}.δ:K×Σk→K×(Σ×{left,stay,right})k.

For δ(q,a)=(q′,(σi,di)i<k)\delta(q,a) = (q', (\sigma_i, d_i)_{i<k})δ(q,a)=(q′,(σi​,di​)i<k​), the value σi\sigma_iσi​ is the symbol written on tape iii and did_idi​ is the move of head iii.

The following conditions are imposed for every state qqq (including qhaltq_{\mathrm{halt}}qhalt​), every scanned tuple a∈Σka \in \Sigma^ka∈Σk and every tape iii:

  1. (start symbol preserved) If ai=▹a_i = \trianglerightai​=▹, then σi=▹\sigma_i = \trianglerightσi​=▹ and di≠leftd_i \ne \mathrm{left}di​=left.
  2. (start symbol never newly written) If ai≠▹a_i \ne \trianglerightai​=▹, then σi≠▹\sigma_i \ne \trianglerightσi​=▹.
  3. (halt is frozen) For every aaa, δ(qhalt,a)=(qhalt,(ai,stay)i<k)\delta(q_{\mathrm{halt}}, a) = (q_{\mathrm{halt}}, (a_i, \mathrm{stay})_{i<k})δ(qhalt​,a)=(qhalt​,(ai​,stay)i<k​). In the halting state the machine rewrites every scanned symbol unchanged and does not move any head.
  4. (input tape read-only) For every qqq and aaa, σ0=a0\sigma_0 = a_0σ0​=a0​: tape 000 always gets back the symbol it scanned. The head on tape 000 may still move freely.

Conditions 1 and 2 together say that δ\deltaδ writes ▹\triangleright▹ on a tape exactly when that tape scans ▹\triangleright▹. No condition restricts the output tape (for example, it is not write-only), the work tapes, the symbols written on tapes 1,…,k−11,\dots,k-11,…,k−1 other than ▹\triangleright▹, or the moves of the heads, apart from the ban on moving left from a ▹\triangleright▹. Conditions 1–4 are mutually consistent, so such machines exist.


3. inTape and outTape

The input tape is tape 000 and the output tape is tape 111. Both exist because k≥2k \ge 2k≥2. Tapes 2,…,k−12,\dots,k-12,…,k−1 have no designated role.


4. Cfg: configurations

A configuration of MMM is a triple (q,C,h)(q, C, h)(q,C,h):

  • q∈Kq \in Kq∈K is the current state;
  • C:{0,…,k−1}×N→ΣC : \{0,\dots,k-1\} \times \mathbb{N} \to \SigmaC:{0,…,k−1}×N→Σ gives the contents, with Ci(p)C_i(p)Ci​(p) the symbol in cell ppp of tape iii;
  • h:{0,…,k−1}→Nh : \{0,\dots,k-1\} \to \mathbb{N}h:{0,…,k−1}→N gives the head positions.

Each tape is one-way infinite, with cells 0,1,2,…0,1,2,\dots0,1,2,…. A configuration as such is completely unconstrained: tape contents are arbitrary functions, need not be blank from some point on, and may hold ▹\triangleright▹ anywhere. The constraints below come only from reachability from the initial configuration.


5. step: one computation step

From (q,C,h)(q, C, h)(q,C,h), let ai=Ci(hi)a_i = C_i(h_i)ai​=Ci​(hi​) be the scanned symbols and let δ(q,a)=(q′,(σi,di)i)\delta(q, a) = (q', (\sigma_i, d_i)_i)δ(q,a)=(q′,(σi​,di​)i​). The next configuration is (q′,C′,h′)(q', C', h')(q′,C′,h′), where

Ci′(p)={σip=hiCi(p)p≠hihi′={hi−˙1di=lefthidi=stayhi+1di=right.C'_i(p) = \begin{cases} \sigma_i & p = h_i \\ C_i(p) & p \ne h_i \end{cases} \qquad h'_i = \begin{cases} h_i \dot- 1 & d_i = \mathrm{left} \\ h_i & d_i = \mathrm{stay} \\ h_i + 1 & d_i = \mathrm{right}. \end{cases}Ci′​(p)={σi​Ci​(p)​p=hi​p=hi​​hi′​=⎩⎨⎧​hi​−˙​1hi​hi​+1​di​=leftdi​=staydi​=right.​

Here −˙\dot-−˙​ is truncated subtraction on N\mathbb{N}N. So a head at cell 000 that is told to move left stays at cell 000; this is not an error. In configurations reachable from an initial configuration (see items 8 and 9) this case never arises. There, cell 000 of every tape always holds ▹\triangleright▹, and condition 1 forbids moving left from ▹\triangleright▹.

step is a total function. It is applied the same way in every state. Because of condition 3, a configuration in state qhaltq_{\mathrm{halt}}qhalt​ is a fixed point of step: the scanned cells are rewritten with their own contents and no head moves.


6. bitSym

Booleans are encoded as symbols: true↦1\mathrm{true} \mapsto \mathtt{1}true↦1 and false↦0\mathrm{false} \mapsto \mathtt{0}false↦0. For a bit list uuu, write u‾\overline{u}u for its symbol list.


7. tapeOf

For a finite symbol list w=(w1,…,wm)w = (w_1,\dots,w_m)w=(w1​,…,wm​), the tape contents tape(w):N→Σ\mathrm{tape}(w) : \mathbb{N} \to \Sigmatape(w):N→Σ are

tape(w)(0)=▹,tape(w)(p)=wp (1≤p≤m),tape(w)(p)=□ (p>m).\mathrm{tape}(w)(0) = \triangleright,\qquad \mathrm{tape}(w)(p) = w_p \ (1 \le p \le m),\qquad \mathrm{tape}(w)(p) = \square \ (p > m).tape(w)(0)=▹,tape(w)(p)=wp​ (1≤p≤m),tape(w)(p)=□ (p>m).

So tape(w)=▹ w1⋯wm □ □⋯\mathrm{tape}(w) = \triangleright\, w_1 \cdots w_m\, \square\,\square \cdotstape(w)=▹w1​⋯wm​□□⋯. The empty list gives tape( )=▹ □ □⋯\mathrm{tape}(\,) = \triangleright\,\square\,\square\cdotstape()=▹□□⋯.


8. initCfg: the initial configuration on (x,y)(x, y)(x,y)

For bit lists xxx and yyy of any lengths, possibly different and possibly empty, the initial configuration has:

  • state qstartq_{\mathrm{start}}qstart​;
  • input tape tape(x‾ # y‾)=▹ x1⋯x∣x∣ # y1⋯y∣y∣ □ □⋯\mathrm{tape}(\overline{x}\,\#\,\overline{y}) = \triangleright\, x_1\cdots x_{|x|}\, \#\, y_1 \cdots y_{|y|}\, \square\,\square\cdotstape(x#y​)=▹x1​⋯x∣x∣​#y1​⋯y∣y∣​□□⋯;
  • every other tape (the output tape and all work tapes) equal to ▹ □ □⋯\triangleright\,\square\,\square\cdots▹□□⋯;
  • every head at cell 000.

For x=y=()x = y = ()x=y=() the input tape is ▹ # □⋯\triangleright\,\#\,\square\cdots▹#□⋯.

Where ▹\triangleright▹ can appear. In the initial configuration, ▹\triangleright▹ is in cell 000 of every tape and nowhere else, because □,0,1,#\square, \mathtt{0}, \mathtt{1}, \#□,0,1,# are all distinct from ▹\triangleright▹. A step changes only the scanned cells. By conditions 1–2, a scanned ▹\triangleright▹ is rewritten as ▹\triangleright▹ and a scanned non-▹\triangleright▹ is never turned into ▹\triangleright▹. Hence every configuration reachable from initCfg has ▹\triangleright▹ in exactly cell 000 of each tape. This is a consequence of the definitions; the file does not state it as a lemma. In arbitrary, non-reachable configurations, ▹\triangleright▹ can appear anywhere.


9. HaltsWithOutput

For bit lists x,y,wx, y, wx,y,w and t∈Nt \in \mathbb{N}t∈N, let stept\mathrm{step}^{t}stept denote ttt applications of step, with step0\mathrm{step}^0step0 the identity. The predicate holds iff the configuration

stept(init(x,y))\mathrm{step}^{t}(\mathrm{init}(x,y))stept(init(x,y))

satisfies both of the following:

  • its state is qhaltq_{\mathrm{halt}}qhalt​; and
  • its entire output tape (tape 111) equals tape(w‾)\mathrm{tape}(\overline{w})tape(w). That is, cell 000 holds ▹\triangleright▹, cells 1,…,∣w∣1,\dots,|w|1,…,∣w∣ hold the bits of www as 0/1\mathtt{0}/\mathtt{1}0/1 symbols, and every later cell holds □\square□. No leftover non-blank symbols are allowed anywhere on tape 111.

The predicate does not constrain:

  • the position of the output head or of any other head;
  • the contents of the input tape or of the work tapes;
  • whether ttt is the first time the state is qhaltq_{\mathrm{halt}}qhalt​.

Because halted configurations are fixed points, if the predicate holds at ttt it also holds at every t′≥tt' \ge tt′≥t. Hence "it holds for some t≤Tt \le Tt≤T" is the same as "the machine reaches qhaltq_{\mathrm{halt}}qhalt​ within TTT steps with this output tape". Here ttt counts applications of the step function, and the step that enters qhaltq_{\mathrm{halt}}qhalt​ is counted. Since qstart≠qhaltq_{\mathrm{start}} \ne q_{\mathrm{halt}}qstart​=qhalt​, the predicate fails at t=0t = 0t=0, so t≥1t \ge 1t≥1 is necessary.


10. val

For a bit list x=(x1,…,xm)x = (x_1,\dots,x_m)x=(x1​,…,xm​), the value is

val(x)=∑j=1mxj 2m−j,\mathrm{val}(x) = \sum_{j=1}^{m} x_j\, 2^{m-j},val(x)=j=1∑m​xj​2m−j,

with the most significant bit first. It is computed by folding a↦2a+xja \mapsto 2a + x_ja↦2a+xj​ from a=0a = 0a=0. Leading zeros are allowed and val( )=0\mathrm{val}(\,) = 0val()=0. Every xxx of length nnn has 0≤val(x)<2n0 \le \mathrm{val}(x) < 2^n0≤val(x)<2n.


11. bin

For k,z∈Nk, z \in \mathbb{N}k,z∈N, bink(z)\mathrm{bin}_k(z)bink​(z) is the length-kkk bit list whose iii-th entry (i=0,…,k−1i = 0,\dots,k-1i=0,…,k−1) is bit number k−1−ik-1-ik−1−i of zzz, where bit 000 is the least significant. It is therefore the binary representation of

z mod 2kz \bmod 2^kzmod2k

padded with leading zeros to exactly kkk bits, most significant bit first. If z≥2kz \ge 2^kz≥2k, the higher bits are silently dropped. bin0(z)\mathrm{bin}_0(z)bin0​(z) is the empty list.


12. lg

For n∈Nn \in \mathbb{N}n∈N,

lg(n)=max⁡(⌈log⁡2n⌉,1).\mathrm{lg}(n) = \max\bigl(\lceil \log_2 n \rceil, 1\bigr).lg(n)=max(⌈log2​n⌉,1).

Here ⌈log⁡2n⌉\lceil\log_2 n\rceil⌈log2​n⌉ is Mathlib's Nat.clog 2 n, the least m∈Nm \in \mathbb{N}m∈N with n≤2mn \le 2^mn≤2m, which is 000 for n∈{0,1}n \in \{0,1\}n∈{0,1}. So lg(0)=lg(1)=lg(2)=1\mathrm{lg}(0) = \mathrm{lg}(1) = \mathrm{lg}(2) = 1lg(0)=lg(1)=lg(2)=1, lg(3)=lg(4)=2\mathrm{lg}(3) = \mathrm{lg}(4) = 2lg(3)=lg(4)=2, lg(5)=3\mathrm{lg}(5) = 3lg(5)=3, and so on. In every case lg(n)≥1\mathrm{lg}(n) \ge 1lg(n)≥1.


13. MultipliesAt

For a machine MMM, n∈Nn \in \mathbb{N}n∈N and a real number TTT, the predicate holds iff:

∀ x,y∈{0,1}n  ∃ t∈N:  t≤T  ∧  HaltsWithOutputM(x,y,t,bin2n(val(x)⋅val(y))).\forall\, x, y \in \{0,1\}^n\ \ \exists\, t \in \mathbb{N}:\ \ t \le T\ \ \wedge\ \ \mathrm{HaltsWithOutput}_M\bigl(x, y, t, \mathrm{bin}_{2n}(\mathrm{val}(x)\cdot \mathrm{val}(y))\bigr).∀x,y∈{0,1}n  ∃t∈N:  t≤T  ∧  HaltsWithOutputM​(x,y,t,bin2n​(val(x)⋅val(y))).

Since val(x) val(y)<22n\mathrm{val}(x)\,\mathrm{val}(y) < 2^{2n}val(x)val(y)<22n, the required output is exactly the product written with exactly 2n2n2n bits, including leading zeros, and no truncation occurs.

  • The predicate quantifies only over inputs where both xxx and yyy have length exactly nnn. Behaviour on unequal lengths is unconstrained.
  • The bound t≤Tt \le Tt≤T is a comparison of the natural number ttt with a real, so it is equivalent to t≤⌊T⌋t \le \lfloor T \rfloort≤⌊T⌋.
  • If T<1T < 1T<1, the predicate is false for n≥0n \ge 0n≥0, because t≥1t \ge 1t≥1 is needed and there is at least one input.
  • For n=0n = 0n=0 the only input is x=y=()x = y = ()x=y=(), and the required output is bin0(0)=()\mathrm{bin}_0(0) = ()bin0​(0)=(), so the output tape must be ▹ □ □⋯\triangleright\,\square\,\square\cdots▹□□⋯.

14. MulTimeBound

For g:N→Rg : \mathbb{N} \to \mathbb{R}g:N→R, MulTimeBound(g)\mathrm{MulTimeBound}(g)MulTimeBound(g) holds iff:

∃ M  [ (∀n∈N, n≥1⇒∃ T∈R: MultipliesAt(M,n,T))  ∧  ∃ c∈R, c>0, ∃ n0∈N, ∀n∈N, n≥n0⇒n≥1⇒MultipliesAt(M,n,c⋅g(n)) ].\exists\, M \;\Bigl[\ \bigl(\forall n \in \mathbb{N},\ n \ge 1 \Rightarrow \exists\, T \in \mathbb{R}:\ \mathrm{MultipliesAt}(M, n, T)\bigr)\ \ \wedge\ \ \exists\, c \in \mathbb{R},\ c > 0,\ \exists\, n_0 \in \mathbb{N},\ \forall n \in \mathbb{N},\ n \ge n_0 \Rightarrow n \ge 1 \Rightarrow \mathrm{MultipliesAt}\bigl(M, n, c\cdot g(n)\bigr)\ \Bigr].∃M[ (∀n∈N, n≥1⇒∃T∈R: MultipliesAt(M,n,T))  ∧  ∃c∈R, c>0, ∃n0​∈N, ∀n∈N, n≥n0​⇒n≥1⇒MultipliesAt(M,n,c⋅g(n)) ].

The machine. One single machine MMM, with fixed alphabet, state set and tape count kkk, must work for all nnn.

First conjunct. For every n≥1n \ge 1n≥1, MMM correctly multiplies all pairs of nnn-bit inputs and halts within some finite real bound TTT that may depend on nnn. Since there are finitely many inputs of length nnn, this amounts to: MMM halts on every x#yx\#yx#y with ∣x∣=∣y∣=n≥1|x| = |y| = n \ge 1∣x∣=∣y∣=n≥1, and its output tape is then exactly tape(bin2n(val(x)val(y))‾)\mathrm{tape}(\overline{\mathrm{bin}_{2n}(\mathrm{val}(x)\mathrm{val}(y))})tape(bin2n​(val(x)val(y))​). This conjunct is what forces correctness for 1≤n<n01 \le n < n_01≤n<n0​, which the second conjunct does not cover. It imposes no time bound.

Second conjunct. There are a real constant c>0c > 0c>0 and a threshold n0∈Nn_0 \in \mathbb{N}n0​∈N. Both are chosen after MMM, and neither depends on nnn. For every n≥max⁡(n0,1)n \ge \max(n_0, 1)n≥max(n0​,1) and every pair x,yx, yx,y of length nnn, MMM reaches qhaltq_{\mathrm{halt}}qhalt​ with the correct output tape within at most ⌊c g(n)⌋\lfloor c\, g(n) \rfloor⌊cg(n)⌋ steps.

What is not constrained. Inputs with n=0n = 0n=0 are never constrained. Inputs with ∣x∣≠∣y∣|x| \ne |y|∣x∣=∣y∣ are never constrained. Nothing is required of ggg itself. If c g(n)<1c\,g(n) < 1cg(n)<1 for infinitely many nnn (for example, if g(n)≤0g(n) \le 0g(n)≤0 infinitely often), the second conjunct is unsatisfiable.


15. KappaBound

For a real κ\kappaκ, with no restriction on its sign or size,

KappaBound(κ)  ⟺  MulTimeBound(n↦n⋅lg(n) 1−κ).\mathrm{KappaBound}(\kappa) \iff \mathrm{MulTimeBound}\Bigl(n \mapsto n \cdot \mathrm{lg}(n)^{\,1-\kappa}\Bigr).KappaBound(κ)⟺MulTimeBound(n↦n⋅lg(n)1−κ).

The power is the real power. Since lg(n)≥1\mathrm{lg}(n) \ge 1lg(n)≥1, the base is a positive real and lg(n)1−κ>0\mathrm{lg}(n)^{1-\kappa} > 0lg(n)1−κ>0 for all nnn. At n=1n = 1n=1 the function equals 111.

  • κ=0\kappa = 0κ=0 gives n lg(n)n\,\mathrm{lg}(n)nlg(n).
  • κ=1\kappa = 1κ=1 gives nnn.
  • κ>1\kappa > 1κ>1 gives n lg(n)−(κ−1)n\,\mathrm{lg}(n)^{-(\kappa-1)}nlg(n)−(κ−1), which grows more slowly than nnn.
  • κ<0\kappa < 0κ<0 gives exponents larger than 111.

Unfolded, the statement is: there exist one machine MMM, a constant c>0c > 0c>0 and an n0n_0n0​ as in item 14. MMM correctly multiplies all pairs of nnn-bit inputs for every n≥1n \ge 1n≥1. For every n≥max⁡(n0,1)n \ge \max(n_0,1)n≥max(n0​,1) it does so within c⋅n⋅lg(n)1−κc \cdot n \cdot \mathrm{lg}(n)^{1-\kappa}c⋅n⋅lg(n)1−κ steps on every such pair.

Human review
  • Endorsed by wurtle · Oct 8, 2026

    Confirmed by the moderator at approval.

  • Endorsed by avi · Oct 8, 2026

    Confirmed by the mission captain (proposal self-audit).

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paper
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me