eyereasoner / eye

Euler Yet another proof Engine
https://eyereasoner.github.io/eye/
MIT License
124 stars 17 forks source link

Foreign predicate shell/2 did not clear exception: error(system_error,context(shell/2,Function not implemented)) #99

Closed jeswr closed 1 year ago

jeswr commented 1 year ago

Tested using eye v8.1.0 (via eye-js)

Not sure where to start debugging on this one. We get the following error when the command eye --nope --quiet --no-qnames data_0.n3s data_1.n3s data_2.n3s is run with the 3 files given below. However when any of the files are omitted from the command the error does not occur.

/home/jesght/Documents/GitHub/SolidLabResearch/ConversationalDataExchange/server_agent/node_modules/eyereasoner/dist/transformers.js:102
        throw new Error(`Error while executing query: ${err.join('\n')}`);
              ^

Error: Error while executing query: Foreign predicate shell/2 did not clear exception: error(system_error,context(shell/2,Function not implemented))
Foreign predicate shell/2 did not clear exception: error(system_error,context(shell/2,Function not implemented))
Foreign predicate shell/2 did not clear exception: error(system_error,context(shell/2,Function not implemented))
** ERROR ** eam ** error(existence_error(source_sink,/tmp/swipl_eye_42_14),context(system:open/4,No such file or directory))
    at executeBasicEyeQuery (/home/jesght/Documents/GitHub/SolidLabResearch/ConversationalDataExchange/server_agent/node_modules/eyereasoner/dist/transformers.js:102:15)

data_0.n3s

<https://myuserpod.com/rubend/profile/card#me> <http://www.w3.org/2006/vcard/ns#bday> "1995-11-08T00:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime>.

data_1.n3s

() <urn:dialog:onVerifiedSurface> {
    <urn:dialog:message:1698934228184> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <urn:dialog:DialogMessage>.
    <urn:dialog:message:1698934228184> <urn:dialog:actor> <https://myuserpod.com/rubend/profile/card#me>.
    <urn:dialog:message:1698934228184> <urn:dialog:issuer> <https://myuserpod.com/>.
    <urn:dialog:message:1698934228184> <urn:dialog:client> <https://storeapp.com>.
    <urn:dialog:message:1698934228184> <urn:dialog:endpoint> <https://myuserpod.com/agent/endpoint/>.
    <urn:dialog:message:1698934228184> <urn:dialog:contents> <file:///data_0.n3s>.
}.

data_2.n3s

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

@prefix fn: <http://www.w3.org/2006/xpath-functions#>.
@prefix crypto: <http://www.w3.org/2000/10/swap/crypto#>.
@prefix graph: <http://www.w3.org/2000/10/swap/graph#>.
@prefix log: <http://www.w3.org/2000/10/swap/log#> .
@prefix time: <http://www.w3.org/2000/10/swap/time#> .
@prefix func: <http://www.w3.org/2007/rif-builtin-function#>.
@prefix math: <http://www.w3.org/2000/10/swap/math#>.

@prefix vcard: <http://www.w3.org/2006/vcard/ns#> .
@prefix dialog: <urn:dialog:> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.

@prefix rulelogic: <urn:rule:logic:>.

# Assert validated birthdays
(
    _:Graffiti _:G
    _:Actor _:BirthDate
) log:onNegativeSurface {
    _:Graffiti dialog:onVerifiedSurface _:G.
    _:G log:includes {
        _:Actor vcard:bday _:BirthDate.
    }.
    () log:onNegativeSurface {
        _:Actor vcard:bday _:BirthDate .
    }.
}.

# Check for present actor
(
    _:Graffiti _:G
    _:Message _:Actor
    _:Result _:Warning

    _:AssertedGraph
    _:SCOPE
) log:onNegativeSurface {
    (
        {
            _:Graffiti dialog:onVerifiedSurface _:G.
            _:G log:includes {
                _:Message a dialog:DialogMessage.
                _:Message dialog:actor _:Actor.
            }
        }
        { _:AssertedGraph log:equalTo {} }
        { 
            _:AssertedGraph log:equalTo {
                () log:onWarningSurface {
                    _:Warning a dialog:Warning;
                        dialog:message "No actor was present in the dialog message. No alcoholic beverages will be displayed";
                        dialog:questions { 
                            (
                                _:VerifiedSurface _:RequestedActor _:BirthDate
                            ) dialog:onQuestionSurface { 
                                () dialog:onVerifiedSurface _:VerifiedSurface.
                                () log:onAnswerSurface {
                                    _:VerifiedSurface log:includes {
                                        _:Message dialog:actor _:RequestedActor.
                                        _:RequestedActor vcard:bday _:BirthDate.
                                    }.
                                }.
                            }. 
                        }.
                }.
            }.
        }
    ) log:ifThenElseIn _:SCOPE .
    () log:onNegativeSurface _:AssertedGraph.
}.

