Thank you for your question on I Samuel 23, “If whatever God says comes to pass, did God lie in 1 Samuel 23 when he said Saul would come?”
As I read the text several times in trying to understand your question, God said that Saul would come and tear down the city IF David stayed in the city. This is a true statement that if David didn’t flee, Saul would have capture him. He was bringing his whole army.
David further inquire of God whether the men of that city would surrender David to spare their own lives. The answer is yes. For the men of that city thought more about themselves than David. God knew the intentions of the hearts of the men. He knew the heart of King Saul and the people of Keilah. Thus both answer are correct that if David stayed in Keliah, he would be captured.
If God say, “No” that Saul wouldn’t come nor the people of Keilah hand him over to Saul, but Saul did come and the men of Keilah handed him over to Saul, then one can say that God lied to David. That is not the case.
David with his wisdom decided not to endanger the city and his men. He left the city so that Saul would not attack it. He didn’t want the bloodshed of that city on his hands. It would be unnecessary bloodshed. David logically concluded that if the remained, he would be capture. Thus for him and his men to leave would be a wiser choice.
The unknown factors for David was whether Saul and his men would confront David and his men some where in the mountains. He didn’t know whether he would have to battle Saul and his men. That was not David’s choice. David had opportunities to kill Saul, but he restrained himself and his men from murdering Saul.
I Samuel 26 says this, “But David said to Abishai, “Don’t destroy him! Who can lay a hand on the LORD’s anointed and be guiltless? 10 As surely as the LORD lives,” he said, “the LORD himself will strike him, or his time will come and he will die, or he will go into battle and perish. 11 But the LORD forbid that I should lay a hand on the LORD’s anointed. Now get the spear and water jug that are near his head, and let’s go.” (NIV).
I believe David knew that Saul could not kill him since God had anointed him king. David had to be patient to see how God would deliver him from Saul time and time again. David entrusted his life and those who follow him into God’s hand.
SUMMARY: God revealed the hearts of men to David. It was David’s decision as to