Probabilistic Logic Programming (PLP) languages, like ProbLog, naturally support reasoning under uncertainty, while maintaining a declarative and interpretable framework. Meanwhile, counterfactual reasoning (i.e., answering ``what if'' questions) is critical for ensuring AI systems are robust and trustworthy; however, integrating this capability into PLP can be computationally prohibitive and unstable in accuracy. This paper addresses this challenge, by proposing an efficient program transformation for counterfactuals as Single World Intervention Programs (SWIPs) in ProbLog. By systematically splitting ProbLog clauses to observed and fixed components relevant to a counterfactual, we create a transformed program that (1) does not asymptotically exceed the computational complexity of existing methods, and is strictly smaller in common cases, and (2) reduces counterfactual reasoning to marginal inference over a simpler program. We formally prove the correctness of our approach, which relies on a weaker set independence assumptions and is consistent with conditional independencies, showing the resulting marginal probabilities match the counterfactual distributions of the underlying Structural Causal Model in wide domains. Our method achieves a 35% reduction in inference time versus existing methods in extensive experiments. This work makes complex counterfactual reasoning more computationally tractable and reliable, providing a crucial step towards developing more robust and explainable AI systems. The code is at https://github.com/EVIEHub/swip.
Figures & tables
Figure 1: A causal diagram with variables L , D , G , and H . The corresponding SCM declares H as a function of A , B and C , D as a function of G and L , and L as functions of G .
Figure 2: Side-by-side comparison of (a) the original structural causal model and (b) its corresponding twin network construction.
Figure 3: SWIG where intervention fix(L=l) is acted
Figure 4: Construction of benchmark DAGs. A random tree of size n rooted at s (top) is generated, a dense layer of k nodes u1,…,uk is added below (each receiving edges from multiple tree nodes), and a single goal node g is appended below the dense layer receiving edges from every ui .
Figure 5: Unfolded treewidth as a function of synthetic graph size and original treewidth. The SWIG-based transformation yields narrower unfolded dependency structures than the Twin Network approach.
Figure 6: Mean compilation and inference times for varying numbers of evidence and intervention atoms. The SWIG-based transformation achieves lower inference and compilation times, corresponding to its smaller unfolded program structures.
Appendix figures & tables3 assets
Supplementary material from the paper’s appendix.
Appendix
Symbol
Definition
V
Set of endogenous variables
U
Set of exogenous variables
F
Set of functional equations
pa(X)
Set of endogenous parents of x
M
Structural causal model (SCM): tuple of ⟨U,V,F⟩
X:=fX(pa(X),ϵX)
Structural equation for variable X w
Appendix
Table 1: Summary of key notation used throughout the paper.
πl(ϕ):={1,0,I(l)⊨(E=e)∧Pσ(l),do(X:=x)⊨ϕelse.
Appendix
Algorithm 5 Treatment of Counterfactuals in CP-logic
πl(ϕ):={1,0,I(l)⊨(E=e)∧Pσ(l),fix(X:=x)⊨ϕelse.
Appendix
Algorithm 6 Fixed Operator Counterfactuals in CP-logic
Neurosymbolic systems such as DeepProbLog combine neural perception with probabilistic logic, but standard inference is associational. Counterfactual reasoning additionally requires a causal semantics for interventions and evidence. We introduce DeepSWIP, a single-world counterfactual semantics for DeepProbLog programs. Using neural materialization, we reduce fixed-context neural predicates to ordinary ProbLog choices, apply Single World Intervention Programs (SWIPs), and compute counterfactuals by weighted model counting (WMC) over a single transformed program. Under finite grounding and unique-supported-model assumptions, DeepSWIP is exact relative to the learned materialized FCM. The standard quotient-WMC form of ProbLog conditionals identifies active neural probabilities and explains intervention cleaning, calibration sensitivity, and rare-evidence instability. Experiments on MPI3D confirm the transformation against a DeepTwin construction against 12,000 queries, as predicted and a 2.14× inference speedup from avoiding the Twin's endogenous duplication. A SUMO HOV experiment shows that neural calibration degradation biases plug-in estimates, while a correctly scoped randomized-policy AIPW estimator removes most first-order bias for population mean and ATE estimands. Code is at https://github.com/saibib/deep_SWIP.
Probabilistic logic programming is a formalism of statistical relational artificial intelligence that supports causal queries, including interventions from outside the system. When the structure of a probabilistic logic program is learned from data, however, only probabilistic information is used, and a single probability distribution may be compatible with several causal orders. This leads to ambiguity in interventional reasoning, raising the question of when the causal order is uniquely determined by the distribution. Exploiting the relationship between acyclic probabilistic logic programs and Bayesian networks, we derive conditions under which the probabilistic information encoded in a program determines a unique causal order. We also incorporate constraints arising from relational structure by taking into account prescribed sets of causal symmetries induced by the underlying relational vocabulary. The result is a method for verifying when a learned probabilistic logic program supports well-defined intervention semantics.
Zora Wurm, Kilian Rückschloß, Felix Weitkämper
Ludwig-Maximilians-Universität München, Oettingenstraße 67, 80538 München · Eberhard-Karls-Universität Tübingen, Auf der Morgenstelle 10, 72076 Tübingen · German University of Digital Science, Marlene-Dietrich-Allee 14, 14482 Potsdam
Pearl famously argues that causal knowledge enables the prediction of intervention effects. By contrast, purely descriptive knowledge supports only conclusions drawn from observations. His theory of causality, however, is developed exclusively within Bayesian networks and causal models. Consequently, it is largely restricted to acyclic causal relationships, and transferring its ideas to other formalisms risks misinterpretation or inconsistency. This paper brings Pearl's approach to causality into probabilistic logic programming (PLP). To this end, such programs are aligned with philosophical foundations established in prior work that do not rely on temporal notions; that is, all relevant events are assumed to occur simultaneously. A formal causal semantics for these programs, together with a notion of intervention and an implementation, is proposed. It is shown that this semantics coincides with the P-log semantics for stratified ProbLog programs, while the two may differ in the non-stratified case and for other PLP formalisms.
Kilian Rueckschloss, Felix Weitkaemper
Eberhard Karls Universitaet Tuebingen · University of Tübingen Tübingen, Germany · German University of Digital Science +1