# Check for present birthdate
(
    _:Graffiti _:G
    _:Message _:Actor _:BirthDate
    _:Result _:Warning

    _:AssertedGraph
    _:SCOPE
) log:onNegativeSurface {

    _:Graffiti dialog:onVerifiedSurface _:G.
    _:G log:includes {
        _:Message a dialog:DialogMessage.
        _:Message dialog:actor _:Actor.
    }.
    (
       {  _:Actor vcard:bday _:BirthDate. }
       { _:AssertedGraph log:equalTo {}. }
       { 
            _:AssertedGraph log:equalTo {
                () log:onWarningSurface {
                    _:Warning a dialog:Warning;
                        dialog:message "No actor birthdate was given. No alcoholic beverages will be displayed";
                        dialog:questions { 
                            (_:RequestedBirthDate)  dialog:onQuestionSurface { 
                                _:Actor vcard:bday _:RequestedBirthDate.
                                () log:onAnswerSurface {
                                _:Actor vcard:bday _:RequestedBirthDate.
                                }.
                            } 
                        }.
                }.
            }.
        }
    ) log:ifThenElseIn _:SCOPE .
    () log:onNegativeSurface _:AssertedGraph.
}.

# Check if older than 18
(
    _:Graffiti _:G
    _:Message
    _:Actor
    _:BirthDate

    _:LocalTime
    _:DateToCheck

    _:AssertedGraph
    _:Warning
) log:onNegativeSurface {

    _:Graffiti dialog:onVerifiedSurface _:G.
    _:G log:includes {
        _:Message a dialog:DialogMessage.
        _:Message dialog:actor _:Actor.
    }.
    _:Actor vcard:bday _:BirthDate.

    "" time:localTime _:LocalTime.
    (_:LocalTime "P18Y0M"^^xsd:yearMonthDuration) func:subtract-yearMonthDuration-from-dateTime _:DateToCheck.

    # Check if the actor was born before 18 years ago

    (
        { _:BirthDate math:lessThan _:DateToCheck. }
        { 
            _:AssertedGraph log:equalTo { _:Actor a rulelogic:Adult. }.
        }
        { 
            _:AssertedGraph log:equalTo {
                () log:onWarningSurface {
                    _:Warning a dialog:Warning;
                        dialog:message "Actor is a minor. No alcoholic beverages will be displayed".
                    # This does not warrant an additional question. We have sufficient information to decide we should not show alcoholic beverages
                }.
            }.
        }
    ) log:ifThenElseIn _:SCOPE .
    () log:onNegativeSurface _:AssertedGraph.
}.
josd commented 1 year ago

There is a missing declaration of _:SCOPE in the graffiti of the last surface in data_2.n3s Adding it like

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

@prefix fn: <http://www.w3.org/2006/xpath-functions#>.
@prefix crypto: <http://www.w3.org/2000/10/swap/crypto#>.
@prefix graph: <http://www.w3.org/2000/10/swap/graph#>.
@prefix log: <http://www.w3.org/2000/10/swap/log#> .
@prefix time: <http://www.w3.org/2000/10/swap/time#> .
@prefix func: <http://www.w3.org/2007/rif-builtin-function#>.
@prefix math: <http://www.w3.org/2000/10/swap/math#>.

@prefix vcard: <http://www.w3.org/2006/vcard/ns#> .
@prefix dialog: <urn:dialog:> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.

@prefix rulelogic: <urn:rule:logic:>.

# Assert validated birthdays
(
    _:Graffiti _:G
    _:Actor _:BirthDate
) log:onNegativeSurface {
    _:Graffiti dialog:onVerifiedSurface _:G.
    _:G log:includes {
        _:Actor vcard:bday _:BirthDate.
    }.
    () log:onNegativeSurface {
        _:Actor vcard:bday _:BirthDate .
    }.
}.

