First, the Alloy code you wrote means that contents
is a ternary relation, that is a set of triples whose first coordinate is in FileSystem
, the second in Dir
and the third in FSObject
. Labelling arrows works well for binary relations, not really for ternary (or more) ones.
OK. So, this was the formalist view, without taking into account the designer’s intent when using this name. The relation could as well be called foo
or bar
without changing its mathematical meaning (that is, being a set of triples).
But:
- The word
contents
wasn’t chosen without a reason. Designers and programmers name things (sets, relations, types, variables, constants, functions, methods…) to convey a mental model, trying to use names as evocative of the modeled situation as possible.
- A ternary relation on sets A, B and C can also be viewed as (in mathematical terms: is isomorphic to) a function from A to P(A x B) or a function from A x B to P(C) (where, given a set X, P(X) is the powerset of X).
Here, it’s likely that the ternary relation was named contents
because it is the same to see it as a ternary relation or as a function from FileSystem x Dir to P(FSObject) (if you sit in a given filesystem and a given directory, then you can retrieve _the set of _ objects they contain).
I hope it’s clearer.
Notice also that your sketch doesn’t show some interesting situations. For instance, you could also have a triple (F2, D, O1), or (F2, D, O2), or both (remark that, in the first two cases, you can’t easily go on with drawing arrows as you did).
Finally we haven’t spoken of this lone
multiplicty yet: it adds a further constraint that says that, for all other columns of the relation (FileSystem
and FSObject
), there is at most one (lone) directory. In plain English, we rule out situations where, in a given filesystem, a given FSObject may belong to two (or more) different directories. For instance, you cannot have (F2, D, O3).
In Unix terms, this amounts to ruling out so-called “hard links”.