From 3-valued Semantics to Supported Model Computation for Logic
Programs in Vector Spaces
Taisuke Sato
1 a
, Chiaki Sakama
2 b
and Katsumi Inoue
3 c
1
National Institute of Advanced Industrial Science and Technology, Japan
2
Wakayama University, Japan
3
National Institute of Informatics, Japan
Keywords:
Dualized Logic Program, Supported Model, 3-valued, Vector Space.
Abstract:
We propose a linear algebraic approach to computing 2-valued and 3-valued completion semantics of finite
propositional normal logic programs in vector spaces. We first consider 3-valued completion semantics and
construct the least 3-valued model of comp(DB), i.e. the iff (if-and-only-if) completion of a propositional nor-
mal logic program DB in Kleene’s 3-valued logic which has three truth values {t(true), f(false), (undefined)}.
The construction is carried out in a vector space by matrix operations applied to the matricized version of a
dualized logic program DB
d
of DB. DB
d
is a definite clause program compiled from DB and used to compute
the success set P
as true atoms and finite failure set N
as false atoms that constitute the least 3-valued model
I
= (P
, N
) of comp(DB). We then construct a supported model of DB, i.e. a 2-valued model of comp(DB)
by carefully assigning t or f to undefined atoms not in P
or N
so that the resulting model is 2-valued and
supported. The assigning process is guided by an atom dependency relation on undefined atoms. We imple-
mented our proposal by matrix operations and conducted an experiment with random normal logic programs
which demonstrated the effectiveness of our linear algebraic approach to computing completion semantics.
1 INTRODUCTION
Performing logical inference in vector spaces has
been studied as an attractive alternative to the tra-
ditional symbolic inference which opens a way to
take advantage of flexible matrix operations in vector
spaces and associated parallelism supported by recent
computer technologies (Sato, 2017; Sakama et al.,
2017; Sato et al., 2018). For example it was demon-
strated Datalog programs can be computed orders of
magnitude faster in vector spaces than by symbolic
computation when relations are not too sparse (Sato,
2017). Also it is possible to invent new relations for
more than 10
4
entities from real knowledge graphs by
reformulating abduction in vector spaces (Sato et al.,
2018). In this paper, along the same line, we develop
a linear algebraic approach to computing completion
semantics of logic programs in vector spaces.
a
https://orcid.org/0000-0001-9062-0729
b
https://orcid.org/0000-0002-9966-3722
c
https://orcid.org/0000-0002-2717-9122
This paper is based on results obtained from a project
commissioned by the New Energy and Industrial Technol-
ogy Development Organization (NEDO).
We first consider 3-valued completion semantics
and construct the least 3-valued model of comp(DB)
where comp(DB) is the iff (if-and-only-if) completion
of a finite propositional normal logic program DB as
the 3-valued denotation of DB, in Kleene’s 3-valued
logic which is based on three truth values {t(true),
f(false), (undefined)} (Fitting, 1985; Kunen, 1987).
We prove that the model construction can be deter-
ministically carried out in a vector space by matrix
operations applied to the matricized version of a du-
alized logic program DB
d
of DB. DB
d
is a finite def-
inite clause program compiled from DB and used to
compute DB’s success set P
as true atoms, and DB’s
finite failure set N
as false atoms. They constitute
the least 3-valued model I
= (P
, N
) of comp(DB).
We then construct a 2-valued model of comp(DB),
i.e. supported model (Apt et al., 1988; Marek and
V.S.Subrahmanian, 1992) of DB by appropriately as-
signing t or f to undefined atoms not in P
or N
so
that the resulting model is 2-valued and supported.
Every supported model of DB is obtained this way.
The assignment process is guided by an atom de-
pendency relation on undefined atoms and processes
them from bottom-layers. Since every true (resp.
758
Sato, T., Sakama, C. and Inoue, K.
From 3-valued Semantics to Supported Model Computation for Logic Programs in Vector Spaces.
DOI: 10.5220/0009093407580765
In Proceedings of the 12th International Conference on Agents and Artificial Intelligence (ICAART 2020) - Volume 2, pages 758-765
ISBN: 978-989-758-395-7; ISSN: 2184-433X
Copyright
c
2022 by SCITEPRESS Science and Technology Publications, Lda. All rights reserved
false) atom in I
remains true (resp. false) in any sup-
ported model of DB, we may say that I
represents
the “deterministic part” of supported models (or sta-
ble models) of DB. To our knowledge, our approach
is the first that computes 3-valued completion seman-
tics in vector spaces and also the first that computes
the deterministic part of supported models separately.
2 PRELIMINARIES
In this paper, programs mean finite propositional nor-
mal logic programs DB made up of a set of atoms A
unless otherwise stated. Write DB = {a
i
B
i
| 1 i
N, a
i
A } where B
i
is a conjunction of literals whose
atoms are in A
1
. Let a B
1
, . . . , a B
k
be clauses
about a in DB. Introduce new constant atoms true
and false respectively denoting t and f. We define
the iff (if-and-only-if) completion about a as follows.
If k = 0, i.e. there is no clause about a, put
iff(a) = a false. If k = 1 and B
1
is an empty con-
junction, i.e. a is a unit clause, put iff(a) = a true.
Otherwise put iff(a) = a B
1
··· B
k
. The com-
pletion of DB, denoted by comp(DB), is defined as
comp(DB) = {iff(a) | a A }.
We consider 3-valued completion semantics of
logic programs following Fitting and Kunen(Fitting,
1985; Kunen, 1987). Their semantics is based on
Kleene’s 3-valued logic that has three truth values {
t(true), f(false), (undefined) }. In Kleene’s 3-valued
logic, when neither A nor B is , conjunction A B,
disjunction A B and negation ¬A are evaluated as
usual. However, if one of them is , we obey the fol-
lowing rules; A B = iff one conjunct is and the
other is not false, A B = iff one disjunct is and
the other is not true, and ¬A = iff A = . We treat
implication A B as ¬A B. Accordingly =
.
A 3-valued interpretation I in A is a pair (P, N)
such that P N A and P N =
/
0 where P stands
for true atoms and N for false atoms. We next de-
fine [[F]]
I
{t, f, ⊥}, i.e. the truth value of a Boolean
formula F evaluated by I = (P, N). We first define
[[true]]
I
= t and [[false]]
I
= f, then define [[F]]
I
for
F = a A by [[a]]
I
= t, f and respectively if a P,
a N and otherwise and extend the definition to com-
pound Boolean formulas according to Kleene’s 3-
valued logic.
Since we are interested in comp(DB), in particular
in iff(a) = a B
1
· ·· B
k
and the equality of truth
values of a and B
1
· ·· B
k
, we deviate here from
1
Throughout this paper, we assume that if a program has
a unit clause a , there is no other clause about a in the
program.
Kleene’s 3-valued logic and interpret in a 2-valued
way. We stipulate that [[A B]]
I
= t if [[A]]
I
= [[B]]
I
.
Otherwise [[A B]]
I
= f. So [[ ]]
I
= t and [[
t]]
I
= f. If [[iff(a)]]
I
= t holds for every a A , we
call I a 3-valued model of comp(DB) or equivalently
a 3-valued completion model of DB
2
.
It is known that Fitting’s 3-valued semantics of
normal logic programs is highly undecidable whereas
Kunen’s 3-valued one is recursively enumerable (Fit-
ting, 1985; Kunen, 1987), but they coincide in the
case of finite propositional normal logic programs,
which we describe next. Here we inductively define
a series of 3-valued interpretations I
0
= (P
0
, N
0
), I
1
=
(P
1
, N
1
), . . . (Sato, 1990).
(base case) P
0
= N
0
=
/
0
(inductive step)
Put I
n1
= (P
n1
, N
n1
)
P
n
= {a A | there is a B in DB s.t. [[B]]
I
n1
= t }
N
n
= {a A | for all a B in DB, [[B]]
I
n1
= f}
Figure 1: Defining 3-valued interpretations {(P
n
, N
n
)}.
It is straightforward to verify P
n
N
n
=
/
0 (n=0,1. . . ),
and hence I
n
= (P
n
, N
n
) is a 3-valued interpretation.
Let (A
1
, A
2
) and (B
1
, B
2
) be pairs of sets. We in-
troduce a partial ordering v on pairs of sets by
(A
1
, A
2
) v (B
1
, B
2
) iff A
1
B
1
and A
2
B
2
. Now
we see I
0
v I
1
v ··· (Sato, 1990). We introduce P
by P
=
S
P
n
and N
by N
=
S
N
n
respectively and
put I
= (P
, N
).
We list some propositions (see (Sato, 1990) for
proofs).
Proposition 1. I
is a 3-valued model of comp(DB).
Proposition 2. I
is the least 3-valued model of
comp(DB) in the sense of v-ordering.
It is apparent that when DB is a definite clause
program, P
in I
= (P
, N
) gives the success set of
DB, i.e. the least 2-valued model of DB (whereas N
gives the finite failure set of DB). We consider the
least 3-valued model I
as the denotation of DB in
our 3-valued semantics.
A 2-valued completion model of DB, i.e. a 2-
valued interpretation satisfying comp(DB), is called
a supported model of DB (Apt et al., 1988; Marek
and V.S.Subrahmanian, 1992). DB may have no sup-
ported model (think of a ¬a) but if DB has a
supported model represented by a set P
s
( A ), we
see I
v I
s
= (P
s
, A \ P
s
) thanks to Proposition 2 be-
cause every 2-valued completion model is also a 3-
valued completion model. In other words, every sup-
2
Likewise, a 2-valued model of comp(DB) is called a
2-valued completion model of DB.
From 3-valued Semantics to Supported Model Computation for Logic Programs in Vector Spaces
759
ported model is obtained by appropriately assigning
t or f to the undefined atoms in U
= A \ (P
N
).
Supported models are a super class of stable models
and when DB is tight (no looping caller-callee chain
through positive goals), DB’s supported models and
DB’s stable models coincide (Erdem and Lifschitz,
2003).
DB
0
=
a ¬b c
b ¬a c
c ¬d
comp(DB
0
) =
a ¬b c
b ¬a c
c ¬d
d false
Figure 2: A program DB
0
and its completion comp(DB
0
).
Look at DB
0
in Figure 2. We see (P
0
, N
0
) =
(
/
0,
/
0), (P
1
, N
1
) = (
/
0, {d}), (P
2
, N
2
) = ({c}, {d}) and
(P
3
, N
3
) = (P
2
, N
2
) = I
. Then {a, b} are undefined
atoms U
in I
. So any supported model of DB
0
is
obtained by assigning t or f to each of a and b appro-
priately. Actually ({a, c}, {b, d}) and ({b, c}, {a, d})
exhaust all supported models of DB
0
.
3 MATRICIZING 3-VALUED
SEMANTICS
We here compute I
= (P
, N
) in a vector space by
matrix. As a preprocessing step, we standardize a
program first and then represent the standardized pro-
gram by a 0-1 matrix.
3.1 Standardization
Let DB be a program, A the set of all atoms appearing
in DB. For every atom a A , do the following.
If a has no clause about it, add a false to DB.
If a has a unit clause a , replace it with a
true.
If there is more than one clause {a B
1
, . . . , a
B
k
} (k > 1) in DB, replace them with a set of new
clauses {a b
1
·· · b
k
, b
1
B
1
, . . . , b
k
B
k
}
containing new atoms {b
1
, . . . , b
k
}.
Call the resulting program a standardized program of
DB. In general, if a program is standardized, every
atom a in A has exactly one clause a B about it
and B is true, false, a conjunction or disjunction of
literals in A.
Proposition 3. Let DB
0
be a standardized program of
DB. Then comp(DB
0
) and comp(DB) have the same
3-valued completion models as far as atoms in A are
concerned (proof omitted).
Proposition 3 tells us that to compute a 3-valued
model of comp(DB), we may assume DB is standard-
ized. So, hereafter, we only deal with standardized
programs.
3.2 Dualized Logic Programs
Here we introduce dualized programs for later use.
Let DB = {a
i
B
i
| 1 i N} be a standardized
program in a set of atoms A = {a
1
, . . . , a
N
}. We de-
fine a definite clause program DB
d
called a dualized
program of DB that can compute DB’s least 3-valued
completion model I
= (P
, N
) as its least 2-valued
model.
First introduce a set of new atoms
¯
A =
{na
1
, . . . , na
N
}. The idea is that na
i
represents ¬a
i
by negation-as-failure (NAF), i.e. an SLD derivation
with NAF for a
i
finitely fails. We now define a syn-
tactic function n(·) as follows. First put n(true) =
false and n(false) = true. Next consider literals.
Let l be a literal whose atom is in A . If l is an atom
a, define n(l) = na. Otherwise l is a negated atom ¬a
and put n(l) = a. We extend n(·) to conjunction and
disjunction by defining n(l
1
· ·· l
m
) = n(l
1
) ···
n(l
m
) and n(l
1
·· · l
m
) = n(l
1
) ·· · n(l
m
). Also
we apply n(·) to a set S by n(S) = {n(a) | a S}.
Dually we introduce a function p(·) s.t.
p(true) = true and p(false) = false. For atoms
in A, if l is an atom a, put p(l) = a. Otherwise l = ¬a
and put p(l) = na. p(·) is extended to conjunction and
disjunction by p(l
1
· ·· l
m
) = p(l
1
) ··· p(l
m
)
and p(l
1
·· · l
m
) = p(l
1
) · ·· p(l
m
).
Finally define a dualized program DB
d
of DB. It
is a definite clause program and defined by DB
d
=
{a p(B), na n(B) | a B DB}. Note that if
DB is standardized, so is DB
d
.
Look at DB
1
in Figure 3. It is a standardization
of DB
0
in Figure 2. Notice that the least 2-valued
model of DB
d
1
is {c, nd} and it exactly corresponds
to the least 3-valued model ({c}, {d}) of comp(DB
1
).
This is not a coincidence. We next prove that DB
d
computes the least 3-valued model I
of comp(DB)
as its least 2-valued model.
Put
¯
A = {na | a A } and A
d
= A
¯
A. Equate
J A
d
with a 2-valued interpretation s.t. [[c]]
J
= t
iff c J for an atom c A
d
. Now define a series
of 2-valued interpretations {J
n
( A
d
)} for DB
d
by
J
0
=
/
0 and J
n
= {c | c D DB
d
, [[D]]
J
n1
= t}. We
have
/
0 = J
0
J
1
. . . and J
=
S
n
J
n
gives the least
2-valued model of DB
d
as usual. We call {J
n
} the
ICAART 2020 - 12th International Conference on Agents and Artificial Intelligence
760
DB
1
=
a ¬b c
b ¬a c
c ¬d
d false
DB
1
d
=
a nb c
b na c
c nd
d false
na b nc
nb a nc
nc d
nd true
Figure 3: Standardized program DB
1
and its dual program
DB
d
1
.
defining interpretations associated with J
. The fol-
lowing theorem is proved.
Theorem 1. Suppose DB is a standardized normal
logic program and DB
d
is the dualized program of
DB. Let I
= (P
, N
) be the least 3-valued model of
comp(DB) and J
the least 2-valued model of DB
d
re-
spectively. Then we have (P
, n(N
)) = (A J
,
¯
A
J
) (proof omitted).
3.3 Matricized Logic Programs
Theorem 1 tells us that the least 3-valued model I
=
(P
, N
) of comp(DB) can be computed as the least
2-valued model J
of DB
d
. Here we point out that
J
is conveniently computable in a vector space using
matrix operations. Our linear algebraic approach to
completion semantics is motivated to exploit rapidly
growing computer power enabled by modern paral-
lel computation technologies such as multicores and
GPUs.
Let DB = {a
1
B
1
, . . . , a
N
B
N
} be a stan-
dardized normal logic program where the bodies B
i
s
are either true, false, a conjunction or disjunc-
tion of atoms in A = {a
1
, . . . , a
N
}. Write the du-
alized program as DB
d
= {a
1
B
1
, . . . , a
N
B
N
,
na
1
nB
1
, . . . , na
N
nB
N
}. We represent DB
d
in
terms of a (2N × 2N) 0-1 matrix Q and a (2N × 1)
threshold vector θ
3
. Q is said to be a matricized DB
d
or a program matrix for DB
d
. We construct Q and θ
by a procedure in Figure 4
4
.
3
Q only stores information about occurrences of atoms
in the clause body and does not make a distinction between
conjunction and disjunction. So we need to record supple-
mentary information θ to recover the original DB
d
.
4
For a conjunction or disjunction F, we use |F| to denote
the number of literals occurring in F.
Initialize Q to a (2N × 2N) zero matrix.
For i(1 i N), do the following;
If B
i
= true, set Q(i, i) = θ(i) = 1.
If B
i
= false, set Q(i + N, i + N) = θ(i) = 1.
Otherwise, let a
i
B
i
and na
i
nB
i
be clauses
about a
i
and na
i
in DB
d
respectively.
If B
i
is a conjunction with |B
i
| > 1, set θ(i) =
|B
i
| and θ(i + N) = 1.
Otherwise B
i
is a disjunction. Set θ(i) = 1 and
θ(i + N) = |nB
i
|.
Write B
i
as l
1
··· l
m
(m > 0) where denotes
either or .
For p(1 p m),
If l
p
is an atom a
j
,
put Q(i, j) = Q(i + N, j + N) = 1.
Else l
p
is a negated atom ¬a
j
and
set Q(i, j + N) = Q(i + N, j) = 1.
Figure 4: Constructing a program matrix Q and a threshold
vector θ for DB
d
.
For i (1 i N), the body B
i
of a
i
B
i
in DB
d
is encoded as the i-th row Q(i, :) of Q whereas the
body nB
i
of na
i
nB
i
is encoded as the i + N-th row
Q(i+N, :) of Q. More specifically, for k(1 k 2N),
when θ(k) > 1, Q(k, :) represents a conjunction of
atoms in A
d
. However, if θ(k) = 1, Q(k, :) may repre-
sent true, false or a disjunction. We disambiguate
them as follows. If Q(k, :) is a zero vector, Q(k, :)
represents c
k
false DB
d
. If Q(k, k) = 1 and
(Q(k + N, :) or Q(k N, :) is a zero vector), Q(k, :)
represents c
k
true DB
d
. Otherwise Q(k, :) is a
disjunction of atoms in A
d
. Thus DB
d
is recoverable
from Q and θ.
An (8 × 8) matrix Q
1
below is a program matrix
for DB
1
in Figure 3. As we can see, a nb c is
encoded by Q
1
(1, :) = (0 0 1 0 0 1 0 0), d false by
Q
1
(4, :) = (0 0 0 0 0 0 0 0), and nd true by Q
1
(8, :
) = (0 0 0 0 0 0 0 1). Also we set θ(1) = |nb c| = 2
as the threshold associated with a conjunctive clause
a nb c while we set θ(5) = 1 for θ(5) associated
with a disjunctive clause na b nc
5
.
We compute the least 2-valued model J
of DB
d
numerically using Q in a vector space. Let J( A
d
)
be an interpretation for DB
d
. J is represented by a 2N
dimensional 0-1 vector u
(J)
which is constructed as
follows. For i (1 i N), put u
(J)
(i) = 1 if a
i
J.
Otherwise u
(J)
(i) = 0. Similarly put u
(J)
(i + N) = 1
if na
i
J and otherwise u
(J)
(i + N) = 0.
5
In this paper, a definite clause whose body is a conjunc-
tion (resp. disjunction) is called a conjunctive clause (resp.
disjunctive clause).
From 3-valued Semantics to Supported Model Computation for Logic Programs in Vector Spaces
761
Q
1
=
a b c d na nb nc nd
a 0 0 1 0 0 1 0 0
b 0 0 1 0 1 0 0 0
c 0 0 0 0 0 0 0 1
d 0 0 0 0 0 0 0 0
na 0 1 0 0 0 0 1 0
nb 1 0 0 0 0 0 1 0
nc 0 0 0 1 0 0 0 0
nd 0 0 0 0 0 0 0 1
θ
1
=
2
2
1
1
1
1
1
1
Figure 5: A program matrix Q
1
and a threshold vector θ
1
for DB
d
1
.
We here introduce a thresholding notation (x)
θ
parameterized with a real number θ by (x)
θ
= 1 if
x θ. Otherwise (x)
θ
= 0. We further extend (x)
θ
to a vector notation (u)
θ
with a threshold vector θ
in such a way that (u)
θ
(i) = (u(i))
θ(i)
(1 i n)
when u and θ are n dimensional vectors.
Now consider the k-th clause c
k
D
k
DB
d
(1
k 2N) and let Q(k, :) be the k-th row encoding D
k
.
By construction, Q(k, :)u
(J)
gives the number literals
in D
k
which are true in J. Hence when D
k
is a con-
junction, D
k
is true in J iff Q(k, :)u
(J)
= |D
k
|(= θ(k)),
or equivalently [[D
k
]]
J
= (Q(k, :)u
(J)
)
θ(k)
6
. Simi-
larly, if D
k
is a disjunction, we set θ(k) = 1 and
have [[D
k
]]
J
= (Q(k, :)u
(J)
)
θ(k)
. Thus in either case,
the clause body D
k
of c
k
D
k
is evaluated by J as
[[D
k
]]
J
= (Q(k, :)u
(J)
)
θ(k)
, purely in a vector space in
terms of matrix multiplication and thresholding. We
summarize the argument so far as
Proposition 4. Let DB = {a
1
B
1
, . . . , a
N
B
N
}
be a standardized normal logic program in atoms
A = {a
1
, . . . , a
N
}, DB
d
the dualized logic program of
DB, J
the least 2-valued model of DB
d
, Q a program
matrix and θ a threshold vector for DB
d
. Compute a
2N dimensional vector u
= u
(J
)
. Then u
satisfies
u
= (Qu
)
θ
(proof omitted).
Proposition 4 says that u
is a fixedpoint vector of
f (u) = (Qu)
θ
but does not tell us how to compute
it, in particular, in a solely linear algebraic way.
Proposition 5. Let {J
n
} be the defining interpreta-
tions associated with the least model J
of DB
d
. De-
6
We identify 1 with t and 0 with f where the context is
clear.
fine a series of 0-1 vectors {u
n
} by u
1
= u
(J
1
)7
and
u
n+1
= (Qu
n
)
θ
. Then u
n
= u
(J
n
)
for all n 1 and
lim
n
u
n
= u
(proof omitted).
We restate Proposition 5 as the least 3-valued
model computation procedure in Figure 6. Given a
dualized program DB
d
of a standardized normal logic
program DB = {a
1
B
1
, . . . , a
N
B
N
}, it computes
the least 2-valued model J
of DB
d
as a 2N dimen-
sional 0-1 vector u
s.t. u
= u
(J
)
, using a program
matrix Q and a threshold vector θ for DB
d
.
Step 1: Compute u
1
= u
(J
1
)
Step 2: Iterate for n = 1, 2. . .
u
n+1
= (Qu
n
)
θ
until u
n+1
= u
n
Step 3: Return u
= u
n
Figure 6: Computing u
by a program matrix Q and a
threshold vector θ.
Applying the procedure in Figure 6
to DB
d
1
, we see u
1
= (0 0 0 0 0 0 0 1)
T
,
u
2
= (Q
1
u
1
)
θ
1
= (0 0 1 0 0 0 0 1)
T
,
u
3
= (Q
1
u
2
)
θ
1
= (0 0 1 0 0 0 0 1)
T
= u
2
. Hence
u
= u
2
= (0 0 1 0 0 0 0 1)
T
which coincides with
u
(J
)
encoding J
= {c, nd} for DB
d
1
that corresponds
to the least 3-valued model ({c}, {d}) of comp(DB
0
).
The procedure in Figure 6 shows that it is possible
to compute the least model semantics purely within
vector spaces, but unfortunately, it takes O((2N)
3
)
time if implemented naively using matrix multiplica-
tion. On the other hand, although we do not explain
algorithmic details here, it is possible to compute the
least model of Horn clause programs by matrix op-
erations in O(size(|DB|)) time by an elaborated im-
plementation where size(DB) is the number of atoms
occurring in DB.
4 SUPPORTED MODEL
COMPUTATION
Suppose a program DB = {a
1
B
i
, . . . , a
N
B
N
}
in A = {a
1
, . . . , a
N
} is given and the least 3-valued
model I
= (P
, N
) of comp(DB) has been com-
puted. Put U
= A \ (P
N
). Atoms a in U
cause
infinite computation, or looping computation when an
SLD-derivation is applied to a. As stated before,
every supported model can be obtained by appropri-
ately assigning t or f to atoms in U
. We construct a
7
J
1
= {a | a true DB
d
}{na | na true DB
d
}.
So u
1
encodes unit clauses in DB
d
.
ICAART 2020 - 12th International Conference on Agents and Artificial Intelligence
762
supported model of DB by a divide-and-conquer ap-
proach. First we analyze U
and detect strongly con-
nected components (SCCs) in U
explained next. We
then process SCCs one by one, i.e. assign, from bot-
tom SCCs upwards, t or f to atoms in each SCC to lo-
cally construct a supported model of the SCC. When
this process is completed without failure, we have a
supported model of DB.
In general, atoms in U
have caller-caller de-
pendency specified by DB and we express it as a
dependency graph G
U
s.t. nodes are atoms in U
and
there is a directed edge from a node a
i
to a node a
j
iff
there is a clause a
i
B
i
is in DB and B
i
contains a
j
.
An SCC is a set of atoms written as [a] = {a} {b |
there exist paths from a to b and from b to a in G
U
}
for some a U
. Intuitively atoms in an SCC are
those calling one another, directly or indirectly.
Note that SCCs in G
U
have a natural partial or-
dering. Let [a] and [b] be two SCCs. If there is
a path from a to b but not from b to a, we write
[b] [a]. is a partial ordering on SCCs. Us-
ing ”, SCCs are reverse-topologically sorted like
[S
1
, S
2
. . .] s.t. whenever S
i
S
j
, i < j holds. We can
obtain this reverse-topologically sorted list by Tar-
jan’s algorithm in O(|V |+|E|) time where |V | is the
number of nodes, |E| the number of edges of G
U
.
Look at DB
2
in Figure 7 which is a slight vari-
ant of DB
1
. The least 3-valued model of comp(DB
2
)
is (
/
0,
/
0) and all atoms are undefined, i.e. U
=
{a, b, c, d}. There are two SCCs, [a] = [b] = {a, b}
and [c] = [d] = {c, d}, and [c] [a] holds. They
are reverse-topologically sorted into a list SCC
DB
2
=
[{c, d}, {a, b}].
DB
2
=
a ¬b c
b ¬a c
c ¬d
d ¬c
SCC
DB
2
= [{c, d}, {a, b}]
Figure 7: DB
2
having two SCCs.
Let SCC
DB
= [SCC
1
, SCC
2
, . . .] be a reverse-
topologically sorted list of SCCs in U
. We build
a supported model of DB by processing those SCCs
from left-to-right. Suppose SCC
j
s ( j < i) preceding
SCC
i
have been processed and their atoms are already
assigned t or f. Write SCC
i
= {b
1
, . . . , b
K
} and let
DB
SCC
i
= {b
j
W
j
| 1 j K} be a subprogram of
DB about atoms in SCC
i
. Since undefined atoms that
appear in DB
SCC
i
other than SCC
i
are already assigned
t or f, we construct a supported model of DB
SCC
i
by
appropriately assigning t or f to atoms in SCC
i
when
possible.
Our task w.r.t. SCC
i
is to make every b
j
W
j
(1 j K) in comp(SCC
i
) true (in 2-valued logic) by
determining the truth values of b
1
, . . . , b
K
. Although
this is easily formulated as a SAT problem and solv-
able by a SAT solver, we would like to exploit the
form of iff completion which is lost in translation to
CNF. Suppose iff(b) = b c ¬d is in DB
SCC
i
and
{b, c, d} are all undefined. We have to find their truth
values that make iff(b) true. Basically this is an ex-
haustive search but since iff(b) is an equivalence for-
mula, the truth value of the atom b, once determined,
propagates to the body atoms on the right-hand side.
For example, if t is assigned to b, c = t and d = f nec-
essarily follow for iff(b) to be true. Or if f is assigned
to b, we nondeterministically choose one of {c, ¬d}
and make the chosen literal false. Similarly for the
disjunctive case such as iff(b) = b c ¬d, an as-
signment b = f propagates to c = f and d = t in the
body and so on. In this way, we make use of the iff
completion to efficiently propagate truth values from
one atom to another in SCC
i
.
We conclude this section with our search proce-
dure for supported models in Figure 8. Suppose we
are given a program DB in a set of propositional
atoms A.
Step 1: Compute the least 3-valued model I
=
(P
, N
) of comp(DB) via dualized
program DB
d
using the procedure in
Figure 6 and extract undefined atoms
U
= A \ (P
N
).
Step 2: Analyze U
and obtain a reverse-
topologically sorted list SCC
DB
=
{SCC
1
, . . . , SCC
M
} of SCCs in U
.
Step 3: For i = 1 to M, assign appropriately
truth values {t, f} to atoms in SCC
i
so
that the total assignment constitutes a
supported model of DB, i.e. a 2-valued
model of comp(DB).
Figure 8: Search procedure for a supported model of DB
via dualized DB
d
.
5 EXPERIMENT
In this section, we conduct an experiment with sup-
ported model computation
8
using the computation
procedure described in Figure 8 which is imple-
mented entirely by matrix operations provided by
GNU Octave 4.2.2
9
. Our experiment is intended to
8
The experiment is conducted on a PC with Intel(R)
Core(TM) i7-8650U CPU (max 4GHz), 16 GB memory.
9
For example, to implement Step 2, we represent a de-
pendency graph G
U
by an adjacency matrix and implement
Tarjan’s algorithm on it to compute SCCs.
From 3-valued Semantics to Supported Model Computation for Logic Programs in Vector Spaces
763
show the effectiveness of 3-valued model computa-
tion as a preprocessing step prior to 2-valued model
computation.
Computing the least 3-valued model I
=
(P
, N
) of comp(DB) at Step 1 in Figure 8 has the ef-
fect of reducing the search space for supported model
construction of DB by detecting atoms whose truth
values are determined, or common to all supported
models of DB. That is, since atoms in P
(resp. atoms
in N
) are true (resp. false) in any supported model of
DB, we have only to consider truth value assignment
for the remaining atoms, those in U
= A \ (P
N
)
when searching for a supported model of DB.
We here conduct an experiment to measure the ef-
fect of Step 1 on search space reduction. First we
introduce newly determined atoms. They are atoms
whose truth values are “newly determined” at Step
1. By “newly determined”, we mean those atoms in
(P
N
) \ (P
1
N
1
) because atoms in P
1
N
1
are
unit clauses (facts) or atoms having no clauses about
them, and hence their truth values are immediately
known. Since newly determined atoms are removed
from the search space for supported model construc-
tion, we measure the effect of search space reduc-
tion by “reduction
rate” defined by reduction rate
= #newly determined/n where #newly determined is
the number of newly determined atoms and n is the
total number of atoms.
In this experiment, after setting the number of
atoms n = 100 and a probability p = 0.03, we ran-
domly generate a normal logic program DB
(100,0.03)
in a set of propositional atoms A = {a
1
, . . . , a
100
},
compute its least 3-valued completion model and
count #newly determined atom. When generating
clauses in DB
(100,0.03)
, we specifically consider “base
atoms” {a
1
, . . . , a
10
}, and convert them to facts (unit
clauses) {a
1
, . . . , a
10
←} or to tautologies {a
1
a
1
, . . . , a
10
a
10
}. When base atoms are converted
to facts, DB
(100,0.03)
will have more newly deter-
mined atoms than are converted to tautologies. To
generate clauses a B for the remaining atoms
{a
11
, . . . , a
100
}, we randomly pick up atoms in A with
probability p, negate them with probability 0.5 and
make a conjunction of resulting literals with proba-
bility 0.5 as the clause body B. Otherwise use their
disjunction as B. Consequently, the body B contains
average n · p = 100 · 0.03 = 3 atoms. We repeat this
process 90 times and construct the remaining clauses
about {a
11
, . . . , a
100
} in DB
(100,0.03)
.
Table. 1 depicts the statistics of this experi-
ment (figures are average over 10 trials). There
#empty
body denotes the average number of atoms
having no clause about them in the randomly
generated DB
(100,0.03)
. Their truth values are f
in every supported model of DB
(100,0.03)
. #un-
def atom is the average number of undefined atoms
in the least 3-valued model of comp(DB
(100,0.03)
).
#newly determined atom is therefore computed
as 100 (#undef atom + #zero body + 10) when
{a
1
, . . . , a
10
} are converted to facts. Otherwise it is
100 (#undef atom + #zero body).
In the former case (see as facts column), we ob-
serve #newly determined atom = 83.9 giving reduc-
tion rate = 83.9%. It means, on average, 83.9% of
atoms are newly assigned t or f at Step 1 and removed
from the search space for supported model construc-
tion. In the latter case (see as tautology column) in
which base atoms are converted to tautologies, we
have more undefined atoms, resulting in a smaller
#newly determined atom, 45.1 on average, but still
45.1% of atoms get their truth values automatically
determined and removed from the search space at
Step 1. Although the effect of preprocessing by com-
puting the deterministic part of supported models at
Step 1 may vary depending on programs, as far as
randomly generated programs in this experiment are
concerned, we may say it greatly reduces the search
space associated with supported model construction.
6 RELATED WORK
3-valued semantics of logic programs has been devel-
oped primarily from a theoretical perspective (Fitting,
1985; Kunen, 1987; Van Gelder et al., 1991; Naish,
2006; Barbosa et al., 2019). Fitting generalized the
T
P
operator associated with 2-valued logic programs
P to a 3-valued operator Φ
P
. He used Kleene’s 3-
valued logic and transfinite induction, which is sim-
ilar to the inductive definition of {(P
n
, N
n
)} given in
Figure 1 where n is replaced by ordinals, and estab-
lished the existence of the least 3-valued model of ar-
bitrary normal logic programs (Fitting, 1985). How-
ever his semantics is highly undecidable, goes far be-
yond computable relations (at the cost of induction up
to the Church-Kleene ordinal, i.e. the smallest non-
recursive ordinal). Kunen later proposed to cut off Fit-
ting’s induction at ω and proved using a 3-valued ultra
power model construction that the notion of DB |=
3
φ,
a sentence φ being a 3-valued logical consequence
Table 1: The number of newly determined atoms.
base atoms
{a
1
, . . . , a
10
}
as facts as tautology
#empty body 3.6 12.4
#undef atom 3.5 42.5
reduction rate 83.9% 45.1%
ICAART 2020 - 12th International Conference on Agents and Artificial Intelligence
764
of a program DB, is recursively enumerable (Kunen,
1987). Van Gelder proposed well-founded seman-
tics (Van Gelder et al., 1991). The denotation of a
program P, well-founded partial model, is defined as
the least fixed point of some monotonic operator W
P
associated with P, which gives a 3-valued model of
comp(P). However, since W
P
is asymmetric on the
treatment of positive/negative occurrence of atoms in
the clause body, well-founded semantics differs from
our semantics; for example, p in a program {p p}
receives f in well-founded semantics.
Supported models of a program DB are 2-valued
models of the completed program comp(DB) (Apt
et al., 1988; Marek and V.S.Subrahmanian, 1992).
They can represent solutions of a quite large class
of combinatorial problems, and hence their efficient
computation is of practical interest. Also it is well-
known that stable models used in answer set program-
ming (ASP) are a subclass of supported models and
when propositional programs are finite and tight, they
are identical (Erdem and Lifschitz, 2003). Our pro-
posal to use 3-valued model computation as a prepro-
cessing step to compute supported models looks new
and is applicable to stable model computation as well.
It eliminates, as the experiment in Section 5 shows,
the extraneous need for finding the right assignment
of {t, f} to the deterministic part of supported mod-
els. On the other hand, in ASP, stable models (or
supported models) are computed by highly developed
SAT technologies as in clingo (Gebser et al., 2019). It
is an interesting future topic to merge our matricized
approach with existing ASP computation mechanism.
7 CONCLUSION
We proposed to compute the least 3-valued comple-
tion model of a finite normal logic program DB in a
vector space by first converting DB to an equivalent
definite clause program DB
d
, the dualized version of
DB, and then computing its least 2-valued model in a
vector space using a matrix representing DB
d
, which
is translated back to the least 3-valued completion
model of DB. We then applied this 3-valued model
computation to computing 2-valued completion mod-
els of DB, i.e. supported models of DB which are a
super class of stable models. We constructed them by
appropriately assigning t or f to the undefined atoms
in the least 3-valued completion model of DB while
guided by the completion form of clauses. We imple-
mented the 2-valued and 3-valued completion model
computation by matrix operations, and confirmed the
effectiveness of 3-valued computation as a prepro-
cessing step prior to 2-valued model computation.
Assigning truth vales to undefined atoms found in
this method is the next step to compute 2-valued sup-
ported models, and verification of efficiency of this
part will be reported in a full version of this paper.
REFERENCES
Apt, K. R., Blair, H. A., and Walker, A. (1988). Founda-
tions of deductive databases and logic programming.
chapter Towards a Theory of Declarative Knowledge,
pages 89–148.
Barbosa, J., Florido, M., and Costa, V. S. (2019). A three-
valued semantics for typed logic programming. In
Proceedings 35th International Conference on Logic
Programming, ICLP 2019 Technical Communica-
tions, pages 36–51.
Erdem, E. and Lifschitz, V. (2003). Tight Logic Programs.
Theory and Practice of Logic Programming (TPLP),
3(4–5):499–518.
Fitting, M. (1985). A Kripke-Kleene semactics for logic
programs. Journal of Logic Programming, 2:295–312.
Gebser, M., Kaminski, R., Kaufmann, B., and Schaub, T.
(2019). Multi-shot ASP solving with clingo. TPLP,
19(1):27–82.
Kunen, K. (1987). Negation in logic programming. Journal
of Logic Programming, 4:289–308.
Marek, W. and V.S.Subrahmanian (1992). The relation-
ship between stable, supported, default and autoepis-
temic semantics for general logic programs. Theoret-
ical Computer Science, 103(2):365–386.
Naish, L. (2006). A three-valued semantics for logic pro-
grammers. Theory and Practice of Logic Program-
ming (TPLP), 6(5):509–538.
Sakama, C., Inoue, K., and Sato, T. (2017). Linear
Algebraic Characterization of Logic Programs. In
Proceedings of the 10th International Conference on
Knowledge Science, Engineering and Management
(KSEM2017), LNAI 10412, Springer-Verlag, pages
520–533.
Sato, T. (1990). Completed logic programs and their con-
sistency. Journal of Logic Programming, 9:33–44.
Sato, T. (2017). A linear algebraic approach to Datalog
evaluation. Theory and Practice of Logic Program-
ming (TPLP), 17(3):244–265.
Sato, T., Inoue, K., and Sakama, C. (2018). Abducing re-
lations in continuous spaces. In Proceedings of the
27th International Joint Conference on Artificial In-
telligence (IJCAI-ECAI-18), pages 1956–1962.
Van Gelder, A., Ross, K., and Schlipf, J. (1991). The well-
founded semantics for general logic programs. The
journal of ACM (JACM), 38(3):620–650.
From 3-valued Semantics to Supported Model Computation for Logic Programs in Vector Spaces
765