@Override public boolean isConstructed(Variable variable, IQTree child) { return child.isConstructed(variable); }
@Override public boolean isConstructed(Variable variable, IQTree child) { return child.isConstructed(variable); }
@Override public boolean isConstructed(Variable variable, ImmutableList<IQTree> children) { return children.stream() .anyMatch(c -> c.isConstructed(variable)); }
@Override public boolean isConstructed(Variable variable, IQTree leftChild, IQTree rightChild) { return Stream.of(leftChild, rightChild) .anyMatch(c -> c.isConstructed(variable)); }
@Override public boolean isConstructed(Variable variable, ImmutableList<IQTree> children) { return children.stream() .anyMatch(c -> c.isConstructed(variable)); }
@Override public boolean isConstructed(Variable variable, IQTree child) { return substitution.isDefining(variable) || (getChildVariables().contains(variable) && child.isConstructed(variable)); }
@Override public IQTree liftIncompatibleDefinitions(Variable variable, ImmutableList<IQTree> children) { return IntStream.range(0, children.size()).boxed() .map(i -> Maps.immutableEntry(i, children.get(i))) .filter(e -> e.getValue().isConstructed(variable)) // index -> new child .map(e -> Maps.immutableEntry(e.getKey(), e.getValue().liftIncompatibleDefinitions(variable))) .filter(e -> { QueryNode newRootNode = e.getValue().getRootNode(); return (newRootNode instanceof UnionNode) && ((UnionNode) newRootNode).hasAChildWithLiftableDefinition(variable, e.getValue().getChildren()); }) .findFirst() .map(e -> liftUnionChild(e.getKey(), (NaryIQTree) e.getValue(), children)) .orElseGet(() -> iqFactory.createNaryIQTree(this, children)); }