Exercise 14Write a Prolog program in which you type in an English sentence and Prolog replies with another sentence that is an altered version of the one you have typed in. For example, the program might produce an interaction like the following:
You: you are a computer
Computer: i am not a computer
You: do you speak french
Computer: no, i speak german
It is easy to write a program to do this by simply following these steps:
You should take the input to be a list; so that the interaction goes:
|:[do, you, know,french].
no, i know german
This program is just a variant of the one we constructed in class to translate English into French, so you can model this program on that one.
A difference between this program and the French translator, however, is that here `reply' is a zero-place predicate; to accept input from the user, it must contain a call to read/1 as part of its definition. Similarly, Prolog’s answer has to be produced using the write/1 predicate. Note that the Prolog response does not contain any brackets or commas; you therefore will need to write a (recursive) predicate which will ’write’ the items on a list one by one, with a space between each one, until it reaches the end of this list and stops - and integrate it into your program.
Write your program so it will run indefinitely, until the interaction is terminated by the user.