/* Research Project: Graphical Database for Category Theory J. Bradbury, Dr. R. Rosebrugh, I. Rutherford Mount Allison University 2001 M. Graves, J. Tweedle Updated: May 8th, 2003 File: Mono.java Description: This class contains the code to test a given category for monomorphisms. It is used only by the MonoFrame class. */ public class Mono { private Category cat; private int nummonos; private String output; private boolean supress_output; private boolean endopassed; public Mono(Category newCat) { cat = newCat; nummonos = 0; output = ""; supress_output = false; endopassed = false; } public void generate_monos(int path[], int domain, HomTree pathtree, int maxloop) /* Parameters: path: the current path domain: the current object of the path codomain: the object we are trying to find all arrows to objects: an array of integers which keeps the function from exceeding the maximum number of loops yestree: tree of verified monomorphisms notree: tree of verified non-monomorphisms Purpose: To find all monomorphisms from domain to codomain */ { int i, j, len, number, endo = 0; int arrow_array[] = new int [cat.num_arrows]; path = cat.reduce(path); len = cat.path_len(path); if (path[0] == -2) path[0] = -1; for (i=0; i 0) { if (ismono(path)) { output+=cat.path_to_string(path) + " is a monomorphism!\n"; nummonos++; } } number = cat.all_arr(domain, arrow_array); if (number > 0) for (i=0; i=0; j--) path[j+1] = path[j]; path[0] = arrow_array[i]; generate_monos(path, cat.arr[arrow_array[i]][1], pathtree, maxloop); for (j=0; j<=len; j++) path[j] = path[j+1]; } } } else endopassed = true; } boolean ismono(int[] mono) { int path[] = new int[cat.ini.getMAXWORD()]; HomTree alphatree, amonotree, pathtree; int obj, codomain; codomain = cat.arr[mono[cat.path_len(mono)-1]][0]; for (obj=0; obj=0; j--) path[j+1] = path[j]; path[0] = arrows[i]; // check recursively if (!check_mono(alphatree, amonotree, mono, path, cat.arr[path[0]][1], codomain, pathtree)) return false; // now remove the arrow and object from the path for (j=0; j<=pathlen; j++) path[j] = path[j+1]; } // if we're at the second object, then add the path to the tree if (path[0] != -1 && cat.arr[path[0]][1] == codomain) { int alpha[] = cat.reduce(path); if (alphatree.addPath(alpha)) { alpha = cat.reduce(cat.append_path(path, mono)); if (!amonotree.addPath(alpha)) return false; } } } } else endopassed = true; return true; } public int getNumMonos() { return nummonos; } public void setNumMonos(int newNumMonos) { nummonos = newNumMonos; } public String getOutput() { return output; } public void setOutput(String newOutput) { output = newOutput; } public boolean getSupressOutput() { return supress_output; } public void setSupressOutput(boolean newSupressOutput) { supress_output = newSupressOutput; } public boolean getEndoPassed() { return endopassed; } public void setEndoPassed(boolean newEndoPassed) { endopassed = newEndoPassed; } }