本文整理汇总了Java中kodkod.ast.Expression.INTS属性的典型用法代码示例。如果您正苦于以下问题:Java Expression.INTS属性的具体用法?Java Expression.INTS怎么用?Java Expression.INTS使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类kodkod.ast.Expression
的用法示例。
在下文中一共展示了Expression.INTS属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: interpret
/**
* 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);
}
}
示例2: visit
/** {@inheritDoc} */
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);
}
示例3: interpret
/**
* 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);
}
}
示例4: sim
/** If ex is a simple combination of Relations, then return that combination, else return null. */
private Expression sim(Expr ex) {
while(ex instanceof ExprUnary) {
ExprUnary u = (ExprUnary)ex;
if (u.op!=ExprUnary.Op.NOOP && u.op!=ExprUnary.Op.EXACTLYOF) break;
ex = u.sub;
}
if (ex instanceof ExprBinary) {
ExprBinary b = (ExprBinary)ex;
if (b.op==ExprBinary.Op.ARROW || b.op==ExprBinary.Op.PLUS || b.op==ExprBinary.Op.JOIN) {
Expression left = sim(b.left); if (left==null) return null;
Expression right = sim(b.right); if (right==null) return null;
if (b.op==ExprBinary.Op.ARROW) return left.product(right);
if (b.op==ExprBinary.Op.PLUS) return left.union(right); else return left.join(right);
}
}
if (ex instanceof ExprConstant) {
switch(((ExprConstant)ex).op) {
case EMPTYNESS: return Expression.NONE;
}
}
if (ex==Sig.NONE) return Expression.NONE;
if (ex==Sig.SIGINT) return Expression.INTS;
if (ex instanceof Sig) return sol.a2k((Sig)ex);
if (ex instanceof Field) return sol.a2k((Field)ex);
return null;
}
示例5: visit
/** {@inheritDoc} */
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);
}
示例6: sim
/**
* If ex is a simple combination of Relations, then return that combination,
* else return null.
*/
private Expression sim(Expr ex) {
while (ex instanceof ExprUnary) {
ExprUnary u = (ExprUnary) ex;
if (u.op != ExprUnary.Op.NOOP && u.op != ExprUnary.Op.EXACTLYOF)
break;
ex = u.sub;
}
if (ex instanceof ExprBinary) {
ExprBinary b = (ExprBinary) ex;
if (b.op == ExprBinary.Op.ARROW || b.op == ExprBinary.Op.PLUS || b.op == ExprBinary.Op.JOIN) {
Expression left = sim(b.left);
if (left == null)
return null;
Expression right = sim(b.right);
if (right == null)
return null;
if (b.op == ExprBinary.Op.ARROW)
return left.product(right);
if (b.op == ExprBinary.Op.PLUS)
return left.union(right);
else
return left.join(right);
}
}
if (ex instanceof ExprConstant) {
switch (((ExprConstant) ex).op) {
case EMPTYNESS :
return Expression.NONE;
}
}
if (ex == Sig.NONE)
return Expression.NONE;
if (ex == Sig.SIGINT)
return Expression.INTS;
if (ex instanceof Sig)
return sol.a2k((Sig) ex);
if (ex instanceof Field)
return sol.a2k((Field) ex);
return null;
}