# Check for present actor
(
    _:Graffiti _:G
    _:Message _:Actor
    _:Result _:Warning

    _:AssertedGraph
    _:SCOPE
) log:onNegativeSurface {
    (
        {
            _:Graffiti dialog:onVerifiedSurface _:G.
            _:G log:includes {
                _:Message a dialog:DialogMessage.
                _:Message dialog:actor _:Actor.
            }
        }
        { _:AssertedGraph log:equalTo {} }
        { 
            _:AssertedGraph log:equalTo {
                () log:onWarningSurface {
                    _:Warning a dialog:Warning;
                        dialog:message "No actor was present in the dialog message. No alcoholic beverages will be displayed";
                        dialog:questions { 
                            (
                                _:VerifiedSurface _:RequestedActor _:BirthDate
                            ) dialog:onQuestionSurface { 
                                () dialog:onVerifiedSurface _:VerifiedSurface.
                                () log:onAnswerSurface {
                                    _:VerifiedSurface log:includes {
                                        _:Message dialog:actor _:RequestedActor.
                                        _:RequestedActor vcard:bday _:BirthDate.
                                    }.
                                }.
                            }. 
                        }.
                }.
            }.
        }
    ) log:ifThenElseIn _:SCOPE .
    () log:onNegativeSurface _:AssertedGraph.
}.

# Check for present birthdate
(
    _:Graffiti _:G
    _:Message _:Actor _:BirthDate
    _:Result _:Warning

    _:AssertedGraph
    _:SCOPE
) log:onNegativeSurface {

    _:Graffiti dialog:onVerifiedSurface _:G.
    _:G log:includes {
        _:Message a dialog:DialogMessage.
        _:Message dialog:actor _:Actor.
    }.
    (
       {  _:Actor vcard:bday _:BirthDate. }
       { _:AssertedGraph log:equalTo {}. }
       { 
            _:AssertedGraph log:equalTo {
                () log:onWarningSurface {
                    _:Warning a dialog:Warning;
                        dialog:message "No actor birthdate was given. No alcoholic beverages will be displayed";
                        dialog:questions { 
                            (_:RequestedBirthDate)  dialog:onQuestionSurface { 
                                _:Actor vcard:bday _:RequestedBirthDate.
                                () log:onAnswerSurface {
                                _:Actor vcard:bday _:RequestedBirthDate.
                                }.
                            } 
                        }.
                }.
            }.
        }
    ) log:ifThenElseIn _:SCOPE .
    () log:onNegativeSurface _:AssertedGraph.
}.

# Check if older than 18
(
    _:Graffiti _:G
    _:Message
    _:Actor
    _:BirthDate

    _:LocalTime
    _:DateToCheck

    _:AssertedGraph
    _:Warning
    _:SCOPE
) log:onNegativeSurface {

    _:Graffiti dialog:onVerifiedSurface _:G.
    _:G log:includes {
        _:Message a dialog:DialogMessage.
        _:Message dialog:actor _:Actor.
    }.
    _:Actor vcard:bday _:BirthDate.

    "" time:localTime _:LocalTime.
    (_:LocalTime "P18Y0M"^^xsd:yearMonthDuration) func:subtract-yearMonthDuration-from-dateTime _:DateToCheck.

    # Check if the actor was born before 18 years ago

    (
        { _:BirthDate math:lessThan _:DateToCheck. }
        { 
            _:AssertedGraph log:equalTo { _:Actor a rulelogic:Adult. }.
        }
        { 
            _:AssertedGraph log:equalTo {
                () log:onWarningSurface {
                    _:Warning a dialog:Warning;
                        dialog:message "Actor is a minor. No alcoholic beverages will be displayed".
                    # This does not warrant an additional question. We have sufficient information to decide we should not show alcoholic beverages
                }.
            }.
        }
    ) log:ifThenElseIn _:SCOPE .
    () log:onNegativeSurface _:AssertedGraph.
}.

makes the eye-js eyereasoner happy

$ eyereasoner --nope --quiet --no-qnames data_0.n3s data_1.n3s data_2.n3s --pass-only-new

<https://myuserpod.com/rubend/profile/card#me> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <urn:rule:logic:Adult>.

The error message is indeed tricky, what happens is that log:ifThenElseIn for a non-variable scope is invoking another reasoner instance (via shell/2) to run the log:ifThenElseIn in that external scope.

jeswr commented 1 year ago

This fixes it - thanks!