A simple fact about politics

Disclaimer: I am not a politics expert (whatever that may mean) nor have I read any books about politics. My background is in software engineering and maths.

Every party wants to be the ruling party

  1. A political party is formed with the intent of it to be a ruling party.
  2. A political party spends resources on marketing.
  3. Therefore every political party wants to be ruling.

Every politician must lie sometimes

  1. Assume a politician of a party A always tells the truth.
  2. Assume there’s an opposing party B.
  3. Since every political party wants to be ruling, opposing party B can abuse the truth.
  4. Since every political party wants to be ruling, Party A doesn’t want the truth to be manipulated and lose points.
  5. Therefore it is not the case that a politician of party A always tells the truth, that is, a politician of party A must lie sometimes. Without loss of generality, every politician must lie sometimes.

Lying can be a simple fact about GDP, or even worse when combined with the fact that every party wants to be ruling: manipulate the population into believing that the other party is the ultimate evil.

Recursion from first principles

Recursion is one of the things that makes computation happen – whether you’re doing something on your computer, smart TV, or smartphone.

For example, here’s a definition of the addition function represented in first-order logic:

\forall y, add(0, y, y) \\ \forall x, y, z, add(x, y, z) \to add(S(x), y, S(z))

Or, the more commonly known variant:

\begin{aligned} 0+y &= y \\ S(x)+y &= S(x+y) \end{aligned}

In this blog post, we will generalize recursive functions.

Continue reading “Recursion from first principles” →

Implementing a formal system in Python

Some of the contents of this post are contained in my third book.

In this post, we’ll go deeper into the syntactical part of a formal system, along with the semantical. We’ve discussed formal systems in the past, and in this post, we’ll get more practical by providing an implementation of an example formal system.

Continue reading “Implementing a formal system in Python” →

An algorithm for a BNF matcher

BNF (short for Backus-Naur Form) is a notation for specifying syntaxes. It allows specifying syntax with sums (|) and products (). For example, foo ::= 1 | 2 specifies that foo can be either 1 or 2, and baz = <foo>2 specifies that baz can be either 12 or 22.

A BNF matcher is a program that takes as input a grammar and a string and tells us whether the string is captured by the grammar or not. A BNF parser works similarly, but instead, it generates a syntax tree out of it rather than telling if a particular string matches the structure.

BNF is important because it’s used as the syntax of languages in computing, mainly in programming languages. That is, any time you get a “Syntax error! Missing ;” or a similar error, you can freely blame BNF 🙂

We will start with a concrete example, then give a general algorithm and finally write a BNF matcher in PHP and Lisp.

Continue reading “An algorithm for a BNF matcher” →

The computation of appending lists at the type and value level

Recently, I spent some time experimenting with Haskell’s type families – a concept that allows one to perform computation at the type level in Haskell.

In one example, I wrote an append implementation at the value and the type level, and also other stuff such as Merge Sort implementation at the type level.

In this post, I will show different implementations of appending two lists together, written both in Haskell and in Idris, as well as some observations around the differences.

Continue reading “The computation of appending lists at the type and value level” →