Documentation

CslibFrontier.Computability.PolyTime.CSP.CrossAdjacentTransposition

A bounded positioned adjacent value transposition #

CrossInsertion.transposeAdjacent moves the suffix past the selected pair by actual RIGHT calls, executes the existing CROSS tail program, then moves the suffix back by actual LEFT calls. Invalid binary positions retain the ENTIRE input before insertion. The selected values are exchanged at fresh names, not by permuting the original names. Raw cycles are never canceled.

This original routing step toward #3091 uses one fixed actual gadget and its witness outside runtime. Sorting schedules, accumulated swap bounds, the native planarization compiler and full hardness remain open there.

Main definitions #

Main results #

def Cslib.Complexity.CSP.CrossInsertion.transposeAdjacent {Rel : Type} {ar : Rel → ℕ} {sem : Rel → List Bool → Bool} (g : Logic.PL.CSP.PPGadget ar sem BitString.cross) (w : OrderedBoundary.GadgetWitness g) (I : State Rel) (j : ℕ) :
State Rel

Select positions j,j+1 using a binary index. The suffix length funds both literal rotation loops. Invalid positions preserve the entire raw input before insertion.

theorem Cslib.Complexity.CSP.CrossInsertion.transposeAdjacent_invalid {Rel : Type} {ar : Rel → ℕ} {sem : Rel → List Bool → Bool} (g : Logic.PL.CSP.PPGadget ar sem BitString.cross) (w : OrderedBoundary.GadgetWitness g) (I : State Rel) (j : ℕ) (h : I.ports.length ≤ j + 1) :

Out-of-range binary positions preserve every row, name and raw table entry.

Every table check is derived from actual preceding accepted output, including both loops.

theorem Cslib.Complexity.CSP.CrossInsertion.ports_transposeAdjacent {Rel : Type} {ar : Rel → ℕ} {sem : Rel → List Bool → Bool} (g : Logic.PL.CSP.PPGadget ar sem BitString.cross) (w : OrderedBoundary.GadgetWitness g) (F : Logic.PL.CSP Rel ℕ) (L : List ℕ) (x y : ℕ) (R : List ℕ) (c : Graph.RotationCertificate) :
(transposeAdjacent g w { body := F, ports := L ++ [x, y] ++ R, rotation := c } L.length).ports = List.map (fun (x : ℕ) => 2 * x) L ++ [5, 7] ++ List.map (fun (x : ℕ) => 2 * x) R

The actual directed port word has fresh middle names carrying reversed values. Repeated names and malformed tables need no premise.

theorem Cslib.Complexity.CSP.CrossInsertion.transposeAdjacent_tail {Rel : Type} {ar : Rel → ℕ} {sem : Rel → List Bool → Bool} (g : Logic.PL.CSP.PPGadget ar sem BitString.cross) (w : OrderedBoundary.GadgetWitness g) (F : Logic.PL.CSP Rel ℕ) (L : List ℕ) (x y : ℕ) (c : Graph.RotationCertificate) :
transposeAdjacent g w { body := F, ports := L ++ [x, y], rotation := c } L.length = transposeTail g w { body := F, ports := L ++ [x, y], rotation := c }

A tail position executes exactly the old tail primitive, including its complete table.

theorem Cslib.Complexity.CSP.CrossInsertion.recover_transposeAdjacent {Rel : Type} {ar : Rel → ℕ} {sem : Rel → List Bool → Bool} (g : Logic.PL.CSP.PPGadget ar sem BitString.cross) (w : OrderedBoundary.GadgetWitness g) (F : Logic.PL.CSP Rel ℕ) (L : List ℕ) (x y : ℕ) (R : List ℕ) (c : Graph.RotationCertificate) (τ : ℕ → Bool) (ht : Logic.PL.CSP.eval sem τ (transposeAdjacent g w { body := F, ports := L ++ [x, y] ++ R, rotation := c } L.length).body = true) :
Logic.PL.CSP.eval sem (fun (z : ℕ) => τ (2 * z)) F = true ∧ List.map τ (transposeAdjacent g w { body := F, ports := L ++ [x, y] ++ R, rotation := c } L.length).ports = List.map (fun (z : ℕ) => τ (2 * z)) L ++ [τ (2 * y), τ (2 * x)] ++ List.map (fun (z : ℕ) => τ (2 * z)) R

Recover the source assignment on EVERY old even name from one satisfying output, and recover the complete directed swapped word. No checker or syntax premise is needed.

theorem Cslib.Complexity.CSP.CrossInsertion.eval_transposeAdjacent_iff {Rel : Type} {ar : Rel → ℕ} {sem : Rel → List Bool → Bool} (g : Logic.PL.CSP.PPGadget ar sem BitString.cross) (w : OrderedBoundary.GadgetWitness g) (F : Logic.PL.CSP Rel ℕ) (L : List ℕ) (x y : ℕ) (R : List ℕ) (c : Graph.RotationCertificate) (σ : ℕ → Bool) :
Logic.PL.CSP.eval sem σ F = true ↔ ∃ (τ : ℕ → Bool), Logic.PL.CSP.eval sem τ (transposeAdjacent g w { body := F, ports := L ++ [x, y] ++ R, rotation := c } L.length).body = true ∧ (∀ (z : ℕ), τ (2 * z) = σ z) ∧ List.map τ (transposeAdjacent g w { body := F, ports := L ++ [x, y] ++ R, rotation := c } L.length).ports = List.map σ L ++ [σ y, σ x] ++ List.map σ R

Exact extension at a valid selected pair. The fresh output word carries y,x, and all old even names, including unused names, agree with the original assignment.

Wrong-arity old constraints stay wrong-arity; the actual CROSS supplies the new scopes.

Total raw component counts. Only a successful guard inserts the actual gadget; invalid requests preserve every component and never change the boundary length.

Each successful request appends the fixed template's relation-symbol word after all old rows; invalid requests preserve the word exactly. This includes arbitrary encoded Rel.

theorem Cslib.Complexity.CSP.CrossInsertion.name_width_transposeAdjacent_le {Rel : Type} {ar : Rel → ℕ} {sem : Rel → List Bool → Bool} (g : Logic.PL.CSP.PPGadget ar sem BitString.cross) (w : OrderedBoundary.GadgetWitness g) (F : Logic.PL.CSP Rel ℕ) (L : List ℕ) (x y : ℕ) (R : List ℕ) (c : Graph.RotationCertificate) (W : ℕ) (hW : ∀ z ∈ F.vars ++ (L ++ [x, y] ++ R), z.size ≤ W) (z : ℕ) :
z ∈ (transposeAdjacent g w { body := F, ports := L ++ [x, y] ++ R, rotation := c } L.length).body.vars ++ (transposeAdjacent g w { body := F, ports := L ++ [x, y] ++ R, rotation := c } L.length).ports → z.size ≤ max (W + 1) (2 * g.numAux + 7).size

One positioned operation adds at most one bit to old names. Rotations preserve name multisets; no accumulated repeated-swap bound is asserted.

Plain polynomial time on EVERY raw state and binary position for any encoded alphabet. The position is capped by actual unary port length before either loop. Reachable rotation states have an internal component/bit-width budget; no growth provider is a hypothesis.

A valid raw step emits the actual dart count, with entry widths reset by its final restriction. Arbitrary malformed source entries require no input bound or acceptance.