computing prime implicants
play

Computing prime implicants David D eharbe Pascal Fontaine Daniel - PowerPoint PPT Presentation

Computing prime implicants David D eharbe Pascal Fontaine Daniel Le Berre Bertrand Mazure UFRN, Brazil Inria, U. of Lorraine, France CRIL-CNRS, U. of Artois, France FMCAD 2013, October 21, Portland 1/17 Model, implicant, prime implicant


  1. Computing prime implicants David D´ eharbe Pascal Fontaine Daniel Le Berre Bertrand Mazure UFRN, Brazil Inria, U. of Lorraine, France CRIL-CNRS, U. of Artois, France FMCAD 2013, October 21, Portland 1/17

  2. Model, implicant, prime implicant Example ◮ Let φ = { a ∨ b , a ∨ c , ¬ d ∨ ¬ e ∨ ¬ f } ◮ { a , b , c , d , e , ¬ f } is a model of φ ◮ a ∧ b ∧ c ∧ d ∧ e ∧ ¬ f and a ∧ c ∧ ¬ d are implicants of φ ◮ a ∧ ¬ f , b ∧ c ∧ ¬ f are prime implicants of φ ◮ A model of a formula is an implicant of that formula ◮ From one implicant, one can derive at least one prime implicant ◮ SAT solvers compute models ◮ How to make them compute prime implicants (efficiently) ? 2/17

  3. Clauses, cardinality constraints, pseudo-boolean constraints Various boolean constraints clauses a ∨ ¬ b ∨ c cardinality � l i {≤ , = , ≥} k a + b + c + d ≤ 1 pseudo boolean � w i × l i {≤ , = , ≥} k 4 × a + 2 × b + c + d ≥ 6 ◮ Boolean variables seen as 0/1 integer variables ◮ Normalization : ¬ a + ¬ b + ¬ c + ¬ d ≥ 3 ◮ Clauses are specific cardinality constraints with k = 1 a ∨ ¬ b ∨ c ≡ a + ¬ b + c ≥ 1 ◮ Cardinality constraints are specific PB constraints with w i = 1.

  4. Motivation : SAT-based MAXSAT Example ◮ Let φ = {¬ a ∨ b , ¬ a ∨ c , a , ¬ b , a ∨ b , ¬ c ∨ b } ◮ MAXSAT ( φ ) = minimize � s i such that φ ′ with φ ′ = { s 1 ∨¬ a ∨ b , s 2 ∨¬ a ∨ c , s 3 ∨ a , s 4 ∨¬ b , s 5 ∨ a ∨ b , s 6 ∨¬ c ∨ b } ◮ S = { s i } called “selector variables” ◮ Use SAT solver to find models M of φ ′ ∧ ( � s i < k ) with decreasing k = | M ∩ S | until formula inconsistent. ◮ � s i < k being either a native cardinality constraints (Sat4j) or translated into CNF (QMaxSat). ◮ � w i × s i < k (pseudo-boolean constraint) for Weighted [Partial] MaxSat

  5. Motivation : SAT-based MAXSAT Example ◮ Let φ = {¬ a ∨ b , ¬ a ∨ c , a , ¬ b , a ∨ b , ¬ c ∨ b } ◮ MAXSAT ( φ ) = minimize � s i such that φ ′ with φ ′ = { s 1 ∨¬ a ∨ b , s 2 ∨¬ a ∨ c , s 3 ∨ a , s 4 ∨¬ b , s 5 ∨ a ∨ b , s 6 ∨¬ c ∨ b } ◮ S = { s i } called “selector variables” ◮ Use SAT solver to find models M of φ ′ ∧ ( � s i < k ) with decreasing k = | M ∩ S | until formula inconsistent. ◮ � s i < k being either a native cardinality constraints (Sat4j) or translated into CNF (QMaxSat). ◮ � w i × s i < k (pseudo-boolean constraint) for Weighted [Partial] MaxSat ◮ if M = { a , b , c , s 1 , s 2 , s 3 , s 4 , ¬ s 5 , ¬ s 6 } , k = 4 The bound is not tight ! s 1 , s 2 , s 3 are satisfied while their corresponding clauses are satisfied !

  6. Improve upper bound for SAT-based MAXSAT solvers ◮ Two possible approaches : ◮ Change the encoding : equivalence instead of implication for selector variables ¬ s i → c i becomes ¬ s i ↔ c i adds | φ | binary clauses to φ ′ ◮ Use a prime implicant instead of a model to compute the upper bound ◮ Requirements : ◮ fast : computation need to be done at each model found ◮ compatible with incremental SAT (no/small data structure overhead) ◮ should work with clauses, cardinality constraints, and pseudo-boolean constraints 5/17

  7. Abstract computation of prime implicants 1: procedure Prime ( C , M 0 , Π 0 ) M , Π ← M 0 , Π 0 2: while ℓ ∈ M \ Π do 3: if Required ( M , ℓ, C ) then Π ← Π ∪ { ℓ } 4: else M ← M \ { ℓ } 5: return Π 6: ◮ M 0 is the model returned by the SAT solver ◮ Required () checks if a given literal ℓ is required in the implicant, i.e. ∃ c ∈ C such that satisfying ℓ is mandatory to satysfy c [Castell96]. ◮ Π 0 easy to find required literals (e.g. propagated literals). ◮ In practice, | M 0 \ Π 0 | << | Π 0 | ◮ Works for any kind of constraints ◮ Needs to be refined for efficient implementation !

  8. Prime implicants for clauses (counter based) 1: procedure Prime ( C , M 0 , Π 0 ) M , Π ← M 0 , Π 0 2: for all ℓ ∈ M do W ( ℓ ) ← ∅ 3: for all c ∈ C do 4: N [ c ] ← 0 5: for all ℓ ∈ c do W ( ℓ ) ← W ( ℓ ) ∪ { c } 6: for all ℓ ∈ M do 7: for all c ∈ W ( ℓ ) do N [ c ] ← N [ c ] + 1 8: for all ℓ ∈ M \ Π do 9: if ∃ c ∈ W ( ℓ ) . N [ c ] = 1 then 10: Π ← Π ∪ { ℓ } 11: else 12: for all c ∈ W ( ℓ ) do N [ c ] ← N [ c ] − 1 13: M ← M \ { ℓ } 14: return Π 15:

  9. Prime implicants for cardinality constraints (counter based) 1: procedure Prime ( C , M 0 , Π 0 ) M , Π ← M 0 , Π 0 2: for all ℓ ∈ M do W ( ℓ ) ← ∅ 3: for all c ∈ C do 4: N [ c ] ← 0 5: for all ℓ ∈ c do W ( ℓ ) ← W ( ℓ ) ∪ { c } 6: for all ℓ ∈ M do 7: for all c ∈ W ( ℓ ) do N [ c ] ← N [ c ] + 1 8: for all ℓ ∈ M \ Π do 9: if ∃ c ∈ W ( ℓ ) . N [ c ] = degree ( c ) then 10: Π ← Π ∪ { ℓ } 11: else 12: for all c ∈ W ( ℓ ) do N [ c ] ← N [ c ] − 1 13: M ← M \ { ℓ } 14: return Π 15:

  10. About Counter-based approaches ◮ Complexity is linear in the size of C : O ( � c ∈C | c | ) ◮ Works for both clauses and cardinality constraints ◮ Easy to implement outside the solver ◮ What about early detection of required literals ? ◮ What about pseudo boolean constraints ? ◮ What about incremental SAT solving ? 9/17

  11. Abstract propagation-based algorithm 1: procedure Prime ( C , M 0 , Π 0 ) M , Π ← M 0 , Π 0 2: Π ← Π ∪ Implied ( C , M ) ⊲ Propagates required literals 3: while ℓ ∈ M \ Π do 4: M ← M \ { ℓ } 5: Π ← Π ∪ Implied ( C , M ) ⊲ Propagates removal of ℓ 6: return Π 7: ◮ Implied () propagates truth value similarly to Unit Propagation ◮ New invariant : each literal picked up at line 4 is not required ◮ We can reuse here the data structures found in modern SAT solvers ! 10/17

  12. Prime implicants using watched literals 1: procedure Prime ( C , M 0 , Π 0 , W ) M , Π ← M 0 , Π 0 2: for all ℓ ∈ M \ Π do ⊲ Watch satisfied literals 3: Implied W ( C , M , ¯ ℓ, Π , W ) 4: while ℓ ∈ M \ Π do 5: M ← M \ { ℓ } 6: Implied W ( C , M , ℓ, Π , W ) ⊲ Propagates removal of ℓ 7: return Π 8: 9: procedure Implied W ( C , M , ℓ, ref Π , ref W ) W ℓ ← W ( ℓ ) 10: for all c ∈ W ℓ do 11: Hdl constr ( c , M , ℓ, Π , W ) ⊲ Specific to each c 12: W ( ℓ ) = constraints “watched” for literal ℓ

  13. Hdl constr for clause or cardinality constraints 1: procedure Hdl constr ( c , M , ℓ, ref Π , ref W ) if ∃ ℓ ′ ∈ c ∩ M . ℓ ′ / ∈ W − 1 ( c ) then 2: W ← ( W ∪ { ℓ ′ �→ c } ) \ { ℓ �→ c } 3: else Π ← Π ∪ ( W − 1 ( c ) \ { ℓ } ) 4: ◮ W − 1 ( c ) = literals “watched” in constraint c ◮ Just like lazy data structure management during unit propagation (in clauses or cardinality constraints) ◮ Watches satisfied literals : there is at least one such literal per clause. ◮ One important difference : constraints are traversed only once. that condition must hold to achieve linear time !

  14. Prime Implicant specific propagation ◮ Triggered when a literal is removed from M ◮ Procedure looks for a satisfied literal ◮ Some literals may be deleted ◮ Propagates a required literal . . . p q a c e r s b d w1 w2 13/17

  15. Prime Implicant specific propagation ◮ Triggered when a literal is removed from M ◮ Procedure looks for a satisfied literal ◮ Some literals may be deleted ◮ Propagates a required literal . . . p q a c e r s b d w1 w2 ? 13/17

  16. Prime Implicant specific propagation ◮ Triggered when a literal is removed from M ◮ Procedure looks for a satisfied literal ◮ Some literals may be deleted ◮ Propagates a required literal . . . p q a c c e r s b d w1 w2 13/17

  17. Prime Implicant specific propagation ◮ Triggered when a literal is removed from M ◮ Procedure looks for a satisfied literal ◮ Some literals may be deleted ◮ Propagates a required literal . . . p q a c c e r s b d w1 w2 ? 13/17

  18. Prime Implicant specific propagation ◮ Triggered when a literal is removed from M ◮ Procedure looks for a satisfied literal ◮ Some literals may be deleted ◮ Propagates a required literal . . . p q a c c e r s b d d w1 w2 13/17

  19. Prime Implicant specific propagation ◮ Triggered when a literal is removed from M ◮ Procedure looks for a satisfied literal ◮ Some literals may be deleted ◮ Propagates a required literal . . . p q a c c e r s b d d d b w1 w2 13/17

  20. Prime Implicant specific propagation ◮ Triggered when a literal is removed from M ◮ Procedure looks for a satisfied literal ◮ Some literals may be deleted ◮ Propagates a required literal . . . p q a c e r s b d d b w1 w2 13/17

  21. Prime Implicant specific propagation ◮ Triggered when a literal is removed from M ◮ Procedure looks for a satisfied literal ◮ Some literals may be deleted ◮ Propagates a required literal . . . p q a c e r s b d d b w1 w2 ? 13/17

  22. Prime Implicant specific propagation ◮ Triggered when a literal is removed from M ◮ Procedure looks for a satisfied literal ◮ Some literals may be deleted ◮ Propagates a required literal . . . p q a c e e r s b d d b w1 w2 13/17

  23. Prime Implicant specific propagation ◮ Triggered when a literal is removed from M ◮ Procedure looks for a satisfied literal ◮ Some literals may be deleted ◮ Propagates a required literal . . . p q a c e e r s b d d b w1 w2 ? 13/17

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend