This paper was converted on www.awesomepapers.org from LaTeX by an anonymous user.
Want to know more? Visit the Converter page.

A Compositional Atlas for Algebraic Circuits

Benjie Wang
University of California, Los Angeles
benjiewang@ucla.edu
&Denis Deratani Mauá
University of São Paulo
ddm@ime.usp.br &Guy Van den Broeck
University of California, Los Angeles
guyvdb@cs.ucla.edu
&YooJung Choi
Arizona State University
yj.choi@asu.edu
Abstract

Circuits based on sum-product structure have become a ubiquitous representation to compactly encode knowledge, from Boolean functions to probability distributions. By imposing constraints on the structure of such circuits, certain inference queries become tractable, such as model counting and most probable configuration. Recent works have explored analyzing probabilistic and causal inference queries as compositions of basic operators to derive tractability conditions. In this paper, we take an algebraic perspective for compositional inference, and show that a large class of queries—including marginal MAP, probabilistic answer set programming inference, and causal backdoor adjustment—correspond to a combination of basic operators over semirings: aggregation, product, and elementwise mapping. Using this framework, we uncover simple and general sufficient conditions for tractable composition of these operators, in terms of circuit properties (e.g., marginal determinism, compatibility) and conditions on the elementwise mappings. Applying our analysis, we derive novel tractability conditions for many such compositional queries. Our results unify tractability conditions for existing problems on circuits, while providing a blueprint for analysing novel compositional inference queries.

1 Introduction

Circuit-based representations, such as Boolean circuits, decision diagrams, and arithmetic circuits, are of central importance in many areas of AI and machine learning. For example, a primary means of performing inference in many models, from Bayesian networks [darwiche2003differential, Chavira08] to probabilistic programs [problog, problog-inference, holtzen2020scaling, saad2021sppl], is to convert them into equivalent circuits; this is commonly known as knowledge compilation. Inference via knowledge compilation has also been used for many applications in neuro-symbolic AI, such as constrained generation [AhmedNeurIPS22, ZhangICML23] and neural logic programming [manhaeve2018deepproblog, huang2021scallop]. Circuits can also be learned as probabilistic generative models directly from data [gens2013learning, rahman2014cutset, peharz2020random, LiuICLR23], in which context they are known as probabilistic circuits [probcirc]. Compared with neural generative models, probabilistic circuits enjoy tractable evaluation of inference queries such as marginal probabilities, which has been used for tasks such as fair machine learning [choi2021group] and causal reasoning [zevcevic2021interventional, wang2022tractable, wang2023compositional].

The key feature of circuits is that they enable one to precisely characterize tractability conditions under which a given inference query can be computed exactly and efficiently, in terms of structural properties of the circuit. One can then enforce these circuit properties when compiling or learning a model to enable tractable inference. For many basic inference queries, such as computing a marginal probability, tractability conditions are well understood [vergari2021atlas, BroadrickUAI24]. However, for more complex queries, the situation is less clear, and the exercise of deriving tractability conditions for a given query has usually been carried out in an instance-specific manner requiring significant effort.

In Figure 1, we illustrate two such queries. The marginal MAP (MMAP) [marginalmap] query takes a probabilistic circuit pp and some evidence 𝒆\bm{e} and asks for the most likely assignment of a subset of variables. The success probability inference in probabilistic logic programming [plog, smproblog] takes a circuit representation ϕ\phi of a logic program, a weight function ω\omega and some query 𝒒\bm{q}, and computes the probability of the query under the program’s semantics (MaxEnt, in the example). At first glance, these seem like very different queries, involving different types of input circuits (logical and probabilistic), and different types of computations. However, they share similar algebraic structure: logical and probabilistic circuits can be interpreted as circuits defined over different semirings, while maximization and summation can be viewed as aggregation over different semirings. In this paper, inspired by the compositional atlas for probabilistic circuits [vergari2021atlas], we take a compositional approach to algebraic inference problems, breaking them down into a series of basic operators: aggregation, product, and elementwise mapping. For example, the MMAP and probabilistic logic programming queries involve multiple interleaved aggregations and products, along with one elementwise mapping each. Given a circuit algorithm (and associated tractability condition) for each basic operator, we can reuse these algorithms to construct algorithms for arbitrary compositions. The key challenge is then to check if each intermediate circuit satisfies the requisite tractability conditions.

Our contributions can be summarized as follows. We introduce a compositional inference framework for algebraic circuits (Section 3) over arbitrary semirings, generalizing existing results on logical [darwiche2002knowledge] and probabilistic [vergari2021atlas] circuits. In particular, we provide a language for specifying inference queries involving different semirings as a composition of basic operators (Section 3.1). We then prove sufficient conditions for the tractability of each basic operator (Section 3.2) and novel conditions for composing such operators (Section 3.3). We apply our compositional framework to a number of inference problems (Section LABEL:sec:case_studies), showing how our compositional approach leads to more systematic derivation of tractability conditions and algorithms, and in some cases improved complexity analysis. In particular, we discover a tractability hierarchy for inference queries captured under the 2AMC framework [asp2mc], and reduce the complexity of causal backdoor/frontdoor adjustment on probabilistic circuits [pearl1995do, wang2023compositional] from quadratic/cubic to linear/quadratic respectively.

max𝐗𝐘𝐞p(𝐗,𝐘)\max_{\mathbf{X}}\sum_{\mathbf{Y}\sim\mathbf{e}}p(\mathbf{X},\mathbf{Y})p(𝐗,𝐘)p(\mathbf{X},\mathbf{Y})[[𝐘𝐞]][\![\mathbf{Y}\sim\mathbf{e}]\!]\otimes𝐘\oplus_{\mathbf{Y}}τid\tau_{\text{id}}𝐗\oplus_{\mathbf{X}}𝐗ω(𝐗)𝐘𝐪ϕ(𝐗,𝐘)𝐘ϕ(𝐗,𝐘)\sum_{\mathbf{X}}\omega(\mathbf{X})\sum_{\mathbf{Y}\sim\mathbf{q}}\frac{\phi(\mathbf{X},\mathbf{Y})}{\sum_{\mathbf{Y}}\phi(\mathbf{X},\mathbf{Y})}ϕ(𝐗,𝐘)\phi(\mathbf{X},\mathbf{Y})[[𝐘𝐪]][\![\mathbf{Y}\sim\mathbf{q}]\!][[]][\![\cdot]\!]𝐘\oplus_{\mathbf{Y}}τ1\tau_{-1}\otimes\otimes𝐘\oplus_{\mathbf{Y}}ω(𝐗)\omega(\mathbf{X})\otimes𝐗\oplus_{\mathbf{X}}
Figure 1: Example applications of our compositional inference framework for (Left) MMAP and (Right) Success Probability in Prob. Logic Programing under the Stable Model semantics (MaxEnt).

2 Preliminaries

Notation

We use capital letters (e.g., X,YX,Y) to denote variables and lowercase for assignments (values) of those variables (e.g., x,yx,y). We use boldface to denote sets of variables/assignments (e.g., 𝑿,𝒚\bm{X},\bm{y}) and write Assign(𝑽)\text{Assign}(\bm{V}) for the set of all assignments to 𝑽\bm{V}. Given a variable assignment 𝒗\bm{v} of 𝑽\bm{V}, and a subset of variables 𝑾𝑽\bm{W}\subseteq\bm{V}, we write 𝒗𝑾\bm{v}_{\bm{W}} to denote the assignment of 𝑾\bm{W} corresponding to 𝒗\bm{v}.

Semirings

In this paper, we consider inference problems over commutative semirings. Semirings are sets closed w.r.t. operators of addition (\oplus) and multiplication (\otimes) that satisfy certain properties:

Definition 1 (Commutative Semiring).

A commutative semiring 𝒮\mathcal{S} is a tuple (S,,,0𝒮,1𝒮)(S,\oplus,\otimes,0_{\mathcal{S}},1_{\mathcal{S}}), where \oplus and \otimes are associative and commutative binary operators on a set SS (called the domain) such that \otimes distributes over \oplus (i.e., a(bc)=(ab)(ac)a\otimes(b\oplus c)=(a\otimes b)\oplus(a\otimes c) for all a,b,cSa,b,c\in S); 0𝒮S0_{\mathcal{S}}\in S is the additive identity (i.e., 0𝒮a=a0_{\mathcal{S}}\oplus a=a for all aSa\in S) and annihilates SS through multiplication (i.e., 0𝒮a=00_{\mathcal{S}}\otimes a=0 for all aSa\in S); and 1𝒮S1_{\mathcal{S}}\in S is the multiplicative identity (i.e., 1𝒮a=a1_{\mathcal{S}}\otimes a=a for all aSa\in S).

For example, the probability semiring 𝒫=(0,+,,0,1)\mathcal{P}=(\mathbb{R}_{\geq 0},+,\cdot,0,1) employs standard addition and multiplication (=+\oplus=+ and =\otimes=\cdot) over the non-negative reals, the (max,)(\max,\cdot) semiring =(0,max,,0,1)\mathcal{M}=(\mathbb{R}_{\geq 0},\max,\cdot,0,1) replaces addition with maximization, while the Boolean semiring =({,},,,,)\mathcal{B}=(\{\bot,\top\},\vee,\wedge,\bot,\top) employs disjunction and conjunction operators (=\oplus=\vee and =\otimes=\wedge) over truth values.

Algebraic Circuits

We now define the concept of an algebraic circuit, which are computational graph-based representations of functions taking values in an arbitrary semiring.

Definition 2 (Algebraic Circuit).

Given a semiring 𝒮=(S,,,0𝒮,1𝒮)\mathcal{S}=(S,\oplus,\otimes,0_{\mathcal{S}},1_{\mathcal{S}}), an algebraic circuit CC over variables 𝐕\bm{V} is a rooted directed acyclic graph (DAG), whose nodes α\alpha have the following syntax:

α::=l+i=1kαi×i=1kαi,\alpha::=l\mid+_{i=1}^{k}\alpha_{i}\mid\times_{i=1}^{k}\alpha_{i}\,,

where αiC\alpha_{i}\in C are circuit nodes, k>0k\in\mathbb{N}^{>0} and l:Assign(𝐖)Sl:\text{Assign}(\bm{W})\to S is a function over a (possibly empty) subset 𝐖𝐕\bm{W}\subseteq\bm{V} of variables, called its scope. That is, each circuit node may be an input (ll), sum (++), or a product (×\times). The scope of any internal node is defined to be vars(α):=i=1kvars(αi)\textnormal{vars}(\alpha):=\cup_{i=1}^{k}\textnormal{vars}(\alpha_{i}). Each node α\alpha represents a function pαp_{\alpha} taking values in SS, defined recursively by: pα(𝐰)::=l(𝐰)p_{\alpha}(\bm{w})::=l(\bm{w}) if α=l\alpha=l, pα(𝐰)::=i=1kpαi(𝐰)p_{\alpha}(\bm{w})::=\oplus_{i=1}^{k}p_{\alpha_{i}}(\bm{w}) if α=+i=1kαi\alpha=+_{i=1}^{k}\alpha_{i}, and pα(𝐰)::=i=1kpαi(𝐰)p_{\alpha}(\bm{w})::=\otimes_{i=1}^{k}p_{\alpha_{i}}(\bm{w}) if ×i=1kαi\times_{i=1}^{k}\alpha_{i}, where 𝐖\bm{W} is the scope of α\alpha. The function pCp_{C} represented by the circuit is defined to be the function of the root node. The size |C||C| of a circuit is defined to be the number of edges in the DAG.

