CWM Bug: Don't Canonicalise Lists

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

CWM Bug: Don't Canonicalise Lists

Sean B. Palmer

Please remove list canonicalisation from cwm.

Compare:

$ echo '@prefix : <http://example.org/#> . (:p) :q (:p) .' | \
     cwm --n3 --rdf | rapper -i rdfxml -o ntriples - .
rapper: Parsing URI (null) with base URI .
_:genid1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first>
<http://example.org/#p> .
_:genid1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .
_:genid2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first>
<http://example.org/#p> .
_:genid2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .
_:genid1 <http://example.org/#q> _:genid2 .
rapper: Parsing returned 5 triples

With:

$ echo '@prefix : <http://example.org/#> . (:p) :q (:p) .' | cwm --ntriples
_:li1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first>
<http://example.org/#p> .
_:li1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest>
   <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .
_:li1 <http://example.org/#q> _:li1 .

(Note that I wonder about formula canonicalisation too.)

Thanks,

--
Sean B. Palmer, http://inamidst.com/sbp/

Reply | Threaded
Open this post in threaded view
|

Re: CWM Bug: Don't Canonicalise Lists

Yosi Scharf

This shows what list canonicalization does. I'm not so sure it is an  
argument to remove it.


Yosi



On Oct 15, 2007, at 5:32 AM, Sean B. Palmer wrote:

>
> Please remove list canonicalisation from cwm.
>
> Compare:
>
> $ echo '@prefix : <http://example.org/#> . (:p) :q (:p) .' | \
>      cwm --n3 --rdf | rapper -i rdfxml -o ntriples - .
> rapper: Parsing URI (null) with base URI .
> _:genid1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first>
> <http://example.org/#p> .
> _:genid1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest>
> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .
> _:genid2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first>
> <http://example.org/#p> .
> _:genid2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest>
> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .
> _:genid1 <http://example.org/#q> _:genid2 .
> rapper: Parsing returned 5 triples
>
> With:
>
> $ echo '@prefix : <http://example.org/#> . (:p) :q (:p) .' | cwm --
> ntriples
> _:li1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first>
> <http://example.org/#p> .
> _:li1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest>
>    <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .
> _:li1 <http://example.org/#q> _:li1 .
>
> (Note that I wonder about formula canonicalisation too.)
>
> Thanks,
>
> --
> Sean B. Palmer, http://inamidst.com/sbp/
>


Reply | Threaded
Open this post in threaded view
|

Re: CWM Bug: Don't Canonicalise Lists

Tim Berners-Lee
In reply to this post by Sean B. Palmer

I suppose we could make it an option.
Note also though that cwm does datatype canonicalization as well for  
example for 08 and 8.
Would you want that removed?

Tim

On 2007-10 -15, at 05:32, Sean B. Palmer wrote:

>
> Please remove list canonicalisation from cwm.
>
> Compare:
>
> $ echo '@prefix : <http://example.org/#> . (:p) :q (:p) .' | \
>      cwm --n3 --rdf | rapper -i rdfxml -o ntriples - .
> rapper: Parsing URI (null) with base URI .
> _:genid1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first>
> <http://example.org/#p> .
> _:genid1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest>
> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .
> _:genid2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first>
> <http://example.org/#p> .
> _:genid2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest>
> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .
> _:genid1 <http://example.org/#q> _:genid2 .
> rapper: Parsing returned 5 triples
>
> With:
>
> $ echo '@prefix : <http://example.org/#> . (:p) :q (:p) .' | cwm --
> ntriples
> _:li1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first>
> <http://example.org/#p> .
> _:li1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest>
>    <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .
> _:li1 <http://example.org/#q> _:li1 .
>
> (Note that I wonder about formula canonicalisation too.)
>
> Thanks,
>
> --
> Sean B. Palmer, http://inamidst.com/sbp/


Reply | Threaded
Open this post in threaded view
|

Re: CWM Bug: Don't Canonicalise Lists

Sean B. Palmer

On 10/16/07, Tim Berners-Lee <[hidden email]> wrote:

> I suppose we could make it an option.
> Note also though that cwm does datatype canonicalization as
> well for example for 08 and 8.
> Would you want that removed?

No, I understand the utility of list canonicalisation now, but I'm
worried about the possiblity of it making cwm incompatible with the
RDF standards. As DanC noted on IRC, "you might be able to phrase some
entailment test invoving rdf:first that cwm would fail because it
forgot about axiomatic lists".

The added *practical* pain is that it's a computational burden to
canonicalise lists when parsing N3, so should it be such an ingrained
part of the language? Perhaps a clearer demonstration is formula
canonicalisation: for that you have to do graph isomorphism, an even
bigger computational burden.

Nobody is saying that all N3 processors must canonicalise, of course,
I understand. But if I want to process non-canon N3, what can I test
against? CWM is N3's only reference specification, so you can't really
write a standalone N3 parser without the two kinds of
canonicalisation.

I'm therefore leaving this bug open until you produce a reference
specification, or a non-canonicalised N3 test suite, or formally
forbid non-canon N3, or... :-)

