<!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 />
    <article-meta>
      <title-group>
        <article-title>PSOA Prova: PSOA Translation of Pure Production Rules to the Prova Engine</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Lukas Grtz</string-name>
          <xref ref-type="aff" rid="aff2">2</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Harold Boley</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Adrian Paschke</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Faculty of Computer Science, University of New Brunswick</institution>
          ,
          <addr-line>Fredericton</addr-line>
          ,
          <country>Canada harold</country>
          <institution>[DT]boley[AT]unb.ca</institution>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>Fraunhofer FOKUS and Freie Universitaet Berlin</institution>
          ,
          <addr-line>Berlin, Germany adrian[DT]paschke[AT]fokus.fraunhofer.de</addr-line>
        </aff>
        <aff id="aff2">
          <label>2</label>
          <institution>Institut fr Philosophie, Universitt Leipzig, Germany lukas[DT]graetz[AT]studserv.uni-leipzig.de</institution>
        </aff>
      </contrib-group>
      <abstract>
        <p>PSOA Prova enriches PSOA RuleML with parts of Reaction RuleML. It is implemented by combining PSOATransRun and Prova, a Prolog-based language and engine which supports object orientation, reactive programming as well as several other programming paradigms. A modied Prova engine targeted by PSOA RuleML's PSOATransRun translators is introduced and then extended to top-level assert and retract by allowing KB consult and unconsult at runtime. PSOA is further extended to pure production rules, a conclusion-asserting subset of Production RuleML, hence Reaction RuleML. This is exemplied for a PSOA Prova knowledge base about the British Succession to the Crown Act 2013. These extensions yield a PSOA Prova language and engine available on GitHub. The PSOA Prova concepts are demonstrated with three formalization approaches for the British Succession to the Crown Act 2013.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>In knowledge representation and reasoning, a Knowledge Base (KB) can be used
to represent and reason about an unchanging world. Such an immutable KB, e.g.
in a Pure Prolog-like rule language, can be implemented with a derivation-rule
engine.</p>
      <p>
        However, what if the state of the world changes? In this scenario, a mutable
KB is needed, which can be successively modied to reect each new state of
the world. For a static(ally) (mutable) KB, these modications are done
(interactively) by the user with commands such as consult, assert and retract,
before starting (each round of) querying. For a dynamic(ally) (mutable) KB [
        <xref ref-type="bibr" rid="ref1 ref2">1,2</xref>
        ],
modications can also be done (automatically) by reactive rules invoking such
commands at runtime. In the following, we will only consider mutable KB facts,
although Reaction RuleML also allows mutable KB rules.
      </p>
      <p>The well-known relational databases correspond to mutable KBs of,
essentially, (ground) facts, since these databases allow to insert and remove records,
usually in a static manner. Relational databases are broadly used as underlying
data management systems on the web. For instance in eCommerce, the database
for web shops must allow to interactively add and remove product records, when
new products become available and others get sold out.</p>
      <p>
        The PSOA RuleML language [36] has so far been presented with immutable
KBs, corresponding to its reference implementation PSOATransRun 1.3.2-a 4,
but some of its use cases would call for a mutable KB, where new data and
knowledge can be integrated into an existing KB. Port Clearance Rules [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ] is an
example: Whenever a ship seeks port clearance, a query is passed to
PSOATransRun, which employs derivation rules to answers whether the ship is allowed to
enter the port. If we want to reason about a new ship, a new KB fact
representing the relevant information about the ship needs to be generated and then
asserted into the Port Clearance KB. This is strictly monotonic and does not
involve any production rules, only top-level assert.
      </p>
      <p>
        In this paper, we slightly extend PSOA RuleML towards Reaction RuleML
by a concept called pure production rule [
        <xref ref-type="bibr" rid="ref8 ref9">8, 9</xref>
        ]5. This is, for example, motivated
by the British Succession to the Crown Act 2013 (Section 2). PSOA RuleML
is used for representing the facts, rules and queries in the KB on an
objectrelational level of abstraction.
      </p>
      <p>
        For demonstrating PSOA Prova, the PSOATransRun translator [
        <xref ref-type="bibr" rid="ref10">10</xref>
        ] is
extended, in Section 3, to target Prova 6, an ISO Prolog-augmenting scripting
language written in Java. A further extension allows KB consult and unconsult at
runtime. Three approaches for the succession law are demonstrated: The rst
version (Section 4) comes with a derivation rule only and is incomplete for the
case that the successors’ parents dissolve their marriage. After extending PSOA
to pure production rules, the second version replaces the derivation rule by the
corresponding pure production rule in Section 5. Although unsound, version two
provides a good insight into pure production rules. A sound and complete third
version (Section 6) simulates an event condition action rule (ECA) on birth
events with a pure production rule. Optimization approaches dealing with the
evaluation time of pure production rules are discussed in Section 7. The paper
concludes in Section 8. All PSOA Prova KBs can be found in Appendix A.
2
      </p>
    </sec>
    <sec id="sec-2">
      <title>Use Case: Royal Family</title>
      <p>Consider how the succession in a Royal Family works. In the United Kingdom,