For simplicity, we will restrict to circuits with binary products (i.e. k=2k=2 for products); this can be enforced with at most a linear increase in size. Prominent examples of algebraic circuits include negation normal forms (NNF) and binary decision diagrams [amarilli2024circus]—which are over the Boolean semiring and represent Boolean functions—and probabilistic circuits [probcirc]—which are over the probabilistic semiring and represent probability distributions.111Probabilistic circuits are sometimes written with weights on the edges; this can easily be translated to our formalism by replacing the child of a weighted edge with a product of itself and an input function with empty scope corrresponding to the weight [shpilka2010arithmetic, rooshenas2014learning]. By imposing simple restrictions on the circuit, which we call circuit properties, various inference queries that are computationally hard in general become tractable. In particular, smoothness and decomposability ensure tractable marginal inference:

Definition 3 (Smoothness, Decomposability).

A circuit is smooth if for every sum node α=+iαi\alpha=+_{i}\alpha_{i}, its children have the same scope: i,j,vars(αi)=vars(αj)\forall i,j,\;\textnormal{vars}(\alpha_{i})=\textnormal{vars}(\alpha_{j}). A circuit is decomposable if for every product node α=α1×α2\alpha=\alpha_{1}\times\alpha_{2}, its children have disjoint scopes: vars(α1)vars(α2)=\textnormal{vars}(\alpha_{1})\cap\textnormal{vars}(\alpha_{2})=\emptyset.

Aside from the scopes of circuit nodes, we can also specify properties relating to their supports [probcirc]:

Definition 4 (𝑿\bm{X}-Support).

Given a partition (𝐗,𝐘)(\bm{X},\bm{Y}) of variables 𝐕\bm{V} and a node α\alpha in circuit CC, the 𝐗\bm{X}-support of α\alpha is the projection of its support on 𝐗\bm{X}:

supp𝑿(α)={𝒙Assign(𝑿vars(α)):𝒚Assign(vars(α)𝑿) s.t. pα(𝒙,𝒚)0𝒮}.\text{supp}_{\bm{X}}(\alpha)=\{\bm{x}\in\text{Assign}(\bm{X}\cap\textnormal{vars}(\alpha)):\exists{\bm{y}\in\text{Assign}(\textnormal{vars}(\alpha)\setminus\bm{X})}\text{ s.t. }p_{\alpha}(\bm{x},\bm{y})\neq 0_{\mathcal{S}}\}.
Definition 5 (𝑿\bm{X}-Determinism).

Given a circuit CC and a partition (𝐗,𝐘)(\bm{X},\bm{Y}) of 𝐕\bm{V}, we say that CC is 𝐗\bm{X}-deterministic if for all sum nodes α=+i=1kαi\alpha=+_{i=1}^{k}\alpha_{i}, either: (i) vars(α)𝐗=\textnormal{vars}(\alpha)\cap\bm{X}=\emptyset; or (ii) supp𝐗(αi)supp𝐗(αj)=\text{supp}_{\bm{X}}(\alpha_{i})\cap\text{supp}_{\bm{X}}(\alpha_{j})=\emptyset for all iji\neq j.

𝑿\bm{X}-determinism refers to a family of properties indexed by sets 𝑿\bm{X}. In particular 𝑽\bm{V}-determinism is usually referred to simply as determinism. Note that, as defined, scope and support, and thus these circuit properties, apply to any semiring: the scope only depends on the variable decomposition of the circuit, while the support only refers to scope and the semiring additive identity 0𝒮0_{\mathcal{S}}. Figure 2(a) shows a simple example of a smooth, decomposable, and deterministic circuit that is not XX-deterministic, while Figure 2(b) shows a smooth, decomposable, and {X1,X2}\{X_{1},X_{2}\}-deterministic circuit.

\vee\wedge\wedgeXXYY¬Y\neg Y
(a) A Boolean circuit that is smooth, decomposable, deterministic, but not X-deterministic.
×\times++++×\times×\times×\times×\times𝟙X1=1\mathds{1}_{X_{1}=1}𝟙Y1=1\mathds{1}_{Y_{1}=1}𝟙X1=0\mathds{1}_{X_{1}=0}𝟙Y1=0\mathds{1}_{Y_{1}=0}𝟙X2=1\mathds{1}_{X_{2}=1}𝟙Y2=1\mathds{1}_{Y_{2}=1}𝟙X2=0\mathds{1}_{X_{2}=0}𝟙Y2=0\mathds{1}_{Y_{2}=0}
(b) A probabilistic circuit that is smooth, decomposable, and X-deterministic.
Figure 2: Examples of Algebraic Circuits.

3 Compositional Inference: A Unifying Approach

