A Fruit Exercise
Let's use the logical modelling tool to choose some fruit.
The constraints:
At least one of
apples
,oranges
,pears
, orbananas
must be chosen.If
apples
is chosen, then we must chooseoranges
If
bananas
is chosen, then we must not choosepears
.We cannot have both
oranges
andpears
.
Fill in the definitions below to express these constraints in logical form:
atom apples
atom oranges
atom pears
atom bananas
define constraint1 {
you_fill_this_in
}
define constraint2 {
and_this
}
define constraint3 {
and_this_one
}
define constraint4 {
and_here
}
allsat (constraint1 & constraint2 & constraint3 & constraint4)
{ "apples" : apples, "oranges" : oranges, "pears" : pears, "bananas" : bananas }
The output should look like this, with 6 possible solutions:
{
"apples": false,
"oranges": true,
"pears": false,
"bananas": false
}
{
"apples": false,
"oranges": false,
"pears": false,
"bananas": true
}
{
"apples": true,
"oranges": true,
"pears": false,
"bananas": false
}
{
"apples": false,
"oranges": true,
"pears": false,
"bananas": true
}
{
"apples": true,
"oranges": true,
"pears": false,
"bananas": true
}
{
"apples": false,
"oranges": false,
"pears": true,
"bananas": false
}