I present two Alloy translations for each of the definitions on this page. The first translations are hugely instructive and are taken from J. N. Oliveira's work on relational methods in software engineering. They present to you in black and white how the various relation classes form a taxonomy. However, using them in your specifications will likely inflate the state space the analyser must explore. That's where the second translation comes in. I took these from Alcino Cunha's writings on Alloy. He calls it the "Relation Bestiary". They'll not explode your state space, but they make it harder to see how the taxonomy is formed. You should be fluent in both translations.
AbstractionABR
SimpleABR
SurjectiveABR
pred Abstraction(A,B: set univ, R: univ->univ) {
Simple[A,B,R]
Surjective[A,B,R]
}
pred Abstraction(A,B: set univ, R: univ->univ) {
R in A some -> lone B
}
BijectionABR
InjectionABR
SurjectionABR
pred Bijection(A,B: set univ, R: univ->univ) {
Injection[A,B,R]
Surjection[A,B,R]
}
pred Bijection(A,B: set univ, R: univ->univ) {
R in A one -> one B
}
EndoFunctionAR
FunctionAAR
pred EndoFunction(A: set univ, R: univ->univ) {
Function[A,A,R]
}
EndoRelationAR
RelationAAR
pred EndoRelation(A: set univ, R: univ->univ) {
Relation[A,A,R]
}
EntireABR
RelationABR
∀(a∈A::∃(b∈B::R.a.b))
pred Entire(A,B: set univ, R: univ->univ) {
Relation[A,B,R]
all a: A | some b: B | a->b in R
}
pred Entire(A,B: set univ, R: univ->univ) {
R in A -> some B
}
FunctionABR
EntireABR
SimpleABR
pred Function(A,B: set univ, R: univ->univ) {
Entire[A,B,R]
Simple[A,B,R]
}
pred Function(A,B: set univ, R: univ->univ) {
R in A -> one B
}
InjectionABR
InjectiveABR
FunctionABR
pred Injection(A,B: set univ, R: univ->univ) {
Injective[A,B,R]
Function[A,B,R]
}
pred Injection(A,B: set univ, R: univ->univ) {
R in A lone -> one B
}
InjectiveABR
RelationABR
∀(x∈B::∀(y,z∈A:R.y.x∧R.z.x:y=z))
pred Injective(A,B: set univ, R: univ->univ) {
Relation[A,B,R]
all x: B | all y,z: A | y->x in R and z->x in R implies y = z
}
pred Injective(A,B: set univ, R: univ->univ) {
R in A lone -> B
}
RelationABR
R⊆A×B
pred Relation(A,B: set univ, R: univ->univ) {
R in A->B
}
RepresentationABR
InjectiveABR
EntireABR
pred Representation(A,B: set univ, R: univ->univ) {
Injective[A,B,R]
Entire[A,B,R]
}
pred Representation(A,B: set univ, R: univ->univ) {
R in A lone -> some B
}
SimpleABR
RelationABR
∀(x∈A::∀(y,z∈B:R.x.y∧R.x.z:y=z))
pred Simple(A,B: set univ, R: univ->univ) {
Relation[A,B,R]
all x: A | all y,z: B | x->y in R and x->z in R implies y = z
}
pred Simple(A,B: set univ, R: univ->univ) {
R in A -> lone B
}
SurjectionABR
FunctionABR
SurjectiveABR
pred Surjection(A,B: set univ, R: univ->univ) {
Function[A,B,R]
Surjective[A,B,R]
}
pred Surjection(A,B: set univ, R: univ->univ) {
R in A some -> one B
}
SurjectiveABR
RelationABR
∀(b∈B::∃(a∈A::R.a.b))
pred Surjective(A,B: set univ, R: univ->univ) {
Relation[A,B,R]
all b: B | some a: A | a->b in R
}
pred Surjective(A,B: set univ, R: univ->univ) {
R in A some -> B
}