Question
Prolog 6. Consider this database of facts, describing what something is made up of. has(bicycle,wheel,2). has(bicycle,handlebar,1). has(bicycle,brake,2). has(wheel,hub,1). has(bicycle,frame,1). has(car,steering_wheel,1). has(car,stereo,1). Write a predicate partof(X,Y)
Prolog
6. Consider this database of facts, describing what something is made up of.
has(bicycle,wheel,2).
has(bicycle,handlebar,1).
has(bicycle,brake,2).
has(wheel,hub,1).
has(bicycle,frame,1).
has(car,steering_wheel,1).
has(car,stereo,1).
Write a predicate partof(X,Y) that succeeds if Y is part of X.
?- partof(wheel,spoke).
True.
?- partof(bicycle,spoke).
True.
?- partof(car,spoke).
False.
partof(X,Y) can also be used to enumerate the parts that make up an object or of which an object is part of.
?- partof(bicycle,X).
X = wheel;
X = handlebar;
X = break;
X = frame;
X = hub;
?- partof(X,spoke).
X = wheel;
X = bicycle.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started