Search in sources :

Example 6 with AnnotatedNode

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);
}
Also used : BinaryFormula(kodkod.ast.BinaryFormula) MultiplicityFormula(kodkod.ast.MultiplicityFormula) QuantifiedFormula(kodkod.ast.QuantifiedFormula) ConstantFormula(kodkod.ast.ConstantFormula) NotFormula(kodkod.ast.NotFormula) ComparisonFormula(kodkod.ast.ComparisonFormula) NaryFormula(kodkod.ast.NaryFormula) Formula(kodkod.ast.Formula) FixFormula(kodkod.ast.FixFormula) IntComparisonFormula(kodkod.ast.IntComparisonFormula) AnnotatedNode(kodkod.util.nodes.AnnotatedNode) Node(kodkod.ast.Node) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Aggregations

Formula (kodkod.ast.Formula)6 Node (kodkod.ast.Node)6 AnnotatedNode (kodkod.util.nodes.AnnotatedNode)6 IdentityHashMap (java.util.IdentityHashMap)5 BinaryFormula (kodkod.ast.BinaryFormula)5 NaryFormula (kodkod.ast.NaryFormula)5 NotFormula (kodkod.ast.NotFormula)5 QuantifiedFormula (kodkod.ast.QuantifiedFormula)5 ArrayList (java.util.ArrayList)4 LinkedHashMap (java.util.LinkedHashMap)4 Map (java.util.Map)4 ComparisonFormula (kodkod.ast.ComparisonFormula)4 IntComparisonFormula (kodkod.ast.IntComparisonFormula)4 MultiplicityFormula (kodkod.ast.MultiplicityFormula)4 ConstantFormula (kodkod.ast.ConstantFormula)3 FixFormula (kodkod.ast.FixFormula)1 RelationPredicate (kodkod.ast.RelationPredicate)1 AbstractReplacer (kodkod.ast.visitor.AbstractReplacer)1 BooleanFormula (kodkod.engine.bool.BooleanFormula)1