The Action Plugin and Action Addon Framework


The Knowledge Base Modification (KBMod) Action Addon

The Knowledge Base Modification Action Addon (in short KBMod) is an addon which provides essential action facilities enabling users to alter external knowledge bases by asserting and rectracting knowledge.

Note that, as of ActHEX 2.0, one can consider, instead of opting for the KBMod features, using an internal source of knowledge (an Environment) for storing information. Note that Environments are performance-wise a better option, although they require some (little) programming burden.

Moreover, KBMod provides the ability to execute arbitrary commands in the shell. The KBMod functionalities are provided by three different action atoms: #retract, #assert, #execute.


Quick reference for action atoms of the addon follow.

#retract Atom

#retract[F, RO, S+]{O,P}
Input:
F
file path of the knowledge base
RO
retract option, either exact or predicate
S+
one or more instances of S whose concatenation will be used when executing retraction. S+ is a comma separated list of one or more strings or integers

#retract action atom will allow user to retract knowledge from knowledge base whose path is F. In the case that the retract option is set to exact, the lines that exactly match the string S+ concatenated with "." will be retracted from the knowledge base. On the other hand, when the retract option is set to predicate the lines that contains an atom whose predicate is exactly S+ will be removed from the knowledge base. Note that there is an implicit assumption that each line contains only one fact or one rule.

Example:

 #retract["kb.lp", predicate, "size"]{b, 1}.

This fact will remove any line that contains an atom with predicate "size" from the knowledge base available at kb.lp.

 #retract["kb.lp", exact, "vertex(", N, ")"]{c, 4} :- unreachable(N).

This rule will remove any line that exactly matches "vertex(N)." from the knowledge based available at kb.lp where N will be instantiated according to the rule body. Note that we will retract every "vertex(i)." for every "unreachable(i)".

#assert Atom

#assert[F, S+]{O,P}
Input:
F
file path of the knowledge base
S+
one or more instances of S whose concatenation will be used in the assert action. S+ is a comma separated list of one or more strings or integers

#assert action atom will allow users to add knowledge to the knowledge base whose path is F. The string S+ will be added to the knowledge base. Note that no syntactic check is applied to the asserted knowledge. Hence, users are expected to respect the syntactic rules of the knowledge base.

Example:

 #assert["kb.lp", "size(5)"]{b, 1}.

The fact will add "size(5)." to the knowledge base whose path is F.

#execute Atom

#execute[S+]{O,P}
Input:
S+
one or more instances of S whose concatenation will be used in execute action as the command where S is a string or integer

#execute action atom will allow users to execute the string S+ in the shell while the dlvhex program is still running.

Example:

 #execute["dlvhex --firstorder kb.lp"]{c,3}.

The fact will execute "dlvhex" with "firstorder" option on the knowledge base whose path is "kb.lp".

 #execute["dlv --firstorder" -n=",X," kb.lp"]{b,2}:- size(X).

The rule will execute "dlv" with "firstorder" option and " -n" option set equal to X on the knowledge base whose path is "kb.lp". Notice that X is not a string thus it will be instantiated depending on the size atoms that are in the interpretation.


In all of the examples, O (resp. P) are option (resp. precedence) that appears in action atoms. Additionally, mentioned action atoms can be combined with weight and level.


You can check it out its source here.

For other action addons return to the section Action Addons of The Action Plugin and Action Addon Framework.



Last edited 2013-04-23

 

General
dlvhex source code @ github.com
Description-Of-A-Project

Popular Plugins
Action Plugin
DecisionDiagrams Plugin
Description Logics Plugin
Description Logics Lite Plugin
MELD: Belief Merging Plugin
Nested HEX Plugin
MCSIE Plugin
String Plugin
dlvhex-semweb Project

Documentation
User Guide
README
doxygen
Writing Plugins in C++
Writing Plugins in Python