These verses are problematic in every attempt to explain the omniscience of God.
Genesis 18:20-21
20 And the Lord said, Because the cry of Sodom and Gomorrah is great, and because their sin is very grievous;
21 I will go down now, and see whether they have done altogether according to the cry of it, which is come unto me; and if not, I will know.
Genesis 18:2,16 (NIV2011)
2 Abraham looked up and saw three men standing nearby. When he saw them, he hurried from the entrance of his tent to meet them and bowed low to the ground.
16 When the men got up to leave, they looked down toward Sodom, and Abraham walked along with them to see them on their way.
God often spoke in a human sense to ancient humans such as Abraham. Three men (believed to be angels) are sent to witness the deeds of Sodom and Gomorrah. All God wants is the legitimacy for the destruction of Sodom and Gomorrah. Sodom and Gomorrah are destroyed not in accordance to God's foreknowledge but in accordance to open witnessing. On the other hand, God doesn't bother to explain what legitimacy and open witnessing are to Abraham the ancient human. The verses you quoted are an alternative way to describe the situation in order to make sense to Abraham.
In a similar fashion, God has all the names of the saved in the Book of Life of the Lamb. We are however not brought to heaven in accordance to His foreknowledge. We are brought to Heaven in accordance to open witnessing and by the standard defined in the New Covenant. It's all about legitimacy instead of God's omniscience.