Native selected-row interface for cross-composition collision verifiers
DefinitionCrossNativeSelectedRecordABIcomplexityfixed-parameter-tractability
A common Cook–Levin machine interface for selected-row collision checks in a cross-composition pipeline. It specifies the supplied equivalence, composition and kernel programs; the serialized advice and mask certificate; and the prepared tape configuration, time bound and exact verdict required from the selected-row stage. It does not assert the existence of a machine implementing that stage.
Definition code
import Mathlib.Data.Finset.Card
import Mathlib.Data.Finset.Lattice.Fold
import Mathlib.Data.Nat.Log
import Mathlib.Data.List.Dedup
import Mathlib.Data.Fintype.Pi
import Mathlib.Data.Finset.Sort
import Mathlib.Data.List.Lex
import Mathlib.Algebra.BigOperators.Group.Finset.Basic
import Mathlib.Algebra.BigOperators.Group.Finset.Sigma
import Mathlib.Algebra.Order.BigOperators.Group.Finset
import Mathlib.Data.Finset.Card
import Mathlib.Data.Finset.Insert
import Mathlib.Data.Finset.Lattice.Fold
import Mathlib.Data.Finset.Max
import Mathlib.Data.Finset.Powerset
import Mathlib.Data.Finset.Range
import Mathlib.Data.Finset.SDiff
import Mathlib.Data.Nat.Size
import Mathlib.Tactic.NormNum
import Mathlib.Algebra.BigOperators.Group.List.Basic
import Mathlib.Data.Finset.Card
import Mathlib.Data.Finset.Sort
import Mathlib.Data.List.Lex
import Mathlib.Data.Fin.VecNotation
import Mathlib.Computability.RE
import Mathlib.Computability.Primrec.List
import Mathlib.Computability.TuringMachine.Computable
import Mathlib.Data.List.OfFn
import Mathlib.Data.Finset.Card
import Mathlib.Data.Finset.Sort
import Mathlib.Data.List.Lex
import Mathlib.Algebra.BigOperators.Group.List.Basic
import Mathlib.Data.Fintype.Fin
import Mathlib.Tactic.FinCases
import Mathlib.Data.Fintype.Sigma
import Mathlib.Data.Fintype.EquivFin
import Mathlib.Computability.TuringMachine.Computable
import Mathlib.Tactic.DeriveFintype
import Mathlib.Computability.TuringMachine.Computable
import Mathlib.Tactic.DeriveFintype
import Mathlib.Computability.TuringMachine.Computable
import Mathlib.Tactic.DeriveFintype
import Mathlib.Computability.TuringMachine.Computable
import Mathlib.Computability.TuringMachine.Computable
import Mathlib.Data.List.Dedup
import Mathlib.Data.List.Sort
import Mathlib.Tactic.DeriveFintype
import Mathlib.Computability.TuringMachine.Computable
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.DeriveFintype
import Mathlib.Computability.TuringMachine.StackTuringMachine
import Mathlib.Data.Finset.Max
import Mathlib.Data.Fintype.Prod
import Mathlib.Data.Fintype.Option
import Mathlib.Data.Fintype.EquivFin
import Mathlib.Data.Fintype.Sets
import Mathlib.Data.Fintype.Sum
import Definitions.Def_PermutationKernel_LowerBound_CrossComposition
import Definitions.Def_PermutationKernel_LowerBound_Kernel
import Definitions.Def_PermutationKernel_LowerBound_Advice
namespace PermutationKernel.LowerBound
/-- One-bit tag keeps the empty input separate from actual kernel instances,
without assuming the parameterized language contains a fixed NO instance. -/
def taggedClassCompress (compose kernel : Word → Word) (xs : List Word) : Word :=
if xs = [] then [false] else true :: kernel (compose (wordsCode xs))
end PermutationKernel.LowerBound
namespace PermutationKernel.LowerBound
end PermutationKernel.LowerBound
namespace PermutationKernel.LowerBound
def dedupTaggedClassCompress (compose kernel : Word → Word) (xs : List Word) : Word :=
taggedClassCompress compose kernel xs.dedup
end PermutationKernel.LowerBound
namespace PermutationKernel.LowerBound
end PermutationKernel.LowerBound
namespace PermutationKernel.LowerBound
end PermutationKernel.LowerBound
namespace PermutationKernel.LowerBound
end PermutationKernel.LowerBound
set_option autoImplicit false
open scoped BigOperators
namespace FPTCross.AdviceCover
end FPTCross.AdviceCover
set_option autoImplicit false
namespace PermutationKernel.LowerBound.CrossCollision
end PermutationKernel.LowerBound.CrossCollision
namespace PermutationKernel.LowerBound
end PermutationKernel.LowerBound
set_option autoImplicit false
namespace PermutationKernel.LowerBound
end PermutationKernel.LowerBound
namespace PermutationKernel.LowerBound
end PermutationKernel.LowerBound
namespace PermutationKernel.LowerBound
end PermutationKernel.LowerBound
set_option autoImplicit false
namespace FPTCross.AdviceCover.Packing
def countPrefix (n : ℕ) : List Bool := List.replicate n true ++ [false]
def encodeWord (w : List Bool) : List Bool := countPrefix w.length ++ w
def encodeSeq {α : Type} (encode : α → List Bool) (xs : List α) : List Bool :=
countPrefix xs.length ++ xs.flatMap encode
def encodeRecord : List (List Bool) → List Bool := encodeSeq encodeWord
def encodeAdvice : List (List (List Bool)) → List Bool := encodeSeq encodeRecord
end FPTCross.AdviceCover.Packing
namespace PermutationKernel.LowerBound.CrossCollision
/-- Ordered sublist selected by the mask. Malformed lengths are rejected by
the caller; truncation here keeps the helper total. -/
def pick : List Word → List Bool → List Word
| x :: xs, b :: bs => if b then x :: pick xs bs else pick xs bs
| _, _ => []
structure Certificate where
index : Nat
left : List Bool
right : List Bool
/-- Exact structural checks before running the compressed-output comparison.
No target-language decision is involved. -/
def atRecord (equiv : Word → Word → Bool) (compress : List Word → Word)
(x : Word) (records : List Word) (left right : List Bool) : Bool :=
left.length == records.length &&
right.length == records.length &&
(x :: records).all (fun a => (x :: records).all (equiv a)) &&
!(pick records right).isEmpty &&
(compress (x :: pick records left) == compress (pick records right))
/-- The row index and mask split point use the published unary code; the
two bit masks follow verbatim. This is the witness tape payload. -/
def certificateCode (c : Certificate) : Word :=
CookLevin.encodeNat c.index ++ pairCode c.left c.right
/-- Canonicalization on real checker inputs is a deduplication and lexicographic
merge sort, not an arbitrary choice of ordering from a finite set. -/
def canonicalWords (s : List Word) : List Word :=
s.dedup.mergeSort (fun a b => decide (a ≤ b))
end PermutationKernel.LowerBound.CrossCollision
namespace PermutationKernel.LowerBound
end PermutationKernel.LowerBound
namespace CookLevin
end CookLevin
namespace PermutationKernel.LowerBound
end PermutationKernel.LowerBound
namespace PermutationKernel.LowerBound
end PermutationKernel.LowerBound
namespace PermutationKernel.LowerBound
end PermutationKernel.LowerBound
namespace PermutationKernel.LowerBound.PreimageAdvice
end PermutationKernel.LowerBound.PreimageAdvice
namespace PermutationKernel.LowerBound.PreimageAdvice
end PermutationKernel.LowerBound.PreimageAdvice
namespace PermutationKernel.LowerBound
end PermutationKernel.LowerBound
set_option autoImplicit true
namespace PermutationKernel.LowerBound
end PermutationKernel.LowerBound
namespace PermutationKernel.LowerBound
open CookLevin
/-- An actual native program and its polynomial clock, not an oracle for its output. -/
structure CrossNativeProgram where
M : Machine
k : Nat
G : Nat
c : Nat
d : Nat
wf : TuringMachine k G M
namespace CrossNativeProgram
def time (P : CrossNativeProgram) (n : Nat) := polyBound P.c P.d n
def run (P : CrossNativeProgram) (x w : Word) (t : Nat) : Config :=
execute P.M (startConfig2 P.k (boolsToSymbols x) (boolsToSymbols w)) t
def transduce (P : CrossNativeProgram) (x : Word) : Word :=
outputOf P.k (P.run x [] (P.time x.length)) (P.time x.length + 2)
def verdict (P : CrossNativeProgram) (x w : Word) : Bool :=
symBool? (tapeFun (P.run x w (P.time (x.length + w.length))) (verdictTape P.k) 1) ==
some true
end CrossNativeProgram
/-- Concrete native suppliers together with the exact semantic promises, in separate
proof fields. In particular, the compression pass never queries `L` or `Q`. -/
structure CrossCompressorPipeline (L : Language) (Q : ParameterizedProblem) where
eqProgram : CrossNativeProgram
composeProgram : CrossNativeProgram
kernelProgram : CrossNativeProgram
R : Word → Word → Prop
equivR : Equivalence R
classC : Nat
classD : Nat
classBound : ∀ S : Finset Word,
(∀ x ∈ S, ∀ y ∈ S, x ≠ y → ¬ R x y) →
S.card ≤ polyBound classC classD (S.sup List.length)
eqDecides : ∀ x w : Word, DecidesIn eqProgram.M eqProgram.k
(boolsToSymbols x) (boolsToSymbols w) (eqProgram.time (x.length + w.length))
(eqProgram.verdict x w)
eqCorrect : ∀ x w, eqProgram.verdict x w = true ↔ R x w
composeHalts : ∀ x, (composeProgram.run x [] (composeProgram.time x.length)).1 =
composeProgram.M.length
kernelHalts : ∀ x, (kernelProgram.run x [] (kernelProgram.time x.length)).1 =
kernelProgram.M.length
c : Nat
d : Nat
a : Nat
b : Nat
composeCorrect : ∀ xs : List Word, xs ≠ [] →
(∀ x ∈ xs, ∀ y ∈ xs, R x y) →
∃ y k, composeProgram.transduce (wordsCode xs) = parameterCode y k ∧
(Q y k ↔ ∃ x ∈ xs, L x) ∧
k ≤ polyBound c d (maxWordLength xs + ceilLogTwo xs.length)
kernelCorrect : ∀ x k, ∃ y j,
kernelProgram.transduce (parameterCode x k) = parameterCode y j ∧
(Q x k ↔ Q y j) ∧ y.length ≤ polyBound a b k ∧ j ≤ polyBound a b k
namespace CrossCompressorPipeline
variable {L : Language} {Q : ParameterizedProblem}
def compress (P : CrossCompressorPipeline L Q) (xs : List Word) : Word :=
dedupTaggedClassCompress P.composeProgram.transduce P.kernelProgram.transduce xs
def equiv (P : CrossCompressorPipeline L Q) := P.eqProgram.verdict
open FPTCross.AdviceCover.Packing
end CrossCompressorPipeline
end PermutationKernel.LowerBound
namespace PermutationKernel.LowerBound
end PermutationKernel.LowerBound
namespace PermutationKernel.LowerBound.CrossCompressorPipeline
end PermutationKernel.LowerBound.CrossCompressorPipeline
namespace PermutationKernel.LowerBound.CrossCompressorPipeline
end PermutationKernel.LowerBound.CrossCompressorPipeline
namespace PermutationKernel.LowerBound
end PermutationKernel.LowerBound
namespace PermutationKernel.LowerBound.PreimageAdvice
end PermutationKernel.LowerBound.PreimageAdvice
namespace PermutationKernel.LowerBound.PreimageAdvice
end PermutationKernel.LowerBound.PreimageAdvice
namespace PermutationKernel.LowerBound
end PermutationKernel.LowerBound
set_option autoImplicit true
namespace Kernelization
end Kernelization
namespace Kernelization.NativeRepresentatives
end Kernelization.NativeRepresentatives
namespace Kernelization.Deadline
end Kernelization.Deadline
namespace Kernelization.OutputRouter
end Kernelization.OutputRouter
namespace Kernelization.OutputRouter.Frame
end Kernelization.OutputRouter.Frame
namespace FPTCross.NativeScan
end FPTCross.NativeScan
namespace FPTCross.NativeExtract
end FPTCross.NativeExtract
namespace FPTCross.NativeAdviceSkip
end FPTCross.NativeAdviceSkip
namespace FPTCross.NativeFrame
end FPTCross.NativeFrame
namespace CookLevin
end CookLevin
namespace CookLevin
end CookLevin
namespace FPTCross.NativeFrame
end FPTCross.NativeFrame
namespace FPTCross.NativeAdviceFrame
end FPTCross.NativeAdviceFrame
namespace CookLevin.CrossNativeBank
abbrev freshTape : Tape := (contents [], 0)
end CookLevin.CrossNativeBank
namespace FPTCross.NativeAdviceSeekFrame
end FPTCross.NativeAdviceSeekFrame
namespace FPTCross.NativeAdviceBounds
end FPTCross.NativeAdviceBounds
namespace FPTCross.NativeAdviceGuard
end FPTCross.NativeAdviceGuard
namespace FPTCross.NativeIndex
end FPTCross.NativeIndex
namespace FPTCross.NativeIndex
end FPTCross.NativeIndex
namespace CookLevin.ArbitraryFrame
end CookLevin.ArbitraryFrame
namespace FPTCross.NativeAdviceIndexed
end FPTCross.NativeAdviceIndexed
namespace FPTCross.NativeAdviceIndexed
end FPTCross.NativeAdviceIndexed
namespace FPTCross.NativeAdviceCursor
end FPTCross.NativeAdviceCursor
namespace FPTCross.NativeAdviceValidate
end FPTCross.NativeAdviceValidate
namespace FPTCross.NativeAdviceValidate
end FPTCross.NativeAdviceValidate
namespace FPTCross.NativeAdviceGuarded
end FPTCross.NativeAdviceGuarded
namespace FPTCross.NativeAdviceCursorGuarded
end FPTCross.NativeAdviceCursorGuarded
namespace FPTCross.NativeAdviceConcrete
end FPTCross.NativeAdviceConcrete
namespace FPTCross.NativeAdviceConcrete
end FPTCross.NativeAdviceConcrete
namespace FPTCross.NativeAdviceConcreteFrame
end FPTCross.NativeAdviceConcreteFrame
namespace FPTCross.NativeExtract
end FPTCross.NativeExtract
namespace CookLevin
end CookLevin
namespace CookLevin
end CookLevin
namespace CookLevin
end CookLevin
namespace CookLevin
end CookLevin
namespace CookLevin
end CookLevin
/-! Copy literal public input and witness into independent work tapes, keeping
both external tapes exactly as they were at canonical entry. -/
namespace CookLevin
end CookLevin
namespace CookLevin
end CookLevin
namespace FPTCross.NativeExtract
end FPTCross.NativeExtract
namespace CookLevin
end CookLevin
namespace CookLevin
end CookLevin
namespace CookLevin
end CookLevin
namespace FPTCross.NativeSplitReduce
end FPTCross.NativeSplitReduce
namespace FPTCross.NativeOuterGuard
end FPTCross.NativeOuterGuard
namespace FPTCross.NativeGuardSplitReduce
end FPTCross.NativeGuardSplitReduce
namespace FPTCross.NativeGuardAdviceCopy
end FPTCross.NativeGuardAdviceCopy
namespace FPTCross.NativeGuardAdviceSelectorEntry
end FPTCross.NativeGuardAdviceSelectorEntry
namespace FPTCross.NativeFramedVerifier
end FPTCross.NativeFramedVerifier
namespace FPTCross.NativeFinalVerifierBank
end FPTCross.NativeFinalVerifierBank
namespace FPTCross.NativeAdviceConcreteBranches
end FPTCross.NativeAdviceConcreteBranches
namespace FPTCross.NativeAdviceConcreteBranches
end FPTCross.NativeAdviceConcreteBranches
namespace FPTCross.NativeAdviceSuccessDispatch
end FPTCross.NativeAdviceSuccessDispatch
namespace FPTCross.NativeAdviceSuccessDispatch
end FPTCross.NativeAdviceSuccessDispatch
namespace FPTCross.NativeAdviceSuccessDispatch
end FPTCross.NativeAdviceSuccessDispatch
namespace FPTCross.NativeAdviceVerifierLocal
end FPTCross.NativeAdviceVerifierLocal
namespace FPTCross.NativeAdviceVerifierLocal
end FPTCross.NativeAdviceVerifierLocal
namespace FPTCross.NativeAdviceVerifierLocal
end FPTCross.NativeAdviceVerifierLocal
namespace FPTCross.NativeRectangularBudget
end FPTCross.NativeRectangularBudget
namespace FPTCross.NativeOfficialComposer
end FPTCross.NativeOfficialComposer
namespace FPTCross.NativeOfficialSelection
end FPTCross.NativeOfficialSelection
namespace CookLevin
end CookLevin
namespace FPTCross.NativeOfficialSelection
end FPTCross.NativeOfficialSelection
namespace FPTCross.NativeLinearWitnessGate
end FPTCross.NativeLinearWitnessGate
namespace FPTCross.NativeLinearWitnessGate
end FPTCross.NativeLinearWitnessGate
namespace FPTCross.NativeLinearWitnessGate
end FPTCross.NativeLinearWitnessGate
namespace FPTCross.NativeStructuralGate
end FPTCross.NativeStructuralGate
namespace FPTCross.NativeLinearWitnessGate
end FPTCross.NativeLinearWitnessGate
namespace FPTCross.NativeLinearWitnessGate
end FPTCross.NativeLinearWitnessGate
namespace FPTCross.NativeLinearWitnessGate
end FPTCross.NativeLinearWitnessGate
namespace PermutationKernel.LowerBound.PreimageAdvice
end PermutationKernel.LowerBound.PreimageAdvice
namespace FPTCross.NativeLinearPairEntry
open CookLevin CookLevin.CrossNativeBank
open FPTCross.NativeExtract FPTCross.NativeScan
open PermutationKernel.LowerBound (Word pairCode)
abbrev width (a : Nat) := 9+a
end FPTCross.NativeLinearPairEntry
namespace PermutationKernel.LowerBound
end PermutationKernel.LowerBound
namespace PermutationKernel.LowerBound
end PermutationKernel.LowerBound
namespace FPTCross.NativeNestedRow
open CookLevin PermutationKernel.LowerBound
open FPTCross.NativeScan FPTCross.NativeAdviceSkip
open FPTCross.NativeAdviceValidate
open FPTCross.AdviceCover.Packing
/-- Exact address of a selected row under the original public encoding. -/
def beforeRow (done : List (List Word)) (selected : List Word) (rest : List (List Word)) : Word :=
encodeNat (done ++ selected :: rest).length ++ done.flatMap encodeRecord
end FPTCross.NativeNestedRow
namespace FPTCross.NativeNestedSeek
end FPTCross.NativeNestedSeek
namespace FPTCross.NativeCertificateShape
end FPTCross.NativeCertificateShape
namespace FPTCross.NativeMaskParts
open CookLevin FPTCross.NativeScan FPTCross.NativeAdviceSkip
open FPTCross.NativeAdviceValidate
open PermutationKernel.LowerBound
open FPTCross.AdviceCover.Packing
abbrev framed (w : Word) := contents (boolsToSymbols w)
end FPTCross.NativeMaskParts
namespace FPTCross.NativeMaskStart
end FPTCross.NativeMaskStart
namespace FPTCross.NativeMaskGate
end FPTCross.NativeMaskGate
namespace FPTCross.NativeMaskFilter
end FPTCross.NativeMaskFilter
namespace FPTCross.NativeMaskFilter
end FPTCross.NativeMaskFilter
namespace FPTCross.NativeCertificateContract
end FPTCross.NativeCertificateContract
namespace FPTCross.NativeMaskFilterBank
end FPTCross.NativeMaskFilterBank
namespace FPTCross.NativeMaskStartFilter
end FPTCross.NativeMaskStartFilter
namespace FPTCross.NativeMaskExtractBank
end FPTCross.NativeMaskExtractBank
namespace FPTCross.NativeMaskPipeline
end FPTCross.NativeMaskPipeline
namespace FPTCross.NativeMaskGateBank
end FPTCross.NativeMaskGateBank
namespace FPTCross.NativeMaskGuarded
end FPTCross.NativeMaskGuarded
namespace FPTCross.NativeMaskSeam
end FPTCross.NativeMaskSeam
namespace FPTCross.NativeRowArityBank
end FPTCross.NativeRowArityBank
namespace FPTCross.NativeMaskTestPrep
end FPTCross.NativeMaskTestPrep
namespace FPTCross.NativeCertificateCursor
end FPTCross.NativeCertificateCursor
namespace FPTCross.NativeMaskFullCheck
end FPTCross.NativeMaskFullCheck
namespace FPTCross.NativeCertificateGuard
end FPTCross.NativeCertificateGuard
namespace FPTCross.NativeNestedRaw
end FPTCross.NativeNestedRaw
namespace FPTCross.NativeNestedValidate
end FPTCross.NativeNestedValidate
namespace FPTCross.NativeNestedGuard
end FPTCross.NativeNestedGuard
namespace FPTCross.NativeCanonicalHeader
end FPTCross.NativeCanonicalHeader
namespace FPTCross.NativeBankRun
end FPTCross.NativeBankRun
namespace FPTCross.NativeDirectWord
end FPTCross.NativeDirectWord
namespace FPTCross.NativeDirectMembership
end FPTCross.NativeDirectMembership
namespace FPTCross.NativeDirectBank
end FPTCross.NativeDirectBank
namespace FPTCross.NativeDirectPriorityGate
end FPTCross.NativeDirectPriorityGate
namespace FPTCross.NativeDirectPriority
end FPTCross.NativeDirectPriority
namespace FPTCross.NativeNestedSeekBank
end FPTCross.NativeNestedSeekBank
namespace FPTCross.NativeNestedSeekGuard
end FPTCross.NativeNestedSeekGuard
namespace FPTCross.NativeCollisionEntry
end FPTCross.NativeCollisionEntry
namespace FPTCross.NativeBothStrict
end FPTCross.NativeBothStrict
namespace FPTCross.NativeDirectSelect
end FPTCross.NativeDirectSelect
namespace FPTCross.NativePriorityChain
end FPTCross.NativePriorityChain
namespace FPTCross.NativeBulkDuplicate
end FPTCross.NativeBulkDuplicate
namespace FPTCross.NativePriorityCursors
end FPTCross.NativePriorityCursors
namespace FPTCross.NativeInitialCopies
open CookLevin
open CookLevin.CrossNativeBank (freshTape)
open NativeBulkDuplicate
open NativeMaskParts (framed)
open PermutationKernel.LowerBound
variable {N G : Nat}
structure Routes (N : Nat) where
x : Fin N
a : Fin N
w : Fin N
dx : List (Fin N)
da : List (Fin N)
dw : List (Fin N)
def Routes.fresh (p : Routes N) (i : Fin N) := i ∈ p.dx ++ p.da ++ p.dw
end FPTCross.NativeInitialCopies
namespace FPTCross.NativePreparedPriority
open CookLevin CookLevin.ArbitraryFrame
open NativeMaskParts (framed)
open NativeInitialCopies (Routes )
open CookLevin.CrossNativeBank (freshTape)
open PermutationKernel.LowerBound
open FPTCross.AdviceCover.Packing
variable {N G : Nat}
structure Layout (N : Nat) where
cp : Routes N
a : Fin 5 ↪ Fin N
w : Fin 4 ↪ Fin N
p : Fin 4 ↪ Fin N
q : Fin 4 ↪ Fin N
m : Fin 3 ↪ Fin N
out : Fin N
def quiet (l : Layout N) (j : Fin N) : Prop :=
(¬∃ i, l.a i = j) ∧ (¬∃ i, l.w i = j) ∧
(¬∃ i, l.p i = j) ∧ (¬∃ i, l.q i = j) ∧ j ≠ l.m 1 ∧ j ≠ l.m 2
def remains (l : Layout N) (j : Fin N) : Prop := ¬l.cp.fresh j ∧ quiet l j
end FPTCross.NativePreparedPriority
namespace FPTCross.NativePortableContinuation
open CookLevin CookLevin.ArbitraryFrame PermutationKernel.LowerBound
open PermutationKernel.LowerBound.CrossCollision
open NativeMaskParts (framed)
open NativeNestedRow (beforeRow)
open FPTCross.AdviceCover.Packing (encodeAdvice)
variable {N G : Nat}
structure Ports (N : Nat) where
d : Fin 5 ↪ Fin N
p : Fin 5 ↪ Fin N
c : Fin 4 ↪ Fin N
dst : Fin N
d0 : ∀ i, (d i).val = 0 → i.val = 0
p0 : ∀ i, (p i).val = 0 → i.val = 0
c0 : ∀ i, (c i).val = 0 → i.val = 0
out0 : dst.val ≠ 0
directOut : ∀ i, d i ≠ dst
seekOut : ∀ i, p i ≠ dst
certOut : ¬∃ i, c i = dst
directSeek : ∀ i j, d i ≠ p j
directCert : ∀ i j, d i ≠ c j
share : c 3 = p 4
seekCert : ∀ j, j ≠ 4 → ¬∃ i, c i = p j
def quiet (p : Ports N) (j : Fin N) : Prop :=
(¬∃ i, p.d i = j) ∧ (¬∃ i, p.c i = j) ∧ (¬∃ i, p.p i = j)
/-- Portable continuation entry after the real priority/seek dispatcher.
The selected tape is the original packed advice at an interior row cursor.
All untouched auxiliary copies, seeds, and suffix reserves are available
by the frame, not asserted to have a new encoding. -/
structure Selected (p : Ports N) (rows : List (List Word))
(done : List (List Word)) (row : List Word) (rest : List (List Word))
(ts mid : Fin N → Tape) : Prop where
advice : mid (p.p 0) = (framed (encodeAdvice rows),(beforeRow done row rest).length+1)
scratch : mid (p.p 1) = (contents [],0)
count : mid (p.p 3) = (contents [],0)
index : mid (p.p 4) = (contents [],0)
frame : ∀ j, quiet p j → mid j = ts j
end FPTCross.NativePortableContinuation
namespace FPTCross.NativePortableContinuation
end FPTCross.NativePortableContinuation
namespace FPTCross.NativeLinearPreparedLayout
open CookLevin
open NativeLinearPairEntry (width)
open NativeInitialCopies (Routes)
open NativePreparedPriority (Layout)
variable {a : Nat} (ha : 30 ≤ a)
def index (i : Fin 38) : Fin (width a) :=
⟨i.val,by have := i.isLt; unfold width; omega⟩
def liftBank {k : Nat} (f : Fin k ↪ Fin 38) : Fin k ↪ Fin (width a) where
toFun i := index ha (f i)
inj' i j h := f.injective (Fin.ext (congrArg (fun j : Fin (width a) => j.val) h))
def adviceGuard : Fin 5 ↪ Fin 38 :=
⟨![9,10,11,12,13], by
intro i j h
fin_cases i <;> fin_cases j <;> first | rfl | contradiction⟩
def certGuard : Fin 4 ↪ Fin 38 :=
⟨![14,15,16,17], by
intro i j h
fin_cases i <;> fin_cases j <;> first | rfl | contradiction⟩
def cursorDirect : Fin 4 ↪ Fin 38 :=
⟨![18,19,20,21], by
intro i j h
fin_cases i <;> fin_cases j <;> first | rfl | contradiction⟩
def cursorSeek : Fin 4 ↪ Fin 38 :=
⟨![22,23,24,25], by
intro i j h
fin_cases i <;> fin_cases j <;> first | rfl | contradiction⟩
def queryCursor : Fin 3 ↪ Fin 38 :=
⟨![7,26,27], by
intro i j h
fin_cases i <;> fin_cases j <;> first | rfl | contradiction⟩
def memberBank : Fin 5 ↪ Fin 38 :=
⟨![18,26,28,29,30], by
intro i j h
fin_cases i <;> fin_cases j <;> first | rfl | contradiction⟩
def seekBank : Fin 5 ↪ Fin 38 :=
⟨![22,31,32,33,34], by
intro i j h
fin_cases i <;> fin_cases j <;> first | rfl | contradiction⟩
def indexBank : Fin 4 ↪ Fin 38 :=
⟨![35,36,37,34], by
intro i j h
fin_cases i <;> fin_cases j <;> first | rfl | contradiction⟩
def finalPort (n : Nat) : Fin (width n) :=
⟨verdictTape (width n),Nat.sub_lt ((Nat.add_pos_left (by decide : 0 < 9) n)) Nat.one_pos⟩
theorem verdict_outside (i : Fin 38) : index ha i ≠ finalPort a := by
intro h
have e := congrArg Fin.val h
change i.val = 9+a-1 at e
have := i.isLt
omega
def copies : Routes (width a) where
x := index ha 7
a := index ha 8
w := index ha 1
dx := [index ha 26]
da := [index ha 9,index ha 18,index ha 22]
dw := [index ha 14,index ha 35]
def core : Layout (width a) where
cp := copies ha
a := liftBank ha adviceGuard
w := liftBank ha certGuard
p := liftBank ha cursorDirect
q := liftBank ha cursorSeek
m := liftBank ha queryCursor
out := finalPort a
def direct : Fin 5 ↪ Fin (width a) := liftBank ha memberBank
def seek : Fin 5 ↪ Fin (width a) := liftBank ha seekBank
def cert : Fin 4 ↪ Fin (width a) := liftBank ha indexBank
theorem core_alignment :
direct ha 0 = (core ha).p 0 ∧
seek ha 0 = (core ha).q 0 ∧
direct ha 1 = (core ha).m 1 ∧
cert ha 0 ∈ (core ha).cp.dw ∧
cert ha 3 = seek ha 4 := by
refine ⟨rfl,rfl,rfl,?_,rfl⟩
change index ha 35 ∈ [index ha 14,index ha 35]
exact List.mem_cons_of_mem _ (List.mem_singleton_self _)
theorem direct_seek_separate (i j : Fin 5) : direct ha i ≠ seek ha j := by
intro h
have hV := congrArg (fun j : Fin (width a) => j.val) h
change (memberBank i).val = (seekBank j).val at hV
fin_cases i <;> fin_cases j <;> contradiction
theorem direct_cert_separate (i : Fin 5) (j : Fin 4) : direct ha i ≠ cert ha j := by
intro h
have hV := congrArg (fun j : Fin (width a) => j.val) h
change (memberBank i).val = (indexBank j).val at hV
fin_cases i <;> fin_cases j <;> contradiction
theorem seek_cert_separate (j : Fin 5) (hj : j ≠ 4) : ¬∃ i, cert ha i = seek ha j := by
rintro ⟨i,h⟩
have hV := congrArg (fun j : Fin (width a) => j.val) h
change (indexBank i).val = (seekBank j).val at hV
fin_cases i <;> fin_cases j <;> first | contradiction | exact hj rfl
def ports : NativePortableContinuation.Ports (width a) where
d := direct ha
p := seek ha
c := cert ha
dst := finalPort a
d0 i h := by
change (memberBank i).val = 0 at h
fin_cases i <;> contradiction
p0 i h := by
change (seekBank i).val = 0 at h
fin_cases i <;> contradiction
c0 i h := by
change (indexBank i).val = 0 at h
fin_cases i <;> contradiction
out0 := by
change 9+a-1 ≠ 0
omega
directOut i := verdict_outside ha (memberBank i)
seekOut i := verdict_outside ha (seekBank i)
certOut := by rintro ⟨i,h⟩; exact verdict_outside ha (indexBank i) h
directSeek := direct_seek_separate ha
directCert := direct_cert_separate ha
share := (core_alignment ha).2.2.2.2
seekCert := seek_cert_separate ha
end FPTCross.NativeLinearPreparedLayout
namespace FPTCross.NativeLinearPreparedLayout
end FPTCross.NativeLinearPreparedLayout
namespace FPTCross.NativeLinearPreparedLayout
end FPTCross.NativeLinearPreparedLayout
namespace FPTCross.NativeLinearPreparedLayout
open CookLevin PermutationKernel.LowerBound
open CookLevin.CrossNativeBank (freshTape)
open NativeMaskParts (framed)
open NativeLinearPairEntry (width)
open NativePortableContinuation
open PermutationKernel.LowerBound.CrossCollision
open FPTCross.AdviceCover.Packing (encodeAdvice)
section
variable {a : Nat} (ha : 30 ≤ a)
/-- The exact last machine obligation: on the selected cursor and its
physical frame, the actual V implements the native record test. This does
not assume any tape is silently initialized or any row has been copied. -/
def VerifiedSelected (V : Machine) (c d : Nat) (equiv : Word → Word → Bool)
(compress : List Word → Word) : Prop :=
∀ (x : Word) (rows : List (List Word)) (cert : Certificate)
(ts tm : Fin (width a) → Tape)
(done : List (List Word)) (row : List Word) (rest : List (List Word))
(mid : Fin (width a) → Tape),
rows = done++row::rest → cert.index = done.length →
ts (index ha 7) = (framed x,0) →
ts (index ha 8) = (framed (encodeAdvice rows),0) →
ts (index ha 1) = (framed (certificateCode cert),0) →
(∀ i : Fin (width a), 9 ≤ i.val → ts i = freshTape) →
(∀ j, NativePreparedPriority.remains (core ha) j → tm j = ts j) →
Selected (ports ha) rows done row rest tm mid →
∃ t ≤ polyBound c d ((pairCode x (encodeAdvice rows)).length+(certificateCode cert).length),
let o := execute V (0,List.ofFn mid) t
o.1 = V.length ∧ tapeFun o (finalPort a).val 1 =
boolSym (atRecord equiv (fun s => compress (canonicalWords s)) x row cert.left cert.right)
end
end FPTCross.NativeLinearPreparedLayout
namespace PermutationKernel.LowerBound
end PermutationKernel.LowerBound
namespace FPTCross.NativeSelectedPolynomial
end FPTCross.NativeSelectedPolynomial
namespace FPTCross.NativeLinearPreparedLayout
end FPTCross.NativeLinearPreparedLayout
/-! A two-stack representation for the actual left-bounded Cook–Levin tape.
The action implementation uses only head reads and constant many stack edits. -/
namespace CookLevin.KernelTapeZipper
end CookLevin.KernelTapeZipper
namespace CookLevin.KernelTapeZipper
end CookLevin.KernelTapeZipper
set_option backward.isDefEq.respectTransparency false
namespace CookLevin.KernelTapeZipper.TM2
end CookLevin.KernelTapeZipper.TM2
/-! Fixed-family native TM2 implementation of simultaneous head gathering. -/
namespace CookLevin.KernelTapeZipper.TM2.Gather
end CookLevin.KernelTapeZipper.TM2.Gather
namespace CookLevin.KernelTapeZipper.TM2.Gather.Init
end CookLevin.KernelTapeZipper.TM2.Gather.Init
namespace CookLevin.KernelTapeZipper.TM2.Gather.Merge
end CookLevin.KernelTapeZipper.TM2.Gather.Merge
set_option backward.isDefEq.respectTransparency false
namespace FPTCross.TM2LexCompare
end FPTCross.TM2LexCompare
set_option backward.isDefEq.respectTransparency false
namespace FPTCross.TM2AdjacentDedup
end FPTCross.TM2AdjacentDedup
set_option backward.isDefEq.respectTransparency false
namespace FPTCross.TM2FrameCursor
end FPTCross.TM2FrameCursor
set_option backward.isDefEq.respectTransparency false
namespace FPTCross.TM2FrameEmit
end FPTCross.TM2FrameEmit
set_option backward.isDefEq.respectTransparency false
namespace FPTCross.TM2DedupLoop
end FPTCross.TM2DedupLoop
set_option backward.isDefEq.respectTransparency false
namespace FPTCross.TM2StableInsert
end FPTCross.TM2StableInsert
set_option backward.isDefEq.respectTransparency false
namespace FPTCross.TM2CanonicalSort
end FPTCross.TM2CanonicalSort
namespace Kernelization.ClockedStack
end Kernelization.ClockedStack
/-!
Normalize a Mathlib TM2 controller-step into one primitive per micro-step. A micro-step never
opens more than one statement constructor; terminal micro-steps return a label or halt.
The depth of the syntax tree bounds the number of micro-steps, including the return.
-/
namespace FPTKernelStmtFinite
end FPTKernelStmtFinite
namespace Kernelization.RequestCook
end Kernelization.RequestCook
namespace Kernelization.CookMacroScheduler
end Kernelization.CookMacroScheduler
set_option backward.isDefEq.respectTransparency false
namespace FPTCross.CookCanonicalSort
end FPTCross.CookCanonicalSort
namespace FPTCross.TM2CanonicalSeam
end FPTCross.TM2CanonicalSeam
namespace CookLevin.NativeJump
end CookLevin.NativeJump
namespace Kernelization.MappedStartup
end Kernelization.MappedStartup
namespace FPTCross.RowCodec
end FPTCross.RowCodec
namespace FPTCross.RowCodec
end FPTCross.RowCodec
namespace FPTCross.RowCodec
end FPTCross.RowCodec
namespace FPTCross.RowCodec
end FPTCross.RowCodec
namespace FPTCross.RowCodec
end FPTCross.RowCodec
namespace FPTCross.FrameSerializer
end FPTCross.FrameSerializer
namespace FPTCross.FrameSerializer
end FPTCross.FrameSerializer
namespace FPTCross.JoinedCanonical
end FPTCross.JoinedCanonical
namespace FPTCross.JoinedCanonical
end FPTCross.JoinedCanonical
namespace FPTCross.OfficialOutput
end FPTCross.OfficialOutput
namespace Kernelization.StopCook
end Kernelization.StopCook
namespace Kernelization.StopCook
end Kernelization.StopCook
namespace FPTCross.CanonClosedPipeline
end FPTCross.CanonClosedPipeline
set_option maxRecDepth 10000
namespace FPTCross.CanonClosedPipeline
end FPTCross.CanonClosedPipeline
namespace FPTCross.CanonClosedPipeline
end FPTCross.CanonClosedPipeline
namespace FPTCross.CanonClosedPipeline
end FPTCross.CanonClosedPipeline
namespace FPTCross.CanonClosedPipeline
end FPTCross.CanonClosedPipeline
namespace CookLevin
end CookLevin
namespace CookLevin
end CookLevin
namespace CookLevin
end CookLevin
namespace CookLevin
end CookLevin
namespace CookLevin
end CookLevin
namespace FPTCross.NativeSuppliedCompressor
end FPTCross.NativeSuppliedCompressor
namespace FPTCross.CanonicalBank
end FPTCross.CanonicalBank
namespace FPTCross.CanonicalBank
end FPTCross.CanonicalBank
namespace FPTCross.NativeWordEquality
end FPTCross.NativeWordEquality
namespace FPTCross.NativeTwoCompressors
end FPTCross.NativeTwoCompressors
namespace FPTCross.NativePreparedCollision
end FPTCross.NativePreparedCollision
namespace FPTCross.NativePreparedCollision
end FPTCross.NativePreparedCollision
namespace FPTCross.NativePreparedCollision
end FPTCross.NativePreparedCollision
namespace FPTCross.NativePreparedCollision
end FPTCross.NativePreparedCollision
namespace FPTCross.NativeMaskCollisionTail
end FPTCross.NativeMaskCollisionTail
namespace FPTCross.NativePreparedCollision
end FPTCross.NativePreparedCollision
namespace FPTCross.NativeMaskCollisionTail
end FPTCross.NativeMaskCollisionTail
namespace FPTCross.NativeMaskClassBranch
end FPTCross.NativeMaskClassBranch
namespace FPTCross.NativeFilterMaskCopies
end FPTCross.NativeFilterMaskCopies
namespace FPTCross.NativeFilterRowCopies
end FPTCross.NativeFilterRowCopies
namespace FPTCross.NativeFilterSeed
end FPTCross.NativeFilterSeed
namespace FPTCross.NativeFilterReady
end FPTCross.NativeFilterReady
namespace FPTCross.NativeFixedFilterWiring
end FPTCross.NativeFixedFilterWiring
/-! Literal Cook–Levin scratch tape binary clock. No tape initialization
or caller dispatch is implicit in these lemmas. -/
namespace CookLevin.KernelClockBits
end CookLevin.KernelClockBits
/-! A native radix digit on a marked Cook–Levin tape. Its head position is the
digit; in particular cell zero is itself digit position zero. -/
namespace CookLevin.KernelOdometer
end CookLevin.KernelOdometer
namespace FPTCross.NativeSameClassLoop
end FPTCross.NativeSameClassLoop
namespace FPTCross.NativeSameClassLoop
end FPTCross.NativeSameClassLoop
namespace FPTCross.NativeSameClassLoop
end FPTCross.NativeSameClassLoop
namespace FPTCross.NativeSameClassLoop
end FPTCross.NativeSameClassLoop
namespace FPTCross.NativeSameClassLoop
end FPTCross.NativeSameClassLoop
namespace FPTCross.NativePairIndexCursor
end FPTCross.NativePairIndexCursor
namespace FPTCross.NativePairExtract
end FPTCross.NativePairExtract
namespace FPTCross.NativePairExtract
end FPTCross.NativePairExtract
namespace FPTCross.NativePairExtract
end FPTCross.NativePairExtract
namespace FPTCross.NativePairExtract
end FPTCross.NativePairExtract
namespace FPTCross.NativePairExtract
end FPTCross.NativePairExtract
namespace FPTCross.NativePairBankClear
end FPTCross.NativePairBankClear
namespace FPTCross.NativePairShadow
end FPTCross.NativePairShadow
namespace FPTCross.NativePairShadow
end FPTCross.NativePairShadow
namespace FPTCross.NativePairContract
end FPTCross.NativePairContract
namespace FPTCross.NativePairRestore
end FPTCross.NativePairRestore
namespace FPTCross.NativePairContract
end FPTCross.NativePairContract
namespace FPTCross.NativePairContract
end FPTCross.NativePairContract
namespace FPTCross.NativePairContract
end FPTCross.NativePairContract
namespace FPTCross.NativePairContract
end FPTCross.NativePairContract
namespace FPTCross.NativePairFlag
end FPTCross.NativePairFlag
namespace FPTCross.NativePairContract
end FPTCross.NativePairContract
namespace FPTCross.NativePairContract
end FPTCross.NativePairContract
namespace FPTCross.NativePairContract
end FPTCross.NativePairContract
namespace FPTCross.NativePairContract
end FPTCross.NativePairContract
namespace FPTCross.NativePairContract
end FPTCross.NativePairContract
namespace CookLevin.PairTapeMap
end CookLevin.PairTapeMap
namespace CookLevin.PairTapeMap
end CookLevin.PairTapeMap
namespace CookLevin.PairTapeMap
end CookLevin.PairTapeMap
namespace CookLevin.PairTapeMap
end CookLevin.PairTapeMap
namespace CookLevin.PairRadius
end CookLevin.PairRadius
namespace CookLevin.PairRadius
end CookLevin.PairRadius
namespace CookLevin.PairTapeMap
end CookLevin.PairTapeMap
namespace CookLevin.PairTapeMap
end CookLevin.PairTapeMap
namespace CookLevin.PairRadius
end CookLevin.PairRadius
namespace FPTCross.NativePairExtract
end FPTCross.NativePairExtract
namespace CookLevin.PairTapeMap
end CookLevin.PairTapeMap
namespace CookLevin.PairTapeMap
end CookLevin.PairTapeMap
namespace CookLevin.PairTapeMap
end CookLevin.PairTapeMap
namespace CookLevin.PairTapeMap
end CookLevin.PairTapeMap
namespace CookLevin.PairTapeMap
end CookLevin.PairTapeMap
namespace CookLevin.PairTapeMap
end CookLevin.PairTapeMap
namespace CookLevin.PairTapeMap
end CookLevin.PairTapeMap
namespace FPTCross.NativeRightMirror
end FPTCross.NativeRightMirror
namespace FPTCross.NativeSelectedRowCopy
end FPTCross.NativeSelectedRowCopy
namespace FPTCross.NativeStandaloneRow
end FPTCross.NativeStandaloneRow
namespace FPTCross.NativeStandaloneRowBank
end FPTCross.NativeStandaloneRowBank
namespace FPTCross.NativeMaskSameClassReady
end FPTCross.NativeMaskSameClassReady
namespace FPTCross.NativeFixedMaskReady
end FPTCross.NativeFixedMaskReady
namespace FPTCross.NativePeekArity
end FPTCross.NativePeekArity
namespace FPTCross.NativeFixedMaskPrep
end FPTCross.NativeFixedMaskPrep
namespace FPTCross.NativeFrame
end FPTCross.NativeFrame
namespace FPTCross.NativePrependQuery
end FPTCross.NativePrependQuery
namespace FPTCross.NativePrependQueryBank
end FPTCross.NativePrependQueryBank
namespace FPTCross.NativeSelectedCollisionSetup
end FPTCross.NativeSelectedCollisionSetup
namespace FPTCross.NativeSelectedMaskBoundary
end FPTCross.NativeSelectedMaskBoundary
namespace FPTCross.NativeSelectedMaskBoundary
end FPTCross.NativeSelectedMaskBoundary
namespace FPTCross.NativeSelectedBank
end FPTCross.NativeSelectedBank
namespace CookLevin
end CookLevin
namespace FPTCross.NativeSelectedBank
end FPTCross.NativeSelectedBank
namespace FPTCross.NativeSelectedBank
end FPTCross.NativeSelectedBank
namespace FPTCross.NativeSelectedBank
end FPTCross.NativeSelectedBank
namespace FPTCross.NativeSelectedBank
end FPTCross.NativeSelectedBank
namespace FPTCross.NativeSelectedPolynomial
end FPTCross.NativeSelectedPolynomial
Source
Formalization interface for the selected-advice collision check used in the Prove2Me proof of Bliznets, Cygan, Komosa and Mach, Kernelization Lower Bound for Permutation Pattern Matching, arXiv:1406.1158v2, Theorem 5, p. 3, https://arxiv.org/abs/1406.1158v2. Related cross-composition framework: Bodlaender, Jansen and Kratsch, STACS 2011, Definition 8 and Theorem 9, pp. 168–169, https://doi.org/10.4230/LIPIcs.STACS.2011.165. The native tape representation is a new formalization detail, not a statement attributed to the paper.