TABDUAL+int is an improvement of TABDUAL+ (see https://github.com/harventhy/tabdual-plus) by adding an advance feature tabling which is tabling with interned terms. TABDUAL+int is implemented in XSB Prolog, so you need to install XSB Prolog in your machine. For convenience, you might want to put the path to directory where the XSB command is found in your $PATH
environment variable. Otherwise, you have to include the path to directory where you have this implementation into XSB default search paths using predicate library_directory/1
.
You can define an input program, i.e. a logic program, as your own knowledge base inside in
folder in a file called {filename}.ab
. Your input program has to satisfy following properties:
- Abducibles is specified by predicate
abds/1
whose argument is a list of abducibles along with its arity. For exampleabds([a/1, b/2, c/3])
. - To define a rule (including an integrity constraint), please use
<-
instead of:-
to denote if operator. For example, please useH <- X, Y.
instead of usingH :- X, Y.
. - Predicates comprising just fact are written separately between the
beginProlog.
andendProlog.
identifiers. - Regular Prolog programs (those that will not be transformed) are also written separately between the
beginProlog.
andendProlog.
identifiers. Please useH :- X, Y.
instead of usingH <- X, Y.
when defining regular Prolog programs because these programs will not be transformed but will be rewritten as it is.
With regard to properties mentioned above, your input program must be written in following parts, ordered from top to bottom:
beginProlog.
andendProlog.
identifiers, and also facts and programs that need to be placed between them. This part is unnecessary when no such program in it.- Abducibles.
- Rules.
TABDUAL+int implementation consists of two phases:
- Program transformation.
In transformation phase, your input program will be transformed into its corresponding output program that supports contextual abduction. The output program will be used in the next stage. Before you transform your input program, you can choose what mode of transformation you want to use using predicate
switch_mode/1
. TABDUAL+int provides four transformation modes, which are no tabling, normal tabling, tabling with answer subsumption, and tabling with interned terms. Those program transformation respectively coded into n, t, s, and i. For example, if you want to using tabling with interned terms mode, you must switch mode using directiveswitch_mode(i)
. Notice that in TABDUAL+int, the default mode is normal tabling mode. So, if you skip this step, you will automatically using normal tabling mode for transformation program.
To transform your input program{filename}.ab
, typetransform({filename}).
and then hit Enter. The output program{filename}_{InitialMode}.pl
will be created inout
folder. For example, if you want to transform an input programgoodgrades.ab
using tabling with interned terms mode, you have to typetransform(goodgrades)
, and consequently a filegoodgrades_int.pl
will be created inout
folder. Remember that your input programgoodgrades.ab
must be placed insidein
folder. To avoid errors in the next steps, please always perform this step even though the corresponding output program has been created. - Abduction. In abduction phase, you may perform the abduction itself output program that is produced in the previous stage. Practically, you have to load the output program first, only then you can perform abduction by asking queries to the loaded program.
-
Open a terminal in the directory where you have this implementation.
-
Invoke XSB by the command:
$ xsb
Notice that this command may vary depends on how XSB is configured in your machine. Make sure you have entered XSB prompt level (indentified by | ?-
prompt) before you proceed to the next step.
-
Type
[tabdual].
and then hit Enter to load the main program. -
Type
load({filename}).
and then hit Enter to load your output program. For example, you have to typeload(goodgrades)
to load the output programgoodgrades_int.pl
. Make sure you have transformed the corresponding input program that you want to load, otherwise errors may occur. -
Now you may ask a query using predicate
ask/1
whose argument is the query you want to ask. If you want to retrieve the solution gradually, please useask/2
whose first argument is the query you want to ask, while the second is the solution to the query, retrieved one by one. If you want to supply abductive contexts, use predicateask/3
instead, whose second argument is a list of abductive contexts you want to supply, the first and the last arguments remain the same asask/2
. Please do not forget to use parentheses if you are asking multiple goals in the query. Here are some example of usage predicateask/1
,ask/2
, andask/3
. These examples will usein/goodgrades.ab
as its input program.% using ask/1
?- ask(getting_good_grades)).
(1) [getting_lucky,healthy]
(2) [have_study_notes]
yes
% using ask/1 with multiple goals
?- ask((getting_good_grades,studying_hard)).
(1) [getting_lucky,healthy,have_study_notes]
(2) [have_study_notes]
yes
% using ask/2
?- ask(getting_good_grades, O).
O = [getting_lucky,healthy];
% type ';' to retrieve next goals
O = [have_study_notes];
no
% using ask/3 (with conflicting abductive context)
?- ask(q(1), [not a(1)], O).
O = [not have_study_notes,getting_lucky,healthy];
no
If you want to know more how this program work including the experiment results, you can read our paper in here: http://jiki.cs.ui.ac.id/index.php/jiki/article/view/569/404.
You are free to use and improve the TABDUAL+int, but if you want to publish paper/publication using the TABDUAL+int, please cite this publication:
M. O. Ibrohim and A. Saptawijaya, “Tabling with Interned Terms On Contextual Abduction”, Jurnal Ilmu Komputer dan Informasi, vol. 12(1), pp. 1-11, 2019. (Every paper template may have different citation writting. For LaTex user, you can see citation.bib).
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.