I checked Clojure's core with Lean and found unreported bugs

https://s.conao3.com/blog/2026/e4f733

Comments

rvprasadNov 25, 2026, 6:36 PM
While the effort is interesting, I found two issues in the list.

First, (.indexOf (seq (byte-array [1 2 3])) 2) fails because byte arrays store bytes and the argument 2 to `.indexOf` is a Long value. Simple type checking (via eyeballing) could have flagged the incorrect usage. I think such exercises can be more helpful if we can reduce the noise.

Second, (get "abc" 1.9) fails because `get` coerces the given key to integer in the context of string objects, which makes sense; specifically in the context of weakly typed language. That said, I believe that detailed documentation of the behavior of `get` can help clients just as well as returning `nil` or not-found value. However, we are still left with questions such as "who and where do we draw the line about the dynamism of the language?" and "what is the agreed upon semantics that we are checking against?"

devinNov 25, 2026, 8:15 PM
I'm kind of iffy on `(get "abc" 1.9)`. I feel like Clojure has always kind of went out of its way to not go to Ruby levels of implicit dynamism. Think things like: "5" * 3 => "555". Explicit > implicit has been a guiding principle in Clojure since the beginning. For that reason I think the behavior is... a little surprising, but also tend to agree I would stop short of calling it a "bug" in any meaningful sense of the word. I'm curious to see what the core maintainers decide to do about it, if anything. If I were a betting man I'd guess it will stay this way forever because existing programs may quietly (or not-so-quietly) rely on the current behavior.

Hyrum's law, anyone?

> With a sufficient number of users of an API, it does not matter what you promise in the contract: all observable behaviors of your system will be depended on by somebody.

vidarhNov 26, 2026, 2:44 PM
I'm more upset at the (get "abc" 1.9) and that "abc"[1.9] also works in Ruby, than I am that "5" * 3 results in "555". The former feels more surprising. There's an expectation that "*" must do something different to a string, so if in doubt I'd look it up. But that a float is quietly floor'ed was surprising enough to me that I've used Ruby for more than 20 years, written a compiler* for a good subset of Ruby, and still didn't realise.
rvprasadNov 25, 2026, 8:46 PM
I believe most significant/critical software (written in Clojure) would not pass a float/double as a key in the context of string object. At the same time, instead of evaluating the impact of such a change, the core team may just lean on Hyrum's law and decide to not change the behavior. It is also possible that the core team may just ignore this list.

So, while I prefer changing get's behavior to match our intuition in the context of string objects, I think it could go either way, which is not saying much :)

guenthertNov 26, 2026, 9:05 AM
> but also tend to agree I would stop short of calling it a "bug" in any meaningful sense of the word

Well, what does the specification say?

y1n0Nov 26, 2026, 1:16 AM
Can someone help me understand how this works? I’ve briefly looked at lean for helping me verify my chip designs, given recent hype. My take away was “not worth it” after the design stage. The hang up I kept running into is that there is no linkage between RTL and lean, so it’s up to me to model it in lean, and any apparent errors are 9 times out of 10 be my crappy model.

To be fair this is true in more traditional verification too but Systemverilog is designed to model digital logic with multiple levels of abstraction.

My first thought in reading the title is how likely is it they got their models right?

Modeling mathematical theorems is probably much more natural in lean, but even there it seems like flawed models are a huge risk. I think it’s mitigated by a greater set of peers skilled in validating these sorts of models. I m skeptical that is true of software or chip designs.

Now, during the design and architecture stage I imagine there can be a lot of value in proving a model before you commit to a design.

rvprasadNov 26, 2026, 2:40 AM
As different tools (e.g., SPIN, Z3) have been used as "checking engines" to realize verification solutions, I think trying to use Lean as a checking engine is understandable; more so, if Lean provides additional benefits (e.g., richer library, higher level of abstractions, performant checking) over other tools that help reduce modeling tedium, improve model fidelity, or speed up checking.

That said, I think the issue of model fidelity and spec/property correctness will still exist in a reduced form. Also, simpler solutions/tools may be better suited for certain classes of properties.

As for how this exercise worked, my guess is that the agent models both the SUT and the environment, encodes the property based on property templates, and checks the model for bugs (w/ counterexample) or correctness proof using a set of tactics; see https://github.com/hirosassa/lean-verify/blob/main/skills/le.... I hope the author or others can provide a better explanation.

dgoldstein0Nov 26, 2026, 2:09 AM
This seems like a valid question, though it sounds like he validated each finding with writing real counter examples against real code. So any errors in the model would lead to missed findings rather than erroneous bugs.
rvprasadNov 26, 2026, 3:56 AM
One of the bug is erroneous; see the first issue at the top of this thread. So, either the model for byte-array was erroneous or the translation of the counterexample into code was wrong.
saghmNov 26, 2026, 4:52 AM
> Simple type checking (via eyeballing) could have flagged the incorrect usage

Asking as someone who doesn't know Clojure (or really any lisp): are you saying that this isn't actually a bug, or that the bug could have easily been spotted by a human?

If the former, that certainly makes the output here somewhat questionable, but if latter, what you're saying basically sounds like it could apply to any runtime type error due to a lack of static type checking that's ever occurred (or really any bug at all); programmers are capable of noticing virtually any bug in theory, but in practice no one is actually able to catch all of them up front. Having a type system is useful because it genuinely does a better job than humans at spotting bugs like this. If you're using a dynamically typed language, there will be errors that human eyeballs could notice but didn't.

lkrubnerNov 26, 2026, 6:33 AM
(.indexOf (seq (byte-array [1 2 3])) 2)

This is not a bug. This is acting as you would expect once you realize the types you are looking at. While a simple reading of this would expect it to return the "3", this line doesn't return the "3" because the "2" is a Java Long, while the bytes are bytes.

vikramkrNov 26, 2026, 3:38 AM
The indexOf thing type checks fine and it's weird that contains and indexOf disagree - is the java spec not that they're supposed to agree for a byte array?
rvprasadNov 26, 2026, 6:05 AM
To clarify, by "type mismatch", I meant checking if an int value occurs in a byte array (and, hence, in the wrapping sequence). Of course, appropriate type coercion would prevent such a mismatch.

The disagreement between `.indexOf` and `.contains` is interesting. Nice catch!!

Digging into the code, `.indexOf` invokes `ArraySeq_byte.indexOf` while `.contains` invokes `ASeq.contains`. Interestingly, `ASeq.contains` and `ASeq.indexOf` have similar behavior while `ArraySeq_byte.indexOf` and `ASeq.contains` different behavior.

vitorsrNov 25, 2026, 6:52 PM
That is interesting, given heavy hitters like Nubank (Brazilian digital bank) basically runs on Clojure, having bought / acquihired Rich's Cognitect. I would normally expect such primitive types and functions to be spotless.
vemvNov 25, 2026, 8:25 PM
It's because these are darker, dusty corners of the language that people would use extremely rarely, and not at all for practically any commercial domain.
wavemodeNov 25, 2026, 9:29 PM
I wouldn't really call "reducing over a vector of longs" a dark and dusty corner of the language
lukevNov 25, 2026, 11:00 PM
`vector-of` isn't commonly used, and vectors longer than 2^16 are also rare (typically you'd use a native mutable array at that size, for performance), so it's not terribly surprising the intersection never showed up.
haolezNov 25, 2026, 8:36 PM
Is this still true? Or is Clojure a small piece of the puzzle nowadays?
lukevNov 25, 2026, 10:51 PM
Very much still true. Source: I work there, though this information is also googleable.
yababa_yNov 25, 2026, 8:40 PM
I found dozens of issues in sbcl, clozure, and ACL2 as well: https://github.com/emberian/common-lisp-compiler-audit
networkedNov 25, 2026, 7:10 PM
So this kind of work is done in Lean now, too? Based on a glimpse into the world of dependently typed languages in the 2010s, I assumed Rocq (formerly Coq) was used to verify program correctness.

Are language models significantly better at writing Lean than Rocq?

estherneyNov 25, 2026, 7:27 PM
I do think that Sledgehammer-like tooling in Rocq and Isabelle has historically been the main reason why these languages have been used for program correctness, however of course LLMs have completely diminished this advantage.

As for why Lean is now used: I guess it's just frontier labs having configured their RLVR environments for Lean? Not sure why, though intuitively I think of Mathlib.

dnauticsNov 25, 2026, 7:55 PM
Wasn't lean built to verify programs?
throwforfedsNov 25, 2026, 8:50 PM
There's a great, quick read on the history of Lean [1] that I read a couple months ago and yes, the original project's intent was for verifying programs.

[1] https://www.quantabooks.org/books/the-proof-in-the-code/

