top of page

What would be the output of the following statement in Prolog, and why?

The statement is:

? - A is 6 + 3, B = 5+4, A = B.


In Prolog, the expression is is used for arithmetic evaluation, while = is used for unification. So, the query you provided will result in a false statement because B is unified before arithmetic evaluation:


?- A is 6 + 3, B = 5 + 4, A = B.
false.

This is because A is unified with the result of arithmetic evaluation (9), while B is unified with the term "5+4", which is not equal to 9.

346 views0 comments

Comments


bottom of page