/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"><< Prev</A></TD><TD><A href="index.html">- Up -</A></TD><TD><A href="bib.html#label192">Next >></A></TD></TR></TABLE><H1><A name="label182">Answers to the Exercises</A></H1><DIV class="answer"><P><A name="label191"><B>Answer 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 3.2</B></A></P><BLOCKQUOTE><P></P><DL class="anonymous"><DD class="code"><CODE><SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">Donald</SPAN> Root}<BR> sol(a:A b:B d:D e:E g:G l:L n:N o:O r:R t:T) = Root<BR><SPAN class="keyword">in</SPAN> <BR> Root <SPAN class="keyword">:::</SPAN> 0<SPAN class="keyword">#</SPAN>9<BR> {FD<SPAN class="keyword">.</SPAN>distinct Root}<BR> D<SPAN class="keyword">\=:</SPAN>0 R<SPAN class="keyword">\=:</SPAN>0 G<SPAN class="keyword">\=:</SPAN>0<BR> 100000<SPAN class="keyword">*</SPAN>D <SPAN class="keyword">+</SPAN> 10000<SPAN class="keyword">*</SPAN>O <SPAN class="keyword">+</SPAN> 1000<SPAN class="keyword">*</SPAN>N <SPAN class="keyword">+</SPAN> 100<SPAN class="keyword">*</SPAN>A <SPAN class="keyword">+</SPAN> 10<SPAN class="keyword">*</SPAN>L <SPAN class="keyword">+</SPAN> D<BR> <SPAN class="keyword">+</SPAN> 100000<SPAN class="keyword">*</SPAN>G <SPAN class="keyword">+</SPAN> 10000<SPAN class="keyword">*</SPAN>E <SPAN class="keyword">+</SPAN> 1000<SPAN class="keyword">*</SPAN>R <SPAN class="keyword">+</SPAN> 100<SPAN class="keyword">*</SPAN>A <SPAN class="keyword">+</SPAN> 10<SPAN class="keyword">*</SPAN>L <SPAN class="keyword">+</SPAN> D<BR> <SPAN class="keyword">=:</SPAN> 100000<SPAN class="keyword">*</SPAN>R <SPAN class="keyword">+</SPAN> 10000<SPAN class="keyword">*</SPAN>O <SPAN class="keyword">+</SPAN> 1000<SPAN class="keyword">*</SPAN>B <SPAN class="keyword">+</SPAN> 100<SPAN class="keyword">*</SPAN>E <SPAN class="keyword">+</SPAN> 10<SPAN class="keyword">*</SPAN>R <SPAN class="keyword">+</SPAN> T<BR> {FD<SPAN class="keyword">.</SPAN>distribute split Root}<BR><SPAN class="keyword">end</SPAN></CODE></DD></DL><P></P></BLOCKQUOTE></DIV><DIV class="answer"><P><A name="label189"><B>Answer 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"> </SPAN>{<SPAN class="functionname">MagicSequence</SPAN> N}<BR> Cs = {List<SPAN class="keyword">.</SPAN>number <SPAN class="keyword">~</SPAN>1 N<SPAN class="keyword">-</SPAN>2 1}<BR><SPAN class="keyword">in</SPAN> <BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> S}<BR> {FD<SPAN class="keyword">.</SPAN>tuple sequence N 0<SPAN class="keyword">#</SPAN>N<SPAN class="keyword">-</SPAN>1 S}<BR> {For 0 N<SPAN class="keyword">-</SPAN>1 1 <BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> I} {FD<SPAN class="keyword">.</SPAN>exactly S<SPAN class="keyword">.</SPAN>(I<SPAN class="keyword">+</SPAN>1) S I} <SPAN class="keyword">end</SPAN>}<BR> %% <SPAN class="comment">redundant constraints<BR></SPAN> {FD<SPAN class="keyword">.</SPAN>sum S <SPAN class="string">'=:'</SPAN> N}<BR> {FD<SPAN class="keyword">.</SPAN>sumC Cs S <SPAN class="string">'=:'</SPAN> 0}<BR> %%<SPAN class="comment"> <BR></SPAN> {FD<SPAN class="keyword">.</SPAN>distribute ff S}<BR> <SPAN class="keyword">end</SPAN> <BR><SPAN class="keyword">end</SPAN></CODE></DD></DL><P></P></BLOCKQUOTE></DIV><DIV class="answer"><P><A name="label188"><B>Answer 8.1</B></A></P><BLOCKQUOTE><P></P><BLOCKQUOTE class="code"><CODE>{FD<SPAN class="keyword">.</SPAN>impl X<SPAN class="keyword"><:</SPAN>Y X<SPAN class="keyword">+</SPAN>Y<SPAN class="keyword">=:</SPAN>Z} = {FD<SPAN class="keyword">.</SPAN>disj X<SPAN class="keyword">*</SPAN>Y<SPAN class="keyword">=:</SPAN>Z Z<SPAN class="keyword">\=:</SPAN>5}</CODE></BLOCKQUOTE><P></P></BLOCKQUOTE></DIV><DIV class="answer"><P><A name="label187"><B>Answer 8.2</B></A></P><BLOCKQUOTE><P></P><BLOCKQUOTE class="code"><CODE><SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">Conj</SPAN> X Y Z}<BR> X<SPAN class="keyword">::</SPAN>0<SPAN class="keyword">#</SPAN>1 Y<SPAN class="keyword">::</SPAN>0<SPAN class="keyword">#</SPAN>1<BR> (X<SPAN class="keyword">+</SPAN>Y<SPAN class="keyword">=:</SPAN>2) = Z<BR><SPAN class="keyword">end</SPAN> <BR><SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">Equi</SPAN> X Y Z}<BR> X<SPAN class="keyword">::</SPAN>0<SPAN class="keyword">#</SPAN>1 Y<SPAN class="keyword">::</SPAN>0<SPAN class="keyword">#</SPAN>1<BR> (X<SPAN class="keyword">=:</SPAN>Y) = Z <BR><SPAN class="keyword">end</SPAN> <BR><SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">Nega</SPAN> X Z}<BR> X<SPAN class="keyword">::</SPAN>0<SPAN class="keyword">#</SPAN>1<BR> (X<SPAN class="keyword">=:</SPAN>0) = Z <BR><SPAN class="keyword">end</SPAN> <BR><SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">Disj</SPAN> X Y Z}<BR> X<SPAN class="keyword">::</SPAN>0<SPAN class="keyword">#</SPAN>1 Y<SPAN class="keyword">::</SPAN>0<SPAN class="keyword">#</SPAN>1<BR> (X<SPAN class="keyword">+</SPAN>Y<SPAN class="keyword">>:</SPAN>0) = Z<BR><SPAN class="keyword">end</SPAN> <BR><SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">Impl</SPAN> X Y Z}<BR> X<SPAN class="keyword">::</SPAN>0<SPAN class="keyword">#</SPAN>1 Y<SPAN class="keyword">::</SPAN>0<SPAN class="keyword">#</SPAN>1<BR> (Y<SPAN class="keyword">-</SPAN>X<SPAN class="keyword">>=:</SPAN>0) = Z<BR><SPAN class="keyword">end</SPAN></CODE></BLOCKQUOTE><P></P></BLOCKQUOTE></DIV><DIV class="answer"><P><A name="label186"><B>Answer 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 generic(order:naive value:min) [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 8.4</B></A></P><BLOCKQUOTE><P></P><BLOCKQUOTE class="code"><CODE><SPAN class="keyword">local</SPAN> Aux <SPAN class="keyword">in</SPAN> <BR> {FD<SPAN class="keyword">.</SPAN>decl Aux}<BR> {FD<SPAN class="keyword">.</SPAN>distance Q<SPAN class="keyword">.</SPAN>7 Q<SPAN class="keyword">.</SPAN>8 <SPAN class="string">'=:'</SPAN> Aux}<BR> {FD<SPAN class="keyword">.</SPAN>element Q<SPAN class="keyword">.</SPAN>7 [4 3 2 1 0] Aux}<BR><SPAN class="keyword">end</SPAN></CODE></BLOCKQUOTE><P></P></BLOCKQUOTE></DIV><DIV class="answer"><P><A name="label184"><B>Answer 8.5</B></A></P><BLOCKQUOTE><P></P><BLOCKQUOTE class="code"><CODE><SPAN class="keyword">thread</SPAN> <BR> <SPAN class="keyword">if</SPAN> A<SPAN class="keyword">.</SPAN>type<SPAN class="keyword">==</SPAN>B<SPAN class="keyword">.</SPAN>type <SPAN class="keyword">then</SPAN> <BR> A<SPAN class="keyword">.</SPAN>glass <SPAN class="keyword">>=:</SPAN> B<SPAN class="keyword">.</SPAN>glass<BR> <SPAN class="keyword">end</SPAN> <BR><SPAN class="keyword">end</SPAN></CODE></BLOCKQUOTE><P></P></BLOCKQUOTE></DIV><DIV class="answer"><P><A name="label183"><B>Answer 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"> </SPAN>{<SPAN class="functionname">CapacityConstraints</SPAN> TasksOnRes Start Dur}<BR> {Record<SPAN class="keyword">.</SPAN>forAll TasksOnRes<BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> Ts}<BR> {ForAllTail Ts<BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> T1<SPAN class="keyword">|</SPAN>Tr}<BR> {ForAll Tr<BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> T2}<BR> (Start<SPAN class="keyword">.</SPAN>T1 <SPAN class="keyword">+</SPAN> Dur<SPAN class="keyword">.</SPAN>T1 <SPAN class="keyword">=<:</SPAN> Start<SPAN class="keyword">.</SPAN>T2) <SPAN class="keyword">+</SPAN> <BR> (Start<SPAN class="keyword">.</SPAN>T2 <SPAN class="keyword">+</SPAN> Dur<SPAN class="keyword">.</SPAN>T2 <SPAN class="keyword">=<:</SPAN> Start<SPAN class="keyword">.</SPAN>T1) <SPAN class="keyword">=:</SPAN> 1<BR> <SPAN class="keyword">end</SPAN>}<BR> <SPAN class="keyword">end</SPAN>}<BR> <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"><< Prev</A></TD><TD><A href="index.html">- Up -</A></TD><TD><A href="bib.html#label192">Next >></A></TD></TR></TABLE><HR><ADDRESS><A href="http://www.ps.uni-sb.de/~schulte/">Christian Schulte</A> and <A href="http://www.ps.uni-sb.de/~smolka/">Gert Smolka</A><BR><SPAN class="version">Version 1.4.0 (20110908185330)</SPAN></ADDRESS></BODY></HTML>
|