Applications of automata theory to presentations of monoids and inverse monoids