• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Node类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: inlinePredicates

import kodkod.ast.Node; //导入依赖的package包/类
/**
 * Returns an annotated formula f such that f.node is equivalent to
 * annotated.node with its <tt>simplified</tt> predicates replaced with
 * their corresponding Formulas and the remaining predicates replaced with
 * equivalent constraints. The annotated formula f will contain transitive
 * source information for each of the subformulas of f.node. Specifically,
 * let t be a subformula of f.node, and s be a descdendent of annotated.node
 * from which t was derived. Then, f.source[t] = annotated.source[s].
 * </p>
 * 
 * @requires simplified.keySet() in
 *           annotated.predicates()[RelationPredicate.NAME]
 * @requires no disj p, p': simplified.keySet() | simplified.get(p) =
 *           simplifed.get(p') // this must hold in order to maintain the
 *           invariant that each subformula of the returned formula has
 *           exactly one source
 * @requires for each p in simplified.keySet(), the formulas "p and
 *           [[this.bounds]]" and "simplified.get(p) and [[this.bounds]]"
 *           are equisatisfiable
 * @return an annotated formula f such that f.node is equivalent to
 *         annotated.node with its <tt>simplified</tt> predicates replaced
 *         with their corresponding Formulas and the remaining predicates
 *         replaced with equivalent constraints.
 */
private AnnotatedNode<Formula> inlinePredicates(final AnnotatedNode<Formula> annotated,
		final Map<RelationPredicate,Formula> simplified) {
	final Map<Node,Node> sources = new IdentityHashMap<Node,Node>();
	final AbstractReplacer inliner = new AbstractReplacer(annotated.sharedNodes()) {
		private RelationPredicate source = null;

		protected <N extends Node> N cache(N node, N replacement) {
			if (replacement instanceof Formula) {
				if (source == null) {
					final Node nsource = annotated.sourceOf(node);
					if (replacement != nsource)
						sources.put(replacement, nsource);
				} else {
					sources.put(replacement, source);
				}
			}
			return super.cache(node, replacement);
		}

		public Formula visit(RelationPredicate pred) {
			Formula ret = lookup(pred);
			if (ret != null)
				return ret;
			source = pred;
			if (simplified.containsKey(pred)) {
				ret = simplified.get(pred).accept(this);
			} else {
				ret = pred.toConstraints().accept(this);
			}
			source = null;
			return cache(pred, ret);
		}
	};

	return annotate(annotated.node().accept(inliner), sources);
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:61,代码来源:Translator.java


示例17: visit

import kodkod.ast.Node; //导入依赖的package包/类
private void visit(Node parent, Object label, Iterator<? extends Node> children) {
	if (visited(parent)) return;
	node(parent, label.toString());
	while(children.hasNext()) {
		Node child = children.next();
		child.accept(this);
		edge(parent, child);
	}
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:10,代码来源:PrettyPrinter.java


示例18: cache

import kodkod.ast.Node; //导入依赖的package包/类
/**
 * Caches the given replacement for the specified node, if 
 * the node is a syntactically shared expression, int expression or declaration with
 * no free variables.  Otherwise does nothing.  The method returns
 * the replacement node.  
 * @return replacement
 */
@Override
protected final <N extends Node> N cache(N node, N replacement) {
	if (cache.containsKey(node)) {
		cache.put(node, replacement);
	}
	return replacement;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:15,代码来源:Skolemizer.java


示例19: visit

import kodkod.ast.Node; //导入依赖的package包/类
/**
 * {@inheritDoc}
 * @see kodkod.ast.visitor.AbstractVoidVisitor#visit(kodkod.ast.QuantifiedFormula)
 */
public final void visit(QuantifiedFormula qf) {
	if (visited(qf)) return;
	
	if (breakupQuantifiers) {
		
		final Quantifier quant = qf.quantifier();
		
		if ((!negated && quant==ALL) || (negated && quant==SOME)) { // may break down further
			final Map<Formula, Node> oldConjuncts = conjuncts;
			conjuncts = new LinkedHashMap<Formula, Node>();
			qf.formula().accept(this);
			if (conjuncts.size()>1) { // was broken down further
				final Decls decls = qf.decls();
				for(Map.Entry<Formula, Node> entry : conjuncts.entrySet()) { 
					oldConjuncts.put(entry.getKey().forAll(decls), entry.getValue());
				}
				conjuncts = oldConjuncts;
				return;
			} else { // wasn't broken down further
				conjuncts = oldConjuncts;
			}
		} // won't break down further
	} 

	addConjunct(qf);
	
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:32,代码来源:FormulaFlattener.java


示例20: FOL2BoolCache

import kodkod.ast.Node; //导入依赖的package包/类
/**
 * Constructs a new translation cache for the given annotated node.
 * @ensures this.node' = annotated.node 
 */
FOL2BoolCache(AnnotatedNode<? extends Node> annotated) {
	final CacheCollector collector = new CacheCollector(annotated.sharedNodes());
	annotated.node().accept(collector);

	this.cache = new IdentityHashMap<Node, Record>(collector.cache().size());
	for(Map.Entry<Node, Set<Variable>> e :  collector.cache().entrySet()) {
		Set<Variable> freeVars = e.getValue();
		if (freeVars.isEmpty())
			this.cache.put(e.getKey(), new NoVarRecord());
		else 
			this.cache.put(e.getKey(), new MultiVarRecord(freeVars));
	}
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:18,代码来源:FOL2BoolCache.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IWorkingSetSelectionDialog类代码示例发布时间:2022-05-22
下一篇:
Java Kernel类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap