Reading time: about 1 minute (296 words).

Jython Examples

This page describes how we used Jython and the UACalc together to find a counterexample for a project involving universal algebra and CSP research.

Scala examples are described on this page.

Bergman: varieties generated by finite algebras

Here we describe how to read in a bunch of algebras and test whether the varieties they generate have certain properties. (This example was used for joint work with Cliff Bergman.)

We have some files in the UACalc/Algebra directory called Alg1.ua, Alg2.ua,..., Alg9.ua each one containing a finite idempotent algebra, and we want to check whether the varieties generated by these algebras are congruence distributive or congruence permutable.

Freese and Valeriote [1] discovered polynomial time algorithms to test for these properties, and implemented them in the UACalc.

Here's how one could use Jython to call the UACalc methods that perform these tests:

from org.uacalc.alg.Malcev import isCongruenceDistIdempotent
from org.uacalc.alg.Malcev import cpIdempotent
from org.uacalc.io import AlgebraIO

homedir = "/home/williamdemeo/git/UACalc/"

outfile1 = open(homedir+"isCD.txt", 'w')
outfile2 = open(homedir+"isCP.txt", 'w')

for k in range(1,10):
  algname = "Alg"+str(k)
  algfile = homedir+"Algebras/"+algname+".ua"
  A = AlgebraIO.readAlgebraFile(algfile)
  outfile1.write(algname+"   "+str(isCongruenceDistIdempotent(A, None))+"\n")
  outfile2.write(algname+"   "+str((cpIdempotent(A, None)==None))+"\n")

outfile1.close()
outfile2.close()

The output will be stored in the isCD.txt and isCP.txt files, and will look something like this:

    Alg1    True
    Alg2    True
    Alg3    False
    Alg4    True...

with True in the isCD.txt (resp, isCP.txt) file meaning the algebra generates a variety that is congruence distributive (resp, permutable).

References

[1] Ralph Freese and Matthew Valeriote, On the complexity of some Maltsev conditions, Intern. J. Algebra & Computation, 19(2009), 41-77.