Representing Worms as a term rewriting system