<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta>
      <journal-title-group>
        <journal-title>Cognitive AI</journal-title>
      </journal-title-group>
    </journal-meta>
    <article-meta>
      <title-group>
        <article-title>Automating Theory Repair in First Order Logic</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Wan Ki Wong</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Xue Li</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Alan Bundy</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>School of Informatics, The University of Edinburgh</institution>
          ,
          <country country="UK">United Kingdom</country>
        </aff>
      </contrib-group>
      <pub-date>
        <year>2023</year>
      </pub-date>
      <volume>13</volume>
      <fpage>0000</fpage>
      <lpage>0002</lpage>
      <abstract>
        <p>Automatic theory repair systems help identify and repair faults in a knowledge base, which has useful applications in artificial intelligence such as decision systems. The ABC system is a state-of-the-art implementation of such systems which combines three existing techniques: abduction, belief revision and conceptual change, but with a limitation that it only accepts Datalog logic. To enhance its expressive power, this study extends the ABC system to first-order logic (ABC_FOL), by augmenting the fault detection module and adding new repair plans to the system. The resultant extended system is able to correctly identify faults and generate sensible repairs across a diverse set of first-order logic examples that cannot be expressed in Datalog logic.</p>
      </abstract>
      <kwd-group>
        <kwd>eol&gt;automated theory repair</kwd>
        <kwd>abduction</kwd>
        <kwd>belief revision</kwd>
        <kwd>conceptual change</kwd>
        <kwd>reformation</kwd>
        <kwd>first-order logic</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>1. Introduction
considering real-world scenarios, some complex rules (such as Government laws and regulations)
simply cannot be encoded in Datalog logic. It is hence important to consider first-order logic
(FOL), a more expressive logic that allows translation of almost any natural language statement
to FOL statements [5]. This project aims to extend ABC to support FOL while retaining
domainindependence. The hypothesis is that ABC techniques can be adapted to repair FOL theories,
ofering some potential repairs, though not all of them.</p>
      <p>Referring to figure 1, the project focuses on modifying C2 and C3 of ABC, as follows: 1.
Developing an ABC theorem prover for FOL, generating partial proofs for repairs (C2). 2.
Extending existing repair strategies to accommodate FOL (C3). 3. Creating new FOL-specific
repair strategies (C3).
2. Extension of Fault Detection (C2)
2.1. Ancestor Resolution
Ancestor resolution involves resolving the current clause with one of its own ancestors [6]. This
concept is used in SL-resolution, where ancestors refer to intermediate goal clauses derived
through resolution steps (RS). Incorporating ancestor resolution in FOL is essential due to its
ability to handle non-Horn clauses, enabling new rules and theorems to emerge during the
resolution process. This adaptability proves crucial in correctly deriving desired goals.</p>
      <p>Consider the following example:</p>
      <p>(, ℎ) =⇒ (, ).
(, ) =⇒ (, ℎ).</p>
      <p>=⇒ (, ) ∨ (, ℎ)</p>
      <p>Figure 2 shows the inference result of (, ). The final resolution step, as
highlighted in green, reuses the derivation result of the initial step (red) to prove the desired
result. Without ancestor resolution, we would not be able to prove the result.
(, ) =⇒
=⇒ (, ℎ)
=⇒ (, )
2.2. Occurs Check
The occurs check is crucial for inference soundness, preventing cyclic substitutions where a
variable is bound to a term containing itself, e.g.,  ( )/ [6]. Unlike the prior ABC version,
the new FOL context introduces functions, rendering the occurs check necessary. This issue
arises only when binding a variable to a function-containing a term, not a constant.</p>
      <p>Consider the illustrative example:</p>
      <p>(, ) ≡ (, ( ))
The sign ≡ represents a unification problem. Here, unifying the second argument encounters
the challenge  ≡ ( ), causing the occurs check to fail due to cyclic substitution.</p>
      <p>The project reinstates the occurs check into the unification algorithm. The condition  ∈ ()
