/* Research Project: Graphical Database for Category Theory J. Bradbury, Dr. R. Rosebrugh, I. Rutherford Mount Allison University 2001 File: CatFunctor.java Description: This class is equivalent to a struct in C/C++. It contains all of the information that is needed to create a functor node */ public class CatFunctor { IniSettings ini = new IniSettings(); String filename; String name; int[] obj = new int[ini.getMAXWORD()]; int[][] arr = new int [ini.getMAXARR()][ini.getMAXWORD()]; public boolean check_domain(int path[], int arrow, Category A, Category B) /* Parameters: path: the path in B that the arrow goes to under the functor arrow: the arrow of A that goes to the path under the functor f: a category functor A: the category that the functor goes from B: the category that the functor goes to Purpose: To check that the object which is the domain of the arrow in A goes to the object which is the domain of the path in B that the arrow goes to under the functor Design: Returns true if the domains match up, false otherwise */ { //System.out.println("domain : " + B.arr[path[B.path_len(path)-1]][0] + " codomain: " + B.arr[path[0]][1]); //System.out.println("domain : " + obj[A.arr[arrow][0]] + " codomain: " + obj[A.arr[arrow][1]]); //System.out.println("arrow: " + arrow + " A.: " + A.arr[arrow][0]); if(obj[A.arr[arrow][0]] != B.arr[path[B.path_len(path)-1]][0]) { // System.out.println("inside cat functor: " + obj[A.arr[arrow][0]] + " != " + B.arr[path[B.path_len(path)-1]][0]); //new MessageDialog(this, "Error", B.path_to_string(path) + " has an invalid domain.", true); System.out.println("Error: " + B.path_to_string(path) + " has an invalid domain."); return(false); } return(true); } public boolean check_codomain(int path[], int arrow, Category A, Category B) //This function checks that the object which is the codomain of the arrow in //A goes to the object which is the codomain of the path in B that the arrow goes //to under the functor. It returns true if the codomains match up, false otherwise { if(obj[A.arr[arrow][1]] != B.arr[path[0]][1]) { //new MessageDialog(this, "Error", B.path_to_string(path) + " has an invalid codomain.", true); System.out.println("Error: "+ B.path_to_string(path) + " has an invalid codomain."); return(false); } return(true); } }