Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 4 ) [ 5 points ] By filling in the blanks in the knowledge base below, give facts / rules which introduce a relation

Question 4)[5 points] By filling in the blanks in the knowledge base below, give facts/rules which
introduce a relation subst. This relation has arity 4. Given an old element 0ld, a new element New, and
two lists x and Y, subst (New, Old, X, Y) holds if Y is the same list as x except where every occurrence
of the old element Old in x is replaced by an occurrence of the new element New in Y.
/* KNOWLEDGE BASE */
subst(dots,dots,[],[]).
subst(New , Old ,[..| T1],[... T2]) :- subst(New , Old ,...,...).
/* EXAMPLE QUERIES */
?- subst(7,1,[1,2,1,3],[7,2,7,3]).
Yes
?- subst(7,1,[1,2,1,3],[7,2,1,3]).
No
?- subst(7,1,[1,2,1,3],R).
R=[7,2,7,3]
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatial Database Systems Design Implementation And Project Management

Authors: Albert K.W. Yeung, G. Brent Hall

1st Edition

1402053932, 978-1402053931

More Books

Students also viewed these Databases questions