My Picat page

This page is maintained by Hakan Kjellerstrand (hakank@gmail.com)

Picat is a general-purpose programming language that incorporates features from logic programming, functional programming, and scripting languages. The letters in the name summarize Picat's features: Picat is created by Neng-Fa Zhou and Jonathan Fruhman.

Some links:

Book: Constraint Solving and Planning with Picat

Book by Neng-Fa Zhou, Håkan Kjellerstrand, and Jonathan Fruhman: Constraint Solving and Planning with Picat, Springer Verlag. ISBN: 9783319258812 (paper), 9783319258836 (e-book).



From the Springer page:
This book introduces a new logic-based multi-paradigm programming language that integrates logic programming, functional programming, dynamic programming with tabling, and scripting, for use in solving combinatorial search problems, including CP, SAT, and MIP (mixed integer programming) based solver modules, and a module for planning that is implemented using tabling.

The book is useful for undergraduate and graduate students, researchers, and practitioners.

The book page at https://picat-lang.org/ .
The complete book is available as a PDF.

My Picat programs/models

Here are some of my Picat programs/models. Many are ported from (or inspired by) my earlier B-Prolog models. There are also quite a few non-CP programs, e.g. problem from Rosetta Code and Project Euler.

The files are available (or will soon be available) at my Github repo: https://github.com/hakank/hakank/tree/master/picat .

They are separated in different sections:

Program for Picat v3

These programs are for Picat version v3 with (Prolog) Horn clauses, DCG's etc. Also, see Neng-Fa Zhou's port of GeoQuery to Picat v3:
github.com/nfzhou/geoquery.

Prolog benchmark suite, van Roy (etc)

The following programs are ported from SWI Prolog benchmark suite (https://github.com/SWI-Prolog/bench). Run with run_benchmark_v3.pi

Jan Burse's Prolog Benchmark

Jan Burse has a collection of some of the van Roy benchmarks. This benchmark is ported in benchmark_burse_v3.pi.

Pereira's Prolog Benchmark

Here is a port of the Fernando Pereira's Prolog benchmark collection: pereira_v3.pi

Other programs in v3

Here are some other programs, mostly ports from Prolog programs (in some cases it's not really a port, since the code work without any changes) . Note: Some program use the utils in v3_utils.pi which must also be downloaded.

Constraint Programming and SAT models

Here are models that mainly use the Constraint Programming (import cp.) or SAT (import sat.) solvers.

Decompositions of global constraints

Here are some (decompositions of) global constraints or similar general constraints:

Models using the BV module (requires Picat v3.9)

The bv module was introduced in Picat v3.9 for handling bitwise operators such as bv_and,, etc for specific bitsizes. It also handle much larger integer domains than the "plain" SAT solver (i.e. much larger integers than 2**56). Note that currently the bv module only supports positive integers and thus cannot handle negative numbers. Also, the output value of the operations can be larger value (overflow) than the size of the input values if it is not explicitly stated to be of a specific bit size; this might be seen as a great feature when modeling problems with very large integers.

Below are some examples of the module, not necessarily using fixed bit length or large integers. All models uses my
bv_utils module which expands the functionality of the built-in bv module.

Also see our ICLP'25 paper Picat Through the Lens of Advent of Code by Neng-Fa Zhou, Cristian Grozea, Hakan Kjellerstrand, Oisin Mac Fhearai), section "4 Day 17: Chronospatial Computer" for an example of how to use the bv module.