kodkod.engine.satlab
Class Clause

java.lang.Object
  extended by kodkod.engine.satlab.Clause

public abstract class Clause
extends java.lang.Object

A propositional clause.

Author:
Emina Torlak
invariant:
0 !in literals
no lit: literals | -lit in literals
some antecedents => #antecedents > 1
some antecedents => literals = { lit: antecedents[int].literals | no i: [0..#antecedents-1) | lit in antecedents[i].literals && -lit in antecedents[i+1].literals }
specfield:
literals: set int
antecedents: Clause[]

Method Summary
abstract  java.util.Iterator<Clause> antecedents()
          Returns an iterator that traverses this.antecedents in proper sequence.
 boolean equals(java.lang.Object o)
          Returns true if o is a Clause whose literals and antecedents are equal to those of this clause.
 int hashCode()
          Returns the hashcode for this clause.
abstract  IntIterator literals()
          Returns an iterator over the literals in this clause, in the ascending order of absolute values.
abstract  int maxVariable()
          Returns the largest variable identifier occuring in this.literals.
abstract  int numberOfAntecedents()
          Returns the number of antecedents of this clause.
abstract  int size()
          Returns the size of this clause, measured in the number of literals.
 int[] toArray()
          Returns a new array of length this.size(), initialized with this.literals.
abstract  int[] toArray(int[] array)
          Copies this.literals into the specified array, provided that it is large enough, and returns it.
 java.lang.String toString()
          Returns a string representation of this clause.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

size

public abstract int size()
Returns the size of this clause, measured in the number of literals.

Returns:
#this.literals

literals

public abstract IntIterator literals()
Returns an iterator over the literals in this clause, in the ascending order of absolute values.

Returns:
an iterator over this.literals

maxVariable

public abstract int maxVariable()
Returns the largest variable identifier occuring in this.literals.

Returns:
max(abs(this.literals))

toArray

public abstract int[] toArray(int[] array)
Copies this.literals into the specified array, provided that it is large enough, and returns it. If the array is not large enough, a new array is allocated, populated with this.literals, and returned.

Returns:
the given array, filled with this.literals, if the it is large enough; otherwise a new array containing this.literals
Throws:
java.lang.NullPointerException - - array = null

toArray

public int[] toArray()
Returns a new array of length this.size(), initialized with this.literals.

Returns:
a new array of length this.size(), initialized with this.literals.

numberOfAntecedents

public abstract int numberOfAntecedents()
Returns the number of antecedents of this clause.

Returns:
#this.antecedents

antecedents

public abstract java.util.Iterator<Clause> antecedents()
Returns an iterator that traverses this.antecedents in proper sequence.

Note:The clause objects returned by the iterator are not required to be immutable. In particular, the state of a clause object returned by next() (as well as the state of any object obtained through that clause's antecedents() methods) is guaranteed to remain the same only until the subsequent call to next().

Returns:
an iterator that traverses this.antecedents in proper sequence.

equals

public boolean equals(java.lang.Object o)
Returns true if o is a Clause whose literals and antecedents are equal to those of this clause.

Overrides:
equals in class java.lang.Object
Returns:
o in Clause && o.literals.equals(this.literals) && o.antecedents.equals(this.antecedents)

hashCode

public int hashCode()
Returns the hashcode for this clause. The hashcode for a clause is equivalent to Ints.superFastHash(x) where x is an array such that its first this.size() elements are the literals of this clause (as returned by this.literals()) and its remaining this.numberOfAntecedents() elements are the hashCodes of this.antecedents (as returned by this.antecedents()).

Overrides:
hashCode in class java.lang.Object
Returns:
hashcode for this clause

toString

public java.lang.String toString()
Returns a string representation of this clause.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of this clause.