Assignment3:

Consider a prolog program in which we type an English sentence and Prolog replies with another sentence that is an altered version

of the one we type in. The dialogue is similar as following:

type in: you are a computer

program reply: I am not a computer

type in: do you speak french

program reply: no I speak german

 

basic steps:

1. Accept a sentence that is typed in by the user.

2. Change each "you" in the sentence to an "i".

3. Likewise, change any "are" to "am not".

4.Change "french" to "german".

5. Change "do" to "no".

 

We can see the relation of the original sentence and the replying sentence. So, we define predicate called alter(X,Y).

The final program should works as follows:

?-alter([do,you,know,french],X).

and program should reply:

X=[no,i,know,german].