This is ridiculous. One man with Claude, forget about Lean4.
Egel Language
Thursday, December 3, 2026
Wednesday, October 7, 2026
Dabbling with Lean4
Given all the Lean4 AI proofs, I thought I'd dabble with that a bit myself.
Formalisations matter, as I learned the hard way during my PhD studies. It's completely possible that a formalisation works out on paper, but is 'impossible' to work with in an interactive theorem prover.
So, I thought I'd revisit possibly infinite streams in Lean4 and came up with the formalisation below. But I now think I should reject it as 'another wrong attempt at formalising a co-inductive type.'
A series is a set of lists closed under prefix that shares all prefixes.
Sunday, September 20, 2026
AI Assisted Proofs
Compared to model checkers that just exhaustively search a well-defined state space, there's not a lot of reason to believe in opaque, large proofs of interactive theorem provers at this moment. Four reasons.
- There's a problem with the math. If there's one 'paradox' like Banach-Tarski, there are probably an infinite number of them. What if the proof exploits one?
- There's a problem with the logic. At one point in time, I understood the rather simple type theories people worked with. I don't understand the current ones, so maybe I shouldn't comment on it, but I am unsure how robust they are.
- There's a problem with the implementation of the type theory. Usually, that would boil down to a kernel bug, but there's ample reason to believe it may lie elsewhere. For example, the presentation of a proof.
- There's a problem with the formalisation. I.e., something was stated, but it turns out that didn't reflect the math correctly, and subsequently something else was proven.
Thursday, March 26, 2026
Peirce's Law in Egel
Like Scheme, Egel has a trivial inhabitant of Peirce's Law ((p->q)->p)->p too.
def peirce = [F -> try F [X -> throw X] catch [X -> X]]The combinator peirce has Peirce's law as type and takes as an argument a function F of type (p->q)->p and we feed that function another function of type p->q that throws its argument X of type p to the outer scope.
Utter bullshit, of course.
Friday, January 16, 2026
Matching recurring variables
Monday, September 1, 2025
Lazy Streams
I did a small Lean experiment with lazy streams. It failed, but I wanted to write it down anyway.
inductive Sequence (α : Type u) : Type u
| nil : Sequence α
| cons : α → (Unit → Sequence α) → Sequence α
Let's look at slicesdef slice : Nat → Sequence α → List α
| 0, _ => []
| _, .nil => []
| n + 1, .cons a f => a :: slice n (f ())
and prove the following.theorem sequence_extensionality {α : Type u} (s₁ s₂ : Sequence α) :
(∀ n : Nat, slice n s₁ = slice n s₂) → s₁ = s₂ := by
sorry
So far so good. But unfortunately, this models finite lists. On the following, Lean cannot prove termination.def zeroes : Sequence Nat := Sequence.cons 0 (fun x => zeroes)
Moreover, falsum is trivially inhabited by induction. example (x : Sequence Nat) (h : x = .cons 0 (fun _ => x)) : False := by
induction x with
| nil =>
contradiction
| cons a f ih =>
simp only [Sequence.cons.injEq] at h
apply ih ()
conv => lhs; rw [h.2]
dsimp
rw [h.1]
We could try the following, but it just results in finite lists.def zeroes : Nat -> Sequence Nat
| 0 => .nil
| n + 1 => .cons 0 (fun _ => zeroes n)
End of experiment for me, I was just interested whether a formalization like this could work.
Wednesday, December 25, 2024
Lessons learned from Advent of Code 2024
I should have kept a log, but here we are: a bullet list of lessons learned from Advent of Code this year in no particular order.
- Egel is a fine language for short scripts, but—here we go again—it lacks an order in performance.
- When I do stuff right, and this year I did, Egel programs are comparable in size to Haskell programs but -in my mind- way more readable.
Where Haskell shines is sometimes clever use of laziness and -very important- list comprehensions. Egel sometimes shines because of clever use of dynamic typing (usually the use of none), and having mutation.
In comparison to K, both Haskell and Egel take an order more symbols. Ken Iverson was on to something. - Where Egel is slow that is usually due to several factors.
First, the interpreter implements a slow rewriter and something like a one-instruction increment which comes at virtually no cost in most imperative languages takes orders, and not a small amount, more.
Then second, I often iterate over dictionaries, which means first creating the list of keys and then folding over all those keys. I am not sure that is even that hefty a cost, but I should probably write folds and maps for dictionaries.
Third, looking up a value in a dictionary costs much more than indexing in an array.
That means that one example, day 6, which involves an enormous amount of iteration over a board, is very, very slow and times in at 12 minutes. - I added namespace mechanisms and that seems to be a win. Because I added namespaces however, and I still wanted to be able to include the out-of-the box utilities with a short statement I decided to uniquely name all combinators. (I.e., you'll normally find a length operator on lists, strings, and dictionaries, those now all have different names.)
That was a mistake, roughly I need to use the namespaces where nothing in System, OS, and List overlaps but it's fine to have a length operator on strings and use the namespace mechanisms to rename or include that in the manner deemed fit. - I should implement more generic combinators akin to Python or array languages like J/K. Just having add on atoms and complex data shortened the code substantially.
- I still get bitten by `-1` versus `-` `1`. I also got bitten by my dumb operator precedence heuristic, the latter did fine for a while but now I need to fix that.
- At the end of Advent of Code, programs become longer, and development becomes painful in Egel. I expected this but Egel is indeed only usable for relatively straightforward code.
For short programs, something like a missing or wrongly named argument is trivially found by inspecting the output after running the program. For longer complex programs, it becomes hard to see where the bug is without strong typing. - There was a segfault somewhere during coding this month I can no longer reproduce.
Egel programs and several metrics are in the README.
