SemanticApplicationDesignLanguage / sadl

Semantic Application Design Language (SADL) Open Source Code
http://semanticapplicationdesignlanguage.github.io/sadl/
Eclipse Public License 1.0
30 stars 12 forks source link

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

Open crapo opened 2 years ago

crapo commented 2 years ago

Reported by @AbhaMoitra .

crapo commented 2 years ago

@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 commented 2 years ago

I’ll need to prune my model while still retaining the issue and then “simplify” it and then I’ll post it on GIT.

BTW the 3rd thing I had mentioned (no error but no rule generated), I have not been able to recreate. I did not capture the noValue construct I had used so lets forget about it until I observe it again.

From: Andrew Crapo @.> Sent: Tuesday, October 5, 2021 12:30 PM To: SemanticApplicationDesignLanguage/sadl @.> Cc: Moitra, Abha (GE Research, US) @.>; Mention @.> Subject: EXT: Re: [SemanticApplicationDesignLanguage/sadl] Explanation of higher-stage staged rules doesn't work. (#806)

@AbhaMoitrahttps://github.com/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.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/SemanticApplicationDesignLanguage/sadl/issues/806#issuecomment-934568071, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AGZX3GZKDN5M5R3DO75DR3TUFMRXBANCNFSM5FL3ZO6A. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

AbhaMoitra commented 2 years ago

@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 commented 2 years ago

@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 commented 2 years ago

@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 commented 2 years ago

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

AbhaMoitra commented 2 years ago

@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.