Prolog is a logic programming language with characteristics very different from popular programming languages such as Python and JavaScript. Prolog is modeled after first-order predicate logic in formal logic.
# install prolog on ubuntu
sudo apt update ; sudo apt-get install swi-prolog
The basic constructs of logic programming, terms and statements, are inherited from logic. There are three basic statements:
Facts are fundamental assertions about the problem domain (e.g. “Socrates is a man”) Rules are inferences about facts in the domain (e.g. “All men are mortal.”) Queries are questions about that domain (e.g. “Is Socrates mortal?”)
As mentioned above, Prolog code has three attributes: Facts, Rules, and Queries. Roughly speaking, facts are things that are true, rules are things related to truths, and queries are questions.
Introduction to logic programming with Prolog
Prolog execution is performed as follows:

yuis@yuis:~/pg/prolog$ cat > dev.pl
man(socrates).
mortal(X) :- man(X).
yuis@yuis:~/pg/prolog$ prolog -q
?- mortal(socrates).
ERROR: Undefined procedure: mortal/1 (DWIM could not correct goal)
?- [dev].
true.
?- mortal(socrates).
true.
?-
The following results in an error:

yuis@yuis:~/pg/prolog$ prolog -q
?- man(socrates).
ERROR: Undefined procedure: man/1 (DWIM could not correct goal)
?-
What I’m trying to say is that facts and rules should be written in a file and loaded, while queries should be executed on the interactive shell.
Loading files in Prolog - Stack Overflow
Looking at many Prolog reference articles, they write as if facts like man(socrates). can be defined and executed on the interactive shell, but doing so will result in errors. It’s probably a difference in version or something.
Therefore, if you want to put code directly into the interactive shell, you would write it like this:

yuis@yuis:~/pg/prolog$ prolog -q <<< " $( printf "[dev].\nmortal(socrates)." )"
true.
true.
To introduce my personal approach, I prepare two files, one for facts and rules, and one for queries, and do the following:
prolog <<< " $( printf "[dev_facts].\n$( cat dev_queries.pl )" ) "