0% found this document useful (0 votes)
13 views2 pages

Ai 8

Prolog is a high-level programming language used in artificial intelligence and computational linguistics, focusing on declarative programming through facts, rules, and queries. It operates by defining relationships and allows users to query these definitions to determine truth values. Examples illustrate the syntax of facts and rules, demonstrating how Prolog evaluates queries based on defined conditions.

Uploaded by

cadetbro23
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views2 pages

Ai 8

Prolog is a high-level programming language used in artificial intelligence and computational linguistics, focusing on declarative programming through facts, rules, and queries. It operates by defining relationships and allows users to query these definitions to determine truth values. Examples illustrate the syntax of facts and rules, demonstrating how Prolog evaluates queries based on defined conditions.

Uploaded by

cadetbro23
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Experiment No.

8
Prolog Language

Introduction: Prolog (short for "Programming in Logic") is a high-level programming language


primarily associated with artificial intelligence (AI) and computational linguistics. Developed in the early
1970s, Prolog is based on formal logic and is particularly well-suited for tasks that involve complex data
structures, relationships, and rule-based reasoning.

Prolog operates using a declarative paradigm, meaning that instead of specifying step-by-step instructions,
you define facts and rules about a problem domain, and then ask queries.

In Prolog, programs consist of:

• Facts (statements about what is true)

• Rules (logical relationships derived from facts)

• Queries (questions to find whether statements are true)

Example 1 :
1. Full Stop (.): In Prolog, every fact or rule must end with a full stop (.). This indicates that the statement is
complete, and Prolog can interpret it.
2. Fact 1: dog(ozzy). This is a fact in Prolog, which states that "ozzy" is a dog. This means whenever Prolog
is asked if "ozzy" is a dog, it will return true.
3. Fact 2: cat(poppy). Similarly, this is another fact that states "poppy" is a cat. So, if you ask Prolog if
"poppy" is a cat, it will return true.

The output "true." confirms that Prolog has successfully matched the query to the fact cat(poppy).
Example 2 :
1. Full Stop (.) : In Prolog, every fact or rule must end with a full stop (.). This indicates that the statement
is complete, and Prolog can interpret it.
2. Fact 1: dog(ozzy). This fact states that "ozzy is a dog." Whenever Prolog is asked if mani is a dog, it will
return true.
3. Fact 2: cat(poppy). This fact states that "poppy” is a cat." Whenever Prolog is asked if poppy is a cat, it
will return true.
Rule 1: is_animal(X) :- dog(X); cat(X).
This is a rule that defines the condition under which something is an animal. It states that X is an animal if X
is a dog or X is a cat. The ; operator means "or." The :- symbol means "if".
This rule checks if the argument (X) is either a dog or a cat, and if so, concludes that it is an animal

The output "true." confirms that Prolog has successfully matched the query to the fact cat(poppy) is
is_animal

You might also like