Design patterns in Prolog