(defrule move-train :forward
(train ?train position ?train-pos)
(signal ?signal position ?signal-pos
(test (= ?signal-pos (1+ ?train-pos)))
((format t "~%Train moving to position ~s"
(assert (signal ?signal colour red))
(assert (train ?train position ?signal-pos)))
specifies that if there is a train with a green signal directly in front then the train may move on and the signal changes to red.