Zzzcode.ai works as a teacher for PROLOG

While searching for an answer to my problems with PROLOG syntax,
I found the following AI: zzzcode.ai. Here you can ask questions in any language (German, English, etc.) and get answers in your favourite language:

My question in German was : “Wie kann ich eine Variable innerhalb eines Prolog-Programms definieren, um sie in verschiedenen Prädikaten mehrfach zu verwenden? (How can I define a variable within a Prolog program so that it can be used multiple times in different predicates?)

AI answer: “In Prolog, there are no classic variables as in other programming languages.
Instead, we use predicates and facts to store and process data.
To use a ‘variable’ in multiple predicates, you can define a common predicate
that stores the desired values. Here is a simple example:

% Definition eines Fakts
farbe(baum, grün).
farbe(himmel, blau).

% Prädikat, das die Farbe eines Objekts abruft
zeige_farbe(X) :-
    farbe(X, Farbe),
    format('Die Farbe von ~w ist ~w.~n', [X, Farbe]).

% Verwendung des Prädikats
?- zeige_farbe(baum).
?- zeige_farbe(himmel).

And the AI-explanation of the example: “In this example, the predicate color/2 is used
to store the colors of different objects. The predicate show_color/1 can then
be called to display the color of an object. This allows you to use the
‘variables’ in different predicates by defining them in a common context.

It helped me get my first PROLOG program up and running. Coole AI

Viele Grüße | Best regards

Siegfried

Bah, if you ask me, that “explanation” is really just atrocious, and calling that a “teacher” is rather the nail in the coffin of any learning and teaching: especially the learning. Anyway, I guess we’ll have to agree to disagree.

2 Likes

Given the question, the answer is quite OK, really. I am not sure what exactly is so bad about it.

It only comes to show how common that specific line of questions is for people trying to program Prolog.

As for learning and teaching and so on: until now, we have spent a shocking amount of education on reading and writing (and orthography and grammar and all that stuff). Now, we have computers who are better than any of us at all of that. I wish we would start asking the real questions, for example:

  • Now that computers are better than students at homework, should we change the homework?
  • Now that sounding clever is no longer a human privilege, do we keep trying to sound clever or do we move on?
  • Now that anyone can create text that sounds like they are educated and clever, how can we really tell?

Just as a starting point.

1 Like

I agree to that bullet points. But before I became clever, I have to ask stupid questions…

My question was the typical question of a procedural programmer—and it only took this very simple answer for me to realize my idea. In terms of syntax and grammar, AI is definitely better than me. But: I (as a human being) have ideas and visions. I want to implement them, I am enthusiastic.

And if it doesn’t work with PROLOG or Python, I’ll find another way. Just do it. If it turns out wrong, I’ll change my solution. But I can only change course after I’ve started. That’s what makes the difference for me compared to AI. I don’t wait for a prompt. I am the prompt! :smiley:

Check out https://exercism.org as well. They have the classic Zebra problem and about 90 other exercises.