kites.logic
Class Codification

java.lang.Object
  extended by kites.logic.Codification

public class Codification
extends java.lang.Object

This class provides everything necessary to transform a RuleList and an instance of it to the normal form. This means that all function, constant and variable symbols will be replaced so a very specific signature consisting only of the symbols fun, var, suc and zero is used. All symbols will get a number associated with them, beginning with 0 (zero). For example function 3 is represented as: fun(suc(suc(suc(zero)))) These terms are then put together using several cons terms. For details please refer to my bachelor thesis.


Field Summary
private  java.util.HashMap<java.lang.String,java.lang.Integer> codes
           
private  ASTNode codifiedInstance
           
private  ASTNode codifiedRuleList
           
private  int curNumFunction
           
private  int curNumVariable
           
private  TRSFile rulelist
           
 
Constructor Summary
Codification(TRSFile rulelist)
          Initialize the class to perform the codification
 
Method Summary
 void codify()
          Performs the actual codification by first generating a mapping between the original symbols and ascending numbers.
private  ASTNode codifyRuleList()
          Create the encoded standard form of a RuleList.
private  ASTNode codifyTree(java.util.LinkedList<java.lang.Object> flatTree)
          This method transforms a given tree to its encoded standard form.
private  void createMap(ASTNode node)
          Create a mapping between function symbols and numbers for a tree.
private  ASTNode genCode(ASTNode node)
          Generate the codified term for a specific node.
private  java.util.LinkedList<java.lang.Object> genFlatTree(ASTNode node)
          This method creates a flat list from a node tree See my bachelor thesis for details.
private  ASTNode genNumber(int number)
          Generate a number in term form using suc and zero
 ASTNode getCodifiedInstance()
          Returns the previously computed codified instance.
 ASTNode getCodifiedRuleList()
          Returns the previously computed codified rulelist.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

codes

private java.util.HashMap<java.lang.String,java.lang.Integer> codes

curNumFunction

private int curNumFunction

curNumVariable

private int curNumVariable

rulelist

private TRSFile rulelist

codifiedRuleList

private ASTNode codifiedRuleList

codifiedInstance

private ASTNode codifiedInstance
Constructor Detail

Codification

public Codification(TRSFile rulelist)
Initialize the class to perform the codification

Parameters:
rulelist - The RuleList to be codified
Method Detail

codify

public void codify()
Performs the actual codification by first generating a mapping between the original symbols and ascending numbers. Then both the RuleList and afterwards the instance will be codified. Symbols present in the instance, but not in the RuleList will also be codified. Their associated numbers will be the highest ones.


codifyTree

private ASTNode codifyTree(java.util.LinkedList<java.lang.Object> flatTree)
This method transforms a given tree to its encoded standard form. It is supposed the mapping has already been created. It takes a flattened list structure and then transforms that structure into a new "tree-list" with cons. See my bachelor thesis for details.

Parameters:
flatTree - A flattened tree
Returns:
The normal form of the tree
See Also:
This method flattens the tree

genFlatTree

private java.util.LinkedList<java.lang.Object> genFlatTree(ASTNode node)
This method creates a flat list from a node tree See my bachelor thesis for details.

Parameters:
node - The tree to be flattened
Returns:
The flattened tree

genCode

private ASTNode genCode(ASTNode node)
Generate the codified term for a specific node. Here a node may not be a tree - No checks are performed!

Parameters:
node - The node to be codified
Returns:
Term [fun | var](suc(...(zero)...)

genNumber

private ASTNode genNumber(int number)
Generate a number in term form using suc and zero

Parameters:
number -
Returns:
The number's term, e. g. suc(suc(zero))

codifyRuleList

private ASTNode codifyRuleList()
Create the encoded standard form of a RuleList. The existence of a mapping is pre-supposed. This builds a list of all the rules in the form:
 cons( cons( rule1.left,
             rule1.right),
       cons( cons( rule2.left,
                   rule2.right),
             ...
                   cons( cons( ruleN.left,
                               ruleN.right),
                         empty) ... ))
 

Returns:
The encoded rulelist
See Also:
codifyTree(LinkedList)

createMap

private void createMap(ASTNode node)
Create a mapping between function symbols and numbers for a tree.

Parameters:
node - The tree a mapping shall be created for

getCodifiedRuleList

public ASTNode getCodifiedRuleList()
Returns the previously computed codified rulelist.

Returns:
null if the list was not computed previously, else the list

getCodifiedInstance

public ASTNode getCodifiedInstance()
Returns the previously computed codified instance.

Returns:
null if the list was not computed previously, else the instance