```; Here we are dealing with simple facts that ; define girls' placement. (deftemplate placement (slot name) (slot place)) ; Assert all possible girls' placements. ; The second rule will select the suitable placement. (defrule AllThePossibleFacts => (foreach ?name (create\$ Nancy Minnie Lucy Opey) (foreach ?place (create\$ 1 2 3 4) (assert (placement (name ?name) (place ?place)))))) ; With no facts in the working memory, the rule will never fire. (defrule ProblemFromIngenuityInMathematics ; See that all four competitors have been defined ; and that all their placements are different. (placement (name Nancy) (place ?n)) (placement (name Minnie) (place ?m&~?n)) (placement (name Lucy) (place ?l&~?n&~?m)) (placement (name Opey) (place ?o&~?n&~?m&~?l)) ; This is what follows from what Lucy said (or (and (placement (name Nancy) (place ?n&1)) (not (placement (name Minnie) (place ?m&2)))) (and (not (placement (name Nancy) (place ?n&1))) (placement (name Minnie) (place ?m&2)))) ; This is what follows from what Minnie said (or (and (placement (name Nancy) (place ?n&2)) (not (placement (name Opey) (place ?o&3)))) (and (not (placement (name Nancy) (place ?n&2))) (placement (name Opey) (place ?o&3)))) ; This is what follows from what Nancy said (or (and (placement (name Opey) (place ?o&4)) (not (placement (name Lucy) (place ?l&2)))) (and (not (placement (name Opey) (place ?o&4))) (placement (name Lucy) (place ?l&2)))) => (printout t crlf "Lucy is in the " ?l " place" crlf) (printout t "Nancy is in the " ?n " place" crlf) (printout t "Minnie is in the " ?m " place" crlf) (printout t "Opey is in the " ?o " place" crlf)) (reset) (run) ```