Encoding item distinctness by sequential unit clause blocks
DefinitionElementDistinctnessUnitSATcomplexity-theoryformal-verification
For the item at position i, emit one unit clause per bit j of i. Its variable encodes the pair of this item and j, and the literal sign equals bit j of i. Concatenate the blocks in arrival order using the mission binary CNF encoding.
Definition code
import Definitions.Def_PvsNP
set_option autoImplicit false
namespace PvsNP.DistinctnessToSAT
/-- A unit clause, generated when the item at position i arrives. Two
occurrences of the same item refer to the same variable at each bit j. -/
def unit {n : ℕ} (items : Fin n → ℕ) (i : Fin n) (j : ℕ) : Clause :=
[(i.val.testBit j, Nat.pair (items i) j)]
/-- Visit each item once and emit one unit clause for each position bit. -/
def formula {n : ℕ} (items : Fin n → ℕ) (indexBits : ℕ) : CNF :=
(List.finRange n).flatMap fun i =>
(List.finRange indexBits).map fun j => unit items i j.val
def word {n : ℕ} (items : Fin n → ℕ) (indexBits : ℕ) : Str :=
encodeCNF (formula items indexBits)
/-- Encode the clause block for one item from its position and value alone. -/
def itemWord (position value indexBits : ℕ) : Str :=
encodeCNF ((List.finRange indexBits).map fun j =>
[(position.testBit j.val,Nat.pair value j.val)])
end PvsNP.DistinctnessToSAT
Source
An explicit unit-clause reduction from element distinctness to the mission SAT encoding.