Search code examples
prologprolog-dif

Prolog Query returning H128


In the query below, firstly I'm getting X = H128, where does that come from? Also why is it returning yes? Is it because the variable X is actually not defined and we are testing for that condition?

?- not(X==3).
X = H128 
yes

Solution

  • Your query is using an uninstantiated variable (X). When checking whether X is instantiated with the term 3 it (X==3) it fails because X is uninstantiated.

    Therefore, not(X==3) will succeed as the prolog engine cannot prove X==3. Your prolog interpreter is thus returning 'yes' (due to the negation as failure approach of the interpreter), and X remains uninstantiated.

    That is why the interpreter shows X = H128, where H128 is a dummy uninstantiated variable.