/* The ladies of the committee in Picat. From Adrian Groza "Modelling Puzzles in First Order Logic" See https://www.researchgate.net/publication/374588335_Measuring_reasoning_capabilities_of_ChatGPT """ Puzzle 51. The ladies of the committee Six ladies are eligible for the offices of Captain, Vice-captain, and Treasurer (in descending order of seniority), in the local ladies' golf club (puzzle 33 in Clessa (1996)). 1. Audrey won't serve if Elaine is Captain, or if Freda is Treasurer. 2. Betty won't be Treasurer if Cynthia is one of the officials. 3. Audrey won't serve with both Betty and Elaine. 4. Freda won't serve if Elaine is also an official. 5. Betty refuses to be Vice-captain. 6. Freda won't serve if she outranks Audrey. 7. Cynthia won't serve with Audrey or Betty unless she is Captain. 8. Doris won't serve unless Betty is Captain. 9. Betty won't serve with Doris unless Elaine is also an official. 10. Elaine won't serve unless she or Audrey is Captain. How can the three offices be filled? """ Solution: captain = Audrey vice_captain = Freda treasurer = Betty not_serve = [Cynthia,Doris,Elaine] This program was created by Hakan Kjellerstrand, hakank@gmail.com See also my Picat page: http://www.hakank.org/picat/ */ import cp. main => go. go => N = 6, [Audrey,Betty,Cynthia,Doris,Elaine,Freda] = [1,2,3,4,5,6], Names = ["Audrey","Betty","Cynthia","Doris","Elaine","Freda"], NotServe = 0, Treasurer = 1, ViceCaptain = 2, Captain = 3, Str = ["Not serve","Captain","Vice Captain","Treasurer"], X = new_list(N), X :: NotServe..Captain, % 1. Audrey won't serve if Elaine is Captain, or if Freda is Treasurer. (X[Elaine] #= Captain #\/ X[Freda] #= Treasurer) #=> X[Audrey] #= NotServe, % 2. Betty won't be Treasurer if Cynthia is one of the officials. (X[Cynthia] #!= NotServe) #=> X[Betty] #!= Treasurer, % 3. Audrey won't serve with both Betty and Elaine. (X[Betty] #!= NotServe #/\ X[Elaine] #!= NotServe) #=> X[Audrey] #= NotServe, % 4. Freda won't serve if Elaine is also an official. (X[Elaine] #!= NotServe) #=> X[Freda] #= NotServe, % 5. Betty refuses to be Vice-captain. X[Betty] #!= ViceCaptain, % 6. Freda won't serve if she outranks Audrey. (X[Audrey] #= ViceCaptain) #=> (X[Freda] #!= Captain), (X[Audrey] #= Treasurer) #=> (X[Freda] #!= ViceCaptain #/\ X[Freda] #!= Captain), % 7. Cynthia won't serve with Audrey or Betty unless she is Captain. ((X[Audrey] #!= NotServe #\/ X[Betty] #!= NotServe) #/\ X[Cynthia] #!= Captain) #=> X[Cynthia] #= NotServe, % 8. Doris won't serve unless Betty is Captain. (X[Betty] #!= Captain) #=> (X[Doris] #= NotServe), % 9. Betty won't serve with Doris unless Elaine is also an official. (X[Elaine] #= NotServe) #=> #~( X[Betty] #!= NotServe #/\ X[Doris] #!= NotServe), % 10. Elaine won't serve unless she or Audrey is Captain. #~( X[Elaine] #= Captain #\/ X[Audrey] #= Captain) #=> X[Elaine] #=> NotServe, count(Captain,X) #= 1, count(ViceCaptain,X) #= 1, count(Treasurer,X) #= 1, % How can the three offices be filled? solve(X), % println(X), % foreach(I in 1..N) % println(Names[I]=Str[X[I]+1]) % end, % nl, println(captain=[Names[I] : I in 1..N, X[I] == Captain].head), println(vice_captain=[Names[I] : I in 1..N, X[I] == ViceCaptain].head), println(treasurer=[Names[I] : I in 1..N, X[I] == Treasurer].head), println(not_serve=[Names[I] : I in 1..N, X[I] == NotServe]), nl, fail, nl.