CLINGO is an answer set solver used to process declarative programs. Unlike an imperative language such as Python or C# where you program algorithms as a series of steps (changing program states), in a declarative programming language you instead describe the solution without describing the "how" of obtaining the solution. The answer set solver processes the program and outputs a "stable model" or "answer set" that meets the described solution.
Potassco
Source code on github
In version 5.4 and prior, the github maintainers provided a compiled executable that could be downloaded and used on Windows, however that is not the case for current versions.
CLINGO is really built to run on Linux. Our workflow will be to use the Windows Subsystem for Linux (WSL) to install and execute CLINGO, however we will use VS Code in Windows as our editor for the CLINGO program files on the WSL filesystem.
mkdir -p ~/miniconda3 wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda3/miniconda.sh bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3 rm -rf ~/miniconda3/miniconda.sh ~/miniconda3/bin/conda init bash
conda --version
to confirm it's correctly installedconda deactivate
will disable conda. conda activate
will enable conda.conda create -n potassco -c conda-forge clingo=5.6.2
conda activate potassco
clingo --version
to confirm it's correctly installedconda activate potassco
each time you restart TerminalAt this point you could use vim or nano in Ubuntu to create your CLINGO .lp files, however let's use VS Code.
In Ubuntu create a working folder: mkdir clingo
. You will put your programs (.lp files) here.
Open this folder in VS Code (yes, open an Ubuntu folder using VS Code on Windows)
\\wsl.localhost\Ubuntu\home\[your Ubuntu user name]\clingo
In VS Code create a new file program1.lp
Enter the following sample, and save the file.
% instance motive(harry). motive(sally). guilty(harry).% encoding innocent(Suspect) :- motive(Suspect), not guilty(Suspect).
In VS Code select Terminal -> New Terminal. Note that a Terminal window opens towards the bottom. The Terminal will likely default to "powershell". In the upper right of the Terminal window select the "+ v" (plus sign, down arrow) icon to change the Terminal to "Ubuntu (WSL)"
conda activate potassco
clingo program1.lp
to run your CLINGO program(optional) In VS Code click on the Extensions icon on the left to install the "Answer Set Programming syntax highlighter" from "abelcour" to add syntax highlighting to your .lp code.
You have now established an environment and workflow for editing and running CLINGO programs. If you have any feedback feel free to contact me jimsvoboda@unomaha.edu