SMT-based Weighted Model Integration with Structure Awareness
Abstract
Weighted Model Integration (WMI) is a popular formalism aimed at unifying approaches for probabilistic inference in hybrid domains, involving logical and algebraic constraints.
Despite a considerable amount of recent work, allowing WMI algorithms to scale with the complexity of the hybrid problem is still a challenge.
In this paper we highlight some substantial limitations of existing state-of-the-art solutions, and develop an algorithm that combines SMT-based enumeration, an efficient technique in formal verification, with an effective encoding of the problem structure.
This allows our algorithm to avoid generating redundant models, resulting in substantial computational savings.
An extensive experimental evaluation on both synthetic and real-world datasets confirms the advantage of the proposed solution over existing alternatives.
INTRODUCTION
Weighted Model Integration [Belle et al., 2015] recently emerged as a unifying formalism for probabilistic inference in hybrid domains, characterized by both continuous and discrete variables and their relationships.
The paradigm extends Weighted Model Counting (WMC)
[Chavira and Darwiche, 2008], which is the task of computing the weighted sum of the set of satisfying assignments of a propositional formula, to deal with SMT formulas (e.g. [Barrett et al., 2009]).
Whereas WMC can be made extremely efficient by leveraging component caching techniques [Sang et al., 2004, Bacchus et al., 2009], these strategies are hard to apply for WMI because of the tight coupling induced by the arithmetic constraints.
Indeed, component caching approaches for WMI are restricted to fully factorized densities with few dependencies among continuous variables [Belle et al., 2016].
Another direction specifically targets acyclic [Zeng and Van den Broeck, 2019, Zeng et al., 2020a] or loopy [Zeng et al., 2020b] pairwise models.
Exact solutions for more general classes of densities and constraints mainly leverage advancements in SMT technology or in knowledge compilation (KC)
[Darwiche and Marquis, 2002].
WMI-PA [Morettin et al., 2017, 2019] relies on SMTbased Predicate Abstraction (PA) [Lahiri et al., 2006] to reduce the number of models to be generated and integrated over, and was shown to achieve substantial improvements over previous solutions.
However, we show how WMI-PA has the major drawback of ignoring the structure of the weight function when pruning away redundant models.
This seriously affects its simplification power when dealing with symmetries in the density.
The use of KC for hybrid probabilistic inference was pioneered by Sanner and Abbasnejad [2012] and further refined in a series of later works [Kolb et al., 2018, Dos Martires et al., 2019, Kolb et al., 2020,
Feldstein and Belle, 2021].
By compiling a formula into an algebraic circuit, KC techniques can exploit the structure of the problem to reduce the size of the resulting circuit, and are at the core of many state-of-the-art approaches for
WMC [Chavira and Darwiche, 2008].
However, even the most recent solutions for WMI [Dos Martires et al., 2019,
Kolb et al., 2020] have serious troubles in dealing with densely coupled problems, resulting in exponentially large circuits.
In this paper we introduce a novel algorithm for WMI that aims to combine the best of both worlds, by introducing weight-structure awareness into PA-based WMI.
The main idea is to iteratively build a formula which mimics the conditional structure of the weight function, so as to drive the
SMT-based enumeration algorithm preventing it from generating redundant models.
An extensive experimental evaluation on synthetic and real-world datasets shows substantial computational advantages of the proposed solution over existing alternatives for the most challenging settings.
Our main contributions can be summarized as follows:
• We identify major efficiency issues of existing stateof-the-art WMI approaches, both PA and knowledgecompilation based.
• We introduce SA-WMI-PA, a novel WMI algorithm that combines PA with weight-structure awareness.
• We show how SA-WMI-PA achieves substantial computational improvements over existing solutions in both synthetic and real-world settings.
BACKGROUND 2.1 SMT AND PREDICATE ABSTRACTION
Satisfiability Modulo Theories (SMT) (see Barrett et al.
[2009]) consists in deciding the satisfiability of first-order formulas over some given theory.
For the context of this paper, we will refer to quantifier-free SMT formulas over linear real arithmetic ( LRA ), possibly combined with uninterpreted function symbols ( LRA ∪ EUF ).
We adopt the notation and definitions in Morettin et al.
We use B def = {⊤ , ⊥} to indicate the set of Boolean value, whereas R indicates the set of real values.
SMT( LRA ) formulas combines Boolean variables
A i ∈ B and LRA atoms in the form ( (cid:80)
i c i x i ▷◁ c ) (where c i are rational values, x i are real variables in R and ▷◁ is one of the standard algebraic operators { = , ̸ = , <, >, ≤ , ≥} ) by using standard Boolean operators {¬ , ∧ , ∨ , → , ↔} .
In SMT( LRA ∪ EUF ), LRA terms can be interleaved with uninterpreted function symbols.
Some shortcuts are provided to simplify the reading.
The formula ( x i ≥ l ) ∧ ( x i ≤ u ) is shortened into (cid:74) x i ∈
[ l, u ] (cid:75) .
Given an SMT formula φ , a total truth assignment µ is a function that maps every atom in φ to a truth value in B .
A partial truth assignment maps only a subset of atoms to B .
2.2 WEIGHTED MODEL INTEGRATION (WMI)
Let x def = { x 1 , ..., x N } ∈ R N and A def = { A 1 , ..., A M } ∈
B M for some integers N and M .
φ ( x , A ) denotes an
SMT( LRA ) formula over variables in A and x (subgroup of variables are admissible), while w ( x , A ) denotes a nonnegative weight function s.t. R N × B M (cid:55)−→ R + .
Intuitively, w encodes a (possibly unnormalized) density function over
A × x .
Hereafter µ A denotes a truth assignment on A , µ LRA denotes a truth assignment on the LRA -atoms of φ , φ [ µ A ] ( x ) denotes (any formula equivalent to) the formula obtained from φ by substituting every Boolean value
A i with its truth value in µ A and propagating the truth values through Boolean operators, and w [ µ A ] ( x ) def = w ( x , µ A ) is w restricted to the truth values of µ A .
Given a theory T ∈ {LRA , LRA ∪ EUF} , the nomenclature TTA ( φ ) def = { µ 1 , ..., µ j } defines the set of T -consistent total assignments over both propositional and T atoms that propositionally satisfy φ ; TA ( φ ) def = { µ 1 , ..., µ j } represents one set of T partial assignments over both propositional and T atoms that propositionally satisfy φ , s.t.
every total assignment in TTA ( φ ) is a super-assignment of some of the partial ones in TA ( φ ) .
Given by φ ( x , A ) , with TTA ( ∃ x .φ )
we mean the set of all total truth assignment µ A on A s.t.
φ [ µ A ] ( x ) is T -satisfiable, and by TA ( ∃ x .φ ) a set of partial ones s.t.
every total assignment in TTA ( ∃ x .φ ) is a superassignment of some of the partial ones in TA ( ∃ x .φ ) .
The Weighted Model Integral of w ( x , A ) over φ ( x , A ) is defined as follows [Morettin et al., 2019]:
[Equation]
where the µ A ’s are all total truth assignments on A ,
WMI nb ( φ, w | x ) is the integral of w ( x ) over the set { x | φ ( x ) is true } (“ nb ” means “no-Booleans”).
We call a support of a weight function w ( x , A ) any subset of R N × B M out of which w ( x , A ) = 0 , and we represent it as a LRA -formula χ ( x , A ) .
We recall that, consequently,
WMI ( φ ∧ χ, w | x , A ) =
WMI ( φ, w | x , A ) .
[Equation]
We consider the class of feasibly integrable on LRA ( FI LRA ) functions w ( x ) , which contain no conditional component, and for which there exists some procedure able to compute WMI nb ( µ LRA , w | x ) for every set of LRA literals on x .
(E.g., polynomials are FI LRA .)
Then we call a weight function w ( x , A ) , feasibly integrable under LRA conditions ( FIUC LRA )
iff it can be described in terms of a support
LRA -formula χ ( x , A ) ( ⊤ if not provided), a set Ψ def = { ψ i ( x , A ) }
Ki =1 of LRA conditions , in such a way that, for every total truth assignment µ Ψ to Ψ , w [ µ Ψ ] ( x ) is total and FI LRA in the domain given by the values of ⟨ x , A ⟩ which satisfy ( χ ∧ µ Ψ )
[ µ A ] .
FIUC LRA functions are all the weight functions which can be described by means of arbitrary combinations of nested if-then-else’s on conditions in
A and Ψ , s.t.
each branch µ Ψ results into a FI LRA weight function.
Each µ Ψ describes a portion of the domain of w , inside which w [ µ Ψ ] ( x ) is FI LRA , and we say that µ Ψ identifies w [ µ Ψ ] in w .
In what follows we assume w.l.o.g. that FIUC LRA functions are described as combinations of constants, variables, standard mathematical operators + , − , · , / un-conditioned mathematical functions (e.g., exp, sin, ... ), conditional expressions in the form ( If ψ i Then t 1 i Else t 2 i ) whose conditions ψ i are LRA formulas and terms t 1 i , t 2 i are FIUC LRA .
1: ⟨ φ ∗ , w ∗ , A ∗ ⟩ ← LabelConditions φ,
, x ,
) 2: M A ∗ ← TTA ( PredAbs [ φ ∗ ]
( A ∗ )) 3: vol ←4: for µ A ∗ ∈
M A ∗ do 5:
Simplify ( φ ∗ [ µ A ∗ ] ) 6: if LiteralConjunction ( φ ∗ [ µ A ∗ ] ) then 7: vol ← vol + WMI nb ( φ ∗ [ µ A ∗ ] , w ∗ [ µ A ∗ ] | x ) 8: else 9:
M LRA ← TA ( PredAbs [ φ ∗ [ µ A ∗ ] ] ( Atoms ( φ ∗ [ µ A ∗ ] ))) 10: for µ LRA ∈ M LRA do 11: vol ← vol + WMI nb ( µ LRA , w ∗ [ µ A ∗ ] | x ) 12: return vol
2.3 WMI VIA PREDICATE ABSTRACTION
WMI-PA is an efficient WMI algorithm presented in Morettin et al.
[2017, 2019] which exploits SMT-based predicate abstraction.
Let w ( x , A ) be a FIUC LRA function as above.
WMI-PA is based on the fact that
[Equation]
A ∗ def =
A ∪ B s.t.
B def = { B 1 , ..., B K } are fresh propositional atoms and w ∗ ( x , A ∪ B ) is the weight function obtained by substituting in w ( x , A ) each condition ψ k with B k .
The pseudocode of WMI-PA is reported in Algorithm 1.
First, the problem is transformed (if needed) by labeling all conditions Ψ occurring in w ( x , A ) with fresh
Boolean variables B .
After this preprocessing stage, the set M A ∗ def =
TTA ( ∃ x .φ ∗ ) is computed by invoking
SMT-based predicate abstraction Lahiri et al.
[2006], namely TTA ( PredAbs [ φ ∗ ]
( A ∗ )) .
Then, the algorithm iterates over each Boolean assignment µ A ∗ in M A ∗ .
φ ∗ [ µ A ∗ ] is simplified by the Simplify procedure.
Then, if φ ∗ [ µ A ∗ ] is already a conjunction of literals, the algorithm directly computes its contribution to the volume by calling
WMI nb ( φ ∗ [ µ A ∗ ] , w ∗ [ µ A ∗ ] | x ) .
Otherwise, TA ( φ ∗ [ µ A ∗ ] ) is computed as TA ( PredAbs [ φ ∗ [ µ A ∗ ] ] ( Atoms ( φ ∗ [ µ A ∗ ] ))) to produce partial assignments, and the algorithm iteratively computes contributions to the volume for each µ LRA .
We refer the reader to Morettin et al.
[2019] for more details.
Notice that in the actual implementation the potentiallylarge sets M A ∗ and M LRA are not generated explicitly.
Rather, their elements are generated, integrated and then dropped one-by-one, so that to avoid space blowup.
EFFICIENCY ISSUES 3.1 KNOWLEDGE COMPILATION
We start our analysis of WMI techniques by noticing a major problem with existing KC approaches for WMI [Dos Martires et al., 2019, Kolb et al., 2020], in that they tend easily to blow up in space even with simple weight functions.
Consider, e.g., the case in which
[Equation]
[Equation]
ψ i then w
[Equation]
x ) else
[Equation] [Equation]
where the ψ i s are LRA conditions on { x , A } and the w i 1 , w i 2 are generic functions on x .
First, the decision diagrams do not interleave arithmetical and conditional operators, rather they push all the arithmetic operators below the conditional ones.
Thus with (8) the resulting decision diagrams consist of 2 N branches on the ψ i s, each corresponding to a distinct unconditioned weight function of the form (cid:81)
Ni
=1 w ij i ( x ) s.t.
j i ∈ { 1 , 2 } .
Second, the decision diagrams are built on the Boolean abstraction of w ( x , A ) , s.t.
they do not eliminate a priori the useless branches consisting in LRA -inconsistent combinations of ψ i s, which can be up to exponentially many.
With WMI-PA, instead, the representation of (8) does not grow in size, because FIUC LRA functions allow for interleaving arithmetical and conditional operators.
Also, the
SMT-based enumeration algorithm does not generate LRAinconsistent assignments on the ψ i s.
We stress the fact that (8) is not an artificial scenario: rather, e.g., this is the case of the real-world logistics problems in Morettin et al.
3.2 WMI-PA
We continue our analysis by noticing a major deficiency also of the WMI-PA algorithm, that is, it fails to leverage the structure of the weight function to prune the set of models to integrate over.
We illustrate the issue by means of a simple example (see Figure 1).
Example 1 Let φ def = ⊤ , χ def = (cid:74) x 1 ∈ [0 , 2] (cid:75)
∧ (cid:74) x 2 ∈ [0 , 3] (cid:75)
(Figure 1(a)) and let w ( x , A ) be a tree-structured weight function defined as in Figure 1(b).
To compute WMI ( φ ∧ χ, w | x , A ) , six integrals have to be computed: x 21 x 2 on (cid:74) x 1 ∈ [1 , 2] (cid:75)
∧ (cid:74) x 2 ∈ [1 , 3] (cid:75) (if A 1 = ⊤ ) x 31 x 2 on (cid:74) x 1 ∈ [1 , 2] (cid:75)
∧ (cid:74) x 2 ∈ [0 , 1] (cid:75) (if A 1 = ⊤ ) x 1 x 2 2 on (cid:74) x 1 ∈ [0 , 1] (cid:75) ∧ (cid:74) x 2 ∈ [2 , 3] (cid:75)
(if A 1 = ⊤ ) x 1 x 32 on (cid:74) x 1 ∈ [0 , 1] (cid:75) ∧
(cid:74) x 2 ∈ [0 , 2] (cid:75) (if A 1 = ⊤ ).
2 x 1 x 2 on (cid:74) x 1 ∈ [0 , 2] (cid:75) ∧
(cid:74) x 2 ∈ [0 , 3] (cid:75) (if A 1 = ⊥ , A 2 = ⊤ ) 3 x 1 x 2 on (cid:74) x 1 ∈ [0 , 2] (cid:75)
∧ (cid:74) x 2 ∈ [0 , 3] (cid:75) (if A 1 = ⊥ , A 2 = ⊥ )
When WMI-PA is used (Algorithm 1), applying LabelCon- ditions(...) we obtain (Figure 1(c)): φ [Equation]
[Equation]
and the weight function w ∗ ( x , A ∪ B ) shown in Figure 1(d).
Then, by applying TTA ( PredAbs [ φ ∗ ] ( A ∗ )) (row 2) we obtain 24 total assignments M A ∗ on A ∪ B , as shown in
Figure 1(e)..
Notice that WMI-PA uselessly splits intoparts the integrals on x 21 x 2 and x 1 x 32 and into 6 parts the integral on 2 x 1 x 2 and on 3 x 1 x 2 .
Also, it repeats the very same integrals for { A 1 ,
A 2 , ... } and { A 1 , ¬ A 2 , ... } .
⋄
We highlight two facts.
First, WMI-PA enumerates total truth assignments on the Boolean atoms A ∪ B in
TTA ( ∃ x .φ ∗ ) (6) (row 2 in Algorithm 1), assigning also unnecessary values.
Second, WMI-PA labels LRA conditions in w by means of fresh Boolean atoms B (row 1 in
Algorithm 1).
This forces the enumerator to assign all their values in every assignment, even when not necessary.
The key issue about WMI-PA is that the enumeration of
TTA ( ∃ x .φ ∗ ) in (6) and of TA ( φ ∗ [ µ A ∗ ] ) in (4) (rows 2 andin Algorithm 1) is not aware of the conditional structure of the weight function w , in particular, it is not aware of the fact that often partial assignments to the set of conditions in w ∗ (both Boolean and LRA ) are sufficient to identify the value of a FIUC LRA function (e.g { A 1 , B 1 , B 2 } suffices to identify x 2 1 x 2 , or {¬ A 1 , A 2 } suffices to identify 2 x 1 x 2 ), so that it is forced to enumerate all total assignments extending them (e.g. { A 1 , A 2 , B 1 , B 2 , B 3 } and { A 1 , A 2 , B 1 , B 2 , ¬ B 3 } ).
Thus, to cope with this issue, we need to modify WMI-PA to make it aware of the conditional structure of w .
MAKING WMI-PA WEIGHT-STRUCTURE AWARE
The key idea to prevent total enumeration works as follows.
We do not rename with B the conditions Ψ in w and, rather than enumerating total truth assignments for ∃ x .φ ∗ as in (6)–(7), we enumerate partial assignments for ∃ x .φ ∗∗ where φ ∗∗ def = φ ∧ χ ∧ sk ( w ) and sk ( w ) –which we call the conditional skeleton of w – is a LRA formula s.t.:
( a ) its atoms are all and only the conditions in Ψ , ( b ) is LRA -valid, so that φ ∧ χ is equivalent to φ ∧ χ ∧ sk ( w ) , ( c ) any partial truth value assignment µ to the conditions Ψ which makes sk ( w ) true is such that w [ µ ] is FI LRA .
Thus, we have that (2) can be rewritten as:
[Equation]
where | A \ µ | is the number of Boolean atoms in A that are not assigned by µ .
Condition ( c ) guarantees that
WMI nb ( φ ∗∗ [ µ ] , w [ µ ] | x ) in (9) can be directly computed, without further partitioning.
The 2 | A \ µ | factor in (9) resembles the fact that, if some Boolean atom A i ∈ A is not assigned in µ , then WMI nb ( φ ∗∗ [ µ ] , w [ µ ] | x ) should be counted twice because µ represents two assignments µ ∪{ A i } and µ ∪{¬ A i } which would produce two identical integrals.
Notice that logic-wise sk ( w ) is non-informative because it is a valid formula.
Nevertheless, the role of sk ( w ) is to mimic the structure of w so that to “make the enumerator aware of the presence of the conditions Ψ ”, forcing every assignment µ to assign truth values also to these conditions which are necessary to make w [ µ ] FI LRA and hence make
WMI nb ( φ ∗∗ [ µ ] , w [ µ ] | x ) directly computable, without further partitioning.
An important issue is to avoid sk ( w ) blow up in size.
E.g., one could use as sk ( w ) a formula encoding the conditional structure of an XADDs or (F)XSDDs, but this may cause a blow up in size, as discussed in Section 3.1.
In order to prevent such problems, we do not generate sk ( w ) explicitly.
Rather, we build it as a disjunction of partial assignments over Ψ which we enumerate progressively.
To this extent, we define sk ( w ) def = ∃ y .
(cid:74) y
=
w (cid:75) where (cid:74) y
= w (cid:75) is a formula on A , x , y s.t.
y def = { y, y 1 , ..., y k } is a set of fresh variables.
Thus, TA ( ∃ x . ( φ ∧ χ ∧ ∃ y .
(cid:74) y
=
w (cid:75) )) can be computed as TA ( ∃ xy .
( φ ∧ χ ∧ (cid:74) y
= w (cid:75) ))
because the y ’s do not occur in φ ∧ χ , with no need to generate sk ( w ) explicitly.
The enumeration of TA ( ∃ xy .
( φ ∧ χ ∧ (cid:74) y
= w (cid:75) )) is performed by the very same SMT-based procedure used in Morettin et al.
(cid:74) y
=
w (cid:75) is obtained by taking ( y = w ) , s.t.
y is fresh, and recursively substituting bottom-up every conditional term ( If ψ i Then t i 1 Else t i 2 ) in it with a fresh variable y i ∈ y , adding the definition of ( y i =
( If ψ i Then t i 1 Else t i 2 )) as ( ¬ ψ i ∨ y i =
t i 1 ) ∧ ( ψ i ∨ y i
=
t i
[Equation]
[Equation]
[Equation]
This labeling&rewriting process, which is inspired to labeling CNF-ization [Tseitin, 1968], guarantees that the size of (cid:74) y
=
w (cid:75) is linear wrt.
that of w .
E.g., if (8) holds, then (cid:74) y
=
w (cid:75) is ( y = (cid:81)
Ni =1 y i ) ∧ (cid:86) Ni =1 (( ¬ ψ i ∨ y i =
w i 1 ( x ))
∧ ( ψ i ∨ y i =
w i 2 ( x ))) .
One problem with the above definition of (cid:74) y = w (cid:75) is that it is not a LRA -formula, because w may include multiplications or even transcendental functions out of the conditions Ψ 2 , which makes SMT reasoning over it dramatically hard or even undecidable.
We notice, however, that when computing TA ( ∃ xy .
( φ ∧ χ ∧ (cid:74) y
= w (cid:75) ))
the arithmetical functions (including operators + , − , ∗ , / ) occurring in w out of the conditions Ψ have no role, since the only fact that we need to guarantee for the validity of sk ( w ) is that they are indeed functions, so that ∃ y. ( y = f ( ... )) is always valid.
3 (In substance, during the enumeration we are interested only in the truth values of the conditions Ψ in µ which make w [ µ ] FI LRA , regardless the actual values of w [ µ ] ).
Therefore we can safely substitute condition-less arithmetical functions (including operators + , − , · , / ) with some fresh uninterpreted function symbols, obtaining a LRA ∪ EUFformula (cid:74) y
= w (cid:75) EUF , which is relatively easy to solve by standard SMT solvers [Barrett et al., 2009].
It is easy to see of (cid:74) y = that a partial assignment µ evaluating (cid:74) y = w (cid:75) to true is
LRA -satisfiable iff its corresponding assignment µ EUF is
LRA∪EUF -satisfiable.
Therefore, we can modify the enumeration procedure into TA ( ∃ xy .
( φ ∧ χ ∧ (cid:74) y
= w (cid:75) EUF )) .
Finally, we enforce the fact that the two branches of an if-then-else are alternative by adding to (11) a mutualexclusion constraint ¬
( y i =
t i 1 ) ∨ ¬ ( y i =
t i 2 ) , so that the choice of the function is univocally associated to the list of decisions on the ψ i s. The procedure producing (cid:74) y
= w (cid:75)
EUF is described in detail in Appendix, Algorithm 1.
Example 2 Consider the problem in Example 1.
Figureshows the relabeling process applied to the weight function w .
The resulting (cid:74) y
=
w (cid:75) EUF formula is:
[Equation]
[Equation] [Equation] ∧ [Equation]
[Equation]
[Equation]
x )))
∧ (
[Equation]
A
[Equation] [Equation]
[Equation] [Equation]
[Equation]
( y
[Equation]
21 ( x )))
∧ (
[Equation]
A
[Equation]
Figure 3 illustrates a possible enumeration process.
The algorithm enumerates partial assignments satisfying φ ∧ χ ∧ (cid:74)
y
= w (cid:75) EUF , restricted on the conditions Ψ def =
{ A 1 , A 2 , ( x 1 ≥ 1) , ( x 2 ≥ 1) , ( x 2 ≥ 2) } , which is equivalent to enumerate TA ( ∃ xy .
( φ ∧ χ ∧ (cid:74) y
= w (cid:75) EUF )) .
Assuming the enumeration procedure picks nondeterministic choices following the order of the above set 5 and assigning positive values first, then in the first branch the following satisfying partial assignment is generated, in order:χ ∪ { ( y = y 5 ) , A 1 , ( y 5 = y 3 ) , ¬ ( y 5 = y 4 ) , ( x 1 ≥ 1) , ( y 3 = y 1 ) , ¬ ( y 3 = y 2 ) , ( x 2 ≥ 1) , ( y 1 = f 11 ( x )) , ¬ ( y 1 = f 12 ( x )) } .
(Notice that, following the chains of true equalities, we have y =
y 5 = y 3 =
y 1 = f 11 ( x ) .)
Then the SMT solver extracts from the subset { A 1 , ( x 1 ≥ 1) , ( x 2 ≥ 1) } restricted on the conditions in Ψ .
Then the blocking clause ¬
A 1 ∨ ¬ ( x 1 ≥ 1) ∨ ¬ ( x 2 ≥ 1) is added to the formula, which prevents to enumerate the same subset again.
This forces the algorithm to backtrack and generate χ ∪ { ( y = y 5 ) , A 1 , ( y 5 = y 3 ) , ¬ ( y 5 = y 4 ) , ( x 1 ≥ 1) , ( y 3 = y 1 ) , ¬ ( y 3 = y 2 ) , ¬ ( x 2 ≥ 1) , ( y 1 = f 12 ( x )) , ¬ ( y 1 =
f 11 ( x )) } .
producing the assignment: { A 1 , ( x 1 ≥ 1) , ¬ ( x 2 ≥ 1) } .
Overall the algorithm enumerates the following ordered collection of partial assignments restricted to
Atoms ( φ ∧ χ ) ∪ Ψ : χ ∪ { A 1 , ( x 1 ≥ 1) , ( x 2 ≥ 1) } , //y = ... = f 11 ( x ) χ ∪ { A 1 , ( x 1 ≥ 1) , ¬ ( x 2 ≥ 1) } , //y = ...
=
f 12 ( x ) χ ∪ { A 1 , ¬ ( x 1 ≥ 1) , ( x 2 ≥ 2) } , //y = ...
= f 21 ( x ) χ ∪ { A 1 , ¬ ( x 1 ≥ 1) , ¬ ( x 2 ≥ 2) } , //y = ... = f 22 ( x ) χ ∪ {¬ A 1 , A 2 } , //y = ... = f 3 ( x ) χ ∪ {¬ A 1 , ¬
A 2 } //y = ...
= f 4 ( x ) which correspond to the six integrals of Example 1.
Notice that according to (2) the first four integrals have to be multiplied by 2, because the partial assignment { A 1 } covers two total assignments { A 1 , A 2 } and { A 1 ,
¬
A 2 } .
Notice also that the disjunction of the six partial assignments, ( A 1 ∧ ( x 1 ≥ 1) ∧ ( x 2 ≥ 1)) ∨ ... ∨ ( ¬ A 1 ∧¬ A 2 ) , matches the definition of sk ( w ) , which we have computed by progressive enumeration rather than encoded a priori.
⋄
Based on the previous ideas, we develop SA-WMI-PA, a novel “weight structure aware” variant of WMI-PA.
The pseudocode of SA-WMI-PA is reported in Algorithm 2.
As with WMI-PA, we enumerate the assignments in two main steps: in the first loop (rows 3-7) we generate a set M A ∗ of partial assignments µ A ∗ over the
Boolean variables A , s.t.
φ ∗∗ [ µ A ] is LRA -satisfiable and does not contain Boolean variables anymore.
In Example 2 M A ∗ def = {{ A 1 } , {¬ A 1 , A 2 } , {¬ A 1 , ¬ A 2 }} .
In the second loop (rows 11-19), for each µ A ∗ in M A ∗ we enumerate the set M LRA of LRA -satisfiable partial assignments satisfying φ ∗∗ [ µ A ∗ ] (that is, on LRA atoms in Atoms ( φ ∧ χ ) ∪ Ψ ), we compute the integral WMI nb ( µ LRA , w [ µ A ∗ ] | x ) , multiply it by the 2 | A \ µ A ∗ | factor and add it to the result.
In Example 2, if e.g. µ A ∗ = {
A 1 } ,
TA ( PredAbs [ φ ∗∗ [ µ A ∗ ] ] ( Atoms ( φ ∗∗ [ µ A ∗ ] ))) computes the four partial assignments { χ ∪ { ( x 1 ≥ 1) , ( x 2 ≥ 1) } , ..., χ ∪ {¬ ( x 1 ≥ 1) , ¬ ( x 2 ≥ 2) }} .
In detail, in row 2 we extend φ ∧ χ with (cid:74) y =
w (cid:75) EUF to provide structure awareness.
(We recall that, unlike with WMI-PA, we do not label LRA conditions with fresh Boolean variables B .)
Next, in row 3 we perform
TA ( PredAbs [ φ ∗∗ [ µ A ] ] ( A )) to obtain a set M A of partial assignments restricted on Boolean atoms A .
Then, for each assignment µ A ∈ M A we build the (simplified) residual φ ∗∗ [ µ A ] .
Since µ A is partial, φ ∗∗ [ µ A ] is not guaranteed to be free of Boolean variables A , as shown in Example 3.
If this is the case, we simply add µ A to M A ∗ , otherwise we invoke
TTA ( PredAbs [ φ ∗∗ [ µ A ] ] ( A )) to assign the remaining variables and conjoin each assignment µ A residual to µ A , ensuring that the residual now contains only LRA atoms (rows 4- 10).
The second loop (rows 11-19) resembles the main loop in
WMI-PA, with the only relevant difference that, since µ A ∗ is partial, the integral is multiplied by a 2 | A \ µ A ∗ | factor.
Notice that in general the assignments µ A ∗ are partial even if the steps in rows 9-10 are executed; the set of residual
Boolean variables in φ ∗∗ [ µ A ] are a (possibly much smaller) subset of A \ µ A because some of them do not occur anymore in φ ∗∗ [ µ A ] after the simplification, as shown in the following example.
Example 3 Let φ def =
( A 1 ∨ A 2 ∨ A 3 ) ∧ ( ¬ A 1 ∨ A 2 ∨ ( x ≥ 1))
∧ ( ¬ A 2 ∨ ( x ≥ 2))
∧ ( ¬ A 3 ∨ ( x ≤ 3)) , χ def = (cid:74) x 1 ∈ [0 , 4] (cid:75) and w ( x , A ) def = 1 . 0 .
Suppose TA ( PredAbs [ φ ∗∗ ] ( A )) finds the partial assignment 1: M A ∗ ← ∅ ; vol ←2: φ ∗∗ ← φ ∧ χ ∧ (cid:74) y = w (cid:75) EUF 3: M A ← TA ( PredAbs [ φ ∗∗ ] ( A )) 4: for µ A ∈ M A do 5: Simplify ( φ ∗∗ [ µ A ] ) 6: if φ ∗∗ [ µ A ] does not contain Boolean variables then 7:
M A ∗ ← M A ∗ ∪ { µ A } 8: else 9: for µ A residual ∈ TTA ( PredAbs [ φ ∗∗ [ µ A ] ] ( A )) do 10:
M A ∗ ← M A ∗ ∪ { µ A ∧ µ A residual } 11: for µ A ∗ ∈
M A ∗ do 12: k ← | A \ µ A ∗ | 13:
Simplify ( φ ∗∗ [ µ A ∗ ] ) 14: if LiteralConjunction ( φ ∗∗ [ µ A ∗ ] ) then 15: vol ← vol + 2 k · WMI nb ( φ ∗∗ [ µ A ∗ ] , w [ µ A ∗ ] | x ) 16: else 17:
M LRA ← TA ( PredAbs [ φ ∗∗ [ µ A ∗ ] ] ( Atoms ( φ ∗∗ [ µ A ∗ ] ))) 18: for µ LRA ∈ M LRA do 19: vol ← vol + 2 k · WMI nb ( µ LRA , w [ µ A ∗ ] | x ) 20: return vol { ( x ≥ 0) , ( x ≤ 4) ,
A 2 , ( x ≥ 1) , ( x ≥ 2) , ( x ≤ 3) } , whose projected version is µ A def = { A 2 } (row 3).
Then φ ∗∗ [ µ A ] reduces to ( ¬ A 3 ∨ ( x ≤ 3)) , so that M A ∗ is {{ A 2 , A 3 } , { A 2 ,
¬ A 3 }} , avoiding branching on A 1 .
⋄
We stress the fact that in our actual implementation, like with that of WMI-PA, the potentially-large sets M A ∗ and
M LRA are not generated explicitly.
Rather, their elements are generated, integrated and then dropped one-by-one, so that to avoid space blowup.
We highlight two main differences wrt.
WMI-PA.
First, unlike with WMI-PA, the generated assignments µ A on A are partial, each representing 2 | A \ µ A | total ones.
Second, the assignments on (non-Boolean) conditions Ψ inside the µ LRA s are also partial, whereas with WMI-PA the assignments to the B s are total.
This may drastically reduce the number of integrals to compute, as empirically demonstrated in the next section.
EXPERIMENTAL EVALUATION
The novel algorithm SA-WMI-PA is compared to the original WMI-PA algorithm [Morettin et al., 2019], and the
WMI solvers based on KC: XADD
[Kolb et al., 2018],
XSDD and FXSDD
[Kolb et al., 2020].
Each of these methods is called from the Python framework pywmi [Kolb et al., 2019].
For both WMI-PA and SA-WMI-PA, we use M ATH SAT for SMT enumeration and L ATT E I NTE - [Figure] GRALE for computing integrals.
For the KC algorithms we use PSiPSI
[Gehr et al., 2016] as symbolic computer algebra backend.
All experiments are performed on an Intel Xeon
Gold 6238R @ 2.20GHz 28 Core machine with 128GB of ram and running Ubuntu Linux 20.04.
The code of SAWMI-PA is freely available at https://github.com/ unitn-sml/wmi-pa .
For improved readability, in both the experiments we report runtime using cactus plots, i.e. the single problem instances are increasingly sorted by runtime for each algorithm separately.
We highlight how, by construction, problem instances of the same tick of the x-axis are not guaranteed to be the same for different algorithms.
Steeper slopes of an algorithm curve means less efficiency.
5.1 SYNTHETIC EXPERIMENTS
We first evaluate our algorithm on random formulas and weights, following the experimental protocol of Morettin et al.
We define two recursive procedures to generate LRA formulae and weight functions with respect to a positive integer number D , named depth:
[Equation]
(cid:40)(cid:76)
[Equation]
=
[Equation] r φ ( D − 1) if D >[ ¬ ] A B / R otherwise r w ( D ) =     (cid:74) If r φ ( D ) Then r w ( D − 1) Else r w ( D − 1) (cid:75) or r w ( D − 1) ⊗ r w ( D − 1) if D >
P random ( x ) otherwise where (cid:76) ∈ { (cid:87) , (cid:86) , ¬ (cid:87) , ¬ (cid:86) } , ⊗ ∈ { + , ·} and P random ( x ) is a random polynomial function.
Using these procedure we generate instances of synthetic problems: [Equation] φ [Equation]
A ) =
[Equation]
D ) where l x , u
[Figure]
times and standard deviation in seconds on a set of DET
In contrast with the benchmarks used in other recent works [Kolb et al., 2018, 2020]
[Figure]
the procedure is not strongly biased towards the generation of problems with structural regularities, offering a more neutral perspective on how the different techniques are expected to perform in the wild.
The generated synthetic benchmark contains problems where the number of both Boolean and real variables is set to 3, while the depth of weights functions fits in the range [4 , 7] .
Timeout was set to 3600 seconds, similarly to what has been done in previous works.
In this settings, the approaches based on a SMT oracle clearly outperform those based on KC (Fig. 4 left).
In addition, SA-WMI-PA greatly improves over WMI-PA, thanks to a drastic reduction in the number of integrals computed (Fig.
4 right), with the advantage of our approach getting more evident when the weight functions are deeper.
5.2 DENSITY ESTIMATION TREES
We explore the use of WMI solvers for marginal inference in real-world probabilistic models.
In particular, we considered Density Estimation Trees (DETs)
[Ram and
Gray, 2011], hybrid density estimators encoding piecewise constant distributions.
Having only univariate conditions in the internal nodes, DETs natively support tractable inference when single variables are considered.
Answering queries like Pr ( X ≤ Y ) requires instead marginalizing over an oblique constraint, which is reduced to WMI: Pr
[Equation]
Being able to address this type of queries is crucial to apply WMI-based inference to e.g. probabilistic formal verification tasks, involving constraints that the system should satisfy with high probability.
We considered a selection of hybrid datasets from the UCI repository [Dua and Graff, 2017], reported in Table 1 in the Appendix.
Following the approach of Morettin et al.
[2020], discrete numerical features were relaxed into continuous variables, while n -ary categorical features are one-hot encoded with n binary variables.
After learning a DET on each dataset, we generated a benchmark of increasingly complex queries, 5 for each dataset, involving a ratio H ∈ [0 , 1] of the continuous variables.
More specifically, the queries are linear inequalities involving a number of variables k = max (1 , ⌊ H ·| x |⌋ ) .
Figure 5 depicts the runtime of the algorithms for H ∈ { 0 . 25 , 0 .
Timeout was set to 1200 seconds.
KC approaches have an edge for the simplest cases ( H ≤ 0 . 5 ) in which substantial factorization of the integrals is possible.
Contrarily to many other probabilistic models, which are akin to the case in Section 3.1, DETs are well-suited for KC-based inference, due to the absence of arithmetic operations in the internal nodes.
When the coupling between variables increases, however, the advantage of decomposing the integrals is overweight by the combinatorial reasoning capabilities of SA-WMI-PA.
We remark that SA-WMI-PA is agnostic of the underlying integration procedure, and thus in principle it could also incorporate a symbolic integration component.
CONCLUSION
We presented the first SMT-based algorithm for WMI that is aware of the structure of the weight function.
This is particularly beneficial when the piecewise density defined on top of
SMT( LRA ) constraints is deep, as it is often the case with densities learned from data.
We evaluated our algorithmic ideas on both synthetic and real-world problems, obtaining state-of-the-art results in many settings of practical interest.
Providing unprecedented scalability in the evaluation of complex probabilistic SMT problems, this contribution directly impacts the use of WMI for the probabilistic verification of systems.
While the improvements described in this work drastically reduce the number of integrations required to compute a weighted model integral, the integration itself remains an obstacle to scalability.
Combining the fast combinatorial reasoning offered by SMT solvers with symbolic integration is a promising research direction.
Acknowledgements
This research was partially supported by TAILOR, a project funded by EU Horizon 2020 research and innovation programme under GA
No 952215 and from the European Research Council (ERC) under the European Union’s Horizon 2020 research and innovation programme (grant agreement
No. [694980] SYNTH: Synthesising Inductive Data Models).
The authors would like to thank Pedro Zuidberg Dos
Martires for his help with XSDDs and FXSDDs.