Is this tool compatible with the 4.0 and5.0a/hr batteries?

Yes, it's compatible with 3Ah batteries or larger.