Prolog In tro duction Prolog programmi ng F acts ab out - - PDF document

prolog in tro duction prolog programmi ng f acts ab out
SMART_READER_LITE
LIVE PREVIEW

Prolog In tro duction Prolog programmi ng F acts ab out - - PDF document

Prolog In tro duction Prolog programmi ng F acts ab out ob jects ab out ob ject relationships and prop erties Rules ab out ob jects relationships prop erties Questions Prolog


slide-1
SLIDE 1
  • Prolog
In tro duction Prolog programmi ng
  • F
acts ab
  • ut
  • b
jects
  • Rules
ab
  • ut
  • b
ject relationships and prop erties
  • Questions
ab
  • ut
  • b
jects relationships prop erties
slide-2
SLIDE 2 Prolog
  • F
acts Syn tax
  • Names
  • f
relationships and
  • b
jects b egin with a lo w er case letter
  • The
relationship name is giv en rst related
  • b
jects are enclosed in paren thesis and separated b y commas This commaseparated list is the argu men t
  • f
the relationship
  • F
act sen tences end in a PERIOD
slide-3
SLIDE 3 Prolog
  • Seman
tics
  • The
pr
  • gr
ammer is resp
  • nsible
for deciding up
  • n
the meaning asso ciated with relationships dogspot Sp
  • t
is a dog fathergerry deb Gerry is the father
  • f
Deb petspot cindy Sp
  • t
is the p et
  • f
Cindy playjohn mary tennis John and Mary pla y tennis
  • Ob
jects spot cindy gerry deb
  • Relationships
dog father pet
slide-4
SLIDE 4 Prolog
  • This
means there migh t b e am biguities in the in terpretation
  • f
program results Do es
  • ldergerry
brian mean
  • gerry
is
  • lder
than brian
  • r
  • brian
is
  • lder
than gerry By con v en tion w e usually write relationship descriptions lik e this relationshipobj
  • bj
means
  • bj
is relationship tooffor
  • bj
slide-5
SLIDE 5 Prolog
  • Questions
W e can ask questions ab
  • ut
facts Supp
  • se
w e had the database giv en ab
  • v
e dogspot This is the question yes This is the answer Answ ers ma y
  • nly
use facts in the database
  • r
facts that ma y b e deduced from the database Th us dogmeg no No fact de claring me g to b e a do g NO means Pr
  • lo
g c annot de duc e an answer not false W e can use v ariables These are indicated b y an upp er case letter W e can ha v e sev eral v ariables playXYZ X
  • john
Y
  • mary
Z
  • tennis
Prolog lo
  • ks
through the database and determines whether there is a set
  • f
assignmen ts to X Y Z that will mak e playX Y Z true Sometimes there will b e more than
  • ne
p
  • ssible
list Supp
  • se
w e ha v e the follo wing facts playjohn mary tennis playjohn mary baseball playjohn bill basketball Ask the same question playXYZ X
  • john
Y
  • mary
Z
  • tennis
  • X
  • john
Y
  • mary
Z
  • baseball
  • X
  • john
slide-6
SLIDE 6 Prolog
  • Y
  • bill
Z
  • basketball
  • no
There w ere three sets
  • f
assignmen ts to X Y Z that w
  • uld
mak e the ques tion true Prolog con tin ues returning these v ariable assignmen ts un til no more remain W e can restrict
  • ur
queries asking who pla ys tennis playXYtennis
  • X
  • john
Y
  • mary
When Prolog matc hes an
  • b
ject with a v ariable w e sa y that the v ariable has b een instantiate d to that v alue
  • Conjunctions
W e can construct more complicated questions b y using conjunctions Supp
  • se
w e use a new database playjohn mary tennis playjohn mary baseball playjohn bill basketball playbill mary tennis playbill mary basketball W e w
  • uld
lik e to kno w who pla ys John b
  • th
in tennis and in bask etball playjohnYten nis playjohn Y basketball
  • Y
  • bill
Prolog will
  • nly
return instan tiations for Y that will mak e mak e b
  • th
parts
  • f
the question the goals true at
  • nce
  • Rules
Rules are a con v enien t w a y to state something ab
  • ut
a collection
  • f
  • b
jects W e can alw a ys list eac h fact separately for ev ery
  • b
ject horserobin horsemac horsesecretari at
slide-7
SLIDE 7 Prolog
  • dogmeg
dogspot doglassie animalrobin animalmeg animalsecretar iat animalmac animallassie animalspot likesdebrobin
  • likesdebmeg
likesdebsecre taria t likesdebmac likesdeblassi e likesdebspot
  • Ho
w ev er this gets unreasonably length y
  • By
adding rules ab
  • ut
relationships b et w een
  • b
jects w e can signican tly cut do wn
  • n
the database size horserobin horsemac horsesecretari at dogmeg dogspot doglassie animalX
  • horseX
animalX
  • dogX
likesdebX
  • animalX
The last three statemen ts are rules In English w e w
  • uld
sa y
  • animalX
  • horseX
If there is some X that is a horse then that X is an animal
  • likesdebX
  • animalX
If there is some X that is a horse then that deb lik es that X Prolog do esnt care ab
  • ut
the truth
  • f
the rules they are statemen ts b y the programmer This rule sa ys that all studen ts lik e studying
slide-8
SLIDE 8 Prolog
  • likesXstudyin
g
  • studentX
  • Rules
are also useful for making denitions featherstweety
  • yellowtweety
animaltweety furmeg whitemeg animalmeg barksmeg furrobin paintrobin animalrobin neighsrobin birdX
  • feathersX
animalX
  • dogX
  • furX
barksX animalX
  • horseX
  • furX
neighsX animalX
  • W
ev e dened
  • A
bird as an animal with feathers
  • A
dog as an animal with fur that barks
  • A
horse as an animal with fur that neighs W e can ask questions furX X
  • meg
  • X
  • robin
dogX X
  • meg
Rule dep endencies can in tro duce new conditions Notice that M F app ear
  • nly
  • n
the righ t hand side
  • f
the rule
  • Family
  • f
Queen Victoria
  • malealbert
maleedward femalealice
slide-9
SLIDE 9 Prolog
  • femalevictoria
  • Albert
and Victoria are the parents
  • f
Edward
  • parentsedward
victoria albert parentsalice victoria albert
  • X
is the sister
  • f
Y if
  • sisterOfX
Y
  • femaleX
  • X
is female
  • parentsX
M F
  • parents
are the same
  • parentsY
M F
  • parents
are the same
  • X
is the brother
  • f
Y if
  • brotherOfX
Y
  • maleX
  • X
is male
  • parentsX
M F
  • parents
are the same
  • parentsY
M F
  • parents
are the same
  • W
e can use Prolog rules to calculate things
  • Population
in millions
  • f
people in
  • popX
Y
  • The
population
  • f
X is Y million people
  • popusa
popindia popchina popbrazil
  • Area
in millions
  • f
square miles in
  • areaX
Y
  • The
area
  • f
X is Y million square miles
  • areausa
areaindia areachina areabrazil
  • Density
is population divided by area
  • densityX
Y
  • The
density
  • f
X is Y people per square mile
  • densityX
Y
  • popX
P
  • population
  • f
X is P
  • areaX
A
  • area
  • f
X is A
  • Y
is PA
  • density
Y is population P
  • ver
area A
  • W
e can ask questions ab
  • ut
densit y no w
slide-10
SLIDE 10 Prolog
  • densityusaY
Y
  • densitychinaY
  • Y
  • densityCountry
  • Country
  • india
T races for the rst t w
  • queries
using BinProlog
  • consultpopulatio
n consultingpopu latio n consultedpopul ation time
  • yes
  • tracedensitychi
naY
  • Call
densitychina
  • dynamicdensity
Call popchina
  • dynamicpop
Exit popchina Call areachina
  • dynamicarea
Exit areachina Call
  • is
  • compiledis
Exit
  • is
  • Exit
densitychina
  • Y
Redo densitychina
  • Redo
  • is
  • Fail
  • is
  • Redo
areachina Fail areachina Redo popchina Fail popchina Fail densitychina
  • no
Note that not all Prolog in terpreters will come up with the same answ ers for the ab
  • v
e Op enProlog is able to determine that
  • is
equiv alen t to
  • but
BinProlog do es not
  • tracedensityCou
ntry
slide-11
SLIDE 11 Prolog
  • Call
density
  • dynamicdensity
Call pop
  • dynamicpop
Exit popusa Call areausa
  • dynamicarea