--
Sean B. Palmer, http://inamidst.com/sbp/

Reply | Threaded
Open this post in threaded view
|

Re: CWM Bug: Don't Canonicalise Lists

Sean B. Palmer
In reply to this post by Yosi Scharf

On Oct 15, 2007 2:07 PM, Yosi Scharf <[hidden email]> wrote:

> This shows what list canonicalization does. I'm not so sure it
> is an argument to remove it.

I finally worked out an example where it matters: in subclassing
rdf:List to come up with your own containers to which you might attach
various semantics. People have asked for this kind of thing on #swig
before, and it just came up in a JSON project I'm working on which is
how I figured it out.

Here's an example:

$ cat siblings.n3
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix list: <http://www.w3.org/2000/10/swap/list#> .
@keywords a .

John siblings [
   names [ a BrotherNames;
           rdf:first "Morgan";
           rdf:rest ("Kris" "Kerry") ]
] .

Jane siblings [
   names [ a SisterNames;
           rdf:first "Morgan";
           rdf:rest ("Kris" "Kerry") ]
] .

{ ?list a BrotherNames } => { ?list a List } .
{ ?list a SisterNames } => { ?list a List } .
{ ?element list:in ?list . ?list a List }
   => { ?list member ?element } .

{ ?person siblings [ names [ a SisterNames; member ?name ] ] }
   => { ?person sisterName ?name } .

{ ?person siblings [ names [ a BrotherNames; member ?name ] ] }
   => { ?person brotherName ?name } .

$ cwm siblings.n3 --think

Gives in part:

    :John     :brotherName "Kerry",
                "Kris",
                "Morgan";
         :siblings  [
             :names  (
            "Morgan"
            "Kris"
            "Kerry" ) ];
         :sisterName "Kerry",
                "Kris",
                "Morgan" .

Which is wrong. John doesn't have any sisters, and yet the model of
the input is fine. The problem is caused by CWM canonicalising lists
and having no way to turn it off.

--
Sean B. Palmer, http://inamidst.com/sbp/

Reply | Threaded
Open this post in threaded view
|

Re: CWM Bug: Don't Canonicalise Lists

Tim Berners-Lee

Sean,

Well,   the situation is analogous with the simpler:

"Morgan" a BrotherName; is name of [ is sibling of John ].

"Morgan" a SisterName; is name of [ is sibling of John ].

An axiom is that "Morgan" === "Morgan" wherever it appears.  Strings  
don't have gender, charm etc.
CWM makes the same assumption about   ( "Morgan" "Kris" ).

Basically, lists of literals are like literals.  Formulas too, work  
like that.
Their identity is their value.  Variables of course make things more  
complicated.

Just as if can say

        7 a Prime.

It applies to any 7, if you say   (7 3) a MutallyPrimePair it applies  
to any (7 3).

I am loth to do it differently.
In practice, you can make a sisternames have a list instead of being  
one, of course.

Tim

> John sibling [
>   name [ a BrotherName;
>           == "Morgan";
>           ]



On 2007-11 -23, at 10:39, Sean B. Palmer wrote:

>
> On Oct 15, 2007 2:07 PM, Yosi Scharf <[hidden email]> wrote:
>
>> This shows what list canonicalization does. I'm not so sure it
>> is an argument to remove it.
>
> I finally worked out an example where it matters: in subclassing
> rdf:List to come up with your own containers to which you might attach
> various semantics. People have asked for this kind of thing on #swig
> before, and it just came up in a JSON project I'm working on which is
> how I figured it out.
>
> Here's an example:
>
> $ cat siblings.n3
> @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
> @prefix list: <http://www.w3.org/2000/10/swap/list#> .
> @keywords a .
>
> John siblings [
>   names [ a BrotherNames;
>           rdf:first "Morgan";
>           rdf:rest ("Kris" "Kerry") ]
> ] .
>
> Jane siblings [
>   names [ a SisterNames;
>           rdf:first "Morgan";
>           rdf:rest ("Kris" "Kerry") ]
> ] .
>
> { ?list a BrotherNames } => { ?list a List } .
> { ?list a SisterNames } => { ?list a List } .
> { ?element list:in ?list . ?list a List }
>   => { ?list member ?element } .
>
> { ?person siblings [ names [ a SisterNames; member ?name ] ] }
>   => { ?person sisterName ?name } .
>
> { ?person siblings [ names [ a BrotherNames; member ?name ] ] }
>   => { ?person brotherName ?name } .
>
> $ cwm siblings.n3 --think
>
> Gives in part:
>
>    :John     :brotherName "Kerry",
>                "Kris",
>                "Morgan";
>         :siblings  [
>             :names  (
>            "Morgan"
>            "Kris"
>            "Kerry" ) ];
>         :sisterName "Kerry",
>                "Kris",
>                "Morgan" .
>
> Which is wrong. John doesn't have any sisters, and yet the model of
> the input is fine. The problem is caused by CWM canonicalising lists
> and having no way to turn it off.
>
> --
> Sean B. Palmer, http://inamidst.com/sbp/