Chess

Chess is a board game, with 8×8 tiles and some figures on them. It’s a turn-based game, usually played by two players (or one, for practicing), and the players move these figures accordi… | Continue reading


@bor0.wordpress.com | 2 years ago

Towards Hoare logic for a small imperative language in Haskell

Recently I finished Logical Foundations, and I have to admit it was an excellent read. This post is directly inspired by the Simple Imperative Programs section of the same book. What is an imperati… | Continue reading


@bor0.wordpress.com | 3 years ago

Proof: One Sunday every 7 days

DST changes in North Macedonia on the last Sunday of October. It happens to be the 25th of October this year. What can we do with the previous statement, other than generalize it and try to prove a… | Continue reading


@bor0.wordpress.com | 3 years ago

A simple Constraint Programming implementation

Constraint programming is a programming paradigm where problems are stated declaratively. In this post, I will implement a very simple constraint solver. | Continue reading


@bor0.wordpress.com | 3 years ago

Superliminal Game Overview

I used to play a lot of video games, and nowadays not that many. But I have never written a game overview. I believe this game deserved one. | Continue reading


@bor0.wordpress.com | 3 years ago

Deriving a Quine in a Lisp

As with my previous post, this post is another excerpt that will be included in my final Master’s thesis, but I decided it is interesting enough to post it on its own. We start with a definition of… | Continue reading


@bor0.wordpress.com | 4 years ago

Equational Reasoning in Racket

This post is an excerpt that will be included in my final Master’s thesis, but I decided it is interesting enough to post it on its own. We will define a few of Peano’s axioms together … | Continue reading


@bor0.wordpress.com | 4 years ago

Encoding probability and random variables in Racket

This blog post will serve as a quick tutorial to basic probability and random variables, and encoding them in Racket. It assumes basic knowledge with sets and programming. | Continue reading


@bor0.wordpress.com | 4 years ago

Idea: News Diversity

As with most of my mornings, they start with a coffee and reading the news on time.mk – news portals' aggregator. At the time of writing this post, there are about 115 sources on the sou… | Continue reading


@bor0.wordpress.com | 4 years ago

Formalizing Expresiveness of Line Editors

According to Wikipedia, a line editor is a text editor in which each editing command applies to one or more complete lines of text designated by the user. We will implement our own line editor in C… | Continue reading


@bor0.wordpress.com | 4 years ago

Proving Groupoids with Idris

Exactly a year ago, in one of my previous posts, we proved Monoid laws with Idris. We’ll do the same with Groupoids. | Continue reading


@bor0.wordpress.com | 4 years ago

Freedom of Creativity

I like puzzles. If it’s a non-trivial one, in order to come up with a solution I usually spend a few days (on and off) thinking about it. But it also has to be interesting to get my attention… | Continue reading


@bor0.wordpress.com | 4 years ago

Tuply Singleton v3 (With Proof)

In my previous post, I had a different approach to Tuply singleton. This is the third and last post in the Tuply singleton series. We will provide mathematical proof for correctness, and also show … | Continue reading


@bor0.wordpress.com | 4 years ago

Tuply Singleton v2

In my previous post I showed how we can encode a pair into a single number. I found out that encoding is wrong for some numbers. For example, consider the pairs $latex \{ (0.4, 3), (2.8, 2) \}$. If… | Continue reading


@bor0.wordpress.com | 4 years ago

Tuply Singleton

I noticed this while at a company team meetup. Whenever we were discussing which place we should eat food at, most of my coworkers were paying attention to two numbers: rating and number of votes. … | Continue reading


@bor0.wordpress.com | 4 years ago

One plus one equals two

Suppose one of your programmer friends comes to you and says: “Hey, convince me that 1 + 1 = 2!”. What a request. You start by “Okay, I have one apple in my hand. I grab another o… | Continue reading


@bor0.wordpress.com | 4 years ago

Generalized Average

These are the values I get on my 3rd day of running, after a long break: 4’48” or 12.5 km/h (= 60/4’48”) for distance 2.06km 4’53” or ~12.29 km/h for distance 1.… | Continue reading


@bor0.wordpress.com | 4 years ago

Arithmetic on Algebraic Data Types

