=Paper= {{Paper |id=Vol-3281/paper6 |storemode=property |title=Explainability via Short Formulas: the Case of Propositional Logic with Implementation |pdfUrl=https://ceur-ws.org/Vol-3281/paper6.pdf |volume=Vol-3281 |authors=Reijo Jaakkola,Tomi Janhunen,Antti Kuusisto,Masood Feyzbakhsh Rankooh,Miikka Vilander |dblpUrl=https://dblp.org/rec/conf/lpnmr/JaakkolaJKRV22 }} ==Explainability via Short Formulas: the Case of Propositional Logic with Implementation== https://ceur-ws.org/Vol-3281/paper6.pdf
Explainability via Short Formulas: the Case of
Propositional Logic with Implementation
Reijo Jaakkola1 , Tomi Janhunen2 , Antti Kuusisto3 , Masood Feyzbakhsh Rankooh4 and
Miikka Vilander5,βˆ—
Tampere University, FI-33014, Tampere University, Finland


                                         Abstract
                                         We conceptualize explainability in terms of logic and formula size, giving a number of related definitions
                                         of explainability in a very general setting. Our main interest is the so-called special explanation problem
                                         which aims to explain the truth value of an input formula in an input model. The explanation is a formula
                                         of minimal size that (1) agrees with the input formula on the input model and (2) transmits the involved
                                         truth value to the input formula globally, i.e., on every model. As an important example case, we study
                                         propositional logic in this setting and show that the special explainability problem is complete for the
                                         second level of the polynomial hierarchy. We also provide an implementation of this problem in answer
                                         set programming and investigate its capacity in relation to explaining answers to the n-queens and
                                         dominating set problems.

                                         Keywords
                                         explainability, answer set programming, satisfiability checking, computational complexity




1. Introduction
This paper investigates explainability in a general setting. The key in our approach is to relate
explainability to formula size. We differentiate between the general and special explanation
problems. The general explanation problem for a logic L takes as input a formula πœ‘ ∈ L and
outputs an equivalent formula of minimal size. Thus the objective is to explain the global
behavior of πœ‘. For example, we can consider ¬¬¬¬¬¬𝑝 to be globally explained by 𝑝. In
contrast, the goal of the special explanation problem is to explicate why an input formula πœ“ gets
the truth value 𝑏 in an input model 𝑀. Given a tuple (𝑀, πœ“ , 𝑏), the problem outputs a formula πœ’
of minimal size such that (1) the formula πœ’ obtains the same truth value 𝑏 on 𝑀, and (2) on every
model 𝑀 β€² where πœ’ gets the truth value 𝑏, also πœ“ gets that same truth value. Intuitively, this
second condition states that the given truth value 𝑏 of πœ’ on a model 𝑀 β€² causes πœ“ to be judged
similarly. In summary, the special explanation problem gives reasons why a piece of data (or a

Accepted for presentation at the 29th RCRA Workshop, 2022, Genoa, Italy
βˆ—
    Corresponding author.
Envelope-Open reijo.jaakkola@tuni.fi (R. Jaakkola); tomi.janhunen@tuni.fi (T. Janhunen); antti.kuusisto@tuni.fi (A. Kuusisto);
masood.feyzbakhshrankooh@tuni.fi (M. F. Rankooh); miikka.vilander@tuni.fi (M. Vilander)
GLOBE https://reijojaakkola.github.io/ (R. Jaakkola); https://tuni.fi/en/tomi-janhunen (T. Janhunen);
https://homepages.tuni.fi/antti.kuusisto/ (A. Kuusisto)
Orcid 0000-0003-4714-4637 (R. Jaakkola); 0000-0002-2029-7708 (T. Janhunen); 0000-0003-1356-8749 (A. Kuusisto);
0000-0001-5660-3052 (M. F. Rankooh); 0000-0002-7301-939X (M. Vilander)
                                       Β© 2022 Copyright for this paper by its authors. Use permitted under Creative Commons License Attribution 4.0 International (CC BY 4.0).
    CEUR
    Workshop
    Proceedings
                  http://ceur-ws.org
                  ISSN 1613-0073
                                       CEUR Workshop Proceedings (CEUR-WS.org)
model) is treated in a given way (i.e., obtains a given truth value) by a classifier (or a formula).
   The two explanation problems give rise to corresponding questions of explainability. The
general explainability problem for a logic L asks, given a formula πœ‘ ∈ L and π‘˜ ∈ β„•, whether
there exists a formula equivalent to πœ“ of size at most π‘˜. The special explainability problem gets
as input a tuple (𝑀, πœ“ , 𝑏, π‘˜), and the task is then to check whether there exists a formula πœ’ of
size at most π‘˜ satisfying the above conditions (1) and (2) of the special explanation problem.
   As an important particular case, we study the special explainability problem of propositional
logic (PL) in detail. We prove that the problem is Σ𝑃2 -complete. This is an important result
whose usefulness lies in its implications that go far beyond PL itself. Indeed, the result gives a
robust lower bound for various logics. We demonstrate this by establishing Σ𝑃2 -completeness of
the special explainability problem of S5 modal logic; the lower bound follows directly from the
case of PL, while the upper bound is very easy to obtain. We observe that a rather wide range
of logics with satisfiability in NP have Σ𝑃2 -complete special explainability problems.
   As a further theoretical result, we prove that, when limiting to explaining only the positive
truth value ⊀, the special explainability problem is only NP-complete for CNF -formulas of PL.
As a corollary, we get NP-completeness of the problem for DNF -formulas in restriction to the
truth value βŠ₯. While theoretically interesting, these results are also relevant from the point of
view of applications, as quite often real-life classification scenarios require explanations only
in the case of one truth value. For example, explanations concerning automated insurance
decisions are typically relevant only in the case of rejected applications. In addition to the
NP-completeness results, we also show that restricting to a single truth value here is necessary
for obtaining the given complexity (supposing coNP ⊈ NP).
   We provide an implementation of the special explainability problem of PL based on answer-set
programming (ASP) [1]. Generally, ASP is a logic programming language based on stable-
model semantics and propositional syntax, particularly Horn clauses. ASP is especially suitable
and almost custom-made for implementing the special explainability problem of PL, as ASP
is designed precisely for the complexity levels up to Σ𝑃2 . Indeed, while the disjunction-free
fragments of ASP [2] cover the first level of the polynomial hierarchy in a natural way, proper
disjunctive rules with cyclic dependencies become necessary to reach the second one [3].
   We test the implementation via experiments with benchmarks based on the 𝑛-queens and
dominating set problems. The experiments provide concrete and compact explanations why a
particular configuration of queens on the generalized chessboard or a particular set of vertices of
a graph is or is not an acceptable solution to the involved problem. Runtimes scale exponentially
in the size of the instance and negative explanations tend to be harder to compute than positive
ones. Also, we observe from the experiments that the respective optimization variants of
explanations problems can be computationally more effective, leaving the exact bound on the
size of explaining formulas open and relieving the user from providing a particular bound.
   Concerning related work, while the literature on explainability is extensive, only a small
part of it is primarily based on logic. In relation to the current paper, the special explainability
problem in the particular case of PL has some similarities with the prime implicant (or PI)
explanations of [4]. However, there are some key differences. PI-explanations are defined in
terms of finding a minimal subset of featuresβ€”or propositionsβ€”that suffice to explain the input
instance of a Boolean decision function. Our definition of special explainability allows for any
kind of formula as output. In the propositional case, we separately prove that a subconjunction
of the literals in the input is always a possible output. We end up with a similar goal of removing
propositions, but from a different starting point and in a different setting. In the case of other
logics, such as FO, the resemblance to prime implicant explanations decreases. Concerning
results, [4] does not provide a full complexity analysis relating to the studied problems. Although
PI-explanations are defined for any decision function, the algorithms used in [4] to compute
PI-explanations have ordered binary decision diagrams (OBDD) as inputs and outputs. For these
algorithms, the authors give empirical runtimes but no complexity bounds. Thus, in our work,
while the space of potential input and output formulas is different, we also give a complete
complexity analysis of the special explainability problem in addition to experiments.
                                                                      𝑝
   In [5], Umans shows that the shortest implicant problem is Ξ£2 -complete, thereby solving a
long-standing open problem of Stockmeyer. An implicant of πœ‘ is a conjunction πœ’ of literals such
that πœ’ ⊨ πœ‘. The shortest implicant problem asks whether there is an implicant of πœ‘ with size
at most π‘˜. Size is defined as the number of occurrences of literals. Below we prove that the
special explainability problem for PL can be reduced to certain particular implicant problems.
                                                                                     𝑝
However, despite this, the work of Umans does not directly modify to give the Ξ£2 -completeness
result of the special explainability problem. The key issue is that the explainability problem
requires an interpolant between a set πœ’ of literals and a formula πœ‘, where πœ’ has precisely the
same set of propositions symbols as πœ‘. Thus we need to give an independent proof for the Σ𝑃2
lower bound. Also, formula size in [5] is measured in a more coarse way.


2. Preliminaries
Let Ξ¦ be a set of proposition symbols. The set PL(Ξ¦) of formulas of propositional logic PL
over Ξ¦ is given by the grammar πœ‘ ∢= 𝑝 ∣ Β¬πœ‘ ∣ (πœ‘ ∧ πœ‘) ∣ (πœ‘ ∨ πœ‘), where 𝑝 ∈ Ξ¦. Literals are either
atoms 𝑝 or their negations ¬𝑝, also known as positive and negative literals, respectively. A
Ξ¦-assignment is a function 𝑠 ∢ Ξ¦ β†’ {0, 1}. When Ξ¦ is clear from the context or irrelevant, we
simply refer to assignments rather than Ξ¦-assignments. We define the semantics of propositional
logic in the usual way, and we write 𝑠 ⊧ πœ‘ if the assignment 𝑠 satisfies the formula πœ‘ ∈ PL(Ξ¦).
Alternatively, we can use the standard valuation function 𝑣Φ defined such that 𝑣Φ (𝑠, πœ‘) = 1 if
𝑠 ⊨ πœ‘ and otherwise 𝑣Φ (𝑠, πœ‘) = 0. Below we sometimes use the set {βŠ₯, ⊀} instead of {0, 1},
   A formula πœ“ ∈ PL(Ξ¦) is a logical consequence of πœ‘ ∈ PL(Ξ¦), denoted πœ‘ ⊨ πœ“, if for every
Ξ¦-assignment 𝑠, 𝑠 ⊨ πœ‘ implies 𝑠 ⊨ πœ“. A formula πœ’ ∈ PL(Ξ¦) is an interpolant between πœ‘ and πœ“ if
πœ‘ ⊨ πœ’ and πœ’ ⊨ πœ“. For a finite Ξ¦, we say that a formula πœ‘ is a maximal conjunction w.r.t. Ξ¦ if πœ‘
is a conjunction of exactly one literal for each 𝑝 ∈ Ξ¦. A Ξ¦-assignment 𝑠 can be naturally identified
with a maximal conjunction, for example {(𝑝, 1), (π‘ž, 0)} identifies with 𝑝 ∧ Β¬π‘ž. A formula πœ’ is
a subconjunction of πœ‘ if πœ’ is a conjunction of literals occurring in πœ‘. The size of πœ‘, denoted
size(πœ‘), is the number of occurrences of proposition symbols, binary connectives and negations
in πœ‘. For example, the size of ¬¬(𝑝 ∧ 𝑝) is 5 as it has one ∧ and two occurrences of both Β¬ and 𝑝.


3. Notions of explanation and explainability
In this section we introduce four natural problems concerning the general and special per-
spectives to explainability. The general problems deal with the question of explaining the
entire behavior of a classifier, whereas the special ones attempt to explicate why a single input
instance was classified in a given way. We give very general definitions of these problems, and
for that we will devise a very general definition of the notion of a logic. Our definition of a
logic covers various kinds of classifiers in addition to standard formal logics, including logic
programs, Turing machines, neural network models, automata, and the like.

Definition 1. A logic is a tuple (β„³, β„± , 𝑣, π‘š) where β„³ and β„± are sets; 𝑣 ∢ β„³ Γ— β„± β†’ 𝑉 is a
function mapping to some set 𝑉; and π‘š ∢ β„± β†’ β„• is a function. Emphasizing the set 𝑉, we can
also call (β„³, β„± , 𝑣, π‘š) a 𝑉-valued logic.

   Intuitively, we can think of β„³ as a set of models and β„± as a set of formulas. The function
𝑣 ∢ β„³ Γ— β„± β†’ 𝑉 gives the semantics of the logic, with 𝑣(𝔐, πœ‘) being the truth value of πœ‘ in 𝔐.
We call 𝑣 a valuation. The function π‘š gives a complexity measure for the formulas in β„±, such
as, for example, formula size.

Example 2. Propositional logic PL over a set Ξ¦ of proposition symbols can be defined as a tuple
(β„³, β„± , 𝑣, π‘š), where β„³ is the set of Ξ¦-assignments; β„± the set PL(Ξ¦) of formulas; 𝑣 ∢ β„³ Γ— β„± β†’
{0, 1} is the standard valuation 𝑣Φ ; and π‘š(πœ‘) = size(πœ‘) for all πœ‘ ∈ β„±.

  Now, the following example demonstrates that we can consider much more general scenarios
than ones involving the standard formal logics.

Example 3. Let β„³ be a set of data and β„± a set of programs for classifying the data, that is,
programs that take elements of β„³ as inputs and output a value in some set 𝑉 of suitable outputs.
Now 𝑣 ∢ β„³ Γ— β„± β†’ 𝑉 is just the function such that 𝑣(𝐷, 𝑃) is the output of 𝑃 ∈ β„± on the
input 𝐷 ∈ β„³. The function π‘š can quite naturally give the program size for each 𝑃 ∈ β„±. If we
redefine the domain of π‘š to be β„³ Γ— β„±, we can let π‘š(𝐷, 𝑃) be for example the running time of
the program 𝑃 on the input 𝐷, or the length of the computation (or derivation) table.

   Given a logic, we define the equivalence relation ≑ βŠ† β„± Γ— β„± such that (𝑀, 𝑀 β€² ) ∈ ≑ if and
only if 𝑣(𝑀, πœ‘) = 𝑣(𝑀 β€² , πœ‘) for all πœ‘ ∈ β„±. We shall now define four formal problems relating
to explainability. The problems do work especially well for finite 𝑉, but this is not required
as long as the elements of 𝑉 are representable in the sense that they can be used as inputs to
computational problems.

Definition 4. Let 𝐿 = (β„³, β„± , 𝑣, π‘š) be a logic. We define the following four problems for 𝐿.
General explanation problem:
Input: πœ‘ ∈ β„±, Output: πœ“ ∈ β„±
Description: Find πœ“ ∈ β„± with πœ“ ≑ πœ‘ and minimal π‘š(πœ“ ).
Special explanation problem
Input: (𝔐, πœ‘, 𝑏) where 𝔐 ∈ β„³, πœ‘ ∈ β„± and 𝑏 ∈ 𝑉, Output: πœ“ ∈ β„± or e r r o r
Description: If 𝑣(𝔐, πœ‘) β‰  𝑏, output e r r o r . Else find πœ“ ∈ β„± with minimal π‘š(πœ“ ) such that the
following two conditions hold:
   (1) 𝑣(𝔐, πœ“ ) = 𝑏 and
   (2) For all 𝔐′ ∈ β„³, 𝑣(𝔐′ , πœ“ ) = 𝑏 β‡’ 𝑣(𝔐′ , πœ‘) = 𝑏.
General explainability problem
Input: (πœ‘, π‘˜), where πœ‘ ∈ β„± and π‘˜ ∈ β„•, Output: Yes or no
Description: If there is πœ“ ∈ β„± with πœ“ ≑ πœ‘ and π‘š(πœ“ ) ≀ π‘˜, output yes. Otherwise output no.
Special explainability problem
Input: (𝔐, πœ‘, 𝑏, π‘˜) where 𝔐 ∈ β„³, πœ‘ ∈ β„±, 𝑏 ∈ 𝑉 and π‘˜ ∈ β„•, Output: Yes or no
Description: Output β€œyes” if and only if there exists some πœ“ ∈ β„± with π‘š(πœ‘) ≀ π‘˜ such that the
conditions (1) and (2) of the special explanation problem hold.

   In the full version, we shall generalize these definitions, but the current ones suffice here.
However, already in the current framework, the notions are quite flexible. Notice, for example,
that while the set β„³ may typically be considered a set of models, or pieces of data, there are
many further natural possibilities. For instance, β„³ can be a set of formulas. This nicely covers,
e.g., model-free settings based on proof systems.

3.1. Special explainability for PL
Let (πœ‘, πœ“ , 𝑏) be an input to the special explanation problem of propositional logic, where πœ‘
is a maximal conjunction w.r.t. some (any) finite Ξ¦ (thus encoding a Ξ¦-assignment) and πœ“ a
Ξ¦-formula. The special explanation problem can be reformulated equivalently in the following
way. (1) Suppose 𝑏 = ⊀. If πœ‘ ⊧ πœ“, find a minimal interpolant between πœ‘ and πœ“. Else output e r r o r .
(2) Suppose 𝑏 = βŠ₯. If πœ‘ ⊧ Β¬πœ“, find a minimal interpolant between πœ“ and Β¬πœ‘. Else output e r r o r .
   Let πœ‘ ∈ PL(Ξ¦) be a conjunction of literals. Let 𝑃(πœ‘) and 𝑁 (πœ‘) be the sets of positive and
negative literals in πœ‘, respectively. We denote the De Morgan transformations of πœ‘ and Β¬πœ‘ by

       DM(πœ‘) ∢= β‹€ 𝑝 ∧ Β¬(           ⋁        π‘ž)   and   DM(Β¬πœ‘) ∢= Β¬( β‹€ 𝑝) ∨           ⋁        π‘ž.
                   π‘βˆˆπ‘ƒ(πœ‘)        Β¬π‘žβˆˆπ‘ (πœ‘)                              π‘βˆˆπ‘ƒ(πœ‘)      Β¬π‘žβˆˆπ‘ (πœ‘)

Lemma 5. Let Ξ¦ be a finite set of proposition symbols, let πœ‘ be a maximal conjunction w.r.t. Ξ¦
and let πœ“ ∈ PL(Ξ¦). (1) If πœ‘ ⊧ πœ“, then there is a subconjunction πœ’ of πœ‘ such that DM(πœ’ ) is a minimal
interpolant between πœ‘ and πœ“. (2) If πœ‘ ⊧ Β¬πœ“, then there is a subconjunction πœ’ of πœ‘ such that DM(Β¬πœ’ )
is a minimal interpolant between πœ“ and Β¬πœ‘.

Proof. Assume that πœ‘ ⊧ πœ“. Clearly at least one minimal interpolant exists, as for example πœ‘ itself
is an interpolant. Let πœƒ be a minimal interpolant. Let Ξ¦(πœƒ) be the set of proposition symbols
occurring in πœƒ. We transform πœƒ into an equivalent formula πœƒ β€² in Ξ¦(πœƒ)-full disjunctive normal
form where each disjunct is a maximal conjunction w.r.t. Ξ¦(πœƒ). To see that such a form always
exists, first consider the DNF of πœƒ and then, for each disjunct, fill in all possible values of any
missing propositions (thus possibly increasing the number of disjuncts).
   Now, as πœ‘ is a maximal conjunction w.r.t. Ξ¦, exactly one disjunct of πœƒ β€² is a subconjunction of
πœ‘. Let πœ’ denote this disjunct. As πœ‘ ⊧ πœ“, the formula πœ’ is clearly an interpolant between πœ‘ and πœ“.
   Now, each proposition in Ξ¦(πœƒ) occurs in πœ’ and thus also in DM(πœ’ ) exactly once, so DM(πœ’ )
has at most the same number of occurrences of proposition symbols and binary connectives as
πœƒ. Furthermore, DM(πœ’ ) has at most one negation. If πœƒ has no negations, then we claim DM(πœ’ )
also has none. To see this, note that πœ’ is a disjunct of πœƒ β€² and πœƒ β€² is equivalent to πœƒ, so πœ’ ⊧ πœƒ. As
πœƒ is negation-free, we have πœ’ β€² ⊧ πœƒ where πœ’ β€² is obtained from πœ’ by removing all the negative
literals. Hence, by the minimality of πœƒ, we have πœ’ β€² = πœ’. Thus πœ’ and DM(πœ’ ) are negation-free.
We have shown that size(DM(πœ’ )) ≀ size(πœƒ), so DM(πœ’ ) is a minimal interpolant.
   Suppose then that πœ‘ ⊨ Β¬πœ“. Let πœƒ be a minimal interpolant between πœ“ and Β¬πœ‘. In a dual fashion
compared to the positive case above, we transform πœƒ into an equivalent formula πœƒ β€² in Ξ¦(πœƒ)-full
conjunctive normal form. Additionally let πœ‘ β€² be the negation normal form of Β¬πœ‘. Now πœ‘ β€² is a
disjunction of literals and exactly one conjunct of πœƒ β€² is a subdisjunction of πœ‘ β€² . Let πœ’ β€² denote
this conjunct and let πœ’ denote the negation normal form of Β¬πœ’ β€² . Now πœ’ is a subconjunction of πœ‘
and Β¬πœ’ is an interpolant between πœ“ and Β¬πœ‘.
   As in the positive case, DM(Β¬πœ’ ) has at most the same number of proposition symbols and
binary connectives as the minimal interpolant πœƒ. The formula DM(Β¬πœ’ ) again has at most one
negation so we only check the case where πœƒ has no negations. Recall that Β¬πœ’ is equivalent
to πœ’ β€² , which in turn is a conjunct of πœƒ β€² . Thus πœƒ ⊨ πœ’ β€² . As πœƒ has no negations and πœ’ β€² is a
disjunction of literals, we have πœƒ ⊨ πœ’ β€³ , where πœ’ β€³ is obtained from πœ’ β€² by removing all the
negative literals. By the minimality of πœƒ we obtain πœ’ β€³ = πœ’ β€² so πœ’ β€² has no negations. Thus also
DM(Β¬πœ’ ) is negation-free and is a minimal interpolant.

   The above lemma implies that for propositional logic, it suffices to consider subconjunctions
of the input in the special explanation and explainability problems. This will be very useful
both in the below theoretical considerations and in implementations.
                    𝑝
   We next prove Ξ£2 -completeness of the special explainability problem via a reduction from
                                    𝑝
Ξ£2 𝑆𝐴𝑇, which is well-known to be Ξ£2 -complete. The input of the problem is a quantified Boolean
formula πœ‘ of the form βˆƒπ‘1 … βˆƒπ‘π‘› βˆ€π‘ž1 … βˆ€π‘žπ‘š πœƒ(𝑝1 , … , 𝑝𝑛 , π‘ž1 , … , π‘žπ‘š ). The output is yes iff πœ‘ is true.
                                                                 𝑝
Theorem 6. The special explainability problem for PL is Ξ£2 -complete.

Proof. The upper bound is clear. For the lower bound, we will give a polynomial time (Karp-)
reduction from Ξ£2 𝑆𝐴𝑇. Consider an instance βˆƒπ‘1 … βˆƒπ‘π‘› βˆ€π‘ž1 … βˆ€π‘žπ‘š πœƒ(𝑝1 , … , 𝑝𝑛 , π‘ž1 , … , π‘žπ‘š ) of Ξ£2 𝑆𝐴𝑇.
We start by introducing, for every existentially quantified Boolean variable 𝑝𝑖 , a new proposition
symbol 𝑝𝑖 . Denoting πœƒ(𝑝1 , … , 𝑝𝑛 , π‘ž1 , … , π‘žπ‘š ) simply by πœƒ, we define
                                         𝑛                  𝑛
                                πœ“ ∢= β‹€(𝑝𝑖 ∨ 𝑝𝑖 ) ∧ (πœƒ ∨ ⋁(𝑝𝑖 ∧ 𝑝𝑖 )).
                                        𝑖=1                𝑖=1

We let 𝑠 be the valuation mapping all proposition symbols to 1, i.e., the assignment corresponding
                                          𝑛                   π‘š
to the maximal conjunction πœ‘π‘  ∢= ⋀𝑖=1 (𝑝𝑖 ∧ 𝑝𝑖 ) ∧ ⋀𝑗=1 π‘žπ‘— w.r.t. the set of proposition symbols in
πœ“. Clearly πœ‘π‘  ⊧ πœ“. We now claim that there exists an interpolant of size at most 2𝑛 βˆ’ 1 between
πœ‘π‘  and πœ“ iff the original instance of Ξ£2 𝑆𝐴𝑇 is true.
    Suppose first that the original instance of Ξ£2 𝑆𝐴𝑇 is true. Thus there exists a tuple (𝑝1 , … , 𝑝𝑛 ) ∈
{0, 1}𝑛 such that βˆ€π‘ž1 … π‘žπ‘š πœƒ(𝑝1 , … , 𝑝𝑛 , π‘ž1 , … , π‘žπ‘š ) is true. Consider now the subconjunction πœ’ ∢=
⋀𝑠(𝑝𝑖 )=1 𝑝𝑖 ∧ ⋀𝑠(𝑝𝑖 )=0 𝑝𝑖 of πœ‘π‘  . Clearly πœ’ is of size 2𝑛 βˆ’ 1. It is easy to see that πœ’ is also an
interpolant between πœ‘π‘  and πœ“.
    Suppose then that πœ’ is an interpolant of size at most 2𝑛 βˆ’ 1 between πœ‘π‘  and πœ“. Using Lemma
5, we can assume that πœ’ is a subconjunction of πœ‘π‘  . Since πœ’ has size at most 2𝑛 βˆ’ 1, it can contain
at most 𝑛 proposition symbols. Furthermore, πœ’ must contain, for every 𝑖 ∈ {1, … , 𝑛}, either 𝑝𝑖 or
                                                  𝑛
𝑝𝑖 , since otherwise πœ’ would not entail ⋀𝑖=1 (𝑝𝑖 ∨ 𝑝𝑖 ). Thus πœ’ contains precisely 𝑛 proposition
symbols. More specifically, πœ’ contains, for every 𝑖 ∈ {1, … , 𝑛}, either 𝑝𝑖 or 𝑝𝑖 . Now, we define a
tuple (𝑒1 , … , 𝑒𝑛 ) ∈ {0, 1}𝑛 by setting 𝑒𝑖 = 1 if πœ’ contains 𝑝𝑖 and 𝑒𝑖 = 0 if πœ’ contains 𝑝𝑖 . It is easy
to see that βˆ€π‘ž1 … π‘žπ‘š πœƒ(𝑒1 , … , 𝑒𝑛 , π‘ž1 , … , π‘žπ‘š ) is true.

  The above theorem immediately implies a wide range of corollaries. Recall that S5 is the sys-
tem of modal logic where the accessibility relations are equivalences. The special explainability
problem for S5 has as input a pointed S5-model (𝔐, 𝑀), an S5-formula πœ‘, 𝑏 ∈ {⊀, βŠ₯} and π‘˜ ∈ β„•.
                                                                 𝑝
Corollary 7. The special explainability problem for S5 is Ξ£2 -complete.

Proof. The lower bound follows immediately from Theorem 6, while the upper bound follows
from the well-known fact that the validity problem for S5 is coNP-complete [6].
                           𝑝
    Note indeed that the Ξ£2 lower bound for propositional logic is a rather useful result, implying
  𝑝
Ξ£2 -completeness of special explainability for various logics with an NP-complete satisfiability.
    We next show that if the formula πœ“ in the special explainability problem is restricted to
CNF -formulas and we consider only the case 𝑏 = ⊀, then the problem is NP-complete. The
following example demonstrates that it is necessary to restrict to the case 𝑏 = ⊀.

Example 8. Let πœ“ ∈ PL(Ξ¦) be an arbitrary CNF -formula and let π‘ž be a proposition symbol such
that π‘ž βˆ‰ Ξ¦. Suppose that 𝑠 ⊭ πœ“, where 𝑠(𝑝) = 1 for every 𝑝 ∈ Ξ¦. Consider now the formula
πœ‘π‘ž ∢= π‘ž ∨ β‹π‘βˆˆΞ¦ ¬𝑝. Note that Β¬πœ‘π‘ž is equivalent to a maximal conjunction w.r.t. Ξ¦ βˆͺ {π‘ž}. Clearly
πœ“ ∧ Β¬π‘ž ⊧ πœ‘π‘ž , since πœ“ entails that β‹π‘βˆˆΞ¦ ¬𝑝. We now claim that there exists an interpolant πœ’ of
size one between πœ“ ∧ Β¬π‘ž and πœ‘π‘ž iff πœ“ is unsatisfiable. First, we note that the only proposition
from Ξ¦ βˆͺ {π‘ž} which entails πœ‘π‘ž is π‘ž. But the only way π‘ž can be an interpolant between πœ“ ∧ Β¬π‘ž
and πœ‘π‘ž is that πœ“ is unsatisfiable. Conversely, if πœ“ is unsatisfiable, then π‘ž is clearly an interpolant
between πœ“ ∧ Β¬π‘ž and πœ‘π‘ž . Since the unsatisfiability problem of CNF -formulas is coNP-hard, the
special explainability problem for CNF -formulas is also coNP-hard.

   To prove NP-hardness, we will give a reduction from the dominating set problem. For a
graph 𝐺 = (𝑉 , 𝐸), a dominating set 𝐷 βŠ† 𝑉 is a set of vertices such that every vertex not in 𝐷
is adjacent to a vertex in 𝐷. The input of the dominating set problem is a graph and a natural
number π‘˜. The output is yes, if the graph has a dominating set of at most π‘˜ vertices.

Theorem 9. For CNF -formulas, the special explainability problem with 𝑏 = ⊀ is NP-complete.
The lower bound holds even if we restrict our attention to formulas without negations.

Proof. For the upper bound, let πœ“ ∈ PL(Ξ¦) be a CNF -formula and let πœ‘ be a maximal conjunction
w.r.t. Ξ¦. We want to determine whether there is an interpolant of size at most π‘˜. Using Lemma
5, it suffices to determine whether there is a subconjunction πœ’ of πœ‘ such that size(DM(πœ’ )) ≀ π‘˜.
   Our nondeterministic procedure will start by guessing a subconjunction πœ’ of πœ‘. If
size(DM(πœ’ )) > π‘˜, then it rejects. Otherwise we replace the formula πœ“ with the formula πœ“ β€²
which is obtained from πœ“ by replacing each proposition symbol 𝑝 that occurs in πœ’ with either ⊀
or βŠ₯, depending on whether 𝑝 occurs positively or negatively in πœ’. Now, if πœ“ β€² is valid, then our
procedure accepts, and if it is not, then it rejects. Since the validity of CNF -formulas can be
decided in polynomial time, our procedure runs in polynomial time as well.
  For the lower bound we will give a reduction from the dominating set problem. Consider a
graph 𝐺 = (𝑉 , 𝐸) and a parameter π‘˜. Let

                                           πœ“ ∢= β‹€ (𝑝𝑣 ∨ ⋁ 𝑝𝑒 )                                                  (1)
                                                 π‘£βˆˆπ‘‰        (𝑣,𝑒)∈𝐸

and πœ‘ ∢= β‹€π‘£βˆˆπ‘‰ 𝑝𝑣 . Now πœ‘ ⊧ πœ“ and πœ“ is a CNF -formula. It is easy to verify that there exists an
interpolant πœƒ of size at most 2π‘˜ βˆ’ 1 if and only if 𝐺 has a dominating set of size at most π‘˜.

  By simply negating formulas, we obtain that the special explainability problem with 𝑏 = βŠ₯ is
NP-complete for DNF -formulas (and in general coNP-hard, see Example 8).

Corollary 10. For DNF -formulas, the special explainability problem with 𝑏 = βŠ₯ is NP-complete.

3.2. On general explainability
The general explainability problem for propositional logic has been discussed in the literature
under motivations unrelated to explainability. The minimum equivalent expression prob-
lem MEE asks, given a formula πœ‘ and an integer π‘˜, if there exists a formula equivalent to πœ‘
                                                                        𝑝
and of size at most π‘˜. This problem has been shown in [7] to be Ξ£2 -complete under Turing
reductions, with formula size defined as the number of occurrences of proposition symbols and
with formulas in negation normal form. The case of standard reductions is open.
   For logics beyond PL, the literature on the complexity of formula minimization is surprisingly
scarce. The study of formula size in first-order and modal logics has mainly focused on particular
properties that either can be expressed very succinctly or via a very large formulas. This leads to
relative succinctness results between logics. For lack of space, we shall not discuss the general
explainability problem further in the current article, but instead leave the topic for the future.


4. Implementation
In this section, we devise a proof-of-concept implementation of explainability problems defined
above. The implementation exploits the ASP fragment of the Clingo system1 combining the
Gringo grounder with the Clasp solver. However, we adopt the modular approach of [8] for
the representation of oracles, thus hiding disjunctive rules and their saturation from encodings.
Since CNF -formulas are dominant in the context of SAT checking, we devise our first imple-
mentation under an assumption that input formulas take this form. Thus, in spirit of Lemma 5,
πœ‘ is essentially a set 𝐿 of literals and πœ“ is a set 𝑆 of clauses, i.e., disjunctions of literals. To enable
meta-level encodings in ASP, a CNF -formula in DIMACS format can be reified into a set of
first-order (ground) facts using the lpreify tool2 (option flag - d ). Using additional rules, we
define domain predicates c l a u s e / 1 , p c o n d / 2 , and n c o n d / 2 for identifying clauses, their positive
conditions, and negative conditions respectively. The literals in the set 𝐿 are expressed by using
domain predicates p l i t / 1 and n l i t / 1 for positive and negative literals, respectively.

1
    https://potassco.org/clingo/
2
    https://github.com/asptools/software
                           Listing 1: Checking Positive Precondition (Lemma 5)
1   :- clause(C), nlit(P): pcond(C,P); plit(N): ncond(C,N).
2   simp(C) :- plit(P), pcond(C,P).          simp(C) :- nlit(N), ncond(C,N).
3   simp(C) :- pcond(C,A), ncond(C,A).
4   :- clause(C), not simp(C), pcond(C,P), not plit(P), not nlit(P).
5   :- clause(C), not simp(C), ncond(C,N), not plit(N), not nlit(N).



                          Listing 2: Checking Negative Precondition (Lemma 5)
1 t(A) :- plit(A), atom(A).
2 { t(A) } :- atom(A), not plit(A), not nlit(A).
3 :- clause(C), not t(P): pcond(C,P); t(N): ncond(C,N).



        We relax the requirement that the set of literals 𝐿 is maximal, so that any three-valued
    interpretation can be represented. However, the precondition for the positive (resp. negative)
    explanation is essentially the same: the result 𝑆 ∣𝐿 of partially evaluating 𝑆 with respect to 𝐿 must
    remain valid (resp. unsatisfiable) in accordance to Lemma 5. The positive check is formalized in
    Listing 1. The constraint in Line 1 excludes the possibility that 𝐿 falsifies 𝑆 directly. Lines 2–3
    detect which clauses of 𝑆 are immediately true given 𝐿 and removed from 𝑆 ∣𝐿 altogether. Rules
    in Lines 4 and 5 deny any clause containing yet open literals that could be used to falsify the
    clause in question. The net effect is that the encoding extended by facts describing 𝐿 and 𝑆 has
    an answer set iff 𝑆 ∣𝐿 is valid. Since the scope of negation is restricted to domain predicates only,
    the check is effectively polytime. The negative case can be handled by a single ASP program
    evaluating a coNP query, see Listing 2. The rule in Line 1 infers any positive literal in 𝐿 to be
    true while the negative ones in 𝐿 remain false by default. In Line 2, the truth values of atoms
    undefined in 𝐿 are freely chosen. The constraint in Line 3 ensures that each clause in the input
    𝑆 must be satisfied. Thus 𝑆 ∣𝐿 is unsatisfiable iff the encoding extended by facts describing 𝐿 and
    𝑆 has no answer set. In general, this check is deemed worst-case exponential, but for maximal
    𝐿, the task reduces to simple polytime propagation as no choices are active in Line 2.
        Our more general goal is to find minimum-size explanations 𝐿′ βŠ† 𝐿 possessing the identical
    property as required from 𝐿, i.e., 𝑆 βˆ£πΏβ€² is either valid or unsatisfiable. As regards the size of
    𝐿′ , we leave the mapping back to a minimum-size formula as a post-processing step. In the
    negative case (the second item of Lemma 5), the idea is formalized by Listing 3. While the (fixed)
    set 𝐿 is specified as before using predicates p l i t / 1 and n l i t / 1 , the subset 𝐿′ is determined by
    choosing 𝐿-compatible truth values for atoms in Line 1. The resulting size of 𝐿′ is put subject
    to minimization in Line 3 if k = 0 , as set by default in Line 2. Positive values k > 0 set by the user
    activate the special explainability mode: the size of 𝐿′ is at most k by the cardinality constraint
    in Line 4. Besides this objective, we check that 𝐿′ βˆͺ 𝑆 is unsatisfiable by using an oracle encoded
    in Listing 4. The input atoms (cf. [8]) are declared in Line 1. The predicate e t / 1 captures a
    two-valued truth assignment compatible with 𝐿′ as enforced by Lines 2 and 3. Moreover, the
    clauses of 𝑆 are satisfied by constraints introduced in Line 4. Thus, the oracle has an answer set
                        Listing 3: Finding Minimum-Size or Bounded-Size Explanations
1   { t(A) } :- atom(A), plit(A).           { f(A) } :- atom(A), nlit(A).
2   #const k=0.
3   #minimize { 1,A: t(A), k=0; 1,A: f(A), k=0}.
4   :- #count { A: t(A); A: f(A)} > k, k>0.



                                      Listing 4: Oracle for the Negative Case
1   { t(A) } :- plit(A).          { f(A) } :- nlit(A).
2   et(A) :- t(A).
3   { et(A) }:- not t(A), not f(A), atom(A).
4   :- clause(C), not et(P): pcond(C,P); et(N): ncond(C,N).



                                     Listing 5: Extension for the Positive Case
1   simp(C) :- t(P), pcond(C,P).          simp(C) :- f(N), ncond(C,N).
2   simp(C) :- pcond(C,A), ncond(C,A).
3   :- clause(C), not simp(C), pcond(C,P), not t(P), not f(P).
4   :- clause(C), not simp(C), ncond(C,N), not t(N), not f(N).



    iff 𝐿′ βˆͺ 𝑆 is satisfiable. However, stable-unstable semantics [9] and the translation unsat2lp from
    [8] yield the complementary effect, amounting to the unsatisfiability of 𝑆 βˆ£πΏβ€² .
        On the other hand, the positive case (the first item of Lemma 5), can be covered by extending
    the program of Listing 3 by further rules in Listing 5. The rules are analogous to those in
    Listing 1, but formulated in terms of predicates t / 1 and f / 1 rather than p l i t / 1 and n l i t / 1 . Thus
    𝐿′ inherits the properties of 𝐿, i.e., the encoding based on Listings 3 and 5 extended by facts
    describing 𝐿 and 𝑆 has an answer set iff 𝑆 βˆ£πΏβ€² is valid for a minimum-size 𝐿′ βŠ† 𝐿.


    5. Experiments
    In what follows, we evaluate the computational performance of the Clingo system by using
    the encodings from Section 4 and two benchmark problems,3 viz. the famous 𝑛-queens (𝑛-
    Qs) problem and the dominating set (DS) problem of undirected graphsβ€”recall the proof of
    Theorem 9 in this respect. Besides understanding the scalability of Clingo in reasoning tasks
    corresponding to explanation problems defined in this work, we get also some indications what
    kinds of explanations are obtained in practice. We study explainability in the context of these
    benchmark problems to be first encoded as SAT problems in CNF using the declarative approach
    from [10]: clauses involved in problem specifications are stated with rules in ASP style, but
    interpreted in CNF by using an adapter called Satgrnd. Thus, the Gringo grounder of Clingo
    3
        https://github.com/asptools/benchmarks
                    Listing 6: Propositional Specification for the 𝑛-Queens Problem
1   #const n=8.
2   pair(X1,X2) :- X1=1..n, X2=X1+1..n.
3   triple(X1,X2,Y1) :- pair(X1,X2), Y1=1..n-(X2-X1).
4   queen(X,Y): Y=1..n :- X=1..n.
5   -queen(X,Y1) | -queen(X,Y2) :- X=1..n, pair(Y1,Y2).
6   -queen(X1,Y) | -queen(X2,Y) :- pair(X1,X2), Y=1..n.
7   -queen(X1,Y1) | -queen(X2,Y1+X2-X1) :- triple(X1,X2,Y1).        % X1+Y2 = X2+Y1
8   -queen(X1,Y1+X2-X1) | -queen(X2,Y1) :- triple(X1,X2,Y1).        % By symmetry



                 Listing 7: Propositional Specification for the Dominating Set Problem
1 vertex(X) :- edge(X,Y).     vertex(Y) :- edge(X,Y).
2 in(X) | in(Y): edge(X,Y) | in(Z): edge(Z,X) :- vertex(X).



    can be readily used for the instantiation of the respective propositional schemata, as given in
    Listings 6 and 7, for subsequent SAT solving.
       Our 𝑛-Qs encoding in Listing 6 introduces a default value for the number of queens n in
    Line 1 and, based on n , the pairs and triples of numbers relevant for the construction of clauses
    are formed in Lines 2 and 3. Then, for the queen in a column X , the length n clause in Line 4
    chooses a row Y made unique for X by the clauses introduced in Line 5. Similarly, columns
    become unique by the clauses in Line 6. Finally, queens on the same diagonal are denied by
    clauses resulting from Lines 7 and 8. Turning our attention to the DS problem in Listing 7,
    vertices are extracted from edges in Line 1. The clauses generated in Line 2 essentially capture
    the disjunctions collected as parts of πœ“ in (1): our encoding assumes that the edges of the graph
    are provided as ordered pairs for the sake of space efficiency. Intuitively, given any vertex X in
    the graph, either it is in the (dominating) set or any of its neighboring vertices is.
       In the experiments, we evaluate the performance of the Clasp solver (v. 3.3.5) when used to
    solve various explainability problems. All test runs are executed on a cluster of Linux machines
    with Intel Xeon 2.40 GHz CPUs, and a memory limit of 16 GB. We report only the running times
    of the solver, since the implementations of grounding and translation steps are suboptimal due
    to our meta-level approach and such computations could also be performed off-line in general,
    and it is worth emphasizing that our current method has been designed to work for any CNF
    and set of literals given as input. For 𝑛-Qs, we generate (i) positive instances by searching for
    random solutions to the problem with different values of 𝑛 and (ii) negative instances by moving,
    in each solution found, one randomly selected queen to a wrong row. The respective truth
    assignments are converted into sets of literals 𝐿 ready for explaining. For DS, we first generate
    random planar graphs of varying sizes and search for minimum-size dominating sets for them.
    Then, negative instances are obtained by moving one random vertex outside each optimal set
    and by describing the outcomes as sets of literals 𝐿. For positive instances, we include the
    positive literal i n ( X ) in 𝐿 for all vertices X , in analogy to the reduction deployed in Theorem 9.
                                                                    10 4                                                            10 3

            10 2
                                                                                                                                    10 2


                                                                    10 2                                                            10 1
 Time (s)




                                                         Time (s)




                                                                                                                         Time (s)
            10 0
                                                                                                                                    10 0


                                                                    10 0                                                            10 -1

            10 -2
                                                                                                                                    10 -2

                                                                    10 -2                                                           10 -3
                    100   200        300     400   500                   10   15   20    25    30   35    40   45   50                      8   10   12    14    16   18     20   22   24
                                Number of Nodes                                         Number of Nodes                                                   Number of Queens

                                    (a)                                                       (b)                                                               (c)
Figure 1: Experimental Results on Explaining DS Positively (a), Negatively (b), and 𝑛-Qs Negatively (c).


   The results of our experiments are collected in Figure 1. Since initial screening suggests that
explanation under exact size bounds is computationally more difficult, we present only results
obtained by minimizing the size of 𝐿 using the Clasp solver in its unsatisfiable core (USC) mode.
Figure 1a shows the performance of Clasp when searching for positive explanations for DS based
on planar graphs from 100 up to 550 vertices. Explanations are minimum-size dominating sets.
The performance obtained for the respective negative explanations is presented in Figure 1b.
In spite of somewhat similar scaling, far smaller planar graphs with the number of vertices in
the range 10 … 50 can be covered. In this case, explanations consist of sets of vertices based on
some vertex and its neighbors. The final plot in Figure 1c concerns 𝑛-Qs when 𝑛 = 8 … 24 and
negative explanations are sought. Explanations obtained from the runs correspond to either (i)
single (misplaced) queens or (ii) pairs of (threatening) queens. The respective positive instances
simply reproduce solutions and are computationally easy. Therefore, they are uninteresting.
   Some observations are in order. The instances obtained by increasing their size, i.e., either
the number of vertices or queens, give rise to higher running times almost systematically. For
each size, the time is computed as an average for running 10 instances of equal size. Due to
logarithmic scale, running times tend to scale exponentially. Moreover, positive explanations
appear to be easier to find than negative ones in compliance with complexity results.


6. Conclusion
We have provided general, logic-based definitions of explainability and studied the particular
case of propositional logic in detail. The related Σ𝑃2 -completeness result gives a useful, robust
lower bound for a wide range of more expressive logics and future work. We have also shown
NP-completeness of the explainability problems with formulas in CNF and DNF when the input
truth value is restricted. Moreover, we have presented a proof-of-concept implementation for
the explanation of CNF -formulas (without truth value restrictions). Our experimental results
confirm the expected worst-case exponential runtime behavior of Clasp. Negative explanations
have higher computational cost than positive explanations. The optimization variants of
explanation problems seem interesting, because the USC strategy seems very effective and the
users need not provide fixed bounds for queries in advance.
References
 [1] G. Brewka, T. Eiter, M. Truszczynski, Answer set programming at a glance, Commun.
     ACM 54 (2011) 92–103. doi:1 0 . 1 1 4 5 / 2 0 4 3 1 7 4 . 2 0 4 3 1 9 5 .
 [2] P. Simons, I. NiemelΓ€, T. Soininen, Extending and implementing the stable model semantics,
     Artif. Intell. 138 (2002) 181–234. doi:1 0 . 1 0 1 6 / S 0 0 0 4 - 3 7 0 2 ( 0 2 ) 0 0 1 8 7 - X .
 [3] T. Eiter, G. Gottlob, On the computational cost of disjunctive logic programming: Proposi-
     tional case, Ann. Math. Artif. Intell. 15 (1995) 289–323. doi:1 0 . 1 0 0 7 / B F 0 1 5 3 6 3 9 9 .
 [4] A. Shih, A. Choi, A. Darwiche, A symbolic approach to explaining Bayesian network
     classifiers, in: J. Lang (Ed.), IJCAI, 2018, pp. 5103–5111. doi:1 0 . 2 4 9 6 3 / i j c a i . 2 0 1 8 / 7 0 8 .
 [5] C. Umans, The minimum equivalent DNF problem and shortest implicants, J. Comput.
     Syst. Sci. 63 (2001) 597–611. doi:1 0 . 1 0 0 6 / j c s s . 2 0 0 1 . 1 7 7 5 .
 [6] P. Blackburn, M. de Rijke, Y. Venema, Modal Logic, volume 53 of Cambridge Tracts in Theo-
     retical Computer Science, Cambridge University Press, 2001. doi:1 0 . 1 0 1 7 / C B O 9 7 8 1 1 0 7 0 5 0 8 8 4 .
 [7] D. Buchfuhrer, C. Umans, The complexity of Boolean formula minimization, J. Comput.
     Syst. Sci. 77 (2011) 142–153. doi:1 0 . 1 0 1 6 / j . j c s s . 2 0 1 0 . 0 6 . 0 1 1 .
 [8] T. Janhunen, Implementing stable-unstable semantics with ASPTOOLS and clingo, in:
     J. Cheney, S. Perri (Eds.), PADL, 2022, pp. 135–153. doi:1 0 . 1 0 0 7 / 9 7 8 - 3 - 0 3 0 - 9 4 4 7 9 - 7 \ _ 9 .
 [9] B. Bogaerts, T. Janhunen, S. Tasharrofi, Stable-unstable semantics: Beyond NP with
     normal logic programs, Theory Pract. Log. Program. 16 (2016) 570–586. doi:1 0 . 1 0 1 7 /
     S1471068416000387.
[10] M. Gebser, T. Janhunen, R. Kaminski, T. Schaub, S. Tasharrofi, Writing declarative
     specifications for clauses, in: L. Michael, A. C. Kakas (Eds.), JELIA, 2016, pp. 256–271.
     doi:1 0 . 1 0 0 7 / 9 7 8 - 3 - 3 1 9 - 4 8 7 5 8 - 8 \ _ 1 7 .



Acknowledgments
Tomi Janhunen, Antti Kuusisto, Masood Feyzbakhsh Rankooh and Miikka Vilander were sup-
ported by the Academy of Finland consortium project Explaining AI via Logic (XAILOG), grant
numbers 345633 (Janhunen) and 345612 (Kuusisto). Antti Kuusisto was also supported by the
Academy of Finland project Theory of computational logics, grant numbers 324435, 328987 (to
December 2021) and 352419, 352420 (from January 2022). The author names of this article have
been ordered on the basis of alphabetic order.