kodkod.ast
Class Expression

java.lang.Object
  extended by kodkod.ast.Expression
All Implemented Interfaces:
Node
Direct Known Subclasses:
BinaryExpression, Comprehension, IfExpression, IntToExprCast, LeafExpression, ProjectExpression, UnaryExpression

public abstract class Expression
extends java.lang.Object
implements Node

A relational expression. Unless otherwise noted, all methods in this class throw a NullPointerException when given null arguments.

Author:
Emina Torlak
invariant:
arity > 0
specfield:
arity: int

Field Summary
static Expression IDEN
          The identity relation: maps all atoms in a universe of discourse to themselves.
static Expression INTS
          The integer relation: contains all atoms bound to integers
static Expression NONE
          The empty relation: contains no atoms.
static Expression UNIV
          The universal relation: contains all atoms in a universe of discourse.
 
Method Summary
abstract
<E,F,D,I> E
accept(ReturnVisitor<E,F,D,I> visitor)
          Accepts the given visitor and returns the result.
 IntExpression apply(ExprToIntCast.Operator op)
          Returns the cast of this expression to an integer expression, that represents either the cardinality of this expression (if op is CARDINALITY) or the sum of the integer atoms it contains (if op is SUM).
 Formula apply(Multiplicity mult)
          Returns the formula that results from applying the specified multiplicity to this expression.
 Expression apply(UnaryExpression.Operator op)
          Returns the expression that results from applying the given unary operator to this.
abstract  int arity()
          Returns the arity of this expression.
 Expression closure()
          Returns the transitive closure of this.
 Expression compose(BinaryExpression.Operator op, Expression expr)
          Returns the composition of this and the specified expression, using the given binary operator.
 Formula compose(ComparisonFormula.Operator op, Expression expr)
          Returns the formula that represents the composition of this and the given expression with the given comparison operator.
 IntExpression count()
          Returns the cardinality of this expression.
 Expression difference(Expression expr)
          Returns the difference of this and the specified expression.
 Formula eq(Expression expr)
          Returns the formula 'this = expr'.
 Formula in(Expression expr)
          Returns the formula 'this in expr'.
 Expression intersection(Expression expr)
          Returns the intersection of this and the specified expression.
 Expression join(Expression expr)
          Returns the join of this and the specified expression.
 Formula lone()
          Returns the formula 'lone this'.
 Formula no()
          Returns the formula 'no this'.
 Formula one()
          Returns the formula 'one this'.
 Expression override(Expression expr)
          Returns the relational override of this with the specified expression.
 Expression product(Expression expr)
          Returns the product of this and the specified expression.
 Expression project(IntExpression... columns)
          Returns the projection of this expression onto the specified columns.
 Expression reflexiveClosure()
          Returns the reflexive transitive closure of this.
 Formula some()
          Returns the formula 'some this'.
 IntExpression sum()
          Returns the sum of the integer atoms in this expression.
 Expression transpose()
          Returns the transpose of this.
 Expression union(Expression expr)
          Returns the union of this and the specified expression.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface kodkod.ast.Node
accept
 

Field Detail

UNIV

public static final Expression UNIV
The universal relation: contains all atoms in a universe of discourse.


IDEN

public static final Expression IDEN
The identity relation: maps all atoms in a universe of discourse to themselves.


NONE

public static final Expression NONE
The empty relation: contains no atoms.


INTS

public static final Expression INTS
The integer relation: contains all atoms bound to integers

Method Detail

join

public final Expression join(Expression expr)
Returns the join of this and the specified expression. The effect of this method is the same as calling this.compose(BinaryExpression.Operator.JOIN, expr).

Returns:
{e : Expression | e = this.expr}

product

public final Expression product(Expression expr)
Returns the product of this and the specified expression. The effect of this method is the same as calling this.compose(BinaryExpression.Operator.PRODUCT, expr).

Returns:
{e : Expression | e = this->expr}

union

public final Expression union(Expression expr)
Returns the union of this and the specified expression. The effect of this method is the same as calling this.compose(BinaryExpression.Operator.UNION, expr).

Returns:
{e : Expression | e = this + expr}

difference

public final Expression difference(Expression expr)
Returns the difference of this and the specified expression. The effect of this method is the same as calling this.compose(BinaryExpression.Operator.DIFFERENCE, expr).

Returns:
{e : Expression | e = this - expr}

intersection

public final Expression intersection(Expression expr)
Returns the intersection of this and the specified expression. The effect of this method is the same as calling this.compose(BinaryExpression.Operator.INTERSECTION, expr).

Returns:
{e : Expression | e = this & expr}

override

public final Expression override(Expression expr)
Returns the relational override of this with the specified expression. The effect of this method is the same as calling this.compose(BinaryExpression.Operator.OVERRIDE, expr).

Returns:
{e : Expression | e = this ++ expr}

compose

public final Expression compose(BinaryExpression.Operator op,
                                Expression expr)
Returns the composition of this and the specified expression, using the given binary operator.

Returns:
{e: Expression | e = this op expr }

transpose

public final Expression transpose()
Returns the transpose of this. The effect of this method is the same as calling this.apply(UnaryExpression.Operator.TRANSPOSE).

Returns:
{e : Expression | e = ~this}

closure

public final Expression closure()
Returns the transitive closure of this. The effect of this method is the same as calling this.apply(UnaryExpression.Operator.CLOSURE).

Returns:
{e : Expression | e = ^this}
Throws:
java.lang.IllegalArgumentException - - this.arity != 2

reflexiveClosure

public final Expression reflexiveClosure()
Returns the reflexive transitive closure of this. The effect of this method is the same as calling this.apply(UnaryExpression.Operator.REFLEXIVE_CLOSURE).

Returns:
{e : Expression | e = *this}
Throws:
java.lang.IllegalArgumentException - - this.arity != 2

apply

public final Expression apply(UnaryExpression.Operator op)
Returns the expression that results from applying the given unary operator to this.

Returns:
{e: Expression | e = op this }
Throws:
java.lang.IllegalArgumentException - - this.arity != 2

project

public final Expression project(IntExpression... columns)
Returns the projection of this expression onto the specified columns.

Returns:
{e: Expression | e = project(this, columns) }
Throws:
java.lang.IllegalArgumentException - - columns.length < 1

count

public final IntExpression count()
Returns the cardinality of this expression. The effect of this method is the same as calling this.apply(ExprToIntCast.Operator.CARDINALITY).

Returns:
{e: IntExpression | e = #this }

sum

public final IntExpression sum()
Returns the sum of the integer atoms in this expression. The effect of this method is the same as calling this.apply(ExprToIntCast.Operator.SUM).

Returns:
{e: IntExpression | e = sum(this) }

apply

public final IntExpression apply(ExprToIntCast.Operator op)
Returns the cast of this expression to an integer expression, that represents either the cardinality of this expression (if op is CARDINALITY) or the sum of the integer atoms it contains (if op is SUM).

Returns:
{e: IntExpression | e.op = op && e.expression = this}

eq

public final Formula eq(Expression expr)
Returns the formula 'this = expr'. The effect of this method is the same as calling this.compose(ComparisonFormula.Operator.EQUALS, expr).

Returns:
{f : Formula | f <=> this = expr}

in

public final Formula in(Expression expr)
Returns the formula 'this in expr'. The effect of this method is the same as calling this.compose(ComparisonFormula.Operator.SUBSET, expr).

Returns:
{f : Formula | f <=> this in expr}

compose

public final Formula compose(ComparisonFormula.Operator op,
                             Expression expr)
Returns the formula that represents the composition of this and the given expression with the given comparison operator.

Returns:
{f: Formula | f <=> this op expr }

some

public final Formula some()
Returns the formula 'some this'. The effect of this method is the same as calling this.apply(MultiplicityFormula.Multiplicity.SOME).

Returns:
{f : Formula | f <=> some this}

no

public final Formula no()
Returns the formula 'no this'. The effect of this method is the same as calling this.apply(MultiplicityFormula.Multiplicity.NO).

Returns:
{f : Formula | f <=> no this}

one

public final Formula one()
Returns the formula 'one this'. The effect of this method is the same as calling this.apply(MultiplicityFormula.Multiplicity.ONE).

Returns:
{f : Formula | f <=> one this}

lone

public final Formula lone()
Returns the formula 'lone this'. The effect of this method is the same as calling this.apply(MultiplicityFormula.Multiplicity.LONE).

Returns:
{f : Formula | f <=> lone this}

apply

public final Formula apply(Multiplicity mult)
Returns the formula that results from applying the specified multiplicity to this expression. The SET multiplicity is not allowed.

Returns:
{f: Formula | f <=> mult this}
Throws:
java.lang.IllegalArgumentException - - mult = Multiplicity.SET

arity

public abstract int arity()
Returns the arity of this expression.

Returns:
this.arity

accept

public abstract <E,F,D,I> E accept(ReturnVisitor<E,F,D,I> visitor)
Accepts the given visitor and returns the result.

Specified by:
accept in interface Node
Returns:
the result of being visited by the given visitor
See Also:
Node.accept(kodkod.ast.visitor.ReturnVisitor)