Copyright | (c) Masahiro Sakai 2022 |
---|---|
License | BSD-style |
Maintainer | masahiro.sakai@gmail.com |
Stability | provisional |
Portability | non-portable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Extensions | BangPatterns |
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
- addPBLinAtLeastBCCNF :: PrimMonad m => Encoder m -> PBLinAtLeast -> m ()
- encodePBLinAtLeastWithPolarityBCCNF :: PrimMonad m => Encoder m -> Polarity -> PBLinAtLeast -> m Lit
- encode :: PBLinAtLeast -> [[AtLeast]]
- preprocess :: PBLinAtLeast -> PBLinAtLeast
- type PrefixSum = [(Integer, Int, [Lit])]
- toPrefixSum :: PBLinSum -> PrefixSum
- encodePrefixSum :: PrefixSum -> Integer -> [[BCLit]]
- encodePrefixSumBuggy :: PrefixSum -> Integer -> [[BCLit]]
- encodePrefixSumNaive :: PrefixSum -> Integer -> [[BCLit]]
- type BCLit = (Int, [Lit], Int)
- toAtLeast :: BCLit -> AtLeast
- implyBCLit :: BCLit -> BCLit -> Bool
- type BCClause = [BCLit]
- reduceBCClause :: BCClause -> BCClause
- implyBCClause :: BCClause -> BCClause -> Bool
- type BCCNF = [BCClause]
- reduceBCCNF :: BCCNF -> BCCNF
Monadic interface
addPBLinAtLeastBCCNF :: PrimMonad m => Encoder m -> PBLinAtLeast -> m () Source #
encodePBLinAtLeastWithPolarityBCCNF :: PrimMonad m => Encoder m -> Polarity -> PBLinAtLeast -> m Lit Source #
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 preprocess
ed before calling the function.
encodePrefixSum :: PrefixSum -> Integer -> [[BCLit]] Source #
Algorithm 2 in the paper but with a bug fixed
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\).
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
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
reduceBCCNF :: BCCNF -> BCCNF Source #
Reduce BCCNF
by reducing each clause using reduceBCClause
and then
remove redundant clauses based on implyBCClause
.