Monday notes from 8 June 2020

It's a bit of a long one this week. I think I've just had a lot of coffee!

Go. I had my second 13×13 go game over the course of the last week. Like no other game I've played, go has this property of unfolding itself to you as you play, and each game is an education. Compared to my first 13×13 game, the main lessons — whether from mistakes or from successes — were:

I am improving at reading ahead, especially when using the analyser. Doing so seems to reveal small patterns and move sequences that act as little lessons. Chris is open to undoing moves if we would learn something from the undoing, and we've now rewound and started playing a fork of the second game from a critical point.

Given these lessons, the next goal for me is to learn a few of the basic eye shapes. There are a few hundred strong eye shapes, but at my level, apparently, the basic five will make a big difference.

I've also tried to get my nephew into go by introducing him to atari go via the Goban app on my computer. He internalised and applied the basic rules within minutes, doing well in a game or two of atari go on a 7×7 board, but after I called it 'the board game' (a paraphrasing of BoardSpace's opinion), he declared it 'the worst board game... with pebbles'. I still have a bit of work to get him into it. I have ordered an simple go set from Hoyle's, since I think maybe it'll be more enjoyable to play away from the computer. We'll see — I won't give up!

Haskell. My simple GPS trails app is plodding along. I'm not really adding much in the way of features, more that I'm trying to prune and tweak the code — AST topiary — to make it more concise and functional. As an erstwhile Prolog guy, I'm used to recursion, but converting things to folds where possible really made things look nice.

I wanted to go somewhere else with my Haskell, though, and on Sunday afternoon I started experimenting with algebra in Haskell. I'd enjoyed learning about structures like monoids, and I wanted to see how some other algebraic structures could be defined and implemented.

The Haskell Prelude is a module which contains the basic, standard definitions. They are seen by many as not ideal for working with abstract structures. It's imported by default, but fortunately you can disable that and use your own Prelude — your own custom Prelude to suit your application and your philosophy on the structure of types within it. Numeric Prelude provided a re-orientation toward abstract structures, in the words of its package description, 'an experimental alternative hierarchy of numeric type classes'. Algebraic Prelude is another drop-in replacement for Prelude based based on the algebraic hierarchy provided by the algebra package for constructive abstract algebra.

More generally, Haskell is sometimes recommended for mathematical work, or at least for mathematicians, even though purpose-built languages like Macaulay2 are out there. And functional programming is most often connected with logic — not least because of the Curry-Howard isomorphism — and category theory, but I'm more talking about using Haskell to explore mathematics, rather than using mathematics to understand Haskell. So it's time for another project.

Machine learning. I think I should start with something simple and familiar, so I'm going to try to code up, in a general way, a version space learner, a concept learner. It's a binary classifier, that is, a learner that decides whether an instance is to be labelled as one thing or the other. This kind of learning was the first topic in the first textbook we studied in my machine learning MSc course twenty years ago! It's summarised well in the slides for that chapter.

So, a quick overview of the ideas:

The logical language in the most basic implementation of all this would be just propositional. That is, the examples are just yes/no values describing aspects of the weather (sunny? rainy? snowing?). However, you could use any suitable logical language, as long as you could decide generality between the descriptions. Inductive logic programming, one of the focuses of my PhD thesis, commonly uses first-order Horn clauses instead.

Learning in this way isn't exactly popular, and one reason for that is that version space learning doesn't handle noise. It fits the data perfectly, and that means encountering any two examples which are inconsistent just result in an empty version space. From there you can't really learn anything! Although this learning strategy has been generalised to noisy data, the setting I lay out above is far too limited to be useful for real-world learning. But, it's a start.

So, coming back to my Haskell mini-project, I'm going to be basically playing with lattices or partially ordered sets at one level, and propositional and perhaps other logics at another. Lattices are modelled by the Algebra.Lattice module inside Numeric Prelude, but, playing around a bit, it seems that the Ord class is the only way of representing an order, and it must be total. algebra supports partial orders, but there's a purpose-built lattices package which looks more fine-grained and useful for this application. I plan to try both algebra and lattices, just to get a feel for things. The basic mechanics of the logic can be handled by, for example, logic-classes, though I could just code up the propositional case myself. If I can keep the two layers separate I might be able to do some cool tricks.

And, as you'd expect, all this has been done already in AI.VersionSpaces, so none of this is remotely ground-breaking except for me. But I hope it'll serve as a familiar place from which to explore working with algebraic structures with Haskell, from which I can head out into less familiar territory.

To support this interest in maths and logic with Haskell, I'm also going to try to read at least a couple of chapters of The Haskell Road to Logic, Maths and Programming by Jan van Eijck and Kees Doets. In the preface it states:

The purpose of this book is to teach logic and mathematical reasoning in practice, and to connect logical reasoning with computer programming.

and later,

The subject of this book is the use of logic in practice, more in particular the use of logic in reasoning about programming tasks. Logic is not taught here as a mathematical discipline per se, but as an aid in the understanding and construction of proofs, and as a tool for reasoning about formal objects like numbers, lists, trees, formulas, and so on. As we go along, we will introduce the concepts and tools that form the set-theoretic basis of mathematics, and demonstrate the role of these concepts and tools in implementations. These implementations can be thought of as representations of the mathematical concepts.

This sounds ideal.

Beekeeping. I've been looking after my nephew on some of the afternoons this week, too. We've slowly been working our way through building a Bees on a Budget hive for the next swarm. It may require only a basic level of carpentry to assemble one of these, but it's good practice for both me and him.

We hope it'll be put in the apiary early this week, or later this week if we opt to stain it.

Screen time. The pandemic lockdown is still mostly in force in England, and is even stricter in the other countries of the United Kingdom. Since its sixth day, a few friends (initially me, Holly and Red) have been holding a virtual cinema.

Using streaming services synchronised by a countdown, we'll watch one or two films a week, with a beer or wine in one hand and in the other, a device connected to our chatroom. The films have so far formed thematic triples (or quadruples): folk horror, neon noir, gems of the Hollywood left, or Lynch.

So far we've watched a dozen films, but by far the favourites have been those by Ari Aster. We are all fans of horror, and for us, these were absolute cinematic nightmares. So far Aster has made two feature-length films, Hereditary (2018) and Midsommar (2019). Both are beautifully paced, shot and performed. Neither gives away everything on the first viewing, but enough to creep you out, so you won't necessarily want to watch either again right away!

When the lockdown began, we half-joked that we'd like to put on a folk horror film festival in an old creepy country pub somewhere in the middle of nowhere. I hope we do that.

(I updated some of the explanations in this note thanks to some feedback from Tim — thanks, Tim!)