# Assertions

Establishing relationships and constraints between inputs, outputs and variables is key to building a ZK program.

To generate a constraint, use predicates like `eq`

that produce Boolean results as the argument for `assert`

. This will create constraints that are fulfilled when the predicate is `true`

.

## Predicates

### Equality

The `eq`

predicate returns `true`

when the expressions on both sides of the equation evaluate to the same value.

### Inequality

Similar to `eq`

, but returns the opposite result.

### Comparisons

#### Less than or equal to

#### Less than

#### Greater than or equal to

#### Greater than

### Logical operations

Any functions that produces Boolean will do, here are some common built-in Boolean operators.

#### Conjunction

#### Disjunction

**Exclusive disjunction**

**Exclusive disjunction**

**Complement**

**Complement**

## Examples

`square`

`square`

Here's another program that takes two inputs and asserts that the second input is the square of the first input:

Compiling this function would result in:

The resulting constraint system has two input variables, `$0`

and `$1`

, and an additional constraint stating that `$1`

should be the square of `$0`

, which is exactly what we want.

Note that because `square`

returns `()`

, it would generate no output variable when compiled.

Last updated