Alloy Introduction

Readings

Topics covered

  • Modeling general software systems.
    • Introduction to the Alloy modeling language.
    • Alloy’s foundadions.
    • Signatures, fields, and multiplicity constrainst.
  • Modeling simple domains in Alloy.
    • Generating and analyzing model instances.
  • Relations and operations on them.
    • Formulas, Boolean operators and quantifiers.
    • Expressing constraints on relations using Alloy formulas.
  • Functions and predicates.

Resources

  • A simple family model for the Alloy Analyzer: family-1.als
  • A simple family model with facts, different run configurations and assertions for the Alloy Analyzer: family-2.als

Transitive closure

A relation is transitive when it satisfies the transitivity property, which can be stated as:

∀xyz . ((x, y) ∈ R ∧ (y, z) ∈ R) → (x, z) ∈ R

for any relation R : A × A, with x,y,z ∈ A. The transitive closure of a relation R is the smallest transitive relation containing it. It can be defined as

R⁺ = R ∪ (R ; R) ∪ ((R ; R) ; R) ∪ ...

in which ; is relation composition.

Consider a relation S = {(a, b), (b, c)}. This relation is not transitive. Its transitive closure can be obtained by creating a new relation T which contains S, is transitive, and is the smallest relation with these two properties. This is the case if T = {(a, b), (b, c), (a, c)}, i.e., T = S ∪ (S ; S).

Note that (S ; S) ; S is the empty set. So no new pairs can be obtained via composition.