6.13 Get full details of all projects.

     ans(X,Y,Z) :- j(X,Y,Z).

6.14 Get full details of all projects in London.
  
     ans(X,Y) :- j(X,Y,london).

6.15 Get supplier numbers for suppliers who supply project J1.

     ans(X) :- spj(X,_,j1,_).

6.16 Get all shipments where the quantity is in the range 300 to 750
     inclusive.

     ans(X,Y,Z,W) :- spj(X,Y,Z,W), W >= 300, W <= 750.

6.17 Get all part-color/part-city combinations.

     ans(X,Y) :- p(_,_,X,_,_), p(_,_,_,_,Y).

6.18 Get all supplier-number/part-number/project-number triples such that
     the indicated supplier, part, and project are all colocated.

     ans(X,Y,Z) :- s(X,_,_,C), p(Y,_,_,_,C), j(Z,_,C).

6.19 Get all supplier-number/part-number/project-number triples such that
     the indicated supplier, part, and project are not all colocated.

     temp1(X,Y,Z) :- s(X,_,_,C), p(Y,_,_,_,C), j(Z,_,C).
     temp2(X,Y,Z) :- s(X,_,_,_), p(Y,_,_,_,_), j(Z,_,_).
     ans(X,Y,Z)   :- temp2(X,Y,Z), not temp1(X,Y,Z).

6.20 Get all supplier-number/part-number/project-number triples such that
     no two of the indicated supplier, part, and project are colocated.

     ans(X,Y,Z) :- s(X,_,_,C1), p(Y,_,_,_,C2), j(Z,_,C3),
                   C1 \== C2, C1 \== C3, C2 \== C3.


				Remaining Conjuctive queries -

6.21  -  Get part numbers for parts supplied by a supplier in London.

            ans(X) :- S(Y,_,_,London), SPJ(Y,X,_,_). 

6.22  -  Get part numbers for parts supplied by a supplier in London 
	 to a project in London.

	    ans(X) :- S(Y,_,_,London), J(Z,_,London), SPJ(Y,X,Z,_).

6.23  -  Get all pairs of city names such that a supplier in the first 
	 city supplies a project in the second city.

	    ans(X,Y) :- S(A,_,_,X), SPJ(A,_B,_), J(B,_,Y).

6.24  -  Get part numbers for parts supplied to any project by a supplier 
	 in the same city as that project.

	    ans(X) :- S(A,_,_,C), J(B,_,C), SPJ(A,X,B,_).

6.26  -  Get all pairs of part numbers such that some supplier supplies 
	 both the indicated parts.

	    ans(X,Y) :- SPJ(A,X,_,_), SPJ(A,Y,_,_).

6.31  -  Get project names for projects supplied by supplier S1.

	    ans(X) :- SPJ(S1,Y,_,_), P(Y,X,_,_,_).

6.32  -  Get colors of parts supplied by supplier S1.

	    ans(X) :- SPJ(S1,Y,_,_), P(Y,_,X,_,_).

6.33  -  Get part numbers for parts supplied to any project in London.

	    ans(X) :- J(Y,_,London), SPJ(_,X,Y,_).

6.34  -  Get project numbers for projects using at least one part 
	 available from supplier S1.

	    ans(X) :- SPJ(_,P,X,1), SPJ(S1,P,_,_).

6.35  -  Get supplier numbers for suppliers supplying atleast one part 
	 supplied by atleat one supplier who supplies at least one red part.

	    ans(X) :- P(A,_,RED,_,_), SPJ(B,A,_,_), 
			SPJ(B,C,_,1), SPJ(X,C,_,_).

			
				
			Remaining Negation Queries -

6.25  -  Get project numbers for projects supplied by at least one 
	 supplier not in the same city.

	   ans(X) :- S(Y,_,_,C1), J(X,_,C2), SPJ(Y,_,X,_), C1 \== C2.

6.43  -  Get supplier numbers for suppliers who supply the same 
	 part to all projects.

	   sup_par(X,Y) :- S(X,_,_,_), P(Y,_,_,_,_).
	   not_ans(X) :- sup_par(X,Y), J(Z,_,_), not SPJ(X,Y,Z,_)
	   ans(X) :- S(X,_,_,_), not not_ans(X).

			OR

	   sup_par(X,Y) :- S(X,_,_,_), P(Y,_,_,_,_).
	   temp(X,Y) :- sup_par(X,Y), J(Z,_,_), not SPJ(X,Y,Z,_).
	   ans(X) :- sup_par(X,Y), not temp(X,Y).

6.44  -  Get project numbers for projects supplied with at least all 
	 parts available from supplier S1.

	   S1_parts(X) :- SPJ(S1,X,_,_).
	   not_ans(X) :- S1_parts(Y), J(X,_,_), not SPJ(X,Y,Z,_).
	   ans(X) :- S(X,_,_,_), not not_ans(X).

6.47  -  Get supplier-number/part-number pairs such that the indicated 
	 supplier does not supply the indicated part.

	   all_sup_par(X,Y) :- S(X,_,_,_), P(Y,_,_,_,_).
	   sup_par(X,Y) :- SPJ(X,Y,_,_).
	   ans(X,Y) :- all_sup_par(X,Y), not sup_par(X,Y).

6.48 -   Get all pairs of supplier numbers, Sx and Sy say, such that Sx
	 and Sy supply exactly the same set of parts each.

	   sup_par(X,Y) :- SPJ(X,Y,_,_).
	   all_pairs(X,Y) :- S(X,_,_,_), S(Y,_,_,_).
	   not_ans(X,Y) :- all_pairs(X,Y), sup_par(X,Z), not sup_par(Y,Z).
	   not_ans(X,Y) :- all_pairs(X,Y), sup_par(Y,Z), not sup_par(X,Z).
 	   ans(X,Y) :- all_pairs(X,Y), not not_ans(X,Y).