r/functionalprogramming • • Jul 08 '25

Question why not Lisp/Haskell used for MachineLearning/AI

i have a course on topic of AI: Search Methods and it the instructor told about Lisp, found out it was a func-lang, also told about functions like car & cdr why in the real world of AI/ML func-langs aren't adopted more when they naturally transfom to operations like, map->filter->reduce->functions

am I missing something ?

56 Upvotes

66 comments sorted by

View all comments

Show parent comment

3

u/funbike Jul 10 '25 edited Jul 10 '25

You have such wonderful responses ITT.

However, couldn't these concepts be bridged? For example, Anthropic reverse engineered Claude and discovered it amazingly invented it's own calculator. It would be interesting to somehow patch a real caclulator at that point in the model. Of course tools / function calling can achive the same, but less efficiently.

Similar to the calculator a theorem prover embedded into the model would be immensely useful for math, category theory, software code generation, and problem solving. I experimented with Rocq (formerly Coq) to validate algorithms before generating Typescript source code, but there wasn't enough training for the LLM to produce correct Rocq/Coq syntax.

(I am not an academic. I just have a 30 year old CS degree)

3

u/OptimizedGarbage Jul 12 '25

Most commercial models these days do have access to some set of external tools and databases through RAG. Giving it access to Z3 or something could definitely be useful for some applications, although they can be pretty slow.

As far as integration with dependently typed languages for formally checking the results, there's a lot of interest in that. Being able to guarantee that anything that compiles is correct allows you to trial-and-error your way to good results, and also gives the model feedback that you can use to train it. I'm currently working on doing this for the Lean theorem prover.

3

u/funbike Jul 12 '25 edited Jul 12 '25

FYI, waaaay back in the late '90s I attempted to build a large product with Java/ESC, now OpenJML, which extended Java with design-by-contract annotations in comments (pre/post conditions and invariants).

Java/ESC converted code and contracts into a format that could be fed into the Simplify theorem prover. It found lots of real bugs, many of which were missed by code review and unit testing. (However, some were because java didn't yet have generics or an optional type).

One great thing is that it didn't require a PhD in computer science to use. You just coded in standard Java with some additional boolean checks.

In the end my effort failed. They didn't keep up with changes to Java, as they had written their own parser, rather than using an AST from a highly supported one. Also, I felt their tool lacked some practical ergonomics that would have made it less of a pain to use. The biggest one would be a way to specify if a contract should be enforced during compile time or runtime.

I never forgot how effective that tool was. Now that this AI explosion is happening, I can see how it could be used to assist LLMs at creating correct code.