Documentation

CslibFrontier.Logics.Propositional.CSP.PrimitivePositive.Replacement

Pure fixed-gadget replacement #

The existing primitive-positive gadget is instantiated in the original source scope, with free names 2*v and private auxiliary names 2*(B*i+j)+1. The exact-arity guard and semantic correctness retain repeated variables, duplicate constraints, empty and nullary instances.

This module contains the unchanged logical replacement declarations formerly in the native runtime module. It has no native computability imports or runtime certificates. The native module publicly imports this topic, preserving the original declaration names and visibility.

Main definitions #

Main results #

The construction is the equality-free case of [Che06], Proposition 3.9, arXiv v1, p. 8.

def Cslib.Logic.PL.CSP.PPGadget.template {Rel : Type} {arity : Rel → ℕ} {sem : Rel → List Bool → Bool} {n : ℕ} {R : Set (Fin n → Bool)} (g : PPGadget arity sem R) :
CSP Rel (Bool × ℕ)

Uniform local ports: false denotes a free port and true an auxiliary port. The natural indices are bounded constants, encoded in unary.

def Cslib.Logic.PL.CSP.instantiate {Rel : Type} (B index : ℕ) (scope : List ℕ) (body : CSP Rel (Bool × ℕ)) :
CSP Rel ℕ

Instantiate a local template at one source scope and constraint index.

def Cslib.Logic.PL.CSP.replaceGadgets {Src Rel : Type} (B : ℕ) (templates : Src → CSP Rel (Bool × ℕ)) (F : CSP Src ℕ) :
CSP Rel ℕ

Replace every source constraint, with disjoint auxiliary namespaces.

def Cslib.Logic.PL.CSP.replaceGadgetsGuarded {Src Rel : Type} (srcArity : Src → ℕ) (B : ℕ) (templates : Src → CSP Rel (Bool × ℕ)) (reject : CSP Rel ℕ) (F : CSP Src ℕ) :
CSP Rel ℕ

Exact-arity guarded gadget replacement with an explicit reject instance.

theorem Cslib.Logic.PL.CSP.PPGadget.wellFormed_template {Rel : Type} {arity : Rel → ℕ} {sem : Rel → List Bool → Bool} {n : ℕ} {R : Set (Fin n → Bool)} (g : PPGadget arity sem R) :

Uniform templates retain the well-formedness of the certified gadget.

theorem Cslib.Logic.PL.CSP.wellFormed_instantiate {Rel : Type} {arity : Rel → ℕ} (B index : ℕ) (scope : List ℕ) (body : CSP Rel (Bool × ℕ)) (h : WellFormed arity body) :
WellFormed arity (instantiate B index scope body)

Renaming a well-formed gadget preserves exact target arities.

theorem Cslib.Logic.PL.CSP.wellFormed_replaceGadgets {Src Rel : Type} {arity : Rel → ℕ} (B : ℕ) (templates : Src → CSP Rel (Bool × ℕ)) (h : ∀ (r : Src), WellFormed arity (templates r)) (F : CSP Src ℕ) :
WellFormed arity (replaceGadgets B templates F)

Replacing with well-formed templates produces well-formed target constraints.

theorem Cslib.Logic.PL.CSP.wellFormed_replaceGadgetsGuarded {Src Rel : Type} {arity : Rel → ℕ} (srcArity : Src → ℕ) (B : ℕ) (templates : Src → CSP Rel (Bool × ℕ)) (h : ∀ (r : Src), WellFormed arity (templates r)) (reject : CSP Rel ℕ) (hr : WellFormed arity reject) (F : CSP Src ℕ) :
WellFormed arity (replaceGadgetsGuarded srcArity B templates reject F)

The guarded compiler produces a well-formed result if its fixed reject instance is well formed.

