Combinatorial Programming

  • Declare function signatures
  • Optionally: define functions explicitly
  • Post constraints over these functions
  • Reason over set of admissible functions
  • Functions are total and strongly typed along bool, int, string

= != > < >= =< + - * /
not and or xor implies

div rem abs min max count

distinct same if-then-else


Explanation for unexpected satisfiability

Try it online at

Explanation for unexpected unsatisfiability

declare drinksAlcohol: -> bool.
declare age: -> {0..150}.
age() >= 18 implies drinksAlcohol().

define drinksAlcohol() as true.
define age() as 0.

· · age() [0]
· >= [false]
· · 18

implies [true]
· drinksAlcohol() [true].

1  declare color: string -> {"r", "g", "b", "y"}.

2  declare border: string, string -> bool.


4  define border as {("NL","BE"), ("NL","DE"),
5  ("BE","LU"), ("BE","DE"), ("BE","FR"),
6  ("FR","LU"), ("FR","DE"), ("LU","DE")} default false.


8  all[ color(x)!=color(y) for x,y where border(x,y) ].

Bug: forget color "y"

Line 8: all[ color(x)!=color(y) for x,y where border(x,y) ].

Line 8: not color("BE")=color("DE")
Line 8: not color("BE")=color("FR")
Line 8: not color("BE")=color("LU")
Line 8: not color("DE")=color("FR")
Line 8: not color("DE")=color("LU")
Line 8: not color("FR")=color("LU")

Bug: wrong use of implication

Incorrect world returned

Explain in detail why constraints hold in world

Jo Devriendt

A knowledge base

system in the spirit of

Reasoning modes (inferences)

find intersect count

@minimize @maximize @mode

Fold-Map-Filter expressions

all any none odd even count
sum product min max
distinct same

ManyWorlds: Combinatorial Programming Summary

By Jo Devriendt

ManyWorlds: Combinatorial Programming Summary

Poster for XAI - the Explainable Symbolic AI workshop

  • 88