Year: 2021

Abstract:
The goal of combining the robustness of neural networks and the expressivity of symbolic methods has rekindled the interest in Neuro-Symbolic AI. Recent advancements in Neuro-Symbolic AI often consider specifically-tailored architectures consisting of disjoint neural and symbolic components, and thus do not exhibit desired gains that can be achieved by integrating them into a unifying framework. We introduce SLASH – a novel deep probabilistic programming language (DPPL). At its core, SLASH consists of Neural-Probabilistic Predicates (NPPs) and logical programs which are united via answer set programming. The probability estimates resulting from NPPs act as the binding element between the logical program and raw input data, thereby allowing SLASH to answer task-dependent logical queries. This allows SLASH to elegantly integrate the symbolic and neural components in a unified framework. We evaluate SLASH on the benchmark data of MNIST addition as well as novel tasks for DPPLs such as missing data prediction and set prediction with state-of-the-art performance, thereby showing the effectiveness and generality of our method.

heading: 1 INTRODUCTION
text: In recent years, Neuro-Symbolic AI approaches to learning (Hudson & Manning, 2019; d’Avila Garcez et al., 2019; Jiang & Ahn, 2020; d’Avila Garcez & Lamb, 2020), which integrates low-level perception with high-level reasoning by combining data-driven neural modules with logic-based symbolic modules, has gained traction. This combination of sub-symbolic and symbolic systems has been shown to have several advantages for various tasks such as visual question answering and reasoning (Yi et al., 2018), concept learning (Mao et al., 2019) and improved properties for explainable and revisable models (Ciravegna et al., 2020; Stammer et al., 2021).
Rather than designing specifically tailored Neuro-Symbolic architectures, where often the neural and symbolic modules are disjoint and trained independently (Yi et al., 2018; Mao et al., 2019; Stammer et al., 2021), deep probabilistic programming languages (DPPLs) provide an exciting alternative (Bingham et al., 2019; Tran et al., 2017; Manhaeve et al., 2018; Yang et al., 2020). Specifically, DPPLs integrate neural and symbolic modules via a unifying programming framework with probability estimates acting as the “glue” between separate modules allowing for reasoning over noisy, uncertain data and, importantly, joint training of the modules. Additionally, prior knowledge and biases in the form of logical rules can easily be added with DPPLs, rather than creating implicit architectural biases, thereby integrating neural networks into downstream logical reasoning tasks.
Object-centric deep learning has recently brought forth several exciting avenues of research by introducing inductive biases to neural networks to extract objects from visual scenes in an unsupervised manner (Zhang et al., 2019; Burgess et al., 2019; Engelcke et al., 2020; Greff et al., 2019; Lin et al., 2020; Locatello et al., 2020; Jiang & Ahn, 2020). We refer to Greff et al. (2020) for a detailed overview. A motivation for this specific line of investigation, which notably has been around for a longer period of time (Fodor & Pylyshyn, 1988; Marcus, 2019), is that objects occur as natural building blocks in human perception and possess advantageous properties for many cognitive tasks, such as scene understanding and reasoning. With a DPPL, these advancements can be improved by integrating the previously mentioned components into the DPPL’s programming framework and further adding constraints about objects and their properties in form of logical statements e.g. about color singularity, rather than implicitly enforcing this via one hot encodings.
We propose SLASH – a novel DPPL that, similar to the punctuation symbol, can be used to efficiently combine several paradigms into one. Specifically, SLASH represents a scalable programming language that seamlessly integrates probabilistic logical programming with neural representations and tractable probabilistic estimations. Fig. 1 shows an example instantiation of SLASH, termed SLASH Attention, for object-centric set prediction. SLASH consists of several key building blocks. Firstly, it makes use of Neural-Probabilistic Predicates (NPPs) for probability estimation. NPPs consist of neural and/or probabilistic circuit (PC) modules and act as a unifying term, encompassing the neural predicates of DeepProbLog and NeurASP, as well as purely probabilistic predicates. In this work, we introduce a much more powerful “flavor” of NPPs that consist jointly of neural and PC modules, taking advantage of the power of neural computations together with true density estimation of PCs. Depending on the underlying task one can thus ask a range of queries to the NPP, e.g. sample an unknown, desired variable, but also query for conditional class probabilities. Example NPPs consisting of a slot attention encoder and several PCs are depicted in Fig. 1 for the task of set prediction. The slot encoder is shared across all NPPs, whereas the PC of each NPP models a separate category of attributes. In this way, each NPP models the joint distribution over slot encodings and object attribute values, such as the color of an object. By querying the NPP, one can obtain task-related probability estimations, such as the conditional attribute probability.
The second component of SLASH is the logical program, which consists of a set of facts and logical statements defining the state of the world of the underlying task. For example, one can define the rules for when an object possesses a specific set of attributes (cf. Fig. 1). Thirdly, an ASP module is used to combine the first two components. Given a logical query about the input data, the logical program and the probability estimates obtained from the NPP(s), the ASP module produces a probability estimate about the truth value of the query, stating, e.g., how likely it is for a specific object in an image to be a large, dark red triangle. In contrast to query evaluation in Prolog (Colmerauer & Roussel, 1993; Clocksin & Mellish, 1981) which may lead to an infinite loop, many modern answer set solvers use Conflict-Driven-Clause-Learning (CDPL) which, in principle, always terminates.
Training in SLASH is performed efficiently in a batch-wise and end-to-end fashion, by integrating the parameters of all modules, neural and probabilistic, into a single loss term. SLASH thus allows a simple, fast and effective integration of sub-symbolic and symbolic computations. In our experiments, we investigate the advantages of SLASH in comparison to SOTA DPPLs on the benchmark task of MNIST-Addition (Manhaeve et al., 2018). We hereby show SLASH’s increased scalability regarding
computation time, as well as SLASH’s ability to handle incomplete data via true probabilistic density modelling. Next, we show that SLASH Attention provides superior results for set prediction in terms of accuracy and generalization abilities compared to a baseline slot attention encoder. With our experiments, we thus show that SLASH is a realization of “one system – two approaches” (Bengio, 2019), that can successfully be used for performing various tasks and on a variety of data types.
We make the following contributions: (1) We introduce neural-probabilistic predicates, efficiently integrating answer set programming with probabilistic inference via our novel DPPL, SLASH. (2) We successfully train neural, probabilistic and logic modules within SLASH for complex data structures end-to-end via a simple, single loss term. (3) We show that SLASH provides various advantages across a variety of tasks and data sets compared to state-of-the-art DPPLs and neural models.

