Implement chain.replace_rule()