# How to make Stardog Rules working?

**URL:** <https://community.stardog.com/t/how-to-make-stardog-rules-working/2632>\
**Category:** Support\
**Created:** [August 5, 2020, 1:25am UTC](https://community.stardog.com/t/how-to-make-stardog-rules-working/2632 "2020-08-05T01:25:46Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![crapthings](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/crapthings/32/686_2.png) [@crapthings](https://community.stardog.com/u/crapthings)\
**Post date:** [August 5, 2020, 1:25am UTC](https://community.stardog.com/t/how-to-make-stardog-rules-working/2632/1 "2020-08-05T01:25:46Z")

</div>

i've tried to add these in to archetype schema

```auto
@prefix rule: <tag:stardog:api:rule:> .
@prefix skosextends: <http://www.w3.org/2004/02/skos/skos-extends#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .

skosextends:coordinateOf a owl:ObjectProperty ;
  owl:inverseOf skosextends:hasCoordinate ;
  rdfs:subPropertyOf skos:semanticRelation ;
  rdfs:domain skos:Concept ;
  rdfs:range rdf:List .

skosextends:hasCoordinate a owl:ObjectProperty ;
  owl:inverseOf skosextends:coordinateOf ;
  rdfs:subPropertyOf skos:semanticRelation ;
  rdfs:domain skos:List ;
  rdfs:range rdf:Concept .

skosextends:hasCoordinatePart a owl:ObjectProperty ;
  rdfs:subPropertyOf skos:semanticRelation ;
  rdfs:domain skos:Concept ;
  rdfs:range rdf:Concept .

IF {
  ?concept skosextends:coordinateOf ?list .
  ?list rdf:rest*/rdf:first ?conceptIRI .
} THEN {
  ?concept skosextends:hasCoordinatePart ?conceptIRI .
}

```

but the rule doesn't seems to work

my reasoning type is set to SL

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/1X/5226e8f23df65c7737e95653e8c5cd77c1a6dfb1.png)

you can see the inverse infer "hasCoordinate" is working, but not IF THEN

---

<div class="post-metadata">

**Author:** ![jess](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/jess/32/10_2.png) [@jess](https://community.stardog.com/u/jess)\
**Post date:** [August 5, 2020, 1:50am UTC](https://community.stardog.com/t/how-to-make-stardog-rules-working/2632/2 "2020-08-05T01:50:36Z")

</div>

Hey can you share the query plan please? (in text format, not json)

---

<div class="post-metadata">

**Author:** ![crapthings](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/crapthings/32/686_2.png) [@crapthings](https://community.stardog.com/u/crapthings)\
**Post date:** [August 5, 2020, 1:58am UTC](https://community.stardog.com/t/how-to-make-stardog-rules-working/2632/3 "2020-08-05T01:58:43Z")

</div>

```auto
SELECT
      (stardog:functions:localname(?conceptIRI) as ?conceptId)
      ?conceptLabel
    WHERE {
      ?concept skosextends:coordinateOf ?list .
      ?list rdf:rest*/rdf:first ?conceptIRI .
      ?conceptIRI skosxl:prefLabel/skosxl:literalForm ?conceptLabel .
    }
    ORDER BY ASC(?conceptLabel)

```

```auto
Distinct [#1]
`─ Projection(?conceptId, ?conceptLabel) [#1]
   `─ OrderBy(ASC(?conceptLabel)) [#1]
      `─ Bind(localname(?conceptIRI) AS ?conceptId) [#1]
         `─ MergeJoin(?hfmdgnuq) [#1]
            +─ Scan[PSOC](?hfmdgnuq, <http://www.w3.org/2008/05/skos-xl#literalForm>, ?conceptLabel) [#1]
            `─ Sort(?hfmdgnuq) [#1]
               `─ MergeJoin(?conceptIRI) [#1]
                  +─ Scan[PSOC](?conceptIRI, <http://www.w3.org/2008/05/skos-xl#prefLabel>, ?hfmdgnuq) [#1]
                  `─ Sort(?conceptIRI) [#1]
                     `─ MergeJoin(?bxrkqwcl) [#1]
                        +─ Scan[PSOC](?bxrkqwcl, rdf:first, ?conceptIRI) [#1]
                        `─ Sort(?bxrkqwcl) [#3]
                           `─ MergeJoin(?list) [#3]
                              +─ Scan[PO_NOC](_, <http://www.w3.org/2004/02/skos/skos-extends#>, ?list) [#1]
                              `─ PropertyPath(?list -> ?bxrkqwcl, minLength=0, sorted by=?list) [#551]
                                 `─ Scan[PSOC](?list, rdf:rest, ?bxrkqwcl) [#1]

```

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/1X/31d4f30db09a32b521e9db345c820deae46b4b05.png)

```auto
SELECT *
WHERE {
    ?s ?p ?o .
    FILTER (?o NOT IN (owl:Thing)) .
}

```

```auto
Distinct [#97K]
`─ Projection(?s, ?p, ?o) [#97K]
   `─ Filter(?o != owl:Thing) [#97K]
      `─ Property(?s, ?p, ?o)

```

---

<div class="post-metadata">

**Author:** ![crapthings](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/crapthings/32/686_2.png) [@crapthings](https://community.stardog.com/u/crapthings)\
**Post date:** [August 5, 2020, 2:10am UTC](https://community.stardog.com/t/how-to-make-stardog-rules-working/2632/4 "2020-08-05T02:10:16Z")

</div>

weird

after fixing typo

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/1X/165b0bc16edf4c53b08aa4081f78d02d48d620a8.png)

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/1X/a06a8d190eaf590fe0ae76131dd4370331a6b5ec.png)

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/1X/687f402d19f1f8f9b27d69849e03ab0f32c6e475.png)

the inverse infer hasCoordinate are gone

---

<div class="post-metadata">

**Author:** ![crapthings](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/crapthings/32/686_2.png) [@crapthings](https://community.stardog.com/u/crapthings)\
**Post date:** [August 5, 2020, 2:16am UTC](https://community.stardog.com/t/how-to-make-stardog-rules-working/2632/5 "2020-08-05T02:16:23Z")

</div>

this is the archetype that used in this post

> **[GitHub - crapthings/stardog-archetypes-extends](https://github.com/crapthings/stardog-archetypes-extends)**
>
> Contribute to crapthings/stardog-archetypes-extends development by creating an account on GitHub.

```auto
stardog-admin db create -o database.archetypes="dcterms,skos-inline,skosxl,skosthes,uneskos,skosextends" -n app

```

```auto
INSERT DATA {
    :otherconcept1 a skos:Concept .
    :otherconcept2 a skos:Concept .
    :someconcept a skos:Concept .
    :someconcept skosextends:coordinateOf (:otherconcept1 :otherconcept2)
}

```

some data

---

<div class="post-metadata">

**Author:** ![jess](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/jess/32/10_2.png) [@jess](https://community.stardog.com/u/jess)\
**Post date:** [August 5, 2020, 2:26am UTC](https://community.stardog.com/t/how-to-make-stardog-rules-working/2632/6 "2020-08-05T02:26:05Z")

</div>

> [@crapthings](#):
>
> `skosextends:hasCoordinatePart`

Can you share the query plan for just `select * { ?s skosextends:hasCoordinatePart ?o }`?

---

<div class="post-metadata">

**Author:** ![crapthings](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/crapthings/32/686_2.png) [@crapthings](https://community.stardog.com/u/crapthings)\
**Post date:** [August 5, 2020, 2:27am UTC](https://community.stardog.com/t/how-to-make-stardog-rules-working/2632/7 "2020-08-05T02:27:21Z")

</div>

> [@jess](#):
>
> select \* { ?s skosextends:hasCoordinatePart ?o }

```auto
Distinct [#1]
`─ Projection(?s, ?o) [#1]
   `─ Empty [#1]

```

---

<div class="post-metadata">

**Author:** ![jess](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/jess/32/10_2.png) [@jess](https://community.stardog.com/u/jess)\
**Post date:** [August 5, 2020, 2:42am UTC](https://community.stardog.com/t/how-to-make-stardog-rules-working/2632/8 "2020-08-05T02:42:21Z")

</div>

I see you have the `*` property path operator used in the rule which is not supported. You should see a message about this in the `stardog.log`.

---

<div class="post-metadata">

**Author:** ![crapthings](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/crapthings/32/686_2.png) [@crapthings](https://community.stardog.com/u/crapthings)\
**Post date:** [August 5, 2020, 2:52am UTC](https://community.stardog.com/t/how-to-make-stardog-rules-working/2632/9 "2020-08-05T02:52:30Z")

</div>

```auto
WARN 2020-08-05 10:49:42,221 [stardog-user-5] com.complexible.stardog.reasoning.rule.RuleExtractor:parseRule(153): Ignoring invalid rule:
 IF {
   ?concept <http://www.w3.org/2004/02/skos/skos-extends#coordinateOf> ?list .
   ?list <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest>*/<http://www.w3.org/1999/02/22-rdf-syntax-ns#first> ?conceptIRI .
}
THEN {
   ?concept <http://www.w3.org/2004/02/skos/skos-extends#hasCoordinatePart> ?conceptIRI .
}

Parse error was: Unsupported operator: PropertyPath

```

oh oh oh okay thanks @jess

and how do i fix warn like this Not a valid SL axiom

```auto
WARN 2020-08-05 10:49:42,185 [stardog-user-5] com.clarkparsia.blackout.ProfileFilterBase:apply(39): Not a valid SL axiom: Range(terms:modified,rdfs:Literal) 
WARN 2020-08-05 10:49:42,186 [stardog-user-5] com.clarkparsia.blackout.ProfileFilterBase:apply(39): Not a valid SL axiom: Range(terms:issued,rdfs:Literal) 
WARN 2020-08-05 10:49:42,186 [stardog-user-5] com.clarkparsia.blackout.ProfileFilterBase:apply(39): Not a valid SL axiom: Range(core:member,or(core:Concept, core:Collection)) 
WARN 2020-08-05 10:49:42,187 [stardog-user-5] com.clarkparsia.blackout.ProfileFilterBase:apply(39): Not a valid SL axiom: Range(ns:term_status,xsd:string) 
WARN 2020-08-05 10:49:42,188 [stardog-user-5] com.clarkparsia.blackout.ProfileFilterBase:apply(39): Not a valid SL axiom: Domain(skos-thes:status,or(core:Concept, skos-xl:Label)) 
WARN 2020-08-05 10:49:42,188 [stardog-user-5] com.clarkparsia.blackout.ProfileFilterBase:apply(39): Not a valid SL axiom: Domain(uneskos:memberOf,or(core:Collection, core:Concept)) 
WARN 2020-08-05 10:49:42,189 [stardog-user-5] com.clarkparsia.blackout.ProfileFilterBase:apply(39): Not a valid SL axiom: SubClassOf(skos-xl:Label,cardinality(skos-xl:literalForm,1,rdfs:Literal)) 
WARN 2020-08-05 10:49:42,190 [stardog-user-5] com.clarkparsia.blackout.ProfileFilterBase:apply(39): Not a valid SL axiom: SubClassOf(skos-thes:CompoundEquivalence,min(skos-thes:plusUse,2,skos-thes:PreferredTerm)) 
WARN 2020-08-05 10:49:42,190 [stardog-user-5] com.clarkparsia.blackout.ProfileFilterBase:apply(39): Not a valid SL axiom: SubClassOf(skos-thes:CompoundEquivalence,cardinality(skos-thes:plusUF,1,skos-thes:SplitNonPreferredTerm)) 

```

---

<div class="post-metadata">

**Author:** ![jess](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/jess/32/10_2.png) [@jess](https://community.stardog.com/u/jess)\
**Post date:** [August 5, 2020, 3:23am UTC](https://community.stardog.com/t/how-to-make-stardog-rules-working/2632/10 "2020-08-05T03:23:57Z")

</div>

You have a couple different issues here:

> [@crapthings](#):
>
> ```auto
> Not a valid SL axiom: Range(terms:modified,rdfs:Literal) 
> Not a valid SL axiom: Range(terms:issued,rdfs:Literal) 
> 
> ```

I don't think Literal is specific enough to infer anything.

> [@crapthings](#):
>
> ```auto
> Not a valid SL axiom: Range(ns:term_status,xsd:string) 
> 
> ```

This is not permitted in Stardog (not sure why). Also not sure why you would require it.

> [@crapthings](#):
>
> ```auto
> Not a valid SL axiom: Range(core:member,or(core:Concept, core:Collection)) 
> Not a valid SL axiom: Domain(skos-thes:status,or(core:Concept, skos-xl:Label)) 
> Not a valid SL axiom: Domain(uneskos:memberOf,or(core:Collection, core:Concept)) 
> 
> ```

"or" is not permitted for domain/range spec in OWL2 RL profile. What are you trying to infer here?

> [@crapthings](#):
>
> ```auto
> Not a valid SL axiom: SubClassOf(skos-xl:Label,cardinality(skos-xl:literalForm,1,rdfs:Literal)) 
> Not a valid SL axiom: SubClassOf(skos-thes:CompoundEquivalence,min(skos-thes:plusUse,2,skos-thes:PreferredTerm)) 
> Not a valid SL axiom: SubClassOf(skos-thes:CompoundEquivalence,cardinality(skos-thes:plusUF,1,skos-thes:SplitNonPreferredTerm)) 
> 
> ```

There are some restrictions on cardinality, esp on the right hand side of these expressions. What are you after here?

---

<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:** [August 19, 2020, 3:24am UTC](https://community.stardog.com/t/how-to-make-stardog-rules-working/2632/11 "2020-08-19T03:24:02Z")

</div>

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