Manuscript Offprint
arXiv:2610.06270DPNL: A DPLL-based Algorithm for Probabilistic Neurosymbolic Learning
Abstract
Probabilistic Neurosymbolic Learning (PNL) combines neural predictions with symbolic reasoning, enabling end-to-end learning from final-output supervision without labels for intermediate concepts. A central challenge is probabilistic inference: state-of-the-art approaches often rely on materializing the logical provenance of a query, which can itself become a major computational bottleneck. We introduce Dynamic Probabilistic Neurosymbolic Learning (DPNL), an oracle-guided framework that avoids requiring complete provenance materialization before inference. DPNL lazily explores the space of intermediate assignments, while oracles resolve entire regions that can already be certified to produce or exclude the target output. We establish conditions ensuring soundness and termination. ApproxDPNL extends the same search with early termination while maintaining certified bounds on the exact output probability, providing controlled approximation guarantees. The oracle interface decouples inference from the representation of the symbolic component, enabling problem-specific reasoning within the same framework. Experiments on several neurosymbolic tasks show that DPNL and ApproxDPNL substantially extend the range of problem instances tractable by probabilistic neurosymbolic inference.
1 Introduction
Neurosymbolic artificial intelligence seeks to combine the learning capabilities of neural networks with structured symbolic reasoning [van Harmelen and ten Teije, 2019; Vermeulen et al., 2023]. Probabilistic Neurosymbolic Learning (PNL) is one approach to this integration, in which neural networks predict probability distributions over intermediate concepts and a symbolic component combines these predictions to produce the final output [De Raedt et al., 2020; Li et al., 2023]. A key advantage of this setting is that the intermediate predictions need not be supervised directly. Instead, the symbolic computation connects them to the observed output, allowing the neural component to be trained end-to-end from supervision on the final task. At the same time, the symbolic component makes explicit how intermediate predictions are combined to determine the final output, providing a structured and inspectable reasoning process.
Consider, for instance, a kinship-reasoning task in the style of CLUTRR [Sinha et al., 2019]. Given a short text describing relations between people, a neural component may predict distributions over uncertain relations such as sister, aunt, or parent. Symbolic kinship rules then compose these relations to answer a query such as “How are Rich and Anne related?”. Training may provide only the correct answer to this final query, and not the intermediate relations required to derive it. Learning therefore requires propagating supervision through the symbolic reasoning process while accounting for uncertainty in the intermediate neural predictions.
This introduces a central computational challenge. To obtain the probability of a given output, probabilistic reasoning must aggregate the probability mass of all assignments of the intermediate predictions that make the symbolic computation produce that output. Depending on the task, this aggregation may admit an efficient computation or a compact representation. In general, however, the number of relevant assignments can grow rapidly with the number of intermediate variables, making their explicit enumeration impractical. Importantly, this difficulty is distinct from the cost of evaluating the symbolic computation on one complete assignment: a symbolic function may be inexpensive to evaluate while the set of assignments leading to a given output is much harder to represent or aggregate over.
Existing exact PNL approaches such as DeepProbLog [Manhaeve et al., 2021a] address this problem by constructing the logical provenance of a query, using knowledge compilation techniques, and subsequently performing probabilistic inference over that representation. However, constructing the complete provenance can itself become a bottleneck when the number of alternative reasoning paths is large. Approximate methods have consequently been proposed to extend PNL to larger problem instances [Manhaeve et al., 2021b; Huang et al., 2021; van Krieken et al., 2023]. These methods trade exact inference for scalability in different ways. This motivates a complementary question: can probabilistic inference avoid constructing the complete provenance in the first place, while retaining exact inference when feasible and providing explicit control over the error when approximation is necessary?
Contribution. Our main contribution is the DPNL framework, a new probabilistic reasoning architecture for end-to-end neurosymbolic learning, with two major aspects:
i. Inference without full provenance materialization. Instead of constructing the complete logical provenance of a query before inference, DPNL performs a lazy exploration of partial assignments and dynamically eliminates regions of the implicit reasoning space that can be determined to succeed or fail. Only regions that cannot yet be decided are explored further. This yields an exact inference procedure when exploration is continued to completion.
ii. Certified approximation. When exact inference is not required, ApproxDPNL can stop this exploration early while maintaining certified bounds on the exact output probability. Specifically, it tracks the probability mass of unresolved regions and maintains certified lower and upper bounds on the exact output probability at any point during the search.
An important architectural property of DPNL and Approx-DPNL is their ability to combine neural predictions over finite-domain random variables with diverse forms of symbolic reasoning. They separate probabilistic inference from the representation and implementation of the symbolic component, allowing the same inference architecture to accommodate a broad range of symbolic representations and reasoning procedures. We formalize a generic oracle interface that supports ordinary executable symbolic programs, solver-backed logical specifications, and domain-specific oracles, and establish conditions under which oracle-guided inference is sound and terminating.
We implement DPNL and ApproxDPNL in a research prototype and evaluate them on several neurosymbolic tasks. Experiments show that oracle-guided reasoning can substantially extend the range of tractable problem instances for probabilistic neurosymbolic learning.
Given a fixed observed input i from an input space I, the neural component predicts a distribution for each of m random variables , where each takes values in a finite domain . We write
for the predicted distribution of , where collects all neural parameters. The neural component may consist of one or several neural networks.
The symbolic component is a deterministic function
which maps a joint assignment of the neural variables to an output .
For instance, in the kinship example, the variables represent uncertain relations extracted from the text, while S applies symbolic reasoning to these relations to infer the answer to the final kinship query.
For each fixed input i, the random variables are assumed to be mutually independent. The probability assigned to an output o for input i is then
(1)
where .
Since is deterministic and does not depend on , Eq. (1) is a finite sum of products of neural probabilities. Therefore, since the distributions are differentiable with respect to , then is differentiable as well. This enables end-to-end learning from supervision on the final output, without requiring labels for the intermediate variables .
Major computational challenge. Computing Eq. (1) can nevertheless be expensive. The set of assignments
may be exponentially large in m. Consequently, explicitly enumerating all assignments that contribute to the sum can become intractable.
The inference problem considered in this work is therefore to compute exactly, or to approximate it with certified bounds, without explicitly materializing the full set of satisfying assignments.
3 DPNL: Oracle-Guided Inference
We now introduce Dynamic Probabilistic Neurosymbolic Learning (DPNL), an inference framework for computing the output probability in Eq. (1) without explicitly materializing the set of satisfying assignments. The key idea is to reason over regions of the assignment space rather than over complete assignments individually.
DPNL queries the symbolic component through an oracle that, for a region and a target output o, can return one of three answers: (i) every assignment in the region produces o, (ii) no assignment in the region produces o, or (iii) the available information is insufficient to decide. In the first two cases, DPNL can account for or discard the entire region without exploring its individual assignments. In the third case, DPNL further explores the region.
This oracle interface abstracts away the particular representation of S: DPNL only requires enough information to determine whether a region can already be accepted or rejected. The resulting split-or-prune process follows the same recursive principle as DPLL-style search (an analogy intentionally reflected in the name DPNL). We now formalize these regions using valuations and state the conditions that an oracle must satisfy.
3.1 Search Regions and Oracle Interface
We formalize the regions explored by DPNL using valuations. A valuation of the variables is an array of size such that, for every ,
The value indicates that has not yet been assigned.
We denote by the set of all valuations. A valuation is total if for every , and partial otherwise. A valuation is a refinement of if
Thus, preserves all values fixed in v, while possibly fixing additional variables.
We denote by the set of all total refinements of . We call the region represented by . The empty valuation represents the whole assignment space, while a total valuation represents a single complete assignment.
For , we denote by the valuation obtained from by replacing with .
For a given valuation v and output o of S, an oracle is in charge of determining whether it is still relevant to explore refinements of v or whether the exploration process can be stopped. Formally, an oracle is a function
Given a valuation v and a target output o, the oracle returns 1 if it can establish that every total refinement of v produces o, 0 if it can establish that no total refinement produces o, and otherwise. Intuitively, indicates that the oracle cannot yet decide the region and further exploration is needed.
We call an oracle valid when its definitive answers are sound and it always decides total valuations. Formally, is a valid oracle for if, for every and ,
In addition, for every total valuation , . Since when is total, the previous conditions imply
A valid oracle is complete if the implications in Eqs. (2)–(3) are equivalences. Importantly, DPNL requires validity but not completeness: returning on a partial valuation only causes the corresponding region to be explored further. Completeness therefore affects pruning efficiency, but not correctness.
3.2 Exact Inference with DPNL
Algorithm 1 presents the core algorithm of the framework. Starting from the empty valuation , DPNL computes the output probability in Eq. 1 as
Algorithm 1: DPNL(i, o, v, )
Input: , , , and an oracle for S.
Output: The probability of obtaining o under v.
1: if then 2: return 1 3: else if then 4: return 0 5: else 6: Choose such that . 7: return 8: end if
A recursive call terminates as soon as the oracle returns 0 or 1. Otherwise, choosing an unassigned variable partitions the current region into the regions represented by its refinements, whose contributions are combined according to .
Theorem 1 (DPNL termination and correctness). For any input , output , and valid oracle for , DPNL( ) terminates and returns .
The proof is provided in the supplementary material.
Crucially, DPNL explores the assignment space lazily: regions are further explored only when the oracle cannot decide them. It therefore avoids materializing the full query provenance before inference.
3.3 Approximate Inference with ApproxDPNL
ApproxDPNL, presented in Algorithm 2, extends this lazy search with early termination while maintaining certified bounds on the exact probability.
Algorithm 2: ApproxDPNL(i, o, , STOP, H)
Input: , , a valid oracle for S, a stopping condition STOP, and a search heuristic H.
Output: Bounds (low, up) such that .
1: low, up 0, 1
2:
3: while and do
4:
5:
6:
7: if then
8:
9: else if then
10:
11: else
12: Choose such that
13:
14: end if
15: end while
16: return (low, up)
ApproxDPNL maintains a set Q of valuations representing regions whose contribution to the target output has not yet been resolved. Throughout the search, it maintains a lower bound low and an upper bound up such that . The lower bound low is the probability mass already certified to produce o, while up additionally includes all unresolved probability mass, which may still contribute to the output. Equivalently, is the probability mass already certified not to produce o. Hence, up - low is precisely the unresolved probability mass, and at every iteration, the interval tightens: .
Stopping condition. A function STOP determines how tightly the returned interval must bound before inference terminates. If STOP never triggers, all regions are eventually resolved and , recovering exact inference. Different stopping conditions provide different approximation guarantees.
Additive approximation. For a desired absolute error with respect to the exact probability , the search can stop when . The midpoint then satisfies .
Multiplicative approximation. For , is a multiplicative -approximation when . When , stopping when and taking provides this guarantee. This interval-to-estimate conversion follows [Dubray et al., 2024].
Anytime inference. Without prescribing an error tolerance, ApproxDPNL may instead be interrupted under any computational budget: the returned interval remains certified at any time. Its midpoint has absolute error at most ; when , the geometric mean provides a multiplicative guarantee with .
Search heuristic. The search heuristic H determines which unresolved region is explored next by selecting a valuation v from Q. The choice of the next unassigned variable can likewise follow a fixed ordering or a problem-specific branching heuristic. These choices affect how quickly the bounds tighten, but not their validity.
3.4 Designing and Combining Oracles
Both DPNL and ApproxDPNL rely on the same oracle interface. Any symbolic function S that can be evaluated on complete valuations admits a valid oracle: one may simply return on every partial valuation and evaluate S once the valuation is total. Hence, the existence of an oracle does not restrict the applicability of DPNL. Oracles determine how efficiently the search space can be explored.
In practice, oracle design involves a trade-off between the cost of each oracle call and its pruning power, i.e., how early and how much of the remaining search space it can resolve. A stronger oracle may avoid many recursive calls, but may itself be more expensive to evaluate. In particular, completeness maximizes the ability to decide partial valuations, but does not imply computational efficiency.
Basic oracles. When an executable implementation of S is available, a basic oracle can be obtained automatically by running it on a partial valuation. If the execution attempts to access an unassigned variable, the oracle returns ; otherwise, the computation terminates without depending on the remaining variables and its output determines whether to return 0 or 1. Basic oracles therefore inherit the computational efficiency of the implementation of S, but need not be complete.
Solver-backed oracles. When S is expressed in a decidable logic, a solver can be used to determine whether all completions of the current partial valuation produce the target output o, or whether none of them do. Such oracles can provide substantially stronger pruning than direct program execution. We give in the supplementary material a generic construction for logic-based PNL systems, together with sufficient conditions under which the resulting oracle is valid and complete.
Custom and combined oracles. Domain knowledge can also be used to implement specialized valid oracles. For example, in relational reasoning tasks such as CLUTRR, an oracle can propagate the relations already fixed in a partial valuation. Knowing that A is the sister of B and B the father of C, for instance, may already determine that A is the aunt of C, independently of the remaining unknown relations.
Different valid oracles can moreover be combined safely. Given , DPNL may query them in sequence and return the first answer different from . The resulting oracle remains valid; if one of the queried oracles is complete, the combination is complete as well. This makes it possible to query inexpensive oracles first and fall back to stronger, more costly reasoning only when needed.
4 Experimental Evaluation
We conduct experiments on symbolic and neurosymbolic reasoning tasks in order to bring elements of answers to the following research questions:
Q1: How does DPNL compare to other exact probabilistic reasoning systems?
Q2: In a neurosymbolic setting, how does the DPNL approach compare to SOTA PNL systems with exact and approximate reasoning in terms of efficiency and accuracy?
Q3: How do the parameters of ApproxDPNL, the per-sample timeout of the anytime approximation and the error budget of the -approximation, trade accuracy against runtime?
We first report on the experimental methodology and results for symbolic reasoning tasks, followed by neurosymbolic evaluations and an analysis of the and anytime timeout parameters of ApproxDPNL.
4.1 Symbolic reasoning (Q1)
We compare DPNL to ProbLog a state-of-the-art system with exact probabilistic inference used in DeepProbLog. We use the two following probabilistic reasoning tasks.
We first evaluate DPNL on the popular MNIST-N-SUM task. By extending from an N digit sum to an N+1 digit sum, the complexity of reasoning increases exponentially. Thus, the multi-digit MNIST-N-SUM task is well-suited for exploring the scalability of PNL systems. Each digit is represented as a probability distribution over , simulating uncertainty in perception. Here, we randomly generate the digit distributions. The symbolic function S performs digit by digit integer addition and verifies the equality with the target. The following oracles are compared on this task. The basic oracle is built on the digit-by-digit addition implementation for S.
The logic oracle is generated from the Boolean logic representation of the N-digit addition. The combined oracle uses the sequential combination of the basic and logic oracles.
We also evaluate DPNL on a graph reachability task. This involves estimating the probability that a path exists between a source and a target node in a probabilistic graph. We consider a graph with nodes, represented by an adjacency matrix containing potential edges. Each edge is assumed to be independently present with a certain probability. The symbolic function is a reachability predicate, implemented using a depth-first search (DFS) algorithm. Probabilities are randomly assigned to the edges, and the existence of a path from the source to the destination node is evaluated.

