Artificial intelligence with prolog
Write a prolog program that solves the following problems 1. Construct a rule palindrome which takes a word as a list or characters and checks to see whether it as a palindrome or not. (A palindrome is a word or phrase that is the same forwards as it is backwards e.g. radar). It should works as follows: ? - palindrome ( [ n, a, v, a, n ] ). Yes ? - palindrome ( [ d, u, b, l, i, n ] ). No 2. Write a predicate replace/4 to replace all occurrences of a given element (second argument) by another given element (third argument) in a given list (first argument). It should work as follows: ?- replace ([1, 2, 3, 4, 3, 5, 6, 3], 3, x, List). List = [1, 2, x, 4, x, 5, 6, x] Yes 3. Implement a Prolog predicate remove_duplicates/2 that removes all duplicate elements from a list given in the first argument and returns the result in the second argument position. It should work as follows: ?- remove_duplicates([a, b, a, c, d, d], List). List = [b, a, c, d] Yes