当前位置: 首页>>代码示例>>Java>>正文


Java Expression.eq方法代码示例

本文整理汇总了Java中kodkod.ast.Expression.eq方法的典型用法代码示例。如果您正苦于以下问题:Java Expression.eq方法的具体用法?Java Expression.eq怎么用?Java Expression.eq使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在kodkod.ast.Expression的用法示例。


在下文中一共展示了Expression.eq方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isIn

import kodkod.ast.Expression; //导入方法依赖的package包/类
/**
 * Helper method that translates the formula "a in b" into a Kodkod formula.
 */
private Formula isIn(Expression a, Expr right) throws Err {
	Expression b;
	if (right instanceof ExprBinary && right.mult != 0 && ((ExprBinary) right).op.isArrow) {
		// Handles possible "binary" or higher-arity multiplicity
		return isInBinary(a, (ExprBinary) right);
	}
	switch (right.mult()) {
		case EXACTLYOF :
			b = cset(right);
			return a.eq(b);
		case ONEOF :
			b = cset(right);
			return a.one().and(a.in(b));
		case LONEOF :
			b = cset(right);
			return a.lone().and(a.in(b));
		case SOMEOF :
			b = cset(right);
			return a.some().and(a.in(b));
		default :
			b = cset(right);
			return a.in(b);
	}
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:28,代码来源:TranslateAlloyToKodkod.java

示例2: wilkie

import kodkod.ast.Expression; //导入方法依赖的package包/类
/**
 * Returns the wilkie conjecture.
 * 
 * @return wilkie
 */
public final Formula wilkie() {
	// ! [C,P,Q,R,S,A,B] :
	// ( ( C = product(A,A)
	// & P = sum(n1,A)
	// & Q = sum(P,C)
	// & R = sum(n1,product(A,C))
	// & S = sum(sum(n1,C),product(C,C)) )
	// =>
	// product(exponent(sum(exponent(P,A),exponent(Q,A)),B),exponent(sum(exponent(R,B),exponent(S,B)),A))
	// =
	// product(exponent(sum(exponent(P,B),exponent(Q,B)),A),exponent(sum(exponent(R,A),exponent(S,A)),B))
	// ) )).
	final Variable c = Variable.unary("C");
	final Variable p = Variable.unary("P");
	final Variable q = Variable.unary("Q");
	final Variable r = Variable.unary("R");
	final Variable s = Variable.unary("S");
	final Variable a = Variable.unary("A");
	final Variable b = Variable.unary("B");
	final Formula f0 = c.eq(product(a, a));
	final Formula f1 = p.eq(sum(n1, a));
	final Formula f2 = q.eq(sum(p, c));
	final Formula f3 = r.eq(sum(n1, product(a, c)));
	final Formula f4 = s.eq(sum(sum(n1, c), product(c, c)));
	final Expression e0 = product(exponent(sum(exponent(p, a), exponent(q, a)), b),
			exponent(sum(exponent(r, b), exponent(s, b)), a));
	final Expression e1 = product(exponent(sum(exponent(p, b), exponent(q, b)), a),
			exponent(sum(exponent(r, a), exponent(s, a)), b));
	final Formula f5 = e0.eq(e1);
	return (f0.and(f1).and(f2).and(f3).and(f4)).implies(f5)
			.forAll(c.oneOf(UNIV)
					.and(p.oneOf(UNIV))
					.and(q.oneOf(UNIV))
					.and(r.oneOf(UNIV))
					.and(s.oneOf(UNIV))
					.and(a.oneOf(UNIV))
					.and(b.oneOf(UNIV)));
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:44,代码来源:NUM374.java

示例3: AbWorldSecureOp

import kodkod.ast.Expression; //导入方法依赖的package包/类
/**
 * Returns the application of the AbWorldSecureOp predicate.
 * 
 * @return application of the AbWorldSecureOp predicate.
 */
public Formula AbWorldSecureOp(Expression s, Expression sprime, Expression a_in, Expression a_out) {
	final Formula f0 = AbOp(a_out);
	final Formula f1 = a_in.in(TransferDetails);

	final Expression e0 = a_in.join(from);
	final Expression e1 = a_in.join(to);
	final Expression e2 = s.join(abAuthPurse).difference(e0).difference(e1);
	final Expression e3 = sprime.join(abAuthPurse).difference(e0).difference(e1);
	final Formula f2 = e2.eq(e3);

	final Formula f3 = XiAbPurse(s, sprime, e2);

	return Formula.and(f0, f1, f2, f3);
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:20,代码来源:AbstractWorldDefinitions.java

示例4: isIn

import kodkod.ast.Expression; //导入方法依赖的package包/类
/** Helper method that translates the formula "a in b" into a Kodkod formula. */
private Formula isIn(Expression a, Expr right) throws Err {
   Expression b;
   if (right instanceof ExprBinary && right.mult!=0 && ((ExprBinary)right).op.isArrow) {
      // Handles possible "binary" or higher-arity multiplicity
      return isInBinary(a, (ExprBinary)right);
   }
   switch(right.mult()) {
      case EXACTLYOF: b=cset(right); return a.eq(b);
      case ONEOF:     b=cset(right); return a.one().and(a.in(b));
      case LONEOF:    b=cset(right); return a.lone().and(a.in(b));
      case SOMEOF:    b=cset(right); return a.some().and(a.in(b));
      default:        b=cset(right); return a.in(b);
   }
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:16,代码来源:TranslateAlloyToKodkod.java

示例5: testFelix_06192008

import kodkod.ast.Expression; //导入方法依赖的package包/类
public final void testFelix_06192008() {
	Relation x5 = Relation.unary("R");

	List<String> atomlist = Arrays.asList("X");

	Universe universe = new Universe(atomlist);
	TupleFactory factory = universe.factory();
	Bounds bounds = new Bounds(universe);

	TupleSet x5_upper = factory.noneOf(1);
	x5_upper.add(factory.tuple("X"));
	bounds.bound(x5, x5_upper);

	Variable x10 = Variable.unary("a");
	Expression x11 = x5.difference(x5);
	Decls x9 = x10.oneOf(x11);
	Variable x14 = Variable.nary("b", 2);
	Expression x15 = x5.product(x5);
	Decls x13 = x14.setOf(x15);
	Expression x19 = x5.product(x5);
	Formula x17 = x14.in(x19);
	Expression x22 = x10.product(x10);
	Formula x21 = x22.eq(x14);
	Formula x16 = x17.and(x21);
	Formula x12 = x16.forSome(x13);
	Formula x7 = x12.forAll(x9);

	// System.out.println(x7);

	Solver solver = new Solver();
	solver.options().setSolver(SATFactory.DefaultSAT4J);
	solver.options().setBitwidth(4);
	// solver.options().setFlatten(false);
	solver.options().setIntEncoding(Options.IntEncoding.TWOSCOMPLEMENT);
	solver.options().setSymmetryBreaking(20);

	// System.out.println("Depth=0..."); System.out.flush();
	solver.options().setSkolemDepth(0);
	assertEquals(Solution.Outcome.TRIVIALLY_SATISFIABLE, solver.solve(x7, bounds).outcome());

	// System.out.println("Depth=1..."); System.out.flush();
	solver.options().setSkolemDepth(1);
	final Solution sol = solver.solve(x7, bounds);
	assertEquals(Solution.Outcome.SATISFIABLE, sol.outcome());
	assertEquals(2, sol.instance().relations().size());
	for (Relation r : sol.instance().relations()) {
		assertTrue(sol.instance().tuples(r).isEmpty());
	}
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:50,代码来源:BugTests.java

示例6: AbOp

import kodkod.ast.Expression; //导入方法依赖的package包/类
/**
 * Returns the application of the AbOp predicate.
 * 
 * @return application of the AbOp predicate.
 */
public Formula AbOp(Expression a_out) {
	return a_out.eq(aNullOut);
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:9,代码来源:AbstractWorldDefinitions.java


注:本文中的kodkod.ast.Expression.eq方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。