-
Notifications
You must be signed in to change notification settings - Fork 28
Open
Labels
answeredTutorial question is answered but not added to docsTutorial question is answered but not added to docshelp wantedExtra attention is neededExtra attention is neededquestionFurther information is requestedFurther information is requestedtutorialTutorial questionTutorial question
Description
Suppose we have the following knowledge base:
(Parent Tom Bob)
(Parent Pam Bob)
(Parent Tom Liz)
(Parent Bob Ann)
(Parent Bob Pat)
(Parent Pat Jim)
(Parent Jim Lil)
How to implement transitive closure through the loop of the match-based rules below in the most efficient way?
!(match &self (Parent $x $y) (add-atom &self (Predecessor $x $y)))
!(match &self (, (Parent $x $y) (Predecessor $y $z)) (add-atom &self (Predecessor $x $z)))
The main parts of the question are:
how to effectively check immutability of the space to stop the loop?
and how to effectively populate space with intermediate inference results without duplicates of what's been done on the previous steps?
For now I'm doing the last with the "function" like that (from this issue)
(= (not_exist $pattern)
(unify &self $pattern Fasle True))
but it seems kinda awkward.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
answeredTutorial question is answered but not added to docsTutorial question is answered but not added to docshelp wantedExtra attention is neededExtra attention is neededquestionFurther information is requestedFurther information is requestedtutorialTutorial questionTutorial question