heading: 2 NEURO-SYMBOLIC LOGIC PROGRAMMING
text: Neuro-Symbolic AI can be divided into two lines of research, depending on the starting point. Both, however, have the same final goal: to combine low-level perception with logical constraints and reasoning.
A key motivation of Neuro-Symbolic AI (d’Avila Garcez et al., 2009; Mao et al., 2019; Hudson & Manning, 2019; d’Avila Garcez et al., 2019; Jiang & Ahn, 2020; d’Avila Garcez & Lamb, 2020) is to combine the advantages of symbolic and neural representations into a joint system. This is often done in a hybrid approach where a neural network acts as a perception module that interfaces with a symbolic reasoning system, e.g. (Mao et al., 2019; Yi et al., 2018). The goal of such an approach is to mitigate the issues of one type of representation by the other, e.g. using the power of symbolic reasoning systems to handle the generalizability issues of neural networks and on the other hand handle the difficulty of noisy data for symbolic systems via neural networks. Recent work has also shown the advantage of Neuro-Symbolic approaches for explaining and revising incorrect decisions (Ciravegna et al., 2020; Stammer et al., 2021). Many of these previous works, however, train the sub-symbolic and symbolic modules separately.
Deep Probabilistic Programming Languages (DPPLs) are programming languages that combine deep neural networks with probabilistic models and allow a user to express a probabilistic model via a logical program. Similar to Neuro-Symbolic architectures, DPPLs thereby unite the advantages of different paradigms. DPPLs are related to earlier works such as Markov Logic Networks (MLNs) (Richardson & Domingos, 2006). Thereby, the binding link is the Weighted Model Counting (WMC) introduced in LPMLN (Lee & Wang, 2016). Several DPPLs have been proposed by now, among which are Pyro (Bingham et al., 2019), Edward (Tran et al., 2017), DeepProbLog (Manhaeve et al., 2018), and NeurASP (Yang et al., 2020).
To resolve the scalability issues of DeepProbLog, which use Sentential Decision Diagrams (SDDs) (Darwiche, 2011) as the underlying data structure to evaluate queries, NeurASP (Yang et al., 2020), offers a solution by utilizing Answer Set Programming (ASP) (Dimopoulos et al., 1997; Soininen & Niemelä, 1999; Marek & Truszczynski, 1999; Calimeri et al., 2020). In this way, NeurASP changes the paradigm from query evaluation to model generation, i.e. instead of constructing an SDD or similar knowledge representation system, NeurASP generates a set of all possible solutions (one model per solution) and estimates the probability for the truth value of each of these solutions. Of those DPPLs that handle learning in a relational, probabilistic setting and in an end-to-end fashion, all of these are limited to estimating only conditional class probabilities.

heading: 3 THE SLASH FRAMEWORK
text: In this section, we introduce our novel DPPL, SLASH. Before we dive into the details of this, it is necessary to first introduce Neural-Probabilistic Predicates, for which we require an understanding of Probabilistic Circuits. Finally, we will present the learning paradigm of SLASH.
The term probabilistic circuit (PC) (Choi et al., 2020) represents a unifying framework that encompasses all computational graphs which encode probability distributions and guarantee tractable probabilistic modelling. These include Sum-Product Networks (SPNs) (Poon & Domingos, 2011) which are deep mixture models represented via a rooted directed acyclic graphs with a recursively defined structure.