is verified within the  case of the standard unification. Readers can refer to [ 6] for details
of the occurs check.
3. Extension of Repair Generation (C3)
A summary of old and new repair plans in ABC_FOL are listed in table 1, appendix A. The
description of the changes are as follows.
3.1. Extension of ABC’s Framework
ABC’s framework needs to be modified for FOL, including a new trace-back, incorporating
functions, and removing restrictions of Datalog.</p>
      <p>A repair is generated to block an unwanted unification or unblock a wanted unification in
a resolution process, which has to modify a source axiom that is originally from the input
theory rather than a theorem that is derived during resolution. Otherwise, the fault will still be
derivable from the source axioms.</p>
      <p>Thus, a trace-back algorithm is pivotal in pinpointing the source axiom for a targeted
uniifcation from a proof. This necessity arises from ancestor resolution. The accurate change
propagation to the pertinent axiom hinges on the trace-back process.</p>
      <p>In order to incorporate functions, we adapted ABC’s framework to accept functions and be
able to accurately identify constants, variables, predicates and functions.</p>
      <p>Finally, a number of restrictions are modified in each specific old repair plan, that targets
FOL’s distinction from Datalog - non-Horn clauses, allowing orphan variables (variables that
are solely present in the head but not the body), predicates with function arguments.
3.2. New Repair Plans
A brief summary of each of the repair plans is provided as follows. The first three fix an
incompatibility that a proposition in the false set of preferred structure is derived so that we
want to break a unification in its proof. The last is for an insuficiency that a proposition in the
true set of the preferred structure cannot be derived, where we want to fix the failed unification
to build a proof for it. Readers are directed to the project’s github repository [7] for a detailed
description of the repair plans.</p>
      <p>CR7-10: Break unification of a function : These repairs break unification of two functions by
renaming functions, renaming constant arguments, weakening variables or adding diferent
constants, which inherently breaks the predicate-level unification. The repair plans accommodate
functions with various nesting depths.</p>
      <p>CR11: Break 1(⃗) ≡ (⃗ ) by adding a variable  to : This repair breaks unification
by failing the occurs check, which is achieved by adding a variable that would cause cyclic
substitution.</p>
      <p>CR12: Break 1(⃗) ≡ (⃗ ) by adding an unprovable alternative (⃗): Appends an
unprovable positive literal  to the original axiom that satisfies certain conditions, efectively
breaking the unification.</p>
      <p>SR6: Fix the failed unification  ̸=  by removing all occurrences of a variable :
Fixing a failed occurs check by removing all occurrences of the variable that leads to a cyclic
substitution.</p>
      <p>
        An example scenario that utilizes the new repair plans is a repair of an erroneous mathematical
equation. Consider the equation: ∃, ∀.  ̸= . This equation can be formulated in ABC_FOL
in the following form: ¬(, ). This causes a contradiction with the fact (, ), which
is also added as an axiom in ABC_FOL. The new repair plan, CR11, is able to remedy this by
introducing a new variable to the constant , changing equation ¬(, ) to the following:
¬(, 1( ))
(
        <xref ref-type="bibr" rid="ref1">1</xref>
        )
This reorders the quantifiers into ∀, ∃.  ̸= , which now holds true.
      </p>
      <p>
        Note that 1 is a function yet to be assigned any meaning, as in any functions which
arise from skolemization. In many applications, we need to assign values to the new functions
for the logical system to behave correctly. Suppose that, based on other observations, a new
rule 1() =  is added to the theory - this raises yet another contradiction with the
rule (
        <xref ref-type="bibr" rid="ref1">1</xref>
        ).
      </p>
      <p>
        Now, CR7 is able to rename the function 1 in (
        <xref ref-type="bibr" rid="ref1">1</xref>
        ) further into 1:
¬(, 1( ))
(
        <xref ref-type="bibr" rid="ref2">2</xref>
        )
      </p>
      <p>
        This makes sure the function in equation (
        <xref ref-type="bibr" rid="ref1">1</xref>
        ) stands diferent from other occurences of
