/* Four bikers puzzle in Picat. From Adrian Groza "Modelling Puzzles in First Order Logic" See https://www.researchgate.net/publication/374588335_Measuring_reasoning_capabilities_of_ChatGPT """ Puzzle 56. Four bikers There are four bikers that are riding their own bikes. Each bike has a brand and each motorcyclist is wearing a helmet. 1. Exactly one person is riding a bike by a brand with the same initial of his/her name. That's not the boy with the yellow helmet. 2. A girl is riding a Groovers. 3. Herold is on the Yamada or has a XL helmet. 4. Yoshi's helmet is one size larger than Anne's. None of them has the white one. 5. Greta's helmet is one size larger than a boy's one, but one size smaller than the other boy's one. 6. The blue helmet is Small or Large. However, it doesn't belong to the person on Aprily. 7. Herold's helmet is XL or white. 8. The person on the Honshu has Medium or Large helmet. 9. If the green Helmet is Large, then the white helmet is on a Grooves. However, the green helmet is not on the Aprily. Who is riding the Aprily bike? (adapted from Brainzilla-www.brainzilla.com) """ This model - as well as Groza's Mace4 model - yields three solutions, all indicating that it's Herold that rides Aprily: Anne = Groovers = Blue = Small Yoshi = Yamada = Green = Medium Greta = Honshu = White = Large Herold = Aprily = Yellow = XL Anne = Yamada = Blue = Small Yoshi = Honshu = Green = Medium Greta = Groovers = White = Large Herold = Aprily = Yellow = XL Anne = Yamada = Green = Small Yoshi = Honshu = Yellow = Medium Greta = Groovers = Blue = Large Herold = Aprily = White = XL 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 = 4, Names = new_list(N), Names :: 1..N, Names = [Anne,Greta,Herold,Yoshi], NamesS = ["Anne","Greta","Herold","Yoshi"], Bike = new_list(N), Bike :: 1..N, Bike = [Aprily,Groovers,Honshu,Yamada], BikeS = ["Aprily","Groovers","Honshu","Yamada"], % Helmet color Color = new_list(N), Color :: 1..N, Color = [Blue,Green,White,Yellow], ColorS = ["Blue","Green","White","Yellow"], % Helmet size Size = new_list(N), Size = 1..N, Size = [Small,Medium,Large,XL], SizeS = ["Small","Medium","Large","XL"], all_different(Names), all_different(Bike), all_different(Color), all_different(Size), element(Anne,Size,SizeAnne), element(Greta,Size,SizeGreta), element(Herold,Size,SizeHerold), element(Yoshi,Size,SizeYoshi), % 1. Exactly one person is riding a bike by a brand with the same initial of his/her name. % That's not the boy with the yellow helmet. sum([Anne #= Aprily, Greta #= Groovers, Herold #= Honshu #/\ Herold #!= Yellow, Yoshi #= Yamada #/\ Yoshi #!= Yellow]) #= 1, Yellow #= Herold #\/ Yellow #= Yoshi, % 2. A girl is riding a Groovers. Anne #= Groovers #\/ Greta #= Groovers, % 3. Herold is on the Yamada or has a XL helmet. Herold #= Yamada #\/ Herold #= XL, % 4. Yoshi's helmet is one size larger than Anne's. None of them has the white one. SizeYoshi #= SizeAnne + 1, Yoshi #!= White, Anne #!= White, % 5. Greta's helmet is one size larger than a boy's one, but one size smaller than the % other boy's one. (SizeHerold #= SizeGreta+1 #/\ SizeYoshi #= SizeGreta-1) #\/ (SizeHerold #= SizeGreta-1 #/\ SizeYoshi #= SizeGreta+1), % 6. The blue helmet is Small or Large. However, it doesn't belong to the person on % Aprily. Blue #= Small #\/ Blue #= Large, Blue #!= Aprily, % 7. Herold's helmet is XL or white. Herold #= XL #\/ Herold #= White, % 8. The person on the Honshu has Medium or Large helmet. Honshu #= Medium #\/ Honshu #= Large, % 9. If the green Helmet is Large, then the white helmet is on a Grooves. However, the % green helmet is not on the Aprily. (Green #= Large) #=> (White #= Groovers), Green #!= Aprily, % Who is riding the Aprily bike? (adapted from Brainzilla-www.brainzilla.com) element(RidesAprily,Names,Aprily), Vars = [names=Names,bike=Bike,color=Color,size=Size,ridesAprily=RidesAprily], solve(Vars), % println(Vars), println(ridesAprily=NamesS[RidesAprily]), foreach(I in 1..N) nth(Name,Names,I), nth(B,Bike,I), nth(C,Color,I), nth(S,Size,I), println(NamesS[Name]=BikeS[B]=ColorS[C]=SizeS[S]) end, nl, fail, nl.