Mike Delmonaco's Blog: Mike Delmonaco's BlogMike Delmonaco's Blog: Mike Delmonaco's Blog
https://quasarbright.github.io/blog/index.html
Mon, 29 Apr 2024 22:57:22 UTMon, 29 Apr 2024 22:57:22 UT1800Math From Scratch: Creating a Proof Checker
https://quasarbright.github.io/blog/2024/04/math-from-scratch-creating-a-proof-checker.html?utm_source=all&utm_medium=RSS
urn:https-quasarbright-github-io:-blog-2024-04-math-from-scratch-creating-a-proof-checker-htmlMon, 29 Apr 2024 22:57:22 UTMike Delmonaco
<p>Math, at its core, is a network of facts that are undoubtably known to be true. We start out with some simple assumptions called axioms and prove new facts to be true using logic and reasoning. As long as the proofs are valid, then under the founding assumptions, anything that can is proven is definitely true. But when you’re proving something in math, how do you actually know if you’re doing it right? What if you make a mistake? What if you gloss over proving something which is "obviously true" that turns out to be false? One way to be sure is to have a computer check your proof, which is what we’re going to do. But first, we’re going to have to build math from the ground up.</p><a href="https://quasarbright.github.io/blog/2024/04/math-from-scratch-creating-a-proof-checker.html?utm_source=all&utm_medium=RSS"><em>More…</em></a>Guess-Free Minesweeper
https://quasarbright.github.io/blog/2024/04/guess-free-minesweeper.html?utm_source=all&utm_medium=RSS
urn:https-quasarbright-github-io:-blog-2024-04-guess-free-minesweeper-htmlMon, 01 Apr 2024 20:29:50 UTMike Delmonaco
<p>Have you ever played Minesweeper? If you have, you’ve probably run into a situation where you’re forced to guess, hoping you’re not about to step on a mine and lose the game. What if I told you it was possible to make it so you never have to guess in a game of minesweeper?</p>
<p>In this post, I’ll explain how I made a minesweeper solver and how I used the solver to generate guess-free minefields.</p><a href="https://quasarbright.github.io/blog/2024/04/guess-free-minesweeper.html?utm_source=all&utm_medium=RSS"><em>More…</em></a>Understanding and Implementing Algebraic Effects
https://quasarbright.github.io/blog/2024/04/understanding-and-implementing-algebraic-effects.html?utm_source=all&utm_medium=RSS
urn:https-quasarbright-github-io:-blog-2024-04-understanding-and-implementing-algebraic-effects-htmlMon, 01 Apr 2024 20:21:35 UTMike Delmonaco
<p>Algebraic effects are kind of like exceptions that you can resume from. They can be used to express computational effects like non-determinism, generators, multi-threading, and of course, exceptions. They are a slightly less confusing alternative to using raw continuations via operators like <span class="RktSym"><a class="RktValLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/reference/cont.html#%28def._%28%28lib._racket%2Fprivate%2Fmore-scheme..rkt%29._call%2Fcc%29%29">call/cc</a></span> and have other benefits like dynamic interpretation.</p>
<p>In this post, we will discover and implement algebraic effects using continuations in Racket. I will assume you are familiar with Racket and continuations. If you’re not, I have <a href="/blog/2023/09/continuations.html">the perfect post for you</a>!</p><a href="https://quasarbright.github.io/blog/2024/04/understanding-and-implementing-algebraic-effects.html?utm_source=all&utm_medium=RSS"><em>More…</em></a>Understanding and Implementing a Macro System
https://quasarbright.github.io/blog/2023/12/understanding-and-implementing-a-macro-system.html?utm_source=all&utm_medium=RSS
urn:https-quasarbright-github-io:-blog-2023-12-understanding-and-implementing-a-macro-system-htmlFri, 01 Dec 2023 03:11:00 UTMike Delmonaco
<p>Macros are a powerful tool that allow programmers to extend the syntax of a language. In a language with macros, features like for-loops, while-loops, and pattern matching can be implemented as a library by users of the langauge! In this post, we’ll discover what macros are, how and why to use them, and how to implement a tiny language with a simple macro system.</p>
<p>For this post, you’ll need some familiarity with Racket, but no familiarity with macros is required. If you don’t know what something is, click on the variable name in the code and you’ll be taken to its documentation.</p><a href="https://quasarbright.github.io/blog/2023/12/understanding-and-implementing-a-macro-system.html?utm_source=all&utm_medium=RSS"><em>More…</em></a>Everything from call/cc
https://quasarbright.github.io/blog/2023/10/everything-from-call-cc.html?utm_source=all&utm_medium=RSS
urn:https-quasarbright-github-io:-blog-2023-10-everything-from-call-cc-htmlSat, 21 Oct 2023 20:40:48 UTMike Delmonaco
<p><span class="RktSym"><a class="RktValLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/reference/cont.html#%28def._%28%28lib._racket%2Fprivate%2Fmore-scheme..rkt%29._call%2Fcc%29%29">call/cc</a></span> is a powerful tool for implementing custom control forms operators. However, <span class="RktSym"><a class="RktValLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/reference/cont.html#%28def._%28%28lib._racket%2Fprivate%2Fmore-scheme..rkt%29._call%2Fcc%29%29">call/cc</a></span> can be pretty unwieldy, so people tend to use delimited, composable continuations with operators like <span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/reference/cont.html#%28form._%28%28lib._racket%2Fcontrol..rkt%29._reset%29%29">reset</a></span> and <span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/reference/cont.html#%28form._%28%28lib._racket%2Fcontrol..rkt%29._shift%29%29">shift</a></span>. But what if I told you that these operators can be implemented using just <span class="RktSym"><a class="RktValLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/reference/cont.html#%28def._%28%28lib._racket%2Fprivate%2Fmore-scheme..rkt%29._call%2Fcc%29%29">call/cc</a></span>?</p>
<p>In this post, we’ll implement delimited continuations, composable continuations, <span class="RktSym"><a class="RktValLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/reference/cont.html#%28def._%28%28quote._~23~25kernel%29._dynamic-wind%29%29">dynamic-wind</a></span>, and parameters all from just <span class="RktSym"><a class="RktValLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/reference/cont.html#%28def._%28%28lib._racket%2Fprivate%2Fmore-scheme..rkt%29._call%2Fcc%29%29">call/cc</a></span>. I will assume a solid familiarity with continuations and Racket. If you aren’t very familiar, then feel free to check out my <a href="/blog/2023/09/continuations.html">continuations post</a> to get some background. But even having read that, you sould play around with them a lot to get familiar, because this post is pretty heavy on continuation weirdness!</p><a href="https://quasarbright.github.io/blog/2023/10/everything-from-call-cc.html?utm_source=all&utm_medium=RSS"><em>More…</em></a>Understanding and Implementing Pattern Matching
https://quasarbright.github.io/blog/2023/10/understanding-and-implementing-pattern-matching.html?utm_source=all&utm_medium=RSS
urn:https-quasarbright-github-io:-blog-2023-10-understanding-and-implementing-pattern-matching-htmlSat, 21 Oct 2023 16:07:06 UTMike Delmonaco
<p>Pattern matching is a very powerful tool used to destructure and perform case analysis on data.
It’s commonly found in more academic functional languages and has recently made its way into Python. In this post,
we’ll discover pattern matching and implement it in Racket.</p>
<p>I will assume that you have some familiarity with Racket. We’re going to be writing some macros, but general familiarity with macros should be enough, we’re not doing anything fancy.</p><a href="https://quasarbright.github.io/blog/2023/10/understanding-and-implementing-pattern-matching.html?utm_source=all&utm_medium=RSS"><em>More…</em></a>Pi Calculus: Understanding and Implementing Concurrency
https://quasarbright.github.io/blog/2023/10/pi-calculus-understanding-and-implementing-concurrency.html?utm_source=all&utm_medium=RSS
urn:https-quasarbright-github-io:-blog-2023-10-pi-calculus-understanding-and-implementing-concurrency-htmlFri, 13 Oct 2023 05:44:53 UTMike Delmonaco
<p>You may have heard of the lamdba calculus. It is a model of computation where everything is either a function, a variable, or a function call. It is the essence of functional programming and the theoretical foundation for modern functional programming languages. Even though it is very simple, it is just as powerful as any programming language since it is Turing-complete.</p>
<p>The pi calculus is a similar idea, but instead of functional programming, it is the essence of concurrent programming. For our purposes, it will serve as a simple example of a programming language with concurrency. In this post, we will explore and implement the pi calculus in Racket. This will give an idea of how modern programming languages implement concurrency.</p>
<p>This post requires some familiarity with Racket or any Lisp-like language. If you have read some of my Racket posts which explain Racket stuff, you should be fine. If you see something you don’t understand in the code, you can click on it and the link will take you to its documentation.</p><a href="https://quasarbright.github.io/blog/2023/10/pi-calculus-understanding-and-implementing-concurrency.html?utm_source=all&utm_medium=RSS"><em>More…</em></a>Solving Polynomials with Recursion
https://quasarbright.github.io/blog/2023/09/solving-polynomials-with-recursion.html?utm_source=all&utm_medium=RSS
urn:https-quasarbright-github-io:-blog-2023-09-solving-polynomials-with-recursion-htmlMon, 25 Sep 2023 12:29:02 UTMike Delmonaco
<p>In this post, we explore a simple and elegant algorithm to find the (real) zeros of a polynomial using recursion and derivatives.</p><a href="https://quasarbright.github.io/blog/2023/09/solving-polynomials-with-recursion.html?utm_source=all&utm_medium=RSS"><em>More…</em></a>Continuations
https://quasarbright.github.io/blog/2023/09/continuations.html?utm_source=all&utm_medium=RSS
urn:https-quasarbright-github-io:-blog-2023-09-continuations-htmlSun, 24 Sep 2023 12:37:35 UTMike Delmonaco
<p>Continuations are a powerful tool that allow you to implement control flow constructs like exceptions, generators, and multi-threading, and back tracking as libraries. That’s right, libraries! In a programming language that gives access to continuations, these features don’t have to be baked into the implementation of the language. In this post, we will explore what continuations are, how to use them, and how to implement them in a programming language as a pre-processing step.</p><a href="https://quasarbright.github.io/blog/2023/09/continuations.html?utm_source=all&utm_medium=RSS"><em>More…</em></a>Extending Automatic Differentiation to Higher Order Derivatives
https://quasarbright.github.io/blog/2023/07/extending-automatic-differentiation-to-higher-order-derivatives.html?utm_source=all&utm_medium=RSS
urn:https-quasarbright-github-io:-blog-2023-07-extending-automatic-differentiation-to-higher-order-derivatives-htmlFri, 07 Jul 2023 23:15:39 UTMike Delmonaco
<p>This is part 2 of a series of blog posts about implementing automatic differentiation. You can read part 1 <a href="/blog/2022/12/understanding-and-implementing-automatic-differentiation.html">here</a>. In this post, we extend our automatic differentiation system to support higher order derivatives.</p>
<p>Like the previous post, some knowledge of calculus is required and Racket-y stuff will be explained as we go.</p><a href="https://quasarbright.github.io/blog/2023/07/extending-automatic-differentiation-to-higher-order-derivatives.html?utm_source=all&utm_medium=RSS"><em>More…</em></a>Understanding and Implementing Automatic Differentiation
https://quasarbright.github.io/blog/2022/12/understanding-and-implementing-automatic-differentiation.html?utm_source=all&utm_medium=RSS
urn:https-quasarbright-github-io:-blog-2022-12-understanding-and-implementing-automatic-differentiation-htmlSun, 04 Dec 2022 16:17:10 UTMike Delmonaco
<p>\[
\DeclareMathOperator{\expt}{expt}
\DeclareMathOperator{\mul}{mul}
\DeclareMathOperator{\add}{add}
\DeclareMathOperator{\derivative}{derivative}
\]</p>
<p>Automatic differentiation is a technique that allows programs to compute the derivatives of functions. It is vital
for deep learning and useful for optimization in general.
For me, it’s always been dark magic, but I recently thought of a nice way to implement it and made a little library. This
blog post takes you along the journey of discovering that implementation. Specifically, we will be implementing forward mode
automatic differentiation for scalar numbers.</p>
<p>This post requires some knowledge of differential calculus. You’ll need to know basic derivative rules, the chain rule,
and it’d help to know partial derivatives. If you’ve taken an introductory calculus course, you should be fine.</p>
<p>The code is in Racket. If you don’t know Racket, you should still be able to follow along. I’ll explain the Racket-y stuff.
Don’t let the parentheses scare you away!</p><a href="https://quasarbright.github.io/blog/2022/12/understanding-and-implementing-automatic-differentiation.html?utm_source=all&utm_medium=RSS"><em>More…</em></a>Matching Regular Expressions by Computing Their Derivatives
https://quasarbright.github.io/blog/2022/11/matching-regular-expressions-by-computing-their-derivatives.html?utm_source=all&utm_medium=RSS
urn:https-quasarbright-github-io:-blog-2022-11-matching-regular-expressions-by-computing-their-derivatives-htmlSat, 05 Nov 2022 16:01:01 UTMike Delmonaco
<p>Regular expressions allow us to describe patterns in text. They are very useful and show up all over the place in programming,
but matching regular expressions can be difficult. One well-known technique for matching regular expressions is converting the regular
expression to a finite state machine. This is pretty elegant, but can get complicated and messy.</p>
<p>An alternative technique, which is the subject of this blog post, involves something called a Brzozowski derivative. This technique can be
used to compute the derivative of a generalized regular expression.</p><a href="https://quasarbright.github.io/blog/2022/11/matching-regular-expressions-by-computing-their-derivatives.html?utm_source=all&utm_medium=RSS"><em>More…</em></a>Composable Promises: Adding Laziness to a Strict Language and Collapsing Indirection
https://quasarbright.github.io/blog/2022/10/composable-promises-adding-laziness-to-a-strict-language-and-collapsing-indirection.html?utm_source=all&utm_medium=RSS
urn:https-quasarbright-github-io:-blog-2022-10-composable-promises-adding-laziness-to-a-strict-language-and-collapsing-indirection-htmlSun, 02 Oct 2022 21:20:34 UTMike Delmonaco
<p>Before there is any confusion, I’m not talking about JavaScript promises that are used for asynchronous computations.
In this case, a promise is just a delayed computation. For example, a simple form of a promise is a function that
takes in no arguments and returns a result. In this blog post, we will be focusing on promises that remember their
results and promises that may evaluate to other promises. Promises are useful for control flow and implementing
lazy semantics in a strict language.</p>
<p>In this blog post, we will learn what promises are and how to implement them efficiently. Promises are useful and
interesting, but honestly, I mainly wrote this just to talk about the algorithm for forcing composable promises because I
think it’s very cool!</p><a href="https://quasarbright.github.io/blog/2022/10/composable-promises-adding-laziness-to-a-strict-language-and-collapsing-indirection.html?utm_source=all&utm_medium=RSS"><em>More…</em></a>