Skip to content

Facts

A Dusa program describes some solutions, and the Dusa interpreter finds those solutions. A solution is a set of propositions that have no free variables: we call propositions with no free variables facts.

This is a very simple program: it just says that there are three facts.

oneFact.
anotherFact.
theThirdFact.

A slightly more complicated set of facts could describe the position of the black pieces on this checkerboard:

position 2 1.
position 4 3.
position 1 4.

If you’re familiar with other logic programming languages, you may expect the first fact above to be written as position(2,1), but Dusa uses a more “curried” or Lisp-like syntax to say the same thing.

Relational propositions

A relational proposition is a predicate followed by any number of terms. In the examples above, oneFact, anotherFact and theThirdFact, and position 4 3 were all facts.

We say oneFact is a relational predicate that takes no arguments, and that position is a relational predicate that takes two arguments. Dusa enforces that most predicates are used with a consistent number of arguments throughout a program.

Functional propositions

Dusa also utilizes functional propositions, which consist of an attribute (a predicate plus zero or more terms), the keyword is, and then a value (a single term). One use for a functional proposition might be describing the checkerboard above: each piece has both a position and a color.

color 1 4 is "black".
color 2 1 is "black".
color 3 8 is "red".
color 4 3 is "black".
color 5 4 is "red".

The predicate plus its terms is called an attribute: for the fact color 1 4 is "black", the attribute is color 1 4 and the value is "black".

A key property of functional propositions is that Dusa forbids a solution from having two different facts with the same attribute but with different values. In the checkers example, this means that you can’t have two different pieces at the same position: a solution that tries to make color 1 4 is "red" and color 1 4 is "black" both facts will be invalidated for failing an integrity constraint.

These functional propositions aren’t unique to Dusa, but Dusa does interesting things by allowing a program to make choices about the connection between attributes and values.