pona-aNov 25, 2026, 7:23 PM
Maybe the author is not an experienced researcher in this field, and was simply jumping on the hype-wagon of LLM-powered auto-formalization, and Lean recently had disproportional publicity.
sisciaNov 25, 2026, 7:02 PM
I really need to learn Lean and these testing mechanism
HavocNov 26, 2026, 12:42 AM
Yeah was thinking the same - it's showing up so much on hn all of a sudden
joelthelionNov 26, 2026, 7:34 AM
Does anyone know a good resource to start learning about this stuff?
gritzkoNov 25, 2026, 6:05 PM
On the practical side, Clojure sits on top of JVM which is humongous and likely unverifiable. On the theory side, very exciting!
pjmlpNov 26, 2026, 7:57 AM
Even if it was verifiable, it would be a single implementation, folks keep forgetting Java is like C and C++, there are plenty of implementations to chose from, not even OpenJDK distros are all alike.
coldteaNov 26, 2026, 8:41 AM
Not so different for this to matter, except if you need NASA level verification.

Most use OpenJDK upstream Java code and SDK and HotSpot jvm code. Even if you didn't also check vendor patches, the huge majority of code and behavior would still be covered by the verification, and this already covers the largest share of users.

pjmlpNov 26, 2026, 9:15 AM
They use different JIT, GC and AOT compiler implementations, that alone is enough to change behaviour, well depending on which runtime behaviours one would like to validate as the right way.

Then you have all the others that have nothing to do with OpenJDK, like PTC, Aicas, microEJ, and the myriad of embedded ones.

coldteaNov 26, 2026, 9:48 AM
>They use different JIT, GC and AOT compiler implementations, that alone is enough to change behaviour, well depending on which runtime behaviours one would like to validate as the right way.

We're talking about verifying the codebase, not the binary or the compiler.

pjmlpNov 27, 2026, 6:10 AM
The code isn't static.
HavocNov 26, 2026, 12:42 AM
With enough token...who knows what is possible
functionmouseNov 25, 2026, 6:41 PM
Flash was also absolutely everywhere and humongous and likely unverifiable.

-was-. JVM belongs in the same box.

oblioNov 25, 2026, 6:56 PM
Java will probably be there during humanity's dying hour.
ch4s3Nov 25, 2026, 7:27 PM
It’s what the terminators will be running.
tsearcherNov 25, 2026, 10:35 PM
3 billion of them.
ch4s3Nov 26, 2026, 4:03 AM
Being disemboweled by a blue-ray player is going to be pretty embarrassing.
orthoxeroxNov 25, 2026, 10:44 PM
And it will be Java 8.
krosaenNov 25, 2026, 5:31 PM
Having long admired clojure and Rich, I wonder what Rich makes of AI / agentic coding. I can imagine him having something really interesting and surprising to say, or being very anti-AI in an entertaining and persuasive way that ultimately feels destined to be a losing argument.
nextosNov 25, 2026, 5:32 PM
He has a very elaborate anti-LLM stance: https://www.linkedin.com/pulse/ai-tool-rich-hickey-kjl8e

Sadly, posted on LinkedIn, but in a nutshell, he claims that LLMs are not a tool, they are intrinsic automation.

And by using them, you are kinda giving up.

vegnusNov 25, 2026, 5:40 PM
I was sad when I read this. I thought Clojure + LLMs was like a match made in heaven for some reason
chr15mNov 25, 2026, 11:30 PM
It is a match made in heaven.

- Idiomatic Clojure code has less defects whether written by humans or by LLMs.

- Less code (more expressive).

- LLMs can use the REPL to explore and modify the program in real time, and functional code makes this safe.

Don't be sad. You can disagree with the creator of a technology and still use the technology.

[What tipped the scales for Closure] https://www.youtube.com/watch?v=tzzg8CVkl2A

https://mccormick.cx/news/entries/advantages-of-generating-c...

cmiles74Nov 25, 2026, 6:11 PM
It's one man's opinion, albeit the creator of the language. People will disagree and that shouldn't stop you from doing what works best for you.

Just the other day, someone told me "AI tools can write better code than you, right?", that gave me a chuckle. Yet that attitude is pervasive, I worry it encourages people to let the tool do all of the work. At that point I find myself agreeing with Rich: is it even a tool anymore?

