 Hello to all our virtual viewers. This is MFPS 36 2020 This year. We're having the conference online virtually What are partial evaluations? So if you don't know what a monad is here's the definition, but let's try to give it a more Practical and operational interpretation So the idea is that let's work in the category of sets a monad is like a way to form formal expressions consistently What I mean is that we can consider our sets as containing just some variables or elements And then a monad has a functor first of all that takes a set and gives a new set Which contains the formal expressions in these variables for example formal sums so in this sense Formal sums what does it mean formal and means that the sum somehow does not see the content of this variable So maybe it's helpful to wrap the variable inside a box to say that this plus does not have access to the inside of the box Okay, so this is a purely formal sum X1 and X2 don't have to be numbers They can be literally those letters. We can still sum them formally. All right, so we can take binary sums sturdnery sums Well singleton sums some just this thing to nothing or even the empty sum Okay, and so on Of course, not just sums. This is more general sums are an example Now the functor is an endo functor So it turns a set of these expressions so we can iterate it And we get formal expressions off formal expressions namely nested formal expressions with so with two levels of boxing So you see the plus in here has no access to the inside of this large box But the plus in here does just does not have access to the innermost level and on functions So morphisms Well, you apply the function box wise or element wise So if you have X1 plus X2 then TF just applies F inside each box. Okay? Okay, that's the functor part. So we also have a unit So a unit is a way to take an element of X and just give a formal expression in our picture We can wrap this element around its own little box and And there is a multiplication which takes formal expressions off formal expressions and Flattens them to just formal expressions So in our picture we can just imagine that this removes the outer boxes Okay, and in particular it equates the level of this plus and this other plus What do the diagrams of the monad mean? so the first unit diagram says that if we have a formal expression and We wrap it inside a box. So we make this double formal expression, which is rather trivial It's not really double so to say and you remove the outer box and you get back To what you had before the right unitality Tells you that if you again start with a formal expression and now apply eta element wise So inside each box you put these elements in their own little boxes Again, so now the inner level is kind of trivial, right? And if you remove the outer boxes you get again the initial expression The multiplication or associativity square says that if you have now a nested nested formal expression So three levels of boxes and you can do either You remove the outer most box apply me or You remove the mid-level boxes, which is inside each box here There's only one you remove the boxes. So these mid-level ones You get doubly formal expressions here, but different ones If you don't apply mu again, you get the same thing It's the reason is because you're basically removing The level that you didn't remove before so only the innermost level remains. Okay, so this diagram commutes so the Diagrams of the monad can tell us that this interpretation is consistent so that you can interpret Monads in terms of adding and removing boxes in your formal expressions. Okay Now all of these were formal But of course we have some places where we can actually do sums like numbers So if you have two plus one, of course, it's it's formal just like X plus Y But two plus one is equal to three, right? So we can in some cases remove the boxes and now the plus can if you want to access these variables and Operate on them So whenever we can do that we speak about an algebra and algebra as a place if you want the structure Where these formal expressions with these specified types of formal expressions can be evaluated to an actual result Here's a more rigorous definition So it's first of all an object of your category for as a set and the map from formal expressions to our set which takes the result Which have to be consistent in the following sense first of all So remember we have the unit the given an element just gets a kind of trivial formal expressions That just contains that element if you evaluate that then you need to get that element back So that's a unit square a unit triangle of the algebra. The other consistency condition Is that if you have a nested formal expression then again, you can do two things you can either flatten it removing the outer boxes and Somehow integrate these two levels of sums into just one larger son or You can remove the inner boxes and so evaluate the stuff that's in here So you get two formal expressions that on the nose are different But if you evaluate them if you like evaluate those things you get some kind of total evaluation and these two ways coincide right, so in some way it tells you that Evaluating a formal expression that comes from you is the same thing as a double evaluation So you kind of packs this double instruction together into a formal expression that contains both steps All right, so that's an algebra over our money Many algebra structures almost all of them can be modeled as Algebra's of a suitable monad either on set or on other categories So it's actually a very powerful construction. You probably know pretty much every monad can be interpreted at least on set as Formal expressions as long as you allow for potentially infinite formal expressions. Okay So now so far we could evaluate things totally all the time, but one may ask cookie How about partial evaluation? So there are some situations I will give some examples in a moment where one is interested in something that looks a bit like this so you have a sum and You don't evaluate it completely, but just partially So maybe in computer science when you have for example an array of Numbers that you want to sum and you want to fold it, but you're not done yet That's the kind of stuff that you get but this is more general This model some very different situations not just this one. Okay. How do you even talk about this in? Terms of monads the way we have talked about it so far since we know There's box schemes of adding removing boxes The idea is that we first want to do this part of the expression So we first want to sum two and three and leave for for later on or in other words, there is a Nested formal expressions the first groups two and three and now we can of course flatten it and remove this grouping and get our initial expression or You can remove the inner boxes this time And so the large box will now be the one that contains a five because we have removed the inner boxes and operated the sum The rest will stay as it is. Okay. Now. We know what these maps are the model removes the outer boxes is the multiplication and the map that removes the inner boxes is Well inside these boxes you evaluate Okay So here's their definition if you have pq and ta then For some mu and tta mu of m gives p and te of m gives q Okay, so whenever this happens We call q a partial evaluation of p and p a partial decomposition of q You see this is also a way to decompose first there does expression partially Sometimes we will refer to m as the partial evaluation or as the witness of partial evaluation because you can consider This nested formal expression as the instruction To partially evaluate this into this or decompose this into this okay Depending on whether we want to consider this as a structure or as a property so Both ways are actually helpful All right Here are some further examples So if you take the free semi group monad so algebras are semi groups and there's an algebra You take natural numbers with multiplication Excluding zero and one. Okay, so the unit is not there, but it's okay because we just want semi groups then the partial the compositions are factorizations and There's a total decomposition. That's the composition into prime factors. So take a number There's many ways to partially decompose this Okay But actually all these ways have a common refinement that's going to be the total decomposition and Here is why we're excluding one because if we hadn't excluded one Then you could go further as much as you want by just adding once I mean multiplying by one as many times as you want technically. It's a different formal expression. We don't want that. Okay Partial the compositions are to total the compositions as factorizations are To factorizations into primes where you cannot go further Here's another one So you probably know that if you have an internal monoid or an internal group In any monoidal category or Cartesian monoidal category If you don't know what these are just imagine sets And the group or monoid object like a group or a monoid Then multiplying or tensoring g gives a monad This is sometimes called the action monad or in computer science This is called the writer monad where this is a monoid usually given by some strings that can concatenate If you're not familiar with this construction, you can look on the n-labs. There's an article that explains this in Pretty accessible terms I would say So the algebras are the g spaces or spaces that have an action of this group or monoid Okay, so now what do partial evaluations look here? We can plug in the definition So first of all ta here is g times a so formal expressions are pairs With an element of a and an element of g which you can think of as a formal action like a formal translation a Way to think about this is like if a is set of places and g is the amount of gas You have to reach a certain place then x is where you start and g is how much gas you have in your car Okay, but you still haven't gone to your destination. It's still there It's a some else still a potential move that you can make. Okay Now plugging in a partial evaluation from this to this if it exists is an element of you know Tta is a g times g times a Such that hl is g and lx is y. So this looks a bit abstract what it means is G so this amount of gas is Actually this amount of gas together with this amount of gas. So let's partition our gas tank and Now just use the L part to move So if this would be all that you can move using g what's a partial translation or a partial action as So if g is a composition of l and h you just Move off L not of it and instead of going all the way you just go, you know halfway or somewhere in between All right Now if you think of g as a group This is rather trivial because you can always do this along an orbit Just you know multiply by h to minus one on the other hand if we have monoids So if this is really gas that you consume and you can't get it back Then this is a non-trivial thing. You're going some way in the direction of the orbit usually you can't go back and you're you know Just going halfway or just a little bit along the direction not completely. So again, it's a partial move right Something that you probably wonder by now is if I have a partial evaluation and then I'm do again a partial evaluation The composition is again a partial evaluation, right? Actually not always But sometimes it does so for the nice cases Do you have that so for example for the case of sums? So suppose you can partially evaluate this into this while using this witness and Listen to this using this witness now Do we get a partial evaluation witness? from this expression to this expression and I don't mean in two steps I mean in a single step So the idea is that okay look Here this to that appears also here was obtained by doing one plus one and that's one Just the same. Okay, so let's replace this to and this expression with the way it was obtained So now you have a triply formal expression So doubly nested and what we can do is now some opaque destruction by removing the inner most errors removing this division Because we want to do a single step That's the instruction the witness is a partial evaluation from here to here You see removing the outer boxes gives this Removing the inner boxes guess Okay So for the listeners, which are familiar with operas this may ring a bell because we are substituting something in here So that may remind Off the multiplication of operas. That's kind of the case. I'll get to that in a moment So the thing is We want these expressions to it to exist this triply formal expressions that can be interpreted as as in substituting this into this in other words We want This property so if there's something in here and something in here such that they agree down here Then there needs to exist an element up here That closes the diagram. Okay almost like a pullback Without uniqueness So what is This thing that's kind of like a pullback, but not quite. It's called a weak pullback or meek pullbacks in times So the idea is that you have a square and you have elements here and here that agree down here Call this a weak pullback if there if when this is the case There is always an element in a such that kept some up to see by G and to be by F It's pulled back without uniqueness now You probably know that a Cartesian monad is a monad that preserves pullbacks like the functor preserves pullbacks and the naturality squares of E and E are pullbacks So just as well one can define a weakly Cartesian monad is the same But T has to preserve weak pullbacks and the naturality squares are weak pullbacks Now for weakly Cartesian monads Compositions always defined because we can always fill up the square before was marked in red And for Cartesian monad it's even uniquely defined because there's a unique rewrite or freerides, okay Okay, when are monads weakly Cartesian so that well all monads presented by an operator are Cartesian So there this composition of partial evaluations is really a substitution It's really the operatic Operation on the nose without any additional identification. So by operate here. I mean plain operator I don't mean symmetric operator Okay, so those things are like equal on the nose not even up to permutation. This includes monads and group actions No, not monads and groups monoid and group actions Okay, so this tensoring with the group object, for example, many monads are weakly Cartesian For example, they're free commutative monoid monad. So roughly if it's presented like it's finitary and presented by Symmetric operas and you get weakly Cartesian and the uniqueness fails because of permutations the generic monad is Not weakly Cartesian, okay the case that interests me the most since I work in probability theory as probability monads in particular the Kantarovish monad and The distribution monad on set for those composition as weakly Cartesian unit is not But we don't care We want composition to compose partial evaluations. Okay Okay, let's talk for a little bit about probability monads We've seen that monads can be seen as constructions in coding formal expressions. So in probability theory You sometimes are interested in taking formal convex combinations or formal averages You have a base category could be sets metric spaces measurable spaces whose objects you can think of as being Spaces of possible states in general deterministic states for example the space x which can think of a coin has two states heads and tails Now the functor takes a space and gives you a new space of the so to say random states like formal convex combinations of these elements For example, it contains half and half heads and tails with like 50 50 probability or you know a hundred and zero 75 25 and so on now. It's important and these are formal averages, okay You're not actually taking the average of heads and tails. There's nothing in between The the coin does not like land vertically or something This is not some kind of superposition of states like in quantum mechanics or some kind of real average But it's important that a probability measure is a formal average You haven't taken that actual midpoint or center of mass. All right formal. That's why monads are so useful here now clearly a completely deterministic state like a hundred percent coin a hundred percent heads Correspond to just heads. So there's a natural map from X to P acts that picks out So how the deterministic states in there? That's the unit of the monad and And more interestingly suppose that I have a fair coin in my pocket that could be heads or tails and This loaded coin in my pocket. That's like has two heads Okay, now suppose that I have both coins in my pocket and I draw one of them at random and then flip it You've probably done that in your head The total probabilities that are going to have like three quarters heads and one quarter tails as outcomes, right? So think of what this was? Also, the coin is random like which coin I pick. So that's like a random coin like a random Random outcome right this was actually an element of PPX. We have a law on the random variables as well like a law on the laws and by kind of averaging out We get a Normal random variable. Okay, that's the multiplication. So this kind of averaging again formal averaging That's a multiplication. Okay So what are the algebras? Well, the algebras are where you can actually take those averages. So Convex spaces of some kind if you have You know probability measures over these two points Then you can map a probability measure So this 100% of a goes to a 100% of b goes to b and stuff in between will go somewhere that if you want like physically in between It's a kind of midpoint or like a complex combination, right? So the space where we can do this are Convex spaces in some sense So if you do this with for the distribution monad on set you get What are actually called abstract convex spaces if you do this on metric spaces you get Convex regions of Banach spaces and so on so so depending on the context depending on the category you get spaces which are Interpretable as convex spaces in that context So let's analyze a bit more in detail the metric case, which is the one I've been working on the most There is this very nicely behaved monad on the category of complete metric spaces and the algebras are what they should be in The sense that they have to be objects of our category. So complete metric spaces and after the convex in some sense so Close convex subsets of Banach spaces somehow are the convex objects, so to say in the category of Complete metric spaces and that's exactly what the algebras are. So what are partial evaluations? Partial evaluations are partial average and this is very important in probability theory So here's an idea you have a probability measure on some space. So what do you do? You first of all you break it into pieces Just like remember we had this formal sum and we were Summing just parts of it. So here's the same we have Probability measure we break it into pieces and then take the average of each piece and replace it with the delta Weighted by the amount of mass of that piece and then put them back together Now here's an example where we broke this into three pieces doesn't need to be finite could be an infinite family and then it's Way more difficult to draw Okay, but the idea is you replace something by something that's more concentrated like locally, so to say. Okay, so The new distribution is going to be more concentrated or if you want less random less risky in some sense You can prove that for this case You always can compose partial evaluation. So the multiplication square at least for element for like single elements is weekly Cartesian so you can actually compose partial evaluations and the relation that you get on PA on the space of formal expressions is actually a Very well known construction Sometimes called the shokai order or a convex order or a risk order even and it's just even in mathematical finance Even the economists like Rothschild and Stiglitz were using it To assess how risky some random variables are at least for the case of the real line So this is actually used in mathematical finance to say that something is riskier or safer So I like this because in category theory often you have a constructed which is derived from private principles And it turns out that a known construction in a different field is an instance of what you just Created or thought you created and this is the case Surprisingly, so for a concept in mathematical finance That's the partial evaluation if real numbers are considered as an algebra off. They can target you might We can say more in Probability theory or a measure theory. There is actually already a notion of things that are like expectations, but only Partial which are conditional expectation and it turns out that these concepts Are the same ones you translate them properly So it turns out that as a corollary to a theorem that's known since the eighties Given probability measures on a so formal expressions if you want to be a then p is a partial evaluation of q if and only f These two probability measures are laws our distributions of random variables Which are in relation of conditional expectation for those of you not familiar with conditional expectation Here's a rough idea So suppose you have a measure on your space Here is the red one and the function. Here's the blue one on your space Which is measurable and suppose you take a course or sigma algebra think of a partition to get for example a finite partition What is a conditional expectation of this function? With respect to this new sigma algebra is new partition is a new function which is Constant within the cells of the partition, so which is measurable for the new sigma algebra but Such that for each cells of the new partition or for each measurable subset of the new sigma algebra the integral is the same So the area of these rectangles is the same as the area of these old shapes Okay So you're replacing this function in the cell with with its average in that cell Okay Replace a function with the cell wise average. That's conditional expectation Of course in general, this is not a partition. This is infinite and it's an actual sigma algebra But now why does this correspond to partial evaluations? Well Let's now look at the values that this thing takes for example are so an algebra of Ramon So if you have this measure you can push it forward along this function and get This image measure like the law of your land variable If you now replace this function by its conditional expectation Then the image random variable will be more concentrated will somehow Break your image random variable into pieces and replace them with their average. Okay, so these two things these two Concepts are actually pretty much the same once you translate once you go from random variables to their distribution Okay, so that's the theorem in ricker and some of you may probably know that this allows to talk about martingales So this tells us that partial evaluations are how you can model martingales in probability using probability monads. I like this because Probability monads until very recently were mostly used to do measure theory rather than probability theory Not many people were using probability monads to actually talk about Stochastic processes and so on but mostly to express what measures are categorically This instead is giving us a way of talk about actual martingales. So things that probability theorists actually work with using monads Last thing I want to mention So there is work in progress that we're doing together with the ACT school students Partial evaluations can be seen as like source and target of A higher-dimensional structure an entire simplicial set, which is called the bar construction So those are just the tip of the iceberg if you want the picture Then if you view this witness of partial evaluations from here to here and this witness of partial evaluation from here to here as two edges of a triangle Then the triple formal expression is like the interior of a triangle and by removing the inner the mid-level box as you got missing arrow of the triangle, okay Turns out that this gives a Lot of new compositional structures similar to categories, but much more general not quasi-categories. They're different and It's a work in progress that we're doing together with the students of the school of last year So I hope that I'll be able to tell you more about this in the near future. So stay tuned if you're interested and For the rest I think I'll stop here. Let me just say so give some credit This is a joint work that I've been doing with Tobias Fritz. I Have to thank Slava Matveev Because he's the person that came up with this idea of partially evaluating something and I want to thank also the students of Our ACT school, which are Carmen Constantine, Martin Lundfall and Brandon Shapiro with whom we are currently working Alright, so here's some references If you want to see some details of this construction Of course, you can look at the paper in the proceedings when it's going to go out It's already in the archive if you want and if you want to see a little bit more about partial evaluations Improbability you can look at chapter 4 of my PhD thesis which you can find it as address Right. Thank you so much for listening and I hope you found this interesting