How to hide solutions in a Prolog learning tool?

I will give a Prolog course soon and have prepared exercises and solutions for different topics (e.g. list programming,…).

Furthermore, I have written a test program that can be used by the students to compare their solution with the given solution prepared by me. The test program checks for typical errors (e.g. missing or too many solutions, …) and, if the student’s solution is different from the given solution, provides a counter example showing that and why the student’s solution is different from the given solution. Furthermore, if the student’s solution is more complex than the given solution, the program tells the student that his or her solution is more complex than the given solution.

My students will use SWI-Prolog at home on different operating systems (Windows, MacOS, different versions of Linux) and shall use my test program.
However, the students shall not see my solutions.

What is the best way to do that?

Currently, I have compiled my test program (containing my solutions and the test cases for typical errors) into a saved state. I am using SWI-Prolog 8.0.2-1, but I do not know how to avoid that I have to provide one saved state for each operating system.

Is there a better way to hide solutions in a Prolog learning tool?

I would appreciate any help or comments to find a better solution.

Stefan

Hiding stuff inside Prolog is of course not much more than obfuscating. With some dedication your students will always be able to get to the data. The only safe solution is to provide a service that you control. Of course, it might be easier for the students to solve the exercises :slight_smile:

Unfortunately saved states are system dependent in 8.0. This limitation is removed in the 8.1 series.

If you can expect/demand all your users to use 64-bit machines, you could compile your program into a
.qlf file and ask your students to load the file to test their programs. .QLF files come in two versions: for 32 or for 64-bit. If you use no :- if(<some OS condition>) in your code they are OS independent. Again, the 8.1 versions are portable between 32/64 bit, but 8.1 and 8.0 qlf files are not compatible.

Finally, you may wish to use this in the sources that produce your .qlf file such that students cannot do listing on your code.

 :- set_prolog_flag(protect_static_code, true).

This stops clause/2 to work on static code. Note that that may affect exercises on meta interpreters …

The clean solution is probably to use a SWISH instance. With control over the server you can make a program available that students can run, but the SWISH sandboxing prohibits accessing code outside the sandbox except for calling it in a controlled manner.

Hope this helps …