Source:
public Term applyAnywhereRules(boolean copyOnShareSubstAndEval, TermContext context) { if (kLabel.toString().equals(KLabels.KSEQ) && kList instanceof KList && (((KList) kList).get(0) instanceof KItem && ((KItem) ((KList) kList).get(0)).kLabel.toString().equals(KLabels.DOTK) || ((KList) kList).get(0).equals(KSequence.EMPTY))) { return ((KList) kList).get(1); } if (!isAnywhereApplicable(context)) { return this; } Definition definition = context.definition(); KLabelConstant kLabelConstant = (KLabelConstant) kLabel; for (Rule rule : definition.anywhereRules().get(kLabelConstant)) { try { if (rule == RuleAuditing.getAuditingRule()) { RuleAuditing.beginAudit(); } else if (RuleAuditing.isAuditBegun() && RuleAuditing.getAuditingRule() == null) { System.err.println("\nAuditing " + rule + "...\n"); } Map<Variable, Term> solution; List<Substitution<Variable, Term>> matches = PatternMatcher.match(this, rule, context); if (matches.isEmpty()) { continue; } else { assert matches.size() == 1 : "unexpected non-deterministic anywhere rule " + rule; solution = matches.get(0); } RuleAuditing.succeed(rule); Term rightHandSide = rule.rightHandSide(); if (copyOnShareSubstAndEval) { rightHandSide = rightHandSide.copyOnShareSubstAndEval( solution, rule.reusableVariables().elementSet(), context); } else { rightHandSide = rightHandSide.substituteAndEvaluate(solution, context); } return rightHandSide; } finally { if (RuleAuditing.isAuditBegun()) { if (RuleAuditing.getAuditingRule() == rule) { RuleAuditing.endAudit(); } if (!RuleAuditing.isSuccess() && RuleAuditing.getAuditingRule() == rule) { throw RuleAuditing.fail(); } } } } return this; }

Target:
public Term applyAnywhereRules(boolean copyOnShareSubstAndEval, TermContext context) { if ((kLabel instanceof KLabelConstant) && ((KLabelConstant) kLabel).name().equals(KLabels.KSEQ) && kList instanceof KList && (((KList) kList).get(0) instanceof KItem && ((KItem) ((KList) kList).get(0)).kLabel.toString().equals(KLabels.DOTK) || ((KList) kList).get(0).equals(KSequence.EMPTY))) { return ((KList) kList).get(1); } if (!isAnywhereApplicable(context)) { return this; } Definition definition = context.definition(); KLabelConstant kLabelConstant = (KLabelConstant) kLabel; for (Rule rule : definition.anywhereRules().get(kLabelConstant)) { try { if (rule == RuleAuditing.getAuditingRule()) { RuleAuditing.beginAudit(); } else if (RuleAuditing.isAuditBegun() && RuleAuditing.getAuditingRule() == null) { System.err.println("\nAuditing " + rule + "...\n"); } Map<Variable, Term> solution; List<Substitution<Variable, Term>> matches = PatternMatcher.match(this, rule, context); if (matches.isEmpty()) { continue; } else { assert matches.size() == 1 : "unexpected non-deterministic anywhere rule " + rule; solution = matches.get(0); } RuleAuditing.succeed(rule); Term rightHandSide = rule.rightHandSide(); if (copyOnShareSubstAndEval) { rightHandSide = rightHandSide.copyOnShareSubstAndEval( solution, rule.reusableVariables().elementSet(), context); } else { rightHandSide = rightHandSide.substituteAndEvaluate(solution, context); } return rightHandSide; } finally { if (RuleAuditing.isAuditBegun()) { if (RuleAuditing.getAuditingRule() == rule) { RuleAuditing.endAudit(); } if (!RuleAuditing.isSuccess() && RuleAuditing.getAuditingRule() == rule) { throw RuleAuditing.fail(); } } } } return this; }