Josh Ko’s blog

0038 · 5 Jun ’24

A variation of the binomial tree datatype, and some more thoughts on a theory of datatype integration.

0037 · 24 Apr ’24

The immediate sublist induction problem seems to point towards some general theory about datatype and program integration.

0036 · 5 Jan ’24

Parametricity is used to prove that the types of both the standard induction principle for natural numbers and the immediate sub-list induction principle are uniquely inhabited (up to extensional equality).

0035 · 22 Dec ’23

I chaired the APLAS 2023 student research competition and the associated poster session, and here’s a report, which may be useful to future SRC chairs.

0034 · 1 Oct ’23

A derivation from a generic top-down specification of divide-and-conquer computation to a bottom-up implementation is reformulated and clarified using dependent types, category theory, and string diagrams.

0033 · 20 Aug ’23

Some rough notes about amplitude amplification and Jordan’s lemma, with some extrapolations about what we should have in a high-level quantum-algorithmic language from what I’ve seen.

0032 · 20 Mar ’23

If the result of a measurement is a uniform distribution, then no quantum information is lost. It turns out that this intuition can be straightforwardly formulated in the graphical quantum theory.

0031 · 24 Feb ’23

To complete the Bell basis trilogy, we also look at entanglement swapping, which, though slightly more complex, can be presented naturally in ZX-calculus.

0030 · 17 Feb ’23

Another popular example that makes use of the Bell basis is dense coding, which is a name I find misleading though.

0029 · 27 Jan ’23

Two graphical presentations of quantum teleportation are given, one directly working with concrete definitions in ZX-calculus, and the other developing a higher-level structure.

0028 · 9 Oct ’22

The Bernstein-Vazirani algorithm is closely related to Deutsch–Jozsa, but I have to fall back to the conventional understanding of the oracle construction —encoding function outputs as phases— to deal with this one.

0027 · 24 Sep ’22

The Deutsch–Jozsa algorithm is one of the simplest quantum algorithms, although the traditional presentation is still rather obscure (at least to beginners). With the help of the ZX-calculus, we can actually see that the algorithm is no more than a twisted form of a simple computation.

0026 · 31 Mar ’22

A rudimentary experiment in writing imperative programs functionally.

0025 · 20 Dec ’21

If we model computation as generating a potentially infinite colist of states, then termination is the ability to cast this colist into a finite list.

0024 · 11 Oct ’21

We take a look at the left scan as a simple application of the traced state monad, which gives us an opportunity to revisit productivity checking and Danielsson’s embedded language technique.

0023 · 1 Oct ’21

The traced state monad is useful for revealing intermediate states even when computation does not terminate and reach a final result. Reasoning about the traced state monad is elementary but inherently extensional, which used to be a problem for proof assistants, but Cubical Agda changes all that.

0022 · 10 Aug ’21

I played a bit with (a simplified version of) Allais et al’s traversal operator for syntax trees with λ-style binders and variables as de Bruijn indices — which translates terms to functions taking an environment as input and manages the environment for the user — and experimented with a corresponding induction operator (not really successfully).

0021 · 22 Jun ’21

This year more people started to join me for tea, and I decided to set up a ‘tea bar’ with which I can hold a nice ‘tea party’ in my office anytime I like.

0020 · 4 May ’21

A bit of fun with identifying states on the Bloch sphere in ZX-calculus, which involves a bit of fun with trigonometry.

0019 · 5 Apr ’21

We perform a (not so successful) experiment that proves a simple graph-theoretic property (an induced sub-graph of a directed acyclic graph is also acyclic) in relational calculus.

0018 · 16 Mar ’21

A (simple) construction that realises the principle of deferred measurement is described (and proved correct) in ZX-calculus.

0017 · 9 Feb ’21

Naturality enters the picture as we prove that the two formulations of optimising definitions in terms of universality and isomorphism are equivalent.

0016 · 7 Feb ’21

An important special case of adjunctions is Galois connections, which can be very helpful for reasoning about order-theoretic optimising definitions.