Exit areausa Call
  • is
  • compiledis
Fail
  • is
  • Redo
areausa Fail areausa Redo popusa Exit popindia Call areaindia
  • dynamicarea
Exit areaindia Call
  • is
  • compiledis
Fail
  • is
  • Redo
areaindia Fail areaindia Redo popindia Ho w ev er if y
  • u
rephrase the question so that densit y is giv en as a real n um b er BinProlog also succeeds
  • densityCountry
  • Countryindia
no
  • tracedensityCou
ntry
  • Call
density
  • dynamicdensity
Call pop
  • dynamicpop
Exit popusa Call areausa
  • dynamicarea
Exit areausa Call
  • is
  • compiledis
Fail
  • is
slide-12
SLIDE 12 Prolog
  • Redo
areausa Fail areausa Redo popusa Exit popindia Call areaindia
  • dynamicarea
Exit areaindia Call
  • is
  • compiledis
Exit
  • is
  • Exit
densityindia
  • Countryindia
Redo densityindia
  • W
e can also use comparators lik e
  • in
  • ur
rules
  • Who
reigned in Wales th and th Centuries
  • reignsrhodri
  • reignsanarawd
  • reignshywelDda
  • reignsIago
  • reignshwelApI
  • reignscadwallo
n
  • reignsmaredudd
  • princeX
Y X was a prince in year Y if X reigned between years A B and year Y is between A B inclusive
  • princeX
Y
  • reignsX
A B
  • X
reigned and
  • Y
  • A
  • target
year is
  • n
  • r
after start
  • f
reign
  • Y
  • B
  • target
year is before
  • r
equal end
  • f
reign
  • Some
questions princecadwallo n
  • yes
slide-13
SLIDE 13 Prolog
  • princerhodri
  • no
princeX
  • X
  • cadwallon
  • X
  • maredudd
  • Matc
hing rules
  • An
uninstan tiated v ariable matc hes an y
  • b
ject
  • Once
a v ariable has b een matc hed it is instan tiated to ha v e the v alue
  • f
the
  • b
ject
  • In
tegers and atoms
  • nly
matc h themselv es
  • Structures
matc h
  • ther
structures if the functor name and n um b er
  • f
ar gumen ts matc h and instan tiated v ariables
  • r
explicitly named argumen ts matc h
  • Data
Structures
  • Represen
tation W e sometimes think
  • f
Prolog clauses as trees in b y in Figprologtree scaled
  • This
is esp ecially handy in describing more complicated clauses suc h as this
  • ne
sentencenounX
  • verbphraseverb
Y nounZ in b y in Figprologsen tence scaled
  • W
e can mo dify
  • ur
tree to include cycles it is a graph no w when w e w an t to indicate sharing in b y in Figsharing scaled
  • Lists
Characteristics
  • f
Prolog lists
  • Ordered
sequence
  • f
  • b
jects
  • Commaseparated
  • An
y length
slide-14
SLIDE 14 Prolog
  • Ma
y b e nested
  • Ma
y include an y t yp e
  • f
  • b
ject Examples
  • the
empty list
  • we
the people
  • element
list
  • we
the people
  • f
the united states
  • element
list
  • As
with Lisp lists ha v e a head and a tail List Head T ail abc a bc we the people we the people we the people we the people W e can use patterns to indicate the head and tail
  • f
lists
  • head
  • rest
  • and
w e can use placeholders to
  • is
sometimes called the anon ymous v ariable
  • X
Consider the follo wing mylistthis is a list containing some words
  • queries
  • mylistX
X
  • thisisalist
cont ainin gso mewo rds mylistHeadTa il Head
  • this
Tail
  • isalistcontai
ning some word s
  • One
placeholder
  • mylistY
Y
  • isalistcont
ainin gsom ewo rds
  • two
placeholders
  • mylistY
  • Y
  • alistcontain
ings
  • mew
  • rds
slide-15
SLIDE 15 Prolog
  • three
placeholders
  • mylistY
  • Y
  • listcontainin
gsom ewor ds
  • four
placeholders
  • mylist
Y Y
  • containingsom
ewor ds
  • nested
  • mylist
Y
  • Y
  • somewords
mylistXYZ
  • X
  • this
Y
  • is
Z
  • alistcontain
ings
  • mew
  • rds
  • Lets
build something useful member Rules
  • X