heading: 3.1 NEURAL-PROBABILISTIC PREDICATES
text: Previous DPPLs, DeepProbLog (Manhaeve et al., 2018) and NeurASP (Yang et al., 2020), introduced the Neural Predicate as an annotated-disjunction or as a propositional atom, respectively, to acquire conditional class probabilities, P (C|X), via the softmax function at the output of an arbitrary DNN. As mentioned in the introduction, this approach has certain limitations concerning inference capabilities. To resolve this issue, we introduce Neural-Probabilisitic Predicates (NPPs).
Formally, we denote with npp (h(x), [v1, . . . , vn]) (1)
a Neural-Probabilistic Predicate h. Thereby, (i) npp is a reserved word to label an NPP, (ii) h a symbolic name of either a PC, NN or a joint of a PC and NN (cf. Fig. 2a), e.g., color_attr is the name of an NPP of Fig. 2b. Additionally, (iii) x denotes a “term” and (iv) v1, . . . , vn are placeholders for each of the n possible outcomes of h. For example, the placeholders for color_attr are the color attributes of an object (Red, Blue, Green, etc.). An NPP abbreviates an arithmetic literal of the form c = v with c ∈ {h(x)} and v ∈ {v1, . . . , vn}. Furthermore, we denote with Πnpp a set of NPPs of the form stated in (Eq. 1) and rnpp the set of all rules c = v of one NPP, which denotes the possible outcomes, obtained from an NPP in Πnpp, e.g. rcolor_attr = {c = Red, c = Blue, c = Green, ...} for the example depicted in Fig. 2b. Rules of the form npp (h(x), [v1, . . . , vn]) ← Body are used as an abbreviation for application to multiple entities, e.g. multiple slots for the task of set prediction (cf. Fig. 2b). Hereby, Body of the rule is identified by > (tautology, true) or ⊥ (contradiction, false) during grounding. Rules of the form Head← Body with rnpp appearing in Head are prohibited for Πnpp. In this work, we largely make use of NPPs that contain probabilistic circuits (specifically SPNs) which allow for tractable density estimation and modelling of joint probabilities. In this way, it is possible to answer a much richer set of probabilistic queries, i.e. P (X,C), P (X|C) and P (C|X). In addition to this, we introduce the arguably more interesting type of NPP that combines a neural module with a PC. Hereby, the neural module learns to map the raw input data into an optimal latent representation, e.g. object-based slot representations. The PC, in turn, learns to model the joint distribution of these latent variables and produces the final probability estimates. This type of NPP nicely combines the representational power of neural networks with the advantages of PCs in probability estimation and query flexibility.
For making the different probabilistic queries distinguishable in a SLASH program, we introduce the following notation. We denote a given variable with + and the query variable with −. E.g., within the running example of set prediction (cf. Fig. 1 and 2b), with the query color_attr(+X,−C) one is asking for P (C|X). Similarly, with color_attr(−X,+C) one is asking for P (X|C) and, finally, with color_attr(−X,−C) for P (X,C).
To summarize, an NPP can consist of neural and/or probabilistic modules and produces querydependent probability estimates. Due to the flexibility of its definition, the term NPP contains the predicates of previous works (Manhaeve et al., 2018; Yang et al., 2020), but also more interesting predicates discussed above. The specific “flavor” of an NPP should be chosen depending on what type of probability estimation is required (cf. Fig 2a). Lastly, NPPs have the unified loss function of the negative log-likelihood:
LNPP := − logLH(x, x̂) = n∑ i=1 LH(xi, x̂i) = − n∑ i=1 xi · log(P (X,C)ξ (xi)) = − n∑ i=1 log(P (X,C) ξ )
(2) whereby we are assuming the data to be i.i.d., ground truth xi to be the all-ones vector, ξ to be the parameters of the NPP and P (X,C)ξ are the predictions x̂i obtained from the PC encoded in the NPP.

