A term rewriting system for SWI-Prolog