2007-06-12 10:39:47 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								================================================================
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								Logtalk - Open source object-oriented logic programming language
							 
						 
					
						
							
								
									
										
										
										
											2007-11-06 01:50:09 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								Release 2.30.7
							 
						 
					
						
							
								
									
										
										
										
											2004-06-06 22:46:45 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-01-10 12:46:10 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								Copyright (c) 1998-2007 Paulo Moura.  All Rights Reserved.
							 
						 
					
						
							
								
									
										
										
										
											2007-06-12 10:39:47 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								================================================================
							 
						 
					
						
							
								
									
										
										
										
											2004-06-06 22:46:45 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-03-28 22:44:31 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								% start by loading the example and the required library files:
							 
						 
					
						
							
								
									
										
										
										
											2004-06-13 18:04:28 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2004-11-29 20:36:31 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								| ?- logtalk_load(puzzles(loader)).
							 
						 
					
						
							
								
									
										
										
										
											2004-06-13 18:04:28 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								...
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2004-06-06 22:46:45 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								% Harry Potter's room of potions logical puzzle:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								| ?- potions::potions(P1, P2, P3, P4, P5, P6, P7).
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								P1 = poison
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								P2 = wine
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								P3 = forward
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								P4 = poison
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								P5 = poison
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								P6 = wine
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								P7 = backwards
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								yes
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								% Horse show logical puzzle:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								| ?- horses::(horses(S), print(S)).
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								1 place: april riding doc, the chestnut gelding
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								2 place: sue riding danny, the bay gelding
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								3 place: doc riding gopher, the gray gelding
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								4 place: danny riding april, the white mare
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								5 place: gopher riding sue, the black mare
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								S = [h(doc,gelding,chestnut,april,1),h(danny,gelding,bay,sue,2),h(gopher,gelding,gray,doc,3),h(april,mare,white,danny,4),h(sue,mare,black,gopher,5)] ? 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								yes
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								% Who Stole the Jam?
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								| ?- jam_thief::thief(Thief).
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								Thief = hare
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								yes
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								| ?- jam_thief::thief(Thief, Why).
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								Thief = hare
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								Why = [trusty(dormouse),liar(hare),trusty(hatter)] ? 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								yes
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								% Houses logical puzzle:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								| ?- houses::(houses(S), print(S)).
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								h(norwegian,fox,kool,water,yellow)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								h(ukrainian,horse,chesterfield,tea,blue)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								h(english,snake,winston,milk,red)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								h(japonese,zebra,kent,coffee,green)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								h(spanish,dog,lucky,juice,white)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								S = [h(norwegian,fox,kool,water,yellow),h(ukrainian,horse,chesterfield,tea,blue),h(english,snake,winston,milk,red),h(japonese,zebra,kent,coffee,green),h(spanish,dog,lucky,juice,white)] ? ;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								yes
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								% Passing a note logical puzzle
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								| ?- note::(students(S), print(S)).
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								s(mary,english,red,1)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								s(paul,math,yellow,2)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								s(josephine,science,green,3)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								s(derrick,french,blue,4)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								s(alexis,reading,black,5)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								S = [s(mary,english,red,1),s(paul,math,yellow,2),s(josephine,science,green,3),s(derrick,french,blue,4),s(alexis,reading,black,5)] ? 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								yes
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2004-10-17 22:37:16 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								% Mort's Letter from Camp Swampy logical puzzle
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2004-06-06 22:46:45 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								| ?- camp_swampy::(beds(S), print(S)).
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								tim thomas, from maine, sleeps on bed number 1
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								sam franklin, from north_carolina, sleeps on bed number 2
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								mac miller, from virginia, sleeps on bed number 3
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								fred james, from florida, sleeps on bed number 4
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								john smith, from arkansas, sleeps on bed number 5
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								S = [b(tim,thomas,maine,1),b(sam,franklin,north_carolina,2),b(mac,miller,virginia,3),b(fred,james,florida,4),b(john,smith,arkansas,5)] ? 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								yes