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

11institutetext: Computer Science Department, UCLA
11email: {\{aychoi, anchal, darwiche}\}@cs.ucla.edu
22institutetext: Computer Science Department, Stanford University
22email: [email protected]

On Symbolically Encoding the
Behavior of Random Forests

Arthur Choi 11    Andy Shih 22    Anchal Goyanka 11    Adnan Darwiche 11
Abstract

Recent work has shown that the input-output behavior of some machine learning systems can be captured symbolically using Boolean expressions or tractable Boolean circuits, which facilitates reasoning about the behavior of these systems. While most of the focus has been on systems with Boolean inputs and outputs, we address systems with discrete inputs and outputs, including ones with discretized continuous variables as in systems based on decision trees. We also focus on the suitability of encodings for computing prime implicants, which have recently played a central role in explaining the decisions of machine learning systems. We show some key distinctions with encodings for satisfiability, and propose an encoding that is sound and complete for the given task.

Keywords:
Explainable AI Random Forests Prime Implicants.

1 Introduction

Recent work has shown that the input-output behavior of some machine learning systems can be captured symbolically using Boolean expressions or tractable Boolean circuits [10, 12, 16, 25, 7, 8, 26, 23]. These encodings facilitate the reasoning about the behavior of these systems, including the explanation of their decisions, the quantification of their robustness and the verification of their properties. Most of the focus has been on systems with Boolean inputs and outputs, with some extensions to discrete inputs and outputs, including discretizations of continuous variables as in systems based on decision trees; see, e.g., [2, 15, 9]. This paper is concerned with the latter case of discrete/continuous systems but those that are encoded using Boolean variables, with the aim of utilizing the vast machinery available for reasoning with Boolean logic. Most prior studies of Boolean encodings have focused on the tasks of satisfiability and model counting [11, 27, 2]. In this paper, we focus instead on prime implicants which have recently played a central role in explaining the decisions of machine learning systems [25, 20, 7, 8, 9, 5]; cf. [21]. We first highlight how the prime implicants of a multi-valued expression are not immediately obtainable as prime implicants of a corresponding Boolean encoding. We reveal how to compute these prime implicants, by computing them instead on a Boolean expression derived from the encoding. Our study is conducted in the context of encoding the behavior of random forests using majority voting, but our results apply more broadly.

This paper is structured as follows. We introduce the task in Section 2 as well as review related work. We discuss in Section 3 the problem of explaining the decisions of machine learning systems whose continuous features can be discretized into intervals. We follow in Section 4 by a discussion on encoding the input-output behavior of such systems, where we analyze three encodings from the viewpoint of computing explanations for decisions. We show that one of these encodings is suitable for this purpose, if employed carefully, while proving its soundness and completeness for the given task. We finally close in Section 5.

2 Boolean, Discrete and Continuous Behaviors

The simplest behaviors to encode are for systems with Boolean inputs and outputs. Consider a neural network whose inputs are Boolean and that has only step activation functions. Each neuron in this network computes a Boolean function and therefore each output of the network also computes a Boolean function. The input-output behavior of such networks can be immediately represented using Boolean expressions, or Boolean circuits as proposed in [3, 23].

Suppose now that the inputs to a machine learning system are discrete variables, say, variable AA with values 1,2,31,2,3, variable BB with values r,b,gr,b,g and variable CC with values l,m,hl,m,h. One can define a multi-valued propositional logic to capture the behavior of such a system. The atomic expressions in this case will be of the form V=v{V\!\!=\!v}, indicating that discrete variable VV has the value vv. We can then construct more complex expressions using Boolean connectives. An example expression in this logic would be (B=rB=b)(A=2¬C=h)({B\!\!=\!r}\vee{B\!\!=\!b})\implies({A\!\!=\!2}\wedge\neg{C\!\!=\!h}).

Refer to caption value interval x1x_{1} (,2)(-\infty,2) x2x_{2} [2,6)[2,6) x3x_{3} [6,+)[6,+\infty) y1y_{1} (,7)(-\infty,-7) y2y_{2} [7,+)[-7,+\infty) XX YY f(X,Y)f(X,Y) x1x_{1} y1y_{1} 0 x1x_{1} y2y_{2} 1 x2x_{2} y1y_{1} 1 x2x_{2} y2y_{2} 1 x3x_{3} y1y_{1} 0 x3x_{3} y2y_{2} 0

Figure 1: (Left) A decision tree of continuous variables XX and YY, where a solid branch means the test is true, and a dashed branch means false. (Center) A discretization of XX and YY into intervals. (Right) The discrete function represented by the decision tree.

Some systems may have continuous variables as inputs, which get discretized during the learning process as is the case with systems based on decision trees. Consider for example the decision tree in Figure 1 (left) over continuous variables XX and YY. The algorithm that learned this tree discretized its variables as follows: XX to intervals (,2),[2,6),[6,+)(-\infty,2),[2,6),[6,+\infty) and YY to intervals (,7),[7,+).(-\infty,-7),[-7,+\infty).

We can now think of variable XX as a discrete variable with three values x1,x2,x3x_{1},x_{2},x_{3}, each corresponding to one of the intervals as shown in Figure 1 (center). Variable YY is binary in this case, with each value corresponding to one of the two intervals. According to this decision tree, the infinite number of input values for variables XX and YY can be grouped into six equivalence classes as shown in Figure 1 (right). Hence, the input-output behavior of this decision tree can be captured using the multi-valued propositional expression f(X,Y)=(X=x1Y=y2)X=x2f(X,Y)=({X\!\!=\!x_{1}}\wedge{Y\!\!=\!y_{2}})\vee{X\!\!=\!x_{2}}, even though we have continuous variables.

Our goal is therefore to encode multi-valued expressions using Boolean expressions as we aim to exploit the vast machinery currently available for reasoning with propositional logic. This includes SAT-based and knowledge compilation tools, which have been used extensively recently to reason about the behavior of machine learning systems [10, 12, 16, 25, 7, 8, 26, 23].

Encoding multi-valued expressions using Boolean expressions has been of interest for a very long time and several methods have been proposed for this purpose; see, e.g., [11, 27, 2]. In some cases, different encodings have been compared in terms of the efficacy of applied SAT-based tools; see, e.g., [27]. In this paper, we consider another dimension for evaluating encodings, which is based on their suitability for computing prime implicants. This is motivated by the fundamental role that implicants have been playing recently in explaining the decisions of machine learning systems [25, 20, 7, 8, 9, 5].

