tom.library.sl
Interface Path

All Known Implementing Classes:
Position

public interface Path

Represent a path between two locations in a term. The implementations of this class must define several algebraic operations on these paths (i.e. addition, subtraction, inverse).


Method Summary
 Path add(Path p)
          Computes the path from the source of this to the target of the parameter p.
 Path conc(int i)
          Add the move i to the begining of the current path
 Path getCanonicalPath()
          Gives the canonical form of a path.
 int getHead()
          Gives the first move of the path which is represented by an integer i.
 Path getTail()
          Gives the tail of the path which is also a path.
 Path inverse()
          Computes the path from the target of this to the source of this.
 int length()
          Computes the length which corresponds to the number of moves needed to go from the source to the target.
 Path sub(Path p)
          Computes the path from the target of this to the target of the parameter p.
 

Method Detail

add

Path add(Path p)
Computes the path from the source of this to the target of the parameter p. The addition of two paths must respect the following equations:

t1.add(t2) = (t1.getTail().add(t2)).conc(t1.getHead()) if t1.length()>0,

t1.add(t2) = t2 otherwise.

Parameters:
p - the path to add.
Returns:
the path corresponding to the addition of this and the parameter p.

sub

Path sub(Path p)
Computes the path from the target of this to the target of the parameter p. The subtraction of two paths must respect the following equation:

t1.sub(t2) = t2.inv().add(t1),

Parameters:
p - the path to subtract.
Returns:
the path corresponding to the subtraction of this and the parameter p.

inverse

Path inverse()
Computes the path from the target of this to the source of this. The inverse operation must respect the following equations:

t.inv() = t.getTail().inv().add(-t.getHead()) if t1.length()>0,

t.inv() = t otherwise

Returns:
the path corresponding to the inverse path of this.

getCanonicalPath

Path getCanonicalPath()
Gives the canonical form of a path. Two paths are equivalent if for every source the corresponding targets are the same. In an equivalence class, the canonical form is the smallest path.

Returns:
its canonical form

length

int length()
Computes the length which corresponds to the number of moves needed to go from the source to the target.

Returns:
the length of the path

getHead

int getHead()
Gives the first move of the path which is represented by an integer i. When i is positive, it corresponds to a move from the parent to th i-th child of the current location. Otherwise, it signifies a move from the i-th child to the parent.

Returns:
the first move.

getTail

Path getTail()
Gives the tail of the path which is also a path.

Returns:
the path after the first move.

conc

Path conc(int i)
Add the move i to the begining of the current path

Parameters:
i - the move to insert.
Returns:
the path corresponding to the insersion of i into this.