a successor to the British throne must be born in a legitimate marriage and
be of Protestant faith. Here, legitimate means (for the rst six successors)
that the marriage has to be accepted by King or Queen. This regulation seems
somehow complicated, but makes some sense: The future King or Queen should
4 http://wiki.ruleml.org/index.php/PSOA_RuleML#PSOATransRun
5 https://lists.w3.org/Archives/Public/public-rif-wg/2008Jun/0244.html
6 https://github.com/ag-csw/prova
be legitimated as a politician and it is necessary that as the head of the
Anglican Church he or she is of Anglican confession. 7</p>
      <p>Our goal is to formalize the succession law and represent all successors in
a Knowledge Base (KB). The KB will change in time, at least when successors
marry or have children. You may call this time-dependent transition behavior
a social-relationship aw. The following example describes how Prince William
becomes a successor (also illustrated by Figure 1):
1. We start with a KB, given as a snapshot before Prince Charles and Lady
Diana get married. This KB contains successors of the royal family as well
as their marriage and child relationships which include the fact that Prince
Charles is a successor.
2. Next, Diana and Charles get married and their marriage becomes
legitimated. This is added to the KB.
3. Now, Diana gives birth to a child with Charles, Prince William.
4. The succession law is fullled, hence we can derive from the KB that William
is a (legitimate) successor.
5. Finally, Charles and Diana dissolve their marriage. A divorce results in a
modication of the relationships represented in the KB. This includes the
removal (retraction) of the fact that Charles and Diana are in marriage. 8
However, Prince William remains a successor.</p>
      <p>m</p>
      <p>1.</p>
      <p>William
m</p>
      <p>2.</p>
      <p>William
m</p>
      <p>3.</p>
      <p>William
Diana</p>
      <sec id="sec-2-1">
        <title>Charles K</title>
        <p>Diana</p>
      </sec>
      <sec id="sec-2-2">
        <title>Charles K</title>
        <p>Diana</p>
      </sec>
      <sec id="sec-2-3">
        <title>Charles K</title>
        <p>m
4.
m
5.</p>
        <p>Diana</p>
      </sec>
      <sec id="sec-2-4">
        <title>Charles K</title>
        <p>Diana</p>
      </sec>
      <sec id="sec-2-5">
        <title>Charles K</title>
      </sec>
      <sec id="sec-2-6">
        <title>William K</title>
      </sec>
      <sec id="sec-2-7">
        <title>William K</title>
      </sec>
      <sec id="sec-2-8">
        <title>7 The current succession law is available here:</title>
        <p>http://www.legislation.gov.uk/ukpga/2013/20
8 If the KB should include divorces, then the fact that Charles and Diana are now
divorced must be added, too.</p>
        <p>
          Family trees are one of the most prominent introductory examples for
knowledge representation and reasoning in web ontologies as well as in rule-based
systems: In description logics, family trees illustrate the basic language ALC, but
family trees also have a long tradition in rule languages like Prolog, as they
are used in several introductory textbooks; even the succession to the British
throne has advantages for students learning Prolog [
          <xref ref-type="bibr" rid="ref11">11</xref>
          ]. PSOA RuleML was also
motivated by family examples [
          <xref ref-type="bibr" rid="ref12 ref3 ref4">3, 4, 12</xref>
          ].
        </p>
        <p>In fact, genealogy databases are an important application for knowledge
representation in the web. The family history of some famous artists, musicians
and scientists or the history of aristocratic families are use cases for genealogy
knowledge. Although these family trees can include thousands of individuals,
historians and the public are highly interested in getting the family relationships
in a nice format.</p>
        <p>And if you have such a large KB, you will want to get information beyond
the traditional family relationships common to all family trees (married, parent,
child, male, female): The succession to a throne hierarchy is an example that is
only relevant for royal families. In the current paper we demonstrate a fraction
of a proposed British Royal Family KB by representing selected facts about
Diana, Charles and William. This way we keep the focus on the development of
derivation and production rules.
3</p>
        <p>PSOA Prova Translator Implementation
This section deals with the underlying technical part of the PSOA Prova project.</p>
        <p>
          The PSOA Prova translator 9 is based on the ANTLR-based PSOATransRun
translator. PSOATransRun translates PSOA KBs and queries (given in PSOA
Presentation Syntax) either into TPTP or XSB Prolog by doing several
normalization steps (unnesting, subclass rewriting, objectication, describution and
skolemization, conjunctive-conclusion splitting, attening) [
          <xref ref-type="bibr" rid="ref5">5</xref>
          ].
        </p>
        <p>Although Prova does not strictly conform to ISO Prolog, it is in fact a Prolog
implementation. Prova’s goal is to be a powerful language by supporting many
programming paradigms simultaneously, so the ISO Prolog standard is of minor
importance. Nevertheless, both the normalization steps and the Prolog translator
are reused for the Prova Translator. Some basic test cases passed with only a
few syntactic modications in the output of the original translator.</p>
        <p>The Java-Prolog communication is dierent from the XSB and SWI Prolog
targets. The latter two require the middleware Interprolog. Prova has a Java
API and is implemented in Java, hence this target no longer needs to depend on
Interprolog. PSOA Prova’s communication inside of PSOATransRun is done in
the ProvaEngine class, part of the org.ruleml.psoa.psoatransrun.prova package.
The ProvaEngine extends ReusableKBEngine, which means that both KB and
ProvaEngine can be reused for several queries. When the method loadKB with
the translated KB as argument is called from outside, a new Prova instance</p>
      </sec>
      <sec id="sec-2-9">
        <title>9 http://wiki.ruleml.org/index.php/PSOA_Prova</title>
        <p>is created as a ProvaCommunicatorImpl object. There is no need to store the
