Hello. I’m confused about the following from the Practical Alloy book:
Relations can be navigated forwards, from the source signature to the target signature, but also backwards from the target signature to the source one.
Here’s a model from the book:
abstract sig Object {}
sig File extends Object {}
sig Dir extends Object {
entries : set Entry
}
sig Entry {
object : one Object,
name : one Name
}
I understand the forward navigation. First, it the dot was chosen to make it readable, and second, It’s turtles tuples all the way down.
For example,
entries.e
denotes the set of directories that contain entrye
: this set can be empty, ife
is not contained in any directory, or even have more than one directory, since when declaring a field there are no multiplicity restrictions imposed on the source signature. We can also compose with an arbitrary set on the right-hand side: for example,entries.Entry
is the set of all directories that contain some entry. Compositions can also be chained to obtain atoms that are somehow indirectly related. For example,d.entries.object
denotes the set of all file system objects that are contained in some entry of directoryd
.
An example from the Software Abstractions book on how the dot join works is helpful:
Examples. Here are some example of joins of tuples:
{(N0, A0)} . {(A0, D0)} = {(N0, D0)}
{(N0, D0)} . {(N0, D0)} = {}
{(N0, D0)} . {(D1)} = {}
{(N0)} . {(N0, D0)} = {(D0)}
{(N0, D0)} . {(D0)} = {(N0)}
{(B0)} . {(B0, N0, D0)} = {(N0, D0)}
The simplest example in our case is {(D0)} . {{D0, E0}} . {(E0, O0)} = {(O0)}
, and this is indeed the set of all file system objects that are contained in some entry of directory d
.
Now, I find it confusing how to read backwards navigation.
And again, it is possible to navigate backwards through a chain of compositions. For example,
entries.object.d
denotes the set of all directories that have some entry that points to directoryd
.
First, I can’t construct a good example for entries.object.d
. Is it {(E0, O0)} . {(O0)} . {(D0)}
? Could anyone provide an example that clarifies this in terms of tuples?
Second, how to is it meant to be read without looking into tuples? Is it (entries.object).d
or entries.(object.d)
here? It’s presented as something natural.