org.xmloperator.lambda2.net.impl
Class LambdaNetImpl

java.lang.Object
  extended byorg.xmloperator.lambda2.net.impl.LambdaNetImpl
All Implemented Interfaces:
LambdaNet

public final class LambdaNetImpl
extends java.lang.Object
implements LambdaNet

LambdaNet implementation.


Constructor Summary
LambdaNetImpl()
          Constructor of a LambdaNet that represents a free variable.
LambdaNetImpl(PortImpl bodySupport)
          Constructor of a cloned LambdaNet.
 
Method Summary
 boolean booleanValue(int[] interactionStat)
          Returns the boolean value of the Term (K or F) represented by this LambdaNet.
 void buildAbstraction()
          Transforms this LambdaNet in such a way that its represented lambda term "t" is replaced by the abstraction "\x.t", where "x" doesn't occur within t.
 void buildAbstraction(Port freeVariableSupport)
          Transforms this LambdaNet in such a way that its represented lambda term "t" is replaced by the abstraction "\x.t", where "x" is bound to the given variable of "t".
 void buildAbstraction(Port[] freeVariableSupports)
          Transforms this LambdaNet in such a way that its represented lambda term "t" is replaced by the abstraction "\x.t", where "x" is bound to the given variables of "t".
 void buildApplication(LambdaNet argument)
           Transforms this LambdaNet in such a way that its represented lambda term "t" is replaced by the application "tu" where "u" is the lambda term represented by the given LambdaNet.
 void buildApplication(LambdaNet argument, int functionExponent)
           Transforms this LambdaNet in such a way that its represented lambda term "t" is replaced by the application "(t^n)u" where "u" is the lambda term represented by the given LambdaNet and "n" an exponent.
 int cellCount()
          Returns the count of cells of this LambdaNet.
 Port getBodySupport()
          Returns the free Port that supports the interaction-net body.
 int getFreeVariableCount()
          Returns the count of free variables.
static void main(java.lang.String[] args)
           
 long numeralValue(int[] interactionStat)
          Returns the value modulo 2^63 of the Church numeral Term represented by this LambdaNet.
 void printNet(java.io.PrintStream out)
          Print a graph representation of this LambdaNet.
 void printStat(java.io.PrintStream out)
          Print a statistic of symbols of this LambdaNet.
 Term readBack(boolean inNormalForm, int maxStepCount, int[] interactionStat)
          Read back the Term represented by this LambdaNet.
 int reduceUntilInterfaceNormalForm(int maxStepCount, int[] interactionStat)
          Reduces this LambdaNet until the interface has a normal form.
static boolean test(java.io.PrintStream out, boolean isVerbose)
          Try some LambdaNets.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LambdaNetImpl

public LambdaNetImpl()
Constructor of a LambdaNet that represents a free variable.


LambdaNetImpl

public LambdaNetImpl(PortImpl bodySupport)
Constructor of a cloned LambdaNet.

Parameters:
bodySupport - a source LambdaNet body support.
Method Detail

printNet

public void printNet(java.io.PrintStream out)
Print a graph representation of this LambdaNet.

Parameters:
out - a PrintStream.

printStat

public void printStat(java.io.PrintStream out)
Print a statistic of symbols of this LambdaNet.

Parameters:
out - a PrintStream.

cellCount

public int cellCount()
Returns the count of cells of this LambdaNet.

Returns:
the count of cells of this LambdaNet.

main

public static void main(java.lang.String[] args)

test

public static boolean test(java.io.PrintStream out,
                           boolean isVerbose)
Try some LambdaNets.

Parameters:
out - the PrintStream to print results.
isVerbose - if true then all tests have to be displayed.
Returns:
true if all is Ok.

getBodySupport

public Port getBodySupport()
Description copied from interface: LambdaNet
Returns the free Port that supports the interaction-net body.

Specified by:
getBodySupport in interface LambdaNet
Returns:
the free Port that supports the interaction-net body.

getFreeVariableCount

public int getFreeVariableCount()
Description copied from interface: LambdaNet
Returns the count of free variables.

Specified by:
getFreeVariableCount in interface LambdaNet
Returns:
the count of free variables.

buildAbstraction

