The following Prolog code defines a predicate P. (Remember that uppercase terms are variables, not constants, in Prolog.)
P(X,[X|Y]). P(X,[Y|Z]) :- P(X,Z). 1. Show proof trees and solutions for the queries P(A,[1,2,3]) and P(2,[1,A,3]).
2. What standard list operation does P represent?

The following Prolog code defines a predicate P. (Remember that uppercase terms are variables, not constants, in Prolog.)
P(X,[X|Y]). P(X,[Y|Z]) :- P(X,Z). 1. Show proof trees and solutions for the queries P(A,[1,2,3]) and P(2,[1,A,3]).
2. What standard list operation does P represent?

4th edition: chapter 9, Inference in First-Order Logic

Tested in Python, Java, JavaScript, C#, Scala, Julia, Lisp





Submit an Answer

The button opens a form on GitHub, with this exercise filled in; you need a GitHub account. Your answer becomes a pull request, and once a maintainer merges it, it shows under Student Answers.