A good book on Term Re-Writing is "Term Rewriting and All That".
It uses Standard ML for implementation of the algorithms, just an excellent text overall.
Also, there's a component of BAP, the Binary Analysis Platform, that uses term rewriting situated in lisp, for analysis of program state