Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Efficient Manipulation of Logical Formulas as D...

Efficient Manipulation of Logical Formulas as Decision Diagrams

Constraint solving and the manipulation of Satisfiability Modulo Theories (SMT) formulas is a fundamental task in symbolic model checking. SMT solvers have proven to be efficient tools in exploiting the high expressive power and flexibility offered by SMT formulas. Decision diagram based approaches have also gained popularity for their capability to represent all solutions in a compact way and are used in numerous efficient algorithms. However, there is a gap between these two approaches.

We present a novel data structure that can combine the flexibility of SMT formulas and the power of SMT solvers with the efficient representation of the solutions. This data structure is a blend of decision diagrams and SMT formulas: it allows us to handle logical formulas as decision diagrams, leveraging both the power of SMT solvers and the advantages of diagram representation. The compatibility with decision diagrams allows the integration of efficient algorithms working on the two different representations. When discussing the benefits of this approach, we also emphasize how the intersection operation - a common problem in constraint solving - can be carried out more efficiently using lazy evaluation. We can also build on the same advantage in transitive closure calculations.

More Decks by Critical Systems Research Group

Other Decks in Research

Transcript

  1. Efficient Manipulation of Logical Formulas as Decision Diagrams Milán Mondok,

    Vince Molnár Budapest University of Technology and Economics, Hungary Supported by the UNKP-23-3-I-BME-8 New National Excellence Program of the Ministry for Culture and Innovation from the source of the National Research, Development and Innovation Fund Efficient Manipulation of Logical Formulas as Decision Diagrams
  2. • Heterogeneous system models – Mix of multiple high-level languages

    – SysMLv2: new OMG systems modeling language → Transformed to an SMT-based representation Motivation Efficient Manipulation of Logical Formulas as Decision Diagrams Statechart Activity diagram Composition, communication Model-Based Testing of Asynchronously Communicating Distributed Controllers, Bence Graics et al, FACS 2023 2 I: x = 0 T: (x < 5 ∧ x’ = x + 1) ∨ (x >= 5 ∧ x’ = x) Initial states SMT formulas Transition relation
  3. • Async behavior – Several asynchronously coupled components – Communication

    via e.g. message queues – Decision-diagram-based model checkers – (Generalized) Saturation algorithm – Proved efficient for Petri Nets Motivation Efficient Manipulation of Logical Formulas as Decision Diagrams Goal: Exploit the advantages of decision-diagram-based algorithms (e.g., saturation) on SMT-based model representations Extensions and generalization of the saturation algorithm in model checking, Vince Molnár, PhD Thesis, 2019 3
  4. • Compact representation of a set of vectors Decision diagrams

    0 0 0 1 1 1 0 1 0 1 1 Efficient Manipulation of Logical Formulas as Decision Diagrams Terminal node: final result Node: decision point a b c Levels: variables Usage for model checking: – Encode states with k levels – Encode transitions with 2k levels – Model step: relational product → Calculate fixed point level i: x level i+1: x’ 4
  5. • One possible way: enumerate all solutions first • Problem:

    formula might have too many solutions → can’t enumerate – Too many variables – Transition relation might be infinitely large Decision diagram from SMT formula? Efficient Manipulation of Logical Formulas as Decision Diagrams How to represent general transition relations given as SMT formulas? For example, x’ = x + 1 x > 0 ∧ x < 4 SMT formula { (x=1), (x=2), (x=3) } Enumerated solutions Decision diagram 1 1 2 3 5
  6. Efficient Manipulation of Logical Formulas as Decision Diagrams Overview Input

    model I: x = 0 T: (x < 5 ∧ x’ = x + 1) ∨ (x >= 5 ∧ x’ = x) SMT formulas Decision diagrams Symbolic model checker ✓ X / ? Goal: Exploit the advantages of decision-diagram-based algorithms (e.g., saturation) on SMT-based model representations 6
  7. Efficient Manipulation of Logical Formulas as Decision Diagrams Overview Input

    model I: x = 0 T: (x < 5 ∧ x’ = x + 1) ∨ (x >= 5 ∧ x’ = x) SMT formulas Substitution diagrams Symbolic model checker ✓ X / Goal: Exploit the advantages of decision-diagram-based algorithms (e.g., saturation) on SMT-based model representations 7
  8. Efficient Manipulation of Logical Formulas as Decision Diagrams Substitution diagram

    Observation: SMT formulas and the variable substitution operation span a structure that is similar to decision diagrams SMT formulas → Nodes Variable substitution → Edges Controlling SAT/SMT solvers with decision diagrams to support abstraction-based model checking Almási Nóra, BME VIK TDK 2020 (x > 2) SMT formula substitute x with 0 (0 > 2) SMT formula 8
  9. Substitution diagram f f t (a ∨ ¬b) ∧ (x

    = 2) true ¬b ∧ (x = 2) (x = 2) 2 a b x Efficient Manipulation of Logical Formulas as Decision Diagrams 9 Lazy evaluation: presence of edges and children evaluated only when queried! substitute a with false Node: SMT formula substitute a with true Equivalent nodes are merged syntactically or with an SMT-solver
  10. x’ y’ x y Model checking with substitution diagrams I:

    (x = 0) ∧ (y = 1) T: (x’ = x + 1) ∧ (y’ = y) (x = 0) ∧ (y = 1) true (y = 1) 0 1 (x’ = x + 1) ∧ (y’ = y) true (y’ = y) 1 … … 0 1 2 1 2 3 0 1 2 2 0 1 Efficient Manipulation of Logical Formulas as Decision Diagrams Initial states Transition relation 10
  11. x’ y’ x y Relational product: model step (x =

    0) ∧ (y = 1) true (y = 1) 0 1 (x’ = x + 1) ∧ (y’ = y) true (y’ = y) 1 … … 0 1 2 1 2 3 0 1 2 2 0 1 Efficient Manipulation of Logical Formulas as Decision Diagrams x = 10
  12. x’ y’ x y (x = 0) ∧ (y =

    1) true (y = 1) 0 1 (x’ = x + 1) ∧ (y’ = y) true (y’ = y) 1 … … 0 1 2 1 2 3 0 1 2 2 0 1 Efficient Manipulation of Logical Formulas as Decision Diagrams true x = Relational product: model step 10
  13. x’ y’ x y Relational product: model step (x =

    0) ∧ (y = 1) true (y = 1) 0 1 (x’ = x + 1) ∧ (y’ = y) true (y’ = y) 1 … … 0 1 2 1 2 3 0 1 2 2 0 1 Efficient Manipulation of Logical Formulas as Decision Diagrams true x = Intersection of “source” edges 10
  14. x’ y’ x y Relational product: model step (x =

    0) ∧ (y = 1) true (y = 1) 0 1 (x’ = x + 1) ∧ (y’ = y) true (y’ = y) 1 … … 0 1 2 1 2 3 0 1 2 2 0 1 Efficient Manipulation of Logical Formulas as Decision Diagrams true (y = 1) 1 x = Intersection of “source” edges Extract “target” edges 10
  15. x’ y’ x y Relational product: model step (x =

    0) ∧ (y = 1) true (y = 1) 0 1 (x’ = x + 1) ∧ (y’ = y) true (y’ = y) 1 … … 0 1 2 1 2 3 0 1 2 2 0 1 Efficient Manipulation of Logical Formulas as Decision Diagrams true (y = 1) 1 x = 10 Intersection of “source” edges Extract “target” edges
  16. x’ y’ x y Relational product: model step (x =

    0) ∧ (y = 1) true (y = 1) 0 1 (x’ = x + 1) ∧ (y’ = y) true (y’ = y) 1 … … 0 1 2 1 2 3 0 1 2 2 0 1 Efficient Manipulation of Logical Formulas as Decision Diagrams (x = 1) ∧ (y = 1) true (y = 1) 1 1 x = The set of reachable states after one step of the model 10 Intersection of “source” edges Extract “target” edges
  17. Fixed point calculation x x x x … Efficient Manipulation

    of Logical Formulas as Decision Diagrams Repeat until new states keep appearing Many possible algorithms: BFS, Saturation 11
  18. • When should we merge two nodes? • Decision diagrams:

    semantic equivalence • Would be too costly for SMT formulas: solver required • Compromise: syntactic equivalence + normal form transformation Syntactic vs semantic equivalence Efficient Manipulation of Logical Formulas as Decision Diagrams x < 5 !(x >= 5) = ? Semantically equivalent Syntactically different More precise → smaller diagrams 12
  19. Efficient Manipulation of Logical Formulas as Decision Diagrams • Compromise:

    syntactic equivalence + normal form transformation – Replaces appearances of substituted variable with a constant – Removes unnecessary operands – Replaces operations expressible using other operations – Entirely syntactic, no solver used → lightweight Syntactic vs semantic equivalence φ ∧ true φ x < 5 !(x >= 5) 13
  20. New data structure: substitution diagram • Decision diagram structure from

    SMT formulas • Lazy evaluation • Syntactically equivalent nodes are merged • Lightweight normal form transformation • Implemented in the Theta model checker – Reachability analysis – github.com/ftsrg/theta Summary f f t (a ∨ ¬b) ∧ (x = 2) true ¬b ∧ (x = 2) (x = 2) 2 Enables the use of decision-diagram-based (e.g., saturation) algorithms on SMT-based model representations Efficient Manipulation of Logical Formulas as Decision Diagrams 14
  21. Efficient Manipulation of Logical Formulas as Decision Diagrams • How

    good is our normal form transformation? – Compare node count of decision diagrams vs substitution diagrams → 10000 randomly generated transition systems → 10000 SMT formulas → 3789 satisfiable formulas → Build decision and substitution diagrams from these formulas and calculate node counts Evaluation 18
  22. Efficient Manipulation of Logical Formulas as Decision Diagrams • How

    good is our normal form transformation? – Node count comparison on 3789 randomly generated SMT formulas Evaluation MDD is always smaller or equal in size Substitution diagram is not significantly larger in most cases 19