use of kodkod.util.nodes.AnnotatedNode in project org.alloytools.alloy by AlloyTools.
the class FullNegationPropagator method toNNF.
public static AnnotatedNode<Formula> toNNF(AnnotatedNode<Formula> annotated, Reporter reporter) {
if (reporter != null)
reporter.convertingToNNF();
final FullNegationPropagator flat = new FullNegationPropagator(annotated.sharedNodes());
annotated.node().accept(flat);
final List<Formula> roots = new ArrayList<Formula>(flat.annotations.size());
roots.addAll(flat.annotations.keySet());
for (Iterator<Map.Entry<Formula, Node>> itr = flat.annotations.entrySet().iterator(); itr.hasNext(); ) {
final Map.Entry<Formula, Node> entry = itr.next();
final Node source = annotated.sourceOf(entry.getValue());
if (entry.getKey() == source) {
itr.remove();
/* TODO: what is this for? */
} else {
entry.setValue(source);
}
}
return AnnotatedNode.annotate(Formula.and(flat.conjuncts), flat.annotations);
}
Aggregations