Built-in Functions listing(fruit).: Lists all the objects within this relation halt. Exit from Prolog write(X). /* Write to console */ nl /* New Line */

Slides:



Advertisements
Similar presentations
Artificial Intelligence: Natural Language and Prolog
Advertisements

Mod arithmetic.
CS4026 Formal Models of Computation Part II The Logic Model Lecture 6 – Arithmetic, fail and the cut.
People can lie on the internet. Don’t plan to meet someone in person. Don’t friend someone you don’t know. Don’t respond to people you don’t know.
 Too many and too much are phrases that we use to say that there is more of something than is wanted.  I´ve got too many CDs.(I don’t have a place to.
The Commons Quiz. How much is black and white printing in The Commons? 25 cents 15 cents 5 cents.
אימרות שירות לקוחות 1 If You Don’t Take Care of Your Customer, Somebody Else Will.
Computational Models The exam. Models of computation. –The Turing machine. –The Von Neumann machine. –The calculus. –The predicate calculus. Turing.
Python Mini-Course University of Oklahoma Department of Psychology Day 2 – Lesson 8 Fruitful Functions 05/02/09 Python Mini-Course: Day 2 - Lesson 8 1.
Muller’s Method Dan Heflin Sarah Hare. Muller’s Method What problem does it solve? How is it represented? Where does it come from?
Prolog The language of logic. History Kowalski: late 60’s Logician who showed logical proof can support computation. Colmerauer: early 70’s Developed.
1 Introduction to Prolog References: – – Bratko, I., Prolog Programming.
1 Logic Programming. 2 A little bit of Prolog Objects and relations between objects Facts and rules. Upper case are variables. parent(pam, bob).parent(tom,bob).
Visualising Program Behaviour. 2 Program visualisation tools in ECLiPSe  Debugger  Profiler  Coverage  Display matrix  Visualisation  Debugger 
AB 11 22 33 44 55 66 77 88 99 10  20  19  18  17  16  15  14  13  12  11  21  22  23  24  25  26  27  28.
4. PROLOG Data Objects And PROLOG Arithmetic
1 Prolog III. 2 Lists [ ] is the empty list. [x, 2+2, [a, b, c]] is a list of three elements. The first element in the list is its “head”. The list with.
For Friday Read “lectures” 1-5 of Learn Prolog Now: prolog-now/
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering More Built-in Predicates Notes for Ch.7 of Bratko For CSCE 580 Sp03 Marco Valtorta.
I.1 ii.2 iii.3 iv.4 1+1=. i.1 ii.2 iii.3 iv.4 1+1=
I.1 ii.2 iii.3 iv.4 1+1=. i.1 ii.2 iii.3 iv.4 1+1=
4. Python - Basic Operators
Kindergarten Sight Words
Grammar – Unit 46 Have something done
For Wednesday Read “lectures” 7-10 of Learn Prolog Now Chapter 9, exs 4 and 6. –6 must be in Horn clause form Prolog Handout 2.
The way someone or something acts; what they do a)behaviorbehaviorb)darknessdarknessc)illnessillnessd)silencesilence.
A biography is a true story about someone written by someone else. On the other hand, an autobiography is a true story of someone written by himself or.
CS4026 Formal Models of Computation Part II The Logic Model Lecture 2 – Prolog: History and Introduction.
CS101 Computer Software. Software Software is... Two main types of software are…
This will all add up in the end. Assignment operator =Simple Assignment operator Arithmetic Operators +Additive operator – Subtraction operator * Multiplication.
Task 1. 1.) Match these sentences and with the three tenses (a,b,c) below 1. I wish I had married Dave not Barry. 2. I wish I had a flat stomach. 3.I.
For Monday Exam 1 is Monday Takehome due Prolog Handout 3 due.
Reading is an Investment Kindergarten Lesson
For Friday No reading Prolog Handout 2. Homework.
Flow Charts WHAT ARE THEY AND WHY DO WE USE THEM?.
Alternate Interior Angle Theorem By: Miguel Reyes.
GENETICALLY ENGINEERED FOODS BY:SHANARA HARPER. GENETICALLY ENGINEERED FOOD Genetically engineered foods usually have traits/characteristics of the item.
基 督 再 來 (一). 經文: 1 你們心裡不要憂愁;你們信神,也當信我。 2 在我父的家裡有許多住處;若是沒有,我就早 已告訴你們了。我去原是為你們預備地去 。 3 我 若去為你們預備了地方,就必再來接你們到我那 裡去,我在 那裡,叫你們也在那裡, ] ( 約 14 : 1-3)
Project Brief for Action Learning Sets This report says how this work will be done.
CS 330 Programming Languages 12 / 06 / 2007 Instructor: Michael Eckmann.
1 TP #4: Control Facilities n Last TP exercises solved; n Don’t care variables « _ »; n Or « ; »; n Cut.
For Friday No reading Prolog handout 3 Chapter 9, exercises 9-11.
For Wednesday Read “lectures” 7-10 of Learn Prolog Now:
The Universe Keeping and Getting Rid Of Things Your Stuff My Stuff
ФОНД ЗА РАЗВОЈ РЕПУБЛИКЕ СРБИЈЕ
بنــام خــدا.
Unit 1: Proud to Be Me Theme 2: My Family
المبادئ الأساسية للصحة المهنية
Слайд-дәріс Қарағанды мемлекеттік техникалық университеті
.. -"""--..J '. / /I/I =---=-- -, _ --, _ = :;:.
Stages of Coping with Data
II //II // \ Others Q.
Пасиви и пасивни операции Активи и активни операции
'III \-\- I ', I ,, - -
1.2.1 Privacy: My body belongs to me
I1I1 a 1·1,.,.,,I.,,I · I 1··n I J,-·
Prolog III.
Welcome to my class Our Class Rules.
It’s Good to Be a Friend But how do I know if I am?
1.2.1 Privacy: My body belongs to me
design – make a drawing or plan for something
imitate – try to act like something else
Welcome to My Class Our Class Rules.
Welcome to My Class Our Class Rules.
,, 'III \-\-

Prolog III Lists 8-Jul-19.
. '. '. I;.,, - - "!' - -·-·,Ii '.....,,......, -,
I need to improve my… I am now able to… I feel more confident about…
Prolog Based on: Chapter 12 of PLP “Seven languages in seven weeks”
Presentation transcript:

Built-in Functions listing(fruit).: Lists all the objects within this relation halt. Exit from Prolog write(X). /* Write to console */ nl /* New Line */ ! /* CUT Backtrack */

Example I: Simple Program has(jack,apples). has(ann,plums). has(dan,money). fruit(apples). fruit(plums).Queries: has(jack,_). /* Don’t care about second operand */ has(X,apples),has(Y,plums). /* who has apples and who has plums? */ has(dan,X),fruit(X). /* has Dan fruits? */ has(X,Y),not fruit(Y). /* does someone have something else? */

Basic Arithmetic ?- X is 5+4, Y is 5-4. X = 9, Y = 1 ?- X is 5*4, Y is 2^3. X = 20, Y = 8 ?- X is sqrt(3),Y is 3^0.5. X = , Y = ?- X is 8 mod 3. X = 2

Example II: Arithmetic abs(X,X):- X >= 0, !. abs(X,Y):- Y is -X. ?- abs(0,R). R = 0 ?- abs(-9,R). R = 9

Example III: Lists Find Member member(X,[X|_]). member(X,[_|T]):- member(X,T). ?- member(b,[a,v,b,c]). yes ?- member(a,[b,c,g]).no Print List my_write([]). my_write([X|R]): write(X),nl,my_write(R). ?- my_write([a,b,c]). a b c yes