Regarding "main", note that an exit status of 0 indicating "success" is a convention that is true on most systems (in particular, POSIX-conforming systems), but there may be exceptions: https://en.wikipedia.org/wiki/Exit_status#POSIX
main starts a Goal of arity 0.
library(main) provides Goal
main/0, which calls
main/1 with the argument vector. You are supposed to code up
Thus, for a program taking two arguments for example:
:- use_module(library(main)). :- initialization(main, main). main([Arg1, Arg2]) :- ....