"And Thamud": meaning, and how He dealt with Thamud: He destroyed them when they denied their messenger. "Who carved the rocks in the valley": They carved it; they hollowed it out and made them into houses.
Muhammad said: The recitation of Nafi‘ in the narration of Warsh is "bi-al-wadi" (in the valley) with a ya', and others narrated from him "bi-al-wad" without a ya', as mentioned by Ibn Mujahid.
﴿وَثَمُود﴾ أَيْ: وَكَيْفَ فَعَلَ بِثَمُودَ: أَهْلَكَهُمْ حِينَ كَذَّبُوا رُسُولَهُمْ ﴿الَّذِينَ جَابُوا الصخر بالواد﴾ جَابُوهُ: نَقَّبُوهُ فَجَعَلُوهُ بُيُوتًا
قَالَ مُحَمَّدٌ: قِرَاءَةُ نَافِعٍ فِي رِوَايَةِ وَرْشٍ ﴿بِالْوَادِي﴾ بِيَاءٍ، وَرَوَى عَنْهُ غَيره ﴿بالواد﴾ بِغَيْرِ يَاءٍ ذَكَرَهُ ابْنُ مُجَاهِدٍ.