Slide 1

Slide 1 text

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

Slide 2

Slide 2 text

• 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

Slide 3

Slide 3 text

• 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

Slide 4

Slide 4 text

• 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

Slide 5

Slide 5 text

• 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

Slide 6

Slide 6 text

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

Slide 7

Slide 7 text

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

Slide 8

Slide 8 text

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

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

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

Slide 11

Slide 11 text

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

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

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

Slide 14

Slide 14 text

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

Slide 15

Slide 15 text

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

Slide 16

Slide 16 text

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

Slide 17

Slide 17 text

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

Slide 18

Slide 18 text

• 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

Slide 19

Slide 19 text

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

Slide 20

Slide 20 text

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

Slide 21

Slide 21 text

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

Slide 22

Slide 22 text

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