Edit me

Constraints are predicates in the body of the rule that produces true and false values. Constraints can be equalities, inequalities, and string checks such as containment and string matching.

Constraint contains(string1, string2) is used to check if the latter string contains the former string.

.decl stringTable(t:symbol)
.decl substringTable(t:symbol)
.decl outputData(substr:symbol, str:symbol)
.output outputData
outputData(x,y) :- substringTable(x), stringTable(y), contains(x,y).
stringTable("aaaa").
stringTable("abba").
stringTable("bcab").
stringTable("bdab").
substringTable("a").
substringTable("ab").
substringTable("cab").

The output would be:

a	aaaa
a	abba
a	bcab
a	bdab
ab	abba
ab	bcab
ab	bdab
cab	bcab

Constraint match is used to check if the latter string matches a wildcard pattern specified in the former string.

.decl inputData(t:symbol)
.decl outputData(t:symbol)
.output outputData
outputData(x) :- inputData(x), match("a.*",x).
inputData("aaaa").
inputData("abba").
inputData("bcab").
inputData("bdab").

The output would be:

aaaa
abba

Soufflé supports inequalities and equalities, i.e., >, <, =, !=, >= and <=. Examples of this are given below.

A(a,c) :- a > c.
B(a,c) :- a < c.
C(a,c) :- a = c.
D(a,c) :- a != c.
E(a,c) :- a <= c.
F(a,c) :- a >= c.

Syntax

In the following, we define constraints and argument values in Soufflé more formally using syntax diagrams and EBNF. The syntax diagrams were produced with Bottlecaps.

Constraint

A constraint is a predicate in the body of a rule. It either produces a true or a false value. Constraints can be inequalities and equalities for primitive types, and there are string constraints for matching and containment ship.

constraint

constraint ::= argument ( '<' | '>' | '<=' | '>=' | '=' | '!=' ) argument
           | ( 'match' | 'contains' ) '(' argument ',' argument ')'
           | 'true'
           | 'false'