Joan Thibault Khalil Ghorbal July 23, 2020 arXiv:2003 ... · Joan Thibault joan.thibault@inria.fr...

Post on 19-Aug-2020

0 views 0 download

Transcript of Joan Thibault Khalil Ghorbal July 23, 2020 arXiv:2003 ... · Joan Thibault joan.thibault@inria.fr...

Ordered Functional Decision Diagrams:

A Functional Semantics For Binary Decision Diagrams

Joan Thibaultjoan.thibault@inria.fr

Khalil Ghorbalkhalil.ghorbal@inria.fr

July 23, 2020

Abstract

We introduce a novel framework, termed λDD, that revisits Binary Decision Diagrams from apurely functional point of view. The framework allows to classify the already existing variants,including the most recent ones like Chain-DD and ESRBDD, as implementations of a special classof ordered models. We enumerate, in a principled way, all the models of this class and isolateits most expressive model. This new model, termed λDD-O-NUCX, is suitable for both dense andsparse Boolean functions, and is moreover invariant by negation. The canonicity of λDD-O-NUCXis formally verified using the Coq proof assistant. We furthermore give bounds on the size ofthe different diagrams: the potential gain achieved by more expressive models can be at mostlinear in the number of variables n.

Introduction

A Binary Decision Diagram (BDD) is a versatile graph-based data structure, well suited to effec-tively represent and manipulate Boolean functions. As shown by Bryant [6], although a BinaryDecision Diagram (BDD) has an exponential worst-case size, many practical applications yield moreconcise representations thanks to the elimination of useless nodes, i.e., those nodes having theiroutgoing edges pointing towards the same subgraph. Many BDD variants [9, 16, 14] have been sub-sequently designed to capture specific application-dependent properties in order to further reducethe size of the diagram or to efficiently perform specific operations. For instance, Zero-suppressedDecision Diagrams [17, 15], or ZDD, form a notable variant that is well suited to encode sparsefunctions, i.e., functions that evaluate to zero except for a limited number of valuations of theirinputs.

Most recently, two new variants, namely Chain-BDD [8] and ESRBDD [2], propose to combineROBDD and ZDD in order to get a data structure suitable for both dense and sparse functions.In this work, we are also interested in combining existing variants in order to benefit from theirrespective sweet spots.

Our approach is however, drastically different: we combine reduction rules by composing theirfunctional abstraction (or interpretation). To do so, we introduce a new functional framework,together with its related data structure, that we term λDD. Special variables, like useless variables,are captured by elementary operators (or functors) acting on Boolean functions. We exemplify ourapproach by considering the so-called canalizing variables [11], which form an important class ofspecial variables dual to useless variables: their valuation fixes the output of the function regardlessof the valuation of the other variables. In our framework, designing a data structure that capturesseveral special variables amounts to combining, at the functional level, various elementary operators,while paying attention to their possible interactions.

1

arX

iv:2

003.

0934

0v4

[cs

.LO

] 2

1 Ju

l 202

0

The functional framework allows not only to compare the expressive power of the modeledvariants, but also, and more importantly, to design in a principled way new models with highercompression rates. We present in particular a new canonical data structure, termed λDD-O-NUCX,that combines canalizing and useless variables while supporting negation, unlike ZDD, Chain-BDD,and ESRBDD. The obtained graphs are invariant by negation, i.e., the diagram of the negation of afunction differs from the diagram of the function itself by only appending the symbol that encodesnegation. As a consequence, negation is a constant-time operation.

The three main contributions of this paper can be summarized as follows. (I) A general func-tional framework for Boolean functions relying on the Shannon combinator (Section 2) for a classof ordered models, denoted λDD-O, classifying many already existing BDD variants (Section 4).(II) A new model, called λDD-O-NUCX (Section 5), supporting all the primitives defining the classλDD-O, including negation (Section 3). λDD-O-NUCX is a strict generalization of the recent variantsChain-DD and ESRBDD. (III) A comparison of the number of nodes showing that the potential gaincan be at most linear in n regardless of the expressiveness of the models.

Remark 1. All results and theorems in the upcoming sections are part of the formalization projectof the λDD data structure in the Coq proof assistant. For lack of space, the formalization detailswont be detailed.

1 Preliminaries

A Boolean function of arity n ∈ N is a form (or functional) from Bn to B. It operates on an orderedtuple of Booleans of dimension n, (x0, . . . , xn−1), by assigning a Boolean value to each of the 2n

valuations of its tuple. The set of Boolean functions of arity n, denoted by Bn→1, is thus finite andcontains 22

nelements. In particular, B0→1 has two elements and is isomorphic to B itself (only the

types differ: functions on the one hand, and co-domain elements, or Booleans, on the other hand).To avoid confusion, we use a different font for functions: 0 will denote the constant function ofarity zero returning 0, and 1 will denote the constant function of arity zero returning 1.

We rely on a binary non-commutative operator (or functor), sometimes referred to as theShannon operator in the literature, defined as follows.

Definition 1 (Shannon operator). Let f, g be two Boolean functions defined over the same set ofvariable x1, . . . , xn. The Shannon operator ? : Bn→1 × Bn→1 → Bn+1→1 id defined as

(f ? g) : (x0, x1, . . . , xn) 7→ (¬x0 ∧ f(x1, . . . , xn)) ∨ (x0 ∧ g(x1, . . . , xn)) .

The Shannon operator is (i) universal : any Boolean function can be fully decomposed, byinduction over its arity, all the way down to constant functions; and (ii) elementary : it operateson two functions defined over the same set of variables and increases the arity by exactly one. Inour definition, this is done by appending a new variable, x0, at position 0, to the ordered tuple(x1, . . . , xn).

Depending on the operands f and g, this newly introduced variable can be of several types.Two kinds of variables will be of particular interest in this paper.

Definition 2 (Useless Variable). For any function f , the newly added variable in f ? f is said tobe useless.

Definition 3 (Canalizing Variable). Let f denote a function and let c denote a constant function(0 or 1 ) having the same arity of f . The newly added variable in c ? f or f ? c is said to becanalizing.

2