Many inference problems can be written as compositions of basic operators, which take as input one or more functions and output another function. For example, the marginal MAP query on probability distributions max𝒙𝒚p(𝒙,𝒚)\max_{\bm{x}}\sum_{\bm{y}}p(\bm{x},\bm{y}) is a composition of the \sum and max\max operators. Similarly, for Boolean functions ϕ,ψ\phi,\psi, the query 𝒙𝒚.ϕ(𝒙,𝒚)ψ(𝒙,𝒚)\sum_{\bm{x}}\exists\bm{y}.\,\phi(\bm{x},\bm{y})\wedge\psi(\bm{x},\bm{y}) composes the \sum, \exists and \wedge operators. Although these queries appear to involve four different operators, three of them (,max,)(\sum,\max,\exists) can viewed as an aggregation operation over different semirings. Thus, we begin this section by consolidating to a simple set of three operators applicable to functions taking values in some semiring: namely, aggregation, product, and elementwise mapping (Section 3.1).

Equipped with this language for specifiying compositional inference queries, we then move on to analyzing their tractability when the input functions are given as circuits. The thesis of this paper is that algebraic structure is often the right level of abstraction to derive useful sufficient (and sometimes necessary) conditions for tractability. We firstly show tractability conditions of each of the basic operators (Section 3.2), before deriving composability conditions that show how circuit properties are maintained through operators (Section 3.3). This enables us to systematically derive conditions for the input circuits that enable efficient computation of a compositional inference query. Algorithms and detailed proofs of all theorems can be found in Appendix LABEL:appx:proofs.

3.1 Basic Operators

Aggregation

Given a function f:Assign(𝑽)Sf\!:\!\text{Assign}(\bm{V})\to S, aggregating ff over 𝐖𝐕\bm{W}\subseteq\bm{V} returns the function f:Assign(𝒁)Sf^{\prime}\!:\!\text{Assign}(\bm{Z})\to S for 𝒁=𝑽𝑾\bm{Z}=\bm{V}\setminus\bm{W} defined by f(𝒛):=𝒘f(𝒛,𝒘).f^{\prime}(\bm{z}):=\bigoplus_{\bm{w}}f(\bm{z},\bm{w}).

For example, aggregation corresponds to forgetting variables 𝑾\bm{W} in the Boolean semiring, marginalizing out 𝑾\bm{W} in the probability semiring, and maximizing over assignments in the (max,)(\max,\cdot) semiring. Next, some queries, such as divergence measures between probability distributions, take two functions as inputs, and many others involve combining two or more intermediate results, as is the case in probabilistic answer set programming inference and causal backdoor/frontdoor queries. We define the product operator to encapsulate such “combination” of functions in general.

Product

Given two functions f:Assign(𝑾)Sf\!:\!\text{Assign}(\bm{W})\to S and f:Assign(𝑾)Sf^{\prime}\!:\!\text{Assign}(\bm{W}^{\prime})\to S, the product of ff and ff^{\prime} is a function f:Assign(𝑽)Sf^{\prime\prime}:\text{Assign}(\bm{V})\to S, where 𝑽=𝑾𝑾\bm{V}\!=\!\bm{W}\cup\bm{W}^{\prime}, defined by f(𝒗):=f(𝒗𝑾)f(𝒗𝑾).f^{\prime\prime}(\bm{v}):=f(\bm{v}_{\bm{W}})\otimes f^{\prime}(\bm{v}_{\bm{W}^{\prime}}).

For example, a product corresponds to the conjoin operator \wedge in the Boolean semiring, and standard multiplication \cdot in the probability semiring. Lastly, we introduce the elementwise mapping operator, defined by a mapping τ\tau from a semiring to a (possibly different) semiring. When applied to a function ff, it returns the function composition τf\tau\circ f. This is the key piece that distinguishes our framework from prior analysis of sum-of-product queries over specific semirings, allowing us to express queries such as causal inference and probabilistic logic programming inference under the same framework.

Elementwise Mapping

Given a function f:Assign(𝑽)Sf\!:\!\text{Assign}(\bm{V})\to S and a mapping τ:SS\tau\!:\!S\to S^{\prime} from semiring 𝒮\mathcal{S} to 𝒮\mathcal{S}^{\prime} satisfying τ(0𝒮)=0𝒮\tau(0_{\mathcal{S}})=0_{\mathcal{S}^{\prime}}, an elementwise mapping of ff by τ\tau results in a function f:Assign(𝑽)Sf^{\prime}:\text{Assign}(\bm{V})\to S^{\prime} defined by f(𝒗):=τ(f(𝒗)).f^{\prime}(\bm{v}):=\tau(f(\bm{v})).222In a slight abuse of notation, we will write τ:𝒮𝒮\tau:\mathcal{S}\to\mathcal{S}^{\prime} to indicate that τ\tau maps between the respective sets.

In practice, we use elementwise mappings as an abstraction predominantly for two purposes. The first is for switching between semirings, while the second is to map between elements of the same semiring. For the former, one of the most important elementwise mappings we will consider is the support mapping, which maps between any two semirings as follows.

Definition 6 (Support Mapping).

Given a source semiring 𝒮\mathcal{S} and a target semiring 𝒮\mathcal{S}^{\prime}, the support mapping 𝒮𝒮\llbracket\cdot\rrbracket_{\mathcal{S}\to\mathcal{S}^{\prime}} is defined as: a𝒮𝒮=0𝒮\llbracket a\rrbracket_{\mathcal{S}\to\mathcal{S}^{\prime}}=0_{\mathcal{S}^{\prime}} if a=0𝒮a=0_{\mathcal{S}}; a𝒮𝒮=1𝒮\llbracket a\rrbracket_{\mathcal{S}\to\mathcal{S}^{\prime}}=1_{\mathcal{S}^{\prime}} otherwise.

