Add the ppa ppa:swi-prolog/stable:
sudo add-apt-repository ppa:swi-prolog/stable
Update the package:
sudo apt-get update
Install SWI-Prolog through the package manager:
sudo apt-get install swi-prolog
You can run your your code with the following:
swipl -f .\HelloWorld.pl