GithubHelp home page GithubHelp logo

eyereasoner / eye Goto Github PK

View Code? Open in Web Editor NEW
119.0 119.0 16.0 164.47 MB

Euler Yet another proof Engine

Home Page: https://eyereasoner.github.io/eye/

License: MIT License

Batchfile 0.07% Prolog 43.30% Shell 7.08% HTML 49.53% Dockerfile 0.02%

eye's People

Contributors

bdevloed avatar hongsun502 avatar janwielemaker avatar jeswr avatar josd avatar phochste avatar pmoura avatar rubenverborgh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

eye's Issues

question about recursive rule

by "recursive rule" I mean a rule with other rules in it's antecedent and/or consequent.

in this simple example :

{?P :subPropertyOf ?Q } => { {_:S ?P _:O} => {_:S ?Q _:O} } .
:k1 :subPropertyOf :k0.
:x :k1 :y.

And run eye --pass-only-new --nope ./test.n3
I expected to get :

:x :k0 :y.
{?U_0 :k1 ?U_1} => {?U_0 :k0 ?U_1}.

But only got :

{?U_0 :k1 ?U_1} => {?U_0 :k0 ?U_1}.

I also tried to write the recursive rule like this:
{?P :subPropertyOf ?Q } => {@forAll :S, :O. {:S ?P :O} => {:S ?Q :O} } .
And got the similar result.

Is this a bug or did I make a mistake?

"non_rdf_entailment" error

I tested —entail option like this:

In ./test-entail.n3 , I write:

PREFIX : <http://www.example.com/>
:biggerThan :inverseOf :smallerThan.
{?p1 :inverseOf ?p2. ?a ?p1 ?b} => {?b ?p2 ?a}.

In ./test-entail-claim.n3:

PREFIX : <http://www.example.com/>
{?a :biggerThan ?b} => {?b :smallerThan ?a}.

And run
Eye —-nope ./test-entail.n3 --entail ./test-entail-claim.n3

Gives me error message like this:
** ERROR ** file://.../test-entail-result.n3 ** non_rdf_entailment('file://.../test-entail-claim.n3#in'(_a,_b),after_line(2))

What does “non_rdf_entailment” mean? And I want to know is it possible that the claim of entail is a rule?

