Prima di svolgere il prossimo esercizio consiglio di installare il plugin PDT su Eclipse per avere una postazione di lavoro più comoda e potente :

Eclipse : versione successiva alla 4
SWI-Prolog : versione successiva alla 6
PDT

Attenzione a non installare la versione nel repository di ubuntu che è più vecchia

$ apt-cache showpkg swi-prolog
Package: swi-prolog
Versions:
6.4.1-1-g09194b7-raringppa2 ... <- da installare
5.10.4-5ubuntu1 (/var/lib/apt/lists/i

$ sudo apt-get install swi-prolog=6.4.1-1-g09194b7-raringppa2

Exercise 2.4 Here are six Italian words:
astante , astoria , baratto , cobalto , pistola , statale .
They are to be arranged, crossword puzzle fashion, in the following grid:
The following knowledge base represents a lexicon containing these words:

word(astante, a,s,t,a,n,t,e).
word(astoria, a,s,t,o,r,i,a).
word(baratto, b,a,r,a,t,t,o).
word(cobalto, c,o,b,a,l,t,o).
word(pistola, p,i,s,t,o,l,a).
word(statale, s,t,a,t,a,l,e).
Write a predicate crossword/6 that tells us how to fill in the grid. The first three arguments should be the vertical words from left to right, and the last three arguments the horizontal words from top to bottom.

% 3 verticali V1,V2,V3 e 3 orizzonatali H1,H2,H3
word(astante, a,s,t,a,n,t,e).
word(astoria, a,s,t,o,r,i,a).
word(baratto, b,a,r,a,t,t,o).
word(cobalto, c,o,b,a,l,t,o).
word(pistola, p,i,s,t,o,l,a).
word(statale, s,t,a,t,a,l,e).

crossword(V1,V2,V3, H1,H2,H3) :- 
		word(V1, _,V1H1,_,V1H2,_,V1H3,_),
		word(V2, _,V2H1,_,V2H2,_,V2H3,_),
		word(V3, _,V3H1,_,V3H2,_,V3H3,_),
		word(H1, _,V1H1,_,V2H1,_,V3H1,_),
		word(H2, _,V1H2,_,V2H2,_,V3H2,_),
		word(H3, _,V1H3,_,V2H3,_,V3H3,_),
             % non incrociare le parole con sé stesse
		H1\=V1, H2\=V2, H3\=V3.	

% chi più ne ha più ne metta :)
/*
word(scatole, s,c,a,t,o,l,e).
word(estonia, e,s,t,o,n,i,a).
word(baretto, b,a,r,e,t,t,o).
word(cavallo, c,a,v,a,l,l,o).
word(ceretta, c,e,r,e,t,t,a).
word(cintola, c,i,n,t,o,l,a).
word(pittalo, p,i,t,t,a,l,o).
word(lisbona, l,i,s,b,o,n,a).
word(funesto, f,u,n,e,s,t,o).
word(colante, c,o,l,a,n,t,e).
*/

/*
one solution :
     a   c   p
   a s t o r i a  
     t   b   s 
   b a r a t t o  
     n   l   o   
   s t a t a l e  	
     e   o   a
*/