Logical Approach to Theorem Proving with Term Rewriting on KR-logic
Tadayuki Yoshida
1
, Ekawit Nantajeewarawat
2
, Masaharu Munetomo
3
and Kiyoshi Akama
3
1
Tokyo Software Development Laboratory, International Business Machines Corporation, Tokyo, Japan
2
Computer Science Program, Sirindhorn International Institute of Technology Thammasat University,
Pathumthani, Thailand
3
Information Initiative Center, Hokkaido University, Sapporo, Japan
Keywords: Term Rewriting Rules, Logical Problem Solving Framework, Equivalent Transformation, Correctness.
Abstract:
Term rewriting is often used for proving theorems. To mechanizing such a proof method with computation
correctness guaranteed strictly, we follow LPSF, which is a general framework for generating logical problem
solution methods. In place of the first-order logic, we use KR-logic, which has function variables, for correct
formalization. By repeating (1) specialization by a substitution for usual variables, and (2) application of an
already derived rewriting rule, we can generate a term rewriting rule from the resulting equational clause.
The obtained term rewriting rules are proved to be equivalent transformation rules. The correctness of the
computation results is guaranteed. This theory shows that LPSF integrates logical inference and functional
rewriting under the broader concept of equivalent transformation.
1 INTRODUCTION
Term rewriting is often used for solving proof prob-
lems (Bird and Wadler, 1988; Dershowitz and Jouan-
naud, 1990). Typical examples are proofs in group
theory, where the axiom of a group consists of laws,
such as associativity law x, y,z G : x · (y · z) = (x ·
y) · z. The operator (·) here is a mapping G × G G.
Assuming the axiom of a group, we want to prove that
((a
1
·a)·(b·b
1
))
1
= b·((a·b)
1
·a). Usually, term
rewriting is used for proving such an equation. If the
terms on both sides of this equation are rewritten re-
peatedly to reach a single term finally, the equation is
proved.
Such a proof by term rewriting is, however, not
regarded as logical problem solving. To mechaniz-
ing such a proof method, we need to formalize the
problem as a logical problem with computation cor-
rectness guaranteed strictly. We follow the LPSF
(Akama et al., 2019a), which is a general framework
for generating logical problem solving methods for
Model-Intersection (MI) problems (Akama and Nan-
tajeewarawat, 2016). We apply the LPSF to this proof
problem by reformalizing it as an MI problem.
We also need to construct a rule set. We already
know how to make term rewriting rules from equa-
tional clauses (Akama et al., 2019b). Based on this
work, we try to devise a new method of generating
new term rewriting rules from Cs.
Assume that Cs is a background knowledge con-
sisting of equational clauses. We apply to Cs repeat-
edly (1) specialization by a substitution for usual vari-
ables, and (2) application of already derived rewriting
rules. After repetition, we make a term rewriting rule
from the resulting equational clause. We prove the
correctness of the obtained term rewriting rule, i.e., it
is an ET rule. Since ET rules are repeatedly applied
to the original problem, the result of computation is
also correct. Such guarantee of correctness is usually
not clearly discussed in the theory of term rewriting
systems.
The rest of this paper is organized as follows: Sec-
tion 2 gives an introductory example used throughout
the paper. Section 3 reviews KR-Logic, a foundation
to formalize the problem (Akama et al., 2019a). Sec-
tion 4 introduces a class of conditional term rewriting
rules and gives a theoretical bases for handling equal-
ity atoms in KR-Logic. Section 5 proves the correct-
ness of the rule generation method for a given clause
set. Section 6 shows how we can build a conditional
term rewriting system for an introductory example by
producing a set of term rewriting rules from a given
clause set. Section 7 explains a solution built on the
new conditional term rewriting system and the com-
putation steps are shown for an example input. Sec-
tion 8 concludes the paper.
282
Yoshida, T., Nantajeewarawat, E., Munetomo, M. and Akama, K.
Logical Approach to Theorem Proving with Term Rewriting on KR-logic.
DOI: 10.5220/0008165902820289
In Proceedings of the 11th International Joint Conference on Knowledge Discovery, Knowledge Engineering and Knowledge Management (IC3K 2019), pages 282-289
ISBN: 978-989-758-382-7
Copyright
c
2019 by SCITEPRESS Science and Technology Publications, Lda. All rights reserved
2 AN INTRODUCTORY
EXAMPLE
We take a proof problem in the group theory and show
intuitive solution by term rewriting. We will try to
formalize this solution in later sections.
2.1 A Proof Problem of a Group
Consider the following definition of a group:
hG,(·), e,(
1
))i is a group iff
1. G is a set,
2. (·) is a mapping from G × G to G,
3. e G, and
4. (
1
) is a mapping from G to G,
that satisfy the following conditions:
A1 (associativity) : x,y, z G : x · (y · z) = (x · y) · z
A2 (identity) : x G : x ·e = e · x = x
A3 (inverse) : x G,x
1
G :
x · x
1
= x
1
· x = e
Using these three axioms, we want to prove that
((a
1
· a) · (b · b
1
))
1
= b · ((a · b)
1
· a).
2.2 Informal Proof with Equalities
We formalize the proof problem in 2.1 by introducing
two function-like notations. Assume that
1. (·) is a mapping f from G × G to G, and
2. (
1
) is a mapping i from G to G.
Using these mappings, we have the following five
equations corresponding to three axioms in 2.1.
e1: f (x, f (y,z)) = f ( f (x , y),z)
e2: f (x,e) = x
e3: f (e,x) = x
e4: f (x,i(x)) = e
e5: f (i(x),x) = e
Let a,b be a term in G. Let’s take an couple
of terms i( f ( f (i(a),a), f (b,i(b)))) as ((a
1
· a) · (b ·
b
1
))
1
and f (b, f (i( f (a,b)), a) as b · ((a · b)
1
· a).
The original proof problem is then considered to de-
termine the equality of these two terms.
In addition to the set of equalities above, we have
four additional equalities derived from the original
equalities.
e6: i(e) = e
e7: f (x, f (y,i( f (x,y)))) = e
e8: f (y,i( f (x,y))) = i(x)
e9: i( f (y,x)) = f (i(x),i(y))
For example, a generation process of e7 is shown
as follows:
f (x,i(x)) = e (p1)
f ( f (x, y),i( f (x, y))) = e (p2)
f (x, f (y,i( f (x, y)))) = e (e7)
Starting with p1, a substitution {x/ f (x , y)} is ap-
plied to p1 then p2 is obtained. Applying e1 to p2
results in e7. In similar way, e6 is obtained. Using e7,
e8 and e9 are generated.
By replacement of the terms using these nine
equalities, each term reaches e. This obviously means
that these two are equal;
i( f ( f (i(a),a), f (b,i(b)))) = f (b, f (i( f (a,b)),a).
2.3 How to Give Correctness to the
Informal Method
The informal method is only procedural, i.e.,
1. each term rewriting rule is constructed without
proving it to be semantically correct.
2. each successive transformation process is ob-
tained by application of rewriting rules without
correctness of computation result.
Our theory is correctness-based, i.e.,
1. each term rewriting rule is proved to be an ET
rule.
2. each successive transformation process is ob-
tained with guarantee of correctness of computa-
tion result.
KR-logic is sufficient for correctness-based the-
ory, while first order logic is not.
3 REPRESENTATION IN
KR-LOGIC
We use KR-Logic in order to formalize the original
problem in 2.1 as a proof problem on a logical struc-
ture. KR-Logic is considered as an extension of usual
first order logic by introduction of existential quan-
tification of function variables, which is essential for
representation of proof problems with equality con-
straints.
3.1 KR-logic
We take ECLS
N
as a logical structure L, where
ECLS
N
is the space of all clauses (including non-
flat ones) on KR-logic. It is an extension of ECLS
F
(Akama and Nantajeewarawat, 2018) that contain
Logical Approach to Theorem Proving with Term Rewriting on KR-logic
283
only flat clauses, which is also an extension of CLS
consisting of usual clauses.
Let K denote the conjunction of the following for-
mulas:
F
1
: xy : (g(x) g(y) g($ f (x, y)))
F
2
: x : (g(x) g($i(x)))
F
3
: g($e)
F
4
: xyz : ((g(x) g(y) g(z))
eq($ f (x,$ f (y,z)), $ f ($ f (x , y),z)))
F
5
: x : (g(x) eq($ f (x, $e),x))
F
6
: x : (g(x) eq($ f ($e,x), x))
F
7
: x : (g(x) eq($ f (x, $i(x)),$e))
F
8
: x : (g(x) eq($ f ($i(x),x),$e))
These formulas give definitions of $ f , $i, and $e
which are corresponding to conditions listed in 2.1.
3.2 Formalization in Clausal Form in
KR-logic
Let term t
a
and t
b
be
t
a
= $i($ f ($ f ($i(x),x), $ f (y,$i(y)))) and
t
b
= $ f (y,$ f ($i($ f (x, y)),x),
respectively. In order to ensure the equality of these
two terms, we want to prove
K (xy : (g(x)g(y)) eq(t
a
,t
b
)).
Its negation is
K ¬(xy : (g(x) g(y)) eq(t
a
,t
b
)),
which is equivalent to
K (xy : (g(x) g(y) ¬eq(t
a
,t
b
))).
By meaning-preserving Skolemization (MPS),
this formula is transformed into
E : $ f $i$e$a$b :
K g($a) g($b) ¬eq(t
a
,t
b
),
where $a and $b are new function variables.
Each formula in K is transformed into a set of
clausal forms using MPS as follows: MPS(F
1
) =
C
1
, MPS(F
2
) = C
2
, MPS(F
3
) = C
3
, MPS(F
4
) = C
4
,
MPS(F
5
) = C
5
, MPS(F
6
) = C
6
, MPS(F
7
) = C
7
, and
MPS(F
8
) = C
8
.
The formula E is eventually represented in a
clausal form by:
C
0
: eq($i($ f ($ f ($i($a),$a),$ f ($b, $i($b)))),
$ f ($b,$ f ($i($ f ($a, $b)),$a)))
C
1
: g($ f (x,y)) g(x), g(y)
C
2
: g($i(x)) g(x)
C
3
: g($e)
C
4
: eq($ f (x,$ f (y,z)), $ f ($ f (x, y),z))
g(x),g(y), g(z)
C
5
: eq($ f (x,$e), x) g(x)
C
6
: eq($ f ($e,x),x) g(x)
C
7
: eq($ f (x,$i(x)), $e) g(x)
C
8
: eq($ f ($i(x),x), $e) g(x)
C
9
: g($a)
C
10
: g($b)
Let Cs be a set of clauses in ECLS
N
and equal
to {C
1
,C
2
,. ..,C
10
}. Then we solve the given proof
problem by proving that Models({C
0
} Cs) =
/
0.
4 TERM REWRITING RULES
We introduce a class of conditional term rewriting
rules based on the equality atoms in a given clause
set.
4.1 Overview
We introduce a logical structure ECLS
N
, in which
an equational clause is defined. A conditional term
rewriting rule is defined. We obtain a conditional term
rewriting rule from an equational clause. Rewriting
relation determined by a conditional term rewriting
rule is defined. We propose a sufficient condition of
the correctness of a conditional term rewriting rule
that is obtained from an equational clause.
4.2 Alphabet and Terms of KR-logic
An alphabet hF,V,FC,FV,Pred,Pred
C
i is assumed,
where F is a set of constructors, V is a set of usual
variables, FC is a set of function constants, FV is
a set of function variables, Pred is a set of user-
defined predicate symbols, and Pred
C
is a set of built-
in constraint predicate symbols. Each element in
F FC FV is associated with a non-negative inte-
ger, called its arity.
Definition 1. A term on hF,V, FC,FVi, which is
also simply called a term, is inductively defined as
follows:
1. A 0-ary element in F FC is a term.
2. If v V FV, then v is a term.
3. If f F FC FV, the arity of f is n > 0, and
t
1
,. ..,t
n
are terms, then f (t
1
,. ..,t
n
) is a term.
The set of all terms on hF,V,FC,FVi is denoted
by T(F,V,FC,FV). Let T(F) = T(F,
/
0,
/
0,
/
0). Let
T(F, FC) = T(F,
/
0,FC,
/
0). A term in T(F,FC) is
called a ground term.
KEOD 2019 - 11th International Conference on Knowledge Engineering and Ontology Development
284
4.3 Term Contexts, Atom Contexts, and
Clause Contexts
Assume that is a function symbol with arity 0 that
does not belong to F V FC FV. A subterm is a
part of a term, and a subterm is extended by a term-
context into a term. Let t be a term and tc a term
context. t B tc is the term tc{/t}. A term is a part
of an atom, and a term is extended by an atom context
into an atom. Let t be a term and ac an atom context.
t B ac is the atom ac{/t}. An atom is a part of a
clause, and an atom is extended by a clause context
into a clause. Let a be an atom and con a clause con-
text. a B con is the clause con{/a}. The sets of all
term contexts, all atom contexts, and all clause con-
texts are denoted, respectively, by Con
T
, Con
A
, and
Con
C
.
4.4 Conditional Term Rewriting Rules
4.4.1 Equational Clauses
An equational clause is a clause in ECLS
N
of the form
eq(t
1
,t
2
) conds,
where t
1
and t
2
are terms in T(F,V, FC,FV), and
conds is a finite sequence of atoms. The set of all
equational clauses in ECLS
N
is denoted by EQC.
4.4.2 Conditional Term Rewriting Rule
A conditional term rewriting rule, “CTRR” for short,
is a formula of the form (t
1
t
2
: conds). A condi-
tional term rewriting rule r of the formula (t
1
t
2
:
conds) is often represented by r : (t
1
t
2
: conds).
The set of all conditional term rewriting rules is de-
noted by CT R.
4.4.3 Equational Clause to CTRR
An equational clause C = (eq(t
1
,t
2
) conds) deter-
mines a set of two conditional term rewriting rules,
which is denoted by ctrs(C), i.e.,
ctrs(C) = {(t
1
t
2
: conds),(t
2
t
1
: conds)}.
4.5 CTRR as Relation of Clauses
A conditional term rewriting rule r determines a rela-
tion on pow(ECLS
N
), denoted by rel(r), as follows:
Definition 2. Let r be a conditional term rewriting
rule. Let S
θ
be the set of all substitutions on V.
rel(r) = { (C
1
,C
2
) | r = (t
1
t
2
: conds)
& (tc Con
T
) & (ac Con
A
)
& (con Con
C
)
& (θ S
θ
) & (condsθ = true)
& (C
1
= ((((t
1
θ) B tc) B ac) B con))
& (C
2
= ((((t
2
θ) B tc) B ac) B con)) }.
Figure 1 illustrates how the element of rel(r) is
constructed by a couple of clauses C
1
and C
2
. As-
sume that θ is given to fullfil the conditions denoted
by condsθ, all occurrences of t
1
θ are valid under the
term context tc, with which all atom occurrences con-
taining t
1
θ are valid under the atom context ac, in
which a clause containing the atoms with t
1
θ is valid
under the clause context con. The same validity is
confirmed for t
2
θ in C
2
. Then an element of rel(r) is
obtained as a pair of C
1
and C
2
.
term
context
atom
context
clause
context
C
1
C
2
rel(r)
r
= (
t
1
à
t
2
:
conds
)
!
1
#
!
2
#
conds
#
!
1
!
1
#
conds
!
2
#!
2
true
Figure 1: Element of rel(r) visualized.
Definition 3. C
1
is transformed into C
2
by a condi-
tional term rewriting rule r, denoted by C
1
r
C
2
, iff
(C
1
,C
2
) rel(r).
4.6 Basic Theorem
Theorem 1. Let Cs be a set of clauses. Let C,
C
1
, and C
2
be clauses in ECLS
N
. If Models(Cs) =
Models(Cs {C}), ctrs(C) 3 r, then r is model-
preserving.
Proof. According to Theorem 1 in (Akama et al.,
2019b), obviously Models(Cs{C
1
}) = Models(Cs
{C
2
}).
5 MAKING CORRECT TERM
REWRITING RULE
We introduce a mechanism to generate a new condi-
tional term rewriting rule from a set of clauses. Also,
we prove a theorem for giving the correctness of gen-
erated rules.
5.1 Generation of CTRR
We describe the method of generating a CTRR after
transforming a set of equational clauses. A transfor-
Logical Approach to Theorem Proving with Term Rewriting on KR-logic
285
mation is caused by two ways, i.e., substitution and
rewriting.
Definition 4. Let Cs be a set of clauses. Let C be
a clause in ECLS
N
. Let R be a set of term rewriting
rules. Cs
R
C is defined inductively by:
If Cs 3 C, then Cs
R
C.
If Cs
R
C
0
, θ is a substitution, and C
0
θ = C, then
Cs
R
C.
If Cs
R
C
0
, r R, and C
0
r
C, then Cs
R
C.
Using above relation, we can make a rewriting
rule.
Definition 5. Cs
R
7→ r iff there is a clause C such that
Cs
R
C and ctrs(C) 3 r.
5.2 Main Theorem for Generation
A logical consequence relation, lcr is defined by
lcr(X) = (Models(Cs) = Models(Cs {X})), where
X is an equational clause. A transformation by sub-
stitution preserves a logical consequence relation.
Proposition 1. Let Cs be a subset of ECLS
N
, and
C a clause in ECLS
N
. Let θ be a substitution. If
Models(Cs) = Models(Cs{C}), then Models(Cs) =
Models(Cs {Cθ}).
Proof. Since (1) G Models(Cs) iff G
Models(Cs {C}), and (2) G Models(Cs {C}) iff
G Models(Cs {Cθ}), we have G Models(Cs)
iff G Models(Cs {Cθ}). Hence Models(Cs) =
Models(Cs {Cθ}).
A logical consequence relation is preserved by re-
peated application of specialization and rewriting.
Proposition 2. Let Cs be a set of clauses. Let C
be a clause in ECLS
N
. Assume that R is a set of
model-preserving term rewriting rules. If Cs
R
C,
then Models(Cs) = Models(Cs {C}).
Proof. Assume that Cs
R
C.
(base case) Assume that Cs 3 C. Then, Cs = Cs
{C}. Hence, Models(Cs) = Models(Cs {C}).
(inductive case) There is a clause C
0
, a substitu-
tion θ, and r R such that (1) Cs
R
C
0
, and (2)
C
0
θ
r
C. By the inductive hypothesis and (1),
Models(Cs) = Models(Cs {C
0
}). By proposi-
tion 1, Models(Cs) = Models(Cs {C
0
θ}). By
r R and (2), Models(Cs {C
0
θ}) = Models(Cs
{C}). Hence, Models(Cs) = Models(Cs {C}).
The method of rule generation gives model-
preserving rules.
Theorem 2. Let Cs be a subset of ECLS
N
. Let R
be a set of term rewriting rules. Let r be a conditional
term rewriting rule such that Cs
R
7→ r. If R is model-
preserving, then r is also model-preserving.
Proof. Models(Cs) = Models(Cs {C
1
}) and from
Theorem 1, Models(Cs {C
1
}) = Models(Cs
{C
2
}). Then Models(Cs) = Models(Cs {C
2
}).
A generated rule is model-preserving since all
transformations in the generation sequence and a rule
generation method preserve a logical consequence re-
lation.
Equational
clauses in
Cs
6
,
4
5
7
,
8
CTRRs
2
1
3
4
5
6
7
8
9
10
24
16
11 11
4
9
21 22
23
8 4
2
11
17
17
13
18
Legend
C
,
C’
Rule
application
Rule
generation
r
Clause
r
CTRR
Generated
CTRR
r’
Transformed
clause
r’
20
,
Figure 2: CTRRs expansion by rule generation.
6 CONSTRUCTING TERM
REWRITING SYSTEM WITH
RULE GENERATION
We introduce a method to construct a term rewriting
system which equips rule generation.
6.1 Term Rewriting System Overview
Once a logical structure containing equational clauses
are constructed, then we can develop a term rewriting
system which contains a set of CTRRs growing by
rule generation.
Figure 2 shows the overview of CTRRs expan-
sion. The basic diagram elements shown in Legend
are:
KEOD 2019 - 11th International Conference on Knowledge Engineering and Ontology Development
286
Clause, a circled number represents an equational
clause with its number
Rule application, a solid line between two circles
represents a transformation using pre-generated
CTRR
CTRR, a diamond with inner number. A white
diamond represents a simple CTRR, while a dark
diamond a CTRR from a transformed clause, and
Rule generation, a dotted line between a clause
and a CTRR
CTRR #1 to #10 are generated in straightforward
way as shown in 4.4.3. For example, the top diamond
in “CTRRs” section at the right side means r
9
, which
is generated from C
4
. It is denoted as ctrs(C
4
) 3 r
9
.
CTRR #11, #13, #17, and #18 are generated from
transformed clauses by applying one or more pre-
generated CTRRs. For example, the negative dia-
mond of 13 is a generated rule from C
16
which is a
resulting clause of rule application to C
8
.
As a result, a set of CTRRs are growing by gen-
erating a new one from a transformed clause using
existing CTRRs.
6.2 Generation of Term Rewriting
Rules
Figure 2 shows the mechanism where conditional
term rewriting rules are generated from a set of equa-
tional clauses. In “Equational clauses in Cs section
at the left side of Figure 2, C
4
, C
6
, C
7
, C
8
, and C
5
are
listed in this order. For example, the circle of #8 in
“Equational clauses in Cs is connected to the circle
of #16 with a solid line and the diamond of #4, which
means that by application of r
4
, C
8
is transformed into
C
16
. Then the dark diamond of #13 is generated from
a transformed clause #16.
6.3 Rule Generation Sequences
In Figure 2, we have 14 generation lines. Each line
consists of a rule generation arrow line and zero or
more rule application arrow lines. When we repre-
sent a rule generation line using , ctrs, and 7→, we
call such formal representation a “rule generation se-
quence. Here are 14 generation sequences appear in
Figure 2.
#4: ctrs(C
4
) = {r
9
,r
10
}
#6: ctrs(C
6
) = {r
3
,r
4
}
#7: ctrs(C
7
) = {r
5
,r
6
}
#8(a): ctrs(C
8
) = {r
7
,r
8
}
#8(b): Cs C
16
, ctrs(C
16
) 3 r
13
;
#8(c): Cs C
11
, ctrs(C
11
) 3 r
11
;
#5(a): Cs C
23
, ctrs(C
23
) 3 r
17
;
#5(b): Cs C
24
, ctrs(C
24
) 3 r
18
;
#5(c): ctrs(C
5
) = {r
1
,r
2
}
6.4 Generation of r
17
from Cs
The following steps explain the generation sequence
#5(a) for r
17
from Cs starting with C
5
.
(1) Cs 3 C
5
(2) C
5
θ
20
r
8
C
20
(3) C
20
θ
21
r
4
C
21
(4) C
21
θ
22
r
11
C
22
(5) C
22
θ
23
r
2
C
23
(6) ctrs(C
23
) 3 r
17
The 4th step is detailed as follows:
(4-1) Take C
21
C
21
: eq(y,$ f ($i(x), $ f (x, y))) g(x),g(y)
(4-2) Specialization by θ
22
= {y/$ f (y,$i($ f (x,y)))}
C
21
θ
22
: eq($ f (y,$i($ f (x, y))),
$ f ($i(x), $ f (x, $ f (y,$i($ f (x,y))))))
g(x), g(y)
(4-3) Application of r
11
;C
21
θ
22
r
11
C
22
r
11
: ($ f (x, $ f (y,$i($ f (x, y)))) $e
: {g(x), g(y)})
C
22
: eq($ f (y,$i($ f (x, y))),$ f ($i(x),$e))
g(x), g(y)
6.5 Generated Rules
From all 14 generation sequences, we have condi-
tional term rewriting rules as follows:
r
1
: (x $ f (x,$e) : {g(x)})
r
2
: ($ f (x,$e) x : {g(x)})
r
3
: (x $ f ($e,x) : {g(x)})
r
4
: ($ f ($e,x) x : {g(x)})
r
5
: ($e $ f (x, $i(x)) : {g(x)})
r
6
: ($ f (x,$i(x)) $e : {g(x)})
r
7
: ($e $ f ($i(x), x) : {g(x)})
r
8
: ($ f ($i(x),x) $e : {g(x)})
r
9
: ($ f ($ f (x, y),z) $ f (x , $ f (y,z)) :
{g(x),g(y), g(z)})
r
10
: ($ f (x,$ f (y,z)) $ f ($ f (x,y),z) :
{g(x),g(y), g(z)})
r
11
: ($ f (x,$ f (y,$i($ f (x,y)))) $e) :
{g(x),g(y)})
r
13
: ($i($e) $e : {})
r
17
: ($ f (y,$i($ f (x, y))) $i(x) :
{g(x),g(y)})
r
18
: ($i($ f (y,x )) $ f ($i(x ), $i(y)) :
{g(x),g(y)})
Logical Approach to Theorem Proving with Term Rewriting on KR-logic
287
7 LPSF-BASED SOLUTION WITH
TERM REWRITING
We propose a LPSF-based solution for problems us-
ing term rewriting. First, we give a theoretical foun-
dation of the correctness of the solution, followed by
the solution for the sample problem.
7.1 Clause-rule Interaction Tree
A clause is transformed into a clause by repeated ap-
plication of rules, which is represented by a triple.
C [r
1
,..., r
n
] = C
0
is defined inductively by:
C [] = C.
C [r
1
,..., r
n1
] = C
00
, and there is θ such that
C
00
θ
r
n
C
0
.
We add a generated rule to a triple to form a
quadruple.
Definition 6. Let Cs a set of clauses. Clause-
Rule Interaction quadruple wrt Cs is a tuple of the
form (C, [r
1
,..., r
n
],C
0
,r
0
), where C and C
0
are clauses,
r
1
,..., r
n
and r
0
are term rewriting rules, C Cs,
C [r
1
,..., r
n
] = C
0
, and ctrs(C
0
) 3 r
0
.
Notations for an element designator in a sequence
and a subsequence are introduced.
Definition 7. Let X be a finite sequence.
nth(m,X) is defined as the m-th element of X.
Under(m,X ) is defined as the set of all elements
of X until m-th element, i.e., U nder(m,X) =
{nth(1,X),nth(2,X ), .. .,nth(m,X )}.
Two notations for obtaining clauses and rules from
a set of CRI quadruples.
Definition 8. Let X be a set of Clause-Rule Interac-
tion quadruples. We define cl(X ) and trs(X) by:
cl(X) = {C | (C,[r
1
,..., r
n
],C
0
,r
0
) X}.
trs(X) = {r
0
| (C,[r
1
,..., r
n
],C
0
,r
0
) X}.
If a rule is applied for rule generation, the rule
must be already generated.
Definition 9. Let Cs a set of clauses. Clause-Rule
Interaction Tree wrt Cs, denoted by CRIT (Cs), is
a finite sequence of clause-rule interaction quadru-
ples wrt Cs such that if (C, [r
1
,..., r
n
],C
0
,r
0
) =
nth(m,CRIT (Cs)), then {r
1
,..., r
n
} trs(Under(m
1,CRIT (Cs))).
Example:
CRIT(Cs) = ( (C
4
,[],C
4
,r
9
),
(C
4
,[],C
4
,r
10
),
(C
5
,[],C
5
,r
1
),
(C
5
,[],C
5
,r
2
),
...
(C
8
,[r
4
],C
16
,r
13
),
(C
8
,[r
9
],C
11
,r
11
),
(C
5
,[r
8
,r
4
,r
11
,r
2
],C
23
,r
17
),
(C
5
,[r
8
,r
4
,r
17
],C
24
,r
18
))
7.2 Correctness
Rules generated in a Clause-Rule Interaction Tree are
model-preserving.
Theorem 3. Let Cs be a set of clauses. Let r be a
conditional term rewriting rule. If trs(CRIT (Cs)) 3 r,
then r is model-preserving.
Proof. We prove the theorem by induction of the size
of CRIT (Cs). Assume that trs(CRIT (Cs)) 3 r.
When size(CRIT (Cs)) = 1. Then
(C,[],C
0
,r) = nth(1,C RIT (Cs)). Hence C = C
0
and Models(Cs) = Models(Cs {C
0
}). Let
R
0
= {}. Since Cs
R
0
C
0
and ctrs(C
0
) 3 r, we have
Cs
R
0
7→ r. By Theorem 2, r is model-preserving.
When size(CRIT (Cs)) > 1. Assume that the the-
orem holds for U nder(m 1,CRIT (Cs)). Let
R = trs(U nder(m 1,CRIT (Cs))). Each r
0
R is model-preserving. Assume also that
(C,[r
1
,..., r
n
],C
0
,r) = nth(m,CRIT (Cs)). Let
R
0
= {r
1
,..., r
n
}. Then Cs
R
0
C
0
. Since CRIT (Cs)
is a clause-rule interaction tree wrt Cs, we
have R
0
R. Hence R
0
is model-preserving.
Since Cs
R
0
C
0
and Proposition 2, we have
Models(Cs) = Models(Cs {C
0
}). Since Cs
R
0
C
0
and ctrs(C
0
) 3 r, we have Cs
R
0
7→ r. By Theorem 2,
r is model-preserving.
7.3 Solution for the Sample Problem
The sample proof problem is proven by the applica-
tion of model-preserving term rewriting rules gener-
ated in this paper. All steps of computation are shown
below. M is used as a short-hand for Models for sav-
ing spaces.
M ({( eq($i($ f ($ f ($i($a),$a), $ f ($b, $i($b)))),
$ f ($b,$ f ($i($ f ($a, $b)),$a))))} Cs)
(Apply r
8
with θ
31
= {x/$a})
= M ({( eq($i($ f ($e,$ f ($b,$i($b)))),
$ f ($b,$ f ($i($ f ($a, $b)),$a))))} Cs)
(Apply r
18
with θ
32
= {x/$a,y/$b}
= M ({( eq($i($ f ($e,$ f ($b,$i($b)))),
$ f ($b,$ f ($ f ($i($b),$i($a)),$a))))} Cs)
(Apply r
6
with θ
33
= {x/$b})
KEOD 2019 - 11th International Conference on Knowledge Engineering and Ontology Development
288
= M ({( eq($i($ f ($e,$e)),
$ f ($b,$ f ($ f ($i($b),$i($a)),$a))))} Cs)
(Apply r
9
with θ
34
= {x/$i($b),y/$i($a), z/$a}
= M ({( eq($i($ f ($e,$e)),
$ f ($b,$ f ($i($b), $ f ($i($a), $a)))))} Cs)
(Apply r
4
with θ
35
= {x/$e})
= M ({( eq($i($e),
$ f ($b,$ f ($i($b), $ f ($i($a), $a)))))} Cs)
(Apply r
8
with θ
36
= {x/$a})
= M ({( eq($i($e),
$ f ($b,$ f ($i($b), $e))))} Cs)
(Apply r
13
with θ
37
= {})
= M ({( eq($e,$ f ($b,$ f ($i($b),$e))))} Cs)
(Apply r
2
with θ
38
= {x/$i($b)}
= M ({( eq($e,$ f ($b,$i($b))))}Cs)
(Apply r
6
with θ
39
= {x/$b})
= M ({( eq($e,$e))} Cs)
(Remove the eq($e,$e) atom since it is true.)
= M ({()} Cs)
=
/
0.
In the last step of transformation, a constraint
solving rule for equality is used. This rule is not a
term rewriting rule. However, it obviously preserves
models. In our computation model, rules of logical
inference and term rewriting can be used together un-
der the principle of equivalent transformation.
8 CONCLUDING REMARKS
Term rewriting rules are used for computation
when the background knowledge contains equational
clauses. We can generate two term rewriting rules
directly from an equational clause. We apply to
an equational clause repeatedly (1) specialization by
a substitution for usual variables, and (2) applica-
tion of an already derived rewriting rule. We make
term rewriting rules directly from the resulting equa-
tional clauses. We have proved that the obtained term
rewriting rule is an ET rule. Since ET rules are re-
peatedly applied to the original problem, the result of
computation is also correct. Such guarantee of cor-
rectness is usually not clearly discussed in the theory
of term rewriting systems.
The informal method is procedural, i.e., seman-
tical structure is not discussed relating to rewriting
rules. Each term rewriting rule is constructed with-
out proving it to be semantically correct. Moreover,
correctness of computation result is guaranteed based
on the correctness of each rewriting rule.
First order logic is not sufficient for correctness-
based theory since it doesn’t have enough expressive
power, while KR-logic is sufficient due to the exis-
tence of function variables.
The theory in this paper is constructed on LPSF,
where KR-logic is used as a canonical logical struc-
ture, and term rewriting rules are used as ET rules.
The resolution rule and the unfolding rule are typi-
cal instances of rules in the domain of logic, while
term rewriting rules are typical instances of functional
rewriting. Hence, logical inference and functional
rewriting co-exist, both of them being instances of a
broader concept of equivalent transformation.
REFERENCES
Akama, K. and Nantajeewarawat, E. (2016). Model-
intersection problems with existentially quantified
function variables: Formalization and a solution
schema. In Proc. 8th International Joint Confer-
ence on Knowledge Discovery, Knowledge Engineer-
ing and Knowledge Management, volume 2, pages
52–63, Porto, Portugal.
Akama, K. and Nantajeewarawat, E. (2018). Solving query-
answering problems with constraints for function vari-
ables. Springer International Publishing AG, part of
Springer Nature 2018, N. T. Nguyen et al. (Eds.): ACI-
IDS 2018, LNAI 10751, pages 36–47.
Akama, K., Nantajeewarawat, E., and Akama, T. (2019a).
Logical problem solving framework. Springer Inter-
national Publishing AG, part of Springer Nature 2019,
N. T. Nguyen et al. (Eds.): ACIIDS 2019, LNAI 11431,
pages 28–40.
Akama, K., Nantajeewarawat, E., and Akama, T.
(2019b). Term rewriting that preserves models in kr-
logic. Springer International Publishing AG, part of
Springer Nature 2019, N. T. Nguyen et al. (Eds.): ACI-
IDS 2019, LNAI 11431, pages 41–52.
Bird, R. and Wadler, P. (1988). Prentice-Hall, Inc., New
Jersey.
Dershowitz, N. and Jouannaud, J.-P. (1990). pages 243–
320. MIT Press.
Logical Approach to Theorem Proving with Term Rewriting on KR-logic
289