In particular we will often use the source semiring 𝒮=\mathcal{S}=\mathcal{B}, in which case the support mapping maps \bot to the 0𝒮0_{\mathcal{S}^{\prime}} and \top to the 1𝒮1_{\mathcal{S}^{\prime}} in the target semiring. This is useful for encoding a logical function for inference in another semiring, e.g. probabilistic inference in the probabilistic semiring.

Example 1 (Marginal MAP).

Suppose that we are given a Boolean formula ϕ(𝐗,𝐘)\phi(\bm{X},\bm{Y}) and a weight function w:Assign(𝐗𝐘)0w:\text{Assign}(\bm{X}\cup\bm{Y})\to\mathbb{R}_{\geq 0}. The marginal MAP query for variables 𝐗\bm{X} is defined by

MMAP(ϕ,ω)=max𝒙𝒚ϕ(𝒙,𝒚)ω(𝒙,𝒚),\textnormal{MMAP}(\phi,\omega)=\max_{\bm{x}}\sum_{\bm{y}}\phi(\bm{x},\bm{y})\cdot\omega(\bm{x},\bm{y})\,,

where we interpret \top as 11 and \bot as 0. We can break this down into a compositional query as follows:

𝒙τid,𝒫[𝒚ϕ(𝒙,𝒚)𝒫ω(𝒙,𝒚)].\bigoplus_{\bm{x}}\tau_{\text{id},\mathcal{P}\to\mathcal{M}}\left[\bigoplus_{\bm{y}}\llbracket\phi(\bm{x},\bm{y})\rrbracket_{\mathcal{B}\to\mathcal{P}}\otimes\omega(\bm{x},\bm{y})\right]\,.

The support mapping ensures ϕ\phi and ω\omega are both functions over the probabilistic semiring, so that we can apply the product operation. Notice also the inclusion of an identity mapping τid,𝒫\tau_{\text{id},\mathcal{P}\to\mathcal{M}} from the probability to the (max,)(\max,\cdot) semiring defined by τid,𝒫(x)=x\tau_{\text{id},\mathcal{P}\to\mathcal{M}}(x)=x for all x0x\in\mathbb{R}_{\geq 0}. While differentiating between semirings over the same domain may seem superfluous, the explicit identity operator will become important when we analyze the tractability of these compositions on circuits.

3.2 Tractability Conditions for Basic Operators

We now consider the tractability of applying each basic operation to circuits: that is, computing a circuit whose function corresponds to the result of applying the operation to the functions given by the input circuit(s). First, it is well known that forgetting and marginalization of any subset of variables can be performed in polynomial time if the input circuits in the respective semirings (NNF and PC) are smooth and decomposable [darwiche2002knowledge, probcirc]. This can be generalized to arbitrary semirings:

{restatable}

[Tractable Aggregation]theoremthmAggregation Let CC be a smooth and decomposable circuit representing a function p:Assign(𝑽)Sp:\text{Assign}(\bm{V})\to S. Then for any 𝑾𝑽\bm{W}\subseteq\bm{V}, it is possible to compute the aggregate as a smooth and decomposable circuit CC^{\prime} (i.e., pC(𝒁)=𝒘pC(𝒁,𝒘)p_{C^{\prime}}(\bm{Z})=\bigoplus_{\bm{w}}p_{C}(\bm{Z},\bm{w})) in O(|C|)O(|C|) time and space.

Next, let us consider the product operator. In the Boolean circuits literature, it is well known that the conjoin operator can be applied tractably if the circuits both follow a common structure known as a vtree [darwiche2011sdd]. In [vergari2021atlas] a more general property known as compatibility was introduced that directly specifies conditions with respect to two (probabilistic) circuits, without reference to a vtree. We now define a generalization of this property (𝑿\bm{X}-compatibility) and also identify a new condition (𝑿\bm{X}-support-compatibility) that enables tractable products.

Definition 7 (𝑿\bm{X}-Compatibility).

Given two smooth and decomposable circuits C,CC,C^{\prime} over variables 𝐕,𝐕\bm{V},\bm{V}^{\prime} respectively, and a variable set 𝐗𝐕𝐕\bm{X}\subseteq\bm{V}\cap\bm{V^{\prime}}, we say that C,CC,C^{\prime} are 𝑿\bm{X}-compatible if for every product node α=α1×α2C\alpha=\alpha_{1}\times\alpha_{2}\in C and α=α1×α2C\alpha^{\prime}=\alpha^{\prime}_{1}\times\alpha^{\prime}_{2}\in C^{\prime} such that vars(α)𝐗=vars(α)𝐗\textnormal{vars}(\alpha)\cap\bm{X}=\textnormal{vars}(\alpha^{\prime})\cap\bm{X}, the scope is partitioned in the same way, i.e. vars(α1)𝐗=vars(α1)𝐗\textnormal{vars}(\alpha_{1})\cap\bm{X}=\textnormal{vars}(\alpha^{\prime}_{1})\cap\bm{X} and vars(α2)𝐗=vars(α2)𝐗\textnormal{vars}(\alpha_{2})\cap\bm{X}=\textnormal{vars}(\alpha^{\prime}_{2})\cap\bm{X}. We say that C,CC,C^{\prime} are compatible if they are (𝐕𝐕)(\bm{V}\cap\bm{V}^{\prime})-compatible.

