Failing inference rule?

1 view
Skip to first unread message

F. Andy Seidl

unread,
Dec 5, 2009, 6:01:07 PM12/5/09
to ontopia
Are inference rules always non-failing clauses?

I was trying to write a rule to test for an object's type to determine
ensure that it was either a specific type or an instance of that
specific type. I tried variations of rules like this one:

typed($object_, $type_) :- {
type($object_, $type_) |
type($object_, $t), instance-of($t, $type_)
}.

However, that rule never seems fail, even when the object's type is
completely unrelated to the specified type.

Lars Marius Garshol

unread,
Dec 6, 2009, 3:47:36 AM12/6/09
to ont...@googlegroups.com

* F. Andy Seidl
>
> Are inference rules always non-failing clauses?

No. They should behave like ordinary queries.
I can't see anything wrong with the rule as written. Could you give some examples of how it misbehaves?

--Lars M.
http://www.garshol.priv.no/tmphoto/
http://www.garshol.priv.no/blog/

F. Andy Seidl

unread,
Dec 6, 2009, 9:38:17 AM12/6/09
to ontopia
Here's a simple test case.

This query, as expected, returns on results:

--------------------------------------------------
topic($TOPIC),
instance-of($TOPIC, $TOPIC)?
--------------------------------------------------

This query, which should be functionaly identical (I think), returns
every topic:

--------------------------------------------------
my-instance-of($A, $B) :- { instance-of($A, $B) }.

topic($TOPIC),
my-instance-of($TOPIC, $TOPIC)?
--------------------------------------------------

I testing his in the omnigator Query page using ontopia-5.0.2.

Lars Marius Garshol

unread,
Dec 6, 2009, 10:16:35 AM12/6/09
to ont...@googlegroups.com

* F. Andy Seidl
>
> This query, which should be functionaly identical (I think), returns
> every topic:
>
> --------------------------------------------------
> my-instance-of($A, $B) :- { instance-of($A, $B) }.
>
> topic($TOPIC),
> my-instance-of($TOPIC, $TOPIC)?
> --------------------------------------------------

The problem here is that you've wrapped the rule body in {}, which means that this is the same as

topic($TOPIC),
{ instance-of($TOPIC, $TOPIC) }?

In other words, you've turned the rule into a non-failing clause. I thought this might be the problem, but in your first posting you had a rule where the body was an OR clause, so this didn't apply there.

F. Andy Seidl

unread,
Dec 6, 2009, 12:02:19 PM12/6/09
to ontopia
Ah, pilot error. Thanks! I thought the syntax of an inference rule
required the { ... } for the rule body. Too many decades writing
Java, C++, and C, I guess. ;-)

On Dec 6, 10:16 am, Lars Marius Garshol <lar...@garshol.priv.no>
wrote:

Lars Marius Garshol

unread,
Dec 6, 2009, 12:40:04 PM12/6/09
to ont...@googlegroups.com

* F. Andy Seidl
>
> Ah, pilot error. Thanks! I thought the syntax of an inference rule
> required the { ... } for the rule body. Too many decades writing
> Java, C++, and C, I guess. ;-)

You're not the first to make this mistake, so I added a section to the tolog tutorial about it:
http://code.google.com/p/ontopia/source/detail?r=717
Reply all
Reply to author
Forward
0 new messages