static BasicLogicRule ai_sharedPhrasesIntoDollarVars(BasicLogicRule r) { LLS splits = stringsToLineCompSplits_wordMode(r.lhs, r.rhs); LS phrases = antiFilter isDollarVar(intersectCISets(splits)); SS map = ciMapWithUnusedCountingDollarVars(phrases, linesLL(r.lhs, r.rhs)); LLS splits2 = map(splits, l -> replaceElementsUsingMap(l, map)); ret listToBasicLogicRule(lambdaMap joinWithSpace(splits2)); }