[tmql-wg] Negation in the different TMQL candidates

Robert Barta rho@bigpond.net.au
Sun, 4 Apr 2004 09:46:42 +1000


On Tue, Mar 30, 2004 at 01:53:25PM +0200, Rani Pinchuk wrote:

> select $player, %is-author where is-author->author != $player;
> 
> Could give:
> 
>   $player   | %is-author
> ------------+------------
> bla         |     1
> bla         |     2
> 
> Because the topic 'bla' indeed doesn't play the author role in an
> association of type is-author. But actually the more correct result
> is: 
> 
> 
>   $player   | %is-author
> ------------+------------
> steve-pepper|     2
> holger-rath |     1
> bla         |     1
> bla         |     2
> 
> Because the topic 'steve-pepper' doesn't play the role author in the
> association object 2, and the topic 'holger-rath' doesn't play the
> role author in the association object 1. And in toma the expression
> is-author->author represents the topics that play the role author in
> the associations of type is-author.

Yes, this is the difference between 'forall' and 'exists'.

> select $player, %is-author where $player not in is-author->author;

This is the 'exists' solution. If you look at

    http://astma.it.bond.edu.au/astma-use-cases.dbk?section=1

where I have various approaches to do one and the same thing, then

    $m / person [ not . -> author \ is-author-of ] / bn

is just a shortcut for

    forall [ $p (person)
             bn : $bn ]
    => not exists [ (is-author-of)
                    author : $p ] in $m
    return
       ($bn)

The predicate [ ... ] means:

   1) get that one person at the time, but go through all,

   2) find all places where it plays the role 'author' in an
      association of type 'is-author-of'. 

   3) If that (unordered sequence) is empty, then [ not
      <empty-sequence> ] resolves to true and the person is in the
      result sequence.  Otherwise it is false and that person is
      suppressed.

So the behaviour defaults to 'exists'.

--

If, OTOH, I would have a query

  "give me all persons who have authored ONLY books"

I would have to select ALL authorship relations and FORALL of those
the thing authored must be of class 'book'. The long version would be

   forall [ $p (person) ]
   => forall [ (is-author-of)
               author : $p
               opus   : $o ]
      => exists [ $o (book) ] in $m
   return
      ($p)

The short version is

   $m / person [ . -> author \ is-author-of / opus [ . -> instance \ is-a / book ] ]

The abridged, short version of this is (using positional roles)

   $m / person [ . -> is-author-of / [ . -> is-a / book ] ]

Note how the most inner [] is an exists clause, all outer []
expression are forall. This corresponds to the long-language version.

I also allow 'not' ONLY at the innerst level to not allow the language
to become too powerful. It is my (unsubstantiated) hope that I stay
roughly at the DL level.

There is - for instance - no

exists [ .. ]
=> forall [ ... ]
   => exists [...]

or a

forall [ ... ]
=> not forall [ ... ]
   => exists [ ...]

I played for a while to restrict the form of rules, but still to be
able to express most of the things which may be necessary. I not sure,
though, how AsTMa!? can be mapped into DL. Maybe the variables we all
use are a showstopper for this process.

--

This is, for instance, one of the problems with tolog. It is basically
a datalog implementation, and - as such - based on predicate logic. [
Logicians listing: I apologize for sloppy argumentation, please feel
free to correct me here ! ]

In this summer I will hijack a friend of mine who is knowledgeable in
these matters. Maybe he can help us out here.

\rho