Prolog homework