heading: 3.2 THE SLASH LANGUAGE AND SEMANTICS
text: Fig. 1 presents an illustration of SLASH, exemplified for the task of set prediction, with all of its key components. Having introduced the NPPs previously, which produce probability estimates, we now continue in the pipeline on how to use these probability estimates for answering logical queries. We begin by formally defining a SLASH program.
Definition 1. A SLASH program Π is the union of Πasp, Πnpp. Therewith, Πasp is the set of propositional rules (standard rules from ASP-Core-2 (Calimeri et al., 2020)), and Πnpp is a set of Neural-Probabilistic Predicates of the form stated in Eq. 1.
Fig. 2b depicts a minimal SLASH program for the task of set prediction, exemplifying a set of propositional rules and neural predicates. Similar to NeurASP, SLASH requires ASP and as such adopts its syntax to most part. We therefore now address integrating our NPPs into an ASP compatible form to obtain the success probability for the logical query given all possible solutions. Thus, we define SLASH’s semantics. For SLASH to translate the program Π to the ASP-solver’s compatible form, the rules (Eq. 1) will be rewritten to the set of rules:
1{h(x) = v1; . . . ;h(x) = vn}1 (3)
The ASP-solver should understand this as “Pick exactly one rule from the set”. After the translation is done, we can ask an ASP-solver for the solutions for Π. We denote a set of ASP constraints in the form← Body, as queries Q (annotation). and each of the solutions with respect to Q as a potential solution, I , (referred to as stable model in ASP). With I|rnpp we denote the projection of the I onto rnpp, Num(I|rnpp ,Π) – the number of the possible solutions of the program Π agreeing with I|rnpp on rnpp. Because we aim to calculate the success probability of the query Q, we formalize the probability of a potential solution I beforehand.
Definition 2. We specify the probability of the potential solution, I , for the program Π as the product of the probabilities of all atoms c = v in I|rnpp divided by the number of potential solutions of Π agreeing with I|rnpp on rnpp:
PΠ(I) =
{∏ c=v∈I|rnpp PΠ(c=v)
Num(I|rnpp ,Π) , if I is a potential solution of Π, 0, otherwise.
(4)
Therefore, the probability of a query can be defined as follows.
Definition 3. The probability of the query Q given the set of possible solutions I is defined as PΠ(Q) := ∑ I|=Q PΠ(I). (5)
Thereby, I |= Q reads as “I satisfies Q”. The probability of the set of queries Q = {Q1, . . . , Ql} is defined as the product of the probability of each. I.e.
PΠ (Q) := ∏ Qi∈Q PΠ(Qi) = ∏ Qi∈Q ∑ I|=Q PΠ(I). (6)

heading: 3.3 PARAMETER LEARNING IN SLASH
text: We denote with Π(θ) the SLASH program under consideration, thereby θ is the set of the parameters associated with Π. Further, making the i.i.d. assumption of the query set Q, we follow Manhaeve et al. (2018) and Skryagin et al. (2020), and use the learning from entailment setting. That is, the training examples are logical queries that are known to be true in the SLASH program Π(θ). The goal is now to learn the parameters θ of the SLASH program Π(θ) so that the observed queries are most likely.
To this end, we employ the negative log-likelihood and the cross-entropy of the observed queries PΠ(θ)(Qi) and their predicted probability value P (XQ,C)(xQi), assuming the NPPs are fixed: LENT :=
−logLH ( log(PΠ(θ)(Q)), P (XQ,C)(xQ) ) = − m∑ j=1 log(PΠ(θ)(Qij))·log ( P (XQ,C)(xQij ) ) . (7)
This loss function aims at maximizing the estimated success probability. We remark that the defined loss function is true regardless of the NPP’s form (NN with Softmax, PC or PC jointly with NN). The only difference will be the second term, i.e. P (C|XQ)(xQ) or P (XQ|C)(xQ)) depending on the NPP and task. Furthermore, we assume that for the set of queries Q holds
PΠ(θ)(Q) > 0 ∀ Q ∈ Q.
In accordance with the semantics, we seek to reward the right solutions v = c and penalize wrong ones v 6= c. Referring to the probabilities in rnpp (the set of logical rules denoting NPPs, see Def. 2) as p, one can compute their gradients w.r.t. θ via backpropagation as∑
Q∈Q
∂ log ( PΠ(θ)(Q) ) ∂θ = ∑ Q∈Q ∂ log ( PΠ(θ)(Q) ) ∂p × ∂p ∂θ . (8)
The term ∂p∂θ can now be computed as usual via backward propagation through the NPPs (see Eq. 13 in the appendix for details). By letting p to be the label of the probability of an atom c = v in rnpp
and denoting PΠ(θ)(c = v), the term ∂ log(PΠ(θ)(Q)) ∂p follows from NeurASP (Yang et al., 2020) as
∂ log ( PΠ(θ)(Q) ) ∂p =
∑ I:I|=Q I|=c=v PΠ(θ)(I) PΠ(θ)(c=v) − ∑ I:I,v′|=Q I|=c=v′,v 6=v′ PΠ(θ)(I) PΠ(θ)(c=v′)
∑ I:I|=Q PΠ(θ)(I) . (9)
This is sensible. For instance, if a query to be true is not likely to be entailed, the gradient is positive. Putting everything together, the final loss function is
LSLASH = LNPP + LENT (10)
and we perform training using coordinate descent, i.e., we train the NPPs, the train the program with fixed NPPs, train the NPPs with the program fixed, and so on.
In hindsight, rather than requiring a novel loss function for each individual task and data set, with SLASH, it is possible to simply incorporate the specific requirements into the logic program. The training loss, however, remains the same. We refer to the Appendix A for further details, including the derivation of the total loss gradient.

