Skip to content
  • Getting Started
  • HELP
  • Error Messages


This guide explains why you may experience an arity mismatch error and what potential solutions can solve it.

If you think of relations as tables, the arity of a relation in Rel is the number of columns. For instance, the constants true and false are relations of arity 0, a single element is a relation of arity 1, and so on. Check this section of Rel Primer: Basic Syntax for more details.

Consider the following example that returns an arity mismatch:

def friends = {("Mike", "Anna"); ("Zoe", "Jenn")}
def zoes_friends = friends("Zoe") 
Error example from the RAI Console

First, you define a relation friends containing tuples of friends. Then, to know Zoe’s friends you define zoes_friends. The error may be caused by these reasons:

  1. The relation you are calling expects a different number of arguments. In friends("Zoe"), you are passing just one argument, while friends is defined by tuples of arity 2.

  2. You are using parentheses, (), instead of square brackets, []. The operator () can be thought of as a special case of partial relational application used as a boolean filter, with output arity 0 (meaning either true or false). This means that when you write friends("Zoe"), the Rel compiler is expecting a second argument to check if that tuple is within the relation friends. See this section of Rel Primer: Basic Syntax for further insights.

Some correct examples could be:

// query
def friends = {("Mike", "Anna"); ("Zoe", "Jenn")}
def zoes_friends = friends["Zoe"]
def output = zoes_friends
Loading arity-sol1...

This returns Zoe’s friends list.

// query
def friends = {("Mike", "Anna"); ("Zoe", "Jenn")}
def zoes_friends = friends("Zoe", "Jenn")
def output = zoes_friends
Loading arity-sol2...

This returns (), i.e., true, confirming that the tuple is within the relation friends.

Was this doc helpful?