Documentation

CslibFrontier.Logics.Propositional.CSP.Planar.Substitution.CopyOccurrences

Actual copied occurrences in the exact replacement body #

The positional map follows the existing template renaming, instantiation and flat-map in replaceGadgets. Its edge index is the already proved copy offset. Its constraint and argument coordinates retain the local body row and scope positions, including duplicate records.

def Cslib.Complexity.CSP.GadgetRotation.replacementOccurrence {Src Rel : Type} {arity : Rel → ℕ} {sem : Rel → List Bool → Bool} {srcArity : Src → ℕ} {srcSem : Src → List Bool → Bool} (gadgets : (r : Src) → Logic.PL.CSP.PPGadget arity sem (Logic.PL.CSP.booleanRelation srcArity srcSem r)) (B : ℕ) (F : Logic.PL.CSP Src ℕ) (i : Fin (List.length F)) (o : (gadgets F[↑i].rel).body.Occurrence) :
(Logic.PL.CSP.replaceGadgets B (fun (r : Src) => (gadgets r).template) F).Occurrence

Copy an actual local occurrence through the exact original replacement operation.

theorem Cslib.Complexity.CSP.GadgetRotation.incidenceEdgeIndex_replacementOccurrence {Src Rel : Type} {arity : Rel → ℕ} {sem : Rel → List Bool → Bool} {srcArity : Src → ℕ} {srcSem : Src → List Bool → Bool} (gadgets : (r : Src) → Logic.PL.CSP.PPGadget arity sem (Logic.PL.CSP.booleanRelation srcArity srcSem r)) (B : ℕ) (F : Logic.PL.CSP Src ℕ) (i : Fin (List.length F)) (o : (gadgets F[↑i].rel).body.Occurrence) :
incidenceEdgeIndex (replacementOccurrence gadgets B F i o) = occurrencePrefix (fun (r : Src) => (gadgets r).template) F ↑i + incidenceEdgeIndex o

The copied occurrence's edge index is the literal prefix offset used by the executed table. This identifies positions, without rank preservation assumptions about dense names.

theorem Cslib.Complexity.CSP.GadgetRotation.replacementOccurrence_constraint {Src Rel : Type} {arity : Rel → ℕ} {sem : Rel → List Bool → Bool} {srcArity : Src → ℕ} {srcSem : Src → List Bool → Bool} (gadgets : (r : Src) → Logic.PL.CSP.PPGadget arity sem (Logic.PL.CSP.booleanRelation srcArity srcSem r)) (B : ℕ) (F : Logic.PL.CSP Src ℕ) (i : Fin (List.length F)) (o : (gadgets F[↑i].rel).body.Occurrence) :
↑(replacementOccurrence gadgets B F i o).fst = (List.flatMap (fun (row : Logic.PL.Constraint Src ℕ) => (gadgets row.rel).template) (List.take (↑i) F)).length + ↑o.fst

Copied constraints retain their actual local row position after the preceding bodies. This offset counts rows, independently of their arities or repeated relation records.

theorem Cslib.Complexity.CSP.GadgetRotation.replacementOccurrence_argument {Src Rel : Type} {arity : Rel → ℕ} {sem : Rel → List Bool → Bool} {srcArity : Src → ℕ} {srcSem : Src → List Bool → Bool} (gadgets : (r : Src) → Logic.PL.CSP.PPGadget arity sem (Logic.PL.CSP.booleanRelation srcArity srcSem r)) (B : ℕ) (F : Logic.PL.CSP Src ℕ) (i : Fin (List.length F)) (o : (gadgets F[↑i].rel).body.Occurrence) :
↑(replacementOccurrence gadgets B F i o).snd = ↑o.snd

Copied argument positions keep exactly their local scope indices.

theorem Cslib.Complexity.CSP.GadgetRotation.argumentSuccessor_replacementOccurrence {Src Rel : Type} {arity : Rel → ℕ} {sem : Rel → List Bool → Bool} {srcArity : Src → ℕ} {srcSem : Src → List Bool → Bool} (gadgets : (r : Src) → Logic.PL.CSP.PPGadget arity sem (Logic.PL.CSP.booleanRelation srcArity srcSem r)) (B : ℕ) (F : Logic.PL.CSP Src ℕ) (i : Fin (List.length F)) (o : (gadgets F[↑i].rel).body.Occurrence) :

The actual copied occurrence map preserves the original positive scope successor. Neither local nor source scope names need to be distinct.

