University logic assignment in Prolog