Intuitively, compatibility states that the scopes of the circuits decompose in the same way at product nodes. Compatibility of two circuits suffices to be able to tractably compute their product:

{restatable}

[Tractable Product - Compatibility]theoremthmCmp Let C,CC,C^{\prime} be compatible circuits over variables 𝑽,𝑽\bm{V},\bm{V}^{\prime}, respectively, and the same semiring. Then it is possible to compute their product as a circuit CC compatible with them (i.e., pC(𝑽𝑽)=pC(𝑽)pC(𝑽)p_{C^{\prime\prime}}(\bm{V}\cup\bm{V}^{\prime})=p_{C}(\bm{V})\otimes p_{C^{\prime}}(\bm{V}^{\prime})) in O(|C||C|)O(|C||C^{\prime}|) time and space.

We remark that if we are given a fully factorized function f(𝑽)=Vi𝑽fi(Vi)f(\bm{V})=\bigotimes_{V_{i}\in\bm{V}}f_{i}(V_{i}), this can be arranged as a circuit (series of binary products) compatible with any other decomposable circuit; thus, we say this type of function is omni-compatible. We also say that a circuit is structured decomposable if it is compatible with itself. Now, our more general definition of 𝑿\bm{X}-compatibility states that the scopes of the circuits restricted to 𝐗\bm{X} decompose in the same way at product nodes. This will be important when we consider composing products with other operators, such as aggregation. The following result shows that compatibility w.r.t. a subset is a weaker condition:

Proposition 1 (Properties of 𝑿\bm{X}-Compatibility).

If two circuits C,CC,C^{\prime} are 𝐗\bm{X}-compatible, then they are 𝐗\bm{X}^{\prime}-compatible for any subset 𝐗𝐗\bm{X}^{\prime}\subseteq\bm{X}.

Compatibility is a sufficient but not necessary condition for tractable products. Some non-compatible circuits can be efficiently restructured to be compatible [zhang2024restructuring]. Alternatively, it is also known that some circuits can be multiplied with themselves in linear time, even when they are not structured decomposable [vergari2021atlas, huang2024causal]. We formalize this idea with a new property which we call support-compatibility.

Definition 8 (𝑿\bm{X}-Support Compatibility).

Given two smooth and decomposable circuits C,CC,C^{\prime} over variables 𝐕,𝐕\bm{V},\bm{V}^{\prime} respectively, and a set of variables 𝐗𝐕𝐕\bm{X}\subseteq\bm{V}\cap\bm{V^{\prime}}, let C[𝐗],C[𝐗]C[\bm{X}],C^{\prime}[\bm{X}] be the DAGs obtained by restricting to nodes with scope overlapping with 𝐗\bm{X}. We say that C,CC,C^{\prime} are 𝑿\bm{X}-support-compatible if there is an isomorphism ι\iota between C[𝐗],C[𝐗]C[\bm{X}],C^{\prime}[\bm{X}] such that: (i) for any node αC[𝐗]\alpha\in C[\bm{X}], vars(α)𝐗=vars(ι(α))𝐗\textnormal{vars}(\alpha)\cap\bm{X}=\textnormal{vars}(\iota(\alpha))\cap\bm{X}; (ii) for any sum node αC[𝐗]\alpha\in C[\bm{X}], supp𝐗(αi)supp𝐗(ι(αj))=\text{supp}_{\bm{X}}(\alpha_{i})\cap\text{supp}_{\bm{X}}(\iota(\alpha_{j}))=\emptyset whenever iji\neq j. We say that C,CC,C^{\prime} are support-compatible if they are (𝐕𝐕)(\bm{V}\cap\bm{V}^{\prime})-support-compatible.

To unpack this definition, we note that any smooth, decomposable, and 𝑿\bm{X}-deterministic circuit is 𝑿\bm{X}-support-compatible with itself, with the obvious isomorphism. However, this property is more general in that it allows for circuits over different sets of variables and does not require that the nodes represent exactly the same function; merely that the sum nodes have “compatible” support decompositions. As we will later see, the significance of this property is that it can be often maintained through applications of operators, making it useful for compositions.

{restatable}

[Tractable Product - Support Compatibility]theoremthmSComp Let C,CC,C^{\prime} be support-compatible circuits over variables 𝑽,𝑽\bm{V},\bm{V}^{\prime}, respectively, and the same semiring. Then, given the isomorphism ι\iota, it is possible to compute their product as a smooth and decomposable circuit CC^{\prime\prime} support-compatible with them (i.e., pC(𝑽𝑽)=pC(𝑽)pC(𝑽)p_{C^{\prime\prime}}(\bm{V}\cup\bm{V}^{\prime})=p_{C}(\bm{V})\otimes p_{C^{\prime}}(\bm{V}^{\prime})) in O(max(|C|,|C|))O(\max(|C|,|C^{\prime}|)) time and space.

