inpro.irmrsc.rmrs
Class Formula

java.lang.Object
  extended by inpro.irmrsc.rmrs.VariableEnvironment
      extended by inpro.irmrsc.rmrs.Formula
All Implemented Interfaces:
VariableIDsInterpretable

public class Formula
extends VariableEnvironment
implements VariableIDsInterpretable

A RMRS formula, consisting of a hook, a stack of slots and a bag of relations, scope constraints and variable equalities.

RMRS formulas are usually built by by creating new ones from lexical predicate names or by loading them from xml-specifications. They can be combined with other formulas.

Author:
Andreas Peldszus

Field Summary
private  java.util.List<VariableIDPair> mEqs
          Variable Equalities
private  Hook mHook
           
private  java.util.List<Relation> mRels
           
private  java.util.List<VariableIDPair> mScons
          Scope Constraints
private  java.util.Deque<Hook> mSlots
           
 
Fields inherited from class inpro.irmrsc.rmrs.VariableEnvironment
mVariables
 
Constructor Summary
Formula()
          default constructor, only used for xml loading
Formula(Formula f)
           
Formula(java.lang.String lexname, Variable.Type semtype)
          make a simple new formula for a lexical object
 
Method Summary
 void checkVariableEnvironmentConsistency()
          warns if variable IDs in this expression are not defined in the underlying VariableEnvironment.
 boolean forwardCombine(Formula fo)
          combines the given formula with this formula in a 'forward function composition' manner.
 java.util.List<SimpleAssertion> getNominalAssertions()
           
 java.util.List<SimpleAssertion> getUnscopedPredicateLogic()
          a first, unfinished implementation to extract unscoped predicate logic statements of this rmrs, i.e. to get rid of the predicate-argument factorisation
 java.util.Set<java.lang.Integer> getVariableIDs()
           
 boolean isComplete()
           
 boolean isReduced()
           
 void parseXML(org.jdom.Element e)
          initializes this rmrs formula object from XML element variable definition <rmrsincrement>
 void reduce()
          applies all variable equalities by replacing the corresponding variable IDs.
 void renumber()
          reassigns new IDs for all variables in this expression starting from 0
 void renumber(int StartIndex)
          reassigns new IDs for all variables in this expression starting from StartIndex
 void replaceVariableID(int oldID, int newID)
          replace all variables IDs matching a specifid old ID with a new ID
private  void rerenumber(int StartIndex)
           
 void simpleAdd(Formula fo)
          simply adds another formula to this formula without consuming a slot and equating variables
 java.lang.String toRMRSString()
           
 java.lang.String toString()
           
 java.lang.String toStringMultiLine()
           
 java.lang.String toStringOneLine()
           
 
Methods inherited from class inpro.irmrsc.rmrs.VariableEnvironment
getMaxID, getVariableString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

mHook

private Hook mHook

mSlots

private java.util.Deque<Hook> mSlots

mRels

private java.util.List<Relation> mRels

mScons

private java.util.List<VariableIDPair> mScons
Scope Constraints


mEqs

private java.util.List<VariableIDPair> mEqs
Variable Equalities

Constructor Detail

Formula

public Formula(Formula f)

Formula

public Formula()
default constructor, only used for xml loading


Formula

public Formula(java.lang.String lexname,
               Variable.Type semtype)
make a simple new formula for a lexical object

Method Detail

reduce

public void reduce()
applies all variable equalities by replacing the corresponding variable IDs.

Type-underspecified variables that are equated with type-specified variables may be specified in this process.


isReduced

public boolean isReduced()

isComplete

public boolean isComplete()

forwardCombine

public boolean forwardCombine(Formula fo)
combines the given formula with this formula in a 'forward function composition' manner.

The top slot of this formula is consumed by the argument formula. The argument formula content is added to this formula. Variable of the consumed slot and the argument formula's hook are equated. Variable equations may be reduced by reduce() afterwards.

This combination is implemented as mutation. The argument formula is not changed.


simpleAdd

public void simpleAdd(Formula fo)
simply adds another formula to this formula without consuming a slot and equating variables


getVariableIDs

public java.util.Set<java.lang.Integer> getVariableIDs()
Specified by:
getVariableIDs in interface VariableIDsInterpretable
Returns:
the set of IDs of all variables in that expression

replaceVariableID

public void replaceVariableID(int oldID,
                              int newID)
Description copied from interface: VariableIDsInterpretable
replace all variables IDs matching a specifid old ID with a new ID

Specified by:
replaceVariableID in interface VariableIDsInterpretable

checkVariableEnvironmentConsistency

public void checkVariableEnvironmentConsistency()
warns if variable IDs in this expression are not defined in the underlying VariableEnvironment.

Specified by:
checkVariableEnvironmentConsistency in class VariableEnvironment

renumber

public void renumber(int StartIndex)
reassigns new IDs for all variables in this expression starting from StartIndex


renumber

public void renumber()
reassigns new IDs for all variables in this expression starting from 0


rerenumber

private void rerenumber(int StartIndex)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

toStringOneLine

public java.lang.String toStringOneLine()

toStringMultiLine

public java.lang.String toStringMultiLine()

toRMRSString

public java.lang.String toRMRSString()

getUnscopedPredicateLogic

public java.util.List<SimpleAssertion> getUnscopedPredicateLogic()
a first, unfinished implementation to extract unscoped predicate logic statements of this rmrs, i.e. to get rid of the predicate-argument factorisation


getNominalAssertions

public java.util.List<SimpleAssertion> getNominalAssertions()
Returns:
a list of predicate logic statements involving all individual variables in the formula, but not necessarily the other variables

parseXML

public void parseXML(org.jdom.Element e)
initializes this rmrs formula object from XML element variable definition <rmrsincrement>

Parameters:
e - the element