org.uacalc.alg.op
Class Operations

java.lang.Object
  extended by org.uacalc.alg.op.Operations

public class Operations
extends java.lang.Object

This is a factory class with static methods to make Operations.


Method Summary
static void binaryOpToCSV(java.lang.String desc, Operation binop, java.io.PrintStream out)
           
static boolean commutes(int[] map, Operation op0, Operation op1)
          Test if map defines a homomorphism wrt these operations.
static boolean commutes(Operation unaryOp, Operation op)
          This tests if an operation commutes with a unary operation.
static boolean equalValues(Operation op0, Operation op1)
          Test if these have the same int values on the common sized set.
static int[] findDifference(Operation op0, Operation op1)
          Find an argument where these operations differ.
static boolean isAssociative(Operation op)
          Test if an operation is binary and associative.
static boolean isCommutative(Operation op)
          Test if an operation is binary and commutative.
static boolean isIdempotent(Operation op)
          Test if an operation is idempotent.
static boolean isTotal(Operation op)
           
static boolean isTotallySymmetric(Operation op)
          Test if an operation is totally symmetric; that is, invariant under all permutation of the variables.
static void main(java.lang.String[] args)
           
static Operation makeBinaryIntOperation(OperationSymbol symbol, int algSize, int[][] table)
           
static Operation makeCompositionOp(int n, int pow)
           
static Operation makeConstantIntOperation(int algSize, int elt)
           
static Operation makeConstantIntOperation(java.lang.String symbolPrefix, int algSize, int elt)
           
static Operation makeDerivedOperation(Operation op, int[] reductionArray, int newArity)
          The operation derived by equating variables.
static Operation makeIntOperation(Operation opx)
          This makes a new operation that agrees with the original but is table based and so faster.
static Operation makeIntOperation(OperationSymbol symbol, int algSize, int[] valueTable)
          Construct an Operation from a valueTable.
static Operation makeIntOperation(java.lang.String symbol, int arity, int algSize, int[] valueTable)
          Construct an Operation from a valueTable.
static java.util.List<Operation> makeIntOperations(java.util.List<Operation> ops)
           
static java.util.List<Operation> makeJonssonOperationsFromNUF(Operation nuf)
          Make the Jonsson terms from a near unanimity operation, omitting the two projections.
static Operation makeLeftShift(int vecSize, int rootSize)
          The unary operation that cyclically shifts a vector left.
static java.util.Map<OperationSymbol,Operation> makeMap(java.util.List<Operation> ops)
          This makes a hash map from the operation symbols to the operations.
static Operation makeMatrixDiagonalOp(int vecSize, int rootSize)
           
static Operation makeOperationFromScript(OperationSymbol symbol, int arity, int algSize, java.lang.String[] script)
          The script should be the body of the definition of intValueAt(int[] args).
static Operation makeRandomOperation(int n, OperationSymbol opSym)
          Make an operation with the the given opeation symbol and set size.
static Operation makeRandomOperation(int n, OperationSymbol opSym, java.util.Random random)
          Make an operation with the the given opeation symbol and set size.
static java.util.List<Operation> makeRandomOperations(int n, SimilarityType simType)
          Make a list of operations corresponding to a similarity type and a set size.
static java.util.List<Operation> makeRandomOperations(int n, SimilarityType simType, long seed)
          Make a list of operations corresponding to a similarity type and a set size.
static int power(int base, int pow)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

commutes

public static boolean commutes(Operation unaryOp,
                               Operation op)
This tests if an operation commutes with a unary operation. It can be used to test if an operation is a endomorphism (or automorphism).


commutes

public static boolean commutes(int[] map,
                               Operation op0,
                               Operation op1)
Test if map defines a homomorphism wrt these operations. The operations must have the same arity.

Parameters:
map - an array defining the map
op0 - the first operation
op1 - the second operation
Returns:
true or false

isTotal

public static boolean isTotal(Operation op)

isIdempotent

public static final boolean isIdempotent(Operation op)
Test if an operation is idempotent.


isCommutative

public static final boolean isCommutative(Operation op)
Test if an operation is binary and commutative.


isTotallySymmetric

public static final boolean isTotallySymmetric(Operation op)
Test if an operation is totally symmetric; that is, invariant under all permutation of the variables.


isAssociative

public static final boolean isAssociative(Operation op)
Test if an operation is binary and associative.


findDifference

public static final int[] findDifference(Operation op0,
                                         Operation op1)
