;; TITLE: LOGIC PROGRAMMING EXAMPLE ;; AUTHOR: Brian Harvey, PhD, UC Berkeley ;; URL: http://www.eecs.berkeley.edu/~bh/logic.html (Backtracking section) ;; ;; PROBLEM ;; ;; Five schoolgirls sat for an examination. Their parents -- so they thought -- ;; showed an undue degree of interest in the result. They therefore agreed ;; that, in writing home about the examination, each girl should make one true ;; statement and one untrue one. The following are the relevant passages from ;; their letters: ;; ;; * Betty: Kitty was second in the examination. I was only third. ;; * Ethel: You'll be glad to hear that I was on top. Joan was second. ;; * Joan: I was third, and poor old Ethel was bottom. ;; * Kitty: I came out second. Mary was only fourth. ;; * Mary: I was fourth. Top place was taken by Betty. track [[Betty Ethel Joan Kitty Mary] [1 2 3 4 5]] [[not equalp (is "Kitty 2) (is "Betty 3)] [not equalp (is "Ethel 1) (is "Joan 2)] [not equalp (is "Joan 3) (is "Ethel 5)] [not equalp (is "Kitty 2) (is "Mary 4)] [not equalp (is "Mary 4) (is "Betty 1)]] ;; OUTPUT ;; Welcome to Berkeley Logo version 6.0(exported) ;; ? exam ;; Betty 3 ;; Ethel 5 ;; Joan 2 ;; Kitty 1 ;; Mary 4 ;; ?