# OUTLINE Boolean Equi-propagation for Optimized SAT Encoding Compiling Finite Domain Constraints to SAT with BEE Encoding process Design choices Compiling.

## Presentation on theme: "OUTLINE Boolean Equi-propagation for Optimized SAT Encoding Compiling Finite Domain Constraints to SAT with BEE Encoding process Design choices Compiling."— Presentation transcript:

OUTLINE Boolean Equi-propagation for Optimized SAT Encoding Compiling Finite Domain Constraints to SAT with BEE Encoding process Design choices Compiling Model-Based Diagnosis to Boolean Satisfaction using BEE Amit Metodi Michael Codish Vitaly Lagoon Peter J. Stuckey ; CP 2011 Amit Metodi Michael Codish ; TPLP 2012 Amit Metodi Roni Stern Meir Kalech Michael Codish ; AAAI 2012

Problem (hard) Solution CNF Satisfied assignment Encoding FINITE DOMAIN PROBLEM SOLVING Model Constraint Model Direct CSP solving Model Solution Translate Decoding SAT solving

CNF Constraint Model C1 C2 C3 Cn encode Simplify Tools such as: SatELite, ReVivAl Based on Unit Propagation and Resolution. Problems: Constraint / Bits relation lost Large CNF CNF THE USUAL APPROACH Simplified CNF

Constraint Model C1 C2 C3 Cn encode CNF OUR APPROACH simplification propagation

Constraint Model C1 C2 C3 encode THE EQUI-PROPAGATION PROCESS Equi-propagation is a process of inferring equational consequences from a Boolean formula and given equational information. of the form X=L where L is a constant or a literal: X=Y, X= -Y, X=0, X=1 such X can be removed from ALL Boolean formulas / constraints. Cn CNF

Encoding Constraint Model Equi-propagationPartial evaluation view each single constraint as a Boolean formula

CNF BEE PROCESS – BY EXAMPLE Constraint Model C1 C2 C3 Cn encode bool_array_sum_eq( [ A,B,C,D,E,F,G],3) Step 1: Encode each constraint

Constraint Model C1 C2 C3 Cn encode BEE PROCESS – BY EXAMPLE encode bool_array_sum_eq( [ A,B,C,D,E,F,G],3) A=1, D= -E CNF Step 2: Apply Equi-Propagation

Constraint Model C3 bool_array_sum_eq( [ A,B,C,D,E,F,G],3) C1 C2 Cn encode BEE PROCESS – BY EXAMPLE update encode update encode update encode update bool_array_sum_eq( [ A,B,C,D,E,F,G],3) bool_array_sum_eq( [ 1,B,C,-E,E,F,G],3) A=1, D= -E CNF Step 3: Update the Constraints Model

Constraint Model C1 C2 C3 Cn encode BEE PROCESS – BY EXAMPLE update encode update encode update encode update bool_array_sum_eq( [ A,B,C,D,E,F,G],3) bool_array_sum_eq( [ 1,B,C,-E,E,F,G],3) bool_array_sum_eq( [ B,C, F,G],1) A=1, D= -E CNF Step 4: Apply Partial Evaluation

Constraint Model C1 C2 C3 Cn encode BEE PROCESS – BY EXAMPLE update encode update encode update encode update bool_array_sum_eq( [ A,B,C,D,E,F,G],3) bool_array_sum_eq( [ 1,B,C,-E,E,F,G],3) bool_array_sum_eq( [ B,C, F,G],1) A=1, D= -E CNF Step 5: Encode with a better encoding

Constraint Model C1 C2 C3 Cn encode BEE PROCESS – BY EXAMPLE update encode update encode update encode update bool_array_sum_eq( [ A,B,C,D,E,F,G],3) bool_array_sum_eq( [ 1,B,C,-E,E,F,G],3) bool_array_sum_eq( [ B,C, F,G],1) CNF Step 6: Merge the optimized CNF Optimized CNF merge

THE DESIGN CHOICES Representing numbers Implementing Equi-Propagation

MODELING FINITE DOMAIN CSP representing numbers (integers) BinaryUnaryOrder encoding x i (X i) (X = 3) = [1,1,1,0,0] Direct encoding x i (X = i) (X = 3) = [0,0,0,1,0,0] SMALL

