1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include "macrovsa.hpp"
#include "time.hpp"
using namespace macrovsa;

/* Experiment corresponding to the (ViƩville & Mercier 2024) draft
 * @param {bool} [with_RDFSS = true] Defines if we add extra RDFSs supplementary inferences.
 * @param {double} [tau_eat = 1] Defines if exact (tau_eat = 1) or approximate (tau_eat = 0.5) inference on eating.
 * @param {String} [trace = "ado"] Level of trace as defined Rules.hpp.
 */
void small_pizza_experiment(double tau_eat = 1, String trace = "ado")
{
  class SomeRules: public Rules {
public:
    SomeRules(String trace) : Rules(0, trace) {
      // 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()
             output.add(*subject_1, tau, "rdf:type", *object_2);
             );
    }
  }
  someRules(trace);

  // Defines incoming facts
  RelationalMap incoming("Luigi pizza incoming facts");
  incoming.add("Luigi", tau_eat, "eats", "thisPizza");
  incoming.add("eats", "rdfs:domain", "Person");
  incoming.add("eats", "rdfs:range", "Food");
  incoming.add("thisPizza", "rdf:type", "MagheritaPizza");
  incoming.add("thisPizza", "hasTopping", "thisMozzarella");
  incoming.add("MagheritaPizza", "rdfs:subClassOf", "Pizza");
  incoming.add("Pizza", "rdfs:subClassOf", "Food");
  incoming.add("hasTopping", "rdfs:subPropertyOf", "hasIngredient");
  incoming.add("MagheritaPizza", "hasTopping", "Tomato");

  // Runs inference
  RelationalMap infered("Luigi pizza infered facts");
  aidesys::now(false, false);
  someRules.apply(infered, incoming);
  printf("Calculus duration in msec : %.3f\n", aidesys::now(false, true));
  printf("%s\n", infered.asString().c_str());
}
int main()
{
  small_pizza_experiment(1, "ado");
  small_pizza_experiment(0.5, "");
  return 0;
}