I am trying to write an Alloy function to retrieve all elements of a certain type that are in relation with the parameter of the function (let me say, that have that value for one of their "fields/attributes"). I have tried in various ways, none of them worked.
It's something like
fun get[a:A] : set X{
(x.name :> a)
}
but this return a set of A while I want a set of X
You can do this more simply:
name.a
returns the set of X's that map under name to an element in a.
Checking equivalence to your version:
sig A { }
sig X {
name: set A
}
fun get [a:A] : set X{
((X <: name) :> a).A
}
fun get' [a:A] : set X{
name.a
}
check {
all a: A | get[a] = get'[a]
}