For instance, in g : (x0, x1) 7→ x0 ∧ ¬x1, the variable x0 is canalizing. Indeed, let f : x1 7→ ¬x1,then g = 0 ? f . Canalizing variables are dual to useless variables in the sense that their valuationscould fix the output of the entire function. For the function g, one has g(0, x1) = 0 regardless ofx1.

A key observation for useless and canalizing variables alike is that the Shannon operator acts onone function f and produces a new function by appending a typed variable (useless or canalizing)to the ordered list of inputs of f . As such, the binary operator behaves like a unary operatoracting on Boolean functions. This simple observation is at the heart of the functional frameworkintroduced next.

2 Ordered Functional Decision Diagrams

We introduce a new data structure, akin to ordered BDD, that we term Ordered Functional DecisionDiagram or λDD-O.

2.1 Syntax and Semantics

Let ∆ denote a finite set of letters, and ∆∗ denote the set of all words (freely) generated byconcatenating any finite number of letters from ∆. In particular, ε ∈ ∆∗ denotes the empty word.

Definition 4 (λDD-O). A λDD-O (φ, n), n ∈ N, is a parameterized recursive data structure definedas follows

(φ, 0) := (0 , 0) | (1 , 0)

(φ, n+ 1) := `(φ, n) | (φ, n) � (φ, n),

where ` is a letter in ∆.The letters in ∆ as well as the binary operator � increase the parameter nby exactly one. Notice that the two operands of � have necessarily the same parameter n.

We drop the arity n from the notation whenever clear from the context. A λDD-O can be rep-resented as a directed acyclic graph, with (all) edges labeled with words in ∆∗. The representationrequires three types of nodes: one root node (H), two terminal nodes (� and �), and a diamondnode (3). The structure is defined inductively as follows.

• a root node pointing to a terminal node;

• or a root node pointing to a λDD-O graph;

• or a root node pointing to a diamond node having two outgoing edges, each of which pointingto a λDD-O.

An edge can have only one label: composingw1−→ and

w2−→ results inw1.w2−−−−→, where w1.w2 denotes

the concatenation of w1 and w2.The λDD-O data structure, or equivalently its graph representation, can be given, by induction,

a semantics over Boolean functions. An elementary unary operator acts on a Boolean function fof arity n ≥ 0 by appending a typed variable to the input of f (regarded as an ordered tuple).For instance, the elementary operator δu : f 7→ f ? f appends a useless variable to the input of f .Similarly, each of the following elementary operators append a different canalizing variable to the

3

input of f .

δc00 : f 7→ 0 ? f δc10 : f 7→ f ? 0

δc01 : f 7→ 1 ? f δc11 : f 7→ f ? 1

Definition 5 (Semantics of λDD-O). Let (φ, n) be a λDD-O graph.

• (�, 0) denotes the constant function 0 of arity zero;

• (�, 0) denotes the constant function 1 of arity zero;

• Letters in ∆ denote elementary operators;

• Concatenation of letters denote composition of operators;

• The empty word ε denotes the identity operator;

• The symbol � denotes the Shannon operator;

• The parameter n is the arity of the function;

We denote by J(φ, n)K the Boolean function represented by (φ, n).

A model of λDD-O is an instantiation of ∆ with some letters. For instance, the letters u andc10 are used to encode the unary operators δu and δc10 , respectively; we use similar letters for theremaining canalizing variables. The simplest possible model has no letters: ∆ is empty and ∆∗

contains one word of length zero, namely ε, which semantically corresponds to the identity operatorδε : f 7→ f . The λDD-O graphs obtained for ∆ = ∅, after merging isomorphic subgraphs, are knownin the literature as Shannon Decision Diagrams, or SDD; we thus term this model λDD-S.

Example 1 (Running Example). The λDD-S graph of the Boolean function

(x0, x1, x2, x3) 7→ x1 ⊕ x2 ⊕ (¬x0 ∧ x3)

is depicted in Figure 1a where dashed and solid edges point respectively to the left and right operandsof � (recall that the operator ? represented by � is not commutative). For clarity, the terminal nodesare not merged and are explicitly labeled by their respective constant functions.

Remark 2. Unlike BDD variants, the diamond nodes in λDD-O are not labeled with the integersdenoting the indices (or positions) of variables. Such information can be fully retrieved from thelength of the words labeling the edges and the nesting depth of diamond nodes.

The canonicity of the λDD-S data structure is obvious: each Boolean function has a uniqueλDD-S representation and every λDD-S represents unambiguously a unique Boolean function. Inthe next section, we detail how such canonicity is achieved for non-trivial models (∆ 6= ∅).

2.2 Syntactic Reduction and Canonicity

Each letter in ∆ comes with an introduction rule. For instance, an intuitive introduction rule forthe letter ‘u’ could be:

intro-u(φ, n) � (φ, n)

u−→ (φ, n).

4

0 1 1 0

SDD

(a) λDD-S

O-UC10

0 1 10

C10

C10

C10

U

UU

(b) λDD-O-UC10

O-NUC

0

C11

UC11

U

0

C11

C11

(c) λDD-O-NUC

O-NUCX

XXX

0

XXU

(d) λDD-O-NUCX

Figure 1: λDD-O graphs for (x0, x1, x2, x3) 7→ x1 ⊕ x2 ⊕ (¬x0 ∧ x3).

We use

n times︷ ︸︸ ︷u. . . . .u−−−−−→ (�, 0) to denote (�, n) and a similar shorthand notation is used for �. This in

turn allows the following introduction rules for the letters c10 and c11 :

intro-c10(φ, n) � (�, n)

c10−−→ (φ, n), intro-c11

(φ, n) � (�, n)c11−−→ (φ, n)

.

The letters c00 , c01 could be introduced similarly.

intro-c00(�, n) � (φ, n)

c00−−→ (φ, n), intro-c01

(�, n) � (φ, n)c01−−→ (φ, n)

.

Notice that, although natural, the above intro rules are not unique. We say that a graph is reducedw.r.t. a fixed set of intro rules if it is a fixed point for those rules. Depending on ∆, the samegraph may have distinct reduced representations. For instance, if ∆ contains both u and c10 , thenwith respect to the rules above the graph (�, 0) � (�, 0) reduces to either

