Question: Use Prolog syntax and semantics. (Use siwpl-SWI-Prolog) Define the double_double ( X, Y) relation that holds when Y is a list structure that contains the

Use Prolog syntax and semantics. (Use siwpl-SWI-Prolog)

Define the double_double ( X, Y) relation that holds when Y is a list structure that contains the same basic structure, and elements, that appeared in X, but each entry in Y is a list containing two copies of a list containing two copies of the entry in X. For example: . ?- double_double( [a, b, [c,d]], Y). Y = [[[a,a], [a,a]],[[b, b],[b, b]],[[[c,d], [c,d]],[[c,d],[c,d]]]] ; false . ?- double_double( [1, X], [Y, [[2,2], Q]]). X = 2, Y = [[1, 1], [1, 1]], Q = [2, 2] ; false . ?- double_double( [1, X], [Y, [2, 2]]). false.

In general, your program should work even even if there are variables in either argument -- as suggested by the above examples. Be sure to specify if that is not true.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!