Occurrence splitting for monotone 1-in-3-SAT
DefinitionNQueensComp_NPC_MonotoneOccurrenceSplitNumber the three positions in each input clause and create a separate variable for each position. For each original variable, join its successive copies by a path of exact-one constraints. Each link has fresh auxiliary variables that uniquely enforce equality of its two endpoints. The bit-string map sends a malformed input to the empty string. The source count interprets a repeated variable once per occurrence in its clause.
Definition code
import Definitions.Def_NQueensComp_NPC_Codes
namespace NQueensComp.NPC
/-- Parse a list of positive triples. Repeated entries count as separate occurrences. -/
def decodeMonotoneTriples (x : List Bool) : Option Code6 :=
let L := (CookLevin.decodeFormulaNFuel x.length x).1
if enc6 L = x ∧ (∀ c ∈ L, c.length = 3) then some L else none
/-- Only variables occurring in the input receive truth values. -/
def MonotoneTripleSol (L : Code6) (T : Finset ℕ) : Prop :=
T ⊆ L.flatten.toFinset ∧ ∀ c ∈ L, c.countP (fun v => decide (v ∈ T)) = 1
noncomputable def countMonotoneTriples (x : List Bool) : ℕ :=
match decodeMonotoneTriples x with
| none => 0
| some L => Set.ncard {T : Finset ℕ | MonotoneTripleSol L T}
/-- The two endpoints are occurrence copies numbered 6*i and 6*j.
The first three clauses pin t to true and a,b,c to false. The last two
then force the endpoints to share a truth value and determine the auxiliary u. -/
def occurrenceLink (i j : ℕ) : Code6 :=
let u := 6*i + 1
let t := 6*i + 2
let a := 6*i + 3
let b := 6*i + 4
let c := 6*i + 5
[[t,a,b], [t,b,c], [t,c,a], [6*i,u,a], [u,6*j,b]]
/-- Split the input triples into distinct occurrence copies, then link consecutive
copies of each variable in input order. Each link has its own auxiliary variables. -/
def splitMonotoneTriples (L : Code6) : Code6 :=
let triples := L.zipIdx.map fun p =>
[6*(3*p.2), 6*(3*p.2+1), 6*(3*p.2+2)]
let occurrencesByVar := fun v : ℕ =>
(L.flatten.zipIdx.filter (fun p => p.1 == v)).map Prod.snd
triples ++ L.flatten.eraseDups.flatMap fun v =>
let is := occurrencesByVar v
(is.zip (is.drop 1)).flatMap fun p => occurrenceLink p.1 p.2
/-- Malformed strings map to the empty bit string, which encodes no formula. -/
def splitMonotoneBits (x : List Bool) : List Bool :=
match decodeMonotoneTriples x with
| none => []
| some L => enc6 (splitMonotoneTriples L)
end NQueensComp.NPC
Source
Gent, Jefferson & Nightingale, Complexity of n-Queens Completion (2017), Theorem 4, pp. 820–821, https://doi.org/10.1613/jair.5512. The link construction uses a fresh forced-constant triple for each adjacent pair of occurrence copies.