arXiv:2608.21141cs.DBAug 2026

Manuscript Offprint

arXiv:2608.21141

Causal Explanations for Stratified Datalog

Ratan Bahadur Thapa, Steffen Staab

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Rule-based reasoning with exceptions requires causal explanations that account for both present and absent facts. For positive Datalog, monotonicity allows minimal supports to determine deletion causality. Stratified negation removes that property because inserting or deleting a fact may create or destroy an answer. We study actual causes, responsibility, and robustness for safe and stratified Datalog under perfect-model semantics and interventions over a finite set of mutable extensional facts. We prove that minimal supports and inclusion-minimal outcome-changing interventions do not determine causality, while robustness radius one may coexist with unbounded minimum contingencies. Our main result characterizes the minimum contingency size of a candidate fact by compatible prime implicants for the observed and opposite outcomes. The characterization conservatively recovers support-based causality for positive Datalog and yields path-cut characterizations for blocked recursive reachability. For fixed nonrecursive stratified programs, we establish data-complexity NP-completeness for cause recognition, robustness, and responsibility, and coNP-completeness for intervention-response equivalence between two such programs.

1 Introduction

Rule-based systems often derive conclusions subject to exceptions. An eligibility decision may require a qualification and the absence of an exclusion; an access decision may hold unless a revocation is derived; and a diagnosis may remain valid unless a contraindication is established. Explaining such conclusions requires reasoning about both present and absent facts. Stratified datalog gives such rules a deterministic declarative semantics while retaining recursion and polynomial-time data evaluation (Abiteboul, Hull, and Vianu 1995; Apt, Blair, and Walker 1988). We study causal explanation for a ground conclusion over a finite set of mutable extensional facts. At an observed input, we ask which present or absent fact can become pivotal under a contingency, how strongly it is responsible, and how many changes are required to reverse the answer.

To make these questions concrete, we begin with an example that introduces the relevant causal quantities. Consider the Datalog program Πex\Pi_{ex}

approve(x)←eligible(x),¬blocked(x),blocked(x)←violation(x),blocked(x)←highRisk(x),¬reviewed(x).\begin{array}{r l}{\mathrm{a p p r o v e}(x)}&{\leftarrow\mathrm{e l i g i b l e}(x),\neg\mathrm{b l o c k e d}(x),}\\ {\mathrm{b l o c k e d}(x)}&{\leftarrow\mathrm{v i o l a t i o n}(x),}\\ {\mathrm{b l o c k e d}(x)}&{\leftarrow\mathrm{h i g h R i s k}(x),\neg\mathrm{r e v i e w e d}(x).}\end{array}

(★)

Let Dx=∅D^x = \varnothing, E={highRisk(a)}E = \{highRisk(a)\}, A=approve(a)A = approve(a), and U={eligible(a),violation(a),highRisk(a),reviewed(a)}\mathcal{U} = \{eligible(a), violation(a), highRisk(a), reviewed(a)\}, where DxD^x is the fixed extensional database whose facts cannot be changed, EE is the observed mutable input, U\mathcal{U} is the finite set of mutable extensional facts that may be inserted or deleted, and AA is the ground goal. An intervention J⊆UJ \subseteq \mathcal{U} is applied by changing the membership in EE of every atom in JJ. Thus, the intervention toggles every atom in JJ, inserting those absent from EE and deleting those present in EE.

At EE, the goal AA is false. The singleton intervention J={eligible(a)}J = \{eligible(a)\} leaves it false: since highRisk(aa) is present and reviewed(aa) is absent, the last rule derives blocked(aa). Inserting reviewed(aa) alone also leaves AA false because eligibility is absent. However, inserting both reviewed(aa) and eligible(aa) makes AA true, because eligibility and review are present and violation is absent. Thus, eligible(aa) is an actual cause of the false outcome with a contingency Γ={reviewed(a)}\Gamma = \{reviewed(a)\} for that cause. The responsibility of a cause with minimum contingency size kk is 1/(k+1)1/(k+1). Since the contingency Γ\Gamma is minimum and ∣Γ∣=1|\Gamma| = 1, the responsibility of eligible(aa) is 1/(∣Γ∣+1)=1/21/(|\Gamma| + 1) = 1/2. Robustness is the minimum size of an intervention that reverses the observed outcome. Therefore, the robustness value is 2 in this instance because the above intervention of size ∣J∣=2|J| = 2 makes AA true, whereas no singleton intervention does.

The program Πex\Pi_{ex} also explains why absence conditions matter. The absence of eligible(a) at E is sufficient for the false outcome. The true outcome requires eligible(a) and the absence of violation(a), together with either the absence of highRisk(a) or the presence of reviewed(a). The false and true conditions disagree on the value of eligible(a). Once this atom is treated as the candidate cause, either deleting highRisk(a) or inserting reviewed(a) before toggling it yields a minimum contingency of size one. To illustrate deletion-based causality, consider instead

E′={eligible(a),highRisk(a),reviewed(a)}.E^{\prime}=\{\mathrm{eligible}(a),\mathrm{highRisk}(a),\mathrm{reviewed}(a)\}.

∗^{*}With Extended Proofs and Supplementary Results

Then, approve(a) holds under Πex\Pi_{ex} at the alternative observed state E′E'. A fact in the observed state is a deletion cause if

†^{\dagger}Corresponding Author: ratan.thapa@ki.uni-stuttgart.de deleting it reverses the outcome, possibly after a contingency that alone preserves the outcome. Deleting reviewed(a) activates the blocking rule and therefore makes the approval false. Thus, in the alternative observed state E′E', reviewed(a) is a deletion cause with the empty contingency Γ=∅\Gamma = \varnothing.

This nonmonotonic behavior shows why the positive-Datalog support representation does not extend to stratified negation. A minimal support is an inclusion-minimal set of mutable facts deriving an answer; by monotonicity, an answer holds exactly when its input contains one. In the deletion-based causality, the resulting support hypergraph determines deletion causes, responsibility, and robustness (Thapa and Staab 2026). Under stratified negation, minimal supports omit necessary absences, and inclusion-minimal outcome-changing interventions can omit atoms pivotal only at states farther from the observation. We prove that neither representation determines actual causes or responsibilities and that a robustness radius of one can coexist with unbounded minimum contingencies.

Database causality defines actual causes, contingencies, and responsibility for query answers and non-answers (Meliou et al. 2010a,b), while prime implicants encode inclusion-minimal partial assignments forcing a Boolean outcome (Darwiche and Ji 2022; Dubslaff et al. 2022). Feature-causality accounts minimize simultaneous changes containing the candidate without requiring the remaining changes alone to preserve the observed outcome. We instead pair compatible observed- and opposite-outcome implicants containing complementary candidate literals. Compatibility enforces this intermediate-state condition, and minimum pair cost gives the minimum contingency size for every finite Boolean response. For stratified Datalog, we construct both prime families compositionally through stratum-wise perfect-model evaluation. For blocked recursive reachability, we derive path-cut pairs and an exact responsibility formula.

Our contributions are as follows: (i) in Section 4, we prove that minimal supports and inclusion-minimal outcome-changing interventions do not determine causality, establish an unbounded separation between robustness and minimum contingency size, and prove the compatible prime-pair characterization and its positive Datalog specialization; (ii) in Section 5, we derive the recursive path-cut characterization and exact responsibility formula, and show that explicit prime families may be exponential although the corresponding causal quantities remain polynomial-time computable; and (iii) in Section 6, we establish data-complexity bounds for fixed programs and goal predicates, with the database-level objects supplied as input.