Jekyll2020-01-13T12:48:58+01:00http://math.andrej.com/feed.xmlMathematics and ComputationA blog about mathematics for computersOn fixed-point theorems in synthetic computability2019-11-07T00:00:00+01:002019-11-07T00:00:00+01:00http://math.andrej.com/2019/11/07/on-fixed-point-theorems-in-synthetic-computability<p>I forgot to record the fact that already two years ago I wrote a paper on Lawvere's fixed-point theorem in synthetic computability:</p> <blockquote> <p>Andrej Bauer: <a href="https://content.sciendo.com/view/journals/tmj/10/3/article-p167.xml"><em>On fixed-point theorems in synthetic computability</em></a>. Tbilisi Mathematical Journal, Volume 10: Issue 3, pp. 167–181.</p> </blockquote> <p>It was a special issue in honor of Professors <a href="https://en.wikipedia.org/wiki/Peter_J._Freyd">Peter J. Freyd</a> and <a href="https://en.wikipedia.org/wiki/William_Lawvere">F. William Lawvere</a> on the occasion of their 80th birthdays.</p> <p>Lawvere's paper <a href="http://tac.mta.ca/tac/reprints/articles/15/tr15abs.html">"Diagonal arguments and cartesian closed categories</a> proves a beautifully simple fixed point theorem.</p> <blockquote> <p><strong>Theorem:</strong> (Lawvere) <em>If $e : A \to B^A$ is a surjection then every $f : B \to B$ has a fixed point.</em></p> </blockquote> <p><em>Proof.</em> Because $e$ is a surjection, there is $a \in A$ such that $e(a) = \lambda x : A \,.\, f(e(x)(x))$, but then $e(a)(a) = f(e(a)(a)$. $\Box$</p> <p>Lawvere's original version is a bit more general, but the one given here makes is very clear that Lawvere's fixed point theorem is the diagonal argument in crystallized form. Indeed, the contrapositive form of the theorem, namely</p> <blockquote> <p><strong>Corollary:</strong> <em>If $f : B \to B$ has no fixed point then there is no surjection $e : A \to B^A$.</em></p> </blockquote> <p>immediately implies a number of famous theorems that rely on the diagonal argument. For example, there can be no surjection $A \to \lbrace 0, 1\rbrace^A$ because the map $x \mapsto 1 - x$ has no fixed point in $\lbrace 0, 1\rbrace$ -- and that is Cantors' theorem.</p> <p>It not easy to find non-trivial instances to which Lawvere's theorem applies. Indeed, if excluded middle holds, then having a surjection $e : A \to B^A$ implies that $B$ is the singleton. We should look for interesting instances in categories other than classical sets. In my paper I do so: I show that countably based $\omega$-cpos in the effective topos are countable and closed under countable products, which gives us a rich supply of objects $B$ such that there is a surjection $\mathbb{N} \to B^\mathbb{N}$.</p> <p>Enjoy the paper!</p>Andrej BauerI forgot to record the fact that already two years ago I wrote a paper on Lawvere's fixed-point theorem in synthetic computability: Andrej Bauer: On fixed-point theorems in synthetic computability. Tbilisi Mathematical Journal, Volume 10: Issue 3, pp. 167–181. It was a special issue in honor of Professors Peter J. Freyd and F. William Lawvere on the occasion of their 80th birthdays. Lawvere's paper "Diagonal arguments and cartesian closed categories proves a beautifully simple fixed point theorem. Theorem: (Lawvere) If $e : A \to B^A$ is a surjection then every $f : B \to B$ has a fixed point. Proof. Because $e$ is a surjection, there is $a \in A$ such that $e(a) = \lambda x : A \,.\, f(e(x)(x))$, but then $e(a)(a) = f(e(a)(a)$. $\Box$ Lawvere's original version is a bit more general, but the one given here makes is very clear that Lawvere's fixed point theorem is the diagonal argument in crystallized form. Indeed, the contrapositive form of the theorem, namely Corollary: If $f : B \to B$ has no fixed point then there is no surjection $e : A \to B^A$. immediately implies a number of famous theorems that rely on the diagonal argument. For example, there can be no surjection $A \to \lbrace 0, 1\rbrace^A$ because the map $x \mapsto 1 - x$ has no fixed point in $\lbrace 0, 1\rbrace$ -- and that is Cantors' theorem. It not easy to find non-trivial instances to which Lawvere's theorem applies. Indeed, if excluded middle holds, then having a surjection $e : A \to B^A$ implies that $B$ is the singleton. We should look for interesting instances in categories other than classical sets. In my paper I do so: I show that countably based $\omega$-cpos in the effective topos are countable and closed under countable products, which gives us a rich supply of objects $B$ such that there is a surjection $\mathbb{N} \to B^\mathbb{N}$. Enjoy the paper!Runners in action2019-10-28T00:00:00+01:002019-10-28T00:00:00+01:00http://math.andrej.com/2019/10/28/runners-in-action<p>It has been almost a decade since <a href="http://matija.pretnar.info">Matija Pretnar</a> and I posted the <a href="http://math.andrej.com/category/eff/">first blog posts</a> about programming with algebraic effects and handlers and the programming language <a href="http://www.eff-lang.org">Eff</a>. Since then handlers have become a well-known control mechanism in programming languages.</p> <p>Handlers and monads excel at <em>simulating</em> effects, either in terms of other effects or as pure computations. For example, the familiar <a href="https://wiki.haskell.org/State_Monad">state monad</a> implements mutable state with (pure) state-passing functions, and there are many more examples. But I have always felt that handlers and monads are not very good at explaining how a program interacts with its external environment and how it gets to perform <em>real-world</em> effects.</p> <p><a href="https://danel.ahman.ee">Danel Ahman</a> and I have worked for a while on attacking the question on how to better model external resources and what programming constructs are appropriate for working with them. The time is right for us to show what we have done so far. The theoretical side of things is explained in our paper <a href="http://arxiv.org/abs/1910.11629"><strong>Runners in action</strong></a>, Danel implemented a Haskell library <a href="https://github.com/danelahman/haskell-coop"><strong>Haskell-Coop</strong></a> to go with the paper, and I implemented a programming language <a href="https://github.com/andrejbauer/coop"><strong>Coop</strong></a>.</p> <!--more--> <p>General-purpose programming languages, even the so-called pure ones, have to have <em>some</em> account of interaction with the external environment. A popular choice is to provide a foreign-function interface that connects the language with an external library, and through it with an operating system and the universe. A more nuanced approach would differentiate between a function that just happens to be written in a different language, and one that actually performs an effect. The latter kind is known as an <em>algebraic operation</em> in the algebraic-effects-and-handlers way of doing things.</p> <p>A <em>bad</em> approach to modeling the external world is to pretend that it is internal to the language. One would think that this is obvious but it is not. For instance, Haskell represents the interface to the external world through the <a href="https://www.haskell.org/onlinereport/haskell2010/haskellch41.html#x49-32100041.1"><code class="highlighter-rouge">IO</code> monad</a>. But what is this monad <em>really</em>? How does it get to interact with the external world? The Haskell Wiki page which answers this question has <a href="https://wiki.haskell.org/IO_inside#Welcome_to_the_RealWorld.2C_baby">the following disclaimer</a>:</p> <blockquote> <p><em>"Warning: The following story about <code class="highlighter-rouge">IO</code> is incorrect in that it cannot actually explain some important aspects of <code class="highlighter-rouge">IO</code> (including interaction and concurrency). However, some people find it useful to begin developing an understanding."</em></p> </blockquote> <p>The Wiki goes on to say how <code class="highlighter-rouge">IO</code> is a bit like a state monad with an imaginary <code class="highlighter-rouge">RealWorld</code> state, except that of course <code class="highlighter-rouge">RealWorld</code> is not really a Haskell type, or at least not one that actually holds the state of the real world.</p> <p>The situation with Eff is not much better: it treats some operations at the top-level in a special way. For example, if <code class="highlighter-rouge">print</code> percolates to the top level, it turns into a <em>real</em> <code class="highlighter-rouge">print</code> that actually causes an effect. So it looks like there is some sort of "top level handler" that models the real world, but that cannot be the case: a handler may discard the continuation or run it twice, but Eff hardly has the ability to discard the external world, or to make it bifurcate into two separate realities.</p> <p>If <code class="highlighter-rouge">IO</code> monad is not an honest monad and a top-level handler is not really a handler, then what we have is a case of ingenious hackery in need of proper programming-language design.</p> <p>How precisely does an operation call in the program cause an effect in the external world? As we have just seen, some sort of runtime environment or top level needs to relate it to the external world. From the viewpoint of the program, the external world appears as state which is not directly accessible, or even representable in the language. The effect of calling an operation $\mathtt{op}(a,\kappa)$ is to change the state of the world, and to get back a result. We can model the situation with a map $\overline{\mathtt{op}} : A \times W \to B \times W$, where $W$ is the set of all states of the world, $A$ is the set of parameters, and $B$ the set of results of the operation. The operation call $\mathtt{op}(a, \kappa)$ is "executed" in the current world $w \in W$ by computing $\overline{\mathtt{op}}(a,w) = (b, w')$ to get the next world $w'$ and a result $b$. The program then proceeds with the continuation $\kappa\,b$ in the world $w'$. Notice how the world $w$ is an external entity that is manipulated by the external map $\overline{\mathtt{op}}$ realistically in a <em>linear</em> fashion, i.e., the world is neither discarded nor copied, just transformed.</p> <p>What I have just described is <em>not</em> a monad or a handler, but a <em>comodel</em>, also known as a <em>runner</em>, and the map $\overline{\mathtt{op}}$ is not an operation, but a <em>co-operation</em>. This was all observed a while ago by <a href="http://homepages.inf.ed.ac.uk/gdp/">Gordon Plotkin</a> and <a href="https://scholar.google.co.uk/citations?user=aOCekqQAAAAJ">John Power</a>, <a href="https://www.ioc.ee/~tarmo/">Tarmo Uustalu</a>, and generalized by <a href="http://www.itu.dk/people/mogel/">Rasmus Møgelberg</a> and <a href="https://www.cs.ox.ac.uk/people/samuel.staton/main.html">Sam Staton</a>, see our paper for references. Perhaps we should replace "top-level" handlers and "special" monads with runners?</p> <p>Danel and I worked out how <em>effectful</em> runners (a generalization of runners that supports other effects in addition to state) provide a mathematical model of resource management. They also give rise to a programming concept that models top-level external resources, as well as allows programmers to modularly define their own “virtual machines” and run code inside them. Such virtual machines can be nested and combined in interesting ways. We capture the core ideas of programming with runners in an equational calculus $\lambda_{\mathsf{coop}}$, that guarantees the linear use of resources and execution of finalization code.</p> <p>An interesting practical aspect of $\lambda_{\mathsf{coop}}$, that was begotten by theory, is modeling of extra-ordinary circumstances. The external environment should have the ability to signal back to the program an extra-ordinary circumstance that prevents if from returning a result. This is normally accomplished by an exception mechanism, but since the external world is stateful, there are <em>two</em> ways of combining it with exceptions, namely the sum and the tensor of algebraic theories. Which one is the right one? Both! After a bit of head scratching we realized that the two options are (analogous to) what is variously called <a href="https://docs.oracle.com/javase/tutorial/essential/exceptions/runtime.html">"checked" and "non-checked" exceptions</a>, <a href="http://man7.org/linux/man-pages/man3/errno.3.html">errors</a> and <a href="http://man7.org/linux/man-pages/man7/signal.7.html">signals</a>, or <a href="https://www.repository.cam.ac.uk/bitstream/handle/1810/283239/paper.pdf?sequence=3&amp;isAllowed=y">synchronous and asynchronous exceptions</a>. And so we included in $\lambda_{\mathsf{coop}}$ both mechanisms: ordinary <em>exceptions</em>, which are special events that disrupt the flow of user code but can be caught and attended to, and <em>signals</em> which are unrecoverable failures that irrevocably <em>kill</em> user code, but can still be finalized. We proved a finalization theorem which gives strong guarantees about resources always being properly finalized.</p> <p>If you are familiar with handlers, as a first approximation you can think of runners as handlers that use the continuation at most once in a tail-call position. Many handlers are already of this form but not all. Non-determinism, probability, and handlers that hijack the continuation (<code class="highlighter-rouge">delimcc</code>, threads, and selection functionals) fall outside of the scope of runners. Perhaps in the future we can resurrect some of these (in particular it seems like threads, or even some form of concurrency would be worth investigating). There are many other directions of possible future investigations: efficient compilation, notions of correctness, extensions to the simple effect subtyping discipline that we implemented, etc.</p> <p>To find out more, we kindly invite you to have a look at the <a href="http://arxiv.org/abs/1910.11629">paper</a>, and to try out the implementations. The prototype programming language <a href="https://github.com/andrejbauer/coop">Coop</a> implements and extends $\lambda_{\mathsf{coop}}$. You can start by skimming the <a href="https://github.com/andrejbauer/coop/blob/master/Manual.md">Coop manual</a> and the <a href="https://github.com/andrejbauer/coop/tree/master/examples">examples</a>. If you prefer to experiment on your own, you might prefer the <a href="https://github.com/danelahman/haskell-coop">Haskell-Coop</a> library, as it allows you to combine runners with everything else that Haskell has to offer.</p>Andrej BauerIt has been almost a decade since Matija Pretnar and I posted the first blog posts about programming with algebraic effects and handlers and the programming language Eff. Since then handlers have become a well-known control mechanism in programming languages. Handlers and monads excel at simulating effects, either in terms of other effects or as pure computations. For example, the familiar state monad implements mutable state with (pure) state-passing functions, and there are many more examples. But I have always felt that handlers and monads are not very good at explaining how a program interacts with its external environment and how it gets to perform real-world effects. Danel Ahman and I have worked for a while on attacking the question on how to better model external resources and what programming constructs are appropriate for working with them. The time is right for us to show what we have done so far. The theoretical side of things is explained in our paper Runners in action, Danel implemented a Haskell library Haskell-Coop to go with the paper, and I implemented a programming language Coop.On complete ordered fields2019-09-09T00:00:00+02:002019-09-09T00:00:00+02:00http://math.andrej.com/2019/09/09/on-complete-ordered-fields<p><a href="http://jdh.hamkins.org">Joel Hamkins</a> advertised the following theorem on Twitter:</p> <blockquote> <p><strong>Theorem:</strong> <em>All <a href="https://en.wikipedia.org/wiki/Least-upper-bound_property">complete</a> <a href="https://en.wikipedia.org/wiki/Ordered_field">ordered</a> fields are isomorphic.</em></p> </blockquote> <p><a href="https://twitter.com/JDHamkins/status/1169935061480804352?s=20">The standard proof</a> posted by Joel has two parts:</p> <ol> <li>A complete ordered field is archimedean.</li> <li>Using the fact that the rationals are dense in an archimedean field, we construct an isomorphism between any two complete ordered fields.</li> </ol> <p>The second step is constructive, but the first one is proved using excluded middle, as follows. Suppose $F$ is a complete ordered field. If $b \in F$ is an upper bound for the natural numbers, construed as a subset of $F$, then so $b - 1$, but then no element of $F$ can be the least upper bound of $\mathbb{N}$. By excluded middle, above every $x \in F$ there is $n \in \mathbb{N}$.</p> <p>So I asked myself and the <a href="https://groups.google.com/forum/#!topic/constructivenews/4jncQ9axrxI">constructive news mailing list</a> what the constructive status of the theorem is. But something was amiss, as <a href="http://math.fau.edu/richman/">Fred Richman</a> immediately asked me to provide an example of a complete ordered field. Why would he do that, don't we have the <a href="https://ncatlab.org/nlab/show/MacNeille+real+number">MacNeille reals</a>? After agreeing on definitions, <a href="http://tobybartels.name">Toby Bartels</a> gave the answer, which I am taking the liberty to adapt a bit and present here. I am probably just reinventing the wheel, so if someone knows an original reference, please provide it in the comments.</p> <p>The theorem holds constructively, but for a bizarre reason: if there exists a complete ordered field, then the law of excluded middle holds, and the standard proof is valid!</p> <!--more--> <p>As there are many constructive versions of order and completeness, let me spell out the definitions that are well adapted to the oddities of constructive mathematics. In classical logic these are all equivalent to the usual ones. Having to disentangle definitions when passing to constructive mathematics is a bit like learning how to be careful when passing from commutative to non-commutative algebra.</p> <p>A <strong>partial order</strong> $\leq$ on a set $P$ is a reflexive, transitive and antisymmetric relation on $P$.</p> <p>We are interested in <strong>linearly</strong> ordered fields, but constructively we need to take care, as the usual linearity, $x \leq y \lor y \leq x$, is quite difficult to satisfy, and may fail for reals.</p> <p>A <strong>strict order</strong> on a set $P$ is a relation $&lt;$ which is:</p> <ul> <li>irreflexive: $\lnot (x &lt; x)$,</li> <li>tight: $\lnot (x &lt; y \lor y &lt; x) \Rightarrow x = y$,</li> <li>weakly linear: $x &lt; y \Rightarrow x &lt; z \lor z &lt; y$</li> </ul> <p>The <strong>associated</strong> partial order is defined by $x \leq y \Leftrightarrow \lnot (y &lt; x)$. The reflexivity, antisymmetry and transitivity of $\leq$ follow respectively from irreflexivity, tightness, and weak linearity of $&lt;$.</p> <p>Next, an element $x \in P$ is an <strong>upper bound</strong> for $S \subseteq P$ when $y \leq x$ for all $y \in P$. An element $x \in P$ is the <em>supremum</em> of $S \subseteq P$ if it is an upper bound for $S$, and for every $y &lt; x$ there exists $z \in S$ such that $y &lt; z$. A poset $P$ is <strong>(Dedekind-MacNeille) complete</strong> when every inhabited bounded subset has a supremum (for the classically trained, $S \subseteq P$ is <em>inhabited</em> when there exists $x \in S$, and this is <em>not</em> the same as $S \neq \emptyset$).</p> <p>A basic exercise is to give a non-trivial complete order, i.e., a strict order $&lt;$ whose associated partial order $\leq$ is complete.</p> <blockquote> <p><strong>Theorem:</strong> <em>If there exists a non-trivial complete order then excluded middle holds.</em></p> </blockquote> <p><em>Proof.</em> Suppose $&lt;$ is a strict order on a set $P$ whose associated order $\leq$ is complete, and there exist $a, b \in P$ such that $a &lt; b$. Let $\phi$ be any proposition. Consider the set $S = \lbrace x \in P \mid x = a \lor (\phi \land x = b)\rbrace$. Observe that $\phi$ is equivalent to $b \in S$. Because $a \in S \subseteq \lbrace a, b\rbrace$, the set $S$ is inhabited and bounded, so let $s$ be its supremum. We know that $a &lt; s$ or $s &lt; b$, from which we can decide $\phi$:</p> <ol> <li>If $a &lt; s$ then $b \in S$: indeed, there exists $c \in S$ such that $a &lt; c$, but then $c = b$. In this case $\phi$ holds.</li> <li>If $s &lt; b$ then $\lnot(b \in S)$: if we had $b \in S$ then $S = \lbrace a, b \rbrace$ and $b = s &lt; b$, which is impossible. In this case $\lnot\phi$. $\Box$</li> </ol> <p>This immediately gives us the desired theorem.</p> <blockquote> <p><strong>Theorem (constructive):</strong> <em>All complete ordered fields are isomorphic.</em></p> </blockquote> <p><em>Proof.</em> The definition of a complete ordered field requires $0 &lt; 1$, therefore excluded middle holds. Now proceed with the usual classical proof. $\Box$</p> <p>This is very odd, as I always thought that the MacNeille reals form a MacNeille complete ordered field. Recall that a <a href="https://ncatlab.org/nlab/show/MacNeille+real+number">MacNeille real</a> is a pair $(L, U)$ of subsets of $\mathbb{Q}$ such that:</p> <ol> <li>$U$ is the set of upper bounds of $L$: $u \in U$ if, and only if, $\ell \leq u$ for all $\ell \in L$,</li> <li>$L$ is the set of lower bounds of $U$: $\ell \in L$ if, and only if, $\ell \leq u$ for all $u \in U$,</li> <li>$L$ and $U$ are inhabited.</li> </ol> <p>Furthermore, the MacNeille reals are complete, as they are just the <a href="https://ncatlab.org/nlab/show/MacNeille+completion">MacNeille completion</a> of the rationals. We may define a strict order on them by stipulating that, for $x = (L_x, U_x)$ and $y = (L_y, U_y)$, $$x &lt; y \iff \exists q \in U_x . \exists r \in L_y \,.\, q &lt; r.$$ According to Peter Johnstone (Sketches of an Elephant, D4.7), the MacNeille reals form a commutative unital ring in which $x$ is invertible if, and only if, $x &lt; 0 \lor x &gt; 0$. So apparently, the weak linearity of the strict order is problematic.</p> <p>What if we relax completeness? Two standard notions of completeness are:</p> <ol> <li>An ordered field $F$ is <strong>Cauchy-complete</strong> if every Cauchy sequence has a limit in $F$.</li> <li>An ordered field $F$ is <strong>Dedekind-complete</strong> if every Dedekind cut determines an element of $F$.</li> </ol> <p>It is easy enough to find non-isomorphic Cauchy-complete fields. Order the field $\mathbb{Q}(x)$ of rational functions with rational coefficients by stipulating that it extends the order of $\mathbb{Q}$ and that $q &lt; x$ for all $q \in \mathbb{Q}$. The Cauchy-completion of $\mathbb{Q}(x)$ is a Cauchy complete field which is not isomorphic to $\mathbb{Q}$. Caveat: I am speaking off the top of my head, do not trust this paragraph! (Or any other for that matter.)</p> <p>Regarding Dedekind completeness, it is important constructively that we take <em>two-sided</em> Dedekind cuts, i.e., pairs $(L, U)$ of subsets of $F$ such that</p> <ul> <li>$L$ is lower-rounded: $q \in L \iff \exists r \in L . q &lt; r$,</li> <li>$U$ is upper-rounded: $r \in U \iff \exists q \in U . q &lt; r$,</li> <li>the cut is bounded: $L$ and $U$ are inhabited,</li> <li>the cut is disjoint: $L \cap U = \emptyset$,</li> <li>the cut is located: if $q &lt; r$ then $L \in q$ or $r \in U$.</li> </ul> <p>Dedekind completeness states that for every Dedekind cut $(L, U)$ in $F$ there exists a unique $x \in F$ such that $L = \lbrace y \in F \mid y &lt; x\rbrace$ and $U = \lbrace y \in F \mid x &lt; y\rbrace$. Constructively this is a weaker form of completeness than the Dedekind-MacNeille one, but classically they coincide. Thus we cannot hope to exhibit constructively two non-isomorphic Dedekind-complete ordered fields (because constructive results are also classically valid). But perhaps there is a model of constructive mathematics where such strange fields exist. Does anyone know of one?</p>Andrej BauerJoel Hamkins advertised the following theorem on Twitter: Theorem: All complete ordered fields are isomorphic. The standard proof posted by Joel has two parts: A complete ordered field is archimedean. Using the fact that the rationals are dense in an archimedean field, we construct an isomorphism between any two complete ordered fields. The second step is constructive, but the first one is proved using excluded middle, as follows. Suppose $F$ is a complete ordered field. If $b \in F$ is an upper bound for the natural numbers, construed as a subset of $F$, then so $b - 1$, but then no element of $F$ can be the least upper bound of $\mathbb{N}$. By excluded middle, above every $x \in F$ there is $n \in \mathbb{N}$. So I asked myself and the constructive news mailing list what the constructive status of the theorem is. But something was amiss, as Fred Richman immediately asked me to provide an example of a complete ordered field. Why would he do that, don't we have the MacNeille reals? After agreeing on definitions, Toby Bartels gave the answer, which I am taking the liberty to adapt a bit and present here. I am probably just reinventing the wheel, so if someone knows an original reference, please provide it in the comments. The theorem holds constructively, but for a bizarre reason: if there exists a complete ordered field, then the law of excluded middle holds, and the standard proof is valid!The blog moved from Wordpress to Jekyll2019-09-03T00:00:00+02:002019-09-03T00:00:00+02:00http://math.andrej.com/2019/09/03/the-blog-moved-from-wordpress-to-jekyll<p>You may have noticed that lately I have had trouble with the blog. It was dying periodically because the backend database kept crashing. It was high time I moved away from Wordpress anyway, so I bit the bullet and ported the blog.</p> <!--more--> <p>All in all, it was a typical system administration experience: lots of installing Ruby and Node.js packages, figuring out which of several equivalent tools actually is worth using, dealing with scarce and obsolete documentation (a blog post is <em>not</em> a good substitute for proper documentation), etc. But all the tools are out there, it's just a simple matter of installing them:</p> <ul> <li><a href="https://wordpress.org/plugins/jekyll-exporter/">Jekyll Exporter</a> - an exporter from Wordpress to Jekyll</li> <li><a href="https://jekyllrb.com">Jekyll</a> - static pages blog, free of databases, with support for Markdown</li> <li><a href="https://staticman.net">Staticman</a> - a backend for blog comments</li> </ul> <p>I decided to make the blog repository <a href="https://github.com/andrejbauer/mathematics-and-computation"><code class="highlighter-rouge">mathematics-and-computation</code></a> public, as there is no good reason to keep it private. In fact, this way people can contribute by making pull requests (see the <a href="https://github.com/andrejbauer/mathematics-and-computation/blob/master/README.md"><code class="highlighter-rouge">README.md</code></a>.</p> <p>I will use this post to test the working on the new blog, and especially the comments, so please excuse silly comments below.</p>Andrej BauerYou may have noticed that lately I have had trouble with the blog. It was dying periodically because the backend database kept crashing. It was high time I moved away from Wordpress anyway, so I bit the bullet and ported the blog.What is algebraic about algebraic effects?2019-09-03T00:00:00+02:002019-09-03T00:00:00+02:00http://math.andrej.com/2019/09/03/what-is-algebraic-about-algebraic-effects<p>Published as <a href="https://arxiv.org/abs/1807.05923"><code class="highlighter-rouge">arXiv:1807.05923</code></a>.</p> <p><strong>Abstract:</strong> This note recapitulates and expands the contents of a tutorial on the mathematical theory of algebraic effects and handlers which I gave at the Dagstuhl seminar 18172 <a href="https://www.dagstuhl.de/en/program/calendar/semhp/?semnr=18172">"Algebraic effect handlers go mainstream"</a>. It is targeted roughly at the level of a doctoral student with some amount of mathematical training, or at anyone already familiar with algebraic effects and handlers as programming concepts who would like to know what they have to do with algebra. We draw an uninterrupted line of thought between algebra and computational effects. We begin on the mathematical side of things, by reviewing the classic notions of universal algebra: signatures, algebraic theories, and their models. We then generalize and adapt the theory so that it applies to computational effects. In the last step we replace traditional mathematical notation with one that is closer to programming languages.</p>Andrej BauerPublished as arXiv:1807.05923. Abstract: This note recapitulates and expands the contents of a tutorial on the mathematical theory of algebraic effects and handlers which I gave at the Dagstuhl seminar 18172 "Algebraic effect handlers go mainstream". It is targeted roughly at the level of a doctoral student with some amount of mathematical training, or at anyone already familiar with algebraic effects and handlers as programming concepts who would like to know what they have to do with algebra. We draw an uninterrupted line of thought between algebra and computational effects. We begin on the mathematical side of things, by reviewing the classic notions of universal algebra: signatures, algebraic theories, and their models. We then generalize and adapt the theory so that it applies to computational effects. In the last step we replace traditional mathematical notation with one that is closer to programming languages.Derivations as computations (ICFP 2019 slides)2019-08-21T11:02:57+02:002019-08-21T11:02:57+02:00http://math.andrej.com/2019/08/21/derivations-as-computations<p>I gave a <a href="https://icfp19.sigplan.org/details/icfp-2019-Keynotes-and-Reports/3/Derivations-as-computations">keynote talk "Derivations as Computations"</a> at <a href="https://icfp19.sigplan.org">ICFP 2019</a>.</p> <ul> <li>Slides with speaker notes: <a href="http://math.andrej.com/wp-content/uploads/2019/08/derivations-as-computations-icfp-2019.pdf">derivations-as-computations-icfp-2019.pdf</a></li> <li>Demo file: <a href="http://math.andrej.com/wp-content/uploads/2019/08/demo-icfp2019.m31">demo-icfp2019.m31</a></li> </ul> <!--more--> <p><strong>Abstract:</strong> According to the propositions-as-types reading, programs correspond to proofs, i.e., a term <code class="highlighter-rouge">t</code> of type <code class="highlighter-rouge">A</code> encodes a derivation <code class="highlighter-rouge">D</code> whose conclusion is <code class="highlighter-rouge">t : A</code>. But to be quite precise, <code class="highlighter-rouge">D</code> may have parts which are not represented in <code class="highlighter-rouge">t</code>, such as subderivations of judgmental equalities. In general, a term does not record an entire derivation, but only its <em>proof relevant</em> part. This is not a problem, as long as the missing subderivations can be reconstructed algorithmically. For instance, an equation may be re-checked, as long as we work in a type theory with decidable equality checking.</p> <p>But what happens when a type theory misbehaves? For instance, the extensional type theory elides arbitrarily complex term through applications of the equality reflection principle. One may take the stance that good computational properties are paramount, and dismiss any type theory that lacks them – or one may look into the matter with an open mind.</p> <p>If there is more to a derivation than its conclusion, then we should not equate the two. Instead, we can adopt a fresh perspective in which the conclusion is the <em>result</em> of a derivation. That is, we think of a derivation as a <em>computation tree</em> showing how to compute its conclusion. Moreover, the computation encoded by the derivation is <em>effectful</em>: proof irrelevance is the computational effect of discarding data, while checking a side condition is the effect of consulting an oracle. Where there are two computational effects, surely many others can be found.</p> <p>Indeed, we may set up type theory so that any terminating computation represents a derivation, as long as the computational steps that construct type-theoretic judgments are guaranteed to be validated by corresponding inference rules. Common techniques found in proof assistants (implicit arguments, coercions, equality checking, etc.) become computational effects. If we allow the user to control the effects, say through the mechanism of Plotkin and Pretnar’s handlers for algebraic effects, we obtain a very flexible proof assistant capable of dealing with a variety type theories.</p>Andrej BauerI gave a keynote talk "Derivations as Computations" at ICFP 2019. Slides with speaker notes: derivations-as-computations-icfp-2019.pdf Demo file: demo-icfp2019.m31What is an explicit bijection? (FPSAC 2019 slides)2019-07-04T12:08:17+02:002019-07-04T12:08:17+02:00http://math.andrej.com/2019/07/04/what-is-an-explicit-bijection-fpsac-2019-slides<p>Here are the slides with speaker notes for the talk <em>What is an explicit bijection</em> which I gave at the <a href="http://fpsac2019.fmf.uni-lj.si">31st International Conference on Formal Power Series and Algebraic Combinatorics</a> (FPSAC 2019). It was the "outsider" talk, where they invite someone to tell them something outside of their area.</p> <p>So how does one sell homotopy type theory to people who are interested in combinatorics? That is a tough sell. I used my MathOverflow question <a href="https://mathoverflow.net/questions/323779/what-is-an-explicit-bijection-in-combinatorics">"What is an explicit bijection?"</a> to give a stand-up comedy introduction, after which I plunged into type theory. I am told I plunged a little too hard. For instance, people asked "why are we doing this" because I did not make it clear enough that we are trying to make a distinction between "abstractly exists" and "concretely constructed". Oh well, it’s difficult to explain homotopy type theory in 50 minutes. Anyhow, I hope you can get something useful from the slides.</p> <p>Download slides: <a href="/wp-content/uploads/2019/07/What-is-an-explicit-bijection-FPSAC-2019-slides-with-presenter-notes.pdf">what-is-an-explicit-bijection.pdf</a></p> <p><a href="http://videolectures.net/FPSAC2019_bauer_explicit_bijection/">Video recording</a> of the lecture is now available.</p>Andrej BauerHere are the slides with speaker notes for the talk What is an explicit bijection which I gave at the 31st International Conference on Formal Power Series and Algebraic Combinatorics (FPSAC 2019). It was the "outsider" talk, where they invite someone to tell them something outside of their area. So how does one sell homotopy type theory to people who are interested in combinatorics? That is a tough sell. I used my MathOverflow question "What is an explicit bijection?" to give a stand-up comedy introduction, after which I plunged into type theory. I am told I plunged a little too hard. For instance, people asked "why are we doing this" because I did not make it clear enough that we are trying to make a distinction between "abstractly exists" and "concretely constructed". Oh well, it’s difficult to explain homotopy type theory in 50 minutes. Anyhow, I hope you can get something useful from the slides. Download slides: what-is-an-explicit-bijection.pdf Video recording of the lecture is now available.A course on homotopy (type) theory2019-05-08T21:04:48+02:002019-05-08T21:04:48+02:00http://math.andrej.com/2019/05/08/a-course-on-homotopy-type-theory<p>This semester my colleague <a href="https://www.fmf.uni-lj.si/~smrekar/">Jaka Smrekar</a> and I are teaching a graduate course on homotopy theory and homotopy type theory. The first part was taught by Jaka and was a nice review of classical homotopy theory leading up to Quillen model categories. In the second part I am covering basic homotopy type theory.</p> <p>The course materials are available at the GitHub repository <a href="https://github.com/andrejbauer/homotopy-type-theory-course"><code class="highlighter-rouge">homotopy-type-theory-course</code></a>. The homotopy type theory lectures are also <a href="https://vimeo.com/channels/1457250">recorded on video</a>.</p>Andrej BauerThis semester my colleague Jaka Smrekar and I are teaching a graduate course on homotopy theory and homotopy type theory. The first part was taught by Jaka and was a nice review of classical homotopy theory leading up to Quillen model categories. In the second part I am covering basic homotopy type theory. The course materials are available at the GitHub repository homotopy-type-theory-course. The homotopy type theory lectures are also recorded on video.How to implement type theory in an hour2018-08-25T11:31:17+02:002018-08-25T11:31:17+02:00http://math.andrej.com/2018/08/25/how-to-implement-type-theory-in-an-hour<p>I was purging the disk on my laptop of large files and found a video lecture which I forgot to publish. Here it is with some delay. I lectured on how to implement type theory at the <a href="https://unimath.github.io/bham2017/">School and Workshop on Univalent Mathematics</a> in December 2017, at the University of Birmingham (UK).</p> <p>You may <a href="https://vimeo.com/286652934">watch the video</a> and visit the accompanying GitHub repository <a href="https://github.com/andrejbauer/spartan-type-theory">spartan-type-theory</a>.</p>Andrej BauerI was purging the disk on my laptop of large files and found a video lecture which I forgot to publish. Here it is with some delay. I lectured on how to implement type theory at the School and Workshop on Univalent Mathematics in December 2017, at the University of Birmingham (UK). You may watch the video and visit the accompanying GitHub repository spartan-type-theory.Algebraic effects and handlers at OPLSS 20182018-07-22T03:39:42+02:002018-07-22T03:39:42+02:00http://math.andrej.com/2018/07/22/algebraic-effects-and-handlers-at-oplss-2018<p>I have had the honor to lecture at the <a href="https://www.cs.uoregon.edu/research/summerschool/summer18/index.php">Oregon Programming Language Summer School 2018</a> on the topic of algebraic effects and handlers. The notes, materials and the lectures are available online:</p> <ul> <li>the GitHub repository with the <a href="https://github.com/OPLSS/introduction-to-algebraic-effects-and-handlers">course material</a></li> <li>the <a href="https://www.cs.uoregon.edu/research/summerschool/summer18/topics.php">OPLSS lecture materials</a>, including notes and video recordings of the lectures</li> </ul> <p>I gave four lectures which started with the mathematics of algebraic theories, explained how they can be used to model computational effects, how we make a programming language out of them, and how to program with handlers.</p>Andrej BauerI have had the honor to lecture at the Oregon Programming Language Summer School 2018 on the topic of algebraic effects and handlers. The notes, materials and the lectures are available online: the GitHub repository with the course material the OPLSS lecture materials, including notes and video recordings of the lectures I gave four lectures which started with the mathematics of algebraic theories, explained how they can be used to model computational effects, how we make a programming language out of them, and how to program with handlers.