The place you need to check is the Motherboard's RAM MEMORY QVL list for Vermeer processor and see if it lists any RAM running at 4000 Mhz.
It will show at what speeds it can run and how many DIMM Slots it will be compatible with and whether you can Overclock or not.
You can also check the RAM Manufacturer to see if it is compatible with your motherboard that you plan on purchasing.
Generally for the best performance or "Sweet spot" for RAM Mhz for the Ryzen Infinity Fabric is:
3200 Mhz for the 2xxx processors
3600 Mhz for the 3xxx processors
I don't know what is the "sweet spot" for the Vermeer 5xxx processors are.