Skip to content
Browse chapters
Imports

Concrete three-way routing of transition-tail phases

Every phase coordinate is expanded to a tag and three fixed-width candidate payloads. The reusable router retains the narrowing prefix for tag zero, the final-conjunction suffix for tag one, and the equality invocation for every larger tag. This module connects that finite controller to the raw verifier input and proves the exact selected-field stream before identifying it with the canonical transition script in the following module.

noncomputable sectionnamespace CLRS.Chapter34.Turing.CookLevinopen PolyBuilder

One tag followed by the prefix, suffix, and equality candidate forms.

noncomputable def transitionTailPhaseTaggedForms (tm : _root_.Turing.FinTM2) : List AffineUnaryTripleForm := transitionEqCoordinateTagForm :: (transitionTailPrefixPhaseForms tm ++ transitionTailSuffixPhaseForms tm ++ transitionEqInvocationForms)
@[simp] theorem transitionTailPhaseTaggedForms_value (tm : _root_.Turing.FinTM2) (coordinate : AffineUnaryTripleSeed) : affineUnaryTripleMap (transitionTailPhaseTaggedForms tm) coordinate = coordinate.first :: (affineUnaryTripleMap (transitionTailPrefixPhaseForms tm) coordinate ++ affineUnaryTripleMap (transitionTailSuffixPhaseForms tm) coordinate ++ affineUnaryTripleMap transitionEqInvocationForms coordinate) := by simp [transitionTailPhaseTaggedForms, transitionEqCoordinateTagForm, affineUnaryTripleMap, affineUnaryTripleFormValue, List.map_append, List.append_assoc]theorem transitionTailPrefixPhaseDelimiters_nonempty (tm : _root_.Turing.FinTM2) : 0 < (transitionTailPrefixPhaseDelimiters tm).length := by simp [transitionTailPrefixPhaseDelimiters, transitionNarrowNotInvocationDelimiterTable]theorem transitionTailSuffixPhaseDelimiters_nonempty (tm : _root_.Turing.FinTM2) : 0 < (transitionTailSuffixPhaseDelimiters tm).length := by simp [transitionTailSuffixPhaseDelimiters]

Typed router row denoted by one phase coordinate.

Router rows for the complete raw-input phase-coordinate family.

noncomputable def verifierTransitionTailPhaseTaggedRows {Γ : Type} {L : Language Γ} (W : VerifierWitness L) (input : List Γ) : List (UnaryFrameThreeWayTaggedRow (transitionTailPrefixPhaseDelimiters W.machine.tm).length (transitionTailSuffixPhaseDelimiters W.machine.tm).length transitionEqInvocationDelimiterTable.length) := ((verifierTransitionRowSeeds W input).flatMap (transitionEqPhaseCoordinateSeeds W.machine.tm)).map (transitionTailPhaseTaggedRow W.machine.tm)

Ordinary unary source bytes obtained by applying the complete candidate form table to every phase coordinate.

noncomputable def verifierTransitionTailPhaseTaggedValueFrames {Γ : Type} {L : Language Γ} (W : VerifierWitness L) (input : List Γ) : List UnaryFrameSym := encodeUnaryFrame (affineUnaryTripleMapFamily (transitionTailPhaseTaggedForms W.machine.tm) ((verifierTransitionRowSeeds W input).flatMap (transitionEqPhaseCoordinateSeeds W.machine.tm)))
private theorem transitionTailPhaseTaggedValueEncoding (tm : _root_.Turing.FinTM2) (coordinates : List AffineUnaryTripleSeed) : encodeUnaryFrame (affineUnaryTripleMapFamily (transitionTailPhaseTaggedForms tm) coordinates) = encodeUnaryFrameThreeWayTaggedRowFamily (coordinates.map (transitionTailPhaseTaggedRow tm)) := by unfold affineUnaryTripleMapFamily encodeUnaryFrameThreeWayTaggedRowFamily rw [List.flatMap_map] unfold encodeUnaryFrame rw [List.flatMap_assoc] apply List.flatMap_congr intro coordinate _ rw [transitionTailPhaseTaggedForms_value] rfl

The affine-map source is literally the typed family encoding consumed by the finite router.

One fixed polynomial-time TM2 emits the three candidate payloads for every phase coordinate directly from the raw verifier word.

noncomputable def verifierTransitionTailPhaseTaggedValueFrames_computableInPolyTime {Γ : Type} {L : Language Γ} (W : VerifierWitness L) : _root_.Turing.TM2ComputableInPolyTime id id (verifierTransitionTailPhaseTaggedValueFrames W) := by let coordinates := verifierTransitionEqPhaseCoordinateFrameStream_computableInPolyTime W let structured : _root_.Turing.TM2ComputableInPolyTime id encodeAffineUnaryTripleSeedFamily (fun input => (verifierTransitionRowSeeds W input).flatMap (transitionEqPhaseCoordinateSeeds W.machine.tm)) := { tm := coordinates.tm inputAlphabet := coordinates.inputAlphabet outputAlphabet := coordinates.outputAlphabet time := coordinates.time outputsFun := fun input => by have run := coordinates.outputsFun input simpa only [id_eq, verifierTransitionEqPhaseCoordinateFrameStream_eq_seedEncoding W input] using run } let composed := _root_.Turing.TM2Comp.TM2ComputableInPolyTime.comp_scratch structured (affineUnaryTripleMapFamily_computableInPolyTime (transitionTailPhaseTaggedForms W.machine.tm)) let result := Classical.choice composed exact { tm := result.tm inputAlphabet := result.inputAlphabet outputAlphabet := result.outputAlphabet time := result.time outputsFun := fun input => by have run := result.outputsFun input simpa only [Function.comp_apply, id_eq, verifierTransitionTailPhaseTaggedValueFrames] using run }

Selected transition-tail fields after the concrete three-way router.

Exact typed semantics of the routed raw-input stream.

The complete selected phase stream is generated from the raw verifier word by one fixed polynomial-time TM2.

noncomputable def verifierTransitionTailPhaseRoutedInput_computableInPolyTime {Γ : Type} {L : Language Γ} (W : VerifierWitness L) : _root_.Turing.TM2ComputableInPolyTime id id (verifierTransitionTailPhaseRoutedInput W) := by let values := verifierTransitionTailPhaseTaggedValueFrames_computableInPolyTime W let router := rewriteUnaryFrameThreeWayTaggedRows_computableInPolyTime (transitionTailPrefixPhaseDelimiters W.machine.tm) (transitionTailSuffixPhaseDelimiters W.machine.tm) transitionEqInvocationDelimiterTable (transitionTailPrefixPhaseDelimiters_nonempty W.machine.tm) (transitionTailSuffixPhaseDelimiters_nonempty W.machine.tm) transitionEqInvocationDelimiterTable_nonempty let composed := _root_.Turing.TM2Comp.TM2ComputableInPolyTime.comp_scratch values router let result := Classical.choice composed exact { tm := result.tm inputAlphabet := result.inputAlphabet outputAlphabet := result.outputAlphabet time := result.time outputsFun := fun input => by have run := result.outputsFun input simpa only [Function.comp_def, verifierTransitionTailPhaseRoutedInput] using run }
end CLRS.Chapter34.Turing.CookLevin