Rules

Rules

new Rules(maximalDepthopt, traceopt, traceOutputopt)

Description:
  • Implements a VSA based inference mechanism.

    • Inference rules are typically defined using such macro construction:
     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;
    

    where Rule_1, Rule_2 and Rule_3 allows to specifies rules of arity 1, 2 ou 3, with as syntax of the form:

    Rule_i(ruleName, getTau_return_expression, setOutput_add_instruction);
    
Parameters:
Name Type Attributes Default Description
maximalDepth uint <optional>
0

Maximal number of recursion,

  • i.e.,of reintroducing produced rule output as incoming input, 0 means unbounded.
trace String <optional>
"ado"

Defines the inference trace log, using a combination of chars.

  • 'a' : Dumps applied valid rules application.
  • 'u' : Dumps unapplied invalid rules application.
  • 'd' : Dumps the depth value when starting the inference.
  • 'i' : Dumps incoming triples before each recursion step.
  • 'o' : Dumps output triples produces a each recursion step.
traceOutput String <optional>
"stdout"

defines the trace target:

  • "stdout": The stdout during the inference mechanism.
  • filename : A filename.log file saves at the end of the inference mechanism.

Methods

add(rule)

Description:
  • Adds a new rule to the mechanism.

    • A typical manual construction of a rule is of the form:
    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);
    
Parameters:
Name Type Description
rule Rule

The rule to add.

  • Since a pointer to the rule is stored, the rule must never be deleted, e.g. a static variable.

isDifferent(subject_1, predicate_1, object_1, subject_2, predicate_2, object_2) → {bool}

Description:
  • Checks if two triples are distinguishable.

    • This method is to be overloaded to implement a specific difference criterion.
    • The default implementations calculates the conjunction:

    `(subject_1 . subject_2) ^ (predicate_1 . predicate_2) ^ (object_1 . object_2)`

    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..
Parameters:
Name Type Description
subject_1 Symbol

The 1st triple subject.

predicate_1 Symbol

The 1st triple predicate.

object_1 Symbol

The 1st triple object.

subject_2 Symbol

The 2nd triple subject.

predicate_2 Symbol

The 2nd triple predicate.

object_2 Symbol

The 2nd triple object.

Returns:

Returns true if the two triples are distinguishable, or if the 1st triplet brings more information.

Type
bool

apply(triples, incoming)

Description:
  • Applies recursively the rules on a set of incoming triples given a set of reference triples.

    • The relational map reference is enriched by the incoming triples and all their infered consequences.
Parameters:
Name Type Description
triples RelationalMap

A relational map reference with triples for rule application with the given triple.

incoming RelationalMap

A relational map reference with triples incoming the inference mechanism.