0015 · 6 Feb ’21

The universal property of (categorical) products can be reformulated as a useful family of isomorphisms.

0014 · 23 Dec ’20

Quantum theory starts with a few postulates about the states of quantum systems and how they evolve, and there are two formulations, one in terms of unit vectors and the other in terms of density operators. This post shows that the unit vector formulation gives rise to a very simple transition system, which we can then transform and optimise to get a transition system corresponding to the density operator formulation.

0013 · 30 Oct ’20

We experiment with formulating the paradoxical arguments for the undecidability of the halting problem and, more generally, Rice’s theorem in a modally typed setting using (a variation of) Kavvos’s intensional recursion, whose type corresponds to the Gödel–Löb axiom.

0012 · 21 Sep ’20

With path calculations similar to those in 0011, we can prove a couple more important theorems in HoTT: Hedberg’s theorem and the incompatibility between univalence and the unconstrained law of excluded middle.

0011 · 18 Sep ’20

From one lemma, this post proves in Homotopy Type Theory that (i) equality types on a contractible type are also contractible, and that (ii) the definitions of sets and mere propositions match the general definitions of 0-types and (−1)-types.

0010 · 30 Jul ’20

At FLOLAC ’20 I will present Conor McBride’s showcase example in his original ornament paper, where the evaluation of additive expressions (which he calls ‘Hutton’s razor’) is compiled to instructions for a stack machine, and the preservation of semantics is proved purely by datatype indexing.

0009 · 21 Jul ’20

As a short intern project, we’re formalising a semantics-preserving translation from finitely typed circuits to boolean ones, so that properties proved for the compiled boolean circuits by SAT solving can be transferred back to the typed circuits.

0008 · 26 Jun ’20

One nice thing that happened over the past few months was getting all the facilities I want in my office, of which this post is a quick tour. Quite a few pictures are included.

0007 · 7 Apr ’20

A while ago I wrote 0004 about eliminating quantifier alternation, which took a fair amount of logic formula manipulation. Not long after that, my colleague Yun-Sheng Chang came up with a reformulation that makes the solution much more streamlined; this post contains my presentation of the reformulation, along with a higher-level recap of what I did in 0004.

0006 · 25 Mar ’20

程式語言學對符號有近乎偏執的愛好與要求：我們以符號為工具精準簡練地表達程式與相關概念，用符號做厲害的事（證明程式性質），設計易用的符號，並且特別喜歡有多重內涵 — 特別是具有數學和邏輯學意義 — 的符號。本文為科普向。

0005 · 3 Mar ’20

This post is an incomplete digest of Andrej Bauer’s note *What is algebraic about algebraic effects and handlers?*. My goal is to arrive at a reasonable definition of handlers. (Spoiler: I don’t manage to achieve that goal, although we will see Bauer’s definition.)

0004 · 12 Feb ’20

I found that the type theory people and the verification people think about the same logical formulas in different or even opposite ways, which is quite interesting. This post contains a summary of an abstracted (and in fact distorted) version of the problem we discussed, and records some of the different ways of thinking of the two camps.

0003 · 1 Feb ’20

The key is to use the contrapositive universal property of the floor function.

0002 · 15 Jan ’20

Recently I reread Nils Anders Danielsson’s POPL 2008 paper *Lightweight Semiformal Time Complexity Analysis for Purely Functional Data Structures*, whose technique (implemented in Agda) has been adopted by a few groups of people…

0001 · 2 Dec ’19

If we regard the big-O notation as denoting classes/sets of functions, which I call ‘order classes’, we can start talking about their structures, and one such structure is the semiring of order classes. …

0000 · 21 Nov ’19

I am informally notified today that my application for the position of assistant research fellow at the Institute of Information Science, Academia Sinica (the national academy of Taiwan) has been approved, and I can expect to start at the beginning of the next year. With the start of the new job, it looks like a good opportunity to pick up the habit of blogging again. …