Figure 1: Q1 Runtimes (in seconds) for MNIST-N-SUM.

Figure 2: Q1 Runtimes (in seconds) for graph reachability.
Experimental results. Figures 1 and 2 show the time spent on symbolic reasoning for MNIST-N-SUM and graph reachability, respectively. On MNIST-N-SUM, results show that DPNL scales better than ProbLog, solving task instances for where ProbLog fails with a timeout. Results also show that the logic oracle, although slower on small instances, scales better than the basic oracle.
| Benchmark | Difficulty | Reasoning | ||
|---|---|---|---|---|
| Exact | -approx. | Anytime approx. | ||
| Leaf | 120 | ✓ | ||
| MNIST-N-SUM | ✓ | ✓ | ✓ | |
| Visual Sudoku | ✓ | |||
Table 1: Overview of the neurosymbolic benchmarks. Difficulty is the size of the symbolic search space The Reasoning columns mark which DPNL inference modes are evaluated on each benchmark.
Regarding graph reachability, for small instances (up to ) Problog is faster than DPNL. However, for , Problog fails with timeout, whereas DPNL successfully completes with the logic and combined oracles. Results also illustrate that DPNL offers the possibility to scale even further given some manual programming effort with a custom oracle.
4.2 Application to neurosymbolic AI (Q2)
We now evaluate DPNL on a neuro-symbolic benchmark suite, including MNIST-N-Sum, Visual Sudoku and Leaf classification. Table 1 summarizes the difficulty of the task (regarding the symbolic search space) and the versions of the algorithm (exact, -approximation or anytime approximation) that are evaluated on each benchmark. More details on hyperparameter values, timeout thresholds and information on hardware and baseline configurations are given in the supplementary material.
Leaf Classification
We use the LEAF-ID dataset built from the plant-leaf collection of Kanda et al. [2021] which includes leaf images of 11 plant species, with 330 training and 110 test samples. Each leaf is described by three discrete features (MARGIN, SHAPE and TEXTURE) with 6, 5 and 4 possible values respectively. A neural model predicts a distribution over the values of each feature from the image, and the symbolic function maps the feature values to a species. is a fixed decision tree over the species. Because the tree has a bounded number of paths, the reasoning difficulty does not scale with any instance-size parameter. There are at most feature combinations. The oracle evaluates the decision tree on a partial valuation and returns the species as soon as the branch is determined, usually without reading all three features. DPNL is used with exact reasoning on this benchmark. DPNL is trained for 50 epochs with the Adam optimiser (learning rate , batch size 4), and all methods are evaluated over 10 independent runs. We compare DPNL against two families of baselines. The neurosymbolic baselines include DeepProbLog [Manhaeve et al., 2018], Scallop [Huang et al., 2021] in two configurations (top- provenance and exact provenance, A-NeSI [van Krieken et al., 2023], and ISED [Solko-Breslin et al., 2024]. The sampling-based gradient-approximation baselines REINFORCE [Williams, 1992] and NASR [Cornelio et al., 2023] treat the tree as a black box and estimate the gradient from sampled neural predictions
Results. The results are given in Table 2. DPNL with exact
| Method | Accuracy | Std | Time |
|---|---|---|---|
| DPNL (exact) | 0.8080 | 0.0360 | 10:15 |
| Neurosymbolic (probabilistic inference) | |||
| DeepProbLog | 0.4327 | 0.0308 | 1:02:28 |
| Scallop (top-k) | 0.7709 | 0.0284 | 5:30 |
| Scallop (exact) | 0.7691 | 0.0294 | 55:34 |
| A-NeSI | 0.7291 | 0.0909 | 21:33 |
| ISED | 0.7964 | 0.0261 | 18:03 |
| Sampling-based gradient approximation | |||
| REINFORCE | 0.7955 | 0.0357 | 6:52 |
| NASR | 0.1009 | 0.0155 | 2:03 |
Table 2: Results on the Leaf benchmark. Average test accuracy, standard deviation, and total wall-clock runtime (h:mm:ss), over 10 independent runs. Highest accuracy and lowest runtime in bold.
reasoning obtains the highest mean accuracy (0.808) on Leaf. Among the exact methods it is also the fastest: 10:15 against 55:34 for Scallop with and 1:02:28 for DeepProbLog, whose accuracy drops to 0.43. ISED and REINFORCE come close to DPNL (0.796), whereas NASR falls to chance level .
MNIST-N-Sum
MNIST-N-SUM [Manhaeve et al., 2018] is the task of predicting the sum of two -digit numbers written as sequences of handwritten-digit images, supervised only by the value of the sum and never by the individual digit labels (e.g. a pair of two-digit images reading ). We evaluate . DPNL is run in three modes: exact inference, -approximation, and anytime approximation. Training uses Adam with learning rate and batch size 2. The accuracy numbers are averaged over 10 seeds. Per-mode and per- hyper-parameters are listed in Table 6 in the appendix. We compare DPNL (with the basic oracle) with the exact neurosymbolic methods DeepProbLog and Scallop [Huang et al., 2021] and with A-Nesi [van Krieken et al., 2023], DPLA* [Manhaeve et al., 2021b] and Scallop (with the top-k semiring), which use approximate inference. A-Nesi is evaluated across its different variants (predict only, explain, prune). We use the MNIST dataset from [Lecun et al., 1998]. Each experiment is performed with multiple independent runs, and we report the average test accuracy and the average reasoning time per sample during training. The parameters for and timeout for ApproxDPNL have been chosen based on parameter tuning to find a good balance between accuracy and runtime, see Section 4.3.
Results Among the other exact PNL systems, DeepProbLog matches DPNL's accuracy at but no longer finishes for , and Scallop (exact) already times out at . DPNL in exact mode is the only method that completes (avg. accuracy 0.83) and times out only at . The - and anytime-approximation modes preserve accuracy while improving scalability. The anytime mode matches exact inference to within one point at every while cutting the per-sample symbolic time by 5 to (e.g. 0.27 s vs. 6.1 s at ), and it is the only method that runs at all at within the timeout threshold. The -approximation behaves similarly. It stays within one point of exact inference (0.9062, 0.8730, 0.8219 for ), and at its per-sample symbolic time is 0.67 s which is below exact, between the anytime mode (0.27 s) and exact (6.1 s). Comparing exact and approximate inference under the same training budget, a clear accuracy gap opens between the DPNL modes and the approximate baselines from on. DPNL reaches at versus at most 0.84 for the baselines, and at only A-NeSI among the baselines finishes, its best variant (explain) reaching 0.66 versus 0.83 for DPNL. This gap should be read as a difference in data efficiency under a short training budget rather than as a bound on the accuracy that approximate methods can reach, since A-NeSI is reported to reach higher accuracies with substantially more training epochs [van Krieken et al., 2023]. At , all three A-NeSI variants terminate and reach (predict), (explain) and (prune), close to the of anytime DPNL, the only DPNL mode that finishes at this scale. A-NeSI keeps its speed advantage: its per-sample reasoning time is 0.0136 s (predict), 0.0349 s (explain) and 0.0340 s (prune), the same order of magnitude as for and more than below the 1.94 s of anytime DPNL.
Visual Sudoku
We use the Visual Sudoku Puzzle Classification dataset of Augustine et al. [2022]. The task is to decide whether an grid of digit images forms a valid Sudoku, that is, whether no digit occurs twice in any row, any column, or any block. We consider . Each cell is perceived by the same MNIST classifier as in the MNIST-N-SUM task. In DPNL, each of the cells is a random variable over , so a naive PWMC enumeration of the possible grids would consider total valuations. The oracle prunes this search space as follow. Given a partial valuation (a partially filled grid), it returns 0 (invalid) as soon as a duplicate appears in any row, column or block, without waiting for the remaining cells to be assigned. We test DPNL in its exact, anytime and epsilon mode. We compare DPNL to a CNN as neural baseline and to the neuro-symbolic methods NeuPSL [Pryor et al., 2023] and A-Nesi. As for MNIST, the parameters for epsilon and anytime result from parameter tuning, see Section 4.3. For N9, we use a pretrained classifier. For better comparability, we also evaluate A-Nesi with the same pretrained classifier on N9. The results for the CNN, A-Nesi (without pretraining) and NeuPSL are taken from [van Krieken et al., 2023].
Results. Table 4 reports the results. At , exact DPNL reaches 0.912 without classifier pretraining, slightly above the best baselines trained in the same setting (A-NeSI, 0.898; NeuPSL, 0.897). Both approximations stay close to exact inference (0.910 for the -approximation and 0.890 for anytime) while reducing the wall-clock time per run from about 45 to 12 and 5 min, respectively. At , the search space grows to grids and the exact inference baseline times out, whereas anytime DPNL still trains and reaches 0.757, the highest accuracy of all methods, ahead of pretrained A-NeSI
| N = 2 | N = 3 | N = 4 | N = 8 | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Acc | Std | Time | Acc | Std | Time | Acc | Std | Time | Acc | Std | Time | |
| DPNL (exact) | 0.9100 | 0.0161 | 0.0301 | 0.8735 | 0.0168 | 0.4783 | 0.8320 | 0.0209 | 6.1344 | T/O | T/O | T/O |
| DPNL (ε) | 0.9062 | 0.0124 | 0.0061 | 0.8730 | 0.0216 | 0.0430 | 0.8219 | 0.0243 | 0.6656 | T/O | T/O | T/O |
| DPNL (anytime) | 0.9115 | 0.0118 | 0.0063 | 0.8636 | 0.0157 | 0.0271 | 0.8266 | 0.0367 | 0.2654 | 0.7227 | 0.2566 | 1.9446 |
| DeepProbLog | 0.9098 | 0.0122 | 0.4784 | T/O | T/O | T/O | T/O | T/O | T/O | T/O | T/O | T/O |
| Scallop (exact) | T/O | T/O | T/O | T/O | T/O | T/O | T/O | T/O | T/O | T/O | T/O | T/O |
| DPL A* | 0.8945 | 0.0146 | 0.0255 | 0.8365 | 0.0303 | 0.1237 | T/O | T/O | T/O | T/O | T/O | T/O |
| Scallop (top-k) | 0.8257 | 0.2060 | 0.0244 | 0.7523 | 0.2612 | 0.9521 | T/O | T/O | T/O | T/O | T/O | T/O |
| A-Nesi (predict)† | 0.8849 | 0.0142 | 0.0265 | 0.7796 | 0.0074 | 0.0170 | 0.5929 | 0.0394 | 0.0221 | 0.7023 | 0.0248 | 0.0136 |
| A-Nesi (explain)† | 0.8952 | 0.0071 | 0.0213 | 0.7707 | 0.0179 | 0.0219 | 0.6584 | 0.0239 | 0.0268 | 0.7016 | 0.0309 | 0.0349 |
| A-Nesi (prune)† | 0.7866 | 0.2225 | 0.0195 | 0.7706 | 0.0214 | 0.0206 | 0.5905 | 0.0339 | 0.0245 | 0.6841 | 0.0207 | 0.0340 |
Table 3: Results on the MNIST-N-SUM task: average test accuracy (Acc), its standard deviation (Std), and average reasoning time per sample during training (Time, in seconds), over several independent runs. Highest accuracy and lowest runtime in bold. It is worth noting that van Krieken et al. [2023] report higher accuracies for A-NeSI (0.960 for N = 2 and 0.926 for N = 4) with 100 training epochs and batch size 16 on a GPU. We instead train A-NeSI with training parameters similar to those of the other methods, to keep accuracies and reasoning times comparable across systems. For N = 8, all methods are trained for more epochs, which explains why A-NeSI reaches a higher accuracy at N = 8 than at N = 4.
| Method | N = 4 | N = 9 |
|---|---|---|
| DPNL (exact) | 0.9115 ± 0.0111 | T/O |
| DPNL (ε-approx.) | 0.9100 ± 0.0191 | T/O |
| DPNL (anytime) | 0.8895 ± 0.0297 | 0.7570 ± 0.0172 |
| CNN | 0.5150 ± 0.0334 | 0.5120 ± 0.0220 |
| NeuPSL [Pryor et al., 2023] | 0.8970 ± 0.0220 | 0.5150 ± 0.0137 |
| A-NeSI (symbolic pred.) | 0.8970 ± 0.0208 | 0.6215 ± 0.0208 |
| A-NeSI (neural pred.) | 0.8980 ± 0.0211 | 0.6225 ± 0.0220 |
| A-NeSI (pretrained) | - | 0.7230 ± 0.0214 |
Table 4: Results on Visual Sudoku: mean test accuracy ± standard deviation over 10 runs. Highest accuracy in bold. Baselines are taken from van Krieken et al. [2023], except A-NeSI (pretrained), which was ran on the same hardware. T/O denotes timeout. Wall-clock time per DPNL run is about 45, 12 and 5 min at N = 4 (exact, ε-approx., anytime) and 1h 43m to 3h 33m at N = 9.
(0.723) that also profits from the pretraining of the classifier.
4.3 Analysis of the and Anytime Timeout Parameters (Q3)
We study how the two parameters of ApproxDPNL trade accuracy against runtime and consider the per-sample timeout of the anytime approximation and the error budget of the -approximation.
MNIST-N-SUM. Figure 3 shows test accuracy and total runtime as a function of for . Accuracy behaves like a threshold: it stays at 0 as long as is too small for most samples to be resolved, then jumps to a plateau (about 0.90 for , 0.84 to 0.89 for and 0.83 to 0.85 for ) that larger timeouts barely improve. Runtime, in contrast, grows roughly linearly with , e.g. from 1h 20m at s to 7h 57m at s for . The best operating point therefore lies just above the threshold. Figure 4 shows the analogous experiment over for . Runtime drops steeply as grows, while accuracy stays close to that of exact inference up to a breaking point that decreases with the task size (about for , 0.5 for and
| t (s) | Acc. | Std | Runtime |
|---|---|---|---|
| 0.01 | 0.350 | 0.189 | 1:07 |
| 0.02 | 0.401 | 0.085 | 1:52 |
| 0.04 | 0.492 | 0.018 | 2:56 |
| 0.05 | 0.499 | 0.002 | 3:35 |
| 0.06 | 0.534 | 0.076 | 4:16 |
| 0.07 | 0.815 | 0.022 | 4:49 |
| 0.075 | 0.839 | 0.037 | 5:03 |
| 0.08 | 0.880 | 0.046 | 5:13 |
| 0.1 | 0.877 | 0.025 | 6:23 |
| 0.2 | 0.903 | 0.019 | 9:19 |
| 0.5 | 0.884 | 0.037 | 16:16 |
Table 5: Anytime-timeout tuning on Visual Sudoku : mean test accuracy, its standard deviation and mean total runtime (mm: ss) over 5 seeds. Highest accuracy and lowest runtime in bold.
0.4 for ) and collapses beyond it. At , exact inference and all budgets exceed the 4h limit, so the -approximation is what makes this instance tractable. Larger instances thus tolerate less approximation, but they are also those that benefit most from it.
Visual Sudoku. Table 5 and Figure 5 report the same observation over for , with 10 training epochs, batch size 1, no classifier pretraining and 5 seeds per configuration. The anytime approximation shows the same threshold behaviour as on MNIST-N-SUM. Accuracy stays at or below chance level (0.5 on this binary task) up to , rises to 0.815 at and 0.880 at , and then saturates between 0.877 and 0.903 up to , while the runtime keeps growing from 5 to 16 min. We therefore use in the main experiments.
5 Related Works
5.1 Symbolic AI
DPNL builds on a line of work on exact and approximate weighted model counting (WMC). Probabilistic logic programming languages such as ProbLog [De Raedt et al., 2007] pro-

(a)

(b)

(c)
Figure 3: Test accuracy (blue, left axis) and total runtime (red, right axis) as a function of the per-sample symbolic timeout (in seconds) for the anytime approximation on MNIST-N-SUM. No sweep was run for .
vide an important foundation for provenance-based probabilistic inference, later adopted by neurosymbolic approaches such as DeepProbLog. The recursive, search-based structure of DPNL follows the DPLL algorithm [Davis et al., 1962], which decomposes a formula by branching on variable assignments. The use of oracles inside DPNL used to resolve a query under partial valuations is inspired by the decision-DNNF compilation strategies of Lagniez and Marquis [Lagniez and Marquis, 2017]. The approximation techniques used in ApproxDPNL are inspired by works in the symbolic AI literature, namely the anytime DPLL-based weighted model counting procedure of Dubray et al. [Dubray et al., 2024] and the approximate weighted model counting with guarantees [Chakraborty et al., 2015]. Unlike DPNL and ApproxDPNL, none of these systems are used to train a neural component from output-level supervision. They only address general-purpose probabilistic inference and compilation rather than neuro-symbolic learning.
5.2 Neurosymbolic AI
Neurosymbolic AI is a wide field containing a large number of different approaches. They share the same overall goal: bringing neural networks and symbolic AI together, but differ widely in how the two are combined, e.g. by relaxing logical connectives into differentiable operators (fuzzy-logic approaches such as Logic Tensor Networks [Badreddine et al., 2022]) or by adding a differentiable penalty for constraint violation to the training loss (the semantic loss [Xu et al., 2018]). Other probabilistic neurosymbolic frameworks adopt different inference semantics altogether. For instance, NeuPSL [Pryor et al., 2023] integrates neural predictions with Probabilistic Soft Logic and performs symbolic inference as convex MAP inference in a deep hinge-loss Markov random field. See [van Harmelen and ten Teije, 2019; De Raedt et al., 2020; Vermeulen et al., 2023] for surveys.
Within this broad landscape, we focus on approaches for solving the PNL problem defined in Section 2, in which neural predictions over intermediate variables are combined by a symbolic function to determine the final output. Existing approaches differ primarily in how they perform the probabilistic inference required to compute or approximate the output probability in Eq. (1). We distinguish below approaches based on exact reasoning, proof-based approximation, surrogate or sampling-based approximation, and hardware-oriented acceleration.
Exact reasoning. DeepProbLog [Manhaeve et al., 2018] is the seminal PNL approach that compiles the query's full logical provenance and performs exact weighted model counting (WMC) on it. NeurASP [Yang et al., 2020] provides an analogous integration with Answer Set Programs. DPNL instead computes the output probability in Eq. 1 through a lazy search over regions of the assignment space, without requiring the complete provenance to be materialized before inference.
Proof-based approximation. A common approach to improving scalability is to restrict probabilistic inference to a subset of the query's proofs. Scallop's top-k semiring [Huang et al., 2021; Li et al., 2023] retains at most k high-probability proofs during provenance construction, while approximate DeepProbLog [Manhaeve et al., 2021b] (DPLA*) uses A*-search to focus inference on high-probability explanations rather than exhaustively aggregating over all proofs. These approaches therefore control the amount of proof search performed, rather than directly controlling the approximation error on the output probability. In particular, Scallop's parameter k controls the number of retained proofs, while the resulting error depends on the probability mass of the discarded proofs. ApproxDPNL instead maintains certified lower and upper bounds on the exact output probability throughout inference. Its stopping condition can therefore be expressed directly in terms of a desired additive or multiplicative error, while the search may be interrupted at any point and still returns a certified interval.
Surrogate and sampling-based approximation. Other approaches avoid exact probabilistic inference by approximating either the inference result or the learning signal. A-NeSI [van Krieken et al., 2023] trains neural prediction and explanation models to approximate probabilistic neurosymbolic inference, optionally combined with a symbolic pruner that excludes infeasible partial assignments. ISED [Solko-Breslin et al., 2024] instead samples intermediate symbols, evaluates the symbolic program on these samples, and estimates gradients from the resulting partial representation of the program's behavior. These approaches can avoid the cost of exact inference,

(a)
Epsilon Analysis - N = 3

Epsilon Analysis - N = 2
(b)
Epsilon Analysis - N = 4

(c)

Epsilon Analysis - N = 4
(d)
Figure 4: Test accuracy (left panel) and training time (right panel) as a function of the error budget for the -approximation on MNIST-N-SUM. For , the hatched region marks the budgets whose runs exceed the 4h limit. No sweep was run for .
Anytime timeout tuning, Visual Sudoku N = 4

Figure 5: Test accuracy (blue, left axis) and total runtime (red, right axis) as a function of the per-sample timeout t for the anytime approximation on Visual Sudoku N = 4. Shaded bands span standard deviation over seeds; the dashed line marks exact inference (accuracy 0.902).
but unlike ApproxDPNL they do not maintain certified lower and upper bounds on the exact probability in Eq. 1. In particular, unlike A-NeSI, ApproxDPNL does not require an auxiliary learned inference model: its approximation guarantees follow directly from the unresolved probability mass during search. ApproxDPNL nevertheless retains an explicit search over the assignment space rather than replacing it with amortized or sampling-based inference. A complementary direction changes the probabilistic modeling assumptions themselves. Neurosymbolic diffusion models [van Krieken et al., 2025] model dependencies between intermediate symbols through a discrete diffusion process. DPNL instead retains the independence assumption of the PNL problem considered in this work and focuses on making inference over that model more efficient and controllable.
Hardware-oriented acceleration. A complementary line of work improves the execution of neurosymbolic reasoning on modern hardware. KLAY [Maene et al., 2025] maps arithmetic circuits to a representation designed for efficient parallel evaluation on GPU, while Lobster [Biberstein et al., 2026] compiles Datalog-based neurosymbolic programs for GPU execution. Dolphin [Naik et al., 2025] executes symbolic reasoning on the CPU while vectorizing the probabilistic and gradient computations on the GPU. DeepLog [Derkinderen et al., 2025] provides a more general neurosymbolic abstract machine based on extended algebraic circuits and GPU execution. These approaches primarily address the execution of neurosymbolic computations, whereas DPNL changes the inference procedure itself by lazily exploring the assignment space and avoiding complete provenance materialization when possible. The two directions are therefore complementary: hardware-oriented execution techniques could in principle also be investigated for accelerating DPNL.
6 Conclusion
We introduced DPNL, an oracle-guided inference framework for probabilistic neurosymbolic learning that avoids requiring the complete logical provenance of a query to be materialized before inference. DPNL instead explores the space of intermediate assignments lazily, resolving regions as soon as their contribution to the target output can be determined. A generic oracle interface decouples this inference procedure from the representation of the symbolic component. For valid oracles,
DPNL terminates and returns the exact output probability, while ApproxDPNL can stop the same search early while maintaining certified lower and upper bounds on that probability, yielding controlled approximation guarantees. Our experiments show that DPNL can substantially extend the range of instances tractable by exact probabilistic inference, while ApproxDPNL extends this range further through certified approximate inference. This suggests that probabilistic neurosymbolic inference can be organized as dynamic, on-demand exploration of the assignment space, rather than requiring a complete representation of all reasoning paths before inference begins. This opens substantial room for further improvements in pruning, region selection, and branching strategies.
References
[Augustine et al., 2022] Eriq Augustine, Connor Pryor, Charles Dickens, Jay Pujara, William Yang Wang, and Lise Getoor. Visual sudoku puzzle classification: A suite of collective neuro-symbolic tasks. In International Workshop on Neural-Symbolic Learning and Reasoning (NeSy), Windsor, United Kingdom, 2022.
[Badreddine et al., 2022] Samy Badreddine, Artur d'Avila Garcez, Luciano Serafini, and Michael Spranger. Logic tensor networks. Artificial Intelligence, 303:103649, February 2022.
[Biberstein et al., 2026] Paul Biberstein, Ziyang Li, Joseph Devietti, and Mayur Naik. Lobster: A GPU-accelerated framework for neurosymbolic programming. In Proceedings of the 31st ACM International Conference on Architectural Support for Programming Languages and Operating Systems, Volume 1, ASPLOS '26. ACM, 2026.
[Biewald, 2020] Lukas Biewald. Experiment tracking with weights and biases, 2020. Software available from wandb.com.
[Chakraborty et al., 2015] Supratik Chakraborty, Dror Fried, Kuldeep S. Meel, and Moshe Y. Vardi. From weighted to unweighted model counting. In Proceedings of the Twenty-Fourth International Joint Conference on Artificial Intelligence (IJCAI), 2015.
[Cornelio et al., 2023] Cristina Cornelio, Jan Stuehmer, Shell Xu Hu, and Timothy Hospedales. Learning where and when to reason in neuro-symbolic inference. In NeSy 2023, 17th International Workshop on Neural-Symbolic Learning and Reasoning, volume 3432 of CEUR Workshop Proceedings, 2023. Also published at ICLR 2023.
[Davis et al., 1962] M. Davis, G. Logemann, and D. Loveland. A machine program for theorem-proving. Communications of the ACM, pages 394–397, 1962.
[De Raedt et al., 2007] Luc De Raedt, Angelika Kimmig, and Hannu Toivonen. Problog: A probabilistic prolog and its application in link discovery. In IJCAI, pages 2468–2473, 2007.
[De Raedt et al., 2020] Luc De Raedt, Sebastijan Dumančić, Robin Manhaeve, and Giuseppe Marra. From statistical re-
lational to neural-symbolic artificial intelligence. In IJCAI, pages 4943–4950, 2020.
[Derkinderen et al., 2025] Vincent Derkinderen, Robin Manhaeve, Rik Adriaensen, Lucas Van Praet, Lennert De Smet, Giuseppe Marra, and Luc De Raedt. The deeplog neurosymbolic machine, 2025.
[Dubray et al., 2024] Alexandre Dubray, Pierre Schaus, and Siegfried Nijssen. Anytime weighted model counting with approximation guarantees for probabilistic inference. In 30th International Conference on Principles and Practice of Constraint Programming, pages 10:1–10:16, 2024.
[Huang et al., 2021] Jiani Huang, Ziyang Li, Binghong Chen, Karan Samel, Mayur Naik, Le Song, and Xujie Si. Scallop: From probabilistic deductive databases to scalable differentiable reasoning. In NeurIPS, pages 25134–25145, 2021.
[Kanda et al., 2021] Paul Shekonya Kanda, Kewen Xia, and Olanrewaju Hazzan Sanusi. A deep learning-based recognition technique for plant leaf classification. IEEE Access, 9:162590–162613, 2021.
[Lagniez and Marquis, 2017] Jean-Marie Lagniez and Pierre Marquis. An improved decision-DNNF compiler. In Proceedings of the Twenty-Sixth International Joint Conference on Artificial Intelligence (IJCAI), 2017.
[Lecun et al., 1998] Y. Lecun, L. Bottou, Y. Bengio, and P. Haffner. Gradient-based learning applied to document recognition. Proceedings of the IEEE, 86(11):2278–2324, 1998.
[Li et al., 2023] Ziyang Li, Jiani Huang, and Mayur Naik. Scallop: A language for neurosymbolic programming. In ACM on Programming Languages, pages 1463–1487, 2023.
[Maene et al., 2025] Jaron Maene, Vincent Derkinderen, and Pedro Zuidberg Dos Martires. Klay: Accelerating arithmetic circuits for neurosymbolic ai, 2025.
[Manhaeve et al., 2018] Robin Manhaeve, Sebastijan Dumančić, Angelika Kimmig, Thomas Demeester, and Luc De Raedt. Deepproblog: Neural probabilistic logic programming. In NeurIPS, pages 3753–3763, 2018.
[Manhaeve et al., 2021a] Robin Manhaeve, Sebastijan Dumancic, Angelika Kimmig, Thomas Demeester, and Luc De Raedt. Neural probabilistic logic programming in deep-problog. Artif. Intell., 298:103504, 2021.
[Manhaeve et al., 2021b] Robin Manhaeve, Giuseppe Marra, and Luc De Raedt. Approximate Inference for Neural Probabilistic Logic Programming. In Proceedings of the 18th International Conference on Principles of Knowledge Representation and Reasoning, pages 475–486, 11 2021.
[Naik et al., 2025] Aaditya Naik, Jason Liu, Claire Wang, Amish Sethi, Saikat Dutta, Mayur Naik, and Eric Wong. Dolphin: A programmable framework for scalable neurosymbolic learning. In ICML, 2025. arXiv:2410.03348.
[Paszke et al., 2019] Adam Paszke, Sam Gross, Francisco Massa, Adam Lerer, James Bradbury, Gregory Chanan, Trevor Killeen, Zeming Lin, Natalia Gimelshein, Luca
Antiga, Alban Desmaison, Andreas Köpf, Edward Yang, Zach DeVito, Martin Raison, Alykhan Tejani, Sasank Chilamkurthy, Benoit Steiner, Lu Fang, Junjie Bai, and Soumith Chintala. Pytorch: An imperative style, high-performance deep learning library, 2019.
[Pryor et al., 2023] Connor Pryor, Charles Dickens, Eriq Augustine, Alon Albalak, William Yang Wang, and Lise Getoor. Neupsl: Neural probabilistic soft logic. In Edith Elkind, editor, Proceedings of the Thirty-Second International Joint Conference on Artificial Intelligence, IJCAI-23, pages 4145–4153. International Joint Conferences on Artificial Intelligence Organization, 8 2023. Main Track.
[Sinha et al., 2019] Koustuv Sinha, Shagun Sodhani, Jin Dong, Joelle Pineau, and William L. Hamilton. CLUTRR: A diagnostic benchmark for inductive reasoning from text. arXiv preprint arXiv:1908.06177, 2019.
[Solko-Breslin et al., 2024] Alaia Solko-Breslin, Seewon Choi, Ziyang Li, Neelay Velingker, Rajeev Alur, Mayur Naik, and Eric Wong. Data-efficient learning with neural programs. In NeurIPS, 2024. arXiv:2406.06246.
[van Harmelen and ten Teije, 2019] Frank van Harmelen and Annette ten Teije. A boxology of design patterns for hybrid learning and reasoning systems, 2019.
[van Krieken et al., 2023] Emile van Krieken, Thiviyan Thanapalasingam, Jakub Tomczak, Frank van Harmelen, and Annette Ten Teije. A-nesi: A scalable approximate method for probabilistic neurosymbolic inference. In NeurIPS, pages 24586–24609, 2023. arXiv:2212.12393.
[van Krieken et al., 2025] Emile van Krieken, Pasquale Minervini, Edoardo Maria Ponti, and Antonio Vergari. Neurosymbolic diffusion models. In Advances in Neural Information Processing Systems, volume 38, 2025. arXiv:2505.13138.
[Vermeulen et al., 2023] Arne Vermeulen, Robin Manhaeve, and Giuseppe Marra. An experimental overview of neural-symbolic systems. In ILP, pages 124–138, 2023.
[Williams, 1992] Ronald J. Williams. Simple statistical gradient-following algorithms for connectionist reinforcement learning. Machine Learning, 8(3–4):229–256, 1992.
[Xu et al., 2018] Jingyi Xu, Zilu Zhang, Tal Friedman, Yitao Liang, and Guy Van den Broeck. A semantic loss function for deep learning with symbolic knowledge. In Jennifer Dy and Andreas Krause, editors, Proceedings of the 35th International Conference on Machine Learning, volume 80 of Proceedings of Machine Learning Research, pages 5502–5511. PMLR, 10–15 Jul 2018.
[Yang et al., 2020] Zhun Yang, Adam Ishay, and Joohyung Lee. Neurasp: Embracing neural networks into answer set programming. In Christian Bessiere, editor, Proceedings of the Twenty-Ninth International Joint Conference on Artificial Intelligence, IJCAI-20, pages 1755–1762. International Joint Conferences on Artificial Intelligence Organization, 7 2020. Main track.
A Termination and Correctness of DPNL
We prove that DPNL terminates and returns the exact probability associated with the target output.
For a valuation v, let
denote the set of unassigned variables. We define the completion probability of output o under v as
Thus, the values fixed by v are held fixed, while the remaining variables are independently distributed according to their input-dependent distributions.
These weights define a probability distribution over , since
For the empty valuation , this definition coincides with Eq. (1):
Theorem 2. For any input , output , valid oracle for the symbolic function , and valuation ,
In particular,
Proof. We proceed by induction on the number of unassigned variables in v:
Base case. Assume that . Then v is a total valuation and .
Since is a valid oracle, it always decides total valuations. Therefore,
By definition of the completion probability, and using the convention that an empty product equals 1,
Hence DPNL returns exactly , and terminates.
Induction step. Assume the theorem holds for every valuation with at most n unassigned variables. Consider a valuation v with .
There are three possible cases depending on the oracle output.
Case . By validity of the oracle, every total refinement of produces the output . Hence,
Since contains exactly all combinations of values of the variables indexed by , and each is a probability distribution,
DPNL returns 1, which is therefore the correct value.
Case . By validity of the oracle, no total refinement of produces the output . The sum defining the completion probability therefore contains no satisfying refinement, and
DPNL returns 0, which is the correct value.
Case . In this case, DPNL selects an index such that . The regions represented by the refinements , for , partition the region represented by .
For each ,
and every satisfies . Hence,
Therefore, partitioning the total refinements of v according to the value assigned to gives
For every , the valuation contains one fewer unassigned variable:
Hence, by the induction hypothesis,
DPNL
and each recursive call terminates.
Since
the recursive computation performed by DPNL returns
Since is finite and every recursive call decreases the number of unassigned variables, the current call also terminates.
Finally, for the empty valuation ,
and therefore
□
B Logic Oracle Construction
B.1 Logic-based characterization of symbolic functions
We consider symbolic functions over finite domains that can be characterized by logical reasoning. For each variable with finite domain , we associate each possible value with a logical formula expressing that . We assume that, for every , the formulas
are mutually exclusive and exhaustive.
For each output value , let denote a logical formula expressing that the symbolic function produces output .
Let T be a logical theory. We assume that the symbolic function S satisfies:
In other words, once all variables are assigned, the output of the symbolic function is determined by logical entailment.
For a valuation v, we define the theory induced by v as
Hence, a partial valuation corresponds to a partially instantiated logical theory.
B.2 Logic oracle
The logic oracle uses a decision procedure for the underlying logic to determine whether the current partial valuation is sufficient to decide the target output.
Algorithm 3: Logic oracle
Require: valuation v, target output o Ensure: oracle output if then else if then else end if
return r
B.3 Validity and completeness
Theorem 3. Assume that the logical consequence relation is sound. Then Algorithm 3 defines a valid oracle for S.
Proof. Let v be a valuation.
Assume first that the oracle returns 1 for target output o. Then
Let be any total refinement of . By definition of refinement, every formula induced by is also induced by , and therefore
By monotonicity of logical entailment,
Using the characterization of , we obtain
Hence every total refinement of produces output . Now assume that the oracle returns 0. Then
For any total refinement , we again have
and therefore
Consequently,
Hence no total refinement of produces output . Therefore the oracle is valid.
Theorem 4. Assume that the logical consequence relation is sound and complete. Then Algorithm 3 defines a complete oracle for .
Proof. Assume that the oracle returns for a valuation and output .
Then
and
By completeness of the logical consequence relation, there exists a model of such that
and a model of such that
For , define a valuation by
Because satisfies , all values fixed by v are preserved. Therefore,
Moreover, by the characterization of S,
and
Thus both a refinement producing o and a refinement not producing o exist in the region represented by v.
Therefore returning is correct, and the oracle is complete.
C Application to DeepProbLog
C.1 DeepProbLog as a logic-based symbolic function
DeepProbLog provides a natural instance of the logic-based symbolic functions considered in Section B.
A DeepProbLog program combines deterministic logic rules with neural predicates. The outcomes of neural predicates define the intermediate variables , while the deterministic logic program defines the symbolic function S.
Consider a DeepProbLog query q and let T denote the deterministic part of the program. For a complete valuation v, let denote the set of neural facts corresponding to the values fixed by v.
The symbolic function associated with the query is defined as
Therefore, DeepProbLog fits the logic-based characterization introduced in Section B, where the formulas associated with the values of neural predicates correspond to the possible neural facts.
C.2 DeepProbLog oracle
For DeepProbLog programs without negation, the logic oracle can be implemented using the underlying Prolog inference procedure.
For the Boolean query setting of DeepProbLog, we consider and focus on the target output .
For a partial valuation , let denote the neural facts fixed by . Let denote the optimistic completion of , obtained by assuming all unassigned predicates are true.
The oracle is defined as follows:
Algorithm 4: DeepProbLog oracle
Require: valuation v if then return 1 else if then return 0 else return * end if
The oracle is valid because DeepProbLog programs without negation are monotonic: adding additional neural facts cannot invalidate an existing proof.
The first case certifies that every completion of the current valuation produces the query, while the second case certifies that no completion can produce it. Otherwise, further exploration is required.
C.3 Representing probabilistic choices
DeepProbLog represents probabilistic choices through mutually exclusive outcomes, rather than independent Boolean facts.
For a categorical variable with outcomes , directly introducing independent probabilistic facts would incorrectly allow several outcomes to hold simultaneously. DeepProbLog therefore uses annotated disjunctions (ADs) and neural annotated disjunctions (nADs) to represent such choices.
This transformation introduces auxiliary logical variables and rules. Consequently, the logical representation used for provenance-based inference may become substantially larger as the number of probabilistic choices increases.
DPNL does not require this complete logical representation to be materialized: its oracle-guided exploration can reason directly over regions of the assignment space.
C.4 Example: Graph reachability
Consider a probabilistic directed graph where each potential edge is represented by a neural predicate edge .
The query asks whether a target node is reachable from a source node. The deterministic rules can be written as
The corresponding symbolic function returns 1 when the query reachable( ) can be proved.
A provenance-based approach constructs a logical formula representing all possible paths between the source and target nodes. In a dense graph, the number of such paths can grow exponentially with the number of nodes.
In contrast, the DeepProbLog oracle can reason directly over partial valuations. For example, if a reachable path is already established by the currently assigned edges, the region can immediately be accepted without enumerating the remaining edges. Conversely, if reachability is impossible even when all unknown edges are assumed present, the whole region can be rejected.
This illustrates how DPNL can exploit logical reasoning directly during inference instead of first materializing the complete provenance.
D Variable Selection Heuristics
The choice of the next variable to refine determines the structure of the exploration tree and can substantially affect the number of recursive calls required by DPNL.
Correctness and termination do not depend on this choice, as every branching step reduces the number of unassigned variables. However, problem-specific heuristics may significantly improve pruning efficiency.
When the oracle is complete, a partial valuation v returning indicates that the region represented by v contains both successful and unsuccessful total refinements. In principle, a complete oracle may provide information about refinements leading to each outcome. This suggests a branching heuristic that prioritizes variables that are likely to separate such refinements. More precisely, if the oracle can provide witness refinements
such that
and
one may prioritize variables for which
Such variables directly distinguish regions that respectively contribute to or exclude the target output and may lead to smaller exploration trees. Designing effective variable-selection heuristics based on oracle information is an interesting direction for future work.
E Experimental Details
E.1 Hardware
The symbolic experiments are executed on an Apple MacBook Pro (M1 Max) with 64GB RAM. The neurosymbolic experiments on Leaf and MNIST-N-SUM are executed on a CPU-only Dell Precision 7960 workstation with an Intel Xeon w5-3425 processor (12 cores, 24 threads, 3.2 GHz base and 4.6 GHz turbo frequency) and 512GB RAM. The Visual Sudoku experiments are executed on a server with two Intel Xeon Silver 4114 processors (10 cores and 20 threads each, 2.2 GHz base and 3.0 GHz turbo frequency), 187GB RAM and an NVIDIA Quadro P5000 GPU.
E.2 Implementation Details
The DPNL framework is implemented in a modular and extensible Python codebase centered around symbolic reasoning with probabilistic inputs. It introduces a unified abstraction for defining symbolic functions, managing structured probabilistic inputs, and executing exact inference using oracle-guided recursive evaluation. The implementation relies on Pytorch [Paszke et al., 2019] and uses Weights and Biases [Biewald, 2020] as experiment tracking tool.
Core Abstractions. At the heart of the system is the Symbolic class, an abstract interface for symbolic functions S, and the Input class, which represents structured inputs composed of random variables (RndVar). Each RndVar has a discrete domain and a probability distribution, and may be left undefined (unknown) until instantiated during inference.
Oracle Mechanism. DPNL oracles implement the Oracle interface, which answers whether is always true, always false, or unresolved for a given (possibly partial) valuation v and output o. Multiple oracle variants are supported:
• Enumeration Oracle: A naive baseline that returns unknown if any variable in I is undefined. Useful as a reference implementation for exact inference.
• Basic Oracle: Executes and traps access to undefined variables to detect when the computation depends on an unassigned variable.
• Logic Oracle: Implementation of the procedure to obtain a logic oracle given an interface with a logic, its solver and the function S.
• Combination Oracle: Sequentially tries multiple oracles, falling back as needed to obtain stronger pruning or efficiency.
Recursive Inference. The PNLProblem class wraps a symbolic function and input. It computes the probability that via recursive branching over undefined variables, guided by the oracle.
SAT Logic Integration. We implemented an interface for the Logic Oracle with the Boolean logic and SAT solvers for the experiments. The SATLogic class encodes formulas using literals, clauses, and conjunctions, and interfaces with a SAT solver (e.g., MiniSAT). Symbolic functions defined in SAT are specified through the SATLogicSymbolic interface, which supports variable declarations, clause generation, and relational constraints over domains to easily define . This enables symbolic functions to be expressed and reasoned about at the propositional level, improving pruning and solver performance. This experimental instantiation is only one possible implementation of the generic logic oracle interface.
E.3 Hyperparameters.
The hyperparameters used in the experiments are summarized in Table 6. We keep the hyperparameters constant across the experiments with different numbers of digits. Further, we conduct 10 independent runs with different random seeds for DPNL. We enforce computational timeout: 24h for and 48h for . For Visual Sudoku we enforce a computational timeout of 48h.
MNIST Classifier. We follow [Manhaeve et al., 2018] and use the following neural network architecture as digit classifier. It consists of two convolutional layers with kernel size 5 and output dimension 6 and 16 (nn.Conv2d(1, 6, 5) and nn.Conv2d(6, 16, 5),) followed by Max pooling and Relu activation (nn.MaxPool2d(2, 2)). A classifier with three linear layers is stacked which have the dimensions 120 and 84 respectively. The output dimension corresponds to the number of digits and equals 10.
E.4 Baselines
To obtain the results with the baselines for the MNIST-N-Sum task, we used the source code from the following publicly available code repositories:
- DeepProbLog & DPLA*:
https://github.com/ML-KULeuven/deepproblog
-
A-Nesi: https://github.com/HEmile/a-nesi
For the Leaf task, all baselines were reproduced with the code from the ISED repository: https://github.com/alaiasolkobreslin/ISED.
A-Nesi. We conduct five independent runs with different random seeds for each experiment. Table 7 shows the hyperparameters used for configurations used for the different variants of A-Nesi [van Krieken et al., 2023].
| Key | Explain | Predict Only | Prune |
|---|---|---|---|
| amt_samples | 600 | 600 | 600 |
| K_beliefs | 2500 | 2500 | 2500 |
| nrm_lr | 0.001 | 0.001 | 0.001 |
| perception_lr | 0.001 | 0.001 | 0.001 |
| dirichlet_lr | 0.01 | 0.01 | 0.01 |
| dirichlet_iters | 50 | 50 | 50 |
| dirichlet_init | 0.1 | 0.1 | 0.1 |
| dirichlet_L2 | 900000 | 900000 | 900000 |
| nrm_loss | mse | mse | mse |
| hidden_size | 800 | 800 | 800 |
| layers | 3 | 3 | 3 |
| prune | False | False | True |
| predict_only | False | True | False |
| use_prior | True | True | True |
Table 7: Table of hyperparameters of A-Nesi for the variants explain, predict only, and prune.
Scallop. Since Scallop has been only applied to the MNIST-1-SUM task [Huang et al., 2021], we extend the experiments with Scallop to the MNIST-N-SUM task for in order to use it as baseline. The logic programs are given in Listing 1. We use Scallop with exact as well as with approximate reasoning. For approximate reasoning of Scallop we choose the diff-top-k-proof semiring with , as recommended in [Huang et al., 2021]. To investigate the performance of Scallop with exact reasoning, we choose in a way that the logic provenance formula is in any case smallle than and is consequently not pruned. In particular, we choose for every MNIST-N-SUM task depending on N:
This way, represents an upper bound for the length of the logical provenance formula.
DPLA*. DPLA* employs heuristics to estimate the probability of partial proofs to search for the best proof. Here, we use the geometric mean heuristic [Manhaeve et al., 2021b].
1 # N=1 2 self.scl_ctx.add_rule("summand_one(a) :- digit_1(a)") 3 self.scl_ctx.add_rule("summand_two(a) :- digit_2(a)") 4 # N=2 5 self.scl_ctx.add_rule("summand_one(10 * a + b) :- digit_1(a), digit_2(b)") 6 self.scl_ctx.add_rule("summand_two(10 * a + b) :- digit_3(a), digit_4(b)") 7 # N=3 8 self.scl_ctx.add_rule("summand_one(10 * 10 * a + 10 * b + c) :- digit_1(a), digit_2(b), digit_3(c)") 9 self.scl_ctx.add_rule("summand_two(10 * 10 * a + 10 * b + c) :- digit_4(a), digit_5(b), digit_6(c)") 10 # N=4 11 self.scl_ctx.add_rule("summand_one(10 * 10 * 10 * a + 10 * 10 * b + 10 * c + d) :- digit_1(a), digit_2(b), digit_3(c), digit_4(d)") 12 self.scl_ctx.add_rule("summand_two(10 * 10 * 10 * a + 10 * 10 * b + 10 * c + d)
| Engine | t (s) | Epochs | Batch | Pretrain | Test (s) | ||
|---|---|---|---|---|---|---|---|
| Leaf | |||||||
| - | exact | - | - | 50 | 4 | - | - |
| MNIST-N-SUM (basic oracle) | |||||||
| exact | - | - | 1 | 2 | - | - | |
| anytime | 0.006 | - | 1 | 2 | - | 1 | |
| anytime | 0.025 | - | 1 | 2 | - | 1 | |
| anytime | 0.25 | - | 1 | 2 | - | 1 | |
| anytime | 0.25 | - | 10 | 16 | - | 100 | |
| -approx. | - | 0.5 | 1 | 2 | - | - | |
| -approx. | - | 0.4 | 1 | 2 | - | - | |
| Visual Sudoku (Sudoku oracle) | |||||||
| exact | - | - | 10 | 1 | - | - | |
| anytime | 0.08 | - | 10 | 1 | - | - | |
| -approx. | - | 10 | 1 | - | - | ||
| anytime | 0.25 | - | 25 | 16 | 4 ep. | 200 | |
Table 6: Hyperparameters for the neuro-symbolic experiments Leaf, MNIST-N-Sum and Vsudoku. All runs use the Adam optimiser with learning rate 1e-3 (1e-4 for Leaf), and CPU-only execution. is the per-sample symbolic timeout for Anytime ApproxDPNL and the error budget. For Visual Sudoku N9 and MNIST N8, a higher timeout at inference is used. Classifier pretraining uses batch size 32 and learning rate 1e-3. The total training timeout is 24–48 h for MNIST-N-SUM, 24 h (exact) and 5 h (anytime, -approx.) for Visual Sudoku , and 48 h for .
) :- digit_5(a), digit_6(b), digit_7(c), digit_8(d)"
Listing 1: Rules used in Scallop for the MNIST-N-SUM task