/** * Matches the subject against the pattern. The pattern does not contain any disjunctions. */ public List<Substitution<Variable, Term>> matchSinglePattern(Term subject, Term pattern, TermContext context) { constraints[0] = ConjunctiveFormula.of(global); empty = BitSet.apply(ruleCount); BitSet one = BitSet.apply(1); one.makeOnes(1); BitSet theMatchingRules = match(subject, pattern, one, List()); if (theMatchingRules.get(0)) { return constraints[0].getDisjunctiveNormalForm().conjunctions().stream() .map(c -> c.simplify(context)) .filter(c -> !c.isFalse()) .map(c -> c.orientSubstitution(pattern.variableSet())) .filter(c -> c.isMatching(pattern.variableSet())) .map(c -> c.substitution()) .collect(Collectors.toList()); } else { return Collections.emptyList(); } }
empty = BitSet.apply(ruleCount); BitSet theMatchingRules = match(subject.term(), pattern, ruleMask, List());
/** * Matches the subject against the pattern. The pattern does not contain any disjunctions. */ public ConjunctiveFormula unifyEquality(Term subject, Term pattern, boolean patternFold, boolean partialSimplification, boolean continuousSimplification, TermContext context) { this.patternFold = patternFold; this.partialSimplification = partialSimplification; this.continuousSimplification = continuousSimplification; this.context = context; constraints[0] = ConjunctiveFormula.of(global); empty = BitSet.apply(ruleCount); BitSet one = BitSet.apply(1); one.makeOnes(1); BitSet theMatchingRules = match(subject, pattern, one, List()); if (theMatchingRules.get(0)) { return constraints[0]; } else { return ConjunctiveFormula.of(global).add(unificationFailureLeftHandSide, unificationFailureRightHandSide).simplify(); } }
fragmentItems.add(NonTerminal(childOptSort)); sentences.add(Production(childOptSort, List(NonTerminal(childSort)))); if (!m.definedKLabels().contains(KLabel("no"+childSort.toString()))) { sentences.add(Production(KLabel("no"+childSort.toString()), childOptSort, List(Terminal("no"+childSort.toString())), Att().add(Attribute.CELL_OPT_ABSENT_KEY,Sort.class,childSort)));