WorksComputer Science
Formal Explanations for Linear Temporal Logic over Finite Traces
Abstract
Linear Temporal Logic over Finite Traces (LTLf) is widely used in Artificial Intelligence to specify desired temporal behavior and determine whether finite traces satisfy or violate it. Explaining these outcomes is essential for debugging and trust. However, existing approaches typically capture either sufficient reasons or counterfactual causes, without clarifying their relationship. We introduce a native characterization of abductive (AXps) and contrastive (CXps) explanations directly over finite traces, based on locking and unlocking time-indexed events. We prove its equivalence to the classifier-based formulation, and show that CXps coincide with a recently proposed temporal causality semantics for LTLf. This characterization enables an efficient implementation based on the enumeration of minimal unsatisfiable cores and minimal correction sets of ASP programs. Experiments on real-world event logs demonstrate the effectiveness of the approach.

Figure 1. AXps (sufficient reasons) and CXps (minimal outcome-flipping interventions) for on a compliant trace and a violating trace . Sets are listed state by state; e.g. denotes .
Introduction
Linear Temporal Logic over Finite Traces [10] () is a popular formalism for temporal reasoning in AI. It has been successfully applied to several domains, such as reinforcement learning [8], planning [2, 9], robotics [26] and business process management [40, 7].
In applications, formulas are used to describe desired behavior. A formula may describe the dynamics of a system, or the goals driving an agent’s behavior. Traces (interpretations) represents states of a system over time, or a sequence of actions performed by an agent. When a trace satisfies a formula , we say that complies with the specification; otherwise, it violates it. In either case, being able to explain why is important.
Figure 1 illustrates the explanation problem via an autonomous delivery agent subject to which requires every request to be eventually served and every low-battery to be immediately followed by charging. The trace (of Figure 1) satisfies , but this alone does not explain why. We focus on two complementary kinds of explanation. A sufficient reason is a set of time-indexed events and non-events that guarantees satisfaction: for , the absence of throughout the trace already guarantees satisfaction of the charging obligation, no matter how the remaining observations are altered. A minimal intervention is a minimal set of observations whose change flips the outcome: adding to the first time instant of not followed by turns it into a violating trace. Conversely, violates : here a sufficient reason guarantees the violation (e.g., knowing only that holds at the second time instant and is absent at the third time instant makes every trace agreeing with these two observations violate ), while minimal interventions restore satisfaction. Thus the explanation problem answers two complementary questions: why does the trace satisfy or violate the specification? and what must change to obtain the opposite outcome?
These two kinds of explanation are precisely the central notions of formal explainable AI (FXAI) [25, 39]: abductive (AXps) and contrastive (CXps) explanations. Given a classifier and an input instance, an abductive explanation is a subset of feature values sufficient to guarantee the predicted class, whereas a contrastive explanation is a subset of features whose change yields a different class. Importantly, subset-minimal abductive and contrastive explanations are related by hitting-set duality [24, 37], which also supports effective enumeration algorithms [27]. In principle, an formula can be cast as a binary classifier over time-indexed propositions, making these notions formally applicable. However, this encoding is not the usual way temporal formulas are understood and makes it harder to see explanations as observations that are kept fixed or allowed to change. Thus, a native characterization of AXps and CXps for is missing. Existing approaches capture either sufficient reasons for satisfaction [12] or counterfactual causes of violation [33], but none connects the two perspectives or grounds them in hitting-set duality. We fill this gap through the simple operations of locking and unlocking temporal observations: locked observations play the role of the feature values an AXp keeps fixed, whereas unlocked ones are those a CXp is allowed to alter. AXps and CXps are thus defined directly over finite traces, with no classifier-based reformulation. Our contributions are threefold: (i) we characterize AXps and CXps for the satisfaction and violation of specifications, directly over finite traces; (ii) we prove that this characterization is equivalent to the classifier-based one, establish the hitting-set duality between AXps and CXps for , and show that CXps coincide with the temporal causes of [33] under fixed-length interventions; (iii) we reduce their computation to the enumeration of minimal unsatisfiable subsets and minimal correction sets, implement the approach in Answer Set Programming (ASP) [19, 4], and evaluate it on real-world event logs.
Related Work
Formal Explanations.
Our work instantiates the general framework of abductive and contrastive explanations [39, 25, 24, 6] in the setting of . However, the standard formulation treats the object being explained as a classifier over features. While this viewpoint is formally applicable to , it is not natural for temporal-logic practitioners. We therefore provide an equivalent characterization stated directly in terms of formulas and finite traces. Similar specializations have been developed for settings in which the object being explained is not naturally represented as a classifier, such as ranking functions [5] and finite-state machines [20]. Our work follows the same direction by providing a specialization for formulas.
Temporal Implicants & Temporal Causality.
Implicants are partial interpretations guaranteeing a propositional formula’s truth or falsity and, for propositional binary classifiers, coincide with abductive explanations [24]. In LTL, temporal implicants have only been studied under infinite-trace semantics [12], and implemented with a greedy algorithm computing a single, possibly non-minimal implicant. The connection to unsatisfiable cores is mentioned as a related problem but not further developed. We instead address finite traces, recast the problem in the FXAI framework, and provide an efficient implementation based on unsatisfiable cores and correction sets.
A recent work by [33] proposes a revised version of cause for , specializing the Halpern’s [22]. It extends earlier works [3] that considers only singleton causes, to conjunctive causes. Neither line addresses the dual notion of sufficient reasons for satisfaction or violation. We will prove that this notion is closely related to CXps.
Unsatisfiable Cores in Temporal Reasoning.
Minimal unsatisfiable cores and correction sets [28, 32] are at the base of our implementation. admits notions of unsatisfiable cores [38], whose computation has been the focus of recent works [38, 34, 15, 23]. Unsatisfiable cores explain why a formula is unsatisfiable, whereas abductive explanations answer why a trace violates/satisfies a formula. The first is a form of global explanation, the latter is a form of local explanation [21, 31]. Our implementation is based on bounded satisfiability [14], obtaining AXps and CXps as unsatisfiable cores and correction sets of a logic program [1]. The underlying solver is based on SAT techniques [27].
Answer Set Programming
An atom is an expression of the form where is a predicate, are terms (i.e., constants, integer numbers, strings or variables), and is known as arity of the predicate. A literal is either an atom or its negation , where denotes the negation as failure. A rule is an expression of the form where is an atom referred to as head, denoted by , that can also be omitted, , and is a conjunction of literals referred to as body, denoted by . In particular, a rule is said to be a constraint if its head is omitted, while it is said to be a fact if . A rule is safe if each variable appears at least in one positive literal in the body of . A program in ASP is a finite set of safe rules. Given a program , and , is the set of ground instantiations of obtained by replacing variables in with constants in ; whereas is the union of ground instantiations of rules in . Given a program , the Herbrand’s base of , denoted by , is the set of atoms constructible from constants and predicate names occurring in . An interpretation for is a subset of , which is an answer set of if (i) is a model, i.e., for each rule either the head of is true wrt or the body of is false wrt ; and (ii) is a minimal model of its GL-reduct [19].
Minimal Unsatisfiable Subprograms.
Consider a program and a set of objective atoms . For , is the program obtained from by adding a choice over atoms in (i.e., , for ) and a set of constraints of the form , for every . Intuitively, augments the program in such a way that the objective atoms can be arbitrarily chosen (i.e. either as true or false) but the atoms in are enforced to be true. An unsatisfiable subset for wrt the set of objective atoms is a set of atoms such that is incoherent [1]. denotes the set of unsatisfiable subsets of wrt . An unsatisfiable subset is a minimal unsatisfiable subset (MUS) of wrt iff for every , . An answer set of is minimal wrt iff there exist no other answer set of such that [1].
More details on ASP are available in [19, 4, 17, 29].
Linear Temporal Logic on Finite Traces
Linear Temporal Logic on Finite Traces () [10] is a variant of Linear Temporal Logic () [36] where the models, called traces, are assumed to be finite. An formula over the alphabet is defined according to the following grammar:
where (“Next”) and (“Until”) are temporal operators. Standard propositional boolean (, , , , ), and temporal (e.g., Eventually F, Always G, Weak Next X and Release R) shorthands are defined as usual. An interpretation is a finite trace , with . is the trace length, and is the -th state of . The satisfaction relation is defined inductively as follows:
iff
iff
iff and
iff and
iff there exists with such that and for all with ,
is a model of if , denoted as . We denote by the set of models of , that is . The satisfiability problem for , i.e., deciding whether there exists a trace such that , is PSPACE-complete [10]. Complexity drops to NP-complete restricting the problem to traces of bounded length [13].
Formal Explanations
Let be a finite set of features. Each feature is associated to a finite domain . The corresponding feature space is the Cartesian product of the feature domains, . Each element is a total assignment of values to the features, with for every . We refer to such an assignment as an instance. A classifier is a total function , where is a finite set of class labels. Given and two instances , we say and are compatible in and write if, and only if,
An explanation problem is a tuple , where is a classifier, is an instance, and is a class label such that . Two main types of formal explanations are in the literature: abductive (AXp) and contrastive (CXp) explanations. An abductive explanation for answers the question Why was class assigned to ?, while a contrastive explanation addresses the question Why was not assigned a class different from ?.
Weak Abductive Explanations (WAXp).
We say that is a WAXp for if the following holds:
Weak Contrastive Explanations (WCXp).
We say that is a WCXp for if the following holds:
Intuitively, an abductive explanation identifies a set of feature values that is sufficient to guarantee the prediction , that is once the feature in are fixed to the values they assume in , every compatible instance is still classified as . Instead, a contrastive explanation identifies a set of features whose values can be changed to alter the prediction, that is, keeping all features outside fixed to the values in , there exists an assignment to the features in for which the classifier outputs a class different from . Subset-minimal WAXp and WCXp are called abductive explanations (AXp) and contrastive explanations (CXp), respectively. AXps and CXps are related by hitting-set duality: every AXp is a minimal hitting set of the set of all CXps, and vice versa [24].
AXp and CXp for
In this section, we reformulate abductive and contrastive explanations for . In the rest of the paper, we fix a finite alphabet and a trace length . We assume all traces are sequences in .
Notation. We adopt a set-based representation of traces based on temporal literals. Let denote the set of time-indexed atoms, where indicates that holds at time instant . The set of temporal literals is defined as For every temporal literal , we denote by its underlying time-indexed atom, i.e., and . Similarly, denotes the opposite literal, that is, and . A set of temporal literals is said to be invalid if it contains both a literal and its complement, valid otherwise, and complete if, for every , exactly one of or belongs to . A trace is represented by the valid, complete set of temporal literals:
For instance, the violating trace of Figure 1, of length , is represented by . Given a set of temporal literals , two traces and are compatible on if they agree on every literal in , that is, . Accordingly, we define the set of all traces compatible with on as:
Intuitively, consists of all traces having the same length of that preserve the behavior of specified by in terms of events happening (positive literals) and not happening (negative literals). Since is not required to be complete, only the events explicitly described by its literals are fixed, while all remaining propositions at all time instants are left unconstrained.
Explanation problem. An explanation problem is a tuple , where is a trace and is an formula. We now reformulate weak abductive and weak contrastive explanations using the notation introduced above. Since , we focus on explanation settings such that without loss of generality. The complementary case is handled by replacing with . Intuitively, a set identifies the temporal literals that are locked, i.e., forced to retain the truth value they have in , while all literals outside are unlocked and free to change: is precisely the set of traces obtained by locking . An abductive explanation locks enough observations to make the violation unavoidable; a contrastive explanation unlocks enough observations to make satisfaction possible.
Equivalence to Classifier Explanations
In this section, we formalize the -as-binary-classifier setting, establish a correspondence between classifier-based explanations and our reformulation, and prove that the two formulations are equivalent.
Encoding Formulas as Binary Classifiers
Let be binary features, each with domain –that is, we associate one Boolean feature with each time-indexed atom –and let . A trace is represented by the assignment defined by . We denote by the set of such assignments. Conversely, every assignment introduces a trace , that is .
Every formula induces a binary classifier , defined by
As in the previous section, we restrict our attention to instances satisfying , since iff .
A set is a WAXp for if:
A set is a WCXp for if:
Both formulations use the same names; they are distinguished by their arguments, as a WAXp (WCXp) for is a set of features, whereas a WAXp (WCXp) for , as per Definitions def:waxp and def:wcxp, is a set of temporal literals. When needed, we call the former classifier-based and the latter trace-based.
To relate the two formulations, we introduce two mappings between sets of features and sets of temporal literals. Given a trace and a set of feature , we denote by the set of literals of over the features in , that is,
Conversely, for a set of temporal literals , we denote by the corresponding set of features:
Observe that, by construction, for every trace and every , the following properties hold:
;
, and
The equivalence proofs rely on the following observation: agreement between assignments corresponds to compatibility between the corresponding traces. More precisely, if two assignments agree on a set of features , then the corresponding traces share the temporal literals in .
Proof. Assume that . By definition, . Hence, every temporal literal in belongs to both and . Since , every feature in is assigned the same truth value by and . Therefore, . Assume that . Then, for every feature , the assignments and are the same. Since , each literal in also belongs to . Thus, , which implies that . ◻
Using Proposition prop:compat-agreement, we can now prove the equivalence of the two notions of explanation. We start with WAXps.
Proof. Assume that is a WAXp for , and let . By Proposition prop:compat-agreement, . Since , we obtain . Because is a WAXp, , which implies . Therefore, , and hence is a WAXp for . Assume that is a WAXp for . Let be such that . Let . Since , Proposition prop:compat-agreement implies that . Because is a WAXp for , . Hence , which proves that is a WAXp for . ◻
An analogous correspondence holds for WCXp.
Proof. Assume that is a WCXp for . Then there exists such that and . Let . By Proposition prop:compat-agreement, that is equivalent to (property 3 above). Moreover, implies . Hence , which proves that is a WCXp for . Assume being a WCXp for . Then there exists . By property 3 above, . By Proposition prop:compat-agreement, . Since (property 1), we have . Finally, implies , and thus is a WCXp for . ◻
The previous propositions establish a bijective correspondence between the two formulations, i.e. each set that is a WAXp (WCXp, respectively) for can be decoded into the set that is a WAXp (WCXp, respectively) for . The result holds since and . Moreover, from the fact that both preserve subsets, we have that the statements also hold for AXp and CXp.
By AXp/CXp duality [24] and since is an intersection- and inclusion-preserving bijection between and , the following result holds.
Relationship with Temporal Causality
Meng et al. [33] recently proposed a causality-based framework for explaining finite counterexamples to specifications. Their notion of explanation is based on Halpern’s causality, that is a cause is a minimal set of interventions that transform a counterexample trace into a model of the specification. In this section we reformulate their framework using our notation and prove its formal relationship with our characterization of AXps and CXps.
Let be a trace, and let be a formula. A candidate causal set is a set . Given , the alteration trace is a trace obtained by replacing every literal of that occurs in with their opposite. More formally, if , then . A minimal cause for violation is defined as follows:
Let denote the set of alteration traces obtained by intervening on over subsets of . The following lemma establishes the correspondence between alteration and compatible traces.
Proof. Let . Then there exists such that . By definition, . Since , every literal in is left unchanged. Hence, that implies . Let . Consider the set . Since we have that . Therefore, . Moreover, because the intervention flips exactly the literals on which and differ. Hence, . ◻
Now we are ready to establish the relationships.
Proof. Let be a minimal cause for violation of the formula in the counterexample trace . By definition, . By Lemma lemma:tc, . Since and , we have that . Hence, is a WCXp. Suppose that is not a CXp, then there exists a that is also a WCXp. By Lemma lemma:tc , hence there exists such that . Since , this contradicts the minimality of . Let be a CXp (hence also a WCXp), so . By Lemma lemma:tc, , hence there exists with . Take such an that is subset-minimal (it exists, as is finite). Every also satisfies , hence by minimality of ; therefore is a minimal cause for violation. By direction , is a CXp; since and is a CXp, subset-minimality gives . Therefore, is a minimal cause. ◻
Unlike [33], our approach makes AXp/CXp duality explicit and enables efficient cause computation.
| AXp | CXp | |||||||||||||||||||||
| Complete | Timeout | Complete | Timeout | |||||||||||||||||||
| Log | C | T | Min | P25 | P50 | P75 | Max | Min | P25 | P50 | P75 | Max | Min | P25 | P50 | P75 | Max | Min | P25 | P50 | P75 | Max |
| Per-instance counts | ||||||||||||||||||||||
| bpi2020-domdecl | 81 | 8 | 1 | 10 | 21 | 82 | 441 | 567 | 578 | 588 | 647 | 834 | 1 | 1 | 3 | 5 | 19 | 18 | 23 | 28 | 35 | 70 |
| bpi2020-intdecl | 181 | 552 | 6 | 54 | 83 | 193 | 621 | 81 | 186 | 249 | 344 | 784 | 4 | 19 | 38 | 62 | 220 | 0 | 9 | 38 | 91 | 908 |
| bpi2020-permlog | 312 | 1166 | 4 | 40 | 177 | 443 | 1087 | 80 | 294 | 426 | 597 | 1253 | 2 | 15 | 51 | 143 | 366 | 0 | 9 | 70 | 223 | 885 |
| bpi2020-prepcost | 180 | 18 | 1 | 16 | 43 | 155 | 797 | 323 | 432 | 508 | 591 | 754 | 1 | 2 | 4 | 7 | 26 | 6 | 14 | 17 | 21 | 36 |
| bpi2020-reqpay | 79 | 1 | 1 | 6 | 12 | 62 | 937 | 829 | 829 | 829 | 829 | 829 | 1 | 1 | 2 | 4 | 26 | 88 | 88 | 88 | 88 | 88 |
| sepsis | 220 | 624 | 1 | 13 | 24 | 110 | 618 | 43 | 216 | 326 | 435 | 931 | 2 | 18 | 50 | 121 | 415 | 0 | 26 | 96 | 192 | 725 |
| Explanation sizes | ||||||||||||||||||||||
| bpi2020-domdecl | 81 | 8 | 1 | 3 | 4 | 4 | 5 | 1 | 4 | 4 | 5 | 6 | 1 | 10 | 14 | 16 | 24 | 18 | 22 | 24 | 30 | 38 |
| bpi2020-intdecl | 181 | 552 | 1 | 4 | 6 | 7 | 10 | 1 | 7 | 8 | 10 | 29 | 2 | 10 | 14 | 16 | 22 | 6 | 14 | 18 | 20 | 40 |
| bpi2020-permlog | 312 | 1166 | 1 | 5 | 6 | 7 | 11 | 1 | 5 | 6 | 8 | 55 | 2 | 18 | 20 | 20 | 24 | 16 | 24 | 26 | 30 | 144 |
| bpi2020-prepcost | 180 | 18 | 1 | 3 | 4 | 4 | 6 | 1 | 4 | 4 | 4 | 6 | 1 | 14 | 18 | 20 | 30 | 20 | 24 | 24 | 26 | 36 |
| bpi2020-reqpay | 79 | 1 | 1 | 3 | 4 | 4 | 6 | 1 | 4 | 4 | 4 | 7 | 1 | 10 | 16 | 20 | 24 | 24 | 26 | 26 | 28 | 30 |
| sepsis | 220 | 624 | 1 | 5 | 6 | 7 | 11 | 1 | 7 | 9 | 10 | 54 | 1 | 10 | 12 | 14 | 22 | 4 | 14 | 16 | 18 | 50 |
Table 1. Per-instance AXp/CXp counts (top) and AXp/CXp explanation sizes in literals (bottom), by log. : instances (C=complete, T=timeout). Column refers to the -th quantile of the distributions, with P50 being the median. Max., min. refers to the maximum and minimum observed statistics.
Complexity
We analyze the complexity of deciding whether a given set of temporal literals is a WAXp or WCXp. Trace length is fixed as part of the explanation setting and the decision problems amount to searching for models of formulas over traces of bounded length. This reduces the complexity of satisfiability from PSPACE-complete to NP-complete.
Proof (Sketch). [Membership.] A certificate is a trace . One can check in polynomial time that both and . If both conditions hold, then and is a WCXp.
[Hardness.] Hardness is shown by a reduction from the Boolean satisfiability problem [16]. Let be a CNF formula over the variables , and let be a fresh variable. Set and . We map to the instance where:
Note that , so contains every trace of length over ; hence is a WCXp iff some length- trace satisfies . The conjunct ensures , so is a well-formed explanation problem.
() Let satisfy , and set . Then , so and is a WCXp. () Let be a WCXp, witnessed by . Since , we have ; the assignment iff satisfies . ◻
The complexity of WAXp checking follows by duality. is a WAXp for if and only if no trace in satisfies , that is, is not a WCXp for . WAXp checking is thus the complement of WCXp checking, and Proposition prop:wcxp-np yields the following.
Given the coNP (resp. NP) complexity of checking whether a set is a WAXp (resp. WCXp), a deletion-based procedure that removes literals one by one computes an AXp (resp. CXp) with a polynomial (linear) number of oracle calls, which matches general results for AXps/CXps [31].
Next, we show that checking whether a set is an AXp (CXp) is DP-complete (coNP-complete) by reduction from MUS-checking (UNSAT) of a propositional formula. Let be an unsatisfiable propositional formula in 3-CNF with clauses , and let be fresh propositional symbols, one per clause. Set and . Over the alphabet , the formula is an formula and , with , is a trace of length one; since is unsatisfiable, . Keeping false forces to be satisfied through ; accordingly, we identify a set of clauses with the temporal literals . This yields the key correspondence: for every ,
Recall that is an MUS if is unsatisfiable and every proper subset is satisfiable; is a maximal satisfiable subset (MSS) if is satisfiable and is unsatisfiable for every ; and is an MCS if is an MSS, i.e., a minimal set of clauses whose removal restores satisfiability.
Proof. Let be an MUS. By , unsatisfiable gives , so is a WAXp; and for every , satisfiable gives, again by , that is not a WAXp. These are exactly the proper subsets of ; hence is an AXp. Symmetric, reading each implication of in the opposite direction. ◻
Proof. Membership. is an AXp iff (a) is a WAXp and (b) no is a WAXp. Condition (a) is in coNP (Corollary prop:waxp-conp); (b) is in NP, as a certificate is, for some , a trace in . Hence the problem is in DP. Hardness. By Proposition prop:mus-axp, since MUS-checking is DP-hard (MINIMAL UNSATISFIABILITY; [35, 32]). ◻
Checking a CXp, on the other hand, is coNP-complete:
Proof. [Membership.] By Proposition prop:causes, is a CXp if and only if (a) and (b) for every . Condition (a) is a single model check on a fixed trace, feasible in polynomial time [13]. Condition (b) is in coNP since a counterexample is a set with , that can be checked in polynomial time.
[Hardness.] We reduce from UNSAT. Let be a CNF formula over . We assume w.l.o.g. that the all-true assignment does not satisfy , this can be checked in polynomial time, and if it does, we output a fixed instance that is not a CXp (e.g. any with ). Set with fresh, , , and . Since is false in , , so is a well-formed explanation problem. Let , we claim is a CXp for iff is unsatisfiable. Since sets every atom to true, : holds and the antecedent is false. By Proposition prop:causes, is a CXp iff no proper subset satisfies ; we show this holds iff is unsatisfiable.
Suppose is unsatisfiable. Take any . If , then stays false and . If , then since is proper some stays false, so the antecedent holds and would require ; but is unsatisfiable, so no such exists. Hence no proper subset satisfies , and is a CXp.
Suppose is satisfiable. By the w.l.o.g. assumption, it has a model different from all-true. Let . Then , and . Thus a proper subset satisfies , and is not a CXp. ◻
Computing AXps and CXps in ASP
We build upon the approach of [15], that describes an Answer Set Programming (ASP) logic program , such that its stable models correspond one-to-one to traces such that and . is a typical guess-and-check ASP encoding, with a guess program that generates candidate traces, and a check program that discards traces that are not models of . More in detail, is a stratified logic program that evaluates the syntactic tree of in a bottom-up fashion over a guessed trace in , discarding answer sets that encode traces that are not models of .
We briefly describe the original encoding for bounded satisfiability.
Formulae & traces
Consider a formula , and suppose each node in its syntax tree is assigned a unique integer. We can reify into ASP facts by means of predicates , , , , , , where the first term always refers to the unique identifier of the subformula and the other terms refer to identifiers of the most immediate subformulae (children). Predicate names are self-explanatory, and correspond to the given temporal/propositional operator.
Wlog, the root of is identified by 0. We denote this set of facts as . For example, the formula would be encoded as: until(0,1,2). negate(1,3). atomic(3,a). next(2,4). atomic(4,b). root(0).
A trace can be encoded by means of facts if , and if , where holds if , and if and . For example, the trace is encoded as: time(0..2). trace(0,a). trace(0,b). trace(2,c). We denote this set of facts as .
Semantics of temporal operators
The ASP encoding of temporal operators makes use of predicates with signature , , and . An atom models that the subformula rooted in is true at time . The atom states that the trace has an -th state, i.e. it has length at least . The following logic program models the semantics of temporal operators:
holds(T,X) :- atomic(X,A), trace(T,A).
holds(T,X) :- next(X,F), holds(T+1,F).
holds(T,X) :- conjunction(X,_), time(T),
holds(T,F): conjunction(X,F).
holds(T,X) :- negate(X,F), time(T), not holds(T,F).
holds(T,X) :- until(X,F,G), holds(T,G).
holds(T,X) :- until(X,F,G), holds(T,F), holds(T+1,X).
sat :- holds(0,X), root(X).
Each rule closely mirrors the definition of the next normal form transformation of each temporal operator, so correctness follows from previous results [13]; since this is a locally stratified logic program [17], it admits a unique answer set containing iff .
Search for a model
The above encoding evaluates the formula over a trace , so it is sufficient to replace the set of facts by some choice rules that generates all possible traces to lift it for checking bounded satisfiability. Consider the following logic program :
symbol(X) :- atomic(_,X).
{ last_instant(T): T=0..k-1 } = 1.
time(0..T) :- last_instant(T).
{ trace(T,A): symbol(A) } :- time(T).
:- not sat.
Above, k is a runtime clingo constant which denotes the search bounds. The first choice rule yields the length of the guessed trace, , whereas the second one generates all possible states (given symbols that appear in ), for each time point, thus all possible traces of length up to . The constraint discards traces which are not models of . If the above logic program is satisfiable, projecting answer sets on predicates , allows one to obtain satisfying traces.
Thus, for the purposes of our paper, we have that , and .
To apply our approach, we require to edit on , so that we fix the input trace as the unique model of the guess program. This is done as follows.
Let . The program containing a pair of rules of the form:
trace(t,a) :- not ntrace(t,a).
ntrace(t,a) :- not trace(t,a).
for each , guesses the possible interventions on an input trace , that is an arbitrary trace of length by Lemma lemma:tc with .
Let’s introduce the set of constraints . Intuitively, these constraints lock certain events in the models of , playing the same role as .
Proof (Sketch).. By construction observing that generates and constraints in force the occurrence/absence of the temporal literals . ◻
The logic program of the original encoding of [14] models the satisfaction of , thus:
Note also that whenever , the program admits an unique model, that is the trace . Thus, if , we have that is incoherent. Consequently, it admits unsatisfiable cores and correction sets [1]. In particular, we are interested in MUSes and MCSes in terms of the constraints in .
Let be a set of fresh objective atoms. Let . Intuitively, each acts as a selector to include/exclude a constraint in , effectively locking certain temporal literals to assume the same value as in .
Proof (Sketch).. Follows from observing that including or excluding objective atoms in respectively forces or forbids the corresponding temporal literals to match . ◻
Notice this also implies the results holds for MUSes and AXps, since those are minimal unsatisfiable cores and minimal WAXps. The analogous for MCSes follows trivially from minimal hitting set dualities between MUSes/MCSes in ASP programs [1], and AXps/CXps [24]:
Experiments
We evaluate the effectiveness of MUSes/MCSes enumeration for computing AXps and CXps of specifications.
Implementation.
Our implementation is a Python script that parses explanation problems of the form into a logic program, and then applies the MARCO [27] algorithm for ASP [1], to jointly enumerate MUSes (AXps) and MCSes (CXps). We use the clingo [18] ASP solver.
Execution Environment.
Experiments were run on a machine equipped with a 13th Gen Intel(R) Core(TM) i7-13700 CPU and 32 GB of RAM, with 16 physical cores and 24 logical CPUs, running Ubuntu 22.04. In the experiments, we set a CPU-time limit of 10 seconds, a wall-clock timeout of 20 seconds, and a memory limit of 2 GB of RAM.
Data.
Our benchmark is built from Declare [40], a declarative process modeling language based on a set of templates whose semantics is given in . In this setting, process discovery algorithms learn Declare models—that one can translate in formulas—from event logs, i.e., multi-sets of traces recording real process executions. We choose Declare because it is a major application of and, to the best of our knowledge, the only domain providing both real-world traces and formulas that are learned from data rather than hand-crafted. We consider a collection of 6 real-world event logs (from the BPI Challenge 2020 [41], and the Sepsis event log [30]). For each event log, we learn a Declare model using the Declare4Py library [11], which we translate into an formula . For each variant (i.e., unique trace) in the event log, we generate one explanation problem: when , and when . We obtain a total of explanation problems, and we discard 45 where the corresponding formula is incoherent–which would admit a single (empty) AXp and no CXps. This yields a total of 3422 instances.
Results.
Table 1 reports statistics on the number, size of AXps and CXps found by our approach, partitioned by corresponding event log. Top-half reports the number of AXps/CXps found; bottom-half their size. We distinguish between complete instances, where enumeration terminates and incomplete instances where it does not terminate1. The approach is effective, as in a short timeout we are able to complete about 30% of the instances, while on the remaining incomplete instances we are still able to output several CXps and AXps, with a few exceptions (155) where we find zero CXps. However, this is due to the fact that the enumeration algorithm jointly enumerates CXps and AXps, and those instances contain a large amount of AXps. Additionally, we report no memory out errors, and an average (median) time-to-first AXp of s (0.09s) and an average time-to-first CXp of s (0.41s).
Comparison with [33].
The only existing tool that can compute our CXps is caupybara [33], which computes causes (equivalent to CXps) by brute-force. Candidate sets of increasing size (up to a user-provided upper bound on size) are enumerated, and checked for being a cause. As one may notice in Table 1, CXps of large size are not unlikely in real-world event logs. Thus, it is expected the approach scales poorly, as the size of causes increases. We highlight this limitation with a synthetic formula. Let , , and , where the final empty state ensures the last weak next is not trivially satisfied. Every conjunct is violated, so , and the instance has exactly AXps of size 2 (each pairing the presence of with the absence of ) and, by hitting-set duality, CXps of size . Altering the trace to satisfy must satisfy each , choosing for each whether to remove or add . Thus, one needs to enumerate up to . Note that the conjunct is not a “pathological” formula, but a rather common specification pattern in specifications (“every time happens, either the trace concludes or happens next”). In particular, this is known as Chain Response in Declare (with a strong next replacing the weak).
Figure 2 reports the time to compute one and all CXps as grows, under the same 10-second budget as before, with caupybara run at . caupybara exceeds the budget beyond , even for a single CXp. Our approach, instead, manages to enumerate all CXps up to , while also computing AXps. A CXp-only variant of our approach (enumerating minimal stable models [1] to obtain MCSes/CXps, rather than applying MARCO-style joint MUS/MCS enumeration) matches caupybara’s task exactly, and finds a first CXp in under s, but performs worse in enumeration, completing only up to , overall slowing down in the CXp enumeration task.
Figure 2. Time to the first and to all CXps on , , for caupybara, our full approach, and a CXp-only variant. Dashed: first CXp; solid: all CXps. 10 seconds timeout.
Conclusion
In this paper, we specialize abductive and contrastive explanations to . We provide an idiomatic definition that side-steps the classifier view the original definitions require, prove the two equivalent, and prove contrastive explanations equivalent to a recently-proposed notion of temporal causality. This characterization lets us enumerate explanations efficiently by exploiting MUS-MCS duality, which we instantiate in Answer Set Programming. Experiments show the approach is effective on real-world event logs.
References
- [1]Alviano, Dodaro, Fiorentino, Previti, & Ricca. (2023). ASP and subset minimality: Enumeration, cautious reasoning and MUSes.
- [2]Bacchus, & Kabanza. (1998). Planning for temporally extended goals.
- [3]Beer, Ben-David, Chockler, Orni, & Trefler. (2009). Explaining Counterexamples Using Causality.
- [4]Brewka, Eiter, & Truszczynski. (2011). Answer set programming at a glance.
- [5]Chiariello, & Marques-Silva. (2025). Formal Explanations of Black-Box Ranking Functions.
- [6]Darwiche, & Hirth. (2023). On the (Complete) Reasons Behind Decisions.
- [7]De Giacomo, De Masellis, Grasso, Maggi, & Montali. (2014). Monitoring business metaconstraints based on LTL and LDL for finite traces.
- [8]De Giacomo, Iocchi, Favorito, & Patrizi. (2019). Foundations for restraining bolts: Reinforcement learning with LTLf/LDLf restraining specifications.
- [9]De Giacomo, & Rubin. (2018). Automata-Theoretic Foundations of FOND Planning for LTLf and LDLf Goals.
- [10]De Giacomo, & Vardi. (2013). Linear Temporal Logic and Linear Dynamic Logic on Finite Traces.
- [11]Donadello, Riva, Maggi, & Shikhizada. (2022). Declare4Py: A Python Library for Declarative Process Mining.
- [12]Ferrère, Maler, & Ničković. (2015). Trace diagnostics using temporal implicants.
- [13]Fionda, & Greco. (2018). LTL on Finite and Process Traces: Complexity Results and a Practical Reasoner.
- [14]Fionda, Ielo, & Ricca. (2024). LTLf2ASP: LTLf Bounded Satisfiability in ASP.
- [15]Fionda, Ielo, & Ricca. (2026). Computing Syntax Tree-based Minimal Unsatisfiable Cores of LTLf Formulas.
- [16]Garey, & Johnson. (1979). Computers and Intractability: A Guide to the Theory of NP-Completeness (Series of Books in the Mathematical Sciences).
- [17]Gebser, Kaminski, Kaufmann, & Schaub. (2012). Answer Set Solving in Practice.
- [18]Gebser, Kaminski, Kaufmann, & Schaub. (2019). Multi-shot ASP solving with clingo.
- [19]Gelfond, & Lifschitz. (1991). Classical Negation in Logic Programs and Disjunctive Databases.
- [20]Granada, Ignatiev, & Stuckey. (2026). A Formal Framework for the Explanation of Finite Automata Decisions. https://arxiv.org/abs/2602.13351
- [21]Guidotti, Monreale, Ruggieri, Turini, Giannotti, & Pedreschi. (2019). A Survey of Methods for Explaining Black Box Models.
- [22]Halpern. (2016). Actual Causality.
- [23]Ielo, Mazzotta, Peñaloza, & Ricca. (2026). Enumerating Minimal Unsatisfiable Cores of LTLf Formulae.
- [24]Ignatiev, Narodytska, Asher, & Marques-Silva. (2020). From Contrastive to Abductive Explanations and Back Again.
- [25]Ignatiev, Narodytska, & Marques-Silva. (2019). Abduction-Based Explanations for Machine Learning Models.
- [26]Kress-Gazit, Fainekos, & Pappas. (2009). Temporal-logic-based reactive mission and motion planning.
- [27]Liffiton, Previti, Malik, & Marques-Silva. (2016). Fast, flexible MUS enumeration.
- [28]Liffiton, & Sakallah. (2008). Algorithms for Computing Minimal Unsatisfiable Subsets of Constraints.
- [29]Lifschitz. (2019). Answer Set Programming.
- [30]Mannhardt, & Blinde. (2017). Analyzing the Trajectories of Patients with Sepsis using Process Mining.
- [31]Marques-Silva, & Ignatiev. (2022). Delivering Trustworthy AI through Formal XAI.
- [32]Marques-Silva, Janota, & Mencía. (2017). Minimal sets on propositional formulae. Problems and reductions.
- [33]Meng, & Alrajeh. (2025). Causal Detection in Linear Temporal Counterexamples.
- [34]Niu, Xiao, Zhang, Li, Huang, & Shi. (2024). Computing minimal unsatisfiable core for LTL over finite traces.
- [35]Papadimitriou, & Wolfe. (1988). The Complexity of Facets Resolved.
- [36]Pnueli. (1977). The Temporal Logic of Programs.
- [37]Reiter. (1987). A theory of diagnosis from first principles.
- [38]Roveri, Ciccio, Francescomarino, & Ghidini. (2024). Computing Unsatisfiable Cores for LTLf Specifications.
- [39]Shih, Choi, & Darwiche. (2018). A Symbolic Approach to Explaining Bayesian Network Classifiers.
- [40]van der Aalst, Pesic, & Schonenberg. (2009). Declarative workflows: Balancing between flexibility and support.
- [41]van Dongen. (2020). BPI Challenge 2020.
