This file is indexed.

/usr/share/mozart/doc/fdt/node23.html is in mozart-doc 1.4.0-8ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

1
2
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>4.3 Example: Zebra Puzzle</TITLE><LINK href="ozdoc.css" rel="stylesheet" type="text/css"></HEAD><BODY><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="node22.html#section.elimination.family">&lt;&lt; Prev</A></TD><TD><A href="node20.html">- Up -</A></TD></TR></TABLE><DIV id="section.elimination.zebra"><H2><A name="section.elimination.zebra">4.3 Example: Zebra Puzzle</A></H2><P>This example shows a clever problem representation avoiding possible symmetries. It also illustrates the use of defined constraints. </P><DIV class="unnumbered"><H3><A name="label67">Problem Specification</A></H3><P>Five men with different nationalities live in the first five houses of a street. There are only houses on one side of the street. The men practice distinct professions, and each of them has a favorite drink and a favorite animal, all of them different. The five houses are painted with different colors. The following facts are known: </P><OL type="1"><LI><P>The Englishman lives in a red house.</P></LI><LI><P>The Spaniard owns a dog.</P></LI><LI><P>The Japanese is a painter.</P></LI><LI><P>The Italian drinks tea.</P></LI><LI><P>The Norwegian lives in the first house.</P></LI><LI><P>The owner of the green house drinks coffee.</P></LI><LI><P>The green house comes after the white one.</P></LI><LI><P>The sculptor breeds snails.</P></LI><LI><P>The diplomat lives in the yellow house.</P></LI><LI><P>Milk is drunk in the third house.</P></LI><LI><P>The Norwegian's house is next to the blue one.</P></LI><LI><P>The violinist drinks juice.</P></LI><LI><P>The fox is in the house next to that of the doctor.</P></LI><LI><P>The horse is in the house next to that of the diplomat.</P></LI><LI><P>The zebra is in the white house.</P></LI><LI><P>One of the men drinks water.</P></LI></OL><P> Who lives where? </P></DIV><DIV class="unnumbered"><H3><A name="label68">Model</A></H3><P>We number the houses from 1 to 5, where 1 is the first and 5 is last house in the street. There are 25 different properties (i.&nbsp;e. hosting an Englishman, being the green house, hosting a painter, hosting a dog, or hosting someone who drinks juice), and each of these properties must hold for exactly one house. The properties are partitioned into five groups of five members each, where the properties within one group must hold for different houses. The model has one variable for each of these properties, where the variable stands for the number of the house for which this property holds. </P></DIV><DIV class="unnumbered"><H3><A name="label69">Distribution Strategy</A></H3><P>We distribute on the variables for the properties with the standard first-fail strategy. </P><DIV id="progzebra"><HR><P><A name="progzebra"></A></P><DL class="anonymous"><DD class="code"><CODE><SPAN class="keyword">proc</SPAN><SPAN class="variablename">&nbsp;</SPAN>{<SPAN class="functionname">Zebra</SPAN>&nbsp;Nb}<BR>&nbsp;&nbsp;&nbsp;Groups&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;[&nbsp;[english&nbsp;spanish&nbsp;japanese&nbsp;italian&nbsp;norwegian]<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[green&nbsp;red&nbsp;yellow&nbsp;blue&nbsp;white]<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[painter&nbsp;diplomat&nbsp;violinist&nbsp;doctor&nbsp;sculptor]<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[dog&nbsp;zebra&nbsp;fox&nbsp;snails&nbsp;horse]<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[juice&nbsp;water&nbsp;tea&nbsp;coffee&nbsp;milk]&nbsp;]<BR>&nbsp;&nbsp;&nbsp;Properties&nbsp;=&nbsp;{FoldR&nbsp;Groups&nbsp;Append&nbsp;nil}<BR>&nbsp;&nbsp;&nbsp;<SPAN class="keyword">proc</SPAN><SPAN class="variablename">&nbsp;</SPAN>{<SPAN class="functionname">Partition</SPAN>&nbsp;Group}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{FD<SPAN class="keyword">.</SPAN>distinct&nbsp;{Map&nbsp;Group&nbsp;<SPAN class="keyword">fun</SPAN><SPAN class="variablename">&nbsp;</SPAN>{<SPAN class="functionname">$</SPAN>&nbsp;P}&nbsp;Nb<SPAN class="keyword">.</SPAN>P&nbsp;<SPAN class="keyword">end</SPAN>}}<BR>&nbsp;&nbsp;&nbsp;<SPAN class="keyword">end</SPAN>&nbsp;<BR>&nbsp;&nbsp;&nbsp;<SPAN class="keyword">proc</SPAN><SPAN class="variablename">&nbsp;</SPAN>{<SPAN class="functionname">Adjacent</SPAN>&nbsp;X&nbsp;Y}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{FD<SPAN class="keyword">.</SPAN>distance&nbsp;X&nbsp;Y&nbsp;<SPAN class="string">'=:'</SPAN>&nbsp;1}<BR>&nbsp;&nbsp;&nbsp;<SPAN class="keyword">end</SPAN>&nbsp;<BR><SPAN class="keyword">in</SPAN>&nbsp;<BR>&nbsp;&nbsp;&nbsp;%%&nbsp;<SPAN class="comment">Nb&nbsp;maps&nbsp;all&nbsp;properties&nbsp;to&nbsp;house&nbsp;numbers<BR></SPAN>&nbsp;&nbsp;&nbsp;{FD<SPAN class="keyword">.</SPAN>record&nbsp;number&nbsp;Properties&nbsp;1<SPAN class="keyword">#</SPAN>5&nbsp;Nb}<BR>&nbsp;&nbsp;&nbsp;{ForAll&nbsp;Groups&nbsp;Partition}<BR>&nbsp;&nbsp;&nbsp;Nb<SPAN class="keyword">.</SPAN>english&nbsp;=&nbsp;Nb<SPAN class="keyword">.</SPAN>red<BR>&nbsp;&nbsp;&nbsp;Nb<SPAN class="keyword">.</SPAN>spanish&nbsp;=&nbsp;Nb<SPAN class="keyword">.</SPAN>dog<BR>&nbsp;&nbsp;&nbsp;Nb<SPAN class="keyword">.</SPAN>japanese&nbsp;=&nbsp;Nb<SPAN class="keyword">.</SPAN>painter<BR>&nbsp;&nbsp;&nbsp;Nb<SPAN class="keyword">.</SPAN>italian&nbsp;=&nbsp;Nb<SPAN class="keyword">.</SPAN>tea<BR>&nbsp;&nbsp;&nbsp;Nb<SPAN class="keyword">.</SPAN>norwegian&nbsp;=&nbsp;1<BR>&nbsp;&nbsp;&nbsp;Nb<SPAN class="keyword">.</SPAN>green&nbsp;=&nbsp;Nb<SPAN class="keyword">.</SPAN>coffee<BR>&nbsp;&nbsp;&nbsp;Nb<SPAN class="keyword">.</SPAN>green&nbsp;<SPAN class="keyword">&gt;:</SPAN>&nbsp;Nb<SPAN class="keyword">.</SPAN>white<BR>&nbsp;&nbsp;&nbsp;Nb<SPAN class="keyword">.</SPAN>sculptor&nbsp;=&nbsp;Nb<SPAN class="keyword">.</SPAN>snails<BR>&nbsp;&nbsp;&nbsp;Nb<SPAN class="keyword">.</SPAN>diplomat&nbsp;=&nbsp;Nb<SPAN class="keyword">.</SPAN>yellow<BR>&nbsp;&nbsp;&nbsp;Nb<SPAN class="keyword">.</SPAN>milk&nbsp;=&nbsp;3<BR>&nbsp;&nbsp;&nbsp;{Adjacent&nbsp;Nb<SPAN class="keyword">.</SPAN>norwegian&nbsp;Nb<SPAN class="keyword">.</SPAN>blue}<BR>&nbsp;&nbsp;&nbsp;Nb<SPAN class="keyword">.</SPAN>violinist&nbsp;=&nbsp;Nb<SPAN class="keyword">.</SPAN>juice<BR>&nbsp;&nbsp;&nbsp;{Adjacent&nbsp;Nb<SPAN class="keyword">.</SPAN>fox&nbsp;Nb<SPAN class="keyword">.</SPAN>doctor}<BR>&nbsp;&nbsp;&nbsp;{Adjacent&nbsp;Nb<SPAN class="keyword">.</SPAN>horse&nbsp;Nb<SPAN class="keyword">.</SPAN>diplomat}<BR>&nbsp;&nbsp;&nbsp;Nb<SPAN class="keyword">.</SPAN>zebra&nbsp;=&nbsp;Nb<SPAN class="keyword">.</SPAN>white<BR>&nbsp;&nbsp;&nbsp;{FD<SPAN class="keyword">.</SPAN>distribute&nbsp;ff&nbsp;Nb}<BR><SPAN class="keyword">end</SPAN></CODE></DD></DL><P class="caption"><STRONG>Figure&nbsp;4.4:</STRONG> A script for the Zebra Puzzle.</P><HR></DIV><P> </P></DIV><DIV class="unnumbered"><H3><A name="label70">Script</A></H3><P><A href="node23.html#progzebra">Figure&nbsp;4.4</A> shows a script based on the outlined model and distribution strategy. The script constrains the root variable <CODE>Nb</CODE> to a record that maps every property to a house number between 1 and&nbsp;5. </P><P>The script introduces two defined constraints. The defined constraint </P><BLOCKQUOTE class="code"><CODE>{Partition&nbsp;Group}</CODE></BLOCKQUOTE><P> says that the properties in the list <CODE>Group</CODE> must hold for pairwise distinct houses. The defined constraint </P><BLOCKQUOTE class="code"><CODE>{Adjacent&nbsp;</CODE><I>X</I><CODE>&nbsp;</CODE><I>Y</I><CODE>}</CODE></BLOCKQUOTE><P> says that the properties <I>X</I> and <I>Y</I> must hold for houses that are next to each other. The statement </P><BLOCKQUOTE class="code"><CODE>{FD<SPAN class="keyword">.</SPAN>distance&nbsp;X&nbsp;Y&nbsp;<SPAN class="string">'=:'</SPAN>&nbsp;1}</CODE></BLOCKQUOTE><P> creates a propagator for <IMG alt="|X-Y|=1" src="latex112.png">.</P><P>The script defines a search tree with 33 nodes. The unique solution is the record </P><BLOCKQUOTE class="code"><CODE>number(<BR>&nbsp;&nbsp;&nbsp;blue:2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;coffee:5&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;diplomat:3&nbsp;&nbsp;doctor:4&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;dog:3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;english:4&nbsp;&nbsp;&nbsp;&nbsp;fox:5&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;green:5&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;horse:4&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;italian:2&nbsp;&nbsp;&nbsp;&nbsp;japanese:5&nbsp;&nbsp;juice:1<BR>&nbsp;&nbsp;&nbsp;milk:3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;norwegian:1&nbsp;&nbsp;painter:5&nbsp;&nbsp;&nbsp;red:4<BR>&nbsp;&nbsp;&nbsp;sculptor:2&nbsp;&nbsp;&nbsp;snails:2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;spanish:3&nbsp;&nbsp;&nbsp;tea:2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;violinist:1&nbsp;&nbsp;water:4&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;white:1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;yellow:3<BR>&nbsp;&nbsp;&nbsp;zebra:1<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)</CODE></BLOCKQUOTE><P></P></DIV></DIV><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="node22.html#section.elimination.family">&lt;&lt; Prev</A></TD><TD><A href="node20.html">- Up -</A></TD></TR></TABLE><HR><ADDRESS><A href="http://www.ps.uni-sb.de/~schulte/">Christian&nbsp;Schulte</A> and&nbsp;<A href="http://www.ps.uni-sb.de/~smolka/">Gert&nbsp;Smolka</A><BR><SPAN class="version">Version 1.4.0 (20110908185330)</SPAN></ADDRESS></BODY></HTML>