Revision 8ae3500bc11757418ae922dcf891f750ca691dd6 authored by vthierry on 05 December 2025, 10:56:55 UTC, committed by vthierry on 05 December 2025, 10:56:55 UTC
1 parent 4159546
Rules.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Rules - Documentation</title>
<script src="scripts/prettify/prettify.js"></script>
<script src="scripts/prettify/lang-css.js"></script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
<script src="scripts/nav.js" defer></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger" class="navicon-button x">
<div class="navicon"></div>
</label>
<label for="nav-trigger" class="overlay"></label>
<nav >
<input type="text" id="nav-search" placeholder="Search" />
<h2><a href="index.html">Home</a></h2><h3>Objects</h3><ul><li><a href="Array.html">Array</a><ul class='members'></ul><ul class='methods'><li data-type='method' style='display: none;'><a href="Array.html#add">add</a></li><li data-type='method' style='display: none;'><a href="Array.html#get">get</a></li></ul></li><li><a href="AssociativeMap.html">AssociativeMap</a><ul class='members'></ul><ul class='methods'><li data-type='method' style='display: none;'><a href="AssociativeMap.html#add">add</a></li><li data-type='method' style='display: none;'><a href="AssociativeMap.html#erase">erase</a></li><li data-type='method' style='display: none;'><a href="AssociativeMap.html#get">get</a></li><li data-type='method' style='display: none;'><a href="AssociativeMap.html#get">get</a></li><li data-type='method' style='display: none;'><a href="AssociativeMap.html#getBundling">getBundling</a></li><li data-type='method' style='display: none;'><a href="AssociativeMap.html#getSize">getSize</a></li><li data-type='method' style='display: none;'><a href="AssociativeMap.html#asString">asString</a></li><li data-type='method' style='display: none;'><a href="AssociativeMap.html#getValue">getValue</a></li><li data-type='method' style='display: none;'><a href="AssociativeMap.html#getKey">getKey</a></li></ul></li><li><a href="AssociativeNetwork.html">AssociativeNetwork</a><ul class='members'></ul><ul class='methods'><li data-type='method' style='display: none;'><a href="AssociativeNetwork.html#add">add</a></li></ul></li><li><a href="Belief.html">Belief</a><ul class='members'><li data-type='member' style='display: none;'><a href="Belief.html#tau">tau</a></li><li data-type='member' style='display: none;'><a href="Belief.html#sigma">sigma</a></li></ul><ul class='methods'><li data-type='method' style='display: none;'><a href="Belief.html#asString">asString</a></li></ul></li><li><a href="Binding.html">Binding</a><ul class='members'></ul><ul class='methods'><li data-type='method' style='display: none;'><a href="Binding.html#y">y</a></li><li data-type='method' style='display: none;'><a href="Binding.html#x">x</a></li><li data-type='method' style='display: none;'><a href="Binding.html#b">b</a></li><li data-type='method' style='display: none;'><a href="Binding.html#normalized">normalized</a></li><li data-type='method' style='display: none;'><a href="Binding.html#asString">asString</a></li><li data-type='method' style='display: none;'><a href="Binding.html#.getComputationTIme">getComputationTIme</a></li></ul></li><li><a href="Bundling.html">Bundling</a><ul class='members'></ul><ul class='methods'><li data-type='method' style='display: none;'><a href="Bundling.html#add">add</a></li><li data-type='method' style='display: none;'><a href="Bundling.html#erase">erase</a></li><li data-type='method' style='display: none;'><a href="Bundling.html#getSorted">getSorted</a></li><li data-type='method' style='display: none;'><a href="Bundling.html#get">get</a></li></ul></li><li><a href="List.html">List</a><ul class='members'></ul><ul class='methods'><li data-type='method' style='display: none;'><a href="List.html#add">add</a></li><li data-type='method' style='display: none;'><a href="List.html#erase">erase</a></li><li data-type='method' style='display: none;'><a href="List.html#getNext">getNext</a></li><li data-type='method' style='display: none;'><a href="List.html#getPrevious">getPrevious</a></li></ul></li><li><a href="Number.html">Number</a><ul class='members'></ul><ul class='methods'><li data-type='method' style='display: none;'><a href="Number.html#.getInt">getInt</a></li></ul></li><li><a href="RelationalMap.html">RelationalMap</a><ul class='members'></ul><ul class='methods'><li data-type='method' style='display: none;'><a href="RelationalMap.html#add">add</a></li><li data-type='method' style='display: none;'><a href="RelationalMap.html#add">add</a></li><li data-type='method' style='display: none;'><a href="RelationalMap.html#add">add</a></li><li data-type='method' style='display: none;'><a href="RelationalMap.html#get">get</a></li><li data-type='method' style='display: none;'><a href="RelationalMap.html#get">get</a></li><li data-type='method' style='display: none;'><a href="RelationalMap.html#asString">asString</a></li><li data-type='method' style='display: none;'><a href="RelationalMap.html#.asString">asString</a></li><li data-type='method' style='display: none;'><a href="RelationalMap.html#save">save</a></li></ul></li><li><a href="Rule.html">Rule</a><ul class='members'></ul><ul class='methods'><li data-type='method' style='display: none;'><a href="Rule.html#getName">getName</a></li><li data-type='method' style='display: none;'><a href="Rule.html#getArity">getArity</a></li><li data-type='method' style='display: none;'><a href="Rule.html#getTau">getTau</a></li><li data-type='method' style='display: none;'><a href="Rule.html#isValid">isValid</a></li><li data-type='method' style='display: none;'><a href="Rule.html#setOutput">setOutput</a></li></ul></li><li><a href="Rules.html">Rules</a><ul class='members'></ul><ul class='methods'><li data-type='method' style='display: none;'><a href="Rules.html#add">add</a></li><li data-type='method' style='display: none;'><a href="Rules.html#isDifferent">isDifferent</a></li><li data-type='method' style='display: none;'><a href="Rules.html#apply">apply</a></li></ul></li><li><a href="Symbol.html">Symbol</a><ul class='members'><li data-type='member' style='display: none;'><a href="Symbol.html#.nill">nill</a></li></ul><ul class='methods'><li data-type='method' style='display: none;'><a href="Symbol.html#getName">getName</a></li><li data-type='method' style='display: none;'><a href="Symbol.html#getID">getID</a></li><li data-type='method' style='display: none;'><a href="Symbol.html#getType">getType</a></li><li data-type='method' style='display: none;'><a href="Symbol.html#getVector">getVector</a></li><li data-type='method' style='display: none;'><a href="Symbol.html#getBelief()">getBelief()</a></li><li data-type='method' style='display: none;'><a href="Symbol.html#setBelief()">setBelief()</a></li><li data-type='method' style='display: none;'><a href="Symbol.html#equals">equals</a></li><li data-type='method' style='display: none;'><a href="Symbol.html#asString">asString</a></li><li data-type='method' style='display: none;'><a href="Symbol.html#.getDimension">getDimension</a></li><li data-type='method' style='display: none;'><a href="Symbol.html#.setDimension">setDimension</a></li><li data-type='method' style='display: none;'><a href="Symbol.html#.clone">clone</a></li><li data-type='method' style='display: none;'><a href="Symbol.html#.fromJSON">fromJSON</a></li><li data-type='method' style='display: none;'><a href="Symbol.html#.toJSON">toJSON</a></li><li data-type='method' style='display: none;'><a href="Symbol.html#.dump">dump</a></li></ul></li><li><a href="algo.html">algo</a><ul class='members'><li data-type='member' style='display: none;'><a href="algo.html#.sigma_0">sigma_0</a></li></ul><ul class='methods'><li data-type='method' style='display: none;'><a href="algo.html#.reduce">reduce</a></li><li data-type='method' style='display: none;'><a href="algo.html#.sim">sim</a></li><li data-type='method' style='display: none;'><a href="algo.html#.msim">msim</a></li><li data-type='method' style='display: none;'><a href="algo.html#.conj">conj</a></li></ul></li></ul>
</nav>
<div id="main">
<h1 class="page-title">Rules</h1>
<section>
<header>
<h2>
Rules
</h2>
</header>
<article>
<div class="container-overview">
<h4 class="name" id="Rules"><span class="type-signature"></span>new Rules<span class="signature">(maximalDepth<span class="signature-attributes">opt</span>, trace<span class="signature-attributes">opt</span>, traceOutput<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
<dl class="details">
<dt class="tag-description">Description:</dt>
<dd class="tag-description"><ul class="dummy"><li><p>Implements a VSA based inference mechanism.</p>
<ul>
<li>Inference rules are typically defined using such macro construction:</li>
</ul>
<pre class="prettyprint source"><code> class MyRules: public Rules {
public:
MyRules() : Rules() {
// ClassInheritance
Rule_2(rdfs9_,
// getTau()
return algo::conj(algo::sim(predicate_1, "rdf::type"), algo::sim(object_1, subject_2), algo::sim(predicate_2, "rdfs:subClassOf"));,
// setOutput() : please note that *subject_1 and other triple references are pointer prefixed with '*'
output.add(*subject_1, tau, "rdfs:type", *object_2);
);
../.. // Here defining other rules in Rules() constructor.
}
} myRules;
</code></pre>
<p>where <code>Rule_1</code>, <code>Rule_2</code> and <code>Rule_3</code> allows to specifies rules of arity 1, 2 ou 3, with as syntax of the form:</p>
<pre class="prettyprint source"><code>Rule_i(ruleName, getTau_return_expression, setOutput_add_instruction);
</code></pre></li></ul></dd>
</dl>
<h5 class="h5-parameters">Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>maximalDepth</code></td>
<td class="type">
<span class="param-type">uint</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
<code>0</code>
</td>
<td class="description last"><p>Maximal number of recursion,</p>
<ul>
<li>i.e.,of reintroducing produced rule output as incoming input, 0 means unbounded.</li>
</ul></td>
</tr>
<tr>
<td class="name"><code>trace</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
<code>"ado"</code>
</td>
<td class="description last"><p>Defines the inference trace log, using a combination of chars.</p>
<ul>
<li>'a' : Dumps applied valid rules application.</li>
<li>'u' : Dumps unapplied invalid rules application.</li>
<li>'d' : Dumps the depth value when starting the inference.</li>
<li>'i' : Dumps incoming triples before each recursion step.</li>
<li>'o' : Dumps output triples produces a each recursion step.</li>
</ul></td>
</tr>
<tr>
<td class="name"><code>traceOutput</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
<code>"stdout"</code>
</td>
<td class="description last"><p>defines the trace target:</p>
<ul>
<li>"stdout": The stdout during the inference mechanism.</li>
<li>filename : A <code>filename.log</code> file saves at the end of the inference mechanism.</li>
</ul></td>
</tr>
</tbody>
</table>
</div>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id="add"><span class="type-signature"></span>add<span class="signature">(rule)</span><span class="type-signature"></span></h4>
<dl class="details">
<dt class="tag-description">Description:</dt>
<dd class="tag-description"><ul class="dummy"><li><p>Adds a new rule to the mechanism.</p>
<ul>
<li>A typical manual construction of a rule is of the form:</li>
</ul>
<pre class="prettyprint source"><code>class MyRule: public Rule {
public:
// Defines the rule name and arity
MyRule() : Rule("name", arity) {}
// Implements the proper tau calculation mechanism.
virtual Belief getTau(const Symbol& subject_1, const Symbol& predicate_1, const Symbol& object_1, const Symbol& subject_2, const Symbol& predicate_2, const Symbol& object_2) {
return ../..
}
// Implements the proper triple generation mechanism.
void setOutput(RelationalMap& output) {
output.add( ../..
}
};
static MyRule myRule;
rules.add(myRule);
</code></pre></li></ul></dd>
</dl>
<h5 class="h5-parameters">Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>rule</code></td>
<td class="type">
<span class="param-type"><a href="Rule.html">Rule</a></span>
</td>
<td class="description last"><p>The rule to add.</p>
<ul>
<li>Since a pointer to the rule is stored, the rule must never be deleted, e.g. a static variable.</li>
</ul></td>
</tr>
</tbody>
</table>
<h4 class="name" id="isDifferent"><span class="type-signature"></span>isDifferent<span class="signature">(subject_1, predicate_1, object_1, subject_2, predicate_2, object_2)</span><span class="type-signature"> → {bool}</span></h4>
<dl class="details">
<dt class="tag-description">Description:</dt>
<dd class="tag-description"><ul class="dummy"><li><p>Checks if two triples are distinguishable.</p>
<ul>
<li>This method is to be overloaded to implement a specific difference criterion.</li>
<li>The default implementations calculates the conjunction:</li>
</ul>
<p> `(subject_1 . subject_2) ^ (predicate_1 . predicate_2) ^ (object_1 . object_2)`</p>
and considers the triples as different if `tau < sigma` for the obtained belief.
- Then, it considers the system as incremental and if not different,
checks if the 1st triplet brings more information,
i.e. if `tau_1 > tau_2 + 2 sigma`, `tau_i` being the product of the triple elements tau values..</li></ul></dd>
</dl>
<h5 class="h5-parameters">Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>subject_1</code></td>
<td class="type">
<span class="param-type"><a href="Symbol.html">Symbol</a></span>
</td>
<td class="description last"><p>The 1st triple subject.</p></td>
</tr>
<tr>
<td class="name"><code>predicate_1</code></td>
<td class="type">
<span class="param-type"><a href="Symbol.html">Symbol</a></span>
</td>
<td class="description last"><p>The 1st triple predicate.</p></td>
</tr>
<tr>
<td class="name"><code>object_1</code></td>
<td class="type">
<span class="param-type"><a href="Symbol.html">Symbol</a></span>
</td>
<td class="description last"><p>The 1st triple object.</p></td>
</tr>
<tr>
<td class="name"><code>subject_2</code></td>
<td class="type">
<span class="param-type"><a href="Symbol.html">Symbol</a></span>
</td>
<td class="description last"><p>The 2nd triple subject.</p></td>
</tr>
<tr>
<td class="name"><code>predicate_2</code></td>
<td class="type">
<span class="param-type"><a href="Symbol.html">Symbol</a></span>
</td>
<td class="description last"><p>The 2nd triple predicate.</p></td>
</tr>
<tr>
<td class="name"><code>object_2</code></td>
<td class="type">
<span class="param-type"><a href="Symbol.html">Symbol</a></span>
</td>
<td class="description last"><p>The 2nd triple object.</p></td>
</tr>
</tbody>
</table>
<h5 class="h5-returns">Returns:</h5>
<div class="param-desc">
<p>Returns true if the two triples are distinguishable, or if the 1st triplet brings more information.</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">bool</span>
</dd>
</dl>
<h4 class="name" id="apply"><span class="type-signature"></span>apply<span class="signature">(triples, incoming)</span><span class="type-signature"></span></h4>
<dl class="details">
<dt class="tag-description">Description:</dt>
<dd class="tag-description"><ul class="dummy"><li><p>Applies recursively the rules on a set of incoming triples given a set of reference triples.</p>
<ul>
<li>The relational map reference is enriched by the incoming triples and all their infered consequences.</li>
</ul></li></ul></dd>
</dl>
<h5 class="h5-parameters">Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>triples</code></td>
<td class="type">
<span class="param-type"><a href="RelationalMap.html">RelationalMap</a></span>
</td>
<td class="description last"><p>A relational map reference with triples for rule application with the given triple.</p></td>
</tr>
<tr>
<td class="name"><code>incoming</code></td>
<td class="type">
<span class="param-type"><a href="RelationalMap.html">RelationalMap</a></span>
</td>
<td class="description last"><p>A relational map reference with triples incoming the inference mechanism.</p></td>
</tr>
</tbody>
</table>
</article>
</section>
</div>
<br class="clear">
<footer>
<div style='float: right;font-style: italic;'>2025-10-28 version.</div>
</footer>
<script>prettyPrint();</script>
<script src="scripts/polyfill.js"></script>
<script src="scripts/linenumber.js"></script>
<script src="scripts/search.js" defer></script>
<script src="scripts/collapse.js" defer></script>
</body>
</html>
Computing file changes ...