19.01.2015 Views

Constraint Logic Programming Using ECLiPSe

Constraint Logic Programming Using ECLiPSe

Constraint Logic Programming Using ECLiPSe

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

[eclipse 2]: X is 7, X is X+1.<br />

No (0.00s cpu)<br />

[eclipse 3]: X is X+1, X is 7.<br />

instantiation fault in +(X, 1, X)<br />

Abort<br />

[eclipse 4]: X is 3, Y is X+1.<br />

Y = 4<br />

X = 3<br />

Yes (0.00s cpu)<br />

[eclipse 5]: Y is X+1, X is 3.<br />

instantiation fault in +(X, 1, Y)<br />

Abort<br />

Solutions to selected exercises 307<br />

Exercise 3.2<br />

[eclipse 1]: Z is 2, q(X).<br />

Z = 2<br />

X = X<br />

Yes (0.00s cpu)<br />

[eclipse 2]: Z is 2, q(Z).<br />

Z = 2<br />

Yes (0.00s cpu)<br />

[eclipse 3]: Z is 2, q(X), Y is Z+1.<br />

Z = 2<br />

X = X<br />

Y = 3<br />

Yes (0.00s cpu)<br />

[eclipse 4]: Z = 2, inc(X), X = 2.<br />

instantiation fault in +(X, 1, Z) in module eclipse<br />

Abort<br />

[eclipse 5]: X = 2, inc(X), Z = 2.<br />

X = 2<br />

Z = 2<br />

Yes (0.00s cpu)<br />

Exercise 3.3<br />

An example is the query min(1+1, 3, Z). For the first program it yields the<br />

answer Z = 1+1 and for the second program the answer Z = 2.<br />

Exercise 3.4<br />

Assume the declarations<br />

:- op(500, yfx, have).<br />

:- op(400, yfx, and).

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!