Sunday, July 24, 2022

Changes to the copresheaf viewer

The basic objects of the Locus computer algebra system are copresheaves. Locus implements all my original research and ideas about copresheaves and their congruences, and these ideas in turn have influenced my ideas on the use of copresheaf theory in foundations. Once we have established sufficient motivation for wanting to work in terms of copresheaves, it would be nice as a next step to develop tools to make it easier to work with them.

The first such tool I have devised to work with them is the copresheaf viewer. This was implemented in a very small amount of lines of Clojure code using Graphviz and Swing. It consisted of two components: a view of the source category as displayed by Graphviz and a JList used for interacting with the objects and morphisms of the category. These two components are combined in a split pane as seen below. The problems with this user interface design approach are apparent from the get go. This approach is clearly not scalable.
  • You should be able to interact with the index category in place, rather then having to separately go to the JList to access an item. Imagine if we had a large index category with hundreds of objects and morphisms, then you would have to scroll through all of them to find what you are looking for. Instead you should be able to click an object or morphism in place.
  • The view of the source category should be pannable and zoomable. This will allow you to interact with increasingly large source categories, with hundreds of objects and morphisms so that you can find exactly what you are looking for.
So we need a sort of pannable, zoomable, interactive directed graph viewer. It is clear that JavaFX is the technology for this, as Swing is not suitable for designing applications with advanced graphical transformations. A scene graph, like what is provided by JavaFX, is precisely the sort of technical appartus that is needed for this type of job. Three JavaFX graph editor like programs are available and have been considered: I seriously considered each of these options, because I didn't want to create a JavaFX graph editor myself. Unfortunately, none of theme seems to have the idea of displaying categories in mind. In order to display a category we need to support multiple labeled directed edges. Many of these graph editors don't support labeled edges or perhaps even multiple edges, especially the last two. The first one seems to be specifically concerned with the Eclipse modeling foundation technologies, which is a whole different concern entirely.

Another issue is that these graph editors might not have support for adding event listeners on their vertices and edges. Even if they do, they might have the documentation to describe it. Basically, I have a very specific use case: creating interactive displays of categories. This explains why I created my own JavaFX copresheaf viewer, although I didn't set out to do so. At least with this, you can directly click on an object or a morphism to get its corresponding output, without having to go through a JList. It also supports zooming and panning, so you can get a much better handle on some copresheaves. I want everything in general, but in Locus especially, to go through some kind of copresheaf so this viewer is really the key to everything in our whole algebra system.

The copresheaf viewer is programmed in Java. In order to call it from Clojure, we reify a GraphActionListener with vertex and edge actions that apply the copresheaf to its corresponding objects and morphisms and this works fine for now. This gives us an interactive handle on copresheaves, which works pretty good for now.

The only limitation of this approach is that it has limited capabilities for handling graph layouts. I support a simple mechanism for layouting directed acyclic graphs from their partial orders using a ranking like a Hasse diagram. This is good for a number of simple categories, but for anything else you may have to hand hold the copresheaf viewer so that it lays out the objects of the category appropriately.

One thing that is nice is that if you are viewing an MSet in the JavaFX copresheaf viewer, the loops of the source category of the MSet do not overlap so you can more easily access them. I implemented this with a simple algorithm that goes around the node and places the loops separately so they don't overlap. This didn't even always occur in the Graphviz viewer, which despite working great for almost everything also wasn't built with displaying categories in mind. An option I have considered is using JNI or some other solution to access Graphviz layout mechanisms.

It is clear that no graphical user interface program is perfect, and both my copresheaf viewer and to a much lesser extent Graphviz could use some improvements. I look forward to even being able to replace this JavaFX copresheaf viewer with something else, as long as it works better. The most important thing is achieving the vision of a computing environment based upon presheaf theory, however, that happens.

All I have is a grand vision of presheaf theory involving mathematical means of reasoning about presheaves, data structures and algorithms for running computations involving copresheaves, ideas for how to graphically and interactively display copresheaves, new presheaf theoretic mechanisms for creating ontologies, etc. The Locus project is nothing more then the embodiment of this mathematical vision.

The transference of attention to presheaf topos theory is just the first step in building the future of computing. Once you work in presheaf theory, it is possible to create new topos theoretic ontologies and a geometry of computation. Foundations are important, and so it is only by using topos theoretic foundations that these great avenues of exploration can be made available.

No comments:

Post a Comment