Skip to content
Browse chapters
Imports

Total concrete CLIQUE-to-VERTEX-COVER machine

This module assembles the raw well-formedness bit and the normalized complement candidate, feeds both to the fixed guarded selector, and identifies the result with the semantic total reduction on every raw word.

noncomputable sectionnamespace CLRS.Chapter34.Turing.VertexCover.ComplementMachine.Totalopen _root_.Turingopen PolyBuilderopen NonedgeFilterdef normalizedComplement (input : List CliqueSym) : List CliqueSym := encodeCliqueInstance (SyntaxNormalizer.normalizedInstanceValue input).complementForVertexCoverdef selectorData (input : List CliqueSym) : Bool × List CliqueSym := (RawWellFormed.rawWellFormedPass input, normalizedComplement input)def flagPairLeft (input : List CliqueSym) : List (Option CliqueSym) := OptionPairLeft.format ((TM2Comp.boolEncoding (RawWellFormed.rawWellFormedPass input)).map bitSymbol)def candidatePairRight (input : List CliqueSym) : List (Option CliqueSym) := (normalizedComplement input).map sometheorem selectorInput_eq (input : List CliqueSym) : flagPairLeft input ++ candidatePairRight input = GuardSelector.inputEncoding (selectorData input) := by simp [flagPairLeft, candidatePairRight, GuardSelector.inputEncoding, selectorData, TM2Comp.boolEncoding, OptionPairLeft.format, pairEncoding]noncomputable def normalizedComplementComputableInPolyTime : TM2ComputableInPolyTime id id normalizedComplement := by let composed := TM2Comp.TM2ComputableInPolyTime.comp_scratch SyntaxNormalizer.computableInPolyTime TypedComplement.computableInPolyTime let machine := Classical.choice composed exact { tm := machine.tm inputAlphabet := machine.inputAlphabet outputAlphabet := machine.outputAlphabet time := machine.time outputsFun := fun input => by have output := machine.outputsFun input simpa [normalizedComplement, Function.comp_def] using output }noncomputable def rawWellFormedStreamComputableInPolyTime : TM2ComputableInPolyTime id id (fun input => TM2Comp.boolEncoding (RawWellFormed.rawWellFormedPass input)) := by let machine := RawWellFormed.computableInPolyTime exact { tm := machine.tm inputAlphabet := machine.inputAlphabet outputAlphabet := machine.outputAlphabet time := machine.time outputsFun := fun input => by have output := machine.outputsFun input simpa using output }noncomputable def flagPairLeftComputableInPolyTime : TM2ComputableInPolyTime id id flagPairLeft := by let taggedExists := TM2Comp.TM2ComputableInPolyTime.comp_scratch rawWellFormedStreamComputableInPolyTime (listMap_computableInPolyTime bitSymbol) let tagged := Classical.choice taggedExists let pairedExists := TM2Comp.TM2ComputableInPolyTime.comp_scratch tagged (OptionPairLeft.computableInPolyTime CliqueSym) change TM2ComputableInPolyTime id id (fun input => OptionPairLeft.format ((TM2Comp.boolEncoding (RawWellFormed.rawWellFormedPass input)).map bitSymbol)) simpa [Function.comp_def] using Classical.choice pairedExistsnoncomputable def candidatePairRightComputableInPolyTime : TM2ComputableInPolyTime id id candidatePairRight := by let composed := TM2Comp.TM2ComputableInPolyTime.comp_scratch normalizedComplementComputableInPolyTime (GeneralCliqueVerifier.AdjacencyPipeline.someMapComputableInPolyTime CliqueSym) exact Classical.choice composed

A fixed machine assembles exactly the tagged selector input from the same raw source word.

noncomputable def selectorDataComputableInPolyTime : TM2ComputableInPolyTime id GuardSelector.inputEncoding selectorData := by let joined := fixedPairSameInputConcat_computableInPolyTime GeneralCliqueVerifier.AdjacencyPipeline.encodeOptionCliqueSymPair GeneralCliqueVerifier.AdjacencyPipeline.decodeOptionCliqueSymPair GeneralCliqueVerifier.AdjacencyPipeline.decode_encodeOptionCliqueSymPair flagPairLeftComputableInPolyTime candidatePairRightComputableInPolyTime exact { tm := joined.tm inputAlphabet := joined.inputAlphabet outputAlphabet := joined.outputAlphabet time := joined.time outputsFun := fun input => by have output := joined.outputsFun input rw [selectorInput_eq input] at output simpa using output }

The selector formulation agrees with the public total raw reduction on parser failures, ill-formed decoded graphs, and well-formed graphs.

The textbook total CLIQUE-to-VERTEX-COVER reduction is computed by one fixed polynomial-time TM2 on all raw graph strings.

noncomputable def computableInPolyTime : TM2ComputableInPolyTime id id cliqueToVertexCoverMap := by let composed := TM2Comp.TM2ComputableInPolyTime.comp_scratch selectorDataComputableInPolyTime GuardSelector.computableInPolyTime let machine := Classical.choice composed exact { tm := machine.tm inputAlphabet := machine.inputAlphabet outputAlphabet := machine.outputAlphabet time := machine.time outputsFun := fun input => by have output := machine.outputsFun input simp only [Function.comp_apply, id_eq] at output rw [selectedOutput_eq_reduction input] at output simpa using output }
end CLRS.Chapter34.Turing.VertexCover.ComplementMachine.Total