W3C home > Mailing lists > Public > www-rdf-interest@w3.org > February 2004

Re: Strategies for inference over lists of values

From: Jos De_Roo <jos.deroo@agfa.com>
Date: Fri, 27 Feb 2004 20:33:55 +0100
To: "Graham Klyne <gk" <gk@ninebynine.org>
Cc: RDF interest group <www-rdf-interest@w3.org>, www-rdf-logic@w3.org
Message-ID: <OF245D3170.D492032F-ONC1256E47.0068DE03-C1256E47.006B7DB2@agfa.be>

Hi Graham,

For those 2 test cases we build an N3 theory like

{?W :hourlyTemperatures ?L.
 ?L :maxNumber ?N}
=> {?W :maxTemperature ?N}.

{?A rdf:first ?M;
    rdf:rest rdf:nil}
=> {?A :maxNumber ?M}.

{?A rdf:first ?M;
    rdf:rest ?B.
 ?B :maxNumber ?N.
 ?M math:greaterThan ?N}
=> {?A :maxNumber ?M}.

{?A rdf:first ?M;
    rdf:rest ?B.
 ?B :maxNumber ?N.
 ?M math:notGreaterThan ?N}
=> {?A :maxNumber ?N}.

{?E :samples ?L.
 ?L :cumValue ?C;
    :cumFreq ?D.
 (?C ?D) math:integerQuotient ?M}
=> {?E :meanValue ?M}.

rdf:nil :cumValue "0"^^xsd:integer.

{?A rdf:first ?M;
 rdf:rest ?B.
 ?M :value ?V;
    :freq ?F.
 ?B :cumValue ?N.
 ((?V ?F).math:product ?N) math:sum ?C}
=> {?A :cumValue ?C}.

rdf:nil :cumFreq "0"^^xsd:integer.

{?A rdf:first ?M;
    rdf:rest ?B.
 ?M :freq ?F.
 ?B :cumFreq ?N.
 (?F ?N) math:sum ?C}
=> {?A :cumFreq ?C}.

and then giving that and your facts to and asking

_:W :maxTemperature _:M.
_:E :meanValue _:V.

to euler --nope we get

_:weatherToday_1 :maxTemperature "17"^^xsd:integer.
_:experiment_1 :meanValue 26.

So in summary we use N3 facts and implications (wich are recursive
as can be seen in the trace at

Jos De Roo, AGFA http://www.agfa.com/w3c/jdroo/

                      Graham Klyne                                                                                                        
                      <gk@ninebynine.org>         To:       RDF interest group <www-rdf-interest@w3.org>, <www-rdf-logic@w3.org>          
                      Sent by:                    cc:                                                                                     
                      www-rdf-interest-req        Subject:  Strategies for inference over lists of values                                 
                      27/02/2004 18:42                                                                                                    


I'm wondering what strategies folks are using for inference over
collections (lists) of values in RDF (other than resorting to ad-hoc
code).  (Maybe also over containers, but the closure of lists makes the
problem easier to define.)

A simple example would be the selection of the maximum value from a list;


       ( "10"^^xsd:integer "12"^^xsd:integer "15"^^xsd:integer
         "16"^^xsd:integer "14"^^xsd:integer "17"^^xsd:integer
         "13"^^xsd:integer "12"^^xsd:integer "10"^^xsd:integer
         "9"^^xsd:integer  "7"^^xsd:integer  "6"^^xsd:integer ) .

how to deduce:

     :maxTemperature "17"^^xsd:integer .

A more complex example might be the extraction of a mean value given a list

of sample values and observed frequencies:

    :samples ( _:s1 _:s2 _:s3 _:s4 ) .
  _:s1 :value "10"^^xsd:integer ;
       :freq  "2"^^xsd:integer .
  _:s2 :value "20"^^xsd:integer ;
       :freq  "5"^^xsd:integer .
  _:s3 :value "30"^^xsd:integer ;
       :freq  "6"^^xsd:integer .
  _:s4 :value "40"^^xsd:integer ;
       :freq  "3"^^xsd:integer .

to deduce:

      _meanValue "26"^^xsd:integer

with access to normal arithmetic functions.

This can be done by generating intermediate resources that relate to
accumulated values from the list, but this approach rapidly becomes very
ugly.  I have some half-baked ideas for a tidier approach, but was hoping
that someone might have a fully-baked solution.


Graham Klyne
For email:
Received on Friday, 27 February 2004 14:33:57 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:44:48 UTC