Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

BundleMVL-2 NP checker, step 2: checking that all rationals are in lowest terms is polynomial-time

Proved
MultiPurchase.Hardness.canon_filter_polytime

by tianyipeng · Nov 3, 2026 · Mathlib 0df444a (Lean v4.33.1)

multi-purchasenp-completenesspolynomial-time

With the notation of Definitions.Def_MultiPurchase_Hardness_Checker (checker inputs ⟨c#d⟩\langle c\#d\rangle⟨c#d⟩ and the condition ShapeOK\mathrm{ShapeOK}ShapeOK), there is a function ggg on checker inputs that is computable in polynomial time by a Cook Turing machine, maps the empty word to the empty word, and satisfies, for every c,dc, dc,d with ShapeOK(c,d)\mathrm{ShapeOK}(c,d)ShapeOK(c,d),

g(⟨c#d⟩)={⟨c#d⟩if CanonOK(c),εotherwise,g(\langle c\#d\rangle) = \begin{cases} \langle c\#d\rangle & \text{if } \mathrm{CanonOK}(c),\\ \varepsilon & \text{otherwise,}\end{cases}g(⟨c#d⟩)={⟨c#d⟩ε​if CanonOK(c),otherwise,​

where CanonOK(c)\mathrm{CanonOK}(c)CanonOK(c) says that for each of the 2n+n(n−1)/2+22n + n(n-1)/2 + 22n+n(n−1)/2+2 rationals (numt,dent)(\mathrm{num}_t, \mathrm{den}_t)(numt​,dent​) encoded in ccc one has dent>0\mathrm{den}_t > 0dent​>0 and gcd⁡(numt,dent)=1\gcd(\mathrm{num}_t, \mathrm{den}_t) = 1gcd(numt​,dent​)=1.

This is the second check of the BundleMVL-2 verifier: instance codes write every rational as its normalized numerator and denominator, so a word is a code only if every pair is in lowest terms. The check amounts to polynomially many gcd computations on binary numbers.

Preamble
import Mathlib
import Definitions.Def_CookPvsNP_defs
import Definitions.Def_ProjSchedTW_Complexity_Encoding
import Definitions.Def_MultiPurchase_Hardness_Model
import Definitions.Def_MultiPurchase_Hardness_Checker
Formal statement
namespace MultiPurchase.Hardness

open CookPvsNP ProjSchedTW.Complexity

open Classical in
theorem canon_filter_polytime :
    ∃ g : List (Option (BSym ⊕ Bool)) → List (Option (BSym ⊕ Bool)),
      PolyTimeComputable g ∧ g [] = [] ∧
        ∀ c d, ShapeOK c d → g (chkWord c d) = if CanonOK c then chkWord c d else [] := by sorry

end MultiPurchase.Hardness
Source
Tulabandhula, Sinha, Karra & Patidar, Multi-Purchase Behavior: Modeling, Estimation and Optimization, arXiv:2006.08055v2, p. 17, Theorem 1 (membership half: the decision version of (5) is in NP), eq. (4); polynomial-time computability as in S. Cook, The P versus NP problem (Clay Mathematics Institute), §1 and Definition 3

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 paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me