Re: scope of _:existentials in N3Logic?

That example is confusingly written, because _:somebody 
means something different in the different contexts.
a _:foo always is a local bnode within the graph.

Your example is equivalent to

$ cat varscope1b.n3 
@prefix : <evarscope1#>.
@keywords is, of, a.

bob likes _:somebody.
fred likes _:somebody.
{ alice likes ?X } => { ?X likes _:whoever }.
alice likes trina.

$ cwm varscope1b.n3 --think --quiet
     @prefix : <evarscope1#> .
    @prefix va: <#> .    
     @forAll va:X.
         @forSome va:_g0 .
    :alice     :likes :trina .
    :bob     :likes va:_g0 .
    :fred     :likes va:_g0 .
    :trina     :likes  [
         ] .
    {
        :alice     :likes va:X .
        
        }     <http://www.w3.org/2000/10/swap/log#implies> {va:X     :likes  [
             ] .
        } .
    
$ 

If  the effect you were aiming for was to refer in the rule
to the same variable, then you have to explicitly quantify it in the
outermost graph:


$ cat varscope1a.n3 
@prefix : <evarscope1#>.
@keywords is, of, a.

@forSome somebody.
bob likes somebody.
fred likes somebody.
{ alice likes ?X } => { ?X likes somebody }.
alice likes trina.
$ cwm varscope1a.n3 --think --quiet
     @prefix : <evarscope1#> .
    @prefix va: <#> .
    
     @forAll va:X.
         @forSome :somebody .
    
    :alice     :likes :trina .
    
    :bob     :likes :somebody .
    
    :fred     :likes :somebody .
    
    :trina     :likes :somebody .
    {
        :alice     :likes va:X .
        
        }     <http://www.w3.org/2000/10/swap/log#implies> {va:X     :likes :somebody .
        } .
    
$ 


In this case, the rule does bind to the same person.


Tim



On 2010-02 -23, at 17:16, Dan Connolly wrote:

> I'm re-implementing N3Logic in scala... in particular, parsing
> N3 syntax into Coherent formulas. I'm trying to figure
> out how existential variables work in N3, and I'm surprised about
> something.
> 
> Consider:
> 
>  There's somebody that Bob likes and Fred likes.
>  And everybody that Alice likes also likes this somebody.
>  Also, Alice likes Trina.
> 
>  Does Trina like this somebody?
> 
> Of course Trina does, but when I try to write the problem
> down in N3, cwm doesn't handle it as I'd expect. cwm concludes
> that Trina likes something, but not that Trina likes
> the same somebody that Bob and Fred like.
> 
> $ cat ...varscope1.n3
> @prefix : <evarscope1#>.
> @keywords is, of, a.
> 
> bob likes _:somebody.
> fred likes _:somebody.
> { alice likes ?X } => { ?X likes _:somebody }.
> alice likes trina.
> 
> $ cwm.py ...varscope1.n3 --think
> #Processed by Id: cwm.py,v 1.197 2007/12/13 15:38:39 syosi Exp 
>        #    using base
> file:///home/connolly/projects/rdfsem/src/test/resources/varscope1.n3
> 
> #  Notation3 generation by
> #       notation3.py,v 1.200 2007/12/11 21:18:08 syosi Exp
> 
> #   Base was:
> file:///home/connolly/projects/rdfsem/src/test/resources/varscope1.n3
>     @prefix : <evarscope1#> .
>    @prefix va: <#> .
> 
>     @forAll va:X.
>         @forSome va:_g0 .
> 
>    :alice     :likes :trina .
> 
>    :bob     :likes va:_g0 .
> 
>    :fred     :likes va:_g0 .
> 
>    :trina     :likes  [
>         ] .
>    {
>        :alice     :likes va:X .
> 
>        }     <http://www.w3.org/2000/10/swap/log#implies>
> {va:X     :likes  [
>             ] .
>        } .
> 
> #ENDS
> 
> The surprise is bad news, but the good news is that cwm's
> way of reading this formula does fit inside coherent logic,
> which makes my coding goal straightforward...
> 
> -- 
> Dan Connolly, W3C http://www.w3.org/People/Connolly/
> gpg D3C2 887B 0F92 6005 C541  0875 0F91 96DE 6E52 C29E
> 
> 
> 

Received on Friday, 26 February 2010 15:00:47 UTC