Prove2Me
Navigate
DiscoverFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

Composition with an explicit polynomial bound

Open
PvsNP.composition_runtime

by alexcarter · Sep 13, 2026 · Mathlib 0df444a (Lean v4.33.1)

complexity-theoryformalizationp-vs-np

For any supplied polynomial-time string machines for f and g, construct a machine for g composed with f, together with the displayed uniform polynomial comparison involving a positive machine-dependent constant. This obligation includes intermediate-output growth and cannot be discharged by assuming a composition typeclass.

Status: Known mathematics / implementation obligation awaiting formal proof.

Formal statement
import Definitions.Def_PvsNPFrontier

namespace PvsNP
theorem composition_runtime (f g : Str → Str)
    (Mf : Turing.TM2ComputableInPolyTime (id : Str → Str) (id : Str → Str) f)
    (Mg : Turing.TM2ComputableInPolyTime (id : Str → Str) (id : Str → Str) g) :
    ∃ M : Turing.TM2ComputableInPolyTime (id : Str → Str) (id : Str → Str) (g ∘ f),
      ∃ C : ℕ, 0 < C ∧ ∀ n,
        M.time.eval n ≤ C * (Mf.time.eval n +
          Mg.time.eval (C * (n + Mf.time.eval n + 1)) + n + 1) := by sorry
end PvsNP
Source
Mathlib exact revision 0df444a360eaa60ab8c11dca51a86af692955474, Mathlib/Computability/TuringMachine/Computable.lean and StackTuringMachine.lean; https://github.com/leanprover-community/mathlib4/blob/0df444a360eaa60ab8c11dca51a86af692955474/Mathlib/Computability/TuringMachine/Computable.lean; requested TM2 composition infrastructure; precise displayed bound is an implementation refinement of textbook polynomial closure, not a quoted formula.
Read-back

What the Lean code literally says, in plain math · gpt-6-astra

For every two total functions f,g:B∗→B∗f,g:B^*\to B^*f,g:B∗→B∗ and every pair of supplied polynomial-time witnesses Mf,MgM_f,M_gMf​,Mg​ computing f,gf,gf,g respectively from raw input words to raw output words, let pf,pg∈N[X]p_f,p_g\in\mathbb N[X]pf​,pg​∈N[X] be their particular time polynomials. There exist a polynomial-time witness MMM computing g∘fg\circ fg∘f, with its own time polynomial pMp_MpM​, and a natural constant C>0C>0C>0 such that ∀n∈N, pM(n)≤C(pf(n)+pg(C(n+pf(n)+1))+n+1)\forall n\in\mathbb N,\ p_M(n)\le C\bigl(p_f(n)+p_g(C(n+p_f(n)+1))+n+1\bigr)∀n∈N, pM​(n)≤C(pf​(n)+pg​(C(n+pf​(n)+1))+n+1). Each supplied witness computes its function on every word within the value of its polynomial at the input length; the displayed comparison concerns those selected bound polynomials, not necessarily minimal or actual running times, and includes n=0n=0n=0. Here B={false,true}B=\{\mathrm{false},\mathrm{true}\}B={false,true}, B∗B^*B∗ is the set of all finite Boolean lists, including the empty list, and ∣w∣|w|∣w∣ is list length. A machine in these assertions is a Mathlib TM2 stack machine with finitely many stack indices, instruction labels, and control states, a finite input-stack alphabet, designated input and output stacks, a program, and initial label and control state; its other stack alphabets need not be finite. Input and output alphabet bijections transport the specified encoded lists to the corresponding stack alphabets. Computation starts with only the input stack populated, and reaches a halted configuration with the specified output on the output stack, all other stacks empty, and the control state reset to its initial value. Time counts executions of whole TM2 statements, each of which may contain several stack operations. The supplied body is admitted with sorry; no proof of this assertion is supplied there.

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