Find an argument where these operations differ.

Parameters:
op0 -
op1 -
Returns:
an int[] as a witness or null if they agree.
Throws:
java.lang.IllegalArgumentException - if the arities or set sizes differ.

makeMap

public static java.util.Map<OperationSymbol,Operation> makeMap(java.util.List<Operation> ops)
This makes a hash map from the operation symbols to the operations.


equalValues

public static boolean equalValues(Operation op0,
                                  Operation op1)
Test if these have the same int values on the common sized set. So they are equal except they may have different symbos


makeRandomOperation

public static Operation makeRandomOperation(int n,
                                            OperationSymbol opSym)
Make an operation with the the given opeation symbol and set size.

Parameters:
n - the set size
opSym - the operation symbol
Returns:
the operation

makeRandomOperation

public static Operation makeRandomOperation(int n,
                                            OperationSymbol opSym,
                                            java.util.Random random)
Make an operation with the the given opeation symbol and set size.

Parameters:
n - the set size
opSym - the operation symbol
random - a random number generator.
Returns:
the operation

makeRandomOperations

public static java.util.List<Operation> makeRandomOperations(int n,
                                                             SimilarityType simType)
Make a list of operations corresponding to a similarity type and a set size.

Parameters:
n - the set size
simType - the similarity type
Returns:
a list of operations

makeRandomOperations

public static java.util.List<Operation> makeRandomOperations(int n,
                                                             SimilarityType simType,
                                                             long seed)
Make a list of operations corresponding to a similarity type and a set size.

Parameters:
n - the set size
simType - the similarity type
seed - a random seed or -1
Returns:
a list of operations

makeDerivedOperation

public static Operation makeDerivedOperation(Operation op,
                                             int[] reductionArray,
                                             int newArity)
The operation derived by equating variables. If f(x,y,z) is an operation and [1, 0, 1] is the reductionArray, then the derived operation is g(x,y) = f(y,x,y).

Parameters:
reductionArray - an int array that can be viewed as a map from the int less than the arity of op into the arity of the derived operation.

makeJonssonOperationsFromNUF

public static java.util.List<Operation> makeJonssonOperationsFromNUF(Operation nuf)
Make the Jonsson terms from a near unanimity operation, omitting the two projections. See the file nuf.pdf.


power

public static final int power(int base,
                              int pow)

makeLeftShift

public static Operation makeLeftShift(int vecSize,
                                      int rootSize)
The unary operation that cyclically shifts a vector left.


makeMatrixDiagonalOp

public static Operation makeMatrixDiagonalOp(int vecSize,
                                             int rootSize)

makeCompositionOp

public static Operation makeCompositionOp(int n,
                                          int pow)

makeOperationFromScript

public static Operation makeOperationFromScript(OperationSymbol symbol,
                                                int arity,
                                                int algSize,
                                                java.lang.String[] script)
                                         throws javax.script.ScriptException
The script should be the body of the definition of intValueAt(int[] args).

Throws:
javax.script.ScriptException

makeIntOperations

public static java.util.List<Operation> makeIntOperations(java.util.List<Operation> ops)

makeIntOperation

public static Operation makeIntOperation(Operation opx)
This makes a new operation that agrees with the original but is table based and so faster.

Parameters:
opx - the original operation
Returns:
the new operation

makeIntOperation

public static Operation makeIntOperation(java.lang.String symbol,
                                         int arity,
                                         int algSize,
                                         int[] valueTable)
Construct an Operation from a valueTable.

Parameters:
valueTable - a Horner encode table of the values of the operation.

makeIntOperation

public static Operation makeIntOperation(OperationSymbol symbol,
                                         int algSize,
                                         int[] valueTable)
Construct an Operation from a valueTable.

Parameters:
valueTable - a Horner encode table of the values of the operation.

makeBinaryIntOperation

public static Operation makeBinaryIntOperation(OperationSymbol symbol,
                                               int algSize,
                                               int[][] table)

makeConstantIntOperation

public static Operation makeConstantIntOperation(int algSize,
                                                 int elt)

makeConstantIntOperation

public static Operation makeConstantIntOperation(java.lang.String symbolPrefix,
                                                 int algSize,
                                                 int elt)

binaryOpToCSV

public static void binaryOpToCSV(java.lang.String desc,
                                 Operation binop,
                                 java.io.PrintStream out)

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Throws:
java.lang.Exception


Copyright 2003 Ralph Freese. All Rights Reserved.