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


Java Decls.get方法代码示例

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


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

示例1: comprehension

import kodkod.ast.Decls; //导入方法依赖的package包/类
/**
 * Translates the given comprehension as follows (where A_0...A_|A| stand
 * for boolean variables that represent the tuples of the expression A,
 * etc.): let comprehension = "{ a: A, b: B, ..., x: X | F(a, b, ..., x) }"
 * | { a: A, b: B, ..., x: X | a in A && b in B && ... && x in X && F(a, b,
 * ..., x) }.
 * 
 * @param decls the declarations comprehension
 * @param param formula the body of the comprehension
 * @param currentDecl currently processed declaration; should be 0 initially
 * @param declConstraints the constraints implied by the declarations;
 *            should be Boolean.TRUE intially
 * @param partialIndex partial index into the provided matrix; should be 0
 *            initially
 * @param matrix boolean matrix that will retain the final results; should
 *            be an empty matrix of dimensions universe.size^decls.length
 *            initially
 * @ensures the given matrix contains the translation of the comprehension
 *          "{ decls | formula }"
 */
private final void comprehension(Decls decls, Formula formula, int currentDecl, BooleanValue declConstraints,
		int partialIndex, BooleanMatrix matrix) {
	final BooleanFactory factory = interpreter.factory();

	if (currentDecl == decls.size()) {
		// TODO: what about this and overflow???
		matrix.set(partialIndex, factory.and(declConstraints, formula.accept(this)));
		return;
	}

	final Decl decl = decls.get(currentDecl);
	final BooleanMatrix declTransl = visit(decl);
	final int position = (int) StrictMath.pow(interpreter.universe().size(), decls.size() - currentDecl - 1);
	final BooleanMatrix groundValue = factory.matrix(declTransl.dimensions());
	env = env.extend(decl.variable(), decl.expression(), groundValue);
	for (IndexedEntry<BooleanValue> entry : declTransl) {
		groundValue.set(entry.index(), BooleanConstant.TRUE);
		comprehension(decls, formula, currentDecl + 1, factory.and(entry.value(), declConstraints),
				partialIndex + entry.index() * position, matrix);
		groundValue.set(entry.index(), BooleanConstant.FALSE);
	}
	env = env.parent();
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:44,代码来源:FOL2BoolTranslator.java

示例2: sum

import kodkod.ast.Decls; //导入方法依赖的package包/类
/**
 * Translates the given sum expression as follows (where A_0...A_|A| stand
 * for boolean variables that represent the tuples of the expression A,
 * etc.): let sum = "sum a: A, b: B, ..., x: X | IE(a, b, ..., x) " | sum a:
 * A, b: B, ..., x: X | if (a in A && b in B && ... && x in X) then IE(a, b,
 * ..., x) else 0 }.
 * 
 * @param decls intexpr declarations
 * @param formula the formula body
 * @param currentDecl currently processed declaration; should be 0 initially
 * @param declConstraints the constraints implied by the declarations;
 *            should be Boolean.TRUE intially
 * @param values integer values computed so far
 */
private final void sum(Decls decls, IntExpression expr, int currentDecl, BooleanValue declConstraints,
		List<Int> values) {
	final BooleanFactory factory = interpreter.factory();
	if (decls.size() == currentDecl) {
		Int intExpr = expr.accept(this);
		Int newInt = intExpr.choice(declConstraints, factory.integer(0));
		values.add(newInt);
		return;
	}

	final Decl decl = decls.get(currentDecl);
	final BooleanMatrix declTransl = visit(decl);
	final BooleanMatrix groundValue = factory.matrix(declTransl.dimensions());
	env = env.extend(decl.variable(), decl.expression(), groundValue);
	for (IndexedEntry<BooleanValue> entry : declTransl) {
		groundValue.set(entry.index(), BooleanConstant.TRUE);
		sum(decls, expr, currentDecl + 1, factory.and(entry.value(), declConstraints), values);
		groundValue.set(entry.index(), BooleanConstant.FALSE);
	}
	env = env.parent();
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:36,代码来源:FOL2BoolTranslator.java

示例3: comprehension

import kodkod.ast.Decls; //导入方法依赖的package包/类
/**
 * Translates the given comprehension as follows 
 * (where A_0...A_|A| stand for boolean variables that represent the 
 * tuples of the expression A, etc.):
 * let comprehension = "{ a: A, b: B, ..., x: X | F(a, b, ..., x) }" |
 *     { a: A, b: B, ..., x: X | a in A && b in B && ... && x in X && F(a, b, ..., x) }.
 * @param decls the declarations comprehension
 * @param param formula the body of the comprehension
 * @param currentDecl currently processed declaration; should be 0 initially
 * @param declConstraints the constraints implied by the declarations; should be Boolean.TRUE intially
 * @param partialIndex partial index into the provided matrix; should be 0 initially
 * @param matrix boolean matrix that will retain the final results; should be an empty matrix of dimensions universe.size^decls.length initially
 * @ensures the given matrix contains the translation of the comprehension "{ decls | formula }"
 */
private final void comprehension(Decls decls, Formula formula, int currentDecl, 
		BooleanValue declConstraints, int partialIndex, BooleanMatrix matrix) {
	final BooleanFactory factory = interpreter.factory();

	if (currentDecl==decls.size()) {
	    //TODO: what about this and overflow???
		matrix.set(partialIndex, factory.and(declConstraints, formula.accept(this)));
		return;
	}

	final Decl decl = decls.get(currentDecl);
	final BooleanMatrix declTransl = visit(decl);
	final int position = (int)StrictMath.pow(interpreter.universe().size(), decls.size()-currentDecl-1);
	final BooleanMatrix groundValue = factory.matrix(declTransl.dimensions());
	env = env.extend(decl.variable(), decl.expression(), groundValue);
	for(IndexedEntry<BooleanValue> entry : declTransl) {
		groundValue.set(entry.index(), BooleanConstant.TRUE);
		comprehension(decls, formula, currentDecl+1, factory.and(entry.value(), declConstraints), 
				partialIndex + entry.index()*position, matrix);
		groundValue.set(entry.index(), BooleanConstant.FALSE);	
	}
	env = env.parent();
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:38,代码来源:FOL2BoolTranslator.java

示例4: sum

import kodkod.ast.Decls; //导入方法依赖的package包/类
/**
 * Translates the given sum expression as follows 
 * (where A_0...A_|A| stand for boolean variables that represent the 
 * tuples of the expression A, etc.):
 * let sum = "sum a: A, b: B, ..., x: X | IE(a, b, ..., x) " |
 *     sum a: A, b: B, ..., x: X | if (a in A && b in B && ... && x in X) then IE(a, b, ..., x) else 0 }.
 * @param decls intexpr declarations
 * @param formula the formula body
 * @param currentDecl currently processed declaration; should be 0 initially
 * @param declConstraints the constraints implied by the declarations; should be Boolean.TRUE intially
 * @param values integer values computed so far
 */
private final void sum(Decls decls, IntExpression expr, int currentDecl, BooleanValue declConstraints,
		List<Int> values) {
	final BooleanFactory factory = interpreter.factory();
	if (decls.size()==currentDecl) {
		Int intExpr = expr.accept(this);
           Int newInt = intExpr.choice(declConstraints, factory.integer(0));
           values.add(newInt);
		return;
	}

	final Decl decl = decls.get(currentDecl);
	final BooleanMatrix declTransl = visit(decl);
	final BooleanMatrix groundValue = factory.matrix(declTransl.dimensions());
	env = env.extend(decl.variable(), decl.expression(), groundValue);
	for(IndexedEntry<BooleanValue> entry : declTransl) {
		groundValue.set(entry.index(), BooleanConstant.TRUE);
		sum(decls, expr, currentDecl+1, factory.and(entry.value(), declConstraints), values);
		groundValue.set(entry.index(), BooleanConstant.FALSE);	
	}
	env = env.parent();
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:34,代码来源:FOL2BoolTranslator.java

示例5: comprehension

import kodkod.ast.Decls; //导入方法依赖的package包/类
/**
 * Translates the given comprehension as follows 
 * (where A_0...A_|A| stand for boolean variables that represent the 
 * tuples of the expression A, etc.):
 * let comprehension = "{ a: A, b: B, ..., x: X | F(a, b, ..., x) }" |
 *     { a: A, b: B, ..., x: X | a in A && b in B && ... && x in X && F(a, b, ..., x) }.
 * @param decls the declarations comprehension
 * @param param formula the body of the comprehension
 * @param currentDecl currently processed declaration; should be 0 initially
 * @param declConstraints the constraints implied by the declarations; should be Boolean.TRUE intially
 * @param partialIndex partial index into the provided matrix; should be 0 initially
 * @param matrix boolean matrix that will retain the final results; should be an empty matrix of dimensions universe.size^decls.length initially
 * @ensures the given matrix contains the translation of the comprehension "{ decls | formula }"
 */
private final void comprehension(Decls decls, Formula formula, int currentDecl, 
		BooleanValue declConstraints, int partialIndex, BooleanMatrix matrix) {
	final BooleanFactory factory = interpreter.factory();

	if (currentDecl==decls.size()) {
		matrix.set(partialIndex, factory.and(declConstraints, formula.accept(this)));
		return;
	}

	final Decl decl = decls.get(currentDecl);
	final BooleanMatrix declTransl = visit(decl);
	final int position = (int)StrictMath.pow(interpreter.universe().size(), decls.size()-currentDecl-1);
	final BooleanMatrix groundValue = factory.matrix(declTransl.dimensions());
	env = env.extend(decl.variable(), groundValue);
	for(IndexedEntry<BooleanValue> entry : declTransl) {
		groundValue.set(entry.index(), BooleanConstant.TRUE);
		comprehension(decls, formula, currentDecl+1, factory.and(entry.value(), declConstraints), 
				partialIndex + entry.index()*position, matrix);
		groundValue.set(entry.index(), BooleanConstant.FALSE);	
	}
	env = env.parent();
}
 
开发者ID:emina,项目名称:kodkod,代码行数:37,代码来源:FOL2BoolTranslator.java

示例6: all

import kodkod.ast.Decls; //导入方法依赖的package包/类
/**
 * Translates the given universally quantified formula as follows 
 * (where A_0...A_|A| stand for boolean variables that represent the 
 * tuples of the expression A, etc.):
 * let quantFormula = "all a: A, b: B, ..., x: X | F(a, b, ..., x)" |
 *     (A_0 && B_0 && ... && X_0 => translate(F(A_0, B_0, ..., X_0))) && ... && 
 *     (A_|A| && B_|B| && ... && X_|X| => translate(F(A_|A|, B_|B|, ..., X_|X|))
 * @param decls formula declarations
 * @param formula the formula body
 * @param currentDecl currently processed declaration; should be 0 initially
 * @param declConstraints the constraints implied by the declarations; should be Boolean.FALSE intially
 * @param acc the accumulator that contains the top level conjunction; should be an empty AND accumulator initially
 * @ensures the given accumulator contains the translation of the formula "all decls | formula"
 */
private void all(Decls decls, Formula formula, int currentDecl, BooleanValue declConstraints, BooleanAccumulator acc) {
	if (acc.isShortCircuited()) return;
	final BooleanFactory factory = interpreter.factory();

	if (decls.size()==currentDecl) {
		acc.add(factory.or(declConstraints, formula.accept(this)));
		return;
	}

	final Decl decl = decls.get(currentDecl);
	final BooleanMatrix declTransl = visit(decl);
	final BooleanMatrix groundValue = factory.matrix(declTransl.dimensions());
	env = env.extend(decl.variable(), groundValue);
	for(IndexedEntry<BooleanValue> entry : declTransl) {
		groundValue.set(entry.index(), BooleanConstant.TRUE);
		all(decls, formula, currentDecl+1, factory.or(factory.not(entry.value()), declConstraints), acc);
		groundValue.set(entry.index(), BooleanConstant.FALSE);	
	}
	env = env.parent();
	
}
 
开发者ID:emina,项目名称:kodkod,代码行数:36,代码来源:FOL2BoolTranslator.java

示例7: some

import kodkod.ast.Decls; //导入方法依赖的package包/类
/**
 * Translates the given existentially quantified formula as follows 
 * (where A_0...A_|A| stand for boolean variables that represent the 
 * tuples of the expression A, etc.):
 * let quantFormula = "some a: A, b: B, ..., x: X | F(a, b, ..., x)" |
 *     (A_0 && B_0 && ... && X_0 && translate(F(A_0, B_0, ..., X_0))) || ... || 
 *     (A_|A| && B_|B| && ... && X_|X| && translate(F(A_|A|, B_|B|, ..., X_|X|))
 * @param decls formula declarations
 * @param formula the formula body
 * @param currentDecl currently processed declaration; should be 0 initially
 * @param declConstraints the constraints implied by the declarations; should be Boolean.TRUE intially
 * @param acc the accumulator that contains the top level conjunction; should be an empty OR accumulator initially
 * @ensures the given accumulator contains the translation of the formula "some decls | formula"
 */
private void some(Decls decls, Formula formula, int currentDecl, BooleanValue declConstraints, BooleanAccumulator acc) {
	if (acc.isShortCircuited()) return;
	final BooleanFactory factory = interpreter.factory();

	if (decls.size()==currentDecl) {
		acc.add(factory.and(declConstraints, formula.accept(this)));
		return;
	}

	final Decl decl = decls.get(currentDecl);
	final BooleanMatrix declTransl = visit(decl);
	final BooleanMatrix groundValue = factory.matrix(declTransl.dimensions());
	env = env.extend(decl.variable(), groundValue);
	for(IndexedEntry<BooleanValue> entry : declTransl) {
		groundValue.set(entry.index(), BooleanConstant.TRUE);
		some(decls, formula, currentDecl+1, factory.and(entry.value(), declConstraints), acc);
		groundValue.set(entry.index(), BooleanConstant.FALSE);	
	}
	env = env.parent();

}
 
开发者ID:emina,项目名称:kodkod,代码行数:36,代码来源:FOL2BoolTranslator.java

示例8: sum

import kodkod.ast.Decls; //导入方法依赖的package包/类
/**
 * Translates the given sum expression as follows 
 * (where A_0...A_|A| stand for boolean variables that represent the 
 * tuples of the expression A, etc.):
 * let sum = "sum a: A, b: B, ..., x: X | IE(a, b, ..., x) " |
 *     sum a: A, b: B, ..., x: X | if (a in A && b in B && ... && x in X) then IE(a, b, ..., x) else 0 }.
 * @param decls intexpr declarations
 * @param formula the formula body
 * @param currentDecl currently processed declaration; should be 0 initially
 * @param declConstraints the constraints implied by the declarations; should be Boolean.TRUE intially
 * @param values integer values computed so far
 */
private final void sum(Decls decls, IntExpression expr, int currentDecl, BooleanValue declConstraints,
		List<Int> values) {
	final BooleanFactory factory = interpreter.factory();
	if (decls.size()==currentDecl) {
		values.add( expr.accept(this).choice(declConstraints, factory.integer(0)) );
		return;
	}

	final Decl decl = decls.get(currentDecl);
	final BooleanMatrix declTransl = visit(decl);
	final BooleanMatrix groundValue = factory.matrix(declTransl.dimensions());
	env = env.extend(decl.variable(), groundValue);
	for(IndexedEntry<BooleanValue> entry : declTransl) {
		groundValue.set(entry.index(), BooleanConstant.TRUE);
		sum(decls, expr, currentDecl+1, factory.and(entry.value(), declConstraints), values);
		groundValue.set(entry.index(), BooleanConstant.FALSE);	
	}
	env = env.parent();
}
 
开发者ID:emina,项目名称:kodkod,代码行数:32,代码来源:FOL2BoolTranslator.java

示例9: all

import kodkod.ast.Decls; //导入方法依赖的package包/类
/**
 * Translates the given universally quantified formula as follows (where
 * A_0...A_|A| stand for boolean variables that represent the tuples of the
 * expression A, etc.): let quantFormula = "all a: A, b: B, ..., x: X | F(a,
 * b, ..., x)" | (A_0 && B_0 && ... && X_0 => translate(F(A_0, B_0, ...,
 * X_0))) && ... && (A_|A| && B_|B| && ... && X_|X| => translate(F(A_|A|,
 * B_|B|, ..., X_|X|))) If the noOverflow option is specified, then the
 * translation looks like: let quantFormula = "all a: A, b: B, ..., x: X |
 * F(a, b, ..., x)" | (A_0 && B_0 && ... && X_0 => (!of(F(A_0, B_0, ...,
 * X_0)) => translate(F(A_0, B_0, ..., X_0)))) && ... && (A_|A| && B_|B| &&
 * ... && X_|X| => (!of(F(A_|A|, B_|B|, ..., X_|X|)) => translate(F(A_|A|,
 * B_|B|, ..., X_|X|)))) where of(F(A_|a|, B_|b|, ..., X_|x|)) is the
 * portion of the overflow circuit generated by the translation of F(A_|a|,
 * B_|b|, ..., X_|x|) contributed by arithmetic operations over only the
 * integer variables of this quantifier
 *
 * @param decls formula declarations
 * @param formula the formula body
 * @param currentDecl currently processed declaration; should be 0 initially
 * @param declConstraints the constraints implied by the declarations;
 *            should be Boolean.FALSE initially
 * @param acc the accumulator that contains the top level conjunction;
 *            should be an empty AND accumulator initially
 * @ensures the given accumulator contains the translation of the formula
 *          "all decls | formula"
 */
private void all(Decls decls, Formula formula, int currentDecl, BooleanValue declConstraints,
		BooleanAccumulator acc) {
	if (acc.isShortCircuited())
		return;
	final BooleanFactory factory = interpreter.factory();

	if (decls.size() == currentDecl) {
		BooleanValue formulaCircuit = formula.accept(this);
		BooleanValue finalCircuit = factory.or(declConstraints, formulaCircuit);
		acc.add(finalCircuit);
		return;
	}

	final Decl decl = decls.get(currentDecl);
	final BooleanMatrix declTransl = visit(decl);
	final BooleanMatrix groundValue = factory.matrix(declTransl.dimensions());
	env = env.extend(decl.variable(), decl.expression(), groundValue, Quantifier.ALL);
	for (IndexedEntry<BooleanValue> entry : declTransl) {
		groundValue.set(entry.index(), BooleanConstant.TRUE);
		all(decls, formula, currentDecl + 1, factory.or(factory.not(entry.value()), declConstraints), acc);
		groundValue.set(entry.index(), BooleanConstant.FALSE);
	}
	env = env.parent();
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:51,代码来源:FOL2BoolTranslator.java

示例10: some

import kodkod.ast.Decls; //导入方法依赖的package包/类
/**
 * Translates the given existentially quantified formula as follows (where
 * A_0...A_|A| stand for boolean variables that represent the tuples of the
 * expression A, etc.): let quantFormula = "some a: A, b: B, ..., x: X |
 * F(a, b, ..., x)" | (A_0 && B_0 && ... && X_0 && translate(F(A_0, B_0,
 * ..., X_0))) || ... || (A_|A| && B_|B| && ... && X_|X| &&
 * translate(F(A_|A|, B_|B|, ..., X_|X|)) If the noOverflow option is
 * specified, then the translation looks like: let quantFormula = "some a:
 * A, b: B, ..., x: X | F(a, b, ..., x)" | (A_0 && B_0 && ... && X_0 &&
 * !of(F(A_0, B_0, ..., X_0)) && translate(F(A_0, B_0, ..., X_0))) || ... ||
 * (A_|A| && B_|B| && ... && X_|X| && !of(F(A_|A|, B_|B|, ..., X_|X|)) &&
 * translate(F(A_|A|, B_|B|, ..., X_|X|)) where of(F(A_|a|, B_|b|, ...,
 * X_|x|)) is the portion of the overflow circuit generated by the
 * translation of F(A_|a|, B_|b|, ..., X_|x|) contributed by arithmetic
 * operations over only the integer variables of this quantifier
 *
 * @param decls formula declarations
 * @param formula the formula body
 * @param currentDecl currently processed declaration; should be 0 initially
 * @param declConstraints the constraints implied by the declarations;
 *            should be Boolean.TRUE intially
 * @param acc the accumulator that contains the top level conjunction;
 *            should be an empty OR accumulator initially
 * @ensures the given accumulator contains the translation of the formula
 *          "some decls | formula"
 */
private void some(Decls decls, Formula formula, int currentDecl, BooleanValue declConstraints,
		BooleanAccumulator acc) {
	if (acc.isShortCircuited())
		return;
	final BooleanFactory factory = interpreter.factory();

	if (decls.size() == currentDecl) {
		BooleanValue formulaCircuit = formula.accept(this);
		BooleanValue finalCircuit = factory.and(declConstraints, formulaCircuit);
		acc.add(finalCircuit);
		return;
	}

	final Decl decl = decls.get(currentDecl);
	final BooleanMatrix declTransl = visit(decl);
	final BooleanMatrix groundValue = factory.matrix(declTransl.dimensions());
	env = env.extend(decl.variable(), decl.expression(), groundValue, Quantifier.SOME);
	for (IndexedEntry<BooleanValue> entry : declTransl) {
		groundValue.set(entry.index(), BooleanConstant.TRUE);
		some(decls, formula, currentDecl + 1, factory.and(entry.value(), declConstraints), acc);
		groundValue.set(entry.index(), BooleanConstant.FALSE);
	}
	env = env.parent();
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:51,代码来源:FOL2BoolTranslator.java

示例11: all

import kodkod.ast.Decls; //导入方法依赖的package包/类
/**
 * Translates the given universally quantified formula as follows 
 * (where A_0...A_|A| stand for boolean variables that represent the 
 * tuples of the expression A, etc.):
 * 
 * let quantFormula = "all a: A, b: B, ..., x: X | F(a, b, ..., x)" |
 *     (A_0 && B_0 && ... && X_0 => translate(F(A_0, B_0, ..., X_0))) && ... && 
 *     (A_|A| && B_|B| && ... && X_|X| => translate(F(A_|A|, B_|B|, ..., X_|X|)))
 * 
 * If the noOverflow option is specified, then the translation looks like:
 * 
 * let quantFormula = "all a: A, b: B, ..., x: X | F(a, b, ..., x)" |
    *     (A_0 && B_0 && ... && X_0 => (!of(F(A_0, B_0, ..., X_0)) => translate(F(A_0, B_0, ..., X_0)))) && ... && 
    *     (A_|A| && B_|B| && ... && X_|X| => (!of(F(A_|A|, B_|B|, ..., X_|X|)) => translate(F(A_|A|, B_|B|, ..., X_|X|))))
 * 
 * where of(F(A_|a|, B_|b|, ..., X_|x|)) is the portion of the overflow circuit generated by the translation of 
 * F(A_|a|, B_|b|, ..., X_|x|) contributed by arithmetic operations over only the integer variables of this quantifier 
 * 
 * @param decls formula declarations
 * @param formula the formula body
 * @param currentDecl currently processed declaration; should be 0 initially
 * @param declConstraints the constraints implied by the declarations; should be Boolean.FALSE initially
 * @param acc the accumulator that contains the top level conjunction; should be an empty AND accumulator initially
 * @ensures the given accumulator contains the translation of the formula "all decls | formula"
 */
private void all(Decls decls, Formula formula, int currentDecl, BooleanValue declConstraints, BooleanAccumulator acc) {
	if (acc.isShortCircuited()) return;
	final BooleanFactory factory = interpreter.factory();

	if (decls.size()==currentDecl) {
	    BooleanValue formulaCircuit = formula.accept(this);
           BooleanValue finalCircuit = factory.or(declConstraints, formulaCircuit);
           acc.add(finalCircuit);
		return;
	}

	final Decl decl = decls.get(currentDecl);
	final BooleanMatrix declTransl = visit(decl);
	final BooleanMatrix groundValue = factory.matrix(declTransl.dimensions());
	env = env.extend(decl.variable(), decl.expression(), groundValue, Quantifier.ALL);
	for(IndexedEntry<BooleanValue> entry : declTransl) {
	    groundValue.set(entry.index(), BooleanConstant.TRUE);
		all(decls, formula, currentDecl+1, factory.or(factory.not(entry.value()), declConstraints), acc);
		groundValue.set(entry.index(), BooleanConstant.FALSE);
	}
	env = env.parent();	
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:48,代码来源:FOL2BoolTranslator.java

示例12: some

import kodkod.ast.Decls; //导入方法依赖的package包/类
/**
 * Translates the given existentially quantified formula as follows 
 * (where A_0...A_|A| stand for boolean variables that represent the 
 * tuples of the expression A, etc.):
 * 
 * let quantFormula = "some a: A, b: B, ..., x: X | F(a, b, ..., x)" |
 *     (A_0 && B_0 && ... && X_0 && translate(F(A_0, B_0, ..., X_0))) || ... || 
 *     (A_|A| && B_|B| && ... && X_|X| && translate(F(A_|A|, B_|B|, ..., X_|X|))
 * 
 * If the noOverflow option is specified, then the translation looks like:
    * 
    * let quantFormula = "some a: A, b: B, ..., x: X | F(a, b, ..., x)" |
    *     (A_0 && B_0 && ... && X_0 && !of(F(A_0, B_0, ..., X_0)) && translate(F(A_0, B_0, ..., X_0))) || ... || 
    *     (A_|A| && B_|B| && ... && X_|X| && !of(F(A_|A|, B_|B|, ..., X_|X|)) && translate(F(A_|A|, B_|B|, ..., X_|X|))
    *     
 * where of(F(A_|a|, B_|b|, ..., X_|x|)) is the portion of the overflow circuit generated by the translation of 
    * F(A_|a|, B_|b|, ..., X_|x|) contributed by arithmetic operations over only the integer variables of this quantifier
    * 
 * @param decls formula declarations
 * @param formula the formula body
 * @param currentDecl currently processed declaration; should be 0 initially
 * @param declConstraints the constraints implied by the declarations; should be Boolean.TRUE intially
 * @param acc the accumulator that contains the top level conjunction; should be an empty OR accumulator initially
 * @ensures the given accumulator contains the translation of the formula "some decls | formula"
 */
private void some(Decls decls, Formula formula, int currentDecl, BooleanValue declConstraints, BooleanAccumulator acc) {
	if (acc.isShortCircuited()) return;
	final BooleanFactory factory = interpreter.factory();

	if (decls.size()==currentDecl) {
		BooleanValue formulaCircuit = formula.accept(this);
           BooleanValue finalCircuit = factory.and(declConstraints, formulaCircuit);
           acc.add(finalCircuit);
           return;
	}

	final Decl decl = decls.get(currentDecl);
	final BooleanMatrix declTransl = visit(decl);
	final BooleanMatrix groundValue = factory.matrix(declTransl.dimensions());
	env = env.extend(decl.variable(), decl.expression(), groundValue, Quantifier.SOME);
	for(IndexedEntry<BooleanValue> entry : declTransl) {
		groundValue.set(entry.index(), BooleanConstant.TRUE);
		some(decls, formula, currentDecl+1, factory.and(entry.value(), declConstraints), acc);
		groundValue.set(entry.index(), BooleanConstant.FALSE);	
	}
	env = env.parent();
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:48,代码来源:FOL2BoolTranslator.java


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