We now examine the tractability of general elementwise mappings τ:𝒮𝒮\tau:\mathcal{S}\to\mathcal{S}^{\prime} on a circuit CC. It is tempting here to simply construct a new circuit CC^{\prime} over the semiring 𝒮\mathcal{S}^{\prime} with the same structure as CC, and replace each input function ll in the circuit with τ(l)\tau(l). However, the resulting circuit pC(𝑽)p_{C^{\prime}}(\bm{V}) is not guaranteed to correctly compute τ(pC(𝑽))\tau(p_{C}(\bm{V})) in general. For example, consider the support mapping 𝒮\llbracket\cdot\rrbracket_{\mathcal{B}\to\mathcal{S}}—which maps \bot to 0𝒮0_{\mathcal{S}} and \top to 1𝒮1_{\mathcal{S}} —for the probability semiring 𝒮=(0,+,,0,1)\mathcal{S}=(\mathbb{R}_{\geq 0},+,\cdot,0,1). Then the transformation of the smooth and decomposable circuit C=XXC=X\vee X produces C=𝟙X=1+𝟙X=1C^{\prime}=\mathds{1}_{X=1}+\mathds{1}_{X=1}, which evaluates to pC(X=1)=2p_{C^{\prime}}(X=1)=2 whereas τ(pC(X=1))=1\tau(p_{C}(X=1))=1. In order for this simple algorithm to be correct, we need to impose certain conditions on the elementwise mapping τ\tau and/or the circuit CC it is being applied to.

{restatable}

[Tractable Mapping]theoremthmTractMap Let CC be a smooth and decomposable circuit over semiring 𝒮\mathcal{S}, and τ:𝒮𝒮\tau:\mathcal{S}\to\mathcal{S}^{\prime} a mapping such that τ(0𝒮)=0𝒮\tau(0_{\mathcal{S}})=0_{\mathcal{S}^{\prime}}. Then it is possible to compute the mapping of CC by τ\tau as a smooth and decomposable circuit CC^{\prime} (i.e., pC(𝑽)=τ(pC(𝑽))p_{C^{\prime}}(\bm{V})=\tau(p_{C}(\bm{V}))) in O(|C|)O(|C|) time and space if τ\tau distributes over sums and over products.

τ\tau distributes over sums if: either (Additive) τ\tau is an additive homomorphism, i.e. τ(ab)=τ(a)τ(b)\tau(a\oplus b)=\tau(a)\oplus\tau(b); or (Det) CC is deterministic.

τ\tau distributes over products if: either (Multiplicative) τ\tau is an multiplicative homomorphism, i.e. τ(ab)=τ(a)τ(b)\tau(a\otimes b)=\tau(a)\otimes\tau(b); or (Prod 0/1) τ(1𝒮)=1𝒮\tau(1_{\mathcal{S}})=1_{\mathcal{S}^{\prime}}, and for all product nodes α=α1×α2C\alpha=\alpha_{1}\times\alpha_{2}\in C, and for every value 𝒗Assign(vars(α))\bm{v}\in\text{Assign}(\textnormal{vars}(\alpha)), either pα1(𝒗vars(α1)){0𝒮,1𝒮}p_{\alpha_{1}}(\bm{v}_{\textnormal{vars}(\alpha_{1})})\in\{0_{\mathcal{S}},1_{\mathcal{S}}\} or pα2(𝒗vars(α2)){0𝒮,1𝒮}p_{\alpha_{2}}(\bm{v}_{\textnormal{vars}(\alpha_{2})})\in\{0_{\mathcal{S}},1_{\mathcal{S}}\}.

We can apply Theorem 8 to immediately derive the following property of support mappings:

Corollary 1 (Support Mapping).

Given a circuit CC over a semiring 𝒮\mathcal{S} and any target semiring 𝒮\mathcal{S}^{\prime}, a circuit representing pC𝒮𝒮\llbracket p_{C}\rrbracket_{\mathcal{S}\to\mathcal{S}^{\prime}} can be computed tractably if (i) 𝒮\mathcal{S} satisfies ab=0𝒮a=b=0𝒮a\oplus b=0_{\mathcal{S}}\implies a=b=0_{\mathcal{S}} and 𝒮\mathcal{S}^{\prime} is idempotent (i.e., 1𝒮1𝒮=1𝒮1_{\mathcal{S}^{\prime}}\oplus 1_{\mathcal{S}^{\prime}}=1_{\mathcal{S}^{\prime}}), or (ii) CC is deterministic.

Proof.

First note that 𝒮𝒮\llbracket\cdot\rrbracket_{\mathcal{S}\to\mathcal{S}^{\prime}} satisfies (Multiplicative), and thus distributes over products. If (i) holds, consider ab𝒮𝒮\llbracket a\oplus b\rrbracket_{\mathcal{S}\to\mathcal{S}^{\prime}}. If a=b=0𝒮a=b=0_{\mathcal{S}}, then this is equal to 0𝒮𝒮𝒮=a𝒮𝒮+b𝒮𝒮=0𝒮\llbracket 0_{\mathcal{S}}\rrbracket_{\mathcal{S}\to\mathcal{S}^{\prime}}=\llbracket a\rrbracket_{\mathcal{S}\to\mathcal{S}^{\prime}}+\llbracket b\rrbracket_{\mathcal{S}\to\mathcal{S}^{\prime}}=0_{\mathcal{S}^{\prime}}; otherwise a,b,ab0𝒮a,b,a\oplus b\neq 0_{\mathcal{S}} and ab𝒮𝒮=a𝒮𝒮b𝒮𝒮=1𝒮\llbracket a\oplus b\rrbracket_{\mathcal{S}\to\mathcal{S}^{\prime}}=\llbracket a\rrbracket_{\mathcal{S}\to\mathcal{S}^{\prime}}\oplus\llbracket b\rrbracket_{\mathcal{S}\to\mathcal{S}^{\prime}}=1_{\mathcal{S}^{\prime}} (by idempotence of 𝒮\mathcal{S}^{\prime}). Thus 𝒮𝒮\llbracket\cdot\rrbracket_{\mathcal{S}\to\mathcal{S}^{\prime}} satisfies (Additive). Alternatively, if (ii) holds, then (Det) holds. In either case 𝒮𝒮\llbracket\cdot\rrbracket_{\mathcal{S}\to\mathcal{S}^{\prime}} distributes over sums in the circuit. ∎

The following examples illustrate the generality of elementwise mappings and Theorem 8:

Example 2 (Partition Function and MPE).

Given a probability distribution p(𝐕)p(\bm{V}), consider the task of computing the partition function 𝐯p(𝐯)\sum_{\bm{v}}p(\bm{v}) and MPE max𝐯p(𝐯)\max_{\bm{v}}p(\bm{v}). These can be viewed as aggregations over the probability and (max,)(\max,\cdot) semirings respectively.

pp is often either a probabilistic circuit CprobC_{prob}, or a combination of a Boolean circuit CboolC_{bool} and weights ww (in weighted model counting). In the former case, the partition function is tractable because the circuit is already over the probability semiring, while in the latter case, MPE is tractable because the 𝒮=(max,)\mathcal{S}^{\prime}=(\max,\cdot) semiring is idempotent so Cbool𝒮\llbracket C_{bool}\rrbracket_{\mathcal{B}\to\mathcal{S}^{\prime}} is tractable. On the other hand, the partition function for Boolean circuits and MPE for PCs require determinism for the conditions of Theorem 8 to hold; in fact, these problems are known to be NP-hard without determinism [darwiche2002knowledge, peharz2016latent].

Example 3 (Power Function in Probability Semiring).

For the probability semiring 𝒮=𝒮=(0,+,,0,1)\mathcal{S}=\mathcal{S}^{\prime}=(\mathbb{R}_{\geq 0},+,\cdot,0,1), consider the power function τβ(a):={aβif a00if a=0\tau_{\beta}(a):=\begin{cases}a^{\beta}&\text{if }a\neq 0\\ 0&\text{if }a=0\end{cases} for some β\beta\in\mathbb{R}. This mapping satisfies (Multiplicative), and is tractable if we enforce (Det) on the circuit.

It is worth noting that semiring homomorphisms (i.e. additive and multiplicative) are always tractable. In the case when 𝒮=𝒮=𝒫\mathcal{S}=\mathcal{S}^{\prime}=\mathcal{P}, it was shown in [vergari2021atlas] that the only such mapping is the identity function. However this is not the case for other semirings: the power function τβ\tau_{\beta} is an example in the (max,)(\max,\cdot) semiring. To summarize, we have shown sufficient tractability conditions for aggeregation, products, and elementwise mappings. Notice that the conditions for aggregation and products only depend on variable scopes and supports, and as such apply to any semiring; in contrast, for elementwise mappings, we take advantage of specific properties of the semiring(s) in question.

3.3 Tractable Composition of Operators

Table 1: Tractability Conditions for Operations on Algebraic Circuits. Sm: Smoothness, Dec: Decomposability; 𝑿\bm{X}-Det(erminism), 𝑿\bm{X}-Cmp: 𝑿\bm{X}-Compatibility, 𝑿\bm{X}-SCmp: 𝑿\bm{X}-Support-Compatibility.
If the Input Circuit(s) are …
Conditions 𝑿\bm{X}-Det 𝑿\bm{X}-Cmp w/ CotherC_{\text{other}} 𝑿\bm{X}-SCmp w/ CotherC_{\text{other}} Complexity
Then the Output Circuit is …    (LABEL:appx:comp)
Aggr. (W\bm{W}) Sm, Dec
𝑿\bm{X}-Det
if 𝑾𝑿=\bm{W}\!\cap\!\bm{X}\!=\!\emptyset
𝑿\bm{X}-Cmp w/ CotherC_{\text{other}}
if 𝑾𝑿=\bm{W}\!\cap\!\bm{X}\!=\!\emptyset
𝑿\bm{X}-SCmp w/ CotherC_{\text{other}}
if 𝑾𝑿=\bm{W}\!\cap\!\bm{X}\!=\!\emptyset
O(|C|)O(|C|) (LABEL:appx:aggr)
Product Cmp 𝑿\bm{X}-Det 𝑿\bm{X}-Cmp w/ CotherC_{\text{other}} N/A O(|C||C|)O(|C||C^{\prime}|) (LABEL:appx:prod)
SCmp 𝑿\bm{X}-Det 𝑿\bm{X}-Cmp w/ CotherC_{\text{other}} 𝑿\bm{X}-SCmp w/ CotherC_{\text{other}} O(max(|C|,|C|))O(\max(|C|,|C^{\prime}|)) (LABEL:appx:prod-supp)
Elem. Mapping
Sm, Dec,
(Add/Det),
(Mult/Prod01)
𝑿\bm{X}-Det 𝑿\bm{X}-Cmp w/ CotherC_{\text{other}} 𝑿\bm{X}-SCmp w/ CotherC_{\text{other}} O(|C|)O(|C|) (LABEL:appx:elem)

We now analyze compositions of these basic operators. As such, we need to consider not only circuit properties that enable tractability, but how these properties are maintained through each operator, so that the output circuit can be used as input to another operator. We call these composability conditions. In all cases, the output circuit is smooth and decomposable. Thus, we focus on the properties of 𝑿\bm{X}-determinism, 𝑿\bm{X}-compatibility, and 𝑿\bm{X}-support-compatibility. We emphasize that these are not singular properties, but rather families of properties indexed by a variable set 𝑿\bm{X}. We present the intuitive ideas behind our results below, while deferring full proofs to the Appendix.