Yes, there is a priority issue that you must consider.
Prolog binds a numerical priority value to each specific operator, so that its parsing can automatically process, for example, 3 + 4 * 5, just as if the brackets were used to denote 3+ (4 * 5).
So your first example worked as expected, but not the second or third. There was simply no way to unify terms, so Prolog returned false.
source
share