kodkod.ast.operator.IntCompOperator Java Examples
The following examples show how to use
kodkod.ast.operator.IntCompOperator.
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: ExpressionUtil.java From quetzal with Eclipse Public License 2.0 | 5 votes |
public static Formula numeric_test(Expression l, Expression r, IntCompOperator op, boolean negated) { Formula test = intValue(l).compare(op, intValue(r)); if (negated) { test = test.not(); } return isNumeric(l).and(isNumeric(r)).and(test); }
Example #3
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 #4
Source File: ExpressionUtil.java From quetzal with Eclipse Public License 2.0 | 5 votes |
public static Formula not_equal_test(Expression l, Expression r) { return string_equal(l, r, true) .or(numeric_test(l, r, IntCompOperator.EQ, true)) .or(language_equal(l, r, true)) .or(unknown_equal(l, r, true)) .or(isLiteral(l).not().and(isLiteral(r).not()).and(l.eq(r).not())); }
Example #5
Source File: ExpressionUtil.java From quetzal with Eclipse Public License 2.0 | 5 votes |
public static Formula equal_test(Expression l, Expression r) { return string_equal(l, r, false) .or(numeric_test(l, r, IntCompOperator.EQ, false)) .or(language_equal(l, r, false)) .or(unknown_equal(l, r, false)) .or(isLiteral(l).not().and(isLiteral(r).not()).and(l.eq(r))); }
Example #6
Source File: ExpressionUtil.java From quetzal with Eclipse Public License 2.0 | 5 votes |
public static Formula numeric_test(Pair<Expression,IntExpression> l, Pair<Expression,IntExpression> r, IntCompOperator op, boolean negated) { Formula test = intValue(l).compare(op, intValue(r)); if (negated) { test = test.not(); } return isNumeric(l).and(isNumeric(r)).and(test); }
Example #7
Source File: IntTest.java From kodkod with MIT License | 5 votes |
private final void testCompOp(IntCompOperator op, IntExpression ei, IntExpression ej, int i, int j, boolean result) { final Formula e = ei.compare(op, ej); final Formula f = ei.eq(constant(i)).and(ej.eq(constant(j))).and(result ? e : e.not()); final Solution s = solve(f); assertNotNull(s.instance()); final Evaluator eval = new Evaluator(s.instance(), solver.options()); assertFalse(result ^ eval.evaluate(e)); }
Example #8
Source File: IntTest.java From org.alloytools.alloy with Apache License 2.0 | 5 votes |
private final void testCompOp(IntCompOperator op, IntExpression ei, IntExpression ej, int i, int j, boolean result) { final Formula e = ei.compare(op, ej); final Formula f = ei.eq(constant(i)).and(ej.eq(constant(j))).and(result ? e : e.not()); final Solution s = solve(f); if (overflows(ei, i, 0) || overflows(ej, j, 0)) { assertNull(f.toString(), s.instance()); } else { assertNotNull(f.toString(), s.instance()); final Evaluator eval = new Evaluator(s.instance(), solver.options()); assertFalse(result ^ eval.evaluate(e)); } }
Example #9
Source File: IntExpression.java From kodkod with MIT License | 4 votes |
/** * Returns a formula comparing this and the given integer expression using the * specified operator. * @return {f: Formula | f.left = this and f.right = intExpr and f.op = op } */ public Formula compare(IntCompOperator op, IntExpression intExpr) { if (op==null || intExpr==null) throw new NullPointerException(); return new IntComparisonFormula(this, op, intExpr); }
Example #10
Source File: ExpressionUtil.java From quetzal with Eclipse Public License 2.0 | 4 votes |
public static Formula less_test(Expression l, Expression r) { return numeric_test(l, r, IntCompOperator.LT, false).or(string_less(l, r)); }
Example #11
Source File: ExpressionUtil.java From quetzal with Eclipse Public License 2.0 | 4 votes |
public static Formula greater_test(Expression l, Expression r) { return numeric_test(l, r, IntCompOperator.GT, false).or(string_greater(l, r)); }
Example #12
Source File: ExpressionUtil.java From quetzal with Eclipse Public License 2.0 | 4 votes |
public static Formula less_test(Pair<Expression,IntExpression> l, Pair<Expression,IntExpression> r) { return numeric_test(l, r, IntCompOperator.LT, false).or(string_less(l.fst, r.fst)); }
Example #13
Source File: ExpressionUtil.java From quetzal with Eclipse Public License 2.0 | 4 votes |
public static Formula greater_test(Pair<Expression,IntExpression> l, Pair<Expression,IntExpression> r) { return numeric_test(l, r, IntCompOperator.GT, false).or(string_greater(l.fst, r.fst)); }
Example #14
Source File: IntComparisonFormula.java From kodkod with MIT License | 2 votes |
/** * Returns the operator of this. * @return this.op */ public IntCompOperator op() {return op;}
Example #15
Source File: IntComparisonFormula.java From org.alloytools.alloy with Apache License 2.0 | 2 votes |
/** * Constructs a new int comparison formula: left op right * * @ensures this.left' = left && this.right' = right && this.op' = op * @throws NullPointerException left = null || right = null || op = null */ IntComparisonFormula(final IntExpression left, final IntCompOperator op, final IntExpression right) { this.left = left; this.right = right; this.op = op; }
Example #16
Source File: IntComparisonFormula.java From kodkod with MIT License | 2 votes |
/** * Constructs a new int comparison formula: left op right * * @ensures this.left' = left && this.right' = right && this.op' = op * @throws NullPointerException left = null || right = null || op = null */ IntComparisonFormula(final IntExpression left, final IntCompOperator op, final IntExpression right) { this.left = left; this.right = right; this.op = op; }
Example #17
Source File: IntExpression.java From org.alloytools.alloy with Apache License 2.0 | 2 votes |
/** * Returns a formula comparing this and the given integer expression using the * specified operator. * * @return {f: Formula | f.left = this and f.right = intExpr and f.op = op } */ public Formula compare(IntCompOperator op, IntExpression intExpr) { if (op == null || intExpr == null) throw new NullPointerException(); return new IntComparisonFormula(this, op, intExpr); }
Example #18
Source File: IntComparisonFormula.java From org.alloytools.alloy with Apache License 2.0 | 2 votes |
/** * Returns the operator of this. * * @return this.op */ public IntCompOperator op() { return op; }