The Smith family and their three children want to pay a visit but they do not all have the time to do so. Following are few hints who will go and who will not:
o If Mr Smith comes, his wife will come too. o At least one of their two sons Matt and John will come. o Either Mrs Smith or Tim will come, but not both. o Either Tim and John will come, or neither will come. o If Matt comes, then John and his father will also come.
The following query will solve the problem:
[user] ?- Mr_Smith_comes => Mrs_Smith_comes, | Matt_comes \/ John_comes <=> 1, | Mrs_Smith_comes # Tim_comes <=> 1, | Tim_comes <=> John_comes, | Matt_comes => John_comes /\ Mr_Smith_comes, | label(Mr_Smith_comes, Mrs_Smith_comes, | Matt_comes, John_comes, Tim_comes]).
Mr_Smith_comes = 0 Mrs_Smith_comes = 0 Matt_comes = 0 John_comes = 1 Tim_comes = 1
yes
| scroll to top |
|