1 in the theory.
4. Case Study
A precise definition of a general polyhedron has long been argued as there are multiple prevailing
ones [8]. A common definition requires a polyhedron to be formed of four or more polygons.
Consider the following (faulty) definition of a polygon (  and  are the set of vertices and
lines respectively):
(∀  ∈ . ∃ 1, 2 ∈ . 1 ̸= 2 ∧ (, 1, 2)) =⇒ (, , )
(
        <xref ref-type="bibr" rid="ref3">3</xref>
        )
Equation 1 allows the ““, as defined in Appendix B, to be a polygon. Suppose we do not
want the  to count as a polygon as it cannot be properly extended to form a polyhedron
- Lakatos [8] introduced a concept termed “ “ to exclude counter-examples like
this. In ABC_FOL, we can mimic monster barring by the following formulation in clausal form:
¬() ∨ ¬() ∨ ¬() ∨  =  ∨ ¬(, , ) ∨ ()
¬(, 1, 2) ∨ ( )
Equation (
        <xref ref-type="bibr" rid="ref4">4</xref>
        ) is the clausal form of equation (
        <xref ref-type="bibr" rid="ref3">3</xref>
        ), which was not possible to be formulated with
ABC_Datalog. Equation (
        <xref ref-type="bibr" rid="ref3">3</xref>
        ) is a wrong formulation which causes the point , a point that is not
in the vertex set, to be wrongly included in the vertex set. The remaining equations that are not
shown include the definition of all  points and all lines in the set , as referenced from
Appendix B. The only item in the false set of this example is (), which is the
target proposition to block, while the true set is empty.
      </p>
      <p>
        Passing this formulation to FOL_ABC, a total of 56 repair plans are generated, spanning the
use of various repair plans in repairing incompatibility. One of the solution uses the repair CR6
to add an unprovable precondition to (
        <xref ref-type="bibr" rid="ref3">3</xref>
        ), as follows:
      </p>
      <p>
        ¬ ( ) ∨ (, 1, 2) ∨ ( )
Given that the above formulation has no other reasonable candidates for the unprovable
precondition, the predicate   is used. This could be linked to some specific mathematical
definitions that establish point  as a vertex.
(
        <xref ref-type="bibr" rid="ref4">4</xref>
        )
(
        <xref ref-type="bibr" rid="ref5">5</xref>
        )
(
        <xref ref-type="bibr" rid="ref6">6</xref>
        )
5. Conclusion
This paper extends the theory repair system ABC from Datalog to accommodate first-order logic.
The proposed enhancements involve introducing ancestor resolution, an occurs check to the
fault detection module and some framework adaptions for incorporating functions. Furthermore,
novel repair strategies are devised to handle FOL’s specific characteristics, including functions
and non-Horn clauses.
      </p>
      <p>The extension is successfully integrated into the ABC codebase1. The evaluation of ABC_FOL
supports the research hypothesis. The system generates numerous potential repairs to rectify
identified faults while ensuring semantic coherence. ABC_FOL is poised for diverse applications
1Github Link: https://github.com/tpmmthomas/ABC_FOL
in decision systems, law enforcement, and knowledge graphs, ofering broader usability than
ABC_Datalog.</p>
      <p>The project encountered several limitations, including the limited literature on automated
theory repair techniques, inadequate data availability for FOL theorems, and evaluation
constraints due to the subjective nature of repair output assessment. Future work suggestions
include allowing non-ground assertions in PS to handle more complex statements, designing
tailored heuristics for FOL theories to improve eficiency, exploring sorted logic extension for
better proof search guidance, and conducting a more thorough evaluation of ABC_FOL.</p>
      <p>A. Repair Plans Summary</p>
      <p>S
abT suA foa irva from R
)</p>
      <p>)
−  ty
( li
→2 i</p>
      <p>b

a
t
≡ a
) p</p>
      <p>m
