This file is indexed.

/usr/share/mozart/doc/fdt/answers.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
3
4
5
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Answers to the Exercises</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="node54.html#appendix.data">&lt;&lt; Prev</A></TD><TD><A href="index.html">- Up -</A></TD><TD><A href="bib.html#label192">Next &gt;&gt;</A></TD></TR></TABLE><H1><A name="label182">Answers to the Exercises</A></H1><DIV class="answer"><P><A name="label191"><B>Answer&nbsp;3.1</B></A></P><BLOCKQUOTE><P>This does not really require to be answered. Just try it.</P></BLOCKQUOTE></DIV><DIV class="answer"><P><A name="label190"><B>Answer&nbsp;3.2</B></A></P><BLOCKQUOTE><P></P><DL class="anonymous"><DD class="code"><CODE><SPAN class="keyword">proc</SPAN><SPAN class="variablename">&nbsp;</SPAN>{<SPAN class="functionname">Donald</SPAN>&nbsp;Root}<BR>&nbsp;&nbsp;&nbsp;sol(a:A&nbsp;b:B&nbsp;d:D&nbsp;e:E&nbsp;g:G&nbsp;l:L&nbsp;n:N&nbsp;&nbsp;o:O&nbsp;r:R&nbsp;t:T)&nbsp;=&nbsp;Root<BR><SPAN class="keyword">in</SPAN>&nbsp;<BR>&nbsp;&nbsp;&nbsp;Root&nbsp;<SPAN class="keyword">:::</SPAN>&nbsp;0<SPAN class="keyword">#</SPAN>9<BR>&nbsp;&nbsp;&nbsp;{FD<SPAN class="keyword">.</SPAN>distinct&nbsp;Root}<BR>&nbsp;&nbsp;&nbsp;D<SPAN class="keyword">\=:</SPAN>0&nbsp;&nbsp;R<SPAN class="keyword">\=:</SPAN>0&nbsp;&nbsp;G<SPAN class="keyword">\=:</SPAN>0<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;100000<SPAN class="keyword">*</SPAN>D&nbsp;<SPAN class="keyword">+</SPAN>&nbsp;10000<SPAN class="keyword">*</SPAN>O&nbsp;<SPAN class="keyword">+</SPAN>&nbsp;1000<SPAN class="keyword">*</SPAN>N&nbsp;<SPAN class="keyword">+</SPAN>&nbsp;100<SPAN class="keyword">*</SPAN>A&nbsp;<SPAN class="keyword">+</SPAN>&nbsp;10<SPAN class="keyword">*</SPAN>L&nbsp;<SPAN class="keyword">+</SPAN>&nbsp;D<BR>&nbsp;&nbsp;&nbsp;<SPAN class="keyword">+</SPAN>&nbsp;&nbsp;100000<SPAN class="keyword">*</SPAN>G&nbsp;<SPAN class="keyword">+</SPAN>&nbsp;10000<SPAN class="keyword">*</SPAN>E&nbsp;<SPAN class="keyword">+</SPAN>&nbsp;1000<SPAN class="keyword">*</SPAN>R&nbsp;<SPAN class="keyword">+</SPAN>&nbsp;100<SPAN class="keyword">*</SPAN>A&nbsp;<SPAN class="keyword">+</SPAN>&nbsp;10<SPAN class="keyword">*</SPAN>L&nbsp;<SPAN class="keyword">+</SPAN>&nbsp;D<BR>&nbsp;&nbsp;&nbsp;<SPAN class="keyword">=:</SPAN>&nbsp;100000<SPAN class="keyword">*</SPAN>R&nbsp;<SPAN class="keyword">+</SPAN>&nbsp;10000<SPAN class="keyword">*</SPAN>O&nbsp;<SPAN class="keyword">+</SPAN>&nbsp;1000<SPAN class="keyword">*</SPAN>B&nbsp;<SPAN class="keyword">+</SPAN>&nbsp;100<SPAN class="keyword">*</SPAN>E&nbsp;<SPAN class="keyword">+</SPAN>&nbsp;10<SPAN class="keyword">*</SPAN>R&nbsp;<SPAN class="keyword">+</SPAN>&nbsp;T<BR>&nbsp;&nbsp;&nbsp;{FD<SPAN class="keyword">.</SPAN>distribute&nbsp;split&nbsp;Root}<BR><SPAN class="keyword">end</SPAN></CODE></DD></DL><P></P></BLOCKQUOTE></DIV><DIV class="answer"><P><A name="label189"><B>Answer&nbsp;7.1</B></A></P><BLOCKQUOTE><P>The first redundant constraint follows from the fact that the total number of occurrences in the sequence is <IMG alt="n" src="latex43.png">, and that no numbers but those between 0 and <IMG alt="n-1" src="latex163.png"> occur in the sequence. </P><P>The second redundant constraint follows from the fact that </P><BLOCKQUOTE><P><IMG alt="0\cdot x_0\;+\;\ldots\;+\;
(n-1)\cdot x_{n-1}
\;=\;
x_0\;+\;\ldots\;+\;x_{n-1}" src="latex353.png"></P></BLOCKQUOTE><P> </P><P>Here is a parametrized script for the Magic Sequence Puzzle: </P><DL class="anonymous"><DD class="code"><CODE><SPAN class="keyword">fun</SPAN><SPAN class="variablename">&nbsp;</SPAN>{<SPAN class="functionname">MagicSequence</SPAN>&nbsp;N}<BR>&nbsp;&nbsp;&nbsp;Cs&nbsp;=&nbsp;{List<SPAN class="keyword">.</SPAN>number&nbsp;<SPAN class="keyword">~</SPAN>1&nbsp;N<SPAN class="keyword">-</SPAN>2&nbsp;1}<BR><SPAN class="keyword">in</SPAN>&nbsp;<BR>&nbsp;&nbsp;&nbsp;<SPAN class="keyword">proc</SPAN><SPAN class="variablename">&nbsp;</SPAN>{<SPAN class="functionname">$</SPAN>&nbsp;S}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{FD<SPAN class="keyword">.</SPAN>tuple&nbsp;sequence&nbsp;N&nbsp;0<SPAN class="keyword">#</SPAN>N<SPAN class="keyword">-</SPAN>1&nbsp;S}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{For&nbsp;0&nbsp;N<SPAN class="keyword">-</SPAN>1&nbsp;1&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN class="keyword">proc</SPAN><SPAN class="variablename">&nbsp;</SPAN>{<SPAN class="functionname">$</SPAN>&nbsp;I}&nbsp;{FD<SPAN class="keyword">.</SPAN>exactly&nbsp;S<SPAN class="keyword">.</SPAN>(I<SPAN class="keyword">+</SPAN>1)&nbsp;S&nbsp;I}&nbsp;<SPAN class="keyword">end</SPAN>}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;%%&nbsp;<SPAN class="comment">redundant&nbsp;constraints<BR></SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{FD<SPAN class="keyword">.</SPAN>sum&nbsp;S&nbsp;<SPAN class="string">'=:'</SPAN>&nbsp;N}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{FD<SPAN class="keyword">.</SPAN>sumC&nbsp;Cs&nbsp;S&nbsp;<SPAN class="string">'=:'</SPAN>&nbsp;0}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;%%<SPAN class="comment">&nbsp;<BR></SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{FD<SPAN class="keyword">.</SPAN>distribute&nbsp;ff&nbsp;S}<BR>&nbsp;&nbsp;&nbsp;<SPAN class="keyword">end</SPAN>&nbsp;<BR><SPAN class="keyword">end</SPAN></CODE></DD></DL><P></P></BLOCKQUOTE></DIV><DIV class="answer"><P><A name="label188"><B>Answer&nbsp;8.1</B></A></P><BLOCKQUOTE><P></P><BLOCKQUOTE class="code"><CODE>{FD<SPAN class="keyword">.</SPAN>impl&nbsp;X<SPAN class="keyword">&lt;:</SPAN>Y&nbsp;&nbsp;X<SPAN class="keyword">+</SPAN>Y<SPAN class="keyword">=:</SPAN>Z}&nbsp;=&nbsp;{FD<SPAN class="keyword">.</SPAN>disj&nbsp;&nbsp;X<SPAN class="keyword">*</SPAN>Y<SPAN class="keyword">=:</SPAN>Z&nbsp;&nbsp;Z<SPAN class="keyword">\=:</SPAN>5}</CODE></BLOCKQUOTE><P></P></BLOCKQUOTE></DIV><DIV class="answer"><P><A name="label187"><B>Answer&nbsp;8.2</B></A></P><BLOCKQUOTE><P></P><BLOCKQUOTE class="code"><CODE><SPAN class="keyword">proc</SPAN><SPAN class="variablename">&nbsp;</SPAN>{<SPAN class="functionname">Conj</SPAN>&nbsp;X&nbsp;Y&nbsp;Z}<BR>&nbsp;&nbsp;&nbsp;X<SPAN class="keyword">::</SPAN>0<SPAN class="keyword">#</SPAN>1&nbsp;&nbsp;Y<SPAN class="keyword">::</SPAN>0<SPAN class="keyword">#</SPAN>1<BR>&nbsp;&nbsp;&nbsp;(X<SPAN class="keyword">+</SPAN>Y<SPAN class="keyword">=:</SPAN>2)&nbsp;=&nbsp;Z<BR><SPAN class="keyword">end</SPAN>&nbsp;<BR><SPAN class="keyword">proc</SPAN><SPAN class="variablename">&nbsp;</SPAN>{<SPAN class="functionname">Equi</SPAN>&nbsp;X&nbsp;Y&nbsp;Z}<BR>&nbsp;&nbsp;&nbsp;X<SPAN class="keyword">::</SPAN>0<SPAN class="keyword">#</SPAN>1&nbsp;&nbsp;Y<SPAN class="keyword">::</SPAN>0<SPAN class="keyword">#</SPAN>1<BR>&nbsp;&nbsp;&nbsp;(X<SPAN class="keyword">=:</SPAN>Y)&nbsp;=&nbsp;Z&nbsp;&nbsp;<BR><SPAN class="keyword">end</SPAN>&nbsp;<BR><SPAN class="keyword">proc</SPAN><SPAN class="variablename">&nbsp;</SPAN>{<SPAN class="functionname">Nega</SPAN>&nbsp;X&nbsp;Z}<BR>&nbsp;&nbsp;&nbsp;X<SPAN class="keyword">::</SPAN>0<SPAN class="keyword">#</SPAN>1<BR>&nbsp;&nbsp;&nbsp;(X<SPAN class="keyword">=:</SPAN>0)&nbsp;=&nbsp;Z&nbsp;&nbsp;&nbsp;<BR><SPAN class="keyword">end</SPAN>&nbsp;<BR><SPAN class="keyword">proc</SPAN><SPAN class="variablename">&nbsp;</SPAN>{<SPAN class="functionname">Disj</SPAN>&nbsp;X&nbsp;Y&nbsp;Z}<BR>&nbsp;&nbsp;&nbsp;X<SPAN class="keyword">::</SPAN>0<SPAN class="keyword">#</SPAN>1&nbsp;&nbsp;Y<SPAN class="keyword">::</SPAN>0<SPAN class="keyword">#</SPAN>1<BR>&nbsp;&nbsp;&nbsp;(X<SPAN class="keyword">+</SPAN>Y<SPAN class="keyword">&gt;:</SPAN>0)&nbsp;=&nbsp;Z<BR><SPAN class="keyword">end</SPAN>&nbsp;<BR><SPAN class="keyword">proc</SPAN><SPAN class="variablename">&nbsp;</SPAN>{<SPAN class="functionname">Impl</SPAN>&nbsp;X&nbsp;Y&nbsp;Z}<BR>&nbsp;&nbsp;&nbsp;X<SPAN class="keyword">::</SPAN>0<SPAN class="keyword">#</SPAN>1&nbsp;&nbsp;Y<SPAN class="keyword">::</SPAN>0<SPAN class="keyword">#</SPAN>1<BR>&nbsp;&nbsp;&nbsp;(Y<SPAN class="keyword">-</SPAN>X<SPAN class="keyword">&gt;=:</SPAN>0)&nbsp;=&nbsp;Z<BR><SPAN class="keyword">end</SPAN></CODE></BLOCKQUOTE><P></P></BLOCKQUOTE></DIV><DIV class="answer"><P><A name="label186"><B>Answer&nbsp;8.3</B></A></P><BLOCKQUOTE><P>To minimize the value of <CODE>Satisfaction</CODE>, we modify the distributor for <CODE>Satisfaction</CODE> such that it tries smaller values first: </P><BLOCKQUOTE class="code"><CODE>{FD<SPAN class="keyword">.</SPAN>distribute&nbsp;generic(order:naive&nbsp;value:min)&nbsp;[Satisfaction]}</CODE></BLOCKQUOTE><P> It turns out that the persons can be aligned such that no preference is satisfied.</P></BLOCKQUOTE></DIV><DIV class="answer"><P><A name="label185"><B>Answer&nbsp;8.4</B></A></P><BLOCKQUOTE><P></P><BLOCKQUOTE class="code"><CODE><SPAN class="keyword">local</SPAN>&nbsp;Aux&nbsp;<SPAN class="keyword">in</SPAN>&nbsp;<BR>&nbsp;&nbsp;&nbsp;{FD<SPAN class="keyword">.</SPAN>decl&nbsp;Aux}<BR>&nbsp;&nbsp;&nbsp;{FD<SPAN class="keyword">.</SPAN>distance&nbsp;Q<SPAN class="keyword">.</SPAN>7&nbsp;Q<SPAN class="keyword">.</SPAN>8&nbsp;<SPAN class="string">'=:'</SPAN>&nbsp;Aux}<BR>&nbsp;&nbsp;&nbsp;{FD<SPAN class="keyword">.</SPAN>element&nbsp;Q<SPAN class="keyword">.</SPAN>7&nbsp;[4&nbsp;3&nbsp;2&nbsp;1&nbsp;0]&nbsp;Aux}<BR><SPAN class="keyword">end</SPAN></CODE></BLOCKQUOTE><P></P></BLOCKQUOTE></DIV><DIV class="answer"><P><A name="label184"><B>Answer&nbsp;8.5</B></A></P><BLOCKQUOTE><P></P><BLOCKQUOTE class="code"><CODE><SPAN class="keyword">thread</SPAN>&nbsp;<BR>&nbsp;&nbsp;&nbsp;<SPAN class="keyword">if</SPAN>&nbsp;A<SPAN class="keyword">.</SPAN>type<SPAN class="keyword">==</SPAN>B<SPAN class="keyword">.</SPAN>type&nbsp;<SPAN class="keyword">then</SPAN>&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;A<SPAN class="keyword">.</SPAN>glass&nbsp;<SPAN class="keyword">&gt;=:</SPAN>&nbsp;B<SPAN class="keyword">.</SPAN>glass<BR>&nbsp;&nbsp;&nbsp;<SPAN class="keyword">end</SPAN>&nbsp;<BR><SPAN class="keyword">end</SPAN></CODE></BLOCKQUOTE><P></P></BLOCKQUOTE></DIV><DIV class="answer"><P><A name="label183"><B>Answer&nbsp;11.1</B></A></P><BLOCKQUOTE><P>A possible solution is as follows. </P><BLOCKQUOTE class="code"><CODE><SPAN class="keyword">proc</SPAN><SPAN class="variablename">&nbsp;</SPAN>{<SPAN class="functionname">CapacityConstraints</SPAN>&nbsp;TasksOnRes&nbsp;Start&nbsp;Dur}<BR>&nbsp;&nbsp;&nbsp;{Record<SPAN class="keyword">.</SPAN>forAll&nbsp;TasksOnRes<BR>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN class="keyword">proc</SPAN><SPAN class="variablename">&nbsp;</SPAN>{<SPAN class="functionname">$</SPAN>&nbsp;Ts}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ForAllTail&nbsp;Ts<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN class="keyword">proc</SPAN><SPAN class="variablename">&nbsp;</SPAN>{<SPAN class="functionname">$</SPAN>&nbsp;T1<SPAN class="keyword">|</SPAN>Tr}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ForAll&nbsp;Tr<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN class="keyword">proc</SPAN><SPAN class="variablename">&nbsp;</SPAN>{<SPAN class="functionname">$</SPAN>&nbsp;T2}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(Start<SPAN class="keyword">.</SPAN>T1&nbsp;<SPAN class="keyword">+</SPAN>&nbsp;Dur<SPAN class="keyword">.</SPAN>T1&nbsp;<SPAN class="keyword">=&lt;:</SPAN>&nbsp;Start<SPAN class="keyword">.</SPAN>T2)&nbsp;<SPAN class="keyword">+</SPAN>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(Start<SPAN class="keyword">.</SPAN>T2&nbsp;<SPAN class="keyword">+</SPAN>&nbsp;Dur<SPAN class="keyword">.</SPAN>T2&nbsp;<SPAN class="keyword">=&lt;:</SPAN>&nbsp;Start<SPAN class="keyword">.</SPAN>T1)&nbsp;<SPAN class="keyword">=:</SPAN>&nbsp;1<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN class="keyword">end</SPAN>}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN class="keyword">end</SPAN>}<BR>&nbsp;&nbsp;&nbsp;&nbsp;<SPAN class="keyword">end</SPAN>}<BR><SPAN class="keyword">end</SPAN></CODE></BLOCKQUOTE><P></P></BLOCKQUOTE></DIV><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="node54.html#appendix.data">&lt;&lt; Prev</A></TD><TD><A href="index.html">- Up -</A></TD><TD><A href="bib.html#label192">Next &gt;&gt;</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>