must have same value error. Ontology: Relationship property with Relationship to Other Properties

48 views
Skip to first unread message

Stefan Verweij

unread,
Sep 18, 2019, 9:46:44 AM9/18/19
to TopBraid Suite Users
Hi,

I am working with ontologies of the TopBraid EDG package. My ontology has three classes "a", " b" and "results". Both the classes "a" and "b" have a relationship property that links to "results" called "a has results" and "b has results". The class "results" itself has multiple attribute properties all being a certain type of result (that has to be a decimal).

Now the relationship "b has results" has a Relationship to Other Properties constraint that states it has to be equal to the relationship property "a has results". 
When I make an instance for "results" which is something like:

test_result:
Other Properties
result1:       0.09
result2:       0.94
result3:       0.62
label:          test_result
type:           result
----------------------------------
Incoming References
a has results      a
(inverse)
b has results      b
(inverse)


and an instance for both "a" and "b" which links to the same instance for result: test_result, which looks something like this:

instance_a:
Other Properties
a has results   test_result
label:               instance_a
type:                a
 
and instance_b:
Other Properties
b has results   test_result
label:               instance_b
type:                b

 
Now when I try to test this with the Problems and Suggestions option I get this error that says:
 
Must have same values as a has result
Resource:     b                                         
Property:       b has result                        
Value:            test_result                           

But it links to the same instance (value), so why does this error appear? 
Hope someone can help me out!

All the best,
Stefan

Holger Knublauch

unread,
Sep 18, 2019, 9:17:12 PM9/18/19
to topbrai...@googlegroups.com

Hi Stefan,

if you use sh:equals, which is defined here:

https://www.w3.org/TR/shacl/#EqualsConstraintComponent

it means that the sets of values of two properties must be identical, at the same subject.

In your data it seems that instance_b doesn't have the same values for a has results and b has results.

You probably want to express something else?

Holger

PS: it took me a while to "parse" your example. For future postings, maybe consider sending the RDF/Turtle source code exported from EDG to avoid ambiguities.

--
You received this message because you are subscribed to the Google Groups "TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to topbraid-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/topbraid-users/cae52abd-1dc0-4e44-b78e-5ae3e0f0176c%40googlegroups.com.

Stefan Verweij

unread,
Sep 19, 2019, 3:10:31 AM9/19/19
to TopBraid Suite Users
Hi Holger,