The previous works use the notion of a PI-explanation when explaining the decision of a classifier on an instance. A PI-explanation, introduced in [25], is a minimal set of instance characteristics that are sufficient to trigger the decision. That is, if these characteristics are fixed, other instance characteristics can be changed freely without changing the decision. In an image, for example, a PI-explanation corresponds to a minimal set of pixels that guarantees the stability of a decision against any perturbation of the remaining pixels.111A PI-explanation can be viewed as a (minimally) sufficient reason for the decision [5].

PI-explanations are based on prime implicants of Boolean functions, which have been studied extensively in the literature [4, 17, 13, 18]. Consider the following Boolean function over variables AA, BB and CC: f=(A+C¯)(B+C)(A+B).f=(A+\overline{C})(B+C)(A+B). A prime implicant of the function is a minimal setting of its variables that causes the function to trigger. This function has three prime implicants: ABAB, ACAC and BC¯B\overline{C}. Consider now the instance ABC¯AB\overline{C} leading to a positive decision f(ABC¯)=1f(AB\overline{C})=1. The PI-explanations for this decision are the prime implicants of function ff that are compatible with the instance: ABAB and BC¯B\overline{C}. Explaining negative decisions requires working with the function’s complement f¯\overline{f}. Consider instance A¯BC\overline{A}BC, which sets the function ff to 0. The complement f¯\overline{f} has three prime implicants A¯C\overline{A}C, B¯C¯\overline{B}\,\overline{C} and A¯B¯\overline{A}\,\overline{B}. Only one of these is compatible with the instance, A¯C\overline{A}C, so it is the only PI-explanation for the decision on this instance.222The popular Anchor system [22] can be viewed as computing approximations of PI-explanations. The quality of these approximations has been evaluated on some datasets and corresponding classifiers in [9], where an approximation is called optimistic if it is a strict subset of a PI-explanation and pessimistic if it is a strict superset of a PI-explanation. Anchor computes approximate explanations without having to abstract the machine learning system behavior into a symbolic representation.

When considering the encoding of multi-valued expressions using Boolean ones, we will be focusing on whether the prime implicants of multi-valued expressions can be soundly and completely obtained from the prime implicants of the corresponding Boolean expressions. This is motivated by the desire to exploit existing algorithms and tools for computing prime implicants of Boolean expressions (one may also consider developing a new set of algorithms and tools for operating directly on multi-valued expressions).

Before we propose and evaluate some encodings, we need to first define the notion of a prime implicant for multi-valued expressions and then examine explanations from that perspective. This is needed to settle the semantics of explanations in a multi-valued setting, which will then form the basis for deciding whether a particular encoding is satisfactory from the viewpoint of computing explanations. As the following discussion will reveal, the multi-valued setting leads to some new considerations that are preempted in a Boolean setting.

3 Explaining Decisions in a Multi-Valued Setting

Consider again the decision tree in Figure 1 whose behavior is captured by the multi-valued expression (X=x1Y=y2)X=x2({X\!\!=\!x_{1}}\wedge{Y\!\!=\!y_{2}})\vee{X\!\!=\!x_{2}} as discussed earlier. Consider also the positive instance X=3Y=12{X\!\!=\!3}\wedge{Y\!\!=\!12}, which can be represented using the multi-valued expression α:X=x2Y=y2\alpha:{X\!\!=\!x_{2}}\wedge{Y\!\!=\!y_{2}} as shown in Figure 1.

Instance α\alpha has two characteristics X=x2{X\!\!=\!x_{2}} and Y=y2{Y\!\!=\!y_{2}}, yet one of them X=x2{X\!\!=\!x_{2}} is sufficient to trigger the positive decision. Hence, one explanation for the decision is that variable XX takes a value in the interval [2,6)[2,6), which justifies X=x2{X\!\!=\!x_{2}} as a PI-explanation of this positive decision. In fact, if we stick to the literal definition of a PI-explanation from the Boolean setting, then this would be the only PI-explanation since Y=y2{Y\!\!=\!y_{2}} is the only characteristic that can be dropped from the instance while guaranteeing that the decision will stick.