will b e a mem b er
  • f
Y if X is the head
  • f
Y memberXX W e could also ha v e written this rule memberXY
  • X
  • Y
  • X
will b e a mem b er
  • f
Y if X is in the tail
  • f
Y memberX Y
  • memberX
Y What ab
  • ut
this memberaabc
  • yes
memberaX X
  • a
  • is
a unique iden tier Prolog uses to indicate an un b
  • und
v ariable in the answ er Things to w atc h
  • ut
for
  • Mutually
recursiv e rules
slide-16
SLIDE 16 Prolog
  • parentA
B
  • childB
A childA B
  • parentB
A
  • Ordering
  • Prolog
alw a ys starts at the top
  • f
the rule base and w
  • rks
do wn so p
  • rly
  • rder
rule sets
  • ften
w
  • nt
w
  • rk
memberX Y
  • memberX
Y memberXX Another example
  • f
list programs append
  • appendX
Y Z append Y to X producing Z
  • append
L L appendHead
  • TailFirst
SecondList Head
  • Rest
  • append
TailFirst SecondList Rest
  • Some
queries appendabc xy z Result Result
  • abcxyz
appendX Y abc X
  • Y
  • abc
  • X
  • a
Y
  • bc
  • X
  • ab
Y
  • c
  • X
  • abc
Y
  • no
T racing the rst query
  • traceappendab
c xyz Re sult
  • Call
appendabcxy z
  • dynamicappend
Call appendbcxy z
  • dynamicappend
slide-17
SLIDE 17 Prolog
  • Call
appendcxyz
  • dynamicappend
Call appendxyz
  • dynamicappend
Exit appendxyz x yz
  • Exit
appendcxyz c xy z Exit appendbcxy zb cx yz
  • Exit
appendabcxy z ab cxy z Resultabc xyz
  • Redo
appendabcxy z ab cxy z Redo appendbcxy zb cx yz
  • Redo
appendcxyz c xy z Redo appendxyz x yz
  • Fail
appendxyz
  • Fail
appendcxyz
  • Fail
appendbcxy z
  • Fail
appendabcxy z
  • no
T racing the last query is ev en more in teresting
  • traceappendX
Y abc Call append ab c
  • dynamicappend
Exit appendabc abc
  • X
Yabc Redo appendabc abc
  • Call
append bc
  • dynamicappend
Exit appendbcb c Exit appendabca bc
  • Xa
Ybc Redo appendabca bc
  • Redo
appendbcb c Call append c
  • dynamicappend
Exit appendcc
  • Exit
appendbcb c Exit appendabca bc
  • Xab
slide-18
SLIDE 18 Prolog
  • Yc
Redo appendabca bc
  • Redo
appendbcb c Redo appendcc
  • Call
append
  • dynamicappend
Exit append Exit appendcc
  • Exit
appendbcb c Exit appendabc abc
  • Xabc
Y Redo appendabc abc
  • Redo
appendbcb c Redo appendcc
  • Redo
append Fail append
  • Fail
append c
  • Fail
append bc
  • Fail
append ab c no
  • Accum
ulators Sometimes w e need to carry temp
  • rary
v alues along during a deriv ation listlenListLe ngth
  • lengthAccList
  • Length
  • lengthAcc
A A lengthAccHead Tail
  • Acc
Len
  • Acc
is Acc
  • add
  • for
the head
  • lengthAcc
Tail Acc Len
  • count
the tail
  • listlenabc
dLe ngth
  • Length
  • In
this example w e ha v e a helping clause that do es the w
  • rk
and listlen initializes it Notice that lengthAcc creates a temp
  • rary
v ariable Acc whic h app ears
  • nly
  • n
the righ t hand side Subgoal list for lengthAcc
slide-19
SLIDE 19 Prolog
  • lengthAccab
cd
  • Len
lengthAccbc d Len lengthAcccd
  • Len
lengthAccd
  • Len
lengthAcc Len
  • done
  • Or
lo
  • king
at the actual trace
  • tracelistlena
bcd Len gth
  • Call
listlenabcd
  • dynamiclistlen
Call lengthAccabcd
  • dynamiclengthAcc
  • Call
  • is
  • compiledis
Exit
  • is
  • Call
lengthAccbcd
  • dynamiclengthAcc
  • Call
  • is
  • compiledis