heading: 4 EMPIRICAL RESULTS
text: The advantage of SLASH lies in the efficient integration of neural, probabilistic and symbolic computations. To emphasize this, we conduct a variety of experimental evaluations.
Experimental Details. We use two benchmark data sets, namely MNIST (LeCun et al., 1998b) for the task of MNIST-Addition and a variant of the ShapeWorld data set (Kuhnle & Copestake, 2017) for
object-centric set prediction. For all experiments we present the average and the standard deviation over five runs with different random seeds for parameter initialization.
For ShapeWorld experiments, we generate a data set we refer to as ShapeWorld4. Images of ShapeWorld4 contain between one and four objects, with each object consisting of four attributes: a color (red, blue, green, gray, brown, magenta, cyan or yellow), a shade (bright, or dark), a shape (circle, triangle or square) and a size (small or big). Thus, each object can be created from 84 different combinations of attributes. Fig. 1 depicts an example image.
We measure performance via classification accuracies in the MNIST-Addition task. In our ShapeWorld4 experiments, we present the average precision. We refer to appendix B for the SLASH programs and queries of each experiment, and appendix C for a detailed description of hyperparameters and further details.
Evaluation 1: SLASH outperforms SOTA DPPLs in MNIST-Addition. The task of MNISTAddition (Manhaeve et al., 2018) is to predict the sum of two MNIST digits, presented only as raw images. During test time, however, a model should classify the images directly. Thus, although a model does not receive explicit information about the depicted digits, it must learn to identify digits via indirect feedback on the sum prediction.
We compare the test accuracy after convergence between the three DPPLs: DeepProbLog (Manhaeve et al., 2018), NeurASP (Yang et al., 2020) and SLASH, using a probabilistic circuit (PC) or a deep neural network (DNN) as NPP. Notably, the DNN used in SLASH (DNN) is the LeNet5 model (LeCun et al., 1998a) of DeepProbLog and NeurASP. We note that when using the PC as NPP, we have also extracted conditional class probabilities P (C|X), by marginalizing the class variables C to acquire the normalization constant P (X) from the joint P (X,C), and calculating P (X|C). The results can be seen in Tab. 1a. We observe that training SLASH with a DNN NPP produces SOTA accuracies compared to DeepProbLog and NeurASP, confirming that SLASH’s batch-wise loss computation leads to improved performances. We further observe that the test accuracy of SLASH with a PC NPP is slightly below the other DPPLs, however we argue that this may be since a PC, in comparison to a DNN, is learning a true mixture density rather than just conditional probabilities. The advantages of doing so will be investigated in the next experiments. Note that, optimal architecture search for PCs, e.g. for computer vision, is an open research question.These evaluations show SLASH’s advantages on the benchmark MNIST-Addition task. Additional benefits will be made clear in the following experiments.
Evaluation 2: Handling Missing Data with SLASH. SLASH offers the advantage of its flexibility to use various kinds of NPPs. Thus, in comparison to previous DPPLs, one can easily integrate NPPs into SLASH that perform joint probability estimation. For this evaluation, we consider the task of MNIST-Addition with missing data. We trained SLASH (PC) and DeepProbLog with the MNIST-Addition task with images in which a percentage of pixels per image has been removed. It is important to mention here that whereas DeepProbLog handles the missing data simply as background pixels, SLASH (PC) specifically models the missing data as uncertain data by marginalizing the denoted pixels at inference time. We use DeepProbLog here representative of DPPLs without true density estimation.
The results can be seen in Tab. 1b for 50%, 80%, 90% and 97% missing pixels per image. We observe that at 50%, DeepProbLog and SLASH produce almost equal accuracies. With 80% percent missing pixels, there is a substantial difference in the ability of the two DPPLs to correctly classify images, with SLASH being very stable. By further increasing the percentage of missing pixels, this difference becomes even more substantial with SLASH still reaching a 82% test accuracy even when 97% of the pixels per image are missing, whereas DeepProbLog degrades to an average of 32% test accuracy. We further note that SLASH, in comparison to DeepProbLog, produces largely reduced standard deviations over runs.
Thus, by utilizing the power of true density estimation SLASH, with an appropriate NPP, can produce more robust results in comparison to other DPPLs. Further, we refer to Appendix D, which contains results of additional experiments where training is performed with the full MNIST data set whereas only the test set entails different rates of missing pixels.
Evaluation 3: Improved Concept Learning via SLASH. We show that SLASH can be very effective for the complex task of set prediction, which previous DPPLs have not tackled. We revert to the ShapeWorld4 data set for this setting. For set prediction, a model is trained to predict the discrete attributes of a set of objects in an image (cf. Fig. 1 for an example ShapeWorld4 image). The difficulty for the model lies therein that it must match an unordered set of corresponding attributes (with varying number of entities over samples) with its internal representations of the image.
The slot attention module introduced by Locatello et al. (2020) allows for an attractive object-centric approach to this task. Specifically, this module represents a pluggable, differentiable module that can be easily added to any architecture and, through a competitive softmax-based attention mechanism, can enforce the binding of specific parts of a latent representation into permutation-invariant, taskspecific vectors, called slots.
In our experiments, we wish to show that by adding logical constraints to the training setting, one can improve the overall performances and generalization properties of such a model. For this, we train SLASH with NPPs as depicted in Fig. 1 consisting of a shared slot encoder and separate PCs, each modelling the mixture of latent slot variables and the attributes of one category, e.g. color. For ShapeWorld4, we thereby have altogether four NPPs. SLASH is trained via queries of the kind exemplified in Fig. 7 in the Appendix. We refer to this configuration as SLASH Attention.
We compare SLASH Attention to a baseline slot attention encoder using an MLP and Hungarian loss for predicting the object properties from the slot encodings as in Locatello et al. (2020). The results of these experiments can be found in Fig. 3a (top). We observe that the average precision after convergence on the held-out test set with SLASH Attention is greatly improved to that of the baseline model. Additionally, in Fig. 3b we observe that SLASH Attention reaches the average precision value of the baseline model in much fewer number of epochs. Thus, we can summarize that adding logical knowledge in the training procedure via SLASH can greatly improve the capabilities of a neural module for set prediction.
Evaluation 4: Improved Compositional Generalization with SLASH. To test the hypothesis that SLASH Attention possesses improved generalization properties in comparison to the baseline model, we ran experiments on a variant of ShapeWorld4 similar to the CLEVR Compositional Generalization Test (CoGenT) (Johnson et al., 2017). The goal of CoGenT is to investigate a model’s ability to handle novel combinations of attributes that were not seen during training.
For this purpose, we established two conditions within a ShapeWorld4 CoGenT data set: Condition (A) – the training and test data set contains squares with the colors gray, blue, brown, or yellow, triangles with the colors red, green, magenta, or cyan and circles of all colors. Condition (B) – the training set is as in Condition (A). However, the test set contains squares with the colors red, green, magenta, or cyan, triangles with the colors gray, blue, brown, or yellow and circles of all colors. The goal is to investigate how well a model can generalize that, e.g., also squares can have the color red, although never having seen evidence for this during training.
The resulting average precision test scores are presented in Fig. 3a (bottom). We observe that, even though the SLASH Program used for this experiment was not explicitly written to handle composition generalization, SLASH Attention shows greatly improved generalization capabilities. This can be seen in the approx. 13% higher average precision scores on the Condition (B) test set in comparison to the baseline model. Importantly, this trend still holds even when subtracting the higher precision scores observed in Condition (A).
To summarize our findings from the experiments on set prediction: we observe that adding prior knowledge in the form of logical constraints via SLASH can greatly improve a neural module in terms of performance and generalizability. On a side note: training neural networks for novel tasks, often involves defining explicit loss functions, e.g. Hungarian loss for set prediction. In contrast with SLASH, no matter the choice of NPP and underlying task, the training loss remains the same. Task-related requirements simply need to be added as lines of code to the SLASH program. This additionally highlights SLASH’s versatility and flexibility.
Summary of all Empirical Results. All empirical results together demonstrate that the flexibility of SLASH is highly beneficial and can easily outperform state-of-the-art: one can freely combine what is required to solve the underlying task — (deep) neural networks, PCs, and logic. Particularly, the results indicate the potential of integrating PCs via SLASH into DPPLs.

