Javatpoint Logo
Javatpoint Logo

Predicates in Prolog

There was a simple program that has five clauses. Head is a compound term for each first three clauses with functor parent. It has two arguments with 2 arity.

The following program includes the clauses for which functor parent is contained by the head, but a different arity.

For example:

In the same program, we can also use a parent as an atom.

For example

The above example can cause make confusion too.

An atom can appear as a rule head or as a fact. For example,

The above example regards as a predicate with no arguments, i.e., go/0.

In the previous Prolog Clauses file, we have an example of Animals Program 2, which has five predicates: dog/1, cat/1, large/1, small/1, and large_animal/1. Facts are defined by the first 18 clauses, which represent the predicates dog/1, cat/1, large/1, and small/1 in 6, 4, 7

, and 1 clause respectively. The rules are defined by the final two clauses. Both clauses define large_animal/1 predicate.

Declarative Interpretation of Rules

Declarative and procedural interpretation both describes the rules. The following example shows the declarative interpretation of the rules as follows:

In the above example, 'chases(A, B) is true if dog(A) is true, and cat(B) is true, and write(A) is true, etc.'

In the procedural interpretation, "to satisfy chases(A, B), first satisfy dog(A), then satisfy cat(B), then satisfy write(A), etc."

Facts are interpreted declaratively as follows:

The above will be read as 'bengal is a cat'.

Next TopicLoading clauses

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA