Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explanation of higher-stage staged rules doesn't work. #806

Open
crapo opened this issue Oct 5, 2021 · 7 comments
Open

Explanation of higher-stage staged rules doesn't work. #806

crapo opened this issue Oct 5, 2021 · 7 comments
Assignees
Labels

Comments

@crapo
Copy link
Collaborator

crapo commented Oct 5, 2021

Reported by @AbhaMoitra .

@crapo crapo added the bug label Oct 5, 2021
@crapo crapo self-assigned this Oct 5, 2021
@crapo
Copy link
Collaborator Author

crapo commented Oct 5, 2021

@AbhaMoitra , might need a little help with this as I'm not seeing what I expected. Running this model
'''
Thingy is a top-level class.
Color is a top-level class, must be one of {Black, White, Green}.
dp describes Thingy has values of type float.
op describes Thingy has values of type Color.

Stage 1 Rule StageOneRule
given
x is a Thingy
if
dp of x > 2
then
op of x is Black.

Stage 2 Rule StageTwoRule
given
x is a Thingy
if
op of x is not known
then
op of x is Green.

MyThing1 is a Thingy.
MyThing2 is a Thingy, has dp 2.5 .

Explain: Rule StageOneRule.
Explain: Rule StageTwoRule.
'''
gives this result:
'''
Inference of '/home/camfe/andy/ws/sadl/runtime-EclipseApplication2/DefaultValues2/TestTwoLevelDefaults.sadl' requested.
Reasoner family: Jena-Based (com.ge.research.sadl.jena.reasoner.JenaReasonerPlugin), version date 12 April 2021.
Explanation of Rule StageOneRule:
Rule StageOneRule: Premise 1 of 3: rdf(x, type, Thingy):
Premises through 1 had 2 matches.
(SPARQL Query: select ?x where {?x http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://sadl.imp/TestTwoLevelDefaults#Thingy })
x
http://sadl.imp/TestTwoLevelDefaults#MyThing2
http://sadl.imp/TestTwoLevelDefaults#MyThing1
Rule StageOneRule: Premise 2 of 3: rdf(x, dp, v0):
Premises through 2 had 1 matches.
(SPARQL Query: select ?x ?v0 where {?x http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://sadl.imp/TestTwoLevelDefaults#Thingy . ?x http://sadl.imp/TestTwoLevelDefaults#dp ?v0 })
x, v0
http://sadl.imp/TestTwoLevelDefaults#MyThing2, 2.5
Rule StageOneRule: Premise 3 of 3: greaterThan(v0,2):
Premises through 3 had 1 matches.
(SPARQL Query: select ?x ?v0 where {?x http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://sadl.imp/TestTwoLevelDefaults#Thingy . ?x http://sadl.imp/TestTwoLevelDefaults#dp ?v0 . FILTER(?v0 > 2)})
x, v0
http://sadl.imp/TestTwoLevelDefaults#MyThing2, 2.5
Explanation of Rule StageTwoRule:
Rule StageTwoRule: Premise 1 of 2: rdf(x, type, Thingy):
Premises through 1 had 2 matches.
(SPARQL Query: select ?x where {?x http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://sadl.imp/TestTwoLevelDefaults#Thingy })
x
http://sadl.imp/TestTwoLevelDefaults#MyThing2
http://sadl.imp/TestTwoLevelDefaults#MyThing1
Rule StageTwoRule: Premise 2 of 2: noValue(x,op):
Premises through 2 had no matches.
(SPARQL Query equivalent: select ?x where {?x http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://sadl.imp/TestTwoLevelDefaults#Thingy . FILTER(NOT EXISTS { ?x http://sadl.imp/TestTwoLevelDefaults#op ?unspecified_value })})
'''

If I only explain StageTwoRule I get that explanation.

@AbhaMoitra
Copy link
Collaborator

AbhaMoitra commented Oct 5, 2021 via email

@AbhaMoitra
Copy link
Collaborator

@crapo here is a small snippet (2 files) that shows the issue - see the comments in the code.

TestExplain.sadl is as follows
uri "http://sadl.org/TestExplain.sadl".

