# SWRL rule question

**URL:** <https://community.stardog.com/t/swrl-rule-question/751>\
**Category:** Support\
**Created:** [December 30, 2017, 11:29pm UTC](https://community.stardog.com/t/swrl-rule-question/751 "2017-12-30T23:29:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![johan.kumps](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/johan.kumps/32/201_2.png) [@johan.kumps](https://community.stardog.com/u/johan.kumps)\
**Post date:** [December 30, 2017, 11:29pm UTC](https://community.stardog.com/t/swrl-rule-question/751/1 "2017-12-30T23:29:19Z")

</div>

Hi all,

I have a question about SWRL. I want to use the rule in Stardog.

Let consider individual A having a hasObservation object property pointing to two individuals B and C. The rule should add a property to A in case the hasValue property of B AND C meets some criteria.

Any hints?

Thanks,

Kind regards,

---

<div class="post-metadata">

**Author:** ![lorenz\_b](https://avatars.discourse-cdn.com/v4/letter/l/d78d45/32.png) [@lorenz\_b](https://community.stardog.com/u/lorenz_b)\
**Post date:** [December 31, 2017, 8:46am UTC](https://community.stardog.com/t/swrl-rule-question/751/2 "2017-12-31T08:46:36Z")

</div>

Why not starting with writing the rule in abstract syntax down?

`hasObservation(?x, ?y), hasObservation(?x, ?z), notEquals(?y, ?z) , $THE_OTHER_CONDITIONS_HERE -> $PROPERTY_TO_ADD(?x, $VALUE_TO_ADD)`

Afterwarss, you can convert into the desired rule language.

---

<div class="post-metadata">

**Author:** ![johan.kumps](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/johan.kumps/32/201_2.png) [@johan.kumps](https://community.stardog.com/u/johan.kumps)\
**Post date:** [December 31, 2017, 2:17pm UTC](https://community.stardog.com/t/swrl-rule-question/751/3 "2017-12-31T14:17:41Z")

</div>

Thanks for the hint. It’s working, both in Protege as well as via the SparQL interface of Stardog.

Kind regards,  
Johan,

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/2X/e/ed66b48a616f505106a4acde3c9cee7e6da9bc67.svg) [@system](https://community.stardog.com/u/system)\
**Post date:** [January 14, 2018, 2:18pm UTC](https://community.stardog.com/t/swrl-rule-question/751/4 "2018-01-14T14:18:07Z")

</div>

Closed on January 14, 2018, 2:18pm UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
