The bit-string map for Definition 31 of the n-Queens reduction
DefinitionNQueensComp_NPC_CodeReduction36n-queensparsimonious-reduction
Let be a bit string. Decode its clause lists, require that they encode back to , and check that no list repeats a variable. The represented finite sets must be distinct clauses of size three, and every occurring variable may occur in at most three clauses. For the resulting valid instance , define
where each finite set in a gadget is listed in increasing order. In every other case is the empty bit string.
This specifies the total function used in the code-level form of Theorem 36, including its value on malformed inputs.
Definition code
import Definitions.Def_NQueensComp_NPC_Codes import Definitions.Def_NQueensComp_NPC_Reductions namespace NQueensComp.NPC /-- Check that the clauses are distinct triples and test the occurrence bound on their union. -/ def checkInst6 (cs : Inst6) : Bool := decide (cs.Nodup ∧ (∀ c ∈ cs, c.card = 3) ∧ ∀ v ∈ vars cs, occurrences cs v ≤ 3) /-- Decode a Problem 6 string, checking for malformed bits, repeated entries and invalid clauses. Re-encoding checks that the decoder consumed exactly one complete formula. -/ def decodeValid6 (x : List Bool) : Option Inst6 := let L := (CookLevin.decodeFormulaNFuel x.length x).1 let cs := L.map List.toFinset if enc6 L = x ∧ (∀ l ∈ L, l.Nodup) ∧ checkInst6 cs = true then some cs else none /-- Encode each finite set of a gadget in increasing order. -/ def Inst4.toCode4 (M : Inst4) : Code4 := ⟨M.n, M.C.sort, M.R.sort, M.Dm.sort, M.Dp.sort⟩ /-- On valid Problem 6 inputs, encode the gadget family of Definition 31. An invalid input goes to the empty bit string, which is outside the image of `enc5`. -/ def reduce36Bits (x : List Bool) : List Bool := match decodeValid6 x with | none => [] | some cs => enc5 ((def31 cs).map Inst4.toCode4) end NQueensComp.NPC
Source
I. P. Gent, C. Jefferson and P. Nightingale, “Complexity of n-Queens Completion,” JAIR 59 (2017), 815–848. Unary size convention on p. 820, Definition 31 on p. 834, Theorem 36 on p. 836, and the polynomial-time observation in the proof of Theorem 37 on p. 837. https://doi.org/10.1613/jair.5512