All Manuals > KnowledgeWorks and Prolog User Guide > 7 Reference Guide

any Function

Summary

Return the first match of a backward chaining goal.

Package

kw

Signature

any pattern-to-instantiate goal-to-prove => result, successp

Arguments
pattern-to-instantiate
A list or symbol.
goal-to-prove
Any backward chaining goal.
Values
result
nil or a value matching pattern-to-instantiate.
successp
A boolean.
Description

The function any starts the backward chaining inference engine to look for any set of bindings which satisfy goal-to-prove. Using those bindings, pattern-to-instantiate is instantiated and returned.

Two values are returned. The second value indicates with t that a proof was found, or with nil that no proof exists. In the former case, the first value is the instantiated version of pattern-to-instantiate, in the latter case, the first value is nil.

Any subgoals that match the object base will only find objects from the current inferencing state.

Examples
(any '(?x is in (1 2 3)) '(member ?x (1 2 3)))

returns (1 IS IN (1 2 3)), T.

(any '(?truck is a truck) '(truck ?truck))

returns (#<TRUCK TRUCK5> IS A TRUCK), T.

See also

findall


KnowledgeWorks and Prolog User Guide (Windows version) - 01 Dec 2021 19:36:03