BaronSamediNov 26, 2026, 2:24 PM
I don't think LLMs are "tools". They are sui generis. In practice they are more like collaborators. If you use an LLM like a tool you aren't going to get the most benefit from them.
superdiskNov 25, 2026, 7:04 PM
Hmm, I think the opposite. Clojure is very much a human-first language. It's all very "elegant" and fun to write, at the expense of the machine, and thus is very slow. That's the tradeoff you make. LLMs can spit out mountains of boring old C++ without issue, so having them write Clojure is kinda the worst of both worlds.
weavejesterNov 25, 2026, 8:12 PM
Optimized Clojure is on par with Java in terms of performance, which isn't hugely slower than C++. More idiomatic Clojure is less performant, but typically you'll optimize the hot paths.

The main advantage Clojure has in LLM use is that it has a good REPL. LLMs are quite fast at writing code; the bottleneck is often the time it takes to compile and test that code, which is higher for most compiled languages than it is for an open REPL. A LLM writing Clojure typically has a faster iteration loop than one writing C++.

And while I have no hard evidence of this, I also wonder if Clojure's general design philosophy of reducing complexity (i.e. interconnectivity) is also a benefit for LLMs. My experience is that LLMs tend to be more effective the more isolated and unconnected a piece of code is, which Clojure is specifically designed around.

e12eNov 26, 2026, 12:38 AM
Just a reminder that jank is maturing - so you can have clojure and c++ if you want:

https://news.ycombinator.com/item?id=50202762

https://lobste.rs/s/xbmjlj/would_you_believe_it_s_jank

ZambyteNov 25, 2026, 5:44 PM
Interesting, why? Whenever I have used LLMs with Lisps, they always get tripped up balancing parentheses due to the tokenization.
devinNov 25, 2026, 5:50 PM
The REPL loop is really fast for prototyping. The parens balancing thing hasn't been an issue for like 18 months.
casionNov 25, 2026, 5:49 PM
Have written millions of lines of lisp with LLMs (mostly clojure). I have never had this issue in any meaningful quantity comparable to forgetting ; or } (which happens, but is very rare and immediately fixed)
chuckadamsNov 25, 2026, 7:23 PM
I've not regularly run into LLMs generating braces wrong, but what they seem to do every damn day is get the boundaries of replacement regions wrong when using sed or python to make text substitutions, which shows up as unbalanced braces. I've always had a hard time getting consistent compliance when I tell them to use structural editing tools only.
zdragnarNov 25, 2026, 6:38 PM
IME small models definitely fail horribly with lisps. Qwen code and I think I tried 3.6 both choked on closing parens to the point they struggled to get anything at all to ever be syntactically correct.
networkedNov 25, 2026, 9:49 PM
Finally, a justifiable reason to indent Lisp like C.
vegnusNov 26, 2026, 1:42 AM
i did this as a joke for fun www.margeux.com/studio.html
vegnusNov 25, 2026, 5:49 PM
abstraction with macros, minimal syntax (((except these), and giving the LLM direct access to a REPL, to test as stuff is written.

I have used Lisps with LLMs a bit. I toyed around with an indented Lisp I developed with LLMs, to get rid of all the parenthesis, maybe make the LLM more capable of writing it since it looked somewhat closer to Python. I still play around with it, its nice to look at.

gpderettaNov 25, 2026, 9:07 PM
Opus 5.5 seems to be pretty good at elisp (at least as far as results go, I can't comment on the quality of the code).
bcrosby95Nov 26, 2026, 12:19 AM
Why? If you agree with anyone about everything, you probably aren't doing much thinking.
PUSH_AXNov 25, 2026, 6:38 PM
.
vegnusNov 25, 2026, 6:55 PM
I actually just started using other Lisps instead. My opinion is not invalidated at all
waffletowerNov 25, 2026, 7:05 PM
"It’s sadder that a person you’ve never met that you’ve put on a pedestal could invalidate your opinion." While not a world record there are multiple straw men in this sentence -- a fire hazard! I think I invalidated some of the de rigeur anti-AI tropes in Rich's post with my reply.
burnteNov 25, 2026, 6:42 PM
Are automations not tools? The same thing can be said about shovels. If you use a shovel, you've given up using your hands, but the shovel is better so why is it bad to give up when you have a better option? Doing everything the hard way isn't intrinsically "better".
mightyhamNov 25, 2026, 7:19 PM
You should probably read Rich's post before commenting on it.
burnteNov 28, 2026, 8:43 PM
I did, and I fundamentally disagreed with it and then asked a question.
geospeckNov 25, 2026, 6:01 PM
There was this post https://news.ycombinator.com/item?id=46415945 almost a year ago regarding his opinion on AI.
geokonNov 25, 2026, 6:27 PM
he has expressed anti-AI opinions but it's apparent he's not really used them extensively
arjunghose10Nov 25, 2026, 9:03 PM
[flagged]
ayon_jodderNov 25, 2026, 5:42 PM
[dead]
dmeadNov 25, 2026, 5:15 PM
I'm not sure the lisp community could consider these bugs.

Lisp/clojure/scheme etc is inherently untyped. These libs don't guarantee anything near to the level that a formal verification would suggest.

If this were the haskell standard lib however, that would be news.

jeremyjhNov 25, 2026, 5:21 PM
The article I read described clear correctness bugs unrelated to types.
pronNov 25, 2026, 5:54 PM
Even the types in Haskell are far too weak to be included in what we mean by "formal verification" (not to say they're not useful for some things, just that this is not the level of specification that formal verification is typically about). If we rank the strength of properties we can express with types in Clojure as 0 and in Haskell as 3 (or, say, 7 with refinement types), then the strength of types required for formal verification (e.g. in a language like Idris) would be 100.
agentultraNov 25, 2026, 6:29 PM
Indeed. I’ve viewed Haskell not as a high bar to clear. It’s rather low. And most languages don’t even clear it.

Things trickle down to Haskell from higher up but it takes a long time to incorporate them. Dependent Haskell has been in the making for like… 9 years? Maybe more? And it’s still being debated whether Haskell should even adopt it.

The type theory needed for formal proofs is much more advanced at this point. Idris, Agda, Lean, Roq… this is where you need to look to see the 100’s.

whateveracctNov 25, 2026, 11:57 PM
Idris and Haskell are not that far apart lol
packetlostNov 25, 2026, 5:18 PM
Some of these issues are actually quite bad and don't have anything to do with types at all
mtlmtlmtlmtlNov 25, 2026, 5:22 PM
Lisp is not untyped. It is dynamically typed.
kazinatorNov 27, 2026, 6:11 PM
"Untyped" is a political word used by type theorists in computer science to refer to computing paradigms which do not traverse the nodes of the program to assign each one of them a single unambiguous type before proceeding to execution.

It means Not True Scotsman Typed.

You can't think of it as "lacking type information"; watch out: that's a trap laid to reveal you as a n00b who doesn't speak the lingo.

flavio81Nov 25, 2026, 8:02 PM
Common Lisp is strongly typed.

I understand Clojure is strongly typed too.

lo_zamoyskiNov 25, 2026, 7:45 PM
Or as Bob Harper would say, unityped.
kazinatorNov 27, 2026, 6:22 PM
That is an ignorant concept which conflates the implementation level with the program's abstraction.

At the implementation level, there exist storage locations (which we might call "value cells"). These can hold any value and so in a sense they have one type.

The abstract nodes of the program, its expressions, have a type we can reason about. Often a single type that can be known without executing the program..

Static functional languages, too, have typeless value cells in their implementations: word-sized units of storage that can point to anything and may have type tags, gc bits and whatnot. The difference is that nodes of the abstract program are checked.

Dynamic languages have type inference implementations also. The situation is not so strict that an uncheckable program may not be executed, though.

articulatepangNov 25, 2026, 5:28 PM
Types have nothing to do with it. For example, the first bug in the article is about an infinite loop in a core data structure:

“[…] reduce it, the call never returns once the vector has 65505 or more elements.”

> These libs don't guarantee anything near to the level that a formal verification would suggest.

This is just plain wrong. A lisp library can absolutely make performance and correctness guarantees, and formal methods can refute or verify those guarantees. A type system is just a special kind of formal method that can rule out certain classes of bugs.

iorekzNov 25, 2026, 5:24 PM
I'm glad I checked your other comments! Beautiful counter bait
vegnusNov 25, 2026, 4:55 PM
[flagged]
embedding-shapeNov 25, 2026, 4:57 PM
Not sure what you understand "hammock-driven development" to be for, but it is not a tool meant for producing bug-free implementations.
gingersnapNov 25, 2026, 5:03 PM
Somebody woke up on the wrong side of the hammock
Perz1valNov 25, 2026, 5:56 PM
The underside? Ouch