Looking closer, this decision would also stick if the value of XX were contained in the larger interval (,6)(-\infty,6) as long as characteristic Y=y2{Y\!\!=\!y_{2}} is maintained. The interval (,6)(-\infty,6) corresponds to (X=x1X=x2({X\!\!=\!x_{1}}\vee{X\!\!=\!x_{2}}), leading to the expression (X=x1X=x2)Y=y2({X\!\!=\!x_{1}}\vee{X\!\!=\!x_{2}})\wedge{Y\!\!=\!y_{2}}. This expression is the result of weakening literal X=x2{X\!\!=\!x_{2}} in instance X=x2Y=y2{X\!\!=\!x_{2}}\wedge{Y\!\!=\!y_{2}}. It can be viewed as a candidate explanation of the decision on this instance, just like X=x2{X\!\!=\!x_{2}}, in the sense that it also represents an abstraction of the instance that preserves the corresponding decision.

For another example, consider the negative decision on instance X=10Y=20{X\!\!=\!10}\wedge{Y\!\!=\!-20}, and its corresponding multi-valued expression α:X=x3Y=y1\alpha:{X\!\!=\!x_{3}}\wedge{Y\!\!=\!y_{1}}. Recall that x3x_{3} represents the interval [6,+)[6,+\infty) and y1y_{1} represents the interval (,7)(-\infty,-7). We can drop the characteristic Y=y1{Y\!\!=\!y_{1}} from this instance while guaranteeing that the negative decision will stick (i.e., regardless of what value variable YY takes). Hence, X=x3{X\!\!=\!x_{3}} is a PI-explanation in this case. But again, if we maintain the characteristic Y=y1{Y\!\!=\!y_{1}}, then this negative decision will stick as long as the value of XX is in the larger, disconnected interval (,2][6,+)(-\infty,2]\cup[6,+\infty). This interval is represented by the expression X=x1X=x3{X\!\!=\!x_{1}}\vee{X\!\!=\!x_{3}} which is a weakening of characteristic X=x3{X\!\!=\!x_{3}}. This makes (X=x1X=x3)Y=y1({X\!\!=\!x_{1}}\vee{X\!\!=\!x_{3}})\wedge{Y\!\!=\!y_{1}} a candidate explanation as well.

3.1 Multi-Valued Literals, Terms and Implicants

We will now formalize some notions on multi-valued variables and then use them to formally define PI-explanations in a multi-valued setting [19, 14]. We use three multi-valued variables for our running examples: Variable AA with values 1,2,31,2,3, variable BB with values r,b,gr,b,g and variable CC with values l,m,hl,m,h.

A literal is a non-trivial propositional expression that mentions a single variable. The following are literals: B=rB=b{B\!\!=\!r}\vee{B\!\!=\!b}, A=2{A\!\!=\!2} and Ch{C\!\!\not=\!h}. The following are not literals as they are trivial: B=rB=bB=g{B\!\!=\!r}\vee{B\!\!=\!b}\vee{B\!\!=\!g} and C=hCh{C\!\!=\!h}\wedge{C\!\!\not=\!h}. Intuitively, for a variable with nn values, a literal specifies a set of values SS where the cardinality of set SS is in {1,,n1}\{1,\ldots,n-1\}. A literal is simple if it specifies a single value (cardinality of set SS is 11). When multi-valued variables correspond to the discretization of continuous variables, our treatment allows a literal to specify non-contiguous intervals of a continuous variable.

Consider two literals i{\ell}_{i} and j{\ell}_{j} for the same variable. We say i{\ell}_{i} is stronger than j{\ell}_{j} iff ij{\ell}_{i}\models{\ell}_{j} and ij{\ell}_{i}\not\equiv{\ell}_{j}. In this case, j{\ell}_{j} is weaker than i{\ell}_{i}. For example, B=r{B\!\!=\!r} is stronger than B=rB=b{B\!\!=\!r}\vee{B\!\!=\!b}. It is possible to have two literals where neither is stronger or weaker than the other (e.g., B=rB=b{B\!\!=\!r}\vee{B\!\!=\!b} and B=g{B\!\!=\!g}).

A term is a conjunction of literals over distinct variables. The following is a term: A=2(B=rB=b)Ch{A\!\!=\!2}\wedge({B\!\!=\!r}\vee{B\!\!=\!b})\wedge{C\!\!\not=\!h}. A term is simple if all of its literals are simple. The following term is simple: A=2B=rC=h{A\!\!=\!2}\wedge{B\!\!=\!r}\wedge{C\!\!=\!h}. The following terms are not simple: A2B=rC=h{A\!\!\not=\!2}\wedge{B\!\!=\!r}\wedge{C\!\!=\!h} and A=2(B=rB=b)C=h{A\!\!=\!2}\wedge({B\!\!=\!r}\vee{B\!\!=\!b})\wedge{C\!\!=\!h}. A simple term that mentions every variable is called an instance.

Term τi{\tau}_{i} subsumes term τj{\tau}_{j} iff τjτi{\tau}_{j}\models{\tau}_{i}. If we also have τiτj{\tau}_{i}\not\equiv{\tau}_{j}, then τi{\tau}_{i} strictly subsumes τj{\tau}_{j}. For example, the term A=2(B=rB=b)Ch{A\!\!=\!2}\wedge({B\!\!=\!r}\vee{B\!\!=\!b})\wedge{C\!\!\not=\!h} is strictly subsumed by the terms A1(B=rB=b)Ch{A\!\!\not=\!1}\wedge({B\!\!=\!r}\vee{B\!\!=\!b})\wedge{C\!\!\not=\!h} and A=2Ch{A\!\!=\!2}\wedge{C\!\!\not=\!h}.

We stress two points now. First, if term τi{\tau}_{i} strictly subsumes term τj{\tau}_{j} that does not necessarily mean that τi{\tau}_{i} mentions a fewer number of variables than τj{\tau}_{j}. In fact, it is possible that the literals of τi{\tau}_{i} and τj{\tau}_{j} are over the same set of variables. Second, a term does not necessarily fix the values of its variables (unless it is a simple term), which is a departure from how terms are defined in Boolean logic.

In Boolean logic, the only way to get a term that strictly subsumes term τ{\tau} is by dropping some literals from τ{\tau}. In multi-valued logic, we can also do this by weakening some literals in term τ{\tau} (i.e., without dropping any of its variables). This notion of weakening a literal generalizes the notion of dropping a literal in the Boolean setting. In particular, dropping a Boolean literal {\ell} from a Boolean term can be viewed as weakening it into ¬{\ell}\vee\neg{\ell}.

Term τ{\tau} is an implicant of expression Δ\Delta iff τΔ{\tau}\models\Delta. Term τ{\tau} is a prime implicant of Δ\Delta iff it is an implicant of Δ\Delta that is not strictly subsumed by another implicant of Δ\Delta. It is possible to have two terms over the same set of variables such that (a) the terms are compatible in that they admit some common instance, (b) both are implicants of some expression Δ\Delta, yet (c) only one of them is a prime implicant of Δ\Delta. We stress this possibility as it does not arise in a Boolean setting. We define the notions of simple implicant and simple prime implicant in the expected way.

3.2 Multi-Valued Explanations

Consider now a classifier specified using a multi-valued expression Δ\Delta. The variables of Δ\Delta will be called features so an instance α\alpha is a simple term that mentions all features. That is, an instance fixes a value for each feature of the classifier. A decision on instance α\alpha is positive iff the expression Δ\Delta evaluates to 11 on instance α\alpha, written Δ(α)=1\Delta(\alpha)=1. Otherwise, the decision is negative (when Δ(α)=0\Delta(\alpha)=0).

The notation Δα\Delta_{\alpha} is crucial for defining explanations: Δα\Delta_{\alpha} is defined as Δ\Delta if decision Δ(α)\Delta(\alpha) is positive and Δα\Delta_{\alpha} is defined as ¬Δ\neg\Delta if decision Δ(α)\Delta(\alpha) is negative. A PI-explanation for decision Δ(α)\Delta(\alpha) is a prime implicant of Δα\Delta_{\alpha} that is consistent with instance α\alpha. This basically generalizes the notion of PI-explanation introduced in [25] to a multi-valued setting.

The term explanation is somewhat too encompassing so any definition of this general notion is likely to draw criticism as being too narrow. The PI-explanation is indeed narrow as it is based on a syntactic restriction: it must be a conjunction of literals (i.e., a term) [25]. In the Boolean setting, a PI-explanation is a minimal subset of instance characteristics that is sufficient to trigger the same decision made on the instance. In the multi-valued setting, it can be more generally described as an abstraction of the instance that triggers the same decision made on the instance (still in the syntactic form of a term).

As an example, consider the following truth table representing the decision function of a classifier over two ternary variables XX and YY:

X,YX,Y x1y1x_{1}y_{1} x1y2x_{1}y_{2} x1y3x_{1}y_{3} x2y1x_{2}y_{1} x2y2x_{2}y_{2} x2y3x_{2}y_{3} x3y1x_{3}y_{1} x3y2x_{3}y_{2} x3y3x_{3}y_{3}
f(X,Y)f(X,Y) 1 0 0 1 0 0 1 1 1

Consider instance X=x3Y=y1{X\!\!=\!x_{3}}\wedge{Y\!\!=\!y_{1}} leading to a positive decision. The sub-term X=x3{X\!\!=\!x_{3}} is a PI-explanation for this decision: setting input XX to x3x_{3} suffices to trigger a positive decision. Similarly, the sub-term Y=y1{Y\!\!=\!y_{1}} is a second PI-explanation for this decision. Consider now instance X=x1Y=y2{X\!\!=\!x_{1}}\wedge{Y\!\!=\!y_{2}} leading to a negative decision. This decision has a single PI-explanation: Xx3Yy1{X\!\!\not=\!x_{3}}\wedge{Y\!\!\not=\!y_{1}}. Any instance consistent with this explanation will be decided negatively.

4 Encoding Multi-Valued Behavior

We next discuss three encodings that we tried for the purpose of symbolically representing the behavior of decision trees (and random forests). The first two encodings turned out unsuitable for computing prime implicants. Here, suitability refers to the ability of computing multi-valued prime implicants by processing Boolean prime implicants locally and independently. The third encoding, based on a classical encoding [11], was suitable for this purpose but required a usage that deviates from tradition. Using this encoding in a classical way makes it unsuitable as well. The summary of the findings below is that while an encoding may be appropriate for testing satisfiability or counting models, it may not be suitable for computing prime implicants (and, hence, explanations). While much attention was given to encodings in the context of satisfiability and model counting, we are not aware of similar treatments for computing prime implicants.

4.1 Prefix Encoding

Consider a multi-valued variable XX with values x1,,xnx_{1},\ldots,x_{n}. This encoding uses Boolean variables x2,,xnx_{2},\ldots,x_{n} to encode the values of variable XX. Literal X=xi{X\!\!=\!x_{i}} is encoded by setting the first i1i-1 Boolean variables to 11 and the rest to 0. For example, if n=3n=3, the values of XX are encoded as x¯2x¯3\bar{x}_{2}\bar{x}_{3}, x2x¯3x_{2}\bar{x}_{3} and x2x3x_{2}x_{3}. Some instantiations of these Boolean variables will not correspond to any value of variable XX and are ruled out by enforcing the following constraint: all Boolean variables set to 11 must occur before all Boolean variables set to 0. We denote this constraint by ΨX\Psi_{X}: i{3,,n}(xixi1)\bigwedge_{i\in\{3,\ldots,n\}}(x_{i}\Rightarrow x_{i-1}).

The fundamental problem with this encoding is that a multi-valued literal that represents non-contiguous values cannot be represented by a Boolean term. Hence, this encoding cannot generate prime implicants that include such literals. Consider the multi-valued expression Δ=(X=x1X=x3)\Delta=({X\!\!=\!x_{1}}\vee{X\!\!=\!x_{3}}), where XX has values x1,,x4x_{1},\ldots,x_{4}, and its Boolean encoding Δb=x¯2x¯3x¯4+x2x3x¯4\Delta_{b}=\bar{x}_{2}\bar{x}_{3}\bar{x}_{4}+x_{2}x_{3}\bar{x}_{4}. There is only one prime implicant of Δ\Delta, which is X=x1X=x3{X\!\!=\!x_{1}}\vee{X\!\!=\!x_{3}}, but this prime implicant cannot be represented by a Boolean term (that implies Δb\Delta_{b}) so it will never be generated.

4.2 Highest-Bit Encoding

Consider a multi-valued variable XX with values x1,x2,,xnx_{1},x_{2},\ldots,x_{n}. This encoding uses Boolean variables x2,x3,,xnx_{2},x_{3},\ldots,x_{n} to encode the values of variable XX. Every instantiation of these Boolean variables will map to a value of variable XX in the following way. If all Boolean variables are 0, then we map the instantiation to value x1x_{1}. Otherwise we map an instantiation to the maximum index whose variable is 11. The following table provides an example for n=4n=4.

x2x3x4x_{2}x_{3}x_{4} 000 001 010 011 100 101 110 111
highest 11-index - 4 3 4 2 4 3 4
value x1x_{1} x4x_{4} x3x_{3} x4x_{4} x2x_{2} x4x_{4} x3x_{3} x4x_{4}

We can alternatively view this encoding as representing literal X=x1{X\!\!=\!x_{1}} using the Boolean term x¯2x¯n\bar{x}_{2}\ldots\bar{x}_{n} and literal X=xi{X\!\!=\!x_{i}}, i2i\geq 2, using the term xix¯i+1x¯nx_{i}\bar{x}_{i+1}\ldots\bar{x}_{n}. Literals over multiple values can also be represented with this encoding. For example, we can represent the literal X=x1X=x2{X\!\!=\!x_{1}}\vee{X\!\!=\!x_{2}} using the term x¯3x¯4.\bar{x}_{3}\bar{x}_{4}.

This encoding also turned out to be unsuitable for computing prime implicants. Consider the multi-valued expression Δ=(X=x1X=x3)\Delta=({X\!\!=\!x_{1}}\vee{X\!\!=\!x_{3}}), which has one prime implicant Δ\Delta. The Boolean encoding Δb\Delta_{b} is x¯2x¯3x¯4+x3x¯4\bar{x}_{2}\bar{x}_{3}\bar{x}_{4}+x_{3}\bar{x}_{4} and has two prime implicants x¯2x¯4\bar{x}_{2}\bar{x}_{4} and x3x¯4x_{3}\bar{x}_{4}. The term x3x¯4x_{3}\bar{x}_{4} corresponds to the multi-valued implicant X=x3{X\!\!=\!x_{3}}, which is not prime. The term x¯2x¯4\bar{x}_{2}\bar{x}_{4} does not even correspond to a multi-valued term. So in this encoding too, prime implicants of the original multi-valued expression Δ\Delta cannot be computed by locally and independently processing prime implicants of the encoded Boolean expression Δb\Delta_{b}.

4.3 One-Hot Encoding

The prefix and highest-bit encodings provide some insights into requirements that enable one to locally and independently map Boolean prime implicants into multi-valued ones. The requirements are: (1) every multi-valued literal should be representable using a Boolean term, and (2) equivalence and subsumption relations over multi-valued literals should be preserved over their Boolean encodings. The next encoding satisfies these requirements. It is based on [11] but deviates from it in some significant ways that we explain later.

Suppose XX is a multi-valued variable with values x1,,xnx_{1},\ldots,x_{n}. This encoding uses a Boolean variable xix_{i} for each value xix_{i} of variable XX. Suppose now that {\ell} is a literal that specifies a subset SS of these values. The literal will be encoded using the negative Boolean term xiSx¯i\bigwedge_{x_{i}\not\in S}\bar{x}_{i}. For example, if variable XX has three values, then literal X=x2{X\!\!=\!x_{2}} will be encoded using the negative Boolean term x¯1x¯3\bar{x}_{1}\bar{x}_{3} and literal X=x1X=x2{X\!\!=\!x_{1}}\vee{X\!\!=\!x_{2}} will be encoded using the negative Boolean term x¯3\bar{x}_{3}. This encoding requires the employment of an exactly-one constraint for each variable XX, which we denote by ΨX\Psi_{X}: (ixi)ij¬(xixj)(\bigvee_{i}x_{i})\wedge\bigwedge_{i\neq j}\neg(x_{i}\wedge x_{j}). We also use Ψ\Psi to denote the conjunction of all exactly-one constraints.

Using the encoding in [11], one typically represents literal X=xi{X\!\!=\!x_{i}} by the Boolean term xix_{i} which asserts value xix_{i}. Our encoding, however, represents this literal by eliminating all other values of XX. The following result reveals why we made this choice (proofs of results can be found in the appendix).

Proposition 1

Multi-valued terms correspond one-to-one to negative Boolean terms that are consistent with Ψ\Psi. Equivalence and subsumption relations on multi-valued terms are preserved on their Boolean encodings.

Exactly-one constraints are normally added to an encoding as done in [11]. We next show that this leads to unintended results when computing prime implicants, requiring another deviation from [11]. Consider two ternary variables XX and YY, the expression Δ:X=x1Y=y1\Delta:{X\!\!=\!x_{1}}\vee{Y\!\!=\!y_{1}} and its Boolean encoding Δb:x¯2x¯3+y¯2y¯3\Delta_{b}:\bar{x}_{2}\bar{x}_{3}+\bar{y}_{2}\bar{y}_{3}. If Ψ\Psi is the conjunction of all exactly-one constraints (Ψ=ΨXΨY\Psi=\Psi_{X}\wedge\Psi_{Y}), then Δ\Delta and ΔbΨ\Delta_{b}\wedge\Psi will each have five models:

Δ\Delta X=x1,Y=y1{X\!\!=\!x_{1}},{Y\!\!=\!y_{1}} X=x1,Y=y2{X\!\!=\!x_{1}},{Y\!\!=\!y_{2}} X=x1,Y=y3{X\!\!=\!x_{1}},{Y\!\!=\!y_{3}} X=x2,Y=y1{X\!\!=\!x_{2}},{Y\!\!=\!y_{1}} X=x3,Y=y1{X\!\!=\!x_{3}},{Y\!\!=\!y_{1}}
ΔbΨ\Delta_{b}\wedge\Psi x1x¯2x¯3y1y¯2y¯3x_{1}\bar{x}_{2}\bar{x}_{3}y_{1}\bar{y}_{2}\bar{y}_{3} x1x¯2x¯3y¯1y2y¯3x_{1}\bar{x}_{2}\bar{x}_{3}\bar{y}_{1}y_{2}\bar{y}_{3} x1x¯2x¯3y¯1y¯2y3x_{1}\bar{x}_{2}\bar{x}_{3}\bar{y}_{1}\bar{y}_{2}y_{3} x¯1x2x¯3y1y¯2y¯3\bar{x}_{1}x_{2}\bar{x}_{3}y_{1}\bar{y}_{2}\bar{y}_{3} x¯1x¯2x3y1y¯2y¯3\bar{x}_{1}\bar{x}_{2}x_{3}y_{1}\bar{y}_{2}\bar{y}_{3}

The term X=x1{X\!\!=\!x_{1}} is an implicant of Δ\Delta. However, its corresponding Boolean encoding x¯2x¯3\bar{x}_{2}\bar{x}_{3} is not an implicant of ΔbΨ\Delta_{b}\wedge\Psi (neither is x1x¯2x¯3x_{1}\bar{x}_{2}\bar{x}_{3}). For example, x1x¯2x¯3y1y2y¯3x_{1}\bar{x}_{2}\bar{x}_{3}y_{1}y_{2}\bar{y}_{3} does not imply ΔbΨ\Delta_{b}\wedge\Psi since y1y2y¯3y_{1}y_{2}\bar{y}_{3} does not satisfy the exactly-one constraint ΨY\Psi_{Y}. This motivates Definition 1 below and further results on handling exactly-one constraints, which we introduce after some notational conventions.

In what follows, we use Δ\Delta/τ{\tau} to denote multi-valued expressions/terms, and Γ\Gamma/ρ{\rho} to denote Boolean expressions/terms. We also use Δb\Delta_{b} and τb{\tau}_{b} to denote the Boolean encodings of Δ\Delta and τ{\tau}. A completion of a term is a complete variable instantiation that is consistent with the term. We use α\alpha to denote completions. Finally, we use Ψ\Psi to denote the conjunction of all exactly-one constraints.

Definition 1

We define ρΨΓ{\rho}\models_{\Psi}\Gamma iff αΓ\alpha\models\Gamma for all completions α\alpha of Boolean term ρ{\rho} that are consistent with constraint Ψ\Psi.

Note that ρΓ{\rho}\models\Gamma implies ρΨΓ{\rho}\models_{\Psi}\Gamma but the converse is not true.

Proposition 2

ρΨΓ{\rho}\models_{\Psi}\Gamma iff ρ(ΨΓ).{\rho}\models(\Psi\Rightarrow\Gamma).

We now show how one-hot encodings can be used for computing prime implicants, particularly, how exactly-one constraints should be integrated.

Proposition 3

If τ{\tau} is a term, then τΔ{\tau}\models\Delta iff τb(ΨΔb).{\tau}_{b}\models(\Psi\Rightarrow\Delta_{b}).

The proof is based on two lemmas that hold by construction and that use the notion of full encoding of an instance. Consider ternary variables XX and YY. For instance τ:X=x1Y=y1{\tau}:{X\!\!=\!x_{1}}\wedge{Y\!\!=\!y_{1}} the full encoding is ρ:x1x¯2x¯3y1y¯2y¯3{\rho}:x_{1}\bar{x}_{2}\bar{x}_{3}y_{1}\bar{y}_{2}\bar{y}_{3} (x1x_{1} and y1y_{1} are included). Note that ρΨ=ρ{\rho}\wedge\Psi={\rho} since ρ{\rho} is guaranteed to satisfy constraints Ψ\Psi.

Lemma 1

If τ{\tau} is an instance and ρ{\rho} is its full encoding, then τΔ{\tau}\models\Delta iff ρΔb{\rho}\models\Delta_{b}.

Lemma 2

For term τ{\tau}, there is a one-to-one correspondence between the completions of τ{\tau} and the completions of τb{\tau}_{b} that are consistent with Ψ\Psi.

Term τ:X=x1X=x2{\tau}:{X\!\!=\!x_{1}}\vee{X\!\!=\!x_{2}} has six completions: X=x1Y=y1{X\!\!=\!x_{1}}\wedge{Y\!\!=\!y_{1}}, X=x2Y=y1{X\!\!=\!x_{2}}\wedge{Y\!\!=\!y_{1}}, …, X=x2Y=y3{X\!\!=\!x_{2}}\wedge{Y\!\!=\!y_{3}}. Its Boolean encoding τb:x¯3{\tau}_{b}:\bar{x}_{3} also has six completions that are consistent with Ψ\Psi: x1x¯2x¯3y1y¯2y3¯x_{1}\bar{x}_{2}\bar{x}_{3}y_{1}\bar{y}_{2}\bar{y_{3}}, x¯1x2x¯3y1y¯2y3¯\bar{x}_{1}x_{2}\bar{x}_{3}y_{1}\bar{y}_{2}\bar{y_{3}}, …, x¯1x2x¯3y¯1y¯2y3\bar{x}_{1}x_{2}\bar{x}_{3}\bar{y}_{1}\bar{y}_{2}y_{3}. Each of these completions α\alpha is guaranteed to satisfy constraints Ψ\Psi leading to αΨ=α\alpha\wedge\Psi=\alpha. Next, we relate the prime implicants of multi-valued expressions and their encodings.

Proposition 4

Consider a multi-valued expression Δ\Delta and its Boolean encoding Δb\Delta_{b}. If τ{\tau} is a prime implicant of Δ\Delta, then τb{\tau}_{b} is a negative term, consistent with Ψ\Psi and a prime implicant of ΨΔb\Psi\Rightarrow\Delta_{b}. If ρ{\rho} is a prime implicant of ΨΔb\Psi\Rightarrow\Delta_{b}, negative and consistent with Ψ\Psi, then ρ{\rho} encodes a prime implicant of Δ\Delta.

This proposition suggests the following procedure for computing multi-valued prime implicants from Boolean prime implicants. Given a multi-valued expression Δ\Delta, we encode each literal in Δ\Delta using its negative Boolean term, leading to the Boolean expression Δb\Delta_{b}. We then construct the exactly-one constraints Ψ\Psi and compute prime implicants of ΨΔb\Psi\Rightarrow\Delta_{b}, keeping those that are negative and consistent with constraints Ψ\Psi.333It is straightforward to augment the algorithm of [25] so that it only enumerates such prime implicants, by blocking the appropriate branches. Those Boolean prime implicants correspond precisely to the multi-valued prime implicants of Δ\Delta.444Note that when computing PI-explanations, we are interested only in prime implicants that are consistent with a given instance. Any negative prime implicant which is consistent with an instance must also be consistent with constraints Ψ\Psi. The only way a negative Boolean term ρ{\rho} can violate constraints Ψ\Psi is by setting all Boolean variables of some multi-valued variable to false. However, every instance α\alpha will set one of these Boolean variables to true so ρ{\rho} cannot be consistent with α\alpha.

The only system we are aware of that computes prime implicants of decision tree encodings (and forests) is Xplainer [9]. This system bypasses the encoding complications we alluded to earlier as it computes prime implicants in a specific manner [6, 7]. In particular, it encodes a multi-valued expression into a Boolean expression using the classical one-hot encoding. But rather than computing prime implicants of the Boolean encoding directly (which would lead to incorrect results), it reduces the problem of computing prime implicants of a multi-valued expression into one that requires only consistency testing of the Boolean encoding, which can be done using repeated calls to a SAT solver. The classical one-hot encoding is sound and complete for this purpose. Our treatment, however, is meant to be independent of the specific algorithm used to compute prime implicants. It would be needed, for example, when compiling the encoding into a tractable circuit and then computing prime implicants as done in [25, 5].

4.4 Encoding Decision Trees and Random Forests

Consider a decision tree, such as the one depicted in Figure 1. Each internal node in the tree represents a decision, which is either true or false. Each leaf is annotated with the predicted label. We can thus view a decision tree as a function whose inputs are all of the unique decisions that can be made in the tree, and whose output is the resulting label. Each leaf of the decision tree represents a simple term over the decisions made on the path to reach it, found by conjoining the appropriate literals. The Boolean function representing a particular class can then be found by simply disjoining the paths for all leaves of that class. That is, this Boolean function outputs true for all inputs that result in the corresponding class label, and false otherwise. We can also obtain this function for an ensemble of decision trees, such as a random forest. We first obtain the Boolean functions of each individual decision tree, and then aggregate them appropriately. For a random forest, we can use a simple majority gate whose inputs are the outputs of each decision tree; see also [1]. Finally, once we have the Boolean function of a classifier, we could apply a SAT or SMT solver to analyze it as proposed by [10, 16, 7]. We could also compile it into a tractable representation, such as an Ordered Binary Decision Diagram (OBDD), and then analyze it as proposed by [25, 24, 26, 23]. In the latter case, a representation such as an OBDD allows us to perform certain queries and transformation on a Boolean function efficiently, which facilitates the explanation and formal verification of the underlying machine learning classifier, as also shown more generally in [1].

5 Conclusion

We considered the encoding of input-output behavior of decision trees and random forests using Boolean expressions. Our focus has been on the suitability of encodings for computing prime implicants, which have recently played a central role in explaining the decisions of machine learning classifiers. Our findings have identified a particular encoding that is suitable for this purpose. Our encoding is based on a classical encoding that has been employed for the task of satisfiability but that can lead to incorrect results when computing prime implicants, which further emphasizes the merit of the investigation we conducted in this paper.

Ack. This work has been partially supported by grants from NSF IIS-1910317, ONR N00014-18-1-2561, DARPA N66001-17-2-4032 and a gift from JP Morgan.

References

  • [1] Audemard, G., Koriche, F., Marquis, P.: On tractable XAI queries based on compiled representations. In: Proc. of KR’20 (2020), to appear
  • [2] Bessiere, C., Hebrard, E., O’Sullivan, B.: Minimising decision tree size as combinatorial optimisation. In: CP. Lecture Notes in Computer Science, vol. 5732, pp. 173–187. Springer (2009)
  • [3] Choi, A., Shi, W., Shih, A., Darwiche, A.: Compiling neural networks into tractable Boolean circuits. In: AAAI Spring Symposium on Verification of Neural Networks (VNN) (2019)
  • [4] Crama, Y., Hammer, P.L.: Boolean Functions - Theory, Algorithms, and Applications, Encyclopedia of mathematics and its applications, vol. 142. Cambridge University Press (2011)
  • [5] Darwiche, A., Hirth, A.: On the reasons behind decisions. In: Proceedings of the 24th European Conference on Artificial Intelligence (ECAI) (2020)
  • [6] Ignatiev, A., Morgado, A., Marques-Silva, J.: Propositional abduction with implicit hitting sets. In: Proceedings of the 22nd European Conference on Artificial Intelligence (ECAI). pp. 1327–1335 (2016)
  • [7] Ignatiev, A., Narodytska, N., Marques-Silva, J.: Abduction-based explanations for machine learning models. In: Proceedings of the Thirty-Third Conference on Artificial Intelligence (AAAI). pp. 1511–1519 (2019)
  • [8] Ignatiev, A., Narodytska, N., Marques-Silva, J.: On relating explanations and adversarial examples. In: Advances in Neural Information Processing Systems 32 (NeurIPS). pp. 15857–15867 (2019)
  • [9] Ignatiev, A., Narodytska, N., Marques-Silva, J.: On validating, repairing and refining heuristic ML explanations. CoRR abs/1907.02509 (2019)
  • [10] Katz, G., Barrett, C.W., Dill, D.L., Julian, K., Kochenderfer, M.J.: Reluplex: An efficient SMT solver for verifying deep neural networks. In: Computer Aided Verification CAV. pp. 97–117 (2017)
  • [11] de Kleer, J.: A comparison of ATMS and CSP techniques. In: IJCAI. pp. 290–296. Morgan Kaufmann (1989)
  • [12] Leofante, F., Narodytska, N., Pulina, L., Tacchella, A.: Automated verification of neural networks: Advances, challenges and perspectives. CoRR abs/1805.09938 (2018)
  • [13] McCluskey, E.J.: Minimization of boolean functions. The Bell System Technical Journal 35(6), 1417–1444 (Nov 1956)
  • [14] Miller, D.M., Thornton, M.A.: Multiple Valued Logic: Concepts and Representations, Synthesis lectures on digital circuits and systems, vol. 12. Morgan & Claypool Publishers (2008)
  • [15] Narodytska, N., Ignatiev, A., Pereira, F., Marques-Silva, J.: Learning optimal decision trees with SAT. In: Lang, J. (ed.) Proceedings of the Twenty-Seventh International Joint Conference on Artificial Intelligence (IJCAI). pp. 1362–1368 (2018)
  • [16] Narodytska, N., Kasiviswanathan, S.P., Ryzhyk, L., Sagiv, M., Walsh, T.: Verifying properties of binarized deep neural networks. In: Proceedings of the Thirty-Second AAAI Conference on Artificial Intelligence (AAAI) (2018)
  • [17] Quine, W.V.: The problem of simplifying truth functions. The American Mathematical Monthly 59(8), 521–531 (1952)
  • [18] Quine, W.V.: On cores and prime implicants of truth functions. The American Mathematical Monthly 66(9), 755–760 (1959)
  • [19] Ramesh, A., Murray, N.V.: Computing prime implicants/implicates for regular logics. In: Proceedings of the 24th IEEE International Symposium on Multiple-Valued Logic (ISMVL). pp. 115–123 (1994)
  • [20] Renooij, S.: Same-decision probability: Threshold robustness and application to explanation. In: Studeny, M., Kratochvil, V. (eds.) Proceedings of the International Conference on Probabilistic Graphical Models (PGM). Proceedings of Machine Learning Research, vol. 72, pp. 368–379. PMLR (2018)
  • [21] Ribeiro, M.T., Singh, S., Guestrin, C.: Anchors: High-precision model-agnostic explanations. In: Proceedings of the Thirty-Second AAAI Conference on Artificial Intelligence (AAAI) (2018)
  • [22] Ribeiro, M.T., Singh, S., Guestrin, C.: Anchors: High-precision model-agnostic explanations. In: AAAI. pp. 1527–1535. AAAI Press (2018)
  • [23] Shi, W., Shih, A., Darwiche, A., Choi, A.: On tractable representations of binary neural networks. In: Proc. of KR’20 (2020), to appear
  • [24] Shih, A., Choi, A., Darwiche, A.: Formal verification of bayesian network classifiers. In: PGM. Proceedings of Machine Learning Research, vol. 72, pp. 427–438. PMLR (2018)
  • [25] Shih, A., Choi, A., Darwiche, A.: A symbolic approach to explaining bayesian network classifiers. In: IJCAI. pp. 5103–5111. ijcai.org (2018)
  • [26] Shih, A., Darwiche, A., Choi, A.: Verifying binarized neural networks by angluin-style learning. In: SAT (2019)
  • [27] Walsh, T.: SAT v CSP. In: CP. Lecture Notes in Computer Science, vol. 1894, pp. 441–456. Springer (2000)

Appendix 0.A Proofs

Proof (of Proposition 1)

For multi-valued term τ{\tau}, the Boolean encoding τb{\tau}_{b} is a negative term and consistent with Ψ\Psi by construction. Suppose now that ρ{\rho} is a negative Boolean term that is consistent with Ψ\Psi. If ρ{\rho} mentions a Boolean variable of multi-valued variable XX, then ρ{\rho} cannot mention all Boolean variables of XX, otherwise ρ{\rho} will be ruling out all possible values of XX and hence inconsistent with Ψ\Psi. Hence, ρ{\rho} encodes a literal over variable XX when ρ{\rho} mentions a Boolean variable for XX. More generally, ρ{\rho} encodes a term over multi-valued variables whose Boolean variables are mentioned in ρ{\rho}. To prove the second part of the theorem, consider literals 1{\ell}_{1} and 2{\ell}_{2}, which specify values S1S_{1} and S2S_{2} for variable XX. The two literals are equivalent iff S1=S2S_{1}=S_{2} iff xiS1x¯i\bigwedge_{x_{i}\not\in S_{1}}\bar{x}_{i} and xiS2x¯i\bigwedge_{x_{i}\not\in S_{2}}\bar{x}_{i} are equivalent. Moreover, 12{\ell}_{1}\models{\ell}_{2} iff S1S2S_{1}\subseteq S_{2} iff xiS1x¯ixiS2x¯i\bigwedge_{x_{i}\not\in S_{1}}\bar{x}_{i}\models\bigwedge_{x_{i}\not\in S_{2}}\bar{x}_{i}. Equivalence and subsumption relations are then preserved on literals, and on terms as well.

Proof (of Proposition 2)

(\Rightarrow) Suppose ρΨΓ{\rho}\models_{\Psi}\Gamma and let α{\alpha} be a completion of ρ{\rho}. If α{\alpha} is consistent with Ψ\Psi, then αΓ{\alpha}\models\Gamma by Definition 1. If α{\alpha} is not consistent with Ψ\Psi, then α¬Ψ{\alpha}\models\neg\Psi. Hence, ρ¬ΨΓ.{\rho}\models\neg\Psi\vee\Gamma. (\Leftarrow) Suppose ρ¬ΨΓ{\rho}\models\neg\Psi\vee\Gamma and let α{\alpha} be a completion of ρ{\rho} that is consistent with Ψ\Psi. Then α¬ΨΓ{\alpha}\models\neg\Psi\vee\Gamma and, hence, αΨΓ{\alpha}\wedge\Psi\models\Gamma and αΓ{\alpha}\models\Gamma. We then have ρΨΓ{\rho}\models_{\Psi}\Gamma by Definition 1.

Proof (of Proposition 3)

(\Rightarrow) Suppose τΔ.\tau\models\Delta. Then αΔ\alpha\models\Delta for all completions α\alpha of τ{\tau}. By Lemmas 1 and 2, αbΔb\alpha_{b}\models\Delta_{b} for all completions αb\alpha_{b} of τb{\tau}_{b} that are consistent with Ψ\Psi. Hence τb¬ΨΔb.\tau_{b}\models\neg\Psi\vee\Delta_{b}. (\Leftarrow) Suppose τb¬ΨΔb\tau_{b}\models\neg\Psi\vee\Delta_{b} and let αb\alpha_{b} be a completion of τb{\tau}_{b} (αb¬ΨΔb\alpha_{b}\models\neg\Psi\vee\Delta_{b}). For each αb\alpha_{b} consistent with Ψ\Psi, we have αbΨ\alpha_{b}\models\Psi and hence αbΔb.\alpha_{b}\models\Delta_{b}. By Lemmas 1 and 2, the completions α\alpha of τ{\tau} correspond to these αb\alpha_{b} (consistent with Ψ\Psi), leading to αΔ\alpha\models\Delta and hence τΔ{\tau}\models\Delta.

Proof (of Proposition 4)

(\Rightarrow) Suppose τ{\tau} is a prime implicant of Δ\Delta. Then τΔ{\tau}\models\Delta. Moreover, τb(ΨΔb){\tau}_{b}\ \models(\Psi\Rightarrow\Delta_{b}) by Proposition 3 so τb{\tau}_{b} is an implicant of ΨΔb\Psi\Rightarrow\Delta_{b} (τb{\tau}_{b} is negative and consistent with Ψ\Psi by construction). Suppose τb{\tau}_{b} is not a prime implicant of ΨΔb\Psi\Rightarrow\Delta_{b}. Then ρ(ΨΔb){\rho}\models(\Psi\Rightarrow\Delta_{b}) for a strict subset ρ{\rho} of τb{\tau}_{b}, which must be consistent with Ψ\Psi since τbρ{\tau}_{b}\supset{\rho} is consistent with Ψ\Psi. Hence, ρ{\rho} encodes a term τ{\tau}^{\star} that is strictly weaker than term τ{\tau} by Proposition 1. Moreover, τΔ{\tau}^{\star}\models\Delta by Proposition 3 so τ{\tau} is not a prime implicant of Δ\Delta, which is a contradiction. Therefore, τb{\tau}_{b} is a prime implicant of ΨΔb\Psi\Rightarrow\Delta_{b}. (\Leftarrow) Suppose ρ{\rho} is a prime implicant of ΨΔb\Psi\Rightarrow\Delta_{b}, negative and consistent with Ψ\Psi. Then ρ{\rho} encodes a term τ{\tau} by Proposition 1. Moreover, ρ=τbΨΔb{\rho}={\tau}_{b}\models\Psi\Rightarrow\Delta_{b} so τΔ{\tau}\models\Delta by Proposition 3. Hence, τ{\tau} is an implicant of Δ\Delta. Suppose now that τΔ{\tau}^{\star}\models\Delta for some term τ{\tau}^{\star} that is strictly weaker than term τ{\tau}. Then τbΨΔb{\tau}^{\star}_{b}\models\Psi\Rightarrow\Delta_{b} by Proposition 3. This means ρ{\rho} is not a prime implicant of ΨΔb\Psi\Rightarrow\Delta_{b} since τbτb=ρ{\tau}^{\star}_{b}\subset{\tau}_{b}={\rho} by Proposition 1, which is a contradiction. Hence, the term τ{\tau} encoded by ρ{\rho} is a prime implicant of Δ\Delta.