How can I check if a predicate exists in a Prolog program? That would be an exists/1, like:
?- exists(some_predicate).
false.
?- assert(some_predicate).
true.
?- exists(some_predicate).
true.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use current_predicate/1, current_predicate/2 or predicate_property/2 (for the last you will probably need functor/3):
current_predicate/2andpredicate_property/2(with visible) succeeds if the predicate can be autoloaded whilecurrrent_predicate/1fails