I have a piece of code in ALLOY I am trying to do a restaurant reservation system and I have this sig and relation between them.
abstract sig Table{
breakfast: one breakFast,
lunch: one Lunch,
dinner: one Dinner
}
sig Free{
}
sig Reserved{
}
sig breakFast {
breakfastfree:one Free,
breakfastReserved:one Reserved
}
sig Lunch {
Lunchfree:one Free,
LunchReserved:one Reserved
}
sig Dinner {
Dinnerfree:one Free,
DinnertReserved:one Reserved
}
fact{
all t1,t2 : Table | t1 != t2 => t1.breakfast != t2.breakfast
all t1,t2 : Table | t1 != t2 => t1.lunch != t2.lunch
all t1,t2 : Table | t1 != t2 => t1.dinner != t2.dinner
}
pred RealismConstraints []{
#Table = 4
}
run RealismConstraints for 20
I want to put a fact that for breakfast it can be reserved or free NOT BOTH and in lunch and dinner the same thing any ideas?
First, the way you've constrained
breakfastfree
andbreakfastReserved
it will always be both. You need to uselone
(no object or one):Then, you could write the fact:
or, simpler, just:
However, I'd suggest that you just go with something like
and treat
no breakfastReserved
as "free". You don't need any further facts then.