PricingWithTips 3DM dependency: CLRSLean.Chapter_34.Section_34_4_NP_Completeness_Proofs.PolyBuilder.UnaryFrameQuoteSimulation
DefinitionPricingWithTips3DM_2edb7f26b0fd9cd1b939c01fcomplexity-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_23b4e8fdb6bc1ff87a8f0413
import Mathlib.Tactic
set_option autoImplicit true
set_option backward.isDefEq.respectTransparency.types false
/-!
# Exact simulation of unary-frame quoting
-/
noncomputable section
open StateTransition
namespace CLRS.Chapter34.Turing.PolyBuilder
private abbrev quoteStep := step unaryFrameQuoteMarkedRevProgram
/-- Exact cost through the input scan, stopping before the outer boundary is
emitted. -/
def unaryFrameQuoteScanSteps (input : List UnaryFrameSym) : Nat :=
3 * input.length + 1
/-- The scan emits the reverse of every two-symbol codeword. -/
private theorem unaryFrameQuote_scan_eval
(buffer : Option UnaryFrameSym) (input output : List UnaryFrameSym) :
(flip Option.bind quoteStep)^[unaryFrameQuoteScanSteps input]
(some (unaryFrameQuoteCfg .scan buffer input output)) =
some (unaryFrameQuoteCfg .emitBoundary none []
((quoteUnaryFrameStream input).reverse ++ output)) := by
induction input generalizing buffer output with
| nil => rfl
| cons symbol rest ih =>
rw [show unaryFrameQuoteScanSteps (symbol :: rest) =
unaryFrameQuoteScanSteps rest + 1 + 1 + 1 by
simp [unaryFrameQuoteScanSteps]
omega,
Function.iterate_succ_apply, Function.iterate_succ_apply,
Function.iterate_succ_apply]
change
(flip Option.bind quoteStep)^[unaryFrameQuoteScanSteps rest]
(some (unaryFrameQuoteCfg .scan (some symbol) rest
(quoteUnaryFrameSecond symbol ::
quoteUnaryFrameFirst symbol :: output))) = _
simpa [quoteUnaryFrameStream_cons, quoteUnaryFrameSym_eq_pair,
List.reverse_append, List.append_assoc] using
ih (some symbol)
(quoteUnaryFrameSecond symbol ::
quoteUnaryFrameFirst symbol :: output)
/-- Total cost including the outer boundary and the final halt. -/
def unaryFrameQuoteMarkedSteps (input : List UnaryFrameSym) : Nat :=
3 * input.length + 3
/-- The concrete prepend-only controller outputs the reversed encoding of one
quoted singleton marked row. -/
def unaryFrameQuoteMarkedRev_run (input : List UnaryFrameSym) :
EvalsToInTime quoteStep
(initialCfg unaryFrameQuoteMarkedRevProgram input)
(some (haltCfg unaryFrameQuoteMarkedRevProgram
(encodeUnaryFrameMarkedRowFamily
(quotedUnaryFrameSingleton input)).reverse))
(unaryFrameQuoteMarkedSteps input) := by
let afterScan := unaryFrameQuoteCfg .emitBoundary none []
(quoteUnaryFrameStream input).reverse
let afterBoundary := unaryFrameQuoteCfg .finish none []
(.frameEnd :: (quoteUnaryFrameStream input).reverse)
have hscan : EvalsToInTime quoteStep
(initialCfg unaryFrameQuoteMarkedRevProgram input)
(some afterScan) (unaryFrameQuoteScanSteps input) := by
change EvalsToInTime quoteStep
(unaryFrameQuoteCfg .scan none input [])
(some afterScan) (unaryFrameQuoteScanSteps input)
refine ⟨⟨unaryFrameQuoteScanSteps input, ?_⟩, le_rfl⟩
simpa [afterScan] using
unaryFrameQuote_scan_eval none input []
have hboundary : EvalsToInTime quoteStep afterScan
(some afterBoundary) 1 := ⟨⟨1, rfl⟩, le_rfl⟩
have hhalt : EvalsToInTime quoteStep afterBoundary
(some (haltCfg unaryFrameQuoteMarkedRevProgram
(.frameEnd :: (quoteUnaryFrameStream input).reverse))) 1 :=
⟨⟨1, rfl⟩, le_rfl⟩
let throughBoundary := EvalsToInTime.trans quoteStep
(unaryFrameQuoteScanSteps input) 1 _ afterScan _ hscan hboundary
let full := EvalsToInTime.trans quoteStep
(1 + unaryFrameQuoteScanSteps input) 1 _ afterBoundary _
throughBoundary hhalt
convert full using 1
· rw [encode_quotedUnaryFrameSingleton]
simp [List.reverse_append]
· simp [unaryFrameQuoteMarkedSteps, unaryFrameQuoteScanSteps]
omega
end CLRS.Chapter34.Turing.PolyBuilder
Source