Differences w.r.t. Prolog

This is a reference page. If you haven't seen the whole tour by now it is probably better to continue reading the tour.

The language that GUPU supports is basically a subset of (SICStus-)Prolog. There are only a few extentions and lots of restrictions.

GUPU's extentions to Prolog

Overview.

Lines starting with < > * # @ !, Assertions/Goals, Negative Assertions.
Lines starting with < > * # @ !
These lines have a special meaning. When compiling a GUPU-text in an ordinary Prolog system, these lines should be preceeded with a %-comment They have no meaning outside the environment.

< is a line containing a question of the student; > is an answer to a student's questions. *> is an answer to a student's questions when it first appears on the screen. # is a line of the example statement. @ is a line of an answer substitution. It is a temporary line, which is deleted every time an example is saved. ! is an error line. It is a temporary line which is deleted and possibly regenerated after saving.

Assertions/Goals
Assertions/goals (starting with :-) are treated differently to SICStus-Prolog. First the complete program text is loaded, and only then are assertions tested. It is thus possible to write an assertion/goal before the definition of a predicate. In SICStus-Prolog these goals are executed while compiling the program text. Therefore assertions in SICStus can only be written after a predicate's definition.
Negative Assertions
A negative assertion :/- Goal is operationally equivalent to :- \+ (Goal). It's just syntactic sugar, to avoid talking about negation proper too early in the course.

GUPU's subset of Prolog

GUPU uses a subset of (SICStus-) Prolog. The restrictions enforce a clear and uniform coding style. Most of these errors are valid Prolog texts but they are definitely an indication that something is wrong or at least unreadable.

If the restrictions below are violated an example cannot be loaded. So you have to fix the example first. Prior experience has shown that warnings as e.g. SICStus produces them for void variables are ignored by most of the students.

Overview. /* */ comments, Layout of predicates, Old fashioned BIPs, I/O-predicates, Misleading predicates, Orthographical errors in names, Declarative errors in names, Void variables, Variable names, Atoms, \+/1 in assertions, Badly typed predicates, Incorrect usage of BIPs, Ad hoc restrictions, et cetera.

/* */ comments
Only %-comments are possible.
Layout of predicates
The following restrictions ease reading program text. Many subtle typing errors are avoided. For most of these errors a detailed error message is produced.
Old fashioned BIPs like name/2
They are not allowed. Alternate predicates atom_chars/2, number_chars/2 are proposed.
:- name(Atomic,Chars).
! Bitte verwenden Sie nicht das vordefinierte Prädikat name/2 sondern statt dessen atom_chars/2 oder number_chars/2. Je nachdem. \Hinweis{BIP_name} begründet, warum name/2 keine gute Idee ist.
I/O-predicates
All of them are forbidden. Output is only visible via answer substitutions. However, it is possible to display answer substitutions graphically. This has big advantages w.r.t testing: you have to write predicates in such a manner that they can be tested easily. In contrast, a predicate writing to a file cannot be tested automatically with ease. You have to find a safe place where the file should go (/tmp is for sure not a good idea), you have to keep a copy to compare the file with etc.etc.
:- format('Hello world~n', []).
! ! Das Prädikat :format/2: ist ein vordefiniertes Prädikat mit Seiteneffekten. Ist in dieser Umgebung nicht erlaubt und gar nicht sinnvoll.
Misleading predicates like -/2
They cannot be defined, another name must be used instead. In most cases these predicates are typos.
Orthographical errors in names
Certain names are forbidden and a correction is suggested. E.g. borders instead of broders.
Declarative errors in names
Many suggestive imperative (= command oriented) names are forbidden. E.g. append, add, merge, reverse.
Void variables
Void variables have to start with _. In the head voids must have a name to document an arguments meaning. In the case below _Xs instead of _ is definitely preferable, just to underline, that the tail should be a list.
member(X,[X|_]).
! Bitte  verwenden Sie für _ Variablen in diesem Faktum sprechendere Namen, wie _Mutter
(And - if we are at it, the name should not be member/2 but rather member_of/2, member_oflist/2, member_list/2 or if you insist member_/2.)
Variable names
Variables other than voids must not start with _.
equal(_X,_X).
! ! Mit _ beginnende Variablen sollen nur genau einmal vorkommen:[_X]
Atoms
Some atoms with typical variable names are not allowed in certain predicates.
:- kind_von(vater,X).
! ! Bitte beachten Sie, daß Variablen in Prolog mit einem Großbuchstaben bzw. mit _ beginnen. Hier steht das Atom :vater: das wahrscheinlich eine Variable sein soll.: Also großgeschrieben werden soll.
\+/1 in assertions
Not in assertions must not contain variables occuring after the not.
:- \+ p(X), g(X).
! \+ darf hier nicht verwendet werden. \Hinweis{Konsistenzprüfung}
Badly typed predicates
While GUPU contains no type system, certain simple type errors are indicated. In the beginning e.g., students frequently use a functional instead of a relational notation. A general type system might help to find this error and even more errors, but the point is that the error messages produced by GUPU are specific to the situation. A language with a type system usually produces error messages that are difficult to understand and therefore provide no help to fix the errors fast.
:- kind_von(kind_von(A),B).
! Bitte beachten Sie, daß Argumente von Zielen Terme sind, aber keine anderen Ziele.
Incorrect usage of BIPs
a(X) :-
	X is Y,
	X = Y.
! ! Im Arithmetikprädikat :is/2: kommt die Variable :Y: vor. Sie wird jedoch IMMER eine freie Variable sein. Es wird also immer hier ein Fehler bei einem Beweis auftreten.
Similarily many problems with setof/3 are detected.
Ad hoc restrictions
This is the largest part of the error messages. Most of such error messages are added after a student has done such an error. So at least other students get immediate feedback.
is_baum(_Baum).
! Dieses Faktum ist sicher nicht richtig. Was bedeutet dieses Faktum? Alles ist ein Baum? vgl. :- is_baum(napoleon_III).
and many more ...

[logprog|GUPU|UWN]