WHY ORDER ENCODING ? X ij X iX < j 1 0 good for representing ranges X u v i good for arbitrary sets ab c d efg b=c e=f=g

WHY ORDER ENCODING ? Lots of equi-propagation The Encoding to SAT needs NO clauses. It is obtained by unification.

IMPLEMENTING EQUI-PROPAGATION 1.Using BDDs. Prohibitive for global constraints. Complete 2.Using SAT (on small groups of constraints) In practice, surprisingly, not slow Complete 3.Ad-Hoc rules (per constraint type) Fast, precise in practice Incomplete

AD-HOC RULES Equi-Propagation Partial Evaluation int_plus(,, ) Example: int_plus(,, ) Example: int_plus(,, )

THE IMPACT OF BEE 909 clauses 136 Bits 298 clauses 49 Bits

Kakuro QCP / Sudoku BIBD Nonograms Graph Crossing N-Queens Magic Square MAS SCM / MCM Model Based Diagnostic Protein folding

MODEL BASED DIAGNOSIS An important problem which researched by many researches. There is standard benchmarks. Encoding to SAT is straightforward But previous attempts concluded that SAT isnt competitive with other tools. We show that by using BEE, not only SAT is able to compete with other tools, it is faster. We solve the entire benchmark for the first time.

1 Symptom Diagnoses: A B C D E Z1 Z2 Z3 1 0 Observation 0 0 1 Full Adder MODEL BASED DIAGNOSIS 0 0 0 System (model) 0

Diagnoses: A B C D E Z1 Z2 Z3 Full Adder min min-cardinality 1 0 0 0 1 MODEL BASED DIAGNOSIS We focus on minimal cardinality diagnosis of Boolean Circuits, given a single observation.

H -H-H purple means encapsulated with a health variable MODELING MBD: THE WEAK FAULT MODEL (we can assume that) a faulty component flips its output. Introduce health variables:

minimize 1 0 A B C D E X1 X2 A2 A1 O1 Z1 Z2 Z3 0 0 1 Full Adder H1H1 H2H2 H3H3 H4H4 H5H5 sum( [ -H 1, -H 2, -H 3, -H 4, -H 5 ] ) K MODELING MBD: INTRODUCE HEALTH VARIABLES Modeling as CSP where the constraints are: 1. components (logic gates) 2. sum of bits / comparison

minimize sum( [ -H 1, -H 2, -H 3, -H 4, -H 5 ] ) 1 Modeling as CSP where the constraints are: 1. components (logic gates) 2. sum of bits / comparison 1 0 A B C D E X1 X2 A2 A1 O1 0 0 1 Full Adder H1H1 H2H2 H3H3 H4H4 H5H5 green means healthy MODELING MBD: INTRODUCE HEALTH VARIABLES

1 0 A B C D E X1 X2 A2 A1 O1 Z1 Z2 Z3 0 0 1 Full Adder H1H1 H2H2 H3H3 H4H4 H5H5 H -H 1 0 1 0 0 1 0 gray means "melted Z partial evaluation SIMPLIFYING THE ENCODING equi-propagation Z=-H H1 -H3

vanillasimplified 330 components 60 x 26 (input/output) 1182 observations Timeout 180sec

MBD TO SAT We can go just so far (and not very); We can not push the inputs through the circuit because of the health variables. What can we do ? Better modeling Better preprocessing

A B C D E Z1 Z2 Z3 Full Adder dominator BETTER MODELING: CONES Def: gate G dominates gate X, if any path from X to a system output passes through G Def: the cone corresponding to gate G is the set of gates dominated by G

BETTER MODELING: CONES these prune the search space break a symmetry claim: A minimal cardinality diagnosis will always indicate at most one unhealthy gate per cone. We can assume w.l.o.g. that this gate is the dominator. (or: in the search for a single minimal cardinality diagnosis, all dominated gates may be assumed healthy)

1 0 A B C D E X1 X2 A2 A1 O1 Z3 0 0 1 Full Adder H1H1 H2H2 H3H3 H4H4 H5H5 sum( [ -H 1, -H 2, -H 3, -H 4, -H 5 ] ) K H1 -H3 a cone THE IMPACT OF CONES

