Return all matches of a backward chaining goal.
kw
findall pattern-to-instantiate goal-to-prove => list
findallset pattern-to-instantiate goal-to-prove => set
pattern-to-instantiate⇩ | |
A list or symbol. | |
goal-to-prove⇩ |
Any backward chaining goal. |
list |
A list. |
set⇩ |
A list. |
The function findall
starts the backward chaining inference engine to look for all sets of bindings which satisfy goal-to-prove. For each of those bindings, pattern-to-instantiate is instantiated and collected to return a list. The value is nil
if nothing goal-to-prove cannot be satisfied.
Any subgoals that match the object base will only find objects from the current inferencing state.
The function findallset
is like findall
but set will not have any duplicates (as compared by equal).
(findall '(?x is in (1 2 3)) '(member ?x (1 2 3)))
returns:
((1 IS IN (1 2 3)) (2 IS IN (1 2 3)) (3 IS IN (1 2 3)))
(findall '(?truck is a truck) '(truck ?truck))
returns:
((#<TRUCK TRUCK1> IS A TRUCK) (#<TRUCK TRUCK2> IS A TRUCK))
KnowledgeWorks and Prolog User Guide (Unix version) - 01 Dec 2021 19:35:49