There is a set of college students:
sig Student {}
Each student has an attribute indicating what year he/she is in college (first year, second year, etc.):
sig Student {
year: Int
}
The value of year must be 1, 2, 3, or 4. Here is one way to constrain the year field:
sig Student {
year: Int
} {
year in {i: Int | i=1 or i=2 or i=3 or i=4}
}
Is there a better (simpler, more intuitive) way to constrain year?
-- Enumerate
let YEARS = 1+2+3+4
-- or Range
let YEARS = { y : Int | y >= 1 and y <= 4 }
sig Student { year: Int } {
year in YEARS
}
Or more concise
sig Student { year: YEARS }