1 0 A B C D E X1 X2 A2 A1 O1 Z3 0 0 1 Full Adder H1H1 H2H2 H3H3 H4H4 H5H5 H1 0 sum( [ -H 1, -H 2, 0, 0, -H 5 ] ) K green means healthy gray means "melted THE IMPACT OF CONES

1 0 A B C D E X1 X2 A2 A1 O1 0 0 1 Full Adder H1H1 H2H2 H3H3 H4H4 H5H5 H1 0 H 1 sum( [ -H 1, -H 2, -H 5 ] ) K THE IMPACT OF CONES

sum( [ -H 1, -H 2, H 1 ] ) K 1 0 A B C D E X1 X2 A2 A1 O1 0 0 1 Full Adder H1H1 H2H2 H3H3 H4H4 H5H5 H1 0 H1=-H5 H1 THE IMPACT OF CONES

1 0 A B C D E X1 X2 A2 A1 O1 0 0 1 Full Adder H1H1 H2H2 H3H3 H4H4 H5H5 sum( [ -H 1, -H 1, H 1 ] ) K H1 0 H1=-H5 H1=H2 THE IMPACT OF CONES

1 0 A B C D E X1 X2 A2 A1 O1 0 0 1 Full Adder H1H1 H2H2 H3H3 H4H4 H5H5 sum( [ -H 1, -H 1, H 1 ] ) K H1 0 H1=-H5 H1=H2 minimize K H 1 =1 THE IMPACT OF CONES

1 0 A B C D E X1 X2 A2 A1 O1 0 0 1 Full Adder H1H1 H2H2 H3H3 H4H4 H5H5 No SAT solving; Diagnostics (min-cardinality) found by: preprocessing(cones) partial evaluation equi-propagation THE IMPACT OF CONES

vanillasimplifiedcones

Systems Name|C||IN||OUT|Obsrs 7418165148350 741821995250 742833695202 c432160367301 c4992024132835 c88038360261182 c13555464132836 c19088803325846 c267011932331401162 c354016695022756 c531523071781232038 c6288241632 404 c755235122071081557 There are standard benchmarks for finding a minimal cardinality diagnosis of Boolean Circuits, given a single observation. BENCHMARKS

SystemHA*CDA*SAFARISAT Name%Succ.Time%Succ.Time%Succ.Time%Succ.Time 7418168.33.1546.34.51100.0 (44)0.00100.00.02 74182100.00.00100.00.01100.0 (91)0.00100.00.01 74283100.00.04100.01.45100.0 (57)0.00100.00.02 c43278.13.6338.25.15100.0 (28)0.03100.00.03 c49924.15.4510.11.22100.0 (7)0.05100.00.04 c88011.93.766.36.66100.0 (48)0.18100.00.05 c135511.43.900.0-100.0 (5)0.37100.00.07 c19086.41.750.0-100.0 (17)1.08100.00.14 c267012.34.830.0-100.0 (14)2.71100.00.15 c35403.74.300.0-100.0 (9)5.25100.00.27 c53152.711.940.0-100.0 (9)13.34100.00.42 c628813.67.870.0-53.5 (25)16.18100.00.56 c75524.21.060.0- -99.31.07 Average time (sec) on those that do not t/o 30 seconds timeout EXPERIMENTS

CONCLUSIONS Equi-Propagation process apply powerful reasoning techniques to separate parts of the model and maintain efficient preprocessing. BEE encodes finite domain constraints to CNF uses ad-hoc equi-propagation and partial evaluation rules which keeps compilation times typically small. And the reduction in SAT solving time can be larger in orders of magnitude. By using BEE the user may focus on better modeling which will result better preprocessing and faster solving time. (MBD as an example)

FUTURE WORK Other number representations Binary, Mix Radix, RNS, and more… Partition for Complete Equi-Propagation. Additional applications to Model Based Diagnosis.

QUESTIONS ?

Download ppt "OUTLINE Boolean Equi-propagation for Optimized SAT Encoding Compiling Finite Domain Constraints to SAT with BEE Encoding process Design choices Compiling."

Similar presentations