A command line and scripting version of UACalc using Jython

by

William DeMeo and Ralph Freese

Jython is an implementation of (the scripting language) Python in Java. It has the advantage (for us) that it can read Java libraries including the uacalc.jar library.

Up-todate documentation

Setup

  • Get the tar (zip) file: UACalc.tar and untar it in your home directory. This will make a directory called UACalc and subdirectories Algebras, Examples and UACalc_CLI.

Executing scripts and running it interactively

  • You run it with the command ~/UACalc/UACalc_CLI/uacalc. You may want to put (or link) the uacalc file in a directory in your path.

  • Change into the UACalc subdirectory and look at the file AlgebraConstructionExample.py in the Examples subdirectory. This gives an example script showing how to use python to construct an algebra.

  • Now run it with the command uacalc AlgebraConstructionExample.py
    This will create two algebra files in the Algebras directory (which can be loaded into UACalc).

  • More detailed instructions on William DeMeo's page. This also has instructions for more advanced setups, say with and IDE.

An interactive session

  • You can call some hidden methods: for example, if you go to the javadoc link, click on CongruenceLattice on the left, you will find a method

    commutator(BinaryRelation S, BinaryRelation T).

    (There are also methods for the weak and strong rectangularity commutators, as well as centrality methods.)

  • The sample interactive session below
    • First reads in the algebra f3 (the reduct of the three element field to multiplication).
    • Then checks its cardinality.
    • Then derfines theta to be the nontrivial congruence and defines one to be the top.
    • Then checks the commutator [theta,one] = zero but [one,theta] = theta.
    • Then quits.
    [ralph@mahiloa UACalc]$ uacalc
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    Welcome to the command line version of UACalc!
      to exit type quit()
      (more help coming)
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    >>> f3 = AlgebraIO.readAlgebraFile("Algebras/f3.ua")
    >>> f3.cardinality()
    3
    >>> conlat = f3.con().getUniverseList()
    >>> conlat
    [|0|1|2|, |0|1,2|, |0,1,2|]
    >>> theta = conlat[1]
    >>> theta
    |0|1,2|
    >>> one = conlat[2]
    >>> one
    |0,1,2|
    >>> f3.con().commutator(theta,one)
    |0|1|2|
    >>> f3.con().commutator(one,theta)
    |0|1,2|
    >>> quit()