BRATKO PROLOG PDF

Advised book: I. Bratko. PROLOG Programming for Artificial Intelligence, 3rd ed. Addison-Wesley, Harlow, (older editions are also. Prolog Programming for Artificial Intelligence, 4/E: Ivan Bratko, University of Ljubljana The fourth edition of this best-selling guide to Prolog and Artificial. Prolog Programming for Artificial Intelligence. 3rd Edition. Ivan Bratko. ISBN ISBN Learn more about this title.

Author: Yozshuk Tojazuru
Country: Qatar
Language: English (Spanish)
Genre: Video
Published (Last): 27 June 2014
Pages: 114
PDF File Size: 16.26 Mb
ePub File Size: 4.39 Mb
ISBN: 235-9-20852-199-3
Downloads: 18821
Price: Free* [*Free Regsitration Required]
Uploader: Yolkree

There is a recent 2-page article by Kowalski at http: Note that historical information in these lectures is not examinable.

Prolog is a declarative programming language unlike most common programming languages. In a declarative language the programmer specifies a goal to be achieved the Prolog system works out how to achieve it relational databases owe something to Prolog.

Some applications of Prolog are: When we say, “John owns the book”, bdatko are declaring the ownership relationship between two objects: John and the book. Relationships can also rules such as: Two people are sisters if they are both female and they have the same parents. A rule allows us to find out about a relationship even if the relationship isn’t explicitly stated as a fact.

X bdatko a parent if there is a Y such that Y is a child of X. One then uses the system by: They also can begin with digits likeand can be strings of characters enclosed in quotes as in reads fred, “War and Peace”. Together, these facts form Prolog’s database. Should you wish to experiment with them using Prolog, they are available at http: Queries Once we have a database of facts and, soon, rules we can ask questions about the stored information.

Suppose we want to know if Turing lectures in course In example dialogues with Prolog, the text in green italics is what the user types.

See the article on negation in the Prolog dictionary to find out why No. Prolog is not being intelligent about this – it would not see a difference between this query and lectures fred, To ask Prolog to find the course that Turing teaches, enter this: To ask which course s Prof. Codd teaches, we may ask,?

COMP9414/9814 Artificial Intelligence

If Prolog can tell that there are no more solutions, it just gives you the? If Prolog can’t tell, it will let you type ; again, and then if there bratmo no further solution, report false. Prolog can find all possible ways to answer a query, unless you explicitly tell it not to see cutlater. This means finding out if Turing lectures in a course that Fred studies. To answer this question, Prolog must find a single value for Course, that satisfies both goals. However, note that Prolog will evaluate the two goals left-to-right.

In Prolog, there is the practical consideration of which goal should be evaluated first – the code might be more efficient one way or the other. In particular, in “P1, P2”, if P1 fails, then P2 does not need to be evaluated at all. This is sometimes referred to as a “conditional-and”. What about or i. It turns out explicit or s aren’t needed much in Prolog. There is a way to write or: The reason or s aren’t needed much is that head: Avoid using ; if you can, at least until you have learned how to manage without it.

  LENZE 8300 PDF

While some uses of ; are harmless, others can make your code hard to follow. To reinforce this message, you will be penalised if you use the or operator ; in the first Prolog assignment in COMP Backtracking in Prolog Who does Codd teach? When given the initial query, Prolog starts by trying to solve lectures codd, Course. There are six lectures clauses, but only two have codd as their first argument.

Pearson Education – Companion Website

Prolog uses the first clause that refers to codd: It finds the fact studies jack, Then it backs up rebinds Course togoes down the lectures codd, branch tries studies Student,finds the other two solutions: To picture what happens when Prolog tries to find a solution and backtracks, we draw a “proof tree”:.

The previous question can be restated as a general rule: One person, Teacher, teaches another person, Student if Teacher lectures in a course, Course and Student studies Course. In Prolog this is written as: Facts are unit clauses and rules are non-unit clauses. Sometimes, Prilog says true instead of true. Prolog does this when it believes it may be able to prove that the query is true in more than one way and there are no variables in the query, that it can report bindings for. The missing full-stop prompts us to type ; if we want bratkp check for another proof.

Alternatively, we can just press the “return” key if we prrolog not interested in whether there is another proof. You can find more details by looking up true. The author LeGuin has attributes too: How do we ask, “What books does John own that were written by someone called LeGuin”?

What books does John own? Prolog performs a complex matching operation between the structures in the query and those in the clause head. A database of books in a library contains facts of the form book CatalogNo, Title, author Family, Given.

Programming in Prolog

This rule has three clauses: They are tried in the given order. This is how disjunction or is often achieved in Prolog.

More complex arithmetic expressions can be arguments of comparison operators – e. The available numeric comparison operators are: All these numerical comparison operators evaluate both their arguments. That is, they evaluate Expression1 and Expression2. Assume the loan period is one month: You can find a copy of the code for all the library stuff, and a sample toy library database, at http: Use is if and only if you need to evaluate something: To reinforce the point about the meaning of isyou will be penalised in the first Prolog assignment if you use it where it is not needed.

  6502 ASSEMBLY LANGUAGE SUBROUTINES PDF

Order of goals with is Order of goals matters with is. Variables on the RHS of is must be instantiated at the time the is goal is tried by Prolog.

This is why the following example fails: Arguments are not sufficiently instantiated vs? You can see the differences between these three Prolog constructs from the following example Prolog queries:. In the library database example, some complex terms contained other terms, for example, book contained name.

The following term also contains another term, this time one similar to itself: The variables L1, L2, R1, and R2 should be bound to sub-trees this will be clarified shortly. Binary because each “node” has two branches our backtrack tree before had many branches at some nodes. A term that contains another term that has the same principal functor brarko this case tree is said to be recursive.

In full, the tree above would be: Usually, we wouldn’t bother to draw the empty nodes: A binary tree is either empty or contains some data and a left and right subtree that are also binary trees. In Prolog we express this as: Any recursive predicate must have: The example at the heading “An Application of Lists”, below, will show how the recursive branch and the trivial branch work bratki. However, you probably shouldn’t try to look at it until we have studied lists.

PROLOG: Programming for Artificial Intelligence

Recursive Programs for Recursive Structures 2 Let us define or measure the size of tree i. The size of a non-empty tree is the size of the left sub-tree plus the size of the right sub-tree plus one for the current tree node. Recursive data structures need recursive programs.

We could define lists as follows: This notation is understandable but clumsy. Prolog doesn’t actually recognise itand in fact uses. So Prolog would recognise. This is briefer but still looks strange, and is hard to work with. Since lists are used so often, Prolog in fact has a special notation that encloses the list members in square brackets: Within the square brackets [ ]the symbol acts as an operator to construct a list from an item and another list.

Notice that Y is shown with an extra pair of brackets: