Milan Todorovic
Milan Todorovic

Reputation: 440

Prolog existence_error for predicate in generated prolog file

I'm having a problem with a program that I'm writing. The program takes an input and generates a prolog program based on it. It generates something like this:

test(A):-condA(A),condB(A).
condA(val).
condB(val).

My problem is that sometimes, there is no condB(val), or condB anywhere in the program, except in the above definition of test. In that case, I got existence_error for condB, when I try to ask test(val), for example. Is there a way to add something to the prolog program that would define condB as false for all values of it's argument?

I'm sorry if this is stupid question, as I'm new to prolog.

Upvotes: 2

Views: 85

Answers (2)

Vojacejo
Vojacejo

Reputation: 31

Answer to your question is simple.

condB(_):-fail.

the symbol '_' is free variable.

Upvotes: 0

gusbro
gusbro

Reputation: 22585

You can tell the prolog processor that condB/1 is dynamic:

:-dynamic condB/1.

Upvotes: 4

Related Questions