

Queries lets you retrieve information from a logic program. The use of such a program is demonstrated by doing queries.

In fact, a finite set of facts and or rules constitutes as a logic program. Prolog is a declarative language and you can read this database as follows:įor all X and Y, X is a child of Y if Y is a father of X or Y is a mother of X. Note that the here is like the or operator in other languages. Ī logic database contains a set of facts and rules.Ī complex term with only atoms as arguments is called a fact, while a complex term with variables as arguments is called a rule.Įxample of facts in Prolog: father_child(fred, susan).Įxample of a rule in Prolog: child_of(X,Y):. Eg father(john,doe), relative(a), mother(X,Y). Name of a complex term is always an atom, while arguments can either be atoms or variables.

It defines a relation between three arguments and is true if the third argument is a list that denotes the concatenation of the lists that are specified in the first and second arguments.
