Skip to main content




Relation values.


{ < Exp₁₁, Exp₁₂, ... > , < Exp₂₁, Exp₂₂, ... > , ... }


Exp₁₁Exp₁₂...{ < Exp₁₁, Exp₁₂, ... > , ... }
T₁T₂...rel[T₁, T₂, ... ]


A relation is a set of elements with the following property:

  • All elements have the same static tuple type.

Relations are thus nothing more than sets of tuples, but since they are used so often we provide a shorthand notation for them. Relations are represented by the type rel[T₁ L₁, T₂ L₂, ... ], where T₁, T₂, ... are arbitrary types and L₁, L₂, ... are optional labels. It is a shorthand for set[tuple[T₁ L₁, T₂ L₂, ... ]].

An n-ary relations with m tuples is denoted by {< E₁₁, E₁₂, ..., E₁ₙ >,< E₂₁, E₂₂, ..., E₂ₙ >, ..., < Eₘ₁, Eₘ₂, ..., Eₘₙ >}, where the Eᵢⱼ are expressions that yield the desired element type Tᵢ.

Since relations are a form of set all operations (see Set) and functions (see Set) are also applicable to relations.

The following additional operators are provided for relations:

There are also library functions available for Relations.


rascal>{<1,10>, <2,20>, <3,30>}
rel[int,int]: {

instead of rel[int,int] we can also give set[tuple[int,int]] as type of the above expression remember that these types are interchangeable.

rascal>{<"a",10>, <"b",20>, <"c",30>}
rel[str,int]: {
rascal>{<"a", 1, "b">, <"c", 2, "d">}
rel[str,int,str]: {