[= support in eye

This is related to the discussion on n3 mailing list and github repo w3c/N3#100 (comment)

I tried downloading the latest eye I tried with [= and with [ = but with no success. Am I forgetting something?

╭─[email protected] ~/Documents/card
╰─➤  cat moby.n3
@prefix dc: <http://purl.org/dc/terms/>.
@prefix : <http://example.org/nd#>.

[= :mobyDick; dc:title "Moby Dick" ].


╭─[email protected] ~/Documents/card
╰─➤  ~/Programming/eye-22.0622.1937/eye.sh --quiet --nope moby.n3 --pass 2>/dev/null
@prefix dc: <http://purl.org/dc/terms/>.
@prefix : <http://example.org/nd#>.

_:bn_1 <http://www.w3.org/2002/07/owl#sameAs> :mobyDick.
_:bn_1 dc:title "Moby Dick".

Redundant calls to append/2

All the calls to append/2 in the following clauses are redundant:

https://github.com/josd/eye/blob/f453603d036b52257bad95bc4e61ce16667c4dd9/eye.pl#L10867-L10890

You can write instead:

ncodes(A, B) :-
    number_codes(A, D),
    (   A < 10
    ->  B = [0'0| D]
    ;   B = D
    ).

ycodes(A, B) :-
    C is abs(A),
    number_codes(C, D),
    (   C < 10
    ->  E = [0'0, 0'0, 0'0| D]
    ;   (   C < 100
        ->  E = [0'0, 0'0| D]
        ;   (   C < 1000
            ->  E = [0'0| D]
            ;   E = D
            )
        )
    ),
    (   A >= 0
    ->  B = E
    ;   B = [0'-|E]
    ).

There may be others.

math:sum fail to resolve... sometimes

Running the following in the latest version of EYE

{ (20 20) math:sum ?x. (?x 2) math:sum ?y. } => { :ANSWER1 :IS ?y }.
{ (?x 2) math:sum ?y. (20 20) math:sum ?x. } => { :ANSWER2 :IS ?y }.
{ (20 20) math:sum ?x. (?x ?y) math:sum 42. } => { :ANSWER3 :IS ?y }.
{ (?x ?y) math:sum 42. (20 20) math:sum ?x. } => { :ANSWER4 :IS ?y }.
{ (20 20) math:sum ?x. (1 1) math:sum ?y. (?x ?y) math:sum ?z. } => { :ANSWER5 :IS ?z }.
{ (20 20) math:sum ?x. (?x ?y) math:sum ?z. (1 1) math:sum ?y. } => { :ANSWER6 :IS ?z }.
{ (?x ?y) math:sum ?z. (20 20) math:sum ?x. (1 1) math:sum ?y. } => { :ANSWER7 :IS ?z }.

I get all answers but ANSWER4... strange

Could you please extend e:fail and e:findall to enable it to take a formula as the subject?

Just as you have extended e:call here to enable it to take a formula as the subject.
I have to use e:findall and e:fail in the same way when implementing certain functions (for example, use e:findall to find a pattern in a formula).

Here is a simple test:

PREFIX e: <http://eulersharp.sourceforge.net/2003/03swap/log-rules#>
PREFIX log: <http://www.w3.org/2000/10/swap/log#>
PREFIX : <#>

:g1 :content {
        {?x a :mortal} <= {?x a :human}.
        :Socrates a :human.
        }. 

{:g1!:content e:findall ( ?x {?x a :mortal} ?ANSWER ). ?ANSWER log:equalTo (:Socrates)} => {:TEST :PASS 1}.
{:g1!:content e:fail {:Socrates a :female}} => {:TEST :PASS 2}.
{:g1!:content e:call {:Socrates a :mortal}} => {:TEST :PASS 3}. 

Currently we got :TEST :PASS 3 only ( With --pass-only-new).

Thanks in advance!

Installation Instructions [Linux Debian]

I wanted to run some of my own tests on the eye reasoner on my machine.

I was trying to run the ./install.sh script - but haven't got the swipl command installed. Is there a recommended place to install this from since it doesn't appear to be available from the apt package manager.

System Details:

PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

I'm happy to PR a set of Linux installation instructions once I am able to get this working on my machine.

How to express `OR` and negation?

I have a few questions:

  1. How do I express logical or do I have to use , or ;?
    Example:
    if a box is big and it is either green or blue or red, then it's a new box:
    {?X a :Box. ?X a :big. (?X a :green OR ?X a :blue OR ?X a :red)} => {?X a :newBox}.

  2. How do I use negation of a predicate, e.g.
    if a box is big and it is NOT green, then it's a blue box:
    {?X a :Box. ?X a :big. not(?X a :green)} => {?X a :blueBox}.

  3. How do I properly use a recursive predicate, e.g. if we have:

:someRel a :relType1.
:A1 :someRel :A2.
:A2 :someRel :A3.
:A4 :someRel :A5.

When I query for {:A1 :someRel :A3.} => {:A1 :someRel :A3.}., then it finds a solution, but
it does NOT for the following two:

{:A1 :someRel :A4.} => {:A1 :someRel :A4.}.
{:A1 :someRel :A5.} => {:A1 :someRel :A5.}. 
  1. Does EYE automatically check for consistency (integrity) in the DB of facts while adding each new fact.

  2. How to \=, i.e. the opposite of =. I noticed log:notEqualTo and owl:differentFrom but they don't seem to have the same power as =, i.e. those never trigger any eam inference errors.

Sorry for the long question and thanks in advance @josd ! :)

Strange error with rules involving RDF*

I tried to reduce it to a minimal example:

{} => { << :s :p :o >> :c :c2 }.
{} => { << :s :p :o >> :c :c2, :c3 }.
{ << :s :p :o >> :c :c2 } <= {}.
#{ << :s :p :o >> :c :c2, :c3 } <= {}. # this one raises an error

The three first rules work, but uncommenting the 4th one causes the following error:

** ERROR ** gre ** error(permission_error(modify,static_procedure,(,)/2),context(system:assertz/1,_5824))

Incorrect datatype for language strings

According to the spec, literals with a language tag have the datatype rdf:langString. However, the following N3 code does not give the correct result in EYE

@prefix log: <http://www.w3.org/2000/10/swap/log#> .

{ (?lv ?dt) log:dtlit "a"@fr } => { :RESULT :is ?dt }.

Got: :RESULT :is xsd:string.
Expected :RESULT :is rdf:langString.

Bug `pred:list-contains` missing match

If I execute the following query there are no derivations, despite the fact that I expect one result of the form [] :valid true.

@prefix pred: <http://www.w3.org/2007/rif-builtin-predicate#> .
@prefix : <http://example.org/> .

2 :to :o .

{
  ((1 2) ?s) pred:list-contains true .
  ?s :to :o .
} => {
  [] :valid true .
} .

In contrast the following queries do give the expected derivation of [] :valid true

@prefix pred: <http://www.w3.org/2007/rif-builtin-predicate#> .
@prefix : <http://example.org/> .

1 :to :o .

{
  ((1 2) ?s) pred:list-contains true .
  ?s :to :o .
} => {
  [] :valid true .
} .
@prefix pred: <http://www.w3.org/2007/rif-builtin-predicate#> .
@prefix : <http://example.org/> .

2 :to :o .

{
  ?s list:in (1 2) .
  ?s :to :o .
} => {
  [] :valid true .
} .

string:format vs. e:format builtin

Based on my experimentation, it seems that eye does not implement the string:format builtin with (old-style) Python string formatting, but instead implements e:format with SWI Prolog format/2 formatting. Is that correct?

I don't mind using the latter rather than the former, but I'm just trying to make sure I understand correctly.

Lists as predicates fails with exit code 1 when used in implication

E.g. any of the (un)commented examples generates an exit code 1.

@prefix : <http://example.org/#> .

(:book1 :book3) (:readBy :likedBy) (:Jos :Ruben).

{
    (:book1 :book3) (:readBy :likedBy) (:Jos :Ruben).
    #(:book1 :book3) ?X (:Jos :Ruben).
    #(:book1 :book3) ?X ?Y.
    #?X (:readBy :likedBy) ?Y.
    #?X ?Y (:Jos :Ruben).
}
=>
{
    :test :is true .
} .

Using EYE v22.1006.1358

How to express quantifiers like `Some X are Y`

I am playing around with EYE and trying to solve some puzzles, e.g.

(1) No potatoes of mine, that are new, have been boiled;
(2) All my potatoes that are unfit to eat, are in this dish ;
(3) No unboiled potatoes of mine are fit to eat.
-------------------
Q: are there any new potatoes in this dish?

This is my solution so far:

@prefix : <file:///#>.
@prefix e: <file:///e#>.


#:potato1 a :newPotato.

{?X a :newPotato} => {?SCOPE e:fail {?X a :boiled}}.
{?SCOPE e:fail {?X a :fitToEat}} => {?X a :potatoInDish}.
{?SCOPE e:fail {?X a :boiled}} => {?SCOPE e:fail {?X a :fitToEat}}.

And in a separate query file:

{?X a :newPotato. ?X a :potatoInDish.} => {?X a :potatoInDish}.

Q1) It seems to work if I uncomment the assertion :potato1 a :newPotato. but adding that assertion seems a bit like a hack. It is something not mentioned in the puzzle. Is there a more general way of specifying "There exist some new potatoes." or "there exists at least one new potato, but I won't name it here explicitly"?

Q2) How do I specify that potato2 is NOT a new potato. I tried with:

{?SCOPE e:fail {:potato2 a :newPotato}}.

But I think that the above declaration got ignored by EYE.


Q 3) (Somewhat related to Q1). We have the following puzzle:

'Some animals are venomous. All venomous animals are dangerous to touch.'
Which of the following are valid deductions?
All non-venomous animals are safe (not dangerous) to touch.
Some animals are dangerous to touch.
Some animals are safe (not dangerous) to touch.

The second assertion can be specified as:

{?X a :venomous} => {?X a :dangerousToTouch}.

But I find a difficulty modeling the first assertion and the last two questions in EYE. Namely, I don't know how to specify the some quantifier (Some X are Y). Any suggestions?

Question 4) Some unrelated question. Is the use of <= in the following file just for readability or does it mean something different than the left and right hand side have changed places for readability
https://github.com/josd/eye/blob/master/reasoning/4color/4color_rules.n3

strange behavior of backward rule

I’m confused by the behavior of backward rule.
this example:

:Alice :type :human.
{?x :type :animal} <= {?x :type :human}. 
{?x :type :animal} => {?x :type :animal}. # not fired
{?x :type :animal} => {?x :type2 :animal}. # fired.

Give me result:
:Alice :type2 :animal

not what I expected :

:Alice :type :animal
:Alice :type2 :animal

Why did the third rule fired while the second one did not ?

How can I embed the EYE reasoning engine in a C++ application

@josd, First thanks for your hard work on this amazing project!
I've been playing with EYE for a while (solving some logic puzzles, etc.).
Now, I'd like to embed it directly into a C++ application. For the purpose passing millions of rules and data triples directly.

I am thinking of something similar to using SWI Prolog from C++, e.g.
https://github.com/SWI-Prolog/packages-cpp/blob/master/likes.cpp

PS, I am aware of using docker to run EYE and also use the HTTP server client interface. But those add too much latency when dealing with huge amounts of data.
TIA!

How can I use EYE to reify/dereify a formula.

In CWM I can use —reify and —dereify options , to replace the statements in the store with statements describing them, and undo the effects.
Newly to EYE, after some search still don’t know how can I achieve this.

And I also wonder if reify and dereify could be implement as a built-in function, which in my opinion will be very convenient and useful.

Invalid document error with @false

@josd In https://github.com/josd/eye/blob/55b57949312cedbc517f4d02fa84ecffec5eee53/reasoning/skos/skos-rules.n3 there are rules that express disjoint relations, e.g.
{ ?x skos:exactMatch ?y. ?x skos:broadMatch ?y } => @false.
But when I try to use the same syntax in my files, I get an error: ** invalid_document(after_line(15))
On the other hand,
{ ?x skos:exactMatch ?y. ?x skos:broadMatch ?y } => false. (without the @ in front of false) seems to get accepted by EYE. Is the latter rule being interpreted the same way as when using @false?

Error when using local Windows paths

When running the examples locally in Windows, e.g.:

cd /d C:/path/to/eye/reasoning/3outof5
eye sample.n3 --query query.n3 --output answer.n3

I get following error:

eye sample.n3 --query query.n3
EYE v22.1201.1601 josd
SWI-Prolog version 9.0.0
starting 46 [msec cputime] 62 [msec walltime]
#Processed by EYE v22.1201.1601 josd
#eye sample.n3 --query query.n3

GET file:///c:/path/to/eye/reasoning/3outof5/sample.n3 ** ERROR ** gre ** error(existence_error(source_sink,/c:/path/to/eye/reasoning/3outof5/sample.n3),context(system:open/4,Invalid argument))

I tried opening the file in swipl directly, to exclude permission issues and alike, and I noticed that opening "c:/path/to/file" (without leading slash) works, but "/c:/path/to/file" (with leading slash) fails with the same exception "Invalid argument".

log:notIncludes is order dependant

More precisely: log:notIncludes behaves differently depending on where the variables in its pattern are bound (similarly to the e:findAll case we discussed during the last meeting).

Example:

@prefix log: <http://www.w3.org/2000/10/swap/log#> .

:alice :name "alice".
:bob :name "bob".
:charlie :name "charlie".

:alice :says { :bob a :NiceGuy }.

@forAll :y.

{ :alice :says ?x.
  :y :name "charlie".
  ?x log:notIncludes { :y a :NiceGuy }.
} => { :test :pass 1 }.

{ :alice :says ?x. 
  ?x log:notIncludes { :y a :NiceGuy }.
  :y :name "charlie".
} => { :test :pass 2 }.

It should produce:

:test :pass 1, 2.

but only test 1 passes.

See http://ppr.cs.dal.ca:3002/n3/editor/s/zfSPYqFV
(but I also tested it locally with the latest commit).

Issue with string escaping

Given the following input file:

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix schema: <http://schema.org/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix ex: <http://data.table.org/> .
@prefix table: <http://schema.table.org/> .

<http://data.table.org/BIO-DB-DATA-metadata/DA_ALLGewaesser_BIO> a table:Table ;
	table:contextLabel "BIO-DB-DATA-metadata/DA_ALLGewaesser_BIO" ;
	schema:name "\"DA_ALLGewaesser_BIO\"" ;
	table:column <http://data.table.org/BIO-DB-DATA-metadata/DA_ALLGewaesser_BIO/column/gew_ID>, <http://data.table.org/BIO-DB-DATA-metadata/DA_ALLGewaesser_BIO/column/gew_fk_ID>, <http://data.table.org/BIO-DB-DATA-metadata/DA_ALLGewaesser_BIO/column/gew_Name>, <http://data.table.org/BIO-DB-DATA-metadata/DA_ALLGewaesser_BIO/column/gew_Code>, <http://data.table.org/BIO-DB-DATA-metadata/DA_ALLGewaesser_BIO/column/gew_Typ>, <http://data.table.org/BIO-DB-DATA-metadata/DA_ALLGewaesser_BIO/column/gew_Childs> ;
	table:hasUniqueContraint <http://data.table.org/BIO-DB-DATA-metadata/DA_ALLGewaesser_BIO/constraint/SYS_PK_11701> .

and the following N3 file:

@prefix schema: <http://schema.org/>.
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
@prefix string: <http://www.w3.org/2000/10/swap/string#>.
@prefix table: <http://schema.table.org/> .

#
# Access: remove " and add it as rdfs:label 
#
{
  ?iri a table:Table ;
    schema:name ?label .
#  (?label "\"" "") string:replaceAll ?cleanedLabel
}
=>
{
  ?iri rdfs:label ?label .
  #?iri rdfs:label ?cleanedLabel .
} .

This generates invalid Turtle:

@prefix schema: <http://schema.org/>.
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
@prefix string: <http://www.w3.org/2000/10/swap/string#>.
@prefix table: <http://schema.table.org/>.

<http://data.table.org/BIO-DB-DATA-metadata/DA_ALLGewaesser_BIO> rdfs:label ""DA_ALLGewaesser_BIO"".

It looks like the escaping of " gets lost.

Bug or am I missing something?

make it easier to get going

Some ideas:

  • releasing eye on https://brew.sh to make it easy to install so that it installs swi-prolog would make it much more accessible to people on macs.
  • a little better documentation on how to get going.

One thing I used Cwm for was just so that I could use the nice n3 syntax to write things that were not possible to do in n3. So I have a foaf file that used the = shortcut so that one could name blank nodes, see the use below...

I then have a little script that translates it to rdf/xml and turtle and from there to ntriples even.
I can use rapper to do translations from turtle. But I think there should be a way to extract at least
NQuads from a tool such as eye.

# @base <http://bblfish.net/people/henry/> .

@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/>.
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix geo: <http://www.w3.org/2003/01/geo/wgs84_pos#> .
@prefix contact: <http://www.w3.org/2000/10/swap/pim/contact#> .
@prefix awol: <https://bblfish.net/work/atom-owl/2006-06-06/#> .
@prefix iana: <http://www.iana.org/assignments/relation/> .
@prefix cert: <http://www.w3.org/ns/auth/cert#> .
@prefix rsa: <http://www.w3.org/ns/auth/rsa#> .
@prefix wiki: <http://wikipedia.org/wiki/> .
@prefix pingback: <http://purl.org/net/pingback/> .
@prefix space: <http://www.w3.org/ns/pim/space#> .

@prefix : <https://bblfish.net/people/henry/card#> .
   
<https://bblfish.net/people/henry/card>   a foaf:PersonalProfileDocument;
     foaf:maker :me;
     foaf:title "Henry Story's FOAF file";
     foaf:primaryTopic :me ;
     iana:alternate <https://bblfish.net/people/henry/card.rdf>, 
                    <https://bblfish.net/people/henry/card.n3> .

:me    a foaf:Person;
       = <http://bblfish.net/people/henry/card#me>;
       #pingback:to <http://pingback.aksw.org/>;
       pingback:to <https://my-profile.eu/pingback.php>;
       space:storage <https://bblfish.rww.io/cimba/> ;
       foaf:knows [ = <https://www.w3.org/People/Berners-Lee/card#i>; 
                    a foaf:Person;
                    foaf:name "Tim Berners Lee";
                  ],
                  [ = <https://my-profile.eu/people/jwinandy/card#me>;
                    a foaf:Person;
                    foaf:name "Jonathan Winandy";
                  ],
                  [ = <https://my-profile.eu/people/tim/card#me>;
                    a foaf:Person;
                    foaf:name "Tim Boudreau" ],
                  [ = <http://www.turnguard.com/turnguard>;
                    a foaf:Person;
                    foaf:name "jakobitsch jürgen";
                  ] .

Inline function arguments

I have this rule, which uses some built-ins

@prefix ch: <https://schema.ld.admin.ch/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix string: <http://www.w3.org/2000/10/swap/string#> .
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
@prefix schema: <http://schema.org/>.

{
    ?canton a ch:Canton .
    ?canton schema:alternateName ?name .
    ?name string:lowerCase ?nameLower .
    ( "http://classifications.data.admin.ch/canton/" ?nameLower ) string:concatenation ?c .
    ?classification log:uri ?c .
}
=>
{
    ?canton owl:sameAs ?classification .
} .

Is it possible to inline variables ?nameLower and ?c?

Using e:becomes

Is there a simple example someplace of how e:becomes is intended to work?

I had thought that it would be used like log:implies but that it would retract the subject graph in addition to adding the object graph. But I can’t seem to get that to work.

Here's the specific rule I am working on:

{
    ?dtd time:unitType ?unit
    . ?unit time:years ?duration
    . ?duration e:numeral ?years
    . ?years log:equalTo 100
} => {
    ?dtd time:unitType time:unitCentury
} .

I'd like to change this to use e:becomes so that the triples in the subject are retracted; i.e. the conclusion replaces the antecedent.

(Also, please let me know if there is someplace else where you would prefer I ask questions like this.)

BlankNodes getting converted literals

For the following data.n3

{ _:n3-30 ?p ?o} => {} .

the following is output

$ npx eyereasoner@latest --nope --quiet --pass-all ./data.n3 
{"some1-301" ?U_0 ?U_2} => true.

The problem seems to specifically be when there is a dash (-) in the blank node similar problems occur if there is a . in the blank node name.

Strange result with RDF* annotation syntax

@prefix : <#>.
:a is :b of :c {| :d :e |}.

produces

:c :b :a.
<<:a "isof('<file:///home/pa/recherche/2020-mosaicrown/policy_rdfstar/test.n3#b>')" :c>> :d :e.

The isof(...) in the embedded triple looks like internal representation leaking. I was expecting

:c :b :a.
<<:c :b :a>> :d :e.

@gkellogg

How to access/use http:resp [ http:body ] . json as Literal(s)???

Hey Jos!

I'm taking the next step with n3patch where i'm calling out to a web service as a function (to extend the built-ins where necessary).
Whereas we were setting literals with literals in #36, I would like to use properties from the response body as the patch.

How do I go about this in the formula/rule? I have reviewed the respath rule, but don't see where/how I can access response bodies (json) property values to use as literals?

Here is an example I have worked up. The json that will be returned from the [GET] is as follows

{
  "userId": 1,
  "id": 1,
  "title": "delectus aut autem",
  "completed": false
}

Here is the rule I have been attempting:

@prefix http: <http://www.w3.org/2011/http#>.
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
@prefix ex: <http://www.example.org/terms#>.

{ 
    ?person ex:givenName "Claudia" .
} 
=> 
{ 
    _:request http:methodName "GET" ;
        http:requestURI <https://jsonplaceholder.typicode.com/todos/1> ;
        http:resp [ http:body ?body ] .     
    ?person ex:givenName ?body .  # <<------ set with data from the response, e.g., ?body.title (illustrative)
} .

Is this a closed world limitation? I remember recently seeing some dialog where the reasoner keeps its scope only to the local environment.

Thanks for your help!!

How to use log:Includes to find a triple not in the graph

In EYE v21.0811.1752 I used these N3 rules to find subject identifiers that are not an object in the data:

PREFIX ex:   <https://www.example.org/>
PREFIX log:  <http://www.w3.org/2000/10/swap/log#>

ex:MainSubject a ex:Tweet;
    ex:message "EYE rules" .

ex:Tweet a ex:Conversation.

{
    ?id a ?class .

    ?SCOPE log:notIncludes { ?subject ?predicate ?id } .
}
=>
{
    [ ex:TopGraph ?id ].
}.

which gave as result (only new):

_:sk_2 ex:TopGraph ex:MainSubject.

In version EYE v22.0128.1551 the result is empty. I understand how log:notIncludes is interpreted changed a bit.
Is there a way to create an equivalent rule in the latest version of EYE?

Backward rule with blank node in its conclusion seems work incorrectly.

Here is an example. I want to express "For every person, there is one thing that is his/her mother", but it turn out anything could be any person's mother.

@prefix : <#>.
{?x :mother _:y} <= {?x a :person}. 
:Alice a :person.
{:Alice :mother :Alice} => {:got :weird :result1}.
{:Alice :mother :Bob} => {:got :weird :result2}.

gives me

:got :weird :result1.
:got :weird :result2.

The forward rule version works correctly.

exit code is 0 when failing to load invalid document

When failing to load a file that does not exist, eye returns exit code 1:

$ eye nonexistent.n3
eye nonexistent.n3
EYE v21.0901.2352 josd
SWI-Prolog version 8.2.4
starting 55 [msec cputime] 63 [msec walltime]
#Processed by EYE v21.0901.2352 josd
#eye nonexistent.n3

GET file:///Users/ryanshaw/Code/nonexistent.n3 ** ERROR ** gre ** error(existence_error(source_sink,/Users/ryanshaw/Code/nonexistent.n3),context(system:open/4,No such file or directory))
$ echo $?
1

But when failing to load an invalid document, eye returns exit code 0:

$ echo '{' > invalid.n3
$ eye invalid.n3
eye invalid.n3
EYE v21.0901.2352 josd
SWI-Prolog version 8.2.4
starting 57 [msec cputime] 64 [msec walltime]
#Processed by EYE v21.0901.2352 josd
#eye invalid.n3

GET file:///Users/ryanshaw/Code/invalid.n3 ** ERROR ** file:///Users/ryanshaw/Code/invalid.n3 ** invalid_document(after_line(2))
SC=0
networking 1 [msec cputime] 1 [msec walltime]
$ echo $?
0

Is this by design? It makes it difficult to debug workflows that rely on non-successful exit codes to detect problems.

Is N3 Patch as the result of a function possible??

I am attempting to change the n3patch example such that the patch is the result of a built-in function without success.... Is this possible? I am attemping to emulate the method used here: https://arxiv.org/pdf/1511.03036.pdf, e.g, Listing 3 on page 25, Listing 5 on Page 27.

Here is what I am attempting:

@prefix log: <http://www.w3.org/2000/10/swap/log#>.
@prefix ex: <http://www.example.org/terms#>.
@prefix string: <http://www.w3.org/2000/10/swap/string#>.

{ ?person ex:familyName "Garcia" . 
    { ?person ex:givenName "Claudia" }  
        log:becomes 
            { ?person ex:givenName [ is string:concatenation of ( "one" " " "two" ) ] };
            } => {} .

What I'm REALLY desiring to do:

@prefix log: <http://www.w3.org/2000/10/swap/log#>.
@prefix ex: <http://www.example.org/terms#>.
@prefix string: <http://www.w3.org/2000/10/swap/string#>.

{ ?person ex:familyName "Garcia" . 
    { ?person ex:givenName "Claudia" } 
        log:becomes 
            { ?person ex:givenName [ is string:concatenation of ( ?person!ex:givenName " " ?person!familyName ) ] };
            } => {} .

I am using the following parameters:
eye sample-data.n3 patch.n3 --pass > patched-data.n3 --debug --restricted

Here is the output (which appears to pass??):

eye sample-data.n3 patch.n3 --pass --debug --restricted
EYE v22.0409.1317 josd
SWI-Prolog version 8.4.2
starting 24 [msec cputime] 30 [msec walltime]
Mac-mini:n3patch-mapping-test martystache$ eye sample-data.n3 patch.n3 --pass > patched-data.n3 --debug --restricted
eye sample-data.n3 patch.n3 --pass --debug --restricted
EYE v22.0409.1317 josd
SWI-Prolog version 8.4.2
starting 24 [msec cputime] 30 [msec walltime]
GET file:///Users/martystache/Library/Mobile%20Documents/com~apple~CloudDocs/Xtensible/prov/templates/n3_ontology_alignment/n3patch-mapping-test/sample-data.n3 SC=4
GET file:///Users/martystache/Library/Mobile%20Documents/com~apple~CloudDocs/Xtensible/prov/templates/n3_ontology_alignment/n3patch-mapping-test/patch.n3 SC=1
networking 2 [msec cputime] 2 [msec walltime]
eam/1 entering span 0
. eam/1 selecting rule implies(('<http://www.example.org/terms#familyName>'(_4124,literal('Garcia',type('<http://www.w3.org/2001/XMLSchema#string>'))),'<http://www.w3.org/2000/10/swap/log#becomes>'('<http://www.example.org/terms#givenName>'(_4124,literal('Claudia',type('<http://www.w3.org/2001/XMLSchema#string>'))),('<http://www.example.org/terms#givenName>'(_4124,_4170),'<http://www.w3.org/2000/10/swap/string#concatenation>'([_4186,literal(' ',type('<http://www.w3.org/2001/XMLSchema#string>')),_4208],_4170),'<http://www.example.org/terms#givenName>'(_4124,_4186),'<http://www.example.org/terms#familyName>'(_4124,_4208)))),true,'<file:///Users/martystache/Library/Mobile%20Documents/com~apple~CloudDocs/Xtensible/prov/templates/n3_ontology_alignment/n3patch-mapping-test/patch.n3>')
. eam/1 selecting rule implies(exopred(_4118,_4120,_4122),answer(_4118,_4120,_4122),'<http://eulersharp.sourceforge.net/2003/03swap/pass>')
... eam/1 assert step answer('<http://www.example.org/terms#familyName>','<http://www.example.org/terms#pers001>',literal('Garcia',type('<http://www.w3.org/2001/XMLSchema#string>')))
... eam/1 assert step answer('<http://www.example.org/terms#familyName>','<http://www.example.org/terms#pers002>',literal('Cardinale',type('<http://www.w3.org/2001/XMLSchema#string>')))
... eam/1 assert step answer('<http://www.example.org/terms#givenName>','<http://www.example.org/terms#pers001>',literal('Claudia',type('<http://www.w3.org/2001/XMLSchema#string>')))
... eam/1 assert step answer('<http://www.example.org/terms#givenName>','<http://www.example.org/terms#pers002>',literal('Claudia',type('<http://www.w3.org/2001/XMLSchema#string>')))
eam/1 entering span 0
. eam/1 selecting rule implies(('<http://www.example.org/terms#familyName>'(_4278,literal('Garcia',type('<http://www.w3.org/2001/XMLSchema#string>'))),'<http://www.w3.org/2000/10/swap/log#becomes>'('<http://www.example.org/terms#givenName>'(_4278,literal('Claudia',type('<http://www.w3.org/2001/XMLSchema#string>'))),('<http://www.example.org/terms#givenName>'(_4278,_4324),'<http://www.w3.org/2000/10/swap/string#concatenation>'([_4340,literal(' ',type('<http://www.w3.org/2001/XMLSchema#string>')),_4362],_4324),'<http://www.example.org/terms#givenName>'(_4278,_4340),'<http://www.example.org/terms#familyName>'(_4278,_4362)))),true,'<file:///Users/martystache/Library/Mobile%20Documents/com~apple~CloudDocs/Xtensible/prov/templates/n3_ontology_alignment/n3patch-mapping-test/patch.n3>')
. eam/1 selecting rule implies(exopred(_4272,_4274,_4276),answer(_4272,_4274,_4276),'<http://eulersharp.sourceforge.net/2003/03swap/pass>')
reasoning 1 [msec cputime] 1 [msec walltime]
2022-04-15T21:35:33.817Z in=5 out=4 ent=4 step=8 brake=2 inf=35304 sec=0.027 inf/sec=1307556

Eye produces duplicate outputs

A duplicate output is produced

$ npx eyereasoner --nope --quiet --pass-all ./data.n3 
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
@prefix : <http://example.org/>.

:a :b :c.
:a :b :c.

using the folllowing data.n3

@prefix log: <http://www.w3.org/2000/10/swap/log#> .
@prefix : <http://example.org/> .

{ :a :b :c } <= {} .

Using n-quads

Merry Christmas - please respond to this after your break! I am now signing off for the evening anyway


In order to do the Sochrates query using RDF/JS quads in the eye-js package; I first want to convert to n-quads (it is the easiest thing to write using n3.js); which means my data looks like

<http://example.org/socrates#Socrates> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.org/socrates#Human> .
    <http://example.org/socrates#Human> <http://www.w3.org/2000/01/rdf-schema#subClassOf> <http://example.org/socrates#Mortal> .
    ?A <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?B _:b1 .
    ?S <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?A _:b1 .
    ?S <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?B _:b2 .
    _:b1 <http://www.w3.org/2000/10/swap/log#implies> _:b2 .

and my query looks like

<http://example.org/socrates#Socrates> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?WHAT _:b1 .
<http://example.org/socrates#Socrates> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?WHAT _:b2 .
_:b1 <http://www.w3.org/2000/10/swap/log#implies> _:b2 .

When I try and run this in a query I get a syntax error on the last line of each file/ Is there an easy way of resolving this?

Bug: Eye does not always treat the empty list as `rdf:nil`

For the following data.n3

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix : <https://example.org/ns/1/> .

rdf:nil :p :o .

{
  () ?p ?o .
} => {
  :s ?p ?o .
} .

There are no derivations

$ npx eyereasoner --nope --quiet --pass-only-new ./listTest.n3 
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix : <https://example.org/ns/1/>.

I would expect :s :p :o to be derived as rdf:nil ?p ?o matches the pattern () ?p ?o.

list:remove keeps the member

In eye v22.0827.1120 I tried:

@prefix : <urn:example:> .
{ (("a" "b" "c") "c") list:remove ("a" "b") } => { :test1 a :SUCCESS } .
{ (("a" "b" "c") "c") list:remove ("a" "b" "c") } => { :test2 a :FAILURE } .

and got as result

<urn:example:test2> a <urn:example:FAILURE>.

"INF"^^xsd:double and "-INF"^^xsd:double are not supported

According to the datatype definition, xsd:double contains two infinite values INF and -INF such that

INF is greater than all other non-NaN values; −INF is less than all other non-NaN values.

So the following two tests should pass.

{ "INF"^^xsd:double math:greaterThan 42 } => { :TEST :PASS 1 }.
{ "-INF"^^xsd:double math:lessThan -42 } => { :TEST :PASS 2 }.

They both fail in EYE, while they pass in CWM.

NB: the same problem exists with xsd:float.

@gkellogg this would be worth adding in the N3 test suite, if it is not already there...

Named graphs

I'm not sure how to formulate the question correctly, but is it possible to make it work with named graphs (quads mode)?

A backward rule nested in the conclusion of a forward rule cause EYE to freeze

It seems that rules of the form like formula1 => {formula2 <= formula3} are not supported by EYE, and cause the reasoner to get stuck, but in some cases this is the only way to achieve my requirement, and I can’t think of a way to work around it.

For example, In the example below, the predicate in the conclusion of a rule is a variable, and the rule also need to be a backward rule itself:

@prefix : <#>.
:know :type :Reflexive.
{:Alice :know :Alice} => {:TEST :PASS 1}.

# {?x ?p ?x} <= {?p :type :Reflexive}.  # doesn't work, not surprising
# {?p :type :Reflexive} =>  {?x ?p ?x}.  # doesn't work either, not surprising
{?p :type :Reflexive} =>  {@forAll :x. {:x ?p :x} <= true }.  # I hope this works

With eye ./test.n3 —nope —pass-only-new what I expected to get:

{ ?x :know  ?x} <= true.   # I expect that `:know` is bound to `?p`  in the nested rule, and produce this rule.
:TEST :PASS 1.

But the actual result is that EYE get stuck.

Another example where nested rules of this form need to be used:

@prefix log: <http://www.w3.org/2000/10/swap/log#>.
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

log:rawType :sub-property-of :type.
{1 type rdfs:Literal } => {:TEST :PASS 2}.

#{?a ?p2 ?b} <= {?a ?p1 ?b. ?p1 :sub-property-of ?p2}.
#{?p1 :sub-property-of ?p2. ?a ?p1 ?b} => {?a ?p2 ?b} .
{?p1 :sub-property-of ?p2 } => {@forAll :a, :b. {:a ?p2 :b} <= {:a ?p1 :b} }.

error of recursive backward rule

{{:x :y :z} <= {:a :b :c}} <= {:d :e :f}.
The simple one line code above give me error:
** ERROR ** gre ** error(permission_error(modify,static_procedure,(:-)/2),context(system:assertz/1,_5794))
Or maybe this test case could be more simplified:
{:x <= :y} <= :z. #same error

Missing inference involving hasValue restriction and domain

I have the following N3 file

:hasSpine rdfs:domain :Animal.
:Chordate rdfs:subClassOf [
    a owl:Restriction ;
    owl:onProperty :hasSpine ;
    owl:hasValue true;
].

which I use together with all OWL-related files (eye/reasoning/rpo/[ro]*.n3).
I was expecting EYE to infer the following triple:

:Chordate rdfs:subClassOf :Animal.

but it didn't. Protégé (with Hermit) did, on the other hand.

I solved it with the following axiom:

{ ?c rdfs:subClassOf [ owl:onProperty [ rdfs:domain ?d ]; owl:hasValue [] ] }
=>
{ ?c rdfs:subClassOf ?d }.

I think this axiom should be added (as well as related axioms for owl:someValuesFrom, owl:minCardinality (>0) and owl:exactCardinality (>0)) to the relevant files in reasoning/rpo/.

Built-ins can’t use e:Scope parameter to refer to other n3 files.

Here is my test case:

$ cat test-a.n3
PREFIX : <http://www.example.com/test#> 
PREFIX e: <http://eulersharp.sourceforge.net/2003/03swap/log-rules#>
:a :b :c.
{((<>) 1) e:call {:a :b :c} } => {:TEST :PASS 1}. 
{((<./test-b.n3> ) 1) e:call {:a :b :c} } => {:TEST :PASS 2}. #don’t  work
{((<> <./test-b.n3> ) 1) e:call {:a :b :c} } => {:TEST :PASS 3}. #don’t  work

$cat test-b.n3
PREFIX : <http://www.example.com/test#> 
:a :b :c.

$ eye --pass-only-new --nope ./test-a.n3
:TEST :PASS 1 .

I also tried other build-ins with e:Scope parameter, such as e:findall, and got similar result.
Is this a bug?

BUG: Unexpected interpretation of explicit list

Unexpected interpretation of explicit list

data.n3


@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
[] rdf:first 0 ;
  rdf:rest rdf:nil .

Is interpreted as

$ npx eyereasoner --nope --quiet --pass-all ./listTest.n3 
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.

(0) rdf:first 0 .
(0) rdf:rest rdf:nil.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.