rewriting base system