-
Notifications
You must be signed in to change notification settings - Fork 13
The Standard Library
Corset comes with a standard library, that provides functions commonly used in the writing of constraints.
These functions implement boolean and loobean conditions on their operands.
(force-bool x) β¨ Any{M} β¦ πΉ
- forcibly casts
x
as a boolean value; it is up to the user to ensure thatx
is indeed guaranteed to be a boolean. It is recommended to accompany any calls to this function to adebug
call tois-binary
onx
.
These functions returns values whose interpretation is based on their zero-ness, without any assumptions on their value in the non-zero range.
(and x y) β¨ (Any{M} Any{M}) β¦ M
- returns 0 if
x
andy
are 0, a non-zero value otherwise (or x y) β¨ (Any{M} Any{M}) β¦ M
- returns 0 if
x
ory
are 0, a non-zero value otherwise (any x...) β¨ (Any{M} ...) β¦ M
- returns 0 if any of its arguments are zero, a non-zero value otherwise
(all x...) β¨ (Any{M} ...) β¦ M
- returns 0 if all of its arguments are zero, a non-zero value otherwise
(~ x) β¨ Any{M} β¦ πΉ
- returns
1
ifx
is non-zero,0
otherwise
These functions returns boolean values, which are equal to 1
when the function semantic is satisfied, and 0
otherwise.
(~and x y) β¨ (Any{M} Any{M}) β¦ πΉ
- returns
1
ifx
andy
are non-zero,0
otherwise (~or x y) β¨ (Any{M} Any{M}) β¦ πΉ
- returns a non-zero value if at least one of
x
andy
are non-zero, zero otherwise
These functions returns loobean values, which are equal to 0
when the function semantic is satisfied, and a non-zero value otherwise.
(eq! x y) β¨ (Any{πΉ} Any{πΉ}) β¦ π
- returns
0
ifx
andy
are equals, and1
otherwise (eq! x y) β¨ (Any{M} Any{M}) β¦ π
- returns
0
ifx
andy
are equals, and a non-zero value otherwise (neq! x y) β¨ (Any{M} Any{M}) β¦ π
- returns
1
ifx
andy
are equals, and0
otherwise (and! x y) β¨ (Any{M} Any{M}) β¦ π
- returns
0
ifx
andy
are non-zero, and a non-zero value otherwise (or! x y) β¨ (Any{M} Any{M}) β¦ π
- returns
0
if at least one ofx
andy
are non-zero, and a non-zero value otherwise (any! x...) β¨ (Any{M} ...) β¦ π
- returns
0
if any of its arguments is zero, a non-zero value otherwise (all! x...) β¨ (Any{M} ...) β¦ π
- returns
0
if all of its arguments are zero, a non-zero value otherwise
Chronological functions peeks into the past or future values of columns or expressions, allowing the writing of constraints describing to the temporal evolution of the system rather than its instantaneous state.
Access functions fetch the value of a column at a different row than the currently evaluated one, and are the primitives used to build all more specialized chronological function.
(shift X n) β¨ (Column{M} int) β¦ Column{M}
- returns the value of the column
X
n
steps in the past (ifn
is negative) or the future (ifn
is positive) (prev X) β¨ Column{M} β¦ Column{M}
- return the value of
X
one step in the past (next X) β¨ Column{M} β¦ Column{M}
- return the value of
X
one step in the future
These functions define constraints to the variation of a column in the temporal dimension.
These functions impose an exact numeric variation on the concerned column.
(did-inc! X offset) β¨ (Column{M} integer) β¦ ο»Ώπ
- ensures that
X
increased byoffset
during the transition between the previous row and the current (did-dec! X offset) β¨ (Column{M} integer) β¦ ο»Ώπ
- ensures that
X
decreased byoffset
during the transition between the previous row and the current (will-inc! X offset) β¨ (Column{M} integer) β¦ ο»Ώπ
- ensures that
X
will increase byoffset
during the transition between the current row and the next one (will-dec! X offset) β¨ (Column{M} integer) β¦ ο»Ώπ
- ensures that
X
will decrease byoffset
during the transition between the current row and the next one
These functions constrain whether a given column has (resp. will) remained constant (resp. changed) between two consecutive rows.
(remained-constant! X) β¨ (Column{M}) β¦ π
- ensures that
X
has not changed its value between the previous row and the current one (will-remain-constant! X) β¨ (Column{M}) β¦ π
- ensures that
X
will not change its value between the current row and the next one (did-change! X) β¨ (Column{M}) β¦ π
- ensures that
X
has changed value between the current row and the previous one (will-change! X) β¨ (Column{M}) β¦ π
- ensures that
X
will change its value between the current row and the next one
These functions impose a value to a given column at the previous (resp. next) row.
(was-eq! X n) β¨ (Column{M} integer) β¦ π
- ensure that
X
was equal ton
at the previous row (will-eq! X n) β¨ (Column{M} integer) β¦ π
- ensure that
X
will be equal ton
at the next row