Rewrite abstraction/instantiation of patterns