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


Java Node类代码示例

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


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

示例1: FileLog

import kodkod.ast.Node; //导入依赖的package包/类
/**
 * Constructs a new file log for the sources of the given annotated formula,
 * using the provided fixed map, file, and tuplefactory.
 * @requires all f: annotated.node.*children & Formula | logMap.get(f) = freeVariables(f)
 * @requires the file was written by a FileLogger using the given map
 */
FileLog(AnnotatedNode<Formula> annotated, FixedMap<Formula, Variable[]> logMap, File file, Bounds bounds) {
	this.file = file;
	this.bounds = bounds;
	this.roots = Nodes.conjuncts(annotated.node());
	
	final int size = logMap.entrySet().size();
	this.original = new Node[size];
	this.translated = new Formula[size];
	this.freeVars = new Variable[size][];
	int index = 0;
	for(Map.Entry<Formula, Variable[]> e : logMap.entrySet()) {
		translated[index] = e.getKey();
		original[index] = annotated.sourceOf(e.getKey());
		freeVars[index] = e.getValue();
		index++;
	}
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:24,代码来源:FileLogger.java

示例2: NodePruner

import kodkod.ast.Node; //导入依赖的package包/类
/**
 * Constructs a proof finder for the given log.
 * 
 * @ensures this.log' = log
 */
NodePruner(TranslationLog log) {
	visited = new IdentityHashSet<Node>();
	relevant = new IdentityHashSet<Node>();

	final RecordFilter filter = new RecordFilter() {
		public boolean accept(Node node, Formula translated, int literal, Map<Variable,TupleSet> env) {
			return env.isEmpty();
		}
	};

	constNodes = new LinkedHashMap<Formula,Boolean>();
	for (Iterator<TranslationRecord> itr = log.replay(filter); itr.hasNext();) {
		TranslationRecord rec = itr.next();
		int lit = rec.literal();
		if (Math.abs(lit) != Integer.MAX_VALUE) {
			constNodes.remove(rec.translated());
		} else if (lit == Integer.MAX_VALUE) {
			constNodes.put(rec.translated(), Boolean.TRUE);
		} else {
			constNodes.put(rec.translated(), Boolean.FALSE);
		}
	}
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:29,代码来源:TrivialProof.java

示例3: toNNF

import kodkod.ast.Node; //导入依赖的package包/类
public static AnnotatedNode<Formula> toNNF(AnnotatedNode<Formula> annotated, Reporter reporter) {
	if (reporter != null)
		reporter.convertingToNNF();
	final FullNegationPropagator flat = new FullNegationPropagator(annotated.sharedNodes());
	annotated.node().accept(flat);
	final List<Formula> roots = new ArrayList<Formula>(flat.annotations.size());
	roots.addAll(flat.annotations.keySet());
	for (Iterator<Map.Entry<Formula,Node>> itr = flat.annotations.entrySet().iterator(); itr.hasNext();) {
		final Map.Entry<Formula,Node> entry = itr.next();
		final Node source = annotated.sourceOf(entry.getValue());
		if (entry.getKey() == source) {
			itr.remove();
			/* TODO: what is this for? */ } else {
			entry.setValue(source);
		}
	}
	return AnnotatedNode.annotate(Formula.and(flat.conjuncts), flat.annotations);
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:19,代码来源:FullNegationPropagator.java

示例4: FileLog

import kodkod.ast.Node; //导入依赖的package包/类
/**
 * Constructs a new file log for the sources of the given annotated
 * formula, using the provided fixed map, file, and tuplefactory.
 * 
 * @requires all f: annotated.node.*children & Formula | logMap.get(f) =
 *           freeVariables(f)
 * @requires the file was written by a FileLogger using the given map
 */
FileLog(AnnotatedNode<Formula> annotated, FixedMap<Formula,Variable[]> logMap, File file, Bounds bounds) {
	this.file = file;
	this.bounds = bounds;
	this.roots = Nodes.conjuncts(annotated.node());

	final int size = logMap.entrySet().size();
	this.original = new Node[size];
	this.translated = new Formula[size];
	this.freeVars = new Variable[size][];
	int index = 0;
	for (Map.Entry<Formula,Variable[]> e : logMap.entrySet()) {
		translated[index] = e.getKey();
		original[index] = annotated.sourceOf(e.getKey());
		freeVars[index] = e.getValue();
		index++;
	}
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:26,代码来源:FileLogger.java

示例5: visited

import kodkod.ast.Node; //导入依赖的package包/类
/**
 * Returns true if n has already been visited with the current value of the
 * negated flag; otherwise returns false.
 * @ensures records that n is being visited with the current value of the negated flag
 * @return true if n has already been visited with the current value of the
 * negated flag; otherwise returns false.
 */
@Override
protected final boolean visited(Node n) {
	if (sharedNodes.contains(n)) {
		if (!visited.containsKey(n)) { // first visit
			visited.put(n, Boolean.valueOf(negated));
			return false;
		} else {
			final Boolean visit = visited.get(n);
			if (visit==null || visit==negated) { // already visited with same negated value
				return true; 
			} else { // already visited with different negated value
				visited.put(n, null);
				return false;
			}
		}
	}
	return false;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:26,代码来源:AnnotatedNode.java

示例6: toPNF

import kodkod.ast.Node; //导入依赖的package包/类
public static AnnotatedNode<Formula> toPNF(AnnotatedNode<Formula> annotated) {
	final PrenexNFConverter pnfConv = new PrenexNFConverter(annotated.sharedNodes());
	List<Formula> conj = new ArrayList<Formula>();
	for (Formula f : Nodes.allConjuncts(annotated.node(), null))
		conj.add(f.accept(pnfConv));
	Formula ans = Formula.and(conj);

	final List<Formula> roots = new ArrayList<Formula>(pnfConv.annotations.size());
	roots.addAll(pnfConv.annotations.keySet());
	for (Iterator<Map.Entry<Formula,Node>> itr = pnfConv.annotations.entrySet().iterator(); itr.hasNext();) {
		final Map.Entry<Formula,Node> entry = itr.next();
		final Node source = annotated.sourceOf(entry.getValue());
		if (entry.getKey() == source) {
			itr.remove();
		} else {
			entry.setValue(source);
		}
	}

	return AnnotatedNode.annotate(ans, pnfConv.annotations);
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:22,代码来源:PrenexNFConverter.java

示例7: apply

import kodkod.ast.Node; //导入依赖的package包/类
/**
 * Returns the result of applying this visitor to the given annotated
 * formula.
 * 
 * @return the result of applying this visitor to the given annotated
 *         formula.
 */
final AnnotatedNode<Formula> apply(AnnotatedNode<Formula> annotated) {
	annotated.node().accept(this);
	final List<Formula> roots = new ArrayList<Formula>(conjuncts.size());
	roots.addAll(conjuncts.keySet());
	for (Iterator<Map.Entry<Formula,Node>> itr = conjuncts.entrySet().iterator(); itr.hasNext();) {
		final Map.Entry<Formula,Node> entry = itr.next();
		final Node source = annotated.sourceOf(entry.getValue());
		if (entry.getKey() == source) {
			itr.remove();
		} else {
			entry.setValue(source);
		}
	}
	return AnnotatedNode.annotate(Formula.and(roots), conjuncts);
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:23,代码来源:FormulaFlattener.java

示例8: visit

import kodkod.ast.Node; //导入依赖的package包/类
/**
 * Calls nf.formula.accept(this) after flipping the negation flag.
 * 
 * @see kodkod.ast.visitor.AbstractVoidVisitor#visit(kodkod.ast.NotFormula)
 */
public final void visit(NotFormula nf) {
	if (visited(nf))
		return;

	final Map<Formula,Node> oldConjuncts = conjuncts;
	conjuncts = new LinkedHashMap<Formula,Node>();
	negated = !negated;
	nf.formula().accept(this);
	negated = !negated;
	if (conjuncts.size() > 1) { // was broken down further
		oldConjuncts.putAll(conjuncts);
		conjuncts = oldConjuncts;
	} else { // wasn't broken down further
		conjuncts = oldConjuncts;
		conjuncts.put(negated ? nf.formula() : nf, nf);
	}
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:23,代码来源:FormulaFlattener.java

示例9: highLevelCore

import kodkod.ast.Node; //导入依赖的package包/类
/**
 * {@inheritDoc}
 * @see kodkod.engine.Proof#highLevelCore()
 */
public final Map<Formula, Node> highLevelCore() {
	if (coreRoots == null) { 
		final RecordFilter unitFilter = new RecordFilter() {
			final IntSet coreUnits = StrategyUtils.coreUnits(solver.proof());
			final Set<Formula> roots = log().roots();
			public boolean accept(Node node, Formula translated, int literal, Map<Variable, TupleSet> env) {
				return roots.contains(translated) && coreUnits.contains(Math.abs(literal));
			}
			
		};
		coreRoots = new LinkedHashMap<Formula, Node>();
		final IntSet seenUnits = new IntTreeSet();
		for(Iterator<TranslationRecord> itr = log().replay(unitFilter); itr.hasNext(); ) {
			// it is possible that two top-level formulas have identical meaning,
			// and are represented with the same core unit; in that case, we want only
			// one of them in the core.
			final TranslationRecord rec = itr.next();
			if (seenUnits.add(rec.literal())) {
				coreRoots.put(rec.translated(), rec.node());
			}  
		}
		coreRoots = Collections.unmodifiableMap(coreRoots);
	}
	return coreRoots;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:30,代码来源:ResolutionBasedProof.java

示例10: visit

import kodkod.ast.Node; //导入依赖的package包/类
/**
 * Visits the given comprehension, quantified formula, or sum
 * expression. The method returns TRUE if the creator body contains any
 * variable not bound by the decls; otherwise returns FALSE.
 */
private Boolean visit(Node creator, Decls decls, Node body) {
	Boolean ret = lookup(creator);
	if (ret != null)
		return ret;
	boolean retVal = false;
	for (Decl decl : decls) {
		retVal = decl.expression().accept(this) || retVal;
		varsInScope.push(decl.variable());
	}
	retVal = ((Boolean) body.accept(this)) || retVal;
	for (int i = decls.size(); i > 0; i--) {
		varsInScope.pop();
	}
	return cache(creator, retVal);
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:21,代码来源:AnnotatedNode.java

示例11: visited

import kodkod.ast.Node; //导入依赖的package包/类
/**
 * Returns true if n has already been visited with the current value of
 * the negated flag; otherwise returns false.
 * 
 * @ensures records that n is being visited with the current value of
 *          the negated flag
 * @return true if n has already been visited with the current value of
 *         the negated flag; otherwise returns false.
 */
@Override
protected final boolean visited(Node n) {
	if (sharedNodes.contains(n)) {
		if (!visited.containsKey(n)) { // first visit
			visited.put(n, Boolean.valueOf(negated));
			return false;
		} else {
			final Boolean visit = visited.get(n);
			if (visit == null || visit == negated) { // already visited
														// with same
														// negated value
				return true;
			} else { // already visited with different negated value
				visited.put(n, null);
				return false;
			}
		}
	}
	return false;
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:30,代码来源:AnnotatedNode.java

示例12: edge

import kodkod.ast.Node; //导入依赖的package包/类
private void edge(Node n1, Node n2) { 
	if (n2 instanceof LeafExpression || n2 instanceof ConstantFormula || n2 instanceof IntConstant) {
		
	}
	graph.append(id(n1));
	graph.append("->");
	graph.append(id(n2));
	graph.append(";\n");
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:10,代码来源:PrettyPrinter.java

示例13: apply

import kodkod.ast.Node; //导入依赖的package包/类
static String apply(Node node) { 
	final Dotifier dot = new Dotifier();
	dot.graph.append("digraph {\n");
	node.accept(dot);
	dot.graph.append("}");
	return dot.graph.toString();
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:8,代码来源:PrettyPrinter.java

示例14: highLevelCore

import kodkod.ast.Node; //导入依赖的package包/类
/**
 * {@inheritDoc}
 * 
 * @see kodkod.engine.Proof#highLevelCore()
 */
public final Map<Formula,Node> highLevelCore() {
	if (coreRoots == null) {
		final RecordFilter unitFilter = new RecordFilter() {
			final IntSet		coreUnits	= StrategyUtils.coreUnits(solver.proof());
			final Set<Formula>	roots		= log().roots();

			public boolean accept(Node node, Formula translated, int literal, Map<Variable,TupleSet> env) {
				return roots.contains(translated) && coreUnits.contains(Math.abs(literal));
			}

		};
		coreRoots = new LinkedHashMap<Formula,Node>();
		final IntSet seenUnits = new IntTreeSet();
		for (Iterator<TranslationRecord> itr = log().replay(unitFilter); itr.hasNext();) {
			// it is possible that two top-level formulas have identical
			// meaning,
			// and are represented with the same core unit; in that case, we
			// want only
			// one of them in the core.
			final TranslationRecord rec = itr.next();
			if (seenUnits.add(rec.literal())) {
				coreRoots.put(rec.translated(), rec.node());
			}
		}
		coreRoots = Collections.unmodifiableMap(coreRoots);
	}
	return coreRoots;
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:34,代码来源:ResolutionBasedProof.java

示例15: highLevelCore

import kodkod.ast.Node; //导入依赖的package包/类
/**
 * {@inheritDoc}
 * 
 * @see kodkod.engine.Proof#highLevelCore()
 */
public final Map<Formula,Node> highLevelCore() {
	if (coreRoots == null) {
		final Iterator<TranslationRecord> itr = core();
		final Set<Formula> roots = log().roots();
		coreRoots = new LinkedHashMap<Formula,Node>();
		while (itr.hasNext()) {
			TranslationRecord rec = itr.next();
			if (roots.contains(rec.translated()))
				coreRoots.put(rec.translated(), rec.node());
		}
		coreRoots = Collections.unmodifiableMap(coreRoots);
	}
	return coreRoots;
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:20,代码来源:TrivialProof.java


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