Java Code Examples for kodkod.ast.operator.Multiplicity#LONE

The following examples show how to use kodkod.ast.operator.Multiplicity#LONE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RelationPredicate.java    From org.alloytools.alloy with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs a new function predicate over the given relation and domain, with
 * the specified target multiplicity.
 *
 * @ensures this.name' = FUNCTION && this.relation' = relation && this.domain' =
 *          domain && this.range' = range
 * @throws IllegalArgumentException relation.arity != 2 || domain.arity != 1 ||
 *             range.arity != 1 || targetMult !in ONE + LONE
 */
Function(Relation relation, Expression domain, Multiplicity targetMult, Expression range) {
    super(relation);
    if (targetMult != Multiplicity.ONE && targetMult != Multiplicity.LONE)
        throw new IllegalArgumentException("invalid target multiplicity for a function: " + targetMult);
    if (domain.arity() != 1 || range.arity() != 1)
        throw new IllegalArgumentException("invalid arity: " + domain + " or " + range);
    this.targetMult = targetMult;
    this.domain = domain;
    this.range = range;
}
 
Example 2
Source File: RelationPredicate.java    From kodkod with MIT License 5 votes vote down vote up
/**
 * Constructs a new function predicate over the given relation and domain, 
 * with the specified target multiplicity.
 * @ensures this.name' = FUNCTION && this.relation' = relation && this.domain' = domain &&
 *          this.range' = range
 * @throws IllegalArgumentException  relation.arity != 2 || domain.arity != 1 || range.arity != 1 || 
 *                                    targetMult !in ONE + LONE
 */
Function(Relation relation, Expression domain, Multiplicity targetMult, Expression range) {
	super(relation);
	if (targetMult != Multiplicity.ONE && targetMult != Multiplicity.LONE)
		throw new IllegalArgumentException("invalid target multiplicity for a function: " + targetMult);
	if (domain.arity() != 1 || range.arity() != 1)
		throw new IllegalArgumentException("invalid arity: " + domain + " or " + range);
	this.targetMult = targetMult;
	this.domain = domain;
	this.range = range;
}
 
Example 3
Source File: Variable.java    From org.alloytools.alloy with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the declaration that constrains this variable to be bound to at most
 * one element of the given expression: 'this: lone expr'.
 *
 * @return {d: Decl | d.variable = this && d.multiplicity = LONE && d.expression
 *         = expr }
 * @throws NullPointerException expr = null
 * @throws IllegalArgumentException this.arity != expr.arity || expr.arity != 1
 */
public Decl loneOf(Expression expr) {
    return new Decl(this, Multiplicity.LONE, expr);
}
 
Example 4
Source File: Relation.java    From org.alloytools.alloy with Apache License 2.0 2 votes vote down vote up
/**
 * Returns a formula stating that this relation is a partial function with the
 * specified domain and range.
 *
 * @return {f: Formula | f <=> this in domain->range && all v: domain | lone
 *         v.this }
 * @throws NullPointerException domain = null || range = null
 * @throws IllegalArgumentException domain.arity != 1 || range.arity != 1
 * @throws IllegalArgumentException this.arity != 2
 */
public Formula partialFunction(Expression domain, Expression range) {
    return new RelationPredicate.Function(this, domain, Multiplicity.LONE, range);
}
 
Example 5
Source File: Variable.java    From kodkod with MIT License 2 votes vote down vote up
/**
 * Returns the declaration that constrains this variable to 
 * be bound to at most one element of the given expression:  'this: lone expr'.
 * @return {d: Decl | d.variable = this && d.multiplicity = LONE && d.expression = expr }
 * @throws NullPointerException  expr = null
 * @throws IllegalArgumentException  this.arity != expr.arity || expr.arity != 1
 */
public Decl loneOf(Expression expr) {
	return new Decl(this, Multiplicity.LONE, expr);
}
 
Example 6
Source File: Relation.java    From kodkod with MIT License 2 votes vote down vote up
/**
 * Returns a formula stating that this relation is a partial function
 * with the specified domain and range.
 * @return {f: Formula | f <=> this in domain->range && all v: domain | lone v.this }
 * @throws NullPointerException  domain = null || range = null
 * @throws IllegalArgumentException  domain.arity != 1 || range.arity != 1
 * @throws IllegalArgumentException  this.arity != 2
 */
public Formula partialFunction(Expression domain, Expression range) {
		return new RelationPredicate.Function(this, domain, Multiplicity.LONE, range);
}