`Program._add_var` gets invoked often, and `expr_matches` is relatively expensive. We should consider alternatives.