heading: 5 CONCLUSION AND FUTURE WORK
text: We introduce SLASH, a novel DPPL that integrates neural computations with tractable probability estimates and logical statements. The key ingredient of SLASH to achieve this are Neural-Probabilistic Predicates (NPPs) that can be flexibly constructed out of neural and/or probabilistic circuit modules based on the data and underlying task. With these NPPs, one can produce task-specific probability estimates. The details and additional prior knowledge of a task are neatly encompassed within a SLASH program with only few lines of code. Finally, via Answer Set Programming and Weighted Model Counting, the logical SLASH program and probability estimates from the NPPs are combined to estimate the truth value of a task-specific query. Our experiments show the power and efficiency of SLASH, improving upon previous DPPLs in the benchmark MNIST-Addition task in terms of performance, efficiency and robustness. Importantly, by integrating a SOTA slot attention encoder into NPPs and adding few logical constraints, SLASH demonstrates improved performances and generalizability in comparison to the pure slot encoder for the task of object-centric set prediction; a setting no DPPL has tackled yet. This shows the great potential of DPPLs to elegantly combine logical reasoning with neural computations and uncertainty estimates.
Interesting avenues for future work include benchmarking SLASH on additional data types and tasks. One should explore unsupervised and weakly supervised learning using logic with SLASH and investigate how far logical constraints can help unsupervised object discovery. In direct alignment with our work, one should also investigate image generation via the beneficial feature of PCs to generate random samples. Actually, it should be possible to generate images that encapsulate logical knowledge bases. This is important to move from data-rich to knowledge-rich AI.
ETHICS STATEMENT
With our work, we have shown that one can add prior knowledge and logical constraints to the training of learning systems. We postulate that SLASH can therefore additionally be used to identify and remove biases or undesirable behavior, by adding constraints within the SLASH program. We observe that this feature, however, also has the potential danger to be used in the opposite way, e.g. explicitly adding bias and discriminatory factors to a system. To the best of our knowledge, our study does not raise any ethical, privacy or conflict of interest concerns.
REPRODUCIBILITY STATEMENT
An official, curated GitHub repository will be made public with the final version, containing the code of SLASH, as well as scripts to reproduce the experiments and generate data sets. In addition to this, architectural details and hyperparameters are included in the appendix. Preliminary code will be uploaded upon submission. Lastly, details on the evaluation metrics and relevant data sets are given in the main text as well as appendix.