Exit
  • is
  • Call
lengthAcccd
  • dynamiclengthAcc
  • Call
  • is
  • compiledis
Exit
  • is
  • Call
lengthAccd
  • dynamiclengthAc
c Call
  • is
  • compiledis
Exit
  • is
  • Call
lengthAcc
  • dynamiclengthAcc
Exit lengthAcc Exit lengthAccd Exit lengthAcccd
  • Exit
lengthAccbcd
  • Exit
lengthAccabcd
  • Exit
listlenabcd
  • Length
Another useful accum ulator
  • Defining
what an integer is
slide-20
SLIDE 20 Prolog
  • isinteger
isintegerX
  • isintegerY
X is Y isinteger yes isinteger yes isintegerX X
  • X
  • X
  • The
Cut Sometimes w e dont w an t to pro duce list
  • f
instan tiations but
  • nly
a single
  • ne
W e can use the cut sym b
  • l
  • to
indicate this divideN N Result
  • isintegerResul
t
  • prolog
built in
  • Product
is ResultN Product is Result
  • N
Product
  • N
Product
  • N
  • Query
  • divideRes
ult Result
  • Lets
trace the result
  • tracedivide
Resu lt Call divide
  • dynamicdivide
Call isinteger
  • dynamicisinteger
  • Exit
isinteger Call
  • is
  • compiledis
Exit
  • is
  • Call
  • is
  • compiledis
slide-21
SLIDE 21 Prolog
  • Exit
  • is
  • Call
  • compiled
Exit
  • Call
  • compiled
Fail
  • Redo
  • Fail
  • Redo
  • is
  • Fail
  • is
  • Redo
  • is
  • Fail
  • is
  • Redo
isinteger Call isinteger
  • dynamicisinteger
  • Exit
isinteger Call
  • is
  • compiledis
Exit
  • is
  • Exit
isinteger Call
  • is
  • compiledis
Exit
  • is
  • Call
  • is
  • compiledis
Exit
  • is
  • Call
  • compiled
Exit
  • Call
  • compiled
Fail
  • Redo
  • Fail
  • Redo
  • is
  • Fail
  • is
  • Redo
  • is
  • Fail
  • is
  • Redo
isinteger Redo
  • is
  • Fail
  • is
  • Redo
isinteger Call isinteger
slide-22
SLIDE 22 Prolog
  • dynamicisintege
r Exit isinteger Call
  • is
  • compiledis
Exit
  • is
  • Exit
isinteger Call
  • is
  • compiledis
Exit
  • is
  • Exit
isinteger Call
  • is
  • compiledis
Exit
  • is
  • Call
  • is
  • compiledis
Exit
  • is
  • Call
  • compiled
Exit
  • Call
  • compiled
Fail
  • Redo
  • Fail
  • Redo
  • is
  • Fail
  • is
  • Redo
  • is
  • Fail
  • is
  • Redo
isinteger Redo
  • is
  • Fail
  • is
  • Redo
isinteger Redo
  • is
  • Fail
  • is
  • Redo
isinteger Call isinteger
  • dynamicisinteg
er Exit isinteger Call
  • is
  • compiledis
Exit
  • is
  • Exit
isinteger Call
  • is
  • compiledis
slide-23
SLIDE 23 Prolog
  • Exit
  • is
  • Exit
isinteger Call
  • is
  • compiledis
Exit
  • is
  • Exit
isinteger Call
  • is
  • compiledis
Exit
  • is
  • Call
  • is
  • compiledis
Exit
  • is
  • Call
  • compiled
Exit
  • Call
  • compiled
Fail
  • Redo
  • Fail
  • Redo
  • is
  • Fail
  • is
  • Redo
  • is
  • Fail
  • is
  • Redo
isinteger Redo
  • is
  • Fail
  • is
  • Redo
isinteger Redo
  • is
  • Fail
  • is
  • Redo
isinteger Redo
  • is
  • Fail
  • is
  • Redo
isinteger Call isinteger
  • dynamicisinteger
  • Exit
isinteger Call
  • is
  • compiledis
Exit
  • is
  • Exit
isinteger Call
  • is
  • compiledis
Exit
  • is
slide-24
SLIDE 24 Prolog
  • Exit
isinteger Call
  • is
  • compiledis
Exit
  • is
  • Exit