Thanks for the fast response. What do you mean with same subject in the sets of values of two properties? Do you mean that the class (=subject?) of these two properties has to be the same (as in the example of the link class 'name' has properties 'firstname' and 'givenname' which should be equal, thus if you have another class 'person' with the property 'nickname' you cannot state this property 'nickname' has to be equal to the property 'firstname' of class 'name'? And this last thing is basically what I would like to express.

PS: sorry, how silly of me. Here is Turtle code:
For the three classes:
a
test:a
  rdf:type owl:Class ;
  rdf:type sh:NodeShape ;
  rdfs:label "a" ;
  rdfs:subClassOf owl:Thing ;
  sh:property test:a_has_result ;
.

b
test:b
  rdf:type owl:Class ;
  rdf:type sh:NodeShape ;
  rdfs:label "b" ;
  rdfs:subClassOf owl:Thing ;
  sh:property test:b_has_result ;
.


test:result
  rdf:type owl:Class ;
  rdf:type sh:NodeShape ;
  rdfs:label "result" ;
  rdfs:subClassOf owl:Thing ;
  sh:property test:result-has_result1 ;
  sh:property test:result-has_result2 ;
  sh:property test:result-has_result3 ;
.

For the two properties:
a_has_result:
test:a-a_has_result
  rdf:type sh:PropertyShape ;
  sh:path test:a_has_result ;
  sh:class test:result ;
  sh:maxCount 1 ;
  sh:minCount 1 ;
.

b_has_result:
test:b-b_has_result
  rdf:type sh:PropertyShape ;
  sh:path test:b_has_result ;
  sh:class test:result ;
  sh:description "Each b has result. The result should be equal to that of a." ;
  sh:equals test:a_has_result ;
  sh:maxCount 1 ;
  sh:minCount 1 ;
.


For the instances:
instance_a:
test:a91bea78-2c0b-11b2-809c-005056bba47c
  rdf:type test:a ;
  test:a_has_result test:bee2c6e0-2c15-11b2-80f2-005056bba47c ;
  rdfs:label "instance_a" ;
.

instance_b:
test:bee2c6d6-2c15-11b2-80f2-005056bba47c
  rdf:type test:b ;
  test:b_has_result test:bee2c6e0-2c15-11b2-80f2-005056bba47c ;
  rdfs:label "instance_b" ;
.
for instance test_result:
test:bee2c6e0-2c15-11b2-80f2-005056bba47c
  rdf:type test:result ;
  test:has_result1 0.06 ;
  test:has_result2 0.42 ;
  test:has_result3 0.56 ;
  rdfs:label "test_result" ;
.


Op donderdag 19 september 2019 03:17:12 UTC+2 schreef Holger Knublauch:

Richard Cyganiak

unread,
Sep 19, 2019, 5:00:44 AM9/19/19
to topbrai...@googlegroups.com
Stefan,

sh:equals requires that two properties of the same instance have the same values.

What you want is two properties of two different instances having the same values.

Richard



--
You received this message because you are subscribed to the Google Groups "TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to topbraid-user...@googlegroups.com.

Stefan Verweij

unread,
Sep 19, 2019, 5:05:18 AM9/19/19
to TopBraid Suite Users
Thanks for clarifying, is what I want even possible?

Op donderdag 19 september 2019 11:00:44 UTC+2 schreef Richard Cyganiak:

Richard Cyganiak

unread,
Sep 19, 2019, 6:09:01 AM9/19/19
to topbrai...@googlegroups.com
You could amend the property shapes for a_has_result and b_has_result and set their sh:node to something like test:CompleteResultShape. The intention being that the result of any instance of a or b needs to have that shape.

Then define a new NodeShape test:CompleteResultShape that has two property constraints with sh:inversePaths; one for a_has_result and one for b_has_result; both with a minCount of 1. This would mean a result only has the shape test:CompleteResultShape if it has an incoming edge from both an instance of a and an instance of b.

As an effect, if there is any instance of a whose result isn't also the result of an instance of b, then there would be a validation error. I think that's what you want.

So, something like:

test:CompleteResultShape
  rdf:type sh:NodeShape ;
  sh:property [
      sh:path [
          sh:inversePath test:a_has_result ;

        ] ;
      sh:maxCount 1 ;
      sh:minCount 1 ;
    ] ;
  sh:property [
      sh:path [
          sh:inversePath test:b_has_result ;
        ] ;

      sh:maxCount 1 ;
      sh:minCount 1 ;
    ] ;
.
test:a
  rdf:type owl:Class ;
  rdf:type sh:NodeShape ;
  rdfs:label "a" ;
  sh:property [
      rdf:type sh:PropertyShape ;
      sh:path test:aHasResult ;
      sh:class test:Result ;
      sh:name "a has result" ;
      sh:node shacl-test:CompleteResultShape ;
    ] ;
.

And similarly for test:b.

Richard


--
You received this message because you are subscribed to the Google Groups "TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to topbraid-user...@googlegroups.com.

Stefan Verweij

unread,
Sep 19, 2019, 7:36:57 AM9/19/19
to TopBraid Suite Users
Learning something new every day. You are amazing, thanks a lot!

Stefan

Op donderdag 19 september 2019 12:09:01 UTC+2 schreef Richard Cyganiak:
On 19 Sep 2019, at 10:05, Stefan Verweij <stefan...@wur.nl> wrote:

Thanks for clarifying, is what I want even possible?

Op donderdag 19 september 2019 11:00:44 UTC+2 schreef Richard Cyganiak:
Stefan,

sh:equals requires that two properties of the same instance have the same values.

What you want is two properties of two different instances having the same values.

Richard

--
You received this message because you are subscribed to the Google Groups "TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to topbrai...@googlegroups.com.

Stefan Verweij

unread,
Sep 20, 2019, 4:32:27 AM9/20/19
to TopBraid Suite Users
Hi Richard (or others),

I am currently playing around with these shape constraints and I noticed that while it is stated in the shape the property 'b_has_result' has to occur at least one time (minCount 1) it does not raise an error if the property is absent.
Once the property occurs one time however, it raises the error that is should be the same to 'a_has_result' so that seems to work, but when I tried to add another instance for b (instance_b_2), something like:

test:instance_b_2
  rdf:type test:b ;
  test:notes "this instance should also be equal to a_has_result" ;
  test:b_has_result test:test_result ;
  rdfs:label "instance_b_2" ;
.

it results in the error Value does not have shape derived_data_well_shape. While it is exactly the same instance as 'instance_b' besides the different labeling.
Do I have to adjust the CompleteResultShape somehow??


Op donderdag 19 september 2019 12:09:01 UTC+2 schreef Richard Cyganiak:
You could amend the property shapes for a_has_result and b_has_result and set their sh:node to something like test:CompleteResultShape. The intention being that the result of any instance of a or b needs to have that shape.
On 19 Sep 2019, at 10:05, Stefan Verweij <stefan...@wur.nl> wrote:

Thanks for clarifying, is what I want even possible?

Op donderdag 19 september 2019 11:00:44 UTC+2 schreef Richard Cyganiak:
Stefan,

sh:equals requires that two properties of the same instance have the same values.

What you want is two properties of two different instances having the same values.

Richard

--
You received this message because you are subscribed to the Google Groups "TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to topbrai...@googlegroups.com.

Richard Cyganiak

unread,
Sep 20, 2019, 5:37:38 AM9/20/19
to topbraid-users list

On 20 Sep 2019, at 09:32, Stefan Verweij <stefan....@wur.nl> wrote:

Hi Richard (or others),

I am currently playing around with these shape constraints and I noticed that while it is stated in the shape the property 'b_has_result' has to occur at least one time (minCount 1) it does not raise an error if the property is absent.

You are talking about the CompleteResult shape? That shape's definition includes: “To be a CompleteResult, it is necessary to have minimum 1 incoming b_has_result edge.” But we have not said anywhere that every result needs to be a CompleteResult, so having an incomplete result is in itself not an error.

Once the property occurs one time however, it raises the error that is should be the same to 'a_has_result' so that seems to work, but when I tried to add another instance for b (instance_b_2), something like:

test:instance_b_2
  rdf:type test:b ;
  test:notes "this instance should also be equal to a_has_result" ;
  test:b_has_result test:test_result ;
  rdfs:label "instance_b_2" ;
.

it results in the error Value does not have shape derived_data_well_shape. While it is exactly the same instance as 'instance_b' besides the different labeling.
Do I have to adjust the CompleteResultShape somehow??

What is derived_data_well_shape? It's a shape/class you must have defined, and you have not mentioned before.

Richard



To unsubscribe from this group and stop receiving emails from it, send an email to topbraid-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/topbraid-users/b9e9f516-4448-4ded-96c2-373a40cfbf1b%40googlegroups.com.

Stefan Verweij

unread,
Sep 20, 2019, 6:02:53 AM9/20/19
to TopBraid Suite Users
You are talking about the CompleteResult shape? That shape's definition includes: “To be a CompleteResult, it is necessary to have minimum 1 incoming b_has_result edge.” But we have not said anywhere that every result needs to be a CompleteResult, so having an incomplete result is in itself not an error.
Ahh I see, thanks for pointing out. Many thanks for this sentence by the way!!! --> “To be a CompleteResult, it is necessary to have minimum 1 incoming b_has_result edge.” <-- the CompleteResultShape also had a maxCount 1, which didn't let me add any other instances (b_has_result_2) with the same property values if I am understanding this all correctly

What is derived_data_well_shape? It's a shape/class you must have defined, and you have not mentioned before.
I am working with quite some abstract and sometimes illogical names in my real ontology, hence I am also working with a separate simulation ontology (with classes a, b and result). This error was taken from the real ontology Value does not have shape derived_data_well_shape , but in essence can be read as Value does not have shape CompleteResultShape


Richard Cyganiak

unread,
Sep 20, 2019, 6:07:57 AM9/20/19
to topbrai...@googlegroups.com
I think you've figured it out -- the error is likely caused by the maxCount 1 on CompleteResultShape/derived_data_well_shape. After adding b_has_result_2, the result has two incoming b_has_result edges, and that violates the maxCount 1 constraint.

Richard


--
You received this message because you are subscribed to the Google Groups "TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to topbraid-user...@googlegroups.com.

Stefan Verweij

unread,
Sep 24, 2019, 8:01:39 AM9/24/19
to TopBraid Suite Users
I would like to dive a bit deeper. I want to separate the results into the value and the unit e.g. value = 1.04 and the unit is kilogram. I made a constraint where the units for class a and b should be the same units (so similar as previously described - and solved - problem). The difference for this case however is that instances for b can have different values for those units (where in the previous case both value and unit should be the same), so it would look something like this:

test:a
  rdf:type owl:Class ;
  rdf:type sh:NodeShape ;
  rdfs:label "a" ;
  rdfs:subClassOf owl:Thing ;
  sh:property test:a_has_units ;
.

test:b
  rdf:type owl:Class ;
  rdf:type sh:NodeShape ;
  rdfs:label "b" ;
  rdfs:subClassOf owl:Thing ;
  sh:property test:b_has_units ;
  sh:property test:b_has_values_for_units ;
.

Where a_has_units = b_has_units and b_has_values_for_units should contain decimals linked to those units. So it would look something like this for the instances:

instance test_units:
test:bee2c6e0-2c15-11b2-80f2-005056bba47c
  rdf:type test:unit ;
  test:has_unit1 kilogram ;
  test:has_unit2 deciliter ;
  test:has_unit3 meter ;
  rdfs:label "test_units" ;
.

instance_a:
test:a91bea78-2c0b-11b2-809c-005056bba47c
  rdf:type test:a ;
  test:a_has_units test:bee2c6e0-2c15-11b2-80f2-005056bba47c ;
  rdfs:label "instance_a" ;
.

instance_b:
test:bee2c6d6-2c15-11b2-80f2-005056bba47c
  rdf:type test:b ;
  test:b_has_unit test:bee2c6e0-2c15-11b2-80f2-005056bba47c ;
  test:b_has_values_for_units test:bee2c6e0-2c15-11b2-80f2-005056bba50c ;
  rdfs:label "instance_b" ;
.

instance test_values_for_units:
test:bee2c6e0-2c15-11b2-80f2-005056bba50c
  rdf:type test:value ;
  test:has_value1 20.5 ; (note this should somehow indicate/link to kilogram)
  test:has_value2 40.0 ; (note this should somehow indicate/link to deciliter)
  test:has_value3 3.0 ; (note this should somehow indicate/link to meter)
  rdfs:label "test_values_for_units" ;
.

The reason I would like to have such a structure is that b can have multiple instances with different values, but these instances should always contain the same type of units that are found in the instance for a and can not have more values than there are units. Let's write the case in noncode-format:

a has:
- kilogram
- deciliter
- meter

b1 has:
- 1.04 kilogram
- 3.00 deciliter
- 0.58 meter

b2 has:
- 20 kilogram
- 40 deciliter
- 3 meter

b3 has: (when validating this should raise two errors: the units differ from a and there is one extra value)
- 11.2 kilogram
- 3.1 deciliter
- 0.95 nanometer
- 2.23 meter

Could any of you think of solutions for this? 
Reply all
Reply to author
Forward
0 new messages