# Alloy Authors - Practical Alloy - Higher-arity relations (Highlights)

## Metadata
**Review**:: [readwise.io](https://readwise.io/bookreview/50946535)
**Source**:: #from/readwise #from/reader
**Zettel**:: #zettel/fleeting
**Status**:: #x
**Authors**:: [[Alloy Authors]]
**Full Title**:: Practical Alloy - Higher-arity relations
**Category**:: #articles #readwise/articles
**Category Icon**:: 📰
**URL**:: [practicalalloy.github.io](https://practicalalloy.github.io/chapters/structural-topics/topics/nary-relations/index.html)
**Host**:: [[practicalalloy.github.io]]
**Highlighted**:: [[2025-04-28]]
**Created**:: [[2025-05-10]]
## Highlights
- In theory, we can declare fields of an arbitrary arity in an Alloy model. In practice, relations with a large arity become impossible to processed by the Analyzer. ([View Highlight](https://read.readwise.io/read/01jsxs8p3d8w5eta3r9r5qe54e)) ^882950365
- Interestingly, once we encode the content of a directory as a ternary relation, we can actually enforce this constraint directly when declaring the field. Higher-arity fields can also be restricted by multiplicity constraints in their declaration. ([View Highlight](https://read.readwise.io/read/01jsxsd0ttcqr2rxbtetkxnd4m)) ^882951047
`contents: Name -> lone Object`
- By inspecting function `descendants`, it is obvious that the name of the objects inside a directory is irrelevant to calculate this relation, so what we need is to convert ternary field `contents` in `Dir -> Name -> Object` to a binary version in `Dir -> Object` that relates directories with their content disregarding the name. Unfortunately, there is no straightforward way to achieve this using only relational operators, and we need to rely on defining this relation by *comprehension*. ([View Highlight](https://read.readwise.io/read/01jsxsgf84xn3888vq3ks0xbd8)) ^882951343
- Relations can be defined by comprehension by quantifying over a sequence of variables, and keeping only the tuples that satisfy a formula defined over those variables. ([View Highlight](https://read.readwise.io/read/01jsxsjacpavmssyszd8w1r546)) ^882951369
`{ elements | conditions }`