Per Wikipedia, an algebraic data type is a kind of composite type, i.e., a type formed by combining other types. Haskell’s algebraic data types are named such since they correspond to an init… | Continue reading


@bor0.wordpress.com | 4 years ago

Brief Introduction to ML with Gradient Descent

In Mathematics, there are many curves. From a constant curve $latex f(x) = b$, to a linear one $latex f(x) = ax + b$, to a quadratic one $latex f(x) = ax^2 + bx = c$ to …, you name it. Now, i… | Continue reading


@bor0.wordpress.com | 4 years ago

Customer-Driven Engineering

We’re in the process of renovating our house with my wife. We have a bunch of “engineers” working on it: electricians, plumbers, wall painters. These guys have direct contact with… | Continue reading


@bor0.wordpress.com | 4 years ago

Lambda Calculus with Generalized Abstraction

Lately I’ve been thinking about this: What do we get if we change lambda calculus’s abstraction from (λx.M) to (λN.M), where M and N are lambda terms, and x is a variable? That is (foll… | Continue reading


@bor0.wordpress.com | 4 years ago

Writing a lambda calculus evaluator in Haskell

This tutorial serves as a very short and quick summary of the first few chapters of TAPL. My previous post was a general overview of how we can design an evaluator and a type checker. This post is … | Continue reading


@bor0.wordpress.com | 5 years ago

Dependently Typed Lambda Calculus in Haskell

I found this awesome paper “A tutorial implementation of a dependently typed lambda calculus”, by Löh, A., C. McBride, W. Swierstra and I decided to give it a go. I read the paper a few… | Continue reading


@bor0.wordpress.com | 5 years ago

Proving Monoids with Idris

I was watching an interesting video, Opening Keynote by Edward Kmett at Lambda World 2018. Note in the beginning of that video how in Haskell you’d put code comments in place of proofs. Enter… | Continue reading


@bor0.wordpress.com | 5 years ago

Partial orders in Idris

A binary relation $latex R$ is a partial order if the following properties are satisfied: Reflexivity, i.e. $latex \forall a, a R a$ Transitivity, i.e. $latex \forall a, b, c, a R b \land b R c \to… | Continue reading


@bor0.wordpress.com | 5 years ago

Mathematical structure of `git-bisect`

According to Wikipedia, the bisection method in mathematics is a root-finding method that repeatedly bisects an interval and then selects a subinterval in which a root must lie for further processi… | Continue reading


@bor0.wordpress.com | 5 years ago

Lambda calculus implementation in Scheme

Lambda calculus is a formal system for representing computation. As with most formal systems and mathematics, it relies heavily on substitution. We will start by implementing a subst procedure that… | Continue reading


@bor0.wordpress.com | 5 years ago

Closed-expression of a sum with proof in Idris

One well known fact is the sum $latex 1 + 2 + \ldots + n = \frac {n(n + 1)} {2}$. Let’s try to prove this fact in Idris. We start intuitively by defining our recursive sum function: Testing i… | Continue reading


@bor0.wordpress.com | 5 years ago

Proving length of mapped and filtered lists in Idris

First, let’s start by implementing map’ and filter’ for lists: Trying a few cases: Looks neat. A valid question would be: What do we know about the length of a mapped and length o… | Continue reading


@bor0.wordpress.com | 5 years ago

Simple theorem prover in Racket

In an earlier post, we’ve defined what formal systems are. In this example, we’ll put formal systems into action by building a proof tree generator in the Racket programming language. W… | Continue reading


@bor0.wordpress.com | 5 years ago

Effects of Side effects

Recently I was working on a project that involved the usage of PayPal REST API SDK. To give a little bit of background, starting in PHP 7.x (I believe 7.2), the language will throw a warning if you… | Continue reading


@bor0.wordpress.com | 5 years ago

Creating our own ‘struct’ macro in Racket

One thing that was always interesting to me about Lisps in general is their minimality, which means that with a couple of starting points you can implement almost anything in the language, even par… | Continue reading


@bor0.wordpress.com | 5 years ago

Refactoring using mathematical properties of min

Today I refactored a small piece of code. Before: After: This was intuitive to me, but I wanted to prove that it really does the same thing. For that, we need to use the property $latex min(a ̵… | Continue reading


@bor0.wordpress.com | 5 years ago