public static SemanticContext[] factorOr(SemanticContext a, SemanticContext b) { HashSet<SemanticContext> opsA = new HashSet<SemanticContext>(getOrOperands(a)); HashSet<SemanticContext> opsB = new HashSet<SemanticContext>(getOrOperands(b)); HashSet<SemanticContext> result = new HashSet<SemanticContext>(opsA); result.retainAll(opsB); if (result.isEmpty()) return new SemanticContext[] { EMPTY_SEMANTIC_CONTEXT, a, b }; opsA.removeAll(result); if (opsA.isEmpty()) a = new FalsePredicate(); else if (opsA.size() == 1) a = opsA.iterator().next(); else a = new OR(opsA); opsB.removeAll(result); if (opsB.isEmpty()) b = new FalsePredicate(); else if (opsB.size() == 1) b = opsB.iterator().next(); else b = new OR(opsB); if (result.size() == 1) return new SemanticContext[] { result.iterator().next(), a, b }; return new SemanticContext[] { new OR(result), a, b }; }
public static SemanticContext[] factorOr(SemanticContext a, SemanticContext b) { HashSet<SemanticContext> opsA = new HashSet<SemanticContext>(getOrOperands(a)); HashSet<SemanticContext> opsB = new HashSet<SemanticContext>(getOrOperands(b)); HashSet<SemanticContext> result = new HashSet<SemanticContext>(opsA); result.retainAll(opsB); if (result.isEmpty()) return new SemanticContext[] { EMPTY_SEMANTIC_CONTEXT, a, b }; opsA.removeAll(result); if (opsA.isEmpty()) a = new FalsePredicate(); else if (opsA.size() == 1) a = opsA.iterator().next(); else a = new OR(opsA); opsB.removeAll(result); if (opsB.isEmpty()) b = new FalsePredicate(); else if (opsB.size() == 1) b = opsB.iterator().next(); else b = new OR(opsB); if (result.size() == 1) return new SemanticContext[] { result.iterator().next(), a, b }; return new SemanticContext[] { new OR(result), a, b }; }
public static SemanticContext and(SemanticContext a, SemanticContext b) { return new FalsePredicate(); return new FalsePredicate();
public static SemanticContext and(SemanticContext a, SemanticContext b) { return new FalsePredicate(); return new FalsePredicate();
public static SemanticContext not(SemanticContext a) { if (a instanceof NOT) { return ((NOT)a).ctx; } if (a instanceof TruePredicate) return new FalsePredicate(); else if (a instanceof FalsePredicate) return new TruePredicate(); return new NOT(a); }
public static SemanticContext not(SemanticContext a) { if (a instanceof NOT) { return ((NOT)a).ctx; } if (a instanceof TruePredicate) return new FalsePredicate(); else if (a instanceof FalsePredicate) return new TruePredicate(); return new NOT(a); }