Is it possible to give a time restriction to a GAP program? I have written a GAP program that returns "true" or "false" as output.
I would like to modify the program in the following way:
If the computation is not finished after 20 seconds, then its output shall be "false".
Is this possible with GAP?
Example:
I would like to use this program in order to test if an ideal in a family of ideals has a certain property. If the computation does not finish after 20 seconds, then the ideal will most likely not have this property.
I would like to have a probabilistic program in that sense.
Thank you.
 A: In version 4.8 it is possible to call a function with a provided timeout as described in this answer. However, this functionality seems to have serious problems as described in this issue on GitHub and was therefore withdrawn in version 4.9 as stated here.
There is no convenient way (and with convenient I am rereferring to some sort of build in functionality) to achieve what you desire in the current version of plain GAP if we consider the GAP reference as a complete description of its capabilities.
However, using the parallelization options described in HPC-GAP, we could start our calculation in a separate thread, while letting the main thread checking the exceeded time. I have never used it, so I am not sure if this would actually work. I tried it, but failed.
We could also embed the entire GAP system as a C library and call GAP functions in a C program. We could easily monitor the runtime within this program.
Also, and already mentioned by Ethan Bolker in the comments, you can write a GAP program and call it via a shell script. Monitoring the runtime there is also possible. The procedure is described in this answer.
It might also be convenient in some cases to use the GAP interface in SageMath.
