“Where art thou?” God asks (Gen 3:9). Did he not know?

He knew. He was entering into conversation with Adam, and not discovering the location of Adam, but rather discovering himself to Adam, and thereby forcing Adam to face his own sin before his judge. This has been called an arraignment—a formal accusation. In the next chapter, he will follow a very similar procedure with Cain (Gen 4:9); like father, like son.