I set a rule: if a planet travels around a celestial, then the celestial is a star. But I got an error "caused by: java.lang.UnsupportedOperationException: Builtin using unsafe variables: [round([?p, ?s])]". Following is the code. It is my first time to use SWRL. I thought it was as easy as first-order logic, or Prolog. But I failed.
Did I make any mistake?
test = get_ontology("
http://test.org/test.owl")
with test:
class Celestial(Thing):
pass
class round(Celestial >> Celestial):
pass
class Planet(Celestial):
pass
class Star(Celestial):
pass
earth = Planet('earth')
sun = Celestial('sun')
earth.round = [sun]
rule = Imp()
# Planet.is_a.append(round.only(Star))
rule.set_as_rule("Planet(?p), Celestial(?s), round(?p, ?s) -> Star(?s)")
close_world(test)
sync_reasoner_pellet(infer_property_values = True, infer_data_property_values = True)
print(sun.INDIRECT_is_instance_of) # I hope that I can get Star in the list.