isinteger Call
  • is
  • compiledis
Exit
  • is
  • Exit
isinteger Call
  • is
  • compiledis
Exit
  • is
  • Call
  • is
  • compiledis
Exit
  • is
  • Call
  • compiled
Exit
  • Call
  • compiled
Exit
  • CUT
Exit divide Result Redo divide Fail divide no What happ ens if w e dont use the cut W ed k eep generating in tegers though none
  • f
the
  • thers
w
  • uld
ev er pass the test Heres part
  • f
the trace
  • successful
computation
  • f
  • Result
  • now
try for another solution
  • Redo
divide Redo
  • Fail
  • Redo
  • Fail
  • Redo
  • is
  • Fail
  • is
  • Redo
  • is
slide-25
SLIDE 25 Prolog
  • Fail
  • is
  • Redo
isinteger Redo
  • is
  • Fail
  • is
  • Redo
isinteger Redo
  • is
  • Fail
  • is
  • Redo
isinteger Redo
  • is
  • Fail
  • is
  • Redo
isinteger Redo
  • is
  • Fail
  • is
  • Redo
isinteger Call isinteger
  • dynamicisinteger
  • Exit
isinteger Call
  • is
  • compiledis
Exit
  • is
  • Exit
isinteger Call
  • is
  • compiledis
Exit
  • is
  • Exit
isinteger Call
  • is
  • compiledis
Exit
  • is
  • Exit
isinteger Call
  • is
  • compiledis
Exit
  • is
  • Exit
isinteger Call
  • is
  • compiledis
Exit
  • is
  • Exit
isinteger Call
  • is
  • compiledis
Exit
  • is
  • Call
  • is
  • compiledis
Exit
  • is
  • Call
slide-26
SLIDE 26 Prolog
  • compiled
Fail
  • Redo
  • is
  • Fail
  • is
  • Redo
  • is
  • Fail
  • is
  • Redo
isinteger Redo
  • is
  • Fail
  • is
  • Redo
isinteger Redo
  • is
  • Fail
  • is
  • Redo
isinteger Redo
  • is
  • Fail
  • is
  • Redo
isinteger Redo
  • is
  • Fail
  • is
  • Redo
isinteger Redo
  • is
  • Fail
  • is
  • Redo
isinteger Call isinteger
  • dynamicisinteger
  • Exit
isinteger Call
  • is
  • compiledis
Exit
  • is
  • Exit
isinteger Call
  • is
  • compiledis
Exit
  • is
  • Exit
isinteger Call
  • is
  • compiledis
Exit
  • is
  • Exit
isinteger Call
  • is
  • compiledis
Exit
  • is
  • Exit
isinteger Call
  • is
  • compiledis
Exit
  • is
slide-27
SLIDE 27 Prolog
  • Exit
isinteger Call
  • is
  • compiledis
Exit
  • is
  • Exit
isinteger Call
  • is
  • compiledis
Exit
  • is
  • Call
  • is
  • compiledis
Exit
  • is
  • Call
  • compiled
Fail
  • Redo
  • is
  • Fail
  • is
  • Redo
  • is
  • Fail
  • is
  • Redo
isinteger Redo
  • is
  • Fail
  • is
  • Redo
isinteger Redo
  • is
  • Fail
  • is
  • Redo
isinteger Redo
  • is
  • Fail
  • is
  • Redo
isinteger Redo
  • is
  • Fail
  • is
  • Redo
isinteger Redo
  • is
  • Fail
  • is
  • Redo
isinteger Redo
  • is
  • Fail
  • is
  • Redo
isinteger Call isinteger
  • dynamicisintege
r Exit isinteger Call
  • is
  • compiledis
Exit
  • is
  • Exit
isinteger
slide-28
SLIDE 28 Prolog
  • Call
  • is
  • compiledis
Exit
  • is
  • Exit
isinteger Call
  • is
  • compiledis
Exit
  • is
  • Exit
isinteger Call
  • is
  • compiledis
Exit
  • is
  • Exit
isinteger Call
  • is
  • compiledis
Exit
  • is
  • Exit
isinteger Call
  • is
  • compiledis
Exit
  • is
  • Exit
isinteger Call
  • is
  • compiledis
Exit
  • is
  • Exit
isinteger Call
  • is
  • compiledis
Exit
  • is
  • Call
  • is
  • compiledis