import "http://www.w3.org/1999/02/22-rdf-syntax-ns".

Temp is a class.
Temp2 is a class.

// If I keep rule Transitive2 then I do not get an explanation of rule Test;
// but if I comment out rule Transitive2 then I get an explanation for rule Test.

Rule Transitive2
if inst is a cls
and cls is a type of cls2
then inst is a cls2.

Stage 1 Rule Test
if et is a Temp
then et is a Temp2.

Explain: Rule Test.

Ask: "select * where {?x ?y ?z} limit 2".

file rdf.sadl is as follows
uri "http://www.w3.org/1999/02/22-rdf-syntax-ns" alias rdf.

^type is a property.

The console output I see is as follows
Inference of 'C:\Sadl3Workspace21\TestExplain\TestExplain.sadl' requested.
Reasoner family: Jena-Based (com.naturalsemanticsllc.sadl.reasoner.JenaAugmentedReasonerPlugin), version date 12 April 2021.
Explanation of Rule Test:
Failed to get explanation for rule 'Test'. Rule not in loaded rule set.
Query: select * where {?x ?y ?z} limit 2
"x","y","z"
"isListHead","type","893b57a8-1047-46f9-8eae-9775d08d28d1(blank node)"
"isListHead","type","56f98395-b397-4716-8a0f-4c590d6d3e7c(blank node)"

I am using augmented reasoner.

@crapo
Copy link
Collaborator Author

crapo commented Oct 7, 2021

@AbhaMoitra , I created the two models in a new project, copying the content from your comment above. When I run "Test Model" I get the following:
'''
Inference of '/home/camfe/andy/ws/sadl/runtime-EclipseApplication2/GH-806/TestExplain.sadl' requested.
Reasoner family: Jena-Based (com.ge.research.sadl.jena.reasoner.JenaReasonerPlugin), version date 12 April 2021.
Explanation of Rule Test:
Rule Test: Premise 1 of 1: rdf(et, type, Temp):
Premises through 1 had no matches.
(SPARQL Query equivalent: select ?et where {?et http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://sadl.org/TestExplain.sadl#Temp })
Query: select * where {?x ?y ?z} limit 2
"x","y","z"
"isListHead","type","e1bb4cd0-7af5-4b6f-84c2-36fedd0f4bc2(blank node)"
"isListHead","type","b43e099f-bf28-4a68-8f0c-3eaedfa90753(blank node)"
'''

Obviously something is different... Ideas? What version are you running? Not that I recall any recent changes that seem like they would affect this.... Note that I reloaded, exited Eclipse and restarted, trying to reproduce.

@crapo
Copy link
Collaborator Author

crapo commented Oct 7, 2021

@AbhaMoitra , just for fun, I added the statement "InstOfTemp is a Temp." Then ran Test Model. Got this as I expected:
'''
Inference of '/home/camfe/andy/ws/sadl/runtime-EclipseApplication2/GH-806/TestExplain.sadl' requested.
Reasoner family: Jena-Based (com.ge.research.sadl.jena.reasoner.JenaReasonerPlugin), version date 12 April 2021.
Explanation of Rule Test:
Rule Test: Premise 1 of 1: rdf(et, type, Temp):
Premises through 1 had 1 matches.
(SPARQL Query: select ?et where {?et http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://sadl.org/TestExplain.sadl#Temp })
et
http://sadl.org/TestExplain.sadl#InstOfTemp
Query: select * where {?x ?y ?z} limit 2
"x","y","z"
"isListHead","type","97479966-988b-435d-adda-7431c8bf92e3(blank node)"
"isListHead","type","b0f48fc8-7b2e-42e8-b4ab-6172abdd9c96(blank node)"
'''

@crapo
Copy link
Collaborator Author

crapo commented Dec 8, 2021

@AbhaMoitra , I think I haven't been able to reproduce this error. Do you still see the issue with your updated version?

@AbhaMoitra
Copy link
Collaborator

@crapo : I will need to verify. Right now I am running into some issues with the SADL update of 11/30/2021 on one of my projects. I need to sort that out first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants