Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Document preview thumbnail
Preview 2 out of 9 pages
Summary

KIPA PROLOG Summary

Document preview thumbnail
Preview 2 out of 9 pages

Summary of the PROLOG lectures of the KIPA course

Content preview

KIPA PROLOG samenvatting
PROLOG 1
Facts and rules

- A Prolog program consists of facts and rules
o color(chardonnay, white). % fact
o tannines(X, low) :- color(X, white). % rule
- Arguments can be complex
o date(day(15), month(march, num(3)), year(2023))




Variables

- Arguments can be a variable
- Variable is assigned a value through unification
o If the variable is used again after unification then the value is fixed
- Special variable _ matches always, no value assigned




Transform knowledge to prolog code

- Domain rule with or: two rules in Prolog
o If it rains or if you swim then you get wet
 wet(_) :- rains.
 wet(X) :- swim(X).
- Domain rule with and: one rule with two conditions
o If it rains and you are outside then you get wet
 wet(X) :- rains, outside(X).

Query algorithm

, - Find the first fact or rule with the same name and arity as the query
- Check if arguments unify
- If yes:
o Assign values to variables
o For rules: create new query for each condition
- If no: try the next fact or rule

Unification

- A query and a fact or rule unify
o if Name is the same
o Number of arguments is the same
o Value of arguments is the same
o or: arguments are uninstantiated (free) variables




Mathematical operators

- Prolog uses standard operators + - * /
- Test for equality: =/2
o Note: same syntax and same value
- Assignment: is/2
o Math expression only on the right




Syntax of arguments and variables

- Constants: lower case, no spaces or punctuation

Document information

Study
Uploaded on
January 22, 2024
Number of pages
9
Written in
2022/2023
Type
Summary
$7.76

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
Sold
16
Followers
7
Items
10
Last sold
4 months ago




Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions