I would like to create a rule which infers the existence of an entity if it doesn’t already exist. For example, all jedi masters have an apprentice:
apprenticeship sub relation,
relates apprentice,
relates master;
Is there a way to infer that if there is a jedi master, there is always an apprentice, and create the apprentice?
rule masters-always-have-an-apprentice:
when {
$p1 isa person, has status "master"; # There is a jedi master
not {(apprentice: $p2, master $p1) isa apprenticeship;}; # That master has no apprentice
} then {
$p2 isa person, has status "padawan"; # Create an apprentice
(apprentice: $p2, master $p1) isa apprenticeship; # Create an apprenticeship relation
};
I would like it to create both the apprentice and the apprenticeship relation… It appears from the error message that I can only use a rule to create an attribute ownership or a relation.
Is there some way to do this? Or perhaps a workaround?