Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo


try to define in N3 logic a list member predi

  • Hi

    In N3 examples, I tried to reproduce in N3 logic the classic definition of member/2 in Prolog.
    Here are the rules I tried, but they give no result :

      ?LIST a rdf:List .
      ?LIST rdf:first ?FIRST .
    } => {
      ?FIRST :member1 ?LIST .
    } .

    # member(X,[Y|R]) :- member(X,R).
    @forAll :X, :R, :Y .
      ?X a rdf:List .
      ?X :member1 ?R .
    } => {
      ?R1 a rdf:List .
      ?R1 rdf:first ?Y .
      ?R1 rdf:rest  ?R .
      ?X :member1 ?R1 .
    } .

    The full test is here:
    And the EuelrGUI project:

    • Jos De Roo
      Jos De Roo

      There list:in in http://eulersharp.sourceforge.net/2003/03swap/rpo-rules.n3
      which is how it was done in the beginning and it worked fine.
      Since a while this is a builtin and there is actually another list:member too
      see http://www.w3.org/2000/10/swap/doc/CwmBuiltins

    • Indeed the builtin for list:in works fine, as fine as Prolog member/2 which implements it , cf

      However, there seems to be problems when testing the same definition of list:in as in rpo-rules.n3 :

      These simple triples do not pass :

        "1" mylist:in ( "1" "2" ) .
        :a1 mylist:in ( :a1 :a2 ) .

      • Jos De Roo
        Jos De Roo

        in the case of mylist:in there is no built-in knowledge
        even not that (i j k) is a rdf:List
        so tell eye all the rules or give the facts straight
        ("1" "2") a rdf:List.
        (:a1 :a2) a rdf:List.

        • Indded when declaring the facts straight
          ("1" "2") a rdf:List.
          (:a1 :a2) a rdf:List.

          it works.

          However I think it should not be necessary to specify that.
          It seems that per the RDF spec. :

          something that is the subject of rdf:first and  rdf:rest is necessarily a rdf:List .
          And the parenthesis notation in N3 is just a short form for a chain of rdf:first and rdf:rest properties.

          • Jos De Roo
            Jos De Roo

            that's exactly what I meant with "tell eye all the rules":

            rdf:first rdfs:domain rdf:List.
            rdf:rest rdfs:domain rdf:List; rdfs:range rdf:List.

            {?P rdfs:domain ?C. ?S ?P ?O} => {?S a ?C}.
            {?P rdfs:range ?C. ?S ?P ?O} => {?O a ?C}.


            as per RDF MT