Can I differentiate between a UPS, Generator and Main sine wave using a micro-controller?
The mains signal is generated using a generator, so you can't differentiate between those two, and about UPS (inverter), it depends, is it a sine wave inverter or a digital inverter?

If its a sine wave inverter, you can but it looks quite similar to the sine wave. If it's a digital inverter the signal is bit different from the sine wave, they look like steps going up and down.

Now back your question, to distinguish between them using a micro-controller , yes you can, but how? That is another rabbit hole, of course the signal has to be conditioned before hooking it up to the uC so it doesn't go up in smoke.

I hope this clears thing up for you.