Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

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

Definition
PricingWithTips3DM_b6a60ccae73d200ecf9d427a

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_3799fd79c9b0b4d68c438353
import Definitions.Def_PricingWithTips3DM_b4f76447a6d2b46e80bcfdbb
set_option autoImplicit true
set_option backward.isDefEq.respectTransparency.types false

/-!
# Unary frames for finite-symbol codes

A fixed finite alphabet permits each symbol to carry a fixed natural-number
code in finite control.  The verified bounded-loop macro expands a raw input
word into one self-delimiting unary block per symbol.
-/

noncomputable section

namespace CLRS.Chapter34.Turing.PolyBuilder

/-- Symbol-local expansion into one unary block. -/
def finiteSymbolUnaryFrameBody {Γ : Type} (code : Γ → Nat) :
    LoopBody Γ UnaryFrameSym where
  emit symbol := encodeUnaryFrameBlock (code symbol)
  cost symbol := code symbol + 1
  emit_length_le_cost symbol := by
    simp [encodeUnaryFrameBlock]

/-- Concatenated unary code blocks for a raw finite-alphabet word. -/
def finiteSymbolUnaryFrames {Γ : Type} (code : Γ → Nat)
    (input : List Γ) : List UnaryFrameSym :=
  input.flatMap (finiteSymbolUnaryFrameBody code).emit

/-- The bounded-loop target is precisely the ordinary unary encoding of the
pointwise code list. -/
theorem finiteSymbolUnaryFrames_eq_encodeUnaryFrame {Γ : Type}
    (code : Γ → Nat) (input : List Γ) :
    finiteSymbolUnaryFrames code input =
      encodeUnaryFrame (input.map code) := by
  unfold finiteSymbolUnaryFrames finiteSymbolUnaryFrameBody encodeUnaryFrame
  rw [List.flatMap_map]

/-- A fixed polynomial-time TM2 computes all symbol-code frames directly from
the raw word.  The finite code table contributes only a constant factor. -/
noncomputable def finiteSymbolUnaryFrames_computableInPolyTime
    {Γ : Type} [Fintype Γ] (code : Γ → Nat) :
    _root_.Turing.TM2ComputableInPolyTime id id
      (finiteSymbolUnaryFrames code) := by
  change _root_.Turing.TM2ComputableInPolyTime id id
    (fun input : List Γ =>
      input.flatMap (finiteSymbolUnaryFrameBody code).emit)
  exact boundedLoop_computableInPolyTime
    (finiteSymbolUnaryFrameBody code)

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