0% found this document useful (0 votes)
323 views4 pages

Program - 1: AIM:-Introduction To Prolog

Prolog is a logic programming language well-suited for artificial intelligence. It represents relations as facts and rules, and runs queries over these relations. Key aspects include terms as single data type including atoms, numbers, variables, and compound terms. Rules define relations with heads and bodies, with facts as special cases of rules with empty bodies. Prolog execution is initiated by a user query and uses resolution to try to refute the negated query.

Uploaded by

Rohan Singla
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
323 views4 pages

Program - 1: AIM:-Introduction To Prolog

Prolog is a logic programming language well-suited for artificial intelligence. It represents relations as facts and rules, and runs queries over these relations. Key aspects include terms as single data type including atoms, numbers, variables, and compound terms. Rules define relations with heads and bodies, with facts as special cases of rules with empty bodies. Prolog execution is initiated by a user query and uses resolution to try to refute the negated query.

Uploaded by

Rohan Singla
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Program -1

AIM:- Introduction to Prolog


What is Prolog?
Prolog is a programming language particularly well suited to logic and artificial intelligence programming. "Prolog" in fact stands for "Programming in Logic." In this brief introduction we will try to give you a little taste of Prolog without bogging you down with a great deal of technical jargon. By the end of this section you should be able to use Prolog and write some little programs that give you a feel for the language. Feel free to consult the books and Web sites on Prolog mentioned later should you want to go further. In this the term includes are. Introduction Syntax Data types Rules and facts Evaluation Examples

Introduction Prolog is a general purpose logic programming language associated with artificial intelligence and computational linguistics. Prolog is declarative, The program logic is expressed in terms of relations, represented as facts and rules and a computation is initiated by running a query over these relations. The language was first conceived by a group around Alain Colmeraurer in Marseille, France.

Data types Prologs single data type is the term. Terms are either atoms, numbers, variables and compound terms. An atom is a general purpose name with no inherit meaning. Ex: x,blue etc. Numbers can be floats or integers. Variables are denoted by a string consisting of letters, numbers and underscore characters, and beginning with an upper case characters and underscore. A compound term is composed of an atom called functor and a number of arguments, which are again terms.

Compound terms are ordinarily written as a functor followed by a commaseparated list of argument terms, which is contained in the parentheses. A List is an ordered collection of terms. It is denoted by square brackets with the terms separated by brackets with the terms separated by commas or in

the case of an empty list, [] ex: [1,2,3] or [red, green, blue] etc.

Strings are a sequence of characters surrounded by quotes.Ex: to be, or not to be

Rules and Facts Prolog programs describe relations, defined by means of clauses. There are two types of clauses:
o o

Facts Roles

A role is of the form Head :- Body and is read as head is true if body is true. A rules body consists of calls to predicates, which are called the rules goals. Classes with empty bodies are called facts. Ex: cat(tom).

Evaluation Execution of a Prolog program is initiated by the user's posting of a single goal, called the query. Logically, the Prolog engine tries to find a resolution refutation of the negated query. The resolution method used by Prolog is called SLD resolution.

Ex: mother_child(trude, sally). father_child(tom, sally). father_child(tom, erica). father_child(mike, tom). sibling(X, Y) :- parent_child(Z, X), parent_child(Z, Y). parent_child(X, Y) :- father_child(X, Y). parent_child(X, Y) :- mother_child(X, Y). Results in the following query being evaluated as true: ?- sibling(sally, erica). Yes

You might also like