translated KB separately in a le, because a simple copy of the KB string is
sucient for the Prova instance.</p>
        <p>Query strings are passed to the executeQuery method. They typically consist
of a conjunction of goals with free variables. Each answer set consists of an
assignment of free variables. In Prova, goals are solved by the built-in predicate
‘solve/1’. Only one goal is supported at once: This is why a query consisting of
a conjunction of multiple goals like</p>
        <p>a(...), b(...), c(...)
is rst transformed to a rule</p>
        <p>query(...) :- a(...), b(...), c(...).
and then the single goal ‘query(...)’ is solved by the built-in ‘ solve/1’:
:- solve(query(...)).
3.1</p>
      </sec>
      <sec id="sec-2-10">
        <title>Runtime KB Consult and Unconsult</title>
      </sec>
      <sec id="sec-2-11">
        <title>If you call PSOATransRun from the command line,</title>
        <p>$ java -jar PSOATransRunLocal.jar -i RoyalFamily-KB1.psoa -s -l prova -p
Translated KB:
memterm(’_Charles’,’_successor’).
&gt;
PSOATransRun translates and executes the PSOA KB le given as
commandline argument. The -p echos the translated Prova KB (the original KB could
be echoed by -e). Now you can enter your queries, which will be answered
by PSOATransRun and the underlying rule engine (for reasonable queries see
Section 4).</p>
        <p>PSOA Prova extends PSOATransRun by supporting loading and unloading
PSOA KBs at runtime, but please note that this feature is currently highly
experimental. In PSOA Prova,
&gt; consult RoyalFamily-KB2.psoa
is not interpreted as a query but as an import statement:
Translated KB:
prdsloterm(’_1’,’_marriage’,’_partner’,’_Diana’).
prdsloterm(’_1’,’_marriage’,’_partner’,’_Charles’).
memterm(’_1’,’_marriage’).</p>
        <p>Queries will then be interpreted on the basis of a unied KB that includes
the KB given in command line and every KB that was consulted in query mode.
It is possible to consult multiple KBs and ask queries in between. At any time,
you could remove a KB that was consulted in query mode by running:
&gt; unconsult RoyalFamily-KB2.psoa
Now you can check that the KB was removed successfully (observe that, because
of the translation into a conjunction, the order of the partners does not matter):
&gt; marriage( partner+&gt;Diana partner+&gt;Charles )
Translated Query:
prdsloterm(Q1,’_marriage’,’_partner’,’_Diana’),
prdsloterm(Q1,’_marriage’,’_partner’,’_Charles’),
memterm(Q1,’_marriage’).</p>
        <p>Answer(s):
No</p>
        <p>Consulting and unconsulting KBs was made possible by Prova API functions
consultSync( KB, key, ... );
for consulting a KB and</p>
        <p>unconsultSync( key );
for removing the consulted KB referenced by key. In the PSOA Prova
implementation, the key corresponds to the le path of the original PSOA KB.</p>
        <p>Note that removing a KB is not necessarily equivalent to a rollback of the
transaction of consulting, if the language allows some reactive rules. For example,
if we have a rule that results in printing a physical paper sheet, this cannot be
undone. Pure production rules as dened in Section 5 exploit this by persistently
asserting some derived facts.
4</p>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>Succession by a Derivation Rule</title>
      <p>This section reconstructs the time-dependent mutable KB of Section 2 in PSOA,
step by step. At this point, we have to specify the succession law. If the parents
are in marriage the following simple rule derives the ‘ successor’-membership
from a child of a succcessor (again, the order of the ‘ parent’ slots is irrelevant).</p>
      <p>Forall ?Ch ?P1 ?P2 (
?Ch#successor :- And( ?Ch#child( parent-&gt;?P1 parent-&gt;?P2 )
marriage( partner+&gt;?P1 partner+&gt;?P2 )
?P1#successor )
)
1. We start with a KB that contains successors of the royal family as well
as their marriage and child relationships. In reality, we would start with a
snapshot of a huge KB, but for the demo the derivation-KB-snapshot.psoa
only contains the succession derivation rule and the successorship of Charles.
Try it by running:
$ java -jar PSOATransRunLocal.jar -s -l prova -i derivation-KB-snapshot.psoa</p>
      <sec id="sec-3-1">
        <title>You can test that Charles is a successor by entering:</title>
        <p>&gt; Charles#successor
This tests whether the OID ‘ Charles’ is member of the predicate ‘ successor’.
The actual hierarchy, which means the number in the line of succession could
be indicated by a dependent slot ‘ number+&gt;’:
&gt; Charles#successor( number+&gt;1 )
The answer is ‘No’, because this is not implemented. Moreover, the succession
number could change, for example, if an elder brother’s child would get
inserted in the succession line before the younger brother. Therefore, it seems
more natural to implement the succession line as a dynamic list using the
dependent slots ‘previous+&gt;’ and ‘next+&gt;’. For simplicity, the demo deals
with the membership of the succession line only. It is still an interesting
question who is part of the succession line in a Royal Family.
2. Next, Diana and Charles get married and their marriage becomes
legitimated. This is represented in the KB by adding
&gt; marriage( partner+&gt;Charles partner+&gt;Diana )
which is exactly the content of ‘ RoyalFamily-KB2.psoa’:
&gt; consult RoyalFamily-KB2.psoa
3. Now, Diana gives birth to a child with Charles, Prince William:
&gt; William#child( parent-&gt;Charles parent-&gt;Diana )</p>
      </sec>
      <sec id="sec-3-2">
        <title>We get this after:</title>
        <p>&gt; consult RoyalFamily-KB3.psoa</p>
        <p>Both parents are given by the independent slot ‘ parent-&gt;’.10
