1.1 Prova Target
PSOATransRun's new Prova instantiation PSOATransRun[PSOA2Prolog,Prova] is executed by
1.2 Consult & Unconsult
If you call PSOATransRun from command line,
$ java -jar PSOATransRunLocal.jar -i RoyalFamily-KB1.psoa -s -l prova
PSOATransRun translates and executes the PSOA KB file given as command line argument. It then enters the interactive query mode, indicated by:
Now, you can enter your queries, which will be answered by PSOATransRun and the underlying rule engine.
PSOA Prova extends PSOATransRun by supporting loading and unloading PSOA KBs at run-time, but please note that this feature is currently highly experimental. In PSOA Prova,
> consult RoyalFamily-KB2.psoa
is not interpreted as a query but as an import statement. Queries will then be interpreted on the basis of a unified KB that includes the KB given in command line and every KB that was imported in query mode. Be free to import multiple KBs and ask queries in between. At any time, you could remove a KB that was imported in query mode by running:
> unconsult RoyalFamily-KB2.psoa
1.3 Pure Production Rules
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 unsatisfied.
The syntax is slightly modified from the derivation rule syntax by replacing
<conclusion> ::- <condition>
1.4 Experimental Tabling Support
Prova has tabling support by the
cache/1 builtin. To enable tabling for a predicate
p(...), all occurrences of this predicate in any rule body must be replaced by
cache(p(...)). This is done by PSOATransRun in the "new" targeting language
-l prova still produces prova code without the
cache/1 built-in, hence without tabling.
2 Download and Install
Source installation instructions can be found in the README.md.
3 Try It Out
The following expands the PSOATransRun examples by using PSOA Prova specific features.
3.1 Test Cases
Will be added soon.
3.2 Use Case: Royal Family Demo
See this challenge paper for a more detailed description of the use case and instructions for running the demo. There is a screen record for the Succession to the Crown by a derivation rule in comparison to a screen record for a pure production rule.
Try out one of the snapshot-KBs (
production-KB-snapshot.psoa includes a pure production rule):
$ java -jar PSOATransRunLocal.jar -s -l prova -i production-KB-snapshot.psoa
Now, you can dynamically
unconsult KBs and enter queries. For example, test if Prince William is one of the successors:
> William#successor No
He wont become successor before his parents marry and have him as a child! Try to
consult the corresponding KBs.
4 Implementation Details
Java Prova communication inside of PSOATransRun is done in the ProvaEngine class, part of the org.ruleml.psoa.psoatransrun.prova package. ProvaEngine extends ReusableKBEngine, which means that both KB and Prova engine can be reused for several queries. When the method loadKB with the translated KB as argument is called from outside, a new Prova instance is created as a ProvaCommunicatorImpl object. Query strings are passed to the executeQuery method. They typically consist of a conjunction of goals with free variables. Each answer set consists of the assignment of free variables. In Prova, only queries with exactly one goal are supported: This is why a query consisting of a conjunction of multiple goals like
a(...), b(...), c(...)
is first transformed to a rule
query(...) :- a(...), b(...), c(...).
and then the single goal
query(...) is solved by the built-in
Importing and removing KBs was made possible by Prova API
consultSync( KB, key, ... );
for importing a KB and
unconsultSync( key );
for removing the consulted KB referenced by key. In the PSOA Prova
implementation, the key corresponds to the file path of the original PSOA KB.
It is straightforward to extend PSOATransRun to pure production rules: Basically, the ANTLR-based tree walker were adjusted to treat pure production
::- 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.
<conclusion> ::- <condition_1>, ..., <condition_n>.
is translated to:
<conclusion> :- <condition_1>, ..., <condition_n>, assert(<conclusion>).
1. Lukas Grätz, Harold Boley, Adrian Paschke: PSOA Prova: PSOA Translation of Pure Production Rules to the Prova Engine. RuleML+RR 2018: 2nd International Joint Conference on Rules and Reasoning, September 2018. Proceedings: http://ceur-ws.org/Vol-2204/paper8.pdf Slides: https://www.stud.uni-leipzig.de/lukasgraetz/PSOAProvaPureProductionSlides.pdf