ua.gradsoft.termware
Class ArgsPatternTerm

java.lang.Object
  extended by ua.gradsoft.termware.Term
      extended by ua.gradsoft.termware.AbstractComplexTerm
          extended by ua.gradsoft.termware.ArgsPatternTerm
All Implemented Interfaces:
Serializable, Cloneable

public class ArgsPatternTerm
extends AbstractComplexTerm

This term is used for unification of subterms of compired term to list. It has special syntax in TermWare language: ... i.e. unify(f..($x),f(x1,x2)) will unify $x with [x1,x2] unify(f..($x),f()) will unify $x with nil. unify(f..($x),f(x1,x2,x3,x4)) will unify $x with [x1,x2,x3,x4] and so on. unify(f..($x),g(x1,x2)) will fail if g!=f. $f..$x will successfully unficated with any functional term. $f will be substituted with string (name of term). Of course, in right parts of rules this will unroll all back when substituted, i. e. f..($x) when $x=[x1...xN] -> f(x1,..xN)

Author:
Ruslan Shevchenko
See Also:
Serialized Form

Field Summary
 
Fields inherited from class ua.gradsoft.termware.AbstractComplexTerm
emptyFv_
 
Method Summary
 boolean boundUnify(Term t, Substitution s)
          unification when we already have s and when same propositional variables means same things
 PartialOrderingResult concreteOrder(Term x, Substitution s)
          compare for 'more concrete' relation.
static Term createArgsPatternTerm(Term pattern, Term variable)
           
 Term createSame(Term[] args)
          create term, with same name but new body.
 int getArity()
          get arity of term.
 String getName()
          get name of term.
 Object getNameIndex()
          get name index in bounded symbol table or sust string, if name in symbol table does not exists.
 String getPatternName()
          for f..($x) this will be f
 Object getPatternNameIndex()
          get index for pattern name.
 Term getSubtermAt(int i)
          get i-th subterm.
 void setSubtermAt(int i, Term t)
          set i-th subterm.
 Term termClone()
          do 'deep-clone' of object.
 
Methods inherited from class ua.gradsoft.termware.AbstractComplexTerm
boundEquals, clone, emptyFv, findSubtermIndexBoundEqualsTo, freeEquals, freeUnify, getBigDecimal, getBigInteger, getBoolean, getByte, getChar, getDouble, getFloat, getInt, getJavaObject, getLong, getNumber, getPrimaryType0, getShort, getString, getTerm, getXIndex, isAtom, isBigDecimal, isBigInteger, isBoolean, isByte, isChar, isComplexTerm, isDouble, isFloat, isInt, isJavaObject, isLong, isNil, isNumber, isShort, isString, isX, maxFv, minFv, normalizeFv, print, recheckEmptyFv, resetFV, shiftFv, subst, substInside, termCompare
 
Methods inherited from class ua.gradsoft.termware.Term
containsSubtermBoundEqualsTo, getAsBigDecimal, getAsBigInteger, getAsBoolean, getAsByte, getAsChar, getAsDouble, getAsFloat, getAsInt, getAsJavaObject, getAsLong, getAsNumber, getAsShort, getAsString, getPrimaryType1, print, println, println
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createArgsPatternTerm

public static Term createArgsPatternTerm(Term pattern,
                                         Term variable)
                                  throws TermWareException
Throws:
TermWareException

getName

public String getName()
Description copied from class: AbstractComplexTerm
get name of term. (i. e. functional symbold)

Specified by:
getName in class AbstractComplexTerm
Returns:
TermWareSymbols.ARGS_PATTERN_STRING
See Also:
Term.getName()

getNameIndex

public Object getNameIndex()
Description copied from class: AbstractComplexTerm
get name index in bounded symbol table or sust string, if name in symbol table does not exists.

Specified by:
getNameIndex in class AbstractComplexTerm
Returns:
TermWareSymbols.ARGS_PATTERN_INDEX

getPatternName

public String getPatternName()
for f..($x) this will be f

Overrides:
getPatternName in class AbstractComplexTerm
Returns:
name of patterm

getPatternNameIndex

public Object getPatternNameIndex()
Description copied from class: AbstractComplexTerm
get index for pattern name.

Overrides:
getPatternNameIndex in class AbstractComplexTerm

getArity

public final int getArity()
Description copied from class: AbstractComplexTerm
get arity of term.

Specified by:
getArity in class AbstractComplexTerm
Returns:
2
See Also:
Term.getArity()

getSubtermAt

public Term getSubtermAt(int i)
Description copied from class: AbstractComplexTerm
get i-th subterm.

Specified by:
getSubtermAt in class AbstractComplexTerm
Parameters:
i - - index of subterm to get.
Returns:
subterm, which located by index i

setSubtermAt

public void setSubtermAt(int i,
                         Term t)
Description copied from class: AbstractComplexTerm
set i-th subterm.

Specified by:
setSubtermAt in class AbstractComplexTerm
Parameters:
i - - indext of subterm to set.
t - - subterm to set.

boundUnify

public boolean boundUnify(Term t,
                          Substitution s)
                   throws TermWareException
Description copied from class: Term
unification when we already have s and when same propositional variables means same things

Overrides:
boundUnify in class AbstractComplexTerm
Throws:
TermWareException

concreteOrder

public PartialOrderingResult concreteOrder(Term x,
                                           Substitution s)
                                    throws TermWareException
Description copied from class: Term
compare for 'more concrete' relation. i. e. x.<(concrete)<(y) means, that for each substitution of free variables sx exists substituion sy : x[sx] = y[sy] .
Substitution s store previously matched variables.

Specified by:
concreteOrder in class Term
Throws:
TermWareException

createSame

public Term createSame(Term[] args)
                throws TermWareException
Description copied from class: Term
create term, with same name but new body. If this term have arity 0, or other than original - throws exception.

Specified by:
createSame in class AbstractComplexTerm
Throws:
TermWareException

termClone

public Term termClone()
               throws TermWareException
Description copied from class: AbstractComplexTerm
do 'deep-clone' of object. i. e. after calling termClone we sure, that call of setSubtermAt() in any subtree of deepClone of original term does not affect original term.

Specified by:
termClone in class AbstractComplexTerm
Throws:
TermWareException