How does a grid-tie solar power inverter know when the mains power has failed?
The last time I asked this, the answer was that the inverter tries to change the frequency and the grid is so large in comparison that the grid frequency does not move so the inverter senses a difference.
When the grid has disappeared then the frequency is easily changed which means the inverter stops output to prevent issues like islanding.