Exit
  • is
  • Call
  • compiled
Fail
  • Redo
  • is
  • Fail
  • is
  • Redo
  • is
  • Fail
  • is
  • Redo
isinteger Redo
  • is
  • Fail
  • is
  • Redo
isinteger Redo
  • is
  • Fail
  • is
  • Redo
isinteger
slide-29
SLIDE 29 Prolog
  • Redo
  • is
  • Fail
  • is
  • Redo
isinteger Redo
  • is
  • Fail
  • is
  • Redo
isinteger Redo
  • is
  • Fail
  • is
  • Redo
isinteger Redo
  • is
  • Fail
  • is
  • Redo
isinteger Redo
  • is
  • Fail
  • is
  • Redo
isinteger Call isinteger
  • dynamicisinteg
er
  • Exit
isinteger Call
  • is
  • compiledis
Exit
  • is
  • Exit
isinteger Call
  • is
  • compiledis
Exit
  • is
  • Exit
isinteger Call
  • is
  • compiledis
Exit
  • is
  • Exit
isinteger Call
  • is
  • compiledis
Exit
  • is
  • Exit
isinteger Call
  • is
  • compiledis
Exit
  • is
  • Exit
isinteger Call
  • is
  • compiledis
Exit
  • is
  • Exit
isinteger Call
  • is
  • compiledis
slide-30
SLIDE 30 Prolog
  • Exit
  • is
  • Exit
isinteger Call
  • is
  • compiledis
Exit
  • is
  • Exit
isinteger Call
  • is
  • compiledis
Exit
  • is
  • Call
  • is
  • compiledis
Exit
  • is
  • Call
  • compiled
Fail
  • Redo
  • is
  • Fail
  • is
  • Redo
  • is
  • Fail
  • is
  • Redo
isinteger Redo
  • is
  • Fail
  • is
  • Redo
isinteger Redo
  • is
  • Fail
  • is
  • Redo
isinteger Redo
  • is
  • Fail
  • is
  • Redo
isinteger Redo
  • is
  • Fail
  • is
  • Redo
isinteger Redo
  • is
  • Fail
  • is
  • Redo
isinteger Redo
  • is
  • Fail
  • is
  • Redo
isinteger Redo
  • is
  • Fail
  • is
  • Redo
isinteger Redo
  • is
  • Fail
  • is
  • Redo
isinteger
slide-31
SLIDE 31 Prolog
  • Call
isinteger
  • dynamicisinteger
  • Exit
isinteger Call
  • is
  • compiledis
Exit
  • is
  • Exit
isinteger Call
  • is
  • compiledis
Exit
  • is
  • Exit
isinteger Call
  • is
  • compiledis
Exit
  • is
  • Exit
isinteger Call
  • is
  • compiledis
Exit
  • is
  • Exit
isinteger Call
  • is
  • compiledis
Exit
  • is
  • Exit
isinteger Call
  • is
  • compiledis
Exit
  • is
  • Exit
isinteger Call
  • is
  • compiledis
Exit
  • is
  • Exit
isinteger Call
  • is
  • compiledis
Exit
  • is
  • Exit
isinteger Call
  • is
  • compiledis
Exit
  • is
  • Exit
isinteger Call
  • is
  • compiledis
Exit
  • is
  • Call
  • is
  • compiledis
slide-32
SLIDE 32 Prolog
  • Exit
  • is
  • Call
  • compiled
Fail
  • Redo
  • is
  • Fail
  • is
  • Redo
  • is
  • Fail
  • is
  • Redo
isinteger
  • Break
by sending CTRLC
  • Sometimes
the cut can cause problems
  • we ve
asked for A B such that AB
  • divideAB
  • OpenProlog
  • unclassifiederr
  • r
goal is
  • BinProlog
  • variableinis
  • errorinis
  • is
  • Supp
  • se
that w e mo died append to use the cut append L L
  • appendHead
  • TailFirst
SecondList Head
  • Rest
  • append
TailFirst SecondList Rest
  • queries
this
  • ne
works
  • appendabc
def Result Result
  • abcdef
  • this
query no longer works
  • appendX
Y abc X
  • Y
  • abc
  • no
The cut command prev en ted Prolog from making c hanging X and Y so w e didnt get the full list
  • f
solutions that w e receiv ed b efore