Compositional Computational Systems
Total Page:16
File Type:pdf, Size:1020Kb
Institute for Dynamic Systems and Control Swiss Federal Institute of Technology Zürich Master’s Thesis Compositional Computational Systems Aleksandar Petrov Supervision Gioele Zardini Dr. Andrea Censi Prof. Dr. Emilio Frazzoli October 2020 Zürich Contents Contents ii 1 Introduction 1 Part I Compositional problem-solving 9 2 Mathematical preliminaries 11 2.1 Posets .................................. 11 2.2 Category theory ............................ 13 2.3 Anonymous functions ........................ 20 2.4 Type theory .............................. 22 3 Normed types and procedures 27 3.1 Normed types ............................. 27 3.2 Procedures ............................... 34 4 Relationships between problems and solutions 43 4.1 Problems ................................ 44 4.2 Solutions ................................ 46 4.3 Lagado ................................. 48 4.4 Lagado as a heteromorphic twisted category . 57 5 Compositional systems and relations 61 5.1 Compositional systems ........................ 61 5.2 Relationships between compositional systems . 63 5.3 The kinded nature ........................... 67 5.4 The categorical connection ...................... 68 5.5 Categorical representations of some compositional systems . 71 5.6 Categorical representations of some kinded relations . 73 ii Contents iii 6 Compositional computational systems 81 6.1 Generalized problems and procedures . 82 6.2 Laputa ................................. 89 6.3 Lagado and Laputa .......................... 91 6.4 Functorial problems and procedures . 93 6.5 Probabilistically correct solutions . 97 Part II Co-design and compositional computation 103 7 The mathematical theory of co-design 105 7.1 A bit more order theory . 106 7.2 Design problems . 108 8 Solving design problems 113 8.1 Representation of a solution . 113 8.2 Composition of solution maps . 120 8.3 Fixpoints and feedback . 122 8.4 Well-behaved design problems . 128 9 Compositional properties of co-design 131 9.1 The categories of upper and lower sets . 131 9.2 Co-design problems and Lagado . 136 9.3 Functorial relationships . 138 9.4 Monoidal properties . 141 9.5 Locally lattical structure . 148 9.6 Trace and feedback . 150 9.7 Bonus: Interpretation with monads . 156 10 Design problems and compositional computation 165 10.1 Design problems are problems . 165 10.2 Design problems are a problem . 168 10.3 Design problems are a problem with lots of structure . 170 10.4 Answers of design problems can also have extra structure . 178 11 Conclusion 181 Bibliography 185 Chapter 1 Introduction If we are to summarize the topic of this thesis succinctly, perhaps the best way would be to say that it deals with problems, their solutions, and the relationships between the two. We are surrounded by countless problems in our everyday lives, many of which we can’t escape from solving. Hence, we all frequently find ourselves face to face with the task of solving problems. However, given its importance, how many of us have stopped to think about or study the process of problem-solving? This thesis is an exercise in investigating exactly this question: what is problem-solving and how to do it in the best possible way. We are surrounded by thousands of problems and very few solutions. But why is problem-solving so difficult? Well, for once, problems are often not specified well-enough. Making a “fair” legal system or a “safe” autonomous car are examples of problems that cannot be solved until one clarifies what “fair” and “safe” even mean. But even if a problem is unambiguously defined, and is solvable, it does not mean that we are done. Often we have to pick one among a collection of different solutions, many of which are not dominated by another. This is usually a big pain when planning a trip or a holiday. There might be dozens of different ways to get to your destination, each with different costs, taking different time, with different modes of transportation, and with many different characteristics. Picking the “right” option can be very stressful and often takes quite a toll on the holiday-planner. But there’s some light in the tunnel. Even the hardest problems become much easier if we find a way to reduce them to problems that we already know how to solve. And we use this technique a lot! We can reduce the problem of filling in our tax return to the problem of hiring an accountant, which can be much easier. 1 2 Chapter 1. Introduction Or we can reduce the problem of evaluating a neural network to the problem of matrix multiplication, which we know how to do very efficiently. Hence, this philosophy of problem reduction indeed seems to be quite handy for any problem-solver. Often when one struggles with solving or understanding something, the most important question to ask is if they are solving the right problem. Or it could be that the problem is ambiguously defined or defined in inconsistent ways. Sometimes, especially when multiple people are involved, this can also be a result of some sort of miscommunication. It often happens that one party has one thing in mind, but the other interprets it completely differently. While neither side is really at fault here, there are strategies to help in this kind of situation. This is where formal systems come into play. Using formalisms allow us to define and handle various objects and concepts unambiguously and consistently. Hence, we can also communicate while being sure that both parties interpret the problem in the same way: the only way. It is not surprising that mathematicians are perhaps the most agreeable trope of the science and engineering world: they tend to define their problems and objectives in formal and unambiguous ways which ensures that everyone is on the same page. Of course, formalism won’t protect us from defining the wrong problem, but that’s a point for a whole different discussion. We started by saying that we stumble upon many problems in our daily lives. And we mentioned that problems can be badly defined, might have many different possible solutions, and can be reducible to other problems. The main philosophy behind this thesis is that these three characteristic properties of problems can be used to formalize problem-solving. Or, we could also say that formalizing problem-solving implies that the resulting problems would be well-specified, supporting multiple solutions, and reducible to one another. Whether it is these characteristic properties or the formalization that gives rise to the other, and if any at all, is one of the questions that we will not answer. But one can imagine that we might be also observing a self-referential strange loop biting its own tail. However, regardless of which comes first, and if any, it is this intimate relationship that we are ultimately curious about. The current work, despite conceived with a very different mission, is, in fact, a study on the meta-problem of problem-solving. “Meta” because in some way we tried to study the common nature of all problems. But this is also a beautifully self-referential problem because the problem of problem-solving is itself a problem and hence should be subjected to the very conclusions it tries to reach. While this perhaps sounds like some mumbo-jumbo right now, we will show it formally later in the text. Putting this philosophical pondering aside, the official objective of this work Chapter 1. Introduction 3 is to formalize problem-solving so that we can reason about it in a systematic, and automated way. We want to work in a formal setting because, as we mentioned above, that is a way to make sure we agree what problem we are interested in and what we mean by “solving” it. We are interested in systematic reasoning because this would allow us to reason fast and efficiently. And as a nice bonus of a process being systematic is that it might be well-suited for automation with a computer or via some other mechanical means. We tried to keep this work as general and widely applicable as possible. However, the task of solving the problem of defining formalisms for defining problems and for evaluating their solutions is in itself not well-defined. No one provided us with a formal definition of a “problem” or a “solution” on the outset. Hence, the definitions and the resulting theory that you will see in this work are deeply ingrained with our assumptions of what problems and solutions are and with our beliefs of what problem-solving should look like. Hence, it is only fair that we make these biases explicitly known to the reader. First, we are deeply convinced that problem-solving has an intrinsically compositional nature. Problems rarely appear in a complete vacuum. A single problem can often act as a component of more complex problems and can be itself composed of other problems. For example, the problem of making a salad has as subproblems washing the vegetables and cutting them. The very same problem can also be a component of the problem of preparing a three-course meal for a family. When we use the word “component”, we can mean many different things. For example, we can use the answer to one problem as the statement of the next one. The washed vegetables can act as the starting point of their cutting. We can even use the answer of a problem as its own statement, or part of it, creating a loop in the process. Or, we might be interested in finding a steady solution to this loop. Or, we might be solving two problems simultaneously. Or, we might be handling multiple problems and their solutions and then comparing them in various ways. All these different possible operations we will refer collectively to as “compositions”. Everyone who was involved in this work is an engineer. And it is commonly believed that engineers are supposed to be lazy.