theorem Cslib.Complexity.CSP.GadgetRotation.var_replacementOccurrence {Src Rel : Type} {arity : Rel → ℕ} {sem : Rel → List Bool → Bool} {srcArity : Src → ℕ} {srcSem : Src → List Bool → Bool} (gadgets : (r : Src) → Logic.PL.CSP.PPGadget arity sem (Logic.PL.CSP.booleanRelation srcArity srcSem r)) (B : ℕ) (F : Logic.PL.CSP Src ℕ) (i : Fin (List.length F)) (o : (gadgets F[↑i].rel).body.Occurrence) :
(replacementOccurrence gadgets B F i o).var = Sum.elim (fun (a : Fin (srcArity F[↑i].rel)) => 2 * F[↑i].scope.getD (↑a) 0) (fun (j : Fin (gadgets F[↑i].rel).numAux) => 2 * (B * ↑i + ↑j) + 1) o.var

The actual copied occurrence reads its original instantiated free or private name.

theorem Cslib.Complexity.CSP.GadgetRotation.exists_replacementOccurrence {Src Rel : Type} {arity : Rel → ℕ} {sem : Rel → List Bool → Bool} {srcArity : Src → ℕ} {srcSem : Src → List Bool → Bool} (gadgets : (r : Src) → Logic.PL.CSP.PPGadget arity sem (Logic.PL.CSP.booleanRelation srcArity srcSem r)) (B : ℕ) (F : Logic.PL.CSP Src ℕ) (o : (Logic.PL.CSP.replaceGadgets B (fun (r : Src) => (gadgets r).template) F).Occurrence) :
∃ (i : Fin (List.length F)) (p : (gadgets F[↑i].rel).body.Occurrence), replacementOccurrence gadgets B F i p = o

The typed copied occurrences exhaust the actual replacement body's occurrences. The existing public incidence-index inverse recovers the unique local positional source.

theorem Cslib.Complexity.CSP.GadgetRotation.replacementOccurrence_constraint_eq_iff {Src Rel : Type} {arity : Rel → ℕ} {sem : Rel → List Bool → Bool} {srcArity : Src → ℕ} {srcSem : Src → List Bool → Bool} (gadgets : (r : Src) → Logic.PL.CSP.PPGadget arity sem (Logic.PL.CSP.booleanRelation srcArity srcSem r)) (B : ℕ) (F : Logic.PL.CSP Src ℕ) (i k : Fin (List.length F)) (o : (gadgets F[↑i].rel).body.Occurrence) (p : (gadgets F[↑k].rel).body.Occurrence) :
(replacementOccurrence gadgets B F i o).fst = (replacementOccurrence gadgets B F k p).fst ↔ ↑i = ↑k ∧ ↑o.fst = ↑p.fst

Equality of copied constraint positions retains both the source copy and local body row. Repeated relation records and nullary rows are not identified.

theorem Cslib.Complexity.CSP.GadgetRotation.replacementOccurrence_injective {Src Rel : Type} {arity : Rel → ℕ} {sem : Rel → List Bool → Bool} {srcArity : Src → ℕ} {srcSem : Src → List Bool → Bool} (gadgets : (r : Src) → Logic.PL.CSP.PPGadget arity sem (Logic.PL.CSP.booleanRelation srcArity srcSem r)) (B : ℕ) (F : Logic.PL.CSP Src ℕ) :
Function.Injective fun (p : (i : Fin (List.length F)) × (gadgets F[↑i].rel).body.Occurrence) => replacementOccurrence gadgets B F p.fst p.snd

The exact replacement retains every copy/local occurrence identity. In particular coincident free labels and duplicate source rows never identify their indexed edges.

noncomputable def Cslib.Complexity.CSP.GadgetRotation.replacementOccurrenceEquiv {Src Rel : Type} {arity : Rel → ℕ} {sem : Rel → List Bool → Bool} {srcArity : Src → ℕ} {srcSem : Src → List Bool → Bool} (gadgets : (r : Src) → Logic.PL.CSP.PPGadget arity sem (Logic.PL.CSP.booleanRelation srcArity srcSem r)) (B : ℕ) (F : Logic.PL.CSP Src ℕ) :
(i : Fin (List.length F)) × (gadgets F[↑i].rel).body.Occurrence ≃ (Logic.PL.CSP.replaceGadgets B (fun (r : Src) => (gadgets r).template) F).Occurrence

Actual target occurrences correspond bijectively to their original copy/local positions. The inverse is proof-side finite choice; the executed compiler continues to use literal scans.

@[simp]
theorem Cslib.Complexity.CSP.GadgetRotation.replacementOccurrenceEquiv_apply {Src Rel : Type} {arity : Rel → ℕ} {sem : Rel → List Bool → Bool} {srcArity : Src → ℕ} {srcSem : Src → List Bool → Bool} (gadgets : (r : Src) → Logic.PL.CSP.PPGadget arity sem (Logic.PL.CSP.booleanRelation srcArity srcSem r)) (B : ℕ) (F : Logic.PL.CSP Src ℕ) (i : Fin (List.length F)) (o : (gadgets F[↑i].rel).body.Occurrence) :
(replacementOccurrenceEquiv gadgets B F) ⟨i, o⟩ = replacementOccurrence gadgets B F i o

The forward copy/local coordinate map is exactly the original positional occurrence map.