Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Predicate control in Prolog

Tags:

People also ask

What is a predicate in Prolog?

A Prolog program consists of predicate definitions. A predicate denotes a property or relationship between objects. Definitions consist of clauses. A clause has a head and a body (Rule) or just a head (Fact). A head consists of a predicate name and arguments.

What is the control structure used in Prolog?

Prolog uses a stack to keep track of the levels of predicate calls. In the case of a recursive predicate, the stack grows at each recursive call. In this example, with its complex arguments, the stack could easily be consumed in a shortperiod of time by the recursive control structure.

Why not predicate is used in Prolog?

Prolog in Artificial Intelligence The not predicate is used to negate some statement, which means, when a statement is true, then not(statement) will be false, otherwise if the statement is false, then not(statement) will be true. If X and Y match, then different(X,Y) fails, Otherwise different(X,Y) succeeds.

How does Prolog try to satisfy a predicate?

Goals relating to user-defined predicates are evaluated by examining the database of rules and facts loaded by the user. Prolog attempts to satisfy a goal by matching it with the heads of clauses in the database, working from top to bottom.


Have a curiosity related to Prolog predicate control.

Supposedly I have a predicate f(A,X) and g(B).

f(A,X):- a,b,c, g(X).
g(B):- true.

a - returns true
b - returns true.
c - returns false.
where a,b and c are random predicates.

How can I continue to evaluate g(X) in the predicate f(A,X) if c returns false?