How the Interpreter of SWIPL works ...?

Can you show that with a screenshot? I know you are new to Prolog and do not know the terminology so what you are describing has me guessing at the meaning, which could mean many things and more likely my guess would be incorrect.

The = operator is one of the more confusing points of learning Prolog. Many take it that = is the same as other programming languages where it means assignment, in Prolog it is unification, or more specifically syntactic unification.

See: SWI-Prolog -- (=)/2

Over the decades I have read many intros and books to Prolog and IMO many do not explain syntactic unification at all or in enough detail before using it with examples. Many find learning it hard because they bring along ideas from elsewhere that causes confusion but once you learn syntactic unification you find how easy it is and how powerful an idea it is.

Here are some ChatGPT prompts related to syntactic unification.

When learning syntactic unification consider using this as a cheat sheet

Examples of syntactic unification of first-order terms

Here are the examples demonstrated using SWI-Prolog.

Many find the use of either the line debugger trace/0 or the GUI debugger gtrace/0 to be helpful.

Overview of the Debugger


To also help in learning syntatic unification see

It demonstrates the terms as trees

image

and also demonstrates the variables and values using other symbols to help one transition to thinking in other patterns.

image


As for your title question

How the Interpreter of SWIPL works

Towards the end of this topic is related information

In paticular https://www.swi-prolog.org/download/publications/A_Portable_Prolog_Compiler.pdf

2 Likes