本文整理汇总了Java中kodkod.ast.RelationPredicate类的典型用法代码示例。如果您正苦于以下问题:Java RelationPredicate类的具体用法?Java RelationPredicate怎么用?Java RelationPredicate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RelationPredicate类属于kodkod.ast包,在下文中一共展示了RelationPredicate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visit
import kodkod.ast.RelationPredicate; //导入依赖的package包/类
/**
* Visits the children of the predicate if this.visited(pred) returns false.
* Otherwise does nothing.
*
* @ensures pred.relation.accept(this) && (pred.name = FUNCTION =>
* pred.domain.accept(this) && pred.range.accept(this)) &&
* (pred.name = TOTAL_ORDERING => pred.ordered.accept(this) &&
* pred.first.accept(this) && pred.last.accept(this) )
*/
public void visit(RelationPredicate pred) {
if (visited(pred))
return;
pred.relation().accept(this);
if (pred.name() == RelationPredicate.Name.FUNCTION) {
final RelationPredicate.Function fp = (RelationPredicate.Function) pred;
fp.domain().accept(this);
fp.range().accept(this);
} else if (pred.name() == RelationPredicate.Name.TOTAL_ORDERING) {
final RelationPredicate.TotalOrdering tp = (RelationPredicate.TotalOrdering) pred;
tp.ordered().accept(this);
tp.first().accept(this);
tp.last().accept(this);
}
}
示例2: visit
import kodkod.ast.RelationPredicate; //导入依赖的package包/类
/**
* Calls lookup(predicate) and returns the cached value, if any. If no
* cached value exists, visits each child, caches the disjunction of the
* children's return values and returns it.
*
* @return let x = lookup(predicate) | x != null => x, cache(predicate, some
* n: predicate.children | n.accept(this))
*/
public Set<T> visit(RelationPredicate pred) {
Set<T> ret = lookup(pred);
if (ret != null)
return ret;
ret = newSet();
ret.addAll(pred.relation().accept(this));
switch (pred.name()) {
case ACYCLIC :
break;
case FUNCTION :
final RelationPredicate.Function fp = (RelationPredicate.Function) pred;
ret.addAll(fp.domain().accept(this));
ret.addAll(fp.range().accept(this));
break;
case TOTAL_ORDERING :
final RelationPredicate.TotalOrdering tp = (RelationPredicate.TotalOrdering) pred;
ret.addAll(tp.ordered().accept(this));
ret.addAll(tp.first().accept(this));
ret.addAll(tp.last().accept(this));
break;
default :
throw new IllegalArgumentException("unknown relation predicate: " + pred.name());
}
return cache(pred, ret);
}
示例3: visit
import kodkod.ast.RelationPredicate; //导入依赖的package包/类
/**
* Calls lookup(predicate) and returns the cached value, if any. If no
* cached value exists, visits each child, caches the disjunction of the
* children's return values and returns it.
*
* @return let x = lookup(predicate) | x != null => x, cache(predicate, some
* n: predicate.children | n.accept(this))
*/
public Boolean visit(RelationPredicate predicate) {
final Boolean ret = lookup(predicate);
if (ret != null)
return ret;
if (predicate.relation().accept(this))
return cache(predicate, true);
if (predicate.name() == RelationPredicate.Name.FUNCTION) {
final RelationPredicate.Function fp = (RelationPredicate.Function) predicate;
return cache(predicate, fp.domain().accept(this) || fp.range().accept(this));
} else if (predicate.name() == RelationPredicate.Name.TOTAL_ORDERING) {
final RelationPredicate.TotalOrdering tp = (RelationPredicate.TotalOrdering) predicate;
return cache(predicate, tp.ordered().accept(this) || tp.first().accept(this) || tp.last().accept(this));
}
return cache(predicate, false);
}
示例4: visit
import kodkod.ast.RelationPredicate; //导入依赖的package包/类
public Boolean visit(RelationPredicate pred) {
Boolean ans = get(pred);
if (ans != null)
return ans;
pred.relation().accept(this);
if (pred.name() == RelationPredicate.Name.FUNCTION) {
final RelationPredicate.Function fp = (RelationPredicate.Function) pred;
fp.domain().accept(this);
fp.range().accept(this);
} else if (pred.name() == RelationPredicate.Name.TOTAL_ORDERING) {
final RelationPredicate.TotalOrdering tp = (RelationPredicate.TotalOrdering) pred;
tp.ordered().accept(this);
tp.first().accept(this);
tp.last().accept(this);
}
return noHOL(pred);
}
示例5: visit
import kodkod.ast.RelationPredicate; //导入依赖的package包/类
/**
* Calls lookup(predicate) and returns the cached value, if any.
* If no cached value exists, visits each child, caches the
* disjunction of the children's return values and returns it.
* @return let x = lookup(predicate) |
* x != null => x,
* cache(predicate, some n: predicate.children | n.accept(this))
*/
public Set<T> visit(RelationPredicate pred) {
Set<T> ret = lookup(pred);
if (ret!=null) return ret;
ret = newSet();
ret.addAll(pred.relation().accept(this));
switch(pred.name()) {
case ACYCLIC :
break;
case FUNCTION :
final RelationPredicate.Function fp = (RelationPredicate.Function) pred;
ret.addAll(fp.domain().accept(this));
ret.addAll(fp.range().accept(this));
break;
case TOTAL_ORDERING :
final RelationPredicate.TotalOrdering tp = (RelationPredicate.TotalOrdering) pred;
ret.addAll(tp.ordered().accept(this));
ret.addAll(tp.first().accept(this));
ret.addAll(tp.last().accept(this));
break;
default :
throw new IllegalArgumentException("unknown relation predicate: " + pred.name());
}
return cache(pred,ret);
}
示例6: visit
import kodkod.ast.RelationPredicate; //导入依赖的package包/类
/**
* Calls lookup(pred) and returns the cached value, if any. If a replacement
* has not been cached, visits the formula's children. If nothing changes,
* the argument is cached and returned, otherwise a replacement formula is
* cached and returned.
*
* @return { p: RelationPredicate | p.name = pred.name && p.relation =
* pred.relation.accept(delegate) && p.name = FUNCTION =>
* p.targetMult = pred.targetMult && p.domain =
* pred.domain.accept(delegate) && p.range =
* pred.range.accept(delegate), p.name = TOTAL_ORDERING => p.ordered
* = pred.ordered.accept(delegate) && p.first =
* pred.first.accept(delegate) && p.last =
* pred.last.accept(delegate) }
*/
public Formula visit(RelationPredicate pred) {
Formula ret = lookup(pred);
if (ret != null)
return ret;
final Relation r = (Relation) pred.relation().accept(delegate);
switch (pred.name()) {
case ACYCLIC :
ret = (r == pred.relation()) ? pred : r.acyclic();
break;
case FUNCTION :
final RelationPredicate.Function fp = (RelationPredicate.Function) pred;
final Expression domain = fp.domain().accept(delegate);
final Expression range = fp.range().accept(delegate);
ret = (r == fp.relation() && domain == fp.domain() && range == fp.range()) ? fp
: (fp.targetMult() == Multiplicity.ONE ? r.function(domain, range)
: r.partialFunction(domain, range));
break;
case TOTAL_ORDERING :
final RelationPredicate.TotalOrdering tp = (RelationPredicate.TotalOrdering) pred;
final Relation ordered = (Relation) tp.ordered().accept(delegate);
final Relation first = (Relation) tp.first().accept(delegate);
final Relation last = (Relation) tp.last().accept(delegate);
ret = (r == tp.relation() && ordered == tp.ordered() && first == tp.first() && last == tp.last()) ? tp
: r.totalOrder(ordered, first, last);
break;
default :
throw new IllegalArgumentException("unknown relation predicate: " + pred.name());
}
return cache(pred, ret);
}
示例7: inlinePredicates
import kodkod.ast.RelationPredicate; //导入依赖的package包/类
/**
* Returns an annotated formula f such that f.node is equivalent to
* annotated.node with its <tt>truePreds</tt> replaced with the constant
* formula TRUE and the remaining predicates replaced with equivalent
* constraints.
*
* @requires truePreds in annotated.predicates()[RelationnPredicate.NAME]
* @requires truePreds are trivially true with respect to this.bounds
* @return an annotated formula f such that f.node is equivalent to
* annotated.node with its <tt>truePreds</tt> replaced with the
* constant formula TRUE and the remaining predicates replaced with
* equivalent constraints.
*/
private AnnotatedNode<Formula> inlinePredicates(final AnnotatedNode<Formula> annotated,
final Set<RelationPredicate> truePreds) {
final AbstractReplacer inliner = new AbstractReplacer(annotated.sharedNodes()) {
public Formula visit(RelationPredicate pred) {
Formula ret = lookup(pred);
if (ret != null)
return ret;
return truePreds.contains(pred) ? cache(pred, Formula.TRUE) : cache(pred, pred.toConstraints());
}
};
Formula x = annotated.node().accept(inliner);
return annotate(x);
}
示例8: sort
import kodkod.ast.RelationPredicate; //导入依赖的package包/类
/**
* Sorts the predicates in the given array in the ascending order of the
* names of the predicates' relations, and returns it.
*
* @return broken'
* @ensures all i: [0..preds.size()) | all j: [0..i) |
* broken[j].relation.name <= broken[i].relation.name
*/
private static final <P extends RelationPredicate> P[] sort(final P[] preds) {
final Comparator<RelationPredicate> cmp = new Comparator<RelationPredicate>() {
public int compare(RelationPredicate o1, RelationPredicate o2) {
return String.valueOf(o1.relation().name()).compareTo(String.valueOf(o2.relation().name()));
}
};
Arrays.sort(preds, cmp);
return preds;
}
示例9: visit
import kodkod.ast.RelationPredicate; //导入依赖的package包/类
/**
* Calls super.visit(pred) after disabling skolemization and returns the
* result.
*
* @return super.visit(pred)
**/
public final Formula visit(RelationPredicate pred) {
final int oldDepth = skolemDepth;
skolemDepth = -1; // cannot skolemize inside a relation predicate
final Formula ret = super.visit(pred);
skolemDepth = oldDepth;
return source(ret, pred);
}
示例10: visit
import kodkod.ast.RelationPredicate; //导入依赖的package包/类
/**
* @ensures appends the tokenization of the given node to this.tokens
*/
public void visit(RelationPredicate node) {
switch (node.name()) {
case ACYCLIC :
append("acyclic");
append("[");
node.relation().accept(this);
append("]");
break;
case FUNCTION :
RelationPredicate.Function func = (RelationPredicate.Function) node;
append("function");
append("[");
func.relation().accept(this);
colon();
func.domain().accept(this);
infix("->");
keyword(func.targetMult());
func.range().accept(this);
append("]");
break;
case TOTAL_ORDERING :
RelationPredicate.TotalOrdering ord = (RelationPredicate.TotalOrdering) node;
append("ord");
append("[");
ord.relation().accept(this);
comma();
ord.ordered().accept(this);
comma();
ord.first().accept(this);
comma();
ord.last().accept(this);
append("]");
break;
default :
throw new AssertionError("unreachable");
}
}
示例11: PredicateCollector
import kodkod.ast.RelationPredicate; //导入依赖的package包/类
/**
* Constructs a new collector.
*
* @ensures this.negated' = false
*/
PredicateCollector(Set<Node> sharedNodes) {
this.sharedNodes = sharedNodes;
this.visited = new IdentityHashMap<Node,Boolean>();
this.negated = false;
preds = new EnumMap<RelationPredicate.Name,Set<RelationPredicate>>(RelationPredicate.Name.class);
preds.put(ACYCLIC, new IdentityHashSet<RelationPredicate>(4));
preds.put(TOTAL_ORDERING, new IdentityHashSet<RelationPredicate>(4));
preds.put(FUNCTION, new IdentityHashSet<RelationPredicate>(8));
}
示例12: visit
import kodkod.ast.RelationPredicate; //导入依赖的package包/类
/**
* Calls lookup(pred) and returns the cached value, if any.
* If a replacement has not been cached, visits the formula's
* children. If nothing changes, the argument is cached and
* returned, otherwise a replacement formula is cached and returned.
* @return { p: RelationPredicate | p.name = pred.name && p.relation = pred.relation.accept(this) &&
* p.name = FUNCTION => p.targetMult = pred.targetMult &&
* p.domain = pred.domain.accept(this) &&
* p.range = pred.range.accept(this),
* p.name = TOTAL_ORDERING => p.ordered = pred.ordered.accept(this) &&
* p.first = pred.first.accept(this) &&
* p.last = pred.last.accept(this) }
*/
public Formula visit(RelationPredicate pred) {
Formula ret = lookup(pred);
if (ret!=null) return ret;
final Relation r = (Relation)pred.relation().accept(this);
switch(pred.name()) {
case ACYCLIC :
ret = (r==pred.relation()) ? pred : r.acyclic();
break;
case FUNCTION :
final RelationPredicate.Function fp = (RelationPredicate.Function) pred;
final Expression domain = fp.domain().accept(this);
final Expression range = fp.range().accept(this);
ret = (r==fp.relation() && domain==fp.domain() && range==fp.range()) ?
fp :
(fp.targetMult()==Multiplicity.ONE ? r.function(domain, range) : r.partialFunction(domain,range));
break;
case TOTAL_ORDERING :
final RelationPredicate.TotalOrdering tp = (RelationPredicate.TotalOrdering) pred;
final Relation ordered = (Relation) tp.ordered().accept(this);
final Relation first = (Relation)tp.first().accept(this);
final Relation last = (Relation)tp.last().accept(this);
ret = (r==tp.relation() && ordered==tp.ordered() && first==tp.first() && last==tp.last()) ?
tp : r.totalOrder(ordered, first, last);
break;
default :
throw new IllegalArgumentException("unknown relation predicate: " + pred.name());
}
return cache(pred,ret);
}
示例13: visit
import kodkod.ast.RelationPredicate; //导入依赖的package包/类
/**
* Visits the children of the predicate if
* this.visited(pred) returns false. Otherwise does nothing.
* @ensures pred.relation.accept(this) &&
* (pred.name = FUNCTION => pred.domain.accept(this) && pred.range.accept(this)) &&
* (pred.name = TOTAL_ORDERING =>
* pred.ordered.accept(this) && pred.first.accept(this) && pred.last.accept(this) )
*/
public void visit(RelationPredicate pred) {
if (visited(pred)) return;
pred.relation().accept(this);
if (pred.name()==RelationPredicate.Name.FUNCTION) {
final RelationPredicate.Function fp = (RelationPredicate.Function) pred;
fp.domain().accept(this);
fp.range().accept(this);
} else if (pred.name()==RelationPredicate.Name.TOTAL_ORDERING) {
final RelationPredicate.TotalOrdering tp = (RelationPredicate.TotalOrdering) pred;
tp.ordered().accept(this);
tp.first().accept(this);
tp.last().accept(this);
}
}
示例14: visit
import kodkod.ast.RelationPredicate; //导入依赖的package包/类
/**
* Calls lookup(predicate) and returns the cached value, if any.
* If no cached value exists, visits each child, caches the
* disjunction of the children's return values and returns it.
* @return let x = lookup(predicate) |
* x != null => x,
* cache(predicate, some n: predicate.children | n.accept(this))
*/
public Boolean visit(RelationPredicate predicate) {
final Boolean ret = lookup(predicate);
if (ret!=null) return ret;
if (predicate.relation().accept(this))
return cache(predicate, true);
if (predicate.name()==RelationPredicate.Name.FUNCTION) {
final RelationPredicate.Function fp = (RelationPredicate.Function) predicate;
return cache(predicate, fp.domain().accept(this) || fp.range().accept(this));
} else if (predicate.name()==RelationPredicate.Name.TOTAL_ORDERING) {
final RelationPredicate.TotalOrdering tp = (RelationPredicate.TotalOrdering) predicate;
return cache(predicate, tp.ordered().accept(this) || tp.first().accept(this) || tp.last().accept(this));
}
return cache(predicate, false);
}
示例15: inlinePredicates
import kodkod.ast.RelationPredicate; //导入依赖的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 this.options.logTranslation = true
* @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);
}