c10−−→ (�, 0) oru−→ (�, 0).

A simple way to avoid such non-determinism would be to apply the intro rules w.r.t. a fixed order.We shall see next, however, that there is an interplay between such an order and the way one definesthe intro rules for the graph to capture syntactically all the semantic occurrences of the involvedelementary operators.

We focus in the sequel on the model λDD-O-UC containing all useless and canalizing letters. Wereduce the � node by applying a constructor, �\, defined in infix notation as follows

let φ0 �\ φ1 =match φ0 � φ1 with

| φ � φ −→I u−→ φ

| φ � (�, n) −→I c11−−→ φ

| φ � (�, n) −→I c10−−→ φ

| (�, n) � φ −→I c01−−→ φ

| (�, n) � φ −→I c00−−→ φ| −→I φ0 � φ1

where the first letter gets introduced first (if possible), then the second etc. Using �\, we define areduction operator, [·], inductively on the structure of the graph:

5

let rec [φ] =match φ with

| (�, 0) | (�, 0) −→I φ

| `−→ φ′ −→I let ψ0 � ψ1 = elim-`(φ′) in [ψ0] �\ [ψ1]

| φ0 � φ1 −→I [φ0] �\ [φ1]

where elim-` eliminates the letter ` by reversing its introduction rule. For instance,

elim-c00

c00−−→ (φ, n)

(�, n) � (φ, n).

Lemma 1. The reduction operator [·] is idempotent, that is [[φ]] = [φ] for any graph φ.

The proof is by induction on the structure of the graph and relies on the fact that the lettersare always introduced in the same order. The purpose of the elim-` procedure is to deconstructalready introduced letters before reintroducing them w.r.t. to the implicit order of �\. For instance[c10−−→ (�, 0)] gives

u−→ (�, 0) since c10 is eliminated before introducing u.The relative canonicity of λDD-O models is proved by induction on the arity n.

Proposition 1 (Relative Canonicity of λDD-O-UC). Every Boolean function has a unique, seman-tically equivalent, λDD-O-UC graph φ reduced w.r.t. [·] (that is [φ] = φ).

Proof. Let f denote a Boolean function of arity n. Any Boolean function has a unique, semanticallyequivalent, λDD-S graph φ which is also a λDD-O-UC graph. The existence is a consequence of thefact that the procedure [·] is an idempotent function so [φ] exists and [[φ]] = [φ].

It remains to prove uniqueness, that is there is no other distinct graph ψ which is also semanti-cally equivalent to f and such that [ψ] = ψ. The proof is by induction on the arity n. Uniquenesstrivially holds for n = 0, as (�, 0) and (�, 0) are the unique fixed point for [·] with arity zero.Suppose that uniqueness holds for arity n.

Case 1. Suppose that [φ] has the form (φ1, n) � (φ2, n). If ψ has the form`−→ (ψ′, n) then

by eliminating ` we get (ψ′1, n) � (ψ′2, n) which is semantically equivalent to (φ1, n) � (φ2, n) thusJφ1K ≡ Jψ′1K and Jφ2K ≡ Jψ′2K and the induction hypothesis implies that both pairs should besyntactically equal but then this means that (φ1, n) � (φ2, n) is not reduced contradicting thehypothesis. Now if ψ has the form (ψ′1, n) � (ψ′2, n) then a similar reasoning leads to the fact thatψ and [φ] must be syntactically equal.

Case 2. Suppose that [φ] has the form`−→ (φ′, n). Like the first case, if ψ has the form

(ψ′1, n) � (ψ′2, n) then by eliminating ` we get a contradiction. Now suppose ψ has the form`′−→

(ψ′, n). By eliminating both letters and using the semantic equivalence together with the inductionhypothesis we get that ` = `′ as they were both introduced using �\ applied to the exact samegraphs. Thus ψ = [φ].

The relative dependence to [·] highlights a subtle dependence between the way [·] is defined andthe intro rules it uses. Let’s see what this precisely means on a concrete example. Consider thegraph φ := (� � �) � (� � �). Then [φ] gives φ1 :=

c10 .u−−−→ �. Now, suppose we swap the first andfifth matchings of �\ so that all canalizing letters get introduced before u. Then φ gets insteadreduced to φ2 := (

c11−−→ �)� (c00−−→ �). If, however, we swap the third and fourth matchings, one gets

φ3 :=c01 .u−−−→ �.

Although φ1, φ2 and φ3 are semantically equivalent and unique w.r.t. their respective reductionoperators, φ1 and φ3 are better than φ2. Indeed, not only they are more concise, they also capture

6

all (semantically) useless and canalizing variables of the Boolean function they represent, albeiteach uses a different letter to encode the canalizing variable.

To ensure that the reduction operator captures, at the syntactic level, all occurrences of theelementary functors involved in the Boolean function, it must respect the implicit dependencebetween the letters in the considered intro rules. For the λDD-O-UC model, the intro rules we usedfor canalizing letters have the letter u involved in their very definitions since they expect either(�, n) or (�, n) to occur on one side of �. Thus exhibiting u letters before any other canalizingletter (like [·] does) permits to canonically represent constant Boolean functions of any arity as(�, n) or (�, n), thereby syntactically capturing any potential occurrence of (semantic) canalizingvariables via the intro rules we defined. We can now state the main result of this section: thecanonicity of the λDD-O-UC model.

Theorem 1 (Canonicity of λDD-O-UC). Every Boolean function f has a unique, semantically equiv-alent, λDD-O-UC graph φ satisfying the following property: the variable introduced by each � nodeof φ is neither a useless nor a canalizing variable.

In other words, the theorem says that all useless and canalizing variables are captured in thegraph φ by one of the letters. We next explain how negation is supported in our framework.

3 Negation Operator

In this section we enrich our data structure with arity-preserving operators, such as negation. Thisextension is novel: none of the recent BDD variants [8, 2] that partially use canalizing variablessupport negation. As we shall see in the sequel, our functional framework gives a clear insight intowhy this is difficult for those variants.

Arity-preserving operators are not elementary, since they do not increase the arity of theiroperands. We exemplify the main steps through the concrete example of the standard outputnegation operator on Boolean functions δ¬ : Bn→1 → Bn→1, defined by (δ¬f) : (x0, . . . , xn−1) 7→¬f(x0, . . . , xn−1). Syntactically, the words labeling the edges will now include a new letter ‘•’ thatencodes the negation operator.

The letter ‘•’ is introduced by normalizing the representation of the square node (�, 0): 1

intro-•(�, 0)•−→ (�, 0)

.

Arity-preserving operators in general, and the negation operator in particular, interact with boththe elementary operators and the Shannon operator. Those interactions have to be taken intoaccount for the words labeling the edges of the graph to be canonical. There are two fundamentalaspects of such interactions. The first is the distributivity with the Shannon operator. The secondis the commutativity with elementary operators: when and how do arity-preserving operatorscommute with other operators?

The negation operator distributes over the Shannon operator, which makes it possible to prop-agate it upward. The related normalization rule given below is similar to the BDD variants sup-porting complement edges.2

norm-Shannon(•−→ (φ1, n)) � (φ2, n)

•−→ ((φ1, n) � (•−→ (φ2, n)))

.

1Choosing (�, 0) over (�, 0) is arbitrary and has no impact on the treatment that follows.2One may arbitrarily choose the dual reduction rule that normalizes the negation to the left edge.

7

Commuting ‘•’ with the letters encoding the elementary operators allows to syntactically exploitthe involution property of negation:

norm-involution

•−→ (•−→ (φ, n))

(φ, n).

However, commutation with elementary operators is not always possible. For instance the followingtwo functions are not semantically equivalent (the standard functional notations on the right aregiven explicitly for convenience).

(δc10 ◦ δ¬)0 = 1 ? 0 (x 7→ ¬x)

(δ¬ ◦ δc10 )0 = ¬(0 ? 0 ) (x 7→ 1)

To overcome this issue, we adopt in this work a weaker notion of commutativity.

Definition 6 (Quasi-commutativity). We say that an arity-preserving letter, a, quasi-commuteswith an elementary letter, `, if there exists an elementary letter `a (possibly different from `) suchthat the graphs `.a(φ, n) and a.`a(φ, n) are semantically equivalent for all (φ, n). (As the notationsuggests, the letter `a depends in general on a.) We will say that an alphabet ∆ quasi-commuteswith a, or is a−stable, if for all ` ∈ ∆, `a ∈ ∆.

Semantically, quasi-commutation of letters encodes the quasi-commutation of elementary oper-ators and arity-preserving operators. For each arity-preserving operator a, the following normal-ization rule, defined for each elementary operator `, exploits quasi-commutativity to expose arity-preserving operators before elementary operators.

norm-commutation-(`, a)

`.a−→ (φ, n)

a.`a−−→ (φ, n).

We stress the fact that ` must be an elementary letter. Hence, one cannot apply norm-commutation

on•.•−−→ (φ, n). Quasi-commutativity naturally extends to words: a word w quasi-commutes with

an arity-preserving letter a if and only if all its letters quasi-commute with a.The negation, being involutive, is a special operator. Indeed for any letter `, (`•)• = `. Thus,

one can make any alphabet ∆ •-stable by saturating it with the elements `• for each ` ∈ ∆. Asdefined, the involution and commutation rules of the negation expose the • letter at the beginningof each word. The negation commutes with useless variables (i.e., u.•’ as ‘•.u). However, it onlyquasi-commutes with all the other canalizing variables:

c00 .• = •.c01 c01 .• = •.c00 (c00 • = c01 )

c10 .• = •.c11 c11 .• = •.c10 (c10 • = c11 )

Quasi-commutation explains the difficulty in adding (and normalizing) negation in some BDDvariants like ZDD. Typically, a model that has the letter c01 without the letter (c01 )• = c00cannot properly support the encoding and propagation of the negation over the data structure: thenormalization becomes overly cumbersome while not offering any clear advantage.

We term the model λDD-O-UC enriched with ‘•’ λDD-O-NUC. The reduction operator [·] definedin the previous section is extended to account for the introduction and normalizing rules of • whilerespecting the implicit dependencies of the introduction rules. The detailed procedure is given inAppendix A. We prove also that λDD-O-NUC is canonical as part of the formalization of λDD-O data

8

structure in the Coq proof assistant.

Theorem 2 (Canonicity of λDD-O-NUC). Every Boolean function f has a unique, semanticallyequivalent, λDD-O-NUC graph φ satisfying the following property: the variable introduced by each �node of φ is neither a useless nor a canalizing variable. Moreover the canonical λDD-O-NUC graphof ¬f differs from φ only by the letter • at the upper-most edge of the graph.

Figure 1c shows the canonical λDD-O-NUC graph of the Boolean function of Example 1.

4 Functional Classification

The functional point of view suggests a natural way to classify and enumerate a vast class of orderedmodels. It turns out that a large body of already existing BDD variants can be seen, through thelenses of λDD, as special ordered models.

In this section, we start by exhaustively enumerating all arity-preserving functors that act onf ∈ Bn→1 by transforming its output f(x0, . . . , xn−1).

3

An arity-preserving operator that acts on f ∈ Bn→1 by transforming its output f(x0, . . . , xn−1)necessarily has the form:

(δpf) : (x0, . . . , xn−1) 7→ p(f(x0, . . . , xn−1))

where p is a Boolean function in B1→1. There are 221(= 4) possibilities for p: the two constant

functions 0 and 1 of arity 1, the identity function ı : x 7→ x, and the negation ¬ : x 7→ ¬x. When pis a constant function, δp is not injective and is therefore of little interest when it comes to canonicalrepresentations. When p is the identity ı, then δp is the identity operator ε. Thus, one recoversthe model λDD-S. Finally, when p is the negation, δp corresponds to δ¬ and the so obtained model,termed λDD-S-N, enriches λDD-S with the negation operator.

In a similar fashion, we enumerate elementary operators that act on f ∈ Bn→1 by combiningits output f(x1, . . . , xn) with a fresh variable x0. Such operator necessarily has the form

(δpf) : (x0, . . . , xn) 7→ p(x0, f(x1, . . . , xn)) ,

where the parameter p is now an element of B2→1. Let π1 ∈ B(n+1)→1 denote the projectionoperator returning the first input. We can enumerate the 22

2(= 16) possibilities for p by combining

two Boolean functions of arity 1 using the Shannon operator. Constant operators (2 cases), as wellas the operators involving the projection π1 (2 cases), are not injective. Therefore, they cannotbe used for canonical representations. Except for two injective operators, the rest can be fullycaptured by one of the elementary operators we have already introduced (related to useless orcanalizing variables—see Definitions 2 and 3), possibly combined with the negation operator. Thetwo remaining injective elementary operators reveal a new kind of variable which is neither uselessnor canalizing.

Definition 7 (Xor Variable). Let δx denote the following elementary operator:

δx : Bn→1 → B(n+1)→1, f 7→ f ? δ¬(f) .

A variable introduced with δx is called a xor variable.

3Other arity-preserving functors [14, 9] are possible and equally interesting. Those are however out of the scopefor this paper, but planned in the near future.

9

Although one can define a model solely with δx, without supporting the negation as an extraoperator, such a model would not necessarily be useful, as the reduction of the xor-variables cannotbe performed in constant time over normalized subgraphs. Thus, such operator is much morerelevant when the negation is properly supported (i.e., propagated and normalized as discussed inSection 3). This enumeration suggests that a model defined using

{u, x, c00 , c10 , c01 , c11} ∪ {•} ,

where the letter ‘x’ encodes δx, would be the most expressive, •-stable, model of the consideredclass as it has all the elementary operators plus the negation. The next section is entirely devotedto this model, termed λDD-O-NUCX.

Table 1: Existing BDD variants with their corresponding λDD ordered models.

Variant Model Alphabet

SDD λDD-S ∅ ∪ ∅SDD+N λDD-S-N ∅ ∪ {•}

ROBDD [6] λDD-O-U {u} ∪ ∅ROBDD+N [18] λDD-O-NU {u} ∪ {•}

ZDD [15] λDD-O-C10 {c10 } ∪ ∅ChainDD [8] λDD-O-UC10 {u, c10 } ∪ ∅

ChainDD+N [7] λDD-O-NUC10C11 {u, c10 , c11 } ∪ {•}ESR-L0 [2] λDD-O-UC10 {u, c10 } ∪ ∅

ESR [2] λDD-O-UC0 {u, c00 , c10 } ∪ ∅DAGaml-O-NUCX λDD-O-NUCX {u, x, c00 , c10 , c01 , c11 } ∪ {•}

Table 1 summarizes some λDD-O models and their related variants (or implementations). Ob-serve that the TBDD [19] variant is not an ordered model as it uses a syntactic negation that does notcorrespond to the (functional) standard negation.4 The last column of the table gives the alphabetof each model split into two subsets: elementary letters (left) and arity-preserving letters (right)where the expressiveness increases top down.

The ordered models introduced so far form in fact a complete lattice. Its (partial) Hassediagram is depicted in Figure 2. The least upper bound (resp. greatest lower bound) of two modelsis the model induced by the union (resp. intersection) of their ∆ alphabets. The first layer of thediagram has exactly 13 elements: one per elementary operator ({u, x, c00 , c01 , c10 , c11}), one pernegated elementary operator (not necessarily •-stable), and one involving the negation only. Amodel M2 is more expressive than another model M1 if and only if there is a path from M1 to M2

in the diagram. In particular, if there is no path between M1 and M2, then they are incomparable.This relation translates immediately to the number of nodes: the more expressive the model is, thesmaller its number of nodes. Observe for instance, the graphs of Figure 1, where the number ofnodes is decreasing from left to right.

It becomes apparent that Chain-BDD, Chain-ZDD [8], and ESRBDD−L0 [2] are three possibleimplementations of the λDD-O-UC10 model. The main difference between these variants resides intheir respective, carefully designed, choices of encoding the involved elementary operators either aslabels or special nodes. ESRBDD, for instance, encodes canalizing variables as nodes with one child.From a functional point of view, however, they are indistinguishable. To the best of our knowledge,such observation has never been made in the literature where only a performance comparison

4However, this variant can be captured as a model enriched with a specific operator that captures the semanticsof its syntactic negation.

10

λDD-O-NUCX

λDD-O-NU λDD-O-UC0

λDD-O-UC10

λDD-O-C10λDD-O-U

λDD-S

λDD-S-N

Figure 2: Some λDD ordered models organized in a lattice (cf. Table 1 for their correspondingvariants).

prevailed. Notice also that these three variants, as well as their related model, are not •-stable,hindering the support of constant-time negation. This gives a clear insight into a fundamentallimitation of these models.

Remark 3. In [7, Section 9], the author mentions an extension of Chain-BDD [8] with complementedges. The section is fairly short and doesn’t explain how this was done while preserving canonicity.We suspect that the author used both c10 and c11 to make the variant stable by negation. Recallthat these two letters quasi-commute with negation. Let’s also stress the fact that the two letterused in ESRBDD [2] do not quasi-commute making it difficult to support complement edges with theirnatural functional semantics.

5 λDD-O-NUCX

We discuss in this section the most expressive canonical model, called λDD-O-NUCX, that supports allelementary operators of the class λDD-O, together with negation: ∆ := {u, x, c00 , c10 , c01 , c11}∪{•}.We use the following introduction rule for the letter x (encoding xor-variables).

intro-x(φ, n) �

( •−→ (φ, n))

x−→ (φ, n).

The letter ‘x’ commutes with ‘•’, that is the word ‘x.•’ can be rewritten as ‘•.x’. Thus, ∆ is •-stable.The extension of the reduction operator [·] is much more involved and is part of the formalization

of the λDD data structure where we also proved the canonicity of the model.

Theorem 3 (Canonicity of λDD-O-NUCX). Every Boolean function f has a unique, semanticallyequivalent, λDD-O-NUCX graph φ satisfying the following property: the variable introduced by each �node of φ is neither a useless nor a canalizing variable nor a xor-variable. Moreover the canonicalλDD-O-NUCX graph of ¬f differs from φ only by the letter • at the upper-most edge of the graph.

To contrast this new model with the most recent BDD variants, namely ChainDD [8] andESR-L0 [2], the λDD-O-UC10 graph of the Boolean function of Example 1 is depicted in Figure 1bwhereas its λDD-O-NUCX graph is given in Figure 1d. The latter is clearly more concise as it hasonly one diamond node. Negating such graph in Chain-DD or ESR would require reconstructing

11

the entire diagram as both don’t support negation. Negating it in λDD-O-NUCX amounts to simplyadd a ‘•’ in the label of its uppermost edge.

5.1 Normalizing Logical Connectives

In practice, normalized λDD-O-NUCX graphs are built by normalizing the logical connectives. Wedetail below the procedure ‘andb’ that computes the conjunction of two normalized graphs. Thealgorithm is easily adaptable to the other operations. Computations are performed as usual, byrecursively pushing the logical operator down to the child graphs of diamond nodes. For clarity, wedenote a λDD graph (φ, n) simply by φ, omitting arity n whenever unnecessary. We consider thatthe arity can be always extracted from φ by calling arity(φ).

let rec andb φ ψ =if φ = ψ then φ

else if φ =•−→ ψ then (�, arity(φ))

else match φ with

| (�, n) −→I (�, n)

| •−→ (�, n) −→I ψ| _ −→I (match ψ with

| (�, n) −→I (�, n)

| •−→ (�, n) −→I φ| _ −→I (let φ0 = cofactor 0 φand φ1 = cofactor 1 φand ψ0 = cofactor 0 ψand ψ1 = cofactor 1 ψ in

(andb φ0 ψ0) �\• (andb φ1 ψ1) ))

‘cofactor v0 ψ’ is defined below. Intuitively, it returns the graph of the Boolean function ψ whenits first argument is set to v0.

let cofactor v0 φ =match φ with

| •−→ φ′ −→I •−→(cofactorElem v0 φ′)

| _ −→I (cofactorElem v0 φ)

let cofactorElem v0 φ =match φ with

| (�, n) −→I (�, n− 1)

| l−→ φ′ −→I match l with| u −→I φ′

| cbt −→I (if v0 = b then (t, n− 1) else φ′)

| x −→I (if v0 then•−→ φ′ else φ′)

We discuss below the time complexity of andb φ ψ. Let |φ| denote the number of diamondnodes of the normalized graph φ, and let |φ|S denote the number of diamond nodes of its equivalentλDD-S graph (obtained by eliminating all letters and using diamond nodes instead). The algorithmandb can be applied almost identically to λDD-S graphs except for a minor edit to account for theterminal node (�, 0). The algorithm performs a simple structural induction on its inputs. Assumingmemoization, the number of recursive calls is bounded by O(|φ|S × |ψ|S). The time complexity ofa single recursive call is O(1) as the complexity of cofactor is constant time (finite branching andno loops). Thus, the overall time complexity is O(|φ|S × |ψ|S).

12

We have |φ|S is equal to |φ| plus the total size (or length) of all words in φ (each letter is areduced diamond node). The size of any word in φ is bounded by n, the total number of variables.The total number of edges in φ is 1+2|φ|. Thus the total size of all words is bounded by (1+2|φ|)nand, therefore

|φ|S ≤ n+ |φ|+ 2n|φ| = O(n× |φ|) .

This leads to an overall time complexity bounded by O(n2 × |φ| × |ψ|).

5.2 Complexity of Common Queries

Common queries on ROBDD (e.g., TAUTOLOGY, EQUIVALENCE, SAT, AnySAT, AllSAT,#SAT) have polynomial time complexity on the size of the λDD-O-NUCX graphs.

The simplest way to check for EQUIVALENCE((φ, n), (ψ, n)) is by hash-consing both φ and ψ.Hash-consing has a linear time complexity in the size of both graphs leading to O(n× (|φ|+ |ψ|)).

For SAT, it suffices to check whether the graph is (�, n). In the worst case, the entire word (ofsize at most n) has to be checked, leading to a time complexity ofO(n). Likewise for TAUTOLOGY.

One can compute #SAT inductively on the structure of a λDD-O graph:

let rec count (φ, n) =match (φ, n) with| (�, n) −→I 0| (�, n) −→I 2n

| •−→ (φ′, n′) −→I 2n − count(φ′, n)

| u−→ (φ′, n′) −→I 2× count(φ′, n)

| x−→ (φ′, n′) −→I 2n′

| c00−−→ (φ′, n′) | c10−−→ (φ′, n′) −→I count(φ′, n)

| c01−−→ (φ′, n′) | c11−−→ (φ′, n′) −→I 2n′+ count(φ′, n)

| (φ0, n′) � (φ1, n

′) −→I count(φ0, n′) + count(φ1, n

′)

Using memoization, it can thus be computed in O(n × |φ|). Computing AnySat or AllSat can beperformed similarly by induction over the structure. In particular, AnySat can be computed inO(n), and AllSat in O(n×#SAT (φ)).

6 Compression Factors

We compare the size of the different λDD-O models presented so far. Let f denote a Booleanfunction. We denote by NA(f) the total number of nodes in the diagram that represents f withrespect to model A. For clarity, we restrict our attention to models with no complement edges (thatis models without the δ¬ functor). Knuth [13] showed that 5

NλDD-O-U(f) ≤ NλDD-S(f) ≤ n+ 1

2(NλDD-O-U(f) + 1)

and similarly for NλDD-O-C10(f) (which is equivalent to ZDD). In fact the same inequality holds forany (non-negated) model of the first layer of the Hasse diagram (see Figure 2). This in particularallows to compare the size of any two incomparable models. For instance, for ZDD and BDD one

5where λDD-S are referred to as quasi-BDD.

13

gets

NλDD-O-C10(f) ≤ n+ 1

2(NλDD-O-U(f) + 1) and NλDD-O-U(f) ≤ n+ 1

2(NλDD-O-C10(f) + 1) .

These inequalities bound the potential gain from using one model over the other and shows thatsuch gain is linear in the number of variables (which may be considerable when n is big). Thefollowing immediate generalization holds.

Theorem 4. If the model B is more expressive than model A with respect to the Hasse diagram ofFigure 2, then

NB(f) ≤ NA(f) ≤ n+ 1

2(NB(f) + 1) .

Consequently if models B1 and B2 are two incomparable models that are both more expressive thanA, then

NB1(f) ≤ n+ 1

2(NB2(f) + 1) and NB2(f) ≤ n+ 1

2(NB1(f) + 1) .

Proof. The reasoning to show these inequalities is essentially the same as in [13]. To count the sizeof the diagram, one counts the nodes at each level starting from level 0 for the root node all theway down to level n with the terminal nodes. For a level k of the diagram, let ak (resp. bk) denoteits total number of nodes for model A (resp. B). One shows that

ak ≤ 1 + b0 + · · ·+ bk−1︸ ︷︷ ︸µk

and ak ≤ bk + · · ·+ bn .

The first inequality holds because, as soon as a variable is typed, its related node is removed fromthe diagram making its in-degree branches to go necessarily past level k. Since there are µk nodesabove level k, the total number of branches leaving those nodes is 2µk, among which µk − 1 areused (to connect the µk nodes) thus leaving 1 + µk branches that are connected to nodes belowlevel k. Each branch corresponds necessarily to a function of arity n − k and ak is precisely thenumber of distinct (sub)functions of arity n− k. Thus ak ≤ 1 + µk.

For the second inequality, every (sub)function at level k corresponds necessarily to one functionamong the bk + · · · + bn functions up to extracting its typed variables (if any). Summing up thetwo inequalities, one gets

NA(f) ≤ n+ 1

2(NB(f) + 1) .

For the remaining inequality, since B is more expressive than A, it is obvious that NB(f) ≤ NA(f)because some nodes get eventually removed from the diagram of f in A. The inequalities comparingthe sizes of B1 and B2 are obtained by transitivity via A.

Theorem 4 gives a good estimate of the potential gain one may get when using more expressivemodels. It is interesting to note that, even for the most expressive model, the gain can only belinear in n at most.

One shows also that when negation is no longer supported, the size of the diagram can double:

NA+•(f) ≤ NA(f) ≤ 2NA+•(f),

14

where A + • denotes the model A extended with the negation functor δ¬.The main drawback of such analysis is that it doesn’t account for the size of the labels (or any

other artefact) used to encode chains of typed variables. These choices have naturally an impacton the potential gain (see for instance the bounds reported in [8] where the author used specialnodes to encode typed variables).

When labels are used, one can bound the overall size of all the labels by (2N+1)n for a diagramwith N nodes representing a function defined over n variables. Indeed each edge of the diagram hasat most n type symbols. The overall gain in the number of nodes may be in general compensatedby the overhead induced by using labels. These practical considerations are however applicationand implementation dependent and are not discussed in this paper.

7 Related Work

The λDD-based classification differs from Darwiche’s work [10] that uses relative compactness andabsolute worst-time complexity of standard queries to classify representations of Boolean functions.Firstly, λDD is more fine grained. With respect to Darwiche’s classification, many important variantslike ROBDD, ROBDD+N, ZDD, Chain-DD, TBDD and ESRBDD are mostly indistinguishable fromthe vanilla variant SDD since they all fall in the same class. Indeed, all λDD-O models we presentedin this work handle several queries (e.g., EQUIVALENCE, SAT, #SAT) in polytime, very muchlike ROBDD. Secondly, unlike Darwiche’s classification, the λDD framework focuses primarily ongetting more (functionally) expressive canonical models in a principled way.

Functional Decision Diagrams (FDDs), introduced by Kebschull et al. [12], share some similar-ities with λDD, starting with their names. While, in both approaches, logic circuits are regarded(semantically) as Boolean functions, only λDD regards reduction rules as functors operating onBoolean functions. Furthermore, λDD relies entirely on the Shannon operator (or combinator) todeconstruct Boolean functions whereas FDD uses the positive Davio combinator. Nothing preventsusing the latter in λDD, and there is in fact a nice correspondence between the functors in bothcases as detailed next.

7.1 Switching The Underlying Combinator

Recall that both Shannon and Davio combinators are universal and elementary : universal meansthat any Boolean function can be expressed as a combination of constant functions; elementarymeans that it operates on Boolean functions with the same arity by increasing the arity by 1.

Becker and Drechsler [3] identified a total of 12 distinct universal and elementary combinatorshaving the same form as Shannon’s, except that the branching relies on an arbitrary functionp instead of the valuation of one (Boolean) variable. By allowing output negation, they furtherreduced this number to only 3, one of which is Shannon’s; the other two combinators are thepositive and negative Davio combinators. Recall that the (positive) Davio combinator is definedover Boolean functions of the same arity as f ?D+ g as follows:

(f ?D+ g) : (x0, x1, . . . , xn) 7→ f(x1, . . . , xn)⊕ (x0 ∧ g(x1, . . . , xn)) .

Devising a data structure where the combinator is a parameter would be very relevant tocompare and better understand the benefits and drawbacks of switching the underlying combinator.This would be a necessary first step towards a generic universal structure that allows even morecomplex combinators [4, 1, 5].

15

Table 2: Equivalence between Shannon-based reduction rules and Davio-based-reduction rules

S D+ D−

u c10 c10x c11 c11c00 c00 uc01 c01 x

c10 u c00c11 x c01

In fact, Shannon-based reduction rules can be transposed into semantically equivalent positive(or negative) Davio-based reduction rules. To better appreciate this, let us detail an example. Toavoid any confusion, we use ?S below to denote the Shannon operator. The following equation

f ?S f = f ?D+ 0

holds for any Boolean function f by definition of the combinators. Hence, a useless variable for apositive Davio-based λDD would be syntactically captured by the ‘same’ introduction rule of theletter c10 we used for Shannon-based λDD, leading to the following sameness relation denoted by‘!’.

(φ, n) �S (�, n)c10−−→ (φ, n)

!(φ, n) �D+ (�, n)

u−→ (φ, n)

Table 2 summarizes this correspondence for the remaining elementary operators we have consideredin this work. This observation shows the flexibility of the λDD framework and settles the first stepstowards extending it to support Davio operators.

Conclusion

The functional point of view developed in this paper helps getting a better understanding of howdifferent existing variants of BDD are related, by abstracting away several implementation detailsin order to solely focus on how one constructs (or deconstructs) a Boolean function by adding (orremoving) typed variable. This approach allowed us to propose a new data structure with clearfunctional semantics, and to go beyond existing variants. We introduced a new model termedλDD-O-NUCX that combines useless variables, all canalizing variables and xor-variables while beinginvariant by negation. Its canonicity was formalized in the Coq proof assistant. More importantly,the approach we used could be very well instantiated using other elementary and arity-preservingoperators that are application dependent achieving therefor a better compression rate.

References

[1] L. Amaru, P. Gaillardon, and G. D. Micheli, Biconditional bdd: A novel canonicalbdd for logic synthesis targeting xor-rich circuits, in 2013 Design, Automation Test in EuropeConference Exhibition (DATE), March 2013, pp. 1014–1017.

[2] J. Babar, C. Jiang, G. Ciardo, and A. Miner, Binary Decision Diagrams with Edge-Specified Reductions, in Tools and Algorithms for the Construction and Analysis of Systems,

16

T. Vojnar and L. Zhang, eds., TACAS’19, Springer International Publishing, 2019, pp. 303–318.

[3] B. Becker and R. Drechsler, How many decomposition types do we need? [decisiondiagrams], in EDTC, 1995.

[4] A. Bernasconi, V. Ciriani, G. Trucco, and T. Villa, On decomposing boolean functionsvia extended cofactoring, in Proceedings of the Conference on Design, Automation and Test inEurope, DATE ’09, 3001 Leuven, Belgium, Belgium, 2009, European Design and AutomationAssociation, pp. 1464–1469.

[5] V. M. Bertacco, Achieving Scalable Hardware Verification with Symbolic Simulation, PhDthesis, Stanford University, Stanford, CA, USA, 2003. AAI3104197.

[6] R. E. Bryant, Graph-based algorithms for boolean function manipulation, IEEE Trans. Com-put., 35 (1986), pp. 677–691.

[7] , Chain reduction for binary and zero-suppressed decision diagrams, CoRR,abs/1710.06500 (2017).

[8] R. E. Bryant, Chain reduction for binary and zero-suppressed decision diagrams, in TACAS(1), vol. 10805 of Lecture Notes in Computer Science, Springer, 2018, pp. 81–98.

[9] J. R. Burch and D. E. Long, Efficient boolean function matching, in 1992 IEEE/ACMInternational Conference on Computer-Aided Design, Los Alamitos, CA, USA, 1992, IEEEComputer Society Press, pp. 408–411.

[10] A. Darwiche and P. Marquis, A Knowledge Compilation Map, 1, 17 (2002), pp. 229–264.

[11] Q. He and M. Macauley, Stratification and enumeration of boolean functions by canalizingdepth, CoRR, abs/1504.07591 (2015).

[12] U. Kebschull, E. Schubert, and W. Rosenstiel, Multilevel logic synthesis based onfunctional decision diagrams, in [1992] Proceedings The European Conference on Design Au-tomation, Mar. 1992, pp. 43–47. ISSN: null.

[13] D. Knuth, The Art of Computer Programming, Volume 4A: Combinatorial Algorithms, Part1, Pearson Education, 2014.

[14] D. M. Miller and R. Drechsler, Dual edge operations in reduced ordered binary decisiondiagrams, in Circuits and Systems, 1998. ISCAS ’98. Proceedings of the 1998 IEEE Interna-tional Symposium on, vol. 6, May 1998, pp. 159–162 vol.6.

[15] S. Minato, Zero-suppressed bdds for set manipulation in combinatorial problems, in Proceed-ings of the 30th International Design Automation Conference, New York, NY, USA, 1993,ACM, pp. 272–277.

[16] S. Minato, N. Ishiura, and S. Yajima, Shared binary decision diagram with attributededges for efficient boolean function manipulation, in 27th ACM/IEEE Design AutomationConference, Jun 1990, pp. 52–57.

[17] A. Mishchenko, An introduction to zero-suppressed binary decision diagrams, tech. rep.,in ‘Proceedings of the 12th Symposium on the Integration of Symbolic Computation andMechanized Reasoning, 2001.

17

[18] F. Somenzi, Efficient manipulation of decision diagrams, International Journal on SoftwareTools for Technology Transfer, 3 (2001).

[19] T. van Dijk, R. Wille, and R. Meolic, Tagged bdds: Combining reduction rules fromdifferent decision diagram types, in FMCAD, IEEE, 2017, pp. 108–115.

18

A Normalizing λDD-O-NUC

The procedure [·] below reduces inductively a λDD-O-NUC graph. ` denotes an elementary operatorin ∆ = {u, c11 , c10 , c01 , c00}.let φ0 �\ φ1 =

match φ0 � φ1 with

| φ � φ −→I u−→ φ

| φ � (•−→ (�, n)) −→I c11−−→ φ

| φ � (�, n) −→I c10−−→ φ

| (�, n) � (•−→ φ) −→I •.c01−−−→ φ

| (�, n) � φ −→I c00−−→ φ| −→I φ0 � φ1

let •\φ =match φ with

| •−→ φ′ −→I φ′

| −→I •−→ φ′

let φ0 �\• φ1 =match φ0 with

| (•−→ φ′0) −→I •\(φ′0 �\ (•\φ1))

| −→I φ0 �\ φ1

let rec [φ] =match φ with

| (�, 0) −→I (�, 0)

| (�, 0) −→I •−→ (�, 0)

| •−→ φ′ −→I •\[φ′]| `−→ φ′ −→Ilet ψ0 � ψ1 = elim-`(φ′) in [ψ0] �\• [ψ1]

| φ0 � φ1 −→I [φ0] �\• [φ1]

19