Documentation

CslibFrontier.Logics.Propositional.CSP.Planar.Substitution.CopyPositions

Literal occurrence positions in fixed-gadget replacement #

Every local occurrence in a source constraint's template has exactly its actual prefix offset in the existing flat-mapped replacement body. The intervals are disjoint and exhaustive; repeated source constraints, repeated names and empty templates do not change their identity. No enumeration up to a variable name or supplied certificate entry is involved.

theorem Cslib.Complexity.CSP.GadgetRotation.vars_replaceGadgets {Src Rel : Type} (B : ℕ) (templates : Src → Logic.PL.CSP Rel (Bool × ℕ)) (F : Logic.PL.CSP Src ℕ) :
(Logic.PL.CSP.replaceGadgets B templates F).vars = List.flatMap (fun (x : Logic.PL.Constraint Src ℕ × ℕ) => match x with | ({ rel := relation, scope := scope }, i) => List.map (fun (p : Bool × ℕ) => if p.1 = true then 2 * (B * i + p.2) + 1 else 2 * scope.getD p.2 0) (templates relation).vars) (List.zipIdx F)

The replacement's variable word retains every instantiated template position in order.

theorem Cslib.Complexity.CSP.GadgetRotation.instantiatedPrefix_length {Src Rel : Type} (B : ℕ) (templates : Src → Logic.PL.CSP Rel (Bool × ℕ)) (F : Logic.PL.CSP Src ℕ) (i : ℕ) :
(List.flatMap (fun (x : Logic.PL.Constraint Src ℕ × ℕ) => match x with | ({ rel := relation, scope := scope }, i) => List.map (fun (p : Bool × ℕ) => if p.1 = true then 2 * (B * i + p.2) + 1 else 2 * scope.getD p.2 0) (templates relation).vars) (List.take i (List.zipIdx F))).length = occurrencePrefix templates F i

Instantiating the preceding templates preserves their exact occurrence-prefix length.

theorem Cslib.Complexity.CSP.GadgetRotation.copyIndex_lt {Src Rel : Type} (B : ℕ) (templates : Src → Logic.PL.CSP Rel (Bool × ℕ)) (F : Logic.PL.CSP Src ℕ) {i j : ℕ} (hi : i < List.length F) (hj : j < (templates F[i].rel).vars.length) :
occurrencePrefix templates F i + j < (Logic.PL.CSP.replaceGadgets B templates F).vars.length

Local template positions shift into the actual replacement's bounded occurrence word.

theorem Cslib.Complexity.CSP.GadgetRotation.getElem_vars_copyIndex {Src Rel : Type} (B : ℕ) (templates : Src → Logic.PL.CSP Rel (Bool × ℕ)) (F : Logic.PL.CSP Src ℕ) {i j : ℕ} (hi : i < List.length F) (hj : j < (templates F[i].rel).vars.length) :
(Logic.PL.CSP.replaceGadgets B templates F).vars[occurrencePrefix templates F i + j] = have p := (templates F[i].rel).vars[j]; if p.1 = true then 2 * (B * i + p.2) + 1 else 2 * F[i].scope.getD p.2 0

The actual target getter reads the selected original template occurrence after renaming. The equation is positional, so coincident source variables and duplicate rows remain distinct.

theorem Cslib.Complexity.CSP.GadgetRotation.copyIndex_injective {Src Rel : Type} (templates : Src → Logic.PL.CSP Rel (Bool × ℕ)) (F : Logic.PL.CSP Src ℕ) {i j k q : ℕ} (hi : i < List.length F) (hj : j < (templates F[i].rel).vars.length) (hk : k < List.length F) (hq : q < (templates F[k].rel).vars.length) (he : occurrencePrefix templates F i + j = occurrencePrefix templates F k + q) :
i = k ∧ j = q

Different source or local positions remain different literal target occurrences.

theorem Cslib.Complexity.CSP.GadgetRotation.exists_copyIndex {Src Rel : Type} (B : ℕ) (templates : Src → Logic.PL.CSP Rel (Bool × ℕ)) (F : Logic.PL.CSP Src ℕ) {index : ℕ} (hindex : index < (Logic.PL.CSP.replaceGadgets B templates F).vars.length) :
∃ (i : ℕ) (hi : i < List.length F), ∃ j < (templates F[i].rel).vars.length, index = occurrencePrefix templates F i + j

Every actual target occurrence comes from exactly one source copy and local position. In particular no auxiliary padding or unused template port creates a target occurrence.