... for ... execute <? ... ?>

The construction ... for ... execute <? ... ?> is used to express active rules, which are a special case of SWRL rules. If an active rule is fulfilled, some code/simple program can be executed. The concepts listed after for are used as variables, while execute <? ... ?> is followed be the code to be performed.

Different use cases of variables in semantic rules are summed up in the table below.


Those examples show how to write active rules with the construction ... for ... execute <? ... ?>.

Example: Active rule for an ontology monitoring the state of IT infrastructure.
If a server is connected by a thing and the thing has-status Inoperable then for the server and the thing execute
KnowledgeInsert(string.Format("{0} is connected by {1} and has-status Inoperable.", server, thing)); WriteMessage("[" + DateTime.Now + "] " + server + " is inoperable due to " + thing + ".");