try to define in N3 logic a list member predi

  • Jean-Marc Vanel

    Jean-Marc Vanel - 2009-08-30


    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 - 2009-08-30

      There list:in in
      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

    • Jean-Marc Vanel

      Jean-Marc Vanel - 2009-08-31

      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 - 2009-09-01

        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.

        • Jean-Marc Vanel

          Jean-Marc Vanel - 2009-09-01

          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 - 2009-09-01

            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


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks