kodkod.engine.bool
Class Int

java.lang.Object
  extended by kodkod.engine.bool.Int

public abstract class Int
extends java.lang.Object

An integer represented using boolean values and unary or binary encoding.

Author:
Emina Torlak
specfield:
factory: BooleanFactory
bits: [0..factory.bitwidth) -> one factory.components
encoding: factory.intEncoding

Method Summary
abstract  Int abs()
          Returns an Int that represents the absolute value of this integer.
abstract  Int and(Int other)
          Returns an Int that represents the bitwise conjunction of this and the given Int.
abstract  BooleanValue bit(int i)
          Returns the BooleanValue at the specified index.
abstract  Int choice(BooleanValue condition, Int other)
          Returns an Int that evaluates to this if the condition is true, otherwise it evaluates to the given Int.
abstract  Int divide(Int other)
          Returns an Int that represents the quotient of the division between this and the given Int.
 BooleanValue eq(Int other)
          Returns a BooleanValue encoding the comparator circuit that checks whether the integer represented by this Int is equal to the integer represented by the specified Int.
 BooleanFactory factory()
          Returns this.factory
 BooleanValue gt(Int other)
          Returns a BooleanValue encoding the comparator circuit that checks whether the integer represented by this Int is greater than the integer represented by the specified Int.
 BooleanValue gte(Int other)
          Returns a BooleanValue encoding the comparator circuit that checks whether the integer represented by this Int is greater than or equal to the integer represented by the specified Int.
 boolean isConstant()
          Returns true if all the bits representing this Int are BooleanConstants.
 BooleanValue lt(Int other)
          Returns a BooleanValue encoding the comparator circuit that checks whether the integer represented by this Int is less than the integer represented by the specified Int.
abstract  BooleanValue lte(Int other)
          Returns a BooleanValue encoding the comparator circuit that checks whether the integer represented by this Int is less than or equal to the integer represented by the specified Int
abstract  Int minus(Int other)
          Returns an Int that represents the difference between this and the given Int.
abstract  Int modulo(Int other)
          Returns an Int that represents the remainder of the division between this and the given Int.
abstract  Int multiply(Int other)
          Returns an Int that represents the product between this and the given Int.
abstract  Int negate()
          Returns an Int that represents the negation of this integer.
abstract  Int not()
          Returns an Int that represents bitwise negation of this integer.
abstract  Int or(Int other)
          Returns an Int that represents the bitwise disjunction of this and the given Int.
abstract  Int plus(Int other)
          Returns an Int that represents the sum of this and the given Int.
abstract  Int sgn()
          Returns an Int that represents the signum of this integer.
abstract  Int sha(Int other)
          Returns an Int that represents this shifted to the right by the given Int, with sign extension.
abstract  Int shl(Int other)
          Returns an Int that represents this shifted to the left by the given Int.
abstract  Int shr(Int other)
          Returns an Int that represents this shifted to the right by the given Int, with zero extension.
abstract  int value()
          If this Int is constant, returns its value.
abstract  int width()
          Returns the number of bits in the representation of this Int, including sign bits (if any).
abstract  Int xor(Int other)
          Returns an Int that represents the bitwise XOR of this and the given Int.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

factory

public final BooleanFactory factory()
Returns this.factory

Returns:
this.factory

width

public abstract int width()
Returns the number of bits in the representation of this Int, including sign bits (if any).

Returns:
this.width

bit

public abstract BooleanValue bit(int i)
Returns the BooleanValue at the specified index.

Returns:
this.bits[i]
requires:
0 <= i < this.factory.bitwidth

isConstant

public final boolean isConstant()
Returns true if all the bits representing this Int are BooleanConstants.

Returns:
this.bits[int] in BooleanConstant

value

public abstract int value()
If this Int is constant, returns its value. Otherwise throws an IllegalStateException.

Returns:
this.isConstant() => [[this.bits]]
Throws:
java.lang.IllegalStateException - - !this.isConstant()

eq

public final BooleanValue eq(Int other)
Returns a BooleanValue encoding the comparator circuit that checks whether the integer represented by this Int is equal to the integer represented by the specified Int.

Returns:
BooleanValue encoding the comparator circuit that checks whether the integer represented by this Int is equal to the integer represented by the specified Int
Throws:
java.lang.IllegalArgumentException - - this.factory != other.factory
requires:
this.factory = other.factory

lte

public abstract BooleanValue lte(Int other)
Returns a BooleanValue encoding the comparator circuit that checks whether the integer represented by this Int is less than or equal to the integer represented by the specified Int

Returns:
BooleanValue encoding the comparator circuit that checks whether the integer represented by this Int is less than or equal to the integer represented by the specified Int
Throws:
java.lang.IllegalArgumentException - - this.factory != other.factory
requires:
this.factory = other.factory

lt

public BooleanValue lt(Int other)
Returns a BooleanValue encoding the comparator circuit that checks whether the integer represented by this Int is less than the integer represented by the specified Int.

Returns:
BooleanValue encoding the comparator circuit that checks whether the integer represented by this Int is less than the integer represented by the specified Int
Throws:
java.lang.IllegalArgumentException - - this.factory != other.factory
requires:
this.factory = other.factory

gte

public BooleanValue gte(Int other)
Returns a BooleanValue encoding the comparator circuit that checks whether the integer represented by this Int is greater than or equal to the integer represented by the specified Int.

Returns:
BooleanValue encoding the comparator circuit that checks whether the integer represented by this Int is greater than or equal to the integer represented by the specified Int
Throws:
java.lang.IllegalArgumentException - - this.factory != other.factory
requires:
this.factory = other.factory

gt

public BooleanValue gt(Int other)
Returns a BooleanValue encoding the comparator circuit that checks whether the integer represented by this Int is greater than the integer represented by the specified Int.

Returns:
BooleanValue encoding the comparator circuit that checks whether the integer represented by this Int is greater than the integer represented by the specified Int
Throws:
java.lang.IllegalArgumentException - - this.factory != other.factory
requires:
this.factory = other.factory

plus

public abstract Int plus(Int other)
Returns an Int that represents the sum of this and the given Int.

Returns:
an Int that represents the sum of this and the given Int
Throws:
java.lang.IllegalArgumentException - - this.factory != other.factory
requires:
this.factory = other.factory

minus

public abstract Int minus(Int other)
Returns an Int that represents the difference between this and the given Int.

Returns:
an Int that represents the difference between this and the given Int
Throws:
java.lang.UnsupportedOperationException - - this.encoding does not support subtraction
requires:
this.factory = other.factory

multiply

public abstract Int multiply(Int other)
Returns an Int that represents the product between this and the given Int.

Returns:
an Int that represents the product between this and the given Int
Throws:
java.lang.UnsupportedOperationException - - this.encoding does not support multiplication
requires:
this.factory = other.factory

divide

public abstract Int divide(Int other)
Returns an Int that represents the quotient of the division between this and the given Int.

Returns:
an Int that represents the quotient of the division between this and the given Int
Throws:
java.lang.UnsupportedOperationException - - this.encoding does not support division
requires:
this.factory = other.factory

modulo

public abstract Int modulo(Int other)
Returns an Int that represents the remainder of the division between this and the given Int.

Returns:
an Int that represents the remainder of the division between this and the given Int
Throws:
java.lang.UnsupportedOperationException - - this.encoding does not support division
requires:
this.factory = other.factory

choice

public abstract Int choice(BooleanValue condition,
                           Int other)
Returns an Int that evaluates to this if the condition is true, otherwise it evaluates to the given Int.

Returns:
an Int that evaluates to this if the condition is true, and to the given Int if the condition is false.
requires:
other + condition in this.factory.components

and

public abstract Int and(Int other)
Returns an Int that represents the bitwise conjunction of this and the given Int.

Returns:
an Int that represents the bitwise conjunction of this and the given Int.
requires:
this.factory = other.factory

or

public abstract Int or(Int other)
Returns an Int that represents the bitwise disjunction of this and the given Int.

Returns:
an Int that represents the bitwise disjunction of this and the given Int.
requires:
this.factory = other.factory

xor

public abstract Int xor(Int other)
Returns an Int that represents the bitwise XOR of this and the given Int.

Returns:
an Int that represents the bitwise XOR of this and the given Int.
Throws:
java.lang.UnsupportedOperationException - - this.encoding does not support XOR
requires:
this.factory = other.factory

shl

public abstract Int shl(Int other)
Returns an Int that represents this shifted to the left by the given Int.

Returns:
an Int that represents this shifted to the left by the given Int.
Throws:
java.lang.UnsupportedOperationException - - this.encoding does not support SHL
requires:
this.factory = other.factory

shr

public abstract Int shr(Int other)
Returns an Int that represents this shifted to the right by the given Int, with zero extension.

Returns:
an Int that represents this shifted to the right by the given Int, with zero extension.
Throws:
java.lang.UnsupportedOperationException - - this.encoding does not support SHR
requires:
this.factory = other.factory

sha

public abstract Int sha(Int other)
Returns an Int that represents this shifted to the right by the given Int, with sign extension.

Returns:
an Int that represents this shifted to the right by the given Int, with sign extension.
Throws:
java.lang.UnsupportedOperationException - - this.encoding does not support SHA
requires:
this.factory = other.factory

negate

public abstract Int negate()
Returns an Int that represents the negation of this integer.

Returns:
-[[this]]
Throws:
java.lang.UnsupportedOperationException - - this.encoding does not support negation

not

public abstract Int not()
Returns an Int that represents bitwise negation of this integer.

Returns:
~[[this]]
Throws:
java.lang.UnsupportedOperationException - - this.encoding does not support bitwise negation

abs

public abstract Int abs()
Returns an Int that represents the absolute value of this integer.

Returns:
abs([[this]])

sgn

public abstract Int sgn()
Returns an Int that represents the signum of this integer.

Returns:
sgn([[this]])