You can send a goal to execute in a Prolog top-level from any buffer with the command M-x sweeprolog-top-level-send-goal RET.
Execute a Prolog goal in a top-level buffer and display that buffer
This command prompts for a Prolog goal in the minibuffer, executes it in a top-level buffer and displays that buffer if it’s not already visible. While inserting the goal in the minibuffer, you can use TAB (or C-i) to get completion suggestions.
In Sweep Prolog mode buffers, you can invoke
sweeprolog-top-level-send-goal by typing C-c C-q. It
also uses the goal at point (if any) as the “future history” for the
goal prompt, which you can access with M-n in the minibuffer.