−  o
( c
→1 I(n
.
)

:e −</p>
      <p>(
d
i
s
→2

r
e
h )
it 
e
≢
.
′
 :
o ts
t</p>
      <p>n
 ta</p>
      <p>s
n −  .</p>
      <p>( ′
o →′1</p>
      <p>e
t
a
c
i
ed 
r
o 
) r
o
t
 le
b
a
o i</p>
      <p>r t
r n
p −   av e</p>
      <p>( r
e →′2 e</p>
      <p>n fie
m ek</p>
      <p>d
)≢ ean ea d
d
. .</p>
      <p>) 
n 
o
c −  ix
2 e
  l
, b
a
v
o
m
o
(
→2 a
 e</p>
      <p>h
≢ t
e
t
)
1 e
 l</p>
      <p>e

≡
≡
)

=


∧

=


(
∨
)



h
c
t
a
m
s
i
m
/
h
c
t
a
t
e
g
r
a
m
2</p>
      <p>1  
T   (
.
o
t</p>
      <p>) 
on .
c 2
t  le
n , b
e
r (
fe 2
i
d  av
⃗ ia</p>
      <p>r
d ̸≡ d</p>
      <p>d
d )
A 1
n
o
i
t
c
u
d
b</p>
      <p>t e
. u l
) b

−  li
(
h
c
i
h 
w
e
−  l
( l
l →1 a
u  e
. →1
) 

s
e
 −  v
(
→1 ro
 p
n
o
i
t
r
e
s
s
a
m d
r n t
o te
f
e x
R E
. .
1 2
e r
h</p>
      <p>a t
d d le
d d
A
. .</p>
      <p>m
io in
x
a 
p a
n i
r
a
a v
n f
i
g o
i
r s
o ce
m en
o r
r r
f</p>
      <p>u
) c
c
o
)

=


∧


(
)

∨
=


∧

=


(
,
2

1

m
n a
a
l</p>
      <p>n
P
r
i
a
p
e
R 
.</p>
      <p>R
1 −  .2</p>
      <p>,
W A 
. .
3</p>
      <p>D
4 −  .5
(
R →1 R R R
(
→1 R</p>
      <p>.</p>
      <p>.
6 7 ⃗ 8
R R (1 R</p>
      <p>A
W .  .</p>
      <p>0 ,</p>
      <p>2
. 1
9 1 ⃗ 1 1
R R (1 R R</p>
      <p>A
.
e
R C  C C C  C C C  C C C  C C
R R R R R R
S S S S S S
=</p>
      <p>=
∧</p>
      <p>∧
=
=
=
=</p>
      <p>=
∨
) )

=</p>
      <p>=</p>
      <p>∧
=</p>
      <p>∧
2</p>
      <p>=
= 
=</p>
      <p>1   
  ( (
) )
⃗
(
⃗
(
1 2 
  
=</p>
      <p>≡
=</p>
      <p>∧
=
)
)



=


(
∨






(</p>
      <p>=</p>
      <p>=
≠




,
2

1

)

− 
(
→2
 )</p>
      <p>y
≢ c</p>
      <p>n
)

− 
(
→1 I(n
e
i
ifc
u
s
B. Definition of Eggtimer
The , which is the target polygon to block, can be formalized by the set  =
{1, 2, 3, 4},  = {1, 2, 3, 4}, and the meeting points (1, 1, 2), (2, 2, 3),
(3, 3, 4), (4, 4, 1), (, 1, 3). A graphical illustration is provided as follows.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <surname>Chapter</surname>
          </string-name>
          xii
          <article-title>- automatic deduction</article-title>
          , in: P. R. Cohen,
          <string-name>
            <given-names>E. A.</given-names>
            <surname>Feigenbaum</surname>
          </string-name>
          (Eds.),
          <source>The Handbook of Artificial Intelligence</source>
          , Butterworth-Heinemann,
          <year>1982</year>
          , pp.
          <fpage>75</fpage>
          -
          <lpage>123</lpage>
          . URL: https://www. sciencedirect.com/science/article/pii/B9780865760912500071. doi:https://doi.org/10. 1016/B978-0
          <source>-86576-091-2</source>
          .
          <fpage>50007</fpage>
          -
          <lpage>1</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>S.</given-names>
            <surname>Kothawade</surname>
          </string-name>
          ,
          <string-name>
            <given-names>V.</given-names>
            <surname>Khandelwal</surname>
          </string-name>
          ,
          <string-name>
            <given-names>K.</given-names>
            <surname>Basu</surname>
          </string-name>
          ,
          <string-name>
            <given-names>H.</given-names>
            <surname>Wang</surname>
          </string-name>
          , G. Gupta, AUTO-DISCERN:
          <article-title>autonomous driving using common sense reasoning</article-title>
          ,
          <source>CoRR abs/2110</source>
          .13606 (
          <year>2021</year>
          ). URL: https://arxiv. org/abs/2110.13606. arXiv:
          <volume>2110</volume>
          .
          <fpage>13606</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>A.</given-names>
            <surname>Bundy</surname>
          </string-name>
          ,
          <string-name>
            <given-names>X.</given-names>
            <surname>Li</surname>
          </string-name>
          ,
          <article-title>Representational change is integral to reasoning, Philosophical Transactions of the Royal Society A: Mathematical, Physical</article-title>
          and Engineering
          <string-name>
            <surname>Sciences</surname>
          </string-name>
          (
          <year>2023</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>X.</given-names>
            <surname>Li</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Bundy</surname>
          </string-name>
          ,
          <article-title>An overview of the abc repair system for datalog-like theories</article-title>
          , in: A.
          <string-name>
            <surname>Bundy</surname>
          </string-name>
          , D. Mareschal (Eds.),
          <source>Proceedings of 3rd International Workshop on Human-Like ComputingHLC2022 @ IJCLR</source>
          , volume
          <volume>3227</volume>
          <source>of Human-Like Computing Workshop 2022, CEUR Workshop Proceedings (CEUR-WS.org)</source>
          ,
          <year>2022</year>
          , pp.
          <fpage>11</fpage>
          -
          <lpage>17</lpage>
          . URL: https://ijclr22.doc.ic. ac.uk/hlc2022.html/index.html.
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>J.</given-names>
            <surname>Barwise</surname>
          </string-name>
          ,
          <article-title>An introduction to first-order logic</article-title>
          , in: J.
          <string-name>
            <surname>Barwise</surname>
          </string-name>
          (Ed.),
          <source>HANDBOOK OF MATHEMATICAL LOGIC</source>
          , volume
          <volume>90</volume>
          <source>of Studies in Logic and the Foundations of Mathematics, Elsevier</source>
          ,
          <year>1977</year>
          , pp.
          <fpage>5</fpage>
          -
          <lpage>46</lpage>
          . URL: https://www.sciencedirect.com/science/article/pii/S0049237X08710978. doi:https://doi.org/10.1016/
          <fpage>S0049</fpage>
          -237X(
          <issue>08</issue>
          )
          <fpage>71097</fpage>
          -
          <lpage>8</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>A.</given-names>
            <surname>Bundy</surname>
          </string-name>
          ,
          <source>The Computer Modelling of Mathematical Reasoning</source>
          , Academic Press Professional, Inc., USA,
          <year>1985</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <surname>T. W.</surname>
          </string-name>
          <article-title>(forked from Xue Li)</article-title>
          , Abc_fol, https://github.com/tpmmthomas/ABC_FOL,
          <year>2023</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <surname>I. Lakatos</surname>
          </string-name>
          ,
          <source>Proofs and Refutations: The Logic of Mathematical Discovery</source>
          , New York: Cambridge University Press,
          <year>1976</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          [9]
          <string-name>
            <given-names>A.</given-names>
            <surname>Bundy</surname>
          </string-name>
          ,
          <article-title>An ambiguous polygon</article-title>
          ,
          <source>Blue Book Note</source>
          <year>1887</year>
          ,
          <year>2023</year>
          .
          <article-title>m o u n c</article-title>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>