IF Computer > IF/Prolog > Constraint Technology Package > Example Programs > Smith Puzzle

Smith Puzzle

IF/Prolog by Siemens
MINERVA superseeded IF/Prolog. Please see http://www.ifcomputer.co.jp/MINERVA for details.

We discontinued to sell IF/Prolog Dec 31. 2003. For current customers, we continue to provide professional support for IF/Prolog until Dec 31, 2008.

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

document: http://www.ifcomputer.co.jp/IFProlog/Constraints/ExamplePrograms/SmithPuzzle/print_en.html
published 2008/7/7 update 1996/12/10 (c) 1996-2006 IF Computer Japan
IF Computer 5-28-2 Sendagi, Bunkyo-ku Tel +81-3-5814-3352 info@ifcomputer.com
Customer Support Tokyo 113-0022 Japan   http://www.ifcomputer.com
Back> managed with ubiCMS