mln
Class Literal

java.lang.Object
  extended by mln.Literal

public class Literal
extends java.lang.Object

A literal in first-order logic.


Constructor Summary
Literal(Predicate predicate, boolean sense)
          Constructor of Literal.
 
Method Summary
 void appendTerm(Term t)
          Append a new term to this literal.
 boolean coversAllMaterializedTuples()
          Test whether we want this literal to cover all materialized tuples regardless of the sense of this literal.
 void flipSense()
          Flip the sense of this literal.
 int getIdx()
          Return the assigned index of this literal in its parent clause.
 Predicate getPred()
          Return the predicate of this literal.
 boolean getSense()
          Return true if this is a positive literal.
 java.util.ArrayList<Term> getTerms()
          Return the list of terms in this literal.
 java.util.HashSet<java.lang.String> getVars()
          Return the set of variable names in this literal.
 boolean isBuiltIn()
          Return whether the predicate of this literal is a built-in predicate.
 boolean isSameAs(Literal lit)
          Compare a given literal with this one.
 java.util.HashMap<java.lang.String,Term> mostGeneralUnification(Tuple atuple)
          Compute the most general unification (MGU) of two literals.
 void setCoversAllMaterializedTuples(boolean coversAllMaterializedTuples)
          Set whether we want this literal to cover all materialized tuples regardless of the sense of this literal.
 void setIdx(int i)
          Assign an unique (within its parent clause) index to this literal.
 void setSense(boolean asense)
          Set the sense of this literal.
 Literal substitute(java.util.HashMap<java.lang.String,Term> vmap)
          Apply a substitution to this literal.
 Atom toAtom(Atom.AtomType type)
          Convert this literal to an atom.
 java.lang.String toString()
          Return the human-friendly representation of this literal.
 Tuple toTuple()
          Convert this literal into a tuple.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Literal

public Literal(Predicate predicate,
               boolean sense)
Constructor of Literal.

Parameters:
predicate - the predicate
sense - true for a positive literal; false for a negative one
Method Detail

appendTerm

public void appendTerm(Term t)
Append a new term to this literal.

Parameters:
t - the term to be appended

coversAllMaterializedTuples

public boolean coversAllMaterializedTuples()
Test whether we want this literal to cover all materialized tuples regardless of the sense of this literal.


flipSense

public void flipSense()
Flip the sense of this literal.


getIdx

public int getIdx()
Return the assigned index of this literal in its parent clause.


getPred

public Predicate getPred()
Return the predicate of this literal.


getSense

public boolean getSense()
Return true if this is a positive literal. Here the positive/negative refers to that in Horn clause.


getTerms

public java.util.ArrayList<Term> getTerms()
Return the list of terms in this literal.


getVars

public java.util.HashSet<java.lang.String> getVars()
Return the set of variable names in this literal.


isBuiltIn

public boolean isBuiltIn()
Return whether the predicate of this literal is a built-in predicate.


isSameAs

public boolean isSameAs(Literal lit)
Compare a given literal with this one. By ``same'', it means 1) predicate is same; 2) sense is same; 3) corresponding constant is same; and 4) the name of corresponding variable is same. (Do not consider substitution).

Parameters:
lit - the literal needed to be compared.
Returns:
true if these two literals are the same, false otherwise.

mostGeneralUnification

public java.util.HashMap<java.lang.String,Term> mostGeneralUnification(Tuple atuple)
Compute the most general unification (MGU) of two literals.

Parameters:
atuple - the literal (in the form of a tuple) to be unified
Returns:
the MGU in the form of a mapping from variables to variables/constants

setCoversAllMaterializedTuples

public void setCoversAllMaterializedTuples(boolean coversAllMaterializedTuples)
Set whether we want this literal to cover all materialized tuples regardless of the sense of this literal.

Parameters:
coversAllMaterializedTuples -

setIdx

public void setIdx(int i)
Assign an unique (within its parent clause) index to this literal.

Parameters:
i - the index
See Also:
Clause.addLiteral(Literal)

setSense

public void setSense(boolean asense)
Set the sense of this literal.

Parameters:
asense - true if this is intended to be a positive literal

substitute

public Literal substitute(java.util.HashMap<java.lang.String,Term> vmap)
Apply a substitution to this literal.

Parameters:
vmap - the substitution
Returns:
the new literal

toAtom

public Atom toAtom(Atom.AtomType type)
Convert this literal to an atom.

Parameters:
type - indicates if it's an evidence, a query, etc.

toString

public java.lang.String toString()
Return the human-friendly representation of this literal.

Overrides:
toString in class java.lang.Object

toTuple

public Tuple toTuple()
Convert this literal into a tuple. This will assign an internal ID for variables obeying the syntax of class Tuple from Strings.