heading: A APPENDIX A – DETAILS ON PARAMETER LEARNING
text: In the Appendix, we want to discuss details on parameter learning in SLASH. Since we use coordinate descent for training SLASH we present the derivative of each component of the loss function defined in equation 10 since while optimization, one component has to be kept fixed.
We start with the gradient of the NPP loss function LNPP i.e. the negative log-likelihood, defined in equation 2
∂
∂ξ LNPP =
∂ ∂xQi · ∂xQi ∂ξ LNPP = ∂xQi ∂ξ
( −
n∑ i=1 ∂ ∂xQi log ( P (XQ,C) ξ (xQi)
))
= ∂xQi ∂ξ − n∑ i=1 1( P (XQ,C) ξ (xQi) ) ∂ ∂xQi ( P (XQ,C) ξ (xQi) ) Here, we remark that ∂xQi∂ξ will be carried out by back-propagation and the expression after it is the initial gradient.
Next, we derive the gradient of the logical entailment loss function LENT , as defined in equation 7. One estimates the gradient as follows
1
n
∂
∂p LENT ≥ −
1
n n∑ i=1 ∂ log(PΠ(θ)(Qi)) ∂p · log(P (XQ,C)(xQi)),
whereby
• XQ is the set of random variables associated with the set of the queries Q, • xQi is a training sample, a realization of the set of random variables XQ associated with the
particular query Qi,
• P (XQ,C)(xQi) is the probability of the realization xQi estimated by the NPP modelling the joint over the set XQ and C – the set of classes (the domain of the NPP),
• log(PΠ(θ)(Qi)) – the probability of the query Qi under the program Π(θ) calculated by SLASH (for the reference see the equation (5)),
• and ∂ log(PΠ(θ)(Qi))∂p is the gradient as defined in Eq.9.
We begin with the definition of the cross-entropy for two vectors yi and ŷi:
H(yi, ŷi) := m∑ j=1 yij · log ( 1 ŷij ) = m∑ j=1 yij · log(1)︸ ︷︷ ︸ =0 −yij · log(ŷij)  = − m∑ j=1 yij · log(ŷij).
Hereafter we substitute yi = log(PΠ(θ)(Qi)) and ŷi = P (XQ,C)(xQi)
and obtain H(yi, ŷi) = H ( log(PΠ(θ)(Qi)), P (XQ,C)(xQi) ) = − m∑ j=1 log(PΠ(θ)(Qij))·log ( P (XQ,C)(xQij ) ) . (11) We remark that m represent the number of classes defined in the domain of an NPP. Now, we differentiate the equation (11) with the respect to p depicted as in Eq. 9 to be the label of the probability of an atom c = v in rnpp, denoting PΠ(θ)(c = v). Since differentiation is linear, the product rule is applicable directly:
∂
∂p H (yi, ŷi) = − m∑ j=1
[ ∂ log(PΠ(θ)(Qij))
∂p · log
( P (XQ,C)(xQij ) )
+ log(PΠ(θ)(Qij)) · ∂ log
( P (XQ,C)(xQij ) ) ∂p ] .
We do not wish to consider the latter term of log(PΠ(θ)(Qi))· ∂ log(P (XQ,C)(xQi )) ∂p because it represents the rescaling and to keep the first since SLASH procure ∂ log(PΠ(θ)(Qi))∂p following Eq. 9. To achieve this, we estimate equation from above downwards as
∂
∂p H (yi, ŷi) ≥ − m∑ j=1 ∂ log(PΠ(θ)(Qij)) ∂p · log ( P (XQ,C)(xQij ) ) . (12)
Furthermore, let us recall that under i.i.d assumption we obtain from the definition of likelihood
LH(y, ŷ) = n∏ i=1 LH(yi, ŷi),
and following the negative likelihood coupled with the knowledge that the log-likelihood of yi is the log of a particular entry of ŷi
LENT = − logLH(y, ŷ) =− n∑ i=1 logLH(yi, ŷi) = − n∑ i=1 m∑ j=1 yij · log(ŷij) =
n∑ i=1 − m∑ j=1 yij · log(ŷij)  = n∑ i=1 H(yi, ŷi).
Finally, we obtain the following estimate applying inequality (12)
1
n
∂
∂p LENT =
1
n n∑ i=1 ∂ ∂p H(yi, ŷi) ≥ − 1 n n∑ i=1 ∂ log(PΠ(θ)(Qi)) ∂p · log ( P (XQ,C)(xQi) ) Also, we note that the mathematical transformations listed above hold for any type of NPP and the task dependent queries (NN with Softmax, PC or PC jointly with NN). The only difference will be the second term, i.e., log(P (C|XQ)(xQij )) or log(P
(XQ|C)(xQij )) depending on the NPP and task. The NPP in a form of a single PC modeling the joint over XQ and C was depicted to be the example. With that, the derivation of gradients for both loss functions 2 and 7 is complete, and the training is carried out by coordinated descent.
Backpropagation for joint NN and PC NPPs: If within the SLASH program, Π(θ), the NPP forwards the data tensor through a NN first, i.e., the NPP models a joint over the NN’s output variables by a PC, then we rewrite (8) to
n∑ i=1
∂ log ( PΠ(θ)(Qi) ) ∂θ = n∑ i=1 ∂ log ( PΠ(θ)(Qi) ) ∂p × ∂p ∂θ × ∂θ ∂γ . (13)
Thereby, γ is the set of the NN’s parameters and ∂θ∂γ is computed by the backward propagation through the NN.

heading: B APPENDIX B – SLASH PROGRAMS
text: Here, the interested reader will find the SLASH programs which we compiled for our experiments. Figure 4 presents the one for the MNIST Addition task, Figure 6 – for the set prediction task with slot attention encoder and the subsequent CoGenT test. Note the use of the “+” and “-” notation for indicating whether a random variable is given or being queried for.

