toysolver-0.9.0: Assorted decision procedures for SAT, SMT, Max-SAT, PB, MIP, etc
Copyright(c) Masahiro Sakai 2022
LicenseBSD-style
Maintainermasahiro.sakai@gmail.com
Stabilityprovisional
Portabilitynon-portable
Safe HaskellSafe-Inferred
LanguageHaskell2010
ExtensionsBangPatterns

ToySolver.SAT.Encoder.PB.Internal.BCCNF

Description

References

  • 南 雄之 (Yushi Minami), 宋 剛秀 (Takehide Soh), 番原 睦則 (Mutsunori Banbara), 田村 直之 (Naoyuki Tamura). ブール基数制約を 経由した擬似ブール制約のSAT符号化手法 (A SAT Encoding of Pseudo-Boolean Constraints via Boolean Cardinality Constraints). Computer Software, 2018, volume 35, issue 3, pages 65-78, https://doi.org/10.11309/jssst.35.3_65
Synopsis

Monadic interface

High-level pure encoder

encode :: PBLinAtLeast -> [[AtLeast]] Source #

Encode a given pseudo boolean constraint \(\sum_i a_i x_i \ge c\) into an equilavent formula in the form of \(\bigwedge_j \bigvee_k \sum_{l \in L_{j,k}} l \ge d_{j,k}\).

Low-level implementation

preprocess :: PBLinAtLeast -> PBLinAtLeast Source #

Perform normalizePBLinAtLeast and sort the terms in descending order of coefficients

Prefix sum

type PrefixSum = [(Integer, Int, [Lit])] Source #

\(\sum_{j=1}^i b_j s_j = \sum_{j=1}^i b_j (x_1, \ldots, x_j)\) is represented as a list of tuples consisting of \(b_j, j, [x_1, \ldots, x_j]\).

toPrefixSum :: PBLinSum -> PrefixSum Source #

Convert PBLinSum to PrefixSum. The PBLinSum must be preprocessed before calling the function.

encodePrefixSum :: PrefixSum -> Integer -> [[BCLit]] Source #

Algorithm 2 in the paper but with a bug fixed

encodePrefixSumBuggy :: PrefixSum -> Integer -> [[BCLit]] Source #

Algorithm 2 in the paper

encodePrefixSumNaive :: PrefixSum -> Integer -> [[BCLit]] Source #

Algorithm 1 in the paper

Boolean cardinality constraints

type BCLit = (Int, [Lit], Int) Source #

A constraint \(s_i \ge c\) where \(s_i = x_1 + \ldots + x_i\) is represnted as a tuple of \(i\), \([x_1, \ldots, x_i]\), and \(c\).

toAtLeast :: BCLit -> AtLeast Source #

Forget \(s_i\) and returns \(x_1 + \ldots + x_i \ge c\).

implyBCLit :: BCLit -> BCLit -> Bool Source #

\((s_i \ge a) \Rightarrow (s_j \ge b)\) is defined as \((i \le j \wedge a \ge b) \vee (i \ge b \wedge i - a \le j - b)\).

Clause over boolean cardinality constraints

type BCClause = [BCLit] Source #

Disjunction of BCLit

reduceBCClause :: BCClause -> BCClause Source #

Remove redundant literals based on implyBCLit.

implyBCClause :: BCClause -> BCClause -> Bool Source #

\(C \Rightarrow C'\) is defined as \(\forall l\in C \exists l' \in C' (l \Rightarrow l')\).

CNF over boolean cardinality constraints

type BCCNF = [BCClause] Source #

Conjunction of BCClause

reduceBCCNF :: BCCNF -> BCCNF Source #

Reduce BCCNF by reducing each clause using reduceBCClause and then remove redundant clauses based on implyBCClause.