Navigation
Synopsis The reflexive transitive closure of a binary list relation.
Syntax Exp *
Types
Exp Exp *
lrel[T1, T2] lrel[T1, T2]
Description Reflexive transitive closure is defined by repeated composition of a list relation. If we define for a given list relation R:
  • R0 = identity relation = [<a, a>, <b, b> | <a, b> <- R]
  • R1 = R
  • R2 = R o R
  • R3 = R o R2
  • ...
then the reflexive transitive closure R* can be defined in two ways: (also see TransitiveClosure):
  • R* = R0 + R1 + R2 + R3 + ...
  • R* = R0 + R+
Examples
rascal>[<1,2>, <2,3>, <3,4>]*;
lrel[int,int]: [
  <1,2>,
  <2,3>,
  <3,4>,
  <1,3>,
  <2,4>,
  <1,4>,
  <4,4>,
  <3,3>,
  <2,2>,
  <1,1>
]

Questions
Question [1].
The type of [<1,0>,<0,1>,<1,2>,<2,3>]* is

Question [2].
[<4,2>,<1,2>,<2,3>,<3,4>]* == 



Is this page unclear, or have you spotted an error? Please add a comment below and help us to improve it. For all other questions and remarks, visit ask.rascal-mpl.org.