theorem Cslib.Logic.PL.CSP.eval_instantiate {Rel : Type} {arity : Rel → ℕ} {sem : Rel → List Bool → Bool} {n : ℕ} {R : Set (Fin n → Bool)} (g : PPGadget arity sem R) (B index : ℕ) (scope : List ℕ) (σ : ℕ → Bool) :
eval sem σ (instantiate B index scope g.template) = eval sem (Sum.elim (fun (i : Fin n) => σ (2 * scope.getD (↑i) 0)) fun (j : Fin g.numAux) => σ (2 * (B * index + ↑j) + 1)) g.body

Instantiating an actual gadget evaluates its original body at the supplied even free names and odd per-occurrence auxiliary names, for every fixed target assignment. No satisfiability or arity premise is needed for this pointwise equation.

theorem Cslib.Logic.PL.CSP.satisfiable_replaceGadgets_iff {Src Rel : Type} {arity : Rel → ℕ} {sem : Rel → List Bool → Bool} {srcArity : Src → ℕ} {srcSem : Src → List Bool → Bool} (gadgets : (r : Src) → PPGadget arity sem (booleanRelation srcArity srcSem r)) (B : ℕ) (hB : ∀ (r : Src), (gadgets r).numAux ≤ B) (F : CSP Src ℕ) (hF : WellFormed srcArity F) :
Satisfiable sem (replaceGadgets B (fun (r : Src) => (gadgets r).template) F) ↔ Satisfiable srcSem F

Correct gadgets preserve satisfiability on well-formed inputs. Only a uniform bound on the number of auxiliary ports is required.

theorem Cslib.Logic.PL.CSP.satisfiable_replaceGadgetsGuarded_iff {Src Rel : Type} {arity : Rel → ℕ} {sem : Rel → List Bool → Bool} {srcArity : Src → ℕ} {srcSem : Src → List Bool → Bool} (gadgets : (r : Src) → PPGadget arity sem (booleanRelation srcArity srcSem r)) (B : ℕ) (hB : ∀ (r : Src), (gadgets r).numAux ≤ B) (reject : CSP Rel ℕ) (hreject : ¬Satisfiable sem reject) (F : CSP Src ℕ) :
Satisfiable sem (replaceGadgetsGuarded srcArity B (fun (r : Src) => (gadgets r).template) reject F) ↔ WellFormed srcArity F ∧ Satisfiable srcSem F

The exact-arity guard gives total correctness, including malformed inputs. The supplied reject instance must be unsatisfiable.

theorem Cslib.Logic.PL.CSP.wellFormed_satisfiable_replaceGadgetsGuarded_iff {Src Rel : Type} {arity : Rel → ℕ} {sem : Rel → List Bool → Bool} {srcArity : Src → ℕ} {srcSem : Src → List Bool → Bool} (gadgets : (r : Src) → PPGadget arity sem (booleanRelation srcArity srcSem r)) (B : ℕ) (hB : ∀ (r : Src), (gadgets r).numAux ≤ B) (reject : CSP Rel ℕ) (hreject : ¬(WellFormed arity reject ∧ Satisfiable sem reject)) (F : CSP Src ℕ) :
WellFormed arity (replaceGadgetsGuarded srcArity B (fun (r : Src) => (gadgets r).template) reject F) ∧ Satisfiable sem (replaceGadgetsGuarded srcArity B (fun (r : Src) => (gadgets r).template) reject F) ↔ WellFormed srcArity F ∧ Satisfiable srcSem F

Full guarded correctness for the exact-arity CSP decision predicate. A reject target may fail either well-formedness or satisfiability, allowing a fixed malformed constraint.

def Cslib.Logic.PL.CSP.malformedReject {Rel : Type} (arity : Rel → ℕ) (r : Rel) :
CSP Rel ℕ

A fixed malformed target for rejecting invalid source scopes. Any target symbol suffices.

theorem Cslib.Logic.PL.CSP.not_wellFormed_malformedReject {Rel : Type} (arity : Rel → ℕ) (r : Rel) :

The fixed reject target fails exact arity independently of its semantics.