Subject: More on the distinction between $has and $has$a
In a message to the list on Friday about $has statements, I said:
+x/$has/+y does in fact translate into two base graph statements: +x/+y/+x+y and +x+y
In reply Bill asked two questions. The first one was:
But what do you mean by translate? Do you mean (a) that the presence of the first (+x/$has/+y) in the graph implies the other two (+x/+y/+x+y and +x+y) ; (b) that the presence of the other two in the graph implies the first, or (c) both?
What I meant by “translate” should more accurately have been “infer”, i.e., +x/$has/+y in the metagraph infers both +x/+y/+x+y and +x+y . The opposite applies as well. In fact, any one of the following three statements infers the other:
Nick and I also noted that the second statement above infers a fourth statement:
Bill then posed a second question:
I agree with (c) for the +x+y part, but am having trouble with the other. If you say (c) for both then +x/+y/+x+y <=> +x+y. So the subject +ball, predicate +color has the object +ball+color as well as +red? That would mean that a query of +ball/+color would return two answers: +ball+color and +color*red?
My answer is that the subject +ball with predicate +color COULD produce both the objects +ball+color and +red. But the semantics of both answers are clear if we follow the statements and inferences all the way though.
I found it quite instructive to do this, so I offer the following writeup:
Start by substituating +ball for +x and +color for +y in the three statements above. This yields:
So far these are all metagraph statements (T-box statements to use the terminology Bill suggests) about classes. There are no base graph (A-box) statements about instances yet. To do that we would need a fourth statement:
That’s an A-box statement that says in English “a ball has a color of type red”. Note the “has a” in that sentence. The object of an A-box statement is an instance (yes, +red is also a class, but in this context it is an instance of the class +color). That means that the A-box statement +ball/+color/+red is described by the following two T-box statements (or their inverses):
But neither of those is a $has statement. That’s because $has can only be used to describe an arc whose object is a restricted class of that type of arc. In other words, +ball/$has/+color can only be used to create a restricted subclass of +color – specifically the type of color that a ball has. XDI RDF assigns this restricted subclass the XRI +ball+color. About the subclass +ball+color we can infer the following two T-box statements:
The opposite is true for $has$a. $has$a can only be used to describe an arc whose object is an instance of that type of arc. For example, if we say +ball/$has$a/+color, then we actually can’t infer any other T-box statement. All we can do is say that the XDI address +ball/+color is valid and then make A-box statements against an XDI dictionary defining instances of the class +color:
XDI DICTIONARY (T-BOX)
XDI INSTANCES (A-BOX)
But we can’t say
because +small not an instance of +color.
So, to get back to Bill’s question, say we had an XDI document with the following statements in it:
+ball/$has/+color <== same as the statement below
+ball/+color/+ball+color <== same as the statement above
This would be a little strange since the two marked statements mean the same thing, but it would still be valid.
If we then did a $get on +ball/+color, we’d get two answers:
But the metagraph semantics of this answer are clear. +ball+color is not in the dictionary as an instance of +color. So if you did a $get on +ball+color from the same XDI document, you would get:
In other words, for this XDI subject – +ball – there are two ways of expressing that it has the color +red. The first way is direct:
The second way is to subclass +color into +ball+color and then give its value:
Both are valid. Both could appear in the same XDI document, though that would be somewhat redundant. Though the first way is simpler, but there can be good reasons to use the second, i.e., create a restricted subclass. One of them is that you want to express different predicates on the subclass. For example:
Note that +ball+color/+density/+high is very different that +ball/+density/+high
For me, this analysis helps make the distinction between $has and $has$a much clearer. The former asserts a restricted subclass as a new XDI subject. Its object is always a new class. The latter asserts a predicate on the existing XDI subject. Its object is always an instance.
What $has and $has$a have in common, as Nick observed, is that both describe outgoing arcs on an XDI subject, i.e., both are rooted in $has, which is the metagraph predicate representing an outgoing arc. However this brings up a one more very interesting point that Nick and I discussed last Thursday: at first glance it might appear that if an XDI subject has a $has$a, it implies it has a $has. For example, if you saw
then it looks like it implies
However the analysis above – and specifically the inferences between +x+y and +x/+y/+x+y – show why that’s not true. +ball/$has$a/+color only means you can make XDI statements about +ball/+color. It does not infer that the XDI subject +ball+color exists because it doesn’t infer that the statement +ball/+color/+ball+color exists. That’s a separate statement.
Hope this helps.