Logic Prolog Loop