kodkod.ast.ConstantExpression Java Examples
The following examples show how to use
kodkod.ast.ConstantExpression.
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: FOL2BoolTranslator.java From kodkod with MIT License | 6 votes |
/** * Calls lookup(unaryExpr) and returns the cached value, if any. * If a translation has not been cached, translates the expression, * calls cache(...) on it and returns it. * @return let t = lookup(unaryExpr) | some t => t, * let op = (unaryExpr.op).(TRANSPOSE->transpose + CLOSURE->closure + REFLEXIVE_CLOSURE->(lambda(m)(m.closure().or(iden))) | * cache(unaryExpr, op(unaryExpr.child)) */ public final BooleanMatrix visit(UnaryExpression unaryExpr) { BooleanMatrix ret = lookup(unaryExpr); if (ret!=null) return ret; final BooleanMatrix child = unaryExpr.expression().accept(this); final ExprOperator op = unaryExpr.op(); switch(op) { case TRANSPOSE : ret = child.transpose(); break; case CLOSURE : ret = child.closure(); break; case REFLEXIVE_CLOSURE : ret = child.closure().or(visit((ConstantExpression)Expression.IDEN)); break; default : throw new IllegalArgumentException("Unknown operator: " + op); } return cache(unaryExpr,ret); }
Example #2
Source File: LeafInterpreter.java From kodkod with MIT License | 6 votes |
/** * Returns a {@link kodkod.engine.bool.BooleanMatrix matrix} m of * {@link kodkod.engine.bool.BooleanValue boolean formulas} representing * the specified constant expression. * @return { m: BooleanMatrix | let dset = [0..this.universe.size()^c.arity) | * m.dimensions.dimensions = [0..c.arity) ->one this.universe.size() && * c = UNIV => m.elements[dset] = TRUE, c = NONE => m.elements[dset] = FALSE, * c = IDEN => (all i: dset | (some j: int | i = j*(1+this.universe.size())) => m.elements[i] = TRUE, m.elements[i] = FALSE), * c = INT => (all i: dset | (some j: int | this.interpret(j)=i) => m.elements[i] = TRUE, m.elements[i] = FALSE } */ public final BooleanMatrix interpret(ConstantExpression c) { final int univSize = universe().size(); if (c==Expression.UNIV) { final IntSet all = Ints.rangeSet(Ints.range(0, univSize-1)); return factory().matrix(Dimensions.square(univSize, 1), all, all); } else if (c==Expression.IDEN) { final Dimensions dim2 = Dimensions.square(univSize, 2); final IntSet iden = Ints.bestSet(dim2.capacity()); for(int i = 0; i < univSize; i++) { iden.add(i*univSize + i); } return factory().matrix(dim2, iden, iden); } else if (c==Expression.NONE) { return factory().matrix(Dimensions.square(univSize, 1), Ints.EMPTY_SET, Ints.EMPTY_SET); } else if (c==Expression.INTS) { final IntSet ints = Ints.bestSet(univSize); for(IntIterator iter = ints().iterator(); iter.hasNext(); ) { ints.add(interpret(iter.next())); } return factory().matrix(Dimensions.square(univSize, 1), ints, ints); } else { throw new IllegalArgumentException("unknown constant expression: " + c); } }
Example #3
Source File: LeafInterpreter.java From org.alloytools.alloy with Apache License 2.0 | 6 votes |
/** * Returns a {@link kodkod.engine.bool.BooleanMatrix matrix} m of * {@link kodkod.engine.bool.BooleanValue boolean formulas} representing the * specified constant expression. * * @return { m: BooleanMatrix | let dset = [0..this.universe.size()^c.arity) | * m.dimensions.dimensions = [0..c.arity) ->one this.universe.size() && * c = UNIV => m.elements[dset] = TRUE, c = NONE => m.elements[dset] = * FALSE, c = IDEN => (all i: dset | (some j: int | i = * j*(1+this.universe.size())) => m.elements[i] = TRUE, m.elements[i] = * FALSE), c = INT => (all i: dset | (some j: int | this.interpret(j)=i) * => m.elements[i] = TRUE, m.elements[i] = FALSE } */ public final BooleanMatrix interpret(ConstantExpression c) { final int univSize = universe().size(); if (c == Expression.UNIV) { final IntSet all = Ints.rangeSet(Ints.range(0, univSize - 1)); return factory().matrix(Dimensions.square(univSize, 1), all, all); } else if (c == Expression.IDEN) { final Dimensions dim2 = Dimensions.square(univSize, 2); final IntSet iden = Ints.bestSet(dim2.capacity()); for (int i = 0; i < univSize; i++) { iden.add(i * univSize + i); } return factory().matrix(dim2, iden, iden); } else if (c == Expression.NONE) { return factory().matrix(Dimensions.square(univSize, 1), Ints.EMPTY_SET, Ints.EMPTY_SET); } else if (c == Expression.INTS) { final IntSet ints = Ints.bestSet(univSize); for (IntIterator iter = ints().iterator(); iter.hasNext();) { ints.add(interpret(iter.next())); } return factory().matrix(Dimensions.square(univSize, 1), ints, ints); } else { throw new IllegalArgumentException("unknown constant expression: " + c); } }
Example #4
Source File: FOL2BoolTranslator.java From org.alloytools.alloy with Apache License 2.0 | 6 votes |
/** * Calls lookup(unaryExpr) and returns the cached value, if any. If a * translation has not been cached, translates the expression, calls cache(...) * on it and returns it. * * @return let t = lookup(unaryExpr) | some t => t, let op = * (unaryExpr.op).(TRANSPOSE->transpose + CLOSURE->closure + * REFLEXIVE_CLOSURE->(lambda(m)(m.closure().or(iden))) | * cache(unaryExpr, op(unaryExpr.child)) */ @Override public final BooleanMatrix visit(UnaryExpression unaryExpr) { BooleanMatrix ret = lookup(unaryExpr); if (ret != null) return ret; final BooleanMatrix child = unaryExpr.expression().accept(this); final ExprOperator op = unaryExpr.op(); switch (op) { case TRANSPOSE : ret = child.transpose(); break; case CLOSURE : ret = child.closure(); break; case REFLEXIVE_CLOSURE : ret = child.closure().or(visit((ConstantExpression) Expression.IDEN)); break; default : throw new IllegalArgumentException("Unknown operator: " + op); } return cache(unaryExpr, ret); }
Example #5
Source File: TranslateKodkodToJava.java From org.alloytools.alloy with Apache License 2.0 | 6 votes |
/** {@inheritDoc} */ @Override public void visit(ConstantExpression x) { if (map.containsKey(x)) return; String newname = null; if (x == Expression.NONE) newname = "Expression.NONE"; else if (x == Expression.UNIV) newname = "Expression.UNIV"; else if (x == Expression.IDEN) newname = "Expression.IDEN"; else if (x == Expression.INTS) newname = "Expression.INTS"; else throw new RuntimeException("Unknown kodkod ConstantExpression \"" + x + "\" encountered"); map.put(x, newname); }
Example #6
Source File: FOL2BoolTranslator.java From kodkod with MIT License | 5 votes |
/** * Returns this.interpreter.interpret(constExpr). * @return this.interpreter.interpret(constExpr). */ public final BooleanMatrix visit(ConstantExpression constExpr) { BooleanMatrix ret = leafCache.get(constExpr); if (ret==null) { ret = interpreter.interpret(constExpr); leafCache.put(constExpr, ret); } return ret; }
Example #7
Source File: FOL2BoolTranslator.java From org.alloytools.alloy with Apache License 2.0 | 5 votes |
/** * Returns this.interpreter.interpret(constExpr). * * @return this.interpreter.interpret(constExpr). */ @Override public final BooleanMatrix visit(ConstantExpression constExpr) { BooleanMatrix ret = leafCache.get(constExpr); if (ret == null) { ret = interpreter.interpret(constExpr); leafCache.put(constExpr, ret); } return ret; }
Example #8
Source File: AnnotatedNode.java From org.alloytools.alloy with Apache License 2.0 | 4 votes |
@Override public Boolean visit(ConstantExpression constExpr) { return noHOL(constExpr); }
Example #9
Source File: PrettyPrinter.java From quetzal with Eclipse Public License 2.0 | 4 votes |
/** @effects this.tokens' = concat[ this.tokens, node ] */ public void visit(ConstantExpression node) { append(node); }
Example #10
Source File: PrettyPrinter.java From kodkod with MIT License | 4 votes |
/** @ensures this.tokens' = concat[ this.tokens, node ] */ public void visit(ConstantExpression node) { append(node); }
Example #11
Source File: AbstractCollector.java From kodkod with MIT License | 4 votes |
/** * Returns Collections.EMPTY_SET * @return Collections.EMPTY_SET */ @SuppressWarnings("unchecked") public Set<T> visit(ConstantExpression constExpr) { return Collections.EMPTY_SET; }
Example #12
Source File: AspectReturnVisitor.java From org.alloytools.alloy with Apache License 2.0 | 4 votes |
@Override public E visit(ConstantExpression constExpr) { start(constExpr); return end(constExpr, visitor.visit(constExpr)); }
Example #13
Source File: PrettyPrinter.java From org.alloytools.alloy with Apache License 2.0 | 4 votes |
@Override public void visit(ConstantExpression constExpr) { visit(constExpr, constExpr.name()); }
Example #14
Source File: PrettyPrinter.java From org.alloytools.alloy with Apache License 2.0 | 4 votes |
/** @ensures this.tokens' = concat[ this.tokens, node ] */ @Override public void visit(ConstantExpression node) { append(node); }
Example #15
Source File: HOLTranslator.java From org.alloytools.alloy with Apache License 2.0 | 4 votes |
@Override public Expression visit(ConstantExpression constExpr) { return constExpr; }
Example #16
Source File: AbstractCollector.java From org.alloytools.alloy with Apache License 2.0 | 4 votes |
/** * Returns Collections.EMPTY_SET * * @return Collections.EMPTY_SET */ @Override @SuppressWarnings("unchecked" ) public Set<T> visit(ConstantExpression constExpr) { return Collections.EMPTY_SET; }
Example #17
Source File: VoidVisitor.java From kodkod with MIT License | 2 votes |
/** * Visits the given constant expression. **/ public void visit(ConstantExpression constExpr);
Example #18
Source File: AbstractReplacer.java From kodkod with MIT License | 2 votes |
/** * Calls lookup(constExpr) and returns the cached value, if any. * If a replacement has not been cached, the constExpr is cached and * returned. * @return constExpr */ public Expression visit(ConstantExpression constExpr) { final Expression ret = lookup(constExpr); return ret==null ? cache(constExpr,constExpr) : constExpr; }
Example #19
Source File: AbstractVoidVisitor.java From kodkod with MIT License | 2 votes |
/** * Does nothing. */ public void visit(ConstantExpression constExpr) {}
Example #20
Source File: ReturnVisitor.java From kodkod with MIT License | 2 votes |
/** * Visits the given constant expression and returns the result. * @return the result of visiting <code>constExpr</code> **/ public E visit(ConstantExpression constExpr);
Example #21
Source File: AbstractDetector.java From org.alloytools.alloy with Apache License 2.0 | 2 votes |
/** * Returns FALSE. * * @return FALSE */ @Override public Boolean visit(ConstantExpression expr) { return Boolean.FALSE; }
Example #22
Source File: AbstractDetector.java From kodkod with MIT License | 2 votes |
/** * Returns FALSE. * @return FALSE */ public Boolean visit(ConstantExpression expr) { return Boolean.FALSE; }
Example #23
Source File: ReturnVisitor.java From org.alloytools.alloy with Apache License 2.0 | 2 votes |
/** * Visits the given constant expression and returns the result. * * @return the result of visiting <code>constExpr</code> **/ public E visit(ConstantExpression constExpr);
Example #24
Source File: AbstractVoidVisitor.java From org.alloytools.alloy with Apache License 2.0 | 2 votes |
/** * Does nothing. */ @Override public void visit(ConstantExpression constExpr) {}
Example #25
Source File: AbstractReplacer.java From org.alloytools.alloy with Apache License 2.0 | 2 votes |
/** * Calls lookup(constExpr) and returns the cached value, if any. If a * replacement has not been cached, the constExpr is cached and returned. * * @return constExpr */ @Override public Expression visit(ConstantExpression constExpr) { final Expression ret = lookup(constExpr); return ret == null ? cache(constExpr, constExpr) : constExpr; }
Example #26
Source File: VoidVisitor.java From org.alloytools.alloy with Apache License 2.0 | 2 votes |
/** * Visits the given constant expression. **/ public void visit(ConstantExpression constExpr);
Example #27
Source File: PrettyPrinter.java From kodkod with MIT License | votes |
public void visit(ConstantExpression constExpr) { visit(constExpr, constExpr.name()); }