MACHINE Sorting
SETS Objects = {Obj1,Obj2,Obj3}
CONSTANTS lt, sz
PROPERTIES
  lt  = {Obj1↦Obj2, Obj1↦Obj3, Obj2↦Obj3} ∧
  sz ∈ NAT
VARIABLES arr
INVARIANT
  arr ∈ 1..sz → Objects 
INITIALISATION
  arr :∈ 1..sz → Objects
DEFINITIONS
  sorted(aa) == ∀ii.(ii∈2..sz ⇒ aa(ii-1)↦aa(ii) ∈ lt)
OPERATIONS
  SortArray = ANY pm WHERE pm ∈ perm(1..sz) ∧ sorted((pm ; arr)) THEN
    arr := (pm ; arr)
  END
END

