# Optionally, write the algebra to a UACalc file that can be loaded into the gui.
    AlgebraIO.writeAlgebraFile(alg, "../../Algebras/Example2_MutliunaryAlgebra.ua")
    print "UACalc algebra file created: ../../Algebras/Example2_MutliunaryAlgebra.ua"
    
    

print "\n\n---- Example 3 ----"
print "The congruence lattice of a congruence lattice."
print "\nThe congruence lattice Con(A) of the algebra A is itself an algebra (specifically, a lattice)."
print "We represent it in UACalc as an object of the class BasicLattice.  UACalc represents the" 
print "universe of an algebra of cardinality n with integers {0, 1, ..., n-1}, and in some cases"
print "it is important to know to what elements these integers correspond."

print "\nFor example, suppose we read in Polin's algebra from the file polin.ua, and name this algebra P,"
P = AlgebraIO.readAlgebraFile("../../Algebras/polin.ua")

print "and suppose we then construct an algebra that is the congruence lattice of P (using the convenient"
print "and fast UACalc con() method), and call this algebra conP."
conP = BasicLattice("conP", P.con(), 0)

print "\nWe can print the universe of conP with"
print "\n    conP.universe(): ", conP.universe()

print "\nNow suppose we want the congruence lattice of the algebra conP.  "
print "\n    conP.con().universe() gives ", conP.con().universe()

print "\nTo make use of this result, we must know to which elements of conP.universe() the"
print "integers appearing in the blocks of conP.con().universe() correspond."

n = conP.cardinality()
示例#2
0
if os.path.exists("../../Algebras"):

    # Optionally, write the algebra to a UACalc file that can be loaded into the gui.
    AlgebraIO.writeAlgebraFile(alg,
                               "../../Algebras/Example2_MutliunaryAlgebra.ua")
    print "UACalc algebra file created: ../../Algebras/Example2_MutliunaryAlgebra.ua"

print "\n\n---- Example 3 ----"
print "The congruence lattice of a congruence lattice."
print "\nThe congruence lattice Con(A) of the algebra A is itself an algebra (specifically, a lattice)."
print "We represent it in UACalc as an object of the class BasicLattice.  UACalc represents the"
print "universe of an algebra of cardinality n with integers {0, 1, ..., n-1}, and in some cases"
print "it is important to know to what elements these integers correspond."

print "\nFor example, suppose we read in Polin's algebra from the file polin.ua, and name this algebra P,"
P = AlgebraIO.readAlgebraFile("../../Algebras/polin.ua")

print "and suppose we then construct an algebra that is the congruence lattice of P (using the convenient"
print "and fast UACalc con() method), and call this algebra conP."
conP = BasicLattice("conP", P.con(), 0)

print "\nWe can print the universe of conP with"
print "\n    conP.universe(): ", conP.universe()

print "\nNow suppose we want the congruence lattice of the algebra conP.  "
print "\n    conP.con().universe() gives ", conP.con().universe()

print "\nTo make use of this result, we must know to which elements of conP.universe() the"
print "integers appearing in the blocks of conP.con().universe() correspond."

n = conP.cardinality()
示例#3
0
f0 = 7,6,6,7,3,2,2,3
f1 = 0,1,1,0,4,5,5,4
f2 = 0,2,3,1,0,2,3,1
ff = f0, f1, f2

name = "Example3"    
if os.path.exists("../Algebras"):
    fqname3 = '../Algebras/'+name+'.ua'
else:
    fqname3 = name+'.ua'

print "Writing algebra to file ", fqname3
write_unaryalgebra(ff, fqname3)


alg = AlgebraIO.readAlgebraFile(fqname3)

print "\nQuick check that we constructed an algebra:"
print "   alg.getName() = ", alg.getName()        
print "   alg.universe() = ", alg.universe()
    




print "\n\n---- Example 4 ----"
print "The congruence lattice of a congruence lattice."
print "\nThe congruence lattice Con(A) of the algebra A is itself an algebra (specifically, a lattice)."
print "We represent it in UACalc as an object of the class BasicLattice.  UACalc represents the" 
print "universe of an algebra of cardinality n with integers {0, 1, ..., n-1}, and in some cases"
print "it is important to know to what elements these integers correspond."