heading: C APPENDIX C – EXPERIMENTAL DETAILS
text: C.1 SHAPEWORLD4 GENERATION
The ShapeWorld4 and ShapeWorld4 CoGenT data sets were generated using the original scripts of (Kuhnle & Copestake, 2017) (https://github.com/AlexKuhnle/ShapeWorld). The exact scripts will be added together with the SLASH source code.
C.2 AVERAGE PRECISION COMPUTATION (SHAPEWORLD4)
For the baseline slot encoder experiments on ShapeWorld4 we measured the average precision score as in Locatello et al. (2020). In comparison to the baseline slot encoder, when applying SLASH Attention, however, we handled the case of a slot not containing an object, e.g. only background variables, differently. Whereas Locatello et al. (2020) add an additional binary identifier to the multi-label ground truth vectors, we have added a background (bg) attribute to each category (cf. Fig. 6). A slot is thus considered to be empty (i.e. not containing an object) if each NPP returns the maximal conditional probability for the bg attribute. As the ShapeWorld4 prediction task only included discrete object properties both for Slot Attention as well as for SLASH Attention the distance threshold for the average precision computation was infinity (thus corresponding to no threshold).
C.3 MODEL DETAILS
For those experiments using NPPs with PC we have used Einsum Networks (EiNets) for implementing the probabilistic circuits. EiNets are a novel implementation design for SPNs introduced by Peharz et al. (2020) that minimize the issue of computational costs that initial SPNs had suffered. This is accomplished by combining several arithmetic operations via a single monolithic einsum-operation.
For all experiments, the ADAM optimizer (Kingma & Ba, 2015) with β1 = 0.9 and β2 = 0.999, = 1e− 8 and no weight decay was used. MNIST-Addition Experiments For the MNIST-Addition experiments, we ran the DeepProbLog and NeurASP programs with their original configurations, as stated in (Manhaeve et al., 2018) and (Yang et al., 2020), respectively. For the SLASH MNIST-Addition experiments, we have used the same neural module as in DeepProbLog and NeurASP, when training SLASH with the neural NPP (SLASH (DNN)) represented in Tab. 2. When using a PC NPP (SLASH (PC)) we have used an EiNet with the Poon-Domingos (PD) structure (Poon & Domingos, 2011) and normal distribution for the leafs. The formal hyperparameters for the EiNet are depicted in Tab. 3.
The learning rate and batch size for the DNN were 0.005 and 100, for DeepProbLog, NeurASP and SLASH (DNN). For the EiNet, these were 0.01 and 100.
ShapeWorld4 Experiments For the baseline slot attention experiments with the ShapeWorld4 data set we have used the architecture presented in Tab. 4. For further details on this, we refer to the original work of Locatello et al. (2020). The slot encoder had a number of 4 slots and 3 attention iterations over all experiments.
For the SLASH Attention experiments with ShapeWorld4 we have used the same slot encoder as in Tab. 4, however, we replaced the final MLPs with 4 individual EiNets with Poon-Domingos structure (Poon & Domingos, 2011). Their hyperparameters are represented in Tab. 5.
The learning rate and batch size for SLASH Attention were 0.01 and 512, for ShapeWorld4 and ShapeWorld4 CoGenT. The learning rate for the baseline slot encoder were 0.0004 and 512.

heading: D APPENDIX D - ADDITIONAL RESULTS ON MNIST ADDITION
text: In addition to the setting considered in Evaluation 2, we adjusted the settings for the MNIST Addition task with missing data into the following way.
Training was performed with the full MNIST data set, however the test data set contained different rates of missing pixels. Whereas using an NPP with a PC allows, among other things, to compute marginalization “out of the box” without requiring an update to the architecture or a retraining, this is not so trivial for purely neural-based predicates as in DeepProbLog. Thus, we allowed SLASH (PC) to marginalize over the missing pixels, where this was not directly possible for DeepProbLog.
The results can be seen in Tab. 6 for 50%, 80%, 90% and 97% of missing pixels per image in the test set. We observe that at 50%, DeepProbLog outperforms SLASH by a small margin. For all other rates, we observe that SLASH (PC) reaches significantly higher test accuracies than DeepProbLog. However, we remark that in this setting, SLASH produces larger standard deviations in comparison to DeepProbLog. These results indicate that the conclusions, drawn in the main part of our work, remain true also in this setting of handling missing data.

Review summaries:
This paper presents a new deep probabilistic programming language based on ASP. The key feature is the use of a single attention encoder paired with a collection of probabilistic circuits (one for each "category"/model solution of the neuro-symbolic task). ASP is finally used to answer a query given the probabilistic predicates returned by the circuits for the features extracted by the encoder and the logical program modelling the particular task under consideration. SOTA accuracies are achieved with advantages related to the generative nature of the considered approach (e.g., when coping with missing data) and good computation times (due to the parallelisation of the ASP tasks). 

This paper proposes a neuro-symbolic model, dubbed SLASH, that extends previous deep probabilistic programming languages with probabilistic circuits (PCs). The advantage of this approach with respect to similar frameworks, such as DeepProbLog or NeurASP, lies in defining predicates using Sum-Product Networks (SPNs), a subclass of PCs that admit tractable marginal/conditional inference over any subset of variables. Additionally, neural networks and SPNs can be unified in the same framework, for instance by defining PCs on the latent representation extracted by an Attention Slot module. Experiments on different tasks show promising results for this approach. 

The paper presents an approach for neuro-symbolic integration that differs from NeurASP because NN can be replaced by probabilistic circuits (PC) or by NN+PC.  The resulting system, SLASH, is applied to the problems of MNIST-Addition and set prediction on a variant of the ShapeWorld dataset.  The results on MNIST-Addition show that SLASH+NN is faster and more accurate than DeepProbLog and NeurASP. Moreover, when pixels are missing, SLAHS+PC has much better performance than DeepProbLog.  On ShapeWorld, SLASH is compared with Slot Attention (Locatello et al 2020) and found to have better avg precision especially in handling novel combinations of attributes that were not seen during training.