Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

PricingWithTips 3DM dependency: CLRSLean.Chapter_34.Section_34_4_NP_Completeness_Proofs.PolyBuilder.FixedPairCodecSimulation

Definition
PricingWithTips3DM_52ac209afb637abc9efed0fc

by qmaai2907271020 · Oct 22, 2026 · Mathlib 0df444a (Lean v4.33.1)

complexity-theorypricing-with-tipsthree-dimensional-matching

A private, kernel-checked dependency module used by the formal NP-hardness proof for three-dimensional matching and Theorems 4.1 and 4.2 of arXiv:2507.10872.

Definition code
import Definitions.Def_PricingWithTips3DM_3e64c10efcfddaf97027018c
import Mathlib.Tactic
set_option autoImplicit true
set_option backward.isDefEq.respectTransparency.types false

/-!
# Exact simulation of the fixed-pair decoder
-/

noncomputable section

open StateTransition

namespace CLRS.Chapter34.Turing.PolyBuilder

/-- Exact number of direct decoder steps on every physical input. -/
def fixedPairDecodeSteps {Δ : Type} : List Δ → Nat
  | [] => 2
  | [_] => 3
  | _ :: _ :: rest => 3 + fixedPairDecodeSteps rest

/-- Exact contextual run of the reverse-output fixed-pair decoder. -/
def fixedPairDecodeRev_context {Γ Δ : Type} [Fintype Δ]
    (decode : Δ → Δ → Γ) (buffer : Option Δ)
    (input : List Δ) (output : List Γ) :
    EvalsToInTime (step (fixedPairDecodeRevProgram decode))
      (fixedPairDecodeCfg decode .scan buffer input output)
      (some (haltCfg (fixedPairDecodeRevProgram decode)
        ((fixedPairDecode decode input).reverse ++ output)))
      (fixedPairDecodeSteps input) := by
  induction input using List.twoStepInduction generalizing buffer output with
  | nil => exact ⟨⟨2, rfl⟩, le_rfl⟩
  | singleton first => exact ⟨⟨3, rfl⟩, le_rfl⟩
  | cons_cons first second rest ih _ =>
      have hprefix : EvalsToInTime
          (step (fixedPairDecodeRevProgram decode))
          (fixedPairDecodeCfg decode .scan buffer
            (first :: second :: rest) output)
          (some (fixedPairDecodeCfg decode .scan (some second) rest
            (decode first second :: output))) 3 :=
        ⟨⟨3, rfl⟩, le_rfl⟩
      let full := EvalsToInTime.trans
        (step (fixedPairDecodeRevProgram decode))
        3 (fixedPairDecodeSteps rest) _
        (fixedPairDecodeCfg decode .scan (some second) rest
          (decode first second :: output)) _
        hprefix (ih (some second) (decode first second :: output))
      convert full using 1 <;>
        simp [fixedPairDecodeSteps, fixedPairDecode,
          List.reverse_cons, List.append_assoc] <;> omega

/-- Canonical exact direct decoder run. -/
def fixedPairDecodeRev_run {Γ Δ : Type} [Fintype Δ]
    (decode : Δ → Δ → Γ) (input : List Δ) :
    EvalsToInTime (step (fixedPairDecodeRevProgram decode))
      (initialCfg (fixedPairDecodeRevProgram decode) input)
      (some (haltCfg (fixedPairDecodeRevProgram decode)
        (fixedPairDecode decode input).reverse))
      (fixedPairDecodeSteps input) := by
  change EvalsToInTime _
    (fixedPairDecodeCfg decode .scan none input []) _ _
  simpa using fixedPairDecodeRev_context decode none input []

/-- The total decoder has a uniform linear physical-input bound. -/
theorem fixedPairDecodeSteps_le {Δ : Type} (input : List Δ) :
    fixedPairDecodeSteps input ≤ 2 * input.length + 2 := by
  induction input using List.twoStepInduction with
  | nil => simp [fixedPairDecodeSteps]
  | singleton first => simp [fixedPairDecodeSteps]
  | cons_cons first second rest ih _ =>
      simp only [fixedPairDecodeSteps, List.length_cons]
      omega

end CLRS.Chapter34.Turing.PolyBuilder
Source
https://github.com/tanktechnology/CLRS-Lean

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