kodkod.ast.IntComparisonFormula Java Examples
The following examples show how to use
kodkod.ast.IntComparisonFormula.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PartialCannonicalizer.java From quetzal with Eclipse Public License 2.0 | 6 votes |
public Formula visit(IntComparisonFormula formula) { Formula ret = lookup(formula); if (ret!=null) return ret; final IntCompOperator op = formula.op(); final IntExpression left = formula.left().accept(this); final IntExpression right = formula.right().accept(this); if (left==right) return cache(formula,Formula.TRUE); final int hash = hash(op, left, right); for(Iterator<PartialCannonicalizer.Holder<Formula>> itr = formulas.get(hash); itr.hasNext(); ) { final Formula next = itr.next().obj; if (next instanceof IntComparisonFormula) { final IntComparisonFormula hit = (IntComparisonFormula) next; if (hit.op()==op && hit.left()==left && hit.right()==right) { return cache(formula, hit); } } } ret = left==formula.left()&&right==formula.right() ? formula : left.compare(op, right); formulas.add(new PartialCannonicalizer.Holder<Formula>(ret, hash)); return cache(formula,ret); }
Example #2
Source File: FOL2BoolTranslator.java From kodkod with MIT License | 6 votes |
/** * Calls lookup(intComp) and returns the cached value, if any. * If a translation has not been cached, translates the formula, * calls cache(...) on it and returns it. * @return let t = lookup(intComp) | some t => t, * cache(intComp, intComp.left.accept(this) intComp.op intComp.right.accept(this)) */ public final BooleanValue visit(IntComparisonFormula intComp) { BooleanValue ret = lookup(intComp); if (ret!=null) return ret; final Int left = intComp.left().accept(this); final Int right = intComp.right().accept(this); switch(intComp.op()) { case EQ : ret = left.eq(right); break; case LT : ret = left.lt(right); break; case LTE : ret = left.lte(right); break; case GT : ret = left.gt(right); break; case GTE : ret = left.gte(right); break; default: throw new IllegalArgumentException("Unknown operator: " + intComp.op()); } return cache(intComp, ret); }
Example #3
Source File: TranslateKodkodToJava.java From org.alloytools.alloy with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ @Override public void visit(IntComparisonFormula x) { String newname = makename(x); if (newname == null) return; String left = make(x.left()); String right = make(x.right()); switch (x.op()) { case NEQ : file.printf("Formula %s=%s.neq(%s);%n", newname, left, right); break; case EQ : file.printf("Formula %s=%s.eq(%s);%n", newname, left, right); break; case GT : file.printf("Formula %s=%s.gt(%s);%n", newname, left, right); break; case GTE : file.printf("Formula %s=%s.gte(%s);%n", newname, left, right); break; case LT : file.printf("Formula %s=%s.lt(%s);%n", newname, left, right); break; case LTE : file.printf("Formula %s=%s.lte(%s);%n", newname, left, right); break; default : throw new RuntimeException("Unknown kodkod operator \"" + x.op() + "\" encountered"); } }
Example #4
Source File: Simplifier.java From quetzal with Eclipse Public License 2.0 | 5 votes |
public Formula visit(IntComparisonFormula formula) { Formula ret = lookup(formula); if (ret!=null) return ret; final IntCompOperator op = formula.op(); final IntExpression left = formula.left().accept(this); final IntExpression right = formula.right().accept(this); if (left==right) return cache(formula,Formula.TRUE); ret = left==formula.left()&&right==formula.right() ? formula : left.compare(op, right); return cache(formula,ret); }
Example #5
Source File: PrettyPrinter.java From quetzal with Eclipse Public License 2.0 | 5 votes |
/** @effects this.tokens' = concat[ this.tokens, tokenize[node.left], node.op, tokenize[node.right] */ public void visit(IntComparisonFormula node) { if (displayed(node)) return; final boolean oldTop = notTop(); visitChild(node.left(), parenthesize(node.left())); infix(node.op()); visitChild(node.right(), parenthesize(node.right())); top = oldTop; }
Example #6
Source File: Skolemizer.java From kodkod with MIT License | 5 votes |
/** * Calls super.visit(icf) after disabling skolemization and returns the result. * @return super.visit(icf) **/ public final Formula visit(IntComparisonFormula icf) { final int oldDepth = skolemDepth; skolemDepth = -1; // cannot skolemize inside an int comparison formula final Formula ret = super.visit(icf); skolemDepth = oldDepth; return source(ret,icf); }
Example #7
Source File: AbstractCollector.java From kodkod with MIT License | 5 votes |
/** * Calls lookup(intComp) and returns the cached value, if any. * If no cached value exists, visits each child, caches the * union of the children's return values and returns it. * @return let x = lookup(intComp) | * x != null => x, * cache(intComp, intComp.left.accept(this) + intComp.right.accept(this)) */ public Set<T> visit(IntComparisonFormula intComp) { Set<T> ret = lookup(intComp); if (ret!=null) return ret; ret = newSet(); ret.addAll(intComp.left().accept(this)); ret.addAll(intComp.right().accept(this)); return cache(intComp, ret); }
Example #8
Source File: AbstractReplacer.java From kodkod with MIT License | 5 votes |
/** * Calls lookup(intComp) and returns the cached value, if any. * If a replacement has not been cached, visits the formula's * children. If nothing changes, the argument is cached and * returned, otherwise a replacement formula is cached and returned. * @return { c: Formula | [[c]] = intComp.left.accept(this) op intComp.right.accept(this) } */ public Formula visit(IntComparisonFormula intComp) { Formula ret = lookup(intComp); if (ret!=null) return ret; final IntExpression left = intComp.left().accept(this); final IntExpression right = intComp.right().accept(this); ret = (left==intComp.left() && right==intComp.right()) ? intComp : left.compare(intComp.op(), right); return cache(intComp,ret); }
Example #9
Source File: PrettyPrinter.java From org.alloytools.alloy with Apache License 2.0 | 5 votes |
/** * @ensures this.tokens' = concat[ this.tokens, tokenize[node.left], node.op, * tokenize[node.right] */ @Override public void visit(IntComparisonFormula node) { visitChild(node.left(), parenthesize(node.left())); infix(node.op()); visitChild(node.right(), parenthesize(node.right())); }
Example #10
Source File: FOL2BoolTranslator.java From org.alloytools.alloy with Apache License 2.0 | 5 votes |
/** * Calls lookup(intComp) and returns the cached value, if any. If a translation * has not been cached, translates the formula, calls cache(...) on it and * returns it. This is the only place where <code>Int</code>s are turned into * formulas, so that's where the overflow circuits of individual * <code>Int</code>s are built into the translated formula. * * @return let t = lookup(intComp) | some t => t, cache(intComp, * intComp.left.accept(this) intComp.op intComp.right.accept(this)) */ @Override public final BooleanValue visit(IntComparisonFormula intComp) { BooleanValue ret = lookup(intComp); if (ret != null) return ret; final Int left = intComp.left().accept(this); final Int right = intComp.right().accept(this); switch (intComp.op()) { case EQ : ret = left.eq(right, env); break; case NEQ : ret = left.neq(right, env); break; case LT : ret = left.lt(right, env); break; case LTE : ret = left.lte(right, env); break; case GT : ret = left.gt(right, env); break; case GTE : ret = left.gte(right, env); break; default : throw new IllegalArgumentException("Unknown operator: " + intComp.op()); } return cache(intComp, ret); }
Example #11
Source File: FullNegationPropagator.java From org.alloytools.alloy with Apache License 2.0 | 5 votes |
/** @see #visitFormula(Formula) */ @Override public final void visit(IntComparisonFormula cf) { if (visited(cf)) return; if (!negated) { addConjunct(cf); } else { switch (cf.op()) { case GT : addConjunct(cf.left().lte(cf.right()), false, cf); hasChanged = true; break; case GTE : addConjunct(cf.left().lt(cf.right()), false, cf); hasChanged = true; break; case LT : addConjunct(cf.left().gte(cf.right()), false, cf); hasChanged = true; break; case LTE : addConjunct(cf.left().gt(cf.right()), false, cf); hasChanged = true; break; case EQ : addConjunct(cf.left().neq(cf.right()), false, cf); hasChanged = true; break; case NEQ : addConjunct(cf.left().eq(cf.right()), false, cf); hasChanged = true; break; default : addConjunct(cf); } } }
Example #12
Source File: AbstractCollector.java From org.alloytools.alloy with Apache License 2.0 | 5 votes |
/** * Calls lookup(intComp) and returns the cached value, if any. If no cached * value exists, visits each child, caches the union of the children's return * values and returns it. * * @return let x = lookup(intComp) | x != null => x, cache(intComp, * intComp.left.accept(this) + intComp.right.accept(this)) */ @Override public Set<T> visit(IntComparisonFormula intComp) { Set<T> ret = lookup(intComp); if (ret != null) return ret; ret = newSet(); ret.addAll(intComp.left().accept(this)); ret.addAll(intComp.right().accept(this)); return cache(intComp, ret); }
Example #13
Source File: AbstractVoidVisitor.java From org.alloytools.alloy with Apache License 2.0 | 5 votes |
/** * Visits the children of the given integer comparison formula if * this.visited(intComp) returns false. Otherwise does nothing. * * @ensures intComp.left.accept(this) && intComp.right.accept(this) */ @Override public void visit(IntComparisonFormula intComp) { if (visited(intComp)) return; intComp.left().accept(this); intComp.right().accept(this); }
Example #14
Source File: AbstractReplacer.java From org.alloytools.alloy with Apache License 2.0 | 5 votes |
/** * Calls lookup(intComp) and returns the cached value, if any. If a replacement * has not been cached, visits the formula's children. If nothing changes, the * argument is cached and returned, otherwise a replacement formula is cached * and returned. * * @return { c: Formula | [[c]] = intComp.left.accept(delegate) op * intComp.right.accept(delegate) } */ @Override public Formula visit(IntComparisonFormula intComp) { Formula ret = lookup(intComp); if (ret != null) return ret; final IntExpression left = intComp.left().accept(delegate); final IntExpression right = intComp.right().accept(delegate); ret = (left == intComp.left() && right == intComp.right()) ? intComp : left.compare(intComp.op(), right); return cache(intComp, ret); }
Example #15
Source File: Skolemizer.java From org.alloytools.alloy with Apache License 2.0 | 5 votes |
/** * Calls super.visit(icf) after disabling skolemization and returns the result. * * @return super.visit(icf) **/ @Override public final Formula visit(IntComparisonFormula icf) { final int oldDepth = skolemDepth; skolemDepth = -1; // cannot skolemize inside an int comparison formula final Formula ret = super.visit(icf); skolemDepth = oldDepth; return source(ret, icf); }
Example #16
Source File: TrivialProof.java From org.alloytools.alloy with Apache License 2.0 | 4 votes |
@Override public void visit(IntComparisonFormula intComp) { if (visited(intComp)) return; relevant.add(intComp); }
Example #17
Source File: FormulaFlattener.java From kodkod with MIT License | 4 votes |
/** @see #visitFormula(Formula) */ public final void visit(IntComparisonFormula cf) { visitFormula(cf); }
Example #18
Source File: PrettyPrinter.java From kodkod with MIT License | 4 votes |
/** @ensures this.tokens' = concat[ this.tokens, tokenize[node.left], node.op, tokenize[node.right] */ public void visit(IntComparisonFormula node) { visitChild(node.left(), parenthesize(node.left())); infix(node.op()); visitChild(node.right(), parenthesize(node.right())); }
Example #19
Source File: TrivialProof.java From kodkod with MIT License | 4 votes |
public void visit(IntComparisonFormula intComp) { if (visited(intComp)) return; relevant.add(intComp); }
Example #20
Source File: AbstractVoidVisitor.java From kodkod with MIT License | 4 votes |
/** * Visits the children of the given integer comparison formula if * this.visited(intComp) returns false. Otherwise does nothing. * @ensures intComp.left.accept(this) && intComp.right.accept(this) */ public void visit(IntComparisonFormula intComp) { if (visited(intComp)) return; intComp.left().accept(this); intComp.right().accept(this); }
Example #21
Source File: AspectReturnVisitor.java From org.alloytools.alloy with Apache License 2.0 | 4 votes |
@Override public F visit(IntComparisonFormula intComp) { start(intComp); return end(intComp, visitor.visit(intComp)); }
Example #22
Source File: AnnotatedNode.java From org.alloytools.alloy with Apache License 2.0 | 4 votes |
@Override public Boolean visit(IntComparisonFormula f) { return checkVisitedThenAccumA(f, Boolean.FALSE, f.left(), f.right()); }
Example #23
Source File: AnnotatedNode.java From org.alloytools.alloy with Apache License 2.0 | 4 votes |
/** * Calls visited(intComp); intComp's children are not top-level formulas so they * are not visited. */ @Override public void visit(IntComparisonFormula intComp) { visited(intComp); }
Example #24
Source File: PrettyPrinter.java From org.alloytools.alloy with Apache License 2.0 | 4 votes |
@Override public void visit(IntComparisonFormula intComp) { visit(intComp, intComp.op(), intComp.left(), intComp.right()); }
Example #25
Source File: HOLTranslator.java From org.alloytools.alloy with Apache License 2.0 | 4 votes |
@Override public Proc visit(IntComparisonFormula intComp) { return new Proc.FOL(bounds, intComp); }
Example #26
Source File: FormulaFlattener.java From org.alloytools.alloy with Apache License 2.0 | 4 votes |
/** @see #visitFormula(Formula) */ @Override public final void visit(IntComparisonFormula cf) { visitFormula(cf); }
Example #27
Source File: VoidVisitor.java From org.alloytools.alloy with Apache License 2.0 | 2 votes |
/** * Visits the given integer comparison formula. */ public void visit(IntComparisonFormula intComp);
Example #28
Source File: AnnotatedNode.java From kodkod with MIT License | 2 votes |
/** * Calls visited(intComp); intComp's children are not top-level formulas * so they are not visited. */ public void visit(IntComparisonFormula intComp) { visited(intComp); }
Example #29
Source File: ReturnVisitor.java From org.alloytools.alloy with Apache License 2.0 | 2 votes |
/** * Visits the given integer comparison formula and returns the result. * * @return the result of visiting <code>intcomp</code> */ public F visit(IntComparisonFormula intComp);
Example #30
Source File: AbstractDetector.java From kodkod with MIT License | 2 votes |
/** * Calls lookup(intComp) and returns the cached value, if any. * If no cached value exists, visits each child, caches the * disjunction of the children's return values and returns it. * @return let x = lookup(intComp) | * x != null => x, * cache(intComp, intComp.left.accept(this) || intComp.right.accept(this)) */ public Boolean visit(IntComparisonFormula intComp) { final Boolean ret = lookup(intComp); return (ret!=null) ? ret : cache(intComp, intComp.left().accept(this) || intComp.right().accept(this)); }