4. The succession law is fullled. Hence we can derive from the KB that William
is a (legitimate) successor:
&gt; William#successor
&gt; ?Q#successor
or</p>
        <p>
          You could also want to test more advanced (e.g., non-ground) queries like
10 This is equivalent to ‘ William#child’, ‘William#Top( parent-&gt;Charles )’ and
‘William#Top( parent-&gt;Diana )’ which we would get after some PSOA
normalization (cf. [
          <xref ref-type="bibr" rid="ref7">7</xref>
          ]). It is conceivable that one parent is unknown. In this case, PSOA
allows to formalize just the parentship to the second parent.
&gt; And( ?Ch#successor ?Ch#child( parent-&gt;Diana ) )
The rst query returns all successors (like Charles and William), the second
query gives successors who are children of Diana.
5. Finally, Charles and Diana dissolve their marriage which can be represented
by retracting
&gt; marriage( partner+&gt;Charles partner+&gt;Diana )
from the KB. This is done by:
&gt; unconsult RoyalFamily-KB2.psoa
Note that this was a condition of the successor derivation rule above, hence
we can no longer derive:
&gt; William#successor
However, Prince William should remain a successor. This is not guaranteed
by the derivation rule, since the conclusion no longer holds.
        </p>
        <p>So the question is: What went wrong with the reconstruction? The answer is
that it is sucient and necessary that the parents of a successor are in marriage
at the time of birth and it is irrelevant what happens later. This could be
implemented by a static immutable approach, where marriages are dened by a time
period, so that even dissolved marriages remain in the KB. But, as we will see
later, the time-dynamic formalization approach has some advantages over the
static one. So, in the next section, let us x the mutable approach.
5</p>
      </sec>
    </sec>
    <sec id="sec-4">
      <title>Succession by a Pure Production Rule</title>
      <p>As we saw in the previous section, the derivation rule for succession was suitable
only if it was evaluated directly after birth. When the parents are divorced, the
condition of this rule no longer holds. In a production rule system like CLIPS
with an inationary model, this would not be a problem, since inferred facts
are stored persistently, even if conditions are eventually no longer satised. This
gives us the idea to extend derivation rule languages to some sort of production
rules.</p>
      <p>So let us dene an extended derivation rule where the inferred conclusion
remains persistent. This rule is called pure production rule, as a general
production rule if condition, do action usually allows more actions like retraction
of inferred facts (besides the dierence in the backward-reasoning semantics of
logical derivation rules and the forward-directed classical production rules with
inationary semantics).</p>
      <p>Denition 1. A pure production rule is an extended derivation rule, where the
derived conclusion is asserted persistently to the KB. If the condition holds, the
conclusion is derivable; moreover, the conclusion will be asserted at least before
the condition becomes unsatised.</p>
      <p>The syntax is slightly modied from the derivation rule syntax by replacing
‘:-’ with ‘::-’:
&lt;conclusion&gt; ::- &lt;condition&gt;</p>
      <p>If a non-reactive rule-language is extended only to pure production rules, they
have the same semantics as the standard implication of a derivation rule: We can
still derive the conclusion because any asserted fact was derived at some point.
But in case that the underlying KB changes (by top-level assert and retract),
a pure production rule comes in handy: Even if the conditions are no longer
satised the asserted fact stays in the KB. Note, that pure production rules only
assert proven conclusions as facts. In case of unrestricted knowledge updates
during the derivation proofs, we would need to handle side eects between
assertions and retractions and roll-back resp. disallow any updates in failing proofs.
This can be specied in (Reaction) RuleML semantic proles with the @safety
attribute set to transactional and implemented, e.g. with transaction logics.</p>
      <p>The pure production succession rule is the same as the derivation rule of the
previous section, except that :- is replaced by ::-:</p>
      <p>Forall ?Ch ?P1 ?P2 (
?Ch#successor ::- And( ?Ch#child( parent-&gt;?P1 parent-&gt;?P2 )
marriage( partner+&gt;?P1 partner+&gt;?P2 )
?P1#successor )
)</p>
      <p>It is straightforward to extend PSOATransRun to pure production rules:
Basically, the ANTLR-based tree walkers are adjusted to treat pure production
implications ‘::-’ exactly as standard derivation implications ‘ :-’. Only in the
last PSOA to Prolog conversion step, assert of the conclusion of a pure
production rule is appended to the condition list. 11 So
&lt;conclusion&gt; ::- &lt;condition_1&gt;, ..., &lt;condition_n&gt;.
is translated to:
&lt;conclusion&gt; :- &lt;condition_1&gt;, ..., &lt;condition_n&gt;, assert(&lt;conclusion&gt;).</p>
      <p>Let us now retry the reconstruction of the relationship aw illustrated by
Figure 1 in Section 2 by using the pure production rule in contrast to the
derivation rule of Section 4. First of all, we start with the modied KB snapshot of
11 Implementation details (briey):
1. New token PRODUCTION : ’::-’; in PSOAPS.g
2. For Every Tree walker in PSOACore the ANTLR-rules are adjusted to behave the
same for (standard) IMPLICATION and PRODUCTION.
3. For every pure production rule, PrologConverter.g in PSOA2X nally appends
asserta(&lt;string-copy of the rule head&gt;) .
the current world of the year 1981, before the date of Charles’s and Diana’s
marriage.
$ java -jar PSOATransRunLocal.jar -s -l prova -i production-KB-snapshot.psoa</p>
      <p>We can test that the knowledge states 1. to 4. from Section 4 can be
reproduced by the pure production rule:
1. ... 3. (see Section 4)
4. The succession law is fullled. Hence we can derive from the KB that William
is a (legitimate) successor:
&gt; William#successor
Yes
&gt; ?Q#successor
?Q=_William ;
?Q=_Charles
&gt; And( ?Ch#successor ?Ch#child( parent-&gt;Diana ) )
?Ch=_William
These queries evaluate the pure production rule ‘ successor’: The conclusion
is returned like in a normal derivation rule but additionally asserted.
5. Finally, Charles and Diana dissolve their marriage which can be represented
by retracting
&gt; marriage( partner+&gt;Charles partner+&gt;Diana )
Yes
from the KB. This is done by:
&gt; unconsult RoyalFamily-KB2.psoa
Note that we retracted a condition of the successor production rule above.
Nevertheless we can derive
&gt; William#successor
Yes
because this was asserted as a new fact. The answer is correct according
to the law of succession, since Prince William should remain a successor,
although this is not guaranteed by the derivation rule anymore, since the
conclusion no longer holds:
&gt; marriage( partner+&gt;Charles partner+&gt;Diana )</p>
      <p>No
6</p>
      <p>Become Successor at Birth and not Afterwards!
If we switch 2. and 3. in the sequence displayed by Figure 1, the child still
becomes a successor in the next step. This is problematic: For example, if Charles
had a child with his second wife Camilla before he married Camilla, this child
would become successor too (according to our formalization). This was not
intended, because the succession law clearly requires that the parents have to be
married during birth.</p>
      <p>So we have to distinguish between a legitimate child, whose parents are
married during birth and an illegitimate child whose parents marry afterwards.
Complex event processing (CEP), with temporal reactive semantics, would x this
problem, but we will see that this can be modeled by pure productions rules,
too:</p>
      <p>First, we change the condition of the derivation rule to use a length-1 tuple
indicating legitimacy and to keep only the ‘ successor’-typed ‘parent’ slot:
Forall ?Ch ?P1 (
?Ch#successor :- And( ?Ch#child( legitimate parent-&gt;?P1 )</p>
      <p>?P1#successor )</p>
      <p>Then we have to dene a pure production rule for legitimacy that will be
evaluated only for newly born children:</p>
      <p>Forall ?Ch ?P1 ?P2 (
?Ch#child( legitimate )
::</p>
      <p>And( ?Ch#newly_born( parent-&gt;?P1 parent-&gt;?P2 )</p>
      <p>marriage( partner+&gt;?P1 partner+&gt;?P2 )</p>
      <p>These rules are included in legitimate-KB-snapshot.psoa:
$ java -jar PSOATransRunLocal.jar -s -l prova -i legitimate-KB-snapshot.psoa</p>
      <p>This time, we have to adjust step 3 (for the steps 1-2 see Section 4):</p>
      <sec id="sec-4-1">
        <title>3. Check that William is not yet born:</title>
        <p>&gt; William#child
No
Assert that William is born as child of Diana and Charles:
&gt; consult RoyalFamily-KB3.psoa</p>
      </sec>
      <sec id="sec-4-2">
        <title>Now explicitly assert that William is newly born:</title>
        <p>&gt; consult RoyalFamily-KB3-a.psoa</p>
      </sec>
      <sec id="sec-4-3">
        <title>You can test this, if you like:</title>
        <p>&gt; William#newly_born
Be sure to evaluate the production rule to obtain that William is a legitimite
child:
&gt; William#child( legitimate )</p>
      </sec>
      <sec id="sec-4-4">
        <title>Now, retract that William is newly born:</title>
        <p>&gt; unconsult RoyalFamily-KB3-a.psoa
4. The conditions for the successor rule are satised, hence we can derive</p>
        <p>Note that we have presupposed in step 3 that consult and unconsult
instructions are executed atomically: No other top-level consult and unconsult
statements are allowed when the child is marked as newly born. It would be
fatal if the parents marry while the child is still considered as newly born and
we derive that the child is legitimate. On the other hand, queries are allowed at
any time.</p>
        <p>The atomicity can be implemented by mutual exclusion in a layer between
PSOA Prova on the technical layer and the event processing layer.</p>
        <p>Also note that this is kind of a simulation of an ECA rule (Event Condition
Action): It is an event that a child is newly born, triggered for a short time
interval. On this event, the production rule should re that a child is legitimate,
if the parents are married.</p>
        <p>
          To make the formalization complete you could add some rules to derive that
someone is a disqualied successor. These rules correspond to [
          <xref ref-type="bibr" rid="ref11">11</xref>
          ]. For example,
a person with catholic faith is disqualied 12 from the succession line:
Forall ?S (
?S#successor( disqualified ) :- Or( ?S#deceased
?S#successor( abdicated )
?S#catholic )
)
        </p>
        <p>Finally, it is simple to get the actual succession number of each person with
the depth-rst search algorithm.
7</p>
        <p>When to Evaluate Pure Production Rules?
If Charles and Diana dissolve their marriage, then this can be modeled by
retracting the fact:
marriage( partner+&gt;Charles partner+&gt;Diana )
12 It would be consequent in a way if deceased people were deleted from the KB (just
like marriages). However, since the succession is stored (persistently) in the KB by a
pure production rule, the deletion cannot be done by simply unconsulting a source
le. Such a functionality is future research.
According to the evaluation of the pure production rule, Prince William
remained a successor, although the conditions for the production rule were no
longer satised. But if the Production Rule had never been evaluated before the
marriage of Charles and Diana was dissolved, it can no longer be derived that
William is a successor. This could be intended, but in our opinion, this would
not result in a clear logical semantics. Whether a rule was evaluated or not is
hardly predictable and should be invisible to the user.</p>
        <p>A clearer and transparent functionality for retracting a fact could be achieved
by evaluating all production rules depending on this fact right before the fact is
retracted. This would lead to a non-monotonic state transition semantics, where
the KB transits from one knowledge state to the next knowledge state. In the
succession example, the fact that Prince William is a successor would be asserted
when the marriage of Charles and Diana is retracted (or dissolved).</p>
        <p>
          At the same time, a pure production rule is a special ECA Rule On Event, if
g(...) then assert(g(...)) . However, it is questionable what kind of event triggers
this rule (cf. [
          <xref ref-type="bibr" rid="ref13">13</xref>
          ]), e.g.:
1. Structure operation
(a) after assert
(b) before retract
(c) ...
2. Behavior invocation
(a) when the head of a pure production rule is a derivation (sub)goal
(b) ...
3. Clock (e.g. polling)
4. External (e.g. by the CEP engine which orders assert and retract)
5. ...
        </p>
        <p>Currently, only 2a is implemented for ::-. The other possibilities are also
feasible, when a PSOA pure production rule
&lt;conclusion&gt; ::- &lt;condition&gt;
is translated not in the way of Section 5 but to
&lt;conclusion&gt; :- &lt;condition&gt;.
&lt;event&gt; :- &lt;condition&gt;, assert(&lt;conclusion&gt;).
in Prolog, where &lt;event&gt; may depend on &lt;condition&gt; and/or &lt;conclusion&gt;.
Hence, it follows that any pure production rule is in fact an abbreviation for
two rules, rst, a Prolog derivation rule and second, an ECA rule that is
evaluated on event (not visible to the knowledge engineer).</p>
        <p>In classical production rule systems the update actions, such as assert and
retract, can be considered as implicit events that act as trigger to the production
rules. In the Prova implementation this reactive behaviour can be implemented
using the Prova message built-ins that inform about updates to the knowledge
base and act as event trigger. In our example, the retraction of the marriage
triggers the additional reaction rule, which rst asserts that William is a successor
and then actually retracts the marriage (this would be implemented by 1b):
rcvMsg(XID,self,From, inform, retract(marriage("Charles","Diana"))
:marriage("Charles","Diana"),
assert(successor("William")),
retract(marriage("Charles","Diana")).
8</p>
      </sec>
    </sec>
    <sec id="sec-5">
      <title>Conclusion and Outlook</title>
      <p>PSOATransRun has been extended for PSOA Prova to allow consult and
unconsult of KB modules at runtime. This is a rst step to support (statically)
mutable KBs.</p>
      <p>In addition, PSOATransRun was extended to allow the derivation of
persistent facts by so-called pure production rules. Pure production rules can be seen
either as extended derivation rules (asserting conclusions) or, dually, as restricted
production rules (with only assert actions). 13 They constitute the
derivationproduction-unifying core of rule languages such as RuleML: a minimal superset
of Horn logic and production rules. Negations like negation-as-failure are not
necessarily part of the core (and are not used in this document).</p>
      <p>Both extensions were motivated and used by a time-dynamic knowledge
transition for the use case of a royal family KB.</p>
      <p>A common query for royal family KBs is to get all legitimate successors.
This was discussed for famous members of the British Royal Family according
to the ‘British Succession to the Crown Act 2013’. Three solution approaches
were given in the paper: The rst uses a classical derivation rule. The second
a pure production rule. The third appoach is more advanced and simulates an
ECA rule by top-level assert, retract and a pure production rule.</p>
      <p>All three approaches were tested against the scenario in how Prince William
became a successor, because one of his parents is a successor and both parents
were married at the time he was born. The rst derivation-rule approach failed
(hence, is incomplete) because it was no longer derivable that William was a
successor after the parents were divorced.</p>
      <p>Pure production rules were dened as extended derivation rules where the
conclusion is also asserted persistently. For the second approach we could derive
that William was still a successor after the parents were divorced, since this
was asserted persistently by the pure production succession rule. As discussed
in Section 6, this pure production formalization approach is unsound, since even
someone who was not born as a successor could eventually become a successor:
This is the case when the parents were not married during birth but married
afterwards.</p>
      <p>The third approach is based on the rst approach and xes incompleteness
and unsoundness by dening a pure production rule for legitimate children.</p>
      <p>Nevertheless, all approaches can be adequate for other royal families (with
other rules) or in case that the succession law changes. In general, dynamic
13 Also similar to rules for goal-directed bottom-up execution (for exhaustive
bottomup execution see, e.g., (OO) jDREW Bottom-Up: http://www.jdrew.org/oojdrew/.
KBs for time-dynamic domains have the advantage of not requiring an explicit
representation of time-related aspects: It is not necessary to store any time or
date references or historic revisions of the KB, even if the knowledge state, and
therefore the KB, changes in time.</p>
      <p>
        Prova, with its built-ins for sending and receiving messages supports implicit
events that can trigger an evaluation of (sub)goals so that a forward-directed
production semantics for knowledge updates can be implemented. To avoid
nondeclarative behavior, as discussed in Section 5 about inationary semantics of
classical production rules, this would additionally require that the logical
semantics is extended to a transaction logic [
        <xref ref-type="bibr" rid="ref14">14</xref>
        ], where knowledge updates, such as
assert and retract, are rolled back in case of failing proofs.
      </p>
      <p>RoyalFamily-KB1.psoa
A</p>
    </sec>
    <sec id="sec-6">
      <title>Appendix</title>
      <p>)
)
)
RuleML (</p>
      <p>Assert (</p>
      <p>Charles#successor
% Pure production rule for the succession to the British throne:
% A successor must be a (biological) child of a successor and both
% parents have to be in marriage.</p>
      <p>Forall ?Ch ?P1 ?P2 (
?Ch#successor
::</p>
      <p>And( ?Ch#child( parent-&gt;?P1 parent-&gt;?P2 )
marriage( partner+&gt;?P1 partner+&gt;?P2 )
?P1#successor
% Derivation rule for the succession to the British throne:
% A successor must be a legitimate (biological) child of a successor.
Forall ?Ch ?P1 (
?Ch#successor
:</p>
      <p>And(
?Ch#child( legitimate parent-&gt;?P1 )
?P1#successor
% Pure production rule for a legitimate child
Forall ?Ch ?P1 ?P2 (
?Ch#child( legitimate )
::</p>
      <p>And( ?Ch#newly_born( parent-&gt;?P1 parent-&gt;?P2 )</p>
      <p>marriage( partner+&gt;?P1 partner+&gt;?P2 )</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <surname>Katerinenko</surname>
            ,
            <given-names>R.S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Bessmertnyi</surname>
            ,
            <given-names>I.A.</given-names>
          </string-name>
          :
          <article-title>A method for acceleration of logical inference in the production knowledge model</article-title>
          .
          <source>Programming and Computer Software</source>
          <volume>37</volume>
          (
          <issue>4</issue>
          ) (
          <year>2011</year>
          )
          <fpage>197199</fpage>
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <surname>Pujara</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Getoor</surname>
            ,
            <given-names>L.</given-names>
          </string-name>
          :
          <article-title>Building dynamic knowledge graphs</article-title>
          .
          <source>In: NIPS Workshop on Automated Knowledge Base Construction</source>
          . (
          <year>2014</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <surname>Boley</surname>
          </string-name>
          , H.:
          <article-title>A RIF-Style Semantics for RuleML-Integrated Positional-Slotted, Object-Applicative Rules</article-title>
          .
          <source>In: Proc. 5th International Symposium on Rules: Research Based and Industry Focused (RuleML-2011 Europe)</source>
          ,
          <source>Barcelona, Spain. Lecture Notes in Computer Science</source>
          , Springer (July
          <year>2011</year>
          )
          <fpage>194211</fpage>
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <surname>Boley</surname>
          </string-name>
          , H.:
          <article-title>PSOA RuleML: Integrated Object-Relational Data and Rules</article-title>
          . In Faber, W.,
          <string-name>
            <surname>Paschke</surname>
          </string-name>
          , A., eds.
          <source>: Reasoning Web. Web Logic Rules (RuleML</source>
          <year>2015</year>
          )
          <article-title>-</article-title>
          11th
          <source>Int'l Summer School</source>
          <year>2015</year>
          , Berlin, Germany,
          <source>July 31- August 4</source>
          ,
          <year>2015</year>
          ,
          <string-name>
            <given-names>Tutorial</given-names>
            <surname>Lectures</surname>
          </string-name>
          . Volume
          <volume>9203</volume>
          of LNCS., Springer (
          <year>2015</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <surname>Boley</surname>
            ,
            <given-names>H.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Zou</surname>
          </string-name>
          , G.:
          <article-title>Perspectival Knowledge in PSOA RuleML: Representation, Model Theory, and Translation</article-title>
          .
          <source>CoRR abs/1712</source>
          .02869 (
          <year>2017</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <surname>Zou</surname>
          </string-name>
          , G.:
          <article-title>Translators for Interoperating and Porting Object-Relational Knowledge</article-title>
          .
          <source>PhD thesis</source>
          , Faculty of Computer Science, University of New Brunswick (April
          <year>2018</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <surname>Zou</surname>
            ,
            <given-names>G.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Boley</surname>
            ,
            <given-names>H.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Wood</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Lea</surname>
            ,
            <given-names>K.</given-names>
          </string-name>
          :
          <article-title>Port Clearance Rules in PSOA RuleML: From Controlled-English Regulation to Object-Relational Logic</article-title>
          .
          <source>In: Proceedings of the RuleML+RR 2017 Challenge. Volume</source>
          <year>1875</year>
          .,
          <string-name>
            <surname>CEUR</surname>
          </string-name>
          (
          <year>July 2017</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8.
          <string-name>
            <surname>Paschke</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Boley</surname>
          </string-name>
          , H.:
          <article-title>Rules capturing events and reactivity</article-title>
          . In Giurca,
          <string-name>
            <surname>A.</surname>
          </string-name>
          , Gsaevi¢,
          <string-name>
            <given-names>D.</given-names>
            ,
            <surname>Taveter</surname>
          </string-name>
          , K., eds.:
          <source>Handbook of Research on Emerging Rule-Based Languages and Technologies</source>
          . Hershey, PA (
          <year>2009</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          9.
          <string-name>
            <surname>Paschke</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Boley</surname>
            ,
            <given-names>H.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Zhao</surname>
            ,
            <given-names>Z.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Teymourian</surname>
            ,
            <given-names>K.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Athan</surname>
            ,
            <given-names>T.</given-names>
          </string-name>
          :
          <article-title>Reaction ruleml 1.0: Standardized semantic reaction rules</article-title>
          . [
          <volume>15</volume>
          ]
          <fpage>100119</fpage>
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          10.
          <string-name>
            <surname>Zou</surname>
            ,
            <given-names>G.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Boley</surname>
          </string-name>
          , H.:
          <article-title>PSOA2Prolog: Object-Relational Rule Interoperation and Implementation by Translation from PSOA RuleML to ISO Prolog</article-title>
          . In Bassiliades, N.,
          <string-name>
            <surname>Gottlob</surname>
            ,
            <given-names>G.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Sadri</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Paschke</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Roman</surname>
          </string-name>
          , D., eds.: Rule Technologies: Foundations, Tools, and
          <string-name>
            <surname>Applications</surname>
          </string-name>
          ,
          <source>Proc. 9th International Symposium, RuleML</source>
          <year>2015</year>
          , Berlin, Germany,
          <source>August 2-5</source>
          ,
          <year>2015</year>
          . Volume
          <volume>9202</volume>
          of Lecture Notes in Computer Science., Springer (
          <year>August 2015</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          11.
          <string-name>
            <surname>Mohr</surname>
          </string-name>
          , J.:
          <article-title>Two novel prolog assignments</article-title>
          . In BrØzillon, P.,
          <string-name>
            <surname>Russell</surname>
            ,
            <given-names>I.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Labat</surname>
          </string-name>
          , J., eds.
          <source>: Proceedings of the 14th Annual SIGCSE Conference on Innovation and Technology in Computer Science Education, ITiCSE</source>
          <year>2009</year>
          , Paris, France,
          <source>July 6-9</source>
          ,
          <year>2009</year>
          , ACM (
          <year>2009</year>
          )
          <fpage>350</fpage>
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          12.
          <string-name>
            <surname>Manir</surname>
            ,
            <given-names>M.S.A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Riazanov</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Boley</surname>
            ,
            <given-names>H.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Baker</surname>
            ,
            <given-names>C.J.O.</given-names>
          </string-name>
          :
          <article-title>PSOA ruleml API: A tool for processing abstract and concrete syntaxes</article-title>
          . [
          <volume>15</volume>
          ]
          <fpage>280288</fpage>
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          13.
          <string-name>
            <surname>Paton</surname>
            ,
            <given-names>N.W.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Daz</surname>
            ,
            <given-names>O.</given-names>
          </string-name>
          :
          <article-title>Active database systems</article-title>
          .
          <source>ACM Comput. Surv</source>
          .
          <volume>31</volume>
          (
          <issue>1</issue>
          ) (
          <year>March 1999</year>
          )
          <fpage>63103</fpage>
        </mixed-citation>
      </ref>
      <ref id="ref14">
        <mixed-citation>
          14.
          <string-name>
            <surname>Bonner</surname>
            ,
            <given-names>A.J.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Kifer</surname>
            ,
            <given-names>M.:</given-names>
          </string-name>
          <article-title>An overview of transaction logic</article-title>
          .
          <source>Theoretical Computer Science</source>
          <volume>133</volume>
          (
          <issue>2</issue>
          ) (
          <year>1994</year>
          )
          <fpage>205</fpage>
          <lpage>265</lpage>
        </mixed-citation>
      </ref>
      <ref id="ref15">
        <mixed-citation>
          15.
          <string-name>
            <surname>Bikakis</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Giurca</surname>
          </string-name>
          , A., eds.
          <source>: Rules on the Web: Research and Applications - 6th International Symposium, RuleML</source>
          <year>2012</year>
          , Montpellier, France,
          <source>August 27-29</source>
          ,
          <year>2012</year>
          . Proceedings. Volume
          <volume>7438</volume>
          of Lecture Notes in Computer Science., Springer (
          <year>2012</year>
          )
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>