public void buildAbstraction()
Description copied from interface: LambdaNet
Transforms this LambdaNet in such a way that its represented lambda term "t" is replaced by the abstraction "\x.t", where "x" doesn't occur within t.

Specified by:
buildAbstraction in interface LambdaNet

buildAbstraction

public void buildAbstraction(Port freeVariableSupport)
Description copied from interface: LambdaNet
Transforms this LambdaNet in such a way that its represented lambda term "t" is replaced by the abstraction "\x.t", where "x" is bound to the given variable of "t".

Specified by:
buildAbstraction in interface LambdaNet
Parameters:
freeVariableSupport - a support of free variable.

buildAbstraction

public void buildAbstraction(Port[] freeVariableSupports)
Description copied from interface: LambdaNet
Transforms this LambdaNet in such a way that its represented lambda term "t" is replaced by the abstraction "\x.t", where "x" is bound to the given variables of "t".

Specified by:
buildAbstraction in interface LambdaNet
Parameters:
freeVariableSupports - a set of 0 or more support of free variable.

buildApplication

public void buildApplication(LambdaNet argument)
Description copied from interface: LambdaNet

Transforms this LambdaNet in such a way that its represented lambda term "t" is replaced by the application "tu" where "u" is the lambda term represented by the given LambdaNet.

The argument LambdaNet is consumed by the operation and is no more usable.

Specified by:
buildApplication in interface LambdaNet
Parameters:
argument - an argument LambdaNet.

buildApplication

public void buildApplication(LambdaNet argument,
                             int functionExponent)
Description copied from interface: LambdaNet

Transforms this LambdaNet in such a way that its represented lambda term "t" is replaced by the application "(t^n)u" where "u" is the lambda term represented by the given LambdaNet and "n" an exponent.

The argument LambdaNet is consumed by the operation and is no more usable.

Specified by:
buildApplication in interface LambdaNet
Parameters:
argument - an argument LambdaNet.
functionExponent - a function exponent

reduceUntilInterfaceNormalForm

public int reduceUntilInterfaceNormalForm(int maxStepCount,
                                          int[] interactionStat)
                                   throws TooMuchReductionStepException
Description copied from interface: LambdaNet
Reduces this LambdaNet until the interface has a normal form.

Post-condition: the body port is a principal Port or a free Port.

Specified by:
reduceUntilInterfaceNormalForm in interface LambdaNet
Parameters:
maxStepCount - a maximun step count. A negative value means no limit.
interactionStat - an array of interaction type count. May be null.
Returns:
the count of reducing step.
Throws:
TooMuchReductionStepException - if the given maximum count of step is not sufficient to obtain an interface normal form.

readBack

public Term readBack(boolean inNormalForm,
                     int maxStepCount,
                     int[] interactionStat)
              throws TooMuchReductionStepException
Description copied from interface: LambdaNet
Read back the Term represented by this LambdaNet.

Pre-condition: this LambdaNet must have no free variable.

Specified by:
readBack in interface LambdaNet
Parameters:
inNormalForm - if true then returns a Term in normal form.
maxStepCount - a maximum step count. A negative value means no limit.
interactionStat - an array of interaction type count. May be null.
Returns:
the Term read back from this LambdaNet.
Throws:
TooMuchReductionStepException - if the given maximum count of step is not sufficient to obtain a normal form or an interface normal form.

booleanValue

public boolean booleanValue(int[] interactionStat)
Description copied from interface: LambdaNet
Returns the boolean value of the Term (K or F) represented by this LambdaNet.

Specified by:
booleanValue in interface LambdaNet
Parameters:
interactionStat - an array of interaction type count. May be null.
Returns:
the boolean value of the Term (K or F) represented by this LambdaNet.

numeralValue

public long numeralValue(int[] interactionStat)
Description copied from interface: LambdaNet
Returns the value modulo 2^63 of the Church numeral Term represented by this LambdaNet. Returns -1 if this LambdaNet doesn't represent a Church numeral.

Specified by:
numeralValue in interface LambdaNet
Parameters:
interactionStat - an array of interaction type count. May be null.
Returns:
the value modulo 2^63 of the Church numeral Term represented by this LambdaNet. Returns -1 if this LambdaNet doesn't represent a Church numeral.